tide-commander 1.43.0 → 1.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/assets/{BossLogsModal-CnIyv0O7.js → BossLogsModal-CTo4Bbm7.js} +1 -1
  2. package/dist/assets/BossSpawnModal-DOk9u7EW.js +1 -0
  3. package/dist/assets/{ControlsModal-DJ6kwJQg.js → ControlsModal-BzBzF0Cw.js} +1 -1
  4. package/dist/assets/{DockerLogsModal-wLLPPw3N.js → DockerLogsModal-CrHd6OZ3.js} +1 -1
  5. package/dist/assets/{EmbeddedEditor-BZUBqqzE.js → EmbeddedEditor-h8IrAy4E.js} +1 -1
  6. package/dist/assets/{GmailOAuthSetup-DU-rYgPc.js → GmailOAuthSetup-io57q0N8.js} +1 -1
  7. package/dist/assets/{GoogleOAuthSetup-DUG794k5.js → GoogleOAuthSetup-YyNFVd9Y.js} +1 -1
  8. package/dist/assets/{IframeModal-BEaeYao1.js → IframeModal-DqmSDXCT.js} +1 -1
  9. package/dist/assets/{IntegrationsPanel-CrT3G7gD.js → IntegrationsPanel-DiW8UeG5.js} +2 -2
  10. package/dist/assets/{LogViewerModal-pmKvg2_3.js → LogViewerModal-CGW8yajP.js} +1 -1
  11. package/dist/assets/{MonitoringModal-BopLTYX0.js → MonitoringModal-BfsYrF1j.js} +1 -1
  12. package/dist/assets/{PM2LogsModal-akdCsnNY.js → PM2LogsModal-BJytXxKY.js} +1 -1
  13. package/dist/assets/{RestoreArchivedAreaModal-BAe0BLNN.js → RestoreArchivedAreaModal-CtRiwwzT.js} +1 -1
  14. package/dist/assets/{SaveSnapshotModal-CCK5ncy-.js → SaveSnapshotModal-BHBdh1dK.js} +1 -1
  15. package/dist/assets/{Scene2DCanvas-CTrNCLiT.js → Scene2DCanvas-BYUuUYur.js} +1 -1
  16. package/dist/assets/{SceneManager-WQvF4y8-.js → SceneManager-u4hiSYdk.js} +1 -1
  17. package/dist/assets/{SkillsPanel-BpY-jIMP.js → SkillsPanel-D4IHFehE.js} +1 -1
  18. package/dist/assets/{SnapshotManager-DlJQAEC-.js → SnapshotManager-Cys1dllC.js} +1 -1
  19. package/dist/assets/{SpawnModal-Ci_uvH1F.js → SpawnModal-DUK7X8ql.js} +1 -1
  20. package/dist/assets/{SubordinateAssignmentModal-kFDllrhg.js → SubordinateAssignmentModal-DeH34tA3.js} +1 -1
  21. package/dist/assets/{SupervisorPanel-CPyoCa6i.js → SupervisorPanel-D0c7Kkzt.js} +1 -1
  22. package/dist/assets/{TriggerManagerPanel-B7qEVCh4.js → TriggerManagerPanel-RsbYDmIC.js} +1 -1
  23. package/dist/assets/{WorkflowEditorPanel-D8FwpAyj.js → WorkflowEditorPanel-lpYmT8iN.js} +1 -1
  24. package/dist/assets/{index-M90uUgxL.js → index-BOY5J4U4.js} +1 -1
  25. package/dist/assets/{index-C5IJ99Dq.js → index-BQdQ0iv_.js} +1 -1
  26. package/dist/assets/{index-BWCjlz0C.js → index-BexCA27h.js} +3 -3
  27. package/dist/assets/{index-OOJWJ_4Z.js → index-BqPgrat9.js} +1 -1
  28. package/dist/assets/{index-CRD8TN18.js → index-C6GdsxBK.js} +1 -1
  29. package/dist/assets/{index-DkhEv4qN.js → index-CpwhIgf8.js} +1 -1
  30. package/dist/assets/{index-Bu3B9Eke.js → index-X9qZZBXG.js} +2 -2
  31. package/dist/assets/{index-CjH90tsj.js → index-t5WzFf-W.js} +1 -1
  32. package/dist/assets/{main-DB67UbmQ.js → main-CrRMpn-n.js} +56 -56
  33. package/dist/assets/main-DjGrMNoB.css +1 -0
  34. package/dist/assets/{web-DRj84zWD.js → web-D94DaG2N.js} +1 -1
  35. package/dist/assets/{web-D4vvRMYa.js → web-XswRIovf.js} +1 -1
  36. package/dist/index.html +2 -2
  37. package/dist/src/packages/server/data/index.js +40 -0
  38. package/dist/src/packages/server/index.js +2 -0
  39. package/dist/src/packages/server/routes/agents.js +33 -0
  40. package/dist/src/packages/server/services/agent-service.js +42 -2
  41. package/dist/src/packages/server/websocket/handler.js +3 -1
  42. package/dist/src/packages/server/websocket/handlers/agent-handler.js +45 -0
  43. package/package.json +1 -1
  44. package/dist/assets/BossSpawnModal-C5JHnXoV.js +0 -1
  45. package/dist/assets/main-Chjl2UXl.css +0 -1
