tide-commander 1.83.0 → 1.84.1

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 (52) hide show
  1. package/dist/assets/{BossLogsModal-Bgg8MqNZ.js → BossLogsModal-C8zRzuFy.js} +1 -1
  2. package/dist/assets/{BossSpawnModal-SQNEPxH1.js → BossSpawnModal-CeA6mhN7.js} +1 -1
  3. package/dist/assets/{ControlsModal-ImEPi76l.js → ControlsModal-CP6NB4EV.js} +1 -1
  4. package/dist/assets/{DockerLogsModal-Cs3jjehG.js → DockerLogsModal-DEgQJ1ZA.js} +1 -1
  5. package/dist/assets/{EmbeddedEditor-Cg3lq_Cv.js → EmbeddedEditor-CKvksEzA.js} +1 -1
  6. package/dist/assets/{GmailOAuthSetup-1Gh5-yZt.js → GmailOAuthSetup-DdRol00s.js} +1 -1
  7. package/dist/assets/{GoogleOAuthSetup-DmXPQyOR.js → GoogleOAuthSetup-CGV5agAn.js} +1 -1
  8. package/dist/assets/{IframeModal-BEItm7bf.js → IframeModal-hQ9wpT90.js} +1 -1
  9. package/dist/assets/{IntegrationsPanel-epI8eaV_.js → IntegrationsPanel-0DPPoL2y.js} +2 -2
  10. package/dist/assets/{LogViewerModal-B4ryb52t.js → LogViewerModal-DGVR_WfJ.js} +1 -1
  11. package/dist/assets/{MonitoringModal-CzUjqD5Y.js → MonitoringModal-FzeLMdzo.js} +1 -1
  12. package/dist/assets/{PM2LogsModal-Ex9G2Mly.js → PM2LogsModal-UqeZ-Z-C.js} +1 -1
  13. package/dist/assets/{RestoreArchivedAreaModal-DIsamY35.js → RestoreArchivedAreaModal-Dk3oNX5d.js} +1 -1
  14. package/dist/assets/{Scene2DCanvas-B5VdT-R2.js → Scene2DCanvas-BLYWui_s.js} +1 -1
  15. package/dist/assets/{SceneManager-CgkTa3Uf.js → SceneManager-Bo_ImHGE.js} +1 -1
  16. package/dist/assets/{SkillsPanel-DXxAlZbz.js → SkillsPanel-D448Eb0f.js} +1 -1
  17. package/dist/assets/{SpawnModal-_1Af5rTQ.js → SpawnModal-BMlp3ZUn.js} +1 -1
  18. package/dist/assets/{SubordinateAssignmentModal-CZ1p4KxH.js → SubordinateAssignmentModal-WdKcjuF8.js} +1 -1
  19. package/dist/assets/{TriggerManagerPanel-DnOvAQq6.js → TriggerManagerPanel-DAQz-77a.js} +1 -1
  20. package/dist/assets/{WorkflowEditorPanel-Dr896thl.js → WorkflowEditorPanel-j4Ios7kX.js} +1 -1
  21. package/dist/assets/index-BR9_mEVJ.css +1 -0
  22. package/dist/assets/index-BdGz_GAe.css +1 -0
  23. package/dist/assets/index-C8qENpYZ.js +1 -0
  24. package/dist/assets/{index-CkhtIUBY.js → index-CDxPahrR.js} +1 -1
  25. package/dist/assets/index-CQ-mkqhz.js +1 -0
  26. package/dist/assets/{index-DVqDWfDB.js → index-Cbf25fjE.js} +2 -2
  27. package/dist/assets/{index-DvRrAd9Y.js → index-Ce_6e5Xj.js} +1 -1
  28. package/dist/assets/index-CkoqkFEg.js +2 -0
  29. package/dist/assets/{index-C70mj1bd.js → index-RyuR5SvS.js} +1 -1
  30. package/dist/assets/{index-CgPa_6TH.js → index-blYiJWLh.js} +1 -1
  31. package/dist/assets/{index-OYmdvKdM.js → index-voJf2Goi.js} +3 -3
  32. package/dist/assets/main-CFu_SP_0.css +1 -0
  33. package/dist/assets/{main-CHfGSVnw.js → main-CPwivjwQ.js} +87 -87
  34. package/dist/assets/{web-rv0WAVTk.js → web-DrIhSNal.js} +1 -1
  35. package/dist/assets/{web-D1aYcbd6.js → web-DsEKGJbn.js} +1 -1
  36. package/dist/index.html +3 -3
  37. package/dist/locales/en/common.json +5 -1
  38. package/dist/locales/en/config.json +61 -0
  39. package/dist/src/packages/server/integrations/whatsapp/whatsapp-notification-publisher.js +48 -0
  40. package/dist/src/packages/server/integrations/whatsapp/whatsapp-routes.js +43 -0
  41. package/dist/src/packages/server/routes/notifications.js +12 -0
  42. package/dist/src/packages/server/services/agent-service.js +10 -0
  43. package/dist/src/packages/server/services/index.js +1 -0
  44. package/dist/src/packages/server/services/whatsapp-notification-config-service.js +120 -0
  45. package/dist/src/packages/server/websocket/handlers/notification-handler.js +12 -0
  46. package/package.json +1 -1
  47. package/dist/assets/index-B0Q9DUzT.css +0 -1
  48. package/dist/assets/index-CFb36m7S.css +0 -1
  49. package/dist/assets/index-CoUtzDXD.js +0 -2
  50. package/dist/assets/index-DCHHa29_.js +0 -1
  51. package/dist/assets/index-ave_XgRW.js +0 -1
  52. package/dist/assets/main-DmmvYoEs.css +0 -1
