tide-commander 1.85.0 → 1.86.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 (36) hide show
  1. package/dist/assets/{BossLogsModal-uPeGcb3I.js → BossLogsModal-BB1vCM5J.js} +1 -1
  2. package/dist/assets/{BossSpawnModal-D7iyXoJq.js → BossSpawnModal-wMLySpgn.js} +1 -1
  3. package/dist/assets/{ControlsModal-DXnnGYp5.js → ControlsModal-BklEN7j8.js} +1 -1
  4. package/dist/assets/{DockerLogsModal-DxmUWbDV.js → DockerLogsModal-B49O9xcw.js} +1 -1
  5. package/dist/assets/{EmbeddedEditor-BUi6dUs3.js → EmbeddedEditor-BX9aBsiv.js} +1 -1
  6. package/dist/assets/{GmailOAuthSetup-iCnmfNtc.js → GmailOAuthSetup-BzB4QGx5.js} +1 -1
  7. package/dist/assets/{GoogleOAuthSetup-BPMmX5ua.js → GoogleOAuthSetup-4nw4iS8V.js} +1 -1
  8. package/dist/assets/{IframeModal-CVJjFAPp.js → IframeModal-DGXje5GK.js} +1 -1
  9. package/dist/assets/{IntegrationsPanel-DpQUsPg2.js → IntegrationsPanel-CjtCtu7-.js} +2 -2
  10. package/dist/assets/{LogViewerModal-tBZ1aP8p.js → LogViewerModal-CnOV3Ai5.js} +1 -1
  11. package/dist/assets/{MonitoringModal-B4A0qczU.js → MonitoringModal-VwORpB9L.js} +1 -1
  12. package/dist/assets/{PM2LogsModal-i7fxasp0.js → PM2LogsModal-8bnD0XcQ.js} +1 -1
  13. package/dist/assets/{RestoreArchivedAreaModal-UurWP1-j.js → RestoreArchivedAreaModal-BhwpPzFY.js} +1 -1
  14. package/dist/assets/{Scene2DCanvas-B9DuBLip.js → Scene2DCanvas-DaRWkux-.js} +1 -1
  15. package/dist/assets/{SceneManager-xEBRq68j.js → SceneManager-CKz-v1rU.js} +1 -1
  16. package/dist/assets/{SkillsPanel-BDyKxve4.js → SkillsPanel-l0DKbOtc.js} +2 -2
  17. package/dist/assets/{SpawnModal-CBKT43_l.js → SpawnModal-DEAh9hdW.js} +1 -1
  18. package/dist/assets/{SubordinateAssignmentModal-CddDPiHW.js → SubordinateAssignmentModal-CczaDW9_.js} +1 -1
  19. package/dist/assets/{TriggerManagerPanel-CcVCNnhm.js → TriggerManagerPanel-aczhr8bG.js} +1 -1
  20. package/dist/assets/{WorkflowEditorPanel-C5meCq60.js → WorkflowEditorPanel-Pp473-yC.js} +1 -1
  21. package/dist/assets/index-BrntsiFl.js +2 -0
  22. package/dist/assets/{index-CQll-mer.js → index-Bsu-4DMd.js} +2 -2
  23. package/dist/assets/{index-CrpntCm1.js → index-CfEa34G0.js} +5 -5
  24. package/dist/assets/{index-DtDo7QHt.js → index-CsZl2cpZ.js} +3 -3
  25. package/dist/assets/{index-BNQjdC7D.js → index-DAsa2Q29.js} +3 -3
  26. package/dist/assets/{index-huFbdygq.js → index-DEEA8DzD.js} +1 -1
  27. package/dist/assets/{index-BfUS9DYN.js → index-Da106QNu.js} +1 -1
  28. package/dist/assets/{index-JUHUy-Tv.js → index-VOQ8B_0s.js} +1 -1
  29. package/dist/assets/{index-C7Mu39PP.js → index-bumMaJlF.js} +1 -1
  30. package/dist/assets/{main-Q3uQGSTr.js → main-D2EQVTAu.js} +41 -41
  31. package/dist/assets/{web-ko2U5w1Z.js → web-Bdm2kdQ5.js} +1 -1
  32. package/dist/assets/web-CZQVhlQA.js +1 -0
  33. package/dist/assets/{web-_0kug6fn.js → web-DlbC6v-L.js} +1 -1
  34. package/dist/index.html +1 -1
  35. package/package.json +2 -1
  36. package/dist/assets/index-D_wtUWqj.js +0 -2
@@ -1,8 +1,8 @@
1
- import{be as ta,u as E,j as e,aJ as v,bh as $s,bi as Fs,aK as He,s as P,bj as Ms,D as Y,I as A,a0 as Hs,aT as Ge,f as na,bk as la,r,G as ia,S as oa,h as ra,bl as Us,aU as Ke}from"./main-Q3uQGSTr.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const ca=[{value:"",labelKey:"terminal:building.colorDefault"},{value:"#2a2a3a",labelKey:"terminal:building.colorDarkGray"},{value:"#3a2a2a",labelKey:"terminal:building.colorDarkRed"},{value:"#2a3a2a",labelKey:"terminal:building.colorDarkGreen"},{value:"#2a2a4a",labelKey:"terminal:building.colorDarkBlue"},{value:"#3a3a2a",labelKey:"terminal:building.colorDarkYellow"},{value:"#3a2a3a",labelKey:"terminal:building.colorDarkPurple"},{value:"#2a3a3a",labelKey:"terminal:building.colorDarkCyan"},{value:"#4a3a3a",labelKey:"terminal:building.colorWarmBrown"},{value:"#3a4a4a",labelKey:"terminal:building.colorCoolSteel"}];function ma(a){return ta.t(a)}function Ve(a){if(a===0)return"0 B";const l=1024,c=["B","KB","MB","GB"],h=Math.floor(Math.log(a)/Math.log(l));return parseFloat((a/Math.pow(l,h)).toFixed(1))+" "+c[h]}function da(a){const c=Date.now()-a,h=Math.floor(c/(1e3*60*60)),t=Math.floor(c%(1e3*60*60)/(1e3*60));return h>0?`${h}h ${t}m`:`${t}m`}const Ks={30:"#1a1a1a",31:"#e74c3c",32:"#2ecc71",33:"#f39c12",34:"#3498db",35:"#9b59b6",36:"#00bcd4",37:"#ecf0f1",90:"#7f8c8d",91:"#ff6b6b",92:"#4ade80",93:"#fbbf24",94:"#60a5fa",95:"#c084fc",96:"#22d3ee",97:"#ffffff"};function Gs(a){const l=[],c=/\x1B\[([0-9;]*)m/g;let h=0,t=null,o;for(;(o=c.exec(a))!==null;){if(o.index>h){const m=a.slice(h,o.index);t?l.push(e.jsx("span",{style:{color:t},children:m},l.length)):l.push(m)}const g=o[1].split(";").map(Number);for(const m of g)m===0||m===39?t=null:Ks[m]&&(t=Ks[m]);h=c.lastIndex}if(h<a.length){const g=a.slice(h);t?l.push(e.jsx("span",{style:{color:t},children:g},l.length)):l.push(g)}return l.length>0?l:[a]}function ua({buildingName:a,onClose:l,onConfirm:c}){const{t:h}=E(["terminal","common"]);return e.jsx("div",{className:"modal-overlay visible",onClick:l,children:e.jsxs("div",{className:"modal confirm-modal",onClick:t=>t.stopPropagation(),children:[e.jsx("div",{className:"modal-header",children:h("terminal:building.deleteBuilding")}),e.jsxs("div",{className:"modal-body confirm-modal-body",children:[e.jsx("p",{children:h("terminal:building.deleteConfirm",{name:a})}),e.jsx("p",{className:"confirm-modal-note",children:h("terminal:building.deleteNote")})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn btn-secondary",onClick:l,children:h("common:buttons.cancel")}),e.jsx("button",{className:"btn btn-danger",onClick:c,autoFocus:!0,children:h("common:buttons.delete")})]})]})})}function pa({usePM2:a,setUsePM2:l}){const{t:c}=E(["terminal"]);return e.jsxs("div",{className:"form-section pm2-toggle-section",children:[e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",className:"toggle-input",checked:a,onChange:h=>l(h.target.checked)}),e.jsx("span",{className:"toggle-track",children:e.jsx("span",{className:"toggle-thumb"})}),e.jsxs("span",{className:"toggle-label",children:[e.jsx("span",{className:"pm2-badge",children:"PM2"}),c("terminal:building.usePM2")]})]}),e.jsx("div",{className:"form-hint",children:c("terminal:building.pm2Hint")})]})}function ha({usePM2:a,pm2Script:l,setPm2Script:c,pm2Args:h,setPm2Args:t,pm2Interpreter:o,setPm2Interpreter:g,pm2InterpreterArgs:m,setPm2InterpreterArgs:d,pm2Env:s,setPm2Env:u,isEditMode:b,building:x,handleCommand:N}){var y;const{t:p}=E(["terminal","common"]);return a?e.jsxs("div",{className:"form-section pm2-config-section",children:[e.jsx("label",{className:"form-label",children:p("terminal:building.pm2Configuration")}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Script"),e.jsx(v,{text:p("terminal:building.helpPm2Script"),title:p("terminal:building.pm2Script"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:l,onChange:j=>c(j.target.value),placeholder:"npm, java, python, ./app.js",required:a})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Arguments"),e.jsx(v,{text:p("terminal:building.helpPm2Arguments"),title:p("terminal:building.pm2Arguments"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:h,onChange:j=>t(j.target.value),placeholder:"run dev, -jar app.jar, app.py"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Interpreter"),e.jsx(v,{text:p("terminal:building.helpPm2Interpreter"),title:p("terminal:building.pm2Interpreter"),position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:o,onChange:j=>g(j.target.value),children:Object.keys($s).map(j=>e.jsx("option",{value:j,children:$s[j].label},j))})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2InterpArgs"),e.jsx(v,{text:p("terminal:building.helpPm2InterpArgs"),title:p("terminal:building.pm2InterpArgs"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:m,onChange:j=>d(j.target.value),placeholder:"-jar (for Java)"})]}),e.jsxs("div",{className:"command-row env-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Environment"),e.jsx(v,{text:p("terminal:building.helpPm2Environment"),title:p("terminal:building.pm2Environment"),position:"top",size:"sm"})]}),e.jsx("textarea",{className:"form-input form-textarea",value:s,onChange:j=>u(j.target.value),placeholder:`KEY=value
1
+ import{bg as ta,u as E,j as e,aL as v,bj as $s,bk as Fs,aM as He,s as P,bl as Ms,D as Y,I as A,a2 as Hs,aV as Ge,f as na,bm as la,r,J as ia,S as oa,h as ra,bn as Us,aW as Ke}from"./main-D2EQVTAu.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const ca=[{value:"",labelKey:"terminal:building.colorDefault"},{value:"#2a2a3a",labelKey:"terminal:building.colorDarkGray"},{value:"#3a2a2a",labelKey:"terminal:building.colorDarkRed"},{value:"#2a3a2a",labelKey:"terminal:building.colorDarkGreen"},{value:"#2a2a4a",labelKey:"terminal:building.colorDarkBlue"},{value:"#3a3a2a",labelKey:"terminal:building.colorDarkYellow"},{value:"#3a2a3a",labelKey:"terminal:building.colorDarkPurple"},{value:"#2a3a3a",labelKey:"terminal:building.colorDarkCyan"},{value:"#4a3a3a",labelKey:"terminal:building.colorWarmBrown"},{value:"#3a4a4a",labelKey:"terminal:building.colorCoolSteel"}];function ma(a){return ta.t(a)}function Ve(a){if(a===0)return"0 B";const l=1024,c=["B","KB","MB","GB"],h=Math.floor(Math.log(a)/Math.log(l));return parseFloat((a/Math.pow(l,h)).toFixed(1))+" "+c[h]}function da(a){const c=Date.now()-a,h=Math.floor(c/(1e3*60*60)),t=Math.floor(c%(1e3*60*60)/(1e3*60));return h>0?`${h}h ${t}m`:`${t}m`}const Ks={30:"#1a1a1a",31:"#e74c3c",32:"#2ecc71",33:"#f39c12",34:"#3498db",35:"#9b59b6",36:"#00bcd4",37:"#ecf0f1",90:"#7f8c8d",91:"#ff6b6b",92:"#4ade80",93:"#fbbf24",94:"#60a5fa",95:"#c084fc",96:"#22d3ee",97:"#ffffff"};function Gs(a){const l=[],c=/\x1B\[([0-9;]*)m/g;let h=0,t=null,o;for(;(o=c.exec(a))!==null;){if(o.index>h){const m=a.slice(h,o.index);t?l.push(e.jsx("span",{style:{color:t},children:m},l.length)):l.push(m)}const g=o[1].split(";").map(Number);for(const m of g)m===0||m===39?t=null:Ks[m]&&(t=Ks[m]);h=c.lastIndex}if(h<a.length){const g=a.slice(h);t?l.push(e.jsx("span",{style:{color:t},children:g},l.length)):l.push(g)}return l.length>0?l:[a]}function ua({buildingName:a,onClose:l,onConfirm:c}){const{t:h}=E(["terminal","common"]);return e.jsx("div",{className:"modal-overlay visible",onClick:l,children:e.jsxs("div",{className:"modal confirm-modal",onClick:t=>t.stopPropagation(),children:[e.jsx("div",{className:"modal-header",children:h("terminal:building.deleteBuilding")}),e.jsxs("div",{className:"modal-body confirm-modal-body",children:[e.jsx("p",{children:h("terminal:building.deleteConfirm",{name:a})}),e.jsx("p",{className:"confirm-modal-note",children:h("terminal:building.deleteNote")})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn btn-secondary",onClick:l,children:h("common:buttons.cancel")}),e.jsx("button",{className:"btn btn-danger",onClick:c,autoFocus:!0,children:h("common:buttons.delete")})]})]})})}function pa({usePM2:a,setUsePM2:l}){const{t:c}=E(["terminal"]);return e.jsxs("div",{className:"form-section pm2-toggle-section",children:[e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",className:"toggle-input",checked:a,onChange:h=>l(h.target.checked)}),e.jsx("span",{className:"toggle-track",children:e.jsx("span",{className:"toggle-thumb"})}),e.jsxs("span",{className:"toggle-label",children:[e.jsx("span",{className:"pm2-badge",children:"PM2"}),c("terminal:building.usePM2")]})]}),e.jsx("div",{className:"form-hint",children:c("terminal:building.pm2Hint")})]})}function ha({usePM2:a,pm2Script:l,setPm2Script:c,pm2Args:h,setPm2Args:t,pm2Interpreter:o,setPm2Interpreter:g,pm2InterpreterArgs:m,setPm2InterpreterArgs:d,pm2Env:s,setPm2Env:u,isEditMode:b,building:x,handleCommand:N}){var y;const{t:p}=E(["terminal","common"]);return a?e.jsxs("div",{className:"form-section pm2-config-section",children:[e.jsx("label",{className:"form-label",children:p("terminal:building.pm2Configuration")}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Script"),e.jsx(v,{text:p("terminal:building.helpPm2Script"),title:p("terminal:building.pm2Script"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:l,onChange:j=>c(j.target.value),placeholder:"npm, java, python, ./app.js",required:a})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Arguments"),e.jsx(v,{text:p("terminal:building.helpPm2Arguments"),title:p("terminal:building.pm2Arguments"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:h,onChange:j=>t(j.target.value),placeholder:"run dev, -jar app.jar, app.py"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Interpreter"),e.jsx(v,{text:p("terminal:building.helpPm2Interpreter"),title:p("terminal:building.pm2Interpreter"),position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:o,onChange:j=>g(j.target.value),children:Object.keys($s).map(j=>e.jsx("option",{value:j,children:$s[j].label},j))})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2InterpArgs"),e.jsx(v,{text:p("terminal:building.helpPm2InterpArgs"),title:p("terminal:building.pm2InterpArgs"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:m,onChange:j=>d(j.target.value),placeholder:"-jar (for Java)"})]}),e.jsxs("div",{className:"command-row env-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Environment"),e.jsx(v,{text:p("terminal:building.helpPm2Environment"),title:p("terminal:building.pm2Environment"),position:"top",size:"sm"})]}),e.jsx("textarea",{className:"form-input form-textarea",value:s,onChange:j=>u(j.target.value),placeholder:`KEY=value
2
2
  SERVER_PORT=7201
