tide-commander 1.77.0 → 1.78.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 (35) hide show
  1. package/dist/assets/{BossLogsModal-DadqfwM-.js → BossLogsModal-BJUaVgOz.js} +1 -1
  2. package/dist/assets/{BossSpawnModal-BfBD2177.js → BossSpawnModal-CLzUp9FQ.js} +1 -1
  3. package/dist/assets/{ControlsModal-C7k19rVV.js → ControlsModal-BK-nIx6P.js} +1 -1
  4. package/dist/assets/{DockerLogsModal-zerJaMSY.js → DockerLogsModal-wW7EV327.js} +1 -1
  5. package/dist/assets/{EmbeddedEditor-C_sbdn9e.js → EmbeddedEditor-B7LC5gF5.js} +1 -1
  6. package/dist/assets/{GmailOAuthSetup-CWUAVZZM.js → GmailOAuthSetup-C_kETU4w.js} +1 -1
  7. package/dist/assets/{GoogleOAuthSetup-E7aWGuMy.js → GoogleOAuthSetup-Dn1hZsMs.js} +1 -1
  8. package/dist/assets/{IframeModal-BNwvP8Po.js → IframeModal-8t96ASFF.js} +1 -1
  9. package/dist/assets/{IntegrationsPanel-CWQ5Uum4.js → IntegrationsPanel-C0TjN-6q.js} +2 -2
  10. package/dist/assets/{LogViewerModal-BCXMLdRH.js → LogViewerModal-J_Wv4RxY.js} +1 -1
  11. package/dist/assets/{MonitoringModal-DK79sc5N.js → MonitoringModal-CUy6EbeR.js} +1 -1
  12. package/dist/assets/{PM2LogsModal-Bh3w4epV.js → PM2LogsModal-CgYX33GL.js} +1 -1
  13. package/dist/assets/{RestoreArchivedAreaModal-B-H5Skrp.js → RestoreArchivedAreaModal-ILOa64df.js} +1 -1
  14. package/dist/assets/{Scene2DCanvas-B9UN5ZKm.js → Scene2DCanvas-B9_c0Cr2.js} +1 -1
  15. package/dist/assets/{SceneManager-FjdQYco5.js → SceneManager-BuMbzzM8.js} +1 -1
  16. package/dist/assets/{SkillsPanel-B9C8MwOF.js → SkillsPanel-Bp0UiQRG.js} +1 -1
  17. package/dist/assets/{SpawnModal-D_LcFbP1.js → SpawnModal-DjzhiAMO.js} +1 -1
  18. package/dist/assets/{SubordinateAssignmentModal-BoanKhXq.js → SubordinateAssignmentModal-CWaAMKp5.js} +1 -1
  19. package/dist/assets/{TriggerManagerPanel-Ck-tzKLv.js → TriggerManagerPanel-DpCFDRa5.js} +1 -1
  20. package/dist/assets/{WorkflowEditorPanel-Bwvw_Vgj.js → WorkflowEditorPanel-D-Vcfxmm.js} +1 -1
  21. package/dist/assets/{index-B5v0FpYR.js → index-1yqGGDiA.js} +1 -1
  22. package/dist/assets/{index-Baz89OXb.js → index-7TaAASV1.js} +2 -2
  23. package/dist/assets/{index-DvKJEzc1.js → index-BRLyVoUe.js} +1 -1
  24. package/dist/assets/{index-8lOgiTZV.js → index-BeUHeagl.js} +1 -1
  25. package/dist/assets/{index-BJJScfkg.js → index-COln_-Fk.js} +1 -1
  26. package/dist/assets/index-D6--gGWa.js +2 -0
  27. package/dist/assets/{index-BKq2RkPI.js → index-DX-7fZ78.js} +3 -3
  28. package/dist/assets/{index-BAwissdJ.js → index-DyidqysN.js} +1 -1
  29. package/dist/assets/{index-7isjCekP.js → index-rGRqmeiB.js} +1 -1
  30. package/dist/assets/{main-CiaEK7il.js → main-COvyQg-T.js} +4 -4
  31. package/dist/assets/{web-C1fk4YYO.js → web-CpCf-DCG.js} +1 -1
  32. package/dist/assets/{web-BdPxI-ix.js → web-N_FykYu_.js} +1 -1
  33. package/dist/index.html +1 -1
  34. package/package.json +1 -1
  35. package/dist/assets/index-DMa3VOph.js +0 -2
@@ -1 +1 @@
1
- import{c5 as s}from"./main-CiaEK7il.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
+ import{c5 as s}from"./main-COvyQg-T.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{c5 as a}from"./main-CiaEK7il.js";import{ImpactStyle as i,NotificationType as r}from"./index-Baz89OXb.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};
1
+ import{c5 as a}from"./main-COvyQg-T.js";import{ImpactStyle as i,NotificationType as r}from"./index-7TaAASV1.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,7 +22,7 @@
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-CiaEK7il.js"></script>
25
+ <script type="module" crossorigin src="/assets/main-COvyQg-T.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
28
  <link rel="stylesheet" crossorigin href="/assets/main-Co2mNETL.css">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tide-commander",
3
- "version": "1.77.0",
3
+ "version": "1.78.0",
4
4
  "description": "Visual multi-agent orchestrator and manager for Claude Code with 3D/2D interface",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,2 +0,0 @@
