tide-commander 1.76.2 → 1.77.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/assets/{BossLogsModal-B41BvcEF.js → BossLogsModal-DadqfwM-.js} +1 -1
  2. package/dist/assets/{BossSpawnModal-DUTcju8I.js → BossSpawnModal-BfBD2177.js} +1 -1
  3. package/dist/assets/{ControlsModal-DbiIdKPt.js → ControlsModal-C7k19rVV.js} +1 -1
  4. package/dist/assets/{DockerLogsModal-5mrsMmlQ.js → DockerLogsModal-zerJaMSY.js} +1 -1
  5. package/dist/assets/{EmbeddedEditor-DirMT3E8.js → EmbeddedEditor-C_sbdn9e.js} +1 -1
  6. package/dist/assets/{GmailOAuthSetup-CmGKGxui.js → GmailOAuthSetup-CWUAVZZM.js} +1 -1
  7. package/dist/assets/{GoogleOAuthSetup-CbWwCAK0.js → GoogleOAuthSetup-E7aWGuMy.js} +1 -1
  8. package/dist/assets/{IframeModal-Dboa4JXN.js → IframeModal-BNwvP8Po.js} +1 -1
  9. package/dist/assets/{IntegrationsPanel-DS28YNJo.js → IntegrationsPanel-CWQ5Uum4.js} +2 -2
  10. package/dist/assets/{LogViewerModal-UbrMLs2v.js → LogViewerModal-BCXMLdRH.js} +1 -1
  11. package/dist/assets/{MonitoringModal-B_XI1vTS.js → MonitoringModal-DK79sc5N.js} +1 -1
  12. package/dist/assets/{PM2LogsModal-ChvPf5Uv.js → PM2LogsModal-Bh3w4epV.js} +1 -1
  13. package/dist/assets/{RestoreArchivedAreaModal-CEq_4zoQ.js → RestoreArchivedAreaModal-B-H5Skrp.js} +1 -1
  14. package/dist/assets/{Scene2DCanvas-DYDA_fv5.js → Scene2DCanvas-B9UN5ZKm.js} +1 -1
  15. package/dist/assets/{SceneManager-Be_I2Z9r.js → SceneManager-FjdQYco5.js} +1 -1
  16. package/dist/assets/{SkillsPanel-CNIkJScD.js → SkillsPanel-B9C8MwOF.js} +1 -1
  17. package/dist/assets/{SpawnModal-BXV32TQn.js → SpawnModal-D_LcFbP1.js} +1 -1
  18. package/dist/assets/{SubordinateAssignmentModal-DK3uJtBR.js → SubordinateAssignmentModal-BoanKhXq.js} +1 -1
  19. package/dist/assets/{TriggerManagerPanel-C8JheOOO.js → TriggerManagerPanel-Ck-tzKLv.js} +1 -1
  20. package/dist/assets/{WorkflowEditorPanel-DeLnt3ou.js → WorkflowEditorPanel-Bwvw_Vgj.js} +1 -1
  21. package/dist/assets/{index-C2QVwmIa.js → index-7isjCekP.js} +1 -1
  22. package/dist/assets/{index-D6ez6g4v.js → index-8lOgiTZV.js} +1 -1
  23. package/dist/assets/{index-C-HNvKyN.js → index-B5v0FpYR.js} +1 -1
  24. package/dist/assets/{index-BZFjiZW2.js → index-BAwissdJ.js} +1 -1
  25. package/dist/assets/{index-BR3DNqtn.js → index-BJJScfkg.js} +1 -1
  26. package/dist/assets/{index-DXjESpea.js → index-BKq2RkPI.js} +3 -3
  27. package/dist/assets/{index-B7BnOlMV.js → index-Baz89OXb.js} +2 -2
  28. package/dist/assets/index-DMa3VOph.js +2 -0
  29. package/dist/assets/{index-CymWdB1l.js → index-DvKJEzc1.js} +1 -1
  30. package/dist/assets/{main-BvvvhWnd.js → main-CiaEK7il.js} +89 -89
  31. package/dist/assets/{web-Dyi_JNTJ.js → web-BdPxI-ix.js} +1 -1
  32. package/dist/assets/{web-B-5bt6Uj.js → web-C1fk4YYO.js} +1 -1
  33. package/dist/index.html +1 -1
  34. package/package.json +1 -1
  35. package/dist/assets/index-DHlpIGVI.js +0 -2
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/web-Dyi_JNTJ.js","assets/main-BvvvhWnd.js","assets/vendor-react--Eh9ivFN.js","assets/vendor-three-Chj50gSY.js","assets/main-Co2mNETL.css"])))=>i.map(i=>d[i]);
2
- import{bW as e,bn as n}from"./main-BvvvhWnd.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";var i;(function(r){r.Heavy="HEAVY",r.Medium="MEDIUM",r.Light="LIGHT"})(i||(i={}));var t;(function(r){r.Success="SUCCESS",r.Warning="WARNING",r.Error="ERROR"})(t||(t={}));const E=e("Haptics",{web:()=>n(()=>import("./web-Dyi_JNTJ.js"),__vite__mapDeps([0,1,2,3,4])).then(r=>new r.HapticsWeb)});export{E as Haptics,i as ImpactStyle,t as NotificationType};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/web-BdPxI-ix.js","assets/main-CiaEK7il.js","assets/vendor-react--Eh9ivFN.js","assets/vendor-three-Chj50gSY.js","assets/main-Co2mNETL.css"])))=>i.map(i=>d[i]);
2
+ import{bW as e,bn as n}from"./main-CiaEK7il.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";var i;(function(r){r.Heavy="HEAVY",r.Medium="MEDIUM",r.Light="LIGHT"})(i||(i={}));var t;(function(r){r.Success="SUCCESS",r.Warning="WARNING",r.Error="ERROR"})(t||(t={}));const E=e("Haptics",{web:()=>n(()=>import("./web-BdPxI-ix.js"),__vite__mapDeps([0,1,2,3,4])).then(r=>new r.HapticsWeb)});export{E as Haptics,i as ImpactStyle,t as NotificationType};
@@ -0,0 +1,2 @@
1
+ import{u as Dt,z as Lt,B as zt,r as n,E as xt,S as j,G as _t,H as dt,J as bt,K as Xe,L as he,M as $t,s as C,N as vt,O as Ot,v as Ft,w as Bt,j as e,I as m,P as Wt,m as Ht,U as Gt,V as Nt,W as kt,X as Vt,Y as Ut,Z as Xt,_ as qt,$ as Kt,a0 as Yt,a1 as Zt,a2 as Jt,a3 as Qt,C as ea,a4 as ta,a5 as aa,a6 as na,a7 as sa,a8 as ra,a9 as la,aa as ia,ab as oa,ac as ca,ad as da,ae as ua,af as pa,ag as ma,ah as fa,ai as ha,aj as ga,ak as xa}from"./main-CiaEK7il.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const qe=3,Ke=280,wt=320,ct=240,Ct=64,_a=["simple","chat","advanced"],ba={simple:"Simple",chat:"Chat",advanced:"Advanced"},wa={simple:"○",chat:"◐",advanced:"◉"},Ca={simple:"Simple view — clean messages only",chat:"Chat view — assistant replies (no tool calls)",advanced:"Advanced view — everything including tools"},jt="flat-clear-context";function ja(x){const c=x.split("/").filter(Boolean);return c.length===0?x:c.slice(-2).join("/")}function va(x){if(x.provider==="codex"){const ie=x.codexModel||"gpt-5.3-codex",L=ha[ie];return{model:(L==null?void 0:L.label)||ie}}if(x.provider==="opencode")return{model:x.opencodeModel||"opencode"};const c=x.model||"sonnet",v=xa[c],y=x.effort,D=y?ga[y]:void 0;return{model:(v==null?void 0:v.label)||c,effort:D==null?void 0:D.label}}function Na(x,c){if(c.type==="rectangle"&&c.width&&c.height){const v=c.width/2,y=c.height/2;return x.x>=c.center.x-v&&x.x<=c.center.x+v&&x.z>=c.center.z-y&&x.z<=c.center.z+y}if(c.type==="circle"&&c.radius){const v=x.x-c.center.x,y=x.z-c.center.z;return v*v+y*y<=c.radius*c.radius}return!1}const ka=ta.memo(function({agentId:c,terminalViewMode:v,onTerminalViewModeChange:y,inspectorOpen:D,onToggleInspector:ie,onImageClick:L,onFileClick:S,onBashClick:ge,onViewMarkdown:xe,onRequestClearSubordinates:Se,onOpenBuilding:_e,keyboard:Me,canNavigateBack:be,canNavigateForward:ye,onNavigateBack:T,onNavigateForward:oe,agentInfoOpen:z,onToggleAgentInfo:Ee}){var Fe,E,re,Be;const p=aa(c),P=na(),ce=n.useRef(null),Te=n.useRef(null);n.useEffect(()=>{const r=Te.current;if(!r)return;const i=o=>{o.button===3?(o.preventDefault(),o.stopPropagation(),T()):o.button===4&&(o.preventDefault(),o.stopPropagation(),oe())},d=o=>{(o.button===3||o.button===4)&&o.preventDefault()};return r.addEventListener("mouseup",i),r.addEventListener("mousedown",d),()=>{r.removeEventListener("mouseup",i),r.removeEventListener("mousedown",d)}},[T,oe]);const we=vt(),de=n.useMemo(()=>{if(!p)return null;const r=new Set,i=[];for(const d of we.values())d.archived||d.directories.length===0||d.assignedAgentIds.includes(c)&&(r.add(d.id),i.push(d));for(const d of we.values())d.archived||d.directories.length===0||r.has(d.id)||Na({x:p.position.x,z:p.position.z},d)&&(r.add(d.id),i.push(d));return i.length===0?null:i.flatMap(d=>d.directories.filter(o=>o&&o.trim().length>0).map(o=>({areaId:d.id,areaName:d.name,dir:o})))},[p,c,we]),{branches:Pe,fetchRemote:Ce,fetchingDirs:je}=sa(de),F=n.useMemo(()=>{var d;const r=C.getAreaForAgent(c);if(!r)return[];const i=[];for(const o of P.values())o.type==="terminal"&&C.isPositionInArea(o.position,r)&&i.push({id:o.id,name:o.name,hasUrl:!!((d=o.terminalStatus)!=null&&d.url)});return i},[c,P]),ue=n.useMemo(()=>{var d;const r=C.getAreaForAgent(c);if(!r)return[];const i=[];for(const o of P.values())o.type==="server"&&((d=o.pm2)!=null&&d.enabled)&&C.isPositionInArea(o.position,r)&&i.push({id:o.id,name:o.name});return i},[c,P]),Re=n.useMemo(()=>{const r=C.getAreaForAgent(c);if(!r)return[];const i=[];for(const d of P.values())d.type==="database"&&d.database&&C.isPositionInArea(d.position,r)&&i.push({id:d.id,name:d.name});return i},[c,P]),[,Ye]=n.useReducer(r=>r+1,0),B=((Fe=ce.current)==null?void 0:Fe.search.searchMode)??!1,te=n.useCallback(()=>{var r;(r=ce.current)==null||r.search.toggleSearch(),Ye()},[]),X=ra(),q=X.isPending(jt),[k,W]=n.useState(null),M=k?P.get(k):null,{height:K,onResizeStart:Ze}=la(),[ae,ve]=n.useState(()=>dt(j.GIT_PANEL_OPEN,!1)),[$,De]=n.useState(()=>dt(j.BUILDINGS_PANEL_OPEN,!1)),[ne,Y]=n.useState(!1),Je=n.useCallback(()=>{Y(r=>{const i=!r;return i&&ia.setEnabled(!0),i})},[]),Le=n.useCallback(()=>Y(!1),[]),Qe=n.useCallback(()=>{ve(r=>{const i=!r;return he(j.GIT_PANEL_OPEN,i),i})},[]),et=n.useCallback(()=>{De(r=>{const i=!r;return he(j.BUILDINGS_PANEL_OPEN,i),i})},[]),tt=n.useCallback(()=>{ve(!1),he(j.GIT_PANEL_OPEN,!1)},[]),at=n.useCallback(()=>{De(!1),he(j.BUILDINGS_PANEL_OPEN,!1)},[]),nt=oa();n.useEffect(()=>{if(!k)return;F.some(i=>i.id===k)||W(null)},[k,F]);const[se,Z]=n.useState(!1),Ne=n.useRef(null);if(n.useEffect(()=>{if(!se)return;const r=i=>{Ne.current&&!Ne.current.contains(i.target)&&Z(!1)};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[se]),!p)return e.jsx("div",{className:"flat-chat flat-chat--empty",children:e.jsxs("div",{className:"flat-chat__placeholder",children:[e.jsx("span",{className:"flat-chat__placeholder-icon",children:"💬"}),e.jsx("span",{className:"flat-chat__placeholder-text",children:"Select an agent to start chatting"})]})});const H=p.contextStats,u=!!H,G=H?H.totalTokens:p.contextUsed||0,R=H?H.contextWindow:p.contextLimit||2e5,pe=H?H.usedPercent:Math.round(G/R*100),V=Math.max(0,Math.min(100,pe)),st=Math.max(0,100-V),ze=V>=80?"#ff4a4a":V>=60?"#ff9e4a":V>=40?"#ffd700":"#4aff9e",$e=(G/1e3).toFixed(1),Oe=(R/1e3).toFixed(1),U=p.cwd,J=U?ja(U):null,Q=((E=p.subordinateIds)==null?void 0:E.length)||0,ee=Q>0;return e.jsxs("div",{ref:Te,className:`flat-terminal-wrapper ${ae||$||ne?"flat-terminal-wrapper--with-side-panel":""}`,children:[e.jsxs("div",{className:"flat-terminal-wrapper__header",children:[e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__header-main ${z?"flat-terminal-wrapper__header-main--active":""}`,onClick:Ee,title:z?"Hide agent info":"Show agent info","aria-pressed":z,children:[e.jsx(Nt,{agent:p,size:28}),e.jsxs("span",{className:"flat-terminal-wrapper__header-info",children:[e.jsx("span",{className:"flat-terminal-wrapper__header-name",children:p.name}),e.jsx("span",{className:"flat-terminal-wrapper__header-status",style:{color:kt(p.status)},children:p.status})]}),p.taskLabel&&e.jsxs("span",{className:"flat-terminal-wrapper__header-task",title:p.taskLabel,children:["📋 ",p.taskLabel]}),e.jsxs("span",{className:"flat-terminal-wrapper__header-model",children:[e.jsx("img",{src:p.provider==="codex"?"/assets/codex.png":p.provider==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:p.provider,className:"flat-terminal-wrapper__header-provider-icon",title:p.provider==="codex"?"Codex Agent":p.provider==="opencode"?"OpenCode Agent":"Claude Agent"}),(()=>{const{model:r,effort:i}=va(p);return e.jsxs("span",{className:"flat-terminal-wrapper__header-model-chip",title:i?`Model: ${r} · Effort: ${i}`:`Model: ${r}`,children:[e.jsx("span",{className:"flat-terminal-wrapper__header-model-name",children:r}),i&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flat-terminal-wrapper__header-model-sep","aria-hidden":"true",children:"·"}),e.jsx("span",{className:"flat-terminal-wrapper__header-model-effort",children:i})]})]})})()]})]}),e.jsxs("div",{className:"flat-terminal-wrapper__header-meta",children:[e.jsx("div",{className:"flat-terminal-wrapper__view-mode",role:"group","aria-label":"Message view mode",children:_a.map(r=>e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__view-mode-btn ${v===r?"flat-terminal-wrapper__view-mode-btn--active":""}`,onClick:()=>y(r),title:Ca[r],"aria-pressed":v===r,children:[e.jsx("span",{className:"flat-terminal-wrapper__view-mode-icon","aria-hidden":"true",children:wa[r]}),e.jsx("span",{className:"flat-terminal-wrapper__view-mode-label",children:ba[r]})]},r))}),e.jsxs("div",{className:"flat-terminal-wrapper__actions",role:"group","aria-label":"Terminal actions",children:[e.jsx("button",{type:"button",className:"flat-terminal-wrapper__action-btn",onClick:T,disabled:!be,title:"Back to previous agent","aria-label":"Back to previous agent",children:e.jsx(m,{name:"arrow-left",size:14})}),e.jsx("button",{type:"button",className:"flat-terminal-wrapper__action-btn",onClick:oe,disabled:!ye,title:"Forward to next agent","aria-label":"Forward to next agent",children:e.jsx(m,{name:"arrow-right",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${B?"flat-terminal-wrapper__action-btn--active":""}`,onClick:te,title:B?"Close search":"Search messages","aria-pressed":B,children:e.jsx(m,{name:B?"cross":"search",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn flat-terminal-wrapper__action-btn--danger ${q?"flat-terminal-wrapper__action-btn--confirm":""}`,onClick:()=>X.handleClick(jt,()=>{var r;C.clearContext(c),(r=ce.current)==null||r.historyLoader.clearHistory()}),title:q?"Click again to confirm clear context":"Clear context",children:e.jsx(m,{name:q?"question":"clear",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${ae?"flat-terminal-wrapper__action-btn--active":""}`,onClick:Qe,title:ae?"Hide git panel":"Show git changes","aria-pressed":ae,children:e.jsx(m,{name:"git-branch",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${$?"flat-terminal-wrapper__action-btn--active":""}`,onClick:et,title:$?"Hide buildings panel":"Show area buildings","aria-pressed":$,children:e.jsx(m,{name:"buildings",size:14})}),e.jsxs("div",{className:"flat-terminal-wrapper__more",ref:Ne,children:[e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${se?"flat-terminal-wrapper__action-btn--active":""}`,onClick:()=>Z(r=>!r),title:"More actions","aria-expanded":se,children:"⋮"}),se&&e.jsxs("div",{className:"flat-terminal-wrapper__more-menu",role:"menu",children:[e.jsxs("button",{type:"button",role:"menuitem",className:`flat-terminal-wrapper__more-item ${ne?"flat-terminal-wrapper__more-item--active":""}`,onClick:()=>{Je(),Z(!1)},title:ne?"Hide Debug Panel":"Show Debug Panel",children:[e.jsx(m,{name:"bug",size:14}),e.jsx("span",{children:ne?"Hide Debug Panel":"Show Debug Panel"})]}),e.jsx("div",{className:"flat-terminal-wrapper__more-divider"}),e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item",onClick:()=>{C.collapseContext(c),Z(!1)},disabled:p.status!=="idle",title:p.status!=="idle"?"Agent must be idle to collapse context":"Collapse context",children:[e.jsx(m,{name:"package",size:14}),e.jsx("span",{children:"Collapse context"})]}),ee&&e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item flat-terminal-wrapper__more-item--danger",onClick:()=>{Se(c,Q),Z(!1)},children:[e.jsx(m,{name:"crown",size:14}),e.jsxs("span",{children:["Clear ",Q," subordinate",Q===1?"":"s"]})]}),e.jsx("div",{className:"flat-terminal-wrapper__more-divider"}),e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item flat-terminal-wrapper__more-item--danger",onClick:()=>{C.killAgent(c),Z(!1)},children:[e.jsx(m,{name:"cross",size:14}),e.jsx("span",{children:"Remove agent"})]})]})]})]}),e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__inspector-toggle ${D?"flat-terminal-wrapper__inspector-toggle--active":""}`,onClick:ie,title:D?"Hide inspector panel":"Show inspector panel","aria-label":D?"Hide inspector panel":"Show inspector panel","aria-pressed":D,children:[e.jsx("span",{className:"flat-terminal-wrapper__inspector-icon","aria-hidden":"true",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"}),e.jsx("line",{x1:"10",y1:"2.5",x2:"10",y2:"13.5"})]})}),e.jsx("span",{className:"flat-terminal-wrapper__inspector-label",children:"Inspector"})]}),e.jsx("button",{type:"button",className:"flat-terminal-wrapper__close",onClick:()=>C.deselectAll(),title:"Close chat","aria-label":"Close chat",children:e.jsx(m,{name:"cross",size:14})})]})]}),e.jsx(ca,{ref:ce,agentId:c,agent:p,viewMode:v,isOpen:!0,onImageClick:L,onFileClick:S,onBashClick:ge,onViewMarkdown:xe,keyboard:Me,hasModalOpen:!1}),M&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"guake-bottom-terminal-resize",onMouseDown:Ze,role:"separator","aria-orientation":"horizontal","aria-label":"Resize embedded terminal"}),e.jsxs("div",{className:"flat-bottom-panel",role:"region","aria-label":`Embedded terminal: ${M.name}`,style:{height:K},children:[e.jsxs("div",{className:"flat-bottom-panel__header",children:[e.jsxs("span",{className:"flat-bottom-panel__title",children:[e.jsx(m,{name:"terminal",size:12}),e.jsx("span",{children:M.name}),!((re=M.terminalStatus)!=null&&re.url)&&e.jsx("span",{className:"flat-bottom-panel__muted",children:"(starting...)"})]}),e.jsx("button",{type:"button",className:"flat-bottom-panel__close",onClick:()=>W(null),title:"Close embedded terminal","aria-label":"Close embedded terminal",children:e.jsx(m,{name:"cross",size:12})})]}),e.jsx("div",{className:"flat-bottom-panel__body",children:(Be=M.terminalStatus)!=null&&Be.url?e.jsx(da,{terminalUrl:M.terminalStatus.url,visible:!0}):e.jsx("div",{className:"flat-bottom-panel__placeholder",children:"Starting terminal..."})})]})]}),e.jsxs("div",{className:"flat-terminal-wrapper__statusbar",role:"contentinfo",children:[p.isDetached&&e.jsxs("span",{className:"flat-terminal-wrapper__detached",title:"Reattaching session...",children:[e.jsx(m,{name:"refresh",size:12}),e.jsx("span",{children:"Reattaching"})]}),U&&J&&e.jsxs("span",{className:"flat-terminal-wrapper__cwd",title:U,onClick:()=>C.setFileViewerPath(U),children:[e.jsx("span",{className:"flat-terminal-wrapper__cwd-icon",children:e.jsx(m,{name:"folder",size:12})}),e.jsx("span",{className:"flat-terminal-wrapper__cwd-text",children:J})]}),de&&de.map(({areaId:r,areaName:i,dir:d})=>{const o=Pe.get(d),We=je.has(d),rt=d.split("/").filter(Boolean).pop()||d;return e.jsxs("span",{className:"flat-terminal-wrapper__area-dir",title:`${i}: ${d}${o?` (${o.branch}${o.ahead?` ↑${o.ahead}`:""}${o.behind?` ↓${o.behind}`:""})`:""}`,onClick:()=>C.openFileExplorerForAreaFolder(r,d),children:[e.jsx(m,{name:"folder-open",size:12}),e.jsx("span",{className:"flat-terminal-wrapper__area-dir-name",children:rt}),o&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flat-terminal-wrapper__area-dir-branch",children:[e.jsx(m,{name:"git-branch",size:10})," ",o.branch]}),o.ahead>0&&e.jsxs("span",{className:"flat-terminal-wrapper__branch-ahead",title:`${o.ahead} ahead`,children:[e.jsx(m,{name:"arrow-up",size:9}),o.ahead]}),o.behind>0&&e.jsxs("span",{className:"flat-terminal-wrapper__branch-behind",title:`${o.behind} behind`,children:[e.jsx(m,{name:"arrow-down",size:9}),o.behind]}),e.jsx("span",{className:`flat-terminal-wrapper__area-fetch ${We?"flat-terminal-wrapper__area-fetch--fetching":""}`,title:"Git fetch",onClick:ke=>{ke.stopPropagation(),Ce(d)},children:e.jsx(m,{name:We?"hourglass":"download",size:12})})]})]},`${r}:${d}`)}),e.jsxs("span",{className:"flat-terminal-wrapper__context",onClick:()=>C.setContextModalAgentId(c),title:u?`Context usage: ${$e}k / ${Oe}k tokens (${V}% used). Click to view stats.`:"Click to fetch context stats",children:[e.jsx("span",{className:"flat-terminal-wrapper__context-icon",children:e.jsx(m,{name:"dashboard",size:12})}),e.jsx("span",{className:"flat-terminal-wrapper__context-label",children:"Ctx:"}),e.jsx("span",{className:"flat-terminal-wrapper__context-bar",children:e.jsx("span",{className:"flat-terminal-wrapper__context-bar-fill",style:{width:`${V}%`,backgroundColor:ze}})}),e.jsxs("span",{className:"flat-terminal-wrapper__context-tokens",style:{color:ze},children:[$e,"k/",Oe,"k"]}),e.jsxs("span",{className:"flat-terminal-wrapper__context-free",children:["(",st,"% free)"]}),!u&&e.jsx("span",{className:"flat-terminal-wrapper__context-warning",title:"No context stats yet",children:e.jsx(m,{name:"warn",size:12})})]}),e.jsx("div",{className:"flat-terminal-wrapper__statusbar-spacer","aria-hidden":"true"}),F.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area terminals",children:F.map(r=>{const i=k===r.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${i?"flat-terminal-wrapper__building-btn--active":""} ${r.hasUrl?"":"flat-terminal-wrapper__building-btn--offline"}`,title:`${i?"Hide":"Show"} terminal: ${r.name}${r.hasUrl?"":" (starting...)"}`,onClick:()=>{if(i){W(null);return}r.hasUrl||C.sendBuildingCommand(r.id,"start"),W(r.id)},children:e.jsx(m,{name:"terminal",size:14})},r.id)})}),ue.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area PM2 logs",children:ue.map(r=>e.jsx("button",{type:"button",className:"flat-terminal-wrapper__building-btn",title:`Open logs: ${r.name}`,onClick:()=>_e(r.id),children:e.jsx(m,{name:"scroll",size:14})},r.id))}),Re.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area databases",children:Re.map(r=>e.jsx("button",{type:"button",className:"flat-terminal-wrapper__building-btn",title:`Open database: ${r.name}`,onClick:()=>_e(r.id),children:e.jsx(m,{name:"hard-drives",size:14})},r.id))}),e.jsx("div",{className:"flat-terminal-wrapper__theme",children:e.jsx(ua,{})})]}),ae&&e.jsx(pa,{agentId:c,agents:nt,onClose:tt,branchInfoMap:Pe,fetchRemote:Ce,fetchingDirs:je}),$&&e.jsx(ma,{agentId:c,onClose:at}),ne&&e.jsx(fa,{agentId:c,onClose:Le})]})});function Ma({onAgentClick:x,onBuildingClick:c,onBuildingDoubleClick:v,onOpenSpawnModal:y,onOpenBossSpawnModal:D,onOpenAreaModal:ie}){const{t:L}=Dt(["common"]),S=Lt(),ge=zt(),[xe,Se]=n.useState(null),[_e,Me]=n.useState(null),[be,ye]=n.useState(null),[T,oe]=n.useState(null),[z,Ee]=n.useState(null),[p,P]=n.useState(!1),ce=n.useCallback(()=>{P(t=>!t)},[]),Te=n.useCallback(()=>{P(!1)},[]),[we,de]=n.useState(()=>{const t=xt(j.VIEW_MODE);return t==="simple"||t==="chat"||t==="advanced"?t:"simple"}),Pe=n.useCallback(t=>{de(t),_t(j.VIEW_MODE,t)},[]);n.useEffect(()=>{const t=a=>{if(a.key!==j.VIEW_MODE)return;const s=a.newValue;(s==="simple"||s==="chat"||s==="advanced")&&de(s)};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)},[]);const[Ce,je]=n.useState(()=>dt(j.FLAT_INSPECTOR_OPEN,!1)),[F,ue]=n.useState(!1),Re=n.useCallback(()=>ue(t=>!t),[]),Ye=n.useCallback(()=>ue(!1),[]),B=n.useRef(null),te=n.useRef(null),[X,q]=n.useState(()=>{const t=bt(j.FLAT_MIDDLE_WIDTH,0);return t>=Ke?t:null}),[k,W]=n.useState(()=>{const t=bt(j.FLAT_INSPECTOR_WIDTH,0);return t>=ct?t:null}),M=n.useCallback(t=>{if(typeof window>"u")return t;const a=k!==null?qe+k:0,s=window.innerWidth-Ct-qe-wt-a;return Math.max(Ke,Math.min(Math.max(s,Ke),t))},[k]),K=n.useCallback(t=>{var f;if(typeof window>"u")return t;const a=(f=B.current)==null?void 0:f.querySelector(".flat-middle"),s=(a==null?void 0:a.getBoundingClientRect().width)??Ke,l=window.innerWidth-Ct-s-qe-wt-qe;return Math.max(ct,Math.min(Math.max(l,ct),t))},[]);n.useEffect(()=>{if(X===null&&k===null)return;const t=()=>{q(a=>{if(a===null)return a;const s=M(a);return s===a?a:s}),W(a=>{if(a===null)return a;const s=K(a);return s===a?a:s})};return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[X,k,M,K]);const Ze=n.useCallback(t=>{var s;if(t.button!==0)return;const a=(s=B.current)==null?void 0:s.querySelector(".flat-middle");a&&(t.currentTarget.setPointerCapture(t.pointerId),te.current={kind:"middle",startX:t.clientX,startWidth:a.getBoundingClientRect().width,pointerId:t.pointerId},document.body.classList.add("flat-splitter-dragging"))},[]),ae=n.useCallback(t=>{var s;if(t.button!==0)return;const a=(s=B.current)==null?void 0:s.querySelector(".flat-inspector");a&&(t.currentTarget.setPointerCapture(t.pointerId),te.current={kind:"inspector",startX:t.clientX,startWidth:a.getBoundingClientRect().width,pointerId:t.pointerId},document.body.classList.add("flat-splitter-dragging"))},[]),ve=n.useCallback(t=>{const a=te.current;if(!a||t.pointerId!==a.pointerId)return;const s=t.clientX-a.startX;a.kind==="middle"?q(M(a.startWidth+s)):W(K(a.startWidth-s))},[M,K]),$=n.useCallback(t=>{const a=te.current;if(!a||t.pointerId!==a.pointerId)return;try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}if(te.current=null,document.body.classList.remove("flat-splitter-dragging"),!(Math.abs(t.clientX-a.startX)>2))return;const l=t.clientX-a.startX;if(a.kind==="middle"){const f=M(a.startWidth+l);q(f),Xe(j.FLAT_MIDDLE_WIDTH,f)}else{const f=K(a.startWidth-l);W(f),Xe(j.FLAT_INSPECTOR_WIDTH,f)}},[M,K]),De=n.useCallback(()=>{q(null),Xe(j.FLAT_MIDDLE_WIDTH,0)},[]),ne=n.useCallback(()=>{W(null),Xe(j.FLAT_INSPECTOR_WIDTH,0)},[]),[Y,Je]=n.useState(()=>xt(j.FLAT_INSPECTOR_VIEW)==="tracking"?"tracking":"agent"),Le=n.useCallback(t=>{Je(t),_t(j.FLAT_INSPECTOR_VIEW,t)},[]),Qe=n.useCallback(()=>{je(t=>{const a=!t;return he(j.FLAT_INSPECTOR_OPEN,a),a})},[]),et=n.useCallback(()=>{je(!1),he(j.FLAT_INSPECTOR_OPEN,!1)},[]),tt=$t(),at=n.useCallback((t,a)=>{Se({url:t,name:a})},[]),nt=n.useCallback((t,a)=>{Me({command:t,output:a,isLive:!1})},[]),se=n.useCallback((t,a)=>{C.setFileViewerPath(t,a)},[]),Z=n.useCallback(t=>{},[]),Ne=n.useCallback((t,a)=>{ye({agentId:t,count:a})},[]),H=n.useCallback(t=>{v?v(t):c(t)},[c,v]),u=n.useMemo(()=>ge.size>0?Array.from(ge)[0]:null,[ge]);n.useEffect(()=>{P(!1)},[u]);const G=n.useRef([]),R=n.useRef(-1),pe=n.useRef(!1),V=n.useRef(null),[st,ze]=n.useState(!1),[$e,Oe]=n.useState(!1),U=n.useRef(!1),J=n.useRef(null),Q=n.useRef(!1),ee=n.useMemo(()=>new Set(S.map(t=>t.id)),[S]),Fe=n.useMemo(()=>{const t=new Map(S.map(s=>[s.id,s])),a=new Map;for(const s of S)if((s.isBoss||s.class==="boss")&&s.subordinateIds&&s.subordinateIds.length>0){const l=s.subordinateIds.map(f=>t.get(f)).filter(f=>f!==void 0);l.length>0&&a.set(s.id,l)}return a},[S]),E=n.useCallback(()=>{const t=G.current,a=R.current;ze(a>0),Oe(a>=0&&a<t.length-1)},[]),re=n.useCallback(t=>{const a=G.current;if(a.length===0)return;let s=R.current+t;for(;s>=0&&s<a.length;){const l=a[s];if(ee.has(l)){pe.current=!0,R.current=s,E(),C.selectAgent(l);return}s+=t}},[ee,E]),Be=n.useCallback(()=>re(-1),[re]),r=n.useCallback(()=>re(1),[re]),i=n.useCallback((t,a)=>{if(typeof window>"u")return;const s=window.history.state,f={...typeof s=="object"&&s!==null?s:{},__flatAgentNav:{agentId:t}};a==="replace"?window.history.replaceState(f,"",window.location.href):window.history.pushState(f,"",window.location.href)},[]);n.useEffect(()=>{if(!u){U.current=!1,J.current=null;return}if(!U.current){i(u,"replace"),U.current=!0,J.current=u;return}if(Q.current){Q.current=!1,J.current=u;return}J.current!==u&&(i(u,"push"),J.current=u)},[u,i]),n.useEffect(()=>{const t=a=>{var w,h;const s=(h=(w=a.state)==null?void 0:w.__flatAgentNav)==null?void 0:h.agentId;if(!s||typeof s!="string"||!ee.has(s)||s===u)return;Q.current=!0,pe.current=!0;const l=G.current,f=l.lastIndexOf(s);f>=0?R.current=f:(l.push(s),R.current=l.length-1),E(),C.selectAgent(s)};return window.addEventListener("popstate",t),()=>window.removeEventListener("popstate",t)},[ee,u,E]),n.useEffect(()=>{if(!u){G.current=[],R.current=-1,E();return}if(V.current=u,pe.current){pe.current=!1,E();return}const t=G.current,a=R.current;if(a>=0&&t[a]===u){E();return}const s=a<t.length-1?t.slice(0,a+1):t.slice();s.push(u),s.length>100&&s.shift(),G.current=s,R.current=s.length-1,E()},[u,E]);const d=n.useCallback(t=>{x(t),ue(!1)},[x]),o=u??"",We=n.useCallback(()=>{},[]),rt=n.useCallback(t=>{d(t)},[d]),ke=Ce,ut=n.useRef(null);n.useEffect(()=>{if(u)return;const t=a=>{if(a.key!==" "&&a.key!=="Backspace")return;const s=a.target;if(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable)return;const l=V.current;!l||!ee.has(l)||(a.preventDefault(),C.selectAgent(l))};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[u,ee]);const[At,pt]=n.useState(new Set),It=n.useCallback(t=>{pt(a=>{const s=new Set(a);return s.has(t)?s.delete(t):s.add(t),s})},[]),mt=vt(),[St]=Ot(),me=n.useMemo(()=>{const t=new Map,a=[];for(const g of S){const b=C.getAreaForAgent(g.id);if(!Ft((b==null?void 0:b.id)??null))continue;if(!b||b.archived){a.push(g);continue}const O=t.get(b.id);O?O.push(g):t.set(b.id,[g])}const s=[];for(const[,g]of mt){if(g.archived||!Bt(g.id))continue;const b=t.get(g.id);b&&b.length>0&&s.push({area:g,agents:b})}a.length>0&&s.push({area:{id:"__unassigned__",name:"Unassigned",color:"#6272a4",center:{x:0,z:0},type:"circle",radius:0,directories:[],archived:!1,assignedAgentIds:[],zIndex:0},agents:a});const l=s.filter(g=>g.area.id!=="__unassigned__"),f=s.filter(g=>g.area.id==="__unassigned__");let w=1,h=1;const Ae=new Map;if(l.length>1){let g=1/0,b=-1/0,O=1/0,fe=-1/0;for(const A of l)g=Math.min(g,A.area.center.x),b=Math.max(b,A.area.center.x),O=Math.min(O,A.area.center.z),fe=Math.max(fe,A.area.center.z);const Ge=b-g||1,Ve=fe-O||1;if(l.length<=4){w=l.length,h=1;const A=[...l].sort((I,lt)=>I.area.center.x-lt.area.center.x);for(let I=0;I<A.length;I++)Ae.set(A[I].area.id,{row:1,col:I+1})}else{const A=[...l].sort((_,N)=>_.area.center.x-N.area.center.x),I=[];for(let _=1;_<A.length;_++)I.push(A[_].area.center.x-A[_-1].area.center.x);const lt=I.reduce((_,N)=>_+N,0)/I.length||1;let ft=1;for(const _ of I)_>lt*1.3&&ft++;w=Math.max(2,Math.min(ft,l.length));const it=[...l].sort((_,N)=>_.area.center.z-N.area.center.z),Ue=[];for(let _=1;_<it.length;_++)Ue.push(it[_].area.center.z-it[_-1].area.center.z);const Et=Ue.reduce((_,N)=>_+N,0)/Ue.length||1;let ht=1;for(const _ of Ue)_>Et*1.3&&ht++;h=Math.max(2,Math.min(ht,l.length)),w=Math.max(w,Math.ceil(l.length/h)),h=Math.max(h,Math.ceil(l.length/w));const Tt=Ge/w,Pt=Ve/h,ot=new Set;for(const _ of l){let N=Math.min(w-1,Math.max(0,Math.floor((_.area.center.x-g)/Tt))),le=Math.min(h-1,Math.max(0,Math.floor((_.area.center.z-O)/Pt))),Ie=`${le},${N}`,gt=0;const Rt=h*w;for(;ot.has(Ie)&&gt<Rt;)N++,N>=w&&(N=0,le=(le+1)%h),Ie=`${le},${N}`,gt++;ot.has(Ie)&&(le=h,N=0,Ie=`${le},${N}`,h++),ot.add(Ie),Ae.set(_.area.id,{row:le+1,col:N+1})}}}const He=g=>{g.sort((b,O)=>{var Ge,Ve,A,I;const fe=(((Ge=b.position)==null?void 0:Ge.z)??0)-(((Ve=O.position)==null?void 0:Ve.z)??0);return fe!==0?fe:(((A=b.position)==null?void 0:A.x)??0)-(((I=O.position)==null?void 0:I.x)??0)})};for(const g of l)He(g.agents);for(const g of f)He(g.agents);return{groups:[...l,...f],gridCols:w,gridRows:h,positions:Ae}},[S,mt,St]),Mt=n.useMemo(()=>{if(!T)return[];const t=S.find(a=>a.id===T.agentId);return t?[{id:"edit-agent",label:"Edit Agent",icon:e.jsx(m,{name:"edit",size:14}),onClick:()=>{window.dispatchEvent(new CustomEvent("tide:open-agent-edit",{detail:{agentId:t.id}}))}},{id:"open-chat",label:"Open Chat",icon:e.jsx(m,{name:"chat",size:14}),onClick:()=>x(t.id)},{id:"delete-agent",label:"Delete Agent",icon:e.jsx(m,{name:"trash",size:14}),danger:!0,onClick:()=>{Ee({agentId:t.id,name:t.name})}}]:[]},[T,S,x]),yt=n.useCallback(t=>{const a=new Set(me.groups.map(s=>s.area.id));a.delete(t),pt(a),requestAnimationFrame(()=>{const s=ut.current;if(!s)return;const l=s.querySelector(`[data-area-id="${t}"]`);if(!l)return;const f=s.getBoundingClientRect(),h=l.getBoundingClientRect().top-f.top+s.scrollTop-8;s.scrollTo({top:Math.max(0,h),behavior:"smooth"})})},[me]);return e.jsxs("div",{ref:B,className:`flat-view ${ke?"flat-view--with-inspector":""} ${u?"flat-view--has-chat":""} ${F?"flat-view--mobile-sidebar-open":""}`,style:(()=>{if(X===null&&k===null)return;const t={};return X!==null&&(t["--flat-middle-width"]=`${X}px`),k!==null&&(t["--flat-inspector-width"]=`${k}px`),t})(),children:[F&&e.jsx("div",{className:"flat-mobile-sidebar-backdrop",onClick:Ye,"aria-hidden":"true"}),e.jsxs("div",{className:"flat-middle",children:[e.jsxs("div",{className:"flat-middle__header",children:[e.jsx("h2",{className:"flat-middle__title",children:"👥 Agents"}),e.jsxs("div",{className:"flat-middle__actions",children:[e.jsx("button",{className:"flat-cta-btn flat-cta-btn--agent",onClick:y,title:"Create new agent",children:"+ Agent"}),e.jsx("button",{className:"flat-cta-btn flat-cta-btn--boss",onClick:D,title:"Create new boss agent",children:"+ Boss"}),e.jsx("button",{className:"flat-cta-btn flat-cta-btn--area",onClick:ie,title:"Create new area",children:"+ Area"})]})]}),e.jsx("div",{className:"flat-middle__content",children:e.jsx(Wt,{activeAgentId:o,onClose:We,onSelectAgent:rt,collapsedAreas:At,onToggleArea:It,agentListRef:ut})})]}),e.jsx("div",{className:"flat-splitter flat-splitter--middle",role:"separator","aria-orientation":"vertical","aria-label":"Resize agents panel",title:"Drag to resize · Double-click to reset",onPointerDown:Ze,onPointerMove:ve,onPointerUp:$,onPointerCancel:$,onDoubleClick:De}),e.jsxs("div",{className:"flat-right",children:[e.jsxs("button",{type:"button",className:"flat-mobile-sidebar-toggle","aria-label":F?"Close agents sidebar":"Open agents sidebar","aria-expanded":F,onClick:Re,children:[e.jsx(m,{name:"list",size:18}),e.jsx("span",{className:"flat-mobile-sidebar-toggle__label",children:"Agents"})]}),u?e.jsx(ka,{agentId:u,terminalViewMode:we,onTerminalViewModeChange:Pe,inspectorOpen:Ce,onToggleInspector:Qe,onImageClick:at,onFileClick:se,onBashClick:nt,onViewMarkdown:Z,onRequestClearSubordinates:Ne,onOpenBuilding:H,keyboard:tt,canNavigateBack:st,canNavigateForward:$e,onNavigateBack:Be,onNavigateForward:r,agentInfoOpen:p,onToggleAgentInfo:ce}):e.jsx("div",{className:"flat-chat flat-chat--empty",children:e.jsxs("div",{className:"flat-map",children:[e.jsxs("div",{className:"flat-map__header",children:[e.jsx("span",{className:"flat-map__title",children:"🗺️ Areas"}),e.jsx("span",{className:"flat-map__hint",children:"Click an area to focus it, or an agent to chat"})]}),e.jsx("div",{className:"flat-map__grid",style:{gridTemplateColumns:`repeat(${me.gridCols}, 1fr)`},children:me.groups.length===0?e.jsx("div",{className:"flat-map__empty",children:e.jsx("span",{children:"No areas or agents yet"})}):me.groups.map(t=>{const a=t.area.id,s=me.positions.get(a);return e.jsxs("div",{className:"flat-map-area-card",style:{"--area-color":t.area.color,gridRow:s==null?void 0:s.row,gridColumn:s==null?void 0:s.col},children:[e.jsxs("button",{type:"button",className:"flat-map-area-card__header",onClick:()=>yt(a),title:`Focus ${t.area.name} in left panel`,children:[e.jsx("span",{className:"flat-map-area-card__color",style:{background:t.area.color}}),e.jsx("span",{className:"flat-map-area-card__name",children:t.area.name}),e.jsx("span",{className:"flat-map-area-card__count",children:t.agents.length})]}),e.jsx("div",{className:"flat-map-area-card__agents",children:t.agents.map(l=>{const f=l.isBoss||l.class==="boss",w=f?Fe.get(l.id):void 0,h=Ht(l),Ae=h.usedPercent>=80?"#ff4a4a":h.usedPercent>=60?"#ff9e4a":h.usedPercent>=40?"#ffd700":"#4aff9e",He=`Context: ${(h.totalTokens/1e3).toFixed(1)}k / ${(h.contextWindow/1e3).toFixed(1)}k (${h.usedPercent}% used, ${h.freePercent}% free)`,g=l.latestTodos&&l.latestTodos.length>0||w&&w.length>0;return e.jsx(Gt,{todos:l.latestTodos,subordinates:w,position:"top",children:e.jsxs("button",{type:"button",className:`flat-map-agent-chip ${l.status}`,onClick:()=>x(l.id),onContextMenu:b=>{b.preventDefault(),b.stopPropagation(),oe({agentId:l.id,position:{x:b.clientX,y:b.clientY}})},title:g?void 0:`${f?"Boss · ":""}Open chat with ${l.name}
2
+ ${He}`,children:[e.jsx(Nt,{agent:l,size:16}),f&&e.jsx("span",{className:"flat-map-agent-chip__crown","aria-hidden":"true",children:e.jsx(m,{name:"crown",size:11,color:"#ffd700",weight:"fill"})}),e.jsx("span",{className:"flat-map-agent-chip__name",children:l.name}),e.jsx("img",{src:l.provider==="codex"?"/assets/codex.png":l.provider==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:l.provider,className:"flat-map-agent-chip__provider-icon",title:l.provider==="codex"?"Codex Agent":l.provider==="opencode"?"OpenCode Agent":"Claude Agent"}),e.jsx("span",{className:"flat-map-agent-chip__dot",style:{backgroundColor:kt(l.status)}}),l.latestTodos&&l.latestTodos.length>0&&e.jsx(Vt,{todos:l.latestTodos,maxDots:6}),f&&w&&w.length>0&&e.jsx(Ut,{subordinates:w,maxDots:6}),e.jsx("span",{className:"flat-map-agent-chip__context-bar","aria-hidden":"true",children:e.jsx("span",{className:"flat-map-agent-chip__context-bar-fill",style:{width:`${h.usedPercent}%`,backgroundColor:Ae}})})]})},l.id)})})]},a)})})]})})]}),ke&&e.jsx("div",{className:"flat-splitter flat-splitter--inspector",role:"separator","aria-orientation":"vertical","aria-label":"Resize inspector panel",title:"Drag to resize · Double-click to reset",onPointerDown:ae,onPointerMove:ve,onPointerUp:$,onPointerCancel:$,onDoubleClick:ne}),ke&&e.jsxs("aside",{className:"flat-inspector","aria-label":"Inspector panel",children:[e.jsxs("div",{className:"flat-inspector__header",children:[e.jsxs("div",{className:"flat-inspector__tabs",role:"tablist","aria-label":"Inspector view",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":Y==="agent",className:`flat-inspector__tab ${Y==="agent"?"flat-inspector__tab--active":""}`,onClick:()=>Le("agent"),children:"Agent"}),e.jsx("button",{type:"button",role:"tab","aria-selected":Y==="tracking",className:`flat-inspector__tab ${Y==="tracking"?"flat-inspector__tab--active":""}`,onClick:()=>Le("tracking"),children:"Tracking"})]}),e.jsx("button",{type:"button",className:"flat-inspector__close",onClick:et,title:"Close inspector","aria-label":"Close inspector",children:"✕"})]}),e.jsx("div",{className:"flat-inspector__body",children:Y==="tracking"?e.jsx(Xt,{activeAgentId:u??"",onSelectAgent:t=>x(t)}):(()=>{if(!u)return e.jsx("div",{className:"flat-inspector__empty",children:e.jsx("span",{children:"Select an agent to inspect"})});const t=S.find(a=>a.id===u);return t?e.jsx(qt,{agent:t,onFocusAgent:a=>x(a),onKillAgent:a=>C.killAgent(a)}):e.jsx("div",{className:"flat-inspector__empty",children:e.jsx("span",{children:"Agent not found"})})})()})]}),xe&&e.jsx(Kt,{url:xe.url,name:xe.name,onClose:()=>Se(null)}),_e&&e.jsx(Yt,{state:_e,onClose:()=>Me(null)}),be&&e.jsx(Zt,{action:"clear-subordinates",selectedAgentId:be.agentId,subordinateCount:be.count,onClose:()=>ye(null),onClearHistory:()=>{}}),e.jsx(Jt,{agent:u?S.find(t=>t.id===u)??null:null,isOpen:p&&!!u,onClose:Te}),e.jsx(Qt,{isOpen:T!==null,position:(T==null?void 0:T.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:Mt,onClose:()=>oe(null)}),e.jsx(ea,{isOpen:z!==null,title:L("common:confirm.removeAgentTitle"),message:L("common:confirm.removeAgentMessage",{name:(z==null?void 0:z.name)??""}),confirmLabel:L("common:buttons.remove"),cancelLabel:L("common:buttons.cancel"),variant:"danger",onConfirm:()=>{z&&C.removeAgentFromServer(z.agentId)},onClose:()=>Ee(null)})]})}export{Ma as FlatView};
@@ -1 +1 @@
1
- import{r as d,aO as re,aP as ke,j as e,I as P,u as G,aQ as Ce,as as Ae,f as pe,s as v,aR as _e,k as Be,l as J,aS as U,aT as De,aH as Re,aU as Ue,C as ge,aV as M,aE as oe,aW as Ve,aX as Ke,aY as qe,aZ as Me,a_ as Ge,aA as He,E as We,S as ne,a$ as Ye,b0 as Je,aC as Ze,b1 as de,G as ie,aL as Xe,b2 as me,b3 as Qe}from"./main-BvvvhWnd.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const he="deivid11/tide-commander",es=`https://api.github.com/repos/${he}/releases/latest`,ss=`https://api.github.com/repos/${he}/releases?per_page=3`,ts=3600*1e3,we="app_update_dismissed_version",Se="1.76.2";function as(){var k,C;const[s,i]=d.useState({isChecking:!1,updateAvailable:!1,updateInfo:null,recentReleases:[],error:null,currentVersion:Se}),n=((C=(k=re)==null?void 0:k.getPlatform)==null?void 0:C.call(k))==="android"||!1,o=r=>r.replace(/^v/,"").split(".").map(x=>parseInt(x,10)||0),m=(r,g)=>{const x=o(r),S=o(g),y=Math.max(x.length,S.length);for(let c=0;c<y;c++){const L=x[c]||0,R=S[c]||0;if(L>R)return 1;if(L<R)return-1}return 0},p=async r=>{var x,S;if(re&&ke&&((S=(x=re).isNativePlatform)==null?void 0:S.call(x))===!0){const y=await ke.get({url:r,headers:{Accept:"application/vnd.github.v3+json"}});return{data:y.data,status:y.status}}else{const y=await fetch(r,{headers:{Accept:"application/vnd.github.v3+json"}});return y.ok?{data:await y.json(),status:y.status}:{data:null,status:y.status}}},l=d.useCallback(async(r=!1)=>{i(g=>({...g,isChecking:!0,error:null}));try{const[g,x]=await Promise.all([p(es),p(ss)]);if(g.status!==200)throw new Error(`GitHub API error: ${g.status}`);const S=g.data,y=S.tag_name;let c=[];x.status===200&&x.data&&(c=x.data.map(w=>({version:w.tag_name,name:w.name,publishedAt:w.published_at,releaseUrl:w.html_url})));const L=localStorage.getItem(we);if(!r&&L===y)return i(w=>({...w,isChecking:!1,updateAvailable:!1,recentReleases:c})),null;if(!(m(y,Se)>0))return i(w=>({...w,isChecking:!1,updateAvailable:!1,recentReleases:c})),null;const $=S.assets.find(w=>w.name.endsWith(".apk")&&w.content_type==="application/vnd.android.package-archive"),b={version:y,name:S.name,changelog:S.body,releaseUrl:S.html_url,apkUrl:($==null?void 0:$.browser_download_url)||null,apkSize:($==null?void 0:$.size)||null,publishedAt:S.published_at};return i(w=>({...w,isChecking:!1,updateAvailable:!0,updateInfo:b,recentReleases:c})),b}catch(g){const x=g instanceof Error?g.message:"Failed to check for updates";return i(S=>({...S,isChecking:!1,error:x})),null}},[]),a=d.useCallback(async()=>{var r,g,x;if(!((r=s.updateInfo)!=null&&r.apkUrl)){(g=s.updateInfo)!=null&&g.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}if(!n){(x=s.updateInfo)!=null&&x.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}try{window.open(s.updateInfo.apkUrl,"_system"),i(S=>({...S,error:null}))}catch(S){const y=S instanceof Error?S.message:"Failed to open download";i(c=>({...c,error:y}))}},[s.updateInfo,n]),u=d.useCallback(()=>{s.updateInfo&&localStorage.setItem(we,s.updateInfo.version),i(r=>({...r,updateAvailable:!1,updateInfo:null}))},[s.updateInfo]),A=d.useCallback(()=>{var r;(r=s.updateInfo)!=null&&r.releaseUrl?window.open(s.updateInfo.releaseUrl,"_blank"):window.open(`https://github.com/${he}/releases`,"_blank")},[s.updateInfo]);return d.useEffect(()=>{if(!n)return;const r=setTimeout(()=>{l()},5e3),g=setInterval(()=>{l()},ts);return()=>{clearTimeout(r),clearInterval(g)}},[n,l]),{...s,isAndroid:n,checkForUpdate:l,downloadAndInstall:a,dismissUpdate:u,openReleasePage:A}}const Te="tide-toolbox-collapse";function ns(s,i){try{const n=localStorage.getItem(`${Te}-${s}`);if(n!==null)return n==="true"}catch{}return i}function os(s,i){try{localStorage.setItem(`${Te}-${s}`,String(i))}catch{}}function O({title:s,storageKey:i,defaultOpen:n=!1,forceOpen:o=!1,children:m,headerExtra:p}){const[l,a]=d.useState(()=>i?ns(i,n):n),u=()=>{const k=!l;a(k),i&&os(i,k)},A=o||l;return e.jsxs("div",{className:`collapsible-section ${A?"open":"collapsed"}`,children:[e.jsxs("button",{className:"collapsible-header",onClick:u,children:[e.jsx("span",{className:"collapsible-title",children:s}),e.jsxs("span",{className:"collapsible-header-right",children:[p,e.jsx("span",{className:"collapsible-arrow",children:e.jsx(P,{name:A?"caret-down":"caret-right",size:10})})]})]}),A&&e.jsx("div",{className:"collapsible-content",children:m})]})}function is({area:s,isSelected:i,onClick:n,onDelete:o}){const{t:m}=G(["config","common"]),p=s.assignedAgentIds.length,l=s.type==="rectangle"?m("config:areas.rect"):m("config:areas.circle");return e.jsxs("div",{className:`area-item ${i?"selected":""}`,onClick:n,children:[e.jsx("div",{className:"area-color-dot",style:{backgroundColor:s.color}}),e.jsxs("div",{className:"area-info",children:[e.jsx("div",{className:"area-name",children:s.name}),e.jsxs("div",{className:"area-meta",children:[l," ",p>0&&`• ${p} ${p>1?m("common:labels.agents").toLowerCase():m("common:labels.agent").toLowerCase()}`]})]}),e.jsx("button",{className:"area-delete-btn",onClick:o,title:m("config:areas.deleteArea"),children:"×"})]})}function ls({building:s,isSelected:i,onClick:n,onEdit:o}){var a;const{t:m}=G(["config"]),p=((a=s.pm2Status)==null?void 0:a.ports)||[],l=(u,A)=>{u.stopPropagation(),window.open(`http://localhost:${A}`,"_blank")};return e.jsxs("div",{className:`building-item ${i?"selected":""}`,onClick:n,children:[e.jsx("div",{className:"building-status-dot",style:{backgroundColor:Ce[s.status]},title:s.status}),e.jsx("div",{className:"building-icon",children:e.jsx(P,{name:Ae(s.type),size:16})}),e.jsxs("div",{className:"building-info",children:[e.jsx("div",{className:"building-name",children:s.name}),e.jsxs("div",{className:"building-meta",children:[s.type,p.length>0&&e.jsx("span",{className:"building-ports",children:p.map(u=>e.jsxs("a",{href:`http://localhost:${u}`,className:"building-port-link",onClick:A=>l(A,u),title:`Open :${u}`,children:[":",u]},u))})]})]}),e.jsx("button",{className:"building-edit-btn",onClick:u=>{u.stopPropagation(),o()},title:m("config:buildings.editBuilding"),children:e.jsx(P,{name:"gear",size:14})})]})}function cs({building:s,onClose:i,onOpenModal:n}){var A,k,C,r,g,x,S,y;const{t:o}=G(["config","common"]),{buildingLogs:m}=pe(),p=v.getBuildingLogs(s.id),l=_e[s.style||"server-rack"],a=c=>{v.sendBuildingCommand(s.id,c)},u=c=>{window.open(c,"_blank")};return e.jsxs("div",{className:"building-editor",children:[e.jsxs("div",{className:"building-editor-header",children:[e.jsxs("div",{className:"building-editor-title-row",children:[e.jsx("span",{className:"building-editor-icon",children:e.jsx(P,{name:Ae(s.type),size:18})}),e.jsx("span",{className:"building-editor-title",children:s.name}),e.jsx("span",{className:"building-editor-status",style:{backgroundColor:Ce[s.status]},children:s.status})]}),e.jsx("button",{className:"building-editor-close",onClick:i,children:"×"})]}),e.jsx("div",{className:"building-editor-section",children:e.jsxs("div",{className:"building-editor-info-grid",children:[e.jsxs("div",{className:"building-editor-info-item",children:[e.jsx("span",{className:"building-editor-info-label",children:o("common:labels.type")}),e.jsx("span",{className:"building-editor-info-value",children:s.type})]}),e.jsxs("div",{className:"building-editor-info-item",children:[e.jsx("span",{className:"building-editor-info-label",children:o("config:buildings.style")}),e.jsx("span",{className:"building-editor-info-value",children:l.label})]}),s.cwd&&e.jsxs("div",{className:"building-editor-info-item building-editor-info-wide",children:[e.jsx("span",{className:"building-editor-info-label",children:o("config:buildings.directory")}),e.jsx("span",{className:"building-editor-info-value building-editor-cwd",title:s.cwd,children:s.cwd.split("/").pop()||s.cwd})]})]})}),s.type==="server"&&e.jsxs("div",{className:"building-editor-section",children:[e.jsx("div",{className:"building-editor-section-title",children:o("config:buildings.actions")}),e.jsxs("div",{className:"building-editor-actions",children:[e.jsxs("button",{className:"building-editor-action-btn start",onClick:()=>a("start"),disabled:!((A=s.commands)!=null&&A.start)||s.status==="running",title:((k=s.commands)==null?void 0:k.start)||o("config:buildings.noStartCommand"),children:[e.jsx(P,{name:"play",size:12})," ",o("common:buttons.start")]}),e.jsxs("button",{className:"building-editor-action-btn stop",onClick:()=>a("stop"),disabled:!((C=s.commands)!=null&&C.stop)||s.status==="stopped",title:((r=s.commands)==null?void 0:r.stop)||o("config:buildings.noStopCommand"),children:[e.jsx(P,{name:"stop",size:12,weight:"fill"})," ",o("common:buttons.stop")]}),e.jsxs("button",{className:"building-editor-action-btn restart",onClick:()=>a("restart"),disabled:!((g=s.commands)!=null&&g.restart),title:((x=s.commands)==null?void 0:x.restart)||o("config:buildings.noRestartCommand"),children:[e.jsx(P,{name:"refresh",size:12})," ",o("common:buttons.retry")]}),e.jsxs("button",{className:"building-editor-action-btn health",onClick:()=>a("healthCheck"),disabled:!((S=s.commands)!=null&&S.healthCheck),title:((y=s.commands)==null?void 0:y.healthCheck)||o("config:buildings.noHealthCheck"),children:[e.jsx(P,{name:"heart",size:12})," Health"]})]})]}),s.urls&&s.urls.length>0&&e.jsxs("div",{className:"building-editor-section",children:[e.jsx("div",{className:"building-editor-section-title",children:o("config:buildings.links")}),e.jsx("div",{className:"building-editor-links",children:s.urls.map((c,L)=>e.jsxs("button",{className:"building-editor-link",onClick:()=>u(c.url),title:c.url,children:[e.jsx(P,{name:"link",size:12})," ",c.label||c.url]},L))})]}),p.length>0&&e.jsxs("div",{className:"building-editor-section",children:[e.jsxs("div",{className:"building-editor-section-title",children:[o("config:buildings.recentLogs"),e.jsx("button",{className:"building-editor-clear-logs",onClick:()=>v.clearBuildingLogs(s.id),title:o("common:buttons.clear"),children:o("common:buttons.clear")})]}),e.jsx("div",{className:"building-editor-logs",children:p.slice(-5).map((c,L)=>e.jsx("div",{className:"building-editor-log-entry",children:c},L))})]}),e.jsx("div",{className:"building-editor-footer",children:e.jsxs("button",{className:"building-editor-edit-btn",onClick:n,children:[e.jsx(P,{name:"gear",size:12})," ",o("config:buildings.fullSettings")]})})]})}async function rs(s,i){const n=U(),o=await fetch(J(`/api/areas/${s}/logo`),{method:"POST",headers:{"Content-Type":i.type||"image/png","X-Filename":encodeURIComponent(i.name),...n?{Authorization:`Bearer ${n}`}:{}},body:i});if(!o.ok){const m=await o.json().catch(()=>({error:o.statusText}));throw new Error(m.error||`Upload failed: ${o.statusText}`)}return o.json()}async function ds(s){const i=U(),n=await fetch(J(`/api/areas/${s}/logo`),{method:"DELETE",headers:{...i?{Authorization:`Bearer ${i}`}:{}}});if(!n.ok)throw new Error(`Failed to delete logo: ${n.statusText}`)}function ms(s){return Be(J(`/api/areas/logos/${s}`))}const us=[{key:"center",labelKey:"posCenter"},{key:"top-left",labelKey:"posTopLeft"},{key:"top-right",labelKey:"posTopRight"},{key:"bottom-left",labelKey:"posBottomLeft"},{key:"bottom-right",labelKey:"posBottomRight"}];function gs({area:s,onClose:i,onOpenFolder:n}){var Q;const{t:o}=G(["config","common"]),[m,p]=d.useState(s.name),[l,a]=d.useState(s.prompt||""),[u,A]=d.useState(!1),[k,C]=d.useState(""),[r,g]=d.useState(!1),x=d.useRef(null);d.useEffect(()=>{p(s.name)},[s.id,s.name]),d.useEffect(()=>{a(s.prompt||"")},[s.id,s.prompt]);const S=f=>{const T=f.target.value;p(T),v.updateArea(s.id,{name:T})},y=f=>{v.updateArea(s.id,{color:f})},c=f=>{const T=f.target.value;a(T),v.updateArea(s.id,{prompt:T})},L=()=>{k.trim()&&(v.addDirectoryToArea(s.id,k.trim()),C(""),A(!1))},R=(f,T)=>{T.stopPropagation(),v.removeDirectoryFromArea(s.id,f)},$=()=>{v.bringAreaToFront(s.id)},b=()=>{v.sendAreaToBack(s.id)},w=d.useCallback(()=>{let f=2,T=2;s.type==="rectangle"&&s.width&&s.height?(f=s.width,T=s.height):s.type==="circle"&&s.radius&&(f=s.radius*1.414,T=s.radius*1.414);const D=Math.min(f,T)*.4;return{width:Math.round(D*10)/10,height:Math.round(D*10)/10}},[s.type,s.width,s.height,s.radius]),Z=async f=>{var D;const T=(D=f.target.files)==null?void 0:D[0];if(T){g(!0);try{const h=await rs(s.id,T),E=w();v.updateArea(s.id,{logo:{filename:h.filename,position:"center",width:E.width,height:E.height,keepAspectRatio:!0,opacity:.8}})}catch(h){console.error("Failed to upload logo:",h)}finally{g(!1),x.current&&(x.current.value="")}}},H=async()=>{try{await ds(s.id),v.updateArea(s.id,{logo:void 0})}catch(f){console.error("Failed to remove logo:",f)}},K=f=>{s.logo&&v.updateArea(s.id,{logo:{...s.logo,position:f}})},X=f=>{if(!s.logo)return;const T=parseFloat(f.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.width>0){const D=s.logo.height/s.logo.width;v.updateArea(s.id,{logo:{...s.logo,width:T,height:Math.round(T*D*10)/10}})}else v.updateArea(s.id,{logo:{...s.logo,width:T}})},I=f=>{if(!s.logo)return;const T=parseFloat(f.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.height>0){const D=s.logo.width/s.logo.height;v.updateArea(s.id,{logo:{...s.logo,height:T,width:Math.round(T*D*10)/10}})}else v.updateArea(s.id,{logo:{...s.logo,height:T}})},W=()=>{s.logo&&v.updateArea(s.id,{logo:{...s.logo,keepAspectRatio:!s.logo.keepAspectRatio}})},te=f=>{s.logo&&v.updateArea(s.id,{logo:{...s.logo,opacity:parseFloat(f.target.value)}})};return e.jsxs("div",{className:"area-editor",children:[e.jsxs("div",{className:"area-editor-header",children:[e.jsx("span",{className:"area-editor-title",children:o("config:areas.editArea")}),e.jsx("button",{className:"area-editor-close",onClick:i,children:"×"})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("common:labels.name")}),e.jsx("input",{type:"text",className:"area-editor-input",value:m,onChange:S,placeholder:o("config:areas.areaName")})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.color")}),e.jsx("div",{className:"color-picker-row",children:De.map(f=>e.jsx("div",{className:`color-swatch ${s.color===f?"selected":""}`,style:{backgroundColor:f},onClick:()=>y(f)},f))})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.layer")}),e.jsxs("div",{className:"area-layer-buttons",children:[e.jsxs("button",{className:"area-layer-btn",onClick:$,title:o("config:areas.bringToFront"),children:[e.jsx(P,{name:"arrow-up",size:12})," ",o("config:areas.front")]}),e.jsxs("button",{className:"area-layer-btn",onClick:b,title:o("config:areas.sendToBack"),children:[e.jsx(P,{name:"arrow-down",size:12})," ",o("config:areas.back")]})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.logo")}),e.jsxs("div",{className:"area-logo-section",children:[(Q=s.logo)!=null&&Q.filename?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"area-logo-preview",children:[e.jsx("img",{src:ms(s.logo.filename),alt:"Logo",className:"area-logo-thumbnail"}),e.jsx("button",{className:"area-logo-remove-btn",onClick:H,children:o("config:areas.removeLogo")}),e.jsx("button",{className:"area-logo-replace-btn",onClick:()=>{var f;return(f=x.current)==null?void 0:f.click()},disabled:r,children:r?"...":e.jsx(P,{name:"refresh",size:12})})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoPosition")}),e.jsx("div",{className:"area-logo-position-row",children:us.map(({key:f,labelKey:T})=>{var D;return e.jsx("button",{className:`area-logo-pos-btn ${((D=s.logo)==null?void 0:D.position)===f?"active":""}`,onClick:()=>K(f),children:o(`config:areas.${T}`)},f)})})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoSize")}),e.jsxs("div",{className:"area-logo-size-row",children:[e.jsxs("label",{className:"area-logo-size-field",children:[e.jsx("span",{children:o("config:areas.logoWidth")}),e.jsx("input",{type:"number",className:"area-logo-size-input",value:s.logo.width,onChange:X,min:.1,step:.1})]}),e.jsxs("label",{className:"area-logo-size-field",children:[e.jsx("span",{children:o("config:areas.logoHeight")}),e.jsx("input",{type:"number",className:"area-logo-size-input",value:s.logo.height,onChange:I,min:.1,step:.1})]}),e.jsxs("label",{className:"area-logo-aspect-label",title:o("config:areas.keepAspectRatio"),children:[e.jsx("input",{type:"checkbox",checked:s.logo.keepAspectRatio,onChange:W}),o("config:areas.keepAspectRatio")]})]})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoOpacity")}),e.jsxs("div",{className:"area-logo-opacity-row",children:[e.jsx("input",{type:"range",min:0,max:1,step:.05,value:s.logo.opacity??.8,onChange:te,className:"area-logo-opacity-slider"}),e.jsxs("span",{className:"area-logo-opacity-value",children:[Math.round((s.logo.opacity??.8)*100),"%"]})]})]})]}):e.jsx("button",{className:"area-logo-upload-btn",onClick:()=>{var f;return(f=x.current)==null?void 0:f.click()},disabled:r,children:r?"...":o("config:areas.uploadLogo")}),e.jsx("input",{ref:x,type:"file",accept:"image/*",style:{display:"none"},onChange:Z})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.folders",{count:s.directories.length})}),e.jsxs("div",{className:"area-folders-list",children:[s.directories.map(f=>e.jsxs("div",{className:"area-folder-item",title:f,children:[e.jsx("span",{className:"area-folder-icon clickable",onClick:()=>n==null?void 0:n(s.id),title:o("config:areas.openFolder"),children:e.jsx(P,{name:"folder",size:14})}),e.jsx("span",{className:"area-folder-path",children:f.split("/").pop()||f}),e.jsx("button",{className:"area-folder-remove",onClick:T=>R(f,T),title:o("config:areas.removeFolder"),children:"×"})]},f)),u?e.jsxs("div",{className:"area-add-folder-inline",children:[e.jsx(Re,{value:k,onChange:C,onSubmit:L,placeholder:o("config:areas.folderPlaceholder"),className:"area-add-folder-input",directoriesOnly:!0,autoFocus:!0}),e.jsx("button",{className:"area-add-folder-confirm",onClick:L,children:"+"})]}):e.jsx("button",{className:"area-add-folder-btn",onClick:()=>A(!0),children:o("config:areas.addFolder")})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.prompt","Prompt")}),e.jsx("textarea",{className:"area-editor-input",value:l,onChange:c,placeholder:o("config:areas.promptPlaceholder","System prompt for agents in this area..."),rows:4,style:{resize:"vertical",fontFamily:"monospace",fontSize:12}}),e.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4},children:o("config:areas.promptHint","This prompt is injected into agents assigned to this area. Takes effect on next context refresh.")})]}),s.assignedAgentIds.length>0&&e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.assignedAgents",{count:s.assignedAgentIds.length})}),e.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:o("config:areas.rightClickUnassign")})]})]})}function ps(){const{t:s}=G(["config","common"]),i=Ue(),[n,o]=d.useState(!1),[m,p]=d.useState(null),[l,a]=d.useState({name:"",key:"",value:"",description:""}),[u,A]=d.useState(null),k=()=>{o(!0),p(null),a({name:"",key:"",value:"",description:""})},C=c=>{p(c.id),o(!1),a({name:c.name,key:c.key,value:c.value,description:c.description||""})},r=()=>{o(!1),p(null),a({name:"",key:"",value:"",description:""})},g=()=>{!l.name.trim()||!l.key.trim()||(m?v.updateSecret(m,{name:l.name.trim(),key:l.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:l.value,description:l.description.trim()||void 0}):v.createSecret({name:l.name.trim(),key:l.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:l.value,description:l.description.trim()||void 0}),r())},x=c=>{A(c)},S=()=>{u&&(v.deleteSecret(u),m===u&&r())},y=c=>{navigator.clipboard.writeText(`{{${c}}}`)};return e.jsxs("div",{className:"secrets-section",children:[e.jsx("div",{className:"secrets-description",children:s("config:secrets.description",{placeholder:"{{KEY}}"})}),e.jsx("div",{className:"secrets-list",children:i.length===0&&!n?e.jsx("div",{className:"secrets-empty",children:s("config:secrets.noSecrets")}):i.map(c=>e.jsxs("div",{className:`secret-item ${m===c.id?"editing":""}`,children:[e.jsxs("div",{className:"secret-item-header",children:[e.jsxs("div",{className:"secret-item-info",children:[e.jsx("span",{className:"secret-item-name",children:c.name}),e.jsx("code",{className:"secret-item-key",onClick:()=>y(c.key),title:s("config:secrets.copyPlaceholder"),children:`{{${c.key}}}`})]}),e.jsxs("div",{className:"secret-item-actions",children:[e.jsx("button",{className:"secret-item-btn edit",onClick:()=>C(c),title:s("common:buttons.edit"),children:e.jsx(P,{name:"edit",size:12})}),e.jsx("button",{className:"secret-item-btn delete",onClick:()=>x(c.id),title:s("common:buttons.delete"),children:"×"})]})]}),c.description&&e.jsx("div",{className:"secret-item-description",children:c.description})]},c.id))}),(n||m)&&e.jsxs("div",{className:"secret-form",children:[e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("common:labels.name")}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.namePlaceholder"),value:l.name,onChange:c=>a({...l,name:c.target.value}),autoFocus:!0})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:"Key"}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.keyPlaceholder"),value:l.key,onChange:c=>a({...l,key:c.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"")})}),e.jsx("span",{className:"secret-form-hint",children:s("config:secrets.usedAs",{placeholder:`{{${l.key||"KEY"}}}`})})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("config:secrets.secretValue")}),e.jsx("input",{type:"password",className:"secret-form-input",placeholder:s("config:secrets.valuePlaceholder"),value:l.value,onChange:c=>a({...l,value:c.target.value})})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("common:labels.description")}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.descriptionPlaceholder"),value:l.description,onChange:c=>a({...l,description:c.target.value})})]}),e.jsxs("div",{className:"secret-form-actions",children:[e.jsx("button",{className:"secret-form-btn cancel",onClick:r,children:s("common:buttons.cancel")}),e.jsx("button",{className:"secret-form-btn save",onClick:g,disabled:!l.name.trim()||!l.key.trim(),children:s(m?"config:secrets.update":"common:buttons.add")})]})]}),!n&&!m&&e.jsx("button",{className:"secrets-add-btn",onClick:k,children:s("config:secrets.addSecret")}),e.jsx(ge,{isOpen:u!==null,title:s("common:buttons.delete"),message:s("config:secrets.deleteConfirm"),confirmLabel:s("common:buttons.delete"),cancelLabel:s("common:buttons.cancel"),variant:"danger",onConfirm:S,onClose:()=>A(null)})]})}async function hs(){const s=U(),i=await fetch(`${M()}/api/agents/system-settings/prompt`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch system prompt: ${i.statusText}`);return(await i.json()).prompt||""}async function fs(s){const i=U(),n=await fetch(`${M()}/api/agents/system-settings/prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({prompt:s})});if(!n.ok)throw new Error(`Failed to update system prompt: ${n.statusText}`)}async function xs(){const s=U(),i=await fetch(`${M()}/api/agents/system-settings/prompt`,{method:"DELETE",headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to clear system prompt: ${i.statusText}`)}async function bs(){const s=U(),i=await fetch(`${M()}/api/agents/system-settings/echo-prompt`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch echo prompt setting: ${i.statusText}`);return(await i.json()).enabled||!1}async function js(s){const i=U(),n=await fetch(`${M()}/api/agents/system-settings/echo-prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!n.ok)throw new Error(`Failed to update echo prompt setting: ${n.statusText}`)}async function vs(){const s=U(),i=await fetch(`${M()}/api/agents/system-settings/codex-binary`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch codex binary path: ${i.statusText}`);return(await i.json()).path||""}async function Ns(s){const i=U(),n=await fetch(`${M()}/api/agents/system-settings/codex-binary`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({path:s})});if(!n.ok)throw new Error(`Failed to update codex binary path: ${n.statusText}`)}async function ys(){const s=U(),i=await fetch(`${M()}/api/agents/system-settings/tmux-mode`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch tmux mode setting: ${i.statusText}`);return(await i.json()).enabled||!1}async function ks(s){const i=U(),n=await fetch(`${M()}/api/agents/system-settings/tmux-mode`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!n.ok)throw new Error(`Failed to update tmux mode setting: ${n.statusText}`)}async function ws(){const s=U(),i=await fetch(`${M()}/api/agents/system-settings/backup`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch backup status: ${i.statusText}`);return i.json()}async function Ss(s){const i=U(),n=await fetch(`${M()}/api/agents/system-settings/backup`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(o.error||`Failed to update backup setting: ${n.statusText}`)}return n.json()}function Cs({checked:s,onChange:i,disabled:n}){return e.jsxs("label",{className:"config-toggle",children:[e.jsx("input",{type:"checkbox",className:"config-toggle-input",checked:s,disabled:n,onChange:o=>i(o.target.checked)}),e.jsx("span",{className:"config-toggle-track",children:e.jsx("span",{className:"config-toggle-thumb"})})]})}function As(){const{t:s}=G(["config","common"]),[i,n]=d.useState([]),[o,m]=d.useState(new Set),[p,l]=d.useState(new Set),[a,u]=d.useState(!1),[A,k]=d.useState(!1),[C,r]=d.useState(null),[g,x]=d.useState(null),[S,y]=d.useState(null),[c,L]=d.useState(null),[R,$]=d.useState(!1),[b,w]=d.useState(null);d.useEffect(()=>{oe(J("/api/config/categories")).then(h=>h.json()).then(h=>{const E=Array.isArray(h)?h:[];n(E),m(new Set(E.map(F=>F.id)))}).catch(h=>console.error("Failed to fetch config categories:",h))},[]),d.useEffect(()=>{ws().then(L).catch(h=>{console.error("Failed to fetch backup status:",h),w(h.message||"Failed to fetch backup status")})},[]);const Z=async h=>{if(!R){$(!0),w(null);try{const E=await Ss(h);L(E)}catch(E){w(E.message||"Failed to update backup setting")}finally{$(!1)}}},H=h=>{m(E=>{const F=new Set(E);return F.has(h)?F.delete(h):F.add(h),F})},K=h=>{l(E=>{const F=new Set(E);return F.has(h)?F.delete(h):F.add(h),F})},X=()=>m(new Set(i.map(h=>h.id))),I=()=>m(new Set),W=()=>{g&&l(new Set(g.categories.map(h=>h.id)))},te=()=>l(new Set),Q=async()=>{var h;if(o.size!==0){u(!0),y(null);try{const E=Array.from(o).join(","),F=await oe(J(`/api/config/export?categories=${E}`));if(!F.ok)throw new Error("Export failed");const Y=await F.blob(),q=window.URL.createObjectURL(Y),j=document.createElement("a");j.href=q;const B=F.headers.get("Content-Disposition"),le=((h=B==null?void 0:B.match(/filename="(.+)"/))==null?void 0:h[1])||"tide-commander-config.zip";j.download=le,document.body.appendChild(j),j.click(),document.body.removeChild(j),window.URL.revokeObjectURL(q),y({type:"success",text:s("config:data.exportSuccess")})}catch(E){y({type:"error",text:E.message||"Export failed"})}finally{u(!1)}}},f=async h=>{var F;const E=(F=h.target.files)==null?void 0:F[0];if(E){r(E),y(null),x(null),l(new Set);try{const Y=await oe(J("/api/config/preview"),{method:"POST",headers:{"Content-Type":"application/zip"},body:await E.arrayBuffer()});if(!Y.ok){const B=await Y.json();throw new Error(B.error||"Failed to preview config file")}const q=await Y.json(),j=Array.isArray(q.categories)?q.categories:[];x({...q,categories:j}),l(new Set(j.map(B=>B.id)))}catch(Y){y({type:"error",text:Y.message||"Failed to read config file"}),r(null)}}},T=async()=>{if(!(!C||p.size===0)){k(!0),y(null);try{const h=Array.from(p).join(","),E=await oe(J(`/api/config/import?categories=${h}`),{method:"POST",headers:{"Content-Type":"application/zip"},body:await C.arrayBuffer()}),F=await E.json();if(!E.ok)throw new Error(F.error||"Import failed");y({type:"success",text:F.message||s("config:data.importSuccess")}),r(null),x(null),l(new Set)}catch(h){y({type:"error",text:h.message||"Import failed"})}finally{k(!1)}}},D=()=>{r(null),x(null),l(new Set),y(null)};return e.jsxs("div",{className:"data-section",children:[S&&e.jsx("div",{className:`data-message data-message-${S.type}`,children:S.text}),e.jsxs("div",{className:"data-subsection",children:[e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-title",children:"Hourly Backups"}),e.jsx(Cs,{checked:!!(c!=null&&c.enabled),disabled:R||!c,onChange:Z})]}),e.jsxs("div",{className:"data-backup-info",children:[c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:["Saves a compressed snapshot of your data every hour to"," ",e.jsx("code",{children:c.backupDir}),". Identical snapshots are skipped. Keeps the 8 newest plus one from each of the 2 most recent prior days."]}),!c.scriptExists&&e.jsxs("div",{style:{marginTop:6,color:"var(--dracula-red, #ff5555)"},children:["Backup script not found at ",e.jsx("code",{children:c.scriptPath})]}),c.lastRunAt&&e.jsxs("div",{style:{marginTop:6},children:["Last run: ",new Date(c.lastRunAt).toLocaleString(),c.lastRunOk===!0&&" — ok",c.lastRunOk===!1&&c.lastRunError&&e.jsxs("span",{style:{color:"var(--dracula-red, #ff5555)"},children:[" — ",c.lastRunError]})]})]}):e.jsx("div",{children:"Loading backup status…"}),b&&e.jsx("div",{className:"data-message data-message-error",style:{marginTop:6},children:b})]})]}),e.jsxs("div",{className:"data-subsection",children:[e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-title",children:s("config:data.exportData")}),e.jsxs("div",{className:"data-select-controls",children:[e.jsx("button",{className:"data-select-btn",onClick:X,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:I,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:i.map(h=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:o.has(h.id),onChange:()=>H(h.id)}),e.jsx("span",{className:"data-category-name",children:h.name})]},h.id))}),e.jsx("button",{className:"data-action-btn export",onClick:Q,disabled:a||o.size===0,children:a?s("config:data.exporting"):s("config:data.exportCount",{count:o.size})})]}),e.jsxs("div",{className:"data-subsection",children:[e.jsx("div",{className:"data-subsection-header",children:e.jsx("span",{className:"data-subsection-title",children:s("config:data.importData")})}),C?g?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"data-import-info",children:[e.jsx("div",{className:"data-import-file",children:C.name}),e.jsxs("div",{className:"data-import-date",children:[s("config:data.exported"),": ",new Date(g.exportedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-subtitle",children:s("config:data.selectToImport")}),e.jsxs("div",{className:"data-select-controls",children:[e.jsx("button",{className:"data-select-btn",onClick:W,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:te,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:g.categories.map(h=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:p.has(h.id),onChange:()=>K(h.id)}),e.jsx("span",{className:"data-category-name",children:h.name}),h.fileCount&&e.jsxs("span",{className:"data-category-count",children:["(",h.fileCount," ",s("config:data.files"),")"]})]},h.id))}),e.jsxs("div",{className:"data-import-actions",children:[e.jsx("button",{className:"data-action-btn cancel",onClick:D,children:s("common:buttons.cancel")}),e.jsx("button",{className:"data-action-btn import",onClick:T,disabled:A||p.size===0,children:A?s("config:data.importing"):s("config:data.importCount",{count:p.size})})]})]}):e.jsx("div",{className:"data-loading",children:s("config:data.readingFile")}):e.jsxs("label",{className:"data-file-input",children:[e.jsx("input",{type:"file",accept:".zip",onChange:f,style:{display:"none"}}),e.jsx("span",{className:"data-file-input-label",children:s("config:data.selectFile")})]})]})]})}function Ts(){const[s,i]=d.useState(()=>Ve()),n=o=>{i(o);const m=qe(o);Me(m)};return e.jsx("div",{className:"theme-selector",children:e.jsx("div",{className:"theme-selector-grid",children:Ke.map(o=>e.jsxs("button",{className:`theme-option ${s===o.id?"active":""}`,onClick:()=>n(o.id),title:o.description,children:[e.jsx("div",{className:"theme-preview",children:e.jsxs("div",{className:"theme-preview-bg",style:{backgroundColor:o.colors.bgPrimary},children:[e.jsx("div",{className:"theme-preview-accent",style:{backgroundColor:o.colors.accentBlue}}),e.jsx("div",{className:"theme-preview-claude",style:{backgroundColor:o.colors.accentClaude}})]})}),e.jsx("span",{className:"theme-name",children:o.name})]},o.id))})})}function Es(){const{t:s}=G(["config"]),{updateAvailable:i,updateInfo:n,recentReleases:o,isChecking:m,error:p,currentVersion:l,isAndroid:a,checkForUpdate:u,downloadAndInstall:A,openReleasePage:k}=as(),C=g=>g?`${(g/(1024*1024)).toFixed(1)} MB`:"",r=g=>new Date(g).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"});return e.jsxs("div",{className:"about-section",children:[e.jsxs("div",{className:"about-logo",children:[e.jsx("span",{className:"about-logo-icon",children:e.jsx(P,{name:"waves",size:24})}),e.jsx("span",{className:"about-logo-text",children:"Tide Commander"})]}),e.jsxs("div",{className:"about-version",children:[e.jsx("span",{className:"about-version-label",children:s("config:about.version")}),e.jsxs("div",{className:"about-version-info",children:[e.jsx("span",{className:"about-version-value",children:l}),i&&n?e.jsx("span",{className:"about-version-update-badge",onClick:k,title:`Update available: ${n.version}`,children:n.version}):e.jsxs("a",{href:"https://github.com/deivid11/tide-commander/releases",target:"_blank",rel:"noopener noreferrer",className:"about-version-status",children:["(",s("config:about.updated"),")"]})]})]}),e.jsxs("div",{className:"about-update",children:[i&&n?e.jsxs("div",{className:"about-update-available",children:[e.jsxs("div",{className:"about-update-header",children:[e.jsx("span",{className:"about-update-badge",children:s("config:about.updateAvailable")}),e.jsx("span",{className:"about-update-version",children:n.version})]}),n.apkSize&&e.jsxs("div",{className:"about-update-size",children:[s("config:about.sizeLabel"),": ",C(n.apkSize)]}),p&&e.jsx("div",{className:"about-update-error",children:p}),e.jsxs("div",{className:"about-update-actions",children:[e.jsx("button",{className:"about-update-btn changelog",onClick:k,children:s("config:about.changelog")}),a&&n.apkUrl?e.jsx("button",{className:"about-update-btn download",onClick:A,children:s("config:about.downloadAPK")}):e.jsx("button",{className:"about-update-btn download",onClick:k,children:s("config:about.viewRelease")})]})]}):e.jsxs("div",{className:"about-update-check",children:[e.jsx("span",{className:"about-update-status",children:s(m?"config:about.checkingUpdates":"config:about.upToDate")}),e.jsx("button",{className:"about-update-btn check",onClick:()=>u(!0),disabled:m,children:m?"...":s("config:about.check")})]}),o.length>0&&e.jsxs("div",{className:"about-releases",children:[e.jsx("div",{className:"about-releases-title",children:s("config:about.recentReleases")}),e.jsx("div",{className:"about-releases-list",children:o.map(g=>e.jsxs("a",{href:g.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:`about-release-item ${g.version===`v${l}`||g.version===l?"current":""}`,children:[e.jsx("span",{className:"about-release-version",children:g.version}),e.jsx("span",{className:"about-release-date",children:r(g.publishedAt)})]},g.version))})]})]}),e.jsx("div",{className:"about-description",children:s("config:about.tagline")}),e.jsxs("div",{className:"about-principles",children:[e.jsx("div",{className:"about-principles-title",children:s("config:about.corePrinciples")}),e.jsxs("ul",{className:"about-principles-list",children:[e.jsx("li",{children:s("config:about.principle1")}),e.jsx("li",{children:s("config:about.principle2")}),e.jsx("li",{children:s("config:about.principle3")}),e.jsx("li",{children:s("config:about.principle4")})]})]}),e.jsx("div",{className:"about-links",children:e.jsxs("a",{href:"https://github.com/deivid11/tide-commander",target:"_blank",rel:"noopener noreferrer",className:"about-link",children:[e.jsx("span",{className:"about-link-icon",children:e.jsx(P,{name:"package",size:14})}),e.jsx("span",{children:s("config:about.repository")})]})}),e.jsxs("div",{className:"about-credits",children:[e.jsx("div",{className:"about-credits-title",children:s("config:about.specialThanks")}),e.jsxs("div",{className:"about-credit-item",children:[e.jsx("a",{href:"https://kenney.nl",target:"_blank",rel:"noopener noreferrer",className:"about-credit-link",children:"Kenney.nl"}),e.jsx("span",{className:"about-credit-desc",children:s("config:about.kenneyCredit")})]}),e.jsxs("div",{className:"about-credit-item",children:[e.jsx("a",{href:"https://claude.ai/code",target:"_blank",rel:"noopener noreferrer",className:"about-credit-link",children:"Claude Code"}),e.jsx("span",{className:"about-credit-desc",children:s("config:about.claudeCodeCredit")})]})]})]})}const Is={gmail:"✉️",slack:"💬",jira:"📋","google-calendar":"📅",docx:"📄"};function Ps({onOpenModal:s}){const[i,n]=d.useState([]),[o,m]=d.useState(!0),p=d.useCallback(async()=>{try{const l=await oe(J("/api/integrations"));if(!l.ok)return;const a=await l.json();n(a)}catch{}finally{m(!1)}},[]);return d.useEffect(()=>{p()},[p]),o?e.jsx("div",{style:{color:"var(--text-secondary, #a6adc8)",fontSize:12,padding:"4px 0"},children:"Loading..."}):i.length===0?e.jsx("div",{style:{color:"var(--text-secondary, #a6adc8)",fontSize:12,padding:"4px 0"},children:"No integrations available."}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[i.map(l=>{const a=Is[l.id]||"🔌",u=!!l.status.error,A=l.status.connected,k=u?"#f38ba8":A?"#a6e3a1":"#fab387",C=u?"Error":A?"Connected":"Setup Required",r=u?"✗":A?"✓":"⚠";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",borderRadius:6,background:"var(--surface-1, #181825)",border:"1px solid var(--border, #313244)",fontSize:13},children:[e.jsx("span",{style:{fontSize:15,flexShrink:0},children:a}),e.jsx("span",{style:{flex:1,color:"var(--text-primary, #cdd6f4)",fontWeight:500},children:l.name}),e.jsxs("span",{style:{color:k,fontSize:11,fontWeight:500,whiteSpace:"nowrap"},children:[r," ",C]}),e.jsx("button",{onClick:()=>s(l.id),title:`Configure ${l.name}`,style:{background:"none",border:"none",cursor:"pointer",padding:"2px 4px",fontSize:14,color:"var(--text-secondary, #a6adc8)",borderRadius:4,flexShrink:0},onMouseEnter:g=>{g.target.style.color="var(--text-primary, #cdd6f4)"},onMouseLeave:g=>{g.target.style.color="var(--text-secondary, #a6adc8)"},children:"⚙️"})]},l.id)}),e.jsx("button",{onClick:()=>s(),style:{background:"none",border:"1px dashed var(--border, #313244)",borderRadius:6,padding:"6px 8px",cursor:"pointer",color:"var(--text-secondary, #a6adc8)",fontSize:12,textAlign:"center",marginTop:2},onMouseEnter:l=>{l.target.style.borderColor="var(--accent, #89b4fa)",l.target.style.color="var(--accent, #89b4fa)"},onMouseLeave:l=>{l.target.style.borderColor="var(--border, #313244)",l.target.style.color="var(--text-secondary, #a6adc8)"},children:"Manage All Integrations"})]})}function Ls({isOpen:s,onClose:i}){const{t:n}=G(["config"]),[o,m]=d.useState(""),[p,l]=d.useState(""),[a,u]=d.useState(!0),[A,k]=d.useState(null),[C,r]=d.useState(null),[g,x]=d.useState(!1),[S,y]=d.useState(!1),[c,L]=d.useState(!1);d.useEffect(()=>{s&&R()},[s]);const R=async()=>{try{u(!0),k(null),r(null);const I=await hs();m(I),l(I),x(!1)}catch(I){k(I instanceof Error?I.message:"Failed to load system prompt")}finally{u(!1)}},$=I=>{const W=I.target.value;m(W),x(W!==p),k(null),r(null)},b=async()=>{try{k(null),r(null),await fs(o),l(o),x(!1),r(n("config:systemPrompt.saved"))}catch(I){k(I instanceof Error?I.message:"Failed to save system prompt")}},w=()=>{y(!0)},Z=async()=>{try{k(null),r(null),await xs(),m(""),l(""),x(!1),r(n("config:systemPrompt.cleared"))}catch(I){k(I instanceof Error?I.message:"Failed to clear system prompt")}},H=()=>{m(p),x(!1),k(null),r(null)},K=()=>{if(g){L(!0);return}i()},X=I=>{I.key==="Escape"&&(I.preventDefault(),K())};return s?e.jsxs(Ge,{children:[e.jsx("div",{className:`modal-overlay ${s?"visible":""}`,onClick:K,children:e.jsxs("div",{className:"system-prompt-modal",onClick:I=>I.stopPropagation(),onKeyDown:X,children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h2",{children:n("config:systemPrompt.title")}),e.jsx("button",{className:"modal-close",onClick:K,"aria-label":"Close",children:e.jsx(P,{name:"close",size:16})})]}),e.jsx("div",{className:"modal-body",children:a?e.jsxs("div",{className:"loading-state",children:[e.jsx("div",{className:"spinner"}),e.jsx("p",{children:"Loading system prompt..."})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"modal-description",children:n("config:systemPrompt.description")}),A&&e.jsxs("div",{className:"alert alert-error",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(P,{name:"warn",size:14})}),A]}),C&&e.jsxs("div",{className:"alert alert-success",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(P,{name:"check",size:14})}),C]}),e.jsxs("div",{className:"editor-wrapper",children:[e.jsxs("div",{className:"editor-header",children:[e.jsx("label",{htmlFor:"prompt-input",className:"editor-label",children:n("config:systemPrompt.editPrompt")}),e.jsxs("span",{className:"char-count",children:[o.length," ",n("config:systemPrompt.characters")]})]}),e.jsx("textarea",{id:"prompt-input",className:"prompt-editor",value:o,onChange:$,placeholder:n("config:systemPrompt.placeholder"),rows:18,autoFocus:!0}),e.jsx("div",{className:"editor-hint",children:n("config:systemPrompt.hint")})]})]})}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("div",{className:"footer-buttons-left",children:e.jsx("button",{className:"btn btn-danger",onClick:w,disabled:!o||a,children:n("config:systemPrompt.clear")})}),e.jsxs("div",{className:"footer-buttons-right",children:[e.jsx("button",{className:"btn btn-secondary",onClick:K,children:"Close"}),e.jsx("button",{className:"btn btn-secondary",onClick:H,disabled:!g||a,children:n("config:systemPrompt.reset")}),e.jsx("button",{className:"btn btn-primary",onClick:b,disabled:!g||a,children:n("config:systemPrompt.save")})]})]})]})}),e.jsx(ge,{isOpen:S,title:n("config:systemPrompt.clear"),message:n("config:systemPrompt.confirmClear"),confirmLabel:n("config:systemPrompt.clear"),cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{Z()},onClose:()=>y(!1)}),e.jsx(ge,{isOpen:c,title:"Unsaved Changes",message:"You have unsaved changes. Close anyway?",confirmLabel:"Close anyway",cancelLabel:"Keep editing",variant:"danger",onConfirm:i,onClose:()=>L(!1)})]}):null}const Fs=[{value:"auto",label:"Auto",icon:"🕐"},{value:"dawn",label:"Dawn",icon:"🌅"},{value:"day",label:"Day",icon:"☀️"},{value:"dusk",label:"Dusk",icon:"🌇"},{value:"night",label:"Night",icon:"🌙"}],Os=[{value:"none",label:"Grass",icon:"🌱"},{value:"concrete",label:"Concrete",icon:"🏗️"},{value:"galactic",label:"Galactic",icon:"🌌"},{value:"metal",label:"Metal",icon:"⚙️"},{value:"hex",label:"Hex",icon:"⬡"},{value:"circuit",label:"Circuit",icon:"🔌"},{value:"pokemon-stadium",label:"Pokemon",icon:"🔴"}],$s=[{value:"static",label:"Static",icon:"🧍"},{value:"idle",label:"Idle",icon:"🚶"},{value:"walk",label:"Walk",icon:"🚶‍♂️"},{value:"sprint",label:"Sprint",icon:"🏃"},{value:"jump",label:"Jump",icon:"⬆️"},{value:"fall",label:"Fall",icon:"⬇️"},{value:"crouch",label:"Crouch",icon:"🧎"},{value:"sit",label:"Sit",icon:"🪑"},{value:"die",label:"Die",icon:"💀"},{value:"emote-yes",label:"Yes",icon:"👍"},{value:"emote-no",label:"No",icon:"👎"}],zs=[{value:"normal",label:"Normal",icon:"🎨"},{value:"bw",label:"B&W",icon:"⬛"},{value:"sepia",label:"Sepia",icon:"🟤"},{value:"cool",label:"Cool",icon:"❄️"},{value:"warm",label:"Warm",icon:"🔥"},{value:"neon",label:"Neon",icon:"💜"}],_s=[{key:"showTrees",icon:"🌳",label:"Trees"},{key:"showBushes",icon:"🌿",label:"Bushes"},{key:"showHouse",icon:"🏠",label:"House"},{key:"showLamps",icon:"💡",label:"Lamps"},{key:"showGrass",icon:"🟩",label:"Grass"},{key:"showClouds",icon:"☁️",label:"Clouds"}],Bs=[{value:null,label:"Auto",color:"linear-gradient(135deg, #4a90d9 0%, #0a1a2a 100%)"},{value:"#4a90d9",label:"Day Blue",color:"#4a90d9"},{value:"#0a1a2a",label:"Night",color:"#0a1a2a"},{value:"#ff6b35",label:"Sunset",color:"#ff6b35"},{value:"#1a0a2e",label:"Purple",color:"#1a0a2e"},{value:"#2d5a27",label:"Matrix",color:"#2d5a27"},{value:"#8b0000",label:"Blood",color:"#8b0000"},{value:"#000000",label:"Void",color:"#000000"}],Ds={showTrees:"trees",showBushes:"bushes",showHouse:"house",showLamps:"lamps",showGrass:"grass",showClouds:"clouds"},Rs={none:"grass","pokemon-stadium":"pokemon"},Us={"emote-yes":"yes","emote-no":"no"},Vs={"":"auto","#4a90d9":"dayBlue","#0a1a2a":"night","#ff6b35":"sunset","#1a0a2e":"purple","#2d5a27":"matrix","#8b0000":"blood","#000000":"void"};function V({checked:s,onChange:i}){return e.jsxs("label",{className:"config-toggle",children:[e.jsx("input",{type:"checkbox",className:"config-toggle-input",checked:s,onChange:n=>i(n.target.checked)}),e.jsx("span",{className:"config-toggle-track",children:e.jsx("span",{className:"config-toggle-thumb"})})]})}function ae({options:s,value:i,onChange:n,iconOnly:o=!1}){return e.jsx("div",{className:"chip-selector",children:s.map(m=>e.jsxs("button",{className:`chip ${i===m.value?"active":""}`,onClick:()=>n(m.value),title:m.label,children:[e.jsx("span",{className:"chip-icon",children:m.icon}),!o&&e.jsx("span",{className:"chip-label",children:m.label})]},m.value))})}function N({text:s,query:i}){if(!i.trim())return e.jsx(e.Fragment,{children:s});const n=s.toLowerCase(),o=i.toLowerCase(),m=n.indexOf(o);if(m===-1)return e.jsx(e.Fragment,{children:s});const p=s.slice(0,m),l=s.slice(m,m+i.length),a=s.slice(m+i.length);return e.jsxs(e.Fragment,{children:[p,e.jsx("mark",{className:"search-highlight",children:l}),a]})}const Ks=[{id:"general",title:"General",keywords:["history","hide costs","grid","fps","power saving","performance","limit","editor","external editor","language","idioma","语言","vibration","haptic","intensity","tab title","tmux","process persistence"]},{id:"agentNames",title:"Agent Names",keywords:["agent","names","custom","characters","rename"]},{id:"defaultClass",title:"Default Spawn Class",keywords:["default","class","spawn","agent","scout","builder","random"]},{id:"appearance",title:"Appearance",keywords:["theme","appearance","color","dark","light","style","look"]},{id:"connection",title:"Connection",keywords:["backend","url","auth","token","reconnect","server","api","connect","codex","opencode","binary","path"]},{id:"scene",title:"Scene",keywords:["character","size","indicator","scale","time","dawn","day","dusk","night","auto"]},{id:"terrain",title:"Terrain",keywords:["trees","bushes","house","lamps","grass","clouds","fog","brightness","floor","sky","color","environment","battlefield","size","grid","simple","minimal","dark","clean"]},{id:"modelStyle",title:"Agent Model Style",keywords:["saturation","roughness","metalness","glow","emissive","reflections","wireframe","color mode","material","shader"]},{id:"animations",title:"Animations",keywords:["idle","working","animation","walk","run","sprint","jump","sit","crouch"]},{id:"secrets",title:"Secrets",keywords:["secrets","api","key","password","credentials","env","environment"]},{id:"systemPrompt",title:"System Prompt",keywords:["system","prompt","global","instructions","ai","agent","rules","guidelines"]},{id:"data",title:"Data",keywords:["export","import","backup","restore","save","load","json"]},{id:"integrations",title:"Integrations",keywords:["integrations","plugins","gmail","slack","jira","calendar","docx","email","config","setup"]},{id:"workflows",title:"Workflows",keywords:["workflow","automation","state machine","editor","actions","transitions","pipeline"]},{id:"triggers",title:"Triggers",keywords:["trigger","event","webhook","cron","slack","email","jira","matching","fire"]},{id:"monitoring",title:"Monitoring",keywords:["monitoring","logs","triggers","events","history","workflow","traces","audit","timeline"]},{id:"experimental",title:"Experimental",keywords:["experimental","2d","view","voice","assistant","speech","tts","text to speech","echo","prompt","duplicate"]},{id:"about",title:"About",keywords:["about","version","update","credits","github","releases"]}],ue=[{value:"auto",label:"Auto",icon:"🌐"},{value:"en",label:"English",icon:"🇺🇸"},{value:"zh-CN",label:"中文",icon:"🇨🇳"},{value:"es",label:"Español",icon:"🇪🇸"},{value:"hi",label:"हिन्दी",icon:"🇮🇳"},{value:"pt",label:"Português",icon:"🇧🇷"},{value:"ru",label:"Русский",icon:"🇷🇺"},{value:"ja",label:"日本語",icon:"🇯🇵"},{value:"de",label:"Deutsch",icon:"🇩🇪"},{value:"fr",label:"Français",icon:"🇫🇷"},{value:"it",label:"Italiano",icon:"🇮🇹"}];function qs({config:s,onChange:i,searchQuery:n="",onOpenIntegrationsModal:o,onOpenMonitoringModal:m,onOpenWorkflowEditor:p,onOpenTriggerManager:l}){var Ne;const{t:a}=G(["config","common"]),u=pe(),A=He(),[k,C]=d.useState(()=>We(ne.DEFAULT_AGENT_CLASS)||"scout"),[r,g]=d.useState(u.settings.historyLimit),[x,S]=d.useState(()=>Ye()),[y,c]=d.useState(!1),[L,R]=d.useState(()=>U()),[$,b]=d.useState(!1),[w,Z]=d.useState(!1),[H,K]=d.useState(""),[X,I]=d.useState(!1),[W,te]=d.useState(""),[Q,f]=d.useState(!1);d.useEffect(()=>{vs().then(te).catch(()=>{})},[]),d.useEffect(()=>{bs().then(t=>{t!==u.settings.experimentalEchoPrompt&&v.updateSettings({experimentalEchoPrompt:t})}).catch(()=>{})},[]),d.useEffect(()=>{ys().then(t=>{t!==u.settings.tmuxMode&&v.updateSettings({tmuxMode:t})}).catch(()=>{})},[]),d.useEffect(()=>Je(t=>{S(t),c(!1)}),[]);const T=Fs.map(t=>({...t,label:a(`config:time.${t.value}`)})),D=Os.map(t=>({...t,label:a(`config:floor.${Rs[t.value]||t.value}`)})),h=$s.map(t=>({...t,label:a(`config:animation.${Us[t.value]||t.value}`)})),E=zs.map(t=>({...t,label:a(`config:colorMode.${t.value}`)})),F=_s.map(t=>({...t,label:a(`config:terrain.${Ds[t.key]}`)})),Y=Bs.map(t=>({...t,label:a(`config:sky.${Vs[t.value??""]}`)})),q=n.trim()?Ks.filter(t=>{const _=n.toLowerCase();return t.title.toLowerCase().includes(_)||t.keywords.some(ce=>ce.toLowerCase().includes(_))}).map(t=>t.id):null,j=t=>q?q.includes(t):!0,B=u.settings.customAgentNames||[],le=B.length>0?B:Ze,fe=()=>{const t=H.trim();t&&!B.includes(t)&&(v.updateSettings({customAgentNames:[...B,t]}),K(""))},Ee=t=>{v.updateSettings({customAgentNames:B.filter(_=>_!==t)})},Ie=()=>{v.updateSettings({customAgentNames:[]})},Pe=t=>{S(t),c(!0)},xe=()=>{Qe(x),c(!1),me()},Le=t=>{R(t),b(!0)},be=()=>{ie(ne.AUTH_TOKEN,L),b(!1),me()},Fe=t=>{te(t),f(!0)},je=()=>{Ns(W).catch(()=>{}),f(!1)},ee=t=>{i({...s,terrain:{...s.terrain,...t}})},se=t=>{i({...s,modelStyle:{...s.modelStyle,...t}})},ve=t=>{i({...s,animations:{...s.animations,...t}})},Oe=t=>{g(t),v.updateSettings({historyLimit:t})},$e=t=>{const _=s.terrain[t];typeof _=="boolean"&&ee({[t]:!_})},z=n.trim().length>0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"config-section",children:[q&&q.length===0&&e.jsx("div",{className:"config-no-results",children:a("config:noResults",{query:n})}),j("general")&&e.jsxs(O,{title:a("config:sections.general"),storageKey:"general",defaultOpen:!0,forceOpen:z&&j("general"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:general.history"),query:n})}),e.jsx("input",{type:"number",className:"config-input config-input-sm",value:r,onChange:t=>Oe(parseInt(t.target.value)||100),min:50,max:2e3,step:50})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:general.hideCosts"),query:n})}),e.jsx(V,{checked:u.settings.hideCost,onChange:t=>v.updateSettings({hideCost:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:general.grid"),query:n})}),e.jsx(V,{checked:s.gridVisible,onChange:t=>i({...s,gridVisible:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:general.showFPS"),query:n})}),e.jsx(V,{checked:u.settings.showFPS,onChange:t=>v.updateSettings({showFPS:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:general.fpsLimit"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"120",step:"10",value:s.fpsLimit,onChange:t=>i({...s,fpsLimit:parseInt(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.fpsLimit===0?"∞":s.fpsLimit})]}),e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Experimental: Reduce FPS when idle to save power",children:[e.jsx(N,{text:a("config:general.powerSaving"),query:n})," ",e.jsx(P,{name:"bolt",size:12})]}),e.jsx(V,{checked:u.settings.powerSaving,onChange:t=>v.updateSettings({powerSaving:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",title:"Wrap agent processes in tmux sessions so they survive server restarts (requires tmux installed)",children:e.jsx(N,{text:a("config:general.tmuxMode"),query:n})}),e.jsx(V,{checked:u.settings.tmuxMode,onChange:async t=>{v.updateSettings({tmuxMode:t});try{await ks(t)}catch(_){console.error("Failed to sync tmux mode setting to server:",_)}}})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:general.vibrationIntensity"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"5",step:"1",value:u.settings.vibrationIntensity,onChange:t=>v.updateSettings({vibrationIntensity:parseInt(t.target.value)})}),e.jsx("span",{className:"config-value",children:u.settings.vibrationIntensity===0?a("config:vibrationValues.off"):u.settings.vibrationIntensity===1?a("config:vibrationValues.ultraLight"):u.settings.vibrationIntensity===2?a("config:vibrationValues.veryLight"):u.settings.vibrationIntensity===3?a("config:vibrationValues.light"):u.settings.vibrationIntensity===4?a("config:vibrationValues.medium"):a("config:vibrationValues.heavy")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:general.externalEditor"),query:n})}),e.jsx("input",{type:"text",className:"config-input",placeholder:a("config:general.externalEditorPlaceholder"),value:u.settings.externalEditorCommand||"",onChange:t=>v.updateSettings({externalEditorCommand:t.target.value})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:general.tabTitle"),query:n})}),e.jsx("input",{type:"text",className:"config-input",placeholder:a("config:general.tabTitlePlaceholder"),value:u.settings.tabTitle||"",onChange:t=>v.updateSettings({tabTitle:t.target.value})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:general.language"),query:n})}),e.jsx(ae,{options:ue,value:localStorage.getItem("tide-commander-language-mode")==="manual"?((Ne=ue.find(t=>t.value!=="auto"&&de.language.startsWith(t.value.split("-")[0])))==null?void 0:Ne.value)||"en":"auto",onChange:t=>{var _;if(t==="auto"){localStorage.setItem("tide-commander-language-mode","auto");const ce=navigator.language,ze=((_=ue.find(ye=>ye.value!=="auto"&&ce.startsWith(ye.value.split("-")[0])))==null?void 0:_.value)||"en";de.changeLanguage(ze)}else localStorage.setItem("tide-commander-language-mode","manual"),de.changeLanguage(t)}})]})]}),j("agentNames")&&e.jsx(O,{title:a("config:sections.agentNames"),storageKey:"agentNames",defaultOpen:!1,forceOpen:z&&j("agentNames"),children:e.jsxs("div",{className:"agent-names-section",children:[e.jsx("span",{className:"config-hint",children:B.length>0?a("config:agentNames.customConfigured",{count:B.length}):a("config:agentNames.usingDefaults")}),e.jsxs("div",{className:"agent-names-input-row",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",placeholder:a("config:agentNames.addPlaceholder"),value:H,onChange:t=>K(t.target.value),onKeyDown:t=>{t.key==="Enter"&&fe()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:fe,disabled:!H.trim(),title:a("config:agentNames.addName"),children:"+"})]}),e.jsx("div",{className:"agent-names-list",children:le.map((t,_)=>e.jsxs("div",{className:"agent-name-chip",children:[e.jsx("span",{className:"agent-name-text",children:t}),B.length>0&&e.jsx("button",{className:"agent-name-remove",onClick:()=>Ee(t),title:a("common:buttons.remove"),children:"x"})]},`${t}-${_}`))}),B.length>0&&e.jsx("button",{className:"config-btn config-btn-link",onClick:Ie,children:a("common:buttons.resetToDefaults")})]})}),j("defaultClass")&&e.jsx(O,{title:"Default Spawn Class",storageKey:"defaultClass",defaultOpen:!1,forceOpen:z&&j("defaultClass"),children:e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-hint",children:'Class pre-selected when the spawn modal opens. "Random" picks a different class each time.'}),e.jsxs("div",{className:"agent-names-list",style:{flexWrap:"wrap",gap:"6px",marginTop:"8px"},children:[e.jsx("div",{className:`agent-name-chip${k==="random"?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{C("random"),ie(ne.DEFAULT_AGENT_CLASS,"random")},children:e.jsx("span",{className:"agent-name-text",children:"🎲 Random"})}),Object.entries(Xe).map(([t,_])=>e.jsx("div",{className:`agent-name-chip${k===t?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{C(t),ie(ne.DEFAULT_AGENT_CLASS,t)},children:e.jsxs("span",{className:"agent-name-text",children:[_.icon," ",t.charAt(0).toUpperCase()+t.slice(1)]})},t)),A.map(t=>e.jsx("div",{className:`agent-name-chip${k===t.id?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{C(t.id),ie(ne.DEFAULT_AGENT_CLASS,t.id)},children:e.jsxs("span",{className:"agent-name-text",children:[t.icon," ",t.name]})},t.id))]})]})}),j("appearance")&&e.jsx(O,{title:a("config:sections.appearance"),storageKey:"appearance",defaultOpen:!1,forceOpen:z&&j("appearance"),children:e.jsx(Ts,{})}),j("connection")&&e.jsxs(O,{title:a("config:sections.connection"),storageKey:"connection",defaultOpen:!1,forceOpen:z&&j("connection"),children:[e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:connection.backendUrl"),query:n})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",value:x,onChange:t=>Pe(t.target.value),placeholder:"http://localhost:5174",onKeyDown:t=>{t.key==="Enter"&&y&&xe()}}),y&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:xe,title:a("config:connection.saveAndReconnect"),children:a("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:a("config:connection.autoDetectHint")})]}),e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:connection.authToken"),query:n})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:w?"text":"password",className:"config-input config-input-full",value:L,onChange:t=>Le(t.target.value),placeholder:a("config:connection.tokenPlaceholder"),onKeyDown:t=>{t.key==="Enter"&&$&&be()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>Z(!w),title:a(w?"config:connection.hideToken":"config:connection.showToken"),children:e.jsx(P,{name:w?"eye-closed":"eye",size:14})}),$&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:be,title:a("config:connection.saveAndReconnect"),children:a("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:a("config:connection.tokenRequired")})]}),e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:connection.codexBinaryPath"),query:n})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",value:W,onChange:t=>Fe(t.target.value),placeholder:a("config:connection.codexBinaryPathPlaceholder"),onKeyDown:t=>{t.key==="Enter"&&Q&&je()}}),Q&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:je,children:a("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:a("config:connection.codexBinaryPathHint")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("common:buttons.reconnect"),query:n})}),e.jsx("button",{className:"config-btn",onClick:()=>me(),title:"Force reconnect to server",children:a("common:buttons.reconnect")})]})]}),j("scene")&&e.jsxs(O,{title:a("config:sections.scene"),storageKey:"scene",defaultOpen:!1,forceOpen:z&&j("scene"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:scene.characterSize"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.3",max:"3.0",step:"0.1",value:s.characterScale,onChange:t=>i({...s,characterScale:parseFloat(t.target.value)})}),e.jsxs("span",{className:"config-value",children:[s.characterScale.toFixed(1),"x"]})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:scene.scale2d",{defaultValue:"2D Scale"}),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.3",max:"2.0",step:"0.1",value:s.scale2d,onChange:t=>i({...s,scale2d:parseFloat(t.target.value)})}),e.jsxs("span",{className:"config-value",children:[s.scale2d.toFixed(1),"x"]})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:scene.scale3d",{defaultValue:"3D Scale"}),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.3",max:"2.0",step:"0.1",value:s.scale3d,onChange:t=>i({...s,scale3d:parseFloat(t.target.value)})}),e.jsxs("span",{className:"config-value",children:[s.scale3d.toFixed(1),"x"]})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:scene.show2DTaskLabels",{defaultValue:"Show 2D task labels"}),query:n})}),e.jsx(V,{checked:s.show2DTaskLabels,onChange:t=>i({...s,show2DTaskLabels:t})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:scene.time"),query:n})}),e.jsx(ae,{options:T,value:s.timeMode,onChange:t=>i({...s,timeMode:t}),iconOnly:!0})]})]}),j("terrain")&&e.jsxs(O,{title:a("config:sections.terrain"),storageKey:"terrain",defaultOpen:!1,forceOpen:z&&j("terrain"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:terrainSettings.simpleMode",{defaultValue:"Simple Mode"}),query:n})}),e.jsx(V,{checked:s.terrain.simpleMode??!1,onChange:t=>ee({simpleMode:t})})]}),e.jsx("div",{className:"terrain-icons",style:{opacity:s.terrain.simpleMode?.4:1,pointerEvents:s.terrain.simpleMode?"none":"auto"},children:F.map(t=>e.jsx("button",{className:`terrain-icon-btn ${s.terrain[t.key]?"active":""}`,onClick:()=>$e(t.key),title:t.label,children:t.icon},t.key))}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:terrainSettings.fog"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"2",step:"0.1",value:s.terrain.fogDensity,onChange:t=>ee({fogDensity:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.fogDensity===0?a("config:fogValues.off"):s.terrain.fogDensity<=1?a("config:fogValues.low"):a("config:fogValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:terrainSettings.brightness"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.2",max:"2",step:"0.1",value:s.terrain.brightness,onChange:t=>ee({brightness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.brightness<=.5?a("config:brightnessValues.dark"):s.terrain.brightness<=1.2?a("config:brightnessValues.normal"):a("config:brightnessValues.bright")})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:terrainSettings.floor"),query:n})}),e.jsx(ae,{options:D,value:s.terrain.floorStyle,onChange:t=>ee({floorStyle:t}),iconOnly:!0})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:terrainSettings.sky"),query:n})}),e.jsx("div",{className:"sky-color-selector",children:Y.map(t=>e.jsx("button",{className:`sky-color-btn ${s.terrain.skyColor===t.value?"active":""}`,onClick:()=>ee({skyColor:t.value}),title:t.label,style:{background:t.color}},t.value??"auto"))})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:terrainSettings.battlefieldSize"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"30",max:"200",step:"10",value:s.terrain.battlefieldSize,onChange:t=>ee({battlefieldSize:parseInt(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.battlefieldSize})]})]}),j("modelStyle")&&e.jsxs(O,{title:a("config:sections.modelStyle"),storageKey:"modelStyle",defaultOpen:!1,forceOpen:z&&j("modelStyle"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:modelStyleSettings.saturation"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"2",step:"0.1",value:s.modelStyle.saturation,onChange:t=>se({saturation:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.saturation<=.3?a("config:saturationValues.gray"):s.modelStyle.saturation<=1.2?a("config:saturationValues.normal"):a("config:saturationValues.vivid")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:modelStyleSettings.roughness"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"1",step:"0.1",value:s.modelStyle.roughness,onChange:t=>se({roughness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.roughness<0?a("config:roughnessValues.auto"):s.modelStyle.roughness<=.3?a("config:roughnessValues.glossy"):s.modelStyle.roughness<=.7?a("config:roughnessValues.normal"):a("config:roughnessValues.matte")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:modelStyleSettings.metalness"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"1",step:"0.1",value:s.modelStyle.metalness,onChange:t=>se({metalness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.metalness<0?a("config:metalnessValues.auto"):s.modelStyle.metalness<=.3?a("config:metalnessValues.plastic"):s.modelStyle.metalness<=.7?a("config:metalnessValues.mixed"):a("config:metalnessValues.metal")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:modelStyleSettings.glow"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"1",step:"0.05",value:s.modelStyle.emissiveBoost,onChange:t=>se({emissiveBoost:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.emissiveBoost<=.1?a("config:glowValues.off"):s.modelStyle.emissiveBoost<=.4?a("config:glowValues.low"):s.modelStyle.emissiveBoost<=.7?a("config:glowValues.med"):a("config:glowValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:modelStyleSettings.reflections"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"2",step:"0.1",value:s.modelStyle.envMapIntensity,onChange:t=>se({envMapIntensity:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.envMapIntensity<0?a("config:reflectionValues.auto"):s.modelStyle.envMapIntensity<=.3?a("config:reflectionValues.low"):s.modelStyle.envMapIntensity<=1?a("config:reflectionValues.normal"):a("config:reflectionValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:modelStyleSettings.wireframe"),query:n})}),e.jsx(V,{checked:s.modelStyle.wireframe,onChange:t=>se({wireframe:t})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:modelStyleSettings.colorMode"),query:n})}),e.jsx(ae,{options:E,value:s.modelStyle.colorMode,onChange:t=>se({colorMode:t}),iconOnly:!0})]})]}),j("animations")&&e.jsxs(O,{title:a("config:sections.animations"),storageKey:"animations",defaultOpen:!1,forceOpen:z&&j("animations"),children:[e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:animationSettings.idle"),query:n})}),e.jsx(ae,{options:h,value:s.animations.idleAnimation,onChange:t=>ve({idleAnimation:t}),iconOnly:!0})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:animationSettings.working"),query:n})}),e.jsx(ae,{options:h,value:s.animations.workingAnimation,onChange:t=>ve({workingAnimation:t}),iconOnly:!0})]})]}),j("secrets")&&e.jsx(O,{title:a("config:sections.secrets"),storageKey:"secrets",defaultOpen:!1,forceOpen:z&&j("secrets"),children:e.jsx(ps,{})}),j("systemPrompt")&&e.jsx(O,{title:a("config:sections.systemPrompt"),storageKey:"systemPrompt",defaultOpen:!1,forceOpen:z&&j("systemPrompt"),children:e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:systemPrompt.title"),query:n})}),e.jsx("button",{className:"config-button",onClick:()=>I(!0),children:a("config:systemPrompt.editPrompt")})]})}),j("data")&&e.jsx(O,{title:a("config:sections.data"),storageKey:"data",defaultOpen:!1,forceOpen:z&&j("data"),children:e.jsx(As,{})}),j("integrations")&&e.jsx(O,{title:"Integrations",storageKey:"integrations",defaultOpen:!1,forceOpen:z&&j("integrations"),children:e.jsx(Ps,{onOpenModal:t=>o==null?void 0:o(t)})}),j("workflows")&&e.jsxs(O,{title:"Workflows",storageKey:"workflows",defaultOpen:!1,forceOpen:z&&j("workflows"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(N,{text:"Create and manage automated workflow pipelines with visual state machine editor",query:n})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>p==null?void 0:p(),children:"Open Workflow Editor"})})]}),j("triggers")&&e.jsxs(O,{title:"Triggers",storageKey:"triggers",defaultOpen:!1,forceOpen:z&&j("triggers"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(N,{text:"Create and manage event-driven triggers that fire agents with templates",query:n})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>l==null?void 0:l(),children:"Open Trigger Manager"})})]}),j("monitoring")&&e.jsxs(O,{title:"Monitoring",storageKey:"monitoring",defaultOpen:!1,forceOpen:z&&j("monitoring"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(N,{text:"View event logs, trigger history, workflow traces, and system stats",query:n})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>m==null?void 0:m(),children:"Open Monitoring & Logs"})})]}),j("experimental")&&e.jsxs(O,{title:a("config:sections.experimental"),storageKey:"experimental",defaultOpen:!1,forceOpen:z&&j("experimental"),children:[e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Lightweight 2D top-down view for better performance",children:[e.jsx(N,{text:a("config:experimental.2dView"),query:n})," ",e.jsx(P,{name:"map",size:12})]}),e.jsx(V,{checked:u.settings.experimental2DView,onChange:t=>v.updateSettings({experimental2DView:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Voice assistant for hands-free agent control",children:[e.jsx(N,{text:a("config:experimental.voiceAssistant"),query:n})," ",e.jsx(P,{name:"microphone",size:12})]}),e.jsx(V,{checked:u.settings.experimentalVoiceAssistant,onChange:t=>v.updateSettings({experimentalVoiceAssistant:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Text-to-speech for reading agent responses",children:[e.jsx(N,{text:a("config:experimental.tts"),query:n})," ",e.jsx(P,{name:"speaker-on",size:12})]}),e.jsx(V,{checked:u.settings.experimentalTTS,onChange:t=>v.updateSettings({experimentalTTS:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",title:"Duplicate system prompt for improved LLM attention coverage. Increases input token usage.",children:e.jsx(N,{text:a("config:experimental.echoPrompt"),query:n})}),e.jsx(V,{checked:u.settings.experimentalEchoPrompt,onChange:async t=>{v.updateSettings({experimentalEchoPrompt:t});try{await js(t)}catch(_){console.error("Failed to sync echo prompt setting to server:",_)}}})]}),e.jsx("span",{className:"config-hint",children:a("config:experimental.hint")})]}),j("about")&&e.jsx(O,{title:a("config:sections.about"),storageKey:"about",defaultOpen:!1,forceOpen:z&&j("about"),children:e.jsx(Es,{})})]}),e.jsx(Ls,{isOpen:X,onClose:()=>I(!1)})]})}function Ws({onConfigChange:s,onToolChange:i,config:n,isOpen:o,onClose:m,onOpenBuildingModal:p,onOpenAreaExplorer:l,onOpenIntegrationsModal:a,onOpenMonitoringModal:u,onOpenWorkflowEditor:A,onOpenTriggerManager:k}){const{t:C}=G(["config","common"]),r=pe(),g=Array.from(r.areas.values()),x=Array.from(r.buildings.values()),[S,y]=d.useState(""),c=d.useRef(null);if(d.useEffect(()=>{const b=w=>{w.key==="Escape"&&o&&m()};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[o,m]),d.useEffect(()=>{if(o&&c.current){const b=setTimeout(()=>{var w;(w=c.current)==null||w.focus()},50);return()=>clearTimeout(b)}},[o]),!o)return null;const L=b=>{const w=r.activeTool===b?null:b;i(w)},R=b=>{v.selectArea(r.selectedAreaId===b?null:b),i("select")},$=(b,w)=>{b.stopPropagation(),v.deleteArea(w)};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"toolbox-backdrop",onClick:m}),e.jsxs("aside",{className:"toolbox",children:[e.jsxs("div",{className:"toolbox-header",children:[e.jsx("span",{children:C("config:title")}),e.jsx("button",{className:"toolbox-close-btn",onClick:m,title:C("common:buttons.close"),children:"×"})]}),e.jsxs("div",{className:"toolbox-search",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"M21 21l-4.35-4.35"})]}),e.jsx("input",{ref:c,type:"text",placeholder:C("config:searchPlaceholder"),value:S,onChange:b=>y(b.target.value),className:"toolbox-search-input"}),S&&e.jsx("button",{className:"toolbox-search-clear",onClick:()=>y(""),children:"×"})]}),e.jsxs("div",{className:"toolbox-content",children:[e.jsx("div",{className:"toolbox-section toolbox-section-collapsible",children:e.jsxs(O,{title:C("config:areas.title",{count:g.length}),storageKey:"areas",children:[e.jsxs("div",{className:"tool-buttons",children:[e.jsx("button",{className:`tool-btn ${r.activeTool==="select"?"active":""}`,onClick:()=>L("select"),title:C("config:tools.select"),children:e.jsx("span",{children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M3 3l7.07 16.97 2.51-7.39 7.39-2.51L3 3z"})})})}),e.jsx("button",{className:`tool-btn ${r.activeTool==="rectangle"?"active":""}`,onClick:()=>L("rectangle"),title:C("config:tools.rectangle"),children:e.jsx("span",{children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"})})})}),e.jsx("button",{className:`tool-btn ${r.activeTool==="circle"?"active":""}`,onClick:()=>L("circle"),title:C("config:tools.circle"),children:e.jsx("span",{children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("circle",{cx:"12",cy:"12",r:"9"})})})})]}),e.jsx("div",{className:"areas-list",children:g.length===0?e.jsx("div",{className:"areas-empty",children:C("config:areas.drawToCreate")}):g.map(b=>e.jsx(is,{area:b,isSelected:r.selectedAreaId===b.id,onClick:()=>R(b.id),onDelete:w=>$(w,b.id)},b.id))})]})}),r.selectedAreaId&&e.jsx(gs,{area:r.areas.get(r.selectedAreaId),onClose:()=>v.selectArea(null),onOpenFolder:l}),e.jsx("div",{className:"toolbox-section toolbox-section-collapsible",children:e.jsx(O,{title:C("config:buildings.title",{count:x.length}),storageKey:"buildings",headerExtra:e.jsx("button",{className:"add-building-btn",onClick:b=>{b.stopPropagation(),p==null||p()},title:C("config:buildings.addBuilding"),children:"+"}),children:e.jsx("div",{className:"buildings-list",children:x.length===0?e.jsx("div",{className:"buildings-empty",children:C("config:buildings.clickToAdd")}):x.map(b=>e.jsx(ls,{building:b,isSelected:r.selectedBuildingIds.has(b.id),onClick:()=>{v.selectBuilding(r.selectedBuildingIds.has(b.id)?null:b.id)},onEdit:()=>p==null?void 0:p(b.id)},b.id))})})}),r.selectedBuildingIds.size===1&&(()=>{const b=Array.from(r.selectedBuildingIds)[0],w=r.buildings.get(b);return w?e.jsx(cs,{building:w,onClose:()=>v.selectBuilding(null),onOpenModal:()=>p==null?void 0:p(b)}):null})(),e.jsx(qs,{config:n,onChange:s,searchQuery:S,onOpenIntegrationsModal:a,onOpenMonitoringModal:u,onOpenWorkflowEditor:A,onOpenTriggerManager:k})]})]})]})}export{Ws as Toolbox};
1
+ import{r as d,aO as re,aP as ke,j as e,I as P,u as G,aQ as Ce,as as Ae,f as pe,s as v,aR as _e,k as Be,l as J,aS as U,aT as De,aH as Re,aU as Ue,C as ge,aV as M,aE as oe,aW as Ve,aX as Ke,aY as qe,aZ as Me,a_ as Ge,aA as He,E as We,S as ne,a$ as Ye,b0 as Je,aC as Ze,b1 as de,G as ie,aL as Xe,b2 as me,b3 as Qe}from"./main-CiaEK7il.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const he="deivid11/tide-commander",es=`https://api.github.com/repos/${he}/releases/latest`,ss=`https://api.github.com/repos/${he}/releases?per_page=3`,ts=3600*1e3,we="app_update_dismissed_version",Se="1.77.0";function as(){var k,C;const[s,i]=d.useState({isChecking:!1,updateAvailable:!1,updateInfo:null,recentReleases:[],error:null,currentVersion:Se}),n=((C=(k=re)==null?void 0:k.getPlatform)==null?void 0:C.call(k))==="android"||!1,o=r=>r.replace(/^v/,"").split(".").map(x=>parseInt(x,10)||0),m=(r,g)=>{const x=o(r),S=o(g),y=Math.max(x.length,S.length);for(let c=0;c<y;c++){const L=x[c]||0,R=S[c]||0;if(L>R)return 1;if(L<R)return-1}return 0},p=async r=>{var x,S;if(re&&ke&&((S=(x=re).isNativePlatform)==null?void 0:S.call(x))===!0){const y=await ke.get({url:r,headers:{Accept:"application/vnd.github.v3+json"}});return{data:y.data,status:y.status}}else{const y=await fetch(r,{headers:{Accept:"application/vnd.github.v3+json"}});return y.ok?{data:await y.json(),status:y.status}:{data:null,status:y.status}}},l=d.useCallback(async(r=!1)=>{i(g=>({...g,isChecking:!0,error:null}));try{const[g,x]=await Promise.all([p(es),p(ss)]);if(g.status!==200)throw new Error(`GitHub API error: ${g.status}`);const S=g.data,y=S.tag_name;let c=[];x.status===200&&x.data&&(c=x.data.map(w=>({version:w.tag_name,name:w.name,publishedAt:w.published_at,releaseUrl:w.html_url})));const L=localStorage.getItem(we);if(!r&&L===y)return i(w=>({...w,isChecking:!1,updateAvailable:!1,recentReleases:c})),null;if(!(m(y,Se)>0))return i(w=>({...w,isChecking:!1,updateAvailable:!1,recentReleases:c})),null;const $=S.assets.find(w=>w.name.endsWith(".apk")&&w.content_type==="application/vnd.android.package-archive"),b={version:y,name:S.name,changelog:S.body,releaseUrl:S.html_url,apkUrl:($==null?void 0:$.browser_download_url)||null,apkSize:($==null?void 0:$.size)||null,publishedAt:S.published_at};return i(w=>({...w,isChecking:!1,updateAvailable:!0,updateInfo:b,recentReleases:c})),b}catch(g){const x=g instanceof Error?g.message:"Failed to check for updates";return i(S=>({...S,isChecking:!1,error:x})),null}},[]),a=d.useCallback(async()=>{var r,g,x;if(!((r=s.updateInfo)!=null&&r.apkUrl)){(g=s.updateInfo)!=null&&g.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}if(!n){(x=s.updateInfo)!=null&&x.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}try{window.open(s.updateInfo.apkUrl,"_system"),i(S=>({...S,error:null}))}catch(S){const y=S instanceof Error?S.message:"Failed to open download";i(c=>({...c,error:y}))}},[s.updateInfo,n]),u=d.useCallback(()=>{s.updateInfo&&localStorage.setItem(we,s.updateInfo.version),i(r=>({...r,updateAvailable:!1,updateInfo:null}))},[s.updateInfo]),A=d.useCallback(()=>{var r;(r=s.updateInfo)!=null&&r.releaseUrl?window.open(s.updateInfo.releaseUrl,"_blank"):window.open(`https://github.com/${he}/releases`,"_blank")},[s.updateInfo]);return d.useEffect(()=>{if(!n)return;const r=setTimeout(()=>{l()},5e3),g=setInterval(()=>{l()},ts);return()=>{clearTimeout(r),clearInterval(g)}},[n,l]),{...s,isAndroid:n,checkForUpdate:l,downloadAndInstall:a,dismissUpdate:u,openReleasePage:A}}const Te="tide-toolbox-collapse";function ns(s,i){try{const n=localStorage.getItem(`${Te}-${s}`);if(n!==null)return n==="true"}catch{}return i}function os(s,i){try{localStorage.setItem(`${Te}-${s}`,String(i))}catch{}}function O({title:s,storageKey:i,defaultOpen:n=!1,forceOpen:o=!1,children:m,headerExtra:p}){const[l,a]=d.useState(()=>i?ns(i,n):n),u=()=>{const k=!l;a(k),i&&os(i,k)},A=o||l;return e.jsxs("div",{className:`collapsible-section ${A?"open":"collapsed"}`,children:[e.jsxs("button",{className:"collapsible-header",onClick:u,children:[e.jsx("span",{className:"collapsible-title",children:s}),e.jsxs("span",{className:"collapsible-header-right",children:[p,e.jsx("span",{className:"collapsible-arrow",children:e.jsx(P,{name:A?"caret-down":"caret-right",size:10})})]})]}),A&&e.jsx("div",{className:"collapsible-content",children:m})]})}function is({area:s,isSelected:i,onClick:n,onDelete:o}){const{t:m}=G(["config","common"]),p=s.assignedAgentIds.length,l=s.type==="rectangle"?m("config:areas.rect"):m("config:areas.circle");return e.jsxs("div",{className:`area-item ${i?"selected":""}`,onClick:n,children:[e.jsx("div",{className:"area-color-dot",style:{backgroundColor:s.color}}),e.jsxs("div",{className:"area-info",children:[e.jsx("div",{className:"area-name",children:s.name}),e.jsxs("div",{className:"area-meta",children:[l," ",p>0&&`• ${p} ${p>1?m("common:labels.agents").toLowerCase():m("common:labels.agent").toLowerCase()}`]})]}),e.jsx("button",{className:"area-delete-btn",onClick:o,title:m("config:areas.deleteArea"),children:"×"})]})}function ls({building:s,isSelected:i,onClick:n,onEdit:o}){var a;const{t:m}=G(["config"]),p=((a=s.pm2Status)==null?void 0:a.ports)||[],l=(u,A)=>{u.stopPropagation(),window.open(`http://localhost:${A}`,"_blank")};return e.jsxs("div",{className:`building-item ${i?"selected":""}`,onClick:n,children:[e.jsx("div",{className:"building-status-dot",style:{backgroundColor:Ce[s.status]},title:s.status}),e.jsx("div",{className:"building-icon",children:e.jsx(P,{name:Ae(s.type),size:16})}),e.jsxs("div",{className:"building-info",children:[e.jsx("div",{className:"building-name",children:s.name}),e.jsxs("div",{className:"building-meta",children:[s.type,p.length>0&&e.jsx("span",{className:"building-ports",children:p.map(u=>e.jsxs("a",{href:`http://localhost:${u}`,className:"building-port-link",onClick:A=>l(A,u),title:`Open :${u}`,children:[":",u]},u))})]})]}),e.jsx("button",{className:"building-edit-btn",onClick:u=>{u.stopPropagation(),o()},title:m("config:buildings.editBuilding"),children:e.jsx(P,{name:"gear",size:14})})]})}function cs({building:s,onClose:i,onOpenModal:n}){var A,k,C,r,g,x,S,y;const{t:o}=G(["config","common"]),{buildingLogs:m}=pe(),p=v.getBuildingLogs(s.id),l=_e[s.style||"server-rack"],a=c=>{v.sendBuildingCommand(s.id,c)},u=c=>{window.open(c,"_blank")};return e.jsxs("div",{className:"building-editor",children:[e.jsxs("div",{className:"building-editor-header",children:[e.jsxs("div",{className:"building-editor-title-row",children:[e.jsx("span",{className:"building-editor-icon",children:e.jsx(P,{name:Ae(s.type),size:18})}),e.jsx("span",{className:"building-editor-title",children:s.name}),e.jsx("span",{className:"building-editor-status",style:{backgroundColor:Ce[s.status]},children:s.status})]}),e.jsx("button",{className:"building-editor-close",onClick:i,children:"×"})]}),e.jsx("div",{className:"building-editor-section",children:e.jsxs("div",{className:"building-editor-info-grid",children:[e.jsxs("div",{className:"building-editor-info-item",children:[e.jsx("span",{className:"building-editor-info-label",children:o("common:labels.type")}),e.jsx("span",{className:"building-editor-info-value",children:s.type})]}),e.jsxs("div",{className:"building-editor-info-item",children:[e.jsx("span",{className:"building-editor-info-label",children:o("config:buildings.style")}),e.jsx("span",{className:"building-editor-info-value",children:l.label})]}),s.cwd&&e.jsxs("div",{className:"building-editor-info-item building-editor-info-wide",children:[e.jsx("span",{className:"building-editor-info-label",children:o("config:buildings.directory")}),e.jsx("span",{className:"building-editor-info-value building-editor-cwd",title:s.cwd,children:s.cwd.split("/").pop()||s.cwd})]})]})}),s.type==="server"&&e.jsxs("div",{className:"building-editor-section",children:[e.jsx("div",{className:"building-editor-section-title",children:o("config:buildings.actions")}),e.jsxs("div",{className:"building-editor-actions",children:[e.jsxs("button",{className:"building-editor-action-btn start",onClick:()=>a("start"),disabled:!((A=s.commands)!=null&&A.start)||s.status==="running",title:((k=s.commands)==null?void 0:k.start)||o("config:buildings.noStartCommand"),children:[e.jsx(P,{name:"play",size:12})," ",o("common:buttons.start")]}),e.jsxs("button",{className:"building-editor-action-btn stop",onClick:()=>a("stop"),disabled:!((C=s.commands)!=null&&C.stop)||s.status==="stopped",title:((r=s.commands)==null?void 0:r.stop)||o("config:buildings.noStopCommand"),children:[e.jsx(P,{name:"stop",size:12,weight:"fill"})," ",o("common:buttons.stop")]}),e.jsxs("button",{className:"building-editor-action-btn restart",onClick:()=>a("restart"),disabled:!((g=s.commands)!=null&&g.restart),title:((x=s.commands)==null?void 0:x.restart)||o("config:buildings.noRestartCommand"),children:[e.jsx(P,{name:"refresh",size:12})," ",o("common:buttons.retry")]}),e.jsxs("button",{className:"building-editor-action-btn health",onClick:()=>a("healthCheck"),disabled:!((S=s.commands)!=null&&S.healthCheck),title:((y=s.commands)==null?void 0:y.healthCheck)||o("config:buildings.noHealthCheck"),children:[e.jsx(P,{name:"heart",size:12})," Health"]})]})]}),s.urls&&s.urls.length>0&&e.jsxs("div",{className:"building-editor-section",children:[e.jsx("div",{className:"building-editor-section-title",children:o("config:buildings.links")}),e.jsx("div",{className:"building-editor-links",children:s.urls.map((c,L)=>e.jsxs("button",{className:"building-editor-link",onClick:()=>u(c.url),title:c.url,children:[e.jsx(P,{name:"link",size:12})," ",c.label||c.url]},L))})]}),p.length>0&&e.jsxs("div",{className:"building-editor-section",children:[e.jsxs("div",{className:"building-editor-section-title",children:[o("config:buildings.recentLogs"),e.jsx("button",{className:"building-editor-clear-logs",onClick:()=>v.clearBuildingLogs(s.id),title:o("common:buttons.clear"),children:o("common:buttons.clear")})]}),e.jsx("div",{className:"building-editor-logs",children:p.slice(-5).map((c,L)=>e.jsx("div",{className:"building-editor-log-entry",children:c},L))})]}),e.jsx("div",{className:"building-editor-footer",children:e.jsxs("button",{className:"building-editor-edit-btn",onClick:n,children:[e.jsx(P,{name:"gear",size:12})," ",o("config:buildings.fullSettings")]})})]})}async function rs(s,i){const n=U(),o=await fetch(J(`/api/areas/${s}/logo`),{method:"POST",headers:{"Content-Type":i.type||"image/png","X-Filename":encodeURIComponent(i.name),...n?{Authorization:`Bearer ${n}`}:{}},body:i});if(!o.ok){const m=await o.json().catch(()=>({error:o.statusText}));throw new Error(m.error||`Upload failed: ${o.statusText}`)}return o.json()}async function ds(s){const i=U(),n=await fetch(J(`/api/areas/${s}/logo`),{method:"DELETE",headers:{...i?{Authorization:`Bearer ${i}`}:{}}});if(!n.ok)throw new Error(`Failed to delete logo: ${n.statusText}`)}function ms(s){return Be(J(`/api/areas/logos/${s}`))}const us=[{key:"center",labelKey:"posCenter"},{key:"top-left",labelKey:"posTopLeft"},{key:"top-right",labelKey:"posTopRight"},{key:"bottom-left",labelKey:"posBottomLeft"},{key:"bottom-right",labelKey:"posBottomRight"}];function gs({area:s,onClose:i,onOpenFolder:n}){var Q;const{t:o}=G(["config","common"]),[m,p]=d.useState(s.name),[l,a]=d.useState(s.prompt||""),[u,A]=d.useState(!1),[k,C]=d.useState(""),[r,g]=d.useState(!1),x=d.useRef(null);d.useEffect(()=>{p(s.name)},[s.id,s.name]),d.useEffect(()=>{a(s.prompt||"")},[s.id,s.prompt]);const S=f=>{const T=f.target.value;p(T),v.updateArea(s.id,{name:T})},y=f=>{v.updateArea(s.id,{color:f})},c=f=>{const T=f.target.value;a(T),v.updateArea(s.id,{prompt:T})},L=()=>{k.trim()&&(v.addDirectoryToArea(s.id,k.trim()),C(""),A(!1))},R=(f,T)=>{T.stopPropagation(),v.removeDirectoryFromArea(s.id,f)},$=()=>{v.bringAreaToFront(s.id)},b=()=>{v.sendAreaToBack(s.id)},w=d.useCallback(()=>{let f=2,T=2;s.type==="rectangle"&&s.width&&s.height?(f=s.width,T=s.height):s.type==="circle"&&s.radius&&(f=s.radius*1.414,T=s.radius*1.414);const D=Math.min(f,T)*.4;return{width:Math.round(D*10)/10,height:Math.round(D*10)/10}},[s.type,s.width,s.height,s.radius]),Z=async f=>{var D;const T=(D=f.target.files)==null?void 0:D[0];if(T){g(!0);try{const h=await rs(s.id,T),E=w();v.updateArea(s.id,{logo:{filename:h.filename,position:"center",width:E.width,height:E.height,keepAspectRatio:!0,opacity:.8}})}catch(h){console.error("Failed to upload logo:",h)}finally{g(!1),x.current&&(x.current.value="")}}},H=async()=>{try{await ds(s.id),v.updateArea(s.id,{logo:void 0})}catch(f){console.error("Failed to remove logo:",f)}},K=f=>{s.logo&&v.updateArea(s.id,{logo:{...s.logo,position:f}})},X=f=>{if(!s.logo)return;const T=parseFloat(f.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.width>0){const D=s.logo.height/s.logo.width;v.updateArea(s.id,{logo:{...s.logo,width:T,height:Math.round(T*D*10)/10}})}else v.updateArea(s.id,{logo:{...s.logo,width:T}})},I=f=>{if(!s.logo)return;const T=parseFloat(f.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.height>0){const D=s.logo.width/s.logo.height;v.updateArea(s.id,{logo:{...s.logo,height:T,width:Math.round(T*D*10)/10}})}else v.updateArea(s.id,{logo:{...s.logo,height:T}})},W=()=>{s.logo&&v.updateArea(s.id,{logo:{...s.logo,keepAspectRatio:!s.logo.keepAspectRatio}})},te=f=>{s.logo&&v.updateArea(s.id,{logo:{...s.logo,opacity:parseFloat(f.target.value)}})};return e.jsxs("div",{className:"area-editor",children:[e.jsxs("div",{className:"area-editor-header",children:[e.jsx("span",{className:"area-editor-title",children:o("config:areas.editArea")}),e.jsx("button",{className:"area-editor-close",onClick:i,children:"×"})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("common:labels.name")}),e.jsx("input",{type:"text",className:"area-editor-input",value:m,onChange:S,placeholder:o("config:areas.areaName")})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.color")}),e.jsx("div",{className:"color-picker-row",children:De.map(f=>e.jsx("div",{className:`color-swatch ${s.color===f?"selected":""}`,style:{backgroundColor:f},onClick:()=>y(f)},f))})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.layer")}),e.jsxs("div",{className:"area-layer-buttons",children:[e.jsxs("button",{className:"area-layer-btn",onClick:$,title:o("config:areas.bringToFront"),children:[e.jsx(P,{name:"arrow-up",size:12})," ",o("config:areas.front")]}),e.jsxs("button",{className:"area-layer-btn",onClick:b,title:o("config:areas.sendToBack"),children:[e.jsx(P,{name:"arrow-down",size:12})," ",o("config:areas.back")]})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.logo")}),e.jsxs("div",{className:"area-logo-section",children:[(Q=s.logo)!=null&&Q.filename?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"area-logo-preview",children:[e.jsx("img",{src:ms(s.logo.filename),alt:"Logo",className:"area-logo-thumbnail"}),e.jsx("button",{className:"area-logo-remove-btn",onClick:H,children:o("config:areas.removeLogo")}),e.jsx("button",{className:"area-logo-replace-btn",onClick:()=>{var f;return(f=x.current)==null?void 0:f.click()},disabled:r,children:r?"...":e.jsx(P,{name:"refresh",size:12})})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoPosition")}),e.jsx("div",{className:"area-logo-position-row",children:us.map(({key:f,labelKey:T})=>{var D;return e.jsx("button",{className:`area-logo-pos-btn ${((D=s.logo)==null?void 0:D.position)===f?"active":""}`,onClick:()=>K(f),children:o(`config:areas.${T}`)},f)})})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoSize")}),e.jsxs("div",{className:"area-logo-size-row",children:[e.jsxs("label",{className:"area-logo-size-field",children:[e.jsx("span",{children:o("config:areas.logoWidth")}),e.jsx("input",{type:"number",className:"area-logo-size-input",value:s.logo.width,onChange:X,min:.1,step:.1})]}),e.jsxs("label",{className:"area-logo-size-field",children:[e.jsx("span",{children:o("config:areas.logoHeight")}),e.jsx("input",{type:"number",className:"area-logo-size-input",value:s.logo.height,onChange:I,min:.1,step:.1})]}),e.jsxs("label",{className:"area-logo-aspect-label",title:o("config:areas.keepAspectRatio"),children:[e.jsx("input",{type:"checkbox",checked:s.logo.keepAspectRatio,onChange:W}),o("config:areas.keepAspectRatio")]})]})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoOpacity")}),e.jsxs("div",{className:"area-logo-opacity-row",children:[e.jsx("input",{type:"range",min:0,max:1,step:.05,value:s.logo.opacity??.8,onChange:te,className:"area-logo-opacity-slider"}),e.jsxs("span",{className:"area-logo-opacity-value",children:[Math.round((s.logo.opacity??.8)*100),"%"]})]})]})]}):e.jsx("button",{className:"area-logo-upload-btn",onClick:()=>{var f;return(f=x.current)==null?void 0:f.click()},disabled:r,children:r?"...":o("config:areas.uploadLogo")}),e.jsx("input",{ref:x,type:"file",accept:"image/*",style:{display:"none"},onChange:Z})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.folders",{count:s.directories.length})}),e.jsxs("div",{className:"area-folders-list",children:[s.directories.map(f=>e.jsxs("div",{className:"area-folder-item",title:f,children:[e.jsx("span",{className:"area-folder-icon clickable",onClick:()=>n==null?void 0:n(s.id),title:o("config:areas.openFolder"),children:e.jsx(P,{name:"folder",size:14})}),e.jsx("span",{className:"area-folder-path",children:f.split("/").pop()||f}),e.jsx("button",{className:"area-folder-remove",onClick:T=>R(f,T),title:o("config:areas.removeFolder"),children:"×"})]},f)),u?e.jsxs("div",{className:"area-add-folder-inline",children:[e.jsx(Re,{value:k,onChange:C,onSubmit:L,placeholder:o("config:areas.folderPlaceholder"),className:"area-add-folder-input",directoriesOnly:!0,autoFocus:!0}),e.jsx("button",{className:"area-add-folder-confirm",onClick:L,children:"+"})]}):e.jsx("button",{className:"area-add-folder-btn",onClick:()=>A(!0),children:o("config:areas.addFolder")})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.prompt","Prompt")}),e.jsx("textarea",{className:"area-editor-input",value:l,onChange:c,placeholder:o("config:areas.promptPlaceholder","System prompt for agents in this area..."),rows:4,style:{resize:"vertical",fontFamily:"monospace",fontSize:12}}),e.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4},children:o("config:areas.promptHint","This prompt is injected into agents assigned to this area. Takes effect on next context refresh.")})]}),s.assignedAgentIds.length>0&&e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.assignedAgents",{count:s.assignedAgentIds.length})}),e.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:o("config:areas.rightClickUnassign")})]})]})}function ps(){const{t:s}=G(["config","common"]),i=Ue(),[n,o]=d.useState(!1),[m,p]=d.useState(null),[l,a]=d.useState({name:"",key:"",value:"",description:""}),[u,A]=d.useState(null),k=()=>{o(!0),p(null),a({name:"",key:"",value:"",description:""})},C=c=>{p(c.id),o(!1),a({name:c.name,key:c.key,value:c.value,description:c.description||""})},r=()=>{o(!1),p(null),a({name:"",key:"",value:"",description:""})},g=()=>{!l.name.trim()||!l.key.trim()||(m?v.updateSecret(m,{name:l.name.trim(),key:l.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:l.value,description:l.description.trim()||void 0}):v.createSecret({name:l.name.trim(),key:l.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:l.value,description:l.description.trim()||void 0}),r())},x=c=>{A(c)},S=()=>{u&&(v.deleteSecret(u),m===u&&r())},y=c=>{navigator.clipboard.writeText(`{{${c}}}`)};return e.jsxs("div",{className:"secrets-section",children:[e.jsx("div",{className:"secrets-description",children:s("config:secrets.description",{placeholder:"{{KEY}}"})}),e.jsx("div",{className:"secrets-list",children:i.length===0&&!n?e.jsx("div",{className:"secrets-empty",children:s("config:secrets.noSecrets")}):i.map(c=>e.jsxs("div",{className:`secret-item ${m===c.id?"editing":""}`,children:[e.jsxs("div",{className:"secret-item-header",children:[e.jsxs("div",{className:"secret-item-info",children:[e.jsx("span",{className:"secret-item-name",children:c.name}),e.jsx("code",{className:"secret-item-key",onClick:()=>y(c.key),title:s("config:secrets.copyPlaceholder"),children:`{{${c.key}}}`})]}),e.jsxs("div",{className:"secret-item-actions",children:[e.jsx("button",{className:"secret-item-btn edit",onClick:()=>C(c),title:s("common:buttons.edit"),children:e.jsx(P,{name:"edit",size:12})}),e.jsx("button",{className:"secret-item-btn delete",onClick:()=>x(c.id),title:s("common:buttons.delete"),children:"×"})]})]}),c.description&&e.jsx("div",{className:"secret-item-description",children:c.description})]},c.id))}),(n||m)&&e.jsxs("div",{className:"secret-form",children:[e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("common:labels.name")}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.namePlaceholder"),value:l.name,onChange:c=>a({...l,name:c.target.value}),autoFocus:!0})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:"Key"}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.keyPlaceholder"),value:l.key,onChange:c=>a({...l,key:c.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"")})}),e.jsx("span",{className:"secret-form-hint",children:s("config:secrets.usedAs",{placeholder:`{{${l.key||"KEY"}}}`})})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("config:secrets.secretValue")}),e.jsx("input",{type:"password",className:"secret-form-input",placeholder:s("config:secrets.valuePlaceholder"),value:l.value,onChange:c=>a({...l,value:c.target.value})})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("common:labels.description")}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.descriptionPlaceholder"),value:l.description,onChange:c=>a({...l,description:c.target.value})})]}),e.jsxs("div",{className:"secret-form-actions",children:[e.jsx("button",{className:"secret-form-btn cancel",onClick:r,children:s("common:buttons.cancel")}),e.jsx("button",{className:"secret-form-btn save",onClick:g,disabled:!l.name.trim()||!l.key.trim(),children:s(m?"config:secrets.update":"common:buttons.add")})]})]}),!n&&!m&&e.jsx("button",{className:"secrets-add-btn",onClick:k,children:s("config:secrets.addSecret")}),e.jsx(ge,{isOpen:u!==null,title:s("common:buttons.delete"),message:s("config:secrets.deleteConfirm"),confirmLabel:s("common:buttons.delete"),cancelLabel:s("common:buttons.cancel"),variant:"danger",onConfirm:S,onClose:()=>A(null)})]})}async function hs(){const s=U(),i=await fetch(`${M()}/api/agents/system-settings/prompt`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch system prompt: ${i.statusText}`);return(await i.json()).prompt||""}async function fs(s){const i=U(),n=await fetch(`${M()}/api/agents/system-settings/prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({prompt:s})});if(!n.ok)throw new Error(`Failed to update system prompt: ${n.statusText}`)}async function xs(){const s=U(),i=await fetch(`${M()}/api/agents/system-settings/prompt`,{method:"DELETE",headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to clear system prompt: ${i.statusText}`)}async function bs(){const s=U(),i=await fetch(`${M()}/api/agents/system-settings/echo-prompt`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch echo prompt setting: ${i.statusText}`);return(await i.json()).enabled||!1}async function js(s){const i=U(),n=await fetch(`${M()}/api/agents/system-settings/echo-prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!n.ok)throw new Error(`Failed to update echo prompt setting: ${n.statusText}`)}async function vs(){const s=U(),i=await fetch(`${M()}/api/agents/system-settings/codex-binary`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch codex binary path: ${i.statusText}`);return(await i.json()).path||""}async function Ns(s){const i=U(),n=await fetch(`${M()}/api/agents/system-settings/codex-binary`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({path:s})});if(!n.ok)throw new Error(`Failed to update codex binary path: ${n.statusText}`)}async function ys(){const s=U(),i=await fetch(`${M()}/api/agents/system-settings/tmux-mode`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch tmux mode setting: ${i.statusText}`);return(await i.json()).enabled||!1}async function ks(s){const i=U(),n=await fetch(`${M()}/api/agents/system-settings/tmux-mode`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!n.ok)throw new Error(`Failed to update tmux mode setting: ${n.statusText}`)}async function ws(){const s=U(),i=await fetch(`${M()}/api/agents/system-settings/backup`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch backup status: ${i.statusText}`);return i.json()}async function Ss(s){const i=U(),n=await fetch(`${M()}/api/agents/system-settings/backup`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(o.error||`Failed to update backup setting: ${n.statusText}`)}return n.json()}function Cs({checked:s,onChange:i,disabled:n}){return e.jsxs("label",{className:"config-toggle",children:[e.jsx("input",{type:"checkbox",className:"config-toggle-input",checked:s,disabled:n,onChange:o=>i(o.target.checked)}),e.jsx("span",{className:"config-toggle-track",children:e.jsx("span",{className:"config-toggle-thumb"})})]})}function As(){const{t:s}=G(["config","common"]),[i,n]=d.useState([]),[o,m]=d.useState(new Set),[p,l]=d.useState(new Set),[a,u]=d.useState(!1),[A,k]=d.useState(!1),[C,r]=d.useState(null),[g,x]=d.useState(null),[S,y]=d.useState(null),[c,L]=d.useState(null),[R,$]=d.useState(!1),[b,w]=d.useState(null);d.useEffect(()=>{oe(J("/api/config/categories")).then(h=>h.json()).then(h=>{const E=Array.isArray(h)?h:[];n(E),m(new Set(E.map(F=>F.id)))}).catch(h=>console.error("Failed to fetch config categories:",h))},[]),d.useEffect(()=>{ws().then(L).catch(h=>{console.error("Failed to fetch backup status:",h),w(h.message||"Failed to fetch backup status")})},[]);const Z=async h=>{if(!R){$(!0),w(null);try{const E=await Ss(h);L(E)}catch(E){w(E.message||"Failed to update backup setting")}finally{$(!1)}}},H=h=>{m(E=>{const F=new Set(E);return F.has(h)?F.delete(h):F.add(h),F})},K=h=>{l(E=>{const F=new Set(E);return F.has(h)?F.delete(h):F.add(h),F})},X=()=>m(new Set(i.map(h=>h.id))),I=()=>m(new Set),W=()=>{g&&l(new Set(g.categories.map(h=>h.id)))},te=()=>l(new Set),Q=async()=>{var h;if(o.size!==0){u(!0),y(null);try{const E=Array.from(o).join(","),F=await oe(J(`/api/config/export?categories=${E}`));if(!F.ok)throw new Error("Export failed");const Y=await F.blob(),q=window.URL.createObjectURL(Y),j=document.createElement("a");j.href=q;const B=F.headers.get("Content-Disposition"),le=((h=B==null?void 0:B.match(/filename="(.+)"/))==null?void 0:h[1])||"tide-commander-config.zip";j.download=le,document.body.appendChild(j),j.click(),document.body.removeChild(j),window.URL.revokeObjectURL(q),y({type:"success",text:s("config:data.exportSuccess")})}catch(E){y({type:"error",text:E.message||"Export failed"})}finally{u(!1)}}},f=async h=>{var F;const E=(F=h.target.files)==null?void 0:F[0];if(E){r(E),y(null),x(null),l(new Set);try{const Y=await oe(J("/api/config/preview"),{method:"POST",headers:{"Content-Type":"application/zip"},body:await E.arrayBuffer()});if(!Y.ok){const B=await Y.json();throw new Error(B.error||"Failed to preview config file")}const q=await Y.json(),j=Array.isArray(q.categories)?q.categories:[];x({...q,categories:j}),l(new Set(j.map(B=>B.id)))}catch(Y){y({type:"error",text:Y.message||"Failed to read config file"}),r(null)}}},T=async()=>{if(!(!C||p.size===0)){k(!0),y(null);try{const h=Array.from(p).join(","),E=await oe(J(`/api/config/import?categories=${h}`),{method:"POST",headers:{"Content-Type":"application/zip"},body:await C.arrayBuffer()}),F=await E.json();if(!E.ok)throw new Error(F.error||"Import failed");y({type:"success",text:F.message||s("config:data.importSuccess")}),r(null),x(null),l(new Set)}catch(h){y({type:"error",text:h.message||"Import failed"})}finally{k(!1)}}},D=()=>{r(null),x(null),l(new Set),y(null)};return e.jsxs("div",{className:"data-section",children:[S&&e.jsx("div",{className:`data-message data-message-${S.type}`,children:S.text}),e.jsxs("div",{className:"data-subsection",children:[e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-title",children:"Hourly Backups"}),e.jsx(Cs,{checked:!!(c!=null&&c.enabled),disabled:R||!c,onChange:Z})]}),e.jsxs("div",{className:"data-backup-info",children:[c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:["Saves a compressed snapshot of your data every hour to"," ",e.jsx("code",{children:c.backupDir}),". Identical snapshots are skipped. Keeps the 8 newest plus one from each of the 2 most recent prior days."]}),!c.scriptExists&&e.jsxs("div",{style:{marginTop:6,color:"var(--dracula-red, #ff5555)"},children:["Backup script not found at ",e.jsx("code",{children:c.scriptPath})]}),c.lastRunAt&&e.jsxs("div",{style:{marginTop:6},children:["Last run: ",new Date(c.lastRunAt).toLocaleString(),c.lastRunOk===!0&&" — ok",c.lastRunOk===!1&&c.lastRunError&&e.jsxs("span",{style:{color:"var(--dracula-red, #ff5555)"},children:[" — ",c.lastRunError]})]})]}):e.jsx("div",{children:"Loading backup status…"}),b&&e.jsx("div",{className:"data-message data-message-error",style:{marginTop:6},children:b})]})]}),e.jsxs("div",{className:"data-subsection",children:[e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-title",children:s("config:data.exportData")}),e.jsxs("div",{className:"data-select-controls",children:[e.jsx("button",{className:"data-select-btn",onClick:X,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:I,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:i.map(h=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:o.has(h.id),onChange:()=>H(h.id)}),e.jsx("span",{className:"data-category-name",children:h.name})]},h.id))}),e.jsx("button",{className:"data-action-btn export",onClick:Q,disabled:a||o.size===0,children:a?s("config:data.exporting"):s("config:data.exportCount",{count:o.size})})]}),e.jsxs("div",{className:"data-subsection",children:[e.jsx("div",{className:"data-subsection-header",children:e.jsx("span",{className:"data-subsection-title",children:s("config:data.importData")})}),C?g?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"data-import-info",children:[e.jsx("div",{className:"data-import-file",children:C.name}),e.jsxs("div",{className:"data-import-date",children:[s("config:data.exported"),": ",new Date(g.exportedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-subtitle",children:s("config:data.selectToImport")}),e.jsxs("div",{className:"data-select-controls",children:[e.jsx("button",{className:"data-select-btn",onClick:W,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:te,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:g.categories.map(h=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:p.has(h.id),onChange:()=>K(h.id)}),e.jsx("span",{className:"data-category-name",children:h.name}),h.fileCount&&e.jsxs("span",{className:"data-category-count",children:["(",h.fileCount," ",s("config:data.files"),")"]})]},h.id))}),e.jsxs("div",{className:"data-import-actions",children:[e.jsx("button",{className:"data-action-btn cancel",onClick:D,children:s("common:buttons.cancel")}),e.jsx("button",{className:"data-action-btn import",onClick:T,disabled:A||p.size===0,children:A?s("config:data.importing"):s("config:data.importCount",{count:p.size})})]})]}):e.jsx("div",{className:"data-loading",children:s("config:data.readingFile")}):e.jsxs("label",{className:"data-file-input",children:[e.jsx("input",{type:"file",accept:".zip",onChange:f,style:{display:"none"}}),e.jsx("span",{className:"data-file-input-label",children:s("config:data.selectFile")})]})]})]})}function Ts(){const[s,i]=d.useState(()=>Ve()),n=o=>{i(o);const m=qe(o);Me(m)};return e.jsx("div",{className:"theme-selector",children:e.jsx("div",{className:"theme-selector-grid",children:Ke.map(o=>e.jsxs("button",{className:`theme-option ${s===o.id?"active":""}`,onClick:()=>n(o.id),title:o.description,children:[e.jsx("div",{className:"theme-preview",children:e.jsxs("div",{className:"theme-preview-bg",style:{backgroundColor:o.colors.bgPrimary},children:[e.jsx("div",{className:"theme-preview-accent",style:{backgroundColor:o.colors.accentBlue}}),e.jsx("div",{className:"theme-preview-claude",style:{backgroundColor:o.colors.accentClaude}})]})}),e.jsx("span",{className:"theme-name",children:o.name})]},o.id))})})}function Es(){const{t:s}=G(["config"]),{updateAvailable:i,updateInfo:n,recentReleases:o,isChecking:m,error:p,currentVersion:l,isAndroid:a,checkForUpdate:u,downloadAndInstall:A,openReleasePage:k}=as(),C=g=>g?`${(g/(1024*1024)).toFixed(1)} MB`:"",r=g=>new Date(g).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"});return e.jsxs("div",{className:"about-section",children:[e.jsxs("div",{className:"about-logo",children:[e.jsx("span",{className:"about-logo-icon",children:e.jsx(P,{name:"waves",size:24})}),e.jsx("span",{className:"about-logo-text",children:"Tide Commander"})]}),e.jsxs("div",{className:"about-version",children:[e.jsx("span",{className:"about-version-label",children:s("config:about.version")}),e.jsxs("div",{className:"about-version-info",children:[e.jsx("span",{className:"about-version-value",children:l}),i&&n?e.jsx("span",{className:"about-version-update-badge",onClick:k,title:`Update available: ${n.version}`,children:n.version}):e.jsxs("a",{href:"https://github.com/deivid11/tide-commander/releases",target:"_blank",rel:"noopener noreferrer",className:"about-version-status",children:["(",s("config:about.updated"),")"]})]})]}),e.jsxs("div",{className:"about-update",children:[i&&n?e.jsxs("div",{className:"about-update-available",children:[e.jsxs("div",{className:"about-update-header",children:[e.jsx("span",{className:"about-update-badge",children:s("config:about.updateAvailable")}),e.jsx("span",{className:"about-update-version",children:n.version})]}),n.apkSize&&e.jsxs("div",{className:"about-update-size",children:[s("config:about.sizeLabel"),": ",C(n.apkSize)]}),p&&e.jsx("div",{className:"about-update-error",children:p}),e.jsxs("div",{className:"about-update-actions",children:[e.jsx("button",{className:"about-update-btn changelog",onClick:k,children:s("config:about.changelog")}),a&&n.apkUrl?e.jsx("button",{className:"about-update-btn download",onClick:A,children:s("config:about.downloadAPK")}):e.jsx("button",{className:"about-update-btn download",onClick:k,children:s("config:about.viewRelease")})]})]}):e.jsxs("div",{className:"about-update-check",children:[e.jsx("span",{className:"about-update-status",children:s(m?"config:about.checkingUpdates":"config:about.upToDate")}),e.jsx("button",{className:"about-update-btn check",onClick:()=>u(!0),disabled:m,children:m?"...":s("config:about.check")})]}),o.length>0&&e.jsxs("div",{className:"about-releases",children:[e.jsx("div",{className:"about-releases-title",children:s("config:about.recentReleases")}),e.jsx("div",{className:"about-releases-list",children:o.map(g=>e.jsxs("a",{href:g.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:`about-release-item ${g.version===`v${l}`||g.version===l?"current":""}`,children:[e.jsx("span",{className:"about-release-version",children:g.version}),e.jsx("span",{className:"about-release-date",children:r(g.publishedAt)})]},g.version))})]})]}),e.jsx("div",{className:"about-description",children:s("config:about.tagline")}),e.jsxs("div",{className:"about-principles",children:[e.jsx("div",{className:"about-principles-title",children:s("config:about.corePrinciples")}),e.jsxs("ul",{className:"about-principles-list",children:[e.jsx("li",{children:s("config:about.principle1")}),e.jsx("li",{children:s("config:about.principle2")}),e.jsx("li",{children:s("config:about.principle3")}),e.jsx("li",{children:s("config:about.principle4")})]})]}),e.jsx("div",{className:"about-links",children:e.jsxs("a",{href:"https://github.com/deivid11/tide-commander",target:"_blank",rel:"noopener noreferrer",className:"about-link",children:[e.jsx("span",{className:"about-link-icon",children:e.jsx(P,{name:"package",size:14})}),e.jsx("span",{children:s("config:about.repository")})]})}),e.jsxs("div",{className:"about-credits",children:[e.jsx("div",{className:"about-credits-title",children:s("config:about.specialThanks")}),e.jsxs("div",{className:"about-credit-item",children:[e.jsx("a",{href:"https://kenney.nl",target:"_blank",rel:"noopener noreferrer",className:"about-credit-link",children:"Kenney.nl"}),e.jsx("span",{className:"about-credit-desc",children:s("config:about.kenneyCredit")})]}),e.jsxs("div",{className:"about-credit-item",children:[e.jsx("a",{href:"https://claude.ai/code",target:"_blank",rel:"noopener noreferrer",className:"about-credit-link",children:"Claude Code"}),e.jsx("span",{className:"about-credit-desc",children:s("config:about.claudeCodeCredit")})]})]})]})}const Is={gmail:"✉️",slack:"💬",jira:"📋","google-calendar":"📅",docx:"📄"};function Ps({onOpenModal:s}){const[i,n]=d.useState([]),[o,m]=d.useState(!0),p=d.useCallback(async()=>{try{const l=await oe(J("/api/integrations"));if(!l.ok)return;const a=await l.json();n(a)}catch{}finally{m(!1)}},[]);return d.useEffect(()=>{p()},[p]),o?e.jsx("div",{style:{color:"var(--text-secondary, #a6adc8)",fontSize:12,padding:"4px 0"},children:"Loading..."}):i.length===0?e.jsx("div",{style:{color:"var(--text-secondary, #a6adc8)",fontSize:12,padding:"4px 0"},children:"No integrations available."}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[i.map(l=>{const a=Is[l.id]||"🔌",u=!!l.status.error,A=l.status.connected,k=u?"#f38ba8":A?"#a6e3a1":"#fab387",C=u?"Error":A?"Connected":"Setup Required",r=u?"✗":A?"✓":"⚠";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",borderRadius:6,background:"var(--surface-1, #181825)",border:"1px solid var(--border, #313244)",fontSize:13},children:[e.jsx("span",{style:{fontSize:15,flexShrink:0},children:a}),e.jsx("span",{style:{flex:1,color:"var(--text-primary, #cdd6f4)",fontWeight:500},children:l.name}),e.jsxs("span",{style:{color:k,fontSize:11,fontWeight:500,whiteSpace:"nowrap"},children:[r," ",C]}),e.jsx("button",{onClick:()=>s(l.id),title:`Configure ${l.name}`,style:{background:"none",border:"none",cursor:"pointer",padding:"2px 4px",fontSize:14,color:"var(--text-secondary, #a6adc8)",borderRadius:4,flexShrink:0},onMouseEnter:g=>{g.target.style.color="var(--text-primary, #cdd6f4)"},onMouseLeave:g=>{g.target.style.color="var(--text-secondary, #a6adc8)"},children:"⚙️"})]},l.id)}),e.jsx("button",{onClick:()=>s(),style:{background:"none",border:"1px dashed var(--border, #313244)",borderRadius:6,padding:"6px 8px",cursor:"pointer",color:"var(--text-secondary, #a6adc8)",fontSize:12,textAlign:"center",marginTop:2},onMouseEnter:l=>{l.target.style.borderColor="var(--accent, #89b4fa)",l.target.style.color="var(--accent, #89b4fa)"},onMouseLeave:l=>{l.target.style.borderColor="var(--border, #313244)",l.target.style.color="var(--text-secondary, #a6adc8)"},children:"Manage All Integrations"})]})}function Ls({isOpen:s,onClose:i}){const{t:n}=G(["config"]),[o,m]=d.useState(""),[p,l]=d.useState(""),[a,u]=d.useState(!0),[A,k]=d.useState(null),[C,r]=d.useState(null),[g,x]=d.useState(!1),[S,y]=d.useState(!1),[c,L]=d.useState(!1);d.useEffect(()=>{s&&R()},[s]);const R=async()=>{try{u(!0),k(null),r(null);const I=await hs();m(I),l(I),x(!1)}catch(I){k(I instanceof Error?I.message:"Failed to load system prompt")}finally{u(!1)}},$=I=>{const W=I.target.value;m(W),x(W!==p),k(null),r(null)},b=async()=>{try{k(null),r(null),await fs(o),l(o),x(!1),r(n("config:systemPrompt.saved"))}catch(I){k(I instanceof Error?I.message:"Failed to save system prompt")}},w=()=>{y(!0)},Z=async()=>{try{k(null),r(null),await xs(),m(""),l(""),x(!1),r(n("config:systemPrompt.cleared"))}catch(I){k(I instanceof Error?I.message:"Failed to clear system prompt")}},H=()=>{m(p),x(!1),k(null),r(null)},K=()=>{if(g){L(!0);return}i()},X=I=>{I.key==="Escape"&&(I.preventDefault(),K())};return s?e.jsxs(Ge,{children:[e.jsx("div",{className:`modal-overlay ${s?"visible":""}`,onClick:K,children:e.jsxs("div",{className:"system-prompt-modal",onClick:I=>I.stopPropagation(),onKeyDown:X,children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h2",{children:n("config:systemPrompt.title")}),e.jsx("button",{className:"modal-close",onClick:K,"aria-label":"Close",children:e.jsx(P,{name:"close",size:16})})]}),e.jsx("div",{className:"modal-body",children:a?e.jsxs("div",{className:"loading-state",children:[e.jsx("div",{className:"spinner"}),e.jsx("p",{children:"Loading system prompt..."})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"modal-description",children:n("config:systemPrompt.description")}),A&&e.jsxs("div",{className:"alert alert-error",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(P,{name:"warn",size:14})}),A]}),C&&e.jsxs("div",{className:"alert alert-success",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(P,{name:"check",size:14})}),C]}),e.jsxs("div",{className:"editor-wrapper",children:[e.jsxs("div",{className:"editor-header",children:[e.jsx("label",{htmlFor:"prompt-input",className:"editor-label",children:n("config:systemPrompt.editPrompt")}),e.jsxs("span",{className:"char-count",children:[o.length," ",n("config:systemPrompt.characters")]})]}),e.jsx("textarea",{id:"prompt-input",className:"prompt-editor",value:o,onChange:$,placeholder:n("config:systemPrompt.placeholder"),rows:18,autoFocus:!0}),e.jsx("div",{className:"editor-hint",children:n("config:systemPrompt.hint")})]})]})}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("div",{className:"footer-buttons-left",children:e.jsx("button",{className:"btn btn-danger",onClick:w,disabled:!o||a,children:n("config:systemPrompt.clear")})}),e.jsxs("div",{className:"footer-buttons-right",children:[e.jsx("button",{className:"btn btn-secondary",onClick:K,children:"Close"}),e.jsx("button",{className:"btn btn-secondary",onClick:H,disabled:!g||a,children:n("config:systemPrompt.reset")}),e.jsx("button",{className:"btn btn-primary",onClick:b,disabled:!g||a,children:n("config:systemPrompt.save")})]})]})]})}),e.jsx(ge,{isOpen:S,title:n("config:systemPrompt.clear"),message:n("config:systemPrompt.confirmClear"),confirmLabel:n("config:systemPrompt.clear"),cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{Z()},onClose:()=>y(!1)}),e.jsx(ge,{isOpen:c,title:"Unsaved Changes",message:"You have unsaved changes. Close anyway?",confirmLabel:"Close anyway",cancelLabel:"Keep editing",variant:"danger",onConfirm:i,onClose:()=>L(!1)})]}):null}const Fs=[{value:"auto",label:"Auto",icon:"🕐"},{value:"dawn",label:"Dawn",icon:"🌅"},{value:"day",label:"Day",icon:"☀️"},{value:"dusk",label:"Dusk",icon:"🌇"},{value:"night",label:"Night",icon:"🌙"}],Os=[{value:"none",label:"Grass",icon:"🌱"},{value:"concrete",label:"Concrete",icon:"🏗️"},{value:"galactic",label:"Galactic",icon:"🌌"},{value:"metal",label:"Metal",icon:"⚙️"},{value:"hex",label:"Hex",icon:"⬡"},{value:"circuit",label:"Circuit",icon:"🔌"},{value:"pokemon-stadium",label:"Pokemon",icon:"🔴"}],$s=[{value:"static",label:"Static",icon:"🧍"},{value:"idle",label:"Idle",icon:"🚶"},{value:"walk",label:"Walk",icon:"🚶‍♂️"},{value:"sprint",label:"Sprint",icon:"🏃"},{value:"jump",label:"Jump",icon:"⬆️"},{value:"fall",label:"Fall",icon:"⬇️"},{value:"crouch",label:"Crouch",icon:"🧎"},{value:"sit",label:"Sit",icon:"🪑"},{value:"die",label:"Die",icon:"💀"},{value:"emote-yes",label:"Yes",icon:"👍"},{value:"emote-no",label:"No",icon:"👎"}],zs=[{value:"normal",label:"Normal",icon:"🎨"},{value:"bw",label:"B&W",icon:"⬛"},{value:"sepia",label:"Sepia",icon:"🟤"},{value:"cool",label:"Cool",icon:"❄️"},{value:"warm",label:"Warm",icon:"🔥"},{value:"neon",label:"Neon",icon:"💜"}],_s=[{key:"showTrees",icon:"🌳",label:"Trees"},{key:"showBushes",icon:"🌿",label:"Bushes"},{key:"showHouse",icon:"🏠",label:"House"},{key:"showLamps",icon:"💡",label:"Lamps"},{key:"showGrass",icon:"🟩",label:"Grass"},{key:"showClouds",icon:"☁️",label:"Clouds"}],Bs=[{value:null,label:"Auto",color:"linear-gradient(135deg, #4a90d9 0%, #0a1a2a 100%)"},{value:"#4a90d9",label:"Day Blue",color:"#4a90d9"},{value:"#0a1a2a",label:"Night",color:"#0a1a2a"},{value:"#ff6b35",label:"Sunset",color:"#ff6b35"},{value:"#1a0a2e",label:"Purple",color:"#1a0a2e"},{value:"#2d5a27",label:"Matrix",color:"#2d5a27"},{value:"#8b0000",label:"Blood",color:"#8b0000"},{value:"#000000",label:"Void",color:"#000000"}],Ds={showTrees:"trees",showBushes:"bushes",showHouse:"house",showLamps:"lamps",showGrass:"grass",showClouds:"clouds"},Rs={none:"grass","pokemon-stadium":"pokemon"},Us={"emote-yes":"yes","emote-no":"no"},Vs={"":"auto","#4a90d9":"dayBlue","#0a1a2a":"night","#ff6b35":"sunset","#1a0a2e":"purple","#2d5a27":"matrix","#8b0000":"blood","#000000":"void"};function V({checked:s,onChange:i}){return e.jsxs("label",{className:"config-toggle",children:[e.jsx("input",{type:"checkbox",className:"config-toggle-input",checked:s,onChange:n=>i(n.target.checked)}),e.jsx("span",{className:"config-toggle-track",children:e.jsx("span",{className:"config-toggle-thumb"})})]})}function ae({options:s,value:i,onChange:n,iconOnly:o=!1}){return e.jsx("div",{className:"chip-selector",children:s.map(m=>e.jsxs("button",{className:`chip ${i===m.value?"active":""}`,onClick:()=>n(m.value),title:m.label,children:[e.jsx("span",{className:"chip-icon",children:m.icon}),!o&&e.jsx("span",{className:"chip-label",children:m.label})]},m.value))})}function N({text:s,query:i}){if(!i.trim())return e.jsx(e.Fragment,{children:s});const n=s.toLowerCase(),o=i.toLowerCase(),m=n.indexOf(o);if(m===-1)return e.jsx(e.Fragment,{children:s});const p=s.slice(0,m),l=s.slice(m,m+i.length),a=s.slice(m+i.length);return e.jsxs(e.Fragment,{children:[p,e.jsx("mark",{className:"search-highlight",children:l}),a]})}const Ks=[{id:"general",title:"General",keywords:["history","hide costs","grid","fps","power saving","performance","limit","editor","external editor","language","idioma","语言","vibration","haptic","intensity","tab title","tmux","process persistence"]},{id:"agentNames",title:"Agent Names",keywords:["agent","names","custom","characters","rename"]},{id:"defaultClass",title:"Default Spawn Class",keywords:["default","class","spawn","agent","scout","builder","random"]},{id:"appearance",title:"Appearance",keywords:["theme","appearance","color","dark","light","style","look"]},{id:"connection",title:"Connection",keywords:["backend","url","auth","token","reconnect","server","api","connect","codex","opencode","binary","path"]},{id:"scene",title:"Scene",keywords:["character","size","indicator","scale","time","dawn","day","dusk","night","auto"]},{id:"terrain",title:"Terrain",keywords:["trees","bushes","house","lamps","grass","clouds","fog","brightness","floor","sky","color","environment","battlefield","size","grid","simple","minimal","dark","clean"]},{id:"modelStyle",title:"Agent Model Style",keywords:["saturation","roughness","metalness","glow","emissive","reflections","wireframe","color mode","material","shader"]},{id:"animations",title:"Animations",keywords:["idle","working","animation","walk","run","sprint","jump","sit","crouch"]},{id:"secrets",title:"Secrets",keywords:["secrets","api","key","password","credentials","env","environment"]},{id:"systemPrompt",title:"System Prompt",keywords:["system","prompt","global","instructions","ai","agent","rules","guidelines"]},{id:"data",title:"Data",keywords:["export","import","backup","restore","save","load","json"]},{id:"integrations",title:"Integrations",keywords:["integrations","plugins","gmail","slack","jira","calendar","docx","email","config","setup"]},{id:"workflows",title:"Workflows",keywords:["workflow","automation","state machine","editor","actions","transitions","pipeline"]},{id:"triggers",title:"Triggers",keywords:["trigger","event","webhook","cron","slack","email","jira","matching","fire"]},{id:"monitoring",title:"Monitoring",keywords:["monitoring","logs","triggers","events","history","workflow","traces","audit","timeline"]},{id:"experimental",title:"Experimental",keywords:["experimental","2d","view","voice","assistant","speech","tts","text to speech","echo","prompt","duplicate"]},{id:"about",title:"About",keywords:["about","version","update","credits","github","releases"]}],ue=[{value:"auto",label:"Auto",icon:"🌐"},{value:"en",label:"English",icon:"🇺🇸"},{value:"zh-CN",label:"中文",icon:"🇨🇳"},{value:"es",label:"Español",icon:"🇪🇸"},{value:"hi",label:"हिन्दी",icon:"🇮🇳"},{value:"pt",label:"Português",icon:"🇧🇷"},{value:"ru",label:"Русский",icon:"🇷🇺"},{value:"ja",label:"日本語",icon:"🇯🇵"},{value:"de",label:"Deutsch",icon:"🇩🇪"},{value:"fr",label:"Français",icon:"🇫🇷"},{value:"it",label:"Italiano",icon:"🇮🇹"}];function qs({config:s,onChange:i,searchQuery:n="",onOpenIntegrationsModal:o,onOpenMonitoringModal:m,onOpenWorkflowEditor:p,onOpenTriggerManager:l}){var Ne;const{t:a}=G(["config","common"]),u=pe(),A=He(),[k,C]=d.useState(()=>We(ne.DEFAULT_AGENT_CLASS)||"scout"),[r,g]=d.useState(u.settings.historyLimit),[x,S]=d.useState(()=>Ye()),[y,c]=d.useState(!1),[L,R]=d.useState(()=>U()),[$,b]=d.useState(!1),[w,Z]=d.useState(!1),[H,K]=d.useState(""),[X,I]=d.useState(!1),[W,te]=d.useState(""),[Q,f]=d.useState(!1);d.useEffect(()=>{vs().then(te).catch(()=>{})},[]),d.useEffect(()=>{bs().then(t=>{t!==u.settings.experimentalEchoPrompt&&v.updateSettings({experimentalEchoPrompt:t})}).catch(()=>{})},[]),d.useEffect(()=>{ys().then(t=>{t!==u.settings.tmuxMode&&v.updateSettings({tmuxMode:t})}).catch(()=>{})},[]),d.useEffect(()=>Je(t=>{S(t),c(!1)}),[]);const T=Fs.map(t=>({...t,label:a(`config:time.${t.value}`)})),D=Os.map(t=>({...t,label:a(`config:floor.${Rs[t.value]||t.value}`)})),h=$s.map(t=>({...t,label:a(`config:animation.${Us[t.value]||t.value}`)})),E=zs.map(t=>({...t,label:a(`config:colorMode.${t.value}`)})),F=_s.map(t=>({...t,label:a(`config:terrain.${Ds[t.key]}`)})),Y=Bs.map(t=>({...t,label:a(`config:sky.${Vs[t.value??""]}`)})),q=n.trim()?Ks.filter(t=>{const _=n.toLowerCase();return t.title.toLowerCase().includes(_)||t.keywords.some(ce=>ce.toLowerCase().includes(_))}).map(t=>t.id):null,j=t=>q?q.includes(t):!0,B=u.settings.customAgentNames||[],le=B.length>0?B:Ze,fe=()=>{const t=H.trim();t&&!B.includes(t)&&(v.updateSettings({customAgentNames:[...B,t]}),K(""))},Ee=t=>{v.updateSettings({customAgentNames:B.filter(_=>_!==t)})},Ie=()=>{v.updateSettings({customAgentNames:[]})},Pe=t=>{S(t),c(!0)},xe=()=>{Qe(x),c(!1),me()},Le=t=>{R(t),b(!0)},be=()=>{ie(ne.AUTH_TOKEN,L),b(!1),me()},Fe=t=>{te(t),f(!0)},je=()=>{Ns(W).catch(()=>{}),f(!1)},ee=t=>{i({...s,terrain:{...s.terrain,...t}})},se=t=>{i({...s,modelStyle:{...s.modelStyle,...t}})},ve=t=>{i({...s,animations:{...s.animations,...t}})},Oe=t=>{g(t),v.updateSettings({historyLimit:t})},$e=t=>{const _=s.terrain[t];typeof _=="boolean"&&ee({[t]:!_})},z=n.trim().length>0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"config-section",children:[q&&q.length===0&&e.jsx("div",{className:"config-no-results",children:a("config:noResults",{query:n})}),j("general")&&e.jsxs(O,{title:a("config:sections.general"),storageKey:"general",defaultOpen:!0,forceOpen:z&&j("general"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:general.history"),query:n})}),e.jsx("input",{type:"number",className:"config-input config-input-sm",value:r,onChange:t=>Oe(parseInt(t.target.value)||100),min:50,max:2e3,step:50})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:general.hideCosts"),query:n})}),e.jsx(V,{checked:u.settings.hideCost,onChange:t=>v.updateSettings({hideCost:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:general.grid"),query:n})}),e.jsx(V,{checked:s.gridVisible,onChange:t=>i({...s,gridVisible:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:general.showFPS"),query:n})}),e.jsx(V,{checked:u.settings.showFPS,onChange:t=>v.updateSettings({showFPS:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:general.fpsLimit"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"120",step:"10",value:s.fpsLimit,onChange:t=>i({...s,fpsLimit:parseInt(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.fpsLimit===0?"∞":s.fpsLimit})]}),e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Experimental: Reduce FPS when idle to save power",children:[e.jsx(N,{text:a("config:general.powerSaving"),query:n})," ",e.jsx(P,{name:"bolt",size:12})]}),e.jsx(V,{checked:u.settings.powerSaving,onChange:t=>v.updateSettings({powerSaving:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",title:"Wrap agent processes in tmux sessions so they survive server restarts (requires tmux installed)",children:e.jsx(N,{text:a("config:general.tmuxMode"),query:n})}),e.jsx(V,{checked:u.settings.tmuxMode,onChange:async t=>{v.updateSettings({tmuxMode:t});try{await ks(t)}catch(_){console.error("Failed to sync tmux mode setting to server:",_)}}})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:general.vibrationIntensity"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"5",step:"1",value:u.settings.vibrationIntensity,onChange:t=>v.updateSettings({vibrationIntensity:parseInt(t.target.value)})}),e.jsx("span",{className:"config-value",children:u.settings.vibrationIntensity===0?a("config:vibrationValues.off"):u.settings.vibrationIntensity===1?a("config:vibrationValues.ultraLight"):u.settings.vibrationIntensity===2?a("config:vibrationValues.veryLight"):u.settings.vibrationIntensity===3?a("config:vibrationValues.light"):u.settings.vibrationIntensity===4?a("config:vibrationValues.medium"):a("config:vibrationValues.heavy")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:general.externalEditor"),query:n})}),e.jsx("input",{type:"text",className:"config-input",placeholder:a("config:general.externalEditorPlaceholder"),value:u.settings.externalEditorCommand||"",onChange:t=>v.updateSettings({externalEditorCommand:t.target.value})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:general.tabTitle"),query:n})}),e.jsx("input",{type:"text",className:"config-input",placeholder:a("config:general.tabTitlePlaceholder"),value:u.settings.tabTitle||"",onChange:t=>v.updateSettings({tabTitle:t.target.value})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:general.language"),query:n})}),e.jsx(ae,{options:ue,value:localStorage.getItem("tide-commander-language-mode")==="manual"?((Ne=ue.find(t=>t.value!=="auto"&&de.language.startsWith(t.value.split("-")[0])))==null?void 0:Ne.value)||"en":"auto",onChange:t=>{var _;if(t==="auto"){localStorage.setItem("tide-commander-language-mode","auto");const ce=navigator.language,ze=((_=ue.find(ye=>ye.value!=="auto"&&ce.startsWith(ye.value.split("-")[0])))==null?void 0:_.value)||"en";de.changeLanguage(ze)}else localStorage.setItem("tide-commander-language-mode","manual"),de.changeLanguage(t)}})]})]}),j("agentNames")&&e.jsx(O,{title:a("config:sections.agentNames"),storageKey:"agentNames",defaultOpen:!1,forceOpen:z&&j("agentNames"),children:e.jsxs("div",{className:"agent-names-section",children:[e.jsx("span",{className:"config-hint",children:B.length>0?a("config:agentNames.customConfigured",{count:B.length}):a("config:agentNames.usingDefaults")}),e.jsxs("div",{className:"agent-names-input-row",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",placeholder:a("config:agentNames.addPlaceholder"),value:H,onChange:t=>K(t.target.value),onKeyDown:t=>{t.key==="Enter"&&fe()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:fe,disabled:!H.trim(),title:a("config:agentNames.addName"),children:"+"})]}),e.jsx("div",{className:"agent-names-list",children:le.map((t,_)=>e.jsxs("div",{className:"agent-name-chip",children:[e.jsx("span",{className:"agent-name-text",children:t}),B.length>0&&e.jsx("button",{className:"agent-name-remove",onClick:()=>Ee(t),title:a("common:buttons.remove"),children:"x"})]},`${t}-${_}`))}),B.length>0&&e.jsx("button",{className:"config-btn config-btn-link",onClick:Ie,children:a("common:buttons.resetToDefaults")})]})}),j("defaultClass")&&e.jsx(O,{title:"Default Spawn Class",storageKey:"defaultClass",defaultOpen:!1,forceOpen:z&&j("defaultClass"),children:e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-hint",children:'Class pre-selected when the spawn modal opens. "Random" picks a different class each time.'}),e.jsxs("div",{className:"agent-names-list",style:{flexWrap:"wrap",gap:"6px",marginTop:"8px"},children:[e.jsx("div",{className:`agent-name-chip${k==="random"?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{C("random"),ie(ne.DEFAULT_AGENT_CLASS,"random")},children:e.jsx("span",{className:"agent-name-text",children:"🎲 Random"})}),Object.entries(Xe).map(([t,_])=>e.jsx("div",{className:`agent-name-chip${k===t?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{C(t),ie(ne.DEFAULT_AGENT_CLASS,t)},children:e.jsxs("span",{className:"agent-name-text",children:[_.icon," ",t.charAt(0).toUpperCase()+t.slice(1)]})},t)),A.map(t=>e.jsx("div",{className:`agent-name-chip${k===t.id?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{C(t.id),ie(ne.DEFAULT_AGENT_CLASS,t.id)},children:e.jsxs("span",{className:"agent-name-text",children:[t.icon," ",t.name]})},t.id))]})]})}),j("appearance")&&e.jsx(O,{title:a("config:sections.appearance"),storageKey:"appearance",defaultOpen:!1,forceOpen:z&&j("appearance"),children:e.jsx(Ts,{})}),j("connection")&&e.jsxs(O,{title:a("config:sections.connection"),storageKey:"connection",defaultOpen:!1,forceOpen:z&&j("connection"),children:[e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:connection.backendUrl"),query:n})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",value:x,onChange:t=>Pe(t.target.value),placeholder:"http://localhost:5174",onKeyDown:t=>{t.key==="Enter"&&y&&xe()}}),y&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:xe,title:a("config:connection.saveAndReconnect"),children:a("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:a("config:connection.autoDetectHint")})]}),e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:connection.authToken"),query:n})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:w?"text":"password",className:"config-input config-input-full",value:L,onChange:t=>Le(t.target.value),placeholder:a("config:connection.tokenPlaceholder"),onKeyDown:t=>{t.key==="Enter"&&$&&be()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>Z(!w),title:a(w?"config:connection.hideToken":"config:connection.showToken"),children:e.jsx(P,{name:w?"eye-closed":"eye",size:14})}),$&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:be,title:a("config:connection.saveAndReconnect"),children:a("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:a("config:connection.tokenRequired")})]}),e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:connection.codexBinaryPath"),query:n})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",value:W,onChange:t=>Fe(t.target.value),placeholder:a("config:connection.codexBinaryPathPlaceholder"),onKeyDown:t=>{t.key==="Enter"&&Q&&je()}}),Q&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:je,children:a("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:a("config:connection.codexBinaryPathHint")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("common:buttons.reconnect"),query:n})}),e.jsx("button",{className:"config-btn",onClick:()=>me(),title:"Force reconnect to server",children:a("common:buttons.reconnect")})]})]}),j("scene")&&e.jsxs(O,{title:a("config:sections.scene"),storageKey:"scene",defaultOpen:!1,forceOpen:z&&j("scene"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:scene.characterSize"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.3",max:"3.0",step:"0.1",value:s.characterScale,onChange:t=>i({...s,characterScale:parseFloat(t.target.value)})}),e.jsxs("span",{className:"config-value",children:[s.characterScale.toFixed(1),"x"]})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:scene.scale2d",{defaultValue:"2D Scale"}),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.3",max:"2.0",step:"0.1",value:s.scale2d,onChange:t=>i({...s,scale2d:parseFloat(t.target.value)})}),e.jsxs("span",{className:"config-value",children:[s.scale2d.toFixed(1),"x"]})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:scene.scale3d",{defaultValue:"3D Scale"}),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.3",max:"2.0",step:"0.1",value:s.scale3d,onChange:t=>i({...s,scale3d:parseFloat(t.target.value)})}),e.jsxs("span",{className:"config-value",children:[s.scale3d.toFixed(1),"x"]})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:scene.show2DTaskLabels",{defaultValue:"Show 2D task labels"}),query:n})}),e.jsx(V,{checked:s.show2DTaskLabels,onChange:t=>i({...s,show2DTaskLabels:t})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:scene.time"),query:n})}),e.jsx(ae,{options:T,value:s.timeMode,onChange:t=>i({...s,timeMode:t}),iconOnly:!0})]})]}),j("terrain")&&e.jsxs(O,{title:a("config:sections.terrain"),storageKey:"terrain",defaultOpen:!1,forceOpen:z&&j("terrain"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:terrainSettings.simpleMode",{defaultValue:"Simple Mode"}),query:n})}),e.jsx(V,{checked:s.terrain.simpleMode??!1,onChange:t=>ee({simpleMode:t})})]}),e.jsx("div",{className:"terrain-icons",style:{opacity:s.terrain.simpleMode?.4:1,pointerEvents:s.terrain.simpleMode?"none":"auto"},children:F.map(t=>e.jsx("button",{className:`terrain-icon-btn ${s.terrain[t.key]?"active":""}`,onClick:()=>$e(t.key),title:t.label,children:t.icon},t.key))}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:terrainSettings.fog"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"2",step:"0.1",value:s.terrain.fogDensity,onChange:t=>ee({fogDensity:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.fogDensity===0?a("config:fogValues.off"):s.terrain.fogDensity<=1?a("config:fogValues.low"):a("config:fogValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:terrainSettings.brightness"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.2",max:"2",step:"0.1",value:s.terrain.brightness,onChange:t=>ee({brightness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.brightness<=.5?a("config:brightnessValues.dark"):s.terrain.brightness<=1.2?a("config:brightnessValues.normal"):a("config:brightnessValues.bright")})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:terrainSettings.floor"),query:n})}),e.jsx(ae,{options:D,value:s.terrain.floorStyle,onChange:t=>ee({floorStyle:t}),iconOnly:!0})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:terrainSettings.sky"),query:n})}),e.jsx("div",{className:"sky-color-selector",children:Y.map(t=>e.jsx("button",{className:`sky-color-btn ${s.terrain.skyColor===t.value?"active":""}`,onClick:()=>ee({skyColor:t.value}),title:t.label,style:{background:t.color}},t.value??"auto"))})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:terrainSettings.battlefieldSize"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"30",max:"200",step:"10",value:s.terrain.battlefieldSize,onChange:t=>ee({battlefieldSize:parseInt(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.battlefieldSize})]})]}),j("modelStyle")&&e.jsxs(O,{title:a("config:sections.modelStyle"),storageKey:"modelStyle",defaultOpen:!1,forceOpen:z&&j("modelStyle"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:modelStyleSettings.saturation"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"2",step:"0.1",value:s.modelStyle.saturation,onChange:t=>se({saturation:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.saturation<=.3?a("config:saturationValues.gray"):s.modelStyle.saturation<=1.2?a("config:saturationValues.normal"):a("config:saturationValues.vivid")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:modelStyleSettings.roughness"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"1",step:"0.1",value:s.modelStyle.roughness,onChange:t=>se({roughness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.roughness<0?a("config:roughnessValues.auto"):s.modelStyle.roughness<=.3?a("config:roughnessValues.glossy"):s.modelStyle.roughness<=.7?a("config:roughnessValues.normal"):a("config:roughnessValues.matte")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:modelStyleSettings.metalness"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"1",step:"0.1",value:s.modelStyle.metalness,onChange:t=>se({metalness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.metalness<0?a("config:metalnessValues.auto"):s.modelStyle.metalness<=.3?a("config:metalnessValues.plastic"):s.modelStyle.metalness<=.7?a("config:metalnessValues.mixed"):a("config:metalnessValues.metal")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:modelStyleSettings.glow"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"1",step:"0.05",value:s.modelStyle.emissiveBoost,onChange:t=>se({emissiveBoost:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.emissiveBoost<=.1?a("config:glowValues.off"):s.modelStyle.emissiveBoost<=.4?a("config:glowValues.low"):s.modelStyle.emissiveBoost<=.7?a("config:glowValues.med"):a("config:glowValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:modelStyleSettings.reflections"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"2",step:"0.1",value:s.modelStyle.envMapIntensity,onChange:t=>se({envMapIntensity:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.envMapIntensity<0?a("config:reflectionValues.auto"):s.modelStyle.envMapIntensity<=.3?a("config:reflectionValues.low"):s.modelStyle.envMapIntensity<=1?a("config:reflectionValues.normal"):a("config:reflectionValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:modelStyleSettings.wireframe"),query:n})}),e.jsx(V,{checked:s.modelStyle.wireframe,onChange:t=>se({wireframe:t})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:modelStyleSettings.colorMode"),query:n})}),e.jsx(ae,{options:E,value:s.modelStyle.colorMode,onChange:t=>se({colorMode:t}),iconOnly:!0})]})]}),j("animations")&&e.jsxs(O,{title:a("config:sections.animations"),storageKey:"animations",defaultOpen:!1,forceOpen:z&&j("animations"),children:[e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:animationSettings.idle"),query:n})}),e.jsx(ae,{options:h,value:s.animations.idleAnimation,onChange:t=>ve({idleAnimation:t}),iconOnly:!0})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:animationSettings.working"),query:n})}),e.jsx(ae,{options:h,value:s.animations.workingAnimation,onChange:t=>ve({workingAnimation:t}),iconOnly:!0})]})]}),j("secrets")&&e.jsx(O,{title:a("config:sections.secrets"),storageKey:"secrets",defaultOpen:!1,forceOpen:z&&j("secrets"),children:e.jsx(ps,{})}),j("systemPrompt")&&e.jsx(O,{title:a("config:sections.systemPrompt"),storageKey:"systemPrompt",defaultOpen:!1,forceOpen:z&&j("systemPrompt"),children:e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(N,{text:a("config:systemPrompt.title"),query:n})}),e.jsx("button",{className:"config-button",onClick:()=>I(!0),children:a("config:systemPrompt.editPrompt")})]})}),j("data")&&e.jsx(O,{title:a("config:sections.data"),storageKey:"data",defaultOpen:!1,forceOpen:z&&j("data"),children:e.jsx(As,{})}),j("integrations")&&e.jsx(O,{title:"Integrations",storageKey:"integrations",defaultOpen:!1,forceOpen:z&&j("integrations"),children:e.jsx(Ps,{onOpenModal:t=>o==null?void 0:o(t)})}),j("workflows")&&e.jsxs(O,{title:"Workflows",storageKey:"workflows",defaultOpen:!1,forceOpen:z&&j("workflows"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(N,{text:"Create and manage automated workflow pipelines with visual state machine editor",query:n})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>p==null?void 0:p(),children:"Open Workflow Editor"})})]}),j("triggers")&&e.jsxs(O,{title:"Triggers",storageKey:"triggers",defaultOpen:!1,forceOpen:z&&j("triggers"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(N,{text:"Create and manage event-driven triggers that fire agents with templates",query:n})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>l==null?void 0:l(),children:"Open Trigger Manager"})})]}),j("monitoring")&&e.jsxs(O,{title:"Monitoring",storageKey:"monitoring",defaultOpen:!1,forceOpen:z&&j("monitoring"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(N,{text:"View event logs, trigger history, workflow traces, and system stats",query:n})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>m==null?void 0:m(),children:"Open Monitoring & Logs"})})]}),j("experimental")&&e.jsxs(O,{title:a("config:sections.experimental"),storageKey:"experimental",defaultOpen:!1,forceOpen:z&&j("experimental"),children:[e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Lightweight 2D top-down view for better performance",children:[e.jsx(N,{text:a("config:experimental.2dView"),query:n})," ",e.jsx(P,{name:"map",size:12})]}),e.jsx(V,{checked:u.settings.experimental2DView,onChange:t=>v.updateSettings({experimental2DView:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Voice assistant for hands-free agent control",children:[e.jsx(N,{text:a("config:experimental.voiceAssistant"),query:n})," ",e.jsx(P,{name:"microphone",size:12})]}),e.jsx(V,{checked:u.settings.experimentalVoiceAssistant,onChange:t=>v.updateSettings({experimentalVoiceAssistant:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Text-to-speech for reading agent responses",children:[e.jsx(N,{text:a("config:experimental.tts"),query:n})," ",e.jsx(P,{name:"speaker-on",size:12})]}),e.jsx(V,{checked:u.settings.experimentalTTS,onChange:t=>v.updateSettings({experimentalTTS:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",title:"Duplicate system prompt for improved LLM attention coverage. Increases input token usage.",children:e.jsx(N,{text:a("config:experimental.echoPrompt"),query:n})}),e.jsx(V,{checked:u.settings.experimentalEchoPrompt,onChange:async t=>{v.updateSettings({experimentalEchoPrompt:t});try{await js(t)}catch(_){console.error("Failed to sync echo prompt setting to server:",_)}}})]}),e.jsx("span",{className:"config-hint",children:a("config:experimental.hint")})]}),j("about")&&e.jsx(O,{title:a("config:sections.about"),storageKey:"about",defaultOpen:!1,forceOpen:z&&j("about"),children:e.jsx(Es,{})})]}),e.jsx(Ls,{isOpen:X,onClose:()=>I(!1)})]})}function Ws({onConfigChange:s,onToolChange:i,config:n,isOpen:o,onClose:m,onOpenBuildingModal:p,onOpenAreaExplorer:l,onOpenIntegrationsModal:a,onOpenMonitoringModal:u,onOpenWorkflowEditor:A,onOpenTriggerManager:k}){const{t:C}=G(["config","common"]),r=pe(),g=Array.from(r.areas.values()),x=Array.from(r.buildings.values()),[S,y]=d.useState(""),c=d.useRef(null);if(d.useEffect(()=>{const b=w=>{w.key==="Escape"&&o&&m()};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[o,m]),d.useEffect(()=>{if(o&&c.current){const b=setTimeout(()=>{var w;(w=c.current)==null||w.focus()},50);return()=>clearTimeout(b)}},[o]),!o)return null;const L=b=>{const w=r.activeTool===b?null:b;i(w)},R=b=>{v.selectArea(r.selectedAreaId===b?null:b),i("select")},$=(b,w)=>{b.stopPropagation(),v.deleteArea(w)};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"toolbox-backdrop",onClick:m}),e.jsxs("aside",{className:"toolbox",children:[e.jsxs("div",{className:"toolbox-header",children:[e.jsx("span",{children:C("config:title")}),e.jsx("button",{className:"toolbox-close-btn",onClick:m,title:C("common:buttons.close"),children:"×"})]}),e.jsxs("div",{className:"toolbox-search",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"M21 21l-4.35-4.35"})]}),e.jsx("input",{ref:c,type:"text",placeholder:C("config:searchPlaceholder"),value:S,onChange:b=>y(b.target.value),className:"toolbox-search-input"}),S&&e.jsx("button",{className:"toolbox-search-clear",onClick:()=>y(""),children:"×"})]}),e.jsxs("div",{className:"toolbox-content",children:[e.jsx("div",{className:"toolbox-section toolbox-section-collapsible",children:e.jsxs(O,{title:C("config:areas.title",{count:g.length}),storageKey:"areas",children:[e.jsxs("div",{className:"tool-buttons",children:[e.jsx("button",{className:`tool-btn ${r.activeTool==="select"?"active":""}`,onClick:()=>L("select"),title:C("config:tools.select"),children:e.jsx("span",{children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M3 3l7.07 16.97 2.51-7.39 7.39-2.51L3 3z"})})})}),e.jsx("button",{className:`tool-btn ${r.activeTool==="rectangle"?"active":""}`,onClick:()=>L("rectangle"),title:C("config:tools.rectangle"),children:e.jsx("span",{children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"})})})}),e.jsx("button",{className:`tool-btn ${r.activeTool==="circle"?"active":""}`,onClick:()=>L("circle"),title:C("config:tools.circle"),children:e.jsx("span",{children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("circle",{cx:"12",cy:"12",r:"9"})})})})]}),e.jsx("div",{className:"areas-list",children:g.length===0?e.jsx("div",{className:"areas-empty",children:C("config:areas.drawToCreate")}):g.map(b=>e.jsx(is,{area:b,isSelected:r.selectedAreaId===b.id,onClick:()=>R(b.id),onDelete:w=>$(w,b.id)},b.id))})]})}),r.selectedAreaId&&e.jsx(gs,{area:r.areas.get(r.selectedAreaId),onClose:()=>v.selectArea(null),onOpenFolder:l}),e.jsx("div",{className:"toolbox-section toolbox-section-collapsible",children:e.jsx(O,{title:C("config:buildings.title",{count:x.length}),storageKey:"buildings",headerExtra:e.jsx("button",{className:"add-building-btn",onClick:b=>{b.stopPropagation(),p==null||p()},title:C("config:buildings.addBuilding"),children:"+"}),children:e.jsx("div",{className:"buildings-list",children:x.length===0?e.jsx("div",{className:"buildings-empty",children:C("config:buildings.clickToAdd")}):x.map(b=>e.jsx(ls,{building:b,isSelected:r.selectedBuildingIds.has(b.id),onClick:()=>{v.selectBuilding(r.selectedBuildingIds.has(b.id)?null:b.id)},onEdit:()=>p==null?void 0:p(b.id)},b.id))})})}),r.selectedBuildingIds.size===1&&(()=>{const b=Array.from(r.selectedBuildingIds)[0],w=r.buildings.get(b);return w?e.jsx(cs,{building:w,onClose:()=>v.selectBuilding(null),onOpenModal:()=>p==null?void 0:p(b)}):null})(),e.jsx(qs,{config:n,onChange:s,searchQuery:S,onOpenIntegrationsModal:a,onOpenMonitoringModal:u,onOpenWorkflowEditor:A,onOpenTriggerManager:k})]})]})]})}export{Ws as Toolbox};