3
- NODE_ENV=production`,rows:3})]}),e.jsx("div",{className:"pm2-examples",children:e.jsxs("details",{children:[e.jsx("summary",{children:p("terminal:building.pm2Examples")}),e.jsxs("div",{className:"pm2-examples-content",children:[e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Node.js:"})," Script: ",e.jsx("code",{children:"npm"}),", Args: ",e.jsx("code",{children:"run dev"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Symfony:"})," Script: ",e.jsx("code",{children:"symfony"}),", Args: ",e.jsx("code",{children:"serve --no-daemon"}),", Interpreter: ",e.jsx("code",{children:"None"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Java JAR:"})," Script: ",e.jsx("code",{children:"app.jar"}),", Interpreter: ",e.jsx("code",{children:"Java"}),", Interp. Args: ",e.jsx("code",{children:"-jar"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Python:"})," Script: ",e.jsx("code",{children:"app.py"}),", Interpreter: ",e.jsx("code",{children:"Python 3"})]})]})]})}),b&&(x==null?void 0:x.pm2Status)&&e.jsx("div",{className:"pm2-status-display",children:e.jsxs("div",{className:"pm2-status-row",children:[e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"PID"}),e.jsx("span",{className:"pm2-metric-value",children:x.pm2Status.pid||"-"})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"CPU"}),e.jsxs("span",{className:"pm2-metric-value",children:[((y=x.pm2Status.cpu)==null?void 0:y.toFixed(1))||"0","%"]})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"MEM"}),e.jsx("span",{className:"pm2-metric-value",children:Ve(x.pm2Status.memory||0)})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"Restarts"}),e.jsx("span",{className:"pm2-metric-value",children:x.pm2Status.restarts||0})]}),x.pm2Status.uptime&&e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"Uptime"}),e.jsx("span",{className:"pm2-metric-value",children:da(x.pm2Status.uptime)})]})]})}),b&&e.jsxs("div",{className:"pm2-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>N("start"),children:p("common:buttons.start")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>N("stop"),children:p("common:buttons.stop")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>N("restart"),children:p("terminal:buildingAction.restart")}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>N("logs"),children:p("terminal:logs.title")})]})]}):null}function xa({dockerMode:a,setDockerMode:l,dockerImage:c,setDockerImage:h,dockerContainerName:t,setDockerContainerName:o,dockerCommand:g,setDockerCommand:m,dockerPorts:d,setDockerPorts:s,dockerVolumes:u,setDockerVolumes:b,dockerNetwork:x,setDockerNetwork:N,dockerRestart:p,setDockerRestart:y,dockerPull:j,setDockerPull:F,dockerEnv:M,setDockerEnv:R,dockerComposePath:J,setDockerComposePath:U,dockerComposeProject:W,setDockerComposeProject:K,dockerComposeServices:Z,setDockerComposeServices:H,selectedExistingContainer:T,setSelectedExistingContainer:G,dockerContainersList:O,isEditMode:I,building:k,handleCommand:L}){const{t:z}=E(["config","common"]);return e.jsxs("div",{className:"form-section docker-config-section",children:[e.jsx("label",{className:"form-label",children:z("config:buildings.dockerConfig")}),e.jsxs("div",{className:"docker-mode-selector",children:[e.jsxs("label",{className:`docker-mode-option ${a==="container"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"container",checked:a==="container",onChange:()=>l("container")}),e.jsx("span",{className:"docker-mode-icon",children:"📦"}),e.jsx("span",{className:"docker-mode-label",children:"Container"}),e.jsx("span",{className:"docker-mode-desc",children:"Create a new container"})]}),e.jsxs("label",{className:`docker-mode-option ${a==="compose"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"compose",checked:a==="compose",onChange:()=>l("compose")}),e.jsx("span",{className:"docker-mode-icon",children:"🛠"}),e.jsx("span",{className:"docker-mode-label",children:"Compose"}),e.jsx("span",{className:"docker-mode-desc",children:"Manage multiple services"})]}),e.jsxs("label",{className:`docker-mode-option ${a==="existing"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"existing",checked:a==="existing",onChange:()=>l("existing")}),e.jsx("span",{className:"docker-mode-icon",children:"🔎"}),e.jsx("span",{className:"docker-mode-label",children:"Existing"}),e.jsx("span",{className:"docker-mode-desc",children:"Adopt existing container"})]})]}),a==="container"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Image:",e.jsx(v,{text:"Docker image to run, e.g., nginx:latest, redis:alpine, my-app:v1",title:"Image",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:c,onChange:n=>h(n.target.value),placeholder:"nginx:latest",required:!0})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Container Name:",e.jsx(v,{text:"Custom name for the container. If empty, auto-generated based on building name.",title:"Container Name",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:t,onChange:n=>o(n.target.value),placeholder:"Auto-generated (tc-{name}-{id})"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Command:",e.jsx(v,{text:"Override the default container command. Leave empty to use image's CMD.",title:"Command Override",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:g,onChange:n=>m(n.target.value),placeholder:"Optional command override"})]}),e.jsxs("div",{className:"form-section docker-ports-section",children:[e.jsxs("label",{className:"form-label",children:["Port Mappings",e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>s([...d,""]),children:"+ Add"})]}),d.map((n,C)=>e.jsxs("div",{className:"docker-mapping-row",children:[e.jsx("input",{type:"text",className:"form-input",value:n,onChange:B=>{const D=[...d];D[C]=B.target.value,s(D)},placeholder:"8080:80 or 3000"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>s(d.filter((B,D)=>D!==C)),children:"x"})]},C)),d.length===0&&e.jsx("div",{className:"form-hint",children:"Format: host:container (e.g., 8080:80) or same port (e.g., 3000)"})]}),e.jsxs("div",{className:"form-section docker-volumes-section",children:[e.jsxs("label",{className:"form-label",children:["Volume Mounts",e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>b([...u,""]),children:"+ Add"})]}),u.map((n,C)=>e.jsxs("div",{className:"docker-mapping-row",children:[e.jsx("input",{type:"text",className:"form-input",value:n,onChange:B=>{const D=[...u];D[C]=B.target.value,b(D)},placeholder:"./data:/app/data or /host/path:/container/path"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>b(u.filter((B,D)=>D!==C)),children:"x"})]},C)),u.length===0&&e.jsx("div",{className:"form-hint",children:"Format: host_path:container_path (relative paths resolved from working directory)"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Network:",e.jsx(v,{text:"Docker network to connect to. Leave empty for default bridge network.",title:"Network",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:x,onChange:n=>N(n.target.value),placeholder:"bridge (default)"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Restart Policy:",e.jsx(v,{text:"When should Docker restart the container automatically?",title:"Restart Policy",position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:p,onChange:n=>y(n.target.value),children:Object.keys(Fs).map(n=>e.jsx("option",{value:n,children:Fs[n].label},n))})]})]}),a==="compose"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Compose File:",e.jsx(v,{text:"Path to docker-compose.yml file, relative to working directory.",title:"Compose File",position:"top",size:"sm"})]}),e.jsx(He,{value:J,onChange:U,placeholder:"docker-compose.yml",className:"form-input",directoriesOnly:!1})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Project Name:",e.jsx(v,{text:"Override the compose project name. Leave empty for auto-generated name.",title:"Project Name",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:W,onChange:n=>K(n.target.value),placeholder:"Auto-generated"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Services:",e.jsx(v,{text:"Specific services to manage (comma-separated). Leave empty for all services.",title:"Services",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:Z,onChange:n=>H(n.target.value),placeholder:"All services (or: api, db, redis)"})]})]}),a==="existing"&&e.jsxs("div",{className:"docker-existing-section",children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Select Container:",e.jsx(v,{text:"Choose an existing Docker container to monitor and control. The container will not be deleted when removing the building.",title:"Existing Container",position:"top",size:"sm"})]}),e.jsxs("div",{className:"docker-existing-select-wrapper",children:[e.jsxs("select",{className:"form-input form-select",value:T,onChange:n=>G(n.target.value),required:a==="existing",children:[e.jsx("option",{value:"",children:"Select a container..."}),O.map(n=>e.jsxs("option",{value:n.name,children:[n.name," (",n.image,") - ",n.state]},n.id))]}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>P.requestDockerContainersList(),title:"Refresh container list",children:"↻"})]})]}),O.length===0&&e.jsx("div",{className:"form-hint docker-existing-hint",children:"No containers found. Make sure Docker is running and you have containers available."}),T&&e.jsx("div",{className:"docker-existing-info",children:(()=>{const n=O.find(C=>C.name===T);return n?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Image:"}),e.jsx("span",{className:"docker-existing-info-value",children:n.image})]}),e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Status:"}),e.jsx("span",{className:`docker-existing-info-value docker-status-${n.status}`,children:n.state})]}),e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"ID:"}),e.jsx("span",{className:"docker-existing-info-value",children:n.id.slice(0,12)})]}),n.ports.length>0&&e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Ports:"}),e.jsx("span",{className:"docker-existing-info-value",children:n.ports.map(C=>`${C.host}:${C.container}/${C.protocol}`).join(", ")})]})]}):null})()}),e.jsx("div",{className:"form-hint",children:"Note: Existing containers will not be deleted when you remove this building."})]}),a!=="existing"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Pull Policy:",e.jsx(v,{text:"When to pull images: always, only if missing, or never.",title:"Pull Policy",position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:j,onChange:n=>F(n.target.value),children:Object.keys(Ms).map(n=>e.jsx("option",{value:n,children:Ms[n].label},n))})]}),e.jsxs("div",{className:"command-row env-row",children:[e.jsxs("span",{className:"command-label",children:["Environment:",e.jsx(v,{text:"Environment variables in KEY=value format, one per line.",title:"Environment Variables",position:"top",size:"sm"})]}),e.jsx("textarea",{className:"form-input form-textarea",value:M,onChange:n=>R(n.target.value),placeholder:`KEY=value
3
+ NODE_ENV=production`,rows:3})]}),e.jsx("div",{className:"pm2-examples",children:e.jsxs("details",{children:[e.jsx("summary",{children:p("terminal:building.pm2Examples")}),e.jsxs("div",{className:"pm2-examples-content",children:[e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Node.js:"})," Script: ",e.jsx("code",{children:"npm"}),", Args: ",e.jsx("code",{children:"run dev"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Symfony:"})," Script: ",e.jsx("code",{children:"symfony"}),", Args: ",e.jsx("code",{children:"serve --no-daemon"}),", Interpreter: ",e.jsx("code",{children:"None"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Java JAR:"})," Script: ",e.jsx("code",{children:"app.jar"}),", Interpreter: ",e.jsx("code",{children:"Java"}),", Interp. Args: ",e.jsx("code",{children:"-jar"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Python:"})," Script: ",e.jsx("code",{children:"app.py"}),", Interpreter: ",e.jsx("code",{children:"Python 3"})]})]})]})}),b&&(x==null?void 0:x.pm2Status)&&e.jsx("div",{className:"pm2-status-display",children:e.jsxs("div",{className:"pm2-status-row",children:[e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"PID"}),e.jsx("span",{className:"pm2-metric-value",children:x.pm2Status.pid||"-"})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"CPU"}),e.jsxs("span",{className:"pm2-metric-value",children:[((y=x.pm2Status.cpu)==null?void 0:y.toFixed(1))||"0","%"]})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"MEM"}),e.jsx("span",{className:"pm2-metric-value",children:Ve(x.pm2Status.memory||0)})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"Restarts"}),e.jsx("span",{className:"pm2-metric-value",children:x.pm2Status.restarts||0})]}),x.pm2Status.uptime&&e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"Uptime"}),e.jsx("span",{className:"pm2-metric-value",children:da(x.pm2Status.uptime)})]})]})}),b&&e.jsxs("div",{className:"pm2-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>N("start"),children:p("common:buttons.start")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>N("stop"),children:p("common:buttons.stop")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>N("restart"),children:p("terminal:buildingAction.restart")}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>N("logs"),children:p("terminal:logs.title")})]})]}):null}function xa({dockerMode:a,setDockerMode:l,dockerImage:c,setDockerImage:h,dockerContainerName:t,setDockerContainerName:o,dockerCommand:g,setDockerCommand:m,dockerPorts:d,setDockerPorts:s,dockerVolumes:u,setDockerVolumes:b,dockerNetwork:x,setDockerNetwork:N,dockerRestart:p,setDockerRestart:y,dockerPull:j,setDockerPull:F,dockerEnv:M,setDockerEnv:R,dockerComposePath:J,setDockerComposePath:U,dockerComposeProject:W,setDockerComposeProject:K,dockerComposeServices:Z,setDockerComposeServices:H,selectedExistingContainer:O,setSelectedExistingContainer:G,dockerContainersList:T,isEditMode:I,building:k,handleCommand:L}){const{t:z}=E(["config","common"]);return e.jsxs("div",{className:"form-section docker-config-section",children:[e.jsx("label",{className:"form-label",children:z("config:buildings.dockerConfig")}),e.jsxs("div",{className:"docker-mode-selector",children:[e.jsxs("label",{className:`docker-mode-option ${a==="container"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"container",checked:a==="container",onChange:()=>l("container")}),e.jsx("span",{className:"docker-mode-icon",children:"📦"}),e.jsx("span",{className:"docker-mode-label",children:"Container"}),e.jsx("span",{className:"docker-mode-desc",children:"Create a new container"})]}),e.jsxs("label",{className:`docker-mode-option ${a==="compose"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"compose",checked:a==="compose",onChange:()=>l("compose")}),e.jsx("span",{className:"docker-mode-icon",children:"🛠"}),e.jsx("span",{className:"docker-mode-label",children:"Compose"}),e.jsx("span",{className:"docker-mode-desc",children:"Manage multiple services"})]}),e.jsxs("label",{className:`docker-mode-option ${a==="existing"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"existing",checked:a==="existing",onChange:()=>l("existing")}),e.jsx("span",{className:"docker-mode-icon",children:"🔎"}),e.jsx("span",{className:"docker-mode-label",children:"Existing"}),e.jsx("span",{className:"docker-mode-desc",children:"Adopt existing container"})]})]}),a==="container"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Image:",e.jsx(v,{text:"Docker image to run, e.g., nginx:latest, redis:alpine, my-app:v1",title:"Image",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:c,onChange:n=>h(n.target.value),placeholder:"nginx:latest",required:!0})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Container Name:",e.jsx(v,{text:"Custom name for the container. If empty, auto-generated based on building name.",title:"Container Name",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:t,onChange:n=>o(n.target.value),placeholder:"Auto-generated (tc-{name}-{id})"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Command:",e.jsx(v,{text:"Override the default container command. Leave empty to use image's CMD.",title:"Command Override",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:g,onChange:n=>m(n.target.value),placeholder:"Optional command override"})]}),e.jsxs("div",{className:"form-section docker-ports-section",children:[e.jsxs("label",{className:"form-label",children:["Port Mappings",e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>s([...d,""]),children:"+ Add"})]}),d.map((n,C)=>e.jsxs("div",{className:"docker-mapping-row",children:[e.jsx("input",{type:"text",className:"form-input",value:n,onChange:B=>{const D=[...d];D[C]=B.target.value,s(D)},placeholder:"8080:80 or 3000"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>s(d.filter((B,D)=>D!==C)),children:"x"})]},C)),d.length===0&&e.jsx("div",{className:"form-hint",children:"Format: host:container (e.g., 8080:80) or same port (e.g., 3000)"})]}),e.jsxs("div",{className:"form-section docker-volumes-section",children:[e.jsxs("label",{className:"form-label",children:["Volume Mounts",e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>b([...u,""]),children:"+ Add"})]}),u.map((n,C)=>e.jsxs("div",{className:"docker-mapping-row",children:[e.jsx("input",{type:"text",className:"form-input",value:n,onChange:B=>{const D=[...u];D[C]=B.target.value,b(D)},placeholder:"./data:/app/data or /host/path:/container/path"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>b(u.filter((B,D)=>D!==C)),children:"x"})]},C)),u.length===0&&e.jsx("div",{className:"form-hint",children:"Format: host_path:container_path (relative paths resolved from working directory)"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Network:",e.jsx(v,{text:"Docker network to connect to. Leave empty for default bridge network.",title:"Network",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:x,onChange:n=>N(n.target.value),placeholder:"bridge (default)"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Restart Policy:",e.jsx(v,{text:"When should Docker restart the container automatically?",title:"Restart Policy",position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:p,onChange:n=>y(n.target.value),children:Object.keys(Fs).map(n=>e.jsx("option",{value:n,children:Fs[n].label},n))})]})]}),a==="compose"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Compose File:",e.jsx(v,{text:"Path to docker-compose.yml file, relative to working directory.",title:"Compose File",position:"top",size:"sm"})]}),e.jsx(He,{value:J,onChange:U,placeholder:"docker-compose.yml",className:"form-input",directoriesOnly:!1})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Project Name:",e.jsx(v,{text:"Override the compose project name. Leave empty for auto-generated name.",title:"Project Name",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:W,onChange:n=>K(n.target.value),placeholder:"Auto-generated"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Services:",e.jsx(v,{text:"Specific services to manage (comma-separated). Leave empty for all services.",title:"Services",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:Z,onChange:n=>H(n.target.value),placeholder:"All services (or: api, db, redis)"})]})]}),a==="existing"&&e.jsxs("div",{className:"docker-existing-section",children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Select Container:",e.jsx(v,{text:"Choose an existing Docker container to monitor and control. The container will not be deleted when removing the building.",title:"Existing Container",position:"top",size:"sm"})]}),e.jsxs("div",{className:"docker-existing-select-wrapper",children:[e.jsxs("select",{className:"form-input form-select",value:O,onChange:n=>G(n.target.value),required:a==="existing",children:[e.jsx("option",{value:"",children:"Select a container..."}),T.map(n=>e.jsxs("option",{value:n.name,children:[n.name," (",n.image,") - ",n.state]},n.id))]}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>P.requestDockerContainersList(),title:"Refresh container list",children:"↻"})]})]}),T.length===0&&e.jsx("div",{className:"form-hint docker-existing-hint",children:"No containers found. Make sure Docker is running and you have containers available."}),O&&e.jsx("div",{className:"docker-existing-info",children:(()=>{const n=T.find(C=>C.name===O);return n?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Image:"}),e.jsx("span",{className:"docker-existing-info-value",children:n.image})]}),e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Status:"}),e.jsx("span",{className:`docker-existing-info-value docker-status-${n.status}`,children:n.state})]}),e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"ID:"}),e.jsx("span",{className:"docker-existing-info-value",children:n.id.slice(0,12)})]}),n.ports.length>0&&e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Ports:"}),e.jsx("span",{className:"docker-existing-info-value",children:n.ports.map(C=>`${C.host}:${C.container}/${C.protocol}`).join(", ")})]})]}):null})()}),e.jsx("div",{className:"form-hint",children:"Note: Existing containers will not be deleted when you remove this building."})]}),a!=="existing"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Pull Policy:",e.jsx(v,{text:"When to pull images: always, only if missing, or never.",title:"Pull Policy",position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:j,onChange:n=>F(n.target.value),children:Object.keys(Ms).map(n=>e.jsx("option",{value:n,children:Ms[n].label},n))})]}),e.jsxs("div",{className:"command-row env-row",children:[e.jsxs("span",{className:"command-label",children:["Environment:",e.jsx(v,{text:"Environment variables in KEY=value format, one per line.",title:"Environment Variables",position:"top",size:"sm"})]}),e.jsx("textarea",{className:"form-input form-textarea",value:M,onChange:n=>R(n.target.value),placeholder:`KEY=value
4
4
  DATABASE_URL=postgres://...
5
- NODE_ENV=production`,rows:3})]})]}),I&&(k==null?void 0:k.dockerStatus)&&e.jsxs("div",{className:"docker-status-display",children:[e.jsxs("div",{className:"docker-status-row",children:[e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"ID"}),e.jsx("span",{className:"docker-metric-value",children:k.dockerStatus.containerId||"-"})]}),e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"Status"}),e.jsx("span",{className:"docker-metric-value",children:k.dockerStatus.status||"-"})]}),k.dockerStatus.health&&k.dockerStatus.health!=="none"&&e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"Health"}),e.jsx("span",{className:"docker-metric-value",children:k.dockerStatus.health})]}),k.dockerStatus.cpu!==void 0&&e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"CPU"}),e.jsxs("span",{className:"docker-metric-value",children:[k.dockerStatus.cpu.toFixed(1),"%"]})]}),k.dockerStatus.memory!==void 0&&e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"MEM"}),e.jsxs("span",{className:"docker-metric-value",children:[Ve(k.dockerStatus.memory),k.dockerStatus.memoryLimit?` / ${Ve(k.dockerStatus.memoryLimit)}`:""]})]})]}),k.dockerStatus.ports&&k.dockerStatus.ports.length>0&&e.jsxs("div",{className:"docker-ports-row",children:[e.jsx("span",{className:"docker-metric-label",children:"Ports:"}),k.dockerStatus.ports.map((n,C)=>e.jsxs("a",{href:`http://${window.location.hostname}:${n.host}`,target:"_blank",rel:"noopener noreferrer",className:"docker-port-link",children:[n.host,":",n.container,"/",n.protocol]},C))]}),k.dockerStatus.services&&k.dockerStatus.services.length>0&&e.jsxs("div",{className:"docker-services-status",children:[e.jsx("span",{className:"docker-metric-label",children:"Services:"}),e.jsx("div",{className:"docker-services-grid",children:k.dockerStatus.services.map((n,C)=>e.jsxs("div",{className:"docker-service-item",children:[e.jsx("span",{className:"docker-service-indicator",style:{backgroundColor:n.status==="running"?"#4ade80":"#f87171"}}),e.jsx("span",{className:"docker-service-name",children:n.name}),e.jsx("span",{className:"docker-service-status",children:n.status})]},C))})]})]}),I&&e.jsxs("div",{className:"docker-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>L("start"),children:"Start"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>L("stop"),children:"Stop"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>L("restart"),children:"Restart"}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>L("logs"),children:"Logs"})]})]})}function ba({dbConnections:a,setDbConnections:l,activeDbConnectionId:c,setActiveDbConnectionId:h}){const{t}=E(["terminal","common"]);return e.jsxs("div",{className:"form-section database-config-section",children:[e.jsxs("label",{className:"form-label",children:[t("terminal:building.dbConnections"),e.jsx(v,{text:t("terminal:building.helpDbConnections"),title:t("terminal:building.dbConnections"),position:"top",size:"sm"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>{const o={id:`conn_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,name:`Connection ${a.length+1}`,engine:"mysql",host:"localhost",port:3306,username:"root"};l([...a,o]),c||h(o.id)},children:t("terminal:database.addConnection")})]}),a.length===0&&e.jsx("div",{className:"form-hint",children:t("terminal:building.dbGetStarted")}),a.map((o,g)=>e.jsxs("div",{className:"db-connection-card",children:[e.jsxs("div",{className:"db-connection-header",children:[e.jsxs("label",{className:"db-connection-active",children:[e.jsx("input",{type:"radio",name:"activeConnection",checked:c===o.id,onChange:()=>h(o.id)}),t("common:labels.default"),e.jsx(v,{text:t("terminal:building.helpDbDefault"),position:"top",size:"sm"})]}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>{const m=a.filter(d=>d.id!==o.id);l(m),c===o.id&&m.length>0?h(m[0].id):m.length===0&&h(void 0)},children:t("common:buttons.remove")})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field",children:[e.jsx("label",{children:t("common:labels.name")}),e.jsx("input",{type:"text",className:"form-input",value:o.name,onChange:m=>{const d=[...a];d[g]={...o,name:m.target.value},l(d)},placeholder:"My Database"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsx("label",{children:t("terminal:building.dbEngine")}),e.jsx("select",{className:"form-input form-select",value:o.engine,onChange:m=>{const d=m.target.value,s=[...a];s[g]={...o,engine:d,port:Y[d].defaultPort},l(s)},children:Object.keys(Y).map(m=>e.jsxs("option",{value:m,children:[Y[m].icon," ",Y[m].label]},m))})]})]}),o.engine==="sqlite"?e.jsx("div",{className:"db-connection-row",children:e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:t("terminal:building.dbFilepath")}),e.jsx("input",{type:"text",className:"form-input",value:o.filepath||"",onChange:m=>{const d=[...a];d[g]={...o,filepath:m.target.value||void 0},l(d)},placeholder:"/path/to/database.db"})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:t("terminal:building.dbHost")}),e.jsx("input",{type:"text",className:"form-input",value:o.host,onChange:m=>{const d=[...a];d[g]={...o,host:m.target.value},l(d)},placeholder:"localhost"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsx("label",{children:t("terminal:building.dbPort")}),e.jsx("input",{type:"number",className:"form-input",value:o.port,onChange:m=>{const d=[...a];d[g]={...o,port:parseInt(m.target.value)||Y[o.engine].defaultPort},l(d)}})]})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field",children:[e.jsx("label",{children:t("terminal:building.dbUsername")}),e.jsx("input",{type:"text",className:"form-input",value:o.username,onChange:m=>{const d=[...a];d[g]={...o,username:m.target.value},l(d)},placeholder:"root"})]}),e.jsxs("div",{className:"db-field",children:[e.jsx("label",{children:t("terminal:building.dbPassword")}),e.jsx("input",{type:"password",className:"form-input",value:o.password||"",onChange:m=>{const d=[...a];d[g]={...o,password:m.target.value||void 0},l(d)},placeholder:"Optional"})]})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:t("terminal:building.dbDefaultDatabase")}),e.jsx("input",{type:"text",className:"form-input",value:o.database||"",onChange:m=>{const d=[...a];d[g]={...o,database:m.target.value||void 0},l(d)},placeholder:"Optional - select after connecting"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsxs("label",{children:["SSL",e.jsx(v,{text:t("terminal:building.helpDbSsl"),position:"top",size:"sm"})]}),e.jsxs("label",{className:"toggle-switch toggle-switch--small",children:[e.jsx("input",{type:"checkbox",checked:o.ssl||!1,onChange:m=>{const d=[...a];d[g]={...o,ssl:m.target.checked},l(d)}}),e.jsx("span",{className:"toggle-track",children:e.jsx("span",{className:"toggle-thumb"})})]})]})]})]})]},o.id)),a.length>0&&e.jsx("div",{className:"form-hint",children:t("terminal:building.dbAfterSaving")})]})}function ja({buildings:a,buildingId:l,subordinateBuildingIds:c,setSubordinateBuildingIds:h,isEditMode:t,showBossLogs:o,setShowBossLogs:g,currentBossLogs:m,bossLogsContainerRef:d}){const{t:s}=E(["terminal","common"]);return e.jsxs("div",{className:"form-section boss-building-section",children:[e.jsxs("label",{className:"form-label",children:[s("terminal:building.managedBuildings"),e.jsx(v,{text:s("terminal:building.helpManagedBuildings"),title:s("terminal:building.managedBuildings"),position:"top",size:"sm"})]}),e.jsx("div",{className:"form-hint",children:s("terminal:building.managedBuildingsHint")}),e.jsxs("div",{className:"subordinate-buildings-list",children:[Array.from(a.values()).filter(u=>u.id!==l&&u.type!=="boss"&&u.type!=="link"&&u.type!=="folder").map(u=>e.jsxs("label",{className:"subordinate-building-item",children:[e.jsx("input",{type:"checkbox",checked:c.includes(u.id),onChange:b=>{b.target.checked?h([...c,u.id]):h(c.filter(x=>x!==u.id))}}),e.jsx("span",{className:"subordinate-building-icon",children:e.jsx(A,{name:Hs(u.type),size:14})}),e.jsx("span",{className:"subordinate-building-name",children:u.name}),e.jsx("span",{className:"subordinate-building-status",style:{backgroundColor:Ge[u.status]}})]},u.id)),Array.from(a.values()).filter(u=>u.id!==l&&u.type!=="boss"&&u.type!=="link"&&u.type!=="folder").length===0&&e.jsx("div",{className:"form-hint no-buildings-hint",children:s("terminal:building.noManageableBuildings")})]}),t&&c.length>0&&e.jsxs("div",{className:"boss-building-actions",children:[e.jsxs("div",{className:"boss-actions-header",children:[s("terminal:building.bulkActions"),e.jsx(v,{text:s("terminal:building.helpBulkActions"),position:"top",size:"sm"})]}),e.jsxs("div",{className:"boss-actions-row",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>P.sendBossBuildingCommand(l,"start_all"),children:s("terminal:building.startAll")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>P.sendBossBuildingCommand(l,"stop_all"),children:s("terminal:building.stopAll")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>P.sendBossBuildingCommand(l,"restart_all"),children:s("terminal:building.restartAll")}),e.jsx("button",{type:"button",className:`btn btn-sm ${o?"btn-primary":""}`,onClick:()=>{o?(P.stopBossLogStreaming(l),g(!1)):(P.startBossLogStreaming(l),g(!0))},children:s(o?"terminal:building.hideLogs":"terminal:building.unifiedLogs")})]}),e.jsxs("div",{className:"boss-subordinates-status",children:[e.jsx("div",{className:"boss-status-header",children:s("terminal:building.statusOverview")}),e.jsx("div",{className:"boss-status-grid",children:c.map(u=>{const b=a.get(u);return b?e.jsxs("div",{className:"boss-status-item",children:[e.jsx("span",{className:"boss-status-indicator",style:{backgroundColor:Ge[b.status]}}),e.jsx("span",{className:"boss-status-name",children:b.name}),e.jsx("span",{className:"boss-status-label",children:b.status})]},u):null})})]})]}),t&&o&&e.jsxs("div",{className:"form-section boss-logs-section",children:[e.jsxs("label",{className:"form-label",children:[s("terminal:building.unifiedLogs"),e.jsx(v,{text:s("terminal:building.helpUnifiedLogs"),position:"top",size:"sm"}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>P.clearBossStreamingLogs(l),children:s("common:buttons.clear")})]}),e.jsxs("div",{className:"boss-logs-container",ref:d,children:[m.map((u,b)=>e.jsxs("div",{className:"boss-log-entry",children:[e.jsxs("span",{className:"boss-log-source",children:["[",u.subordinateName,"]"]}),e.jsx("span",{className:"boss-log-content",children:Gs(u.chunk)})]},b)),m.length===0&&e.jsx("div",{className:"boss-logs-empty",children:s("terminal:building.waitingForLogs")})]})]})]})}function ga({startCmd:a,setStartCmd:l,stopCmd:c,setStopCmd:h,restartCmd:t,setRestartCmd:o,healthCheckCmd:g,setHealthCheckCmd:m,logsCmd:d,setLogsCmd:s,isEditMode:u,handleCommand:b}){const{t:x}=E(["terminal","common"]);return e.jsxs("div",{className:"form-section commands-section",children:[e.jsxs("label",{className:"form-label",children:[x("terminal:building.commands"),e.jsx(v,{text:x("terminal:building.helpCommands"),title:x("terminal:building.commands"),position:"top",size:"sm"})]}),e.jsxs("div",{className:"command-inputs",children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdStart"),e.jsx(v,{text:x("terminal:building.helpCmdStart"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:a,onChange:N=>l(N.target.value),placeholder:"npm run dev"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>b("start"),disabled:!a,children:x("common:buttons2.run")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdStop"),e.jsx(v,{text:x("terminal:building.helpCmdStop"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:c,onChange:N=>h(N.target.value),placeholder:"pkill -f 'npm run dev'"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>b("stop"),disabled:!c,children:x("common:buttons2.run")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdRestart"),e.jsx(v,{text:x("terminal:building.helpCmdRestart"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:t,onChange:N=>o(N.target.value),placeholder:"npm run restart"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>b("restart"),disabled:!t,children:x("common:buttons2.run")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdHealthCheck"),e.jsx(v,{text:x("terminal:building.helpCmdHealthCheck"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:g,onChange:N=>m(N.target.value),placeholder:"curl -s http://localhost:3000/health"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>b("healthCheck"),disabled:!g,children:x("terminal:building.check")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdLogs"),e.jsx(v,{text:x("terminal:building.helpCmdLogs"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:d,onChange:N=>s(N.target.value),placeholder:"tail -n 100 /var/log/app.log"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>b("logs"),children:x("terminal:building.fetch")})]})]})]})}const va=[{value:"",label:"Default ($SHELL)"},{value:"/bin/bash",label:"Bash"},{value:"/bin/zsh",label:"Zsh"},{value:"/usr/bin/fish",label:"Fish"},{value:"/bin/sh",label:"sh"}];function Na({terminalShell:a,setTerminalShell:l,terminalPort:c,setTerminalPort:h,terminalSaveSession:t,setTerminalSaveSession:o,terminalArgs:g,setTerminalArgs:m,isEditMode:d,building:s,handleCommand:u,onOpenTerminal:b,onOpenBelow:x}){const{t:N}=E(["config"]),p=(s==null?void 0:s.status)==="running",y=s==null?void 0:s.terminalStatus;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:N("config:buildings.terminalConfig",{defaultValue:"Terminal Configuration"})}),e.jsxs("div",{className:"form-row",children:[e.jsxs("div",{className:"form-field",children:[e.jsx("label",{className:"form-sublabel",children:N("config:buildings.terminalShell",{defaultValue:"Shell"})}),e.jsx("select",{className:"form-input",value:a,onChange:j=>l(j.target.value),children:va.map(j=>e.jsx("option",{value:j.value,children:j.label},j.value))})]}),e.jsxs("div",{className:"form-field",children:[e.jsx("label",{className:"form-sublabel",children:N("config:buildings.terminalPort",{defaultValue:"Port"})}),e.jsx("input",{type:"number",className:"form-input",value:c,onChange:j=>h(j.target.value),placeholder:"Auto",min:1024,max:65535})]})]}),e.jsx("div",{className:"form-row",style:{marginTop:"8px"},children:e.jsxs("label",{className:"form-checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:j=>o(j.target.checked)}),e.jsx("span",{children:N("config:buildings.terminalSaveSession",{defaultValue:"Persist session (tmux)"})})]})}),e.jsxs("div",{style:{marginTop:"8px"},children:[e.jsx("label",{className:"form-sublabel",children:N("config:buildings.terminalArgs",{defaultValue:"Extra ttyd args"})}),e.jsx("input",{type:"text",className:"form-input",value:g,onChange:j=>m(j.target.value),placeholder:"--client-option titleFixed=Terminal"}),e.jsx("div",{className:"form-hint",children:"Additional command-line arguments passed to ttyd"})]})]}),d&&s&&e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:N("config:buildings.terminalControls",{defaultValue:"Terminal Controls"})}),y&&e.jsxs("div",{className:"building-runtime-info",children:[e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"Proxy"}),e.jsx("span",{className:"runtime-value",style:{color:"#4a9eff"},children:y.url})]}),e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"PID"}),e.jsx("span",{className:"runtime-value",children:y.pid})]}),e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"Port"}),e.jsx("span",{className:"runtime-value",children:y.port})]}),y.tmuxSession&&e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"Session"}),e.jsx("span",{className:"runtime-value",children:y.tmuxSession})]})]}),e.jsxs("div",{className:"building-actions",style:{marginTop:"8px"},children:[!p&&e.jsxs("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>u("start"),children:[e.jsx(A,{name:"play",size:12})," Start"]}),p&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>u("restart"),children:[e.jsx(A,{name:"refresh",size:12})," Restart"]}),e.jsxs("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>u("stop"),children:[e.jsx(A,{name:"stop",size:12})," Stop"]}),(y==null?void 0:y.url)&&e.jsxs(e.Fragment,{children:[b&&e.jsxs("button",{type:"button",className:"btn btn-sm btn-primary",onClick:()=>b(y.url),children:[e.jsx(A,{name:"desktop",size:12})," Modal"]}),x&&s&&e.jsxs("button",{type:"button",className:"btn btn-sm btn-primary",onClick:()=>x(s.id),children:[e.jsx(A,{name:"arrow-down",size:12})," Below"]})]})]})]})]})]})}function fa({logs:a,buildingId:l,logsContainerRef:c}){return e.jsxs("div",{className:"form-section logs-section",children:[e.jsxs("label",{className:"form-label",children:["Logs",e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>P.clearBuildingLogs(l),children:"Clear"})]}),e.jsx("div",{className:"logs-container",ref:c,children:a.map((h,t)=>e.jsx("pre",{className:"log-entry",children:Gs(h)},t))})]})}function Sa({isOpen:a,onClose:l,buildingId:c,initialPosition:h}){const{t}=E(["config","common"]),{buildings:o,buildingLogs:g,bossStreamingLogs:m}=na(),d=la(),s=c?o.get(c):null,u=c?m.get(c)||[]:[],b=!!s,[x,N]=r.useState(""),[p,y]=r.useState("server"),[j,F]=r.useState("server-rack"),[M,R]=r.useState(""),[J,U]=r.useState(""),[W,K]=r.useState(""),[Z,H]=r.useState(""),[T,G]=r.useState(""),[O,I]=r.useState(""),[k,L]=r.useState(""),[z,n]=r.useState([]),[C,B]=r.useState(!1),[D,se]=r.useState(""),[V,Q]=r.useState(1),[q,ae]=r.useState(!1),[qe,te]=r.useState(""),[Ye,ne]=r.useState(""),[Je,le]=r.useState(""),[We,ie]=r.useState(""),[Ze,oe]=r.useState(""),[Vs,re]=r.useState(!1),[w,ce]=r.useState("container"),[me,de]=r.useState(""),[Qe,ue]=r.useState(""),[pe,he]=r.useState(""),[xe,be]=r.useState([]),[je,ge]=r.useState([]),[Xe,ve]=r.useState(""),[Ne,fe]=r.useState(""),[ke,ye]=r.useState(""),[es,Ce]=r.useState("unless-stopped"),[ss,Se]=r.useState("missing"),[we,Pe]=r.useState(""),[De,Ee]=r.useState(""),[Le,ze]=r.useState(""),[Ae,Be]=r.useState([]),[qs,Ys]=r.useState(!1),[Re,Te]=r.useState([]),[as,Oe]=r.useState(void 0),[ts,Ie]=r.useState(""),[_e,$e]=r.useState(""),[ns,Fe]=r.useState(!1),[ls,Me]=r.useState(""),is=r.useRef(null),Js=r.useRef(null),X=r.useRef(null);r.useEffect(()=>{var i,f,S,_,ms,ds,us,ps,hs,xs,bs,js,gs,vs,Ns,fs,ks,ys,Cs,Ss,ws,Ps,Ds,Es,Ls,zs,As,Bs,Rs,Ts,Os,Is,_s;a&&(s?(N(s.name),y(s.type),F(s.style||"server-rack"),R(s.color||""),U(s.cwd||""),K(((i=s.commands)==null?void 0:i.start)||""),H(((f=s.commands)==null?void 0:f.stop)||""),G(((S=s.commands)==null?void 0:S.restart)||""),I(((_=s.commands)==null?void 0:_.healthCheck)||""),L(((ms=s.commands)==null?void 0:ms.logs)||""),n(s.urls||[]),se(s.folderPath||""),Q(s.scale||1),ae(((ds=s.pm2)==null?void 0:ds.enabled)||!1),te(((us=s.pm2)==null?void 0:us.script)||""),ne(((ps=s.pm2)==null?void 0:ps.args)||""),le(((hs=s.pm2)==null?void 0:hs.interpreter)||""),ie(((xs=s.pm2)==null?void 0:xs.interpreterArgs)||""),oe((bs=s.pm2)!=null&&bs.env?Object.entries(s.pm2.env).map(([$,Ue])=>`${$}=${Ue}`).join(`
5
+ NODE_ENV=production`,rows:3})]})]}),I&&(k==null?void 0:k.dockerStatus)&&e.jsxs("div",{className:"docker-status-display",children:[e.jsxs("div",{className:"docker-status-row",children:[e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"ID"}),e.jsx("span",{className:"docker-metric-value",children:k.dockerStatus.containerId||"-"})]}),e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"Status"}),e.jsx("span",{className:"docker-metric-value",children:k.dockerStatus.status||"-"})]}),k.dockerStatus.health&&k.dockerStatus.health!=="none"&&e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"Health"}),e.jsx("span",{className:"docker-metric-value",children:k.dockerStatus.health})]}),k.dockerStatus.cpu!==void 0&&e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"CPU"}),e.jsxs("span",{className:"docker-metric-value",children:[k.dockerStatus.cpu.toFixed(1),"%"]})]}),k.dockerStatus.memory!==void 0&&e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"MEM"}),e.jsxs("span",{className:"docker-metric-value",children:[Ve(k.dockerStatus.memory),k.dockerStatus.memoryLimit?` / ${Ve(k.dockerStatus.memoryLimit)}`:""]})]})]}),k.dockerStatus.ports&&k.dockerStatus.ports.length>0&&e.jsxs("div",{className:"docker-ports-row",children:[e.jsx("span",{className:"docker-metric-label",children:"Ports:"}),k.dockerStatus.ports.map((n,C)=>e.jsxs("a",{href:`http://${window.location.hostname}:${n.host}`,target:"_blank",rel:"noopener noreferrer",className:"docker-port-link",children:[n.host,":",n.container,"/",n.protocol]},C))]}),k.dockerStatus.services&&k.dockerStatus.services.length>0&&e.jsxs("div",{className:"docker-services-status",children:[e.jsx("span",{className:"docker-metric-label",children:"Services:"}),e.jsx("div",{className:"docker-services-grid",children:k.dockerStatus.services.map((n,C)=>e.jsxs("div",{className:"docker-service-item",children:[e.jsx("span",{className:"docker-service-indicator",style:{backgroundColor:n.status==="running"?"#4ade80":"#f87171"}}),e.jsx("span",{className:"docker-service-name",children:n.name}),e.jsx("span",{className:"docker-service-status",children:n.status})]},C))})]})]}),I&&e.jsxs("div",{className:"docker-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>L("start"),children:"Start"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>L("stop"),children:"Stop"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>L("restart"),children:"Restart"}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>L("logs"),children:"Logs"})]})]})}function ba({dbConnections:a,setDbConnections:l,activeDbConnectionId:c,setActiveDbConnectionId:h}){const{t}=E(["terminal","common"]);return e.jsxs("div",{className:"form-section database-config-section",children:[e.jsxs("label",{className:"form-label",children:[t("terminal:building.dbConnections"),e.jsx(v,{text:t("terminal:building.helpDbConnections"),title:t("terminal:building.dbConnections"),position:"top",size:"sm"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>{const o={id:`conn_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,name:`Connection ${a.length+1}`,engine:"mysql",host:"localhost",port:3306,username:"root"};l([...a,o]),c||h(o.id)},children:t("terminal:database.addConnection")})]}),a.length===0&&e.jsx("div",{className:"form-hint",children:t("terminal:building.dbGetStarted")}),a.map((o,g)=>e.jsxs("div",{className:"db-connection-card",children:[e.jsxs("div",{className:"db-connection-header",children:[e.jsxs("label",{className:"db-connection-active",children:[e.jsx("input",{type:"radio",name:"activeConnection",checked:c===o.id,onChange:()=>h(o.id)}),t("common:labels.default"),e.jsx(v,{text:t("terminal:building.helpDbDefault"),position:"top",size:"sm"})]}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>{const m=a.filter(d=>d.id!==o.id);l(m),c===o.id&&m.length>0?h(m[0].id):m.length===0&&h(void 0)},children:t("common:buttons.remove")})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field",children:[e.jsx("label",{children:t("common:labels.name")}),e.jsx("input",{type:"text",className:"form-input",value:o.name,onChange:m=>{const d=[...a];d[g]={...o,name:m.target.value},l(d)},placeholder:"My Database"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsx("label",{children:t("terminal:building.dbEngine")}),e.jsx("select",{className:"form-input form-select",value:o.engine,onChange:m=>{const d=m.target.value,s=[...a];s[g]={...o,engine:d,port:Y[d].defaultPort},l(s)},children:Object.keys(Y).map(m=>e.jsxs("option",{value:m,children:[Y[m].icon," ",Y[m].label]},m))})]})]}),o.engine==="sqlite"?e.jsx("div",{className:"db-connection-row",children:e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:t("terminal:building.dbFilepath")}),e.jsx("input",{type:"text",className:"form-input",value:o.filepath||"",onChange:m=>{const d=[...a];d[g]={...o,filepath:m.target.value||void 0},l(d)},placeholder:"/path/to/database.db"})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:t("terminal:building.dbHost")}),e.jsx("input",{type:"text",className:"form-input",value:o.host,onChange:m=>{const d=[...a];d[g]={...o,host:m.target.value},l(d)},placeholder:"localhost"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsx("label",{children:t("terminal:building.dbPort")}),e.jsx("input",{type:"number",className:"form-input",value:o.port,onChange:m=>{const d=[...a];d[g]={...o,port:parseInt(m.target.value)||Y[o.engine].defaultPort},l(d)}})]})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field",children:[e.jsx("label",{children:t("terminal:building.dbUsername")}),e.jsx("input",{type:"text",className:"form-input",value:o.username,onChange:m=>{const d=[...a];d[g]={...o,username:m.target.value},l(d)},placeholder:"root"})]}),e.jsxs("div",{className:"db-field",children:[e.jsx("label",{children:t("terminal:building.dbPassword")}),e.jsx("input",{type:"password",className:"form-input",value:o.password||"",onChange:m=>{const d=[...a];d[g]={...o,password:m.target.value||void 0},l(d)},placeholder:"Optional"})]})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:t("terminal:building.dbDefaultDatabase")}),e.jsx("input",{type:"text",className:"form-input",value:o.database||"",onChange:m=>{const d=[...a];d[g]={...o,database:m.target.value||void 0},l(d)},placeholder:"Optional - select after connecting"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsxs("label",{children:["SSL",e.jsx(v,{text:t("terminal:building.helpDbSsl"),position:"top",size:"sm"})]}),e.jsxs("label",{className:"toggle-switch toggle-switch--small",children:[e.jsx("input",{type:"checkbox",checked:o.ssl||!1,onChange:m=>{const d=[...a];d[g]={...o,ssl:m.target.checked},l(d)}}),e.jsx("span",{className:"toggle-track",children:e.jsx("span",{className:"toggle-thumb"})})]})]})]})]})]},o.id)),a.length>0&&e.jsx("div",{className:"form-hint",children:t("terminal:building.dbAfterSaving")})]})}function ja({buildings:a,buildingId:l,subordinateBuildingIds:c,setSubordinateBuildingIds:h,isEditMode:t,showBossLogs:o,setShowBossLogs:g,currentBossLogs:m,bossLogsContainerRef:d}){const{t:s}=E(["terminal","common"]);return e.jsxs("div",{className:"form-section boss-building-section",children:[e.jsxs("label",{className:"form-label",children:[s("terminal:building.managedBuildings"),e.jsx(v,{text:s("terminal:building.helpManagedBuildings"),title:s("terminal:building.managedBuildings"),position:"top",size:"sm"})]}),e.jsx("div",{className:"form-hint",children:s("terminal:building.managedBuildingsHint")}),e.jsxs("div",{className:"subordinate-buildings-list",children:[Array.from(a.values()).filter(u=>u.id!==l&&u.type!=="boss"&&u.type!=="link"&&u.type!=="folder").map(u=>e.jsxs("label",{className:"subordinate-building-item",children:[e.jsx("input",{type:"checkbox",checked:c.includes(u.id),onChange:b=>{b.target.checked?h([...c,u.id]):h(c.filter(x=>x!==u.id))}}),e.jsx("span",{className:"subordinate-building-icon",children:e.jsx(A,{name:Hs(u.type),size:14})}),e.jsx("span",{className:"subordinate-building-name",children:u.name}),e.jsx("span",{className:"subordinate-building-status",style:{backgroundColor:Ge[u.status]}})]},u.id)),Array.from(a.values()).filter(u=>u.id!==l&&u.type!=="boss"&&u.type!=="link"&&u.type!=="folder").length===0&&e.jsx("div",{className:"form-hint no-buildings-hint",children:s("terminal:building.noManageableBuildings")})]}),t&&c.length>0&&e.jsxs("div",{className:"boss-building-actions",children:[e.jsxs("div",{className:"boss-actions-header",children:[s("terminal:building.bulkActions"),e.jsx(v,{text:s("terminal:building.helpBulkActions"),position:"top",size:"sm"})]}),e.jsxs("div",{className:"boss-actions-row",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>P.sendBossBuildingCommand(l,"start_all"),children:s("terminal:building.startAll")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>P.sendBossBuildingCommand(l,"stop_all"),children:s("terminal:building.stopAll")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>P.sendBossBuildingCommand(l,"restart_all"),children:s("terminal:building.restartAll")}),e.jsx("button",{type:"button",className:`btn btn-sm ${o?"btn-primary":""}`,onClick:()=>{o?(P.stopBossLogStreaming(l),g(!1)):(P.startBossLogStreaming(l),g(!0))},children:s(o?"terminal:building.hideLogs":"terminal:building.unifiedLogs")})]}),e.jsxs("div",{className:"boss-subordinates-status",children:[e.jsx("div",{className:"boss-status-header",children:s("terminal:building.statusOverview")}),e.jsx("div",{className:"boss-status-grid",children:c.map(u=>{const b=a.get(u);return b?e.jsxs("div",{className:"boss-status-item",children:[e.jsx("span",{className:"boss-status-indicator",style:{backgroundColor:Ge[b.status]}}),e.jsx("span",{className:"boss-status-name",children:b.name}),e.jsx("span",{className:"boss-status-label",children:b.status})]},u):null})})]})]}),t&&o&&e.jsxs("div",{className:"form-section boss-logs-section",children:[e.jsxs("label",{className:"form-label",children:[s("terminal:building.unifiedLogs"),e.jsx(v,{text:s("terminal:building.helpUnifiedLogs"),position:"top",size:"sm"}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>P.clearBossStreamingLogs(l),children:s("common:buttons.clear")})]}),e.jsxs("div",{className:"boss-logs-container",ref:d,children:[m.map((u,b)=>e.jsxs("div",{className:"boss-log-entry",children:[e.jsxs("span",{className:"boss-log-source",children:["[",u.subordinateName,"]"]}),e.jsx("span",{className:"boss-log-content",children:Gs(u.chunk)})]},b)),m.length===0&&e.jsx("div",{className:"boss-logs-empty",children:s("terminal:building.waitingForLogs")})]})]})]})}function ga({startCmd:a,setStartCmd:l,stopCmd:c,setStopCmd:h,restartCmd:t,setRestartCmd:o,healthCheckCmd:g,setHealthCheckCmd:m,logsCmd:d,setLogsCmd:s,isEditMode:u,handleCommand:b}){const{t:x}=E(["terminal","common"]);return e.jsxs("div",{className:"form-section commands-section",children:[e.jsxs("label",{className:"form-label",children:[x("terminal:building.commands"),e.jsx(v,{text:x("terminal:building.helpCommands"),title:x("terminal:building.commands"),position:"top",size:"sm"})]}),e.jsxs("div",{className:"command-inputs",children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdStart"),e.jsx(v,{text:x("terminal:building.helpCmdStart"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:a,onChange:N=>l(N.target.value),placeholder:"npm run dev"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>b("start"),disabled:!a,children:x("common:buttons2.run")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdStop"),e.jsx(v,{text:x("terminal:building.helpCmdStop"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:c,onChange:N=>h(N.target.value),placeholder:"pkill -f 'npm run dev'"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>b("stop"),disabled:!c,children:x("common:buttons2.run")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdRestart"),e.jsx(v,{text:x("terminal:building.helpCmdRestart"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:t,onChange:N=>o(N.target.value),placeholder:"npm run restart"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>b("restart"),disabled:!t,children:x("common:buttons2.run")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdHealthCheck"),e.jsx(v,{text:x("terminal:building.helpCmdHealthCheck"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:g,onChange:N=>m(N.target.value),placeholder:"curl -s http://localhost:3000/health"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>b("healthCheck"),disabled:!g,children:x("terminal:building.check")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdLogs"),e.jsx(v,{text:x("terminal:building.helpCmdLogs"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:d,onChange:N=>s(N.target.value),placeholder:"tail -n 100 /var/log/app.log"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>b("logs"),children:x("terminal:building.fetch")})]})]})]})}const va=[{value:"",label:"Default ($SHELL)"},{value:"/bin/bash",label:"Bash"},{value:"/bin/zsh",label:"Zsh"},{value:"/usr/bin/fish",label:"Fish"},{value:"/bin/sh",label:"sh"}];function Na({terminalShell:a,setTerminalShell:l,terminalPort:c,setTerminalPort:h,terminalSaveSession:t,setTerminalSaveSession:o,terminalArgs:g,setTerminalArgs:m,isEditMode:d,building:s,handleCommand:u,onOpenTerminal:b,onOpenBelow:x}){const{t:N}=E(["config"]),p=(s==null?void 0:s.status)==="running",y=s==null?void 0:s.terminalStatus;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:N("config:buildings.terminalConfig",{defaultValue:"Terminal Configuration"})}),e.jsxs("div",{className:"form-row",children:[e.jsxs("div",{className:"form-field",children:[e.jsx("label",{className:"form-sublabel",children:N("config:buildings.terminalShell",{defaultValue:"Shell"})}),e.jsx("select",{className:"form-input",value:a,onChange:j=>l(j.target.value),children:va.map(j=>e.jsx("option",{value:j.value,children:j.label},j.value))})]}),e.jsxs("div",{className:"form-field",children:[e.jsx("label",{className:"form-sublabel",children:N("config:buildings.terminalPort",{defaultValue:"Port"})}),e.jsx("input",{type:"number",className:"form-input",value:c,onChange:j=>h(j.target.value),placeholder:"Auto",min:1024,max:65535})]})]}),e.jsx("div",{className:"form-row",style:{marginTop:"8px"},children:e.jsxs("label",{className:"form-checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:j=>o(j.target.checked)}),e.jsx("span",{children:N("config:buildings.terminalSaveSession",{defaultValue:"Persist session (tmux)"})})]})}),e.jsxs("div",{style:{marginTop:"8px"},children:[e.jsx("label",{className:"form-sublabel",children:N("config:buildings.terminalArgs",{defaultValue:"Extra ttyd args"})}),e.jsx("input",{type:"text",className:"form-input",value:g,onChange:j=>m(j.target.value),placeholder:"--client-option titleFixed=Terminal"}),e.jsx("div",{className:"form-hint",children:"Additional command-line arguments passed to ttyd"})]})]}),d&&s&&e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:N("config:buildings.terminalControls",{defaultValue:"Terminal Controls"})}),y&&e.jsxs("div",{className:"building-runtime-info",children:[e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"Proxy"}),e.jsx("span",{className:"runtime-value",style:{color:"#4a9eff"},children:y.url})]}),e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"PID"}),e.jsx("span",{className:"runtime-value",children:y.pid})]}),e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"Port"}),e.jsx("span",{className:"runtime-value",children:y.port})]}),y.tmuxSession&&e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"Session"}),e.jsx("span",{className:"runtime-value",children:y.tmuxSession})]})]}),e.jsxs("div",{className:"building-actions",style:{marginTop:"8px"},children:[!p&&e.jsxs("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>u("start"),children:[e.jsx(A,{name:"play",size:12})," Start"]}),p&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>u("restart"),children:[e.jsx(A,{name:"refresh",size:12})," Restart"]}),e.jsxs("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>u("stop"),children:[e.jsx(A,{name:"stop",size:12})," Stop"]}),(y==null?void 0:y.url)&&e.jsxs(e.Fragment,{children:[b&&e.jsxs("button",{type:"button",className:"btn btn-sm btn-primary",onClick:()=>b(y.url),children:[e.jsx(A,{name:"desktop",size:12})," Modal"]}),x&&s&&e.jsxs("button",{type:"button",className:"btn btn-sm btn-primary",onClick:()=>x(s.id),children:[e.jsx(A,{name:"arrow-down",size:12})," Below"]})]})]})]})]})]})}function fa({logs:a,buildingId:l,logsContainerRef:c}){return e.jsxs("div",{className:"form-section logs-section",children:[e.jsxs("label",{className:"form-label",children:["Logs",e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>P.clearBuildingLogs(l),children:"Clear"})]}),e.jsx("div",{className:"logs-container",ref:c,children:a.map((h,t)=>e.jsx("pre",{className:"log-entry",children:Gs(h)},t))})]})}function Sa({isOpen:a,onClose:l,buildingId:c,initialPosition:h}){const{t}=E(["config","common"]),{buildings:o,buildingLogs:g,bossStreamingLogs:m}=na(),d=la(),s=c?o.get(c):null,u=c?m.get(c)||[]:[],b=!!s,[x,N]=r.useState(""),[p,y]=r.useState("server"),[j,F]=r.useState("server-rack"),[M,R]=r.useState(""),[J,U]=r.useState(""),[W,K]=r.useState(""),[Z,H]=r.useState(""),[O,G]=r.useState(""),[T,I]=r.useState(""),[k,L]=r.useState(""),[z,n]=r.useState([]),[C,B]=r.useState(!1),[D,se]=r.useState(""),[V,Q]=r.useState(1),[q,ae]=r.useState(!1),[qe,te]=r.useState(""),[Ye,ne]=r.useState(""),[Je,le]=r.useState(""),[We,ie]=r.useState(""),[Ze,oe]=r.useState(""),[Vs,re]=r.useState(!1),[w,ce]=r.useState("container"),[me,de]=r.useState(""),[Qe,ue]=r.useState(""),[pe,he]=r.useState(""),[xe,be]=r.useState([]),[je,ge]=r.useState([]),[Xe,ve]=r.useState(""),[Ne,fe]=r.useState(""),[ke,ye]=r.useState(""),[es,Ce]=r.useState("unless-stopped"),[ss,Se]=r.useState("missing"),[we,Pe]=r.useState(""),[De,Ee]=r.useState(""),[Le,ze]=r.useState(""),[Ae,Be]=r.useState([]),[qs,Ys]=r.useState(!1),[Re,Oe]=r.useState([]),[as,Te]=r.useState(void 0),[ts,Ie]=r.useState(""),[_e,$e]=r.useState(""),[ns,Fe]=r.useState(!1),[ls,Me]=r.useState(""),is=r.useRef(null),Js=r.useRef(null),X=r.useRef(null);r.useEffect(()=>{var i,f,S,_,ms,ds,us,ps,hs,xs,bs,js,gs,vs,Ns,fs,ks,ys,Cs,Ss,ws,Ps,Ds,Es,Ls,zs,As,Bs,Rs,Os,Ts,Is,_s;a&&(s?(N(s.name),y(s.type),F(s.style||"server-rack"),R(s.color||""),U(s.cwd||""),K(((i=s.commands)==null?void 0:i.start)||""),H(((f=s.commands)==null?void 0:f.stop)||""),G(((S=s.commands)==null?void 0:S.restart)||""),I(((_=s.commands)==null?void 0:_.healthCheck)||""),L(((ms=s.commands)==null?void 0:ms.logs)||""),n(s.urls||[]),se(s.folderPath||""),Q(s.scale||1),ae(((ds=s.pm2)==null?void 0:ds.enabled)||!1),te(((us=s.pm2)==null?void 0:us.script)||""),ne(((ps=s.pm2)==null?void 0:ps.args)||""),le(((hs=s.pm2)==null?void 0:hs.interpreter)||""),ie(((xs=s.pm2)==null?void 0:xs.interpreterArgs)||""),oe((bs=s.pm2)!=null&&bs.env?Object.entries(s.pm2.env).map(([$,Ue])=>`${$}=${Ue}`).join(`
6
6
  `):""),ce(((js=s.docker)==null?void 0:js.mode)||"container"),de(((gs=s.docker)==null?void 0:gs.mode)==="existing"&&((vs=s.docker)==null?void 0:vs.containerName)||""),ue(((Ns=s.docker)==null?void 0:Ns.image)||""),he(((fs=s.docker)==null?void 0:fs.containerName)||""),be(((ks=s.docker)==null?void 0:ks.ports)||[]),ge(((ys=s.docker)==null?void 0:ys.volumes)||[]),ve((Cs=s.docker)!=null&&Cs.env?Object.entries(s.docker.env).map(([$,Ue])=>`${$}=${Ue}`).join(`
7
- `):""),fe(((Ss=s.docker)==null?void 0:Ss.network)||""),ye(((ws=s.docker)==null?void 0:ws.command)||""),Ce(((Ps=s.docker)==null?void 0:Ps.restart)||"unless-stopped"),Se(((Ds=s.docker)==null?void 0:Ds.pull)||"missing"),Pe(((Es=s.docker)==null?void 0:Es.composePath)||""),Ee(((Ls=s.docker)==null?void 0:Ls.composeProject)||""),ze(((As=(zs=s.docker)==null?void 0:zs.services)==null?void 0:As.join(", "))||""),Be(s.subordinateBuildingIds||[]),Te(((Bs=s.database)==null?void 0:Bs.connections)||[]),Oe((Rs=s.database)==null?void 0:Rs.activeConnectionId),Ie(((Ts=s.terminal)==null?void 0:Ts.shell)||""),$e((Os=s.terminal)!=null&&Os.port?String(s.terminal.port):""),Fe(((Is=s.terminal)==null?void 0:Is.saveSession)||!1),Me(((_s=s.terminal)==null?void 0:_s.args)||"")):(N("New Server"),y("server"),F("server-rack"),R(""),U(ia(oa.LAST_CWD)),K(""),H(""),G(""),I(""),L(""),n([]),se(""),Q(1),ae(!1),te(""),ne(""),le(""),ie(""),oe(""),ce("container"),de(""),ue(""),he(""),be([]),ge([]),ve(""),fe(""),ye(""),Ce("unless-stopped"),Se("missing"),Pe(""),Ee(""),ze(""),Be([]),Te([]),Oe(void 0),Ie(""),$e(""),Fe(!1),Me("")),setTimeout(()=>{var $;return($=is.current)==null?void 0:$.focus()},100))},[a,s]),r.useEffect(()=>{X.current&&(X.current.scrollTop=X.current.scrollHeight)},[g]),r.useEffect(()=>{p==="docker"&&w==="existing"&&P.requestDockerContainersList()},[p,w]);const os=i=>{if(i.trim())return Object.fromEntries(i.trim().split(`
8
- `).map(f=>f.trim()).filter(f=>f&&f.includes("=")).map(f=>{const S=f.indexOf("=");return[f.slice(0,S),f.slice(S+1)]}))},Ws=i=>{i.preventDefault();const f={name:x,type:p,style:j,color:M||void 0,position:h||(s==null?void 0:s.position)||{x:0,z:0},cwd:J||void 0,folderPath:D||void 0,commands:q?void 0:{start:W||void 0,stop:Z||void 0,restart:T||void 0,healthCheck:O||void 0,logs:k||void 0},pm2:q?{enabled:!0,script:qe,args:Ye||void 0,interpreter:Je||void 0,interpreterArgs:We||void 0,env:os(Ze)}:void 0,docker:p==="docker"?{enabled:!0,mode:w,image:w==="container"?Qe:void 0,containerName:w==="container"&&pe?pe:w==="existing"&&me?me:void 0,ports:w==="container"&&xe.length>0?xe:void 0,volumes:w==="container"&&je.length>0?je:void 0,env:os(Xe),network:w==="container"&&Ne?Ne:void 0,command:w==="container"&&ke?ke:void 0,restart:w==="container"?es:void 0,pull:w!=="existing"?ss:void 0,composePath:w==="compose"&&we?we:void 0,composeProject:w==="compose"&&De?De:void 0,services:w==="compose"&&Le?Le.split(",").map(S=>S.trim()).filter(S=>S):void 0}:void 0,urls:z.length>0?z:void 0,scale:V!==1?V:void 0,subordinateBuildingIds:p==="boss"&&Ae.length>0?Ae:void 0,database:p==="database"&&Re.length>0?{connections:Re,activeConnectionId:as}:void 0,terminal:p==="terminal"?{enabled:!0,shell:ts||void 0,port:_e?parseInt(_e,10):void 0,saveSession:ns||void 0,args:ls||void 0}:void 0};b&&c?P.updateBuilding(c,f):P.createBuilding(f),l()},Zs=()=>{re(!0)},Qs=()=>{c&&(P.deleteBuilding(c),re(!1),l())},ee=i=>{c&&(P.sendBuildingCommand(c,i),i==="logs"&&B(!0))},Xs=()=>{n([...z,{label:"",url:""}])},ea=i=>{n(z.filter((f,S)=>S!==i))},rs=(i,f,S)=>{const _=[...z];_[i]={..._[i],[f]:S},n(_)},{handleMouseDown:sa,handleClick:aa}=ra(l);if(!a)return null;const cs=c?P.getBuildingLogs(c):[];return e.jsxs("div",{className:"modal-overlay visible",onMouseDown:sa,onClick:aa,children:[e.jsxs("div",{className:"modal building-config-modal",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("span",{children:t(b?"config:buildings.editBuilding":"config:buildings.addBuilding")}),b&&s&&e.jsx("span",{className:"building-status-badge",style:{backgroundColor:Ge[s.status]},children:s.status})]}),e.jsxs("form",{onSubmit:Ws,children:[e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("common:labels.name")}),e.jsx("input",{ref:is,type:"text",className:"form-input",value:x,onChange:i=>N(i.target.value),placeholder:t("config:buildings.namePlaceholder"),required:!0})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("common:labels.type")}),e.jsx("div",{className:"building-type-selector",children:Object.keys(Us).map(i=>e.jsxs("button",{type:"button",className:`building-type-btn ${p===i?"active":""}`,onClick:()=>y(i),title:Us[i].description,children:[e.jsx("span",{className:"building-type-icon",children:e.jsx(A,{name:Hs(i),size:16})}),e.jsx("span",{className:"building-type-name",children:i})]},i))})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("config:buildings.style")}),e.jsx("div",{className:"building-style-selector",children:Object.keys(Ke).map(i=>e.jsxs("button",{type:"button",className:`building-style-btn ${j===i?"active":""}`,onClick:()=>F(i),title:Ke[i].description,children:[e.jsx("span",{className:"building-style-preview","data-style":i}),e.jsx("span",{className:"building-style-name",children:Ke[i].label})]},i))})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("common:labels.color")}),e.jsxs("div",{className:"building-color-selector",children:[ca.map(i=>e.jsx("button",{type:"button",className:`building-color-btn ${M===i.value?"active":""}`,onClick:()=>R(i.value),title:ma(i.labelKey),style:i.value?{backgroundColor:i.value}:void 0,children:!i.value&&e.jsx("span",{className:"color-default-icon",children:e.jsx(A,{name:"gear",size:12})})},i.value||"default")),e.jsx("input",{type:"color",className:"building-color-picker",value:M||"#2a2a3a",onChange:i=>R(i.target.value),title:"Custom color"})]})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("common:labels.size")}),e.jsxs("div",{className:"building-size-control",children:[e.jsxs("div",{className:"size-slider-row",children:[e.jsx("input",{type:"range",className:"size-slider",min:"0",max:"100",step:"1",value:Math.log(V/.1)/Math.log(100)*100,onChange:i=>{const f=parseFloat(i.target.value),S=.1*Math.pow(100,f/100);Q(Math.round(S*100)/100)}}),e.jsxs("span",{className:"size-value",children:[V.toFixed(2),"x"]})]}),e.jsx("div",{className:"size-presets",children:[.5,.75,1,1.25,1.5,2].map(i=>e.jsxs("button",{type:"button",className:`size-preset-btn ${V===i?"active":""}`,onClick:()=>Q(i),children:[i,"x"]},i))})]})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("config:buildings.directory")}),e.jsx(He,{value:J,onChange:U,placeholder:"/path/to/project",className:"form-input",directoriesOnly:!0})]}),p==="folder"&&e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("config:buildings.folderPath")}),e.jsx(He,{value:D,onChange:se,placeholder:"/path/to/folder",className:"form-input",directoriesOnly:!0}),e.jsx("div",{className:"form-hint",children:"Click this building to open the file explorer at this path"})]}),p==="boss"&&e.jsx(ja,{buildings:o,buildingId:c,subordinateBuildingIds:Ae,setSubordinateBuildingIds:Be,isEditMode:b,showBossLogs:qs,setShowBossLogs:Ys,currentBossLogs:u,bossLogsContainerRef:Js}),p==="database"&&e.jsx(ba,{dbConnections:Re,setDbConnections:Te,activeDbConnectionId:as,setActiveDbConnectionId:Oe}),p==="server"&&e.jsx(pa,{usePM2:q,setUsePM2:ae}),p==="server"&&e.jsx(ha,{usePM2:q,pm2Script:qe,setPm2Script:te,pm2Args:Ye,setPm2Args:ne,pm2Interpreter:Je,setPm2Interpreter:le,pm2InterpreterArgs:We,setPm2InterpreterArgs:ie,pm2Env:Ze,setPm2Env:oe,isEditMode:b,building:s??null,handleCommand:ee}),p==="docker"&&e.jsx(xa,{dockerMode:w,setDockerMode:ce,dockerImage:Qe,setDockerImage:ue,dockerContainerName:pe,setDockerContainerName:he,dockerCommand:ke,setDockerCommand:ye,dockerPorts:xe,setDockerPorts:be,dockerVolumes:je,setDockerVolumes:ge,dockerNetwork:Ne,setDockerNetwork:fe,dockerRestart:es,setDockerRestart:Ce,dockerPull:ss,setDockerPull:Se,dockerEnv:Xe,setDockerEnv:ve,dockerComposePath:we,setDockerComposePath:Pe,dockerComposeProject:De,setDockerComposeProject:Ee,dockerComposeServices:Le,setDockerComposeServices:ze,selectedExistingContainer:me,setSelectedExistingContainer:de,dockerContainersList:d,isEditMode:b,building:s??null,handleCommand:ee}),p==="terminal"&&e.jsx(Na,{terminalShell:ts,setTerminalShell:Ie,terminalPort:_e,setTerminalPort:$e,terminalSaveSession:ns,setTerminalSaveSession:Fe,terminalArgs:ls,setTerminalArgs:Me,isEditMode:b,building:s??null,handleCommand:ee,onOpenTerminal:()=>{s!=null&&s.id&&window.dispatchEvent(new CustomEvent("tide:open-iframe-modal",{detail:{buildingId:s.id}}))},onOpenBelow:i=>{window.dispatchEvent(new CustomEvent("tide:open-bottom-terminal",{detail:{buildingId:i}}))}}),p==="server"&&!q&&e.jsx(ga,{startCmd:W,setStartCmd:K,stopCmd:Z,setStopCmd:H,restartCmd:T,setRestartCmd:G,healthCheckCmd:O,setHealthCheckCmd:I,logsCmd:k,setLogsCmd:L,isEditMode:b,handleCommand:ee}),e.jsxs("div",{className:"form-section",children:[e.jsxs("label",{className:"form-label",children:[t("config:buildings.links"),e.jsxs("button",{type:"button",className:"btn btn-sm btn-add",onClick:Xs,children:["+ ",t("common:buttons.add")]})]}),z.map((i,f)=>e.jsxs("div",{className:"url-row",children:[e.jsx("input",{type:"text",className:"form-input url-label",value:i.label,onChange:S=>rs(f,"label",S.target.value),placeholder:"Label"}),e.jsx("input",{type:"text",className:"form-input url-value",value:i.url,onChange:S=>rs(f,"url",S.target.value),placeholder:"https://..."}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>ea(f),children:"x"})]},f))]}),b&&C&&cs.length>0&&e.jsx(fa,{logs:cs,buildingId:c,logsContainerRef:X})]}),e.jsxs("div",{className:"modal-footer",children:[b&&e.jsx("button",{type:"button",className:"btn btn-danger",onClick:Zs,children:t("common:buttons.delete")}),e.jsx("div",{className:"footer-spacer"}),e.jsx("button",{type:"button",className:"btn btn-secondary",onClick:l,children:t("common:buttons.cancel")}),e.jsx("button",{type:"submit",className:"btn btn-primary",children:t(b?"common:buttons.save":"common:buttons.create")})]})]})]}),Vs&&s&&e.jsx(ua,{buildingName:s.name,onClose:()=>re(!1),onConfirm:Qs})]})}export{Sa as BuildingConfigModal};
7
+ `):""),fe(((Ss=s.docker)==null?void 0:Ss.network)||""),ye(((ws=s.docker)==null?void 0:ws.command)||""),Ce(((Ps=s.docker)==null?void 0:Ps.restart)||"unless-stopped"),Se(((Ds=s.docker)==null?void 0:Ds.pull)||"missing"),Pe(((Es=s.docker)==null?void 0:Es.composePath)||""),Ee(((Ls=s.docker)==null?void 0:Ls.composeProject)||""),ze(((As=(zs=s.docker)==null?void 0:zs.services)==null?void 0:As.join(", "))||""),Be(s.subordinateBuildingIds||[]),Oe(((Bs=s.database)==null?void 0:Bs.connections)||[]),Te((Rs=s.database)==null?void 0:Rs.activeConnectionId),Ie(((Os=s.terminal)==null?void 0:Os.shell)||""),$e((Ts=s.terminal)!=null&&Ts.port?String(s.terminal.port):""),Fe(((Is=s.terminal)==null?void 0:Is.saveSession)||!1),Me(((_s=s.terminal)==null?void 0:_s.args)||"")):(N("New Server"),y("server"),F("server-rack"),R(""),U(ia(oa.LAST_CWD)),K(""),H(""),G(""),I(""),L(""),n([]),se(""),Q(1),ae(!1),te(""),ne(""),le(""),ie(""),oe(""),ce("container"),de(""),ue(""),he(""),be([]),ge([]),ve(""),fe(""),ye(""),Ce("unless-stopped"),Se("missing"),Pe(""),Ee(""),ze(""),Be([]),Oe([]),Te(void 0),Ie(""),$e(""),Fe(!1),Me("")),setTimeout(()=>{var $;return($=is.current)==null?void 0:$.focus()},100))},[a,s]),r.useEffect(()=>{X.current&&(X.current.scrollTop=X.current.scrollHeight)},[g]),r.useEffect(()=>{p==="docker"&&w==="existing"&&P.requestDockerContainersList()},[p,w]);const os=i=>{if(i.trim())return Object.fromEntries(i.trim().split(`
8
+ `).map(f=>f.trim()).filter(f=>f&&f.includes("=")).map(f=>{const S=f.indexOf("=");return[f.slice(0,S),f.slice(S+1)]}))},Ws=i=>{i.preventDefault();const f={name:x,type:p,style:j,color:M||void 0,position:h||(s==null?void 0:s.position)||{x:0,z:0},cwd:J||void 0,folderPath:D||void 0,commands:q?void 0:{start:W||void 0,stop:Z||void 0,restart:O||void 0,healthCheck:T||void 0,logs:k||void 0},pm2:q?{enabled:!0,script:qe,args:Ye||void 0,interpreter:Je||void 0,interpreterArgs:We||void 0,env:os(Ze)}:void 0,docker:p==="docker"?{enabled:!0,mode:w,image:w==="container"?Qe:void 0,containerName:w==="container"&&pe?pe:w==="existing"&&me?me:void 0,ports:w==="container"&&xe.length>0?xe:void 0,volumes:w==="container"&&je.length>0?je:void 0,env:os(Xe),network:w==="container"&&Ne?Ne:void 0,command:w==="container"&&ke?ke:void 0,restart:w==="container"?es:void 0,pull:w!=="existing"?ss:void 0,composePath:w==="compose"&&we?we:void 0,composeProject:w==="compose"&&De?De:void 0,services:w==="compose"&&Le?Le.split(",").map(S=>S.trim()).filter(S=>S):void 0}:void 0,urls:z.length>0?z:void 0,scale:V!==1?V:void 0,subordinateBuildingIds:p==="boss"&&Ae.length>0?Ae:void 0,database:p==="database"&&Re.length>0?{connections:Re,activeConnectionId:as}:void 0,terminal:p==="terminal"?{enabled:!0,shell:ts||void 0,port:_e?parseInt(_e,10):void 0,saveSession:ns||void 0,args:ls||void 0}:void 0};b&&c?P.updateBuilding(c,f):P.createBuilding(f),l()},Zs=()=>{re(!0)},Qs=()=>{c&&(P.deleteBuilding(c),re(!1),l())},ee=i=>{c&&(P.sendBuildingCommand(c,i),i==="logs"&&B(!0))},Xs=()=>{n([...z,{label:"",url:""}])},ea=i=>{n(z.filter((f,S)=>S!==i))},rs=(i,f,S)=>{const _=[...z];_[i]={..._[i],[f]:S},n(_)},{handleMouseDown:sa,handleClick:aa}=ra(l);if(!a)return null;const cs=c?P.getBuildingLogs(c):[];return e.jsxs("div",{className:"modal-overlay visible",onMouseDown:sa,onClick:aa,children:[e.jsxs("div",{className:"modal building-config-modal",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("span",{children:t(b?"config:buildings.editBuilding":"config:buildings.addBuilding")}),b&&s&&e.jsx("span",{className:"building-status-badge",style:{backgroundColor:Ge[s.status]},children:s.status})]}),e.jsxs("form",{onSubmit:Ws,children:[e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("common:labels.name")}),e.jsx("input",{ref:is,type:"text",className:"form-input",value:x,onChange:i=>N(i.target.value),placeholder:t("config:buildings.namePlaceholder"),required:!0})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("common:labels.type")}),e.jsx("div",{className:"building-type-selector",children:Object.keys(Us).map(i=>e.jsxs("button",{type:"button",className:`building-type-btn ${p===i?"active":""}`,onClick:()=>y(i),title:Us[i].description,children:[e.jsx("span",{className:"building-type-icon",children:e.jsx(A,{name:Hs(i),size:16})}),e.jsx("span",{className:"building-type-name",children:i})]},i))})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("config:buildings.style")}),e.jsx("div",{className:"building-style-selector",children:Object.keys(Ke).map(i=>e.jsxs("button",{type:"button",className:`building-style-btn ${j===i?"active":""}`,onClick:()=>F(i),title:Ke[i].description,children:[e.jsx("span",{className:"building-style-preview","data-style":i}),e.jsx("span",{className:"building-style-name",children:Ke[i].label})]},i))})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("common:labels.color")}),e.jsxs("div",{className:"building-color-selector",children:[ca.map(i=>e.jsx("button",{type:"button",className:`building-color-btn ${M===i.value?"active":""}`,onClick:()=>R(i.value),title:ma(i.labelKey),style:i.value?{backgroundColor:i.value}:void 0,children:!i.value&&e.jsx("span",{className:"color-default-icon",children:e.jsx(A,{name:"gear",size:12})})},i.value||"default")),e.jsx("input",{type:"color",className:"building-color-picker",value:M||"#2a2a3a",onChange:i=>R(i.target.value),title:"Custom color"})]})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("common:labels.size")}),e.jsxs("div",{className:"building-size-control",children:[e.jsxs("div",{className:"size-slider-row",children:[e.jsx("input",{type:"range",className:"size-slider",min:"0",max:"100",step:"1",value:Math.log(V/.1)/Math.log(100)*100,onChange:i=>{const f=parseFloat(i.target.value),S=.1*Math.pow(100,f/100);Q(Math.round(S*100)/100)}}),e.jsxs("span",{className:"size-value",children:[V.toFixed(2),"x"]})]}),e.jsx("div",{className:"size-presets",children:[.5,.75,1,1.25,1.5,2].map(i=>e.jsxs("button",{type:"button",className:`size-preset-btn ${V===i?"active":""}`,onClick:()=>Q(i),children:[i,"x"]},i))})]})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("config:buildings.directory")}),e.jsx(He,{value:J,onChange:U,placeholder:"/path/to/project",className:"form-input",directoriesOnly:!0})]}),p==="folder"&&e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("config:buildings.folderPath")}),e.jsx(He,{value:D,onChange:se,placeholder:"/path/to/folder",className:"form-input",directoriesOnly:!0}),e.jsx("div",{className:"form-hint",children:"Click this building to open the file explorer at this path"})]}),p==="boss"&&e.jsx(ja,{buildings:o,buildingId:c,subordinateBuildingIds:Ae,setSubordinateBuildingIds:Be,isEditMode:b,showBossLogs:qs,setShowBossLogs:Ys,currentBossLogs:u,bossLogsContainerRef:Js}),p==="database"&&e.jsx(ba,{dbConnections:Re,setDbConnections:Oe,activeDbConnectionId:as,setActiveDbConnectionId:Te}),p==="server"&&e.jsx(pa,{usePM2:q,setUsePM2:ae}),p==="server"&&e.jsx(ha,{usePM2:q,pm2Script:qe,setPm2Script:te,pm2Args:Ye,setPm2Args:ne,pm2Interpreter:Je,setPm2Interpreter:le,pm2InterpreterArgs:We,setPm2InterpreterArgs:ie,pm2Env:Ze,setPm2Env:oe,isEditMode:b,building:s??null,handleCommand:ee}),p==="docker"&&e.jsx(xa,{dockerMode:w,setDockerMode:ce,dockerImage:Qe,setDockerImage:ue,dockerContainerName:pe,setDockerContainerName:he,dockerCommand:ke,setDockerCommand:ye,dockerPorts:xe,setDockerPorts:be,dockerVolumes:je,setDockerVolumes:ge,dockerNetwork:Ne,setDockerNetwork:fe,dockerRestart:es,setDockerRestart:Ce,dockerPull:ss,setDockerPull:Se,dockerEnv:Xe,setDockerEnv:ve,dockerComposePath:we,setDockerComposePath:Pe,dockerComposeProject:De,setDockerComposeProject:Ee,dockerComposeServices:Le,setDockerComposeServices:ze,selectedExistingContainer:me,setSelectedExistingContainer:de,dockerContainersList:d,isEditMode:b,building:s??null,handleCommand:ee}),p==="terminal"&&e.jsx(Na,{terminalShell:ts,setTerminalShell:Ie,terminalPort:_e,setTerminalPort:$e,terminalSaveSession:ns,setTerminalSaveSession:Fe,terminalArgs:ls,setTerminalArgs:Me,isEditMode:b,building:s??null,handleCommand:ee,onOpenTerminal:()=>{s!=null&&s.id&&window.dispatchEvent(new CustomEvent("tide:open-iframe-modal",{detail:{buildingId:s.id}}))},onOpenBelow:i=>{window.dispatchEvent(new CustomEvent("tide:open-bottom-terminal",{detail:{buildingId:i}}))}}),p==="server"&&!q&&e.jsx(ga,{startCmd:W,setStartCmd:K,stopCmd:Z,setStopCmd:H,restartCmd:O,setRestartCmd:G,healthCheckCmd:T,setHealthCheckCmd:I,logsCmd:k,setLogsCmd:L,isEditMode:b,handleCommand:ee}),e.jsxs("div",{className:"form-section",children:[e.jsxs("label",{className:"form-label",children:[t("config:buildings.links"),e.jsxs("button",{type:"button",className:"btn btn-sm btn-add",onClick:Xs,children:["+ ",t("common:buttons.add")]})]}),z.map((i,f)=>e.jsxs("div",{className:"url-row",children:[e.jsx("input",{type:"text",className:"form-input url-label",value:i.label,onChange:S=>rs(f,"label",S.target.value),placeholder:"Label"}),e.jsx("input",{type:"text",className:"form-input url-value",value:i.url,onChange:S=>rs(f,"url",S.target.value),placeholder:"https://..."}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>ea(f),children:"x"})]},f))]}),b&&C&&cs.length>0&&e.jsx(fa,{logs:cs,buildingId:c,logsContainerRef:X})]}),e.jsxs("div",{className:"modal-footer",children:[b&&e.jsx("button",{type:"button",className:"btn btn-danger",onClick:Zs,children:t("common:buttons.delete")}),e.jsx("div",{className:"footer-spacer"}),e.jsx("button",{type:"button",className:"btn btn-secondary",onClick:l,children:t("common:buttons.cancel")}),e.jsx("button",{type:"submit",className:"btn btn-primary",children:t(b?"common:buttons.save":"common:buttons.create")})]})]})]}),Vs&&s&&e.jsx(ua,{buildingName:s.name,onClose:()=>re(!1),onConfirm:Qs})]})}export{Sa as BuildingConfigModal};
@@ -1,5 +1,5 @@
1
- import{bm as Oe,r as t,s as I,l as ye,bn as Ee,aH as _e,j as e,I as z,u as fe,bo as ze,bp as Te,bq as Be,br as Ue,m as Ke,bs as We,bt as De,bu as Ve,a4 as Ge,a5 as qe,bv as Ye,aQ as Je,G as Me,S as oe,aK as Qe,aG as Xe,Y as Ze,H as Ie,af as et,O as tt,bw as st,n as Q,bx as nt}from"./main-Q3uQGSTr.js";import{F as at}from"./index-BNQjdC7D.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Ne={status:"all",activity:"all",sort:"activity"},lt={"1h":3600*1e3,"6h":360*60*1e3,"24h":1440*60*1e3},Ae=20,me=3,ot={idle:"#4aff9e",working:"#4a9eff",waiting:"#ff9e4a",waiting_permission:"#ffcc00",error:"#ff4a4a",offline:"#888888",orphaned:"#ff9e4a"},ct=12e4;function rt(s){return s.trim().replace(/\r\n/g,`
2
- `)}function $e(s,a){return`${s}:${rt(a)}`}function it(s,a,l,f){if(s.uuid&&a.has(s.uuid))return!1;if(s.uuid)return!0;const p=s.isUserPrompt?"user":"assistant",d=$e(p,s.text),M=s.timestamp||0,A=l.get(d);return A!==void 0&&Math.abs(M-A)<=ct?!1:M>f}function dt({isOpen:s,agents:a}){const l=Oe(),[f,p]=t.useState(new Map),d=t.useRef(new Set);t.useRef(a);const M=t.useMemo(()=>Array.from(a.keys()).sort().join(","),[a]),A=t.useMemo(()=>Array.from(a.values()).map(j=>`${j.id}:${j.sessionId||""}`).sort().join(","),[a]);t.useEffect(()=>{s||(d.current.clear(),p(new Map))},[s]),t.useEffect(()=>{if(!s)return;const j=new Set(Array.from(a.keys()));for(const i of d.current)j.has(i)||d.current.delete(i);let h=null;l>0&&(h=I.preserveOutputs(),d.current.clear());const v=async(i,C,F=0)=>{if(d.current.add(i.id),F>0&&await new Promise(x=>setTimeout(x,F)),p(x=>{const k=new Map(x);return k.set(i.id,{agentId:i.id,messages:[],loading:!0,hasMore:!1,totalCount:0}),k}),!i.sessionId){C&&C.length>0&&I.mergeOutputsWithHistory(i.id,[],C),p(x=>{const k=new Map(x);return k.set(i.id,{agentId:i.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),k});return}try{const k=await(await _e(ye(`/api/agents/${i.id}/history?limit=${Ee}&offset=0`))).json(),P=k.messages||[],W=P.length>0?Math.max(...P.map(w=>w.timestamp?new Date(w.timestamp).getTime():0)):0,Y=new Set(P.map(w=>w.uuid).filter(w=>!!w)),V=new Map;for(const w of P){if(w.type!=="user"&&w.type!=="assistant")continue;const c=$e(w.type,w.content),L=w.timestamp?new Date(w.timestamp).getTime():0,K=V.get(c)??0;L>K&&V.set(c,L)}const G=I.getOutputs(i.id),U=(C&&C.length>0?[...C,...G]:G).filter(w=>it(w,Y,V,W));I.clearOutputs(i.id);for(const w of U)I.addOutput(i.id,w);p(w=>{const c=new Map(w);return c.set(i.id,{agentId:i.id,messages:P,loading:!1,hasMore:k.hasMore||!1,totalCount:k.totalCount||0}),c})}catch(x){if(console.error(`Failed to load history for ${i.name}:`,x),C&&C.length>0){I.clearOutputs(i.id);for(const k of C)I.addOutput(i.id,k)}p(k=>{const P=new Map(k);return P.set(i.id,{agentId:i.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),P})}},u=l>0?500:0,D=Array.from(a.values());for(const i of D)if(!d.current.has(i.id)){const C=h==null?void 0:h.get(i.id);v(i,C,u)}},[s,M,A,l]);const R=t.useRef(a),N=t.useRef(f);R.current=a,N.current=f;const b=t.useCallback(async j=>{const h=R.current.get(j),v=N.current.get(j);if(!(h!=null&&h.sessionId)||!v||!v.hasMore)return;const u=v.messages.length;try{const i=await(await fetch(ye(`/api/agents/${j}/history?limit=${Ee}&offset=${u}`))).json();i.messages&&i.messages.length>0&&p(C=>{const F=new Map(C),x=C.get(j);return x&&F.set(j,{...x,messages:[...i.messages,...x.messages],hasMore:i.hasMore||!1}),F})}catch(D){console.error(`Failed to load more history for agent ${j}:`,D)}},[]),E=t.useCallback(j=>{d.current.delete(j),p(h=>{const v=new Map(h),u=h.get(j);return u&&v.set(j,{...u,messages:[],hasMore:!1,totalCount:0,loading:!1}),v})},[]);return{histories:f,loadMoreHistory:b,clearAgentHistory:E}}function ut({command:s,onCommandChange:a,useTextarea:l,forceTextarea:f,onForceTextarea:p,onSend:d,canSend:M,attachedFiles:A,onAddFile:R,onRemoveFile:N,uploadFile:b,onAddPastedText:E,placeholder:j="Message...",className:h="",compact:v=!1,inputRef:u}){const D=t.useRef(null),i=t.useRef(null),C=t.useRef(l);t.useEffect(()=>{if(l&&!C.current&&i.current){const c=i.current;c.focus(),c.selectionStart=c.selectionEnd=c.value.length}C.current=l},[l]),t.useEffect(()=>{const c=i.current;if(!c||!l)return;c.style.height="auto";const L=v?120:180,K=Math.min(c.scrollHeight,L);c.style.height=`${K}px`},[s,l,v]);const F=t.useCallback(async c=>{const L=c.clipboardData.items;for(const _ of L)if(_.type.startsWith("image/")){c.preventDefault();const $=_.getAsFile();if($){const H=await b($);H&&R(H)}return}const K=c.clipboardData.files;if(K.length>0){c.preventDefault();for(const _ of K){const $=await b(_);$&&R($)}return}const B=c.clipboardData.getData("text"),te=(B.match(/\n/g)||[]).length+1;if(te>5){c.preventDefault();const $=`[Pasted text #${E(B)} +${te} lines]`,H=c.target,se=H.selectionStart||0,ae=H.selectionEnd||0,ne=s.slice(0,se)+$+s.slice(ae);a(ne),l||p(!0)}},[s,a,l,p,b,R,E]),x=t.useCallback(async c=>{const L=c.target.files;if(L){for(const K of L){const B=await b(K);B&&R(B)}D.current&&(D.current.value="")}},[b,R]),k=t.useCallback(c=>{if(c.key==="Enter"&&c.shiftKey){l||(c.preventDefault(),p(!0));return}c.key==="Enter"&&(c.preventDefault(),d())},[l,p,d]),P=t.useCallback(c=>{},[]),W=t.useCallback(c=>{c.button===1&&(c.preventDefault(),c.stopPropagation())},[]),Y=t.useCallback(c=>{i.current=c,u==null||u(c)},[u]),V=v?"agent-panel-input":"guake-input",G=v?"agent-panel-input-container":"guake-input-container",X=v?"agent-panel-attach-btn":"guake-attach-btn",U=v?"agent-panel-send-btn":"",w=l?v?"agent-panel-input-expanded":"guake-input-expanded":"";return e.jsxs(e.Fragment,{children:[A.length>0&&e.jsx("div",{className:v?"agent-panel-attachments":"guake-attachments",children:A.map(c=>e.jsxs("div",{className:`${v?"agent-panel-attachment":"guake-attachment"} ${c.isImage?"is-image":""}`,children:[e.jsx("span",{className:v?"agent-panel-attachment-icon":"guake-attachment-icon",children:e.jsx(z,{name:c.isImage?"file":"paperclip",size:12})}),e.jsx("span",{className:v?"agent-panel-attachment-name":"guake-attachment-name",title:c.path,children:c.name}),!v&&e.jsxs("span",{className:"guake-attachment-size",children:["(",Math.round(c.size/1024),"KB)"]}),e.jsx("button",{className:v?"agent-panel-attachment-remove":"guake-attachment-remove",onClick:()=>N(c.id),title:"Remove",children:"×"})]},c.id))}),e.jsxs("div",{className:`${V} ${w} ${h}`,children:[e.jsx("input",{ref:D,type:"file",multiple:!0,onChange:x,style:{display:"none"},accept:"*"}),e.jsxs("div",{className:G,onAuxClick:W,children:[e.jsx("button",{className:X,onClick:()=>{var c;return(c=D.current)==null?void 0:c.click()},title:"Attach file (or paste image)",children:e.jsx(z,{name:"paperclip",size:14})}),l?e.jsx("textarea",{ref:Y,placeholder:j,value:s,onChange:c=>a(c.target.value),onKeyDown:k,onPaste:F,onMouseDown:P}):e.jsx("input",{ref:u,type:"text",placeholder:j,value:s,onChange:c=>a(c.target.value),onKeyDown:k,onPaste:F,onMouseDown:P}),e.jsx("button",{className:U,onClick:d,disabled:!M,title:"Send",children:e.jsx(z,{name:"send",size:14})})]})]})]})}function mt(s){const a=Math.floor(s/1e3),l=Math.floor(a/60),f=a%60;return`${l}:${f.toString().padStart(2,"0")}`}const ft=t.memo(function({agentId:a,isWorking:l,timestamp:f}){const{t:p}=fe(["terminal"]),[d,M]=t.useState(0);return t.useEffect(()=>{if(!l||!f){M(0);return}M(Date.now()-f);const A=setInterval(()=>{M(Date.now()-f)},1e3);return()=>clearInterval(A)},[l,f]),l?e.jsxs("div",{className:"guake-stop-bar",children:[e.jsx("span",{className:"guake-elapsed-timer",children:mt(d)}),e.jsxs("button",{className:"guake-stop-btn",onClick:()=>I.stopAgent(a),title:p("terminal:input.stopOperation"),children:[e.jsx("span",{className:"stop-icon",children:e.jsx(z,{name:"stop",size:12,weight:"fill"})}),e.jsx("span",{className:"stop-label",children:p("terminal:input.stop")})]})]}):null});function pt({agent:s,history:a,outputs:l,isExpanded:f,isFocused:p,advancedView:d,onExpand:M,onFocus:A,inputRef:R,onLoadMore:N,onClearHistory:b}){const{t:E}=fe(["terminal","common"]),j=ze(s.id),h=t.useRef(null),[v,u]=t.useState(!1),D=t.useRef(0),i=t.useRef(!1),[C,F]=t.useState(!0),[x,k]=t.useState(!1),[P,W]=t.useState(null),[Y,V]=t.useState(null),[G,X]=t.useState(null);Te(`commander-image-modal-${s.id}`,P!==null,()=>W(null));const{command:U,setCommand:w,forceTextarea:c,setForceTextarea:L,useTextarea:K,setPastedTexts:B,incrementPastedCount:te,resetPastedCount:_,attachedFiles:$,setAttachedFiles:H,removeAttachedFile:se,uploadFile:ae,expandPastedTexts:ne}=Be({selectedAgentId:s.id}),le=U.trim().length>0||$.length>0,n=Ue({outputs:l,viewMode:d?"advanced":"simple"}),o=t.useMemo(()=>{const S=Ke(s);return{usedPercent:S.usedPercent,freePercent:S.freePercent,hasData:!!s.contextStats,totalTokens:S.totalTokens,contextWindow:S.contextWindow}},[s.contextStats,s.contextUsed,s.contextLimit]),g=t.useCallback(()=>{!v&&(a!=null&&a.hasMore)&&N&&(u(!0),D.current=h.current?h.current.scrollHeight-h.current.scrollTop:0,N())},[v,a==null?void 0:a.hasMore,N]);t.useEffect(()=>{v&&a&&!a.loading&&u(!1)},[a,v]);const m=t.useCallback(()=>{i.current=!0,F(!1)},[]),T=t.useRef(f),Z=t.useRef(p);t.useEffect(()=>{(f&&!T.current||p&&!Z.current)&&(i.current=!1,F(!0),k(!0)),T.current=f,Z.current=p},[f,p]);const ee=t.useRef(a==null?void 0:a.loading);t.useEffect(()=>{ee.current&&!(a!=null&&a.loading)&&(i.current=!1,F(!0),k(!0)),ee.current=a==null?void 0:a.loading},[a==null?void 0:a.loading]),t.useEffect(()=>{if(!x)return;const S=h.current;if(!S)return;const y=performance.now();let O=0,ue=-1,ke;const Re=()=>{const{scrollTop:Fe,scrollHeight:Se,clientHeight:Le}=S,He=Se-Fe-Le<=2;if(Math.abs(Se-ue)<=1&&He?O+=1:O=0,ue=Se,O>=3){k(!1);return}if(performance.now()-y>5e3){k(!1);return}ke=requestAnimationFrame(Re)};return ke=requestAnimationFrame(Re),()=>cancelAnimationFrame(ke)},[x]),t.useEffect(()=>{i.current||F(!0)},[n.length]);const q=t.useCallback(()=>!1,[]),ie=t.useCallback(S=>{const y=te();return B(O=>new Map(O).set(y,S)),y},[te,B]),he=t.useCallback(S=>{H(y=>[...y,S])},[H]),xe=t.useCallback(()=>{if(!le)return;if(U.trim()==="/clear"&&$.length===0){I.clearContext(s.id),b(),w(""),L(!1),B(new Map),H([]),_();return}let S=ne(U.trim());if($.length>0){const y=$.map(O=>O.isImage?`[Image: ${O.path}]`:`[File: ${O.path}]`).join(`
1
+ import{bo as Oe,r as t,s as I,l as ye,bp as Ee,aJ as _e,j as e,I as z,u as fe,bq as ze,br as Te,bs as Ue,bt as Be,m as Ke,bu as We,bv as De,bw as Ve,a6 as qe,a7 as Ge,bx as Je,aS as Ye,J as Me,S as oe,aM as Xe,aI as Qe,_ as Ze,K as Ie,ah as et,U as tt,by as st,n as X,bz as nt}from"./main-D2EQVTAu.js";import{F as at}from"./index-DAsa2Q29.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Ne={status:"all",activity:"all",sort:"activity"},lt={"1h":3600*1e3,"6h":360*60*1e3,"24h":1440*60*1e3},Ae=20,me=3,ot={idle:"#4aff9e",working:"#4a9eff",waiting:"#ff9e4a",waiting_permission:"#ffcc00",error:"#ff4a4a",offline:"#888888",orphaned:"#ff9e4a"},ct=12e4;function rt(s){return s.trim().replace(/\r\n/g,`
2
+ `)}function $e(s,a){return`${s}:${rt(a)}`}function it(s,a,l,f){if(s.uuid&&a.has(s.uuid))return!1;if(s.uuid)return!0;const p=s.isUserPrompt?"user":"assistant",d=$e(p,s.text),M=s.timestamp||0,A=l.get(d);return A!==void 0&&Math.abs(M-A)<=ct?!1:M>f}function dt({isOpen:s,agents:a}){const l=Oe(),[f,p]=t.useState(new Map),d=t.useRef(new Set);t.useRef(a);const M=t.useMemo(()=>Array.from(a.keys()).sort().join(","),[a]),A=t.useMemo(()=>Array.from(a.values()).map(j=>`${j.id}:${j.sessionId||""}`).sort().join(","),[a]);t.useEffect(()=>{s||(d.current.clear(),p(new Map))},[s]),t.useEffect(()=>{if(!s)return;const j=new Set(Array.from(a.keys()));for(const i of d.current)j.has(i)||d.current.delete(i);let h=null;l>0&&(h=I.preserveOutputs(),d.current.clear());const v=async(i,C,F=0)=>{if(d.current.add(i.id),F>0&&await new Promise(x=>setTimeout(x,F)),p(x=>{const k=new Map(x);return k.set(i.id,{agentId:i.id,messages:[],loading:!0,hasMore:!1,totalCount:0}),k}),!i.sessionId){C&&C.length>0&&I.mergeOutputsWithHistory(i.id,[],C),p(x=>{const k=new Map(x);return k.set(i.id,{agentId:i.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),k});return}try{const k=await(await _e(ye(`/api/agents/${i.id}/history?limit=${Ee}&offset=0`))).json(),P=k.messages||[],W=P.length>0?Math.max(...P.map(w=>w.timestamp?new Date(w.timestamp).getTime():0)):0,J=new Set(P.map(w=>w.uuid).filter(w=>!!w)),V=new Map;for(const w of P){if(w.type!=="user"&&w.type!=="assistant")continue;const c=$e(w.type,w.content),L=w.timestamp?new Date(w.timestamp).getTime():0,K=V.get(c)??0;L>K&&V.set(c,L)}const q=I.getOutputs(i.id),B=(C&&C.length>0?[...C,...q]:q).filter(w=>it(w,J,V,W));I.clearOutputs(i.id);for(const w of B)I.addOutput(i.id,w);p(w=>{const c=new Map(w);return c.set(i.id,{agentId:i.id,messages:P,loading:!1,hasMore:k.hasMore||!1,totalCount:k.totalCount||0}),c})}catch(x){if(console.error(`Failed to load history for ${i.name}:`,x),C&&C.length>0){I.clearOutputs(i.id);for(const k of C)I.addOutput(i.id,k)}p(k=>{const P=new Map(k);return P.set(i.id,{agentId:i.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),P})}},u=l>0?500:0,D=Array.from(a.values());for(const i of D)if(!d.current.has(i.id)){const C=h==null?void 0:h.get(i.id);v(i,C,u)}},[s,M,A,l]);const R=t.useRef(a),N=t.useRef(f);R.current=a,N.current=f;const b=t.useCallback(async j=>{const h=R.current.get(j),v=N.current.get(j);if(!(h!=null&&h.sessionId)||!v||!v.hasMore)return;const u=v.messages.length;try{const i=await(await fetch(ye(`/api/agents/${j}/history?limit=${Ee}&offset=${u}`))).json();i.messages&&i.messages.length>0&&p(C=>{const F=new Map(C),x=C.get(j);return x&&F.set(j,{...x,messages:[...i.messages,...x.messages],hasMore:i.hasMore||!1}),F})}catch(D){console.error(`Failed to load more history for agent ${j}:`,D)}},[]),E=t.useCallback(j=>{d.current.delete(j),p(h=>{const v=new Map(h),u=h.get(j);return u&&v.set(j,{...u,messages:[],hasMore:!1,totalCount:0,loading:!1}),v})},[]);return{histories:f,loadMoreHistory:b,clearAgentHistory:E}}function ut({command:s,onCommandChange:a,useTextarea:l,forceTextarea:f,onForceTextarea:p,onSend:d,canSend:M,attachedFiles:A,onAddFile:R,onRemoveFile:N,uploadFile:b,onAddPastedText:E,placeholder:j="Message...",className:h="",compact:v=!1,inputRef:u}){const D=t.useRef(null),i=t.useRef(null),C=t.useRef(l);t.useEffect(()=>{if(l&&!C.current&&i.current){const c=i.current;c.focus(),c.selectionStart=c.selectionEnd=c.value.length}C.current=l},[l]),t.useEffect(()=>{const c=i.current;if(!c||!l)return;c.style.height="auto";const L=v?120:180,K=Math.min(c.scrollHeight,L);c.style.height=`${K}px`},[s,l,v]);const F=t.useCallback(async c=>{const L=c.clipboardData.items;for(const _ of L)if(_.type.startsWith("image/")){c.preventDefault();const $=_.getAsFile();if($){const H=await b($);H&&R(H)}return}const K=c.clipboardData.files;if(K.length>0){c.preventDefault();for(const _ of K){const $=await b(_);$&&R($)}return}const U=c.clipboardData.getData("text"),te=(U.match(/\n/g)||[]).length+1;if(te>5){c.preventDefault();const $=`[Pasted text #${E(U)} +${te} lines]`,H=c.target,se=H.selectionStart||0,ae=H.selectionEnd||0,ne=s.slice(0,se)+$+s.slice(ae);a(ne),l||p(!0)}},[s,a,l,p,b,R,E]),x=t.useCallback(async c=>{const L=c.target.files;if(L){for(const K of L){const U=await b(K);U&&R(U)}D.current&&(D.current.value="")}},[b,R]),k=t.useCallback(c=>{if(c.key==="Enter"&&c.shiftKey){l||(c.preventDefault(),p(!0));return}c.key==="Enter"&&(c.preventDefault(),d())},[l,p,d]),P=t.useCallback(c=>{},[]),W=t.useCallback(c=>{c.button===1&&(c.preventDefault(),c.stopPropagation())},[]),J=t.useCallback(c=>{i.current=c,u==null||u(c)},[u]),V=v?"agent-panel-input":"guake-input",q=v?"agent-panel-input-container":"guake-input-container",Q=v?"agent-panel-attach-btn":"guake-attach-btn",B=v?"agent-panel-send-btn":"",w=l?v?"agent-panel-input-expanded":"guake-input-expanded":"";return e.jsxs(e.Fragment,{children:[A.length>0&&e.jsx("div",{className:v?"agent-panel-attachments":"guake-attachments",children:A.map(c=>e.jsxs("div",{className:`${v?"agent-panel-attachment":"guake-attachment"} ${c.isImage?"is-image":""}`,children:[e.jsx("span",{className:v?"agent-panel-attachment-icon":"guake-attachment-icon",children:e.jsx(z,{name:c.isImage?"file":"paperclip",size:12})}),e.jsx("span",{className:v?"agent-panel-attachment-name":"guake-attachment-name",title:c.path,children:c.name}),!v&&e.jsxs("span",{className:"guake-attachment-size",children:["(",Math.round(c.size/1024),"KB)"]}),e.jsx("button",{className:v?"agent-panel-attachment-remove":"guake-attachment-remove",onClick:()=>N(c.id),title:"Remove",children:"×"})]},c.id))}),e.jsxs("div",{className:`${V} ${w} ${h}`,children:[e.jsx("input",{ref:D,type:"file",multiple:!0,onChange:x,style:{display:"none"},accept:"*"}),e.jsxs("div",{className:q,onAuxClick:W,children:[e.jsx("button",{className:Q,onClick:()=>{var c;return(c=D.current)==null?void 0:c.click()},title:"Attach file (or paste image)",children:e.jsx(z,{name:"paperclip",size:14})}),l?e.jsx("textarea",{ref:J,placeholder:j,value:s,onChange:c=>a(c.target.value),onKeyDown:k,onPaste:F,onMouseDown:P}):e.jsx("input",{ref:u,type:"text",placeholder:j,value:s,onChange:c=>a(c.target.value),onKeyDown:k,onPaste:F,onMouseDown:P}),e.jsx("button",{className:B,onClick:d,disabled:!M,title:"Send",children:e.jsx(z,{name:"send",size:14})})]})]})]})}function mt(s){const a=Math.floor(s/1e3),l=Math.floor(a/60),f=a%60;return`${l}:${f.toString().padStart(2,"0")}`}const ft=t.memo(function({agentId:a,isWorking:l,timestamp:f}){const{t:p}=fe(["terminal"]),[d,M]=t.useState(0);return t.useEffect(()=>{if(!l||!f){M(0);return}M(Date.now()-f);const A=setInterval(()=>{M(Date.now()-f)},1e3);return()=>clearInterval(A)},[l,f]),l?e.jsxs("div",{className:"guake-stop-bar",children:[e.jsx("span",{className:"guake-elapsed-timer",children:mt(d)}),e.jsxs("button",{className:"guake-stop-btn",onClick:()=>I.stopAgent(a),title:p("terminal:input.stopOperation"),children:[e.jsx("span",{className:"stop-icon",children:e.jsx(z,{name:"stop",size:12,weight:"fill"})}),e.jsx("span",{className:"stop-label",children:p("terminal:input.stop")})]})]}):null});function pt({agent:s,history:a,outputs:l,isExpanded:f,isFocused:p,advancedView:d,onExpand:M,onFocus:A,inputRef:R,onLoadMore:N,onClearHistory:b}){const{t:E}=fe(["terminal","common"]),j=ze(s.id),h=t.useRef(null),[v,u]=t.useState(!1),D=t.useRef(0),i=t.useRef(!1),[C,F]=t.useState(!0),[x,k]=t.useState(!1),[P,W]=t.useState(null),[J,V]=t.useState(null),[q,Q]=t.useState(null);Te(`commander-image-modal-${s.id}`,P!==null,()=>W(null));const{command:B,setCommand:w,forceTextarea:c,setForceTextarea:L,useTextarea:K,setPastedTexts:U,incrementPastedCount:te,resetPastedCount:_,attachedFiles:$,setAttachedFiles:H,removeAttachedFile:se,uploadFile:ae,expandPastedTexts:ne}=Ue({selectedAgentId:s.id}),le=B.trim().length>0||$.length>0,n=Be({outputs:l,viewMode:d?"advanced":"simple"}),o=t.useMemo(()=>{const S=Ke(s);return{usedPercent:S.usedPercent,freePercent:S.freePercent,hasData:!!s.contextStats,totalTokens:S.totalTokens,contextWindow:S.contextWindow}},[s.contextStats,s.contextUsed,s.contextLimit]),g=t.useCallback(()=>{!v&&(a!=null&&a.hasMore)&&N&&(u(!0),D.current=h.current?h.current.scrollHeight-h.current.scrollTop:0,N())},[v,a==null?void 0:a.hasMore,N]);t.useEffect(()=>{v&&a&&!a.loading&&u(!1)},[a,v]);const m=t.useCallback(()=>{i.current=!0,F(!1)},[]),T=t.useRef(f),Z=t.useRef(p);t.useEffect(()=>{(f&&!T.current||p&&!Z.current)&&(i.current=!1,F(!0),k(!0)),T.current=f,Z.current=p},[f,p]);const ee=t.useRef(a==null?void 0:a.loading);t.useEffect(()=>{ee.current&&!(a!=null&&a.loading)&&(i.current=!1,F(!0),k(!0)),ee.current=a==null?void 0:a.loading},[a==null?void 0:a.loading]),t.useEffect(()=>{if(!x)return;const S=h.current;if(!S)return;const y=performance.now();let O=0,ue=-1,ke;const Re=()=>{const{scrollTop:Fe,scrollHeight:Se,clientHeight:Le}=S,He=Se-Fe-Le<=2;if(Math.abs(Se-ue)<=1&&He?O+=1:O=0,ue=Se,O>=3){k(!1);return}if(performance.now()-y>5e3){k(!1);return}ke=requestAnimationFrame(Re)};return ke=requestAnimationFrame(Re),()=>cancelAnimationFrame(ke)},[x]),t.useEffect(()=>{i.current||F(!0)},[n.length]);const G=t.useCallback(()=>!1,[]),ie=t.useCallback(S=>{const y=te();return U(O=>new Map(O).set(y,S)),y},[te,U]),he=t.useCallback(S=>{H(y=>[...y,S])},[H]),xe=t.useCallback(()=>{if(!le)return;if(B.trim()==="/clear"&&$.length===0){I.clearContext(s.id),b(),w(""),L(!1),U(new Map),H([]),_();return}let S=ne(B.trim());if($.length>0){const y=$.map(O=>O.isImage?`[Image: ${O.path}]`:`[File: ${O.path}]`).join(`
3
3
  `);S=S?`${S}
4
4
 
5
- ${y}`:y}I.sendCommand(s.id,S),w(""),L(!1),B(new Map),H([]),_()},[s.id,U,le,$,ne,b,_,w,L,B,H]),ge=t.useCallback((S,y)=>{W({url:S,name:y})},[]),ve=t.useCallback((S,y)=>{const O=We(S,s.cwd),ue=O.line?{...y||{},targetLine:O.line}:y;I.setFileViewerPath(O.path,ue,s.cwd)},[s.cwd]),je=t.useCallback((S,y)=>{V({command:S,output:y,isLive:y==="Running..."})},[]),we=t.useCallback(S=>{X(S)},[]),Ce=t.useCallback(()=>{k(!1),i.current=!0,F(!1)},[]),be=t.useCallback(()=>W(null),[]),r=t.useCallback(()=>V(null),[]),J=t.useCallback(()=>X(null),[]),de=t.useCallback(S=>{S.stopPropagation(),M()},[M]),ce=ot[s.status]||"#888888",re=(a==null?void 0:a.messages)||[];return e.jsxs("div",{className:`agent-panel ${s.status==="working"?"working":""} ${f?"expanded":""} ${p?"focused":""}`,onClick:p?void 0:A,children:[e.jsxs("div",{className:"agent-panel-header",onClick:p?A:void 0,children:[e.jsxs("div",{className:"agent-panel-info",children:[e.jsx("span",{className:"agent-panel-status",style:{background:ce},title:s.status}),e.jsxs("span",{className:"agent-panel-name",children:[(s.isBoss||s.class==="boss")&&e.jsx("span",{className:"agent-panel-boss-crown",children:e.jsx(z,{name:"crown",size:14})}),s.name]}),e.jsx("span",{className:`agent-panel-status-label ${s.status}`,children:s.status}),e.jsx("span",{className:"agent-panel-class",children:s.class}),e.jsx("span",{className:`agent-panel-provider ${s.provider==="codex"?"codex":s.provider==="opencode"?"opencode":"claude"}`,children:s.provider||"claude"}),e.jsxs("span",{className:"agent-panel-id",title:`ID: ${s.id}`,children:["[",s.id.substring(0,4),"]"]}),s.taskLabel?e.jsxs("div",{className:"agent-panel-task agent-panel-task-label",title:s.taskLabel,children:[e.jsx(z,{name:"task",size:12})," ",s.taskLabel]}):s.currentTask?e.jsxs("div",{className:"agent-panel-task",title:s.currentTask,children:[s.currentTask.substring(0,40),"..."]}):null]}),e.jsxs("div",{className:"agent-panel-context",title:`Context: ${Math.round(o.usedPercent)}% used (${De(o.totalTokens)} / ${De(o.contextWindow)})`,children:[e.jsx("div",{className:"agent-panel-context-bar",style:{background:o.freePercent<20?"#ff4a4a":o.freePercent<50?"#ff9e4a":"#4aff9e",width:`${o.freePercent}%`}}),e.jsxs("span",{className:"agent-panel-context-text",children:[Math.round(o.freePercent),"%"]})]}),e.jsx("div",{className:"agent-panel-actions",children:e.jsx("button",{className:"agent-panel-expand",onClick:de,title:E(f?"commander.collapsePanel":"commander.expandPanel"),children:f?e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("polyline",{points:"4 14 10 14 10 20"}),e.jsx("polyline",{points:"20 10 14 10 14 4"}),e.jsx("line",{x1:"14",y1:"10",x2:"21",y2:"3"}),e.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]}):e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("polyline",{points:"9 21 3 21 3 15"}),e.jsx("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),e.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]})})})]}),e.jsx("div",{className:"agent-panel-content",ref:h,children:a!=null&&a.loading?e.jsx("div",{className:"agent-panel-loading",children:E("common:status.loading")}):e.jsx(e.Fragment,{children:!re.length&&!n.length?e.jsxs("div",{className:"agent-panel-empty",children:[E("commander.noMessages"),!s.sessionId&&e.jsx("div",{style:{fontSize:"10px",color:"#666"},children:E("commander.noSessionId")})]}):e.jsx(Ve,{historyMessages:re,liveOutputs:n,agentId:s.id,viewMode:d?"advanced":"simple",selectedMessageIndex:null,isMessageSelected:q,onImageClick:ge,onFileClick:ve,onBashClick:je,onViewMarkdown:we,scrollContainerRef:h,onScrollTopReached:g,isLoadingMore:v,hasMore:a==null?void 0:a.hasMore,shouldAutoScroll:C,onUserScroll:m,pinToBottom:x,onPinCancel:Ce,isLoadingHistory:a==null?void 0:a.loading})})}),e.jsxs("div",{className:`guake-input-wrapper ${s.status==="working"?"has-stop-btn is-working":""}`,children:[e.jsx(ft,{agentId:s.id,isWorking:s.status==="working",timestamp:j==null?void 0:j.timestamp}),e.jsx(ut,{command:U,onCommandChange:w,useTextarea:K,forceTextarea:c,onForceTextarea:L,onSend:xe,canSend:le,attachedFiles:$,onAddFile:he,onRemoveFile:se,uploadFile:ae,onAddPastedText:ie,placeholder:E("commander.command",{name:s.name}),compact:!1,inputRef:R})]}),P&&e.jsx(Ge,{url:P.url,name:P.name,onClose:be}),Y&&e.jsx(qe,{state:Y,onClose:r}),e.jsx(Ye,{agent:s,content:G,onClose:J})]})}function ht({currentArea:s,onClose:a}){const{t:l}=fe(["terminal","common"]),[f,p]=t.useState(()=>{const u=new Set(Array.from(I.getState().agents.values()).map(D=>D.name));return Je.find(D=>!u.has(D))||`Agent-${Date.now().toString(36)}`}),[d,M]=t.useState(()=>Me(oe.LAST_CWD)),[A,R]=t.useState("scout"),[N,b]=t.useState("claude"),[E,j]=t.useState(!1),h=()=>{if(!f.trim()||!d.trim())return;j(!0),Ie(oe.LAST_CWD,d);let u;s&&(u={x:s.center.x,z:s.center.z}),I.spawnAgent(f.trim(),A,d.trim(),u,void 0,void 0,void 0,void 0,N),setTimeout(()=>{a()},500)},v=u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),h()),u.key==="Escape"&&a()};return e.jsx("div",{className:"commander-spawn-overlay",onClick:a,children:e.jsxs("div",{className:"commander-spawn-form",onClick:u=>u.stopPropagation(),children:[e.jsxs("div",{className:"commander-spawn-header",children:[e.jsx("h3",{children:l("spawn.addNewAgent")}),s&&e.jsxs("span",{className:"commander-spawn-area",children:[e.jsx("span",{className:"commander-spawn-area-dot",style:{background:s.color}}),s.name]})]}),e.jsxs("div",{className:"commander-spawn-body",children:[e.jsxs("div",{className:"commander-spawn-field",children:[e.jsx("label",{children:l("common:labels.name")}),e.jsx("input",{type:"text",value:f,onChange:u=>p(u.target.value),onKeyDown:v,autoFocus:!0})]}),e.jsxs("div",{className:"commander-spawn-field",children:[e.jsx("label",{children:l("common:labels.workingDirectory")}),e.jsx(Qe,{value:d,onChange:M,onSubmit:h,placeholder:l("spawn.workingDirPlaceholder"),directoriesOnly:!0})]}),e.jsxs("div",{className:"commander-spawn-field",children:[e.jsx("label",{children:l("common:labels.class")}),e.jsx("div",{className:"commander-spawn-classes",children:Xe.map(u=>e.jsxs("button",{className:`commander-spawn-class ${A===u.id?"selected":""}`,onClick:()=>R(u.id),children:[e.jsx(Ze,{classId:u.id,size:18,className:"commander-spawn-class-icon"}),e.jsx("span",{children:u.name})]},u.id))})]}),e.jsxs("div",{className:"commander-spawn-field",children:[e.jsx("label",{children:l("common:labels.runtime")}),e.jsxs("div",{className:"commander-spawn-classes",children:[e.jsxs("button",{className:`commander-spawn-class ${N==="claude"?"selected":""}`,onClick:()=>b("claude"),children:[e.jsx("span",{className:"commander-spawn-class-icon",children:e.jsx(z,{name:"brain",size:14})}),e.jsx("span",{children:"Claude"})]}),e.jsxs("button",{className:`commander-spawn-class ${N==="codex"?"selected":""}`,onClick:()=>b("codex"),children:[e.jsx("span",{className:"commander-spawn-class-icon",children:e.jsx(z,{name:"gear",size:14})}),e.jsx("span",{children:"Codex"})]}),e.jsxs("button",{className:`commander-spawn-class ${N==="opencode"?"selected":""}`,onClick:()=>b("opencode"),children:[e.jsx("span",{className:"commander-spawn-class-icon",children:e.jsx(z,{name:"status-pending",size:12,weight:"fill",color:"#4ade80"})}),e.jsx("span",{children:"OpenCode"})]})]})]})]}),e.jsxs("div",{className:"commander-spawn-footer",children:[e.jsx("button",{className:"commander-spawn-cancel",onClick:a,children:l("common:buttons.cancel")}),e.jsx("button",{className:"commander-spawn-submit",onClick:h,disabled:!f.trim()||!d.trim()||E,children:l(E?"common:buttons.deploying":"common:buttons.deploy")})]})]})})}const Pe=t.memo(function({agent:a,history:l,isExpanded:f,isFocused:p,advancedView:d,index:M,onExpand:A,onCollapse:R,onFocus:N,onInputRef:b,onLoadMore:E,onClearHistory:j}){const h=nt(a.id),v=t.useCallback(()=>{f?R():A(a.id)},[a.id,f,A,R]),u=t.useCallback(()=>{N(p?-1:M)},[M,p,N]),D=t.useCallback(F=>{b(a.id,F)},[a.id,b]),i=t.useCallback(()=>{E(a.id)},[a.id,E]),C=t.useCallback(()=>{j(a.id)},[a.id,j]);return e.jsx(pt,{agent:a,history:l,outputs:h,isExpanded:f,isFocused:p,advancedView:d,onExpand:v,onFocus:u,inputRef:D,onLoadMore:i,onClearHistory:C})});function Ct({isOpen:s,onClose:a}){const{t:l}=fe(["terminal","common"]),f=et(),p=tt(),[d,M]=t.useState(()=>Me(oe.COMMANDER_TAB,"all")),[A,R]=t.useState(0),[N,b]=t.useState(null),E=t.useRef(null),[j,h]=t.useState(0),[v,u]=t.useState(!1),[D,i]=t.useState(null),[C,F]=t.useState(!1),[x,k]=t.useState(()=>{try{const n=Me(oe.COMMANDER_FILTERS,"");if(n)return{...Ne,...JSON.parse(n)}}catch{}return Ne}),P=t.useRef(new Map),W=t.useRef([]),Y=t.useRef(0),V=t.useRef([]),G=t.useRef(d),{histories:X,loadMoreHistory:U,clearAgentHistory:w}=dt({isOpen:s,agents:f});t.useEffect(()=>{s||(b(null),h(0),u(!1))},[s]);const c=t.useMemo(()=>{const n=Array.from(p.values()).sort((g,m)=>g.name.localeCompare(m.name)),o=[{id:"all",name:l("common:labels.all")}];for(const g of n)o.push({id:g.id,name:g.name,color:g.color});return o.push({id:"unassigned",name:l("commander.unassigned")}),o},[p]),L=t.useMemo(()=>d==="all"||d==="unassigned"?null:p.get(d)||null,[d,p]),K=t.useMemo(()=>{const n=new Map;n.set("all",f.size);let o=0;for(const g of f.values()){const m=I.getAreaForAgent(g.id);m?n.set(m.id,(n.get(m.id)||0)+1):o++}return n.set("unassigned",o),n},[f]),B=x.status!=="all"||x.activity!=="all"||x.sort!=="activity",te=(x.status!=="all"?1:0)+(x.activity!=="all"?1:0)+(x.sort!=="activity"?1:0),_=t.useMemo(()=>{const n=m=>m.isBoss===!0||m.class==="boss",o=Date.now();let g=Array.from(f.values());if(d==="unassigned"?g=g.filter(m=>!I.getAreaForAgent(m.id)):d!=="all"&&(g=g.filter(m=>{const T=I.getAreaForAgent(m.id);return(T==null?void 0:T.id)===d})),x.status!=="all"&&(g=g.filter(m=>{switch(x.status){case"working":return m.status==="working";case"idle":return m.status==="idle";case"error":return m.status==="error"||m.status==="waiting"||m.status==="waiting_permission";case"offline":return m.status==="offline"||m.status==="orphaned";default:return!0}})),x.activity!=="all"){const m=lt[x.activity];g=g.filter(T=>o-(T.lastActivity||0)<m)}return g.sort((m,T)=>{var Z,ee;if(n(m)&&!n(T))return-1;if(!n(m)&&n(T))return 1;switch(x.sort){case"activity":return(T.lastActivity||0)-(m.lastActivity||0);case"name":return m.name.localeCompare(T.name);case"created":return(m.createdAt||0)-(T.createdAt||0);case"context":{const q=((Z=m.contextStats)==null?void 0:Z.usedPercent)??(m.contextUsed||0)/(m.contextLimit||2e5)*100;return(((ee=T.contextStats)==null?void 0:ee.usedPercent)??(T.contextUsed||0)/(T.contextLimit||2e5)*100)-q}default:return(T.lastActivity||0)-(m.lastActivity||0)}}),g},[f,d,x]),$=Math.ceil(_.length/Ae),H=t.useMemo(()=>_.slice(A*Ae,(A+1)*Ae),[_,A]);W.current=H,E.current=N,Y.current=j,V.current=c,G.current=d,Te("commander-expanded",N!==null,()=>b(null));const se=st();t.useEffect(()=>{s&&se&&(b(se),I.clearCommanderExpandRequest())},[s,se]);const ae=t.useCallback(()=>b(null),[]),ne=t.useCallback(n=>b(n),[]),le=t.useCallback(n=>h(n),[]),pe=t.useCallback((n,o)=>{o?P.current.set(n,o):P.current.delete(n)},[]);return t.useEffect(()=>{R(0),Ie(oe.COMMANDER_TAB,d)},[d]),t.useEffect(()=>{Ie(oe.COMMANDER_FILTERS,JSON.stringify(x)),R(0)},[x]),t.useEffect(()=>{var o;if(!s||window.matchMedia("(pointer: coarse)").matches)return;const n=N||((o=W.current[j])==null?void 0:o.id);if(n){const g=P.current.get(n);g&&document.activeElement!==g&&setTimeout(()=>g.focus(),50)}},[s,j,N]),t.useEffect(()=>{if(!s)return;const n=o=>{const g=I.getShortcuts(),m=o.target,T=m.tagName==="INPUT"||m.tagName==="TEXTAREA",Z=W.current,ee=Z.length-1,q=E.current,ie=g.find(r=>r.id==="commander-close");if(Q(o,ie)){const{fileViewerPath:r,contextModalAgentId:J}=I.getState();if(r||J)return;o.preventDefault(),o.stopImmediatePropagation(),q?b(null):a();return}const he=g.find(r=>r.id==="commander-vim-left");if(Q(o,he)&&!q){o.preventDefault(),h(r=>r>0?r-1:r);return}const xe=g.find(r=>r.id==="commander-vim-right");if(Q(o,xe)&&!q){o.preventDefault(),h(r=>r<ee?r+1:r);return}const ge=g.find(r=>r.id==="commander-vim-up");if(Q(o,ge)&&!q){o.preventDefault(),h(r=>r>=me?r-me:r);return}const ve=g.find(r=>r.id==="commander-vim-down");if(Q(o,ve)&&!q){o.preventDefault(),h(r=>r+me<=ee?r+me:r);return}const je=g.find(r=>r.id==="commander-expand");if(Q(o,je)){if(o.preventDefault(),q)b(null);else{const r=Z[Y.current];r&&b(r.id)}return}const we=g.find(r=>r.id==="commander-new-agent");if(Q(o,we)){o.preventDefault(),u(!0);return}const Ce=g.find(r=>r.id==="commander-next-tab"),be=g.find(r=>r.id==="commander-prev-tab");if(!T){const r=V.current;if(Q(o,Ce)){const J=I.getState().latestNotificationAgentId;if(J){if(o.preventDefault(),o.stopPropagation(),!I.getState().agents.get(J)){I.setLatestNotificationAgentId(null);return}const y=I.getAreaForAgent(J);y&&r.some(O=>O.id===y.id)?M(y.id):M("unassigned"),b(J),h(0),R(0),I.setLatestNotificationAgentId(null);return}o.preventDefault(),o.stopPropagation();const ce=(r.findIndex(re=>re.id===G.current)+1)%r.length;M(r[ce].id),h(0);return}if(Q(o,be)){o.preventDefault(),o.stopPropagation();const de=(r.findIndex(ce=>ce.id===G.current)-1+r.length)%r.length;M(r[de].id),h(0);return}}};return document.addEventListener("keydown",n,!0),()=>document.removeEventListener("keydown",n,!0)},[s,a]),s?e.jsx("div",{className:"commander-overlay",onClick:a,children:e.jsxs("div",{className:"commander-view",onClick:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"commander-header",children:[e.jsxs("div",{className:"commander-title-section",children:[e.jsx("h2",{className:"commander-title",children:l("commander.title")}),e.jsx("span",{className:"commander-shortcuts",children:l("commander.shortcuts")})]}),e.jsxs("div",{className:"commander-controls",children:[e.jsx("button",{className:`commander-view-toggle ${C?"active":""}`,onClick:()=>F(!C),title:l(C?"commander.simple":"commander.advanced"),children:C?e.jsxs(e.Fragment,{children:[e.jsx(z,{name:"target",size:12})," ",l("commander.advanced")]}):e.jsxs(e.Fragment,{children:[e.jsx(z,{name:"status-pending",size:12})," ",l("commander.simple")]})}),e.jsx("button",{className:"commander-add-btn",onClick:()=>u(!0),title:l("commander.addAgent"),children:l("commander.addAgent")}),e.jsx("button",{className:"commander-close",onClick:a,children:l("commander.close")})]})]}),e.jsx("div",{className:"commander-tabs",children:c.map(n=>{const o=n.id!=="all"&&n.id!=="unassigned"?p.get(n.id):null,g=o&&o.directories&&o.directories.length>0;return e.jsxs("button",{className:`commander-tab ${d===n.id?"active":""}`,onClick:()=>{M(n.id),h(0)},style:n.color?{borderBottomColor:d===n.id?n.color:"transparent"}:void 0,children:[n.color&&e.jsx("span",{className:"commander-tab-dot",style:{background:n.color}}),e.jsx("span",{children:n.name}),e.jsx("span",{className:"commander-tab-count",children:K.get(n.id)||0}),g&&e.jsx("span",{className:"commander-tab-folder",onClick:m=>{m.stopPropagation(),i(n.id)},title:l("commander.openFileExplorer"),children:e.jsx(z,{name:"folder",size:12})})]},n.id)})}),e.jsxs("div",{className:"commander-filters",children:[e.jsxs("div",{className:"commander-filter-group",children:[e.jsx("span",{className:"commander-filter-label",children:l("commander.filters.status")}),["all","working","idle","error","offline"].map(n=>e.jsx("button",{className:`commander-filter-btn ${x.status===n?"active":""}`,onClick:()=>k(o=>({...o,status:n})),children:n==="all"?l("commander.filters.all"):n==="error"?l("commander.filters.needsAttn"):n.charAt(0).toUpperCase()+n.slice(1)},n))]}),e.jsxs("div",{className:"commander-filter-group",children:[e.jsx("span",{className:"commander-filter-label",children:l("commander.filters.active")}),["all","1h","6h","24h"].map(n=>e.jsx("button",{className:`commander-filter-btn ${x.activity===n?"active":""}`,onClick:()=>k(o=>({...o,activity:n})),children:n==="all"?l("commander.filters.any"):`< ${n}`},n))]}),e.jsxs("div",{className:"commander-filter-group",children:[e.jsx("span",{className:"commander-filter-label",children:l("commander.filters.sort")}),["activity","name","created","context"].map(n=>e.jsx("button",{className:`commander-filter-btn ${x.sort===n?"active":""}`,onClick:()=>k(o=>({...o,sort:n})),children:n==="activity"?l("commander.filters.recent"):n==="context"?l("commander.filters.context"):n.charAt(0).toUpperCase()+n.slice(1)},n))]}),B&&e.jsx("button",{className:"commander-filter-clear",onClick:()=>k(Ne),title:l("commander.clearFilters"),children:l("commander.filters.clearFilters",{count:te})})]}),$>1&&e.jsxs("div",{className:"commander-pagination",children:[e.jsxs("button",{className:"commander-page-btn",onClick:()=>R(n=>Math.max(0,n-1)),disabled:A===0,children:[e.jsx(z,{name:"caret-left",size:12})," ",l("commander.prev")]}),e.jsx("span",{className:"commander-page-info",children:l("commander.page",{current:A+1,total:$,count:_.length})}),e.jsxs("button",{className:"commander-page-btn",onClick:()=>R(n=>Math.min($-1,n+1)),disabled:A===$-1,children:[l("commander.next")," ",e.jsx(z,{name:"caret-right",size:12})]})]}),e.jsx("div",{className:`commander-grid ${N?"has-expanded":""}`,"data-agent-count":N?1:H.length,children:H.length===0?e.jsx("div",{className:"commander-empty",children:l(d==="all"?"commander.noAgentsAll":d==="unassigned"?"commander.noAgentsUnassigned":"commander.noAgentsArea")}):N?(()=>{const n=f.get(N);return n?e.jsx(Pe,{agent:n,history:X.get(n.id),isExpanded:!0,isFocused:!0,advancedView:C,index:0,onExpand:ne,onCollapse:ae,onFocus:le,onInputRef:pe,onLoadMore:U,onClearHistory:w},n.id):null})():H.map((n,o)=>e.jsx(Pe,{agent:n,history:X.get(n.id),isExpanded:!1,isFocused:o===j,advancedView:C,index:o,onExpand:ne,onCollapse:ae,onFocus:le,onInputRef:pe,onLoadMore:U,onClearHistory:w},n.id))}),v&&e.jsx(ht,{currentArea:L,onClose:()=>u(!1)}),D&&e.jsx(at,{isOpen:!0,areaId:D,onClose:()=>i(null),onChangeArea:n=>i(n)})]})}):null}export{Ct as CommanderView};
5
+ ${y}`:y}I.sendCommand(s.id,S),w(""),L(!1),U(new Map),H([]),_()},[s.id,B,le,$,ne,b,_,w,L,U,H]),ge=t.useCallback((S,y)=>{W({url:S,name:y})},[]),ve=t.useCallback((S,y)=>{const O=We(S,s.cwd),ue=O.line?{...y||{},targetLine:O.line}:y;I.setFileViewerPath(O.path,ue,s.cwd)},[s.cwd]),je=t.useCallback((S,y)=>{V({command:S,output:y,isLive:y==="Running..."})},[]),we=t.useCallback(S=>{Q(S)},[]),Ce=t.useCallback(()=>{k(!1),i.current=!0,F(!1)},[]),be=t.useCallback(()=>W(null),[]),r=t.useCallback(()=>V(null),[]),Y=t.useCallback(()=>Q(null),[]),de=t.useCallback(S=>{S.stopPropagation(),M()},[M]),ce=ot[s.status]||"#888888",re=(a==null?void 0:a.messages)||[];return e.jsxs("div",{className:`agent-panel ${s.status==="working"?"working":""} ${f?"expanded":""} ${p?"focused":""}`,onClick:p?void 0:A,children:[e.jsxs("div",{className:"agent-panel-header",onClick:p?A:void 0,children:[e.jsxs("div",{className:"agent-panel-info",children:[e.jsx("span",{className:"agent-panel-status",style:{background:ce},title:s.status}),e.jsxs("span",{className:"agent-panel-name",children:[(s.isBoss||s.class==="boss")&&e.jsx("span",{className:"agent-panel-boss-crown",children:e.jsx(z,{name:"crown",size:14})}),s.name]}),e.jsx("span",{className:`agent-panel-status-label ${s.status}`,children:s.status}),e.jsx("span",{className:"agent-panel-class",children:s.class}),e.jsx("span",{className:`agent-panel-provider ${s.provider==="codex"?"codex":s.provider==="opencode"?"opencode":"claude"}`,children:s.provider||"claude"}),e.jsxs("span",{className:"agent-panel-id",title:`ID: ${s.id}`,children:["[",s.id.substring(0,4),"]"]}),s.taskLabel?e.jsxs("div",{className:"agent-panel-task agent-panel-task-label",title:s.taskLabel,children:[e.jsx(z,{name:"task",size:12})," ",s.taskLabel]}):s.currentTask?e.jsxs("div",{className:"agent-panel-task",title:s.currentTask,children:[s.currentTask.substring(0,40),"..."]}):null]}),e.jsxs("div",{className:"agent-panel-context",title:`Context: ${Math.round(o.usedPercent)}% used (${De(o.totalTokens)} / ${De(o.contextWindow)})`,children:[e.jsx("div",{className:"agent-panel-context-bar",style:{background:o.freePercent<20?"#ff4a4a":o.freePercent<50?"#ff9e4a":"#4aff9e",width:`${o.freePercent}%`}}),e.jsxs("span",{className:"agent-panel-context-text",children:[Math.round(o.freePercent),"%"]})]}),e.jsx("div",{className:"agent-panel-actions",children:e.jsx("button",{className:"agent-panel-expand",onClick:de,title:E(f?"commander.collapsePanel":"commander.expandPanel"),children:f?e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("polyline",{points:"4 14 10 14 10 20"}),e.jsx("polyline",{points:"20 10 14 10 14 4"}),e.jsx("line",{x1:"14",y1:"10",x2:"21",y2:"3"}),e.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]}):e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("polyline",{points:"9 21 3 21 3 15"}),e.jsx("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),e.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]})})})]}),e.jsx("div",{className:"agent-panel-content",ref:h,children:a!=null&&a.loading?e.jsx("div",{className:"agent-panel-loading",children:E("common:status.loading")}):e.jsx(e.Fragment,{children:!re.length&&!n.length?e.jsxs("div",{className:"agent-panel-empty",children:[E("commander.noMessages"),!s.sessionId&&e.jsx("div",{style:{fontSize:"10px",color:"#666"},children:E("commander.noSessionId")})]}):e.jsx(Ve,{historyMessages:re,liveOutputs:n,agentId:s.id,viewMode:d?"advanced":"simple",selectedMessageIndex:null,isMessageSelected:G,onImageClick:ge,onFileClick:ve,onBashClick:je,onViewMarkdown:we,scrollContainerRef:h,onScrollTopReached:g,isLoadingMore:v,hasMore:a==null?void 0:a.hasMore,shouldAutoScroll:C,onUserScroll:m,pinToBottom:x,onPinCancel:Ce,isLoadingHistory:a==null?void 0:a.loading})})}),e.jsxs("div",{className:`guake-input-wrapper ${s.status==="working"?"has-stop-btn is-working":""}`,children:[e.jsx(ft,{agentId:s.id,isWorking:s.status==="working",timestamp:j==null?void 0:j.timestamp}),e.jsx(ut,{command:B,onCommandChange:w,useTextarea:K,forceTextarea:c,onForceTextarea:L,onSend:xe,canSend:le,attachedFiles:$,onAddFile:he,onRemoveFile:se,uploadFile:ae,onAddPastedText:ie,placeholder:E("commander.command",{name:s.name}),compact:!1,inputRef:R})]}),P&&e.jsx(qe,{url:P.url,name:P.name,onClose:be}),J&&e.jsx(Ge,{state:J,onClose:r}),e.jsx(Je,{agent:s,content:q,onClose:Y})]})}function ht({currentArea:s,onClose:a}){const{t:l}=fe(["terminal","common"]),[f,p]=t.useState(()=>{const u=new Set(Array.from(I.getState().agents.values()).map(D=>D.name));return Ye.find(D=>!u.has(D))||`Agent-${Date.now().toString(36)}`}),[d,M]=t.useState(()=>Me(oe.LAST_CWD)),[A,R]=t.useState("scout"),[N,b]=t.useState("claude"),[E,j]=t.useState(!1),h=()=>{if(!f.trim()||!d.trim())return;j(!0),Ie(oe.LAST_CWD,d);let u;s&&(u={x:s.center.x,z:s.center.z}),I.spawnAgent(f.trim(),A,d.trim(),u,void 0,void 0,void 0,void 0,N),setTimeout(()=>{a()},500)},v=u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),h()),u.key==="Escape"&&a()};return e.jsx("div",{className:"commander-spawn-overlay",onClick:a,children:e.jsxs("div",{className:"commander-spawn-form",onClick:u=>u.stopPropagation(),children:[e.jsxs("div",{className:"commander-spawn-header",children:[e.jsx("h3",{children:l("spawn.addNewAgent")}),s&&e.jsxs("span",{className:"commander-spawn-area",children:[e.jsx("span",{className:"commander-spawn-area-dot",style:{background:s.color}}),s.name]})]}),e.jsxs("div",{className:"commander-spawn-body",children:[e.jsxs("div",{className:"commander-spawn-field",children:[e.jsx("label",{children:l("common:labels.name")}),e.jsx("input",{type:"text",value:f,onChange:u=>p(u.target.value),onKeyDown:v,autoFocus:!0})]}),e.jsxs("div",{className:"commander-spawn-field",children:[e.jsx("label",{children:l("common:labels.workingDirectory")}),e.jsx(Xe,{value:d,onChange:M,onSubmit:h,placeholder:l("spawn.workingDirPlaceholder"),directoriesOnly:!0})]}),e.jsxs("div",{className:"commander-spawn-field",children:[e.jsx("label",{children:l("common:labels.class")}),e.jsx("div",{className:"commander-spawn-classes",children:Qe.map(u=>e.jsxs("button",{className:`commander-spawn-class ${A===u.id?"selected":""}`,onClick:()=>R(u.id),children:[e.jsx(Ze,{classId:u.id,size:18,className:"commander-spawn-class-icon"}),e.jsx("span",{children:u.name})]},u.id))})]}),e.jsxs("div",{className:"commander-spawn-field",children:[e.jsx("label",{children:l("common:labels.runtime")}),e.jsxs("div",{className:"commander-spawn-classes",children:[e.jsxs("button",{className:`commander-spawn-class ${N==="claude"?"selected":""}`,onClick:()=>b("claude"),children:[e.jsx("span",{className:"commander-spawn-class-icon",children:e.jsx(z,{name:"brain",size:14})}),e.jsx("span",{children:"Claude"})]}),e.jsxs("button",{className:`commander-spawn-class ${N==="codex"?"selected":""}`,onClick:()=>b("codex"),children:[e.jsx("span",{className:"commander-spawn-class-icon",children:e.jsx(z,{name:"gear",size:14})}),e.jsx("span",{children:"Codex"})]}),e.jsxs("button",{className:`commander-spawn-class ${N==="opencode"?"selected":""}`,onClick:()=>b("opencode"),children:[e.jsx("span",{className:"commander-spawn-class-icon",children:e.jsx(z,{name:"status-pending",size:12,weight:"fill",color:"#4ade80"})}),e.jsx("span",{children:"OpenCode"})]})]})]})]}),e.jsxs("div",{className:"commander-spawn-footer",children:[e.jsx("button",{className:"commander-spawn-cancel",onClick:a,children:l("common:buttons.cancel")}),e.jsx("button",{className:"commander-spawn-submit",onClick:h,disabled:!f.trim()||!d.trim()||E,children:l(E?"common:buttons.deploying":"common:buttons.deploy")})]})]})})}const Pe=t.memo(function({agent:a,history:l,isExpanded:f,isFocused:p,advancedView:d,index:M,onExpand:A,onCollapse:R,onFocus:N,onInputRef:b,onLoadMore:E,onClearHistory:j}){const h=nt(a.id),v=t.useCallback(()=>{f?R():A(a.id)},[a.id,f,A,R]),u=t.useCallback(()=>{N(p?-1:M)},[M,p,N]),D=t.useCallback(F=>{b(a.id,F)},[a.id,b]),i=t.useCallback(()=>{E(a.id)},[a.id,E]),C=t.useCallback(()=>{j(a.id)},[a.id,j]);return e.jsx(pt,{agent:a,history:l,outputs:h,isExpanded:f,isFocused:p,advancedView:d,onExpand:v,onFocus:u,inputRef:D,onLoadMore:i,onClearHistory:C})});function Ct({isOpen:s,onClose:a}){const{t:l}=fe(["terminal","common"]),f=et(),p=tt(),[d,M]=t.useState(()=>Me(oe.COMMANDER_TAB,"all")),[A,R]=t.useState(0),[N,b]=t.useState(null),E=t.useRef(null),[j,h]=t.useState(0),[v,u]=t.useState(!1),[D,i]=t.useState(null),[C,F]=t.useState(!1),[x,k]=t.useState(()=>{try{const n=Me(oe.COMMANDER_FILTERS,"");if(n)return{...Ne,...JSON.parse(n)}}catch{}return Ne}),P=t.useRef(new Map),W=t.useRef([]),J=t.useRef(0),V=t.useRef([]),q=t.useRef(d),{histories:Q,loadMoreHistory:B,clearAgentHistory:w}=dt({isOpen:s,agents:f});t.useEffect(()=>{s||(b(null),h(0),u(!1))},[s]);const c=t.useMemo(()=>{const n=Array.from(p.values()).sort((g,m)=>g.name.localeCompare(m.name)),o=[{id:"all",name:l("common:labels.all")}];for(const g of n)o.push({id:g.id,name:g.name,color:g.color});return o.push({id:"unassigned",name:l("commander.unassigned")}),o},[p]),L=t.useMemo(()=>d==="all"||d==="unassigned"?null:p.get(d)||null,[d,p]),K=t.useMemo(()=>{const n=new Map;n.set("all",f.size);let o=0;for(const g of f.values()){const m=I.getAreaForAgent(g.id);m?n.set(m.id,(n.get(m.id)||0)+1):o++}return n.set("unassigned",o),n},[f]),U=x.status!=="all"||x.activity!=="all"||x.sort!=="activity",te=(x.status!=="all"?1:0)+(x.activity!=="all"?1:0)+(x.sort!=="activity"?1:0),_=t.useMemo(()=>{const n=m=>m.isBoss===!0||m.class==="boss",o=Date.now();let g=Array.from(f.values());if(d==="unassigned"?g=g.filter(m=>!I.getAreaForAgent(m.id)):d!=="all"&&(g=g.filter(m=>{const T=I.getAreaForAgent(m.id);return(T==null?void 0:T.id)===d})),x.status!=="all"&&(g=g.filter(m=>{switch(x.status){case"working":return m.status==="working";case"idle":return m.status==="idle";case"error":return m.status==="error"||m.status==="waiting"||m.status==="waiting_permission";case"offline":return m.status==="offline"||m.status==="orphaned";default:return!0}})),x.activity!=="all"){const m=lt[x.activity];g=g.filter(T=>o-(T.lastActivity||0)<m)}return g.sort((m,T)=>{var Z,ee;if(n(m)&&!n(T))return-1;if(!n(m)&&n(T))return 1;switch(x.sort){case"activity":return(T.lastActivity||0)-(m.lastActivity||0);case"name":return m.name.localeCompare(T.name);case"created":return(m.createdAt||0)-(T.createdAt||0);case"context":{const G=((Z=m.contextStats)==null?void 0:Z.usedPercent)??(m.contextUsed||0)/(m.contextLimit||2e5)*100;return(((ee=T.contextStats)==null?void 0:ee.usedPercent)??(T.contextUsed||0)/(T.contextLimit||2e5)*100)-G}default:return(T.lastActivity||0)-(m.lastActivity||0)}}),g},[f,d,x]),$=Math.ceil(_.length/Ae),H=t.useMemo(()=>_.slice(A*Ae,(A+1)*Ae),[_,A]);W.current=H,E.current=N,J.current=j,V.current=c,q.current=d,Te("commander-expanded",N!==null,()=>b(null));const se=st();t.useEffect(()=>{s&&se&&(b(se),I.clearCommanderExpandRequest())},[s,se]);const ae=t.useCallback(()=>b(null),[]),ne=t.useCallback(n=>b(n),[]),le=t.useCallback(n=>h(n),[]),pe=t.useCallback((n,o)=>{o?P.current.set(n,o):P.current.delete(n)},[]);return t.useEffect(()=>{R(0),Ie(oe.COMMANDER_TAB,d)},[d]),t.useEffect(()=>{Ie(oe.COMMANDER_FILTERS,JSON.stringify(x)),R(0)},[x]),t.useEffect(()=>{var o;if(!s||window.matchMedia("(pointer: coarse)").matches)return;const n=N||((o=W.current[j])==null?void 0:o.id);if(n){const g=P.current.get(n);g&&document.activeElement!==g&&setTimeout(()=>g.focus(),50)}},[s,j,N]),t.useEffect(()=>{if(!s)return;const n=o=>{const g=I.getShortcuts(),m=o.target,T=m.tagName==="INPUT"||m.tagName==="TEXTAREA",Z=W.current,ee=Z.length-1,G=E.current,ie=g.find(r=>r.id==="commander-close");if(X(o,ie)){const{fileViewerPath:r,contextModalAgentId:Y}=I.getState();if(r||Y)return;o.preventDefault(),o.stopImmediatePropagation(),G?b(null):a();return}const he=g.find(r=>r.id==="commander-vim-left");if(X(o,he)&&!G){o.preventDefault(),h(r=>r>0?r-1:r);return}const xe=g.find(r=>r.id==="commander-vim-right");if(X(o,xe)&&!G){o.preventDefault(),h(r=>r<ee?r+1:r);return}const ge=g.find(r=>r.id==="commander-vim-up");if(X(o,ge)&&!G){o.preventDefault(),h(r=>r>=me?r-me:r);return}const ve=g.find(r=>r.id==="commander-vim-down");if(X(o,ve)&&!G){o.preventDefault(),h(r=>r+me<=ee?r+me:r);return}const je=g.find(r=>r.id==="commander-expand");if(X(o,je)){if(o.preventDefault(),G)b(null);else{const r=Z[J.current];r&&b(r.id)}return}const we=g.find(r=>r.id==="commander-new-agent");if(X(o,we)){o.preventDefault(),u(!0);return}const Ce=g.find(r=>r.id==="commander-next-tab"),be=g.find(r=>r.id==="commander-prev-tab");if(!T){const r=V.current;if(X(o,Ce)){const Y=I.getState().latestNotificationAgentId;if(Y){if(o.preventDefault(),o.stopPropagation(),!I.getState().agents.get(Y)){I.setLatestNotificationAgentId(null);return}const y=I.getAreaForAgent(Y);y&&r.some(O=>O.id===y.id)?M(y.id):M("unassigned"),b(Y),h(0),R(0),I.setLatestNotificationAgentId(null);return}o.preventDefault(),o.stopPropagation();const ce=(r.findIndex(re=>re.id===q.current)+1)%r.length;M(r[ce].id),h(0);return}if(X(o,be)){o.preventDefault(),o.stopPropagation();const de=(r.findIndex(ce=>ce.id===q.current)-1+r.length)%r.length;M(r[de].id),h(0);return}}};return document.addEventListener("keydown",n,!0),()=>document.removeEventListener("keydown",n,!0)},[s,a]),s?e.jsx("div",{className:"commander-overlay",onClick:a,children:e.jsxs("div",{className:"commander-view",onClick:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"commander-header",children:[e.jsxs("div",{className:"commander-title-section",children:[e.jsx("h2",{className:"commander-title",children:l("commander.title")}),e.jsx("span",{className:"commander-shortcuts",children:l("commander.shortcuts")})]}),e.jsxs("div",{className:"commander-controls",children:[e.jsx("button",{className:`commander-view-toggle ${C?"active":""}`,onClick:()=>F(!C),title:l(C?"commander.simple":"commander.advanced"),children:C?e.jsxs(e.Fragment,{children:[e.jsx(z,{name:"target",size:12})," ",l("commander.advanced")]}):e.jsxs(e.Fragment,{children:[e.jsx(z,{name:"status-pending",size:12})," ",l("commander.simple")]})}),e.jsx("button",{className:"commander-add-btn",onClick:()=>u(!0),title:l("commander.addAgent"),children:l("commander.addAgent")}),e.jsx("button",{className:"commander-close",onClick:a,children:l("commander.close")})]})]}),e.jsx("div",{className:"commander-tabs",children:c.map(n=>{const o=n.id!=="all"&&n.id!=="unassigned"?p.get(n.id):null,g=o&&o.directories&&o.directories.length>0;return e.jsxs("button",{className:`commander-tab ${d===n.id?"active":""}`,onClick:()=>{M(n.id),h(0)},style:n.color?{borderBottomColor:d===n.id?n.color:"transparent"}:void 0,children:[n.color&&e.jsx("span",{className:"commander-tab-dot",style:{background:n.color}}),e.jsx("span",{children:n.name}),e.jsx("span",{className:"commander-tab-count",children:K.get(n.id)||0}),g&&e.jsx("span",{className:"commander-tab-folder",onClick:m=>{m.stopPropagation(),i(n.id)},title:l("commander.openFileExplorer"),children:e.jsx(z,{name:"folder",size:12})})]},n.id)})}),e.jsxs("div",{className:"commander-filters",children:[e.jsxs("div",{className:"commander-filter-group",children:[e.jsx("span",{className:"commander-filter-label",children:l("commander.filters.status")}),["all","working","idle","error","offline"].map(n=>e.jsx("button",{className:`commander-filter-btn ${x.status===n?"active":""}`,onClick:()=>k(o=>({...o,status:n})),children:n==="all"?l("commander.filters.all"):n==="error"?l("commander.filters.needsAttn"):n.charAt(0).toUpperCase()+n.slice(1)},n))]}),e.jsxs("div",{className:"commander-filter-group",children:[e.jsx("span",{className:"commander-filter-label",children:l("commander.filters.active")}),["all","1h","6h","24h"].map(n=>e.jsx("button",{className:`commander-filter-btn ${x.activity===n?"active":""}`,onClick:()=>k(o=>({...o,activity:n})),children:n==="all"?l("commander.filters.any"):`< ${n}`},n))]}),e.jsxs("div",{className:"commander-filter-group",children:[e.jsx("span",{className:"commander-filter-label",children:l("commander.filters.sort")}),["activity","name","created","context"].map(n=>e.jsx("button",{className:`commander-filter-btn ${x.sort===n?"active":""}`,onClick:()=>k(o=>({...o,sort:n})),children:n==="activity"?l("commander.filters.recent"):n==="context"?l("commander.filters.context"):n.charAt(0).toUpperCase()+n.slice(1)},n))]}),U&&e.jsx("button",{className:"commander-filter-clear",onClick:()=>k(Ne),title:l("commander.clearFilters"),children:l("commander.filters.clearFilters",{count:te})})]}),$>1&&e.jsxs("div",{className:"commander-pagination",children:[e.jsxs("button",{className:"commander-page-btn",onClick:()=>R(n=>Math.max(0,n-1)),disabled:A===0,children:[e.jsx(z,{name:"caret-left",size:12})," ",l("commander.prev")]}),e.jsx("span",{className:"commander-page-info",children:l("commander.page",{current:A+1,total:$,count:_.length})}),e.jsxs("button",{className:"commander-page-btn",onClick:()=>R(n=>Math.min($-1,n+1)),disabled:A===$-1,children:[l("commander.next")," ",e.jsx(z,{name:"caret-right",size:12})]})]}),e.jsx("div",{className:`commander-grid ${N?"has-expanded":""}`,"data-agent-count":N?1:H.length,children:H.length===0?e.jsx("div",{className:"commander-empty",children:l(d==="all"?"commander.noAgentsAll":d==="unassigned"?"commander.noAgentsUnassigned":"commander.noAgentsArea")}):N?(()=>{const n=f.get(N);return n?e.jsx(Pe,{agent:n,history:Q.get(n.id),isExpanded:!0,isFocused:!0,advancedView:C,index:0,onExpand:ne,onCollapse:ae,onFocus:le,onInputRef:pe,onLoadMore:B,onClearHistory:w},n.id):null})():H.map((n,o)=>e.jsx(Pe,{agent:n,history:Q.get(n.id),isExpanded:!1,isFocused:o===j,advancedView:C,index:o,onExpand:ne,onCollapse:ae,onFocus:le,onInputRef:pe,onLoadMore:B,onClearHistory:w},n.id))}),v&&e.jsx(ht,{currentArea:L,onClose:()=>u(!1)}),D&&e.jsx(at,{isOpen:!0,areaId:D,onClose:()=>i(null),onChangeArea:n=>i(n)})]})}):null}export{Ct as CommanderView};