tide-commander 1.111.1 → 1.111.2

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 (37) hide show
  1. package/dist/assets/{BossLogsModal-C1li4cnA.js → BossLogsModal-DLTh_jKZ.js} +1 -1
  2. package/dist/assets/{BossSpawnModal-BJ-fx5zF.js → BossSpawnModal-DzivoRl1.js} +1 -1
  3. package/dist/assets/{ControlsModal-CHKX3bwB.js → ControlsModal-B8j6My0t.js} +1 -1
  4. package/dist/assets/{DockerLogsModal-CwtdNToh.js → DockerLogsModal-BNwx7lVp.js} +1 -1
  5. package/dist/assets/{EmbeddedEditor-BTRUWN3W.js → EmbeddedEditor-CBoOoGL8.js} +1 -1
  6. package/dist/assets/{GmailOAuthSetup-CxGheYrE.js → GmailOAuthSetup-BACIjX54.js} +1 -1
  7. package/dist/assets/{GoogleOAuthSetup-CqcDFcuw.js → GoogleOAuthSetup-BuASGyWh.js} +1 -1
  8. package/dist/assets/{IframeModal-DCI2xBDs.js → IframeModal-ckpeQpQB.js} +1 -1
  9. package/dist/assets/{IntegrationsPanel-BsBSuc5U.js → IntegrationsPanel-Dh7UOnTC.js} +2 -2
  10. package/dist/assets/{LogViewerModal-Cs4_VfRa.js → LogViewerModal-Cj7Hv-mD.js} +1 -1
  11. package/dist/assets/{MonitoringModal-CcQ0zYEr.js → MonitoringModal-Bx4vcjBr.js} +1 -1
  12. package/dist/assets/{PM2LogsModal-r4FAIdxy.js → PM2LogsModal-RBIjfi4J.js} +1 -1
  13. package/dist/assets/{RestoreArchivedAreaModal-DqqxPSu-.js → RestoreArchivedAreaModal-BBYlYIso.js} +1 -1
  14. package/dist/assets/{Scene2DCanvas-_RP_XoMQ.js → Scene2DCanvas-CYB1Y5Wa.js} +1 -1
  15. package/dist/assets/{SceneManager-CD6E0rIP.js → SceneManager-6vk047Kd.js} +1 -1
  16. package/dist/assets/{SkillsPanel-CNEhrh4l.js → SkillsPanel-CRRypqdy.js} +1 -1
  17. package/dist/assets/{SlackMultiInstanceSetup-Cjylwazt.js → SlackMultiInstanceSetup-DisMBGxX.js} +1 -1
  18. package/dist/assets/{SpawnModal-hEtOcN47.js → SpawnModal-qiu5nT-F.js} +1 -1
  19. package/dist/assets/{StatisticsModal-BYA9cfTG.js → StatisticsModal-Bzk7qqOd.js} +1 -1
  20. package/dist/assets/{SubordinateAssignmentModal-CzcBncW1.js → SubordinateAssignmentModal-AUCAiGkE.js} +1 -1
  21. package/dist/assets/{TriggerManagerPanel-DsOfMpov.js → TriggerManagerPanel-56SuYzNh.js} +1 -1
  22. package/dist/assets/{WorkflowEditorPanel-BHDvK1D5.js → WorkflowEditorPanel-H0IGkyMd.js} +1 -1
  23. package/dist/assets/{index-XGwd-4sy.js → index--3sQ1gHE.js} +3 -3
  24. package/dist/assets/{index-DtKnq4Lr.js → index-94AqwQn0.js} +1 -1
  25. package/dist/assets/{index-CxvFEZYp.js → index-9NugNkE4.js} +1 -1
  26. package/dist/assets/{index-Buzi9_q1.js → index-C-kx99MP.js} +1 -1
  27. package/dist/assets/{index-mCP4-x_q.js → index-DFWA70Lq.js} +1 -1
  28. package/dist/assets/{index-HTRPdYbU.js → index-DY395tVJ.js} +2 -2
  29. package/dist/assets/{index-C3dHJ4j6.js → index-DZP3fZ3b.js} +1 -1
  30. package/dist/assets/{index-DlUMlSJy.js → index-Dv0tQnLX.js} +1 -1
  31. package/dist/assets/{index-CPCKwSnq.js → index-pRI5GcXd.js} +1 -1
  32. package/dist/assets/{main-Cq5TB_d6.js → main-Bon1sZAi.js} +64 -64
  33. package/dist/assets/{web-BO9rHZoK.js → web-CccJFC0m.js} +1 -1
  34. package/dist/assets/{web-C4r_DTuF.js → web-CdhZGenV.js} +1 -1
  35. package/dist/assets/{web-CfhEju0q.js → web-RZLwjKCT.js} +1 -1
  36. package/dist/index.html +1 -1
  37. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import{r as l,aW as Re,aX as Ye,j as e,I as L,u as Y,aY as as,a3 as ns,f as Ve,s as E,aZ as ms,k as is,l as he,a_ as Z,a$ as gs,aP as fs,b0 as xs,C as me,b1 as J,aM as we,b2 as bs,b3 as js,b4 as ws,b5 as ys,b6 as Se,b7 as os,b8 as Ns,b9 as Me,ba as vs,bb as ks,bc as Ss,bd as Cs,be as Ts,bf as As,bg as _s,aI as Es,J as Is,S as ke,bh as Ps,bi as $s,aK as Ls,bj as Ue,K as Ie,aT as Ds,bk as ze,bl as Fs}from"./main-Cq5TB_d6.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Ke="deivid11/tide-commander",Os=`https://api.github.com/repos/${Ke}/releases/latest`,Rs=`https://api.github.com/repos/${Ke}/releases?per_page=3`,Us=3600*1e3,Je="app_update_dismissed_version",Ze="1.111.1";function zs(){var w,C;const[s,a]=l.useState({isChecking:!1,updateAvailable:!1,updateInfo:null,recentReleases:[],error:null,currentVersion:Ze}),t=((C=(w=Re)==null?void 0:w.getPlatform)==null?void 0:C.call(w))==="android"||!1,o=u=>u.replace(/^v/,"").split(".").map(m=>parseInt(m,10)||0),r=(u,p)=>{const m=o(u),j=o(p),b=Math.max(m.length,j.length);for(let h=0;h<b;h++){const k=m[h]||0,$=j[h]||0;if(k>$)return 1;if(k<$)return-1}return 0},d=async u=>{var m,j;if(Re&&Ye&&((j=(m=Re).isNativePlatform)==null?void 0:j.call(m))===!0){const b=await Ye.get({url:u,headers:{Accept:"application/vnd.github.v3+json"}});return{data:b.data,status:b.status}}else{const b=await fetch(u,{headers:{Accept:"application/vnd.github.v3+json"}});return b.ok?{data:await b.json(),status:b.status}:{data:null,status:b.status}}},c=l.useCallback(async(u=!1)=>{a(p=>({...p,isChecking:!0,error:null}));try{const[p,m]=await Promise.all([d(Os),d(Rs)]);if(p.status!==200)throw new Error(`GitHub API error: ${p.status}`);const j=p.data,b=j.tag_name;let h=[];m.status===200&&m.data&&(h=m.data.map(y=>({version:y.tag_name,name:y.name,publishedAt:y.published_at,releaseUrl:y.html_url})));const k=localStorage.getItem(Je);if(!u&&k===b)return a(y=>({...y,isChecking:!1,updateAvailable:!1,recentReleases:h})),null;if(!(r(b,Ze)>0))return a(y=>({...y,isChecking:!1,updateAvailable:!1,recentReleases:h})),null;const P=j.assets.find(y=>y.name.endsWith(".apk")&&y.content_type==="application/vnd.android.package-archive"),K={version:b,name:j.name,changelog:j.body,releaseUrl:j.html_url,apkUrl:(P==null?void 0:P.browser_download_url)||null,apkSize:(P==null?void 0:P.size)||null,publishedAt:j.published_at};return a(y=>({...y,isChecking:!1,updateAvailable:!0,updateInfo:K,recentReleases:h})),K}catch(p){const m=p instanceof Error?p.message:"Failed to check for updates";return a(j=>({...j,isChecking:!1,error:m})),null}},[]),g=l.useCallback(async()=>{var u,p,m;if(!((u=s.updateInfo)!=null&&u.apkUrl)){(p=s.updateInfo)!=null&&p.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}if(!t){(m=s.updateInfo)!=null&&m.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}try{window.open(s.updateInfo.apkUrl,"_system"),a(j=>({...j,error:null}))}catch(j){const b=j instanceof Error?j.message:"Failed to open download";a(h=>({...h,error:b}))}},[s.updateInfo,t]),n=l.useCallback(()=>{s.updateInfo&&localStorage.setItem(Je,s.updateInfo.version),a(u=>({...u,updateAvailable:!1,updateInfo:null}))},[s.updateInfo]),x=l.useCallback(()=>{var u;(u=s.updateInfo)!=null&&u.releaseUrl?window.open(s.updateInfo.releaseUrl,"_blank"):window.open(`https://github.com/${Ke}/releases`,"_blank")},[s.updateInfo]);return l.useEffect(()=>{if(!t)return;const u=setTimeout(()=>{c()},5e3),p=setInterval(()=>{c()},Us);return()=>{clearTimeout(u),clearInterval(p)}},[t,c]),{...s,isAndroid:t,checkForUpdate:c,downloadAndInstall:g,dismissUpdate:n,openReleasePage:x}}const ls="tide-toolbox-collapse";function Bs(s,a){try{const t=localStorage.getItem(`${ls}-${s}`);if(t!==null)return t==="true"}catch{}return a}function Ms(s,a){try{localStorage.setItem(`${ls}-${s}`,String(a))}catch{}}function W({title:s,storageKey:a,defaultOpen:t=!1,forceOpen:o=!1,children:r,headerExtra:d}){const[c,g]=l.useState(()=>a?Bs(a,t):t),n=()=>{const w=!c;g(w),a&&Ms(a,w)},x=o||c;return e.jsxs("div",{className:`collapsible-section ${x?"open":"collapsed"}`,children:[e.jsxs("button",{className:"collapsible-header",onClick:n,children:[e.jsx("span",{className:"collapsible-title",children:s}),e.jsxs("span",{className:"collapsible-header-right",children:[d,e.jsx("span",{className:"collapsible-arrow",children:e.jsx(L,{name:x?"caret-down":"caret-right",size:10})})]})]}),x&&e.jsx("div",{className:"collapsible-content",children:r})]})}function Vs({area:s,isSelected:a,onClick:t,onDelete:o}){const{t:r}=Y(["config","common"]),d=s.assignedAgentIds.length,c=s.type==="rectangle"?r("config:areas.rect"):r("config:areas.circle");return e.jsxs("div",{className:`area-item ${a?"selected":""}`,onClick:t,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:[c," ",d>0&&`• ${d} ${d>1?r("common:labels.agents").toLowerCase():r("common:labels.agent").toLowerCase()}`]})]}),e.jsx("button",{className:"area-delete-btn",onClick:o,title:r("config:areas.deleteArea"),children:"×"})]})}function Ks({building:s,isSelected:a,onClick:t,onEdit:o}){var g;const{t:r}=Y(["config"]),d=((g=s.pm2Status)==null?void 0:g.ports)||[],c=(n,x)=>{n.stopPropagation(),window.open(`http://${window.location.hostname}:${x}`,"_blank")};return e.jsxs("div",{className:`building-item ${a?"selected":""}`,onClick:t,children:[e.jsx("div",{className:"building-status-dot",style:{backgroundColor:as[s.status]},title:s.status}),e.jsx("div",{className:"building-icon",children:e.jsx(L,{name:ns(s.type),size:16})}),e.jsxs("div",{className:"building-info",children:[e.jsx("div",{className:"building-name",children:s.name}),e.jsxs("div",{className:"building-meta",children:[s.type,d.length>0&&e.jsx("span",{className:"building-ports",children:d.map(n=>e.jsxs("a",{href:`http://${window.location.hostname}:${n}`,className:"building-port-link",onClick:x=>c(x,n),title:`Open :${n}`,children:[":",n]},n))})]})]}),e.jsx("button",{className:"building-edit-btn",onClick:n=>{n.stopPropagation(),o()},title:r("config:buildings.editBuilding"),children:e.jsx(L,{name:"gear",size:14})})]})}function Hs({building:s,onClose:a,onOpenModal:t}){var x,w,C,u,p,m,j,b;const{t:o}=Y(["config","common"]),{buildingLogs:r}=Ve(),d=E.getBuildingLogs(s.id),c=ms[s.style||"server-rack"],g=h=>{E.sendBuildingCommand(s.id,h)},n=h=>{window.open(h,"_blank")};return e.jsxs("div",{className:"building-editor",children:[e.jsxs("div",{className:"building-editor-header",children:[e.jsxs("div",{className:"building-editor-title-row",children:[e.jsx("span",{className:"building-editor-icon",children:e.jsx(L,{name:ns(s.type),size:18})}),e.jsx("span",{className:"building-editor-title",children:s.name}),e.jsx("span",{className:"building-editor-status",style:{backgroundColor:as[s.status]},children:s.status})]}),e.jsx("button",{className:"building-editor-close",onClick:a,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:c.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:()=>g("start"),disabled:!((x=s.commands)!=null&&x.start)||s.status==="running",title:((w=s.commands)==null?void 0:w.start)||o("config:buildings.noStartCommand"),children:[e.jsx(L,{name:"play",size:12})," ",o("common:buttons.start")]}),e.jsxs("button",{className:"building-editor-action-btn stop",onClick:()=>g("stop"),disabled:!((C=s.commands)!=null&&C.stop)||s.status==="stopped",title:((u=s.commands)==null?void 0:u.stop)||o("config:buildings.noStopCommand"),children:[e.jsx(L,{name:"stop",size:12,weight:"fill"})," ",o("common:buttons.stop")]}),e.jsxs("button",{className:"building-editor-action-btn restart",onClick:()=>g("restart"),disabled:!((p=s.commands)!=null&&p.restart),title:((m=s.commands)==null?void 0:m.restart)||o("config:buildings.noRestartCommand"),children:[e.jsx(L,{name:"refresh",size:12})," ",o("common:buttons.retry")]}),e.jsxs("button",{className:"building-editor-action-btn health",onClick:()=>g("healthCheck"),disabled:!((j=s.commands)!=null&&j.healthCheck),title:((b=s.commands)==null?void 0:b.healthCheck)||o("config:buildings.noHealthCheck"),children:[e.jsx(L,{name:"heart",size:12})," Health"]})]})]}),s.urls&&s.urls.length>0&&e.jsxs("div",{className:"building-editor-section",children:[e.jsx("div",{className:"building-editor-section-title",children:o("config:buildings.links")}),e.jsx("div",{className:"building-editor-links",children:s.urls.map((h,k)=>e.jsxs("button",{className:"building-editor-link",onClick:()=>n(h.url),title:h.url,children:[e.jsx(L,{name:"link",size:12})," ",h.label||h.url]},k))})]}),d.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:()=>E.clearBuildingLogs(s.id),title:o("common:buttons.clear"),children:o("common:buttons.clear")})]}),e.jsx("div",{className:"building-editor-logs",children:d.slice(-5).map((h,k)=>e.jsx("div",{className:"building-editor-log-entry",children:h},k))})]}),e.jsx("div",{className:"building-editor-footer",children:e.jsxs("button",{className:"building-editor-edit-btn",onClick:t,children:[e.jsx(L,{name:"gear",size:12})," ",o("config:buildings.fullSettings")]})})]})}async function Ws(s,a){const t=Z(),o=await fetch(he(`/api/areas/${s}/logo`),{method:"POST",headers:{"Content-Type":a.type||"image/png","X-Filename":encodeURIComponent(a.name),...t?{Authorization:`Bearer ${t}`}:{}},body:a});if(!o.ok){const r=await o.json().catch(()=>({error:o.statusText}));throw new Error(r.error||`Upload failed: ${o.statusText}`)}return o.json()}async function qs(s){const a=Z(),t=await fetch(he(`/api/areas/${s}/logo`),{method:"DELETE",headers:{...a?{Authorization:`Bearer ${a}`}:{}}});if(!t.ok)throw new Error(`Failed to delete logo: ${t.statusText}`)}function Gs(s){return is(he(`/api/areas/logos/${s}`))}const Ys=[{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 Js({area:s,onClose:a,onOpenFolder:t}){var ie;const{t:o}=Y(["config","common"]),[r,d]=l.useState(s.name),[c,g]=l.useState(s.prompt||""),[n,x]=l.useState(!1),[w,C]=l.useState(""),[u,p]=l.useState(!1),m=l.useRef(null);l.useEffect(()=>{d(s.name)},[s.id,s.name]),l.useEffect(()=>{g(s.prompt||"")},[s.id,s.prompt]);const j=v=>{const F=v.target.value;d(F),E.updateArea(s.id,{name:F})},b=v=>{E.updateArea(s.id,{color:v})},h=v=>{const F=v.target.value;g(F),E.updateArea(s.id,{prompt:F})},k=()=>{w.trim()&&(E.addDirectoryToArea(s.id,w.trim()),C(""),x(!1))},$=(v,F)=>{F.stopPropagation(),E.removeDirectoryFromArea(s.id,v)},P=()=>{E.bringAreaToFront(s.id)},K=()=>{E.sendAreaToBack(s.id)},y=l.useCallback(()=>{let v=2,F=2;s.type==="rectangle"&&s.width&&s.height?(v=s.width,F=s.height):s.type==="circle"&&s.radius&&(v=s.radius*1.414,F=s.radius*1.414);const M=Math.min(v,F)*.4;return{width:Math.round(M*10)/10,height:Math.round(M*10)/10}},[s.type,s.width,s.height,s.radius]),U=async v=>{var M;const F=(M=v.target.files)==null?void 0:M[0];if(F){p(!0);try{const N=await Ws(s.id,F),D=y();E.updateArea(s.id,{logo:{filename:N.filename,position:"center",width:D.width,height:D.height,keepAspectRatio:!0,opacity:.8}})}catch(N){console.error("Failed to upload logo:",N)}finally{p(!1),m.current&&(m.current.value="")}}},B=async()=>{try{await qs(s.id),E.updateArea(s.id,{logo:void 0})}catch(v){console.error("Failed to remove logo:",v)}},V=v=>{s.logo&&E.updateArea(s.id,{logo:{...s.logo,position:v}})},S=v=>{if(!s.logo)return;const F=parseFloat(v.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.width>0){const M=s.logo.height/s.logo.width;E.updateArea(s.id,{logo:{...s.logo,width:F,height:Math.round(F*M*10)/10}})}else E.updateArea(s.id,{logo:{...s.logo,width:F}})},T=v=>{if(!s.logo)return;const F=parseFloat(v.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.height>0){const M=s.logo.width/s.logo.height;E.updateArea(s.id,{logo:{...s.logo,height:F,width:Math.round(F*M*10)/10}})}else E.updateArea(s.id,{logo:{...s.logo,height:F}})},H=()=>{s.logo&&E.updateArea(s.id,{logo:{...s.logo,keepAspectRatio:!s.logo.keepAspectRatio}})},X=v=>{s.logo&&E.updateArea(s.id,{logo:{...s.logo,opacity:parseFloat(v.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:a,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:r,onChange:j,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:gs.map(v=>e.jsx("button",{type:"button",className:`color-swatch ${s.color===v?"selected":""}`,style:{backgroundColor:v},onClick:()=>b(v),"aria-label":`Set area color ${v}`,"aria-pressed":s.color===v,title:v},v))})]}),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:P,title:o("config:areas.bringToFront"),children:[e.jsx(L,{name:"arrow-up",size:12})," ",o("config:areas.front")]}),e.jsxs("button",{className:"area-layer-btn",onClick:K,title:o("config:areas.sendToBack"),children:[e.jsx(L,{name:"arrow-down",size:12})," ",o("config:areas.back")]})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.logo")}),e.jsxs("div",{className:"area-logo-section",children:[(ie=s.logo)!=null&&ie.filename?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"area-logo-preview",children:[e.jsx("img",{src:Gs(s.logo.filename),alt:"Logo",className:"area-logo-thumbnail"}),e.jsx("button",{className:"area-logo-remove-btn",onClick:B,children:o("config:areas.removeLogo")}),e.jsx("button",{className:"area-logo-replace-btn",onClick:()=>{var v;return(v=m.current)==null?void 0:v.click()},disabled:u,children:u?"...":e.jsx(L,{name:"refresh",size:12})})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoPosition")}),e.jsx("div",{className:"area-logo-position-row",children:Ys.map(({key:v,labelKey:F})=>{var M;return e.jsx("button",{className:`area-logo-pos-btn ${((M=s.logo)==null?void 0:M.position)===v?"active":""}`,onClick:()=>V(v),children:o(`config:areas.${F}`)},v)})})]}),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:S,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:T,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:H}),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:X,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 v;return(v=m.current)==null?void 0:v.click()},disabled:u,children:u?"...":o("config:areas.uploadLogo")}),e.jsx("input",{ref:m,type:"file",accept:"image/*",style:{display:"none"},onChange:U})]})]}),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(v=>e.jsxs("div",{className:"area-folder-item",title:v,children:[e.jsx("span",{className:"area-folder-icon clickable",onClick:()=>t==null?void 0:t(s.id),title:o("config:areas.openFolder"),children:e.jsx(L,{name:"folder",size:14})}),e.jsx("span",{className:"area-folder-path",children:v.split("/").pop()||v}),e.jsx("button",{className:"area-folder-remove",onClick:F=>$(v,F),title:o("config:areas.removeFolder"),children:"×"})]},v)),n?e.jsxs("div",{className:"area-add-folder-inline",children:[e.jsx(fs,{value:w,onChange:C,onSubmit:k,placeholder:o("config:areas.folderPlaceholder"),className:"area-add-folder-input",directoriesOnly:!0,autoFocus:!0}),e.jsx("button",{className:"area-add-folder-confirm",onClick:k,children:"+"})]}):e.jsx("button",{className:"area-add-folder-btn",onClick:()=>x(!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:c,onChange:h,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 Zs(){const{t:s}=Y(["config","common"]),a=xs(),[t,o]=l.useState(!1),[r,d]=l.useState(null),[c,g]=l.useState({name:"",key:"",value:"",description:""}),[n,x]=l.useState(null),w=()=>{o(!0),d(null),g({name:"",key:"",value:"",description:""})},C=h=>{d(h.id),o(!1),g({name:h.name,key:h.key,value:h.value,description:h.description||""})},u=()=>{o(!1),d(null),g({name:"",key:"",value:"",description:""})},p=()=>{!c.name.trim()||!c.key.trim()||(r?E.updateSecret(r,{name:c.name.trim(),key:c.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:c.value,description:c.description.trim()||void 0}):E.createSecret({name:c.name.trim(),key:c.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:c.value,description:c.description.trim()||void 0}),u())},m=h=>{x(h)},j=()=>{n&&(E.deleteSecret(n),r===n&&u())},b=h=>{navigator.clipboard.writeText(`{{${h}}}`)};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:a.length===0&&!t?e.jsx("div",{className:"secrets-empty",children:s("config:secrets.noSecrets")}):a.map(h=>e.jsxs("div",{className:`secret-item ${r===h.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:h.name}),e.jsx("code",{className:"secret-item-key",onClick:()=>b(h.key),title:s("config:secrets.copyPlaceholder"),children:`{{${h.key}}}`})]}),e.jsxs("div",{className:"secret-item-actions",children:[e.jsx("button",{className:"secret-item-btn edit",onClick:()=>C(h),title:s("common:buttons.edit"),children:e.jsx(L,{name:"edit",size:12})}),e.jsx("button",{className:"secret-item-btn delete",onClick:()=>m(h.id),title:s("common:buttons.delete"),children:"×"})]})]}),h.description&&e.jsx("div",{className:"secret-item-description",children:h.description})]},h.id))}),(t||r)&&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:c.name,onChange:h=>g({...c,name:h.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:c.key,onChange:h=>g({...c,key:h.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"")})}),e.jsx("span",{className:"secret-form-hint",children:s("config:secrets.usedAs",{placeholder:`{{${c.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:c.value,onChange:h=>g({...c,value:h.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:c.description,onChange:h=>g({...c,description:h.target.value})})]}),e.jsxs("div",{className:"secret-form-actions",children:[e.jsx("button",{className:"secret-form-btn cancel",onClick:u,children:s("common:buttons.cancel")}),e.jsx("button",{className:"secret-form-btn save",onClick:p,disabled:!c.name.trim()||!c.key.trim(),children:s(r?"config:secrets.update":"common:buttons.add")})]})]}),!t&&!r&&e.jsx("button",{className:"secrets-add-btn",onClick:w,children:s("config:secrets.addSecret")}),e.jsx(me,{isOpen:n!==null,title:s("common:buttons.delete"),message:s("config:secrets.deleteConfirm"),confirmLabel:s("common:buttons.delete"),cancelLabel:s("common:buttons.cancel"),variant:"danger",onConfirm:j,onClose:()=>x(null)})]})}async function Xs(){const s=Z(),a=await fetch(`${J()}/api/agents/system-settings/prompt`,{headers:{Authorization:`Bearer ${s}`}});if(!a.ok)throw new Error(`Failed to fetch system prompt: ${a.statusText}`);return(await a.json()).prompt||""}async function Qs(s){const a=Z(),t=await fetch(`${J()}/api/agents/system-settings/prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({prompt:s})});if(!t.ok)throw new Error(`Failed to update system prompt: ${t.statusText}`)}async function et(){const s=Z(),a=await fetch(`${J()}/api/agents/system-settings/prompt`,{method:"DELETE",headers:{Authorization:`Bearer ${s}`}});if(!a.ok)throw new Error(`Failed to clear system prompt: ${a.statusText}`)}async function st(){const s=Z(),a=await fetch(`${J()}/api/agents/system-settings/echo-prompt`,{headers:{Authorization:`Bearer ${s}`}});if(!a.ok)throw new Error(`Failed to fetch echo prompt setting: ${a.statusText}`);return(await a.json()).enabled||!1}async function tt(s){const a=Z(),t=await fetch(`${J()}/api/agents/system-settings/echo-prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({enabled:s})});if(!t.ok)throw new Error(`Failed to update echo prompt setting: ${t.statusText}`)}async function at(){const s=Z(),a=await fetch(`${J()}/api/agents/system-settings/codex-binary`,{headers:{Authorization:`Bearer ${s}`}});if(!a.ok)throw new Error(`Failed to fetch codex binary path: ${a.statusText}`);return(await a.json()).path||""}async function nt(s){const a=Z(),t=await fetch(`${J()}/api/agents/system-settings/codex-binary`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({path:s})});if(!t.ok)throw new Error(`Failed to update codex binary path: ${t.statusText}`)}async function it(){const s=Z(),a=await fetch(`${J()}/api/agents/system-settings/tmux-mode`,{headers:{Authorization:`Bearer ${s}`}});if(!a.ok)throw new Error(`Failed to fetch tmux mode setting: ${a.statusText}`);return(await a.json()).enabled||!1}async function ot(s){const a=Z(),t=await fetch(`${J()}/api/agents/system-settings/tmux-mode`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({enabled:s})});if(!t.ok)throw new Error(`Failed to update tmux mode setting: ${t.statusText}`)}async function lt(){const s=Z(),a=await fetch(`${J()}/api/agents/system-settings/backup`,{headers:{Authorization:`Bearer ${s}`}});if(!a.ok)throw new Error(`Failed to fetch backup status: ${a.statusText}`);return a.json()}async function ct(s){const a=Z(),t=await fetch(`${J()}/api/agents/system-settings/backup`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({enabled:s})});if(!t.ok){const o=await t.json().catch(()=>({}));throw new Error(o.error||`Failed to update backup setting: ${t.statusText}`)}return t.json()}function rt({checked:s,onChange:a,disabled:t}){return e.jsxs("label",{className:"config-toggle",children:[e.jsx("input",{type:"checkbox",className:"config-toggle-input",checked:s,disabled:t,onChange:o=>a(o.target.checked)}),e.jsx("span",{className:"config-toggle-track",children:e.jsx("span",{className:"config-toggle-thumb"})})]})}function dt(){const{t:s}=Y(["config","common"]),[a,t]=l.useState([]),[o,r]=l.useState(new Set),[d,c]=l.useState(new Set),[g,n]=l.useState(!1),[x,w]=l.useState(!1),[C,u]=l.useState(null),[p,m]=l.useState(null),[j,b]=l.useState(null),[h,k]=l.useState(null),[$,P]=l.useState(!1),[K,y]=l.useState(null);l.useEffect(()=>{we(he("/api/config/categories")).then(N=>N.json()).then(N=>{const D=Array.isArray(N)?N:[];t(D),r(new Set(D.map(O=>O.id)))}).catch(N=>console.error("Failed to fetch config categories:",N))},[]),l.useEffect(()=>{lt().then(k).catch(N=>{console.error("Failed to fetch backup status:",N),y(N.message||"Failed to fetch backup status")})},[]);const U=async N=>{if(!$){P(!0),y(null);try{const D=await ct(N);k(D)}catch(D){y(D.message||"Failed to update backup setting")}finally{P(!1)}}},B=N=>{r(D=>{const O=new Set(D);return O.has(N)?O.delete(N):O.add(N),O})},V=N=>{c(D=>{const O=new Set(D);return O.has(N)?O.delete(N):O.add(N),O})},S=()=>r(new Set(a.map(N=>N.id))),T=()=>r(new Set),H=()=>{p&&c(new Set(p.categories.map(N=>N.id)))},X=()=>c(new Set),ie=async()=>{var N;if(o.size!==0){n(!0),b(null);try{const D=Array.from(o).join(","),O=await we(he(`/api/config/export?categories=${D}`));if(!O.ok)throw new Error("Export failed");const ee=await O.blob(),se=window.URL.createObjectURL(ee),Q=document.createElement("a");Q.href=se;const A=O.headers.get("Content-Disposition"),q=((N=A==null?void 0:A.match(/filename="(.+)"/))==null?void 0:N[1])||"tide-commander-config.zip";Q.download=q,document.body.appendChild(Q),Q.click(),document.body.removeChild(Q),window.URL.revokeObjectURL(se),b({type:"success",text:s("config:data.exportSuccess")})}catch(D){b({type:"error",text:D.message||"Export failed"})}finally{n(!1)}}},v=async N=>{var O;const D=(O=N.target.files)==null?void 0:O[0];if(D){u(D),b(null),m(null),c(new Set);try{const ee=await we(he("/api/config/preview"),{method:"POST",headers:{"Content-Type":"application/zip"},body:await D.arrayBuffer()});if(!ee.ok){const A=await ee.json();throw new Error(A.error||"Failed to preview config file")}const se=await ee.json(),Q=Array.isArray(se.categories)?se.categories:[];m({...se,categories:Q}),c(new Set(Q.map(A=>A.id)))}catch(ee){b({type:"error",text:ee.message||"Failed to read config file"}),u(null)}}},F=async()=>{if(!(!C||d.size===0)){w(!0),b(null);try{const N=Array.from(d).join(","),D=await we(he(`/api/config/import?categories=${N}`),{method:"POST",headers:{"Content-Type":"application/zip"},body:await C.arrayBuffer()}),O=await D.json();if(!D.ok)throw new Error(O.error||"Import failed");b({type:"success",text:O.message||s("config:data.importSuccess")}),u(null),m(null),c(new Set)}catch(N){b({type:"error",text:N.message||"Import failed"})}finally{w(!1)}}},M=()=>{u(null),m(null),c(new Set),b(null)};return e.jsxs("div",{className:"data-section",children:[j&&e.jsx("div",{className:`data-message data-message-${j.type}`,children:j.text}),e.jsxs("div",{className:"data-subsection",children:[e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-title",children:"Hourly Backups"}),e.jsx(rt,{checked:!!(h!=null&&h.enabled),disabled:$||!h,onChange:U})]}),e.jsxs("div",{className:"data-backup-info",children:[h?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:["Saves a compressed snapshot of your data every hour to"," ",e.jsx("code",{children:h.backupDir}),". Identical snapshots are skipped. Keeps the 8 newest plus one from each of the 2 most recent prior days."]}),!h.scriptExists&&e.jsxs("div",{style:{marginTop:6,color:"var(--dracula-red, #ff5555)"},children:["Backup script not found at ",e.jsx("code",{children:h.scriptPath})]}),h.lastRunAt&&e.jsxs("div",{style:{marginTop:6},children:["Last run: ",new Date(h.lastRunAt).toLocaleString(),h.lastRunOk===!0&&" — ok",h.lastRunOk===!1&&h.lastRunError&&e.jsxs("span",{style:{color:"var(--dracula-red, #ff5555)"},children:[" — ",h.lastRunError]})]})]}):e.jsx("div",{children:"Loading backup status…"}),K&&e.jsx("div",{className:"data-message data-message-error",style:{marginTop:6},children:K})]})]}),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:S,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:T,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:a.map(N=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:o.has(N.id),onChange:()=>B(N.id)}),e.jsx("span",{className:"data-category-name",children:N.name})]},N.id))}),e.jsx("button",{className:"data-action-btn export",onClick:ie,disabled:g||o.size===0,children:g?s("config:data.exporting"):s("config:data.exportCount",{count:o.size})})]}),e.jsxs("div",{className:"data-subsection",children:[e.jsx("div",{className:"data-subsection-header",children:e.jsx("span",{className:"data-subsection-title",children:s("config:data.importData")})}),C?p?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"data-import-info",children:[e.jsx("div",{className:"data-import-file",children:C.name}),e.jsxs("div",{className:"data-import-date",children:[s("config:data.exported"),": ",new Date(p.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:H,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:X,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:p.categories.map(N=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:d.has(N.id),onChange:()=>V(N.id)}),e.jsx("span",{className:"data-category-name",children:N.name}),N.fileCount&&e.jsxs("span",{className:"data-category-count",children:["(",N.fileCount," ",s("config:data.files"),")"]})]},N.id))}),e.jsxs("div",{className:"data-import-actions",children:[e.jsx("button",{className:"data-action-btn cancel",onClick:M,children:s("common:buttons.cancel")}),e.jsx("button",{className:"data-action-btn import",onClick:F,disabled:x||d.size===0,children:x?s("config:data.importing"):s("config:data.importCount",{count:d.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:v,style:{display:"none"}}),e.jsx("span",{className:"data-file-input-label",children:s("config:data.selectFile")})]})]})]})}async function ut(){const s=await we(`${J()}/api/system/install-info`);if(!s.ok)throw new Error(`Failed to fetch install info: ${s.statusText}`);return s.json()}function pt(s,a){const t=new AbortController;return(async()=>{try{const o=await fetch(is(`${J()}/api/system/self-update`),{method:"POST",signal:t.signal,headers:{Accept:"text/event-stream"}});if(!o.ok||!o.body){const g=await o.text().catch(()=>"");let n=null;try{n=JSON.parse(g)}catch{}const x=n&&typeof n=="object"&&"error"in n&&typeof n.error=="string"?n.error:`Self-update failed: ${o.status} ${o.statusText}`;s({type:"error",message:x}),a(new Error(x));return}const r=o.body.getReader(),d=new TextDecoder("utf-8");let c="";for(;;){const{value:g,done:n}=await r.read();if(n)break;c+=d.decode(g,{stream:!0});let x=c.indexOf(`
1
+ import{r as l,aW as Re,aX as Ye,j as e,I as L,u as Y,aY as as,a3 as ns,f as Ve,s as E,aZ as ms,k as is,l as he,a_ as Z,a$ as gs,aP as fs,b0 as xs,C as me,b1 as J,aM as we,b2 as bs,b3 as js,b4 as ws,b5 as ys,b6 as Se,b7 as os,b8 as Ns,b9 as Me,ba as vs,bb as ks,bc as Ss,bd as Cs,be as Ts,bf as As,bg as _s,aI as Es,J as Is,S as ke,bh as Ps,bi as $s,aK as Ls,bj as Ue,K as Ie,aT as Ds,bk as ze,bl as Fs}from"./main-Bon1sZAi.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Ke="deivid11/tide-commander",Os=`https://api.github.com/repos/${Ke}/releases/latest`,Rs=`https://api.github.com/repos/${Ke}/releases?per_page=3`,Us=3600*1e3,Je="app_update_dismissed_version",Ze="1.111.2";function zs(){var w,C;const[s,a]=l.useState({isChecking:!1,updateAvailable:!1,updateInfo:null,recentReleases:[],error:null,currentVersion:Ze}),t=((C=(w=Re)==null?void 0:w.getPlatform)==null?void 0:C.call(w))==="android"||!1,o=u=>u.replace(/^v/,"").split(".").map(m=>parseInt(m,10)||0),r=(u,p)=>{const m=o(u),j=o(p),b=Math.max(m.length,j.length);for(let h=0;h<b;h++){const k=m[h]||0,$=j[h]||0;if(k>$)return 1;if(k<$)return-1}return 0},d=async u=>{var m,j;if(Re&&Ye&&((j=(m=Re).isNativePlatform)==null?void 0:j.call(m))===!0){const b=await Ye.get({url:u,headers:{Accept:"application/vnd.github.v3+json"}});return{data:b.data,status:b.status}}else{const b=await fetch(u,{headers:{Accept:"application/vnd.github.v3+json"}});return b.ok?{data:await b.json(),status:b.status}:{data:null,status:b.status}}},c=l.useCallback(async(u=!1)=>{a(p=>({...p,isChecking:!0,error:null}));try{const[p,m]=await Promise.all([d(Os),d(Rs)]);if(p.status!==200)throw new Error(`GitHub API error: ${p.status}`);const j=p.data,b=j.tag_name;let h=[];m.status===200&&m.data&&(h=m.data.map(y=>({version:y.tag_name,name:y.name,publishedAt:y.published_at,releaseUrl:y.html_url})));const k=localStorage.getItem(Je);if(!u&&k===b)return a(y=>({...y,isChecking:!1,updateAvailable:!1,recentReleases:h})),null;if(!(r(b,Ze)>0))return a(y=>({...y,isChecking:!1,updateAvailable:!1,recentReleases:h})),null;const P=j.assets.find(y=>y.name.endsWith(".apk")&&y.content_type==="application/vnd.android.package-archive"),K={version:b,name:j.name,changelog:j.body,releaseUrl:j.html_url,apkUrl:(P==null?void 0:P.browser_download_url)||null,apkSize:(P==null?void 0:P.size)||null,publishedAt:j.published_at};return a(y=>({...y,isChecking:!1,updateAvailable:!0,updateInfo:K,recentReleases:h})),K}catch(p){const m=p instanceof Error?p.message:"Failed to check for updates";return a(j=>({...j,isChecking:!1,error:m})),null}},[]),g=l.useCallback(async()=>{var u,p,m;if(!((u=s.updateInfo)!=null&&u.apkUrl)){(p=s.updateInfo)!=null&&p.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}if(!t){(m=s.updateInfo)!=null&&m.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}try{window.open(s.updateInfo.apkUrl,"_system"),a(j=>({...j,error:null}))}catch(j){const b=j instanceof Error?j.message:"Failed to open download";a(h=>({...h,error:b}))}},[s.updateInfo,t]),n=l.useCallback(()=>{s.updateInfo&&localStorage.setItem(Je,s.updateInfo.version),a(u=>({...u,updateAvailable:!1,updateInfo:null}))},[s.updateInfo]),x=l.useCallback(()=>{var u;(u=s.updateInfo)!=null&&u.releaseUrl?window.open(s.updateInfo.releaseUrl,"_blank"):window.open(`https://github.com/${Ke}/releases`,"_blank")},[s.updateInfo]);return l.useEffect(()=>{if(!t)return;const u=setTimeout(()=>{c()},5e3),p=setInterval(()=>{c()},Us);return()=>{clearTimeout(u),clearInterval(p)}},[t,c]),{...s,isAndroid:t,checkForUpdate:c,downloadAndInstall:g,dismissUpdate:n,openReleasePage:x}}const ls="tide-toolbox-collapse";function Bs(s,a){try{const t=localStorage.getItem(`${ls}-${s}`);if(t!==null)return t==="true"}catch{}return a}function Ms(s,a){try{localStorage.setItem(`${ls}-${s}`,String(a))}catch{}}function W({title:s,storageKey:a,defaultOpen:t=!1,forceOpen:o=!1,children:r,headerExtra:d}){const[c,g]=l.useState(()=>a?Bs(a,t):t),n=()=>{const w=!c;g(w),a&&Ms(a,w)},x=o||c;return e.jsxs("div",{className:`collapsible-section ${x?"open":"collapsed"}`,children:[e.jsxs("button",{className:"collapsible-header",onClick:n,children:[e.jsx("span",{className:"collapsible-title",children:s}),e.jsxs("span",{className:"collapsible-header-right",children:[d,e.jsx("span",{className:"collapsible-arrow",children:e.jsx(L,{name:x?"caret-down":"caret-right",size:10})})]})]}),x&&e.jsx("div",{className:"collapsible-content",children:r})]})}function Vs({area:s,isSelected:a,onClick:t,onDelete:o}){const{t:r}=Y(["config","common"]),d=s.assignedAgentIds.length,c=s.type==="rectangle"?r("config:areas.rect"):r("config:areas.circle");return e.jsxs("div",{className:`area-item ${a?"selected":""}`,onClick:t,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:[c," ",d>0&&`• ${d} ${d>1?r("common:labels.agents").toLowerCase():r("common:labels.agent").toLowerCase()}`]})]}),e.jsx("button",{className:"area-delete-btn",onClick:o,title:r("config:areas.deleteArea"),children:"×"})]})}function Ks({building:s,isSelected:a,onClick:t,onEdit:o}){var g;const{t:r}=Y(["config"]),d=((g=s.pm2Status)==null?void 0:g.ports)||[],c=(n,x)=>{n.stopPropagation(),window.open(`http://${window.location.hostname}:${x}`,"_blank")};return e.jsxs("div",{className:`building-item ${a?"selected":""}`,onClick:t,children:[e.jsx("div",{className:"building-status-dot",style:{backgroundColor:as[s.status]},title:s.status}),e.jsx("div",{className:"building-icon",children:e.jsx(L,{name:ns(s.type),size:16})}),e.jsxs("div",{className:"building-info",children:[e.jsx("div",{className:"building-name",children:s.name}),e.jsxs("div",{className:"building-meta",children:[s.type,d.length>0&&e.jsx("span",{className:"building-ports",children:d.map(n=>e.jsxs("a",{href:`http://${window.location.hostname}:${n}`,className:"building-port-link",onClick:x=>c(x,n),title:`Open :${n}`,children:[":",n]},n))})]})]}),e.jsx("button",{className:"building-edit-btn",onClick:n=>{n.stopPropagation(),o()},title:r("config:buildings.editBuilding"),children:e.jsx(L,{name:"gear",size:14})})]})}function Hs({building:s,onClose:a,onOpenModal:t}){var x,w,C,u,p,m,j,b;const{t:o}=Y(["config","common"]),{buildingLogs:r}=Ve(),d=E.getBuildingLogs(s.id),c=ms[s.style||"server-rack"],g=h=>{E.sendBuildingCommand(s.id,h)},n=h=>{window.open(h,"_blank")};return e.jsxs("div",{className:"building-editor",children:[e.jsxs("div",{className:"building-editor-header",children:[e.jsxs("div",{className:"building-editor-title-row",children:[e.jsx("span",{className:"building-editor-icon",children:e.jsx(L,{name:ns(s.type),size:18})}),e.jsx("span",{className:"building-editor-title",children:s.name}),e.jsx("span",{className:"building-editor-status",style:{backgroundColor:as[s.status]},children:s.status})]}),e.jsx("button",{className:"building-editor-close",onClick:a,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:c.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:()=>g("start"),disabled:!((x=s.commands)!=null&&x.start)||s.status==="running",title:((w=s.commands)==null?void 0:w.start)||o("config:buildings.noStartCommand"),children:[e.jsx(L,{name:"play",size:12})," ",o("common:buttons.start")]}),e.jsxs("button",{className:"building-editor-action-btn stop",onClick:()=>g("stop"),disabled:!((C=s.commands)!=null&&C.stop)||s.status==="stopped",title:((u=s.commands)==null?void 0:u.stop)||o("config:buildings.noStopCommand"),children:[e.jsx(L,{name:"stop",size:12,weight:"fill"})," ",o("common:buttons.stop")]}),e.jsxs("button",{className:"building-editor-action-btn restart",onClick:()=>g("restart"),disabled:!((p=s.commands)!=null&&p.restart),title:((m=s.commands)==null?void 0:m.restart)||o("config:buildings.noRestartCommand"),children:[e.jsx(L,{name:"refresh",size:12})," ",o("common:buttons.retry")]}),e.jsxs("button",{className:"building-editor-action-btn health",onClick:()=>g("healthCheck"),disabled:!((j=s.commands)!=null&&j.healthCheck),title:((b=s.commands)==null?void 0:b.healthCheck)||o("config:buildings.noHealthCheck"),children:[e.jsx(L,{name:"heart",size:12})," Health"]})]})]}),s.urls&&s.urls.length>0&&e.jsxs("div",{className:"building-editor-section",children:[e.jsx("div",{className:"building-editor-section-title",children:o("config:buildings.links")}),e.jsx("div",{className:"building-editor-links",children:s.urls.map((h,k)=>e.jsxs("button",{className:"building-editor-link",onClick:()=>n(h.url),title:h.url,children:[e.jsx(L,{name:"link",size:12})," ",h.label||h.url]},k))})]}),d.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:()=>E.clearBuildingLogs(s.id),title:o("common:buttons.clear"),children:o("common:buttons.clear")})]}),e.jsx("div",{className:"building-editor-logs",children:d.slice(-5).map((h,k)=>e.jsx("div",{className:"building-editor-log-entry",children:h},k))})]}),e.jsx("div",{className:"building-editor-footer",children:e.jsxs("button",{className:"building-editor-edit-btn",onClick:t,children:[e.jsx(L,{name:"gear",size:12})," ",o("config:buildings.fullSettings")]})})]})}async function Ws(s,a){const t=Z(),o=await fetch(he(`/api/areas/${s}/logo`),{method:"POST",headers:{"Content-Type":a.type||"image/png","X-Filename":encodeURIComponent(a.name),...t?{Authorization:`Bearer ${t}`}:{}},body:a});if(!o.ok){const r=await o.json().catch(()=>({error:o.statusText}));throw new Error(r.error||`Upload failed: ${o.statusText}`)}return o.json()}async function qs(s){const a=Z(),t=await fetch(he(`/api/areas/${s}/logo`),{method:"DELETE",headers:{...a?{Authorization:`Bearer ${a}`}:{}}});if(!t.ok)throw new Error(`Failed to delete logo: ${t.statusText}`)}function Gs(s){return is(he(`/api/areas/logos/${s}`))}const Ys=[{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 Js({area:s,onClose:a,onOpenFolder:t}){var ie;const{t:o}=Y(["config","common"]),[r,d]=l.useState(s.name),[c,g]=l.useState(s.prompt||""),[n,x]=l.useState(!1),[w,C]=l.useState(""),[u,p]=l.useState(!1),m=l.useRef(null);l.useEffect(()=>{d(s.name)},[s.id,s.name]),l.useEffect(()=>{g(s.prompt||"")},[s.id,s.prompt]);const j=v=>{const F=v.target.value;d(F),E.updateArea(s.id,{name:F})},b=v=>{E.updateArea(s.id,{color:v})},h=v=>{const F=v.target.value;g(F),E.updateArea(s.id,{prompt:F})},k=()=>{w.trim()&&(E.addDirectoryToArea(s.id,w.trim()),C(""),x(!1))},$=(v,F)=>{F.stopPropagation(),E.removeDirectoryFromArea(s.id,v)},P=()=>{E.bringAreaToFront(s.id)},K=()=>{E.sendAreaToBack(s.id)},y=l.useCallback(()=>{let v=2,F=2;s.type==="rectangle"&&s.width&&s.height?(v=s.width,F=s.height):s.type==="circle"&&s.radius&&(v=s.radius*1.414,F=s.radius*1.414);const M=Math.min(v,F)*.4;return{width:Math.round(M*10)/10,height:Math.round(M*10)/10}},[s.type,s.width,s.height,s.radius]),U=async v=>{var M;const F=(M=v.target.files)==null?void 0:M[0];if(F){p(!0);try{const N=await Ws(s.id,F),D=y();E.updateArea(s.id,{logo:{filename:N.filename,position:"center",width:D.width,height:D.height,keepAspectRatio:!0,opacity:.8}})}catch(N){console.error("Failed to upload logo:",N)}finally{p(!1),m.current&&(m.current.value="")}}},B=async()=>{try{await qs(s.id),E.updateArea(s.id,{logo:void 0})}catch(v){console.error("Failed to remove logo:",v)}},V=v=>{s.logo&&E.updateArea(s.id,{logo:{...s.logo,position:v}})},S=v=>{if(!s.logo)return;const F=parseFloat(v.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.width>0){const M=s.logo.height/s.logo.width;E.updateArea(s.id,{logo:{...s.logo,width:F,height:Math.round(F*M*10)/10}})}else E.updateArea(s.id,{logo:{...s.logo,width:F}})},T=v=>{if(!s.logo)return;const F=parseFloat(v.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.height>0){const M=s.logo.width/s.logo.height;E.updateArea(s.id,{logo:{...s.logo,height:F,width:Math.round(F*M*10)/10}})}else E.updateArea(s.id,{logo:{...s.logo,height:F}})},H=()=>{s.logo&&E.updateArea(s.id,{logo:{...s.logo,keepAspectRatio:!s.logo.keepAspectRatio}})},X=v=>{s.logo&&E.updateArea(s.id,{logo:{...s.logo,opacity:parseFloat(v.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:a,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:r,onChange:j,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:gs.map(v=>e.jsx("button",{type:"button",className:`color-swatch ${s.color===v?"selected":""}`,style:{backgroundColor:v},onClick:()=>b(v),"aria-label":`Set area color ${v}`,"aria-pressed":s.color===v,title:v},v))})]}),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:P,title:o("config:areas.bringToFront"),children:[e.jsx(L,{name:"arrow-up",size:12})," ",o("config:areas.front")]}),e.jsxs("button",{className:"area-layer-btn",onClick:K,title:o("config:areas.sendToBack"),children:[e.jsx(L,{name:"arrow-down",size:12})," ",o("config:areas.back")]})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.logo")}),e.jsxs("div",{className:"area-logo-section",children:[(ie=s.logo)!=null&&ie.filename?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"area-logo-preview",children:[e.jsx("img",{src:Gs(s.logo.filename),alt:"Logo",className:"area-logo-thumbnail"}),e.jsx("button",{className:"area-logo-remove-btn",onClick:B,children:o("config:areas.removeLogo")}),e.jsx("button",{className:"area-logo-replace-btn",onClick:()=>{var v;return(v=m.current)==null?void 0:v.click()},disabled:u,children:u?"...":e.jsx(L,{name:"refresh",size:12})})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoPosition")}),e.jsx("div",{className:"area-logo-position-row",children:Ys.map(({key:v,labelKey:F})=>{var M;return e.jsx("button",{className:`area-logo-pos-btn ${((M=s.logo)==null?void 0:M.position)===v?"active":""}`,onClick:()=>V(v),children:o(`config:areas.${F}`)},v)})})]}),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:S,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:T,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:H}),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:X,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 v;return(v=m.current)==null?void 0:v.click()},disabled:u,children:u?"...":o("config:areas.uploadLogo")}),e.jsx("input",{ref:m,type:"file",accept:"image/*",style:{display:"none"},onChange:U})]})]}),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(v=>e.jsxs("div",{className:"area-folder-item",title:v,children:[e.jsx("span",{className:"area-folder-icon clickable",onClick:()=>t==null?void 0:t(s.id),title:o("config:areas.openFolder"),children:e.jsx(L,{name:"folder",size:14})}),e.jsx("span",{className:"area-folder-path",children:v.split("/").pop()||v}),e.jsx("button",{className:"area-folder-remove",onClick:F=>$(v,F),title:o("config:areas.removeFolder"),children:"×"})]},v)),n?e.jsxs("div",{className:"area-add-folder-inline",children:[e.jsx(fs,{value:w,onChange:C,onSubmit:k,placeholder:o("config:areas.folderPlaceholder"),className:"area-add-folder-input",directoriesOnly:!0,autoFocus:!0}),e.jsx("button",{className:"area-add-folder-confirm",onClick:k,children:"+"})]}):e.jsx("button",{className:"area-add-folder-btn",onClick:()=>x(!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:c,onChange:h,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 Zs(){const{t:s}=Y(["config","common"]),a=xs(),[t,o]=l.useState(!1),[r,d]=l.useState(null),[c,g]=l.useState({name:"",key:"",value:"",description:""}),[n,x]=l.useState(null),w=()=>{o(!0),d(null),g({name:"",key:"",value:"",description:""})},C=h=>{d(h.id),o(!1),g({name:h.name,key:h.key,value:h.value,description:h.description||""})},u=()=>{o(!1),d(null),g({name:"",key:"",value:"",description:""})},p=()=>{!c.name.trim()||!c.key.trim()||(r?E.updateSecret(r,{name:c.name.trim(),key:c.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:c.value,description:c.description.trim()||void 0}):E.createSecret({name:c.name.trim(),key:c.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:c.value,description:c.description.trim()||void 0}),u())},m=h=>{x(h)},j=()=>{n&&(E.deleteSecret(n),r===n&&u())},b=h=>{navigator.clipboard.writeText(`{{${h}}}`)};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:a.length===0&&!t?e.jsx("div",{className:"secrets-empty",children:s("config:secrets.noSecrets")}):a.map(h=>e.jsxs("div",{className:`secret-item ${r===h.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:h.name}),e.jsx("code",{className:"secret-item-key",onClick:()=>b(h.key),title:s("config:secrets.copyPlaceholder"),children:`{{${h.key}}}`})]}),e.jsxs("div",{className:"secret-item-actions",children:[e.jsx("button",{className:"secret-item-btn edit",onClick:()=>C(h),title:s("common:buttons.edit"),children:e.jsx(L,{name:"edit",size:12})}),e.jsx("button",{className:"secret-item-btn delete",onClick:()=>m(h.id),title:s("common:buttons.delete"),children:"×"})]})]}),h.description&&e.jsx("div",{className:"secret-item-description",children:h.description})]},h.id))}),(t||r)&&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:c.name,onChange:h=>g({...c,name:h.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:c.key,onChange:h=>g({...c,key:h.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"")})}),e.jsx("span",{className:"secret-form-hint",children:s("config:secrets.usedAs",{placeholder:`{{${c.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:c.value,onChange:h=>g({...c,value:h.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:c.description,onChange:h=>g({...c,description:h.target.value})})]}),e.jsxs("div",{className:"secret-form-actions",children:[e.jsx("button",{className:"secret-form-btn cancel",onClick:u,children:s("common:buttons.cancel")}),e.jsx("button",{className:"secret-form-btn save",onClick:p,disabled:!c.name.trim()||!c.key.trim(),children:s(r?"config:secrets.update":"common:buttons.add")})]})]}),!t&&!r&&e.jsx("button",{className:"secrets-add-btn",onClick:w,children:s("config:secrets.addSecret")}),e.jsx(me,{isOpen:n!==null,title:s("common:buttons.delete"),message:s("config:secrets.deleteConfirm"),confirmLabel:s("common:buttons.delete"),cancelLabel:s("common:buttons.cancel"),variant:"danger",onConfirm:j,onClose:()=>x(null)})]})}async function Xs(){const s=Z(),a=await fetch(`${J()}/api/agents/system-settings/prompt`,{headers:{Authorization:`Bearer ${s}`}});if(!a.ok)throw new Error(`Failed to fetch system prompt: ${a.statusText}`);return(await a.json()).prompt||""}async function Qs(s){const a=Z(),t=await fetch(`${J()}/api/agents/system-settings/prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({prompt:s})});if(!t.ok)throw new Error(`Failed to update system prompt: ${t.statusText}`)}async function et(){const s=Z(),a=await fetch(`${J()}/api/agents/system-settings/prompt`,{method:"DELETE",headers:{Authorization:`Bearer ${s}`}});if(!a.ok)throw new Error(`Failed to clear system prompt: ${a.statusText}`)}async function st(){const s=Z(),a=await fetch(`${J()}/api/agents/system-settings/echo-prompt`,{headers:{Authorization:`Bearer ${s}`}});if(!a.ok)throw new Error(`Failed to fetch echo prompt setting: ${a.statusText}`);return(await a.json()).enabled||!1}async function tt(s){const a=Z(),t=await fetch(`${J()}/api/agents/system-settings/echo-prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({enabled:s})});if(!t.ok)throw new Error(`Failed to update echo prompt setting: ${t.statusText}`)}async function at(){const s=Z(),a=await fetch(`${J()}/api/agents/system-settings/codex-binary`,{headers:{Authorization:`Bearer ${s}`}});if(!a.ok)throw new Error(`Failed to fetch codex binary path: ${a.statusText}`);return(await a.json()).path||""}async function nt(s){const a=Z(),t=await fetch(`${J()}/api/agents/system-settings/codex-binary`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({path:s})});if(!t.ok)throw new Error(`Failed to update codex binary path: ${t.statusText}`)}async function it(){const s=Z(),a=await fetch(`${J()}/api/agents/system-settings/tmux-mode`,{headers:{Authorization:`Bearer ${s}`}});if(!a.ok)throw new Error(`Failed to fetch tmux mode setting: ${a.statusText}`);return(await a.json()).enabled||!1}async function ot(s){const a=Z(),t=await fetch(`${J()}/api/agents/system-settings/tmux-mode`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({enabled:s})});if(!t.ok)throw new Error(`Failed to update tmux mode setting: ${t.statusText}`)}async function lt(){const s=Z(),a=await fetch(`${J()}/api/agents/system-settings/backup`,{headers:{Authorization:`Bearer ${s}`}});if(!a.ok)throw new Error(`Failed to fetch backup status: ${a.statusText}`);return a.json()}async function ct(s){const a=Z(),t=await fetch(`${J()}/api/agents/system-settings/backup`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({enabled:s})});if(!t.ok){const o=await t.json().catch(()=>({}));throw new Error(o.error||`Failed to update backup setting: ${t.statusText}`)}return t.json()}function rt({checked:s,onChange:a,disabled:t}){return e.jsxs("label",{className:"config-toggle",children:[e.jsx("input",{type:"checkbox",className:"config-toggle-input",checked:s,disabled:t,onChange:o=>a(o.target.checked)}),e.jsx("span",{className:"config-toggle-track",children:e.jsx("span",{className:"config-toggle-thumb"})})]})}function dt(){const{t:s}=Y(["config","common"]),[a,t]=l.useState([]),[o,r]=l.useState(new Set),[d,c]=l.useState(new Set),[g,n]=l.useState(!1),[x,w]=l.useState(!1),[C,u]=l.useState(null),[p,m]=l.useState(null),[j,b]=l.useState(null),[h,k]=l.useState(null),[$,P]=l.useState(!1),[K,y]=l.useState(null);l.useEffect(()=>{we(he("/api/config/categories")).then(N=>N.json()).then(N=>{const D=Array.isArray(N)?N:[];t(D),r(new Set(D.map(O=>O.id)))}).catch(N=>console.error("Failed to fetch config categories:",N))},[]),l.useEffect(()=>{lt().then(k).catch(N=>{console.error("Failed to fetch backup status:",N),y(N.message||"Failed to fetch backup status")})},[]);const U=async N=>{if(!$){P(!0),y(null);try{const D=await ct(N);k(D)}catch(D){y(D.message||"Failed to update backup setting")}finally{P(!1)}}},B=N=>{r(D=>{const O=new Set(D);return O.has(N)?O.delete(N):O.add(N),O})},V=N=>{c(D=>{const O=new Set(D);return O.has(N)?O.delete(N):O.add(N),O})},S=()=>r(new Set(a.map(N=>N.id))),T=()=>r(new Set),H=()=>{p&&c(new Set(p.categories.map(N=>N.id)))},X=()=>c(new Set),ie=async()=>{var N;if(o.size!==0){n(!0),b(null);try{const D=Array.from(o).join(","),O=await we(he(`/api/config/export?categories=${D}`));if(!O.ok)throw new Error("Export failed");const ee=await O.blob(),se=window.URL.createObjectURL(ee),Q=document.createElement("a");Q.href=se;const A=O.headers.get("Content-Disposition"),q=((N=A==null?void 0:A.match(/filename="(.+)"/))==null?void 0:N[1])||"tide-commander-config.zip";Q.download=q,document.body.appendChild(Q),Q.click(),document.body.removeChild(Q),window.URL.revokeObjectURL(se),b({type:"success",text:s("config:data.exportSuccess")})}catch(D){b({type:"error",text:D.message||"Export failed"})}finally{n(!1)}}},v=async N=>{var O;const D=(O=N.target.files)==null?void 0:O[0];if(D){u(D),b(null),m(null),c(new Set);try{const ee=await we(he("/api/config/preview"),{method:"POST",headers:{"Content-Type":"application/zip"},body:await D.arrayBuffer()});if(!ee.ok){const A=await ee.json();throw new Error(A.error||"Failed to preview config file")}const se=await ee.json(),Q=Array.isArray(se.categories)?se.categories:[];m({...se,categories:Q}),c(new Set(Q.map(A=>A.id)))}catch(ee){b({type:"error",text:ee.message||"Failed to read config file"}),u(null)}}},F=async()=>{if(!(!C||d.size===0)){w(!0),b(null);try{const N=Array.from(d).join(","),D=await we(he(`/api/config/import?categories=${N}`),{method:"POST",headers:{"Content-Type":"application/zip"},body:await C.arrayBuffer()}),O=await D.json();if(!D.ok)throw new Error(O.error||"Import failed");b({type:"success",text:O.message||s("config:data.importSuccess")}),u(null),m(null),c(new Set)}catch(N){b({type:"error",text:N.message||"Import failed"})}finally{w(!1)}}},M=()=>{u(null),m(null),c(new Set),b(null)};return e.jsxs("div",{className:"data-section",children:[j&&e.jsx("div",{className:`data-message data-message-${j.type}`,children:j.text}),e.jsxs("div",{className:"data-subsection",children:[e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-title",children:"Hourly Backups"}),e.jsx(rt,{checked:!!(h!=null&&h.enabled),disabled:$||!h,onChange:U})]}),e.jsxs("div",{className:"data-backup-info",children:[h?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:["Saves a compressed snapshot of your data every hour to"," ",e.jsx("code",{children:h.backupDir}),". Identical snapshots are skipped. Keeps the 8 newest plus one from each of the 2 most recent prior days."]}),!h.scriptExists&&e.jsxs("div",{style:{marginTop:6,color:"var(--dracula-red, #ff5555)"},children:["Backup script not found at ",e.jsx("code",{children:h.scriptPath})]}),h.lastRunAt&&e.jsxs("div",{style:{marginTop:6},children:["Last run: ",new Date(h.lastRunAt).toLocaleString(),h.lastRunOk===!0&&" — ok",h.lastRunOk===!1&&h.lastRunError&&e.jsxs("span",{style:{color:"var(--dracula-red, #ff5555)"},children:[" — ",h.lastRunError]})]})]}):e.jsx("div",{children:"Loading backup status…"}),K&&e.jsx("div",{className:"data-message data-message-error",style:{marginTop:6},children:K})]})]}),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:S,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:T,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:a.map(N=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:o.has(N.id),onChange:()=>B(N.id)}),e.jsx("span",{className:"data-category-name",children:N.name})]},N.id))}),e.jsx("button",{className:"data-action-btn export",onClick:ie,disabled:g||o.size===0,children:g?s("config:data.exporting"):s("config:data.exportCount",{count:o.size})})]}),e.jsxs("div",{className:"data-subsection",children:[e.jsx("div",{className:"data-subsection-header",children:e.jsx("span",{className:"data-subsection-title",children:s("config:data.importData")})}),C?p?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"data-import-info",children:[e.jsx("div",{className:"data-import-file",children:C.name}),e.jsxs("div",{className:"data-import-date",children:[s("config:data.exported"),": ",new Date(p.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:H,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:X,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:p.categories.map(N=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:d.has(N.id),onChange:()=>V(N.id)}),e.jsx("span",{className:"data-category-name",children:N.name}),N.fileCount&&e.jsxs("span",{className:"data-category-count",children:["(",N.fileCount," ",s("config:data.files"),")"]})]},N.id))}),e.jsxs("div",{className:"data-import-actions",children:[e.jsx("button",{className:"data-action-btn cancel",onClick:M,children:s("common:buttons.cancel")}),e.jsx("button",{className:"data-action-btn import",onClick:F,disabled:x||d.size===0,children:x?s("config:data.importing"):s("config:data.importCount",{count:d.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:v,style:{display:"none"}}),e.jsx("span",{className:"data-file-input-label",children:s("config:data.selectFile")})]})]})]})}async function ut(){const s=await we(`${J()}/api/system/install-info`);if(!s.ok)throw new Error(`Failed to fetch install info: ${s.statusText}`);return s.json()}function pt(s,a){const t=new AbortController;return(async()=>{try{const o=await fetch(is(`${J()}/api/system/self-update`),{method:"POST",signal:t.signal,headers:{Accept:"text/event-stream"}});if(!o.ok||!o.body){const g=await o.text().catch(()=>"");let n=null;try{n=JSON.parse(g)}catch{}const x=n&&typeof n=="object"&&"error"in n&&typeof n.error=="string"?n.error:`Self-update failed: ${o.status} ${o.statusText}`;s({type:"error",message:x}),a(new Error(x));return}const r=o.body.getReader(),d=new TextDecoder("utf-8");let c="";for(;;){const{value:g,done:n}=await r.read();if(n)break;c+=d.decode(g,{stream:!0});let x=c.indexOf(`
2
2
 
3
3
  `);for(;x!==-1;){const w=c.slice(0,x);c=c.slice(x+2);const C=w.split(`
4
4
  `);let u="message",p="";for(const m of C)m.startsWith(":")||(m.startsWith("event:")?u=m.slice(6).trim():m.startsWith("data:")&&(p+=(p?`
@@ -1,4 +1,4 @@
1
- import{bq as Oe,r as t,s as I,l as ye,br as Ee,aM as _e,j as e,I as z,u as fe,bs as ze,bt as Te,bu as Ue,bv as Be,m as Ke,bw as We,bx as De,by as Ve,a7 as qe,a8 as Ge,a9 as Je,aV as Ye,J as Me,S as ce,aP as Xe,aL as Qe,_ as Ze,K as Ie,ak as et,U as tt,bz as st,n as X,bA as nt}from"./main-Cq5TB_d6.js";import{FileExplorerPanel as at}from"./index-XGwd-4sy.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Ne={status:"all",activity:"all",sort:"activity"},lt={"1h":3600*1e3,"6h":360*60*1e3,"24h":1440*60*1e3},Ae=20,me=3,ct={idle:"#4aff9e",working:"#4a9eff",waiting:"#ff9e4a",waiting_permission:"#ffcc00",error:"#ff4a4a",offline:"#888888",orphaned:"#ff9e4a"},ot=12e4;function rt(s){return s.trim().replace(/\r\n/g,`
1
+ import{bq as Oe,r as t,s as I,l as ye,br as Ee,aM as _e,j as e,I as z,u as fe,bs as ze,bt as Te,bu as Ue,bv as Be,m as Ke,bw as We,bx as De,by as Ve,a7 as qe,a8 as Ge,a9 as Je,aV as Ye,J as Me,S as ce,aP as Xe,aL as Qe,_ as Ze,K as Ie,ak as et,U as tt,bz as st,n as X,bA as nt}from"./main-Bon1sZAi.js";import{FileExplorerPanel as at}from"./index--3sQ1gHE.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Ne={status:"all",activity:"all",sort:"activity"},lt={"1h":3600*1e3,"6h":360*60*1e3,"24h":1440*60*1e3},Ae=20,me=3,ct={idle:"#4aff9e",working:"#4a9eff",waiting:"#ff9e4a",waiting_permission:"#ffcc00",error:"#ff4a4a",offline:"#888888",orphaned:"#ff9e4a"},ot=12e4;function rt(s){return s.trim().replace(/\r\n/g,`
2
2
  `)}function $e(s,a){return`${s}:${rt(a)}`}function it(s,a,l,f){if(s.uuid&&a.has(s.uuid))return!1;if(s.uuid)return!0;const p=s.isUserPrompt?"user":"assistant",d=$e(p,s.text),M=s.timestamp||0,A=l.get(d);return A!==void 0&&Math.abs(M-A)<=ot?!1:M>f}function dt({isOpen:s,agents:a}){const l=Oe(),[f,p]=t.useState(new Map),d=t.useRef(new Set);t.useRef(a);const M=t.useMemo(()=>Array.from(a.keys()).sort().join(","),[a]),A=t.useMemo(()=>Array.from(a.values()).map(j=>`${j.id}:${j.sessionId||""}`).sort().join(","),[a]);t.useEffect(()=>{s||(d.current.clear(),p(new Map))},[s]),t.useEffect(()=>{if(!s)return;const j=new Set(Array.from(a.keys()));for(const i of d.current)j.has(i)||d.current.delete(i);let h=null;l>0&&(h=I.preserveOutputs(),d.current.clear());const v=async(i,C,F=0)=>{if(d.current.add(i.id),F>0&&await new Promise(x=>setTimeout(x,F)),p(x=>{const k=new Map(x);return k.set(i.id,{agentId:i.id,messages:[],loading:!0,hasMore:!1,totalCount:0}),k}),!i.sessionId){C&&C.length>0&&I.mergeOutputsWithHistory(i.id,[],C),p(x=>{const k=new Map(x);return k.set(i.id,{agentId:i.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),k});return}try{const k=await(await _e(ye(`/api/agents/${i.id}/history?limit=${Ee}&offset=0`))).json(),P=k.messages||[],W=P.length>0?Math.max(...P.map(w=>w.timestamp?new Date(w.timestamp).getTime():0)):0,J=new Set(P.map(w=>w.uuid).filter(w=>!!w)),V=new Map;for(const w of P){if(w.type!=="user"&&w.type!=="assistant")continue;const o=$e(w.type,w.content),L=w.timestamp?new Date(w.timestamp).getTime():0,K=V.get(o)??0;L>K&&V.set(o,L)}const q=I.getOutputs(i.id),B=(C&&C.length>0?[...C,...q]:q).filter(w=>it(w,J,V,W));I.clearOutputs(i.id);for(const w of B)I.addOutput(i.id,w);p(w=>{const o=new Map(w);return o.set(i.id,{agentId:i.id,messages:P,loading:!1,hasMore:k.hasMore||!1,totalCount:k.totalCount||0}),o})}catch(x){if(console.error(`Failed to load history for ${i.name}:`,x),C&&C.length>0){I.clearOutputs(i.id);for(const k of C)I.addOutput(i.id,k)}p(k=>{const P=new Map(k);return P.set(i.id,{agentId:i.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),P})}},u=l>0?500:0,D=Array.from(a.values());for(const i of D)if(!d.current.has(i.id)){const C=h==null?void 0:h.get(i.id);v(i,C,u)}},[s,M,A,l]);const R=t.useRef(a),N=t.useRef(f);R.current=a,N.current=f;const b=t.useCallback(async j=>{const h=R.current.get(j),v=N.current.get(j);if(!(h!=null&&h.sessionId)||!v||!v.hasMore)return;const u=v.messages.length;try{const i=await(await fetch(ye(`/api/agents/${j}/history?limit=${Ee}&offset=${u}`))).json();i.messages&&i.messages.length>0&&p(C=>{const F=new Map(C),x=C.get(j);return x&&F.set(j,{...x,messages:[...i.messages,...x.messages],hasMore:i.hasMore||!1}),F})}catch(D){console.error(`Failed to load more history for agent ${j}:`,D)}},[]),E=t.useCallback(j=>{d.current.delete(j),p(h=>{const v=new Map(h),u=h.get(j);return u&&v.set(j,{...u,messages:[],hasMore:!1,totalCount:0,loading:!1}),v})},[]);return{histories:f,loadMoreHistory:b,clearAgentHistory:E}}function ut({command:s,onCommandChange:a,useTextarea:l,forceTextarea:f,onForceTextarea:p,onSend:d,canSend:M,attachedFiles:A,onAddFile:R,onRemoveFile:N,uploadFile:b,onAddPastedText:E,placeholder:j="Message...",className:h="",compact:v=!1,inputRef:u}){const D=t.useRef(null),i=t.useRef(null),C=t.useRef(l);t.useEffect(()=>{if(l&&!C.current&&i.current){const o=i.current;o.focus(),o.selectionStart=o.selectionEnd=o.value.length}C.current=l},[l]),t.useEffect(()=>{const o=i.current;if(!o||!l)return;o.style.height="auto";const L=v?120:180,K=Math.min(o.scrollHeight,L);o.style.height=`${K}px`},[s,l,v]);const F=t.useCallback(async o=>{const L=o.clipboardData.items;for(const _ of L)if(_.type.startsWith("image/")){o.preventDefault();const $=_.getAsFile();if($){const H=await b($);H&&R(H)}return}const K=o.clipboardData.files;if(K.length>0){o.preventDefault();for(const _ of K){const $=await b(_);$&&R($)}return}const U=o.clipboardData.getData("text"),te=(U.match(/\n/g)||[]).length+1;if(te>5){o.preventDefault();const $=`[Pasted text #${E(U)} +${te} lines]`,H=o.target,se=H.selectionStart||0,ae=H.selectionEnd||0,ne=s.slice(0,se)+$+s.slice(ae);a(ne),l||p(!0)}},[s,a,l,p,b,R,E]),x=t.useCallback(async o=>{const L=o.target.files;if(L){for(const K of L){const U=await b(K);U&&R(U)}D.current&&(D.current.value="")}},[b,R]),k=t.useCallback(o=>{if(o.key==="Enter"&&o.shiftKey){l||(o.preventDefault(),p(!0));return}o.key==="Enter"&&(o.preventDefault(),d())},[l,p,d]),P=t.useCallback(o=>{},[]),W=t.useCallback(o=>{o.button===1&&(o.preventDefault(),o.stopPropagation())},[]),J=t.useCallback(o=>{i.current=o,u==null||u(o)},[u]),V=v?"agent-panel-input":"guake-input",q=v?"agent-panel-input-container":"guake-input-container",Q=v?"agent-panel-attach-btn":"guake-attach-btn",B=v?"agent-panel-send-btn":"",w=l?v?"agent-panel-input-expanded":"guake-input-expanded":"";return e.jsxs(e.Fragment,{children:[A.length>0&&e.jsx("div",{className:v?"agent-panel-attachments":"guake-attachments",children:A.map(o=>e.jsxs("div",{className:`${v?"agent-panel-attachment":"guake-attachment"} ${o.isImage?"is-image":""}`,children:[e.jsx("span",{className:v?"agent-panel-attachment-icon":"guake-attachment-icon",children:e.jsx(z,{name:o.isImage?"file":"paperclip",size:12})}),e.jsx("span",{className:v?"agent-panel-attachment-name":"guake-attachment-name",title:o.path,children:o.name}),!v&&e.jsxs("span",{className:"guake-attachment-size",children:["(",Math.round(o.size/1024),"KB)"]}),e.jsx("button",{className:v?"agent-panel-attachment-remove":"guake-attachment-remove",onClick:()=>N(o.id),title:"Remove",children:"×"})]},o.id))}),e.jsxs("div",{className:`${V} ${w} ${h}`,children:[e.jsx("input",{ref:D,type:"file",multiple:!0,onChange:x,style:{display:"none"},accept:"*"}),e.jsxs("div",{className:q,onAuxClick:W,children:[e.jsx("button",{className:Q,onClick:()=>{var o;return(o=D.current)==null?void 0:o.click()},title:"Attach file (or paste image)",children:e.jsx(z,{name:"paperclip",size:14})}),l?e.jsx("textarea",{ref:J,placeholder:j,value:s,onChange:o=>a(o.target.value),onKeyDown:k,onPaste:F,onMouseDown:P}):e.jsx("input",{ref:u,type:"text",placeholder:j,value:s,onChange:o=>a(o.target.value),onKeyDown:k,onPaste:F,onMouseDown:P}),e.jsx("button",{className:B,onClick:d,disabled:!M,title:"Send",children:e.jsx(z,{name:"send",size:14})})]})]})]})}function mt(s){const a=Math.floor(s/1e3),l=Math.floor(a/60),f=a%60;return`${l}:${f.toString().padStart(2,"0")}`}const ft=t.memo(function({agentId:a,isWorking:l,timestamp:f}){const{t:p}=fe(["terminal"]),[d,M]=t.useState(0);return t.useEffect(()=>{if(!l||!f){M(0);return}M(Date.now()-f);const A=setInterval(()=>{M(Date.now()-f)},1e3);return()=>clearInterval(A)},[l,f]),l?e.jsxs("div",{className:"guake-stop-bar",children:[e.jsx("span",{className:"guake-elapsed-timer",children:mt(d)}),e.jsxs("button",{className:"guake-stop-btn",onClick:()=>I.stopAgent(a),title:p("terminal:input.stopOperation"),children:[e.jsx("span",{className:"stop-icon",children:e.jsx(z,{name:"stop",size:12,weight:"fill"})}),e.jsx("span",{className:"stop-label",children:p("terminal:input.stop")})]})]}):null});function pt({agent:s,history:a,outputs:l,isExpanded:f,isFocused:p,advancedView:d,onExpand:M,onFocus:A,inputRef:R,onLoadMore:N,onClearHistory:b}){const{t:E}=fe(["terminal","common"]),j=ze(s.id),h=t.useRef(null),[v,u]=t.useState(!1),D=t.useRef(0),i=t.useRef(!1),[C,F]=t.useState(!0),[x,k]=t.useState(!1),[P,W]=t.useState(null),[J,V]=t.useState(null),[q,Q]=t.useState(null);Te(`commander-image-modal-${s.id}`,P!==null,()=>W(null));const{command:B,setCommand:w,forceTextarea:o,setForceTextarea:L,useTextarea:K,setPastedTexts:U,incrementPastedCount:te,resetPastedCount:_,attachedFiles:$,setAttachedFiles:H,removeAttachedFile:se,uploadFile:ae,expandPastedTexts:ne}=Ue({selectedAgentId:s.id}),le=B.trim().length>0||$.length>0,n=Be({outputs:l,viewMode:d?"advanced":"simple"}),c=t.useMemo(()=>{const S=Ke(s);return{usedPercent:S.usedPercent,freePercent:S.freePercent,hasData:!!s.contextStats,totalTokens:S.totalTokens,contextWindow:S.contextWindow}},[s.contextStats,s.contextUsed,s.contextLimit]),g=t.useCallback(()=>{!v&&(a!=null&&a.hasMore)&&N&&(u(!0),D.current=h.current?h.current.scrollHeight-h.current.scrollTop:0,N())},[v,a==null?void 0:a.hasMore,N]);t.useEffect(()=>{v&&a&&!a.loading&&u(!1)},[a,v]);const m=t.useCallback(()=>{i.current=!0,F(!1)},[]),T=t.useRef(f),Z=t.useRef(p);t.useEffect(()=>{(f&&!T.current||p&&!Z.current)&&(i.current=!1,F(!0),k(!0)),T.current=f,Z.current=p},[f,p]);const ee=t.useRef(a==null?void 0:a.loading);t.useEffect(()=>{ee.current&&!(a!=null&&a.loading)&&(i.current=!1,F(!0),k(!0)),ee.current=a==null?void 0:a.loading},[a==null?void 0:a.loading]),t.useEffect(()=>{if(!x)return;const S=h.current;if(!S)return;const y=performance.now();let O=0,ue=-1,ke;const Re=()=>{const{scrollTop:Fe,scrollHeight:Se,clientHeight:Le}=S,He=Se-Fe-Le<=2;if(Math.abs(Se-ue)<=1&&He?O+=1:O=0,ue=Se,O>=3){k(!1);return}if(performance.now()-y>5e3){k(!1);return}ke=requestAnimationFrame(Re)};return ke=requestAnimationFrame(Re),()=>cancelAnimationFrame(ke)},[x]),t.useEffect(()=>{i.current||F(!0)},[n.length]);const G=t.useCallback(()=>!1,[]),ie=t.useCallback(S=>{const y=te();return U(O=>new Map(O).set(y,S)),y},[te,U]),he=t.useCallback(S=>{H(y=>[...y,S])},[H]),xe=t.useCallback(()=>{if(!le)return;if(B.trim()==="/clear"&&$.length===0){I.clearContext(s.id),b(),w(""),L(!1),U(new Map),H([]),_();return}let S=ne(B.trim());if($.length>0){const y=$.map(O=>O.isImage?`[Image: ${O.path}]`:`[File: ${O.path}]`).join(`
3
3
  `);S=S?`${S}
4
4