@@ -0,0 +1 @@
1
+ import{r as l,aP as Fe,aQ as Ve,j as e,I as L,u as ee,aR as Je,_ as Ze,f as Re,s as A,aS as es,k as ss,l as ce,aT as H,aU as as,aI as ts,aV as ns,C as re,aW as Y,aF as je,aX as is,aY as os,aZ as ls,a_ as cs,a$ as _e,b0 as rs,b1 as ds,b2 as Me,b3 as ms,b4 as ps,b5 as us,b6 as hs,b7 as gs,b8 as fs,b9 as xs,aB as bs,E as js,S as be,ba as vs,bb as Ns,aD as ws,bc as Oe,G as Se,aM as ys,bd as De,be as ks}from"./main-CPwivjwQ.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const ze="deivid11/tide-commander",Ss=`https://api.github.com/repos/${ze}/releases/latest`,Cs=`https://api.github.com/repos/${ze}/releases?per_page=3`,As=3600*1e3,qe="app_update_dismissed_version",We="1.84.1";function Ts(){var b,k;const[s,o]=l.useState({isChecking:!1,updateAvailable:!1,updateInfo:null,recentReleases:[],error:null,currentVersion:We}),a=((k=(b=Fe)==null?void 0:b.getPlatform)==null?void 0:k.call(b))==="android"||!1,i=d=>d.replace(/^v/,"").split(".").map(u=>parseInt(u,10)||0),m=(d,g)=>{const u=i(d),y=i(g),x=Math.max(u.length,y.length);for(let c=0;c<x;c++){const F=u[c]||0,_=y[c]||0;if(F>_)return 1;if(F<_)return-1}return 0},f=async d=>{var u,y;if(Fe&&Ve&&((y=(u=Fe).isNativePlatform)==null?void 0:y.call(u))===!0){const x=await Ve.get({url:d,headers:{Accept:"application/vnd.github.v3+json"}});return{data:x.data,status:x.status}}else{const x=await fetch(d,{headers:{Accept:"application/vnd.github.v3+json"}});return x.ok?{data:await x.json(),status:x.status}:{data:null,status:x.status}}},r=l.useCallback(async(d=!1)=>{o(g=>({...g,isChecking:!0,error:null}));try{const[g,u]=await Promise.all([f(Ss),f(Cs)]);if(g.status!==200)throw new Error(`GitHub API error: ${g.status}`);const y=g.data,x=y.tag_name;let c=[];u.status===200&&u.data&&(c=u.data.map(E=>({version:E.tag_name,name:E.name,publishedAt:E.published_at,releaseUrl:E.html_url})));const F=localStorage.getItem(qe);if(!d&&F===x)return o(E=>({...E,isChecking:!1,updateAvailable:!1,recentReleases:c})),null;if(!(m(x,We)>0))return o(E=>({...E,isChecking:!1,updateAvailable:!1,recentReleases:c})),null;const R=y.assets.find(E=>E.name.endsWith(".apk")&&E.content_type==="application/vnd.android.package-archive"),w={version:x,name:y.name,changelog:y.body,releaseUrl:y.html_url,apkUrl:(R==null?void 0:R.browser_download_url)||null,apkSize:(R==null?void 0:R.size)||null,publishedAt:y.published_at};return o(E=>({...E,isChecking:!1,updateAvailable:!0,updateInfo:w,recentReleases:c})),w}catch(g){const u=g instanceof Error?g.message:"Failed to check for updates";return o(y=>({...y,isChecking:!1,error:u})),null}},[]),n=l.useCallback(async()=>{var d,g,u;if(!((d=s.updateInfo)!=null&&d.apkUrl)){(g=s.updateInfo)!=null&&g.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}if(!a){(u=s.updateInfo)!=null&&u.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}try{window.open(s.updateInfo.apkUrl,"_system"),o(y=>({...y,error:null}))}catch(y){const x=y instanceof Error?y.message:"Failed to open download";o(c=>({...c,error:x}))}},[s.updateInfo,a]),h=l.useCallback(()=>{s.updateInfo&&localStorage.setItem(qe,s.updateInfo.version),o(d=>({...d,updateAvailable:!1,updateInfo:null}))},[s.updateInfo]),I=l.useCallback(()=>{var d;(d=s.updateInfo)!=null&&d.releaseUrl?window.open(s.updateInfo.releaseUrl,"_blank"):window.open(`https://github.com/${ze}/releases`,"_blank")},[s.updateInfo]);return l.useEffect(()=>{if(!a)return;const d=setTimeout(()=>{r()},5e3),g=setInterval(()=>{r()},As);return()=>{clearTimeout(d),clearInterval(g)}},[a,r]),{...s,isAndroid:a,checkForUpdate:r,downloadAndInstall:n,dismissUpdate:h,openReleasePage:I}}const Xe="tide-toolbox-collapse";function Es(s,o){try{const a=localStorage.getItem(`${Xe}-${s}`);if(a!==null)return a==="true"}catch{}return o}function Is(s,o){try{localStorage.setItem(`${Xe}-${s}`,String(o))}catch{}}function U({title:s,storageKey:o,defaultOpen:a=!1,forceOpen:i=!1,children:m,headerExtra:f}){const[r,n]=l.useState(()=>o?Es(o,a):a),h=()=>{const b=!r;n(b),o&&Is(o,b)},I=i||r;return e.jsxs("div",{className:`collapsible-section ${I?"open":"collapsed"}`,children:[e.jsxs("button",{className:"collapsible-header",onClick:h,children:[e.jsx("span",{className:"collapsible-title",children:s}),e.jsxs("span",{className:"collapsible-header-right",children:[f,e.jsx("span",{className:"collapsible-arrow",children:e.jsx(L,{name:I?"caret-down":"caret-right",size:10})})]})]}),I&&e.jsx("div",{className:"collapsible-content",children:m})]})}function Ps({area:s,isSelected:o,onClick:a,onDelete:i}){const{t:m}=ee(["config","common"]),f=s.assignedAgentIds.length,r=s.type==="rectangle"?m("config:areas.rect"):m("config:areas.circle");return e.jsxs("div",{className:`area-item ${o?"selected":""}`,onClick:a,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:[r," ",f>0&&`• ${f} ${f>1?m("common:labels.agents").toLowerCase():m("common:labels.agent").toLowerCase()}`]})]}),e.jsx("button",{className:"area-delete-btn",onClick:i,title:m("config:areas.deleteArea"),children:"×"})]})}function Ls({building:s,isSelected:o,onClick:a,onEdit:i}){var n;const{t:m}=ee(["config"]),f=((n=s.pm2Status)==null?void 0:n.ports)||[],r=(h,I)=>{h.stopPropagation(),window.open(`http://${window.location.hostname}:${I}`,"_blank")};return e.jsxs("div",{className:`building-item ${o?"selected":""}`,onClick:a,children:[e.jsx("div",{className:"building-status-dot",style:{backgroundColor:Je[s.status]},title:s.status}),e.jsx("div",{className:"building-icon",children:e.jsx(L,{name:Ze(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,f.length>0&&e.jsx("span",{className:"building-ports",children:f.map(h=>e.jsxs("a",{href:`http://${window.location.hostname}:${h}`,className:"building-port-link",onClick:I=>r(I,h),title:`Open :${h}`,children:[":",h]},h))})]})]}),e.jsx("button",{className:"building-edit-btn",onClick:h=>{h.stopPropagation(),i()},title:m("config:buildings.editBuilding"),children:e.jsx(L,{name:"gear",size:14})})]})}function Fs({building:s,onClose:o,onOpenModal:a}){var I,b,k,d,g,u,y,x;const{t:i}=ee(["config","common"]),{buildingLogs:m}=Re(),f=A.getBuildingLogs(s.id),r=es[s.style||"server-rack"],n=c=>{A.sendBuildingCommand(s.id,c)},h=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(L,{name:Ze(s.type),size:18})}),e.jsx("span",{className:"building-editor-title",children:s.name}),e.jsx("span",{className:"building-editor-status",style:{backgroundColor:Je[s.status]},children:s.status})]}),e.jsx("button",{className:"building-editor-close",onClick:o,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:i("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:i("config:buildings.style")}),e.jsx("span",{className:"building-editor-info-value",children:r.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:i("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:i("config:buildings.actions")}),e.jsxs("div",{className:"building-editor-actions",children:[e.jsxs("button",{className:"building-editor-action-btn start",onClick:()=>n("start"),disabled:!((I=s.commands)!=null&&I.start)||s.status==="running",title:((b=s.commands)==null?void 0:b.start)||i("config:buildings.noStartCommand"),children:[e.jsx(L,{name:"play",size:12})," ",i("common:buttons.start")]}),e.jsxs("button",{className:"building-editor-action-btn stop",onClick:()=>n("stop"),disabled:!((k=s.commands)!=null&&k.stop)||s.status==="stopped",title:((d=s.commands)==null?void 0:d.stop)||i("config:buildings.noStopCommand"),children:[e.jsx(L,{name:"stop",size:12,weight:"fill"})," ",i("common:buttons.stop")]}),e.jsxs("button",{className:"building-editor-action-btn restart",onClick:()=>n("restart"),disabled:!((g=s.commands)!=null&&g.restart),title:((u=s.commands)==null?void 0:u.restart)||i("config:buildings.noRestartCommand"),children:[e.jsx(L,{name:"refresh",size:12})," ",i("common:buttons.retry")]}),e.jsxs("button",{className:"building-editor-action-btn health",onClick:()=>n("healthCheck"),disabled:!((y=s.commands)!=null&&y.healthCheck),title:((x=s.commands)==null?void 0:x.healthCheck)||i("config:buildings.noHealthCheck"),children:[e.jsx(L,{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:i("config:buildings.links")}),e.jsx("div",{className:"building-editor-links",children:s.urls.map((c,F)=>e.jsxs("button",{className:"building-editor-link",onClick:()=>h(c.url),title:c.url,children:[e.jsx(L,{name:"link",size:12})," ",c.label||c.url]},F))})]}),f.length>0&&e.jsxs("div",{className:"building-editor-section",children:[e.jsxs("div",{className:"building-editor-section-title",children:[i("config:buildings.recentLogs"),e.jsx("button",{className:"building-editor-clear-logs",onClick:()=>A.clearBuildingLogs(s.id),title:i("common:buttons.clear"),children:i("common:buttons.clear")})]}),e.jsx("div",{className:"building-editor-logs",children:f.slice(-5).map((c,F)=>e.jsx("div",{className:"building-editor-log-entry",children:c},F))})]}),e.jsx("div",{className:"building-editor-footer",children:e.jsxs("button",{className:"building-editor-edit-btn",onClick:a,children:[e.jsx(L,{name:"gear",size:12})," ",i("config:buildings.fullSettings")]})})]})}async function Os(s,o){const a=H(),i=await fetch(ce(`/api/areas/${s}/logo`),{method:"POST",headers:{"Content-Type":o.type||"image/png","X-Filename":encodeURIComponent(o.name),...a?{Authorization:`Bearer ${a}`}:{}},body:o});if(!i.ok){const m=await i.json().catch(()=>({error:i.statusText}));throw new Error(m.error||`Upload failed: ${i.statusText}`)}return i.json()}async function Ds(s){const o=H(),a=await fetch(ce(`/api/areas/${s}/logo`),{method:"DELETE",headers:{...o?{Authorization:`Bearer ${o}`}:{}}});if(!a.ok)throw new Error(`Failed to delete logo: ${a.statusText}`)}function $s(s){return ss(ce(`/api/areas/logos/${s}`))}const Rs=[{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 _s({area:s,onClose:o,onOpenFolder:a}){var oe;const{t:i}=ee(["config","common"]),[m,f]=l.useState(s.name),[r,n]=l.useState(s.prompt||""),[h,I]=l.useState(!1),[b,k]=l.useState(""),[d,g]=l.useState(!1),u=l.useRef(null);l.useEffect(()=>{f(s.name)},[s.id,s.name]),l.useEffect(()=>{n(s.prompt||"")},[s.id,s.prompt]);const y=j=>{const O=j.target.value;f(O),A.updateArea(s.id,{name:O})},x=j=>{A.updateArea(s.id,{color:j})},c=j=>{const O=j.target.value;n(O),A.updateArea(s.id,{prompt:O})},F=()=>{b.trim()&&(A.addDirectoryToArea(s.id,b.trim()),k(""),I(!1))},_=(j,O)=>{O.stopPropagation(),A.removeDirectoryFromArea(s.id,j)},R=()=>{A.bringAreaToFront(s.id)},w=()=>{A.sendAreaToBack(s.id)},E=l.useCallback(()=>{let j=2,O=2;s.type==="rectangle"&&s.width&&s.height?(j=s.width,O=s.height):s.type==="circle"&&s.radius&&(j=s.radius*1.414,O=s.radius*1.414);const K=Math.min(j,O)*.4;return{width:Math.round(K*10)/10,height:Math.round(K*10)/10}},[s.type,s.width,s.height,s.radius]),V=async j=>{var K;const O=(K=j.target.files)==null?void 0:K[0];if(O){g(!0);try{const v=await Os(s.id,O),D=E();A.updateArea(s.id,{logo:{filename:v.filename,position:"center",width:D.width,height:D.height,keepAspectRatio:!0,opacity:.8}})}catch(v){console.error("Failed to upload logo:",v)}finally{g(!1),u.current&&(u.current.value="")}}},B=async()=>{try{await Ds(s.id),A.updateArea(s.id,{logo:void 0})}catch(j){console.error("Failed to remove logo:",j)}},W=j=>{s.logo&&A.updateArea(s.id,{logo:{...s.logo,position:j}})},N=j=>{if(!s.logo)return;const O=parseFloat(j.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.width>0){const K=s.logo.height/s.logo.width;A.updateArea(s.id,{logo:{...s.logo,width:O,height:Math.round(O*K*10)/10}})}else A.updateArea(s.id,{logo:{...s.logo,width:O}})},T=j=>{if(!s.logo)return;const O=parseFloat(j.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.height>0){const K=s.logo.width/s.logo.height;A.updateArea(s.id,{logo:{...s.logo,height:O,width:Math.round(O*K*10)/10}})}else A.updateArea(s.id,{logo:{...s.logo,height:O}})},M=()=>{s.logo&&A.updateArea(s.id,{logo:{...s.logo,keepAspectRatio:!s.logo.keepAspectRatio}})},se=j=>{s.logo&&A.updateArea(s.id,{logo:{...s.logo,opacity:parseFloat(j.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:i("config:areas.editArea")}),e.jsx("button",{className:"area-editor-close",onClick:o,children:"×"})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:i("common:labels.name")}),e.jsx("input",{type:"text",className:"area-editor-input",value:m,onChange:y,placeholder:i("config:areas.areaName")})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:i("config:areas.color")}),e.jsx("div",{className:"color-picker-row",children:as.map(j=>e.jsx("div",{className:`color-swatch ${s.color===j?"selected":""}`,style:{backgroundColor:j},onClick:()=>x(j)},j))})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:i("config:areas.layer")}),e.jsxs("div",{className:"area-layer-buttons",children:[e.jsxs("button",{className:"area-layer-btn",onClick:R,title:i("config:areas.bringToFront"),children:[e.jsx(L,{name:"arrow-up",size:12})," ",i("config:areas.front")]}),e.jsxs("button",{className:"area-layer-btn",onClick:w,title:i("config:areas.sendToBack"),children:[e.jsx(L,{name:"arrow-down",size:12})," ",i("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:i("config:areas.logo")}),e.jsxs("div",{className:"area-logo-section",children:[(oe=s.logo)!=null&&oe.filename?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"area-logo-preview",children:[e.jsx("img",{src:$s(s.logo.filename),alt:"Logo",className:"area-logo-thumbnail"}),e.jsx("button",{className:"area-logo-remove-btn",onClick:B,children:i("config:areas.removeLogo")}),e.jsx("button",{className:"area-logo-replace-btn",onClick:()=>{var j;return(j=u.current)==null?void 0:j.click()},disabled:d,children:d?"...":e.jsx(L,{name:"refresh",size:12})})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:i("config:areas.logoPosition")}),e.jsx("div",{className:"area-logo-position-row",children:Rs.map(({key:j,labelKey:O})=>{var K;return e.jsx("button",{className:`area-logo-pos-btn ${((K=s.logo)==null?void 0:K.position)===j?"active":""}`,onClick:()=>W(j),children:i(`config:areas.${O}`)},j)})})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:i("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:i("config:areas.logoWidth")}),e.jsx("input",{type:"number",className:"area-logo-size-input",value:s.logo.width,onChange:N,min:.1,step:.1})]}),e.jsxs("label",{className:"area-logo-size-field",children:[e.jsx("span",{children:i("config:areas.logoHeight")}),e.jsx("input",{type:"number",className:"area-logo-size-input",value:s.logo.height,onChange:T,min:.1,step:.1})]}),e.jsxs("label",{className:"area-logo-aspect-label",title:i("config:areas.keepAspectRatio"),children:[e.jsx("input",{type:"checkbox",checked:s.logo.keepAspectRatio,onChange:M}),i("config:areas.keepAspectRatio")]})]})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:i("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:se,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 j;return(j=u.current)==null?void 0:j.click()},disabled:d,children:d?"...":i("config:areas.uploadLogo")}),e.jsx("input",{ref:u,type:"file",accept:"image/*",style:{display:"none"},onChange:V})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:i("config:areas.folders",{count:s.directories.length})}),e.jsxs("div",{className:"area-folders-list",children:[s.directories.map(j=>e.jsxs("div",{className:"area-folder-item",title:j,children:[e.jsx("span",{className:"area-folder-icon clickable",onClick:()=>a==null?void 0:a(s.id),title:i("config:areas.openFolder"),children:e.jsx(L,{name:"folder",size:14})}),e.jsx("span",{className:"area-folder-path",children:j.split("/").pop()||j}),e.jsx("button",{className:"area-folder-remove",onClick:O=>_(j,O),title:i("config:areas.removeFolder"),children:"×"})]},j)),h?e.jsxs("div",{className:"area-add-folder-inline",children:[e.jsx(ts,{value:b,onChange:k,onSubmit:F,placeholder:i("config:areas.folderPlaceholder"),className:"area-add-folder-input",directoriesOnly:!0,autoFocus:!0}),e.jsx("button",{className:"area-add-folder-confirm",onClick:F,children:"+"})]}):e.jsx("button",{className:"area-add-folder-btn",onClick:()=>I(!0),children:i("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:i("config:areas.prompt","Prompt")}),e.jsx("textarea",{className:"area-editor-input",value:r,onChange:c,placeholder:i("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:i("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:i("config:areas.assignedAgents",{count:s.assignedAgentIds.length})}),e.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:i("config:areas.rightClickUnassign")})]})]})}function zs(){const{t:s}=ee(["config","common"]),o=ns(),[a,i]=l.useState(!1),[m,f]=l.useState(null),[r,n]=l.useState({name:"",key:"",value:"",description:""}),[h,I]=l.useState(null),b=()=>{i(!0),f(null),n({name:"",key:"",value:"",description:""})},k=c=>{f(c.id),i(!1),n({name:c.name,key:c.key,value:c.value,description:c.description||""})},d=()=>{i(!1),f(null),n({name:"",key:"",value:"",description:""})},g=()=>{!r.name.trim()||!r.key.trim()||(m?A.updateSecret(m,{name:r.name.trim(),key:r.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:r.value,description:r.description.trim()||void 0}):A.createSecret({name:r.name.trim(),key:r.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:r.value,description:r.description.trim()||void 0}),d())},u=c=>{I(c)},y=()=>{h&&(A.deleteSecret(h),m===h&&d())},x=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:o.length===0&&!a?e.jsx("div",{className:"secrets-empty",children:s("config:secrets.noSecrets")}):o.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:()=>x(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:()=>k(c),title:s("common:buttons.edit"),children:e.jsx(L,{name:"edit",size:12})}),e.jsx("button",{className:"secret-item-btn delete",onClick:()=>u(c.id),title:s("common:buttons.delete"),children:"×"})]})]}),c.description&&e.jsx("div",{className:"secret-item-description",children:c.description})]},c.id))}),(a||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:r.name,onChange:c=>n({...r,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:r.key,onChange:c=>n({...r,key:c.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"")})}),e.jsx("span",{className:"secret-form-hint",children:s("config:secrets.usedAs",{placeholder:`{{${r.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:r.value,onChange:c=>n({...r,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:r.description,onChange:c=>n({...r,description:c.target.value})})]}),e.jsxs("div",{className:"secret-form-actions",children:[e.jsx("button",{className:"secret-form-btn cancel",onClick:d,children:s("common:buttons.cancel")}),e.jsx("button",{className:"secret-form-btn save",onClick:g,disabled:!r.name.trim()||!r.key.trim(),children:s(m?"config:secrets.update":"common:buttons.add")})]})]}),!a&&!m&&e.jsx("button",{className:"secrets-add-btn",onClick:b,children:s("config:secrets.addSecret")}),e.jsx(re,{isOpen:h!==null,title:s("common:buttons.delete"),message:s("config:secrets.deleteConfirm"),confirmLabel:s("common:buttons.delete"),cancelLabel:s("common:buttons.cancel"),variant:"danger",onConfirm:y,onClose:()=>I(null)})]})}async function Us(){const s=H(),o=await fetch(`${Y()}/api/agents/system-settings/prompt`,{headers:{Authorization:`Bearer ${s}`}});if(!o.ok)throw new Error(`Failed to fetch system prompt: ${o.statusText}`);return(await o.json()).prompt||""}async function Bs(s){const o=H(),a=await fetch(`${Y()}/api/agents/system-settings/prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({prompt:s})});if(!a.ok)throw new Error(`Failed to update system prompt: ${a.statusText}`)}async function Ks(){const s=H(),o=await fetch(`${Y()}/api/agents/system-settings/prompt`,{method:"DELETE",headers:{Authorization:`Bearer ${s}`}});if(!o.ok)throw new Error(`Failed to clear system prompt: ${o.statusText}`)}async function Vs(){const s=H(),o=await fetch(`${Y()}/api/agents/system-settings/echo-prompt`,{headers:{Authorization:`Bearer ${s}`}});if(!o.ok)throw new Error(`Failed to fetch echo prompt setting: ${o.statusText}`);return(await o.json()).enabled||!1}async function Ms(s){const o=H(),a=await fetch(`${Y()}/api/agents/system-settings/echo-prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({enabled:s})});if(!a.ok)throw new Error(`Failed to update echo prompt setting: ${a.statusText}`)}async function qs(){const s=H(),o=await fetch(`${Y()}/api/agents/system-settings/codex-binary`,{headers:{Authorization:`Bearer ${s}`}});if(!o.ok)throw new Error(`Failed to fetch codex binary path: ${o.statusText}`);return(await o.json()).path||""}async function Ws(s){const o=H(),a=await fetch(`${Y()}/api/agents/system-settings/codex-binary`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({path:s})});if(!a.ok)throw new Error(`Failed to update codex binary path: ${a.statusText}`)}async function Hs(){const s=H(),o=await fetch(`${Y()}/api/agents/system-settings/tmux-mode`,{headers:{Authorization:`Bearer ${s}`}});if(!o.ok)throw new Error(`Failed to fetch tmux mode setting: ${o.statusText}`);return(await o.json()).enabled||!1}async function Gs(s){const o=H(),a=await fetch(`${Y()}/api/agents/system-settings/tmux-mode`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({enabled:s})});if(!a.ok)throw new Error(`Failed to update tmux mode setting: ${a.statusText}`)}async function Ys(){const s=H(),o=await fetch(`${Y()}/api/agents/system-settings/backup`,{headers:{Authorization:`Bearer ${s}`}});if(!o.ok)throw new Error(`Failed to fetch backup status: ${o.statusText}`);return o.json()}async function Js(s){const o=H(),a=await fetch(`${Y()}/api/agents/system-settings/backup`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({enabled:s})});if(!a.ok){const i=await a.json().catch(()=>({}));throw new Error(i.error||`Failed to update backup setting: ${a.statusText}`)}return a.json()}function Zs({checked:s,onChange:o,disabled:a}){return e.jsxs("label",{className:"config-toggle",children:[e.jsx("input",{type:"checkbox",className:"config-toggle-input",checked:s,disabled:a,onChange:i=>o(i.target.checked)}),e.jsx("span",{className:"config-toggle-track",children:e.jsx("span",{className:"config-toggle-thumb"})})]})}function Xs(){const{t:s}=ee(["config","common"]),[o,a]=l.useState([]),[i,m]=l.useState(new Set),[f,r]=l.useState(new Set),[n,h]=l.useState(!1),[I,b]=l.useState(!1),[k,d]=l.useState(null),[g,u]=l.useState(null),[y,x]=l.useState(null),[c,F]=l.useState(null),[_,R]=l.useState(!1),[w,E]=l.useState(null);l.useEffect(()=>{je(ce("/api/config/categories")).then(v=>v.json()).then(v=>{const D=Array.isArray(v)?v:[];a(D),m(new Set(D.map($=>$.id)))}).catch(v=>console.error("Failed to fetch config categories:",v))},[]),l.useEffect(()=>{Ys().then(F).catch(v=>{console.error("Failed to fetch backup status:",v),E(v.message||"Failed to fetch backup status")})},[]);const V=async v=>{if(!_){R(!0),E(null);try{const D=await Js(v);F(D)}catch(D){E(D.message||"Failed to update backup setting")}finally{R(!1)}}},B=v=>{m(D=>{const $=new Set(D);return $.has(v)?$.delete(v):$.add(v),$})},W=v=>{r(D=>{const $=new Set(D);return $.has(v)?$.delete(v):$.add(v),$})},N=()=>m(new Set(o.map(v=>v.id))),T=()=>m(new Set),M=()=>{g&&r(new Set(g.categories.map(v=>v.id)))},se=()=>r(new Set),oe=async()=>{var v;if(i.size!==0){h(!0),x(null);try{const D=Array.from(i).join(","),$=await je(ce(`/api/config/export?categories=${D}`));if(!$.ok)throw new Error("Export failed");const J=await $.blob(),ae=window.URL.createObjectURL(J),X=document.createElement("a");X.href=ae;const G=$.headers.get("Content-Disposition"),ge=((v=G==null?void 0:G.match(/filename="(.+)"/))==null?void 0:v[1])||"tide-commander-config.zip";X.download=ge,document.body.appendChild(X),X.click(),document.body.removeChild(X),window.URL.revokeObjectURL(ae),x({type:"success",text:s("config:data.exportSuccess")})}catch(D){x({type:"error",text:D.message||"Export failed"})}finally{h(!1)}}},j=async v=>{var $;const D=($=v.target.files)==null?void 0:$[0];if(D){d(D),x(null),u(null),r(new Set);try{const J=await je(ce("/api/config/preview"),{method:"POST",headers:{"Content-Type":"application/zip"},body:await D.arrayBuffer()});if(!J.ok){const G=await J.json();throw new Error(G.error||"Failed to preview config file")}const ae=await J.json(),X=Array.isArray(ae.categories)?ae.categories:[];u({...ae,categories:X}),r(new Set(X.map(G=>G.id)))}catch(J){x({type:"error",text:J.message||"Failed to read config file"}),d(null)}}},O=async()=>{if(!(!k||f.size===0)){b(!0),x(null);try{const v=Array.from(f).join(","),D=await je(ce(`/api/config/import?categories=${v}`),{method:"POST",headers:{"Content-Type":"application/zip"},body:await k.arrayBuffer()}),$=await D.json();if(!D.ok)throw new Error($.error||"Import failed");x({type:"success",text:$.message||s("config:data.importSuccess")}),d(null),u(null),r(new Set)}catch(v){x({type:"error",text:v.message||"Import failed"})}finally{b(!1)}}},K=()=>{d(null),u(null),r(new Set),x(null)};return e.jsxs("div",{className:"data-section",children:[y&&e.jsx("div",{className:`data-message data-message-${y.type}`,children:y.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(Zs,{checked:!!(c!=null&&c.enabled),disabled:_||!c,onChange:V})]}),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…"}),w&&e.jsx("div",{className:"data-message data-message-error",style:{marginTop:6},children:w})]})]}),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:N,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:T,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:o.map(v=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:i.has(v.id),onChange:()=>B(v.id)}),e.jsx("span",{className:"data-category-name",children:v.name})]},v.id))}),e.jsx("button",{className:"data-action-btn export",onClick:oe,disabled:n||i.size===0,children:n?s("config:data.exporting"):s("config:data.exportCount",{count:i.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")})}),k?g?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"data-import-info",children:[e.jsx("div",{className:"data-import-file",children:k.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:M,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:se,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:g.categories.map(v=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:f.has(v.id),onChange:()=>W(v.id)}),e.jsx("span",{className:"data-category-name",children:v.name}),v.fileCount&&e.jsxs("span",{className:"data-category-count",children:["(",v.fileCount," ",s("config:data.files"),")"]})]},v.id))}),e.jsxs("div",{className:"data-import-actions",children:[e.jsx("button",{className:"data-action-btn cancel",onClick:K,children:s("common:buttons.cancel")}),e.jsx("button",{className:"data-action-btn import",onClick:O,disabled:I||f.size===0,children:I?s("config:data.importing"):s("config:data.importCount",{count:f.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:j,style:{display:"none"}}),e.jsx("span",{className:"data-file-input-label",children:s("config:data.selectFile")})]})]})]})}function Qs(){const[s,o]=l.useState(()=>is()),a=i=>{o(i);const m=ls(i);cs(m)};return e.jsx("div",{className:"theme-selector",children:e.jsx("div",{className:"theme-selector-grid",children:os.map(i=>e.jsxs("button",{className:`theme-option ${s===i.id?"active":""}`,onClick:()=>a(i.id),title:i.description,children:[e.jsx("div",{className:"theme-preview",children:e.jsxs("div",{className:"theme-preview-bg",style:{backgroundColor:i.colors.bgPrimary},children:[e.jsx("div",{className:"theme-preview-accent",style:{backgroundColor:i.colors.accentBlue}}),e.jsx("div",{className:"theme-preview-claude",style:{backgroundColor:i.colors.accentClaude}})]})}),e.jsx("span",{className:"theme-name",children:i.name})]},i.id))})})}function ea(){const{t:s}=ee(["config"]),{updateAvailable:o,updateInfo:a,recentReleases:i,isChecking:m,error:f,currentVersion:r,isAndroid:n,checkForUpdate:h,downloadAndInstall:I,openReleasePage:b}=Ts(),k=g=>g?`${(g/(1024*1024)).toFixed(1)} MB`:"",d=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(L,{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:r}),o&&a?e.jsx("span",{className:"about-version-update-badge",onClick:b,title:`Update available: ${a.version}`,children:a.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:[o&&a?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:a.version})]}),a.apkSize&&e.jsxs("div",{className:"about-update-size",children:[s("config:about.sizeLabel"),": ",k(a.apkSize)]}),f&&e.jsx("div",{className:"about-update-error",children:f}),e.jsxs("div",{className:"about-update-actions",children:[e.jsx("button",{className:"about-update-btn changelog",onClick:b,children:s("config:about.changelog")}),n&&a.apkUrl?e.jsx("button",{className:"about-update-btn download",onClick:I,children:s("config:about.downloadAPK")}):e.jsx("button",{className:"about-update-btn download",onClick:b,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:()=>h(!0),disabled:m,children:m?"...":s("config:about.check")})]}),i.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:i.map(g=>e.jsxs("a",{href:g.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:`about-release-item ${g.version===`v${r}`||g.version===r?"current":""}`,children:[e.jsx("span",{className:"about-release-version",children:g.version}),e.jsx("span",{className:"about-release-date",children:d(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(L,{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 sa={gmail:"✉️",slack:"💬",jira:"📋","google-calendar":"📅",docx:"📄"};function aa({onOpenModal:s}){const[o,a]=l.useState([]),[i,m]=l.useState(!0),f=l.useCallback(async()=>{try{const r=await je(ce("/api/integrations"));if(!r.ok)return;const n=await r.json();a(n)}catch{}finally{m(!1)}},[]);return l.useEffect(()=>{f()},[f]),i?e.jsx("div",{style:{color:"var(--text-secondary, #a6adc8)",fontSize:12,padding:"4px 0"},children:"Loading..."}):o.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:[o.map(r=>{const n=sa[r.id]||"🔌",h=!!r.status.error,I=r.status.connected,b=h?"#f38ba8":I?"#a6e3a1":"#fab387",k=h?"Error":I?"Connected":"Setup Required",d=h?"✗":I?"✓":"⚠";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:n}),e.jsx("span",{style:{flex:1,color:"var(--text-primary, #cdd6f4)",fontWeight:500},children:r.name}),e.jsxs("span",{style:{color:b,fontSize:11,fontWeight:500,whiteSpace:"nowrap"},children:[d," ",k]}),e.jsx("button",{onClick:()=>s(r.id),title:`Configure ${r.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:"⚙️"})]},r.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:r=>{r.target.style.borderColor="var(--accent, #89b4fa)",r.target.style.color="var(--accent, #89b4fa)"},onMouseLeave:r=>{r.target.style.borderColor="var(--border, #313244)",r.target.style.color="var(--text-secondary, #a6adc8)"},children:"Manage All Integrations"})]})}function ta({isOpen:s,onClose:o}){const{t:a}=ee(["config"]),[i,m]=l.useState(""),[f,r]=l.useState(""),[n,h]=l.useState(!0),[I,b]=l.useState(null),[k,d]=l.useState(null),[g,u]=l.useState(!1),[y,x]=l.useState(!1),[c,F]=l.useState(!1);l.useEffect(()=>{s&&_()},[s]);const _=async()=>{try{h(!0),b(null),d(null);const T=await Us();m(T),r(T),u(!1)}catch(T){b(T instanceof Error?T.message:"Failed to load system prompt")}finally{h(!1)}},R=T=>{const M=T.target.value;m(M),u(M!==f),b(null),d(null)},w=async()=>{try{b(null),d(null),await Bs(i),r(i),u(!1),d(a("config:systemPrompt.saved"))}catch(T){b(T instanceof Error?T.message:"Failed to save system prompt")}},E=()=>{x(!0)},V=async()=>{try{b(null),d(null),await Ks(),m(""),r(""),u(!1),d(a("config:systemPrompt.cleared"))}catch(T){b(T instanceof Error?T.message:"Failed to clear system prompt")}},B=()=>{m(f),u(!1),b(null),d(null)},W=()=>{if(g){F(!0);return}o()},N=T=>{T.key==="Escape"&&(T.preventDefault(),W())};return s?e.jsxs(_e,{children:[e.jsx("div",{className:`modal-overlay ${s?"visible":""}`,onClick:W,children:e.jsxs("div",{className:"system-prompt-modal",onClick:T=>T.stopPropagation(),onKeyDown:N,children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h2",{children:a("config:systemPrompt.title")}),e.jsx("button",{className:"modal-close",onClick:W,"aria-label":"Close",children:e.jsx(L,{name:"close",size:16})})]}),e.jsx("div",{className:"modal-body",children:n?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:a("config:systemPrompt.description")}),I&&e.jsxs("div",{className:"alert alert-error",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(L,{name:"warn",size:14})}),I]}),k&&e.jsxs("div",{className:"alert alert-success",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(L,{name:"check",size:14})}),k]}),e.jsxs("div",{className:"editor-wrapper",children:[e.jsxs("div",{className:"editor-header",children:[e.jsx("label",{htmlFor:"prompt-input",className:"editor-label",children:a("config:systemPrompt.editPrompt")}),e.jsxs("span",{className:"char-count",children:[i.length," ",a("config:systemPrompt.characters")]})]}),e.jsx("textarea",{id:"prompt-input",className:"prompt-editor",value:i,onChange:R,placeholder:a("config:systemPrompt.placeholder"),rows:18,autoFocus:!0}),e.jsx("div",{className:"editor-hint",children:a("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:E,disabled:!i||n,children:a("config:systemPrompt.clear")})}),e.jsxs("div",{className:"footer-buttons-right",children:[e.jsx("button",{className:"btn btn-secondary",onClick:W,children:"Close"}),e.jsx("button",{className:"btn btn-secondary",onClick:B,disabled:!g||n,children:a("config:systemPrompt.reset")}),e.jsx("button",{className:"btn btn-primary",onClick:w,disabled:!g||n,children:a("config:systemPrompt.save")})]})]})]})}),e.jsx(re,{isOpen:y,title:a("config:systemPrompt.clear"),message:a("config:systemPrompt.confirmClear"),confirmLabel:a("config:systemPrompt.clear"),cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{V()},onClose:()=>x(!1)}),e.jsx(re,{isOpen:c,title:"Unsaved Changes",message:"You have unsaved changes. Close anyway?",confirmLabel:"Close anyway",cancelLabel:"Keep editing",variant:"danger",onConfirm:o,onClose:()=>F(!1)})]}):null}const He={enabled:!1,baseUrl:"",defaultSessionId:"",webhookVerifyToken:"",showIncomingToasts:!0},na=2500,ia=12e4;function Ge(s){return{enabled:s.enabled??!1,baseUrl:s.baseUrl??"",defaultSessionId:s.defaultSessionId??"",webhookVerifyToken:s.webhookVerifyToken??"",showIncomingToasts:s.showIncomingToasts??!0}}function oa(s,o){return s.enabled===o.enabled&&s.baseUrl===o.baseUrl&&s.defaultSessionId===o.defaultSessionId&&s.webhookVerifyToken===o.webhookVerifyToken&&s.showIncomingToasts===o.showIncomingToasts}function la({isOpen:s,onClose:o}){const{t:a}=ee(["config"]),[i,m]=l.useState(He),[f,r]=l.useState(He),[n,h]=l.useState(!1),[I,b]=l.useState([]),[k,d]=l.useState(!0),[g,u]=l.useState(null),[y,x]=l.useState(null),[c,F]=l.useState(""),[_,R]=l.useState(!1),[w,E]=l.useState(""),[V,B]=l.useState(null),[W,N]=l.useState(null),[T,M]=l.useState(null),se=l.useRef(null),oe=l.useRef(0),[j,O]=l.useState(""),[K,v]=l.useState(""),[D,$]=l.useState(null),[J,ae]=l.useState(!1),[X,G]=l.useState(!1),[ge,ve]=l.useState(!1),[Ae,de]=l.useState(!1),[S,Z]=l.useState(null),fe=!oa(i,f),te=l.useCallback(()=>{se.current&&(clearTimeout(se.current),se.current=null)},[]),Ne=l.useCallback(async()=>{try{d(!0),u(null),x(null);const[p,t]=await Promise.all([rs(),ds()]),P=Ge(p);if(m(P),r(P),h(!!t.configured),t.configured)try{const q=await Me();b(Array.isArray(q)?q:[])}catch{b([])}else b([])}catch(p){u(p instanceof Error?p.message:a("config:whatsapp.errors.loadFailed"))}finally{d(!1)}},[a]),me=l.useCallback(async()=>{try{const p=await Me();b(Array.isArray(p)?p:[])}catch{}},[]);l.useEffect(()=>(s?Ne():(te(),B(null),N(null),M(null),F(""),R(!1),$(null)),()=>{te()}),[s,Ne,te]);const le=(p,t)=>{m(P=>({...P,[p]:t})),u(null),x(null)},Te=async()=>{try{u(null),x(null);const p=await gs({enabled:i.enabled,baseUrl:i.baseUrl.trim(),defaultSessionId:i.defaultSessionId.trim(),webhookVerifyToken:i.webhookVerifyToken,showIncomingToasts:i.showIncomingToasts});window.dispatchEvent(new CustomEvent("tide:whatsapp-config-updated"));const t=Ge(p);m(t),r(t),x(a("config:whatsapp.saved"))}catch(p){u(p instanceof Error?p.message:a("config:whatsapp.errors.saveFailed"))}},we=()=>{m(f),u(null),x(null)},ue=()=>{if(fe){G(!0);return}o()},Ee=p=>{p.key==="Escape"&&(p.preventDefault(),ue())},ye=async()=>{const p=c.trim();if(p)try{u(null),x(null),await ps(p),F(""),R(!1),h(!0),x(a("config:whatsapp.apiKeySaved"))}catch(t){u(t instanceof Error?t.message:a("config:whatsapp.errors.apiKeySaveFailed"))}},Ie=()=>{ve(!0)},ke=async()=>{try{u(null),x(null),await fs(),h(!1),x(a("config:whatsapp.apiKeyCleared"))}catch(p){u(p instanceof Error?p.message:a("config:whatsapp.errors.apiKeyClearFailed"))}},ne=l.useCallback(async p=>{if(Date.now()>oe.current){M(a("config:whatsapp.pairingTimeout")),B(null),N(null),te(),me();return}try{const t=await ms(p);if(t.status&&["connected","paired","open","ready"].includes(t.status.toLowerCase())){M(a("config:whatsapp.pairingSuccess")),B(null),N(null),te(),me();return}const q=t.qrUrl??t.qr??null;q&&N(q)}catch(t){M(t instanceof Error?t.message:a("config:whatsapp.errors.qrFetchFailed"))}se.current=setTimeout(()=>{ne(p)},na)},[me,te,a]),ie=async()=>{const p=w.trim();if(p)try{u(null),x(null),M(null),N(null),te(),await us(p),E(""),B(p),oe.current=Date.now()+ia,ne(p),me()}catch(t){u(t instanceof Error?t.message:a("config:whatsapp.errors.sessionCreateFailed"))}},xe=()=>{te(),B(null),N(null),M(null)},Pe=p=>{Z(p),de(!0)},Le=async()=>{if(S)try{u(null),x(null),await xs(S),V===S&&xe(),me(),x(a("config:whatsapp.sessionDeleted"))}catch(p){u(p instanceof Error?p.message:a("config:whatsapp.errors.sessionDeleteFailed"))}finally{Z(null)}},z=async()=>{const p=j.trim(),t=K.trim();if(!(!p||!t))try{ae(!0),$(null);const P=i.defaultSessionId.trim()||void 0;await hs(p,t,P),$({kind:"success",text:a("config:whatsapp.testSent")})}catch(P){$({kind:"error",text:P instanceof Error?P.message:a("config:whatsapp.errors.testSendFailed")})}finally{ae(!1)}};return s?e.jsxs(_e,{children:[e.jsx("div",{className:`modal-overlay ${s?"visible":""}`,onClick:ue,children:e.jsxs("div",{className:"whatsapp-config-modal",onClick:p=>p.stopPropagation(),onKeyDown:Ee,children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h2",{children:a("config:whatsapp.title")}),e.jsx("button",{className:"modal-close",onClick:ue,"aria-label":"Close",children:e.jsx(L,{name:"close",size:16})})]}),e.jsx("div",{className:"modal-body",children:k?e.jsxs("div",{className:"loading-state",children:[e.jsx("div",{className:"spinner"}),e.jsx("p",{children:a("config:whatsapp.loading")})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"modal-description",children:a("config:whatsapp.description")}),g&&e.jsxs("div",{className:"alert alert-error",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(L,{name:"warn",size:14})}),g]}),y&&e.jsxs("div",{className:"alert alert-success",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(L,{name:"check",size:14})}),y]}),e.jsxs("section",{className:"wa-section",children:[e.jsx("h3",{className:"wa-section-title",children:a("config:whatsapp.sections.general")}),e.jsxs("div",{className:"wa-field wa-field-row",children:[e.jsx("label",{htmlFor:"wa-enabled",className:"wa-label",children:a("config:whatsapp.enabled")}),e.jsxs("label",{className:"wa-toggle",children:[e.jsx("input",{id:"wa-enabled",type:"checkbox",checked:i.enabled,onChange:p=>le("enabled",p.target.checked)}),e.jsx("span",{className:"wa-toggle-track",children:e.jsx("span",{className:"wa-toggle-thumb"})})]})]}),e.jsxs("div",{className:"wa-field wa-field-row",children:[e.jsx("label",{htmlFor:"wa-show-toasts",className:"wa-label",children:a("config:whatsapp.showIncomingToasts")}),e.jsxs("label",{className:"wa-toggle",children:[e.jsx("input",{id:"wa-show-toasts",type:"checkbox",checked:i.showIncomingToasts,onChange:p=>le("showIncomingToasts",p.target.checked)}),e.jsx("span",{className:"wa-toggle-track",children:e.jsx("span",{className:"wa-toggle-thumb"})})]})]}),e.jsx("span",{className:"wa-hint",children:a("config:whatsapp.showIncomingToastsHelp")}),e.jsxs("div",{className:"wa-field",children:[e.jsx("label",{htmlFor:"wa-base-url",className:"wa-label",children:a("config:whatsapp.baseUrl")}),e.jsx("input",{id:"wa-base-url",type:"text",className:"wa-input",placeholder:"http://localhost:3007",value:i.baseUrl,onChange:p=>le("baseUrl",p.target.value)})]}),e.jsxs("div",{className:"wa-field",children:[e.jsx("label",{htmlFor:"wa-default-session",className:"wa-label",children:a("config:whatsapp.defaultSessionId")}),e.jsx("input",{id:"wa-default-session",type:"text",className:"wa-input",placeholder:a("config:whatsapp.defaultSessionIdPlaceholder"),value:i.defaultSessionId,onChange:p=>le("defaultSessionId",p.target.value)})]}),e.jsxs("div",{className:"wa-field",children:[e.jsx("label",{htmlFor:"wa-webhook-token",className:"wa-label",children:a("config:whatsapp.webhookVerifyToken")}),e.jsx("input",{id:"wa-webhook-token",type:"text",className:"wa-input",placeholder:a("config:whatsapp.webhookVerifyTokenPlaceholder"),value:i.webhookVerifyToken,onChange:p=>le("webhookVerifyToken",p.target.value)})]})]}),e.jsxs("section",{className:"wa-section",children:[e.jsx("h3",{className:"wa-section-title",children:a("config:whatsapp.sections.apiKey")}),e.jsx("div",{className:"wa-key-status",children:n?e.jsxs("span",{className:"wa-status wa-status-ok",children:[e.jsx(L,{name:"check",size:12})," ",a("config:whatsapp.configured")]}):e.jsxs("span",{className:"wa-status wa-status-warn",children:[e.jsx(L,{name:"warn",size:12})," ",a("config:whatsapp.notConfigured")]})}),e.jsxs("div",{className:"wa-field wa-field-inline",children:[e.jsx("input",{type:_?"text":"password",className:"wa-input",placeholder:a("config:whatsapp.apiKeyPlaceholder"),value:c,onChange:p=>F(p.target.value)}),e.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>R(p=>!p),title:a(_?"config:whatsapp.hideKey":"config:whatsapp.showKey"),children:e.jsx(L,{name:_?"eye-closed":"eye",size:14})}),e.jsx("button",{type:"button",className:"btn btn-primary",onClick:ye,disabled:!c.trim(),children:a("config:whatsapp.saveKey")}),e.jsx("button",{type:"button",className:"btn btn-danger",onClick:Ie,disabled:!n,children:a("config:whatsapp.clearKey")})]}),e.jsx("span",{className:"wa-hint",children:a("config:whatsapp.apiKeyHint")})]}),e.jsxs("section",{className:"wa-section",children:[e.jsx("h3",{className:"wa-section-title",children:a("config:whatsapp.sections.sessions")}),e.jsx("div",{className:"wa-sessions-list",children:!Array.isArray(I)||I.length===0?e.jsx("div",{className:"wa-empty",children:a("config:whatsapp.noSessions")}):I.map(p=>e.jsxs("div",{className:"wa-session-row",children:[e.jsxs("div",{className:"wa-session-info",children:[e.jsx("span",{className:"wa-session-id",children:p.id}),e.jsx("span",{className:`wa-session-status status-${(p.status??"unknown").toLowerCase()}`,children:p.status||"—"}),p.pairedNumber&&e.jsx("span",{className:"wa-session-paired",children:p.pairedNumber})]}),e.jsx("button",{type:"button",className:"btn btn-danger btn-sm",onClick:()=>Pe(p.id),children:a("config:whatsapp.deleteSession")})]},p.id))}),e.jsxs("div",{className:"wa-field wa-field-inline",children:[e.jsx("input",{type:"text",className:"wa-input",placeholder:a("config:whatsapp.addSessionPlaceholder"),value:w,onChange:p=>E(p.target.value),onKeyDown:p=>{p.key==="Enter"&&ie()}}),e.jsx("button",{type:"button",className:"btn btn-primary",onClick:ie,disabled:!w.trim()||V!==null,children:a("config:whatsapp.addSession")})]}),V&&e.jsxs("div",{className:"wa-qr-panel",children:[e.jsxs("div",{className:"wa-qr-header",children:[e.jsx("span",{children:a("config:whatsapp.qrPrompt",{id:V})}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:xe,children:a("config:whatsapp.cancelPairing")})]}),W?e.jsx("div",{className:"wa-qr-image",children:e.jsx("img",{src:W,alt:"WhatsApp pairing QR code"})}):e.jsxs("div",{className:"wa-qr-loading",children:[e.jsx("div",{className:"spinner"}),e.jsx("p",{children:a("config:whatsapp.waitingForQr")})]})]}),T&&!V&&e.jsx("div",{className:"wa-pairing-message",children:T})]}),e.jsxs("section",{className:"wa-section",children:[e.jsx("h3",{className:"wa-section-title",children:a("config:whatsapp.sections.testMessage")}),e.jsxs("div",{className:"wa-field",children:[e.jsx("label",{htmlFor:"wa-test-to",className:"wa-label",children:a("config:whatsapp.testTo")}),e.jsx("input",{id:"wa-test-to",type:"text",className:"wa-input",placeholder:a("config:whatsapp.testToPlaceholder"),value:j,onChange:p=>O(p.target.value)})]}),e.jsxs("div",{className:"wa-field",children:[e.jsx("label",{htmlFor:"wa-test-message",className:"wa-label",children:a("config:whatsapp.testMessageBody")}),e.jsx("textarea",{id:"wa-test-message",className:"wa-textarea",rows:4,placeholder:a("config:whatsapp.testMessageBodyPlaceholder"),value:K,onChange:p=>v(p.target.value)})]}),e.jsx("div",{className:"wa-field-inline wa-field-end",children:e.jsx("button",{type:"button",className:"btn btn-primary",onClick:z,disabled:!j.trim()||!K.trim()||J,children:a(J?"config:whatsapp.sending":"config:whatsapp.sendTest")})}),D&&e.jsxs("div",{className:`alert ${D.kind==="success"?"alert-success":"alert-error"}`,children:[e.jsx("span",{className:"alert-icon",children:e.jsx(L,{name:D.kind==="success"?"check":"warn",size:14})}),D.text]})]})]})}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("div",{className:"footer-buttons-left"}),e.jsxs("div",{className:"footer-buttons-right",children:[e.jsx("button",{className:"btn btn-secondary",onClick:ue,children:a("config:whatsapp.close")}),e.jsx("button",{className:"btn btn-secondary",onClick:we,disabled:!fe||k,children:a("config:whatsapp.reset")}),e.jsx("button",{className:"btn btn-primary",onClick:Te,disabled:!fe||k,children:a("config:whatsapp.save")})]})]})]})}),e.jsx(re,{isOpen:X,title:a("config:whatsapp.unsavedTitle"),message:a("config:whatsapp.unsavedMessage"),confirmLabel:a("config:whatsapp.closeAnyway"),cancelLabel:a("config:whatsapp.keepEditing"),variant:"danger",onConfirm:()=>{G(!1),o()},onClose:()=>G(!1)}),e.jsx(re,{isOpen:ge,title:a("config:whatsapp.clearKey"),message:a("config:whatsapp.confirmClearKey"),confirmLabel:a("config:whatsapp.clearKey"),cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{ke()},onClose:()=>ve(!1)}),e.jsx(re,{isOpen:Ae,title:a("config:whatsapp.deleteSession"),message:a("config:whatsapp.confirmDeleteSession",{id:S??""}),confirmLabel:a("config:whatsapp.deleteSession"),cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{Le()},onClose:()=>{de(!1),Z(null)}})]}):null}const Qe=["messages","statusChanges","taskComplete","errors","planReady","agentSpawned","agentStopped"];function Ue(s=!1){const o=H(),a={};return o&&(a.Authorization=`Bearer ${o}`),s&&(a["Content-Type"]="application/json"),a}async function Be(s,o){try{const a=await s.json();if(a&&typeof a.error=="string")return a.error;if(a&&typeof a.message=="string")return a.message}catch{}return`${o}: ${s.statusText}`}async function ca(){const s=await fetch(`${Y()}/api/whatsapp/notification-config`,{headers:Ue()});if(!s.ok)throw new Error(await Be(s,"Failed to fetch WhatsApp notification config"));return s.json()}async function ra(s){const o=await fetch(`${Y()}/api/whatsapp/notification-config`,{method:"PATCH",headers:Ue(!0),body:JSON.stringify(s)});if(!o.ok)throw new Error(await Be(o,"Failed to update WhatsApp notification config"));return o.json()}async function da(){const s=await fetch(`${Y()}/api/whatsapp/notification-config`,{method:"DELETE",headers:Ue()});if(!s.ok)throw new Error(await Be(s,"Failed to reset WhatsApp notification config"));return s.json()}const Ce={messages:!0,statusChanges:!0,taskComplete:!0,errors:!0,planReady:!0,agentSpawned:!0,agentStopped:!0},Ye={filter:{...Ce},recipient:""};function ma(s,o){if(s.recipient!==o.recipient)return!1;for(const a of Qe)if(s.filter[a]!==o.filter[a])return!1;return!0}function pa({isOpen:s,onClose:o}){const{t:a}=ee(["config"]),[i,m]=l.useState(Ye),[f,r]=l.useState(Ye),[n,h]=l.useState(!0),[I,b]=l.useState(null),[k,d]=l.useState(null),[g,u]=l.useState(!1),[y,x]=l.useState(!1),c=!ma(i,f),F=l.useCallback(async()=>{try{h(!0),b(null),d(null);const N=await ca(),T={filter:{...Ce,...N.filter},recipient:N.recipient??""};m(T),r(T)}catch(N){b(N instanceof Error?N.message:a("config:whatsappNotifications.errors.loadFailed"))}finally{h(!1)}},[a]);l.useEffect(()=>{s&&F()},[s,F]);const _=(N,T)=>{m(M=>({...M,filter:{...M.filter,[N]:T}})),b(null),d(null)},R=N=>{m(T=>({...T,recipient:N})),b(null),d(null)},w=async()=>{try{b(null),d(null);const N=await ra({filter:i.filter,recipient:i.recipient.trim()}),T={filter:{...Ce,...N.filter},recipient:N.recipient??""};m(T),r(T),d(a("config:whatsappNotifications.saved"))}catch(N){b(N instanceof Error?N.message:a("config:whatsappNotifications.errors.saveFailed"))}},E=()=>{m(f),b(null),d(null)},V=async()=>{try{b(null),d(null);const N=await da(),T={filter:{...Ce,...N.filter},recipient:N.recipient??""};m(T),r(T),d(a("config:whatsappNotifications.resetDone"))}catch(N){b(N instanceof Error?N.message:a("config:whatsappNotifications.errors.resetFailed"))}},B=()=>{if(c){u(!0);return}o()},W=N=>{N.key==="Escape"&&(N.preventDefault(),B())};return s?e.jsxs(_e,{children:[e.jsx("div",{className:`modal-overlay ${s?"visible":""}`,onClick:B,children:e.jsxs("div",{className:"whatsapp-notifications-modal",onClick:N=>N.stopPropagation(),onKeyDown:W,children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h2",{children:a("config:whatsappNotifications.title")}),e.jsx("button",{className:"modal-close",onClick:B,"aria-label":"Close",children:e.jsx(L,{name:"close",size:16})})]}),e.jsx("div",{className:"modal-body",children:n?e.jsxs("div",{className:"loading-state",children:[e.jsx("div",{className:"spinner"}),e.jsx("p",{children:a("config:whatsappNotifications.loading")})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"modal-description",children:a("config:whatsappNotifications.description")}),I&&e.jsxs("div",{className:"alert alert-error",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(L,{name:"warn",size:14})}),I]}),k&&e.jsxs("div",{className:"alert alert-success",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(L,{name:"check",size:14})}),k]}),e.jsxs("section",{className:"wan-section",children:[e.jsx("h3",{className:"wan-section-title",children:a("config:whatsappNotifications.sections.recipient")}),e.jsxs("div",{className:"wan-field",children:[e.jsx("label",{htmlFor:"wan-recipient",className:"wan-label",children:a("config:whatsappNotifications.recipientLabel")}),e.jsx("input",{id:"wan-recipient",type:"text",className:"wan-input",placeholder:a("config:whatsappNotifications.recipientPlaceholder"),value:i.recipient,onChange:N=>R(N.target.value)}),e.jsx("span",{className:"wan-hint",children:a("config:whatsappNotifications.recipientHint")})]})]}),e.jsxs("section",{className:"wan-section",children:[e.jsx("h3",{className:"wan-section-title",children:a("config:whatsappNotifications.sections.events")}),e.jsx("p",{className:"wan-section-hint",children:a("config:whatsappNotifications.eventsHint")}),Qe.map(N=>e.jsxs("div",{className:"wan-toggle-row",children:[e.jsxs("div",{className:"wan-toggle-info",children:[e.jsx("span",{className:"wan-toggle-title",children:a(`config:whatsappNotifications.events.${N}.title`)}),e.jsx("span",{className:"wan-toggle-help",children:a(`config:whatsappNotifications.events.${N}.help`)})]}),e.jsxs("label",{className:"wan-toggle",children:[e.jsx("input",{type:"checkbox",checked:i.filter[N],onChange:T=>_(N,T.target.checked)}),e.jsx("span",{className:"wan-toggle-track",children:e.jsx("span",{className:"wan-toggle-thumb"})})]})]},N))]})]})}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("div",{className:"footer-buttons-left",children:e.jsx("button",{className:"btn btn-danger",onClick:()=>x(!0),disabled:n,children:a("config:whatsappNotifications.resetToDefaults")})}),e.jsxs("div",{className:"footer-buttons-right",children:[e.jsx("button",{className:"btn btn-secondary",onClick:B,children:a("config:whatsappNotifications.close")}),e.jsx("button",{className:"btn btn-secondary",onClick:E,disabled:!c||n,children:a("config:whatsappNotifications.reset")}),e.jsx("button",{className:"btn btn-primary",onClick:w,disabled:!c||n,children:a("config:whatsappNotifications.save")})]})]})]})}),e.jsx(re,{isOpen:g,title:a("config:whatsappNotifications.unsavedTitle"),message:a("config:whatsappNotifications.unsavedMessage"),confirmLabel:a("config:whatsappNotifications.closeAnyway"),cancelLabel:a("config:whatsappNotifications.keepEditing"),variant:"danger",onConfirm:()=>{u(!1),o()},onClose:()=>u(!1)}),e.jsx(re,{isOpen:y,title:a("config:whatsappNotifications.resetToDefaults"),message:a("config:whatsappNotifications.confirmReset"),confirmLabel:a("config:whatsappNotifications.resetToDefaults"),cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{V(),x(!1)},onClose:()=>x(!1)})]}):null}const ua=[{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:"🌙"}],ha=[{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:"🔴"}],ga=[{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:"👎"}],fa=[{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:"💜"}],xa=[{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"}],ba=[{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"}],ja={showTrees:"trees",showBushes:"bushes",showHouse:"house",showLamps:"lamps",showGrass:"grass",showClouds:"clouds"},va={none:"grass","pokemon-stadium":"pokemon"},Na={"emote-yes":"yes","emote-no":"no"},wa={"":"auto","#4a90d9":"dayBlue","#0a1a2a":"night","#ff6b35":"sunset","#1a0a2e":"purple","#2d5a27":"matrix","#8b0000":"blood","#000000":"void"};function Q({checked:s,onChange:o}){return e.jsxs("label",{className:"config-toggle",children:[e.jsx("input",{type:"checkbox",className:"config-toggle-input",checked:s,onChange:a=>o(a.target.checked)}),e.jsx("span",{className:"config-toggle-track",children:e.jsx("span",{className:"config-toggle-thumb"})})]})}function he({options:s,value:o,onChange:a,iconOnly:i=!1}){return e.jsx("div",{className:"chip-selector",children:s.map(m=>e.jsxs("button",{className:`chip ${o===m.value?"active":""}`,onClick:()=>a(m.value),title:m.label,children:[e.jsx("span",{className:"chip-icon",children:m.icon}),!i&&e.jsx("span",{className:"chip-label",children:m.label})]},m.value))})}function C({text:s,query:o}){if(!o.trim())return e.jsx(e.Fragment,{children:s});const a=s.toLowerCase(),i=o.toLowerCase(),m=a.indexOf(i);if(m===-1)return e.jsx(e.Fragment,{children:s});const f=s.slice(0,m),r=s.slice(m,m+o.length),n=s.slice(m+o.length);return e.jsxs(e.Fragment,{children:[f,e.jsx("mark",{className:"search-highlight",children:r}),n]})}const ya=[{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:"whatsapp",title:"WhatsApp Integration",keywords:["whatsapp","message","sms","integration","notification","baileys"]},{id:"whatsappNotifications",title:"WhatsApp Notifications",keywords:["whatsapp","notification","notifications","messages","status","toggle","filter","event","subscribe","plan","error","spawned","stopped"]},{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"]}],$e=[{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 ka({config:s,onChange:o,searchQuery:a="",onOpenIntegrationsModal:i,onOpenMonitoringModal:m,onOpenWorkflowEditor:f,onOpenTriggerManager:r}){var p;const{t:n}=ee(["config","common"]),h=Re(),I=bs(),[b,k]=l.useState(()=>js(be.DEFAULT_AGENT_CLASS)||"scout"),[d,g]=l.useState(h.settings.historyLimit),[u,y]=l.useState(()=>vs()),[x,c]=l.useState(!1),[F,_]=l.useState(""),[R,w]=l.useState(()=>H()),[E,V]=l.useState(!1),[B,W]=l.useState(!1),[N,T]=l.useState(""),[M,se]=l.useState(!1),[oe,j]=l.useState(!1),[O,K]=l.useState(!1),[v,D]=l.useState(""),[$,J]=l.useState(!1);l.useEffect(()=>{qs().then(D).catch(()=>{})},[]),l.useEffect(()=>{Vs().then(t=>{t!==h.settings.experimentalEchoPrompt&&A.updateSettings({experimentalEchoPrompt:t})}).catch(()=>{})},[]),l.useEffect(()=>{Hs().then(t=>{t!==h.settings.tmuxMode&&A.updateSettings({tmuxMode:t})}).catch(()=>{})},[]),l.useEffect(()=>Ns(t=>{y(t),c(!1)}),[]);const ae=ua.map(t=>({...t,label:n(`config:time.${t.value}`)})),X=ha.map(t=>({...t,label:n(`config:floor.${va[t.value]||t.value}`)})),G=ga.map(t=>({...t,label:n(`config:animation.${Na[t.value]||t.value}`)})),ge=fa.map(t=>({...t,label:n(`config:colorMode.${t.value}`)})),ve=xa.map(t=>({...t,label:n(`config:terrain.${ja[t.key]}`)})),Ae=ba.map(t=>({...t,label:n(`config:sky.${wa[t.value??""]}`)})),de=a.trim()?ya.filter(t=>{const P=a.toLowerCase();return t.title.toLowerCase().includes(P)||t.keywords.some(q=>q.toLowerCase().includes(P))}).map(t=>t.id):null,S=t=>de?de.includes(t):!0,Z=h.settings.customAgentNames||[],fe=Z.length>0?Z:ws,te=()=>{const t=N.trim();t&&!Z.includes(t)&&(A.updateSettings({customAgentNames:[...Z,t]}),T(""))},Ne=t=>{A.updateSettings({customAgentNames:Z.filter(P=>P!==t)})},me=()=>{A.updateSettings({customAgentNames:[]})},le=()=>{const t=F.trim();if(t){if(u.includes(t)){_("");return}y([...u,t]),c(!0),_("")}},Te=t=>{y(u.filter((P,q)=>q!==t)),c(!0)},we=(t,P)=>{const q=t+P;if(q<0||q>=u.length)return;const pe=u.slice();[pe[t],pe[q]]=[pe[q],pe[t]],y(pe),c(!0)},ue=()=>{ks(u),c(!1),De()},Ee=t=>{w(t),V(!0)},ye=()=>{Se(be.AUTH_TOKEN,R),V(!1),De()},Ie=t=>{D(t),J(!0)},ke=()=>{Ws(v).catch(()=>{}),J(!1)},ne=t=>{o({...s,terrain:{...s.terrain,...t}})},ie=t=>{o({...s,modelStyle:{...s.modelStyle,...t}})},xe=t=>{o({...s,animations:{...s.animations,...t}})},Pe=t=>{g(t),A.updateSettings({historyLimit:t})},Le=t=>{const P=s.terrain[t];typeof P=="boolean"&&ne({[t]:!P})},z=a.trim().length>0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"config-section",children:[de&&de.length===0&&e.jsx("div",{className:"config-no-results",children:n("config:noResults",{query:a})}),S("general")&&e.jsxs(U,{title:n("config:sections.general"),storageKey:"general",defaultOpen:!0,forceOpen:z&&S("general"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("config:general.history"),query:a})}),e.jsx("input",{type:"number",className:"config-input config-input-sm",value:d,onChange:t=>Pe(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(C,{text:n("config:general.hideCosts"),query:a})}),e.jsx(Q,{checked:h.settings.hideCost,onChange:t=>A.updateSettings({hideCost:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("config:general.grid"),query:a})}),e.jsx(Q,{checked:s.gridVisible,onChange:t=>o({...s,gridVisible:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("config:general.showFPS"),query:a})}),e.jsx(Q,{checked:h.settings.showFPS,onChange:t=>A.updateSettings({showFPS:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("config:general.fpsLimit"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"120",step:"10",value:s.fpsLimit,onChange:t=>o({...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(C,{text:n("config:general.powerSaving"),query:a})," ",e.jsx(L,{name:"bolt",size:12})]}),e.jsx(Q,{checked:h.settings.powerSaving,onChange:t=>A.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(C,{text:n("config:general.tmuxMode"),query:a})}),e.jsx(Q,{checked:h.settings.tmuxMode,onChange:async t=>{A.updateSettings({tmuxMode:t});try{await Gs(t)}catch(P){console.error("Failed to sync tmux mode setting to server:",P)}}})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("config:general.vibrationIntensity"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"5",step:"1",value:h.settings.vibrationIntensity,onChange:t=>A.updateSettings({vibrationIntensity:parseInt(t.target.value)})}),e.jsx("span",{className:"config-value",children:h.settings.vibrationIntensity===0?n("config:vibrationValues.off"):h.settings.vibrationIntensity===1?n("config:vibrationValues.ultraLight"):h.settings.vibrationIntensity===2?n("config:vibrationValues.veryLight"):h.settings.vibrationIntensity===3?n("config:vibrationValues.light"):h.settings.vibrationIntensity===4?n("config:vibrationValues.medium"):n("config:vibrationValues.heavy")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("config:general.externalEditor"),query:a})}),e.jsx("input",{type:"text",className:"config-input",placeholder:n("config:general.externalEditorPlaceholder"),value:h.settings.externalEditorCommand||"",onChange:t=>A.updateSettings({externalEditorCommand:t.target.value})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("config:general.tabTitle"),query:a})}),e.jsx("input",{type:"text",className:"config-input",placeholder:n("config:general.tabTitlePlaceholder"),value:h.settings.tabTitle||"",onChange:t=>A.updateSettings({tabTitle:t.target.value})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("config:general.language"),query:a})}),e.jsx(he,{options:$e,value:localStorage.getItem("tide-commander-language-mode")==="manual"?((p=$e.find(t=>t.value!=="auto"&&Oe.language.startsWith(t.value.split("-")[0])))==null?void 0:p.value)||"en":"auto",onChange:t=>{var P;if(t==="auto"){localStorage.setItem("tide-commander-language-mode","auto");const q=navigator.language,pe=((P=$e.find(Ke=>Ke.value!=="auto"&&q.startsWith(Ke.value.split("-")[0])))==null?void 0:P.value)||"en";Oe.changeLanguage(pe)}else localStorage.setItem("tide-commander-language-mode","manual"),Oe.changeLanguage(t)}})]})]}),S("agentNames")&&e.jsx(U,{title:n("config:sections.agentNames"),storageKey:"agentNames",defaultOpen:!1,forceOpen:z&&S("agentNames"),children:e.jsxs("div",{className:"agent-names-section",children:[e.jsx("span",{className:"config-hint",children:Z.length>0?n("config:agentNames.customConfigured",{count:Z.length}):n("config:agentNames.usingDefaults")}),e.jsxs("div",{className:"agent-names-input-row",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",placeholder:n("config:agentNames.addPlaceholder"),value:N,onChange:t=>T(t.target.value),onKeyDown:t=>{t.key==="Enter"&&te()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:te,disabled:!N.trim(),title:n("config:agentNames.addName"),children:"+"})]}),e.jsx("div",{className:"agent-names-list",children:fe.map((t,P)=>e.jsxs("div",{className:"agent-name-chip",children:[e.jsx("span",{className:"agent-name-text",children:t}),Z.length>0&&e.jsx("button",{className:"agent-name-remove",onClick:()=>Ne(t),title:n("common:buttons.remove"),children:"x"})]},`${t}-${P}`))}),Z.length>0&&e.jsx("button",{className:"config-btn config-btn-link",onClick:me,children:n("common:buttons.resetToDefaults")})]})}),S("defaultClass")&&e.jsx(U,{title:"Default Spawn Class",storageKey:"defaultClass",defaultOpen:!1,forceOpen:z&&S("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${b==="random"?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{k("random"),Se(be.DEFAULT_AGENT_CLASS,"random")},children:e.jsx("span",{className:"agent-name-text",children:"🎲 Random"})}),Object.entries(ys).map(([t,P])=>e.jsx("div",{className:`agent-name-chip${b===t?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{k(t),Se(be.DEFAULT_AGENT_CLASS,t)},children:e.jsxs("span",{className:"agent-name-text",children:[P.icon," ",t.charAt(0).toUpperCase()+t.slice(1)]})},t)),I.map(t=>e.jsx("div",{className:`agent-name-chip${b===t.id?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{k(t.id),Se(be.DEFAULT_AGENT_CLASS,t.id)},children:e.jsxs("span",{className:"agent-name-text",children:[t.icon," ",t.name]})},t.id))]})]})}),S("appearance")&&e.jsx(U,{title:n("config:sections.appearance"),storageKey:"appearance",defaultOpen:!1,forceOpen:z&&S("appearance"),children:e.jsx(Qs,{})}),S("connection")&&e.jsxs(U,{title:n("config:sections.connection"),storageKey:"connection",defaultOpen:!1,forceOpen:z&&S("connection"),children:[e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("config:connection.backendUrl"),query:a})}),e.jsx("div",{className:"backend-urls-list",children:u.map((t,P)=>e.jsxs("div",{className:"backend-url-row",children:[e.jsx("span",{className:"backend-url-priority",title:n("config:connection.priorityLabel",{defaultValue:"Priority"}),children:P+1}),e.jsx("span",{className:"backend-url-text",title:t,children:t}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>we(P,-1),disabled:P===0,title:n("config:connection.moveUp",{defaultValue:"Move up"}),children:"↑"}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>we(P,1),disabled:P===u.length-1,title:n("config:connection.moveDown",{defaultValue:"Move down"}),children:"↓"}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>Te(P),title:n("common:buttons.remove"),children:"x"})]},`${t}-${P}`))}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",value:F,onChange:t=>_(t.target.value),placeholder:n("config:connection.addUrlPlaceholder",{defaultValue:"http://host:port"}),onKeyDown:t=>{t.key==="Enter"&&le()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:le,disabled:!F.trim(),title:n("config:connection.addUrl",{defaultValue:"Add URL"}),children:"+"}),x&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:ue,title:n("config:connection.saveAndReconnect"),children:n("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:n("config:connection.urlsHint",{defaultValue:"Tried in order on connect; the first reachable host wins. Leave empty for auto-detect."})})]}),e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("config:connection.authToken"),query:a})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:B?"text":"password",className:"config-input config-input-full",value:R,onChange:t=>Ee(t.target.value),placeholder:n("config:connection.tokenPlaceholder"),onKeyDown:t=>{t.key==="Enter"&&E&&ye()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>W(!B),title:n(B?"config:connection.hideToken":"config:connection.showToken"),children:e.jsx(L,{name:B?"eye-closed":"eye",size:14})}),E&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:ye,title:n("config:connection.saveAndReconnect"),children:n("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:n("config:connection.tokenRequired")})]}),e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("config:connection.codexBinaryPath"),query:a})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",value:v,onChange:t=>Ie(t.target.value),placeholder:n("config:connection.codexBinaryPathPlaceholder"),onKeyDown:t=>{t.key==="Enter"&&$&&ke()}}),$&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:ke,children:n("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:n("config:connection.codexBinaryPathHint")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("common:buttons.reconnect"),query:a})}),e.jsx("button",{className:"config-btn",onClick:()=>De(),title:"Force reconnect to server",children:n("common:buttons.reconnect")})]})]}),S("scene")&&e.jsxs(U,{title:n("config:sections.scene"),storageKey:"scene",defaultOpen:!1,forceOpen:z&&S("scene"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("config:scene.characterSize"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.3",max:"3.0",step:"0.1",value:s.characterScale,onChange:t=>o({...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(C,{text:n("config:scene.scale2d",{defaultValue:"2D Scale"}),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.3",max:"2.0",step:"0.1",value:s.scale2d,onChange:t=>o({...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(C,{text:n("config:scene.scale3d",{defaultValue:"3D Scale"}),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.3",max:"2.0",step:"0.1",value:s.scale3d,onChange:t=>o({...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(C,{text:n("config:scene.show2DTaskLabels",{defaultValue:"Show 2D task labels"}),query:a})}),e.jsx(Q,{checked:s.show2DTaskLabels,onChange:t=>o({...s,show2DTaskLabels:t})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("config:scene.time"),query:a})}),e.jsx(he,{options:ae,value:s.timeMode,onChange:t=>o({...s,timeMode:t}),iconOnly:!0})]})]}),S("terrain")&&e.jsxs(U,{title:n("config:sections.terrain"),storageKey:"terrain",defaultOpen:!1,forceOpen:z&&S("terrain"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("config:terrainSettings.simpleMode",{defaultValue:"Simple Mode"}),query:a})}),e.jsx(Q,{checked:s.terrain.simpleMode??!1,onChange:t=>ne({simpleMode:t})})]}),e.jsx("div",{className:"terrain-icons",style:{opacity:s.terrain.simpleMode?.4:1,pointerEvents:s.terrain.simpleMode?"none":"auto"},children:ve.map(t=>e.jsx("button",{className:`terrain-icon-btn ${s.terrain[t.key]?"active":""}`,onClick:()=>Le(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(C,{text:n("config:terrainSettings.fog"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"2",step:"0.1",value:s.terrain.fogDensity,onChange:t=>ne({fogDensity:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.fogDensity===0?n("config:fogValues.off"):s.terrain.fogDensity<=1?n("config:fogValues.low"):n("config:fogValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("config:terrainSettings.brightness"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.2",max:"2",step:"0.1",value:s.terrain.brightness,onChange:t=>ne({brightness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.brightness<=.5?n("config:brightnessValues.dark"):s.terrain.brightness<=1.2?n("config:brightnessValues.normal"):n("config:brightnessValues.bright")})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("config:terrainSettings.floor"),query:a})}),e.jsx(he,{options:X,value:s.terrain.floorStyle,onChange:t=>ne({floorStyle:t}),iconOnly:!0})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("config:terrainSettings.sky"),query:a})}),e.jsx("div",{className:"sky-color-selector",children:Ae.map(t=>e.jsx("button",{className:`sky-color-btn ${s.terrain.skyColor===t.value?"active":""}`,onClick:()=>ne({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(C,{text:n("config:terrainSettings.battlefieldSize"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"30",max:"200",step:"10",value:s.terrain.battlefieldSize,onChange:t=>ne({battlefieldSize:parseInt(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.battlefieldSize})]})]}),S("modelStyle")&&e.jsxs(U,{title:n("config:sections.modelStyle"),storageKey:"modelStyle",defaultOpen:!1,forceOpen:z&&S("modelStyle"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("config:modelStyleSettings.saturation"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"2",step:"0.1",value:s.modelStyle.saturation,onChange:t=>ie({saturation:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.saturation<=.3?n("config:saturationValues.gray"):s.modelStyle.saturation<=1.2?n("config:saturationValues.normal"):n("config:saturationValues.vivid")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("config:modelStyleSettings.roughness"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"1",step:"0.1",value:s.modelStyle.roughness,onChange:t=>ie({roughness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.roughness<0?n("config:roughnessValues.auto"):s.modelStyle.roughness<=.3?n("config:roughnessValues.glossy"):s.modelStyle.roughness<=.7?n("config:roughnessValues.normal"):n("config:roughnessValues.matte")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("config:modelStyleSettings.metalness"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"1",step:"0.1",value:s.modelStyle.metalness,onChange:t=>ie({metalness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.metalness<0?n("config:metalnessValues.auto"):s.modelStyle.metalness<=.3?n("config:metalnessValues.plastic"):s.modelStyle.metalness<=.7?n("config:metalnessValues.mixed"):n("config:metalnessValues.metal")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("config:modelStyleSettings.glow"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"1",step:"0.05",value:s.modelStyle.emissiveBoost,onChange:t=>ie({emissiveBoost:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.emissiveBoost<=.1?n("config:glowValues.off"):s.modelStyle.emissiveBoost<=.4?n("config:glowValues.low"):s.modelStyle.emissiveBoost<=.7?n("config:glowValues.med"):n("config:glowValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("config:modelStyleSettings.reflections"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"2",step:"0.1",value:s.modelStyle.envMapIntensity,onChange:t=>ie({envMapIntensity:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.envMapIntensity<0?n("config:reflectionValues.auto"):s.modelStyle.envMapIntensity<=.3?n("config:reflectionValues.low"):s.modelStyle.envMapIntensity<=1?n("config:reflectionValues.normal"):n("config:reflectionValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("config:modelStyleSettings.wireframe"),query:a})}),e.jsx(Q,{checked:s.modelStyle.wireframe,onChange:t=>ie({wireframe:t})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("config:modelStyleSettings.colorMode"),query:a})}),e.jsx(he,{options:ge,value:s.modelStyle.colorMode,onChange:t=>ie({colorMode:t}),iconOnly:!0})]})]}),S("animations")&&e.jsxs(U,{title:n("config:sections.animations"),storageKey:"animations",defaultOpen:!1,forceOpen:z&&S("animations"),children:[e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("config:animationSettings.idle"),query:a})}),e.jsx(he,{options:G,value:s.animations.idleAnimation,onChange:t=>xe({idleAnimation:t}),iconOnly:!0})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("config:animationSettings.working"),query:a})}),e.jsx(he,{options:G,value:s.animations.workingAnimation,onChange:t=>xe({workingAnimation:t}),iconOnly:!0})]})]}),S("secrets")&&e.jsx(U,{title:n("config:sections.secrets"),storageKey:"secrets",defaultOpen:!1,forceOpen:z&&S("secrets"),children:e.jsx(zs,{})}),S("systemPrompt")&&e.jsx(U,{title:n("config:sections.systemPrompt"),storageKey:"systemPrompt",defaultOpen:!1,forceOpen:z&&S("systemPrompt"),children:e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("config:systemPrompt.title"),query:a})}),e.jsx("button",{className:"config-button",onClick:()=>se(!0),children:n("config:systemPrompt.editPrompt")})]})}),S("whatsapp")&&e.jsx(U,{title:n("config:sections.whatsapp"),storageKey:"whatsapp",defaultOpen:!1,forceOpen:z&&S("whatsapp"),children:e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("config:whatsapp.title"),query:a})}),e.jsx("button",{className:"config-button",onClick:()=>j(!0),children:n("config:whatsapp.editConfig")})]})}),S("whatsappNotifications")&&e.jsx(U,{title:n("config:sections.whatsappNotifications"),storageKey:"whatsappNotifications",defaultOpen:!1,forceOpen:z&&S("whatsappNotifications"),children:e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(C,{text:n("config:whatsappNotifications.title"),query:a})}),e.jsx("button",{className:"config-button",onClick:()=>K(!0),children:n("config:whatsappNotifications.editButton")})]})}),S("data")&&e.jsx(U,{title:n("config:sections.data"),storageKey:"data",defaultOpen:!1,forceOpen:z&&S("data"),children:e.jsx(Xs,{})}),S("integrations")&&e.jsx(U,{title:"Integrations",storageKey:"integrations",defaultOpen:!1,forceOpen:z&&S("integrations"),children:e.jsx(aa,{onOpenModal:t=>i==null?void 0:i(t)})}),S("workflows")&&e.jsxs(U,{title:"Workflows",storageKey:"workflows",defaultOpen:!1,forceOpen:z&&S("workflows"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(C,{text:"Create and manage automated workflow pipelines with visual state machine editor",query:a})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>f==null?void 0:f(),children:"Open Workflow Editor"})})]}),S("triggers")&&e.jsxs(U,{title:"Triggers",storageKey:"triggers",defaultOpen:!1,forceOpen:z&&S("triggers"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(C,{text:"Create and manage event-driven triggers that fire agents with templates",query:a})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>r==null?void 0:r(),children:"Open Trigger Manager"})})]}),S("monitoring")&&e.jsxs(U,{title:"Monitoring",storageKey:"monitoring",defaultOpen:!1,forceOpen:z&&S("monitoring"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(C,{text:"View event logs, trigger history, workflow traces, and system stats",query:a})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>m==null?void 0:m(),children:"Open Monitoring & Logs"})})]}),S("experimental")&&e.jsxs(U,{title:n("config:sections.experimental"),storageKey:"experimental",defaultOpen:!1,forceOpen:z&&S("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(C,{text:n("config:experimental.2dView"),query:a})," ",e.jsx(L,{name:"map",size:12})]}),e.jsx(Q,{checked:h.settings.experimental2DView,onChange:t=>A.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(C,{text:n("config:experimental.voiceAssistant"),query:a})," ",e.jsx(L,{name:"microphone",size:12})]}),e.jsx(Q,{checked:h.settings.experimentalVoiceAssistant,onChange:t=>A.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(C,{text:n("config:experimental.tts"),query:a})," ",e.jsx(L,{name:"speaker-on",size:12})]}),e.jsx(Q,{checked:h.settings.experimentalTTS,onChange:t=>A.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(C,{text:n("config:experimental.echoPrompt"),query:a})}),e.jsx(Q,{checked:h.settings.experimentalEchoPrompt,onChange:async t=>{A.updateSettings({experimentalEchoPrompt:t});try{await Ms(t)}catch(P){console.error("Failed to sync echo prompt setting to server:",P)}}})]}),e.jsx("span",{className:"config-hint",children:n("config:experimental.hint")})]}),S("about")&&e.jsx(U,{title:n("config:sections.about"),storageKey:"about",defaultOpen:!1,forceOpen:z&&S("about"),children:e.jsx(ea,{})})]}),e.jsx(ta,{isOpen:M,onClose:()=>se(!1)}),e.jsx(la,{isOpen:oe,onClose:()=>j(!1)}),e.jsx(pa,{isOpen:O,onClose:()=>K(!1)})]})}function Ta({onConfigChange:s,onToolChange:o,config:a,isOpen:i,onClose:m,onOpenBuildingModal:f,onOpenAreaExplorer:r,onOpenIntegrationsModal:n,onOpenMonitoringModal:h,onOpenWorkflowEditor:I,onOpenTriggerManager:b}){const{t:k}=ee(["config","common"]),d=Re(),g=Array.from(d.areas.values()),u=Array.from(d.buildings.values()),[y,x]=l.useState(""),c=l.useRef(null);if(l.useEffect(()=>{const w=E=>{E.key==="Escape"&&i&&m()};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[i,m]),l.useEffect(()=>{if(i&&c.current){if(typeof window<"u"&&window.matchMedia("(max-width: 768px)").matches)return;const E=setTimeout(()=>{var V;(V=c.current)==null||V.focus()},50);return()=>clearTimeout(E)}},[i]),!i)return null;const F=w=>{const E=d.activeTool===w?null:w;o(E)},_=w=>{A.selectArea(d.selectedAreaId===w?null:w),o("select")},R=(w,E)=>{w.stopPropagation(),A.deleteArea(E)};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:k("config:title")}),e.jsx("button",{className:"toolbox-close-btn",onClick:m,title:k("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:k("config:searchPlaceholder"),value:y,onChange:w=>x(w.target.value),className:"toolbox-search-input"}),y&&e.jsx("button",{className:"toolbox-search-clear",onClick:()=>x(""),children:"×"})]}),e.jsxs("div",{className:"toolbox-content",children:[e.jsx("div",{className:"toolbox-section toolbox-section-collapsible",children:e.jsxs(U,{title:k("config:areas.title",{count:g.length}),storageKey:"areas",children:[e.jsxs("div",{className:"tool-buttons",children:[e.jsx("button",{className:`tool-btn ${d.activeTool==="select"?"active":""}`,onClick:()=>F("select"),title:k("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 ${d.activeTool==="rectangle"?"active":""}`,onClick:()=>F("rectangle"),title:k("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 ${d.activeTool==="circle"?"active":""}`,onClick:()=>F("circle"),title:k("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:k("config:areas.drawToCreate")}):g.map(w=>e.jsx(Ps,{area:w,isSelected:d.selectedAreaId===w.id,onClick:()=>_(w.id),onDelete:E=>R(E,w.id)},w.id))})]})}),d.selectedAreaId&&e.jsx(_s,{area:d.areas.get(d.selectedAreaId),onClose:()=>A.selectArea(null),onOpenFolder:r}),e.jsx("div",{className:"toolbox-section toolbox-section-collapsible",children:e.jsx(U,{title:k("config:buildings.title",{count:u.length}),storageKey:"buildings",headerExtra:e.jsx("button",{className:"add-building-btn",onClick:w=>{w.stopPropagation(),f==null||f()},title:k("config:buildings.addBuilding"),children:"+"}),children:e.jsx("div",{className:"buildings-list",children:u.length===0?e.jsx("div",{className:"buildings-empty",children:k("config:buildings.clickToAdd")}):u.map(w=>e.jsx(Ls,{building:w,isSelected:d.selectedBuildingIds.has(w.id),onClick:()=>{A.selectBuilding(d.selectedBuildingIds.has(w.id)?null:w.id)},onEdit:()=>f==null?void 0:f(w.id)},w.id))})})}),d.selectedBuildingIds.size===1&&(()=>{const w=Array.from(d.selectedBuildingIds)[0],E=d.buildings.get(w);return E?e.jsx(Fs,{building:E,onClose:()=>A.selectBuilding(null),onOpenModal:()=>f==null?void 0:f(w)}):null})(),e.jsx(ka,{config:a,onChange:s,searchQuery:y,onOpenIntegrationsModal:n,onOpenMonitoringModal:h,onOpenWorkflowEditor:I,onOpenTriggerManager:b})]})]})]})}export{Ta as Toolbox};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/web-D1aYcbd6.js","assets/main-CHfGSVnw.js","assets/vendor-react--Eh9ivFN.js","assets/vendor-three-Chj50gSY.js","assets/main-DmmvYoEs.css"])))=>i.map(i=>d[i]);
2
- import{c5 as e,by as o}from"./main-CHfGSVnw.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 c=e("Haptics",{web:()=>o(()=>import("./web-D1aYcbd6.js"),__vite__mapDeps([0,1,2,3,4])).then(r=>new r.HapticsWeb)});export{c as Haptics,i as ImpactStyle,t as NotificationType};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/web-DsEKGJbn.js","assets/main-CPwivjwQ.js","assets/vendor-react--Eh9ivFN.js","assets/vendor-three-Chj50gSY.js","assets/main-CFu_SP_0.css"])))=>i.map(i=>d[i]);
2
+ import{c5 as e,by as o}from"./main-CPwivjwQ.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 c=e("Haptics",{web:()=>o(()=>import("./web-DsEKGJbn.js"),__vite__mapDeps([0,1,2,3,4])).then(r=>new r.HapticsWeb)});export{c as Haptics,i as ImpactStyle,t as NotificationType};
@@ -1,4 +1,4 @@
1
- import{bc as ta,u as D,j as e,aH as v,bf as $s,bg as Fs,aI as He,s as P,bh as Ms,D as Y,I as A,_ as Hs,aR as Ge,f as na,bi as la,r,E as ia,S as oa,h as ra,bj as Us,aS as Ke}from"./main-CHfGSVnw.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const ca=[{value:"",labelKey:"terminal:building.colorDefault"},{value:"#2a2a3a",labelKey:"terminal:building.colorDarkGray"},{value:"#3a2a2a",labelKey:"terminal:building.colorDarkRed"},{value:"#2a3a2a",labelKey:"terminal:building.colorDarkGreen"},{value:"#2a2a4a",labelKey:"terminal:building.colorDarkBlue"},{value:"#3a3a2a",labelKey:"terminal:building.colorDarkYellow"},{value:"#3a2a3a",labelKey:"terminal:building.colorDarkPurple"},{value:"#2a3a3a",labelKey:"terminal:building.colorDarkCyan"},{value:"#4a3a3a",labelKey:"terminal:building.colorWarmBrown"},{value:"#3a4a4a",labelKey:"terminal:building.colorCoolSteel"}];function ma(a){return ta.t(a)}function Ve(a){if(a===0)return"0 B";const l=1024,c=["B","KB","MB","GB"],h=Math.floor(Math.log(a)/Math.log(l));return parseFloat((a/Math.pow(l,h)).toFixed(1))+" "+c[h]}function da(a){const c=Date.now()-a,h=Math.floor(c/(1e3*60*60)),t=Math.floor(c%(1e3*60*60)/(1e3*60));return h>0?`${h}h ${t}m`:`${t}m`}const Ks={30:"#1a1a1a",31:"#e74c3c",32:"#2ecc71",33:"#f39c12",34:"#3498db",35:"#9b59b6",36:"#00bcd4",37:"#ecf0f1",90:"#7f8c8d",91:"#ff6b6b",92:"#4ade80",93:"#fbbf24",94:"#60a5fa",95:"#c084fc",96:"#22d3ee",97:"#ffffff"};function Gs(a){const l=[],c=/\x1B\[([0-9;]*)m/g;let h=0,t=null,o;for(;(o=c.exec(a))!==null;){if(o.index>h){const m=a.slice(h,o.index);t?l.push(e.jsx("span",{style:{color:t},children:m},l.length)):l.push(m)}const g=o[1].split(";").map(Number);for(const m of g)m===0||m===39?t=null:Ks[m]&&(t=Ks[m]);h=c.lastIndex}if(h<a.length){const g=a.slice(h);t?l.push(e.jsx("span",{style:{color:t},children:g},l.length)):l.push(g)}return l.length>0?l:[a]}function ua({buildingName:a,onClose:l,onConfirm:c}){const{t:h}=D(["terminal","common"]);return e.jsx("div",{className:"modal-overlay visible",onClick:l,children:e.jsxs("div",{className:"modal confirm-modal",onClick:t=>t.stopPropagation(),children:[e.jsx("div",{className:"modal-header",children:h("terminal:building.deleteBuilding")}),e.jsxs("div",{className:"modal-body confirm-modal-body",children:[e.jsx("p",{children:h("terminal:building.deleteConfirm",{name:a})}),e.jsx("p",{className:"confirm-modal-note",children:h("terminal:building.deleteNote")})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn btn-secondary",onClick:l,children:h("common:buttons.cancel")}),e.jsx("button",{className:"btn btn-danger",onClick:c,autoFocus:!0,children:h("common:buttons.delete")})]})]})})}function pa({usePM2:a,setUsePM2:l}){const{t:c}=D(["terminal"]);return e.jsxs("div",{className:"form-section pm2-toggle-section",children:[e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",className:"toggle-input",checked:a,onChange:h=>l(h.target.checked)}),e.jsx("span",{className:"toggle-track",children:e.jsx("span",{className:"toggle-thumb"})}),e.jsxs("span",{className:"toggle-label",children:[e.jsx("span",{className:"pm2-badge",children:"PM2"}),c("terminal:building.usePM2")]})]}),e.jsx("div",{className:"form-hint",children:c("terminal:building.pm2Hint")})]})}function ha({usePM2:a,pm2Script:l,setPm2Script:c,pm2Args:h,setPm2Args:t,pm2Interpreter:o,setPm2Interpreter:g,pm2InterpreterArgs:m,setPm2InterpreterArgs:d,pm2Env:s,setPm2Env:u,isEditMode:b,building:x,handleCommand:N}){var y;const{t:p}=D(["terminal","common"]);return a?e.jsxs("div",{className:"form-section pm2-config-section",children:[e.jsx("label",{className:"form-label",children:p("terminal:building.pm2Configuration")}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Script"),e.jsx(v,{text:p("terminal:building.helpPm2Script"),title:p("terminal:building.pm2Script"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:l,onChange:j=>c(j.target.value),placeholder:"npm, java, python, ./app.js",required:a})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Arguments"),e.jsx(v,{text:p("terminal:building.helpPm2Arguments"),title:p("terminal:building.pm2Arguments"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:h,onChange:j=>t(j.target.value),placeholder:"run dev, -jar app.jar, app.py"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Interpreter"),e.jsx(v,{text:p("terminal:building.helpPm2Interpreter"),title:p("terminal:building.pm2Interpreter"),position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:o,onChange:j=>g(j.target.value),children:Object.keys($s).map(j=>e.jsx("option",{value:j,children:$s[j].label},j))})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2InterpArgs"),e.jsx(v,{text:p("terminal:building.helpPm2InterpArgs"),title:p("terminal:building.pm2InterpArgs"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:m,onChange:j=>d(j.target.value),placeholder:"-jar (for Java)"})]}),e.jsxs("div",{className:"command-row env-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Environment"),e.jsx(v,{text:p("terminal:building.helpPm2Environment"),title:p("terminal:building.pm2Environment"),position:"top",size:"sm"})]}),e.jsx("textarea",{className:"form-input form-textarea",value:s,onChange:j=>u(j.target.value),placeholder:`KEY=value
1
+ import{bc as ta,u as D,j as e,aH as v,bf as $s,bg as Fs,aI as He,s as P,bh as Ms,D as Y,I as A,_ as Hs,aR as Ge,f as na,bi as la,r,E as ia,S as oa,h as ra,bj as Us,aS as Ke}from"./main-CPwivjwQ.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const ca=[{value:"",labelKey:"terminal:building.colorDefault"},{value:"#2a2a3a",labelKey:"terminal:building.colorDarkGray"},{value:"#3a2a2a",labelKey:"terminal:building.colorDarkRed"},{value:"#2a3a2a",labelKey:"terminal:building.colorDarkGreen"},{value:"#2a2a4a",labelKey:"terminal:building.colorDarkBlue"},{value:"#3a3a2a",labelKey:"terminal:building.colorDarkYellow"},{value:"#3a2a3a",labelKey:"terminal:building.colorDarkPurple"},{value:"#2a3a3a",labelKey:"terminal:building.colorDarkCyan"},{value:"#4a3a3a",labelKey:"terminal:building.colorWarmBrown"},{value:"#3a4a4a",labelKey:"terminal:building.colorCoolSteel"}];function ma(a){return ta.t(a)}function Ve(a){if(a===0)return"0 B";const l=1024,c=["B","KB","MB","GB"],h=Math.floor(Math.log(a)/Math.log(l));return parseFloat((a/Math.pow(l,h)).toFixed(1))+" "+c[h]}function da(a){const c=Date.now()-a,h=Math.floor(c/(1e3*60*60)),t=Math.floor(c%(1e3*60*60)/(1e3*60));return h>0?`${h}h ${t}m`:`${t}m`}const Ks={30:"#1a1a1a",31:"#e74c3c",32:"#2ecc71",33:"#f39c12",34:"#3498db",35:"#9b59b6",36:"#00bcd4",37:"#ecf0f1",90:"#7f8c8d",91:"#ff6b6b",92:"#4ade80",93:"#fbbf24",94:"#60a5fa",95:"#c084fc",96:"#22d3ee",97:"#ffffff"};function Gs(a){const l=[],c=/\x1B\[([0-9;]*)m/g;let h=0,t=null,o;for(;(o=c.exec(a))!==null;){if(o.index>h){const m=a.slice(h,o.index);t?l.push(e.jsx("span",{style:{color:t},children:m},l.length)):l.push(m)}const g=o[1].split(";").map(Number);for(const m of g)m===0||m===39?t=null:Ks[m]&&(t=Ks[m]);h=c.lastIndex}if(h<a.length){const g=a.slice(h);t?l.push(e.jsx("span",{style:{color:t},children:g},l.length)):l.push(g)}return l.length>0?l:[a]}function ua({buildingName:a,onClose:l,onConfirm:c}){const{t:h}=D(["terminal","common"]);return e.jsx("div",{className:"modal-overlay visible",onClick:l,children:e.jsxs("div",{className:"modal confirm-modal",onClick:t=>t.stopPropagation(),children:[e.jsx("div",{className:"modal-header",children:h("terminal:building.deleteBuilding")}),e.jsxs("div",{className:"modal-body confirm-modal-body",children:[e.jsx("p",{children:h("terminal:building.deleteConfirm",{name:a})}),e.jsx("p",{className:"confirm-modal-note",children:h("terminal:building.deleteNote")})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn btn-secondary",onClick:l,children:h("common:buttons.cancel")}),e.jsx("button",{className:"btn btn-danger",onClick:c,autoFocus:!0,children:h("common:buttons.delete")})]})]})})}function pa({usePM2:a,setUsePM2:l}){const{t:c}=D(["terminal"]);return e.jsxs("div",{className:"form-section pm2-toggle-section",children:[e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",className:"toggle-input",checked:a,onChange:h=>l(h.target.checked)}),e.jsx("span",{className:"toggle-track",children:e.jsx("span",{className:"toggle-thumb"})}),e.jsxs("span",{className:"toggle-label",children:[e.jsx("span",{className:"pm2-badge",children:"PM2"}),c("terminal:building.usePM2")]})]}),e.jsx("div",{className:"form-hint",children:c("terminal:building.pm2Hint")})]})}function ha({usePM2:a,pm2Script:l,setPm2Script:c,pm2Args:h,setPm2Args:t,pm2Interpreter:o,setPm2Interpreter:g,pm2InterpreterArgs:m,setPm2InterpreterArgs:d,pm2Env:s,setPm2Env:u,isEditMode:b,building:x,handleCommand:N}){var y;const{t:p}=D(["terminal","common"]);return a?e.jsxs("div",{className:"form-section pm2-config-section",children:[e.jsx("label",{className:"form-label",children:p("terminal:building.pm2Configuration")}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Script"),e.jsx(v,{text:p("terminal:building.helpPm2Script"),title:p("terminal:building.pm2Script"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:l,onChange:j=>c(j.target.value),placeholder:"npm, java, python, ./app.js",required:a})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Arguments"),e.jsx(v,{text:p("terminal:building.helpPm2Arguments"),title:p("terminal:building.pm2Arguments"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:h,onChange:j=>t(j.target.value),placeholder:"run dev, -jar app.jar, app.py"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Interpreter"),e.jsx(v,{text:p("terminal:building.helpPm2Interpreter"),title:p("terminal:building.pm2Interpreter"),position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:o,onChange:j=>g(j.target.value),children:Object.keys($s).map(j=>e.jsx("option",{value:j,children:$s[j].label},j))})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2InterpArgs"),e.jsx(v,{text:p("terminal:building.helpPm2InterpArgs"),title:p("terminal:building.pm2InterpArgs"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:m,onChange:j=>d(j.target.value),placeholder:"-jar (for Java)"})]}),e.jsxs("div",{className:"command-row env-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Environment"),e.jsx(v,{text:p("terminal:building.helpPm2Environment"),title:p("terminal:building.pm2Environment"),position:"top",size:"sm"})]}),e.jsx("textarea",{className:"form-input form-textarea",value:s,onChange:j=>u(j.target.value),placeholder:`KEY=value
2
2
  SERVER_PORT=7201
3
3
  NODE_ENV=production`,rows:3})]}),e.jsx("div",{className:"pm2-examples",children:e.jsxs("details",{children:[e.jsx("summary",{children:p("terminal:building.pm2Examples")}),e.jsxs("div",{className:"pm2-examples-content",children:[e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Node.js:"})," Script: ",e.jsx("code",{children:"npm"}),", Args: ",e.jsx("code",{children:"run dev"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Symfony:"})," Script: ",e.jsx("code",{children:"symfony"}),", Args: ",e.jsx("code",{children:"serve --no-daemon"}),", Interpreter: ",e.jsx("code",{children:"None"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Java JAR:"})," Script: ",e.jsx("code",{children:"app.jar"}),", Interpreter: ",e.jsx("code",{children:"Java"}),", Interp. Args: ",e.jsx("code",{children:"-jar"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Python:"})," Script: ",e.jsx("code",{children:"app.py"}),", Interpreter: ",e.jsx("code",{children:"Python 3"})]})]})]})}),b&&(x==null?void 0:x.pm2Status)&&e.jsx("div",{className:"pm2-status-display",children:e.jsxs("div",{className:"pm2-status-row",children:[e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"PID"}),e.jsx("span",{className:"pm2-metric-value",children:x.pm2Status.pid||"-"})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"CPU"}),e.jsxs("span",{className:"pm2-metric-value",children:[((y=x.pm2Status.cpu)==null?void 0:y.toFixed(1))||"0","%"]})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"MEM"}),e.jsx("span",{className:"pm2-metric-value",children:Ve(x.pm2Status.memory||0)})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"Restarts"}),e.jsx("span",{className:"pm2-metric-value",children:x.pm2Status.restarts||0})]}),x.pm2Status.uptime&&e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"Uptime"}),e.jsx("span",{className:"pm2-metric-value",children:da(x.pm2Status.uptime)})]})]})}),b&&e.jsxs("div",{className:"pm2-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>N("start"),children:p("common:buttons.start")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>N("stop"),children:p("common:buttons.stop")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>N("restart"),children:p("terminal:buildingAction.restart")}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>N("logs"),children:p("terminal:logs.title")})]})]}):null}function xa({dockerMode:a,setDockerMode:l,dockerImage:c,setDockerImage:h,dockerContainerName:t,setDockerContainerName:o,dockerCommand:g,setDockerCommand:m,dockerPorts:d,setDockerPorts:s,dockerVolumes:u,setDockerVolumes:b,dockerNetwork:x,setDockerNetwork:N,dockerRestart:p,setDockerRestart:y,dockerPull:j,setDockerPull:F,dockerEnv:M,setDockerEnv:R,dockerComposePath:J,setDockerComposePath:U,dockerComposeProject:W,setDockerComposeProject:K,dockerComposeServices:Z,setDockerComposeServices:H,selectedExistingContainer:O,setSelectedExistingContainer:G,dockerContainersList:T,isEditMode:I,building:k,handleCommand:L}){const{t:z}=D(["config","common"]);return e.jsxs("div",{className:"form-section docker-config-section",children:[e.jsx("label",{className:"form-label",children:z("config:buildings.dockerConfig")}),e.jsxs("div",{className:"docker-mode-selector",children:[e.jsxs("label",{className:`docker-mode-option ${a==="container"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"container",checked:a==="container",onChange:()=>l("container")}),e.jsx("span",{className:"docker-mode-icon",children:"📦"}),e.jsx("span",{className:"docker-mode-label",children:"Container"}),e.jsx("span",{className:"docker-mode-desc",children:"Create a new container"})]}),e.jsxs("label",{className:`docker-mode-option ${a==="compose"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"compose",checked:a==="compose",onChange:()=>l("compose")}),e.jsx("span",{className:"docker-mode-icon",children:"🛠"}),e.jsx("span",{className:"docker-mode-label",children:"Compose"}),e.jsx("span",{className:"docker-mode-desc",children:"Manage multiple services"})]}),e.jsxs("label",{className:`docker-mode-option ${a==="existing"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"existing",checked:a==="existing",onChange:()=>l("existing")}),e.jsx("span",{className:"docker-mode-icon",children:"🔎"}),e.jsx("span",{className:"docker-mode-label",children:"Existing"}),e.jsx("span",{className:"docker-mode-desc",children:"Adopt existing container"})]})]}),a==="container"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Image:",e.jsx(v,{text:"Docker image to run, e.g., nginx:latest, redis:alpine, my-app:v1",title:"Image",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:c,onChange:n=>h(n.target.value),placeholder:"nginx:latest",required:!0})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Container Name:",e.jsx(v,{text:"Custom name for the container. If empty, auto-generated based on building name.",title:"Container Name",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:t,onChange:n=>o(n.target.value),placeholder:"Auto-generated (tc-{name}-{id})"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Command:",e.jsx(v,{text:"Override the default container command. Leave empty to use image's CMD.",title:"Command Override",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:g,onChange:n=>m(n.target.value),placeholder:"Optional command override"})]}),e.jsxs("div",{className:"form-section docker-ports-section",children:[e.jsxs("label",{className:"form-label",children:["Port Mappings",e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>s([...d,""]),children:"+ Add"})]}),d.map((n,C)=>e.jsxs("div",{className:"docker-mapping-row",children:[e.jsx("input",{type:"text",className:"form-input",value:n,onChange:B=>{const E=[...d];E[C]=B.target.value,s(E)},placeholder:"8080:80 or 3000"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>s(d.filter((B,E)=>E!==C)),children:"x"})]},C)),d.length===0&&e.jsx("div",{className:"form-hint",children:"Format: host:container (e.g., 8080:80) or same port (e.g., 3000)"})]}),e.jsxs("div",{className:"form-section docker-volumes-section",children:[e.jsxs("label",{className:"form-label",children:["Volume Mounts",e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>b([...u,""]),children:"+ Add"})]}),u.map((n,C)=>e.jsxs("div",{className:"docker-mapping-row",children:[e.jsx("input",{type:"text",className:"form-input",value:n,onChange:B=>{const E=[...u];E[C]=B.target.value,b(E)},placeholder:"./data:/app/data or /host/path:/container/path"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>b(u.filter((B,E)=>E!==C)),children:"x"})]},C)),u.length===0&&e.jsx("div",{className:"form-hint",children:"Format: host_path:container_path (relative paths resolved from working directory)"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Network:",e.jsx(v,{text:"Docker network to connect to. Leave empty for default bridge network.",title:"Network",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:x,onChange:n=>N(n.target.value),placeholder:"bridge (default)"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Restart Policy:",e.jsx(v,{text:"When should Docker restart the container automatically?",title:"Restart Policy",position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:p,onChange:n=>y(n.target.value),children:Object.keys(Fs).map(n=>e.jsx("option",{value:n,children:Fs[n].label},n))})]})]}),a==="compose"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Compose File:",e.jsx(v,{text:"Path to docker-compose.yml file, relative to working directory.",title:"Compose File",position:"top",size:"sm"})]}),e.jsx(He,{value:J,onChange:U,placeholder:"docker-compose.yml",className:"form-input",directoriesOnly:!1})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Project Name:",e.jsx(v,{text:"Override the compose project name. Leave empty for auto-generated name.",title:"Project Name",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:W,onChange:n=>K(n.target.value),placeholder:"Auto-generated"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Services:",e.jsx(v,{text:"Specific services to manage (comma-separated). Leave empty for all services.",title:"Services",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:Z,onChange:n=>H(n.target.value),placeholder:"All services (or: api, db, redis)"})]})]}),a==="existing"&&e.jsxs("div",{className:"docker-existing-section",children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Select Container:",e.jsx(v,{text:"Choose an existing Docker container to monitor and control. The container will not be deleted when removing the building.",title:"Existing Container",position:"top",size:"sm"})]}),e.jsxs("div",{className:"docker-existing-select-wrapper",children:[e.jsxs("select",{className:"form-input form-select",value:O,onChange:n=>G(n.target.value),required:a==="existing",children:[e.jsx("option",{value:"",children:"Select a container..."}),T.map(n=>e.jsxs("option",{value:n.name,children:[n.name," (",n.image,") - ",n.state]},n.id))]}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>P.requestDockerContainersList(),title:"Refresh container list",children:"↻"})]})]}),T.length===0&&e.jsx("div",{className:"form-hint docker-existing-hint",children:"No containers found. Make sure Docker is running and you have containers available."}),O&&e.jsx("div",{className:"docker-existing-info",children:(()=>{const n=T.find(C=>C.name===O);return n?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Image:"}),e.jsx("span",{className:"docker-existing-info-value",children:n.image})]}),e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Status:"}),e.jsx("span",{className:`docker-existing-info-value docker-status-${n.status}`,children:n.state})]}),e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"ID:"}),e.jsx("span",{className:"docker-existing-info-value",children:n.id.slice(0,12)})]}),n.ports.length>0&&e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Ports:"}),e.jsx("span",{className:"docker-existing-info-value",children:n.ports.map(C=>`${C.host}:${C.container}/${C.protocol}`).join(", ")})]})]}):null})()}),e.jsx("div",{className:"form-hint",children:"Note: Existing containers will not be deleted when you remove this building."})]}),a!=="existing"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Pull Policy:",e.jsx(v,{text:"When to pull images: always, only if missing, or never.",title:"Pull Policy",position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:j,onChange:n=>F(n.target.value),children:Object.keys(Ms).map(n=>e.jsx("option",{value:n,children:Ms[n].label},n))})]}),e.jsxs("div",{className:"command-row env-row",children:[e.jsxs("span",{className:"command-label",children:["Environment:",e.jsx(v,{text:"Environment variables in KEY=value format, one per line.",title:"Environment Variables",position:"top",size:"sm"})]}),e.jsx("textarea",{className:"form-input form-textarea",value:M,onChange:n=>R(n.target.value),placeholder:`KEY=value
4
4
  DATABASE_URL=postgres://...
@@ -0,0 +1,2 @@
1
+ import{u as Yt,z as Zt,B as Jt,r as a,E as It,S as C,G as St,H as wt,J as yt,K as lt,L as J,M as Qt,s as f,N as zt,O as Dt,P as en,v as Et,w as Mt,j as e,I as u,U as tn,m as nn,V as an,W as Ot,X as $t,Y as sn,Z as ln,_ as rn,$ as on,a0 as cn,a1 as dn,a2 as un,a3 as pn,a4 as mn,a5 as fn,a6 as Tt,C as hn,a7 as gn,a8 as bn,a9 as xn,aa as _n,ab as wn,ac as Cn,ad as vn,ae as jn,af as Nn,ag as kn,ah as An,ai as In,aj as Sn,ak as yn,al as En,am as Mn}from"./main-CPwivjwQ.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const rt=3,it=280,Pt=320,_t=240,Lt=64,Tn=["simple","chat","advanced"],Pn={simple:"Simple",chat:"Chat",advanced:"Advanced"},Ln={simple:"○",chat:"◐",advanced:"◉"},Rn={simple:"Simple view — clean messages only",chat:"Chat view — assistant replies (no tool calls)",advanced:"Advanced view — everything including tools"},Rt="flat-clear-context";function zn(_){const d=_.split("/").filter(Boolean);return d.length===0?_:d.slice(-2).join("/")}function Dn(_){if(_.provider==="codex"){const we=_.codexModel||"gpt-5.3-codex",ie=yn[we];return{model:(ie==null?void 0:ie.label)||we}}if(_.provider==="opencode")return{model:_.opencodeModel||"opencode"};const d=_.model||"sonnet",N=Mn[d],T=_.effort,W=T?En[T]:void 0;return{model:(N==null?void 0:N.label)||d,effort:W==null?void 0:W.label}}function On(_,d){if(d.type==="rectangle"&&d.width&&d.height){const N=d.width/2,T=d.height/2;return _.x>=d.center.x-N&&_.x<=d.center.x+N&&_.z>=d.center.z-T&&_.z<=d.center.z+T}if(d.type==="circle"&&d.radius){const N=_.x-d.center.x,T=_.z-d.center.z;return N*N+T*T<=d.radius*d.radius}return!1}const $n=gn.memo(function({agentId:d,terminalViewMode:N,onTerminalViewModeChange:T,inspectorOpen:W,onToggleInspector:we,onImageClick:ie,onFileClick:Ce,onBashClick:P,onViewMarkdown:Ee,onRequestClearSubordinates:Me,onOpenBuilding:Te,keyboard:We,canNavigateBack:He,canNavigateForward:Pe,onNavigateBack:Q,onNavigateForward:L,agentInfoOpen:ve,onToggleAgentInfo:X}){var le,Ie,Y,Qe;const h=bn(d),I=Dt(),oe=a.useRef(null),je=a.useRef(null);a.useEffect(()=>{const l=je.current;if(!l)return;const i=o=>{o.button===3?(o.preventDefault(),o.stopPropagation(),Q()):o.button===4&&(o.preventDefault(),o.stopPropagation(),L())},c=o=>{(o.button===3||o.button===4)&&o.preventDefault()};return l.addEventListener("mouseup",i),l.addEventListener("mousedown",c),()=>{l.removeEventListener("mouseup",i),l.removeEventListener("mousedown",c)}},[Q,L]),a.useEffect(()=>{const l=je.current;if(!l)return;let i=0,c=0,o=0;const re=250,be=600,Se=80,mt=1.5,ft=S=>{let k=S instanceof HTMLElement?S:null;for(;k&&k!==l;){const et=window.getComputedStyle(k).overflowX;if((et==="auto"||et==="scroll")&&k.scrollWidth>k.clientWidth)return!0;k=k.parentElement}return!1},F=S=>{const k=Date.now();if(k<o){S.preventDefault();return}if(Math.abs(S.deltaX)<=Math.abs(S.deltaY)*mt){i=0;return}if(ft(S.target)){i=0;return}k-c>re&&(i=0),c=k,i+=S.deltaX,i<=-Se?(i=0,o=k+be,S.preventDefault(),Q()):i>=Se&&(i=0,o=k+be,S.preventDefault(),L())};return l.addEventListener("wheel",F,{passive:!1}),()=>l.removeEventListener("wheel",F)},[Q,L]);const ce=zt(),Le=a.useMemo(()=>{if(!h)return null;const l=new Set,i=[];for(const c of ce.values())c.archived||c.directories.length===0||c.assignedAgentIds.includes(d)&&(l.add(c.id),i.push(c));for(const c of ce.values())c.archived||c.directories.length===0||l.has(c.id)||On({x:h.position.x,z:h.position.z},c)&&(l.add(c.id),i.push(c));return i.length===0?null:i.flatMap(c=>c.directories.filter(o=>o&&o.trim().length>0).map(o=>({areaId:c.id,areaName:c.name,dir:o})))},[h,d,ce]),{branches:Ge,fetchRemote:Ve,fetchingDirs:Re}=xn(Le),Ne=a.useMemo(()=>{var c;const l=f.getAreaForAgent(d);if(!l)return[];const i=[];for(const o of I.values())o.type==="terminal"&&f.isPositionInArea(o.position,l)&&i.push({id:o.id,name:o.name,hasUrl:!!((c=o.terminalStatus)!=null&&c.url)});return i},[d,I]),de=a.useMemo(()=>{var c;const l=f.getAreaForAgent(d);if(!l)return[];const i=[];for(const o of I.values())o.type==="server"&&((c=o.pm2)!=null&&c.enabled)&&f.isPositionInArea(o.position,l)&&i.push({id:o.id,name:o.name});return i},[d,I]),ee=a.useMemo(()=>{const l=f.getAreaForAgent(d);if(!l)return[];const i=[];for(const c of I.values())c.type==="database"&&c.database&&f.isPositionInArea(c.position,l)&&i.push({id:c.id,name:c.name});return i},[d,I]),[,te]=a.useReducer(l=>l+1,0),$=((le=oe.current)==null?void 0:le.search.searchMode)??!1,ot=a.useCallback(()=>{var l;(l=oe.current)==null||l.search.toggleSearch(),te()},[]),Xe=_n(),ne=Xe.isPending(Rt),[z,H]=a.useState(null),B=z?I.get(z):null,{height:G,onResizeStart:ke}=wn(),[D,U]=a.useState(()=>wt(C.GIT_PANEL_OPEN,!1)),[ue,Ue]=a.useState(()=>wt(C.BUILDINGS_PANEL_OPEN,!1)),[ae,pe]=a.useState(!1),ct=a.useCallback(()=>{pe(l=>{const i=!l;return i&&Cn.setEnabled(!0),i})},[]),dt=a.useCallback(()=>pe(!1),[]),me=a.useCallback(()=>{U(l=>{const i=!l;return J(C.GIT_PANEL_OPEN,i),i})},[]),ut=a.useCallback(()=>{Ue(l=>{const i=!l;return J(C.BUILDINGS_PANEL_OPEN,i),i})},[]),qe=a.useCallback(()=>{U(!1),J(C.GIT_PANEL_OPEN,!1)},[]),pt=a.useCallback(()=>{Ue(!1),J(C.BUILDINGS_PANEL_OPEN,!1)},[]),ze=vn();a.useEffect(()=>{if(!z)return;Ne.some(i=>i.id===z)||H(null)},[z,Ne]);const[fe,se]=a.useState(!1),De=a.useRef(null);if(a.useEffect(()=>{if(!fe)return;const l=i=>{De.current&&!De.current.contains(i.target)&&se(!1)};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[fe]),!h)return e.jsx("div",{className:"flat-chat flat-chat--empty",children:e.jsxs("div",{className:"flat-chat__placeholder",children:[e.jsx("span",{className:"flat-chat__placeholder-icon",children:"💬"}),e.jsx("span",{className:"flat-chat__placeholder-text",children:"Select an agent to start chatting"})]})});const q=h.contextStats,Ke=!!q,Ye=q?q.totalTokens:h.contextUsed||0,he=q?q.contextWindow:h.contextLimit||2e5,g=q?q.usedPercent:Math.round(Ye/he*100),R=Math.max(0,Math.min(100,g)),V=Math.max(0,100-R),ge=R>=80?"#ff4a4a":R>=60?"#ff9e4a":R>=40?"#ffd700":"#4aff9e",Oe=(Ye/1e3).toFixed(1),Ze=(he/1e3).toFixed(1),K=h.cwd,Je=K?zn(K):null,Ae=((Ie=h.subordinateIds)==null?void 0:Ie.length)||0,$e=Ae>0;return e.jsxs("div",{ref:je,className:`flat-terminal-wrapper ${D||ue||ae?"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 ${ve?"flat-terminal-wrapper__header-main--active":""}`,onClick:X,title:ve?"Hide agent info":"Show agent info","aria-pressed":ve,children:[e.jsx(Ot,{agent:h,size:28}),e.jsxs("span",{className:"flat-terminal-wrapper__header-info",children:[e.jsx("span",{className:"flat-terminal-wrapper__header-name",children:h.name}),e.jsx("span",{className:"flat-terminal-wrapper__header-status",style:{color:$t(h.status)},children:h.status})]}),h.taskLabel&&e.jsxs("span",{className:"flat-terminal-wrapper__header-task",title:h.taskLabel,children:["📋 ",h.taskLabel]}),e.jsxs("span",{className:"flat-terminal-wrapper__header-model",children:[e.jsx("img",{src:h.provider==="codex"?"/assets/codex.png":h.provider==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:h.provider,className:"flat-terminal-wrapper__header-provider-icon",title:h.provider==="codex"?"Codex Agent":h.provider==="opencode"?"OpenCode Agent":"Claude Agent"}),(()=>{const{model:l,effort:i}=Dn(h);return e.jsxs("span",{className:"flat-terminal-wrapper__header-model-chip",title:i?`Model: ${l} · Effort: ${i}`:`Model: ${l}`,children:[e.jsx("span",{className:"flat-terminal-wrapper__header-model-name",children:l}),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:Tn.map(l=>e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__view-mode-btn ${N===l?"flat-terminal-wrapper__view-mode-btn--active":""}`,onClick:()=>T(l),title:Rn[l],"aria-pressed":N===l,children:[e.jsx("span",{className:"flat-terminal-wrapper__view-mode-icon","aria-hidden":"true",children:Ln[l]}),e.jsx("span",{className:"flat-terminal-wrapper__view-mode-label",children:Pn[l]})]},l))}),e.jsxs("div",{className:"flat-terminal-wrapper__actions",role:"group","aria-label":"Terminal actions",children:[e.jsx("button",{type:"button",className:"flat-terminal-wrapper__action-btn",onClick:Q,disabled:!He,title:"Back to previous agent","aria-label":"Back to previous agent",children:e.jsx(u,{name:"arrow-left",size:14})}),e.jsx("button",{type:"button",className:"flat-terminal-wrapper__action-btn",onClick:L,disabled:!Pe,title:"Forward to next agent","aria-label":"Forward to next agent",children:e.jsx(u,{name:"arrow-right",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${$?"flat-terminal-wrapper__action-btn--active":""}`,onClick:ot,title:$?"Close search":"Search messages","aria-pressed":$,children:e.jsx(u,{name:$?"cross":"search",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn flat-terminal-wrapper__action-btn--danger ${ne?"flat-terminal-wrapper__action-btn--confirm":""}`,onClick:()=>Xe.handleClick(Rt,()=>{var l;f.clearContext(d),(l=oe.current)==null||l.historyLoader.clearHistory()}),title:ne?"Click again to confirm clear context":"Clear context",children:e.jsx(u,{name:ne?"question":"clear",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${D?"flat-terminal-wrapper__action-btn--active":""}`,onClick:me,title:D?"Hide git panel":"Show git changes","aria-pressed":D,children:e.jsx(u,{name:"git-branch",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${ue?"flat-terminal-wrapper__action-btn--active":""}`,onClick:ut,title:ue?"Hide buildings panel":"Show area buildings","aria-pressed":ue,children:e.jsx(u,{name:"buildings",size:14})}),e.jsxs("div",{className:"flat-terminal-wrapper__more",ref:De,children:[e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${fe?"flat-terminal-wrapper__action-btn--active":""}`,onClick:()=>se(l=>!l),title:"More actions","aria-expanded":fe,children:"⋮"}),fe&&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 ${ae?"flat-terminal-wrapper__more-item--active":""}`,onClick:()=>{ct(),se(!1)},title:ae?"Hide Debug Panel":"Show Debug Panel",children:[e.jsx(u,{name:"bug",size:14}),e.jsx("span",{children:ae?"Hide Debug Panel":"Show Debug Panel"})]}),e.jsx("div",{className:"flat-terminal-wrapper__more-divider"}),e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item",onClick:()=>{f.collapseContext(d),se(!1)},disabled:h.status!=="idle",title:h.status!=="idle"?"Agent must be idle to collapse context":"Collapse context",children:[e.jsx(u,{name:"package",size:14}),e.jsx("span",{children:"Collapse context"})]}),$e&&e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item flat-terminal-wrapper__more-item--danger",onClick:()=>{Me(d,Ae),se(!1)},children:[e.jsx(u,{name:"crown",size:14}),e.jsxs("span",{children:["Clear ",Ae," subordinate",Ae===1?"":"s"]})]}),e.jsx("div",{className:"flat-terminal-wrapper__more-divider"}),e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item flat-terminal-wrapper__more-item--danger",onClick:()=>{f.killAgent(d),se(!1)},children:[e.jsx(u,{name:"cross",size:14}),e.jsx("span",{children:"Remove agent"})]})]})]})]}),e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__inspector-toggle ${W?"flat-terminal-wrapper__inspector-toggle--active":""}`,onClick:we,title:W?"Hide inspector panel":"Show inspector panel","aria-label":W?"Hide inspector panel":"Show inspector panel","aria-pressed":W,children:[e.jsx("span",{className:"flat-terminal-wrapper__inspector-icon","aria-hidden":"true",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"}),e.jsx("line",{x1:"10",y1:"2.5",x2:"10",y2:"13.5"})]})}),e.jsx("span",{className:"flat-terminal-wrapper__inspector-label",children:"Inspector"})]}),e.jsx("button",{type:"button",className:"flat-terminal-wrapper__close",onClick:()=>f.deselectAll(),title:"Close chat","aria-label":"Close chat",children:e.jsx(u,{name:"cross",size:14})})]})]}),e.jsx(jn,{ref:oe,agentId:d,agent:h,viewMode:N,isOpen:!0,onImageClick:ie,onFileClick:Ce,onBashClick:P,onViewMarkdown:Ee,keyboard:We,hasModalOpen:!1}),B&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"guake-bottom-terminal-resize",onMouseDown:ke,role:"separator","aria-orientation":"horizontal","aria-label":"Resize embedded terminal"}),e.jsxs("div",{className:"flat-bottom-panel",role:"region","aria-label":`Embedded terminal: ${B.name}`,style:{height:G},children:[e.jsxs("div",{className:"flat-bottom-panel__header",children:[e.jsxs("span",{className:"flat-bottom-panel__title",children:[e.jsx(u,{name:"terminal",size:12}),e.jsx("span",{children:B.name}),!((Y=B.terminalStatus)!=null&&Y.url)&&e.jsx("span",{className:"flat-bottom-panel__muted",children:"(starting...)"})]}),e.jsx("button",{type:"button",className:"flat-bottom-panel__close",onClick:()=>H(null),title:"Close embedded terminal","aria-label":"Close embedded terminal",children:e.jsx(u,{name:"cross",size:12})})]}),e.jsx("div",{className:"flat-bottom-panel__body",children:(Qe=B.terminalStatus)!=null&&Qe.url?e.jsx(Nn,{terminalUrl:B.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:[h.isDetached&&e.jsxs("span",{className:"flat-terminal-wrapper__detached",title:"Reattaching session...",children:[e.jsx(u,{name:"refresh",size:12}),e.jsx("span",{children:"Reattaching"})]}),K&&Je&&e.jsxs("span",{className:"flat-terminal-wrapper__cwd",title:`Open in file explorer: ${K}`,"aria-label":`Open ${K} in file explorer`,role:"button",tabIndex:0,onClick:()=>f.openFileExplorer(K),onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),f.openFileExplorer(K))},children:[e.jsx("span",{className:"flat-terminal-wrapper__cwd-icon",children:e.jsx(u,{name:"folder",size:12})}),e.jsx("span",{className:"flat-terminal-wrapper__cwd-text",children:Je})]}),Le&&Le.map(({areaId:l,areaName:i,dir:c})=>{const o=Ge.get(c),re=Re.has(c),be=c.split("/").filter(Boolean).pop()||c;return e.jsxs("span",{className:"flat-terminal-wrapper__area-dir",title:`${i}: ${c}${o?` (${o.branch}${o.ahead?` ↑${o.ahead}`:""}${o.behind?` ↓${o.behind}`:""})`:""}`,onClick:()=>f.openFileExplorerForAreaFolder(l,c),children:[e.jsx(u,{name:"folder-open",size:12}),e.jsx("span",{className:"flat-terminal-wrapper__area-dir-name",children:be}),o&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flat-terminal-wrapper__area-dir-branch",children:[e.jsx(u,{name:"git-branch",size:10})," ",o.branch]}),o.ahead>0&&e.jsxs("span",{className:"flat-terminal-wrapper__branch-ahead",title:`${o.ahead} ahead`,children:[e.jsx(u,{name:"arrow-up",size:9}),o.ahead]}),o.behind>0&&e.jsxs("span",{className:"flat-terminal-wrapper__branch-behind",title:`${o.behind} behind`,children:[e.jsx(u,{name:"arrow-down",size:9}),o.behind]}),e.jsx("span",{className:`flat-terminal-wrapper__area-fetch ${re?"flat-terminal-wrapper__area-fetch--fetching":""}`,title:"Git fetch",onClick:Se=>{Se.stopPropagation(),Ve(c)},children:e.jsx(u,{name:re?"hourglass":"download",size:12})})]})]},`${l}:${c}`)}),e.jsxs("span",{className:"flat-terminal-wrapper__context",onClick:()=>f.setContextModalAgentId(d),title:Ke?`Context usage: ${Oe}k / ${Ze}k tokens (${R}% used). Click to view stats.`:"Click to fetch context stats",children:[e.jsx("span",{className:"flat-terminal-wrapper__context-icon",children:e.jsx(u,{name:"dashboard",size:12})}),e.jsx("span",{className:"flat-terminal-wrapper__context-label",children:"Ctx:"}),e.jsx("span",{className:"flat-terminal-wrapper__context-bar",children:e.jsx("span",{className:"flat-terminal-wrapper__context-bar-fill",style:{width:`${R}%`,backgroundColor:ge}})}),e.jsxs("span",{className:"flat-terminal-wrapper__context-tokens",style:{color:ge},children:[Oe,"k/",Ze,"k"]}),e.jsxs("span",{className:"flat-terminal-wrapper__context-free",children:["(",V,"% free)"]}),!Ke&&e.jsx("span",{className:"flat-terminal-wrapper__context-warning",title:"No context stats yet",children:e.jsx(u,{name:"warn",size:12})})]}),e.jsx("div",{className:"flat-terminal-wrapper__statusbar-spacer","aria-hidden":"true"}),Ne.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area terminals",children:Ne.map(l=>{const i=z===l.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${i?"flat-terminal-wrapper__building-btn--active":""} ${l.hasUrl?"":"flat-terminal-wrapper__building-btn--offline"}`,title:`${i?"Hide":"Show"} terminal: ${l.name}${l.hasUrl?"":" (starting...)"}`,onClick:()=>{if(i){H(null);return}l.hasUrl||f.sendBuildingCommand(l.id,"start"),H(l.id)},children:e.jsx(u,{name:"terminal",size:14})},l.id)})}),de.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area PM2 logs",children:de.map(l=>e.jsx("button",{type:"button",className:"flat-terminal-wrapper__building-btn",title:`Open logs: ${l.name}`,onClick:()=>Te(l.id),children:e.jsx(u,{name:"scroll",size:14})},l.id))}),ee.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area databases",children:ee.map(l=>e.jsx("button",{type:"button",className:"flat-terminal-wrapper__building-btn",title:`Open database: ${l.name}`,onClick:()=>Te(l.id),children:e.jsx(u,{name:"hard-drives",size:14})},l.id))}),e.jsx("div",{className:"flat-terminal-wrapper__theme",children:e.jsx(kn,{})})]}),D&&e.jsx(An,{agentId:d,agents:ze,onClose:qe,branchInfoMap:Ge,fetchRemote:Ve,fetchingDirs:Re}),ue&&e.jsx(In,{agentId:d,onClose:pt}),ae&&e.jsx(Sn,{agentId:d,onClose:dt})]})});function Hn({onAgentClick:_,onBuildingClick:d,onBuildingDoubleClick:N,onBuildingPopup:T,onOpenSpawnModal:W,onOpenBossSpawnModal:we,onOpenAreaModal:ie}){const{t:Ce}=Yt(["common"]),P=Zt(),Ee=Jt(),[Me,Te]=a.useState(null),[We,He]=a.useState(null),[Pe,Q]=a.useState(null),[L,ve]=a.useState(null),[X,h]=a.useState(null),[I,oe]=a.useState(null),[je,ce]=a.useState(!1),Le=a.useCallback(()=>{ce(t=>!t)},[]),Ge=a.useCallback(()=>{ce(!1)},[]),[Ve,Re]=a.useState(()=>{const t=It(C.VIEW_MODE);return t==="simple"||t==="chat"||t==="advanced"?t:"simple"}),Ne=a.useCallback(t=>{Re(t),St(C.VIEW_MODE,t)},[]);a.useEffect(()=>{const t=n=>{if(n.key!==C.VIEW_MODE)return;const s=n.newValue;(s==="simple"||s==="chat"||s==="advanced")&&Re(s)};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)},[]);const[de,ee]=a.useState(()=>wt(C.FLAT_INSPECTOR_OPEN,!1)),[te,$]=a.useState(!1),ot=a.useCallback(()=>$(t=>!t),[]),Xe=a.useCallback(()=>$(!1),[]);a.useEffect(()=>{window.dispatchEvent(new CustomEvent("tide-flat-agents-drawer-state",{detail:{open:te}}))},[te]),a.useEffect(()=>{window.dispatchEvent(new CustomEvent("tide-flat-inspector-state",{detail:{open:de}}))},[de]),a.useEffect(()=>{const t=()=>$(m=>!m),n=()=>{ee(m=>{const x=!m;return J(C.FLAT_INSPECTOR_OPEN,x),x})},s=()=>{$(!1),ee(!1),J(C.FLAT_INSPECTOR_OPEN,!1)},r=()=>$(!1),p=()=>{ee(!1),J(C.FLAT_INSPECTOR_OPEN,!1)};return window.addEventListener("tide-toggle-flat-agents-drawer",t),window.addEventListener("tide-toggle-flat-inspector",n),window.addEventListener("tide-close-flat-side-views",s),window.addEventListener("tide-close-flat-agents-drawer-only",r),window.addEventListener("tide-close-flat-inspector-only",p),()=>{window.removeEventListener("tide-toggle-flat-agents-drawer",t),window.removeEventListener("tide-toggle-flat-inspector",n),window.removeEventListener("tide-close-flat-side-views",s),window.removeEventListener("tide-close-flat-agents-drawer-only",r),window.removeEventListener("tide-close-flat-inspector-only",p)}},[]);const ne=a.useRef(null),z=a.useRef(null),[H,B]=a.useState(()=>{const t=yt(C.FLAT_MIDDLE_WIDTH,0);return t>=it?t:null}),[G,ke]=a.useState(()=>{const t=yt(C.FLAT_INSPECTOR_WIDTH,0);return t>=_t?t:null}),D=a.useCallback(t=>{if(typeof window>"u")return t;const n=G!==null?rt+G:0,s=window.innerWidth-Lt-rt-Pt-n;return Math.max(it,Math.min(Math.max(s,it),t))},[G]),U=a.useCallback(t=>{var p;if(typeof window>"u")return t;const n=(p=ne.current)==null?void 0:p.querySelector(".flat-middle"),s=(n==null?void 0:n.getBoundingClientRect().width)??it,r=window.innerWidth-Lt-s-rt-Pt-rt;return Math.max(_t,Math.min(Math.max(r,_t),t))},[]);a.useEffect(()=>{if(H===null&&G===null)return;const t=()=>{B(n=>{if(n===null)return n;const s=D(n);return s===n?n:s}),ke(n=>{if(n===null)return n;const s=U(n);return s===n?n:s})};return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[H,G,D,U]);const ue=a.useCallback(t=>{var s;if(t.button!==0)return;const n=(s=ne.current)==null?void 0:s.querySelector(".flat-middle");n&&(t.currentTarget.setPointerCapture(t.pointerId),z.current={kind:"middle",startX:t.clientX,startWidth:n.getBoundingClientRect().width,pointerId:t.pointerId},document.body.classList.add("flat-splitter-dragging"))},[]),Ue=a.useCallback(t=>{var s;if(t.button!==0)return;const n=(s=ne.current)==null?void 0:s.querySelector(".flat-inspector");n&&(t.currentTarget.setPointerCapture(t.pointerId),z.current={kind:"inspector",startX:t.clientX,startWidth:n.getBoundingClientRect().width,pointerId:t.pointerId},document.body.classList.add("flat-splitter-dragging"))},[]),ae=a.useCallback(t=>{const n=z.current;if(!n||t.pointerId!==n.pointerId)return;const s=t.clientX-n.startX;n.kind==="middle"?B(D(n.startWidth+s)):ke(U(n.startWidth-s))},[D,U]),pe=a.useCallback(t=>{const n=z.current;if(!n||t.pointerId!==n.pointerId)return;try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}if(z.current=null,document.body.classList.remove("flat-splitter-dragging"),!(Math.abs(t.clientX-n.startX)>2))return;const r=t.clientX-n.startX;if(n.kind==="middle"){const p=D(n.startWidth+r);B(p),lt(C.FLAT_MIDDLE_WIDTH,p)}else{const p=U(n.startWidth-r);ke(p),lt(C.FLAT_INSPECTOR_WIDTH,p)}},[D,U]),ct=a.useCallback(()=>{B(null),lt(C.FLAT_MIDDLE_WIDTH,0)},[]),dt=a.useCallback(()=>{ke(null),lt(C.FLAT_INSPECTOR_WIDTH,0)},[]),[me,ut]=a.useState(()=>It(C.FLAT_INSPECTOR_VIEW)==="tracking"?"tracking":"agent"),qe=a.useCallback(t=>{ut(t),St(C.FLAT_INSPECTOR_VIEW,t)},[]),pt=a.useCallback(()=>{ee(t=>{const n=!t;return J(C.FLAT_INSPECTOR_OPEN,n),n})},[]),ze=a.useCallback(()=>{ee(!1),J(C.FLAT_INSPECTOR_OPEN,!1)},[]),fe=Qt(),se=a.useCallback((t,n)=>{Te({url:t,name:n})},[]),De=a.useCallback((t,n)=>{He({command:t,output:n,isLive:!1})},[]),q=a.useCallback((t,n)=>{f.setFileViewerPath(t,n)},[]),Ke=a.useCallback(t=>{},[]),Ye=a.useCallback((t,n)=>{Q({agentId:t,count:n})},[]),he=a.useCallback(t=>{N?N(t):d(t)},[d,N]),g=a.useMemo(()=>Ee.size>0?Array.from(Ee)[0]:null,[Ee]);a.useEffect(()=>{ce(!1)},[g]);const R=a.useRef([]),V=a.useRef(-1),ge=a.useRef(!1),Oe=a.useRef(null),[Ze,K]=a.useState(!1),[Je,Ae]=a.useState(!1),$e=a.useRef(!1),le=a.useRef(null),Ie=a.useRef(!1),Y=a.useMemo(()=>new Set(P.map(t=>t.id)),[P]),Qe=a.useMemo(()=>{const t=new Map(P.map(s=>[s.id,s])),n=new Map;for(const s of P)if((s.isBoss||s.class==="boss")&&s.subordinateIds&&s.subordinateIds.length>0){const r=s.subordinateIds.map(p=>t.get(p)).filter(p=>p!==void 0);r.length>0&&n.set(s.id,r)}return n},[P]),l=a.useCallback(()=>{const t=R.current,n=V.current;K(n>0),Ae(n>=0&&n<t.length-1)},[]),i=a.useCallback(t=>{const n=R.current;if(n.length===0)return;let s=V.current+t;for(;s>=0&&s<n.length;){const r=n[s];if(Y.has(r)){ge.current=!0,V.current=s,l(),f.selectAgent(r);return}s+=t}},[Y,l]),c=a.useCallback(()=>i(-1),[i]),o=a.useCallback(()=>i(1),[i]),re=a.useCallback((t,n)=>{if(typeof window>"u")return;const s=window.history.state,p={...typeof s=="object"&&s!==null?s:{},__flatAgentNav:{agentId:t}};n==="replace"?window.history.replaceState(p,"",window.location.href):window.history.pushState(p,"",window.location.href)},[]);a.useEffect(()=>{if(!g){$e.current=!1,le.current=null;return}if(!$e.current){re(g,"replace"),$e.current=!0,le.current=g;return}if(Ie.current){Ie.current=!1,le.current=g;return}le.current!==g&&(re(g,"push"),le.current=g)},[g,re]),a.useEffect(()=>{const t=n=>{var m,x;const s=(x=(m=n.state)==null?void 0:m.__flatAgentNav)==null?void 0:x.agentId;if(!s||typeof s!="string"||!Y.has(s)||s===g)return;Ie.current=!0,ge.current=!0;const r=R.current,p=r.lastIndexOf(s);p>=0?V.current=p:(r.push(s),V.current=r.length-1),l(),f.selectAgent(s)};return window.addEventListener("popstate",t),()=>window.removeEventListener("popstate",t)},[Y,g,l]),a.useEffect(()=>{if(!g){R.current=[],V.current=-1,l();return}if(Oe.current=g,ge.current){ge.current=!1,l();return}const t=R.current,n=V.current;if(n>=0&&t[n]===g){l();return}const s=n<t.length-1?t.slice(0,n+1):t.slice();s.push(g),s.length>100&&s.shift(),R.current=s,V.current=s.length-1,l()},[g,l]);const be=a.useCallback(t=>{_(t),$(!1)},[_]),Se=g??"",mt=a.useCallback(()=>{},[]),ft=a.useCallback(t=>{be(t)},[be]),F=de,[S,k]=a.useState(F),[et,Ct]=a.useState(F);a.useEffect(()=>{if(F){k(!0);return}Ct(!1);const t=setTimeout(()=>k(!1),240);return()=>clearTimeout(t)},[F]),a.useEffect(()=>{if(!S||!F)return;let t=0;const n=requestAnimationFrame(()=>{t=requestAnimationFrame(()=>Ct(!0))});return()=>{cancelAnimationFrame(n),cancelAnimationFrame(t)}},[S,F]);const vt=a.useRef(null);a.useEffect(()=>{if(g)return;const t=n=>{if(n.key!==" "&&n.key!=="Backspace")return;const s=n.target;if(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable)return;const r=Oe.current;!r||!Y.has(r)||(n.preventDefault(),f.selectAgent(r))};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[g,Y]);const[Bt,jt]=a.useState(new Set),Ft=a.useCallback(t=>{jt(n=>{const s=new Set(n);return s.has(t)?s.delete(t):s.add(t),s})},[]),ht=zt(),tt=Dt(),[Wt]=en(),ye=a.useMemo(()=>{const t=new Map,n=[];for(const b of P){const v=f.getAreaForAgent(b.id);if(!Et((v==null?void 0:v.id)??null))continue;if(!v||v.archived){n.push(b);continue}const j=t.get(v.id);j?j.push(b):t.set(v.id,[b])}const s=new Map,r=[];for(const b of tt.values()){let v=!1;for(const j of ht.values())if(!j.archived&&Mt(j.id)&&f.isPositionInArea(b.position,j)){const Z=s.get(j.id);Z?Z.push(b):s.set(j.id,[b]),v=!0;break}!v&&Et(null)&&r.push(b)}const p=[];for(const[,b]of ht){if(b.archived||!Mt(b.id))continue;const v=t.get(b.id),j=s.get(b.id)??[];(v&&v.length>0||j.length>0)&&p.push({area:b,agents:v??[],buildings:j})}(n.length>0||r.length>0)&&p.push({area:{id:"__unassigned__",name:"Unassigned",color:"#6272a4",center:{x:0,z:0},type:"circle",radius:0,directories:[],archived:!1,assignedAgentIds:[],zIndex:0},agents:n,buildings:r});const m=p.filter(b=>b.area.id!=="__unassigned__"),x=p.filter(b=>b.area.id==="__unassigned__");let O=1,y=1;const Be=new Map;if(m.length>1){let b=1/0,v=-1/0,j=1/0,Z=-1/0;for(const E of m)b=Math.min(b,E.area.center.x),v=Math.max(v,E.area.center.x),j=Math.min(j,E.area.center.z),Z=Math.max(Z,E.area.center.z);const nt=v-b||1,at=Z-j||1;if(m.length<=4){O=m.length,y=1;const E=[...m].sort((M,gt)=>M.area.center.x-gt.area.center.x);for(let M=0;M<E.length;M++)Be.set(E[M].area.id,{row:1,col:M+1})}else{const E=[...m].sort((w,A)=>w.area.center.x-A.area.center.x),M=[];for(let w=1;w<E.length;w++)M.push(E[w].area.center.x-E[w-1].area.center.x);const gt=M.reduce((w,A)=>w+A,0)/M.length||1;let Nt=1;for(const w of M)w>gt*1.3&&Nt++;O=Math.max(2,Math.min(Nt,m.length));const bt=[...m].sort((w,A)=>w.area.center.z-A.area.center.z),st=[];for(let w=1;w<bt.length;w++)st.push(bt[w].area.center.z-bt[w-1].area.center.z);const Xt=st.reduce((w,A)=>w+A,0)/st.length||1;let kt=1;for(const w of st)w>Xt*1.3&&kt++;y=Math.max(2,Math.min(kt,m.length)),O=Math.max(O,Math.ceil(m.length/y)),y=Math.max(y,Math.ceil(m.length/O));const Ut=nt/O,qt=at/y,xt=new Set;for(const w of m){let A=Math.min(O-1,Math.max(0,Math.floor((w.area.center.x-b)/Ut))),_e=Math.min(y-1,Math.max(0,Math.floor((w.area.center.z-j)/qt))),Fe=`${_e},${A}`,At=0;const Kt=y*O;for(;xt.has(Fe)&&At<Kt;)A++,A>=O&&(A=0,_e=(_e+1)%y),Fe=`${_e},${A}`,At++;xt.has(Fe)&&(_e=y,A=0,Fe=`${_e},${A}`,y++),xt.add(Fe),Be.set(w.area.id,{row:_e+1,col:A+1})}}}const xe=b=>{b.sort((v,j)=>{var nt,at,E,M;const Z=(((nt=v.position)==null?void 0:nt.z)??0)-(((at=j.position)==null?void 0:at.z)??0);return Z!==0?Z:(((E=v.position)==null?void 0:E.x)??0)-(((M=j.position)==null?void 0:M.x)??0)})};for(const b of m)xe(b.agents);for(const b of x)xe(b.agents);return{groups:[...m,...x],gridCols:O,gridRows:y,positions:Be}},[P,ht,tt,Wt]),Ht=a.useMemo(()=>{if(!L)return[];const t=P.find(n=>n.id===L.agentId);return t?[{id:"edit-agent",label:"Edit Agent",icon:e.jsx(u,{name:"edit",size:14}),onClick:()=>{window.dispatchEvent(new CustomEvent("tide:open-agent-edit",{detail:{agentId:t.id}}))}},{id:"open-chat",label:"Open Chat",icon:e.jsx(u,{name:"chat",size:14}),onClick:()=>_(t.id)},{id:"delete-agent",label:"Delete Agent",icon:e.jsx(u,{name:"trash",size:14}),danger:!0,onClick:()=>{oe({agentId:t.id,name:t.name})}}]:[]},[L,P,_]),Gt=a.useMemo(()=>{var m;if(!X)return[];const t=tt.get(X.buildingId);if(!t)return[];const n=[],s=t.type==="server"||t.type==="docker"||t.type==="terminal",r=t.status==="running",p=t.type==="boss";if(n.push({id:"open",label:t.type==="database"?"Open Database":t.type==="folder"?"Open Folder":t.type==="boss"?"View Boss Logs":t.type==="terminal"?"Open Terminal":t.type==="server"&&((m=t.pm2)!=null&&m.enabled)?"View PM2 Logs":"Open",icon:e.jsx(u,{name:t.type==="database"?"database":t.type==="folder"?"folder":t.type==="terminal"?"terminal":"eye",size:14}),onClick:()=>he(t.id)}),s&&(r||n.push({id:"start",label:"Start",icon:e.jsx(u,{name:"play",size:14}),onClick:()=>f.sendBuildingCommand(t.id,"start")}),r&&(n.push({id:"restart",label:"Restart",icon:e.jsx(u,{name:"refresh",size:14}),onClick:()=>f.sendBuildingCommand(t.id,"restart")}),n.push({id:"stop",label:"Stop",icon:e.jsx(u,{name:"stop",size:14}),onClick:()=>f.sendBuildingCommand(t.id,"stop")}))),p&&t.subordinateBuildingIds&&t.subordinateBuildingIds.length>0&&(n.push({id:"start-all",label:"Start All Subordinates",icon:e.jsx(u,{name:"launch",size:14}),onClick:()=>{for(const x of t.subordinateBuildingIds)f.sendBuildingCommand(x,"start")}}),n.push({id:"stop-all",label:"Stop All Subordinates",icon:e.jsx(u,{name:"pause",size:14}),onClick:()=>{for(const x of t.subordinateBuildingIds)f.sendBuildingCommand(x,"stop")}}),n.push({id:"restart-all",label:"Restart All Subordinates",icon:e.jsx(u,{name:"restart",size:14}),onClick:()=>{for(const x of t.subordinateBuildingIds)f.sendBuildingCommand(x,"restart")}})),s&&n.push({id:"health-check",label:"Health Check",icon:e.jsx(u,{name:"health",size:14}),onClick:()=>f.sendBuildingCommand(t.id,"healthCheck")}),n.push({id:"divider-edit",label:"",divider:!0,onClick:()=>{}}),n.push({id:"edit",label:"Edit Building",icon:e.jsx(u,{name:"edit",size:14}),onClick:()=>{window.dispatchEvent(new CustomEvent("tide:building-edit",{detail:{buildingId:t.id}}))}}),n.push({id:"clone",label:"Clone Building",icon:e.jsx(u,{name:"copy",size:14}),onClick:()=>{f.createBuilding({name:`${t.name} (Copy)`,type:t.type,style:t.style,color:t.color,scale:t.scale,position:{x:t.position.x+2,z:t.position.z+2},cwd:t.cwd,folderPath:t.folderPath,commands:t.commands,pm2:t.pm2,docker:t.docker,database:t.database,terminal:t.terminal,urls:t.urls,subordinateBuildingIds:t.subordinateBuildingIds})}}),t.urls&&t.urls.length>0)for(const x of t.urls)n.push({id:`url-${x.label}`,label:x.label,icon:e.jsx(u,{name:"link",size:14}),onClick:()=>window.open(x.url,"_blank","noopener,noreferrer")});return n.push({id:"divider-danger",label:"",divider:!0,onClick:()=>{}}),n.push({id:"delete",label:"Delete Building",icon:e.jsx(u,{name:"trash",size:14}),danger:!0,onClick:()=>f.deleteBuilding(t.id)}),n},[X,tt,he]),Vt=a.useCallback(t=>{const n=new Set(ye.groups.map(s=>s.area.id));n.delete(t),jt(n),requestAnimationFrame(()=>{const s=vt.current;if(!s)return;const r=s.querySelector(`[data-area-id="${t}"]`);if(!r)return;const p=s.getBoundingClientRect(),x=r.getBoundingClientRect().top-p.top+s.scrollTop-8;s.scrollTo({top:Math.max(0,x),behavior:"smooth"})})},[ye]);return e.jsxs("div",{ref:ne,className:`flat-view ${F?"flat-view--with-inspector":""} ${g?"flat-view--has-chat":""} ${te?"flat-view--mobile-sidebar-open":""}`,style:(()=>{if(H===null&&G===null)return;const t={};return H!==null&&(t["--flat-middle-width"]=`${H}px`),G!==null&&(t["--flat-inspector-width"]=`${G}px`),t})(),children:[te&&e.jsx("div",{className:"flat-mobile-sidebar-backdrop",onClick:Xe,"aria-hidden":"true"}),e.jsxs("div",{className:"flat-middle",children:[e.jsx("div",{className:"flat-middle__header",children:e.jsxs("div",{className:"flat-middle__actions",children:[e.jsx("button",{className:"flat-cta-btn flat-cta-btn--agent",onClick:W,title:"Create new agent",children:"+ Agent"}),e.jsx("button",{className:"flat-cta-btn flat-cta-btn--boss",onClick:we,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(tn,{activeAgentId:Se,onClose:mt,onSelectAgent:ft,collapsedAreas:Bt,onToggleArea:Ft,agentListRef:vt})})]}),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:ue,onPointerMove:ae,onPointerUp:pe,onPointerCancel:pe,onDoubleClick:ct}),e.jsxs("div",{className:"flat-right",children:[e.jsxs("button",{type:"button",className:"flat-mobile-sidebar-toggle","aria-label":te?"Close agents sidebar":"Open agents sidebar","aria-expanded":te,onClick:ot,children:[e.jsx(u,{name:"list",size:18}),e.jsx("span",{className:"flat-mobile-sidebar-toggle__label",children:"Agents"})]}),g?e.jsx($n,{agentId:g,terminalViewMode:Ve,onTerminalViewModeChange:Ne,inspectorOpen:de,onToggleInspector:pt,onImageClick:se,onFileClick:q,onBashClick:De,onViewMarkdown:Ke,onRequestClearSubordinates:Ye,onOpenBuilding:he,keyboard:fe,canNavigateBack:Ze,canNavigateForward:Je,onNavigateBack:c,onNavigateForward:o,agentInfoOpen:je,onToggleAgentInfo:Le}):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(${ye.gridCols}, 1fr)`},children:ye.groups.length===0?e.jsx("div",{className:"flat-map__empty",children:e.jsx("span",{children:"No areas or agents yet"})}):ye.groups.map(t=>{const n=t.area.id,s=ye.positions.get(n);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:()=>Vt(n),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(r=>{const p=r.isBoss||r.class==="boss",m=p?Qe.get(r.id):void 0,x=nn(r),O=x.usedPercent>=80?"#ff4a4a":x.usedPercent>=60?"#ff9e4a":x.usedPercent>=40?"#ffd700":"#4aff9e",y=`Context: ${(x.totalTokens/1e3).toFixed(1)}k / ${(x.contextWindow/1e3).toFixed(1)}k (${x.usedPercent}% used, ${x.freePercent}% free)`,Be=r.latestTodos&&r.latestTodos.length>0||m&&m.length>0;return e.jsx(an,{todos:r.latestTodos,subordinates:m,position:"top",children:e.jsxs("button",{type:"button",className:`flat-map-agent-chip ${r.status}`,onClick:()=>_(r.id),onContextMenu:xe=>{xe.preventDefault(),xe.stopPropagation(),ve({agentId:r.id,position:{x:xe.clientX,y:xe.clientY}})},title:Be?void 0:`${p?"Boss · ":""}Open chat with ${r.name}
2
+ ${y}`,children:[e.jsx(Ot,{agent:r,size:16}),p&&e.jsx("span",{className:"flat-map-agent-chip__crown","aria-hidden":"true",children:e.jsx(u,{name:"crown",size:11,color:"#ffd700",weight:"fill"})}),e.jsx("span",{className:"flat-map-agent-chip__name",children:r.name}),e.jsx("img",{src:r.provider==="codex"?"/assets/codex.png":r.provider==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:r.provider,className:"flat-map-agent-chip__provider-icon",title:r.provider==="codex"?"Codex Agent":r.provider==="opencode"?"OpenCode Agent":"Claude Agent"}),e.jsx("span",{className:"flat-map-agent-chip__dot",style:{backgroundColor:$t(r.status)}}),r.latestTodos&&r.latestTodos.length>0&&e.jsx(sn,{todos:r.latestTodos,maxDots:6}),p&&m&&m.length>0&&e.jsx(ln,{subordinates:m,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:`${x.usedPercent}%`,backgroundColor:O}})})]})},r.id)})}),t.buildings.length>0&&e.jsx("div",{className:"flat-map-area-card__buildings",children:t.buildings.map(r=>e.jsxs("button",{type:"button",className:`flat-map-building-chip flat-map-building-chip--${r.status}`,onClick:p=>{if(T){const m=p.currentTarget.getBoundingClientRect();T(r.id,{x:m.right,y:m.top+m.height/2})}else he(r.id)},onContextMenu:p=>{p.preventDefault(),p.stopPropagation(),h({buildingId:r.id,position:{x:p.clientX,y:p.clientY}})},title:`${r.name} · ${r.type} · ${r.status}`,children:[e.jsx(u,{name:rn(r.type),size:12}),e.jsx("span",{className:"flat-map-building-chip__name",children:r.name}),e.jsx("span",{className:"flat-map-building-chip__dot",style:{backgroundColor:on(r.status)}})]},r.id))})]},n)})})]})})]}),F&&e.jsx("div",{className:"flat-splitter flat-splitter--inspector",role:"separator","aria-orientation":"vertical","aria-label":"Resize inspector panel",title:"Drag to resize · Double-click to reset",onPointerDown:Ue,onPointerMove:ae,onPointerUp:pe,onPointerCancel:pe,onDoubleClick:dt}),S&&e.jsxs("aside",{className:`flat-inspector ${et?"flat-inspector--open":"flat-inspector--closing"}`,"aria-label":"Inspector panel",children:[e.jsxs("div",{className:"flat-inspector__header",children:[e.jsxs("div",{className:"flat-inspector__tabs",role:"tablist","aria-label":"Inspector view",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":me==="agent",className:`flat-inspector__tab ${me==="agent"?"flat-inspector__tab--active":""}`,onClick:()=>qe("agent"),children:"Agent"}),e.jsx("button",{type:"button",role:"tab","aria-selected":me==="tracking",className:`flat-inspector__tab ${me==="tracking"?"flat-inspector__tab--active":""}`,onClick:()=>qe("tracking"),children:"Tracking"})]}),e.jsx("button",{type:"button",className:"flat-inspector__close",onClick:ze,title:"Close inspector","aria-label":"Close inspector",children:"✕"})]}),e.jsx("div",{className:"flat-inspector__body",children:me==="tracking"?e.jsx(cn,{activeAgentId:g??"",onSelectAgent:t=>{_(t),ze()}}):(()=>{if(!g)return e.jsx("div",{className:"flat-inspector__empty",children:e.jsx("span",{children:"Select an agent to inspect"})});const t=P.find(n=>n.id===g);return t?e.jsx(dn,{agent:t,onFocusAgent:n=>{_(n),ze()},onKillAgent:n=>f.killAgent(n)}):e.jsx("div",{className:"flat-inspector__empty",children:e.jsx("span",{children:"Agent not found"})})})()})]}),Me&&e.jsx(un,{url:Me.url,name:Me.name,onClose:()=>Te(null)}),We&&e.jsx(pn,{state:We,onClose:()=>He(null)}),Pe&&e.jsx(mn,{action:"clear-subordinates",selectedAgentId:Pe.agentId,subordinateCount:Pe.count,onClose:()=>Q(null),onClearHistory:()=>{}}),e.jsx(fn,{agent:g?P.find(t=>t.id===g)??null:null,isOpen:je&&!!g,onClose:Ge}),e.jsx(Tt,{isOpen:L!==null,position:(L==null?void 0:L.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:Ht,onClose:()=>ve(null)}),e.jsx(Tt,{isOpen:X!==null,position:(X==null?void 0:X.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:Gt,onClose:()=>h(null)}),e.jsx(hn,{isOpen:I!==null,title:Ce("common:confirm.removeAgentTitle"),message:Ce("common:confirm.removeAgentMessage",{name:(I==null?void 0:I.name)??""}),confirmLabel:Ce("common:buttons.remove"),cancelLabel:Ce("common:buttons.cancel"),variant:"danger",onConfirm:()=>{I&&f.removeAgentFromServer(I.agentId)},onClose:()=>oe(null)})]})}export{Hn as FlatView};