1
- import{u as Dt,z as Lt,B as zt,r as n,E as xt,S as j,G as _t,H as dt,J as bt,K as Xe,L as he,M as $t,s as C,N as vt,O as Ot,v as Ft,w as Bt,j as e,I as m,P as Wt,m as Ht,U as Gt,V as Nt,W as kt,X as Vt,Y as Ut,Z as Xt,_ as qt,$ as Kt,a0 as Yt,a1 as Zt,a2 as Jt,a3 as Qt,C as ea,a4 as ta,a5 as aa,a6 as na,a7 as sa,a8 as ra,a9 as la,aa as ia,ab as oa,ac as ca,ad as da,ae as ua,af as pa,ag as ma,ah as fa,ai as ha,aj as ga,ak as xa}from"./main-CiaEK7il.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const qe=3,Ke=280,wt=320,ct=240,Ct=64,_a=["simple","chat","advanced"],ba={simple:"Simple",chat:"Chat",advanced:"Advanced"},wa={simple:"○",chat:"◐",advanced:"◉"},Ca={simple:"Simple view — clean messages only",chat:"Chat view — assistant replies (no tool calls)",advanced:"Advanced view — everything including tools"},jt="flat-clear-context";function ja(x){const c=x.split("/").filter(Boolean);return c.length===0?x:c.slice(-2).join("/")}function va(x){if(x.provider==="codex"){const ie=x.codexModel||"gpt-5.3-codex",L=ha[ie];return{model:(L==null?void 0:L.label)||ie}}if(x.provider==="opencode")return{model:x.opencodeModel||"opencode"};const c=x.model||"sonnet",v=xa[c],y=x.effort,D=y?ga[y]:void 0;return{model:(v==null?void 0:v.label)||c,effort:D==null?void 0:D.label}}function Na(x,c){if(c.type==="rectangle"&&c.width&&c.height){const v=c.width/2,y=c.height/2;return x.x>=c.center.x-v&&x.x<=c.center.x+v&&x.z>=c.center.z-y&&x.z<=c.center.z+y}if(c.type==="circle"&&c.radius){const v=x.x-c.center.x,y=x.z-c.center.z;return v*v+y*y<=c.radius*c.radius}return!1}const ka=ta.memo(function({agentId:c,terminalViewMode:v,onTerminalViewModeChange:y,inspectorOpen:D,onToggleInspector:ie,onImageClick:L,onFileClick:S,onBashClick:ge,onViewMarkdown:xe,onRequestClearSubordinates:Se,onOpenBuilding:_e,keyboard:Me,canNavigateBack:be,canNavigateForward:ye,onNavigateBack:T,onNavigateForward:oe,agentInfoOpen:z,onToggleAgentInfo:Ee}){var Fe,E,re,Be;const p=aa(c),P=na(),ce=n.useRef(null),Te=n.useRef(null);n.useEffect(()=>{const r=Te.current;if(!r)return;const i=o=>{o.button===3?(o.preventDefault(),o.stopPropagation(),T()):o.button===4&&(o.preventDefault(),o.stopPropagation(),oe())},d=o=>{(o.button===3||o.button===4)&&o.preventDefault()};return r.addEventListener("mouseup",i),r.addEventListener("mousedown",d),()=>{r.removeEventListener("mouseup",i),r.removeEventListener("mousedown",d)}},[T,oe]);const we=vt(),de=n.useMemo(()=>{if(!p)return null;const r=new Set,i=[];for(const d of we.values())d.archived||d.directories.length===0||d.assignedAgentIds.includes(c)&&(r.add(d.id),i.push(d));for(const d of we.values())d.archived||d.directories.length===0||r.has(d.id)||Na({x:p.position.x,z:p.position.z},d)&&(r.add(d.id),i.push(d));return i.length===0?null:i.flatMap(d=>d.directories.filter(o=>o&&o.trim().length>0).map(o=>({areaId:d.id,areaName:d.name,dir:o})))},[p,c,we]),{branches:Pe,fetchRemote:Ce,fetchingDirs:je}=sa(de),F=n.useMemo(()=>{var d;const r=C.getAreaForAgent(c);if(!r)return[];const i=[];for(const o of P.values())o.type==="terminal"&&C.isPositionInArea(o.position,r)&&i.push({id:o.id,name:o.name,hasUrl:!!((d=o.terminalStatus)!=null&&d.url)});return i},[c,P]),ue=n.useMemo(()=>{var d;const r=C.getAreaForAgent(c);if(!r)return[];const i=[];for(const o of P.values())o.type==="server"&&((d=o.pm2)!=null&&d.enabled)&&C.isPositionInArea(o.position,r)&&i.push({id:o.id,name:o.name});return i},[c,P]),Re=n.useMemo(()=>{const r=C.getAreaForAgent(c);if(!r)return[];const i=[];for(const d of P.values())d.type==="database"&&d.database&&C.isPositionInArea(d.position,r)&&i.push({id:d.id,name:d.name});return i},[c,P]),[,Ye]=n.useReducer(r=>r+1,0),B=((Fe=ce.current)==null?void 0:Fe.search.searchMode)??!1,te=n.useCallback(()=>{var r;(r=ce.current)==null||r.search.toggleSearch(),Ye()},[]),X=ra(),q=X.isPending(jt),[k,W]=n.useState(null),M=k?P.get(k):null,{height:K,onResizeStart:Ze}=la(),[ae,ve]=n.useState(()=>dt(j.GIT_PANEL_OPEN,!1)),[$,De]=n.useState(()=>dt(j.BUILDINGS_PANEL_OPEN,!1)),[ne,Y]=n.useState(!1),Je=n.useCallback(()=>{Y(r=>{const i=!r;return i&&ia.setEnabled(!0),i})},[]),Le=n.useCallback(()=>Y(!1),[]),Qe=n.useCallback(()=>{ve(r=>{const i=!r;return he(j.GIT_PANEL_OPEN,i),i})},[]),et=n.useCallback(()=>{De(r=>{const i=!r;return he(j.BUILDINGS_PANEL_OPEN,i),i})},[]),tt=n.useCallback(()=>{ve(!1),he(j.GIT_PANEL_OPEN,!1)},[]),at=n.useCallback(()=>{De(!1),he(j.BUILDINGS_PANEL_OPEN,!1)},[]),nt=oa();n.useEffect(()=>{if(!k)return;F.some(i=>i.id===k)||W(null)},[k,F]);const[se,Z]=n.useState(!1),Ne=n.useRef(null);if(n.useEffect(()=>{if(!se)return;const r=i=>{Ne.current&&!Ne.current.contains(i.target)&&Z(!1)};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[se]),!p)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 H=p.contextStats,u=!!H,G=H?H.totalTokens:p.contextUsed||0,R=H?H.contextWindow:p.contextLimit||2e5,pe=H?H.usedPercent:Math.round(G/R*100),V=Math.max(0,Math.min(100,pe)),st=Math.max(0,100-V),ze=V>=80?"#ff4a4a":V>=60?"#ff9e4a":V>=40?"#ffd700":"#4aff9e",$e=(G/1e3).toFixed(1),Oe=(R/1e3).toFixed(1),U=p.cwd,J=U?ja(U):null,Q=((E=p.subordinateIds)==null?void 0:E.length)||0,ee=Q>0;return e.jsxs("div",{ref:Te,className:`flat-terminal-wrapper ${ae||$||ne?"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 ${z?"flat-terminal-wrapper__header-main--active":""}`,onClick:Ee,title:z?"Hide agent info":"Show agent info","aria-pressed":z,children:[e.jsx(Nt,{agent:p,size:28}),e.jsxs("span",{className:"flat-terminal-wrapper__header-info",children:[e.jsx("span",{className:"flat-terminal-wrapper__header-name",children:p.name}),e.jsx("span",{className:"flat-terminal-wrapper__header-status",style:{color:kt(p.status)},children:p.status})]}),p.taskLabel&&e.jsxs("span",{className:"flat-terminal-wrapper__header-task",title:p.taskLabel,children:["📋 ",p.taskLabel]}),e.jsxs("span",{className:"flat-terminal-wrapper__header-model",children:[e.jsx("img",{src:p.provider==="codex"?"/assets/codex.png":p.provider==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:p.provider,className:"flat-terminal-wrapper__header-provider-icon",title:p.provider==="codex"?"Codex Agent":p.provider==="opencode"?"OpenCode Agent":"Claude Agent"}),(()=>{const{model:r,effort:i}=va(p);return e.jsxs("span",{className:"flat-terminal-wrapper__header-model-chip",title:i?`Model: ${r} · Effort: ${i}`:`Model: ${r}`,children:[e.jsx("span",{className:"flat-terminal-wrapper__header-model-name",children:r}),i&&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:i})]})]})})()]})]}),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:_a.map(r=>e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__view-mode-btn ${v===r?"flat-terminal-wrapper__view-mode-btn--active":""}`,onClick:()=>y(r),title:Ca[r],"aria-pressed":v===r,children:[e.jsx("span",{className:"flat-terminal-wrapper__view-mode-icon","aria-hidden":"true",children:wa[r]}),e.jsx("span",{className:"flat-terminal-wrapper__view-mode-label",children:ba[r]})]},r))}),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:T,disabled:!be,title:"Back to previous agent","aria-label":"Back to previous agent",children:e.jsx(m,{name:"arrow-left",size:14})}),e.jsx("button",{type:"button",className:"flat-terminal-wrapper__action-btn",onClick:oe,disabled:!ye,title:"Forward to next agent","aria-label":"Forward to next agent",children:e.jsx(m,{name:"arrow-right",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${B?"flat-terminal-wrapper__action-btn--active":""}`,onClick:te,title:B?"Close search":"Search messages","aria-pressed":B,children:e.jsx(m,{name:B?"cross":"search",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn flat-terminal-wrapper__action-btn--danger ${q?"flat-terminal-wrapper__action-btn--confirm":""}`,onClick:()=>X.handleClick(jt,()=>{var r;C.clearContext(c),(r=ce.current)==null||r.historyLoader.clearHistory()}),title:q?"Click again to confirm clear context":"Clear context",children:e.jsx(m,{name:q?"question":"clear",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${ae?"flat-terminal-wrapper__action-btn--active":""}`,onClick:Qe,title:ae?"Hide git panel":"Show git changes","aria-pressed":ae,children:e.jsx(m,{name:"git-branch",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${$?"flat-terminal-wrapper__action-btn--active":""}`,onClick:et,title:$?"Hide buildings panel":"Show area buildings","aria-pressed":$,children:e.jsx(m,{name:"buildings",size:14})}),e.jsxs("div",{className:"flat-terminal-wrapper__more",ref:Ne,children:[e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${se?"flat-terminal-wrapper__action-btn--active":""}`,onClick:()=>Z(r=>!r),title:"More actions","aria-expanded":se,children:"⋮"}),se&&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 ${ne?"flat-terminal-wrapper__more-item--active":""}`,onClick:()=>{Je(),Z(!1)},title:ne?"Hide Debug Panel":"Show Debug Panel",children:[e.jsx(m,{name:"bug",size:14}),e.jsx("span",{children:ne?"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:()=>{C.collapseContext(c),Z(!1)},disabled:p.status!=="idle",title:p.status!=="idle"?"Agent must be idle to collapse context":"Collapse context",children:[e.jsx(m,{name:"package",size:14}),e.jsx("span",{children:"Collapse context"})]}),ee&&e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item flat-terminal-wrapper__more-item--danger",onClick:()=>{Se(c,Q),Z(!1)},children:[e.jsx(m,{name:"crown",size:14}),e.jsxs("span",{children:["Clear ",Q," subordinate",Q===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:()=>{C.killAgent(c),Z(!1)},children:[e.jsx(m,{name:"cross",size:14}),e.jsx("span",{children:"Remove agent"})]})]})]})]}),e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__inspector-toggle ${D?"flat-terminal-wrapper__inspector-toggle--active":""}`,onClick:ie,title:D?"Hide inspector panel":"Show inspector panel","aria-label":D?"Hide inspector panel":"Show inspector panel","aria-pressed":D,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:()=>C.deselectAll(),title:"Close chat","aria-label":"Close chat",children:e.jsx(m,{name:"cross",size:14})})]})]}),e.jsx(ca,{ref:ce,agentId:c,agent:p,viewMode:v,isOpen:!0,onImageClick:L,onFileClick:S,onBashClick:ge,onViewMarkdown:xe,keyboard:Me,hasModalOpen:!1}),M&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"guake-bottom-terminal-resize",onMouseDown:Ze,role:"separator","aria-orientation":"horizontal","aria-label":"Resize embedded terminal"}),e.jsxs("div",{className:"flat-bottom-panel",role:"region","aria-label":`Embedded terminal: ${M.name}`,style:{height:K},children:[e.jsxs("div",{className:"flat-bottom-panel__header",children:[e.jsxs("span",{className:"flat-bottom-panel__title",children:[e.jsx(m,{name:"terminal",size:12}),e.jsx("span",{children:M.name}),!((re=M.terminalStatus)!=null&&re.url)&&e.jsx("span",{className:"flat-bottom-panel__muted",children:"(starting...)"})]}),e.jsx("button",{type:"button",className:"flat-bottom-panel__close",onClick:()=>W(null),title:"Close embedded terminal","aria-label":"Close embedded terminal",children:e.jsx(m,{name:"cross",size:12})})]}),e.jsx("div",{className:"flat-bottom-panel__body",children:(Be=M.terminalStatus)!=null&&Be.url?e.jsx(da,{terminalUrl:M.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:[p.isDetached&&e.jsxs("span",{className:"flat-terminal-wrapper__detached",title:"Reattaching session...",children:[e.jsx(m,{name:"refresh",size:12}),e.jsx("span",{children:"Reattaching"})]}),U&&J&&e.jsxs("span",{className:"flat-terminal-wrapper__cwd",title:U,onClick:()=>C.setFileViewerPath(U),children:[e.jsx("span",{className:"flat-terminal-wrapper__cwd-icon",children:e.jsx(m,{name:"folder",size:12})}),e.jsx("span",{className:"flat-terminal-wrapper__cwd-text",children:J})]}),de&&de.map(({areaId:r,areaName:i,dir:d})=>{const o=Pe.get(d),We=je.has(d),rt=d.split("/").filter(Boolean).pop()||d;return e.jsxs("span",{className:"flat-terminal-wrapper__area-dir",title:`${i}: ${d}${o?` (${o.branch}${o.ahead?` ↑${o.ahead}`:""}${o.behind?` ↓${o.behind}`:""})`:""}`,onClick:()=>C.openFileExplorerForAreaFolder(r,d),children:[e.jsx(m,{name:"folder-open",size:12}),e.jsx("span",{className:"flat-terminal-wrapper__area-dir-name",children:rt}),o&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flat-terminal-wrapper__area-dir-branch",children:[e.jsx(m,{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(m,{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(m,{name:"arrow-down",size:9}),o.behind]}),e.jsx("span",{className:`flat-terminal-wrapper__area-fetch ${We?"flat-terminal-wrapper__area-fetch--fetching":""}`,title:"Git fetch",onClick:ke=>{ke.stopPropagation(),Ce(d)},children:e.jsx(m,{name:We?"hourglass":"download",size:12})})]})]},`${r}:${d}`)}),e.jsxs("span",{className:"flat-terminal-wrapper__context",onClick:()=>C.setContextModalAgentId(c),title:u?`Context usage: ${$e}k / ${Oe}k tokens (${V}% used). Click to view stats.`:"Click to fetch context stats",children:[e.jsx("span",{className:"flat-terminal-wrapper__context-icon",children:e.jsx(m,{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:`${V}%`,backgroundColor:ze}})}),e.jsxs("span",{className:"flat-terminal-wrapper__context-tokens",style:{color:ze},children:[$e,"k/",Oe,"k"]}),e.jsxs("span",{className:"flat-terminal-wrapper__context-free",children:["(",st,"% free)"]}),!u&&e.jsx("span",{className:"flat-terminal-wrapper__context-warning",title:"No context stats yet",children:e.jsx(m,{name:"warn",size:12})})]}),e.jsx("div",{className:"flat-terminal-wrapper__statusbar-spacer","aria-hidden":"true"}),F.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area terminals",children:F.map(r=>{const i=k===r.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${i?"flat-terminal-wrapper__building-btn--active":""} ${r.hasUrl?"":"flat-terminal-wrapper__building-btn--offline"}`,title:`${i?"Hide":"Show"} terminal: ${r.name}${r.hasUrl?"":" (starting...)"}`,onClick:()=>{if(i){W(null);return}r.hasUrl||C.sendBuildingCommand(r.id,"start"),W(r.id)},children:e.jsx(m,{name:"terminal",size:14})},r.id)})}),ue.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area PM2 logs",children:ue.map(r=>e.jsx("button",{type:"button",className:"flat-terminal-wrapper__building-btn",title:`Open logs: ${r.name}`,onClick:()=>_e(r.id),children:e.jsx(m,{name:"scroll",size:14})},r.id))}),Re.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area databases",children:Re.map(r=>e.jsx("button",{type:"button",className:"flat-terminal-wrapper__building-btn",title:`Open database: ${r.name}`,onClick:()=>_e(r.id),children:e.jsx(m,{name:"hard-drives",size:14})},r.id))}),e.jsx("div",{className:"flat-terminal-wrapper__theme",children:e.jsx(ua,{})})]}),ae&&e.jsx(pa,{agentId:c,agents:nt,onClose:tt,branchInfoMap:Pe,fetchRemote:Ce,fetchingDirs:je}),$&&e.jsx(ma,{agentId:c,onClose:at}),ne&&e.jsx(fa,{agentId:c,onClose:Le})]})});function Ma({onAgentClick:x,onBuildingClick:c,onBuildingDoubleClick:v,onOpenSpawnModal:y,onOpenBossSpawnModal:D,onOpenAreaModal:ie}){const{t:L}=Dt(["common"]),S=Lt(),ge=zt(),[xe,Se]=n.useState(null),[_e,Me]=n.useState(null),[be,ye]=n.useState(null),[T,oe]=n.useState(null),[z,Ee]=n.useState(null),[p,P]=n.useState(!1),ce=n.useCallback(()=>{P(t=>!t)},[]),Te=n.useCallback(()=>{P(!1)},[]),[we,de]=n.useState(()=>{const t=xt(j.VIEW_MODE);return t==="simple"||t==="chat"||t==="advanced"?t:"simple"}),Pe=n.useCallback(t=>{de(t),_t(j.VIEW_MODE,t)},[]);n.useEffect(()=>{const t=a=>{if(a.key!==j.VIEW_MODE)return;const s=a.newValue;(s==="simple"||s==="chat"||s==="advanced")&&de(s)};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)},[]);const[Ce,je]=n.useState(()=>dt(j.FLAT_INSPECTOR_OPEN,!1)),[F,ue]=n.useState(!1),Re=n.useCallback(()=>ue(t=>!t),[]),Ye=n.useCallback(()=>ue(!1),[]),B=n.useRef(null),te=n.useRef(null),[X,q]=n.useState(()=>{const t=bt(j.FLAT_MIDDLE_WIDTH,0);return t>=Ke?t:null}),[k,W]=n.useState(()=>{const t=bt(j.FLAT_INSPECTOR_WIDTH,0);return t>=ct?t:null}),M=n.useCallback(t=>{if(typeof window>"u")return t;const a=k!==null?qe+k:0,s=window.innerWidth-Ct-qe-wt-a;return Math.max(Ke,Math.min(Math.max(s,Ke),t))},[k]),K=n.useCallback(t=>{var f;if(typeof window>"u")return t;const a=(f=B.current)==null?void 0:f.querySelector(".flat-middle"),s=(a==null?void 0:a.getBoundingClientRect().width)??Ke,l=window.innerWidth-Ct-s-qe-wt-qe;return Math.max(ct,Math.min(Math.max(l,ct),t))},[]);n.useEffect(()=>{if(X===null&&k===null)return;const t=()=>{q(a=>{if(a===null)return a;const s=M(a);return s===a?a:s}),W(a=>{if(a===null)return a;const s=K(a);return s===a?a:s})};return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[X,k,M,K]);const Ze=n.useCallback(t=>{var s;if(t.button!==0)return;const a=(s=B.current)==null?void 0:s.querySelector(".flat-middle");a&&(t.currentTarget.setPointerCapture(t.pointerId),te.current={kind:"middle",startX:t.clientX,startWidth:a.getBoundingClientRect().width,pointerId:t.pointerId},document.body.classList.add("flat-splitter-dragging"))},[]),ae=n.useCallback(t=>{var s;if(t.button!==0)return;const a=(s=B.current)==null?void 0:s.querySelector(".flat-inspector");a&&(t.currentTarget.setPointerCapture(t.pointerId),te.current={kind:"inspector",startX:t.clientX,startWidth:a.getBoundingClientRect().width,pointerId:t.pointerId},document.body.classList.add("flat-splitter-dragging"))},[]),ve=n.useCallback(t=>{const a=te.current;if(!a||t.pointerId!==a.pointerId)return;const s=t.clientX-a.startX;a.kind==="middle"?q(M(a.startWidth+s)):W(K(a.startWidth-s))},[M,K]),$=n.useCallback(t=>{const a=te.current;if(!a||t.pointerId!==a.pointerId)return;try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}if(te.current=null,document.body.classList.remove("flat-splitter-dragging"),!(Math.abs(t.clientX-a.startX)>2))return;const l=t.clientX-a.startX;if(a.kind==="middle"){const f=M(a.startWidth+l);q(f),Xe(j.FLAT_MIDDLE_WIDTH,f)}else{const f=K(a.startWidth-l);W(f),Xe(j.FLAT_INSPECTOR_WIDTH,f)}},[M,K]),De=n.useCallback(()=>{q(null),Xe(j.FLAT_MIDDLE_WIDTH,0)},[]),ne=n.useCallback(()=>{W(null),Xe(j.FLAT_INSPECTOR_WIDTH,0)},[]),[Y,Je]=n.useState(()=>xt(j.FLAT_INSPECTOR_VIEW)==="tracking"?"tracking":"agent"),Le=n.useCallback(t=>{Je(t),_t(j.FLAT_INSPECTOR_VIEW,t)},[]),Qe=n.useCallback(()=>{je(t=>{const a=!t;return he(j.FLAT_INSPECTOR_OPEN,a),a})},[]),et=n.useCallback(()=>{je(!1),he(j.FLAT_INSPECTOR_OPEN,!1)},[]),tt=$t(),at=n.useCallback((t,a)=>{Se({url:t,name:a})},[]),nt=n.useCallback((t,a)=>{Me({command:t,output:a,isLive:!1})},[]),se=n.useCallback((t,a)=>{C.setFileViewerPath(t,a)},[]),Z=n.useCallback(t=>{},[]),Ne=n.useCallback((t,a)=>{ye({agentId:t,count:a})},[]),H=n.useCallback(t=>{v?v(t):c(t)},[c,v]),u=n.useMemo(()=>ge.size>0?Array.from(ge)[0]:null,[ge]);n.useEffect(()=>{P(!1)},[u]);const G=n.useRef([]),R=n.useRef(-1),pe=n.useRef(!1),V=n.useRef(null),[st,ze]=n.useState(!1),[$e,Oe]=n.useState(!1),U=n.useRef(!1),J=n.useRef(null),Q=n.useRef(!1),ee=n.useMemo(()=>new Set(S.map(t=>t.id)),[S]),Fe=n.useMemo(()=>{const t=new Map(S.map(s=>[s.id,s])),a=new Map;for(const s of S)if((s.isBoss||s.class==="boss")&&s.subordinateIds&&s.subordinateIds.length>0){const l=s.subordinateIds.map(f=>t.get(f)).filter(f=>f!==void 0);l.length>0&&a.set(s.id,l)}return a},[S]),E=n.useCallback(()=>{const t=G.current,a=R.current;ze(a>0),Oe(a>=0&&a<t.length-1)},[]),re=n.useCallback(t=>{const a=G.current;if(a.length===0)return;let s=R.current+t;for(;s>=0&&s<a.length;){const l=a[s];if(ee.has(l)){pe.current=!0,R.current=s,E(),C.selectAgent(l);return}s+=t}},[ee,E]),Be=n.useCallback(()=>re(-1),[re]),r=n.useCallback(()=>re(1),[re]),i=n.useCallback((t,a)=>{if(typeof window>"u")return;const s=window.history.state,f={...typeof s=="object"&&s!==null?s:{},__flatAgentNav:{agentId:t}};a==="replace"?window.history.replaceState(f,"",window.location.href):window.history.pushState(f,"",window.location.href)},[]);n.useEffect(()=>{if(!u){U.current=!1,J.current=null;return}if(!U.current){i(u,"replace"),U.current=!0,J.current=u;return}if(Q.current){Q.current=!1,J.current=u;return}J.current!==u&&(i(u,"push"),J.current=u)},[u,i]),n.useEffect(()=>{const t=a=>{var w,h;const s=(h=(w=a.state)==null?void 0:w.__flatAgentNav)==null?void 0:h.agentId;if(!s||typeof s!="string"||!ee.has(s)||s===u)return;Q.current=!0,pe.current=!0;const l=G.current,f=l.lastIndexOf(s);f>=0?R.current=f:(l.push(s),R.current=l.length-1),E(),C.selectAgent(s)};return window.addEventListener("popstate",t),()=>window.removeEventListener("popstate",t)},[ee,u,E]),n.useEffect(()=>{if(!u){G.current=[],R.current=-1,E();return}if(V.current=u,pe.current){pe.current=!1,E();return}const t=G.current,a=R.current;if(a>=0&&t[a]===u){E();return}const s=a<t.length-1?t.slice(0,a+1):t.slice();s.push(u),s.length>100&&s.shift(),G.current=s,R.current=s.length-1,E()},[u,E]);const d=n.useCallback(t=>{x(t),ue(!1)},[x]),o=u??"",We=n.useCallback(()=>{},[]),rt=n.useCallback(t=>{d(t)},[d]),ke=Ce,ut=n.useRef(null);n.useEffect(()=>{if(u)return;const t=a=>{if(a.key!==" "&&a.key!=="Backspace")return;const s=a.target;if(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable)return;const l=V.current;!l||!ee.has(l)||(a.preventDefault(),C.selectAgent(l))};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[u,ee]);const[At,pt]=n.useState(new Set),It=n.useCallback(t=>{pt(a=>{const s=new Set(a);return s.has(t)?s.delete(t):s.add(t),s})},[]),mt=vt(),[St]=Ot(),me=n.useMemo(()=>{const t=new Map,a=[];for(const g of S){const b=C.getAreaForAgent(g.id);if(!Ft((b==null?void 0:b.id)??null))continue;if(!b||b.archived){a.push(g);continue}const O=t.get(b.id);O?O.push(g):t.set(b.id,[g])}const s=[];for(const[,g]of mt){if(g.archived||!Bt(g.id))continue;const b=t.get(g.id);b&&b.length>0&&s.push({area:g,agents:b})}a.length>0&&s.push({area:{id:"__unassigned__",name:"Unassigned",color:"#6272a4",center:{x:0,z:0},type:"circle",radius:0,directories:[],archived:!1,assignedAgentIds:[],zIndex:0},agents:a});const l=s.filter(g=>g.area.id!=="__unassigned__"),f=s.filter(g=>g.area.id==="__unassigned__");let w=1,h=1;const Ae=new Map;if(l.length>1){let g=1/0,b=-1/0,O=1/0,fe=-1/0;for(const A of l)g=Math.min(g,A.area.center.x),b=Math.max(b,A.area.center.x),O=Math.min(O,A.area.center.z),fe=Math.max(fe,A.area.center.z);const Ge=b-g||1,Ve=fe-O||1;if(l.length<=4){w=l.length,h=1;const A=[...l].sort((I,lt)=>I.area.center.x-lt.area.center.x);for(let I=0;I<A.length;I++)Ae.set(A[I].area.id,{row:1,col:I+1})}else{const A=[...l].sort((_,N)=>_.area.center.x-N.area.center.x),I=[];for(let _=1;_<A.length;_++)I.push(A[_].area.center.x-A[_-1].area.center.x);const lt=I.reduce((_,N)=>_+N,0)/I.length||1;let ft=1;for(const _ of I)_>lt*1.3&&ft++;w=Math.max(2,Math.min(ft,l.length));const it=[...l].sort((_,N)=>_.area.center.z-N.area.center.z),Ue=[];for(let _=1;_<it.length;_++)Ue.push(it[_].area.center.z-it[_-1].area.center.z);const Et=Ue.reduce((_,N)=>_+N,0)/Ue.length||1;let ht=1;for(const _ of Ue)_>Et*1.3&&ht++;h=Math.max(2,Math.min(ht,l.length)),w=Math.max(w,Math.ceil(l.length/h)),h=Math.max(h,Math.ceil(l.length/w));const Tt=Ge/w,Pt=Ve/h,ot=new Set;for(const _ of l){let N=Math.min(w-1,Math.max(0,Math.floor((_.area.center.x-g)/Tt))),le=Math.min(h-1,Math.max(0,Math.floor((_.area.center.z-O)/Pt))),Ie=`${le},${N}`,gt=0;const Rt=h*w;for(;ot.has(Ie)&&gt<Rt;)N++,N>=w&&(N=0,le=(le+1)%h),Ie=`${le},${N}`,gt++;ot.has(Ie)&&(le=h,N=0,Ie=`${le},${N}`,h++),ot.add(Ie),Ae.set(_.area.id,{row:le+1,col:N+1})}}}const He=g=>{g.sort((b,O)=>{var Ge,Ve,A,I;const fe=(((Ge=b.position)==null?void 0:Ge.z)??0)-(((Ve=O.position)==null?void 0:Ve.z)??0);return fe!==0?fe:(((A=b.position)==null?void 0:A.x)??0)-(((I=O.position)==null?void 0:I.x)??0)})};for(const g of l)He(g.agents);for(const g of f)He(g.agents);return{groups:[...l,...f],gridCols:w,gridRows:h,positions:Ae}},[S,mt,St]),Mt=n.useMemo(()=>{if(!T)return[];const t=S.find(a=>a.id===T.agentId);return t?[{id:"edit-agent",label:"Edit Agent",icon:e.jsx(m,{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(m,{name:"chat",size:14}),onClick:()=>x(t.id)},{id:"delete-agent",label:"Delete Agent",icon:e.jsx(m,{name:"trash",size:14}),danger:!0,onClick:()=>{Ee({agentId:t.id,name:t.name})}}]:[]},[T,S,x]),yt=n.useCallback(t=>{const a=new Set(me.groups.map(s=>s.area.id));a.delete(t),pt(a),requestAnimationFrame(()=>{const s=ut.current;if(!s)return;const l=s.querySelector(`[data-area-id="${t}"]`);if(!l)return;const f=s.getBoundingClientRect(),h=l.getBoundingClientRect().top-f.top+s.scrollTop-8;s.scrollTo({top:Math.max(0,h),behavior:"smooth"})})},[me]);return e.jsxs("div",{ref:B,className:`flat-view ${ke?"flat-view--with-inspector":""} ${u?"flat-view--has-chat":""} ${F?"flat-view--mobile-sidebar-open":""}`,style:(()=>{if(X===null&&k===null)return;const t={};return X!==null&&(t["--flat-middle-width"]=`${X}px`),k!==null&&(t["--flat-inspector-width"]=`${k}px`),t})(),children:[F&&e.jsx("div",{className:"flat-mobile-sidebar-backdrop",onClick:Ye,"aria-hidden":"true"}),e.jsxs("div",{className:"flat-middle",children:[e.jsxs("div",{className:"flat-middle__header",children:[e.jsx("h2",{className:"flat-middle__title",children:"👥 Agents"}),e.jsxs("div",{className:"flat-middle__actions",children:[e.jsx("button",{className:"flat-cta-btn flat-cta-btn--agent",onClick:y,title:"Create new agent",children:"+ Agent"}),e.jsx("button",{className:"flat-cta-btn flat-cta-btn--boss",onClick:D,title:"Create new boss agent",children:"+ Boss"}),e.jsx("button",{className:"flat-cta-btn flat-cta-btn--area",onClick:ie,title:"Create new area",children:"+ Area"})]})]}),e.jsx("div",{className:"flat-middle__content",children:e.jsx(Wt,{activeAgentId:o,onClose:We,onSelectAgent:rt,collapsedAreas:At,onToggleArea:It,agentListRef:ut})})]}),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:Ze,onPointerMove:ve,onPointerUp:$,onPointerCancel:$,onDoubleClick:De}),e.jsxs("div",{className:"flat-right",children:[e.jsxs("button",{type:"button",className:"flat-mobile-sidebar-toggle","aria-label":F?"Close agents sidebar":"Open agents sidebar","aria-expanded":F,onClick:Re,children:[e.jsx(m,{name:"list",size:18}),e.jsx("span",{className:"flat-mobile-sidebar-toggle__label",children:"Agents"})]}),u?e.jsx(ka,{agentId:u,terminalViewMode:we,onTerminalViewModeChange:Pe,inspectorOpen:Ce,onToggleInspector:Qe,onImageClick:at,onFileClick:se,onBashClick:nt,onViewMarkdown:Z,onRequestClearSubordinates:Ne,onOpenBuilding:H,keyboard:tt,canNavigateBack:st,canNavigateForward:$e,onNavigateBack:Be,onNavigateForward:r,agentInfoOpen:p,onToggleAgentInfo:ce}):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("div",{className:"flat-map__grid",style:{gridTemplateColumns:`repeat(${me.gridCols}, 1fr)`},children:me.groups.length===0?e.jsx("div",{className:"flat-map__empty",children:e.jsx("span",{children:"No areas or agents yet"})}):me.groups.map(t=>{const a=t.area.id,s=me.positions.get(a);return e.jsxs("div",{className:"flat-map-area-card",style:{"--area-color":t.area.color,gridRow:s==null?void 0:s.row,gridColumn:s==null?void 0:s.col},children:[e.jsxs("button",{type:"button",className:"flat-map-area-card__header",onClick:()=>yt(a),title:`Focus ${t.area.name} in left panel`,children:[e.jsx("span",{className:"flat-map-area-card__color",style:{background:t.area.color}}),e.jsx("span",{className:"flat-map-area-card__name",children:t.area.name}),e.jsx("span",{className:"flat-map-area-card__count",children:t.agents.length})]}),e.jsx("div",{className:"flat-map-area-card__agents",children:t.agents.map(l=>{const f=l.isBoss||l.class==="boss",w=f?Fe.get(l.id):void 0,h=Ht(l),Ae=h.usedPercent>=80?"#ff4a4a":h.usedPercent>=60?"#ff9e4a":h.usedPercent>=40?"#ffd700":"#4aff9e",He=`Context: ${(h.totalTokens/1e3).toFixed(1)}k / ${(h.contextWindow/1e3).toFixed(1)}k (${h.usedPercent}% used, ${h.freePercent}% free)`,g=l.latestTodos&&l.latestTodos.length>0||w&&w.length>0;return e.jsx(Gt,{todos:l.latestTodos,subordinates:w,position:"top",children:e.jsxs("button",{type:"button",className:`flat-map-agent-chip ${l.status}`,onClick:()=>x(l.id),onContextMenu:b=>{b.preventDefault(),b.stopPropagation(),oe({agentId:l.id,position:{x:b.clientX,y:b.clientY}})},title:g?void 0:`${f?"Boss · ":""}Open chat with ${l.name}
2
- ${He}`,children:[e.jsx(Nt,{agent:l,size:16}),f&&e.jsx("span",{className:"flat-map-agent-chip__crown","aria-hidden":"true",children:e.jsx(m,{name:"crown",size:11,color:"#ffd700",weight:"fill"})}),e.jsx("span",{className:"flat-map-agent-chip__name",children:l.name}),e.jsx("img",{src:l.provider==="codex"?"/assets/codex.png":l.provider==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:l.provider,className:"flat-map-agent-chip__provider-icon",title:l.provider==="codex"?"Codex Agent":l.provider==="opencode"?"OpenCode Agent":"Claude Agent"}),e.jsx("span",{className:"flat-map-agent-chip__dot",style:{backgroundColor:kt(l.status)}}),l.latestTodos&&l.latestTodos.length>0&&e.jsx(Vt,{todos:l.latestTodos,maxDots:6}),f&&w&&w.length>0&&e.jsx(Ut,{subordinates:w,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:`${h.usedPercent}%`,backgroundColor:Ae}})})]})},l.id)})})]},a)})})]})})]}),ke&&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:ae,onPointerMove:ve,onPointerUp:$,onPointerCancel:$,onDoubleClick:ne}),ke&&e.jsxs("aside",{className:"flat-inspector","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":Y==="agent",className:`flat-inspector__tab ${Y==="agent"?"flat-inspector__tab--active":""}`,onClick:()=>Le("agent"),children:"Agent"}),e.jsx("button",{type:"button",role:"tab","aria-selected":Y==="tracking",className:`flat-inspector__tab ${Y==="tracking"?"flat-inspector__tab--active":""}`,onClick:()=>Le("tracking"),children:"Tracking"})]}),e.jsx("button",{type:"button",className:"flat-inspector__close",onClick:et,title:"Close inspector","aria-label":"Close inspector",children:"✕"})]}),e.jsx("div",{className:"flat-inspector__body",children:Y==="tracking"?e.jsx(Xt,{activeAgentId:u??"",onSelectAgent:t=>x(t)}):(()=>{if(!u)return e.jsx("div",{className:"flat-inspector__empty",children:e.jsx("span",{children:"Select an agent to inspect"})});const t=S.find(a=>a.id===u);return t?e.jsx(qt,{agent:t,onFocusAgent:a=>x(a),onKillAgent:a=>C.killAgent(a)}):e.jsx("div",{className:"flat-inspector__empty",children:e.jsx("span",{children:"Agent not found"})})})()})]}),xe&&e.jsx(Kt,{url:xe.url,name:xe.name,onClose:()=>Se(null)}),_e&&e.jsx(Yt,{state:_e,onClose:()=>Me(null)}),be&&e.jsx(Zt,{action:"clear-subordinates",selectedAgentId:be.agentId,subordinateCount:be.count,onClose:()=>ye(null),onClearHistory:()=>{}}),e.jsx(Jt,{agent:u?S.find(t=>t.id===u)??null:null,isOpen:p&&!!u,onClose:Te}),e.jsx(Qt,{isOpen:T!==null,position:(T==null?void 0:T.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:Mt,onClose:()=>oe(null)}),e.jsx(ea,{isOpen:z!==null,title:L("common:confirm.removeAgentTitle"),message:L("common:confirm.removeAgentMessage",{name:(z==null?void 0:z.name)??""}),confirmLabel:L("common:buttons.remove"),cancelLabel:L("common:buttons.cancel"),variant:"danger",onConfirm:()=>{z&&C.removeAgentFromServer(z.agentId)},onClose:()=>Ee(null)})]})}export{Ma as FlatView};