tide-commander 1.145.0 → 1.146.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 (43) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/assets/{BossLogsModal-DPXsdZ7u.js → BossLogsModal-BR0IXO2N.js} +1 -1
  3. package/dist/assets/BossSpawnModal-x75-j2da.js +1 -0
  4. package/dist/assets/{ControlsModal-J62POwmI.js → ControlsModal-DVil4qEv.js} +1 -1
  5. package/dist/assets/{DockerLogsModal-DZx8OuLO.js → DockerLogsModal-CFREftxm.js} +1 -1
  6. package/dist/assets/{EmbeddedEditor-BLZrqHph.js → EmbeddedEditor-BB1dXjgA.js} +1 -1
  7. package/dist/assets/{GmailOAuthSetup-BD-W3VJ9.js → GmailOAuthSetup-Bt4lYIib.js} +1 -1
  8. package/dist/assets/{GoogleOAuthSetup-miugyyJJ.js → GoogleOAuthSetup-D9WbR8pi.js} +1 -1
  9. package/dist/assets/{IframeModal-uiyVg9VQ.js → IframeModal-VRxo8uW0.js} +1 -1
  10. package/dist/assets/{IntegrationsPanel-CAt_jjW7.js → IntegrationsPanel-CPGny7vx.js} +2 -2
  11. package/dist/assets/{LogViewerModal-DHSPYmTn.js → LogViewerModal-bkAbzlbh.js} +1 -1
  12. package/dist/assets/{MonitoringModal-DJdIFnXI.js → MonitoringModal-CkpuOazc.js} +1 -1
  13. package/dist/assets/{PM2LogsModal-CA7IDf-Q.js → PM2LogsModal-Cllh-p5p.js} +1 -1
  14. package/dist/assets/{RestoreArchivedAreaModal-CrgrnJrN.js → RestoreArchivedAreaModal-DLjiody0.js} +1 -1
  15. package/dist/assets/{Scene2DCanvas-CCKFfv_Q.js → Scene2DCanvas-UxkEcgli.js} +1 -1
  16. package/dist/assets/{SceneManager-DPogxokC.js → SceneManager-3z1c1ca8.js} +1 -1
  17. package/dist/assets/{SkillsPanel-BGH4Jzy2.js → SkillsPanel-Opv6_qsA.js} +1 -1
  18. package/dist/assets/{SlackMultiInstanceSetup-Cde0PF27.js → SlackMultiInstanceSetup-BRBXqcBK.js} +1 -1
  19. package/dist/assets/SpawnModal-Cgr2So6H.js +1 -0
  20. package/dist/assets/{StatisticsModal-BWx5rOYA.js → StatisticsModal-CQ9zX_te.js} +1 -1
  21. package/dist/assets/{SubordinateAssignmentModal-BcACB1Rb.js → SubordinateAssignmentModal-DYl_KFut.js} +1 -1
  22. package/dist/assets/{TriggerManagerPanel-BQdBJs9X.js → TriggerManagerPanel-DteLW6l2.js} +1 -1
  23. package/dist/assets/{WorkflowEditorPanel-CzM3DxVG.js → WorkflowEditorPanel-C_OQpYuO.js} +1 -1
  24. package/dist/assets/{area-logos-BHJ2RYkS.js → area-logos-CcA80suT.js} +1 -1
  25. package/dist/assets/{index-DxcL_hH1.js → index-BMCNBI0L.js} +1 -1
  26. package/dist/assets/index-CCFfkD_H.js +2 -0
  27. package/dist/assets/{index-DtuQeAw2.js → index-CIuAGpI4.js} +1 -1
  28. package/dist/assets/{index-f23AFZac.js → index-ClQaYJNq.js} +1 -1
  29. package/dist/assets/{index-D0wHZqkk.js → index-CtzZOKXq.js} +1 -1
  30. package/dist/assets/{index-D_wa-zns.js → index-DQhrNqbn.js} +3 -3
  31. package/dist/assets/{index-B20Fn_-l.js → index-DhL1siJA.js} +1 -1
  32. package/dist/assets/{index-DuPDS7BI.js → index-DtUDyvyC.js} +2 -2
  33. package/dist/assets/{index-C4Xpdvs6.js → index-k4vAPWgE.js} +1 -1
  34. package/dist/assets/{main-DBurmQCa.js → main-BhpZ8DMy.js} +107 -107
  35. package/dist/assets/{web-B-nLiUYo.js → web-5BrjMiIU.js} +1 -1
  36. package/dist/assets/{web-BkDI_Oul.js → web-Cx4v8f8d.js} +1 -1
  37. package/dist/assets/{web-XTmM7Spb.js → web-DpsRRzsh.js} +1 -1
  38. package/dist/index.html +1 -1
  39. package/dist/src/packages/shared/agent-types.js +12 -32
  40. package/package.json +1 -1
  41. package/dist/assets/BossSpawnModal-Bn8bGZyF.js +0 -1
  42. package/dist/assets/SpawnModal-B_1WTo88.js +0 -1
  43. package/dist/assets/index-BksOQHtD.js +0 -2
@@ -1 +1 @@
1
- import{c$ as t}from"./main-DBurmQCa.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";class o extends t{constructor(){super(),this.handleVisibilityChange=()=>{const e={isActive:document.hidden!==!0};this.notifyListeners("appStateChange",e),document.hidden?this.notifyListeners("pause",null):this.notifyListeners("resume",null)},document.addEventListener("visibilitychange",this.handleVisibilityChange,!1)}exitApp(){throw this.unimplemented("Not implemented on web.")}async getInfo(){throw this.unimplemented("Not implemented on web.")}async getLaunchUrl(){return{url:""}}async getState(){return{isActive:document.hidden!==!0}}async minimizeApp(){throw this.unimplemented("Not implemented on web.")}async toggleBackButtonHandler(){throw this.unimplemented("Not implemented on web.")}async getAppLanguage(){return{value:navigator.language.split("-")[0].toLowerCase()}}}export{o as AppWeb};
1
+ import{c$ as t}from"./main-BhpZ8DMy.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";class o extends t{constructor(){super(),this.handleVisibilityChange=()=>{const e={isActive:document.hidden!==!0};this.notifyListeners("appStateChange",e),document.hidden?this.notifyListeners("pause",null):this.notifyListeners("resume",null)},document.addEventListener("visibilitychange",this.handleVisibilityChange,!1)}exitApp(){throw this.unimplemented("Not implemented on web.")}async getInfo(){throw this.unimplemented("Not implemented on web.")}async getLaunchUrl(){return{url:""}}async getState(){return{isActive:document.hidden!==!0}}async minimizeApp(){throw this.unimplemented("Not implemented on web.")}async toggleBackButtonHandler(){throw this.unimplemented("Not implemented on web.")}async getAppLanguage(){return{value:navigator.language.split("-")[0].toLowerCase()}}}export{o as AppWeb};
@@ -1 +1 @@
1
- import{c$ as a}from"./main-DBurmQCa.js";import{ImpactStyle as i,NotificationType as r}from"./index-DuPDS7BI.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{c$ as a}from"./main-BhpZ8DMy.js";import{ImpactStyle as i,NotificationType as r}from"./index-DtUDyvyC.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 +1 @@
1
- import{c$ as s}from"./main-DBurmQCa.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{c$ as s}from"./main-BhpZ8DMy.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};
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-DBurmQCa.js"></script>
25
+ <script type="module" crossorigin src="/assets/main-BhpZ8DMy.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-ijcbyjBn.css">
@@ -25,40 +25,20 @@ export const CODEX_REASONING_EFFORTS = {
25
25
  xhigh: { label: 'X-High', description: 'Extra-high reasoning, slowest', icon: '🧠' },
26
26
  };
