tide-commander 1.84.6 → 1.85.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.
- package/dist/assets/{BossLogsModal-Cdpx6ycE.js → BossLogsModal-uPeGcb3I.js} +1 -1
- package/dist/assets/{BossSpawnModal-Dggt0YfE.js → BossSpawnModal-D7iyXoJq.js} +1 -1
- package/dist/assets/{ControlsModal-CUlAiEBw.js → ControlsModal-DXnnGYp5.js} +1 -1
- package/dist/assets/{DockerLogsModal-CMXFBadq.js → DockerLogsModal-DxmUWbDV.js} +1 -1
- package/dist/assets/{EmbeddedEditor-BCndZBxL.js → EmbeddedEditor-BUi6dUs3.js} +1 -1
- package/dist/assets/{GmailOAuthSetup-Cc5WGia9.js → GmailOAuthSetup-iCnmfNtc.js} +1 -1
- package/dist/assets/{GoogleOAuthSetup-bcxBts0d.js → GoogleOAuthSetup-BPMmX5ua.js} +1 -1
- package/dist/assets/{IframeModal-DVZTZXmQ.js → IframeModal-CVJjFAPp.js} +1 -1
- package/dist/assets/{IntegrationsPanel-Qk_q6nK2.js → IntegrationsPanel-DpQUsPg2.js} +2 -2
- package/dist/assets/{LogViewerModal-CGlMdoYd.js → LogViewerModal-tBZ1aP8p.js} +1 -1
- package/dist/assets/{MonitoringModal-Cz9QeKZW.js → MonitoringModal-B4A0qczU.js} +1 -1
- package/dist/assets/{PM2LogsModal-Bx2vdQ-E.js → PM2LogsModal-i7fxasp0.js} +1 -1
- package/dist/assets/{RestoreArchivedAreaModal-DcJJGwXu.js → RestoreArchivedAreaModal-UurWP1-j.js} +1 -1
- package/dist/assets/{Scene2DCanvas-CfE7OMGC.js → Scene2DCanvas-B9DuBLip.js} +1 -1
- package/dist/assets/{SceneManager-rHjb08q0.js → SceneManager-xEBRq68j.js} +1 -1
- package/dist/assets/{SkillsPanel-BHzuGofi.js → SkillsPanel-BDyKxve4.js} +1 -1
- package/dist/assets/{SpawnModal-DIdl2Drd.js → SpawnModal-CBKT43_l.js} +1 -1
- package/dist/assets/{SubordinateAssignmentModal-DQwdL9vl.js → SubordinateAssignmentModal-CddDPiHW.js} +1 -1
- package/dist/assets/{TriggerManagerPanel-DyBatEQL.js → TriggerManagerPanel-CcVCNnhm.js} +1 -1
- package/dist/assets/{WorkflowEditorPanel-BgmL4Ch-.js → WorkflowEditorPanel-C5meCq60.js} +1 -1
- package/dist/assets/{index-Czc4WA-r.js → index-BNQjdC7D.js} +3 -3
- package/dist/assets/{index-DWbo7Hf3.js → index-BfUS9DYN.js} +1 -1
- package/dist/assets/{index-1OSS3ui-.js → index-C7Mu39PP.js} +1 -1
- package/dist/assets/{index-DaMAErCi.js → index-CQll-mer.js} +2 -2
- package/dist/assets/{index-CWlU_PZq.js → index-CrpntCm1.js} +1 -1
- package/dist/assets/index-D_wtUWqj.js +2 -0
- package/dist/assets/{index-DMhLboZ5.js → index-DtDo7QHt.js} +1 -1
- package/dist/assets/{index-4c1B05V1.js → index-JUHUy-Tv.js} +1 -1
- package/dist/assets/{index-BGT2utqA.js → index-huFbdygq.js} +1 -1
- package/dist/assets/{main-DrsDQIKU.js → main-Q3uQGSTr.js} +85 -85
- package/dist/assets/{main-CFu_SP_0.css → main-kpU9m5LW.css} +1 -1
- package/dist/assets/{web-D1RJXxjR.js → web-_0kug6fn.js} +1 -1
- package/dist/assets/{web-BP2TNYTf.js → web-ko2U5w1Z.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/locales/en/terminal.json +14 -0
- package/dist/src/packages/server/routes/agents.js +28 -0
- package/dist/src/packages/server/services/claude-usage-service.js +66 -0
- package/package.json +1 -1
- package/dist/assets/index-DMQ6F_-M.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ci as s}from"./main-
|
|
1
|
+
import{ci as s}from"./main-Q3uQGSTr.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";class l extends s{constructor(){super(...arguments),this.pending=[],this.deliveredNotifications=[],this.hasNotificationSupport=()=>{if(!("Notification"in window)||!Notification.requestPermission)return!1;if(Notification.permission!=="granted")try{new Notification("")}catch(i){if(i instanceof Error&&i.name==="TypeError")return!1}return!0}}async getDeliveredNotifications(){const i=[];for(const t of this.deliveredNotifications){const e={title:t.title,id:parseInt(t.tag),body:t.body};i.push(e)}return{notifications:i}}async removeDeliveredNotifications(i){for(const t of i.notifications){const e=this.deliveredNotifications.find(n=>n.tag===String(t.id));e==null||e.close(),this.deliveredNotifications=this.deliveredNotifications.filter(()=>!e)}}async removeAllDeliveredNotifications(){for(const i of this.deliveredNotifications)i.close();this.deliveredNotifications=[]}async createChannel(){throw this.unimplemented("Not implemented on web.")}async deleteChannel(){throw this.unimplemented("Not implemented on web.")}async listChannels(){throw this.unimplemented("Not implemented on web.")}async schedule(i){if(!this.hasNotificationSupport())throw this.unavailable("Notifications not supported in this browser.");for(const t of i.notifications)this.sendNotification(t);return{notifications:i.notifications.map(t=>({id:t.id}))}}async getPending(){return{notifications:this.pending}}async registerActionTypes(){throw this.unimplemented("Not implemented on web.")}async cancel(i){this.pending=this.pending.filter(t=>!i.notifications.find(e=>e.id===t.id))}async areEnabled(){const{display:i}=await this.checkPermissions();return{value:i==="granted"}}async changeExactNotificationSetting(){throw this.unimplemented("Not implemented on web.")}async checkExactNotificationSetting(){throw this.unimplemented("Not implemented on web.")}async requestPermissions(){if(!this.hasNotificationSupport())throw this.unavailable("Notifications not supported in this browser.");return{display:this.transformNotificationPermission(await Notification.requestPermission())}}async checkPermissions(){if(!this.hasNotificationSupport())throw this.unavailable("Notifications not supported in this browser.");return{display:this.transformNotificationPermission(Notification.permission)}}transformNotificationPermission(i){switch(i){case"granted":return"granted";case"denied":return"denied";default:return"prompt"}}sendPending(){var i;const t=[],e=new Date().getTime();for(const n of this.pending)!((i=n.schedule)===null||i===void 0)&&i.at&&n.schedule.at.getTime()<=e&&(this.buildNotification(n),t.push(n));this.pending=this.pending.filter(n=>!t.find(o=>o===n))}sendNotification(i){var t;if(!((t=i.schedule)===null||t===void 0)&&t.at){const e=i.schedule.at.getTime()-new Date().getTime();this.pending.push(i),setTimeout(()=>{this.sendPending()},e);return}this.buildNotification(i)}buildNotification(i){const t=new Notification(i.title,{body:i.body,tag:String(i.id)});return t.addEventListener("click",this.onClick.bind(this,i),!1),t.addEventListener("show",this.onShow.bind(this,i),!1),t.addEventListener("close",()=>{this.deliveredNotifications=this.deliveredNotifications.filter(()=>!this)},!1),this.deliveredNotifications.push(t),t}onClick(i){const t={actionId:"tap",notification:i};this.notifyListeners("localNotificationActionPerformed",t)}onShow(i){this.notifyListeners("localNotificationReceived",i)}}export{l as LocalNotificationsWeb};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ci as a}from"./main-
|
|
1
|
+
import{ci as a}from"./main-Q3uQGSTr.js";import{ImpactStyle as i,NotificationType as r}from"./index-CQll-mer.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";class h extends a{constructor(){super(...arguments),this.selectionStarted=!1}async impact(t){const e=this.patternForImpact(t==null?void 0:t.style);this.vibrateWithPattern(e)}async notification(t){const e=this.patternForNotification(t==null?void 0:t.type);this.vibrateWithPattern(e)}async vibrate(t){const e=(t==null?void 0:t.duration)||300;this.vibrateWithPattern([e])}async selectionStart(){this.selectionStarted=!0}async selectionChanged(){this.selectionStarted&&this.vibrateWithPattern([70])}async selectionEnd(){this.selectionStarted=!1}patternForImpact(t=i.Heavy){return t===i.Medium?[43]:t===i.Light?[20]:[61]}patternForNotification(t=r.Success){return t===r.Warning?[30,40,30,50,60]:t===r.Error?[27,45,50]:[35,65,21]}vibrateWithPattern(t){if(navigator.vibrate)navigator.vibrate(t);else throw this.unavailable("Browser does not support the vibrate API")}}export{h as HapticsWeb};
|
package/dist/index.html
CHANGED
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
<link rel="icon" type="image/png" sizes="16x16" href="/assets/icons/favicon-16x16.png" />
|
|
23
23
|
<link rel="apple-touch-icon" sizes="180x180" href="/assets/icons/apple-touch-icon.png" />
|
|
24
24
|
<title>Tide Commander</title>
|
|
25
|
-
<script type="module" crossorigin src="/assets/main-
|
|
25
|
+
<script type="module" crossorigin src="/assets/main-Q3uQGSTr.js"></script>
|
|
26
26
|
<link rel="modulepreload" crossorigin href="/assets/vendor-react--Eh9ivFN.js">
|
|
27
27
|
<link rel="modulepreload" crossorigin href="/assets/vendor-three-Chj50gSY.js">
|
|
28
|
-
<link rel="stylesheet" crossorigin href="/assets/main-
|
|
28
|
+
<link rel="stylesheet" crossorigin href="/assets/main-kpU9m5LW.css">
|
|
29
29
|
</head>
|
|
30
30
|
<body>
|
|
31
31
|
<div id="app"></div>
|
|
@@ -1187,5 +1187,19 @@
|
|
|
1187
1187
|
"can-clear-context": "Fully done — context safe to clear",
|
|
1188
1188
|
"waiting-subordinates": "Waiting on delegated work",
|
|
1189
1189
|
"working": "Working"
|
|
1190
|
+
},
|
|
1191
|
+
"usage": {
|
|
1192
|
+
"title": "Claude Usage",
|
|
1193
|
+
"session": "Session",
|
|
1194
|
+
"tokensUsed": "Tokens used",
|
|
1195
|
+
"taskCount": "Tasks sent",
|
|
1196
|
+
"today": "Today",
|
|
1197
|
+
"messages": "Messages",
|
|
1198
|
+
"sessions": "Sessions",
|
|
1199
|
+
"toolCalls": "Tool calls",
|
|
1200
|
+
"noActivityToday": "No activity recorded yet today.",
|
|
1201
|
+
"recentDays": "Last 7 days",
|
|
1202
|
+
"refresh": "Refresh usage data",
|
|
1203
|
+
"error": "Could not load usage: {{message}}"
|
|
1190
1204
|
}
|
|
1191
1205
|
}
|
|
@@ -19,6 +19,7 @@ import { buildCustomAgentConfig } from '../websocket/handlers/command-handler.js
|
|
|
19
19
|
import { clearDelegation, getBossForSubordinate } from '../websocket/handlers/boss-response-handler.js';
|
|
20
20
|
import { OpencodeBackend } from '../opencode/backend.js';
|
|
21
21
|
import { getSystemPrompt, setSystemPrompt, clearSystemPrompt, isEchoPromptEnabled, setEchoPromptEnabled, getCodexBinaryPath, setCodexBinaryPath, isTmuxModeEnabled, setTmuxModeEnabled } from '../services/system-prompt-service.js';
|
|
22
|
+
import { buildClaudeUsageSnapshot } from '../services/claude-usage-service.js';
|
|
22
23
|
import { getBackupStatus, setBackupEnabled } from '../services/backup-service.js';
|
|
23
24
|
const log = createLogger('Routes');
|
|
24
25
|
const router = Router();
|
|
@@ -693,6 +694,33 @@ router.delete('/:id', (req, res) => {
|
|
|
693
694
|
}
|
|
694
695
|
res.status(204).end();
|
|
695
696
|
});
|
|
697
|
+
// GET /api/agents/:id/usage - Claude usage snapshot for a single agent
|
|
698
|
+
//
|
|
699
|
+
// Mirrors what the Claude CLI's `/usage` slash command would surface — but
|
|
700
|
+
// assembled from local data we can read non-interactively. See
|
|
701
|
+
// services/claude-usage-service.ts for the rationale and source list.
|
|
702
|
+
router.get('/:id/usage', (req, res) => {
|
|
703
|
+
const agent = agentService.getAgent(req.params.id);
|
|
704
|
+
if (!agent) {
|
|
705
|
+
res.status(404).json({ error: 'Agent not found' });
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
if (agent.provider !== 'claude') {
|
|
709
|
+
res.status(400).json({
|
|
710
|
+
error: 'Usage data is only available for Claude agents',
|
|
711
|
+
provider: agent.provider,
|
|
712
|
+
});
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
715
|
+
try {
|
|
716
|
+
const snapshot = buildClaudeUsageSnapshot(agent);
|
|
717
|
+
res.json(snapshot);
|
|
718
|
+
}
|
|
719
|
+
catch (err) {
|
|
720
|
+
log.error('Failed to build Claude usage snapshot:', err);
|
|
721
|
+
res.status(500).json({ error: err?.message ?? 'Failed to build usage snapshot' });
|
|
722
|
+
}
|
|
723
|
+
});
|
|
696
724
|
// GET /api/agents/:id/sessions - List agent's sessions
|
|
697
725
|
router.get('/:id/sessions', async (req, res) => {
|
|
698
726
|
try {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Usage Service
|
|
3
|
+
*
|
|
4
|
+
* Surfaces the same data the Claude Code CLI shows in its `/usage` slash
|
|
5
|
+
* command panel — but assembled from sources we can read non-interactively.
|
|
6
|
+
*
|
|
7
|
+
* The CLI's interactive `/usage` panel pulls weekly/session rate-limit
|
|
8
|
+
* percentages from Anthropic's API at runtime. That request can't be replayed
|
|
9
|
+
* server-side without driving the CLI's React TUI through a real PTY (the
|
|
10
|
+
* slash-command interception only fires on real keystrokes; piping `/usage\r`
|
|
11
|
+
* into stdin gets sent to the model as plain text instead). So this service
|
|
12
|
+
* returns what's reliably available locally:
|
|
13
|
+
* - per-agent session totals (tokens + context) from Tide's own tracking
|
|
14
|
+
* - daily activity history from `~/.claude/stats-cache.json` (the file the
|
|
15
|
+
* CLI populates as it runs — same cache `/usage` reads from)
|
|
16
|
+
* and a `cliHint` string the frontend can display so the user knows where to
|
|
17
|
+
* look for the live rate-limit gauges.
|
|
18
|
+
*/
|
|
19
|
+
import * as fs from 'fs';
|
|
20
|
+
import * as os from 'os';
|
|
21
|
+
import * as path from 'path';
|
|
22
|
+
import { createLogger } from '../utils/logger.js';
|
|
23
|
+
const log = createLogger('ClaudeUsage');
|
|
24
|
+
const STATS_CACHE_PATH = path.join(os.homedir(), '.claude', 'stats-cache.json');
|
|
25
|
+
function readStatsCache() {
|
|
26
|
+
try {
|
|
27
|
+
if (!fs.existsSync(STATS_CACHE_PATH))
|
|
28
|
+
return null;
|
|
29
|
+
const raw = fs.readFileSync(STATS_CACHE_PATH, 'utf-8');
|
|
30
|
+
return JSON.parse(raw);
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
log.warn(`Failed to read stats cache at ${STATS_CACHE_PATH}: ${err}`);
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function todayString() {
|
|
38
|
+
const d = new Date();
|
|
39
|
+
const yyyy = d.getFullYear();
|
|
40
|
+
const mm = String(d.getMonth() + 1).padStart(2, '0');
|
|
41
|
+
const dd = String(d.getDate()).padStart(2, '0');
|
|
42
|
+
return `${yyyy}-${mm}-${dd}`;
|
|
43
|
+
}
|
|
44
|
+
export function buildClaudeUsageSnapshot(agent) {
|
|
45
|
+
const cache = readStatsCache();
|
|
46
|
+
const all = cache?.dailyActivity ?? [];
|
|
47
|
+
// The cache writes oldest-first; sort newest-first for display.
|
|
48
|
+
const sortedDesc = [...all].sort((a, b) => (a.date < b.date ? 1 : a.date > b.date ? -1 : 0));
|
|
49
|
+
const today = sortedDesc.find((e) => e.date === todayString()) ?? null;
|
|
50
|
+
const recentDays = sortedDesc.slice(0, 14);
|
|
51
|
+
return {
|
|
52
|
+
provider: 'claude',
|
|
53
|
+
fetchedAt: Date.now(),
|
|
54
|
+
session: {
|
|
55
|
+
tokensUsed: agent.tokensUsed ?? 0,
|
|
56
|
+
contextUsed: agent.contextUsed ?? 0,
|
|
57
|
+
contextLimit: agent.contextLimit ?? 200_000,
|
|
58
|
+
taskCount: agent.taskCount ?? 0,
|
|
59
|
+
lastActivity: agent.lastActivity ?? 0,
|
|
60
|
+
},
|
|
61
|
+
today,
|
|
62
|
+
recentDays,
|
|
63
|
+
statsCacheLastComputed: cache?.lastComputedDate ?? null,
|
|
64
|
+
cliHint: 'Run /usage inside this agent\'s terminal to see live weekly and session rate-limit gauges (those live in the Claude Code TUI and aren\'t exposed as a non-interactive command).',
|
|
65
|
+
};
|
|
66
|
+
}
|
package/package.json
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as a,u as Ot,z as nn,j as e,V as an,B as sn,E as ln,G as St,S as k,H as Et,J as vt,K as Mt,L as rt,M as ae,N as rn,s as h,O as $t,P as Bt,U as on,v as Tt,w as Pt,I as u,W as cn,m as dn,X as un,Y as Ft,Z as Wt,_ as pn,$ as mn,a0 as fn,a1 as hn,a2 as gn,a3 as xn,a4 as bn,a5 as _n,a6 as wn,a7 as Cn,a8 as Lt,C as vn,a9 as jn,aa as Nn,ab as kn,ac as yn,ad as In,ae as An,af as Sn,ag as En,ah as Mn,ai as Tn,aj as Pn,ak as Ln,al as Rn,am as zn,an as Dn,ao as On}from"./main-DrsDQIKU.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const $n=a.memo(function({className:c=""}){const{t:I}=Ot(["common"]),[A,T]=nn(),K=a.useRef(null),[W,se]=a.useState(null);a.useLayoutEffect(()=>{const C=K.current;if(!C)return;const Y=C.querySelector(".view-mode-toggle__btn--active");Y&&se({left:Y.offsetLeft,width:Y.offsetWidth})},[A]);const M=a.useCallback(C=>{if(C!==A){if(typeof window<"u"&&window.dispatchEvent(new CustomEvent("tide:viewmode-switch-pressed",{detail:{mode:C}})),C==="3d"){requestAnimationFrame(()=>T(C));return}T(C)}},[A,T]);return e.jsxs("div",{className:`view-mode-toggle ${c}`,ref:K,children:[W&&e.jsx("div",{className:"view-mode-toggle__indicator",style:{left:W.left,width:W.width}}),an.map(C=>e.jsxs("button",{className:`view-mode-toggle__btn ${A===C?"view-mode-toggle__btn--active":""}`,onClick:()=>M(C),title:I(`common:viewMode.descriptions.${C}`),children:[e.jsxs("span",{className:"view-mode-toggle__icon",children:[C==="2d"&&e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),e.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"21"})]}),C==="3d"&&e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),e.jsx("path",{d:"M2 17l10 5 10-5"}),e.jsx("path",{d:"M2 12l10 5 10-5"})]}),C==="flat"&&e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"3",width:"8",height:"8",rx:"1"}),e.jsx("rect",{x:"13",y:"3",width:"8",height:"8",rx:"1"}),e.jsx("rect",{x:"3",y:"13",width:"8",height:"8",rx:"1"}),e.jsx("rect",{x:"13",y:"13",width:"8",height:"8",rx:"1"})]}),C==="dashboard"&&e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"3",width:"7",height:"9",rx:"1"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"5",rx:"1"}),e.jsx("rect",{x:"14",y:"12",width:"7",height:"9",rx:"1"}),e.jsx("rect",{x:"3",y:"16",width:"7",height:"5",rx:"1"})]})]}),e.jsx("span",{className:"view-mode-toggle__label",children:I(`common:viewMode.labels.${C}`)})]},C))]})}),ot=3,ct=280,Rt=320,Ct=240,zt=64,Bn=["simple","chat","advanced"],Fn={simple:"Simple",chat:"Chat",advanced:"Advanced"},Wn={simple:"○",chat:"◐",advanced:"◉"},Hn={simple:"Simple view — clean messages only",chat:"Chat view — assistant replies (no tool calls)",advanced:"Advanced view — everything including tools"},Dt="flat-clear-context";function Vn(_){const c=_.split("/").filter(Boolean);return c.length===0?_:c.slice(-2).join("/")}function Gn(_){if(_.provider==="codex"){const K=_.codexModel||"gpt-5.3-codex",W=zn[K];return{model:(W==null?void 0:W.label)||K}}if(_.provider==="opencode")return{model:_.opencodeModel||"opencode"};const c=_.model||"sonnet",I=On[c],A=_.effort,T=A?Dn[A]:void 0;return{model:(I==null?void 0:I.label)||c,effort:T==null?void 0:T.label}}function Xn(_,c){if(c.type==="rectangle"&&c.width&&c.height){const I=c.width/2,A=c.height/2;return _.x>=c.center.x-I&&_.x<=c.center.x+I&&_.z>=c.center.z-A&&_.z<=c.center.z+A}if(c.type==="circle"&&c.radius){const I=_.x-c.center.x,A=_.z-c.center.z;return I*I+A*A<=c.radius*c.radius}return!1}const Un=jn.memo(function({agentId:c,terminalViewMode:I,onTerminalViewModeChange:A,inspectorOpen:T,onToggleInspector:K,onImageClick:W,onFileClick:se,onBashClick:M,onViewMarkdown:C,onRequestClearSubordinates:Y,onOpenBuilding:Pe,keyboard:We,canNavigateBack:He,canNavigateForward:Le,onNavigateBack:le,onNavigateForward:D,agentInfoOpen:ye,onToggleAgentInfo:Z}){var ue,Me,te,Qe;const g=Nn(c),P=Bt(),me=a.useRef(null),Ie=a.useRef(null);a.useEffect(()=>{const l=Ie.current;if(!l)return;const r=o=>{o.button===3?(o.preventDefault(),o.stopPropagation(),le()):o.button===4&&(o.preventDefault(),o.stopPropagation(),D())},d=o=>{(o.button===3||o.button===4)&&o.preventDefault()};return l.addEventListener("mouseup",r),l.addEventListener("mousedown",d),()=>{l.removeEventListener("mouseup",r),l.removeEventListener("mousedown",d)}},[le,D]),a.useEffect(()=>{const l=Ie.current;if(!l)return;let r=0,d=0,o=0;const pe=250,ve=600,Te=80,ht=1.5,gt=L=>{let S=L instanceof HTMLElement?L:null;for(;S&&S!==l;){const et=window.getComputedStyle(S).overflowX;if((et==="auto"||et==="scroll")&&S.scrollWidth>S.clientWidth)return!0;S=S.parentElement}return!1},G=L=>{const S=Date.now();if(S<o){L.preventDefault();return}if(Math.abs(L.deltaX)<=Math.abs(L.deltaY)*ht){r=0;return}if(gt(L.target)){r=0;return}S-d>pe&&(r=0),d=S,r+=L.deltaX,r<=-Te?(r=0,o=S+ve,L.preventDefault(),le()):r>=Te&&(r=0,o=S+ve,L.preventDefault(),D())};return l.addEventListener("wheel",G,{passive:!1}),()=>l.removeEventListener("wheel",G)},[le,D]);const fe=$t(),Re=a.useMemo(()=>{if(!g)return null;const l=new Set,r=[];for(const d of fe.values())d.archived||d.directories.length===0||d.assignedAgentIds.includes(c)&&(l.add(d.id),r.push(d));for(const d of fe.values())d.archived||d.directories.length===0||l.has(d.id)||Xn({x:g.position.x,z:g.position.z},d)&&(l.add(d.id),r.push(d));return r.length===0?null:r.flatMap(d=>d.directories.filter(o=>o&&o.trim().length>0).map(o=>({areaId:d.id,areaName:d.name,dir:o})))},[g,c,fe]),{branches:Ve,fetchRemote:Ge,fetchingDirs:ze}=kn(Re),Ae=a.useMemo(()=>{var d;const l=h.getAreaForAgent(c);if(!l)return[];const r=[];for(const o of P.values())o.type==="terminal"&&h.isPositionInArea(o.position,l)&&r.push({id:o.id,name:o.name,hasUrl:!!((d=o.terminalStatus)!=null&&d.url)});return r},[c,P]),he=a.useMemo(()=>{var d;const l=h.getAreaForAgent(c);if(!l)return[];const r=[];for(const o of P.values())o.type==="server"&&((d=o.pm2)!=null&&d.enabled)&&h.isPositionInArea(o.position,l)&&r.push({id:o.id,name:o.name});return r},[c,P]),ie=a.useMemo(()=>{const l=h.getAreaForAgent(c);if(!l)return[];const r=[];for(const d of P.values())d.type==="database"&&d.database&&h.isPositionInArea(d.position,l)&&r.push({id:d.id,name:d.name});return r},[c,P]),[,re]=a.useReducer(l=>l+1,0),H=((ue=me.current)==null?void 0:ue.search.searchMode)??!1,dt=a.useCallback(()=>{var l;(l=me.current)==null||l.search.toggleSearch(),re()},[]),Xe=yn(),oe=Xe.isPending(Dt),[$,X]=a.useState(null),V=$?P.get($):null,{height:U,onResizeStart:Se}=In(),[B,J]=a.useState(()=>vt(k.GIT_PANEL_OPEN,!1)),[ge,Ue]=a.useState(()=>vt(k.BUILDINGS_PANEL_OPEN,!1)),[ce,xe]=a.useState(!1),ut=a.useCallback(()=>{xe(l=>{const r=!l;return r&&An.setEnabled(!0),r})},[]),pt=a.useCallback(()=>xe(!1),[]),be=a.useCallback(()=>{J(l=>{const r=!l;return ae(k.GIT_PANEL_OPEN,r),r})},[]),mt=a.useCallback(()=>{Ue(l=>{const r=!l;return ae(k.BUILDINGS_PANEL_OPEN,r),r})},[]),qe=a.useCallback(()=>{J(!1),ae(k.GIT_PANEL_OPEN,!1)},[]),ft=a.useCallback(()=>{Ue(!1),ae(k.BUILDINGS_PANEL_OPEN,!1)},[]),De=Sn();a.useEffect(()=>{if(!$)return;Ae.some(r=>r.id===$)||X(null)},[$,Ae]);const[_e,de]=a.useState(!1),Oe=a.useRef(null);if(a.useEffect(()=>{if(!_e)return;const l=r=>{Oe.current&&!Oe.current.contains(r.target)&&de(!1)};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[_e]),!g)return e.jsx("div",{className:"flat-chat flat-chat--empty",children:e.jsxs("div",{className:"flat-chat__placeholder",children:[e.jsx("span",{className:"flat-chat__placeholder-icon",children:"💬"}),e.jsx("span",{className:"flat-chat__placeholder-text",children:"Select an agent to start chatting"})]})});const Q=g.contextStats,Ke=!!Q,Ye=Q?Q.totalTokens:g.contextUsed||0,we=Q?Q.contextWindow:g.contextLimit||2e5,x=Q?Q.usedPercent:Math.round(Ye/we*100),O=Math.max(0,Math.min(100,x)),q=Math.max(0,100-O),Ce=O>=80?"#ff4a4a":O>=60?"#ff9e4a":O>=40?"#ffd700":"#4aff9e",$e=(Ye/1e3).toFixed(1),Ze=(we/1e3).toFixed(1),ee=g.cwd,Je=ee?Vn(ee):null,Ee=((Me=g.subordinateIds)==null?void 0:Me.length)||0,Be=Ee>0;return e.jsxs("div",{ref:Ie,className:`flat-terminal-wrapper ${B||ge||ce?"flat-terminal-wrapper--with-side-panel":""}`,children:[e.jsxs("div",{className:"flat-terminal-wrapper__header",children:[e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__header-main ${ye?"flat-terminal-wrapper__header-main--active":""}`,onClick:Z,title:ye?"Hide agent info":"Show agent info","aria-pressed":ye,children:[e.jsx(Ft,{agent:g,size:28}),e.jsxs("span",{className:"flat-terminal-wrapper__header-info",children:[e.jsx("span",{className:"flat-terminal-wrapper__header-name",children:g.name}),e.jsx("span",{className:"flat-terminal-wrapper__header-status",style:{color:Wt(g.status)},children:g.status})]}),g.taskLabel&&e.jsxs("span",{className:"flat-terminal-wrapper__header-task",title:g.taskLabel,children:["📋 ",g.taskLabel]}),e.jsxs("span",{className:"flat-terminal-wrapper__header-model",children:[e.jsx("img",{src:g.provider==="codex"?"/assets/codex.png":g.provider==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:g.provider,className:"flat-terminal-wrapper__header-provider-icon",title:g.provider==="codex"?"Codex Agent":g.provider==="opencode"?"OpenCode Agent":"Claude Agent"}),(()=>{const{model:l,effort:r}=Gn(g);return e.jsxs("span",{className:"flat-terminal-wrapper__header-model-chip",title:r?`Model: ${l} · Effort: ${r}`:`Model: ${l}`,children:[e.jsx("span",{className:"flat-terminal-wrapper__header-model-name",children:l}),r&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flat-terminal-wrapper__header-model-sep","aria-hidden":"true",children:"·"}),e.jsx("span",{className:"flat-terminal-wrapper__header-model-effort",children:r})]})]})})()]})]}),e.jsxs("div",{className:"flat-terminal-wrapper__header-meta",children:[e.jsx("div",{className:"flat-terminal-wrapper__view-mode",role:"group","aria-label":"Message view mode",children:Bn.map(l=>e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__view-mode-btn ${I===l?"flat-terminal-wrapper__view-mode-btn--active":""}`,onClick:()=>A(l),title:Hn[l],"aria-pressed":I===l,children:[e.jsx("span",{className:"flat-terminal-wrapper__view-mode-icon","aria-hidden":"true",children:Wn[l]}),e.jsx("span",{className:"flat-terminal-wrapper__view-mode-label",children:Fn[l]})]},l))}),e.jsxs("div",{className:"flat-terminal-wrapper__actions",role:"group","aria-label":"Terminal actions",children:[e.jsx("button",{type:"button",className:"flat-terminal-wrapper__action-btn",onClick:le,disabled:!He,title:"Back to previous agent","aria-label":"Back to previous agent",children:e.jsx(u,{name:"arrow-left",size:14})}),e.jsx("button",{type:"button",className:"flat-terminal-wrapper__action-btn",onClick:D,disabled:!Le,title:"Forward to next agent","aria-label":"Forward to next agent",children:e.jsx(u,{name:"arrow-right",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${H?"flat-terminal-wrapper__action-btn--active":""}`,onClick:dt,title:H?"Close search":"Search messages","aria-pressed":H,children:e.jsx(u,{name:H?"cross":"search",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn flat-terminal-wrapper__action-btn--danger ${oe?"flat-terminal-wrapper__action-btn--confirm":""}`,onClick:()=>Xe.handleClick(Dt,()=>{var l;h.clearContext(c),(l=me.current)==null||l.historyLoader.clearHistory()}),title:oe?"Click again to confirm clear context":"Clear context",children:e.jsx(u,{name:oe?"question":"clear",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${B?"flat-terminal-wrapper__action-btn--active":""}`,onClick:be,title:B?"Hide git panel":"Show git changes","aria-pressed":B,children:e.jsx(u,{name:"git-branch",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${ge?"flat-terminal-wrapper__action-btn--active":""}`,onClick:mt,title:ge?"Hide buildings panel":"Show area buildings","aria-pressed":ge,children:e.jsx(u,{name:"buildings",size:14})}),e.jsxs("div",{className:"flat-terminal-wrapper__more",ref:Oe,children:[e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${_e?"flat-terminal-wrapper__action-btn--active":""}`,onClick:()=>de(l=>!l),title:"More actions","aria-expanded":_e,children:"⋮"}),_e&&e.jsxs("div",{className:"flat-terminal-wrapper__more-menu",role:"menu",children:[e.jsxs("button",{type:"button",role:"menuitem",className:`flat-terminal-wrapper__more-item ${ce?"flat-terminal-wrapper__more-item--active":""}`,onClick:()=>{ut(),de(!1)},title:ce?"Hide Debug Panel":"Show Debug Panel",children:[e.jsx(u,{name:"bug",size:14}),e.jsx("span",{children:ce?"Hide Debug Panel":"Show Debug Panel"})]}),e.jsx("div",{className:"flat-terminal-wrapper__more-divider"}),e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item",onClick:()=>{h.collapseContext(c),de(!1)},disabled:g.status!=="idle",title:g.status!=="idle"?"Agent must be idle to collapse context":"Collapse context",children:[e.jsx(u,{name:"package",size:14}),e.jsx("span",{children:"Collapse context"})]}),Be&&e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item flat-terminal-wrapper__more-item--danger",onClick:()=>{Y(c,Ee),de(!1)},children:[e.jsx(u,{name:"crown",size:14}),e.jsxs("span",{children:["Clear ",Ee," subordinate",Ee===1?"":"s"]})]}),e.jsx("div",{className:"flat-terminal-wrapper__more-divider"}),e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item flat-terminal-wrapper__more-item--danger",onClick:()=>{h.killAgent(c),de(!1)},children:[e.jsx(u,{name:"cross",size:14}),e.jsx("span",{children:"Remove agent"})]})]})]})]}),e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__inspector-toggle ${T?"flat-terminal-wrapper__inspector-toggle--active":""}`,onClick:K,title:T?"Hide inspector panel":"Show inspector panel","aria-label":T?"Hide inspector panel":"Show inspector panel","aria-pressed":T,children:[e.jsx("span",{className:"flat-terminal-wrapper__inspector-icon","aria-hidden":"true",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"}),e.jsx("line",{x1:"10",y1:"2.5",x2:"10",y2:"13.5"})]})}),e.jsx("span",{className:"flat-terminal-wrapper__inspector-label",children:"Inspector"})]}),e.jsx("button",{type:"button",className:"flat-terminal-wrapper__close",onClick:()=>h.deselectAll(),title:"Close chat","aria-label":"Close chat",children:e.jsx(u,{name:"cross",size:14})})]})]}),e.jsx(En,{ref:me,agentId:c,agent:g,viewMode:I,isOpen:!0,onImageClick:W,onFileClick:se,onBashClick:M,onViewMarkdown:C,keyboard:We,hasModalOpen:!1}),V&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"guake-bottom-terminal-resize",onMouseDown:Se,role:"separator","aria-orientation":"horizontal","aria-label":"Resize embedded terminal"}),e.jsxs("div",{className:"flat-bottom-panel",role:"region","aria-label":`Embedded terminal: ${V.name}`,style:{height:U},children:[e.jsxs("div",{className:"flat-bottom-panel__header",children:[e.jsxs("span",{className:"flat-bottom-panel__title",children:[e.jsx(u,{name:"terminal",size:12}),e.jsx("span",{children:V.name}),!((te=V.terminalStatus)!=null&&te.url)&&e.jsx("span",{className:"flat-bottom-panel__muted",children:"(starting...)"})]}),e.jsx("button",{type:"button",className:"flat-bottom-panel__close",onClick:()=>X(null),title:"Close embedded terminal","aria-label":"Close embedded terminal",children:e.jsx(u,{name:"cross",size:12})})]}),e.jsx("div",{className:"flat-bottom-panel__body",children:(Qe=V.terminalStatus)!=null&&Qe.url?e.jsx(Mn,{terminalUrl:V.terminalStatus.url,visible:!0}):e.jsx("div",{className:"flat-bottom-panel__placeholder",children:"Starting terminal..."})})]})]}),e.jsxs("div",{className:"flat-terminal-wrapper__statusbar",role:"contentinfo",children:[g.isDetached&&e.jsxs("span",{className:"flat-terminal-wrapper__detached",title:"Reattaching session...",children:[e.jsx(u,{name:"refresh",size:12}),e.jsx("span",{children:"Reattaching"})]}),ee&&Je&&e.jsxs("span",{className:"flat-terminal-wrapper__cwd",title:`Open in file explorer: ${ee}`,"aria-label":`Open ${ee} in file explorer`,role:"button",tabIndex:0,onClick:()=>h.openFileExplorer(ee),onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),h.openFileExplorer(ee))},children:[e.jsx("span",{className:"flat-terminal-wrapper__cwd-icon",children:e.jsx(u,{name:"folder",size:12})}),e.jsx("span",{className:"flat-terminal-wrapper__cwd-text",children:Je})]}),Re&&Re.map(({areaId:l,areaName:r,dir:d})=>{const o=Ve.get(d),pe=ze.has(d),ve=d.split("/").filter(Boolean).pop()||d;return e.jsxs("span",{className:"flat-terminal-wrapper__area-dir",title:`${r}: ${d}${o?` (${o.branch}${o.ahead?` ↑${o.ahead}`:""}${o.behind?` ↓${o.behind}`:""})`:""}`,onClick:()=>h.openFileExplorerForAreaFolder(l,d),children:[e.jsx(u,{name:"folder-open",size:12}),e.jsx("span",{className:"flat-terminal-wrapper__area-dir-name",children:ve}),o&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flat-terminal-wrapper__area-dir-branch",children:[e.jsx(u,{name:"git-branch",size:10})," ",o.branch]}),o.ahead>0&&e.jsxs("span",{className:"flat-terminal-wrapper__branch-ahead",title:`${o.ahead} ahead`,children:[e.jsx(u,{name:"arrow-up",size:9}),o.ahead]}),o.behind>0&&e.jsxs("span",{className:"flat-terminal-wrapper__branch-behind",title:`${o.behind} behind`,children:[e.jsx(u,{name:"arrow-down",size:9}),o.behind]}),e.jsx("span",{className:`flat-terminal-wrapper__area-fetch ${pe?"flat-terminal-wrapper__area-fetch--fetching":""}`,title:"Git fetch",onClick:Te=>{Te.stopPropagation(),Ge(d)},children:e.jsx(u,{name:pe?"hourglass":"download",size:12})})]})]},`${l}:${d}`)}),e.jsxs("span",{className:"flat-terminal-wrapper__context",onClick:()=>h.setContextModalAgentId(c),title:Ke?`Context usage: ${$e}k / ${Ze}k tokens (${O}% used). Click to view stats.`:"Click to fetch context stats",children:[e.jsx("span",{className:"flat-terminal-wrapper__context-icon",children:e.jsx(u,{name:"dashboard",size:12})}),e.jsx("span",{className:"flat-terminal-wrapper__context-label",children:"Ctx:"}),e.jsx("span",{className:"flat-terminal-wrapper__context-bar",children:e.jsx("span",{className:"flat-terminal-wrapper__context-bar-fill",style:{width:`${O}%`,backgroundColor:Ce}})}),e.jsxs("span",{className:"flat-terminal-wrapper__context-tokens",style:{color:Ce},children:[$e,"k/",Ze,"k"]}),e.jsxs("span",{className:"flat-terminal-wrapper__context-free",children:["(",q,"% free)"]}),!Ke&&e.jsx("span",{className:"flat-terminal-wrapper__context-warning",title:"No context stats yet",children:e.jsx(u,{name:"warn",size:12})})]}),e.jsx("div",{className:"flat-terminal-wrapper__statusbar-spacer","aria-hidden":"true"}),Ae.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area terminals",children:Ae.map(l=>{const r=$===l.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${r?"flat-terminal-wrapper__building-btn--active":""} ${l.hasUrl?"":"flat-terminal-wrapper__building-btn--offline"}`,title:`${r?"Hide":"Show"} terminal: ${l.name}${l.hasUrl?"":" (starting...)"}`,onClick:()=>{if(r){X(null);return}l.hasUrl||h.sendBuildingCommand(l.id,"start"),X(l.id)},children:e.jsx(u,{name:"terminal",size:14})},l.id)})}),he.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area PM2 logs",children:he.map(l=>e.jsx("button",{type:"button",className:"flat-terminal-wrapper__building-btn",title:`Open logs: ${l.name}`,onClick:()=>Pe(l.id),children:e.jsx(u,{name:"scroll",size:14})},l.id))}),ie.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area databases",children:ie.map(l=>e.jsx("button",{type:"button",className:"flat-terminal-wrapper__building-btn",title:`Open database: ${l.name}`,onClick:()=>Pe(l.id),children:e.jsx(u,{name:"hard-drives",size:14})},l.id))}),e.jsx("div",{className:"flat-terminal-wrapper__theme",children:e.jsx(Tn,{})})]}),B&&e.jsx(Pn,{agentId:c,agents:De,onClose:qe,branchInfoMap:Ve,fetchRemote:Ge,fetchingDirs:ze}),ge&&e.jsx(Ln,{agentId:c,onClose:ft}),ce&&e.jsx(Rn,{agentId:c,onClose:pt})]})});function Zn({onAgentClick:_,onBuildingClick:c,onBuildingDoubleClick:I,onBuildingPopup:A,onOpenSpawnModal:T,onOpenBossSpawnModal:K,onOpenAreaModal:W}){const{t:se}=Ot(["common"]),M=sn(),C=ln(),[Y,Pe]=a.useState(null),[We,He]=a.useState(null),[Le,le]=a.useState(null),[D,ye]=a.useState(null),[Z,g]=a.useState(null),[P,me]=a.useState(null),[Ie,fe]=a.useState(!1),Re=a.useCallback(()=>{fe(t=>!t)},[]),Ve=a.useCallback(()=>{fe(!1)},[]),[Ge,ze]=a.useState(()=>{const t=St(k.VIEW_MODE);return t==="simple"||t==="chat"||t==="advanced"?t:"simple"}),Ae=a.useCallback(t=>{ze(t),Et(k.VIEW_MODE,t)},[]);a.useEffect(()=>{const t=n=>{if(n.key!==k.VIEW_MODE)return;const s=n.newValue;(s==="simple"||s==="chat"||s==="advanced")&&ze(s)};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)},[]);const[he,ie]=a.useState(()=>vt(k.FLAT_INSPECTOR_OPEN,!1)),[re,H]=a.useState(!1),dt=a.useCallback(()=>H(t=>!t),[]),Xe=a.useCallback(()=>H(!1),[]);a.useEffect(()=>{window.dispatchEvent(new CustomEvent("tide-flat-agents-drawer-state",{detail:{open:re}}))},[re]),a.useEffect(()=>{window.dispatchEvent(new CustomEvent("tide-flat-inspector-state",{detail:{open:he}}))},[he]),a.useEffect(()=>{const t=()=>H(b=>!b),n=()=>{ie(b=>{const i=!b;return ae(k.FLAT_INSPECTOR_OPEN,i),i})},s=()=>{H(!1),ie(!1),ae(k.FLAT_INSPECTOR_OPEN,!1)},p=()=>H(!1),m=()=>{ie(!1),ae(k.FLAT_INSPECTOR_OPEN,!1)};return window.addEventListener("tide-toggle-flat-agents-drawer",t),window.addEventListener("tide-toggle-flat-inspector",n),window.addEventListener("tide-close-flat-side-views",s),window.addEventListener("tide-close-flat-agents-drawer-only",p),window.addEventListener("tide-close-flat-inspector-only",m),()=>{window.removeEventListener("tide-toggle-flat-agents-drawer",t),window.removeEventListener("tide-toggle-flat-inspector",n),window.removeEventListener("tide-close-flat-side-views",s),window.removeEventListener("tide-close-flat-agents-drawer-only",p),window.removeEventListener("tide-close-flat-inspector-only",m)}},[]);const oe=a.useRef(null),$=a.useRef(null),[X,V]=a.useState(()=>{const t=Mt(k.FLAT_MIDDLE_WIDTH,0);return t>=ct?t:null}),[U,Se]=a.useState(()=>{const t=Mt(k.FLAT_INSPECTOR_WIDTH,0);return t>=Ct?t:null}),B=a.useCallback(t=>{if(typeof window>"u")return t;const n=U!==null?ot+U:0,s=window.innerWidth-zt-ot-Rt-n;return Math.max(ct,Math.min(Math.max(s,ct),t))},[U]),J=a.useCallback(t=>{var m;if(typeof window>"u")return t;const n=(m=oe.current)==null?void 0:m.querySelector(".flat-middle"),s=(n==null?void 0:n.getBoundingClientRect().width)??ct,p=window.innerWidth-zt-s-ot-Rt-ot;return Math.max(Ct,Math.min(Math.max(p,Ct),t))},[]);a.useEffect(()=>{if(X===null&&U===null)return;const t=()=>{V(n=>{if(n===null)return n;const s=B(n);return s===n?n:s}),Se(n=>{if(n===null)return n;const s=J(n);return s===n?n:s})};return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[X,U,B,J]);const ge=a.useCallback(t=>{var s;if(t.button!==0)return;const n=(s=oe.current)==null?void 0:s.querySelector(".flat-middle");n&&(t.currentTarget.setPointerCapture(t.pointerId),$.current={kind:"middle",startX:t.clientX,startWidth:n.getBoundingClientRect().width,pointerId:t.pointerId},document.body.classList.add("flat-splitter-dragging"))},[]),Ue=a.useCallback(t=>{var s;if(t.button!==0)return;const n=(s=oe.current)==null?void 0:s.querySelector(".flat-inspector");n&&(t.currentTarget.setPointerCapture(t.pointerId),$.current={kind:"inspector",startX:t.clientX,startWidth:n.getBoundingClientRect().width,pointerId:t.pointerId},document.body.classList.add("flat-splitter-dragging"))},[]),ce=a.useCallback(t=>{const n=$.current;if(!n||t.pointerId!==n.pointerId)return;const s=t.clientX-n.startX;n.kind==="middle"?V(B(n.startWidth+s)):Se(J(n.startWidth-s))},[B,J]),xe=a.useCallback(t=>{const n=$.current;if(!n||t.pointerId!==n.pointerId)return;try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}if($.current=null,document.body.classList.remove("flat-splitter-dragging"),!(Math.abs(t.clientX-n.startX)>2))return;const p=t.clientX-n.startX;if(n.kind==="middle"){const m=B(n.startWidth+p);V(m),rt(k.FLAT_MIDDLE_WIDTH,m)}else{const m=J(n.startWidth-p);Se(m),rt(k.FLAT_INSPECTOR_WIDTH,m)}},[B,J]),ut=a.useCallback(()=>{V(null),rt(k.FLAT_MIDDLE_WIDTH,0)},[]),pt=a.useCallback(()=>{Se(null),rt(k.FLAT_INSPECTOR_WIDTH,0)},[]),[be,mt]=a.useState(()=>St(k.FLAT_INSPECTOR_VIEW)==="tracking"?"tracking":"agent"),qe=a.useCallback(t=>{mt(t),Et(k.FLAT_INSPECTOR_VIEW,t)},[]),ft=a.useCallback(()=>{ie(t=>{const n=!t;return ae(k.FLAT_INSPECTOR_OPEN,n),n})},[]),De=a.useCallback(()=>{ie(!1),ae(k.FLAT_INSPECTOR_OPEN,!1)},[]),_e=rn(),de=a.useCallback((t,n)=>{Pe({url:t,name:n})},[]),Oe=a.useCallback((t,n)=>{He({command:t,output:n,isLive:!1})},[]),Q=a.useCallback((t,n)=>{h.setFileViewerPath(t,n)},[]),Ke=a.useCallback(t=>{},[]),Ye=a.useCallback((t,n)=>{le({agentId:t,count:n})},[]),we=a.useCallback(t=>{I?I(t):c(t)},[c,I]),x=a.useMemo(()=>C.size>0?Array.from(C)[0]:null,[C]);a.useEffect(()=>{fe(!1)},[x]);const O=a.useRef([]),q=a.useRef(-1),Ce=a.useRef(!1),$e=a.useRef(null),[Ze,ee]=a.useState(!1),[Je,Ee]=a.useState(!1),Be=a.useRef(!1),ue=a.useRef(null),Me=a.useRef(!1),te=a.useMemo(()=>new Set(M.map(t=>t.id)),[M]),Qe=a.useMemo(()=>{const t=new Map(M.map(s=>[s.id,s])),n=new Map;for(const s of M)if((s.isBoss||s.class==="boss")&&s.subordinateIds&&s.subordinateIds.length>0){const p=s.subordinateIds.map(m=>t.get(m)).filter(m=>m!==void 0);p.length>0&&n.set(s.id,p)}return n},[M]),l=a.useCallback(()=>{const t=O.current,n=q.current;ee(n>0),Ee(n>=0&&n<t.length-1)},[]),r=a.useCallback(t=>{const n=O.current;if(n.length===0)return;let s=q.current+t;for(;s>=0&&s<n.length;){const p=n[s];if(te.has(p)){Ce.current=!0,q.current=s,l(),h.selectAgent(p);return}s+=t}},[te,l]),d=a.useCallback(()=>r(-1),[r]),o=a.useCallback(()=>r(1),[r]),pe=a.useCallback((t,n)=>{if(typeof window>"u")return;const s=window.history.state,m={...typeof s=="object"&&s!==null?s:{},__flatAgentNav:{agentId:t}};n==="replace"?window.history.replaceState(m,"",window.location.href):window.history.pushState(m,"",window.location.href)},[]);a.useEffect(()=>{if(!x){Be.current=!1,ue.current=null;return}if(!Be.current){pe(x,"replace"),Be.current=!0,ue.current=x;return}if(Me.current){Me.current=!1,ue.current=x;return}ue.current!==x&&(pe(x,"push"),ue.current=x)},[x,pe]),a.useEffect(()=>{const t=n=>{var b,i;const s=(i=(b=n.state)==null?void 0:b.__flatAgentNav)==null?void 0:i.agentId;if(!s||typeof s!="string"||!te.has(s)||s===x)return;Me.current=!0,Ce.current=!0;const p=O.current,m=p.lastIndexOf(s);m>=0?q.current=m:(p.push(s),q.current=p.length-1),l(),h.selectAgent(s)};return window.addEventListener("popstate",t),()=>window.removeEventListener("popstate",t)},[te,x,l]),a.useEffect(()=>{if(!x){O.current=[],q.current=-1,l();return}if($e.current=x,Ce.current){Ce.current=!1,l();return}const t=O.current,n=q.current;if(n>=0&&t[n]===x){l();return}const s=n<t.length-1?t.slice(0,n+1):t.slice();s.push(x),s.length>100&&s.shift(),O.current=s,q.current=s.length-1,l()},[x,l]);const ve=a.useCallback(t=>{_(t),H(!1)},[_]),Te=x??"",ht=a.useCallback(()=>{},[]),gt=a.useCallback(t=>{ve(t)},[ve]),G=he,[L,S]=a.useState(G),[et,jt]=a.useState(G);a.useEffect(()=>{if(G){S(!0);return}jt(!1);const t=setTimeout(()=>S(!1),240);return()=>clearTimeout(t)},[G]),a.useEffect(()=>{if(!L||!G)return;let t=0;const n=requestAnimationFrame(()=>{t=requestAnimationFrame(()=>jt(!0))});return()=>{cancelAnimationFrame(n),cancelAnimationFrame(t)}},[L,G]);const Nt=a.useRef(null);a.useEffect(()=>{if(x)return;const t=n=>{if(n.key!==" "&&n.key!=="Backspace")return;const s=n.target;if(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable)return;const p=$e.current;!p||!te.has(p)||(n.preventDefault(),h.selectAgent(p))};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[x,te]);const[Ht,kt]=a.useState(new Set),Vt=a.useCallback(t=>{kt(n=>{const s=new Set(n);return s.has(t)?s.delete(t):s.add(t),s})},[]),[je,Gt]=a.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 768px)").matches);a.useEffect(()=>{if(typeof window>"u")return;const t=window.matchMedia("(max-width: 768px)"),n=s=>Gt(s.matches);return t.addEventListener("change",n),()=>t.removeEventListener("change",n)},[]);const[tt,Xt]=a.useState(null),Ut=a.useCallback(t=>{Xt(n=>n===t?null:t)},[]),xt=$t(),nt=Bt(),[qt]=on(),Ne=a.useMemo(()=>{const t=new Map,n=[];for(const f of M){const N=h.getAreaForAgent(f.id);if(!Tt((N==null?void 0:N.id)??null))continue;if(!N||N.archived){n.push(f);continue}const v=t.get(N.id);v?v.push(f):t.set(N.id,[f])}const s=new Map,p=[];for(const f of nt.values()){let N=!1;for(const v of xt.values())if(!v.archived&&Pt(v.id)&&h.isPositionInArea(f.position,v)){const ne=s.get(v.id);ne?ne.push(f):s.set(v.id,[f]),N=!0;break}!N&&Tt(null)&&p.push(f)}const m=[];for(const[,f]of xt){if(f.archived||!Pt(f.id))continue;const N=t.get(f.id),v=s.get(f.id)??[];(N&&N.length>0||v.length>0)&&m.push({area:f,agents:N??[],buildings:v})}(n.length>0||p.length>0)&&m.push({area:{id:"__unassigned__",name:"Unassigned",color:"#6272a4",center:{x:0,z:0},type:"circle",radius:0,directories:[],archived:!1,assignedAgentIds:[],zIndex:0},agents:n,buildings:p});const b=m.filter(f=>f.area.id!=="__unassigned__"),i=m.filter(f=>f.area.id==="__unassigned__");let y=1,j=1;const F=new Map;if(b.length>1){let f=1/0,N=-1/0,v=1/0,ne=-1/0;for(const R of b)f=Math.min(f,R.area.center.x),N=Math.max(N,R.area.center.x),v=Math.min(v,R.area.center.z),ne=Math.max(ne,R.area.center.z);const st=N-f||1,lt=ne-v||1;if(b.length<=4){y=b.length,j=1;const R=[...b].sort((z,bt)=>z.area.center.x-bt.area.center.x);for(let z=0;z<R.length;z++)F.set(R[z].area.id,{row:1,col:z+1})}else{const R=[...b].sort((w,E)=>w.area.center.x-E.area.center.x),z=[];for(let w=1;w<R.length;w++)z.push(R[w].area.center.x-R[w-1].area.center.x);const bt=z.reduce((w,E)=>w+E,0)/z.length||1;let yt=1;for(const w of z)w>bt*1.3&&yt++;y=Math.max(2,Math.min(yt,b.length));const _t=[...b].sort((w,E)=>w.area.center.z-E.area.center.z),it=[];for(let w=1;w<_t.length;w++)it.push(_t[w].area.center.z-_t[w-1].area.center.z);const Jt=it.reduce((w,E)=>w+E,0)/it.length||1;let It=1;for(const w of it)w>Jt*1.3&&It++;j=Math.max(2,Math.min(It,b.length)),y=Math.max(y,Math.ceil(b.length/j)),j=Math.max(j,Math.ceil(b.length/y));const Qt=st/y,en=lt/j,wt=new Set;for(const w of b){let E=Math.min(y-1,Math.max(0,Math.floor((w.area.center.x-f)/Qt))),ke=Math.min(j-1,Math.max(0,Math.floor((w.area.center.z-v)/en))),Fe=`${ke},${E}`,At=0;const tn=j*y;for(;wt.has(Fe)&&At<tn;)E++,E>=y&&(E=0,ke=(ke+1)%j),Fe=`${ke},${E}`,At++;wt.has(Fe)&&(ke=j,E=0,Fe=`${ke},${E}`,j++),wt.add(Fe),F.set(w.area.id,{row:ke+1,col:E+1})}}}const at=f=>{f.sort((N,v)=>{var st,lt,R,z;const ne=(((st=N.position)==null?void 0:st.z)??0)-(((lt=v.position)==null?void 0:lt.z)??0);return ne!==0?ne:(((R=N.position)==null?void 0:R.x)??0)-(((z=v.position)==null?void 0:z.x)??0)})};for(const f of b)at(f.agents);for(const f of i)at(f.agents);return{groups:[...b,...i],gridCols:y,gridRows:j,positions:F}},[M,xt,nt,qt]),Kt=a.useMemo(()=>{if(!D)return[];const t=M.find(n=>n.id===D.agentId);return t?[{id:"edit-agent",label:"Edit Agent",icon:e.jsx(u,{name:"edit",size:14}),onClick:()=>{window.dispatchEvent(new CustomEvent("tide:open-agent-edit",{detail:{agentId:t.id}}))}},{id:"open-chat",label:"Open Chat",icon:e.jsx(u,{name:"chat",size:14}),onClick:()=>_(t.id)},{id:"delete-agent",label:"Delete Agent",icon:e.jsx(u,{name:"trash",size:14}),danger:!0,onClick:()=>{me({agentId:t.id,name:t.name})}}]:[]},[D,M,_]),Yt=a.useMemo(()=>{var b;if(!Z)return[];const t=nt.get(Z.buildingId);if(!t)return[];const n=[],s=t.type==="server"||t.type==="docker"||t.type==="terminal",p=t.status==="running",m=t.type==="boss";if(n.push({id:"open",label:t.type==="database"?"Open Database":t.type==="folder"?"Open Folder":t.type==="boss"?"View Boss Logs":t.type==="terminal"?"Open Terminal":t.type==="server"&&((b=t.pm2)!=null&&b.enabled)?"View PM2 Logs":"Open",icon:e.jsx(u,{name:t.type==="database"?"database":t.type==="folder"?"folder":t.type==="terminal"?"terminal":"eye",size:14}),onClick:()=>we(t.id)}),s&&(p||n.push({id:"start",label:"Start",icon:e.jsx(u,{name:"play",size:14}),onClick:()=>h.sendBuildingCommand(t.id,"start")}),p&&(n.push({id:"restart",label:"Restart",icon:e.jsx(u,{name:"refresh",size:14}),onClick:()=>h.sendBuildingCommand(t.id,"restart")}),n.push({id:"stop",label:"Stop",icon:e.jsx(u,{name:"stop",size:14}),onClick:()=>h.sendBuildingCommand(t.id,"stop")}))),m&&t.subordinateBuildingIds&&t.subordinateBuildingIds.length>0&&(n.push({id:"start-all",label:"Start All Subordinates",icon:e.jsx(u,{name:"launch",size:14}),onClick:()=>{for(const i of t.subordinateBuildingIds)h.sendBuildingCommand(i,"start")}}),n.push({id:"stop-all",label:"Stop All Subordinates",icon:e.jsx(u,{name:"pause",size:14}),onClick:()=>{for(const i of t.subordinateBuildingIds)h.sendBuildingCommand(i,"stop")}}),n.push({id:"restart-all",label:"Restart All Subordinates",icon:e.jsx(u,{name:"restart",size:14}),onClick:()=>{for(const i of t.subordinateBuildingIds)h.sendBuildingCommand(i,"restart")}})),s&&n.push({id:"health-check",label:"Health Check",icon:e.jsx(u,{name:"health",size:14}),onClick:()=>h.sendBuildingCommand(t.id,"healthCheck")}),n.push({id:"divider-edit",label:"",divider:!0,onClick:()=>{}}),n.push({id:"edit",label:"Edit Building",icon:e.jsx(u,{name:"edit",size:14}),onClick:()=>{window.dispatchEvent(new CustomEvent("tide:building-edit",{detail:{buildingId:t.id}}))}}),n.push({id:"clone",label:"Clone Building",icon:e.jsx(u,{name:"copy",size:14}),onClick:()=>{h.createBuilding({name:`${t.name} (Copy)`,type:t.type,style:t.style,color:t.color,scale:t.scale,position:{x:t.position.x+2,z:t.position.z+2},cwd:t.cwd,folderPath:t.folderPath,commands:t.commands,pm2:t.pm2,docker:t.docker,database:t.database,terminal:t.terminal,urls:t.urls,subordinateBuildingIds:t.subordinateBuildingIds})}}),t.urls&&t.urls.length>0)for(const i of t.urls)n.push({id:`url-${i.label}`,label:i.label,icon:e.jsx(u,{name:"link",size:14}),onClick:()=>window.open(i.url,"_blank","noopener,noreferrer")});return n.push({id:"divider-danger",label:"",divider:!0,onClick:()=>{}}),n.push({id:"delete",label:"Delete Building",icon:e.jsx(u,{name:"trash",size:14}),danger:!0,onClick:()=>h.deleteBuilding(t.id)}),n},[Z,nt,we]),Zt=a.useCallback(t=>{const n=new Set(Ne.groups.map(s=>s.area.id));n.delete(t),kt(n),requestAnimationFrame(()=>{const s=Nt.current;if(!s)return;const p=s.querySelector(`[data-area-id="${t}"]`);if(!p)return;const m=s.getBoundingClientRect(),i=p.getBoundingClientRect().top-m.top+s.scrollTop-8;s.scrollTo({top:Math.max(0,i),behavior:"smooth"})})},[Ne]);return e.jsxs("div",{ref:oe,className:`flat-view ${G?"flat-view--with-inspector":""} ${x?"flat-view--has-chat":""} ${re?"flat-view--mobile-sidebar-open":""}`,style:(()=>{if(X===null&&U===null)return;const t={};return X!==null&&(t["--flat-middle-width"]=`${X}px`),U!==null&&(t["--flat-inspector-width"]=`${U}px`),t})(),children:[re&&e.jsx("div",{className:"flat-mobile-sidebar-backdrop",onClick:Xe,"aria-hidden":"true"}),e.jsxs("div",{className:"flat-middle",children:[e.jsx("div",{className:"flat-middle__header",children:e.jsxs("div",{className:"flat-middle__actions",children:[e.jsx("button",{className:"flat-cta-btn flat-cta-btn--agent",onClick:T,title:"Create new agent",children:"+ Agent"}),e.jsx("button",{className:"flat-cta-btn flat-cta-btn--boss",onClick:K,title:"Create new boss agent",children:"+ Boss"}),e.jsx("button",{className:"flat-cta-btn flat-cta-btn--area",onClick:W,title:"Create new area",children:"+ Area"})]})}),e.jsx("div",{className:"flat-middle__content",children:e.jsx(cn,{activeAgentId:Te,onClose:ht,onSelectAgent:gt,collapsedAreas:Ht,onToggleArea:Vt,agentListRef:Nt})})]}),e.jsx("div",{className:"flat-splitter flat-splitter--middle",role:"separator","aria-orientation":"vertical","aria-label":"Resize agents panel",title:"Drag to resize · Double-click to reset",onPointerDown:ge,onPointerMove:ce,onPointerUp:xe,onPointerCancel:xe,onDoubleClick:ut}),e.jsxs("div",{className:"flat-right",children:[e.jsxs("button",{type:"button",className:"flat-mobile-sidebar-toggle","aria-label":re?"Close agents sidebar":"Open agents sidebar","aria-expanded":re,onClick:dt,children:[e.jsx(u,{name:"list",size:18}),e.jsx("span",{className:"flat-mobile-sidebar-toggle__label",children:"Agents"})]}),x?e.jsx(Un,{agentId:x,terminalViewMode:Ge,onTerminalViewModeChange:Ae,inspectorOpen:he,onToggleInspector:ft,onImageClick:de,onFileClick:Q,onBashClick:Oe,onViewMarkdown:Ke,onRequestClearSubordinates:Ye,onOpenBuilding:we,keyboard:_e,canNavigateBack:Ze,canNavigateForward:Je,onNavigateBack:d,onNavigateForward:o,agentInfoOpen:Ie,onToggleAgentInfo:Re}):e.jsx("div",{className:"flat-chat flat-chat--empty",children:e.jsxs("div",{className:"flat-map",children:[e.jsxs("div",{className:"flat-map__header",children:[e.jsx("span",{className:"flat-map__title",children:"🗺️ Areas"}),e.jsx("span",{className:"flat-map__hint",children:"Click an area to focus it, or an agent to chat"}),e.jsx($n,{className:"flat-map__view-mode"})]}),e.jsx("div",{className:"flat-map__grid",style:{gridTemplateColumns:`repeat(${Ne.gridCols}, 1fr)`},children:Ne.groups.length===0?e.jsx("div",{className:"flat-map__empty",children:e.jsx("span",{children:"No areas or agents yet"})}):(()=>{var n;const t=je&&tt?((n=Ne.positions.get(tt))==null?void 0:n.row)??null:null;return Ne.groups.map(s=>{const p=s.area.id,m=Ne.positions.get(p),b=je&&tt!==p;return je&&t!=null&&(m==null?void 0:m.row)===t&&p!==tt?null:e.jsxs("div",{className:`flat-map-area-card${b?" flat-map-area-card--collapsed":""}`,style:{"--area-color":s.area.color,gridRow:m==null?void 0:m.row,gridColumn:m==null?void 0:m.col},children:[e.jsxs("button",{type:"button",className:"flat-map-area-card__header",onClick:()=>je?Ut(p):Zt(p),title:je?b?`Expand ${s.area.name}`:`Collapse ${s.area.name}`:`Focus ${s.area.name} in left panel`,"aria-expanded":je?!b:void 0,children:[e.jsx("span",{className:"flat-map-area-card__color",style:{background:s.area.color}}),e.jsx("span",{className:"flat-map-area-card__name",children:s.area.name}),e.jsx("span",{className:"flat-map-area-card__count",children:s.agents.length}),je&&e.jsx(u,{name:b?"caret-down":"caret-up",size:11,className:"flat-map-area-card__caret"})]}),e.jsx("div",{className:"flat-map-area-card__agents",children:s.agents.map(i=>{const y=i.isBoss||i.class==="boss",j=y?Qe.get(i.id):void 0,F=dn(i),at=F.usedPercent>=80?"#ff4a4a":F.usedPercent>=60?"#ff9e4a":F.usedPercent>=40?"#ffd700":"#4aff9e",f=`Context: ${(F.totalTokens/1e3).toFixed(1)}k / ${(F.contextWindow/1e3).toFixed(1)}k (${F.usedPercent}% used, ${F.freePercent}% free)`,N=i.latestTodos&&i.latestTodos.length>0||j&&j.length>0;return e.jsx(un,{todos:i.latestTodos,subordinates:j,position:"top",children:e.jsxs("button",{type:"button",className:`flat-map-agent-chip ${i.status}`,onClick:()=>_(i.id),onContextMenu:v=>{v.preventDefault(),v.stopPropagation(),ye({agentId:i.id,position:{x:v.clientX,y:v.clientY}})},title:N?void 0:`${y?"Boss · ":""}Open chat with ${i.name}
|
|
2
|
-
${f}`,children:[e.jsx(Ft,{agent:i,size:16}),y&&e.jsx("span",{className:"flat-map-agent-chip__crown","aria-hidden":"true",children:e.jsx(u,{name:"crown",size:11,color:"#ffd700",weight:"fill"})}),e.jsx("span",{className:"flat-map-agent-chip__name",children:i.name}),e.jsx("img",{src:i.provider==="codex"?"/assets/codex.png":i.provider==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:i.provider,className:"flat-map-agent-chip__provider-icon",title:i.provider==="codex"?"Codex Agent":i.provider==="opencode"?"OpenCode Agent":"Claude Agent"}),e.jsx("span",{className:"flat-map-agent-chip__dot",style:{backgroundColor:Wt(i.status)}}),i.latestTodos&&i.latestTodos.length>0&&e.jsx(pn,{todos:i.latestTodos,maxDots:6}),y&&j&&j.length>0&&e.jsx(mn,{subordinates:j,maxDots:6}),e.jsx("span",{className:"flat-map-agent-chip__context-bar","aria-hidden":"true",children:e.jsx("span",{className:"flat-map-agent-chip__context-bar-fill",style:{width:`${F.usedPercent}%`,backgroundColor:at}})})]})},i.id)})}),s.buildings.length>0&&e.jsx("div",{className:"flat-map-area-card__buildings",children:s.buildings.map(i=>e.jsxs("button",{type:"button",className:`flat-map-building-chip flat-map-building-chip--${i.status}`,onClick:y=>{if(A){const j=y.currentTarget.getBoundingClientRect();A(i.id,{x:j.right,y:j.top+j.height/2})}else we(i.id)},onContextMenu:y=>{y.preventDefault(),y.stopPropagation(),g({buildingId:i.id,position:{x:y.clientX,y:y.clientY}})},title:`${i.name} · ${i.type} · ${i.status}`,children:[e.jsx(u,{name:fn(i.type),size:12}),e.jsx("span",{className:"flat-map-building-chip__name",children:i.name}),e.jsx("span",{className:"flat-map-building-chip__dot",style:{backgroundColor:hn(i.status)}})]},i.id))})]},p)})})()})]})})]}),G&&e.jsx("div",{className:"flat-splitter flat-splitter--inspector",role:"separator","aria-orientation":"vertical","aria-label":"Resize inspector panel",title:"Drag to resize · Double-click to reset",onPointerDown:Ue,onPointerMove:ce,onPointerUp:xe,onPointerCancel:xe,onDoubleClick:pt}),L&&e.jsxs("aside",{className:`flat-inspector ${et?"flat-inspector--open":"flat-inspector--closing"}`,"aria-label":"Inspector panel",children:[e.jsxs("div",{className:"flat-inspector__header",children:[e.jsxs("div",{className:"flat-inspector__tabs",role:"tablist","aria-label":"Inspector view",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":be==="agent",className:`flat-inspector__tab ${be==="agent"?"flat-inspector__tab--active":""}`,onClick:()=>qe("agent"),children:"Agent"}),e.jsx("button",{type:"button",role:"tab","aria-selected":be==="tracking",className:`flat-inspector__tab ${be==="tracking"?"flat-inspector__tab--active":""}`,onClick:()=>qe("tracking"),children:"Tracking"})]}),e.jsx("button",{type:"button",className:"flat-inspector__close",onClick:De,title:"Close inspector","aria-label":"Close inspector",children:"✕"})]}),e.jsx("div",{className:"flat-inspector__body",children:be==="tracking"?e.jsx(gn,{activeAgentId:x??"",onSelectAgent:t=>{_(t),De()}}):(()=>{if(!x)return e.jsx("div",{className:"flat-inspector__empty",children:e.jsx("span",{children:"Select an agent to inspect"})});const t=M.find(n=>n.id===x);return t?e.jsx(xn,{agent:t,onFocusAgent:n=>{_(n),De()},onKillAgent:n=>h.killAgent(n)}):e.jsx("div",{className:"flat-inspector__empty",children:e.jsx("span",{children:"Agent not found"})})})()})]}),Y&&e.jsx(bn,{url:Y.url,name:Y.name,onClose:()=>Pe(null)}),We&&e.jsx(_n,{state:We,onClose:()=>He(null)}),Le&&e.jsx(wn,{action:"clear-subordinates",selectedAgentId:Le.agentId,subordinateCount:Le.count,onClose:()=>le(null),onClearHistory:()=>{}}),e.jsx(Cn,{agent:x?M.find(t=>t.id===x)??null:null,isOpen:Ie&&!!x,onClose:Ve}),e.jsx(Lt,{isOpen:D!==null,position:(D==null?void 0:D.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:Kt,onClose:()=>ye(null)}),e.jsx(Lt,{isOpen:Z!==null,position:(Z==null?void 0:Z.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:Yt,onClose:()=>g(null)}),e.jsx(vn,{isOpen:P!==null,title:se("common:confirm.removeAgentTitle"),message:se("common:confirm.removeAgentMessage",{name:(P==null?void 0:P.name)??""}),confirmLabel:se("common:buttons.remove"),cancelLabel:se("common:buttons.cancel"),variant:"danger",onConfirm:()=>{P&&h.removeAgentFromServer(P.agentId)},onClose:()=>me(null)})]})}export{Zn as FlatView};
|