@wrongstack/webui 0.280.0 → 0.281.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 (68) hide show
  1. package/dist/assets/AnalyticsDashboard-uYxJjohK.js +1 -0
  2. package/dist/assets/AutoPhaseView-DG8bm0_l.js +1 -0
  3. package/dist/assets/CodeEditor-DLzmCqWF.js +1 -0
  4. package/dist/assets/DebugDashboard-D6-znhBO.js +1 -0
  5. package/dist/assets/DesignGalleryView-CtA0fPrm.js +1 -0
  6. package/dist/assets/MailboxDetailView-2_R4qJn-.js +1 -0
  7. package/dist/assets/OfficeMapPanel-BNZNbZik.js +4 -0
  8. package/dist/assets/ProcessMonitor-DgEXCx7y.js +1 -0
  9. package/dist/assets/QueuePanel-DL8SvR30.js +1 -0
  10. package/dist/assets/RefreshDebugView-pmMPOier.js +1 -0
  11. package/dist/assets/SddBoardView-CFhQv9Pv.js +2 -0
  12. package/dist/assets/SddFlowGraph-WW0qCx0t.js +1 -0
  13. package/dist/assets/SddWizard-Cnksg4-y.js +1 -0
  14. package/dist/assets/SessionsDashboard-VwXvmSxS.js +1 -0
  15. package/dist/assets/SkillDetailView-C1qcnlPI.js +2 -0
  16. package/dist/assets/SpecsView-BY7LKawq.js +1 -0
  17. package/dist/assets/TerminalPanel-Dq0Xdhdv.js +1 -0
  18. package/dist/assets/activity-DT93tsyC.js +5 -0
  19. package/dist/assets/chat-DCAGDU3F.js +1 -0
  20. package/dist/assets/chat-store-YPRVJGbn.js +5 -0
  21. package/dist/assets/commandPalette-DUootORZ.js +1 -0
  22. package/dist/assets/common-D7usadq4.js +1 -0
  23. package/dist/assets/i18n-BJCOtLro.js +2 -0
  24. package/dist/assets/index-CMiinLaB.css +1 -0
  25. package/dist/assets/index-DJpDzI2b.js +145 -0
  26. package/dist/assets/markdown-D0X23O-i.js +44 -0
  27. package/dist/assets/monaco-Br_kD0ds.css +1 -0
  28. package/dist/assets/monaco-DqY9Mr3N.js +1211 -0
  29. package/dist/assets/session-store-Do0MGnXu.js +1 -0
  30. package/dist/assets/settings-CGhOOFpI.js +1 -0
  31. package/dist/assets/setup-B8S3Rhsj.js +1 -0
  32. package/dist/assets/setup-BPkWK-DE.js +1 -0
  33. package/dist/assets/setup-BqoJ89VQ.js +1 -0
  34. package/dist/assets/setup-C4wNoopG.js +1 -0
  35. package/dist/assets/setup-CGWbN6bj.js +1 -0
  36. package/dist/assets/setup-Dr2UDb8s.js +1 -0
  37. package/dist/assets/setup-Iyk4ncan.js +1 -0
  38. package/dist/assets/toasts-BL_8kH4B.js +1 -0
  39. package/dist/assets/ui-store-D3gGpJWY.js +1 -0
  40. package/dist/assets/utils-sFCTikqz.js +1 -0
  41. package/dist/assets/vendor-Bhf0nZ3B.js +70 -0
  42. package/dist/assets/vendor-CcOzUMQS.css +1 -0
  43. package/dist/assets/ws-client-D9IQ9580.js +1 -0
  44. package/dist/assets/xterm-B9RXJkIu.js +36 -0
  45. package/dist/assets/xterm-BrP-ENHg.css +1 -0
  46. package/dist/assets/xyflow-Bp8EMwkC.js +7 -0
  47. package/dist/assets/xyflow-DtxX27Jz.css +1 -0
  48. package/dist/index.css +247 -0
  49. package/dist/index.css.map +1 -1
  50. package/dist/index.html +20 -4
  51. package/dist/index.js +31866 -30427
  52. package/dist/index.js.map +1 -1
  53. package/dist/server/entry.js +119 -44
  54. package/dist/server/entry.js.map +1 -1
  55. package/dist/server/index.js +119 -44
  56. package/dist/server/index.js.map +1 -1
  57. package/dist/types.d.ts +7 -1
  58. package/package.json +6 -13
  59. package/dist/assets/index-BMDGZBnY.css +0 -2
  60. package/dist/assets/index-Ci_SxQGe.js +0 -157
  61. package/dist/assets/setup-B5TfeR6q.js +0 -1
  62. package/dist/assets/setup-BBwNpiE3.js +0 -1
  63. package/dist/assets/setup-BT2iTMm4.js +0 -1
  64. package/dist/assets/setup-CVMjqrZh.js +0 -1
  65. package/dist/assets/setup-DOXm3hFc.js +0 -1
  66. package/dist/assets/setup-Dhb_xOpk.js +0 -1
  67. package/dist/assets/vendor-B_dTeUDT.js +0 -1364
  68. package/dist/assets/vendor-C3aCZA5Q.css +0 -1
@@ -1,157 +0,0 @@
1
- import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{$ as n,$n as r,$r as i,$t as a,A as o,An as s,Ar as c,At as l,B as u,Bn as d,Br as f,Bt as p,C as m,Ci as h,Cn as g,Cr as _,Ct as v,D as y,Di as b,Dn as x,Dr as S,Dt as C,E as w,Ei as T,En as E,Er as D,Et as O,F as k,Fn as A,Fr as j,Ft as M,G as N,Gn as P,Gr as F,Gt as I,H as L,Hn as R,Hr as ee,Ht as te,I as ne,In as re,Ir as ie,It as ae,J as oe,Jn as se,Jr as ce,Jt as le,K as ue,Kn as de,Kr as fe,Kt as pe,L as me,Ln as he,Lr as ge,Lt as _e,M as ve,Mn as ye,Mr as z,Mt as be,N as xe,Nn as Se,Nr as Ce,Nt as we,O as Te,Oi as Ee,On as De,Or as Oe,Ot as ke,P as Ae,Pn as je,Pr as Me,Pt as Ne,Q as Pe,Qn as Fe,Qr as Ie,Qt as Le,R as Re,Rn as ze,Rr as Be,Rt as Ve,S as He,Si as Ue,Sn as We,Sr as Ge,St as Ke,T as qe,Ti as Je,Tn as Ye,Tr as Xe,Tt as Ze,U as Qe,Un as $e,Ur as et,Ut as tt,V as nt,Vn as rt,Vr as it,Vt as at,W as ot,Wn as st,Wr as ct,Wt as lt,X as ut,Xn as dt,Xr as ft,Xt as pt,Y as mt,Yn as ht,Yr as gt,Yt as _t,Z as vt,Zn as yt,Zr as bt,Zt as xt,_ as St,_i as Ct,_n as wt,_r as Tt,_t as Et,a as Dt,ai as Ot,an as kt,ar as At,at as jt,b as Mt,bi as Nt,bn as Pt,br as Ft,bt as It,c as Lt,ci as Rt,cn as zt,cr as Bt,ct as Vt,d as Ht,di as Ut,dn as Wt,dr as Gt,dt as Kt,ei as qt,en as Jt,er as Yt,et as Xt,f as Zt,fi as Qt,fn as $t,fr as en,ft as tn,g as nn,gi as rn,gn as an,gr as on,gt as sn,h as cn,hi as ln,hn as un,hr as dn,ht as fn,i as pn,ii as mn,in as hn,ir as gn,it as _n,j as vn,jn as yn,jr as bn,jt as xn,k as Sn,ki as Cn,kn as wn,kr as Tn,kt as En,l as Dn,li as On,ln as kn,lr as An,lt as jn,m as Mn,mi as Nn,mn as Pn,mr as Fn,mt as In,n as Ln,ni as B,nn as Rn,nr as zn,nt as Bn,o as Vn,oi as Hn,on as Un,or as Wn,ot as Gn,p as Kn,pi as qn,pn as Jn,pr as Yn,pt as Xn,q as Zn,qn as Qn,qr as $n,qt as er,r as tr,ri as nr,rn as rr,rr as ir,rt as ar,s as or,si as sr,sn as cr,sr as lr,st as ur,t as dr,ti as fr,tn as pr,tr as mr,tt as hr,u as gr,ui as _r,un as vr,ur as yr,ut as br,v as xr,vi as Sr,vn as Cr,vr as wr,vt as Tr,w as Er,wi as V,wn as Dr,wr as Or,wt as kr,x as Ar,xi as H,xn as jr,xr as Mr,xt as Nr,y as Pr,yi as Fr,yn as Ir,yr as Lr,yt as Rr,z as zr,zn as Br,zr as Vr,zt as Hr}from"./vendor-B_dTeUDT.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function Ur(e,t){if(e==null){let e=Error(t?`Expected ${t} to be defined`:`Expected value to be defined`);throw e.name=`ExpectDefinedError`,e}return e}function Wr(e,t){let n=e=>e.trim().replace(/\s+/g,` `).toLowerCase();return n(e)===n(t)}function Gr(e){return e instanceof Error?e.message:String(e)}var U=t(Cn(),1),Kr=t(Ee(),1),qr=(e,t,n)=>{let r=t.lastIndexOf(`?`),i=e[r===-1||r<t.lastIndexOf(`/`)?t:t.slice(0,r)];return i?typeof i==`function`?i():Promise.resolve(i):new Promise((e,r)=>{(typeof queueMicrotask==`function`?queueMicrotask:setTimeout)(r.bind(null,Error(`Unknown variable dynamic import: `+t+(t.split(`/`).length===n?``:`. Note that variables only represent file names one level deep.`))))})},Jr=[`en`,`tr`,`de`,`fr`,`it`,`es`,`pt-BR`],Yr=[{code:`en`,name:`English`},{code:`tr`,name:`Türkçe`},{code:`de`,name:`Deutsch`},{code:`fr`,name:`Français`},{code:`it`,name:`Italiano`},{code:`es`,name:`Español`},{code:`pt-BR`,name:`Português (Brasil)`}],Xr=new Set(Jr);function Zr(){return typeof navigator>`u`||!navigator.language?`en`:$r(navigator.language)}function Qr(e){return!e||typeof e!=`string`?Zr():$r(e)}function $r(e){let t=e.trim().toLowerCase();if(!t)return`en`;if(Xr.has(t))return t;let n=t.split(`-`)[0];return n&&Xr.has(n)?n:n===`pt`?`pt-BR`:`en`}var ei={autonomy:`auto`,autonomyDelayMs:45e3,autoProceedMaxIterations:50,yolo:!0,maxIterations:500,chime:!1,confirmExit:!0,streamFleet:!0,nextPrediction:!1,fallbackModels:[],fallbackProfiles:{},favoriteModels:[],favoriteModelsOnly:!1,modelMatrix:{},fallbackAuto:!0,featureMcp:!0,featurePlugins:!0,featureMemory:!0,featureSkills:!0,featureModelsRegistry:!0,indexOnStart:!0,contextAutoCompact:!0,contextStrategy:`hybrid`,contextMode:`balanced`,tokenSavingTier:`off`,maxConcurrent:10,titleAnimation:!0,logLevel:`info`,auditLevel:`standard`,enhanceEnabled:!0,enhanceDelayMs:6e4,enhanceLanguage:`original`,reasoningMode:`auto`,reasoningEffort:`high`,reasoningPreserve:!1,cacheTtl:`default`,hqEnabled:!1,hqUrl:``,hqToken:``,hqRawContent:!1,tgConfigured:!1,tgSessionEnd:!1,tgDelegate:!0,tgLongToolMs:3e4,uiLocale:Zr()},ti=h()(Ue(e=>({...ei,set:t=>e(t),reset:()=>e(ei)}),{name:`wrongstack-local-prefs`,version:5,migrate:e=>{let t=e??{};return[`hybrid`,`intelligent`,`selective`].includes(t.contextStrategy)||(t.contextStrategy=`hybrid`),t.auditLevel===`verbose`&&(t.auditLevel=`full`),[`minimal`,`standard`,`full`].includes(t.auditLevel)||(t.auditLevel=`standard`),typeof t.autoProceedMaxIterations!=`number`&&(t.autoProceedMaxIterations=50),(!t.fallbackProfiles||typeof t.fallbackProfiles!=`object`||Array.isArray(t.fallbackProfiles))&&(t.fallbackProfiles={}),Array.isArray(t.favoriteModels)||(t.favoriteModels=[]),typeof t.favoriteModelsOnly!=`boolean`&&(t.favoriteModelsOnly=!1),(!t.modelMatrix||typeof t.modelMatrix!=`object`||Array.isArray(t.modelMatrix))&&(t.modelMatrix={}),(typeof t.uiLocale!=`string`||!t.uiLocale)&&(t.uiLocale=Zr()),t}})),ni=e({agents:()=>li,agentsMonitor:()=>Ti,analytics:()=>ya,autoPhase:()=>Ni,autonomy:()=>Qi,board:()=>xi,brand:()=>ii,changes:()=>ui,checkpoint:()=>ea,codeEditor:()=>va,collab:()=>Pi,connection:()=>Fi,context:()=>_i,cost:()=>Li,ctxMode:()=>Xi,debug:()=>Si,default:()=>Oa,design:()=>Mi,designStudio:()=>Ta,diff:()=>ia,dock:()=>wi,errorBody:()=>ca,fallback:()=>aa,fileExplorer:()=>_a,filePicker:()=>Ki,fileRef:()=>Wi,fleet:()=>gi,goal:()=>ta,history:()=>ci,inspector:()=>di,liveSessions:()=>oa,mailbox:()=>pi,menu:()=>oi,message:()=>da,mode:()=>Ii,model:()=>Ri,modelSwitcher:()=>zi,monacoDiff:()=>sa,monitor:()=>ki,nav:()=>ri,nextSteps:()=>fi,office:()=>Sa,officeMap:()=>la,officeSettings:()=>Da,phase:()=>Yi,plan:()=>Gi,process:()=>ra,promptLib:()=>ba,providerModels:()=>Ci,queue:()=>$i,refine:()=>vi,refresh:()=>bi,sdd:()=>Ai,sddBoard:()=>ma,sddTask:()=>ha,sddWizard:()=>ga,search:()=>Ji,sessionPanel:()=>hi,sessionWatch:()=>Di,sessions:()=>mi,shortcuts:()=>pa,sideEffects:()=>Oi,sidePanel:()=>si,skillDetail:()=>xa,skillsList:()=>Ca,specs:()=>yi,status:()=>ai,task:()=>Hi,terminal:()=>Ei,timeline:()=>wa,toast:()=>qi,todos:()=>Vi,toolGroup:()=>Ui,toolInput:()=>ua,toolResult:()=>ji,transcript:()=>Zi,watch:()=>fa,work:()=>Bi,worktree:()=>na,worktrees:()=>Ea}),ri={chat:`Session`,agents:`Agents`,history:`History`,files:`Files`,changes:`Changes`,mailbox:`Mailbox`,skills:`Skills`,worktrees:`Worktrees`,design:`Design Studio`,officemap:`Office Map`,settings:`Settings`,sddwizard:`New SDD Project`,specs:`Specs`,sddboard:`Live Board`,autophase:`Phases`,fleet:`Fleet`,inspector:`Inspector`,prompts:`Prompts`},ii={returnToChat:`{{name}} — return to chat`,returnToChatDefault:`WrongStack — return to chat`},ai={connected:`Connected`,disconnected:`Disconnected`,idle:`Idle`,thinking:`Thinking`,running:`Running`,waiting:`Waiting`,done:`Done`,stopped:`Stopped`},oi={moreWithHidden:`More, {{count}} hidden items`,moreOptions:`More options`,moreCompactHidden:`More — {{count}} hidden panels/views, palette, theme, monitors`,moreCompact:`More — palette, theme, monitors`,moreFull:`More — palette, theme, shortcuts, monitors`,commandPalette:`Command Palette`,keyboardShortcuts:`Keyboard Shortcuts`,panels:`Panels`,views:`Views`,theme:`Theme`,monitors:`Monitors`,fleetMonitor:`Fleet Monitor`,agentsMonitor:`Agents Monitor`},si={dragHint:`Drag to resize · double-click to reset`,collapse:`Collapse panel (Ctrl+\\)`},ci={openDashboard:`Open sessions dashboard`},li={pending:`pending…`,empty:`No agents yet`,emptyHint:`Subagents appear here when the fleet is active.`,runningCount:`{{count}} running`,totalCount:`{{count}} total`,openFull:`Open full agents view`,agentsLive:`AGENTS · LIVE`,doneCount:`{{count}} done`,failedCount:`{{count}} failed`,modelsLabel:`models`,shownLabel:`shown`,totalLabel:`total`,leaderFleetTotals:`(leader {{leader}} · fleet {{fleet}})`,navHintJk:`j/k or ↑↓ to navigate`,escCloseDetail:`· Esc to close detail`,noAgentsRunning:`No agents running.`,contextUsage:`Context Usage`,lastToolLabel:`last:`,unknownSession:`Unknown session`,sessionCopyTitle:`Session: {{sid}} — click to copy ID`,sessionWord:`session`,agentsCountSuffix_one:`{{count}} agent`,agentsCountSuffix_other:`{{count}} agents`,sessionTitle:`Session: {{sid}}`,projectSuffix:` · Project: {{name}}`,statusIdle:`idle`},ui={fileCount_one:`{{count}} file`,fileCount_other:`{{count}} files`,refreshTitle:`Refresh changes`,loading:`Loading changes…`,clean:`No changes — working tree is clean.`,selectPrompt:`Select a changed file to view its diff.`,unified:`Unified`,unifiedTitle:`Unified diff`,edit:`Edit`,editTitle:`Side-by-side editable diff`,loadingDiff:`Loading diff…`,binary:`Binary file — diff not shown.`,tooLarge:`File too large to diff.`},di={showPanel:`Show inspector panel (Fleet / Agents / Audit)`,hidePanel:`Hide inspector panel`,label:`Inspector`,openAudit:`Open Audit tab`,tabFleet:`Fleet`,tabAgents:`Agents`,tabAudit:`Audit`,collapseAria:`Collapse inspector panel`,collapseTitle:`Collapse (Esc)`,noAgentsActive:`No agents active`,agentsAppearHint:`Agents appear here when the fleet is active.`,selected:`{{name}} (selected)`},fi={header:`Next steps`,autoSubmitting:`auto-submitting in`,clickToFill:`click to fill input`,clickToFillTitle:`Click to fill: {{text}}`,auto:`auto`,willAutoSubmit:`Will auto-submit after countdown`},pi={onlineCount:`{{count}} online`,messages:`Messages`,deleteAllTitle:`Delete all messages`,deleteAll:`Delete all`,deleting:`Deleting…`,purgeTitle:`Purge stale/orphaned messages`,purge:`Purge`,purging:`Purging…`,newLabel:`NEW`,empty:`No messages yet.`,offlineCount:`+{{count}} offline`,timeNow:`now`,deleteAllConfirmTitle_one:`Delete {{count}} message?`,deleteAllConfirmTitle_other:`Delete all {{count}} messages?`,deleteAllConfirmBody:`The mailbox file is truncated for every agent. This cannot be undone.`,purgeConfirmTitle:`Purge stale messages?`,purgeConfirmBody:`Removes completed messages older than 1 day and incomplete messages older than 7 days. Active messages are preserved.`,type:{note:`Note`,ask:`Question`,assign:`Assignment`,steer:`Steer`,btw:`By the way`,broadcast:`Broadcast`,status:`Status`,result:`Result`},emptyDetail:`No message selected`,emptyDetailHint:`Click a message in the Mailbox panel to view it here.`,readBy:`Read by`,backToChat:`Back to chat`,completed:`Completed`,everyone:`everyone`,closeTitle:`Close (Esc)`,replyTo:`In reply to: {{id}}`,completedBy:`Completed by {{name}}`,completedByAt:`Completed by {{name}} at {{time}}`,outcome:`Outcome:`,task:`Task:`,messageNotFound:`Message not found`,messageNotFoundHint:`This message may have been deleted or purged.`},mi={recentSessions:`Recent sessions`,deleteEmptyTitle_one:`Delete {{count}} empty session?`,deleteEmptyTitle_other:`Delete {{count}} empty sessions?`,deleteEmptyConfirmBody:`Sessions without any token usage are removed from disk.`,filterPlaceholder:`Filter title, model, provider…`,clearFilter:`Clear filter`,noHistory:`No history yet`,noHistoryHint:`Your conversations will appear here`,noMatches:`No matches`,noMatchesHint:`Try a different filter`,group:{favorites:`Favorites`,today:`Today`,yesterday:`Yesterday`,thisWeek:`This week`,earlier:`Earlier`},nicknamePlaceholder:`Nickname`,empty:`(empty)`,resuming:`resuming…`,active:`active`,renameTitleNickname:`{{nickname}} — original: {{title}}`,renameTitle:`{{title}}
2
-
3
- Double-click to rename`,unfavorite:`Unfavorite`,markFavorite:`Mark as favorite`,deleteSessionConfirmTitle:`Delete session?`,deleteSessionConfirmBody:`"{{name}}" will be removed from disk. This cannot be undone.`,deleteSessionTitle:`Delete session`},hi={actions:{abort:`Abort`,newSession:`New session`,export:`Export`,compact:`Compact`,newSessionTitle:`Start a new session (Ctrl+N)`,exportTitle:`Export chat as markdown (Ctrl+E)`,compactTitle:`Compact the context window`,clearTitle:`Clear context (Ctrl+L)`},model:`Model`,modelTitle:`Change model (Ctrl+M)`,context:`Context`,contextTitle:`Click for a context breakdown`,sessionLabel:`Session`,stats:{messages:`Messages`,elapsed:`Elapsed`,tokens:`Tokens`,cost:`Cost`,iteration:`Iteration`,agents:`Agents`,tokensSub:`{{in}} in / {{out}} out`,iterationOf:`of {{max}}`,agentsRunning:`{{count}} running`},plan:`Plan`,planComplete:`{{pct}}% complete`,pinned:`Pinned`,quickSettings:`Quick settings`,autonomy:`Autonomy`,autonomyOptions:{off:`Off`,suggest:`Suggest`,auto:`Auto`,eternal:`Eternal`,"eternal-parallel":`Eternal Parallel`},yolo:`YOLO mode`,yoloTitle:`Bypass tool confirmation prompts`,refine:`Refine prompts`,refineTitle:`Rewrite prompts before sending`,sound:`Sound on completion`,soundTitle:`Play a soft chime when a run finishes`,sessionId:`session {{id}}`},gi={status:{running:`running`,done:`done`,failed:`failed`,timeout:`timeout`,stopped:`stopped`},leader:`leader`,providerModel:`Provider / Model`,elapsed:`Elapsed`,running:`running…`,iterations:`Iterations`,toolCalls:`Tool Calls`,cost:`Cost`,budgetExtensions:`Budget Extensions`,activity:`Activity`,budgetWarning:`budget warning`,contextWindow:`Context window`,tokensUsed:`{{used}} / {{max}} tokens`,toolRunning:`running…`,lastTool:`last tool`,error:`Error`,finalOutput:`Final Output`,copyOutput:`Copy output`,liveOutput:`Live Output`,waitingOutput:`Waiting for output…`,outputHint:`Output appears here as the agent streams text.`,toolLog:`Tool Log ({{count}} calls)`,fail:`fail`,moreTools:`+{{count}} more tools`,cardRunning:`running {{tool}}`,cardLastTool:`last: {{tool}}`,contextPercent:`Context {{pct}}%`,doneCount:`{{count}} done`,errCount:`{{count}} err`,statusRunning:`running`,statusDone:`done`,statusFailed:`failed`,statusTimeout:`timeout`,statusStopped:`stopped`,sessionPrefix:`session:`,currentTask:`Current Task`,performance:`Performance`,uniqueTools:`Unique Tools`,avgPerTool:`avg {{ms}}ms per tool`,context:`Context`,tokens:`Tokens`,ctxUsed:`{{pct}}% used`,completed:`completed`,budgetWarningTitle:`⚡ Budget Warning`,hittingLimit:`Hitting {{kind}} limit ({{used}}/{{limit}})`,hittingLimitTitle:`⚡ hitting {{kind}} limit ({{used}}/{{limit}})`,budgetExt_one:`{{count}} Budget Extension`,budgetExt_other:`{{count}} Budget Extensions`,extendedTimes_one:`Agent extended its budget {{count}} time due to long-running tasks`,extendedTimes_other:`Agent extended its budget {{count}} times due to long-running tasks`,errorLabel:`Error`,failureReason:`Failure Reason`,failed:`Failed`,fleetMonitor:`FLEET MONITOR`,runningCount:`{{count}} running`,totalAgents_one:`{{count}} total agent`,totalAgents_other:`{{count}} total agents`,noLeader:`no leader`,closeFleet:`Close fleet monitor`,colName:`Name`,colStatus:`Status`,colActivity:`Activity`,colIters:`Iters`,colTools:`Tools`,colCost:`Cost`,colCtx:`CTX`,colExt:`Ext`,colReason:`Reason`,noAgentsActive:`No agents active`,agentsAppear:`Agents appear here when the fleet is active.`,agentTimeline:`Agent Timeline`,noAgentEvents:`No agent conversation events yet.`,navHint:`↑↓ navigate`,selectDetailHint:`↵ select detail`,escHint:`Esc deselect / close`,detailedView:`detailed view`,closeBtn:`✕ close`,selectAgentDetail:`Select an agent to view detailed information`,selectAgentBody:`Click on any agent in the list to see detailed metrics, tool logs, streaming output, and more — similar to the chat history detailed view.`,navigateWord:`navigate`,selectWord:`select`,deselectWord:`deselect`},_i={wsNotConnected:`WebSocket not connected`,noData:`No debug data received. The server may not support context debugging.`,title:`Context Breakdown`,windowUsage:`Window Usage`,contextMode:`Context Mode`,fetching:`Fetching context breakdown…`,systemPrompt:`System Prompt`,tools:`Tools`,messages:`Messages`,tokenAllocation:`Token Allocation`,systemTitle:`System: {{tokens}}`,toolsTitle:`Tools: {{tokens}}`,messagesTitle:`Messages: {{tokens}}`,system:`System`,toolBreakdown:`Tool Breakdown`,messagesSummary:`Messages ({{count}}) — {{total}} tok`,barWithTokens:`Context window: {{tokens}} / {{max}} tokens ({{pct}})`,barPct:`Context window: {{pct}}`,barClick:` — click for breakdown`},vi={header:`✨ Refine Prompt`,autoSend:`auto-send in {{count}}s`,cancelTitle:`Cancel (Esc)`,editLabel:`Edit refined prompt:`,editPlaceholder:`Edit the refined prompt...`,useEdit:`Use Edit`,original:`Original`,refined:`Refined`,yourLanguage:`(your language)`,refinedTitle:`Click or press Enter to use this version`,english:`English`,englishTitle:`Press e to use English version`,hintRefined:`refined`,hintEnglish:`English`,hintOriginal:`original`,hintEdit:`edit`,edit:`Edit`,useRefined:`Use Refined`},yi={heading:`Specifications`,subtitle:`View and manage specification-driven development`,empty:`No specs found. Use {{command}} to create one.`,tasks:`Tasks ({{count}})`,doneCount:`{{count}} done`,runningCount:`{{count}} running`,pendingCount:`{{count}} pending`,runTitle:`Run this spec as a live AutoPhase board`,run:`Run`,list:`List`,graph:`Graph`,loadingTasks:`Loading tasks…`},bi={heading:`F5 Resilience Verifier`,subtitle:`Confirms the latest active session, transcript, and UI state survive a page refresh. Open this view, then press F5 — every green row should remain green.`,recordProbe:`Record probe`,latestSession:`Latest active session`,restoredLocal:`Restored from localStorage`,sessionIdExtra:`session id: {{id}}`,noSessionYet:`no session has been started yet`,activePointer:`Active session pointer`,lastVisited:`lastVisitedAt timestamp`,never:`never`,persistedEnv:`Persisted environment`,transcriptRehydrate:`Chat transcript rehydration`,localTranscript:`Local transcript recovered`,messagesExtra:`{{count}} messages, {{queued}} queued`,noMessages:`0 messages`,noBleed:`No cross-session bleed`,bleedExtra:`bound={{bound}} vs active={{active}}`,transcriptBinds:`transcript binds to the active session`,uiWorkspace:`UI workspace`,noneValue:`(none)`,payloadSize:`localStorage payload (4 keys): {{count}} chars`,probeLog:`Probe log`,noProbes:`No probes yet — press the "Record probe" button at the top, or press F5 in this view, to record a rehydration check.`,simulatedF5:`simulated F5: re-running persist rehydrate`},xi={status:{pending:`Pending`,in_progress:`In Progress`,review:`Review`,failed:`Failed`,completed:`Done`,queued:`Queued`,blocked:`Blocked`,cancelled:`Cancelled`},newTaskTitle:`New task`,newTaskPlaceholder:`Task title…`,addTask:`Add task`,empty:`No phases yet — start an AutoPhase run to populate the board.`,summary:`{{phases}} phases · {{tasks}} tasks`,phases:`Phases`,statusTab:`Status`,dropHere:`Drop tasks here`,emptySpec:`No tasks in this spec yet.`,depGraphHeading:`Dependency Graph`,worktreePrefix:`worktree: {{branch}}`},Si={trendUp:`Increasing`,trendDown:`Decreasing`,trendStable:`Stable`,heading:`Debug Dashboard`,subtitle:`Real-time monitoring for WrongStack WebUI`,refreshLabel:`Refresh:`,lastUpdated:`Last updated: {{time}}`,fetchFailed:`Failed to fetch metrics`,fileWatcher:`File Watcher`,watcherStatus:`Watcher Status`,running:`Running`,stopped:`Stopped`,activeProjects:`Active Projects`,projectsWatched:`Projects being watched`,fileChanges:`File Changes`,totalDetected:`Total detected`,filesProcessed:`Files Processed`,afterHash:`After hash filter`,broadcastsSent:`Broadcasts Sent`,toClients:`To WebUI clients`,debounceResets:`Debounce Resets`,rapidWrites:`Rapid successive writes`,avgDebounce:`Avg Debounce Delay`,actualDelay:`Actual delay applied`,totalDelay:`Total Delay`,sumDelays:`Sum of all delays`,browserPerf:`Browser Performance`,heapUsed:`Heap Used`,jsHeap:`JavaScript heap`,heapTotal:`Heap Total`,totalHeap:`Total heap size`,pageUptime:`Page Uptime`,sinceLoad:`Since page load`,rawData:`Raw Data`},Ci={using:`Using`,noModelPicked:`(no model picked)`,clearAllowlist:`Clear allowlist`,clearAllowlistAria:`Clear saved allowlist for {{provider}}`,refresh:`Refresh from server`,refreshAria:`Refresh model list for {{provider}}`,probing:`Probing…`,use:`Use`,useModelAria:`Use model {{model}} for {{provider}}`,differsHint:`Probed list differs from the saved allowlist — re-run {{command}} to persist.`},wi={expandChip:`Expand {{label}}`,collapseChip:`Collapse {{label}}`,ahead:`{{count}} ahead`,behind:`{{count}} behind`,linesAdded:`{{count}} lines added`,linesDeleted:`{{count}} lines deleted`,untrackedFiles:`{{count}} untracked files`,customizeTitle:`Customize dock chips`,dockChips:`Dock chips`,noActiveGoal:`No active goal`,noActiveGoalDetail:`Start a goal from chat or the goal command.`},Ti={leaderBadge:`LEADER`,iters:`Iters`,tools:`Tools`,activityBins:`Activity (12 bins)`,streamingOutput:`Streaming output`,recentTools:`Recent tools`,finalOutput:`Final output`,heading:`Agents Monitor`,prevAgent:`Previous agent`,nextAgent:`Next agent`,closeAria:`Close agents monitor`,hintPage:`←→ page`,hintNavigate:`↑↓ navigate list`,hintEsc:`Esc close`},Ei={resize:`Resize terminals`,labelSingular:`Terminal`,labelPlural:`Terminals`,projectShell:`Project shell`,maxTerminals:`Maximum {{count}} terminals`,newTerminal:`New terminal`,restart:`Restart active terminal`,closeAll:`Close all terminals`,closeDock:"Close terminal dock (Ctrl+`)",closeTab:`Close {{name}}`,processExited:`[process exited with code {{code}}]`},Di={liveStream:`Live stream`,events_one:`{{count}} event`,events_other:`{{count}} events`,interruptTitle:`Cooperatively stop this agent at its next step (not a process kill)`,interrupt:`⏸ Interrupt`,interrupting:`…`,loading:`Loading session…`,done:`✓✓ done`,read:`✓ read`,delivered:`⏳ delivered`,agent:`Agent`,you:`You`,working:`{{name}} · working`,claude:`Claude`,priority:`Priority`,placeholder:`{{label}} → this session…`,send:`Send`,sendHint:`⌘/Ctrl+Enter to send · seen on the agent's next iteration`,msgType:{steerLabel:`🔄 Steer`,steerHint:`Adjust behavior mid-task`,askLabel:`❓ Ask`,askHint:`Question — expects a reply`,assignLabel:`📋 Assign`,assignHint:`A task to act on`,noteLabel:`💬 Note`,noteHint:`FYI, non-urgent`},sentRunning:`Delivered — the running agent sees it on its next step`,sentIdle:`Delivered — target is idle; appears in its mailbox, read when it next runs`,sentFailed:`Failed: {{error}}`,interruptReason:`Operator requested stop from Fleet HQ`,interruptSent:`Interrupt sent — agent stops at its next step (not a kill)`,interruptFailed:`Interrupt failed: {{error}}`},Oi={empty:`No side effects recorded yet.`,emptyHint:`Bash commands, package installs, and network requests will appear here.`,heading:`Side Effects`,exportTitle:`Export filtered side effects as CSV`,all:`All`,colTime:`Time`,colTool:`Tool`,colRisk:`Risk`,colDetail:`Detail`,colOutcome:`Outcome`},ki={elapsedHm:`{{h}}h {{m}}m ago`,elapsedMs:`{{m}}m {{s}}s ago`,elapsedS:`{{s}}s ago`,heading:`Fleet Monitor`,clientsHeading:`Connected Clients`,terminal:`Terminal`,webui:`Web UI`,repl:`REPL`,totalConnected:`total connected`,mailQueue:`Mail Queue`,total:`Total`,open:`Open`,unread:`Unread`,agents:`Agents`,messagesSub:`messages`,uncompletedSub:`uncompleted`,waitingSub:`waiting`,ofTotal:`of {{count}} total`,agentRoster:`Agent Roster`,liveMailActivity:`Live Mail Activity`,noActivity:`No recent activity`,mailboxAgents:`Mailbox Agents`,noMailboxAgents:`No agents registered`,moreCount:`+{{count}} more`,agentFallback:`agent`,fleetAgents:`Fleet Agents`,noFleetAgents:`No fleet agents running`,iter:`iter`,mailType:{sent:`Sent`,delivered:`Delivered`,read:`Read`,completed:`Completed`}},Ai={status:{pending:`pending`,queued:`queued`,in_progress:`running`,blocked:`blocked`,review:`review`,failed:`failed`,completed:`done`,cancelled:`cancelled`},activityHeading:`Activity`,feedEmpty:`Nothing yet — events appear here as agents pick up and finish tasks.`,destroyTitle:`Destroy SDD project?`,destroyDesc:`This wipes the run and its work. It cannot be undone (the optional commit revert is history-preserving).`,stopRun:`Stop the run`,stopRunAgents_one:`Stop the run ({{count}} agent working)`,stopRunAgents_other:`Stop the run ({{count}} agents working)`,removeWorktreesAll:`Remove all git worktrees + wstack/ap/* branches — including un-merged work`,removeWorktreesCount_one:`Remove {{count}} git worktree + wstack/ap/* branches — including un-merged work`,removeWorktreesCount_other:`Remove {{count}} git worktrees + wstack/ap/* branches — including un-merged work`,deleteArtifacts:`Delete all SDD artifacts (specs, task graph, board, session)`,revertMerged_one:`Also revert {{count}} merged commit`,revertMerged_other:`Also revert {{count}} merged commits`,revertHint:`Adds revert commits (history preserved). Refused if the working tree is dirty.`,baseBranchFallback:`the base branch`,noteLeaveMerged:`Merged commits will be left on the base branch. Tick the box above to undo them too.`,noteAbandon:`Make sure you really want to abandon this run.`,destroying:`Destroying…`,destroyAll:`Destroy everything`,kanbanBacklog:`Backlog`,kanbanReady:`Ready`,kanbanRunning:`Running`,kanbanReview:`Review`,kanbanFailed:`Failed`,kanbanDone:`Done`,kanbanEmpty:`empty`},ji={collapseToLines:`Collapse to first {{count}} lines`,showAllLines:`Show all {{total}} lines ({{more}} more)`,exitCode:`exit code:`,jsonLines:`JSON · {{count}} lines`,collapse:`collapse`,expand:`expand`},Mi={heading:`Design Studio — Gallery`,kitsCount:`{{count}} kits`,searchPlaceholder:`Search kits…`,stackTitle:`Stack for Use + Materialize`,wrote:`Wrote {{path}}`,materializeFailed:`Materialize failed: {{error}}`,verifyError:`Verify: {{error}}`,verifyOffPalette:`Verify: {{pct}}% on-palette — {{count}} off-palette in {{files}} file(s)`,verifyClean:`Verify: clean ✓ ({{files}} file(s) on-palette)`,writing:`Writing theme file…`,scanning:`Scanning UI files…`,active:`Active`,reapply:`Reapply`,use:`Use`,materializeTitle:`Write tokens to a {{stack}} theme file`,materialize:`Materialize`,verifyTitle:`Scan UI files for off-palette colors`,verify:`Verify`,colors:`Colors`},Ni={summary_one:`{{count}} phase · {{pct}}% complete`,summary_other:`{{count}} phases · {{pct}}% complete`,switchBoard:`Switch board`,boardsCount_one:`{{count}} board…`,boardsCount_other:`{{count}} boards…`,toggleAutonomousTitle:`Toggle autonomous mode`,autonomous:`Autonomous`,manual:`Manual`,resumeTitle:`Resume the run`,pauseTitle:`Pause the run`,resume:`Resume`,pause:`Pause`,stopTitle:`Stop the run — aborts in-flight agents immediately`,stop:`Stop`,newTitle:`Clear this board and start a new AutoPhase run`,newLabel:`New`,revertConfirm:`Revert run's commits?`,revertTitle:`Undo this run — git-revert the commits it landed and remove its worktrees`,revert:`Revert`,goal:`Goal`,planning:`Planning phases…`,planningBody:`Your goal was received. WrongStack is breaking it into phases and tasks — the board appears here the moment the plan is ready.`,startHeading:`Start a Phase Plan`,startBody:`Describe what you want to build. WrongStack will plan phases and tasks, then execute them — watch and steer the run on the board.`,startPlaceholder:`e.g. Build a REST API for user management with Express and SQLite...`,isolateLabel:`Isolate each phase in its own git worktree`,startButton:`Start AutoPhase`,ctrlHint:`Ctrl+Enter to start`,isolateOn:`phases run in isolated worktrees, squash-merged back`,isolateOff:`phases run directly on the current branch`,lanes:`Lanes`,graph:`Graph`,planningAck:`🚀 **AutoPhase** — got it. Planning phases for your goal now…`},Pi={noObservers:`No live observers`,observerTitle:`Join as a read-only observer (Phase 1)`,observerRole:`observer`,annotatorTitle:`Join as an annotator — leave inline notes on tool calls (Phase 2)`,annotatorRole:`annotator`,controllerTitle:`Join as a controller — can pause the agent loop (Phase 3)`,controllerRole:`controller`,errorPrefix:`Collab: {{error}}`,dismiss:`dismiss`,observers_one:`{{count}} observer`,observers_other:`{{count}} observers`,annotationsTitle:`{{count}} open annotation(s) — annotators reviewing this session`,notes_one:`{{count}} note`,notes_other:`{{count}} notes`,pausedTitle:`Agent loop is paused — a controller is reviewing`,paused:`paused`,joinedTitle:`Joined {{time}}`,grantTitle:`Grant control — promote this participant to controller`,injectTitle:`Inject a synthetic result for an in-flight tool call`,inject:`Inject`,resumeTitle:`Resume the agent loop`,resume:`Resume`,pauseTitle:`Pause the agent before the next tool call`,pauseAgent:`Pause agent`,leaveTitle:`Leave the observer session`,leave:`Leave`,injectToolResult:`Inject tool result`,close:`close`,targetTool:`Target tool_use id`,targetPlaceholder:`pick an in-flight call or type a tool_use id`,toolFallback:`tool`,noPendingTools:`No in-flight tool calls — type a tool_use id to pre-queue, or pause the agent first.`,resultContent:`Result content`,resultPlaceholder:`Synthetic tool result fed to the agent in place of running the tool`,markError:`mark as error`,reasonPlaceholder:`reason (audit log)`,queueInjection:`Queue injection`,controllerInjection:`controller injection`},Fi={reconnecting:`Reconnecting to backend (attempt {{attempt}}) — retrying in {{remaining}}s`,disconnected:`Disconnected from backend`,retry:`Retry now`,retryTitle:`Retry connection now`,dismissTitle:`Dismiss (chip in topbar still shows status)`},Ii={modePrefix:`mode:`,activeTitle:`Active mode`,heading:`Mode`,defaultName:`Default`,defaultDesc:`Standard agent behaviour`},Li={clickTitle:`Click for per-turn cost breakdown`,heading:`Cost breakdown`,noPricing:`No pricing for the current model — cost figures are zero.`,noTurns:`No completed turns yet. Run a prompt to see per-turn cost here.`,topExpensive_one:`Top {{count}} expensive turn`,topExpensive_other:`Top {{count}} expensive turns`},Ri={runDefault:`Run default`,useRunDefault:`Use run default`,filterPlaceholder:`Filter models…`,loading:`Loading models…`,noMatch:`No match`},zi={filterPlaceholder:`Filter providers and models…`,noSavedProviders:`No saved providers — register a key in Settings first.`,active:`active`},Bi={todos:`Todos`,tasks:`Tasks`,plan:`Plan`},Vi={toggleAria:`Toggle: {{content}}`,removeTitle:`Remove todo`,removeAria:`Remove "{{content}}"`,completedCount_one:`{{count}} completed`,completedCount_other:`{{count}} completed`},Hi={start:`Start`,complete:`Complete`,retry:`Retry`,assign:`Assign`,assignTitle:`Assign agent`,unassigned:`Unassigned`,statusPending:`Pending`,statusInProgress:`In Progress`,statusBlocked:`Blocked`,statusFailed:`Failed`,statusReview:`Review`,statusDone:`Done`,startTitle:`Start`,completeTitle:`Complete`,fail:`Fail`,failTitle:`Mark failed`,boardCount:`{{total}} tasks · {{done}} completed`},Ui={toolCalls_one:`{{count}} tool call`,toolCalls_other:`{{count}} tool calls`},Wi={removeTitle:`Remove reference`,linesCount_one:`{{count}} line`,linesCount_other:`{{count}} lines`},Gi={statusOpen:`Open`,statusInProgress:`In Progress`,statusDone:`Done`,startTitle:`Start`,doneTitle:`Mark done`,reopenTitle:`Reopen`,reopen:`Reopen`},Ki={heading:`@ Files`,noMatch:`No files match "{{query}}"`,searching:`Searching project…`},qi={dismiss:`Dismiss`},Ji={placeholder:`Search in chat…`,prevHit:`Previous hit`,nextHit:`Next hit`,close:`Close (Esc)`},Yi={statusPending:`Pending`,statusReady:`Ready`,statusRunning:`Running`,statusPaused:`Paused`,statusCompleted:`Completed`,statusFailed:`Failed`,statusSkipped:`Skipped`,heading:`Phases`,autonomousOn:`● Autonomous`,autonomousOff:`○ Manual`,autonomousOnTitle:`Autonomous mode active — click to pause`,autonomousOffTitle:`Manual mode — click to enable autonomous`,overallProgress:`Overall Progress`,tasksSuffix:`{{done}}/{{total}} tasks`,agentsSuffix_one:`{{count}} agent`,agentsSuffix_other:`{{count}} agents`},Xi={triggerTitle:`Context-window mode`,ctxPrefix:`ctx:`,opsHeading:`Context Operations`,compactNow:`Compact Now`,compactNowDesc:`Elide old tool output`,compactAggressive:`Compact Aggressive`,compactAggressiveDesc:`Maximum elision now`,repairContext:`Repair Context`,repairDesc:`Fix orphan tool-use blocks`,debugContext:`Debug Context`,debugDesc:`Size breakdown per section`,windowHeading:`Context Window`,keepElide:`keep {{k}} recent · elide {{t}}+ tokens`,fallbackName:`Balanced`,fallbackDesc:`Default rolling compaction`},Zi={kindAssistant:`Assistant`,kindThinking:`Thinking`,kindToolCall:`Tool call`,kindToolResult:`Tool result`,kindError:`Error`,kindStatus:`Status`,kindSystem:`System`,title:`Chat history`,copyTitle:`Copy agent chat history`,empty:`No chat history for this agent yet.`},Qi={heading:`Autonomy Mode`,titlePrefix:`Autonomy: {{label}}`,descOff:`Full manual control — agent waits for your input.`,descSuggest:`Agent suggests next steps but waits for approval.`,descAuto:`Agent auto-proceeds after brief confirmation delay.`,descEternal:`Agent runs autonomously until goal is complete.`,descEternalParallel:`Multi-agent autonomous execution — fleet mode.`},$i={heading:`Message Queue`,subtitle:`{{count}} queued · messages sent before the agent finishes`,btwTitle:`By-the-way — sent as follow-up without interrupting the running agent`,steerTitle:`Steer — interrupts the running agent and redirects it with this message`,queueTitle:`Queued — held until the current agent run completes, then sent in order`,sortNewestTitle:`Sorted newest first — click to sort oldest first`,sortOldestTitle:`Sorted oldest first — click to sort newest first`,newest:`Newest`,oldest:`Oldest`,clear:`Clear`,clearTitle:`Clear all queued messages`,closeTitle:`Close`,emptyTitle:`Queue is empty`,emptyBody:`Use the btw / steer / add queue buttons beside the input to add messages. Queued items are sent in order when the current agent run completes.`,removeTitle:`Remove from queue`,footer:`Messages are sent in arrival order when the current agent run completes. Use the sort toggle to view newest-first.`},ea={heading:`Session Checkpoints`,countSuffix_one:`{{count}} checkpoint`,countSuffix_other:`{{count}} checkpoints`,description:`Rewind the session to any checkpoint. Messages and file changes revert to that point — the LLM continues from there as if nothing happened after.`,emptyTitle:`No checkpoints yet`,emptyBody:`Checkpoints are automatically created each time you send a message. Send a few messages and come back.`,latest:`latest`,msgSuffix_one:`{{count}} msg`,msgSuffix_other:`{{count}} msgs`,footerPre:`Click any checkpoint to rewind`,footerPost:`to close`},ta={statusActive:`Active`,statusPaused:`Paused`,statusDone:`Done`,statusFailed:`Failed`,statusAbandoned:`Abandoned`,heading:`Goal`,refined:`Refined`,progress:`Progress`,iterations:`iterations`,deliverables:`Deliverables`,recentActivity:`Recent Activity`},na={cleanTitle_one:`Clean {{count}} orphaned worktree?`,cleanTitle_other:`Clean {{count}} orphaned worktrees?`,cleanMessage:`Force-removes every leftover git worktree + wstack/ap branch from previous runs. Un-merged work in them is discarded.`,cleanConfirm:`Clean orphans`,orphanCount_one:`{{count}} orphaned worktree from previous runs`,orphanCount_other:`{{count}} orphaned worktrees from previous runs`,andMore:`…and {{count}} more`,cleanButtonTitle:`Force-remove all orphaned worktrees + branches`,removed_one:`✓ Removed {{count}} orphaned worktree.`,removed_other:`✓ Removed {{count}} orphaned worktrees.`,cleanupFailed:`cleanup failed`,lanesHeading:`Worktrees`,base:`base`,isolatedCount_one:`{{count}} isolated`,isolatedCount_other:`{{count}} isolated`,statusAllocating:`allocating`,statusActive:`active`,statusCommitting:`committing`,statusMerging:`merging`,statusMerged:`merged`,statusConflict:`conflict`,statusFailed:`failed`,conflictBadge:`CONFLICT`,graphAria:`Worktree branch graph off {{base}}`,mergedLabel:`✓ merged → {{base}}`},ra={heading:`Running Processes`,subtitle:`{{active}} active · {{total}} total`,killAll:`Kill All`,emptyTitle:`No processes tracked`,emptyBody:`Processes appear here when the agent runs bash or exec tools. Active processes show a pulsing LED.`,pidLabel:`PID {{pid}}`,protected:`protected`,protectedTitle:`Protected — survives kill/killAll`,killTitle:`Kill PID {{pid}}`},ia={tooLarge:`Diff omitted (file too large to render inline).`},aa={placeholder:`Add a fallback model…`,emptyHint:`Tried in order when the primary model rate-limits or stalls.`,moveUp:`Move up`,moveDown:`Move down`,manualPlaceholder:`provider/model`,addTitle:`Add model reference`},oa={loading:`Loading sessions...`,apiUnavailable:`Session API unavailable:`,empty:`No live sessions. Open another wstack instance to see it here.`,heading:`Live Sessions ({{count}})`,autoRefresh:`auto-refresh every 5s`,pidLabel:`PID {{pid}}`,agentMeta:`{{iter}} iter · {{tools}} tools · {{ago}}`,andMore:`... and {{count}} more`,noAgents:`No agents`},sa={applyTitle:`Write the edited version back to disk`,applying:`Applying…`,applied:`Applied`,apply:`Apply`},ca={showStack_one:`Show stack trace ({{count}} frame)`,showStack_other:`Show stack trace ({{count}} frames)`,hideStack_one:`Hide stack trace ({{count}} frame)`,hideStack_other:`Hide stack trace ({{count}} frames)`},la={liveHeading:`Live`,clients:`Clients`,agents:`Agents`,model:`Model`,mode:`Mode`,toolCalls:`Tool calls`,displayHeading:`Display`,statsHud:`Stats HUD`,legends:`Legends`,minimap:`Minimap`,zoomControls:`Zoom controls`,animateWires:`Animate wires`,backgroundHeading:`Background`,bgDots:`Dots`,bgLines:`Lines`,bgCross:`Cross`,bgNone:`None`},ua={noParams:`(no params)`,itemCount_one:`{{count}} item`,itemCount_other:`{{count}} items`,keyCount_one:`{{count}} key`,keyCount_other:`{{count}} keys`},da={roleYou:`You`,roleTool:`Tool`,roleThinking:`Thinking`,roleAssistant:`Assistant`,inputLabel:`Input`,downloadTitle:`Download as file`,empty:`(empty)`,hideDetails:`Hide details`,showDetails:`Show details`,showDetailsLines_one:`Show details ({{count}} line)`,showDetailsLines_other:`Show details ({{count}} lines)`,editHint:`⌘/Ctrl+Enter to save · Esc to cancel`,saveResend:`Save & resend`,thinkingProcess:`Thinking process`,thinkingMeta:`iter {{iter}} · {{dur}} · {{lines}}`,replay:`replay`,linesSuffix_one:`{{count}} line`,linesSuffix_other:`{{count}} lines`,copyLog:`Copy log`,showFullLog:`Show full log`,typing:`Typing…`,noContent:`No content`,failedToSend:`⚠ Failed to send`,autoPaused:`⚠️ _Auto-proceed paused — maximum consecutive automatic turns reached. Type anything to continue (autonomy stays on)._`,rsIterations:`Iterations: {{n}}`,rsTools:`Tool calls: {{n}}`,rsElapsed:`Elapsed: {{s}}`,rsCost:`Cost: {{c}}`,useInput:`Input: {{n}}`,useOutput:`Output: {{n}}`,useCacheRead:`Cache read: {{n}}`,useCost:`Cost: {{c}}`,renderedLabel:`Rendered`,rawLabel:`Raw`,showRenderedTitle:`Show rendered markdown`,showRawTitle:`Show raw markdown source`,editTitle:`Edit & resend this prompt`,editLabel:`Edit`,unpinTitle:`Unpin`,pinTitle:`Pin this answer`,pinnedLabel:`Pinned`,pinLabel:`Pin`,regenerateTitle:`Regenerate this response`,retryLabel:`Retry`},fa={toolFallback:`tool`,toolFailed:`Tool failed`},pa={heading:`Keyboard shortcuts`,footerPre:`Press`,footerPost:`any time to reopen this list.`,sectionGlobal:`Global`,sectionTuiParity:`TUI Panel Parity`,sectionFleet:`Fleet & Agents`,sectionChatInput:`Chat input`,sectionChat:`Chat`,sectionChatNav:`Chat navigation (when not typing)`,dCommandPalette:`Open command palette`,dShowOverlay:`Show this shortcuts overlay`,dToggleSidebar:`Toggle sidebar`,dOpenPanel:`Open side panel (Session, Agents, History, Files, Changes, Mailbox, Skills, Office Map)`,dDesignStudio:`Open Design Studio side panel`,dWorktrees:`Open Worktrees side panel`,dFocusInput:`Focus the message input`,dSessionPanel:`Session panel`,dFleetOverlay:`Fleet monitor overlay`,dAgentsOverlay:`Agents monitor overlay`,dWorktreeMonitor:`Worktree monitor`,dPlanPanel:`Plan panel`,dTodosPanel:`Todos panel`,dQueuePanel:`Queue panel`,dProcessMonitor:`Process monitor`,dGoalPanel:`Goal panel`,dSessionsDashboard:`Sessions dashboard`,dOfficeMap:`Coordinator office map`,dDockPicker:`Dock chip picker`,dOpenFleet:`Open Fleet Monitor overlay`,dOpenAgents:`Open Agents Monitor overlay`,dNavigateAgents:`Navigate agents in monitor`,dSelectAgent:`Select focused agent`,dCloseOverlay:`Close active overlay`,dSendMessage:`Send message`,dNewline:`Insert a newline`,dRecallPrev:`Recall previous prompt (in empty input)`,dRecallNext:`Recall next prompt`,dSlashPopup:`Open slash command popup`,dAutocomplete:`Autocomplete highlighted command`,dDismissPopup:`Dismiss popup / clear input`,dSearchChat:`Search within current chat`,dClearContext:`Clear context (same as /clear)`,dNewSession:`Start a new session (same as /new)`,dExportMarkdown:`Export chat as markdown`,dModelSwitcher:`Quick model switcher overlay`,dCompactDensity:`Toggle compact UI density`,dAbortRun:`Abort the current run (when running)`,dFocusNext:`Focus next message (alias: ↓)`,dFocusPrev:`Focus previous message (alias: ↑)`,dJumpFirst:`Jump to first message`,dJumpLast:`Jump to last message`,dCopyFocused:`Copy focused message text`,dClearFocused:`Clear focused message`},ma={titleFallback:`Live SDD Board`,defaultModelTitle:`Run-level default worker model (per-task overrides take precedence)`,graphLabel:`Graph`,kanbanLabel:`Kanban`,retryAllTitle:`Requeue every failed task to pending`,retryFailed:`Retry failed ({{count}})`,resume:`Resume`,pause:`Pause`,stop:`Stop`,cleanTitle:`Remove the run's git worktrees + wstack/ap branches`,cleanWorktrees:`Clean worktrees`,rollbackTitle:`Revert {{count}} merged commit(s) on {{base}}`,rollback:`Rollback ({{count}})`,stopping:`Stopping…`,destroying:`Destroying…`,destroyTitle:`Stop, remove all worktrees, optionally revert merged commits, and delete the SDD project`,destroy:`Destroy`,statDone:`done`,statRunning:`running`,statFailed:`failed`,statWave:`wave`,statElapsed:`elapsed`,noActiveWorkers:`no active workers`,deadlock:`Deadlock — tasks blocked by failed work:`,noRunTitle:`No active SDD run.`,noRunBody:`Start one from the New SDD Project wizard, or via /sdd execute in the CLI — agents appear here live, each working an isolated worktree.`,clickTaskHint:`click a task for details`,lcClean:`Clean`,lcRollback:`Rollback`,lcDestroy:`Destroy`,lcFailed:`{{op}} failed: {{reason}}`,lcUnknownError:`unknown error`,lcWorktrees_one:`{{count}} worktree removed`,lcWorktrees_other:`{{count}} worktrees removed`,lcCommits_one:`{{count}} commit reverted`,lcCommits_other:`{{count}} commits reverted`,lcDeleted:`deleted {{items}}`,lcNothing:`nothing to do`,lcNote:`{{op}}: {{body}} — note: {{reason}}`,lcOk:`{{op}}: {{body}}`},ha={backTitle:`Back to activity`,workingOn:`working on this task`,assigned:`assigned`,metaPriority:`Priority`,metaType:`Type`,metaDuration:`Duration`,metaElapsed:`Elapsed`,metaRetries:`Retries`,metaWorktree:`Worktree`,workerModel:`Worker model`,runDefault:`run default: {{model}}`,runDefaultPlaceholder:`Run default`,runDefaultPlaceholderModel:`Run default ({{model}})`,verificationCmd:`Verification command`,gatesCompletion:`gates completion (exit 0)`,verifyPlaceholder:`e.g. pnpm vitest run path/to/file`,addVerify:`+ Add verification command`,description:`Description`,timeline:`Timeline`,dependsOn:`Depends on`,blocks:`Blocks`,newWorkerPlaceholder:`New worker name…`,confirmStop:`Stop this running task?`,confirmDelete:`Delete this task from the run?`,retryTitle:`Requeue this task to pending`,reassign:`Reassign`,stopTitle:`Abort the worker on this task`,splitTitle:`Split this task into sub-tasks delegated to separate workers`,split:`Split`,splitHint:`One sub-task per line — Title :: description (description optional)`,splitPlaceholder:`Write the data layer :: add the repository
4
- Wire the UI`,splitInto:`Split into sub-tasks`,deleteTitle:`Remove this not-started task from the run`},ga={phaseStart:`Start`,phaseInterview:`Interview`,phaseSpecReview:`Spec Review`,phasePlanning:`Planning`,phaseTaskReview:`Task Review`,phaseRunning:`Running`,phaseDone:`Done`,titleFallback:`New SDD Project`,questionsSuffix:`{{cur}}/{{max}} questions`,tasksSuffix:`{{count}} tasks`,runCfgTitle:`Run config — default model + fallback chain`,modelsLabel:`Models`,startRun:`Start Run`,defaultWorkerModel:`Default worker model`,leaderDefaultPlaceholder:`Leader / session default`,useSessionDefault:`Use session default`,fallbackChain:`Fallback chain`,appliesToAll:`Applies to every task. Override per-task from the live board after the run starts.`,parallelAgents:`Parallel agents`,isolateWorktrees:`Isolate in git worktrees`,worktreeOn:`Each task runs in its own worktree, squash-merged back on completion.`,worktreeOff:`Tasks run directly on the current branch (no isolation).`,goalPrompt:`What do you want to build?`,goalPlaceholder:`e.g. Add OAuth login (Google + GitHub) with session management`,startingInterview:`Starting interview…`,startInterview:`Start Interview`,introBody:`An isolated agent interviews you to build a spec, decomposes it into a dependency-ordered task graph, then a real multi-agent fleet executes it — watch live on the board.`,taskGraphSummary:`Task graph · {{count}} tasks, dependency-ordered`,dragToExplore:`drag to explore`,show:`show`,goalLabel:`Goal`,implementationPlan:`Implementation plan`,approveSpec:`Approve spec → plan implementation`,approveTasks:`Approve tasks`,approvePlan:`Approve plan`,answerPlaceholder:`Answer the question…`,changePlaceholder:`Request a change…`},_a={emptyDir:`empty`,loadFailed:`Failed to load files: {{error}}`,expandAllTitle:`Expand all directories`,expandAll:`Expand all`,collapseAllTitle:`Collapse all directories`,collapse:`Collapse`,folders_one:`{{count}} folder`,folders_other:`{{count}} folders`,currentDirTitle:`Current directory: {{path}}`,navigateToTitle:`Navigate to {{path}}`,filesSuffix_one:`{{count}} file`,filesSuffix_other:`{{count}} files`,goToDir:`go to dir`,navigateParentTitle:`Navigate to parent directory of {{path}}`,parentDirectory:`parent directory`,noFiles:`No files found`,copyAbsPath:`Copy absolute path`,copyRelPath:`Copy relative path`,openInTerminal:`Open in terminal`,openInFileManager:`Open in file manager`,mentionInChat:`Mention in chat`,copyPath:`Copy path`},va={sendSelectionAction:`Send selection to chat`,noFilesOpen:`No files open`,selectToEdit:`Select a file from the explorer to start editing`,sendSelectedTitle:`Send selected lines to chat`,mentionFileTitle:`Mention this file in chat`,sendToChat:`Send to chat`,mentionFile:`Mention file`,loadingEditor:`Loading editor…`,selectTab:`Select a tab to view its content`},ya={loading:`Loading analytics…`,heading:`Analytics Dashboard`,autoRefresh:`auto-refresh every 10s`,liveSessions:`Live Sessions`,agents:`Agents`,agentsActive:`{{count}} active`,totalEvents:`Total Events`,categoriesSub:`{{count}} categories`,toolCalls:`Tool Calls`,iterationsSub:`{{count}} iterations`,sessionCost:`Session Cost`,tokensSub:`{{input}} in / {{output}} out`,sessionDuration:`Session Duration`,messagesSub:`{{count}} messages`,eventsByCategory:`Events by Category`,noEvents:`No events recorded yet.`,topEvents:`Top Events`,activeSessionUsage:`Active Session Usage`,provider:`Provider`,model:`Model`,inputTokens:`Input Tokens`,outputTokens:`Output Tokens`,cacheRatio:`Cache Ratio`,filesRead:`Files Read`,noSession:`No active session or waiting for data…`,healthErrors:`Health & Errors`,errorEvents:`Error events`,warningEvents:`Warning events`,cacheHitRate:`Cache hit rate`,totalCategories:`Total categories`,waitingData:`Waiting for data…`,recentEvents:`Recent Events`,noRecentEvents:`No recent events. Interact with the UI to generate events.`},ba={searchPlaceholder:`Search prompts…`,newPrompt:`+ New prompt`,all:`All`,recent:`🕘 Recent`,favorites:`★ Favorites`,noMatch:`No prompts match.`,newPromptHeading:`New prompt`,titlePlaceholder:`Title *`,descPlaceholder:`One-line description`,categoryPlaceholder:`Category`,tagsPlaceholder:`tags, comma, separated`,contentPlaceholder:`Prompt content * — use {{name}} for variables`,variables:`Variables`,addVar:`+ var`,varNamePlaceholder:`name`,varDescPlaceholder:`description`,removeVarTitle:`Remove variable`,required:`required`,multiline:`multiline`,enumPlaceholder:`enum: a, b, c`,savePrompt:`Save prompt`,saveFailed:`Could not save the prompt.`,titleContentRequired:`Title and content are required.`,toggleFavoriteTitle:`Toggle favorite`,selectOption:`— select —`,fillMissing:`Fill: {{missing}}`,insertIntoChat:`Insert into chat`,selectPromptHint:`Select a prompt to preview and insert.`},xa={scopeProject:`Project`,scopeGlobal:`Global`,scopeBundled:`Bundled`,timeoutError:`Request timed out. Please try again.`,updateFailed:`Update failed`,saveFailed:`Save failed`,uninstallFailed:`Uninstall failed`,noSkillSelected:`No skill selected`,selectSkillHint:`Select a skill from the sidebar to view its documentation`,goToChat:`Go to chat`,openSourceRepo:`Open source repo`,copySourceUrl:`Copy source URL`,updatedLabel:`↑ Updated: {{list}}`,upToDateLabel:`— Up to date: {{list}}`,errorsLabel:`✗ {{list}}`,checkUpdatesTitle:`Check for updates`,exportTitle:`Export skill as .md`,editTitle:`Edit skill`,uninstallTitle:`Uninstall skill`,closeTitle:`Close and go to chat`,backTitle:`Go back`,forwardTitle:`Go forward`,relatedFiles:`Related Files`,references:`References`,goToSkillTitle:`Go to {{name}}`,loadingContent:`Loading skill content…`,editingLabel:`Editing {{name}}`,editStats:`{{lines}} lines · {{words}} words · {{chars}} chars`,charsWarningFmt:`⚠ {{used}} MB / {{limit}} MB`,draftSaved:`Draft saved`,draftRestored:`Draft restored`,discardDraft:`Discard draft`,splitViewTitle:`Split view`,hidePreviewTitle:`Hide preview`,contentPlaceholder:`Skill content (markdown)...`,loadFailed:`Failed to load skill content`,noContent:`No skill content available`,uninstallSkillHeading:`Uninstall Skill`,uninstallConfirm:`Uninstall {{name}}?`,uninstallRemovePath:`This will remove the skill from {{path}} and cannot be undone.`,uninstallAction:`Uninstall`},Sa={sessionStats:`Session Stats`,clients:`Clients`,input:`Input`,output:`Output`,cost:`Cost`,agentsSuffix:`agents`,upPrefix:`up {{time}}`,webuiClient:`WebUI Client`,disconnected:`Disconnected`,connected:`Connected`,tuiClient:`TUI Client`,terminal:`Terminal`,repl:`REPL`,coordinator:`COORDINATOR`,fleetSummary:`Fleet summary`,toolCallsLabel:`Tool calls`,tokensLabel:`Tokens`,coordinatingFleet:`Coordinating fleet`,donePrefix:`✓ done ·`,failedPrefix:`✕ failed ·`,seenPrefix:`seen {{time}}`,availableDesk:`Available desk`,mailboxHub:`Mailbox Hub`,unreadSuffix_one:`{{count}} unread`,unreadSuffix_other:`{{count}} unread`,allClear:`All clear`,total:`Total`,unreadLabel:`Unread`,liveActivity:`Live activity`,waitingActivity:`Waiting for activity…`,now:`now`,fleetHq:`WrongStack Fleet HQ`,live:`LIVE`,legendStatus:`Status`,legendActive:`Active`,legendIdle:`Idle`,legendError:`Error`,legendConnections:`Connections`,legendMail:`Mail`,legendTask:`Task`,legendStatusConn:`Status`,arrange:`Arrange`,arrangeTitle:`Snap nodes back to the floor plan`,feed:`Feed`,feedTitle:`Toggle the live activity feed`,broadcast:`Broadcast`,broadcastTitle:`Broadcast a message to every live session in this project`,broadcastToAll:`Broadcast to all sessions`,broadcastPlaceholder:`Message every live agent in this project…`,broadcastSendHint:`⌘/Ctrl+Enter to send`,openFullView:`Open full operation view`,rowStatus:`Status`,rowModel:`Model`,rowTool:`Tool`,rowIterations:`Iterations`,rowToolCalls:`Tool calls`,rowTokensIn:`Tokens in`,rowTokensOut:`Tokens out`,rowTokensTotal:`Tokens total`,rowContext:`Context`,rowCost:`Cost`,rowLastSeen:`Last seen`,rowSurface:`Surface`,rowBranch:`Branch`,rowPid:`PID`,rowDir:`Dir`,rowAgents:`Agents`,rowUptime:`Uptime`,rowConnections:`Connections`,rowTotalMessages:`Total messages`,rowUnread:`Unread`,recent:`Recent`,noSubject:`(no subject)`,fullOperationStream:`Full operation stream`,closeEsc:`Close (Esc)`,idleDesk:`Idle desk`,fleetHqLabel:`Fleet HQ`,clientsSuffix_one:`{{count}} client`,clientsSuffix_other:`{{count}} clients`,taskFallback:`task`,controlLabel:`control`},Ca={installTitle:`Install skill`,createTitle:`Create skill`,exportTitle:`Export all skills as .zip`,checkUpdatesTitle:`Check for updates (all skills)`,searchPlaceholder:`Search skills…`,loading:`Loading…`,noSkills:`No skills installed`,noMatch:`No skills match filter`,noDescription:`No description`,scopeForeign:`Foreign`,installHeading:`Install Skill`,installHint:`Enter a GitHub repository reference (owner/repo) or full URL.`,installPlaceholder:`e.g. wrongstack/skill-name or https://github.com/owner/repo`,installScope:`Install scope:`,installBtn:`Install`,installedMsg:`Installed: {{names}}`,installFailed:`Installation failed`,createHeading:`Create Skill`,createHint:`Scaffold a new skill. The first line is the trigger; additional lines form the description.`,nameLabel:`Name`,namePlaceholder:`e.g. my-new-skill`,descLabel:`Description / Trigger`,descPlaceholder:`Use this skill when <trigger situation>.
5
- Triggers: user says "keyword", "another".`,saveIn:`Save in:`,createBtn:`Create Skill`,createdMsg:`Created: {{name}}`,createFailed:`Creation failed`},wa={noEvents:`No events yet.`},Ta={pickHint:`Pick a kit — the agent will adhere to it.`,gallery:`Gallery`,galleryTitle:`Open live preview gallery`,stackTitle:`Target stack`,loading:`Loading kits…`,notFound:`No design kits found.`,bestFor:`Best for:`,light:`Light`,dark:`Dark`},Ea={detached:`(detached)`,count_one:`{{count}} worktree`,count_other:`{{count}} worktrees`,baseSuffix:` · base {{base}}`,baseLabel:`base`,cleanOrphans:`Clean orphans`,cleanOrphansTitle:`Remove all orphaned worktrees`,liveBusyTitle:`A run is live — stop it first`,rescanTitle:`Rescan`,removed_one:`Removed {{count}} worktree.`,removed_other:`Removed {{count}} worktrees.`,failed:`Failed`,mergedIntoBase:`Merged {{branch}} into base.`,conflictMerge:`Conflict merging {{branch}}: {{files}}`,seeGit:`see git`,mergeFailed:`Merge failed: {{reason}}`,unknownReason:`unknown`,mergeConfirmTitle:`Merge {{branch}} into {{base}}?`,mergeConfirmMsg:`Squash-merges this branch onto the base branch. Aborts cleanly if it conflicts.`,mergeAction:`Merge`,removeConfirmTitle:`Remove {{branch}}?`,removeConfirmMsg:`Force-removes the worktree checkout and deletes its branch. Un-merged work is discarded.`,empty:`No worktrees.`,emptyHint:`SDD / AutoPhase runs create isolated worktrees here. Orphans from crashed runs show up too.`,actOpenTerm:`Open in terminal`,actOpenFolder:`Open folder`,actViewChanges:`View changes`,actMerge:`Merge to base`,actRemove:`Remove / discard`,live:`live`,noUncommitted:`No uncommitted changes`,commitsAhead_one:`{{count}} commit ahead`,commitsAhead_other:`{{count}} commits ahead`,more:`…{{count}} more`},Da={heading:`Office Map`,headingHint:`Visualize your fleet as an office floor plan with live agent status.`,statAgents:`Agents`,statMail:`Mail`,unreadSuffix:` unread`,sectionView:`View`,sectionDisplay:`Display`,sectionBackground:`Background`,sectionRecent:`Recent Activity`,eventsTrackedSuffix:` events tracked`,recentHint:`Mail sends, agent spawns, and status changes appear here.`,sectionShortcuts:`Shortcuts`,sectionLegend:`Legend`,hudLabel:`HUD`,hudDesc:`Show real-time session stats overlay`,hudToggle:`Toggle HUD`,minimapLabel:`Minimap`,minimapDesc:`Show the overview minimap`,minimapToggle:`Toggle minimap`,controlsLabel:`Controls`,controlsDesc:`Show zoom and fit controls`,controlsToggle:`Toggle controls`,animateLabel:`Animate edges`,animateDesc:`Animate flow on active connections`,animateToggle:`Toggle edge animation`,legendLabel:`Show legend`,legendDesc:`Display status and connection legend`,legendToggle:`Toggle legend`,feedLabel:`Live feed`,feedDesc:`Bottom strip of recent cross-process activity`,feedToggle:`Toggle live feed`,fitView:`Fit view`,zoomIn:`Zoom in`,zoomOut:`Zoom out`,resetZoom:`Reset zoom`,legendActive:`Active (running)`,legendIdle:`Idle`,legendError:`Error`,legendOffline:`Offline`,bg:{dots:`Dots`,lines:`Lines`,cross:`Cross`,none:`None`}},Oa={nav:ri,brand:ii,status:ai,menu:oi,sidePanel:si,history:ci,agents:li,changes:ui,inspector:di,nextSteps:fi,mailbox:pi,sessions:mi,sessionPanel:hi,fleet:gi,context:_i,refine:vi,specs:yi,refresh:bi,board:xi,debug:Si,providerModels:Ci,dock:wi,agentsMonitor:Ti,terminal:Ei,sessionWatch:Di,sideEffects:Oi,monitor:ki,sdd:Ai,toolResult:ji,design:Mi,autoPhase:Ni,collab:Pi,connection:Fi,mode:Ii,cost:Li,model:Ri,modelSwitcher:zi,work:Bi,todos:Vi,task:Hi,toolGroup:Ui,fileRef:Wi,plan:Gi,filePicker:Ki,toast:qi,search:Ji,phase:Yi,ctxMode:Xi,transcript:Zi,autonomy:Qi,queue:$i,checkpoint:ea,goal:ta,worktree:na,process:ra,diff:ia,fallback:aa,liveSessions:oa,monacoDiff:sa,errorBody:ca,officeMap:la,toolInput:ua,message:da,watch:fa,shortcuts:pa,sddBoard:ma,sddTask:ha,sddWizard:ga,fileExplorer:_a,codeEditor:va,analytics:ya,promptLib:ba,skillDetail:xa,office:Sa,skillsList:Ca,timeline:wa,designStudio:Ta,worktrees:Ea,officeSettings:Da},ka=e({default:()=>Ka,empty:()=>Ba,emptyState:()=>Aa,header:()=>Ga,input:()=>Wa,inputPlaceholder:()=>Na,inputPlaceholderConnecting:()=>Pa,inputPlaceholderLoading:()=>Fa,messageCount_one:()=>Va,messageCount_other:()=>Ha,newSession:()=>za,send:()=>Ia,sendTitle:()=>La,sessionNamePlaceholder:()=>ja,stop:()=>Ra,switchSession:()=>Ma,thinking:()=>Ua}),Aa={title:`Start a conversation`,subtitle:`Send a message to begin.`},ja=`Session name…`,Ma=`Switch session`,Na=`Message the agent… (type / for commands, @ for files)`,Pa=`Connect to server first…`,Fa=`Type a btw/steer/queue follow-up…`,Ia=`Send`,La=`Send (Enter)`,Ra=`Stop`,za=`New session`,Ba=`(empty)`,Va=`{{count}} message`,Ha=`{{count}} messages`,Ua=`Thinking…`,Wa={autoFencedAs:`Auto-fenced as`,charsWord:`chars`,linesWord:`lines`,pastedWord:`Pasted`,fencedHintPrefix:`— fenced code blocks render best with`,removeFencesTitle:`Remove fences and restore raw text`,dismissTitle:`Dismiss`,pendingAttachmentAlt:`Pending attachment`,imageAttached:`Image attached`,removeImageTitle:`Remove image`,referencesLabel:`References`,clearAll:`Clear all`,stopEditTitle:`Stop run and edit the last prompt (reuse + rewrite)`,abortTitle:`Abort the current run`,refineEnabledTitle:`Refining enabled — click to disable`,refineDisabledTitle:`Refining disabled — click to enable`,btwRunningTitle:`btw — send without interrupting the running agent`,btwIdleTitle:`btw — send (Enter)`,steerRunningTitle:`steer — interrupt the running agent and redirect`,steerIdleTitle:`steer — send (no interrupt target while idle)`,addQueueTitle:`add queue — hold until the current run completes`},Ga={openSidebarTitle:`Open sidebar (Ctrl+\\)`,renameTitle:`Click to rename session`,untitled:`Untitled`,changeModelTitle:`Change provider / model (Ctrl+M)`,iterationTitle:`Agent iteration — click to jump to live activity`,runningProcessesTitle:`Running processes`,checkpointsTitle:`Session checkpoints — rewind`,scrollTopTitle:`Scroll to top (oldest)`,jkNavigateTitle:`j/k to navigate`,noProvider:`no-provider`,noModel:`no-model`},Ka={emptyState:Aa,sessionNamePlaceholder:ja,switchSession:Ma,inputPlaceholder:Na,inputPlaceholderConnecting:Pa,inputPlaceholderLoading:Fa,send:Ia,sendTitle:La,stop:Ra,newSession:za,empty:Ba,messageCount_one:Va,messageCount_other:Ha,thinking:Ua,input:Wa,header:Ga},qa=e({cat:()=>Za,cmd:()=>Qa,default:()=>$a,footer:()=>Xa,noMatches:()=>Ya,placeholder:()=>Ja}),Ja=`Search commands, sessions, settings…`,Ya=`No matches for "{{query}}"`,Xa={navigate:`↑↓ navigate`,select:`↵ select`,dismiss:`Esc dismiss`},Za={Command:`Command`,Session:`Session`,Theme:`Theme`,Tool:`Tool`,Slash:`Slash`},Qa={help:`Show slash commands`,tools:`List tools`,memory:`Show memory`,skills:`List skills`,diag:`Runtime diagnostics`,stats:`Session stats (tokens, cache, cost)`,clear:`Clear context`,clearHint:`Wipe in-memory context, keep session id`,new:`New session`,newHint:`Brand-new on disk + memory`,compact:`Compact context`,repairContext:`Repair context`,repairContextHint:`Remove orphan tool protocol blocks`,export:`Export chat as markdown`,exportHtml:`Export chat as HTML`,exportHtmlHint:`Self-contained, opens in any browser`,history:`Open history panel`,settings:`Open settings`,model:`Change provider/model`,themeLight:`Theme: Light`,themeDark:`Theme: Dark`,themeSystem:`Theme: Follow system`,compactToggle:`Toggle compact density`,soundOn:`Sound on completion: ON — turn off`,soundOff:`Sound on completion: OFF — turn on`,soundHint:`Chime when a run finishes`,autophaseOpen:`Open AutoPhase view`,autoOn:`Autonomous mode: ON — disable`,autoOff:`Autonomous mode: OFF — enable`,autoHint:`Toggle autonomous phase execution`,autophaseStop:`Stop AutoPhase`,resume:`Resume: {{title}}`,emptyTitle:`(empty)`},$a={placeholder:Ja,noMatches:Ya,footer:Xa,cat:Za,cmd:Qa},eo=e({action:()=>to,confirm:()=>no,default:()=>so,error:()=>ao,sparkline:()=>oo,status:()=>ro,time:()=>io}),to={ok:`OK`,cancel:`Cancel`,save:`Save`,saved:`Saved`,close:`Close`,yes:`Yes`,no:`No`,delete:`Delete`,remove:`Remove`,add:`Add`,edit:`Edit`,rename:`Rename`,retry:`Retry`,reset:`Reset`,apply:`Apply`,confirm:`Confirm`,back:`Back`,next:`Next`,done:`Done`,refresh:`Refresh`,copy:`Copy`,copied:`Copied`,open:`Open`,start:`Start`,stop:`Stop`,pause:`Pause`,resume:`Resume`,continue:`Continue`,clear:`Clear`,search:`Search`,loading:`Loading…`,saving:`Saving…`,searchPlaceholder:`Search…`,always:`Always`,deny:`Deny`,undo:`Undo`,all:`All`},no={title:`Approval required: {{tool}}`,descriptionEdit:`The agent wants to modify a file. Review the request below and decide whether to proceed.`,descriptionTool:`The agent wants to run this tool. Review the request below and decide whether to proceed.`,fileModification:`File modification`,toolExecution:`Tool execution`,riskSuffix:`{{risk}} risk`,command:`Command`,inputLabel:`Input:`,trustSuggestionTitle:`Trust pattern suggestion`,trustSuggestionHint:`Picking Always will whitelist matching calls for this project.`,yoloDestructiveNote:`YOLO is on. This prompt is still shown because the request was classified as destructive.`,skipApprovalsTitle:`Skip future approvals`,skipApprovalsHint:`Enable YOLO mode and the agent runs without asking. Destructive operations still prompt.`,enableYoloTitle:`Enable YOLO mode (auto-approve this and future non-destructive calls)`,enableYoloBtn:`Enable YOLO`,denyAlways:`Deny always`,denyAlwaysTitle:`Reject this and all future calls matching the pattern (d)`,noTitle:`Reject this single call (Esc / n)`,alwaysTitle:`Approve and remember the pattern for the project (a)`,yesTitle:`Approve this single call (y)`},ro={connected:`Connected`,disconnected:`Disconnected`,connecting:`Connecting…`,reconnecting:`Reconnecting…`,ready:`Ready`,error:`Error`,offline:`Offline`,online:`Online`,live:`Live`,budgetWarning:`budget warning`,running:`Running`,inProgress:`In Progress`,working:`working`},io={justNow:`just now`,secondsAgo_one:`{{count}} second ago`,secondsAgo_other:`{{count}} seconds ago`,minutesAgo_one:`{{count}} minute ago`,minutesAgo_other:`{{count}} minutes ago`,hoursAgo_one:`{{count}} hour ago`,hoursAgo_other:`{{count}} hours ago`,daysAgo_one:`{{count}} day ago`,daysAgo_other:`{{count}} days ago`,compactSecondsAgo:`{{count}}s ago`,compactMinutesAgo:`{{count}}m ago`,compactHoursAgo:`{{count}}h ago`},ao={title:`Something went wrong`,body:`A rendering error occurred. Your session is still active on the server — reloading will pick up where you left off.`,reload:`Reload page`,tryAgain:`Try again`},oo={noActivity:`No activity`,noActivityYet:`No activity yet`,activityMax:`Activity sparkline: max {{count}} events`,activityPeak:`Activity sparkline — peak {{count}} events/bucket`},so={action:to,confirm:no,status:ro,time:io,error:ao,sparkline:oo},co=e({agent:()=>yo,allowlist:()=>_o,appearance:()=>fo,connection:()=>mo,default:()=>So,features:()=>bo,mcp:()=>go,model:()=>po,oauth:()=>vo,provider:()=>ho,tabs:()=>uo,title:()=>lo,toast:()=>xo}),lo=`Settings`,uo={provider:`Provider`,connection:`Connect`,appearance:`Look`,agent:`Agent`,features:`Feat.`,mcp:`MCP`},fo={themeHeading:`Theme`,themeLight:`Light`,themeDark:`Dark`,themeSystem:`System`,themeSystemHint:`System follows your OS-level light/dark preference.`,preferencesHeading:`Preferences`,compactDensity:`Compact density`,compactDensityHint:`Tighter spacing throughout the chat.`,soundOnComplete:`Sound on completion`,soundOnCompleteHint:`Play a soft chime when a run finishes.`,titleAnimation:`Title animation`,titleAnimationHint:`Show animated terminal title in the CLI.`,languageHeading:`Language`,languageLabel:`Interface language`,languageHint:`Changes only the interface text. Prompts, skills, and model output are not affected.`},po={heading:`Model`,loading:`Loading models...`,notFound:`No models found for this provider. The catalog might be empty or still loading.`,selectProviderFirst:`Select a provider first`,context:`{{count}}k context`},mo={wsUrlLabel:`WebSocket Server URL`,wsUrlPlaceholder:`ws://localhost:3457`,wsUrlHint:`URL of the agent WebSocket server. The server runs alongside the CLI.`,startingHeading:`Starting the WebSocket Server`,startingBody:`Standalone: run ./dev.ps1 from the repo root, or set WS_HOST/WS_PORT before launching wstackui. Or alongside the CLI: wstack --webui.`},ho={subscriptionHeading:`Subscription login`,apiKeysHeading:`API key providers`,apiKeysBody:`Pick a provider from the catalog and add an API key, or manage saved providers.`,tabCatalog:`Catalog`,tabSaved:`Saved ({{count}})`,searchPlaceholder:`Search {{count}} providers (name / id / family)…`,loadingCatalog:`Loading catalog...`,noMatch:`No providers match "{{query}}".`,configured:`Configured`,reachable:`Reachable`,envVar:`ENV: {{var}}`,modelCount_one:`{{count}} model`,modelCount_other:`{{count}} models`,keyPlaceholder:`{{name}} API key`,orEnv:`Or set {{env}} in the environment instead.`,addApiKey:`Add API key`,manageKeys:`Manage your API keys and provider configurations`,addProvider:`Add Provider`,addCustomHeading:`Add Custom Provider`,localServers:`Local servers — click to pre-fill:`,providerIdPlaceholder:`Provider ID (e.g. my-llm-server)`,apiKeyOptionalPlaceholder:`API Key (optional)`,noSaved:`No saved providers yet`,noSavedHint:`Add a provider to get started`,apiKeysLabel:`API Keys`,addKey:`Add Key`,noKeys:`No keys configured`,active:`Active`,setActive:`Set Active`,keyLabelPlaceholder:`Key label (e.g. default, production)`,apiKeyPlaceholder:`API key`,saveKey:`Save Key`,savedToast:`Saved key for {{name}}`},go={status:{connected:`Connected`,connecting:`Connecting`,sleeping:`Sleeping`,discovering:`Discovering`,error:`Error`,stopped:`Stopped`,unknown:`Unknown`},disabled:`MCP servers are disabled.`,wakeTitle:`Wake server`,sleepTitle:`Sleep server`,discoverTitle:`Discover tools`,editTitle:`Edit`,removeTitle:`Remove`,statusLabel:`Status:`,enabledLabel:`Enabled:`,yes:`Yes`,no:`No`,descriptionLabel:`Description:`,pidLabel:`PID:`,errorLabel:`Error:`,toolsLabel:`Tools ({{count}}):`,noTools:`No tools discovered yet`,serverNameRequired:`Server name is required`,dialogTitleEdit:`Edit MCP Server`,dialogTitleAdd:`Add MCP Server`,dialogTitleAddCustom:`Add Custom MCP Server`,fieldName:`Name`,fieldNamePlaceholder:`e.g., github, filesystem`,fieldTransport:`Transport`,fieldUrl:`URL`,fieldCommand:`Command`,fieldCommandPlaceholder:`e.g., npx`,fieldArgs:`Args`,fieldArgsHint:`(space-separated)`,fieldArgsPlaceholder:`e.g., -y @modelcontextprotocol/server-github`,fieldEnv:`Env vars`,fieldEnvHint:`(KEY=value, one per line)`,fieldDescription:`Description`,fieldDescriptionPlaceholder:`GitHub MCP server for repository access`,enableServer:`Enable server`,lazyConnect:`Lazy connect`,lazyConnectHint:`(don't start until first tool call; auto-sleeps when idle)`,saveChanges:`Save Changes`,addServer:`Add Server`,requires:`Requires: {{vars}}`,added:`Added`,heading:`MCP Servers`,summary:`{{connected}} connected · {{sleeping}} sleeping · {{total}} total`,addCustom:`Add Custom`,tabRecommended:`Recommended`,tabServers:`Servers`,tabAddCustom:`Add Custom`,recommendedBody:`One-click add for popular MCP servers. Click Add to pre-fill the configuration, then confirm. Servers requiring credentials will need their env vars set before use.`,loadingServers:`Loading servers...`,noServers:`No MCP servers configured`,noServersHint:`Switch to the Recommended tab to add popular servers, or Add Custom for your own.`,addCustomBody:`Configure a custom MCP server with stdio, SSE, or HTTP transport.`,addCustomBodyHint:`For popular servers, use the Recommended tab instead — everything is pre-configured for you.`,removeConfirmTitle:`Remove server "{{name}}"?`,removeConfirmBody:`This removes the MCP server from your configuration.`,toastAdded:`Server "{{name}}" added`,toastRemoved:`Server "{{name}}" removed`,toastDiscovered:`Discovered {{count}} tools from "{{name}}"`,toastSleeping:`Server "{{name}}" is now sleeping`,toastConnected:`Server "{{name}}" connected`,toastReconnected:`Server "{{name}}" reconnected`,toastDisconnected:`Server "{{name}}" disconnected: {{reason}}`,toastError:`Server "{{name}}" error: {{error}}`,disabledHint:`Enable the "MCP servers" feature flag in the Features tab to use this section.`},_o={title:`Clear saved allowlist?`,body_one:`This will remove the pinned model for {{provider}}. The model picker will fall back to the models.dev catalog.`,body_other:`This will remove the {{count}} pinned models for {{provider}}. The model picker will fall back to the models.dev catalog.`,undoHint:`You can undo this for 8 seconds after confirming.`,keepTitle:`Keep the allowlist (Esc)`,clearTitle:`Clear the allowlist (Enter)`,clear:`Clear allowlist`},vo={termsWarning:`Sign in with a subscription instead of an API key. Using a subscription outside its official client may violate the provider's Terms — your account could be rate-limited or banned. An API key is the sanctioned path for programmatic use.`,signIn:`Sign in`,waitingBrowser:`Waiting for you to sign in…`,openSignIn:`Open sign-in page`,pasteLoopbackBusy:`Loopback port busy — paste the redirect URL`,pasteCantReach:`Browser can't reach this server? Paste the redirect URL`,submit:`Submit`,enterCode:`Enter this code at the verification page:`,openVerification:`Open verification page`,waitingCode:`Waiting for authorization…`,exchanging:`Exchanging tokens…`,fetchingModels:`Fetching models…`,signedIn:`Signed in.`,signedInToast:`Signed in — {{provider}}`,signInFailed:`Sign-in failed`},yo={modelHeading:`Model`,autonomyHeading:`Autonomy & Behavior`,autonomyModeLabel:`Autonomy mode`,autonomyModeHint:`How independently the agent proceeds between turns.`,autonomyModeOff:`Off — full manual control`,autonomyModeSuggest:`Suggest — suggests next steps`,autonomyModeAuto:`Auto — brief confirmation delay`,autonomyModeEternal:`Eternal — autonomous until goal done`,autonomyModeEternalParallel:`Eternal Parallel — multi-agent fleet`,autoProceedDelayLabel:`Auto-proceed delay`,autoProceedDelayHint:`Milliseconds before the agent auto-proceeds in Auto mode. 0 = immediate.`,yoloLabel:`YOLO mode`,yoloHint:`Bypass tool confirmation prompts — the agent runs without asking.`,refineHeading:`Prompt Refinement`,enableRefineLabel:`Enable refine`,enableRefineHint:`Rewrite prompts before sending — clearer instructions, better results.`,refineDelayLabel:`Refine delay`,refineDelayHint:`Countdown before the refined prompt auto-sends.`,refineLanguageLabel:`Refine language`,refineLanguageHint:`Keep your language or translate to English for the model.`,refineLanguageOriginal:`Original — keep your language`,refineLanguageEnglish:`English — translate to English`,reasoningHeading:`Reasoning & Cache`,reasoningModeLabel:`Reasoning mode`,reasoningModeHint:`Control how the model uses extended thinking. Auto = provider default.`,reasoningModeAuto:`Auto — provider default`,reasoningModeOn:`On — force thinking on`,reasoningModeOff:`Off — force thinking off`,reasoningEffortLabel:`Reasoning effort`,reasoningEffortHint:`How much compute the model spends thinking. Only sent when the model supports it.`,reasoningEffortNone:`None`,reasoningEffortMinimal:`Minimal`,reasoningEffortLow:`Low`,reasoningEffortMedium:`Medium`,reasoningEffortHigh:`High`,reasoningEffortXhigh:`Extra High`,reasoningEffortMax:`Max`,preserveThinkingLabel:`Preserve thinking`,preserveThinkingHint:`Keep reasoning blocks across turns for context continuity.`,cacheTtlLabel:`Cache TTL`,cacheTtlHint:`Prompt cache time-to-live. 1h costs more on write but saves on repeat reads (Anthropic).`,cacheTtlDefault:`Default — provider default`,cacheTtl5m:`5 minutes`,cacheTtl1h:`1 hour`,capsHint:`Use wstack models caps to check what the current model supports. Unsupported settings are silently omitted per-request.`,fallbackHeading:`Model Fallbacks`,fallbackBody:`When the active model rate-limits (429/529), 5xx-errors, or stalls — after its own retries — the agent rotates to the next model in this chain. Also used as the default for SDD worker subagents.`,autoFallbackLabel:`Auto fallback`,autoFallbackHint:`When the chain above is empty, auto-derive one from your keyed providers.`,favoritesOnlyLabel:`Favorites only`,favoritesOnlyHint:`When auto fallback derives a chain, restrict it to your favorite models.`,profilesHeading:`Fallback Profiles`,addProfile:`Add`,noProfiles:`No named fallback profiles yet.`,createDefault:`Create default from active model`,useChain:`Use chain`,setLeader:`Set leader`,profileEmpty:`Profile is empty.`,favoritesHeading:`Favorite Models`,favoritesEmpty:`Favorites are shown first and can constrain auto fallback.`,routingHeading:`Model Routing`,routingRouteKey:`Model route key`,routingPhasesGroup:`Phases`,routingRolesGroup:`{{label}} roles`,routingCustomGroup:`Custom existing routes`,routingTargetPlaceholder:`fallback1, provider/model, or blank`,routingSet:`Set`,routingReasoningModeAria:`New route reasoning mode`,routingReasoningEffortAria:`New route reasoning effort`,routingReasoningPreserveAria:`New route reasoning preserve`,routingReasoningModeFor:`Reasoning mode for {{key}}`,routingReasoningEffortFor:`Reasoning effort for {{key}}`,routingReasoningPreserveFor:`Reasoning preserve for {{key}}`,noRoutes:`No model routes yet.`,leaderModel:`leader model`,hqHeading:`HQ Client`,hqPublishingLabel:`HQ publishing`,hqPublishingHint:`Publish this WebUI/client session to WrongStack HQ. Same-machine clients can auto-discover local HQ auth; remote clients use the URL/token below.`,hqUrlLabel:`HQ URL`,hqUrlHint:`Leave empty for same-machine auto-discovery.`,hqTokenLabel:`HQ client token`,executionHeading:`Execution`,maxIterationsLabel:`Max iterations per run`,maxIterationsHint:`Hard cap on LLM turns per agent.run().`,autoProceedMaxIterationsLabel:`Auto-proceed max iterations`,autoProceedMaxIterationsHint:`Stop auto-proceed after N iterations. 0 = unlimited.`,confirmExitLabel:`Confirm before exit`,confirmExitHint:`First Ctrl+C aborts work, second confirms exit.`,chimeLabel:`Chime on completion`,chimeHint:`Terminal bell when an agent run finishes.`,fleetHeading:`Fleet & Streaming`,streamFleetLabel:`Stream fleet events`,streamFleetHint:`Show live subagent activity in the fleet panel.`,maxConcurrentLabel:`Max concurrent subagents`,maxConcurrentHint:`Maximum number of subagents that can run simultaneously.`,nextPredictionLabel:`Next-step prediction`,nextPredictionHint:`After a turn completes, predict likely next steps.`,telegramHeading:`Telegram Notifications`,telegramSessionEndLabel:`Session end`,telegramSessionEndHint:`Send a summary when a session ends.`,telegramDelegateLabel:`Delegate finished`,telegramDelegateHint:`Send a humanized note when a subagent completes.`,telegramLongToolLabel:`Long-running tools`,telegramLongToolHint:`Notify when a tool exceeds {{ms}}ms. Set 0 to disable.`,telegramChangesApply:`Changes apply immediately.`,telegramNotConfigured:`Telegram is not configured. Run /telegram-setup in the CLI to connect a bot first.`,addModelToProfile:`Add model to profile…`,addFavoriteModel:`Add favorite model…`,hqRawContentLabel:`Raw HQ content`,hqRawContentHint:`Send raw content previews to HQ instead of redacted previews.`},bo={flagsHeading:`Feature Flags`,mcpLabel:`MCP servers`,mcpHint:`Enable Model Context Protocol integrations.`,pluginsLabel:`Plugins`,pluginsHint:`Load and run user-installed plugins.`,memoryLabel:`Memory`,memoryHint:`Persist and recall facts across sessions.`,skillsLabel:`Skills`,skillsHint:`Load domain-specific skill prompts.`,modelsRegistryLabel:`Models registry`,modelsRegistryHint:`Use the models.dev catalog for provider discovery.`,indexOnStartLabel:`Index on start`,indexOnStartHint:`Build the codebase symbol index at session start.`,contextHeading:`Context & Debug`,autoCompactLabel:`Auto-compact context`,autoCompactHint:`Automatically trim the context window when near limits.`,compactorStrategyLabel:`Compactor strategy`,compactorStrategyHint:`How the context is compacted when it grows too large.`,compactorStrategyHybrid:`Hybrid — fast rules (default)`,compactorStrategyIntelligent:`Intelligent — LLM summarization`,compactorStrategySelective:`Selective — LLM-driven selection`,contextModeLabel:`Context mode`,contextModeHint:`Context window policy — balanced is the default.`,contextModeBalanced:`Balanced — normal context usage`,contextModeFrugal:`Frugal — conservative token use`,contextModeDeep:`Deep — larger context for complex tasks`,contextModeArchival:`Archival — maximize context retention`,tokenSavingLabel:`Token-saving mode`,tokenSavingHint:`How aggressively to reduce token usage.`,tokenSavingOff:`Off — no token saving`,tokenSavingMinimal:`Minimal — basic optimization`,tokenSavingLight:`Light — moderate reduction`,tokenSavingMedium:`Medium — significant savings`,tokenSavingAggressive:`Aggressive — maximum compression`,logLevelLabel:`Log level`,logLevelHint:`Minimum severity for server-side logging.`,logLevelDebug:`Debug — everything`,logLevelInfo:`Info — normal flow`,logLevelWarn:`Warn — problems only`,logLevelError:`Error — failures only`,auditLevelLabel:`Audit level`,auditLevelHint:`Detail level for session audit logs.`,auditLevelMinimal:`Minimal — errors only`,auditLevelStandard:`Standard — tool calls + errors`,auditLevelFull:`Full — every event (large logs)`},xo={switchingTo:`Switching to {{provider}} / {{model}}…`,fallbackExists:`Fallback profile "{{name}}" already exists`,selectProviderModelFirst:`Select a provider and model first`,defaultProfileCreated:`Default fallback profile created`,profileEmpty:`Fallback profile "{{name}}" is empty`,leaderSetFrom:`Leader set from {{name}}`},So={title:lo,tabs:uo,appearance:fo,model:po,connection:mo,provider:ho,mcp:go,allowlist:_o,oauth:vo,agent:yo,features:bo,toast:xo},Co=e({default:()=>Do,provider:()=>To,screen:()=>Eo,welcome:()=>wo}),wo={title:`Welcome to WrongStack`,subtitle:`Connect a provider to get started.`,heroTitle:`Where do you want to start?`,heroTitleInProject:`Where do you want to start in {{name}}?`,heroSubtitle:`The agent is connected to your project and ready to read, edit, run commands, search the codebase, track todos, and remember context across sessions. Pick a starting prompt below, write your own, or type / for the full command palette.`,workingDirectory:`Working directory: {{cwd}}`,noKeyTitle:`No API key configured yet`,noKeyBody:`Register a provider in Settings before sending a message — otherwise the agent has nothing to talk to. Anthropic, OpenAI, Google, and any OpenAI-compatible endpoint all work.`,openSettings:`Open Settings`,pickBackUp:`Pick back up`,recentPrompts:`Recent prompts`,quickCommands:`Quick commands`,empty:`(empty)`,card:{understand:{title:`Understand`,hint:`Explore and analyze the codebase`},create:{title:`Create`,hint:`Build new features and functionality`},investigate:{title:`Investigate`,hint:`Debug issues and find root causes`},improve:{title:`Improve`,hint:`Refactor and optimize existing code`}},slashRef:{help:`list every slash command`,diag:`runtime diagnostics`,stats:`tokens · cache · cost · elapsed`,tools:`show registered tools`,memory:`show remembered notes`,compact:`shrink context`,clear:`wipe current context`,new:`fresh session`}},To={heading:`Choose a provider`,keyPlaceholder:`Paste your API key`,connect:`Connect`,connected:`Connected`},Eo={header:{title:`Welcome to WrongStack`,subtitle:`Add at least one API key to get started`,continue:`Continue`},steps:{addKeys:`Add API Keys`,pickModel:`Pick a Model`,start:`Start`,keys:`Keys`},security:{title:`Your keys stay on your machine`,body:`API keys are encrypted and stored locally. They're only sent to the provider's API endpoint — never to us or any third party.`},errors:{backendUnreachable:`Can't reach the backend`,backendNotResponding:`The backend is not responding. It may have crashed or the connection dropped.`,retry:`Retry`,modelSwitchTimeout:`Model switch timed out. Please try again.`,noModels:`No models available. Check your API key and try again.`},providers:{popular:`Popular Providers`,more:`More Providers`,selfHosted:`Self-hosted`,updating:`Updating...`,refresh:`Refresh`,refreshTitle:`Refresh provider list`,modelsAvailable_one:`{{count}} model available`,modelsAvailable_other:`{{count}} models available`,catalogDescription:`{{family}} · {{count}} models`},start:{pickAndStart:`Pick a model and start`,addMoreKeys:`← Add more keys`,chooseProvider:`Choose a Provider`,chooseModel:`Choose a Model`,modelsFor:`Models available for {{provider}}`,activeKeys_one:`{{count}} active key`,activeKeys_other:`{{count}} active keys`,startSession:`Start Session`},card:{keySaved:`Key saved`,referral:`Referral`,save:`Save`,getKey:`Get your API key`,copied:`Copied`,copyReferral:`Copy referral link`,share:`Share`,qrAlt:`{{name}} referral QR code`},share:{title:`Share {{name}} Referral`,description:`Share this referral link with friends and earn rewards!`,hint:`Scan the QR code or copy the link to share`,twitter:`Share on X/Twitter`,linkedin:`Share on LinkedIn`,telegram:`Share on Telegram`,whatsapp:`Share on WhatsApp`,reddit:`Share on Reddit`,facebook:`Share on Facebook`,email:`Share via Email`},custom:{title:`Custom / Self-hosted Provider`,description:`Add any OpenAI-compatible endpoint (Ollama, vLLM, Together, etc.)`,localServers:`Local servers — click to pre-fill`,providerId:`Provider ID *`,family:`Family`,familyOpenAiCompatible:`OpenAI Compatible`,baseUrl:`Base URL (optional)`,apiKey:`API Key (optional — some local providers don't need one)`,apiKeyPlaceholder:`API key (if required)`,add:`Add Provider`},time:{justNow:`just now`,secondsAgo:`{{count}}s ago`,minutesAgo:`{{count}}m ago`,hoursAgo:`{{count}}h ago`,daysAgo:`{{count}}d ago`},toasts:{keySaved:`{{name}} API key saved`,keySaveFailed:`Failed to save {{name}} API key`,referralCopied:`Referral link copied to clipboard`,referralCopyFailed:`Failed to copy referral link`,providerAdded:`Provider "{{id}}" added`,providerAddFailed:`Failed to add provider`,providersLoadedNew:`{{count}} providers loaded ({{diff}} new)`,providersLoadedRemoved:`{{count}} providers loaded ({{diff}} removed)`,providersLoadedNoChanges:`{{count}} providers loaded (no changes)`,providersRefreshFailed:`Failed to refresh providers`}},Do={welcome:wo,provider:To,screen:Eo},Oo=e({default:()=>jo,error:()=>Ao,session:()=>ko}),ko={saved:`Session saved`,loaded:`Session loaded`,deleted:`Session deleted`},Ao={generic:`Something went wrong.`,connectionLost:`Connection lost. Reconnecting…`,reconnected:`Reconnected.`},jo={session:ko,error:Ao},Mo=[`common`,`activity`,`chat`,`commandPalette`,`settings`,`setup`,`toasts`];function No(){try{return Qr(ti.getState().uiLocale)}catch{return`en`}}b.use(Je).use(T((e,t)=>qr(Object.assign({"./locales/de/activity.json":()=>H(()=>import(`./activity-CVWYwjgf.js`),[]),"./locales/de/chat.json":()=>H(()=>import(`./chat-cxuX4gFa.js`),[]),"./locales/de/commandPalette.json":()=>H(()=>import(`./commandPalette-2M1hYRuH.js`),[]),"./locales/de/common.json":()=>H(()=>import(`./common-CrGjglH4.js`),[]),"./locales/de/settings.json":()=>H(()=>import(`./settings-CQ4x-iFD.js`),[]),"./locales/de/setup.json":()=>H(()=>import(`./setup-DOXm3hFc.js`),[]),"./locales/de/toasts.json":()=>H(()=>import(`./toasts-CFzweRH5.js`),[]),"./locales/en/activity.json":()=>H(()=>Promise.resolve().then(()=>ni),void 0),"./locales/en/chat.json":()=>H(()=>Promise.resolve().then(()=>ka),void 0),"./locales/en/commandPalette.json":()=>H(()=>Promise.resolve().then(()=>qa),void 0),"./locales/en/common.json":()=>H(()=>Promise.resolve().then(()=>eo),void 0),"./locales/en/settings.json":()=>H(()=>Promise.resolve().then(()=>co),void 0),"./locales/en/setup.json":()=>H(()=>Promise.resolve().then(()=>Co),void 0),"./locales/en/toasts.json":()=>H(()=>Promise.resolve().then(()=>Oo),void 0),"./locales/es/activity.json":()=>H(()=>import(`./activity-ByEwzh5Q.js`),[]),"./locales/es/chat.json":()=>H(()=>import(`./chat-Cvy-F2d6.js`),[]),"./locales/es/commandPalette.json":()=>H(()=>import(`./commandPalette-CTE9ITWg.js`),[]),"./locales/es/common.json":()=>H(()=>import(`./common-BAg8_MKg.js`),[]),"./locales/es/settings.json":()=>H(()=>import(`./settings-TqprB9wO.js`),[]),"./locales/es/setup.json":()=>H(()=>import(`./setup-BT2iTMm4.js`),[]),"./locales/es/toasts.json":()=>H(()=>import(`./toasts-BwQJwYLe.js`),[]),"./locales/fr/activity.json":()=>H(()=>import(`./activity-BEjzb11U.js`),[]),"./locales/fr/chat.json":()=>H(()=>import(`./chat-Cfq81NCh.js`),[]),"./locales/fr/commandPalette.json":()=>H(()=>import(`./commandPalette-BYf22WAi.js`),[]),"./locales/fr/common.json":()=>H(()=>import(`./common-tmj0IcQS.js`),[]),"./locales/fr/settings.json":()=>H(()=>import(`./settings-DgGu17XI.js`),[]),"./locales/fr/setup.json":()=>H(()=>import(`./setup-Dhb_xOpk.js`),[]),"./locales/fr/toasts.json":()=>H(()=>import(`./toasts-BCDGDcyq.js`),[]),"./locales/it/activity.json":()=>H(()=>import(`./activity-Cjm0UoMi.js`),[]),"./locales/it/chat.json":()=>H(()=>import(`./chat-DNIePdaQ.js`),[]),"./locales/it/commandPalette.json":()=>H(()=>import(`./commandPalette-BZhacjvy.js`),[]),"./locales/it/common.json":()=>H(()=>import(`./common-BH1mb9Im.js`),[]),"./locales/it/settings.json":()=>H(()=>import(`./settings-BVvx94WK.js`),[]),"./locales/it/setup.json":()=>H(()=>import(`./setup-B5TfeR6q.js`),[]),"./locales/it/toasts.json":()=>H(()=>import(`./toasts-Dm12Nq8t.js`),[]),"./locales/pt-BR/activity.json":()=>H(()=>import(`./activity-DN6Bmnaw.js`),[]),"./locales/pt-BR/chat.json":()=>H(()=>import(`./chat-CdLXf1yN.js`),[]),"./locales/pt-BR/commandPalette.json":()=>H(()=>import(`./commandPalette-RxWSjQIg.js`),[]),"./locales/pt-BR/common.json":()=>H(()=>import(`./common-C29pCVfm.js`),[]),"./locales/pt-BR/settings.json":()=>H(()=>import(`./settings-CmHCQRVI.js`),[]),"./locales/pt-BR/setup.json":()=>H(()=>import(`./setup-BBwNpiE3.js`),[]),"./locales/pt-BR/toasts.json":()=>H(()=>import(`./toasts-frBt6fvE.js`),[]),"./locales/tr/activity.json":()=>H(()=>import(`./activity-CqiCPjKb.js`),[]),"./locales/tr/chat.json":()=>H(()=>import(`./chat-DhofDrgA.js`),[]),"./locales/tr/commandPalette.json":()=>H(()=>import(`./commandPalette-BE_ljQwl.js`),[]),"./locales/tr/common.json":()=>H(()=>import(`./common-KzRPhobM.js`),[]),"./locales/tr/settings.json":()=>H(()=>import(`./settings-OOQ-99Tn.js`),[]),"./locales/tr/setup.json":()=>H(()=>import(`./setup-CVMjqrZh.js`),[]),"./locales/tr/toasts.json":()=>H(()=>import(`./toasts-DDYQsJV8.js`),[])}),`./locales/${e}/${t}.json`,4))).init({lng:No(),fallbackLng:`en`,supportedLngs:[...Jr],ns:[...Mo],defaultNS:`common`,partialBundledLanguages:!0,resources:{en:{common:so,activity:Oa,chat:Ka,commandPalette:$a,settings:So,setup:Do,toasts:jo}},interpolation:{escapeValue:!1},react:{useSuspense:!1},returnNull:!1});function Po(e){typeof document<`u`&&(document.documentElement.lang=e)}Po(b.language||`en`),ti.subscribe((e,t)=>{let n=e.uiLocale;n&&n!==t.uiLocale&&n!==b.language&&b.changeLanguage(n).then(()=>Po(n))});function Fo(){window.wrongstackDesktopHost?.onLocaleChanged?.(e=>{if(!e)return;let t=Qr(e);if(t===b.language)return;let n=ti.getState();n.uiLocale!==t&&n.set({uiLocale:t}),b.changeLanguage(t).then(()=>Po(t))})}try{Fo()}catch{}var Io=`#4f46e5`;function Lo(e){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
6
- <rect x="2" y="2" width="60" height="60" rx="14" fill="${Io}" />
7
- <text x="32" y="44" text-anchor="middle" font-family="-apple-system,Segoe UI,Roboto,sans-serif" font-size="38" font-weight="700" fill="#fff">W</text>
8
- ${e===`ready`?`<circle cx="50" cy="14" r="14" fill="#22c55e" stroke="#fff" stroke-width="3" />`:e===`error`?`<circle cx="50" cy="14" r="14" fill="#ef4444" stroke="#fff" stroke-width="3" />`:e===`running`?`<circle cx="50" cy="14" r="14" fill="#f59e0b" stroke="#fff" stroke-width="3" />`:e===`attention`?`<circle cx="50" cy="14" r="14" fill="#eab308" stroke="#fff" stroke-width="3"><animate attributeName="opacity" values="1;0.3;1" dur="1s" repeatCount="indefinite"/></circle>`:``}
9
- </svg>`}function Ro(e){return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`}function zo(){if(typeof document>`u`)return null;let e=document.querySelector(`link[rel="icon"]`);return e||(e=document.createElement(`link`),e.rel=`icon`,e.type=`image/svg+xml`,document.head.appendChild(e)),e}var Bo=`idle`;function Vo(e){Bo=e;let t=zo();t&&(t.href=Ro(Lo(e)))}var Ho=!1;function Uo(){Ho||typeof document>`u`||(Ho=!0,document.addEventListener(`visibilitychange`,()=>{!document.hidden&&(Bo===`ready`||Bo===`error`||Bo===`attention`)&&Vo(`idle`)}))}function Wo(e){typeof requestAnimationFrame==`function`?requestAnimationFrame(e):queueMicrotask(e)}var Go=new class{pending=new Map;scheduled=!1;push(e,t,n){if(!t)return;let r=this.pending.get(e);r?(r.buffer+=t,r.flush=n):this.pending.set(e,{buffer:t,flush:n}),this.schedule()}schedule(){this.scheduled||(this.scheduled=!0,Wo(()=>{this.scheduled=!1,this.drain()}))}drain(){if(this.pending.size===0)return;let e=Array.from(this.pending.entries());this.pending.clear();for(let[t,n]of e)n.buffer&&n.flush(t,n.buffer)}drop(e){this.pending.delete(e)}dropAll(){this.pending.clear()}flush(e){let t=this.pending.get(e);t&&(this.pending.delete(e),t.buffer&&t.flush(e,t.buffer))}flushAll(){this.drain()}};function Ko(e){return{type:`provider.clear_models`,payload:{providerId:e}}}function qo(e,t){return{type:`provider.undo_clear`,payload:{providerId:e,previousModels:[...t]}}}function Jo(e){return{type:`provider.update`,payload:e}}function Yo(e){try{return new URL(e).searchParams.get(`token`)}catch{return null}}function Xo(){if(typeof window>`u`||!window.location)return null;try{let e=window.location.search??``;return new URLSearchParams(e).get(`token`)}catch{return null}}function Zo(e){try{let t=new URL(e);return t.searchParams.delete(`token`),t.toString()}catch{return e}}function Qo(){if(!(typeof window>`u`||!window.location||!window.history?.replaceState))try{let e=window.location.href;if(!e)return;let t=new URL(e);if(!t.searchParams.has(`token`))return;t.searchParams.delete(`token`),window.history.replaceState(window.history.state,document.title,t.toString())}catch{}}var $o=3457;function es(){if(typeof document>`u`)return $o;let e=document.querySelector(`meta[name="wrongstack-ws-port"]`)?.getAttribute(`content`),t=e?Number.parseInt(e,10):NaN;return Number.isFinite(t)&&t>0&&t<65536?t:$o}function ts(){if(typeof document>`u`)return null;let e=document.querySelector(`meta[name="wrongstack-ws-url"]`)?.getAttribute(`content`)?.trim();if(!e)return null;try{let t=new URL(e);if(t.protocol!==`ws:`&&t.protocol!==`wss:`)return null;let n=Xo();return n&&!t.searchParams.has(`token`)&&t.searchParams.set(`token`,n),t.toString()}catch{return null}}function ns(){let e=ts();if(e)return e;let t=es();if(typeof window>`u`||!window.location?.hostname)return`ws://127.0.0.1:${t}`;let n=window.location.protocol===`https:`?`wss`:`ws`,r=window.location.hostname.toLowerCase(),i=Xo(),a=i?`?token=${encodeURIComponent(i)}`:``;return r===`localhost`||r===`127.0.0.1`||r===`[::1]`||r===`::1`?`${n}://127.0.0.1:${t}${a}`:`${n}://${window.location.hostname}:${t}${a}`}function rs(){if(typeof window>`u`||!window.location?.hostname)return`http://127.0.0.1:3456`;let e=window.location.protocol===`https:`?`https`:`http`,t=window.location.hostname.toLowerCase(),n=window.location.port?`:${window.location.port}`:``;return t===`localhost`||t===`127.0.0.1`||t===`[::1]`||t===`::1`?`${e}://127.0.0.1${n}`:`${e}://${window.location.hostname}${n}`}var is=e({WrongStackWebSocketClient:()=>os,getWSClient:()=>W});function as(e){try{let t=new URL(e),n=new URL(rs());return t.hostname===n.hostname}catch{return!0}}var os=class e{ws=null;url;handlers=new Map;reconnectAttempts=0;maxReconnectAttempts=10;reconnectDelay=1e3;shouldReconnect=!0;reconnectTimer=null;messageQueue=[];static MAX_QUEUED_MESSAGES=1e3;pendingConfirms=new Map;sessionId=null;lastErrorText;statusListeners=new Set;currentStatus={state:`connecting`};onStatus(e){return this.statusListeners.add(e),e(this.currentStatus),()=>this.statusListeners.delete(e)}get status(){return this.currentStatus}setStatus(e){this.currentStatus=e;for(let t of this.statusListeners)try{t(e)}catch{}}constructor(e){this.url=e??ns()}withSession(e){return this.sessionId?{...e,sessionId:this.sessionId}:e}async ensureAuthCookie(){if(typeof window>`u`)return;if(document.cookie.split(`;`).some(e=>e.trim().startsWith(`ws_token=`))){as(this.url)&&(this.url=Zo(this.url)),Qo();return}let e=Yo(this.url)??Xo();if(!e)return;let t=rs()+`/ws-auth?token=${encodeURIComponent(e)}`;try{let e=await fetch(t,{method:`GET`,credentials:`same-origin`,cache:`no-store`});e.ok?(as(this.url)&&(this.url=Zo(this.url)),Qo()):console.warn(JSON.stringify({level:`warn`,event:`ws_client.ws_auth_failed`,status:e.status,timestamp:new Date().toISOString()}))}catch(e){console.warn(JSON.stringify({level:`warn`,event:`ws_client.ws_auth_error`,message:e instanceof Error?e.message:String(e),timestamp:new Date().toISOString()}))}}async connect(){return await this.ensureAuthCookie(),new Promise((e,t)=>{if(this.ws?.readyState===WebSocket.OPEN){e();return}this.setStatus({state:`connecting`});try{this.ws=new WebSocket(this.url),this.ws.binaryType=`arraybuffer`;let n=setTimeout(()=>{t(Error(`Connection timeout`))},1e4),r=!1;this.ws.onopen=()=>{clearTimeout(n),r=!0,this.reconnectAttempts=0,this.lastErrorText=void 0,this.setStatus({state:`open`}),this.flushMessageQueue(),e()},this.ws.onmessage=e=>{try{let t=JSON.parse(e.data);this.handleMessage(t)}catch(e){console.error(JSON.stringify({level:`error`,event:`ws_client.message_parse_failed`,message:e instanceof Error?e.message:String(e),timestamp:new Date().toISOString()}))}},this.ws.onerror=e=>{console.error(JSON.stringify({level:`error`,event:`ws_client.error`,message:e instanceof Error?e.message:String(e),timestamp:new Date().toISOString()})),this.lastErrorText=`Connection error (see browser devtools)`,r||(clearTimeout(n),t(Error(this.lastErrorText)))},this.ws.onclose=e=>{if(!r){clearTimeout(n);let r=e.reason||`Closed with code ${e.code}`;this.lastErrorText=r,t(Error(r));return}e.reason&&!this.lastErrorText?this.lastErrorText=`${e.reason} (code ${e.code})`:!this.lastErrorText&&e.code!==1e3&&(this.lastErrorText=`Closed with code ${e.code}`),this.attemptReconnect()}}catch(e){this.lastErrorText=e instanceof Error?e.message:String(e),this.setStatus({state:`closed`,error:this.lastErrorText}),t(e)}})}attemptReconnect(){if(!this.shouldReconnect||this.reconnectAttempts>=this.maxReconnectAttempts){this.reconnectTimer=null,this.setStatus({state:`closed`,error:this.lastErrorText??`Disconnected`});return}this.reconnectAttempts++;let e=Math.min(this.reconnectDelay*2**(this.reconnectAttempts-1),3e4),t=Date.now()+e;this.setStatus({state:`reconnecting`,attempt:this.reconnectAttempts,nextRetryAt:t,lastError:this.lastErrorText}),this.reconnectTimer=setTimeout(async()=>{if(this.shouldReconnect)try{await this.connect()}catch(e){console.error(JSON.stringify({level:`error`,event:`ws_client.reconnect_failed`,message:e instanceof Error?e.message:String(e),timestamp:new Date().toISOString()}))}},e)}retryNow(){this.currentStatus.state!==`open`&&(this.reconnectTimer&&=(clearTimeout(this.reconnectTimer),null),this.reconnectAttempts=0,this.connect().catch(e=>console.warn(JSON.stringify({level:`warn`,event:`ws_client.reconnect_failed`,message:e instanceof Error?e.message:String(e),timestamp:new Date().toISOString()}))))}flushMessageQueue(){for(;this.messageQueue.length>0;){let e=this.messageQueue.shift();e&&this.send(e)}}handleMessage(e){if(e.type===`tool.confirm_needed`){let t=e.payload;this.pendingConfirms.set(t.id,{}),this.emit(e);return}if(e.type===`session.start`){let t=e.payload;this.sessionId=t.sessionId}this.emit(e)}emit(e){let t=this.handlers.get(e.type);if(t)for(let n of t)try{n(e)}catch(t){console.error(JSON.stringify({level:`error`,event:`ws_client.handler_error`,messageType:e.type,message:t instanceof Error?t.message:String(t),timestamp:new Date().toISOString()}))}}send(t){if((t.type===`context.clear`||t.type===`session.new`||t.type===`session.resume`)&&Go.dropAll(),this.ws?.readyState===WebSocket.OPEN)this.ws.send(JSON.stringify(t));else{if(this.messageQueue.length>=e.MAX_QUEUED_MESSAGES){let t=this.messageQueue.shift();t&&console.warn(JSON.stringify({level:`warn`,event:`ws_client.message_queue_full`,cap:e.MAX_QUEUED_MESSAGES,droppedType:t.type,timestamp:new Date().toISOString()}))}this.messageQueue.push(t)}}on(e,t){let n=this.handlers.get(e);return n||(n=new Set,this.handlers.set(e,n)),n.add(t),()=>n?.delete(t)}off(e,t){this.handlers.get(e)?.delete(t)}sendMessage(e,t){let n=`msg_${Date.now()}_${crypto.randomUUID().slice(0,8)}`;return this.send({type:`user_message`,payload:this.withSession({id:n,content:e,timestamp:Date.now(),...t?{imageBase64:t}:{}})}),n}sendAbort(){this.send({type:`abort`,payload:this.withSession({})})}getGitInfo(){this.send({type:`git.info`})}getGitChanges(){this.send({type:`git.changes`})}getGitDiff(e){this.send({type:`git.diff`,payload:{path:e}})}sendConfirm(e,t){this.pendingConfirms.has(e)&&this.pendingConfirms.delete(e),this.send({type:`tool.confirm_result`,payload:this.withSession({id:e,decision:t})})}switchModel(e,t){this.send({type:`model.switch`,payload:{provider:e,model:t}})}newSession(){this.send({type:`session.new`,payload:this.withSession({})})}listProviders(){this.send({type:`providers.list`})}listProviderModels(e){this.send({type:`provider.models`,payload:{providerId:e}})}listSavedProviders(){this.send({type:`providers.saved`})}addKey(e,t,n){this.send({type:`key.add`,payload:{providerId:e,label:t,apiKey:n}})}updateKey(e,t,n){this.send({type:`key.update`,payload:{providerId:e,label:t,apiKey:n}})}deleteKey(e,t){this.send({type:`key.delete`,payload:{providerId:e,label:t}})}setActiveKey(e,t){this.send({type:`key.set_active`,payload:{providerId:e,label:t}})}addProvider(e,t,n,r){this.send({type:`provider.add`,payload:{id:e,family:t,baseUrl:n,apiKey:r}})}removeProvider(e){this.send({type:`provider.remove`,payload:{providerId:e}})}startOAuth(e){this.send({type:`auth.oauth.start`,payload:{kind:e}})}submitOAuthCode(e,t){this.send({type:`auth.oauth.code`,payload:{kind:e,input:t}})}cancelOAuth(e){this.send({type:`auth.oauth.cancel`,payload:{kind:e}})}probeProvider(e,t){this.send({type:`provider.probe`,payload:t===void 0?{providerId:e}:{providerId:e,timeoutMs:t}})}clearProviderModels(e){this.send(Ko(e))}undoProviderClear(e,t){this.send(qo(e,t))}updateProvider(e){this.send(Jo(e))}clearContext(){this.send({type:`context.clear`,payload:this.withSession({})})}compactContext(e=!1){this.send({type:`context.compact`,payload:this.withSession({aggressive:e})})}repairContext(){this.send({type:`context.repair`,payload:this.withSession({})})}debugContext(){this.send({type:`context.debug`,payload:this.withSession({})})}listContextModes(){this.send({type:`context.modes.list`,payload:this.withSession({})})}switchContextMode(e){this.send({type:`context.mode.switch`,payload:this.withSession({id:e})})}createContextMode(e){this.send({type:`context.mode.create`,payload:this.withSession(e)})}updateContextMode(e,t){this.send({type:`context.mode.update`,payload:this.withSession({id:e,...t})})}deleteContextMode(e){this.send({type:`context.mode.delete`,payload:this.withSession({id:e})})}switchAutonomy(e){this.send({type:`autonomy.switch`,payload:{mode:e}})}updatePrefs(e){this.send({type:`prefs.update`,payload:e})}getPrefs(){this.send({type:`prefs.get`})}listTools(){this.send({type:`tools.list`})}listMemory(){this.send({type:`memory.list`})}remember(e,t){this.send({type:`memory.remember`,payload:{text:e,scope:t}})}forget(e,t){this.send({type:`memory.forget`,payload:{text:e,scope:t}})}listMcpServers(){this.send({type:`mcp.list`})}addMcpServer(e){this.send({type:`mcp.add`,payload:e})}removeMcpServer(e){this.send({type:`mcp.remove`,payload:{name:e}})}updateMcpServer(e){this.send({type:`mcp.update`,payload:e})}wakeMcpServer(e){this.send({type:`mcp.wake`,payload:{name:e}})}sleepMcpServer(e){this.send({type:`mcp.sleep`,payload:{name:e}})}discoverMcpServer(e){this.send({type:`mcp.discover`,payload:{name:e}})}enableMcpServer(e){this.send({type:`mcp.enable`,payload:{name:e}})}disableMcpServer(e){this.send({type:`mcp.disable`,payload:{name:e}})}restartMcpServer(e){this.send({type:`mcp.restart`,payload:{name:e}})}listSkills(){this.send({type:`skills.list`})}getSkillContent(e,t){this.send({type:`skills.content`,payload:{name:e,source:t}})}installSkill(e,t){this.send({type:`skills.install`,payload:{ref:e,global:t}})}uninstallSkill(e,t){this.send({type:`skills.uninstall`,payload:{name:e,global:t}})}checkForUpdates(e,t){this.send({type:`skills.update`,payload:{name:e,global:t}})}createSkill(e,t,n){this.send({type:`skills.create`,payload:{name:e,description:t,scope:n}})}editSkill(e,t){this.send({type:`skills.edit`,payload:{name:e,body:t}})}exportAllSkills(){this.send({type:`skills.export`})}getDiag(){this.send({type:`diag.get`,payload:this.withSession({})})}getStats(){this.send({type:`stats.get`,payload:this.withSession({})})}saveSession(){this.send({type:`session.save`,payload:this.withSession({})})}resumeSessionById(e){this.send({type:`session.resume`,payload:this.withSession({id:e})})}listModes(){this.send({type:`modes.list`})}switchMode(e){this.send({type:`mode.switch`,payload:{id:e}})}listFiles(e,t,n){this.send({type:`files.list`,payload:{query:e,limit:t,path:n}})}requestCompletion(e){this.send({type:`completion.request`,payload:e})}getTodos(){this.send({type:`todos.get`,payload:this.withSession({})})}clearTodos(){this.send({type:`todos.clear`,payload:this.withSession({})})}removeTodo(e){let t=typeof e==`number`?{index:e}:{id:e};this.send({type:`todos.remove`,payload:this.withSession(t)})}updateTodoStatus(e,t){this.send({type:`todo.update`,payload:this.withSession({id:e,status:t})})}getTasks(){this.send({type:`tasks.get`,payload:this.withSession({})})}updateTaskStatus(e,t){this.send({type:`task.update`,payload:this.withSession({id:e,status:t})})}getPlan(){this.send({type:`plan.get`,payload:this.withSession({})})}updatePlanItem(e,t){this.send({type:`plan.item.update`,payload:this.withSession({target:e,status:t})})}listSessions(e=50){this.send({type:`sessions.list`,payload:this.withSession({limit:e})})}deleteSession(e){this.send({type:`session.delete`,payload:{id:e}})}setWorkingDir(e){this.send({type:`working_dir.set`,payload:{path:e}})}resumeSession(e){this.send({type:`session.resume`,payload:this.withSession({id:e})})}ping(){this.send({type:`ping`})}refineModel(e){this.send({type:`model.refine`,payload:{text:e}})}disconnect(){this.shouldReconnect=!1,this.reconnectTimer&&=(clearTimeout(this.reconnectTimer),null),this.messageQueue.length=0,this.ws?.close(),this.ws=null}get isConnected(){return this.ws?.readyState===WebSocket.OPEN}get currentSessionId(){return this.sessionId}},ss=null;function W(e){return ss||=new os(e),ss}function cs(e){if(!e)return e;let t=e.split(/\n{2,}/),n=[];for(let e of t)n.length>0&&n[n.length-1]?.trim()===e.trim()||n.push(e);return n.map(e=>{let t=e.split(`
10
- `),n=[];for(let e of t)n.length>0&&e.trim().length>0&&n[n.length-1]?.trim()===e.trim()||n.push(e);return n.join(`
11
- `)}).join(`
12
-
13
- `)}function ls(e){let t=new Map;for(let n of e)n.role===`tool`&&n.toolUseId&&t.set(n.toolUseId,n.id);return t}var G=h()(Ue((e,t)=>({messages:[],currentAssistantMessageId:null,currentToolId:null,isLoading:!1,abortController:null,executions:new Map,toolMessageIdsByUseId:new Map,queue:[],runStart:null,thinkingBuffer:``,thinkingStartedAt:null,thinkingLogBuffer:``,thinkingLogStartedAt:null,boundSessionId:null,addMessage:t=>{let n=`msg_${Date.now()}_${crypto.randomUUID().slice(0,8)}`,r={...t,id:n,timestamp:t.timestamp??Date.now()};return e(e=>{let i={messages:[...e.messages,r],currentAssistantMessageId:t.role===`assistant`?n:e.currentAssistantMessageId};if(r.role===`tool`&&r.toolUseId){let t=new Map(e.toolMessageIdsByUseId);t.set(r.toolUseId,n),i.toolMessageIdsByUseId=t}return i}),n},setMessages:t=>{e({messages:t,currentAssistantMessageId:null,currentToolId:null,executions:new Map,toolMessageIdsByUseId:ls(t),thinkingBuffer:``,thinkingStartedAt:null,thinkingLogBuffer:``,thinkingLogStartedAt:null})},updateMessage:(t,n)=>{e(e=>({messages:e.messages.map(e=>e.id===t?{...e,...n}:e)}))},appendToMessage:(t,n)=>{e(e=>({messages:e.messages.map(e=>e.id===t?{...e,content:e.content+n}:e)}))},finalizeMessage:t=>{e(e=>({messages:e.messages.map(e=>e.id===t?{...e,content:cs(e.content),streaming:!1}:e)}))},setToolResult:(t,n,r)=>{e(e=>({messages:e.messages.map(e=>e.id===t?{...e,toolResult:n,isError:!r,progressLines:void 0}:e)}))},appendToolProgress:(e,n)=>{t().appendToolProgressLines(e,[n])},appendToolProgressLines:(t,n)=>{n.length!==0&&e(e=>({messages:e.messages.map(e=>{if(e.id!==t)return e;let r=e.progressLines??[];return r.push(...n),r.length>30&&r.splice(0,r.length-30),{...e,progressLines:r}})}))},getToolMessageId:e=>t().toolMessageIdsByUseId.get(e),setToolResultByUseId:(e,n,r)=>{let i=t().toolMessageIdsByUseId.get(e);i&&t().setToolResult(i,n,r)},appendToolProgressLinesByUseId:(e,n)=>{let r=t().toolMessageIdsByUseId.get(e);r&&t().appendToolProgressLines(r,n)},setLoading:t=>e({isLoading:t}),setAbortController:t=>e({abortController:t}),clearMessages:()=>e({messages:[],currentAssistantMessageId:null,currentToolId:null,executions:new Map,toolMessageIdsByUseId:new Map,thinkingBuffer:``,thinkingStartedAt:null,thinkingLogBuffer:``,thinkingLogStartedAt:null,boundSessionId:null}),setBoundSessionId:t=>e({boundSessionId:t}),setCurrentAssistantMessage:t=>e({currentAssistantMessageId:t}),setCurrentToolId:t=>e({currentToolId:t}),truncateAfter:t=>e(e=>{let n=e.messages.findIndex(e=>e.id===t);if(n===-1)return e;let r=e.messages.slice(0,n+1);return{messages:r,currentAssistantMessageId:null,currentToolId:null,toolMessageIdsByUseId:ls(r)}}),addExecution:t=>{e(e=>{let n=new Map(e.executions);return n.set(t.id,t),{executions:n}})},updateExecution:(t,n)=>{e(e=>{let r=new Map(e.executions),i=r.get(t);return i&&r.set(t,{...i,...n}),{executions:r}})},enqueue:(t,n=`queue`)=>e(e=>({queue:[...e.queue,{text:t,mode:n,addedAt:Date.now()}]})),dequeue:()=>{let{queue:n}=t();if(n.length===0)return null;let[r,...i]=n;return e({queue:i}),Ur(r)},removeQueued:t=>e(e=>({queue:e.queue.filter((e,n)=>n!==t)})),clearQueue:()=>e({queue:[]}),setRunStart:t=>e({runStart:t}),appendThinking:t=>e(e=>({thinkingBuffer:e.thinkingBuffer+t,thinkingStartedAt:e.thinkingStartedAt??Date.now(),thinkingLogBuffer:e.thinkingLogBuffer+t,thinkingLogStartedAt:e.thinkingLogStartedAt??Date.now()})),clearThinking:()=>e({thinkingBuffer:``,thinkingStartedAt:null}),flushThinkingLog:e=>{let{thinkingLogBuffer:n,thinkingLogStartedAt:r}=t(),i=n.trim();if(!i)return;let a=r??Date.now();t().addMessage({role:`system`,content:``,thinkingLog:{iteration:e,text:i,startedAt:a,durationMs:Math.max(0,Date.now()-a)}}),t().clearThinkingLog()},clearThinkingLog:()=>e({thinkingLogBuffer:``,thinkingLogStartedAt:null})}),{name:`wrongstack-chat`,version:1,partialize:e=>({messages:e.messages,queue:e.queue,boundSessionId:e.boundSessionId,thinkingLogBuffer:e.thinkingLogBuffer}),migrate:(e,t)=>{if(t>1)return null;let n=e??{};return{messages:Array.isArray(n.messages)?n.messages:[],queue:Array.isArray(n.queue)?n.queue:[],boundSessionId:typeof n.boundSessionId==`string`?n.boundSessionId:null,thinkingLogBuffer:typeof n.thinkingLogBuffer==`string`?n.thinkingLogBuffer:``}},onRehydrateStorage:()=>(e,t)=>{t||typeof window<`u`&&(window.__wrongstackChatRehydrated=!0)}})),K=h()(Ue(e=>({provider:`anthropic`,model:`claude-sonnet-4-20250514`,wsUrl:ns(),wsConnected:!1,wsStatus:{state:`connecting`},theme:`system`,autoConnect:!0,soundOnComplete:!1,setProvider:t=>e({provider:t}),setModel:t=>e({model:t}),setConfig:t=>e(t),setTheme:t=>e({theme:t}),setWsConnected:t=>e({wsConnected:t}),setWsStatus:t=>e({wsStatus:t,wsConnected:t.state===`open`}),setSoundOnComplete:t=>e({soundOnComplete:t})}),{name:`wrongstack-config`,partialize:e=>({provider:e.provider,model:e.model,baseUrl:e.baseUrl,apiKey:e.apiKey,theme:e.theme,autoConnect:e.autoConnect,soundOnComplete:e.soundOnComplete}),merge:(e,t)=>({...t,...e,wsUrl:ns(),wsConnected:!1,wsStatus:{state:`connecting`}})})),us=1,q=h()(Ue(e=>({session:null,totalTokens:{input:0,output:0,cacheRead:0,cacheWrite:0},lastInputTokens:0,cost:0,startTime:null,maxContext:0,inputCost:0,outputCost:0,cacheReadCost:0,projectName:``,projectRoot:``,cwd:``,mode:`default`,modes:[],contextMode:`balanced`,contextModes:[],iteration:null,todos:[],lastVisitedAt:0,setSession:t=>e({session:t,lastVisitedAt:Date.now()}),updateUsage:t=>e(e=>{let n=t.input+(t.cacheRead??0)+(t.cacheWrite??0),r=t.cacheRead??0,i=t.cacheWrite??0;return{totalTokens:{input:e.totalTokens.input+t.input,output:e.totalTokens.output+t.output,cacheRead:(e.totalTokens.cacheRead??0)+r,cacheWrite:(e.totalTokens.cacheWrite??0)+i},lastInputTokens:n||e.lastInputTokens}}),addCost:t=>e(e=>({cost:e.cost+t})),startSession:t=>e({session:t,startTime:Date.now(),iteration:null,lastInputTokens:0,totalTokens:{input:0,output:0,cacheRead:0,cacheWrite:0},cost:0,lastVisitedAt:Date.now()}),endSession:()=>e({session:null,startTime:null,iteration:null}),setEnv:t=>e(e=>({maxContext:t.maxContext??e.maxContext,projectRoot:t.projectRoot??e.projectRoot,projectName:t.projectName??e.projectName,cwd:t.cwd??e.cwd,mode:t.mode??e.mode,contextMode:t.contextMode??e.contextMode,inputCost:t.inputCost??e.inputCost,outputCost:t.outputCost??e.outputCost,cacheReadCost:t.cacheReadCost??e.cacheReadCost})),setIteration:t=>e({iteration:t}),setContextUsage:(t,n)=>e(e=>({lastInputTokens:t,maxContext:n??e.maxContext})),setModes:t=>e({modes:t}),setContextModes:t=>e({contextModes:t}),setTodos:t=>e({todos:t})}),{name:`wrongstack-session`,version:us,partialize:e=>({session:e.session,projectName:e.projectName,projectRoot:e.projectRoot,cwd:e.cwd,mode:e.mode,contextMode:e.contextMode,lastVisitedAt:e.lastVisitedAt}),migrate:(e,t)=>{if(t>us)return null;let n=e??{};return n.session!==null&&n.session!==void 0&&typeof n.session!=`object`?null:{session:n.session??null,projectName:typeof n.projectName==`string`?n.projectName:``,projectRoot:typeof n.projectRoot==`string`?n.projectRoot:``,cwd:typeof n.cwd==`string`?n.cwd:``,mode:typeof n.mode==`string`?n.mode:`default`,contextMode:typeof n.contextMode==`string`?n.contextMode:`balanced`,lastVisitedAt:typeof n.lastVisitedAt==`number`?n.lastVisitedAt:0}},onRehydrateStorage:()=>(e,t)=>{t||typeof window<`u`&&(window.__wrongstackSessionRehydrated=!0)}})),ds=[`chat`,`agents`,`history`,`files`,`changes`,`mailbox`,`skills`,`design`,`worktrees`,`officemap`];function fs(e){return ds.includes(e)?e:e===`context`?`chat`:e===`sessions`?`history`:e===`projects`?`chat`:e===`officemap`?`officemap`:`chat`}var ps=[`chat`,`settings`,`autophase`,`specs`,`sddboard`,`sddwizard`,`files`,`changes`,`sessions`,`setup`,`skill`,`officemap`,`mailbox`,`debug`,`design-gallery`,`refresh-debug`,`analytics`];function ms(e){return ps.includes(e)?e:`chat`}var hs=[`autophase`,`goal`,`fleet`,`work`,`worktrees`,`collab`];function gs(e){return e==null||!hs.includes(e)?null:e}function _s(){if(typeof window>`u`)return!1;if(window.wrongstackDesktopHost)return!0;try{return new URLSearchParams(window.location.search).get(`shell`)===`desktop`}catch{return!1}}function vs(e={}){return{currentView:`chat`,activeActivity:`chat`,sidebarOpen:e.sidebarOpen??!1,dockSection:null,dockCustomizeOpen:!1,fleetMonitorOpen:!1,agentsMonitorOpen:!1,processMonitorOpen:!1,queuePanelOpen:!1,inspectorOpen:!1,terminalOpen:!1,paletteOpen:!1,shortcutsOpen:!1,searchOpen:!1,searchQuery:``,searchActiveMessageId:null,modelSwitcherOpen:!1,promptLibraryOpen:!1,selectedMailMessage:null,refinePanel:null}}var J=h()(Ue(e=>({sidebarOpen:!0,activeActivity:`chat`,settingsOpen:!1,currentView:`chat`,showConfirmDialog:!1,confirmInfo:null,paletteOpen:!1,shortcutsOpen:!1,searchOpen:!1,searchQuery:``,searchActiveMessageId:null,scrollTarget:null,promptHistory:[],sidebarWidth:304,pinnedIds:[],compactMode:!1,modelSwitcherOpen:!1,favoriteSessionIds:[],sessionNicknames:{},fileExplorerWidth:220,refineEnabled:!0,refinePanel:null,promptLibraryOpen:!1,promptInsertRequest:null,dockSection:null,workDashboardTab:`todos`,hiddenChips:[],dockCustomizeOpen:!1,fleetMonitorOpen:!1,agentsMonitorOpen:!1,inspectorOpen:!1,inspectorTab:`fleet`,processMonitorOpen:!1,queuePanelOpen:!1,terminalOpen:!1,terminalCreateNonce:0,selectedMailMessage:null,skillsState:{selectedSkill:null,navHistory:[],historyIndex:-1,detailOpen:!1,knownRefs:{},updateAvailableCount:0},selectActivity:t=>e({activeActivity:t}),toggleSidebar:()=>e(e=>({sidebarOpen:!e.sidebarOpen})),setSidebarOpen:t=>e({sidebarOpen:t}),setSettingsOpen:t=>e({settingsOpen:t}),setCurrentView:t=>e({currentView:ms(t)}),showConfirm:t=>e({showConfirmDialog:!0,confirmInfo:t}),hideConfirm:()=>e({showConfirmDialog:!1,confirmInfo:null}),setPaletteOpen:t=>e({paletteOpen:t}),setShortcutsOpen:t=>e({shortcutsOpen:t}),setSearchOpen:t=>e({searchOpen:t,searchQuery:``,searchActiveMessageId:null}),setSearchQuery:t=>e({searchQuery:t}),setSearchActiveMessageId:t=>e({searchActiveMessageId:t}),requestScrollToMessage:t=>e(e=>({scrollTarget:{id:t,nonce:(e.scrollTarget?.nonce??0)+1}})),pushPrompt:t=>e(e=>{let n=t.trim();return n?{promptHistory:[n,...e.promptHistory.filter(e=>e!==n)].slice(0,50)}:e}),setSidebarWidth:t=>e({sidebarWidth:Math.max(240,Math.min(560,Math.round(t)))}),togglePin:t=>e(e=>({pinnedIds:e.pinnedIds.includes(t)?e.pinnedIds.filter(e=>e!==t):[...e.pinnedIds,t]})),unpinAll:()=>e({pinnedIds:[]}),toggleCompactMode:()=>e(e=>({compactMode:!e.compactMode})),setModelSwitcherOpen:t=>e({modelSwitcherOpen:t}),toggleFavoriteSession:t=>e(e=>({favoriteSessionIds:e.favoriteSessionIds.includes(t)?e.favoriteSessionIds.filter(e=>e!==t):[...e.favoriteSessionIds,t]})),setSessionNickname:(t,n)=>e(e=>{let r=n.trim(),i={...e.sessionNicknames};return r?i[t]=r:delete i[t],{sessionNicknames:i}}),setFileExplorerWidth:t=>e({fileExplorerWidth:Math.max(160,Math.min(400,Math.round(t)))}),toggleRefineEnabled:()=>e(e=>({refineEnabled:!e.refineEnabled})),setRefinePanel:t=>e({refinePanel:t}),setPromptLibraryOpen:t=>e({promptLibraryOpen:t}),requestPromptInsert:t=>e({promptInsertRequest:t,promptLibraryOpen:!1}),clearPromptInsert:()=>e({promptInsertRequest:null}),setDockSection:t=>e({dockSection:t}),setWorkDashboardTab:t=>e({workDashboardTab:t}),toggleDockSection:t=>e(e=>({dockSection:e.dockSection===t?null:t})),toggleChipHidden:t=>e(e=>{let n=e.hiddenChips.includes(t);return{hiddenChips:n?e.hiddenChips.filter(e=>e!==t):[...e.hiddenChips,t],dockSection:!n&&e.dockSection===t?null:e.dockSection}}),showDockChip:t=>e(e=>({hiddenChips:e.hiddenChips.filter(e=>e!==t)})),setDockCustomizeOpen:t=>e({dockCustomizeOpen:t}),setFleetMonitorOpen:t=>e({fleetMonitorOpen:t}),setAgentsMonitorOpen:t=>e({agentsMonitorOpen:t}),setInspectorOpen:t=>e({inspectorOpen:t}),setInspectorTab:t=>e({inspectorTab:t}),toggleInspector:()=>e(e=>({inspectorOpen:!e.inspectorOpen})),setProcessMonitorOpen:t=>e({processMonitorOpen:t}),setQueuePanelOpen:t=>e({queuePanelOpen:t}),setTerminalOpen:t=>e({terminalOpen:t}),toggleTerminal:()=>e(e=>({terminalOpen:!e.terminalOpen})),requestTerminalCreate:()=>e(e=>({terminalCreateNonce:e.terminalCreateNonce+1})),setSkillsState:t=>e({skillsState:t}),setSelectedMailMessage:t=>e({selectedMailMessage:t})}),{name:`wrongstack-ui`,version:5,migrate:(e,t)=>{let n=e??{};return n.activeActivity=fs(n.activeActivity),typeof n.sidebarWidth==`number`&&(n.sidebarWidth=Math.max(240,Math.min(560,n.sidebarWidth))),t<2&&(delete n.fleetDrawerOpen,delete n.agentsDrawerOpen),`currentView`in n&&(n.currentView=ms(n.currentView)),`dockSection`in n&&(n.dockSection=gs(n.dockSection)),n},merge:(e,t)=>{let n={...t,...e??{}};return n.activeActivity=fs(n.activeActivity),n.currentView=ms(n.currentView),n.dockSection=gs(n.dockSection),n.sidebarWidth=Math.max(240,Math.min(560,n.sidebarWidth)),_s()?{...n,...vs({sidebarOpen:!1})}:n},partialize:e=>({sidebarOpen:e.sidebarOpen,activeActivity:e.activeActivity,sidebarWidth:e.sidebarWidth,promptHistory:e.promptHistory,pinnedIds:e.pinnedIds,compactMode:e.compactMode,favoriteSessionIds:e.favoriteSessionIds,sessionNicknames:e.sessionNicknames,fileExplorerWidth:e.fileExplorerWidth,refineEnabled:e.refineEnabled,hiddenChips:e.hiddenChips,workDashboardTab:e.workDashboardTab,inspectorOpen:e.inspectorOpen,inspectorTab:e.inspectorTab,skillsState:e.skillsState,currentView:e.currentView,dockSection:e.dockSection})}));function ys(e={}){J.setState(vs(e))}var bs=h()(e=>({messages:[],agents:[],setMessages:t=>e({messages:t}),setAgents:t=>e({agents:t})}));function xs(e){return e.messages.filter(e=>!e.completed&&(e.readByCount??0)===0).length}var Ss=h()(e=>({info:null,setInfo:t=>e({info:t}),clear:()=>e({info:null})})),Cs=h(e=>({sideEffects:[],loading:!1,setSideEffects:t=>e({sideEffects:t,loading:!1}),setLoading:t=>e({loading:t}),clear:()=>e({sideEffects:[],loading:!1})})),ws=h()(e=>({files:[],error:null,loadingList:!1,selectedPath:null,diff:null,loadingDiff:!1,setFiles:(t,n)=>e({files:t,error:n,loadingList:!1}),setListLoading:t=>e({loadingList:t}),select:t=>e({selectedPath:t,diff:null,loadingDiff:!!t}),setDiff:t=>e({diff:t,loadingDiff:!1}),setDiffLoading:t=>e({loadingDiff:t}),clear:()=>e({files:[],error:null,selectedPath:null,diff:null,loadingDiff:!1})})),Ts=h()(e=>({entries:[],loading:!1,error:null,setEntries:(t,n=null)=>e({entries:t,error:n,loading:!1}),setLoading:t=>e({loading:t}),removeEntry:t=>e(e=>({entries:e.entries.filter(e=>e.id!==t)})),clearHistory:()=>e({entries:[]})})),Es=h()(e=>({worktrees:[],baseBranch:``,activity:[],orphans:[],canClean:!1,cleanResult:null,mergeResult:null,diffByDir:{},setSnapshot:(t,n)=>e({worktrees:t,baseBranch:n}),pushEvent:t=>e(e=>({activity:[...e.activity,t].slice(-40)})),setOrphans:(t,n,r)=>e({orphans:t,canClean:n,cleanBlockedReason:r}),setCleanResult:t=>e({cleanResult:t}),setMergeResult:t=>e({mergeResult:t}),setDiff:(t,n)=>e(e=>({diffByDir:{...e.diffByDir,[t]:n}}))})),Y=Kt(),Ds=/(?:💡\s*Next steps?|<next_steps>)\s*\n+/i,Os=/^(?:(\d+)[.)]\s*|[-*•]\s*)(.+?)(\s+auto="true")?$/,ks=6;function As(e,t=!0){let n=t?Ds.exec(e):Ms().exec(e);if(!n)return{steps:[],stripped:e};let r=n.index+n[0].length,i=e.slice(r),a=i.split(`
14
- `),o=[],s=new Set,c=0,l=0;for(let e of a){let t=e.trim();if(t===`</next_steps>`){c+=e.length+1;break}if(!t){c+=e.length+1;continue}let n=Os.exec(t);if(!n)break;let r=n[1],i=n[2].trim(),a=!!n[3],u=r===void 0?o.length+1:Number.parseInt(r,10);if(s.has(u)){c+=e.length+1;continue}if(s.add(u),o.push(a?{index:u,text:i,auto:!0}:{index:u,text:i}),c+=e.length+1,l++,l>=ks)break}if(o.length===0||t&&/<next_steps>/i.test(n[0])&&!i.includes(`</next_steps>`))return{steps:[],stripped:e};let u=n.index,d=r+c;return{steps:o,stripped:(e.slice(0,u)+e.slice(d)).replace(/\n{3,}/g,`
15
-
16
- `).trim()}}var js=[{re:/💡\s*Next steps?\s*\n+/i,label:`emoji`},{re:/##?\s*Next steps?\s*\n+/i,label:`markdown`},{re:/\n{1,2}Next steps?\s*\n+/i,label:`plain`},{re:/<next_steps>\s*\n+/i,label:`xml-tag`}];function Ms(){let e=js.map(({re:e})=>`(?:${e.source})`).join(`|`);return new RegExp(e,`i`)}function Ns(e){return e.replace(/<next_steps\b[^>]*>[\s\S]*?<\/next_steps>/gi,``).replace(/<next_steps\b[^>]*\/?>/gi,``).replace(/\n{3,}/g,`
17
-
18
- `).trim()}function Ps(e){let t=document.querySelector(`textarea`);t&&((Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,`value`)?.set)?.call(t,e),t.dispatchEvent(new Event(`input`,{bubbles:!0})),t.focus())}function Fs({delayMs:e,onComplete:t}){let[n,r]=(0,U.useState)(Math.ceil(e/1e3));return(0,U.useEffect)(()=>{if(n<=0){t();return}let e=setTimeout(()=>r(e=>e-1),1e3);return()=>clearTimeout(e)},[n,t]),(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-primary font-medium`,children:[(0,Y.jsx)(ke,{className:`h-3 w-3`}),n,`s`]})}function Is({steps:e,yoloMode:t=!1,autoMode:n=!1,autoDelayMs:r=3e4,onAutoSubmit:i,canAutoSubmit:a=!0}){let{t:o}=V();if(e.length===0)return null;let s=t&&n&&a,c=s?e.find(e=>e.auto):void 0;return(0,Y.jsxs)(`div`,{className:`mt-4 rounded-xl border border-primary/20 bg-primary/[0.03] overflow-hidden animate-message`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-3.5 py-2 border-b border-primary/10 bg-primary/[0.04]`,children:[(0,Y.jsx)(`span`,{className:`flex items-center justify-center w-5 h-5 rounded-md bg-primary/15 text-primary`,children:(0,Y.jsx)(ye,{className:`h-3 w-3`})}),(0,Y.jsx)(`span`,{className:`text-xs font-semibold text-foreground/90`,children:o(`activity:nextSteps.header`)}),s&&c?(0,Y.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-xs text-primary`,children:[(0,Y.jsx)(ke,{className:`h-3 w-3`}),o(`activity:nextSteps.autoSubmitting`),` `,(0,Y.jsx)(Fs,{delayMs:r,onComplete:()=>i?.(c.text)})]}):(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground ml-auto`,children:o(`activity:nextSteps.clickToFill`)})]}),(0,Y.jsx)(`div`,{className:`flex flex-col p-2 gap-1`,children:e.map(e=>{let t=s&&e.auto;return(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>Ps(e.text),className:`group flex items-center gap-2.5 w-full text-left px-3 py-2 rounded-lg transition-all border ${t?`bg-primary/10 border-primary/30 ring-1 ring-primary/20`:`border-transparent hover:bg-primary/[0.08] hover:shadow-sm hover:border-primary/20`}`,title:o(`activity:nextSteps.clickToFillTitle`,{text:e.text}),children:[(0,Y.jsx)(`span`,{className:`flex items-center justify-center w-5 h-5 rounded-md text-[11px] font-mono font-semibold tabular-nums shrink-0 transition-colors ${t?`bg-primary/30 text-primary`:`bg-muted/80 group-hover:bg-primary/20 text-muted-foreground group-hover:text-primary`}`,children:e.index}),(0,Y.jsx)(it,{className:`h-3.5 w-3.5 shrink-0 transition-all ${t?`text-primary`:`text-muted-foreground/60 group-hover:text-primary group-hover:translate-x-0.5`}`}),(0,Y.jsx)(`span`,{className:`text-sm leading-snug flex-1 min-w-0 transition-colors ${t?`text-foreground font-medium`:`text-foreground/80 group-hover:text-foreground`}`,children:e.text}),e.auto&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-primary/70`,children:[n&&e.index===1&&!s?(0,Y.jsx)(`span`,{title:o(`activity:nextSteps.willAutoSubmit`),children:`⏩`}):(0,Y.jsx)(ke,{className:`h-3 w-3`}),o(`activity:nextSteps.auto`)]}),(0,Y.jsx)(Pn,{className:`h-3.5 w-3.5 shrink-0 transition-all ${t?`opacity-100 text-primary/60`:`opacity-0 group-hover:opacity-100 text-primary/60`}`})]},e.index)})})]})}var Ls=12,Rs=20,zs=500,Bs=[];function Vs(e,t,n){return{id:e,name:t?.trim()||e,sessionId:n,status:`running`,iteration:0,toolCalls:0,costUsd:0,ctxPct:0,ctxTokens:0,maxContext:0,extensions:0,startedAt:Date.now(),toolLog:[],sparklineBins:Array(Ls).fill(0)}}var Hs=0;function Us(){return`tl_${Date.now()}_${++Hs}`}function Ws(e,t){return[t,...e].slice(0,Rs)}function Gs(e){switch(e){case`text`:case`thinking`:case`tool_use`:case`tool_result`:case`error`:case`status`:case`system`:return e;default:return`status`}}function Ks(e,t){return e.subagentId!==t.subagentId||e.kind!==t.kind||e.iteration!==t.iteration||e.toolName!==t.toolName?!1:e.kind===`text`||e.kind===`thinking`}function qs(e,t){let n=e[e.length-1];return n&&Ks(n,t)?[...e.slice(0,-1),{...n,content:`${n.content}${t.content}`,ts:t.ts}].slice(-1e3):[...e,t].slice(-1e3)}function Js(e){return[e[0]+1,...e.slice(0,Ls-1)]}function Ys(e){return Number.isFinite(e)?Math.max(0,Math.min(100,e)):0}var Xs=h()((e,t)=>({agents:new Map,leaderId:void 0,fleetTokensIn:0,fleetTokensOut:0,fleetConcurrency:0,fleetConcurrencyMax:4,eventTimeline:[],agentTimeline:[],agentTranscripts:new Map,pushAgentTimelineEntry:t=>e(e=>{let n={id:`agent_tl_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,...t,kind:Gs(t.kind)},r=new Map(e.agentTranscripts);return r.set(n.subagentId,qs(r.get(n.subagentId)??[],n)),{agentTimeline:[n,...e.agentTimeline].slice(0,zs),agentTranscripts:r}}),clear:()=>e({agents:new Map,leaderId:void 0,fleetTokensIn:0,fleetTokensOut:0,fleetConcurrency:0,eventTimeline:[],agentTimeline:[],agentTranscripts:new Map}),getAgentsBySession:e=>{let n=[];for(let r of t().agents.values())r.sessionId===e&&n.push(r);return n},getAgentTranscript:e=>t().agentTranscripts.get(e)??Bs,applyEvent:t=>e(e=>{let n=new Map(e.agents),r=new Map(e.agentTranscripts),i=e.eventTimeline,a=e.leaderId,o=e.fleetTokensIn,s=e.fleetTokensOut;if(t.kind===`session_stopped`&&t.sessionId){let i=new Set;for(let[e,a]of n)a.sessionId===t.sessionId&&(n.delete(e),r.delete(e),i.add(e));return{agents:n,agentTranscripts:r,agentTimeline:e.agentTimeline.filter(e=>!i.has(e.subagentId)),leaderId:void 0,fleetTokensIn:0,fleetTokensOut:0}}if(t.kind===`leader_updated`&&t.subagentId){let r=e.leaderId;if(r&&r!==t.subagentId){let e=n.get(r);e&&n.set(r,{...e,isLeader:!1})}a=t.subagentId;let o=n.get(t.subagentId)??Vs(t.subagentId,t.name,t.sessionId);return n.set(t.subagentId,{...o,isLeader:!0,name:t.name?.trim()||o.name}),i=Ws(i,{id:Us(),kind:`leader_updated`,agentId:t.subagentId,agentName:t.name??a,timestamp:Date.now(),message:`${t.name??t.subagentId} became leader`}),{agents:n,leaderId:a,eventTimeline:i}}if(!t.subagentId)return e;let c=n.get(t.subagentId)??Vs(t.subagentId,t.name,t.sessionId),l={...c},u=Date.now();switch(t.kind){case`spawned`:l.name=t.name?.trim()||l.name,l.provider=t.provider??l.provider,l.model=t.model??l.model,l.description=t.description??l.description,l.taskId=t.taskId??l.taskId,l.sessionId=t.sessionId??l.sessionId,l.status=`running`,l.sparklineBins=Array(Ls).fill(0),i=Ws(i,{id:Us(),kind:`spawned`,agentId:t.subagentId,agentName:l.name,timestamp:u,message:`${l.name} spawned`});break;case`task_started`:l.description=t.description??l.description,l.taskId=t.taskId??l.taskId,l.status=`running`,i=Ws(i,{id:Us(),kind:`task_started`,agentId:t.subagentId,agentName:l.name,timestamp:u,message:`${l.name} started: ${t.description??`new task`}`});break;case`tool_executed`:{let e=typeof t.ok==`boolean`?t.ok:!0,n=typeof t.durationMs==`number`?t.durationMs:0;l.lastTool=t.toolName??l.lastTool,l.toolCalls+=1,l.toolLog=[{name:t.toolName??`unknown`,ok:e,durationMs:n,at:u},...l.toolLog].slice(0,50),l.sparklineBins=Js(l.sparklineBins),i=Ws(i,{id:Us(),kind:`tool_executed`,agentId:t.subagentId,agentName:l.name,timestamp:u,message:`${l.name} ${e?`✓`:`✗`} ${t.toolName??`tool`}`,value:n});break}case`iteration_summary`:l.iteration=t.iteration??l.iteration,typeof t.toolCalls==`number`&&(l.toolCalls=t.toolCalls),typeof t.costUsd==`number`&&(l.costUsd=t.costUsd),l.currentTool=t.currentTool??l.currentTool,typeof t.partialText==`string`&&t.partialText&&(l.partialText=t.partialText),l.sparklineBins=Js(l.sparklineBins),i=Ws(i,{id:Us(),kind:`iteration_summary`,agentId:t.subagentId,agentName:l.name,timestamp:u,message:`${l.name} iter ${t.iteration??l.iteration} · ${t.currentTool?`${t.currentTool}`:``}`,value:t.costUsd});break;case`budget_warning`:{let e=t.budgetKind??`budget`,n=typeof t.used==`number`?t.used:0,r=typeof t.limit==`number`?t.limit:0;l.budgetWarning={kind:e,used:n,limit:r},i=Ws(i,{id:Us(),kind:`budget_warning`,agentId:t.subagentId,agentName:l.name,timestamp:u,message:`${l.name} hit ${e} budget ${n}/${r}`,value:n});break}case`budget_extended`:l.extensions=t.totalExtensions??l.extensions+1,l.budgetWarning=void 0,i=Ws(i,{id:Us(),kind:`budget_extended`,agentId:t.subagentId,agentName:l.name,timestamp:u,message:`${l.name} extended budget ⚡×${l.extensions}`});break;case`ctx_pct`:l.ctxPct=Ys(Math.round(Math.max(0,t.load??0)*100)),l.ctxTokens=t.tokens??l.ctxTokens,l.maxContext=t.maxContext??l.maxContext,l.ctxPct>=80&&!l.budgetWarning&&(l.budgetWarning=l.ctxPct>=100?{kind:`hard`,used:l.ctxPct,limit:100}:{kind:`soft`,used:l.ctxPct,limit:100}),typeof t.costUsd==`number`&&(l.costUsd=t.costUsd),typeof t.tokensIn==`number`&&(l.tokensIn=t.tokensIn,o=o-(c.tokensIn??0)+t.tokensIn),typeof t.tokensOut==`number`&&(l.tokensOut=t.tokensOut,s=s-(c.tokensOut??0)+t.tokensOut),i=Ws(i,{id:Us(),kind:`ctx_pct`,agentId:t.subagentId,agentName:l.name,timestamp:u,message:`${l.name} ctx ${l.ctxPct}%`,value:l.ctxPct});break;case`task_completed`:{l.status=t.status===`success`?`completed`:t.status??`completed`,typeof t.iterations==`number`&&(l.iteration=t.iterations),typeof t.toolCalls==`number`&&(l.toolCalls=t.toolCalls),l.error=t.error,l.currentTool=void 0,l.completedAt=u,l.failureReason=t.failureReason??l.failureReason,typeof t.finalText==`string`&&t.finalText&&(l.finalText=Ns(t.finalText));let e=t.status===`success`?`✓ completed`:t.status===`failed`?`✗ failed${t.failureReason?` (${t.failureReason})`:``}`:t.status===`timeout`?`⏱ timeout${t.failureReason?` (${t.failureReason})`:``}`:`stopped`;i=Ws(i,{id:Us(),kind:`task_completed`,agentId:t.subagentId,agentName:l.name,timestamp:u,message:`${l.name} ${e}`,value:l.costUsd});break}}return n.set(t.subagentId,l),{agents:n,leaderId:a,fleetTokensIn:o,fleetTokensOut:s,eventTimeline:i}})}));function Zs(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return!(typeof t.iteration!=`number`||!Number.isFinite(t.iteration)||t.task!==void 0&&typeof t.task!=`string`||t.status!==void 0&&typeof t.status!=`string`||t.progress!==void 0&&(typeof t.progress!=`number`||!Number.isFinite(t.progress))||t.progressNote!==void 0&&typeof t.progressNote!=`string`||t.timestamp!==void 0&&typeof t.timestamp!=`string`)}function Qs(e){return!e||typeof e.goal!=`string`||!e.goal.trim()?null:{goal:e.goal,refinedGoal:typeof e.refinedGoal==`string`?e.refinedGoal:void 0,goalState:[`active`,`paused`,`completed`,`failed`,`abandoned`].includes(e.goalState)?e.goalState:`active`,iterations:typeof e.iterations==`number`?e.iterations:0,progress:typeof e.progress==`number`?e.progress:0,progressNote:typeof e.progressNote==`string`?e.progressNote:void 0,progressTrend:e.progressTrend===`accelerating`?`up`:e.progressTrend===`stalling`?`down`:e.progressTrend===`steady`?`stable`:void 0,deliverables:Array.isArray(e.deliverables)?e.deliverables.map((e,t)=>typeof e==`string`?{id:`d${t}`,text:e,status:/^\[[x✓]\]|✅|\(done\)/i.test(e)?`done`:`pending`}:e):void 0,journal:Array.isArray(e.journal)?e.journal.filter(Zs):void 0,lastTask:typeof e.lastTask==`string`?e.lastTask:void 0,lastStatus:typeof e.lastStatus==`string`?e.lastStatus:void 0}}var $s=h()(e=>({goal:null,setGoal:t=>e({goal:Qs(t)}),clear:()=>e({goal:null}),appendJournalEntry:t=>e(e=>e.goal?{goal:{...e.goal,iterations:Math.max(e.goal.iterations,t.iteration),lastTask:t.task??e.goal.lastTask,lastStatus:t.status??e.goal.lastStatus,journal:[t,...e.goal.journal??[]].slice(0,200)}}:e),refresh:()=>{try{W()?.send?.({type:`goal.get`})}catch{}}})),ec=h()(e=>({phases:[],activePhaseId:null,overallPercent:0,autonomous:!1,title:null,goal:null,status:`idle`,lastEvent:null,lastError:null,graphs:[],progress:null,setState:t=>e(e=>({phases:t.phases??e.phases,activePhaseId:t.activePhaseId===void 0?e.activePhaseId:t.activePhaseId,overallPercent:t.overallPercent??e.overallPercent,autonomous:t.autonomous??e.autonomous,title:t.title===void 0?e.title:t.title,goal:t.goal===void 0?e.goal:t.goal,status:t.status??e.status,lastEvent:t.lastEvent===void 0?e.lastEvent:t.lastEvent,lastError:t.lastError===void 0?e.lastError:t.lastError,graphs:t.graphs??e.graphs,progress:t.progress===void 0?e.progress:t.progress})),clear:()=>e({phases:[],activePhaseId:null,overallPercent:0,autonomous:!1,title:null,goal:null,status:`idle`,lastEvent:null,lastError:null,graphs:[],progress:null})})),tc=h()(e=>({specs:[],detail:null,expandedSpecId:null,setSpecs:t=>e({specs:t}),setDetail:t=>e({detail:t}),setExpanded:t=>e({expandedSpecId:t,detail:null})})),nc=h()(e=>({snapshot:null,boards:[],lifecycleResult:null,destroying:!1,setSnapshot:t=>e({snapshot:t}),setBoards:t=>e({boards:t}),setLifecycleResult:t=>e({lifecycleResult:t}),setDestroying:t=>e({destroying:t})})),rc=h()(e=>({snapshot:null,agentText:``,error:null,startedRunId:null,setSnapshot:t=>e({snapshot:t,error:null}),setAgentText:t=>e({agentText:t}),setError:t=>e({error:t}),setStartedRunId:t=>e({startedRunId:t}),reset:()=>e({snapshot:null,agentText:``,error:null,startedRunId:null})})),ic=h()((e,t)=>({projectRoot:``,tree:[],openFiles:[],activeFilePath:null,treeLoading:!1,error:null,setTree:(t,n)=>e({projectRoot:t,tree:n,treeLoading:!1,error:null}),openFile:(n,r)=>{let i=t();if(i.openFiles.find(e=>e.path===n)){e({openFiles:i.openFiles.map(e=>e.path===n?{...e,content:r,dirty:!1,savedContent:r}:e),activeFilePath:n});return}e({openFiles:[...i.openFiles,{path:n,content:r,dirty:!1,savedContent:r}],activeFilePath:n})},closeFile:n=>{let r=t(),i=r.openFiles.findIndex(e=>e.path===n);if(i===-1)return;let a=[...r.openFiles];a.splice(i,1);let o=r.activeFilePath;r.activeFilePath===n&&(o=a.length===0?null:i<a.length?a[i].path:a[a.length-1].path),e({openFiles:a,activeFilePath:o})},setActiveFile:t=>e({activeFilePath:t}),updateContent:(t,n)=>{e(e=>({openFiles:e.openFiles.map(e=>e.path===t?{...e,content:n,dirty:n!==e.savedContent}:e)}))},markSaved:t=>{e(e=>({openFiles:e.openFiles.map(e=>e.path===t?{...e,dirty:!1,savedContent:e.content}:e)}))},setTreeLoading:t=>e({treeLoading:t}),setError:t=>e({error:t})}));function ac(){return`ref_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function oc(e){switch(e.split(`.`).pop()?.toLowerCase()??``){case`ts`:case`tsx`:return`typescript`;case`js`:case`jsx`:return`javascript`;case`json`:return`json`;case`md`:case`mdx`:return`markdown`;case`css`:return`css`;case`scss`:return`scss`;case`html`:case`htm`:return`html`;case`py`:return`python`;case`rs`:return`rust`;case`go`:return`go`;case`rb`:return`ruby`;case`java`:return`java`;case`c`:return`c`;case`cpp`:case`hpp`:return`cpp`;case`h`:return`c`;case`sh`:case`bash`:return`bash`;case`sql`:return`sql`;case`yaml`:case`yml`:return`yaml`;case`toml`:return`toml`;default:return``}}function sc(e,t=20,n=2e3){let r=e.split(`
19
- `),i=!1,a=e;return r.length>t&&(a=r.slice(0,t).join(`
20
- `),i=!0),a.length>n&&(a=a.slice(0,n),i=!0),i&&(a=a.replace(/\s+$/,``)+`
21
- …`),a}function cc(e){if(e.length===0)return``;let t=[];for(let n of e){if(n.kind===`file`){t.push(`@${n.path}`);continue}let e=oc(n.path),r=e?`\`\`\`${e}`:"```",i=`// ${n.path}:${n.startLine}-${n.endLine}`,a=n.kind===`snippet`?sc(n.content):sc(n.preview);t.push(`${r}\n${i}\n${a}\n\`\`\``)}return t.join(`
22
-
23
- `)}var lc=h()((e,t)=>({refs:[],addRef:n=>{let r=t();if(n.kind===`file`&&r.refs.find(e=>e.kind===`file`&&e.path===n.path))return;let i={...n,id:ac()};e({refs:[...r.refs,i]})},removeRef:t=>{e(e=>({refs:e.refs.filter(e=>e.id!==t)}))},clearRefs:()=>e({refs:[]})}));function uc(e){return Math.max(0,Math.min(100,Math.round((typeof e==`number`&&Number.isFinite(e)?e:0)*100)))}function dc(e,t=!1){if(t&&e.target){if(e.kind===`agent:tool`||e.kind===`tool:executed`||e.kind===`tool:started`)return`tool`;if(e.source===`leader`||e.source===`coordinator`)return`coordinator`;if(e.kind.startsWith(`provider:`))return`provider`;if(e.kind.startsWith(`mailbox:`))return`mailbox`}switch(e.kind){case`provider:call`:case`provider:delta`:case`provider:response`:return`provider`;case`agent:spawned`:case`agent:tool`:case`agent:status`:case`agent:text`:case`agent:ctx`:case`budget:warning`:case`budget:extended`:return`agent`;case`tool:started`:case`tool:executed`:case`tool:progress`:return`tool`;case`mailbox:send`:case`mailbox:deliver`:return`mailbox`;case`collab:event`:return`system`;case`session:start`:case`session:end`:case`iteration:start`:case`iteration:end`:case`eternal:iteration`:case`fleet:snapshot`:return`session`;case`context:compacted`:case`context:repaired`:case`cost:update`:return`system`;case`error`:return`error`;default:return`system`}}function fc(e){switch(e){case`provider:call`:case`provider:delta`:case`agent:tool`:case`tool:started`:case`tool:progress`:case`iteration:start`:case`agent:text`:return`streaming`;case`agent:status`:case`iteration:end`:return`completed`;case`error`:return`error`;case`tool:executed`:return`completed`;case`session:end`:return`idle`;default:return`active`}}var pc=0;function mc(){return`viz_${Date.now()}_${++pc}`}function hc(e,t){if(e===t)return!0;if(!e||!t)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(n!==i){if(n==null||i==null||typeof n!=typeof i)return!1;if(typeof n==`object`){if(Array.isArray(n)||Array.isArray(i)||!hc(n,i))return!1;continue}return!1}}return!0}var gc={provider:`hsl(180, 80%, 55%)`,agent:`hsl(280, 80%, 65%)`,tool:`hsl(40, 90%, 55%)`,mailbox:`hsl(140, 70%, 55%)`,session:`hsl(220, 80%, 60%)`,system:`hsl(0, 0%, 60%)`,error:`hsl(0, 80%, 55%)`},_c={"provider:call":`hsl(180, 80%, 55%)`,"provider:delta":`hsl(180, 60%, 70%)`,"agent:tool":`hsl(40, 90%, 55%)`,"mailbox:send":`hsl(140, 70%, 55%)`,default:`hsl(0, 0%, 40%)`},vc=h()((e,t)=>({events:[],nodes:new Map,edges:new Map,isActive:!1,maxEvents:2e3,counters:{totalTokens:0,totalCost:0,totalToolCalls:0,activeAgents:0,completedTasks:0,errors:0,mailboxMessages:0},pushEvent:t=>e(e=>{let n=[{...t,id:t.id??mc(),timestamp:t.timestamp||Date.now()},...e.events];n.length>e.maxEvents&&(n.length=e.maxEvents);let r=Date.now(),i=t.source,a={id:i,kind:dc(t),label:t.label,status:fc(t.kind),activity:1,color:t.color??gc[dc(t)],lastSeenAt:r},o=e.nodes.get(i),s=o?{...o,...a}:a,c=!hc(o,s),l,u=!1,d;if(t.target){d=t.target;let n={id:d,kind:dc(t,!0),label:d,status:fc(t.kind),activity:.8,color:t.color??gc[dc(t,!0)],lastSeenAt:r},i=e.nodes.get(d);l=i?{...i,...n}:n,u=!hc(i,l)}let f,p=!1,m;if(t.target&&i){m=`${i}->${t.target}`;let n=e.edges.get(m),a={id:m,source:i,target:t.target,kind:t.kind,label:t.label,intensity:n?Math.min(1,n.intensity+.3):.7,color:t.color??gc[dc(t)]??`#6366f1`,lastActiveAt:r,totalMagnitude:(n?.totalMagnitude??0)+(t.magnitude??0)};f=n?{...n,...a}:a,p=!hc(n,f)}let h=e.nodes,g=e.edges;return(c||u)&&(h=new Map(e.nodes),c&&h.set(i,s),u&&l&&d&&h.set(d,l)),p&&f&&m&&(g=new Map(e.edges),g.set(m,f)),{events:n,nodes:h,edges:g}}),upsertNode:t=>e(e=>{let n=new Map(e.nodes),r=n.get(t.id);return n.set(t.id,{...r,...t,lastSeenAt:t.lastSeenAt===void 0?Date.now():t.lastSeenAt}),{nodes:n}}),removeNode:t=>e(e=>{let n=new Map(e.nodes);n.delete(t);let r=new Map(e.edges);for(let[e,n]of r)(n.source===t||n.target===t)&&r.delete(e);return{nodes:n,edges:r}}),upsertEdge:t=>e(e=>{let n=new Map(e.edges),r=n.get(t.id);return n.set(t.id,{...r,...t,lastActiveAt:t.lastActiveAt===void 0?Date.now():t.lastActiveAt,intensity:t.intensity??r?.intensity??.5,color:t.color??_c[t.kind]??_c.default,totalMagnitude:(r?.totalMagnitude??0)+(t.totalMagnitude??0)}),{edges:n}}),removeEdge:t=>e(e=>{let n=new Map(e.edges);return n.delete(t),{edges:n}}),clear:()=>e({events:[],nodes:new Map,edges:new Map,counters:{totalTokens:0,totalCost:0,totalToolCalls:0,activeAgents:0,completedTasks:0,errors:0,mailboxMessages:0}}),setActive:t=>e({isActive:t}),decayActivity:()=>e(e=>{let t=new Map(e.nodes);for(let[e,n]of t)if(n.activity>=.01){let r=n.activity*.92;t.set(e,{...n,activity:r<.01?0:r})}let n=new Map(e.edges);for(let[e,t]of n)if(t.intensity>=.01){let r=t.intensity*.9;n.set(e,{...t,intensity:r<.01?0:r})}return{nodes:t,edges:n}}),prunesStale:t=>e(e=>{let n=Date.now()-t,r=new Map(e.nodes);for(let[e,t]of r)t.lastSeenAt<n&&t.status!==void 0&&t.status!==`active`&&r.delete(e);let i=new Map(e.edges);for(let[e,t]of i)t.lastActiveAt<n&&i.delete(e);return{nodes:r,edges:i,events:e.events.filter(e=>e.timestamp>n)}})}));function yc(e,t){switch(e){case`provider.text_delta`:{let e=t.text??``;return{id:mc(),kind:`provider:delta`,timestamp:Date.now(),source:`provider`,target:`leader`,label:e.slice(0,60),magnitude:e.length,data:{text:e},color:gc.provider,flowGroup:`provider`}}case`provider.response`:{let e=t.usage,n=(e?.input??0)+(e?.output??0);return{id:mc(),kind:`provider:response`,timestamp:Date.now(),source:`provider`,target:`leader`,label:`${(e?.input??0).toLocaleString(`en-US`)} in / ${(e?.output??0).toLocaleString(`en-US`)} out`,magnitude:n,data:t,color:gc.provider,flowGroup:`provider`}}case`provider.stream_error`:{let e=t.message??`Provider stream error`;return{id:mc(),kind:`error`,timestamp:Date.now(),source:`provider`,target:`leader`,label:e.slice(0,80),magnitude:1,data:t,color:gc.error,flowGroup:`provider`}}case`tool.started`:{let e=t.name??`tool`;return{id:mc(),kind:`tool:started`,timestamp:Date.now(),source:e,target:`filesystem`,label:e,magnitude:1,data:t,color:gc.tool,flowGroup:`tool:${e}`}}case`tool.executed`:{let e=t.name??`tool`,n=t.ok??!0;return{id:mc(),kind:`tool:executed`,timestamp:Date.now(),source:e,target:`leader`,label:`${e} ${n?`✓`:`✗`} (${t.durationMs??0}ms)`,magnitude:t.durationMs??0,data:t,color:n?gc.tool:gc.error,flowGroup:`tool:${e}`}}case`tool.progress`:{let e=t.name??`tool`,n=t.event?.text??``;return{id:mc(),kind:`tool:progress`,timestamp:Date.now(),source:e,target:`leader`,label:n.slice(0,60)||e,magnitude:n.length,data:t,color:gc.tool,flowGroup:`tool:${e}`}}case`tool.loop_detected`:{let e=t.tools??``,n=t.kind??`loop`;return{id:mc(),kind:`error`,timestamp:Date.now(),source:e||n,target:`leader`,label:`${n} loop x${t.repeatCount??0}`,magnitude:t.repeatCount??1,data:t,color:gc.error,flowGroup:`tool`}}case`delegate.started`:{let e=t.target??`delegate`,n=t.task??``;return{id:mc(),kind:`agent:status`,timestamp:Date.now(),source:`leader`,target:e,label:n.slice(0,80)||`Delegating to ${e}`,magnitude:1,data:t,color:gc.agent,flowGroup:`delegate:${e}`}}case`delegate.completed`:{let e=t.subagentId??t.target??`delegate`,n=t.ok??!1;return{id:mc(),kind:n?`agent:status`:`error`,timestamp:Date.now(),source:e,target:`leader`,label:(t.summary??t.status??`delegate completed`).slice(0,80),magnitude:t.durationMs??1,data:t,color:n?gc.agent:gc.error,flowGroup:`delegate:${e}`}}case`subagent.event`:{let e=t.kind,n=t.subagentId??`unknown`,r=t.name??n;switch(e){case`spawned`:return{id:mc(),kind:`agent:spawned`,timestamp:Date.now(),source:n,target:`session`,label:`${r} spawned`,magnitude:1,data:t,color:gc.agent,flowGroup:`agent:${n}`};case`tool_executed`:{let e=t.toolName??`tool`,r=t.ok??!0;return{id:mc(),kind:`agent:tool`,timestamp:Date.now(),source:n,target:e,label:e,magnitude:t.durationMs??0,data:t,color:r?gc.tool:gc.error,flowGroup:`agent:${n}`}}case`task_completed`:{let e=t.status??`completed`;return{id:mc(),kind:`agent:status`,timestamp:Date.now(),source:n,target:`session`,label:`${r} ${e}`,magnitude:1,data:t,color:e===`success`?`hsl(140, 70%, 55%)`:gc.error,flowGroup:`agent:${n}`}}case`ctx_pct`:return{id:mc(),kind:`agent:ctx`,timestamp:Date.now(),source:n,target:`session`,label:`ctx ${uc(t.load)}%`,magnitude:t.tokens??0,data:t,color:gc.agent,flowGroup:`agent:${n}`};case`iteration_summary`:return{id:mc(),kind:`agent:text`,timestamp:Date.now(),source:n,target:`session`,label:(t.partialText??``).slice(0,80)||`iter ${t.iteration??0}`,magnitude:t.costUsd??0,data:t,color:gc.agent,flowGroup:`agent:${n}`};case`budget_extended`:return{id:mc(),kind:`budget:extended`,timestamp:Date.now(),source:n,target:`session`,label:`${r} extended budget`,magnitude:t.totalExtensions??1,data:t,color:`hsl(40, 90%, 55%)`,flowGroup:`agent:${n}`};case`budget_warning`:return{id:mc(),kind:`budget:warning`,timestamp:Date.now(),source:n,target:`session`,label:`${r} hit ${t.budgetKind??`budget`} ${t.used??0}/${t.limit??0}`,magnitude:t.used??1,data:t,color:gc.error,flowGroup:`agent:${n}`}}return null}case`mailbox.event`:{let e=t.event,n=t.from??`?`,r=t.to??`?`,i=t.subject??``,a=e===`mailbox.sent`;return{id:mc(),kind:a?`mailbox:send`:`mailbox:deliver`,timestamp:Date.now(),source:n,target:r,label:i||(a?`→ ${r}`:`← ${n}`),magnitude:1,data:t,color:gc.mailbox,flowGroup:`mailbox`}}case`iteration.started`:{let e=t.index??0;return{id:mc(),kind:`iteration:start`,timestamp:Date.now(),source:`leader`,target:`session`,label:`Iteration ${e}`,magnitude:e,data:t,color:gc.agent,flowGroup:`iteration`}}case`iteration.completed`:{let e=t.index??0;return{id:mc(),kind:`iteration:end`,timestamp:Date.now(),source:`leader`,target:`session`,label:`Iteration ${e} done`,magnitude:e,data:t,color:gc.session,flowGroup:`iteration`}}case`ctx.pct`:{let e=t.tokens??0;return{id:mc(),kind:`agent:ctx`,timestamp:Date.now(),source:`leader`,target:`session`,label:`ctx ${uc(t.load)}%`,magnitude:e,data:t,color:gc.agent,flowGroup:`leader`}}case`error`:{let e=t.message??`Error`;return{id:mc(),kind:`error`,timestamp:Date.now(),source:t.phase??`system`,target:`session`,label:e,magnitude:1,data:t,color:gc.error,flowGroup:`error`}}case`context.compacted`:return{id:mc(),kind:`context:compacted`,timestamp:Date.now(),source:`system`,target:`session`,label:`Compacted: ${(t.saved??0).toLocaleString(`en-US`)} tokens`,magnitude:t.saved??0,data:t,color:`hsl(220, 60%, 50%)`,flowGroup:`context`};case`compaction.failed`:{let e=t.message??`Compaction failed`;return{id:mc(),kind:`error`,timestamp:Date.now(),source:`compactor`,target:`session`,label:e.slice(0,80),magnitude:t.tokens??1,data:t,color:gc.error,flowGroup:`context`}}case`context.repaired`:return{id:mc(),kind:`context:repaired`,timestamp:Date.now(),source:`system`,target:`session`,label:`Repaired: ${t.removedMessages??0} msgs`,magnitude:t.removedMessages??0,data:t,color:`hsl(220, 60%, 50%)`,flowGroup:`context`};case`session.start`:{let e=t.sessionId??`?`,n=t.projectName??``;return{id:mc(),kind:`session:start`,timestamp:Date.now(),source:`session`,target:`leader`,label:n||e.slice(0,12),magnitude:1,data:t,color:gc.session,flowGroup:`session`}}case`sessions.status_update`:{let e=t.sessions??[];return{id:mc(),kind:`fleet:snapshot`,timestamp:Date.now(),source:`system`,target:`session`,label:`${e.length} session(s)`,magnitude:e.length,data:t,color:gc.system,flowGroup:`fleet`}}default:return null}}function bc(e){switch(e){case`tui`:return`tui`;case`cli`:case`repl`:return`repl`;case`webui`:return`webui`;default:return`webui`}}function xc(e){let t={tui:0,webui:0,repl:0},n=0,r=0,i={toolCalls:0,costUsd:0,tokensIn:0,tokensOut:0};for(let a of e){t[bc(a.clientType)]+=1;for(let e of a.agents)n+=1,(e.status===`running`||e.status===`streaming`)&&(r+=1),i.toolCalls+=e.toolCalls??0,i.costUsd+=e.costUsd??0,i.tokensIn+=e.tokensIn??0,i.tokensOut+=e.tokensOut??0}return{clientCounts:t,totalAgents:n,activeAgents:r,aggregate:i}}function Sc(e){if(e!==void 0)return Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function Cc(e){return e.map(e=>({...e,agents:e.agents.map(e=>({...e,ctxPct:Sc(e.ctxPct)}))}))}var wc=0,Tc=h()(e=>({clientCounts:{tui:0,webui:0,repl:0},mailActivity:[],totalMessages:0,openMessages:0,unreadMessages:0,totalAgents:0,activeAgents:0,currentSession:{},liveSessions:[],aggregate:{toolCalls:0,costUsd:0,tokensIn:0,tokensOut:0},lastUpdated:Date.now(),setClientCounts:t=>e({clientCounts:t,lastUpdated:Date.now()}),setLiveSessions:t=>{let n=Cc(t);e({liveSessions:n,...xc(n),lastUpdated:Date.now()})},addMailActivity:t=>e(e=>({mailActivity:[{...t,seq:t.seq??++wc},...e.mailActivity].slice(0,50),lastUpdated:Date.now()})),setMailStats:(t,n,r)=>e({totalMessages:t,openMessages:n,unreadMessages:r,lastUpdated:Date.now()}),setAgentStats:(t,n)=>e({totalAgents:t,activeAgents:n,lastUpdated:Date.now()}),setCurrentSession:t=>e({currentSession:{...Tc.getState().currentSession,...t},lastUpdated:Date.now()}),clear:()=>e({clientCounts:{tui:0,webui:0,repl:0},mailActivity:[],totalMessages:0,openMessages:0,unreadMessages:0,totalAgents:0,activeAgents:0,currentSession:{},liveSessions:[],aggregate:{toolCalls:0,costUsd:0,tokensIn:0,tokensOut:0},lastUpdated:Date.now()})}));function Ec(e,t){return t>=100?`danger`:`warning`}function Dc(e,t){switch(e){case`budget.threshold_reached`:{let e=t,n=e.limit>0?Math.round(e.used/e.limit*100):0;return`${e.subagentId} [${e.kind}] ${n}% (${e.used}/${e.limit})`}case`budget.decision`:{let e=t;return`${e.subagentId} [${e.kind}] → ${e.decision}`}case`consensus.vote_initiated`:{let e=t;return`Vote: "${e.title}" — ${e.eligible.length} voters`}case`consensus.vote_cast`:{let e=t;return`${e.voterId} voted ${e.value}`}case`consensus.vote_resolved`:{let e=t;return`${e.result} — ✅${e.approveCount} ❌${e.rejectCount}`}case`task.pending`:return`Task queued: "${t.description.slice(0,60)}"`;case`task.started`:{let e=t;return`${e.subagentId} started ${e.taskId}`}case`task.completed`:{let e=t;return`Task ${e.taskId} ${e.status} (${e.durationMs}ms)`}case`task.failed`:{let e=t;return`Task ${e.taskId} failed: ${e.error.slice(0,60)}`}case`subagent.budget_extended`:{let e=t;return`${e.subagentId} [${e.kind}] extended → ${e.extendedTo}ms`}default:return e}}var Oc=200,kc=50,Ac=300,jc=200,Mc=100;function Nc(e,t,n){if(!(e.size<=t)){if(n)for(let[r,i]of e){if(e.size<=t)break;n(i)&&e.delete(r)}for(let n of e.keys()){if(e.size<=t)break;e.delete(n)}}}var Pc=h()(e=>({coordinatorStatus:`idle`,subagents:new Map,events:[],consensusVotes:new Map,tasks:new Map,taskCounts:{pending:0,running:0,completed:0,failed:0},budgetAlerts:[],lastUpdated:Date.now(),setCoordinatorStatus:(t,n)=>e(e=>({coordinatorStatus:t,coordinatorMode:n,lastUpdated:Date.now()})),updateCoordinatorStats:t=>e(e=>{let n=new Map(e.subagents);for(let e of t.subagentStatuses??[]){let t=n.get(e.id);n.set(e.id,{id:e.id,name:e.name,role:t?.role??`agent`,status:e.status,currentTask:e.currentTask,budgetLimits:t?.budgetLimits,budgetUsage:t?.budgetUsage,lastSeen:t?.lastSeen??Date.now()})}return Nc(n,jc,e=>e.status===`stopped`),{subagents:n,taskCounts:{pending:t.pending,running:t.inFlight,completed:t.completed,failed:0},lastUpdated:Date.now()}}),updateSubagentBudget:(t,n)=>e(e=>{let r=new Map(e.subagents),i=r.get(t);return r.set(t,{id:t,name:i?.name??t,role:i?.role??`agent`,status:i?.status??`idle`,...i,...n,lastSeen:Date.now()}),Nc(r,jc,e=>e.status===`stopped`),{subagents:r,lastUpdated:Date.now()}}),pushEvent:(t,n,r,i,a)=>e(e=>{let o=n.kind??t,s=(t.includes(`budget`)||t.includes(`threshold`))&&typeof n.limit==`number`&&n.limit>0?Math.round(n.used/n.limit*100):void 0,c=s===void 0?t.includes(`consensus.vote_resolved`)?`info`:t.includes(`consensus.vote_initiated`)?`warning`:`info`:s>=100?`danger`:s>=85?`warning`:`info`;return{events:[{id:`${r}-${t}`,ts:r,type:t,subagentId:i,taskId:a,payload:n,kind:o,level:c,message:Dc(t,n)},...e.events].slice(0,Oc),lastUpdated:Date.now()}}),pushConsensusVote:(t,n,r)=>e(e=>{let i=new Map(e.consensusVotes);return i.set(t,{changeId:t,title:n,status:`pending`,eligible:r,votes:[],approveCount:0,rejectCount:0,abstainCount:0,expiresAt:Date.now()+300*1e3}),Nc(i,Mc,e=>e.status!==`pending`),{consensusVotes:i,lastUpdated:Date.now()}}),recordConsensusVote:(t,n,r,i)=>e(e=>{let a=new Map(e.consensusVotes),o=a.get(t);if(!o)return{};let s={...o,votes:[...o.votes.filter(e=>e.agentId!==n),{agentId:n,agentName:r,value:i,votedAt:Date.now()}],approveCount:i===`approve`?o.approveCount+1:o.approveCount,rejectCount:i===`reject`?o.rejectCount+1:o.rejectCount,abstainCount:i===`abstain`?o.abstainCount+1:o.abstainCount};return a.set(t,s),{consensusVotes:a,lastUpdated:Date.now()}}),resolveConsensusVote:(t,n,r,i)=>e(e=>{let a=new Map(e.consensusVotes),o=a.get(t);return o?(a.set(t,{...o,status:n,approveCount:r,rejectCount:i,resolvedAt:Date.now()}),{consensusVotes:a,lastUpdated:Date.now()}):{}}),pushTaskPending:(t,n,r)=>e(e=>{let i=new Map(e.tasks);return i.set(t,{id:t,description:n,status:`pending`,priority:r,queuedAt:Date.now()}),Nc(i,Ac,e=>e.status===`completed`||e.status===`failed`),{tasks:i,taskCounts:{...e.taskCounts,pending:e.taskCounts.pending+1},lastUpdated:Date.now()}}),startTask:(t,n)=>e(e=>{let r=new Map(e.tasks),i=r.get(t);return i?r.set(t,{...i,status:`running`,subagentId:n,startedAt:Date.now()}):r.set(t,{id:t,description:``,status:`running`,subagentId:n,startedAt:Date.now()}),{tasks:r,taskCounts:{...e.taskCounts,pending:Math.max(0,e.taskCounts.pending-1),running:e.taskCounts.running+1},lastUpdated:Date.now()}}),completeTask:(t,n,r)=>e(e=>{let i=new Map(e.tasks),a=i.get(t);return a&&i.set(t,{...a,status:n,completedAt:Date.now(),durationMs:r}),Nc(i,Ac,e=>e.status===`completed`||e.status===`failed`),{tasks:i,taskCounts:{...e.taskCounts,running:Math.max(0,e.taskCounts.running-1),completed:n===`completed`?e.taskCounts.completed+1:e.taskCounts.completed,failed:n===`failed`?e.taskCounts.failed+1:e.taskCounts.failed},lastUpdated:Date.now()}}),failTask:(t,n)=>e(e=>{let r=new Map(e.tasks),i=r.get(t);return i&&r.set(t,{...i,status:`failed`,error:n,completedAt:Date.now()}),Nc(r,Ac,e=>e.status===`completed`||e.status===`failed`),{tasks:r,taskCounts:{...e.taskCounts,running:Math.max(0,e.taskCounts.running-1),failed:e.taskCounts.failed+1},lastUpdated:Date.now()}}),recordBudgetDecision:(t,n,r,i)=>e(e=>{let a=new Map(e.budgetAlerts.reduce((e,r)=>(r.subagentId===t&&r.kind===n||e.set(`${r.subagentId}:${r.kind}`,r),e),new Map)),o=`${t}:${n}`,s=a.get(o);return s&&a.set(o,{...s,decision:r,newLimit:i,level:r===`extend`?`warning`:`danger`}),{budgetAlerts:Array.from(a.values()),lastUpdated:Date.now()}}),recordBudgetAlert:(t,n,r,i)=>e(e=>{let a=`${Date.now()}-${t}-${n}`,o=i>0?Math.round(r/i*100):0;return{budgetAlerts:[{id:a,ts:Date.now(),subagentId:t,kind:n,level:Ec(n,o),used:r,limit:i,pct:o},...e.budgetAlerts].slice(0,kc),lastUpdated:Date.now()}}),recordBudgetExtended:(t,n,r)=>e(e=>{let i=new Map(e.subagents),a=i.get(t);if(a?.budgetLimits){let e={...a.budgetLimits};n===`timeout`&&r&&(e.timeoutMs=r),n===`iterations`&&(e.maxIterations=r),n===`tool_calls`&&(e.maxToolCalls=r),i.set(t,{...a,budgetLimits:e,lastSeen:Date.now()})}return{subagents:i,lastUpdated:Date.now()}}),clear:()=>e({coordinatorStatus:`idle`,coordinatorMode:void 0,subagents:new Map,events:[],consensusVotes:new Map,tasks:new Map,taskCounts:{pending:0,running:0,completed:0,failed:0},budgetAlerts:[],lastUpdated:Date.now()})})),Fc=h()(Ue(e=>({showHud:!0,showLegend:!0,showMinimap:!0,showControls:!0,animateEdges:!0,showFeed:!0,background:`dots`,setShowHud:t=>e({showHud:t}),setShowLegend:t=>e({showLegend:t}),setShowMinimap:t=>e({showMinimap:t}),setShowControls:t=>e({showControls:t}),setAnimateEdges:t=>e({animateEdges:t}),setShowFeed:t=>e({showFeed:t}),setBackground:t=>e({background:t})}),{name:`wrongstack-officemap`}));function X(...e){return jn(br(e))}function Ic(){return`toast_${typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}`}var Lc=8e3,Rc=h(e=>({toasts:[],push:t=>{let n=Ic();return e(e=>({toasts:[...e.toasts,{...t,id:n}]})),n},dismiss:t=>e(e=>({toasts:e.toasts.filter(e=>e.id!==t)}))})),Z={success:(e,t=3500)=>Rc.getState().push({message:e,variant:`success`,ttl:t}),error:(e,t=6e3)=>Rc.getState().push({message:e,variant:`error`,ttl:t}),warn:(e,t=4500)=>Rc.getState().push({message:e,variant:`warn`,ttl:t}),info:(e,t=3500)=>Rc.getState().push({message:e,variant:`info`,ttl:t}),undoable:(e,t,n=b.t(`common:action.undo`),r=Lc)=>Rc.getState().push({message:e,variant:`info`,ttl:r,action:{label:n,onClick:t}}),dismiss:e=>Rc.getState().dismiss(e)};function zc({variant:e}){return e===`success`?(0,Y.jsx)(rn,{className:`h-4 w-4 text-green-500`}):e===`error`?(0,Y.jsx)(Nn,{className:`h-4 w-4 text-destructive`}):e===`warn`?(0,Y.jsx)(gt,{className:`h-4 w-4 text-amber-500`}):(0,Y.jsx)(ze,{className:`h-4 w-4 text-blue-500`})}function Bc({entry:e}){let{t}=V(),n=Rc(e=>e.dismiss);return(0,U.useEffect)(()=>{let t=setTimeout(()=>n(e.id),e.ttl);return()=>clearTimeout(t)},[e.id,e.ttl,n]),(0,Y.jsxs)(`div`,{className:X(`flex items-start gap-2 rounded-lg border bg-popover shadow-lg px-3 py-2 text-sm max-w-sm`,`animate-message`,e.variant===`error`&&`border-destructive/40`,e.variant===`warn`&&`border-amber-500/40`,e.variant===`success`&&`border-green-500/40`),children:[(0,Y.jsx)(zc,{variant:e.variant}),(0,Y.jsx)(`div`,{className:`flex-1 min-w-0 whitespace-pre-wrap break-words leading-snug`,children:e.message}),e.action&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{e.action?.onClick(),n(e.id)},className:`shrink-0 font-medium text-primary hover:underline`,children:e.action.label}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>n(e.id),className:`text-muted-foreground hover:text-foreground`,title:t(`activity:toast.dismiss`),children:(0,Y.jsx)(Xn,{className:`h-3.5 w-3.5`})})]})}function Vc(){let e=Rc(e=>e.toasts);return e.length===0?null:(0,Y.jsx)(`div`,{className:`fixed bottom-4 right-4 z-[60] flex flex-col gap-2 pointer-events-auto`,children:e.map(e=>(0,Y.jsx)(Bc,{entry:e},e.id))})}var Hc=null;function Uc(){if(typeof window>`u`)return null;if(Hc)return Hc;let e=window.AudioContext||window.webkitAudioContext;if(!e)return null;try{Hc=new e}catch{return null}return Hc}function Wc(e,t,n){let r=Uc();if(!r)return;let i=r.currentTime+t,a=r.createOscillator(),o=r.createGain();a.type=`sine`,a.frequency.value=e,o.gain.setValueAtTime(0,i),o.gain.linearRampToValueAtTime(.18,i+.01),o.gain.exponentialRampToValueAtTime(1e-4,i+n),a.connect(o).connect(r.destination),a.start(i),a.stop(i+n+.02)}function Gc(){Wc(659.25,0,.18),Wc(880,.12,.24)}function Kc(){Wc(523.25,0,.15),Wc(659.25,.1,.15),Wc(783.99,.2,.25)}var qc=`default`;qc=typeof window<`u`&&`Notification`in window?Notification.permission:`unsupported`;async function Jc(){if(qc===`unsupported`||qc===`granted`||qc===`denied`)return qc;try{let e=await Notification.requestPermission();return qc=e,e}catch{return`denied`}}function Yc(e,t,n){if(!(typeof document>`u`||!document.hidden)&&qc===`granted`)try{let r=new Notification(e,{body:t,icon:`/favicon.ico`,tag:n??`wrongstack-run`,requireInteraction:n===`wrongstack-confirm`});r.onclick=()=>{window.focus(),r.close()}}catch{}}function Xc(e){let t=yc(e.type,e.payload);t&&(vc.getState().pushEvent(t),vc.getState().setActive(!0))}function Zc(e){let t=e.payload?.sessionId,n=q.getState().session?.id;return!t||!n||t===n}var Qc={"iteration.started":$c,"provider.text_delta":el,"provider.thinking_delta":tl,"tool.started":nl,"tool.progress":rl,"tool.executed":il,"tool.confirm_needed":al,"run.result":ol};function $c(e){if(!Zc(e))return;Xc(e);let t=e.payload;q.getState().setIteration({index:t.index,max:t.maxIterations??0}),G.getState().setLoading(!0),typeof document<`u`&&document.hidden&&Vo(`running`),G.getState().runStart===null&&G.getState().setRunStart({at:Date.now(),cost:q.getState().cost}),G.getState().setCurrentAssistantMessage(null)}function el(e){if(!Zc(e))return;let t=e.payload;Go.flush(`__thinking__`),G.getState().clearThinking();let n=G.getState().currentAssistantMessageId;n||(n=G.getState().addMessage({role:`assistant`,content:``,streaming:!0}),G.getState().setCurrentAssistantMessage(n)),Go.push(n,t.text,(e,t)=>G.getState().appendToMessage(e,t))}function tl(e){if(!Zc(e))return;let t=e.payload;t.text&&Go.push(`__thinking__`,t.text,(e,t)=>G.getState().appendThinking(t))}function nl(e){if(!Zc(e))return;Xc(e);let t=e.payload,n=G.getState().getToolMessageId(t.id);if(n){G.getState().setCurrentToolId(n);return}Go.flush(`__thinking__`),G.getState().clearThinking(),G.getState().setCurrentAssistantMessage(null);let r=G.getState().addMessage({role:`tool`,content:``,toolName:t.name,toolInput:t.input,toolUseId:t.id});G.getState().setCurrentToolId(r),G.getState().addExecution({id:t.id,name:t.name,input:t.input,ok:!0,startedAt:Date.now()})}function rl(e){if(!Zc(e))return;let t=e.payload,n=(t.event?.text??``).trim();if(!n)return;let r=G.getState().getToolMessageId(t.id);if(!r)return;let i=t.event?.type===`warning`?`⚠ `:``;Go.push(r,`${i}${n}\n`,(e,n)=>G.getState().appendToolProgressLinesByUseId(t.id,n.split(`
24
- `).filter(e=>e.length>0)))}function il(e){if(!Zc(e))return;Xc(e);let t=e.payload,{currentToolId:n}=G.getState(),r=t.id?G.getState().getToolMessageId(t.id):n;r&&(Go.drop(r),t.id?G.getState().setToolResultByUseId(t.id,t.output??``,t.ok):G.getState().setToolResult(r,t.output??``,t.ok),G.getState().updateMessage(r,{toolDurationMs:t.durationMs})),t.id&&G.getState().updateExecution(t.id,{completedAt:Date.now(),durationMs:t.durationMs,output:t.output,ok:t.ok}),n&&r===n&&G.getState().setCurrentToolId(null)}function al(e){if(!Zc(e))return;let t=e.payload;if(ti.getState().yolo===!0&&t.riskTier!==`destructive`&&t.decisionSource!==`yolo_destructive`){W(K.getState().wsUrl).sendConfirm(t.id,`yes`),J.getState().hideConfirm();return}J.getState().showConfirm({id:t.id,toolName:t.toolName,input:t.input,suggestedPattern:t.suggestedPattern,decisionSource:t.decisionSource,riskTier:t.riskTier});try{Kc()}catch{}Jc(),Yc(`${q.getState().projectName||`Agent`} needs approval`,`Tool "${t.toolName}" is waiting for your decision.`,`agent-confirm`),typeof document<`u`&&document.hidden&&Vo(`attention`)}function ol(e){if(!Zc(e))return;let t=e.payload;Go.flushAll(),G.getState().flushThinkingLog(Math.max(1,t.iterations)),q.getState().setIteration(null),G.getState().setLoading(!1),G.getState().setCurrentAssistantMessage(null),G.getState().clearThinking();let n=G.getState().runStart;if(n&&t.status===`done`){let e=G.getState().messages,r=-1,i=0;for(let t=e.length-1;t>=0;t--){let a=Ur(e[t]);if(a.role===`assistant`&&r===-1&&a.content&&(r=t),a.role===`tool`&&a.timestamp>=n.at&&(i+=1),a.role===`user`&&a.timestamp<=n.at)break}if(r!==-1){let a=q.getState().cost;G.getState().updateMessage(e[r]?.id,{runSummary:{iterations:t.iterations,tools:i,durationMs:Date.now()-n.at,costDelta:Math.max(0,a-n.cost)}})}}if(G.getState().setRunStart(null),t.status!==`done`&&t.error)G.getState().addMessage({role:`assistant`,content:`Error: ${t.error.message}`,isError:!0}),Z.error(`Run ended: ${t.error.message}`),Yc(`${q.getState().projectName||`Agent`} run failed`,t.error.message),typeof document<`u`&&document.hidden&&Vo(`error`);else if(t.status===`done`&&(typeof document<`u`&&document.hidden&&(Z.success(`Run completed in ${t.iterations} iteration${t.iterations===1?``:`s`}`),Yc(`${q.getState().projectName||`Agent`} run finished`,`Completed in ${t.iterations} iteration${t.iterations===1?``:`s`}.`),Vo(`ready`)),Jc(),K.getState().soundOnComplete))try{Gc()}catch{}let r=G.getState().dequeue();if(r){let e=W(K.getState().wsUrl);G.getState().addMessage({role:`user`,content:r.text}),G.getState().setLoading(!0),e.sendMessage(r.text)}}function sl(e,t){if(t)return!0;try{return new URLSearchParams(e).get(`shell`)===`desktop`}catch{return!1}}function cl(){return typeof window>`u`?!1:sl(window.location.search,!!window.wrongstackDesktopHost)}var ll={chat:`chat`,agents:`chat`,history:`sessions`,files:`files`,changes:`changes`,mailbox:`mailbox`,skills:`skill`,worktrees:`chat`,design:`design-gallery`,officemap:`officemap`},ul={chat:`chat`,files:`files`,changes:`changes`,sessions:`history`,mailbox:`mailbox`,skill:`skills`,officemap:`officemap`,"design-gallery":`design`},dl={1:`chat`,2:`agents`,3:`history`,4:`files`,5:`changes`,6:`mailbox`,7:`skills`,8:`officemap`,0:`design`},fl={chat:`Ctrl+1`,agents:`Ctrl+2`,history:`Ctrl+3`,files:`Ctrl+4`,changes:`Ctrl+5`,mailbox:`Ctrl+6`,skills:`Ctrl+7`,worktrees:`Ctrl+Shift+W`,design:`Ctrl+0`,officemap:`Ctrl+8`};function pl(e){return ll[e]??`chat`}function ml(e){return fl[e]??``}function hl(e){let t=J.getState();t.currentView!==e&&t.setCurrentView(e)}function Q(e){let t=J.getState();t.setSidebarOpen(!0),t.selectActivity(e),hl(pl(e))}function gl(e){let t=J.getState();if(!t.sidebarOpen)t.setSidebarOpen(!0),t.selectActivity(e);else if(t.activeActivity===e){t.setSidebarOpen(!1);return}else t.selectActivity(e);hl(pl(e))}function _l(e){let t=J.getState();if(t.currentView===e){Q(`chat`);return}t.setSidebarOpen(!1),hl(e)}function vl(e){let t=ul[e];if(t){Q(t);return}J.getState().setSidebarOpen(!1),hl(e)}function yl(e){if(typeof e!=`string`)return Date.now();let t=Date.parse(e);return Number.isFinite(t)?t:Date.now()}function bl(e){return`replay_${Date.now()}_${e}`}function xl(e){return typeof e==`string`?e:JSON.stringify(e)}function Sl(e){let t=[],n=new Map,r=0,i=(e,n,r)=>{n&&t.push({id:bl(t.length),role:e,content:n,timestamp:r})},a=(e,n)=>{let i=e.trim();i&&(r+=1,t.push({id:bl(t.length),role:`system`,content:``,timestamp:n,thinkingLog:{iteration:r,text:i,startedAt:n,durationMs:0,replayed:!0}}))};for(let r of e){if(r.role!==`user`&&r.role!==`assistant`&&r.role!==`system`)continue;let e=r.role,o=yl(r.ts);if(typeof r.content==`string`){i(e,r.content,o);continue}if(!Array.isArray(r.content))continue;let s=``,c=[];for(let a of r.content){if(a.type===`thinking`&&typeof a.thinking==`string`){c.push(a.thinking);continue}if(a.type===`text`&&typeof a.text==`string`){s+=(s?`
25
- `:``)+a.text;continue}if(a.type===`tool_use`){i(e,s,o),s=``;let r=String(a.id??``),c={id:bl(t.length),role:`tool`,content:``,toolName:String(a.name??`tool`),toolInput:a.input,toolUseId:r,timestamp:o};t.push(c),r&&n.set(r,c);continue}if(a.type===`tool_result`){let e=String(a.tool_use_id??``),t=n.get(e);t&&(t.toolResult=xl(a.content),t.isError=!!a.is_error)}}i(e,s,o),e===`assistant`&&c.length>0&&a(c.join(`
26
-
27
- `),o)}return t}function Cl(e){let t=yc(e.type,e.payload);t&&(vc.getState().pushEvent(t),vc.getState().setActive(!0))}function wl(e){let t=e.payload?.sessionId,n=q.getState().session?.id;return!t||!n||t===n}var Tl=new Set;function El(e,t=140){return e.length>t?`${e.slice(0,t-1)}…`:e}function Dl(){Go.flush(`__thinking__`);let e=q.getState().iteration;G.getState().flushThinkingLog(Math.max(1,e?.index??1)),G.getState().clearThinking()}function Ol(e){let t=yc(`session.start`,e.payload);t&&(vc.getState().pushEvent(t),vc.getState().setActive(!0));let n=e.payload,r=q.getState().session?.id,i=!r||r!==n.sessionId||n.reset;if(n.needsSetup&&vl(`setup`),i?q.getState().startSession({id:n.sessionId,startedAt:Date.now(),model:n.model,provider:n.provider}):q.getState().setSession({id:n.sessionId,startedAt:q.getState().session?.startedAt??Date.now(),model:n.model,provider:n.provider}),q.getState().setEnv({maxContext:n.maxContext,projectRoot:n.projectRoot??``,projectName:n.projectName,cwd:n.cwd,mode:n.mode,contextMode:n.contextMode,inputCost:n.inputCost,outputCost:n.outputCost,cacheReadCost:n.cacheReadCost}),K.getState().setConfig({provider:n.provider,model:n.model}),i){!n.needsSetup&&cl()&&ys({sidebarOpen:!1}),Go.dropAll(),G.getState().clearMessages(),G.getState().setBoundSessionId(n.sessionId),J.getState().setSearchActiveMessageId(null),G.getState().setLoading(!1),q.setState({todos:[]}),Vo(`ready`);let e=Xs.getState();if(n.clearedSessionId){let t=new Map;for(let[r,i]of e.agents)i.sessionId!==n.clearedSessionId&&t.set(r,i);Xs.setState({agents:t})}else e.clear();ic.getState().setTreeLoading(!0),W().send({type:`files.tree`,payload:{path:q.getState().cwd}})}let a=n.replayMessages;if(a&&a.length>0&&(G.getState().setMessages(Sl(a)),G.getState().setBoundSessionId(n.sessionId)),a){let e=n.replayUsage;if(e){let t=q.getState(),n=e.input??0,r=e.output??0,i=e.cacheRead??0,a=e.cacheWrite??0;q.setState({totalTokens:{input:n,output:r,cacheRead:i,cacheWrite:a},cost:(n*t.inputCost+r*t.outputCost+i*t.cacheReadCost)/1e6})}i&&!n.needsSetup&&(cl()?ys({sidebarOpen:!1}):J.getState().currentView!==`chat`&&Q(`chat`)),typeof window<`u`&&window.matchMedia?.(`(max-width: 768px)`).matches&&J.getState().setSidebarOpen(!1)}}function kl(e){if(!wl(e))return;let t=e.payload,n=e=>e.toLocaleString(),r=[...t.tools.breakdown].sort((e,t)=>t.tokens-e.tokens).slice(0,8),i=[...t.messages.breakdown].sort((e,t)=>t.tokens-e.tokens).slice(0,8);G.getState().addMessage({role:`assistant`,content:[`📊 **Context breakdown** (heuristic — 4 chars/token)`,``,`**Total estimate:** ${n(t.total)} tokens`,`• System prompt: ${n(t.systemPrompt)}`,`• Tool schemas: ${n(t.tools.total)} (${t.tools.count} tools)`,`• Messages: ${n(t.messages.total)} (${t.messages.count} messages)`,``,`**Top tool schemas:**`,...r.map(e=>` · ${e.name}: ${n(e.tokens)}`),``,`**Top messages:**`,...i.map(e=>` · #${e.index} ${e.role}: ${n(e.tokens)} — ${e.preview||`(empty)`}`)].join(`
28
- `)})}function Al(e){let t=e.payload;t.success?Z.success(t.message):Z.error(t.message),W(K.getState().wsUrl).listSavedProviders()}function jl(e){if(!wl(e))return;Cl(e);let t=e.payload,n=t.reductions.length?t.reductions.map(e=>`${e.phase}: ${e.saved}`).join(`, `):`no-op`;t.repaired&&(n+=`; repaired ${t.repaired.removedToolUses?.length??0} tool_use, ${t.repaired.removedToolResults?.length??0} tool_result, ${t.repaired.removedMessages} empty messages`),G.getState().addMessage({role:`assistant`,content:`🗜️ Context compacted: ${t.before} → ${t.after} tokens (saved ~${t.saved}). ${n}`}),q.setState({lastInputTokens:t.after})}function Ml(e){if(!wl(e))return;Cl(e);let t=e.payload,n,r;t.budget&&t.budget.availableInputTokens>0?(n=Math.min(100,Math.max(0,Math.round(t.budget.load*100))),r=`input budget`):(n=t.maxContext>0?Math.min(100,Math.max(0,Math.round(t.tokens/t.maxContext*100))):0,r=`context`),G.getState().addMessage({role:`assistant`,content:`Compaction failed at ${t.level} (${n}% ${r}): ${t.message}`,isError:t.fatal}),Z.error(`Compaction failed: ${t.message}`)}function Nl(e){if(!wl(e))return;Cl(e);let t=e.payload,n=t.usage,r=(n.input??0)+(n.cacheWrite??0)-(n.cacheRead??0);r>0&&q.setState({lastInputTokens:r}),q.getState().updateUsage(t.usage);let{inputCost:i,outputCost:a,cacheReadCost:o}=q.getState(),s=(t.usage.input*i+t.usage.output*a+(t.usage.cacheRead??0)*o)/1e6;s>0&&q.getState().addCost(s),t.stopReason!==`tool_use`&&t.stopReason!==`tool_call`&&G.getState().setLoading(!1);let c=G.getState().currentAssistantMessageId;c&&(Go.flush(c),G.getState().finalizeMessage(c),t.usage.output>0&&G.getState().updateMessage(c,{usage:t.usage})),G.getState().setCurrentAssistantMessage(null),Go.flush(`__thinking__`),G.getState().clearThinking()}function Pl(e){if(!wl(e))return;Cl(e);let t=e.payload;Go.flush(`__thinking__`),G.getState().flushThinkingLog(t.index),G.getState().clearThinking();let n=q.getState().iteration;n&&q.getState().setIteration({index:t.index,max:n.max})}function Fl(e){if(!wl(e))return;let t=e.payload;G.getState().addMessage({role:`assistant`,content:`Iteration limit reached: ${t.currentIterations}/${t.currentLimit}.`,isError:!0}),Z.warn(`Iteration limit reached (${t.currentIterations}/${t.currentLimit})`)}function Il(e){if(!wl(e))return;let t=e.payload,n=Math.max(0,Math.round(t.delayMs/100)/10);Z.warn(`${t.providerId} retry ${t.attempt} after ${n}s (${t.status})`)}function Ll(e){if(!wl(e))return;let t=e.payload;G.getState().addMessage({role:`assistant`,content:[`Provider error from \`${t.providerId}\` (${t.status}).`,t.description,t.retryable?`_Retryable; WrongStack may recover automatically._`:``].filter(Boolean).join(`
29
-
30
- `),isError:!0}),Z.error(`${t.providerId} provider error (${t.status})`)}function Rl(e){if(!wl(e))return;let t=e.payload,n=`${t.from.providerId}/${t.from.model}`,r=`${t.to.providerId}/${t.to.model}`;G.getState().addMessage({role:`assistant`,content:`Provider fallback: \`${n}\` returned ${t.status}; switching to \`${r}\`${t.providerSwitched?` with provider change`:``}.`}),Z.warn(`Fallback to ${r}`)}function zl(e){if(!wl(e))return;Cl(e);let t=e.payload;Z.warn(`Provider stream event skipped: ${t.eventType}`),G.getState().addMessage({role:`assistant`,content:`Provider stream warning (${t.eventType}): ${t.message}`,isError:!0})}function Bl(e){if(!wl(e))return;Cl(e);let t=e.payload,n=t.tools||t.kind||`assistant response`;G.getState().addMessage({role:`assistant`,content:`Loop guard triggered: ${n} repeated ${t.repeatCount} time(s) at iteration ${t.iteration}.`,isError:!0}),Z.warn(`Loop guard triggered`)}function Vl(e){if(!wl(e))return;Cl(e);let t=e.payload,n=El(t.task,180);G.getState().addMessage({role:`assistant`,content:`Delegating to \`${t.target}\`: ${n}`}),Xs.getState().pushAgentTimelineEntry({subagentId:t.target,agentName:t.target,content:n,kind:`status`,iteration:0,ts:new Date().toISOString(),status:`delegating`})}function Hl(e){if(!wl(e))return;Cl(e);let t=e.payload,n=Math.max(0,Math.round(t.durationMs/100)/10),r=typeof t.costUsd==`number`&&t.costUsd>0?` · $${t.costUsd.toFixed(4)}`:``,i=`${t.iterations} iteration(s), ${t.toolCalls} tool call(s), ${n}s${r}`;G.getState().addMessage({role:`assistant`,content:[`Delegate ${t.ok?`completed`:`failed`} for \`${t.target}\`${t.status?` (${t.status})`:``}.`,t.summary,i].join(`
31
- `),isError:!t.ok}),Xs.getState().pushAgentTimelineEntry({subagentId:t.subagentId??t.target,agentName:t.target,content:t.summary,kind:t.ok?`status`:`error`,iteration:t.iterations,ts:new Date().toISOString(),status:t.status??(t.ok?`completed`:`failed`)}),t.ok||Z.warn(`Delegate failed: ${t.target}`)}function Ul(e){if(!wl(e))return;let t=e.payload,n=`${t.tool}: ${t.pattern}`;t.decision===`always`?Z.success(`Always allowed ${n}`):Z.warn(`Denied ${n}`)}function Wl(e){if(!wl(e))return;Cl(e);let t=e.payload,n=t.removedToolUses.length+t.removedToolResults.length+t.removedMessages,r=t.beforeMessages!==void 0&&t.afterMessages!==void 0?` Messages: ${t.beforeMessages} -> ${t.afterMessages}.`:``;G.getState().addMessage({role:`assistant`,content:`Context repaired: removed ${n} orphan protocol item(s).${r} tool_use ${t.removedToolUses.length}, tool_result ${t.removedToolResults.length}.`})}function Gl(e){if(!wl(e))return;Cl(e);let t=e.payload;q.getState().setContextUsage(t.tokens,t.maxContext)}function Kl(e){if(!wl(e))return;let t=e.payload;q.getState().setEnv({maxContext:t.maxContext})}function ql(e){if(!wl(e))return;let t=e.payload;q.getState().setContextUsage(t.used,t.limit);let n=t.limit>0?Math.round(t.used/t.limit*100):0;Z.warn(`Token threshold reached (${n}%)`)}function Jl(e){if(!wl(e))return;let t=e.payload.model||`<unknown>`;Tl.has(t)||(Tl.add(t),Z.warn(`Cost estimate unavailable for ${t}`))}function Yl(e){if(!wl(e))return;let t=e.payload;G.getState().addMessage({role:`assistant`,content:`Session ${t.sessionId} is damaged: ${t.detail}`,isError:!0}),Z.error(`Session damage detected`)}function Xl(e){if(!wl(e))return;let t=e.payload;G.getState().addMessage({role:`assistant`,content:`Session rewound to prompt #${t.toPromptIndex}. Removed ${t.removedEvents} event(s); reverted ${t.revertedFiles.length} file(s).`}),Z.info(`Session rewound`)}function Zl(e){if(!wl(e))return;let t=e.payload;Z.success(`Checkpoint #${t.promptIndex} written (${t.fileCount} file(s))`)}function Ql(e){if(!wl(e))return;let t=e.payload;vc.getState().pushEvent({id:`inflight_${Date.now()}`,kind:`session:start`,timestamp:Date.now(),source:`session`,target:`leader`,label:`In-flight: ${t.context}`,magnitude:1,data:t,raw:e.payload,flowGroup:`session`})}function $l(e){wl(e)&&e.payload.reason===`recovered`&&Z.info(`Recovered previous in-flight operation`)}function eu(){K.getState().setWsConnected(!1)}function tu(e){if(!wl(e))return;let t=e.payload;q.getState().setContextModes(t.modes.map(e=>({id:e.id,name:e.name,description:e.description,thresholds:e.thresholds,preserveK:e.preserveK,eliseThreshold:e.eliseThreshold,custom:e.custom}))),q.getState().setEnv({contextMode:t.activeId})}function nu(e){if(!wl(e))return;let t=e.payload;q.getState().setEnv({contextMode:t.id})}function ru(e){let t=e.payload;Ts.getState().setEntries(t.sessions??[],t.error??null)}function iu(e){if(!wl(e))return;let t=e.payload;Dl(),G.getState().addMessage({role:`assistant`,content:`[${t.phase}] ${t.message}`,isError:!0}),G.getState().setLoading(!1)}var au={"context.debug":kl,"key.operation_result":Al,"context.compacted":jl,"compaction.failed":Ml,"provider.response":Nl,"iteration.completed":Pl,"iteration.limit_reached":Fl,"provider.retry":Il,"provider.error":Ll,"provider.fallback":Rl,"provider.stream_error":zl,"tool.loop_detected":Bl,"delegate.started":Vl,"delegate.completed":Hl,"trust.persisted":Ul,"context.repaired":Wl,"ctx.pct":Gl,"ctx.max_context":Kl,"token.threshold":ql,"token.cost_estimate_unavailable":Jl,"session.end":eu,"session.damaged":Yl,"session.rewound":Xl,"checkpoint.written":Zl,"in_flight.started":Ql,"in_flight.ended":$l,"context.modes.list":tu,"context.mode.changed":nu,"sessions.list":ru,error:iu};function ou(e){let t=e.payload;Es.getState().setSnapshot(t.worktrees??[],t.baseBranch??``)}function su(e){let t=e.payload;Es.getState().pushEvent(t)}function cu(e){let t=e.payload;Es.getState().setOrphans(t.orphans??[],t.canClean??!1,t.reason)}function lu(e){let t=e.payload;Es.getState().setCleanResult({...t,at:Date.now()})}function uu(e){let t=e.payload;Es.getState().setMergeResult({...t,at:Date.now()})}function du(e){let t=e.payload;Es.getState().setDiff(t.dir,t.summary)}function fu(e){Xs.getState().applyEvent(e.payload);let t=yc(`subagent.event`,e.payload);t&&(vc.getState().pushEvent(t),vc.getState().setActive(!0))}function pu(e){let t=e.payload;Xs.setState({fleetConcurrency:t.fleetConcurrency,fleetConcurrencyMax:t.fleetConcurrencyMax})}function mu(e){let t=e.payload;Tc.getState().setCurrentSession({clientType:t.clientType,clientId:t.clientId,agentCount:t.agentCount,model:t.model,mode:t.mode,toolCalls:t.toolCalls,inputTokens:t.inputTokens,outputTokens:t.outputTokens,cacheTokens:t.cacheTokens,costUsd:t.costUsd,timestamp:t.timestamp})}function hu(e){let t=e.payload;Tc.getState().setLiveSessions(t?.sessions??[]);let n=yc(`sessions.status_update`,e.payload);n&&(vc.getState().pushEvent(n),vc.getState().setActive(!0))}var gu={"worktree.state":ou,"worktree.event":su,"worktree.orphans":cu,"worktree.cleanup_result":lu,"worktree.merge_result":uu,"worktree.diff_result":du,"subagent.event":fu,"fleet.concurrency_update":pu,"client.status_update":mu,"sessions.status_update":hu};function _u(){let e=W();e?.send?.({type:`mailbox.messages`,payload:{limit:30,incompleteOnly:!0}}),e?.send?.({type:`mailbox.agents`,payload:{}})}function vu(e){let t=e.payload;if(t.error){ic.getState().setError(t.error);return}ic.getState().setTree(t.root,t.tree)}function yu(e){let t=e.payload;if(t.error){ic.getState().setError(t.error);return}ic.getState().openFile(t.filePath,t.content)}function bu(e){let t=e.payload;t.success?ic.getState().markSaved(t.filePath):t.error&&ic.getState().setError(`Save failed: ${t.error}`)}function xu(e){let t=yc(`mailbox.event`,e.payload);t&&(vc.getState().pushEvent(t),vc.getState().setActive(!0)),_u()}function Su(e){let t=e.payload;t?.messages&&bs.getState().setMessages(t.messages)}function Cu(e){let t=e.payload;t?.agents&&bs.getState().setAgents(t.agents)}function wu(e){let t=yc(`mailbox.received`,e.payload);t&&(vc.getState().pushEvent(t),vc.getState().setActive(!0)),_u()}function Tu(e){_u()}function Eu(e){bs.getState().setMessages([]),_u()}function Du(e){_u()}var Ou={"files.tree":vu,"files.read":yu,"files.written":bu,"mailbox.event":xu,"mailbox.messages":Su,"mailbox.agents":Cu,"mailbox.received":wu,"mailbox.agent_registered":Tu,"mailbox.cleared":Eu,"mailbox.purged":Du};function ku(e){let t=e.payload?.sessionId,n=q.getState().session?.id;return!t||!n||t===n}function Au(e){if(!e||e.length===0)return;let t=e.map(e=>e.status);return t.some(e=>e===`failed`)?`failed`:t.every(e=>e===`completed`||e===`skipped`)?`completed`:t.some(e=>e===`paused`)?`paused`:`running`}function ju(e){let t=e.payload,n=Array.isArray(t.phases)?t.phases:void 0,r=Au(n);ec.getState().setState({phases:n,activePhaseId:typeof t.activePhaseId==`string`?t.activePhaseId:void 0,overallPercent:typeof t.overallPercent==`number`?t.overallPercent:void 0,autonomous:typeof t.autonomous==`boolean`?t.autonomous:void 0,title:typeof t.title==`string`?t.title:void 0,goal:typeof t.goal==`string`?t.goal:void 0,status:r,lastError:r===`failed`?ec.getState().lastError:null})}function Mu(e){let t=e.payload,n={totalPhases:typeof t.totalPhases==`number`?t.totalPhases:0,completed:typeof t.completed==`number`?t.completed:0,failed:typeof t.failed==`number`?t.failed:0,totalTasks:typeof t.totalTasks==`number`?t.totalTasks:0,completedTasks:typeof t.completedTasks==`number`?t.completedTasks:0,failedTasks:typeof t.failedTasks==`number`?t.failedTasks:0};ec.getState().setState({progress:n,overallPercent:typeof t.percentComplete==`number`?Math.round(t.percentComplete):void 0,status:n.failed>0||n.failedTasks>0?`failed`:`running`,lastEvent:`progress`})}function Nu(e){let t=e.payload,n=typeof t.title==`string`&&t.title?t.title:`AutoPhase`,r=typeof t.error==`string`&&t.error?t.error:void 0;if(e.type===`autophase.paused`){ec.getState().setState({status:`paused`,autonomous:!1,lastEvent:`paused`}),Z.info(`AutoPhase paused`);return}if(e.type===`autophase.resumed`){ec.getState().setState({status:`running`,autonomous:!0,lastEvent:`resumed`}),Z.info(`AutoPhase resumed`);return}if(e.type===`autophase.stopped`){ec.getState().setState({status:`stopped`,autonomous:!1,lastEvent:`stopped`}),Z.warn(`AutoPhase stopped`);return}if(e.type===`autophase.cleared`){ec.getState().clear();return}if(e.type===`autophase.reverted`){let e=t.ok===!0,n=typeof t.reverted==`number`?t.reverted:0,r=typeof t.reason==`string`?t.reason:void 0;e?Z.success(n>0?`Reverted ${n} commit${n===1?``:`s`}`:`Nothing to revert`):Z.error(`Revert failed: ${r??`unknown error`}`),ec.getState().setState({lastEvent:`reverted`});return}if(e.type===`autophase.saved`){ec.getState().setState({lastEvent:`saved`}),Z.success(`AutoPhase graph saved`);return}if(e.type===`autophase.completed`){ec.getState().setState({status:`completed`,autonomous:!1,overallPercent:100,lastEvent:`completed`,lastError:null}),Z.success(`${n} completed`);return}if(e.type===`autophase.failed`||e.type===`autophase.error`){let e=r??(typeof t.message==`string`?t.message:`${n} failed`);ec.getState().setState({status:`failed`,autonomous:!1,lastEvent:`failed`,lastError:e}),Z.error(e)}}function Pu(e){let t=e.payload;ec.getState().setState({lastEvent:`list`,graphs:Array.isArray(t.graphs)?t.graphs:[]})}function Fu(e){let t=e.payload;$s.getState().setGoal(t)}function Iu(e){let t=e.payload;if(ti.getState().set(t),t.yolo===!0){let e=J.getState().confirmInfo;e&&e.riskTier!==`destructive`&&e.decisionSource!==`yolo_destructive`&&J.getState().hideConfirm()}}function Lu(e){if(!ku(e))return;let t=e.payload,n=[`🧠 **Brain** — policy → LLM decision chain`,``,`Autonomy ceiling: \`${t.maxAutoRisk}\` _(change with \`/brain risk <off|low|medium|high|all>\`)_`];if(t.log.length===0)n.push(``,`_No decisions recorded yet this session._`);else{n.push(``,`Recent decisions (${t.log.length}):`);for(let e of t.log.slice(-10)){let t=Math.max(0,Math.round((Date.now()-e.at)/1e3)),r=t<60?`${t}s`:t<3600?`${Math.round(t/60)}m`:`${Math.round(t/3600)}h`,i=e.question.length>70?`${e.question.slice(0,67)}…`:e.question;n.push(`- \`${r} ago\` **${e.kind}** — ${i}${e.outcome?` → _${e.outcome}_`:``}`)}}G.getState().addMessage({role:`assistant`,content:n.join(`
32
- `)})}function Ru(e){if(!ku(e))return;let t=e.payload,n;if(t.decision.type===`answer`){let e=t.decision.rationale&&t.decision.rationale!==t.decision.text?`\n\n_${t.decision.rationale}_`:``;n=`🧠 ${t.decision.text??``}${e}`}else n=t.decision.type===`deny`?`🧠 Denied: ${t.decision.reason??``}`:`🧠 The Brain escalated this question back to you — it needs human judgement.`;G.getState().addMessage({role:`assistant`,content:n})}function zu(e){if(!ku(e))return;let t=e.payload;if(t.event===`brain.intervention`){let e=t.decision?.rationale??t.decision?.text??``,n=t.intervened?`🧠 **Brain intervention** — corrective guidance was sent to the agent.`:`🧠 **Brain check** — a distress signal was reviewed; no action needed.`;G.getState().addMessage({role:`assistant`,content:[n,t.request?.question??``,e?`_${e}_`:``].filter(Boolean).join(`
33
-
34
- `)}),t.intervened&&Z.info(`Brain intervened: agent steered`)}else t.event===`brain.decision_denied`&&Z.warn(`Brain denied: ${t.decision?.reason??t.request?.question??`request`}`)}function Bu(e){let t=e.payload,n=typeof t.kind==`string`?t.kind:typeof t.event==`string`?t.event:`collab.event`;vc.getState().pushEvent({id:`collab_${Date.now()}_${Math.random().toString(36).slice(2,7)}`,kind:`collab:event`,timestamp:Date.now(),source:`collab`,target:typeof t.sessionId==`string`?t.sessionId:`session`,label:n,magnitude:1,data:t,raw:e.payload,color:`hsl(200, 70%, 55%)`,flowGroup:`collab`}),vc.getState().setActive(!0)}function Vu(e){Bu(e);let t=e.payload;t?.phase===`consumed`?Z.success(`Tool injection applied${t.toolName?` to ${t.toolName}`:``}`):Z.info(`Collab tool injection queued`)}function Hu(e){let t=e.payload?.entry;if(!t)return;let n=typeof t.iteration==`number`?t.iteration:0,r=typeof t.task==`string`?t.task:void 0,i=typeof t.status==`string`?t.status:void 0,a=typeof t.at==`string`?t.at:new Date().toISOString();$s.getState().appendJournalEntry({iteration:n,task:r,status:i,timestamp:a}),vc.getState().pushEvent({id:`eternal_${Date.now()}_${n}`,kind:`eternal:iteration`,timestamp:Date.now(),source:`eternal`,target:`goal`,label:r?`L${n}: ${r}`:`Eternal iteration ${n}`,magnitude:typeof t.costUsd==`number`?t.costUsd:1,data:t,raw:e.payload,color:i===`failure`?`hsl(0, 80%, 55%)`:`hsl(220, 80%, 60%)`,flowGroup:`eternal`}),vc.getState().setActive(!0)}function Uu(e){let t=e.payload;q.getState().setEnv({cwd:t.cwd,projectRoot:t.projectRoot,projectName:t.projectRoot.split(/[/\\]/).pop()||t.projectRoot}),ic.getState().setTreeLoading(!0),W().send({type:`files.tree`,payload:{path:t.cwd}})}function Wu(e){let t=e.payload,n=J.getState().refinePanel;if(!n)return;if(t.error){Z.error(`Refinement failed: ${t.error}`);let{original:e}=n;J.getState().setRefinePanel(null),G.getState().addMessage({role:`user`,content:e}),G.getState().setLoading(!0),W().sendMessage(e);return}let r=n.original;if(Wr(t.refined,r)){J.getState().setRefinePanel(null),G.getState().addMessage({role:`user`,content:r}),G.getState().setLoading(!0),W().sendMessage(r);return}J.getState().setRefinePanel({...n,refined:t.refined,english:t.english})}function Gu(e){let t=e.payload;Ss.getState().setInfo({...t,fetchedAt:Date.now()})}function Ku(e){let t=e.payload;ws.getState().setFiles(t.files??[],t.error??null)}function qu(e){let t=e.payload;ws.getState().selectedPath===t.path&&ws.getState().setDiff({path:t.path,oldText:t.oldText??``,newText:t.newText??``,binary:t.binary,tooLarge:t.tooLarge,error:t.error})}var Ju={"goal.updated":Fu,"prefs.updated":Iu,"autophase.state":ju,"autophase.progress":Mu,"autophase.paused":Nu,"autophase.resumed":Nu,"autophase.stopped":Nu,"autophase.cleared":Nu,"autophase.reverted":Nu,"autophase.saved":Nu,"autophase.completed":Nu,"autophase.failed":Nu,"autophase.error":Nu,"autophase.list":Pu,"brain.status":Lu,"brain.answer":Ru,"brain.event":zu,"collab.event":Bu,"collab.injection.granted":Vu,"eternal.iteration":Hu,"working_dir.changed":Uu,"model.refine_result":Wu,"git.info":Gu,"git.changes":Ku,"git.diff":qu},Yu={"coordinator.status":e=>{let t=e.payload;Pc.getState().setCoordinatorStatus(t.status,t.mode),t.taskQueue&&Pc.getState().updateCoordinatorStats({total:t.subagentCount??0,running:0,idle:0,stopped:0,inFlight:t.taskQueue.running,pending:t.taskQueue.pending,completed:t.taskQueue.completed})},"coordinator.stats":e=>{let t=e.payload;Pc.getState().updateCoordinatorStats(t)},"budget.threshold_reached":e=>{let t=e.payload;Pc.getState().pushEvent(`budget.threshold_reached`,t,t.ts??Date.now(),t.subagentId,t.taskId),t.limit>0&&t.used/t.limit*100>=85&&Pc.getState().recordBudgetAlert(t.subagentId,t.kind,t.used,t.limit),Pc.getState().updateSubagentBudget(t.subagentId,{budgetUsage:{iterations:0,toolCalls:0,tokens:0,costUsd:0,elapsedMs:t.used??0}})},"budget.decision":e=>{let t=e.payload,n=t.extended?.timeoutMs??t.extended?.maxIterations??t.extended?.maxToolCalls;Pc.getState().recordBudgetDecision(t.subagentId,t.kind,t.decision,n),Pc.getState().pushEvent(`budget.decision`,{subagentId:t.subagentId,kind:t.kind,decision:t.decision,newLimit:n},Date.now(),t.subagentId)},"subagent.budget_extended":e=>{let t=e.payload;Pc.getState().recordBudgetExtended(t.subagentId,t.kind,t.extendedTo),Pc.getState().pushEvent(`subagent.budget_extended`,t,Date.now(),t.subagentId)},"consensus.vote_initiated":e=>{let t=e.payload;Pc.getState().pushConsensusVote(t.changeId,t.title,t.eligible),Pc.getState().pushEvent(`consensus.vote_initiated`,t,Date.now()),Z.info(`Vote started: `+t.title)},"consensus.vote_cast":e=>{let t=e.payload,n=Pc.getState().consensusVotes.get(t.changeId)?.eligible.find(e=>e.agentId===t.voterId);Pc.getState().recordConsensusVote(t.changeId,t.voterId,n?.agentName??t.voterId,t.value),Pc.getState().pushEvent(`consensus.vote_cast`,t,Date.now(),t.voterId)},"consensus.vote_resolved":e=>{let t=e.payload;Pc.getState().resolveConsensusVote(t.changeId,t.result,t.approveCount,t.rejectCount),Pc.getState().pushEvent(`consensus.vote_resolved`,t,Date.now()),Z.info(`Vote resolved: `+t.result+` (y`+t.approveCount+` n`+t.rejectCount+`)`)},"task.pending":e=>{let t=e.payload;Pc.getState().pushTaskPending(t.taskId,t.description,t.priority),Pc.getState().pushEvent(`task.pending`,t,Date.now())},"task.started":e=>{let t=e.payload;Pc.getState().startTask(t.taskId,t.subagentId),Pc.getState().pushEvent(`task.started`,t,Date.now(),t.subagentId)},"task.completed":e=>{let t=e.payload;Pc.getState().completeTask(t.taskId,t.status,t.durationMs),Pc.getState().pushEvent(`task.completed`,t,Date.now(),t.subagentId)},"task.failed":e=>{let t=e.payload;Pc.getState().failTask(t.taskId,t.error),Pc.getState().pushEvent(`task.failed`,{taskId:t.taskId,subagentId:t.subagentId,error:String(t.error).slice(0,120)},Date.now(),t.subagentId),Z.error(`Task failed: `+String(t.error).slice(0,80))}};function Xu(e){let t=e.payload?.sessionId,n=q.getState().session?.id;return!t||!n||t===n}function Zu(e){let t=e.payload;G.getState().addMessage({role:`assistant`,content:[`🛠️ **Registered tools** (${t.tools.length})`,``,...t.tools.map(e=>`• \`${e.name}\`${e.params.length?` (${e.params.join(`, `)})`:``} — ${e.description||`_no description_`}`)].join(`
35
- `)})}function Qu(e){let t=e.payload,n=t.text?.trim();G.getState().addMessage({role:`assistant`,content:t.error?`Memory read failed: ${t.error}`:n?`🧠 **Memory** \n\n${n}`:`🧠 **Memory**
36
-
37
- _empty — nothing remembered yet_`})}function $u(e){let t=e.payload;if(!t.enabled){G.getState().addMessage({role:`assistant`,content:`🎯 **Skills**
38
-
39
- _disabled (config.features.skills = false)_`});return}let n=[`🎯 **Skills** (${t.skills.length})`,``,...t.skills.length===0?[`_none registered_`]:t.skills.map(e=>`• \`${e.name}\`${e.version?` v${e.version}`:``} _(${e.source})_ — ${e.description||e.trigger||`_no description_`}`)];t.error&&n.push(``,`⚠ ${t.error}`),G.getState().addMessage({role:`assistant`,content:n.join(`
40
- `)})}function ed(e){if(!Xu(e))return;let t=e.payload;G.getState().addMessage({role:`assistant`,content:[`🩺 **Runtime diagnostics**`,``,`**Provider:** \`${t.provider}\` / \`${t.model}\``,`**Mode:** \`${t.mode}\``,`**Session:** \`${t.sessionId}\``,`**CWD:** \`${t.cwd}\``,``,`**Tools:** ${t.tools.count}`,`**Messages:** ${t.messages} · **Todos:** ${t.todos}`,`**Usage:** ${t.usage.input.toLocaleString()} in · ${t.usage.output.toLocaleString()} out${t.usage.cacheRead?` · ${t.usage.cacheRead.toLocaleString()} cache`:``}`,``,`**Features:** memory=${t.features.memory?`✓`:`✗`} · skills=${t.features.skills?`✓`:`✗`} · modelsRegistry=${t.features.modelsRegistry?`✓`:`✗`}`].join(`
41
- `)})}function td(e){if(!Xu(e))return;let t=e.payload,n=Math.floor(t.elapsedMs/1e3),r=n<60?`${n}s`:n<3600?`${Math.floor(n/60)}m ${n%60}s`:`${Math.floor(n/3600)}h ${Math.floor(n%3600/60)}m`;G.getState().addMessage({role:`assistant`,content:[`📈 **Session stats**`,``,`**Session:** \`${t.sessionId}\``,`**Provider/Model:** \`${t.provider}\` / \`${t.model}\``,`**Elapsed:** ${r}`,``,`**Usage:** ${t.usage.input.toLocaleString()} in · ${t.usage.output.toLocaleString()} out`,...t.cache&&t.cache.readTokens>0?[`**Cache:** ${t.cache.readTokens.toLocaleString()} read · ${t.cache.writeTokens.toLocaleString()} write · hit ratio ${(t.cache.hitRatio*100).toFixed(1)}%`]:[],`**Cost:** ${t.cost.toFixed(4)}`,``,`**Messages:** ${t.messages} · **Files read:** ${t.readFiles} · **Tools available:** ${t.tools}`,...t.sideEffectCount?[`**Side effects:** ⚠ ${t.sideEffectCount}`]:[]].join(`
42
- `)})}function nd(e){if(!Xu(e))return;let t=e.payload;q.getState().setTodos(t.todos??[])}function rd(e){let t=e.payload;q.getState().setModes(t.modes.map(e=>({id:e.id,name:e.name,description:e.description}))),q.getState().setEnv({mode:t.activeId})}var id={...Qc,...au,...gu,...Ou,...Ju,...Yu,"session.start":e=>{Ol(e),_u()},"specs.list":e=>{let t=e.payload;tc.getState().setSpecs(t.specs??[])},"specs.detail":e=>{tc.getState().setDetail(e.payload)},"sdd.board.snapshot":e=>{nc.getState().setSnapshot(e.payload)},"sdd.board.list":e=>{let t=e.payload;nc.getState().setBoards(t.boards??[])},"sdd.board.lifecycle_result":e=>{let t=e.payload,n=nc.getState();n.setLifecycleResult({...t,at:Date.now()}),n.setDestroying(!1)},"sdd.spec.snapshot":e=>{rc.getState().setSnapshot(e.payload)},"sdd.spec.agent_text":e=>{rc.getState().setAgentText(e.payload.text??``)},"sdd.spec.error":e=>{rc.getState().setError(e.payload.message??`Error`)},"sdd.run.started":e=>{rc.getState().setStartedRunId(e.payload.runId??null)},"tools.list":Zu,"memory.list":Qu,"skills.list":$u,"diag.get":ed,"stats.get":td,side_effects:e=>{if(!Xu(e))return;let t=e.payload;Cs.getState().setSideEffects(t.sideEffects??[])},"todos.updated":nd,"todos.cleared":e=>{Xu(e)&&q.getState().setTodos([])},"agent.timeline.message":e=>{if(!Xu(e))return;let t=e.payload;Xs.getState().pushAgentTimelineEntry({subagentId:t.subagentId,agentName:t.agentName,content:t.content,kind:t.kind,iteration:t.iteration,ts:t.ts,toolName:t.toolName,costUsd:t.costUsd})},"agent.status_changed":e=>{if(!Xu(e))return;let t=e.payload;Xs.getState().pushAgentTimelineEntry({subagentId:t.subagentId,agentName:t.agentName,content:t.summary??t.status,kind:`status`,iteration:0,ts:t.ts,status:t.status})},"tasks.updated":e=>{},"plan.updated":e=>{},"modes.list":rd,"session.checkpoints":e=>{},"process.list":e=>{},"projects.list":e=>{},"projects.added":e=>{},"projects.selected":e=>{},"prompts.search":e=>{},"prompts.created":e=>{},"prompts.favorite":e=>{},"prompts.used":e=>{},"design.state":e=>{}};function ad(e){let t=[];for(let[n,r]of Object.entries(id))t.push(e.on(n,r));return()=>{for(let e of t)e()}}function od(){let{autoConnect:e,wsUrl:t}=K(),n=K(e=>e.setWsStatus),r=(0,U.useRef)(!1);(0,U.useEffect)(()=>{if(!e)return;Uo();let i=W(t),a=!1,o=i.onStatus(e=>{a||n(e)});if(i.connect().then(()=>{a||i.getPrefs()}).catch(e=>{a||console.warn(JSON.stringify({level:`warn`,event:`webui.ws_connection_failed`,message:e instanceof Error?e.message:String(e),timestamp:new Date().toISOString()}))}),r.current)return()=>{a=!0,o()};r.current=!0;let s=ad(i);return()=>{a=!0,s(),o()}},[e,t,n])}function sd(){let{wsUrl:e}=K(),t=W(e),n=(0,U.useCallback)((e,n)=>t.isConnected?t.sendMessage(e,n):null,[t]),r=(0,U.useCallback)(()=>t.sendAbort(),[t]),{hideConfirm:i}=J(),a=(0,U.useCallback)((e,n)=>{t.sendConfirm(e,n),i()},[t,i]),o=(0,U.useCallback)((e,n)=>t.switchModel(e,n),[t]),s=(0,U.useCallback)(()=>t.listProviders(),[t]),c=(0,U.useCallback)(e=>t.listProviderModels(e),[t]),l=(0,U.useCallback)(()=>t.listSavedProviders(),[t]),u=(0,U.useCallback)((e,n,r)=>t.addKey(e,n,r),[t]),d=(0,U.useCallback)((e,n,r)=>t.updateKey(e,n,r),[t]),f=(0,U.useCallback)((e,n)=>t.deleteKey(e,n),[t]),p=(0,U.useCallback)((e,n)=>t.setActiveKey(e,n),[t]),m=(0,U.useCallback)((e,n,r,i)=>t.addProvider(e,n,r,i),[t]),h=(0,U.useCallback)(e=>t.removeProvider(e),[t]),g=(0,U.useCallback)(e=>{Ts.getState().setLoading(!0),t.listSessions(e)},[t]),_=(0,U.useCallback)(e=>{Ts.getState().removeEntry(e),t.deleteSession(e)},[t]),v=(0,U.useCallback)(e=>t.resumeSessionById(e),[t]),y=(0,U.useCallback)(()=>t.saveSession(),[t]),b=(0,U.useCallback)(()=>t.listTools(),[t]),x=(0,U.useCallback)(()=>t.listMemory(),[t]),S=(0,U.useCallback)(()=>t.listSkills(),[t]),C=(0,U.useCallback)(()=>t.getDiag(),[t]),w=(0,U.useCallback)(()=>t.getStats(),[t]),T=(0,U.useCallback)(()=>t.getPlan(),[t]),E=(0,U.useCallback)(()=>t.listModes(),[t]),D=(0,U.useCallback)(e=>t.switchMode(e),[t]),O=(0,U.useCallback)(()=>t.listContextModes(),[t]),k=(0,U.useCallback)(e=>t.switchContextMode(e),[t]),A=(0,U.useCallback)(e=>t.createContextMode(e),[t]),j=(0,U.useCallback)((e,n)=>t.updateContextMode(e,n),[t]),M=(0,U.useCallback)(e=>t.deleteContextMode(e),[t]),N=(0,U.useCallback)(()=>t.repairContext(),[t]),P=(0,U.useCallback)(e=>t.refineModel(e),[t]),F=(0,U.useCallback)(e=>t.switchAutonomy(e),[t]),I=(0,U.useCallback)(e=>t.updatePrefs(e),[t]);return{client:t,sendMessage:n,sendAbort:r,sendConfirm:a,switchModel:o,listProviders:s,listProviderModels:c,listSavedProviders:l,addKey:u,updateKey:d,deleteKey:f,setActiveKey:p,addProvider:m,removeProvider:h,listSessions:g,deleteSession:_,resumeSession:v,saveSession:y,listTools:b,listMemory:x,listSkills:S,getDiag:C,getStats:w,getPlan:T,listModes:E,switchMode:D,listContextModes:O,switchContextMode:k,createContextMode:A,updateContextMode:j,deleteContextMode:M,repairContext:N,toggleAutoPhaseAutonomous:(0,U.useCallback)(e=>{t.send({type:`autophase.toggleAutonomous`,payload:{autonomous:e}})},[t]),startAutoPhase:(0,U.useCallback)((e,n,r=!0)=>{t.send({type:`autophase.start`,payload:{title:e,phases:n,autonomous:r}})},[t]),pauseAutoPhase:(0,U.useCallback)(()=>{t.send({type:`autophase.pause`,payload:{}})},[t]),resumeAutoPhase:(0,U.useCallback)(()=>{t.send({type:`autophase.resume`,payload:{}})},[t]),stopAutoPhase:(0,U.useCallback)(()=>{t.send({type:`autophase.stop`,payload:{}})},[t]),selectAutoPhase:(0,U.useCallback)(e=>{t.send({type:`autophase.selectPhase`,payload:{phaseId:e}})},[t]),switchAutonomy:F,updatePrefs:I,refineModel:P}}var cd=(0,U.createContext)(void 0);function ld({children:e,defaultTheme:t=`system`,storageKey:n=`wrongstack-theme`}){let{setTheme:r}=K(),[i,a]=(0,U.useState)(()=>typeof window<`u`&&localStorage.getItem(n)||t);(0,U.useEffect)(()=>{let e=window.document.documentElement;if(e.classList.remove(`light`,`dark`),i===`system`){let t=window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`;e.classList.add(t)}else e.classList.add(i)},[i]);let o={theme:i,setTheme:e=>{localStorage.setItem(n,e),a(e),r(e)}};return(0,Y.jsx)(cd.Provider,{value:o,children:e})}function ud(){let e=(0,U.useContext)(cd);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e}var dd=ar,fd=ur,pd=hr,md=U.forwardRef(({className:e,inset:t,children:n,...r},i)=>(0,Y.jsxs)(Gn,{ref:i,className:X(`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,Y.jsx)(Oe,{className:`ml-auto h-4 w-4`})]}));md.displayName=Gn.displayName;var hd=U.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(jt,{ref:n,className:X(`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}));hd.displayName=jt.displayName;var gd=U.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,Y.jsx)(Xt,{children:(0,Y.jsx)(ut,{ref:r,sideOffset:t,className:X(`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})}));gd.displayName=ut.displayName;var _d=U.forwardRef(({className:e,inset:t,...n},r)=>(0,Y.jsx)(vt,{ref:r,className:X(`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}));_d.displayName=vt.displayName;var vd=U.forwardRef(({className:e,children:t,checked:n,...r},i)=>(0,Y.jsxs)(mt,{ref:i,className:X(`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,Y.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Y.jsx)(Pe,{children:(0,Y.jsx)(z,{className:`h-4 w-4`})})}),t]}));vd.displayName=mt.displayName;var yd=U.forwardRef(({className:e,children:t,...n},r)=>(0,Y.jsxs)(Bn,{ref:r,className:X(`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,Y.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Y.jsx)(Pe,{children:(0,Y.jsx)(Or,{className:`h-2 w-2 fill-current`})})}),t]}));yd.displayName=Bn.displayName;var bd=U.forwardRef(({className:e,inset:t,...r},i)=>(0,Y.jsx)(n,{ref:i,className:X(`px-2 py-1.5 text-sm font-semibold`,t&&`pl-8`,e),...r}));bd.displayName=n.displayName;var xd=U.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(_n,{ref:n,className:X(`-mx-1 my-1 h-px bg-muted`,e),...t}));xd.displayName=_n.displayName;var Sd=({className:e,...t})=>(0,Y.jsx)(`span`,{className:X(`ml-auto text-xs tracking-widest opacity-60`,e),...t});Sd.displayName=`DropdownMenuShortcut`;var Cd=[{id:`chat`,icon:(0,Y.jsx)(Ir,{size:16}),label:`Session`},{id:`agents`,icon:(0,Y.jsx)(j,{size:16}),label:`Agents`},{id:`history`,icon:(0,Y.jsx)(Ge,{size:16}),label:`History`},{id:`files`,icon:(0,Y.jsx)(Fe,{size:16}),label:`Files`},{id:`changes`,icon:(0,Y.jsx)(P,{size:16}),label:`Changes`},{id:`mailbox`,icon:(0,Y.jsx)(g,{size:16}),label:`Mailbox`},{id:`skills`,icon:(0,Y.jsx)(bt,{size:16}),label:`Skills`},{id:`worktrees`,icon:(0,Y.jsx)(de,{size:16}),label:`Worktrees`},{id:`design`,icon:(0,Y.jsx)(Wt,{size:16}),label:`Design Studio`},{id:`officemap`,icon:(0,Y.jsx)(Ce,{size:16}),label:`Office Map`}],wd=[{id:`sddwizard`,icon:(0,Y.jsx)(ce,{size:16}),label:`New SDD Project`},{id:`specs`,icon:(0,Y.jsx)(gn,{size:16}),label:`Specs`},{id:`sddboard`,icon:(0,Y.jsx)($n,{size:16}),label:`Live Board`},{id:`autophase`,icon:(0,Y.jsx)(a,{size:16}),label:`Phases`},{id:`settings`,icon:(0,Y.jsx)(I,{size:16}),label:`Settings`}],Td=[`chat`,`agents`,`files`,`changes`,`mailbox`],Ed=[...Td,`history`,`skills`,`worktrees`,`officemap`,`design`],Dd=132,Od=38;function kd(e){let t=Cd.length+wd.length,n=Math.floor(((Number.isFinite(e)?e:720)-Dd)/Od);return Math.max(Td.length,Math.min(t,n))}function Ad(e){let t=Cd.length+wd.length,n=Math.max(Td.length,Math.min(t,Math.floor(e))),r=Math.min(Cd.length,n),i=new Set(Ed.slice(0,r)),a=Cd.map(e=>e.id).filter(e=>i.has(e)),o=Cd.map(e=>e.id).filter(e=>!i.has(e)),s=Math.max(0,n-a.length),c=wd.slice(0,s).map(e=>e.id),l=new Set(c);return{visiblePanelIds:a,overflowPanelIds:o,visibleViewIds:c,overflowViewIds:wd.map(e=>e.id).filter(e=>!l.has(e))}}var jd=Cd.map(e=>e.id);function Md(){return typeof window>`u`?720:window.visualViewport?.height??window.innerHeight}function Nd(e){let[t,n]=(0,U.useState)(Md);return(0,U.useEffect)(()=>{if(!e||typeof window>`u`)return;let t=()=>n(Md());return t(),window.addEventListener(`resize`,t),window.visualViewport?.addEventListener(`resize`,t),()=>{window.removeEventListener(`resize`,t),window.visualViewport?.removeEventListener(`resize`,t)}},[e]),e?kd(t):Cd.length+wd.length}function Pd({desktopShell:e=!1}){let t=J(e=>e.activeActivity),n=J(e=>e.sidebarOpen),r=J(e=>e.currentView),i=q(e=>e.projectName),a=q(e=>e.cwd),o=K(e=>e.wsConnected),{t:s}=V(),c=(e,t)=>s(`activity:nav.${e}`,t),l=Xs(e=>Array.from(e.agents.values()).filter(e=>e.status===`running`).length),u=bs(xs),d=J(e=>e.inspectorOpen),f=J(e=>e.inspectorTab),p=Nd(e),m=(0,U.useMemo)(()=>Ad(p),[p]),h=(0,U.useMemo)(()=>new Set(m.visiblePanelIds),[m.visiblePanelIds]),g=(0,U.useMemo)(()=>new Set(m.overflowPanelIds),[m.overflowPanelIds]),_=(0,U.useMemo)(()=>new Set(m.visibleViewIds),[m.visibleViewIds]),v=(0,U.useMemo)(()=>new Set(m.overflowViewIds),[m.overflowViewIds]),y=e?Cd.filter(e=>h.has(e.id)):Cd,b=e?Cd.filter(e=>g.has(e.id)):[],x=e?wd.filter(e=>_.has(e.id)):wd,S=e?wd.filter(e=>v.has(e.id)):[],C=e=>{if(e===`agents`)return l||void 0;if(e===`mailbox`)return u||void 0};return(0,Y.jsxs)(`div`,{className:X(`flex h-full min-h-0 shrink-0 flex-col border-r bg-card/60`,e?`w-10`:`w-12`),children:[(0,Y.jsxs)(`div`,{className:X(`flex flex-col items-center border-b border-border/50 shrink-0`,e?`pt-2 pb-1.5`:`pt-2.5 pb-2`),children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{Q(`chat`)},title:i?s(`activity:brand.returnToChat`,{name:i}):s(`activity:brand.returnToChatDefault`),className:X(`relative rounded-md bg-primary flex items-center justify-center shadow-[0_0_0_1px_hsl(var(--primary)/0.4),0_2px_8px_-2px_hsl(var(--primary)/0.5)] hover:shadow-[0_0_0_1px_hsl(var(--primary)/0.6),0_3px_12px_-2px_hsl(var(--primary)/0.6)] transition-shadow`,e?`w-7 h-7`:`w-8 h-8`),children:(0,Y.jsx)(tn,{className:X(`text-primary-foreground`,e?`h-3.5 w-3.5`:`h-4 w-4`),strokeWidth:2.4})}),!e&&(0,Y.jsx)(`span`,{className:`mt-1.5 text-[8px] font-semibold tracking-tight text-muted-foreground text-center leading-tight w-10 truncate`,title:a||i||`WrongStack`,children:i||`WS`}),(0,Y.jsx)(`span`,{className:X(`inline-block w-1.5 h-1.5 rounded-full`,e?`mt-1.5`:`mt-1`,o?`bg-[hsl(var(--success))] shadow-[0_0_4px_hsl(var(--success)/0.6)]`:`bg-[hsl(var(--warning))]`),title:s(o?`activity:status.connected`:`activity:status.disconnected`)})]}),(0,Y.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto no-scrollbar flex flex-col items-center pt-2 pb-1`,children:[y.map(r=>(0,Y.jsx)(Id,{compact:e,icon:r.icon,label:`${c(r.id,r.label)} (${ml(r.id)})`,active:n&&t===r.id,badge:C(r.id),onClick:()=>gl(r.id)},r.id)),x.length>0&&(0,Y.jsx)(`div`,{className:`my-1.5 h-px w-6 bg-border/60 shrink-0`}),x.map(t=>(0,Y.jsx)(Id,{compact:e,icon:t.icon,label:c(t.id,t.label),active:r===t.id,onClick:()=>_l(t.id)},t.id))]}),(0,Y.jsx)(`div`,{className:`flex flex-col items-center shrink-0 pt-1 pb-2 border-t border-border/50`,children:(0,Y.jsx)(Fd,{compact:e,monitorOpen:d&&(f===`fleet`||f===`agents`),overflowPanels:b,overflowViews:S})})]})}function Fd({compact:e=!1,monitorOpen:t,overflowPanels:n,overflowViews:r}){let{theme:i,setTheme:a}=ud(),{t:o}=V(),s=J(e=>e.activeActivity),c=J(e=>e.sidebarOpen),l=J(e=>e.currentView),u=J(e=>e.inspectorOpen),d=J(e=>e.inspectorTab),f=n.length+r.length,p=n.some(e=>c&&s===e.id),m=r.some(e=>l===e.id),h=p||m,g=e=>{let t=J.getState();t.inspectorOpen&&t.inspectorTab===e?t.setInspectorOpen(!1):(t.setInspectorTab(e),t.setInspectorOpen(!0))};return(0,Y.jsxs)(dd,{children:[(0,Y.jsx)(fd,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,"aria-label":f>0?o(`activity:menu.moreWithHidden`,{count:f}):o(`activity:menu.moreOptions`),title:e&&f>0?o(`activity:menu.moreCompactHidden`,{count:f}):o(e?`activity:menu.moreCompact`:`activity:menu.moreFull`),className:X(`relative flex items-center justify-center rounded-lg transition-colors`,e?`w-9 h-9`:`w-10 h-10`,`text-muted-foreground hover:text-foreground hover:bg-muted/70`,`data-[state=open]:text-primary data-[state=open]:bg-primary/10`,(t||h)&&`text-primary`),children:[(0,Y.jsx)(`span`,{className:`h-5 w-5 flex items-center justify-center`,children:(0,Y.jsx)(_r,{size:16})}),f>0&&(0,Y.jsx)(`span`,{className:X(`absolute -top-0.5 -right-0.5 min-w-[15px] h-[15px] flex items-center justify-center rounded-full px-1 text-[8px] font-bold leading-none tabular`,h?`bg-primary text-primary-foreground`:`bg-muted-foreground text-background`),children:f>9?`9+`:f}),t&&f===0&&(0,Y.jsx)(`span`,{className:`absolute top-1 right-1 w-1.5 h-1.5 rounded-full bg-primary`})]})}),(0,Y.jsxs)(gd,{side:`right`,align:`end`,sideOffset:8,className:`w-56`,children:[(0,Y.jsxs)(_d,{onSelect:()=>J.getState().setPaletteOpen(!0),children:[(0,Y.jsx)(Mr,{size:16}),(0,Y.jsx)(`span`,{children:o(`activity:menu.commandPalette`)}),(0,Y.jsx)(Sd,{children:`⌘K`})]}),(0,Y.jsxs)(_d,{onSelect:()=>J.getState().setShortcutsOpen(!0),children:[(0,Y.jsx)(A,{size:16}),(0,Y.jsx)(`span`,{children:o(`activity:menu.keyboardShortcuts`)}),(0,Y.jsx)(Sd,{children:`?`})]}),n.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(xd,{}),(0,Y.jsx)(bd,{className:`text-[11px] uppercase tracking-wide text-muted-foreground`,children:o(`activity:menu.panels`)}),n.map(e=>(0,Y.jsxs)(_d,{onSelect:()=>Q(e.id),children:[e.icon,(0,Y.jsx)(`span`,{children:o(`activity:nav.${e.id}`,e.label)}),c&&s===e.id?(0,Y.jsx)(`span`,{className:`ml-auto w-1.5 h-1.5 rounded-full bg-primary`}):(0,Y.jsx)(Sd,{children:ml(e.id)})]},e.id))]}),r.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(xd,{}),(0,Y.jsx)(bd,{className:`text-[11px] uppercase tracking-wide text-muted-foreground`,children:o(`activity:menu.views`)}),r.map(e=>(0,Y.jsxs)(_d,{onSelect:()=>_l(e.id),children:[e.icon,(0,Y.jsx)(`span`,{children:o(`activity:nav.${e.id}`,e.label)}),l===e.id&&(0,Y.jsx)(`span`,{className:`ml-auto w-1.5 h-1.5 rounded-full bg-primary`})]},e.id))]}),(0,Y.jsx)(xd,{}),(0,Y.jsx)(bd,{className:`text-[11px] uppercase tracking-wide text-muted-foreground`,children:o(`activity:menu.theme`)}),(0,Y.jsxs)(pd,{value:i,onValueChange:e=>a(e),children:[(0,Y.jsxs)(yd,{value:`light`,children:[(0,Y.jsx)(we,{size:16,className:`mr-2`}),o(`settings:appearance.themeLight`)]}),(0,Y.jsxs)(yd,{value:`dark`,children:[(0,Y.jsx)(un,{size:16,className:`mr-2`}),o(`settings:appearance.themeDark`)]}),(0,Y.jsxs)(yd,{value:`system`,children:[(0,Y.jsx)(an,{size:16,className:`mr-2`}),o(`settings:appearance.themeSystem`)]})]}),(0,Y.jsx)(xd,{}),(0,Y.jsx)(bd,{className:`text-[11px] uppercase tracking-wide text-muted-foreground`,children:o(`activity:menu.monitors`)}),(0,Y.jsxs)(_d,{onSelect:()=>g(`fleet`),children:[(0,Y.jsx)(je,{size:16}),(0,Y.jsx)(`span`,{children:o(`activity:menu.fleetMonitor`)}),u&&d===`fleet`?(0,Y.jsx)(`span`,{className:`ml-auto w-1.5 h-1.5 rounded-full bg-primary`}):(0,Y.jsx)(Sd,{children:`⇧⌘M`})]}),(0,Y.jsxs)(_d,{onSelect:()=>g(`agents`),children:[(0,Y.jsx)($n,{size:16}),(0,Y.jsx)(`span`,{children:o(`activity:menu.agentsMonitor`)}),u&&d===`agents`?(0,Y.jsx)(`span`,{className:`ml-auto w-1.5 h-1.5 rounded-full bg-primary`}):(0,Y.jsx)(Sd,{children:`⇧⌘A`})]})]})]})}function Id({compact:e=!1,icon:t,label:n,active:r,badge:i,onClick:a}){return(0,Y.jsxs)(`button`,{type:`button`,onClick:a,title:n,className:X(`relative flex items-center justify-center rounded-lg transition-colors`,e?`w-9 h-9`:`w-10 h-10`,`text-muted-foreground hover:text-foreground hover:bg-muted/70`,r&&`text-primary bg-primary/10`),children:[r&&(0,Y.jsx)(`span`,{className:`absolute left-0 top-1/2 -translate-y-1/2 w-0.5 h-6 rounded-r-full bg-primary`}),(0,Y.jsx)(`span`,{className:`h-5 w-5`,children:t}),i!==void 0&&i>0&&(0,Y.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 min-w-[15px] h-[15px] flex items-center justify-center rounded-full bg-primary text-[8px] font-bold text-primary-foreground leading-none px-1 tabular`,children:i>99?`99+`:i})]})}function Ld(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(e)}var Rd=e=>{let t=new Date(e);return`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`};function zd(e,t){let n=new Date(e),r=new Date(t),i=new Date(t-864e5);return Rd(e)===Rd(r.getTime())?`Today`:Rd(e)===Rd(i.getTime())?`Yesterday`:n.toLocaleDateString(void 0,{weekday:`short`,month:`short`,day:`numeric`,year:n.getFullYear()===r.getFullYear()?void 0:`numeric`})}function Bd(e,t=Date.now()){let n=[];for(let t=0;t<e.length;t++){let r=Ur(e[t]);if(r.role===`tool`){let e=n[n.length-1];e&&e.kind===`tools`?e.tools.push(r):n.push({kind:`tools`,tools:[r],key:r.id})}else{let i=e[t-1];n.push({kind:`msg`,message:r,isFirst:!i||i.role!==r.role})}}let r=[];for(let e of n){if(e.kind===`msg`&&e.message.role===`user`){r.push({kind:`user`,message:e.message,key:e.message.id});continue}let t=r[r.length-1];if(t&&t.kind===`agent`)t.items.push(e);else{let t=e.kind===`msg`?e.message.id:e.key;r.push({kind:`agent`,items:[e],key:t})}}let i=e=>{if(e.kind===`user`)return e.message.timestamp;let t=Ur(e.items[0]);return t.kind===`msg`?t.message.timestamp:t.tools[0]?.timestamp??0},a=[],o=null;for(let e=0;e<r.length;e++){let n=Ur(r[e]),s=i(n),c=Rd(s);if(c!==o&&(a.push({kind:`day`,key:`day-${c}-${e}`,label:zd(s,t)}),o=c),n.kind===`user`){a.push({kind:`user`,key:n.key,message:n.message});continue}let l=e===r.length-1,u=n.items.map((e,t)=>{let r=t>0;return e.kind===`msg`?{kind:`msg`,key:e.message.id,message:e.message,isFirst:!r&&e.isFirst,isContinuation:r}:{kind:`tools`,key:e.key,tools:e.tools,isContinuation:r,isLastGroup:t===n.items.length-1,hasRunningTool:e.tools.some(e=>e.toolResult===void 0)}});a.push({kind:`agent`,key:n.key,items:u,isLastTurn:l})}return a}var Vd={0:``,1:`▏`,2:`▎`,3:`▍`,4:`▌`,5:`▋`,6:`▊`,7:`▉`,8:`█`};function Hd(e){return e>=75?`bg-destructive`:e>=60?`bg-[hsl(var(--warning))]`:`bg-[hsl(var(--success))]`}function Ud(e){return e>=75?`text-destructive`:e>=60?`text-[hsl(var(--warning))]`:`text-[hsl(var(--success))]`}function Wd(e){return Number.isFinite(e)?Math.max(0,Math.min(100,e)):0}function Gd({pct:e,tokens:t,maxTokens:n,segments:r=10,showTokens:i=!0,className:a,onClick:o}){let{t:s}=V(),c=Wd(e),l=Math.round(c/100*r*8),u=[],d=l;for(let e=0;e<r;e++){let e=Math.min(8,d);u.push({fill:e}),d-=e}let f=`${Math.round(c)}%`,p=i&&t!==void 0&&n!==void 0&&n>0?` ${Ld(t)}/${Ld(n)}`:``;return(0,Y.jsxs)(`span`,{className:X(`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[11px] font-mono font-medium shrink-0`,o&&`cursor-pointer hover:ring-1 hover:ring-ring transition-shadow`,Ud(c),c>=75?`bg-red-500/10`:c>=60?`bg-amber-500/10`:`bg-emerald-500/10`,a),title:(t!==void 0&&n!==void 0?s(`activity:context.barWithTokens`,{tokens:t.toLocaleString(),max:n.toLocaleString(),pct:f}):s(`activity:context.barPct`,{pct:f}))+(o?s(`activity:context.barClick`):``),onClick:o?e=>{e.stopPropagation(),o()}:void 0,onKeyDown:o?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),o())}:void 0,role:o?`button`:void 0,tabIndex:o?0:void 0,children:[(0,Y.jsx)(`span`,{className:`inline-flex font-mono text-[10px] leading-none tracking-tight`,children:u.map((e,t)=>(0,Y.jsx)(`span`,{className:X(`tabular-nums w-[0.55em] text-center`,e.fill>0?Ud(c):`text-muted-foreground/30`),children:Vd[e.fill]??` `},t))}),(0,Y.jsx)(`span`,{children:f}),p&&(0,Y.jsx)(`span`,{className:`tabular-nums`,children:p})]})}function Kd({pct:e,tokens:t,maxTokens:n,showTokens:r=!0,className:i,onClick:a}){let{t:o}=V(),s=Wd(e),c=`${Math.round(s)}%`,l=r&&t!==void 0&&n!==void 0&&n>0?` ${Ld(t)}/${Ld(n)}`:``;return(0,Y.jsxs)(`span`,{className:X(`inline-flex items-center gap-1.5`,a&&`cursor-pointer hover:opacity-80 transition-opacity`,i),title:(t!==void 0&&n!==void 0?o(`activity:context.barWithTokens`,{tokens:t.toLocaleString(),max:n.toLocaleString(),pct:c}):o(`activity:context.barPct`,{pct:c}))+(a?o(`activity:context.barClick`):``),onClick:a?e=>{e.stopPropagation(),a()}:void 0,onKeyDown:a?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),a())}:void 0,role:a?`button`:void 0,tabIndex:a?0:void 0,children:[(0,Y.jsx)(`span`,{className:`h-1.5 w-16 overflow-hidden rounded-full bg-muted shrink-0`,children:(0,Y.jsx)(`span`,{className:X(`h-full rounded-full transition-all duration-300`,Hd(s)),style:{width:`${Math.max(2,s)}%`}})}),(0,Y.jsx)(`span`,{className:X(`text-[11px] font-mono tabular-nums font-medium`,Ud(s)),children:c}),l&&(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:l})]})}var qd={text:{labelKey:`kindAssistant`,icon:Pt,tone:`text-primary`,bubble:`border-border bg-card`},thinking:{labelKey:`kindThinking`,icon:Me,tone:`text-violet-500`,bubble:`border-violet-500/20 bg-violet-500/5`},tool_use:{labelKey:`kindToolCall`,icon:In,tone:`text-amber-500`,bubble:`border-amber-500/20 bg-amber-500/5`},tool_result:{labelKey:`kindToolResult`,icon:z,tone:`text-emerald-500`,bubble:`border-emerald-500/20 bg-emerald-500/5`},error:{labelKey:`kindError`,icon:Ct,tone:`text-destructive`,bubble:`border-destructive/25 bg-destructive/5`},status:{labelKey:`kindStatus`,icon:ze,tone:`text-muted-foreground`,bubble:`border-border bg-muted/25`},system:{labelKey:`kindSystem`,icon:Xe,tone:`text-muted-foreground`,bubble:`border-border bg-muted/25`}};function Jd(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}):``}function Yd(e){return e.map(e=>{let t=qd[e.kind]??qd.status,n=Jd(e.ts),r=e.toolName?` [${e.toolName}]`:``;return`[${n}] ${e.agentName} · ${b.t(`activity:transcript.${t.labelKey}`)}${r}\n${e.content}`}).join(`
43
-
44
- `)}function Xd({entries:e,agentName:t,className:n,compact:r=!1,maxHeightClassName:i,title:a,showHeader:o=!0}){let{t:s}=V(),[c,l]=(0,U.useState)(!1),u=(0,U.useMemo)(()=>Yd(e),[e]),d=(0,U.useCallback)(async()=>{if(u)try{await navigator.clipboard.writeText(u),l(!0),setTimeout(()=>l(!1),1600)}catch{}},[u]);return(0,Y.jsxs)(`div`,{className:X(`rounded-lg border bg-card`,n),children:[o&&(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b bg-muted/25 px-3 py-2`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(j,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,Y.jsx)(`span`,{className:`truncate text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:a??s(`activity:transcript.title`)}),t&&(0,Y.jsx)(`span`,{className:`truncate text-[10px] text-muted-foreground`,children:t}),(0,Y.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,Y.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,Y.jsx)(z,{className:`h-3 w-3 text-emerald-500`}):(0,Y.jsx)(Ft,{className:`h-3 w-3`}),s(c?`common:action.copied`:`common:action.copy`)]})]}),(0,Y.jsx)(`div`,{className:X(`space-y-2 overflow-y-auto p-2`,i??(r?`max-h-72`:`max-h-[32rem]`)),children:e.length===0?(0,Y.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=qd[e.kind]??qd.status,n=t.icon;return(0,Y.jsxs)(`div`,{className:X(`rounded-md border px-3 py-2`,t.bubble,r?`space-y-1`:`space-y-1.5`),children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(n,{className:X(`h-3.5 w-3.5 shrink-0`,t.tone)}),(0,Y.jsx)(`span`,{className:`shrink-0 text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:s(`activity:transcript.${t.labelKey}`)}),e.toolName&&(0,Y.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,Y.jsx)(`span`,{className:`ml-auto shrink-0 font-mono text-[9px] tabular-nums text-muted-foreground`,children:Jd(e.ts)})]}),(0,Y.jsx)(`pre`,{className:X(`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 Zd=[` `,`▁`,`▂`,`▃`,`▄`,`▅`,`▆`,`▇`,`█`],Qd=12;function $d(e,t){return t===0?0:Math.min(8,Math.round(e/t*8))}function ef({bins:e,className:t}){let{t:n}=V(),r=Array.from({length:Qd},(t,n)=>e.at(-(Qd-n))??0),i=Math.max(...r,1);return i===1&&r.every(e=>e===0)?(0,Y.jsx)(`span`,{className:t,"aria-label":n(`common:sparkline.noActivity`),title:n(`common:sparkline.noActivityYet`),children:`—`}):(0,Y.jsx)(`span`,{className:t,"aria-label":n(`common:sparkline.activityMax`,{count:i}),title:n(`common:sparkline.activityPeak`,{count:i}),children:r.map((e,t)=>{let n=$d(e,i),r=Zd[n];return(0,Y.jsx)(`span`,{style:{color:n>=7?`hsl(var(--success))`:`hsl(var(--muted-foreground))`,opacity:n>0?void 0:.3},children:r},t)})})}function tf(e){return e<=0?`$0`:e>=.01?`$${e.toFixed(3)}`:`$${e.toFixed(5)}`.replace(/0+$/,``).replace(/\.$/,``)}function nf(e){let t=Math.floor(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}var rf={running:{led:`bg-[hsl(var(--success))]`,pulse:!0,badge:`bg-[hsl(var(--success))]/15 text-[hsl(var(--success))]`},completed:{led:`bg-[hsl(var(--success))]`,pulse:!1,badge:`bg-muted text-muted-foreground`},failed:{led:`bg-destructive`,pulse:!1,badge:`bg-destructive/15 text-destructive`},timeout:{led:`bg-[hsl(var(--warning))]`,pulse:!1,badge:`bg-amber-500/15 text-amber-500`},stopped:{led:`bg-muted-foreground`,pulse:!1,badge:`bg-muted text-muted-foreground`}};function af({agent:e,isLeader:t}){let n=rf[e.status],{t:r}=V(),i=e.status===`running`,a=Date.now()-e.startedAt,o=Xs(t=>t.agentTranscripts.get(e.id)??Bs),s=[...e.toolLog.slice(0,8)].reverse();return(0,Y.jsxs)(`div`,{className:X(`rounded-xl border p-4 space-y-3`,i?`border-primary/20 bg-primary/[0.02]`:`border-border bg-card`,t&&`ring-2 ring-amber-500/30`),children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:X(`led`,n.led,n.pulse&&`led-pulse`,`mt-0.5`)}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-semibold`,children:e.name}),t&&(0,Y.jsx)(on,{className:`h-3.5 w-3.5 text-amber-500`,"aria-label":r(`activity:fleet.leader`)}),e.extensions>0&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full bg-amber-500/15 text-[10px] text-amber-600 dark:text-amber-400 font-medium`,children:[(0,Y.jsx)(tn,{className:`h-2.5 w-2.5`}),`×`,e.extensions]})]}),(0,Y.jsx)(`span`,{className:X(`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,Y.jsx)(`div`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground`,children:t&&(0,Y.jsx)(`span`,{className:`text-[9px] bg-amber-500/15 text-amber-600 dark:text-amber-400 px-1.5 py-0.5 rounded`,children:r(`activity:agentsMonitor.leaderBadge`)})})]}),e.description&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed line-clamp-2`,children:e.description}),e.budgetWarning&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg bg-amber-500/10 border border-amber-500/20 text-xs`,children:[(0,Y.jsx)(tn,{className:`h-3.5 w-3.5 text-amber-500 shrink-0`}),(0,Y.jsx)(`span`,{className:`text-amber-600 dark:text-amber-400`,children:r(`activity:fleet.budgetWarning`,{kind:e.budgetWarning.kind,used:e.budgetWarning.used,limit:e.budgetWarning.limit})})]}),e.failureReason&&(0,Y.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,Y.jsxs)(`span`,{className:`text-destructive font-medium`,children:[`✗ `,e.failureReason]})}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-4 gap-2`,children:[(0,Y.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-2 py-1.5 text-center`,children:[(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:r(`activity:agentsMonitor.iters`)}),(0,Y.jsx)(`div`,{className:`text-xs font-mono font-semibold tabular-nums`,children:e.iteration})]}),(0,Y.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-2 py-1.5 text-center`,children:[(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:r(`activity:agentsMonitor.tools`)}),(0,Y.jsx)(`div`,{className:`text-xs font-mono font-semibold tabular-nums`,children:e.toolCalls})]}),(0,Y.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-2 py-1.5 text-center`,children:[(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:r(`activity:fleet.cost`)}),(0,Y.jsx)(`div`,{className:`text-xs font-mono font-semibold tabular-nums`,children:tf(e.costUsd)})]}),(0,Y.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-2 py-1.5 text-center`,children:[(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:r(`activity:fleet.elapsed`)}),(0,Y.jsx)(`div`,{className:`text-xs font-mono font-semibold tabular-nums`,children:nf(a)})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r(`activity:agentsMonitor.activityBins`)}),(0,Y.jsx)(ef,{bins:e.sparklineBins,className:`font-mono text-[9px]`})]}),(0,Y.jsx)(Gd,{pct:e.ctxPct,tokens:e.ctxTokens,maxTokens:e.maxContext})]}),(e.provider||e.model)&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground`,children:[(0,Y.jsx)(wr,{className:`h-3 w-3`}),(0,Y.jsxs)(`span`,{className:`font-mono`,children:[e.provider??`?`,`/`,e.model??`?`]})]}),(e.currentTool||e.lastTool)&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground`,children:[(0,Y.jsx)(In,{className:X(`h-3 w-3`,i&&`animate-pulse text-primary`)}),(0,Y.jsx)(`span`,{className:`font-mono`,children:e.currentTool??e.lastTool}),i&&(0,Y.jsx)(B,{className:`h-3 w-3 animate-spin`})]}),(0,Y.jsx)(Xd,{entries:o,agentName:e.name,compact:!0,maxHeightClassName:`max-h-80`}),e.partialText&&i&&(0,Y.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 p-2`,children:[(0,Y.jsx)(`div`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider mb-1`,children:r(`activity:agentsMonitor.streamingOutput`)}),(0,Y.jsx)(`pre`,{className:`text-[10px] font-mono text-foreground/80 whitespace-pre-wrap line-clamp-3 leading-relaxed`,children:e.partialText})]}),s.length>0&&(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(`div`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:r(`activity:agentsMonitor.recentTools`)}),(0,Y.jsx)(`div`,{className:`space-y-0.5`,children:s.map((e,t)=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-mono`,children:[(0,Y.jsx)(`span`,{className:X(`shrink-0`,e.ok?`text-[hsl(var(--success))]`:`text-destructive`),children:e.ok?`✓`:`✗`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground truncate`,children:e.name}),(0,Y.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`})]},t))})]}),e.finalText&&!i&&(0,Y.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 p-2`,children:[(0,Y.jsx)(`div`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider mb-1`,children:r(`activity:agentsMonitor.finalOutput`)}),(0,Y.jsx)(`pre`,{className:`text-[10px] font-mono text-foreground/80 whitespace-pre-wrap line-clamp-4 leading-relaxed`,children:e.finalText})]})]})}function of({onClose:e}){let t=Xs(e=>e.agents),{t:n}=V(),r=Xs(e=>e.leaderId),[i,a]=(0,U.useState)(0),o=(0,U.useMemo)(()=>{let e=Array.from(t.values());return e.sort((e,t)=>{if(e.id===r)return-1;if(t.id===r)return 1;let n=e.status===`running`?0:1,i=t.status===`running`?0:1;return n===i?e.startedAt-t.startedAt:n-i}),e},[t,r]),s=(0,U.useCallback)(t=>{if(t.key===`Escape`){e();return}if(t.key===`ArrowDown`){t.preventDefault(),a(e=>Math.min(e+1,o.length-1));return}if(t.key===`ArrowUp`){t.preventDefault(),a(e=>Math.max(e-1,0));return}},[o.length,e]);(0,U.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]);let l=o[i]??null;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/10 backdrop-blur-[1px]`,onClick:e,"aria-hidden":`true`}),(0,Y.jsxs)(`div`,{className:`fixed right-0 top-0 z-50 flex h-full min-h-0 w-[600px] max-w-[90vw] flex-col border-l bg-background shadow-2xl animate-slide-in-right`,onKeyDown:s,tabIndex:-1,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b bg-card/80 backdrop-blur shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(j,{className:`h-5 w-5 text-primary`}),(0,Y.jsx)(`h2`,{className:`text-sm font-semibold`,children:n(`activity:agentsMonitor.heading`)}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`activity:agents.totalCount`,{count:o.length})})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>a(e=>Math.max(e-1,0)),className:`p-1.5 rounded-md hover:bg-muted transition-colors disabled:opacity-30`,disabled:i===0,"aria-label":n(`activity:agentsMonitor.prevAgent`),children:(0,Y.jsx)(c,{className:`h-4 w-4`})}),(0,Y.jsx)(`span`,{className:`text-xs tabular-nums text-muted-foreground font-mono`,children:o.length>0?`${i+1}/${o.length}`:`0/0`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>a(e=>Math.min(e+1,o.length-1)),className:`p-1.5 rounded-md hover:bg-muted transition-colors disabled:opacity-30`,disabled:i>=o.length-1,"aria-label":n(`activity:agentsMonitor.nextAgent`),children:(0,Y.jsx)(Oe,{className:`h-4 w-4`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:e,className:`p-1.5 rounded-md hover:bg-muted transition-colors ml-2`,"aria-label":n(`activity:agentsMonitor.closeAria`),children:(0,Y.jsx)(Xn,{className:`h-4 w-4`})})]})]}),(0,Y.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto p-4`,children:o.length===0?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-muted-foreground`,children:[(0,Y.jsx)(j,{className:`h-12 w-12 mb-3 opacity-20`}),(0,Y.jsx)(`p`,{className:`text-sm font-medium`,children:n(`activity:inspector.noAgentsActive`)})]}):l?(0,Y.jsx)(`div`,{className:`max-w-2xl mx-auto`,children:(0,Y.jsx)(af,{agent:l,isLeader:l.id===r})}):null}),o.length>0&&(0,Y.jsxs)(`div`,{className:`border-t bg-card/80 backdrop-blur shrink-0`,children:[(0,Y.jsx)(`div`,{className:`px-4 py-2 flex items-center gap-2 overflow-x-auto`,children:o.map((e,t)=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>a(t),className:X(`shrink-0 flex items-center gap-1.5 px-2 py-1 rounded-md text-[10px] transition-colors`,t===i?`bg-primary/15 text-primary ring-1 ring-primary/40`:`hover:bg-accent text-muted-foreground`),children:[(0,Y.jsx)(`span`,{className:X(`led`,rf[e.status].led,rf[e.status].pulse&&`led-pulse`,`shrink-0`)}),(0,Y.jsx)(`span`,{children:e.name}),e.id===r&&(0,Y.jsx)(on,{className:`h-2.5 w-2.5 text-amber-500 shrink-0`})]},e.id))}),(0,Y.jsxs)(`div`,{className:`px-4 py-1.5 border-t text-[10px] text-muted-foreground flex items-center gap-4`,children:[(0,Y.jsx)(`span`,{children:n(`activity:agentsMonitor.hintPage`)}),(0,Y.jsx)(`span`,{children:n(`activity:agentsMonitor.hintNavigate`)}),(0,Y.jsx)(`span`,{children:n(`activity:agentsMonitor.hintEsc`)})]})]})]})]})}function sf(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m ${t%60}s`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d`}function cf(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function lf(e){return e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function uf(e){return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function df(e){return e.includes(`error`)||e.includes(`fail`)?`text-red-400`:e.includes(`warn`)?`text-amber-400`:e.includes(`success`)||e.includes(`complete`)?`text-emerald-400`:`text-slate-400`}function ff({icon:e,label:t,value:n,sub:r,color:i=`text-slate-300`}){return(0,Y.jsxs)(`div`,{className:`rounded-lg border border-slate-700 bg-slate-800/50 p-4 flex items-start gap-3`,children:[(0,Y.jsx)(`div`,{className:`mt-0.5 ${i}`,children:e}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-2xl font-semibold tabular-nums text-slate-100`,children:n}),(0,Y.jsx)(`div`,{className:`text-xs text-slate-500 mt-0.5`,children:t}),r?(0,Y.jsx)(`div`,{className:`text-xs text-slate-600 mt-1`,children:r}):null]})]})}function pf(){let{t:e}=V(),[t,n]=(0,U.useState)(null),[r,i]=(0,U.useState)([]),[a,o]=(0,U.useState)([]),[s,c]=(0,U.useState)(null),[l,u]=(0,U.useState)(!0),[d,f]=(0,U.useState)(!1),p=(0,U.useRef)(null),m=(0,U.useCallback)(async()=>{try{let e=await fetch(`/api/analytics/summary`);e.ok&&n(await e.json())}catch{}},[]),h=(0,U.useCallback)(async()=>{try{let e=await fetch(`/api/analytics?limit=50`);e.ok&&i((await e.json()).events)}catch{}},[]),g=(0,U.useCallback)(async()=>{try{let e=await fetch(`/api/sessions`);e.ok&&o(await e.json())}catch{}},[]),_=(0,U.useCallback)(async()=>{if(!d){f(!0);try{let e=W(K.getState().wsUrl);p.current=e;let t=e.on(`stats.get`,e=>{let n=e.payload;c(n),f(!1),t()});e.getStats(),setTimeout(()=>{f(!1),t()},8e3)}catch{f(!1)}}},[d]);(0,U.useEffect)(()=>{let e=()=>{Promise.all([m(),h(),g(),_()]).finally(()=>u(!1))};e();let t=setInterval(e,1e4);return()=>clearInterval(t)},[m,h,g,_]);let{totalAgents:v,activeAgents:y,totalToolCalls:b,totalIterations:x}=(0,U.useMemo)(()=>{let e=0,t=0,n=0,r=0;for(let i of a)for(let a of i.agents)e++,a.status===`running`&&t++,n+=a.toolCalls,r+=a.iterations;return{totalAgents:e,activeAgents:t,totalToolCalls:n,totalIterations:r}},[a]),S=(0,U.useMemo)(()=>t?Object.entries(t.categoryBreakdown).sort((e,t)=>t[1]-e[1]).slice(0,8):[],[t]),C=(0,U.useMemo)(()=>t?Object.entries(t.eventBreakdown).sort((e,t)=>t[1]-e[1]).slice(0,10):[],[t]),w=(0,U.useMemo)(()=>{if(!t)return 0;let e=0;for(let[n,r]of Object.entries(t.eventBreakdown))n.toLowerCase().includes(`error`)&&(e+=r);return e},[t]),T=(0,U.useMemo)(()=>{if(!t)return 0;let e=0;for(let[n,r]of Object.entries(t.eventBreakdown))n.toLowerCase().includes(`warn`)&&(e+=r);return e},[t]),E=(0,U.useMemo)(()=>[...r].reverse(),[r]);return l?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 p-4 text-slate-400`,children:[(0,Y.jsx)(B,{className:`h-4 w-4 animate-spin`}),e(`activity:analytics.loading`)]}):(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Y.jsx)(`div`,{className:`shrink-0 px-4 pt-3 pb-2 border-b border-slate-700/50`,children:(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Sr,{className:`h-4 w-4 text-cyan-400`}),(0,Y.jsx)(`h1`,{className:`text-sm font-semibold text-slate-200 uppercase tracking-wider`,children:e(`activity:analytics.heading`)})]}),(0,Y.jsx)(`span`,{className:`text-xs text-slate-600`,children:e(`activity:analytics.autoRefresh`)})]})}),(0,Y.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto p-4 space-y-5`,children:[(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3`,children:[(0,Y.jsx)(ff,{icon:(0,Y.jsx)($n,{className:`h-4 w-4`}),label:e(`activity:analytics.liveSessions`),value:a.length,color:`text-cyan-400`}),(0,Y.jsx)(ff,{icon:(0,Y.jsx)(Rr,{className:`h-4 w-4`}),label:e(`activity:analytics.agents`),value:`${y}/${v}`,sub:y>0?e(`activity:analytics.agentsActive`,{count:y}):void 0,color:`text-blue-400`}),(0,Y.jsx)(ff,{icon:(0,Y.jsx)(Ir,{className:`h-4 w-4`}),label:e(`activity:analytics.totalEvents`),value:t?.totalEvents??0,sub:e(`activity:analytics.categoriesSub`,{count:t?.uniqueCategories??0}),color:`text-violet-400`}),(0,Y.jsx)(ff,{icon:(0,Y.jsx)(En,{className:`h-4 w-4`}),label:e(`activity:analytics.toolCalls`),value:b,sub:e(`activity:analytics.iterationsSub`,{count:x}),color:`text-emerald-400`}),(0,Y.jsx)(ff,{icon:(0,Y.jsx)(Fn,{className:`h-4 w-4`}),label:e(`activity:analytics.sessionCost`),value:s?lf(s.cost):`—`,sub:s?e(`activity:analytics.tokensSub`,{input:cf(s.usage.input),output:cf(s.usage.output)}):void 0,color:`text-amber-400`}),(0,Y.jsx)(ff,{icon:(0,Y.jsx)(wr,{className:`h-4 w-4`}),label:e(`activity:analytics.sessionDuration`),value:s?sf(s.elapsedMs):`—`,sub:s?e(`activity:analytics.messagesSub`,{count:s.messages}):void 0,color:`text-rose-400`})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`rounded-lg border border-slate-700 bg-slate-800/30 p-4`,children:[(0,Y.jsxs)(`h3`,{className:`text-xs font-semibold text-slate-400 uppercase tracking-wider mb-3 flex items-center gap-2`,children:[(0,Y.jsx)(Ze,{className:`h-3.5 w-3.5 text-cyan-400`}),e(`activity:analytics.eventsByCategory`)]}),S.length===0?(0,Y.jsx)(`p`,{className:`text-slate-600 text-xs`,children:e(`activity:analytics.noEvents`)}):(0,Y.jsx)(`div`,{className:`space-y-1.5`,children:S.map(([e,t])=>{let n=S[0]?.[1]??1,r=Math.round(t/n*100);return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,Y.jsx)(`span`,{className:`w-28 shrink-0 truncate text-slate-300`,children:e}),(0,Y.jsx)(`div`,{className:`flex-1 h-4 bg-slate-700/50 rounded-full overflow-hidden`,children:(0,Y.jsx)(`div`,{className:`h-full bg-cyan-500/60 rounded-full transition-all`,style:{width:`${Math.max(r,4)}%`}})}),(0,Y.jsx)(`span`,{className:`w-10 text-right tabular-nums text-slate-400`,children:t})]},e)})})]}),(0,Y.jsxs)(`div`,{className:`rounded-lg border border-slate-700 bg-slate-800/30 p-4`,children:[(0,Y.jsxs)(`h3`,{className:`text-xs font-semibold text-slate-400 uppercase tracking-wider mb-3 flex items-center gap-2`,children:[(0,Y.jsx)(Sr,{className:`h-3.5 w-3.5 text-violet-400`}),e(`activity:analytics.topEvents`)]}),C.length===0?(0,Y.jsx)(`p`,{className:`text-slate-600 text-xs`,children:e(`activity:analytics.noEvents`)}):(0,Y.jsx)(`div`,{className:`space-y-1.5`,children:C.map(([e,t])=>{let n=C[0]?.[1]??1,r=Math.round(t/n*100);return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,Y.jsx)(`span`,{className:`w-36 shrink-0 truncate ${df(e)}`,children:e}),(0,Y.jsx)(`div`,{className:`flex-1 h-4 bg-slate-700/50 rounded-full overflow-hidden`,children:(0,Y.jsx)(`div`,{className:`h-full bg-violet-500/60 rounded-full transition-all`,style:{width:`${Math.max(r,4)}%`}})}),(0,Y.jsx)(`span`,{className:`w-10 text-right tabular-nums text-slate-400`,children:t})]},e)})})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`rounded-lg border border-slate-700 bg-slate-800/30 p-4`,children:[(0,Y.jsxs)(`h3`,{className:`text-xs font-semibold text-slate-400 uppercase tracking-wider mb-3 flex items-center gap-2`,children:[(0,Y.jsx)(Fn,{className:`h-3.5 w-3.5 text-amber-400`}),e(`activity:analytics.activeSessionUsage`)]}),s?(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-xs`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-slate-500`,children:e(`activity:analytics.provider`)}),(0,Y.jsx)(`p`,{className:`text-slate-200 font-mono mt-0.5`,children:s.provider})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-slate-500`,children:e(`activity:analytics.model`)}),(0,Y.jsx)(`p`,{className:`text-slate-200 font-mono mt-0.5`,children:s.model})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-slate-500`,children:e(`activity:analytics.inputTokens`)}),(0,Y.jsx)(`p`,{className:`text-slate-200 tabular-nums mt-0.5`,children:cf(s.usage.input)})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-slate-500`,children:e(`activity:analytics.outputTokens`)}),(0,Y.jsx)(`p`,{className:`text-slate-200 tabular-nums mt-0.5`,children:cf(s.usage.output)})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-slate-500`,children:e(`activity:analytics.cacheRatio`)}),(0,Y.jsxs)(`p`,{className:`text-slate-200 tabular-nums mt-0.5`,children:[(s.cache.ratio*100).toFixed(1),`%`]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-slate-500`,children:e(`activity:analytics.filesRead`)}),(0,Y.jsx)(`p`,{className:`text-slate-200 tabular-nums mt-0.5`,children:s.readFiles})]})]}):(0,Y.jsx)(`p`,{className:`text-slate-600 text-xs`,children:e(`activity:analytics.noSession`)})]}),(0,Y.jsxs)(`div`,{className:`rounded-lg border border-slate-700 bg-slate-800/30 p-4`,children:[(0,Y.jsxs)(`h3`,{className:`text-xs font-semibold text-slate-400 uppercase tracking-wider mb-3 flex items-center gap-2`,children:[(0,Y.jsx)(gt,{className:`h-3.5 w-3.5 text-amber-400`}),e(`activity:analytics.healthErrors`)]}),(0,Y.jsx)(`div`,{className:`space-y-2 text-xs`,children:t?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-slate-500`,children:e(`activity:analytics.errorEvents`)}),(0,Y.jsx)(`span`,{className:`text-red-400 tabular-nums`,children:w})]}),(0,Y.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-slate-500`,children:e(`activity:analytics.warningEvents`)}),(0,Y.jsx)(`span`,{className:`text-amber-400 tabular-nums`,children:T})]}),(0,Y.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-slate-500`,children:e(`activity:analytics.cacheHitRate`)}),(0,Y.jsx)(`span`,{className:`text-emerald-400 tabular-nums`,children:s?`${(s.cache.ratio*100).toFixed(1)}%`:`—`})]}),(0,Y.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-slate-500`,children:e(`activity:analytics.totalCategories`)}),(0,Y.jsx)(`span`,{className:`text-slate-300 tabular-nums`,children:t.uniqueCategories})]})]}):(0,Y.jsx)(`p`,{className:`text-slate-600`,children:e(`activity:analytics.waitingData`)})})]})]}),(0,Y.jsxs)(`div`,{className:`rounded-lg border border-slate-700 bg-slate-800/30 p-4`,children:[(0,Y.jsxs)(`h3`,{className:`text-xs font-semibold text-slate-400 uppercase tracking-wider mb-3 flex items-center gap-2`,children:[(0,Y.jsx)($n,{className:`h-3.5 w-3.5 text-cyan-400`}),e(`activity:analytics.recentEvents`)]}),r.length===0?(0,Y.jsx)(`p`,{className:`text-slate-600 text-xs`,children:e(`activity:analytics.noRecentEvents`)}):(0,Y.jsx)(`div`,{className:`max-h-64 overflow-y-auto space-y-1`,children:E.map((e,t)=>(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 py-1 px-2 rounded hover:bg-slate-700/30 text-xs`,children:[(0,Y.jsx)(`span`,{className:`text-slate-600 tabular-nums shrink-0 w-16`,children:uf(e.timestamp)}),(0,Y.jsx)(`span`,{className:`shrink-0 w-24 truncate ${df(e.event)}`,children:e.event}),(0,Y.jsx)(`span`,{className:`text-slate-500 shrink-0 w-20 truncate`,children:e.category}),(0,Y.jsx)(`span`,{className:`text-slate-400 truncate`,children:e.label??e.sessionId??``})]},`${e.timestamp}-${t}`))})]})]})]})}var mf={pending:{icon:(0,Y.jsx)(Or,{className:`w-4 h-4`}),color:`text-muted-foreground`,label:`Pending`},in_progress:{icon:(0,Y.jsx)(Ge,{className:`w-4 h-4 animate-spin`}),color:`text-primary`,label:`In Progress`},blocked:{icon:(0,Y.jsx)(kn,{className:`w-4 h-4`}),color:`text-[hsl(var(--warning))]`,label:`Blocked`},failed:{icon:(0,Y.jsx)(Nn,{className:`w-4 h-4`}),color:`text-destructive`,label:`Failed`},review:{icon:(0,Y.jsx)(Le,{className:`w-4 h-4`}),color:`text-[hsl(var(--info))]`,label:`Review`},completed:{icon:(0,Y.jsx)(rn,{className:`w-4 h-4`}),color:`text-[hsl(var(--success))]`,label:`Done`}},hf={critical:`bg-destructive/15 text-destructive`,high:`bg-orange-500/15 text-orange-600 dark:text-orange-400`,medium:`bg-[hsl(var(--info)/0.15)] text-[hsl(var(--info))]`,low:`bg-muted text-muted-foreground`},gf={feature:`bg-[hsl(var(--success)/0.15)] text-[hsl(var(--success))]`,bugfix:`bg-destructive/15 text-destructive`,refactor:`bg-violet-500/15 text-violet-600 dark:text-violet-400`,docs:`bg-sky-500/15 text-sky-600 dark:text-sky-400`,test:`bg-primary/15 text-primary`,chore:`bg-muted text-muted-foreground`};function _f(e){if(!e)return``;let t=Math.floor(e/6e4);if(t<60)return`${t}m`;let n=Math.floor(t/60),r=t%60;return r>0?`${n}h ${r}m`:`${n}h`}function vf({task:e,onStatusChange:t,onRetry:n,agents:r,onAssign:i,compact:a,className:o}){let{t:s}=V(),c=mf[e.status],[l,u]=(0,U.useState)(!1),d=e.status===`in_progress`;return(0,Y.jsxs)(`div`,{className:X(`w-full text-left rounded-lg border p-3 transition-all hover:shadow-sm`,d?`border-primary/40 bg-primary/5`:e.status===`completed`?`border-[hsl(var(--success)/0.35)] bg-[hsl(var(--success)/0.06)]`:e.status===`failed`?`border-destructive/40 bg-destructive/5`:`border-border bg-card`,o),children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Y.jsx)(`span`,{className:X(`mt-0.5`,c.color),"aria-label":d?s(`common:status.inProgress`):void 0,children:c.icon}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-medium`,children:e.title}),(0,Y.jsx)(`span`,{className:X(`px-1.5 py-0.5 rounded text-[10px] font-medium`,hf[e.priority]),children:e.priority}),(0,Y.jsx)(`span`,{className:X(`px-1.5 py-0.5 rounded text-[10px] font-medium`,gf[e.type]),children:e.type})]}),e.description&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 line-clamp-2`,children:e.description})]})]}),e.assignee&&(0,Y.jsxs)(`div`,{className:X(`mt-2 inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-[10px] font-medium`,d?`bg-primary/15 text-primary`:`bg-muted text-muted-foreground`),children:[d&&(0,Y.jsx)(Ge,{className:`w-3 h-3 animate-spin`,"aria-label":s(`common:status.working`)}),(0,Y.jsx)(`span`,{children:e.assignee})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 mt-2 text-xs text-muted-foreground`,children:[e.estimateHours?(0,Y.jsxs)(`span`,{children:[`~`,e.estimateHours,`h`]}):null,e.actualHours?(0,Y.jsxs)(`span`,{children:[`• `,e.actualHours,`h`]}):null,e.startedAt?(0,Y.jsxs)(`span`,{children:[`• `,_f(Date.now()-e.startedAt)]}):null]}),e.tags.length>0&&(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:e.tags.map(e=>(0,Y.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:e},e))}),!a&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 mt-2`,children:[t&&e.status!==`in_progress`&&e.status!==`completed`&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>t(e.id,`in_progress`),className:`px-2 py-0.5 text-[10px] rounded bg-primary/15 text-primary hover:bg-primary/25 transition-colors`,children:s(`activity:task.start`)}),t&&e.status===`in_progress`&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>t(e.id,`completed`),className:`px-2 py-0.5 text-[10px] rounded bg-[hsl(var(--success)/0.15)] text-[hsl(var(--success))] hover:bg-[hsl(var(--success)/0.25)] transition-colors`,children:s(`activity:task.complete`)}),n&&(e.status===`failed`||e.status===`completed`)&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),className:`px-2 py-0.5 text-[10px] rounded bg-muted text-muted-foreground hover:bg-muted/70 transition-colors inline-flex items-center gap-1`,children:[(0,Y.jsx)(Le,{className:`w-3 h-3`}),` `,s(`activity:task.retry`)]}),i&&r&&r.length>0&&(l?(0,Y.jsxs)(`select`,{autoFocus:!0,defaultValue:e.assignee??``,onChange:t=>{i(e.id,t.target.value),u(!1)},onBlur:()=>u(!1),className:`px-1 py-0.5 text-[10px] rounded border border-border bg-card`,children:[(0,Y.jsx)(`option`,{value:``,children:s(`activity:task.unassigned`)}),r.map(e=>(0,Y.jsx)(`option`,{value:e,children:e},e))]}):(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>u(!0),className:`px-2 py-0.5 text-[10px] rounded bg-muted text-muted-foreground hover:bg-muted/70 transition-colors inline-flex items-center gap-1`,title:s(`activity:task.assignTitle`),children:[(0,Y.jsx)(Ke,{className:`w-3 h-3`}),` `,s(`activity:task.assign`)]}))]})]})}var yf=oe(`inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/90`,destructive:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,outline:`border border-input bg-background hover:bg-accent hover:text-accent-foreground`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-accent-foreground`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-10 px-4 py-2`,sm:`h-9 rounded-md px-3`,lg:`h-11 rounded-md px-8`,icon:`h-10 w-10`}},defaultVariants:{variant:`default`,size:`default`}}),$=U.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...i},a)=>(0,Y.jsx)(r?Vt:`button`,{className:X(yf({variant:t,size:n,className:e})),ref:a,...i}));$.displayName=`Button`;var bf=nt,xf=ue,Sf=U.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(N,{ref:n,className:X(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t}));Sf.displayName=N.displayName;var Cf=U.forwardRef(({className:e,children:t,...n},r)=>(0,Y.jsxs)(xf,{children:[(0,Y.jsx)(Sf,{}),(0,Y.jsxs)(Qe,{ref:r,className:X(`fixed left-[50%] top-[50%] z-50 grid max-h-[calc(100dvh-2rem)] w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg`,e),...n,children:[t,(0,Y.jsxs)(L,{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 data-[state=open]:bg-accent data-[state=open]:text-muted-foreground`,children:[(0,Y.jsx)(Xn,{className:`h-4 w-4`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}));Cf.displayName=Qe.displayName;var wf=({className:e,...t})=>(0,Y.jsx)(`div`,{className:X(`flex flex-col space-y-1.5 text-center sm:text-left`,e),...t});wf.displayName=`DialogHeader`;var Tf=({className:e,...t})=>(0,Y.jsx)(`div`,{className:X(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});Tf.displayName=`DialogFooter`;var Ef=U.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(Zn,{ref:n,className:X(`text-lg font-semibold leading-none tracking-tight`,e),...t}));Ef.displayName=Zn.displayName;var Df=U.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(ot,{ref:n,className:X(`text-sm text-muted-foreground`,e),...t}));Df.displayName=ot.displayName;var Of=U.forwardRef(({className:e,type:t,...n},r)=>(0,Y.jsx)(`input`,{type:t,className:X(`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50`,e),ref:r,...n}));Of.displayName=`Input`;var kf=h()((e,t)=>({request:null,open:n=>{t().request?.resolve(!1),e({request:n})},settle:n=>{t().request?.resolve(n),e({request:null})}}));function Af(e){return new Promise(t=>{kf.getState().open({...e,resolve:t})})}function jf(){let{t:e}=V(),t=kf(e=>e.request),n=kf(e=>e.settle);return(0,U.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Enter`&&(e.preventDefault(),kf.getState().settle(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,Y.jsx)(bf,{open:t!==null,onOpenChange:e=>{e||n(!1)},children:(0,Y.jsxs)(Cf,{className:`max-w-md`,children:[(0,Y.jsxs)(wf,{children:[(0,Y.jsx)(Ef,{children:t?.title}),t?.message&&(0,Y.jsx)(Df,{children:t.message})]}),(0,Y.jsxs)(Tf,{className:`gap-2`,children:[(0,Y.jsx)($,{variant:`outline`,size:`sm`,onClick:()=>n(!1),children:t?.cancelLabel??e(`common:action.cancel`)}),(0,Y.jsx)($,{variant:t?.danger?`destructive`:`default`,size:`sm`,autoFocus:!0,onClick:()=>n(!0),children:t?.confirmLabel??e(`common:action.confirm`)})]})]})})}var Mf=h()((e,t)=>({request:null,open:n=>{t().request?.resolve(null),e({request:n})},settle:n=>{t().request?.resolve(n),e({request:null})}}));function Nf(e){return new Promise(t=>{Mf.getState().open({...e,resolve:t})})}function Pf(){let{t:e}=V(),t=Mf(e=>e.request),n=Mf(e=>e.settle),[r,i]=(0,U.useState)(``);(0,U.useEffect)(()=>{i(t?.defaultValue??``)},[t]);let a=()=>{let e=r.trim();n(e.length>0?e:null)};return(0,Y.jsx)(bf,{open:t!==null,onOpenChange:e=>{e||n(null)},children:(0,Y.jsxs)(Cf,{className:`max-w-md`,children:[(0,Y.jsxs)(wf,{children:[(0,Y.jsx)(Ef,{children:t?.title}),t?.message&&(0,Y.jsx)(Df,{children:t.message})]}),(0,Y.jsx)(Of,{autoFocus:!0,value:r,placeholder:t?.placeholder,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),a())}}),(0,Y.jsxs)(Tf,{className:`gap-2`,children:[(0,Y.jsx)($,{variant:`outline`,size:`sm`,onClick:()=>n(null),children:t?.cancelLabel??e(`common:action.cancel`)}),(0,Y.jsx)($,{size:`sm`,disabled:r.trim().length===0,onClick:a,children:t?.confirmLabel??e(`common:action.ok`)})]})]})})}var Ff=[{key:`pending`,label:`Pending`,match:[`pending`,`blocked`]},{key:`in_progress`,label:`In Progress`,match:[`in_progress`]},{key:`review`,label:`Review`,match:[`review`]},{key:`failed`,label:`Failed`,match:[`failed`]},{key:`completed`,label:`Done`,match:[`completed`]}],If={pending:`bg-muted text-muted-foreground`,ready:`bg-[hsl(var(--info)/0.15)] text-[hsl(var(--info))]`,running:`bg-primary/15 text-primary`,paused:`bg-amber-500/15 text-amber-600 dark:text-amber-400`,completed:`bg-[hsl(var(--success)/0.15)] text-[hsl(var(--success))]`,failed:`bg-destructive/15 text-destructive`,skipped:`bg-muted text-muted-foreground`};function Lf(){let{client:e}=sd(),{t}=V(),n=ec(e=>e.phases),[r,i]=(0,U.useState)(`phase`),[a,o]=(0,U.useState)(null),[s,c]=(0,U.useState)(null),l=(0,U.useMemo)(()=>n.flatMap(e=>(e.tasks??[]).map(t=>({...t,phaseId:e.id}))),[n]),u=(0,U.useMemo)(()=>[...new Set(l.map(e=>e.assignee).filter(e=>!!e))],[l]),d=(0,U.useCallback)(t=>e?.send?.(t),[e]),f=(0,U.useCallback)((e,t)=>d({type:`autophase.taskStatus`,payload:{taskId:e,status:t}}),[d]),p=(0,U.useCallback)(e=>d({type:`autophase.retryTask`,payload:{taskId:e}}),[d]),m=(0,U.useCallback)((e,t)=>d({type:`autophase.assignTask`,payload:{taskId:e,agentName:t||void 0}}),[d]),h=(0,U.useCallback)(e=>{Nf({title:t(`activity:board.newTaskTitle`),placeholder:t(`activity:board.newTaskPlaceholder`),confirmLabel:t(`activity:board.addTask`)}).then(t=>{t&&d({type:`autophase.addTask`,payload:{phaseId:e,title:t}})})},[d]),g=(0,U.useCallback)(e=>{a&&d({type:`autophase.moveTask`,payload:{taskId:a,toPhaseId:e}}),o(null),c(null)},[a,d]),_=(0,U.useCallback)(e=>{a&&d({type:`autophase.taskStatus`,payload:{taskId:a,status:e}}),o(null),c(null)},[a,d]),v={onStatusChange:f,onRetry:p,agents:u,onAssign:m};function y(e){return{draggable:!0,onDragStart:t=>{o(e),t.dataTransfer.effectAllowed=`move`},onDragEnd:()=>{o(null),c(null)}}}function b(e,t){return{onDragOver:t=>{t.preventDefault(),t.dataTransfer.dropEffect=`move`,s!==e&&c(e)},onDragLeave:()=>c(t=>t===e?null:t),onDrop:e=>{e.preventDefault(),t()},"data-hover":s===e||void 0}}return n.length===0?(0,Y.jsx)(`div`,{className:`flex h-full min-h-0 min-w-0 items-center justify-center text-muted-foreground`,children:(0,Y.jsx)(`p`,{className:`text-sm`,children:t(`activity:board.empty`)})}):(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-4 py-2`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`activity:board.summary`,{phases:n.length,tasks:l.length})}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>i(`phase`),className:X(`inline-flex items-center gap-1 rounded px-2 py-1 text-xs transition-colors`,r===`phase`?`bg-primary/15 text-primary`:`text-muted-foreground hover:text-foreground`),children:[(0,Y.jsx)(Ut,{className:`h-3.5 w-3.5`}),` `,t(`activity:board.phases`)]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>i(`status`),className:X(`inline-flex items-center gap-1 rounded px-2 py-1 text-xs transition-colors`,r===`status`?`bg-primary/15 text-primary`:`text-muted-foreground hover:text-foreground`),children:[(0,Y.jsx)(Ie,{className:`h-3.5 w-3.5`}),` `,t(`activity:board.statusTab`)]})]})]}),r===`phase`?(0,Y.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 gap-3 overflow-x-auto p-3`,children:n.map(e=>{let n=l.filter(t=>t.phaseId===e.id);return(0,Y.jsxs)(`div`,{...b(`phase:${e.id}`,()=>g(e.id)),className:X(`flex min-h-0 w-80 shrink-0 flex-col rounded-lg border bg-muted/30 transition-colors`,s===`phase:${e.id}`?`border-primary/60 bg-primary/5`:`border-border`),children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border px-3 py-2`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`truncate text-sm font-semibold`,children:e.name}),(0,Y.jsx)(`span`,{className:X(`rounded px-1.5 py-0.5 text-[10px] font-medium capitalize`,If[e.status]),children:e.status})]}),(0,Y.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[e.completedTasks,`/`,e.taskCount,` · `,e.progressPercent,`%`]})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>h(e.id),title:t(`activity:board.addTask`),className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,Y.jsx)(hn,{className:`h-4 w-4`})})]}),(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-2`,children:n.length===0?(0,Y.jsx)(`p`,{className:`px-1 py-4 text-center text-[11px] text-muted-foreground`,children:t(`activity:board.dropHere`)}):n.map(e=>(0,Y.jsx)(`div`,{...y(e.id),className:X(a===e.id&&`opacity-50`),children:(0,Y.jsx)(vf,{task:e,...v})},e.id))})]},e.id)})}):(0,Y.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-auto p-3`,children:(0,Y.jsxs)(`div`,{className:`grid min-w-[900px] gap-2`,style:{gridTemplateColumns:`9rem repeat(${Ff.length}, minmax(0, 1fr))`},children:[(0,Y.jsx)(`div`,{}),Ff.map(e=>(0,Y.jsx)(`div`,{className:`px-2 pb-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:t(`activity:board.status.${e.key}`)},e.key)),n.map(e=>(0,Y.jsxs)(Rf,{children:[(0,Y.jsx)(`div`,{className:`flex items-center pr-2`,children:(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.name}),(0,Y.jsx)(`span`,{className:X(`mt-0.5 inline-block rounded px-1.5 py-0.5 text-[10px] capitalize`,If[e.status]),children:e.status})]})}),Ff.map(t=>{let n=l.filter(n=>n.phaseId===e.id&&t.match.includes(n.status)),r=`cell:${e.id}:${t.key}`;return(0,Y.jsx)(`div`,{...b(r,()=>_(t.key)),className:X(`min-h-[4rem] space-y-2 rounded-md border p-1.5 transition-colors`,s===r?`border-primary/60 bg-primary/5`:`border-border bg-muted/20`),children:n.map(e=>(0,Y.jsx)(`div`,{...y(e.id),className:X(a===e.id&&`opacity-50`),children:(0,Y.jsx)(vf,{task:e,compact:!0,...v})},e.id))},t.key)})]},e.id))]})})]})}function Rf({children:e}){return(0,Y.jsx)(Y.Fragment,{children:e})}var zf=[`#3b82f6`,`#06b6d4`,`#22c55e`,`#eab308`,`#f97316`,`#a855f7`,`#ec4899`],Bf=e=>e.replace(/^wstack\/ap\//,``);function Vf(e){return[...e].sort((e,t)=>e.allocatedAt-t.allocatedAt).map((e,t)=>({handle:e,color:zf[t%zf.length],y:60+t*48}))}var Hf={allocating:{dash:`4 4`,opacity:.4},active:{dash:`4 4`,opacity:.6},committing:{dash:`4 4`,opacity:.8},merging:{dash:`0`,opacity:.9},merged:{dash:`0`,opacity:1},"needs-review":{dash:`2 3`,opacity:.9},failed:{dash:`2 3`,opacity:.6}};function Uf({worktrees:e,baseBranch:t}){let{t:n}=V(),r=Vf(e),i=Math.max(120,60+r.length*48+20);return(0,Y.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-[--color-border-dark] bg-[--color-card-dark]/40 p-3`,children:(0,Y.jsxs)(`svg`,{width:`100%`,height:i,viewBox:`0 0 600 ${i}`,className:`min-w-[420px]`,role:`img`,"aria-label":n(`activity:worktree.graphAria`,{base:t||`HEAD`}),children:[(0,Y.jsx)(`title`,{children:n(`activity:worktree.graphAria`,{base:t||`HEAD`})}),(0,Y.jsx)(`line`,{x1:40,y1:20,x2:40,y2:i-10,stroke:`#F93951`,strokeWidth:3}),(0,Y.jsx)(`text`,{x:36,y:14,fontSize:11,fill:`#9ca3af`,children:t||`HEAD`}),(0,Y.jsx)(`circle`,{cx:40,cy:20,r:5,fill:`#F93951`}),r.map(e=>{let r=Hf[e.handle.status]??Ur(Hf.active),i=e.handle.status===`merged`,a=e.handle.status===`needs-review`||e.handle.status===`failed`;return(0,Y.jsxs)(`g`,{className:`transition-all duration-500`,children:[(0,Y.jsx)(`path`,{d:`M 40 ${e.y-24} C 100 ${e.y-24}, 160 ${e.y}, 220 ${e.y}`,fill:`none`,stroke:e.color,strokeWidth:2,strokeDasharray:r.dash,opacity:r.opacity}),i?(0,Y.jsx)(`path`,{d:`M 220 ${e.y} C 160 ${e.y+20}, 100 ${e.y+24}, 40 ${e.y+24}`,fill:`none`,stroke:`#34d399`,strokeWidth:2,opacity:.9}):null,(0,Y.jsx)(`circle`,{cx:220,cy:e.y,r:5,fill:a?`#e879f9`:e.color}),(0,Y.jsx)(`text`,{x:232,y:e.y-6,fontSize:12,fill:`#e5e7eb`,fontFamily:`monospace`,children:Bf(e.handle.branch)}),(0,Y.jsx)(`text`,{x:232,y:e.y+10,fontSize:10,fill:`#9ca3af`,children:a?`⚠ ${e.handle.status}`:i?n(`activity:worktree.mergedLabel`,{base:t}):`+${e.handle.insertions}/-${e.handle.deletions} · ${e.handle.ownerLabel}`})]},e.handle.handleId)})]})})}var Wf={allocating:{icon:`○`,labelKey:`statusAllocating`,tint:`border-zinc-400/40`,dot:`bg-zinc-400`},active:{icon:`●`,labelKey:`statusActive`,tint:`border-amber-400/40`,dot:`bg-amber-400 animate-pulse`},committing:{icon:`◐`,labelKey:`statusCommitting`,tint:`border-cyan-400/40`,dot:`bg-cyan-400 animate-pulse`},merging:{icon:`⇡`,labelKey:`statusMerging`,tint:`border-blue-400/40`,dot:`bg-blue-400 animate-pulse`},merged:{icon:`✓`,labelKey:`statusMerged`,tint:`border-emerald-400/40`,dot:`bg-emerald-400`},"needs-review":{icon:`⚠`,labelKey:`statusConflict`,tint:`border-fuchsia-400/50`,dot:`bg-fuchsia-400`},failed:{icon:`✗`,labelKey:`statusFailed`,tint:`border-rose-400/50`,dot:`bg-rose-400`}};function Gf(e){return Wf[e]??{icon:`?`,labelKey:``,tint:`border-border`,dot:`bg-muted-foreground`}}var Kf=e=>e.replace(/^wstack\/ap\//,``);function qf({worktrees:e,baseBranch:t}){let{t:n}=V();if(e.length===0)return null;let r=[...e].sort((e,t)=>e.allocatedAt-t.allocatedAt);return(0,Y.jsxs)(`div`,{className:`rounded-lg border bg-card/50 backdrop-blur-sm px-3 py-3`,children:[(0,Y.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`font-semibold tracking-wide uppercase text-[10px]`,children:n(`activity:worktree.lanesHeading`)}),(0,Y.jsxs)(`span`,{className:`opacity-60`,children:[`· `,n(`activity:worktree.base`)]}),(0,Y.jsx)(`code`,{className:`font-mono text-primary`,children:t||`HEAD`}),(0,Y.jsxs)(`span`,{className:`opacity-60`,children:[`· `,n(`activity:worktree.isolatedCount`,{count:r.length})]})]}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:r.map(e=>{let t=Gf(e.status),r=e.status===`needs-review`,i=Math.min(100,e.insertions+e.deletions);return(0,Y.jsxs)(`div`,{className:X(`group relative flex items-center gap-3 rounded-lg border px-3 py-2 transition-all duration-500`,`bg-background/60 hover:bg-accent/20`,t.tint),children:[(0,Y.jsx)(`span`,{className:X(`h-2.5 w-2.5 shrink-0 rounded-full`,t.dot),"aria-hidden":!0}),(0,Y.jsx)(`code`,{className:`w-44 shrink-0 truncate font-mono text-sm`,children:Kf(e.branch)}),(0,Y.jsxs)(`span`,{className:`shrink-0 rounded bg-muted px-2 py-0.5 text-xs text-muted-foreground`,children:[`⟵ `,e.ownerLabel]}),r?(0,Y.jsx)(`span`,{className:`font-mono text-xs font-bold text-fuchsia-400`,children:n(`activity:worktree.conflictBadge`)}):(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 font-mono text-xs transition-all duration-500`,children:[(0,Y.jsxs)(`span`,{className:`text-emerald-500`,children:[`+`,e.insertions]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,Y.jsxs)(`span`,{className:`text-rose-500`,children:[`-`,e.deletions]}),(0,Y.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[e.files,`f`]})]}),(0,Y.jsx)(`div`,{className:`ml-auto hidden h-1 w-24 overflow-hidden rounded-full bg-muted sm:block`,children:(0,Y.jsx)(`div`,{className:`h-full bg-gradient-to-r from-emerald-500 to-rose-500 transition-all duration-700`,style:{width:`${i}%`}})}),(0,Y.jsx)(`span`,{className:`w-20 shrink-0 text-right text-xs text-muted-foreground`,children:t.labelKey?n(`activity:worktree.${t.labelKey}`):e.status}),e.recentActivity.length>0?(0,Y.jsxs)(`span`,{className:`absolute -bottom-2 left-9 max-w-[60%] truncate rounded bg-muted px-1.5 text-[10px] text-muted-foreground opacity-0 transition-opacity duration-300 group-hover:opacity-100`,children:[e.recentActivity[e.recentActivity.length-1]?.kind,`: `,e.recentActivity[e.recentActivity.length-1]?.text]}):null]},e.handleId)})})]})}var Jf=e=>e?e.replace(/^wstack\/ap\//,``):``;function Yf(){let{t:e}=V(),{client:t}=sd(),n=Es(e=>e.orphans),r=Es(e=>e.canClean),i=Es(e=>e.cleanBlockedReason),a=Es(e=>e.cleanResult),[o,s]=(0,U.useState)(!1);return(0,U.useEffect)(()=>{t?.send?.({type:`worktree.scan`})},[t]),(0,U.useEffect)(()=>{a&&s(!1)},[a]),n.length===0&&!a?null:(0,Y.jsxs)(`div`,{className:`rounded-md border border-amber-500/30 bg-amber-500/5 px-3 py-2 text-xs`,children:[n.length>0?(0,Y.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Y.jsx)(gt,{className:`mt-0.5 h-4 w-4 shrink-0 text-amber-500`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`font-medium text-amber-700 dark:text-amber-300`,children:e(`activity:worktree.orphanCount`,{count:n.length})}),(0,Y.jsxs)(`div`,{className:`mt-0.5 max-h-16 overflow-auto font-mono text-[10px] text-muted-foreground`,children:[n.slice(0,8).map((e,t)=>(0,Y.jsxs)(`div`,{className:`truncate`,children:[e.kind===`branch`?`⌥ `:`▢ `,Jf(e.branch)||e.dir]},`${e.kind}-${e.branch??e.dir??t}`)),n.length>8&&(0,Y.jsx)(`div`,{children:e(`activity:worktree.andMore`,{count:n.length-8})})]})]}),(0,Y.jsxs)(`button`,{type:`button`,disabled:!r||o,onClick:async()=>{let r=n.length;await Af({title:e(`activity:worktree.cleanTitle`,{count:r}),message:e(`activity:worktree.cleanMessage`),confirmLabel:e(`activity:worktree.cleanConfirm`),danger:!0})&&(s(!0),t?.send?.({type:`worktree.cleanup`}))},title:r?e(`activity:worktree.cleanButtonTitle`):i,className:`inline-flex shrink-0 items-center gap-1 rounded bg-amber-600/90 px-2 py-1 font-medium text-white hover:bg-amber-700 disabled:cursor-not-allowed disabled:opacity-50`,children:[o?(0,Y.jsx)(B,{className:`h-3.5 w-3.5 animate-spin`}):(0,Y.jsx)(en,{className:`h-3.5 w-3.5`}),e(`activity:worktree.cleanConfirm`)]})]}):null,a&&(0,Y.jsx)(`div`,{className:a.ok?`mt-1 text-emerald-600 dark:text-emerald-400`:`mt-1 text-rose-500`,children:a.ok?e(`activity:worktree.removed`,{count:a.removed}):`✗ ${a.reason??e(`activity:worktree.cleanupFailed`)}`})]})}function Xf({onClose:e}){let{client:t}=sd(),{t:n}=V(),r=ec(e=>e.phases),i=ec(e=>e.overallPercent),o=ec(e=>e.autonomous),s=ec(e=>e.title),c=ec(e=>e.goal),l=ec(e=>e.status),u=ec(e=>e.lastError),d=ec(e=>e.graphs);(0,U.useEffect)(()=>{t?.send?.({type:`autophase.list`})},[t]);let f=Es(e=>e.worktrees),p=Es(e=>e.baseBranch),[m,h]=(0,U.useState)(``),[g,_]=(0,U.useState)(null),[v,y]=(0,U.useState)(!1),[x,S]=(0,U.useState)(!0),C=r.length>0,w=g!=null&&!C;(0,U.useEffect)(()=>{C&&_(null)},[C]);let T=(0,U.useCallback)(()=>{let e=m.trim();if(!e||g!=null)return;let n=G.getState();n.addMessage({role:`user`,content:e}),n.addMessage({role:`assistant`,content:b.t(`activity:autoPhase.planningAck`)}),_(e),h(``),t?.send?.({type:`autophase.start`,payload:{title:e,autonomous:!0,worktrees:x}})},[m,g,t,x]),E=(0,U.useCallback)(()=>{t?.send?.({type:`autophase.stop`,payload:{}}),_(null)},[t]),D=(0,U.useCallback)(()=>{t?.send?.({type:`autophase.toggleAutonomous`,payload:{}})},[t]),O=(0,U.useCallback)(()=>{t?.send?.(l===`paused`?{type:`autophase.resume`,payload:{}}:{type:`autophase.pause`,payload:{}})},[t,l]),k=(0,U.useCallback)(()=>{t?.send?.({type:`autophase.stop`,payload:{}})},[t]),A=(0,U.useCallback)(()=>{t?.send?.({type:`autophase.clear`,payload:{}}),ec.getState().clear(),_(null),h(``)},[t]),[j,M]=(0,U.useState)(!1),N=(0,U.useCallback)(()=>{t?.send?.({type:`autophase.revert`,payload:{}}),M(!1)},[t]),P=l===`running`||l===`paused`,F=l===`stopped`||l===`completed`||l===`failed`,I=(0,U.useCallback)(e=>{e&&t?.send?.({type:`autophase.load`,payload:{graphId:e}})},[t]);return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,Y.jsxs)(`header`,{className:`flex items-center justify-between px-4 py-2 border-b bg-card shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(nr,{className:`h-5 w-5 text-muted-foreground`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h1`,{className:`text-lg font-semibold`,children:C&&s||`AutoPhase`}),C&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`activity:autoPhase.summary`,{count:r.length,pct:i})})]}),C&&(0,Y.jsx)(`span`,{className:X(`rounded border px-2 py-0.5 text-[11px] font-medium capitalize`,l===`failed`?`border-destructive/40 bg-destructive/10 text-destructive`:l===`paused`||l===`stopped`?`border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300`:l===`completed`?`border-green-500/40 bg-green-500/10 text-green-700 dark:text-green-300`:`border-primary/30 bg-primary/10 text-primary`),title:u??void 0,children:l})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[d.length>0&&(0,Y.jsxs)(`select`,{value:C?d.find(e=>e.title===s)?.id??``:``,onChange:e=>I(e.target.value),title:n(`activity:autoPhase.switchBoard`),className:`rounded border border-border bg-card px-2 py-1 text-xs text-foreground`,children:[(0,Y.jsx)(`option`,{value:``,disabled:!0,children:n(`activity:autoPhase.boardsCount`,{count:d.length})}),d.map(e=>(0,Y.jsxs)(`option`,{value:e.id,children:[e.title,` · `,e.status]},e.id))]}),C&&(0,Y.jsxs)(`button`,{type:`button`,onClick:D,title:n(`activity:autoPhase.toggleAutonomousTitle`),className:X(`inline-flex items-center gap-1 rounded border px-2 py-1 text-xs transition-colors`,o?`border-primary/30 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:text-foreground`),children:[(0,Y.jsx)(tn,{className:`h-3.5 w-3.5`}),` `,n(o?`activity:autoPhase.autonomous`:`activity:autoPhase.manual`)]}),P&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:O,title:n(l===`paused`?`activity:autoPhase.resumeTitle`:`activity:autoPhase.pauseTitle`),className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-xs text-muted-foreground transition-colors hover:text-foreground`,children:[l===`paused`?(0,Y.jsx)(kt,{className:`h-3.5 w-3.5`}):(0,Y.jsx)(kn,{className:`h-3.5 w-3.5`}),n(l===`paused`?`activity:autoPhase.resume`:`activity:autoPhase.pause`)]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:k,title:n(`activity:autoPhase.stopTitle`),className:`inline-flex items-center gap-1 rounded border border-destructive/40 bg-destructive/10 px-2 py-1 text-xs font-medium text-destructive transition-colors hover:bg-destructive/20`,children:[(0,Y.jsx)(ae,{className:`h-3.5 w-3.5 fill-current`}),` `,n(`activity:autoPhase.stop`)]})]}),C&&F&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:A,title:n(`activity:autoPhase.newTitle`),className:`inline-flex items-center gap-1 rounded border border-primary/30 bg-primary/10 px-2 py-1 text-xs font-medium text-primary transition-colors hover:bg-primary/20`,children:[(0,Y.jsx)(hn,{className:`h-3.5 w-3.5`}),` `,n(`activity:autoPhase.newLabel`)]}),j?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-amber-500/40 bg-amber-500/10 px-1.5 py-0.5 text-xs`,children:[(0,Y.jsx)(`span`,{className:`text-amber-700 dark:text-amber-300`,children:n(`activity:autoPhase.revertConfirm`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:N,className:`rounded bg-destructive/15 px-1.5 py-0.5 font-medium text-destructive hover:bg-destructive/25`,children:n(`common:action.yes`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>M(!1),className:`rounded px-1.5 py-0.5 text-muted-foreground hover:text-foreground`,children:n(`common:action.no`)})]}):(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>M(!0),title:n(`activity:autoPhase.revertTitle`),className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-xs text-muted-foreground transition-colors hover:text-foreground`,children:[(0,Y.jsx)(kr,{className:`h-3.5 w-3.5`}),` `,n(`activity:autoPhase.revert`)]})]}),(0,Y.jsx)($,{variant:`ghost`,size:`icon`,onClick:e,children:(0,Y.jsx)(Xn,{className:`h-4 w-4`})})]})]}),C&&c&&(0,Y.jsxs)(`div`,{className:`shrink-0 border-b border-border/60 bg-muted/20 px-4 py-2.5`,children:[(0,Y.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,Y.jsx)(a,{className:`h-3 w-3`}),` `,n(`activity:autoPhase.goal`)]}),(0,Y.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:c})]}),C?(0,Y.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,Y.jsx)(Lf,{})}):w?(0,Y.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-8`,children:(0,Y.jsxs)(`div`,{className:`max-w-lg w-full space-y-5 text-center`,children:[(0,Y.jsx)(B,{className:`h-10 w-10 mx-auto animate-spin text-primary/70`}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(`h2`,{className:`text-xl font-semibold`,children:n(`activity:autoPhase.planning`)}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`activity:autoPhase.planningBody`)})]}),(0,Y.jsxs)(`div`,{className:`rounded-lg border border-border bg-card px-4 py-3 text-left`,children:[(0,Y.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,Y.jsx)(a,{className:`h-3 w-3`}),` `,n(`activity:autoPhase.goal`)]}),(0,Y.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:g})]}),(0,Y.jsxs)($,{variant:`outline`,onClick:E,className:`gap-2`,children:[(0,Y.jsx)(ae,{className:`h-4 w-4 fill-current`}),` `,n(`common:action.cancel`)]})]})}):(0,Y.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-8`,children:(0,Y.jsxs)(`div`,{className:`max-w-lg w-full space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,Y.jsx)(a,{className:`h-10 w-10 mx-auto text-primary/60`}),(0,Y.jsx)(`h2`,{className:`text-xl font-semibold`,children:n(`activity:autoPhase.startHeading`)}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`activity:autoPhase.startBody`)})]}),(0,Y.jsx)(`textarea`,{value:m,onChange:e=>h(e.target.value),placeholder:n(`activity:autoPhase.startPlaceholder`),rows:5,className:`w-full rounded-lg border border-border bg-card px-4 py-3 text-sm resize-none focus:outline-none focus:ring-2 focus:ring-primary/30 placeholder:text-muted-foreground/50`,onKeyDown:e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),T())}}),(0,Y.jsxs)(`label`,{className:`flex cursor-pointer items-center justify-center gap-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked),className:`h-3.5 w-3.5 accent-primary`}),n(`activity:autoPhase.isolateLabel`)]}),(0,Y.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,Y.jsxs)($,{onClick:T,disabled:!m.trim(),className:`flex-1 gap-2`,children:[(0,Y.jsx)(kt,{className:`h-4 w-4`}),n(`activity:autoPhase.startButton`)]})}),(0,Y.jsxs)(`p`,{className:`text-xs text-muted-foreground text-center`,children:[n(`activity:autoPhase.ctrlHint`),` ·`,` `,n(x?`activity:autoPhase.isolateOn`:`activity:autoPhase.isolateOff`)]})]})}),f.length>0&&(0,Y.jsxs)(`div`,{className:`border-t bg-card/50 shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-4 pt-2 text-xs`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>y(!1),className:X(`rounded px-2 py-0.5 border transition-colors`,v?`border-border text-muted-foreground hover:text-foreground`:`bg-primary/10 border-primary/30 text-primary`),children:n(`activity:autoPhase.lanes`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>y(!0),className:X(`rounded px-2 py-0.5 border transition-colors`,v?`bg-primary/10 border-primary/30 text-primary`:`border-border text-muted-foreground hover:text-foreground`),children:n(`activity:autoPhase.graph`)})]}),(0,Y.jsxs)(`div`,{className:`space-y-2 px-4 pb-3`,children:[(0,Y.jsx)(Yf,{}),v?(0,Y.jsx)(Uf,{worktrees:f,baseBranch:p}):(0,Y.jsx)(qf,{worktrees:f,baseBranch:p})]})]})]})}var Zf=(0,U.memo)(function({oldText:e,newText:t,caption:n,fill:r}){let{t:i}=V(),a=(0,U.useMemo)(()=>$f(e,t),[e,t]);if(a===null)return(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2`,children:i(`activity:diff.tooLarge`)});let o=a.filter(e=>e.kind===`add`).length,s=a.filter(e=>e.kind===`del`).length;return(0,Y.jsxs)(`div`,{className:X(`rounded-lg border bg-background/40 overflow-hidden text-xs`,r&&`flex h-full min-h-0 min-w-0 flex-col`),children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 border-b bg-muted/40 shrink-0`,children:[(0,Y.jsx)(`span`,{className:`font-mono text-muted-foreground truncate`,children:n??`diff`}),(0,Y.jsxs)(`span`,{className:`font-mono shrink-0`,children:[(0,Y.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-400`,children:[`+`,o]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground mx-1 opacity-50`,children:`·`}),(0,Y.jsxs)(`span`,{className:`text-rose-600 dark:text-rose-400`,children:[`-`,s]})]})]}),(0,Y.jsx)(`div`,{className:X(`font-mono leading-relaxed overflow-auto`,r?`min-h-0 flex-1`:`max-h-96`),children:a.map((e,t)=>(0,Y.jsxs)(`div`,{className:X(`flex`,e.kind===`add`&&`bg-emerald-500/10`,e.kind===`del`&&`bg-rose-500/10`),children:[(0,Y.jsx)(`span`,{className:X(`w-6 shrink-0 text-center select-none`,e.kind===`add`&&`text-emerald-600 dark:text-emerald-400`,e.kind===`del`&&`text-rose-600 dark:text-rose-400`,e.kind===`ctx`&&`text-muted-foreground/40`),children:e.kind===`add`?`+`:e.kind===`del`?`-`:` `}),(0,Y.jsx)(`pre`,{className:X(`whitespace-pre-wrap break-all flex-1 px-2`,e.kind===`ctx`&&`text-muted-foreground/70`),children:e.text||`\xA0`})]},t))})]})}),Qf=5e3;function $f(e,t){let n=e.split(`
45
- `),r=t.split(`
46
- `);if(n.length>Qf||r.length>Qf)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--)n[e]===r[t]?Ur(o[e])[t]=Ur(o[e+1]?.[t+1])+1:Ur(o[e])[t]=Math.max(Ur(o[e+1]?.[t]),Ur(o[e]?.[t+1]));let s=[],c=0,l=0;for(;c<i&&l<a;)n[c]===r[l]?(s.push({kind:`ctx`,text:Ur(n[c])}),c++,l++):Ur(o[c+1]?.[l])>=Ur(o[c]?.[l+1])?(s.push({kind:`del`,text:Ur(n[c])}),c++):(s.push({kind:`add`,text:Ur(r[l])}),l++);for(;c<i;)s.push({kind:`del`,text:Ur(n[c++])});for(;l<a;)s.push({kind:`add`,text:Ur(r[l++])});return s}function ep(e,t){if(!e||typeof t!=`object`||!t)return null;let n=t,r=String(n.file_path??n.path??``);switch(e){case`edit`:case`str_replace`:case`edit_file`:{let e=typeof n.old_string==`string`?n.old_string:``,t=typeof n.new_string==`string`?n.new_string:``;return!e&&!t?null:{oldText:e,newText:t,caption:`edit ${r}`}}case`write`:case`write_file`:case`create_file`:return{oldText:``,newText:typeof n.content==`string`?n.content:``,caption:`write ${r} (new)`};default:return null}}ne.defineTheme(`wrongstack-dark`,{base:`vs-dark`,inherit:!0,rules:[{token:`comment`,foreground:`6e717a`,fontStyle:`italic`},{token:`comment.line`,foreground:`6e717a`,fontStyle:`italic`},{token:`comment.block`,foreground:`6e717a`,fontStyle:`italic`},{token:`comment.documentation`,foreground:`6e717a`,fontStyle:`italic`},{token:`string`,foreground:`64d488`},{token:`string.escape`,foreground:`49d3c5`},{token:`string.template`,foreground:`64d488`},{token:`number`,foreground:`f2a23a`},{token:`number.hex`,foreground:`f2a23a`},{token:`number.float`,foreground:`f2a23a`},{token:`keyword`,foreground:`f28dbc`},{token:`keyword.control`,foreground:`f28dbc`},{token:`keyword.operator`,foreground:`9ea0a8`},{token:`type`,foreground:`6cb6ff`},{token:`type.identifier`,foreground:`6cb6ff`},{token:`type.parameter`,foreground:`eeede7`},{token:`function`,foreground:`6cb6ff`},{token:`predefined`,foreground:`6cb6ff`},{token:`variable`,foreground:`eeede7`},{token:`variable.parameter`,foreground:`f2a23a`},{token:`variable.readonly`,foreground:`f2a23a`},{token:`variable.language`,foreground:`f28dbc`},{token:`tag`,foreground:`f47a95`},{token:`metatag`,foreground:`f47a95`},{token:`tag.html`,foreground:`f47a95`},{token:`tag.jsx`,foreground:`f47a95`},{token:`tag.tsx`,foreground:`f47a95`},{token:`attribute.name`,foreground:`ffb055`},{token:`attribute.value`,foreground:`64d488`},{token:`attribute.name.html`,foreground:`ffb055`},{token:`attribute.name.jsx`,foreground:`ffb055`},{token:`regexp`,foreground:`49d3c5`},{token:`delimiter`,foreground:`9ea0a8`},{token:`delimiter.bracket`,foreground:`9ea0a8`},{token:`delimiter.parenthesis`,foreground:`9ea0a8`},{token:`delimiter.curly`,foreground:`9ea0a8`},{token:`delimiter.square`,foreground:`9ea0a8`},{token:`delimiter.array`,foreground:`9ea0a8`},{token:`operator`,foreground:`9ea0a8`},{token:`constant`,foreground:`f2a23a`},{token:`constant.language`,foreground:`f28dbc`},{token:`support`,foreground:`6cb6ff`},{token:`support.function`,foreground:`6cb6ff`},{token:`support.type`,foreground:`6cb6ff`},{token:`support.constant`,foreground:`f2a23a`},{token:`support.variable`,foreground:`eeede7`},{token:`storage`,foreground:`f28dbc`},{token:`storage.modifier`,foreground:`f28dbc`},{token:`storage.type`,foreground:`6cb6ff`},{token:`entity.name.type`,foreground:`6cb6ff`},{token:`entity.name.function`,foreground:`6cb6ff`},{token:`entity.other.inherited-class`,foreground:`6cb6ff`},{token:`entity.name.tag`,foreground:`f47a95`},{token:`entity.other.attribute-name`,foreground:`ffb055`},{token:`invalid`,foreground:`d63c3c`},{token:`invalid.deprecated`,foreground:`d63c3c`},{token:`emphasis`,fontStyle:`italic`},{token:`strong`,fontStyle:`bold`},{token:`header`,foreground:`6cb6ff`,fontStyle:`bold`},{token:`link`,foreground:`49d3c5`,fontStyle:`underline`},{token:`class`,foreground:`6cb6ff`},{token:`interface`,foreground:`49d3c5`},{token:`enum`,foreground:`f2a23a`},{token:`enumMember`,foreground:`f2a23a`},{token:`typeParameter`,foreground:`f2a23a`},{token:`namespace`,foreground:`6cb6ff`},{token:`method`,foreground:`6cb6ff`},{token:`property`,foreground:`eeede7`},{token:`property.readonly`,foreground:`f2a23a`},{token:`property.static`,foreground:`eeede7`},{token:`parameter`,foreground:`f2a23a`},{token:`variable.defaultLibrary`,foreground:`6cb6ff`},{token:`function.defaultLibrary`,foreground:`6cb6ff`},{token:`macro`,foreground:`c4a0ff`},{token:`decorator`,foreground:`c4a0ff`},{token:`label`,foreground:`f2a23a`},{token:`comment.deprecated`,foreground:`6e717a`,fontStyle:`italic strikethrough`},{token:`variable.deprecated`,foreground:`6e717a`,fontStyle:`strikethrough`}],colors:{"editor.background":`#121318`,"editor.foreground":`#eeede7`,"editorCursor.foreground":`#f2a23a`,"editor.selectionBackground":`#f2a23a25`,"editor.selectionHighlightBackground":`#f2a23a15`,"editor.inactiveSelectionBackground":`#f2a23a10`,"editor.lineHighlightBackground":`#1a1c23`,"editorLineNumber.foreground":`#4a4d55`,"editorLineNumber.activeForeground":`#9ea0a8`,"editorRuler.foreground":`#1e2028`,"editorBracketMatch.background":`#f2a23a15`,"editorBracketMatch.border":`#f2a23a30`,"editor.findMatchBackground":`#f2a23a30`,"editor.findMatchHighlightBackground":`#f2a23a15`,"editorWidget.background":`#1a1c23`,"editorWidget.border":`#262830`,"editorSuggestWidget.background":`#1a1c23`,"editorSuggestWidget.border":`#262830`,"editorSuggestWidget.selectedBackground":`#262830`,"editorHoverWidget.background":`#1a1c23`,"editorHoverWidget.border":`#262830`,"scrollbar.shadow":`#00000000`,"scrollbarSlider.background":`#4a4d5530`,"scrollbarSlider.hoverBackground":`#f2a23a50`,"scrollbarSlider.activeBackground":`#f2a23a70`,"minimap.background":`#121318`,"diffEditor.insertedTextBackground":`#64d48815`,"diffEditor.removedTextBackground":`#d63c3c15`,"sideBar.background":`#121318`,"sideBar.border":`#1e2028`,"input.background":`#1a1c23`,"input.border":`#262830`,"input.foreground":`#eeede7`,"input.placeholderForeground":`#6e717a`,focusBorder:`#f2a23a40`,"list.activeSelectionBackground":`#262830`,"list.hoverBackground":`#1e2028`,"dropdown.background":`#1a1c23`,"dropdown.border":`#262830`,"badge.background":`#f2a23a`,"badge.foreground":`#1a1208`,"editorBracketHighlighting.foreground1":`#f2a23a`,"editorBracketHighlighting.foreground2":`#6cb6ff`,"editorBracketHighlighting.foreground3":`#f28dbc`,"editorBracketHighlighting.foreground4":`#64d488`,"editorBracketHighlighting.foreground5":`#49d3c5`,"editorBracketHighlighting.foreground6":`#c4a0ff`,"editorBracketPairGuide.background1":`#f2a23a18`,"editorBracketPairGuide.background2":`#6cb6ff18`,"editorBracketPairGuide.background3":`#f28dbc18`,"editorBracketPairGuide.background4":`#64d48818`,"editorBracketPairGuide.background5":`#49d3c518`,"editorBracketPairGuide.background6":`#c4a0ff18`,"editorBracketPairGuide.activeBackground1":`#f2a23a30`,"editorBracketPairGuide.activeBackground2":`#6cb6ff30`,"editorBracketPairGuide.activeBackground3":`#f28dbc30`,"editorBracketPairGuide.activeBackground4":`#64d48830`,"editorBracketPairGuide.activeBackground5":`#49d3c530`,"editorBracketPairGuide.activeBackground6":`#c4a0ff30`}}),ne.defineTheme(`wrongstack-light`,{base:`vs`,inherit:!0,rules:[{token:`comment`,foreground:`9a9d99`,fontStyle:`italic`},{token:`comment.line`,foreground:`9a9d99`,fontStyle:`italic`},{token:`comment.block`,foreground:`9a9d99`,fontStyle:`italic`},{token:`comment.documentation`,foreground:`9a9d99`,fontStyle:`italic`},{token:`string`,foreground:`3b8c5a`},{token:`string.escape`,foreground:`17998e`},{token:`string.template`,foreground:`3b8c5a`},{token:`number`,foreground:`d97a12`},{token:`number.hex`,foreground:`d97a12`},{token:`number.float`,foreground:`d97a12`},{token:`keyword`,foreground:`d65a9a`},{token:`keyword.control`,foreground:`d65a9a`},{token:`keyword.operator`,foreground:`6b6d72`},{token:`type`,foreground:`3178c6`},{token:`type.identifier`,foreground:`3178c6`},{token:`type.parameter`,foreground:`1a1c23`},{token:`function`,foreground:`3178c6`},{token:`predefined`,foreground:`3178c6`},{token:`variable`,foreground:`1a1c23`},{token:`variable.parameter`,foreground:`d97a12`},{token:`variable.readonly`,foreground:`d97a12`},{token:`variable.language`,foreground:`d65a9a`},{token:`tag`,foreground:`c93a5e`},{token:`metatag`,foreground:`c93a5e`},{token:`tag.html`,foreground:`c93a5e`},{token:`tag.jsx`,foreground:`c93a5e`},{token:`tag.tsx`,foreground:`c93a5e`},{token:`attribute.name`,foreground:`d4893a`},{token:`attribute.value`,foreground:`3b8c5a`},{token:`attribute.name.html`,foreground:`d4893a`},{token:`attribute.name.jsx`,foreground:`d4893a`},{token:`regexp`,foreground:`17998e`},{token:`delimiter`,foreground:`6b6d72`},{token:`delimiter.bracket`,foreground:`6b6d72`},{token:`delimiter.parenthesis`,foreground:`6b6d72`},{token:`delimiter.curly`,foreground:`6b6d72`},{token:`delimiter.square`,foreground:`6b6d72`},{token:`delimiter.array`,foreground:`6b6d72`},{token:`operator`,foreground:`6b6d72`},{token:`constant`,foreground:`d97a12`},{token:`constant.language`,foreground:`d65a9a`},{token:`support`,foreground:`3178c6`},{token:`support.function`,foreground:`3178c6`},{token:`support.type`,foreground:`3178c6`},{token:`support.constant`,foreground:`d97a12`},{token:`support.variable`,foreground:`1a1c23`},{token:`storage`,foreground:`d65a9a`},{token:`storage.modifier`,foreground:`d65a9a`},{token:`storage.type`,foreground:`3178c6`},{token:`entity.name.type`,foreground:`3178c6`},{token:`entity.name.function`,foreground:`3178c6`},{token:`entity.other.inherited-class`,foreground:`3178c6`},{token:`entity.name.tag`,foreground:`c93a5e`},{token:`entity.other.attribute-name`,foreground:`d4893a`},{token:`invalid`,foreground:`d63c3c`},{token:`invalid.deprecated`,foreground:`d63c3c`},{token:`emphasis`,fontStyle:`italic`},{token:`strong`,fontStyle:`bold`},{token:`header`,foreground:`3178c6`,fontStyle:`bold`},{token:`link`,foreground:`17998e`,fontStyle:`underline`},{token:`class`,foreground:`3178c6`},{token:`interface`,foreground:`17998e`},{token:`enum`,foreground:`d97a12`},{token:`enumMember`,foreground:`d97a12`},{token:`typeParameter`,foreground:`d97a12`},{token:`namespace`,foreground:`3178c6`},{token:`method`,foreground:`3178c6`},{token:`property`,foreground:`1a1c23`},{token:`property.readonly`,foreground:`d97a12`},{token:`property.static`,foreground:`1a1c23`},{token:`parameter`,foreground:`d97a12`},{token:`variable.defaultLibrary`,foreground:`3178c6`},{token:`function.defaultLibrary`,foreground:`3178c6`},{token:`macro`,foreground:`8b5cf6`},{token:`decorator`,foreground:`8b5cf6`},{token:`label`,foreground:`d97a12`},{token:`comment.deprecated`,foreground:`9a9d99`,fontStyle:`italic strikethrough`},{token:`variable.deprecated`,foreground:`9a9d99`,fontStyle:`strikethrough`}],colors:{"editor.background":`#f7f7f5`,"editor.foreground":`#1a1c23`,"editorCursor.foreground":`#e07b0e`,"editor.selectionBackground":`#e07b0e18`,"editor.selectionHighlightBackground":`#e07b0e10`,"editor.inactiveSelectionBackground":`#e07b0e08`,"editor.lineHighlightBackground":`#f0efe9`,"editorLineNumber.foreground":`#bab8b0`,"editorLineNumber.activeForeground":`#6b6d72`,"editorRuler.foreground":`#e8e6de`,"editorBracketMatch.background":`#e07b0e12`,"editorBracketMatch.border":`#e07b0e25`,"editor.findMatchBackground":`#e07b0e25`,"editor.findMatchHighlightBackground":`#e07b0e12`,"editorWidget.background":`#f7f7f5`,"editorWidget.border":`#ddd9d0`,"editorSuggestWidget.background":`#f7f7f5`,"editorSuggestWidget.border":`#ddd9d0`,"editorSuggestWidget.selectedBackground":`#eeece2`,"editorHoverWidget.background":`#f7f7f5`,"editorHoverWidget.border":`#ddd9d0`,"scrollbar.shadow":`#00000000`,"scrollbarSlider.background":`#bab8b040`,"scrollbarSlider.hoverBackground":`#e07b0e50`,"scrollbarSlider.activeBackground":`#e07b0e70`,"minimap.background":`#f7f7f5`,"diffEditor.insertedTextBackground":`#3b8c5a12`,"diffEditor.removedTextBackground":`#d63c3c12`,"sideBar.background":`#f7f7f5`,"sideBar.border":`#e8e6de`,"input.background":`#ffffff`,"input.border":`#ddd9d0`,"input.foreground":`#1a1c23`,"input.placeholderForeground":`#9a9d99`,focusBorder:`#e07b0e35`,"list.activeSelectionBackground":`#eeece2`,"list.hoverBackground":`#f0efe9`,"dropdown.background":`#ffffff`,"dropdown.border":`#ddd9d0`,"badge.background":`#e07b0e`,"badge.foreground":`#ffffff`,"editorBracketHighlighting.foreground1":`#d97a12`,"editorBracketHighlighting.foreground2":`#3178c6`,"editorBracketHighlighting.foreground3":`#d65a9a`,"editorBracketHighlighting.foreground4":`#3b8c5a`,"editorBracketHighlighting.foreground5":`#17998e`,"editorBracketHighlighting.foreground6":`#8b5cf6`,"editorBracketPairGuide.background1":`#d97a1215`,"editorBracketPairGuide.background2":`#3178c615`,"editorBracketPairGuide.background3":`#d65a9a15`,"editorBracketPairGuide.background4":`#3b8c5a15`,"editorBracketPairGuide.background5":`#17998e15`,"editorBracketPairGuide.background6":`#8b5cf615`,"editorBracketPairGuide.activeBackground1":`#d97a1228`,"editorBracketPairGuide.activeBackground2":`#3178c628`,"editorBracketPairGuide.activeBackground3":`#d65a9a28`,"editorBracketPairGuide.activeBackground4":`#3b8c5a28`,"editorBracketPairGuide.activeBackground5":`#17998e28`,"editorBracketPairGuide.activeBackground6":`#8b5cf628`}});function tp(){return typeof document>`u`||document.documentElement.classList.contains(`dark`)?`wrongstack-dark`:`wrongstack-light`}u.config({monaco:xe});var np={ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,json:`json`,css:`css`,scss:`scss`,html:`html`,md:`markdown`,py:`python`,go:`go`,rs:`rust`,java:`java`,c:`c`,cpp:`cpp`,cs:`csharp`,rb:`ruby`,php:`php`,sh:`shell`,bash:`shell`,yml:`yaml`,yaml:`yaml`,toml:`toml`,sql:`sql`};function rp(e){return np[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function ip({path:e,oldText:t,newText:n}){let{t:r}=V(),i=(0,U.useRef)(null),[a,o]=(0,U.useState)(!1),[s,c]=(0,U.useState)(!1),[l,u]=(0,U.useState)(null);(0,U.useEffect)(()=>{o(!1),c(!1),u(null)},[]);let d=(0,U.useCallback)(e=>{i.current=e,ne.setTheme(tp()),e.getModifiedEditor().onDidChangeModelContent(()=>o(!0))},[]),f=(0,U.useCallback)(()=>{let t=i.current?.getModifiedEditor().getValue();if(t==null)return;c(!0);let n=W(K.getState().wsUrl),r=n.on(`files.written`,t=>{t.type===`files.written`&&t.payload.filePath===e&&(r(),clearTimeout(a),c(!1),t.payload.success&&(o(!1),u(Date.now())))}),a=setTimeout(()=>{r(),c(!1)},5e3);n.send({type:`files.write`,payload:{filePath:e,content:t}})},[e]),p=rp(e);return(0,Y.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2 px-2 py-1.5 border-b border-border/40`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground truncate`,children:e}),(0,Y.jsxs)(`button`,{type:`button`,onClick:f,disabled:!a||s,className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md border border-border text-xs font-medium disabled:opacity-40 enabled:hover:bg-muted transition-colors`,title:r(`activity:monacoDiff.applyTitle`),children:[s?(0,Y.jsx)(B,{className:`h-3.5 w-3.5 animate-spin`}):l&&!a?(0,Y.jsx)(z,{className:`h-3.5 w-3.5 text-emerald-500`}):(0,Y.jsx)(pt,{className:`h-3.5 w-3.5`}),r(s?`activity:monacoDiff.applying`:l&&!a?`activity:monacoDiff.applied`:`activity:monacoDiff.apply`)]})]}),(0,Y.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,Y.jsx)(zr,{original:t,modified:n,language:p,theme:tp(),onMount:d,options:{renderSideBySide:!0,readOnly:!1,originalEditable:!1,minimap:{enabled:!1},fontSize:13,scrollBeyondLastLine:!1,automaticLayout:!0}})})]})}function ap({className:e}){let{t}=V(),n=ws(e=>e.selectedPath),r=ws(e=>e.diff),i=ws(e=>e.loadingDiff),[a,o]=(0,U.useState)(`unified`);if(!n)return(0,Y.jsxs)(`div`,{className:X(`flex min-h-0 min-w-0 flex-1 flex-col items-center justify-center gap-3 text-muted-foreground`,e),children:[(0,Y.jsx)(lr,{className:`h-10 w-10 opacity-30`}),(0,Y.jsx)(`p`,{className:`text-sm`,children:t(`activity:changes.selectPrompt`)})]});let s=r&&!r.error&&!r.binary&&!r.tooLarge;return(0,Y.jsxs)(`div`,{className:X(`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden p-3`,e),children:[s&&(0,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-1 pb-2`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>o(`unified`),title:t(`activity:changes.unifiedTitle`),className:X(`inline-flex items-center gap-1 h-7 px-2 rounded-md border text-xs transition-colors`,a===`unified`?`border-primary/40 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-muted`),children:[(0,Y.jsx)(Ie,{className:`h-3.5 w-3.5`}),` `,t(`activity:changes.unified`)]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>o(`edit`),title:t(`activity:changes.editTitle`),className:X(`inline-flex items-center gap-1 h-7 px-2 rounded-md border text-xs transition-colors`,a===`edit`?`border-primary/40 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-muted`),children:[(0,Y.jsx)(Qt,{className:`h-3.5 w-3.5`}),` `,t(`activity:changes.edit`)]})]}),i||!r?(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,Y.jsx)(B,{className:`h-4 w-4 animate-spin`}),` `,t(`activity:changes.loadingDiff`)]}):r.error?(0,Y.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-rose-500`,children:r.error}):r.binary?(0,Y.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground`,children:t(`activity:changes.binary`)}):r.tooLarge?(0,Y.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground`,children:t(`activity:changes.tooLarge`)}):a===`edit`?(0,Y.jsx)(ip,{path:r.path,oldText:r.oldText??``,newText:r.newText??``},r.path):(0,Y.jsx)(Zf,{oldText:r.oldText,newText:r.newText,caption:r.path,fill:!0})]})}var op=[{mode:`off`,label:`Off`,descKey:`descOff`,icon:(0,Y.jsx)(kn,{className:`h-3.5 w-3.5`})},{mode:`suggest`,label:`Suggest`,descKey:`descSuggest`,icon:(0,Y.jsx)(ee,{className:`h-3.5 w-3.5`})},{mode:`auto`,label:`Auto`,descKey:`descAuto`,icon:(0,Y.jsx)(kt,{className:`h-3.5 w-3.5`})},{mode:`eternal`,label:`Eternal`,descKey:`descEternal`,icon:(0,Y.jsx)($n,{className:`h-3.5 w-3.5`})},{mode:`eternal-parallel`,label:`Eternal Parallel`,descKey:`descEternalParallel`,icon:(0,Y.jsx)($n,{className:`h-3.5 w-3.5`})}];function sp({value:e,onChange:t,className:n,compact:r=!1}){let{t:i}=V(),[a,o]=(0,U.useState)(!1),s=(0,U.useRef)(null);(0,U.useEffect)(()=>{if(!a)return;let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[a]),(0,U.useEffect)(()=>{if(!a)return;let e=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]);let c=op.find(t=>t.mode===e);return(0,Y.jsxs)(`div`,{ref:s,className:`relative`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:X(`flex items-center gap-1 px-2 py-0.5 rounded-md border text-[11px] font-medium transition-colors hover:opacity-80`,e===`eternal`||e===`eternal-parallel`?`bg-rose-500/15 text-rose-600 dark:text-rose-400 border-rose-500/30`:e===`auto`?`bg-amber-500/15 text-amber-600 dark:text-amber-400 border-amber-500/30`:e===`suggest`?`bg-blue-500/15 text-blue-600 dark:text-blue-400 border-blue-500/30`:`bg-muted text-muted-foreground border-transparent`,n),title:i(`activity:autonomy.titlePrefix`,{label:c?.label??e}),children:[c?.icon,!r&&(0,Y.jsx)(`span`,{className:`truncate max-w-[7rem]`,children:c?.label??e}),(0,Y.jsx)(bn,{className:`h-3 w-3 opacity-60`})]}),a&&(0,Y.jsxs)(`div`,{className:`absolute top-full mt-1 right-0 z-50 w-56 rounded-lg border bg-popover shadow-lg p-1`,children:[(0,Y.jsx)(`div`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wider text-muted-foreground border-b mb-1`,children:i(`activity:autonomy.heading`)}),op.map(n=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{t(n.mode),o(!1)},className:X(`w-full flex items-start gap-2 px-3 py-2 rounded text-left transition-colors`,e===n.mode?`bg-accent text-accent-foreground`:`hover:bg-accent/40`),children:[(0,Y.jsx)(`span`,{className:`mt-0.5 text-muted-foreground`,children:n.icon}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-medium`,children:n.label}),(0,Y.jsx)(`p`,{className:`text-[10px] text-muted-foreground leading-snug`,children:i(`activity:autonomy.${n.descKey}`)})]}),e===n.mode&&(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary mt-2 shrink-0`})]},n.mode))]})]})}var cp={ts:Bt,tsx:Bt,js:Bt,jsx:Bt,mjs:Bt,cjs:Bt,json:On,lock:Ot,css:gn,scss:gn,less:gn,html:ir,htm:ir,svg:Wn,xml:ir,md:gn,mdx:gn,txt:gn,yml:gn,yaml:gn,toml:sr,env:sr,gitignore:sr,editorconfig:sr,sh:Bt,bash:Bt,zsh:Bt,fish:Bt,ps1:Bt,bat:Bt,py:Bt,pyi:Bt,pyx:Bt,rs:Bt,go:Bt,rb:Bt,java:Bt,c:Bt,cpp:Bt,h:Bt,hpp:Bt,sql:Bt,graphql:Bt,png:Wn,jpg:Wn,jpeg:Wn,gif:Wn,webp:Wn,ico:Wn};function lp(e,t){if(t){let t=e.toLowerCase();return t===`.git`?`text-orange-500/80 dark:text-orange-400/80`:t===`node_modules`?`text-red-400/60 dark:text-red-500/60`:t===`src`||t===`lib`||t===`packages`?`text-amber-500/70 dark:text-amber-400/70`:t===`tests`||t===`test`||t===`__tests__`?`text-emerald-500/70 dark:text-emerald-400/70`:t===`dist`||t===`build`||t===`.next`?`text-muted-foreground/50`:`text-amber-500/70 dark:text-amber-400/70`}let n=e.split(`.`).pop()?.toLowerCase()??``;return/^(ts|tsx|js|jsx|mjs|cjs)$/.test(n)?`text-blue-500 dark:text-blue-400`:/^(json|lock)$/.test(n)?`text-amber-500 dark:text-amber-400`:/^(css|scss|less|sass)$/.test(n)?`text-teal-500 dark:text-teal-400`:/^(html|htm|xml|svg)$/.test(n)?`text-rose-500 dark:text-rose-400`:/^(md|mdx)$/.test(n)?`text-violet-500 dark:text-violet-400`:/^(yml|yaml|toml|env)$/.test(n)?`text-emerald-500 dark:text-emerald-400`:/^(sh|bash|zsh|fish|ps1|bat)$/.test(n)?`text-orange-400 dark:text-orange-300`:/^(py|pyi|pyx)$/.test(n)?`text-cyan-500 dark:text-cyan-400`:n===`rs`?`text-orange-500 dark:text-orange-400`:n===`go`?`text-sky-500 dark:text-sky-400`:n===`rb`?`text-red-400 dark:text-red-400`:/^(c|h|cpp|hpp|cc|hh)$/.test(n)?`text-slate-500 dark:text-slate-400`:/^(png|jpe?g|gif|webp|ico)$/.test(n)?`text-purple-500 dark:text-purple-400`:/^(gitignore|editorconfig|prettierrc|eslintrc)$/.test(n)?`text-muted-foreground/60`:`text-muted-foreground`}function up(e){return cp[e.split(`.`).pop()?.toLowerCase()??``]??zn}function dp(e){return e.replace(/\\/g,`/`).split(`/`).pop()??e}function fp(e){if(e.kind===`file`)return e.path;let t=e.kind===`snippet`?e.content:e.preview,n=t.split(`
47
- `).slice(0,6).join(`
48
- `);return`${e.path}:${e.startLine}-${e.endLine}\n${n}${t.split(`
49
- `).length>6?`
50
- …`:``}`}function pp({ref:e,onRemove:t}){let{t:n}=V(),r=dp(e.path),i=up(r),a=lp(r,!1),o=e.kind===`file`?r:`${r}:${e.startLine}-${e.endLine}`,s=e.kind===`snippet`?e.content.split(`
51
- `).length:0,c=s>0?n(`activity:fileRef.linesCount`,{count:s}):null;return(0,Y.jsxs)(`div`,{title:fp(e),className:X(`inline-flex items-center gap-1.5 max-w-[180px] shrink-0`,`rounded-full border border-border bg-muted/60 pl-2 pr-1 py-0.5`,`text-xs text-foreground hover:bg-muted transition-colors`),children:[(0,Y.jsx)(i,{className:X(`h-3 w-3 shrink-0`,a)}),(0,Y.jsx)(`span`,{className:`truncate font-mono text-[11px]`,children:o}),c&&(0,Y.jsx)(`span`,{className:`text-[9px] text-muted-foreground shrink-0`,children:c}),(0,Y.jsx)(`button`,{type:`button`,onClick:t,className:`inline-flex items-center justify-center h-4 w-4 rounded-full text-muted-foreground hover:bg-background hover:text-foreground transition-colors shrink-0`,title:n(`activity:fileRef.removeTitle`),children:(0,Y.jsx)(Xn,{className:`h-3 w-3`})})]})}var mp=0,hp=!1;function gp(){let e=ti(e=>e.autoProceedMaxIterations),t=ti(e=>e.autonomy),n=(0,U.useRef)(mp),r=(0,U.useRef)(hp),i=(0,U.useRef)(t);(0,U.useEffect)(()=>{n.current=mp,r.current=hp}),(0,U.useEffect)(()=>{i.current!==`auto`&&t===`auto`&&(hp=!1,r.current=!1),i.current=t},[t]);let a=(0,U.useCallback)(()=>e<=0?!0:n.current<e,[e]),o=(0,U.useCallback)(()=>{let t=e;return t>0&&n.current>=t?!1:(mp=++n.current,t>0&&mp>=t&&(hp=!0,r.current=!0),!0)},[e]),s=(0,U.useCallback)(()=>{mp=0,n.current=0,hp=!1,r.current=!1},[]),c=(0,U.useCallback)(()=>{hp=!1,r.current=!1},[]);return{streak:n.current,capWarned:r.current,canAutoSubmit:a,recordAutoSubmit:o,reset:s,resetCapWarned:c}}function _p({query:e,onPick:t,onClose:n}){let{t:r}=V(),i=sd(),a=K(e=>e.wsUrl),[o,s]=(0,U.useState)([]),[c,l]=(0,U.useState)(0),u=(0,U.useRef)(null),d=(0,U.useRef)(null);return(0,U.useEffect)(()=>{let e=W(a).on(`files.list`,e=>{let t=e.payload;s(t.files??[]),l(0),d.current?.resolve(t.files??[]),d.current=null});return()=>e()},[a]),(0,U.useEffect)(()=>(u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{i.client.listFiles(e,50)},80),()=>{u.current&&clearTimeout(u.current)}),[e,i.client]),(0,U.useEffect)(()=>{let e=e=>{if(e.key===`ArrowDown`)e.preventDefault(),l(e=>(e+1)%Math.max(1,o.length));else if(e.key===`ArrowUp`)e.preventDefault(),l(e=>(e-1+Math.max(1,o.length))%Math.max(1,o.length));else if(e.key===`Enter`||e.key===`Tab`){if(o.length===0)return;e.preventDefault(),t(Ur(o[c]))}else e.key===`Escape`&&(e.preventDefault(),n())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[o,c,t,n]),(0,Y.jsxs)(`div`,{className:`absolute bottom-full left-0 right-0 mb-2 rounded-lg border bg-popover shadow-md p-1 text-sm max-h-72 overflow-auto`,children:[(0,Y.jsxs)(`div`,{className:`px-3 py-1 text-[10px] uppercase tracking-wider text-muted-foreground border-b mb-1 flex items-center justify-between`,children:[(0,Y.jsxs)(`span`,{children:[r(`activity:filePicker.heading`),` `,e&&`· "${e}"`]}),(0,Y.jsx)(`span`,{children:`↑/↓ select · ↵ insert · Esc dismiss`})]}),o.length===0?(0,Y.jsx)(`div`,{className:`px-3 py-2 text-xs text-muted-foreground italic`,children:e?r(`activity:filePicker.noMatch`,{query:e}):r(`activity:filePicker.searching`)}):o.map((e,n)=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>t(e),onMouseEnter:()=>l(n),className:X(`w-full text-left px-3 py-1.5 rounded transition-colors flex items-center gap-2 font-mono text-xs`,n===c?`bg-accent text-accent-foreground`:`hover:bg-accent/40`),children:[e.includes(`/`)?(0,Y.jsx)(dt,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}):(0,Y.jsx)(gn,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e})]},e))]})}function vp({atMention:e,input:t,textareaRef:n,setInput:r,setAtMention:i}){let{addRef:a}=lc.getState();return e?(0,Y.jsx)(_p,{query:e.query,onClose:()=>i(null),onPick:o=>{r(`${t.slice(0,e.start)}${t.slice(e.start+1+e.query.length)}`.replace(/\s+/g,` `).trim()),i(null),a({kind:`file`,path:o}),requestAnimationFrame(()=>{let t=n.current;if(t){let n=e.start;t.focus(),t.setSelectionRange(n,n),t.style.height=`auto`,t.style.height=`${Math.min(t.scrollHeight,200)}px`}})}}):null}var yp={btw:{label:`btw`,tone:`bg-sky-500/10 text-sky-700 dark:text-sky-300 border-sky-500/30`,titleKey:`btwTitle`},steer:{label:`steer`,tone:`bg-amber-500/10 text-amber-700 dark:text-amber-300 border-amber-500/30`,titleKey:`steerTitle`},queue:{label:`queue`,tone:`bg-indigo-500/10 text-indigo-700 dark:text-indigo-300 border-indigo-500/30`,titleKey:`queueTitle`}};function bp({queue:e,onClear:t,onRemove:n}){let{t:r}=V(),[i,a]=(0,U.useState)(`oldest`),o=(0,U.useMemo)(()=>{let t=e.slice();return t.sort((e,t)=>i===`newest`?t.addedAt-e.addedAt:e.addedAt-t.addedAt),t},[e,i]);return e.length===0?null:(0,Y.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 p-2 text-xs`,"data-testid":`inline-queue`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5 gap-2`,children:[(0,Y.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground font-medium shrink-0`,children:[r(`activity:queue.heading`),` (`,e.length,`)`]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>e===`newest`?`oldest`:`newest`),className:X(`inline-flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors px-1.5 py-0.5 rounded text-[10px]`,`hover:bg-muted`),title:r(i===`newest`?`activity:queue.sortNewestTitle`:`activity:queue.sortOldestTitle`),"data-testid":`inline-queue-sort`,children:[i===`newest`?(0,Y.jsx)(Nt,{className:`h-3 w-3`}):(0,Y.jsx)(Fr,{className:`h-3 w-3`}),r(i===`newest`?`activity:queue.newest`:`activity:queue.oldest`)]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:t,className:`inline-flex items-center gap-1 text-muted-foreground hover:text-destructive transition-colors px-1.5 py-0.5 rounded text-[10px]`,title:r(`activity:queue.clearTitle`),"data-testid":`inline-queue-clear-all`,children:[(0,Y.jsx)(C,{className:`h-3 w-3`}),r(`activity:queue.clear`)]})]})]}),(0,Y.jsx)(`ul`,{className:`space-y-1`,children:o.map(t=>{let i=e.indexOf(t),a=yp[t.mode];return(0,Y.jsxs)(`li`,{className:`flex items-start justify-between gap-2 rounded bg-background/60 border px-2 py-1`,"data-testid":`inline-queue-item`,"data-queue-mode":t.mode,children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-1.5 min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:X(`shrink-0 inline-flex items-center justify-center text-[9px] font-semibold uppercase tracking-wider px-1 py-px rounded border mt-0.5`,a.tone),title:r(`activity:queue.${a.titleKey}`),children:a.label}),(0,Y.jsx)(`span`,{className:`truncate flex-1 min-w-0`,children:t.text})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>n(i),className:`text-muted-foreground hover:text-destructive shrink-0`,title:r(`activity:queue.removeTitle`),"data-testid":`inline-queue-remove-${i}`,children:`×`})]},`${t.addedAt}-${i}`)})})]})}var xp=[{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`,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:`Show the current goal (opens the Goal 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:`/autophase`,category:`Agent`,description:`AutoPhase: start <title> | pause | resume | stop`},{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:`/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}],Sp=[`Run`,`Session`,`Inspect`,`Agent`,`Config`,`App`];function Cp(e){let t=e.toLowerCase();return t===`/`||t===``?xp.filter(e=>!e.hidden):xp.filter(e=>e.name.startsWith(t)||(e.aliases?.some(e=>e.startsWith(t))??!1))}function wp(e,t){let n=t-1;for(;n>=0;){let r=Ur(e[n]);if(r===`@`){let r=n>0?e[n-1]:``;return n===0||/\s/.test(r??``)?{start:n,query:e.slice(n+1,t)}:null}if(/\s/.test(r))return null;n--}return null}function Tp(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 Ep(e){let t=Math.max(3,...Array.from(e.matchAll(/`+/g),e=>e[0].length+1));return"`".repeat(t)}function Dp(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function Op(){let e=G.getState().messages,t=[],n=new Date().toISOString().slice(0,19).replace(/[:T]/g,`-`),r=q.getState().projectName||`chat`,i=q.getState().session?.title||r;t.push(`# ${i} — chat export`),t.push(`*Exported: ${new Date().toISOString()}*`),t.push(``);for(let n of e)if(n.thinkingLog){let e=Ep(n.thinkingLog.text),r=n.thinkingLog.text.split(`
52
- `).length;t.push(`### 🧠 Thinking process — iteration ${n.thinkingLog.iteration}`),t.push(``),t.push(`_${Tp(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 a=new Blob([t.join(`
53
- `)],{type:`text/markdown`}),o=URL.createObjectURL(a),s=document.createElement(`a`);s.href=o,s.download=`${r.toLowerCase().replace(/[^a-z0-9]+/g,`-`)}-chat-${n}.md`,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(o)}function kp(){let e=G.getState().messages,t=q.getState(),n=t.projectName||`chat`,r=Dp(t.session?.title||n),i=new Date().toISOString().slice(0,19).replace(/[:T]/g,`-`),a=e.map(e=>{if(e.thinkingLog){let t=e.thinkingLog.text.split(`
54
- `).length;return`
55
- <section class="bubble thinking">
56
- <header><span class="icon">🧠</span><strong>Thinking process</strong> <span class="meta-chip">iter ${e.thinkingLog.iteration} · ${Dp(Tp(e))} · ${t} line${t===1?``:`s`}</span></header>
57
- <details open><summary>Log</summary><pre>${Dp(e.thinkingLog.text)}</pre></details>
58
- </section>`}if(e.role===`tool`){let t=e.isError?`❌`:e.toolResult===void 0?`⏳`:`✅`;return`
59
- <section class="bubble tool ${e.isError?`error`:``}">
60
- <header><span class="icon">🔧</span><code>${Dp(e.toolName??`tool`)}</code> ${t}</header>
61
- ${e.toolInput===void 0?``:`<details><summary>Input</summary><pre>${Dp(JSON.stringify(e.toolInput,null,2))}</pre></details>`}
62
- ${e.toolResult?`<details><summary>Output</summary><pre>${Dp(e.toolResult)}</pre></details>`:``}
63
- </section>`}return`
64
- <section class="bubble ${e.role===`user`?`user`:`assistant`}">
65
- <header><span class="icon">${e.role===`user`?`👤`:`🤖`}</span><strong>${e.role===`user`?`User`:`Assistant`}</strong></header>
66
- <pre class="content">${Dp(e.content)}</pre>
67
- </section>`}),o=`<!doctype html>
68
- <html lang="en"><head>
69
- <meta charset="utf-8">
70
- <title>${r} — chat export</title>
71
- <style>
72
- :root { color-scheme: light dark; }
73
- body { font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; max-width: 920px; margin: 24px auto; padding: 0 16px; }
74
- h1 { font-size: 20px; margin-bottom: 4px; }
75
- .meta { color: #666; font-size: 12px; margin-bottom: 24px; }
76
- .bubble { margin: 12px 0; padding: 10px 14px; border-radius: 10px; border: 1px solid #ddd; }
77
- .bubble header { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: #666; margin-bottom: 6px; }
78
- .bubble header .icon { margin-right: 4px; }
79
- .bubble.user { background: #eef4ff; border-color: #c8d8f5; }
80
- .bubble.assistant { background: #fff; }
81
- .bubble.thinking { background: #fbf7ff; border-color: #dcc7ff; }
82
- .bubble.tool { background: #fafafa; }
83
- .bubble.tool.error { background: #fff5f5; border-color: #f5c8c8; }
84
- .meta-chip { text-transform: none; letter-spacing: 0; font-weight: 400; }
85
- pre.content, .bubble pre { white-space: pre-wrap; word-break: break-word; font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; margin: 0; }
86
- details summary { cursor: pointer; color: #555; font-size: 12px; }
87
- details pre { margin-top: 6px; background: #f4f4f4; padding: 8px; border-radius: 6px; max-height: 360px; overflow: auto; }
88
- @media (prefers-color-scheme: dark) {
89
- body { background: #0d0d0f; color: #e6e6e6; }
90
- .bubble { border-color: #2a2a2e; }
91
- .bubble.user { background: #16213a; border-color: #2a3d6b; }
92
- .bubble.assistant { background: #161618; }
93
- .bubble.thinking { background: #1d1728; border-color: #4b3673; }
94
- .bubble.tool { background: #131315; }
95
- .bubble.tool.error { background: #2a1717; border-color: #5c2a2a; }
96
- details pre { background: #1a1a1c; }
97
- .meta, .bubble header, details summary { color: #999; }
98
- }
99
- </style>
100
- </head><body>
101
- <h1>${r} — chat export</h1>
102
- <div class="meta">
103
- Exported ${new Date().toISOString()}${t.session?.provider?` · ${Dp(t.session.provider)}/${Dp(t.session.model)}`:``} · ${e.length} message${e.length===1?``:`s`}
104
- </div>
105
- ${a.join(``)}
106
- </body></html>`,s=new Blob([o],{type:`text/html;charset=utf-8`}),c=URL.createObjectURL(s),l=document.createElement(`a`);l.href=c,l.download=`${n.toLowerCase().replace(/[^a-z0-9]+/g,`-`)}-chat-${i}.html`,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(c)}function Ap(){let e=J(e=>e.paletteOpen),t=J(e=>e.setPaletteOpen),n=K(e=>e.setTheme),{entries:r}=Ts(),{addMessage:i,clearMessages:o}=G(),s=sd(),{t:c}=V(),[l,u]=(0,U.useState)(``),[f,p]=(0,U.useState)(0),m=(0,U.useRef)(null);(0,U.useEffect)(()=>{e&&(u(``),p(0),requestAnimationFrame(()=>m.current?.focus()))},[e]),(0,U.useEffect)(()=>{let e=e=>{if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`k`){e.preventDefault(),t(!J.getState().paletteOpen);return}e.key===`Escape`&&J.getState().paletteOpen&&(e.preventDefault(),t(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let h=(0,U.useMemo)(()=>{let e=[{id:`help`,category:`Command`,label:c(`commandPalette:cmd.help`),icon:rt,keywords:[`help`,`commands`,`?`],run:()=>{i({role:`assistant`,content:"Type `/` in the message box to see every slash command."})}},{id:`tools`,category:`Command`,label:c(`commandPalette:cmd.tools`),icon:In,keywords:[`tools`,`list`],run:()=>s.listTools()},{id:`memory`,category:`Command`,label:c(`commandPalette:cmd.memory`),icon:Me,keywords:[`memory`,`remember`,`notes`],run:()=>s.listMemory()},{id:`skills`,category:`Command`,label:c(`commandPalette:cmd.skills`),icon:bt,keywords:[`skills`],run:()=>s.listSkills()},{id:`diag`,category:`Command`,label:c(`commandPalette:cmd.diag`),icon:Ne,keywords:[`diag`,`diagnostics`,`debug`],run:()=>s.getDiag()},{id:`stats`,category:`Command`,label:c(`commandPalette:cmd.stats`),icon:Sr,keywords:[`stats`,`tokens`,`cost`,`cache`],run:()=>s.getStats()},{id:`clear`,category:`Session`,label:c(`commandPalette:cmd.clear`),hint:c(`commandPalette:cmd.clearHint`),icon:C,keywords:[`clear`,`reset`,`wipe`],run:()=>{Go.dropAll(),o(),s.client?.clearContext?.()}},{id:`new`,category:`Session`,label:c(`commandPalette:cmd.new`),hint:c(`commandPalette:cmd.newHint`),icon:Le,keywords:[`new`,`fresh`,`session`],run:()=>{s.client?.newSession?.(),Q(`chat`)}},{id:`compact`,category:`Session`,label:c(`commandPalette:cmd.compact`),icon:dn,keywords:[`compact`,`shrink`,`context`],run:()=>s.client?.compactContext?.()},{id:`repair-context`,category:`Session`,label:c(`commandPalette:cmd.repairContext`),hint:c(`commandPalette:cmd.repairContextHint`),icon:In,keywords:[`repair`,`context`,`tool_use`,`tool_result`],run:()=>s.client?.repairContext?.()},{id:`export`,category:`Session`,label:c(`commandPalette:cmd.export`),icon:Yn,keywords:[`export`,`save`,`markdown`,`download`],run:()=>Op()},{id:`export-html`,category:`Session`,label:c(`commandPalette:cmd.exportHtml`),hint:c(`commandPalette:cmd.exportHtmlHint`),icon:Yn,keywords:[`export`,`html`,`download`,`archive`],run:()=>kp()},{id:`history`,category:`Command`,label:c(`commandPalette:cmd.history`),icon:d,keywords:[`history`,`sessions`],run:()=>{Q(`history`)}},{id:`settings`,category:`Command`,label:c(`commandPalette:cmd.settings`),icon:I,keywords:[`settings`,`config`],run:()=>_l(`settings`)},{id:`model`,category:`Command`,label:c(`commandPalette:cmd.model`),icon:wr,keywords:[`model`,`provider`,`change`],run:()=>J.getState().setModelSwitcherOpen(!0)},{id:`theme-light`,category:`Theme`,label:c(`commandPalette:cmd.themeLight`),icon:we,keywords:[`theme`,`light`,`mode`],run:()=>n(`light`)},{id:`theme-dark`,category:`Theme`,label:c(`commandPalette:cmd.themeDark`),icon:un,keywords:[`theme`,`dark`,`mode`],run:()=>n(`dark`)},{id:`theme-system`,category:`Theme`,label:c(`commandPalette:cmd.themeSystem`),icon:an,keywords:[`theme`,`system`,`auto`],run:()=>n(`system`)},{id:`compact-toggle`,category:`Command`,label:c(`commandPalette:cmd.compactToggle`),icon:We,hint:`Ctrl+Shift+D`,keywords:[`compact`,`dense`,`density`,`size`],run:()=>J.getState().toggleCompactMode()},{id:`sound-toggle`,category:`Command`,label:K.getState().soundOnComplete?c(`commandPalette:cmd.soundOn`):c(`commandPalette:cmd.soundOff`),icon:K.getState().soundOnComplete?Tr:Et,hint:c(`commandPalette:cmd.soundHint`),keywords:[`sound`,`audio`,`chime`,`notify`,`beep`],run:()=>{let e=!K.getState().soundOnComplete;K.getState().setSoundOnComplete(e),e&&Gc()}},{id:`autophase-open`,category:`Command`,label:c(`commandPalette:cmd.autophaseOpen`),icon:a,keywords:[`autophase`,`autonomous`,`phases`,`rocket`],run:()=>_l(`autophase`)},{id:`autophase-toggle`,category:`Command`,label:ec.getState().autonomous?c(`commandPalette:cmd.autoOn`):c(`commandPalette:cmd.autoOff`),icon:ec.getState().autonomous?kn:kt,hint:c(`commandPalette:cmd.autoHint`),keywords:[`autonomous`,`autophase`,`auto`,`pause`,`resume`],run:()=>{let e=!ec.getState().autonomous;s.toggleAutoPhaseAutonomous(e)}},{id:`autophase-stop`,category:`Command`,label:c(`commandPalette:cmd.autophaseStop`),icon:ae,keywords:[`autophase`,`stop`,`autonomous`,`end`],run:()=>s.stopAutoPhase()}],t=e=>{let t=G.getState(),n=J.getState();return{raw:e,addMessage:i,clearMessages:o,client:s.client,queue:t.queue,sendAbort:s.sendAbort,sendMsg:e=>{if(t.isLoading){t.enqueue(e);return}t.addMessage({role:`user`,content:e}),s.sendMessage(e)&&t.setLoading(!0)},setLoading:t.setLoading,setCurrentView:e=>vl(e),toggleRefineEnabled:n.toggleRefineEnabled,setProcessMonitorOpen:n.setProcessMonitorOpen,setQueuePanelOpen:n.setQueuePanelOpen,ws:s,onOpenBreakdown:()=>vl(`debug`),handleNextList:()=>!1,handleNextSelect:()=>!1}};for(let n of xp)n.hidden||e.push({id:`slash-${n.name}`,category:`Slash`,label:n.name,hint:n.description,icon:rt,keywords:[`slash`,n.name.replace(`/`,``),...(n.aliases??[]).map(e=>e.replace(`/`,``))],run:()=>{Mp(t(n.name))}});for(let t of r.slice(0,10))t.isCurrent||e.push({id:`resume-${t.id}`,category:`Session`,label:c(`commandPalette:cmd.resume`,{title:t.title||c(`commandPalette:cmd.emptyTitle`)}),hint:`${t.provider}/${t.model}`,icon:fe,keywords:[`resume`,t.title,t.id,t.provider,t.model],run:()=>s.resumeSession(t.id)});return e},[r,s,n,i,o,c]),g=(0,U.useMemo)(()=>{let e=l.toLowerCase().trim();return e?h.filter(t=>[t.label,t.hint??``,t.category,...t.keywords??[]].join(` `).toLowerCase().includes(e)):h},[h,l]);if((0,U.useEffect)(()=>{f>=g.length&&p(0)},[g.length,f]),!e)return null;let _=e=>{e&&(t(!1),e.run())};return(0,Y.jsx)(`div`,{className:`fixed inset-0 z-50 bg-background/60 backdrop-blur-sm flex items-start justify-center pt-[14dvh] px-4`,onClick:()=>t(!1),onKeyDown:e=>{e.key===`Escape`&&t(!1)},children:(0,Y.jsxs)(`div`,{onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),className:`w-full max-w-2xl rounded-xl border bg-popover shadow-2xl overflow-hidden flex flex-col`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 border-b`,children:[(0,Y.jsx)(le,{className:`h-4 w-4 text-muted-foreground`}),(0,Y.jsx)(`input`,{ref:m,value:l,onChange:e=>u(e.target.value),placeholder:c(`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,g.length))):e.key===`ArrowUp`?(e.preventDefault(),p(e=>(e-1+Math.max(1,g.length))%Math.max(1,g.length))):e.key===`Enter`&&(e.preventDefault(),_(g[f]))}}),(0,Y.jsx)(`kbd`,{className:`text-[10px] text-muted-foreground border rounded px-1.5 py-0.5`,children:`Esc`})]}),(0,Y.jsx)(`div`,{className:`max-h-[60dvh] overflow-y-auto`,children:g.length===0?(0,Y.jsx)(`div`,{className:`px-4 py-8 text-center text-sm text-muted-foreground`,children:c(`commandPalette:noMatches`,{query:l})}):jp(g,f,_,p)}),(0,Y.jsxs)(`div`,{className:`border-t px-4 py-2 text-[10px] uppercase tracking-wider text-muted-foreground flex items-center gap-3`,children:[(0,Y.jsx)(`span`,{children:c(`commandPalette:footer.navigate`)}),(0,Y.jsx)(`span`,{children:c(`commandPalette:footer.select`)}),(0,Y.jsx)(`span`,{children:c(`commandPalette:footer.dismiss`)})]})]})})}function jp(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,Y.jsx)(`div`,{className:`p-1`,children:Object.entries(i).map(([e,i])=>(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`px-3 pt-2 pb-1 text-[10px] uppercase tracking-wider text-muted-foreground`,children:b.t(`commandPalette:cat.${e}`,{defaultValue:e})}),i.map(({item:e,globalIdx:i})=>{let a=e.icon,o=i===t;return(0,Y.jsxs)(`button`,{type:`button`,onMouseEnter:()=>r(i),onClick:()=>n(e),className:X(`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,Y.jsx)(a,{className:`h-4 w-4 text-muted-foreground shrink-0`}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`truncate`,children:e.label}),e.hint&&(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:e.hint})]}),o&&(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`↵`})]},e.id)})]},e))})}function Mp(e){let{raw:t,addMessage:n,clearMessages:r,client:i,queue:a,sendAbort:o,sendMsg:s,setLoading:c,toggleRefineEnabled:l,setProcessMonitorOpen:u,setQueuePanelOpen:d,ws:f,onOpenBreakdown:p,handleNextList:m,handleNextSelect:h}=e,g=t.trim(),_=g.indexOf(` `),v=(_===-1?g:g.slice(0,_)).toLowerCase(),y=_===-1?``:g.slice(_+1).trim(),b=v,x=e=>{let t=J.getState();Q(`chat`),t.setDockSection(`work`),t.setWorkDashboardTab(e)};switch(b){case`/help`:return n({role:`assistant`,content:[`📖 **Slash commands**`,``,...xp.map(e=>`• \`${e.name}\`${e.aliases?.length?` (${e.aliases.map(e=>`\`${e}\``).join(`, `)})`:``} — ${e.description}`)].join(`
107
- `)}),!0;case`/clear`:return Go.dropAll(),r(),i?.clearContext?.(),!0;case`/new`:return i?.newSession?.(),Q(`chat`),!0;case`/exit`:return i?.send?.({type:`webui.shutdown`}),n({role:`assistant`,content:`👋 Shutting down WebUI server…`}),!0;case`/compact`:case`/compact!`:return i?.compactContext?.(b===`/compact!`),!0;case`/repair`:return i?.repairContext?.(),!0;case`/debug`:case`/context`:return p?.(),!0;case`/tools`:return f.listTools(),!0;case`/memory`:return f.listMemory(),!0;case`/skill`:case`/skills`:return f.listSkills(),!0;case`/prompt`:case`/prompts`:return J.getState().setPromptLibraryOpen(!0),!0;case`/diag`:return f.getDiag(),!0;case`/stats`:return f.getStats(),!0;case`/save`:return f.saveSession(),!0;case`/load`:case`/resume`:return f.listSessions(50),Q(`history`),!0;case`/agents`:return J.getState().setAgentsMonitorOpen(!0),!0;case`/autonomy`:{let e=y.trim().toLowerCase(),t=[`off`,`suggest`,`auto`,`eternal`,`eternal-parallel`];return e?t.includes(e)?(i?.send?.({type:`autonomy.switch`,payload:{mode:e}}),n({role:`assistant`,content:`🤖 Autonomy mode → **${e}**.`}),!0):(n({role:`assistant`,content:`Unknown autonomy mode \`${e}\`. Try: ${t.join(`, `)}.`}),!0):(n({role:`assistant`,content:`Usage: \`/autonomy <mode>\` — one of: ${t.map(e=>`\`${e}\``).join(`, `)}.`}),!0)}case`/goal`:return i?.send?.({type:`goal.get`}),Q(`chat`),J.getState().setDockSection(`goal`),!0;case`/fleet`:return J.getState().setFleetMonitorOpen(!0),!0;case`/terminal`:case`/term`:return J.getState().setTerminalOpen(!0),!0;case`/collab`:return Q(`chat`),J.getState().setDockSection(`collab`),!0;case`/worktree`:case`/worktrees`:return Q(`worktrees`),J.getState().setDockSection(`worktrees`),!0;case`/mode`:{let e=y.trim();return e?(i?.send?.({type:`mode.switch`,payload:{id:e}}),n({role:`assistant`,content:`Mode → **${e}**.`}),!0):(i?.send?.({type:`modes.list`}),n({role:`assistant`,content:"Fetching available modes… (or pass `/mode <name>` to switch)."}),!0)}case`/mcp`:return i?.send?.({type:`mcp.list`}),_l(`settings`),!0;case`/working-dir`:case`/cwd`:{let e=y.trim();if(!e){let e=q.getState().cwd;return n({role:`assistant`,content:e?`📂 Working directory: \`${e}\`\n\n_Pass \`/working-dir <path>\` to change it._`:"Working directory unknown. Pass `/working-dir <path>` to set it."}),!0}return i?.send?.({type:`working_dir.set`,payload:{path:e}}),n({role:`assistant`,content:`📂 Working directory → \`${e}\`.`}),!0}case`/autophase`:{let[e,...t]=y.split(/\s+/).filter(Boolean),r=(e??``).toLowerCase();if(r===`start`){let e=t.join(` `).trim();return e?(i?.send?.({type:`autophase.start`,payload:{title:e}}),_l(`autophase`),!0):(n({role:`assistant`,content:"Usage: `/autophase start <title>`"}),!0)}return r===`pause`?(i?.send?.({type:`autophase.pause`,payload:{}}),!0):r===`resume`?(i?.send?.({type:`autophase.resume`,payload:{}}),!0):r===`stop`?(i?.send?.({type:`autophase.stop`,payload:{}}),!0):(_l(`autophase`),!0)}case`/brain`:{let[e,...t]=y.split(/\s+/).filter(Boolean),r=(e??``).toLowerCase();if(r===`risk`)i?.send?.({type:`brain.risk`,payload:{level:(t[0]??``).toLowerCase()}});else if(r===`ask`){let e=t.join(` `).trim();e?i?.send?.({type:`brain.ask`,payload:{question:e}}):n({role:`assistant`,content:"Usage: `/brain ask <question>`"})}else i?.send?.({type:`brain.status`});return!0}case`/plan`:return f.getPlan(),x(`plan`),!0;case`/todos`:{if(y.toLowerCase()===`clear`)return i?.clearTodos?.(),!0;x(`todos`);let e=q.getState().todos;if(e.length===0)return n({role:`assistant`,content:`✅ **Todos** — _empty. Ask the agent to plan something and they'll show up here._`}),!0;let t=[`✅ **Todos** (${e.filter(e=>e.status===`completed`).length}/${e.length} done)`,``];for(let n of e){let e=n.status===`completed`?`[x]`:n.status===`in_progress`?`[~]`:`[ ]`,r=n.status===`in_progress`&&n.activeForm?n.activeForm:n.content;t.push(`- ${e} ${r}`)}return t.push(``,"_Use `/todos clear` to wipe the list._"),n({role:`assistant`,content:t.join(`
108
- `)}),!0}case`/export`:return Op(),n({role:`assistant`,content:`📥 Chat exported to your downloads folder.`}),!0;case`/interrupt`:case`/abort`:case`/stop`:case`/int`:return o(),c(!1),!0;case`/settings`:case`/model`:return _l(`settings`),!0;case`/setup`:return vl(`setup`),!0;case`/enhance`:{let e=!J.getState().refineEnabled;return l(),n({role:`assistant`,content:`Prompt refinement ${e?`enabled`:`disabled`}.`}),!0}case`/suggest`:case`/next-steps`:return s(`What are the next steps I should take? Be specific and actionable.`),!0;case`/review`:case`/cr`:{let e=y.trim();return s(`Review the pending git changes (run \`git diff\` and \`git status\` to see them). ${e?`Focus especially on: ${e}.`:`Cover correctness bugs, security issues, performance, and obvious simplifications.`} For each finding give the file, a short description, severity, and a concrete fix. If there are no changes, review the most recently edited files instead.`),!0}case`/fix`:{let e=y.trim();return s(e?`Diagnose and fix this error. Find the root cause, then apply the fix and explain it:\n\n${e}`:`Investigate the most recent error or failing test, find the root cause, fix it, and verify the fix.`),!0}case`/kill`:case`/ps`:return u(!0),!0;case`/queue`:{let e=a;if(e.length===0)n({role:`assistant`,content:`📋 **Message Queue** — empty.
109
-
110
- Type while the agent is running to queue messages; they are sent automatically when the agent finishes.`});else{let t=[`📋 **Message Queue** (${e.length} queued)`,``];e.forEach((e,n)=>{let r=e.text.length>80?`${e.text.slice(0,77)}…`:e.text;t.push(`${n+1}. ${r}`)}),t.push(``,"_Use `/queue open` to manage, or `/queue clear` to wipe._"),n({role:`assistant`,content:t.join(`
111
- `)})}return y.toLowerCase()===`open`&&d(!0),!0}case`/next`:{let e=y.trim().toLowerCase();return!e||e===`list`||e===`ls`||e===`show`?m():e===`clear`||e===`reset`?(n({role:`assistant`,content:`💡 _Suggestion list cleared._`}),!0):h(y.trim())}case`/f`:case`/f1`:case`/f2`:case`/f3`:case`/f4`:case`/f5`:case`/f6`:case`/f7`:case`/f8`:case`/f9`:case`/f10`:case`/f11`:case`/f12`:{let e={"/f":``,"/f1":`sessionPanel`,"/f2":`fleetMonitor`,"/f3":`agentsMonitor`,"/f4":`worktreeMonitor`,"/f5":`planPanel`,"/f6":`todosMonitor`,"/f7":`queuePanel`,"/f8":`processList`,"/f9":`goalPanel`,"/f10":`sessionsPanel`,"/f11":`coordinatorMonitor`,"/f12":`statuslinePicker`},t=b===`/f`&&y?e[`/f${y.trim()}`]:e[b];if(!t)return n({role:`assistant`,content:[`🎛️ **F-key panels**`,``,`/f 1 — Session panel`,`/f 2 — Fleet orchestration monitor`,`/f 3 — Agents live monitor`,`/f 4 — Worktree monitor`,`/f 5 — Plan panel`,`/f 6 — Todos monitor overlay`,`/f 7 — Queue panel`,`/f 8 — Process list overlay`,`/f 9 — Goal panel`,`/f 10 — Live sessions panel`,`/f 11 — Coordinator monitor`,`/f 12 — Status line picker`,``,`_Or use /f1 … /f12 directly._`].join(`
112
- `)}),!0;let r=J.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`),!0):t===`sessionsPanel`?(f.listSessions(50),Q(`history`),!0):t===`coordinatorMonitor`?(Q(`officemap`),!0):t===`statuslinePicker`?(Q(`chat`),r.setDockSection(`work`),r.setDockCustomizeOpen(!0),!0):!0}default:return!1}}var Np=[{lang:`typescript`,patterns:[{regex:/:\s*(string|number|boolean|void|never|any|unknown|Promise|Array|Record|Map|Set)\b/,weight:4},{regex:/\b(interface|type|enum|namespace|implements|extends|as|satisfies|infer)\b/,weight:3},{regex:/\b(import|export)\s+/,weight:3},{regex:/\b(const|let|var)\s+\w+\s*[:=]/,weight:2},{regex:/=>/,weight:1},{regex:/\.tsx?['"]/,weight:2}]},{lang:`javascript`,patterns:[{regex:/\b(import|export|require)\s*[({]/,weight:3},{regex:/\b(const|let|var)\s+\w+\s*=\s*require/,weight:2},{regex:/\bmodule\.exports/,weight:3},{regex:/\.jsx?['"]/,weight:2}]},{lang:`python`,patterns:[{regex:/^\s*def\s+\w+\s*\(/,weight:4},{regex:/^\s*class\s+\w+.*:/,weight:3},{regex:/\bimport\s+\w+/,weight:2},{regex:/\bfrom\s+\w+\s+import/,weight:3},{regex:/\bprint\(/,weight:1},{regex:/\bself\./,weight:2},{regex:/if\s+__name__\s*==\s*['"]__main__['"]/,weight:4}]},{lang:`rust`,patterns:[{regex:/\bfn\s+\w+\s*[<(]/,weight:4},{regex:/\blet\s+mut\s/,weight:3},{regex:/\b(struct|enum|impl|trait|mod)\s+\w+/,weight:3},{regex:/\bpub\s+(fn|struct|enum)/,weight:3},{regex:/->\s*\w+/,weight:1},{regex:/::\w+/,weight:1}]},{lang:`go`,patterns:[{regex:/\bfunc\s+\w+\s*\(/,weight:4},{regex:/\bpackage\s+\w+/,weight:4},{regex:/\bimport\s*\(/,weight:3},{regex:/\b(err|nil)\b/,weight:2},{regex:/:=/,weight:2},{regex:/\bdefer\s/,weight:2}]},{lang:`json`,patterns:[{regex:/^\s*[{[]/,weight:3},{regex:/"[^"]+"\s*:\s*/,weight:3},{regex:/^\s*[}\]]\s*$/,weight:1}]},{lang:`yaml`,patterns:[{regex:/^---\s*$/,weight:4},{regex:/^\s*\w[\w.-]*:\s/,weight:2},{regex:/^\s*-\s+\w/,weight:1}]},{lang:`html`,patterns:[{regex:/<(!DOCTYPE|html|head|body|div|span|a|p|ul|li|table)/i,weight:4},{regex:/<\/?\w+[\s>]/,weight:2},{regex:/\b(class|id|href|src)="/,weight:2}]},{lang:`css`,patterns:[{regex:/[{]\s*$/,weight:1},{regex:/^\s*[.#@]\S+\s*[{]/,weight:3},{regex:/\b(\d+px|\d+em|\d+rem|\d+vh|\d+vw)\b/,weight:3},{regex:/:\s*\w+\s*!important/,weight:3},{regex:/@(media|keyframes|import|apply)/,weight:3}]},{lang:`sql`,patterns:[{regex:/\b(SELECT|INSERT|UPDATE|DELETE|CREATE TABLE|ALTER TABLE|DROP TABLE)\b/i,weight:4},{regex:/\bFROM\s+\w+/i,weight:2},{regex:/\bWHERE\s+/i,weight:2},{regex:/\b(JOIN|INNER JOIN|LEFT JOIN)\b/i,weight:2}]},{lang:`bash`,patterns:[{regex:/^#!\/.*(bash|sh|zsh)/,weight:5},{regex:/\becho\s/,weight:2},{regex:/\bexport\s+\w+=/,weight:2},{regex:/\bif\s+\[\[?\s/,weight:2},{regex:/\$\{?\w+/,weight:1},{regex:/&&|\|\|/,weight:1}]},{lang:`toml`,patterns:[{regex:/^\s*\[.*\]\s*$/,weight:3},{regex:/^\s*\w+\s*=\s*['"]/,weight:2},{regex:/^\s*\[\[.*\]\]\s*$/,weight:3}]}],Pp=6,Fp=3,Ip=180;function Lp(e){let t=e.split(`
113
- `);if(t.length<Fp)return!1;let n=0,r=0;for(let e of t){let t=e.trim();t.length!==0&&(t.length>Ip&&r++,/^ {2,}/.test(e)&&n++,/[.!?]$/.test(t)&&r++,/[{}();=<>[\]]/.test(t)&&n++,/[#$]/.test(t)&&!/^# /.test(t)&&n++)}return n>=r&&n>=2}function Rp(e){if(!Lp(e))return null;let t={};for(let n of Np){let r=0;for(let{regex:t,weight:i}of n.patterns){let n=e.match(new RegExp(t.source,t.flags.includes(`g`)?t.flags:`${t.flags}g`));n&&(r+=n.length*i)}r>0&&(t[n.lang]=r)}t.javascript&&t.typescript&&(t.typescript>=t.javascript?delete t.javascript:t.javascript>t.typescript&&delete t.typescript);let n=null,r=0;for(let[e,i]of Object.entries(t))i>r&&(r=i,n=e);return r>=Pp?n:null}function zp(e){let t=e.trim();return/^```[\s\S]*```\s*$/.test(t)}function Bp(e){if(zp(e))return null;let t=Rp(e);return t?{fenced:`\`\`\`${t}\n${e}\n\`\`\``,lang:t}:null}function Vp(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>n(r.error),r.readAsDataURL(e)})}function Hp({input:e,textareaRef:t,setInput:n}){let[r,i]=(0,U.useState)(null),[a,o]=(0,U.useState)(!1),s=(0,U.useRef)(null),[c,l]=(0,U.useState)(null),u=e=>{s.current=e,l(e)};return(0,U.useEffect)(()=>{let e=t.current;if(!e)return;let n=async e=>{let t=e.clipboardData?.items;if(t){for(let n of t)if(n.type.startsWith(`image/`)){e.preventDefault();try{let e=n.getAsFile();if(!e)continue;let t=new FileReader;t.onload=()=>{u(t.result)},t.readAsDataURL(e)}catch{}return}}};return e.addEventListener(`paste`,n),()=>e.removeEventListener(`paste`,n)},[t]),{draggingOver:a,onDragEnter:e=>{!e.dataTransfer||!Array.from(e.dataTransfer.types).includes(`Files`)||(e.preventDefault(),o(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||o(!1)},onDragOver:e=>{!e.dataTransfer||!Array.from(e.dataTransfer.types).includes(`Files`)||(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)},onDrop:e=>{if(!e.dataTransfer)return;let t=Array.from(e.dataTransfer.files??[]);if(t.length===0){o(!1);return}e.preventDefault(),o(!1);let n=t.find(e=>e.type?.startsWith(`image/`));n&&Vp(n).then(e=>u(e)).catch(()=>{});let r=t.filter(e=>!e.type?.startsWith(`image/`));if(r.length===0)return;let{addRef:i}=lc.getState();for(let e of r)i({kind:`file`,path:e.name})},onTextPaste:r=>{let a=r.clipboardData?.getData(`text`)??``;if(!a)return;let o=Bp(a);if(o){r.preventDefault();let s=t.current;if(!s)return;let c=s.selectionStart,l=s.selectionEnd,u=e.slice(0,c),d=e.slice(l),f=o.fenced;n(u+f+d);let p=a.split(`
114
- `).length;i({chars:a.length,lines:p,lang:o.lang,undoFence:()=>{n(u+a+d),i(null),requestAnimationFrame(()=>{s&&(s.focus(),s.style.height=`auto`,s.style.height=`${Math.min(s.scrollHeight,200)}px`)})}}),setTimeout(()=>i(null),6e3),requestAnimationFrame(()=>{s.style.height=`auto`,s.style.height=`${Math.min(s.scrollHeight,200)}px`;let e=u.length+f.length;s.setSelectionRange(e,e)});return}if(a.length>800){let e=a.split(`
115
- `).length;i({chars:a.length,lines:e}),setTimeout(()=>i(null),4e3)}},pasteHint:r,pendingImageRef:s,pendingImage:c,clearPendingImage:()=>u(null),setPasteHint:i}}function Up({original:e,refined:t,english:n,onDecision:r,autoSendDelayMs:a=0}){let o=J(e=>e.setRefinePanel),{t:s}=V(),[c,l]=(0,U.useState)(a>0?Math.ceil(a/1e3):null),[u,d]=(0,U.useState)(t),[f,p]=(0,U.useState)(!1),m=(0,U.useRef)(null),h=(0,U.useRef)(null);(0,U.useEffect)(()=>{if(!(a<=0||f))return m.current=setInterval(()=>{l(e=>e===null||e<=1?(clearInterval(m.current),r(`refined`),null):e-1)},1e3),()=>{m.current&&clearInterval(m.current)}},[a,f,r]),(0,U.useEffect)(()=>{let e=e=>{if(!(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement))switch(e.key){case`Enter`:f||(e.preventDefault(),r(`refined`));break;case`e`:case`E`:f||(e.preventDefault(),r(`english`));break;case`o`:case`O`:f||(e.preventDefault(),r(`original`));break;case`t`:case`T`:f||(e.preventDefault(),p(!0));break;case`Escape`:e.preventDefault(),f?(p(!1),d(t)):(o(null),r(`original`));break}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[f,r,t,o]),(0,U.useEffect)(()=>{f&&h.current&&h.current.querySelector(`textarea`)?.focus()},[f]);let g=e=>{m.current&&clearInterval(m.current),o(null),r(e)};return(0,Y.jsxs)(`div`,{ref:h,className:`rounded-lg border bg-card text-card-foreground shadow-sm overflow-hidden animate-message`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b bg-muted/30`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-medium`,children:s(`activity:refine.header`)}),c!==null&&!f&&(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:s(`activity:refine.autoSend`,{count:c})})]}),(0,Y.jsx)(`button`,{onClick:()=>g(`original`),className:`text-muted-foreground hover:text-foreground transition-colors`,title:s(`activity:refine.cancelTitle`),children:(0,Y.jsx)(Xn,{className:`h-4 w-4`})})]}),(0,Y.jsx)(`div`,{className:`p-4 space-y-3`,children:f?(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(`label`,{className:`text-xs text-muted-foreground font-medium`,children:s(`activity:refine.editLabel`)}),(0,Y.jsx)(`textarea`,{value:u,onChange:e=>d(e.target.value),className:`w-full min-h-[80px] rounded-md border border-input bg-background px-3 py-2 text-sm resize-none focus:outline-none focus:ring-2 focus:ring-ring`,placeholder:s(`activity:refine.editPlaceholder`)}),(0,Y.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,Y.jsx)($,{variant:`outline`,size:`sm`,onClick:()=>{p(!1),d(t)},children:s(`common:action.cancel`)}),(0,Y.jsxs)($,{size:`sm`,onClick:()=>{u.trim()&&g(`edit`)},disabled:!u.trim(),children:[(0,Y.jsx)(z,{className:`h-3 w-3 mr-1`}),s(`activity:refine.useEdit`)]})]})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground font-medium uppercase tracking-wider`,children:s(`activity:refine.original`)}),(0,Y.jsx)(`div`,{className:`text-sm text-muted-foreground bg-muted/30 rounded-md px-3 py-2`,children:e.length>200?e.slice(0,200)+`...`:e})]}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-yellow-600 dark:text-yellow-400 font-medium uppercase tracking-wider`,children:[s(`activity:refine.refined`),` `,(0,Y.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:s(`activity:refine.yourLanguage`)})]}),(0,Y.jsx)(`div`,{className:X(`text-sm bg-yellow-500/10 border border-yellow-500/20 rounded-md px-3 py-2 cursor-pointer`,`hover:bg-yellow-500/20 transition-colors`),onClick:()=>g(`refined`),title:s(`activity:refine.refinedTitle`),children:t.length>300?t.slice(0,300)+`...`:t})]}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400 font-medium uppercase tracking-wider`,children:[(0,Y.jsx)($e,{className:`h-3 w-3`}),s(`activity:refine.english`)]}),(0,Y.jsx)(`div`,{className:X(`text-sm bg-blue-500/10 border border-blue-500/20 rounded-md px-3 py-2 cursor-pointer`,`hover:bg-blue-500/20 transition-colors`),onClick:()=>g(`english`),title:s(`activity:refine.englishTitle`),children:n.length>300?n.slice(0,300)+`...`:n})]})]})}),!f&&(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-4 py-3 border-t bg-muted/20`,children:[(0,Y.jsxs)(`div`,{className:`flex gap-1 text-xs text-muted-foreground`,children:[(0,Y.jsx)(`kbd`,{className:`px-1.5 py-0.5 rounded bg-muted border font-mono`,children:`Enter`}),(0,Y.jsx)(`span`,{children:s(`activity:refine.hintRefined`)}),(0,Y.jsx)(`kbd`,{className:`px-1.5 py-0.5 rounded bg-muted border font-mono ml-2`,children:`e`}),(0,Y.jsx)(`span`,{children:s(`activity:refine.hintEnglish`)}),(0,Y.jsx)(`kbd`,{className:`px-1.5 py-0.5 rounded bg-muted border font-mono ml-2`,children:`o`}),(0,Y.jsx)(`span`,{children:s(`activity:refine.hintOriginal`)}),(0,Y.jsx)(`kbd`,{className:`px-1.5 py-0.5 rounded bg-muted border font-mono ml-2`,children:`t`}),(0,Y.jsx)(`span`,{children:s(`activity:refine.hintEdit`)})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsxs)($,{variant:`ghost`,size:`sm`,onClick:()=>g(`original`),className:`text-xs`,children:[(0,Y.jsx)(Xn,{className:`h-3 w-3 mr-1`}),s(`activity:refine.original`)]}),(0,Y.jsxs)($,{variant:`outline`,size:`sm`,onClick:()=>p(!0),className:`text-xs`,children:[(0,Y.jsx)(i,{className:`h-3 w-3 mr-1`}),s(`activity:refine.edit`)]}),(0,Y.jsxs)($,{size:`sm`,onClick:()=>g(`refined`),className:`text-xs bg-yellow-600 hover:bg-yellow-700 text-white`,children:[(0,Y.jsx)(z,{className:`h-3 w-3 mr-1`}),s(`activity:refine.useRefined`)]})]})]})]})}var Wp={builtin:`📦`,user:`👤`,project:`📁`,synced:`☁`},Gp={title:``,description:``,category:``,tagsCsv:``,content:``,vars:[]};function Kp(e,t){return e.replace(/\{\{\s*([\w.-]+)\s*\}\}/g,(e,n)=>Object.hasOwn(t,n.trim())&&t[n.trim()]?t[n.trim()]:e)}function qp(){let{t:e}=V(),{client:t}=sd(),n=J(e=>e.promptLibraryOpen),r=J(e=>e.setPromptLibraryOpen),i=J(e=>e.requestPromptInsert),[a,o]=(0,U.useState)([]),[s,c]=(0,U.useState)([]),[l,u]=(0,U.useState)(``),[d,f]=(0,U.useState)(null),[p,m]=(0,U.useState)(!1),[h,g]=(0,U.useState)(!1),[_,v]=(0,U.useState)([]),[y,x]=(0,U.useState)(null),[S,C]=(0,U.useState)(``),[w,T]=(0,U.useState)({}),E=(0,U.useRef)(null),[D,O]=(0,U.useState)(!1),[k,A]=(0,U.useState)(Gp),[j,M]=(0,U.useState)(null);(0,U.useEffect)(()=>{if(!n||!t)return;let e=e=>{let t=e.payload;o(t.prompts??[]),c(t.categories??[])};return t.on(`prompts.list`,e),t.send({type:`prompts.list`}),setTimeout(()=>E.current?.focus(),50),()=>t.off(`prompts.list`,e)},[n,t]),(0,U.useEffect)(()=>{if(!y||!t)return;C(``),T(Object.fromEntries((y.variables??[]).map(e=>[e.name,e.default??``])));let e=e=>{let t=e.payload;t.slug===y.slug&&t.found&&C(t.content)};return t.on(`prompts.content`,e),t.send({type:`prompts.content`,payload:{slug:y.slug}}),()=>t.off(`prompts.content`,e)},[y,t]),(0,U.useEffect)(()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n,r]),(0,U.useEffect)(()=>{if(!n||!t||!h)return;let e=e=>{v(e.payload.slugs??[])};return t.on(`prompts.recent`,e),t.send({type:`prompts.recent`}),()=>t.off(`prompts.recent`,e)},[n,t,h]);let N=(0,U.useMemo)(()=>{let e=l.trim().toLowerCase(),t=t=>!e||t.title.toLowerCase().includes(e)||t.description.toLowerCase().includes(e)||t.slug.includes(e)||t.tags.some(t=>t.toLowerCase().includes(e));if(h){let e=new Map(a.map(e=>[e.slug,e]));return _.map(t=>e.get(t)).filter(e=>!!e).filter(t)}return a.filter(e=>p&&!e.favorite||d&&e.category!==d?!1:t(e))},[a,l,d,p,h,_]),P=(0,U.useMemo)(()=>(y?.variables??[]).filter(e=>e.required&&!w[e.name]).map(e=>e.name),[y,w]),F=(0,U.useCallback)(()=>{!y||!S||(t?.send({type:`prompts.used`,payload:{slug:y.slug}}),i(Kp(S,w)))},[y,S,w,i,t]),I=(0,U.useCallback)(e=>{t&&(t.send({type:`prompts.favorite`,payload:{slug:e.slug,favorite:!e.favorite}}),o(t=>t.map(t=>t.slug===e.slug?{...t,favorite:!t.favorite}:t)))},[t]);(0,U.useEffect)(()=>{if(!n||!t)return;let e=e=>{let n=e.payload;n.success?(O(!1),A(Gp),M(null),t.send({type:`prompts.list`})):M(n.error??b.t(`activity:promptLib.saveFailed`))};return t.on(`prompts.created`,e),()=>t.off(`prompts.created`,e)},[n,t]);let L=(0,U.useCallback)(()=>{if(!t)return;if(!k.title.trim()||!k.content.trim()){M(b.t(`activity:promptLib.titleContentRequired`));return}let e=k.vars.filter(e=>e.name.trim()).map(e=>{let t=e.enumCsv.split(`,`).map(e=>e.trim()).filter(Boolean);return{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},required:e.required,...e.multiline?{multiline:!0}:{},...t.length>0?{enum:t}:{}}});t.send({type:`prompts.create`,payload:{title:k.title.trim(),content:k.content,description:k.description.trim(),category:k.category.trim()||void 0,tags:k.tagsCsv.split(`,`).map(e=>e.trim()).filter(Boolean),...e.length>0?{variables:e}:{}}})},[t,k]);return n?(0,Y.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4`,onClick:()=>r(!1),children:(0,Y.jsxs)(`div`,{className:`flex h-[80dvh] min-h-0 min-w-0 w-full max-w-4xl overflow-hidden rounded-lg border border-border bg-popover shadow-xl`,onClick:e=>e.stopPropagation(),children:[(0,Y.jsxs)(`div`,{className:`flex min-h-0 min-w-0 w-1/2 flex-col border-r border-border`,children:[(0,Y.jsxs)(`div`,{className:`border-b border-border p-3`,children:[(0,Y.jsx)(`input`,{ref:E,value:l,onChange:e=>u(e.target.value),placeholder:e(`activity:promptLib.searchPlaceholder`),className:`w-full rounded border border-border bg-background px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-primary`}),(0,Y.jsx)(`button`,{onClick:()=>{O(!0),x(null),M(null),A(Gp)},className:`mt-2 w-full rounded border border-dashed border-border px-2 py-1 text-xs text-muted-foreground hover:bg-accent hover:text-foreground`,children:e(`activity:promptLib.newPrompt`)}),(0,Y.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[(0,Y.jsx)(`button`,{onClick:()=>{f(null),m(!1),g(!1)},className:`rounded px-2 py-0.5 text-xs ${d===null&&!p&&!h?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-accent`}`,children:e(`activity:promptLib.all`)}),(0,Y.jsx)(`button`,{onClick:()=>{g(e=>!e),m(!1),f(null)},className:`rounded px-2 py-0.5 text-xs ${h?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-accent`}`,children:e(`activity:promptLib.recent`)}),(0,Y.jsx)(`button`,{onClick:()=>{m(e=>!e),g(!1),f(null)},className:`rounded px-2 py-0.5 text-xs ${p?`bg-yellow-500 text-black`:`bg-muted text-muted-foreground hover:bg-accent`}`,children:e(`activity:promptLib.favorites`)}),s.map(e=>(0,Y.jsxs)(`button`,{onClick:()=>{f(e.id),g(!1),m(!1)},className:`rounded px-2 py-0.5 text-xs ${d===e.id?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-accent`}`,children:[e.label,` (`,e.count,`)`]},e.id))]})]}),(0,Y.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-auto`,children:[N.map(e=>(0,Y.jsxs)(`button`,{onClick:()=>x(e),className:`flex w-full flex-col items-start gap-0.5 border-b border-border/50 px-3 py-2 text-left hover:bg-accent ${y?.slug===e.slug?`bg-accent`:``}`,children:[(0,Y.jsxs)(`div`,{className:`flex w-full items-center gap-1 text-sm`,children:[(0,Y.jsx)(`span`,{children:Wp[e.source]??`•`}),(0,Y.jsx)(`span`,{className:`font-medium`,children:e.title}),e.favorite&&(0,Y.jsx)(`span`,{className:`text-yellow-500`,children:`★`})]}),(0,Y.jsx)(`div`,{className:`line-clamp-1 text-xs text-muted-foreground`,children:e.description})]},e.slug)),N.length===0&&(0,Y.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:e(`activity:promptLib.noMatch`)})]})]}),(0,Y.jsx)(`div`,{className:`flex min-h-0 min-w-0 w-1/2 flex-col`,children:D?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border p-3`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-semibold`,children:e(`activity:promptLib.newPromptHeading`)}),(0,Y.jsx)(`button`,{onClick:()=>{O(!1),M(null)},className:`text-xs text-muted-foreground hover:text-foreground`,children:e(`common:action.cancel`)})]}),(0,Y.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 space-y-2 overflow-auto p-3 text-xs`,children:[(0,Y.jsx)(`input`,{value:k.title,onChange:e=>A(t=>({...t,title:e.target.value})),placeholder:e(`activity:promptLib.titlePlaceholder`),className:`w-full rounded border border-border bg-background px-2 py-1 outline-none`}),(0,Y.jsx)(`input`,{value:k.description,onChange:e=>A(t=>({...t,description:e.target.value})),placeholder:e(`activity:promptLib.descPlaceholder`),className:`w-full rounded border border-border bg-background px-2 py-1 outline-none`}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`input`,{list:`prompt-category-list`,value:k.category,onChange:e=>A(t=>({...t,category:e.target.value})),placeholder:e(`activity:promptLib.categoryPlaceholder`),className:`w-1/2 rounded border border-border bg-background px-2 py-1 outline-none`}),(0,Y.jsx)(`datalist`,{id:`prompt-category-list`,children:s.map(e=>(0,Y.jsx)(`option`,{value:e.id},e.id))}),(0,Y.jsx)(`input`,{value:k.tagsCsv,onChange:e=>A(t=>({...t,tagsCsv:e.target.value})),placeholder:e(`activity:promptLib.tagsPlaceholder`),className:`w-1/2 rounded border border-border bg-background px-2 py-1 outline-none`})]}),(0,Y.jsx)(`textarea`,{value:k.content,onChange:e=>A(t=>({...t,content:e.target.value})),placeholder:e(`activity:promptLib.contentPlaceholder`),rows:6,className:`w-full resize-y rounded border border-border bg-background px-2 py-1 font-mono outline-none`}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between pt-1`,children:[(0,Y.jsx)(`span`,{className:`font-semibold text-muted-foreground`,children:e(`activity:promptLib.variables`)}),(0,Y.jsx)(`button`,{onClick:()=>A(e=>({...e,vars:[...e.vars,{name:``,description:``,required:!0,multiline:!1,enumCsv:``}]})),className:`rounded border border-border px-1.5 py-0.5 hover:bg-accent`,children:e(`activity:promptLib.addVar`)})]}),k.vars.map((t,n)=>(0,Y.jsxs)(`div`,{className:`space-y-1 rounded border border-border/60 p-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Y.jsx)(`input`,{value:t.name,onChange:e=>A(t=>({...t,vars:t.vars.map((t,r)=>r===n?{...t,name:e.target.value}:t)})),placeholder:e(`activity:promptLib.varNamePlaceholder`),className:`w-1/3 rounded border border-border bg-background px-1.5 py-0.5 outline-none`}),(0,Y.jsx)(`input`,{value:t.description,onChange:e=>A(t=>({...t,vars:t.vars.map((t,r)=>r===n?{...t,description:e.target.value}:t)})),placeholder:e(`activity:promptLib.varDescPlaceholder`),className:`flex-1 rounded border border-border bg-background px-1.5 py-0.5 outline-none`}),(0,Y.jsx)(`button`,{onClick:()=>A(e=>({...e,vars:e.vars.filter((e,t)=>t!==n)})),className:`rounded border border-border px-1.5 text-muted-foreground hover:bg-accent`,title:e(`activity:promptLib.removeVarTitle`),children:`✕`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsxs)(`label`,{className:`flex items-center gap-1 text-muted-foreground`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:t.required,onChange:e=>A(t=>({...t,vars:t.vars.map((t,r)=>r===n?{...t,required:e.target.checked}:t)}))}),e(`activity:promptLib.required`)]}),(0,Y.jsxs)(`label`,{className:`flex items-center gap-1 text-muted-foreground`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:t.multiline,onChange:e=>A(t=>({...t,vars:t.vars.map((t,r)=>r===n?{...t,multiline:e.target.checked}:t)}))}),e(`activity:promptLib.multiline`)]}),(0,Y.jsx)(`input`,{value:t.enumCsv,onChange:e=>A(t=>({...t,vars:t.vars.map((t,r)=>r===n?{...t,enumCsv:e.target.value}:t)})),placeholder:e(`activity:promptLib.enumPlaceholder`),className:`flex-1 rounded border border-border bg-background px-1.5 py-0.5 outline-none`})]})]},n))]}),(0,Y.jsxs)(`div`,{className:`border-t border-border p-3`,children:[j&&(0,Y.jsx)(`div`,{className:`mb-2 text-xs text-red-500`,children:j}),(0,Y.jsx)(`button`,{onClick:L,disabled:!k.title.trim()||!k.content.trim(),className:`w-full rounded bg-primary px-3 py-2 text-sm text-primary-foreground disabled:opacity-50`,children:e(`activity:promptLib.savePrompt`)})]})]}):y?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-between border-b border-border p-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`text-sm font-semibold`,children:y.title}),(0,Y.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[y.category,` · `,y.slug]})]}),(0,Y.jsx)(`button`,{onClick:()=>I(y),className:`text-lg`,title:e(`activity:promptLib.toggleFavoriteTitle`),children:y.favorite?`★`:`☆`})]}),(0,Y.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-auto p-3`,children:[(0,Y.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-xs text-foreground`,children:S||`…`}),(y.variables??[]).length>0&&(0,Y.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground`,children:e(`activity:promptLib.variables`)}),y.variables.map(t=>{let n=(0,Y.jsxs)(`label`,{className:`text-xs text-muted-foreground`,children:[t.name,t.required?` *`:``,t.description?` — ${t.description}`:``]}),r=e=>T(n=>({...n,[t.name]:e})),i=`mt-0.5 w-full rounded border border-border bg-background px-2 py-1 text-xs outline-none`;return t.enum&&t.enum.length>0?(0,Y.jsxs)(`div`,{children:[n,(0,Y.jsxs)(`select`,{value:w[t.name]??``,onChange:e=>r(e.target.value),className:i,children:[(0,Y.jsx)(`option`,{value:``,children:e(`activity:promptLib.selectOption`)}),t.enum.map(e=>(0,Y.jsx)(`option`,{value:e,children:e},e))]})]},t.name):t.multiline?(0,Y.jsxs)(`div`,{children:[n,(0,Y.jsx)(`textarea`,{value:w[t.name]??``,onChange:e=>r(e.target.value),rows:4,className:`${i} resize-y font-mono`})]},t.name):(0,Y.jsxs)(`div`,{children:[n,(0,Y.jsx)(`input`,{value:w[t.name]??``,onChange:e=>r(e.target.value),className:i})]},t.name)})]})]}),(0,Y.jsx)(`div`,{className:`border-t border-border p-3`,children:(0,Y.jsx)(`button`,{onClick:F,disabled:!S||P.length>0,className:`w-full rounded bg-primary px-3 py-2 text-sm text-primary-foreground disabled:opacity-50`,children:P.length>0?e(`activity:promptLib.fillMissing`,{missing:P.join(`, `)}):e(`activity:promptLib.insertIntoChat`)})})]}):(0,Y.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-4 text-sm text-muted-foreground`,children:e(`activity:promptLib.selectPromptHint`)})})]})}):null}function Jp({onOpenBreakdown:e}={}){let{isLoading:t,setLoading:n,addMessage:r,clearMessages:i}=G(),a=G(e=>e.messages).length>0,o=G(e=>e.queue),s=G(e=>e.enqueue),c=G(e=>e.removeQueued),l=G(e=>e.clearQueue),{setCurrentView:u}=J(),d=J(e=>e.pushPrompt),f=J(e=>e.promptHistory),p=sd(),{sendMessage:m,sendAbort:h,client:g,refineModel:_}=p,{t:v}=V(),y=J(e=>e.refineEnabled),b=J(e=>e.refinePanel),x=J(e=>e.promptInsertRequest),S=J(e=>e.clearPromptInsert),C=J(e=>e.toggleRefineEnabled),w=J(e=>e.setRefinePanel),T=J(e=>e.setProcessMonitorOpen),E=J(e=>e.setQueuePanelOpen),{reset:D}=gp(),O=q(e=>e.lastInputTokens),k=q(e=>e.maxContext),[A,j]=(0,U.useState)(``),[M,N]=(0,U.useState)(0),[P,F]=(0,U.useState)(-1),[I,L]=(0,U.useState)(null),R=(0,U.useRef)(null),ee=lc(e=>e.refs),{removeRef:te,clearRefs:ne}=lc.getState(),re=ee.length>0,{draggingOver:ie,onDragEnter:oe,onDragLeave:se,onDragOver:ce,onDrop:le,onTextPaste:ue,pasteHint:de,pendingImageRef:fe,pendingImage:pe,clearPendingImage:me,setPasteHint:he}=Hp({input:A,textareaRef:R,setInput:j});(0,U.useEffect)(()=>{x!=null&&(j(e=>e.trim()?`${e}\n${x}`:x),S(),requestAnimationFrame(()=>R.current?.focus()))},[x,S]);let _e=(0,U.useCallback)(t=>Mp({raw:t,addMessage:r,clearMessages:i,client:g,queue:o,sendAbort:h,sendMsg:be,setLoading:n,setCurrentView:u,toggleRefineEnabled:C,setProcessMonitorOpen:T,setQueuePanelOpen:E,ws:p,onOpenBreakdown:e,handleNextList:xe,handleNextSelect:Se}),[r,i,g,o,h,n,u,C,T,E,p,e]),ve=/💡\s*Next steps?\s*\n+((?:\d+\.\s+.+\n?)+)/i;function ye(e){let t=ve.exec(e);if(!t?.[1])return[];let n=[];for(let e of t[1].split(`
116
- `).filter(Boolean)){let t=/^(\d+)\.\s+(.+)$/.exec(e.trim());t&&n.push({index:Number.parseInt(t[1],10),text:t[2].trim()})}return n.slice(0,6)}function z(){let e=G.getState().messages;for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.role===`assistant`&&n.content)return ye(n.content)}return[]}function be(e){if(t){s(e);return}r({role:`user`,content:e}),m(e)&&n(!0)}function xe(){let e=G.getState().messages,t=``;for(let n=e.length-1;n>=0;n--){let r=e[n];if(r?.role===`assistant`&&r.content){t=r.content;break}}let n=ye(t);if(n.length===0)return r({role:`assistant`,content:"💡 _No next-step suggestions found. Use `/suggest` to generate some._"}),!0;let i=[`💡 **Next steps**`,``];for(let e of n)i.push(`${e.index}. ${e.text}`);return i.push(``,"_Use `/next 1`, `/next 1 2 3` to execute._"),r({role:`assistant`,content:i.join(`
117
- `)}),!0}function Se(e){let t=z();if(t.length===0)return r({role:`assistant`,content:"💡 _No suggestions available. Use `/suggest` first._"}),!0;let n=e.split(/[\s,]+/).filter(Boolean).map(e=>Number.parseInt(e,10)).filter(e=>!Number.isNaN(e)&&e>0);if(n.length===0)return r({role:`assistant`,content:`💡 _No valid suggestion numbers._`}),!0;let i=n.filter(e=>e>t.length);if(i.length>0)return r({role:`assistant`,content:`💡 _Invalid suggestion(s): ${i.join(`, `)}. Valid range: 1–${t.length}._`}),!0;for(let e of n){let n=t[e-1];n&&be(n.text)}return!0}let Ce=A.startsWith(`/`)&&!A.includes(` `)?Cp(A):[];(0,U.useEffect)(()=>{M>=Ce.length&&N(0)},[Ce.length,M]);let we=(0,U.useCallback)(()=>{let e=R.current;e&&(e.value=``,e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`,t||e.focus())},[t]),Te=(0,U.useCallback)(async e=>{if(D(),!A.trim()&&!fe.current&&ee.length===0)return;let i=fe.current;me();let a=A.trim(),o=[a,cc(ee)].filter(Boolean).join(`
118
-
119
- `);if(ne(),a.startsWith(`/`)&&_e(a)){d(a),j(``),F(-1),we();return}j(``),F(-1),we(),d(a),we();let c=i?`![pasted image](${i})\n\n${o}`:o;if(e===`queue`){s(c,`queue`);return}let l=e===`steer`&&t;if(e===`btw`&&t){s(c,`btw`);return}l&&h();try{g?.isConnected?y&&_?(w({original:o,refined:o,english:o,resolve:e=>{}}),_(o)):(r({role:`user`,content:c}),n(!0),m(o,i??void 0)):console.warn(JSON.stringify({level:`warn`,event:`ws_send_failed`,reason:`not_connected`,timestamp:new Date().toISOString()}))}catch(e){console.warn(JSON.stringify({level:`warn`,event:`ws_send_error`,error:Gr(e),timestamp:new Date().toISOString()})),n(!1)}},[A,ee,t,s,g,m,h,_,y,w,r,n,_e,d,we,D,me,fe]),Ee=(0,U.useCallback)(e=>{e.preventDefault(),Te(`btw`)},[Te]),De=(0,U.useCallback)(()=>{Te(`btw`)},[Te]),Oe=(0,U.useCallback)(()=>{Te(`steer`)},[Te]),ke=(0,U.useCallback)(()=>{Te(`queue`)},[Te]),Ae=(0,U.useCallback)(()=>{h(),n(!1)},[h,n]),je=(0,U.useCallback)(()=>{h(),n(!1);let e=G.getState().messages;for(let t=e.length-1;t>=0;t--){let n=Ur(e[t]);if(n.role===`user`&&n.content){j(n.content),requestAnimationFrame(()=>{let e=R.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`,e.focus(),e.setSelectionRange(n.content.length,n.content.length))});return}}},[h,n]),Me=(0,U.useCallback)(e=>{if(Ce.length===0&&!I&&f.length>0){if(e.key===`ArrowUp`){let t=e.currentTarget,n=t.value.slice(0,t.selectionStart);if(P>=0||n.indexOf(`
120
- `)===-1){e.preventDefault();let t=Math.min(f.length-1,P+1);F(t);let n=f[t]??``;j(n),requestAnimationFrame(()=>{let e=R.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`,e.setSelectionRange(n.length,n.length))});return}}if(e.key===`ArrowDown`&&P>=0){e.preventDefault();let t=P-1;if(t<0)F(-1),j(``);else{F(t);let e=f[t]??``;j(e),requestAnimationFrame(()=>{let t=R.current;t&&(t.style.height=`auto`,t.style.height=`${Math.min(t.scrollHeight,200)}px`,t.setSelectionRange(e.length,e.length))})}return}}if(Ce.length>0){if(e.key===`ArrowDown`){e.preventDefault(),N(e=>(e+1)%Ce.length);return}if(e.key===`ArrowUp`){e.preventDefault(),N(e=>(e-1+Ce.length)%Ce.length);return}if(e.key===`Tab`){e.preventDefault();let t=Ce[M];t&&(j(t.name+` `),N(0));return}if(e.key===`Enter`&&!e.shiftKey){let t=Ce[M];if(t&&t.name!==A.toLowerCase().trim()){e.preventDefault(),j(``),_e(t.name);return}}if(e.key===`Escape`){e.preventDefault(),j(``);return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Ee(e))},[Ce,M,I,f,P,A,_e,Ee]),Ne=()=>{let e=R.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`)};return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(qp,{}),de&&(0,Y.jsxs)(`div`,{className:X(`rounded-md border px-2.5 py-1.5 text-xs flex items-center justify-between gap-2 animate-message`,de.lang?`border-emerald-500/30 bg-emerald-500/5 text-emerald-700 dark:text-emerald-300`:`border-amber-500/30 bg-amber-500/5 text-amber-700 dark:text-amber-300`),children:[(0,Y.jsx)(`span`,{children:de.lang?(0,Y.jsxs)(Y.Fragment,{children:[v(`chat:input.autoFencedAs`),` `,(0,Y.jsx)(`span`,{className:`font-mono font-semibold`,children:de.lang}),` — `,(0,Y.jsx)(`span`,{className:`font-mono tabular-nums`,children:de.chars.toLocaleString()}),` `,v(`chat:input.charsWord`),` (`,(0,Y.jsx)(`span`,{className:`font-mono tabular-nums`,children:de.lines}),` `,v(`chat:input.linesWord`),`)`]}):(0,Y.jsxs)(Y.Fragment,{children:[v(`chat:input.pastedWord`),` `,(0,Y.jsx)(`span`,{className:`font-mono tabular-nums`,children:de.chars.toLocaleString()}),` `,v(`chat:input.charsWord`),` (`,(0,Y.jsx)(`span`,{className:`font-mono tabular-nums`,children:de.lines}),` `,v(`chat:input.linesWord`),`) `,v(`chat:input.fencedHintPrefix`),` `,(0,Y.jsx)(`span`,{className:`font-mono`,children:"```"}),`.`]})}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[de.undoFence&&(0,Y.jsx)(`button`,{type:`button`,onClick:de.undoFence,className:`underline underline-offset-2 hover:opacity-80`,title:v(`chat:input.removeFencesTitle`),children:v(`common:action.undo`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>he(null),className:`opacity-60 hover:opacity-100 shrink-0`,title:v(`chat:input.dismissTitle`),children:`×`})]})]}),pe&&(0,Y.jsxs)(`div`,{className:`mb-2 inline-flex items-center gap-2 rounded-lg border border-border bg-muted/40 px-2 py-1.5`,children:[(0,Y.jsx)(`img`,{src:pe,alt:v(`chat:input.pendingAttachmentAlt`),className:`h-12 w-12 rounded object-cover border border-border/50`}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:v(`chat:input.imageAttached`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:me,title:v(`chat:input.removeImageTitle`),className:`inline-flex items-center justify-center h-5 w-5 rounded text-muted-foreground hover:bg-muted hover:text-foreground transition-colors`,children:`×`})]}),(0,Y.jsx)(bp,{queue:o,onClear:l,onRemove:c}),b&&(0,Y.jsx)(Up,{original:b.original,refined:b.refined,english:b.english,onDecision:e=>{let{original:t,refined:i,english:a}=b,o=t;if(e===`refined`?o=i:e===`english`?o=a:e===`edit`&&(o=i),e===`edit`){j(i);return}w(null),g?.isConnected&&(r({role:`user`,content:o}),n(!0),m(o))}}),re&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-1`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground shrink-0`,children:v(`chat:input.referencesLabel`)}),ee.map(e=>(0,Y.jsx)(pp,{ref:e,onRemove:()=>te(e.id)},e.id)),(0,Y.jsx)(`button`,{type:`button`,onClick:ne,className:`text-[10px] text-muted-foreground hover:text-foreground underline underline-offset-2 shrink-0`,children:v(`chat:input.clearAll`)})]}),(0,Y.jsxs)(`form`,{onSubmit:Ee,onDragEnter:oe,onDragOver:ce,onDragLeave:se,onDrop:le,className:X(`flex items-end gap-2 relative rounded-lg transition-colors`,ie&&`ring-2 ring-primary ring-offset-2 ring-offset-background bg-primary/5`),children:[ie&&(0,Y.jsxs)(`div`,{className:`absolute inset-0 z-20 flex items-center justify-center pointer-events-none rounded-lg bg-primary/10 text-primary text-sm font-medium`,children:[`Drop file`,`(s)`,` to attach as @-mention`]}),(0,Y.jsxs)(`div`,{className:`relative flex-1`,children:[(0,Y.jsx)(vp,{atMention:I,input:A,textareaRef:R,setInput:j,setAtMention:L}),!I&&Ce.length>0&&(()=>{let e={};Ce.forEach((t,n)=>{e[t.category]||(e[t.category]=[]),e[t.category]?.push({cmd:t,idx:n})});let t=Sp.filter(t=>e[t]?.length);return(0,Y.jsxs)(`div`,{className:`absolute bottom-full left-0 right-0 mb-2 rounded-lg border bg-popover shadow-md p-1 text-sm max-h-72 overflow-auto`,children:[(0,Y.jsx)(`div`,{className:`px-3 py-1 text-[10px] uppercase tracking-wider text-muted-foreground border-b mb-1`,children:`↑/↓ select · Tab complete · Enter dispatch · Esc dismiss`}),t.map(t=>(0,Y.jsxs)(`div`,{className:`mb-1`,children:[(0,Y.jsx)(`div`,{className:`px-3 pt-1 pb-0.5 text-[10px] uppercase tracking-wider text-muted-foreground/70 font-semibold`,children:t}),e[t]?.map(({cmd:e,idx:t})=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{j(``),_e(e.name)},onMouseEnter:()=>N(t),className:X(`w-full text-left px-3 py-1.5 rounded transition-colors flex items-center gap-3`,t===M?`bg-accent text-accent-foreground`:`hover:bg-accent/40`),children:[(0,Y.jsx)(`span`,{className:`font-mono shrink-0`,children:e.name}),e.aliases?.length?(0,Y.jsxs)(`span`,{className:`text-xs text-muted-foreground/70 font-mono shrink-0`,children:[`(`,e.aliases.join(`, `),`)`]}):null,(0,Y.jsxs)(`span`,{className:`text-xs text-muted-foreground truncate`,children:[`— `,e.description]})]},e.name))]},t))]})})(),(0,Y.jsx)(`textarea`,{ref:R,value:A,onChange:e=>{let t=e.target.value;j(t),Ne(),P>=0&&F(-1),L(wp(t,e.target.selectionStart??t.length))},onSelect:e=>{let t=e.currentTarget;L(wp(t.value,t.selectionStart))},onKeyDown:Me,onPaste:ue,placeholder:g?.isConnected?v(t?`chat:inputPlaceholderLoading`:`chat:inputPlaceholder`):v(`chat:inputPlaceholderConnecting`),className:X(`flex min-h-[44px] w-full resize-none rounded-lg border border-input bg-background px-4 py-3 pr-12`,`text-sm ring-offset-background placeholder:text-muted-foreground`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,`disabled:cursor-not-allowed disabled:opacity-50`,`scrollbar-thin`),rows:1,disabled:!g?.isConnected}),A.length>0&&(()=>{let e=A.length>=400,t=Math.ceil(A.length/4),n=`text-muted-foreground`,r;if(k>0&&e){let e=(O+t+64)/k*100;e>=100?(n=`text-red-600 dark:text-red-400 font-medium`,r=`Projected ${Math.round(e)}% of ${k.toLocaleString()} ctx — will likely error or compact.`):e>=85?(n=`text-amber-600 dark:text-amber-400 font-medium`,r=`Projected ${Math.round(e)}% of ${k.toLocaleString()} ctx — getting tight.`):r=`≈ ${t.toLocaleString()} tokens · projected ${Math.round(e)}% of ${k.toLocaleString()} ctx.`}else e&&(r=`≈ ${t.toLocaleString()} tokens (4-char heuristic)`);return(0,Y.jsxs)(`span`,{className:X(`absolute bottom-1.5 right-12 text-xs tabular-nums`,n),title:r,children:[A.length,e&&(0,Y.jsxs)(`span`,{className:`ml-1 opacity-70`,children:[`· ≈`,t>=1e3?`${(t/1e3).toFixed(1)}k`:t,`t`]})]})})()]}),(0,Y.jsxs)(`div`,{className:`flex gap-1`,children:[t&&a?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)($,{type:`button`,size:`icon`,variant:`outline`,onClick:je,className:`h-[44px] w-[44px] rounded-lg`,title:v(`chat:input.stopEditTitle`),"data-testid":`stop-and-edit`,children:(0,Y.jsx)(zt,{className:`h-4 w-4`})}),(0,Y.jsx)($,{type:`button`,size:`icon`,variant:`destructive`,onClick:Ae,className:`h-[44px] w-[44px] rounded-lg`,title:v(`chat:input.abortTitle`),"data-testid":`stop`,children:(0,Y.jsx)(ae,{className:`h-4 w-4 fill-current`})})]}):(0,Y.jsx)($,{type:`button`,size:`icon`,variant:y?`default`:`outline`,disabled:!g?.isConnected,onClick:C,className:X(`h-[44px] w-[44px] rounded-lg transition-colors`,y&&`bg-yellow-500/20 hover:bg-yellow-500/30 text-yellow-600 dark:text-yellow-400 border-yellow-500/50`),title:v(y?`chat:input.refineEnabledTitle`:`chat:input.refineDisabledTitle`),children:(0,Y.jsx)(bt,{className:`h-4 w-4`})}),(0,Y.jsx)($,{type:`submit`,size:`icon`,variant:`default`,disabled:!A.trim()||!g?.isConnected,className:`h-[44px] w-[44px] rounded-lg bg-sky-600 hover:bg-sky-700 text-white dark:bg-sky-500 dark:hover:bg-sky-600`,title:v(`chat:sendTitle`),"data-testid":`send-submit`,children:(0,Y.jsx)(er,{className:`h-4 w-4`})}),a&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)($,{type:`button`,size:`icon`,variant:`default`,disabled:!A.trim()||!g?.isConnected,onClick:De,className:`h-[44px] w-[44px] rounded-lg bg-sky-600 hover:bg-sky-700 text-white dark:bg-sky-500 dark:hover:bg-sky-600`,title:v(t?`chat:input.btwRunningTitle`:`chat:input.btwIdleTitle`),"data-testid":`send-btw`,children:(0,Y.jsx)(ge,{className:`h-4 w-4`})}),(0,Y.jsx)($,{type:`button`,size:`icon`,variant:`outline`,disabled:!A.trim()||!g?.isConnected,onClick:Oe,className:`h-[44px] w-[44px] rounded-lg border-amber-500/50 text-amber-700 dark:text-amber-400 hover:bg-amber-500/10`,title:v(t?`chat:input.steerRunningTitle`:`chat:input.steerIdleTitle`),"data-testid":`send-steer`,children:(0,Y.jsx)(xt,{className:`h-4 w-4`})}),(0,Y.jsx)($,{type:`button`,size:`icon`,variant:`outline`,disabled:!A.trim()||!g?.isConnected,onClick:ke,className:`h-[44px] w-[44px] rounded-lg border-indigo-500/50 text-indigo-700 dark:text-indigo-400 hover:bg-indigo-500/10`,title:v(`chat:input.addQueueTitle`),"data-testid":`send-queue`,children:(0,Y.jsx)(wn,{className:`h-4 w-4`})})]})]})]})]})}function Yp({open:e,onClose:t,className:n}){let{t:r}=V(),[i,a]=(0,U.useState)([]),[o,s]=(0,U.useState)(!1),c=sd(),l=(0,U.useRef)(null);(0,U.useEffect)(()=>{if(!(!e||!c.client?.isConnected))return c.client.send?.({type:`session.checkpoints`}),l.current=c.client.on?.(`session.checkpoints`,e=>{let t=e?.payload;t?.checkpoints&&a(t.checkpoints)})??null,()=>{l.current?.()}},[e,c.client]);let u=(0,U.useCallback)(async e=>{s(!0),c.client.send?.({type:`session.rewind`,payload:{checkpointIndex:e}}),setTimeout(()=>{t(),s(!1)},800)},[c.client,t]);return e?(0,Y.jsx)(`div`,{className:X(`fixed inset-0 z-50 flex items-start justify-center pt-[10dvh] bg-black/40 backdrop-blur-sm`,n),onClick:e=>{e.target===e.currentTarget&&t()},children:(0,Y.jsxs)(`div`,{className:`w-full max-w-md rounded-xl border bg-card shadow-2xl max-h-[75dvh] flex flex-col animate-in fade-in zoom-in-95`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,Y.jsx)(`span`,{className:`flex items-center justify-center w-8 h-8 rounded-lg bg-violet-500/10 text-violet-600 dark:text-violet-400`,children:(0,Y.jsx)(d,{className:`h-4 w-4`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold`,children:r(`activity:checkpoint.heading`)}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:r(`activity:checkpoint.countSuffix`,{count:i.length})})]})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:t,className:`p-1.5 rounded-md hover:bg-muted transition-colors`,children:(0,Y.jsx)(Xn,{className:`h-4 w-4`})})]}),(0,Y.jsx)(`div`,{className:`px-4 py-2.5 border-b bg-muted/20 text-[10px] text-muted-foreground leading-relaxed`,children:r(`activity:checkpoint.description`)}),(0,Y.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto`,children:i.length===0?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 gap-3 text-muted-foreground`,children:[(0,Y.jsx)(Ge,{className:`h-10 w-10 opacity-15`}),(0,Y.jsx)(`p`,{className:`text-sm font-medium`,children:r(`activity:checkpoint.emptyTitle`)}),(0,Y.jsx)(`p`,{className:`text-xs text-center max-w-xs`,children:r(`activity:checkpoint.emptyBody`)})]}):(0,Y.jsx)(`div`,{className:`py-1`,children:[...i].reverse().map((e,t)=>{let n=t===0;return(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>u(e.index),disabled:o,className:X(`w-full flex items-start gap-3 px-4 py-3 text-left transition-colors group`,n?`bg-primary/5 hover:bg-primary/10`:`hover:bg-accent/40`,o&&`opacity-50 pointer-events-none`),children:[(0,Y.jsxs)(`div`,{className:`flex flex-col items-center mt-1.5`,children:[(0,Y.jsx)(`div`,{className:X(`w-2.5 h-2.5 rounded-full border-2 shrink-0 transition-colors`,n?`border-primary bg-primary/20 shadow-[0_0_0_3px_hsl(var(--primary)/0.25)]`:`border-muted-foreground/30 bg-background group-hover:border-primary/40`)}),t<i.length-1&&(0,Y.jsx)(`div`,{className:`w-px flex-1 min-h-[20px] bg-border/50`})]}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsxs)(`span`,{className:`text-xs font-mono text-muted-foreground tabular-nums shrink-0`,children:[`#`,e.index]}),(0,Y.jsx)(`span`,{className:`text-xs font-medium truncate`,children:e.label}),n&&(0,Y.jsx)(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium shrink-0`,children:r(`activity:checkpoint.latest`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 text-[10px] text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`tabular-nums`,children:r(`activity:checkpoint.msgSuffix`,{count:e.messageCount})}),(0,Y.jsx)(`span`,{className:`opacity-50`,children:`·`}),(0,Y.jsxs)(`span`,{className:`tabular-nums`,children:[`~`,e.tokens.toLocaleString(),` tok`]}),(0,Y.jsx)(`span`,{className:`opacity-50`,children:`·`}),(0,Y.jsxs)(`span`,{className:`tabular-nums`,children:[`iter `,e.iteration]})]})]}),(0,Y.jsx)(`span`,{className:`shrink-0 mt-1.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,Y.jsx)(Jt,{className:`h-4 w-4 text-violet-500`})})]},e.index)})})}),(0,Y.jsxs)(`div`,{className:`border-t px-4 py-2 text-[10px] text-muted-foreground text-center shrink-0`,children:[r(`activity:checkpoint.footerPre`),` ·`,` `,(0,Y.jsx)(`kbd`,{className:`px-1 py-0.5 rounded bg-muted font-mono text-[9px]`,children:`Esc`}),` `,r(`activity:checkpoint.footerPost`)]})]})}):null}function Xp(){let{t:e}=V(),t=q(e=>e.contextMode),n=q(e=>e.contextModes),{listContextModes:r,switchContextMode:i,client:a}=sd(),[o,s]=(0,U.useState)(!1),[c,l]=(0,U.useState)(!1),u=(0,U.useRef)(null),d=(0,U.useRef)(null);(0,U.useEffect)(()=>{o&&r()},[o,r]),(0,U.useEffect)(()=>{if(!o)return;let e=e=>{u.current?.contains(e.target)||s(!1)},t=e=>{e.key===`Escape`&&s(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[o]),(0,U.useEffect)(()=>{if(!c)return;let e=e=>{d.current?.contains(e.target)||l(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[c]);let f=(0,U.useCallback)(e=>{a?.compactContext?.(e),l(!1),s(!1)},[a]),p=(0,U.useCallback)(()=>{a?.repairContext?.(),l(!1),s(!1)},[a]),m=n.length>0?n:[{id:`balanced`,name:e(`activity:ctxMode.fallbackName`),description:e(`activity:ctxMode.fallbackDesc`),thresholds:{warn:.6,soft:.75,hard:.9},preserveK:10,eliseThreshold:2e3}],h=m.find(e=>e.id===t)??Ur(m[0]);return(0,Y.jsxs)(`div`,{ref:u,className:`relative shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:X(`flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium`,`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300 hover:bg-emerald-500/15 transition-colors border border-transparent hover:border-emerald-500/30`),title:e(`activity:ctxMode.triggerTitle`),children:[(0,Y.jsx)(se,{className:`h-3 w-3`}),e(`activity:ctxMode.ctxPrefix`),` `,(0,Y.jsx)(`span`,{className:`font-mono`,children:t||h.id}),(0,Y.jsx)(bn,{className:`h-3 w-3 opacity-60`})]}),(0,Y.jsxs)(`div`,{ref:d,className:`relative`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),className:X(`flex items-center justify-center h-5 w-5 rounded-full`,`text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors`,c&&`bg-accent/50 text-foreground`),title:e(`activity:ctxMode.opsHeading`),children:(0,Y.jsx)(In,{className:`h-3 w-3`})}),c&&(0,Y.jsxs)(`div`,{className:`absolute top-full right-0 mt-1 w-52 rounded-md border bg-popover shadow-lg z-40 py-1`,children:[(0,Y.jsx)(`div`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wider text-muted-foreground border-b`,children:e(`activity:ctxMode.opsHeading`)}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>f(!1),className:`w-full text-left px-3 py-2 hover:bg-accent/40 flex items-center gap-2`,children:[(0,Y.jsx)(tn,{className:`h-3.5 w-3.5 shrink-0 text-amber-500`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`text-xs`,children:e(`activity:ctxMode.compactNow`)}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:e(`activity:ctxMode.compactNowDesc`)})]})]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>f(!0),className:`w-full text-left px-3 py-2 hover:bg-accent/40 flex items-center gap-2`,children:[(0,Y.jsx)(tn,{className:`h-3.5 w-3.5 shrink-0 text-red-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`text-xs`,children:e(`activity:ctxMode.compactAggressive`)}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:e(`activity:ctxMode.compactAggressiveDesc`)})]})]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:p,className:`w-full text-left px-3 py-2 hover:bg-accent/40 flex items-center gap-2`,children:[(0,Y.jsx)(In,{className:`h-3.5 w-3.5 shrink-0 text-blue-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`text-xs`,children:e(`activity:ctxMode.repairContext`)}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:e(`activity:ctxMode.repairDesc`)})]})]}),(0,Y.jsx)(`div`,{className:`border-t mt-1 pt-1 px-3 py-1.5`,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{document.dispatchEvent(new CustomEvent(`open:context-breakdown`)),l(!1),s(!1)},className:`w-full text-left px-3 py-2 hover:bg-accent/40 flex items-center gap-2`,children:[(0,Y.jsx)(At,{className:`h-3.5 w-3.5 shrink-0 text-green-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`text-xs`,children:e(`activity:ctxMode.debugContext`)}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:e(`activity:ctxMode.debugDesc`)})]})]})})]})]})]}),o&&(0,Y.jsxs)(`div`,{className:`absolute top-full left-0 mt-1 w-80 rounded-md border bg-popover shadow-lg z-30 py-1`,children:[(0,Y.jsx)(`div`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wider text-muted-foreground border-b`,children:e(`activity:ctxMode.windowHeading`)}),m.map(n=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{i(n.id),s(!1)},className:X(`w-full text-left px-3 py-2 hover:bg-accent/40 flex items-start gap-2`,n.id===t&&`bg-accent/30`),children:[(0,Y.jsx)(z,{className:X(`h-3.5 w-3.5 mt-0.5 shrink-0`,n.id===t?`opacity-100 text-primary`:`opacity-0`)}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-mono`,children:n.id}),n.thresholds?.warn!==void 0&&(0,Y.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[Math.round(n.thresholds.warn*100),`/`,Math.round(n.thresholds.soft*100),`/`,Math.round(n.thresholds.hard*100),`%`]})]}),(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground leading-snug`,children:n.description}),(n.preserveK||n.eliseThreshold)&&(0,Y.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground/80`,children:e(`activity:ctxMode.keepElide`,{k:n.preserveK??`-`,t:n.eliseThreshold??`-`})})]})]},n.id))]})]})}function Zp({open:e,onClose:t}){let n=K(e=>e.wsUrl),{lastInputTokens:r,maxContext:i}=q(),{t:a}=V(),[o,s]=(0,U.useState)(null),[c,l]=(0,U.useState)(!1),[u,d]=(0,U.useState)(null);if((0,U.useEffect)(()=>{if(!e){s(null),d(null);return}l(!0),d(null),s(null);let t=W(n);if(!t?.send){d(b.t(`activity:context.wsNotConnected`)),l(!1);return}t.send({type:`context.debug`});let r=t.on(`context.debug`,e=>{e.type===`context.debug`&&(s(e.payload),l(!1))}),i=setTimeout(()=>{c&&(l(!1),d(b.t(`activity:context.noData`)))},5e3);return()=>{clearTimeout(i),r()}},[e,n]),(0,U.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e,t]),!e)return null;let f=i>0&&r>0?Math.min(100,Math.round(r/i*100)):0;return(0,Y.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center pt-[10dvh] bg-black/40 backdrop-blur-sm`,children:(0,Y.jsxs)(`div`,{className:`w-full max-w-2xl max-h-[80dvh] overflow-y-auto rounded-xl border bg-card shadow-2xl`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b sticky top-0 bg-card z-10`,children:[(0,Y.jsxs)(`h3`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,Y.jsx)(gt,{className:`h-4 w-4 text-[hsl(var(--warning))]`}),a(`activity:context.title`)]}),(0,Y.jsx)(`button`,{type:`button`,onClick:t,className:`p-1 rounded-md hover:bg-muted transition-colors`,children:(0,Y.jsx)(Xn,{className:`h-4 w-4`})})]}),(0,Y.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Y.jsxs)(`div`,{className:`rounded bg-muted/30 px-3 py-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:a(`activity:context.windowUsage`)}),(0,Y.jsxs)(`span`,{className:`block text-sm font-mono font-medium`,children:[Ld(r),` / `,Ld(i),` (`,f,`%)`]})]}),(0,Y.jsxs)(`div`,{className:`rounded bg-muted/30 px-3 py-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:a(`activity:context.contextMode`)}),(0,Y.jsx)(`span`,{className:`block text-sm font-mono font-medium`,children:o?.mode??`—`})]})]}),c?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground py-4`,children:[(0,Y.jsx)(Rn,{className:`h-4 w-4 animate-spin`}),a(`activity:context.fetching`)]}):u?(0,Y.jsx)(`div`,{className:`rounded-md bg-destructive/10 border border-destructive/20 p-3 text-sm text-destructive`,children:u}):o?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,Y.jsxs)(`div`,{className:`rounded bg-muted/30 px-3 py-2`,children:[(0,Y.jsxs)(`span`,{className:`text-[10px] text-muted-foreground flex items-center gap-1`,children:[(0,Y.jsx)(gn,{className:`h-3 w-3`}),a(`activity:context.systemPrompt`)]}),(0,Y.jsx)(`span`,{className:`block text-sm font-mono font-medium`,children:Ld(o.systemPrompt)})]}),(0,Y.jsxs)(`div`,{className:`rounded bg-muted/30 px-3 py-2`,children:[(0,Y.jsxs)(`span`,{className:`text-[10px] text-muted-foreground flex items-center gap-1`,children:[(0,Y.jsx)(In,{className:`h-3 w-3`}),a(`activity:context.tools`)]}),(0,Y.jsxs)(`span`,{className:`block text-sm font-mono font-medium`,children:[Ld(o.tools.total),` (`,o.tools.count,`)`]})]}),(0,Y.jsxs)(`div`,{className:`rounded bg-muted/30 px-3 py-2`,children:[(0,Y.jsxs)(`span`,{className:`text-[10px] text-muted-foreground flex items-center gap-1`,children:[(0,Y.jsx)(Ir,{className:`h-3 w-3`}),a(`activity:context.messages`)]}),(0,Y.jsxs)(`span`,{className:`block text-sm font-mono font-medium`,children:[Ld(o.messages.total),` (`,o.messages.count,`)`]})]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground font-semibold`,children:a(`activity:context.tokenAllocation`)}),(0,Y.jsx)(`div`,{className:`mt-1.5 h-3 w-full overflow-hidden rounded-full bg-muted flex`,children:o.total>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`h-full bg-blue-500/70 transition-all`,style:{width:`${o.systemPrompt/o.total*100}%`},title:a(`activity:context.systemTitle`,{tokens:Ld(o.systemPrompt)})}),(0,Y.jsx)(`span`,{className:`h-full bg-amber-500/70 transition-all`,style:{width:`${o.tools.total/o.total*100}%`},title:a(`activity:context.toolsTitle`,{tokens:Ld(o.tools.total)})}),(0,Y.jsx)(`span`,{className:`h-full bg-emerald-500/70 transition-all`,style:{width:`${o.messages.total/o.total*100}%`},title:a(`activity:context.messagesTitle`,{tokens:Ld(o.messages.total)})})]})}),(0,Y.jsxs)(`div`,{className:`flex gap-3 mt-1 text-[10px] text-muted-foreground`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-blue-500/70`}),` `,a(`activity:context.system`)]}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-amber-500/70`}),` `,a(`activity:context.tools`)]}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-emerald-500/70`}),` `,a(`activity:context.messages`)]})]})]}),o.tools.breakdown.length>0&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground font-semibold`,children:a(`activity:context.toolBreakdown`)}),(0,Y.jsx)(`div`,{className:`mt-1 space-y-0.5`,children:o.tools.breakdown.map(e=>(0,Y.jsxs)(`div`,{className:`flex items-center justify-between text-xs py-0.5`,children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:e.name}),(0,Y.jsxs)(`span`,{className:`tabular-nums text-muted-foreground`,children:[e.tokens.toLocaleString(),` tok`]})]},e.name))})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground font-semibold`,children:a(`activity:context.messagesSummary`,{count:o.messages.count,total:Ld(o.messages.total)})}),(0,Y.jsx)(`div`,{className:`mt-1 space-y-0.5 max-h-40 overflow-y-auto`,children:o.messages.breakdown.slice(0,20).map(e=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-xs py-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground font-mono w-6 text-right`,children:e.index}),(0,Y.jsx)(`span`,{className:`text-muted-foreground font-mono w-14`,children:e.role}),(0,Y.jsxs)(`span`,{className:`tabular-nums text-muted-foreground w-14`,children:[e.tokens.toLocaleString(),` tok`]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground/70 truncate flex-1`,children:e.preview.slice(0,80)})]},e.index))})]})]}):null]})]})})}function Qp(){let{t:e}=V(),t=q(e=>e.cost),n=q(e=>e.inputCost),r=q(e=>e.outputCost),i=q(e=>e.cacheReadCost),a=G(e=>e.messages),[o,s]=(0,U.useState)(!1),c=(0,U.useRef)(null);(0,U.useEffect)(()=>{if(!o)return;let e=e=>{c.current?.contains(e.target)||s(!1)},t=e=>{e.key===`Escape`&&s(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[o]);let l=(()=>{let e=[];for(let t of a)t.role===`assistant`&&t.runSummary&&t.runSummary.costDelta>0&&e.push({id:t.id,preview:t.content.slice(0,80).replace(/\s+/g,` `).trim()||`(empty)`,cost:t.runSummary.costDelta,tools:t.runSummary.tools,ms:t.runSummary.durationMs,ts:t.timestamp});return e.sort((e,t)=>t.cost-e.cost),e.slice(0,5)})(),u=e=>e>=.01?`$${e.toFixed(4)}`:e>0?`$${e.toFixed(6).replace(/0+$/,``).replace(/\.$/,``)}`:`$0`,d=n>0||r>0;return(0,Y.jsxs)(`div`,{ref:c,className:`relative inline-block`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:X(`font-medium text-green-600 dark:text-green-400 hover:underline tabular-nums`),title:e(`activity:cost.clickTitle`),children:[`$`,t.toFixed(4)]}),o&&(0,Y.jsxs)(`div`,{className:`absolute right-0 top-full mt-1 z-30 w-80 rounded-md border bg-popover shadow-lg p-3 text-foreground`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,Y.jsx)(`span`,{className:`text-xs uppercase tracking-wider text-muted-foreground font-medium`,children:e(`activity:cost.heading`)}),(0,Y.jsx)(`span`,{className:`font-mono tabular-nums text-sm font-semibold text-green-600 dark:text-green-400`,children:u(t)})]}),d?(0,Y.jsxs)(`div`,{className:`text-[11px] text-muted-foreground font-mono mb-3 border-b pb-2`,children:[(0,Y.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Y.jsx)(`span`,{children:`input /1M`}),(0,Y.jsxs)(`span`,{children:[`$`,n.toFixed(2)]})]}),(0,Y.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Y.jsx)(`span`,{children:`output /1M`}),(0,Y.jsxs)(`span`,{children:[`$`,r.toFixed(2)]})]}),i>0&&(0,Y.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Y.jsx)(`span`,{children:`cache /1M`}),(0,Y.jsxs)(`span`,{children:[`$`,i.toFixed(2)]})]})]}):(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground italic mb-3 border-b pb-2`,children:e(`activity:cost.noPricing`)}),l.length===0?(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:e(`activity:cost.noTurns`)}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground/80 mb-1`,children:e(`activity:cost.topExpensive`,{count:l.length})}),(0,Y.jsx)(`ul`,{className:`space-y-1`,children:l.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{let t=document.querySelector(`[data-message-id="${e.id}"]`);t&&t.scrollIntoView({behavior:`smooth`,block:`center`}),s(!1)},className:`w-full text-left rounded px-2 py-1.5 hover:bg-accent/40 transition-colors`,children:[(0,Y.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-xs truncate`,children:e.preview}),(0,Y.jsx)(`span`,{className:`text-xs font-mono tabular-nums text-green-600 dark:text-green-400 shrink-0`,children:u(e.cost)})]}),(0,Y.jsxs)(`div`,{className:`text-[10px] text-muted-foreground font-mono mt-0.5`,children:[e.tools,` tool`,e.tools===1?``:`s`,` · `,(e.ms/1e3).toFixed(1),`s`]})]})},e.id))})]})]})]})}var $p=[`path`,`file_path`,`pattern`,`command`,`cmd`,`url`,`query`,`description`,`content`];function em(e,t){if(t==null)return``;if(typeof t!=`object`)return tm(String(t),120);let n=t,r=(e??``).toLowerCase();if(/^todo(_?write)?$|^todos$/i.test(r)||Array.isArray(n.todos)){let e=n.todos??[];if(Array.isArray(e)){let t=e.filter(e=>e.status===`completed`).length,n=e.filter(e=>e.status===`in_progress`).length,r=[`${e.length} todo${e.length===1?``:`s`}`];return t>0&&r.push(`${t} done`),n>0&&r.push(`${n} in-progress`),r.join(` · `)}}if(/batch|parallel/.test(r)||Array.isArray(n.tool_uses)||Array.isArray(n.calls)){let e=n.tool_uses??n.calls??n.batch;if(Array.isArray(e)){let t=new Set;for(let n of e)n&&typeof n==`object`&&`name`in n&&t.add(String(n.name));let n=[...t].slice(0,3).join(`, `),r=t.size>3?` +${t.size-3}`:``;return`${e.length} sub-tool${e.length===1?``:`s`}${n?` · ${n}${r}`:``}`}}if(/^(edit|str_replace|edit_file|patch)$/.test(r)){let e=nm(n),t=typeof n.old_string==`string`?n.old_string:``,r=typeof n.new_string==`string`?n.new_string:``,i=t?t.split(`
121
- `).length:0,a=r?r.split(`
122
- `).length:0;return`edit ${e||`(file)`}${i||a?` (${i} → ${a} lines)`:``}`}if(/^(write|write_file|create_file|new_file)$/.test(r)){let e=nm(n),t=typeof n.content==`string`?n.content:``,r=t?t.split(`
123
- `).length:0;return`write ${e||`(file)`}${r?` · ${r} lines`:``}`}if(/^(bash|shell|exec|run|run_command|run_shell)$/.test(r)){let e=n.command??n.cmd??n.script;if(typeof e==`string`)return`$ ${tm(e,110)}`}if(/^(fetch|http|web|webfetch|curl|request)$/.test(r)){let e=n.url;if(typeof e==`string`)return`${(n.method??`GET`).toUpperCase()} ${tm(e,100)}`}if(/^(grep|search|ripgrep)$/.test(r)){let e=n.pattern,t=n.path??n.glob??n.type;if(typeof e==`string`)return t?`grep ${tm(e,60)} in ${t}`:`grep ${tm(e,100)}`}if(/^(glob|find)$/.test(r)){let e=n.pattern??n.glob;if(typeof e==`string`)return`glob ${tm(e,100)}`}if(/^(read|read_file|cat)$/.test(r)){let e=nm(n),t=n.offset,r=n.limit;if(e&&(typeof t==`number`||typeof r==`number`)){let n=t??0;return`read ${e} (${n}…${typeof r==`number`?n+r:``})`}if(e)return`read ${e}`}for(let e of $p){let t=n[e];if(typeof t==`string`&&t.length>0)return`${e}: ${tm(t,100)}`}return tm(rm(t),120)}function tm(e,t){return e.length>t?`${e.slice(0,t-1)}…`:e}function nm(e){let t=e.file_path??e.path??e.filepath;return typeof t==`string`?t:``}function rm(e){try{return JSON.stringify(e)}catch{return String(e)}}var im={file:{color:`#60a5fa`},edit:{color:`#fbbf24`},search:{color:`#a78bfa`},folder:{color:`#38bdf8`},terminal:{color:`#67e8f9`},web:{color:`#34d399`},git:{color:`#a3e635`},tree:{color:`#22d3ee`},code:{color:`#818cf8`},test:{color:`#4ade80`},package:{color:`#f472b6`},document:{color:`#94a3b8`},scaffold:{color:`#c084fc`},todo:{color:`#facc15`},plan:{color:`#2dd4bf`},task:{color:`#5eead4`},meta:{color:`#cbd5e1`},index:{color:`#06b6d4`},json:{color:`#eab308`},diff:{color:`#93c5fd`},logs:{color:`#a3a3a3`},settings:{color:`#9ca3af`},brain:{color:`#e879f9`},fallback:{color:`#9ca3af`}},am={read:`file`,cat:`file`,view:`file`,write:`file`,create:`file`,edit:`edit`,replace:`edit`,str_replace:`edit`,multi_edit:`edit`,patch:`diff`,grep:`search`,search:`search`,rg:`search`,ripgrep:`search`,glob:`search`,find:`search`,folder:`folder`,ls:`folder`,list:`folder`,set_working_dir:`folder`,tree:`tree`,bash:`terminal`,shell:`terminal`,sh:`terminal`,exec:`terminal`,run:`terminal`,command:`terminal`,fetch:`web`,web_fetch:`web`,web_search:`web`,git:`git`,diff:`diff`,lint:`code`,format:`settings`,typecheck:`code`,test:`test`,install:`package`,outdated:`package`,audit:`package`,document:`document`,scaffold:`scaffold`,todo:`todo`,plan:`plan`,task:`task`,json:`json`,index:`index`,logs:`logs`,mode:`meta`,tool_search:`meta`,tool_use:`meta`,batch_tool_use:`meta`,tool_help:`meta`,remember:`brain`,forget:`brain`,search_memory:`brain`,find_related_memories:`brain`};function om(e){return e?am[e.toLowerCase()]??`fallback`:`fallback`}var sm={file:gn,edit:mn,search:le,folder:Fe,terminal:tt,web:$e,git:de,tree:yt,code:qn,test:mr,package:$t,document:_t,scaffold:R,todo:De,plan:_,task:yn,meta:In,index:dn,json:On,diff:P,logs:rt,settings:I,brain:Me,fallback:In};function cm(e){let t=om(e);return{Icon:sm[t],color:im[t].color}}var lm={file:`file read/write`,edit:`file editing`,search:`search & grep`,folder:`folder navigation`,terminal:`shell commands`,web:`web fetch`,git:`git operations`,tree:`directory tree`,code:`code quality`,test:`testing`,package:`package management`,document:`documentation`,scaffold:`project scaffolding`,todo:`todo tracking`,plan:`planning`,task:`task management`,meta:`tool orchestration`,index:`code indexing`,json:`JSON data`,diff:`diff & patch`,logs:`log viewing`,settings:`configuration`,brain:`memory`,fallback:`external tool`};function um(e){let t=om(e),n=dm(im[t].color);return`${lm[t]} — ${n}`}function dm(e){return{"#60a5fa":`blue`,"#fbbf24":`amber`,"#a78bfa":`violet`,"#38bdf8":`sky`,"#67e8f9":`cyan-light`,"#a3e635":`lime`,"#34d399":`emerald`,"#22d3ee":`cyan`,"#818cf8":`indigo`,"#4ade80":`green`,"#f472b6":`pink`,"#94a3b8":`slate`,"#c084fc":`purple`,"#facc15":`yellow`,"#2dd4bf":`teal`,"#5eead4":`teal-light`,"#cbd5e1":`slate-light`,"#06b6d4":`cyan-dark`,"#eab308":`yellow-dark`,"#93c5fd":`blue-light`,"#a3a3a3":`neutral`,"#9ca3af":`gray`,"#e879f9":`fuchsia`}[e]??`colored`}var fm=25,pm=12;function mm({text:e,isError:t,className:n,wrapClass:r,showLineNumbers:i,defaultCollapsed:a}){let o=(0,U.useMemo)(()=>e.split(`
124
- `),[e]),s=o.length>fm,[c,l]=(0,U.useState)(a?!1:!s),{t:u}=V(),d=c?e:o.slice(0,pm).join(`
125
- `),f=!!i&&s&&c;return(0,Y.jsxs)(`div`,{className:X(`rounded-md border bg-background/40 overflow-hidden`,n),children:[f?(0,Y.jsxs)(`div`,{className:`flex max-h-96 overflow-auto`,children:[(0,Y.jsx)(`pre`,{"aria-hidden":!0,className:`text-xs font-mono leading-[1.4] py-2 pl-2 pr-2 text-muted-foreground/50 select-none border-r border-border/40 bg-muted/20 tabular-nums text-right whitespace-pre shrink-0`,children:o.map((e,t)=>`${t+1}`).join(`
126
- `)}),(0,Y.jsx)(`pre`,{className:X(`text-xs font-mono leading-[1.4] py-2 px-2 flex-1 whitespace-pre`,t?`text-destructive`:`text-foreground`),children:d})]}):(0,Y.jsx)(`pre`,{className:X(`text-xs font-mono p-2 max-h-96 overflow-auto`,r,t?`text-destructive`:`text-foreground`),children:d}),s&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),className:`w-full flex items-center justify-center gap-1 px-2 py-1 border-t bg-muted/30 text-[11px] text-muted-foreground hover:text-foreground transition-colors`,children:c?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(D,{className:`h-3 w-3`}),u(`activity:toolResult.collapseToLines`,{count:pm})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(S,{className:`h-3 w-3`}),u(`activity:toolResult.showAllLines`,{total:o.length,more:o.length-pm})]})})]})}var hm=(0,U.memo)(function({toolName:e,result:t,isError:n,className:r,renderMode:i}){let a=(0,U.useMemo)(()=>gm(e,t),[e,t]),{t:o}=V(),s=i===`simple`;return a.kind===`json`?(0,Y.jsx)(_m,{value:a.value,isError:n,className:r,defaultCollapsed:s}):a.kind===`numbered`?(0,Y.jsx)(mm,{text:t,isError:n,className:r,wrapClass:`whitespace-pre`,defaultCollapsed:s}):a.kind===`bash`?(0,Y.jsxs)(`div`,{className:X(`rounded-md border bg-background/40 overflow-hidden`,r),children:[a.stdout&&(0,Y.jsx)(mm,{text:a.stdout,isError:n,className:`border-0 rounded-none bg-transparent`,wrapClass:`whitespace-pre-wrap break-all`,showLineNumbers:!0,defaultCollapsed:s}),(a.exitCode!==void 0||a.duration)&&(0,Y.jsxs)(`div`,{className:X(`flex items-center gap-3 text-[11px] px-2 py-1 border-t bg-muted/30 tabular-nums`,a.exitCode&&a.exitCode!==0?`text-destructive`:`text-muted-foreground`),children:[a.exitCode!==void 0&&(0,Y.jsxs)(`span`,{children:[o(`activity:toolResult.exitCode`),` `,(0,Y.jsx)(`span`,{className:`font-mono`,children:a.exitCode})]}),a.duration&&(0,Y.jsx)(`span`,{children:a.duration})]})]}):(0,Y.jsx)(mm,{text:t,isError:n,className:r,wrapClass:`whitespace-pre-wrap break-all`,showLineNumbers:!0,defaultCollapsed:s})});function gm(e,t){let n=t.trim();if(/^\s*\d+→/m.test(t.slice(0,200)))return{kind:`numbered`};if(n.startsWith(`{`)&&n.endsWith(`}`)||n.startsWith(`[`)&&n.endsWith(`]`))try{let e=JSON.parse(n);if(typeof e==`object`&&e)return{kind:`json`,value:e}}catch{}let r=!!e&&/^(bash|shell|exec|run)/i.test(e),i=t.match(/(?:^|\n)\s*(?:\[?exit(?:\s*code)?\]?\s*[:=]?\s*)(\d+)\s*$/i),a=t.match(/(?:^|\s)(\d+\s*ms|\d+\.\d+s)\s*$/i);if(r||i){let e=t;return i&&(e=t.slice(0,i.index).trimEnd()),{kind:`bash`,stdout:e,exitCode:i?Number(i[1]):void 0,duration:a?.[1]}}return{kind:`plain`}}function _m({value:e,isError:t,className:n,defaultCollapsed:r}){let{t:i}=V(),a=(0,U.useMemo)(()=>{try{return JSON.stringify(e,null,2)}catch{return String(e)}},[e]),o=a.split(`
127
- `).length,[s,c]=(0,U.useState)(r?!1:o<30);return(0,Y.jsxs)(`div`,{className:X(`rounded-md border bg-background/40 overflow-hidden`,t&&`border-destructive/40`,n),children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>c(e=>!e),className:`w-full flex items-center justify-between px-2 py-1 border-b bg-muted/30 text-[11px] text-muted-foreground hover:text-foreground`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[s?(0,Y.jsx)(bn,{className:`h-3 w-3`}):(0,Y.jsx)(Oe,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{className:`font-mono`,children:i(`activity:toolResult.jsonLines`,{count:o})})]}),(0,Y.jsx)(`span`,{children:i(s?`activity:toolResult.collapse`:`activity:toolResult.expand`)})]}),s&&(0,Y.jsx)(`pre`,{className:X(`text-xs font-mono whitespace-pre p-2 max-h-96 overflow-auto`,t?`text-destructive`:`text-foreground`),children:a})]})}async function vm(e){try{if(typeof navigator<`u`&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function ym(e,t){if(typeof document>`u`)return;let n=new Blob([t],{type:`text/plain;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(r),1e3)}function bm(e){let t=(e??``).toLowerCase();return/bash|shell|exec|run/.test(t)?`log`:(/grep|search|find/.test(t),`txt`)}function xm(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 Sm=[Sn];function Cm({text:e}){let{t}=V(),[n,r]=(0,U.useState)(!1);return(0,Y.jsxs)(`button`,{type:`button`,onClick:(0,U.useCallback)(async()=>{await vm(e)&&(r(!0),setTimeout(()=>r(!1),1500))},[e]),className:X(`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] transition-colors`,`hover:bg-muted-foreground/10`,n?`text-emerald-500`:`text-muted-foreground hover:text-foreground`),title:t(n?`common:action.copied`:`common:action.copy`),children:[n?(0,Y.jsx)(z,{className:`h-3 w-3`}):(0,Y.jsx)(Ft,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:t(n?`common:action.copied`:`common:action.copy`)})]})}var wm={code({inline:e,className:t,children:n,...r}){let i=/language-(\w+)/.exec(t??``),a=String(n??``).replace(/\n$/,``);if(e||!i)return(0,Y.jsx)(`code`,{className:X(`rounded border border-border/60 px-1.5 py-0.5 text-[0.85em] font-mono`,t),...r,children:n});let o=(0,U.useMemo)(()=>a.split(`
128
- `),[a]),s=o.length>1;return(0,Y.jsxs)(`div`,{className:`not-prose relative my-3 rounded-lg border border-border overflow-hidden group/codeblock`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1 border-b border-border text-xs`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Rt,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`font-mono text-muted-foreground font-medium`,children:i[1]}),o.length>0&&(0,Y.jsxs)(`span`,{className:`text-[10px] text-muted-foreground/60 tabular-nums`,children:[o.length,` line`,o.length===1?``:`s`]})]}),(0,Y.jsx)(Cm,{text:a})]}),s?(0,Y.jsxs)(`div`,{className:`flex max-h-[40rem] overflow-auto`,children:[(0,Y.jsx)(`pre`,{"aria-hidden":!0,className:`text-xs font-mono leading-[1.55] py-3 pl-3 pr-2 text-muted-foreground/40 select-none border-r border-border/30 tabular-nums text-right shrink-0`,children:o.map((e,t)=>(0,Y.jsx)(`div`,{children:t+1},t))}),(0,Y.jsx)(`pre`,{className:`overflow-x-auto py-3 px-3 text-xs leading-[1.55] font-mono flex-1`,children:(0,Y.jsx)(`code`,{className:X(`hljs`,t),...r,children:n})})]}):(0,Y.jsx)(`pre`,{className:`overflow-x-auto p-3 text-xs leading-relaxed font-mono max-h-[40rem]`,children:(0,Y.jsx)(`code`,{className:X(`hljs`,t),...r,children:n})}),(0,Y.jsx)(`div`,{className:`pointer-events-none absolute bottom-8 left-0 right-0 h-8 bg-gradient-to-t from-black/10 to-transparent opacity-0 group-hover/codeblock:opacity-100 transition-opacity`})]})}};function Tm({text:e,className:t,label:n}){let{t:r}=V(),[i,a]=(0,U.useState)(!1),o=n??r(`common:action.copy`);return(0,Y.jsx)(`button`,{type:`button`,onClick:async t=>{t.stopPropagation(),await vm(e)&&(a(!0),setTimeout(()=>a(!1),1400))},className:X(`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,t),title:o,children:i?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(z,{className:`h-3 w-3 text-green-500`}),(0,Y.jsx)(`span`,{children:r(`common:action.copied`)})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Ft,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:o})]})})}function Em(e){let t=e.split(`
129
- `);for(let e=0;e<t.length;e++){let n=Ur(t[e]);if(/^\s*at\s+\S+.*\(.*:\d+:\d+\)\s*$/.test(n)||/^\s*at\s+\S+\.\S+\(\S+\.java:\d+\)\s*$/.test(n)||/^\s+File "[^"]+", line \d+/.test(n))return e}return-1}function Dm({text:e}){let{t}=V(),n=Em(e),[r,i]=(0,U.useState)(!1);if(n===-1)return(0,Y.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs leading-relaxed`,children:e});let a=e.split(`
130
- `),o=a.slice(0,n).join(`
131
- `).trim(),s=a.slice(n).join(`
132
- `),c=s.split(`
133
- `).filter(e=>e.trim().length>0).length;return(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[o&&(0,Y.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs leading-relaxed`,children:o}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`inline-flex items-center gap-1 text-xs text-destructive hover:text-destructive/80 font-medium`,children:[r?`▾`:`▸`,` `,t(r?`activity:errorBody.hideStack`:`activity:errorBody.showStack`,{count:c})]}),r&&(0,Y.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-[11px] leading-snug bg-destructive/5 border border-destructive/20 rounded p-2 max-h-80 overflow-auto`,children:s})]})}function Om({input:e}){let{t}=V(),[n,r]=(0,U.useState)({});if(typeof e!=`object`||!e||Array.isArray(e))return(0,Y.jsx)(`pre`,{className:`whitespace-pre-wrap break-all text-xs font-mono`,children:JSON.stringify(e,null,2)});let i=Object.entries(e);return i.length===0?(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground italic`,children:t(`activity:toolInput.noParams`)}):(0,Y.jsx)(`div`,{className:`text-xs font-mono`,children:i.map(([e,i])=>{if(i==null||typeof i==`string`||typeof i==`number`||typeof i==`boolean`){let t=i===null?`null`:i===void 0?`undefined`:typeof i==`string`?i:String(i),n=typeof i==`string`&&(t.length>80||t.includes(`
134
- `));return(0,Y.jsxs)(`div`,{className:X(`py-0.5`,n?`flex flex-col gap-0.5`:`flex items-baseline gap-2`),children:[(0,Y.jsxs)(`span`,{className:`text-muted-foreground shrink-0`,children:[e,`:`]}),(0,Y.jsx)(`span`,{className:X(`text-foreground`,n?`whitespace-pre-wrap break-all bg-muted/40 rounded px-1.5 py-1`:`truncate`,typeof i==`string`?``:`text-amber-600 dark:text-amber-400`),title:typeof i==`string`&&!n?t:void 0,children:t})]},e)}let a=!!n[e],o=Array.isArray(i)?`[${t(`activity:toolInput.itemCount`,{count:i.length})}]`:`{${t(`activity:toolInput.keyCount`,{count:Object.keys(i).length})}}`;return(0,Y.jsxs)(`div`,{className:`py-0.5`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>r(t=>({...t,[e]:!t[e]})),className:`flex items-baseline gap-2 hover:bg-muted/30 rounded px-1 -mx-1`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground/60 text-[10px]`,children:a?`▾`:`▸`}),(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[e,`:`]}),(0,Y.jsx)(`span`,{className:`text-violet-600 dark:text-violet-400`,children:o})]}),a&&(0,Y.jsx)(`pre`,{className:`ml-3 mt-1 whitespace-pre-wrap break-all text-[11px] bg-muted/40 rounded px-2 py-1.5`,children:JSON.stringify(i,null,2)})]},e)})})}var km=(0,U.memo)(function({message:e,isFirst:t=!1,isContinuation:n=!1}){let{t:r}=V(),[i,a]=(0,U.useState)({}),[s,c]=(0,U.useState)(!1),[l,u]=(0,U.useState)(!1),[d,f]=(0,U.useState)(``),[p,m]=(0,U.useState)(!1),h=e.role===`user`,g=e.role===`tool`,_=!!e.thinkingLog;e.role;let v=G(e=>e.truncateAfter),y=G(e=>e.addMessage),b=G(e=>e.setLoading),x=G(e=>e.isLoading),S=K(e=>e.wsUrl),C=J(e=>e.pinnedIds),w=J(e=>e.togglePin),T=J(e=>e.compactMode),E=J(e=>e.searchOpen),D=J(e=>e.searchActiveMessageId),O=C.includes(e.id),k=q(e=>e.inputCost),A=q(e=>e.outputCost),M=q(e=>e.cacheReadCost),N=ti(),{autonomy:P,yolo:F}=N,{canAutoSubmit:I,recordAutoSubmit:L,capWarned:R}=gp(),ee=N.autoProceedMaxIterations<=0||I(),te=e=>{if(!I()){R||y({role:`assistant`,content:r(`activity:message.autoPaused`)});return}L(),y({role:`user`,content:e}),b(!0),W(S).sendMessage(e),Ps(``)},ne=(()=>{if(e.role!==`assistant`||x)return!1;let t=G.getState().messages;for(let n=t.length-1;n>=0;n--){let r=Ur(t[n]);if(r.role===`assistant`)return r.id===e.id}return!1})(),re=(0,U.useMemo)(()=>ne&&e.content?As(e.content):null,[ne,e.content]);(0,U.useEffect)(()=>{if(!e.thinkingLog||!E||D!==e.id)return;let t=J.getState().searchQuery.trim().toLowerCase();t&&e.thinkingLog.text.toLowerCase().includes(t)&&c(!0)},[e.id,e.thinkingLog,D,E]);let ie=()=>{let t=G.getState().messages,n=t.findIndex(t=>t.id===e.id);if(n===-1)return;let r=-1;for(let e=n-1;e>=0;e--)if(t[e]?.role===`user`){r=e;break}if(r===-1)return;let i=Ur(t[r]);v(i.id),y({role:`user`,content:i.content}),b(!0),W(S).sendMessage(i.content)},ae=e=>{a(t=>({...t,[e]:!t[e]}))},oe=()=>{f(e.content),u(!0)},se=()=>{u(!1),f(``)},ce=()=>{let t=d.trim();if(!t){se();return}v(e.id),y({role:`user`,content:t}),b(!0),W(S).sendMessage(t),u(!1),f(``)};return(0,Y.jsxs)(`div`,{"data-message-id":e.id,"data-pinned":O?`1`:void 0,className:X(`group flex msg-bubble animate-message rounded-lg transition-shadow`,T?`gap-2`:`gap-3`,h?`flex-row-reverse`:`flex-row`,O&&`ring-1 ring-amber-500/30 bg-amber-500/[0.02] px-1 -mx-1`),children:[n?(0,Y.jsx)(`div`,{className:`flex-shrink-0 w-8 h-8`,"aria-hidden":!0}):(0,Y.jsx)(`div`,{className:X(`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center`,`ring-2 ring-offset-2 ring-offset-background`,h?`bg-primary text-primary-foreground ring-primary/20`:g?`bg-secondary text-secondary-foreground ring-secondary/20`:_?`bg-violet-500/10 text-violet-600 dark:text-violet-400 ring-violet-500/20`:`bg-accent text-accent-foreground ring-accent/20`),children:h?(0,Y.jsx)(It,{className:`h-4 w-4`}):g?(0,Y.jsx)(En,{className:`h-4 w-4`}):_?(0,Y.jsx)(Me,{className:`h-4 w-4`}):(0,Y.jsx)(j,{className:`h-4 w-4`})}),(0,Y.jsxs)(`div`,{className:X(`flex flex-col gap-1.5 max-w-[85%]`,h&&`items-end`),children:[t&&!n&&(0,Y.jsx)(`span`,{className:X(`text-xs font-medium px-1`,h?`text-primary`:g?`text-secondary`:_?`text-violet-600 dark:text-violet-400`:`text-muted-foreground`),children:r(h?`activity:message.roleYou`:g?`activity:message.roleTool`:_?`activity:message.roleThinking`:`activity:message.roleAssistant`)}),g&&e.toolName&&(()=>{let{Icon:t,color:n}=cm(e.toolName),r=um(e.toolName);return(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>ae(e.id),className:X(`flex items-center gap-2 text-sm font-medium cursor-pointer select-none`,`hover:bg-muted/50 rounded-lg px-2 py-1 -mx-2 transition-colors`,e.isError?`text-destructive`:`text-foreground`),title:r,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground/50`,children:i[e.id]?(0,Y.jsx)(bn,{className:`h-3 w-3`}):(0,Y.jsx)(Oe,{className:`h-3 w-3`})}),(0,Y.jsx)(t,{className:`h-3 w-3`,style:{color:n}}),(0,Y.jsx)(`span`,{className:`font-mono`,style:{color:n},children:e.toolName}),e.toolResult===void 0?(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-amber-500 animate-pulse`,"aria-hidden":!0}):e.isError?(0,Y.jsx)(Nn,{className:`h-3 w-3 text-destructive`}):(0,Y.jsx)(rn,{className:`h-3 w-3 text-green-500`}),typeof e.toolDurationMs==`number`&&(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums font-normal`,children:xm(e.toolDurationMs)})]})})(),(0,Y.jsx)(`div`,{className:X(`rounded-2xl`,T?`px-3 py-1.5`:`px-4 py-3`,h?`bg-primary text-primary-foreground rounded-br-md`:g?e.isError?`bg-destructive/5 border border-destructive/20 text-destructive`:`bg-muted/80 text-foreground`:`bg-card border text-foreground`,e.isError&&!g&&`border-destructive/20`,h&&e.status===`failed`&&`opacity-60 ring-1 ring-destructive/30`),children:g?(()=>{let t=!!i[e.id],n=e.toolInput===void 0?``:em(e.toolName,e.toolInput),a=e.toolResult?e.toolResult.split(`
135
- `).length:0;return(0,Y.jsxs)(`div`,{className:`space-y-1 tool-details`,children:[n&&!t&&(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground font-mono truncate`,children:n}),e.toolResult===void 0&&e.progressLines&&e.progressLines.length>0&&(0,Y.jsx)(`div`,{className:`mt-1 rounded-md border border-amber-500/20 bg-amber-500/5 p-1.5 text-[11px] font-mono leading-snug max-h-32 overflow-auto`,children:(()=>{let t=new Map;return e.progressLines.slice(-6).map(e=>{let n=t.get(e)??0;return t.set(e,n+1),(0,Y.jsx)(`div`,{className:`truncate text-muted-foreground`,children:e},`${e}-${n}`)})})()}),t&&e.toolInput!==void 0&&(()=>{let t=ep(e.toolName,e.toolInput);return t?(0,Y.jsx)(Zf,{oldText:t.oldText,newText:t.newText,caption:t.caption}):(0,Y.jsxs)(`div`,{className:`p-3 bg-muted/50 rounded-lg overflow-x-auto`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 text-muted-foreground mb-2 text-xs`,children:[(0,Y.jsx)(Ge,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:r(`activity:message.inputLabel`)})]}),(0,Y.jsx)(Om,{input:e.toolInput})]})})(),t&&e.toolResult!==void 0&&e.toolResult.length>0&&(0,Y.jsxs)(`div`,{className:`relative group/tool`,children:[(0,Y.jsx)(hm,{toolName:e.toolName,result:e.toolResult,isError:e.isError}),(0,Y.jsxs)(`div`,{className:`absolute top-1.5 right-1.5 flex items-center gap-1 opacity-0 group-hover/tool:opacity-100 transition-opacity`,children:[(0,Y.jsx)(Tm,{text:e.toolResult,label:``,className:`bg-background/80 border rounded px-1.5 py-0.5`}),e.toolResult.split(`
136
- `).length>5&&(0,Y.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation();let n=bm(e.toolName);ym(`${(e.toolName??`output`).replace(/[^a-z0-9_-]+/gi,`-`).toLowerCase()}-${new Date().toISOString().replace(/[:.]/g,`-`)}.${n}`,e.toolResult??``)},className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground bg-background/80 border rounded px-1.5 py-0.5`,title:r(`activity:message.downloadTitle`),children:(0,Y.jsx)(Yn,{className:`h-3 w-3`})})]})]}),t&&e.toolResult!==void 0&&e.toolResult.length===0&&(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground italic`,children:r(`activity:message.empty`)}),!t&&e.isError&&e.toolResult&&(0,Y.jsx)(`div`,{className:`text-xs font-mono text-destructive truncate`,children:e.toolResult.split(`
137
- `)[0]}),(e.toolResult!==void 0&&e.toolResult.length>0||e.toolInput!==void 0&&Object.keys(e.toolInput??{}).length>0)&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>ae(e.id),className:`text-xs text-muted-foreground hover:text-foreground transition-colors`,children:t?r(`activity:message.hideDetails`):a>0?r(`activity:message.showDetailsLines`,{count:a}):r(`activity:message.showDetails`)})]})})():l&&h?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 min-w-[280px]`,children:[(0,Y.jsx)(`textarea`,{value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),se()):e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),ce())},rows:Math.min(8,Math.max(2,d.split(`
138
- `).length)),className:`w-full resize-none rounded-md border bg-background text-foreground px-2 py-1.5 text-sm font-mono focus:outline-none focus:ring-2 focus:ring-ring`}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] text-primary-foreground/60`,children:r(`activity:message.editHint`)}),(0,Y.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:se,className:`text-xs px-2 py-0.5 rounded border border-primary-foreground/30 hover:bg-primary-foreground/10`,children:r(`common:action.cancel`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:ce,disabled:!d.trim(),className:`text-xs px-2 py-0.5 rounded bg-primary-foreground text-primary disabled:opacity-50`,children:r(`activity:message.saveResend`)})]})]})]}):e.thinkingLog?(()=>{let t=e.thinkingLog,n=t.text.split(`
139
- `).length,i=Math.max(.1,t.durationMs/1e3),a=t.replayed?r(`activity:message.replay`):`${i.toFixed(+(i<10))}s`,o=t.text.split(`
140
- `).slice(-4).join(`
141
- `).trim();return(0,Y.jsxs)(`div`,{className:`min-w-0 max-w-[min(720px,85vw)]`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>c(e=>!e),className:`flex w-full flex-wrap items-center gap-x-2 gap-y-1 text-left text-sm font-medium text-violet-600 dark:text-violet-400`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground/60`,children:s?(0,Y.jsx)(bn,{className:`h-3.5 w-3.5`}):(0,Y.jsx)(Oe,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(Me,{className:`h-3.5 w-3.5`}),(0,Y.jsx)(`span`,{className:`min-w-0`,children:r(`activity:message.thinkingProcess`)}),(0,Y.jsx)(`span`,{className:`ml-0 text-[10px] font-mono font-normal text-muted-foreground sm:ml-auto`,children:r(`activity:message.thinkingMeta`,{iter:t.iteration,dur:a,lines:r(`activity:message.linesSuffix`,{count:n})})})]}),(0,Y.jsx)(`pre`,{className:X(`mt-2 whitespace-pre-wrap break-words rounded-lg border border-violet-500/20 bg-violet-500/[0.04] p-3 font-mono text-xs leading-relaxed text-foreground/80`,s?`max-h-[32rem] overflow-auto`:`max-h-24 overflow-hidden`),children:s?t.text:o||t.text}),(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,Y.jsx)(Tm,{text:t.text,label:r(`activity:message.copyLog`),className:`opacity-70 hover:opacity-100 transition-opacity`}),!s&&n>4&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>c(!0),className:`text-xs text-muted-foreground hover:text-foreground transition-colors`,children:r(`activity:message.showFullLog`)})]})]})})():(()=>{let t=re?re.stripped:e.content;return(0,Y.jsx)(`div`,{className:X(`text-sm leading-relaxed markdown-content`,e.streaming&&`streaming-cursor`),children:t?p&&e.role===`assistant`?(0,Y.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,Y.jsx)(Dm,{text:e.content}):(0,Y.jsx)(vn,{remarkPlugins:[o],rehypePlugins:Sm,components:wm,children:t}):e.streaming?(0,Y.jsx)(`span`,{className:`inline-block animate-pulse text-muted-foreground`,children:r(`activity:message.typing`)}):(0,Y.jsx)(`span`,{className:`text-muted-foreground italic`,children:r(`activity:message.noContent`)})})})()}),h&&e.status===`failed`&&(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-destructive flex items-center gap-1 px-1`,children:r(`activity:message.failedToSend`)}),re&&re.steps.length>0&&(0,Y.jsx)(Is,{steps:re.steps,yoloMode:F,autoMode:P===`auto`,autoDelayMs:N.autonomyDelayMs,onAutoSubmit:te,canAutoSubmit:ee}),(0,Y.jsxs)(`div`,{className:X(`flex items-center gap-2 px-1`,h?`flex-row-reverse`:`flex-row`),children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground/50`,children:new Date(e.timestamp).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}),(0,Y.jsx)(`span`,{className:`w-px h-3 bg-border/60 shrink-0`,"aria-hidden":!0}),e.runSummary&&(0,Y.jsxs)(`span`,{className:`text-[10px] text-muted-foreground/60 font-mono tabular-nums`,title:[r(`activity:message.rsIterations`,{n:e.runSummary.iterations}),r(`activity:message.rsTools`,{n:e.runSummary.tools}),r(`activity:message.rsElapsed`,{s:`${(e.runSummary.durationMs/1e3).toFixed(2)}s`}),e.runSummary.costDelta>0?r(`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*k+t.output*A+(t.cacheRead??0)*M)/1e6,i=k>0||A>0,a=n>=.01?`${n.toFixed(4)}`:n>0?`${n.toFixed(6).replace(/0+$/,``).replace(/\.$/,``)}`:``;return(0,Y.jsxs)(`span`,{className:`text-[10px] text-muted-foreground/60 font-mono tabular-nums`,title:[r(`activity:message.useInput`,{n:t.input.toLocaleString()}),r(`activity:message.useOutput`,{n:t.output.toLocaleString()}),t.cacheRead?r(`activity:message.useCacheRead`,{n:t.cacheRead.toLocaleString()}):``,i?r(`activity:message.useCost`,{c:a}):``].filter(Boolean).join(` · `),children:[t.input.toLocaleString(),`→`,t.output.toLocaleString(),t.cacheRead?` · ${t.cacheRead.toLocaleString()} ↺`:``,i&&a?` · ${a}`:``]})})(),!g&&e.content&&!e.streaming&&(0,Y.jsx)(Tm,{text:e.content,label:r(`common:action.copy`),className:`opacity-50 hover:opacity-100 transition-opacity`}),e.role===`assistant`&&e.content&&!e.streaming&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>m(e=>!e),title:r(p?`activity:message.showRenderedTitle`:`activity:message.showRawTitle`),className:X(`text-xs inline-flex items-center gap-1 transition-opacity`,p?`text-primary hover:text-primary/80 opacity-100`:`opacity-50 hover:opacity-100 text-muted-foreground hover:text-foreground`),children:[(0,Y.jsx)(Rt,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:r(p?`activity:message.renderedLabel`:`activity:message.rawLabel`)})]}),h&&!l&&!x&&e.content&&(0,Y.jsxs)(`button`,{type:`button`,onClick:oe,title:r(`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,Y.jsx)(zt,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:r(`activity:message.editLabel`)})]}),e.role===`assistant`&&e.content&&!e.streaming&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>w(e.id),title:r(O?`activity:message.unpinTitle`:`activity:message.pinTitle`),className:X(`text-xs inline-flex items-center gap-1 transition-opacity`,O?`text-amber-500 hover:text-amber-600 opacity-100`:`opacity-50 hover:opacity-100 text-muted-foreground hover:text-foreground`),children:[O?(0,Y.jsx)(cr,{className:`h-3 w-3`}):(0,Y.jsx)(Un,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:r(O?`activity:message.pinnedLabel`:`activity:message.pinLabel`)})]}),ne&&e.content&&!e.streaming&&(0,Y.jsxs)(`button`,{type:`button`,onClick:ie,title:r(`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,Y.jsx)(Le,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:r(`activity:message.retryLabel`)})]})]})]})]})});function Am(){let{t:e}=V(),t=q(e=>e.mode),n=q(e=>e.modes),{listModes:r,switchMode:i}=sd(),[a,o]=(0,U.useState)(!1),s=(0,U.useRef)(null);(0,U.useEffect)(()=>{a&&r()},[a,r]),(0,U.useEffect)(()=>{if(!a)return;let e=e=>{s.current?.contains(e.target)||o(!1)},t=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[a]);let c=n.length>0?n:[{id:`default`,name:e(`activity:mode.defaultName`),description:e(`activity:mode.defaultDesc`)}];return(0,Y.jsxs)(`div`,{ref:s,className:`relative shrink-0`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:X(`flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium`,`bg-accent/40 text-foreground hover:bg-accent transition-colors border border-transparent hover:border-primary/30`),title:e(`activity:mode.activeTitle`),children:[e(`activity:mode.modePrefix`),` `,(0,Y.jsx)(`span`,{className:`font-mono`,children:t||`default`}),(0,Y.jsx)(bn,{className:`h-3 w-3 opacity-60`})]}),a&&(0,Y.jsxs)(`div`,{className:`absolute top-full left-0 mt-1 w-64 rounded-md border bg-popover shadow-lg z-30 py-1`,children:[(0,Y.jsx)(`div`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wider text-muted-foreground border-b`,children:e(`activity:mode.heading`)}),c.map(e=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{i(e.id),o(!1)},className:X(`w-full text-left px-3 py-2 hover:bg-accent/40 flex items-start gap-2`,e.id===t&&`bg-accent/30`),children:[(0,Y.jsx)(z,{className:X(`h-3.5 w-3.5 mt-0.5 shrink-0`,e.id===t?`opacity-100 text-primary`:`opacity-0`)}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-mono`,children:e.id}),e.description&&(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground leading-snug`,children:e.description})]})]},e.id))]})]})}function jm({open:e,onClose:t,className:n}){let{t:r}=V(),[i,a]=(0,U.useState)([]),o=sd(),s=(0,U.useRef)(null),c=(0,U.useRef)(null);(0,U.useEffect)(()=>{if(!(!e||!o.client?.isConnected))return o.client.send?.({type:`process.list`}),s.current=o.client.on?.(`process.list`,e=>{let t=e?.payload;t?.processes&&a(t.processes)})??null,c.current=setInterval(()=>{o.client.send?.({type:`process.list`})},3e3),()=>{s.current?.(),c.current&&clearInterval(c.current)}},[e,o.client]);let l=(0,U.useCallback)(e=>{o.client.send?.({type:`process.kill`,payload:{pid:e}})},[o.client]),u=(0,U.useCallback)(()=>{o.client.send?.({type:`process.killAll`})},[o.client]),d=i.filter(e=>e.status===`running`);return e?(0,Y.jsx)(`div`,{className:X(`fixed inset-0 z-50 flex items-start justify-center pt-[10dvh] bg-black/40 backdrop-blur-sm`,n),onClick:e=>{e.target===e.currentTarget&&t()},children:(0,Y.jsxs)(`div`,{className:`flex max-h-[75dvh] min-h-0 w-full max-w-lg flex-col rounded-xl border bg-card shadow-2xl animate-in fade-in zoom-in-95`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,Y.jsx)(`span`,{className:`flex items-center justify-center w-8 h-8 rounded-lg bg-amber-500/10 text-amber-600 dark:text-amber-400`,children:(0,Y.jsx)(En,{className:`h-4 w-4`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold`,children:r(`activity:process.heading`)}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:r(`activity:process.subtitle`,{active:d.length,total:i.length})})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[d.length>0&&(0,Y.jsxs)(`button`,{type:`button`,onClick:u,className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs text-destructive hover:bg-destructive/10 transition-colors font-medium`,children:[(0,Y.jsx)(ae,{className:`h-3 w-3 fill-current`}),r(`activity:process.killAll`)]}),(0,Y.jsx)(`button`,{type:`button`,onClick:t,className:`p-1.5 rounded-md hover:bg-muted transition-colors`,children:(0,Y.jsx)(Xn,{className:`h-4 w-4`})})]})]}),(0,Y.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto`,children:i.length===0?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 gap-3 text-muted-foreground`,children:[(0,Y.jsx)(En,{className:`h-10 w-10 opacity-15`}),(0,Y.jsx)(`p`,{className:`text-sm font-medium`,children:r(`activity:process.emptyTitle`)}),(0,Y.jsx)(`p`,{className:`text-xs text-center max-w-xs`,children:r(`activity:process.emptyBody`)})]}):(0,Y.jsx)(`div`,{className:`divide-y`,children:i.map(e=>{let t=e.status===`running`?Math.floor((Date.now()-e.startedAt)/1e3):null,n=t?t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`:null,i=e.protected===!0;return(0,Y.jsxs)(`div`,{className:X(`flex items-center justify-between px-4 py-3 text-xs transition-colors`,e.status===`running`?`bg-background hover:bg-muted/30`:`bg-muted/20 text-muted-foreground`),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:X(`led shrink-0`,e.status===`running`?i?`text-blue-400`:`text-[hsl(var(--success))] led-pulse`:`text-muted-foreground`)}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground shrink-0`,children:r(`activity:process.pidLabel`,{pid:e.pid})}),(0,Y.jsx)(`span`,{className:`font-medium truncate`,children:e.tool}),i&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1 py-0.5 rounded text-[9px] bg-blue-500/10 text-blue-600 dark:text-blue-400 font-medium shrink-0`,title:r(`activity:process.protectedTitle`),children:[(0,Y.jsx)(p,{className:`h-2.5 w-2.5`}),r(`activity:process.protected`)]})]}),(0,Y.jsx)(`code`,{className:`text-[10px] text-muted-foreground/70 truncate block mt-0.5 font-mono`,children:e.command})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0 ml-3`,children:[n&&(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:n}),e.status===`running`&&!i&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>l(e.pid),className:`p-1.5 rounded-md hover:bg-destructive/10 hover:text-destructive transition-colors`,title:r(`activity:process.killTitle`,{pid:e.pid}),children:(0,Y.jsx)(ae,{className:`h-3.5 w-3.5 fill-current`})})]})]},e.pid)})})})]})}):null}var Mm=`
142
- ::highlight(chat-search) { background-color: hsl(var(--primary) / 0.3); color: inherit; }
143
- ::highlight(chat-search-active) { background-color: hsl(var(--primary) / 0.85); color: hsl(var(--primary-foreground)); }
144
- `;function Nm(e){return e.thinkingLog?[e.content,e.thinkingLog.text].filter(Boolean).join(`
145
- `):e.role===`tool`?[e.toolName??``,e.toolResult??``,JSON.stringify(e.toolInput??``)].join(`
146
- `):e.content}function Pm(){let{t:e}=V(),t=J(e=>e.searchOpen),n=J(e=>e.setSearchOpen),r=J(e=>e.searchQuery),i=J(e=>e.setSearchQuery),a=G(e=>e.messages),o=J(e=>e.requestScrollToMessage),s=J(e=>e.setSearchActiveMessageId),c=(0,U.useRef)(null),[l,u]=(0,U.useState)(0),[d,f]=(0,U.useState)(0);(0,U.useEffect)(()=>{t&&requestAnimationFrame(()=>c.current?.focus())},[t]),(0,U.useEffect)(()=>{let e=document.createElement(`style`);return e.textContent=Mm,document.head.appendChild(e),()=>{document.head.removeChild(e)}},[]);let p=(0,U.useMemo)(()=>{let e=r.trim().toLowerCase();return e?a.filter(t=>Nm(t).toLowerCase().includes(e)).map(e=>e.id):[]},[a,r]);if((0,U.useEffect)(()=>{l>=p.length&&u(0)},[p,l]),(0,U.useEffect)(()=>{s(t&&r.trim()?p[l]??null:null)},[t,r,p,l,s]),(0,U.useEffect)(()=>{let e=window,n=e.CSS?.highlights,i=e.Highlight;if(!n||!i)return;let a=()=>{n.delete(`chat-search`),n.delete(`chat-search-active`)},o=r.trim();if(!o||!t){a();return}let s=o.toLowerCase(),c=[],u=[],d=p[l];for(let e of document.querySelectorAll(`[data-message-id]`)){let t=e.dataset.messageId===d,n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),r=n.nextNode();for(;r;){let e=r.nodeValue??``;if(e.length>0){let n=e.toLowerCase(),i=0;for(;i<=n.length-s.length;){let e=n.indexOf(s,i);if(e===-1)break;let a=document.createRange();a.setStart(r,e),a.setEnd(r,e+s.length),c.push(a),t&&u.push(a),i=e+s.length}}r=n.nextNode()}}return c.length>0?n.set(`chat-search`,new i(...c)):n.delete(`chat-search`),u.length>0?n.set(`chat-search-active`,new i(...u)):n.delete(`chat-search-active`),a},[r,p,l,t,d]),(0,U.useEffect)(()=>{let e=p[l];if(!e)return;o(e);let t=0,n=requestAnimationFrame(function e(){f(e=>e+1),++t<3&&(n=requestAnimationFrame(e))});return()=>cancelAnimationFrame(n)},[p,l,o]),!t)return null;let m=e=>{p.length!==0&&u(t=>(t+e+p.length)%p.length)};return(0,Y.jsx)(`div`,{className:`absolute top-2 right-4 z-30 w-[28rem] max-w-[calc(100%-2rem)] rounded-lg border bg-popover shadow-xl`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,Y.jsx)(le,{className:`h-4 w-4 text-muted-foreground shrink-0`}),(0,Y.jsx)(`input`,{ref:c,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),n(!1)):e.key===`Enter`?(e.preventDefault(),m(e.shiftKey?-1:1)):e.key===`ArrowDown`?(e.preventDefault(),m(1)):e.key===`ArrowUp`&&(e.preventDefault(),m(-1))},placeholder:e(`activity:search.placeholder`),className:`flex-1 bg-transparent outline-none text-sm placeholder:text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums shrink-0`,children:p.length===0?r?`0`:``:`${l+1} / ${p.length}`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>m(-1),disabled:p.length===0,className:X(`p-1 rounded hover:bg-muted disabled:opacity-30 disabled:cursor-not-allowed`),title:e(`activity:search.prevHit`),children:(0,Y.jsx)(Vr,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>m(1),disabled:p.length===0,className:X(`p-1 rounded hover:bg-muted disabled:opacity-30 disabled:cursor-not-allowed`),title:e(`activity:search.nextHit`),children:(0,Y.jsx)(ct,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>n(!1),className:`p-1 rounded hover:bg-muted text-muted-foreground`,title:e(`activity:search.close`),children:(0,Y.jsx)(Xn,{className:`h-3.5 w-3.5`})})]})})}function Fm(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 Im=(0,U.memo)(function({tools:e,defaultOpen:t=!1,isContinuation:n=!1}){let{t:r}=V(),[i,a]=(0,U.useState)(t);if(e.length===1)return(0,Y.jsx)(km,{message:Ur(e[0]),isFirst:!0,isContinuation:n});let o=e.filter(e=>e.toolResult===void 0).length,s=e.filter(e=>e.isError).length,c=e.reduce((e,t)=>e+(t.toolDurationMs??0),0),l=Array.from(new Set(e.map(e=>e.toolName).filter(Boolean))),u=l.slice(0,3).join(`, `),d=l.length>3?` +${l.length-3}`:``;return(0,Y.jsxs)(`div`,{className:`flex gap-3 animate-message`,children:[n?(0,Y.jsx)(`div`,{className:`flex-shrink-0 w-8 h-8`,"aria-hidden":!0}):(0,Y.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,Y.jsx)(En,{className:`h-4 w-4`})}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5 max-w-[85%] flex-1 min-w-0`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:X(`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:[i?(0,Y.jsx)(bn,{className:`h-3.5 w-3.5 text-muted-foreground`}):(0,Y.jsx)(Oe,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,Y.jsx)(En,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`font-mono text-xs`,children:r(`activity:toolGroup.toolCalls`,{count:e.length})}),o>0?(0,Y.jsx)(B,{className:`h-3 w-3 animate-spin text-amber-500`}):s>0?(0,Y.jsx)(Nn,{className:`h-3 w-3 text-destructive`}):(0,Y.jsx)(rn,{className:`h-3 w-3 text-green-500`}),c>0&&(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums font-normal`,children:Fm(c)}),u&&(0,Y.jsxs)(`span`,{className:`text-xs text-muted-foreground/80 font-mono truncate`,children:[`· `,u,d]})]}),i&&(0,Y.jsx)(`div`,{className:`space-y-2 pl-3 border-l-2 border-border/40 ml-2 tool-details`,children:e.map(e=>(0,Y.jsx)(km,{message:e,isFirst:!1},e.id))})]})]})}),Lm=[{id:`understand`,icon:le,title:`Understand`,hint:`Explore and analyze the codebase`,tone:`text-blue-600 dark:text-blue-400 bg-blue-500/10 border-blue-500/20`,prompts:[`Map out the structure of this codebase: what are the main modules or components, how do they depend on each other, and what are the key patterns used throughout?`,`Find and document the public API surface — all exported interfaces, functions, and types that other parts of the system depend on.`,`Trace the flow of data through the system for a typical operation. Where does input validation happen? Where are side effects triggered?`]},{id:`create`,icon:ye,title:`Create`,hint:`Build new features and functionality`,tone:`text-emerald-600 dark:text-emerald-400 bg-emerald-500/10 border-emerald-500/20`,prompts:[`Add a new feature that covers the full stack: data model, business logic, and any UI or API layers. Follow existing patterns in this codebase.`,`Write comprehensive tests for a module with low coverage. Include happy paths, edge cases, and error scenarios.`,`Add observability to a critical path — structured logging, error tracking, or metrics that help diagnose issues in production.`]},{id:`investigate`,icon:Tt,title:`Investigate`,hint:`Debug issues and find root causes`,tone:`text-amber-600 dark:text-amber-400 bg-amber-500/10 border-amber-500/20`,prompts:[`Something isn't working as expected — help me trace from the symptom to the root cause. Follow the code path and identify where behavior diverges from intent.`,`There's a difference between how this works locally versus in production or CI. Check for environment differences, configuration issues, or hidden assumptions.`,`Performance is degrading. Identify the bottlenecks — whether N+1 queries, blocking I/O, unnecessary allocations, or something else — and propose targeted fixes.`]},{id:`improve`,icon:bt,title:`Improve`,hint:`Refactor and optimize existing code`,tone:`text-violet-600 dark:text-violet-400 bg-violet-500/10 border-violet-500/20`,prompts:[`Find duplicated or similar logic that could be consolidated into shared utilities. Extract the common parts and update the call sites.`,`Identify modules that have grown too large or handle too many responsibilities. Propose a cleaner separation that can be done incrementally.`,`Review error handling across the codebase: are errors consistent, well-contextualized, and properly propagated? Suggest improvements to the worst cases.`]}],Rm=[{id:`help`,name:`/help`,hint:`list every slash command`},{id:`diag`,name:`/diag`,hint:`runtime diagnostics`},{id:`stats`,name:`/stats`,hint:`tokens · cache · cost · elapsed`},{id:`tools`,name:`/tools`,hint:`show registered tools`},{id:`memory`,name:`/memory`,hint:`show remembered notes`},{id:`compact`,name:`/compact`,hint:`shrink context`},{id:`clear`,name:`/clear`,hint:`wipe current context`},{id:`new`,name:`/new`,hint:`fresh session`}];function zm(e){let t=document.querySelector(`textarea`);t&&((Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,`value`)?.set)?.call(t,e),t.dispatchEvent(new Event(`input`,{bubbles:!0})),t.focus())}function Bm(){let{t:e}=V(),{projectName:t,cwd:n}=q(),{provider:r,model:i}=K(),a=K(e=>e.wsConnected),o=K(e=>e.wsUrl),[s,c]=(0,U.useState)(void 0);(0,U.useEffect)(()=>{if(!a)return;let e=W(o),t=e.on(`providers.saved`,e=>{let t=e.payload;c(t.providers?.length??0)});return e.listSavedProviders(),()=>{t()}},[a,o]);let l=J(e=>e.promptHistory).slice(0,6),{listSessions:u,resumeSession:d}=sd(),f=Ts(e=>e.entries);(0,U.useEffect)(()=>{a&&f.length===0&&u(10)},[a]);let p=J(e=>e.sessionNicknames),m=f.filter(e=>!e.isCurrent).slice(0,4);return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-8 py-8 px-2 max-w-5xl mx-auto w-full`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col items-center text-center gap-3`,children:[(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsx)(`div`,{className:`w-14 h-14 rounded-2xl bg-gradient-to-br from-primary via-primary to-primary/60 flex items-center justify-center shadow-lg shadow-primary/20`,children:(0,Y.jsx)(tn,{className:`h-7 w-7 text-primary-foreground`})}),(0,Y.jsx)(`div`,{className:`absolute -inset-3 bg-gradient-to-r from-transparent via-primary/10 to-transparent animate-pulse rounded-full -z-10`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-2xl font-semibold tracking-tight`,children:t?e(`setup:welcome.heroTitleInProject`,{name:t}):e(`setup:welcome.heroTitle`)}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground mt-2 max-w-2xl mx-auto leading-relaxed`,children:e(`setup:welcome.heroSubtitle`)}),r&&i&&(0,Y.jsxs)(`p`,{className:`text-xs text-muted-foreground/70 mt-2 font-mono`,children:[r,` / `,i]}),n&&(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground/50 mt-1 font-mono`,title:n,children:e(`setup:welcome.workingDirectory`,{cwd:n})})]})]}),a&&s===0&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>_l(`settings`),className:X(`group rounded-xl border bg-gradient-to-br from-amber-500/10 via-amber-500/5 to-transparent`,`border-amber-500/30 hover:border-amber-500/50 transition-colors`,`p-4 flex items-center gap-4 text-left`),children:[(0,Y.jsx)(`span`,{className:`flex items-center justify-center w-12 h-12 rounded-lg bg-amber-500/15 text-amber-600 dark:text-amber-400 shrink-0`,children:(0,Y.jsx)(he,{className:`h-6 w-6`})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`h3`,{className:`text-base font-semibold mb-1`,children:e(`setup:welcome.noKeyTitle`)}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:e(`setup:welcome.noKeyBody`)})]}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400 font-medium shrink-0 group-hover:translate-x-0.5 transition-transform`,children:[e(`setup:welcome.openSettings`),` `,(0,Y.jsx)(it,{className:`h-3.5 w-3.5`})]})]}),(0,Y.jsx)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4 max-h-[calc(100dvh-16rem)] lg:max-h-none overflow-y-auto`,children:Lm.map((t,n)=>{let r=t.icon;return(0,Y.jsxs)(`div`,{className:`rounded-xl border bg-card/40 backdrop-blur-sm p-4 flex flex-col gap-3 animate-message hover:border-primary/20 hover:shadow-sm transition-all`,style:{animationDelay:`${n*80}ms`},children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:X(`flex items-center justify-center w-8 h-8 rounded-lg border`,t.tone),children:(0,Y.jsx)(r,{className:`h-4 w-4`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold`,children:e(`setup:welcome.card.${t.id}.title`)}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`setup:welcome.card.${t.id}.hint`)})]})]}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:t.prompts.map((e,t)=>(0,Y.jsx)(`button`,{type:`button`,onClick:()=>zm(e),className:`text-left text-xs leading-relaxed text-foreground/80 hover:text-foreground border border-transparent hover:border-border/60 rounded-lg px-3 py-2 hover:bg-muted/40 transition-colors line-clamp-3`,title:e,children:e},t))})]},t.id)})}),m.length>0&&(0,Y.jsxs)(`div`,{className:`rounded-xl border bg-muted/20 p-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,Y.jsx)(fe,{className:`h-4 w-4 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-xs uppercase tracking-wider text-muted-foreground font-medium`,children:e(`setup:welcome.pickBackUp`)})]}),(0,Y.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:m.map(t=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>d(t.id),className:`text-left rounded-lg border border-border/40 bg-background/60 hover:border-primary/40 hover:bg-accent/30 px-3 py-2 transition-colors group/sess`,title:t.title,children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium truncate text-foreground group-hover/sess:text-primary`,children:p[t.id]||t.title||e(`setup:welcome.empty`)}),(0,Y.jsxs)(`div`,{className:`text-[10px] text-muted-foreground font-mono truncate mt-0.5`,children:[t.provider,`/`,t.model,t.tokenTotal>0&&(0,Y.jsxs)(`span`,{className:`ml-2`,children:[`· `,t.tokenTotal.toLocaleString(),` tok`]})]})]},t.id))})]}),l.length>0&&(0,Y.jsxs)(`div`,{className:`rounded-xl border bg-muted/20 p-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,Y.jsx)(Ge,{className:`h-4 w-4 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-xs uppercase tracking-wider text-muted-foreground font-medium`,children:e(`setup:welcome.recentPrompts`)})]}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:l.filter(e=>!e.startsWith(`/`)).slice(0,5).map((e,t)=>(0,Y.jsx)(`button`,{type:`button`,onClick:()=>zm(e),className:`text-left text-xs leading-relaxed text-muted-foreground hover:text-foreground border border-transparent hover:border-border/60 rounded-lg px-3 py-2 hover:bg-background/60 transition-colors line-clamp-2`,title:e,children:e},t))})]}),(0,Y.jsxs)(`div`,{className:`rounded-xl border bg-muted/20 p-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,Y.jsx)(A,{className:`h-4 w-4 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-xs uppercase tracking-wider text-muted-foreground font-medium`,children:e(`setup:welcome.quickCommands`)})]}),(0,Y.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-2`,children:Rm.map(t=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>zm(t.name),className:`text-left flex flex-col gap-0.5 rounded-md border border-border/40 bg-background/60 px-3 py-2 hover:border-primary/40 hover:bg-accent/40 transition-colors`,children:[(0,Y.jsx)(`span`,{className:`font-mono text-xs text-foreground`,children:t.name}),(0,Y.jsx)(`span`,{className:`text-[11px] text-muted-foreground truncate`,children:e(`setup:welcome.slashRef.${t.id}`)})]},t.name))})]})]})}function Vm(){let{t:e}=V(),t=G(e=>e.thinkingBuffer);if(!t)return null;let n=t.split(`
147
- `).slice(-6).join(`
148
- `).trim();return(0,Y.jsxs)(`div`,{className:`flex gap-3 animate-message`,children:[(0,Y.jsx)(`div`,{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center bg-violet-500/10 text-violet-600 dark:text-violet-400 ring-2 ring-offset-2 ring-offset-background ring-violet-500/20`,children:(0,Y.jsx)(Me,{className:`h-4 w-4 animate-pulse`})}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1 max-w-[85%] min-w-0`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-violet-600 dark:text-violet-400 px-1`,children:e(`chat:thinking`)}),(0,Y.jsx)(`div`,{className:`rounded-2xl rounded-bl-md px-3 py-2 bg-violet-500/[0.04] border border-violet-500/20 text-foreground/80`,children:(0,Y.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-sans text-xs leading-relaxed italic max-h-32 overflow-hidden`,children:n||`…`})})]})]})}var Hm=(0,U.memo)(function({row:e,isLoading:t,compactMode:n,isFirstRow:r}){let i=X(`mx-auto max-w-5xl w-full px-4`,r&&`pt-4`,n?`pb-3`:`pb-6`);return e.kind===`day`?(0,Y.jsx)(`div`,{className:i,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 py-1 text-[11px] text-muted-foreground/70 uppercase tracking-wider font-medium`,children:[(0,Y.jsx)(`div`,{className:`flex-1 h-px bg-border/50`}),(0,Y.jsx)(`span`,{children:e.label}),(0,Y.jsx)(`div`,{className:`flex-1 h-px bg-border/50`})]})}):e.kind===`user`?(0,Y.jsx)(`div`,{className:i,children:(0,Y.jsx)(km,{message:e.message,isFirst:!0})}):(0,Y.jsx)(`div`,{className:i,children:(0,Y.jsx)(`div`,{className:X(`chat-turn`,n?`space-y-1`:`space-y-1.5`),children:e.items.map(n=>{if(n.kind===`msg`)return(0,Y.jsx)(km,{message:n.message,isFirst:n.isFirst,isContinuation:n.isContinuation},n.key);let r=e.isLastTurn&&n.isLastGroup&&t&&n.hasRunningTool;return(0,Y.jsx)(Im,{tools:n.tools,defaultOpen:r,isContinuation:n.isContinuation},n.key)})})})});function Um(){let{t:e}=V(),t=G(e=>e.messages),n=G(e=>e.isLoading),r=J(e=>e.sidebarOpen),i=J(e=>e.toggleSidebar),a=J(e=>e.compactMode),{totalTokens:o,startTime:s,lastInputTokens:c,maxContext:l,iteration:u}=q(),f=q(e=>e.session),p=f?.id,m=J(e=>p?e.sessionNicknames[p]:void 0),h=J(e=>e.setSessionNickname),g=f?.title,[_,v]=(0,U.useState)(!1),[y,b]=(0,U.useState)(``),x=Ts(e=>e.entries),[S,C]=(0,U.useState)(!1),w=(0,U.useRef)(null);(0,U.useEffect)(()=>{if(!S)return;let e=e=>{w.current?.contains(e.target)||C(!1)},t=e=>{e.key===`Escape`&&C(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[S]);let{provider:T,model:E}=K(),D=(0,U.useRef)(null),O=(0,U.useMemo)(()=>Bd(t),[t]),k=(0,U.useRef)(0);k.current=O.length+1;let A=(0,U.useMemo)(()=>{let e=new Map;return O.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},[O]),M=J(e=>e.scrollTarget),N=ti(e=>e.autonomy),P=(0,U.useCallback)(e=>{ti.getState().set({autonomy:e}),W()?.send?.({type:`autonomy.switch`,payload:{mode:e}})},[]),[F,I]=(0,U.useState)(!1),[L,R]=(0,U.useState)(!1),[ee,te]=(0,U.useState)(!1);(0,U.useEffect)(()=>{let e=()=>te(!0);return document.addEventListener(`open:context-breakdown`,e),()=>document.removeEventListener(`open:context-breakdown`,e)},[]);let ne=l>0&&c>0?Math.min(100,Math.round(c/l*100)):0,[re,ie]=(0,U.useState)(!0),[ae,oe]=(0,U.useState)(0),[se,ce]=(0,U.useState)(!1),le=(0,U.useRef)(t.length),ue=(0,U.useCallback)(()=>{let e=D.current;if(!e)return;let t=e.scrollSize-e.scrollOffset-e.viewportSize<120;ie(t),t&&(oe(0),le.current=G.getState().messages.length),ce(e.scrollOffset>e.viewportSize&&e.scrollSize>e.viewportSize*2.5)},[]),de=(0,U.useCallback)(e=>{W()?.resumeSession?.(e),C(!1)},[]);(0,U.useEffect)(()=>{let e=D.current;if(e)if(re)e.scrollToIndex(k.current-1,{align:`end`}),le.current=t.length;else{let e=t.length-le.current;e>0&&oe(e)}},[t,re]),(0,U.useEffect)(()=>{ie(!0),oe(0),le.current=G.getState().messages.length,requestAnimationFrame(()=>{D.current?.scrollToIndex(k.current-1,{align:`end`})})},[p]),(0,U.useEffect)(()=>{if(!M)return;let e=A.get(M.id);e!==void 0&&D.current?.scrollToIndex(e,{align:`center`,smooth:!0})},[M,A]);let fe=(0,U.useCallback)(()=>{D.current?.scrollToIndex(k.current-1,{align:`end`,smooth:!0}),ie(!0),oe(0),le.current=G.getState().messages.length},[]),pe=(0,U.useCallback)(()=>{D.current?.scrollToIndex(0,{align:`start`,smooth:!0})},[]),[me,he]=(0,U.useState)(null),[ge,_e]=(0,U.useState)(()=>Date.now()),ye=(0,U.useRef)(null),z=(0,U.useMemo)(()=>{let e=t[t.length-1],n=t.filter(e=>e.role===`tool`&&e.toolResult===void 0),r=`Thinking…`;if(n.length>0){let e=Array.from(new Set(n.map(e=>e.toolName).filter(Boolean))),t=e.slice(0,2).join(`, `),i=e.length>2?` +${e.length-2}`:``;r=n.length===1?`Running ${t||`tool`}…`:`Running ${n.length} tools (${t}${i})…`}else e?.role===`assistant`&&e.content?r=`Writing reply…`:e?.role===`tool`&&e.toolResult!==void 0&&(r=`Thinking about the next step…`);let i=me?Math.max(0,Math.floor((ge-me)/1e3)):0,a=i<60?`${i}s`:`${Math.floor(i/60)}m ${i%60}s`,o=``,s=e?.role===`assistant`&&e.streaming&&e.content?e:null;if(s){let e=ye.current;if(!e||e.id!==s.id)ye.current={id:s.id,at:Date.now(),len:s.content.length};else{let t=Math.max(1,ge-e.at),n=Math.max(0,s.content.length-e.len);if(t>500&&n>0){let e=n*1e3/t;o=e>=1e3?`${(e/1e3).toFixed(1)}k ch/s`:`${Math.round(e)} ch/s`}}}else ye.current&&=null;return{label:r,elapsed:a,speedLabel:o}},[t,ge,me]);(0,U.useEffect)(()=>{n&&me===null&&he(Date.now()),!n&&me!==null&&he(null)},[n,me]),(0,U.useEffect)(()=>{if(!n)return;let e=setInterval(()=>_e(Date.now()),500);return()=>clearInterval(e)},[n]);let be=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`},xe=(()=>{if(!n)return`idle`;let e=t[t.length-1];return e?.role===`assistant`&&e.content&&e.streaming?`streaming`:`thinking`})(),Se=xe===`idle`?`bg-muted text-muted-foreground`:xe===`streaming`?`bg-blue-500/10 text-blue-600 dark:text-blue-400`:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,Ce=l>0&&c>0||o.input>0||!!s;return(0,Y.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0`,children:[(0,Y.jsxs)(`header`,{className:`flex flex-col border-b bg-card/95 backdrop-blur-sm supports-[backdrop-filter]:bg-card/80 shrink-0 sticky top-0 z-20`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0 flex-1 overflow-hidden`,children:[!r&&(0,Y.jsx)($,{variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0`,onClick:i,title:e(`chat:header.openSidebarTitle`),children:(0,Y.jsx)(qt,{className:`h-4 w-4`})}),!r&&(0,Y.jsx)(`div`,{className:`flex items-center gap-1.5 shrink-0 mr-1`,children:(0,Y.jsx)(`div`,{className:`w-5 h-5 rounded bg-primary flex items-center justify-center`,children:(0,Y.jsx)(tn,{className:`h-3 w-3 text-primary-foreground`})})}),(0,Y.jsxs)(`span`,{className:X(`flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[11px] font-medium shrink-0 tabular-nums`,Se),title:`Agent state: ${xe}`,children:[xe!==`idle`&&(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-current animate-pulse`}),(0,Y.jsx)(`span`,{children:xe})]}),p&&(_?(0,Y.jsx)(`input`,{value:y,onChange:e=>b(e.target.value),onBlur:()=>{y.trim()&&h(p,y),v(!1)},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),y.trim()&&h(p,y),v(!1)):e.key===`Escape`&&(e.preventDefault(),v(!1))},placeholder:e(`chat:sessionNamePlaceholder`),className:`h-5 px-1.5 text-[11px] bg-background border border-primary/40 rounded focus:outline-none focus:ring-1 focus:ring-ring shrink-0 w-32`,autoFocus:!0}):(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{b(m||g||``),v(!0)},className:`flex items-center gap-1 text-[11px] font-medium text-foreground/80 hover:text-foreground truncate max-w-[12rem] shrink-0 px-1 -mx-1 rounded hover:bg-muted/50 transition-colors`,title:e(`chat:header.renameTitle`),children:[(0,Y.jsx)(zt,{className:`h-2.5 w-2.5 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate`,children:m||g||e(`chat:header.untitled`)})]}))]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[x.length>1&&(0,Y.jsxs)(`div`,{ref:w,className:`relative shrink-0`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>C(e=>!e),className:`flex items-center gap-0.5 px-1 py-0.5 rounded text-[10px] text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors`,title:e(`chat:switchSession`),children:[(0,Y.jsx)(d,{className:`h-3 w-3`}),(0,Y.jsx)(bn,{className:`h-2.5 w-2.5`})]}),S&&(0,Y.jsx)(`div`,{className:`absolute left-0 top-full mt-1 z-40 w-64 rounded-md border bg-popover shadow-lg p-1 max-h-60 overflow-y-auto`,children:x.slice(0,15).map(t=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>de(t.id),className:X(`w-full text-left px-2 py-1.5 rounded text-xs hover:bg-accent transition-colors`,t.isCurrent&&`bg-primary/10`),children:[(0,Y.jsx)(`div`,{className:`font-medium truncate`,children:t.title||e(`chat:empty`)}),(0,Y.jsxs)(`div`,{className:`text-[10px] text-muted-foreground font-mono truncate`,children:[t.provider,`/`,t.model,` · `,t.tokenTotal.toLocaleString(),` tok`]})]},t.id))})]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>J.getState().setModelSwitcherOpen(!0),className:`group hidden sm:flex items-center gap-1 px-2 py-0.5 rounded-md border bg-background/50 hover:bg-accent hover:border-primary/40 transition-colors text-[11px] min-w-0 shrink-0`,title:e(`chat:header.changeModelTitle`),children:[(0,Y.jsx)(wr,{className:`h-3 w-3 text-muted-foreground group-hover:text-foreground shrink-0`}),(0,Y.jsxs)(`span`,{className:`font-mono truncate max-w-[9rem] xl:max-w-[16rem]`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:T||e(`chat:header.noProvider`)}),(0,Y.jsx)(`span`,{className:`text-muted-foreground/40 mx-0.5`,children:`/`}),(0,Y.jsx)(`span`,{className:`font-medium`,children:E||e(`chat:header.noModel`)})]})]}),(0,Y.jsxs)(`div`,{className:`hidden md:flex items-center gap-1.5 shrink-0`,children:[(0,Y.jsx)(Am,{}),(0,Y.jsx)(Xp,{})]}),u&&(0,Y.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[11px] font-medium bg-primary/10 text-primary shrink-0 hover:bg-primary/20 transition-colors cursor-pointer`,title:e(`chat:header.iterationTitle`),onClick:()=>document.getElementById(`chat-activity`)?.scrollIntoView({behavior:`smooth`,block:`center`}),children:[(0,Y.jsx)($n,{className:`h-3 w-3 animate-pulse`}),`iter `,u.index,u.max>0?`/${u.max}`:``]}),(0,Y.jsx)(sp,{value:N,onChange:P,compact:!0})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[(0,Y.jsxs)($,{variant:F?`secondary`:`ghost`,size:`icon`,className:X(`h-7 w-7 relative`,F&&`bg-amber-500/10 text-amber-600 dark:text-amber-400`),onClick:()=>I(e=>!e),title:e(`chat:header.runningProcessesTitle`),children:[(0,Y.jsx)(En,{className:`h-4 w-4`}),F&&(0,Y.jsx)(`span`,{className:`absolute -bottom-0.5 left-1/2 -translate-x-1/2 w-1 h-1 rounded-full bg-amber-500`})]}),(0,Y.jsxs)($,{variant:L?`secondary`:`ghost`,size:`icon`,className:X(`h-7 w-7 relative`,L&&`bg-violet-500/10 text-violet-600 dark:text-violet-400`),onClick:()=>R(e=>!e),title:e(`chat:header.checkpointsTitle`),children:[(0,Y.jsx)(d,{className:`h-4 w-4`}),L&&(0,Y.jsx)(`span`,{className:`absolute -bottom-0.5 left-1/2 -translate-x-1/2 w-1 h-1 rounded-full bg-violet-500`})]})]})]}),Ce&&(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 py-1 border-t bg-muted/20 text-[11px] text-muted-foreground`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1 tabular-nums`,children:[c>0&&(0,Y.jsx)(Kd,{pct:ne,tokens:c,maxTokens:l>0?l:void 0,onClick:()=>te(!0)}),o.input>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:Ld(o.input)}),(0,Y.jsx)(`span`,{children:`in`})]}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:Ld(o.output)}),(0,Y.jsx)(`span`,{children:`out`})]}),o.cacheRead&&o.cacheRead>0&&(()=>{let e=(o.cacheRead??0)+o.input,t=e>0?Math.round((o.cacheRead??0)/e*100):0;return(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,title:`Cache hit ratio: ${t}%`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:Ld(o.cacheRead)}),(0,Y.jsxs)(`span`,{children:[`cache (`,t,`%)`]})]})})(),(0,Y.jsx)(Qp,{})]})]}),s&&(0,Y.jsx)(`span`,{className:`text-muted-foreground/70 tabular-nums shrink-0`,children:be(s)})]})]}),(0,Y.jsxs)(`div`,{className:`relative min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,Y.jsx)(Pm,{}),!re&&(0,Y.jsxs)(`button`,{type:`button`,onClick:fe,className:X(`absolute bottom-4 left-1/2 -translate-x-1/2 z-10 jump-bottom`,`flex items-center gap-2 px-4 py-2 rounded-full shadow-lg`,`bg-primary text-primary-foreground text-xs font-medium`,`hover:bg-primary/90 transition-colors animate-message`),children:[(0,Y.jsx)(ct,{className:`h-3.5 w-3.5`}),ae>0?`${ae} new message${ae===1?``:`s`}`:`Jump to latest`]}),se&&(0,Y.jsxs)(`button`,{type:`button`,onClick:pe,title:e(`chat:header.scrollTopTitle`),className:X(`absolute top-3 right-3 z-10`,`flex items-center gap-1 px-2.5 py-1 rounded-full 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,Y.jsx)(Vr,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:`Top`})]}),O.length===0&&!n?(0,Y.jsx)(`div`,{className:`h-full overflow-y-auto overscroll-contain`,children:(0,Y.jsx)(`div`,{className:`mx-auto max-w-5xl w-full px-4 pt-4 pb-8`,children:(0,Y.jsx)(Bm,{})})}):(0,Y.jsxs)(ve,{ref:D,className:`h-full`,onScroll:ue,children:[O.map((e,t)=>(0,Y.jsx)(Hm,{row:e,isLoading:n,compactMode:a,isFirstRow:t===0},e.key)),(0,Y.jsxs)(`div`,{id:`chat-activity`,className:X(`mx-auto max-w-5xl w-full px-4`,a?`pb-3`:`pb-8`),children:[(0,Y.jsx)(Vm,{}),n&&(0,Y.jsxs)(`div`,{className:`flex gap-3 animate-message`,children:[(0,Y.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,Y.jsx)(j,{className:`h-4 w-4`})}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:(0,Y.jsx)(`div`,{className:`rounded-2xl px-4 py-3 bg-card border text-foreground`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex gap-1`,children:[(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary/70 animate-bounce [animation-delay:-0.3s]`}),(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary/70 animate-bounce [animation-delay:-0.15s]`}),(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary/70 animate-bounce`})]}),(0,Y.jsx)(`span`,{className:`text-foreground/90`,children:z.label}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:z.elapsed}),u&&(0,Y.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[`· iter `,u.index,u.max>0?`/${u.max}`:``]}),z.speedLabel&&(0,Y.jsxs)(`span`,{className:`text-xs text-muted-foreground/80 tabular-nums`,children:[`· `,z.speedLabel]})]})})})]})]},`__live`)]})]}),(0,Y.jsxs)(`div`,{className:`border-t bg-card/50 backdrop-blur supports-[backdrop-filter]:bg-card/50 shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`ws-shortcut-hints max-w-5xl mx-auto px-4 pt-1.5 flex items-center gap-3 text-[10px] text-muted-foreground/50 select-none overflow-x-auto`,children:[(0,Y.jsxs)(`span`,{title:`Enter`,className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(`kbd`,{children:`Enter`}),` send`]}),(0,Y.jsx)(`span`,{className:`opacity-50`,children:`·`}),(0,Y.jsxs)(`span`,{title:`Shift+Enter`,className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(`kbd`,{children:`Shift`}),`+`,(0,Y.jsx)(`kbd`,{children:`↵`}),` newline`]}),(0,Y.jsx)(`span`,{className:`opacity-50`,children:`·`}),(0,Y.jsxs)(`span`,{title:`Ctrl+\\\\`,className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(`kbd`,{children:`Ctrl+\\`}),` sidebar`]}),(0,Y.jsx)(`span`,{className:`opacity-50`,children:`·`}),(0,Y.jsxs)(`span`,{title:`Ctrl+F`,className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(`kbd`,{children:`Ctrl+F`}),` search`]}),(0,Y.jsx)(`span`,{className:`opacity-50`,children:`·`}),(0,Y.jsxs)(`span`,{title:`Ctrl+K`,className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(`kbd`,{children:`Ctrl+K`}),` palette`]}),(0,Y.jsx)(`span`,{className:`opacity-50`,children:`·`}),(0,Y.jsxs)(`span`,{title:`Ctrl+L / Ctrl+N`,className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(`kbd`,{children:`Ctrl+L`}),` clear`]}),(0,Y.jsx)(`span`,{className:`opacity-50`,children:`·`}),(0,Y.jsxs)(`span`,{title:e(`chat:header.jkNavigateTitle`),className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(`kbd`,{children:`j`}),(0,Y.jsx)(`kbd`,{children:`k`}),` navigate`]}),(0,Y.jsx)(`span`,{className:`opacity-50`,children:`·`}),(0,Y.jsxs)(`span`,{title:`Ctrl+M`,className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(`kbd`,{children:`Ctrl+M`}),` model`]}),(0,Y.jsx)(`span`,{className:`opacity-50`,children:`·`}),(0,Y.jsxs)(`span`,{title:`Ctrl+Shift+D`,className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(`kbd`,{children:`Ctrl+⇧D`}),` density`]})]}),(0,Y.jsx)(`div`,{className:`ws-chat-input-wrap p-4`,children:(0,Y.jsx)(`div`,{className:`max-w-5xl mx-auto`,children:(0,Y.jsx)(Jp,{onOpenBreakdown:()=>te(!0)})})})]}),(0,Y.jsx)(jm,{open:F,onClose:()=>I(!1)}),(0,Y.jsx)(Yp,{open:L,onClose:()=>R(!1)}),(0,Y.jsx)(Zp,{open:ee,onClose:()=>te(!1)})]})}var Wm={ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,css:`css`,html:`html`,svg:`xml`,md:`markdown`,yml:`yaml`,yaml:`yaml`,toml:`toml`,sh:`shell`,bash:`shell`,ps1:`powershell`,py:`python`,rs:`rust`,go:`go`,rb:`ruby`,java:`java`,c:`c`,cpp:`cpp`,h:`c`,hpp:`cpp`,sql:`sql`,xml:`xml`},Gm=Array.from(new Set(Object.values(Wm))).filter(e=>e!==`plaintext`),Km=12e3,qm=4e3,Jm=5e3,Ym=1e4;function Xm(e){return Wm[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function Zm(e){return e.match(/([A-Za-z_$][\w$]*)$/)?.[1]??``}function Qm(e,t){return e.triggerCharacter?!0:t.length>=3}function $m(e,t){return e.triggerCharacter===`.`?!0:e.triggerCharacter?!1:/^(findBy|findAllBy|create|update|delete|remove|get[A-Z_]|set[A-Z_]|use[A-Z_])/.test(t)}function eh(e){return[e.filePath,e.language,e.lineNumber,e.column,e.versionId??``,e.triggerCharacter??``,e.linePrefix.slice(-160),e.suffix.slice(0,160)].join(`\0`)}u.config({monaco:xe});function th(e){switch(e){case`method`:return me.CompletionItemKind.Method;case`function`:return me.CompletionItemKind.Function;case`constructor`:return me.CompletionItemKind.Constructor;case`field`:return me.CompletionItemKind.Field;case`variable`:return me.CompletionItemKind.Variable;case`class`:return me.CompletionItemKind.Class;case`interface`:return me.CompletionItemKind.Interface;case`module`:return me.CompletionItemKind.Module;case`property`:return me.CompletionItemKind.Property;case`unit`:return me.CompletionItemKind.Unit;case`value`:return me.CompletionItemKind.Value;case`enum`:return me.CompletionItemKind.Enum;case`keyword`:return me.CompletionItemKind.Keyword;case`snippet`:return me.CompletionItemKind.Snippet;case`file`:return me.CompletionItemKind.File;case`reference`:return me.CompletionItemKind.Reference;default:return me.CompletionItemKind.Text}}function nh(){let e=ic(e=>e.openFiles),t=ic(e=>e.activeFilePath),n=ic(e=>e.setActiveFile),r=ic(e=>e.closeFile);return e.length===0?null:(0,Y.jsx)(`div`,{className:`flex items-center border-b bg-muted/40 overflow-x-auto shrink-0`,children:e.map(e=>{let i=e.path===t,a=e.path.split(`/`).pop()??e.path;return(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>n(e.path),onMouseDown:t=>{t.button===1&&(t.preventDefault(),r(e.path))},className:X(`group flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r whitespace-nowrap min-w-0 max-w-[180px] transition-colors`,i?`bg-background border-t-2 border-t-primary text-foreground -mb-px`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),title:e.path,children:[e.dirty&&(0,Y.jsx)(Or,{className:`h-2 w-2 fill-current text-primary shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate`,children:a}),(0,Y.jsx)(Xn,{className:X(`h-3 w-3 shrink-0 rounded-sm hover:bg-muted-foreground/20 opacity-0 group-hover:opacity-100 transition-opacity`,i&&`opacity-100`),onClick:t=>{t.stopPropagation(),r(e.path)}})]},e.path)})})}function rh(){let{t:e}=V(),t=ic(e=>e.openFiles),n=ic(e=>e.activeFilePath),r=ic(e=>e.updateContent),{theme:i}=ud(),a=(0,U.useRef)(null),o=(0,U.useRef)(n),s=(0,U.useRef)(new Map),c=(0,U.useMemo)(()=>t.find(e=>e.path===n)??null,[t,n]),l=n?Xm(n):`plaintext`,u=tp(),[d,f]=(0,U.useState)(!1);(0,U.useEffect)(()=>{o.current=n},[n]),(0,U.useEffect)(()=>{let e=tp();ne.setTheme(e)},[i]),(0,U.useEffect)(()=>{let e=Gm.map(e=>me.registerCompletionItemProvider(e,{triggerCharacters:[`.`,`_`],provideCompletionItems:async(e,t,n,r)=>{let i=o.current;if(!i)return{suggestions:[]};let a=e.getOffsetAt(t),c=e.getValue(),l=c.slice(Math.max(0,a-Km),a),u=c.slice(a,a+qm),d=e.getLineContent(t.lineNumber).slice(0,Math.max(0,t.column-1)),f=Zm(d),p={triggerCharacter:n.triggerCharacter,triggerKind:n.triggerKind};if(!Qm(p,f))return{suggestions:[]};let m=`cmp_${Date.now()}_${Math.random().toString(36).slice(2)}`,h=e.getWordUntilPosition(t),g={startLineNumber:t.lineNumber,endLineNumber:t.lineNumber,startColumn:h.startColumn,endColumn:t.column},_=W(K.getState().wsUrl),v=e=>e.map((e,t)=>({label:e.label,kind:th(e.kind),insertText:e.insertText,detail:e.detail??(e.source?`WrongStack ${e.source}`:void 0),documentation:e.documentation,sortText:e.sortText??`${String(t).padStart(3,`0`)}-${e.label}`,range:g,insertTextRules:e.kind===`snippet`?me.CompletionItemInsertTextRule.InsertAsSnippet:void 0})),y=eh({filePath:i,language:e.getLanguageId(),lineNumber:t.lineNumber,column:t.column,versionId:e.getVersionId(),triggerCharacter:n.triggerCharacter,linePrefix:d,suffix:u}),b=s.current.get(y);return b&&b.expiresAt>Date.now()?{suggestions:v(b.items)}:await new Promise(a=>{let o=!1,d=()=>{},h=null,g,b=e=>{o||(o=!0,d(),g!==void 0&&window.clearTimeout(g),h?.dispose(),a({suggestions:e}))};d=_.on(`completion.result`,e=>{let t=e;t.payload.requestId===m&&(s.current.set(y,{expiresAt:Date.now()+Ym,items:t.payload.items}),b(v(t.payload.items)))}),g=window.setTimeout(()=>b([]),Jm),h=r.onCancellationRequested(()=>b([])),_.requestCompletion({requestId:m,filePath:i,language:e.getLanguageId(),lineNumber:t.lineNumber,column:t.column,content:c.length<=5e5?c:void 0,prefix:l,suffix:u,triggerCharacter:n.triggerCharacter,triggerKind:n.triggerKind,allowLlm:$m(p,f)})})}}));return()=>{e.forEach(e=>{e.dispose()})}},[]);let p=(0,U.useCallback)(()=>{let e=a.current;if(!e)return null;let t=e.getSelection();if(!t||t.isEmpty())return null;let n=e.getModel();if(!n)return null;let r=n.getValueInRange(t);return r.trim()?{content:r,startLine:t.startLineNumber,endLine:t.endLineNumber}:null},[]),m=(0,U.useCallback)(()=>{Q(`chat`),requestAnimationFrame(()=>{document.querySelector(`textarea[placeholder*="agent"], textarea[placeholder*="follow-up"]`)?.focus()})},[]),h=(0,U.useCallback)(()=>{let e=o.current;if(!e)return;let t=p();t&&(lc.getState().addRef({kind:`snippet`,path:e,startLine:t.startLine,endLine:t.endLine,content:t.content}),m())},[p,m]),g=(0,U.useCallback)(()=>{let e=o.current;e&&(lc.getState().addRef({kind:`file`,path:e}),m())},[m]),_=(0,U.useCallback)(t=>{a.current=t,ne.setTheme(tp()),t.onDidChangeCursorSelection(()=>{let e=t.getSelection();f(!!e&&!e.isEmpty())}),t.addAction({id:`wrongstack-send-to-chat`,label:e(`activity:codeEditor.sendSelectionAction`),contextMenuGroupId:`wrongstack`,contextMenuOrder:0,precondition:void 0,keybindings:[k.CtrlCmd|k.Shift|Ae.KeyL],run:e=>{let t=e.getSelection();t&&!t.isEmpty()?h():g()}})},[h,g]),v=(0,U.useCallback)(e=>{n&&e!==void 0&&r(n,e)},[n,r]);return(0,U.useEffect)(()=>{let e=e=>{let t=e.ctrlKey||e.metaKey,r=e.target?.tagName?.toLowerCase()===`textarea`||e.target?.closest(`.monaco-editor`)!==null;!t||!r||(e.key.toLowerCase()===`s`&&(e.preventDefault(),window.dispatchEvent(new CustomEvent(`wrongstack:save-file`,{detail:{filePath:n}}))),e.key.toLowerCase()===`w`&&(e.preventDefault(),n&&ic.getState().closeFile(n)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),t.length===0?(0,Y.jsx)(`div`,{className:`flex h-full min-w-0 items-center justify-center`,children:(0,Y.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`activity:codeEditor.noFilesOpen`)}),(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground/60`,children:e(`activity:codeEditor.selectToEdit`)})]})}):(0,Y.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col overflow-hidden`,children:[(0,Y.jsx)(nh,{}),(0,Y.jsxs)(`div`,{className:`relative min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(d||c)&&(0,Y.jsx)(`div`,{className:`absolute top-2 right-2 z-10 flex items-center gap-1 rounded-lg border border-border bg-popover/95 backdrop-blur shadow-md p-1`,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:d?h:g,className:`inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-[11px] text-foreground hover:bg-accent transition-colors`,title:e(d?`activity:codeEditor.sendSelectedTitle`:`activity:codeEditor.mentionFileTitle`),children:[d?(0,Y.jsx)(er,{className:`h-3 w-3`}):(0,Y.jsx)(gn,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:e(d?`activity:codeEditor.sendToChat`:`activity:codeEditor.mentionFile`)})]})}),c?(0,Y.jsx)(Re,{language:l,value:c.content,onChange:v,theme:u,onMount:_,loading:(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Y.jsx)(`span`,{className:`text-[11px] text-muted-foreground animate-pulse`,children:e(`activity:codeEditor.loadingEditor`)})}),options:{minimap:{enabled:!1},fontSize:13,fontFamily:`'IBM Plex Mono', 'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace`,lineNumbers:`on`,renderWhitespace:`selection`,scrollBeyondLastLine:!1,wordWrap:`off`,tabSize:2,smoothScrolling:!0,cursorBlinking:`smooth`,cursorSmoothCaretAnimation:`on`,bracketPairColorization:{enabled:!0},"semanticHighlighting.enabled":!0,automaticLayout:!0,padding:{top:8}}},c.path):(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e(`activity:codeEditor.selectTab`)})})]})]})}function ih(e){return/edit|write|create|patch/i.test(e)?mn:/bash|shell|exec|run|command/i.test(e)?En:/fetch|http|web|curl|request/i.test(e)?$e:In}function ah({toolName:e,input:t}){let{t:n}=V(),r=ep(e,t);if(r)return(0,Y.jsx)(`div`,{className:`rounded-lg overflow-hidden border`,children:(0,Y.jsx)(Zf,{oldText:r.oldText,newText:r.newText,caption:r.caption})});if(typeof t==`object`&&t){let e=t,r=e.command??e.cmd??e.script;if(typeof r==`string`&&r.trim().length>0)return(0,Y.jsxs)(`div`,{className:`rounded-lg border bg-background/40 overflow-hidden`,children:[(0,Y.jsxs)(`div`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wider text-muted-foreground border-b bg-muted/40 flex items-center gap-1.5`,children:[(0,Y.jsx)(En,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:n(`confirm.command`)})]}),(0,Y.jsx)(`pre`,{className:`px-3 py-2 text-xs font-mono whitespace-pre-wrap break-all max-h-40 overflow-auto`,children:r})]});let i=e.url;if(typeof i==`string`)return(0,Y.jsxs)(`div`,{className:`rounded-lg border bg-background/40 px-3 py-2 text-xs font-mono`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:(e.method??`GET`).toUpperCase()}),` `,(0,Y.jsx)(`span`,{className:`break-all`,children:i})]})}return(0,Y.jsxs)(`div`,{className:`p-3 rounded-lg bg-muted/50 border text-xs font-mono`,children:[(0,Y.jsx)(`div`,{className:`text-muted-foreground mb-2`,children:n(`confirm.inputLabel`)}),(0,Y.jsx)(`pre`,{className:`whitespace-pre-wrap break-all max-h-60 overflow-auto`,children:JSON.stringify(t,null,2)})]})}function oh(){let{showConfirmDialog:e,confirmInfo:t,hideConfirm:n}=J(),{t:r}=V(),i=ti(e=>e.yolo),a=ti(e=>e.set),{sendConfirm:o,updatePrefs:s}=sd(),c=(0,U.useRef)(null),l=(0,U.useRef)(!1);(0,U.useEffect)(()=>{e&&t&&(l.current=!1)},[e,t?.id,t]);let u=e=>{l.current||(l.current=!0,t&&o(t.id,e),n())},d=e=>{if(!e){if(t){u(`no`);return}n()}},f=()=>{a({yolo:!0}),s({yolo:!0})};if((0,U.useEffect)(()=>{!e||!t||!i||t.riskTier!==`destructive`&&t.decisionSource!==`yolo_destructive`&&u(`yes`)},[e,t?.id,t?.decisionSource,t?.riskTier,i]),(0,U.useEffect)(()=>{if(!e)return;let t=e=>{let t=e.target?.tagName?.toLowerCase();t===`input`||t===`textarea`||(e.key===`y`||e.key===`Y`?(e.preventDefault(),u(`yes`)):e.key===`n`||e.key===`N`||e.key===`Escape`?(e.preventDefault(),u(`no`)):e.key===`a`||e.key===`A`?(e.preventDefault(),u(`always`)):(e.key===`d`||e.key===`D`)&&(e.preventDefault(),u(`deny`)))};return window.addEventListener(`keydown`,t),c.current?.focus(),()=>window.removeEventListener(`keydown`,t)},[e,t?.id]),!t)return null;let p=ih(t.toolName),m=/edit|write/i.test(t.toolName),h=t.riskTier??`standard`;return(0,Y.jsx)(bf,{open:e,onOpenChange:d,children:(0,Y.jsxs)(Cf,{className:`sm:max-w-2xl max-h-[min(88dvh,760px)] overflow-hidden !flex flex-col border-yellow-500/50`,ref:c,tabIndex:-1,children:[(0,Y.jsxs)(wf,{className:`shrink-0`,children:[(0,Y.jsxs)(Ef,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(te,{className:`h-5 w-5 text-yellow-500 animate-pulse`}),r(`confirm.title`,{tool:t.toolName})]}),(0,Y.jsx)(Df,{children:r(m?`confirm.descriptionEdit`:`confirm.descriptionTool`)})]}),(0,Y.jsxs)(`div`,{className:`py-2 pr-1 space-y-3 overflow-y-auto min-h-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 p-3 rounded-lg bg-muted`,children:[(0,Y.jsx)(p,{className:`h-5 w-5 text-muted-foreground`}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`font-medium font-mono truncate`,children:t.toolName}),(0,Y.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[r(m?`confirm.fileModification`:`confirm.toolExecution`),` —`,` `,r(`confirm.riskSuffix`,{risk:h})]})]})]}),t.input!==void 0&&(0,Y.jsx)(ah,{toolName:t.toolName,input:t.input}),t.suggestedPattern&&(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/20`,children:[(0,Y.jsx)(gt,{className:`h-4 w-4 text-yellow-600 mt-0.5 shrink-0`}),(0,Y.jsxs)(`div`,{className:`text-sm min-w-0`,children:[(0,Y.jsx)(`div`,{className:`font-medium text-yellow-800 dark:text-yellow-200`,children:r(`confirm.trustSuggestionTitle`)}),(0,Y.jsx)(`div`,{className:`font-mono text-xs mt-1 break-all`,children:t.suggestedPattern}),(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:r(`confirm.trustSuggestionHint`)})]})]}),i&&(t.riskTier===`destructive`||t.decisionSource===`yolo_destructive`)&&(0,Y.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:r(`confirm.yoloDestructiveNote`)}),!i&&(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 p-3 rounded-lg bg-primary/5 border border-primary/20`,children:[(0,Y.jsx)(tn,{className:`h-4 w-4 text-primary mt-0.5 shrink-0`}),(0,Y.jsxs)(`div`,{className:`text-sm min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`font-medium`,children:r(`confirm.skipApprovalsTitle`)}),(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground mt-0.5`,children:r(`confirm.skipApprovalsHint`)})]}),(0,Y.jsx)($,{variant:`outline`,size:`sm`,onClick:f,title:r(`confirm.enableYoloTitle`),className:`shrink-0`,children:r(`confirm.enableYoloBtn`)})]})]}),(0,Y.jsxs)(Tf,{className:`gap-2 sm:gap-2 flex-wrap shrink-0`,children:[(0,Y.jsxs)($,{variant:`outline`,size:`sm`,onClick:()=>u(`deny`),title:r(`confirm.denyAlwaysTitle`),children:[r(`confirm.denyAlways`),` `,(0,Y.jsx)(`kbd`,{className:`ml-1 text-[10px] border rounded px-1 bg-background`,children:`d`})]}),(0,Y.jsxs)($,{variant:`outline`,size:`sm`,onClick:()=>u(`no`),title:r(`confirm.noTitle`),children:[r(`action.no`),` `,(0,Y.jsx)(`kbd`,{className:`ml-1 text-[10px] border rounded px-1 bg-background`,children:`n`})]}),(0,Y.jsxs)($,{variant:`outline`,size:`sm`,onClick:()=>u(`always`),title:r(`confirm.alwaysTitle`),children:[r(`action.always`),` `,(0,Y.jsx)(`kbd`,{className:`ml-1 text-[10px] border rounded px-1 bg-background`,children:`a`})]}),(0,Y.jsxs)($,{size:`sm`,onClick:()=>u(`yes`),title:r(`confirm.yesTitle`),children:[r(`action.yes`),` `,(0,Y.jsx)(`kbd`,{className:`ml-1 text-[10px] border rounded px-1 bg-background/80`,children:`y`})]})]})]})})}function sh(){let{t:e}=V(),t=K(e=>e.wsStatus),n=K(e=>e.wsUrl),[r,i]=(0,U.useState)(!1),[a,o]=(0,U.useState)(Date.now());if((0,U.useEffect)(()=>{if(t.state!==`reconnecting`)return;let e=setInterval(()=>o(Date.now()),500);return()=>clearInterval(e)},[t.state]),(0,U.useEffect)(()=>{t.state===`open`&&i(!1)},[t.state]),t.state===`open`||t.state===`connecting`||r)return null;let s=()=>W(n).retryNow(),c=t.state===`reconnecting`,l=t.state===`closed`?t.error:t.state===`reconnecting`?t.lastError:void 0,u=c?Math.max(0,Math.ceil((t.nextRetryAt-a)/1e3)):0;return(0,Y.jsxs)(`div`,{className:X(`flex items-center gap-3 px-4 py-2 border-b text-sm`,c?`bg-orange-500/10 text-orange-700 dark:text-orange-300 border-orange-500/30`:`bg-red-500/10 text-red-700 dark:text-red-300 border-red-500/30`),children:[c?(0,Y.jsx)(B,{className:`h-4 w-4 animate-spin shrink-0`}):(0,Y.jsx)(sn,{className:`h-4 w-4 shrink-0`}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`font-medium`,children:c?e(`activity:connection.reconnecting`,{attempt:t.attempt,remaining:u}):e(`activity:connection.disconnected`)}),l&&(0,Y.jsx)(`div`,{className:`text-xs opacity-80 truncate`,children:l})]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:s,className:X(`inline-flex items-center gap-1 px-2.5 py-1 rounded-md border text-xs font-medium`,`hover:bg-background/30 transition-colors shrink-0`,c?`border-orange-500/40`:`border-red-500/40`),title:e(`activity:connection.retryTitle`),children:[(0,Y.jsx)(Le,{className:`h-3 w-3`}),e(`activity:connection.retry`)]}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>i(!0),className:`text-current/60 hover:text-current shrink-0`,title:e(`activity:connection.dismissTitle`),children:(0,Y.jsx)(Xn,{className:`h-4 w-4`})})]})}function ch({title:e,value:t,subtitle:n,icon:r,color:i=`text-blue-500`,trend:a}){let{t:o}=V();return(0,Y.jsxs)(`div`,{className:`bg-card rounded-lg border p-4 shadow-sm`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground font-medium`,children:e}),(0,Y.jsx)(`p`,{className:`text-2xl font-bold mt-1 ${i}`,children:t}),n&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:n})]}),(0,Y.jsx)(`div`,{className:`p-2 rounded-lg bg-muted ${i}`,children:(0,Y.jsx)(r,{className:`w-5 h-5`})})]}),a&&(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center gap-1`,children:[a===`up`&&(0,Y.jsx)(Ze,{className:`w-3 h-3 text-green-500`}),a===`down`&&(0,Y.jsx)(Ze,{className:`w-3 h-3 text-red-500 rotate-180`}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:o(a===`up`?`activity:debug.trendUp`:a===`down`?`activity:debug.trendDown`:`activity:debug.trendStable`)})]})]})}function lh(){let{t:e}=V(),[t,n]=(0,U.useState)({fileWatcher:null,system:null,lastUpdated:null,error:null}),[r,i]=(0,U.useState)(!0),[a,o]=(0,U.useState)(2e3),s=(0,U.useCallback)(async()=>{try{let e=await fetch(`/debug/watcher-metrics`),t=null;e.ok&&(t=await e.json());let r={memoryUsage:{heapUsed:performance.memory?.usedJSHeapSize??0,heapTotal:performance.memory?.totalJSHeapSize??0,external:0,rss:0,arrayBuffers:0},uptime:performance.timeOrigin?performance.now()/1e3:0,cpuUsage:{user:0,system:0}};n({fileWatcher:t,system:r,lastUpdated:new Date,error:null})}catch(e){n(t=>({...t,error:e instanceof Error?e.message:b.t(`activity:debug.fetchFailed`)}))}finally{i(!1)}},[]);return(0,U.useEffect)(()=>{s();let e=setInterval(s,a);return()=>clearInterval(e)},[s,a]),(0,Y.jsx)(`div`,{className:`h-full min-h-0 min-w-0 flex-1 overflow-y-auto bg-background p-6`,children:(0,Y.jsxs)(`div`,{className:`max-w-6xl mx-auto space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`h1`,{className:`text-2xl font-bold flex items-center gap-2`,children:[(0,Y.jsx)(Sr,{className:`w-7 h-7`}),e(`activity:debug.heading`)]}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e(`activity:debug.subtitle`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,Y.jsx)(Rn,{className:`w-4 h-4 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:debug.refreshLabel`)}),(0,Y.jsxs)(`select`,{value:a,onChange:e=>o(Number(e.target.value)),className:`bg-background border rounded px-2 py-1 text-sm`,children:[(0,Y.jsx)(`option`,{value:1e3,children:`1s`}),(0,Y.jsx)(`option`,{value:2e3,children:`2s`}),(0,Y.jsx)(`option`,{value:5e3,children:`5s`}),(0,Y.jsx)(`option`,{value:1e4,children:`10s`})]})]}),(0,Y.jsxs)(`button`,{onClick:()=>{i(!0),s()},disabled:r,className:`flex items-center gap-2 px-3 py-1.5 bg-primary text-primary-foreground rounded-lg text-sm font-medium hover:opacity-90 disabled:opacity-50`,children:[(0,Y.jsx)(Rn,{className:`w-4 h-4 ${r?`animate-spin`:``}`}),e(`common:action.refresh`)]})]})]}),t.lastUpdated&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,Y.jsx)(Ge,{className:`w-4 h-4`}),e(`activity:debug.lastUpdated`,{time:t.lastUpdated.toLocaleTimeString()})]}),t.error&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 p-4 bg-destructive/10 border border-destructive/30 rounded-lg text-destructive`,children:[(0,Y.jsx)(Ct,{className:`w-5 h-5 flex-shrink-0`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:`font-medium`,children:e(`activity:debug.fetchFailed`)}),(0,Y.jsx)(`p`,{className:`text-sm opacity-80`,children:t.error})]})]}),(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`h2`,{className:`text-lg font-semibold flex items-center gap-2 mb-4`,children:[(0,Y.jsx)(An,{className:`w-5 h-5`}),e(`activity:debug.fileWatcher`)]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4`,children:[(0,Y.jsx)(ch,{title:e(`activity:debug.watcherStatus`),value:t.fileWatcher?.watcherActive?e(`activity:debug.running`):e(`activity:debug.stopped`),icon:pe,color:t.fileWatcher?.watcherActive?`text-green-500`:`text-red-500`}),(0,Y.jsx)(ch,{title:e(`activity:debug.activeProjects`),value:t.fileWatcher?.activeProjects??0,subtitle:e(`activity:debug.projectsWatched`),icon:Hn,color:`text-purple-500`}),(0,Y.jsx)(ch,{title:e(`activity:debug.fileChanges`),value:t.fileWatcher?.fileChangesDetected??0,subtitle:e(`activity:debug.totalDetected`),icon:$n,color:`text-blue-500`,trend:`neutral`}),(0,Y.jsx)(ch,{title:e(`activity:debug.filesProcessed`),value:t.fileWatcher?.filesProcessed??0,subtitle:e(`activity:debug.afterHash`),icon:se,color:`text-cyan-500`})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mt-4`,children:[(0,Y.jsx)(ch,{title:e(`activity:debug.broadcastsSent`),value:t.fileWatcher?.broadcastsSent??0,subtitle:e(`activity:debug.toClients`),icon:Ze,color:`text-green-500`}),(0,Y.jsx)(ch,{title:e(`activity:debug.debounceResets`),value:t.fileWatcher?.debounceResets??0,subtitle:e(`activity:debug.rapidWrites`),icon:Rn,color:`text-orange-500`}),(0,Y.jsx)(ch,{title:e(`activity:debug.avgDebounce`),value:`${(t.fileWatcher?.averageDebounceDelayMs??0).toFixed(1)}ms`,subtitle:e(`activity:debug.actualDelay`),icon:Ge,color:`text-yellow-500`}),(0,Y.jsx)(ch,{title:e(`activity:debug.totalDelay`),value:`${(t.fileWatcher?.totalDebounceDelayMs??0).toFixed(0)}ms`,subtitle:e(`activity:debug.sumDelays`),icon:Sr,color:`text-indigo-500`})]})]}),(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`h2`,{className:`text-lg font-semibold flex items-center gap-2 mb-4`,children:[(0,Y.jsx)(se,{className:`w-5 h-5`}),e(`activity:debug.browserPerf`)]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,Y.jsx)(ch,{title:e(`activity:debug.heapUsed`),value:uh(t.system?.memoryUsage?.heapUsed??0),subtitle:e(`activity:debug.jsHeap`),icon:Sr,color:`text-blue-500`}),(0,Y.jsx)(ch,{title:e(`activity:debug.heapTotal`),value:uh(t.system?.memoryUsage?.heapTotal??0),subtitle:e(`activity:debug.totalHeap`),icon:Sr,color:`text-green-500`}),(0,Y.jsx)(ch,{title:e(`activity:debug.pageUptime`),value:dh(t.system?.uptime??0),subtitle:e(`activity:debug.sinceLoad`),icon:Ge,color:`text-purple-500`})]})]}),(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`h2`,{className:`text-lg font-semibold flex items-center gap-2 mb-4`,children:[(0,Y.jsx)($n,{className:`w-5 h-5`}),e(`activity:debug.rawData`)]}),(0,Y.jsx)(`div`,{className:`bg-card rounded-lg border p-4 shadow-sm`,children:(0,Y.jsx)(`pre`,{className:`text-xs font-mono overflow-x-auto`,children:JSON.stringify({fileWatcher:t.fileWatcher,browserMemory:t.system?.memoryUsage,pageUptime:t.system?.uptime},null,2)})})]})]})})}function uh(e){if(e===0)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return`${(e/t**r).toFixed(1)} ${n[r]}`}function dh(e){return e<60?`${e.toFixed(0)}s`:e<3600?`${(e/60).toFixed(1)}m`:`${(e/3600).toFixed(1)}h`}function fh(e,t,n){return e<t?t:e>n?n:e}function ph(e){let t=/^oklch\(\s*([^)]+)\)$/i.exec(e.trim());if(!t?.[1])return null;let n=(t[1].split(`/`)[0]??``).trim().split(/\s+/);if(n.length<3||!n[0]||!n[1]||!n[2])return null;let r=n[0].endsWith(`%`)?Number.parseFloat(n[0])/100:Number.parseFloat(n[0]),i=n[1].endsWith(`%`)?Number.parseFloat(n[1])/100*.4:Number.parseFloat(n[1]),a=Number.parseFloat(n[2].replace(/deg$/i,``));return[r,i,a].every(Number.isFinite)?[fh(r,0,1),Math.max(0,i),a]:null}function mh(e){return fh(e<=.0031308?12.92*e:1.055*e**(1/2.4)-.055,0,1)}function hh(e){return Math.round(e*255).toString(16).padStart(2,`0`)}function gh(e){let t=ph(e);if(!t)return null;let[n,r,i]=t,a=i*Math.PI/180,o=r*Math.cos(a),s=r*Math.sin(a),c=n+.3963377774*o+.2158037573*s,l=n-.1055613458*o-.0638541728*s,u=n-.0894841775*o-1.291485548*s,d=c**3,f=l**3,p=u**3,m=4.0767416621*d-3.3077115913*f+.2309699292*p,h=-1.2684380046*d+2.6097574011*f-.3413193965*p,g=-.0041960863*d-.7034186147*f+1.707614701*p;return`#${hh(mh(m))}${hh(mh(h))}${hh(mh(g))}`}function _h(e){let t=e.trim(),n=gh(t);if(n)return n.toLowerCase();let r=/^#([0-9a-f]{6})([0-9a-f]{2})?$/i.exec(t);if(r?.[1])return`#${r[1].toLowerCase()}`;let i=/^#([0-9a-f]{3})$/i.exec(t);return i?.[1]?`#${i[1].split(``).map(e=>e+e).join(``).toLowerCase()}`:null}var vh=[`web`,`react-native`,`flutter`,`swiftui`,`compose`],yh=[`primary`,`accent`,`bg`,`surface`,`fg`,`border`];function bh(e,t,n){let r={...e};for(let[e,i]of Object.entries(t))e.startsWith(`light.`)?n===`light`&&(r[e.slice(6)]=i):e.startsWith(`dark.`)?n===`dark`&&(r[e.slice(5)]=i):r[e]=i;return r}function xh({t:e,label:t}){let n=e.bg??`#fff`,r=e.surface??n,i=e.fg??`#111`,a=e.muted??i,o=e.primary??`#3b82f6`,s=e.accent??o,c=e.border??a,l=e.radius??`0.5rem`,u=e.fontSans??`system-ui, sans-serif`,d=e.fontDisplay??u,f=e.shadow&&e.shadow!==`none`?e.shadow:void 0;return(0,Y.jsxs)(`div`,{style:{background:n,color:i,fontFamily:u},className:`p-3 flex flex-col gap-2 overflow-hidden`,children:[(0,Y.jsx)(`div`,{className:`text-[9px] uppercase tracking-wide`,style:{color:a},children:t}),(0,Y.jsxs)(`div`,{style:{background:r,border:`1px solid ${c}`,borderRadius:l,boxShadow:f},className:`p-3 flex flex-col gap-2`,children:[(0,Y.jsx)(`div`,{style:{fontFamily:d},className:`text-base font-bold leading-tight`,children:`Aa Heading`}),(0,Y.jsx)(`div`,{className:`text-[11px] leading-snug`,style:{color:a},children:`The quick brown fox jumps over the lazy dog.`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,Y.jsx)(`span`,{style:{background:o,color:n,borderRadius:l},className:`text-[10px] font-semibold px-2.5 py-1`,children:`Primary`}),(0,Y.jsx)(`span`,{style:{border:`1px solid ${c}`,color:i,borderRadius:l},className:`text-[10px] px-2 py-1`,children:`Ghost`}),(0,Y.jsx)(`span`,{style:{background:s,color:n,borderRadius:`999px`},className:`text-[9px] font-semibold px-2 py-0.5 ml-auto`,children:`Badge`})]}),(0,Y.jsx)(`div`,{style:{border:`1px solid ${c}`,borderRadius:l,color:a},className:`text-[10px] px-2 py-1.5 mt-1`,children:`Input field…`})]})]})}function Sh({kit:e,overrides:t,onSet:n}){let[r,i]=(0,U.useState)(`light`),{t:a}=V(),o=bh(r===`light`?e.light:e.dark,t,r);return(0,Y.jsxs)(`div`,{className:`mt-1 rounded-lg border border-border/60 p-2 bg-muted/30`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-semibold uppercase text-muted-foreground`,children:a(`activity:design.colors`)}),(0,Y.jsx)(`div`,{className:`ml-auto inline-flex rounded border border-border/60 overflow-hidden`,children:[`light`,`dark`].map(e=>(0,Y.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:X(`text-[10px] px-1.5 py-0.5`,r===e?`bg-primary text-primary-foreground`:`text-muted-foreground`),children:e},e))})]}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:yh.filter(e=>o[e]).map(e=>{let t=_h(o[e]??``)??`#000000`;return(0,Y.jsxs)(`label`,{className:`flex flex-col items-center gap-0.5`,title:`${e}: ${o[e]}`,children:[(0,Y.jsx)(`input`,{type:`color`,value:t,onChange:t=>n(`${r}.${e}`,t.target.value),className:`w-6 h-6 rounded cursor-pointer bg-transparent border border-border/60 p-0`}),(0,Y.jsx)(`span`,{className:`text-[8px] text-muted-foreground`,children:e})]},e)})})]})}function Ch({className:e}){let{client:t}=sd(),{t:n}=V(),[r,i]=(0,U.useState)([]),[a,o]=(0,U.useState)(null),[s,c]=(0,U.useState)({}),[l,u]=(0,U.useState)(`web`),[d,f]=(0,U.useState)(``),[p,m]=(0,U.useState)(null);(0,U.useEffect)(()=>{if(!t)return;let e=e=>{let t=e.payload;i(t?.kits??[]),o(t?.activeKit??null),c(t?.overrides??{})},n=e=>{let t=e.payload;t?.ok&&t.kit&&(o(t.kit),c(t.overrides??{}))},r=e=>{let t=e.payload;t?.ok&&t.overrides&&c(t.overrides)},a=e=>{let t=e.payload;m(t?.ok?b.t(`activity:design.wrote`,{path:t.path}):b.t(`activity:design.materializeFailed`,{error:t?.error??`error`}))},s=e=>{let t=e.payload;if(!t?.ok){m(b.t(`activity:design.verifyError`,{error:t?.error??`error`}));return}let n=Math.round((t.score??1)*100);m(t.violationCount?b.t(`activity:design.verifyOffPalette`,{pct:n,count:t.violationCount,files:t.filesScanned}):b.t(`activity:design.verifyClean`,{files:t.filesScanned}))};return t.on(`design.list`,e),t.on(`design.use`,n),t.on(`design.set`,r),t.on(`design.materialize`,a),t.on(`design.verify`,s),t.send({type:`design.list`}),()=>{t.off(`design.list`,e),t.off(`design.use`,n),t.off(`design.set`,r),t.off(`design.materialize`,a),t.off(`design.verify`,s)}},[t]);let h=(0,U.useCallback)(e=>t?.send({type:`design.use`,payload:{kit:e,stack:l}}),[t,l]),g=(0,U.useCallback)((e,n)=>{c(t=>({...t,[e]:n})),t?.send({type:`design.set`,payload:{overrides:{[e]:n}}})},[t]),_=(0,U.useCallback)(()=>{m(b.t(`activity:design.writing`)),t?.send({type:`design.materialize`,payload:{stack:l}})},[t,l]),v=(0,U.useCallback)(()=>{m(b.t(`activity:design.scanning`)),t?.send({type:`design.verify`})},[t]),y=(0,U.useMemo)(()=>{let e=d.trim().toLowerCase();return[...e?r.filter(t=>t.id.includes(e)||t.name.toLowerCase().includes(e)||t.aesthetic.toLowerCase().includes(e)||t.tags.some(t=>t.includes(e))):r].sort((e,t)=>e.name.localeCompare(t.name))},[r,d]);return(0,Y.jsxs)(`div`,{className:X(`flex h-full min-h-0 min-w-0 flex-col`,e),children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 px-4 py-3 border-b border-border/60`,children:[(0,Y.jsx)(Wt,{className:`w-5 h-5 text-muted-foreground`}),(0,Y.jsx)(`h2`,{className:`text-sm font-semibold`,children:n(`activity:design.heading`)}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`activity:design.kitsCount`,{count:y.length})}),(0,Y.jsx)(`input`,{value:d,onChange:e=>f(e.target.value),placeholder:n(`activity:design.searchPlaceholder`),className:`ml-2 text-xs bg-transparent border border-border/60 rounded px-2 py-1 w-44`}),(0,Y.jsx)(`select`,{value:l,onChange:e=>u(e.target.value),className:`text-xs bg-transparent border border-border/60 rounded px-1.5 py-1`,title:n(`activity:design.stackTitle`),children:vh.map(e=>(0,Y.jsx)(`option`,{value:e,children:e},e))}),p&&(0,Y.jsx)(`span`,{className:`text-[11px] text-muted-foreground max-w-48 truncate`,children:p}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>Q(`chat`),className:`ml-auto p-1 rounded hover:bg-muted text-muted-foreground`,title:n(`common:action.close`),children:(0,Y.jsx)(Xn,{className:`w-4 h-4`})})]}),(0,Y.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto p-4`,children:(0,Y.jsx)(`div`,{className:`grid gap-4 [grid-template-columns:repeat(auto-fill,minmax(300px,1fr))]`,children:y.map(e=>{let t=a===e.id,r=t?s:{};return(0,Y.jsxs)(`div`,{className:X(`rounded-xl border overflow-hidden flex flex-col`,t?`border-primary/60 ring-1 ring-primary/40`:`border-border/60`),children:[(0,Y.jsxs)(`div`,{className:`grid grid-cols-2`,children:[(0,Y.jsx)(xh,{t:bh(e.light,r,`light`),label:n(`activity:designStudio.light`)}),(0,Y.jsx)(xh,{t:bh(e.dark,r,`dark`),label:n(`activity:designStudio.dark`)})]}),(0,Y.jsxs)(`div`,{className:`p-3 border-t border-border/60 flex flex-col gap-1.5 bg-card`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold truncate`,children:e.name}),(0,Y.jsx)(`code`,{className:`text-[10px] text-muted-foreground`,children:e.id}),t&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[9px] font-semibold uppercase text-primary ml-auto`,children:[(0,Y.jsx)(z,{className:`w-3 h-3`}),` `,n(`activity:design.active`)]})]}),(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground leading-snug`,children:e.aesthetic}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mt-1`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>h(e.id),className:X(`text-[11px] px-2.5 py-1 rounded font-medium`,t?`bg-primary/10 text-primary`:`bg-primary text-primary-foreground hover:opacity-90`),children:n(t?`activity:design.reapply`:`activity:design.use`)}),t&&(0,Y.jsxs)(`button`,{type:`button`,onClick:_,className:`inline-flex items-center gap-1 text-[11px] px-2 py-1 rounded font-medium border border-border/60 hover:bg-muted`,title:n(`activity:design.materializeTitle`,{stack:l}),children:[(0,Y.jsx)(Yn,{className:`w-3 h-3`}),` `,n(`activity:design.materialize`)]}),t&&(0,Y.jsxs)(`button`,{type:`button`,onClick:v,className:`inline-flex items-center gap-1 text-[11px] px-2 py-1 rounded font-medium border border-border/60 hover:bg-muted`,title:n(`activity:design.verifyTitle`),children:[(0,Y.jsx)(at,{className:`w-3 h-3`}),` `,n(`activity:design.verify`)]}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground truncate`,children:e.bestFor})]}),t&&(0,Y.jsx)(Sh,{kit:e,overrides:r,onSet:g})]})]},e.id)})})})]})}var wh=class extends U.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[ErrorBoundary]`,e,t.componentStack),this.props.onError?.(e,t)}handleReset=()=>{this.setState({error:null})};render(){return this.state.error?(0,Y.jsx)(`div`,{className:`flex min-h-[100dvh] items-center justify-center bg-background`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-4 p-8 max-w-md text-center`,children:[(0,Y.jsx)(gt,{className:`h-12 w-12 text-destructive`}),(0,Y.jsx)(`h1`,{className:`text-lg font-semibold`,children:b.t(`common:error.title`)}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:b.t(`common:error.body`)}),(0,Y.jsx)(`pre`,{className:`text-xs font-mono text-muted-foreground bg-muted/50 rounded p-3 max-h-32 overflow-auto w-full text-left`,children:this.state.error.message}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsxs)($,{size:`sm`,variant:`outline`,onClick:()=>window.location.reload(),children:[(0,Y.jsx)(Rn,{className:`h-4 w-4 mr-1`}),b.t(`common:error.reload`)]}),(0,Y.jsx)($,{size:`sm`,onClick:this.handleReset,children:b.t(`common:error.tryAgain`)})]})]})}):this.props.children}},Th=U.forwardRef(({className:e,children:t,...n},r)=>(0,Y.jsxs)(qe,{ref:r,className:X(`relative overflow-hidden`,e),...n,children:[(0,Y.jsx)(Te,{className:`h-full w-full rounded-[inherit]`,children:t}),(0,Y.jsx)(Eh,{}),(0,Y.jsx)(Er,{})]}));Th.displayName=qe.displayName;var Eh=U.forwardRef(({className:e,orientation:t=`vertical`,...n},r)=>(0,Y.jsx)(w,{ref:r,orientation:t,className:X(`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,Y.jsx)(y,{className:`relative flex-1 rounded-full bg-border`})}));Eh.displayName=w.displayName;var Dh=He,Oh=U.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(Ar,{ref:n,className:X(`inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground`,e),...t}));Oh.displayName=Ar.displayName;var kh=U.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(m,{ref:n,className:X(`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-background data-[state=active]:text-foreground data-[state=active]:shadow-sm`,e),...t}));kh.displayName=m.displayName;var Ah=U.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(Mt,{ref:n,className:X(`mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,e),...t}));Ah.displayName=Mt.displayName;function jh({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-[hsl(var(--warning))]`:`text-[hsl(var(--success))]`;return(0,Y.jsxs)(`span`,{className:n,title:`Fleet concurrency: ${e}/${t}`,children:[(0,Y.jsxs)(`span`,{"aria-hidden":`true`,className:`font-mono text-[10px] tracking-tight`,children:[`[`,(0,Y.jsx)(`span`,{className:s,children:`█`.repeat(i)}),(0,Y.jsx)(`span`,{className:`text-[hsl(var(--muted))]`,children:`░`.repeat(a)}),`]`]}),r&&(0,Y.jsxs)(`span`,{className:`ml-1.5 tabular-nums text-[10px] text-muted-foreground font-mono`,children:[e,`/`,t]})]})}function Mh(e){let t=Date.now()-e;return t<5e3?b.t(`common:time.justNow`):t<6e4?b.t(`common:time.compactSecondsAgo`,{count:Math.floor(t/1e3)}):t<36e5?b.t(`common:time.compactMinutesAgo`,{count:Math.floor(t/6e4)}):b.t(`common:time.compactHoursAgo`,{count:Math.floor(t/36e5)})}var Nh={spawned:`🚀`,task_started:`▶`,tool_executed:`⚡`,iteration_summary:`🔄`,budget_warning:`!`,budget_extended:`⚡`,task_completed:`✅`,ctx_pct:`💬`,leader_updated:`👑`};function Ph({events:e,max:t=20,className:n}){let{t:r}=V(),i=e.slice(0,t);return i.length===0?(0,Y.jsx)(`div`,{className:`py-4 text-center text-xs text-muted-foreground ${n??``}`,children:r(`activity:timeline.noEvents`)}):(0,Y.jsx)(`div`,{className:`space-y-0.5 overflow-y-auto max-h-48 ${n??``}`,children:i.map(e=>(0,Y.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,Y.jsx)(`span`,{className:`shrink-0 w-5 text-center`,"aria-hidden":`true`,children:Nh[e.kind]??`·`}),(0,Y.jsx)(`span`,{className:`shrink-0 w-12 text-right text-muted-foreground font-mono tabular-nums`,children:Mh(e.timestamp)}),(0,Y.jsx)(`span`,{className:`truncate text-foreground/90`,children:e.message}),e.value!==void 0&&e.kind===`tool_executed`&&(0,Y.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,Y.jsxs)(`span`,{className:`ml-auto shrink-0 tabular-nums text-muted-foreground font-mono`,children:[e.value,`%`]})]},e.id))})}function Fh(e){return e===`running`}function Ih(e,t){let n=+!Fh(e.status),r=+!Fh(t.status);return n===r?e.startedAt-t.startedAt:n-r}function Lh(e){let t=0,n=0,r=0;for(let i of e)i.status===`running`?t++:i.status===`completed`?n++:(i.status===`failed`||i.status===`timeout`)&&r++;return{running:t,completed:n,failed:r,total:e.length}}function Rh(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 zh(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 Bh(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 Vh={running:{led:`bg-emerald-500`,labelKey:`statusRunning`,pulse:!0,color:`text-emerald-500`},completed:{led:`bg-emerald-500`,labelKey:`statusDone`,pulse:!1,color:`text-emerald-500`},failed:{led:`bg-destructive`,labelKey:`statusFailed`,pulse:!1,color:`text-destructive`},timeout:{led:`bg-amber-500`,labelKey:`statusTimeout`,pulse:!1,color:`text-amber-500`},stopped:{led:`bg-muted-foreground`,labelKey:`statusStopped`,pulse:!1,color:`text-muted-foreground`}};function Hh({agent:e,now:t}){let{t:n}=V(),[r,i]=(0,U.useState)(!1),[a,o]=(0,U.useState)(!1),s=Xs(t=>t.agentTranscripts.get(e.id)??Bs),c=Vh[e.status],l=e.status===`running`,u=Math.min(100,Math.max(0,e.ctxPct)),d=(0,U.useCallback)(async e=>{try{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),2e3)}catch{}},[]),f=e.toolLog.reduce((e,t)=>e+t.durationMs,0),p=e.toolLog.length>0?Math.round(f/e.toolLog.length):0,m=(0,U.useMemo)(()=>{let t=new Set;for(let n of e.toolLog)t.add(n.name);return t.size},[e.toolLog]),h=e.partialText||e.finalText||void 0,g=!e.finalText&&!!e.partialText;return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Y.jsxs)(`div`,{className:`shrink-0 border-b bg-card p-4 space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(`div`,{className:`flex items-center justify-center w-10 h-10 rounded-lg bg-primary/10`,children:(0,Y.jsx)(j,{className:`h-5 w-5 text-primary`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-base font-semibold`,children:e.name}),(0,Y.jsx)(`span`,{className:X(`px-2 py-0.5 rounded text-[10px] font-medium uppercase tracking-wider`,e.status===`running`?`bg-emerald-500/15 text-emerald-600 dark:text-emerald-400`:e.status===`failed`||e.status===`timeout`?`bg-destructive/15 text-destructive`:`bg-muted text-muted-foreground`),children:n(`activity:fleet.${c.labelKey}`)})]}),(0,Y.jsxs)(`span`,{className:`text-[10px] text-muted-foreground font-mono`,children:[n(`activity:fleet.sessionPrefix`),` `,e.sessionId?.slice(0,12),`…`]})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-muted-foreground`,children:[l&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(ke,{className:`h-3.5 w-3.5`}),(0,Y.jsx)(`span`,{className:`tabular-nums font-mono`,children:Bh(Math.max(0,t-e.startedAt))})]}),(0,Y.jsx)(`span`,{className:X(`led`,c.led,l&&`led-pulse`)})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2 rounded-lg bg-muted/30`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider`,children:n(`activity:fleet.activity`)}),(0,Y.jsx)(ef,{bins:e.sparklineBins,className:`font-mono text-[9px]`}),e.budgetWarning&&(0,Y.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-[10px] text-amber-500`,children:[(0,Y.jsx)(tn,{className:`h-3 w-3`}),n(`activity:fleet.budgetWarning`)]})]}),e.description&&(0,Y.jsxs)(`div`,{className:`px-3 py-2 rounded-lg bg-muted/20 border border-border/50`,children:[(0,Y.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:n(`activity:fleet.currentTask`)}),(0,Y.jsx)(`p`,{className:`text-xs mt-1 text-foreground/80`,children:e.description})]})]}),(0,Y.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto p-4 space-y-4`,children:[(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,Y.jsxs)(`div`,{className:`rounded-lg border bg-card p-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-[9px] text-muted-foreground uppercase tracking-wider mb-2`,children:[(0,Y.jsx)(wr,{className:`h-3 w-3`}),` `,n(`activity:fleet.providerModel`)]}),(0,Y.jsxs)(`div`,{className:`text-sm font-mono font-medium`,children:[e.provider??`?`,`/`,e.model??`?`]})]}),(0,Y.jsxs)(`div`,{className:`rounded-lg border bg-card p-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-[9px] text-muted-foreground uppercase tracking-wider mb-2`,children:[(0,Y.jsx)($n,{className:`h-3 w-3`}),` `,n(`activity:fleet.performance`)]}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex justify-between text-[11px]`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:fleet.iterations`)}),(0,Y.jsx)(`span`,{className:`font-mono font-medium`,children:e.iteration})]}),(0,Y.jsxs)(`div`,{className:`flex justify-between text-[11px]`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:fleet.toolCalls`)}),(0,Y.jsx)(`span`,{className:`font-mono font-medium`,children:e.toolCalls})]}),(0,Y.jsxs)(`div`,{className:`flex justify-between text-[11px]`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:fleet.uniqueTools`)}),(0,Y.jsx)(`span`,{className:`font-mono font-medium`,children:m})]})]})]}),(0,Y.jsxs)(`div`,{className:`rounded-lg border bg-card p-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-[9px] text-muted-foreground uppercase tracking-wider mb-2`,children:[(0,Y.jsx)(Fn,{className:`h-3 w-3`}),` `,n(`activity:fleet.cost`)]}),(0,Y.jsx)(`div`,{className:`text-lg font-mono font-bold text-emerald-500`,children:Rh(e.costUsd)}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground mt-1`,children:n(`activity:fleet.avgPerTool`,{ms:p})})]}),(0,Y.jsxs)(`div`,{className:`rounded-lg border bg-card p-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-[9px] text-muted-foreground uppercase tracking-wider mb-2`,children:[(0,Y.jsx)(dn,{className:`h-3 w-3`}),` `,n(`activity:fleet.context`)]}),(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex justify-between text-[11px]`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:fleet.tokens`)}),(0,Y.jsx)(`span`,{className:`font-mono font-medium`,children:zh(e.ctxTokens)})]}),(0,Y.jsx)(`div`,{className:`h-2 w-full rounded-full bg-muted overflow-hidden`,children:(0,Y.jsx)(`div`,{className:X(`h-full rounded-full transition-all`,u>=85?`bg-destructive`:u>=70?`bg-amber-500`:`bg-emerald-500`),style:{width:`${u}%`}})}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums font-mono`,children:n(`activity:fleet.ctxUsed`,{pct:u})})]})]})]}),(0,Y.jsx)(Xd,{entries:s,agentName:e.name,maxHeightClassName:`max-h-[28rem]`}),e.currentTool&&(0,Y.jsxs)(`div`,{className:X(`rounded-lg border px-4 py-3 flex items-center gap-3`,l?`border-primary/30 bg-primary/[0.04]`:`border-border bg-muted/30`),children:[(0,Y.jsx)(In,{className:X(`h-4 w-4`,l?`text-primary animate-pulse`:`text-muted-foreground`)}),(0,Y.jsx)(`span`,{className:`text-sm font-mono font-medium`,children:e.currentTool}),l?(0,Y.jsxs)(`span`,{className:`ml-auto flex items-center gap-1.5 text-[10px] text-primary`,children:[(0,Y.jsx)(B,{className:`h-3 w-3 animate-spin`}),` `,n(`activity:fleet.running`)]}):(0,Y.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:n(`activity:fleet.completed`)})]}),h?(0,Y.jsxs)(`div`,{className:`rounded-lg border bg-card`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b bg-muted/30`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider flex items-center gap-2`,children:g?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-blue-500 animate-pulse`}),n(`activity:fleet.liveOutput`)]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Fe,{className:`h-3 w-3`}),n(`activity:fleet.finalOutput`)]})}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>d(h),className:`flex items-center gap-1 px-2 py-1 rounded text-[10px] text-muted-foreground hover:text-foreground hover:bg-muted transition-colors`,children:r?`✓ ${n(`common:action.copied`)}`:n(`common:action.copy`)})]}),(0,Y.jsx)(`pre`,{className:`p-4 text-xs whitespace-pre-wrap font-mono text-foreground/80 leading-relaxed max-h-64 overflow-y-auto`,children:h})]}):l?(0,Y.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border p-6 text-center`,children:[(0,Y.jsx)(B,{className:`h-6 w-6 mx-auto mb-2 text-muted-foreground/50 animate-spin`}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`activity:fleet.waitingOutput`)})]}):null,e.budgetWarning&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3 rounded-lg bg-amber-500/10 border border-amber-500/20`,children:[(0,Y.jsx)(tn,{className:`h-5 w-5 text-amber-500 shrink-0`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-sm font-medium text-amber-600 dark:text-amber-400`,children:n(`activity:fleet.budgetWarningTitle`)}),(0,Y.jsx)(`p`,{className:`text-[11px] text-amber-600/80 dark:text-amber-400/80 mt-0.5`,children:n(`activity:fleet.hittingLimit`,{kind:e.budgetWarning.kind,used:e.budgetWarning.used,limit:e.budgetWarning.limit})})]})]}),e.extensions>0&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3 rounded-lg bg-amber-500/10 border border-amber-500/20`,children:[(0,Y.jsx)(tn,{className:`h-5 w-5 text-amber-500 shrink-0`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-sm font-medium`,children:n(`activity:fleet.budgetExt`,{count:e.extensions})}),(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground mt-0.5`,children:n(`activity:fleet.extendedTimes`,{count:e.extensions})})]})]}),e.error&&(0,Y.jsxs)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 p-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,Y.jsx)(Nn,{className:`h-4 w-4 text-destructive`}),(0,Y.jsx)(`span`,{className:`text-[10px] font-semibold text-destructive uppercase tracking-wider`,children:n(`activity:fleet.errorLabel`)})]}),(0,Y.jsx)(`p`,{className:`text-sm text-destructive/90`,children:e.error.message})]}),e.failureReason&&(0,Y.jsxs)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 p-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,Y.jsx)(Nn,{className:`h-4 w-4 text-destructive`}),(0,Y.jsx)(`span`,{className:`text-[10px] font-semibold text-destructive uppercase tracking-wider`,children:n(`activity:fleet.failureReason`)})]}),(0,Y.jsx)(`p`,{className:`text-sm text-destructive/90`,children:e.failureReason})]}),e.toolLog.length>0&&(0,Y.jsxs)(`div`,{className:`rounded-lg border bg-card`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>o(!a),className:`w-full flex items-center justify-between px-4 py-2 border-b bg-muted/30 hover:bg-muted/50 transition-colors`,children:[(0,Y.jsxs)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider flex items-center gap-2`,children:[(0,Y.jsx)(In,{className:`h-3 w-3`}),n(`activity:fleet.toolLog`,{count:e.toolLog.length})]}),(0,Y.jsx)(Oe,{className:X(`h-4 w-4 text-muted-foreground transition-transform`,a&&`rotate-90`)})]}),(0,Y.jsx)(`div`,{className:X(`overflow-hidden transition-all`,a?`max-h-[500px]`:`max-h-48`),children:(0,Y.jsx)(`div`,{className:`p-2 space-y-0.5`,children:e.toolLog.map((e,t)=>(0,Y.jsxs)(`div`,{className:X(`flex items-center gap-3 rounded px-3 py-2 text-[11px]`,e.ok?`bg-muted/30 hover:bg-muted/50`:`bg-destructive/5 border border-destructive/20`),children:[(0,Y.jsx)(`span`,{className:X(`led shrink-0`,e.ok?`bg-emerald-500`:`bg-destructive`)}),(0,Y.jsx)(`span`,{className:X(`font-mono font-medium w-20 shrink-0`,e.ok?`text-foreground`:`text-destructive`),children:e.name}),(0,Y.jsx)(`span`,{className:`text-muted-foreground tabular-nums text-[10px]`,children:e.durationMs>=1e3?`${(e.durationMs/1e3).toFixed(2)}s`:`${e.durationMs}ms`}),!e.ok&&(0,Y.jsx)(`span`,{className:`ml-auto text-[10px] text-destructive font-medium`,children:n(`activity:fleet.failed`)}),(0,Y.jsx)(`span`,{className:`ml-auto text-[9px] text-muted-foreground tabular-nums`,children:new Date(e.at).toLocaleTimeString()})]},`${e.name}-${e.at}-${t}`))})})]})]})]})}function Uh({agent:e,isSelected:t,isLeader:n,onClick:r}){let{t:i}=V(),a=Vh[e.status],o=e.status===`running`,s=Math.min(100,Math.max(0,e.ctxPct));return(0,Y.jsxs)(`button`,{type:`button`,onClick:r,className:X(`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,Y.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0`,children:[(0,Y.jsx)(`span`,{className:X(`led shrink-0`,a.led,a.pulse&&`led-pulse`)}),(0,Y.jsx)(`span`,{className:`truncate font-medium`,children:e.name}),n&&(0,Y.jsx)(on,{className:`h-3 w-3 shrink-0 text-amber-500`,"aria-label":i(`activity:fleet.leader`)})]}),(0,Y.jsx)(`span`,{className:X(`text-[10px] tabular-nums`,o?`text-emerald-500`:`text-muted-foreground`),children:i(`activity:fleet.${a.labelKey}`)}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0`,children:[(0,Y.jsx)(ef,{bins:e.sparklineBins,className:`font-mono text-[9px]`}),e.budgetWarning&&(0,Y.jsx)(`span`,{title:i(`activity:fleet.hittingLimitTitle`,{kind:e.budgetWarning.kind,used:e.budgetWarning.used,limit:e.budgetWarning.limit}),children:(0,Y.jsx)(tn,{className:`h-3 w-3 shrink-0 text-amber-500`,"aria-label":i(`common:status.budgetWarning`)})})]}),(0,Y.jsxs)(`span`,{className:`tabular-nums text-muted-foreground text-[10px]`,children:[e.iteration,`it`]}),(0,Y.jsxs)(`span`,{className:`tabular-nums text-muted-foreground text-[10px]`,children:[e.toolCalls,`tc`]}),(0,Y.jsx)(`span`,{className:`tabular-nums font-mono text-[10px]`,children:Rh(e.costUsd)}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`h-1.5 w-full rounded-full bg-muted overflow-hidden`,children:(0,Y.jsx)(`div`,{className:X(`h-full rounded-full transition-all`,s>=85?`bg-destructive`:s>=70?`bg-amber-500`:`bg-emerald-500`),style:{width:`${s}%`}})}),(0,Y.jsx)(`span`,{className:`text-[9px] tabular-nums text-muted-foreground font-mono leading-none`,children:e.maxContext>0?`${s}%`:`—`})]}),(0,Y.jsx)(`span`,{className:`tabular-nums text-[10px] text-muted-foreground`,children:e.extensions>0?`⚡×${e.extensions}`:`—`}),(0,Y.jsx)(`span`,{className:`text-[9px] text-destructive truncate`,title:e.failureReason,children:e.failureReason??``})]})}function Wh({onClose:e,onSelectAgent:t}){let{t:n}=V(),r=Xs(e=>e.agents),i=Xs(e=>e.leaderId),a=Xs(e=>e.fleetTokensIn),o=Xs(e=>e.fleetTokensOut),s=Xs(e=>e.fleetConcurrency),c=Xs(e=>e.fleetConcurrencyMax),l=Xs(e=>e.eventTimeline),u=Xs(e=>e.agentTimeline),[d,f]=(0,U.useState)(null),[p,m]=(0,U.useState)(Date.now());(0,U.useEffect)(()=>{let e=setInterval(()=>m(Date.now()),1e3);return()=>clearInterval(e)},[]);let h=(0,U.useMemo)(()=>{let e=Array.from(r.values());return e.sort((e,t)=>e.id===i?-1:t.id===i?1:Ih(e,t)),e},[r,i]),g=(0,U.useMemo)(()=>Array.from(r.values()).reduce((e,t)=>e+t.costUsd,0),[r]),_=Lh(h).running,v=d===null?null:h[d],y=(0,U.useCallback)(e=>f(t=>t===e?null:e),[]),b=(0,U.useCallback)(n=>{if(n.key===`Escape`){d===null?e&&e():f(null);return}if(n.key===`ArrowDown`){n.preventDefault(),f(e=>Math.min((e??-1)+1,h.length-1));return}if(n.key===`ArrowUp`){n.preventDefault(),f(e=>Math.max((e??0)-1,0));return}n.key===`Enter`&&h[d??0]&&t?.(h[d??0])},[h,d,e,t]);return(0,U.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/10 backdrop-blur-[1px]`,onClick:e,"aria-hidden":`true`}),(0,Y.jsxs)(`div`,{className:`fixed right-0 top-0 z-50 flex h-full min-h-0 w-[720px] max-w-[95vw] flex-col border-l bg-background shadow-2xl animate-slide-in-right`,onKeyDown:b,tabIndex:-1,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b bg-card/80 backdrop-blur shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(j,{className:`h-5 w-5 text-primary`}),(0,Y.jsxs)(`h2`,{className:`text-sm font-semibold flex items-center gap-2`,children:[n(`activity:fleet.fleetMonitor`),_>0&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] text-emerald-500 font-normal`,children:[(0,Y.jsx)(`span`,{className:`led led-pulse bg-emerald-500`}),n(`activity:fleet.runningCount`,{count:_})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(`span`,{children:n(`activity:fleet.totalAgents`,{count:h.length})}),(0,Y.jsx)(jh,{current:s,max:c,showLabel:!0})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums font-mono`,children:[`↓`,zh(a),` ↑`,zh(o),` · `,Rh(g)]}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums font-mono`,children:i?`👑 ${r.get(i)?.name??i}`:n(`activity:fleet.noLeader`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:e,className:`p-1.5 rounded-md hover:bg-muted transition-colors`,"aria-label":n(`activity:fleet.closeFleet`),children:(0,Y.jsx)(Nn,{className:`h-4 w-4`})})]})]}),(0,Y.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 overflow-x-auto overflow-y-hidden`,children:[(0,Y.jsxs)(`div`,{className:X(`flex min-h-0 min-w-0 flex-col border-r transition-all duration-200`,v?`w-[500px] max-w-full shrink-0`:`w-full`),children:[(0,Y.jsx)(`div`,{className:`border-b bg-card/80 px-3 py-2 overflow-x-auto`,children:(0,Y.jsxs)(`div`,{className:`grid min-w-[650px] grid-cols-[140px_60px_1fr_60px_60px_60px_60px_50px_50px] gap-x-2 text-[9px] uppercase tracking-wider text-muted-foreground font-medium`,children:[(0,Y.jsx)(`span`,{children:n(`activity:fleet.colName`)}),(0,Y.jsx)(`span`,{children:n(`activity:fleet.colStatus`)}),(0,Y.jsx)(`span`,{children:n(`activity:fleet.colActivity`)}),(0,Y.jsx)(`span`,{children:n(`activity:fleet.colIters`)}),(0,Y.jsx)(`span`,{children:n(`activity:fleet.colTools`)}),(0,Y.jsx)(`span`,{children:n(`activity:fleet.colCost`)}),(0,Y.jsx)(`span`,{children:n(`activity:fleet.colCtx`)}),(0,Y.jsx)(`span`,{children:n(`activity:fleet.colExt`)}),(0,Y.jsx)(`span`,{children:n(`activity:fleet.colReason`)})]})}),(0,Y.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-auto`,children:h.length===0?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-muted-foreground`,children:[(0,Y.jsx)(Rr,{className:`h-12 w-12 mb-3 opacity-20`}),(0,Y.jsx)(`p`,{className:`text-sm font-medium`,children:n(`activity:fleet.noAgentsActive`)}),(0,Y.jsx)(`p`,{className:`text-xs mt-1`,children:n(`activity:fleet.agentsAppear`)})]}):(0,Y.jsx)(`div`,{className:`p-2 space-y-0.5`,children:h.map((e,t)=>(0,Y.jsx)(Uh,{agent:e,isSelected:t===d,isLeader:e.id===i,onClick:()=>y(t)},e.id))})}),(0,Y.jsxs)(`div`,{className:`border-t bg-card/80 shrink-0`,children:[(0,Y.jsx)(`div`,{className:`px-4 py-2 border-b`,children:(0,Y.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground font-medium flex items-center gap-2`,children:[(0,Y.jsx)(Ge,{className:`h-3 w-3`}),n(`activity:fleet.agentTimeline`)]})}),(0,Y.jsx)(`div`,{className:`px-4 py-2 max-h-32 overflow-y-auto`,children:(0,Y.jsx)(Ph,{events:l,max:10})}),(0,Y.jsx)(`div`,{className:`border-t border-dashed`}),(0,Y.jsx)(`div`,{className:`px-4 py-2 max-h-40 overflow-y-auto`,children:u.length===0?(0,Y.jsx)(`p`,{className:`text-[10px] text-muted-foreground italic`,children:n(`activity:fleet.noAgentEvents`)}):(0,Y.jsx)(`div`,{className:`space-y-1`,children:u.slice(0,15).map(e=>{let t={text:`💬`,thinking:`🧠`,tool_use:`🔧`,tool_result:`✅`,error:`❌`,status:`💬`,system:`●`}[e.kind]??`●`,n=e.status===`running`||e.status===`spawned`?`text-emerald-500`:e.status===`failed`||e.status===`timeout`?`text-destructive`:`text-muted-foreground`;return(0,Y.jsxs)(`div`,{className:`flex items-start gap-1.5 text-[10px] leading-tight`,children:[(0,Y.jsx)(`span`,{className:`shrink-0`,children:t}),(0,Y.jsx)(`span`,{className:`font-medium text-primary shrink-0`,children:e.agentName}),e.status&&(0,Y.jsx)(`span`,{className:`${n} shrink-0`,children:e.status}),e.toolName&&(0,Y.jsxs)(`span`,{className:`text-muted-foreground shrink-0`,children:[`[`,e.toolName,`]`]}),(0,Y.jsx)(`span`,{className:`min-w-0 text-muted-foreground line-clamp-2 whitespace-pre-wrap break-words`,children:e.content})]},e.id)})})}),(0,Y.jsxs)(`div`,{className:`px-4 py-1.5 border-t text-[10px] text-muted-foreground flex items-center gap-4`,children:[(0,Y.jsx)(`span`,{children:n(`activity:fleet.navHint`)}),(0,Y.jsx)(`span`,{children:n(`activity:fleet.selectDetailHint`)}),(0,Y.jsx)(`span`,{children:n(`activity:fleet.escHint`)})]})]})]}),v&&(0,Y.jsx)(`div`,{className:`min-h-0 min-w-[360px] flex-1 overflow-hidden bg-card/50`,children:(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Y.jsxs)(`div`,{className:`shrink-0 px-4 py-2 border-b bg-card/80 flex items-center gap-2`,children:[(0,Y.jsx)(it,{className:`h-4 w-4 text-primary`}),(0,Y.jsx)(`span`,{className:`text-xs font-semibold text-primary`,children:v.name}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(`activity:fleet.detailedView`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>f(null),className:`ml-auto text-[10px] text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1`,children:n(`activity:fleet.closeBtn`)})]}),(0,Y.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,Y.jsx)(Hh,{agent:v,now:p})})]})}),!v&&h.length>0&&(0,Y.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 items-center justify-center bg-muted/20`,children:(0,Y.jsxs)(`div`,{className:`text-center space-y-3 max-w-sm`,children:[(0,Y.jsx)(Rr,{className:`h-12 w-12 text-muted-foreground/30 mx-auto`}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`activity:fleet.selectAgentDetail`)}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:n(`activity:fleet.selectAgentBody`)}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-center gap-4 pt-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground`,children:[(0,Y.jsx)(`kbd`,{className:`px-1.5 py-0.5 rounded bg-muted border text-[9px]`,children:`↑`}),(0,Y.jsx)(`kbd`,{className:`px-1.5 py-0.5 rounded bg-muted border text-[9px]`,children:`↓`}),(0,Y.jsx)(`span`,{children:n(`activity:fleet.navigateWord`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground`,children:[(0,Y.jsx)(`kbd`,{className:`px-1.5 py-0.5 rounded bg-muted border text-[9px]`,children:`Enter`}),(0,Y.jsx)(`span`,{children:n(`activity:fleet.selectWord`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground`,children:[(0,Y.jsx)(`kbd`,{className:`px-1.5 py-0.5 rounded bg-muted border text-[9px]`,children:`Esc`}),(0,Y.jsx)(`span`,{children:n(`activity:fleet.deselectWord`)})]})]})]})})]})]})]})}var Gh={shell:En,package:$t,network:$e,"fs.write":$n,config:$n},Kh={shell:`text-orange-400`,package:`text-blue-400`,network:`text-green-400`,"fs.write":`text-purple-400`,config:`text-yellow-400`},qh=[`all`,`shell`,`package`,`network`,`fs.write`,`config`];function Jh(e){try{return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}catch{return e.slice(11,19)}}function Yh(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 Xh(e){return/[",\n]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e}function Zh(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[Xh(e.ts),Xh(e.toolName),Xh(e.risk),Xh(String(t)),Xh(e.outcome??``)].join(`,`)})].join(`
149
- `),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 Qh(){let e=Cs(e=>e.sideEffects),t=Cs(e=>e.loading),{t:n}=V(),[r,i]=(0,U.useState)(`all`),[a,o]=(0,U.useState)(`time`),[s,c]=(0,U.useState)(`desc`);(0,U.useEffect)(()=>{Cs.getState().setLoading(!0),H(async()=>{let{getWSClient:e}=await Promise.resolve().then(()=>is);return{getWSClient:e}},void 0).then(({getWSClient:e})=>{e().send({type:`side_effects.list`})})},[]);let l=()=>{Cs.getState().setLoading(!0),H(async()=>{let{getWSClient:e}=await Promise.resolve().then(()=>is);return{getWSClient:e}},void 0).then(({getWSClient:e})=>{e().send({type:`side_effects.list`})})},u=e=>{a===e?c(s===`asc`?`desc`:`asc`):(o(e),c(e===`time`?`desc`:`asc`))},d=(0,U.useMemo)(()=>{let t=r===`all`?[...e]:e.filter(e=>e.risk===r);return t.sort((e,t)=>{let n=0;return a===`time`?n=e.ts.localeCompare(t.ts):a===`tool`?n=e.toolName.localeCompare(t.toolName):a===`risk`&&(n=e.risk.localeCompare(t.risk)),s===`asc`?n:-n}),t},[e,r,a,s]);if(e.length===0&&!t)return(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 py-8 text-zinc-500`,children:[(0,Y.jsx)($n,{className:`h-8 w-8 opacity-40`}),(0,Y.jsx)(`p`,{className:`text-sm`,children:n(`activity:sideEffects.empty`)}),(0,Y.jsx)(`p`,{className:`text-xs text-zinc-600`,children:n(`activity:sideEffects.emptyHint`)})]});let f=({column:e})=>a===e?s===`asc`?(0,Y.jsx)(Tn,{className:`inline h-3 w-3`}):(0,Y.jsx)(bn,{className:`inline h-3 w-3`}):(0,Y.jsx)(`span`,{className:`opacity-30`,children:`↕`});return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between border-b border-zinc-800 px-3 py-2`,children:[(0,Y.jsxs)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-zinc-400`,children:[n(`activity:sideEffects.heading`),` (`,d.length,r===`all`?``:`/${e.length}`,`)`]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsxs)(`button`,{onClick:()=>Zh(d),disabled:d.length===0,className:`flex items-center gap-1 rounded px-2 py-1 text-xs text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300 disabled:opacity-30 disabled:cursor-not-allowed`,title:n(`activity:sideEffects.exportTitle`),children:[(0,Y.jsx)(Yn,{className:`h-3 w-3`}),`CSV`]}),(0,Y.jsxs)(`button`,{onClick:l,className:`flex items-center gap-1 rounded px-2 py-1 text-xs text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300`,children:[(0,Y.jsx)(Rn,{className:X(`h-3 w-3`,t&&`animate-spin`)}),n(`common:action.refresh`)]})]})]}),(0,Y.jsx)(`div`,{className:`flex items-center gap-1 border-b border-zinc-800/50 px-2 py-1`,children:qh.map(e=>(0,Y.jsx)(`button`,{onClick:()=>i(e),className:X(`rounded px-2 py-0.5 text-[10px] font-medium uppercase transition-colors`,r===e?`bg-zinc-700 text-zinc-200`:`text-zinc-500 hover:bg-zinc-800 hover:text-zinc-400`),children:e===`all`?n(`activity:sideEffects.all`):e},e))}),(0,Y.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto`,children:(0,Y.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,Y.jsx)(`thead`,{className:`sticky top-0 bg-zinc-900 text-zinc-500`,children:(0,Y.jsxs)(`tr`,{children:[(0,Y.jsxs)(`th`,{className:`cursor-pointer select-none px-2 py-1 text-left font-medium hover:text-zinc-300`,onClick:()=>u(`time`),children:[n(`activity:sideEffects.colTime`),` `,(0,Y.jsx)(f,{column:`time`})]}),(0,Y.jsxs)(`th`,{className:`cursor-pointer select-none px-2 py-1 text-left font-medium hover:text-zinc-300`,onClick:()=>u(`tool`),children:[n(`activity:sideEffects.colTool`),` `,(0,Y.jsx)(f,{column:`tool`})]}),(0,Y.jsxs)(`th`,{className:`cursor-pointer select-none px-2 py-1 text-left font-medium hover:text-zinc-300`,onClick:()=>u(`risk`),children:[n(`activity:sideEffects.colRisk`),` `,(0,Y.jsx)(f,{column:`risk`})]}),(0,Y.jsx)(`th`,{className:`px-2 py-1 text-left font-medium`,children:n(`activity:sideEffects.colDetail`)}),(0,Y.jsx)(`th`,{className:`px-2 py-1 text-left font-medium`,children:n(`activity:sideEffects.colOutcome`)})]})}),(0,Y.jsx)(`tbody`,{children:d.map((e,t)=>{let n=Gh[e.risk]??$n,r=Kh[e.risk]??`text-zinc-400`;return(0,Y.jsxs)(`tr`,{className:`border-b border-zinc-900 hover:bg-zinc-800/50`,children:[(0,Y.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1.5 text-zinc-500`,children:Jh(e.ts)}),(0,Y.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1.5 font-medium text-zinc-300`,children:e.toolName}),(0,Y.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1.5`,children:(0,Y.jsxs)(`span`,{className:X(`flex items-center gap-1`,r),children:[(0,Y.jsx)(n,{className:`h-3 w-3`}),e.risk]})}),(0,Y.jsx)(`td`,{className:`max-w-xs truncate px-2 py-1.5 font-mono text-zinc-400`,children:Yh(e)}),(0,Y.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1.5 text-zinc-500`,children:e.outcome??``})]},`${e.toolUseId}-${t}`)})})]})})]})}var $h=320;function eg(e){return e<=0?`$0`:e>=.01?`$${e.toFixed(3)}`:`$${e.toFixed(5)}`.replace(/0+$/,``).replace(/\.$/,``)}function tg(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function ng(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 rg(){let e=J(e=>e.inspectorOpen),t=J(e=>e.inspectorTab),n=J(e=>e.toggleInspector),r=J(e=>e.setInspectorOpen),i=J(e=>e.setInspectorTab),{t:a}=V(),o=Xs(e=>e.agents),s=Xs(e=>e.leaderId),c=Xs(e=>e.fleetTokensIn),l=Xs(e=>e.fleetTokensOut),u=Xs(e=>e.fleetConcurrency),d=Xs(e=>e.fleetConcurrencyMax),f=Xs(e=>e.eventTimeline),p=(0,U.useMemo)(()=>ng(o,s),[o,s]),m=p.filter(e=>e.status===`running`).length,h=p.reduce((e,t)=>e+t.costUsd,0),g=p.length,[_,v]=(0,U.useState)(null),y=(0,U.useMemo)(()=>_?o.get(_)??p[0]??null:p[0]??null,[_,p,o]),b=()=>i(`fleet`),x=()=>i(`agents`),S=()=>i(`sideEffects`),C=Cs(e=>e.sideEffects.length);return(0,Y.jsxs)(`div`,{className:`shrink-0 border-t bg-card flex flex-col`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:n,className:X(`group w-full flex items-center justify-between gap-2 px-3 h-7 text-[11px]`,`text-muted-foreground hover:text-foreground hover:bg-accent/40 transition-colors`),title:a(e?`activity:inspector.hidePanel`:`activity:inspector.showPanel`),children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-2 min-w-0`,children:[e?(0,Y.jsx)(bn,{className:`h-3.5 w-3.5 shrink-0`}):(0,Y.jsx)(Tn,{className:`h-3.5 w-3.5 shrink-0`}),(0,Y.jsx)(`span`,{className:`font-medium uppercase tracking-wider`,children:a(`activity:inspector.label`)}),g>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`opacity-40`,children:`·`}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(`span`,{className:X(`h-1.5 w-1.5 rounded-full`,m>0?`bg-emerald-500 animate-pulse`:`bg-muted-foreground/50`)}),(0,Y.jsxs)(`span`,{className:`tabular-nums`,children:[m,`/`,g]})]}),(0,Y.jsx)(`span`,{className:`opacity-40 hidden sm:inline`,children:`·`}),(0,Y.jsxs)(`span`,{className:`tabular-nums font-mono hidden sm:inline`,children:[`↓`,tg(c),` ↑`,tg(l),` · `,eg(h)]})]}),C>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`opacity-40`,children:`·`}),(0,Y.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),r(!0),i(`sideEffects`)},className:`flex items-center gap-1 text-yellow-500 hover:text-yellow-400 transition-colors`,title:a(`activity:inspector.openAudit`),children:[(0,Y.jsx)($n,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{className:`tabular-nums`,children:C})]})]})]}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 shrink-0 opacity-70 group-hover:opacity-100`,children:[(0,Y.jsx)(j,{className:`h-3 w-3`}),(0,Y.jsx)(Rr,{className:`h-3 w-3`}),(0,Y.jsx)($n,{className:`h-3 w-3`})]})]}),(0,Y.jsx)(`div`,{className:`overflow-hidden transition-[height] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)]`,style:{height:e?$h:0},children:(0,Y.jsxs)(`div`,{className:`flex flex-col`,style:{height:$h},children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 px-2 h-8 border-b bg-muted/30 shrink-0`,children:[(0,Y.jsx)(ig,{active:t===`fleet`,onClick:b,icon:(0,Y.jsx)(j,{className:`h-3.5 w-3.5`}),label:a(`activity:inspector.tabFleet`),count:g,running:m}),(0,Y.jsx)(ig,{active:t===`agents`,onClick:x,icon:(0,Y.jsx)(Rr,{className:`h-3.5 w-3.5`}),label:a(`activity:inspector.tabAgents`),count:g}),(0,Y.jsx)(ig,{active:t===`sideEffects`,onClick:S,icon:(0,Y.jsx)($n,{className:`h-3.5 w-3.5`}),label:a(`activity:inspector.tabAudit`),count:C}),(0,Y.jsx)(`div`,{className:`flex-1`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>r(!1),className:`p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground`,"aria-label":a(`activity:inspector.collapseAria`),title:a(`activity:inspector.collapseTitle`),children:(0,Y.jsx)(bn,{className:`h-4 w-4`})})]}),(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:t===`fleet`?(0,Y.jsx)(ag,{fleetList:p,leaderId:s,selectedAgentId:_,runningCount:m,fleetConcurrency:u,fleetConcurrencyMax:d,fleetTokensIn:c,fleetTokensOut:l,totalCost:h,eventTimeline:f,onSelectAgent:e=>{v(e.id),x()}}):t===`agents`?(0,Y.jsx)(og,{fleetList:p,selectedAgent:y,leaderId:s,selectedAgentId:y?.id??null,onSelectAgent:v}):(0,Y.jsx)(Qh,{})})]})})]})}function ig({active:e,onClick:t,icon:n,label:r,count:i,running:a}){return(0,Y.jsxs)(`button`,{type:`button`,onClick:t,className:X(`flex items-center gap-1.5 px-2.5 h-6 rounded-md text-[11px] font-medium transition-colors`,e?`bg-background text-foreground shadow-sm ring-1 ring-border`:`text-muted-foreground hover:text-foreground hover:bg-background/60`),children:[n,r,i>0&&(0,Y.jsx)(`span`,{className:X(`tabular-nums text-[10px] px-1 rounded-full`,a&&a>0?`bg-emerald-500/15 text-emerald-600 dark:text-emerald-400`:`bg-muted text-muted-foreground`),children:a===void 0?i:`${a}/${i}`})]})}function ag({fleetList:e,leaderId:t,selectedAgentId:n,runningCount:r,fleetConcurrency:i,fleetConcurrencyMax:a,fleetTokensIn:o,fleetTokensOut:s,totalCost:c,eventTimeline:l,onSelectAgent:u}){let{t:d}=V();return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1.5 border-b text-[11px] text-muted-foreground shrink-0`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[r>0&&(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-emerald-500 animate-pulse`}),(0,Y.jsxs)(`span`,{className:`tabular-nums`,children:[d(`activity:agents.runningCount`,{count:r}),` · `,d(`activity:agents.totalCount`,{count:e.length})]})]}),(0,Y.jsx)(jh,{current:i,max:a,showLabel:!0}),(0,Y.jsx)(`div`,{className:`flex-1`}),(0,Y.jsxs)(`span`,{className:`tabular-nums font-mono`,children:[`↓`,tg(o),` ↑`,tg(s),` · `,eg(c)]})]}),e.length===0?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:[(0,Y.jsx)(Rr,{className:`h-8 w-8 mb-2 opacity-20`}),(0,Y.jsx)(`p`,{className:`text-xs font-medium`,children:d(`activity:inspector.noAgentsActive`)}),(0,Y.jsx)(`p`,{className:`text-[11px] mt-0.5`,children:d(`activity:inspector.agentsAppearHint`)})]}):(0,Y.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto p-1.5`,children:e.map(e=>(0,Y.jsx)(Uh,{agent:e,isSelected:n===e.id,isLeader:e.id===t,onClick:()=>u(e)},e.id))}),l.length>0&&(0,Y.jsx)(`div`,{className:`border-t px-3 py-1.5 shrink-0`,children:(0,Y.jsx)(Ph,{events:l,max:4})})]})}function og({fleetList:e,selectedAgent:t,leaderId:n,selectedAgentId:r,onSelectAgent:i}){let{t:a}=V();if(e.length===0)return(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:[(0,Y.jsx)(j,{className:`h-8 w-8 mb-2 opacity-20`}),(0,Y.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,Y.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Y.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto p-3`,children:(0,Y.jsx)(`div`,{className:`max-w-2xl mx-auto`,children:(0,Y.jsx)(af,{agent:t,isLeader:t.id===n})})}),(0,Y.jsx)(`div`,{className:`border-t px-2 py-1.5 shrink-0`,children:(0,Y.jsx)(`div`,{className:`flex items-center gap-1 overflow-x-auto pb-0.5`,children:e.map((e,n)=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),className:X(`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,Y.jsx)(`span`,{className:X(`h-1.5 w-1.5 rounded-full shrink-0`,e.status===`running`?`bg-emerald-500 animate-pulse`:e.status===`failed`?`bg-destructive`:`bg-muted-foreground/50`)}),(0,Y.jsx)(`span`,{className:`truncate max-w-[8rem]`,children:e.name})]},e.id))})})]})}var sg={note:gn,ask:ln,assign:er,steer:xt,btw:ge,broadcast:er,status:Or,result:rn},cg={high:`text-red-600 bg-red-50 dark:bg-red-950/30`,normal:`text-muted-foreground bg-muted`,low:`text-slate-500 bg-slate-50 dark:bg-slate-950/20`};function lg(e){return new Date(e).toLocaleString()}function ug(e){let t=new Date(e),n=Date.now()-t.getTime();return n<6e4?b.t(`common:time.justNow`):n<36e5?b.t(`common:time.minutesAgo`,{count:Math.round(n/6e4)}):n<864e5?b.t(`common:time.hoursAgo`,{count:Math.round(n/36e5)}):n<6048e5?b.t(`common:time.daysAgo`,{count:Math.round(n/864e5)}):t.toLocaleDateString()}function dg(){let{t:e}=V();return(0,Y.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-muted-foreground gap-3`,children:[(0,Y.jsx)(g,{className:`h-12 w-12 opacity-20`}),(0,Y.jsx)(`div`,{className:`text-sm font-medium`,children:e(`activity:mailbox.emptyDetail`)}),(0,Y.jsx)(`div`,{className:`text-xs max-w-[260px] text-center opacity-60`,children:e(`activity:mailbox.emptyDetailHint`)})]})}function fg({readBy:e}){let{t}=V(),n=Object.entries(e);return n.length===0?null:(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(`div`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wide`,children:t(`activity:mailbox.readBy`)}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:n.map(([e,t])=>(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] bg-green-50 text-green-700 dark:bg-green-950/30 dark:text-green-400`,title:lg(t),children:[(0,Y.jsx)(rn,{className:`h-2.5 w-2.5`}),e]},e))})]})}function pg({className:e}){let{t}=V(),n=J(e=>e.selectedMailMessage),r=J(e=>e.setSelectedMailMessage);(0,U.useEffect)(()=>()=>{r(null)},[r]);function i(){r(null),Q(`chat`)}if(!n)return(0,Y.jsx)(dg,{});let a=sg[n.type]??Ir,o=t(`activity:mailbox.type.${n.type}`,{defaultValue:n.type}),s=cg[n.priority]??cg.normal;return(0,Y.jsxs)(`div`,{className:X(`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,e),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2.5 border-b border-border bg-card/40 shrink-0`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:i,className:`flex items-center justify-center w-7 h-7 rounded-md hover:bg-accent text-muted-foreground hover:text-foreground transition-colors shrink-0`,title:t(`activity:mailbox.backToChat`),children:(0,Y.jsx)(et,{className:`h-4 w-4`})}),(0,Y.jsx)(`div`,{className:X(`p-1.5 rounded-md shrink-0`,n.completed?`bg-green-100 dark:bg-green-950/40`:`bg-amber-100 dark:bg-amber-950/40`),children:(0,Y.jsx)(a,{className:X(`h-4 w-4`,n.completed?`text-green-600 dark:text-green-400`:`text-amber-600 dark:text-amber-400`)})}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-foreground truncate`,children:n.subject}),n.completed&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium text-green-600 dark:text-green-400 shrink-0`,children:[(0,Y.jsx)(rn,{className:`h-3 w-3`}),t(`activity:mailbox.completed`)]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-muted-foreground mt-0.5`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-foreground/80`,children:n.from}),(0,Y.jsx)(`span`,{children:`→`}),(0,Y.jsx)(`span`,{children:n.to===`*`||n.to===`all`?t(`activity:mailbox.everyone`):n.to}),(0,Y.jsx)(`span`,{className:`opacity-40`,children:`•`}),(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(Ge,{className:`h-3 w-3`}),ug(n.timestamp)]})]})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:i,className:`flex items-center justify-center w-7 h-7 rounded-md hover:bg-accent text-muted-foreground hover:text-foreground transition-colors shrink-0`,title:t(`activity:mailbox.closeTitle`),children:(0,Y.jsx)(Xn,{className:`h-4 w-4`})})]}),(0,Y.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto`,children:(0,Y.jsx)(`div`,{className:`px-4 py-4`,children:(0,Y.jsx)(`div`,{className:`markdown-content prose prose-sm dark:prose-invert max-w-none text-sm leading-relaxed`,children:(0,Y.jsx)(vn,{components:wm,children:n.body})})})}),(0,Y.jsxs)(`div`,{className:`border-t border-border bg-card/30 px-4 py-3 shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-x-6 gap-y-2 text-xs`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Y.jsx)(xn,{className:`h-3 w-3 shrink-0`}),(0,Y.jsx)(`span`,{children:o})]}),(0,Y.jsx)(`div`,{className:`flex items-center gap-1.5`,children:(0,Y.jsx)(`span`,{className:X(`px-1.5 py-0.5 rounded text-[10px] font-semibold uppercase`,s),children:n.priority||`normal`})}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Y.jsx)(It,{className:`h-3 w-3 shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate`,title:n.from,children:n.from})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Y.jsx)(Ge,{className:`h-3 w-3 shrink-0`}),(0,Y.jsx)(`span`,{children:lg(n.timestamp)})]}),n.replyTo&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground col-span-2`,children:[(0,Y.jsx)(pr,{className:`h-3 w-3 shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate`,children:t(`activity:mailbox.replyTo`,{id:n.replyTo})})]}),n.completed&&n.completedBy&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground col-span-2`,children:[(0,Y.jsx)(rn,{className:`h-3 w-3 shrink-0 text-green-500`}),(0,Y.jsx)(`span`,{children:n.completedAt?t(`activity:mailbox.completedByAt`,{name:n.completedBy,time:lg(n.completedAt)}):t(`activity:mailbox.completedBy`,{name:n.completedBy})})]}),n.outcome&&(0,Y.jsxs)(`div`,{className:`flex items-start gap-1.5 text-muted-foreground col-span-2 sm:col-span-4`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide shrink-0 mt-0.5`,children:t(`activity:mailbox.outcome`)}),(0,Y.jsx)(`span`,{children:n.outcome})]}),n.taskContext&&(0,Y.jsxs)(`div`,{className:`flex items-start gap-1.5 text-muted-foreground col-span-2 sm:col-span-4`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide shrink-0 mt-0.5`,children:t(`activity:mailbox.task`)}),(0,Y.jsx)(`span`,{children:n.taskContext})]})]}),Object.keys(n.readBy??{}).length>0&&(0,Y.jsx)(`div`,{className:`mt-3 pt-3 border-t border-border/50`,children:(0,Y.jsx)(fg,{readBy:n.readBy})})]})]})}function mg(e){if(e<1e3)return`${e}ms`;let t=Math.round(e/100);return t<600?`${(t/10).toFixed(1)}s`:`${Math.floor(t/600)}m ${Math.round(t%600/10)}s`}var hg={user:{Icon:It,labelKey:`activity:message.roleYou`,avatarBg:`bg-primary`,avatarColor:`text-primary-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-primary/20`,bubbleBg:`bg-primary`,bubbleBorder:`border-transparent`,textColor:`text-primary-foreground`},assistant:{Icon:j,labelKey:`activity:message.roleAssistant`,avatarBg:`bg-accent`,avatarColor:`text-accent-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-accent/20`,bubbleBg:`bg-card`,bubbleBorder:`border-border`,textColor:`text-foreground`},tool:{Icon:En,labelKey:`activity:message.roleTool`,avatarBg:`bg-secondary`,avatarColor:`text-secondary-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-secondary/20`,bubbleBg:`bg-muted/80`,bubbleBorder:`border-border`,textColor:`text-foreground`},system:{Icon:j,labelKey:`activity:transcript.kindSystem`,avatarBg:`bg-muted`,avatarColor:`text-muted-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-muted/20`,bubbleBg:`bg-muted/50`,bubbleBorder:`border-border`,textColor:`text-muted-foreground`},error:{Icon:Ct,labelKey:`activity:transcript.kindError`,avatarBg:`bg-destructive`,avatarColor:`text-destructive-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-destructive/20`,bubbleBg:`bg-destructive/5`,bubbleBorder:`border-destructive/20`,textColor:`text-destructive`}};function gg({entry:e}){let{t}=V();return e.role===`error`?(0,Y.jsx)(Dm,{text:e.text}):e.role===`tool`?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5 tool-details`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-foreground`,children:[(0,Y.jsx)(En,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{className:`font-mono`,children:e.tool??t(`activity:watch.toolFallback`)}),e.durationMs!==void 0&&(0,Y.jsxs)(`span`,{className:`ml-auto text-[10px] text-muted-foreground font-normal tabular-nums`,children:[(0,Y.jsx)(Ge,{className:`h-3 w-3 inline mr-0.5 align-text-bottom`}),mg(e.durationMs)]})]}),e.input!==void 0&&e.input!==null&&(0,Y.jsx)(`div`,{className:`p-3 bg-muted/50 rounded-lg overflow-x-auto`,children:(0,Y.jsx)(Om,{input:e.input})}),e.output!==void 0&&e.output!==null?(0,Y.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:typeof e.output==`string`?(0,Y.jsx)(vn,{remarkPlugins:[o],rehypePlugins:Sm,components:wm,children:e.output}):(0,Y.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs bg-card rounded-lg p-2 border border-border overflow-x-auto`,children:JSON.stringify(e.output,null,2)})}):e.text?(0,Y.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:(0,Y.jsx)(vn,{remarkPlugins:[o],rehypePlugins:Sm,components:wm,children:e.text})}):null,e.isError&&(0,Y.jsxs)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-destructive`,children:t(`activity:watch.toolFailed`)}),e.text&&(0,Y.jsx)(`pre`,{className:`mt-1 text-xs whitespace-pre-wrap text-destructive/80`,children:e.text})]})]}):(0,Y.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:(0,Y.jsx)(vn,{remarkPlugins:[o],rehypePlugins:Sm,components:wm,children:e.text})})}function _g({entry:e,isContinuation:t=!1}){let{t:n}=V(),r=hg[e.role],i=r.Icon;return(0,Y.jsxs)(`div`,{className:`group flex gap-3 animate-message msg-bubble rounded-lg transition-shadow`,children:[t?(0,Y.jsx)(`div`,{className:`flex-shrink-0 w-8`}):(0,Y.jsx)(`div`,{className:X(`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center`,r.avatarBg,r.avatarColor,r.avatarRing),children:(0,Y.jsx)(i,{className:`h-4 w-4`})}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5 min-w-0 flex-1`,children:[!t&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:X(`text-xs font-medium`,r.textColor),children:e.role===`tool`&&e.tool?e.tool:n(r.labelKey)}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:new Date(e.ts).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}),e.role===`tool`&&e.durationMs!==void 0&&(0,Y.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[`· `,mg(e.durationMs)]})]}),(0,Y.jsx)(`div`,{className:X(`rounded-2xl px-4 py-3 border`,e.role===`user`&&`rounded-br-md`,e.role===`assistant`&&`rounded-bl-md`,e.role===`tool`&&`rounded-bl-sm`,e.role===`system`&&`rounded-bl-sm opacity-70`,e.role===`error`&&`rounded-bl-sm`,r.bubbleBg,r.bubbleBorder),children:(0,Y.jsx)(`div`,{className:X(`text-sm leading-relaxed markdown-content`,r.textColor),children:(0,Y.jsx)(gg,{entry:e})})}),e.text&&e.role!==`error`&&(0,Y.jsx)(`div`,{className:`opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,Y.jsx)(Tm,{text:e.text,label:n(`common:action.copy`)})})]})]})}var vg=[`steer`,`ask`,`assign`,`note`],yg=2500;function bg({sessionId:e,limit:t=200}){let[n,r]=(0,U.useState)(null),{t:i}=V(),[a,o]=(0,U.useState)(null),[s,c]=(0,U.useState)(``),[l,u]=(0,U.useState)(!1),[d,f]=(0,U.useState)(null),[p,m]=(0,U.useState)(`steer`),[h,g]=(0,U.useState)(`high`),[_,v]=(0,U.useState)([]),[y,x]=(0,U.useState)(!1),S=(0,U.useRef)(null),C=(0,U.useRef)(!0),w=(0,U.useRef)(!0),T=Tc(e=>e.liveSessions),E=(0,U.useMemo)(()=>T.find(t=>t.sessionId===e),[T,e]),D=(0,U.useMemo)(()=>{let e=E;return e?`${e.status}|${e.agents.map(e=>`${e.id}:${e.status}:${e.toolCalls??0}:${e.iterations??0}`).join(`,`)}`:``},[E]),O=E?.status===`active`||(E?.agents.some(e=>e.status===`running`||e.status===`streaming`)??!1),k=(0,U.useMemo)(()=>{if(!E)return null;let e=E.agents.find(e=>e.status===`running`||e.status===`streaming`);return e?.currentTool?`🔧 ${e.currentTool}`:e?i(`activity:sessionWatch.working`,{name:e.name??e.id}):null},[E,i]),A=(0,U.useMemo)(()=>{if(!E)return null;let e=E.agents.find(e=>e.partialText&&(e.status===`streaming`||e.status===`running`))??E.agents.find(e=>e.partialText);return e?.partialText?{label:e.id===`leader`?i(`activity:sessionWatch.claude`):e.name||e.id,text:e.partialText}:null},[E,i]),M=(0,U.useCallback)(async()=>{try{let n=await fetch(`/api/sessions/${encodeURIComponent(e)}/events?limit=${t}`);if(!n.ok)throw Error(`HTTP ${n.status}`);let i=await n.json();w.current&&(r(i),o(null))}catch(e){w.current&&o(e instanceof Error?e.message:String(e))}},[e,t]),N=(0,U.useCallback)(async()=>{try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/mailbox`);if(!t.ok)return;let n=await t.json();w.current&&Array.isArray(n.thread)&&v(n.thread)}catch{}},[e]);(0,U.useEffect)(()=>{w.current=!0,r(null),o(null),v([]),M(),N();let e=setInterval(()=>void M(),yg),t=setInterval(()=>void N(),yg);return()=>{w.current=!1,clearInterval(e),clearInterval(t)}},[M,N]),(0,U.useEffect)(()=>{D&&M()},[D,M]),(0,U.useEffect)(()=>{C.current&&S.current&&(S.current.scrollTop=S.current.scrollHeight)},[n,A]);let P=()=>{let e=S.current;e&&(C.current=e.scrollHeight-e.scrollTop-e.clientHeight<40)},F=async()=>{let t=s.trim();if(!(!t||l)){u(!0),f(null);try{let n=await fetch(`/api/sessions/${encodeURIComponent(e)}/message`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:t,type:p,priority:h})});if(!n.ok)throw Error(`HTTP ${n.status}`);c(``),f(O?b.t(`activity:sessionWatch.sentRunning`):b.t(`activity:sessionWatch.sentIdle`)),N()}catch(e){f(b.t(`activity:sessionWatch.sentFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{u(!1)}}},I=async()=>{if(!y){x(!0),f(null);try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/interrupt`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({reason:b.t(`activity:sessionWatch.interruptReason`)})});if(!t.ok)throw Error(`HTTP ${t.status}`);f(b.t(`activity:sessionWatch.interruptSent`)),N()}catch(e){f(b.t(`activity:sessionWatch.interruptFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{x(!1)}}},L=n?.entries??[];return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5 shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:X(`h-1.5 w-1.5 rounded-full`,O?`bg-green-500 animate-pulse`:`bg-muted-foreground`)}),i(`activity:sessionWatch.liveStream`)]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,Y.jsxs)(`div`,{className:`text-[10px] text-muted-foreground`,children:[i(`activity:sessionWatch.events`,{count:n.total}),` · `,n.status]}),O&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>void I(),disabled:y,title:i(`activity:sessionWatch.interruptTitle`),className:`rounded border border-destructive/40 bg-destructive/15 px-1.5 py-0.5 text-[10px] text-destructive hover:bg-destructive/25 disabled:opacity-40 transition-colors`,children:i(y?`activity:sessionWatch.interrupting`:`activity:sessionWatch.interrupt`)})]})]}),k&&(0,Y.jsxs)(`div`,{className:`mb-1.5 shrink-0 text-[10px] text-foreground truncate`,children:[`▶ `,k]}),a&&(0,Y.jsxs)(`div`,{className:`text-[11px] text-destructive mb-1 shrink-0`,children:[`· `,a]}),(0,Y.jsxs)(`div`,{ref:S,onScroll:P,className:`min-h-0 min-w-0 flex-1 overflow-y-auto space-y-1.5 pr-1`,children:[L.length===0&&!a&&(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground italic`,children:i(`activity:sessionWatch.loading`)}),L.map((e,t)=>(0,Y.jsx)(_g,{entry:e,isContinuation:t>0&&L[t-1].role===e.role},`${e.ts}-${t}`)),A&&(0,Y.jsxs)(`div`,{className:`flex gap-3 animate-message`,children:[(0,Y.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,Y.jsx)(j,{className:`h-4 w-4 animate-pulse`})}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5 max-w-[85%] min-w-0`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground px-1`,children:A.label}),(0,Y.jsx)(`div`,{className:`rounded-2xl rounded-bl-md px-4 py-3 bg-card border border-border`,children:(0,Y.jsxs)(`span`,{className:`text-sm leading-relaxed text-foreground whitespace-pre-wrap break-words`,children:[A.text,(0,Y.jsx)(`span`,{className:`animate-pulse text-primary`,children:`▋`})]})})]})]})]}),_.length>0&&(0,Y.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-border shrink-0 max-h-28 overflow-y-auto space-y-1`,children:[(0,Y.jsx)(`div`,{className:`text-[9px] uppercase tracking-wide text-muted-foreground`,children:i(`activity:mailbox.messages`)}),_.slice(-6).map(e=>{let t=e.completed?i(`activity:sessionWatch.done`):e.readByLeader?i(`activity:sessionWatch.read`):i(`activity:sessionWatch.delivered`);return(0,Y.jsxs)(`div`,{className:`text-[10px] leading-snug`,children:[(0,Y.jsx)(`span`,{className:X(`font-semibold mr-1.5`,e.fromLeader?`text-accent`:`text-primary`),children:e.fromLeader?i(`activity:sessionWatch.agent`):i(`activity:sessionWatch.you`)}),(0,Y.jsx)(`span`,{className:`text-foreground whitespace-pre-wrap break-words`,children:e.body}),!e.fromLeader&&(0,Y.jsx)(`span`,{className:X(`ml-1.5 text-[9px]`,e.completed?`text-green-500`:e.readByLeader?`text-cyan-500`:`text-muted-foreground`),children:t})]},e.id)})]}),(0,Y.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-border shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5`,children:[(0,Y.jsx)(`select`,{value:p,onChange:e=>m(e.target.value),title:i(`activity:sessionWatch.msgType.${p}Hint`),className:`rounded bg-muted border border-border px-1.5 py-0.5 text-[10px] text-foreground focus:outline-none focus:ring-1 focus:ring-ring`,children:vg.map(e=>(0,Y.jsx)(`option`,{value:e,children:i(`activity:sessionWatch.msgType.${e}Label`)},e))}),(0,Y.jsxs)(`select`,{value:h,onChange:e=>g(e.target.value),title:i(`activity:sessionWatch.priority`),className:`rounded bg-muted border border-border px-1.5 py-0.5 text-[10px] text-foreground focus:outline-none focus:ring-1 focus:ring-ring`,children:[(0,Y.jsx)(`option`,{value:`high`,children:`high`}),(0,Y.jsx)(`option`,{value:`normal`,children:`normal`}),(0,Y.jsx)(`option`,{value:`low`,children:`low`})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-end gap-1.5`,children:[(0,Y.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),F())},rows:2,placeholder:i(`activity:sessionWatch.placeholder`,{label:i(`activity:sessionWatch.msgType.${p}Label`)}),className:`flex-1 resize-none rounded-md bg-muted border border-border px-2 py-1 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>void F(),disabled:l||!s.trim(),className:`shrink-0 rounded-md bg-primary text-primary-foreground px-2.5 py-1.5 text-xs hover:bg-primary/90 disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:l?`…`:i(`activity:sessionWatch.send`)})]}),d&&(0,Y.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:d}),(0,Y.jsx)(`div`,{className:`mt-0.5 text-[9px] text-muted-foreground`,children:i(`activity:sessionWatch.sendHint`)})]})]})}function xg(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 Sg(e,t){if(!e)return`never`;let n=Date.parse(e);if(!Number.isFinite(n))return`never`;let r=Math.max(0,Math.round((t-n)/1e3));return r<60?`${r}s ago`:r<3600?`${Math.round(r/60)}m ago`:r<86400?`${Math.round(r/3600)}h ago`:`${Math.round(r/86400)}d ago`}function Cg(e,t){if(!e)return``;let n=Date.parse(e);if(!Number.isFinite(n))return``;let r=Math.max(0,Math.round((t-n)/1e3));return r<60?`${r}s`:r<3600?`${Math.round(r/60)}m`:`${Math.round(r/3600)}h`}function wg(e){if(!e)return;let t=e.split(`/`);return t[t.length-1]?.slice(0,18)}function Tg(e,t=380){let n=new Map,r=Math.max(1,e.length);return e.forEach((e,i)=>{let a=(i-(r-1)/2)*t;n.set(e,600+a)}),n}function Eg(e,t,n){let r=Math.min(3,n),i=Math.floor(t/r),a=t%r;return{x:e-(Math.min(r,n-i*r)-1)*190/2+a*190,y:640+i*150}}function Dg(e){return e===`tui`?`tui`:e===`repl`||e===`cli`?`repl`:`webui`}function Og(e){return e===`tui`?`TUI`:e===`repl`?`REPL`:`WebUI`}function kg(e){switch(e){case`running`:case`active`:return`active`;case`idle`:return`idle`;case`completed`:return`completed`;case`failed`:case`error`:return`error`;case`stopped`:return`offline`;default:return`idle`}}function Ag(e,t){let n=new Set,r=[];for(let i of e){let e=Dg(i.clientType),a=`client-${i.pid??i.sessionId}`,o=[],s=!1;for(let e of i.agents){n.add(e.id);let r=t.get(e.id),i=kg(r?.status??e.status);(i===`active`||i===`streaming`)&&(s=!0),o.push({officeId:`${a}__agent-${e.id}`,serverId:e.id,name:r?.name??e.name??e.id,status:i,iteration:r?.iteration??e.iterations??0,toolCalls:r?.toolCalls??e.toolCalls??0,costUsd:r?.costUsd??e.costUsd??0,tokensIn:r?.tokensIn??e.tokensIn??0,tokensOut:r?.tokensOut??e.tokensOut??0,ctxPct:r?.ctxPct??e.ctxPct,model:r?.model??e.model,lastActivityAt:e.lastActivityAt,currentTask:r?.currentTool??r?.lastTool??e.currentTool})}let c=i.status===`closing`||i.status===`stale`?`offline`:s?`active`:`idle`;r.push({id:a,type:e,label:i.projectName||Og(e),sublabel:[Og(e),i.gitBranch?`⎇ ${i.gitBranch}`:``,i.pid?`pid ${i.pid}`:``].filter(Boolean).join(` · `),status:c,sessionId:i.sessionId,pid:i.pid,branch:i.gitBranch,workingDir:i.workingDir,startedAt:i.startedAt,agents:o})}let i=[...t.values()].filter(e=>!n.has(e.id));if(i.length>0){let e=r.find(e=>e.type===`webui`);e||(e={id:`client-self`,type:`webui`,label:`This WebUI`,sublabel:`Web UI`,status:`idle`,agents:[]},r.push(e));for(let t of i){let n=kg(t.status);(n===`active`||n===`streaming`)&&(e.status=`active`),e.agents.push({officeId:`${e.id}__agent-${t.id}`,serverId:t.id,name:t.name,status:n,iteration:t.iteration??0,toolCalls:t.toolCalls??0,costUsd:t.costUsd??0,tokensIn:t.tokensIn??0,tokensOut:t.tokensOut??0,ctxPct:t.ctxPct,model:t.model,currentTask:t.currentTool??t.lastTool})}}return r.length===0&&r.push({id:`client-self`,type:`webui`,label:`This WebUI`,sublabel:`Web UI · connecting…`,status:`idle`,agents:[]}),r}function jg(e){return e.startsWith(`tool`)?`#eab308`:e.startsWith(`mailbox`)?`#06b6d4`:e.startsWith(`provider`)?`#a855f7`:e.startsWith(`agent`)||e.startsWith(`subagent`)?`#22c55e`:e.includes(`error`)?`#ef4444`:`#6366f1`}function Mg(e){return Math.min(100,Math.max(0,e??0))}function Ng({status:e,small:t,activity:n=0}){let r=t?`w-2 h-2`:`w-3 h-3`,i=t?4+n*4:6+n*6;return(0,Y.jsx)(`span`,{className:X(`rounded-full`,r,n>0&&`animate-pulse`,{idle:`bg-gray-500`,active:`bg-emerald-500`,streaming:`bg-blue-500`,completed:`bg-blue-500`,error:`bg-red-500`,offline:`bg-gray-600`}[e]),style:{boxShadow:n>0?`0 0 ${i}px ${{idle:`#9ca3af`,active:`#22c55e`,streaming:`#3b82f6`,completed:`#3b82f6`,error:`#ef4444`,offline:`#6b7280`}[e]}`:void 0}})}function Pg(){let{t:e}=V(),{clientCounts:t,currentSession:n,totalAgents:r,activeAgents:i,aggregate:a}=Tc(),o=t.tui+t.webui+t.repl,s=e=>e?.toLocaleString()??`0`;return(0,Y.jsxs)(`div`,{className:`absolute top-20 left-4 z-10 bg-slate-800/95 backdrop-blur border border-slate-700 rounded-lg p-3 shadow-xl`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,Y.jsx)($n,{className:`h-3.5 w-3.5 text-emerald-400`}),(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-gray-300 uppercase tracking-wide`,children:e(`activity:office.sessionStats`)})]}),(0,Y.jsxs)(`div`,{className:`space-y-1.5 text-[10px]`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(Rr,{className:`h-3 w-3 text-gray-500`}),(0,Y.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.clients`)})]}),(0,Y.jsxs)(`span`,{className:`text-gray-200 font-mono`,children:[i,` `,(0,Y.jsx)(`span`,{className:`text-gray-500`,children:`/`}),` `,(0,Y.jsx)(`span`,{className:`text-emerald-400`,children:o})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 pl-4 text-[9px]`,children:[t.tui>0&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(En,{className:`h-2.5 w-2.5 text-emerald-500`}),(0,Y.jsx)(`span`,{className:`text-gray-400`,children:`TUI`}),(0,Y.jsx)(`span`,{className:`text-emerald-400 font-mono`,children:t.tui})]}),t.webui>0&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(an,{className:`h-2.5 w-2.5 text-blue-500`}),(0,Y.jsx)(`span`,{className:`text-gray-400`,children:`WebUI`}),(0,Y.jsx)(`span`,{className:`text-blue-400 font-mono`,children:t.webui})]}),t.repl>0&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(En,{className:`h-2.5 w-2.5 text-amber-500`}),(0,Y.jsx)(`span`,{className:`text-gray-400`,children:`REPL`}),(0,Y.jsx)(`span`,{className:`text-amber-400 font-mono`,children:t.repl})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(j,{className:`h-3 w-3 text-gray-500`}),(0,Y.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:officeMap.agents`)})]}),(0,Y.jsxs)(`span`,{className:`text-gray-200 font-mono`,children:[i,` `,(0,Y.jsx)(`span`,{className:`text-gray-500`,children:`/`}),` `,(0,Y.jsx)(`span`,{className:`text-cyan-400`,children:r})]})]}),n.model&&(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(wr,{className:`h-3 w-3 text-gray-500`}),(0,Y.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:officeMap.model`)})]}),(0,Y.jsx)(`span`,{className:`text-cyan-400 font-mono truncate max-w-[120px]`,title:n.model,children:n.model.split(`/`).pop()?.slice(0,16)})]}),n.mode&&(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(tn,{className:`h-3 w-3 text-gray-500`}),(0,Y.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:officeMap.mode`)})]}),(0,Y.jsx)(`span`,{className:X(`font-mono uppercase text-[9px] px-1.5 py-0.5 rounded`,n.mode===`auto`&&`bg-purple-500/20 text-purple-400`,n.mode===`suggest`&&`bg-blue-500/20 text-blue-400`,n.mode===`off`&&`bg-gray-500/20 text-gray-400`,![`auto`,`suggest`,`off`].includes(n.mode||``)&&`bg-gray-500/20 text-gray-400`),children:n.mode})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(rt,{className:`h-3 w-3 text-gray-500`}),(0,Y.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.toolCallsLabel`)})]}),(0,Y.jsx)(`span`,{className:`text-yellow-400 font-mono`,children:s(a.toolCalls)})]}),(0,Y.jsxs)(`div`,{className:`border-t border-slate-700 pt-1.5 mt-1.5 space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-gray-500 text-[8px]`,children:`IN`}),(0,Y.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.input`)})]}),(0,Y.jsx)(`span`,{className:`text-gray-300 font-mono text-[9px]`,children:s(a.tokensIn)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-gray-500 text-[8px]`,children:`OUT`}),(0,Y.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.output`)})]}),(0,Y.jsx)(`span`,{className:`text-gray-300 font-mono text-[9px]`,children:s(a.tokensOut)})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4 border-t border-slate-700 pt-1.5 mt-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(Fn,{className:`h-3 w-3 text-gray-500`}),(0,Y.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.cost`)})]}),(0,Y.jsx)(`span`,{className:`text-emerald-400 font-mono font-medium`,children:(e=>e==null?`$0.0000`:`$${e.toFixed(4)}`)(a.costUsd)})]})]})]})}function Fg(){let e={opacity:0,width:1,height:1,minWidth:0,border:`none`,background:`transparent`};return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Dn,{type:`target`,position:xr.Top,style:e,isConnectable:!1}),(0,Y.jsx)(Dn,{type:`source`,position:xr.Bottom,style:e,isConnectable:!1})]})}function Ig({data:e}){let{t}=V();return(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center justify-between border-t border-white/5 pt-1.5 text-[8px] text-gray-500`,children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:`font-mono text-gray-300`,children:e.agentCount??0}),` `,t(`activity:office.agentsSuffix`)]}),e.startedAt&&(0,Y.jsx)(`span`,{children:t(`activity:office.upPrefix`,{time:Cg(e.startedAt,Date.now())})})]})}function Lg({data:e}){let{t}=V(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.status===`offline`,a=e.color||`#3b82f6`;return(0,Y.jsxs)(`div`,{className:X(`rounded-xl border-2 p-4 min-w-[180px] transition-all backdrop-blur-sm`,n&&`shadow-lg shadow-blue-500/20`,r&&`border-red-500/50 bg-red-500/10`,i&&`border-gray-500/30 bg-gray-500/5 opacity-60`,!n&&!r&&!i&&`border-blue-500/30 bg-blue-500/10`),children:[(0,Y.jsx)(Fg,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,Y.jsx)(`div`,{className:X(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-blue-500/20`:`bg-blue-500/10`),children:(0,Y.jsx)(an,{className:`h-5 w-5`,style:{color:a}})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:a},children:e.label}),(0,Y.jsx)(`div`,{className:`text-[10px] text-gray-500`,children:t(`activity:office.webuiClient`)})]}),(0,Y.jsx)(Ng,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,Y.jsx)(`div`,{className:`text-[10px] text-gray-400 mb-2 truncate`,children:e.sublabel}),(0,Y.jsx)(`div`,{className:`flex items-center gap-2 text-[10px] text-gray-500`,children:i?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(sn,{className:`h-3 w-3 text-gray-500`}),(0,Y.jsx)(`span`,{children:t(`activity:office.disconnected`)})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(fn,{className:`h-3 w-3 text-emerald-500`}),(0,Y.jsx)(`span`,{children:t(`activity:office.connected`)})]})}),n&&(0,Y.jsx)(`div`,{className:`mt-2 h-1 rounded-full bg-blue-500/30 overflow-hidden`,children:(0,Y.jsx)(`div`,{className:`h-full bg-blue-500 animate-pulse`,style:{width:`60%`}})}),(0,Y.jsx)(Ig,{data:e})]})}function Rg({data:e}){let{t}=V(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.color||`#22c55e`;return(0,Y.jsxs)(`div`,{className:X(`rounded-xl border-2 p-4 min-w-[180px] transition-all backdrop-blur-sm`,n&&`shadow-lg shadow-emerald-500/20`,r&&`border-red-500/50 bg-red-500/10`,!n&&!r&&`border-emerald-500/30 bg-emerald-500/10`),children:[(0,Y.jsx)(Fg,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,Y.jsx)(`div`,{className:X(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-emerald-500/20`:`bg-emerald-500/10`),children:(0,Y.jsx)(En,{className:`h-5 w-5`,style:{color:i}})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:i},children:e.label}),(0,Y.jsx)(`div`,{className:`text-[10px] text-gray-500`,children:t(`activity:office.tuiClient`)})]}),(0,Y.jsx)(Ng,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,Y.jsx)(`div`,{className:`text-[10px] text-gray-400 mb-2 truncate`,children:e.sublabel}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-gray-500`,children:[(0,Y.jsx)(En,{className:`h-3 w-3 text-emerald-500`}),(0,Y.jsx)(`span`,{children:t(`activity:office.terminal`)})]}),(0,Y.jsx)(Ig,{data:e})]})}function zg({data:e}){let{t}=V(),n=e.status===`active`||e.status===`streaming`,r=e.color||`#f59e0b`;return(0,Y.jsxs)(`div`,{className:X(`rounded-xl border-2 p-4 min-w-[160px] transition-all backdrop-blur-sm`,n&&`shadow-lg shadow-amber-500/20`,!n&&`border-amber-500/30 bg-amber-500/10`),children:[(0,Y.jsx)(Fg,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,Y.jsx)(`div`,{className:X(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-amber-500/20`:`bg-amber-500/10`),children:(0,Y.jsx)(En,{className:`h-5 w-5`,style:{color:r}})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:r},children:e.label}),(0,Y.jsx)(`div`,{className:`text-[10px] text-gray-500`,children:t(`activity:office.repl`)})]}),(0,Y.jsx)(Ng,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,Y.jsx)(`div`,{className:`text-[10px] text-gray-400 mb-1 truncate`,children:e.sublabel}),(0,Y.jsx)(Ig,{data:e})]})}function Bg({data:e}){let{t}=V(),n=e.status===`active`||e.status===`streaming`,r=e.color||`#a855f7`;return(0,Y.jsxs)(`div`,{className:`rounded-xl border-2 p-4 min-w-[200px] transition-all backdrop-blur-sm relative bg-slate-900/90`,children:[(0,Y.jsx)(Fg,{}),(0,Y.jsx)(`div`,{className:`absolute -top-3 left-1/2 -translate-x-1/2 px-2 py-0.5 bg-purple-600 text-white text-[9px] rounded-full font-bold`,children:t(`activity:office.coordinator`)}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 mb-3 mt-2`,children:[(0,Y.jsx)(`div`,{className:X(`flex items-center justify-center w-12 h-12 rounded-xl`,n?`bg-purple-500/20`:`bg-purple-500/10`),children:(0,Y.jsx)(wr,{className:`h-6 w-6`,style:{color:r}})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-bold truncate`,style:{color:r},children:e.label}),(0,Y.jsx)(`div`,{className:`text-[10px] text-gray-500`,children:e.sublabel||t(`activity:office.fleetSummary`)})]}),(0,Y.jsx)(Ng,{status:e.status,activity:e.vizActivity??0})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-[10px] mb-2`,children:[(0,Y.jsxs)(`div`,{className:`bg-black/20 rounded p-1.5 text-center`,children:[(0,Y.jsxs)(`div`,{className:`font-mono`,children:[(0,Y.jsx)(`span`,{className:`text-emerald-400`,children:e.agentsActive||0}),(0,Y.jsx)(`span`,{className:`text-gray-500`,children:` / `}),(0,Y.jsx)(`span`,{className:`text-purple-400`,children:e.agentsTotal||0})]}),(0,Y.jsx)(`div`,{className:`text-gray-500`,children:t(`activity:officeMap.agents`)})]}),(0,Y.jsxs)(`div`,{className:`bg-black/20 rounded p-1.5 text-center`,children:[(0,Y.jsx)(`div`,{className:`font-mono text-yellow-400`,children:(e.toolCalls||0).toLocaleString()}),(0,Y.jsx)(`div`,{className:`text-gray-500`,children:t(`activity:office.toolCallsLabel`)})]}),(0,Y.jsxs)(`div`,{className:`bg-black/20 rounded p-1.5 text-center`,children:[(0,Y.jsx)(`div`,{className:`font-mono text-gray-300`,children:xg(e.tokensIn)}),(0,Y.jsx)(`div`,{className:`text-gray-500`,children:t(`activity:office.tokensLabel`)})]}),(0,Y.jsxs)(`div`,{className:`bg-black/20 rounded p-1.5 text-center`,children:[(0,Y.jsxs)(`div`,{className:`font-mono text-emerald-400`,children:[`$`,(e.costUsd||0).toFixed(3)]}),(0,Y.jsx)(`div`,{className:`text-gray-500`,children:t(`activity:office.cost`)})]})]}),n&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-purple-400`,children:[(0,Y.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-purple-400 animate-pulse`}),t(`activity:office.coordinatingFleet`)]})]})}function Vg({data:e}){let{t}=V(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.status===`completed`,a=e.color||`#06b6d4`,o=Mg(e.ctxPct);return(0,Y.jsxs)(`div`,{className:X(`rounded-lg border p-3 min-w-[150px] transition-all backdrop-blur-sm`,n&&`border-cyan-500/50 bg-cyan-500/10 shadow-lg shadow-cyan-500/10`,r&&`border-red-500/50 bg-red-500/10`,i&&`border-gray-500/30 bg-gray-500/5`,!n&&!r&&!i&&`border-cyan-500/30 bg-cyan-500/10`),children:[(0,Y.jsx)(Fg,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[(0,Y.jsx)(j,{className:`h-4 w-4 shrink-0`,style:{color:a}}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-[11px] font-bold truncate`,style:{color:a},children:e.label}),e.model&&(0,Y.jsx)(`div`,{className:`text-[8px] text-gray-500 truncate`,children:wg(e.model)})]}),(0,Y.jsx)(Ng,{status:e.status,small:!0,activity:e.vizActivity??0})]}),e.currentTask&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 text-[9px] text-cyan-300/90 truncate mb-1.5`,children:[(0,Y.jsx)(`span`,{className:X(`w-1.5 h-1.5 rounded-full bg-cyan-400 shrink-0`,n&&`animate-pulse`)}),(0,Y.jsx)(`span`,{className:`truncate font-mono`,children:e.currentTask})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-2 gap-y-0.5 text-[9px] mb-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-gray-500`,children:`iter`}),(0,Y.jsx)(`span`,{className:`text-gray-300 font-mono`,children:e.iteration||0})]}),(0,Y.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-gray-500`,children:`tools`}),(0,Y.jsx)(`span`,{className:`text-yellow-400/90 font-mono`,children:e.toolCalls||0})]}),(0,Y.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-gray-500`,children:`tok`}),(0,Y.jsx)(`span`,{className:`text-gray-300 font-mono`,children:xg((e.tokensIn||0)+(e.tokensOut||0))})]}),(0,Y.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-gray-500`,children:`cost`}),(0,Y.jsxs)(`span`,{className:`text-emerald-400/90 font-mono`,children:[`$`,(e.costUsd||0).toFixed(3)]})]})]}),o>0&&(0,Y.jsxs)(`div`,{className:`mb-1`,children:[(0,Y.jsxs)(`div`,{className:`flex justify-between text-[8px] text-gray-500 mb-0.5`,children:[(0,Y.jsx)(`span`,{children:`ctx`}),(0,Y.jsxs)(`span`,{className:X(`font-mono`,o>=90?`text-red-400`:o>=70?`text-amber-400`:`text-gray-400`),children:[o,`%`]})]}),(0,Y.jsx)(`div`,{className:`h-1 rounded-full bg-slate-700/60 overflow-hidden`,children:(0,Y.jsx)(`div`,{className:X(`h-full`,o>=90?`bg-red-500`:o>=70?`bg-amber-500`:`bg-cyan-500`),style:{width:`${o}%`}})})]}),e.lastActivityAt&&(0,Y.jsxs)(`div`,{className:X(`flex items-center gap-1 text-[8px]`,n?`text-gray-600`:`text-gray-500`),children:[i&&(0,Y.jsx)(`span`,{className:`text-emerald-500/70`,children:t(`activity:office.donePrefix`)}),r&&(0,Y.jsx)(`span`,{className:`text-red-400/80`,children:t(`activity:office.failedPrefix`)}),(0,Y.jsx)(`span`,{children:t(`activity:office.seenPrefix`,{time:Sg(e.lastActivityAt,Date.now())})})]})]})}function Hg({data:e}){let{t}=V();return(0,Y.jsxs)(`div`,{className:X(`rounded-lg border border-dashed p-3 min-w-[120px] transition-all opacity-40`,`border-gray-600 bg-gray-800/30`),children:[(0,Y.jsx)(Fg,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,Y.jsx)(F,{className:`h-4 w-4 text-gray-600`}),(0,Y.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,Y.jsx)(`div`,{className:`text-[10px] text-gray-500 truncate`,children:e.label})}),(0,Y.jsx)(Ng,{status:e.status,small:!0,activity:e.vizActivity??0})]}),(0,Y.jsx)(`div`,{className:`text-[9px] text-gray-600`,children:t(`activity:office.availableDesk`)})]})}function Ug({data:e}){let{t}=V(),n=e.color||`#eab308`,r=(e.unreadCount||0)>0;return(0,Y.jsxs)(`div`,{className:X(`rounded-xl border-2 p-4 min-w-[160px] transition-all backdrop-blur-sm`,r&&`border-yellow-500/50 bg-yellow-500/10 shadow-lg shadow-yellow-500/10`,!r&&`border-yellow-500/30 bg-yellow-500/5`),children:[(0,Y.jsx)(Fg,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,Y.jsx)(`div`,{className:X(`flex items-center justify-center w-10 h-10 rounded-lg`,r?`bg-yellow-500/20`:`bg-yellow-500/10`),children:(0,Y.jsx)(g,{className:`h-5 w-5`,style:{color:n}})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold`,style:{color:n},children:t(`activity:office.mailboxHub`)}),(0,Y.jsx)(`div`,{className:`text-[10px] text-gray-500`,children:r?t(`activity:office.unreadSuffix`,{count:e.unreadCount||0}):t(`activity:office.allClear`)})]}),r&&(0,Y.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-yellow-500 text-black text-[10px] font-bold flex items-center justify-center`,children:e.unreadCount})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-[10px]`,children:[(0,Y.jsxs)(`div`,{className:`bg-black/20 rounded p-1.5 text-center`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-yellow-400`,children:[(0,Y.jsx)(er,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:e.messageCount||0})]}),(0,Y.jsx)(`div`,{className:`text-gray-500`,children:t(`activity:office.total`)})]}),(0,Y.jsxs)(`div`,{className:`bg-black/20 rounded p-1.5 text-center`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-emerald-400`,children:[(0,Y.jsx)(Br,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:e.unreadCount||0})]}),(0,Y.jsx)(`div`,{className:`text-gray-500`,children:t(`activity:office.unreadLabel`)})]})]}),e.sublabel&&(0,Y.jsxs)(`div`,{className:`mt-2 truncate border-t border-white/5 pt-1.5 text-[9px] text-gray-400`,children:[`✉ `,e.sublabel]})]})}var Wg={webui:Lg,tui:Rg,repl:zg,coordinator:Bg,agent:Vg,mailbox:Ug,desk:Hg},Gg={wire:({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:i,targetPosition:a,data:o,selected:s})=>{let c=o?.color||`#6366f1`,l=Fc(e=>e.animateEdges),u=o?.animated&&l?Math.max(.15,o?.intensity??.6):0,[d,f,p]=Pr({sourceX:e,sourceY:t,sourcePosition:i??xr.Bottom,targetX:n,targetY:r,targetPosition:a??xr.Top,curvature:.28}),m=5+u*7,h=5+u*4,g=m+h,_=`${Math.max(.5,1.6-u).toFixed(2)}s`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`path`,{d,fill:`none`,stroke:c,strokeWidth:s?2.5:1.4,strokeOpacity:s?.9:.28,className:`react-flow__edge-path`}),u>.05&&(0,Y.jsx)(`path`,{d,fill:`none`,stroke:c,strokeWidth:2.2,strokeOpacity:.45+u*.5,strokeDasharray:`${m} ${h}`,strokeLinecap:`round`,style:{filter:`drop-shadow(0 0 ${2+u*4}px ${c})`},children:(0,Y.jsx)(`animate`,{attributeName:`stroke-dashoffset`,from:g,to:`0`,dur:_,repeatCount:`indefinite`})}),o?.label&&u>.1&&(0,Y.jsx)(Lt,{children:(0,Y.jsx)(`div`,{style:{position:`absolute`,transform:`translate(-50%, -50%) translate(${f}px, ${p}px)`},className:`pointer-events-none rounded-full border border-white/15 bg-slate-800/90 px-1.5 py-0.5 text-[8px] font-medium text-white/85 backdrop-blur-sm`,children:o.label})})]})}};function Kg({events:e,now:t}){let{t:n}=V(),r=e.slice(0,14);return(0,Y.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 z-10 pointer-events-none px-3 pb-3`,children:(0,Y.jsxs)(`div`,{className:`pointer-events-auto rounded-lg bg-slate-900/85 border border-slate-700/70 backdrop-blur px-3 py-2 max-w-3xl mx-auto`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5 text-[10px] uppercase tracking-wide text-cyan-400/80`,children:[(0,Y.jsx)($n,{className:`h-3 w-3`}),n(`activity:office.liveActivity`)]}),r.length===0?(0,Y.jsx)(`div`,{className:`text-[11px] text-gray-500 italic`,children:n(`activity:office.waitingActivity`)}):(0,Y.jsx)(`div`,{className:`flex flex-col gap-0.5 max-h-32 overflow-hidden`,children:r.map(e=>{let r=Math.max(0,Math.round((t-e.timestamp)/1e3));return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] leading-tight`,children:[(0,Y.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0`,style:{backgroundColor:jg(e.kind)}}),(0,Y.jsx)(`span`,{className:`text-gray-300 truncate flex-1`,children:e.label}),(0,Y.jsx)(`span`,{className:`text-gray-600 shrink-0 tabular-nums`,children:r<1?n(`activity:office.now`):`${r}s`})]},e.id)})})]})})}function qg(){let{t:e}=V(),{fitView:t}=St(),n=vc(e=>e.events),r=Xs(e=>e.agents),i=Xs(e=>e.agentTranscripts),a=Xs(e=>e.leaderId),o=Tc(e=>e.liveSessions),s=bs(e=>e.messages),c=q(e=>e.session),l=(0,U.useMemo)(()=>Ag(o,r),[o,r]),u=Fc(e=>e.showHud),d=Fc(e=>e.showLegend),f=Fc(e=>e.showMinimap),p=Fc(e=>e.showControls),m=Fc(e=>e.showFeed),h=Fc(e=>e.setShowFeed),_=Fc(e=>e.background),[v,y,b]=nn([]),[x,S,C]=cn([]),[w,T]=(0,U.useState)(null),[E,D]=(0,U.useState)(null),[O,k]=(0,U.useState)(!1),[A,M]=(0,U.useState)(``),[N,P]=(0,U.useState)(!1),[F,I]=(0,U.useState)(null),L=(0,U.useMemo)(()=>{if(w?.data.kind!==`agent`)return Bs;let e=w.data.serverId??(w.id.includes(`__agent-`)?w.id.split(`__agent-`).pop():w.id.replace(/^agent-/,``));return e?i.get(e)??Bs:Bs},[i,w]),R=(0,U.useCallback)(async()=>{let e=A.trim();if(!(!e||N)){P(!0),I(null);try{let t=await fetch(`/api/fleet/broadcast`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e})});if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();M(``),I(`Delivered to ${n.delivered??0}/${n.targets??0} session(s)`)}catch(e){I(`Failed: ${e instanceof Error?e.message:String(e)}`)}finally{P(!1)}}},[A,N]),ee=(0,U.useRef)(new Map),te=4e3,ne=(0,U.useRef)(new Map),re=(0,U.useRef)(new Map),ie=(0,U.useRef)(new Map),ae=(0,U.useRef)(new Map),oe=(0,U.useRef)(``);(0,U.useEffect)(()=>{let n=[],i=[],o=Date.now(),c=Math.max(1,...l.map(e=>e.agents.length||1)),u=Math.max(380,Math.min(3,c)*190+80),d=Tg(l.map(e=>e.id),u),f=s.filter(e=>!e.completed&&(e.readByCount??0)===0).length,p=s.length?[...s].sort((e,t)=>Date.parse(t.timestamp)-Date.parse(e.timestamp))[0]:void 0;n.push({id:`mailbox`,type:`mailbox`,position:{x:830,y:50},data:{label:e(`activity:office.mailboxHub`),kind:`mailbox`,status:f>0?`active`:`idle`,unreadCount:f,messageCount:s.length,sublabel:p?`${p.from} → ${p.to}: ${p.subject}`:void 0,color:`#eab308`}});let m=0,h=0,g=0,_=0,v=0;for(let e of l)for(let t of e.agents)h+=1,(t.status===`active`||t.status===`streaming`)&&(m+=1),g+=t.toolCalls,_+=t.costUsd,v+=t.tokensIn+t.tokensOut;let b=a?r.get(a):null,x=m>0;n.push({id:`coordinator`,type:`coordinator`,position:{x:370,y:50},data:{label:e(`activity:office.fleetHqLabel`),sublabel:e(`activity:office.clientsSuffix`,{count:l.length}),kind:`coordinator`,status:b?.status===`failed`?`error`:x?`active`:`idle`,connections:l.length,agentsActive:m,agentsTotal:h,toolCalls:g,costUsd:_,tokensIn:v,color:`#a855f7`}});let C={tui:`#22c55e`,webui:`#3b82f6`,repl:`#f59e0b`};for(let t of l){let r=d.get(t.id)??600,a=C[t.type],s=t.status===`active`;if(n.push({id:t.id,type:t.type,position:{x:r,y:370},data:{label:t.label,sublabel:t.sublabel,kind:t.type,status:t.status,sessionId:t.sessionId,pid:t.pid,branch:t.branch,workingDir:t.workingDir,startedAt:t.startedAt,agentCount:t.agents.length,color:a}}),i.push({id:`${t.id}->coordinator`,source:t.id,target:`coordinator`,type:`wire`,animated:s,data:{color:a,animated:s,label:e(`activity:office.controlLabel`),flowType:`task`}}),i.push({id:`mailbox->${t.id}`,source:`mailbox`,target:t.id,type:`wire`,animated:f>0,data:{color:`#eab308`,animated:f>0,label:f>0?`${f}`:void 0,flowType:`mail`}}),t.agents.length===0){n.push({id:`desk-${t.id}`,type:`desk`,position:{x:r,y:640},data:{label:e(`activity:office.idleDesk`),kind:`agent`,status:`idle`,color:`#374151`}});continue}t.agents.forEach((a,s)=>{let c=a.status===`active`||a.status===`streaming`,l=ae.current.get(a.serverId);if(l&&(a.toolCalls>l.toolCalls||a.iteration>l.iteration)||c){ee.current.set(a.officeId,o+te);let e=re.current.get(a.officeId)??0;re.current.set(a.officeId,Math.min(1,e+(1-e)*.5));for(let e of[`${t.id}->${a.officeId}`,`${t.id}->coordinator`]){let t=ne.current.get(e)??0;ne.current.set(e,Math.min(1,t+.5))}}ae.current.set(a.serverId,{toolCalls:a.toolCalls,iteration:a.iteration}),n.push({id:a.officeId,type:`agent`,position:Eg(r,s,t.agents.length),data:{label:a.name,kind:`agent`,status:a.status,serverId:a.serverId,sessionId:t.sessionId,currentTask:a.currentTask,iteration:a.iteration,toolCalls:a.toolCalls,costUsd:a.costUsd,tokensIn:a.tokensIn,tokensOut:a.tokensOut,ctxPct:a.ctxPct,model:a.model,lastActivityAt:a.lastActivityAt,color:`#06b6d4`}}),i.push({id:`${t.id}->${a.officeId}`,source:t.id,target:a.officeId,type:`wire`,animated:c,data:{color:`#06b6d4`,animated:c,label:c?a.currentTask??e(`activity:office.taskFallback`):void 0,flowType:`task`}})})}let w=new Set(l.flatMap(e=>e.agents.map(e=>e.serverId)));for(let e of[...ae.current.keys()])w.has(e)||ae.current.delete(e);let T=n.map(e=>{let t=ee.current.get(e.id),n=re.current.get(e.id)??0;return t&&t>o&&e.data.status!==`error`&&e.data.status!==`offline`?{...e,data:{...e.data,status:`active`,vizActivity:n}}:{...e,data:{...e.data,vizActivity:n}}}),E=i.map(e=>{let t=ne.current.get(e.id)??0;return t>.05?{...e,animated:!0,data:{...e.data,animated:!0,intensity:t}}:e}),D=new Map;for(let e of T)D.set(e.id,{...e.position});ie.current=D,y(T),S(E);let O=T.map(e=>e.id).sort().join(`|`);if(O!==oe.current){oe.current=O;let e=setTimeout(()=>t({padding:.2,duration:300}),50);return()=>clearTimeout(e)}},[l,a,r,s,c,te,y,S,t]);let se=l.flatMap(e=>e.agents.map(t=>({clientId:e.id,clientType:e.type,officeId:t.officeId,serverId:t.serverId}))),ce=l.map(e=>e.id),le=new Map;for(let e of se)(!le.has(e.serverId)||e.clientType===`webui`)&&le.set(e.serverId,e.officeId);function ue(e){return le.get(e)??`agent-${e}`}function de(e){let t=e.split(`__agent-`)[0];return t&&t!==e?`${t}->${e}`:`coordinator->${e}`}function fe(e){switch(e.kind){case`mailbox:send`:case`mailbox:deliver`:return{nodes:[`mailbox`],edges:e.kind===`mailbox:send`?ce.map(e=>`mailbox->${e}`):[],status:`active`};case`agent:spawned`:{let t=ue(e.source);return{nodes:[`coordinator`,t],edges:[de(t)],status:`active`}}case`agent:tool`:case`tool:started`:case`tool:progress`:{let t=ue(e.source);return{nodes:[`coordinator`,t],edges:[de(t)],status:e.kind===`tool:progress`||e.kind===`tool:started`?`streaming`:`active`}}case`tool:executed`:{let t=ue(e.target??e.source);return{nodes:[t],edges:[de(t)],status:`active`}}case`provider:call`:case`provider:delta`:case`provider:response`:return{nodes:[`coordinator`],edges:[],status:e.kind===`provider:delta`?`streaming`:`active`};case`iteration:start`:case`iteration:end`:return{nodes:[`coordinator`],edges:se.map(e=>de(e.officeId)),status:e.kind===`iteration:start`?`streaming`:`active`};case`agent:text`:{let t=ue(e.source);return{nodes:[t],edges:[de(t)],status:`streaming`}}case`agent:status`:{let t=ue(e.source);return{nodes:[`coordinator`,t],edges:[de(t)],status:e.data&&typeof e.data==`object`&&`status`in e.data&&String(e.data.status)===`failed`?`error`:`completed`}}case`agent:ctx`:return{nodes:[ue(e.source)],edges:[],status:`active`};case`budget:extended`:return{nodes:[`coordinator`,ue(e.source)],edges:[],status:`active`};case`context:compacted`:case`context:repaired`:return{nodes:[`coordinator`],edges:[],status:`active`};case`error`:return{nodes:e.source?[ue(e.source)]:[],edges:[],status:`error`};case`cost:update`:return{nodes:[`coordinator`],edges:[],status:`active`};case`fleet:snapshot`:{let t=e.data?.sessions??[],n=[`coordinator`];for(let e of t)if(e.agents)for(let t of e.agents){let e=ue(t.id);n.includes(e)||n.push(e)}return{nodes:n,edges:[],status:`active`}}default:return{nodes:[],edges:[],status:`idle`}}}(0,U.useEffect)(()=>{if(n.length===0)return;let e=n[0];if(!e)return;let{nodes:t,edges:r,status:i}=fe(e),a=Date.now();t.length>0&&(t.forEach(e=>{ee.current.set(e,a+te);let t=re.current.get(e)??0;re.current.set(e,Math.min(1,t+(1-t)*.5))}),y(e=>e.map(e=>t.includes(e.id)?{...e,data:{...e.data,status:i,vizActivity:re.current.get(e.id)??0}}:e))),r.length>0&&(r.forEach(e=>{let t=ne.current.get(e)??0;ne.current.set(e,Math.min(1,t+.5))}),S(e=>e.map(e=>r.includes(e.id)?{...e,animated:!0,data:{...e.data,animated:!0,intensity:ne.current.get(e.id)??1}}:e)))},[n,y,S,te,r]),(0,U.useEffect)(()=>{let e=setInterval(()=>{for(let[e,t]of ne.current){let n=t*.85;n<.05?(ne.current.delete(e),S(t=>t.map(t=>t.id===e?{...t,animated:!1,data:{...t.data,animated:!1}}:t))):(ne.current.set(e,n),S(t=>t.map(t=>t.id===e?{...t,data:{...t.data,intensity:n}}:t)))}for(let[e,t]of re.current){let n=t*.9;n<.03?(re.current.delete(e),y(t=>t.map(t=>t.id===e?{...t,data:{...t.data,vizActivity:0}}:t))):(re.current.set(e,n),y(t=>t.map(t=>t.id===e?{...t,data:{...t.data,vizActivity:n}}:t)))}},1e3);return()=>clearInterval(e)},[S,y]);let pe=(0,U.useCallback)(e=>S(t=>Kn({...e,type:`wire`},t)),[S]),me=(0,U.useCallback)((e,t)=>{T(t)},[]),he=(0,U.useCallback)(()=>{T(null)},[]);(0,U.useEffect)(()=>{if(!E)return;let e=e=>{e.key===`Escape`&&D(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[E]);let ge=(0,U.useCallback)(()=>{y(e=>e.map(e=>{let t=ie.current.get(e.id);return t?{...e,position:{...t}}:e})),setTimeout(()=>t({padding:.2,duration:300}),50)},[y,t]),[,_e]=(0,U.useState)(0);return(0,U.useEffect)(()=>{let e=setInterval(()=>_e(e=>e+1),2e3);return()=>clearInterval(e)},[]),(0,Y.jsxs)(`div`,{className:`w-full h-full bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 relative overflow-hidden`,children:[(0,Y.jsx)(`div`,{className:`absolute inset-0 opacity-[0.03]`,style:{backgroundImage:`
150
- linear-gradient(rgba(255,255,255,0.1) 1px, transparent 1px),
151
- linear-gradient(90deg, rgba(255,255,255,0.1) 1px, transparent 1px)
152
- `,backgroundSize:`40px 40px`}}),u&&(0,Y.jsx)(Pg,{}),(0,Y.jsx)(`div`,{className:`absolute top-3 left-1/2 -translate-x-1/2 z-10`,children:(0,Y.jsx)(`div`,{className:`bg-slate-800/90 backdrop-blur px-4 py-2 rounded-lg border border-slate-700 shadow-xl`,children:(0,Y.jsxs)(`div`,{className:`text-xs font-bold text-slate-300 flex items-center gap-2`,children:[(0,Y.jsx)(Ce,{className:`h-4 w-4 text-purple-400`}),e(`activity:office.fleetHq`),(0,Y.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-emerald-500 animate-pulse ml-2`}),(0,Y.jsx)(`span`,{className:`text-[10px] text-gray-400 font-normal`,children:e(`activity:office.live`)})]})})}),d&&(0,Y.jsxs)(`div`,{className:`absolute bottom-4 left-4 z-10 bg-slate-800/90 backdrop-blur rounded-lg border border-slate-700 p-3 text-[10px]`,children:[(0,Y.jsx)(`div`,{className:`font-bold text-gray-300 mb-2`,children:e(`activity:office.legendStatus`)}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-emerald-500 animate-pulse`}),(0,Y.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.legendActive`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-gray-500`}),(0,Y.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.legendIdle`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-red-500 animate-pulse`}),(0,Y.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.legendError`)})]})]})]}),d&&(0,Y.jsxs)(`div`,{className:`absolute bottom-4 right-4 z-10 bg-slate-800/90 backdrop-blur rounded-lg border border-slate-700 p-3 text-[10px]`,children:[(0,Y.jsx)(`div`,{className:`font-bold text-gray-300 mb-2`,children:e(`activity:office.legendConnections`)}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-yellow-400`,children:`✉`}),(0,Y.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.legendMail`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-purple-400`,children:`→`}),(0,Y.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.legendTask`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-emerald-400`,children:`●`}),(0,Y.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.legendStatusConn`)})]})]})]}),(0,Y.jsxs)(Mn,{nodes:v,edges:x,onNodesChange:b,onEdgesChange:C,onConnect:pe,onNodeClick:me,onPaneClick:he,nodeTypes:Wg,edgeTypes:Gg,fitView:!0,fitViewOptions:{padding:.2},minZoom:.3,maxZoom:1.5,defaultEdgeOptions:{type:`wire`},proOptions:{hideAttribution:!0},children:[(0,Y.jsxs)(Ht,{position:`top-right`,className:`flex items-center gap-2`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:ge,title:e(`activity:office.arrangeTitle`),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md bg-slate-800/90 border border-slate-700 text-xs text-slate-200 hover:bg-slate-700 transition-colors`,children:[(0,Y.jsx)(je,{className:`h-3.5 w-3.5`}),e(`activity:office.arrange`)]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>h(!m),title:e(`activity:office.feedTitle`),className:X(`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md border text-xs transition-colors`,m?`bg-cyan-500/20 border-cyan-500/40 text-cyan-300`:`bg-slate-800/90 border-slate-700 text-slate-300 hover:bg-slate-700`),children:[(0,Y.jsx)(_t,{className:`h-3.5 w-3.5`}),e(`activity:office.feed`)]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>k(e=>!e),title:e(`activity:office.broadcastTitle`),className:X(`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md border text-xs transition-colors`,O?`bg-amber-500/20 border-amber-500/40 text-amber-300`:`bg-slate-800/90 border-slate-700 text-slate-300 hover:bg-slate-700`),children:[(0,Y.jsx)(er,{className:`h-3.5 w-3.5`}),e(`activity:office.broadcast`)]})]}),_!==`none`&&(0,Y.jsx)(Dt,{variant:_===`lines`?Vn.Lines:_===`cross`?Vn.Cross:Vn.Dots,gap:20,size:1,color:`rgba(255,255,255,0.05)`}),p&&(0,Y.jsx)(or,{className:`bg-slate-800 border border-slate-700 rounded-lg [&>button]:bg-slate-700 [&>button]:text-slate-200`}),f&&(0,Y.jsx)(gr,{className:`bg-slate-800/90 border border-slate-700 rounded-lg`,nodeColor:e=>{switch(e.data.kind){case`coordinator`:return`#a855f7`;case`webui`:return`#3b82f6`;case`tui`:return`#22c55e`;case`repl`:return`#f59e0b`;case`mailbox`:return`#eab308`;case`agent`:return`#06b6d4`;default:return`#6366f1`}},maskColor:`rgba(0,0,0,0.8)`})]}),m&&(0,Y.jsx)(Kg,{events:n,now:Date.now()}),O&&(0,Y.jsxs)(`div`,{className:`absolute top-16 right-4 z-30 w-80 rounded-lg border border-amber-500/40 bg-slate-900/97 p-3 shadow-2xl backdrop-blur`,children:[(0,Y.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-semibold text-amber-300`,children:[(0,Y.jsx)(er,{className:`h-3.5 w-3.5`}),` `,e(`activity:office.broadcastToAll`)]}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>k(!1),className:`text-gray-400 hover:text-white text-base leading-none`,children:`×`})]}),(0,Y.jsx)(`textarea`,{value:A,onChange:e=>M(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),R())},rows:3,placeholder:e(`activity:office.broadcastPlaceholder`),className:`w-full resize-none rounded-md border border-slate-700 bg-slate-900/70 px-2 py-1 text-[11px] text-gray-200 placeholder:text-gray-600 focus:border-amber-500/50 focus:outline-none`}),(0,Y.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-[9px] text-gray-600`,children:e(`activity:office.broadcastSendHint`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>void R(),disabled:N||!A.trim(),className:`rounded-md border border-amber-500/40 bg-amber-500/20 px-2.5 py-1 text-[11px] text-amber-200 transition-colors hover:bg-amber-500/30 disabled:cursor-not-allowed disabled:opacity-40`,children:N?`…`:e(`activity:office.broadcast`)})]}),F&&(0,Y.jsx)(`div`,{className:`mt-1 text-[10px] text-gray-400`,children:F})]}),w&&(0,Y.jsxs)(`div`,{className:X(`absolute top-20 right-4 bg-background border border-border rounded-lg p-4 shadow-xl z-20`,w.data.kind===`agent`?`w-[28rem] max-w-[calc(100%-2rem)]`:w.data.sessionId?`w-80`:`w-64`),children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[w.data.kind===`webui`&&(0,Y.jsx)(an,{className:`h-4 w-4 text-blue-500`}),w.data.kind===`tui`&&(0,Y.jsx)(En,{className:`h-4 w-4 text-emerald-500`}),w.data.kind===`coordinator`&&(0,Y.jsx)(wr,{className:`h-4 w-4 text-purple-500`}),w.data.kind===`agent`&&(0,Y.jsx)(j,{className:`h-4 w-4 text-cyan-500`}),w.data.kind===`mailbox`&&(0,Y.jsx)(g,{className:`h-4 w-4 text-yellow-500`}),(0,Y.jsx)(`span`,{className:`text-sm font-bold text-foreground`,children:w.data.label})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[w.data.sessionId&&(0,Y.jsx)(`button`,{type:`button`,title:e(`activity:office.openFullView`),onClick:()=>D({sessionId:w.data.sessionId,label:w.data.label}),className:`text-muted-foreground hover:text-primary`,children:(0,Y.jsx)(We,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(`button`,{onClick:he,className:`text-muted-foreground hover:text-foreground text-lg leading-none`,children:`×`})]})]}),(()=>{let t=w.data,n=Date.now(),r=({k:e,v:t,accent:n})=>(0,Y.jsxs)(`div`,{className:`flex justify-between gap-3`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:e}),(0,Y.jsx)(`span`,{className:X(`font-mono truncate text-right`,n??`text-foreground/80`),children:t})]}),i=t.kind===`agent`,a=t.kind===`webui`||t.kind===`tui`||t.kind===`repl`,o=(t.tokensIn||0)+(t.tokensOut||0),c=Mg(t.ctxPct);return(0,Y.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,Y.jsx)(r,{k:`Status`,v:String(t.status).toUpperCase(),accent:X(t.status===`active`&&`text-emerald-600 dark:text-emerald-400`,t.status===`streaming`&&`text-blue-600 dark:text-blue-400`,t.status===`error`&&`text-destructive`,t.status===`idle`&&`text-muted-foreground`,t.status===`offline`&&`text-muted-foreground/50`)}),i&&(0,Y.jsxs)(Y.Fragment,{children:[t.model&&(0,Y.jsx)(r,{k:`Model`,v:wg(t.model),accent:`text-cyan-600 dark:text-cyan-400`}),t.currentTask&&(0,Y.jsx)(r,{k:`Tool`,v:t.currentTask,accent:`text-cyan-600 dark:text-cyan-400`}),(0,Y.jsx)(r,{k:`Iterations`,v:t.iteration||0,accent:`text-cyan-600 dark:text-cyan-400`}),(0,Y.jsx)(r,{k:`Tool calls`,v:t.toolCalls||0,accent:`text-amber-600 dark:text-amber-400`}),(0,Y.jsx)(r,{k:`Tokens in`,v:xg(t.tokensIn)}),(0,Y.jsx)(r,{k:`Tokens out`,v:xg(t.tokensOut)}),(0,Y.jsx)(r,{k:`Tokens total`,v:xg(o)}),c>0&&(0,Y.jsx)(r,{k:`Context`,v:`${c}%`,accent:c>=90?`text-destructive`:c>=70?`text-amber-600 dark:text-amber-400`:`text-foreground/70`}),(0,Y.jsx)(r,{k:`Cost`,v:`$${(t.costUsd||0).toFixed(4)}`,accent:`text-emerald-600 dark:text-emerald-400`}),t.lastActivityAt&&(0,Y.jsx)(r,{k:`Last seen`,v:Sg(t.lastActivityAt,n),accent:`text-muted-foreground`}),(0,Y.jsx)(`div`,{className:`pt-2`,children:(0,Y.jsx)(Xd,{entries:L,agentName:t.label,compact:!0,maxHeightClassName:`max-h-64`})})]}),a&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(r,{k:`Surface`,v:Og(t.kind),accent:`text-foreground/80`}),t.branch&&(0,Y.jsx)(r,{k:`Branch`,v:`⎇ ${t.branch}`,accent:`text-foreground/70`}),t.pid!=null&&(0,Y.jsx)(r,{k:`PID`,v:t.pid}),t.workingDir&&(0,Y.jsx)(r,{k:`Dir`,v:t.workingDir,accent:`text-muted-foreground`}),(0,Y.jsx)(r,{k:`Agents`,v:t.agentCount??0,accent:`text-cyan-600 dark:text-cyan-400`}),t.startedAt&&(0,Y.jsx)(r,{k:`Uptime`,v:Cg(t.startedAt,n),accent:`text-foreground/70`})]}),t.kind===`mailbox`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(r,{k:`Total messages`,v:t.messageCount||0,accent:`text-amber-600 dark:text-amber-400`}),(0,Y.jsx)(r,{k:`Unread`,v:t.unreadCount||0,accent:`text-amber-600 dark:text-amber-400`}),s.length>0&&(0,Y.jsxs)(`div`,{className:`mt-1 space-y-1 border-t border-border pt-2`,children:[(0,Y.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:e(`activity:office.recent`)}),[...s].sort((e,t)=>Date.parse(t.timestamp)-Date.parse(e.timestamp)).slice(0,6).map(t=>(0,Y.jsxs)(`div`,{className:`flex items-start gap-1.5 text-[10px]`,children:[(0,Y.jsx)(`span`,{className:X(`mt-1 h-1.5 w-1.5 shrink-0 rounded-full`,!t.completed&&(t.readByCount??0)===0?`bg-amber-500`:t.completed?`bg-emerald-500`:`bg-muted`)}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`truncate text-foreground/80`,children:t.subject||e(`activity:office.noSubject`)}),(0,Y.jsxs)(`div`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:[t.from,` → `,t.to,` · `,Sg(t.timestamp,n)]})]})]},t.id))]})]}),t.kind===`coordinator`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(r,{k:`Connections`,v:t.connections||0,accent:`text-purple-600 dark:text-purple-400`}),(0,Y.jsx)(r,{k:`Iterations`,v:t.iteration||0,accent:`text-purple-600 dark:text-purple-400`})]}),(i||a)&&t.sessionId&&(0,Y.jsx)(`div`,{className:`mt-2 border-t border-border pt-2 h-72`,children:(0,Y.jsx)(bg,{sessionId:t.sessionId})})]})})()]}),E&&(0,Y.jsxs)(`div`,{className:`absolute inset-y-0 right-0 z-30 flex w-[min(680px,92%)] flex-col border-l border-border bg-background shadow-2xl`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-4 py-2.5 shrink-0 bg-card`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Y.jsx)(j,{className:`h-4 w-4 text-primary shrink-0`}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`truncate text-sm font-bold text-foreground`,children:E.label}),(0,Y.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:e(`activity:office.fullOperationStream`)})]})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>D(null),title:e(`activity:office.closeEsc`),className:`text-muted-foreground hover:text-foreground text-xl leading-none shrink-0`,children:`×`})]}),(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 p-4`,children:(0,Y.jsx)(bg,{sessionId:E.sessionId,limit:500})})]})]})}function Jg(){return(0,Y.jsx)(Zt,{children:(0,Y.jsx)(qg,{})})}var Yg={btw:{label:`btw`,titleKey:`btwTitle`,tone:`bg-sky-500/10 text-sky-700 dark:text-sky-300 border-sky-500/30`},steer:{label:`steer`,titleKey:`steerTitle`,tone:`bg-amber-500/10 text-amber-700 dark:text-amber-300 border-amber-500/30`},queue:{label:`queue`,titleKey:`queueTitle`,tone:`bg-indigo-500/10 text-indigo-700 dark:text-indigo-300 border-indigo-500/30`}};function Xg({open:e,onClose:t,className:n}){let{t:r}=V(),i=G(e=>e.queue),a=G(e=>e.removeQueued),o=G(e=>e.clearQueue),[c,l]=(0,U.useState)(`oldest`),u=(0,U.useCallback)(e=>{a(e)},[a]),d=(0,U.useMemo)(()=>{let e=i.map((e,t)=>({item:e,sourceIdx:t}));return e.sort((e,t)=>c===`newest`?t.item.addedAt-e.item.addedAt:e.item.addedAt-t.item.addedAt),e},[i,c]);return e?(0,Y.jsx)(`div`,{className:X(`fixed inset-0 z-50 flex items-start justify-center pt-[10dvh] bg-black/40 backdrop-blur-sm`,n),onClick:e=>{e.target===e.currentTarget&&t()},children:(0,Y.jsxs)(`div`,{className:`flex max-h-[70dvh] min-h-0 w-full max-w-lg flex-col rounded-xl border bg-card shadow-2xl animate-in fade-in zoom-in-95`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,Y.jsx)(`span`,{className:`flex items-center justify-center w-8 h-8 rounded-lg bg-indigo-500/10 text-indigo-600 dark:text-indigo-400`,children:(0,Y.jsx)(s,{className:`h-4 w-4`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold`,children:r(`activity:queue.heading`)}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:r(`activity:queue.subtitle`,{count:i.length})})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>l(e=>e===`newest`?`oldest`:`newest`),className:X(`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs transition-colors font-medium`,`text-muted-foreground hover:bg-muted hover:text-foreground`),title:r(c===`newest`?`activity:queue.sortNewestTitle`:`activity:queue.sortOldestTitle`),"data-testid":`queue-sort-toggle`,children:[c===`newest`?(0,Y.jsx)(Nt,{className:`h-3 w-3`}):(0,Y.jsx)(Fr,{className:`h-3 w-3`}),r(c===`newest`?`activity:queue.newest`:`activity:queue.oldest`)]}),i.length>0&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>o(),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs text-destructive hover:bg-destructive/10 transition-colors font-medium`,title:r(`activity:queue.clearTitle`),"data-testid":`queue-clear-all`,children:[(0,Y.jsx)(C,{className:`h-3 w-3`}),r(`activity:queue.clear`)]}),(0,Y.jsx)(`button`,{type:`button`,onClick:t,className:`p-1.5 rounded-md hover:bg-muted transition-colors`,title:r(`activity:queue.closeTitle`),children:(0,Y.jsx)(Xn,{className:`h-4 w-4`})})]})]}),(0,Y.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto`,children:i.length===0?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 gap-3 text-muted-foreground`,children:[(0,Y.jsx)(s,{className:`h-10 w-10 opacity-15`}),(0,Y.jsx)(`p`,{className:`text-sm font-medium`,children:r(`activity:queue.emptyTitle`)}),(0,Y.jsx)(`p`,{className:`text-xs text-center max-w-xs`,children:r(`activity:queue.emptyBody`)})]}):(0,Y.jsx)(`ul`,{className:`divide-y`,"data-testid":`queue-list`,children:d.map(({item:e,sourceIdx:t},n)=>{let i=Yg[e.mode];return(0,Y.jsxs)(`li`,{className:`flex items-start justify-between px-4 py-3 text-xs hover:bg-muted/30 transition-colors gap-3`,"data-testid":`queue-item`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-3 min-w-0 flex-1`,children:[(0,Y.jsxs)(`span`,{className:`mt-1 text-[10px] font-mono text-muted-foreground shrink-0 w-5 text-right tabular-nums`,children:[n+1,`.`]}),(0,Y.jsx)(`span`,{className:X(`shrink-0 inline-flex items-center justify-center text-[10px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded border`,i.tone),title:r(`activity:queue.${i.titleKey}`),"data-testid":`queue-mode-${e.mode}`,children:i.label}),(0,Y.jsx)(`p`,{className:`text-sm text-foreground leading-relaxed min-w-0 break-words`,children:e.text.length>120?`${e.text.slice(0,117)}…`:e.text})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>u(t),className:`ml-1 p-1.5 rounded-md shrink-0 hover:bg-destructive/10 hover:text-destructive transition-colors`,title:r(`activity:queue.removeTitle`),"data-testid":`queue-remove-${t}`,children:(0,Y.jsx)(Xn,{className:`h-3.5 w-3.5`})})]},`${e.addedAt}-${t}`)})})}),i.length>0&&(0,Y.jsx)(`div`,{className:`px-4 py-2.5 border-t shrink-0`,children:(0,Y.jsx)(`p`,{className:`text-[10px] text-muted-foreground text-center`,children:r(`activity:queue.footer`)})})]})}):null}function Zg(e,t,n,r,i){let a=[];for(let n of e){let e=t[n.id]??[];for(let t of e)a.push({provider:n.id,model:t.id,modelName:t.name||t.id,contextWindow:t.contextWindow,isCurrent:n.id===r&&t.id===i})}let o=n.toLowerCase().trim();return(o?a.filter(e=>e.provider.toLowerCase().includes(o)||e.model.toLowerCase().includes(o)||e.modelName.toLowerCase().includes(o)):a).sort((e,t)=>e.isCurrent===t.isCurrent?e.provider.localeCompare(t.provider)||e.model.localeCompare(t.model):e.isCurrent?-1:1)}function Qg(){let{t:e}=V(),t=J(e=>e.modelSwitcherOpen),n=J(e=>e.setModelSwitcherOpen),[r,i]=(0,U.useState)(``),[a,o]=(0,U.useState)(0),[s,c]=(0,U.useState)([]),[l,u]=(0,U.useState)({}),d=(0,U.useRef)(null),f=K(e=>e.wsUrl),p=K(e=>e.provider),m=K(e=>e.model),h=J(e=>e.paletteOpen),{listSavedProviders:g,listProviderModels:_,switchModel:v}=sd();(0,U.useEffect)(()=>{let e=e=>{if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`m`&&!e.shiftKey&&!e.altKey){if(h)return;e.preventDefault(),n(!t);return}e.key===`Escape`&&t&&(e.preventDefault(),n(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,h]),(0,U.useEffect)(()=>{let e=W(f),t=e.on(`providers.saved`,e=>{let t=e.payload;c(t.providers??[])}),n=e.on(`provider.models`,e=>{let t=e.payload;u(e=>({...e,[t.provider]:t.models}))});return()=>{t(),n()}},[f]),(0,U.useEffect)(()=>{t&&(i(``),o(0),g(),requestAnimationFrame(()=>d.current?.focus()))},[t,g]),(0,U.useEffect)(()=>{if(t)for(let e of s)l[e.id]||_(e.id)},[t,s,l,_]);let y=(0,U.useMemo)(()=>Zg(s,l,r,p,m),[s,l,r,p,m]);(0,U.useEffect)(()=>{a>=y.length&&o(0)},[y.length,a]);let b=e=>{let t=y[e];t&&(v(t.provider,t.model),n(!1))};return t?(0,Y.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center bg-background/60 backdrop-blur-sm pt-[15dvh]`,onClick:e=>{e.target===e.currentTarget&&n(!1)},onKeyDown:e=>{e.key===`Escape`&&n(!1)},children:(0,Y.jsxs)(`div`,{className:`w-full max-w-xl rounded-xl border bg-popover shadow-2xl overflow-hidden`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-3 py-2`,children:[(0,Y.jsx)(le,{className:`h-4 w-4 text-muted-foreground`}),(0,Y.jsx)(`input`,{ref:d,value:r,onChange:e=>{i(e.target.value),o(0)},onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),o(e=>Math.min(y.length-1,e+1))):e.key===`ArrowUp`?(e.preventDefault(),o(e=>Math.max(0,e-1))):e.key===`Enter`?(e.preventDefault(),b(a)):e.key===`Escape`&&(e.preventDefault(),n(!1))},placeholder:e(`activity:modelSwitcher.filterPlaceholder`),className:`flex-1 bg-transparent outline-none text-sm placeholder:text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground font-mono`,children:`↑↓ · Enter · Esc`})]}),(0,Y.jsx)(`div`,{className:`max-h-[50dvh] overflow-y-auto py-1`,children:y.length===0?(0,Y.jsx)(`div`,{className:`px-4 py-8 text-center text-sm text-muted-foreground`,children:s.length===0?e(`activity:modelSwitcher.noSavedProviders`):e(`activity:model.loading`)}):y.map((t,n)=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>b(n),onMouseEnter:()=>o(n),className:X(`w-full flex items-center gap-3 px-3 py-2 text-left text-sm transition-colors`,n===a?`bg-accent text-accent-foreground`:`hover:bg-accent/40`,t.isCurrent&&`font-medium`),children:[(0,Y.jsx)(wr,{className:X(`h-4 w-4 shrink-0`,t.isCurrent?`text-primary`:`text-muted-foreground`)}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`truncate`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:t.provider}),(0,Y.jsx)(`span`,{className:`mx-1 text-muted-foreground/40`,children:`·`}),(0,Y.jsx)(`span`,{children:t.modelName})]}),t.contextWindow&&(0,Y.jsxs)(`div`,{className:`text-[10px] text-muted-foreground font-mono`,children:[t.model,` · ctx `,t.contextWindow.toLocaleString()]})]}),t.isCurrent?(0,Y.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-primary font-semibold`,children:e(`activity:modelSwitcher.active`)}):(0,Y.jsx)(it,{className:`h-3.5 w-3.5 text-muted-foreground opacity-0 group-hover:opacity-100`})]},`${t.provider}:${t.model}`))})]})}):null}function $g(){let e=q(e=>e.session),{t}=V(),n=q.getState().session?.id,r=q(e=>e.projectName),i=q(e=>e.cwd),a=q(e=>e.mode),o=q(e=>e.contextMode),s=q(e=>e.lastVisitedAt),c=G(e=>e.messages),l=G(e=>e.queue.length),u=G(e=>e.boundSessionId),f=J(e=>e.currentView),p=J(e=>e.dockSection),[m,h]=(0,U.useState)([]),g=(0,U.useMemo)(()=>{if(typeof window>`u`)return 0;let e=0;for(let t of[`wrongstack-session`,`wrongstack-chat`,`wrongstack-ui`,`wrongstack-config`]){let n=window.localStorage.getItem(t);typeof n==`string`&&(e+=n.length)}return e},[c.length]),_=typeof window<`u`&&!!window.__wrongstackSessionRehydrated,v=typeof window<`u`&&!!window.__wrongstackChatRehydrated;function y(e,t){h(n=>[{ts:Date.now(),note:e,ok:t},...n].slice(0,20))}function b(){y(t(`activity:refresh.simulatedF5`),!0)}let x=u!==null&&n!==void 0?u!==n:!1;return(0,Y.jsx)(`div`,{className:`h-full min-h-0 min-w-0 flex-1 overflow-y-auto bg-background p-6`,children:(0,Y.jsxs)(`div`,{className:`max-w-5xl mx-auto space-y-6`,children:[(0,Y.jsxs)(`header`,{className:`flex items-start justify-between`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`h1`,{className:`text-2xl font-bold flex items-center gap-2`,children:[(0,Y.jsx)(xt,{className:`w-7 h-7 text-primary`}),t(`activity:refresh.heading`)]}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:t(`activity:refresh.subtitle`)})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:b,className:`px-3 py-1.5 bg-primary text-primary-foreground rounded-lg text-sm font-medium hover:opacity-90`,children:t(`activity:refresh.recordProbe`)})]}),(0,Y.jsxs)(`section`,{className:`space-y-3`,children:[(0,Y.jsxs)(`h2`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,Y.jsx)($n,{className:`w-5 h-5`}),t(`activity:refresh.latestSession`)]}),(0,Y.jsx)(e_,{label:t(`activity:refresh.restoredLocal`),ok:_,extra:n?t(`activity:refresh.sessionIdExtra`,{id:n}):t(`activity:refresh.noSessionYet`)}),(0,Y.jsx)(e_,{label:t(`activity:refresh.activePointer`),ok:!!e?.id,extra:e?n_(e):`null`}),(0,Y.jsx)(e_,{label:t(`activity:refresh.lastVisited`),ok:s>0,extra:s>0?new Date(s).toISOString():t(`activity:refresh.never`)})]}),(0,Y.jsxs)(`section`,{className:`space-y-3`,children:[(0,Y.jsxs)(`h2`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,Y.jsx)(dn,{className:`w-5 h-5`}),t(`activity:refresh.persistedEnv`)]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,Y.jsx)(t_,{label:`projectName`,value:r||`∅`}),(0,Y.jsx)(t_,{label:`cwd`,value:i||`∅`,mono:!0}),(0,Y.jsx)(t_,{label:`mode`,value:a,mono:!0}),(0,Y.jsx)(t_,{label:`contextMode`,value:o,mono:!0})]})]}),(0,Y.jsxs)(`section`,{className:`space-y-3`,children:[(0,Y.jsxs)(`h2`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,Y.jsx)(d,{className:`w-5 h-5`}),t(`activity:refresh.transcriptRehydrate`)]}),(0,Y.jsx)(e_,{label:t(`activity:refresh.localTranscript`),ok:v&&(c.length>0||u===null),extra:c.length===0?t(`activity:refresh.noMessages`):t(`activity:refresh.messagesExtra`,{count:c.length,queued:l})}),(0,Y.jsx)(e_,{label:t(`activity:refresh.noBleed`),ok:!x,extra:x?t(`activity:refresh.bleedExtra`,{bound:u??`∅`,active:n??`∅`}):t(`activity:refresh.transcriptBinds`),warn:x}),c.length>0&&(0,Y.jsxs)(`div`,{className:`border rounded-lg p-3 bg-muted/40 text-xs font-mono space-y-1`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`first:`}),` `,r_(c[0])]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`last:`}),` `,r_(c[c.length-1]??c[0])]})]})]}),(0,Y.jsxs)(`section`,{className:`space-y-3`,children:[(0,Y.jsxs)(`h2`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,Y.jsx)(pe,{className:`w-5 h-5`}),t(`activity:refresh.uiWorkspace`)]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,Y.jsx)(t_,{label:`currentView`,value:f,mono:!0}),(0,Y.jsx)(t_,{label:`dockSection`,value:p??t(`activity:refresh.noneValue`),mono:!0})]}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`activity:refresh.payloadSize`,{count:g})})]}),(0,Y.jsxs)(`section`,{className:`space-y-2`,children:[(0,Y.jsx)(`h2`,{className:`text-lg font-semibold`,children:t(`activity:refresh.probeLog`)}),m.length===0?(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`activity:refresh.noProbes`)}):(0,Y.jsx)(`ul`,{className:`space-y-1 text-xs font-mono`,children:m.map((e,t)=>(0,Y.jsxs)(`li`,{className:`flex items-center gap-2`,children:[e.ok?(0,Y.jsx)(rn,{className:`w-4 h-4 text-green-500 shrink-0`}):(0,Y.jsx)(gt,{className:`w-4 h-4 text-amber-500 shrink-0`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:new Date(e.ts).toLocaleTimeString()}),(0,Y.jsx)(`span`,{children:e.note})]},`${e.ts}-${t}`))})]})]})})}function e_({label:e,extra:t,ok:n,warn:r}){return(0,Y.jsxs)(`div`,{className:`border rounded-lg px-3 py-2 ${r?`border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300`:n?`border-green-500/40 bg-green-500/10 text-green-700 dark:text-green-300`:`border-border bg-muted/40 text-muted-foreground`}`,children:[(0,Y.jsxs)(`div`,{className:`text-xs font-medium flex items-center gap-2`,children:[n&&!r?(0,Y.jsx)(rn,{className:`w-4 h-4`}):(0,Y.jsx)(gt,{className:`w-4 h-4`}),e]}),(0,Y.jsx)(`div`,{className:`text-xs font-mono mt-1 break-all`,children:t})]})}function t_({label:e,value:t,mono:n}){return(0,Y.jsxs)(`div`,{className:`border rounded-lg p-3 bg-card`,children:[(0,Y.jsx)(`p`,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:e}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm break-all `+(n?`font-mono`:`font-medium`),children:t})]})}function n_(e){let t=e.title?.trim();return t?`${e.id} — "${t}" (${e.provider}/${e.model})`:`${e.id} (${e.provider}/${e.model})`}function r_(e){let t=(e.content??``).trim().replace(/\s+/g,` `);return`[${e.role}] ${t.length>100?`${t.slice(0,99)}…`:t}`}function i_(e){let t=K(e=>e.wsUrl),{listSavedProviders:n,listProviderModels:r}=sd(),[i,a]=(0,U.useState)([]),[o,s]=(0,U.useState)({});return(0,U.useEffect)(()=>{let e=W(t),n=e.on(`providers.saved`,e=>{let t=e.payload;a((t.providers??[]).map(e=>e.id))}),r=e.on(`provider.models`,e=>{let t=e.payload;s(e=>({...e,[t.provider]:t.models??[]}))});return()=>{n(),r()}},[t]),(0,U.useEffect)(()=>{e&&n()},[e,n]),(0,U.useEffect)(()=>{if(e)for(let e of i)o[e]||r(e)},[e,i,o,r]),(0,U.useMemo)(()=>{let e=[];for(let t of i)for(let n of o[t]??[])e.push({provider:t,model:n.id,label:n.name??n.id,description:n.description,contextWindow:n.contextWindow});return e},[i,o])}var a_={pending:{label:`Pending`,icon:Xe,text:`text-slate-500 dark:text-slate-400`,ring:`border-slate-400/50 bg-slate-400/10 dark:border-slate-600/50 dark:bg-slate-700/20`,dot:`bg-slate-500`,hex:`#64748b`},queued:{label:`Ready`,icon:Xe,text:`text-cyan-600 dark:text-cyan-300`,ring:`border-cyan-500/50 bg-cyan-500/10`,dot:`bg-cyan-400`,hex:`#22d3ee`},in_progress:{label:`Running`,icon:B,spin:!0,text:`text-amber-600 dark:text-amber-300`,ring:`border-amber-400/60 bg-amber-500/10`,dot:`bg-amber-400`,hex:`#fbbf24`},blocked:{label:`Blocked`,icon:Xe,text:`text-fuchsia-600 dark:text-fuchsia-300`,ring:`border-fuchsia-500/50 bg-fuchsia-500/10`,dot:`bg-fuchsia-400`,hex:`#e879f9`},review:{label:`Review`,icon:Xe,text:`text-sky-600 dark:text-sky-300`,ring:`border-sky-500/50 bg-sky-500/10`,dot:`bg-sky-400`,hex:`#38bdf8`},failed:{label:`Failed`,icon:Xn,text:`text-red-600 dark:text-red-300`,ring:`border-red-500/60 bg-red-500/10`,dot:`bg-red-400`,hex:`#f87171`},completed:{label:`Done`,icon:z,text:`text-emerald-600 dark:text-emerald-300`,ring:`border-emerald-500/55 bg-emerald-500/10`,dot:`bg-emerald-400`,hex:`#34d399`},cancelled:{label:`Cancelled`,icon:Be,text:`text-slate-500 dark:text-slate-400`,ring:`border-slate-400/50 bg-slate-400/10 dark:border-slate-500/50 dark:bg-slate-600/20`,dot:`bg-slate-500`,hex:`#94a3b8`}};function o_(e){return a_[e]??a_.pending}var s_={critical:{text:`text-red-600 dark:text-red-400`,chip:`bg-red-500/20 text-red-600 dark:text-red-300`},high:{text:`text-amber-600 dark:text-amber-400`,chip:`bg-amber-500/20 text-amber-600 dark:text-amber-300`},medium:{text:`text-cyan-600 dark:text-cyan-400`,chip:`bg-cyan-500/15 text-cyan-600 dark:text-cyan-300`},low:{text:`text-slate-500 dark:text-slate-400`,chip:`bg-slate-400/20 text-slate-600 dark:bg-slate-600/30 dark:text-slate-400`}};function c_(e){return s_[e]??s_.medium}var l_={running:`border-sky-500/40 bg-sky-500/10 text-sky-600 dark:text-sky-300`,paused:`border-amber-500/40 bg-amber-500/10 text-amber-600 dark:text-amber-300`,stopped:`border-zinc-500/40 bg-zinc-500/10 text-zinc-600 dark:text-zinc-300`,completed:`border-emerald-500/40 bg-emerald-500/10 text-emerald-600 dark:text-emerald-300`,failed:`border-red-500/40 bg-red-500/10 text-red-600 dark:text-red-300`,deadlocked:`border-rose-500/40 bg-rose-500/10 text-rose-600 dark:text-rose-300`,idle:`border-border bg-muted text-muted-foreground`},u_=[`bg-amber-500`,`bg-sky-500`,`bg-violet-500`,`bg-emerald-500`,`bg-rose-500`,`bg-cyan-500`,`bg-fuchsia-500`],d_={started:{icon:kt,color:`text-amber-400`},completed:{icon:z,color:`text-emerald-400`},failed:{icon:Xn,color:`text-red-400`},retrying:{icon:Le,color:`text-orange-400`},wave:{icon:nr,color:`text-violet-400`},deadlock:{icon:gt,color:`text-rose-400`},verification_failed:{icon:te,color:`text-red-400`},conflict:{icon:st,color:`text-amber-400`},split:{icon:_e,color:`text-sky-400`},supervisor:{icon:Me,color:`text-fuchsia-400`}};function f_(e){let t=e.trim().split(/\s+/);return((t[0]?.[0]??``)+(t[1]?.[0]??``)).toUpperCase()||`·`}function p_(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?t%60?`${n}m ${t%60}s`:`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function m_(e,t){let n=Math.max(0,Math.floor((t-e)/1e3));if(n<60)return`${n}s`;let r=Math.floor(n/60);return r<60?`${r}m`:`${Math.floor(r/60)}h`}function h_({feed:e,now:t}){let{t:n}=V();return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border px-3 py-2 text-xs font-semibold text-foreground`,children:[(0,Y.jsx)($n,{className:`h-3.5 w-3.5 text-orange-500 dark:text-orange-400`}),n(`activity:sdd.activityHeading`)]}),(0,Y.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 space-y-1 overflow-auto p-2`,children:e.length===0?(0,Y.jsx)(`p`,{className:`px-1 pt-4 text-center text-[11px] text-muted-foreground`,children:n(`activity:sdd.feedEmpty`)}):e.map((e,n)=>{let r=d_[e.kind]??d_.started,i=r.icon;return(0,Y.jsxs)(`div`,{className:X(`sdd-rise flex items-start gap-2 rounded-md px-2 py-1.5 text-[11px]`,n===0?`bg-muted`:`hover:bg-muted`),children:[(0,Y.jsx)(i,{className:X(`mt-0.5 h-3.5 w-3.5 shrink-0`,r.color)}),(0,Y.jsx)(`span`,{className:`flex-1 leading-snug text-foreground`,children:e.text}),(0,Y.jsx)(`span`,{className:`shrink-0 tabular-nums text-[10px] text-muted-foreground`,children:m_(e.ts,t)})]},`${e.ts}-${n}`)})})]})}function g_({open:e,onOpenChange:t,snapshot:n,busy:r,onConfirm:i}){let{t:a}=V(),o=n?.mergedCommits?.length??0,s=n?.baseBranch,[c,l]=(0,U.useState)(!1);(0,U.useEffect)(()=>{e&&l(!1)},[e]);let u=n?.status===`running`||n?.status===`paused`,d=(0,U.useMemo)(()=>{let e=new Set;for(let t of n?.tasks??[])t.worktreeBranch&&e.add(t.worktreeBranch);return e.size},[n?.tasks]),f=(0,U.useMemo)(()=>{let e=new Set;for(let t of n?.tasks??[])t.displayStatus===`in_progress`&&t.agentName&&e.add(t.agentName);return e.size},[n?.tasks]);return(0,Y.jsx)(bf,{open:e,onOpenChange:e=>!r&&t(e),children:(0,Y.jsxs)(Cf,{className:`sm:max-w-lg border-red-500/50`,children:[(0,Y.jsxs)(wf,{children:[(0,Y.jsxs)(Ef,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(C,{className:`h-5 w-5 text-red-500`}),a(`activity:sdd.destroyTitle`)]}),(0,Y.jsx)(Df,{children:a(`activity:sdd.destroyDesc`)})]}),(0,Y.jsxs)(`ul`,{className:`space-y-1.5 py-1 text-sm`,children:[u&&(0,Y.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,Y.jsx)(`span`,{className:`mt-0.5 text-red-500`,children:`■`}),(0,Y.jsx)(`span`,{children:f>0?a(`activity:sdd.stopRunAgents`,{count:f}):a(`activity:sdd.stopRun`)})]}),(0,Y.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,Y.jsx)(`span`,{className:`mt-0.5 text-red-500`,children:`■`}),(0,Y.jsx)(`span`,{children:d>0?a(`activity:sdd.removeWorktreesCount`,{count:d}):a(`activity:sdd.removeWorktreesAll`)})]}),(0,Y.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,Y.jsx)(`span`,{className:`mt-0.5 text-red-500`,children:`■`}),(0,Y.jsx)(`span`,{children:a(`activity:sdd.deleteArtifacts`)})]})]}),o>0&&(0,Y.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md border border-amber-500/30 bg-amber-500/5 p-2.5 text-sm`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked),className:`mt-0.5 h-4 w-4 accent-amber-500`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:a(`activity:sdd.revertMerged`,{count:o})}),` `,`on `,(0,Y.jsx)(`code`,{className:`text-xs`,children:s??a(`activity:sdd.baseBranchFallback`)}),(0,Y.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:a(`activity:sdd.revertHint`)})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md bg-muted/50 p-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(gt,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-amber-500`}),a(o>0&&!c?`activity:sdd.noteLeaveMerged`:`activity:sdd.noteAbandon`)]}),(0,Y.jsxs)(Tf,{className:`gap-2 sm:gap-2`,children:[(0,Y.jsx)($,{variant:`outline`,size:`sm`,disabled:r,onClick:()=>t(!1),children:a(`common:action.cancel`)}),(0,Y.jsx)($,{size:`sm`,disabled:r,onClick:()=>i(c),className:`bg-red-600 text-white hover:bg-red-700`,children:r?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(B,{className:`mr-1 h-3.5 w-3.5 animate-spin`}),` `,a(`activity:sdd.destroying`)]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(C,{className:`mr-1 h-3.5 w-3.5`}),` `,a(`activity:sdd.destroyAll`)]})})]})]})})}var __=300,v_=128,y_=240,b_={pending:{ring:`border-slate-600/50`,chip:`bg-slate-700/40 text-slate-400`,dot:`bg-slate-500`},queued:{ring:`border-cyan-500/50`,chip:`bg-cyan-500/15 text-cyan-300`,dot:`bg-cyan-400`},in_progress:{ring:`border-amber-400/70`,chip:`bg-amber-500/20 text-amber-300`,dot:`bg-amber-400`},blocked:{ring:`border-fuchsia-500/50`,chip:`bg-fuchsia-500/15 text-fuchsia-300`,dot:`bg-fuchsia-400`},review:{ring:`border-sky-500/50`,chip:`bg-sky-500/15 text-sky-300`,dot:`bg-sky-400`},failed:{ring:`border-red-500/60`,chip:`bg-red-500/15 text-red-300`,dot:`bg-red-400`},completed:{ring:`border-emerald-500/55`,chip:`bg-emerald-500/15 text-emerald-300`,dot:`bg-emerald-400`},cancelled:{ring:`border-slate-500/50`,chip:`bg-slate-600/25 text-slate-400`,dot:`bg-slate-500`}};function x_({data:e}){let t=e.task,{t:n}=V(),r=b_[t.displayStatus],i=t.displayStatus===`in_progress`,a=t.displayStatus===`completed`?z:t.displayStatus===`failed`?Xn:i?B:Xe;return(0,Y.jsxs)(`div`,{className:X(`sdd-node-enter group relative rounded-lg border bg-[#0e1117]/95 px-2.5 py-2 text-left shadow-lg backdrop-blur`,r.ring,i&&`sdd-node-running`,t.displayStatus===`completed`&&`sdd-node-complete`,t.displayStatus===`failed`&&`sdd-node-failed`,e.onTaskClick&&`cursor-pointer hover:brightness-125`),style:{width:y_,animationDelay:`${Math.min(e.index*45,600)}ms`},onClick:()=>e.onTaskClick?.(t.id),children:[(0,Y.jsx)(Dn,{type:`target`,position:xr.Left,isConnectable:!1,className:`!h-1.5 !w-1.5 !border-0 !bg-slate-500`}),(0,Y.jsx)(Dn,{type:`source`,position:xr.Right,isConnectable:!1,className:`!h-1.5 !w-1.5 !border-0 !bg-slate-500`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(a,{className:X(`h-3.5 w-3.5`,i&&`animate-spin`,r.chip.split(` `).find(e=>e.startsWith(`text`)))}),(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-slate-500`,children:t.shortId}),(0,Y.jsx)(`span`,{className:X(`font-mono text-[10px] font-bold uppercase`,c_(t.priority).text),children:t.priority[0]}),(0,Y.jsx)(`span`,{className:X(`ml-auto rounded px-1.5 py-px text-[9px] font-medium`,r.chip),children:n(`activity:sdd.status.${t.displayStatus}`)})]}),(0,Y.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[11px] leading-snug text-slate-200`,children:t.title}),(t.agentName||t.worktreeBranch)&&(0,Y.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[t.agentName&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(`span`,{className:X(`flex h-4 w-4 items-center justify-center rounded-full text-[8px] font-bold text-white`,i?`bg-amber-500 sdd-agent-live`:`bg-slate-600`),children:f_(t.agentName)}),(0,Y.jsx)(`span`,{className:`max-w-[88px] truncate text-[10px] text-slate-300`,children:t.agentName})]}),t.retries?(0,Y.jsxs)(`span`,{className:`flex items-center gap-0.5 text-[9px] text-red-400`,children:[(0,Y.jsx)(Le,{className:`h-2.5 w-2.5`}),t.retries]}):null,t.worktreeBranch&&(0,Y.jsxs)(`span`,{className:`ml-auto flex items-center gap-0.5 text-[9px] text-slate-500`,title:t.worktreeBranch,children:[(0,Y.jsx)(de,{className:`h-2.5 w-2.5`}),(0,Y.jsx)(`span`,{className:`max-w-[70px] truncate`,children:t.worktreeBranch.replace(/^.*\//,``)})]})]})]})}function S_({data:e}){return(0,Y.jsx)(`div`,{className:`whitespace-nowrap text-[11px] font-bold uppercase tracking-wider text-slate-500`,children:e.label})}var C_={task:x_,colLabel:S_};function w_(e,t,n){let r=new Map(e.map(e=>[e.shortId,e])),i=[],a=0;t.forEach((e,t)=>{i.push({id:`__col_${t}`,position:{x:t*__,y:-52},data:{label:e.label},draggable:!1,selectable:!1,type:`colLabel`,style:{pointerEvents:`none`}}),e.taskIds.forEach((e,o)=>{let s=r.get(e);s&&i.push({id:s.id,position:{x:t*__,y:o*v_},data:{task:s,index:a++,onTaskClick:n},type:`task`,draggable:!0})})});let o=[];for(let t of e)for(let e of t.deps){let n=r.get(e);if(!n)continue;let i=n.displayStatus===`completed`&&(t.displayStatus===`in_progress`||t.displayStatus===`queued`);o.push({id:`${n.id}->${t.id}`,source:n.id,target:t.id,animated:i,className:i?`sdd-edge-flow`:void 0,style:{stroke:o_(t.displayStatus).hex,strokeWidth:i?2.2:1.4,opacity:t.displayStatus===`pending`?.4:.85}})}return{nodes:i,edges:o}}function T_({tasks:e,columns:t,onTaskClick:n}){let{fitView:r}=St(),{nodes:i,edges:a}=(0,U.useMemo)(()=>w_(e,t,n),[e,t,n]),o=e.length;return(0,U.useEffect)(()=>{let e=setTimeout(()=>r({padding:.18,duration:400}),60);return()=>clearTimeout(e)},[o,r]),(0,Y.jsxs)(Mn,{nodes:i,edges:a,nodeTypes:C_,fitView:!0,fitViewOptions:{padding:.18},minZoom:.2,maxZoom:1.6,proOptions:{hideAttribution:!0},nodesConnectable:!1,elementsSelectable:!!n,children:[(0,Y.jsx)(Dt,{variant:Vn.Dots,gap:22,size:1,color:`#1e293b`}),(0,Y.jsx)(or,{showInteractive:!1,className:`!bottom-2 !left-2`}),(0,Y.jsx)(gr,{pannable:!0,zoomable:!0,nodeStrokeWidth:2,maskColor:`rgba(2,6,23,0.65)`,nodeColor:e=>{let t=e.data?.task?.displayStatus;return t?o_(t).hex:`#334155`},className:`!bottom-2 !right-2 !h-24 !w-40 overflow-hidden rounded-md border border-white/10`})]})}function E_({tasks:e,columns:t,onTaskClick:n}){return(0,Y.jsx)(Zt,{children:(0,Y.jsx)(T_,{tasks:e,columns:t,onTaskClick:n})})}var D_=[{key:`pending`,labelKey:`kanbanBacklog`,accent:`border-slate-600/40`,head:`text-muted-foreground`},{key:`queued`,labelKey:`kanbanReady`,accent:`border-cyan-500/40`,head:`text-cyan-600 dark:text-cyan-300`},{key:`in_progress`,labelKey:`kanbanRunning`,accent:`border-amber-400/50`,head:`text-amber-600 dark:text-amber-300`},{key:`review`,labelKey:`kanbanReview`,accent:`border-sky-500/40`,head:`text-sky-600 dark:text-sky-300`},{key:`failed`,labelKey:`kanbanFailed`,accent:`border-red-500/40`,head:`text-red-600 dark:text-red-300`},{key:`completed`,labelKey:`kanbanDone`,accent:`border-emerald-500/40`,head:`text-emerald-600 dark:text-emerald-300`}];function O_({tasks:e,selectedId:t,onTaskClick:n}){let{t:r}=V(),i=(0,U.useMemo)(()=>{let t=new Map;for(let e of D_)t.set(e.key,[]);for(let n of e){let e=n.displayStatus===`blocked`?`pending`:n.displayStatus===`cancelled`?`failed`:n.displayStatus;(t.get(e)??t.get(`pending`))?.push(n)}return t},[e]);return(0,Y.jsx)(`div`,{className:`flex h-full min-h-0 min-w-0 gap-3 overflow-x-auto p-4`,children:D_.map(e=>{let a=i.get(e.key)??[];return(0,Y.jsxs)(`div`,{className:`flex min-h-0 w-64 shrink-0 flex-col`,children:[(0,Y.jsxs)(`div`,{className:X(`mb-2 flex items-center gap-2 border-b-2 pb-1.5`,e.accent),children:[(0,Y.jsx)(`span`,{className:X(`text-xs font-bold uppercase tracking-wide`,e.head),children:r(`activity:sdd.${e.labelKey}`)}),(0,Y.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 text-[10px] text-muted-foreground`,children:a.length})]}),(0,Y.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto pr-1`,children:[a.map(e=>(0,Y.jsx)(k_,{task:e,selected:e.id===t,onClick:()=>n(e.id)},e.id)),a.length===0&&(0,Y.jsx)(`div`,{className:`rounded-md border border-dashed border-border py-6 text-center text-[10px] text-muted-foreground`,children:r(`activity:sdd.kanbanEmpty`)})]})]},e.key)})})}function k_({task:e,selected:t,onClick:n}){let r=e.displayStatus===`in_progress`;return(0,Y.jsxs)(`button`,{type:`button`,onClick:n,className:X(`sdd-node-enter w-full rounded-lg border bg-card p-2 text-left transition hover:brightness-125`,t?`border-violet-400/70 ring-1 ring-violet-400/40`:`border-border`,r&&`sdd-node-running`,e.displayStatus===`completed`&&`sdd-node-complete`,e.displayStatus===`failed`&&`sdd-node-failed`),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[r&&(0,Y.jsx)(B,{className:`h-3 w-3 animate-spin text-amber-400`}),e.displayStatus===`completed`&&(0,Y.jsx)(z,{className:`h-3 w-3 text-emerald-400`}),e.displayStatus===`failed`&&(0,Y.jsx)(Xn,{className:`h-3 w-3 text-red-400`}),(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.shortId}),(0,Y.jsx)(`span`,{className:X(`ml-auto rounded px-1.5 text-[9px] font-bold uppercase`,c_(e.priority).chip),children:e.priority})]}),(0,Y.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[11px] leading-snug text-foreground`,children:e.title}),(e.agentName||e.worktreeBranch||e.retries)&&(0,Y.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[e.agentName&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(`span`,{className:X(`flex h-4 w-4 items-center justify-center rounded-full text-[8px] font-bold text-white`,r?`bg-amber-500 sdd-agent-live`:`bg-slate-600`),children:f_(e.agentName)}),(0,Y.jsx)(`span`,{className:`max-w-[80px] truncate text-[10px] text-muted-foreground`,children:e.agentName})]}),e.retries?(0,Y.jsxs)(`span`,{className:`flex items-center gap-0.5 text-[9px] text-red-400`,children:[(0,Y.jsx)(Le,{className:`h-2.5 w-2.5`}),e.retries]}):null,e.worktreeBranch&&(0,Y.jsx)(de,{className:`ml-auto h-2.5 w-2.5 text-muted-foreground`})]})]})}function A_({value:e,provider:t,candidates:n,placeholder:r,resetLabel:i,onPick:a,onReset:o,className:s}){let{t:c}=V(),[l,u]=(0,U.useState)(!1),[d,f]=(0,U.useState)(``),p=(0,U.useRef)(null);(0,U.useEffect)(()=>{if(!l)return;let e=e=>{p.current&&!p.current.contains(e.target)&&u(!1)};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[l]);let m=(0,U.useMemo)(()=>{let e=d.trim().toLowerCase();return(e?n.filter(t=>`${t.provider}/${t.model} ${t.label}`.toLowerCase().includes(e)):n).slice(0,60)},[n,d]);return(0,Y.jsxs)(`div`,{ref:p,className:X(`relative`,s),children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>u(e=>!e),className:`flex w-full items-center gap-1.5 rounded-md border border-border bg-muted px-2 py-1.5 text-left text-xs hover:border-violet-500/50`,children:[(0,Y.jsx)(wr,{className:`h-3.5 w-3.5 shrink-0 text-violet-400`}),(0,Y.jsx)(`span`,{className:X(`min-w-0 flex-1 truncate`,e?`text-foreground`:`text-muted-foreground`),children:e?t?`${t}/${e}`:e:r??c(`activity:model.runDefault`)}),(0,Y.jsx)(bn,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),l&&(0,Y.jsxs)(`div`,{className:`sdd-rise absolute z-50 mt-1 max-h-72 w-full min-w-[240px] overflow-hidden rounded-md border border-border bg-popover shadow-xl`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border px-2 py-1.5`,children:[(0,Y.jsx)(`input`,{autoFocus:!0,value:d,onChange:e=>f(e.target.value),placeholder:c(`activity:model.filterPlaceholder`),className:`min-w-0 flex-1 bg-transparent text-xs outline-none placeholder:text-muted-foreground`}),d&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>f(``),className:`text-muted-foreground hover:text-foreground`,children:(0,Y.jsx)(Xn,{className:`h-3 w-3`})})]}),(0,Y.jsxs)(`div`,{className:`max-h-60 overflow-y-auto py-1`,children:[o&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{o(),u(!1)},className:`flex w-full items-center gap-1.5 px-2 py-1.5 text-left text-xs text-muted-foreground hover:bg-muted`,children:[(0,Y.jsx)(Le,{className:`h-3 w-3`}),` `,i??c(`activity:model.useRunDefault`)]}),m.map(n=>{let r=n.model===e&&(!t||n.provider===t);return(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{a(n.model,n.provider),u(!1)},className:X(`flex w-full items-start gap-1.5 px-2 py-1.5 text-left text-xs hover:bg-muted`,r?`text-violet-700 dark:text-violet-200`:`text-foreground`),children:[r?(0,Y.jsx)(z,{className:`mt-0.5 h-3 w-3 shrink-0 text-violet-400`}):(0,Y.jsx)(`span`,{className:`w-3 shrink-0`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate`,children:n.label}),n.description&&(0,Y.jsx)(`span`,{className:`mt-0.5 block truncate text-[10px] text-muted-foreground`,children:n.description})]}),(0,Y.jsx)(`span`,{className:`mt-0.5 shrink-0 font-mono text-[9px] text-muted-foreground`,children:n.provider})]},`${n.provider}/${n.model}`)}),m.length===0&&(0,Y.jsx)(`div`,{className:`px-2 py-3 text-center text-[11px] text-muted-foreground`,children:n.length===0?c(`activity:model.loading`):c(`activity:model.noMatch`)})]})]})]})}function j_({task:e,allTasks:t,feed:n,now:r,modelCandidates:i,defaultModel:a,onClose:o,onRetry:s,onReassign:c,onSetModel:l,onSetVerification:u,onCancel:d,onDelete:f,onSplit:p,onSelectTask:m}){let{t:h}=V(),g=o_(e.displayStatus),_=g.icon,v=e.displayStatus===`in_progress`,y=e.displayStatus===`pending`||e.displayStatus===`blocked`||e.displayStatus===`queued`,[b,x]=(0,U.useState)(!1),[S,w]=(0,U.useState)(``),[T,E]=(0,U.useState)(null),[D,O]=(0,U.useState)(!1),[k,A]=(0,U.useState)(``),[j,M]=(0,U.useState)(!1),[N,P]=(0,U.useState)(e.verificationCommand??``),F=()=>{S.trim()&&(c(e.id,S.trim()),x(!1),w(``))},I=()=>{let t=k.split(`
153
- `).map(e=>e.trim()).filter(Boolean).map(e=>{let[t,...n]=e.split(`::`),r=(t??``).trim();return{title:r,description:n.join(`::`).trim()||r}}).filter(e=>e.title);t.length&&(p(e.id,t),O(!1),A(``))},L=(0,U.useMemo)(()=>new Map(t.map(e=>[e.shortId,e])),[t]),R=(0,U.useMemo)(()=>t.filter(t=>t.deps.includes(e.shortId)),[t,e.shortId]),ee=(0,U.useMemo)(()=>n.filter(t=>t.taskShortId===e.shortId),[n,e.shortId]),te=e.startedAt&&!e.completedAt?p_(r-e.startedAt):e.startedAt&&e.completedAt?p_(e.completedAt-e.startedAt):null;return(0,Y.jsxs)(`div`,{className:`sdd-rise flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3 py-2`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:o,className:`text-muted-foreground hover:text-foreground`,title:h(`activity:sddTask.backTitle`),children:(0,Y.jsx)(et,{className:`h-4 w-4`})}),(0,Y.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.shortId}),(0,Y.jsxs)(`span`,{className:X(`ml-auto flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px]`,g.ring,g.text),children:[(0,Y.jsx)(_,{className:X(`h-3 w-3`,v&&`animate-spin`)}),g.label]})]}),(0,Y.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 space-y-3 overflow-auto p-3`,children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold leading-snug text-foreground`,children:e.title}),e.agentName&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-muted p-2`,children:[(0,Y.jsx)(`span`,{className:X(`flex h-7 w-7 items-center justify-center rounded-full text-[10px] font-bold text-white`,v?`bg-amber-500 sdd-agent-live`:`bg-slate-600`),children:f_(e.agentName)}),(0,Y.jsxs)(`div`,{className:`leading-tight`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-medium text-foreground`,children:e.agentName}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:h(v?`activity:sddTask.workingOn`:`activity:sddTask.assigned`)})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-1.5 text-[11px]`,children:[(0,Y.jsx)(M_,{label:h(`activity:sddTask.metaPriority`),children:(0,Y.jsx)(`span`,{className:X(`font-medium uppercase`,c_(e.priority).text),children:e.priority})}),(0,Y.jsx)(M_,{label:h(`activity:sddTask.metaType`),children:e.type}),te&&(0,Y.jsx)(M_,{label:e.completedAt?h(`activity:sddTask.metaDuration`):h(`activity:sddTask.metaElapsed`),children:(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(Ge,{className:`h-3 w-3 text-muted-foreground`}),te]})}),e.retries?(0,Y.jsx)(M_,{label:h(`activity:sddTask.metaRetries`),children:(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 text-red-400`,children:[(0,Y.jsx)(Le,{className:`h-3 w-3`}),e.retries]})}):null,e.worktreeBranch&&(0,Y.jsx)(M_,{label:h(`activity:sddTask.metaWorktree`),full:!0,children:(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 font-mono text-foreground`,title:e.worktreeBranch,children:[(0,Y.jsx)(de,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.worktreeBranch})]})})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[h(`activity:sddTask.workerModel`),!e.model&&a&&(0,Y.jsxs)(`span`,{className:`font-normal normal-case text-muted-foreground`,children:[`· `,h(`activity:sddTask.runDefault`,{model:a})]})]}),(0,Y.jsx)(A_,{value:e.model,provider:e.provider,candidates:i,placeholder:a?h(`activity:sddTask.runDefaultPlaceholderModel`,{model:a}):h(`activity:sddTask.runDefaultPlaceholder`),onPick:(t,n)=>l(e.id,t,n),onReset:e.model?()=>l(e.id,void 0,void 0):void 0}),e.fallbackModels&&e.fallbackModels.length>0&&(0,Y.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:e.fallbackModels.map((e,t)=>(0,Y.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-[9px] text-muted-foreground`,children:[`↳ `,e]},t))})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[h(`activity:sddTask.verificationCmd`),(0,Y.jsxs)(`span`,{className:`font-normal normal-case text-muted-foreground`,children:[`· `,h(`activity:sddTask.gatesCompletion`)]})]}),j?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`input`,{autoFocus:!0,value:N,onChange:e=>P(e.target.value),onKeyDown:t=>{t.key===`Enter`?(u(e.id,N.trim()||void 0),M(!1)):t.key===`Escape`&&(P(e.verificationCommand??``),M(!1))},placeholder:h(`activity:sddTask.verifyPlaceholder`),className:`w-full rounded border border-border bg-background px-2 py-1 font-mono text-[11px] text-foreground`}),(0,Y.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{u(e.id,N.trim()||void 0),M(!1)},className:`rounded bg-primary px-2 py-0.5 text-[10px] text-primary-foreground hover:opacity-90`,children:h(`common:action.save`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{P(e.verificationCommand??``),M(!1)},className:`rounded bg-muted px-2 py-0.5 text-[10px] text-muted-foreground hover:bg-muted/80`,children:h(`common:action.cancel`)})]})]}):e.verificationCommand?(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(`code`,{className:`flex-1 truncate rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] text-foreground`,children:e.verificationCommand}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>M(!0),className:`rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted/80`,children:h(`common:action.edit`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>u(e.id,void 0),className:`rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted/80`,children:h(`common:action.clear`)})]}):(0,Y.jsx)(`button`,{type:`button`,onClick:()=>M(!0),className:`rounded border border-dashed border-border px-2 py-1 text-[10px] text-muted-foreground hover:bg-muted`,children:h(`activity:sddTask.addVerify`)})]}),e.description&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:h(`activity:sddTask.description`)}),(0,Y.jsx)(`p`,{className:`whitespace-pre-wrap rounded-md bg-muted p-2 text-[11px] leading-relaxed text-foreground`,children:e.description})]}),ee.length>0&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:h(`activity:sddTask.timeline`)}),(0,Y.jsx)(`div`,{className:`space-y-1 border-l border-border pl-2.5`,children:ee.map((e,t)=>(0,Y.jsxs)(`div`,{className:`relative text-[11px] leading-snug text-foreground`,children:[(0,Y.jsx)(`span`,{className:X(`absolute -left-[14px] top-1 h-1.5 w-1.5 rounded-full`,e.kind===`completed`?`bg-emerald-400`:e.kind===`failed`?`bg-red-400`:e.kind===`retrying`?`bg-orange-400`:`bg-amber-400`)}),e.text]},`${e.ts}-${t}`))})]}),e.deps.length>0&&(0,Y.jsx)(N_,{title:h(`activity:sddTask.dependsOn`),shortIds:e.deps,byShort:L,onSelectTask:m}),R.length>0&&(0,Y.jsx)(N_,{title:h(`activity:sddTask.blocks`),shortIds:R.map(e=>e.shortId),byShort:L,onSelectTask:m})]}),(0,Y.jsxs)(`div`,{className:`border-t border-border p-2`,children:[b?(0,Y.jsxs)(`div`,{className:`sdd-rise flex items-center gap-1.5`,children:[(0,Y.jsx)(`input`,{autoFocus:!0,value:S,onChange:e=>w(e.target.value),onKeyDown:e=>{e.key===`Enter`&&F(),e.key===`Escape`&&x(!1)},placeholder:h(`activity:sddTask.newWorkerPlaceholder`),className:`min-w-0 flex-1 rounded-md border border-border bg-background px-2 py-1.5 text-xs outline-none focus:border-violet-500`}),(0,Y.jsx)(`button`,{type:`button`,onClick:F,disabled:!S.trim(),className:`rounded-md bg-violet-500/20 px-2 py-1.5 text-xs font-medium text-violet-700 dark:text-violet-200 hover:bg-violet-500/30 disabled:opacity-40`,children:(0,Y.jsx)(z,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>x(!1),className:`rounded-md bg-muted px-2 py-1.5 text-xs text-muted-foreground hover:bg-muted`,children:(0,Y.jsx)(Xn,{className:`h-3.5 w-3.5`})})]}):T?(0,Y.jsxs)(`div`,{className:`sdd-rise flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`flex-1 text-xs text-foreground`,children:h(T===`stop`?`activity:sddTask.confirmStop`:`activity:sddTask.confirmDelete`)}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{T===`stop`?d(e.id):f(e.id),E(null)},className:`inline-flex items-center gap-1 rounded-md bg-red-500/20 px-2.5 py-1.5 text-xs font-medium text-red-700 dark:text-red-200 hover:bg-red-500/30`,children:[(0,Y.jsx)(z,{className:`h-3.5 w-3.5`}),` `,h(T===`stop`?`common:action.stop`:`common:action.delete`)]}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>E(null),className:`rounded-md bg-muted px-2 py-1.5 text-xs text-muted-foreground hover:bg-muted`,children:(0,Y.jsx)(Xn,{className:`h-3.5 w-3.5`})})]}):(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>s(e.id),title:h(`activity:sddTask.retryTitle`),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-orange-500/15 py-1.5 text-xs font-medium text-orange-600 dark:text-orange-300 hover:bg-orange-500/25`,children:[(0,Y.jsx)(Le,{className:`h-3.5 w-3.5`}),` `,h(`common:action.retry`)]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>x(!0),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-violet-500/15 py-1.5 text-xs font-medium text-violet-600 dark:text-violet-300 hover:bg-violet-500/25`,children:[(0,Y.jsx)(Ke,{className:`h-3.5 w-3.5`}),` `,h(`activity:sddTask.reassign`)]}),v&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>E(`stop`),title:h(`activity:sddTask.stopTitle`),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-red-500/15 py-1.5 text-xs font-medium text-red-600 dark:text-red-300 hover:bg-red-500/25`,children:[(0,Y.jsx)(ae,{className:`h-3.5 w-3.5`}),` `,h(`common:action.stop`)]}),!v&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>O(!0),title:h(`activity:sddTask.splitTitle`),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-sky-500/15 py-1.5 text-xs font-medium text-sky-600 dark:text-sky-300 hover:bg-sky-500/25`,children:[(0,Y.jsx)(_e,{className:`h-3.5 w-3.5`}),` `,h(`activity:sddTask.split`)]}),y&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>E(`delete`),title:h(`activity:sddTask.deleteTitle`),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-red-500/10 py-1.5 text-xs font-medium text-red-600 dark:text-red-300/90 hover:bg-red-500/20`,children:[(0,Y.jsx)(C,{className:`h-3.5 w-3.5`}),` `,h(`common:action.delete`)]})]}),D&&(0,Y.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2`,children:[(0,Y.jsx)(`label`,{className:`text-[11px] text-muted-foreground`,htmlFor:`sdd-split-input`,children:h(`activity:sddTask.splitHint`)}),(0,Y.jsx)(`textarea`,{id:`sdd-split-input`,autoFocus:!0,rows:3,value:k,onChange:e=>A(e.target.value),placeholder:h(`activity:sddTask.splitPlaceholder`),className:`w-full resize-y rounded-md border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-sky-500`}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:I,className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-sky-500/20 py-1.5 text-xs font-medium text-sky-700 dark:text-sky-200 hover:bg-sky-500/30`,children:[(0,Y.jsx)(_e,{className:`h-3.5 w-3.5`}),` `,h(`activity:sddTask.splitInto`)]}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{O(!1),A(``)},className:`rounded-md bg-muted px-2 py-1.5 text-xs text-muted-foreground hover:bg-muted`,children:(0,Y.jsx)(Xn,{className:`h-3.5 w-3.5`})})]})]})]})]})}function M_({label:e,children:t,full:n}){return(0,Y.jsxs)(`div`,{className:X(`rounded-md border border-border bg-muted/50 px-2 py-1`,n&&`col-span-2`),children:[(0,Y.jsx)(`div`,{className:`text-[9px] uppercase tracking-wide text-muted-foreground`,children:e}),(0,Y.jsx)(`div`,{className:`text-foreground`,children:t})]})}function N_({title:e,shortIds:t,byShort:n,onSelectTask:r}){return(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.map(e=>{let t=n.get(e);return(0,Y.jsxs)(`button`,{type:`button`,disabled:!t,onClick:()=>t&&r(t.id),className:`flex items-center gap-1 rounded-full border border-border bg-muted px-2 py-0.5 text-[10px] text-foreground hover:bg-muted disabled:opacity-50`,title:t?.title,children:[(0,Y.jsx)(`span`,{className:X(`h-1.5 w-1.5 rounded-full`,o_(t?.displayStatus??`pending`).dot)}),(0,Y.jsx)(`span`,{className:`font-mono`,children:e})]},e)})})]})}function P_({pct:e}){let t=2*Math.PI*26,n=t-Math.max(0,Math.min(100,e))/100*t;return(0,Y.jsxs)(`div`,{className:`relative h-16 w-16 shrink-0`,children:[(0,Y.jsxs)(`svg`,{viewBox:`0 0 64 64`,className:`h-16 w-16 -rotate-90`,children:[(0,Y.jsx)(`circle`,{cx:`32`,cy:`32`,r:26,fill:`none`,stroke:`hsl(215 28% 22%)`,strokeWidth:`6`}),(0,Y.jsx)(`circle`,{cx:`32`,cy:`32`,r:26,fill:`none`,stroke:`url(#sddgrad)`,strokeWidth:`6`,strokeLinecap:`round`,strokeDasharray:t,strokeDashoffset:n,style:{transition:`stroke-dashoffset 0.6s cubic-bezier(0.16,1,0.3,1)`}}),(0,Y.jsx)(`defs`,{children:(0,Y.jsxs)(`linearGradient`,{id:`sddgrad`,x1:`0`,y1:`0`,x2:`1`,y2:`1`,children:[(0,Y.jsx)(`stop`,{offset:`0%`,stopColor:`#a78bfa`}),(0,Y.jsx)(`stop`,{offset:`100%`,stopColor:`#22d3ee`})]})})]}),(0,Y.jsxs)(`div`,{className:`absolute inset-0 flex items-center justify-center text-sm font-bold text-foreground`,children:[Math.round(e),`%`]})]})}function F_({onClose:e}){let{t}=V(),{client:n}=sd(),r=nc(e=>e.snapshot),i=nc(e=>e.lifecycleResult),a=nc(e=>e.destroying),o=nc(e=>e.setDestroying),s=nc(e=>e.setLifecycleResult),[c,l]=(0,U.useState)(()=>Date.now()),[u,d]=(0,U.useState)(null),[f,p]=(0,U.useState)(`graph`),[m,h]=(0,U.useState)(!1);(0,U.useEffect)(()=>{n?.send?.({type:`sdd.board.get`})},[n]);let g=r&&(r.status===`running`||r.status===`paused`);(0,U.useEffect)(()=>{if(!g)return;let e=setInterval(()=>l(Date.now()),1e3);return l(Date.now()),()=>clearInterval(e)},[g]);let _=(0,U.useCallback)(e=>n?.send?.(e),[n]),v=(0,U.useRef)(null),y=(0,U.useCallback)(e=>{v.current=null,_({type:`sdd.board.destroy`,payload:{revertMerged:e}})},[_]),b=(0,U.useCallback)(e=>{h(!1),s(null),o(!0),g?(_({type:`sdd.board.stop`,payload:{}}),v.current={revertMerged:e,deadline:Date.now()+2e4}):y(e)},[g,_,y,o,s]);(0,U.useEffect)(()=>{let e=v.current;e&&(!g||Date.now()>=e.deadline)&&y(e.revertMerged)},[g,r,y]);let x=(0,U.useCallback)(()=>{s(null),_({type:`sdd.board.cleanup_worktrees`,payload:{}})},[_,s]),S=(0,U.useCallback)(()=>{s(null),_({type:`sdd.board.rollback`,payload:{}})},[_,s]),w=(0,U.useMemo)(()=>(r?.tasks??[]).map(e=>({id:e.id,shortId:e.shortId,title:e.title,displayStatus:e.displayStatus,priority:e.priority,deps:e.deps,agentName:e.agentName,worktreeBranch:e.worktreeBranch})),[r?.tasks]),T=(0,U.useMemo)(()=>{let e=new Map;for(let t of r?.tasks??[])t.displayStatus===`in_progress`&&t.agentName&&e.set(t.agentName,{name:t.agentName,task:t.title});return[...e.values()]},[r?.tasks]),E=(0,U.useCallback)(e=>d(e),[]),D=(0,U.useCallback)(e=>_({type:`sdd.board.retry`,payload:{taskId:e}}),[_]),O=(0,U.useCallback)(()=>_({type:`sdd.board.retry_all_failed`,payload:{}}),[_]),k=(0,U.useCallback)((e,t)=>{let n=t.trim();n&&_({type:`sdd.board.reassign`,payload:{taskId:e,agentName:n}})},[_]),A=(0,U.useCallback)((e,t,n)=>_({type:`sdd.board.set_task_model`,payload:{taskId:e,model:t,provider:n}}),[_]),j=(0,U.useCallback)((e,t)=>_({type:`sdd.board.set_task_verification`,payload:{taskId:e,verificationCommand:t}}),[_]),M=(0,U.useCallback)(e=>_({type:`sdd.board.cancel_task`,payload:{taskId:e}}),[_]),N=(0,U.useCallback)(e=>{_({type:`sdd.board.delete_task`,payload:{taskId:e}}),d(null)},[_]),P=(0,U.useCallback)((e,t)=>{_({type:`sdd.board.split_task`,payload:{taskId:e,subtasks:t}}),d(null)},[_]),F=i_(u!==null),I=(0,U.useMemo)(()=>r?.tasks.find(e=>e.id===u)??null,[r?.tasks,u]),L=r?.progress,R=r?.diagnostics?.deadlockChains??[];return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,Y.jsxs)(`header`,{className:`sdd-sheen shrink-0 border-b border-border px-4 pb-3 pt-2.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)($n,{className:`h-5 w-5 text-orange-400`}),(0,Y.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:r?.title??t(`activity:sddBoard.titleFallback`)}),r&&(0,Y.jsx)(`span`,{className:X(`rounded-full border px-2 py-0.5 text-[11px] font-medium capitalize`,l_[r.status]??l_.idle),children:r.status}),r?.defaultModel&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 rounded-full border border-border bg-muted px-2 py-0.5 text-[10px] text-muted-foreground`,title:t(`activity:sddBoard.defaultModelTitle`),children:[(0,Y.jsx)(wr,{className:`h-3 w-3 text-violet-400`}),r.defaultModel]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r&&(0,Y.jsx)(`div`,{className:`flex items-center rounded-md border border-border bg-muted p-0.5 text-[11px]`,children:[`graph`,`kanban`].map(e=>(0,Y.jsx)(`button`,{type:`button`,onClick:()=>p(e),className:X(`rounded px-2 py-0.5 capitalize transition`,f===e?`bg-violet-500/25 text-violet-700 dark:text-violet-200`:`text-muted-foreground hover:text-foreground`),children:t(e===`graph`?`activity:sddBoard.graphLabel`:`activity:sddBoard.kanbanLabel`)},e))}),g&&(L?.failed??0)>0&&(0,Y.jsxs)(`button`,{type:`button`,onClick:O,title:t(`activity:sddBoard.retryAllTitle`),className:`inline-flex items-center gap-1 rounded-md bg-orange-500/15 px-2.5 py-1 text-xs font-medium text-orange-600 dark:text-orange-300 hover:bg-orange-500/25`,children:[(0,Y.jsx)(Le,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.retryFailed`,{count:L?.failed??0})]}),g&&(0,Y.jsxs)(Y.Fragment,{children:[r?.status===`paused`?(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>_({type:`sdd.board.resume`,payload:{}}),className:`inline-flex items-center gap-1 rounded-md bg-sky-500/15 px-2.5 py-1 text-xs font-medium text-sky-600 dark:text-sky-300 hover:bg-sky-500/25`,children:[(0,Y.jsx)(kt,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.resume`)]}):(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>_({type:`sdd.board.pause`,payload:{}}),className:`inline-flex items-center gap-1 rounded-md bg-amber-500/15 px-2.5 py-1 text-xs font-medium text-amber-600 dark:text-amber-300 hover:bg-amber-500/25`,children:[(0,Y.jsx)(kn,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.pause`)]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>_({type:`sdd.board.stop`,payload:{}}),className:`inline-flex items-center gap-1 rounded-md bg-red-500/15 px-2.5 py-1 text-xs font-medium text-red-600 dark:text-red-300 hover:bg-red-500/25`,children:[(0,Y.jsx)(ae,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.stop`)]})]}),r&&!g&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:x,title:t(`activity:sddBoard.cleanTitle`),className:`inline-flex items-center gap-1 rounded-md bg-slate-500/15 px-2.5 py-1 text-xs font-medium text-slate-600 dark:text-slate-300 hover:bg-slate-500/25`,children:[(0,Y.jsx)(en,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.cleanWorktrees`)]}),(r.mergedCommits?.length??0)>0&&(0,Y.jsxs)(`button`,{type:`button`,onClick:S,title:t(`activity:sddBoard.rollbackTitle`,{count:r.mergedCommits?.length??0,base:r.baseBranch??t(`activity:sdd.baseBranchFallback`)}),className:`inline-flex items-center gap-1 rounded-md bg-amber-500/15 px-2.5 py-1 text-xs font-medium text-amber-600 dark:text-amber-300 hover:bg-amber-500/25`,children:[(0,Y.jsx)(kr,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.rollback`,{count:r.mergedCommits?.length??0})]})]}),r&&(a?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-red-500/15 px-2.5 py-1 text-xs font-medium text-red-600 dark:text-red-300`,children:[(0,Y.jsx)(Le,{className:`h-3.5 w-3.5 animate-spin`}),` `,t(g?`activity:sddBoard.stopping`:`activity:sddBoard.destroying`)]}):(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>h(!0),title:t(`activity:sddBoard.destroyTitle`),className:`inline-flex items-center gap-1 rounded-md bg-red-600/90 px-2.5 py-1 text-xs font-medium text-white hover:bg-red-700`,children:[(0,Y.jsx)(C,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.destroy`)]})),(0,Y.jsx)($,{variant:`ghost`,size:`icon`,onClick:e,children:(0,Y.jsx)(Xn,{className:`h-4 w-4`})})]})]}),r&&L&&(0,Y.jsxs)(`div`,{className:`mt-2.5 flex items-center gap-5`,children:[(0,Y.jsx)(P_,{pct:L.percentComplete}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,Y.jsx)(R_,{label:t(`activity:sddBoard.statDone`),value:`${L.completed}/${L.total}`,color:`text-emerald-600 dark:text-emerald-300`}),L.inProgress>0&&(0,Y.jsx)(R_,{label:t(`activity:sddBoard.statRunning`),value:L.inProgress,color:`text-amber-600 dark:text-amber-300`}),L.failed>0&&(0,Y.jsx)(R_,{label:t(`activity:sddBoard.statFailed`),value:L.failed,color:`text-red-600 dark:text-red-300`}),(0,Y.jsx)(R_,{label:t(`activity:sddBoard.statWave`),value:r.wave+1,color:`text-violet-600 dark:text-violet-300`}),g&&r.startedAt>0&&(0,Y.jsx)(R_,{label:t(`activity:sddBoard.statElapsed`),value:p_(c-r.startedAt),color:`text-foreground`})]}),(0,Y.jsx)(`div`,{className:`flex min-h-[24px] items-center gap-1.5`,children:T.length===0?(0,Y.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t(`activity:sddBoard.noActiveWorkers`)}):T.map((e,t)=>(0,Y.jsxs)(`span`,{title:`${e.name} → ${e.task}`,className:`flex items-center gap-1 rounded-full bg-muted py-0.5 pl-0.5 pr-2`,children:[(0,Y.jsx)(`span`,{className:X(`sdd-agent-live flex h-5 w-5 items-center justify-center rounded-full text-[9px] font-bold text-white`,u_[t%u_.length]),children:f_(e.name)}),(0,Y.jsx)(`span`,{className:`max-w-[90px] truncate text-[11px] text-foreground`,children:e.name})]},e.name))})]})]})]}),i&&(0,Y.jsx)(L_,{result:i,onDismiss:()=>s(null)}),R.length>0&&(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 border-b border-rose-500/30 bg-rose-500/5 px-4 py-2 text-xs text-rose-600 dark:text-rose-300`,children:[(0,Y.jsx)(gt,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`font-semibold`,children:t(`activity:sddBoard.deadlock`)}),R.map(e=>(0,Y.jsxs)(`div`,{className:`font-mono`,children:[e.blocked,` ← `,e.blockedBy.join(`, `)]},e.blocked))]})]}),(0,Y.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`relative min-h-0 min-w-0 flex-1`,children:r?f===`graph`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(E_,{tasks:w,columns:r.columns,onTaskClick:E}),(0,Y.jsx)(`div`,{className:`pointer-events-none absolute bottom-2 left-1/2 -translate-x-1/2 rounded-full bg-black/40 px-2 py-0.5 text-[10px] text-muted-foreground backdrop-blur`,children:t(`activity:sddBoard.clickTaskHint`)})]}):(0,Y.jsx)(O_,{tasks:r.tasks,selectedId:u,onTaskClick:E}):(0,Y.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 text-sm text-muted-foreground`,children:[(0,Y.jsx)(tn,{className:`h-10 w-10 text-violet-500/40`}),(0,Y.jsx)(`p`,{className:`text-foreground`,children:t(`activity:sddBoard.noRunTitle`)}),(0,Y.jsx)(`p`,{className:`max-w-sm text-center text-xs text-muted-foreground`,children:t(`activity:sddBoard.noRunBody`)})]})}),r&&(0,Y.jsx)(`aside`,{className:`w-80 shrink-0 border-l border-border bg-card`,children:I?(0,Y.jsx)(j_,{task:I,allTasks:r.tasks,feed:r.feed??[],now:c,modelCandidates:F,defaultModel:r.defaultModel,onClose:()=>d(null),onRetry:D,onReassign:k,onSetModel:A,onSetVerification:j,onCancel:M,onDelete:N,onSplit:P,onSelectTask:d},I.id):(0,Y.jsx)(h_,{feed:r.feed??[],now:c})})]}),(0,Y.jsx)(g_,{open:m,onOpenChange:h,snapshot:r,busy:a,onConfirm:b})]})}function I_(e){let t=e.op===`cleanup_worktrees`?`lcClean`:e.op===`rollback`?`lcRollback`:`lcDestroy`,n=b.t(`activity:sddBoard.${t}`);if(!e.ok)return b.t(`activity:sddBoard.lcFailed`,{op:n,reason:e.reason??b.t(`activity:sddBoard.lcUnknownError`)});let r=[];typeof e.removed==`number`&&r.push(b.t(`activity:sddBoard.lcWorktrees`,{count:e.removed})),typeof e.reverted==`number`&&e.reverted>0&&r.push(b.t(`activity:sddBoard.lcCommits`,{count:e.reverted})),e.deleted?.length&&r.push(b.t(`activity:sddBoard.lcDeleted`,{items:e.deleted.join(`, `)}));let i=r.length?r.join(` · `):b.t(`activity:sddBoard.lcNothing`);return e.reason?b.t(`activity:sddBoard.lcNote`,{op:n,body:i,reason:e.reason}):b.t(`activity:sddBoard.lcOk`,{op:n,body:i})}function L_({result:e,onDismiss:t}){let n=!e.ok||!!e.reason;return(0,Y.jsxs)(`div`,{className:X(`flex items-start gap-2 border-b px-4 py-2 text-xs`,n?`border-amber-500/30 bg-amber-500/5 text-amber-700 dark:text-amber-300`:`border-emerald-500/30 bg-emerald-500/5 text-emerald-700 dark:text-emerald-300`),children:[n?(0,Y.jsx)(Nn,{className:`mt-0.5 h-4 w-4 shrink-0`}):(0,Y.jsx)(rn,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,Y.jsx)(`span`,{className:`flex-1`,children:I_(e)}),(0,Y.jsx)(`button`,{type:`button`,onClick:t,className:`shrink-0 opacity-60 hover:opacity-100`,children:(0,Y.jsx)(Xn,{className:`h-3.5 w-3.5`})})]})}function R_({label:e,value:t,color:n}){return(0,Y.jsxs)(`span`,{className:`flex items-baseline gap-1`,children:[(0,Y.jsx)(`span`,{className:X(`font-semibold tabular-nums`,n),children:t}),(0,Y.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:e})]})}function z_({value:e,candidates:t,onChange:n,placeholder:r,emptyHint:i}){let{t:a}=V(),[o,s]=(0,U.useState)(``),c=(t,r)=>{let i=t+r;if(i<0||i>=e.length)return;let a=[...e];[a[t],a[i]]=[a[i],a[t]],n(a)},l=t=>n(e.filter((e,n)=>n!==t)),u=(t,r)=>{let i=`${r}/${t}`;e.includes(i)||n([...e,i])},d=()=>{let t=o.trim().replace(/\s*\/\s*/g,`/`).replace(/\s+/g,` `);t&&(e.includes(t)||n([...e,t]),s(``))};return(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[e.length>0&&(0,Y.jsx)(`ol`,{className:`space-y-1`,children:e.map((t,n)=>(0,Y.jsxs)(`li`,{className:`flex items-center gap-1.5 rounded-md border border-border bg-muted px-2 py-1 text-xs`,children:[(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:n+1}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-foreground`,children:t}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>c(n,-1),disabled:n===0,className:`text-muted-foreground hover:text-foreground disabled:opacity-30`,title:a(`activity:fallback.moveUp`),children:(0,Y.jsx)(Vr,{className:`h-3 w-3`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>c(n,1),disabled:n===e.length-1,className:`text-muted-foreground hover:text-foreground disabled:opacity-30`,title:a(`activity:fallback.moveDown`),children:(0,Y.jsx)(ct,{className:`h-3 w-3`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>l(n),className:`text-muted-foreground hover:text-red-400`,title:a(`common:action.remove`),children:(0,Y.jsx)(Xn,{className:`h-3 w-3`})})]},`${t}-${n}`))}),(0,Y.jsx)(A_,{candidates:t,placeholder:r??a(`activity:fallback.placeholder`),onPick:u}),(0,Y.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,Y.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&d()},placeholder:a(`activity:fallback.manualPlaceholder`),className:`min-w-0 flex-1 rounded-md border border-border bg-background px-2 py-1.5 font-mono text-xs outline-none placeholder:text-muted-foreground`}),(0,Y.jsx)(`button`,{type:`button`,onClick:d,className:`rounded-md border border-border px-2 py-1.5 text-xs hover:bg-muted`,title:a(`activity:fallback.addTitle`),children:(0,Y.jsx)(hn,{className:`h-3.5 w-3.5`})})]}),e.length===0&&(0,Y.jsxs)(`p`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,Y.jsx)(hn,{className:`h-2.5 w-2.5`}),` `,i??a(`activity:fallback.emptyHint`)]})]})}var B_={idle:`phaseStart`,questioning:`phaseInterview`,spec_review:`phaseSpecReview`,implementation:`phasePlanning`,task_review:`phaseTaskReview`,executing:`phaseRunning`,done:`phaseDone`},V_=[`questioning`,`spec_review`,`implementation`,`task_review`,`executing`];function H_({onClose:e}){let{t}=V(),{client:n}=sd(),r=rc(e=>e.snapshot),i=rc(e=>e.agentText),o=rc(e=>e.error),s=rc(e=>e.startedRunId),c=rc(e=>e.setStartedRunId),[u,d]=(0,U.useState)(``),[f,p]=(0,U.useState)(``),[m,h]=(0,U.useState)(!1),[g,_]=(0,U.useState)(!0),[v,y]=(0,U.useState)(!0),[b,x]=(0,U.useState)(!1),[S,C]=(0,U.useState)(void 0),[w,T]=(0,U.useState)(void 0),[E,D]=(0,U.useState)([]),[O,k]=(0,U.useState)(4),[A,j]=(0,U.useState)(!0),M=i_(b),N=(0,U.useCallback)(e=>n?.send?.(e),[n]),P=(0,U.useRef)(null);(0,U.useEffect)(()=>{N({type:`sdd.spec.get`})},[N]),(0,U.useEffect)(()=>{P.current?.scrollIntoView({behavior:`smooth`,block:`end`})},[r?.answers.length??0,i]),(0,U.useEffect)(()=>{s&&(_l(`sddboard`),c(null))},[s,c]);let F=r?.busy??!1,I=r?.phase??`idle`,L=!!r;(0,U.useEffect)(()=>{L&&h(!1)},[L]);let R=r?.answers[r.answers.length-1]?.question??``,ee=!!r&&(r.taskCount>0||!!r.graphId||I===`task_review`||I===`executing`),te=()=>{let e=u.trim();!e||F||m||(h(!0),N({type:`sdd.spec.start`,payload:{goal:e}}))},ne=()=>{let e=f.trim();!e||F||(N({type:`sdd.spec.message`,payload:{text:e}}),p(``))},re=()=>!F&&N({type:`sdd.spec.approve`,payload:{}}),ie=()=>{N({type:`sdd.run.start`,payload:{parallelSlots:O,worktrees:A,...S?{model:S,provider:w}:{},...E.length?{fallbackModels:E}:{}}}),x(!1)},ae=(0,U.useMemo)(()=>(r?.board?.tasks??[]).map(e=>({id:e.id,shortId:e.shortId,title:e.title,displayStatus:e.displayStatus,priority:e.priority,deps:e.deps,agentName:e.agentName,worktreeBranch:e.worktreeBranch,retries:e.retries})),[r?.board]),oe=ae.length>0;return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,Y.jsxs)(`header`,{className:`sdd-sheen flex shrink-0 items-center justify-between border-b border-border px-4 py-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(bt,{className:`h-5 w-5 text-violet-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h1`,{className:`text-lg font-semibold`,children:r?.title||t(`activity:sddWizard.titleFallback`)}),L&&(0,Y.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t(`activity:sddWizard.${B_[I]??`phaseStart`}`),I===`questioning`&&` · ${t(`activity:sddWizard.questionsSuffix`,{cur:r?.questionCount??0,max:r?.maxQuestions??0})}`,r&&r.taskCount>0?` · ${t(`activity:sddWizard.tasksSuffix`,{count:r.taskCount})}`:``]})]}),F&&(0,Y.jsx)(B,{className:`h-4 w-4 animate-spin text-muted-foreground`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[ee&&(0,Y.jsxs)(`div`,{className:`relative flex items-center gap-1.5`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>x(e=>!e),title:t(`activity:sddWizard.runCfgTitle`),className:X(`inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs font-medium`,S||E.length?`border-violet-500/40 bg-violet-500/10 text-violet-600 dark:text-violet-300`:`border-border bg-muted text-muted-foreground hover:text-foreground`),children:[(0,Y.jsx)(Ve,{className:`h-3.5 w-3.5`}),S||t(`activity:sddWizard.modelsLabel`)]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:ie,className:`inline-flex items-center gap-1 rounded-md bg-emerald-500/15 px-2.5 py-1 text-xs font-medium text-emerald-700 hover:bg-emerald-500/25 dark:text-emerald-400`,children:[(0,Y.jsx)(a,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddWizard.startRun`)]}),b&&(0,Y.jsxs)(`div`,{className:`sdd-rise absolute right-0 top-9 z-50 w-72 rounded-lg border border-border bg-popover p-3 shadow-xl`,children:[(0,Y.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:t(`activity:sddWizard.defaultWorkerModel`)}),(0,Y.jsx)(A_,{value:S,provider:w,candidates:M,placeholder:t(`activity:sddWizard.leaderDefaultPlaceholder`),resetLabel:t(`activity:sddWizard.useSessionDefault`),onPick:(e,t)=>{C(e),T(t)},onReset:S?()=>{C(void 0),T(void 0)}:void 0}),(0,Y.jsx)(`div`,{className:`mb-1 mt-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:t(`activity:sddWizard.fallbackChain`)}),(0,Y.jsx)(z_,{value:E,candidates:M,onChange:D}),(0,Y.jsx)(`p`,{className:`mt-2 text-[10px] text-muted-foreground`,children:t(`activity:sddWizard.appliesToAll`)}),(0,Y.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`label`,{htmlFor:`sdd-slots`,className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:t(`activity:sddWizard.parallelAgents`)}),(0,Y.jsx)(`input`,{id:`sdd-slots`,type:`number`,min:1,max:16,value:O,onChange:e=>{let t=Number.parseInt(e.target.value,10);k(Number.isFinite(t)?Math.min(16,Math.max(1,t)):1)},className:`w-16 rounded-md border border-border bg-background px-2 py-1 text-right text-xs outline-none focus:border-violet-500`})]}),(0,Y.jsxs)(`label`,{className:`mt-2 flex cursor-pointer items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:t(`activity:sddWizard.isolateWorktrees`)}),(0,Y.jsx)(`input`,{type:`checkbox`,checked:A,onChange:e=>j(e.target.checked),className:`h-3.5 w-3.5 accent-violet-500`})]}),(0,Y.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:t(A?`activity:sddWizard.worktreeOn`:`activity:sddWizard.worktreeOff`)})]})]}),(0,Y.jsx)($,{variant:`ghost`,size:`icon`,onClick:e,children:(0,Y.jsx)(Xn,{className:`h-4 w-4`})})]})]}),L&&(0,Y.jsx)(`div`,{className:`flex shrink-0 items-center gap-1 border-b bg-card/50 px-4 py-1.5 text-[11px]`,children:V_.map((e,n)=>{let r=e===I,i=V_.indexOf(I)>n;return(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsxs)(`span`,{className:X(`rounded-full px-2 py-0.5`,r?`bg-violet-500/20 text-violet-600 dark:text-violet-300`:i?`text-emerald-600 dark:text-emerald-400`:`text-muted-foreground`),children:[i&&(0,Y.jsx)(z,{className:`mr-0.5 inline h-3 w-3`}),t(`activity:sddWizard.${B_[e]}`)]}),n<V_.length-1&&(0,Y.jsx)(`span`,{className:`text-muted-foreground/40`,children:`→`})]},e)})}),(0,Y.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:[o&&(0,Y.jsx)(`div`,{className:`mb-3 rounded-md border border-red-500/40 bg-red-500/5 p-2 text-xs text-red-300`,children:o}),L?(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[oe&&(0,Y.jsxs)(`div`,{className:`sdd-rise overflow-hidden rounded-lg border border-violet-500/20 bg-[#0a0d14]`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>_(e=>!e),className:`flex w-full items-center gap-1.5 border-b border-white/5 px-3 py-1.5 text-[11px] font-medium text-violet-300 hover:bg-white/5`,children:[g?(0,Y.jsx)(bn,{className:`h-3.5 w-3.5`}):(0,Y.jsx)(Oe,{className:`h-3.5 w-3.5`}),(0,Y.jsx)(Jn,{className:`h-3.5 w-3.5`}),t(`activity:sddWizard.taskGraphSummary`,{count:r?.taskCount??0}),(0,Y.jsx)(`span`,{className:`ml-auto text-slate-500`,children:t(g?`activity:sddWizard.dragToExplore`:`activity:sddWizard.show`)})]}),g&&(0,Y.jsx)(`div`,{className:`h-[32dvh] min-h-[200px]`,children:(0,Y.jsx)(E_,{tasks:ae,columns:r?.board?.columns??[]})})]}),(0,Y.jsxs)(`div`,{className:`mx-auto max-w-2xl space-y-3`,children:[r?.goal&&(0,Y.jsxs)(`div`,{className:`rounded-md border border-border bg-muted/30 px-3 py-2`,children:[(0,Y.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,Y.jsx)(l,{className:`h-3 w-3`}),` `,t(`activity:sddWizard.goalLabel`)]}),(0,Y.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:r.goal})]}),r?.answers.length||i&&I===`questioning`||F?(0,Y.jsxs)(`div`,{className:`space-y-2.5`,children:[r?.answers.map((e,t)=>(0,Y.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,Y.jsx)(W_,{role:`assistant`,text:e.question}),(0,Y.jsx)(W_,{role:`user`,text:e.answer})]},t)),i&&I===`questioning`&&i!==R&&(0,Y.jsx)(W_,{role:`assistant`,text:i}),F&&(0,Y.jsx)(W_,{role:`assistant`,text:``,thinking:!0})]}):null,r?.spec&&(0,Y.jsxs)(`div`,{className:`sdd-rise rounded-md border border-border bg-card p-3`,children:[(0,Y.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-sm font-semibold`,children:[(0,Y.jsx)(bt,{className:`h-3.5 w-3.5 text-violet-400`}),r.spec.title]}),(0,Y.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:r.spec.overview}),(0,Y.jsx)(`ul`,{className:`space-y-0.5 text-xs`,children:r.spec.requirements.map((e,t)=>(0,Y.jsxs)(`li`,{className:`flex gap-1.5`,children:[(0,Y.jsx)(`span`,{className:X(`shrink-0 font-mono uppercase`,c_(e.priority).text),children:e.priority[0]}),(0,Y.jsx)(`span`,{children:e.description})]},t))})]}),i&&(I===`implementation`||I===`task_review`)&&(0,Y.jsxs)(`div`,{className:`sdd-rise rounded-md border border-border bg-card`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>y(e=>!e),className:`flex w-full items-center gap-1.5 border-b border-border/60 px-3 py-2 text-sm font-semibold hover:bg-muted/40`,children:[v?(0,Y.jsx)(bn,{className:`h-3.5 w-3.5`}):(0,Y.jsx)(Oe,{className:`h-3.5 w-3.5`}),(0,Y.jsx)(bt,{className:`h-3.5 w-3.5 text-violet-400`}),` `,t(`activity:sddWizard.implementationPlan`)]}),v&&(0,Y.jsx)(`div`,{className:`max-h-[40dvh] overflow-auto px-3 py-2`,children:(0,Y.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:U_(i)})})]}),i&&I!==`questioning`&&I!==`implementation`&&I!==`task_review`&&!r?.spec&&(0,Y.jsx)(W_,{role:`assistant`,text:i}),(I===`spec_review`||I===`implementation`||I===`task_review`)&&(0,Y.jsxs)($,{variant:`secondary`,onClick:re,disabled:F,children:[(0,Y.jsx)(z,{className:`mr-1.5 h-4 w-4`}),t(I===`spec_review`?`activity:sddWizard.approveSpec`:I===`task_review`?`activity:sddWizard.approveTasks`:`activity:sddWizard.approvePlan`)]}),(0,Y.jsx)(`div`,{ref:P})]})]}):(0,Y.jsxs)(`div`,{className:`mx-auto mt-8 max-w-xl`,children:[(0,Y.jsx)(`label`,{className:`mb-2 block text-sm font-medium`,htmlFor:`sdd-goal`,children:t(`activity:sddWizard.goalPrompt`)}),(0,Y.jsx)(`textarea`,{id:`sdd-goal`,value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&te()},rows:4,placeholder:t(`activity:sddWizard.goalPlaceholder`),className:`w-full resize-none rounded-md border border-border bg-card px-3 py-2 text-sm outline-none focus:border-violet-500`}),(0,Y.jsx)($,{className:`mt-3`,onClick:te,disabled:!u.trim()||m,children:m?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(B,{className:`mr-1.5 h-4 w-4 animate-spin`}),` `,t(`activity:sddWizard.startingInterview`)]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(bt,{className:`mr-1.5 h-4 w-4`}),` `,t(`activity:sddWizard.startInterview`)]})}),(0,Y.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:t(`activity:sddWizard.introBody`)})]})]}),L&&I!==`executing`&&I!==`done`&&(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-end gap-2 border-t bg-card px-4 py-2`,children:[(0,Y.jsx)(`textarea`,{value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),ne())},rows:1,placeholder:t(I===`questioning`?`activity:sddWizard.answerPlaceholder`:`activity:sddWizard.changePlaceholder`),disabled:F,className:`max-h-32 flex-1 resize-none rounded-md border border-border bg-background px-3 py-2 text-sm outline-none focus:border-violet-500 disabled:opacity-50`}),(0,Y.jsx)($,{size:`icon`,onClick:ne,disabled:F||!f.trim(),children:(0,Y.jsx)(er,{className:`h-4 w-4`})})]})]})}function U_(e){let t=e.replace(/```json[\s\S]*?```/gi,``).trim();return t.length>0?t:e.trim()}function W_({role:e,text:t,live:n,thinking:r}){let i=e===`user`;return(0,Y.jsxs)(`div`,{className:X(`sdd-rise flex items-start gap-2`,i&&`flex-row-reverse`),children:[(0,Y.jsx)(`span`,{className:X(`mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-full`,i?`bg-sky-500/20 text-sky-600 dark:text-sky-300`:`bg-violet-500/20 text-violet-600 dark:text-violet-300`,(n||r)&&`sdd-agent-live`),children:i?(0,Y.jsx)(It,{className:`h-3.5 w-3.5`}):(0,Y.jsx)(j,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(`div`,{className:X(`max-w-[80%] whitespace-pre-wrap rounded-2xl px-3 py-2 text-sm leading-relaxed text-foreground`,i?`rounded-tr-sm bg-sky-500/15`:`rounded-tl-sm bg-muted`),children:r?(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 py-0.5`,children:[(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 animate-bounce rounded-full bg-muted-foreground [animation-delay:-200ms]`}),(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 animate-bounce rounded-full bg-muted-foreground [animation-delay:-100ms]`}),(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 animate-bounce rounded-full bg-muted-foreground`})]}):t})]})}async function G_(e){try{let t=await e.clone().json(),n=typeof t.error==`string`?t.error:t.message;if(typeof n==`string`&&n.trim())return n}catch{try{let t=await e.text();if(t.trim())return t.trim()}catch{}}return e.statusText||`HTTP ${e.status}`}function K_(e){switch(e){case`running`:return`▶`;case`streaming`:return`↻`;case`waiting_user`:return`⏳`;case`error`:return`✗`;case`idle`:return`■`;default:return`?`}}function q_(e){switch(e){case`running`:return`text-emerald-400`;case`streaming`:return`text-cyan-400`;case`waiting_user`:return`text-amber-400`;case`error`:return`text-red-400`;default:return`text-slate-500`}}function J_(e){switch(e){case`active`:return`text-emerald-400`;case`idle`:return`text-cyan-400`;case`closing`:return`text-amber-400`;default:return`text-slate-500`}}function Y_(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return`<1m`;if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d`}function X_(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/1e3);if(n<10)return b.t(`common:time.justNow`);if(n<60)return b.t(`common:time.secondsAgo`,{count:n});let r=Math.floor(n/60);return r<60?b.t(`common:time.minutesAgo`,{count:r}):b.t(`common:time.hoursAgo`,{count:Math.floor(r/60)})}function Z_(){let{t:e}=V(),[t,n]=(0,U.useState)([]),[r,i]=(0,U.useState)(!0),[a,o]=(0,U.useState)(null),s=(0,U.useCallback)(async()=>{try{let e=await fetch(`/api/sessions`);if(!e.ok){if(e.status===404){o(null),n([]);return}throw Error(`HTTP ${e.status}: ${await G_(e)}`)}n(await e.json()),o(null)}catch(e){o(e instanceof Error?e.message:String(e))}finally{i(!1)}},[]);return(0,U.useEffect)(()=>{s();let e=setInterval(s,5e3);return()=>clearInterval(e)},[s]),r?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 p-4 text-slate-400`,children:[(0,Y.jsx)(B,{className:`h-4 w-4 animate-spin`}),e(`activity:liveSessions.loading`)]}):a?(0,Y.jsxs)(`div`,{className:`p-4 text-slate-500 text-sm`,children:[e(`activity:liveSessions.apiUnavailable`),` `,(0,Y.jsx)(`span`,{className:`text-slate-400`,children:a})]}):t.length===0?(0,Y.jsx)(`div`,{className:`p-4 text-slate-500 text-sm`,children:e(`activity:liveSessions.empty`)}):(0,Y.jsxs)(`div`,{className:`p-4 space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-slate-200 uppercase tracking-wider`,children:e(`activity:liveSessions.heading`,{count:t.length})}),(0,Y.jsx)(`span`,{className:`text-xs text-slate-500`,children:e(`activity:liveSessions.autoRefresh`)})]}),t.map(t=>(0,Y.jsxs)(`div`,{className:`rounded-lg border border-slate-700 bg-slate-800/50 p-3 space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,Y.jsx)(`span`,{className:J_(t.status),children:t.status===`active`?(0,Y.jsx)(fn,{className:`h-3.5 w-3.5 inline`}):t.status===`idle`?(0,Y.jsx)(sn,{className:`h-3.5 w-3.5 inline`}):null}),(0,Y.jsx)(`span`,{className:`font-medium text-slate-200 text-sm`,children:t.projectName}),(0,Y.jsxs)(`span`,{className:`text-slate-500 text-xs`,children:[`[`,t.projectSlug,`]`]}),t.gitBranch?(0,Y.jsxs)(`span`,{className:`text-purple-400 text-xs flex items-center gap-1`,children:[(0,Y.jsx)(Yt,{className:`h-3 w-3`}),t.gitBranch]}):null,(0,Y.jsxs)(`span`,{className:`text-slate-500 text-xs ml-auto flex items-center gap-1`,children:[(0,Y.jsx)(Ge,{className:`h-3 w-3`}),Y_(t.startedAt)]}),(0,Y.jsx)(`span`,{className:`text-slate-600 text-xs`,children:e(`activity:liveSessions.pidLabel`,{pid:t.pid})})]}),(0,Y.jsxs)(`div`,{className:`text-slate-500 text-xs flex items-center gap-1`,children:[(0,Y.jsx)(wr,{className:`h-3 w-3`}),t.workingDir]}),(0,Y.jsxs)(`div`,{className:`space-y-1 mt-2`,children:[t.agents.slice(0,5).map(t=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-xs pl-2 border-l-2 border-slate-700`,children:[(0,Y.jsx)(`span`,{className:q_(t.status),children:K_(t.status)}),(0,Y.jsx)(`span`,{className:`text-slate-300 font-medium`,children:t.name}),t.currentTool?(0,Y.jsxs)(`span`,{className:`text-slate-500`,children:[`[`,t.currentTool,`]`]}):null,(0,Y.jsx)(`span`,{className:`text-slate-600 ml-auto`,children:e(`activity:liveSessions.agentMeta`,{iter:t.iterations,tools:t.toolCalls,ago:X_(t.lastActivityAt)})})]},t.id)),t.agents.length>5?(0,Y.jsx)(`div`,{className:`text-slate-600 text-xs pl-4`,children:e(`activity:liveSessions.andMore`,{count:t.agents.length-5})}):null,t.agents.length===0?(0,Y.jsx)(`div`,{className:`text-slate-600 text-xs pl-4`,children:e(`activity:liveSessions.noAgents`)}):null]})]},t.sessionId))]})}var Q_=[{phase:`discovery`,label:`Discovery`,roles:[{role:`explore`,name:`Explore`},{role:`search`,name:`Search`},{role:`research`,name:`Research`}]},{phase:`planning`,label:`Planning`,roles:[{role:`analyst`,name:`Analyst`},{role:`planner`,name:`Planner`},{role:`architect`,name:`Architect`},{role:`critic`,name:`Critic`},{role:`refactor-planner`,name:`Refactor Planner`}]},{phase:`build`,label:`Build`,roles:[{role:`executor`,name:`Executor`},{role:`refactor`,name:`Refactor`},{role:`simplifier`,name:`Simplifier`},{role:`migration`,name:`Migration`},{role:`vision`,name:`Vision`},{role:`debugger`,name:`Debugger`},{role:`tracer`,name:`Tracer`}]},{phase:`verify`,label:`Verify`,roles:[{role:`test`,name:`Test`},{role:`e2e`,name:`E2E`},{role:`browser`,name:`Browser`},{role:`performance`,name:`Performance`},{role:`chaos`,name:`Chaos`},{role:`security-scanner`,name:`Security Scanner`},{role:`bug-hunter`,name:`Bug Hunter`},{role:`audit-log`,name:`Audit Log`}]},{phase:`review`,label:`Review`,roles:[{role:`code-reviewer`,name:`Code Reviewer`},{role:`security-reviewer`,name:`Security Reviewer`},{role:`accessibility`,name:`Accessibility`},{role:`compliance`,name:`Compliance`}]},{phase:`domain`,label:`Domain`,roles:[{role:`database`,name:`Database`},{role:`api`,name:`API`},{role:`auth`,name:`Auth`},{role:`data`,name:`Data`},{role:`frontend`,name:`Frontend`},{role:`backend`,name:`Backend`},{role:`designer`,name:`Designer`}]},{phase:`knowledge`,label:`Knowledge`,roles:[{role:`document`,name:`Document`},{role:`uml`,name:`UML`},{role:`i18n`,name:`I18n`},{role:`prompt`,name:`Prompt`}]},{phase:`delivery`,label:`Delivery`,roles:[{role:`git`,name:`Git`},{role:`release`,name:`Release`},{role:`devops`,name:`DevOps`},{role:`observability`,name:`Observability`},{role:`dependency`,name:`Dependency`}]},{phase:`meta`,label:`Meta`,roles:[{role:`skill-manage`,name:`Skill Manager`},{role:`self-improving`,name:`Self-Improving`},{role:`context`,name:`Context`},{role:`cost`,name:`Cost`},{role:`tech-stack`,name:`Tech Stack Validator`}]}],$_=Q_.map(e=>e.phase),ev=Q_.flatMap(e=>[...e.roles]),tv=ev.map(e=>e.role),nv=[`*`,...$_,...tv];function rv(e){if(e===`*`)return`Default (*)`;let t=Q_.find(t=>t.phase===e);if(t)return`Phase: ${t.label} (${t.phase})`;let n=ev.find(t=>t.role===e);return n?`${n.name} (${n.role})`:`Custom: ${e}`}var iv=oe(`inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2`,{variants:{variant:{default:`border-transparent bg-primary text-primary-foreground hover:bg-primary/80`,secondary:`border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80`,destructive:`border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80`,outline:`text-foreground`}},defaultVariants:{variant:`default`}});function av({className:e,variant:t,...n}){return(0,Y.jsx)(`div`,{className:X(iv({variant:t}),e),...n})}var ov=[{name:`filesystem`,description:`Read, write, and navigate the local filesystem. Good for exploring projects.`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-filesystem`,`.`]},{name:`github`,description:`GitHub API — issues, PRs, repos, search, and file operations.`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-github`],requiresEnvVars:[`GITHUB_PERSONAL_ACCESS_TOKEN`],badge:`Popular`},{name:`context7`,description:`Codebase-aware documentation and Q&A grounded in your actual library versions.`,transport:`streamable-http`,url:`https://mcp.context7.com/mcp`,badge:`New`},{name:`brave-search`,description:`Web search via Brave Browser. Free tier: 2,000 queries/month.`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-brave-search`],requiresEnvVars:[`BRAVE_SEARCH_API_KEY`]},{name:`google-maps`,description:`Directions, geocoding, places, and distance matrix via Google Maps.`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-google-maps`],requiresEnvVars:[`GOOGLE_MAPS_API_KEY`]},{name:`aws`,description:`AWS — EC2, S3, Lambda, IAM, CloudFormation, and cost management.`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-aws`],requiresEnvVars:[`AWS_ACCESS_KEY_ID`,`AWS_SECRET_ACCESS_KEY`]},{name:`slack`,description:`Slack — messaging, channels, and search.`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-slack`],requiresEnvVars:[`SLACK_BOT_TOKEN`]},{name:`everart`,description:`AI image generation via multiple providers.`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-everart`],requiresEnvVars:[`EVERART_API_KEY`]},{name:`sentinel`,description:`Security vulnerability scanning via Sentinel.`,transport:`streamable-http`,url:`https://mcp.sentinel.ai`,badge:`Security`},{name:`playwright`,description:`Browser automation — navigate, click, type, screenshot, evaluate JS (headless Chromium).`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-playwright`],badge:`Browser`},{name:`zai-vision`,description:`Image analysis, screenshot understanding, and diagram interpretation.`,transport:`stdio`,command:`npx`,args:[`-y`,`@z_ai/mcp-server@latest`],env:{Z_AI_MODE:`ZAI`},requiresEnvVars:[`Z_AI_API_KEY`],allowedTools:[`image_analysis`,`extract_text_from_screenshot`,`diagnose_error_screenshot`,`understand_technical_diagram`,`analyze_data_visualization`,`ui_diff_check`],badge:`Vision`},{name:`minimax-vision`,description:`MiniMax image understanding via understand_image (read-only, safe for auto-run).`,transport:`stdio`,command:`uvx`,args:[`minimax-coding-plan-mcp`,`-y`],env:{MINIMAX_MCP_BASE_PATH:`./.wrongstack/minimax-output`,MINIMAX_API_HOST:`https://api.minimax.io`,MINIMAX_API_RESOURCE_MODE:`url`},requiresEnvVars:[`MINIMAX_API_KEY`],allowedTools:[`understand_image`],badge:`Vision`},{name:`block`,description:`Postgres database access via SQL (Block MCP server).`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-block`],requiresEnvVars:[`DATABASE_URL`]}];function sv(e,t=!1){return{name:e.name,description:e.description,transport:e.transport,command:e.command,args:e.args,url:e.url,env:e.env,allowedTools:e.allowedTools,enabled:t}}function cv(e){switch(e){case`connected`:return{color:`bg-green-500`};case`connecting`:return{color:`bg-yellow-500`};case`sleeping`:return{color:`bg-blue-500`};case`discovering`:return{color:`bg-purple-500`};case`error`:return{color:`bg-red-500`};case`stopped`:return{color:`bg-gray-500`};default:return{color:`bg-gray-400`}}}function lv({status:e}){let{color:t}=cv(e);return(0,Y.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full ${t}`})}function uv({server:e,onWake:t,onSleep:n,onDiscover:r,onEdit:a,onRemove:o}){let[s,c]=(0,U.useState)(!1),{color:l}=cv(e.status),{t:u}=V();return(0,Y.jsxs)(`div`,{className:`border rounded-lg p-3 bg-card`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`button`,{className:`flex items-center gap-2 flex-1 text-left`,onClick:()=>c(!s),children:[s?(0,Y.jsx)(bn,{className:`w-4 h-4`}):(0,Y.jsx)(Oe,{className:`w-4 h-4`}),(0,Y.jsx)(lv,{status:e.status}),(0,Y.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.transport}),!e.enabled&&(0,Y.jsx)(av,{variant:`outline`,className:`text-xs`,children:u(`settings:mcp.disabled`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[e.status===`sleeping`&&(0,Y.jsx)($,{variant:`ghost`,size:`sm`,onClick:t,title:u(`settings:mcp.wakeTitle`),children:(0,Y.jsx)(we,{className:`w-4 h-4`})}),(e.status===`connected`||e.status===`connecting`)&&(0,Y.jsx)($,{variant:`ghost`,size:`sm`,onClick:n,title:u(`settings:mcp.sleepTitle`),children:(0,Y.jsx)(un,{className:`w-4 h-4`})}),(e.status===`stopped`||e.status===`sleeping`)&&(0,Y.jsx)($,{variant:`ghost`,size:`sm`,onClick:r,title:u(`settings:mcp.discoverTitle`),children:(0,Y.jsx)(le,{className:`w-4 h-4`})}),(0,Y.jsx)($,{variant:`ghost`,size:`sm`,onClick:a,title:u(`settings:mcp.editTitle`),children:(0,Y.jsx)(i,{className:`w-4 h-4`})}),(0,Y.jsx)($,{variant:`ghost`,size:`sm`,onClick:o,title:u(`settings:mcp.removeTitle`),className:`text-destructive hover:text-destructive`,children:(0,Y.jsx)(C,{className:`w-4 h-4`})})]})]}),s&&(0,Y.jsxs)(`div`,{className:`mt-3 pl-6 text-sm space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:u(`settings:mcp.statusLabel`)}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full ${l}`}),u(`settings:mcp.status.${e.status}`,{defaultValue:e.status})]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:u(`settings:mcp.enabledLabel`)}),(0,Y.jsx)(`span`,{children:e.enabled?u(`settings:mcp.yes`):u(`settings:mcp.no`)}),e.description&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:u(`settings:mcp.descriptionLabel`)}),(0,Y.jsx)(`span`,{children:e.description})]}),e.pid&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:u(`settings:mcp.pidLabel`)}),(0,Y.jsx)(`span`,{children:e.pid})]}),e.error&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:u(`settings:mcp.errorLabel`)}),(0,Y.jsx)(`span`,{className:`text-destructive`,children:e.error})]})]}),e.tools&&e.tools.length>0&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:u(`settings:mcp.toolsLabel`,{count:e.tools.length})}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:e.tools.map(e=>(0,Y.jsx)(av,{variant:`secondary`,className:`text-xs`,children:e},e))})]}),(!e.tools||e.tools.length===0)&&e.status===`connected`&&(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:u(`settings:mcp.noTools`)})]})]})}function dv({open:e,onOpenChange:t,server:n,onSave:r,prefillConfig:i}){let{t:a}=V(),[o,s]=(0,U.useState)(n?.name??i?.name??``),[c,l]=(0,U.useState)(n?.transport??i?.transport??`stdio`),[u,d]=(0,U.useState)(n?.description??i?.description??``),[f,p]=(0,U.useState)(i?.command??``),[m,h]=(0,U.useState)(i?.args?.join(` `)??``),[g,_]=(0,U.useState)(``),[v,y]=(0,U.useState)(i?.url??``),[b,x]=(0,U.useState)(n?.enabled??!0),[S,C]=(0,U.useState)(n?.lazy??i?.lazy??!1);(0,U.useEffect)(()=>{e&&(n?(s(n.name),l(n.transport),d(n.description??``),x(n.enabled),C(n.lazy??!1),p(``),h(``),_(``),y(``)):i?(s(i.name),l(i.transport),d(i.description??``),x(!0),C(i.lazy??!1),p(i.command??``),h(i.args?.join(` `)??``),_(i.env?Object.entries(i.env).map(([e,t])=>`${e}=${t}`).join(`
154
- `):``),y(i.url??``)):(s(``),l(`stdio`),d(``),x(!0),C(!1),p(``),h(``),_(``),y(``)))},[n,i,e]);let w=()=>{if(!o.trim()){Z.error(a(`settings:mcp.serverNameRequired`));return}let e={};if(g.trim())for(let t of g.trim().split(`
155
- `)){let n=t.indexOf(`=`);n>0&&(e[t.slice(0,n).trim()]=t.slice(n+1).trim())}r({name:o.trim(),transport:c,description:u.trim()||void 0,enabled:b,command:f.trim()||void 0,args:m.trim()?m.trim().split(/\s+/):void 0,env:Object.keys(e).length>0?e:void 0,url:v.trim()||void 0,lazy:S}),t(!1)},T=!!n,E=!!i;return(0,Y.jsx)(bf,{open:e,onOpenChange:t,children:(0,Y.jsxs)(Cf,{children:[(0,Y.jsx)(wf,{children:(0,Y.jsx)(Ef,{children:a(T?`settings:mcp.dialogTitleEdit`:E?`settings:mcp.dialogTitleAdd`:`settings:mcp.dialogTitleAddCustom`)})}),(0,Y.jsxs)(`div`,{className:`space-y-4 py-4`,children:[(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(`label`,{className:`text-sm font-medium`,children:a(`settings:mcp.fieldName`)}),(0,Y.jsx)(Of,{value:o,onChange:e=>s(e.target.value),placeholder:a(`settings:mcp.fieldNamePlaceholder`),disabled:T||E})]}),(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(`label`,{className:`text-sm font-medium`,children:a(`settings:mcp.fieldTransport`)}),(0,Y.jsxs)(`select`,{className:`w-full h-10 px-3 rounded-md border border-input bg-background text-sm`,value:c,onChange:e=>l(e.target.value),disabled:E,children:[(0,Y.jsx)(`option`,{value:`stdio`,children:`stdio`}),(0,Y.jsx)(`option`,{value:`sse`,children:`sse`}),(0,Y.jsx)(`option`,{value:`streamable-http`,children:`streamable-http`}),(0,Y.jsx)(`option`,{value:`http`,children:`http`})]})]}),(c===`streamable-http`||c===`sse`||c===`http`)&&(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(`label`,{className:`text-sm font-medium`,children:a(`settings:mcp.fieldUrl`)}),(0,Y.jsx)(Of,{value:v,onChange:e=>y(e.target.value),placeholder:`https://mcp.example.com/mcp`,disabled:E})]}),c===`stdio`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(`label`,{className:`text-sm font-medium`,children:a(`settings:mcp.fieldCommand`)}),(0,Y.jsx)(Of,{value:f,onChange:e=>p(e.target.value),placeholder:a(`settings:mcp.fieldCommandPlaceholder`),disabled:E})]}),(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsxs)(`label`,{className:`text-sm font-medium`,children:[a(`settings:mcp.fieldArgs`),` `,(0,Y.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:a(`settings:mcp.fieldArgsHint`)})]}),(0,Y.jsx)(Of,{value:m,onChange:e=>h(e.target.value),placeholder:a(`settings:mcp.fieldArgsPlaceholder`),disabled:E})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsxs)(`label`,{className:`text-sm font-medium`,children:[a(`settings:mcp.fieldEnv`),` `,(0,Y.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:a(`settings:mcp.fieldEnvHint`)})]}),(0,Y.jsx)(`textarea`,{className:`w-full h-20 px-3 py-2 rounded-md border border-input bg-background text-sm font-mono resize-none`,value:g,onChange:e=>_(e.target.value),placeholder:`GITHUB_TOKEN=ghp_...
156
- AWS_REGION=us-east-1`})]}),(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(`label`,{className:`text-sm font-medium`,children:a(`settings:mcp.fieldDescription`)}),(0,Y.jsx)(Of,{value:u,onChange:e=>d(e.target.value),placeholder:a(`settings:mcp.fieldDescriptionPlaceholder`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,id:`server-enabled`,checked:b,onChange:e=>x(e.target.checked),className:`rounded`}),(0,Y.jsx)(`label`,{htmlFor:`server-enabled`,className:`text-sm`,children:a(`settings:mcp.enableServer`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,id:`server-lazy`,checked:S,onChange:e=>C(e.target.checked),className:`rounded`}),(0,Y.jsxs)(`label`,{htmlFor:`server-lazy`,className:`text-sm`,children:[a(`settings:mcp.lazyConnect`),` `,(0,Y.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:a(`settings:mcp.lazyConnectHint`)})]})]})]}),(0,Y.jsxs)(Tf,{children:[(0,Y.jsx)($,{variant:`outline`,onClick:()=>t(!1),children:a(`common:action.cancel`)}),(0,Y.jsx)($,{onClick:w,children:a(T?`settings:mcp.saveChanges`:`settings:mcp.addServer`)})]})]})})}function fv({server:e,isAdded:t,onAdd:n}){let{t:r}=V();return(0,Y.jsxs)(`div`,{className:`border rounded-lg p-3 bg-card flex items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-sm`,children:e.name}),e.badge&&(0,Y.jsx)(av,{variant:`secondary`,className:`text-xs shrink-0`,children:e.badge}),(0,Y.jsx)(av,{variant:`outline`,className:`text-xs shrink-0`,children:e.transport})]}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description}),e.requiresEnvVars&&e.requiresEnvVars.length>0&&(0,Y.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400 mt-1`,children:r(`settings:mcp.requires`,{vars:e.requiresEnvVars.join(`, `)})})]}),(0,Y.jsx)(`div`,{className:`shrink-0`,children:t?(0,Y.jsxs)($,{variant:`ghost`,size:`sm`,disabled:!0,children:[(0,Y.jsx)(z,{className:`w-4 h-4 mr-1`}),r(`settings:mcp.added`)]}):(0,Y.jsxs)($,{size:`sm`,variant:`outline`,onClick:n,children:[(0,Y.jsx)(hn,{className:`w-4 h-4 mr-1`}),r(`common:action.add`)]})})]})}function pv(){let e=sd(),{t}=V(),[n,r]=(0,U.useState)([]),[i,a]=(0,U.useState)(!1),[o,s]=(0,U.useState)(`list`),[c,l]=(0,U.useState)(),[u,d]=(0,U.useState)(!1),[f,p]=(0,U.useState)(!1),[m,h]=(0,U.useState)(),[g,_]=(0,U.useState)(null);(0,U.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]),Z.success(b.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)),Z.success(b.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)),_(null),Z.success(b.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)),_(null),Z.info(b.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)),_(null),Z.success(b.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)),_(null),Z.success(b.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)),_(null),Z.warn(b.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)),_(null),Z.error(b.t(`settings:mcp.toastError`,{name:t.name,error:t.error}))}},m=e=>{if(e.type===`mcp.operation_result`){let t=e.payload;t.success||Z.error(t.message),_(null)}},h=e.client.on(`mcp.list`,t),g=e.client.on(`mcp.server.added`,n),v=e.client.on(`mcp.server.removed`,i),y=e.client.on(`mcp.server.updated`,o),x=e.client.on(`mcp.server.discovered`,s),S=e.client.on(`mcp.server.sleeping`,c),C=e.client.on(`mcp.server.waking`,l),w=e.client.on(`mcp.server.connected`,u),T=e.client.on(`mcp.server.error`,p),E=e.client.on(`mcp.operation_result`,m),D=e.client.on(`mcp.server.reconnected`,d),O=e.client.on(`mcp.server.disconnected`,f);return a(!0),e.client?.listMcpServers(),()=>{h?.(),g?.(),v?.(),y?.(),x?.(),S?.(),C?.(),w?.(),T?.(),E?.(),D?.(),O?.()}},[e.client]);let v=(0,U.useCallback)(t=>{e.client?.addMcpServer(t)},[e]),y=(0,U.useCallback)(e=>{h(sv(e,!1)),p(!0)},[]),x=(0,U.useCallback)(n=>{Af({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,U.useCallback)(e=>{l(e),h(void 0),d(!0)},[]),C=(0,U.useCallback)(t=>{e.client?.updateMcpServer(t)},[e]),w=(0,U.useCallback)(t=>{_(t),e.client?.wakeMcpServer(t)},[e]),T=(0,U.useCallback)(t=>{_(t),e.client?.sleepMcpServer(t)},[e]),E=(0,U.useCallback)(t=>{_(t),e.client?.discoverMcpServer(t)},[e]),D=(0,U.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,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(pe,{className:`w-5 h-5`}),(0,Y.jsx)(`h2`,{className:`text-lg font-semibold`,children:t(`settings:mcp.heading`)}),n.length>0&&(0,Y.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:t(`settings:mcp.summary`,{connected:O,sleeping:k,total:n.length})})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsxs)($,{variant:`outline`,size:`sm`,onClick:D,disabled:i,children:[i?(0,Y.jsx)(B,{className:`w-4 h-4 animate-spin`}):null,t(`common:action.refresh`)]}),(0,Y.jsxs)($,{size:`sm`,onClick:()=>{h(void 0),p(!0)},children:[(0,Y.jsx)(hn,{className:`w-4 h-4 mr-1`}),t(`settings:mcp.addCustom`)]})]})]}),(0,Y.jsxs)(Dh,{value:o,onValueChange:e=>s(e),children:[(0,Y.jsxs)(Oh,{children:[(0,Y.jsxs)(kh,{value:`recommended`,children:[(0,Y.jsx)(M,{className:`w-3.5 h-3.5 mr-1`}),t(`settings:mcp.tabRecommended`)]}),(0,Y.jsx)(kh,{value:`list`,children:t(`settings:mcp.tabServers`)}),(0,Y.jsx)(kh,{value:`add`,children:t(`settings:mcp.tabAddCustom`)})]}),(0,Y.jsxs)(Ah,{value:`recommended`,className:`space-y-3`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`settings:mcp.recommendedBody`)}),(0,Y.jsx)(`div`,{className:`grid gap-2`,children:ov.map(e=>(0,Y.jsx)(fv,{server:e,isAdded:A.has(e.name),onAdd:()=>y(e)},e.name))})]}),(0,Y.jsx)(Ah,{value:`list`,className:`space-y-3`,children:i&&n.length===0?(0,Y.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground`,children:[(0,Y.jsx)(B,{className:`w-5 h-5 animate-spin mr-2`}),t(`settings:mcp.loadingServers`)]}):n.length===0?(0,Y.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,Y.jsx)(pe,{className:`w-10 h-10 mx-auto mb-2 opacity-50`}),(0,Y.jsx)(`p`,{children:t(`settings:mcp.noServers`)}),(0,Y.jsx)(`p`,{className:`text-sm`,children:t(`settings:mcp.noServersHint`)})]}):n.map(e=>(0,Y.jsx)(uv,{server:e,onWake:()=>w(e.name),onSleep:()=>T(e.name),onDiscover:()=>E(e.name),onEdit:()=>S(e),onRemove:()=>x(e.name)},e.name))}),(0,Y.jsx)(Ah,{value:`add`,children:(0,Y.jsxs)(`div`,{className:`text-sm text-muted-foreground`,children:[(0,Y.jsx)(`p`,{children:t(`settings:mcp.addCustomBody`)}),(0,Y.jsx)(`p`,{className:`mt-1`,children:t(`settings:mcp.addCustomBodyHint`)})]})})]}),(0,Y.jsx)(dv,{open:f,onOpenChange:e=>{e||(p(!1),h(void 0))},prefillConfig:m,onSave:v}),(0,Y.jsx)(dv,{open:u,onOpenChange:d,server:c,onSave:C})]})}function mv({provider:e,catalogModels:t,currentCatalogProvider:n,isLoadingModels:r,setIsLoadingModels:i,onModelSelect:a,refreshModels:o}){let s=K(e=>e.model),{t:c}=V();return(0,Y.jsx)(`div`,{className:`space-y-4`,children:e?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:`text-sm font-medium`,children:n?.name||e}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e})]}),(0,Y.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>{i(!0),o(e)},children:(0,Y.jsx)(Rn,{className:X(`h-4 w-4`,r&&`animate-spin`)})})]}),r&&!t[e]?(0,Y.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,Y.jsx)(B,{className:`h-6 w-6 animate-spin text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:c(`settings:model.loading`)})]}):(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(t[e]||[]).map(e=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>a(e.id),className:X(`w-full flex items-center justify-between p-3 rounded-lg border text-left transition-all`,s===e.id?`border-primary bg-primary/5 ring-2 ring-primary/20`:`border-border hover:bg-muted`),children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:e.name||e.id}),(0,Y.jsx)(`div`,{className:`flex gap-2 mt-1`,children:e.capabilities.map(e=>(0,Y.jsx)(`span`,{className:`text-xs bg-muted px-1.5 py-0.5 rounded`,children:e},e))})]}),(0,Y.jsxs)(`div`,{className:`text-right text-xs text-muted-foreground`,children:[e.contextWindow&&(0,Y.jsx)(`div`,{children:c(`settings:model.context`,{count:e.contextWindow/1e3})}),e.inputCost&&e.outputCost&&(0,Y.jsxs)(`div`,{children:[`$`,e.inputCost,`/$`,e.outputCost]}),s===e.id&&(0,Y.jsx)(rn,{className:`h-4 w-4 text-primary mt-1`})]})]},e.id)),t[e]?.length===0&&(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:c(`settings:model.notFound`)})]})]}):(0,Y.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,Y.jsx)(wr,{className:`h-8 w-8 mx-auto mb-2 opacity-50`}),(0,Y.jsx)(`p`,{children:c(`settings:model.selectProviderFirst`)})]})})}function hv({label:e,hint:t,value:n,min:r,max:i,step:a=1,onChange:o,unit:s}){return(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-3 py-2`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium`,children:e}),t&&(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground mt-0.5`,children:t})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,Y.jsx)(`input`,{type:`range`,min:r,max:i,step:a,value:n,onChange:e=>o(Number(e.target.value)),className:`w-24 h-1.5 accent-primary`}),(0,Y.jsxs)(`span`,{className:`text-xs tabular-nums w-10 text-right text-muted-foreground`,children:[n,s??``]})]})]})}function gv({label:e,hint:t,value:n,options:r,onChange:i}){return(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-3 py-2`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium`,children:e}),t&&(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground mt-0.5`,children:t})]}),(0,Y.jsx)(`select`,{value:n,onChange:e=>i(e.target.value),className:`shrink-0 h-8 rounded-md border bg-background px-2 text-xs`,children:r.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})}function _v({label:e,hint:t,selector:n,onChange:r,configKey:i,value:a}){let o=typeof a==`boolean`,s=J(e=>n?n(e):!1),c=K(e=>i?e[i]:!1),l=o?a:n?s:c;return(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-3 py-2`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium`,children:e}),t&&(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground mt-0.5`,children:t})]}),(0,Y.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":l,onClick:()=>{if(o)r?.();else if(n)r?.();else if(i===`soundOnComplete`){let e=!K.getState().soundOnComplete;K.getState().setSoundOnComplete(e),e&&Gc()}},className:X(`shrink-0 relative inline-flex h-5 w-9 rounded-full border transition-colors`,l?`bg-primary border-primary`:`bg-muted border-input hover:bg-muted/80`),children:(0,Y.jsx)(`span`,{className:X(`absolute top-0.5 left-0.5 h-3.5 w-3.5 rounded-full bg-background shadow transition-transform`,l&&`translate-x-4`)})})]})}var vv=`openai-compatible`,yv=[{id:`omniroute`,label:`OmniRoute`,defaultBaseUrl:`http://localhost:20128/v1`,noAuth:!0,hint:`WrongStack local gateway · port 20128 · no key · auto-discovers models`},{id:`ollama`,label:`Ollama`,defaultBaseUrl:`http://localhost:11434/v1`,noAuth:!0,hint:`ollama.com · port 11434 · no key`},{id:`vllm`,label:`vLLM`,defaultBaseUrl:`http://localhost:8000/v1`,noAuth:!1,hint:`docs.vllm.ai · port 8000 · optional key`},{id:`lmstudio`,label:`LM Studio`,defaultBaseUrl:`http://localhost:1234/v1`,noAuth:!1,hint:`lmstudio.ai · port 1234 · optional key`}],bv=[{kind:`chatgpt`,label:`ChatGPT`,subtitle:`Plus / Pro / Team → openai-codex`,icon:(0,Y.jsx)(bt,{className:`h-5 w-5`})},{kind:`claude`,label:`Claude`,subtitle:`Pro / Max → anthropic-oauth`,icon:(0,Y.jsx)(j,{className:`h-5 w-5`})},{kind:`copilot`,label:`GitHub Copilot`,subtitle:`Copilot → github-copilot`,icon:(0,Y.jsx)(qn,{className:`h-5 w-5`})}],xv=[`awaiting_browser`,`awaiting_code`,`exchanging`,`fetching_models`];function Sv({ws:e}){let{t}=V(),[n,r]=(0,U.useState)({chatgpt:{phase:`idle`},claude:{phase:`idle`},copilot:{phase:`idle`}}),[i,a]=(0,U.useState)(``),[o,s]=(0,U.useState)(null);(0,U.useEffect)(()=>{let t=e.on(`auth.oauth.status`,e=>{if(e.type!==`auth.oauth.status`)return;let t=e.payload;r(e=>({...e,[t.kind]:{...t}})),t.phase===`success`?(Z.success(t.message??b.t(`settings:oauth.signedInToast`,{provider:t.providerId??t.kind})),s(null),a(``)):t.phase===`error`&&Z.error(t.message??b.t(`settings:oauth.signInFailed`))});return()=>t?.()},[e]);let c=(0,U.useCallback)(t=>{r(e=>({...e,[t]:{phase:t===`copilot`?`awaiting_code`:`awaiting_browser`}})),e.startOAuth(t)},[e]),l=(0,U.useCallback)(t=>{e.cancelOAuth(t),r(e=>({...e,[t]:{phase:`idle`}})),s(null)},[e]),u=(0,U.useCallback)(t=>{let n=i.trim();n&&(e.submitOAuthCode(t,n),r(e=>({...e,[t]:{...e[t],phase:`exchanging`}})))},[i,e]);return(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsx)(`div`,{className:`rounded-md border border-amber-500/30 bg-amber-500/5 p-3`,children:(0,Y.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400`,children:t(`settings:oauth.termsWarning`)})}),bv.map(e=>{let r=n[e.kind],d=xv.includes(r.phase);return(0,Y.jsxs)(`div`,{className:`rounded-lg border border-border p-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`font-medium`,children:e.label}),(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:e.subtitle})]})]}),d?(0,Y.jsx)($,{size:`sm`,variant:`ghost`,onClick:()=>l(e.kind),children:t(`common:action.cancel`)}):(0,Y.jsx)($,{size:`sm`,onClick:()=>c(e.kind),children:t(`settings:oauth.signIn`)})]}),r.phase===`awaiting_browser`&&(0,Y.jsxs)(`div`,{className:`mt-3 space-y-2 border-t pt-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,Y.jsx)(B,{className:`h-4 w-4 animate-spin text-muted-foreground`}),(0,Y.jsx)(`span`,{children:t(`settings:oauth.waitingBrowser`)})]}),r.authorizeUrl&&(0,Y.jsxs)($,{size:`sm`,variant:`outline`,onClick:()=>window.open(r.authorizeUrl,`_blank`,`noopener,noreferrer`),children:[(0,Y.jsx)(Gt,{className:`h-3.5 w-3.5 mr-1`}),t(`settings:oauth.openSignIn`)]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`button`,{type:`button`,className:`text-xs text-muted-foreground underline`,onClick:()=>s(o===e.kind?null:e.kind),children:r.bound===!1?t(`settings:oauth.pasteLoopbackBusy`):t(`settings:oauth.pasteCantReach`)}),o===e.kind&&(0,Y.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,Y.jsx)(Of,{placeholder:`http://localhost:.../callback?code=…`,value:i,onChange:e=>a(e.target.value),className:`font-mono text-xs`,onKeyDown:t=>{t.key===`Enter`&&u(e.kind)}}),(0,Y.jsx)($,{size:`sm`,onClick:()=>u(e.kind),disabled:!i.trim(),children:t(`settings:oauth.submit`)})]})]})]}),r.phase===`awaiting_code`&&(0,Y.jsxs)(`div`,{className:`mt-3 space-y-2 border-t pt-3`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`settings:oauth.enterCode`)}),(0,Y.jsx)(`div`,{className:`font-mono text-2xl font-bold tracking-widest`,children:r.userCode??`…`}),r.verificationUri&&(0,Y.jsxs)($,{size:`sm`,variant:`outline`,onClick:()=>window.open(r.verificationUri,`_blank`,`noopener,noreferrer`),children:[(0,Y.jsx)(Gt,{className:`h-3.5 w-3.5 mr-1`}),t(`settings:oauth.openVerification`)]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(B,{className:`h-3.5 w-3.5 animate-spin`}),(0,Y.jsx)(`span`,{children:t(`settings:oauth.waitingCode`)})]})]}),(r.phase===`exchanging`||r.phase===`fetching_models`)&&(0,Y.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t pt-3 text-sm`,children:[(0,Y.jsx)(B,{className:`h-4 w-4 animate-spin text-muted-foreground`}),(0,Y.jsx)(`span`,{children:r.phase===`exchanging`?t(`settings:oauth.exchanging`):t(`settings:oauth.fetchingModels`)})]}),r.phase===`success`&&(0,Y.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t pt-3 text-sm text-green-600`,children:[(0,Y.jsx)(rn,{className:`h-4 w-4`}),(0,Y.jsx)(`span`,{children:r.message??t(`settings:oauth.signedIn`)})]}),r.phase===`error`&&r.message&&(0,Y.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t pt-3 text-sm text-destructive`,children:[(0,Y.jsx)(Nn,{className:`h-4 w-4`}),(0,Y.jsx)(`span`,{children:r.message})]})]},e.kind)})]})}function Cv({open:e,providerId:t,modelCount:n,onConfirm:r,onCancel:i}){let a=(0,U.useRef)(null),{t:o}=V();return(0,U.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,Y.jsx)(bf,{open:e,onOpenChange:e=>{e||i()},children:(0,Y.jsxs)(Cf,{className:`sm:max-w-md border-amber-500/50`,ref:a,tabIndex:-1,"data-clear-allowlist-dialog":!0,children:[(0,Y.jsxs)(wf,{children:[(0,Y.jsxs)(Ef,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(gt,{className:`h-5 w-5 text-amber-500`}),o(`settings:allowlist.title`)]}),(0,Y.jsx)(Df,{children:o(`settings:allowlist.body`,{count:n,provider:t})})]}),(0,Y.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,Y.jsxs)(Tf,{className:`gap-2 sm:gap-2 flex-wrap`,children:[(0,Y.jsxs)($,{variant:`outline`,size:`sm`,onClick:i,title:o(`settings:allowlist.keepTitle`),"data-action":`cancel`,children:[o(`common:action.cancel`),` `,(0,Y.jsx)(`kbd`,{className:`ml-1 text-[10px] border rounded px-1 bg-background`,children:`Esc`})]}),(0,Y.jsxs)($,{variant:`destructive`,size:`sm`,onClick:r,title:o(`settings:allowlist.clearTitle`),"data-action":`confirm`,children:[o(`settings:allowlist.clear`),` `,(0,Y.jsx)(`kbd`,{className:`ml-1 text-[10px] border rounded px-1 bg-background/80`,children:`↵`})]})]})]})})}function wv(){return{inFlight:!1,last:null,picked:null}}function Tv(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 Ev(e,t,n){return e.picked?e.picked:e.last?.ok&&e.last.modelIds&&e.last.modelIds.length>0&&e.last.modelIds[0]?e.last.modelIds[0]:t||(n&&n.length>0&&n[0]?n[0]:``)}function Dv(e){if(e.inFlight)return{text:`Probing…`,tone:`muted`};let t=e.last;if(!t)return{text:`Click "Refresh from server" to re-probe /v1/models.`,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:`ok — ${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:`no saved provider — the config may have been removed`,tone:`error`};case`no_base_url`:return{text:`no baseUrl configured`,tone:`warning`}}}function Ov(e,t){return e.last?.ok&&e.last.modelIds&&e.last.modelIds.length>0?e.last.modelIds:t??[]}function kv(e,t){if(!e.last?.ok)return!1;let n=e.last.modelIds;if(!n||n.length===0)return!1;let r=t??[];if(r.length!==n.length)return!0;for(let e=0;e<n.length;e++)if(r[e]!==n[e])return!0;return!1}function Av(e){return(e?.length??0)>0}function jv(e,t){return`Allowlist cleared for ${e} — ${t} model${t===1?``:`s`} removed`}function Mv(e){return e.length>0}function Nv(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 Pv=3e3;function Fv({providerId:e,savedPickedModelId:t,savedModels:n,ws:r,onPickModel:i,onClearModels:a,onUndoClear:o}){let[s,c]=(0,U.useState)(()=>wv()),{t:l}=V(),[u,d]=(0,U.useState)(!1);(0,U.useEffect)(()=>r.on(`provider.probe`,t=>{t.type===`provider.probe`&&t.payload.providerId===e&&c(e=>({...e,inFlight:!1,last:Tv(t.payload)}))}),[r,e]);let f=(0,U.useCallback)(()=>{c(e=>({...e,inFlight:!0})),r.probeProvider(e,Pv)},[r,e]),p=(0,U.useCallback)(t=>{c(e=>({...e,picked:t})),i?.(e,t)},[i,e]),m=(0,U.useCallback)(()=>{d(!0)},[]),h=(0,U.useCallback)(()=>{d(!1)},[]),g=(0,U.useCallback)(()=>{d(!1);let t=n?[...n]:[];c(e=>({...e,picked:null,last:null})),a?a(e):r.clearProviderModels(e),Mv(t)&&Z.undoable(jv(e,t.length),()=>{let n=Nv({providerId:e,previousModels:t,onUndoClear:o});switch(n.kind){case`skip`:return;case`callback`:o?.(n.providerId,n.previousModels);return;case`ws-default`:r.undoProviderClear(n.providerId,n.previousModels);return}})},[a,o,r,e,n]),_=(0,U.useMemo)(()=>Ev(s,t,n),[s,t,n]),v=(0,U.useMemo)(()=>Ov(s,n),[s,n]),y=(0,U.useMemo)(()=>Dv(s),[s]),b=(0,U.useMemo)(()=>kv(s,n),[s,n]),x=(0,U.useMemo)(()=>Av(n),[n]);return(0,Y.jsxs)(`div`,{className:`rounded-md border border-border/60 bg-muted/30 px-3 py-2`,"data-provider-models-panel":e,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:l(`activity:providerModels.using`)}),_?(0,Y.jsx)(`span`,{className:`text-xs font-mono px-2 py-0.5 rounded bg-primary/10 text-primary`,children:_}):(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground italic`,children:l(`activity:providerModels.noModelPicked`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[x&&(0,Y.jsx)($,{variant:`ghost`,size:`sm`,onClick:m,"aria-label":l(`activity:providerModels.clearAllowlistAria`,{provider:e}),"data-action":`clear-models`,children:l(`activity:providerModels.clearAllowlist`)}),(0,Y.jsx)($,{variant:`ghost`,size:`sm`,onClick:f,disabled:s.inFlight,"aria-label":l(`activity:providerModels.refreshAria`,{provider:e}),children:s.inFlight?l(`activity:providerModels.probing`):l(`activity:providerModels.refresh`)})]})]}),(0,Y.jsx)(Iv,{formatted:y}),v.length>0&&(0,Y.jsx)(`ul`,{className:`mt-2 flex flex-wrap gap-1.5`,"data-provider-models-list":e,children:v.map(t=>(0,Y.jsxs)(`li`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(`span`,{className:t===_?`text-xs font-mono px-2 py-0.5 rounded bg-primary/10 text-primary`:`text-xs font-mono px-2 py-0.5 rounded border border-border text-foreground/80`,children:t}),t!==_&&(0,Y.jsx)($,{variant:`link`,size:`sm`,onClick:()=>p(t),className:`text-xs h-5 px-1`,"aria-label":l(`activity:providerModels.useModelAria`,{model:t,provider:e}),children:l(`activity:providerModels.use`)})]},t))}),b&&(0,Y.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:l(`activity:providerModels.differsHint`,{command:`wstack auth local --model first`})}),(0,Y.jsx)(Cv,{open:u,providerId:e,modelCount:n?.length??0,onConfirm:g,onCancel:h})]})}function Iv({formatted:e}){return(0,Y.jsx)(`p`,{className:`mt-1 text-xs ${e.tone===`success`?`text-emerald-600 dark:text-emerald-400`:e.tone===`warning`?`text-amber-600 dark:text-amber-400`:e.tone===`error`?`text-rose-600 dark:text-rose-400`:`text-muted-foreground`}`,"data-probe-tone":e.tone,children:e.text})}var Lv=[`anthropic`,`openai`,`google`,`openai-compatible`];function Rv({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:h,setCatalogQuery:g}){let{t:_}=V(),[v,y]=(0,U.useState)(null),[b,x]=(0,U.useState)(``),[S,w]=(0,U.useState)(``),[T,E]=(0,U.useState)(!1),[D,O]=(0,U.useState)(!1),[k,A]=(0,U.useState)(``),[j,M]=(0,U.useState)(`openai-compatible`),[N,P]=(0,U.useState)(``),[F,I]=(0,U.useState)(``),L=(0,U.useCallback)(e=>{!b.trim()||!S.trim()||(c(e,b.trim(),S.trim()),x(``),w(``),y(null))},[c,b,S]),R=(0,U.useCallback)(()=>{k.trim()&&(d(k.trim(),j,N||void 0,F||void 0),A(``),M(`openai-compatible`),P(``),I(``),O(!1))},[d,k,j,N,F]),ee=(0,U.useCallback)(e=>{A(e.id),M(vv),P(e.defaultBaseUrl),e.noAuth&&I(``)},[]),[te,ne]=(0,U.useState)(null),[ie,ae]=(0,U.useState)(``),[oe,se]=(0,U.useState)(!1),[ce,le]=(0,U.useState)({}),ue=(0,U.useMemo)(()=>new Set(r.map(e=>e.id)),[r]);(0,U.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`||le(e=>({...e,[t.providerId]:{ok:t.ok,status:t.status,detail:t.detail}}))});return()=>e?.()},[m]);let de=(0,U.useCallback)(e=>{let t=ie.trim();t&&(ue.has(e.id)?c(e.id,`default`,t):d(e.id,e.family,e.apiBase??void 0,t),ae(``),ne(null),se(!1),Z.success(_(`settings:provider.savedToast`,{name:e.name})),e.apiBase&&setTimeout(()=>m.probeProvider(e.id,6e3),700))},[ie,ue,c,d,m]),fe=h.trim()?t.filter(e=>{let t=h.trim().toLowerCase();return e.id.toLowerCase().includes(t)||e.name.toLowerCase().includes(t)||e.family.toLowerCase().includes(t)}):t,pe=fe.reduce((e,t)=>(e[t.family]||(e[t.family]=[]),e[t.family]?.push(t),e),{});return(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsxs)(`h3`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,Y.jsx)(re,{className:`h-4 w-4 text-muted-foreground`}),_(`settings:provider.subscriptionHeading`)]}),(0,Y.jsx)(Sv,{ws:m})]}),(0,Y.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Y.jsxs)(`h3`,{className:`text-sm font-semibold mb-1 flex items-center gap-2`,children:[(0,Y.jsx)($e,{className:`h-4 w-4 text-muted-foreground`}),_(`settings:provider.apiKeysHeading`)]}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mb-3`,children:_(`settings:provider.apiKeysBody`)})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2 mb-4`,children:[(0,Y.jsxs)($,{variant:a===`catalog`?`default`:`outline`,size:`sm`,onClick:()=>o(`catalog`),children:[(0,Y.jsx)($e,{className:`h-4 w-4 mr-1`}),_(`settings:provider.tabCatalog`)]}),(0,Y.jsxs)($,{variant:a===`saved`?`default`:`outline`,size:`sm`,onClick:()=>o(`saved`),children:[(0,Y.jsx)(re,{className:`h-4 w-4 mr-1`}),_(`settings:provider.tabSaved`,{count:r.length})]})]}),a===`catalog`&&(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(Of,{placeholder:_(`settings:provider.searchPlaceholder`,{count:t.length}),value:h,onChange:e=>g(e.target.value),className:`text-sm`}),n&&t.length===0?(0,Y.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,Y.jsx)(B,{className:`h-6 w-6 animate-spin text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:_(`settings:provider.loadingCatalog`)})]}):fe.length===0&&h?(0,Y.jsx)(`div`,{className:`text-center py-8 text-muted-foreground text-sm`,children:_(`settings:provider.noMatch`,{query:h})}):Lv.map(t=>{let n=pe[t];return n?.length?(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wider`,children:t}),(0,Y.jsx)(`div`,{className:`grid grid-cols-1 gap-2`,children:n.map(t=>{let n=ce[t.id],r=e===t.id;return(0,Y.jsxs)(`div`,{className:X(`rounded-lg border transition-all`,r?`border-primary bg-primary/5 ring-2 ring-primary/20`:`border-border`),children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>s(t.id),className:X(`flex w-full flex-col items-start p-3 text-left rounded-lg`,!r&&`hover:bg-muted`),children:[(0,Y.jsxs)(`div`,{className:`flex w-full justify-between items-start`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:t.name}),(0,Y.jsxs)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:[`(`,t.id,`)`]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t.hasApiKey&&(0,Y.jsxs)(`span`,{className:`text-xs bg-green-500/10 text-green-600 px-2 py-0.5 rounded`,children:[(0,Y.jsx)(re,{className:`h-3 w-3 inline mr-1`}),_(`settings:provider.configured`)]}),n&&(0,Y.jsxs)(`span`,{className:X(`text-xs px-2 py-0.5 rounded inline-flex items-center gap-1`,n.ok?`bg-green-500/10 text-green-600`:`bg-destructive/10 text-destructive`),title:n.detail??n.status,children:[n.ok?(0,Y.jsx)(rn,{className:`h-3 w-3`}):(0,Y.jsx)(Nn,{className:`h-3 w-3`}),n.ok?_(`settings:provider.reachable`):n.status]}),t.envVars[0]&&(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:_(`settings:provider.envVar`,{var:t.envVars[0]})}),r&&(0,Y.jsx)(rn,{className:`h-4 w-4 text-primary`})]})]}),(0,Y.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[_(`settings:provider.modelCount`,{count:t.modelCount}),t.apiBase&&` · ${t.apiBase}`]})]}),r&&!t.hasApiKey&&(0,Y.jsx)(`div`,{className:`px-3 pb-3 -mt-1 space-y-2`,children:te===t.id?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(Of,{autoFocus:!0,type:oe?`text`:`password`,placeholder:_(`settings:provider.keyPlaceholder`,{name:t.name}),value:ie,onChange:e=>ae(e.target.value),className:`text-sm`,onKeyDown:e=>{e.key===`Enter`&&de(t)}}),(0,Y.jsx)($,{size:`icon`,variant:`ghost`,onClick:()=>se(e=>!e),children:oe?(0,Y.jsx)(yr,{className:`h-4 w-4`}):(0,Y.jsx)(An,{className:`h-4 w-4`})}),(0,Y.jsx)($,{size:`sm`,onClick:()=>de(t),disabled:!ie.trim(),children:_(`common:action.save`)})]}),t.envVars[0]&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:_(`settings:provider.orEnv`,{env:t.envVars[0]})})]}):(0,Y.jsxs)($,{size:`sm`,variant:`outline`,onClick:()=>{ne(t.id),ae(``)},children:[(0,Y.jsx)(re,{className:`h-3.5 w-3.5 mr-1`}),_(`settings:provider.addApiKey`)]})})]},t.id)})})]},t):null})]}),a===`saved`&&(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:_(`settings:provider.manageKeys`)}),(0,Y.jsxs)($,{size:`sm`,variant:`outline`,onClick:()=>O(!D),children:[(0,Y.jsx)(hn,{className:`h-4 w-4 mr-1`}),_(`settings:provider.addProvider`)]})]}),D&&(0,Y.jsxs)(`div`,{className:`p-4 border rounded-lg space-y-3 bg-muted/50`,children:[(0,Y.jsx)(`h4`,{className:`font-medium`,children:_(`settings:provider.addCustomHeading`)}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:_(`settings:provider.localServers`)}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:yv.map(e=>(0,Y.jsx)($,{type:`button`,size:`sm`,variant:k===e.id?`default`:`outline`,onClick:()=>ee(e),title:e.hint,children:e.label},e.id))})]}),(0,Y.jsx)(Of,{placeholder:_(`settings:provider.providerIdPlaceholder`),value:k,onChange:e=>A(e.target.value)}),(0,Y.jsxs)(`select`,{className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,value:j,onChange:e=>M(e.target.value),children:[(0,Y.jsx)(`option`,{value:`anthropic`,children:`Anthropic`}),(0,Y.jsx)(`option`,{value:`openai`,children:`OpenAI`}),(0,Y.jsx)(`option`,{value:`openai-compatible`,children:`OpenAI Compatible`}),(0,Y.jsx)(`option`,{value:`google`,children:`Google`})]}),(0,Y.jsx)(Of,{placeholder:`Base URL (optional, e.g. http://localhost:11434/v1)`,value:N,onChange:e=>P(e.target.value)}),(0,Y.jsx)(Of,{type:`password`,placeholder:_(`settings:provider.apiKeyOptionalPlaceholder`),value:F,onChange:e=>I(e.target.value)}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)($,{size:`sm`,onClick:R,disabled:!k.trim(),children:_(`common:action.add`)}),(0,Y.jsx)($,{size:`sm`,variant:`ghost`,onClick:()=>O(!1),children:_(`common:action.cancel`)})]})]}),i?(0,Y.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Y.jsx)(B,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):r.length===0?(0,Y.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,Y.jsx)(re,{className:`h-8 w-8 mx-auto mb-2 opacity-50`}),(0,Y.jsx)(`p`,{children:_(`settings:provider.noSaved`)}),(0,Y.jsx)(`p`,{className:`text-sm`,children:_(`settings:provider.noSavedHint`)})]}):r.map(e=>(0,Y.jsxs)(`div`,{className:`border rounded-lg p-4 space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`flex justify-between items-start`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`font-medium`,children:e.id}),e.family&&(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.family})]}),(0,Y.jsx)(`div`,{className:`flex gap-2`,children:(0,Y.jsx)($,{size:`icon`,variant:`ghost`,onClick:()=>f(e.id),children:(0,Y.jsx)(C,{className:`h-4 w-4 text-destructive`})})})]}),e.baseUrl&&(0,Y.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[(0,Y.jsx)($e,{className:`h-3 w-3 inline mr-1`}),e.baseUrl]}),(0,Y.jsx)(Fv,{providerId:e.id,savedPickedModelId:e.pickedModelId,savedModels:e.models,ws:m,onPickModel:p}),(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-medium`,children:_(`settings:provider.apiKeysLabel`)}),(0,Y.jsxs)($,{size:`sm`,variant:`ghost`,onClick:()=>y(v===e.id?null:e.id),children:[(0,Y.jsx)(hn,{className:`h-3 w-3 mr-1`}),_(`settings:provider.addKey`)]})]}),e.apiKeys.length===0&&!v&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:_(`settings:provider.noKeys`)}),e.apiKeys.map(t=>(0,Y.jsxs)(`div`,{className:`flex items-center justify-between p-2 bg-muted/50 rounded`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-sm font-medium`,children:t.label}),t.isActive&&(0,Y.jsx)(`span`,{className:`ml-2 text-xs bg-green-500/10 text-green-600 px-1.5 py-0.5 rounded`,children:_(`settings:provider.active`)}),(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground font-mono`,children:t.maskedKey})]}),(0,Y.jsxs)(`div`,{className:`flex gap-1`,children:[!t.isActive&&(0,Y.jsx)($,{size:`sm`,variant:`ghost`,onClick:()=>u(e.id,t.label),children:_(`settings:provider.setActive`)}),(0,Y.jsx)($,{size:`icon`,variant:`ghost`,onClick:()=>l(e.id,t.label),children:(0,Y.jsx)(C,{className:`h-3 w-3 text-destructive`})})]})]},t.label)),v===e.id&&(0,Y.jsxs)(`div`,{className:`p-3 border rounded space-y-2 bg-background`,children:[(0,Y.jsx)(Of,{placeholder:_(`settings:provider.keyLabelPlaceholder`),value:b,onChange:e=>x(e.target.value)}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(Of,{type:T?`text`:`password`,placeholder:_(`settings:provider.apiKeyPlaceholder`),value:S,onChange:e=>w(e.target.value)}),(0,Y.jsx)($,{size:`icon`,variant:`ghost`,onClick:()=>E(!T),children:T?(0,Y.jsx)(yr,{className:`h-4 w-4`}):(0,Y.jsx)(An,{className:`h-4 w-4`})})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)($,{size:`sm`,onClick:()=>L(e.id),disabled:!b.trim()||!S.trim(),children:_(`settings:provider.saveKey`)}),(0,Y.jsx)($,{size:`sm`,variant:`ghost`,onClick:()=>{y(null),x(``),w(``)},children:_(`common:action.cancel`)})]})]})]})]},e.id))]})]})}var zv=[{value:``,label:`mode: inherit`},{value:`auto`,label:`mode: auto`},{value:`on`,label:`mode: on`},{value:`off`,label:`mode: off`}],Bv=[{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`}],Vv=[{value:``,label:`preserve: inherit`},{value:`on`,label:`preserve: on`},{value:`off`,label:`preserve: off`}],Hv=new Set(nv);function Uv(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 Wv(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 Gv(){let{provider:e,model:t,setProvider:n,setModel:r,setConfig:i,wsConnected:a,wsUrl:o}=K(),{theme:s,setTheme:c}=ud(),l=sd(),u=l.client,{updatePrefs:d,switchAutonomy:f}=l,m=ti(),{t:h}=V(),g=i_(!0),_=(0,U.useCallback)((e,t)=>{m.set({[e]:t}),d({[e]:t})},[m,d]),v=(0,U.useCallback)(e=>{m.set({uiLocale:e}),b.language!==e&&b.changeLanguage(e),_(`uiLocale`,e)},[m,_]),[y,x]=(0,U.useState)([]),[S,C]=(0,U.useState)({}),[w,T]=(0,U.useState)([]),[E,D]=(0,U.useState)(!1),[O,k]=(0,U.useState)(!1),[A,M]=(0,U.useState)(!1),[N,P]=(0,U.useState)(`catalog`),[F,I]=(0,U.useState)(``),[L,R]=(0,U.useState)(``),[ee,te]=(0,U.useState)(`*`),[ne,re]=(0,U.useState)(``),[ie,ae]=(0,U.useState)(``),[oe,se]=(0,U.useState)(``),[ce,le]=(0,U.useState)(``),ue=y.find(t=>t.id===e);(0,U.useEffect)(()=>{let e=e=>{if(e.type===`provider.catalog`){let t=e.payload;x(t.providers.sort((e,t)=>e.id.localeCompare(t.id))),D(!1)}},t=e=>{if(e.type===`provider.models`){let t=e.payload;C(e=>({...e,[t.provider]:t.models})),k(!1)}},n=e=>{if(e.type===`providers.saved`){let t=e.payload.providers.sort((e,t)=>e.id.localeCompare(t.id));T(t),M(!1),t.length>0&&P(`saved`)}};if(!a||!u)return;let r=u.on(`provider.catalog`,e),i=u.on(`provider.models`,t),o=u.on(`providers.saved`,n);return D(!0),M(!0),u.listProviders(),u.listSavedProviders(),()=>{r?.(),i?.(),o?.()}},[a,u]);let de=(0,U.useCallback)(e=>{n(e),S[e]||(k(!0),l.listProviderModels?.(e))},[S,n,l]),fe=(0,U.useCallback)(e=>{r(e);let t=K.getState().provider;l.switchModel?.(t,e),Z.success(b.t(`settings:toast.switchingTo`,{provider:t,model:e}))},[r,l]),me=(0,U.useCallback)((e,t,n)=>{l.addKey?.(e,t,n)},[l]),he=(0,U.useCallback)((e,t)=>{l.deleteKey?.(e,t)},[l]),ge=(0,U.useCallback)((e,t)=>{l.setActiveKey?.(e,t)},[l]),_e=(0,U.useCallback)((e,t,n,r)=>{l.addProvider?.(e,t,n,r)},[l]),ve=(0,U.useCallback)(e=>{l.removeProvider?.(e)},[l]),ye=(0,U.useCallback)((e,t)=>{l.client.updateProvider({id:e,models:[t]}),e===K.getState().provider&&r(t)},[r,l.client]),z=(0,U.useCallback)(e=>_(`fallbackProfiles`,e),[_]),be=(0,U.useCallback)(()=>{let e=L.trim();if(e){if(m.fallbackProfiles[e]){Z.error(b.t(`settings:toast.fallbackExists`,{name:e}));return}z({...m.fallbackProfiles,[e]:[]}),R(``)}},[m.fallbackProfiles,L,z]),xe=(0,U.useCallback)(()=>{let n=e&&t?`${e}/${t}`:``;if(!n){Z.error(b.t(`settings:toast.selectProviderModelFirst`));return}let r=[n,...m.fallbackModels].filter((e,t,n)=>e&&n.indexOf(e)===t);z({...m.fallbackProfiles,default:r}),Z.success(b.t(`settings:toast.defaultProfileCreated`))},[t,m.fallbackModels,m.fallbackProfiles,e,z]);(0,U.useEffect)(()=>{if(Object.keys(m.fallbackProfiles).length>0)return;let n=e&&t?`${e}/${t}`:``;n&&z({default:[n,...m.fallbackModels].filter((e,t,n)=>e&&n.indexOf(e)===t)})},[t,m.fallbackModels,m.fallbackProfiles,e,z]);let Se=(0,U.useCallback)((e,t)=>{z({...m.fallbackProfiles,[e]:t})},[m.fallbackProfiles,z]),Ce=(0,U.useCallback)(e=>{let{[e]:t,...n}=m.fallbackProfiles;z(n)},[m.fallbackProfiles,z]),Te=(0,U.useCallback)(e=>{_(`fallbackModels`,m.fallbackProfiles[e]??[])},[m.fallbackProfiles,_]),Ee=(0,U.useCallback)(t=>{let i=m.fallbackProfiles[t]??[],a=i[0];if(!a){Z.error(b.t(`settings:toast.profileEmpty`,{name:t}));return}let o=a.indexOf(`/`),s=o>0?a.slice(0,o):e,c=o>0?a.slice(o+1):a;n(s),r(c),l.switchModel?.(s,c),_(`fallbackModels`,i.slice(1)),Z.success(b.t(`settings:toast.leaderSetFrom`,{name:t}))},[m.fallbackProfiles,e,r,n,_,l]),De=(0,U.useCallback)(e=>_(`modelMatrix`,e),[_]),Oe=(0,U.useCallback)(()=>{let e=ee.trim(),t=ne.trim(),n=Uv(ie,oe,ce);if(!e||!t&&!n)return;let r=t?m.fallbackProfiles[t]?{fallbackProfile:t}:t.includes(`/`)?{provider:t.slice(0,t.indexOf(`/`)),model:t.slice(t.indexOf(`/`)+1)}:{model:t}:{},i=m.modelMatrix[e]?.modelRuntime;n?r.modelRuntime=n:i&&(r.modelRuntime=i),De({...m.modelMatrix,[e]:r}),re(``),ae(``),se(``),le(``)},[m.fallbackProfiles,m.modelMatrix,ee,ce,oe,ie,ne,De]),ke=(0,U.useCallback)(e=>{let{[e]:t,...n}=m.modelMatrix;De(n)},[m.modelMatrix,De]),Ae=(0,U.useCallback)((e,t,n)=>{let r={...m.modelMatrix},i={...r[e]??{}},a={...i.modelRuntime??{}},o={...a.reasoning??{}};t===`mode`?n?o.mode=n:delete o.mode:t===`effort`?n?o.effort=n:delete o.effort:n?o.preserve=n===`on`:delete o.preserve,Object.keys(o).length>0?a.reasoning=o:delete a.reasoning,Object.keys(a).length>0?i.modelRuntime=a:delete i.modelRuntime,i.model||i.fallbackProfile||i.modelRuntime?r[e]=i:delete r[e],De(r)},[m.modelMatrix,De]),je=e=>{let t=e.provider&&e.model?`${e.provider}/${e.model}`:e.model,n=e.modelRuntime?.reasoning;return[t??(!e.fallbackProfile&&n?h(`settings:agent.leaderModel`):``),e.fallbackProfile?`profile:${e.fallbackProfile}`:``,...Wv(n)].filter(Boolean).join(` + `)},Me=Array.from(new Set([...Object.keys(m.modelMatrix),ee].filter(e=>e&&!Hv.has(e)))).sort((e,t)=>e.localeCompare(t));return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Y.jsxs)(`header`,{className:`flex items-center justify-between px-4 py-3 border-b bg-card shrink-0`,children:[(0,Y.jsx)(`h1`,{className:`text-lg font-semibold`,children:h(`settings:title`)}),(0,Y.jsx)($,{variant:`ghost`,size:`icon`,onClick:()=>Q(`chat`),children:(0,Y.jsx)(Xn,{className:`h-4 w-4`})})]}),(0,Y.jsx)(Th,{className:`min-h-0 flex-1`,children:(0,Y.jsx)(`div`,{className:`mx-auto max-w-2xl p-6`,children:(0,Y.jsxs)(Dh,{defaultValue:`provider`,children:[(0,Y.jsxs)(Oh,{className:`w-full justify-start mb-6 grid grid-cols-6`,children:[(0,Y.jsxs)(kh,{value:`provider`,className:`gap-1 text-xs`,children:[(0,Y.jsx)(Jn,{className:`h-3.5 w-3.5`}),h(`settings:tabs.provider`)]}),(0,Y.jsxs)(kh,{value:`connection`,className:`gap-1 text-xs`,children:[(0,Y.jsx)($e,{className:`h-3.5 w-3.5`}),h(`settings:tabs.connection`)]}),(0,Y.jsxs)(kh,{value:`appearance`,className:`gap-1 text-xs`,children:[(0,Y.jsx)(Wt,{className:`h-3.5 w-3.5`}),h(`settings:tabs.appearance`)]}),(0,Y.jsxs)(kh,{value:`agent`,className:`gap-1 text-xs`,children:[(0,Y.jsx)(j,{className:`h-3.5 w-3.5`}),h(`settings:tabs.agent`)]}),(0,Y.jsxs)(kh,{value:`features`,className:`gap-1 text-xs`,children:[(0,Y.jsx)(rr,{className:`h-3.5 w-3.5`}),h(`settings:tabs.features`)]}),(0,Y.jsxs)(kh,{value:`mcp`,className:`gap-1 text-xs`,children:[(0,Y.jsx)(pe,{className:`h-3.5 w-3.5`}),h(`settings:tabs.mcp`)]})]}),(0,Y.jsxs)(Ah,{value:`provider`,className:`space-y-4`,children:[(0,Y.jsx)(Rv,{activeProvider:e,catalogProviders:y,isLoadingCatalog:E,savedProviders:w,isLoadingSaved:A,providerTab:N,setProviderTab:P,onSelectProvider:de,onAddKey:me,onDeleteKey:he,onSetActiveKey:ge,onAddProvider:_e,onRemoveProvider:ve,onPickProviderModel:ye,ws:l.client,catalogQuery:F,setCatalogQuery:I}),(0,Y.jsxs)(`div`,{className:`pt-4 border-t`,children:[(0,Y.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 flex items-center gap-2`,children:[(0,Y.jsx)(wr,{className:`h-4 w-4 text-muted-foreground`}),h(`settings:agent.modelHeading`)]}),(0,Y.jsx)(mv,{provider:e,catalogModels:S,currentCatalogProvider:ue,isLoadingModels:O,setIsLoadingModels:k,onModelSelect:fe,refreshModels:e=>l.listProviderModels?.(e)})]})]}),(0,Y.jsxs)(Ah,{value:`connection`,className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsxs)(`label`,{htmlFor:`websocket-url`,className:`text-sm font-medium flex items-center gap-2`,children:[(0,Y.jsx)($e,{className:`h-4 w-4 text-muted-foreground`}),h(`settings:connection.wsUrlLabel`)]}),(0,Y.jsx)(Of,{id:`websocket-url`,value:o,onChange:e=>i({wsUrl:e.target.value}),placeholder:h(`settings:connection.wsUrlPlaceholder`),className:`font-mono text-sm`}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:h(`settings:connection.wsUrlHint`)})]}),(0,Y.jsxs)(`div`,{className:`p-4 rounded-lg border bg-muted/50`,children:[(0,Y.jsx)(`h4`,{className:`text-sm font-medium mb-2`,children:h(`settings:connection.startingHeading`)}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mb-3`,children:h(`settings:connection.startingBody`)})]})]}),(0,Y.jsxs)(Ah,{value:`appearance`,className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold mb-3`,children:h(`settings:appearance.themeHeading`)}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 max-w-md`,children:[(0,Y.jsxs)($,{variant:s===`light`?`default`:`outline`,size:`sm`,onClick:()=>c(`light`),children:[(0,Y.jsx)(we,{className:`h-4 w-4 mr-1`}),h(`settings:appearance.themeLight`)]}),(0,Y.jsxs)($,{variant:s===`dark`?`default`:`outline`,size:`sm`,onClick:()=>c(`dark`),children:[(0,Y.jsx)(un,{className:`h-4 w-4 mr-1`}),h(`settings:appearance.themeDark`)]}),(0,Y.jsxs)($,{variant:s===`system`?`default`:`outline`,size:`sm`,onClick:()=>c(`system`),children:[(0,Y.jsx)(an,{className:`h-4 w-4 mr-1`}),h(`settings:appearance.themeSystem`)]})]}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-2`,children:h(`settings:appearance.themeSystemHint`)})]}),(0,Y.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold mb-3 mt-3`,children:h(`settings:appearance.languageHeading`)}),(0,Y.jsx)(gv,{label:h(`settings:appearance.languageLabel`),hint:h(`settings:appearance.languageHint`),value:m.uiLocale,options:Yr.map(e=>({value:e.code,label:e.name})),onChange:v})]}),(0,Y.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold mb-3 mt-3`,children:h(`settings:appearance.preferencesHeading`)}),(0,Y.jsx)(_v,{label:h(`settings:appearance.compactDensity`),hint:h(`settings:appearance.compactDensityHint`),selector:e=>e.compactMode,onChange:()=>J.getState().toggleCompactMode()}),(0,Y.jsx)(_v,{label:h(`settings:appearance.soundOnComplete`),hint:h(`settings:appearance.soundOnCompleteHint`),selector:null,configKey:`soundOnComplete`}),(0,Y.jsx)(_v,{label:h(`settings:appearance.titleAnimation`),hint:h(`settings:appearance.titleAnimationHint`),value:m.titleAnimation,onChange:()=>_(`titleAnimation`,!m.titleAnimation)})]})]}),(0,Y.jsxs)(Ah,{value:`agent`,className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 flex items-center gap-2`,children:[(0,Y.jsx)($n,{className:`h-4 w-4 text-muted-foreground`}),h(`settings:agent.autonomyHeading`)]}),(0,Y.jsx)(gv,{label:h(`settings:agent.autonomyModeLabel`),hint:h(`settings:agent.autonomyModeHint`),value:m.autonomy,options:[{value:`off`,label:h(`settings:agent.autonomyModeOff`)},{value:`suggest`,label:h(`settings:agent.autonomyModeSuggest`)},{value:`auto`,label:h(`settings:agent.autonomyModeAuto`)},{value:`eternal`,label:h(`settings:agent.autonomyModeEternal`)},{value:`eternal-parallel`,label:h(`settings:agent.autonomyModeEternalParallel`)}],onChange:e=>{m.set({autonomy:e}),f(e)}}),(0,Y.jsx)(hv,{label:h(`settings:agent.autoProceedDelayLabel`),hint:h(`settings:agent.autoProceedDelayHint`),value:m.autonomyDelayMs,min:0,max:1e4,step:500,unit:`ms`,onChange:e=>_(`autonomyDelayMs`,e)}),(0,Y.jsx)(_v,{label:h(`settings:agent.yoloLabel`),hint:h(`settings:agent.yoloHint`),value:m.yolo,onChange:()=>_(`yolo`,!m.yolo)})]}),(0,Y.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Y.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Y.jsx)(tn,{className:`h-4 w-4 text-muted-foreground`}),h(`settings:agent.refineHeading`)]}),(0,Y.jsx)(_v,{label:h(`settings:agent.enableRefineLabel`),hint:h(`settings:agent.enableRefineHint`),value:m.enhanceEnabled,onChange:()=>_(`enhanceEnabled`,!m.enhanceEnabled)}),(0,Y.jsx)(hv,{label:h(`settings:agent.refineDelayLabel`),hint:h(`settings:agent.refineDelayHint`),value:m.enhanceDelayMs,min:3e4,max:12e4,step:15e3,unit:`ms`,onChange:e=>_(`enhanceDelayMs`,e)}),(0,Y.jsx)(gv,{label:h(`settings:agent.refineLanguageLabel`),hint:h(`settings:agent.refineLanguageHint`),value:m.enhanceLanguage,options:[{value:`original`,label:h(`settings:agent.refineLanguageOriginal`)},{value:`english`,label:h(`settings:agent.refineLanguageEnglish`)}],onChange:e=>_(`enhanceLanguage`,e)})]}),(0,Y.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Y.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Y.jsx)(wr,{className:`h-4 w-4 text-muted-foreground`}),h(`settings:agent.reasoningHeading`)]}),(0,Y.jsx)(gv,{label:h(`settings:agent.reasoningModeLabel`),hint:h(`settings:agent.reasoningModeHint`),value:m.reasoningMode,options:[{value:`auto`,label:h(`settings:agent.reasoningModeAuto`)},{value:`on`,label:h(`settings:agent.reasoningModeOn`)},{value:`off`,label:h(`settings:agent.reasoningModeOff`)}],onChange:e=>_(`reasoningMode`,e)}),(0,Y.jsx)(gv,{label:h(`settings:agent.reasoningEffortLabel`),hint:h(`settings:agent.reasoningEffortHint`),value:m.reasoningEffort,options:[{value:`none`,label:h(`settings:agent.reasoningEffortNone`)},{value:`minimal`,label:h(`settings:agent.reasoningEffortMinimal`)},{value:`low`,label:h(`settings:agent.reasoningEffortLow`)},{value:`medium`,label:h(`settings:agent.reasoningEffortMedium`)},{value:`high`,label:h(`settings:agent.reasoningEffortHigh`)},{value:`xhigh`,label:h(`settings:agent.reasoningEffortXhigh`)},{value:`max`,label:h(`settings:agent.reasoningEffortMax`)}],onChange:e=>_(`reasoningEffort`,e)}),(0,Y.jsx)(_v,{label:h(`settings:agent.preserveThinkingLabel`),hint:h(`settings:agent.preserveThinkingHint`),value:m.reasoningPreserve,onChange:()=>_(`reasoningPreserve`,!m.reasoningPreserve)}),(0,Y.jsx)(gv,{label:h(`settings:agent.cacheTtlLabel`),hint:h(`settings:agent.cacheTtlHint`),value:m.cacheTtl,options:[{value:`default`,label:h(`settings:agent.cacheTtlDefault`)},{value:`5m`,label:h(`settings:agent.cacheTtl5m`)},{value:`1h`,label:h(`settings:agent.cacheTtl1h`)}],onChange:e=>_(`cacheTtl`,e)}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-2`,children:h(`settings:agent.capsHint`)})]}),(0,Y.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Y.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Y.jsx)(wr,{className:`h-4 w-4 text-muted-foreground`}),h(`settings:agent.fallbackHeading`)]}),(0,Y.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:h(`settings:agent.fallbackBody`)}),(0,Y.jsx)(z_,{value:m.fallbackModels,candidates:g,onChange:e=>_(`fallbackModels`,e)}),(0,Y.jsxs)(`div`,{className:`pt-1`,children:[(0,Y.jsx)(_v,{label:h(`settings:agent.autoFallbackLabel`),hint:h(`settings:agent.autoFallbackHint`),value:m.fallbackAuto,onChange:()=>_(`fallbackAuto`,!m.fallbackAuto)}),(0,Y.jsx)(_v,{label:h(`settings:agent.favoritesOnlyLabel`),hint:h(`settings:agent.favoritesOnlyHint`),value:m.favoriteModelsOnly,onChange:()=>_(`favoriteModelsOnly`,!m.favoriteModelsOnly)})]})]}),(0,Y.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Y.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Y.jsx)(wn,{className:`h-4 w-4 text-muted-foreground`}),h(`settings:agent.profilesHeading`)]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(Of,{value:L,onChange:e=>R(e.target.value),placeholder:`fallback1`,className:`font-mono text-sm`,onKeyDown:e=>{e.key===`Enter`&&be()}}),(0,Y.jsx)($,{type:`button`,variant:`outline`,onClick:be,children:h(`settings:agent.addProfile`)})]}),(0,Y.jsx)(`div`,{className:`mt-3 space-y-3`,children:Object.keys(m.fallbackProfiles).length===0?(0,Y.jsxs)(`div`,{className:`rounded-md border border-dashed border-border p-3`,children:[(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:h(`settings:agent.noProfiles`)}),(0,Y.jsx)($,{type:`button`,variant:`outline`,size:`sm`,className:`mt-2`,onClick:xe,children:h(`settings:agent.createDefault`)})]}):Object.entries(m.fallbackProfiles).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>(0,Y.jsxs)(`div`,{className:`rounded-md border border-border p-3`,children:[(0,Y.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e}),(0,Y.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Y.jsx)($,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>Te(e),children:h(`settings:agent.useChain`)}),(0,Y.jsx)($,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>Ee(e),children:h(`settings:agent.setLeader`)}),(0,Y.jsx)($,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>Ce(e),children:h(`common:action.remove`)})]})]}),(0,Y.jsx)(z_,{value:t,candidates:g,placeholder:h(`settings:agent.addModelToProfile`),emptyHint:h(`settings:agent.profileEmpty`),onChange:t=>Se(e,t)})]},e))})]}),(0,Y.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Y.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Y.jsx)(wr,{className:`h-4 w-4 text-muted-foreground`}),h(`settings:agent.favoritesHeading`)]}),(0,Y.jsx)(z_,{value:m.favoriteModels,candidates:g,placeholder:h(`settings:agent.addFavoriteModel`),emptyHint:h(`settings:agent.favoritesEmpty`),onChange:e=>_(`favoriteModels`,e)})]}),(0,Y.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Y.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Y.jsx)(nr,{className:`h-4 w-4 text-muted-foreground`}),h(`settings:agent.routingHeading`)]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[minmax(0,180px)_1fr_auto]`,children:[(0,Y.jsxs)(`select`,{"aria-label":h(`settings:agent.routingRouteKey`),value:ee,onChange:e=>te(e.target.value),className:`h-9 min-w-0 rounded-md border bg-background px-3 font-mono text-sm`,children:[(0,Y.jsx)(`option`,{value:`*`,children:rv(`*`)}),(0,Y.jsx)(`optgroup`,{label:h(`settings:agent.routingPhasesGroup`),children:Q_.map(e=>(0,Y.jsx)(`option`,{value:e.phase,children:rv(e.phase)},e.phase))}),Q_.map(e=>(0,Y.jsx)(`optgroup`,{label:h(`settings:agent.routingRolesGroup`,{label:e.label}),children:e.roles.map(e=>(0,Y.jsx)(`option`,{value:e.role,children:rv(e.role)},e.role))},e.phase)),Me.length>0?(0,Y.jsx)(`optgroup`,{label:h(`settings:agent.routingCustomGroup`),children:Me.map(e=>(0,Y.jsx)(`option`,{value:e,children:rv(e)},e))}):null]}),(0,Y.jsx)(Of,{value:ne,onChange:e=>re(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Oe()},placeholder:h(`settings:agent.routingTargetPlaceholder`),className:`font-mono text-sm`}),(0,Y.jsx)($,{type:`button`,variant:`outline`,onClick:Oe,children:h(`settings:agent.routingSet`)})]}),(0,Y.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,Y.jsx)(`select`,{"aria-label":h(`settings:agent.routingReasoningModeAria`),value:ie,onChange:e=>ae(e.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:zv.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,Y.jsx)(`select`,{"aria-label":h(`settings:agent.routingReasoningEffortAria`),value:oe,onChange:e=>se(e.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:Bv.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,Y.jsx)(`select`,{"aria-label":h(`settings:agent.routingReasoningPreserveAria`),value:ce,onChange:e=>le(e.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:Vv.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))})]}),(0,Y.jsx)(`div`,{className:`mt-3 space-y-1.5`,children:Object.keys(m.modelMatrix).length===0?(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:h(`settings:agent.noRoutes`)}):Object.entries(m.modelMatrix).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>(0,Y.jsxs)(`div`,{className:`rounded-md border border-border bg-muted px-2 py-1.5 text-xs`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`w-40 shrink-0 truncate font-mono text-muted-foreground`,title:e,children:rv(e)}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:je(t)}),(0,Y.jsx)($,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>ke(e),children:h(`common:action.remove`)})]}),(0,Y.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,Y.jsx)(`select`,{"aria-label":h(`settings:agent.routingReasoningModeFor`,{key:e}),value:t.modelRuntime?.reasoning?.mode??``,onChange:t=>Ae(e,`mode`,t.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:zv.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,Y.jsx)(`select`,{"aria-label":h(`settings:agent.routingReasoningEffortFor`,{key:e}),value:t.modelRuntime?.reasoning?.effort??``,onChange:t=>Ae(e,`effort`,t.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:Bv.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,Y.jsx)(`select`,{"aria-label":h(`settings:agent.routingReasoningPreserveFor`,{key:e}),value:t.modelRuntime?.reasoning?.preserve===void 0?``:t.modelRuntime.reasoning.preserve?`on`:`off`,onChange:t=>Ae(e,`preserve`,t.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:Vv.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))})]})]},e))})]}),(0,Y.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Y.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Y.jsx)(Jn,{className:`h-4 w-4 text-muted-foreground`}),h(`settings:agent.hqHeading`)]}),(0,Y.jsx)(_v,{label:h(`settings:agent.hqPublishingLabel`),hint:h(`settings:agent.hqPublishingHint`),value:m.hqEnabled,onChange:()=>_(`hqEnabled`,!m.hqEnabled)}),(0,Y.jsxs)(`div`,{className:`space-y-1 py-2`,children:[(0,Y.jsx)(`label`,{className:`text-sm font-medium`,children:h(`settings:agent.hqUrlLabel`)}),(0,Y.jsx)(Of,{value:m.hqUrl,placeholder:`http://host:3499`,onChange:e=>_(`hqUrl`,e.target.value)}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:h(`settings:agent.hqUrlHint`)})]}),(0,Y.jsxs)(`div`,{className:`space-y-1 py-2`,children:[(0,Y.jsx)(`label`,{className:`text-sm font-medium`,children:h(`settings:agent.hqTokenLabel`)}),(0,Y.jsx)(Of,{type:`password`,value:m.hqToken,placeholder:`Client token from wstack --hq`,onChange:e=>_(`hqToken`,e.target.value)})]}),(0,Y.jsx)(_v,{label:h(`settings:agent.hqRawContentLabel`),hint:h(`settings:agent.hqRawContentHint`),value:m.hqRawContent,onChange:()=>_(`hqRawContent`,!m.hqRawContent)})]}),(0,Y.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Y.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Y.jsx)(tn,{className:`h-4 w-4 text-muted-foreground`}),h(`settings:agent.executionHeading`)]}),(0,Y.jsx)(hv,{label:h(`settings:agent.maxIterationsLabel`),hint:h(`settings:agent.maxIterationsHint`),value:m.maxIterations,min:10,max:2e3,step:10,onChange:e=>_(`maxIterations`,e)}),(0,Y.jsx)(hv,{label:h(`settings:agent.autoProceedMaxIterationsLabel`),hint:h(`settings:agent.autoProceedMaxIterationsHint`),value:m.autoProceedMaxIterations,min:0,max:250,step:5,onChange:e=>_(`autoProceedMaxIterations`,e)}),(0,Y.jsx)(_v,{label:h(`settings:agent.confirmExitLabel`),hint:h(`settings:agent.confirmExitHint`),value:m.confirmExit,onChange:()=>_(`confirmExit`,!m.confirmExit)}),(0,Y.jsx)(_v,{label:h(`settings:agent.chimeLabel`),hint:h(`settings:agent.chimeHint`),value:m.chime,onChange:()=>_(`chime`,!m.chime)})]}),(0,Y.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Y.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Y.jsx)(nr,{className:`h-4 w-4 text-muted-foreground`}),h(`settings:agent.fleetHeading`)]}),(0,Y.jsx)(_v,{label:h(`settings:agent.streamFleetLabel`),hint:h(`settings:agent.streamFleetHint`),value:m.streamFleet,onChange:()=>_(`streamFleet`,!m.streamFleet)}),(0,Y.jsx)(hv,{label:h(`settings:agent.maxConcurrentLabel`),hint:h(`settings:agent.maxConcurrentHint`),value:m.maxConcurrent,min:1,max:50,step:1,onChange:e=>_(`maxConcurrent`,e)}),(0,Y.jsx)(_v,{label:h(`settings:agent.nextPredictionLabel`),hint:h(`settings:agent.nextPredictionHint`),value:m.nextPrediction,onChange:()=>_(`nextPrediction`,!m.nextPrediction)})]}),(0,Y.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Y.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Y.jsx)(er,{className:`h-4 w-4 text-muted-foreground`}),h(`settings:agent.telegramHeading`)]}),m.tgConfigured?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(_v,{label:h(`settings:agent.telegramSessionEndLabel`),hint:h(`settings:agent.telegramSessionEndHint`),value:m.tgSessionEnd,onChange:()=>_(`tgSessionEnd`,!m.tgSessionEnd)}),(0,Y.jsx)(_v,{label:h(`settings:agent.telegramDelegateLabel`),hint:h(`settings:agent.telegramDelegateHint`),value:m.tgDelegate,onChange:()=>_(`tgDelegate`,!m.tgDelegate)}),(0,Y.jsx)(_v,{label:h(`settings:agent.telegramLongToolLabel`),hint:h(`settings:agent.telegramLongToolHint`,{ms:m.tgLongToolMs}),value:m.tgLongToolMs>0,onChange:()=>_(`tgLongToolMs`,m.tgLongToolMs>0?0:3e4)}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-2`,children:h(`settings:agent.telegramChangesApply`)})]}):(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:h(`settings:agent.telegramNotConfigured`)})]})]}),(0,Y.jsxs)(Ah,{value:`features`,className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 flex items-center gap-2`,children:[(0,Y.jsx)(rr,{className:`h-4 w-4 text-muted-foreground`}),h(`settings:features.flagsHeading`)]}),(0,Y.jsx)(_v,{label:h(`settings:features.mcpLabel`),hint:h(`settings:features.mcpHint`),value:m.featureMcp,onChange:()=>_(`featureMcp`,!m.featureMcp)}),(0,Y.jsx)(_v,{label:h(`settings:features.pluginsLabel`),hint:h(`settings:features.pluginsHint`),value:m.featurePlugins,onChange:()=>_(`featurePlugins`,!m.featurePlugins)}),(0,Y.jsx)(_v,{label:h(`settings:features.memoryLabel`),hint:h(`settings:features.memoryHint`),value:m.featureMemory,onChange:()=>_(`featureMemory`,!m.featureMemory)}),(0,Y.jsx)(_v,{label:h(`settings:features.skillsLabel`),hint:h(`settings:features.skillsHint`),value:m.featureSkills,onChange:()=>_(`featureSkills`,!m.featureSkills)}),(0,Y.jsx)(_v,{label:h(`settings:features.modelsRegistryLabel`),hint:h(`settings:features.modelsRegistryHint`),value:m.featureModelsRegistry,onChange:()=>_(`featureModelsRegistry`,!m.featureModelsRegistry)}),(0,Y.jsx)(_v,{label:h(`settings:features.indexOnStartLabel`),hint:h(`settings:features.indexOnStartHint`),value:m.indexOnStart,onChange:()=>_(`indexOnStart`,!m.indexOnStart)})]}),(0,Y.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Y.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Y.jsx)(p,{className:`h-4 w-4 text-muted-foreground`}),h(`settings:features.contextHeading`)]}),(0,Y.jsx)(_v,{label:h(`settings:features.autoCompactLabel`),hint:h(`settings:features.autoCompactHint`),value:m.contextAutoCompact,onChange:()=>_(`contextAutoCompact`,!m.contextAutoCompact)}),(0,Y.jsx)(gv,{label:h(`settings:features.compactorStrategyLabel`),hint:h(`settings:features.compactorStrategyHint`),value:m.contextStrategy,options:[{value:`hybrid`,label:h(`settings:features.compactorStrategyHybrid`)},{value:`intelligent`,label:h(`settings:features.compactorStrategyIntelligent`)},{value:`selective`,label:h(`settings:features.compactorStrategySelective`)}],onChange:e=>_(`contextStrategy`,e)}),(0,Y.jsx)(gv,{label:h(`settings:features.contextModeLabel`),hint:h(`settings:features.contextModeHint`),value:m.contextMode,options:[{value:`balanced`,label:h(`settings:features.contextModeBalanced`)},{value:`frugal`,label:h(`settings:features.contextModeFrugal`)},{value:`deep`,label:h(`settings:features.contextModeDeep`)},{value:`archival`,label:h(`settings:features.contextModeArchival`)}],onChange:e=>_(`contextMode`,e)}),(0,Y.jsx)(gv,{label:h(`settings:features.tokenSavingLabel`),hint:h(`settings:features.tokenSavingHint`),value:m.tokenSavingTier,options:[{value:`off`,label:h(`settings:features.tokenSavingOff`)},{value:`minimal`,label:h(`settings:features.tokenSavingMinimal`)},{value:`light`,label:h(`settings:features.tokenSavingLight`)},{value:`medium`,label:h(`settings:features.tokenSavingMedium`)},{value:`aggressive`,label:h(`settings:features.tokenSavingAggressive`)}],onChange:e=>_(`tokenSavingTier`,e)}),(0,Y.jsx)(gv,{label:h(`settings:features.logLevelLabel`),hint:h(`settings:features.logLevelHint`),value:m.logLevel,options:[{value:`debug`,label:h(`settings:features.logLevelDebug`)},{value:`info`,label:h(`settings:features.logLevelInfo`)},{value:`warn`,label:h(`settings:features.logLevelWarn`)},{value:`error`,label:h(`settings:features.logLevelError`)}],onChange:e=>_(`logLevel`,e)}),(0,Y.jsx)(gv,{label:h(`settings:features.auditLevelLabel`),hint:h(`settings:features.auditLevelHint`),value:m.auditLevel,options:[{value:`minimal`,label:h(`settings:features.auditLevelMinimal`)},{value:`standard`,label:h(`settings:features.auditLevelStandard`)},{value:`full`,label:h(`settings:features.auditLevelFull`)}],onChange:e=>_(`auditLevel`,e)})]})]}),(0,Y.jsx)(Ah,{value:`mcp`,className:`space-y-4`,children:m.featureMcp?(0,Y.jsx)(pv,{}):(0,Y.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,Y.jsx)(pe,{className:`w-10 h-10 mx-auto mb-2 opacity-50`}),(0,Y.jsx)(`p`,{children:h(`settings:mcp.disabled`)}),(0,Y.jsx)(`p`,{className:`text-sm mt-1`,children:h(`settings:mcp.disabledHint`)})]})})]})})})]})}var Kv=[],qv=100,Jv=3e4,Yv=5,Xv=null,Zv=!1;function Qv(e){Kv.push(e),Kv.length>qv&&Kv.shift(),Kv.length>=Yv&&!Zv&&$v()}async function $v(){if(Zv||Kv.length===0)return;Zv=!0;let e=Kv.splice(0,Kv.length);try{(await fetch(`/api/analytics`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})).ok||(Kv.unshift(...e),Kv.length>qv&&(Kv.length=qv))}catch{Kv.unshift(...e),Kv.length>qv&&(Kv.length=qv)}finally{Zv=!1}}function ey(){Xv||=setInterval(()=>{Kv.length>0&&$v()},Jv)}function ty(e,t,n){Qv({event:e,category:t,label:n?.label,value:n?.value,metadata:n?.metadata,timestamp:new Date().toISOString()})}var ny=`wrongstack_referral_click`;function ry(e){try{sessionStorage.setItem(ny,JSON.stringify(e))}catch{}ty(`referral_link_clicked`,`engagement`,{label:e.providerName,metadata:{providerId:e.providerId,referralCode:e.referralCode,docsUrl:e.docsUrl}})}function iy(){try{let e=sessionStorage.getItem(ny);return e?JSON.parse(e):null}catch{return null}}function ay(){try{sessionStorage.removeItem(ny)}catch{}}function oy(e,t){let n=iy();if(n&&n.providerId===e){let r=Date.now()-new Date(n.clickedAt).getTime();ty(`referral_converted`,`conversion`,{label:t,value:Math.round(r/1e3),metadata:{providerId:e,referralCode:n.referralCode,timeToConvertMs:r,clickedAt:n.clickedAt}}),ay()}}var sy=t(pn(),1),cy=[{id:`openai`,name:`OpenAI`,description:`GPT, o-series, and Codex models`,icon:`🤖`,color:`from-emerald-500/20 to-emerald-500/5 border-emerald-500/30 hover:border-emerald-500/50`,keyPlaceholder:`sk-...`,docsUrl:`https://platform.openai.com/api-keys`,family:`openai`},{id:`anthropic`,name:`Anthropic`,description:`Claude Opus, Sonnet, and Haiku`,icon:`🧠`,color:`from-amber-500/20 to-amber-500/5 border-amber-500/30 hover:border-amber-500/50`,keyPlaceholder:`sk-ant-...`,docsUrl:`https://console.anthropic.com/settings/keys`,family:`anthropic`},{id:`google`,name:`Google`,description:`Gemini Pro, Flash, and Nano`,icon:`✨`,color:`from-blue-500/20 to-blue-500/5 border-blue-500/30 hover:border-blue-500/50`,keyPlaceholder:`AIza...`,docsUrl:`https://aistudio.google.com/apikey`,family:`google`},{id:`deepseek`,name:`DeepSeek`,description:`High-performance reasoning at low cost`,icon:`🐋`,color:`from-sky-500/20 to-sky-500/5 border-sky-500/30 hover:border-sky-500/50`,keyPlaceholder:`sk-...`,docsUrl:`https://platform.deepseek.com/api_keys`,family:`openai-compatible`},{id:`openrouter`,name:`OpenRouter`,description:`All models via one key`,icon:`🔀`,color:`from-violet-500/20 to-violet-500/5 border-violet-500/30 hover:border-violet-500/50`,keyPlaceholder:`sk-or-...`,docsUrl:`https://openrouter.ai/keys`,family:`openai-compatible`},{id:`minimax`,name:`MiniMax`,description:`Subscribe to one plan and unlock the latest models, including frontier coding capabilities, 1M ultra-long context, and native multimodality. Text, image, and speech models all share the same quota. Invite Friends, Win Together: Friends get 10% off plus Builder benefits when they subscribe, while referrers earn 10% cashback plus community perks.`,icon:`🔮`,color:`from-fuchsia-500/20 to-fuchsia-500/5 border-fuchsia-500/30 hover:border-fuchsia-500/50`,keyPlaceholder:`eyJ...`,docsUrl:`https://platform.minimax.io/subscribe/token-plan?code=JrA4R9QAEn&source=link`,family:`openai-compatible`},{id:`kimi`,name:`Kimi`,description:`Moonshot AI long-context models`,icon:`🌙`,color:`from-cyan-500/20 to-cyan-500/5 border-cyan-500/30 hover:border-cyan-500/50`,keyPlaceholder:`sk-...`,docsUrl:`https://www.kimi.com/membership/pricing`,family:`openai-compatible`},{id:`zai`,name:`Z.ai (GLM)`,description:`You've been invited to join the GLM Coding Plan! Enjoy full support for Claude Code, Cline, and 20+ top coding tools — starting at just $18/month. Subscribe now and grab the limited-time deal!`,icon:`🔷`,color:`from-indigo-500/20 to-indigo-500/5 border-indigo-500/30 hover:border-indigo-500/50`,keyPlaceholder:`...`,docsUrl:`https://z.ai/subscribe?ic=JQZ7TPPRA6`,family:`openai-compatible`},{id:`opencode-go`,name:`OpenCode Go`,description:`Global hosted API for 75+ LLM providers — stable access from US, EU, and Singapore`,icon:`🌍`,color:`from-teal-500/20 to-teal-500/5 border-teal-500/30 hover:border-teal-500/50`,keyPlaceholder:`oc-...`,docsUrl:`https://opencode.ai/go?ref=6VZAER87H4`,family:`openai-compatible`}];async function ly(e,t){try{let n=await fetch(e,{signal:t});if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.json();if(!Array.isArray(r))throw Error(`Expected JSON array`);let i=r.filter(e=>typeof e.id==`string`&&typeof e.name==`string`&&typeof e.family==`string`);return i.length>0?i:cy}catch{return cy}}function uy({popular:e,catalogProvider:t,savedProvider:n,onKeySaved:r}){let{t:i}=V(),[a,o]=(0,U.useState)(``),[s,c]=(0,U.useState)(!1),[l,u]=(0,U.useState)(!!n?.apiKeys.some(e=>e.isActive)),[d,f]=(0,U.useState)(!1),[p,m]=(0,U.useState)(!1),[h,g]=(0,U.useState)(!1),[_,v]=(0,U.useState)(null);(0,U.useEffect)(()=>{h&&e.referral&&sy.toDataURL(e.referral.url,{width:200,margin:2,color:{dark:`#000000`,light:`#ffffff`}}).then(e=>v(e)).catch(()=>v(null))},[h,e.referral]);let y=async()=>{if(a.trim()){c(!0);try{let n=W(K.getState().wsUrl);t?n.addKey(e.id,`default`,a.trim()):n.send({type:`provider.add`,payload:{id:e.id,family:e.family,apiKey:a.trim()}}),u(!0),o(``),Z.success(i(`setup:screen.toasts.keySaved`,{name:e.name})),r(e.id),ty(`provider_key_saved`,`engagement`,{label:e.name,metadata:{providerId:e.id,providerFamily:e.family,hasReferral:!!e.referral,isNewProvider:!t}}),e.referral&&oy(e.id,e.name)}catch{Z.error(i(`setup:screen.toasts.keySaveFailed`,{name:e.name})),ty(`provider_key_save_failed`,`error`,{label:e.name,metadata:{providerId:e.id,providerFamily:e.family}})}finally{c(!1)}}},b=e=>{e.key===`Enter`&&a.trim()&&y()},x=async()=>{if(e.referral)try{await navigator.clipboard.writeText(e.referral.url),m(!0),Z.success(i(`setup:screen.toasts.referralCopied`)),setTimeout(()=>m(!1),2e3),ty(`referral_link_copied`,`engagement`,{label:e.name,metadata:{providerId:e.id,referralCode:e.referral.code,referralUrl:e.referral.url}})}catch{Z.error(i(`setup:screen.toasts.referralCopyFailed`)),ty(`referral_link_copy_failed`,`error`,{label:e.name,metadata:{providerId:e.id,referralCode:e.referral.code}})}},S=t&&t.modelCount>0;return(0,Y.jsxs)(`div`,{className:X(`rounded-xl border p-4 transition-all`,l?`border-emerald-500/30 bg-emerald-500/5`:`bg-gradient-to-br ${e.color}`),children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Y.jsx)(`span`,{className:`text-2xl shrink-0 mt-0.5`,children:e.icon}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),l&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded-full bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border border-emerald-500/20`,children:[(0,Y.jsx)(z,{className:`h-2.5 w-2.5`}),i(`setup:screen.card.keySaved`)]}),e.referral&&!l&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded-full bg-amber-500/10 text-amber-600 dark:text-amber-400 border border-amber-500/20`,children:[(0,Y.jsx)(Qn,{className:`h-2.5 w-2.5`}),i(`setup:screen.card.referral`)]})]}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e.description}),e.referral&&!l&&(0,Y.jsxs)(`p`,{className:`text-[11px] text-amber-600/80 dark:text-amber-400/80 mt-1`,children:[`🎁 `,e.referral.reward]}),l?S?(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>f(!d),className:`mt-2 text-[11px] text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1`,children:[i(`setup:screen.providers.modelsAvailable`,{count:t?.modelCount??0}),d?(0,Y.jsx)(bn,{className:`h-3 w-3`}):(0,Y.jsx)(Oe,{className:`h-3 w-3`})]}):null:(0,Y.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(Of,{type:`password`,placeholder:e.keyPlaceholder,value:a,onChange:e=>o(e.target.value),onKeyDown:b,className:`font-mono text-sm`}),(0,Y.jsx)($,{onClick:y,disabled:!a.trim()||s,size:`sm`,className:`shrink-0`,children:s?(0,Y.jsx)(B,{className:`h-4 w-4 animate-spin`}):i(`setup:screen.card.save`)})]}),e.docsUrl&&(0,Y.jsxs)(`a`,{href:e.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground transition-colors`,onClick:()=>{ty(`provider_docs_link_clicked`,`engagement`,{label:e.name,metadata:{providerId:e.id,docsUrl:e.docsUrl,hasReferral:!!e.referral}}),e.referral&&ry({providerId:e.id,providerName:e.name,referralCode:e.referral.code,clickedAt:new Date().toISOString(),docsUrl:e.docsUrl??``})},children:[i(`setup:screen.card.getKey`),` `,(0,Y.jsx)(Gt,{className:`h-3 w-3`})]}),e.referral&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:x,className:`inline-flex items-center gap-1 text-[11px] text-amber-600/80 dark:text-amber-400/80 hover:text-amber-700 dark:hover:text-amber-300 transition-colors`,children:p?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(z,{className:`h-3 w-3`}),` `,i(`setup:screen.card.copied`)]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Ft,{className:`h-3 w-3`}),` `,i(`setup:screen.card.copyReferral`)]})}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>g(!0),className:`inline-flex items-center gap-1 text-[11px] text-amber-600/80 dark:text-amber-400/80 hover:text-amber-700 dark:hover:text-amber-300 transition-colors`,children:[(0,Y.jsx)(lt,{className:`h-3 w-3`}),` `,i(`setup:screen.card.share`)]})]})]})]})]}),(0,Y.jsx)(bf,{open:h,onOpenChange:g,children:(0,Y.jsxs)(Cf,{className:`sm:max-w-md`,children:[(0,Y.jsxs)(wf,{children:[(0,Y.jsxs)(Ef,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Qn,{className:`h-4 w-4 text-amber-500`}),i(`setup:screen.share.title`,{name:e.name})]}),(0,Y.jsx)(Df,{children:i(`setup:screen.share.description`)})]}),(0,Y.jsx)(`div`,{className:`flex flex-col items-center gap-4 py-4`,children:e.referral&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`text-sm text-center`,children:(0,Y.jsxs)(`p`,{className:`font-medium text-amber-600 dark:text-amber-400`,children:[`🎁 `,e.referral.reward]})}),_?(0,Y.jsx)(`div`,{className:`rounded-lg border border-border p-2 bg-white`,children:(0,Y.jsx)(`img`,{src:_,alt:i(`setup:screen.card.qrAlt`,{name:e.name}),className:`w-[200px] h-[200px]`})}):(0,Y.jsx)(`div`,{className:`w-[200px] h-[200px] rounded-lg border border-border flex items-center justify-center bg-muted`,children:(0,Y.jsx)(B,{className:`h-6 w-6 animate-spin text-muted-foreground`})}),(0,Y.jsxs)(`div`,{className:`w-full space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-center gap-2`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{let t=encodeURIComponent(`Check out ${e.name}! 🎁 ${e.referral.reward}`),n=encodeURIComponent(e.referral.url);window.open(`https://twitter.com/intent/tweet?text=${t}&url=${n}`,`_blank`,`noopener,noreferrer`),ty(`referral_share_twitter`,`engagement`,{label:e.name,metadata:{providerId:e.id}})},className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-slate-900 text-white text-xs hover:bg-slate-800 transition-colors`,title:i(`setup:screen.share.twitter`),children:[(0,Y.jsx)(`svg`,{className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,Y.jsx)(`path`,{d:`M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z`})}),`X`]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{let t=encodeURIComponent(e.referral.url),n=encodeURIComponent(`Check out ${e.name}! ${e.referral.reward}`);window.open(`https://www.linkedin.com/sharing/share-offsite/?url=${t}&summary=${n}`,`_blank`,`noopener,noreferrer`),ty(`referral_share_linkedin`,`engagement`,{label:e.name,metadata:{providerId:e.id}})},className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-[#0A66C2] text-white text-xs hover:bg-[#0958a8] transition-colors`,title:i(`setup:screen.share.linkedin`),children:[(0,Y.jsx)(`svg`,{className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,Y.jsx)(`path`,{d:`M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z`})}),`LinkedIn`]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{let t=encodeURIComponent(`Check out ${e.name}! 🎁 ${e.referral.reward} ${e.referral.url}`);window.open(`https://t.me/share/url?url=${t}`,`_blank`,`noopener,noreferrer`),ty(`referral_share_telegram`,`engagement`,{label:e.name,metadata:{providerId:e.id}})},className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-[#26A5E4] text-white text-xs hover:bg-[#1e96d1] transition-colors`,title:i(`setup:screen.share.telegram`),children:[(0,Y.jsx)(`svg`,{className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,Y.jsx)(`path`,{d:`M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z`})}),`Telegram`]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{let t=encodeURIComponent(`Check out ${e.name}! 🎁 ${e.referral.reward}`),n=encodeURIComponent(e.referral.url);window.open(`https://wa.me/?text=${t}%20${n}`,`_blank`,`noopener,noreferrer`),ty(`referral_share_whatsapp`,`engagement`,{label:e.name,metadata:{providerId:e.id}})},className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-[#25D366] text-white text-xs hover:bg-[#1fb859] transition-colors`,title:i(`setup:screen.share.whatsapp`),children:[(0,Y.jsx)(`svg`,{className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,Y.jsx)(`path`,{d:`M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.134 1.585 5.934L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z`})}),`WhatsApp`]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{let t=encodeURIComponent(e.referral.url),n=encodeURIComponent(`${e.name} - ${e.referral.reward}`);window.open(`https://www.reddit.com/submit?url=${t}&title=${n}`,`_blank`,`noopener,noreferrer`),ty(`referral_share_reddit`,`engagement`,{label:e.name,metadata:{providerId:e.id}})},className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-[#FF4500] text-white text-xs hover:bg-[#e03d00] transition-colors`,title:i(`setup:screen.share.reddit`),children:[(0,Y.jsx)(`svg`,{className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,Y.jsx)(`path`,{d:`M12 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0zm5.01 4.744c.688 0 1.25.561 1.25 1.249a1.25 1.25 0 0 1-2.498.056l-2.597-.547-.8 3.747c1.824.07 3.48.632 4.674 1.488.308-.309.73-.491 1.207-.491.968 0 1.754.786 1.754 1.754 0 .716-.435 1.333-1.01 1.614a3.111 3.111 0 0 1 .042.52c0 2.694-3.13 4.87-7.004 4.87-3.874 0-7.004-2.176-7.004-4.87 0-.183.015-.366.043-.534A1.748 1.748 0 0 1 4.028 12c0-.968.786-1.754 1.754-1.754.463 0 .898.196 1.207.49 1.207-.883 2.878-1.43 4.744-1.487l.885-4.182a.342.342 0 0 1 .14-.197.35.35 0 0 1 .238-.042l2.906.617a1.214 1.214 0 0 0 1.108-.701 1.25 1.25 0 0 1 2.144.33zm-8.811 8.748c-.968 0-1.754.786-1.754 1.754 0 .968.786 1.754 1.754 1.754.968 0 1.754-.786 1.754-1.754 0-.968-.786-1.754-1.754-1.754zm7.944 0c-.968 0-1.754.786-1.754 1.754 0 .968.786 1.754 1.754 1.754.968 0 1.754-.786 1.754-1.754 0-.968-.786-1.754-1.754-1.754z`})}),`Reddit`]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{let t=encodeURIComponent(`Check out ${e.name}! 🎁 ${e.referral.reward}`),n=encodeURIComponent(e.referral.url);window.open(`https://www.facebook.com/sharer/sharer.php?u=${n}&quote=${t}`,`_blank`,`noopener,noreferrer`),ty(`referral_share_facebook`,`engagement`,{label:e.name,metadata:{providerId:e.id}})},className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-[#1877F2] text-white text-xs hover:bg-[#166fe5] transition-colors`,title:i(`setup:screen.share.facebook`),children:[(0,Y.jsx)(`svg`,{className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,Y.jsx)(`path`,{d:`M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z`})}),`Facebook`]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{let t=encodeURIComponent(`Check out ${e.name}! 🎁 ${e.referral.reward}`),n=encodeURIComponent(e.referral.url);window.open(`mailto:?subject=${t}&body=${n}`,`_blank`,`noopener,noreferrer`),ty(`referral_share_email`,`engagement`,{label:e.name,metadata:{providerId:e.id}})},className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-muted text-muted-foreground text-xs hover:bg-muted/80 transition-colors`,title:i(`setup:screen.share.email`),children:[(0,Y.jsx)(`svg`,{className:`h-3.5 w-3.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,viewBox:`0 0 24 24`,children:(0,Y.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25H4.5a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75`})}),`Email`]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Of,{value:e.referral.url,readOnly:!0,className:`font-mono text-xs flex-1`}),(0,Y.jsx)($,{size:`sm`,variant:`outline`,onClick:x,className:`shrink-0`,children:p?(0,Y.jsx)(z,{className:`h-4 w-4`}):(0,Y.jsx)(Ft,{className:`h-4 w-4`})})]}),(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground text-center`,children:i(`setup:screen.share.hint`)})]})]})})]})})]})}function dy({onKeySaved:e}){let{t}=V(),[n,r]=(0,U.useState)(!1),[i,a]=(0,U.useState)(``),[o,s]=(0,U.useState)(`openai-compatible`),[c,l]=(0,U.useState)(``),[u,d]=(0,U.useState)(``),[f,p]=(0,U.useState)(!1);return(0,Y.jsxs)(`div`,{className:`rounded-xl border border-dashed border-border/60 overflow-hidden`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>r(!n),className:`w-full flex items-center gap-3 p-4 text-left hover:bg-muted/30 transition-colors`,children:[(0,Y.jsx)(`div`,{className:`w-10 h-10 rounded-lg bg-muted/50 flex items-center justify-center`,children:(0,Y.jsx)(hn,{className:`h-5 w-5 text-muted-foreground`})}),(0,Y.jsxs)(`div`,{className:`flex-1`,children:[(0,Y.jsx)(`h3`,{className:`text-sm font-medium`,children:t(`setup:screen.custom.title`)}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`setup:screen.custom.description`)})]}),(0,Y.jsx)(Oe,{className:X(`h-4 w-4 text-muted-foreground transition-transform`,n&&`rotate-90`)})]}),n&&(0,Y.jsxs)(`div`,{className:`px-4 pb-4 space-y-3 border-t border-border/40`,children:[(0,Y.jsxs)(`div`,{className:`space-y-1.5 pt-3`,children:[(0,Y.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground block`,children:t(`setup:screen.custom.localServers`)}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:yv.map(e=>(0,Y.jsx)($,{type:`button`,size:`sm`,variant:i===e.id?`default`:`outline`,onClick:()=>{a(e.id),s(`openai-compatible`),l(e.defaultBaseUrl),e.noAuth&&d(``)},title:e.hint,children:e.label},e.id))})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`text-[11px] font-medium text-muted-foreground mb-1 block`,children:t(`setup:screen.custom.providerId`)}),(0,Y.jsx)(Of,{placeholder:`e.g. my-llm`,value:i,onChange:e=>a(e.target.value),className:`text-sm`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`text-[11px] font-medium text-muted-foreground mb-1 block`,children:t(`setup:screen.custom.family`)}),(0,Y.jsxs)(`select`,{value:o,onChange:e=>s(e.target.value),className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 text-sm`,children:[(0,Y.jsx)(`option`,{value:`openai-compatible`,children:t(`setup:screen.custom.familyOpenAiCompatible`)}),(0,Y.jsx)(`option`,{value:`openai`,children:`OpenAI`}),(0,Y.jsx)(`option`,{value:`anthropic`,children:`Anthropic`}),(0,Y.jsx)(`option`,{value:`google`,children:`Google`})]})]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`text-[11px] font-medium text-muted-foreground mb-1 block`,children:t(`setup:screen.custom.baseUrl`)}),(0,Y.jsx)(Of,{placeholder:`e.g. http://localhost:11434/v1`,value:c,onChange:e=>l(e.target.value),className:`text-sm font-mono`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`text-[11px] font-medium text-muted-foreground mb-1 block`,children:t(`setup:screen.custom.apiKey`)}),(0,Y.jsx)(Of,{type:`password`,placeholder:t(`setup:screen.custom.apiKeyPlaceholder`),value:u,onChange:e=>d(e.target.value),className:`text-sm font-mono`})]}),(0,Y.jsxs)($,{onClick:async()=>{if(i.trim()){p(!0);try{W(K.getState().wsUrl).send({type:`provider.add`,payload:{id:i.trim(),family:o,baseUrl:c.trim()||void 0,apiKey:u.trim()||void 0}}),Z.success(t(`setup:screen.toasts.providerAdded`,{id:i.trim()})),e(i.trim()),a(``),l(``),d(``),r(!1)}catch{Z.error(t(`setup:screen.toasts.providerAddFailed`))}finally{p(!1)}}},disabled:!i.trim()||f,size:`sm`,children:[f?(0,Y.jsx)(B,{className:`h-4 w-4 animate-spin mr-2`}):null,t(`setup:screen.custom.add`)]})]})]})}function fy(){let{t:e}=V(),{model:t,setProvider:n,setModel:r,wsConnected:i,wsUrl:a}=K();sd();let[o,s]=(0,U.useState)(`keys`),[c,l]=(0,U.useState)([]),[u,d]=(0,U.useState)({}),[f,m]=(0,U.useState)([]),[h,g]=(0,U.useState)(!1),[_,v]=(0,U.useState)(null),[y,x]=(0,U.useState)(0),[S,C]=(0,U.useState)(new Set),[w,T]=(0,U.useState)(cy),[E,D]=(0,U.useState)(!1),[O,k]=(0,U.useState)(0),[A,M]=(0,U.useState)(0),[N,P]=(0,U.useState)(null),F=(0,U.useRef)(!0);(0,U.useEffect)(()=>{let e=new AbortController,t=`${window.location.origin}/providers.json`,n=`https://raw.githubusercontent.com/WrongStack/WrongStack/main/packages/webui/public/providers.json`;return D(!0),ly(t,e.signal).then(r=>{if(r!==cy){if(T(r),D(!1),ty(`providers_loaded`,`system`,{label:`local`,metadata:{providerCount:r.length,source:t}}),!F.current){let e=r.length-A;e>0?Z.success(b.t(`setup:screen.toasts.providersLoadedNew`,{count:r.length,diff:e})):e<0?Z.success(b.t(`setup:screen.toasts.providersLoadedRemoved`,{count:r.length,diff:Math.abs(e)})):Z.success(b.t(`setup:screen.toasts.providersLoadedNoChanges`,{count:r.length})),M(r.length)}P(new Date);return}return ly(n,e.signal)}).then(e=>{if(e){if(T(e),ty(`providers_loaded`,`system`,{label:`github`,metadata:{providerCount:e.length,source:n}}),!F.current){let t=e.length-A;t>0?Z.success(b.t(`setup:screen.toasts.providersLoadedNew`,{count:e.length,diff:t})):t<0?Z.success(b.t(`setup:screen.toasts.providersLoadedRemoved`,{count:e.length,diff:Math.abs(t)})):Z.success(b.t(`setup:screen.toasts.providersLoadedNoChanges`,{count:e.length})),M(e.length)}P(new Date)}}).catch(()=>{ty(`providers_load_failed`,`error`,{metadata:{localUrl:t,githubUrl:n}}),F.current||Z.error(b.t(`setup:screen.toasts.providersRefreshFailed`))}).finally(()=>{D(!1),F.current=!1}),()=>e.abort()},[O]);let[I,L]=(0,U.useState)(null),[R,ee]=(0,U.useState)(null),[te,ne]=(0,U.useState)(!1);(0,U.useEffect)(()=>{if(!i)return;let e=W(a),n=setTimeout(()=>{n=null,g(!1),v(b.t(`setup:screen.errors.backendNotResponding`))},8e3),r=()=>{n&&=(clearTimeout(n),null)},o=e.on(`provider.catalog`,e=>{e.type===`provider.catalog`&&(r(),v(null),l(e.payload.providers.sort((e,t)=>e.id.localeCompare(t.id))),g(!1))}),s=e.on(`provider.models`,e=>{if(e.type===`provider.models`){let n=e.payload;d(e=>({...e,[n.provider]:n.models})),ne(!1),n.models.length===1?ee(n.models[0].id):t&&n.models.some(e=>e.id===t)&&ee(t)}}),c=e.on(`providers.saved`,e=>{if(e.type===`providers.saved`){let t=e.payload.providers.sort((e,t)=>e.id.localeCompare(t.id));m(t),C(new Set(t.filter(e=>e.apiKeys.some(e=>e.isActive)).map(e=>e.id)))}});return v(null),g(!0),e.listProviders(),()=>{r(),o?.(),s?.(),c?.()}},[i,a,t,y]);let re=(0,U.useCallback)(()=>{v(null),x(e=>e+1)},[]),ie=(0,U.useCallback)(()=>{k(e=>e+1),ty(`providers_refresh_clicked`,`engagement`,{metadata:{currentProviderCount:w.length}})},[w.length]),ae=(0,U.useCallback)(t=>{let n=new Date().getTime()-t.getTime(),r=Math.floor(n/1e3);if(r<10)return e(`setup:screen.time.justNow`);if(r<60)return e(`setup:screen.time.secondsAgo`,{count:r});let i=Math.floor(r/60);if(i<60)return e(`setup:screen.time.minutesAgo`,{count:i});let a=Math.floor(i/60);return a<24?e(`setup:screen.time.hoursAgo`,{count:a}):e(`setup:screen.time.daysAgo`,{count:Math.floor(a/24)})},[e]),oe=(0,U.useCallback)(e=>{C(t=>new Set([...t,e]))},[]),se=S.size>0,ce=(0,U.useCallback)(()=>{if(!se){if(f.length>0){let e=f[0];L(e.id),s(`done`)}return}let e=f.find(e=>e.apiKeys.some(e=>e.isActive));e&&(L(e.id),s(`done`))},[se,f]);(0,U.useEffect)(()=>{if(!I||!i||o!==`done`)return;let e=W(a);u[I]||(ne(!0),e.listProviderModels(I))},[I,i,a,u,o]);let le=I?u[I]??[]:[],ue=(0,U.useCallback)(()=>{if(!I||!R)return;n(I),r(R);let e=W(a);e.switchModel(I,R);let t=null,i=()=>{t&&clearTimeout(t)},o=e.on(`key.operation_result`,t=>{let n=t.payload;i(),o(),n.success?(e.newSession(),Q(`chat`)):Z.error(n.message)});t=setTimeout(()=>{i(),o(),Z.error(b.t(`setup:screen.errors.modelSwitchTimeout`))},5e3)},[I,R,n,r,a]),de=new Set(w.map(e=>e.id)),fe=c.filter(e=>!de.has(e.id)).sort((e,t)=>e.id.localeCompare(t.id));return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Y.jsxs)(`header`,{className:`flex items-center justify-between px-6 py-4 border-b bg-card shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-gradient-to-br from-primary via-primary to-primary/60 flex items-center justify-center`,children:(0,Y.jsx)(tn,{className:`h-5 w-5 text-primary-foreground`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h1`,{className:`text-lg font-semibold`,children:e(`setup:screen.header.title`)}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`setup:screen.header.subtitle`)})]})]}),se&&(0,Y.jsxs)($,{onClick:ce,size:`sm`,children:[e(`setup:screen.header.continue`),(0,Y.jsx)(it,{className:`h-4 w-4 ml-1.5`})]})]}),(0,Y.jsx)(Th,{className:`min-h-0 flex-1`,children:o===`keys`?(0,Y.jsxs)(`div`,{className:`p-6 max-w-3xl mx-auto space-y-8`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-primary font-medium`,children:[(0,Y.jsx)(he,{className:`h-4 w-4`}),(0,Y.jsx)(`span`,{children:e(`setup:screen.steps.addKeys`)})]}),(0,Y.jsx)(Oe,{className:`h-4 w-4 text-muted-foreground`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Y.jsx)(j,{className:`h-4 w-4`}),(0,Y.jsx)(`span`,{children:e(`setup:screen.steps.pickModel`)})]}),(0,Y.jsx)(Oe,{className:`h-4 w-4 text-muted-foreground`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Y.jsx)(bt,{className:`h-4 w-4`}),(0,Y.jsx)(`span`,{children:e(`setup:screen.steps.start`)})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl border border-primary/20 bg-primary/5 p-4`,children:[(0,Y.jsx)(p,{className:`h-5 w-5 text-primary shrink-0 mt-0.5`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:`text-sm font-medium`,children:e(`setup:screen.security.title`)}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`setup:screen.security.body`)})]})]}),_?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center text-center gap-4 py-12 rounded-xl border border-destructive/30 bg-destructive/5 px-6`,children:[(0,Y.jsx)(`div`,{className:`w-12 h-12 rounded-xl bg-destructive/10 border border-destructive/30 flex items-center justify-center`,children:(0,Y.jsx)($e,{className:`h-6 w-6 text-destructive`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:`text-sm font-medium text-destructive`,children:e(`setup:screen.errors.backendUnreachable`)}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 max-w-sm`,children:_})]}),(0,Y.jsxs)($,{onClick:re,size:`sm`,variant:`outline`,children:[(0,Y.jsx)(B,{className:`h-4 w-4 mr-2`}),e(`setup:screen.errors.retry`)]})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-medium text-muted-foreground uppercase tracking-wider`,children:e(`setup:screen.providers.popular`)}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[E&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-muted-foreground`,children:[(0,Y.jsx)(B,{className:`h-3 w-3 animate-spin`}),e(`setup:screen.providers.updating`)]}),N&&!E&&(0,Y.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,title:N.toLocaleString(),children:ae(N)}),(0,Y.jsxs)(`button`,{type:`button`,onClick:ie,disabled:E,className:`inline-flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,title:e(`setup:screen.providers.refreshTitle`),children:[(0,Y.jsx)(Rn,{className:X(`h-3 w-3`,E&&`animate-spin`)}),e(`setup:screen.providers.refresh`)]})]})]}),(0,Y.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:w.map(e=>(0,Y.jsx)(uy,{popular:e,catalogProvider:c.find(t=>t.id===e.id),savedProvider:f.find(t=>t.id===e.id),onKeySaved:oe},e.id))})]}),fe.length>0&&(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-medium text-muted-foreground uppercase tracking-wider`,children:e(`setup:screen.providers.more`)}),(0,Y.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:fe.map(t=>(0,Y.jsx)(uy,{popular:{id:t.id,name:t.name,description:e(`setup:screen.providers.catalogDescription`,{family:t.family,count:t.modelCount}),icon:`🔗`,color:`from-slate-500/20 to-slate-500/5 border-slate-500/30 hover:border-slate-500/50`,keyPlaceholder:`API key`,family:t.family},catalogProvider:t,savedProvider:f.find(e=>e.id===t.id),onKeySaved:oe},t.id))})]}),(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-medium text-muted-foreground uppercase tracking-wider`,children:e(`setup:screen.providers.selfHosted`)}),(0,Y.jsx)(dy,{onKeySaved:oe})]})]}),h&&(0,Y.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Y.jsx)(B,{className:`h-6 w-6 animate-spin text-muted-foreground`})}),se&&(0,Y.jsx)(`div`,{className:`sticky bottom-0 bg-background/80 backdrop-blur-sm py-4 -mx-6 px-6 border-t`,children:(0,Y.jsxs)($,{onClick:ce,className:`w-full`,size:`lg`,children:[(0,Y.jsx)(j,{className:`h-4 w-4 mr-2`}),e(`setup:screen.start.pickAndStart`),(0,Y.jsx)(it,{className:`h-4 w-4 ml-2`})]})})]}):(0,Y.jsxs)(`div`,{className:`p-6 max-w-2xl mx-auto space-y-8`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-emerald-500`,children:[(0,Y.jsx)(z,{className:`h-4 w-4`}),(0,Y.jsx)(`span`,{children:e(`setup:screen.steps.keys`)})]}),(0,Y.jsx)(Oe,{className:`h-4 w-4 text-muted-foreground`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-primary font-medium`,children:[(0,Y.jsx)(j,{className:`h-4 w-4`}),(0,Y.jsx)(`span`,{children:e(`setup:screen.steps.pickModel`)})]}),(0,Y.jsx)(Oe,{className:`h-4 w-4 text-muted-foreground`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Y.jsx)(bt,{className:`h-4 w-4`}),(0,Y.jsx)(`span`,{children:e(`setup:screen.steps.start`)})]})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>s(`keys`),className:`text-xs text-muted-foreground hover:text-foreground transition-colors`,children:e(`setup:screen.start.addMoreKeys`)}),(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsxs)(`h2`,{className:`text-base font-semibold flex items-center gap-2`,children:[(0,Y.jsx)(j,{className:`h-4 w-4 text-primary`}),e(`setup:screen.start.chooseProvider`)]}),(0,Y.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 gap-2`,children:f.map(t=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{L(t.id),ee(null)},className:X(`rounded-lg border p-3 text-left transition-all text-sm`,I===t.id?`border-primary bg-primary/10 ring-1 ring-primary/30`:`border-border hover:border-primary/40 hover:bg-primary/5`),children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:t.id}),(0,Y.jsx)(`span`,{className:`block text-[11px] text-muted-foreground mt-0.5`,children:e(`setup:screen.start.activeKeys`,{count:t.apiKeys.filter(e=>e.isActive).length})})]},t.id))})]}),I&&(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsxs)(`h2`,{className:`text-base font-semibold flex items-center gap-2`,children:[(0,Y.jsx)(bt,{className:`h-4 w-4 text-primary`}),e(`setup:screen.start.chooseModel`)]}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`setup:screen.start.modelsFor`,{provider:I})}),te?(0,Y.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Y.jsx)(B,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):le.length>0?(0,Y.jsx)(`div`,{className:`grid grid-cols-1 gap-2`,children:le.map(e=>{let t=e.contextWindow?`${(e.contextWindow/1e6).toFixed(0)}M ctx`:null;return(0,Y.jsx)(`button`,{type:`button`,onClick:()=>ee(e.id),className:X(`w-full text-left rounded-xl border p-3 transition-all`,`hover:border-primary/40 hover:bg-primary/5`,R===e.id?`border-primary bg-primary/10 ring-1 ring-primary/30`:`border-border bg-card`),children:(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-sm`,children:e.name}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1`,children:[t&&(0,Y.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:t}),e.capabilities.slice(0,3).map(e=>(0,Y.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary border border-primary/20`,children:e},e))]})]}),R===e.id&&(0,Y.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-primary flex items-center justify-center shrink-0`,children:(0,Y.jsx)(z,{className:`h-3 h-3 text-primary-foreground`})})]})},e.id)})}):(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground py-8 text-center`,children:e(`setup:screen.errors.noModels`)})]}),I&&R&&(0,Y.jsxs)(`div`,{className:`sticky bottom-0 bg-background/80 backdrop-blur-sm py-4 -mx-6 px-6 border-t`,children:[(0,Y.jsx)(`div`,{className:`flex items-center justify-between text-sm text-muted-foreground mb-3`,children:(0,Y.jsxs)(`span`,{children:[I,` / `,R]})}),(0,Y.jsxs)($,{onClick:ue,className:`w-full`,size:`lg`,children:[(0,Y.jsx)(j,{className:`h-4 w-4 mr-2`}),e(`setup:screen.start.startSession`),(0,Y.jsx)(it,{className:`h-4 w-4 ml-2`})]})]})]})})]})}var py=[{sectionKey:`sectionGlobal`,items:[{keys:[`Ctrl`,`K`],descKey:`dCommandPalette`},{keys:[`?`],descKey:`dShowOverlay`},{keys:[`Ctrl`,`\\`],descKey:`dToggleSidebar`},{keys:[`Ctrl`,`1-8`],descKey:`dOpenPanel`},{keys:[`Ctrl`,`0`],descKey:`dDesignStudio`},{keys:[`Ctrl`,`Shift`,`W`],descKey:`dWorktrees`},{keys:[`Ctrl`,`/`],descKey:`dFocusInput`}]},{sectionKey:`sectionTuiParity`,items:[{keys:[`F1`],descKey:`dSessionPanel`},{keys:[`F2`],descKey:`dFleetOverlay`},{keys:[`F3`],descKey:`dAgentsOverlay`},{keys:[`F4`],descKey:`dWorktreeMonitor`},{keys:[`F5`],descKey:`dPlanPanel`},{keys:[`F6`],descKey:`dTodosPanel`},{keys:[`F7`],descKey:`dQueuePanel`},{keys:[`F8`],descKey:`dProcessMonitor`},{keys:[`F9`],descKey:`dGoalPanel`},{keys:[`F10`],descKey:`dSessionsDashboard`},{keys:[`F11`],descKey:`dOfficeMap`},{keys:[`F12`],descKey:`dDockPicker`}]},{sectionKey:`sectionFleet`,items:[{keys:[`Ctrl`,`Shift`,`M`],descKey:`dOpenFleet`},{keys:[`Ctrl`,`Shift`,`A`],descKey:`dOpenAgents`},{keys:[`↑`,`↓`],descKey:`dNavigateAgents`},{keys:[`Enter`],descKey:`dSelectAgent`},{keys:[`Esc`],descKey:`dCloseOverlay`}]},{sectionKey:`sectionChatInput`,items:[{keys:[`Enter`],descKey:`dSendMessage`},{keys:[`Shift`,`Enter`],descKey:`dNewline`},{keys:[`↑`],descKey:`dRecallPrev`},{keys:[`↓`],descKey:`dRecallNext`},{keys:[`/`],descKey:`dSlashPopup`},{keys:[`Tab`],descKey:`dAutocomplete`},{keys:[`Esc`],descKey:`dDismissPopup`}]},{sectionKey:`sectionChat`,items:[{keys:[`Ctrl`,`F`],descKey:`dSearchChat`},{keys:[`Ctrl`,`L`],descKey:`dClearContext`},{keys:[`Ctrl`,`N`],descKey:`dNewSession`},{keys:[`Ctrl`,`E`],descKey:`dExportMarkdown`},{keys:[`Ctrl`,`M`],descKey:`dModelSwitcher`},{keys:[`Ctrl`,`Shift`,`D`],descKey:`dCompactDensity`},{keys:[`Esc`],descKey:`dAbortRun`}]},{sectionKey:`sectionChatNav`,items:[{keys:[`j`],descKey:`dFocusNext`},{keys:[`k`],descKey:`dFocusPrev`},{keys:[`g`],descKey:`dJumpFirst`},{keys:[`Shift`,`G`],descKey:`dJumpLast`},{keys:[`c`],descKey:`dCopyFocused`},{keys:[`Esc`],descKey:`dClearFocused`}]}];function my(){let{t:e}=V(),t=J(e=>e.shortcutsOpen),n=J(e=>e.setShortcutsOpen);return(0,U.useEffect)(()=>{let e=e=>{let t=e.target,r=t?.tagName?.toLowerCase();if(!(r===`input`||r===`textarea`||t?.isContentEditable)&&e.key===`?`&&!e.ctrlKey&&!e.metaKey&&!e.altKey){e.preventDefault(),n(!J.getState().shortcutsOpen);return}e.key===`Escape`&&J.getState().shortcutsOpen&&(e.preventDefault(),n(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),t?(0,Y.jsx)(`div`,{className:`fixed inset-0 z-50 bg-background/60 backdrop-blur-sm flex items-center justify-center px-4`,onClick:()=>n(!1),onKeyDown:e=>{e.key===`Escape`&&n(!1)},children:(0,Y.jsxs)(`div`,{onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),className:`w-full max-w-2xl rounded-xl border bg-popover shadow-2xl overflow-hidden flex flex-col max-h-[80dvh]`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-4 border-b`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(A,{className:`h-4 w-4 text-muted-foreground`}),(0,Y.jsx)(`h2`,{className:`text-sm font-semibold`,children:e(`activity:shortcuts.heading`)})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>n(!1),className:`text-muted-foreground hover:text-foreground p-1 rounded hover:bg-muted`,children:(0,Y.jsx)(Xn,{className:`h-4 w-4`})})]}),(0,Y.jsx)(`div`,{className:`overflow-y-auto px-5 py-4 space-y-6`,children:py.map(t=>(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground mb-2`,children:e(`activity:shortcuts.${t.sectionKey}`)}),(0,Y.jsx)(`div`,{className:`grid grid-cols-1 gap-1.5`,children:t.items.map(t=>(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-sm px-2 py-1.5 rounded hover:bg-muted/40`,children:[(0,Y.jsx)(`span`,{className:`text-foreground/80`,children:e(`activity:shortcuts.${t.descKey}`)}),(0,Y.jsx)(`span`,{className:`flex items-center gap-1 shrink-0`,children:t.keys.map((e,t)=>(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[t>0&&(0,Y.jsx)(`span`,{className:`text-muted-foreground/40 text-xs`,children:`+`}),(0,Y.jsx)(`kbd`,{className:`font-mono text-[10px] border rounded px-1.5 py-0.5 bg-background`,children:e})]},e))})]},t.descKey))})]},t.sectionKey))}),(0,Y.jsxs)(`div`,{className:`border-t px-5 py-3 text-xs text-muted-foreground`,children:[e(`activity:shortcuts.footerPre`),` `,(0,Y.jsx)(`kbd`,{className:`font-mono text-[10px] border rounded px-1 py-0.5 bg-background`,children:`?`}),` `,e(`activity:shortcuts.footerPost`)]})]})}):null}function hy({node:e,depth:t,selectedPath:n,forceExpand:i,onSelect:a,onOpen:o,onContextMenu:s}){let{t:c}=V(),[l,u]=(0,U.useState)(t<1),d=ic(e=>e.activeFilePath),f=e.type===`file`&&e.path===d;if((0,U.useEffect)(()=>{i!==null&&u(i)},[i]),e.type===`directory`){let d=(e.children?.length??0)>0,f=l?Fe:dt,p=e.name===`.git`,m=lp(e.name,!0);return(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>u(e=>!e),onContextMenu:t=>s(t,e),className:X(`flex items-center gap-1 w-full text-left px-1 py-0.5 text-[11px] rounded`,`hover:bg-muted/60 transition-colors`),style:{paddingLeft:`${t*14+4}px`},children:[(0,Y.jsx)(Oe,{className:X(`h-3 w-3 shrink-0 text-muted-foreground transition-transform`,l&&`rotate-90`)}),p?(0,Y.jsx)(r,{className:X(`h-3.5 w-3.5 shrink-0`,m)}):(0,Y.jsx)(f,{className:X(`h-3.5 w-3.5 shrink-0`,m)}),(0,Y.jsx)(`span`,{className:`truncate font-medium flex-1 min-w-0`,children:e.name})]}),l&&d&&(0,Y.jsx)(`div`,{children:(e.children??[]).map(e=>(0,Y.jsx)(hy,{node:e,depth:t+1,selectedPath:n,forceExpand:i,onSelect:a,onOpen:o,onContextMenu:s},e.path))}),l&&!d&&(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground italic py-0.5`,style:{paddingLeft:`${(t+1)*14+4}px`},children:c(`activity:fileExplorer.emptyDir`)})]})}let p=up(e.name),m=lp(e.name,!1),h=e.path===n;return(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>a(e.path),onContextMenu:t=>s(t,e),onDoubleClick:t=>{t.preventDefault(),o(e.path)},className:X(`flex items-center gap-1.5 w-full text-left px-1 py-0.5 text-[11px] rounded`,`hover:bg-muted/60 transition-colors`,f&&`bg-primary/10 text-primary`,h&&!f&&`bg-muted/70 ring-1 ring-inset ring-border`),style:{paddingLeft:`${t*14+4}px`},children:[(0,Y.jsx)(`span`,{className:`w-3 shrink-0`}),` `,(0,Y.jsx)(p,{className:X(`h-3.5 w-3.5 shrink-0`,m)}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.name})]})}function gy(){let{t:e}=V(),t=ic(e=>e.tree),n=ic(e=>e.treeLoading),r=ic(e=>e.error),i=ic(e=>e.openFiles),a=ic(e=>e.activeFilePath),o=q(e=>e.cwd),s=q(e=>e.projectName),c=o?.includes(`\\`)?`\\`:`/`,l=(e,t=8,n=4)=>e.length<=t+n+2?e:`${e.slice(0,t)}…${e.slice(-n)}`,u=(()=>{if(!o||!s)return!0;let e=o.replace(/\\/g,`/`).split(`/`).filter(Boolean);return(e[e.length-1]??``)===s})(),d=(0,U.useMemo)(()=>{if(!o||!s)return[];let e=o.replace(/\\/g,`/`).split(`/`).filter(Boolean),t=-1;for(let n=e.length-1;n>=0;n--)if(e[n]===s){t=n;break}if(t===-1)return e.map((t,n)=>({label:t,path:`/`+e.slice(0,n+1).join(`/`),isLast:n===e.length-1}));let n=e.slice(t);return n.map((r,i)=>({label:r,path:`/`+e.slice(0,t+i+1).join(`/`),isLast:i===n.length-1}))},[o,s]),f=(0,U.useRef)(null);(0,U.useEffect)(()=>{let e=f.current;e&&d.length>1&&(e.scrollLeft=e.scrollWidth)},[d]);let p=(0,U.useCallback)(e=>{W().send({type:`working_dir.set`,payload:{path:e}})},[]),[m,h]=(0,U.useState)(null),[g,_]=(0,U.useState)(null),v=(0,U.useCallback)((e,t)=>{e.preventDefault(),e.stopPropagation(),_({x:e.clientX,y:e.clientY,node:t})},[]),y=(0,U.useCallback)(e=>{e.type===`file`&&(lc.getState().addRef({kind:`file`,path:e.path}),Q(`chat`)),_(null)},[]);(0,U.useEffect)(()=>{if(!m&&!g)return;let e=()=>{h(null),_(null)},t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`click`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`click`,e),window.removeEventListener(`keydown`,t)}},[m,g]);let b=(0,U.useCallback)((e,t)=>{e.preventDefault(),e.stopPropagation(),h({x:e.clientX,y:e.clientY,crumb:t})},[]),x=(0,U.useCallback)(e=>{navigator.clipboard.writeText(e),h(null)},[]),S=(0,U.useCallback)(()=>{if(!a)return;let e=a.replace(/\\/g,`/`).split(`/`).slice(0,-1).join(`/`)||`.`;W().send({type:`working_dir.set`,payload:{path:e}})},[a]),C=(0,U.useCallback)((e,t)=>{W().send({type:`shell.open`,payload:{path:e,target:t}}),h(null)},[]),w=(0,U.useCallback)(()=>{if(!o)return;let e=o.replace(/\\/g,`/`),t=e.split(`/`).slice(0,-1).join(`/`)||e;W().send({type:`working_dir.set`,payload:{path:t}})},[o]),[T,E]=(0,U.useState)(!1),D=(0,U.useRef)(null);(0,U.useEffect)(()=>(n?D.current=setTimeout(()=>E(!0),150):(D.current&&clearTimeout(D.current),E(!1)),()=>{D.current&&clearTimeout(D.current)}),[n]);let[O,k]=(0,U.useState)(null),[A,j]=(0,U.useState)(null),M=(0,U.useMemo)(()=>{let e=0,n=t=>{for(let r of t)r.type===`directory`&&e++,r.children&&n(r.children)};return n(t),e},[t]),N=(0,U.useMemo)(()=>{let e=0,n=0;for(let r of t)r.type===`directory`?n++:e++;return{files:e,dirs:n}},[t]),P={value:!1},F=(0,U.useCallback)(()=>{P.value=!0,j(!1),setTimeout(()=>{P.value=!1},400)},[]),I=(0,U.useCallback)(()=>{P.value=!0,j(!0),setTimeout(()=>{P.value=!1},400)},[]),L=(0,U.useCallback)(e=>{if(i.find(t=>t.path===e)){ic.getState().setActiveFile(e);return}k(t=>t===e?null:e)},[i]),R=(0,U.useCallback)(e=>{window.dispatchEvent(new CustomEvent(`wrongstack:open-file`,{detail:{filePath:e}})),k(null)},[]);return(0,U.useEffect)(()=>{a&&k(null)},[a]),T?(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-full py-8`,children:(0,Y.jsx)(B,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):r?(0,Y.jsx)(`div`,{className:`p-3 text-[11px] text-destructive`,children:e(`activity:fileExplorer.loadFailed`,{error:r})}):(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col overflow-hidden`,children:[t.length>0&&M>0&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-0.5 px-2 py-0.5 border-b shrink-0`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:I,className:X(`flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] transition-colors`,`hover:bg-muted/60 text-muted-foreground hover:text-foreground`),title:e(`activity:fileExplorer.expandAllTitle`),children:[(0,Y.jsx)(ht,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:e(`activity:fileExplorer.expandAll`)})]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:F,className:X(`flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] transition-colors`,`hover:bg-muted/60 text-muted-foreground hover:text-foreground`),title:e(`activity:fileExplorer.collapseAllTitle`),children:[(0,Y.jsx)(Cr,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:e(`activity:fileExplorer.collapse`)})]}),(0,Y.jsx)(`span`,{className:`ml-auto text-[9px] text-muted-foreground/50 tabular-nums`,children:e(`activity:fileExplorer.folders`,{count:M})})]}),(0,Y.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto py-1`,children:[d.length>0&&(0,Y.jsxs)(`div`,{ref:f,className:`relative flex items-center gap-0.5 px-1 pb-1 border-b border-border/30 overflow-x-auto`,children:[(0,Y.jsx)(`span`,{className:`sticky left-0 shrink-0 w-3 h-full bg-gradient-to-r from-background to-transparent pointer-events-none`}),d.map((t,n)=>{let r=t.isLast?t.label:l(t.label),i=t.path.replace(/\//g,c),a=o?o.replace(/\\/g,`/`).split(`/`).filter(Boolean):[],u=(()=>{for(let e=a.length-1;e>=0;e--)if(a[e]===s)return e;return-1})(),d=u>=0?a.slice(0,u+n+1):a.slice(0,n+1),f=c===`\\`?d.join(`\\`):`/`+d.join(`/`),m=(u>=0?a.slice(u+1,u+n+1):[]).join(c)||`.`;return(0,Y.jsxs)(`span`,{className:`flex items-center gap-0.5 shrink-0`,children:[n>0&&(0,Y.jsx)(`span`,{className:`text-[9px] text-muted-foreground/40 select-none`,children:c}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>p(t.path),onContextMenu:e=>b(e,{absPath:f,relPath:m}),className:X(`px-1 py-0.5 rounded text-[11px] transition-colors whitespace-nowrap`,t.isLast?`text-foreground font-medium`:`text-muted-foreground hover:text-foreground hover:bg-muted/60`),title:t.isLast?e(`activity:fileExplorer.currentDirTitle`,{path:i}):e(`activity:fileExplorer.navigateToTitle`,{path:i}),children:r})]},t.path)}),t.length>0&&(0,Y.jsxs)(`span`,{className:`ml-auto shrink-0 text-[9px] text-muted-foreground/50 tabular-nums pl-2`,children:[N.files>0&&e(`activity:fileExplorer.filesSuffix`,{count:N.files}),N.files>0&&N.dirs>0&&`, `,N.dirs>0&&e(`activity:fileExplorer.folders`,{count:N.dirs})]})]}),a&&(0,Y.jsxs)(`button`,{type:`button`,onClick:S,className:`flex items-center gap-1 w-full text-left px-2 py-0.5 border-b border-border/30 text-[10px] text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors`,title:e(`activity:fileExplorer.navigateParentTitle`,{path:a.replace(/\//g,c)}),children:[(0,Y.jsx)(Bt,{className:`h-3 w-3 shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate`,children:(()=>{let e=a.replace(/\\/g,`/`).split(`/`);return e[e.length-1]??a})()}),(0,Y.jsx)(`span`,{className:`ml-auto text-[8px] text-muted-foreground/40 shrink-0`,children:e(`activity:fileExplorer.goToDir`)})]}),d.length===0&&!u&&(0,Y.jsxs)(`button`,{type:`button`,onClick:w,className:X(`flex items-center gap-1.5 w-full text-left px-1 py-0.5 text-[11px] rounded`,`hover:bg-muted/60 transition-colors text-muted-foreground hover:text-foreground`,`font-medium`),children:[(0,Y.jsx)(Lr,{className:`h-3.5 w-3.5 shrink-0`}),(0,Y.jsx)(`span`,{children:`..`}),(0,Y.jsx)(`span`,{className:`text-[9px] text-muted-foreground/50 ml-auto`,children:e(`activity:fileExplorer.parentDirectory`)})]}),t.map(e=>(0,Y.jsx)(hy,{node:e,depth:0,selectedPath:O,forceExpand:A,onSelect:L,onOpen:R,onContextMenu:v},e.path)),t.length===0&&(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground italic p-2`,children:e(`activity:fileExplorer.noFiles`)})]}),m&&(0,Y.jsxs)(`div`,{className:`fixed z-50 min-w-[140px] bg-popover border rounded-md shadow-md py-1 text-[11px]`,style:{left:m.x,top:m.y},children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>x(m.crumb.absPath),className:`flex items-center gap-2 w-full text-left px-3 py-1.5 hover:bg-accent transition-colors`,children:e(`activity:fileExplorer.copyAbsPath`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>x(m.crumb.relPath),className:`flex items-center gap-2 w-full text-left px-3 py-1.5 hover:bg-accent transition-colors`,children:e(`activity:fileExplorer.copyRelPath`)}),(0,Y.jsx)(`div`,{className:`border-t border-border/50 my-0.5`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>C(m.crumb.absPath,`terminal`),className:`flex items-center gap-2 w-full text-left px-3 py-1.5 hover:bg-accent transition-colors`,children:e(`activity:fileExplorer.openInTerminal`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>C(m.crumb.absPath,`file-manager`),className:`flex items-center gap-2 w-full text-left px-3 py-1.5 hover:bg-accent transition-colors`,children:e(`activity:fileExplorer.openInFileManager`)}),(0,Y.jsx)(`div`,{className:`border-t border-border/50 mt-0.5 pt-0.5`,children:(0,Y.jsx)(`div`,{className:`px-3 py-1 text-[9px] text-muted-foreground/50 truncate max-w-[200px]`,children:m.crumb.absPath})})]}),g&&(0,Y.jsxs)(`div`,{className:`fixed z-50 min-w-[160px] bg-popover border rounded-md shadow-md py-1 text-[11px]`,style:{left:g.x,top:g.y},children:[g.node.type===`file`&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>y(g.node),className:`flex items-center gap-2 w-full text-left px-3 py-1.5 hover:bg-accent transition-colors`,children:e(`activity:fileExplorer.mentionInChat`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{navigator.clipboard.writeText(g.node.path),_(null)},className:`flex items-center gap-2 w-full text-left px-3 py-1.5 hover:bg-accent transition-colors`,children:e(`activity:fileExplorer.copyPath`)}),(0,Y.jsx)(`div`,{className:`border-t border-border/50 mt-0.5 pt-0.5`,children:(0,Y.jsx)(`div`,{className:`px-3 py-1 text-[9px] text-muted-foreground/50 truncate max-w-[200px]`,children:g.node.path})})]})]})}var _y={note:gn,ask:ln,assign:er,steer:xt,btw:ge,broadcast:er,status:Or,result:rn};function vy(e){let t=new Date(e),n=Date.now()-t.getTime();return n<6e4?b.t(`activity:mailbox.timeNow`):n<36e5?`${Math.round(n/6e4)}m`:n<864e5?`${Math.round(n/36e5)}h`:t.toLocaleDateString()}function yy({className:e}){let t=bs(e=>e.messages),n=bs(e=>e.agents),[r,i]=(0,U.useState)(!1),[a,o]=(0,U.useState)(!1),[s,c]=(0,U.useState)(!1),{client:l}=sd(),{t:u}=V(),[d,f]=(0,U.useState)(l.status.state===`open`);(0,U.useEffect)(()=>{let e=l.onStatus(e=>f(e.state===`open`));return()=>e()},[l]),(0,U.useEffect)(()=>{d&&(l.send({type:`mailbox.messages`,payload:{limit:30}}),l.send({type:`mailbox.agents`,payload:{}}))},[d,l]);let p=J(e=>e.selectedMailMessage),m=J(e=>e.setSelectedMailMessage);function h(e){if(p?.id===e.id){m(null),Q(`chat`);return}m(e),Q(`mailbox`)}let _=t.filter(e=>!e.completed).length,y=n.filter(e=>e.online).length;async function b(){t.length!==0&&await Af({title:u(`activity:mailbox.deleteAllConfirmTitle`,{count:t.length}),message:u(`activity:mailbox.deleteAllConfirmBody`),confirmLabel:u(`activity:mailbox.deleteAll`),danger:!0})&&(o(!0),l.send({type:`mailbox.clear`}))}(0,U.useEffect)(()=>{a&&t.length===0&&o(!1)},[a,t.length]);async function x(){await Af({title:u(`activity:mailbox.purgeConfirmTitle`),message:u(`activity:mailbox.purgeConfirmBody`),confirmLabel:u(`activity:mailbox.purge`),danger:!1})&&(c(!0),l.send({type:`mailbox.purge`}))}return(0,U.useEffect)(()=>{if(s){let e=setTimeout(()=>c(!1),3e3);return()=>clearTimeout(e)}},[s]),(0,Y.jsxs)(`div`,{className:X(`rounded-lg border border-border bg-card/60 backdrop-blur-sm`,e),children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`flex w-full items-center gap-2 px-3 py-2.5 text-left hover:bg-accent/40 rounded-t-lg transition-colors`,children:[(0,Y.jsx)(g,{className:`h-4 w-4 text-cyan-500`}),(0,Y.jsx)(`span`,{className:`text-xs font-semibold text-foreground flex-1 min-w-0 truncate`,children:u(`activity:nav.mailbox`)}),_>0&&(0,Y.jsx)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 rounded-full text-[10px] font-bold bg-yellow-100 dark:bg-yellow-900/40 text-yellow-700 dark:text-yellow-400`,children:_}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:u(`activity:mailbox.onlineCount`,{count:y})})]}),!r&&(0,Y.jsxs)(`div`,{className:`px-3 pb-3 space-y-2`,children:[t.length>0?(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wide`,children:u(`activity:mailbox.messages`)}),(0,Y.jsxs)(`button`,{type:`button`,onClick:b,disabled:a,className:`flex items-center gap-1 text-[10px] text-muted-foreground hover:text-red-500 disabled:opacity-40 transition-colors`,title:u(`activity:mailbox.deleteAllTitle`),children:[(0,Y.jsx)(C,{className:`h-3 w-3`}),u(a?`activity:mailbox.deleting`:`activity:mailbox.deleteAll`)]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:x,disabled:s,className:`flex items-center gap-1 text-[10px] text-muted-foreground hover:text-cyan-500 disabled:opacity-40 transition-colors`,title:u(`activity:mailbox.purgeTitle`),children:[(0,Y.jsx)(bt,{className:`h-3 w-3`}),u(s?`activity:mailbox.purging`:`activity:mailbox.purge`)]})]}),t.slice(0,8).map(e=>{let t=_y[e.type]??Ir,n=e.readByCount>0,r=p?.id===e.id;return(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>h(e),className:X(`flex items-start gap-2 px-2 py-1.5 rounded text-xs w-full text-left cursor-pointer transition-colors hover:bg-accent/60`,!n&&`bg-yellow-50 dark:bg-yellow-950/20`,r&&`ring-1 ring-primary bg-primary/5`),children:[(0,Y.jsx)(t,{className:X(`h-3.5 w-3.5 mt-0.5 shrink-0`,n?`text-muted-foreground`:`text-yellow-600`)}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:X(`font-medium truncate`,!n&&`text-yellow-800 dark:text-yellow-300`),children:e.from}),e.completed&&(0,Y.jsx)(rn,{className:`h-3 w-3 text-green-500 shrink-0`}),!n&&(0,Y.jsx)(`span`,{className:`text-[9px] text-yellow-600 font-bold`,children:u(`activity:mailbox.newLabel`)})]}),(0,Y.jsx)(`div`,{className:`text-muted-foreground truncate`,children:e.subject}),(0,Y.jsxs)(`div`,{className:`text-[10px] text-muted-foreground/70 truncate`,children:[e.body.slice(0,60),e.body.length>60?`…`:``]})]}),(0,Y.jsxs)(`div`,{className:`shrink-0 text-[10px] text-muted-foreground flex flex-col items-end gap-0.5`,children:[(0,Y.jsx)(`span`,{children:vy(e.timestamp)}),n&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,Y.jsx)(v,{className:`h-3 w-3`}),e.readByCount]})]})]},e.id)})]}):(0,Y.jsxs)(`div`,{className:`text-xs text-muted-foreground py-2 text-center`,children:[(0,Y.jsx)(Dr,{className:`h-4 w-4 mx-auto mb-1 opacity-40`}),u(`activity:mailbox.empty`)]}),n.length>0&&(0,Y.jsxs)(`div`,{className:`border-t border-border pt-2`,children:[(0,Y.jsxs)(`div`,{className:`text-[10px] font-semibold text-muted-foreground mb-1 flex items-center gap-1`,children:[(0,Y.jsx)(Rr,{className:`h-3 w-3`}),` `,u(`activity:nav.agents`)]}),n.filter(e=>e.online).slice(0,5).map(e=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground py-0.5`,children:[(0,Y.jsx)(`span`,{className:X(`h-1.5 w-1.5 rounded-full`,e.online?`bg-green-500`:`bg-muted-foreground/30`)}),(0,Y.jsx)(`span`,{className:`font-medium text-foreground/80`,children:e.name}),e.role&&(0,Y.jsxs)(`span`,{className:`opacity-60`,children:[`(`,e.role,`)`]}),(0,Y.jsx)(`span`,{className:`opacity-50`,children:e.status}),e.currentTool&&(0,Y.jsx)(`span`,{className:`text-cyan-500`,children:e.currentTool}),(0,Y.jsx)(`span`,{className:`ml-auto opacity-50`,children:vy(e.lastSeenAt)})]},e.agentId)),n.filter(e=>!e.online).length>0&&(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground/50 mt-0.5`,children:u(`activity:mailbox.offlineCount`,{count:n.filter(e=>!e.online).length})})]})]})]})}var by={running:{led:`text-[hsl(var(--success))]`,pulse:!0},completed:{led:`text-[hsl(var(--success))]`,pulse:!1},failed:{led:`text-destructive`,pulse:!1},timeout:{led:`text-[hsl(var(--warning))]`,pulse:!1},stopped:{led:`text-muted-foreground`,pulse:!1}};function xy({agent:e,onClose:t}){let n=by[e.status],{t:r}=V(),i=e.status===`running`,a=e.currentTool??e.lastTool,o=Date.now()-e.startedAt,[s,c]=(0,U.useState)(!1),l=Xs(e=>e.leaderId),u=e.id===l,d=Xs(t=>t.agentTranscripts.get(e.id)??Bs),f=Math.min(100,Math.max(0,e.ctxPct)),p=(0,U.useCallback)(async e=>{try{await navigator.clipboard.writeText(e),c(!0),setTimeout(()=>c(!1),2e3)}catch{}},[]),m=f>=85?`bg-red-500/15 text-red-600 dark:text-red-400`:f>=70?`bg-amber-500/15 text-amber-600 dark:text-amber-400`:`bg-muted text-muted-foreground`;return(0,Y.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center pt-[10dvh] bg-black/40 backdrop-blur-sm`,children:(0,Y.jsxs)(`div`,{className:`w-full max-w-xl max-h-[80dvh] overflow-y-auto rounded-xl border bg-card shadow-2xl`,children:[(0,Y.jsxs)(`div`,{className:X(`flex items-center justify-between px-4 py-3 border-b`,i?`border-primary/20`:`border-border`),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:X(`led`,n.led,n.pulse&&`led-pulse`)}),(0,Y.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),u&&(0,Y.jsx)(on,{className:`h-3.5 w-3.5 text-amber-500 shrink-0`,"aria-label":r(`activity:fleet.leader`)}),(0,Y.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:r(`activity:fleet.status.${e.status}`)})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:t,className:`p-1 rounded-md hover:bg-muted transition-colors`,children:(0,Y.jsx)(Xn,{className:`h-4 w-4`})})]}),(0,Y.jsxs)(`div`,{className:`p-4 space-y-4`,children:[e.description&&(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground leading-relaxed`,children:e.description}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Y.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-3 py-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r(`activity:fleet.providerModel`)}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 mt-0.5`,children:[(0,Y.jsx)(wr,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`text-xs font-mono font-medium`,children:[e.provider??`?`,`/`,e.model??`?`]})]})]}),(0,Y.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-3 py-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r(`activity:fleet.elapsed`)}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 mt-0.5`,children:[(0,Y.jsx)(Ge,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-xs font-mono tabular`,children:Bh(o)}),i&&(0,Y.jsxs)(`span`,{className:`text-[10px] text-[hsl(var(--success))]`,children:[`· `,r(`activity:fleet.running`)]})]})]}),(0,Y.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-3 py-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r(`activity:fleet.iterations`)}),(0,Y.jsx)(`span`,{className:`block text-xs font-mono font-medium mt-0.5 tabular`,children:e.iteration})]}),(0,Y.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-3 py-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r(`activity:fleet.toolCalls`)}),(0,Y.jsx)(`span`,{className:`block text-xs font-mono font-medium mt-0.5 tabular`,children:e.toolCalls})]}),(0,Y.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-3 py-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r(`activity:fleet.cost`)}),(0,Y.jsx)(`span`,{className:`block text-xs font-mono font-medium mt-0.5 tabular`,children:Rh(e.costUsd)})]}),e.extensions>0&&(0,Y.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-3 py-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r(`activity:fleet.budgetExtensions`)}),(0,Y.jsxs)(`span`,{className:`block text-xs font-mono font-medium mt-0.5 tabular`,children:[`⚡×`,e.extensions]})]})]}),i&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r(`activity:fleet.activity`)}),(0,Y.jsx)(ef,{bins:e.sparklineBins,className:`font-mono`})]}),e.budgetWarning&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg bg-amber-500/10 border border-amber-500/20 text-xs`,children:[(0,Y.jsx)(tn,{className:`h-3.5 w-3.5 text-amber-500 shrink-0`}),(0,Y.jsx)(`span`,{className:`text-amber-600 dark:text-amber-400`,children:r(`activity:fleet.budgetWarning`,{kind:e.budgetWarning.kind,used:e.budgetWarning.used,limit:e.budgetWarning.limit})})]}),e.maxContext>0&&(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between text-[10px]`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:r(`activity:fleet.contextWindow`)}),(0,Y.jsxs)(`span`,{className:X(`tabular font-medium`,m.replace(/bg-\S+\s*/g,``)),children:[f,`%`]})]}),(0,Y.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-muted`,children:(0,Y.jsx)(`div`,{className:X(`h-full rounded-full transition-all`,f>=85?`bg-destructive`:f>=70?`bg-[hsl(var(--warning))]`:`bg-primary`),style:{width:`${Math.max(2,f)}%`}})}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground tabular text-right`,children:r(`activity:fleet.tokensUsed`,{used:zh(e.ctxTokens),max:zh(e.maxContext)})})]}),a&&(0,Y.jsxs)(`div`,{className:X(`flex items-center gap-2 rounded-lg border px-3 py-2`,i?`border-primary/30 bg-primary/[0.04]`:`border-border bg-muted/30`),children:[(0,Y.jsx)(In,{className:X(`h-3.5 w-3.5`,i?`text-primary animate-pulse`:`text-muted-foreground`)}),(0,Y.jsx)(`span`,{className:`text-xs font-mono`,children:a}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground ml-auto`,children:e.currentTool?r(`activity:fleet.toolRunning`):r(`activity:fleet.lastTool`)})]}),(0,Y.jsx)(Xd,{entries:d,agentName:e.name,compact:!0,maxHeightClassName:`max-h-80`}),e.error&&(0,Y.jsxs)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 p-3`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-semibold text-destructive uppercase tracking-wider`,children:r(`activity:fleet.error`)}),(0,Y.jsx)(`p`,{className:`text-xs text-destructive/90 mt-1 leading-relaxed`,children:e.error.message})]}),e.finalText?(0,Y.jsxs)(`div`,{className:`rounded-lg border bg-muted/20 p-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider`,children:r(`activity:fleet.finalOutput`)}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>p(e.finalText),className:`flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] text-muted-foreground hover:text-foreground hover:bg-muted transition-colors`,title:r(`activity:fleet.copyOutput`),children:[s?(0,Y.jsx)(z,{className:`h-3 w-3 text-emerald-500`}):(0,Y.jsx)(Ft,{className:`h-3 w-3`}),r(s?`common:action.copied`:`common:action.copy`)]})]}),(0,Y.jsx)(`pre`,{className:`text-xs whitespace-pre-wrap font-mono text-foreground/80 leading-relaxed max-h-64 overflow-y-auto`,children:e.finalText})]}):e.partialText?(0,Y.jsxs)(`div`,{className:`rounded-lg border bg-muted/20 p-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider`,children:r(`activity:fleet.liveOutput`)}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>p(e.partialText),className:`flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] text-muted-foreground hover:text-foreground hover:bg-muted transition-colors`,title:r(`activity:fleet.copyOutput`),children:[s?(0,Y.jsx)(z,{className:`h-3 w-3 text-emerald-500`}):(0,Y.jsx)(Ft,{className:`h-3 w-3`}),r(s?`common:action.copied`:`common:action.copy`)]})]}),(0,Y.jsx)(`pre`,{className:`text-xs whitespace-pre-wrap font-mono text-foreground/80 leading-relaxed max-h-48 overflow-y-auto`,children:e.partialText})]}):i?(0,Y.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border p-3 text-center`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`activity:fleet.waitingOutput`)}),(0,Y.jsx)(`p`,{className:`text-[10px] text-muted-foreground/60 mt-0.5`,children:r(`activity:fleet.outputHint`)})]}):null,e.toolLog.length>0&&(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider`,children:r(`activity:fleet.toolLog`,{count:e.toolLog.length})}),(0,Y.jsxs)(`div`,{className:`max-h-40 overflow-y-auto space-y-0.5`,children:[e.toolLog.slice(0,15).map((e,t)=>(0,Y.jsxs)(`div`,{className:X(`flex items-center gap-2 rounded px-2 py-1 text-[10px]`,e.ok?`bg-muted/30`:`bg-destructive/5 border border-destructive/20`),children:[(0,Y.jsx)(`span`,{className:X(`led shrink-0`,e.ok?`text-[hsl(var(--success))]`:`text-destructive`)}),(0,Y.jsx)(`span`,{className:`font-mono truncate flex-1`,children:e.name}),(0,Y.jsxs)(`span`,{className:`tabular text-muted-foreground`,children:[e.durationMs,`ms`]}),!e.ok&&(0,Y.jsx)(`span`,{className:`text-destructive font-medium`,children:r(`activity:fleet.fail`)})]},`${e.name}-${e.at}-${t}`)),e.toolLog.length>15&&(0,Y.jsx)(`p`,{className:`text-[9px] text-muted-foreground text-center px-2 py-0.5`,children:r(`activity:fleet.moreTools`,{count:e.toolLog.length-15})})]})]})]})]})})}function Sy({a:e,onClick:t}){let n=by[e.status],{t:r}=V(),i=e.status===`running`,a=e.currentTool??e.lastTool,o=Math.min(100,Math.max(0,e.ctxPct));return(0,Y.jsxs)(`button`,{type:`button`,onClick:t,className:X(`flex min-w-[12rem] max-w-[15rem] flex-col gap-1 rounded-lg border p-2 transition-colors text-left cursor-pointer`,`hover:border-primary/40 hover:bg-primary/[0.06]`,i?`border-primary/30 bg-primary/[0.04]`:`border-border bg-card opacity-85`),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,Y.jsx)(`span`,{className:X(`led shrink-0`,n.led,n.pulse&&`led-pulse`)}),(0,Y.jsx)(`span`,{className:`truncate text-[11px] font-semibold text-foreground`,title:e.name,children:e.name}),(0,Y.jsxs)(`span`,{className:`tabular ml-auto shrink-0 text-[10px] text-muted-foreground`,children:[e.iteration,`it · `,e.toolCalls,`t`]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[e.model&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-0.5 text-[10px] text-muted-foreground truncate`,title:`${e.provider??``}/${e.model}`,children:[(0,Y.jsx)(wr,{className:`h-2.5 w-2.5 shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate font-mono`,children:e.model})]}),(0,Y.jsx)(`span`,{className:`tabular text-[10px] text-foreground/75 ml-auto`,children:Rh(e.costUsd)})]}),a&&(0,Y.jsxs)(`div`,{className:X(`flex items-center gap-1 text-[10px] truncate`,i?`text-primary`:`text-muted-foreground`),title:e.currentTool?r(`activity:fleet.cardRunning`,{tool:a}):r(`activity:fleet.cardLastTool`,{tool:a}),children:[(0,Y.jsx)(In,{className:X(`h-2.5 w-2.5 shrink-0`,i&&`animate-pulse`)}),(0,Y.jsx)(`span`,{className:`truncate font-mono`,children:a})]}),i&&e.maxContext>0&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,title:r(`activity:fleet.contextPercent`,{pct:o}),children:[(0,Y.jsx)(`div`,{className:`h-1 flex-1 overflow-hidden rounded-full bg-muted`,children:(0,Y.jsx)(`div`,{className:X(`h-full rounded-full transition-all`,o>=85?`bg-destructive`:o>=70?`bg-[hsl(var(--warning))]`:`bg-primary`),style:{width:`${Math.max(2,o)}%`}})}),(0,Y.jsx)(`span`,{className:`tabular text-[9px] text-muted-foreground`,children:e.maxContext>0?`${o}%`:`—`})]}),e.error&&(0,Y.jsx)(`div`,{className:`truncate rounded bg-destructive/10 px-1 py-0.5 text-[9px] text-destructive`,title:e.error.message,children:e.error.message})]})}function Cy({className:e}){let t=Xs(e=>e.agents),{t:n}=V(),[r,i]=(0,U.useState)(!0),[a,o]=(0,U.useState)(null),s=(0,U.useMemo)(()=>{let e=Array.from(t.values());return e.sort(Ih),e},[t]),c=a?s.find(e=>e.id===a):null;if(s.length===0)return null;let l=Lh(s),u=s.reduce((e,t)=>e+(t.costUsd??0),0),d=r&&s.length>=3;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:X(`rounded-lg border border-border bg-card/50 backdrop-blur-sm overflow-hidden`,e),children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`flex w-full items-center gap-2 px-3 py-1.5 text-left hover:bg-muted/30 transition-colors`,children:[(0,Y.jsx)(j,{className:`h-3.5 w-3.5 text-primary`}),(0,Y.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground`,children:`Fleet`}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 ml-auto text-[10px]`,children:[l.running>0&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 text-[hsl(var(--success))]`,children:[(0,Y.jsx)(`span`,{className:`led led-pulse text-[hsl(var(--success))]`}),l.running]}),l.completed>0&&(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:fleet.doneCount`,{count:l.completed})}),l.failed>0&&(0,Y.jsx)(`span`,{className:`text-destructive`,children:n(`activity:fleet.errCount`,{count:l.failed})}),u>0&&(0,Y.jsx)(`span`,{className:`tabular text-foreground/70`,children:Rh(u)})]}),d?(0,Y.jsx)(Oe,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}):(0,Y.jsx)(bn,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`})]}),!d&&(0,Y.jsx)(`div`,{className:`flex gap-2 overflow-x-auto px-2 pb-2`,children:s.map(e=>(0,Y.jsx)(Sy,{a:e,onClick:()=>o(e.id)},e.id))})]}),c&&(0,Y.jsx)(xy,{agent:c,onClose:()=>o(null)})]})}var wy={running:{led:`text-[hsl(var(--success))]`,label:`running`,pulse:!0},completed:{led:`text-[hsl(var(--success))]`,label:`done`,pulse:!1},failed:{led:`text-destructive`,label:`failed`,pulse:!1},timeout:{led:`text-[hsl(var(--warning))]`,label:`timeout`,pulse:!1},stopped:{led:`text-muted-foreground`,label:`stopped`,pulse:!1}};function Ty(e){return e<=0?`$0`:e>=.01?`$${e.toFixed(3)}`:`$${e.toFixed(4)}`}function Ey({agent:e,onClick:t}){let n=wy[e.status],{t:r}=V(),i=e.status===`running`;return(0,Y.jsxs)(`button`,{type:`button`,onClick:t,className:X(`w-full text-left rounded-lg border px-2.5 py-2 transition-colors`,`hover:border-primary/40 hover:bg-primary/[0.04]`,i?`border-primary/30 bg-primary/[0.03]`:`border-border/60 bg-card/40`),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,Y.jsx)(`span`,{className:X(`led shrink-0`,n.led,n.pulse&&`led-pulse`)}),(0,Y.jsx)(`span`,{className:`truncate text-[11px] font-semibold`,title:e.name,children:e.name}),(0,Y.jsxs)(`span`,{className:`tabular ml-auto shrink-0 text-[10px] text-muted-foreground`,children:[e.iteration,`it`]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-0.5 min-w-0`,children:[e.model?(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground truncate font-mono`,children:e.model}):(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground italic`,children:r(`activity:agents.pending`)}),(0,Y.jsx)(`span`,{className:`tabular ml-auto text-[10px] text-foreground/70`,children:Ty(e.costUsd)})]}),(e.currentTool||e.lastTool)&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 mt-1 text-[10px] text-muted-foreground truncate`,children:[(0,Y.jsx)(In,{className:X(`h-2.5 w-2.5 shrink-0`,i&&`animate-pulse text-primary`)}),(0,Y.jsx)(`span`,{className:`truncate font-mono`,children:e.currentTool??e.lastTool})]})]})}function Dy(){let e=Xs(e=>e.agents),{t}=V(),[n,r]=(0,U.useState)(null),i=(0,U.useMemo)(()=>{let t=Array.from(e.values());return t.sort((e,t)=>{let n=e.status===`running`?0:1,r=t.status===`running`?0:1;return n===r?e.startedAt-t.startedAt:n-r}),t},[e]),a=i.filter(e=>e.status===`running`).length,o=n?i.find(e=>e.id===n)??null:null;return i.length===0?(0,Y.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-4`,children:(0,Y.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,Y.jsx)(j,{className:`h-8 w-8 mx-auto mb-3 opacity-20`}),(0,Y.jsx)(`p`,{className:`text-sm font-medium`,children:t(`activity:agents.empty`)}),(0,Y.jsx)(`p`,{className:`text-xs mt-1`,children:t(`activity:agents.emptyHint`)})]})}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`px-3 py-2 border-b text-[10px] text-muted-foreground flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`font-semibold uppercase tracking-wider`,children:`Fleet`}),(0,Y.jsxs)(`span`,{className:`ml-auto tabular-nums`,children:[a>0?(0,Y.jsxs)(Y.Fragment,{children:[t(`activity:agents.runningCount`,{count:a}),` · `]}):null,t(`activity:agents.totalCount`,{count:i.length})]})]}),(0,Y.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto p-2 space-y-1.5`,children:i.map(e=>(0,Y.jsx)(Ey,{agent:e,onClick:()=>r(e.id)},e.id))}),(0,Y.jsx)(`div`,{className:`border-t px-3 py-2 shrink-0`,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>J.getState().setAgentsMonitorOpen(!0),className:`w-full flex items-center justify-center gap-1.5 h-7 rounded-md border border-border text-[11px] text-muted-foreground hover:text-foreground hover:bg-accent transition-colors`,children:[(0,Y.jsx)(je,{className:`h-3 w-3`}),t(`activity:agents.openFull`)]})}),o&&(0,Y.jsx)(xy,{agent:o,onClose:()=>r(null)})]})}var Oy={M:{label:`M`,cls:`text-amber-600 dark:text-amber-400`},A:{label:`A`,cls:`text-emerald-600 dark:text-emerald-400`},D:{label:`D`,cls:`text-rose-600 dark:text-rose-400`},R:{label:`R`,cls:`text-sky-600 dark:text-sky-400`},C:{label:`C`,cls:`text-sky-600 dark:text-sky-400`},U:{label:`U`,cls:`text-orange-600 dark:text-orange-400`},"?":{label:`U`,cls:`text-muted-foreground`}};function ky(e){let t=e.lastIndexOf(`/`);return t<0?{name:e,dir:``}:{name:e.slice(t+1),dir:e.slice(0,t+1)}}function Ay({file:e,active:t,onSelect:n}){let r=Oy[e.status]??Oy.M,{name:i,dir:a}=ky(e.path);return(0,Y.jsxs)(`button`,{type:`button`,onClick:n,title:e.path,className:X(`group flex items-center gap-2 w-full px-2 py-1 text-left text-xs rounded hover:bg-accent/60`,t&&`bg-accent`),children:[(0,Y.jsx)(`span`,{className:X(`w-3 shrink-0 text-center font-mono font-bold`,r?.cls),children:r?.label}),(0,Y.jsxs)(`span`,{className:`flex-1 min-w-0 truncate`,children:[(0,Y.jsx)(`span`,{className:X(e.status===`D`&&`line-through opacity-70`),children:i}),a&&(0,Y.jsx)(`span`,{className:`text-muted-foreground/60 ml-1 truncate`,children:a})]}),(0,Y.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums`,children:[e.added>0&&(0,Y.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-400`,children:[`+`,e.added]}),e.deleted>0&&(0,Y.jsxs)(`span`,{className:`text-rose-600 dark:text-rose-400 ml-1`,children:[`-`,e.deleted]})]})]})}function jy(){let{client:e}=sd(),{t}=V(),n=K(e=>e.wsConnected),r=ws(e=>e.files),i=ws(e=>e.error),a=ws(e=>e.loadingList),o=ws(e=>e.selectedPath),s=(0,U.useCallback)(()=>{n&&(ws.getState().setListLoading(!0),e?.getGitChanges?.())},[e,n]);(0,U.useEffect)(()=>{s()},[s]);let c=t=>{ws.getState().select(t),e?.getGitDiff?.(t),Q(`changes`)},l=r.reduce((e,t)=>e+t.added,0),u=r.reduce((e,t)=>e+t.deleted,0);return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col overflow-hidden`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b shrink-0`,children:[(0,Y.jsxs)(`span`,{className:`text-[11px] text-muted-foreground font-mono`,children:[t(`activity:changes.fileCount`,{count:r.length}),r.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[` · `,(0,Y.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-400`,children:[`+`,l]}),` `,(0,Y.jsxs)(`span`,{className:`text-rose-600 dark:text-rose-400`,children:[`-`,u]})]})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:s,title:t(`activity:changes.refreshTitle`),className:`h-6 w-6 inline-flex items-center justify-center rounded hover:bg-accent text-muted-foreground`,children:a?(0,Y.jsx)(B,{className:`h-3.5 w-3.5 animate-spin`}):(0,Y.jsx)(Rn,{className:`h-3.5 w-3.5`})})]}),(0,Y.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto p-1.5`,children:i?(0,Y.jsx)(`div`,{className:`px-2 py-6 text-center text-xs text-muted-foreground`,children:i}):r.length===0?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-2 py-10 text-center text-xs text-muted-foreground`,children:[(0,Y.jsx)(P,{className:`h-6 w-6 opacity-40`}),t(a?`activity:changes.loading`:`activity:changes.clean`)]}):(0,Y.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:r.map(e=>(0,Y.jsx)(Ay,{file:e,active:e.path===o,onSelect:()=>c(e.path)},e.path))})})]})}var My=e=>{let t=Date.parse(e);if(Number.isNaN(t))return``;let n=Date.now()-t;if(n<6e4)return b.t(`common:time.justNow`);if(n<36e5)return b.t(`common:time.minutesAgo`,{count:Math.floor(n/6e4)});if(n<864e5)return b.t(`common:time.hoursAgo`,{count:Math.floor(n/36e5)});let r=Math.floor(n/864e5);return r<7?b.t(`common:time.daysAgo`,{count:r}):new Date(t).toLocaleDateString()};function Ny(e){return e.filter(e=>e.tokenTotal===0&&!e.isCurrent).map(e=>e.id)}function Py({historyQuery:e,setHistoryQuery:t,historyEntries:n,historyLoading:r,historyError:i,wsConnected:a,listSessions:o,resumeSession:s,deleteSession:c}){let l=J(e=>e.favoriteSessionIds),{t:u}=V(),f=J(e=>e.toggleFavoriteSession),p=J(e=>e.sessionNicknames),m=J(e=>e.setSessionNickname),[h,g]=(0,U.useState)(null),[_,v]=(0,U.useState)(``),[y,b]=(0,U.useState)(null);(0,U.useEffect)(()=>{y&&n.some(e=>e.id===y&&e.isCurrent)&&b(null)},[y,n]);let x=(0,U.useCallback)(e=>{b(e),s(e),setTimeout(()=>b(t=>t===e?null:t),1e4)},[s]),S=(0,U.useMemo)(()=>Ny(n),[n]),w=(0,U.useCallback)(async()=>{if(S.length!==0&&await Af({title:u(`activity:sessions.deleteEmptyTitle`,{count:S.length}),message:u(`activity:sessions.deleteEmptyConfirmBody`),confirmLabel:u(`common:action.delete`),danger:!0}))for(let e of S)c(e)},[S,c]),T=(()=>{let t=e.trim().toLowerCase(),r=t?n.filter(e=>e.title.toLowerCase().includes(t)||e.model.toLowerCase().includes(t)||e.provider.toLowerCase().includes(t)||e.id.toLowerCase().includes(t)):n,i=new Date;i.setHours(0,0,0,0);let a=i.getTime(),o=a-864e5,s=a-6*864e5,c={today:[],yesterday:[],week:[],older:[]};for(let e of r){let t=Date.parse(e.startedAt);if(Number.isNaN(t)){c.older.push(e);continue}t>=a?c.today.push(e):t>=o?c.yesterday.push(e):t>=s?c.week.push(e):c.older.push(e)}let u=new Set(l),d=r.filter(e=>u.has(e.id)),f=[];d.length&&f.push({label:`favorites`,rows:d,star:!0});let p=e=>e.filter(e=>!u.has(e.id)),m=p(c.today),h=p(c.yesterday),g=p(c.week),_=p(c.older);return m.length&&f.push({label:`today`,rows:m}),h.length&&f.push({label:`yesterday`,rows:h}),g.length&&f.push({label:`thisWeek`,rows:g}),_.length&&f.push({label:`earlier`,rows:_}),f})();return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b`,children:[(0,Y.jsx)(`span`,{className:`text-xs uppercase tracking-wider text-muted-foreground`,children:u(`activity:sessions.recentSessions`)}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[S.length>0&&(0,Y.jsx)(`button`,{type:`button`,className:`h-6 w-6 inline-flex items-center justify-center rounded-md hover:bg-muted text-muted-foreground hover:text-destructive`,onClick:w,disabled:!a,title:u(`activity:sessions.deleteEmptyTitle`,{count:S.length}),children:(0,Y.jsx)(C,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(`button`,{type:`button`,className:`h-6 w-6 inline-flex items-center justify-center rounded-md hover:bg-muted`,onClick:()=>o(50),disabled:!a,title:u(`common:action.refresh`),children:r?(0,Y.jsx)(B,{className:`h-3.5 w-3.5 animate-spin`}):(0,Y.jsx)(Rn,{className:`h-3.5 w-3.5`})})]})]}),n.length>3&&(0,Y.jsx)(`div`,{className:`px-3 py-2 border-b`,children:(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsx)(le,{className:`absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground/60`}),(0,Y.jsx)(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),placeholder:u(`activity:sessions.filterPlaceholder`),className:`w-full pl-7 pr-7 py-1 text-xs rounded-md bg-muted/40 border border-transparent focus:bg-background focus:border-input focus:outline-none focus:ring-1 focus:ring-ring placeholder:text-muted-foreground/50`}),e&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>t(``),className:`absolute right-1 top-1/2 -translate-y-1/2 text-muted-foreground/60 hover:text-foreground p-0.5`,title:u(`activity:sessions.clearFilter`),children:(0,Y.jsx)(Xn,{className:`h-3 w-3`})})]})}),i&&(0,Y.jsx)(`div`,{className:`px-4 py-2 text-xs text-destructive bg-destructive/5 border-b`,children:i}),(0,Y.jsx)(Th,{className:`flex-1`,children:n.length===0&&!r?(0,Y.jsxs)(`div`,{className:`text-center text-muted-foreground py-8 px-4`,children:[(0,Y.jsx)(d,{className:`h-8 w-8 mx-auto mb-3 opacity-20`}),(0,Y.jsx)(`p`,{className:`text-sm font-medium`,children:u(`activity:sessions.noHistory`)}),(0,Y.jsx)(`p`,{className:`text-xs mt-1`,children:u(`activity:sessions.noHistoryHint`)})]}):T.length===0?(0,Y.jsxs)(`div`,{className:`text-center text-muted-foreground py-8 px-4`,children:[(0,Y.jsx)(le,{className:`h-8 w-8 mx-auto mb-3 opacity-20`}),(0,Y.jsx)(`p`,{className:`text-sm font-medium`,children:u(`activity:sessions.noMatches`)}),(0,Y.jsx)(`p`,{className:`text-xs mt-1`,children:u(`activity:sessions.noMatchesHint`)})]}):(0,Y.jsx)(`div`,{className:`p-2 space-y-3`,children:T.map(e=>(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(`div`,{className:X(`sticky top-0 z-[1] px-1 pb-1 text-[10px] uppercase tracking-wider font-semibold bg-card/90 backdrop-blur-sm flex items-center gap-1`,e.star?`text-amber-500`:`text-muted-foreground/80`),children:[e.star&&(0,Y.jsx)(M,{className:`h-3 w-3 fill-current`}),u(`activity:sessions.group.${e.label}`),` `,(0,Y.jsxs)(`span`,{className:`text-muted-foreground/50 font-normal normal-case ml-1`,children:[`(`,e.rows.length,`)`]})]}),e.rows.map(e=>(0,Y.jsxs)(`div`,{className:X(`group relative rounded-md border text-sm transition-colors`,e.isCurrent?`bg-primary/5 border-primary/40`:`bg-card border-border/60 hover:bg-muted/40 hover:border-primary/40`),children:[(0,Y.jsx)(`button`,{type:`button`,disabled:e.isCurrent||h===e.id||y!==null,onClick:()=>x(e.id),onDoubleClick:t=>{t.stopPropagation(),g(e.id),v(p[e.id]??e.title??``)},className:`block w-full rounded-md px-3 py-2 pr-16 text-left disabled:cursor-default focus:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[h===e.id?(0,Y.jsx)(`input`,{value:_,onChange:e=>v(e.target.value),onClick:e=>e.stopPropagation(),onBlur:()=>{m(e.id,_),g(null)},onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),m(e.id,_),g(null)):t.key===`Escape`&&(t.preventDefault(),g(null))},placeholder:e.title||u(`activity:sessions.nicknamePlaceholder`),className:`w-full text-sm bg-background border border-input rounded px-1.5 py-0.5 focus:outline-none focus:ring-1 focus:ring-ring`}):(0,Y.jsx)(`div`,{className:`font-medium truncate text-foreground`,title:p[e.id]?u(`activity:sessions.renameTitleNickname`,{nickname:p[e.id],title:e.title}):u(`activity:sessions.renameTitle`,{title:e.title}),children:p[e.id]||e.title||u(`activity:sessions.empty`)}),(0,Y.jsxs)(`div`,{className:`text-[10px] text-muted-foreground font-mono truncate mt-0.5`,children:[e.provider,`/`,e.model]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground/80 mt-0.5`,children:[y===e.id?(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 text-primary font-medium`,children:[(0,Y.jsx)(B,{className:`h-3 w-3 animate-spin`}),u(`activity:sessions.resuming`)]}):(0,Y.jsx)(`span`,{children:My(e.startedAt)}),e.tokenTotal>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`opacity-50`,children:`·`}),(0,Y.jsxs)(`span`,{className:`tabular-nums`,children:[e.tokenTotal.toLocaleString(),` tok`]})]}),e.isCurrent&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`opacity-50`,children:`·`}),(0,Y.jsx)(`span`,{className:`text-primary font-medium`,children:u(`activity:sessions.active`)})]})]})]})}),(0,Y.jsxs)(`div`,{className:`absolute right-2 top-2 flex items-center gap-1`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>f(e.id),className:X(`transition-opacity hover:text-amber-500`,l.includes(e.id)?`opacity-100 text-amber-500`:`opacity-0 group-hover:opacity-100 text-muted-foreground`),title:l.includes(e.id)?u(`activity:sessions.unfavorite`):u(`activity:sessions.markFavorite`),children:(0,Y.jsx)(M,{className:X(`h-3.5 w-3.5`,l.includes(e.id)&&`fill-current`)})}),!e.isCurrent&&(0,Y.jsx)(`button`,{type:`button`,onClick:async()=>{await Af({title:u(`activity:sessions.deleteSessionConfirmTitle`),message:u(`activity:sessions.deleteSessionConfirmBody`,{name:p[e.id]||e.title||u(`activity:sessions.empty`)}),confirmLabel:u(`common:action.delete`),danger:!0})&&c(e.id)},className:`opacity-0 group-hover:opacity-100 transition-opacity text-muted-foreground hover:text-destructive`,title:u(`activity:sessions.deleteSessionTitle`),children:(0,Y.jsx)(C,{className:`h-3.5 w-3.5`})})]})]},e.id))]},e.label))})})]})}function Fy(){let e=K(e=>e.wsConnected),{entries:t,loading:n,error:r}=Ts(),{listSessions:i,resumeSession:a,deleteSession:o}=sd(),s=q(e=>e.session?.id),{t:c}=V(),[l,u]=(0,U.useState)(``);return(0,U.useEffect)(()=>{e&&i(50)},[e,s,i]),(0,Y.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,Y.jsx)(Py,{historyQuery:l,setHistoryQuery:u,historyEntries:t,historyLoading:n,historyError:r,wsConnected:e,listSessions:i,resumeSession:a,deleteSession:o}),(0,Y.jsx)(`div`,{className:`border-t px-3 py-2 shrink-0`,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>Q(`history`),className:`w-full flex items-center justify-center gap-1.5 h-7 rounded-md border border-border text-[11px] text-muted-foreground hover:text-foreground hover:bg-accent transition-colors`,children:[(0,Y.jsx)(je,{className:`h-3 w-3`}),c(`activity:history.openDashboard`)]})})]})}function Iy(e){return e<=0?`$0.000`:e>=.01?`$${e.toFixed(3)}`:`$${e.toFixed(4)}`}function Ly(e){if(e<=0)return`--`;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${n%60}m`}function Ry(e){let t=e.split(`/`).pop()??e;return t.length>18?t.slice(0,18):t}function zy({icon:e,label:t,onClick:n,disabled:r,tone:i,title:a}){return(0,Y.jsxs)(`button`,{type:`button`,onClick:n,disabled:r,title:a??t,className:X(`flex items-center justify-center gap-1.5 h-8 rounded-md border text-[11px] font-medium transition-colors`,`disabled:opacity-40 disabled:cursor-not-allowed`,i===`primary`?`border-primary/40 bg-primary/10 text-primary hover:bg-primary/20`:i===`danger`?`border-destructive/40 bg-destructive/10 text-destructive hover:bg-destructive/20`:`border-border bg-card hover:bg-accent text-foreground/80`),children:[e,t]})}function By({label:e,value:t,sub:n}){return(0,Y.jsxs)(`div`,{className:`flex flex-col p-2 rounded-lg bg-muted/40 border border-border/40 min-w-0`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e}),(0,Y.jsx)(`span`,{className:`text-sm font-semibold tabular-nums truncate`,children:t}),n&&(0,Y.jsx)(`span`,{className:`text-[9px] text-muted-foreground/70 truncate`,children:n})]})}function Vy({icon:e,label:t,right:n}){return(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wider text-muted-foreground font-semibold`,children:[e,t]}),n]})}function Hy({label:e,value:t,onChange:n,title:r}){return(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 py-1`,title:r,children:[(0,Y.jsx)(`span`,{className:`text-xs text-foreground/80`,children:e}),(0,Y.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,onClick:n,className:X(`shrink-0 relative inline-flex h-4 w-7 rounded-full border transition-colors`,t?`bg-primary border-primary`:`bg-muted border-input hover:bg-muted/80`),children:(0,Y.jsx)(`span`,{className:X(`absolute top-0.5 left-0.5 h-2.5 w-2.5 rounded-full bg-background shadow transition-transform`,t&&`translate-x-3`)})})]})}function Uy(){let{client:e,updatePrefs:t,switchAutonomy:n}=sd(),{t:r}=V(),i=K(e=>e.wsConnected),a=K(e=>e.wsUrl),o=K(e=>e.provider),s=K(e=>e.model),c=K(e=>e.soundOnComplete),l=q(e=>e.session),u=q(e=>e.totalTokens),d=q(e=>e.cost),f=q(e=>e.iteration),p=q(e=>e.todos),m=q(e=>e.lastInputTokens),h=q(e=>e.maxContext),g=G(e=>e.messages),_=G(e=>e.isLoading),v=Xs(e=>e.agents),y=J(e=>e.pinnedIds),b=J(e=>e.unpinAll),x=J(e=>e.setModelSwitcherOpen),S=ti(),C=(0,U.useCallback)((e,n)=>{S.set({[e]:n}),t({[e]:n})},[S,t]),[w,T]=(0,U.useState)(!1),E=l?.startedAt??null,[D,O]=(0,U.useState)(()=>Date.now());(0,U.useEffect)(()=>{if(!E)return;let e=setInterval(()=>O(Date.now()),1e3);return()=>clearInterval(e)},[E]);let k=(0,U.useMemo)(()=>Array.from(v.values()).filter(e=>e.status===`running`).length,[v]),A=h>0&&m>0?Math.min(100,Math.round(m/h*100)):0,j=y.map(e=>g.find(t=>t.id===e)).filter(e=>!!e&&e.content.length>0),M=e=>W(a)?.send?.(e);return(0,Y.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto`,children:[(0,Y.jsxs)(`div`,{className:`px-3 py-2.5 border-b grid grid-cols-2 gap-1.5`,children:[_?(0,Y.jsx)(zy,{icon:(0,Y.jsx)(ae,{className:`h-3 w-3`}),label:r(`activity:sessionPanel.actions.abort`),tone:`danger`,onClick:()=>M({type:`abort`,payload:{}}),disabled:!i}):(0,Y.jsx)(zy,{icon:(0,Y.jsx)(hn,{className:`h-3 w-3`}),label:r(`activity:sessionPanel.actions.newSession`),tone:`primary`,onClick:()=>{e?.newSession?.(),Q(`chat`)},disabled:!i,title:r(`activity:sessionPanel.actions.newSessionTitle`)}),(0,Y.jsx)(zy,{icon:(0,Y.jsx)(Yn,{className:`h-3 w-3`}),label:r(`activity:sessionPanel.actions.export`),onClick:()=>Op(),title:r(`activity:sessionPanel.actions.exportTitle`)}),(0,Y.jsx)(zy,{icon:(0,Y.jsx)(Hr,{className:`h-3 w-3`}),label:r(`activity:sessionPanel.actions.compact`),onClick:()=>M({type:`context.compact`,payload:{aggressive:!1}}),disabled:!i,title:r(`activity:sessionPanel.actions.compactTitle`)}),(0,Y.jsx)(zy,{icon:(0,Y.jsx)(en,{className:`h-3 w-3`}),label:r(`common:action.clear`),onClick:()=>M({type:`context.clear`}),disabled:!i,title:r(`activity:sessionPanel.actions.clearTitle`)})]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>x(!0),className:`w-full px-4 py-2.5 border-b text-left hover:bg-muted/40 transition-colors`,title:r(`activity:sessionPanel.modelTitle`),children:[(0,Y.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground mb-0.5`,children:r(`activity:sessionPanel.model`)}),(0,Y.jsxs)(`div`,{className:`font-mono text-xs truncate`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:o||`—`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground/40 mx-1`,children:`/`}),(0,Y.jsx)(`span`,{className:`font-medium`,children:s||`—`})]})]}),h>0&&(0,Y.jsxs)(`div`,{className:`px-4 py-2.5 border-b space-y-1.5`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>T(!0),className:`w-full block text-left`,title:r(`activity:sessionPanel.contextTitle`),children:(0,Y.jsx)(Vy,{icon:null,label:r(`activity:sessionPanel.context`),right:(0,Y.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums font-mono`,children:[Ld(m),`/`,Ld(h),` · `,A,`%`]})})}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>T(!0),className:`w-full block`,title:r(`activity:sessionPanel.contextTitle`),children:(0,Y.jsx)(Kd,{pct:A,tokens:m,maxTokens:h,showTokens:!0})})]}),(0,Y.jsxs)(`div`,{className:`px-3 py-2.5 border-b space-y-1.5`,children:[(0,Y.jsx)(Vy,{icon:(0,Y.jsx)(wr,{className:`h-3 w-3`}),label:r(`activity:sessionPanel.sessionLabel`)}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-1.5`,children:[(0,Y.jsx)(By,{label:r(`activity:sessionPanel.stats.messages`),value:g.length}),(0,Y.jsx)(By,{label:r(`activity:sessionPanel.stats.elapsed`),value:E?Ly(D-E):`--`}),(0,Y.jsx)(By,{label:r(`activity:sessionPanel.stats.tokens`),value:Ld(u.input+u.output),sub:r(`activity:sessionPanel.stats.tokensSub`,{in:Ld(u.input),out:Ld(u.output)})}),(0,Y.jsx)(By,{label:r(`activity:sessionPanel.stats.cost`),value:Iy(d)}),f&&(0,Y.jsx)(By,{label:r(`activity:sessionPanel.stats.iteration`),value:f.index,sub:f.max?r(`activity:sessionPanel.stats.iterationOf`,{max:f.max}):void 0}),v.size>0&&(0,Y.jsx)(By,{label:r(`activity:sessionPanel.stats.agents`),value:v.size,sub:k>0?r(`activity:sessionPanel.stats.agentsRunning`,{count:k}):void 0})]})]}),p.length>0&&(()=>{let e=p.filter(e=>e.status===`completed`).length,t=p.filter(e=>e.status===`in_progress`).length,n=Math.round(e/p.length*100),i=e===p.length;return(0,Y.jsxs)(`div`,{className:`px-3 py-2.5 border-b space-y-1.5`,children:[(0,Y.jsx)(Vy,{icon:(0,Y.jsx)(De,{className:`h-3 w-3`}),label:r(`activity:sessionPanel.plan`),right:(0,Y.jsxs)(`span`,{className:`tabular-nums text-[10px] text-muted-foreground`,children:[e,`/`,p.length]})}),(0,Y.jsx)(`div`,{className:X(`relative h-1.5 w-full overflow-hidden rounded-full bg-muted`,t>0&&`bar-sweep`),title:r(`activity:sessionPanel.planComplete`,{pct:n}),children:(0,Y.jsx)(`div`,{className:X(`h-full rounded-full transition-all duration-500`,i?`bg-[hsl(var(--success))]`:`bg-primary`),style:{width:`${Math.max(n,t>0?4:0)}%`}})}),(0,Y.jsx)(`ul`,{className:`space-y-0.5 max-h-56 overflow-y-auto pr-1 -mx-1`,children:p.map(e=>{let t=e.status===`completed`?rn:e.status===`in_progress`?Xe:Or,n=e.status===`in_progress`,r=e.status===`completed`?`text-[hsl(var(--success))] line-through opacity-60`:n?`text-foreground`:`text-muted-foreground`;return(0,Y.jsxs)(`li`,{className:X(`flex items-start gap-2 text-xs leading-snug rounded-md px-1.5 py-1 transition-colors`,n&&`bg-primary/10 ring-1 ring-inset ring-primary/20`,r),children:[(0,Y.jsx)(t,{className:X(`h-3.5 w-3.5 mt-0.5 shrink-0`,n&&`text-primary animate-pulse`)}),(0,Y.jsx)(`span`,{className:`break-words`,children:n&&e.activeForm?e.activeForm:e.content})]},e.id)})})]})})(),j.length>0&&(0,Y.jsxs)(`div`,{className:`px-3 py-2.5 border-b space-y-1.5`,children:[(0,Y.jsx)(Vy,{icon:(0,Y.jsx)(Un,{className:`h-3 w-3 text-amber-500`}),label:r(`activity:sessionPanel.pinned`),right:(0,Y.jsx)(`button`,{type:`button`,onClick:b,className:`text-[10px] text-muted-foreground hover:text-destructive`,children:r(`common:action.clear`)})}),(0,Y.jsx)(`ul`,{className:`space-y-1 max-h-48 overflow-y-auto pr-1`,children:j.map(e=>{let t=e.content.replace(/\s+/g,` `).slice(0,80);return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{let t=document.querySelector(`[data-message-id="${e.id}"]`);t&&(t.scrollIntoView({behavior:`smooth`,block:`center`}),t.classList.add(`ring-2`,`ring-amber-500/60`),setTimeout(()=>{t.classList.remove(`ring-2`,`ring-amber-500/60`)},1600))},className:`w-full text-left text-xs px-2 py-1.5 rounded bg-muted/40 hover:bg-muted/70 border border-amber-500/20 leading-snug`,title:e.content.slice(0,400),children:[t,e.content.length>80?`…`:``]})},e.id)})})]}),(0,Y.jsxs)(`div`,{className:`px-3 py-2.5 border-b space-y-1`,children:[(0,Y.jsx)(Vy,{icon:(0,Y.jsx)(Ve,{className:`h-3 w-3`}),label:r(`activity:sessionPanel.quickSettings`)}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 py-1`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-foreground/80`,children:r(`activity:sessionPanel.autonomy`)}),(0,Y.jsxs)(`select`,{value:S.autonomy,onChange:e=>{let t=e.target.value;S.set({autonomy:t}),n(t)},className:`shrink-0 h-6 max-w-[150px] rounded-md border bg-background px-1.5 text-[11px]`,children:[(0,Y.jsx)(`option`,{value:`off`,children:r(`activity:sessionPanel.autonomyOptions.off`)}),(0,Y.jsx)(`option`,{value:`suggest`,children:r(`activity:sessionPanel.autonomyOptions.suggest`)}),(0,Y.jsx)(`option`,{value:`auto`,children:r(`activity:sessionPanel.autonomyOptions.auto`)}),(0,Y.jsx)(`option`,{value:`eternal`,children:r(`activity:sessionPanel.autonomyOptions.eternal`)}),(0,Y.jsx)(`option`,{value:`eternal-parallel`,children:r(`activity:sessionPanel.autonomyOptions.eternal-parallel`)})]})]}),(0,Y.jsx)(Hy,{label:r(`activity:sessionPanel.yolo`),title:r(`activity:sessionPanel.yoloTitle`),value:S.yolo,onChange:()=>C(`yolo`,!S.yolo)}),(0,Y.jsx)(Hy,{label:r(`activity:sessionPanel.refine`),title:r(`activity:sessionPanel.refineTitle`),value:S.enhanceEnabled,onChange:()=>C(`enhanceEnabled`,!S.enhanceEnabled)}),(0,Y.jsx)(Hy,{label:r(`activity:sessionPanel.sound`),title:r(`activity:sessionPanel.soundTitle`),value:c,onChange:()=>{let e=!K.getState().soundOnComplete;K.getState().setSoundOnComplete(e),e&&Gc()}})]}),(0,Y.jsxs)(`div`,{className:`px-4 py-2.5`,children:[(0,Y.jsxs)(`div`,{className:X(`flex items-center gap-2 text-[11px]`,i?`text-[hsl(var(--success))]`:`text-[hsl(var(--warning))]`),children:[i?(0,Y.jsx)(fn,{className:`h-3.5 w-3.5`}):(0,Y.jsx)(sn,{className:`h-3.5 w-3.5`}),(0,Y.jsx)(`span`,{className:`font-medium`,children:r(i?`common:status.connected`:`common:status.disconnected`)}),(0,Y.jsx)(`span`,{className:`text-muted-foreground font-mono truncate ml-auto`,title:a,children:a})]}),l&&(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground font-mono mt-1 truncate`,title:l.id,children:r(`activity:sessionPanel.sessionId`,{id:Ry(l.id)})})]}),(0,Y.jsx)(Zp,{open:w,onClose:()=>T(!1)})]})}function Wy(e,t){switch(t){case`project`:return e(`activity:skillDetail.scopeProject`);case`user`:return e(`activity:skillDetail.scopeGlobal`);case`bundled`:return e(`activity:skillDetail.scopeBundled`);case`foreign`:return e(`activity:skillsList.scopeForeign`)}}function Gy(e){return e===`project`||e===`user`||e===`bundled`?e:`foreign`}function Ky({source:e}){let{t}=V(),n=Gy(e);return(0,Y.jsx)(`span`,{className:X(`inline-flex items-center px-1.5 py-0.5 rounded text-[9px] font-semibold uppercase tracking-wide`,n===`project`&&`bg-emerald-100 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-400`,n===`user`&&`bg-violet-100 text-violet-700 dark:bg-violet-950 dark:text-violet-400`,n===`bundled`&&`bg-slate-100 text-slate-600 dark:bg-slate-800 dark:text-slate-400`,n===`foreign`&&`bg-amber-100 text-amber-700 dark:bg-amber-950 dark:text-amber-400`),children:Wy(t,n)})}function qy({className:e}){let{t}=V(),{client:n}=sd(),r=J(e=>e.skillsState),i=J(e=>e.setSkillsState),[a,o]=(0,U.useState)([]),[s,c]=(0,U.useState)(!1),[l,u]=(0,U.useState)(`all`),[d,f]=(0,U.useState)(``),p=(0,U.useRef)(r);p.current=r;let[m,h]=(0,U.useState)(!1),[g,_]=(0,U.useState)(``),[v,y]=(0,U.useState)(!1),[x,S]=(0,U.useState)(!1),[C,w]=(0,U.useState)(null),[T,E]=(0,U.useState)(null),[D,O]=(0,U.useState)(!1),[k,A]=(0,U.useState)(``),[j,M]=(0,U.useState)(``),[N,P]=(0,U.useState)(`project`),[F,I]=(0,U.useState)(!1),[L,R]=(0,U.useState)(null),[ee,te]=(0,U.useState)(null),[ne,re]=(0,U.useState)(!1),[ie,ae]=(0,U.useState)(!1),oe=(0,U.useCallback)(async()=>{if(!n||!g.trim())return;S(!0),w(null),E(null);let e=t=>{let r=t;if(S(!1),r.payload.success){let e=r.payload.results?.map(e=>e.name).join(`, `)??g;E(b.t(`activity:skillsList.installedMsg`,{names:e})),n.send({type:`skills.list`})}else w(r.payload.error??b.t(`activity:skillsList.installFailed`));n.off(`skills.installed`,e)};n.on(`skills.installed`,e),n.installSkill(g.trim(),v)},[n,g,v]),se=(0,U.useCallback)(()=>{if(!n||!k.trim()||!j.trim())return;I(!0),R(null),te(null);let e=t=>{let r=t;I(!1),r.payload.success?(te(b.t(`activity:skillsList.createdMsg`,{name:r.payload.skill?.name??``})),n.send({type:`skills.list`})):R(r.payload.error??b.t(`activity:skillsList.createFailed`)),n.off(`skills.created`,e)};n.on(`skills.created`,e),n.createSkill(k.trim(),j.trim(),N)},[n,k,j,N]),ce=(0,U.useCallback)(()=>{n&&(ae(!0),n.checkForUpdates(void 0,void 0))},[n]),le=(0,U.useCallback)(()=>{if(!n)return;re(!0);let e=t=>{let r=t;if(re(!1),r.payload.error)console.error(`[skills.export]`,r.payload.error);else{let e=atob(r.payload.zipBase64),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);let n=new Blob([t],{type:`application/zip`}),i=URL.createObjectURL(n),a=document.createElement(`a`);a.href=i,a.download=`wrongstack-skills-${Date.now()}.zip`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}n.off(`skills.exported`,e)};n.on(`skills.exported`,e),n.exportAllSkills()},[n]);(0,U.useEffect)(()=>{if(!n)return;c(!0);let e=e=>{let t=e;if(t.payload.enabled&&t.payload.skills){o(t.payload.skills);let e=p.current,n=e.knownRefs,r=0,a={...n};for(let e of t.payload.skills){if(e.source===`bundled`)continue;let t=e.ref;if(!t)continue;let i=n[e.name];a[e.name]=t,i&&i!==t&&r++}i({...e,knownRefs:a,updateAvailableCount:r})}c(!1)},t=e=>{let t=e;if(ae(!1),t.payload.success){let e=p.current,r={...e.knownRefs};for(let e of t.payload.updated??[])r[e.name]=e.newRef;i({...e,knownRefs:r,updateAvailableCount:0}),n.send({type:`skills.list`})}};return n.on(`skills.list`,e),n.on(`skills.updated`,t),n.send({type:`skills.list`}),()=>{n.off(`skills.list`,e),n.off(`skills.updated`,t)}},[n,i]);let ue=(0,U.useCallback)(e=>{i({...p.current,selectedSkill:e,navHistory:[e],historyIndex:0,detailOpen:!0}),Q(`skills`)},[i]),de=(0,U.useMemo)(()=>{let e=a;if(l!==`all`&&(e=e.filter(e=>Gy(e.source)===l)),d.trim()){let t=d.toLowerCase();e=e.filter(e=>e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.trigger.toLowerCase().includes(t))}return e},[a,l,d]),fe=(0,U.useMemo)(()=>{let e={project:[],user:[],foreign:[],bundled:[]};for(let t of de)e[Gy(t.source)].push(t);return e},[de]),pe=r.selectedSkill?.name;return(0,Y.jsxs)(`div`,{className:X(`flex h-full min-h-0 min-w-0 flex-col overflow-hidden`,e),children:[(0,Y.jsxs)(`div`,{className:`w-full border-b flex items-center gap-1 px-2 py-2`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{_(``),w(null),E(null),y(!1),h(!0)},className:`flex items-center justify-center w-8 h-8 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors`,title:t(`activity:skillsList.installTitle`),children:(0,Y.jsx)(hn,{className:`h-4 w-4`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{A(``),M(``),P(`project`),R(null),te(null),O(!0)},className:`flex items-center justify-center w-8 h-8 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors`,title:t(`activity:skillsList.createTitle`),children:(0,Y.jsx)(gn,{className:`h-4 w-4`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:le,disabled:ne||a.length===0,className:`flex items-center justify-center w-8 h-8 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-40`,title:t(`activity:skillsList.exportTitle`),children:ne?(0,Y.jsx)(B,{className:`h-4 w-4 animate-spin`}):(0,Y.jsx)(Yn,{className:`h-4 w-4`})}),(0,Y.jsxs)(`button`,{type:`button`,onClick:ce,disabled:ie,className:`flex items-center justify-center w-8 h-8 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-40 relative`,title:t(`activity:skillsList.checkUpdatesTitle`),children:[ie?(0,Y.jsx)(B,{className:`h-4 w-4 animate-spin`}):(0,Y.jsx)(Rn,{className:`h-4 w-4`}),!ie&&r.updateAvailableCount>0&&(0,Y.jsx)(`span`,{className:`absolute top-0.5 right-0.5 h-2.5 w-2.5 rounded-full bg-primary text-[8px] font-bold text-primary-foreground flex items-center justify-center`,children:r.updateAvailableCount>9?`9+`:r.updateAvailableCount})]})]}),(0,Y.jsxs)(`div`,{className:`p-2 space-y-2 border-b shrink-0`,children:[(0,Y.jsx)(`input`,{type:`text`,value:d,onChange:e=>f(e.target.value),placeholder:t(`activity:skillsList.searchPlaceholder`),className:`w-full px-2 py-1.5 text-xs rounded border border-border bg-background focus:outline-none focus:ring-1 focus:ring-ring`}),(0,Y.jsx)(`div`,{className:`flex gap-1 flex-wrap`,children:[`all`,`project`,`user`,`foreign`,`bundled`].map(e=>{let n=e===`all`?de.length:de.filter(t=>Gy(t.source)===e).length;return(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>u(e),className:X(`px-1.5 py-0.5 text-[10px] rounded transition-colors`,l===e?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-accent`),children:[e===`all`?t(`common:action.all`):Wy(t,e),(0,Y.jsxs)(`span`,{className:X(`ml-1 font-medium`,l===e?`opacity-90`:`opacity-60`,n===0&&`line-through`),children:[`(`,n,`)`]})]},e)})})]}),(0,Y.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto`,children:s?(0,Y.jsx)(`div`,{className:`p-4 text-xs text-muted-foreground text-center`,children:t(`activity:skillsList.loading`)}):de.length===0?(0,Y.jsx)(`div`,{className:`p-4 text-xs text-muted-foreground text-center`,children:a.length===0?t(`activity:skillsList.noSkills`):t(`activity:skillsList.noMatch`)}):(0,Y.jsx)(`div`,{className:`py-1`,children:[`project`,`user`,`foreign`,`bundled`].map(e=>{let n=fe[e];return n.length===0?null:(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:`px-2 py-1 text-[10px] font-semibold text-muted-foreground uppercase tracking-wide flex items-center gap-1`,children:[(0,Y.jsx)(Ky,{source:e}),(0,Y.jsx)(`span`,{className:`ml-auto opacity-60`,children:n.length})]}),n.map(e=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>ue(e),className:X(`w-full text-left px-2 py-1.5 text-xs transition-colors`,pe===e.name?`bg-primary/10 text-primary`:`hover:bg-accent/50 text-foreground`),children:[(0,Y.jsxs)(`div`,{className:`font-medium truncate flex items-center gap-1`,children:[(0,Y.jsx)(bt,{className:`h-3 w-3 shrink-0`}),e.name]}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground truncate mt-0.5`,children:e.trigger||e.description?.slice(0,50)||t(`activity:skillsList.noDescription`)})]},e.name))]},e)})})}),m&&(0,Y.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40`,onClick:e=>{e.target===e.currentTarget&&h(!1)},children:(0,Y.jsxs)(`div`,{className:`flex max-h-[calc(100dvh-2rem)] w-[420px] max-w-[90vw] flex-col overflow-hidden rounded-lg border bg-background shadow-xl`,children:[(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between p-4 border-b`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Yn,{className:`h-4 w-4 text-primary`}),(0,Y.jsx)(`span`,{className:`font-semibold text-sm`,children:t(`activity:skillsList.installHeading`)})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>h(!1),className:`p-1 rounded hover:bg-accent text-muted-foreground cursor-pointer`,children:`✕`})]}),(0,Y.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4 space-y-3`,children:[(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`activity:skillsList.installHint`)}),(0,Y.jsx)(`input`,{type:`text`,value:g,onChange:e=>{_(e.target.value),w(null),E(null)},onKeyDown:e=>{e.key===`Enter`&&!x&&oe()},placeholder:t(`activity:skillsList.installPlaceholder`),className:`w-full px-3 py-2 text-xs rounded border border-border bg-background focus:outline-none focus:ring-1 focus:ring-ring`,autoFocus:!0}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`label`,{className:`text-xs text-muted-foreground`,children:t(`activity:skillsList.installScope`)}),(0,Y.jsxs)(`div`,{className:`flex rounded border border-border overflow-hidden`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>y(!1),className:X(`px-2 py-1 text-[10px] transition-colors`,v?`bg-background hover:bg-accent`:`bg-primary text-primary-foreground`),children:t(`activity:skillDetail.scopeProject`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>y(!0),className:X(`px-2 py-1 text-[10px] transition-colors border-l border-border`,v?`bg-primary text-primary-foreground`:`bg-background hover:bg-accent`),children:t(`activity:skillDetail.scopeGlobal`)})]})]}),C&&(0,Y.jsx)(`p`,{className:`text-xs text-destructive bg-destructive/10 rounded px-2 py-1`,children:C}),T&&(0,Y.jsx)(`p`,{className:`text-xs text-emerald-600 dark:text-emerald-400 bg-emerald-500/10 rounded px-2 py-1`,children:T})]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 p-4 border-t bg-muted/20`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>h(!1),className:`px-3 py-1.5 text-xs rounded border border-border hover:bg-accent transition-colors`,children:t(T?`common:action.close`:`common:action.cancel`)}),!T&&(0,Y.jsxs)(`button`,{type:`button`,onClick:oe,disabled:x||!g.trim(),className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:[x&&(0,Y.jsx)(B,{className:`h-3 w-3 animate-spin`}),t(`activity:skillsList.installBtn`)]})]})]})}),D&&(0,Y.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40`,onClick:e=>{e.target===e.currentTarget&&O(!1)},children:(0,Y.jsxs)(`div`,{className:`flex max-h-[calc(100dvh-2rem)] w-[480px] max-w-[90vw] flex-col overflow-hidden rounded-lg border bg-background shadow-xl`,children:[(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between p-4 border-b`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(gn,{className:`h-4 w-4 text-primary`}),(0,Y.jsx)(`span`,{className:`font-semibold text-sm`,children:t(`activity:skillsList.createHeading`)})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>O(!1),className:`p-1 rounded hover:bg-accent text-muted-foreground cursor-pointer`,children:`✕`})]}),(0,Y.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4 space-y-3`,children:[(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`activity:skillsList.createHint`)}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`label`,{className:`block text-xs font-medium mb-1`,children:[t(`activity:skillsList.nameLabel`),` `,(0,Y.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,Y.jsx)(`input`,{type:`text`,value:k,onChange:e=>{A(e.target.value.trim().toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``)),R(null),te(null)},placeholder:t(`activity:skillsList.namePlaceholder`),className:`w-full px-3 py-2 text-xs rounded border border-border bg-background focus:outline-none focus:ring-1 focus:ring-ring font-mono`,autoFocus:!0})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`label`,{className:`block text-xs font-medium mb-1`,children:[t(`activity:skillsList.descLabel`),` `,(0,Y.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,Y.jsx)(`textarea`,{value:j,onChange:e=>{M(e.target.value),R(null),te(null)},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&!F&&se()},placeholder:t(`activity:skillsList.descPlaceholder`),rows:4,className:`w-full px-3 py-2 text-xs rounded border border-border bg-background focus:outline-none focus:ring-1 focus:ring-ring resize-y`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`label`,{className:`text-xs text-muted-foreground`,children:t(`activity:skillsList.saveIn`)}),(0,Y.jsxs)(`div`,{className:`flex rounded border border-border overflow-hidden`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>P(`project`),className:X(`px-2 py-1 text-[10px] transition-colors`,N===`project`?`bg-primary text-primary-foreground`:`bg-background hover:bg-accent`),children:t(`activity:skillDetail.scopeProject`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>P(`global`),className:X(`px-2 py-1 text-[10px] transition-colors border-l border-border`,N===`global`?`bg-primary text-primary-foreground`:`bg-background hover:bg-accent`),children:t(`activity:skillDetail.scopeGlobal`)})]})]}),L&&(0,Y.jsx)(`p`,{className:`text-xs text-destructive bg-destructive/10 rounded px-2 py-1`,children:L}),ee&&(0,Y.jsx)(`p`,{className:`text-xs text-emerald-600 dark:text-emerald-400 bg-emerald-500/10 rounded px-2 py-1`,children:ee})]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 p-4 border-t bg-muted/20`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>O(!1),className:`px-3 py-1.5 text-xs rounded border border-border hover:bg-accent transition-colors`,children:t(ee?`common:action.close`:`common:action.cancel`)}),!ee&&(0,Y.jsxs)(`button`,{type:`button`,onClick:se,disabled:F||!k.trim()||!j.trim(),className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:[F&&(0,Y.jsx)(B,{className:`h-3 w-3 animate-spin`}),t(`activity:skillsList.createBtn`)]})]})]})})]})}var Jy=[`web`,`react-native`,`flutter`,`swiftui`,`compose`],Yy=[`bg`,`surface`,`primary`,`accent`,`fg`,`border`];function Xy({tokens:e,label:t}){let n=Yy.filter(t=>e[t]);return n.length===0?null:(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-[9px] uppercase tracking-wide text-muted-foreground w-7`,children:t}),(0,Y.jsx)(`div`,{className:`flex gap-0.5`,children:n.map(t=>(0,Y.jsx)(`div`,{className:`w-4 h-4 rounded-sm border border-black/10 dark:border-white/10`,style:{backgroundColor:e[t]},title:`${t}: ${e[t]}`},t))})]})}function Zy({className:e}){let{client:t}=sd(),{t:n}=V(),[r,i]=(0,U.useState)([]),[a,o]=(0,U.useState)(null),[s,c]=(0,U.useState)(!0),[l,u]=(0,U.useState)(`web`),[d,f]=(0,U.useState)(null);(0,U.useEffect)(()=>{if(!t)return;let e=e=>{let t=e.payload;i(t?.kits??[]),o(t?.activeKit??null),c(!1)},n=e=>{let t=e.payload;f(null),t?.ok&&t.kit&&o(t.kit)};return t.on(`design.list`,e),t.on(`design.use`,n),t.send({type:`design.list`}),()=>{t.off(`design.list`,e),t.off(`design.use`,n)}},[t]);let p=(0,U.useCallback)(e=>{t&&(f(e),t.send({type:`design.use`,payload:{kit:e,stack:l}}))},[t,l]),m=(0,U.useMemo)(()=>[...r].sort((e,t)=>e.name.localeCompare(t.name)),[r]);return(0,Y.jsxs)(`div`,{className:X(`flex h-full min-h-0 min-w-0 flex-col`,e),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-border/50`,children:[(0,Y.jsx)(Wt,{className:`w-4 h-4 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground flex-1`,children:n(`activity:designStudio.pickHint`)}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>Q(`design`),className:`inline-flex items-center gap-1 text-[11px] px-1.5 py-0.5 rounded border border-border/60 hover:bg-muted`,title:n(`activity:designStudio.galleryTitle`),children:[(0,Y.jsx)(je,{className:`w-3 h-3`}),` `,n(`activity:designStudio.gallery`)]}),(0,Y.jsx)(`select`,{value:l,onChange:e=>u(e.target.value),className:`text-[11px] bg-transparent border border-border/60 rounded px-1 py-0.5`,title:n(`activity:designStudio.stackTitle`),children:Jy.map(e=>(0,Y.jsx)(`option`,{value:e,children:e},e))})]}),(0,Y.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto p-2 space-y-2`,children:[s&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground p-3`,children:[(0,Y.jsx)(B,{className:`w-4 h-4 animate-spin`}),` `,n(`activity:designStudio.loading`)]}),!s&&m.length===0&&(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground p-3`,children:n(`activity:designStudio.notFound`)}),m.map(e=>{let t=a===e.id;return(0,Y.jsxs)(`div`,{className:X(`rounded-lg border p-3 transition-colors`,t?`border-primary/60 bg-primary/5`:`border-border/60 hover:border-border`),children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold truncate`,children:e.name}),t&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[9px] font-semibold uppercase text-primary`,children:[(0,Y.jsx)(z,{className:`w-3 h-3`}),` `,n(`activity:design.active`)]})]}),(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground leading-snug mt-0.5`,children:e.aesthetic})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>p(e.id),disabled:d===e.id,className:X(`shrink-0 text-[11px] px-2 py-1 rounded font-medium`,t?`bg-primary/10 text-primary`:`bg-primary text-primary-foreground hover:opacity-90`),children:d===e.id?`…`:n(t?`activity:design.reapply`:`activity:design.use`)})]}),(0,Y.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,Y.jsx)(Xy,{tokens:e.light,label:n(`activity:designStudio.light`)}),(0,Y.jsx)(Xy,{tokens:e.dark,label:n(`activity:designStudio.dark`)})]}),e.bestFor&&(0,Y.jsxs)(`p`,{className:`text-[10px] text-muted-foreground mt-2 leading-snug`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:n(`activity:designStudio.bestFor`)}),` `,e.bestFor]}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1.5`,children:e.stacks.map(e=>(0,Y.jsx)(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:e},e))})]},e.id)})]})]})}var Qy=new Set([`allocating`,`active`,`committing`,`merging`]),$y={active:`text-amber-500`,committing:`text-cyan-500`,merging:`text-blue-500`,merged:`text-emerald-500`,"needs-review":`text-fuchsia-500`,failed:`text-rose-500`,orphan:`text-zinc-400`};function eb(){let{client:e}=sd(),{t}=V(),n=e=>e?e.replace(/^wstack\/ap\//,``):t(`activity:worktrees.detached`),r=Es(e=>e.worktrees),i=Es(e=>e.orphans),a=Es(e=>e.baseBranch),o=Es(e=>e.canClean),s=Es(e=>e.cleanResult),c=Es(e=>e.mergeResult),l=Es(e=>e.diffByDir),[u,d]=(0,U.useState)(null),[f,p]=(0,U.useState)(null),m=(0,U.useMemo)(()=>e?e.send.bind(e):void 0,[e]);(0,U.useEffect)(()=>{m?.({type:`worktree.scan`})},[m]),(0,U.useEffect)(()=>{d(null)},[c,s]);let h=(0,U.useMemo)(()=>{let e=new Set(r.map(e=>e.branch)),t=r.map(e=>({branch:e.branch,dir:e.dir,status:e.status,baseBranch:e.baseBranch,insertions:e.insertions,deletions:e.deletions,files:e.files,owner:e.ownerLabel,live:Qy.has(e.status)}));for(let n of i)n.branch&&e.has(n.branch)||t.push({branch:n.branch,dir:n.dir,status:`orphan`,insertions:0,deletions:0,files:0,live:!1});return t},[r,i]),g=(e,t)=>{e&&m?.({type:`shell.open`,payload:{path:e,target:t}})},_=e=>{e&&(m?.({type:`worktree.diff`,payload:{dir:e}}),p(t=>t===e?null:e))},v=async e=>{e&&await Af({title:t(`activity:worktrees.mergeConfirmTitle`,{branch:n(e),base:a||t(`activity:worktrees.baseLabel`)}),message:t(`activity:worktrees.mergeConfirmMsg`),confirmLabel:t(`activity:worktrees.mergeAction`)})&&(d(e),m?.({type:`worktree.merge`,payload:{branch:e}}))},y=async e=>{await Af({title:t(`activity:worktrees.removeConfirmTitle`,{branch:n(e.branch)}),message:t(`activity:worktrees.removeConfirmMsg`),confirmLabel:t(`common:action.remove`),danger:!0})&&(d(e.branch??``),m?.({type:`worktree.remove`,payload:{dir:e.dir,branch:e.branch}}))};return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2`,children:[(0,Y.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[t(`activity:worktrees.count`,{count:h.length}),a?t(`activity:worktrees.baseSuffix`,{base:a}):``]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[i.length>0&&(0,Y.jsxs)(`button`,{type:`button`,disabled:!o,onClick:()=>m?.({type:`worktree.cleanup`}),title:t(o?`activity:worktrees.cleanOrphansTitle`:`activity:worktrees.liveBusyTitle`),className:`inline-flex items-center gap-1 rounded bg-amber-600/90 px-1.5 py-0.5 text-[11px] font-medium text-white hover:bg-amber-700 disabled:opacity-50`,children:[(0,Y.jsx)(en,{className:`h-3 w-3`}),` `,t(`activity:worktrees.cleanOrphans`)]}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>m?.({type:`worktree.scan`}),title:t(`activity:worktrees.rescanTitle`),className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,Y.jsx)(Rn,{className:`h-3.5 w-3.5`})})]})]}),s&&(0,Y.jsx)(nb,{ok:s.ok,children:s.ok?t(`activity:worktrees.removed`,{count:s.removed}):s.reason??t(`activity:worktrees.failed`)}),c&&(0,Y.jsx)(nb,{ok:c.ok,children:c.ok?t(`activity:worktrees.mergedIntoBase`,{branch:n(c.branch)}):c.conflict?t(`activity:worktrees.conflictMerge`,{branch:n(c.branch),files:(c.conflictFiles??[]).join(`, `)||t(`activity:worktrees.seeGit`)}):t(`activity:worktrees.mergeFailed`,{reason:c.reason??t(`activity:worktrees.unknownReason`)})}),(0,Y.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto px-2 pb-3`,children:h.length===0?(0,Y.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 text-center text-xs text-muted-foreground`,children:[(0,Y.jsx)(de,{className:`h-8 w-8 opacity-30`}),(0,Y.jsx)(`p`,{children:t(`activity:worktrees.empty`)}),(0,Y.jsx)(`p`,{className:`max-w-[200px]`,children:t(`activity:worktrees.emptyHint`)})]}):h.map((e,r)=>{let i=u===(e.branch??``),a=e.dir?l[e.dir]:void 0;return(0,Y.jsxs)(`div`,{className:`mb-1.5 rounded-md border border-border bg-card/60 px-2.5 py-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(de,{className:X(`h-3.5 w-3.5 shrink-0`,$y[e.status]??`text-muted-foreground`)}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-foreground`,title:e.branch,children:n(e.branch)}),(0,Y.jsx)(`span`,{className:X(`shrink-0 text-[10px] uppercase`,$y[e.status]??`text-muted-foreground`),children:e.status})]}),(0,Y.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2 pl-5 text-[10px] text-muted-foreground`,children:[e.owner&&(0,Y.jsx)(`span`,{className:`truncate`,children:e.owner}),(e.insertions>0||e.deletions>0)&&(0,Y.jsxs)(`span`,{className:`shrink-0`,children:[(0,Y.jsxs)(`span`,{className:`text-emerald-500`,children:[`+`,e.insertions]}),` `,(0,Y.jsxs)(`span`,{className:`text-rose-500`,children:[`−`,e.deletions]}),` · `,e.files,`f`]})]}),(0,Y.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-0.5 pl-5`,children:[(0,Y.jsx)(tb,{title:t(`activity:worktrees.actOpenTerm`),disabled:!e.dir,onClick:()=>g(e.dir,`terminal`),children:(0,Y.jsx)(En,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(tb,{title:t(`activity:worktrees.actOpenFolder`),disabled:!e.dir,onClick:()=>g(e.dir,`file-manager`),children:(0,Y.jsx)(Fe,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(tb,{title:t(`activity:worktrees.actViewChanges`),disabled:!e.dir,onClick:()=>_(e.dir),children:(0,Y.jsx)(An,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(tb,{title:t(`activity:worktrees.actMerge`),disabled:e.live||!e.branch,onClick:()=>v(e.branch),children:i?(0,Y.jsx)(B,{className:`h-3.5 w-3.5 animate-spin`}):(0,Y.jsx)(st,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(tb,{title:t(`activity:worktrees.actRemove`),danger:!0,disabled:e.live,onClick:()=>y(e),children:(0,Y.jsx)(C,{className:`h-3.5 w-3.5`})}),e.live&&(0,Y.jsx)(`span`,{className:`ml-1 text-[10px] text-amber-500`,children:t(`activity:worktrees.live`)})]}),f===e.dir&&a!==void 0&&(0,Y.jsx)(`div`,{className:`mt-1.5 ml-5 rounded bg-muted/50 p-1.5 text-[10px]`,children:a===null||a.files.length===0?(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[t(`activity:worktrees.noUncommitted`),a&&a.commits>0?` · ${t(`activity:worktrees.commitsAhead`,{count:a.commits})}`:``,`.`]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`mb-1 text-muted-foreground`,children:[a.commits>0?`${t(`activity:worktrees.commitsAhead`,{count:a.commits})} · `:``,(0,Y.jsxs)(`span`,{className:`text-emerald-500`,children:[`+`,a.insertions]}),` `,(0,Y.jsxs)(`span`,{className:`text-rose-500`,children:[`−`,a.deletions]})]}),a.files.slice(0,12).map(e=>(0,Y.jsxs)(`div`,{className:`truncate font-mono`,children:[(0,Y.jsxs)(`span`,{className:`text-emerald-500`,children:[`+`,e.insertions]}),` `,(0,Y.jsxs)(`span`,{className:`text-rose-500`,children:[`−`,e.deletions]}),` `,e.path]},e.path)),a.files.length>12&&(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:worktrees.more`,{count:a.files.length-12})})]})})]},`${e.branch??e.dir??r}`)})})]})}function tb({title:e,onClick:t,disabled:n,danger:r,children:i}){return(0,Y.jsx)(`button`,{type:`button`,title:e,disabled:n,onClick:t,className:X(`rounded p-1 text-muted-foreground hover:bg-muted disabled:cursor-not-allowed disabled:opacity-30`,r?`hover:text-rose-500`:`hover:text-foreground`),children:i})}function nb({ok:e,children:t}){return(0,Y.jsxs)(`div`,{className:X(`flex items-start gap-1.5 border-y px-3 py-1.5 text-[11px]`,e?`border-emerald-500/30 bg-emerald-500/5 text-emerald-600 dark:text-emerald-300`:`border-amber-500/30 bg-amber-500/5 text-amber-600 dark:text-amber-300`),children:[e?(0,Y.jsx)(rn,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}):(0,Y.jsx)(gt,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1`,children:t}),!e&&(0,Y.jsx)(Nn,{className:`mt-0.5 h-3 w-3 shrink-0 opacity-40`})]})}function rb({label:e,checked:t,onChange:n}){return(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:`flex w-full items-center justify-between px-2 py-1.5 rounded text-xs hover:bg-accent/50 transition-colors`,children:[(0,Y.jsx)(`span`,{className:`text-foreground`,children:e}),(0,Y.jsx)(`span`,{className:X(`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition-colors`,t?`bg-primary`:`bg-muted`),children:(0,Y.jsx)(`span`,{className:X(`inline-block h-3 w-3 transform rounded-full bg-background transition-transform`,t?`translate-x-3.5`:`translate-x-0.5`)})})]})}var ib=[{value:`dots`,labelKey:`bgDots`},{value:`lines`,labelKey:`bgLines`},{value:`cross`,labelKey:`bgCross`},{value:`none`,labelKey:`bgNone`}];function ab(){let{t:e}=V(),{showHud:t,showLegend:n,showMinimap:r,showControls:i,animateEdges:a,background:o,setShowHud:s,setShowLegend:c,setShowMinimap:l,setShowControls:u,setAnimateEdges:d,setBackground:f}=Fc(),{clientCounts:p,currentSession:m,totalAgents:h,activeAgents:g}=Tc(),_=p.tui+p.webui+p.repl;return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col gap-4 overflow-y-auto p-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wide mb-2`,children:e(`activity:officeMap.liveHeading`)}),(0,Y.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Y.jsx)(Rr,{className:`h-3.5 w-3.5`}),` `,e(`activity:officeMap.clients`)]}),(0,Y.jsx)(`span`,{className:`font-mono`,children:_})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Y.jsx)(j,{className:`h-3.5 w-3.5`}),` `,e(`activity:officeMap.agents`)]}),(0,Y.jsxs)(`span`,{className:`font-mono`,children:[g,(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[` / `,h]})]})]}),m.model&&(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Y.jsx)(wr,{className:`h-3.5 w-3.5`}),` `,e(`activity:officeMap.model`)]}),(0,Y.jsx)(`span`,{className:`font-mono truncate max-w-[140px]`,title:m.model,children:m.model.split(`/`).pop()})]}),m.mode&&(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Y.jsx)(tn,{className:`h-3.5 w-3.5`}),` `,e(`activity:officeMap.mode`)]}),(0,Y.jsx)(`span`,{className:`font-mono uppercase text-[10px]`,children:m.mode})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Y.jsx)($n,{className:`h-3.5 w-3.5`}),` `,e(`activity:officeMap.toolCalls`)]}),(0,Y.jsx)(`span`,{className:`font-mono`,children:(e=>e?.toLocaleString()??`0`)(m.toolCalls)})]})]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wide mb-1`,children:e(`activity:officeMap.displayHeading`)}),(0,Y.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Y.jsx)(rb,{label:e(`activity:officeMap.statsHud`),checked:t,onChange:s}),(0,Y.jsx)(rb,{label:e(`activity:officeMap.legends`),checked:n,onChange:c}),(0,Y.jsx)(rb,{label:e(`activity:officeMap.minimap`),checked:r,onChange:l}),(0,Y.jsx)(rb,{label:e(`activity:officeMap.zoomControls`),checked:i,onChange:u}),(0,Y.jsx)(rb,{label:e(`activity:officeMap.animateWires`),checked:a,onChange:d})]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wide mb-1.5 px-2`,children:e(`activity:officeMap.backgroundHeading`)}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1 px-2`,children:ib.map(t=>(0,Y.jsx)(`button`,{type:`button`,onClick:()=>f(t.value),className:X(`px-2 py-1 text-[10px] rounded transition-colors`,o===t.value?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-accent`),children:e(`activity:officeMap.${t.labelKey}`)},t.value))})]})]})}function ob({desktopShell:e=!1}){let t=J(e=>e.activeActivity),n=J(e=>e.setSidebarOpen),r=J(e=>e.sidebarWidth),i=J(e=>e.setSidebarWidth),a=K(e=>e.wsConnected),{client:o}=sd(),{t:s}=V(),c=e?Math.min(r,280):r;return(0,U.useEffect)(()=>{if(t!==`files`||!a)return;ic.getState().setTreeLoading(!0);let e=q.getState().cwd;o?.send({type:`files.tree`,payload:e?{path:e}:{}})},[t,a,o]),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:X(`fixed inset-y-0 right-0 z-30 bg-black/20 md:hidden`,e?`left-10`:`left-12`),onClick:()=>n(!1),"aria-hidden":`true`}),(0,Y.jsxs)(`aside`,{style:{width:`${c}px`,maxWidth:e?`min(300px, calc(100vw - 2.5rem))`:`calc(100vw - 3rem)`},className:X(`fixed inset-y-0 z-40 flex min-h-0 min-w-0 shrink-0 flex-col overflow-hidden border-r bg-card shadow-2xl animate-slide-in md:relative md:inset-auto md:z-auto md:shadow-none`,e?`left-10`:`left-12`),children:[(0,Y.jsx)(`div`,{onMouseDown:e=>{e.preventDefault();let t=e.clientX,n=r,a=e=>i(n+(e.clientX-t)),o=()=>{window.removeEventListener(`mousemove`,a),window.removeEventListener(`mouseup`,o),document.body.style.cursor=``,document.body.style.userSelect=``};window.addEventListener(`mousemove`,a),window.addEventListener(`mouseup`,o),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`},onDoubleClick:()=>i(304),className:`group/handle absolute top-0 right-0 h-full w-2 cursor-col-resize z-10 flex items-center justify-end`,title:s(`activity:sidePanel.dragHint`),children:(0,Y.jsx)(`div`,{className:`h-full w-px bg-border group-hover/handle:bg-primary/60 group-hover/handle:w-0.5 transition-all`})}),(0,Y.jsxs)(`div`,{className:X(`flex items-center justify-between border-b shrink-0`,e?`px-2.5 py-2`:`px-3 py-2.5`),children:[(0,Y.jsx)(`span`,{className:`text-xs font-semibold tracking-tight text-muted-foreground uppercase`,children:s(`activity:nav.${t}`)}),(0,Y.jsx)($,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>n(!1),title:s(`activity:sidePanel.collapse`),children:(0,Y.jsx)(fr,{className:`h-3.5 w-3.5`})})]}),(0,Y.jsxs)(`div`,{className:`flex-1 min-h-0 min-w-0 flex flex-col overflow-hidden`,children:[t===`chat`&&(0,Y.jsx)(Uy,{}),t===`agents`&&(0,Y.jsx)(Dy,{}),t===`history`&&(0,Y.jsx)(Fy,{}),t===`files`&&(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto`,children:(0,Y.jsx)(gy,{})}),t===`changes`&&(0,Y.jsx)(jy,{}),t===`mailbox`&&(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto p-3`,children:(0,Y.jsx)(yy,{})}),t===`skills`&&(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Y.jsx)(qy,{className:`h-full`})}),t===`design`&&(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Y.jsx)(Zy,{className:`h-full`})}),t===`worktrees`&&(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Y.jsx)(eb,{})}),t===`officemap`&&(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Y.jsx)(ab,{})})]})]})]})}function sb(e){return e===`project`||e===`user`}function cb(e){let t=e.match(/^(.+?)\/SKILL(?:\.save)?\.md$/);return t?t[1]:null}function lb({source:e}){let{t}=V(),n=e===`project`?`project`:e===`user`?`user`:`bundled`;return(0,Y.jsx)(`span`,{className:X(`inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wide`,n===`project`&&`bg-emerald-100 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-400`,n===`user`&&`bg-violet-100 text-violet-700 dark:bg-violet-950 dark:text-violet-400`,n===`bundled`&&`bg-slate-100 text-slate-600 dark:bg-slate-800 dark:text-slate-400`),children:t(`activity:skillDetail.${{project:`scopeProject`,user:`scopeGlobal`,bundled:`scopeBundled`}[n]}`)})}function ub({className:e}){let{t}=V(),{client:n}=sd(),r=J(e=>e.skillsState),i=J(e=>e.setSkillsState),a=r.selectedSkill,o=r.navHistory,s=r.historyIndex,[l,u]=(0,U.useState)(null),[d,p]=(0,U.useState)(!1),[m,h]=(0,U.useState)(null),[g,_]=(0,U.useState)(!1),[v,y]=(0,U.useState)(``),[x,S]=(0,U.useState)(!1),[w,T]=(0,U.useState)(null),[E,D]=(0,U.useState)(!1),[O,k]=(0,U.useState)(null),[A,j]=(0,U.useState)(!1),M=(0,U.useRef)(``),[N,P]=(0,U.useState)(!1),[F,I]=(0,U.useState)(null),[L,R]=(0,U.useState)(!1),[ee,te]=(0,U.useState)(null),[ne,re]=(0,U.useState)(!1),[ae,oe]=(0,U.useState)([]),se=(0,U.useRef)(r);se.current=r;let ce=(0,U.useRef)(!1),le=(0,U.useMemo)(()=>v?{lines:v.split(`
157
- `).length,words:v.trim()?v.trim().split(/\s+/).length:0,chars:v.length}:{lines:0,words:0,chars:0},[v]),ue=(0,U.useMemo)(()=>{if(!v)return null;let e=5*1024*1024,t=new Blob([v]).size;return t>=e?{level:`critical`,used:t,limit:e}:t>=4194304?{level:`warn`,used:t,limit:e}:null},[v]);(0,U.useEffect)(()=>{if(!O)return;let e=setTimeout(()=>k(null),2e3);return()=>clearTimeout(e)},[O]),(0,U.useEffect)(()=>{if(!g||!a)return;let e=setInterval(()=>{v&&v!==M.current&&(M.current=v,localStorage.setItem(`skills_draft_${a.name}`,JSON.stringify({content:v,savedAt:Date.now()})),k(Date.now()))},5e3);return()=>clearInterval(e)},[g,v,a]),(0,U.useEffect)(()=>{if(!a||!g)return;let e=localStorage.getItem(`skills_draft_${a.name}`);if(e)try{let{content:t}=JSON.parse(e);t&&t!==v&&t!==M.current&&(y(t),M.current=t,j(!0))}catch{}},[a?.name,g]),(0,U.useEffect)(()=>{if(!n||!a)return;p(!0),u(null),h(null);let e=setTimeout(()=>{p(!1),h(b.t(`activity:skillDetail.timeoutError`))},1e4),t=t=>{clearTimeout(e);let n=t;n.payload.error?h(n.payload.error):n.payload.name&&u(n.payload),p(!1)},r=e=>{let t=e;P(!1);let r=se.current;if(t.payload.success){let e={...r.knownRefs};for(let n of t.payload.updated??[])e[n.name]=n.newRef;i({...r,knownRefs:e,updateAvailableCount:0}),I({updated:t.payload.updated??[],unchanged:t.payload.unchanged??[],errors:t.payload.errors??[]}),n.send({type:`skills.list`})}else I({updated:[],unchanged:[],errors:[{name:``,error:t.payload.error??b.t(`activity:skillDetail.updateFailed`)}]})},o=e=>{let t=e;t.payload.skills&&oe(t.payload.skills)};return n.on(`skills.content`,t),n.on(`skills.updated`,r),n.on(`skills.list`,o),n.send({type:`skills.content`,payload:{name:a.name,source:a.source}}),()=>{clearTimeout(e),n.off(`skills.content`,t),n.off(`skills.updated`,r),n.off(`skills.list`,o)}},[n,a?.name,a?.source]),(0,U.useEffect)(()=>{g&&(_(!1),y(``),T(null))},[a?.name]);let de=(0,U.useCallback)(e=>ae.find(t=>t.name.toLowerCase()===e.toLowerCase()),[ae]),fe=(0,U.useCallback)(e=>{let t=de(e);if(t){ce.current=!1;let e=o.slice(0,s+1);e.push(t),i({...se.current,selectedSkill:t,navHistory:e,historyIndex:e.length-1}),_(!1),y(``),I(null)}},[de,o,s,i]),pe=(0,U.useCallback)(()=>{if(s<=0)return;ce.current=!0;let e=s-1,t=o[e];i({...se.current,selectedSkill:t,historyIndex:e}),_(!1),y(``),I(null)},[s,o,i]),me=(0,U.useCallback)(()=>{if(s>=o.length-1)return;ce.current=!0;let e=s+1,t=o[e];i({...se.current,selectedSkill:t,historyIndex:e}),_(!1),y(``),I(null)},[s,o,i]),he=(0,U.useCallback)(()=>{Q(`chat`)},[]),ge=(0,U.useCallback)(()=>{l&&(y(l.body),M.current=l.body,j(!1),T(null),_(!0),D(!1))},[l]),_e=(0,U.useCallback)(()=>{_(!1),y(``),T(null),D(!1),j(!1),a&&localStorage.removeItem(`skills_draft_${a.name}`)},[a]),ve=(0,U.useCallback)(()=>{!a||!l||(j(!1),y(l.body),M.current=l.body,a&&localStorage.removeItem(`skills_draft_${a.name}`))},[a,l]),ye=(0,U.useCallback)(()=>{if(!n||!a||!v.trim())return;S(!0),T(null);let e=t=>{let r=t;S(!1),r.payload.success?(M.current=``,localStorage.removeItem(`skills_draft_${a.name}`),j(!1),_(!1),n.send({type:`skills.content`,payload:{name:a.name,source:a.source}}),n.send({type:`skills.list`})):T(r.payload.error??b.t(`activity:skillDetail.saveFailed`)),n.off(`skills.edited`,e)};n.on(`skills.edited`,e),n.editSkill(a.name,v)},[n,a,v]),be=(0,U.useCallback)(()=>{!n||!a||(P(!0),I(null),n.checkForUpdates(a.name,a.source===`user`))},[n,a]),xe=(0,U.useCallback)(()=>{a?.sourceUrl&&navigator.clipboard.writeText(a.sourceUrl).then(()=>{R(!0),setTimeout(()=>R(!1),2e3)})},[a]),Se=(0,U.useCallback)(()=>{if(!l?.body)return;let e=new Blob([l.body],{type:`text/markdown`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${l.name.replace(/\//g,`_`)}-SKILL.md`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)},[l]),Ce=(0,U.useCallback)(async e=>{if(!n||!e)return;re(!0);let t=e=>{let r=e;re(!1),r.payload.success?(te(null),n.send({type:`skills.list`}),he()):T(r.payload.error??b.t(`activity:skillDetail.uninstallFailed`)),n.off(`skills.uninstalled`,t)};n.on(`skills.uninstalled`,t),n.uninstallSkill(e.name,e.source===`user`)},[n,he]);return a?(0,Y.jsxs)(`div`,{className:X(`flex h-full min-h-0 min-w-0 flex-col overflow-hidden bg-background`,e),children:[(0,Y.jsxs)(`div`,{className:`px-4 py-3 border-b bg-card shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(bt,{className:`h-4 w-4 text-primary shrink-0`}),(0,Y.jsx)(`h1`,{className:`text-base font-semibold truncate`,children:a.name}),a.version&&(0,Y.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`v`,a.version]}),(0,Y.jsx)(lb,{source:a.source})]}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:a.description||a.trigger}),a.sourceUrl&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 mt-2`,children:[(0,Y.jsxs)(`a`,{href:`https://${a.sourceUrl.replace(`github:`,``)}`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,title:t(`activity:skillDetail.openSourceRepo`),children:[(0,Y.jsx)($e,{className:`h-3 w-3 shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate font-mono`,children:a.sourceUrl})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:xe,className:`flex items-center shrink-0 text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,title:t(`activity:skillDetail.copySourceUrl`),children:L?(0,Y.jsx)(z,{className:`h-3 w-3 text-green-500`}):(0,Y.jsx)(Ft,{className:`h-3 w-3`})})]}),a.scope.length>0&&(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:a.scope.map(e=>(0,Y.jsx)(`span`,{className:`px-1.5 py-0.5 text-[10px] rounded bg-muted text-muted-foreground`,children:e},e))}),F&&(0,Y.jsxs)(`div`,{className:`mt-2 text-xs space-y-1`,children:[F.updated.length>0&&(0,Y.jsx)(`div`,{className:`text-green-600`,children:t(`activity:skillDetail.updatedLabel`,{list:F.updated.map(e=>`${e.name} (${e.oldRef} → ${e.newRef})`).join(`, `)})}),F.unchanged.length>0&&(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:skillDetail.upToDateLabel`,{list:F.unchanged.join(`, `)})}),F.errors.length>0&&(0,Y.jsx)(`div`,{className:`text-destructive`,children:t(`activity:skillDetail.errorsLabel`,{list:F.errors.map(e=>`${e.name?`${e.name}: `:``}${e.error}`).join(`; `)})})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 ml-auto shrink-0`,children:[sb(a.source)&&a.sourceUrl&&(0,Y.jsx)(`button`,{type:`button`,onClick:be,disabled:N,className:`flex items-center gap-1 px-2 py-1.5 text-xs rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors cursor-pointer disabled:opacity-50`,title:t(`activity:skillDetail.checkUpdatesTitle`),children:N?(0,Y.jsx)(B,{className:`h-3.5 w-3.5 animate-spin`}):(0,Y.jsx)(Rn,{className:`h-3.5 w-3.5`})}),a.source!==`bundled`&&!g&&(0,Y.jsx)(`button`,{type:`button`,onClick:Se,className:`flex items-center gap-1 px-2 py-1.5 text-xs rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors cursor-pointer`,title:t(`activity:skillDetail.exportTitle`),children:(0,Y.jsx)(Yn,{className:`h-3.5 w-3.5`})}),sb(a.source)&&!g&&(0,Y.jsx)(`button`,{type:`button`,onClick:ge,className:`flex items-center gap-1 px-2 py-1.5 text-xs rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors cursor-pointer`,title:t(`activity:skillDetail.editTitle`),children:(0,Y.jsx)(zt,{className:`h-3.5 w-3.5`})}),sb(a.source)&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>te(a),className:`flex items-center gap-1 px-2 py-1.5 text-xs rounded text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors cursor-pointer`,title:t(`activity:skillDetail.uninstallTitle`),children:(0,Y.jsx)(C,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:he,className:`p-1.5 rounded hover:bg-accent text-muted-foreground cursor-pointer`,title:t(`activity:skillDetail.closeTitle`),children:(0,Y.jsx)(Xn,{className:`h-4 w-4`})})]})]}),o.length>1&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 mt-2`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:pe,disabled:s<=0,className:X(`p-1 rounded transition-colors`,s<=0?`text-muted-foreground/40 cursor-not-allowed`:`hover:bg-accent text-muted-foreground cursor-pointer`),title:t(`activity:skillDetail.backTitle`),children:(0,Y.jsx)(c,{className:`h-4 w-4`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:me,disabled:s>=o.length-1,className:X(`p-1 rounded transition-colors`,s>=o.length-1?`text-muted-foreground/40 cursor-not-allowed`:`hover:bg-accent text-muted-foreground cursor-pointer`),title:t(`activity:skillDetail.forwardTitle`),children:(0,Y.jsx)(Oe,{className:`h-4 w-4`})}),(0,Y.jsx)(`div`,{className:`flex items-center gap-0.5 overflow-x-auto text-xs`,children:o.map((e,t)=>(0,Y.jsxs)(`span`,{className:`flex items-center shrink-0`,children:[t>0&&(0,Y.jsx)(Oe,{className:`h-3 w-3 text-muted-foreground/40 mx-0.5 shrink-0`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{t<s&&(ce.current=!0,i({...se.current,selectedSkill:e,historyIndex:t}),_(!1),y(``),I(null))},className:X(`hover:text-primary cursor-pointer transition-colors`,t===s?`text-primary font-medium`:`text-muted-foreground`),children:e.name})]},e.name+t))})]})]}),l&&(l.relatedFiles.length>0||l.references.length>0)&&(0,Y.jsxs)(`div`,{className:`px-4 py-2 border-b bg-muted/30 shrink-0 space-y-2`,children:[l.relatedFiles.length>0&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,Y.jsx)(Fe,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{className:`font-medium uppercase tracking-wide`,children:t(`activity:skillDetail.relatedFiles`)})]}),l.relatedFiles.map(e=>{let n=cb(e);return n&&de(n)?(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>fe(n),className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded bg-background border border-border hover:border-primary hover:text-primary transition-colors cursor-pointer`,title:t(`activity:skillDetail.goToSkillTitle`,{name:n}),children:[(0,Y.jsx)(f,{className:`h-2.5 w-2.5`}),e]},e):(0,Y.jsx)(`span`,{className:`px-1.5 py-0.5 text-[10px] rounded bg-background border border-border text-muted-foreground`,children:e},e)})]}),l.references.length>0&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,Y.jsx)(gn,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{className:`font-medium uppercase tracking-wide`,children:t(`activity:skillDetail.references`)})]}),l.references.map(e=>{let n=cb(e)??e.replace(/\.md$/,``);return de(n)?(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>fe(n),className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded bg-primary/5 border border-primary/20 text-primary hover:bg-primary/10 hover:border-primary/30 transition-colors cursor-pointer`,title:t(`activity:skillDetail.goToSkillTitle`,{name:n}),children:[(0,Y.jsx)(f,{className:`h-2.5 w-2.5`}),n]},e):(0,Y.jsx)(`span`,{className:`px-1.5 py-0.5 text-[10px] rounded bg-muted text-muted-foreground`,children:n},e)})]})]}),(0,Y.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto`,children:d?(0,Y.jsxs)(`div`,{className:`p-8 text-center text-muted-foreground`,children:[(0,Y.jsx)(B,{className:`h-6 w-6 animate-spin mx-auto mb-2`}),(0,Y.jsx)(`p`,{children:t(`activity:skillDetail.loadingContent`)})]}):g?(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Y.jsxs)(`div`,{className:`px-4 py-2 border-b shrink-0 flex items-center justify-between gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`activity:skillDetail.editingLabel`,{name:a.name})}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:t(`activity:skillDetail.editStats`,{lines:le.lines,words:le.words,chars:le.chars})}),ue&&(0,Y.jsx)(`span`,{className:`text-xs tabular-nums ${ue.level===`critical`?`text-red-500 font-medium`:`text-amber-500`}`,children:t(`activity:skillDetail.charsWarningFmt`,{used:(ue.used/(1024*1024)).toFixed(1),limit:(ue.limit/(1024*1024)).toFixed(0)})}),O&&(0,Y.jsx)(`span`,{className:`text-xs text-green-500 animate-pulse`,children:t(`activity:skillDetail.draftSaved`)}),A&&(0,Y.jsx)(`span`,{className:`text-xs text-amber-500 animate-pulse`,children:t(`activity:skillDetail.draftRestored`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[w&&(0,Y.jsx)(`span`,{className:`text-xs text-destructive`,children:w}),A&&(0,Y.jsx)(`button`,{type:`button`,onClick:ve,className:`px-2 py-1 text-[10px] rounded border border-amber-500/50 text-amber-600 dark:text-amber-400 hover:bg-amber-500/10 transition-colors cursor-pointer`,children:t(`activity:skillDetail.discardDraft`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:_e,className:`px-2 py-1 text-xs rounded border border-border hover:bg-accent transition-colors cursor-pointer`,children:t(`common:action.cancel`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>D(e=>!e),title:t(E?`activity:skillDetail.hidePreviewTitle`:`activity:skillDetail.splitViewTitle`),className:`px-2 py-1 text-xs rounded border transition-colors cursor-pointer ${E?`border-primary bg-primary/10 text-primary`:`border-border hover:bg-accent text-muted-foreground`}`,children:(0,Y.jsx)(vr,{className:`h-3 w-3 inline`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:ye,disabled:x||!v.trim(),className:`px-3 py-1 text-xs rounded bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors cursor-pointer`,children:x?(0,Y.jsx)(B,{className:`h-3 w-3 animate-spin inline`}):t(`common:action.save`)})]})]}),E?(0,Y.jsxs)(`div`,{className:`flex flex-1 min-h-0 gap-0.5`,children:[(0,Y.jsx)(`div`,{className:`flex-1 min-w-0 flex flex-col min-h-0`,children:(0,Y.jsx)(tr,{value:v,onChange:e=>y(e.target.value??``),language:`markdown`,className:`flex-1`,style:{fontSize:12,backgroundColor:`transparent`,minHeight:0},placeholder:t(`activity:skillDetail.contentPlaceholder`)})}),(0,Y.jsx)(`div`,{className:`w-px bg-border flex-shrink-0`}),(0,Y.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto p-4 prose prose-sm dark:prose-invert max-w-none`,children:(0,Y.jsx)(vn,{rehypePlugins:[Sn],components:wm,children:v})})]}):(0,Y.jsx)(tr,{value:v,onChange:e=>y(e.target.value??``),language:`markdown`,className:`flex-1`,style:{fontSize:12,backgroundColor:`transparent`,minHeight:0},placeholder:t(`activity:skillDetail.contentPlaceholder`)})]}):l?(0,Y.jsx)(`div`,{className:`p-6 prose prose-sm dark:prose-invert max-w-none`,children:(0,Y.jsx)(vn,{rehypePlugins:[Sn],components:wm,children:l.body})}):m?(0,Y.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,Y.jsx)(`p`,{className:`text-destructive mb-2`,children:t(`activity:skillDetail.loadFailed`)}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:m}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{n&&a&&(p(!0),h(null),n.send({type:`skills.content`,payload:{name:a.name,source:a.source}}))},className:`mt-4 px-3 py-1.5 text-xs rounded border border-border hover:bg-accent transition-colors`,children:t(`common:action.retry`)})]}):(0,Y.jsx)(`div`,{className:`p-8 text-center text-muted-foreground`,children:t(`activity:skillDetail.noContent`)})}),ee&&(0,Y.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40`,onClick:e=>{e.target===e.currentTarget&&te(null)},children:(0,Y.jsxs)(`div`,{className:`flex max-h-[calc(100dvh-2rem)] w-[380px] max-w-[90vw] flex-col overflow-hidden rounded-lg border bg-background shadow-xl`,children:[(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between p-4 border-b`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(C,{className:`h-4 w-4 text-destructive`}),(0,Y.jsx)(`span`,{className:`font-semibold text-sm`,children:t(`activity:skillDetail.uninstallSkillHeading`)})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>te(null),className:`p-1 rounded hover:bg-accent text-muted-foreground cursor-pointer`,children:(0,Y.jsx)(Xn,{className:`h-4 w-4`})})]}),(0,Y.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4 space-y-2`,children:[(0,Y.jsx)(`p`,{className:`text-sm`,children:t(`activity:skillDetail.uninstallConfirm`,{name:ee.name})}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`activity:skillDetail.uninstallRemovePath`,{path:ee.source===`user`?`~/.wrongstack/skills`:`.wrongstack/skills`})})]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 p-4 border-t bg-muted/20`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>te(null),disabled:ne,className:`px-3 py-1.5 text-xs rounded border border-border hover:bg-accent transition-colors disabled:opacity-50`,children:t(`common:action.cancel`)}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>Ce(ee),disabled:ne,className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded bg-destructive text-destructive-foreground hover:bg-destructive/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:[ne&&(0,Y.jsx)(B,{className:`h-3 w-3 animate-spin`}),t(`activity:skillDetail.uninstallAction`)]})]})]})})]}):(0,Y.jsxs)(`div`,{className:X(`flex-1 flex flex-col items-center justify-center text-muted-foreground p-8`,e),children:[(0,Y.jsx)(ie,{className:`h-12 w-12 mb-4 opacity-20`}),(0,Y.jsx)(`p`,{className:`text-base font-medium`,children:t(`activity:skillDetail.noSkillSelected`)}),(0,Y.jsx)(`p`,{className:`text-sm mt-1 text-center max-w-[300px]`,children:t(`activity:skillDetail.selectSkillHint`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:he,className:`mt-4 px-4 py-2 text-sm rounded-md border border-border hover:bg-accent transition-colors`,children:t(`activity:skillDetail.goToChat`)})]})}var db={completed:{icon:(0,Y.jsx)(rn,{className:`h-3.5 w-3.5`}),label:`Completed`,text:`text-emerald-400`,ring:`border-emerald-500/40`},in_progress:{icon:(0,Y.jsx)(B,{className:`h-3.5 w-3.5 animate-spin`}),label:`Running`,text:`text-sky-400`,ring:`border-sky-500/50`},queued:{icon:(0,Y.jsx)(Ge,{className:`h-3.5 w-3.5`}),label:`Queued`,text:`text-amber-400`,ring:`border-amber-500/40`},blocked:{icon:(0,Y.jsx)(x,{className:`h-3.5 w-3.5`}),label:`Blocked`,text:`text-rose-400`,ring:`border-rose-500/30`},pending:{icon:(0,Y.jsx)(Or,{className:`h-3.5 w-3.5`}),label:`Pending`,text:`text-slate-400`,ring:`border-white/10`},review:{icon:(0,Y.jsx)(Le,{className:`h-3.5 w-3.5`}),label:`Review`,text:`text-violet-400`,ring:`border-violet-500/40`},failed:{icon:(0,Y.jsx)(Nn,{className:`h-3.5 w-3.5`}),label:`Failed`,text:`text-red-400`,ring:`border-red-500/50`},cancelled:{icon:(0,Y.jsx)(Be,{className:`h-3.5 w-3.5`}),label:`Cancelled`,text:`text-slate-400`,ring:`border-slate-500/40`}},fb=[`completed`,`in_progress`,`queued`,`blocked`,`pending`,`failed`],pb={critical:{label:`Crit`,cls:`bg-red-500/15 text-red-400`},high:{label:`High`,cls:`bg-red-500/15 text-red-400`},medium:{label:`Med`,cls:`bg-amber-500/15 text-amber-400`},low:{label:`Low`,cls:`bg-emerald-500/15 text-emerald-400`}};function mb({columns:e,onTaskClick:t}){let{t:n}=V();return e.length===0?(0,Y.jsx)(`div`,{className:`flex h-40 items-center justify-center text-sm text-slate-400`,children:n(`activity:board.emptySpec`)}):(0,Y.jsxs)(`div`,{className:`rounded-lg border border-white/10 bg-[#0f1115] p-4`,children:[(0,Y.jsx)(`h3`,{className:`mb-3 text-sm font-semibold text-slate-200`,children:n(`activity:board.depGraphHeading`)}),(0,Y.jsx)(`div`,{className:`mb-4 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs`,children:fb.map(e=>(0,Y.jsxs)(`span`,{className:X(`inline-flex items-center gap-1.5`,db[e].text),children:[db[e].icon,(0,Y.jsx)(`span`,{className:`text-slate-400`,children:n(`activity:board.status.${e}`)})]},e))}),(0,Y.jsx)(`div`,{className:`flex gap-3 overflow-x-auto pb-2`,children:e.map((n,r)=>(0,Y.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Y.jsxs)(`div`,{className:`w-60 shrink-0`,children:[(0,Y.jsx)(`div`,{className:`mb-2 border-b border-white/10 pb-1 text-center text-xs font-medium uppercase tracking-wider text-slate-500`,children:n.label}),(0,Y.jsx)(`div`,{className:`space-y-2`,children:n.tasks.map(e=>(0,Y.jsx)(hb,{task:e,onClick:t},e.id))})]}),r<e.length-1&&(0,Y.jsx)(`div`,{className:`flex h-full items-center pt-8 text-slate-600`,children:(0,Y.jsx)(Oe,{className:`h-5 w-5`})})]},n.label))})]})}function hb({task:e,onClick:t}){let n=db[e.displayStatus],r=pb[e.priority],{t:i}=V();return(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>t?.(e.id),className:X(`w-full rounded-md border bg-[#161a22] p-2.5 text-left transition-colors hover:border-orange-500/40`,n.ring),children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsxs)(`span`,{className:X(`inline-flex items-center gap-1.5 text-xs font-medium`,n.text),children:[n.icon,(0,Y.jsx)(`span`,{className:`font-mono text-slate-300`,children:e.shortId})]}),(0,Y.jsx)(`span`,{className:X(`rounded px-1.5 py-0.5 text-[10px] font-medium`,r.cls),children:r.label})]}),(0,Y.jsx)(`p`,{className:`mt-1.5 text-xs text-slate-200`,children:e.title}),e.deps.length>0&&(0,Y.jsxs)(`p`,{className:`mt-1 font-mono text-[10px] text-slate-500`,children:[`← `,e.deps.join(`, `)]}),e.agentName&&(0,Y.jsxs)(`div`,{className:X(`mt-1.5 inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[10px]`,e.displayStatus===`in_progress`?`bg-sky-500/15 text-sky-400`:`bg-white/5 text-slate-400`),title:e.worktreeBranch?i(`activity:board.worktreePrefix`,{branch:e.worktreeBranch}):void 0,children:[e.displayStatus===`in_progress`&&(0,Y.jsx)(B,{className:`h-3 w-3 animate-spin`}),(0,Y.jsx)(`span`,{children:e.agentName})]})]})}function gb(e){return e.columns.map(e=>({name:e.label,description:``,priority:`medium`,estimateHours:e.tasks.length,parallelizable:!1,taskTemplates:e.tasks.map(e=>({title:e.title,description:e.description,type:e.type,priority:e.priority,estimateHours:1}))}))}function _b({onClose:e}){let{client:t}=sd(),{t:n}=V(),r=tc(e=>e.specs),i=tc(e=>e.detail),a=tc(e=>e.expandedSpecId),o=tc(e=>e.setExpanded),[s,c]=(0,U.useState)(`graph`),l=(0,U.useCallback)(e=>{!i||i.specId!==e.id||(t?.send?.({type:`autophase.start`,payload:{title:e.title,phases:gb(i),autonomous:!0}}),_l(`autophase`))},[i,t]);(0,U.useEffect)(()=>{t?.send?.({type:`specs.list`})},[t]);let u=(0,U.useCallback)(e=>{a===e.id?o(null):(o(e.id),t?.send?.({type:`specs.get`,payload:{specId:e.id}}))},[a,o,t]),d=i?.columns.flatMap(e=>e.tasks)??[],f={done:d.filter(e=>e.status===`completed`).length,running:d.filter(e=>e.status===`in_progress`).length,pending:d.filter(e=>e.status===`pending`||e.displayStatus===`queued`).length};return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,Y.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b bg-card px-4 py-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(gn,{className:`h-5 w-5 text-orange-500`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h1`,{className:`text-lg font-semibold`,children:n(`activity:specs.heading`)}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`activity:specs.subtitle`)})]})]}),(0,Y.jsx)($,{variant:`ghost`,size:`icon`,onClick:e,children:(0,Y.jsx)(Xn,{className:`h-4 w-4`})})]}),(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:r.length===0?(0,Y.jsx)(`div`,{className:`flex h-40 items-center justify-center text-sm text-muted-foreground`,children:n(`activity:specs.empty`,{command:`/sdd`})}):(0,Y.jsx)(`div`,{className:`space-y-3`,children:r.map(e=>{let t=a===e.id,r=e.total>0?Math.round(e.completed/e.total*100):0;return(0,Y.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/60`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>u(e),className:`flex w-full items-start gap-3 p-4 text-left`,children:[(0,Y.jsx)(`span`,{className:`mt-1 text-muted-foreground`,children:t?(0,Y.jsx)(bn,{className:`h-4 w-4`}):(0,Y.jsx)(Oe,{className:`h-4 w-4`})}),(0,Y.jsx)(gn,{className:`mt-0.5 h-4 w-4 text-muted-foreground`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.displayId}),(0,Y.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[10px] capitalize text-muted-foreground`,children:e.status})]}),(0,Y.jsx)(`h2`,{className:`mt-1 text-base font-semibold`,children:e.title}),(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,Y.jsx)(`div`,{className:`h-2 flex-1 overflow-hidden rounded-full bg-muted`,children:(0,Y.jsx)(`div`,{className:`h-full rounded-full bg-emerald-500 transition-all`,style:{width:`${r}%`}})}),(0,Y.jsxs)(`span`,{className:`shrink-0 font-mono text-xs text-muted-foreground`,children:[e.completed,`/`,e.total]})]})]})]}),t&&(0,Y.jsxs)(`div`,{className:`border-t border-border p-4`,children:[(0,Y.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,Y.jsxs)(`div`,{className:`text-sm font-medium`,children:[n(`activity:specs.tasks`,{count:i?.total??e.total}),i&&(0,Y.jsxs)(`span`,{className:`ml-3 text-xs font-normal text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`text-emerald-500`,children:n(`activity:specs.doneCount`,{count:f.done})}),` `,(0,Y.jsx)(`span`,{className:`text-sky-500`,children:n(`activity:specs.runningCount`,{count:f.running})}),` `,(0,Y.jsx)(`span`,{children:n(`activity:specs.pendingCount`,{count:f.pending})})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsxs)(`button`,{type:`button`,disabled:!i||i.specId!==e.id,onClick:()=>l(e),title:n(`activity:specs.runTitle`),className:`inline-flex items-center gap-1 rounded-md bg-orange-500/15 px-2.5 py-1 text-xs font-medium text-orange-500 transition-colors hover:bg-orange-500/25 disabled:opacity-40`,children:[(0,Y.jsx)(kt,{className:`h-3.5 w-3.5`}),` `,n(`activity:specs.run`)]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>c(`list`),className:X(`inline-flex items-center gap-1 rounded px-2 py-1 text-xs`,s===`list`?`bg-primary/15 text-primary`:`text-muted-foreground`),children:[(0,Y.jsx)(Se,{className:`h-3.5 w-3.5`}),` `,n(`activity:specs.list`)]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>c(`graph`),className:X(`inline-flex items-center gap-1 rounded px-2 py-1 text-xs`,s===`graph`?`bg-primary/15 text-primary`:`text-muted-foreground`),children:[(0,Y.jsx)(Jn,{className:`h-3.5 w-3.5`}),` `,n(`activity:specs.graph`)]})]})]})]}),!i||i.specId!==e.id?(0,Y.jsx)(`div`,{className:`flex h-24 items-center justify-center text-sm text-muted-foreground`,children:n(`activity:specs.loadingTasks`)}):s===`graph`?(0,Y.jsx)(mb,{columns:i.columns}):(0,Y.jsx)(`div`,{className:`space-y-1.5`,children:d.map(e=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md border border-border bg-card px-3 py-2`,children:[(0,Y.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.shortId}),(0,Y.jsx)(`span`,{className:`flex-1 text-sm`,children:e.title}),(0,Y.jsx)(`span`,{className:`text-xs capitalize text-muted-foreground`,children:e.displayStatus.replace(`_`,` `)})]},e.id))})]})]},e.id)})})})]})}var vb=`wrongstack.terminalDockHeight`;function yb(e){let t=typeof window>`u`?640:Math.max(140,Math.min(640,Math.floor(window.innerHeight*.55),window.innerHeight-260));return Math.min(Math.max(Math.round(e),140),t)}var bb={background:`#1e1e2e`,foreground:`#cdd6f4`,cursor:`#f5e0dc`,selectionBackground:`#585b70`,black:`#45475a`,red:`#f38ba8`,green:`#a6e3a1`,yellow:`#f9e2af`,blue:`#89b4fa`,magenta:`#f5c2e7`,cyan:`#94e2d5`,white:`#bac2de`,brightBlack:`#585b70`,brightRed:`#f38ba8`,brightGreen:`#a6e3a1`,brightYellow:`#f9e2af`,brightBlue:`#89b4fa`,brightMagenta:`#f5c2e7`,brightCyan:`#94e2d5`,brightWhite:`#a6adc8`},xb=8;function Sb(e=!1){return typeof window>`u`?300:yb(window.innerHeight*(e?.32:.4))}function Cb(e=!1){if(typeof window>`u`)return Sb(e);try{let t=window.localStorage.getItem(vb),n=t?Number.parseInt(t,10):NaN;return Number.isFinite(n)?yb(n):Sb(e)}catch{return Sb(e)}}function wb(e){try{window.localStorage.setItem(vb,String(yb(e)))}catch{}}function Tb(){try{return crypto.randomUUID()}catch{return`term-${Date.now()}-${Math.floor(Math.random()*1e6)}`}}function Eb(e){return{id:Tb(),name:`Terminal ${e}`,status:`starting`}}function Db({desktopShell:e=!1,onClose:t}){let n=(0,U.useRef)(null),{t:r}=V(),i=(0,U.useRef)(1),[a,o]=(0,U.useState)(()=>Cb(e)),[s,c]=(0,U.useState)(()=>[Eb(1)]),[l,u]=(0,U.useState)(()=>s[0]?.id??``),d=J(e=>e.terminalCreateNonce),f=(0,U.useRef)(d),p=q(e=>e.projectName),m=q(e=>e.cwd);(0,U.useEffect)(()=>{let e=()=>{o(e=>{let t=yb(e);return wb(t),t})};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let h=e=>{e.preventDefault(),n.current?.();let t=e.clientY,r=a,i=document.body.style.cursor,s=document.body.style.userSelect;document.body.style.cursor=`ns-resize`,document.body.style.userSelect=`none`;let c=e=>{let n=yb(r+t-e.clientY);o(n),wb(n)},l=()=>{document.body.style.cursor=i,document.body.style.userSelect=s,window.removeEventListener(`pointermove`,c),window.removeEventListener(`pointerup`,l),window.removeEventListener(`pointercancel`,l),n.current===l&&(n.current=null)};n.current=l,window.addEventListener(`pointermove`,c),window.addEventListener(`pointerup`,l,{once:!0}),window.addEventListener(`pointercancel`,l,{once:!0})};(0,U.useEffect)(()=>()=>n.current?.(),[]);let g=()=>{c(e=>{if(e.length>=xb)return e;i.current+=1;let t=Eb(i.current);return u(t.id),[...e,t]})};(0,U.useEffect)(()=>{d!==f.current&&(f.current=d,g())},[d]);let _=e=>{c(n=>{let r=n.findIndex(t=>t.id===e);if(r===-1)return n;let i=n.filter(t=>t.id!==e);return i.length===0?(queueMicrotask(t),i):(l===e&&u(i[Math.max(0,r-1)]?.id??i[0]?.id??``),i)})},v=e=>{let t=Tb();c(n=>{let r=!1,i=n.map(n=>n.id===e?(r=!0,{...n,id:t,status:`starting`,exitCode:void 0}):n);return r&&u(t),i})},y=()=>{c([]),u(``),queueMicrotask(t)},b=(e,t)=>{c(n=>n.map(n=>n.id===e?{...n,...t}:n))},x=s.find(e=>e.id===l)??s[0]??null;return(0,Y.jsxs)(`div`,{"data-terminal-dock":!0,style:{height:a},"data-shell":e?`desktop`:`browser`,className:X(`z-30 flex min-h-0 shrink-0 flex-col border-t border-border bg-[#1e1e2e] shadow-2xl`,e&&`ws-terminal-desktop`),children:[(0,Y.jsx)(`div`,{role:`separator`,"aria-orientation":`horizontal`,title:r(`activity:terminal.resize`),onPointerDown:h,className:`h-1.5 cursor-ns-resize bg-[#181825] hover:bg-primary/35 transition-colors`}),(0,Y.jsxs)(`div`,{className:X(`flex min-w-0 items-center justify-between gap-3 border-b border-border/40 bg-[#181825]`,e?`px-2 py-1`:`px-3 py-1.5`),children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs text-[#cdd6f4]`,children:[(0,Y.jsx)(ft,{className:`h-3.5 w-3.5 shrink-0`}),(0,Y.jsx)(`span`,{className:`font-medium`,children:r(e?`activity:terminal.labelSingular`:`activity:terminal.labelPlural`)}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-[#a6adc8]`,children:p||m||r(`activity:terminal.projectShell`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:g,disabled:s.length>=xb,title:s.length>=xb?r(`activity:terminal.maxTerminals`,{count:xb}):r(`activity:terminal.newTerminal`),className:`inline-flex items-center justify-center h-6 w-6 rounded text-[#a6adc8] hover:bg-white/10 disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:(0,Y.jsx)(hn,{className:`h-4 w-4`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>x&&v(x.id),disabled:!x,title:r(`activity:terminal.restart`),className:`inline-flex items-center justify-center h-6 w-6 rounded text-[#a6adc8] hover:bg-white/10 disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:(0,Y.jsx)(Le,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:y,disabled:s.length===0,title:r(`activity:terminal.closeAll`),className:`inline-flex items-center justify-center h-6 w-6 rounded text-[#a6adc8] hover:bg-white/10 disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:(0,Y.jsx)(C,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:t,title:r(`activity:terminal.closeDock`),className:`inline-flex items-center justify-center h-6 w-6 rounded text-[#a6adc8] hover:bg-white/10 transition-colors`,children:(0,Y.jsx)(Xn,{className:`h-4 w-4`})})]})]}),(0,Y.jsx)(`div`,{className:X(`flex min-w-0 items-center gap-1 overflow-x-auto border-b border-border/40 bg-[#181825]`,e?`px-1.5 py-0.5`:`px-2 py-1`),children:s.map(t=>(0,Y.jsxs)(`div`,{className:X(`group inline-flex items-center rounded border text-xs transition-colors`,e?`h-6 min-w-[92px] max-w-[148px]`:`h-7 min-w-[112px] max-w-[180px]`,l===t.id?`border-[#89b4fa]/45 bg-[#313244] text-[#cdd6f4]`:`border-transparent bg-transparent text-[#a6adc8] hover:bg-white/10`),children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>u(t.id),title:t.status===`exited`?`${t.name} exited`:t.name,className:`inline-flex min-w-0 flex-1 items-center gap-2 px-2 text-left`,children:[(0,Y.jsx)(`span`,{className:X(`h-1.5 w-1.5 shrink-0 rounded-full`,t.status===`running`&&`bg-[#a6e3a1]`,t.status===`starting`&&`bg-[#89b4fa]`,t.status===`exited`&&`bg-[#f38ba8]`)}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[t.name,t.status===`exited`&&typeof t.exitCode==`number`?` (${t.exitCode})`:``]})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),_(t.id)},className:`mr-1 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded text-[#a6adc8] opacity-70 hover:bg-white/10 hover:opacity-100`,title:r(`activity:terminal.closeTab`,{name:t.name}),children:(0,Y.jsx)(Xn,{className:`h-3 w-3`})})]},t.id))}),m&&!e&&(0,Y.jsx)(`div`,{className:`min-w-0 truncate border-b border-border/30 bg-[#181825] px-3 py-1 text-[11px] font-mono text-[#6c7086]`,children:m}),(0,Y.jsx)(`div`,{className:`relative min-h-0 min-w-0 flex-1 overflow-hidden`,children:s.map(e=>(0,Y.jsx)(Ob,{id:e.id,active:e.id===l,onRunning:()=>b(e.id,{status:`running`}),onExit:t=>b(e.id,{status:`exited`,exitCode:t})},e.id))})]})}function Ob({id:e,active:t,onRunning:n,onExit:r}){let i=(0,U.useRef)(null),a=(0,U.useRef)(null),o=(0,U.useRef)(null),s=(0,U.useRef)(n),c=(0,U.useRef)(r),l=K(e=>e.wsConnected);return(0,U.useEffect)(()=>{s.current=n,c.current=r},[r,n]),(0,U.useEffect)(()=>{let t=i.current;if(!t)return;let n=new dr({fontFamily:`"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace`,fontSize:13,cursorBlink:!0,theme:bb,scrollback:5e3}),r=new Ln;a.current=n,o.current=r,n.loadAddon(r),n.open(t);try{r.fit()}catch{}let l=W(K.getState().wsUrl);l.send({type:`terminal.create`,payload:{id:e,cols:n.cols,rows:n.rows}}),s.current();let u=l.on(`terminal.output`,t=>{t.type===`terminal.output`&&t.payload.id===e&&n.write(t.payload.data)}),d=l.on(`terminal.exit`,t=>{t.type===`terminal.exit`&&t.payload.id===e&&(n.write(`\r\n\x1b[2m${b.t(`activity:terminal.processExited`,{code:t.payload.exitCode})}\x1b[0m\r\n`),c.current(t.payload.exitCode))}),f=n.onData(t=>{l.send({type:`terminal.input`,payload:{id:e,data:t}})}),p=new ResizeObserver(()=>{if(t.offsetParent)try{r.fit(),l.send({type:`terminal.resize`,payload:{id:e,cols:n.cols,rows:n.rows}})}catch{}});return p.observe(t),()=>{u(),d(),f.dispose(),p.disconnect(),l.send({type:`terminal.close`,payload:{id:e}}),n.dispose(),a.current=null,o.current=null}},[e,l]),(0,U.useEffect)(()=>{t&&window.requestAnimationFrame(()=>{try{o.current?.fit();let t=a.current;t&&(W(K.getState().wsUrl).send({type:`terminal.resize`,payload:{id:e,cols:t.cols,rows:t.rows}}),t.focus())}catch{}})},[t,e]),(0,Y.jsx)(`div`,{ref:i,className:X(`absolute inset-0 min-h-0 min-w-0 overflow-hidden px-2 py-1`,t?`block`:`hidden`)})}function kb(){let e=Ss(e=>e.info),{client:t}=sd(),n=(0,U.useRef)(null),r=(0,U.useCallback)(()=>{t?.getGitInfo?.()},[t]);return(0,U.useEffect)(()=>(r(),n.current=setInterval(r,3e4),()=>{n.current&&clearInterval(n.current)}),[r]),e}function Ab({sessionId:e,className:t}){let{t:n}=V(),[r,i]=(0,U.useState)([]),[a,o]=(0,U.useState)(!1),[s,c]=(0,U.useState)(null),[l,u]=(0,U.useState)(null),[d,f]=(0,U.useState)(0),[p,m]=(0,U.useState)(!1),[h,g]=(0,U.useState)(!1),[_,v]=(0,U.useState)(``),[y,x]=(0,U.useState)(``),[S,C]=(0,U.useState)(!1),[w,T]=(0,U.useState)(``),D=W(K(e=>e.wsUrl)),O=G(e=>e.messages).filter(e=>e.role===`tool`&&e.toolResult===void 0&&!!e.toolUseId);(0,U.useEffect)(()=>{let t=[];return t.push(D.on(`collab.state`,t=>{let n=t.payload;n.sessionId===e&&i(n.participants??[])})),t.push(D.on(`collab.participant.joined`,t=>{let n=t.payload;n.sessionId===e&&i(e=>e.some(e=>e.participantId===n.participantId)?e:[...e,{participantId:n.participantId,role:n.role,joinedAt:n.joinedAt}])})),t.push(D.on(`collab.participant.left`,t=>{let n=t.payload;if(n.sessionId!==e)return;let r=n.participantId;i(e=>e.filter(e=>e.participantId!==r))})),t.push(D.on(`error`,e=>{let t=e.payload;t.phase===`collab`&&(u(t.message),o(!1))})),t.push(D.on(`collab.annotation.added`,t=>{let n=t.payload;n.sessionId===e&&(n.annotation?.resolved||f(e=>e+1))})),t.push(D.on(`collab.annotation.resolved`,t=>{t.payload.sessionId===e&&f(e=>Math.max(0,e-1))})),t.push(D.on(`collab.pause.granted`,t=>{t.payload.sessionId===e&&m(!0)})),t.push(D.on(`collab.pause.released`,t=>{t.payload.sessionId===e&&m(!1)})),()=>{for(let e of t)e()}},[D,e]);let k=(t=`observer`)=>{u(null),D.send({type:`collab.join`,payload:{sessionId:e,role:t}}),o(!0),c(t)},A=()=>{D.send({type:`collab.request_pause`,payload:{sessionId:e}})},j=()=>{D.send({type:`collab.resume`,payload:{sessionId:e}})},M=()=>{D.send({type:`collab.leave`,payload:{sessionId:e}}),o(!1),i([])},N=t=>{D.send({type:`collab.grant_control`,payload:{sessionId:e,toParticipant:t}})},P=()=>{_&&(D.send({type:`collab.inject_tool`,payload:{sessionId:e,toolUseId:_,content:y,isError:S,reason:w.trim()||b.t(`activity:collab.controllerInjection`)}}),g(!1),v(``),x(``),C(!1),T(``))},F=a&&s===`controller`;return r.length===0&&!l?(0,Y.jsxs)(`div`,{className:X(`flex items-center gap-2 px-3 py-2 rounded-md border border-dashed border-border bg-card/40`,t),children:[(0,Y.jsx)(Rr,{className:`w-4 h-4 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`activity:collab.noObservers`)}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>k(`observer`),className:`inline-flex items-center gap-1 text-xs px-2 py-1 rounded bg-primary text-primary-foreground hover:bg-primary/90 transition-colors`,title:n(`activity:collab.observerTitle`),children:[(0,Y.jsx)(E,{className:`w-3 h-3`}),n(`activity:collab.observerRole`)]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>k(`annotator`),className:`inline-flex items-center gap-1 text-xs px-2 py-1 rounded border border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300 hover:bg-amber-500/20 transition-colors`,title:n(`activity:collab.annotatorTitle`),children:[(0,Y.jsx)(jr,{className:`w-3 h-3`}),n(`activity:collab.annotatorRole`)]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>k(`controller`),className:`inline-flex items-center gap-1 text-xs px-2 py-1 rounded border border-rose-500/40 bg-rose-500/10 text-rose-700 dark:text-rose-300 hover:bg-rose-500/20 transition-colors`,title:n(`activity:collab.controllerTitle`),children:[(0,Y.jsx)(kn,{className:`w-3 h-3`}),n(`activity:collab.controllerRole`)]})]})]}):l?(0,Y.jsxs)(`div`,{className:X(`flex items-center gap-2 px-3 py-2 rounded-md border border-destructive/50 bg-destructive/10`,t),role:`alert`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-destructive`,children:n(`activity:collab.errorPrefix`,{error:l})}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{u(null),o(!1)},className:`ml-auto text-xs underline text-destructive`,children:n(`activity:collab.dismiss`)})]}):(0,Y.jsxs)(`div`,{className:X(`relative flex items-center gap-2 px-3 py-2 rounded-md border border-emerald-500/40 bg-emerald-500/5`,t),children:[(0,Y.jsxs)(`span`,{className:`relative flex h-2 w-2`,"aria-label":n(`common:status.live`),children:[(0,Y.jsx)(`span`,{className:`absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75 animate-ping`}),(0,Y.jsx)(`span`,{className:`relative inline-flex rounded-full h-2 w-2 bg-emerald-500`})]}),(0,Y.jsx)(Rr,{className:`w-4 h-4 text-emerald-700 dark:text-emerald-400`}),(0,Y.jsx)(`span`,{className:`text-xs font-medium text-emerald-700 dark:text-emerald-300`,children:n(`activity:collab.observers`,{count:r.length})}),d>0&&(0,Y.jsxs)(`span`,{title:n(`activity:collab.annotationsTitle`,{count:d}),className:`ml-2 inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-amber-500/15 text-amber-700 dark:text-amber-300 border border-amber-500/30`,children:[(0,Y.jsx)(jr,{className:`w-3 h-3`}),n(`activity:collab.notes`,{count:d})]}),p&&(0,Y.jsxs)(`span`,{title:n(`activity:collab.pausedTitle`),className:`ml-2 inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-rose-500/15 text-rose-700 dark:text-rose-300 border border-rose-500/40`,children:[(0,Y.jsx)(kn,{className:`w-3 h-3`}),n(`activity:collab.paused`)]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 ml-2`,children:[r.slice(0,3).map(e=>(0,Y.jsxs)(`span`,{title:n(`activity:collab.joinedTitle`,{time:new Date(e.joinedAt).toLocaleTimeString()}),className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`,children:[(0,Y.jsx)(An,{className:`w-3 h-3`}),e.role,F&&e.role!==`controller`&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>N(e.participantId),title:n(`activity:collab.grantTitle`),className:`ml-0.5 inline-flex items-center rounded hover:bg-emerald-500/20 transition-colors`,children:(0,Y.jsx)(Nr,{className:`w-3 h-3`})})]},e.participantId)),r.length>3&&(0,Y.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`+`,r.length-3]})]}),F&&(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>g(e=>!e),className:`inline-flex items-center gap-1 text-xs px-2 py-1 rounded border border-sky-500/40 bg-sky-500/10 text-sky-700 dark:text-sky-300 hover:bg-sky-500/20 transition-colors`,title:n(`activity:collab.injectTitle`),children:[(0,Y.jsx)(be,{className:`w-3 h-3`}),n(`activity:collab.inject`)]}),p?(0,Y.jsxs)(`button`,{type:`button`,onClick:j,className:`inline-flex items-center gap-1 text-xs px-2 py-1 rounded border border-rose-500/40 bg-rose-500/10 text-rose-700 dark:text-rose-300 hover:bg-rose-500/20 transition-colors`,title:n(`activity:collab.resumeTitle`),children:[(0,Y.jsx)(kt,{className:`w-3 h-3`}),n(`activity:collab.resume`)]}):(0,Y.jsxs)(`button`,{type:`button`,onClick:A,className:`inline-flex items-center gap-1 text-xs px-2 py-1 rounded border border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300 hover:bg-amber-500/20 transition-colors`,title:n(`activity:collab.pauseTitle`),children:[(0,Y.jsx)(kn,{className:`w-3 h-3`}),n(`activity:collab.pauseAgent`)]})]}),a&&s!==`controller`&&(0,Y.jsxs)(`button`,{type:`button`,onClick:M,className:`ml-auto inline-flex items-center gap-1 text-xs px-2 py-1 rounded border border-border hover:bg-muted transition-colors`,title:n(`activity:collab.leaveTitle`),children:[(0,Y.jsx)(Ye,{className:`w-3 h-3`}),n(`activity:collab.leave`)]}),F&&h&&(0,Y.jsxs)(`div`,{className:`absolute top-full left-0 right-0 mt-1 z-50 flex flex-col gap-2 p-3 rounded-md border border-sky-500/40 bg-card shadow-lg text-xs`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(be,{className:`w-3.5 h-3.5 text-sky-600 dark:text-sky-400`}),(0,Y.jsx)(`span`,{className:`font-medium`,children:n(`activity:collab.injectToolResult`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>g(!1),className:`ml-auto text-muted-foreground hover:text-foreground`,children:n(`activity:collab.close`)})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:collab.targetTool`)}),(0,Y.jsx)(`input`,{list:`collab-inject-tools`,value:_,onChange:e=>v(e.target.value),placeholder:n(`activity:collab.targetPlaceholder`),className:`px-2 py-1 rounded border border-border bg-background font-mono`}),(0,Y.jsx)(`datalist`,{id:`collab-inject-tools`,children:O.map(e=>{let t=e.toolInput===void 0?``:` — ${JSON.stringify(e.toolInput).slice(0,40)}`;return(0,Y.jsxs)(`option`,{value:e.toolUseId,children:[e.toolName??n(`activity:collab.toolFallback`),t]},e.toolUseId)})}),O.length===0&&(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(`activity:collab.noPendingTools`)})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:collab.resultContent`)}),(0,Y.jsx)(`textarea`,{value:y,onChange:e=>x(e.target.value),rows:3,placeholder:n(`activity:collab.resultPlaceholder`),className:`px-2 py-1 rounded border border-border bg-background font-mono`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsxs)(`label`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:S,onChange:e=>C(e.target.checked)}),(0,Y.jsx)(`span`,{children:n(`activity:collab.markError`)})]}),(0,Y.jsx)(`input`,{type:`text`,value:w,onChange:e=>T(e.target.value),placeholder:n(`activity:collab.reasonPlaceholder`),className:`flex-1 px-2 py-1 rounded border border-border bg-background`})]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:P,disabled:!_,className:`self-end inline-flex items-center gap-1 text-xs px-3 py-1 rounded bg-sky-600 text-white hover:bg-sky-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:[(0,Y.jsx)(be,{className:`w-3 h-3`}),n(`activity:collab.queueInjection`)]})]})]})}var jb={up:(0,Y.jsx)(Ze,{className:`h-3.5 w-3.5 text-emerald-500`}),down:(0,Y.jsx)(O,{className:`h-3.5 w-3.5 text-red-500`}),stable:(0,Y.jsx)(wt,{className:`h-3.5 w-3.5 text-amber-500`})},Mb={active:{color:`text-emerald-600 dark:text-emerald-400`,bg:`bg-emerald-100 dark:bg-emerald-900/40`,labelKey:`statusActive`},paused:{color:`text-amber-600 dark:text-amber-400`,bg:`bg-amber-100 dark:bg-amber-900/40`,labelKey:`statusPaused`},completed:{color:`text-blue-600 dark:text-blue-400`,bg:`bg-blue-100 dark:bg-blue-900/40`,labelKey:`statusDone`},failed:{color:`text-red-600 dark:text-red-400`,bg:`bg-red-100 dark:bg-red-900/40`,labelKey:`statusFailed`},abandoned:{color:`text-stone-600 dark:text-stone-400`,bg:`bg-stone-100 dark:bg-stone-900/40`,labelKey:`statusAbandoned`}};function Nb({goal:e,className:t}){let{t:n}=V(),[r,i]=(0,U.useState)(!1);if((0,U.useEffect)(()=>{let e=W();e?.send?.({type:`goal.get`});let t=setInterval(()=>{e?.send?.({type:`goal.get`})},1e4);return()=>clearInterval(t)},[]),(0,U.useEffect)(()=>{(!e||e.goalState===`completed`||e.goalState===`failed`||e.goalState===`abandoned`)&&i(!0)},[e]),!e||e.goalState===`completed`||e.goalState===`failed`||e.goalState===`abandoned`)return null;let a=Mb[e.goalState],o=e.deliverables?.filter(e=>e.status===`done`).length??0,s=e.deliverables?.length??0,c=e.journal?.slice(-5).reverse()??[],u=e.progressTrend?jb[e.progressTrend]:null;return(0,Y.jsxs)(`div`,{className:X(`rounded-lg border border-border bg-card/60 backdrop-blur-sm`,t),children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`flex w-full items-center gap-2 px-3 py-2.5 text-left hover:bg-accent/40 rounded-t-lg transition-colors`,children:[(0,Y.jsx)(l,{className:`h-4 w-4 text-rose-500`}),(0,Y.jsx)(`span`,{className:`text-xs font-semibold text-foreground flex-1 min-w-0 truncate`,children:n(`activity:goal.heading`)}),(0,Y.jsx)(`span`,{className:X(`inline-flex items-center px-1.5 py-0.5 rounded-full text-[10px] font-medium shrink-0`,a.bg,a.color),children:n(`activity:goal.${a.labelKey}`)}),r?(0,Y.jsx)(Oe,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}):(0,Y.jsx)(bn,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`})]}),!r&&(0,Y.jsxs)(`div`,{className:`px-3 pb-3 space-y-3 border-t pt-2`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:`text-xs text-foreground leading-relaxed whitespace-pre-wrap break-words`,children:e.goal}),e.refinedGoal&&e.refinedGoal!==e.goal&&(0,Y.jsxs)(`div`,{className:`mt-1.5 p-2 rounded bg-accent/40 border border-border/50`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] text-muted-foreground mb-0.5 uppercase tracking-wider font-medium`,children:n(`activity:goal.refined`)}),(0,Y.jsx)(`p`,{className:`text-xs leading-relaxed whitespace-pre-wrap break-words`,children:e.refinedGoal})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between text-[10px]`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground uppercase tracking-wider font-medium`,children:n(`activity:goal.progress`)}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 tabular-nums`,children:[u,(0,Y.jsxs)(`span`,{className:`font-medium text-foreground`,children:[e.progress,`%`]})]})]}),(0,Y.jsx)(`div`,{className:`h-1.5 bg-muted rounded-full overflow-hidden`,children:(0,Y.jsx)(`div`,{className:X(`h-full transition-all duration-700 rounded-full`,e.progress>=80?`bg-emerald-500`:e.progress>=50?`bg-amber-500`:`bg-primary`),style:{width:`${e.progress>0?Math.max(2,e.progress):0}%`}})}),e.progressNote&&(0,Y.jsx)(`p`,{className:`text-[10px] text-muted-foreground italic`,children:e.progressNote})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground`,children:[(0,Y.jsx)(Ge,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{className:`tabular-nums font-medium`,children:e.iterations}),(0,Y.jsx)(`span`,{children:n(`activity:goal.iterations`)}),e.lastStatus&&(0,Y.jsx)(`span`,{className:`text-border`,children:`·`}),e.lastStatus&&(0,Y.jsx)(`span`,{className:`truncate`,children:e.lastStatus})]}),s>0&&(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] text-muted-foreground uppercase tracking-wider font-medium`,children:[(0,Y.jsx)(`span`,{children:n(`activity:goal.deliverables`)}),(0,Y.jsxs)(`span`,{className:`tabular-nums`,children:[o,`/`,s]})]}),(0,Y.jsx)(`ul`,{className:`space-y-0.5`,children:e.deliverables?.map(e=>(0,Y.jsxs)(`li`,{className:`flex items-start gap-1.5 text-[11px]`,children:[e.status===`done`?(0,Y.jsx)(rn,{className:`h-3 w-3 text-emerald-500 mt-0.5 shrink-0`}):(0,Y.jsx)(Or,{className:`h-3 w-3 text-muted-foreground/50 mt-0.5 shrink-0`}),(0,Y.jsx)(`span`,{className:X(`leading-snug`,e.status===`done`?`text-muted-foreground line-through`:`text-foreground`),children:e.text})]},e.id))})]}),c.length>0&&(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider font-medium`,children:n(`activity:goal.recentActivity`)}),(0,Y.jsx)(`div`,{className:`space-y-1`,children:c.map((e,t)=>(0,Y.jsxs)(`div`,{className:`flex items-start gap-1.5 text-[10px] text-muted-foreground`,children:[(0,Y.jsxs)(`span`,{className:`font-mono tabular-nums shrink-0 text-foreground/60`,children:[`#`,e.iteration]}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.task||e.status||e.progressNote||`…`})]},`${e.iteration}-${t}`))})]})]})]})}var Pb={in_progress:0,pending:1,completed:2};function Fb(){let{t:e}=V(),[t,n]=(0,U.useState)([]),[r,i]=(0,U.useState)(new Set),a=W(),o=(0,U.useRef)(null);(0,U.useEffect)(()=>(a.send({type:`todos.get`}),o.current=a.on(`todos.updated`,e=>{let t=e?.payload;t?.todos&&n(t.todos)}),()=>{o.current?.()}),[a]);let s=(0,U.useCallback)(e=>{a.removeTodo(e)},[a]),c=(0,U.useCallback)(e=>{if(e.status===`in_progress`)return;let t=e.status===`completed`?`pending`:`completed`;a.updateTodoStatus(e.id,t)},[a]),l=[...t].sort((e,t)=>(Pb[e.status]??9)-(Pb[t.status]??9)),u=l.filter(e=>e.status===`in_progress`),d=l.filter(e=>e.status===`pending`),f=l.filter(e=>e.status===`completed`),p=f.length>0,m=r.has(`completed`),h=e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},g=t=>{let n=t.status===`in_progress`&&t.activeForm?t.activeForm:t.content,r=t.status===`in_progress`,i=t.status===`completed`,a=!r;return(0,Y.jsxs)(`div`,{onClick:()=>a&&c(t),className:X(`px-3 py-1.5 flex items-start gap-2 text-[13px] group transition-colors`,a&&`cursor-pointer hover:bg-accent/40`,r?`bg-yellow-50/40 dark:bg-yellow-950/25`:i?`bg-emerald-50/20 dark:bg-emerald-950/10`:`bg-background`),role:a?`button`:void 0,"aria-label":a?e(`activity:todos.toggleAria`,{content:t.content}):void 0,tabIndex:a?0:void 0,onKeyDown:e=>{a&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c(t))},children:[(0,Y.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:i?(0,Y.jsx)(rn,{className:`w-3.5 h-3.5 text-emerald-500`}):r?(0,Y.jsx)(Ge,{className:`w-3.5 h-3.5 text-yellow-500 animate-spin`}):(0,Y.jsx)(Or,{className:X(`w-3.5 h-3.5 transition-colors`,`text-muted-foreground/40 group-hover:text-emerald-400`)})}),(0,Y.jsx)(`span`,{className:X(`leading-snug flex-1 min-w-0`,r?`text-yellow-800 dark:text-yellow-200 font-medium`:i?`text-muted-foreground line-through`:`text-foreground/80`),children:n}),(0,Y.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s(t.id)},className:`shrink-0 p-0.5 rounded opacity-0 group-hover:opacity-50 hover:opacity-100 hover:bg-destructive/10 transition-all`,title:e(`activity:todos.removeTitle`),"aria-label":e(`activity:todos.removeAria`,{content:t.content}),children:(0,Y.jsx)(C,{className:`w-3 h-3 text-muted-foreground`})})]},t.id)};return t.length===0?null:(0,Y.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/50 backdrop-blur-sm overflow-hidden`,children:[(0,Y.jsxs)(`div`,{className:`px-3 py-1.5 flex items-center gap-2 border-b border-border/50`,children:[(0,Y.jsx)(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:e(`activity:work.todos`)}),(0,Y.jsxs)(`span`,{className:`tabular text-[10px] text-muted-foreground ml-auto`,children:[f.length,`/`,t.length]})]}),u.length>0&&(0,Y.jsx)(`div`,{className:`border-b border-border/30 last:border-b-0`,children:u.map(g)}),d.length>0&&(0,Y.jsx)(`div`,{className:`border-b border-border/30 last:border-b-0`,children:d.map(g)}),p&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>h(`completed`),className:`w-full px-3 py-1 flex items-center gap-1.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:(0,Y.jsxs)(`span`,{className:`tabular`,children:[m?`▶`:`▼`,` `,e(`activity:todos.completedCount`,{count:f.length})]})}),!m&&f.map(g)]})]})}var Ib={pending:{icon:(0,Y.jsx)(Or,{className:`w-3.5 h-3.5`}),labelKey:`statusPending`,color:`text-muted-foreground/50`},in_progress:{icon:(0,Y.jsx)(Ge,{className:`w-3.5 h-3.5 animate-spin`}),labelKey:`statusInProgress`,color:`text-yellow-500`},blocked:{icon:(0,Y.jsx)(kn,{className:`w-3.5 h-3.5`}),labelKey:`statusBlocked`,color:`text-orange-500`},failed:{icon:(0,Y.jsx)(Nn,{className:`w-3.5 h-3.5`}),labelKey:`statusFailed`,color:`text-red-500`},review:{icon:(0,Y.jsx)(Le,{className:`w-3.5 h-3.5`}),labelKey:`statusReview`,color:`text-blue-500`},completed:{icon:(0,Y.jsx)(rn,{className:`w-3.5 h-3.5`}),labelKey:`statusDone`,color:`text-emerald-500`}},Lb={critical:`text-red-600 dark:text-red-400`,high:`text-orange-600 dark:text-orange-400`,medium:`text-yellow-600 dark:text-yellow-400`,low:`text-muted-foreground`},Rb={feature:`⚡`,bugfix:`🐛`,refactor:`♻️`,docs:`📝`,test:`🧪`,chore:`🔧`};function zb(){let{t:e}=V(),[t,n]=(0,U.useState)([]),[r,i]=(0,U.useState)(new Set),a=W(),o=(0,U.useRef)(null);(0,U.useEffect)(()=>(a.getTasks(),o.current=a.on(`tasks.updated`,e=>{let t=e?.payload;t?.tasks&&n(t.tasks)}),()=>{o.current?.()}),[a]);let s=(0,U.useCallback)(e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),c=(0,U.useCallback)((e,t)=>{a.updateTaskStatus(e,t)},[a]),l=[`in_progress`,`blocked`,`review`,`pending`,`failed`,`completed`],u=new Map;for(let e of t){let t=u.get(e.status)??[];t.push(e),u.set(e.status,t)}let d=u.get(`completed`)?.length??0;return t.length===0?null:(0,Y.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/50 backdrop-blur-sm overflow-hidden`,children:[(0,Y.jsxs)(`div`,{className:`px-3 py-1.5 flex items-center gap-2 border-b border-border/50`,children:[(0,Y.jsx)(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:e(`activity:work.tasks`)}),(0,Y.jsxs)(`span`,{className:`tabular text-[10px] text-muted-foreground ml-auto`,children:[d,`/`,t.length]})]}),l.map(t=>{let n=u.get(t);if(!n||n.length===0)return null;let i=Ib[t],a=r.has(t);return(0,Y.jsxs)(`div`,{className:`border-b border-border/30 last:border-b-0`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>s(t),className:`w-full px-3 py-1 flex items-center gap-1.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:(0,Y.jsxs)(`span`,{className:`tabular`,children:[a?`▶`:`▼`,` `,n.length,` `,e(`activity:task.${i.labelKey}`)]})}),!a&&n.map(t=>(0,Y.jsxs)(`div`,{className:X(`px-3 py-1.5 flex items-start gap-2 text-[13px] group`,t.status===`in_progress`?`bg-yellow-50/40 dark:bg-yellow-950/25`:``),children:[(0,Y.jsx)(`span`,{className:X(`mt-0.5 shrink-0`,i.color),children:i.icon}),(0,Y.jsxs)(`span`,{className:`leading-snug flex-1 min-w-0`,children:[(0,Y.jsxs)(`span`,{className:X(t.status===`completed`?`text-muted-foreground line-through`:`text-foreground/80`),children:[Rb[t.type],` `,t.title]}),t.priority!==`medium`&&(0,Y.jsx)(`span`,{className:X(`ml-1 text-[10px]`,Lb[t.priority]),children:t.priority}),t.assignee&&(0,Y.jsxs)(`span`,{className:`ml-1 text-[10px] text-muted-foreground`,children:[`@`,t.assignee]}),t.estimateHours&&(0,Y.jsxs)(`span`,{className:`ml-1 text-[10px] text-muted-foreground`,children:[t.estimateHours,`h`]})]}),(0,Y.jsxs)(`div`,{className:`flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,children:[t.status!==`in_progress`&&t.status!==`completed`&&(0,Y.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c(t.id,`in_progress`)},className:`px-1.5 py-0.5 text-[9px] rounded bg-primary/15 text-primary hover:bg-primary/25 transition-colors`,title:e(`activity:task.startTitle`),children:e(`common:action.start`)}),t.status===`in_progress`&&(0,Y.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c(t.id,`completed`)},className:`px-1.5 py-0.5 text-[9px] rounded bg-[hsl(var(--success)/0.15)] text-[hsl(var(--success))] hover:bg-[hsl(var(--success)/0.25)] transition-colors`,title:e(`activity:task.completeTitle`),children:e(`activity:task.statusDone`)}),t.status!==`completed`&&t.status!==`failed`&&(0,Y.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c(t.id,`failed`)},className:`px-1.5 py-0.5 text-[9px] rounded bg-destructive/15 text-destructive hover:bg-destructive/25 transition-colors`,title:e(`activity:task.failTitle`),children:e(`activity:task.fail`)})]})]},t.id))]},t)})]})}var Bb={open:{icon:(0,Y.jsx)(Or,{className:`w-3.5 h-3.5`}),labelKey:`statusOpen`,color:`text-muted-foreground/50`},in_progress:{icon:(0,Y.jsx)(Ge,{className:`w-3.5 h-3.5 animate-spin`}),labelKey:`statusInProgress`,color:`text-yellow-500`},done:{icon:(0,Y.jsx)(rn,{className:`w-3.5 h-3.5`}),labelKey:`statusDone`,color:`text-emerald-500`}};function Vb(){let{t:e}=V(),[t,n]=(0,U.useState)([]),[r,i]=(0,U.useState)(new Set),a=W(),o=(0,U.useRef)(null);(0,U.useEffect)(()=>(a.getPlan(),o.current=a.on(`plan.updated`,e=>{let t=e?.payload;t?.plan?.items&&n(t.plan.items)}),()=>{o.current?.()}),[a]);let s=(0,U.useCallback)(e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),c=(0,U.useCallback)((e,t)=>{a.updatePlanItem(e.id,t)},[a]),l=[`in_progress`,`open`,`done`],u=new Map;for(let e of t){let t=u.get(e.status)??[];t.push(e),u.set(e.status,t)}let d=u.get(`done`)?.length??0;return t.length===0?null:(0,Y.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/50 backdrop-blur-sm overflow-hidden`,children:[(0,Y.jsxs)(`div`,{className:`px-3 py-1.5 flex items-center gap-2 border-b border-border/50`,children:[(0,Y.jsxs)(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:[`📋 `,e(`activity:work.plan`)]}),(0,Y.jsxs)(`span`,{className:`tabular text-[10px] text-muted-foreground ml-auto`,children:[d,`/`,t.length]})]}),l.map(t=>{let n=u.get(t);if(!n||n.length===0)return null;let i=Bb[t],a=r.has(t);return(0,Y.jsxs)(`div`,{className:`border-b border-border/30 last:border-b-0`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>s(t),className:`w-full px-3 py-1 flex items-center gap-1.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:(0,Y.jsxs)(`span`,{className:`tabular`,children:[a?`▶`:`▼`,` `,n.length,` `,e(`activity:plan.${i.labelKey}`)]})}),!a&&n.map(t=>(0,Y.jsxs)(`div`,{className:X(`px-3 py-1.5 flex items-start gap-2 text-[13px] group`,t.status===`in_progress`?`bg-yellow-50/40 dark:bg-yellow-950/25`:``),children:[(0,Y.jsx)(`span`,{className:X(`mt-0.5 shrink-0`,i.color),children:i.icon}),(0,Y.jsx)(`span`,{className:X(`leading-snug flex-1 min-w-0`,t.status===`done`?`text-muted-foreground line-through`:`text-foreground/80`),children:t.title}),(0,Y.jsxs)(`div`,{className:`flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,children:[t.status===`open`&&(0,Y.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c(t,`in_progress`)},className:`px-1.5 py-0.5 text-[9px] rounded bg-primary/15 text-primary hover:bg-primary/25 transition-colors`,title:e(`activity:plan.startTitle`),children:e(`common:action.start`)}),t.status!==`done`&&(0,Y.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c(t,`done`)},className:`px-1.5 py-0.5 text-[9px] rounded bg-[hsl(var(--success)/0.15)] text-[hsl(var(--success))] hover:bg-[hsl(var(--success)/0.25)] transition-colors`,title:e(`activity:plan.doneTitle`),children:e(`activity:plan.statusDone`)}),t.status===`done`&&(0,Y.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c(t,`open`)},className:`px-1.5 py-0.5 text-[9px] rounded bg-muted text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,title:e(`activity:plan.reopenTitle`),children:e(`activity:plan.reopen`)})]})]},t.id))]},t)})]})}var Hb=[{id:`todos`,labelKey:`work.todos`,icon:`✅`},{id:`tasks`,labelKey:`work.tasks`,icon:`📋`},{id:`plan`,labelKey:`work.plan`,icon:`🗺️`}];function Ub(){let{t:e}=V(),t=J(e=>e.workDashboardTab),n=J(e=>e.setWorkDashboardTab);return(0,Y.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/50 backdrop-blur-sm overflow-hidden`,children:[(0,Y.jsx)(`div`,{className:`flex border-b border-border/50 bg-muted/30`,children:Hb.map(r=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>n(r.id),className:X(`flex items-center gap-1 px-3 py-1.5 text-[11px] font-medium transition-colors`,`border-b-2 -mb-px`,t===r.id?`border-primary text-foreground bg-background`:`border-transparent text-muted-foreground hover:text-foreground hover:bg-accent/30`),children:[(0,Y.jsx)(`span`,{className:`text-xs`,children:r.icon}),e(`activity:${r.labelKey}`)]},r.id))}),(0,Y.jsx)(`div`,{className:X(t===`todos`?`block`:`hidden`),children:(0,Y.jsx)(Fb,{})}),(0,Y.jsx)(`div`,{className:X(t===`tasks`?`block`:`hidden`),children:(0,Y.jsx)(zb,{})}),(0,Y.jsx)(`div`,{className:X(t===`plan`?`block`:`hidden`),children:(0,Y.jsx)(Vb,{})})]})}var Wb={autophase:{active:`bg-primary/15 border-primary/40 text-primary`,idle:`text-primary/80 hover:bg-primary/10`},goal:{active:`bg-rose-500/15 border-rose-500/40 text-rose-600 dark:text-rose-400`,idle:`text-rose-600/80 dark:text-rose-400/80 hover:bg-rose-500/10`},fleet:{active:`bg-emerald-500/15 border-emerald-500/40 text-emerald-600 dark:text-emerald-400`,idle:`text-emerald-600/80 dark:text-emerald-400/80 hover:bg-emerald-500/10`},work:{active:`bg-amber-500/15 border-amber-500/40 text-amber-600 dark:text-amber-400`,idle:`text-amber-600/80 dark:text-amber-400/80 hover:bg-amber-500/10`},worktrees:{active:`bg-violet-500/15 border-violet-500/40 text-violet-600 dark:text-violet-400`,idle:`text-violet-600/80 dark:text-violet-400/80 hover:bg-violet-500/10`},collab:{active:`bg-cyan-500/15 border-cyan-500/40 text-cyan-600 dark:text-cyan-400`,idle:`text-muted-foreground hover:bg-muted/60`}},Gb={autophase:`AutoPhase`,goal:`Goal`,fleet:`Fleet`,work:`Work`,worktrees:`Worktrees`,collab:`Collab`},Kb=[`autophase`,`goal`,`fleet`,`work`,`worktrees`,`collab`];function qb({section:e,icon:t,label:n,value:r,active:i,pulse:a,onClick:o}){let s=Wb[e],{t:c}=V();return(0,Y.jsxs)(`button`,{type:`button`,onClick:o,title:c(i?`activity:dock.collapseChip`:`activity:dock.expandChip`,{label:n}),className:X(`flex items-center gap-2 h-7 px-2.5 rounded-full border text-xs font-medium shrink-0 transition-colors`,i?s.active:X(`border-border/40`,s.idle)),children:[(0,Y.jsx)(`span`,{className:X(a&&`animate-pulse`),children:t}),n,r&&(0,Y.jsx)(`span`,{className:`tabular-nums opacity-80`,children:r})]})}function Jb({sessionId:e}){let t=J(e=>e.dockSection),{t:n}=V(),r=J(e=>e.toggleDockSection),i=J(e=>e.hiddenChips),o=J(e=>e.toggleChipHidden),s=J(e=>e.dockCustomizeOpen),c=J(e=>e.setDockCustomizeOpen),u=$s(e=>e.goal),d=ec(e=>e.phases.length),f=ec(e=>e.overallPercent),p=ec(e=>e.activePhaseId),m=Es(e=>e.worktrees),h=Es(e=>e.baseBranch),g=q(e=>e.todos),_=Xs(e=>e.agents),v=kb(),[y,b]=(0,U.useState)(`graph`),x=_.size,S=(0,U.useMemo)(()=>Array.from(_.values()).filter(e=>e.status===`running`).length,[_]),C=g.filter(e=>e.status===`completed`).length,w=g.some(e=>e.status===`in_progress`),T=d>0,E=(0,U.useMemo)(()=>new Set(i),[i]),D={autophase:T,goal:u!==null,fleet:x>0,work:!0,worktrees:m.length>0,collab:!0},O={autophase:(D.autophase||t===`autophase`)&&!E.has(`autophase`),goal:(D.goal||t===`goal`)&&!E.has(`goal`),fleet:(D.fleet||t===`fleet`)&&!E.has(`fleet`),work:(D.work||t===`work`)&&!E.has(`work`),worktrees:(D.worktrees||t===`worktrees`)&&!E.has(`worktrees`),collab:(D.collab||t===`collab`)&&!E.has(`collab`)},k=t&&O[t]?t:null;return(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 rounded-lg border border-border/50 bg-muted/20 px-2 py-1.5`,children:[O.autophase&&(0,Y.jsx)(qb,{section:`autophase`,icon:(0,Y.jsx)(a,{className:`h-3 w-3`}),label:`AutoPhase`,value:`${f}%`,active:!1,pulse:p!=null,onClick:()=>_l(`autophase`)}),O.goal&&u&&(0,Y.jsx)(qb,{section:`goal`,icon:(0,Y.jsx)(l,{className:`h-3 w-3`}),label:`Goal`,value:`${u.progress}%`,active:k===`goal`,pulse:u.goalState===`active`,onClick:()=>r(`goal`)}),O.fleet&&(0,Y.jsx)(qb,{section:`fleet`,icon:(0,Y.jsx)(j,{className:`h-3 w-3`}),label:`Fleet`,value:`${S}/${x}`,active:k===`fleet`,pulse:S>0,onClick:()=>r(`fleet`)}),(0,Y.jsx)(qb,{section:`work`,icon:(0,Y.jsx)(De,{className:`h-3 w-3`}),label:`Work`,value:g.length>0?`${C}/${g.length}`:void 0,active:k===`work`,pulse:w,onClick:()=>r(`work`)}),O.worktrees&&(0,Y.jsx)(qb,{section:`worktrees`,icon:(0,Y.jsx)(de,{className:`h-3 w-3`}),label:`Worktrees`,value:String(m.length),active:k===`worktrees`,onClick:()=>r(`worktrees`)}),v&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{},className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-full border border-border/40 text-xs font-mono hover:bg-muted/60 transition-colors`,children:[(0,Y.jsx)(de,{className:`h-3 w-3 shrink-0 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:v.branch}),v.ahead>0&&(0,Y.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-400`,title:n(`activity:dock.ahead`,{count:v.ahead}),children:[`↑`,v.ahead]}),v.behind>0&&(0,Y.jsxs)(`span`,{className:`text-amber-600 dark:text-amber-400`,title:n(`activity:dock.behind`,{count:v.behind}),children:[`↓`,v.behind]}),v.added>0&&(0,Y.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-400`,title:n(`activity:dock.linesAdded`,{count:v.added}),children:[`+`,v.added]}),v.deleted>0&&(0,Y.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,title:n(`activity:dock.linesDeleted`,{count:v.deleted}),children:[`-`,v.deleted]}),v.untracked>0&&(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,title:n(`activity:dock.untrackedFiles`,{count:v.untracked}),children:[v.untracked,`?`]})]}),(0,Y.jsx)(qb,{section:`collab`,icon:(0,Y.jsx)(Rr,{className:`h-3 w-3`}),label:`Collab`,active:k===`collab`,onClick:()=>r(`collab`)}),(0,Y.jsxs)(dd,{open:s,onOpenChange:c,children:[(0,Y.jsx)(fd,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,title:n(`activity:dock.customizeTitle`),className:`ml-auto inline-flex items-center justify-center h-7 w-7 rounded-full border border-border/40 text-muted-foreground hover:bg-muted/60 transition-colors shrink-0`,children:(0,Y.jsx)(Ve,{className:`h-3 w-3`})})}),(0,Y.jsxs)(gd,{align:`end`,className:`w-44`,children:[(0,Y.jsx)(bd,{children:n(`activity:dock.dockChips`)}),(0,Y.jsx)(xd,{}),Kb.map(e=>(0,Y.jsx)(vd,{checked:!E.has(e),onCheckedChange:()=>o(e),onSelect:e=>e.preventDefault(),children:Gb[e]},e))]})]})]}),k&&(0,Y.jsx)(`div`,{className:`border-t border-border/40 pt-2`}),k===`goal`&&(u?(0,Y.jsx)(Nb,{goal:u}):(0,Y.jsx)(Yb,{title:n(`activity:dock.noActiveGoal`),detail:n(`activity:dock.noActiveGoalDetail`)})),k===`fleet`&&(0,Y.jsx)(Cy,{}),k===`worktrees`&&(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(`div`,{className:`flex items-center gap-2`,children:[`graph`,`lanes`].map(e=>(0,Y.jsx)(`button`,{type:`button`,onClick:()=>b(e),className:X(`text-xs px-2.5 py-0.5 rounded-full border transition-colors capitalize`,y===e?`bg-primary/10 border-primary/30 text-primary`:`border-border text-muted-foreground hover:text-foreground`),children:e},e))}),(0,Y.jsx)(Yf,{}),y===`graph`?(0,Y.jsx)(Uf,{worktrees:m,baseBranch:h||`HEAD`}):(0,Y.jsx)(qf,{worktrees:m,baseBranch:h||`HEAD`})]}),(0,Y.jsx)(`div`,{className:X(k===`work`?`block`:`hidden`),id:`panel-work`,children:(0,Y.jsx)(Ub,{})}),(0,Y.jsx)(`div`,{className:X(k===`collab`?`block`:`hidden`),children:(0,Y.jsx)(Ab,{sessionId:e})})]})}function Yb({title:e,detail:t}){return(0,Y.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/20 px-3 py-2 text-xs`,children:[(0,Y.jsx)(`div`,{className:`font-medium text-foreground`,children:e}),(0,Y.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:t})]})}var Xb=new Set([`chat`,`settings`,`autophase`,`specs`,`sddboard`,`sddwizard`,`files`,`changes`,`sessions`,`setup`,`skill`,`officemap`,`mailbox`,`debug`,`design-gallery`,`refresh-debug`,`analytics`]),Zb=new Set([`autophase`,`goal`,`fleet`,`work`,`worktrees`,`collab`]),Qb=new Set([`todos`,`tasks`,`plan`]);function $b(){if(typeof window>`u`)return;let e=window.wrongstackDesktopHost;if(!e?.setPrefs)return;let t=ti.getState();e.setPrefs({yolo:t.yolo,nextPrediction:t.nextPrediction,contextAutoCompact:t.contextAutoCompact})}function ex(e){typeof window>`u`||window.wrongstackDesktopHost?.setReady?.(e)}function tx(e,t,n){typeof window>`u`||typeof e!=`string`||window.wrongstackDesktopHost?.ackCommand?.(e,t,n)}function nx(){let{theme:e}=ud(),t=cl(),{currentView:n,sidebarOpen:r,toggleSidebar:i,setSearchOpen:a,setSidebarOpen:o,setInspectorTab:s,setPaletteOpen:c,setShortcutsOpen:l,setModelSwitcherOpen:u,setPromptLibraryOpen:d,toggleInspector:f,fleetMonitorOpen:p,agentsMonitorOpen:m,setFleetMonitorOpen:h,setAgentsMonitorOpen:g,processMonitorOpen:_,setProcessMonitorOpen:v,queuePanelOpen:y,setQueuePanelOpen:b,terminalOpen:x,setTerminalOpen:S}=J(),C=G(e=>e.isLoading),w=q(e=>e.iteration),T=q(e=>e.projectName),E=q(e=>e.session?.title),D=q(e=>e.session?.id),O=J(e=>D?e.sessionNicknames[D]:void 0);return(0,U.useEffect)(()=>{t&&ys({sidebarOpen:!1})},[t]),(0,U.useEffect)(()=>{typeof window>`u`||(window.location.pathname===`/debug`?vl(`debug`):window.location.pathname===`/analytics`?vl(`analytics`):window.location.pathname===`/refresh-debug`&&vl(`refresh-debug`))},[]),(0,U.useEffect)(()=>{let e=e=>{let{filePath:t}=e.detail,n=W(K.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,U.useEffect)(()=>{let e=e=>{let{filePath:t}=e.detail,n=ic.getState().openFiles.find(e=>e.path===t);if(!n)return;let r=W(K.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)},[]),(0,U.useEffect)(()=>{if(typeof window>`u`)return;let e=window.matchMedia(`(max-width: 768px)`),t=()=>{e.matches&&J.getState().sidebarOpen&&o(!1)};return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[o]),od(),(0,U.useEffect)(()=>($b(),ti.subscribe((e,t)=>{e.yolo===t.yolo&&e.nextPrediction===t.nextPrediction&&e.contextAutoCompact===t.contextAutoCompact||$b()})),[]),(0,U.useEffect)(()=>{let e=e=>{let t=e&&typeof e==`object`&&!Array.isArray(e)?e:{},n=J.getState(),r=W(K.getState().wsUrl),i=!1,o=e=>{vl(e),e===`sessions`&&r?.listSessions?.(50)},s=t.activity;if(typeof s==`string`&&jd.includes(s)){let e=s;Q(e),i=!0,t.view===void 0&&pl(e)===`sessions`&&r?.listSessions?.(50)}let f=t.view;typeof f==`string`&&Xb.has(f)&&(o(f),i=!0);let p=t.action;p===`new-session`?(r?.newSession?.(),Q(`chat`),i=!0):p===`clear-context`?(Go.dropAll(),G.getState().clearMessages(),r?.clearContext?.(),Q(`chat`),i=!0):p===`compact-context`?(r?.compactContext?.(),Q(`chat`),i=!0):p===`repair-context`?(r?.repairContext?.(),Q(`chat`),i=!0):p===`download-chat`?(Op(),i=!0):p===`focus-chat`?(Q(`chat`),window.requestAnimationFrame(()=>document.querySelector(`textarea`)?.focus()),i=!0):p===`open-command-palette`?(c(!0),i=!0):p===`open-shortcuts`?(l(!0),i=!0):p===`search-chat`?(a(!0),i=!0):p===`open-model-switcher`?(u(!0),i=!0):p===`open-prompt-library`&&(d(!0),i=!0);let m=t.dockSection;if(typeof m==`string`&&Zb.has(m)){let e=m;if(n.showDockChip(e),n.setDockCustomizeOpen(!1),i=!0,m===`autophase`)return _l(`autophase`),n.setDockSection(null),i;Q(`chat`),n.setDockSection(e),m===`goal`&&r?.send?.({type:`goal.get`})}let _=t.workTab;typeof _==`string`&&Qb.has(_)&&(n.showDockChip(`work`),n.setDockCustomizeOpen(!1),Q(`chat`),n.setDockSection(`work`),n.setWorkDashboardTab(_),i=!0,_===`plan`&&r?.getPlan?.());let y=t.overlay;y===`fleet`?(h(!0),i=!0):y===`agents-monitor`?(g(!0),i=!0):y===`processes`?(v(!0),i=!0):y===`queue`&&(b(!0),i=!0),t.terminal===`toggle`?(n.toggleTerminal(),i=!0):t.terminal===`new`?(n.terminalOpen?n.requestTerminalCreate():S(!0),i=!0):t.terminal===!0?(S(!0),i=!0):t.terminal===!1&&(S(!1),i=!0);let x=t.pref;if(x&&typeof x==`object`&&!Array.isArray(x)){let e=x,t=e.key;if(t===`yolo`||t===`nextPrediction`||t===`contextAutoCompact`){let n=ti.getState(),a=e.toggle===!0?!n[t]:e.value;if(typeof a==`boolean`){let e={[t]:a};n.set(e),r?.updatePrefs?.(e),t===`yolo`&&Z.info(`YOLO ${a?`enabled`:`disabled`}`),i=!0}}}return i},t=new Set,n=[],r=e=>{for(t.add(e),n.push(e);n.length>120;){let e=n.shift();e&&t.delete(e)}},i=n=>{let i=(n&&typeof n==`object`&&!Array.isArray(n)?n:{}).requestId;if(typeof i==`string`&&t.has(i)){tx(i,!0);return}try{let t=e(n);t&&typeof i==`string`&&r(i),tx(i,t)}catch(e){tx(i,!1,e instanceof Error?e.message:String(e)),console.error(`Failed to handle desktop command:`,e)}},o=window.wrongstackDesktopCommands?.subscribe?.(e=>{i(e)})??null,s=e=>{i(e.detail)};return window.addEventListener(`wrongstack:desktop-command`,s),window.__wrongstackDesktopReady=!0,ex(!0),()=>{window.__wrongstackDesktopReady=!1,ex(!1),o&&o(),window.removeEventListener(`wrongstack:desktop-command`,s)}},[g,h,u,c,d,v,b,a,l,S]),(0,U.useEffect)(()=>{let e=()=>{try{let e=[q,G,J,K];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,U.useEffect)(()=>{if(typeof window>`u`||window.location.pathname===`/refresh-debug`)return;let e=J.getState().currentView;(e===`debug`||e===`analytics`||e===`design-gallery`||e===`setup`)&&Q(`chat`)},[]),(0,U.useEffect)(()=>{let e=[];if(C){let t=w?` iter ${w.index}${w.max?`/${w.max}`:``}`:``;e.push(`●${t}`)}let t=O?.trim()||E?.trim(),n=T?.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=T||`AI Agent`}},[C,w,T,E,O]),(0,U.useEffect)(()=>{let e=e=>{let t=e.target,n=t?.tagName?.toLowerCase(),r=n===`input`||n===`textarea`||t?.isContentEditable,o=e.ctrlKey||e.metaKey;if(o&&e.key===`\\`){e.preventDefault(),i();return}if(o&&e.key==="`"){e.preventDefault(),J.getState().toggleTerminal();return}if(o&&!e.shiftKey&&!e.altKey&&Object.hasOwn(dl,e.key)){let t=dl[e.key];if(t){e.preventDefault(),gl(t);return}}if(o&&e.shiftKey&&!e.altKey&&e.key.toLowerCase()===`w`){e.preventDefault(),gl(`worktrees`);return}if(!r&&!o&&!e.altKey&&/^F([1-9]|1[0-2])$/.test(e.key)){e.preventDefault();let t=J.getState(),n=W(K.getState().wsUrl),r=Number(e.key.slice(1));switch(t.setDockCustomizeOpen(!1),r){case 1:gl(`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.get`}),Q(`chat`),t.setDockSection(`goal`);return;case 10:n?.listSessions?.(50),Q(`history`);return;case 11:Q(`officemap`);return;case 12:Q(`chat`),t.setDockSection(`work`),t.setDockCustomizeOpen(!0);return}}if(o&&e.key.toLowerCase()===`f`){e.preventDefault(),a(!0);return}if(o&&e.key.toLowerCase()===`/`){e.preventDefault(),document.querySelector(`textarea`)?.focus();return}if(o&&!r&&(e.key.toLowerCase()===`l`?(e.preventDefault(),Go.dropAll(),G.getState().clearMessages(),W(K.getState().wsUrl)?.clearContext?.()):e.key.toLowerCase()===`n`?(e.preventDefault(),W(K.getState().wsUrl)?.newSession?.(),Q(`chat`)):e.key.toLowerCase()===`e`&&(e.preventDefault(),Op())),o&&e.shiftKey&&e.key.toLowerCase()===`d`&&(e.preventDefault(),J.getState().toggleCompactMode()),o&&e.shiftKey&&e.key.toLowerCase()===`m`){e.preventDefault();let t=J.getState();t.inspectorOpen&&t.inspectorTab===`fleet`?f():(s(`fleet`),t.inspectorOpen||f())}if(o&&e.shiftKey&&e.key.toLowerCase()===`a`){e.preventDefault();let t=J.getState();t.inspectorOpen&&t.inspectorTab===`agents`?f():(s(`agents`),t.inspectorOpen||f())}if(o&&e.shiftKey&&e.key.toLowerCase()===`g`&&(e.preventDefault(),vl(`debug`)),e.key===`Escape`&&!o&&J.getState().inspectorOpen&&J.getState().setInspectorOpen(!1),!r&&!o&&!e.altKey){let t=Array.from(document.querySelectorAll(`[data-message-id]`));if(t.length===0)return;let n=document.querySelector(`[data-message-id][data-focused="true"]`),r=n?t.indexOf(n):-1,i=e=>{for(let e of t)e.removeAttribute(`data-focused`);e.setAttribute(`data-focused`,`true`),e.scrollIntoView({behavior:`smooth`,block:`center`})};if(e.key===`j`||e.key===`ArrowDown`){let n=t[Math.min(t.length-1,Math.max(0,r+1))];n&&(e.preventDefault(),i(n));return}if(e.key===`k`||e.key===`ArrowUp`){let n=t[Math.max(0,r<=0?0:r-1)];n&&(e.preventDefault(),i(n));return}if(e.key===`g`&&!e.shiftKey){e.preventDefault(),i(Ur(t[0]));return}if(e.key===`G`||e.key===`g`&&e.shiftKey){e.preventDefault(),i(Ur(t[t.length-1]));return}if(e.key===`Escape`&&n){e.preventDefault(),n.removeAttribute(`data-focused`);return}if(e.key===`c`&&n){let t=n.querySelector(`.markdown-content`)?.innerText??n.innerText;t&&(navigator.clipboard?.writeText(t).catch(()=>{}),e.preventDefault());return}}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i,a]),(0,Y.jsxs)(`div`,{"data-shell":t?`desktop`:`browser`,className:X(`ws-app-root flex min-h-0 min-w-0 overflow-hidden`,t&&`ws-desktop-shell`,e),children:[n!==`setup`&&(0,Y.jsx)(Pd,{desktopShell:t}),r&&n!==`setup`&&(0,Y.jsx)(ob,{desktopShell:t}),(0,Y.jsxs)(`main`,{className:`flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden`,children:[n!==`setup`&&(0,Y.jsx)(sh,{}),n===`chat`&&(0,Y.jsxs)(Y.Fragment,{children:[D&&(0,Y.jsx)(`div`,{className:X(`ws-workspace-dock-wrap px-4 pt-2 shrink-0 overflow-y-auto overscroll-contain`,x?`max-h-[28dvh]`:`max-h-[45dvh]`),children:(0,Y.jsx)(Jb,{sessionId:D})}),(0,Y.jsx)(Um,{}),(0,Y.jsx)(rg,{})]}),n===`settings`&&(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Y.jsx)(Gv,{})}),n===`setup`&&(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Y.jsx)(fy,{})}),n===`autophase`&&(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Y.jsx)(Xf,{onClose:()=>Q(`chat`)})}),n===`specs`&&(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Y.jsx)(_b,{onClose:()=>Q(`chat`)})}),n===`sddboard`&&(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Y.jsx)(F_,{onClose:()=>Q(`chat`)})}),n===`sddwizard`&&(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Y.jsx)(H_,{onClose:()=>Q(`chat`)})}),n===`sessions`&&(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto`,children:(0,Y.jsx)(Z_,{})}),n===`debug`&&(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Y.jsx)(lh,{})}),n===`refresh-debug`&&(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Y.jsx)($g,{})}),n===`files`&&(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Y.jsx)(rh,{})}),n===`changes`&&(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Y.jsx)(ap,{className:`h-full min-h-0`})}),n===`mailbox`&&(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Y.jsx)(pg,{className:`h-full min-h-0`})}),n===`design-gallery`&&(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Y.jsx)(Ch,{className:`h-full`})}),n===`skill`&&(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Y.jsx)(ub,{className:`h-full`})}),n===`officemap`&&(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Y.jsx)(Jg,{})}),n===`analytics`&&(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Y.jsx)(pf,{})}),x&&(0,Y.jsx)(Db,{desktopShell:t,onClose:()=>S(!1)})]}),p&&(0,Y.jsx)(Wh,{onClose:()=>h(!1)}),m&&(0,Y.jsx)(of,{onClose:()=>g(!1)}),_&&(0,Y.jsx)(jm,{open:_,onClose:()=>v(!1)}),y&&(0,Y.jsx)(Xg,{open:y,onClose:()=>b(!1)}),(0,Y.jsx)(oh,{}),(0,Y.jsx)(jf,{}),(0,Y.jsx)(Pf,{}),(0,Y.jsx)(Ap,{}),(0,Y.jsx)(my,{}),(0,Y.jsx)(Qg,{}),(0,Y.jsx)(Vc,{})]})}function rx(){return(0,Y.jsx)(wh,{children:(0,Y.jsx)(ld,{defaultTheme:`system`,children:(0,Y.jsx)(nx,{})})})}ey(),Kr.createRoot(Ur(document.getElementById(`root`))).render((0,Y.jsx)(U.StrictMode,{children:(0,Y.jsx)(rx,{})}));