27
27
  export const CODEX_MODELS = {
28
- 'gpt-5.5': {
29
- label: 'GPT-5.5',
30
- description: 'Next-generation frontier model with advanced reasoning and coding',
31
- icon: '',
28
+ 'gpt-5.6-luna': {
29
+ label: 'GPT-5.6 Luna',
30
+ description: 'GPT-5.6 Luna model',
31
+ icon: '🌙',
32
32
  },
33
- 'gpt-5.4': {
34
- label: 'GPT-5.4',
35
- description: 'Latest frontier model with advanced reasoning and coding',
36
- icon: '🌟',
33
+ 'gpt-5.6-terra': {
34
+ label: 'GPT-5.6 Terra',
35
+ description: 'GPT-5.6 Terra model',
36
+ icon: '🌍',
37
37
  },
38
- 'gpt-5.3-codex': {
39
- label: 'GPT-5.3 Codex',
40
- description: 'Latest frontier agentic coding model',
41
- icon: '⚙️',
42
- },
43
- 'gpt-5.2-codex': {
44
- label: 'GPT-5.2 Codex',
45
- description: 'Frontier agentic coding model',
46
- icon: '🧠',
47
- },
48
- 'gpt-5.1-codex-max': {
49
- label: 'GPT-5.1 Codex Max',
50
- description: 'Codex-optimized flagship for deep and fast reasoning',
51
- icon: '🚀',
52
- },
53
- 'gpt-5.1-codex-mini': {
54
- label: 'GPT-5.1 Codex Mini',
55
- description: 'Optimized for codex, cheaper and faster',
56
- icon: '⚡',
57
- },
58
- 'gpt-5.2': {
59
- label: 'GPT-5.2',
60
- description: 'General frontier model with strong reasoning and coding',
61
- icon: '🧩',
38
+ 'gpt-5.6-sol': {
39
+ label: 'GPT-5.6 Sol',
40
+ description: 'GPT-5.6 Sol model',
41
+ icon: '☀️',
62
42
  },
63
43
  };
64
44
  export const CLAUDE_MODELS = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tide-commander",
3
- "version": "1.145.0",
3
+ "version": "1.146.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 +0,0 @@
1
- import{u as Be,ay as Oe,b1 as Re,b0 as Te,r as t,X as re,S as W,bc as O,i as Fe,s as v,b4 as G,A as de,bd as C,j as s,a7 as y,b5 as Pe,b7 as ze,I as R,b8 as K,aO as A,aM as T,ba as X,Y as Ue}from"./main-DBurmQCa.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function ue(d){const w=C.filter(E=>!d.has(`Boss ${E}`));return w.length===0?`Boss ${C[Math.floor(Math.random()*C.length)]}-${Date.now()%1e3}`:`Boss ${w[Math.floor(Math.random()*w.length)]}`}function Ke({isOpen:d,onClose:w,onSpawnStart:E,onSpawnEnd:F,spawnPosition:me,spawnAreaId:N}){const{t:n}=Be(["terminal","common"]),H=Oe(),c=Re(),$=Te(),[u,p]=t.useState(""),[L,P]=t.useState(()=>re(W.LAST_CWD)),[r,I]=t.useState("boss"),[J,Y]=t.useState(!1),[pe,_]=t.useState(!1),[V,he]=t.useState(!0),[Q,we]=t.useState("bypass"),[m,z]=t.useState("claude"),[f,g]=t.useState({fullAuto:!0,sandbox:"workspace-write",approvalMode:"on-request",search:!1}),[Z,xe]=t.useState("claude-opus-4-8[1m]"),[ee,fe]=t.useState("gpt-5.3-codex"),[k,D]=t.useState(new Set),[se,U]=t.useState(new Set),[h,be]=t.useState(""),[S,je]=t.useState(""),[ae,Ne]=t.useState(""),B=t.useRef(null),q=t.useRef(!1),ne=t.useRef(!1),b=t.useMemo(()=>$.filter(e=>e.enabled),[$]),le=t.useMemo(()=>{if(!S.trim())return b;const e=S.toLowerCase();return b.filter(a=>a.name.toLowerCase().includes(e)||a.description.toLowerCase().includes(e)||a.slug.toLowerCase().includes(e))},[b,S]),ge=t.useMemo(()=>{var a;const e=c.find(l=>l.id===r);return(a=e==null?void 0:e.defaultSkillIds)!=null&&a.length?$.filter(l=>e.defaultSkillIds.includes(l.id)):[]},[c,r,$]),Se=["full-notifications","streaming-exec","task-label","report-task-to-boss","agent-tracking","agent-memory","send-message-to-agent"];t.useEffect(()=>{if(d&&!ne.current){if(b.length>0){const l=b.filter(i=>Se.includes(i.slug)).map(i=>i.id);l.length>0&&U(new Set(l))}if(re(W.DEFAULT_AGENT_CLASS)==="random"){const i=[...Object.keys(O).filter(j=>j!=="boss"),...c.map(j=>j.id)];i.length>0&&I(i[Math.floor(Math.random()*i.length)])}}ne.current=d},[d,b,c]);const ve=t.useCallback(e=>{U(a=>{const l=new Set(a);return l.has(e)?l.delete(e):l.add(e),l})},[]),o=t.useMemo(()=>c.find(e=>e.id===r),[c,r]),Ce=t.useMemo(()=>{if(o!=null&&o.model)return o.model},[o]),ke=t.useMemo(()=>{if(o!=null&&o.customModelPath)return Fe(`/api/custom-models/${o.id}`)},[o]),Me=o==null?void 0:o.modelScale,ye=t.useMemo(()=>o?"scout":r==="boss"?"architect":r,[r,o]);t.useEffect(()=>{if(!d||!N)return;const e=v.getState().areas.get(N);if(e!=null&&e.directories&&e.directories.length>0){P(e.directories[0]);return}const a=Array.from(v.getState().agents.values()).filter(x=>{var M;return((M=v.getAreaForAgent(x.id))==null?void 0:M.id)===N&&x.cwd});if(a.length===0)return;const l=new Map;for(const x of a)l.set(x.cwd,(l.get(x.cwd)||0)+1);let i="",j=0;for(const[x,M]of l)M>j&&(i=x,j=M);i&&P(i)},[d,N]);const te=t.useMemo(()=>Array.from(H.values()).filter(e=>!e.isBoss&&e.class!=="boss"&&!e.bossId),[H]),ie=t.useMemo(()=>{if(!h.trim())return c;const e=h.toLowerCase();return c.filter(a=>a.name.toLowerCase().includes(e)||a.description.toLowerCase().includes(e)||a.id.toLowerCase().includes(e))},[c,h]),ce=t.useMemo(()=>{if(!h.trim())return G;const e=h.toLowerCase();return G.filter(a=>{const l=de[a.id];return l?a.name.toLowerCase().includes(e)||a.id.toLowerCase().includes(e)||l.description.toLowerCase().includes(e):!1})},[h]),oe=t.useMemo(()=>{if(!h.trim())return!0;const e=h.toLowerCase(),a=O.boss;return"boss".includes(e)||a.description.toLowerCase().includes(e)},[h]);t.useEffect(()=>{if(d&&!q.current){q.current=!0;const e=new Set(Array.from(v.getState().agents.values()).map(l=>l.name)),a=c.find(l=>l.id===r);if(a){const l=C.filter(i=>!e.has(`${a.name} ${i}`));if(l.length===0){const i=C[Math.floor(Math.random()*C.length)];p(`${a.name} ${i}-${Date.now()%1e3}`)}else p(`${a.name} ${l[Math.floor(Math.random()*l.length)]}`)}else p(ue(e));D(new Set),B.current&&(B.current.focus(),B.current.select())}else d||(q.current=!1)},[d]),t.useEffect(()=>{if(!d)return;const e=c.find(a=>a.id===r);if(e)if(u.startsWith("Boss ")){const a=u.substring(5);p(`${e.name} ${a}`)}else{const a=c.find(l=>u.startsWith(l.name+" "));if(a){const l=u.substring(a.name.length+1);p(`${e.name} ${l}`)}else p(`${e.name} ${u}`)}else{const a=c.find(l=>u.startsWith(l.name+" "));if(a){const l=u.substring(a.name.length+1);p(`Boss ${l}`)}else u.startsWith("Boss ")||p(`Boss ${u}`)}},[r]);const Ae=()=>{if(_(!1),!L.trim()){_(!0);return}if(!u.trim()){const l=new Set(Array.from(v.getState().agents.values()).map(i=>i.name));p(ue(l));return}Ue(W.LAST_CWD,L),E(),window.__spawnModalAreaContext=N?{areaId:N}:null;const e=ae.trim()||void 0,a=Array.from(se);v.spawnBossAgent(u.trim(),r,L.trim(),me||void 0,Array.from(k),m==="claude"?V:!1,Q,m,m==="codex"?f:void 0,m==="codex"?ee:void 0,m==="claude"?Z:void 0,e,a),p(""),D(new Set),U(new Set),F(),w()},Ee=()=>{Y(!1),p(""),D(new Set),F(),w()},$e=()=>{Y(!1),_(!0),F()};t.useEffect(()=>(window.__bossSpawnModalSuccess=Ee,window.__bossSpawnModalError=$e,()=>{delete window.__bossSpawnModalSuccess,delete window.__bossSpawnModalError}),[u]);const Le=e=>{e.target===e.currentTarget&&w()},Ie=e=>{e.key==="Escape"&&w()},_e=e=>{const a=new Set(k);a.has(e)?a.delete(e):a.add(e),D(a)};if(!d)return null;const De=O.boss;return s.jsx("div",{className:`modal-overlay ${d?"visible":""}`,onClick:Le,onKeyDown:Ie,children:s.jsxs("div",{className:"modal boss-spawn-modal",children:[s.jsxs("div",{className:"modal-header",children:[s.jsx(y,{classId:"boss",size:22,className:"boss-header-icon"}),n("terminal:spawn.deployBossTitle")]}),s.jsxs("div",{className:"modal-body spawn-modal-body",children:[s.jsxs("div",{className:"spawn-top-section",children:[s.jsx("div",{className:"spawn-preview-compact",children:s.jsx(Pe,{agentClass:ye,modelFile:Ce,customModelUrl:ke,modelScale:Me,width:100,height:120})}),s.jsxs("div",{className:"spawn-class-section",children:[s.jsx("div",{className:"spawn-class-label",children:n("terminal:spawn.bossClass")}),c.length+G.length+1>6&&s.jsx("input",{type:"text",className:"spawn-input class-search-input",placeholder:n("terminal:spawn.filterClasses"),value:h,onChange:e=>be(e.target.value)}),s.jsxs("div",{className:"class-selector-inline",children:[ie.map(e=>s.jsxs("button",{className:`class-chip ${r===e.id?"selected":""}`,onClick:()=>I(e.id),title:e.description,children:[s.jsx(y,{classId:e.id,size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id)),oe&&s.jsxs("button",{className:`class-chip ${r==="boss"?"selected":""}`,onClick:()=>I("boss"),title:De.description,children:[s.jsx(y,{classId:"boss",size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:n("terminal:spawn.bossClassName")})]}),ce.map(e=>{const a=de[e.id];return a?s.jsxs("button",{className:`class-chip ${r===e.id?"selected":""}`,onClick:()=>I(e.id),title:a.description,children:[s.jsx(y,{classId:e.id,size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id):null}),h&&ie.length===0&&!oe&&ce.length===0&&s.jsx("div",{className:"class-search-empty",children:n("terminal:spawn.noClassesMatch",{query:h})})]})]})]}),s.jsxs("div",{className:"spawn-form-section",children:[s.jsxs("div",{className:"spawn-form-row",children:[s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("common:labels.name")}),s.jsx("input",{ref:B,type:"text",className:"spawn-input",placeholder:n("terminal:spawn.bossNamePlaceholder"),value:u,onChange:e=>p(e.target.value)})]}),s.jsxs("div",{className:"spawn-field spawn-field-wide",children:[s.jsx("label",{className:"spawn-label",children:n("terminal:spawn.workingDir")}),s.jsx(ze,{value:L,onChange:e=>{P(e),_(!1)},placeholder:n("terminal:spawn.workingDirPlaceholder"),className:"spawn-input",hasError:pe,directoriesOnly:!0})]})]}),s.jsxs("div",{className:"spawn-form-row",children:[s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("common:labels.runtime")}),s.jsxs("div",{className:"spawn-select-row",children:[s.jsxs("button",{className:`spawn-select-btn ${m==="claude"?"selected":""}`,onClick:()=>z("claude"),title:n("terminal:spawn.useClaudeCli"),children:[s.jsx("img",{src:"/assets/claude.ico",alt:"Claude",className:"spawn-provider-icon"}),s.jsx("span",{children:"Claude"})]}),s.jsxs("button",{className:`spawn-select-btn ${m==="codex"?"selected":""}`,onClick:()=>z("codex"),title:n("terminal:spawn.useCodexCli"),children:[s.jsx("img",{src:"/assets/codex.ico",alt:"Codex",className:"spawn-provider-icon"}),s.jsx("span",{children:"Codex"})]}),s.jsxs("button",{className:`spawn-select-btn spawn-select-btn--opencode ${m==="opencode"?"selected":""}`,onClick:()=>z("opencode"),title:"Use OpenCode CLI (multi-provider)",children:[s.jsx("span",{children:s.jsx(R,{name:"status-pending",size:14,weight:"fill",color:"#4ade80"})}),s.jsx("span",{children:"OpenCode"})]})]})]}),s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("common:labels.permissions")}),s.jsx("div",{className:"spawn-select-row",children:Object.keys(K).map(e=>s.jsxs("button",{className:`spawn-select-btn ${Q===e?"selected":""}`,onClick:()=>we(e),title:K[e].description,children:[s.jsx("span",{children:s.jsx(R,{name:e==="bypass"?"bolt":"lock",size:14})}),s.jsx("span",{children:K[e].label})]},e))})]})]}),s.jsxs("div",{className:"spawn-form-row",children:[s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("common:labels.model")}),m==="claude"?s.jsx("div",{className:"spawn-select-row spawn-select-row--wrap",children:Object.keys(A).filter(e=>!A[e].deprecated).map(e=>s.jsxs("button",{className:`spawn-select-btn ${Z===e?"selected":""}`,onClick:()=>xe(e),title:A[e].description,children:[s.jsx("span",{children:A[e].icon}),s.jsx("span",{children:A[e].label})]},e))}):m==="codex"?s.jsx("div",{className:"spawn-select-row spawn-select-row--codex-models",children:Object.keys(T).map(e=>s.jsxs("button",{className:`spawn-select-btn ${ee===e?"selected":""}`,onClick:()=>fe(e),title:T[e].description,children:[s.jsx("span",{children:T[e].icon}),s.jsx("span",{children:T[e].label})]},e))}):m==="opencode"?s.jsx("input",{type:"text",className:"spawn-input",defaultValue:"minimax/MiniMax-M1-80k",placeholder:"provider/model (e.g., minimax/MiniMax-M1-80k)"}):s.jsx("div",{className:"spawn-inline-hint",children:n("terminal:spawn.codex.configuration")})]}),s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("common:labels.browser")}),s.jsx("div",{className:"spawn-form-row spawn-options-row",children:s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:V,onChange:e=>he(e.target.checked),disabled:m!=="claude"}),s.jsx("span",{children:n("terminal:spawn.chromeBrowser")})]})})]})]}),m==="codex"&&s.jsx("div",{className:"spawn-form-row",children:s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("terminal:spawn.codex.config")}),s.jsxs("div",{className:"spawn-options-row",style:{display:"flex",flexDirection:"column",gap:8},children:[s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:f.fullAuto!==!1,onChange:e=>g(a=>({...a,fullAuto:e.target.checked}))}),s.jsx("span",{children:n("terminal:spawn.codex.useFullAuto")})]}),s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:!!f.search,onChange:e=>g(a=>({...a,search:e.target.checked}))}),s.jsx("span",{children:n("terminal:spawn.codex.enableSearch")})]}),f.fullAuto===!1&&s.jsxs(s.Fragment,{children:[s.jsxs("select",{className:"spawn-input",value:f.sandbox||"workspace-write",onChange:e=>g(a=>({...a,sandbox:e.target.value})),children:[s.jsx("option",{value:"read-only",children:n("terminal:spawn.codex.sandboxReadOnly")}),s.jsx("option",{value:"workspace-write",children:n("terminal:spawn.codex.sandboxWorkspaceWrite")}),s.jsx("option",{value:"danger-full-access",children:n("terminal:spawn.codex.sandboxDangerFullAccess")})]}),s.jsxs("select",{className:"spawn-input",value:f.approvalMode||"on-request",onChange:e=>g(a=>({...a,approvalMode:e.target.value})),children:[s.jsx("option",{value:"untrusted",children:n("terminal:spawn.codex.approvalsUntrusted")}),s.jsx("option",{value:"on-failure",children:n("terminal:spawn.codex.approvalsOnFailure")}),s.jsx("option",{value:"on-request",children:n("terminal:spawn.codex.approvalsOnRequest")}),s.jsx("option",{value:"never",children:n("terminal:spawn.codex.approvalsNever")})]})]}),s.jsx("input",{type:"text",className:"spawn-input",placeholder:n("terminal:spawn.codex.profileOptional"),value:f.profile||"",onChange:e=>g(a=>({...a,profile:e.target.value||void 0}))}),s.jsxs("select",{className:"spawn-input",value:f.reasoningEffort||"",onChange:e=>g(a=>({...a,reasoningEffort:e.target.value||void 0})),children:[s.jsx("option",{value:"",children:n("terminal:spawn.codex.reasoningEffortDefault")}),Object.keys(X).map(e=>s.jsxs("option",{value:e,children:[X[e].icon," ",n("terminal:spawn.codex.reasoningEffort"),": ",X[e].label]},e))]})]})]})}),b.length>0&&s.jsxs("div",{className:"spawn-skills-section",children:[s.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.skills")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",n("common:labels.optional"),")"]})]}),b.length>6&&s.jsx("input",{type:"text",className:"spawn-input skill-search-input",placeholder:n("terminal:spawn.filterSkills"),value:S,onChange:e=>je(e.target.value)}),s.jsxs("div",{className:"spawn-skills-inline",children:[le.map(e=>{const a=se.has(e.id);return ge.some(i=>i.id===e.id)?null:s.jsxs("button",{className:`spawn-skill-chip ${a?"selected":""}`,onClick:()=>ve(e.id),title:e.description,children:[a&&s.jsx("span",{className:"spawn-skill-check",children:s.jsx(R,{name:"check",size:12})}),s.jsx("span",{children:e.name}),e.builtin&&s.jsx("span",{className:"spawn-skill-builtin",children:"TC"})]},e.id)}),S&&le.length===0&&s.jsx("div",{className:"skill-search-empty",children:n("terminal:spawn.noSkillsMatch",{query:S})})]})]}),s.jsxs("div",{className:"spawn-custom-instructions-section",children:[s.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.customInstructions")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",n("common:labels.optional"),")"]})]}),s.jsx("textarea",{className:"spawn-input spawn-textarea",placeholder:n("terminal:spawn.customInstructionsBossPlaceholder"),value:ae,onChange:e=>Ne(e.target.value),rows:3})]}),s.jsxs("div",{className:"spawn-subordinates-section",children:[s.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.initialSubordinates")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",n("common:labels.optional"),")"]})]}),s.jsx("div",{className:"subordinates-selector-compact",children:te.length===0?s.jsx("div",{className:"subordinates-empty",children:n("terminal:spawn.noAvailableAgents")}):te.map(e=>{const a=k.has(e.id),l=O[e.class],i=c.find(x=>x.id===e.class),j=l||i||{color:"#888888"};return s.jsxs("button",{className:`subordinate-chip ${a?"selected":""}`,onClick:()=>_e(e.id),children:[a&&s.jsx("span",{className:"subordinate-check",children:s.jsx(R,{name:"check",size:12})}),s.jsx("span",{className:"subordinate-chip-icon",style:{color:j.color},children:s.jsx(y,{classId:e.class,size:16})}),s.jsx("span",{className:"subordinate-chip-name",children:e.name})]},e.id)})}),k.size>0&&s.jsxs("div",{className:"subordinates-count",children:[k.size," ",n("common:labels.selected").toLowerCase()]})]})]})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:w,children:n("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-boss",onClick:Ae,disabled:J,children:n(J?"common:buttons.deploying":"common:buttons2.deployBoss")})]})]})})}export{Ke as BossSpawnModal};
@@ -1 +0,0 @@
1
- import{u as Ze,b0 as es,b1 as ss,b2 as as,b3 as ns,r as t,X as Ae,S as ne,b4 as te,A as Ee,i as le,h as ts,s as v,k as ls,j as s,b5 as os,a7 as De,b6 as x,b7 as is,b8 as oe,I as ie,aO as T,aM as K,b9 as cs,aN as ce,ba as re,bb as rs,Y as ds}from"./main-DBurmQCa.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function Ie(r,j){const S=j.filter(C=>!r.has(C));return S.length===0?`${j[Math.floor(Math.random()*j.length)]}-${Date.now()%1e3}`:S[Math.floor(Math.random()*S.length)]}function hs({isOpen:r,onClose:j,onSpawnStart:S,onSpawnEnd:C,spawnPosition:_e,spawnAreaId:b}){const{t:a}=Ze(["terminal","common"]),P=es(),p=ss(),de=as(),H=de.length>0?de:ns,[m,N]=t.useState(""),[M,F]=t.useState(()=>Ae(ne.LAST_CWD)),[i,k]=t.useState("scout"),[pe,I]=t.useState(!1),[Le,R]=t.useState(!1),[me,X]=t.useState(!1),[ue,he]=t.useState(""),[y,Y]=t.useState([]),[A,O]=t.useState(null),[$e,we]=t.useState(!1),[_,xe]=t.useState(""),[h,Te]=t.useState(""),[U,Pe]=t.useState(!1),[z,Fe]=t.useState("bypass"),[o,J]=t.useState("claude"),[f,E]=t.useState({fullAuto:!0,sandbox:"workspace-write",approvalMode:"on-request",search:!1}),[fe,Q]=t.useState(new Set),[V,ge]=t.useState("claude-opus-4-8[1m]"),[Z,je]=t.useState("xHigh"),[ee,Re]=t.useState("gpt-5.3-codex"),[se,Oe]=t.useState("minimax/MiniMax-M1-80k"),[be,Ue]=t.useState(""),[D,ze]=t.useState(""),q=t.useRef(null),Ne=t.useRef(!1),L=t.useCallback(()=>{window.__spawnModalAreaContext=null},[]),w=t.useMemo(()=>P.filter(e=>e.enabled),[P]),qe=["full-notifications","streaming-exec","task-label","report-task-to-boss","agent-tracking","agent-memory","send-message-to-agent"];t.useEffect(()=>{if(r&&!Ne.current){if(w.length>0){const l=w.filter(c=>qe.includes(c.slug)).map(c=>c.id);l.length>0&&Q(new Set(l))}const n=Ae(ne.DEFAULT_AGENT_CLASS);if(n==="random"){const c=[...Object.keys(rs),...p.map(u=>u.id)];k(c[Math.floor(Math.random()*c.length)])}else k(n||"scout")}Ne.current=r},[r,w,p]);const ve=t.useMemo(()=>{if(!D.trim())return w;const e=D.toLowerCase();return w.filter(n=>n.name.toLowerCase().includes(e)||n.description.toLowerCase().includes(e)||n.slug.toLowerCase().includes(e))},[w,D]),We=t.useCallback(e=>{Q(n=>{const l=new Set(n);return l.has(e)?l.delete(e):l.add(e),l})},[]);t.useMemo(()=>w.filter(e=>e.assignedAgentClasses.includes(i)),[w,i]);const Ge=t.useMemo(()=>{var n;const e=p.find(l=>l.id===i);return(n=e==null?void 0:e.defaultSkillIds)!=null&&n.length?P.filter(l=>e.defaultSkillIds.includes(l.id)):[]},[p,i,P]),Se=t.useMemo(()=>{if(!_.trim())return y;const e=_.toLowerCase();return y.filter(n=>n.sessionId.toLowerCase().includes(e)||n.projectPath.toLowerCase().includes(e)||n.firstMessage&&n.firstMessage.toLowerCase().includes(e))},[y,_]),W=t.useMemo(()=>{if(!h.trim())return p;const e=h.toLowerCase();return p.filter(n=>n.name.toLowerCase().includes(e)||n.description.toLowerCase().includes(e)||n.id.toLowerCase().includes(e))},[p,h]),G=t.useMemo(()=>{if(!h.trim())return te;const e=h.toLowerCase();return te.filter(n=>{const l=Ee[n.id];return n.name.toLowerCase().includes(e)||n.id.toLowerCase().includes(e)||l.description.toLowerCase().includes(e)})},[h]);t.useEffect(()=>{if(!r||!h.trim())return;const e=[...W.map(n=>n.id),...G.map(n=>n.id)];e.length===1&&e[0]!==i&&k(e[0])},[r,h,W,G,i]);const d=t.useMemo(()=>p.find(e=>e.id===i),[p,i]),Be=t.useMemo(()=>{if(d!=null&&d.model)return d.model},[d]),Ke=t.useMemo(()=>{if(d!=null&&d.customModelPath)return le(`/api/custom-models/${d.id}`)},[d]),He=d==null?void 0:d.modelScale,Xe=t.useMemo(()=>d?"scout":i,[i,d]),B=t.useCallback(async e=>{we(!0);try{const n=e?le(`/api/agents/claude-sessions?cwd=${encodeURIComponent(e)}`):le("/api/agents/claude-sessions"),c=await(await ts(n)).json();Y(c.sessions||[])}catch(n){console.error("Failed to fetch sessions:",n),Y([])}finally{we(!1)}},[]);t.useEffect(()=>{r?B(M||void 0):(Y([]),O(null),xe(""))},[r,B]),t.useEffect(()=>{if(!r)return;const e=setTimeout(()=>{B(M||void 0),O(null)},300);return()=>clearTimeout(e)},[M,r,B]),t.useEffect(()=>{if(!r||!b)return;const e=v.getState().areas.get(b);if(e!=null&&e.directories&&e.directories.length>0){F(e.directories[0]);return}const n=Array.from(v.getState().agents.values()).filter(g=>{var $;return(($=v.getAreaForAgent(g.id))==null?void 0:$.id)===b&&g.cwd});if(n.length===0)return;const l=new Map;for(const g of n)l.set(g.cwd,(l.get(g.cwd)||0)+1);let c="",u=0;for(const[g,$]of l)$>u&&(c=g,u=$);c&&F(c)},[r,b]),t.useEffect(()=>{if(r){const e=new Set(Array.from(v.getState().agents.values()).map(u=>u.name)),n=Ie(e,H),l=p.find(u=>u.id===i),c=l?`${l.name} ${n}`:n;N(c),q.current&&(q.current.focus(),q.current.select())}},[r,H]),t.useEffect(()=>{if(!r)return;const e=p.find(n=>n.id===i);if(e){const n=p.find(l=>m.startsWith(l.name+" "));if(n){const l=m.substring(n.name.length+1);N(`${e.name} ${l}`)}else N(`${e.name} ${m}`)}else{const n=p.find(l=>m.startsWith(l.name+" "));if(n){const l=m.substring(n.name.length+1);N(l)}}},[i]),t.useEffect(()=>{i==="boss"&&ge("claude-opus-4-8[1m]")},[i]);const Ye=()=>{var c;console.log("[SpawnModal] handleSpawn called"),R(!1);const e=A&&((c=y.find(u=>u.sessionId===A))==null?void 0:c.projectPath)||M;if(console.log("[SpawnModal] Effective CWD:",e),console.log("[SpawnModal] Agent name:",m),console.log("[SpawnModal] Agent class:",i),console.log("[SpawnModal] Permission mode:",z),console.log("[SpawnModal] Provider:",o),console.log("[SpawnModal] Use Chrome:",U),console.log("[SpawnModal] Session ID:",A||"none"),!e.trim()){console.error("[SpawnModal] Empty CWD, showing error"),R(!0);return}if(!m.trim()){console.log("[SpawnModal] Empty name, regenerating");const u=new Set(Array.from(v.getState().agents.values()).map(g=>g.name));N(Ie(u,H));return}ds(ne.LAST_CWD,e),I(!0),S();const n=Array.from(fe),l=be.trim()||void 0;console.log("[SpawnModal] Calling store.spawnAgent with:",{name:m.trim(),class:i,cwd:e.trim(),sessionId:A||void 0,useChrome:o==="claude"?U:!1,permissionMode:z,provider:o,codexConfig:o==="codex"?f:void 0,codexModel:o==="codex"?ee:void 0,opencodeModel:o==="opencode"?se:void 0,initialSkillIds:n,model:o==="claude"?V:void 0,customInstructions:l?`${l.length} chars`:void 0,spawnAreaId:b||void 0}),window.__spawnModalAreaContext=b?{areaId:b}:null,v.spawnAgent(m.trim(),i,e.trim(),_e||void 0,A||void 0,o==="claude"?U:!1,z,n,o,o==="codex"?f:void 0,o==="codex"?ee:void 0,o==="claude"?V:void 0,l,o==="claude"?Z:void 0,o==="opencode"?se:void 0)},Ce=()=>{console.log("[SpawnModal] Agent creation successful"),I(!1),N(""),Q(new Set),L(),C(),j()},Me=()=>{console.error("[SpawnModal] Agent creation failed"),I(!1),R(!0),L(),C()},ke=e=>{console.log("[SpawnModal] Directory not found:",e),I(!1),he(e),X(!0),C()},ye=()=>{X(!1),I(!0),S(),v.createDirectoryAndSpawn(ue,m.trim(),i)},ae=()=>{X(!1),he(""),L()};t.useEffect(()=>(window.__spawnModalSuccess=Ce,window.__spawnModalError=Me,window.__spawnModalDirNotFound=ke,()=>{L(),delete window.__spawnModalSuccess,delete window.__spawnModalError,delete window.__spawnModalDirNotFound}),[m,i,Ce,Me,ke,L]);const{handleMouseDown:Je,handleClick:Qe}=ls(j),Ve=e=>{e.key==="Escape"&&j()};return!r&&!me?null:me?s.jsx("div",{className:"modal-overlay visible",onClick:ae,onKeyDown:e=>{e.key==="Escape"&&ae(),e.key==="Enter"&&ye()},children:s.jsxs("div",{className:"modal confirm-modal",onClick:e=>e.stopPropagation(),children:[s.jsx("div",{className:"modal-header",children:a("terminal:spawn.directoryNotFound")}),s.jsxs("div",{className:"modal-body confirm-modal-body",children:[s.jsx("p",{children:a("terminal:spawn.directoryNotExist")}),s.jsx("code",{className:"confirm-modal-path",children:ue}),s.jsx("p",{children:a("terminal:spawn.wouldYouCreate")})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:ae,children:a("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-primary",onClick:ye,autoFocus:!0,children:a("terminal:spawn.createDirectory")})]})]})}):s.jsx("div",{className:`modal-overlay ${r?"visible":""}`,onMouseDown:Je,onClick:Qe,onKeyDown:Ve,children:s.jsxs("div",{className:"modal spawn-modal",children:[s.jsx("div",{className:"modal-header",children:a("terminal:spawn.deployTitle")}),s.jsxs("div",{className:"modal-body spawn-modal-body",children:[s.jsxs("div",{className:"spawn-top-section",children:[s.jsx("div",{className:"spawn-preview-compact",children:s.jsx(os,{agentClass:Xe,modelFile:Be,customModelUrl:Ke,modelScale:He,width:100,height:120})}),s.jsxs("div",{className:"spawn-class-section",children:[s.jsx("div",{className:"spawn-class-label",children:a("terminal:spawn.agentClass")}),p.length+te.length>6&&s.jsx("input",{type:"text",className:"spawn-input class-search-input",placeholder:a("terminal:spawn.filterClasses"),value:h,onChange:e=>Te(e.target.value)}),s.jsxs("div",{className:"class-selector-inline",children:[W.map(e=>s.jsxs("button",{className:`class-chip ${i===e.id?"selected":""}`,onClick:()=>k(e.id),title:e.description,children:[s.jsx(De,{classId:e.id,size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id)),G.map(e=>{const n=Ee[e.id];return s.jsxs("button",{className:`class-chip ${i===e.id?"selected":""}`,onClick:()=>k(e.id),title:n.description,children:[s.jsx(De,{classId:e.id,size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id)}),h&&W.length===0&&G.length===0&&s.jsx("div",{className:"class-search-empty",children:a("terminal:spawn.noClassesMatch",{query:h})})]})]})]}),s.jsxs("div",{className:"spawn-form-section",children:[s.jsxs("div",{className:"spawn-form-row",children:[s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:a("common:labels.name")}),s.jsx("input",{ref:q,type:"text",className:"spawn-input",placeholder:a("terminal:spawn.agentNamePlaceholder"),value:m,onChange:e=>N(e.target.value)})]}),s.jsxs("div",{className:"spawn-field spawn-field-wide",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.workingDir"),s.jsx(x,{text:a("terminal:spawn.helpWorkingDir"),title:a("terminal:spawn.workingDir"),position:"top",size:"sm"})]}),s.jsx(is,{value:M,onChange:e=>{F(e),R(!1)},placeholder:a("terminal:spawn.workingDirPlaceholder"),className:`spawn-input ${Le?"error":""}`,directoriesOnly:!0})]})]}),s.jsxs("div",{className:"spawn-form-row",children:[s.jsxs("div",{className:"spawn-field",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.selectRuntime"),s.jsx(x,{text:a("terminal:spawn.helpRuntime"),title:a("terminal:spawn.runtimeTitle"),position:"top",size:"sm"})]}),s.jsxs("div",{className:"spawn-select-row",children:[s.jsxs("button",{className:`spawn-select-btn ${o==="claude"?"selected":""}`,onClick:()=>J("claude"),title:a("terminal:spawn.useClaudeCli"),children:[s.jsx("img",{src:"/assets/claude.ico",alt:"Claude",className:"spawn-provider-icon"}),s.jsx("span",{children:"Claude"})]}),s.jsxs("button",{className:`spawn-select-btn ${o==="codex"?"selected":""}`,onClick:()=>J("codex"),title:a("terminal:spawn.useCodexCli"),children:[s.jsx("img",{src:"/assets/codex.ico",alt:"Codex",className:"spawn-provider-icon"}),s.jsx("span",{children:"Codex"})]}),s.jsxs("button",{className:`spawn-select-btn spawn-select-btn--opencode ${o==="opencode"?"selected":""}`,onClick:()=>J("opencode"),title:"Use OpenCode CLI (multi-provider)",children:[s.jsx("img",{src:"/assets/opencode.svg",alt:"OpenCode",className:"spawn-provider-icon"}),s.jsx("span",{children:"OpenCode"})]})]})]}),s.jsxs("div",{className:"spawn-field",children:[s.jsxs("label",{className:"spawn-label",children:[a("common:labels.permissions"),s.jsx(x,{text:a("terminal:spawn.helpPermission"),title:a("terminal:spawn.permissionMode"),position:"top",size:"sm"})]}),s.jsx("div",{className:"spawn-select-row",children:Object.keys(oe).map(e=>s.jsxs("button",{className:`spawn-select-btn ${z===e?"selected":""}`,onClick:()=>Fe(e),title:oe[e].description,children:[s.jsx("span",{children:s.jsx(ie,{name:e==="bypass"?"bolt":"lock",size:12})}),s.jsx("span",{children:oe[e].label})]},e))})]})]}),s.jsx("div",{className:"spawn-form-row",children:s.jsxs("div",{className:"spawn-field",children:[s.jsxs("label",{className:"spawn-label",children:[a("common:labels.model"),s.jsx(x,{text:a("terminal:spawn.helpModel"),title:a("terminal:spawn.modelTitle"),position:"top",size:"sm"})]}),o==="claude"?s.jsx("div",{className:"spawn-select-row spawn-select-row--wrap",children:Object.keys(T).filter(e=>!T[e].deprecated).map(e=>s.jsxs("button",{className:`spawn-select-btn ${V===e?"selected":""}`,onClick:()=>ge(e),title:T[e].description,children:[s.jsx("span",{children:T[e].icon}),s.jsx("span",{children:T[e].label})]},e))}):o==="codex"?s.jsx("div",{className:"spawn-select-row spawn-select-row--codex-models",children:Object.keys(K).map(e=>s.jsxs("button",{className:`spawn-select-btn ${ee===e?"selected":""}`,onClick:()=>Re(e),title:K[e].description,children:[s.jsx("span",{children:K[e].icon}),s.jsx("span",{children:K[e].label})]},e))}):o==="opencode"?s.jsx(cs,{value:se,onChange:Oe,inputId:"spawn-opencode-model"}):s.jsx("div",{className:"spawn-inline-hint",children:a("terminal:spawn.chooseCodexModel")})]})}),s.jsxs("div",{className:"spawn-form-row",children:[o==="claude"&&s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:"Effort"}),s.jsxs("div",{className:"spawn-select-row spawn-select-row--effort",children:[s.jsx("button",{className:`spawn-select-btn spawn-select-btn--compact ${Z===void 0?"selected":""}`,onClick:()=>je(void 0),title:"Use default effort level",children:s.jsx("span",{children:"Default"})}),Object.keys(ce).map(e=>s.jsx("button",{className:`spawn-select-btn spawn-select-btn--compact ${Z===e?"selected":""}`,onClick:()=>je(e),title:ce[e].description,children:s.jsx("span",{children:ce[e].label})},e))]})]}),s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:a("terminal:spawn.browser")}),s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:U,onChange:e=>Pe(e.target.checked),disabled:o!=="claude"}),s.jsxs("span",{children:[s.jsx(ie,{name:"globe",size:12})," ",a("terminal:spawn.chromeBrowser")]}),s.jsx(x,{text:a(o==="claude"?"terminal:spawn.helpChrome":"terminal:spawn.helpChromeDisabled"),title:a("terminal:spawn.chromeBrowser"),position:"top",size:"sm"})]})]})]}),o==="codex"&&s.jsxs("div",{className:"codex-config-section",children:[s.jsx("div",{className:"codex-config-title",children:a("terminal:spawn.codex.configuration")}),s.jsxs("div",{className:"codex-config-options",children:[s.jsxs("div",{className:"codex-option-group",children:[s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:f.fullAuto!==!1,onChange:e=>E(n=>({...n,fullAuto:e.target.checked}))}),s.jsx("span",{children:a("terminal:spawn.codex.fullAuto")}),s.jsx(x,{text:a("terminal:spawn.helpFullAuto"),title:a("terminal:spawn.fullAutoTitle"),position:"top",size:"sm"})]}),s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:!!f.search,onChange:e=>E(n=>({...n,search:e.target.checked}))}),s.jsx("span",{children:a("terminal:spawn.codex.search")}),s.jsx(x,{text:a("terminal:spawn.helpSearch"),title:a("terminal:spawn.searchTitle"),position:"top",size:"sm"})]})]}),f.fullAuto===!1&&s.jsxs("div",{className:"codex-option-group",children:[s.jsx("div",{className:"codex-option-header",children:a("terminal:spawn.codex.restrictions")}),s.jsxs("select",{className:"spawn-input codex-select",value:f.sandbox||"workspace-write",onChange:e=>E(n=>({...n,sandbox:e.target.value})),children:[s.jsxs("option",{value:"read-only",children:["📖 ",a("terminal:spawn.codex.sandboxReadOnly")]}),s.jsxs("option",{value:"workspace-write",children:["✏️ ",a("terminal:spawn.codex.sandboxWorkspaceWrite")]}),s.jsxs("option",{value:"danger-full-access",children:["⚡ ",a("terminal:spawn.codex.sandboxDangerFullAccess")]})]}),s.jsxs("select",{className:"spawn-input codex-select",value:f.approvalMode||"on-request",onChange:e=>E(n=>({...n,approvalMode:e.target.value})),children:[s.jsxs("option",{value:"untrusted",children:["🔒 ",a("terminal:spawn.codex.approvalsUntrusted")]}),s.jsxs("option",{value:"on-failure",children:["⚠️ ",a("terminal:spawn.codex.approvalsOnFailure")]}),s.jsxs("option",{value:"on-request",children:["🤔 ",a("terminal:spawn.codex.approvalsOnRequest")]}),s.jsxs("option",{value:"never",children:["✅ ",a("terminal:spawn.codex.approvalsNever")]})]})]}),s.jsxs("div",{className:"codex-option-group",children:[s.jsx("div",{className:"codex-option-header",children:a("terminal:spawn.codex.profile")}),s.jsx("input",{type:"text",className:"spawn-input codex-profile-input",placeholder:a("terminal:spawn.codex.profilePlaceholder"),value:f.profile||"",onChange:e=>E(n=>({...n,profile:e.target.value||void 0}))})]}),s.jsxs("div",{className:"codex-option-group",children:[s.jsx("div",{className:"codex-option-header",children:a("terminal:spawn.codex.reasoningEffort")}),s.jsxs("select",{className:"spawn-input codex-select",value:f.reasoningEffort||"",onChange:e=>E(n=>({...n,reasoningEffort:e.target.value||void 0})),children:[s.jsx("option",{value:"",children:a("terminal:spawn.codex.reasoningEffortDefault")}),Object.keys(re).map(e=>s.jsxs("option",{value:e,children:[re[e].icon," ",re[e].label]},e))]})]})]})]}),w.length>0&&s.jsxs("div",{className:"spawn-skills-section",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.skills")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",a("common:labels.optional"),")"]}),s.jsx(x,{text:a("terminal:spawn.helpSkills"),title:a("terminal:spawn.skillsTitle"),position:"top",size:"sm"})]}),w.length>6&&s.jsx("input",{type:"text",className:"spawn-input skill-search-input",placeholder:a("terminal:spawn.filterSkills"),value:D,onChange:e=>ze(e.target.value)}),s.jsxs("div",{className:"spawn-skills-inline",children:[ve.map(e=>{const n=fe.has(e.id);return Ge.some(c=>c.id===e.id)?null:s.jsxs("button",{className:`spawn-skill-chip ${n?"selected":""}`,onClick:()=>We(e.id),title:e.description,children:[n&&s.jsx("span",{className:"spawn-skill-check",children:s.jsx(ie,{name:"check",size:10})}),s.jsx("span",{children:e.name}),e.builtin&&s.jsx("span",{className:"spawn-skill-builtin",children:"TC"})]},e.id)}),D&&ve.length===0&&s.jsx("div",{className:"skill-search-empty",children:a("terminal:spawn.noSkillsMatch",{query:D})})]})]}),s.jsxs("div",{className:"spawn-custom-instructions-section",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.customInstructions")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",a("common:labels.optional"),")"]}),s.jsx(x,{text:a("terminal:spawn.helpCustomInstructions"),title:a("terminal:spawn.customInstructions"),position:"top",size:"sm"})]}),s.jsx("textarea",{className:"spawn-input spawn-textarea",placeholder:a("terminal:spawn.customInstructionsPlaceholder"),value:be,onChange:e=>Ue(e.target.value),rows:3})]}),s.jsxs("div",{className:"spawn-sessions-section",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.linkSession")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",a("common:labels.optional"),")"]}),s.jsx(x,{text:a("terminal:spawn.helpLinkSession"),title:a("terminal:spawn.linkSessionTitle"),position:"top",size:"sm"})]}),y.length>0&&s.jsx("input",{type:"text",className:"spawn-input session-search-input",placeholder:a("terminal:spawn.searchSessions"),value:_,onChange:e=>xe(e.target.value)}),s.jsx("div",{className:"sessions-list",children:$e?s.jsx("div",{className:"sessions-loading",children:a("terminal:spawn.loadingSessions")}):y.length===0?s.jsx("div",{className:"sessions-empty",children:a("terminal:spawn.noSessions")}):Se.length===0?s.jsx("div",{className:"sessions-empty",children:a("terminal:spawn.noSessionsMatch",{query:_})}):Se.map(e=>{const n=A===e.sessionId,l=Date.now()-new Date(e.lastModified).getTime(),c=l<6e4?a("common:time.justNow"):l<36e5?a("common:time.minutesAgo",{count:Math.floor(l/6e4)}):l<864e5?a("common:time.hoursAgo",{count:Math.floor(l/36e5)}):a("common:time.daysAgo",{count:Math.floor(l/864e5)});return s.jsxs("div",{className:`session-item ${n?"selected":""}`,onClick:()=>{n?O(null):(O(e.sessionId),F(e.projectPath))},children:[s.jsxs("div",{className:"session-item-header",children:[s.jsx("span",{className:"session-item-path",children:e.projectPath}),s.jsx("span",{className:"session-item-age",children:c})]}),s.jsx("div",{className:"session-item-preview",children:e.firstMessage||a("terminal:spawn.messagesCount",{count:e.messageCount})})]},e.sessionId)})})]})]})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:j,children:a("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-primary",onClick:Ye,disabled:pe,children:a(pe?"common:buttons.deploying":"common:buttons2.deploy")})]})]})})}export{hs as SpawnModal};
@@ -1,2 +0,0 @@
1
- import{r as a,B as bn,E as Gt,G as sn,H as ln,j as e,J as rn,K as _n,u as Ht,L as wn,M as vn,N as jn,O as Cn,V as Nn,P as yn,U as kn,W as An,X as qt,S as E,Y as Yt,Z as Wt,_ as Kt,$ as jt,a0 as ye,a1 as Sn,s as f,a2 as on,a3 as cn,a4 as En,w as Zt,x as Jt,I as p,a5 as In,n as Mn,a6 as Tn,a7 as dn,a8 as un,a9 as Pn,aa as Ln,ab as Rn,ac as $n,ad as Dn,ae as zn,af as On,ag as Bn,ah as Fn,ai as Wn,aj as Hn,ak as Un,al as Qt,C as Vn,am as Xn,an as en,ao as Gn,ap as qn,aq as Yn,ar as Kn,as as Zn,at as Jn,au as Qn,av as ea,aw as ta,ax as na,ay as aa,az as sa,aA as ia,aB as la,aC as Ke,aD as ra,aE as oa,aF as ca,aG as da,aH as rt,aI as ua,aJ as pa,aK as ma,aL as fa,aM as ha,aN as ga,aO as xa}from"./main-DBurmQCa.js";import{g as ba}from"./area-logos-BHJ2RYkS.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function _a(u){const o=a.useRef(u);o.current=u,a.useEffect(()=>{if(!bn())return;let m=null,h=!1;return Gt.addListener("backButton",()=>{o.current()==="exit"&&Gt.exitApp()}).then(y=>{h?y.remove():m=y}),()=>{h=!0,m&&(m.remove(),m=null)}},[])}async function wa(u){const o=sn(),m=await fetch(`${ln()}/api/agents/${u}/terminal`,{method:"POST",headers:{Authorization:`Bearer ${o}`}});if(!m.ok){const h=await m.json().catch(()=>({}));throw new Error((h==null?void 0:h.error)||`Failed to start terminal (${m.status})`)}return m.json()}async function va(u){const o=sn();await fetch(`${ln()}/api/agents/${u}/terminal`,{method:"DELETE",headers:{Authorization:`Bearer ${o}`}})}const ot=new Map;function ja({agentId:u}){const[o,m]=a.useState(null),[h,y]=a.useState(null);return a.useEffect(()=>{let R=!1;const P=ot.get(u);return P&&(clearTimeout(P),ot.delete(u)),m(null),y(null),wa(u).then(z=>{R||m(z.url)}).catch(z=>{R||y(z instanceof Error?z.message:"Failed to start terminal")}),()=>{R=!0;const z=ot.get(u);z&&clearTimeout(z),ot.set(u,setTimeout(()=>{ot.delete(u),va(u)},2500))}},[u]),h?e.jsx("div",{className:"flat-classic-terminal flat-classic-terminal--message",children:e.jsx("span",{children:h})}):o?e.jsx("div",{className:"flat-classic-terminal",children:e.jsx(rn,{terminalUrl:o,visible:!0})}):e.jsx("div",{className:"flat-classic-terminal flat-classic-terminal--message",children:e.jsx("span",{children:"Attaching to interactive session…"})})}const Ot=new Map,Ca=6e4;function Na({agentId:u,contextSummary:o}){const{t:m}=Ht(["terminal","common"]),[h,y]=a.useState(()=>{var $;return(($=Ot.get(u))==null?void 0:$.snapshot)??null}),[R,P]=a.useState(!1),[z,le]=a.useState(null),_=a.useRef(0);a.useEffect(()=>{const $=Ot.get(u);if($&&Date.now()-$.fetchedAt<Ca){y($.snapshot);return}const U=++_.current;P(!0),le(null),wn(u).then(ee=>{U===_.current&&(Ot.set(u,{snapshot:ee,fetchedAt:Date.now()}),y(ee),P(!1))}).catch(ee=>{U===_.current&&(le(ee.message||"Failed to load plan limits"),P(!1))})},[u]);const O=[];if(h!=null&&h.rateLimits){const $=[{key:"fiveHour",label:m("terminal:usage.currentSession"),window:h.rateLimits.fiveHour},{key:"sevenDay",label:m("terminal:usage.currentWeekAll"),window:h.rateLimits.sevenDay},{key:"sevenDayOpus",label:m("terminal:usage.currentWeekOpus"),window:h.rateLimits.sevenDayOpus},{key:"sevenDaySonnet",label:m("terminal:usage.currentWeekSonnet"),window:h.rateLimits.sevenDaySonnet}];for(const U of $)U.window&&O.push({...U,window:U.window})}return e.jsxs("div",{className:"plan-limits-tooltip",children:[o&&e.jsx("div",{className:"plan-limits-tooltip__context",children:o}),e.jsx("div",{className:"plan-limits-tooltip__title",children:m("terminal:usage.limits")}),R&&!h&&e.jsxs("div",{className:"plan-limits-tooltip__muted",children:[m("common:status.loading"),"…"]}),!R&&z&&!h&&e.jsx("div",{className:"plan-limits-tooltip__muted",children:m("terminal:usage.limitsError",{message:z})}),O.length>0?e.jsx("div",{className:"plan-limits-tooltip__gauges",children:O.map(({key:$,label:U,window:ee})=>{const te=Math.max(0,Math.min(100,ee.utilization)),de=jn(te);return e.jsxs("div",{className:"plan-limits-tooltip__gauge",children:[e.jsxs("div",{className:"plan-limits-tooltip__gauge-head",children:[e.jsx("span",{className:"plan-limits-tooltip__gauge-label",children:U}),e.jsx("span",{className:"plan-limits-tooltip__gauge-percent",style:{color:de},children:m("terminal:usage.percentUsed",{percent:Math.round(te)})})]}),e.jsx("div",{className:"plan-limits-tooltip__bar",children:e.jsx("div",{className:"plan-limits-tooltip__bar-fill",style:{width:`${te}%`,background:de}})}),e.jsx("div",{className:"plan-limits-tooltip__reset",children:m("terminal:usage.resets",{time:vn(ee.resetsAt)})})]},$)})}):h&&!R&&e.jsx("div",{className:"plan-limits-tooltip__muted",children:h.rateLimitsError?m("terminal:usage.limitsError",{message:h.rateLimitsError}):h.cliHint})]})}function ya({agentId:u,disabled:o,contextSummary:m,children:h}){return e.jsx(_n,{position:"top",maxWidth:320,disabled:o,className:"plan-limits-tooltip-wrapper",triggerStyle:{display:"inline-flex",alignItems:"center"},content:e.jsx(Na,{agentId:u,contextSummary:m}),children:h})}const ka=a.memo(function({className:o=""}){const{t:m}=Ht(["common"]),[h,y]=Cn(),R=a.useRef(null),[P,z]=a.useState(null);a.useLayoutEffect(()=>{const _=R.current;if(!_)return;const O=_.querySelector(".view-mode-toggle__btn--active");O&&z({left:O.offsetLeft,width:O.offsetWidth})},[h]);const le=a.useCallback(_=>{if(_!==h){if(typeof window<"u"&&window.dispatchEvent(new CustomEvent("tide:viewmode-switch-pressed",{detail:{mode:_}})),_==="3d"){requestAnimationFrame(()=>y(_));return}y(_)}},[h,y]);return e.jsxs("div",{className:`view-mode-toggle ${o}`,ref:R,children:[P&&e.jsx("div",{className:"view-mode-toggle__indicator",style:{left:P.left,width:P.width}}),Nn.map(_=>e.jsxs("button",{className:`view-mode-toggle__btn ${h===_?"view-mode-toggle__btn--active":""}`,onClick:()=>le(_),title:m(`common:viewMode.descriptions.${_}`),children:[e.jsxs("span",{className:"view-mode-toggle__icon",children:[_==="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"})]}),_==="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"})]}),_==="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"})]}),_==="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:m(`common:viewMode.labels.${_}`)})]},_))]})}),Ct=3,Nt=280,tn=320,Bt=240,nn=64,Aa=["simple","chat","advanced"],Sa={simple:"Simple",chat:"Chat",advanced:"Advanced"},Ea={simple:"○",chat:"◐",advanced:"◉"},Ia={simple:"Simple view — clean messages only",chat:"Chat view — assistant replies (no tool calls)",advanced:"Advanced view — everything including tools"},an="flat-clear-context",pn="tide:flat-embedded-panels";function mn(){try{const u=localStorage.getItem(pn),o=u?JSON.parse(u):{};return o&&typeof o=="object"?o:{}}catch{return{}}}function Ft(u,o){try{const m=mn();o?m[u]=o:delete m[u],localStorage.setItem(pn,JSON.stringify(m))}catch{}}function Ma(u){const o=u.split("/").filter(Boolean);return o.length===0?u:o.slice(-2).join("/")}function Ta(u){if(u.provider==="codex"){const R=u.codexModel||"gpt-5.3-codex",P=ha[R];return{model:(P==null?void 0:P.label)||R}}if(u.provider==="opencode")return{model:u.opencodeModel||"opencode"};const o=u.model||"sonnet",m=xa[o],h=u.effort,y=h?ga[h]:void 0;return{model:(m==null?void 0:m.label)||o,effort:y==null?void 0:y.label}}function Pa(u,o){if(o.type==="rectangle"&&o.width&&o.height){const m=o.width/2,h=o.height/2;return u.x>=o.center.x-m&&u.x<=o.center.x+m&&u.z>=o.center.z-h&&u.z<=o.center.z+h}if(o.type==="circle"&&o.radius){const m=u.x-o.center.x,h=u.z-o.center.z;return m*m+h*h<=o.radius*o.radius}return!1}const La=Xn.memo(function({agentId:o,terminalViewMode:m,onTerminalViewModeChange:h,inspectorOpen:y,onToggleInspector:R,onImageClick:P,onFileClick:z,onBashClick:le,onViewMarkdown:_,onRequestClearSubordinates:O,keyboard:$,canNavigateBack:U,canNavigateForward:ee,onNavigateBack:te,onNavigateForward:de,agentInfoOpen:Be,onToggleAgentInfo:Ze,onHeaderContextMenu:ct,onBuildingContextMenu:K}){var it,xt;const b=en(o),T=cn(),Je=Gn(),re=a.useRef(null),Fe=a.useRef(null),{displayedAgentId:Pe,fadingOut:Qe}=qn(o),dt=en(Pe),We=!!Je.interactiveMode&&((b==null?void 0:b.provider)??"claude")==="claude"&&!!(b!=null&&b.sessionId),[me,Le]=a.useState(!1);a.useEffect(()=>{Le(!1)},[o]),a.useEffect(()=>{!We&&me&&Le(!1)},[We,me]),a.useEffect(()=>{const n=Fe.current;if(!n)return;const r=d=>{d.button===3?(d.preventDefault(),d.stopPropagation(),te()):d.button===4&&(d.preventDefault(),d.stopPropagation(),de())},l=d=>{(d.button===3||d.button===4)&&d.preventDefault()};return n.addEventListener("mouseup",r),n.addEventListener("mousedown",l),()=>{n.removeEventListener("mouseup",r),n.removeEventListener("mousedown",l)}},[te,de]),a.useEffect(()=>{const n=Fe.current;if(!n)return;let r=0,l=0,d=0;const X=250,Q=600,I=80,Ye=1.5,Ne=ie=>{let W=ie instanceof HTMLElement?ie:null;for(;W&&W!==n;){const t=window.getComputedStyle(W).overflowX;if((t==="auto"||t==="scroll")&&W.scrollWidth>W.clientWidth)return!0;W=W.parentElement}return!1},bt=ie=>{const W=Date.now();if(W<d){ie.preventDefault();return}if(Math.abs(ie.deltaX)<=Math.abs(ie.deltaY)*Ye){r=0;return}if(Ne(ie.target)){r=0;return}W-l>X&&(r=0),l=W,r+=ie.deltaX,r<=-I?(r=0,d=W+Q,ie.preventDefault(),te()):r>=I&&(r=0,d=W+Q,ie.preventDefault(),de())};return n.addEventListener("wheel",bt,{passive:!1}),()=>n.removeEventListener("wheel",bt)},[te,de]);const et=on(),ke=a.useMemo(()=>{if(!b)return null;const n=new Set,r=[];for(const l of et.values())l.archived||l.directories.length===0||l.assignedAgentIds.includes(o)&&(n.add(l.id),r.push(l));for(const l of et.values())l.archived||l.directories.length===0||n.has(l.id)||Pa({x:b.position.x,z:b.position.z},l)&&(n.add(l.id),r.push(l));return r.length===0?null:r.flatMap(l=>l.directories.filter(d=>d&&d.trim().length>0).map(d=>({areaId:l.id,areaName:l.name,dir:d})))},[b,o,et]),{branches:Ae,fetchRemote:fe,fetchingDirs:he}=Yn(ke),He=a.useMemo(()=>{var l;const n=f.getAreaForAgent(o);if(!n)return[];const r=[];for(const d of T.values())d.type==="terminal"&&f.isPositionInArea(d.position,n)&&r.push({id:d.id,name:d.name,hasUrl:!!((l=d.terminalStatus)!=null&&l.url)});return r},[o,T]),Ue=a.useMemo(()=>{var l;const n=f.getAreaForAgent(o);if(!n)return[];const r=[];for(const d of T.values())d.type==="server"&&((l=d.pm2)!=null&&l.enabled)&&f.isPositionInArea(d.position,n)&&r.push({id:d.id,name:d.name});return r},[o,T]),ge=a.useMemo(()=>{const n=f.getAreaForAgent(o);if(!n)return[];const r=[];for(const l of T.values())l.type==="database"&&l.database&&f.isPositionInArea(l.position,n)&&r.push({id:l.id,name:l.name});return r},[o,T]),Se=Kn(),ue=a.useMemo(()=>{const n=f.getAreaForAgent(o);if(!n)return[];const r=[];for(const l of T.values())if(l.type==="tests"&&f.isPositionInArea(l.position,n)){const d=!!l.folderPath&&Se.some(X=>Zn(X,l.folderPath));r.push({id:l.id,name:l.name,working:d})}return r},[o,T,Se]),xe=a.useMemo(()=>{const n=f.getAreaForAgent(o);if(!n)return[];const r=[];for(const l of T.values())l.type==="http"&&f.isPositionInArea(l.position,n)&&r.push({id:l.id,name:l.name});return r},[o,T]),[,pe]=a.useReducer(n=>n+1,0),be=((it=re.current)==null?void 0:it.search.searchMode)??!1,Ee=a.useCallback(()=>{var n;(n=re.current)==null||n.search.toggleSearch(),pe()},[]),_e=Jn(),tt=_e.isPending(an),[j,we]=a.useState(null),B=j?T.get(j.buildingId):null,[ut,Ie]=a.useState(""),[ve,yt]=a.useState(()=>Qn()),D=a.useMemo(()=>{var n;return((n=f.getAreaForAgent(o))==null?void 0:n.id)??null},[o,T]),Re=a.useCallback((n,r)=>{Ie(""),we(l=>{const d=(l==null?void 0:l.buildingId)===r?null:{type:n,buildingId:r};return D&&Ft(D,d),d})},[D]),oe=a.useCallback(()=>{Ie(""),we(null),D&&Ft(D,null)},[D]);a.useEffect(()=>{if((j==null?void 0:j.type)!=="pm2-logs")return;const n=j.buildingId;return f.startLogStreaming(n,200),()=>f.stopLogStreaming(n)},[j]);const{height:kt,onResizeStart:At}=ea(),{sidePanelWidth:St,handleSidePanelResizeStart:Et}=ta(),[$e,pt]=a.useState(()=>Wt(E.GIT_PANEL_OPEN,!1)),[je,v]=a.useState(()=>Wt(E.BUILDINGS_PANEL_OPEN,!1)),[Z,ne]=a.useState(!1),Ve=a.useCallback(()=>{ne(n=>{const r=!n;return r&&na.setEnabled(!0),r})},[]),mt=a.useCallback(()=>ne(!1),[]),It=a.useCallback(()=>{pt(n=>{const r=!n;return ye(E.GIT_PANEL_OPEN,r),r})},[]),Mt=a.useCallback(()=>{v(n=>{const r=!n;return ye(E.BUILDINGS_PANEL_OPEN,r),r})},[]),Tt=a.useCallback(()=>{pt(!1),ye(E.GIT_PANEL_OPEN,!1)},[]),Pt=a.useCallback(()=>{v(!1),ye(E.BUILDINGS_PANEL_OPEN,!1)},[]),nt=aa(),ae=a.useMemo(()=>({terminal:He,"pm2-logs":Ue,database:ge,tests:ue,http:xe}),[He,Ue,ge,ue,xe]);a.useEffect(()=>{if(!j)return;ae[j.type].some(r=>r.id===j.buildingId)||(Ie(""),we(null))},[j,ae]);const Xe=a.useRef(void 0);a.useEffect(()=>{var r;if(Xe.current===D)return;Xe.current=D;const n=D?mn()[D]:void 0;Ie(""),n&&((r=ae[n.type])!=null&&r.some(l=>l.id===n.buildingId))?we(n):we(null)},[D,ae]),a.useEffect(()=>{const n=r=>{var X;const l=r.detail;if(!(l!=null&&l.buildingId)||!(l!=null&&l.type)||!((X=ae[l.type])!=null&&X.some(Q=>Q.id===l.buildingId)))return;l.handled=!0,Ie("");const d={type:l.type,buildingId:l.buildingId};we(d),D&&Ft(D,d)};return window.addEventListener("tide:dock-building-flat",n),()=>window.removeEventListener("tide:dock-building-flat",n)},[ae,D]);const[se,Me]=a.useState(!1),J=a.useRef(null);if(a.useEffect(()=>{if(!se)return;const n=r=>{J.current&&!J.current.contains(r.target)&&Me(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[se]),!b)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 V=b.contextStats,at=!!V,ft=V?V.totalTokens:b.contextUsed||0,Ge=V?V.contextWindow:b.contextLimit||2e5,ht=V?V.usedPercent:Math.round(ft/Ge*100),Te=Math.max(0,Math.min(100,ht)),gt=Math.round(Te*10)/10,Lt=Math.round((100-Te)*10)/10,ce=Te>=80?"#ff4a4a":Te>=60?"#ff9e4a":Te>=40?"#ffd700":"#4aff9e",De=(ft/1e3).toFixed(1),qe=(Ge/1e3).toFixed(1),Ce=b.cwd,st=Ce?Ma(Ce):null,ze=((xt=b.subordinateIds)==null?void 0:xt.length)||0,Rt=ze>0;return e.jsxs("div",{ref:Fe,className:`flat-terminal-wrapper ${$e||je||Z?"flat-terminal-wrapper--with-side-panel":""} ${Qe?"pane-fading-out":""}`,style:{"--guake-side-panel-width":`min(${St}px, 70%)`},children:[e.jsxs("div",{className:"flat-terminal-wrapper__header",children:[e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__header-main ${Be?"flat-terminal-wrapper__header-main--active":""}`,onClick:Ze,onContextMenu:n=>{n.preventDefault(),n.stopPropagation(),ct({x:n.clientX,y:n.clientY})},title:Be?"Hide agent info":"Show agent info","aria-pressed":Be,children:[e.jsx(dn,{agent:b,size:28}),e.jsxs("span",{className:"flat-terminal-wrapper__header-info",children:[e.jsx("span",{className:"flat-terminal-wrapper__header-name",children:b.name}),e.jsx("span",{className:"flat-terminal-wrapper__header-status",style:{color:un(b.status)},children:b.status})]}),b.taskLabel&&e.jsxs("span",{className:"flat-terminal-wrapper__header-task",title:b.taskLabel,children:["📋 ",b.taskLabel]}),e.jsxs("span",{className:"flat-terminal-wrapper__header-model",children:[e.jsx("img",{src:b.provider==="codex"?"/assets/codex.png":b.provider==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:b.provider,className:"flat-terminal-wrapper__header-provider-icon",title:b.provider==="codex"?"Codex Agent":b.provider==="opencode"?"OpenCode Agent":"Claude Agent"}),(()=>{const{model:n,effort:r}=Ta(b);return e.jsxs("span",{className:"flat-terminal-wrapper__header-model-chip",title:r?`Model: ${n} · Effort: ${r}`:`Model: ${n}`,children:[e.jsx("span",{className:"flat-terminal-wrapper__header-model-name",children:n}),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.jsxs("div",{className:"flat-terminal-wrapper__view-mode",role:"group","aria-label":"Message view mode",children:[Aa.map(n=>e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__view-mode-btn ${!me&&m===n?"flat-terminal-wrapper__view-mode-btn--active":""}`,onClick:()=>{Le(!1),h(n)},title:Ia[n],"aria-pressed":!me&&m===n,children:[e.jsx("span",{className:"flat-terminal-wrapper__view-mode-icon","aria-hidden":"true",children:Ea[n]}),e.jsx("span",{className:"flat-terminal-wrapper__view-mode-label",children:Sa[n]})]},n)),We&&e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__view-mode-btn ${me?"flat-terminal-wrapper__view-mode-btn--active":""}`,onClick:()=>Le(n=>!n),title:"Classic TUI — attach to the live interactive claude session in a terminal","aria-pressed":me,children:[e.jsx("span",{className:"flat-terminal-wrapper__view-mode-icon","aria-hidden":"true",children:e.jsx(p,{name:"terminal",size:13})}),e.jsx("span",{className:"flat-terminal-wrapper__view-mode-label",children:"Classic TUI"})]})]}),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:te,disabled:!U,title:"Back to previous agent","aria-label":"Back to previous agent",children:e.jsx(p,{name:"arrow-left",size:14})}),e.jsx("button",{type:"button",className:"flat-terminal-wrapper__action-btn",onClick:de,disabled:!ee,title:"Forward to next agent","aria-label":"Forward to next agent",children:e.jsx(p,{name:"arrow-right",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${be?"flat-terminal-wrapper__action-btn--active":""}`,onClick:Ee,title:be?"Close search":"Search messages","aria-pressed":be,children:e.jsx(p,{name:be?"cross":"search",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn flat-terminal-wrapper__action-btn--danger ${tt?"flat-terminal-wrapper__action-btn--confirm":""}`,onClick:()=>_e.handleClick(an,()=>{var n;f.clearContext(o),(n=re.current)==null||n.historyLoader.clearHistory()}),title:tt?"Click again to confirm clear context":"Clear context",children:e.jsx(p,{name:tt?"question":"clear",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${$e?"flat-terminal-wrapper__action-btn--active":""}`,onClick:It,title:$e?"Hide git panel":"Show git changes","aria-pressed":$e,children:e.jsx(p,{name:"git-branch",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${je?"flat-terminal-wrapper__action-btn--active":""}`,onClick:Mt,title:je?"Hide buildings panel":"Show area buildings","aria-pressed":je,children:e.jsx(p,{name:"buildings",size:14})}),e.jsxs("div",{className:"flat-terminal-wrapper__more",ref:J,children:[e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${se?"flat-terminal-wrapper__action-btn--active":""}`,onClick:()=>Me(n=>!n),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 ${Z?"flat-terminal-wrapper__more-item--active":""}`,onClick:()=>{Ve(),Me(!1)},title:Z?"Hide Debug Panel":"Show Debug Panel",children:[e.jsx(p,{name:"bug",size:14}),e.jsx("span",{children:Z?"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:()=>{f.collapseContext(o),Me(!1)},disabled:b.status!=="idle",title:b.status!=="idle"?"Agent must be idle to collapse context":"Collapse context",children:[e.jsx(p,{name:"package",size:14}),e.jsx("span",{children:"Collapse context"})]}),Rt&&e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item flat-terminal-wrapper__more-item--danger",onClick:()=>{O(o,ze),Me(!1)},children:[e.jsx(p,{name:"crown",size:14}),e.jsxs("span",{children:["Clear ",ze," subordinate",ze===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:()=>{f.killAgent(o),Me(!1)},children:[e.jsx(p,{name:"cross",size:14}),e.jsx("span",{children:"Remove agent"})]})]})]})]}),e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__inspector-toggle ${y?"flat-terminal-wrapper__inspector-toggle--active":""}`,onClick:R,title:y?"Hide inspector panel":"Show inspector panel","aria-label":y?"Hide inspector panel":"Show inspector panel","aria-pressed":y,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:()=>f.deselectAll(),title:"Close chat","aria-label":"Close chat",children:e.jsx(p,{name:"cross",size:14})})]})]}),me&&We?e.jsx(ja,{agentId:o}):Pe&&dt?e.jsx(sa,{ref:re,agentId:Pe,agent:dt,viewMode:m,isOpen:!0,onImageClick:P,onFileClick:z,onBashClick:le,onViewMarkdown:_,keyboard:$,hasModalOpen:!1},Pe):null,j&&B&&(()=>{var X,Q;const n=j.type,r={terminal:"terminal","pm2-logs":"scroll",database:"hard-drives",tests:"flask",http:"globe"},l=n==="terminal"&&!((X=B.terminalStatus)!=null&&X.url),d=!l;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"guake-bottom-terminal-resize",onMouseDown:At,role:"separator","aria-orientation":"horizontal","aria-label":"Resize embedded panel"}),e.jsxs("div",{className:"flat-bottom-panel",role:"region","aria-label":`${B.name} panel`,style:{height:kt},children:[e.jsxs("div",{className:"flat-bottom-panel__header",children:[e.jsxs("span",{className:"flat-bottom-panel__title",children:[e.jsx(p,{name:r[n],size:12}),e.jsx("span",{children:B.name}),l&&e.jsx("span",{className:"flat-bottom-panel__muted",children:"(starting...)"})]}),e.jsxs("span",{className:"flat-bottom-panel__header-actions",children:[n==="pm2-logs"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",className:"guake-bottom-terminal-filter",value:ut,onChange:I=>Ie(I.target.value),placeholder:"Filter logs","aria-label":`Filter logs for ${B.name}`,spellCheck:!1}),e.jsx("select",{className:"guake-bottom-terminal-retention",value:ve===null?"unlimited":String(ve),onChange:I=>{const Ye=I.target.value==="unlimited"?null:Number(I.target.value);yt(Ye),la(Ye)},"aria-label":`Max log retention for ${B.name}`,children:ia.map(I=>e.jsx("option",{value:I===null?"unlimited":String(I),children:I===null?"Unlimited":`${I.toLocaleString()} lines`},I===null?"unlimited":I))}),e.jsx("button",{type:"button",className:"flat-bottom-panel__close",onClick:()=>f.clearStreamingLogs(j.buildingId),title:"Clear logs",children:e.jsx(p,{name:"trash",size:12})}),e.jsx("button",{type:"button",className:"flat-bottom-panel__close",onClick:()=>f.sendBuildingCommand(j.buildingId,"restart"),title:"Restart",children:e.jsx(p,{name:"restart",size:12})})]}),d&&e.jsx("button",{type:"button",className:"flat-bottom-panel__close",onClick:()=>{oe(),Ke(j.buildingId)},title:"Maximize — open as modal","aria-label":"Open as modal",children:e.jsx(p,{name:"fullscreen",size:12})}),e.jsx("button",{type:"button",className:"flat-bottom-panel__close",onClick:oe,title:"Close panel","aria-label":"Close panel",children:e.jsx(p,{name:"cross",size:12})})]})]}),e.jsx("div",{className:"flat-bottom-panel__body",children:n==="terminal"?(Q=B.terminalStatus)!=null&&Q.url?e.jsx(rn,{terminalUrl:B.terminalStatus.url,visible:!0}):e.jsx("div",{className:"flat-bottom-panel__placeholder",children:"Starting terminal..."}):n==="pm2-logs"?e.jsx(ra,{buildingId:j.buildingId,filterText:ut,maxRetention:ve}):n==="database"?e.jsx(oa,{building:B}):n==="tests"?e.jsx("div",{className:"tests-panel-host",children:e.jsx(ca,{building:B,autoFocusSearch:!1})}):e.jsx("div",{className:"http-requests-panel-host",children:e.jsx(da,{building:B,autoFocusSearch:!1})})})]})]})})(),e.jsxs("div",{className:"flat-terminal-wrapper__statusbar",role:"contentinfo",children:[b.isDetached&&e.jsxs("span",{className:"flat-terminal-wrapper__detached",title:"Reattaching session...",children:[e.jsx(p,{name:"refresh",size:12}),e.jsx("span",{children:"Reattaching"})]}),Ce&&st&&e.jsxs("span",{className:"flat-terminal-wrapper__cwd",title:`Open in file explorer: ${Ce}`,"aria-label":`Open ${Ce} in file explorer`,role:"button",tabIndex:0,onClick:()=>f.openFileExplorer(Ce),onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),f.openFileExplorer(Ce))},children:[e.jsx("span",{className:"flat-terminal-wrapper__cwd-icon",children:e.jsx(p,{name:"folder",size:12})}),e.jsx("span",{className:"flat-terminal-wrapper__cwd-text",children:st})]}),ke&&ke.map(({areaId:n,areaName:r,dir:l})=>{const d=Ae.get(l),X=he.has(l),Q=l.split("/").filter(Boolean).pop()||l;return e.jsxs("span",{className:"flat-terminal-wrapper__area-dir",title:`${r}: ${l}${d?` (${d.branch}${d.ahead?` ↑${d.ahead}`:""}${d.behind?` ↓${d.behind}`:""})`:""}`,onClick:()=>f.openFileExplorerForAreaFolder(n,l),children:[e.jsx(p,{name:"folder-open",size:12}),e.jsx("span",{className:"flat-terminal-wrapper__area-dir-name",children:Q}),d&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flat-terminal-wrapper__area-dir-branch",children:[e.jsx(p,{name:"git-branch",size:10})," ",d.branch]}),d.ahead>0&&e.jsxs("span",{className:"flat-terminal-wrapper__branch-ahead",title:`${d.ahead} ahead`,children:[e.jsx(p,{name:"arrow-up",size:9}),d.ahead]}),d.behind>0&&e.jsxs("span",{className:"flat-terminal-wrapper__branch-behind",title:`${d.behind} behind`,children:[e.jsx(p,{name:"arrow-down",size:9}),d.behind]}),e.jsx("span",{className:`flat-terminal-wrapper__area-fetch ${X?"flat-terminal-wrapper__area-fetch--fetching":""}`,title:"Git fetch",onClick:I=>{I.stopPropagation(),fe(l)},children:e.jsx(p,{name:X?"hourglass":"download",size:12})})]})]},`${n}:${l}`)}),e.jsx(ya,{agentId:o,disabled:((b==null?void 0:b.provider)??"claude")!=="claude",contextSummary:at?`Context: ${De}k / ${qe}k tokens (${gt}% used)`:void 0,children:e.jsxs("span",{className:"flat-terminal-wrapper__context",tabIndex:0,role:"button",onClick:()=>f.setContextModalAgentId(o),onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),f.setContextModalAgentId(o))},title:((b==null?void 0:b.provider)??"claude")!=="claude"?at?`Context usage: ${De}k / ${qe}k tokens (${gt}% used). Click to view stats.`:"Click to fetch context stats":void 0,children:[e.jsx("span",{className:"flat-terminal-wrapper__context-icon",children:e.jsx(p,{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:`${Te}%`,backgroundColor:ce}})}),e.jsxs("span",{className:"flat-terminal-wrapper__context-tokens",style:{color:ce},children:[De,"k/",qe,"k"]}),e.jsxs("span",{className:"flat-terminal-wrapper__context-free",children:["(",Lt,"% free)"]}),!at&&e.jsx("span",{className:"flat-terminal-wrapper__context-warning",title:"No context stats yet",children:e.jsx(p,{name:"warn",size:12})})]})}),e.jsx("div",{className:"flat-terminal-wrapper__statusbar-spacer","aria-hidden":"true"}),He.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area terminals",children:He.map(n=>{const r=(j==null?void 0:j.buildingId)===n.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${r?"flat-terminal-wrapper__building-btn--active":""} ${n.hasUrl?"":"flat-terminal-wrapper__building-btn--offline"}`,title:`${r?"Hide":"Show"} terminal: ${n.name}${n.hasUrl?"":" (starting...)"}`,onClick:()=>{if(r){oe();return}if(n.hasUrl&&rt(n.id)==="modal"){Ke(n.id);return}n.hasUrl||f.sendBuildingCommand(n.id,"start"),Re("terminal",n.id)},onContextMenu:l=>{l.preventDefault(),l.stopPropagation(),K(n.id,{x:l.clientX,y:l.clientY})},children:e.jsx(p,{name:"terminal",size:14})},n.id)})}),Ue.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area PM2 logs",children:Ue.map(n=>{const r=(j==null?void 0:j.buildingId)===n.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${r?"flat-terminal-wrapper__building-btn--active":""}`,title:`${r?"Hide":"Show"} logs: ${n.name}`,onClick:()=>{r?oe():rt(n.id)==="modal"?Ke(n.id):Re("pm2-logs",n.id)},onContextMenu:l=>{l.preventDefault(),l.stopPropagation(),K(n.id,{x:l.clientX,y:l.clientY})},children:e.jsx(p,{name:"scroll",size:14})},n.id)})}),ge.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area databases",children:ge.map(n=>{const r=(j==null?void 0:j.buildingId)===n.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${r?"flat-terminal-wrapper__building-btn--active":""}`,title:`${r?"Hide":"Show"} database: ${n.name}`,onClick:()=>{r?oe():rt(n.id)==="modal"?Ke(n.id):Re("database",n.id)},onContextMenu:l=>{l.preventDefault(),l.stopPropagation(),K(n.id,{x:l.clientX,y:l.clientY})},children:e.jsx(p,{name:"hard-drives",size:14})},n.id)})}),ue.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area tests",children:ue.map(n=>{const r=(j==null?void 0:j.buildingId)===n.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${r?"flat-terminal-wrapper__building-btn--active":""} ${n.working?"flat-terminal-wrapper__building-btn--tests-working":""}`,title:n.working?`Running tests: ${n.name}`:`${r?"Hide":"Show"} tests: ${n.name}`,onClick:()=>{r?oe():rt(n.id)==="modal"?Ke(n.id):Re("tests",n.id)},onContextMenu:l=>{l.preventDefault(),l.stopPropagation(),K(n.id,{x:l.clientX,y:l.clientY})},children:e.jsx(p,{name:"flask",size:14})},n.id)})}),xe.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area HTTP requests",children:xe.map(n=>{const r=(j==null?void 0:j.buildingId)===n.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${r?"flat-terminal-wrapper__building-btn--active":""}`,title:`${r?"Hide":"Show"} HTTP requests: ${n.name}`,onClick:()=>{r?oe():rt(n.id)==="modal"?Ke(n.id):Re("http",n.id)},onContextMenu:l=>{l.preventDefault(),l.stopPropagation(),K(n.id,{x:l.clientX,y:l.clientY})},children:e.jsx(p,{name:"globe",size:14})},n.id)})}),e.jsx("div",{className:"flat-terminal-wrapper__theme",children:e.jsx(ua,{})})]}),$e&&e.jsx(pa,{agentId:o,agents:nt,onClose:Tt,branchInfoMap:Ae,fetchRemote:fe,fetchingDirs:he,onResizeStart:n=>Et(n,"right")}),je&&e.jsx(ma,{agentId:o,onClose:Pt}),Z&&e.jsx(fa,{agentId:o,onClose:mt})]})});function Oa({onAgentClick:u,onBuildingClick:o,onBuildingDoubleClick:m,onBuildingPopup:h,onAreaContextMenu:y,onOpenSpawnModal:R,onOpenBossSpawnModal:P,onOpenAreaModal:z}){const{t:le}=Ht(["common"]),_=yn(),O=kn(),[$,U]=a.useState(null),[ee,te]=a.useState(null),[de,Be]=a.useState(null);An("flatview-image-modal",$!==null,()=>U(null));const[Ze,ct]=a.useState(null),[K,b]=a.useState(null),[T,Je]=a.useState(null),[re,Fe]=a.useState(null),[Pe,Qe]=a.useState(!1),dt=a.useCallback(()=>{Qe(t=>!t)},[]),We=a.useCallback(()=>{Qe(!1)},[]),[me,Le]=a.useState(()=>{const t=qt(E.VIEW_MODE);return t==="simple"||t==="chat"||t==="advanced"?t:"simple"}),et=a.useCallback(t=>{Le(t),Yt(E.VIEW_MODE,t)},[]);a.useEffect(()=>{const t=s=>{if(s.key!==E.VIEW_MODE)return;const i=s.newValue;(i==="simple"||i==="chat"||i==="advanced")&&Le(i)};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)},[]);const[ke,Ae]=a.useState(()=>Wt(E.FLAT_INSPECTOR_OPEN,!1)),[fe,he]=a.useState(!1),He=a.useCallback(()=>he(t=>!t),[]),Ue=a.useCallback(()=>he(!1),[]);a.useEffect(()=>{window.dispatchEvent(new CustomEvent("tide-flat-agents-drawer-state",{detail:{open:fe}}))},[fe]),a.useEffect(()=>{window.dispatchEvent(new CustomEvent("tide-flat-inspector-state",{detail:{open:ke}}))},[ke]),a.useEffect(()=>{const t=()=>he(C=>!C),s=()=>{Ae(C=>{const k=!C;return ye(E.FLAT_INSPECTOR_OPEN,k),k})},i=()=>{he(!1),Ae(!1),ye(E.FLAT_INSPECTOR_OPEN,!1)},g=()=>he(!1),x=()=>{Ae(!1),ye(E.FLAT_INSPECTOR_OPEN,!1)};return window.addEventListener("tide-toggle-flat-agents-drawer",t),window.addEventListener("tide-toggle-flat-inspector",s),window.addEventListener("tide-close-flat-side-views",i),window.addEventListener("tide-close-flat-agents-drawer-only",g),window.addEventListener("tide-close-flat-inspector-only",x),()=>{window.removeEventListener("tide-toggle-flat-agents-drawer",t),window.removeEventListener("tide-toggle-flat-inspector",s),window.removeEventListener("tide-close-flat-side-views",i),window.removeEventListener("tide-close-flat-agents-drawer-only",g),window.removeEventListener("tide-close-flat-inspector-only",x)}},[]);const ge=a.useRef(null),Se=a.useRef(null),[ue,xe]=a.useState(()=>{const t=Kt(E.FLAT_MIDDLE_WIDTH,0);return t>=Nt?t:null}),[pe,be]=a.useState(()=>{const t=Kt(E.FLAT_INSPECTOR_WIDTH,0);return t>=Bt?t:null}),Ee=a.useCallback(t=>{if(typeof window>"u")return t;const s=pe!==null?Ct+pe:0,i=window.innerWidth-nn-Ct-tn-s;return Math.max(Nt,Math.min(Math.max(i,Nt),t))},[pe]),_e=a.useCallback(t=>{var x;if(typeof window>"u")return t;const s=(x=ge.current)==null?void 0:x.querySelector(".flat-middle"),i=(s==null?void 0:s.getBoundingClientRect().width)??Nt,g=window.innerWidth-nn-i-Ct-tn-Ct;return Math.max(Bt,Math.min(Math.max(g,Bt),t))},[]);a.useEffect(()=>{if(ue===null&&pe===null)return;const t=()=>{xe(s=>{if(s===null)return s;const i=Ee(s);return i===s?s:i}),be(s=>{if(s===null)return s;const i=_e(s);return i===s?s:i})};return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[ue,pe,Ee,_e]);const tt=a.useCallback(t=>{var i;if(t.button!==0)return;const s=(i=ge.current)==null?void 0:i.querySelector(".flat-middle");s&&(t.currentTarget.setPointerCapture(t.pointerId),Se.current={kind:"middle",startX:t.clientX,startWidth:s.getBoundingClientRect().width,pointerId:t.pointerId},document.body.classList.add("flat-splitter-dragging"))},[]),j=a.useCallback(t=>{var i;if(t.button!==0)return;const s=(i=ge.current)==null?void 0:i.querySelector(".flat-inspector");s&&(t.currentTarget.setPointerCapture(t.pointerId),Se.current={kind:"inspector",startX:t.clientX,startWidth:s.getBoundingClientRect().width,pointerId:t.pointerId},document.body.classList.add("flat-splitter-dragging"))},[]),we=a.useCallback(t=>{const s=Se.current;if(!s||t.pointerId!==s.pointerId)return;const i=t.clientX-s.startX;s.kind==="middle"?xe(Ee(s.startWidth+i)):be(_e(s.startWidth-i))},[Ee,_e]),B=a.useCallback(t=>{const s=Se.current;if(!s||t.pointerId!==s.pointerId)return;try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}if(Se.current=null,document.body.classList.remove("flat-splitter-dragging"),!(Math.abs(t.clientX-s.startX)>2))return;const g=t.clientX-s.startX;if(s.kind==="middle"){const x=Ee(s.startWidth+g);xe(x),jt(E.FLAT_MIDDLE_WIDTH,x)}else{const x=_e(s.startWidth-g);be(x),jt(E.FLAT_INSPECTOR_WIDTH,x)}},[Ee,_e]),ut=a.useCallback(()=>{xe(null),jt(E.FLAT_MIDDLE_WIDTH,0)},[]),Ie=a.useCallback(()=>{be(null),jt(E.FLAT_INSPECTOR_WIDTH,0)},[]),[ve,yt]=a.useState(()=>qt(E.FLAT_INSPECTOR_VIEW)==="tracking"?"tracking":"agent"),D=a.useCallback(t=>{yt(t),Yt(E.FLAT_INSPECTOR_VIEW,t)},[]),Re=a.useCallback(()=>{Ae(t=>{const s=!t;return ye(E.FLAT_INSPECTOR_OPEN,s),s})},[]),oe=a.useCallback(()=>{Ae(!1),ye(E.FLAT_INSPECTOR_OPEN,!1)},[]),kt=Sn(),At=a.useCallback((t,s)=>{U({url:t,name:s})},[]),St=a.useCallback((t,s)=>{te({command:t,output:s,isLive:!1})},[]),Et=a.useCallback((t,s)=>{var x;const i=O.size>0?Array.from(O)[0]:null,g=i?(x=f.getState().agents.get(i))==null?void 0:x.cwd:void 0;f.setFileViewerPath(t,s,g)},[O]),$e=a.useCallback(t=>{Be(t)},[]),pt=a.useCallback((t,s)=>{ct({agentId:t,count:s})},[]),je=a.useCallback(t=>{m?m(t):o(t)},[o,m]),v=a.useMemo(()=>O.size>0?Array.from(O)[0]:null,[O]);a.useEffect(()=>{Qe(!1)},[v]);const Z=a.useRef([]),ne=a.useRef(-1),Ve=a.useRef(!1),mt=a.useRef(null),[It,Mt]=a.useState(!1),[Tt,Pt]=a.useState(!1),nt=a.useRef(!1),ae=a.useRef(null),Xe=a.useRef(!1),se=a.useMemo(()=>new Set(_.map(t=>t.id)),[_]),Me=a.useMemo(()=>{const t=new Map(_.map(i=>[i.id,i])),s=new Map;for(const i of _)if((i.isBoss||i.class==="boss")&&i.subordinateIds&&i.subordinateIds.length>0){const g=i.subordinateIds.map(x=>t.get(x)).filter(x=>x!==void 0);g.length>0&&s.set(i.id,g)}return s},[_]),J=a.useCallback(()=>{const t=Z.current,s=ne.current;Mt(s>0),Pt(s>=0&&s<t.length-1)},[]),V=a.useCallback(t=>{const s=Z.current;if(s.length===0)return;let i=ne.current+t;for(;i>=0&&i<s.length;){const g=s[i];if(se.has(g)){Ve.current=!0,ne.current=i,J(),f.selectAgent(g);return}i+=t}},[se,J]),at=a.useCallback(()=>V(-1),[V]),ft=a.useCallback(()=>V(1),[V]);_a(a.useCallback(()=>{const t=Z.current,s=ne.current;return t.length>0&&s>0?(V(-1),"handled"):"exit"},[V]));const Ge=a.useCallback((t,s)=>{if(typeof window>"u")return;const i=window.history.state,x={...typeof i=="object"&&i!==null?i:{},__flatAgentNav:{agentId:t}};s==="replace"?window.history.replaceState(x,"",window.location.href):window.history.pushState(x,"",window.location.href)},[]);a.useEffect(()=>{if(!v){nt.current=!1,ae.current=null;return}if(!nt.current){Ge(v,"replace"),nt.current=!0,ae.current=v;return}if(Xe.current){Xe.current=!1,ae.current=v;return}ae.current!==v&&(Ge(v,"push"),ae.current=v)},[v,Ge]),a.useEffect(()=>{const t=s=>{var C,k;const i=(k=(C=s.state)==null?void 0:C.__flatAgentNav)==null?void 0:k.agentId;if(!i||typeof i!="string"||!se.has(i)||i===v)return;Xe.current=!0,Ve.current=!0;const g=Z.current,x=g.lastIndexOf(i);x>=0?ne.current=x:(g.push(i),ne.current=g.length-1),J(),f.selectAgent(i)};return window.addEventListener("popstate",t),()=>window.removeEventListener("popstate",t)},[se,v,J]),a.useEffect(()=>{if(!v){Z.current=[],ne.current=-1,J();return}if(mt.current=v,Ve.current){Ve.current=!1,J();return}const t=Z.current,s=ne.current;if(s>=0&&t[s]===v){J();return}const i=s<t.length-1?t.slice(0,s+1):t.slice();i.push(v),i.length>100&&i.shift(),Z.current=i,ne.current=i.length-1,J()},[v,J]);const ht=a.useCallback(t=>{u(t),he(!1)},[u]),Te=v??"",gt=a.useCallback(()=>{},[]),Lt=a.useCallback(t=>{ht(t)},[ht]),ce=ke,[De,qe]=a.useState(ce),[Ce,st]=a.useState(ce);a.useEffect(()=>{if(ce){qe(!0);return}st(!1);const t=setTimeout(()=>qe(!1),240);return()=>clearTimeout(t)},[ce]),a.useEffect(()=>{if(!De||!ce)return;let t=0;const s=requestAnimationFrame(()=>{t=requestAnimationFrame(()=>st(!0))});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(t)}},[De,ce]);const ze=a.useRef(null);a.useEffect(()=>{if(v)return;const t=s=>{if(s.key!==" "&&s.key!=="Backspace")return;const i=s.target;if(i.tagName==="INPUT"||i.tagName==="TEXTAREA"||i.isContentEditable)return;const g=mt.current;!g||!se.has(g)||(s.preventDefault(),f.selectAgent(g))};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[v,se]);const[Rt,it]=a.useState(new Set),xt=a.useCallback(t=>{it(s=>{const i=new Set(s);return i.has(t)?i.delete(t):i.add(t),i})},[]),[n,r]=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)"),s=i=>r(i.matches);return t.addEventListener("change",s),()=>t.removeEventListener("change",s)},[]);const[l,d]=a.useState(null),X=a.useCallback(t=>{d(s=>s===t?null:t)},[]),Q=on(),I=cn(),[Ye]=En(),Ne=a.useMemo(()=>{const t=new Map,s=[];for(const w of _){const S=f.getAreaForAgent(w.id);if(!Zt((S==null?void 0:S.id)??null))continue;if(!S||S.archived){s.push(w);continue}const M=t.get(S.id);M?M.push(w):t.set(S.id,[w])}const i=new Map,g=[];for(const w of I.values()){let S=!1;for(const M of Q.values())if(!M.archived&&Jt(M.id)&&f.isPositionInArea(w.position,M)){const G=i.get(M.id);G?G.push(w):i.set(M.id,[w]),S=!0;break}!S&&Zt(null)&&g.push(w)}const x=[];for(const[,w]of Q){if(w.archived||!Jt(w.id))continue;const S=t.get(w.id),M=i.get(w.id)??[];(S&&S.length>0||M.length>0)&&x.push({area:w,agents:S??[],buildings:M})}(s.length>0||g.length>0)&&x.push({area:{id:"__unassigned__",name:"Unassigned",color:"#6272a4",center:{x:0,z:0},type:"circle",radius:0,directories:[],archived:!1,assignedAgentIds:[],zIndex:0},agents:s,buildings:g});const C=x.filter(w=>w.area.id!=="__unassigned__"),k=x.filter(w=>w.area.id==="__unassigned__");let c=1,A=1;const H=new Map;if(C.length>1){let w=1/0,S=-1/0,M=1/0,G=-1/0;for(const q of C)w=Math.min(w,q.area.center.x),S=Math.max(S,q.area.center.x),M=Math.min(M,q.area.center.z),G=Math.max(G,q.area.center.z);const _t=S-w||1,wt=G-M||1;if(C.length<=4){c=C.length,A=1;const q=[...C].sort((Y,$t)=>Y.area.center.x-$t.area.center.x);for(let Y=0;Y<q.length;Y++)H.set(q[Y].area.id,{row:1,col:Y+1})}else{const q=[...C].sort((N,F)=>N.area.center.x-F.area.center.x),Y=[];for(let N=1;N<q.length;N++)Y.push(q[N].area.center.x-q[N-1].area.center.x);const $t=Y.reduce((N,F)=>N+F,0)/Y.length||1;let Ut=1;for(const N of Y)N>$t*1.3&&Ut++;c=Math.max(2,Math.min(Ut,C.length));const Dt=[...C].sort((N,F)=>N.area.center.z-F.area.center.z),vt=[];for(let N=1;N<Dt.length;N++)vt.push(Dt[N].area.center.z-Dt[N-1].area.center.z);const fn=vt.reduce((N,F)=>N+F,0)/vt.length||1;let Vt=1;for(const N of vt)N>fn*1.3&&Vt++;A=Math.max(2,Math.min(Vt,C.length)),c=Math.max(c,Math.ceil(C.length/A)),A=Math.max(A,Math.ceil(C.length/c));const hn=_t/c,gn=wt/A,zt=new Set;for(const N of C){let F=Math.min(c-1,Math.max(0,Math.floor((N.area.center.x-w)/hn))),Oe=Math.min(A-1,Math.max(0,Math.floor((N.area.center.z-M)/gn))),lt=`${Oe},${F}`,Xt=0;const xn=A*c;for(;zt.has(lt)&&Xt<xn;)F++,F>=c&&(F=0,Oe=(Oe+1)%A),lt=`${Oe},${F}`,Xt++;zt.has(lt)&&(Oe=A,F=0,lt=`${Oe},${F}`,A++),zt.add(lt),H.set(N.area.id,{row:Oe+1,col:F+1})}}}const L=w=>{w.sort((S,M)=>{var _t,wt,q,Y;const G=(((_t=S.position)==null?void 0:_t.z)??0)-(((wt=M.position)==null?void 0:wt.z)??0);return G!==0?G:(((q=S.position)==null?void 0:q.x)??0)-(((Y=M.position)==null?void 0:Y.x)??0)})};for(const w of C)L(w.agents);for(const w of k)L(w.agents);return{groups:[...C,...k],gridCols:c,gridRows:A,positions:H}},[_,Q,I,Ye]),bt=a.useMemo(()=>{if(!K)return[];const t=_.find(s=>s.id===K.agentId);return t?[{id:"edit-agent",label:"Edit Agent",icon:e.jsx(p,{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(p,{name:"chat",size:14}),onClick:()=>u(t.id)},{id:"clone-agent",label:"Clone Agent",icon:e.jsx(p,{name:"clipboard",size:14}),onClick:()=>f.cloneAgent(t.id)},{id:"fork-agent",label:"Fork Agent (with history)",icon:e.jsx(p,{name:"git-branch",size:14}),onClick:()=>f.forkAgent(t.id)},{id:"delete-agent",label:"Delete Agent",icon:e.jsx(p,{name:"trash",size:14}),danger:!0,onClick:()=>{Fe({agentId:t.id,name:t.name})}}]:[]},[K,_,u]),ie=a.useMemo(()=>{var C;if(!T)return[];const t=I.get(T.buildingId);if(!t)return[];const s=[],i=t.type==="server"||t.type==="docker"||t.type==="terminal",g=t.status==="running",x=t.type==="boss";if(s.push({id:"open",label:t.type==="database"?"Open Database":t.type==="folder"?"Open Folder":t.type==="tests"?"Open Tests":t.type==="http"?"Open Requests":t.type==="boss"?"View Boss Logs":t.type==="terminal"?"Open Terminal":t.type==="server"&&((C=t.pm2)!=null&&C.enabled)?"View PM2 Logs":"Open",icon:e.jsx(p,{name:t.type==="database"?"database":t.type==="folder"?"folder":t.type==="tests"?"flask":t.type==="http"?"globe":t.type==="terminal"?"terminal":"eye",size:14}),onClick:()=>je(t.id)}),i&&(g||s.push({id:"start",label:"Start",icon:e.jsx(p,{name:"play",size:14}),onClick:()=>f.sendBuildingCommand(t.id,"start")}),g&&(s.push({id:"restart",label:"Restart",icon:e.jsx(p,{name:"refresh",size:14}),onClick:()=>f.sendBuildingCommand(t.id,"restart")}),s.push({id:"stop",label:"Stop",icon:e.jsx(p,{name:"stop",size:14}),onClick:()=>f.sendBuildingCommand(t.id,"stop")}))),x&&t.subordinateBuildingIds&&t.subordinateBuildingIds.length>0&&(s.push({id:"start-all",label:"Start All Subordinates",icon:e.jsx(p,{name:"launch",size:14}),onClick:()=>{for(const k of t.subordinateBuildingIds)f.sendBuildingCommand(k,"start")}}),s.push({id:"stop-all",label:"Stop All Subordinates",icon:e.jsx(p,{name:"pause",size:14}),onClick:()=>{for(const k of t.subordinateBuildingIds)f.sendBuildingCommand(k,"stop")}}),s.push({id:"restart-all",label:"Restart All Subordinates",icon:e.jsx(p,{name:"restart",size:14}),onClick:()=>{for(const k of t.subordinateBuildingIds)f.sendBuildingCommand(k,"restart")}})),i&&s.push({id:"health-check",label:"Health Check",icon:e.jsx(p,{name:"health",size:14}),onClick:()=>f.sendBuildingCommand(t.id,"healthCheck")}),s.push({id:"divider-edit",label:"",divider:!0,onClick:()=>{}}),s.push({id:"edit",label:"Edit Building",icon:e.jsx(p,{name:"edit",size:14}),onClick:()=>{window.dispatchEvent(new CustomEvent("tide:building-edit",{detail:{buildingId:t.id}}))}}),s.push({id:"clone",label:"Clone Building",icon:e.jsx(p,{name:"copy",size:14}),onClick:()=>{f.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 k of t.urls)s.push({id:`url-${k.label}`,label:k.label,icon:e.jsx(p,{name:"link",size:14}),onClick:()=>window.open(k.url,"_blank","noopener,noreferrer")});return s.push({id:"divider-danger",label:"",divider:!0,onClick:()=>{}}),s.push({id:"delete",label:"Delete Building",icon:e.jsx(p,{name:"trash",size:14}),danger:!0,onClick:()=>f.deleteBuilding(t.id)}),s},[T,I,je]),W=a.useCallback(t=>{const s=new Set(Ne.groups.map(i=>i.area.id));s.delete(t),it(s),requestAnimationFrame(()=>{const i=ze.current;if(!i)return;const g=i.querySelector(`[data-area-id="${t}"]`);if(!g)return;const x=i.getBoundingClientRect(),k=g.getBoundingClientRect().top-x.top+i.scrollTop-8;i.scrollTo({top:Math.max(0,k),behavior:"smooth"})})},[Ne]);return e.jsxs("div",{ref:ge,className:`flat-view ${ce?"flat-view--with-inspector":""} ${v?"flat-view--has-chat":""} ${fe?"flat-view--mobile-sidebar-open":""}`,style:(()=>{if(ue===null&&pe===null)return;const t={};return ue!==null&&(t["--flat-middle-width"]=`${ue}px`),pe!==null&&(t["--flat-inspector-width"]=`${pe}px`),t})(),children:[fe&&e.jsx("div",{className:"flat-mobile-sidebar-backdrop",onClick:Ue,"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:R,title:"Create new agent",children:"+ Agent"}),e.jsx("button",{className:"flat-cta-btn flat-cta-btn--boss",onClick:P,title:"Create new boss agent",children:"+ Boss"}),e.jsx("button",{className:"flat-cta-btn flat-cta-btn--area",onClick:z,title:"Create new area",children:"+ Area"})]})}),e.jsx("div",{className:"flat-middle__content",children:e.jsx(In,{activeAgentId:Te,onClose:gt,onSelectAgent:Lt,collapsedAreas:Rt,onToggleArea:xt,agentListRef:ze})})]}),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:tt,onPointerMove:we,onPointerUp:B,onPointerCancel:B,onDoubleClick:ut}),e.jsxs("div",{className:"flat-right",children:[e.jsxs("button",{type:"button",className:"flat-mobile-sidebar-toggle","aria-label":fe?"Close agents sidebar":"Open agents sidebar","aria-expanded":fe,onClick:He,children:[e.jsx(p,{name:"list",size:18}),e.jsx("span",{className:"flat-mobile-sidebar-toggle__label",children:"Agents"})]}),v?e.jsx(La,{agentId:v,terminalViewMode:me,onTerminalViewModeChange:et,inspectorOpen:ke,onToggleInspector:Re,onImageClick:At,onFileClick:Et,onBashClick:St,onViewMarkdown:$e,onRequestClearSubordinates:pt,keyboard:kt,canNavigateBack:It,canNavigateForward:Tt,onNavigateBack:at,onNavigateForward:ft,agentInfoOpen:Pe,onToggleAgentInfo:dt,onHeaderContextMenu:t=>{v&&b({agentId:v,position:t})},onBuildingContextMenu:(t,s)=>{Je({buildingId:t,position:s})}}):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(ka,{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 s;const t=n&&l?((s=Ne.positions.get(l))==null?void 0:s.row)??null:null;return Ne.groups.map(i=>{var k;const g=i.area.id,x=Ne.positions.get(g),C=n&&l!==g;return n&&t!=null&&(x==null?void 0:x.row)===t&&g!==l?null:e.jsxs("div",{className:`flat-map-area-card${C?" flat-map-area-card--collapsed":""}`,style:{"--area-color":i.area.color,gridRow:x==null?void 0:x.row,gridColumn:x==null?void 0:x.col},onContextMenu:c=>{y&&(c.preventDefault(),c.stopPropagation(),y(g,{x:c.clientX,y:c.clientY}))},children:[((k=i.area.logo)==null?void 0:k.filename)&&e.jsx("img",{className:"flat-map-area-card__logo",src:ba(i.area.logo.filename),alt:"","aria-hidden":"true",onError:c=>{c.currentTarget.style.display="none"}}),e.jsxs("button",{type:"button",className:"flat-map-area-card__header",onClick:()=>n?X(g):W(g),title:n?C?`Expand ${i.area.name}`:`Collapse ${i.area.name}`:`Focus ${i.area.name} in left panel`,"aria-expanded":n?!C:void 0,children:[e.jsx("span",{className:"flat-map-area-card__color",style:{background:i.area.color}}),e.jsx("span",{className:"flat-map-area-card__name",children:i.area.name}),e.jsx("span",{className:"flat-map-area-card__count",children:i.agents.length}),n&&e.jsx(p,{name:C?"caret-down":"caret-up",size:11,className:"flat-map-area-card__caret"})]}),e.jsx("div",{className:"flat-map-area-card__agents",children:i.agents.map(c=>{const A=c.isBoss||c.class==="boss",H=A?Me.get(c.id):void 0,L=Mn(c),w=L.usedPercent>=80?"#ff4a4a":L.usedPercent>=60?"#ff9e4a":L.usedPercent>=40?"#ffd700":"#4aff9e",S=`Context: ${(L.totalTokens/1e3).toFixed(1)}k / ${(L.contextWindow/1e3).toFixed(1)}k (${L.usedPercent}% used, ${L.freePercent}% free)`,M=c.latestTodos&&c.latestTodos.length>0||H&&H.length>0;return e.jsx(Tn,{todos:c.latestTodos,subordinates:H,position:"top",children:e.jsxs("button",{type:"button",className:`flat-map-agent-chip ${c.status}`,onClick:()=>u(c.id),onContextMenu:G=>{G.preventDefault(),G.stopPropagation(),b({agentId:c.id,position:{x:G.clientX,y:G.clientY}})},title:M?void 0:`${A?"Boss · ":""}Open chat with ${c.name}
2
- ${S}`,children:[e.jsx(dn,{agent:c,size:16}),A&&e.jsx("span",{className:"flat-map-agent-chip__crown","aria-hidden":"true",children:e.jsx(p,{name:"crown",size:11,color:"#ffd700",weight:"fill"})}),e.jsx("span",{className:"flat-map-agent-chip__name",children:c.name}),e.jsx("img",{src:c.provider==="codex"?"/assets/codex.png":c.provider==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:c.provider,className:"flat-map-agent-chip__provider-icon",title:c.provider==="codex"?"Codex Agent":c.provider==="opencode"?"OpenCode Agent":"Claude Agent"}),e.jsx("span",{className:"flat-map-agent-chip__dot",style:{backgroundColor:un(c.status)}}),c.latestTodos&&c.latestTodos.length>0&&e.jsx(Pn,{todos:c.latestTodos,maxDots:6}),A&&H&&H.length>0&&e.jsx(Ln,{subordinates:H,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:`${L.usedPercent}%`,backgroundColor:w}})})]})},c.id)})}),i.area.directories.length>0&&e.jsx("div",{className:"flat-map-area-card__folders",role:"group","aria-label":`${i.area.name} folders`,children:i.area.directories.map(c=>{const A=c.split("/").filter(Boolean).pop()||c;return e.jsxs("button",{type:"button",className:"flat-map-folder-chip",onClick:H=>{H.stopPropagation(),f.openFileExplorerForAreaFolder(g,c)},title:`Open in file explorer: ${c}`,children:[e.jsx(p,{name:"folder-open",size:12}),e.jsx("span",{className:"flat-map-folder-chip__name",children:A})]},c)})}),i.buildings.length>0&&e.jsx("div",{className:"flat-map-area-card__buildings",children:i.buildings.map(c=>{var H;const A=(H=Rn[c.type])==null?void 0:H.color;return e.jsxs("button",{type:"button",className:`flat-map-building-chip flat-map-building-chip--${c.status}`,style:A?{"--building-type-color":A}:void 0,onClick:L=>{if(h){const w=L.currentTarget.getBoundingClientRect();h(c.id,{x:w.right,y:w.top+w.height/2})}else je(c.id)},onContextMenu:L=>{L.preventDefault(),L.stopPropagation(),Je({buildingId:c.id,position:{x:L.clientX,y:L.clientY}})},title:`${c.name} · ${c.type} · ${c.status}`,children:[e.jsx(p,{name:$n(c.type),size:12,color:A}),e.jsx("span",{className:"flat-map-building-chip__name",children:c.name}),e.jsx("span",{className:"flat-map-building-chip__dot",style:{backgroundColor:Dn(c.status)}})]},c.id)})})]},g)})})()})]})})]}),ce&&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:j,onPointerMove:we,onPointerUp:B,onPointerCancel:B,onDoubleClick:Ie}),De&&e.jsxs("aside",{className:`flat-inspector ${Ce?"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":ve==="agent",className:`flat-inspector__tab ${ve==="agent"?"flat-inspector__tab--active":""}`,onClick:()=>D("agent"),children:"Agent"}),e.jsx("button",{type:"button",role:"tab","aria-selected":ve==="tracking",className:`flat-inspector__tab ${ve==="tracking"?"flat-inspector__tab--active":""}`,onClick:()=>D("tracking"),children:"Tracking"})]}),e.jsx("button",{type:"button",className:"flat-inspector__close",onClick:oe,title:"Close inspector","aria-label":"Close inspector",children:"✕"})]}),e.jsx("div",{className:"flat-inspector__body",children:ve==="tracking"?e.jsx(zn,{activeAgentId:v??"",onSelectAgent:t=>{u(t),window.innerWidth<=768&&oe()}}):(()=>{if(!v)return e.jsx("div",{className:"flat-inspector__empty",children:e.jsx("span",{children:"Select an agent to inspect"})});const t=_.find(s=>s.id===v);return t?e.jsx(On,{agent:t,onFocusAgent:s=>{u(s),window.innerWidth<=768&&oe()},onKillAgent:s=>f.killAgent(s)}):e.jsx("div",{className:"flat-inspector__empty",children:e.jsx("span",{children:"Agent not found"})})})()})]}),$&&e.jsx(Bn,{url:$.url,name:$.name,onClose:()=>U(null)}),ee&&e.jsx(Fn,{state:ee,onClose:()=>te(null)}),e.jsx(Wn,{agent:v?_.find(t=>t.id===v)??null:null,content:de,onClose:()=>Be(null)}),Ze&&e.jsx(Hn,{action:"clear-subordinates",selectedAgentId:Ze.agentId,subordinateCount:Ze.count,onClose:()=>ct(null),onClearHistory:()=>{}}),e.jsx(Un,{agent:v?_.find(t=>t.id===v)??null:null,isOpen:Pe&&!!v,onClose:We}),e.jsx(Qt,{isOpen:K!==null,position:(K==null?void 0:K.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:bt,onClose:()=>b(null)}),e.jsx(Qt,{isOpen:T!==null,position:(T==null?void 0:T.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:ie,onClose:()=>Je(null)}),e.jsx(Vn,{isOpen:re!==null,title:le("common:confirm.removeAgentTitle"),message:le("common:confirm.removeAgentMessage",{name:(re==null?void 0:re.name)??""}),confirmLabel:le("common:buttons.remove"),cancelLabel:le("common:buttons.cancel"),variant:"danger",onConfirm:()=>{re&&f.removeAgentFromServer(re.agentId)},onClose:()=>Fe(null)})]})}export{Oa as FlatView};