@@ -1 +1 @@
1
- import{r as g,a5 as te,a6 as pe,j as e,u as z,a7 as be,a8 as je,f as ie,s as j,a9 as Pe,v as Ee,w as K,aa as B,ab as Le,Y as Fe,ac as $e,V as ee,ad as Oe,ae as _e,af as De,ag as Re,ah as q,ai as Be,aj as Ue,ak as ze,O as Ve,al as ae,am as ne,an as qe,a1 as Ke,S as Me}from"./main-DB67UbmQ.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const le="deivid11/tide-commander",He=`https://api.github.com/repos/${le}/releases/latest`,Ge=`https://api.github.com/repos/${le}/releases?per_page=3`,Ye=3600*1e3,fe="app_update_dismissed_version",xe="1.43.0";function We(){var x,y;const[s,i]=g.useState({isChecking:!1,updateAvailable:!1,updateInfo:null,recentReleases:[],error:null,currentVersion:xe}),n=((y=(x=te)==null?void 0:x.getPlatform)==null?void 0:y.call(x))==="android"||!1,o=r=>r.replace(/^v/,"").split(".").map(c=>parseInt(c,10)||0),d=(r,u)=>{const c=o(r),w=o(u),k=Math.max(c.length,w.length);for(let I=0;I<k;I++){const T=c[I]||0,F=w[I]||0;if(T>F)return 1;if(T<F)return-1}return 0},p=async r=>{var c,w;if(te&&pe&&((w=(c=te).isNativePlatform)==null?void 0:w.call(c))===!0){const k=await pe.get({url:r,headers:{Accept:"application/vnd.github.v3+json"}});return{data:k.data,status:k.status}}else{const k=await fetch(r,{headers:{Accept:"application/vnd.github.v3+json"}});return k.ok?{data:await k.json(),status:k.status}:{data:null,status:k.status}}},l=g.useCallback(async(r=!1)=>{i(u=>({...u,isChecking:!0,error:null}));try{const[u,c]=await Promise.all([p(He),p(Ge)]);if(u.status!==200)throw new Error(`GitHub API error: ${u.status}`);const w=u.data,k=w.tag_name;let I=[];c.status===200&&c.data&&(I=c.data.map(S=>({version:S.tag_name,name:S.name,publishedAt:S.published_at,releaseUrl:S.html_url})));const T=localStorage.getItem(fe);if(!r&&T===k)return i(S=>({...S,isChecking:!1,updateAvailable:!1,recentReleases:I})),null;if(!(d(k,xe)>0))return i(S=>({...S,isChecking:!1,updateAvailable:!1,recentReleases:I})),null;const _=w.assets.find(S=>S.name.endsWith(".apk")&&S.content_type==="application/vnd.android.package-archive"),m={version:k,name:w.name,changelog:w.body,releaseUrl:w.html_url,apkUrl:(_==null?void 0:_.browser_download_url)||null,apkSize:(_==null?void 0:_.size)||null,publishedAt:w.published_at};return i(S=>({...S,isChecking:!1,updateAvailable:!0,updateInfo:m,recentReleases:I})),m}catch(u){const c=u instanceof Error?u.message:"Failed to check for updates";return i(w=>({...w,isChecking:!1,error:c})),null}},[]),a=g.useCallback(async()=>{var r,u,c;if(!((r=s.updateInfo)!=null&&r.apkUrl)){(u=s.updateInfo)!=null&&u.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}if(!n){(c=s.updateInfo)!=null&&c.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}try{window.open(s.updateInfo.apkUrl,"_system"),i(w=>({...w,error:null}))}catch(w){const k=w instanceof Error?w.message:"Failed to open download";i(I=>({...I,error:k}))}},[s.updateInfo,n]),f=g.useCallback(()=>{s.updateInfo&&localStorage.setItem(fe,s.updateInfo.version),i(r=>({...r,updateAvailable:!1,updateInfo:null}))},[s.updateInfo]),N=g.useCallback(()=>{var r;(r=s.updateInfo)!=null&&r.releaseUrl?window.open(s.updateInfo.releaseUrl,"_blank"):window.open(`https://github.com/${le}/releases`,"_blank")},[s.updateInfo]);return g.useEffect(()=>{if(!n)return;const r=setTimeout(()=>{l()},5e3),u=setInterval(()=>{l()},Ye);return()=>{clearTimeout(r),clearInterval(u)}},[n,l]),{...s,isAndroid:n,checkForUpdate:l,downloadAndInstall:a,dismissUpdate:f,openReleasePage:N}}const ve="tide-toolbox-collapse";function Je(s,i){try{const n=localStorage.getItem(`${ve}-${s}`);if(n!==null)return n==="true"}catch{}return i}function Ze(s,i){try{localStorage.setItem(`${ve}-${s}`,String(i))}catch{}}function $({title:s,storageKey:i,defaultOpen:n=!1,forceOpen:o=!1,children:d,headerExtra:p}){const[l,a]=g.useState(()=>i?Je(i,n):n),f=()=>{const x=!l;a(x),i&&Ze(i,x)},N=o||l;return e.jsxs("div",{className:`collapsible-section ${N?"open":"collapsed"}`,children:[e.jsxs("button",{className:"collapsible-header",onClick:f,children:[e.jsx("span",{className:"collapsible-title",children:s}),e.jsxs("span",{className:"collapsible-header-right",children:[p,e.jsx("span",{className:"collapsible-arrow",children:N?"▼":"▶"})]})]}),N&&e.jsx("div",{className:"collapsible-content",children:d})]})}function Xe({area:s,isSelected:i,onClick:n,onDelete:o}){const{t:d}=z(["config","common"]),p=s.assignedAgentIds.length,l=s.type==="rectangle"?d("config:areas.rect"):d("config:areas.circle");return e.jsxs("div",{className:`area-item ${i?"selected":""}`,onClick:n,children:[e.jsx("div",{className:"area-color-dot",style:{backgroundColor:s.color}}),e.jsxs("div",{className:"area-info",children:[e.jsx("div",{className:"area-name",children:s.name}),e.jsxs("div",{className:"area-meta",children:[l," ",p>0&&`• ${p} ${p>1?d("common:labels.agents").toLowerCase():d("common:labels.agent").toLowerCase()}`]})]}),e.jsx("button",{className:"area-delete-btn",onClick:o,title:d("config:areas.deleteArea"),children:"×"})]})}function Qe({building:s,isSelected:i,onClick:n,onEdit:o}){var f;const{t:d}=z(["config"]),p=be[s.type],l=((f=s.pm2Status)==null?void 0:f.ports)||[],a=(N,x)=>{N.stopPropagation(),window.open(`http://localhost:${x}`,"_blank")};return e.jsxs("div",{className:`building-item ${i?"selected":""}`,onClick:n,children:[e.jsx("div",{className:"building-status-dot",style:{backgroundColor:je[s.status]},title:s.status}),e.jsx("div",{className:"building-icon",children:p.icon}),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,l.length>0&&e.jsx("span",{className:"building-ports",children:l.map(N=>e.jsxs("a",{href:`http://localhost:${N}`,className:"building-port-link",onClick:x=>a(x,N),title:`Open :${N}`,children:[":",N]},N))})]})]}),e.jsx("button",{className:"building-edit-btn",onClick:N=>{N.stopPropagation(),o()},title:d("config:buildings.editBuilding"),children:"⚙"})]})}function es({building:s,onClose:i,onOpenModal:n}){var x,y,r,u,c,w,k,I;const{t:o}=z(["config","common"]),{buildingLogs:d}=ie(),p=j.getBuildingLogs(s.id),l=be[s.type],a=Pe[s.style||"server-rack"],f=T=>{j.sendBuildingCommand(s.id,T)},N=T=>{window.open(T,"_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:l.icon}),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:i,children:"×"})]}),e.jsx("div",{className:"building-editor-section",children:e.jsxs("div",{className:"building-editor-info-grid",children:[e.jsxs("div",{className:"building-editor-info-item",children:[e.jsx("span",{className:"building-editor-info-label",children:o("common:labels.type")}),e.jsx("span",{className:"building-editor-info-value",children:s.type})]}),e.jsxs("div",{className:"building-editor-info-item",children:[e.jsx("span",{className:"building-editor-info-label",children:o("config:buildings.style")}),e.jsx("span",{className:"building-editor-info-value",children:a.label})]}),s.cwd&&e.jsxs("div",{className:"building-editor-info-item building-editor-info-wide",children:[e.jsx("span",{className:"building-editor-info-label",children:o("config:buildings.directory")}),e.jsx("span",{className:"building-editor-info-value building-editor-cwd",title:s.cwd,children:s.cwd.split("/").pop()||s.cwd})]})]})}),s.type==="server"&&e.jsxs("div",{className:"building-editor-section",children:[e.jsx("div",{className:"building-editor-section-title",children:o("config:buildings.actions")}),e.jsxs("div",{className:"building-editor-actions",children:[e.jsxs("button",{className:"building-editor-action-btn start",onClick:()=>f("start"),disabled:!((x=s.commands)!=null&&x.start)||s.status==="running",title:((y=s.commands)==null?void 0:y.start)||o("config:buildings.noStartCommand"),children:["▶ ",o("common:buttons.start")]}),e.jsxs("button",{className:"building-editor-action-btn stop",onClick:()=>f("stop"),disabled:!((r=s.commands)!=null&&r.stop)||s.status==="stopped",title:((u=s.commands)==null?void 0:u.stop)||o("config:buildings.noStopCommand"),children:["■ ",o("common:buttons.stop")]}),e.jsxs("button",{className:"building-editor-action-btn restart",onClick:()=>f("restart"),disabled:!((c=s.commands)!=null&&c.restart),title:((w=s.commands)==null?void 0:w.restart)||o("config:buildings.noRestartCommand"),children:["⟳ ",o("common:buttons.retry")]}),e.jsx("button",{className:"building-editor-action-btn health",onClick:()=>f("healthCheck"),disabled:!((k=s.commands)!=null&&k.healthCheck),title:((I=s.commands)==null?void 0:I.healthCheck)||o("config:buildings.noHealthCheck"),children:"♥ Health"})]})]}),s.urls&&s.urls.length>0&&e.jsxs("div",{className:"building-editor-section",children:[e.jsx("div",{className:"building-editor-section-title",children:o("config:buildings.links")}),e.jsx("div",{className:"building-editor-links",children:s.urls.map((T,F)=>e.jsxs("button",{className:"building-editor-link",onClick:()=>N(T.url),title:T.url,children:["🔗 ",T.label||T.url]},F))})]}),p.length>0&&e.jsxs("div",{className:"building-editor-section",children:[e.jsxs("div",{className:"building-editor-section-title",children:[o("config:buildings.recentLogs"),e.jsx("button",{className:"building-editor-clear-logs",onClick:()=>j.clearBuildingLogs(s.id),title:o("common:buttons.clear"),children:o("common:buttons.clear")})]}),e.jsx("div",{className:"building-editor-logs",children:p.slice(-5).map((T,F)=>e.jsx("div",{className:"building-editor-log-entry",children:T},F))})]}),e.jsx("div",{className:"building-editor-footer",children:e.jsxs("button",{className:"building-editor-edit-btn",onClick:n,children:["⚙ ",o("config:buildings.fullSettings")]})})]})}async function ss(s,i){const n=B(),o=await fetch(K(`/api/areas/${s}/logo`),{method:"POST",headers:{"Content-Type":i.type||"image/png","X-Filename":encodeURIComponent(i.name),...n?{Authorization:`Bearer ${n}`}:{}},body:i});if(!o.ok){const d=await o.json().catch(()=>({error:o.statusText}));throw new Error(d.error||`Upload failed: ${o.statusText}`)}return o.json()}async function ts(s){const i=B(),n=await fetch(K(`/api/areas/${s}/logo`),{method:"DELETE",headers:{...i?{Authorization:`Bearer ${i}`}:{}}});if(!n.ok)throw new Error(`Failed to delete logo: ${n.statusText}`)}function as(s){return Ee(K(`/api/areas/logos/${s}`))}const ns=[{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 os({area:s,onClose:i,onOpenFolder:n}){var R;const{t:o}=z(["config","common"]),[d,p]=g.useState(s.name),[l,a]=g.useState(s.prompt||""),[f,N]=g.useState(!1),[x,y]=g.useState(""),[r,u]=g.useState(!1),c=g.useRef(null);g.useEffect(()=>{p(s.name)},[s.id,s.name]),g.useEffect(()=>{a(s.prompt||"")},[s.id,s.prompt]);const w=h=>{const C=h.target.value;p(C),j.updateArea(s.id,{name:C})},k=h=>{j.updateArea(s.id,{color:h})},I=h=>{const C=h.target.value;a(C),j.updateArea(s.id,{prompt:C})},T=()=>{x.trim()&&(j.addDirectoryToArea(s.id,x.trim()),y(""),N(!1))},F=(h,C)=>{C.stopPropagation(),j.removeDirectoryFromArea(s.id,h)},_=()=>{j.bringAreaToFront(s.id)},m=()=>{j.sendAreaToBack(s.id)},S=g.useCallback(()=>{let h=2,C=2;s.type==="rectangle"&&s.width&&s.height?(h=s.width,C=s.height):s.type==="circle"&&s.radius&&(h=s.radius*1.414,C=s.radius*1.414);const L=Math.min(h,C)*.4;return{width:Math.round(L*10)/10,height:Math.round(L*10)/10}},[s.type,s.width,s.height,s.radius]),Q=async h=>{var L;const C=(L=h.target.files)==null?void 0:L[0];if(C){u(!0);try{const M=await ss(s.id,C),H=S();j.updateArea(s.id,{logo:{filename:M.filename,position:"center",width:H.width,height:H.height,keepAspectRatio:!0,opacity:.8}})}catch(M){console.error("Failed to upload logo:",M)}finally{u(!1),c.current&&(c.current.value="")}}},Y=async()=>{try{await ts(s.id),j.updateArea(s.id,{logo:void 0})}catch(h){console.error("Failed to remove logo:",h)}},W=h=>{s.logo&&j.updateArea(s.id,{logo:{...s.logo,position:h}})},J=h=>{if(!s.logo)return;const C=parseFloat(h.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.width>0){const L=s.logo.height/s.logo.width;j.updateArea(s.id,{logo:{...s.logo,width:C,height:Math.round(C*L*10)/10}})}else j.updateArea(s.id,{logo:{...s.logo,width:C}})},b=h=>{if(!s.logo)return;const C=parseFloat(h.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.height>0){const L=s.logo.width/s.logo.height;j.updateArea(s.id,{logo:{...s.logo,height:C,width:Math.round(C*L*10)/10}})}else j.updateArea(s.id,{logo:{...s.logo,height:C}})},E=()=>{s.logo&&j.updateArea(s.id,{logo:{...s.logo,keepAspectRatio:!s.logo.keepAspectRatio}})},P=h=>{s.logo&&j.updateArea(s.id,{logo:{...s.logo,opacity:parseFloat(h.target.value)}})};return e.jsxs("div",{className:"area-editor",children:[e.jsxs("div",{className:"area-editor-header",children:[e.jsx("span",{className:"area-editor-title",children:o("config:areas.editArea")}),e.jsx("button",{className:"area-editor-close",onClick:i,children:"×"})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("common:labels.name")}),e.jsx("input",{type:"text",className:"area-editor-input",value:d,onChange:w,placeholder:o("config:areas.areaName")})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.color")}),e.jsx("div",{className:"color-picker-row",children:Le.map(h=>e.jsx("div",{className:`color-swatch ${s.color===h?"selected":""}`,style:{backgroundColor:h},onClick:()=>k(h)},h))})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.layer")}),e.jsxs("div",{className:"area-layer-buttons",children:[e.jsxs("button",{className:"area-layer-btn",onClick:_,title:o("config:areas.bringToFront"),children:["↑ ",o("config:areas.front")]}),e.jsxs("button",{className:"area-layer-btn",onClick:m,title:o("config:areas.sendToBack"),children:["↓ ",o("config:areas.back")]})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.logo")}),e.jsxs("div",{className:"area-logo-section",children:[(R=s.logo)!=null&&R.filename?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"area-logo-preview",children:[e.jsx("img",{src:as(s.logo.filename),alt:"Logo",className:"area-logo-thumbnail"}),e.jsx("button",{className:"area-logo-remove-btn",onClick:Y,children:o("config:areas.removeLogo")}),e.jsx("button",{className:"area-logo-replace-btn",onClick:()=>{var h;return(h=c.current)==null?void 0:h.click()},disabled:r,children:r?"...":"↻"})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoPosition")}),e.jsx("div",{className:"area-logo-position-row",children:ns.map(({key:h,labelKey:C})=>{var L;return e.jsx("button",{className:`area-logo-pos-btn ${((L=s.logo)==null?void 0:L.position)===h?"active":""}`,onClick:()=>W(h),children:o(`config:areas.${C}`)},h)})})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoSize")}),e.jsxs("div",{className:"area-logo-size-row",children:[e.jsxs("label",{className:"area-logo-size-field",children:[e.jsx("span",{children:o("config:areas.logoWidth")}),e.jsx("input",{type:"number",className:"area-logo-size-input",value:s.logo.width,onChange:J,min:.1,step:.1})]}),e.jsxs("label",{className:"area-logo-size-field",children:[e.jsx("span",{children:o("config:areas.logoHeight")}),e.jsx("input",{type:"number",className:"area-logo-size-input",value:s.logo.height,onChange:b,min:.1,step:.1})]}),e.jsxs("label",{className:"area-logo-aspect-label",title:o("config:areas.keepAspectRatio"),children:[e.jsx("input",{type:"checkbox",checked:s.logo.keepAspectRatio,onChange:E}),o("config:areas.keepAspectRatio")]})]})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoOpacity")}),e.jsxs("div",{className:"area-logo-opacity-row",children:[e.jsx("input",{type:"range",min:0,max:1,step:.05,value:s.logo.opacity??.8,onChange:P,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 h;return(h=c.current)==null?void 0:h.click()},disabled:r,children:r?"...":o("config:areas.uploadLogo")}),e.jsx("input",{ref:c,type:"file",accept:"image/*",style:{display:"none"},onChange:Q})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.folders",{count:s.directories.length})}),e.jsxs("div",{className:"area-folders-list",children:[s.directories.map(h=>e.jsxs("div",{className:"area-folder-item",title:h,children:[e.jsx("span",{className:"area-folder-icon clickable",onClick:()=>n==null?void 0:n(s.id),title:o("config:areas.openFolder"),children:"📁"}),e.jsx("span",{className:"area-folder-path",children:h.split("/").pop()||h}),e.jsx("button",{className:"area-folder-remove",onClick:C=>F(h,C),title:o("config:areas.removeFolder"),children:"×"})]},h)),f?e.jsxs("div",{className:"area-add-folder-inline",children:[e.jsx(Fe,{value:x,onChange:y,onSubmit:T,placeholder:o("config:areas.folderPlaceholder"),className:"area-add-folder-input",directoriesOnly:!0,autoFocus:!0}),e.jsx("button",{className:"area-add-folder-confirm",onClick:T,children:"+"})]}):e.jsx("button",{className:"area-add-folder-btn",onClick:()=>N(!0),children:o("config:areas.addFolder")})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.prompt","Prompt")}),e.jsx("textarea",{className:"area-editor-input",value:l,onChange:I,placeholder:o("config:areas.promptPlaceholder","System prompt for agents in this area..."),rows:4,style:{resize:"vertical",fontFamily:"monospace",fontSize:12}}),e.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4},children:o("config:areas.promptHint","This prompt is injected into agents assigned to this area. Takes effect on next context refresh.")})]}),s.assignedAgentIds.length>0&&e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.assignedAgents",{count:s.assignedAgentIds.length})}),e.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:o("config:areas.rightClickUnassign")})]})]})}function is(){const{t:s}=z(["config","common"]),i=$e(),[n,o]=g.useState(!1),[d,p]=g.useState(null),[l,a]=g.useState({name:"",key:"",value:"",description:""}),f=()=>{o(!0),p(null),a({name:"",key:"",value:"",description:""})},N=c=>{p(c.id),o(!1),a({name:c.name,key:c.key,value:c.value,description:c.description||""})},x=()=>{o(!1),p(null),a({name:"",key:"",value:"",description:""})},y=()=>{!l.name.trim()||!l.key.trim()||(d?j.updateSecret(d,{name:l.name.trim(),key:l.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:l.value,description:l.description.trim()||void 0}):j.createSecret({name:l.name.trim(),key:l.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:l.value,description:l.description.trim()||void 0}),x())},r=c=>{confirm(s("config:secrets.deleteConfirm"))&&(j.deleteSecret(c),d===c&&x())},u=c=>{navigator.clipboard.writeText(`{{${c}}}`)};return e.jsxs("div",{className:"secrets-section",children:[e.jsx("div",{className:"secrets-description",children:s("config:secrets.description",{placeholder:"{{KEY}}"})}),e.jsx("div",{className:"secrets-list",children:i.length===0&&!n?e.jsx("div",{className:"secrets-empty",children:s("config:secrets.noSecrets")}):i.map(c=>e.jsxs("div",{className:`secret-item ${d===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:()=>u(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:()=>N(c),title:s("common:buttons.edit"),children:"✎"}),e.jsx("button",{className:"secret-item-btn delete",onClick:()=>r(c.id),title:s("common:buttons.delete"),children:"×"})]})]}),c.description&&e.jsx("div",{className:"secret-item-description",children:c.description})]},c.id))}),(n||d)&&e.jsxs("div",{className:"secret-form",children:[e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("common:labels.name")}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.namePlaceholder"),value:l.name,onChange:c=>a({...l,name:c.target.value}),autoFocus:!0})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:"Key"}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.keyPlaceholder"),value:l.key,onChange:c=>a({...l,key:c.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"")})}),e.jsx("span",{className:"secret-form-hint",children:s("config:secrets.usedAs",{placeholder:`{{${l.key||"KEY"}}}`})})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("config:secrets.secretValue")}),e.jsx("input",{type:"password",className:"secret-form-input",placeholder:s("config:secrets.valuePlaceholder"),value:l.value,onChange:c=>a({...l,value:c.target.value})})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("common:labels.description")}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.descriptionPlaceholder"),value:l.description,onChange:c=>a({...l,description:c.target.value})})]}),e.jsxs("div",{className:"secret-form-actions",children:[e.jsx("button",{className:"secret-form-btn cancel",onClick:x,children:s("common:buttons.cancel")}),e.jsx("button",{className:"secret-form-btn save",onClick:y,disabled:!l.name.trim()||!l.key.trim(),children:s(d?"config:secrets.update":"common:buttons.add")})]})]}),!n&&!d&&e.jsx("button",{className:"secrets-add-btn",onClick:f,children:s("config:secrets.addSecret")})]})}function ls(){const{t:s}=z(["config","common"]),[i,n]=g.useState([]),[o,d]=g.useState(new Set),[p,l]=g.useState(new Set),[a,f]=g.useState(!1),[N,x]=g.useState(!1),[y,r]=g.useState(null),[u,c]=g.useState(null),[w,k]=g.useState(null);g.useEffect(()=>{ee(K("/api/config/categories")).then(b=>b.json()).then(b=>{const E=Array.isArray(b)?b:[];n(E),d(new Set(E.map(P=>P.id)))}).catch(b=>console.error("Failed to fetch config categories:",b))},[]);const I=b=>{d(E=>{const P=new Set(E);return P.has(b)?P.delete(b):P.add(b),P})},T=b=>{l(E=>{const P=new Set(E);return P.has(b)?P.delete(b):P.add(b),P})},F=()=>d(new Set(i.map(b=>b.id))),_=()=>d(new Set),m=()=>{u&&l(new Set(u.categories.map(b=>b.id)))},S=()=>l(new Set),Q=async()=>{var b;if(o.size!==0){f(!0),k(null);try{const E=Array.from(o).join(","),P=await ee(K(`/api/config/export?categories=${E}`));if(!P.ok)throw new Error("Export failed");const R=await P.blob(),h=window.URL.createObjectURL(R),C=document.createElement("a");C.href=h;const L=P.headers.get("Content-Disposition"),M=((b=L==null?void 0:L.match(/filename="(.+)"/))==null?void 0:b[1])||"tide-commander-config.zip";C.download=M,document.body.appendChild(C),C.click(),document.body.removeChild(C),window.URL.revokeObjectURL(h),k({type:"success",text:s("config:data.exportSuccess")})}catch(E){k({type:"error",text:E.message||"Export failed"})}finally{f(!1)}}},Y=async b=>{var P;const E=(P=b.target.files)==null?void 0:P[0];if(E){r(E),k(null),c(null),l(new Set);try{const R=await ee(K("/api/config/preview"),{method:"POST",headers:{"Content-Type":"application/zip"},body:await E.arrayBuffer()});if(!R.ok){const L=await R.json();throw new Error(L.error||"Failed to preview config file")}const h=await R.json(),C=Array.isArray(h.categories)?h.categories:[];c({...h,categories:C}),l(new Set(C.map(L=>L.id)))}catch(R){k({type:"error",text:R.message||"Failed to read config file"}),r(null)}}},W=async()=>{if(!(!y||p.size===0)){x(!0),k(null);try{const b=Array.from(p).join(","),E=await ee(K(`/api/config/import?categories=${b}`),{method:"POST",headers:{"Content-Type":"application/zip"},body:await y.arrayBuffer()}),P=await E.json();if(!E.ok)throw new Error(P.error||"Import failed");k({type:"success",text:P.message||s("config:data.importSuccess")}),r(null),c(null),l(new Set)}catch(b){k({type:"error",text:b.message||"Import failed"})}finally{x(!1)}}},J=()=>{r(null),c(null),l(new Set),k(null)};return e.jsxs("div",{className:"data-section",children:[w&&e.jsx("div",{className:`data-message data-message-${w.type}`,children:w.text}),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:F,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:_,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:i.map(b=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:o.has(b.id),onChange:()=>I(b.id)}),e.jsx("span",{className:"data-category-name",children:b.name})]},b.id))}),e.jsx("button",{className:"data-action-btn export",onClick:Q,disabled:a||o.size===0,children:a?s("config:data.exporting"):s("config:data.exportCount",{count:o.size})})]}),e.jsxs("div",{className:"data-subsection",children:[e.jsx("div",{className:"data-subsection-header",children:e.jsx("span",{className:"data-subsection-title",children:s("config:data.importData")})}),y?u?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"data-import-info",children:[e.jsx("div",{className:"data-import-file",children:y.name}),e.jsxs("div",{className:"data-import-date",children:[s("config:data.exported"),": ",new Date(u.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:S,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:u.categories.map(b=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:p.has(b.id),onChange:()=>T(b.id)}),e.jsx("span",{className:"data-category-name",children:b.name}),b.fileCount&&e.jsxs("span",{className:"data-category-count",children:["(",b.fileCount," ",s("config:data.files"),")"]})]},b.id))}),e.jsxs("div",{className:"data-import-actions",children:[e.jsx("button",{className:"data-action-btn cancel",onClick:J,children:s("common:buttons.cancel")}),e.jsx("button",{className:"data-action-btn import",onClick:W,disabled:N||p.size===0,children:N?s("config:data.importing"):s("config:data.importCount",{count:p.size})})]})]}):e.jsx("div",{className:"data-loading",children:s("config:data.readingFile")}):e.jsxs("label",{className:"data-file-input",children:[e.jsx("input",{type:"file",accept:".zip",onChange:Y,style:{display:"none"}}),e.jsx("span",{className:"data-file-input-label",children:s("config:data.selectFile")})]})]})]})}function cs(){const[s,i]=g.useState(()=>Oe()),n=o=>{i(o);const d=De(o);Re(d)};return e.jsx("div",{className:"theme-selector",children:e.jsx("div",{className:"theme-selector-grid",children:_e.map(o=>e.jsxs("button",{className:`theme-option ${s===o.id?"active":""}`,onClick:()=>n(o.id),title:o.description,children:[e.jsx("div",{className:"theme-preview",children:e.jsxs("div",{className:"theme-preview-bg",style:{backgroundColor:o.colors.bgPrimary},children:[e.jsx("div",{className:"theme-preview-accent",style:{backgroundColor:o.colors.accentBlue}}),e.jsx("div",{className:"theme-preview-claude",style:{backgroundColor:o.colors.accentClaude}})]})}),e.jsx("span",{className:"theme-name",children:o.name})]},o.id))})})}function rs(){const{t:s}=z(["config"]),{updateAvailable:i,updateInfo:n,recentReleases:o,isChecking:d,error:p,currentVersion:l,isAndroid:a,checkForUpdate:f,downloadAndInstall:N,openReleasePage:x}=We(),y=u=>u?`${(u/(1024*1024)).toFixed(1)} MB`:"",r=u=>new Date(u).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("span",{className:"about-logo-text",children:"Tide Commander"})]}),e.jsxs("div",{className:"about-version",children:[e.jsx("span",{className:"about-version-label",children:s("config:about.version")}),e.jsxs("div",{className:"about-version-info",children:[e.jsx("span",{className:"about-version-value",children:l}),i&&n?e.jsx("span",{className:"about-version-update-badge",onClick:x,title:`Update available: ${n.version}`,children:n.version}):e.jsxs("a",{href:"https://github.com/deivid11/tide-commander/releases",target:"_blank",rel:"noopener noreferrer",className:"about-version-status",children:["(",s("config:about.updated"),")"]})]})]}),e.jsxs("div",{className:"about-update",children:[i&&n?e.jsxs("div",{className:"about-update-available",children:[e.jsxs("div",{className:"about-update-header",children:[e.jsx("span",{className:"about-update-badge",children:s("config:about.updateAvailable")}),e.jsx("span",{className:"about-update-version",children:n.version})]}),n.apkSize&&e.jsxs("div",{className:"about-update-size",children:[s("config:about.sizeLabel"),": ",y(n.apkSize)]}),p&&e.jsx("div",{className:"about-update-error",children:p}),e.jsxs("div",{className:"about-update-actions",children:[e.jsx("button",{className:"about-update-btn changelog",onClick:x,children:s("config:about.changelog")}),a&&n.apkUrl?e.jsx("button",{className:"about-update-btn download",onClick:N,children:s("config:about.downloadAPK")}):e.jsx("button",{className:"about-update-btn download",onClick:x,children:s("config:about.viewRelease")})]})]}):e.jsxs("div",{className:"about-update-check",children:[e.jsx("span",{className:"about-update-status",children:s(d?"config:about.checkingUpdates":"config:about.upToDate")}),e.jsx("button",{className:"about-update-btn check",onClick:()=>f(!0),disabled:d,children:d?"...":s("config:about.check")})]}),o.length>0&&e.jsxs("div",{className:"about-releases",children:[e.jsx("div",{className:"about-releases-title",children:s("config:about.recentReleases")}),e.jsx("div",{className:"about-releases-list",children:o.map(u=>e.jsxs("a",{href:u.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:`about-release-item ${u.version===`v${l}`||u.version===l?"current":""}`,children:[e.jsx("span",{className:"about-release-version",children:u.version}),e.jsx("span",{className:"about-release-date",children:r(u.publishedAt)})]},u.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("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 ds={gmail:"✉️",slack:"💬",jira:"📋","google-calendar":"📅",docx:"📄"};function ms({onOpenModal:s}){const[i,n]=g.useState([]),[o,d]=g.useState(!0),p=g.useCallback(async()=>{try{const l=await ee(K("/api/integrations"));if(!l.ok)return;const a=await l.json();n(a)}catch{}finally{d(!1)}},[]);return g.useEffect(()=>{p()},[p]),o?e.jsx("div",{style:{color:"var(--text-secondary, #a6adc8)",fontSize:12,padding:"4px 0"},children:"Loading..."}):i.length===0?e.jsx("div",{style:{color:"var(--text-secondary, #a6adc8)",fontSize:12,padding:"4px 0"},children:"No integrations available."}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[i.map(l=>{const a=ds[l.id]||"🔌",f=!!l.status.error,N=l.status.connected,x=f?"#f38ba8":N?"#a6e3a1":"#fab387",y=f?"Error":N?"Connected":"Setup Required",r=f?"✗":N?"✓":"⚠";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",borderRadius:6,background:"var(--surface-1, #181825)",border:"1px solid var(--border, #313244)",fontSize:13},children:[e.jsx("span",{style:{fontSize:15,flexShrink:0},children:a}),e.jsx("span",{style:{flex:1,color:"var(--text-primary, #cdd6f4)",fontWeight:500},children:l.name}),e.jsxs("span",{style:{color:x,fontSize:11,fontWeight:500,whiteSpace:"nowrap"},children:[r," ",y]}),e.jsx("button",{onClick:()=>s(l.id),title:`Configure ${l.name}`,style:{background:"none",border:"none",cursor:"pointer",padding:"2px 4px",fontSize:14,color:"var(--text-secondary, #a6adc8)",borderRadius:4,flexShrink:0},onMouseEnter:u=>{u.target.style.color="var(--text-primary, #cdd6f4)"},onMouseLeave:u=>{u.target.style.color="var(--text-secondary, #a6adc8)"},children:"⚙️"})]},l.id)}),e.jsx("button",{onClick:()=>s(),style:{background:"none",border:"1px dashed var(--border, #313244)",borderRadius:6,padding:"6px 8px",cursor:"pointer",color:"var(--text-secondary, #a6adc8)",fontSize:12,textAlign:"center",marginTop:2},onMouseEnter:l=>{l.target.style.borderColor="var(--accent, #89b4fa)",l.target.style.color="var(--accent, #89b4fa)"},onMouseLeave:l=>{l.target.style.borderColor="var(--border, #313244)",l.target.style.color="var(--text-secondary, #a6adc8)"},children:"Manage All Integrations"})]})}async function us(){const s=B(),i=await fetch(`${q()}/api/agents/system-settings/prompt`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch system prompt: ${i.statusText}`);return(await i.json()).prompt||""}async function gs(s){const i=B(),n=await fetch(`${q()}/api/agents/system-settings/prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({prompt:s})});if(!n.ok)throw new Error(`Failed to update system prompt: ${n.statusText}`)}async function hs(){const s=B(),i=await fetch(`${q()}/api/agents/system-settings/prompt`,{method:"DELETE",headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to clear system prompt: ${i.statusText}`)}async function ps(){const s=B(),i=await fetch(`${q()}/api/agents/system-settings/echo-prompt`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch echo prompt setting: ${i.statusText}`);return(await i.json()).enabled||!1}async function fs(s){const i=B(),n=await fetch(`${q()}/api/agents/system-settings/echo-prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!n.ok)throw new Error(`Failed to update echo prompt setting: ${n.statusText}`)}async function xs(){const s=B(),i=await fetch(`${q()}/api/agents/system-settings/codex-binary`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch codex binary path: ${i.statusText}`);return(await i.json()).path||""}async function bs(s){const i=B(),n=await fetch(`${q()}/api/agents/system-settings/codex-binary`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({path:s})});if(!n.ok)throw new Error(`Failed to update codex binary path: ${n.statusText}`)}async function js(){const s=B(),i=await fetch(`${q()}/api/agents/system-settings/tmux-mode`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch tmux mode setting: ${i.statusText}`);return(await i.json()).enabled||!1}async function vs(s){const i=B(),n=await fetch(`${q()}/api/agents/system-settings/tmux-mode`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!n.ok)throw new Error(`Failed to update tmux mode setting: ${n.statusText}`)}function Ns({isOpen:s,onClose:i}){const{t:n}=z(["config"]),[o,d]=g.useState(""),[p,l]=g.useState(""),[a,f]=g.useState(!0),[N,x]=g.useState(null),[y,r]=g.useState(null),[u,c]=g.useState(!1);g.useEffect(()=>{s&&w()},[s]);const w=async()=>{try{f(!0),x(null),r(null);const m=await us();d(m),l(m),c(!1)}catch(m){x(m instanceof Error?m.message:"Failed to load system prompt")}finally{f(!1)}},k=m=>{const S=m.target.value;d(S),c(S!==p),x(null),r(null)},I=async()=>{try{x(null),r(null),await gs(o),l(o),c(!1),r(n("config:systemPrompt.saved"))}catch(m){x(m instanceof Error?m.message:"Failed to save system prompt")}},T=async()=>{if(window.confirm(n("config:systemPrompt.confirmClear")))try{x(null),r(null),await hs(),d(""),l(""),c(!1),r(n("config:systemPrompt.cleared"))}catch(m){x(m instanceof Error?m.message:"Failed to clear system prompt")}},F=()=>{d(p),c(!1),x(null),r(null)},_=m=>{if(m.key==="Escape"){if(u&&!window.confirm("You have unsaved changes. Close anyway?")){m.preventDefault();return}i()}};return s?e.jsx(Be,{children:e.jsx("div",{className:`modal-overlay ${s?"visible":""}`,onClick:i,children:e.jsxs("div",{className:"system-prompt-modal",onClick:m=>m.stopPropagation(),onKeyDown:_,children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h2",{children:n("config:systemPrompt.title")}),e.jsx("button",{className:"modal-close",onClick:i,"aria-label":"Close",children:"✕"})]}),e.jsx("div",{className:"modal-body",children:a?e.jsxs("div",{className:"loading-state",children:[e.jsx("div",{className:"spinner"}),e.jsx("p",{children:"Loading system prompt..."})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"modal-description",children:n("config:systemPrompt.description")}),N&&e.jsxs("div",{className:"alert alert-error",children:[e.jsx("span",{className:"alert-icon",children:"⚠️"}),N]}),y&&e.jsxs("div",{className:"alert alert-success",children:[e.jsx("span",{className:"alert-icon",children:"✓"}),y]}),e.jsxs("div",{className:"editor-wrapper",children:[e.jsxs("div",{className:"editor-header",children:[e.jsx("label",{htmlFor:"prompt-input",className:"editor-label",children:n("config:systemPrompt.editPrompt")}),e.jsxs("span",{className:"char-count",children:[o.length," ",n("config:systemPrompt.characters")]})]}),e.jsx("textarea",{id:"prompt-input",className:"prompt-editor",value:o,onChange:k,placeholder:n("config:systemPrompt.placeholder"),rows:18,autoFocus:!0}),e.jsx("div",{className:"editor-hint",children:n("config:systemPrompt.hint")})]})]})}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("div",{className:"footer-buttons-left",children:e.jsx("button",{className:"btn btn-danger",onClick:T,disabled:!o||a,children:n("config:systemPrompt.clear")})}),e.jsxs("div",{className:"footer-buttons-right",children:[e.jsx("button",{className:"btn btn-secondary",onClick:i,children:"Close"}),e.jsx("button",{className:"btn btn-secondary",onClick:F,disabled:!u||a,children:n("config:systemPrompt.reset")}),e.jsx("button",{className:"btn btn-primary",onClick:I,disabled:!u||a,children:n("config:systemPrompt.save")})]})]})]})})}):null}const ys=[{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:"🌙"}],ws=[{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:"🔴"}],ks=[{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:"👎"}],Ss=[{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:"💜"}],Cs=[{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"}],As=[{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"}],Ts={showTrees:"trees",showBushes:"bushes",showHouse:"house",showLamps:"lamps",showGrass:"grass",showClouds:"clouds"},Is={none:"grass","pokemon-stadium":"pokemon"},Ps={"emote-yes":"yes","emote-no":"no"},Es={"":"auto","#4a90d9":"dayBlue","#0a1a2a":"night","#ff6b35":"sunset","#1a0a2e":"purple","#2d5a27":"matrix","#8b0000":"blood","#000000":"void"};function U({checked:s,onChange:i}){return e.jsxs("label",{className:"config-toggle",children:[e.jsx("input",{type:"checkbox",className:"config-toggle-input",checked:s,onChange:n=>i(n.target.checked)}),e.jsx("span",{className:"config-toggle-track",children:e.jsx("span",{className:"config-toggle-thumb"})})]})}function X({options:s,value:i,onChange:n,iconOnly:o=!1}){return e.jsx("div",{className:"chip-selector",children:s.map(d=>e.jsxs("button",{className:`chip ${i===d.value?"active":""}`,onClick:()=>n(d.value),title:d.label,children:[e.jsx("span",{className:"chip-icon",children:d.icon}),!o&&e.jsx("span",{className:"chip-label",children:d.label})]},d.value))})}function v({text:s,query:i}){if(!i.trim())return e.jsx(e.Fragment,{children:s});const n=s.toLowerCase(),o=i.toLowerCase(),d=n.indexOf(o);if(d===-1)return e.jsx(e.Fragment,{children:s});const p=s.slice(0,d),l=s.slice(d,d+i.length),a=s.slice(d+i.length);return e.jsxs(e.Fragment,{children:[p,e.jsx("mark",{className:"search-highlight",children:l}),a]})}const Ls=[{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:"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"]},{id:"modelStyle",title:"Agent Model Style",keywords:["saturation","roughness","metalness","glow","emissive","reflections","wireframe","color mode","material","shader"]},{id:"animations",title:"Animations",keywords:["idle","working","animation","walk","run","sprint","jump","sit","crouch"]},{id:"secrets",title:"Secrets",keywords:["secrets","api","key","password","credentials","env","environment"]},{id:"systemPrompt",title:"System Prompt",keywords:["system","prompt","global","instructions","ai","agent","rules","guidelines"]},{id:"data",title:"Data",keywords:["export","import","backup","restore","save","load","json"]},{id:"integrations",title:"Integrations",keywords:["integrations","plugins","gmail","slack","jira","calendar","docx","email","config","setup"]},{id:"workflows",title:"Workflows",keywords:["workflow","automation","state machine","editor","actions","transitions","pipeline"]},{id:"triggers",title:"Triggers",keywords:["trigger","event","webhook","cron","slack","email","jira","matching","fire"]},{id:"monitoring",title:"Monitoring",keywords:["monitoring","logs","triggers","events","history","workflow","traces","audit","timeline"]},{id:"experimental",title:"Experimental",keywords:["experimental","2d","view","voice","assistant","speech","tts","text to speech","echo","prompt","duplicate"]},{id:"about",title:"About",keywords:["about","version","update","credits","github","releases"]}],oe=[{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 Fs({config:s,onChange:i,searchQuery:n="",onOpenIntegrationsModal:o,onOpenMonitoringModal:d,onOpenWorkflowEditor:p,onOpenTriggerManager:l}){var ge;const{t:a}=z(["config","common"]),f=ie(),[N,x]=g.useState(f.settings.historyLimit),[y,r]=g.useState(()=>Ue()),[u,c]=g.useState(!1),[w,k]=g.useState(()=>B()),[I,T]=g.useState(!1),[F,_]=g.useState(!1),[m,S]=g.useState(""),[Q,Y]=g.useState(!1),[W,J]=g.useState(""),[b,E]=g.useState(!1);g.useEffect(()=>{xs().then(J).catch(()=>{})},[]),g.useEffect(()=>{ps().then(t=>{t!==f.settings.experimentalEchoPrompt&&j.updateSettings({experimentalEchoPrompt:t})}).catch(()=>{})},[]),g.useEffect(()=>{js().then(t=>{t!==f.settings.tmuxMode&&j.updateSettings({tmuxMode:t})}).catch(()=>{})},[]),g.useEffect(()=>ze(t=>{r(t),c(!1)}),[]);const P=ys.map(t=>({...t,label:a(`config:time.${t.value}`)})),R=ws.map(t=>({...t,label:a(`config:floor.${Is[t.value]||t.value}`)})),h=ks.map(t=>({...t,label:a(`config:animation.${Ps[t.value]||t.value}`)})),C=Ss.map(t=>({...t,label:a(`config:colorMode.${t.value}`)})),L=Cs.map(t=>({...t,label:a(`config:terrain.${Ts[t.key]}`)})),M=As.map(t=>({...t,label:a(`config:sky.${Es[t.value??""]}`)})),H=n.trim()?Ls.filter(t=>{const D=n.toLowerCase();return t.title.toLowerCase().includes(D)||t.keywords.some(se=>se.toLowerCase().includes(D))}).map(t=>t.id):null,A=t=>H?H.includes(t):!0,V=f.settings.customAgentNames||[],Ne=V.length>0?V:Ve,ce=()=>{const t=m.trim();t&&!V.includes(t)&&(j.updateSettings({customAgentNames:[...V,t]}),S(""))},ye=t=>{j.updateSettings({customAgentNames:V.filter(D=>D!==t)})},we=()=>{j.updateSettings({customAgentNames:[]})},ke=t=>{r(t),c(!0)},re=()=>{qe(y),c(!1),ne()},Se=t=>{k(t),T(!0)},de=()=>{Ke(Me.AUTH_TOKEN,w),T(!1),ne()},Ce=t=>{J(t),E(!0)},me=()=>{bs(W).catch(()=>{}),E(!1)},Z=t=>{i({...s,terrain:{...s.terrain,...t}})},G=t=>{i({...s,modelStyle:{...s.modelStyle,...t}})},ue=t=>{i({...s,animations:{...s.animations,...t}})},Ae=t=>{x(t),j.updateSettings({historyLimit:t})},Te=t=>{const D=s.terrain[t];typeof D=="boolean"&&Z({[t]:!D})},O=n.trim().length>0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"config-section",children:[H&&H.length===0&&e.jsx("div",{className:"config-no-results",children:a("config:noResults",{query:n})}),A("general")&&e.jsxs($,{title:a("config:sections.general"),storageKey:"general",defaultOpen:!0,forceOpen:O&&A("general"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:general.history"),query:n})}),e.jsx("input",{type:"number",className:"config-input config-input-sm",value:N,onChange:t=>Ae(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(v,{text:a("config:general.hideCosts"),query:n})}),e.jsx(U,{checked:f.settings.hideCost,onChange:t=>j.updateSettings({hideCost:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:general.grid"),query:n})}),e.jsx(U,{checked:s.gridVisible,onChange:t=>i({...s,gridVisible:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:general.showFPS"),query:n})}),e.jsx(U,{checked:f.settings.showFPS,onChange:t=>j.updateSettings({showFPS:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:general.fpsLimit"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"120",step:"10",value:s.fpsLimit,onChange:t=>i({...s,fpsLimit:parseInt(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.fpsLimit===0?"∞":s.fpsLimit})]}),e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Experimental: Reduce FPS when idle to save power",children:[e.jsx(v,{text:a("config:general.powerSaving"),query:n})," ⚡"]}),e.jsx(U,{checked:f.settings.powerSaving,onChange:t=>j.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(v,{text:a("config:general.tmuxMode"),query:n})}),e.jsx(U,{checked:f.settings.tmuxMode,onChange:async t=>{j.updateSettings({tmuxMode:t});try{await vs(t)}catch(D){console.error("Failed to sync tmux mode setting to server:",D)}}})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:general.vibrationIntensity"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"5",step:"1",value:f.settings.vibrationIntensity,onChange:t=>j.updateSettings({vibrationIntensity:parseInt(t.target.value)})}),e.jsx("span",{className:"config-value",children:f.settings.vibrationIntensity===0?a("config:vibrationValues.off"):f.settings.vibrationIntensity===1?a("config:vibrationValues.ultraLight"):f.settings.vibrationIntensity===2?a("config:vibrationValues.veryLight"):f.settings.vibrationIntensity===3?a("config:vibrationValues.light"):f.settings.vibrationIntensity===4?a("config:vibrationValues.medium"):a("config:vibrationValues.heavy")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:general.externalEditor"),query:n})}),e.jsx("input",{type:"text",className:"config-input",placeholder:a("config:general.externalEditorPlaceholder"),value:f.settings.externalEditorCommand||"",onChange:t=>j.updateSettings({externalEditorCommand:t.target.value})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:general.tabTitle"),query:n})}),e.jsx("input",{type:"text",className:"config-input",placeholder:a("config:general.tabTitlePlaceholder"),value:f.settings.tabTitle||"",onChange:t=>j.updateSettings({tabTitle:t.target.value})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:general.language"),query:n})}),e.jsx(X,{options:oe,value:localStorage.getItem("tide-commander-language-mode")==="manual"?((ge=oe.find(t=>t.value!=="auto"&&ae.language.startsWith(t.value.split("-")[0])))==null?void 0:ge.value)||"en":"auto",onChange:t=>{var D;if(t==="auto"){localStorage.setItem("tide-commander-language-mode","auto");const se=navigator.language,Ie=((D=oe.find(he=>he.value!=="auto"&&se.startsWith(he.value.split("-")[0])))==null?void 0:D.value)||"en";ae.changeLanguage(Ie)}else localStorage.setItem("tide-commander-language-mode","manual"),ae.changeLanguage(t)}})]})]}),A("agentNames")&&e.jsx($,{title:a("config:sections.agentNames"),storageKey:"agentNames",defaultOpen:!1,forceOpen:O&&A("agentNames"),children:e.jsxs("div",{className:"agent-names-section",children:[e.jsx("span",{className:"config-hint",children:V.length>0?a("config:agentNames.customConfigured",{count:V.length}):a("config:agentNames.usingDefaults")}),e.jsxs("div",{className:"agent-names-input-row",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",placeholder:a("config:agentNames.addPlaceholder"),value:m,onChange:t=>S(t.target.value),onKeyDown:t=>{t.key==="Enter"&&ce()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:ce,disabled:!m.trim(),title:a("config:agentNames.addName"),children:"+"})]}),e.jsx("div",{className:"agent-names-list",children:Ne.map((t,D)=>e.jsxs("div",{className:"agent-name-chip",children:[e.jsx("span",{className:"agent-name-text",children:t}),V.length>0&&e.jsx("button",{className:"agent-name-remove",onClick:()=>ye(t),title:a("common:buttons.remove"),children:"x"})]},`${t}-${D}`))}),V.length>0&&e.jsx("button",{className:"config-btn config-btn-link",onClick:we,children:a("common:buttons.resetToDefaults")})]})}),A("appearance")&&e.jsx($,{title:a("config:sections.appearance"),storageKey:"appearance",defaultOpen:!1,forceOpen:O&&A("appearance"),children:e.jsx(cs,{})}),A("connection")&&e.jsxs($,{title:a("config:sections.connection"),storageKey:"connection",defaultOpen:!1,forceOpen:O&&A("connection"),children:[e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:connection.backendUrl"),query:n})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",value:y,onChange:t=>ke(t.target.value),placeholder:"http://localhost:5174",onKeyDown:t=>{t.key==="Enter"&&u&&re()}}),u&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:re,title:a("config:connection.saveAndReconnect"),children:a("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:a("config:connection.autoDetectHint")})]}),e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:connection.authToken"),query:n})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:F?"text":"password",className:"config-input config-input-full",value:w,onChange:t=>Se(t.target.value),placeholder:a("config:connection.tokenPlaceholder"),onKeyDown:t=>{t.key==="Enter"&&I&&de()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>_(!F),title:a(F?"config:connection.hideToken":"config:connection.showToken"),children:F?"🙈":"👁️"}),I&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:de,title:a("config:connection.saveAndReconnect"),children:a("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:a("config:connection.tokenRequired")})]}),e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:connection.codexBinaryPath"),query:n})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",value:W,onChange:t=>Ce(t.target.value),placeholder:a("config:connection.codexBinaryPathPlaceholder"),onKeyDown:t=>{t.key==="Enter"&&b&&me()}}),b&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:me,children:a("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:a("config:connection.codexBinaryPathHint")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("common:buttons.reconnect"),query:n})}),e.jsx("button",{className:"config-btn",onClick:()=>ne(),title:"Force reconnect to server",children:a("common:buttons.reconnect")})]})]}),A("scene")&&e.jsxs($,{title:a("config:sections.scene"),storageKey:"scene",defaultOpen:!1,forceOpen:O&&A("scene"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:scene.characterSize"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.3",max:"3.0",step:"0.1",value:s.characterScale,onChange:t=>i({...s,characterScale:parseFloat(t.target.value)})}),e.jsxs("span",{className:"config-value",children:[s.characterScale.toFixed(1),"x"]})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:scene.scale2d",{defaultValue:"2D Scale"}),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.3",max:"2.0",step:"0.1",value:s.scale2d,onChange:t=>i({...s,scale2d:parseFloat(t.target.value)})}),e.jsxs("span",{className:"config-value",children:[s.scale2d.toFixed(1),"x"]})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:scene.scale3d",{defaultValue:"3D Scale"}),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.3",max:"2.0",step:"0.1",value:s.scale3d,onChange:t=>i({...s,scale3d:parseFloat(t.target.value)})}),e.jsxs("span",{className:"config-value",children:[s.scale3d.toFixed(1),"x"]})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:scene.show2DTaskLabels",{defaultValue:"Show 2D task labels"}),query:n})}),e.jsx(U,{checked:s.show2DTaskLabels,onChange:t=>i({...s,show2DTaskLabels:t})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:scene.time"),query:n})}),e.jsx(X,{options:P,value:s.timeMode,onChange:t=>i({...s,timeMode:t}),iconOnly:!0})]})]}),A("terrain")&&e.jsxs($,{title:a("config:sections.terrain"),storageKey:"terrain",defaultOpen:!1,forceOpen:O&&A("terrain"),children:[e.jsx("div",{className:"terrain-icons",children:L.map(t=>e.jsx("button",{className:`terrain-icon-btn ${s.terrain[t.key]?"active":""}`,onClick:()=>Te(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(v,{text:a("config:terrainSettings.fog"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"2",step:"0.1",value:s.terrain.fogDensity,onChange:t=>Z({fogDensity:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.fogDensity===0?a("config:fogValues.off"):s.terrain.fogDensity<=1?a("config:fogValues.low"):a("config:fogValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:terrainSettings.brightness"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.2",max:"2",step:"0.1",value:s.terrain.brightness,onChange:t=>Z({brightness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.brightness<=.5?a("config:brightnessValues.dark"):s.terrain.brightness<=1.2?a("config:brightnessValues.normal"):a("config:brightnessValues.bright")})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:terrainSettings.floor"),query:n})}),e.jsx(X,{options:R,value:s.terrain.floorStyle,onChange:t=>Z({floorStyle:t}),iconOnly:!0})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:terrainSettings.sky"),query:n})}),e.jsx("div",{className:"sky-color-selector",children:M.map(t=>e.jsx("button",{className:`sky-color-btn ${s.terrain.skyColor===t.value?"active":""}`,onClick:()=>Z({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(v,{text:a("config:terrainSettings.battlefieldSize"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"30",max:"200",step:"10",value:s.terrain.battlefieldSize,onChange:t=>Z({battlefieldSize:parseInt(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.battlefieldSize})]})]}),A("modelStyle")&&e.jsxs($,{title:a("config:sections.modelStyle"),storageKey:"modelStyle",defaultOpen:!1,forceOpen:O&&A("modelStyle"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:modelStyleSettings.saturation"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"2",step:"0.1",value:s.modelStyle.saturation,onChange:t=>G({saturation:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.saturation<=.3?a("config:saturationValues.gray"):s.modelStyle.saturation<=1.2?a("config:saturationValues.normal"):a("config:saturationValues.vivid")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:modelStyleSettings.roughness"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"1",step:"0.1",value:s.modelStyle.roughness,onChange:t=>G({roughness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.roughness<0?a("config:roughnessValues.auto"):s.modelStyle.roughness<=.3?a("config:roughnessValues.glossy"):s.modelStyle.roughness<=.7?a("config:roughnessValues.normal"):a("config:roughnessValues.matte")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:modelStyleSettings.metalness"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"1",step:"0.1",value:s.modelStyle.metalness,onChange:t=>G({metalness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.metalness<0?a("config:metalnessValues.auto"):s.modelStyle.metalness<=.3?a("config:metalnessValues.plastic"):s.modelStyle.metalness<=.7?a("config:metalnessValues.mixed"):a("config:metalnessValues.metal")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:modelStyleSettings.glow"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"1",step:"0.05",value:s.modelStyle.emissiveBoost,onChange:t=>G({emissiveBoost:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.emissiveBoost<=.1?a("config:glowValues.off"):s.modelStyle.emissiveBoost<=.4?a("config:glowValues.low"):s.modelStyle.emissiveBoost<=.7?a("config:glowValues.med"):a("config:glowValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:modelStyleSettings.reflections"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"2",step:"0.1",value:s.modelStyle.envMapIntensity,onChange:t=>G({envMapIntensity:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.envMapIntensity<0?a("config:reflectionValues.auto"):s.modelStyle.envMapIntensity<=.3?a("config:reflectionValues.low"):s.modelStyle.envMapIntensity<=1?a("config:reflectionValues.normal"):a("config:reflectionValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:modelStyleSettings.wireframe"),query:n})}),e.jsx(U,{checked:s.modelStyle.wireframe,onChange:t=>G({wireframe:t})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:modelStyleSettings.colorMode"),query:n})}),e.jsx(X,{options:C,value:s.modelStyle.colorMode,onChange:t=>G({colorMode:t}),iconOnly:!0})]})]}),A("animations")&&e.jsxs($,{title:a("config:sections.animations"),storageKey:"animations",defaultOpen:!1,forceOpen:O&&A("animations"),children:[e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:animationSettings.idle"),query:n})}),e.jsx(X,{options:h,value:s.animations.idleAnimation,onChange:t=>ue({idleAnimation:t}),iconOnly:!0})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:animationSettings.working"),query:n})}),e.jsx(X,{options:h,value:s.animations.workingAnimation,onChange:t=>ue({workingAnimation:t}),iconOnly:!0})]})]}),A("secrets")&&e.jsx($,{title:a("config:sections.secrets"),storageKey:"secrets",defaultOpen:!1,forceOpen:O&&A("secrets"),children:e.jsx(is,{})}),A("systemPrompt")&&e.jsx($,{title:a("config:sections.systemPrompt"),storageKey:"systemPrompt",defaultOpen:!1,forceOpen:O&&A("systemPrompt"),children:e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:systemPrompt.title"),query:n})}),e.jsx("button",{className:"config-button",onClick:()=>Y(!0),children:a("config:systemPrompt.editPrompt")})]})}),A("data")&&e.jsx($,{title:a("config:sections.data"),storageKey:"data",defaultOpen:!1,forceOpen:O&&A("data"),children:e.jsx(ls,{})}),A("integrations")&&e.jsx($,{title:"Integrations",storageKey:"integrations",defaultOpen:!1,forceOpen:O&&A("integrations"),children:e.jsx(ms,{onOpenModal:t=>o==null?void 0:o(t)})}),A("workflows")&&e.jsxs($,{title:"Workflows",storageKey:"workflows",defaultOpen:!1,forceOpen:O&&A("workflows"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(v,{text:"Create and manage automated workflow pipelines with visual state machine editor",query:n})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>p==null?void 0:p(),children:"Open Workflow Editor"})})]}),A("triggers")&&e.jsxs($,{title:"Triggers",storageKey:"triggers",defaultOpen:!1,forceOpen:O&&A("triggers"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(v,{text:"Create and manage event-driven triggers that fire agents with templates",query:n})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>l==null?void 0:l(),children:"Open Trigger Manager"})})]}),A("monitoring")&&e.jsxs($,{title:"Monitoring",storageKey:"monitoring",defaultOpen:!1,forceOpen:O&&A("monitoring"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(v,{text:"View event logs, trigger history, workflow traces, and system stats",query:n})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>d==null?void 0:d(),children:"Open Monitoring & Logs"})})]}),A("experimental")&&e.jsxs($,{title:a("config:sections.experimental"),storageKey:"experimental",defaultOpen:!1,forceOpen:O&&A("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(v,{text:a("config:experimental.2dView"),query:n})," 🗺️"]}),e.jsx(U,{checked:f.settings.experimental2DView,onChange:t=>j.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(v,{text:a("config:experimental.voiceAssistant"),query:n})," 🎤"]}),e.jsx(U,{checked:f.settings.experimentalVoiceAssistant,onChange:t=>j.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(v,{text:a("config:experimental.tts"),query:n})," 🔊"]}),e.jsx(U,{checked:f.settings.experimentalTTS,onChange:t=>j.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(v,{text:a("config:experimental.echoPrompt"),query:n})}),e.jsx(U,{checked:f.settings.experimentalEchoPrompt,onChange:async t=>{j.updateSettings({experimentalEchoPrompt:t});try{await fs(t)}catch(D){console.error("Failed to sync echo prompt setting to server:",D)}}})]}),e.jsx("span",{className:"config-hint",children:a("config:experimental.hint")})]}),A("about")&&e.jsx($,{title:a("config:sections.about"),storageKey:"about",defaultOpen:!1,forceOpen:O&&A("about"),children:e.jsx(rs,{})})]}),e.jsx(Ns,{isOpen:Q,onClose:()=>Y(!1)})]})}function Rs({onConfigChange:s,onToolChange:i,config:n,isOpen:o,onClose:d,onOpenBuildingModal:p,onOpenAreaExplorer:l,onOpenIntegrationsModal:a,onOpenMonitoringModal:f,onOpenWorkflowEditor:N,onOpenTriggerManager:x}){const{t:y}=z(["config","common"]),r=ie(),u=Array.from(r.areas.values()),c=Array.from(r.buildings.values()),[w,k]=g.useState(""),I=g.useRef(null);if(g.useEffect(()=>{const m=S=>{S.key==="Escape"&&o&&d()};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[o,d]),g.useEffect(()=>{if(o&&I.current){const m=setTimeout(()=>{var S;(S=I.current)==null||S.focus()},50);return()=>clearTimeout(m)}},[o]),!o)return null;const T=m=>{const S=r.activeTool===m?null:m;i(S)},F=m=>{j.selectArea(r.selectedAreaId===m?null:m),i("select")},_=(m,S)=>{m.stopPropagation(),j.deleteArea(S)};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"toolbox-backdrop",onClick:d}),e.jsxs("aside",{className:"toolbox",children:[e.jsxs("div",{className:"toolbox-header",children:[e.jsx("span",{children:y("config:title")}),e.jsx("button",{className:"toolbox-close-btn",onClick:d,title:y("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:I,type:"text",placeholder:y("config:searchPlaceholder"),value:w,onChange:m=>k(m.target.value),className:"toolbox-search-input"}),w&&e.jsx("button",{className:"toolbox-search-clear",onClick:()=>k(""),children:"×"})]}),e.jsxs("div",{className:"toolbox-content",children:[e.jsx("div",{className:"toolbox-section toolbox-section-collapsible",children:e.jsxs($,{title:y("config:areas.title",{count:u.length}),storageKey:"areas",children:[e.jsxs("div",{className:"tool-buttons",children:[e.jsx("button",{className:`tool-btn ${r.activeTool==="select"?"active":""}`,onClick:()=>T("select"),title:y("config:tools.select"),children:e.jsx("span",{children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M3 3l7.07 16.97 2.51-7.39 7.39-2.51L3 3z"})})})}),e.jsx("button",{className:`tool-btn ${r.activeTool==="rectangle"?"active":""}`,onClick:()=>T("rectangle"),title:y("config:tools.rectangle"),children:e.jsx("span",{children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"})})})}),e.jsx("button",{className:`tool-btn ${r.activeTool==="circle"?"active":""}`,onClick:()=>T("circle"),title:y("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:u.length===0?e.jsx("div",{className:"areas-empty",children:y("config:areas.drawToCreate")}):u.map(m=>e.jsx(Xe,{area:m,isSelected:r.selectedAreaId===m.id,onClick:()=>F(m.id),onDelete:S=>_(S,m.id)},m.id))})]})}),r.selectedAreaId&&e.jsx(os,{area:r.areas.get(r.selectedAreaId),onClose:()=>j.selectArea(null),onOpenFolder:l}),e.jsx("div",{className:"toolbox-section toolbox-section-collapsible",children:e.jsx($,{title:y("config:buildings.title",{count:c.length}),storageKey:"buildings",headerExtra:e.jsx("button",{className:"add-building-btn",onClick:m=>{m.stopPropagation(),p==null||p()},title:y("config:buildings.addBuilding"),children:"+"}),children:e.jsx("div",{className:"buildings-list",children:c.length===0?e.jsx("div",{className:"buildings-empty",children:y("config:buildings.clickToAdd")}):c.map(m=>e.jsx(Qe,{building:m,isSelected:r.selectedBuildingIds.has(m.id),onClick:()=>{j.selectBuilding(r.selectedBuildingIds.has(m.id)?null:m.id)},onEdit:()=>p==null?void 0:p(m.id)},m.id))})})}),r.selectedBuildingIds.size===1&&(()=>{const m=Array.from(r.selectedBuildingIds)[0],S=r.buildings.get(m);return S?e.jsx(es,{building:S,onClose:()=>j.selectBuilding(null),onOpenModal:()=>p==null?void 0:p(m)}):null})(),e.jsx(Fs,{config:n,onChange:s,searchQuery:w,onOpenIntegrationsModal:a,onOpenMonitoringModal:f,onOpenWorkflowEditor:N,onOpenTriggerManager:x})]})]})]})}export{Rs as Toolbox};
1
+ import{r as g,a5 as te,a6 as pe,j as e,u as z,a7 as be,a8 as je,f as ie,s as j,a9 as Pe,v as Ee,w as K,aa as B,ab as Le,Y as Fe,ac as $e,V as ee,ad as Oe,ae as _e,af as De,ag as Re,ah as q,ai as Be,aj as Ue,ak as ze,O as Ve,al as ae,am as ne,an as qe,a1 as Ke,S as Me}from"./main-CrRMpn-n.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const le="deivid11/tide-commander",He=`https://api.github.com/repos/${le}/releases/latest`,Ge=`https://api.github.com/repos/${le}/releases?per_page=3`,Ye=3600*1e3,fe="app_update_dismissed_version",xe="1.44.0";function We(){var x,y;const[s,i]=g.useState({isChecking:!1,updateAvailable:!1,updateInfo:null,recentReleases:[],error:null,currentVersion:xe}),n=((y=(x=te)==null?void 0:x.getPlatform)==null?void 0:y.call(x))==="android"||!1,o=r=>r.replace(/^v/,"").split(".").map(c=>parseInt(c,10)||0),d=(r,u)=>{const c=o(r),w=o(u),k=Math.max(c.length,w.length);for(let I=0;I<k;I++){const T=c[I]||0,F=w[I]||0;if(T>F)return 1;if(T<F)return-1}return 0},p=async r=>{var c,w;if(te&&pe&&((w=(c=te).isNativePlatform)==null?void 0:w.call(c))===!0){const k=await pe.get({url:r,headers:{Accept:"application/vnd.github.v3+json"}});return{data:k.data,status:k.status}}else{const k=await fetch(r,{headers:{Accept:"application/vnd.github.v3+json"}});return k.ok?{data:await k.json(),status:k.status}:{data:null,status:k.status}}},l=g.useCallback(async(r=!1)=>{i(u=>({...u,isChecking:!0,error:null}));try{const[u,c]=await Promise.all([p(He),p(Ge)]);if(u.status!==200)throw new Error(`GitHub API error: ${u.status}`);const w=u.data,k=w.tag_name;let I=[];c.status===200&&c.data&&(I=c.data.map(S=>({version:S.tag_name,name:S.name,publishedAt:S.published_at,releaseUrl:S.html_url})));const T=localStorage.getItem(fe);if(!r&&T===k)return i(S=>({...S,isChecking:!1,updateAvailable:!1,recentReleases:I})),null;if(!(d(k,xe)>0))return i(S=>({...S,isChecking:!1,updateAvailable:!1,recentReleases:I})),null;const _=w.assets.find(S=>S.name.endsWith(".apk")&&S.content_type==="application/vnd.android.package-archive"),m={version:k,name:w.name,changelog:w.body,releaseUrl:w.html_url,apkUrl:(_==null?void 0:_.browser_download_url)||null,apkSize:(_==null?void 0:_.size)||null,publishedAt:w.published_at};return i(S=>({...S,isChecking:!1,updateAvailable:!0,updateInfo:m,recentReleases:I})),m}catch(u){const c=u instanceof Error?u.message:"Failed to check for updates";return i(w=>({...w,isChecking:!1,error:c})),null}},[]),a=g.useCallback(async()=>{var r,u,c;if(!((r=s.updateInfo)!=null&&r.apkUrl)){(u=s.updateInfo)!=null&&u.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}if(!n){(c=s.updateInfo)!=null&&c.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}try{window.open(s.updateInfo.apkUrl,"_system"),i(w=>({...w,error:null}))}catch(w){const k=w instanceof Error?w.message:"Failed to open download";i(I=>({...I,error:k}))}},[s.updateInfo,n]),f=g.useCallback(()=>{s.updateInfo&&localStorage.setItem(fe,s.updateInfo.version),i(r=>({...r,updateAvailable:!1,updateInfo:null}))},[s.updateInfo]),N=g.useCallback(()=>{var r;(r=s.updateInfo)!=null&&r.releaseUrl?window.open(s.updateInfo.releaseUrl,"_blank"):window.open(`https://github.com/${le}/releases`,"_blank")},[s.updateInfo]);return g.useEffect(()=>{if(!n)return;const r=setTimeout(()=>{l()},5e3),u=setInterval(()=>{l()},Ye);return()=>{clearTimeout(r),clearInterval(u)}},[n,l]),{...s,isAndroid:n,checkForUpdate:l,downloadAndInstall:a,dismissUpdate:f,openReleasePage:N}}const ve="tide-toolbox-collapse";function Je(s,i){try{const n=localStorage.getItem(`${ve}-${s}`);if(n!==null)return n==="true"}catch{}return i}function Ze(s,i){try{localStorage.setItem(`${ve}-${s}`,String(i))}catch{}}function $({title:s,storageKey:i,defaultOpen:n=!1,forceOpen:o=!1,children:d,headerExtra:p}){const[l,a]=g.useState(()=>i?Je(i,n):n),f=()=>{const x=!l;a(x),i&&Ze(i,x)},N=o||l;return e.jsxs("div",{className:`collapsible-section ${N?"open":"collapsed"}`,children:[e.jsxs("button",{className:"collapsible-header",onClick:f,children:[e.jsx("span",{className:"collapsible-title",children:s}),e.jsxs("span",{className:"collapsible-header-right",children:[p,e.jsx("span",{className:"collapsible-arrow",children:N?"▼":"▶"})]})]}),N&&e.jsx("div",{className:"collapsible-content",children:d})]})}function Xe({area:s,isSelected:i,onClick:n,onDelete:o}){const{t:d}=z(["config","common"]),p=s.assignedAgentIds.length,l=s.type==="rectangle"?d("config:areas.rect"):d("config:areas.circle");return e.jsxs("div",{className:`area-item ${i?"selected":""}`,onClick:n,children:[e.jsx("div",{className:"area-color-dot",style:{backgroundColor:s.color}}),e.jsxs("div",{className:"area-info",children:[e.jsx("div",{className:"area-name",children:s.name}),e.jsxs("div",{className:"area-meta",children:[l," ",p>0&&`• ${p} ${p>1?d("common:labels.agents").toLowerCase():d("common:labels.agent").toLowerCase()}`]})]}),e.jsx("button",{className:"area-delete-btn",onClick:o,title:d("config:areas.deleteArea"),children:"×"})]})}function Qe({building:s,isSelected:i,onClick:n,onEdit:o}){var f;const{t:d}=z(["config"]),p=be[s.type],l=((f=s.pm2Status)==null?void 0:f.ports)||[],a=(N,x)=>{N.stopPropagation(),window.open(`http://localhost:${x}`,"_blank")};return e.jsxs("div",{className:`building-item ${i?"selected":""}`,onClick:n,children:[e.jsx("div",{className:"building-status-dot",style:{backgroundColor:je[s.status]},title:s.status}),e.jsx("div",{className:"building-icon",children:p.icon}),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,l.length>0&&e.jsx("span",{className:"building-ports",children:l.map(N=>e.jsxs("a",{href:`http://localhost:${N}`,className:"building-port-link",onClick:x=>a(x,N),title:`Open :${N}`,children:[":",N]},N))})]})]}),e.jsx("button",{className:"building-edit-btn",onClick:N=>{N.stopPropagation(),o()},title:d("config:buildings.editBuilding"),children:"⚙"})]})}function es({building:s,onClose:i,onOpenModal:n}){var x,y,r,u,c,w,k,I;const{t:o}=z(["config","common"]),{buildingLogs:d}=ie(),p=j.getBuildingLogs(s.id),l=be[s.type],a=Pe[s.style||"server-rack"],f=T=>{j.sendBuildingCommand(s.id,T)},N=T=>{window.open(T,"_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:l.icon}),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:i,children:"×"})]}),e.jsx("div",{className:"building-editor-section",children:e.jsxs("div",{className:"building-editor-info-grid",children:[e.jsxs("div",{className:"building-editor-info-item",children:[e.jsx("span",{className:"building-editor-info-label",children:o("common:labels.type")}),e.jsx("span",{className:"building-editor-info-value",children:s.type})]}),e.jsxs("div",{className:"building-editor-info-item",children:[e.jsx("span",{className:"building-editor-info-label",children:o("config:buildings.style")}),e.jsx("span",{className:"building-editor-info-value",children:a.label})]}),s.cwd&&e.jsxs("div",{className:"building-editor-info-item building-editor-info-wide",children:[e.jsx("span",{className:"building-editor-info-label",children:o("config:buildings.directory")}),e.jsx("span",{className:"building-editor-info-value building-editor-cwd",title:s.cwd,children:s.cwd.split("/").pop()||s.cwd})]})]})}),s.type==="server"&&e.jsxs("div",{className:"building-editor-section",children:[e.jsx("div",{className:"building-editor-section-title",children:o("config:buildings.actions")}),e.jsxs("div",{className:"building-editor-actions",children:[e.jsxs("button",{className:"building-editor-action-btn start",onClick:()=>f("start"),disabled:!((x=s.commands)!=null&&x.start)||s.status==="running",title:((y=s.commands)==null?void 0:y.start)||o("config:buildings.noStartCommand"),children:["▶ ",o("common:buttons.start")]}),e.jsxs("button",{className:"building-editor-action-btn stop",onClick:()=>f("stop"),disabled:!((r=s.commands)!=null&&r.stop)||s.status==="stopped",title:((u=s.commands)==null?void 0:u.stop)||o("config:buildings.noStopCommand"),children:["■ ",o("common:buttons.stop")]}),e.jsxs("button",{className:"building-editor-action-btn restart",onClick:()=>f("restart"),disabled:!((c=s.commands)!=null&&c.restart),title:((w=s.commands)==null?void 0:w.restart)||o("config:buildings.noRestartCommand"),children:["⟳ ",o("common:buttons.retry")]}),e.jsx("button",{className:"building-editor-action-btn health",onClick:()=>f("healthCheck"),disabled:!((k=s.commands)!=null&&k.healthCheck),title:((I=s.commands)==null?void 0:I.healthCheck)||o("config:buildings.noHealthCheck"),children:"♥ Health"})]})]}),s.urls&&s.urls.length>0&&e.jsxs("div",{className:"building-editor-section",children:[e.jsx("div",{className:"building-editor-section-title",children:o("config:buildings.links")}),e.jsx("div",{className:"building-editor-links",children:s.urls.map((T,F)=>e.jsxs("button",{className:"building-editor-link",onClick:()=>N(T.url),title:T.url,children:["🔗 ",T.label||T.url]},F))})]}),p.length>0&&e.jsxs("div",{className:"building-editor-section",children:[e.jsxs("div",{className:"building-editor-section-title",children:[o("config:buildings.recentLogs"),e.jsx("button",{className:"building-editor-clear-logs",onClick:()=>j.clearBuildingLogs(s.id),title:o("common:buttons.clear"),children:o("common:buttons.clear")})]}),e.jsx("div",{className:"building-editor-logs",children:p.slice(-5).map((T,F)=>e.jsx("div",{className:"building-editor-log-entry",children:T},F))})]}),e.jsx("div",{className:"building-editor-footer",children:e.jsxs("button",{className:"building-editor-edit-btn",onClick:n,children:["⚙ ",o("config:buildings.fullSettings")]})})]})}async function ss(s,i){const n=B(),o=await fetch(K(`/api/areas/${s}/logo`),{method:"POST",headers:{"Content-Type":i.type||"image/png","X-Filename":encodeURIComponent(i.name),...n?{Authorization:`Bearer ${n}`}:{}},body:i});if(!o.ok){const d=await o.json().catch(()=>({error:o.statusText}));throw new Error(d.error||`Upload failed: ${o.statusText}`)}return o.json()}async function ts(s){const i=B(),n=await fetch(K(`/api/areas/${s}/logo`),{method:"DELETE",headers:{...i?{Authorization:`Bearer ${i}`}:{}}});if(!n.ok)throw new Error(`Failed to delete logo: ${n.statusText}`)}function as(s){return Ee(K(`/api/areas/logos/${s}`))}const ns=[{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 os({area:s,onClose:i,onOpenFolder:n}){var R;const{t:o}=z(["config","common"]),[d,p]=g.useState(s.name),[l,a]=g.useState(s.prompt||""),[f,N]=g.useState(!1),[x,y]=g.useState(""),[r,u]=g.useState(!1),c=g.useRef(null);g.useEffect(()=>{p(s.name)},[s.id,s.name]),g.useEffect(()=>{a(s.prompt||"")},[s.id,s.prompt]);const w=h=>{const C=h.target.value;p(C),j.updateArea(s.id,{name:C})},k=h=>{j.updateArea(s.id,{color:h})},I=h=>{const C=h.target.value;a(C),j.updateArea(s.id,{prompt:C})},T=()=>{x.trim()&&(j.addDirectoryToArea(s.id,x.trim()),y(""),N(!1))},F=(h,C)=>{C.stopPropagation(),j.removeDirectoryFromArea(s.id,h)},_=()=>{j.bringAreaToFront(s.id)},m=()=>{j.sendAreaToBack(s.id)},S=g.useCallback(()=>{let h=2,C=2;s.type==="rectangle"&&s.width&&s.height?(h=s.width,C=s.height):s.type==="circle"&&s.radius&&(h=s.radius*1.414,C=s.radius*1.414);const L=Math.min(h,C)*.4;return{width:Math.round(L*10)/10,height:Math.round(L*10)/10}},[s.type,s.width,s.height,s.radius]),Q=async h=>{var L;const C=(L=h.target.files)==null?void 0:L[0];if(C){u(!0);try{const M=await ss(s.id,C),H=S();j.updateArea(s.id,{logo:{filename:M.filename,position:"center",width:H.width,height:H.height,keepAspectRatio:!0,opacity:.8}})}catch(M){console.error("Failed to upload logo:",M)}finally{u(!1),c.current&&(c.current.value="")}}},Y=async()=>{try{await ts(s.id),j.updateArea(s.id,{logo:void 0})}catch(h){console.error("Failed to remove logo:",h)}},W=h=>{s.logo&&j.updateArea(s.id,{logo:{...s.logo,position:h}})},J=h=>{if(!s.logo)return;const C=parseFloat(h.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.width>0){const L=s.logo.height/s.logo.width;j.updateArea(s.id,{logo:{...s.logo,width:C,height:Math.round(C*L*10)/10}})}else j.updateArea(s.id,{logo:{...s.logo,width:C}})},b=h=>{if(!s.logo)return;const C=parseFloat(h.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.height>0){const L=s.logo.width/s.logo.height;j.updateArea(s.id,{logo:{...s.logo,height:C,width:Math.round(C*L*10)/10}})}else j.updateArea(s.id,{logo:{...s.logo,height:C}})},E=()=>{s.logo&&j.updateArea(s.id,{logo:{...s.logo,keepAspectRatio:!s.logo.keepAspectRatio}})},P=h=>{s.logo&&j.updateArea(s.id,{logo:{...s.logo,opacity:parseFloat(h.target.value)}})};return e.jsxs("div",{className:"area-editor",children:[e.jsxs("div",{className:"area-editor-header",children:[e.jsx("span",{className:"area-editor-title",children:o("config:areas.editArea")}),e.jsx("button",{className:"area-editor-close",onClick:i,children:"×"})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("common:labels.name")}),e.jsx("input",{type:"text",className:"area-editor-input",value:d,onChange:w,placeholder:o("config:areas.areaName")})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.color")}),e.jsx("div",{className:"color-picker-row",children:Le.map(h=>e.jsx("div",{className:`color-swatch ${s.color===h?"selected":""}`,style:{backgroundColor:h},onClick:()=>k(h)},h))})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.layer")}),e.jsxs("div",{className:"area-layer-buttons",children:[e.jsxs("button",{className:"area-layer-btn",onClick:_,title:o("config:areas.bringToFront"),children:["↑ ",o("config:areas.front")]}),e.jsxs("button",{className:"area-layer-btn",onClick:m,title:o("config:areas.sendToBack"),children:["↓ ",o("config:areas.back")]})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.logo")}),e.jsxs("div",{className:"area-logo-section",children:[(R=s.logo)!=null&&R.filename?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"area-logo-preview",children:[e.jsx("img",{src:as(s.logo.filename),alt:"Logo",className:"area-logo-thumbnail"}),e.jsx("button",{className:"area-logo-remove-btn",onClick:Y,children:o("config:areas.removeLogo")}),e.jsx("button",{className:"area-logo-replace-btn",onClick:()=>{var h;return(h=c.current)==null?void 0:h.click()},disabled:r,children:r?"...":"↻"})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoPosition")}),e.jsx("div",{className:"area-logo-position-row",children:ns.map(({key:h,labelKey:C})=>{var L;return e.jsx("button",{className:`area-logo-pos-btn ${((L=s.logo)==null?void 0:L.position)===h?"active":""}`,onClick:()=>W(h),children:o(`config:areas.${C}`)},h)})})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoSize")}),e.jsxs("div",{className:"area-logo-size-row",children:[e.jsxs("label",{className:"area-logo-size-field",children:[e.jsx("span",{children:o("config:areas.logoWidth")}),e.jsx("input",{type:"number",className:"area-logo-size-input",value:s.logo.width,onChange:J,min:.1,step:.1})]}),e.jsxs("label",{className:"area-logo-size-field",children:[e.jsx("span",{children:o("config:areas.logoHeight")}),e.jsx("input",{type:"number",className:"area-logo-size-input",value:s.logo.height,onChange:b,min:.1,step:.1})]}),e.jsxs("label",{className:"area-logo-aspect-label",title:o("config:areas.keepAspectRatio"),children:[e.jsx("input",{type:"checkbox",checked:s.logo.keepAspectRatio,onChange:E}),o("config:areas.keepAspectRatio")]})]})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoOpacity")}),e.jsxs("div",{className:"area-logo-opacity-row",children:[e.jsx("input",{type:"range",min:0,max:1,step:.05,value:s.logo.opacity??.8,onChange:P,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 h;return(h=c.current)==null?void 0:h.click()},disabled:r,children:r?"...":o("config:areas.uploadLogo")}),e.jsx("input",{ref:c,type:"file",accept:"image/*",style:{display:"none"},onChange:Q})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.folders",{count:s.directories.length})}),e.jsxs("div",{className:"area-folders-list",children:[s.directories.map(h=>e.jsxs("div",{className:"area-folder-item",title:h,children:[e.jsx("span",{className:"area-folder-icon clickable",onClick:()=>n==null?void 0:n(s.id),title:o("config:areas.openFolder"),children:"📁"}),e.jsx("span",{className:"area-folder-path",children:h.split("/").pop()||h}),e.jsx("button",{className:"area-folder-remove",onClick:C=>F(h,C),title:o("config:areas.removeFolder"),children:"×"})]},h)),f?e.jsxs("div",{className:"area-add-folder-inline",children:[e.jsx(Fe,{value:x,onChange:y,onSubmit:T,placeholder:o("config:areas.folderPlaceholder"),className:"area-add-folder-input",directoriesOnly:!0,autoFocus:!0}),e.jsx("button",{className:"area-add-folder-confirm",onClick:T,children:"+"})]}):e.jsx("button",{className:"area-add-folder-btn",onClick:()=>N(!0),children:o("config:areas.addFolder")})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.prompt","Prompt")}),e.jsx("textarea",{className:"area-editor-input",value:l,onChange:I,placeholder:o("config:areas.promptPlaceholder","System prompt for agents in this area..."),rows:4,style:{resize:"vertical",fontFamily:"monospace",fontSize:12}}),e.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4},children:o("config:areas.promptHint","This prompt is injected into agents assigned to this area. Takes effect on next context refresh.")})]}),s.assignedAgentIds.length>0&&e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.assignedAgents",{count:s.assignedAgentIds.length})}),e.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:o("config:areas.rightClickUnassign")})]})]})}function is(){const{t:s}=z(["config","common"]),i=$e(),[n,o]=g.useState(!1),[d,p]=g.useState(null),[l,a]=g.useState({name:"",key:"",value:"",description:""}),f=()=>{o(!0),p(null),a({name:"",key:"",value:"",description:""})},N=c=>{p(c.id),o(!1),a({name:c.name,key:c.key,value:c.value,description:c.description||""})},x=()=>{o(!1),p(null),a({name:"",key:"",value:"",description:""})},y=()=>{!l.name.trim()||!l.key.trim()||(d?j.updateSecret(d,{name:l.name.trim(),key:l.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:l.value,description:l.description.trim()||void 0}):j.createSecret({name:l.name.trim(),key:l.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:l.value,description:l.description.trim()||void 0}),x())},r=c=>{confirm(s("config:secrets.deleteConfirm"))&&(j.deleteSecret(c),d===c&&x())},u=c=>{navigator.clipboard.writeText(`{{${c}}}`)};return e.jsxs("div",{className:"secrets-section",children:[e.jsx("div",{className:"secrets-description",children:s("config:secrets.description",{placeholder:"{{KEY}}"})}),e.jsx("div",{className:"secrets-list",children:i.length===0&&!n?e.jsx("div",{className:"secrets-empty",children:s("config:secrets.noSecrets")}):i.map(c=>e.jsxs("div",{className:`secret-item ${d===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:()=>u(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:()=>N(c),title:s("common:buttons.edit"),children:"✎"}),e.jsx("button",{className:"secret-item-btn delete",onClick:()=>r(c.id),title:s("common:buttons.delete"),children:"×"})]})]}),c.description&&e.jsx("div",{className:"secret-item-description",children:c.description})]},c.id))}),(n||d)&&e.jsxs("div",{className:"secret-form",children:[e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("common:labels.name")}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.namePlaceholder"),value:l.name,onChange:c=>a({...l,name:c.target.value}),autoFocus:!0})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:"Key"}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.keyPlaceholder"),value:l.key,onChange:c=>a({...l,key:c.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"")})}),e.jsx("span",{className:"secret-form-hint",children:s("config:secrets.usedAs",{placeholder:`{{${l.key||"KEY"}}}`})})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("config:secrets.secretValue")}),e.jsx("input",{type:"password",className:"secret-form-input",placeholder:s("config:secrets.valuePlaceholder"),value:l.value,onChange:c=>a({...l,value:c.target.value})})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("common:labels.description")}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.descriptionPlaceholder"),value:l.description,onChange:c=>a({...l,description:c.target.value})})]}),e.jsxs("div",{className:"secret-form-actions",children:[e.jsx("button",{className:"secret-form-btn cancel",onClick:x,children:s("common:buttons.cancel")}),e.jsx("button",{className:"secret-form-btn save",onClick:y,disabled:!l.name.trim()||!l.key.trim(),children:s(d?"config:secrets.update":"common:buttons.add")})]})]}),!n&&!d&&e.jsx("button",{className:"secrets-add-btn",onClick:f,children:s("config:secrets.addSecret")})]})}function ls(){const{t:s}=z(["config","common"]),[i,n]=g.useState([]),[o,d]=g.useState(new Set),[p,l]=g.useState(new Set),[a,f]=g.useState(!1),[N,x]=g.useState(!1),[y,r]=g.useState(null),[u,c]=g.useState(null),[w,k]=g.useState(null);g.useEffect(()=>{ee(K("/api/config/categories")).then(b=>b.json()).then(b=>{const E=Array.isArray(b)?b:[];n(E),d(new Set(E.map(P=>P.id)))}).catch(b=>console.error("Failed to fetch config categories:",b))},[]);const I=b=>{d(E=>{const P=new Set(E);return P.has(b)?P.delete(b):P.add(b),P})},T=b=>{l(E=>{const P=new Set(E);return P.has(b)?P.delete(b):P.add(b),P})},F=()=>d(new Set(i.map(b=>b.id))),_=()=>d(new Set),m=()=>{u&&l(new Set(u.categories.map(b=>b.id)))},S=()=>l(new Set),Q=async()=>{var b;if(o.size!==0){f(!0),k(null);try{const E=Array.from(o).join(","),P=await ee(K(`/api/config/export?categories=${E}`));if(!P.ok)throw new Error("Export failed");const R=await P.blob(),h=window.URL.createObjectURL(R),C=document.createElement("a");C.href=h;const L=P.headers.get("Content-Disposition"),M=((b=L==null?void 0:L.match(/filename="(.+)"/))==null?void 0:b[1])||"tide-commander-config.zip";C.download=M,document.body.appendChild(C),C.click(),document.body.removeChild(C),window.URL.revokeObjectURL(h),k({type:"success",text:s("config:data.exportSuccess")})}catch(E){k({type:"error",text:E.message||"Export failed"})}finally{f(!1)}}},Y=async b=>{var P;const E=(P=b.target.files)==null?void 0:P[0];if(E){r(E),k(null),c(null),l(new Set);try{const R=await ee(K("/api/config/preview"),{method:"POST",headers:{"Content-Type":"application/zip"},body:await E.arrayBuffer()});if(!R.ok){const L=await R.json();throw new Error(L.error||"Failed to preview config file")}const h=await R.json(),C=Array.isArray(h.categories)?h.categories:[];c({...h,categories:C}),l(new Set(C.map(L=>L.id)))}catch(R){k({type:"error",text:R.message||"Failed to read config file"}),r(null)}}},W=async()=>{if(!(!y||p.size===0)){x(!0),k(null);try{const b=Array.from(p).join(","),E=await ee(K(`/api/config/import?categories=${b}`),{method:"POST",headers:{"Content-Type":"application/zip"},body:await y.arrayBuffer()}),P=await E.json();if(!E.ok)throw new Error(P.error||"Import failed");k({type:"success",text:P.message||s("config:data.importSuccess")}),r(null),c(null),l(new Set)}catch(b){k({type:"error",text:b.message||"Import failed"})}finally{x(!1)}}},J=()=>{r(null),c(null),l(new Set),k(null)};return e.jsxs("div",{className:"data-section",children:[w&&e.jsx("div",{className:`data-message data-message-${w.type}`,children:w.text}),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:F,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:_,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:i.map(b=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:o.has(b.id),onChange:()=>I(b.id)}),e.jsx("span",{className:"data-category-name",children:b.name})]},b.id))}),e.jsx("button",{className:"data-action-btn export",onClick:Q,disabled:a||o.size===0,children:a?s("config:data.exporting"):s("config:data.exportCount",{count:o.size})})]}),e.jsxs("div",{className:"data-subsection",children:[e.jsx("div",{className:"data-subsection-header",children:e.jsx("span",{className:"data-subsection-title",children:s("config:data.importData")})}),y?u?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"data-import-info",children:[e.jsx("div",{className:"data-import-file",children:y.name}),e.jsxs("div",{className:"data-import-date",children:[s("config:data.exported"),": ",new Date(u.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:S,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:u.categories.map(b=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:p.has(b.id),onChange:()=>T(b.id)}),e.jsx("span",{className:"data-category-name",children:b.name}),b.fileCount&&e.jsxs("span",{className:"data-category-count",children:["(",b.fileCount," ",s("config:data.files"),")"]})]},b.id))}),e.jsxs("div",{className:"data-import-actions",children:[e.jsx("button",{className:"data-action-btn cancel",onClick:J,children:s("common:buttons.cancel")}),e.jsx("button",{className:"data-action-btn import",onClick:W,disabled:N||p.size===0,children:N?s("config:data.importing"):s("config:data.importCount",{count:p.size})})]})]}):e.jsx("div",{className:"data-loading",children:s("config:data.readingFile")}):e.jsxs("label",{className:"data-file-input",children:[e.jsx("input",{type:"file",accept:".zip",onChange:Y,style:{display:"none"}}),e.jsx("span",{className:"data-file-input-label",children:s("config:data.selectFile")})]})]})]})}function cs(){const[s,i]=g.useState(()=>Oe()),n=o=>{i(o);const d=De(o);Re(d)};return e.jsx("div",{className:"theme-selector",children:e.jsx("div",{className:"theme-selector-grid",children:_e.map(o=>e.jsxs("button",{className:`theme-option ${s===o.id?"active":""}`,onClick:()=>n(o.id),title:o.description,children:[e.jsx("div",{className:"theme-preview",children:e.jsxs("div",{className:"theme-preview-bg",style:{backgroundColor:o.colors.bgPrimary},children:[e.jsx("div",{className:"theme-preview-accent",style:{backgroundColor:o.colors.accentBlue}}),e.jsx("div",{className:"theme-preview-claude",style:{backgroundColor:o.colors.accentClaude}})]})}),e.jsx("span",{className:"theme-name",children:o.name})]},o.id))})})}function rs(){const{t:s}=z(["config"]),{updateAvailable:i,updateInfo:n,recentReleases:o,isChecking:d,error:p,currentVersion:l,isAndroid:a,checkForUpdate:f,downloadAndInstall:N,openReleasePage:x}=We(),y=u=>u?`${(u/(1024*1024)).toFixed(1)} MB`:"",r=u=>new Date(u).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("span",{className:"about-logo-text",children:"Tide Commander"})]}),e.jsxs("div",{className:"about-version",children:[e.jsx("span",{className:"about-version-label",children:s("config:about.version")}),e.jsxs("div",{className:"about-version-info",children:[e.jsx("span",{className:"about-version-value",children:l}),i&&n?e.jsx("span",{className:"about-version-update-badge",onClick:x,title:`Update available: ${n.version}`,children:n.version}):e.jsxs("a",{href:"https://github.com/deivid11/tide-commander/releases",target:"_blank",rel:"noopener noreferrer",className:"about-version-status",children:["(",s("config:about.updated"),")"]})]})]}),e.jsxs("div",{className:"about-update",children:[i&&n?e.jsxs("div",{className:"about-update-available",children:[e.jsxs("div",{className:"about-update-header",children:[e.jsx("span",{className:"about-update-badge",children:s("config:about.updateAvailable")}),e.jsx("span",{className:"about-update-version",children:n.version})]}),n.apkSize&&e.jsxs("div",{className:"about-update-size",children:[s("config:about.sizeLabel"),": ",y(n.apkSize)]}),p&&e.jsx("div",{className:"about-update-error",children:p}),e.jsxs("div",{className:"about-update-actions",children:[e.jsx("button",{className:"about-update-btn changelog",onClick:x,children:s("config:about.changelog")}),a&&n.apkUrl?e.jsx("button",{className:"about-update-btn download",onClick:N,children:s("config:about.downloadAPK")}):e.jsx("button",{className:"about-update-btn download",onClick:x,children:s("config:about.viewRelease")})]})]}):e.jsxs("div",{className:"about-update-check",children:[e.jsx("span",{className:"about-update-status",children:s(d?"config:about.checkingUpdates":"config:about.upToDate")}),e.jsx("button",{className:"about-update-btn check",onClick:()=>f(!0),disabled:d,children:d?"...":s("config:about.check")})]}),o.length>0&&e.jsxs("div",{className:"about-releases",children:[e.jsx("div",{className:"about-releases-title",children:s("config:about.recentReleases")}),e.jsx("div",{className:"about-releases-list",children:o.map(u=>e.jsxs("a",{href:u.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:`about-release-item ${u.version===`v${l}`||u.version===l?"current":""}`,children:[e.jsx("span",{className:"about-release-version",children:u.version}),e.jsx("span",{className:"about-release-date",children:r(u.publishedAt)})]},u.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("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 ds={gmail:"✉️",slack:"💬",jira:"📋","google-calendar":"📅",docx:"📄"};function ms({onOpenModal:s}){const[i,n]=g.useState([]),[o,d]=g.useState(!0),p=g.useCallback(async()=>{try{const l=await ee(K("/api/integrations"));if(!l.ok)return;const a=await l.json();n(a)}catch{}finally{d(!1)}},[]);return g.useEffect(()=>{p()},[p]),o?e.jsx("div",{style:{color:"var(--text-secondary, #a6adc8)",fontSize:12,padding:"4px 0"},children:"Loading..."}):i.length===0?e.jsx("div",{style:{color:"var(--text-secondary, #a6adc8)",fontSize:12,padding:"4px 0"},children:"No integrations available."}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[i.map(l=>{const a=ds[l.id]||"🔌",f=!!l.status.error,N=l.status.connected,x=f?"#f38ba8":N?"#a6e3a1":"#fab387",y=f?"Error":N?"Connected":"Setup Required",r=f?"✗":N?"✓":"⚠";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",borderRadius:6,background:"var(--surface-1, #181825)",border:"1px solid var(--border, #313244)",fontSize:13},children:[e.jsx("span",{style:{fontSize:15,flexShrink:0},children:a}),e.jsx("span",{style:{flex:1,color:"var(--text-primary, #cdd6f4)",fontWeight:500},children:l.name}),e.jsxs("span",{style:{color:x,fontSize:11,fontWeight:500,whiteSpace:"nowrap"},children:[r," ",y]}),e.jsx("button",{onClick:()=>s(l.id),title:`Configure ${l.name}`,style:{background:"none",border:"none",cursor:"pointer",padding:"2px 4px",fontSize:14,color:"var(--text-secondary, #a6adc8)",borderRadius:4,flexShrink:0},onMouseEnter:u=>{u.target.style.color="var(--text-primary, #cdd6f4)"},onMouseLeave:u=>{u.target.style.color="var(--text-secondary, #a6adc8)"},children:"⚙️"})]},l.id)}),e.jsx("button",{onClick:()=>s(),style:{background:"none",border:"1px dashed var(--border, #313244)",borderRadius:6,padding:"6px 8px",cursor:"pointer",color:"var(--text-secondary, #a6adc8)",fontSize:12,textAlign:"center",marginTop:2},onMouseEnter:l=>{l.target.style.borderColor="var(--accent, #89b4fa)",l.target.style.color="var(--accent, #89b4fa)"},onMouseLeave:l=>{l.target.style.borderColor="var(--border, #313244)",l.target.style.color="var(--text-secondary, #a6adc8)"},children:"Manage All Integrations"})]})}async function us(){const s=B(),i=await fetch(`${q()}/api/agents/system-settings/prompt`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch system prompt: ${i.statusText}`);return(await i.json()).prompt||""}async function gs(s){const i=B(),n=await fetch(`${q()}/api/agents/system-settings/prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({prompt:s})});if(!n.ok)throw new Error(`Failed to update system prompt: ${n.statusText}`)}async function hs(){const s=B(),i=await fetch(`${q()}/api/agents/system-settings/prompt`,{method:"DELETE",headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to clear system prompt: ${i.statusText}`)}async function ps(){const s=B(),i=await fetch(`${q()}/api/agents/system-settings/echo-prompt`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch echo prompt setting: ${i.statusText}`);return(await i.json()).enabled||!1}async function fs(s){const i=B(),n=await fetch(`${q()}/api/agents/system-settings/echo-prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!n.ok)throw new Error(`Failed to update echo prompt setting: ${n.statusText}`)}async function xs(){const s=B(),i=await fetch(`${q()}/api/agents/system-settings/codex-binary`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch codex binary path: ${i.statusText}`);return(await i.json()).path||""}async function bs(s){const i=B(),n=await fetch(`${q()}/api/agents/system-settings/codex-binary`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({path:s})});if(!n.ok)throw new Error(`Failed to update codex binary path: ${n.statusText}`)}async function js(){const s=B(),i=await fetch(`${q()}/api/agents/system-settings/tmux-mode`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch tmux mode setting: ${i.statusText}`);return(await i.json()).enabled||!1}async function vs(s){const i=B(),n=await fetch(`${q()}/api/agents/system-settings/tmux-mode`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!n.ok)throw new Error(`Failed to update tmux mode setting: ${n.statusText}`)}function Ns({isOpen:s,onClose:i}){const{t:n}=z(["config"]),[o,d]=g.useState(""),[p,l]=g.useState(""),[a,f]=g.useState(!0),[N,x]=g.useState(null),[y,r]=g.useState(null),[u,c]=g.useState(!1);g.useEffect(()=>{s&&w()},[s]);const w=async()=>{try{f(!0),x(null),r(null);const m=await us();d(m),l(m),c(!1)}catch(m){x(m instanceof Error?m.message:"Failed to load system prompt")}finally{f(!1)}},k=m=>{const S=m.target.value;d(S),c(S!==p),x(null),r(null)},I=async()=>{try{x(null),r(null),await gs(o),l(o),c(!1),r(n("config:systemPrompt.saved"))}catch(m){x(m instanceof Error?m.message:"Failed to save system prompt")}},T=async()=>{if(window.confirm(n("config:systemPrompt.confirmClear")))try{x(null),r(null),await hs(),d(""),l(""),c(!1),r(n("config:systemPrompt.cleared"))}catch(m){x(m instanceof Error?m.message:"Failed to clear system prompt")}},F=()=>{d(p),c(!1),x(null),r(null)},_=m=>{if(m.key==="Escape"){if(u&&!window.confirm("You have unsaved changes. Close anyway?")){m.preventDefault();return}i()}};return s?e.jsx(Be,{children:e.jsx("div",{className:`modal-overlay ${s?"visible":""}`,onClick:i,children:e.jsxs("div",{className:"system-prompt-modal",onClick:m=>m.stopPropagation(),onKeyDown:_,children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h2",{children:n("config:systemPrompt.title")}),e.jsx("button",{className:"modal-close",onClick:i,"aria-label":"Close",children:"✕"})]}),e.jsx("div",{className:"modal-body",children:a?e.jsxs("div",{className:"loading-state",children:[e.jsx("div",{className:"spinner"}),e.jsx("p",{children:"Loading system prompt..."})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"modal-description",children:n("config:systemPrompt.description")}),N&&e.jsxs("div",{className:"alert alert-error",children:[e.jsx("span",{className:"alert-icon",children:"⚠️"}),N]}),y&&e.jsxs("div",{className:"alert alert-success",children:[e.jsx("span",{className:"alert-icon",children:"✓"}),y]}),e.jsxs("div",{className:"editor-wrapper",children:[e.jsxs("div",{className:"editor-header",children:[e.jsx("label",{htmlFor:"prompt-input",className:"editor-label",children:n("config:systemPrompt.editPrompt")}),e.jsxs("span",{className:"char-count",children:[o.length," ",n("config:systemPrompt.characters")]})]}),e.jsx("textarea",{id:"prompt-input",className:"prompt-editor",value:o,onChange:k,placeholder:n("config:systemPrompt.placeholder"),rows:18,autoFocus:!0}),e.jsx("div",{className:"editor-hint",children:n("config:systemPrompt.hint")})]})]})}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("div",{className:"footer-buttons-left",children:e.jsx("button",{className:"btn btn-danger",onClick:T,disabled:!o||a,children:n("config:systemPrompt.clear")})}),e.jsxs("div",{className:"footer-buttons-right",children:[e.jsx("button",{className:"btn btn-secondary",onClick:i,children:"Close"}),e.jsx("button",{className:"btn btn-secondary",onClick:F,disabled:!u||a,children:n("config:systemPrompt.reset")}),e.jsx("button",{className:"btn btn-primary",onClick:I,disabled:!u||a,children:n("config:systemPrompt.save")})]})]})]})})}):null}const ys=[{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:"🌙"}],ws=[{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:"🔴"}],ks=[{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:"👎"}],Ss=[{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:"💜"}],Cs=[{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"}],As=[{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"}],Ts={showTrees:"trees",showBushes:"bushes",showHouse:"house",showLamps:"lamps",showGrass:"grass",showClouds:"clouds"},Is={none:"grass","pokemon-stadium":"pokemon"},Ps={"emote-yes":"yes","emote-no":"no"},Es={"":"auto","#4a90d9":"dayBlue","#0a1a2a":"night","#ff6b35":"sunset","#1a0a2e":"purple","#2d5a27":"matrix","#8b0000":"blood","#000000":"void"};function U({checked:s,onChange:i}){return e.jsxs("label",{className:"config-toggle",children:[e.jsx("input",{type:"checkbox",className:"config-toggle-input",checked:s,onChange:n=>i(n.target.checked)}),e.jsx("span",{className:"config-toggle-track",children:e.jsx("span",{className:"config-toggle-thumb"})})]})}function X({options:s,value:i,onChange:n,iconOnly:o=!1}){return e.jsx("div",{className:"chip-selector",children:s.map(d=>e.jsxs("button",{className:`chip ${i===d.value?"active":""}`,onClick:()=>n(d.value),title:d.label,children:[e.jsx("span",{className:"chip-icon",children:d.icon}),!o&&e.jsx("span",{className:"chip-label",children:d.label})]},d.value))})}function v({text:s,query:i}){if(!i.trim())return e.jsx(e.Fragment,{children:s});const n=s.toLowerCase(),o=i.toLowerCase(),d=n.indexOf(o);if(d===-1)return e.jsx(e.Fragment,{children:s});const p=s.slice(0,d),l=s.slice(d,d+i.length),a=s.slice(d+i.length);return e.jsxs(e.Fragment,{children:[p,e.jsx("mark",{className:"search-highlight",children:l}),a]})}const Ls=[{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:"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"]},{id:"modelStyle",title:"Agent Model Style",keywords:["saturation","roughness","metalness","glow","emissive","reflections","wireframe","color mode","material","shader"]},{id:"animations",title:"Animations",keywords:["idle","working","animation","walk","run","sprint","jump","sit","crouch"]},{id:"secrets",title:"Secrets",keywords:["secrets","api","key","password","credentials","env","environment"]},{id:"systemPrompt",title:"System Prompt",keywords:["system","prompt","global","instructions","ai","agent","rules","guidelines"]},{id:"data",title:"Data",keywords:["export","import","backup","restore","save","load","json"]},{id:"integrations",title:"Integrations",keywords:["integrations","plugins","gmail","slack","jira","calendar","docx","email","config","setup"]},{id:"workflows",title:"Workflows",keywords:["workflow","automation","state machine","editor","actions","transitions","pipeline"]},{id:"triggers",title:"Triggers",keywords:["trigger","event","webhook","cron","slack","email","jira","matching","fire"]},{id:"monitoring",title:"Monitoring",keywords:["monitoring","logs","triggers","events","history","workflow","traces","audit","timeline"]},{id:"experimental",title:"Experimental",keywords:["experimental","2d","view","voice","assistant","speech","tts","text to speech","echo","prompt","duplicate"]},{id:"about",title:"About",keywords:["about","version","update","credits","github","releases"]}],oe=[{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 Fs({config:s,onChange:i,searchQuery:n="",onOpenIntegrationsModal:o,onOpenMonitoringModal:d,onOpenWorkflowEditor:p,onOpenTriggerManager:l}){var ge;const{t:a}=z(["config","common"]),f=ie(),[N,x]=g.useState(f.settings.historyLimit),[y,r]=g.useState(()=>Ue()),[u,c]=g.useState(!1),[w,k]=g.useState(()=>B()),[I,T]=g.useState(!1),[F,_]=g.useState(!1),[m,S]=g.useState(""),[Q,Y]=g.useState(!1),[W,J]=g.useState(""),[b,E]=g.useState(!1);g.useEffect(()=>{xs().then(J).catch(()=>{})},[]),g.useEffect(()=>{ps().then(t=>{t!==f.settings.experimentalEchoPrompt&&j.updateSettings({experimentalEchoPrompt:t})}).catch(()=>{})},[]),g.useEffect(()=>{js().then(t=>{t!==f.settings.tmuxMode&&j.updateSettings({tmuxMode:t})}).catch(()=>{})},[]),g.useEffect(()=>ze(t=>{r(t),c(!1)}),[]);const P=ys.map(t=>({...t,label:a(`config:time.${t.value}`)})),R=ws.map(t=>({...t,label:a(`config:floor.${Is[t.value]||t.value}`)})),h=ks.map(t=>({...t,label:a(`config:animation.${Ps[t.value]||t.value}`)})),C=Ss.map(t=>({...t,label:a(`config:colorMode.${t.value}`)})),L=Cs.map(t=>({...t,label:a(`config:terrain.${Ts[t.key]}`)})),M=As.map(t=>({...t,label:a(`config:sky.${Es[t.value??""]}`)})),H=n.trim()?Ls.filter(t=>{const D=n.toLowerCase();return t.title.toLowerCase().includes(D)||t.keywords.some(se=>se.toLowerCase().includes(D))}).map(t=>t.id):null,A=t=>H?H.includes(t):!0,V=f.settings.customAgentNames||[],Ne=V.length>0?V:Ve,ce=()=>{const t=m.trim();t&&!V.includes(t)&&(j.updateSettings({customAgentNames:[...V,t]}),S(""))},ye=t=>{j.updateSettings({customAgentNames:V.filter(D=>D!==t)})},we=()=>{j.updateSettings({customAgentNames:[]})},ke=t=>{r(t),c(!0)},re=()=>{qe(y),c(!1),ne()},Se=t=>{k(t),T(!0)},de=()=>{Ke(Me.AUTH_TOKEN,w),T(!1),ne()},Ce=t=>{J(t),E(!0)},me=()=>{bs(W).catch(()=>{}),E(!1)},Z=t=>{i({...s,terrain:{...s.terrain,...t}})},G=t=>{i({...s,modelStyle:{...s.modelStyle,...t}})},ue=t=>{i({...s,animations:{...s.animations,...t}})},Ae=t=>{x(t),j.updateSettings({historyLimit:t})},Te=t=>{const D=s.terrain[t];typeof D=="boolean"&&Z({[t]:!D})},O=n.trim().length>0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"config-section",children:[H&&H.length===0&&e.jsx("div",{className:"config-no-results",children:a("config:noResults",{query:n})}),A("general")&&e.jsxs($,{title:a("config:sections.general"),storageKey:"general",defaultOpen:!0,forceOpen:O&&A("general"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:general.history"),query:n})}),e.jsx("input",{type:"number",className:"config-input config-input-sm",value:N,onChange:t=>Ae(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(v,{text:a("config:general.hideCosts"),query:n})}),e.jsx(U,{checked:f.settings.hideCost,onChange:t=>j.updateSettings({hideCost:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:general.grid"),query:n})}),e.jsx(U,{checked:s.gridVisible,onChange:t=>i({...s,gridVisible:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:general.showFPS"),query:n})}),e.jsx(U,{checked:f.settings.showFPS,onChange:t=>j.updateSettings({showFPS:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:general.fpsLimit"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"120",step:"10",value:s.fpsLimit,onChange:t=>i({...s,fpsLimit:parseInt(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.fpsLimit===0?"∞":s.fpsLimit})]}),e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Experimental: Reduce FPS when idle to save power",children:[e.jsx(v,{text:a("config:general.powerSaving"),query:n})," ⚡"]}),e.jsx(U,{checked:f.settings.powerSaving,onChange:t=>j.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(v,{text:a("config:general.tmuxMode"),query:n})}),e.jsx(U,{checked:f.settings.tmuxMode,onChange:async t=>{j.updateSettings({tmuxMode:t});try{await vs(t)}catch(D){console.error("Failed to sync tmux mode setting to server:",D)}}})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:general.vibrationIntensity"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"5",step:"1",value:f.settings.vibrationIntensity,onChange:t=>j.updateSettings({vibrationIntensity:parseInt(t.target.value)})}),e.jsx("span",{className:"config-value",children:f.settings.vibrationIntensity===0?a("config:vibrationValues.off"):f.settings.vibrationIntensity===1?a("config:vibrationValues.ultraLight"):f.settings.vibrationIntensity===2?a("config:vibrationValues.veryLight"):f.settings.vibrationIntensity===3?a("config:vibrationValues.light"):f.settings.vibrationIntensity===4?a("config:vibrationValues.medium"):a("config:vibrationValues.heavy")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:general.externalEditor"),query:n})}),e.jsx("input",{type:"text",className:"config-input",placeholder:a("config:general.externalEditorPlaceholder"),value:f.settings.externalEditorCommand||"",onChange:t=>j.updateSettings({externalEditorCommand:t.target.value})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:general.tabTitle"),query:n})}),e.jsx("input",{type:"text",className:"config-input",placeholder:a("config:general.tabTitlePlaceholder"),value:f.settings.tabTitle||"",onChange:t=>j.updateSettings({tabTitle:t.target.value})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:general.language"),query:n})}),e.jsx(X,{options:oe,value:localStorage.getItem("tide-commander-language-mode")==="manual"?((ge=oe.find(t=>t.value!=="auto"&&ae.language.startsWith(t.value.split("-")[0])))==null?void 0:ge.value)||"en":"auto",onChange:t=>{var D;if(t==="auto"){localStorage.setItem("tide-commander-language-mode","auto");const se=navigator.language,Ie=((D=oe.find(he=>he.value!=="auto"&&se.startsWith(he.value.split("-")[0])))==null?void 0:D.value)||"en";ae.changeLanguage(Ie)}else localStorage.setItem("tide-commander-language-mode","manual"),ae.changeLanguage(t)}})]})]}),A("agentNames")&&e.jsx($,{title:a("config:sections.agentNames"),storageKey:"agentNames",defaultOpen:!1,forceOpen:O&&A("agentNames"),children:e.jsxs("div",{className:"agent-names-section",children:[e.jsx("span",{className:"config-hint",children:V.length>0?a("config:agentNames.customConfigured",{count:V.length}):a("config:agentNames.usingDefaults")}),e.jsxs("div",{className:"agent-names-input-row",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",placeholder:a("config:agentNames.addPlaceholder"),value:m,onChange:t=>S(t.target.value),onKeyDown:t=>{t.key==="Enter"&&ce()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:ce,disabled:!m.trim(),title:a("config:agentNames.addName"),children:"+"})]}),e.jsx("div",{className:"agent-names-list",children:Ne.map((t,D)=>e.jsxs("div",{className:"agent-name-chip",children:[e.jsx("span",{className:"agent-name-text",children:t}),V.length>0&&e.jsx("button",{className:"agent-name-remove",onClick:()=>ye(t),title:a("common:buttons.remove"),children:"x"})]},`${t}-${D}`))}),V.length>0&&e.jsx("button",{className:"config-btn config-btn-link",onClick:we,children:a("common:buttons.resetToDefaults")})]})}),A("appearance")&&e.jsx($,{title:a("config:sections.appearance"),storageKey:"appearance",defaultOpen:!1,forceOpen:O&&A("appearance"),children:e.jsx(cs,{})}),A("connection")&&e.jsxs($,{title:a("config:sections.connection"),storageKey:"connection",defaultOpen:!1,forceOpen:O&&A("connection"),children:[e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:connection.backendUrl"),query:n})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",value:y,onChange:t=>ke(t.target.value),placeholder:"http://localhost:5174",onKeyDown:t=>{t.key==="Enter"&&u&&re()}}),u&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:re,title:a("config:connection.saveAndReconnect"),children:a("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:a("config:connection.autoDetectHint")})]}),e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:connection.authToken"),query:n})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:F?"text":"password",className:"config-input config-input-full",value:w,onChange:t=>Se(t.target.value),placeholder:a("config:connection.tokenPlaceholder"),onKeyDown:t=>{t.key==="Enter"&&I&&de()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>_(!F),title:a(F?"config:connection.hideToken":"config:connection.showToken"),children:F?"🙈":"👁️"}),I&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:de,title:a("config:connection.saveAndReconnect"),children:a("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:a("config:connection.tokenRequired")})]}),e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:connection.codexBinaryPath"),query:n})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",value:W,onChange:t=>Ce(t.target.value),placeholder:a("config:connection.codexBinaryPathPlaceholder"),onKeyDown:t=>{t.key==="Enter"&&b&&me()}}),b&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:me,children:a("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:a("config:connection.codexBinaryPathHint")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("common:buttons.reconnect"),query:n})}),e.jsx("button",{className:"config-btn",onClick:()=>ne(),title:"Force reconnect to server",children:a("common:buttons.reconnect")})]})]}),A("scene")&&e.jsxs($,{title:a("config:sections.scene"),storageKey:"scene",defaultOpen:!1,forceOpen:O&&A("scene"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:scene.characterSize"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.3",max:"3.0",step:"0.1",value:s.characterScale,onChange:t=>i({...s,characterScale:parseFloat(t.target.value)})}),e.jsxs("span",{className:"config-value",children:[s.characterScale.toFixed(1),"x"]})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:scene.scale2d",{defaultValue:"2D Scale"}),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.3",max:"2.0",step:"0.1",value:s.scale2d,onChange:t=>i({...s,scale2d:parseFloat(t.target.value)})}),e.jsxs("span",{className:"config-value",children:[s.scale2d.toFixed(1),"x"]})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:scene.scale3d",{defaultValue:"3D Scale"}),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.3",max:"2.0",step:"0.1",value:s.scale3d,onChange:t=>i({...s,scale3d:parseFloat(t.target.value)})}),e.jsxs("span",{className:"config-value",children:[s.scale3d.toFixed(1),"x"]})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:scene.show2DTaskLabels",{defaultValue:"Show 2D task labels"}),query:n})}),e.jsx(U,{checked:s.show2DTaskLabels,onChange:t=>i({...s,show2DTaskLabels:t})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:scene.time"),query:n})}),e.jsx(X,{options:P,value:s.timeMode,onChange:t=>i({...s,timeMode:t}),iconOnly:!0})]})]}),A("terrain")&&e.jsxs($,{title:a("config:sections.terrain"),storageKey:"terrain",defaultOpen:!1,forceOpen:O&&A("terrain"),children:[e.jsx("div",{className:"terrain-icons",children:L.map(t=>e.jsx("button",{className:`terrain-icon-btn ${s.terrain[t.key]?"active":""}`,onClick:()=>Te(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(v,{text:a("config:terrainSettings.fog"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"2",step:"0.1",value:s.terrain.fogDensity,onChange:t=>Z({fogDensity:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.fogDensity===0?a("config:fogValues.off"):s.terrain.fogDensity<=1?a("config:fogValues.low"):a("config:fogValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:terrainSettings.brightness"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.2",max:"2",step:"0.1",value:s.terrain.brightness,onChange:t=>Z({brightness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.brightness<=.5?a("config:brightnessValues.dark"):s.terrain.brightness<=1.2?a("config:brightnessValues.normal"):a("config:brightnessValues.bright")})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:terrainSettings.floor"),query:n})}),e.jsx(X,{options:R,value:s.terrain.floorStyle,onChange:t=>Z({floorStyle:t}),iconOnly:!0})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:terrainSettings.sky"),query:n})}),e.jsx("div",{className:"sky-color-selector",children:M.map(t=>e.jsx("button",{className:`sky-color-btn ${s.terrain.skyColor===t.value?"active":""}`,onClick:()=>Z({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(v,{text:a("config:terrainSettings.battlefieldSize"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"30",max:"200",step:"10",value:s.terrain.battlefieldSize,onChange:t=>Z({battlefieldSize:parseInt(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.battlefieldSize})]})]}),A("modelStyle")&&e.jsxs($,{title:a("config:sections.modelStyle"),storageKey:"modelStyle",defaultOpen:!1,forceOpen:O&&A("modelStyle"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:modelStyleSettings.saturation"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"2",step:"0.1",value:s.modelStyle.saturation,onChange:t=>G({saturation:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.saturation<=.3?a("config:saturationValues.gray"):s.modelStyle.saturation<=1.2?a("config:saturationValues.normal"):a("config:saturationValues.vivid")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:modelStyleSettings.roughness"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"1",step:"0.1",value:s.modelStyle.roughness,onChange:t=>G({roughness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.roughness<0?a("config:roughnessValues.auto"):s.modelStyle.roughness<=.3?a("config:roughnessValues.glossy"):s.modelStyle.roughness<=.7?a("config:roughnessValues.normal"):a("config:roughnessValues.matte")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:modelStyleSettings.metalness"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"1",step:"0.1",value:s.modelStyle.metalness,onChange:t=>G({metalness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.metalness<0?a("config:metalnessValues.auto"):s.modelStyle.metalness<=.3?a("config:metalnessValues.plastic"):s.modelStyle.metalness<=.7?a("config:metalnessValues.mixed"):a("config:metalnessValues.metal")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:modelStyleSettings.glow"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"1",step:"0.05",value:s.modelStyle.emissiveBoost,onChange:t=>G({emissiveBoost:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.emissiveBoost<=.1?a("config:glowValues.off"):s.modelStyle.emissiveBoost<=.4?a("config:glowValues.low"):s.modelStyle.emissiveBoost<=.7?a("config:glowValues.med"):a("config:glowValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:modelStyleSettings.reflections"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"2",step:"0.1",value:s.modelStyle.envMapIntensity,onChange:t=>G({envMapIntensity:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.envMapIntensity<0?a("config:reflectionValues.auto"):s.modelStyle.envMapIntensity<=.3?a("config:reflectionValues.low"):s.modelStyle.envMapIntensity<=1?a("config:reflectionValues.normal"):a("config:reflectionValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:modelStyleSettings.wireframe"),query:n})}),e.jsx(U,{checked:s.modelStyle.wireframe,onChange:t=>G({wireframe:t})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:modelStyleSettings.colorMode"),query:n})}),e.jsx(X,{options:C,value:s.modelStyle.colorMode,onChange:t=>G({colorMode:t}),iconOnly:!0})]})]}),A("animations")&&e.jsxs($,{title:a("config:sections.animations"),storageKey:"animations",defaultOpen:!1,forceOpen:O&&A("animations"),children:[e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:animationSettings.idle"),query:n})}),e.jsx(X,{options:h,value:s.animations.idleAnimation,onChange:t=>ue({idleAnimation:t}),iconOnly:!0})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:animationSettings.working"),query:n})}),e.jsx(X,{options:h,value:s.animations.workingAnimation,onChange:t=>ue({workingAnimation:t}),iconOnly:!0})]})]}),A("secrets")&&e.jsx($,{title:a("config:sections.secrets"),storageKey:"secrets",defaultOpen:!1,forceOpen:O&&A("secrets"),children:e.jsx(is,{})}),A("systemPrompt")&&e.jsx($,{title:a("config:sections.systemPrompt"),storageKey:"systemPrompt",defaultOpen:!1,forceOpen:O&&A("systemPrompt"),children:e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:systemPrompt.title"),query:n})}),e.jsx("button",{className:"config-button",onClick:()=>Y(!0),children:a("config:systemPrompt.editPrompt")})]})}),A("data")&&e.jsx($,{title:a("config:sections.data"),storageKey:"data",defaultOpen:!1,forceOpen:O&&A("data"),children:e.jsx(ls,{})}),A("integrations")&&e.jsx($,{title:"Integrations",storageKey:"integrations",defaultOpen:!1,forceOpen:O&&A("integrations"),children:e.jsx(ms,{onOpenModal:t=>o==null?void 0:o(t)})}),A("workflows")&&e.jsxs($,{title:"Workflows",storageKey:"workflows",defaultOpen:!1,forceOpen:O&&A("workflows"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(v,{text:"Create and manage automated workflow pipelines with visual state machine editor",query:n})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>p==null?void 0:p(),children:"Open Workflow Editor"})})]}),A("triggers")&&e.jsxs($,{title:"Triggers",storageKey:"triggers",defaultOpen:!1,forceOpen:O&&A("triggers"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(v,{text:"Create and manage event-driven triggers that fire agents with templates",query:n})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>l==null?void 0:l(),children:"Open Trigger Manager"})})]}),A("monitoring")&&e.jsxs($,{title:"Monitoring",storageKey:"monitoring",defaultOpen:!1,forceOpen:O&&A("monitoring"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(v,{text:"View event logs, trigger history, workflow traces, and system stats",query:n})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>d==null?void 0:d(),children:"Open Monitoring & Logs"})})]}),A("experimental")&&e.jsxs($,{title:a("config:sections.experimental"),storageKey:"experimental",defaultOpen:!1,forceOpen:O&&A("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(v,{text:a("config:experimental.2dView"),query:n})," 🗺️"]}),e.jsx(U,{checked:f.settings.experimental2DView,onChange:t=>j.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(v,{text:a("config:experimental.voiceAssistant"),query:n})," 🎤"]}),e.jsx(U,{checked:f.settings.experimentalVoiceAssistant,onChange:t=>j.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(v,{text:a("config:experimental.tts"),query:n})," 🔊"]}),e.jsx(U,{checked:f.settings.experimentalTTS,onChange:t=>j.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(v,{text:a("config:experimental.echoPrompt"),query:n})}),e.jsx(U,{checked:f.settings.experimentalEchoPrompt,onChange:async t=>{j.updateSettings({experimentalEchoPrompt:t});try{await fs(t)}catch(D){console.error("Failed to sync echo prompt setting to server:",D)}}})]}),e.jsx("span",{className:"config-hint",children:a("config:experimental.hint")})]}),A("about")&&e.jsx($,{title:a("config:sections.about"),storageKey:"about",defaultOpen:!1,forceOpen:O&&A("about"),children:e.jsx(rs,{})})]}),e.jsx(Ns,{isOpen:Q,onClose:()=>Y(!1)})]})}function Rs({onConfigChange:s,onToolChange:i,config:n,isOpen:o,onClose:d,onOpenBuildingModal:p,onOpenAreaExplorer:l,onOpenIntegrationsModal:a,onOpenMonitoringModal:f,onOpenWorkflowEditor:N,onOpenTriggerManager:x}){const{t:y}=z(["config","common"]),r=ie(),u=Array.from(r.areas.values()),c=Array.from(r.buildings.values()),[w,k]=g.useState(""),I=g.useRef(null);if(g.useEffect(()=>{const m=S=>{S.key==="Escape"&&o&&d()};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[o,d]),g.useEffect(()=>{if(o&&I.current){const m=setTimeout(()=>{var S;(S=I.current)==null||S.focus()},50);return()=>clearTimeout(m)}},[o]),!o)return null;const T=m=>{const S=r.activeTool===m?null:m;i(S)},F=m=>{j.selectArea(r.selectedAreaId===m?null:m),i("select")},_=(m,S)=>{m.stopPropagation(),j.deleteArea(S)};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"toolbox-backdrop",onClick:d}),e.jsxs("aside",{className:"toolbox",children:[e.jsxs("div",{className:"toolbox-header",children:[e.jsx("span",{children:y("config:title")}),e.jsx("button",{className:"toolbox-close-btn",onClick:d,title:y("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:I,type:"text",placeholder:y("config:searchPlaceholder"),value:w,onChange:m=>k(m.target.value),className:"toolbox-search-input"}),w&&e.jsx("button",{className:"toolbox-search-clear",onClick:()=>k(""),children:"×"})]}),e.jsxs("div",{className:"toolbox-content",children:[e.jsx("div",{className:"toolbox-section toolbox-section-collapsible",children:e.jsxs($,{title:y("config:areas.title",{count:u.length}),storageKey:"areas",children:[e.jsxs("div",{className:"tool-buttons",children:[e.jsx("button",{className:`tool-btn ${r.activeTool==="select"?"active":""}`,onClick:()=>T("select"),title:y("config:tools.select"),children:e.jsx("span",{children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M3 3l7.07 16.97 2.51-7.39 7.39-2.51L3 3z"})})})}),e.jsx("button",{className:`tool-btn ${r.activeTool==="rectangle"?"active":""}`,onClick:()=>T("rectangle"),title:y("config:tools.rectangle"),children:e.jsx("span",{children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"})})})}),e.jsx("button",{className:`tool-btn ${r.activeTool==="circle"?"active":""}`,onClick:()=>T("circle"),title:y("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:u.length===0?e.jsx("div",{className:"areas-empty",children:y("config:areas.drawToCreate")}):u.map(m=>e.jsx(Xe,{area:m,isSelected:r.selectedAreaId===m.id,onClick:()=>F(m.id),onDelete:S=>_(S,m.id)},m.id))})]})}),r.selectedAreaId&&e.jsx(os,{area:r.areas.get(r.selectedAreaId),onClose:()=>j.selectArea(null),onOpenFolder:l}),e.jsx("div",{className:"toolbox-section toolbox-section-collapsible",children:e.jsx($,{title:y("config:buildings.title",{count:c.length}),storageKey:"buildings",headerExtra:e.jsx("button",{className:"add-building-btn",onClick:m=>{m.stopPropagation(),p==null||p()},title:y("config:buildings.addBuilding"),children:"+"}),children:e.jsx("div",{className:"buildings-list",children:c.length===0?e.jsx("div",{className:"buildings-empty",children:y("config:buildings.clickToAdd")}):c.map(m=>e.jsx(Qe,{building:m,isSelected:r.selectedBuildingIds.has(m.id),onClick:()=>{j.selectBuilding(r.selectedBuildingIds.has(m.id)?null:m.id)},onEdit:()=>p==null?void 0:p(m.id)},m.id))})})}),r.selectedBuildingIds.size===1&&(()=>{const m=Array.from(r.selectedBuildingIds)[0],S=r.buildings.get(m);return S?e.jsx(es,{building:S,onClose:()=>j.selectBuilding(null),onOpenModal:()=>p==null?void 0:p(m)}):null})(),e.jsx(Fs,{config:n,onChange:s,searchQuery:w,onOpenIntegrationsModal:a,onOpenMonitoringModal:f,onOpenWorkflowEditor:N,onOpenTriggerManager:x})]})]})]})}export{Rs as Toolbox};
@@ -1,4 +1,4 @@
1
- import{al as sa,u as E,j as e,X as v,ao as Fs,ap as $s,Y as He,s as P,aq as Ms,D as V,a7 as ee,a8 as Ge,f as aa,ar as ta,r as o,P as na,S as la,h as ia,a9 as Ke}from"./main-DB67UbmQ.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const ra=[{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 oa(a){return sa.t(a)}function qe(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 ca(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 Us={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 Ks(a){const l=[],c=/\x1B\[([0-9;]*)m/g;let h=0,t=null,r;for(;(r=c.exec(a))!==null;){if(r.index>h){const m=a.slice(h,r.index);t?l.push(e.jsx("span",{style:{color:t},children:m},l.length)):l.push(m)}const g=r[1].split(";").map(Number);for(const m of g)m===0||m===39?t=null:Us[m]&&(t=Us[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 ma({buildingName:a,onClose:l,onConfirm:c}){const{t:h}=E(["terminal","common"]);return e.jsx("div",{className:"modal-overlay visible",onClick:l,children:e.jsxs("div",{className:"modal confirm-modal",onClick:t=>t.stopPropagation(),children:[e.jsx("div",{className:"modal-header",children:h("terminal:building.deleteBuilding")}),e.jsxs("div",{className:"modal-body confirm-modal-body",children:[e.jsx("p",{children:h("terminal:building.deleteConfirm",{name:a})}),e.jsx("p",{className:"confirm-modal-note",children:h("terminal:building.deleteNote")})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn btn-secondary",onClick:l,children:h("common:buttons.cancel")}),e.jsx("button",{className:"btn btn-danger",onClick:c,autoFocus:!0,children:h("common:buttons.delete")})]})]})})}function da({usePM2:a,setUsePM2:l}){const{t:c}=E(["terminal"]);return e.jsxs("div",{className:"form-section pm2-toggle-section",children:[e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",className:"toggle-input",checked:a,onChange:h=>l(h.target.checked)}),e.jsx("span",{className:"toggle-track",children:e.jsx("span",{className:"toggle-thumb"})}),e.jsxs("span",{className:"toggle-label",children:[e.jsx("span",{className:"pm2-badge",children:"PM2"}),c("terminal:building.usePM2")]})]}),e.jsx("div",{className:"form-hint",children:c("terminal:building.pm2Hint")})]})}function ua({usePM2:a,pm2Script:l,setPm2Script:c,pm2Args:h,setPm2Args:t,pm2Interpreter:r,setPm2Interpreter:g,pm2InterpreterArgs:m,setPm2InterpreterArgs:d,pm2Env:s,setPm2Env:u,isEditMode:b,building:x,handleCommand:N}){var y;const{t:p}=E(["terminal","common"]);return a?e.jsxs("div",{className:"form-section pm2-config-section",children:[e.jsx("label",{className:"form-label",children:p("terminal:building.pm2Configuration")}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Script"),e.jsx(v,{text:p("terminal:building.helpPm2Script"),title:p("terminal:building.pm2Script"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:l,onChange:j=>c(j.target.value),placeholder:"npm, java, python, ./app.js",required:a})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Arguments"),e.jsx(v,{text:p("terminal:building.helpPm2Arguments"),title:p("terminal:building.pm2Arguments"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:h,onChange:j=>t(j.target.value),placeholder:"run dev, -jar app.jar, app.py"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Interpreter"),e.jsx(v,{text:p("terminal:building.helpPm2Interpreter"),title:p("terminal:building.pm2Interpreter"),position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:r,onChange:j=>g(j.target.value),children:Object.keys(Fs).map(j=>e.jsx("option",{value:j,children:Fs[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{al as sa,u as E,j as e,X as v,ao as Fs,ap as $s,Y as He,s as P,aq as Ms,D as V,a7 as ee,a8 as Ge,f as aa,ar as ta,r as o,P as na,S as la,h as ia,a9 as Ke}from"./main-CrRMpn-n.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const ra=[{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 oa(a){return sa.t(a)}function qe(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 ca(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 Us={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 Ks(a){const l=[],c=/\x1B\[([0-9;]*)m/g;let h=0,t=null,r;for(;(r=c.exec(a))!==null;){if(r.index>h){const m=a.slice(h,r.index);t?l.push(e.jsx("span",{style:{color:t},children:m},l.length)):l.push(m)}const g=r[1].split(";").map(Number);for(const m of g)m===0||m===39?t=null:Us[m]&&(t=Us[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 ma({buildingName:a,onClose:l,onConfirm:c}){const{t:h}=E(["terminal","common"]);return e.jsx("div",{className:"modal-overlay visible",onClick:l,children:e.jsxs("div",{className:"modal confirm-modal",onClick:t=>t.stopPropagation(),children:[e.jsx("div",{className:"modal-header",children:h("terminal:building.deleteBuilding")}),e.jsxs("div",{className:"modal-body confirm-modal-body",children:[e.jsx("p",{children:h("terminal:building.deleteConfirm",{name:a})}),e.jsx("p",{className:"confirm-modal-note",children:h("terminal:building.deleteNote")})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn btn-secondary",onClick:l,children:h("common:buttons.cancel")}),e.jsx("button",{className:"btn btn-danger",onClick:c,autoFocus:!0,children:h("common:buttons.delete")})]})]})})}function da({usePM2:a,setUsePM2:l}){const{t:c}=E(["terminal"]);return e.jsxs("div",{className:"form-section pm2-toggle-section",children:[e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",className:"toggle-input",checked:a,onChange:h=>l(h.target.checked)}),e.jsx("span",{className:"toggle-track",children:e.jsx("span",{className:"toggle-thumb"})}),e.jsxs("span",{className:"toggle-label",children:[e.jsx("span",{className:"pm2-badge",children:"PM2"}),c("terminal:building.usePM2")]})]}),e.jsx("div",{className:"form-hint",children:c("terminal:building.pm2Hint")})]})}function ua({usePM2:a,pm2Script:l,setPm2Script:c,pm2Args:h,setPm2Args:t,pm2Interpreter:r,setPm2Interpreter:g,pm2InterpreterArgs:m,setPm2InterpreterArgs:d,pm2Env:s,setPm2Env:u,isEditMode:b,building:x,handleCommand:N}){var y;const{t:p}=E(["terminal","common"]);return a?e.jsxs("div",{className:"form-section pm2-config-section",children:[e.jsx("label",{className:"form-label",children:p("terminal:building.pm2Configuration")}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Script"),e.jsx(v,{text:p("terminal:building.helpPm2Script"),title:p("terminal:building.pm2Script"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:l,onChange:j=>c(j.target.value),placeholder:"npm, java, python, ./app.js",required:a})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Arguments"),e.jsx(v,{text:p("terminal:building.helpPm2Arguments"),title:p("terminal:building.pm2Arguments"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:h,onChange:j=>t(j.target.value),placeholder:"run dev, -jar app.jar, app.py"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Interpreter"),e.jsx(v,{text:p("terminal:building.helpPm2Interpreter"),title:p("terminal:building.pm2Interpreter"),position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:r,onChange:j=>g(j.target.value),children:Object.keys(Fs).map(j=>e.jsx("option",{value:j,children:Fs[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:qe(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:ca(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 pa({dockerMode:a,setDockerMode:l,dockerImage:c,setDockerImage:h,dockerContainerName:t,setDockerContainerName:r,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:$,setDockerEnv:z,dockerComposePath:Y,setDockerComposePath:M,dockerComposeProject:J,setDockerComposeProject:U,dockerComposeServices:W,setDockerComposeServices:K,selectedExistingContainer:R,setSelectedExistingContainer:H,dockerContainersList:O,isEditMode:T,building:k,handleCommand:L}){const{t:A}=E(["config","common"]);return e.jsxs("div",{className:"form-section docker-config-section",children:[e.jsx("label",{className:"form-label",children:A("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=>r(n.target.value),placeholder:"Auto-generated (tc-{name}-{id})"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Command:",e.jsx(v,{text:"Override the default container command. Leave empty to use image's CMD.",title:"Command Override",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:g,onChange:n=>m(n.target.value),placeholder:"Optional command override"})]}),e.jsxs("div",{className:"form-section docker-ports-section",children:[e.jsxs("label",{className:"form-label",children:["Port Mappings",e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>s([...d,""]),children:"+ Add"})]}),d.map((n,C)=>e.jsxs("div",{className:"docker-mapping-row",children:[e.jsx("input",{type:"text",className:"form-input",value:n,onChange:B=>{const D=[...d];D[C]=B.target.value,s(D)},placeholder:"8080:80 or 3000"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>s(d.filter((B,D)=>D!==C)),children:"x"})]},C)),d.length===0&&e.jsx("div",{className:"form-hint",children:"Format: host:container (e.g., 8080:80) or same port (e.g., 3000)"})]}),e.jsxs("div",{className:"form-section docker-volumes-section",children:[e.jsxs("label",{className:"form-label",children:["Volume Mounts",e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>b([...u,""]),children:"+ Add"})]}),u.map((n,C)=>e.jsxs("div",{className:"docker-mapping-row",children:[e.jsx("input",{type:"text",className:"form-input",value:n,onChange:B=>{const D=[...u];D[C]=B.target.value,b(D)},placeholder:"./data:/app/data or /host/path:/container/path"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>b(u.filter((B,D)=>D!==C)),children:"x"})]},C)),u.length===0&&e.jsx("div",{className:"form-hint",children:"Format: host_path:container_path (relative paths resolved from working directory)"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Network:",e.jsx(v,{text:"Docker network to connect to. Leave empty for default bridge network.",title:"Network",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:x,onChange:n=>N(n.target.value),placeholder:"bridge (default)"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Restart Policy:",e.jsx(v,{text:"When should Docker restart the container automatically?",title:"Restart Policy",position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:p,onChange:n=>y(n.target.value),children:Object.keys($s).map(n=>e.jsx("option",{value:n,children:$s[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:Y,onChange:M,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:J,onChange:n=>U(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:W,onChange:n=>K(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:R,onChange:n=>H(n.target.value),required:a==="existing",children:[e.jsx("option",{value:"",children:"Select a container..."}),O.map(n=>e.jsxs("option",{value:n.name,children:[n.name," (",n.image,") - ",n.state]},n.id))]}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>P.requestDockerContainersList(),title:"Refresh container list",children:"↻"})]})]}),O.length===0&&e.jsx("div",{className:"form-hint docker-existing-hint",children:"No containers found. Make sure Docker is running and you have containers available."}),R&&e.jsx("div",{className:"docker-existing-info",children:(()=>{const n=O.find(C=>C.name===R);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:$,onChange:n=>z(n.target.value),placeholder:`KEY=value
4
4
  DATABASE_URL=postgres://...
@@ -1,4 +1,4 @@
1
- import{as as _e,r as t,s as I,w as Ee,at as De,V as Be,j as e,u as pe,au as Ue,av as Ke,aw as $e,ax as We,ay as Ve,k as ze,az as Ge,aA as Pe,aB as qe,aC as Ye,aD as Je,aE as Xe,a3 as Qe,P as Me,S as ce,Y as Ze,U as et,A as tt,a1 as Ie,H as st,J as nt,aF as at,m as Q,aG as ot}from"./main-DB67UbmQ.js";import{F as ct}from"./index-BWCjlz0C.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Ne={status:"all",activity:"all",sort:"activity"},lt={"1h":3600*1e3,"6h":360*60*1e3,"24h":1440*60*1e3},Ae=20,fe=3,rt={idle:"#4aff9e",working:"#4a9eff",waiting:"#ff9e4a",waiting_permission:"#ffcc00",error:"#ff4a4a",offline:"#888888",orphaned:"#ff9e4a"},it=12e4;function dt(s){return s.trim().replace(/\r\n/g,`
1
+ import{as as _e,r as t,s as I,w as Ee,at as De,V as Be,j as e,u as pe,au as Ue,av as Ke,aw as $e,ax as We,ay as Ve,k as ze,az as Ge,aA as Pe,aB as qe,aC as Ye,aD as Je,aE as Xe,a3 as Qe,P as Me,S as ce,Y as Ze,U as et,A as tt,a1 as Ie,H as st,J as nt,aF as at,m as Q,aG as ot}from"./main-CrRMpn-n.js";import{F as ct}from"./index-BexCA27h.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Ne={status:"all",activity:"all",sort:"activity"},lt={"1h":3600*1e3,"6h":360*60*1e3,"24h":1440*60*1e3},Ae=20,fe=3,rt={idle:"#4aff9e",working:"#4a9eff",waiting:"#ff9e4a",waiting_permission:"#ffcc00",error:"#ff4a4a",offline:"#888888",orphaned:"#ff9e4a"},it=12e4;function dt(s){return s.trim().replace(/\r\n/g,`
2
2
  `)}function Fe(s,a){return`${s}:${dt(a)}`}function ut(s,a,o,f){if(s.uuid&&a.has(s.uuid))return!1;const h=s.isUserPrompt?"user":"assistant",u=Fe(h,s.text),M=s.timestamp||0,N=o.get(u);return N!==void 0&&Math.abs(M-N)<=it?!1:M>f}function mt({isOpen:s,agents:a}){const o=_e(),[f,h]=t.useState(new Map),u=t.useRef(new Set);t.useRef(a);const M=t.useMemo(()=>Array.from(a.keys()).sort().join(","),[a]),N=t.useMemo(()=>Array.from(a.values()).map(x=>`${x.id}:${x.sessionId||""}`).sort().join(","),[a]);t.useEffect(()=>{s||(u.current.clear(),h(new Map))},[s]),t.useEffect(()=>{if(!s)return;const x=new Set(Array.from(a.keys()));for(const m of u.current)x.has(m)||u.current.delete(m);let w=null;o>0&&(w=I.preserveOutputs(),u.current.clear());const v=async(m,C,H=0)=>{if(u.current.add(m.id),H>0&&await new Promise(p=>setTimeout(p,H)),h(p=>{const A=new Map(p);return A.set(m.id,{agentId:m.id,messages:[],loading:!0,hasMore:!1,totalCount:0}),A}),!m.sessionId){C&&C.length>0&&I.mergeOutputsWithHistory(m.id,[],C),h(p=>{const A=new Map(p);return A.set(m.id,{agentId:m.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),A});return}try{const A=await(await Be(Ee(`/api/agents/${m.id}/history?limit=${De}&offset=0`))).json(),E=A.messages||[],U=E.length>0?Math.max(...E.map(k=>k.timestamp?new Date(k.timestamp).getTime():0)):0,G=new Set(E.map(k=>k.uuid).filter(k=>!!k)),K=new Map;for(const k of E){if(k.type!=="user"&&k.type!=="assistant")continue;const c=Fe(k.type,k.content),_=k.timestamp?new Date(k.timestamp).getTime():0,L=K.get(c)??0;_>L&&K.set(c,_)}const W=I.getOutputs(m.id),Y=(C&&C.length>0?[...C,...W]:W).filter(k=>ut(k,G,K,U));I.clearOutputs(m.id);for(const k of Y)I.addOutput(m.id,k);h(k=>{const c=new Map(k);return c.set(m.id,{agentId:m.id,messages:E,loading:!1,hasMore:A.hasMore||!1,totalCount:A.totalCount||0}),c})}catch(p){if(console.error(`Failed to load history for ${m.name}:`,p),C&&C.length>0){I.clearOutputs(m.id);for(const A of C)I.addOutput(m.id,A)}h(A=>{const E=new Map(A);return E.set(m.id,{agentId:m.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),E})}},i=o>0?500:0,R=Array.from(a.values());for(const m of R)if(!u.current.has(m.id)){const C=w==null?void 0:w.get(m.id);v(m,C,i)}},[s,M,N,o]);const y=t.useRef(a),S=t.useRef(f);y.current=a,S.current=f;const b=t.useCallback(async x=>{const w=y.current.get(x),v=S.current.get(x);if(!(w!=null&&w.sessionId)||!v||!v.hasMore)return;const i=v.messages.length;try{const m=await(await fetch(Ee(`/api/agents/${x}/history?limit=${De}&offset=${i}`))).json();m.messages&&m.messages.length>0&&h(C=>{const H=new Map(C),p=C.get(x);return p&&H.set(x,{...p,messages:[...m.messages,...p.messages],hasMore:m.hasMore||!1}),H})}catch(R){console.error(`Failed to load more history for agent ${x}:`,R)}},[]),D=t.useCallback(x=>{u.current.delete(x),h(w=>{const v=new Map(w),i=w.get(x);return i&&v.set(x,{...i,messages:[],hasMore:!1,totalCount:0,loading:!1}),v})},[]);return{histories:f,loadMoreHistory:b,clearAgentHistory:D}}function ft({command:s,onCommandChange:a,useTextarea:o,forceTextarea:f,onForceTextarea:h,onSend:u,canSend:M,attachedFiles:N,onAddFile:y,onRemoveFile:S,uploadFile:b,onAddPastedText:D,placeholder:x="Message...",className:w="",compact:v=!1,inputRef:i}){const R=t.useRef(null),m=t.useRef(null),C=t.useRef(o);t.useEffect(()=>{if(o&&!C.current&&m.current){const c=m.current;c.focus(),c.selectionStart=c.selectionEnd=c.value.length}C.current=o},[o]),t.useEffect(()=>{const c=m.current;if(!c||!o)return;c.style.height="auto";const _=v?120:180,L=Math.min(c.scrollHeight,_);c.style.height=`${L}px`},[s,o,v]);const H=t.useCallback(async c=>{const _=c.clipboardData.items;for(const B of _)if(B.type.startsWith("image/")){c.preventDefault();const F=B.getAsFile();if(F){const T=await b(F);T&&y(T)}return}const L=c.clipboardData.files;if(L.length>0){c.preventDefault();for(const B of L){const F=await b(B);F&&y(F)}return}const J=c.clipboardData.getData("text"),q=(J.match(/\n/g)||[]).length+1;if(q>5){c.preventDefault();const F=`[Pasted text #${D(J)} +${q} lines]`,T=c.target,V=T.selectionStart||0,se=T.selectionEnd||0,ne=s.slice(0,V)+F+s.slice(se);a(ne),o||h(!0)}},[s,a,o,h,b,y,D]),p=t.useCallback(async c=>{const _=c.target.files;if(_){for(const L of _){const J=await b(L);J&&y(J)}R.current&&(R.current.value="")}},[b,y]),A=t.useCallback(c=>{if(c.key==="Enter"&&c.shiftKey){o||(c.preventDefault(),h(!0));return}c.key==="Enter"&&(c.preventDefault(),u())},[o,h,u]),E=t.useCallback(c=>{},[]),U=t.useCallback(c=>{c.button===1&&(c.preventDefault(),c.stopPropagation())},[]),G=t.useCallback(c=>{m.current=c,i==null||i(c)},[i]),K=v?"agent-panel-input":"guake-input",W=v?"agent-panel-input-container":"guake-input-container",ee=v?"agent-panel-attach-btn":"guake-attach-btn",Y=v?"agent-panel-send-btn":"",k=o?v?"agent-panel-input-expanded":"guake-input-expanded":"";return e.jsxs(e.Fragment,{children:[N.length>0&&e.jsx("div",{className:v?"agent-panel-attachments":"guake-attachments",children:N.map(c=>e.jsxs("div",{className:`${v?"agent-panel-attachment":"guake-attachment"} ${c.isImage?"is-image":""}`,children:[e.jsx("span",{className:v?"agent-panel-attachment-icon":"guake-attachment-icon",children:c.isImage?"🖼️":"📎"}),e.jsx("span",{className:v?"agent-panel-attachment-name":"guake-attachment-name",title:c.path,children:c.name}),!v&&e.jsxs("span",{className:"guake-attachment-size",children:["(",Math.round(c.size/1024),"KB)"]}),e.jsx("button",{className:v?"agent-panel-attachment-remove":"guake-attachment-remove",onClick:()=>S(c.id),title:"Remove",children:"×"})]},c.id))}),e.jsxs("div",{className:`${K} ${k} ${w}`,children:[e.jsx("input",{ref:R,type:"file",multiple:!0,onChange:p,style:{display:"none"},accept:"*"}),e.jsxs("div",{className:W,onAuxClick:U,children:[e.jsx("button",{className:ee,onClick:()=>{var c;return(c=R.current)==null?void 0:c.click()},title:"Attach file (or paste image)",children:"📎"}),o?e.jsx("textarea",{ref:G,placeholder:x,value:s,onChange:c=>a(c.target.value),onKeyDown:A,onPaste:H,onMouseDown:E}):e.jsx("input",{ref:i,type:"text",placeholder:x,value:s,onChange:c=>a(c.target.value),onKeyDown:A,onPaste:H,onMouseDown:E}),e.jsx("button",{className:Y,onClick:u,disabled:!M,title:"Send",children:"➤"})]})]})]})}function pt(s){const a=Math.floor(s/1e3),o=Math.floor(a/60),f=a%60;return`${o}:${f.toString().padStart(2,"0")}`}const ht=t.memo(function({agentId:a,isWorking:o,timestamp:f}){const{t:h}=pe(["terminal"]),[u,M]=t.useState(0);return t.useEffect(()=>{if(!o||!f){M(0);return}M(Date.now()-f);const N=setInterval(()=>{M(Date.now()-f)},1e3);return()=>clearInterval(N)},[o,f]),o?e.jsxs("div",{className:"guake-stop-bar",children:[e.jsx("span",{className:"guake-elapsed-timer",children:pt(u)}),e.jsxs("button",{className:"guake-stop-btn",onClick:()=>I.stopAgent(a),title:h("terminal:input.stopOperation"),children:[e.jsx("span",{className:"stop-icon",children:"■"}),e.jsx("span",{className:"stop-label",children:h("terminal:input.stop")})]})]}):null});function gt({agent:s,history:a,outputs:o,isExpanded:f,isFocused:h,advancedView:u,onExpand:M,onFocus:N,inputRef:y,onLoadMore:S,onClearHistory:b}){const{t:D}=pe(["terminal","common"]),x=Ue(),w=Ke(s.id),v=t.useRef(null),[i,R]=t.useState(!1),m=t.useRef(0),C=t.useRef(!1),[H,p]=t.useState(!0),[A,E]=t.useState(!1),[U,G]=t.useState(null),[K,W]=t.useState(null),[ee,Y]=t.useState(null);$e(`commander-image-modal-${s.id}`,U!==null,()=>G(null));const{command:k,setCommand:c,forceTextarea:_,setForceTextarea:L,useTextarea:J,setPastedTexts:q,incrementPastedCount:B,resetPastedCount:F,attachedFiles:T,setAttachedFiles:V,removeAttachedFile:se,uploadFile:ne,expandPastedTexts:le}=We({selectedAgentId:s.id}),ae=k.trim().length>0||T.length>0,l=Ve({outputs:o,viewMode:u?"advanced":"simple"}),g=t.useMemo(()=>x!=null&&x.agentSummaries?x.agentSummaries.find(j=>j.agentId===s.id||j.agentName===s.name):null,[x,s.id,s.name]),d=t.useMemo(()=>{const j=ze(s);return{usedPercent:j.usedPercent,freePercent:j.freePercent,hasData:!!s.contextStats,totalTokens:j.totalTokens,contextWindow:j.contextWindow}},[s.contextStats,s.contextUsed,s.contextLimit]),P=t.useCallback(()=>{!i&&(a!=null&&a.hasMore)&&S&&(R(!0),m.current=v.current?v.current.scrollHeight-v.current.scrollTop:0,S())},[i,a==null?void 0:a.hasMore,S]);t.useEffect(()=>{i&&a&&!a.loading&&R(!1)},[a,i]);const te=t.useCallback(()=>{C.current=!0,p(!1)},[]),Z=t.useRef(f),z=t.useRef(h);t.useEffect(()=>{(f&&!Z.current||h&&!z.current)&&(C.current=!1,p(!0),E(!0)),Z.current=f,z.current=h},[f,h]);const re=t.useRef(a==null?void 0:a.loading);t.useEffect(()=>{re.current&&!(a!=null&&a.loading)&&(C.current=!1,p(!0),E(!0)),re.current=a==null?void 0:a.loading},[a==null?void 0:a.loading]),t.useEffect(()=>{if(!A)return;const j=v.current;if(!j)return;const $=performance.now();let O=0,me=-1,be;const ye=()=>{const{scrollTop:Le,scrollHeight:Se,clientHeight:He}=j,Oe=Se-Le-He<=2;if(Math.abs(Se-me)<=1&&Oe?O+=1:O=0,me=Se,O>=3){E(!1);return}if(performance.now()-$>5e3){E(!1);return}be=requestAnimationFrame(ye)};return be=requestAnimationFrame(ye),()=>cancelAnimationFrame(be)},[A]),t.useEffect(()=>{C.current||p(!0)},[l.length]);const he=t.useCallback(()=>!1,[]),ge=t.useCallback(j=>{const $=B();return q(O=>new Map(O).set($,j)),$},[B,q]),xe=t.useCallback(j=>{V($=>[...$,j])},[V]),ve=t.useCallback(()=>{if(!ae)return;if(k.trim()==="/clear"&&T.length===0){I.clearContext(s.id),b(),c(""),L(!1),q(new Map),V([]),F();return}let j=le(k.trim());if(T.length>0){const $=T.map(O=>O.isImage?`[Image: ${O.path}]`:`[File: ${O.path}]`).join(`
3
3
  `);j=j?`${j}
4
4
 
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/web-DRj84zWD.js","assets/main-DB67UbmQ.js","assets/modulepreload-polyfill-B5Qt9EMX.js","assets/vendor-react--Eh9ivFN.js","assets/vendor-three-Chj50gSY.js","assets/main-Chjl2UXl.css"])))=>i.map(i=>d[i]);
2
- import{bm as e,aN as o}from"./main-DB67UbmQ.js";import"./modulepreload-polyfill-B5Qt9EMX.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 p=e("Haptics",{web:()=>o(()=>import("./web-DRj84zWD.js"),__vite__mapDeps([0,1,2,3,4,5])).then(r=>new r.HapticsWeb)});export{p as Haptics,i as ImpactStyle,t as NotificationType};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/web-D94DaG2N.js","assets/main-CrRMpn-n.js","assets/modulepreload-polyfill-B5Qt9EMX.js","assets/vendor-react--Eh9ivFN.js","assets/vendor-three-Chj50gSY.js","assets/main-DjGrMNoB.css"])))=>i.map(i=>d[i]);
2
+ import{bm as e,aN as o}from"./main-CrRMpn-n.js";import"./modulepreload-polyfill-B5Qt9EMX.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 p=e("Haptics",{web:()=>o(()=>import("./web-D94DaG2N.js"),__vite__mapDeps([0,1,2,3,4,5])).then(r=>new r.HapticsWeb)});export{p as Haptics,i as ImpactStyle,t as NotificationType};