tide-commander 1.40.2 → 1.40.4

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 (58) hide show
  1. package/dist/assets/{BossLogsModal-CaDrNfm1.js → BossLogsModal-CehuxNwV.js} +1 -1
  2. package/dist/assets/{BossSpawnModal-DLJInoVf.js → BossSpawnModal-Cohl0WaH.js} +1 -1
  3. package/dist/assets/{ControlsModal-Cnnhwfr_.js → ControlsModal-CAVkg9mM.js} +1 -1
  4. package/dist/assets/{DockerLogsModal-D4CbWK3-.js → DockerLogsModal-BXv9Hzg-.js} +1 -1
  5. package/dist/assets/{EmbeddedEditor-36YBGNE2.js → EmbeddedEditor-CTlTVKdD.js} +1 -1
  6. package/dist/assets/{GmailOAuthSetup-DI5j7wkF.js → GmailOAuthSetup-B1zQWbRR.js} +1 -1
  7. package/dist/assets/{GoogleOAuthSetup-Bsj02mND.js → GoogleOAuthSetup-CmayoZ-D.js} +1 -1
  8. package/dist/assets/{IframeModal-BJ4oeDBn.js → IframeModal-DlS7y7PK.js} +1 -1
  9. package/dist/assets/{IntegrationsPanel-DLmIJEUy.js → IntegrationsPanel-BPKoNwZm.js} +2 -2
  10. package/dist/assets/{LogViewerModal-D7CXMmZf.js → LogViewerModal-Bx9IDiFM.js} +1 -1
  11. package/dist/assets/{MonitoringModal-PnEKvezF.js → MonitoringModal-DzqEa0fQ.js} +1 -1
  12. package/dist/assets/{PM2LogsModal-EB_Au0iK.js → PM2LogsModal-DZXPRV5-.js} +1 -1
  13. package/dist/assets/{RestoreArchivedAreaModal-C-X90Qxe.js → RestoreArchivedAreaModal-BajWqtWn.js} +1 -1
  14. package/dist/assets/{SaveSnapshotModal-D6XAjL2T.js → SaveSnapshotModal-LqaLezB-.js} +1 -1
  15. package/dist/assets/{Scene2DCanvas-DlVguRVM.js → Scene2DCanvas-DWDmyh_y.js} +1 -1
  16. package/dist/assets/{SceneManager-OOaJ_z8v.js → SceneManager-BgkqWsDb.js} +1 -1
  17. package/dist/assets/{SkillsPanel-D5wo2MHh.js → SkillsPanel-CO-Zt0Tq.js} +1 -1
  18. package/dist/assets/{SnapshotManager-BLjpctX_.js → SnapshotManager-D4Uzw6Tp.js} +1 -1
  19. package/dist/assets/{SpawnModal-DQ4uUm1y.js → SpawnModal-BdCgTKpM.js} +1 -1
  20. package/dist/assets/{SubordinateAssignmentModal-BDUDt6WC.js → SubordinateAssignmentModal-BoaofULj.js} +1 -1
  21. package/dist/assets/{SupervisorPanel-BZaBI9BA.js → SupervisorPanel-D8Cp77my.js} +1 -1
  22. package/dist/assets/{TriggerManagerPanel-DuBiclsE.js → TriggerManagerPanel-CFf3Tud5.js} +1 -1
  23. package/dist/assets/{WorkflowEditorPanel-D49yDqth.js → WorkflowEditorPanel-EtzhBZWw.js} +1 -1
  24. package/dist/assets/{index-DZ3f9mNd.js → index-2YWd58Wh.js} +1 -1
  25. package/dist/assets/{index-DJdXbeWz.js → index-BKRKKMPQ.js} +3 -3
  26. package/dist/assets/{index-BwkNteiZ.js → index-BgTRovwT.js} +1 -1
  27. package/dist/assets/{index-mQmnkGdF.js → index-BiJ_hIit.js} +1 -1
  28. package/dist/assets/{index-Bxjd0N-j.js → index-CDAtstMx.js} +1 -1
  29. package/dist/assets/{index-BxbFh16W.js → index-DBpmD8r7.js} +2 -2
  30. package/dist/assets/{index-BiGvhrCO.js → index-DByGRjfY.js} +1 -1
  31. package/dist/assets/index-VO6fNr63.js +1 -0
  32. package/dist/assets/main-BFSqr5mR.css +1 -0
  33. package/dist/assets/main-BSyGZK2z.js +152 -0
  34. package/dist/assets/{web-DAqM9uoZ.js → web-1BwWjkKM.js} +1 -1
  35. package/dist/assets/{web-DQ10iSod.js → web-BXQj42md.js} +1 -1
  36. package/dist/index.html +2 -2
  37. package/dist/locales/en/config.json +1 -0
  38. package/dist/src/packages/server/claude/backend.js +9 -0
  39. package/dist/src/packages/server/claude/runner/process-lifecycle.js +79 -7
  40. package/dist/src/packages/server/claude/runner/recovery-store.js +73 -10
  41. package/dist/src/packages/server/claude/runner/restart-policy.js +9 -0
  42. package/dist/src/packages/server/claude/runner/stdout-pipeline.js +28 -4
  43. package/dist/src/packages/server/claude/runner/tmux-helper.js +264 -0
  44. package/dist/src/packages/server/claude/runner/watchdog.js +27 -0
  45. package/dist/src/packages/server/claude/runner.js +84 -9
  46. package/dist/src/packages/server/cli.js +17 -1
  47. package/dist/src/packages/server/data/builtin-skills/boss-instructions.js +2 -2
  48. package/dist/src/packages/server/data/index.js +6 -0
  49. package/dist/src/packages/server/opencode/backend.js +1 -0
  50. package/dist/src/packages/server/opencode/index.js +1 -0
  51. package/dist/src/packages/server/routes/agents.js +29 -1
  52. package/dist/src/packages/server/services/system-prompt-service.js +38 -0
  53. package/dist/src/packages/server/websocket/handlers/boss-response-handler.js +5 -1
  54. package/dist/src/packages/server/websocket/listeners/runtime-listeners.js +19 -1
  55. package/package.json +1 -1
  56. package/dist/assets/index-BSl18-4e.js +0 -1
  57. package/dist/assets/main-CUx2B9bn.css +0 -1
  58. package/dist/assets/main-DULfVodw.js +0 -152
@@ -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-DULfVodw.js";import{F as ct}from"./index-DJdXbeWz.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-BSyGZK2z.js";import{F as ct}from"./index-BKRKKMPQ.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,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-DULfVodw.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-BSyGZK2z.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 +1 @@
1
- import{a2 as se,H as ne,J as ie,I as re,b7 as ce,r as g,s as O,b8 as bt,z as pt,u as Mt,j as m}from"./main-DULfVodw.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function et(e){return Array.isArray?Array.isArray(e):zt(e)==="[object Array]"}function oe(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function ae(e){return e==null?"":oe(e)}function X(e){return typeof e=="string"}function Qt(e){return typeof e=="number"}function ue(e){return e===!0||e===!1||le(e)&&zt(e)=="[object Boolean]"}function Wt(e){return typeof e=="object"}function le(e){return Wt(e)&&e!==null}function H(e){return e!=null}function gt(e){return!e.trim().length}function zt(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const he="Incorrect 'index' type",de=e=>`Invalid value for key ${e}`,fe=e=>`Pattern length exceeds max of ${e}.`,me=e=>`Missing ${e} property in key`,pe=e=>`Property 'weight' in key '${e}' must be a positive integer`,Rt=Object.prototype.hasOwnProperty;class ge{constructor(t){this._keys=[],this._keyMap={};let s=0;t.forEach(n=>{let i=Vt(n);this._keys.push(i),this._keyMap[i.id]=i,s+=i.weight}),this._keys.forEach(n=>{n.weight/=s})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Vt(e){let t=null,s=null,n=null,i=1,c=null;if(X(e)||et(e))n=e,t=_t(e),s=yt(e);else{if(!Rt.call(e,"name"))throw new Error(me("name"));const o=e.name;if(n=o,Rt.call(e,"weight")&&(i=e.weight,i<=0))throw new Error(pe(o));t=_t(o),s=yt(o),c=e.getFn}return{path:t,id:s,weight:i,src:n,getFn:c}}function _t(e){return et(e)?e:e.split(".")}function yt(e){return et(e)?e.join("."):e}function ye(e,t){let s=[],n=!1;const i=(c,o,a)=>{if(H(c))if(!o[a])s.push(c);else{let u=o[a];const l=c[u];if(!H(l))return;if(a===o.length-1&&(X(l)||Qt(l)||ue(l)))s.push(ae(l));else if(et(l)){n=!0;for(let d=0,h=l.length;d<h;d+=1)i(l[d],o,a+1)}else o.length&&i(l,o,a+1)}};return i(e,X(t)?t.split("."):t,0),n?s:s[0]}const Ae={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},xe={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},Ee={location:0,threshold:.6,distance:100},Ce={useExtendedSearch:!1,getFn:ye,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var p={...xe,...Ae,...Ee,...Ce};const Fe=/[^ ]+/g;function Me(e=1,t=3){const s=new Map,n=Math.pow(10,t);return{get(i){const c=i.match(Fe).length;if(s.has(c))return s.get(c);const o=1/Math.pow(c,.5*e),a=parseFloat(Math.round(o*n)/n);return s.set(c,a),a},clear(){s.clear()}}}class wt{constructor({getFn:t=p.getFn,fieldNormWeight:s=p.fieldNormWeight}={}){this.norm=Me(s,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((s,n)=>{this._keysMap[s.id]=n})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,X(this.docs[0])?this.docs.forEach((t,s)=>{this._addString(t,s)}):this.docs.forEach((t,s)=>{this._addObject(t,s)}),this.norm.clear())}add(t){const s=this.size();X(t)?this._addString(t,s):this._addObject(t,s)}removeAt(t){this.records.splice(t,1);for(let s=t,n=this.size();s<n;s+=1)this.records[s].i-=1}getValueForItemAtKeyId(t,s){return t[this._keysMap[s]]}size(){return this.records.length}_addString(t,s){if(!H(t)||gt(t))return;let n={v:t,i:s,n:this.norm.get(t)};this.records.push(n)}_addObject(t,s){let n={i:s,$:{}};this.keys.forEach((i,c)=>{let o=i.getFn?i.getFn(t):this.getFn(t,i.path);if(H(o)){if(et(o)){let a=[];const u=[{nestedArrIndex:-1,value:o}];for(;u.length;){const{nestedArrIndex:l,value:d}=u.pop();if(H(d))if(X(d)&&!gt(d)){let h={v:d,i:l,n:this.norm.get(d)};a.push(h)}else et(d)&&d.forEach((h,f)=>{u.push({nestedArrIndex:f,value:h})})}n.$[c]=a}else if(X(o)&&!gt(o)){let a={v:o,n:this.norm.get(o)};n.$[c]=a}}}),this.records.push(n)}toJSON(){return{keys:this.keys,records:this.records}}}function Ut(e,t,{getFn:s=p.getFn,fieldNormWeight:n=p.fieldNormWeight}={}){const i=new wt({getFn:s,fieldNormWeight:n});return i.setKeys(e.map(Vt)),i.setSources(t),i.create(),i}function we(e,{getFn:t=p.getFn,fieldNormWeight:s=p.fieldNormWeight}={}){const{keys:n,records:i}=e,c=new wt({getFn:t,fieldNormWeight:s});return c.setKeys(n),c.setIndexRecords(i),c}function ht(e,{errors:t=0,currentLocation:s=0,expectedLocation:n=0,distance:i=p.distance,ignoreLocation:c=p.ignoreLocation}={}){const o=t/e.length;if(c)return o;const a=Math.abs(n-s);return i?o+a/i:a?1:o}function ve(e=[],t=p.minMatchCharLength){let s=[],n=-1,i=-1,c=0;for(let o=e.length;c<o;c+=1){let a=e[c];a&&n===-1?n=c:!a&&n!==-1&&(i=c-1,i-n+1>=t&&s.push([n,i]),n=-1)}return e[c-1]&&c-n>=t&&s.push([n,c-1]),s}const ot=32;function De(e,t,s,{location:n=p.location,distance:i=p.distance,threshold:c=p.threshold,findAllMatches:o=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,includeMatches:u=p.includeMatches,ignoreLocation:l=p.ignoreLocation}={}){if(t.length>ot)throw new Error(fe(ot));const d=t.length,h=e.length,f=Math.max(0,Math.min(n,h));let y=c,C=f;const k=a>1||u,D=k?Array(h):[];let b;for(;(b=e.indexOf(t,C))>-1;){let S=ht(t,{currentLocation:b,expectedLocation:f,distance:i,ignoreLocation:l});if(y=Math.min(S,y),C=b+d,k){let v=0;for(;v<d;)D[b+v]=1,v+=1}}C=-1;let N=[],z=1,Q=d+h;const at=1<<d-1;for(let S=0;S<d;S+=1){let v=0,j=Q;for(;v<j;)ht(t,{errors:S,currentLocation:f+j,expectedLocation:f,distance:i,ignoreLocation:l})<=y?v=j:Q=j,j=Math.floor((Q-v)/2+v);Q=j;let _=Math.max(1,f-j+1),W=o?h:Math.min(f+j,h)+d,K=Array(W+2);K[W+1]=(1<<S)-1;for(let T=W;T>=_;T-=1){let Z=T-1,ct=s[e.charAt(Z)];if(k&&(D[Z]=+!!ct),K[T]=(K[T+1]<<1|1)&ct,S&&(K[T]|=(N[T+1]|N[T])<<1|1|N[T+1]),K[T]&at&&(z=ht(t,{errors:S,currentLocation:Z,expectedLocation:f,distance:i,ignoreLocation:l}),z<=y)){if(y=z,C=Z,C<=f)break;_=Math.max(1,2*f-C)}}if(ht(t,{errors:S+1,currentLocation:f,expectedLocation:f,distance:i,ignoreLocation:l})>y)break;N=K}const st={isMatch:C>=0,score:Math.max(.001,z)};if(k){const S=ve(D,a);S.length?u&&(st.indices=S):st.isMatch=!1}return st}function Se(e){let t={};for(let s=0,n=e.length;s<n;s+=1){const i=e.charAt(s);t[i]=(t[i]||0)|1<<n-s-1}return t}const dt=String.prototype.normalize?(e=>e.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(e=>e);class Gt{constructor(t,{location:s=p.location,threshold:n=p.threshold,distance:i=p.distance,includeMatches:c=p.includeMatches,findAllMatches:o=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,isCaseSensitive:u=p.isCaseSensitive,ignoreDiacritics:l=p.ignoreDiacritics,ignoreLocation:d=p.ignoreLocation}={}){if(this.options={location:s,threshold:n,distance:i,includeMatches:c,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:d},t=u?t:t.toLowerCase(),t=l?dt(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const h=(y,C)=>{this.chunks.push({pattern:y,alphabet:Se(y),startIndex:C})},f=this.pattern.length;if(f>ot){let y=0;const C=f%ot,k=f-C;for(;y<k;)h(this.pattern.substr(y,ot),y),y+=ot;if(C){const D=f-ot;h(this.pattern.substr(D),D)}}else h(this.pattern,0)}searchIn(t){const{isCaseSensitive:s,ignoreDiacritics:n,includeMatches:i}=this.options;if(t=s?t:t.toLowerCase(),t=n?dt(t):t,this.pattern===t){let k={isMatch:!0,score:0};return i&&(k.indices=[[0,t.length-1]]),k}const{location:c,distance:o,threshold:a,findAllMatches:u,minMatchCharLength:l,ignoreLocation:d}=this.options;let h=[],f=0,y=!1;this.chunks.forEach(({pattern:k,alphabet:D,startIndex:b})=>{const{isMatch:N,score:z,indices:Q}=De(t,k,D,{location:c+b,distance:o,threshold:a,findAllMatches:u,minMatchCharLength:l,includeMatches:i,ignoreLocation:d});N&&(y=!0),f+=z,N&&Q&&(h=[...h,...Q])});let C={isMatch:y,score:y?f/this.chunks.length:1};return y&&i&&(C.indices=h),C}}class rt{constructor(t){this.pattern=t}static isMultiMatch(t){return Lt(t,this.multiRegex)}static isSingleMatch(t){return Lt(t,this.singleRegex)}search(){}}function Lt(e,t){const s=e.match(t);return s?s[1]:null}class Be extends rt{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const s=t===this.pattern;return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Ie extends rt{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const n=t.indexOf(this.pattern)===-1;return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}}class ke extends rt{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const s=t.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class $e extends rt{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const s=!t.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}}class be extends rt{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const s=t.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class Re extends rt{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const s=!t.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}}class Yt extends rt{constructor(t,{location:s=p.location,threshold:n=p.threshold,distance:i=p.distance,includeMatches:c=p.includeMatches,findAllMatches:o=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,isCaseSensitive:u=p.isCaseSensitive,ignoreDiacritics:l=p.ignoreDiacritics,ignoreLocation:d=p.ignoreLocation}={}){super(t),this._bitapSearch=new Gt(t,{location:s,threshold:n,distance:i,includeMatches:c,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:d})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class Jt extends rt{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let s=0,n;const i=[],c=this.pattern.length;for(;(n=t.indexOf(this.pattern,s))>-1;)s=n+c,i.push([n,s-1]);const o=!!i.length;return{isMatch:o,score:o?0:1,indices:i}}}const At=[Be,Jt,ke,$e,Re,be,Ie,Yt],Nt=At.length,_e=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Le="|";function Ne(e,t={}){return e.split(Le).map(s=>{let n=s.trim().split(_e).filter(c=>c&&!!c.trim()),i=[];for(let c=0,o=n.length;c<o;c+=1){const a=n[c];let u=!1,l=-1;for(;!u&&++l<Nt;){const d=At[l];let h=d.isMultiMatch(a);h&&(i.push(new d(h,t)),u=!0)}if(!u)for(l=-1;++l<Nt;){const d=At[l];let h=d.isSingleMatch(a);if(h){i.push(new d(h,t));break}}}return i})}const je=new Set([Yt.type,Jt.type]);class Te{constructor(t,{isCaseSensitive:s=p.isCaseSensitive,ignoreDiacritics:n=p.ignoreDiacritics,includeMatches:i=p.includeMatches,minMatchCharLength:c=p.minMatchCharLength,ignoreLocation:o=p.ignoreLocation,findAllMatches:a=p.findAllMatches,location:u=p.location,threshold:l=p.threshold,distance:d=p.distance}={}){this.query=null,this.options={isCaseSensitive:s,ignoreDiacritics:n,includeMatches:i,minMatchCharLength:c,findAllMatches:a,ignoreLocation:o,location:u,threshold:l,distance:d},t=s?t:t.toLowerCase(),t=n?dt(t):t,this.pattern=t,this.query=Ne(this.pattern,this.options)}static condition(t,s){return s.useExtendedSearch}searchIn(t){const s=this.query;if(!s)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:i,ignoreDiacritics:c}=this.options;t=i?t:t.toLowerCase(),t=c?dt(t):t;let o=0,a=[],u=0;for(let l=0,d=s.length;l<d;l+=1){const h=s[l];a.length=0,o=0;for(let f=0,y=h.length;f<y;f+=1){const C=h[f],{isMatch:k,indices:D,score:b}=C.search(t);if(k){if(o+=1,u+=b,n){const N=C.constructor.type;je.has(N)?a=[...a,...D]:a.push(D)}}else{u=0,o=0,a.length=0;break}}if(o){let f={isMatch:!0,score:u/o};return n&&(f.indices=a),f}}return{isMatch:!1,score:1}}}const xt=[];function Pe(...e){xt.push(...e)}function Et(e,t){for(let s=0,n=xt.length;s<n;s+=1){let i=xt[s];if(i.condition(e,t))return new i(e,t)}return new Gt(e,t)}const ft={AND:"$and",OR:"$or"},Ct={PATH:"$path",PATTERN:"$val"},Ft=e=>!!(e[ft.AND]||e[ft.OR]),Ke=e=>!!e[Ct.PATH],Oe=e=>!et(e)&&Wt(e)&&!Ft(e),jt=e=>({[ft.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function Xt(e,t,{auto:s=!0}={}){const n=i=>{let c=Object.keys(i);const o=Ke(i);if(!o&&c.length>1&&!Ft(i))return n(jt(i));if(Oe(i)){const u=o?i[Ct.PATH]:c[0],l=o?i[Ct.PATTERN]:i[u];if(!X(l))throw new Error(de(u));const d={keyId:yt(u),pattern:l};return s&&(d.searcher=Et(l,t)),d}let a={children:[],operator:c[0]};return c.forEach(u=>{const l=i[u];et(l)&&l.forEach(d=>{a.children.push(n(d))})}),a};return Ft(e)||(e=jt(e)),n(e)}function He(e,{ignoreFieldNorm:t=p.ignoreFieldNorm}){e.forEach(s=>{let n=1;s.matches.forEach(({key:i,norm:c,score:o})=>{const a=i?i.weight:null;n*=Math.pow(o===0&&a?Number.EPSILON:o,(a||1)*(t?1:c))}),s.score=n})}function Qe(e,t){const s=e.matches;t.matches=[],H(s)&&s.forEach(n=>{if(!H(n.indices)||!n.indices.length)return;const{indices:i,value:c}=n;let o={indices:i,value:c};n.key&&(o.key=n.key.src),n.idx>-1&&(o.refIndex=n.idx),t.matches.push(o)})}function We(e,t){t.score=e.score}function ze(e,t,{includeMatches:s=p.includeMatches,includeScore:n=p.includeScore}={}){const i=[];return s&&i.push(Qe),n&&i.push(We),e.map(c=>{const{idx:o}=c,a={item:t[o],refIndex:o};return i.length&&i.forEach(u=>{u(c,a)}),a})}class G{constructor(t,s={},n){this.options={...p,...s},this.options.useExtendedSearch,this._keyStore=new ge(this.options.keys),this.setCollection(t,n)}setCollection(t,s){if(this._docs=t,s&&!(s instanceof wt))throw new Error(he);this._myIndex=s||Ut(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){H(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const s=[];for(let n=0,i=this._docs.length;n<i;n+=1){const c=this._docs[n];t(c,n)&&(this.removeAt(n),n-=1,i-=1,s.push(c))}return s}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:s=-1}={}){const{includeMatches:n,includeScore:i,shouldSort:c,sortFn:o,ignoreFieldNorm:a}=this.options;let u=X(t)?X(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return He(u,{ignoreFieldNorm:a}),c&&u.sort(o),Qt(s)&&s>-1&&(u=u.slice(0,s)),ze(u,this._docs,{includeMatches:n,includeScore:i})}_searchStringList(t){const s=Et(t,this.options),{records:n}=this._myIndex,i=[];return n.forEach(({v:c,i:o,n:a})=>{if(!H(c))return;const{isMatch:u,score:l,indices:d}=s.searchIn(c);u&&i.push({item:c,idx:o,matches:[{score:l,value:c,norm:a,indices:d}]})}),i}_searchLogical(t){const s=Xt(t,this.options),n=(a,u,l)=>{if(!a.children){const{keyId:h,searcher:f}=a,y=this._findMatches({key:this._keyStore.get(h),value:this._myIndex.getValueForItemAtKeyId(u,h),searcher:f});return y&&y.length?[{idx:l,item:u,matches:y}]:[]}const d=[];for(let h=0,f=a.children.length;h<f;h+=1){const y=a.children[h],C=n(y,u,l);if(C.length)d.push(...C);else if(a.operator===ft.AND)return[]}return d},i=this._myIndex.records,c={},o=[];return i.forEach(({$:a,i:u})=>{if(H(a)){let l=n(s,a,u);l.length&&(c[u]||(c[u]={idx:u,item:a,matches:[]},o.push(c[u])),l.forEach(({matches:d})=>{c[u].matches.push(...d)}))}}),o}_searchObjectList(t){const s=Et(t,this.options),{keys:n,records:i}=this._myIndex,c=[];return i.forEach(({$:o,i:a})=>{if(!H(o))return;let u=[];n.forEach((l,d)=>{u.push(...this._findMatches({key:l,value:o[d],searcher:s}))}),u.length&&c.push({idx:a,item:o,matches:u})}),c}_findMatches({key:t,value:s,searcher:n}){if(!H(s))return[];let i=[];if(et(s))s.forEach(({v:c,i:o,n:a})=>{if(!H(c))return;const{isMatch:u,score:l,indices:d}=n.searchIn(c);u&&i.push({score:l,key:t,value:c,idx:o,norm:a,indices:d})});else{const{v:c,n:o}=s,{isMatch:a,score:u,indices:l}=n.searchIn(c);a&&i.push({score:u,key:t,value:c,norm:o,indices:l})}return i}}G.version="7.1.0";G.createIndex=Ut;G.parseIndex=we;G.config=p;G.parseQuery=Xt;Pe(Te);const Tt={".ts":"📘",".tsx":"⚛️",".js":"📒",".jsx":"⚛️",".py":"🐍",".rs":"🦀",".go":"🔷",".md":"📝",".json":"📋",".yaml":"⚙️",".yml":"⚙️",".css":"🎨",".scss":"🎨",".html":"🌐",".sql":"🗃️",".sh":"💻",".env":"🔐",".toml":"⚙️",".lock":"🔒",default:"📄"};function Ve(e){var s;const t="."+((s=e.split(".").pop())==null?void 0:s.toLowerCase());return Tt[t]||Tt.default}function Pt(e){const t=se[e];return(t==null?void 0:t.icon)||"🤖"}function Zt(e){const t=Math.floor(e/1e3),s=Math.floor(t/60),n=Math.floor(s/60),i=Math.floor(n/24);return i>0?`${i}d ${n%24}h ago`:n>0?`${n}h ${s%60}m ago`:s>0?`${s}m ago`:"just now"}function Kt(e){const s=Date.now()-e;return Zt(s)}function Ot(e){switch(e){case"agent":return"Agent";case"command":return"Command";case"area":return"Area";case"activity":return"Activity";case"modified-file":return"Changed";case"building":return"Server";default:return e}}const Ht=["command","agent","building","area","modified-file","activity"];function Ue({isOpen:e,onClose:t,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:i,onOpenSupervisor:c,onOpenFileExplorer:o,onOpenPM2LogsModal:a,onOpenBossLogsModal:u,onOpenDatabasePanel:l,onOpenMonitoringModal:d}){const h=ne(),f=ie(),y=re(),C=ce(),k=g.useMemo(()=>{const r=O.getState().supervisor.agentHistories;let A="";for(const[F,M]of r)A+=`${F}:${M.length},`;return A},[h]),D=g.useRef(t);D.current=t;const b=g.useRef(s);b.current=s;const N=g.useRef(n);N.current=n;const z=g.useRef(i);z.current=i;const Q=g.useRef(c);Q.current=c;const at=g.useRef(o);at.current=o;const st=g.useRef(a);st.current=a;const S=g.useRef(u);S.current=u;const v=g.useRef(l);v.current=l;const j=g.useRef(d);j.current=d;const[_,W]=g.useState(""),[K,nt]=g.useState(0);g.useEffect(()=>{if(e){W(""),nt(0);const r=Array.from(h.values());for(const A of r)!O.hasHistoryBeenFetched(A.id)&&!O.isLoadingHistoryForAgent(A.id)&&O.requestAgentSupervisorHistory(A.id)}},[e,h]);const T=O.getShortcuts(),Z=g.useMemo(()=>{if(!e)return[];const r=T.find(F=>F.id==="spawn-agent"),A=T.find(F=>F.id==="toggle-commander");return[{id:"cmd-spawn",type:"command",title:"Spawn New Agent",subtitle:r?bt(r):"Alt+N",icon:"➕",action:()=>{D.current(),b.current()}},{id:"cmd-commander",type:"command",title:"Commander View",subtitle:A?bt(A):"Ctrl+K",icon:"📊",action:()=>{D.current(),N.current()}},{id:"cmd-settings",type:"command",title:"Settings & Tools",subtitle:"Configure Tide Commander",icon:"⚙️",action:()=>{D.current(),z.current()}},{id:"cmd-supervisor",type:"command",title:"Supervisor Overview",subtitle:"View agent analysis",icon:"🎖️",action:()=>{D.current(),Q.current()}},{id:"cmd-monitoring",type:"command",title:"Monitoring & Logs",subtitle:"Triggers, workflows, events",icon:"📊",action:()=>{var F;D.current(),(F=j.current)==null||F.call(j)}}]},[e,T]),ct=g.useMemo(()=>e?Array.from(h.values()).map(r=>{const A=O.getAgentSupervisorHistory(r.id),F=A.length>0?A[0]:null,M=A.map(x=>({text:`${x.analysis.statusDescription} ${x.analysis.recentWorkSummary}`,timestamp:x.timestamp})),$=(C||[]).filter(x=>x.agentId===r.id).map(x=>x.filePath),I=[...new Set($)],R=I.map(x=>x.split("/").pop()||x),B=[];r.lastAssignedTask&&B.push(r.lastAssignedTask);const Y=`${r.class} • ${r.status} • ${r.cwd}`;let J=`${r.name} ${Y}`,L,ut,E;for(const x of M)J+=` ${x.text}`;F&&(L=F.analysis.recentWorkSummary,ut=F.analysis.statusDescription,E=F.timestamp),R.length>0&&(J+=` ${R.join(" ")} ${I.join(" ")}`),B.length>0&&(J+=` ${B.join(" ")}`);const w=Date.now()-r.lastActivity;let U;return r.lastAssignedTask&&(r.lastAssignedTask.length>150?U=r.lastAssignedTask.slice(0,150)+"...":U=r.lastAssignedTask),{id:`agent-${r.id}`,type:"agent",title:r.name,subtitle:Y,lastUserInput:U,statusDescription:ut,activityText:L,matchedText:L,timeAway:w,lastStatusTime:E,icon:Pt(r.class),_searchText:J,_modifiedFiles:I,_userQueries:B,_historyEntries:M,action:()=>{D.current(),O.selectAgent(r.id)}}}):[],[e,h,k,C]),lt=g.useMemo(()=>e?Array.from(f.values()).map(r=>{var A;return{id:`area-${r.id}`,type:"area",title:r.name,subtitle:`${r.assignedAgentIds.length} agents • ${((A=r.directories)==null?void 0:A.length)||0} folders`,icon:"🗺️",action:()=>{D.current(),O.selectArea(r.id)}}}):[],[e,f]),mt=g.useMemo(()=>e?Array.from(y.values()).filter(r=>r.type==="server"||r.type==="boss"||r.type==="database").map(r=>{var R,B,Y,J;const A=r.status==="running"?"🟢":r.status==="stopped"?"🔴":"🟡",F=r.type==="boss"?"👑":r.type==="database"?"🗄️":"🖥️";let $=`${r.type==="boss"?"Boss":r.type==="database"?"Database":"Server"} • ${r.status}`;if(r.type==="database"&&((B=(R=r.database)==null?void 0:R.connections)!=null&&B.length)){const L=r.database.connections[0];$+=` • ${L.engine} @ ${L.host}`}else r.cwd&&($+=` • ${r.cwd}`);let I=`${r.name} ${r.type} ${r.status} ${r.cwd||""} ${((Y=r.pm2)==null?void 0:Y.name)||""}`;if(r.type==="database"&&((J=r.database)!=null&&J.connections))for(const L of r.database.connections)I+=` ${L.name} ${L.engine} ${L.host} ${L.database||""} mysql postgresql sql`;return{id:`building-${r.id}`,type:"building",title:r.name,subtitle:$,icon:`${A} ${F}`,_searchText:I,action:()=>{var L;D.current(),r.type==="boss"?S.current(r.id):r.type==="database"?v.current(r.id):(L=r.pm2)!=null&&L.enabled&&st.current(r.id)}}}):[],[e,y]),vt=g.useMemo(()=>{if(!e)return[];const r=C||[],A=new Set,F=[];for(const M of r){if(A.has(M.filePath))continue;A.add(M.filePath);const $=M.filePath.split("/").pop()||M.filePath,I=M.action==="created"?"Created":M.action==="modified"?"Modified":M.action==="deleted"?"Deleted":"Read";if(F.push({id:`modified-${M.filePath}-${M.timestamp}`,type:"modified-file",title:$,subtitle:`${I} by ${M.agentName} • ${M.filePath}`,matchedText:M.filePath,icon:M.action==="deleted"?"🗑️":Ve(M.filePath),action:()=>{D.current();const R=Array.from(O.getState().areas.values());for(const B of R)for(const Y of B.directories||[])if(M.filePath.startsWith(Y)){O.setFileViewerPath(M.filePath),at.current(B.id);return}O.selectAgent(M.agentId)}}),F.length>=50)break}return F},[e,C]),Dt=g.useMemo(()=>{if(!e)return[];const r=[],A=Array.from(h.values());for(const F of A){const M=O.getAgentSupervisorHistory(F.id);if(M.length>0){const $=M[0],I=$.analysis;r.push({id:`activity-${F.id}-${$.timestamp}`,type:"activity",title:F.name,subtitle:I.statusDescription,activityText:I.recentWorkSummary,matchedText:I.recentWorkSummary,icon:Pt(F.class),action:()=>{D.current(),O.selectAgent(F.id)}})}}return r},[e,h,k]),St=g.useMemo(()=>new G(ct,{keys:["title","subtitle","_searchText","activityText","lastUserInput"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[ct]),Bt=g.useMemo(()=>new G(Z,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[Z]),It=g.useMemo(()=>new G(lt,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[lt]),kt=g.useMemo(()=>new G(vt,{keys:["title","subtitle","matchedText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[vt]),$t=g.useMemo(()=>new G(Dt,{keys:["title","subtitle","matchedText","activityText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[Dt]),qt=g.useMemo(()=>new G(mt,{keys:["title","subtitle","_searchText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[mt]),V=g.useMemo(()=>{if(!_.trim()){const E=[];E.push(...mt);const w=[...ct].sort((x,P)=>{const q=x.timeAway??0,tt=P.timeAway??0;return q-tt});E.push(...w),E.push(...Z.slice(0,2)),E.push(...lt.slice(0,2));const U={};return Ht.forEach((x,P)=>{U[x]=P}),E.sort((x,P)=>(U[x.type]??999)-(U[P.type]??999)),E}const r=_.toLowerCase(),A=St.search(_).slice(0,8),F=Bt.search(_).slice(0,3),M=It.search(_).slice(0,2),$=kt.search(_).slice(0,3),I=$t.search(_).slice(0,3),R=qt.search(_).filter(E=>{const w=E.score??1;return`${E.item.title} ${E.item.subtitle||""} ${E.item._searchText||""}`.toLowerCase().includes(r)||w<=.2}).slice(0,4),B=[],Y=[],J=[];for(const E of A){const w={...E.item};if(w._modifiedFiles&&w._modifiedFiles.length>0){const x=w._modifiedFiles.filter(P=>{var it;const q=((it=P.split("/").pop())==null?void 0:it.toLowerCase())||"",tt=P.toLowerCase();return q.includes(r)||tt.includes(r)});x.length>0&&(w.matchedFiles=x)}if(w._userQueries&&w._userQueries.length>0){const x=w._userQueries.find(P=>P.toLowerCase().includes(r));if(x)if(x.length>200){const q=x.toLowerCase().indexOf(r),tt=Math.max(0,q-60),it=Math.min(x.length,q+r.length+100);w.matchedQuery=(tt>0?"...":"")+x.slice(tt,it)+(it<x.length?"...":"")}else w.matchedQuery=x}if(w._historyEntries&&w._historyEntries.length>0){const x=w._historyEntries.find(P=>P.text.toLowerCase().includes(r));if(x)if(x.text.length>250){const q=x.text.toLowerCase().indexOf(r),tt=Math.max(0,q-80),it=Math.min(x.text.length,q+r.length+120);w.matchedHistory={text:(tt>0?"...":"")+x.text.slice(tt,it)+(it<x.text.length?"...":""),timestamp:x.timestamp}}else w.matchedHistory=x}const U=w.title.toLowerCase();U===r||U.startsWith(r)?Y.push(w):J.push(w)}for(const E of Y)B.push(E);for(const E of R)B.push(E.item);for(const E of J)B.push(E);for(const E of F)B.push(E.item);for(const E of M)B.push(E.item);for(const E of $)B.push(E.item);const L=new Set(A.map(E=>E.item.id));for(const E of I){const w=E.item.id.replace("activity-","").split("-")[0];L.has(`agent-${w}`)||B.push(E.item)}const ut={};return Ht.forEach((E,w)=>{ut[E]=w}),B.sort((E,w)=>(ut[E.type]??999)-(ut[w.type]??999)),B},[_,St,Bt,It,kt,$t,Z,ct,lt]);g.useEffect(()=>{K>=V.length&&nt(Math.max(0,V.length-1))},[V.length,K]);const te=g.useCallback(r=>{if(r.altKey&&!r.ctrlKey&&!r.metaKey&&(r.key==="p"||r.key==="n"||r.key==="P"||r.key==="N")){r.preventDefault(),r.stopPropagation(),r.nativeEvent.stopImmediatePropagation();const A=r.key.toLowerCase();nt(A==="p"?F=>F>0?F-1:V.length-1:F=>F<V.length-1?F+1:0);return}switch(r.key){case"Escape":r.preventDefault(),D.current();break;case"ArrowUp":r.preventDefault(),nt(A=>A>0?A-1:V.length-1);break;case"ArrowDown":r.preventDefault(),nt(A=>A<V.length-1?A+1:0);break;case"Enter":r.preventDefault(),V[K]&&V[K].action();break}},[V,K]),ee=g.useCallback((r,A)=>{if(!A||!r)return r;const F=r.toLowerCase(),M=A.toLowerCase(),$=[];let I=0,R=F.indexOf(M),B=0;for(;R!==-1;)R>I&&$.push(r.slice(I,R)),$.push(pt.createElement("mark",{key:B++,className:"spotlight-highlight"},r.slice(R,R+A.length))),I=R+A.length,R=F.indexOf(M,I);return I<r.length&&$.push(r.slice(I)),$.length>0?pt.createElement(pt.Fragment,null,...$):r},[]);return{query:_,setQuery:W,selectedIndex:K,setSelectedIndex:nt,results:V,handleKeyDown:te,highlightMatch:ee}}const Ge=g.forwardRef(function({query:t,onQueryChange:s,onKeyDown:n,onResetSelection:i},c){const{t:o}=Mt(["common"]);return m.jsxs("div",{className:"spotlight-input-wrapper",children:[m.jsx("span",{className:"spotlight-search-icon",children:"⌘"}),m.jsx("input",{ref:c,type:"text",className:"spotlight-input",placeholder:o("common:search.spotlightPlaceholder"),value:t,onChange:a=>{s(a.target.value),i()},onKeyDown:n,autoFocus:!0,spellCheck:!1}),m.jsxs("div",{className:"spotlight-input-hints",children:[m.jsx("span",{className:"spotlight-shortcut-hint",children:"↑↓"}),m.jsx("span",{className:"spotlight-shortcut-hint",children:"Enter"}),m.jsx("span",{className:"spotlight-shortcut-hint",children:"Esc"})]})]})}),Ye=g.memo(function({result:t,isSelected:s,query:n,highlightMatch:i,onClick:c,onMouseEnter:o}){const a=t.activityText||t.statusDescription||t.matchedFiles&&t.matchedFiles.length>0||t.matchedQuery||t.matchedHistory;return m.jsxs("div",{className:`spotlight-item ${s?"selected":""} ${t.activityText?"has-activity":""}`,onClick:c,onMouseEnter:o,role:"option","aria-selected":s,children:[m.jsx("span",{className:"spotlight-item-icon","aria-hidden":"true",children:t.icon}),m.jsxs("div",{className:"spotlight-item-content",children:[m.jsxs("div",{className:"spotlight-item-header",children:[m.jsx("span",{className:"spotlight-item-title",children:i(t.title,n)}),m.jsx("span",{className:`spotlight-item-type ${t.type}`,"aria-label":Ot(t.type),children:Ot(t.type)})]}),t.subtitle&&m.jsx("span",{className:"spotlight-item-subtitle",children:i(t.subtitle,n)}),t.statusDescription&&m.jsx("span",{className:"spotlight-item-status",children:i(t.statusDescription,n)}),t.activityText&&m.jsx("span",{className:"spotlight-item-activity",children:i(t.activityText,n)}),a&&m.jsxs("div",{className:"spotlight-item-details",children:[t.matchedFiles&&t.matchedFiles.length>0&&m.jsx("span",{className:"spotlight-item-files",children:t.matchedFiles.map((u,l)=>m.jsxs("span",{className:"file-badge",children:[l>0&&m.jsx("span",{className:"file-separator",children:"•"}),i(u.split("/").pop()||u,n)]},u))}),t.matchedQuery&&m.jsx("span",{className:"spotlight-item-query",children:i(t.matchedQuery,n)}),t.matchedHistory&&m.jsxs("span",{className:"spotlight-item-history",children:[i(t.matchedHistory.text,n),m.jsx("span",{className:"spotlight-history-time",children:Kt(t.matchedHistory.timestamp)})]})]}),(t.timeAway!==void 0||t.lastStatusTime!==void 0)&&m.jsxs("span",{className:"spotlight-item-time",children:[t.timeAway!==void 0&&m.jsxs("span",{className:"spotlight-time-away",children:["Idle: ",Zt(t.timeAway)]}),t.lastStatusTime!==void 0&&m.jsxs("span",{className:"spotlight-status-time",children:["Updated ",Kt(t.lastStatusTime)]})]}),t.lastUserInput&&!t.matchedQuery&&m.jsxs("span",{className:"spotlight-item-last-input",children:['"',i(t.lastUserInput,n),'"']})]})]})}),Je=g.forwardRef(function({results:t,selectedIndex:s,query:n,highlightMatch:i,onSelectIndex:c},o){const{t:a}=Mt(["terminal"]),u=g.useRef(!1);g.useEffect(()=>{u.current=!1},[t]),g.useEffect(()=>{const h=typeof o=="function"?null:o==null?void 0:o.current;if(!h)return;const f=()=>{u.current=!0};return h.addEventListener("mousemove",f),()=>{h.removeEventListener("mousemove",f)}},[o,t]);const l={command:a("terminal:spotlight.categories.commands"),agent:a("terminal:spotlight.categories.agents"),building:a("terminal:spotlight.categories.infrastructure"),area:a("terminal:spotlight.categories.areas"),"modified-file":a("terminal:spotlight.categories.modifiedFiles"),activity:a("terminal:spotlight.categories.recentActivity")},d=g.useMemo(()=>{const h=[];let f=null,y=[];return t.forEach((C,k)=>{C.type!==f&&(f!==null&&y.length>0&&h.push([f,y]),f=C.type,y=[]),y.push({result:C,index:k})}),f!==null&&y.length>0&&h.push([f,y]),h},[t]);return g.useEffect(()=>{if(!o||typeof o=="function")return;const h=o.current;if(!h)return;const f=h.querySelector(".spotlight-item.selected");f&&f.scrollIntoView({block:"nearest",behavior:"smooth"})},[s,o]),t.length===0?m.jsx("div",{className:"spotlight-results",ref:o,children:m.jsx("div",{className:"spotlight-empty",children:a("terminal:spotlight.noResults")})}):m.jsx("div",{className:"spotlight-results",ref:o,children:d.map(([h,f])=>m.jsxs("div",{children:[d.length>1&&m.jsx("div",{className:"spotlight-category-header",children:l[h]||h}),f.map(({result:y,index:C})=>m.jsx(Ye,{result:y,isSelected:C===s,query:n,highlightMatch:i,onClick:()=>y.action(),onMouseEnter:()=>{u.current&&c(C)}},y.id))]},h))})}),Xe=g.memo(function(){const{t}=Mt(["terminal"]);return m.jsxs("div",{className:"spotlight-footer",children:[m.jsxs("div",{className:"spotlight-footer-left",children:[m.jsxs("span",{className:"spotlight-footer-hint",children:[m.jsx("kbd",{children:"↑"}),m.jsx("kbd",{children:"↓"})," ",m.jsx("kbd",{children:"Alt+N"}),m.jsx("kbd",{children:"Alt+P"})," ",t("terminal:spotlight.navigate")]}),m.jsxs("span",{className:"spotlight-footer-hint",children:[m.jsx("kbd",{children:"Enter"})," ",t("terminal:spotlight.select")]})]}),m.jsx("div",{className:"spotlight-footer-right",children:m.jsxs("span",{className:"spotlight-footer-hint",children:[m.jsx("kbd",{children:"Esc"})," ",t("common:buttons.close")]})})]})});function ss({isOpen:e,onClose:t,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:i,onOpenSupervisor:c,onOpenFileExplorer:o,onOpenPM2LogsModal:a,onOpenBossLogsModal:u,onOpenDatabasePanel:l,onOpenMonitoringModal:d}){const h=g.useRef(null),f=g.useRef(null),y=g.useRef(0),{query:C,setQuery:k,selectedIndex:D,setSelectedIndex:b,results:N,handleKeyDown:z,highlightMatch:Q}=Ue({isOpen:e,onClose:t,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:i,onOpenSupervisor:c,onOpenFileExplorer:o,onOpenPM2LogsModal:a,onOpenBossLogsModal:u,onOpenDatabasePanel:l,onOpenMonitoringModal:d});y.current=N.length,g.useEffect(()=>{e&&setTimeout(()=>{var S;(S=h.current)==null||S.focus()},50)},[e]),g.useEffect(()=>{if(!e)return;const S=v=>{if(v.key==="Escape"){v.preventDefault(),v.stopPropagation(),v.stopImmediatePropagation(),t();return}if(v.altKey&&!v.ctrlKey&&!v.metaKey&&(v.key==="n"||v.key==="p"||v.key==="N"||v.key==="P")){v.preventDefault(),v.stopPropagation(),v.stopImmediatePropagation();const j=v.key.toLowerCase(),_=y.current;b(j==="p"?W=>W>0?W-1:_-1:W=>W<_-1?W+1:0);return}};return window.addEventListener("keydown",S,{capture:!0}),()=>{window.removeEventListener("keydown",S,{capture:!0})}},[e,t]);const at=g.useCallback(S=>{S.target===S.currentTarget&&t()},[t]),st=g.useCallback(()=>{b(0)},[b]);return e?m.jsx("div",{className:"spotlight-overlay",onClick:at,children:m.jsxs("div",{className:"spotlight-modal",children:[m.jsx(Ge,{ref:h,query:C,onQueryChange:k,onKeyDown:z,onResetSelection:st}),m.jsx(Je,{ref:f,results:N,selectedIndex:D,query:C,highlightMatch:Q,onSelectIndex:b}),m.jsx(Xe,{})]})}):null}export{Tt as FILE_ICONS,ss as Spotlight,Xe as SpotlightFooter,Ge as SpotlightInput,Ye as SpotlightItem,Je as SpotlightResults,Zt as formatDuration,Kt as formatRelativeTime,Pt as getAgentIcon,Ve as getFileIconFromPath,Ot as getTypeLabel,Ue as useSpotlightSearch};
1
+ import{a2 as se,H as ne,J as ie,I as re,b7 as ce,r as g,s as O,b8 as bt,z as pt,u as Mt,j as m}from"./main-BSyGZK2z.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function et(e){return Array.isArray?Array.isArray(e):zt(e)==="[object Array]"}function oe(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function ae(e){return e==null?"":oe(e)}function X(e){return typeof e=="string"}function Qt(e){return typeof e=="number"}function ue(e){return e===!0||e===!1||le(e)&&zt(e)=="[object Boolean]"}function Wt(e){return typeof e=="object"}function le(e){return Wt(e)&&e!==null}function H(e){return e!=null}function gt(e){return!e.trim().length}function zt(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const he="Incorrect 'index' type",de=e=>`Invalid value for key ${e}`,fe=e=>`Pattern length exceeds max of ${e}.`,me=e=>`Missing ${e} property in key`,pe=e=>`Property 'weight' in key '${e}' must be a positive integer`,Rt=Object.prototype.hasOwnProperty;class ge{constructor(t){this._keys=[],this._keyMap={};let s=0;t.forEach(n=>{let i=Vt(n);this._keys.push(i),this._keyMap[i.id]=i,s+=i.weight}),this._keys.forEach(n=>{n.weight/=s})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Vt(e){let t=null,s=null,n=null,i=1,c=null;if(X(e)||et(e))n=e,t=_t(e),s=yt(e);else{if(!Rt.call(e,"name"))throw new Error(me("name"));const o=e.name;if(n=o,Rt.call(e,"weight")&&(i=e.weight,i<=0))throw new Error(pe(o));t=_t(o),s=yt(o),c=e.getFn}return{path:t,id:s,weight:i,src:n,getFn:c}}function _t(e){return et(e)?e:e.split(".")}function yt(e){return et(e)?e.join("."):e}function ye(e,t){let s=[],n=!1;const i=(c,o,a)=>{if(H(c))if(!o[a])s.push(c);else{let u=o[a];const l=c[u];if(!H(l))return;if(a===o.length-1&&(X(l)||Qt(l)||ue(l)))s.push(ae(l));else if(et(l)){n=!0;for(let d=0,h=l.length;d<h;d+=1)i(l[d],o,a+1)}else o.length&&i(l,o,a+1)}};return i(e,X(t)?t.split("."):t,0),n?s:s[0]}const Ae={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},xe={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},Ee={location:0,threshold:.6,distance:100},Ce={useExtendedSearch:!1,getFn:ye,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var p={...xe,...Ae,...Ee,...Ce};const Fe=/[^ ]+/g;function Me(e=1,t=3){const s=new Map,n=Math.pow(10,t);return{get(i){const c=i.match(Fe).length;if(s.has(c))return s.get(c);const o=1/Math.pow(c,.5*e),a=parseFloat(Math.round(o*n)/n);return s.set(c,a),a},clear(){s.clear()}}}class wt{constructor({getFn:t=p.getFn,fieldNormWeight:s=p.fieldNormWeight}={}){this.norm=Me(s,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((s,n)=>{this._keysMap[s.id]=n})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,X(this.docs[0])?this.docs.forEach((t,s)=>{this._addString(t,s)}):this.docs.forEach((t,s)=>{this._addObject(t,s)}),this.norm.clear())}add(t){const s=this.size();X(t)?this._addString(t,s):this._addObject(t,s)}removeAt(t){this.records.splice(t,1);for(let s=t,n=this.size();s<n;s+=1)this.records[s].i-=1}getValueForItemAtKeyId(t,s){return t[this._keysMap[s]]}size(){return this.records.length}_addString(t,s){if(!H(t)||gt(t))return;let n={v:t,i:s,n:this.norm.get(t)};this.records.push(n)}_addObject(t,s){let n={i:s,$:{}};this.keys.forEach((i,c)=>{let o=i.getFn?i.getFn(t):this.getFn(t,i.path);if(H(o)){if(et(o)){let a=[];const u=[{nestedArrIndex:-1,value:o}];for(;u.length;){const{nestedArrIndex:l,value:d}=u.pop();if(H(d))if(X(d)&&!gt(d)){let h={v:d,i:l,n:this.norm.get(d)};a.push(h)}else et(d)&&d.forEach((h,f)=>{u.push({nestedArrIndex:f,value:h})})}n.$[c]=a}else if(X(o)&&!gt(o)){let a={v:o,n:this.norm.get(o)};n.$[c]=a}}}),this.records.push(n)}toJSON(){return{keys:this.keys,records:this.records}}}function Ut(e,t,{getFn:s=p.getFn,fieldNormWeight:n=p.fieldNormWeight}={}){const i=new wt({getFn:s,fieldNormWeight:n});return i.setKeys(e.map(Vt)),i.setSources(t),i.create(),i}function we(e,{getFn:t=p.getFn,fieldNormWeight:s=p.fieldNormWeight}={}){const{keys:n,records:i}=e,c=new wt({getFn:t,fieldNormWeight:s});return c.setKeys(n),c.setIndexRecords(i),c}function ht(e,{errors:t=0,currentLocation:s=0,expectedLocation:n=0,distance:i=p.distance,ignoreLocation:c=p.ignoreLocation}={}){const o=t/e.length;if(c)return o;const a=Math.abs(n-s);return i?o+a/i:a?1:o}function ve(e=[],t=p.minMatchCharLength){let s=[],n=-1,i=-1,c=0;for(let o=e.length;c<o;c+=1){let a=e[c];a&&n===-1?n=c:!a&&n!==-1&&(i=c-1,i-n+1>=t&&s.push([n,i]),n=-1)}return e[c-1]&&c-n>=t&&s.push([n,c-1]),s}const ot=32;function De(e,t,s,{location:n=p.location,distance:i=p.distance,threshold:c=p.threshold,findAllMatches:o=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,includeMatches:u=p.includeMatches,ignoreLocation:l=p.ignoreLocation}={}){if(t.length>ot)throw new Error(fe(ot));const d=t.length,h=e.length,f=Math.max(0,Math.min(n,h));let y=c,C=f;const k=a>1||u,D=k?Array(h):[];let b;for(;(b=e.indexOf(t,C))>-1;){let S=ht(t,{currentLocation:b,expectedLocation:f,distance:i,ignoreLocation:l});if(y=Math.min(S,y),C=b+d,k){let v=0;for(;v<d;)D[b+v]=1,v+=1}}C=-1;let N=[],z=1,Q=d+h;const at=1<<d-1;for(let S=0;S<d;S+=1){let v=0,j=Q;for(;v<j;)ht(t,{errors:S,currentLocation:f+j,expectedLocation:f,distance:i,ignoreLocation:l})<=y?v=j:Q=j,j=Math.floor((Q-v)/2+v);Q=j;let _=Math.max(1,f-j+1),W=o?h:Math.min(f+j,h)+d,K=Array(W+2);K[W+1]=(1<<S)-1;for(let T=W;T>=_;T-=1){let Z=T-1,ct=s[e.charAt(Z)];if(k&&(D[Z]=+!!ct),K[T]=(K[T+1]<<1|1)&ct,S&&(K[T]|=(N[T+1]|N[T])<<1|1|N[T+1]),K[T]&at&&(z=ht(t,{errors:S,currentLocation:Z,expectedLocation:f,distance:i,ignoreLocation:l}),z<=y)){if(y=z,C=Z,C<=f)break;_=Math.max(1,2*f-C)}}if(ht(t,{errors:S+1,currentLocation:f,expectedLocation:f,distance:i,ignoreLocation:l})>y)break;N=K}const st={isMatch:C>=0,score:Math.max(.001,z)};if(k){const S=ve(D,a);S.length?u&&(st.indices=S):st.isMatch=!1}return st}function Se(e){let t={};for(let s=0,n=e.length;s<n;s+=1){const i=e.charAt(s);t[i]=(t[i]||0)|1<<n-s-1}return t}const dt=String.prototype.normalize?(e=>e.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(e=>e);class Gt{constructor(t,{location:s=p.location,threshold:n=p.threshold,distance:i=p.distance,includeMatches:c=p.includeMatches,findAllMatches:o=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,isCaseSensitive:u=p.isCaseSensitive,ignoreDiacritics:l=p.ignoreDiacritics,ignoreLocation:d=p.ignoreLocation}={}){if(this.options={location:s,threshold:n,distance:i,includeMatches:c,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:d},t=u?t:t.toLowerCase(),t=l?dt(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const h=(y,C)=>{this.chunks.push({pattern:y,alphabet:Se(y),startIndex:C})},f=this.pattern.length;if(f>ot){let y=0;const C=f%ot,k=f-C;for(;y<k;)h(this.pattern.substr(y,ot),y),y+=ot;if(C){const D=f-ot;h(this.pattern.substr(D),D)}}else h(this.pattern,0)}searchIn(t){const{isCaseSensitive:s,ignoreDiacritics:n,includeMatches:i}=this.options;if(t=s?t:t.toLowerCase(),t=n?dt(t):t,this.pattern===t){let k={isMatch:!0,score:0};return i&&(k.indices=[[0,t.length-1]]),k}const{location:c,distance:o,threshold:a,findAllMatches:u,minMatchCharLength:l,ignoreLocation:d}=this.options;let h=[],f=0,y=!1;this.chunks.forEach(({pattern:k,alphabet:D,startIndex:b})=>{const{isMatch:N,score:z,indices:Q}=De(t,k,D,{location:c+b,distance:o,threshold:a,findAllMatches:u,minMatchCharLength:l,includeMatches:i,ignoreLocation:d});N&&(y=!0),f+=z,N&&Q&&(h=[...h,...Q])});let C={isMatch:y,score:y?f/this.chunks.length:1};return y&&i&&(C.indices=h),C}}class rt{constructor(t){this.pattern=t}static isMultiMatch(t){return Lt(t,this.multiRegex)}static isSingleMatch(t){return Lt(t,this.singleRegex)}search(){}}function Lt(e,t){const s=e.match(t);return s?s[1]:null}class Be extends rt{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const s=t===this.pattern;return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Ie extends rt{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const n=t.indexOf(this.pattern)===-1;return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}}class ke extends rt{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const s=t.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class $e extends rt{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const s=!t.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}}class be extends rt{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const s=t.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class Re extends rt{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const s=!t.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}}class Yt extends rt{constructor(t,{location:s=p.location,threshold:n=p.threshold,distance:i=p.distance,includeMatches:c=p.includeMatches,findAllMatches:o=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,isCaseSensitive:u=p.isCaseSensitive,ignoreDiacritics:l=p.ignoreDiacritics,ignoreLocation:d=p.ignoreLocation}={}){super(t),this._bitapSearch=new Gt(t,{location:s,threshold:n,distance:i,includeMatches:c,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:d})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class Jt extends rt{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let s=0,n;const i=[],c=this.pattern.length;for(;(n=t.indexOf(this.pattern,s))>-1;)s=n+c,i.push([n,s-1]);const o=!!i.length;return{isMatch:o,score:o?0:1,indices:i}}}const At=[Be,Jt,ke,$e,Re,be,Ie,Yt],Nt=At.length,_e=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Le="|";function Ne(e,t={}){return e.split(Le).map(s=>{let n=s.trim().split(_e).filter(c=>c&&!!c.trim()),i=[];for(let c=0,o=n.length;c<o;c+=1){const a=n[c];let u=!1,l=-1;for(;!u&&++l<Nt;){const d=At[l];let h=d.isMultiMatch(a);h&&(i.push(new d(h,t)),u=!0)}if(!u)for(l=-1;++l<Nt;){const d=At[l];let h=d.isSingleMatch(a);if(h){i.push(new d(h,t));break}}}return i})}const je=new Set([Yt.type,Jt.type]);class Te{constructor(t,{isCaseSensitive:s=p.isCaseSensitive,ignoreDiacritics:n=p.ignoreDiacritics,includeMatches:i=p.includeMatches,minMatchCharLength:c=p.minMatchCharLength,ignoreLocation:o=p.ignoreLocation,findAllMatches:a=p.findAllMatches,location:u=p.location,threshold:l=p.threshold,distance:d=p.distance}={}){this.query=null,this.options={isCaseSensitive:s,ignoreDiacritics:n,includeMatches:i,minMatchCharLength:c,findAllMatches:a,ignoreLocation:o,location:u,threshold:l,distance:d},t=s?t:t.toLowerCase(),t=n?dt(t):t,this.pattern=t,this.query=Ne(this.pattern,this.options)}static condition(t,s){return s.useExtendedSearch}searchIn(t){const s=this.query;if(!s)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:i,ignoreDiacritics:c}=this.options;t=i?t:t.toLowerCase(),t=c?dt(t):t;let o=0,a=[],u=0;for(let l=0,d=s.length;l<d;l+=1){const h=s[l];a.length=0,o=0;for(let f=0,y=h.length;f<y;f+=1){const C=h[f],{isMatch:k,indices:D,score:b}=C.search(t);if(k){if(o+=1,u+=b,n){const N=C.constructor.type;je.has(N)?a=[...a,...D]:a.push(D)}}else{u=0,o=0,a.length=0;break}}if(o){let f={isMatch:!0,score:u/o};return n&&(f.indices=a),f}}return{isMatch:!1,score:1}}}const xt=[];function Pe(...e){xt.push(...e)}function Et(e,t){for(let s=0,n=xt.length;s<n;s+=1){let i=xt[s];if(i.condition(e,t))return new i(e,t)}return new Gt(e,t)}const ft={AND:"$and",OR:"$or"},Ct={PATH:"$path",PATTERN:"$val"},Ft=e=>!!(e[ft.AND]||e[ft.OR]),Ke=e=>!!e[Ct.PATH],Oe=e=>!et(e)&&Wt(e)&&!Ft(e),jt=e=>({[ft.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function Xt(e,t,{auto:s=!0}={}){const n=i=>{let c=Object.keys(i);const o=Ke(i);if(!o&&c.length>1&&!Ft(i))return n(jt(i));if(Oe(i)){const u=o?i[Ct.PATH]:c[0],l=o?i[Ct.PATTERN]:i[u];if(!X(l))throw new Error(de(u));const d={keyId:yt(u),pattern:l};return s&&(d.searcher=Et(l,t)),d}let a={children:[],operator:c[0]};return c.forEach(u=>{const l=i[u];et(l)&&l.forEach(d=>{a.children.push(n(d))})}),a};return Ft(e)||(e=jt(e)),n(e)}function He(e,{ignoreFieldNorm:t=p.ignoreFieldNorm}){e.forEach(s=>{let n=1;s.matches.forEach(({key:i,norm:c,score:o})=>{const a=i?i.weight:null;n*=Math.pow(o===0&&a?Number.EPSILON:o,(a||1)*(t?1:c))}),s.score=n})}function Qe(e,t){const s=e.matches;t.matches=[],H(s)&&s.forEach(n=>{if(!H(n.indices)||!n.indices.length)return;const{indices:i,value:c}=n;let o={indices:i,value:c};n.key&&(o.key=n.key.src),n.idx>-1&&(o.refIndex=n.idx),t.matches.push(o)})}function We(e,t){t.score=e.score}function ze(e,t,{includeMatches:s=p.includeMatches,includeScore:n=p.includeScore}={}){const i=[];return s&&i.push(Qe),n&&i.push(We),e.map(c=>{const{idx:o}=c,a={item:t[o],refIndex:o};return i.length&&i.forEach(u=>{u(c,a)}),a})}class G{constructor(t,s={},n){this.options={...p,...s},this.options.useExtendedSearch,this._keyStore=new ge(this.options.keys),this.setCollection(t,n)}setCollection(t,s){if(this._docs=t,s&&!(s instanceof wt))throw new Error(he);this._myIndex=s||Ut(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){H(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const s=[];for(let n=0,i=this._docs.length;n<i;n+=1){const c=this._docs[n];t(c,n)&&(this.removeAt(n),n-=1,i-=1,s.push(c))}return s}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:s=-1}={}){const{includeMatches:n,includeScore:i,shouldSort:c,sortFn:o,ignoreFieldNorm:a}=this.options;let u=X(t)?X(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return He(u,{ignoreFieldNorm:a}),c&&u.sort(o),Qt(s)&&s>-1&&(u=u.slice(0,s)),ze(u,this._docs,{includeMatches:n,includeScore:i})}_searchStringList(t){const s=Et(t,this.options),{records:n}=this._myIndex,i=[];return n.forEach(({v:c,i:o,n:a})=>{if(!H(c))return;const{isMatch:u,score:l,indices:d}=s.searchIn(c);u&&i.push({item:c,idx:o,matches:[{score:l,value:c,norm:a,indices:d}]})}),i}_searchLogical(t){const s=Xt(t,this.options),n=(a,u,l)=>{if(!a.children){const{keyId:h,searcher:f}=a,y=this._findMatches({key:this._keyStore.get(h),value:this._myIndex.getValueForItemAtKeyId(u,h),searcher:f});return y&&y.length?[{idx:l,item:u,matches:y}]:[]}const d=[];for(let h=0,f=a.children.length;h<f;h+=1){const y=a.children[h],C=n(y,u,l);if(C.length)d.push(...C);else if(a.operator===ft.AND)return[]}return d},i=this._myIndex.records,c={},o=[];return i.forEach(({$:a,i:u})=>{if(H(a)){let l=n(s,a,u);l.length&&(c[u]||(c[u]={idx:u,item:a,matches:[]},o.push(c[u])),l.forEach(({matches:d})=>{c[u].matches.push(...d)}))}}),o}_searchObjectList(t){const s=Et(t,this.options),{keys:n,records:i}=this._myIndex,c=[];return i.forEach(({$:o,i:a})=>{if(!H(o))return;let u=[];n.forEach((l,d)=>{u.push(...this._findMatches({key:l,value:o[d],searcher:s}))}),u.length&&c.push({idx:a,item:o,matches:u})}),c}_findMatches({key:t,value:s,searcher:n}){if(!H(s))return[];let i=[];if(et(s))s.forEach(({v:c,i:o,n:a})=>{if(!H(c))return;const{isMatch:u,score:l,indices:d}=n.searchIn(c);u&&i.push({score:l,key:t,value:c,idx:o,norm:a,indices:d})});else{const{v:c,n:o}=s,{isMatch:a,score:u,indices:l}=n.searchIn(c);a&&i.push({score:u,key:t,value:c,norm:o,indices:l})}return i}}G.version="7.1.0";G.createIndex=Ut;G.parseIndex=we;G.config=p;G.parseQuery=Xt;Pe(Te);const Tt={".ts":"📘",".tsx":"⚛️",".js":"📒",".jsx":"⚛️",".py":"🐍",".rs":"🦀",".go":"🔷",".md":"📝",".json":"📋",".yaml":"⚙️",".yml":"⚙️",".css":"🎨",".scss":"🎨",".html":"🌐",".sql":"🗃️",".sh":"💻",".env":"🔐",".toml":"⚙️",".lock":"🔒",default:"📄"};function Ve(e){var s;const t="."+((s=e.split(".").pop())==null?void 0:s.toLowerCase());return Tt[t]||Tt.default}function Pt(e){const t=se[e];return(t==null?void 0:t.icon)||"🤖"}function Zt(e){const t=Math.floor(e/1e3),s=Math.floor(t/60),n=Math.floor(s/60),i=Math.floor(n/24);return i>0?`${i}d ${n%24}h ago`:n>0?`${n}h ${s%60}m ago`:s>0?`${s}m ago`:"just now"}function Kt(e){const s=Date.now()-e;return Zt(s)}function Ot(e){switch(e){case"agent":return"Agent";case"command":return"Command";case"area":return"Area";case"activity":return"Activity";case"modified-file":return"Changed";case"building":return"Server";default:return e}}const Ht=["command","agent","building","area","modified-file","activity"];function Ue({isOpen:e,onClose:t,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:i,onOpenSupervisor:c,onOpenFileExplorer:o,onOpenPM2LogsModal:a,onOpenBossLogsModal:u,onOpenDatabasePanel:l,onOpenMonitoringModal:d}){const h=ne(),f=ie(),y=re(),C=ce(),k=g.useMemo(()=>{const r=O.getState().supervisor.agentHistories;let A="";for(const[F,M]of r)A+=`${F}:${M.length},`;return A},[h]),D=g.useRef(t);D.current=t;const b=g.useRef(s);b.current=s;const N=g.useRef(n);N.current=n;const z=g.useRef(i);z.current=i;const Q=g.useRef(c);Q.current=c;const at=g.useRef(o);at.current=o;const st=g.useRef(a);st.current=a;const S=g.useRef(u);S.current=u;const v=g.useRef(l);v.current=l;const j=g.useRef(d);j.current=d;const[_,W]=g.useState(""),[K,nt]=g.useState(0);g.useEffect(()=>{if(e){W(""),nt(0);const r=Array.from(h.values());for(const A of r)!O.hasHistoryBeenFetched(A.id)&&!O.isLoadingHistoryForAgent(A.id)&&O.requestAgentSupervisorHistory(A.id)}},[e,h]);const T=O.getShortcuts(),Z=g.useMemo(()=>{if(!e)return[];const r=T.find(F=>F.id==="spawn-agent"),A=T.find(F=>F.id==="toggle-commander");return[{id:"cmd-spawn",type:"command",title:"Spawn New Agent",subtitle:r?bt(r):"Alt+N",icon:"➕",action:()=>{D.current(),b.current()}},{id:"cmd-commander",type:"command",title:"Commander View",subtitle:A?bt(A):"Ctrl+K",icon:"📊",action:()=>{D.current(),N.current()}},{id:"cmd-settings",type:"command",title:"Settings & Tools",subtitle:"Configure Tide Commander",icon:"⚙️",action:()=>{D.current(),z.current()}},{id:"cmd-supervisor",type:"command",title:"Supervisor Overview",subtitle:"View agent analysis",icon:"🎖️",action:()=>{D.current(),Q.current()}},{id:"cmd-monitoring",type:"command",title:"Monitoring & Logs",subtitle:"Triggers, workflows, events",icon:"📊",action:()=>{var F;D.current(),(F=j.current)==null||F.call(j)}}]},[e,T]),ct=g.useMemo(()=>e?Array.from(h.values()).map(r=>{const A=O.getAgentSupervisorHistory(r.id),F=A.length>0?A[0]:null,M=A.map(x=>({text:`${x.analysis.statusDescription} ${x.analysis.recentWorkSummary}`,timestamp:x.timestamp})),$=(C||[]).filter(x=>x.agentId===r.id).map(x=>x.filePath),I=[...new Set($)],R=I.map(x=>x.split("/").pop()||x),B=[];r.lastAssignedTask&&B.push(r.lastAssignedTask);const Y=`${r.class} • ${r.status} • ${r.cwd}`;let J=`${r.name} ${Y}`,L,ut,E;for(const x of M)J+=` ${x.text}`;F&&(L=F.analysis.recentWorkSummary,ut=F.analysis.statusDescription,E=F.timestamp),R.length>0&&(J+=` ${R.join(" ")} ${I.join(" ")}`),B.length>0&&(J+=` ${B.join(" ")}`);const w=Date.now()-r.lastActivity;let U;return r.lastAssignedTask&&(r.lastAssignedTask.length>150?U=r.lastAssignedTask.slice(0,150)+"...":U=r.lastAssignedTask),{id:`agent-${r.id}`,type:"agent",title:r.name,subtitle:Y,lastUserInput:U,statusDescription:ut,activityText:L,matchedText:L,timeAway:w,lastStatusTime:E,icon:Pt(r.class),_searchText:J,_modifiedFiles:I,_userQueries:B,_historyEntries:M,action:()=>{D.current(),O.selectAgent(r.id)}}}):[],[e,h,k,C]),lt=g.useMemo(()=>e?Array.from(f.values()).map(r=>{var A;return{id:`area-${r.id}`,type:"area",title:r.name,subtitle:`${r.assignedAgentIds.length} agents • ${((A=r.directories)==null?void 0:A.length)||0} folders`,icon:"🗺️",action:()=>{D.current(),O.selectArea(r.id)}}}):[],[e,f]),mt=g.useMemo(()=>e?Array.from(y.values()).filter(r=>r.type==="server"||r.type==="boss"||r.type==="database").map(r=>{var R,B,Y,J;const A=r.status==="running"?"🟢":r.status==="stopped"?"🔴":"🟡",F=r.type==="boss"?"👑":r.type==="database"?"🗄️":"🖥️";let $=`${r.type==="boss"?"Boss":r.type==="database"?"Database":"Server"} • ${r.status}`;if(r.type==="database"&&((B=(R=r.database)==null?void 0:R.connections)!=null&&B.length)){const L=r.database.connections[0];$+=` • ${L.engine} @ ${L.host}`}else r.cwd&&($+=` • ${r.cwd}`);let I=`${r.name} ${r.type} ${r.status} ${r.cwd||""} ${((Y=r.pm2)==null?void 0:Y.name)||""}`;if(r.type==="database"&&((J=r.database)!=null&&J.connections))for(const L of r.database.connections)I+=` ${L.name} ${L.engine} ${L.host} ${L.database||""} mysql postgresql sql`;return{id:`building-${r.id}`,type:"building",title:r.name,subtitle:$,icon:`${A} ${F}`,_searchText:I,action:()=>{var L;D.current(),r.type==="boss"?S.current(r.id):r.type==="database"?v.current(r.id):(L=r.pm2)!=null&&L.enabled&&st.current(r.id)}}}):[],[e,y]),vt=g.useMemo(()=>{if(!e)return[];const r=C||[],A=new Set,F=[];for(const M of r){if(A.has(M.filePath))continue;A.add(M.filePath);const $=M.filePath.split("/").pop()||M.filePath,I=M.action==="created"?"Created":M.action==="modified"?"Modified":M.action==="deleted"?"Deleted":"Read";if(F.push({id:`modified-${M.filePath}-${M.timestamp}`,type:"modified-file",title:$,subtitle:`${I} by ${M.agentName} • ${M.filePath}`,matchedText:M.filePath,icon:M.action==="deleted"?"🗑️":Ve(M.filePath),action:()=>{D.current();const R=Array.from(O.getState().areas.values());for(const B of R)for(const Y of B.directories||[])if(M.filePath.startsWith(Y)){O.setFileViewerPath(M.filePath),at.current(B.id);return}O.selectAgent(M.agentId)}}),F.length>=50)break}return F},[e,C]),Dt=g.useMemo(()=>{if(!e)return[];const r=[],A=Array.from(h.values());for(const F of A){const M=O.getAgentSupervisorHistory(F.id);if(M.length>0){const $=M[0],I=$.analysis;r.push({id:`activity-${F.id}-${$.timestamp}`,type:"activity",title:F.name,subtitle:I.statusDescription,activityText:I.recentWorkSummary,matchedText:I.recentWorkSummary,icon:Pt(F.class),action:()=>{D.current(),O.selectAgent(F.id)}})}}return r},[e,h,k]),St=g.useMemo(()=>new G(ct,{keys:["title","subtitle","_searchText","activityText","lastUserInput"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[ct]),Bt=g.useMemo(()=>new G(Z,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[Z]),It=g.useMemo(()=>new G(lt,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[lt]),kt=g.useMemo(()=>new G(vt,{keys:["title","subtitle","matchedText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[vt]),$t=g.useMemo(()=>new G(Dt,{keys:["title","subtitle","matchedText","activityText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[Dt]),qt=g.useMemo(()=>new G(mt,{keys:["title","subtitle","_searchText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[mt]),V=g.useMemo(()=>{if(!_.trim()){const E=[];E.push(...mt);const w=[...ct].sort((x,P)=>{const q=x.timeAway??0,tt=P.timeAway??0;return q-tt});E.push(...w),E.push(...Z.slice(0,2)),E.push(...lt.slice(0,2));const U={};return Ht.forEach((x,P)=>{U[x]=P}),E.sort((x,P)=>(U[x.type]??999)-(U[P.type]??999)),E}const r=_.toLowerCase(),A=St.search(_).slice(0,8),F=Bt.search(_).slice(0,3),M=It.search(_).slice(0,2),$=kt.search(_).slice(0,3),I=$t.search(_).slice(0,3),R=qt.search(_).filter(E=>{const w=E.score??1;return`${E.item.title} ${E.item.subtitle||""} ${E.item._searchText||""}`.toLowerCase().includes(r)||w<=.2}).slice(0,4),B=[],Y=[],J=[];for(const E of A){const w={...E.item};if(w._modifiedFiles&&w._modifiedFiles.length>0){const x=w._modifiedFiles.filter(P=>{var it;const q=((it=P.split("/").pop())==null?void 0:it.toLowerCase())||"",tt=P.toLowerCase();return q.includes(r)||tt.includes(r)});x.length>0&&(w.matchedFiles=x)}if(w._userQueries&&w._userQueries.length>0){const x=w._userQueries.find(P=>P.toLowerCase().includes(r));if(x)if(x.length>200){const q=x.toLowerCase().indexOf(r),tt=Math.max(0,q-60),it=Math.min(x.length,q+r.length+100);w.matchedQuery=(tt>0?"...":"")+x.slice(tt,it)+(it<x.length?"...":"")}else w.matchedQuery=x}if(w._historyEntries&&w._historyEntries.length>0){const x=w._historyEntries.find(P=>P.text.toLowerCase().includes(r));if(x)if(x.text.length>250){const q=x.text.toLowerCase().indexOf(r),tt=Math.max(0,q-80),it=Math.min(x.text.length,q+r.length+120);w.matchedHistory={text:(tt>0?"...":"")+x.text.slice(tt,it)+(it<x.text.length?"...":""),timestamp:x.timestamp}}else w.matchedHistory=x}const U=w.title.toLowerCase();U===r||U.startsWith(r)?Y.push(w):J.push(w)}for(const E of Y)B.push(E);for(const E of R)B.push(E.item);for(const E of J)B.push(E);for(const E of F)B.push(E.item);for(const E of M)B.push(E.item);for(const E of $)B.push(E.item);const L=new Set(A.map(E=>E.item.id));for(const E of I){const w=E.item.id.replace("activity-","").split("-")[0];L.has(`agent-${w}`)||B.push(E.item)}const ut={};return Ht.forEach((E,w)=>{ut[E]=w}),B.sort((E,w)=>(ut[E.type]??999)-(ut[w.type]??999)),B},[_,St,Bt,It,kt,$t,Z,ct,lt]);g.useEffect(()=>{K>=V.length&&nt(Math.max(0,V.length-1))},[V.length,K]);const te=g.useCallback(r=>{if(r.altKey&&!r.ctrlKey&&!r.metaKey&&(r.key==="p"||r.key==="n"||r.key==="P"||r.key==="N")){r.preventDefault(),r.stopPropagation(),r.nativeEvent.stopImmediatePropagation();const A=r.key.toLowerCase();nt(A==="p"?F=>F>0?F-1:V.length-1:F=>F<V.length-1?F+1:0);return}switch(r.key){case"Escape":r.preventDefault(),D.current();break;case"ArrowUp":r.preventDefault(),nt(A=>A>0?A-1:V.length-1);break;case"ArrowDown":r.preventDefault(),nt(A=>A<V.length-1?A+1:0);break;case"Enter":r.preventDefault(),V[K]&&V[K].action();break}},[V,K]),ee=g.useCallback((r,A)=>{if(!A||!r)return r;const F=r.toLowerCase(),M=A.toLowerCase(),$=[];let I=0,R=F.indexOf(M),B=0;for(;R!==-1;)R>I&&$.push(r.slice(I,R)),$.push(pt.createElement("mark",{key:B++,className:"spotlight-highlight"},r.slice(R,R+A.length))),I=R+A.length,R=F.indexOf(M,I);return I<r.length&&$.push(r.slice(I)),$.length>0?pt.createElement(pt.Fragment,null,...$):r},[]);return{query:_,setQuery:W,selectedIndex:K,setSelectedIndex:nt,results:V,handleKeyDown:te,highlightMatch:ee}}const Ge=g.forwardRef(function({query:t,onQueryChange:s,onKeyDown:n,onResetSelection:i},c){const{t:o}=Mt(["common"]);return m.jsxs("div",{className:"spotlight-input-wrapper",children:[m.jsx("span",{className:"spotlight-search-icon",children:"⌘"}),m.jsx("input",{ref:c,type:"text",className:"spotlight-input",placeholder:o("common:search.spotlightPlaceholder"),value:t,onChange:a=>{s(a.target.value),i()},onKeyDown:n,autoFocus:!0,spellCheck:!1}),m.jsxs("div",{className:"spotlight-input-hints",children:[m.jsx("span",{className:"spotlight-shortcut-hint",children:"↑↓"}),m.jsx("span",{className:"spotlight-shortcut-hint",children:"Enter"}),m.jsx("span",{className:"spotlight-shortcut-hint",children:"Esc"})]})]})}),Ye=g.memo(function({result:t,isSelected:s,query:n,highlightMatch:i,onClick:c,onMouseEnter:o}){const a=t.activityText||t.statusDescription||t.matchedFiles&&t.matchedFiles.length>0||t.matchedQuery||t.matchedHistory;return m.jsxs("div",{className:`spotlight-item ${s?"selected":""} ${t.activityText?"has-activity":""}`,onClick:c,onMouseEnter:o,role:"option","aria-selected":s,children:[m.jsx("span",{className:"spotlight-item-icon","aria-hidden":"true",children:t.icon}),m.jsxs("div",{className:"spotlight-item-content",children:[m.jsxs("div",{className:"spotlight-item-header",children:[m.jsx("span",{className:"spotlight-item-title",children:i(t.title,n)}),m.jsx("span",{className:`spotlight-item-type ${t.type}`,"aria-label":Ot(t.type),children:Ot(t.type)})]}),t.subtitle&&m.jsx("span",{className:"spotlight-item-subtitle",children:i(t.subtitle,n)}),t.statusDescription&&m.jsx("span",{className:"spotlight-item-status",children:i(t.statusDescription,n)}),t.activityText&&m.jsx("span",{className:"spotlight-item-activity",children:i(t.activityText,n)}),a&&m.jsxs("div",{className:"spotlight-item-details",children:[t.matchedFiles&&t.matchedFiles.length>0&&m.jsx("span",{className:"spotlight-item-files",children:t.matchedFiles.map((u,l)=>m.jsxs("span",{className:"file-badge",children:[l>0&&m.jsx("span",{className:"file-separator",children:"•"}),i(u.split("/").pop()||u,n)]},u))}),t.matchedQuery&&m.jsx("span",{className:"spotlight-item-query",children:i(t.matchedQuery,n)}),t.matchedHistory&&m.jsxs("span",{className:"spotlight-item-history",children:[i(t.matchedHistory.text,n),m.jsx("span",{className:"spotlight-history-time",children:Kt(t.matchedHistory.timestamp)})]})]}),(t.timeAway!==void 0||t.lastStatusTime!==void 0)&&m.jsxs("span",{className:"spotlight-item-time",children:[t.timeAway!==void 0&&m.jsxs("span",{className:"spotlight-time-away",children:["Idle: ",Zt(t.timeAway)]}),t.lastStatusTime!==void 0&&m.jsxs("span",{className:"spotlight-status-time",children:["Updated ",Kt(t.lastStatusTime)]})]}),t.lastUserInput&&!t.matchedQuery&&m.jsxs("span",{className:"spotlight-item-last-input",children:['"',i(t.lastUserInput,n),'"']})]})]})}),Je=g.forwardRef(function({results:t,selectedIndex:s,query:n,highlightMatch:i,onSelectIndex:c},o){const{t:a}=Mt(["terminal"]),u=g.useRef(!1);g.useEffect(()=>{u.current=!1},[t]),g.useEffect(()=>{const h=typeof o=="function"?null:o==null?void 0:o.current;if(!h)return;const f=()=>{u.current=!0};return h.addEventListener("mousemove",f),()=>{h.removeEventListener("mousemove",f)}},[o,t]);const l={command:a("terminal:spotlight.categories.commands"),agent:a("terminal:spotlight.categories.agents"),building:a("terminal:spotlight.categories.infrastructure"),area:a("terminal:spotlight.categories.areas"),"modified-file":a("terminal:spotlight.categories.modifiedFiles"),activity:a("terminal:spotlight.categories.recentActivity")},d=g.useMemo(()=>{const h=[];let f=null,y=[];return t.forEach((C,k)=>{C.type!==f&&(f!==null&&y.length>0&&h.push([f,y]),f=C.type,y=[]),y.push({result:C,index:k})}),f!==null&&y.length>0&&h.push([f,y]),h},[t]);return g.useEffect(()=>{if(!o||typeof o=="function")return;const h=o.current;if(!h)return;const f=h.querySelector(".spotlight-item.selected");f&&f.scrollIntoView({block:"nearest",behavior:"smooth"})},[s,o]),t.length===0?m.jsx("div",{className:"spotlight-results",ref:o,children:m.jsx("div",{className:"spotlight-empty",children:a("terminal:spotlight.noResults")})}):m.jsx("div",{className:"spotlight-results",ref:o,children:d.map(([h,f])=>m.jsxs("div",{children:[d.length>1&&m.jsx("div",{className:"spotlight-category-header",children:l[h]||h}),f.map(({result:y,index:C})=>m.jsx(Ye,{result:y,isSelected:C===s,query:n,highlightMatch:i,onClick:()=>y.action(),onMouseEnter:()=>{u.current&&c(C)}},y.id))]},h))})}),Xe=g.memo(function(){const{t}=Mt(["terminal"]);return m.jsxs("div",{className:"spotlight-footer",children:[m.jsxs("div",{className:"spotlight-footer-left",children:[m.jsxs("span",{className:"spotlight-footer-hint",children:[m.jsx("kbd",{children:"↑"}),m.jsx("kbd",{children:"↓"})," ",m.jsx("kbd",{children:"Alt+N"}),m.jsx("kbd",{children:"Alt+P"})," ",t("terminal:spotlight.navigate")]}),m.jsxs("span",{className:"spotlight-footer-hint",children:[m.jsx("kbd",{children:"Enter"})," ",t("terminal:spotlight.select")]})]}),m.jsx("div",{className:"spotlight-footer-right",children:m.jsxs("span",{className:"spotlight-footer-hint",children:[m.jsx("kbd",{children:"Esc"})," ",t("common:buttons.close")]})})]})});function ss({isOpen:e,onClose:t,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:i,onOpenSupervisor:c,onOpenFileExplorer:o,onOpenPM2LogsModal:a,onOpenBossLogsModal:u,onOpenDatabasePanel:l,onOpenMonitoringModal:d}){const h=g.useRef(null),f=g.useRef(null),y=g.useRef(0),{query:C,setQuery:k,selectedIndex:D,setSelectedIndex:b,results:N,handleKeyDown:z,highlightMatch:Q}=Ue({isOpen:e,onClose:t,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:i,onOpenSupervisor:c,onOpenFileExplorer:o,onOpenPM2LogsModal:a,onOpenBossLogsModal:u,onOpenDatabasePanel:l,onOpenMonitoringModal:d});y.current=N.length,g.useEffect(()=>{e&&setTimeout(()=>{var S;(S=h.current)==null||S.focus()},50)},[e]),g.useEffect(()=>{if(!e)return;const S=v=>{if(v.key==="Escape"){v.preventDefault(),v.stopPropagation(),v.stopImmediatePropagation(),t();return}if(v.altKey&&!v.ctrlKey&&!v.metaKey&&(v.key==="n"||v.key==="p"||v.key==="N"||v.key==="P")){v.preventDefault(),v.stopPropagation(),v.stopImmediatePropagation();const j=v.key.toLowerCase(),_=y.current;b(j==="p"?W=>W>0?W-1:_-1:W=>W<_-1?W+1:0);return}};return window.addEventListener("keydown",S,{capture:!0}),()=>{window.removeEventListener("keydown",S,{capture:!0})}},[e,t]);const at=g.useCallback(S=>{S.target===S.currentTarget&&t()},[t]),st=g.useCallback(()=>{b(0)},[b]);return e?m.jsx("div",{className:"spotlight-overlay",onClick:at,children:m.jsxs("div",{className:"spotlight-modal",children:[m.jsx(Ge,{ref:h,query:C,onQueryChange:k,onKeyDown:z,onResetSelection:st}),m.jsx(Je,{ref:f,results:N,selectedIndex:D,query:C,highlightMatch:Q,onSelectIndex:b}),m.jsx(Xe,{})]})}):null}export{Tt as FILE_ICONS,ss as Spotlight,Xe as SpotlightFooter,Ge as SpotlightInput,Ye as SpotlightItem,Je as SpotlightResults,Zt as formatDuration,Kt as formatRelativeTime,Pt as getAgentIcon,Ve as getFileIconFromPath,Ot as getTypeLabel,Ue as useSpotlightSearch};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/web-DQ10iSod.js","assets/main-DULfVodw.js","assets/modulepreload-polyfill-B5Qt9EMX.js","assets/vendor-react--Eh9ivFN.js","assets/vendor-three-Chj50gSY.js","assets/main-CUx2B9bn.css"])))=>i.map(i=>d[i]);
2
- import{bm as e,aN as o}from"./main-DULfVodw.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-DQ10iSod.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-BXQj42md.js","assets/main-BSyGZK2z.js","assets/modulepreload-polyfill-B5Qt9EMX.js","assets/vendor-react--Eh9ivFN.js","assets/vendor-three-Chj50gSY.js","assets/main-BFSqr5mR.css"])))=>i.map(i=>d[i]);
2
+ import{bm as e,aN as o}from"./main-BSyGZK2z.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-BXQj42md.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 +1 @@
1
- import{z as ts,u as ns,B as _s,j as e,C as Is,E as Ms,G as Es,r as g,H as $s,I as Ds,J as Ss,K as Ls,s as Y,m as B}from"./main-DULfVodw.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Xs=1,gs=Xs*2.5;function Rs(s,v,d){const l=v.filter(o=>o.position&&!isNaN(o.position.x)&&!isNaN(o.position.z));let t,i,n,u;if(s.type==="rectangle"){const o=(s.width||10)/2,N=(s.height||10)/2;t=s.center.x-o,i=s.center.x+o,n=s.center.z-N,u=s.center.z+N}else{const o=s.radius||5;t=s.center.x-o,i=s.center.x+o,n=s.center.z-o,u=s.center.z+o}const b=2;if(t+=b,i-=b,n+=b,u-=b,d){const o={...d};if(o.x=Math.max(t,Math.min(i,o.x)),o.z=Math.max(n,Math.min(u,o.z)),fs(o,l,s))return o}const x=(t+i)/2,S=(n+u)/2,j=Math.min(i-x,u-S);for(let o=0;o<j;o+=gs*.5)for(let N=0;N<Math.PI*2;N+=Math.PI/8){const C=x+Math.cos(N)*o,E=S+Math.sin(N)*o,_={x:C,z:E};if(_.x=Math.max(t,Math.min(i,_.x)),_.z=Math.max(n,Math.min(u,_.z)),fs(_,l,s))return _}return{x,z:S}}function fs(s,v,d){for(const l of v){if(!l.position)continue;if(Math.hypot(s.x-l.position.x,s.z-l.position.z)<gs)return!1}if(d.type==="rectangle"){const l=(d.width||10)/2,t=(d.height||10)/2,i=s.x>=d.center.x-l+1&&s.x<=d.center.x+l-1,n=s.z>=d.center.z-t+1&&s.z<=d.center.z+t-1;return i&&n}else{const l=(d.radius||5)-1;return Math.hypot(s.x-d.center.x,s.z-d.center.z)<=l}}function vs(s){switch(s){case"idle":case"running":return"healthy";case"working":case"waiting":case"waiting_permission":case"starting":case"stopping":return"working";case"error":case"offline":case"orphaned":case"stopped":return"error";default:return"unknown"}}function Ps(s){switch(s){case"scout":return"🔍";case"builder":return"🔨";case"debugger":return"🐛";case"architect":return"📐";case"warrior":return"⚔️";case"support":return"🛟";case"boss":return"👑";default:return"🤖"}}function Us(s){switch(s){case"server":return"🖥️";case"link":return"🔗";case"database":return"🗄️";case"docker":return"🐳";case"monitor":return"📊";case"folder":return"📁";case"boss":return"🏰";default:return"🏢"}}function Ys(s,v){const d=[],l=new Set;for(const i of v.values()){if(i.archived)continue;const n=[];for(const u of i.assignedAgentIds){const b=s.get(u);b&&(n.push(b),l.add(u))}d.push({area:i,agents:n,label:i.name,color:i.color})}d.sort((i,n)=>i.label.localeCompare(n.label));const t=[];for(const i of s.values())l.has(i.id)||t.push(i);return t.length>0&&d.push({area:null,agents:t,label:"Unassigned",color:"#555"}),d}function Gs(s,v){const d=[],l=[],t=[];for(const n of s.values())n.status==="working"||n.status==="waiting"||n.status==="waiting_permission"?d.push(n):n.status==="error"||n.status==="offline"||n.status==="orphaned"?t.push(n):v&&v.has(n.id)?d.push(n):l.push(n);const i=[];return t.length>0&&i.push({area:null,agents:t,label:"Errors",color:"#d64545"}),d.length>0&&i.push({area:null,agents:d,label:"Working & Unseen",color:"#f5d76e"}),l.length>0&&i.push({area:null,agents:l,label:"Idle",color:"#5cb88a"}),i}function Hs(s){const v=Date.now(),l=[...Array.from(s.values())].sort((o,N)=>(N.lastActivity||0)-(o.lastActivity||0)),t=[],i=[],n=[],u=[],b=300*1e3,x=3600*1e3,S=1440*60*1e3;for(const o of l){const N=v-(o.lastActivity||0);N<b?t.push(o):N<x?i.push(o):N<S?n.push(o):u.push(o)}const j=[];return t.length>0&&j.push({area:null,agents:t,label:"Just Now (< 5m)",color:"#4ade80"}),i.length>0&&j.push({area:null,agents:i,label:"Recent (5m - 1h)",color:"#60a5fa"}),n.length>0&&j.push({area:null,agents:n,label:"Stale (1h - 1d)",color:"#facc15"}),u.length>0&&j.push({area:null,agents:u,label:"Very Stale (> 1d)",color:"#f87171"}),j}function Zs(s){return s.contextLimit<=0?0:Math.round(s.contextUsed/s.contextLimit*100)}function Bs(s){return s>=80?"red":s>=50?"yellow":"green"}function ms(s){return as(s)}function as(s,v={}){const{prioritizeRecentlyIdle:d=!1}=v;return[...s].sort((l,t)=>{const i={error:0,offline:0,orphaned:0,working:1,waiting:1,waiting_permission:1,idle:2},n=i[l.status]??3,u=i[t.status]??3;if(n!==u)return n-u;if(d&&l.status==="idle"&&t.status==="idle"){const b=!!l.taskLabel,x=!!t.taskLabel;return b!==x?b?-1:1:(t.lastActivity||0)-(l.lastActivity||0)}return l.name.localeCompare(t.name)})}const bs=ts.memo(({agent:s,isSelected:v,isKeyboardFocused:d=!1,onSelect:l,onDoubleClick:t,onChat:i,onFocus:n,onKill:u,onDragStart:b})=>{const{t:x}=ns(["dashboard","common"]),j=_s().has(s.id),o=vs(s.status),N=Ps(s.class),C=Zs(s),E=Bs(C),_=s.taskLabel?`📋 ${s.taskLabel}`:s.currentTask||s.lastAssignedTask,X=s.status==="idle"&&s.lastActivity>0,[,F]=ts.useState(0);return ts.useEffect(()=>{if(!X)return;const z=window.setInterval(()=>F(I=>I+1),15e3);return()=>window.clearInterval(z)},[X]),e.jsxs("div",{className:`dash-card dash-card--${o} ${v?"dash-card--selected":""} ${d?"dash-card--keyboard-focused":""}`,"data-agent-id":s.id,onClick:l,onDoubleClick:z=>{z.stopPropagation(),t()},onDragStart:z=>{b==null||b(s),z.dataTransfer.effectAllowed="move"},draggable:!0,title:x("cards.doubleClickHint"),children:[e.jsxs("div",{className:"dash-card__row1",children:[e.jsx("span",{className:`dash-card__status-dot dash-card__status-dot--${o}`}),e.jsx("span",{className:"dash-card__name",children:s.name}),e.jsxs("span",{className:"dash-card__class",children:[N," ",s.class]}),e.jsxs("span",{className:`dash-card__provider dash-card__provider--${s.provider}`,children:[s.provider==="codex"?"🔸":s.provider==="opencode"?"🟢":"🤖"," ",s.provider]}),j&&e.jsx("span",{className:"dash-card__unseen-badge",title:"New output available - click to view",children:"!"})]}),e.jsxs("div",{className:"dash-card__row2",children:[e.jsx("span",{className:`dash-card__status dash-card__status--${o}`,children:j?"Unseen":s.status}),e.jsxs("div",{className:"dash-card__context",children:[e.jsx("div",{className:"dash-card__context-bar",children:e.jsx("div",{className:`dash-card__context-fill dash-card__context-fill--${E}`,style:{width:`${C}%`}})}),e.jsxs("span",{className:`dash-card__context-pct dash-card__context-pct--${E}`,children:[C,"%"]})]})]}),e.jsxs("div",{className:"dash-card__row3",children:[e.jsxs("span",{className:"dash-card__workdir",title:s.cwd,children:["📁 ",s.cwd.split("/").pop()||s.cwd]}),X&&e.jsxs("span",{className:"dash-card__idle-time",style:{color:Es(s.lastActivity)},title:Ms(s.lastActivity),children:["⏱ ",Is(s.lastActivity)]})]}),_&&e.jsx("div",{className:"dash-card__row4",children:e.jsx("span",{className:"dash-card__task",children:_})}),e.jsxs("div",{className:"dash-card__actions",children:[i&&e.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--chat",onClick:z=>{z.stopPropagation(),i()},title:x("cards.openTerminal"),children:x("cards.chat")}),u&&e.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--danger",onClick:z=>{z.stopPropagation(),u()},title:x("cards.killAgent"),children:x("cards.stop")})]})]})});bs.displayName="AgentCard";const ps=({buildings:s,onSelectBuilding:v})=>{const{t:d}=ns(["dashboard"]),l=g.useMemo(()=>Array.from(s.values()).sort((t,i)=>t.name.localeCompare(i.name)),[s]);return e.jsxs("div",{className:"dashboard-view__buildings",children:[e.jsxs("div",{className:"dashboard-view__buildings-header",children:[e.jsx("span",{className:"dashboard-view__buildings-title",children:d("buildings.title")}),e.jsx("span",{className:"dashboard-view__buildings-count",children:l.length})]}),e.jsx("div",{className:"dashboard-view__buildings-row",children:l.map(t=>{const i=vs(t.status),n=Us(t.type);return e.jsxs("button",{className:`dash-pill dash-pill--${i}`,onClick:()=>v==null?void 0:v(t.id),title:`${t.name} (${t.type}) - ${t.status}`,children:[e.jsx("span",{className:"dash-pill__icon",children:n}),e.jsx("span",{className:"dash-pill__name",children:t.name}),e.jsx("span",{className:`dash-pill__dot dash-pill__dot--${i}`})]},t.id)})})]})};ps.displayName="BuildingPills";function Ks({onSelectAgent:s,onFocusAgent:v,onKillAgent:d,onSelectBuilding:l,onOpenTerminal:t,onFocusZone:i}){const{t:n}=ns(["dashboard","common"]),u=$s(),b=Ds(),x=Ss(),S=Ls(),j=_s(),[o,N]=g.useState(""),[C,E]=g.useState("all"),[_,X]=g.useState("zone"),[F,z]=g.useState(new Set),[I,J]=g.useState(null),[ws,V]=g.useState(null),[G,Q]=g.useState(!1),[M,T]=g.useState(null),W=g.useMemo(()=>{const a=Array.from(u.values());return{total:a.length,working:a.filter(h=>h.status==="working"||h.status==="waiting"||h.status==="waiting_permission").length,idle:a.filter(h=>h.status==="idle").length,error:a.filter(h=>h.status==="error"||h.status==="offline"||h.status==="orphaned").length}},[u]),rs=g.useMemo(()=>_==="zone"?Ys(u,x):_==="status"?Gs(u,j):Hs(u),[u,x,_,j]),K=g.useMemo(()=>{const a=o.toLowerCase().trim(),h=rs.map(p=>({...p,agents:p.agents.filter(k=>{if(C==="working"){if(k.status!=="working"&&k.status!=="waiting"&&k.status!=="waiting_permission")return!1}else if(C==="error"&&k.status!=="error"&&k.status!=="offline"&&k.status!=="orphaned")return!1;return!(a&&!k.name.toLowerCase().includes(a)&&!k.class.toLowerCase().includes(a))})}));return _==="zone"?h:h.filter(p=>p.agents.length>0)},[rs,C,o,_]),O=g.useCallback(a=>a.area?`area:${a.area.id}`:`${_}:${a.label}`,[_]),$=g.useMemo(()=>{const a=[];return K.forEach(h=>{const p=O(h);if(F.has(p))return;const k=_==="status"?as(h.agents,{prioritizeRecentlyIdle:!0}):ms(h.agents);a.push(...k)}),a},[K,F,_,O]),xs=g.useCallback(a=>{z(h=>{const p=new Set(h);return p.has(a)?p.delete(a):p.add(a),p})},[]),Ns=g.useCallback(a=>{t==null||t(a)},[t]),ks=g.useCallback(a=>{J(a)},[]),js=g.useCallback((a,h)=>{a.preventDefault(),a.dataTransfer.dropEffect="move",V(h)},[]),ys=g.useCallback(()=>{V(null)},[]),Cs=g.useCallback(a=>{if(!I)return;if(a===null){const R=Y.getState(),r=Array.from(R.areas.values()).find(c=>c.assignedAgentIds.includes(I.id));r&&Y.unassignAgentFromArea(I.id,r.id),J(null),V(null);return}const h=x.get(a);if(!h)return;const p=Array.from(u.values()),k=Rs(h,p,I.position);Y.updateAgent({...I,position:{...I.position,x:k.x,z:k.z}}),Y.assignAgentToArea(I.id,a),J(null),V(null)},[I,x,u]);return g.useEffect(()=>{if($.length===0){Q(!1),T(null);return}G&&(!M||!$.some(a=>a.id===M))&&(T($[0].id),s==null||s($[0].id))},[$,G,M,s]),g.useEffect(()=>{const a=r=>r instanceof HTMLElement?r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.tagName==="SELECT"||r.isContentEditable:!1,h=r=>r instanceof HTMLElement?!!r.closest(".guake-terminal")||r.classList.contains("guake-input")||r.classList.contains("agent-panel-input"):!1,p=r=>{const c=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).find(L=>L.dataset.agentId===r);c==null||c.scrollIntoView({block:"nearest",inline:"nearest"})},k=(r,c)=>{var os,cs,ds,ls,us,hs;const L=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).map(f=>{const w=f.dataset.agentId;if(!w)return null;const D=f.getBoundingClientRect();return{id:w,centerX:D.left+D.width/2,centerY:D.top+D.height/2,height:D.height}}).filter(f=>f!==null).sort((f,w)=>f.centerY-w.centerY||f.centerX-w.centerX);if(L.length===0)return r;const ss=L.reduce((f,w)=>f+w.height,0)/L.length,es=Math.max(18,ss*.6),A=[];for(const f of L){const w=A[A.length-1];if(!w){A.push([{id:f.id,centerX:f.centerX,centerY:f.centerY}]);continue}const D=w.reduce((As,zs)=>As+zs.centerY,0)/w.length;Math.abs(f.centerY-D)<=es?w.push({id:f.id,centerX:f.centerX,centerY:f.centerY}):A.push([{id:f.id,centerX:f.centerX,centerY:f.centerY}])}A.forEach(f=>f.sort((w,D)=>w.centerX-D.centerX));const H=A.findIndex(f=>f.some(w=>w.id===r));if(H===-1)return((cs=(os=A[0])==null?void 0:os[0])==null?void 0:cs.id)??r;const P=A[H],y=P.findIndex(f=>f.id===r);if(y===-1)return((ls=(ds=A[0])==null?void 0:ds[0])==null?void 0:ls.id)??r;if(c==="left")return((us=P[Math.max(0,y-1)])==null?void 0:us.id)??r;if(c==="right")return((hs=P[Math.min(P.length-1,y+1)])==null?void 0:hs.id)??r;const q=c==="up"?Math.max(0,H-1):Math.min(A.length-1,H+1),m=A[q],Z=P[y].centerX;let U=m[0],is=Math.abs(U.centerX-Z);for(const f of m){const w=Math.abs(f.centerX-Z);w<is&&(U=f,is=w)}return(U==null?void 0:U.id)??r},R=r=>{const c=Y.getShortcuts(),L=c.find(m=>m.id==="dashboard-selector-toggle"),ss=c.find(m=>m.id==="dashboard-vim-left"),es=c.find(m=>m.id==="dashboard-vim-down"),A=c.find(m=>m.id==="dashboard-vim-up"),H=c.find(m=>m.id==="dashboard-vim-right"),P=c.find(m=>m.id==="open-terminal"),y=Y.getState();if(a(r.target))if(!y.terminalOpen&&h(r.target)&&document.activeElement instanceof HTMLElement)document.activeElement.blur();else return;if(B(r,L)){if($.length===0)return;r.preventDefault(),r.stopPropagation(),Q(!0),T(m=>{const Z=m&&$.some(U=>U.id===m)?m:$[0].id;return s==null||s(Z),window.setTimeout(()=>p(Z),0),Z});return}const q=B(r,ss)||r.key==="ArrowLeft"?"left":B(r,es)||r.key==="ArrowDown"?"down":B(r,A)||r.key==="ArrowUp"?"up":B(r,H)||r.key==="ArrowRight"?"right":null;if(q&&G&&M){r.preventDefault(),r.stopPropagation();const m=k(M,q);m!==M&&(T(m),s==null||s(m),window.setTimeout(()=>p(m),0));return}if(B(r,P)){if(y.terminalOpen)return;if(G&&M&&y.agents.has(M)){r.preventDefault(),t==null||t(M);return}if(y.selectedAgentIds.size===1){r.preventDefault();const m=Array.from(y.selectedAgentIds)[0];t==null||t(m);return}if(y.lastSelectedAgentId&&y.agents.has(y.lastSelectedAgentId)){r.preventDefault(),t==null||t(y.lastSelectedAgentId);return}}};return document.addEventListener("keydown",R,!0),()=>document.removeEventListener("keydown",R,!0)},[$,G,M,t,s]),g.useEffect(()=>{const a=document.activeElement;a instanceof HTMLElement&&a.closest(".guake-terminal")&&!Y.getState().terminalOpen&&a.blur()},[]),e.jsxs("div",{className:"dashboard-view",children:[e.jsxs("div",{className:"dashboard-view__topbar",children:[e.jsxs("div",{className:"dashboard-view__metrics",children:[e.jsxs("button",{className:`dashboard-view__metric-btn ${C==="all"?"dashboard-view__metric-btn--active":""}`,onClick:()=>E("all"),children:[e.jsx("span",{className:"dashboard-view__metric-value",children:W.total}),e.jsx("span",{className:"dashboard-view__metric-label",children:n("common:labels.agents")})]}),e.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--working ${C==="working"?"dashboard-view__metric-btn--active":""}`,onClick:()=>E("working"),children:[e.jsx("span",{className:"dashboard-view__metric-value",children:W.working}),e.jsx("span",{className:"dashboard-view__metric-label",children:n("common:status.working")})]}),e.jsxs("button",{className:"dashboard-view__metric-btn dashboard-view__metric-btn--idle ",onClick:()=>E("all"),children:[e.jsx("span",{className:"dashboard-view__metric-value",children:W.idle}),e.jsx("span",{className:"dashboard-view__metric-label",children:n("common:status.idle")})]}),e.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--error ${C==="error"?"dashboard-view__metric-btn--active":""}`,onClick:()=>E("error"),children:[e.jsx("span",{className:"dashboard-view__metric-value",children:W.error}),e.jsx("span",{className:"dashboard-view__metric-label",children:n("common:status.error")})]})]}),e.jsx("input",{className:"dashboard-view__search",type:"text",placeholder:n("searchPlaceholder"),value:o,onChange:a=>N(a.target.value)})]}),e.jsxs("div",{className:"dashboard-view__grouping",children:[e.jsx("button",{className:`dashboard-view__grouping-btn ${_==="zone"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>X("zone"),children:n("grouping.byZone")}),e.jsx("button",{className:`dashboard-view__grouping-btn ${_==="status"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>X("status"),children:n("grouping.byStatus")}),e.jsx("button",{className:`dashboard-view__grouping-btn ${_==="activity"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>X("activity"),children:n("grouping.byActivity")})]}),e.jsxs("div",{className:"dashboard-view__content",children:[K.map(a=>{const h=O(a),p=F.has(h),k=_==="status"?as(a.agents,{prioritizeRecentlyIdle:!0}):ms(a.agents),R=a.agents.filter(c=>c.status==="working"||c.status==="waiting"||c.status==="waiting_permission").length,r=a.agents.filter(c=>j.has(c.id)).length;return e.jsxs("div",{className:`dashboard-view__zone ${ws===(a.area?a.area.id:null)&&I?"dashboard-view__zone--drag-over":""}`,onDragOver:c=>js(c,a.area?a.area.id:null),onDragLeave:ys,onDrop:()=>Cs(a.area?a.area.id:null),children:[e.jsxs("div",{className:"dashboard-view__zone-header",onClick:()=>xs(h),children:[e.jsxs("div",{className:"dashboard-view__zone-left",children:[e.jsx("span",{className:`dashboard-view__zone-chevron ${p?"dashboard-view__zone-chevron--collapsed":""}`,children:"▼"}),e.jsx("span",{className:"dashboard-view__zone-dot",style:{backgroundColor:a.color}}),e.jsx("span",{className:"dashboard-view__zone-name",children:a.label}),e.jsxs("span",{className:"dashboard-view__zone-count",children:[n("agentCount",{count:a.agents.length}),R>0&&e.jsxs("span",{className:"dashboard-view__zone-working",children:[" · ",R," ",n("working")]}),r>0&&e.jsxs("span",{className:"dashboard-view__zone-unseen",children:[" · ",r," Unseen"]})]})]}),a.area&&i&&e.jsx("button",{className:"dashboard-view__zone-focus",onClick:c=>{c.stopPropagation(),i(a.area.id)},title:n("focusZone"),children:n("focusZone")})]}),!p&&e.jsx("div",{className:"dashboard-view__zone-grid",children:k.map(c=>e.jsx(bs,{agent:c,isSelected:S.has(c.id),isKeyboardFocused:G&&M===c.id,onSelect:()=>{s==null||s(c.id),Q(!0),T(c.id)},onDoubleClick:()=>Ns(c.id),onChat:()=>t==null?void 0:t(c.id),onFocus:v?()=>v(c.id):void 0,onKill:d?()=>d(c.id):void 0,onDragStart:ks},c.id))})]},h)}),K.length===0&&e.jsx("div",{className:"dashboard-view__empty",children:o?n("noAgentsMatching",{search:o}):n("noAgentsSpawned")}),b.size>0&&e.jsx(ps,{buildings:b,onSelectBuilding:l})]})]})}export{Ks as DashboardView};
1
+ import{z as ts,u as ns,B as _s,j as e,C as Is,E as Ms,G as Es,r as g,H as $s,I as Ds,J as Ss,K as Ls,s as Y,m as B}from"./main-BSyGZK2z.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Xs=1,gs=Xs*2.5;function Rs(s,v,d){const l=v.filter(o=>o.position&&!isNaN(o.position.x)&&!isNaN(o.position.z));let t,i,n,u;if(s.type==="rectangle"){const o=(s.width||10)/2,N=(s.height||10)/2;t=s.center.x-o,i=s.center.x+o,n=s.center.z-N,u=s.center.z+N}else{const o=s.radius||5;t=s.center.x-o,i=s.center.x+o,n=s.center.z-o,u=s.center.z+o}const b=2;if(t+=b,i-=b,n+=b,u-=b,d){const o={...d};if(o.x=Math.max(t,Math.min(i,o.x)),o.z=Math.max(n,Math.min(u,o.z)),fs(o,l,s))return o}const x=(t+i)/2,S=(n+u)/2,j=Math.min(i-x,u-S);for(let o=0;o<j;o+=gs*.5)for(let N=0;N<Math.PI*2;N+=Math.PI/8){const C=x+Math.cos(N)*o,E=S+Math.sin(N)*o,_={x:C,z:E};if(_.x=Math.max(t,Math.min(i,_.x)),_.z=Math.max(n,Math.min(u,_.z)),fs(_,l,s))return _}return{x,z:S}}function fs(s,v,d){for(const l of v){if(!l.position)continue;if(Math.hypot(s.x-l.position.x,s.z-l.position.z)<gs)return!1}if(d.type==="rectangle"){const l=(d.width||10)/2,t=(d.height||10)/2,i=s.x>=d.center.x-l+1&&s.x<=d.center.x+l-1,n=s.z>=d.center.z-t+1&&s.z<=d.center.z+t-1;return i&&n}else{const l=(d.radius||5)-1;return Math.hypot(s.x-d.center.x,s.z-d.center.z)<=l}}function vs(s){switch(s){case"idle":case"running":return"healthy";case"working":case"waiting":case"waiting_permission":case"starting":case"stopping":return"working";case"error":case"offline":case"orphaned":case"stopped":return"error";default:return"unknown"}}function Ps(s){switch(s){case"scout":return"🔍";case"builder":return"🔨";case"debugger":return"🐛";case"architect":return"📐";case"warrior":return"⚔️";case"support":return"🛟";case"boss":return"👑";default:return"🤖"}}function Us(s){switch(s){case"server":return"🖥️";case"link":return"🔗";case"database":return"🗄️";case"docker":return"🐳";case"monitor":return"📊";case"folder":return"📁";case"boss":return"🏰";default:return"🏢"}}function Ys(s,v){const d=[],l=new Set;for(const i of v.values()){if(i.archived)continue;const n=[];for(const u of i.assignedAgentIds){const b=s.get(u);b&&(n.push(b),l.add(u))}d.push({area:i,agents:n,label:i.name,color:i.color})}d.sort((i,n)=>i.label.localeCompare(n.label));const t=[];for(const i of s.values())l.has(i.id)||t.push(i);return t.length>0&&d.push({area:null,agents:t,label:"Unassigned",color:"#555"}),d}function Gs(s,v){const d=[],l=[],t=[];for(const n of s.values())n.status==="working"||n.status==="waiting"||n.status==="waiting_permission"?d.push(n):n.status==="error"||n.status==="offline"||n.status==="orphaned"?t.push(n):v&&v.has(n.id)?d.push(n):l.push(n);const i=[];return t.length>0&&i.push({area:null,agents:t,label:"Errors",color:"#d64545"}),d.length>0&&i.push({area:null,agents:d,label:"Working & Unseen",color:"#f5d76e"}),l.length>0&&i.push({area:null,agents:l,label:"Idle",color:"#5cb88a"}),i}function Hs(s){const v=Date.now(),l=[...Array.from(s.values())].sort((o,N)=>(N.lastActivity||0)-(o.lastActivity||0)),t=[],i=[],n=[],u=[],b=300*1e3,x=3600*1e3,S=1440*60*1e3;for(const o of l){const N=v-(o.lastActivity||0);N<b?t.push(o):N<x?i.push(o):N<S?n.push(o):u.push(o)}const j=[];return t.length>0&&j.push({area:null,agents:t,label:"Just Now (< 5m)",color:"#4ade80"}),i.length>0&&j.push({area:null,agents:i,label:"Recent (5m - 1h)",color:"#60a5fa"}),n.length>0&&j.push({area:null,agents:n,label:"Stale (1h - 1d)",color:"#facc15"}),u.length>0&&j.push({area:null,agents:u,label:"Very Stale (> 1d)",color:"#f87171"}),j}function Zs(s){return s.contextLimit<=0?0:Math.round(s.contextUsed/s.contextLimit*100)}function Bs(s){return s>=80?"red":s>=50?"yellow":"green"}function ms(s){return as(s)}function as(s,v={}){const{prioritizeRecentlyIdle:d=!1}=v;return[...s].sort((l,t)=>{const i={error:0,offline:0,orphaned:0,working:1,waiting:1,waiting_permission:1,idle:2},n=i[l.status]??3,u=i[t.status]??3;if(n!==u)return n-u;if(d&&l.status==="idle"&&t.status==="idle"){const b=!!l.taskLabel,x=!!t.taskLabel;return b!==x?b?-1:1:(t.lastActivity||0)-(l.lastActivity||0)}return l.name.localeCompare(t.name)})}const bs=ts.memo(({agent:s,isSelected:v,isKeyboardFocused:d=!1,onSelect:l,onDoubleClick:t,onChat:i,onFocus:n,onKill:u,onDragStart:b})=>{const{t:x}=ns(["dashboard","common"]),j=_s().has(s.id),o=vs(s.status),N=Ps(s.class),C=Zs(s),E=Bs(C),_=s.taskLabel?`📋 ${s.taskLabel}`:s.currentTask||s.lastAssignedTask,X=s.status==="idle"&&s.lastActivity>0,[,F]=ts.useState(0);return ts.useEffect(()=>{if(!X)return;const z=window.setInterval(()=>F(I=>I+1),15e3);return()=>window.clearInterval(z)},[X]),e.jsxs("div",{className:`dash-card dash-card--${o} ${v?"dash-card--selected":""} ${d?"dash-card--keyboard-focused":""}`,"data-agent-id":s.id,onClick:l,onDoubleClick:z=>{z.stopPropagation(),t()},onDragStart:z=>{b==null||b(s),z.dataTransfer.effectAllowed="move"},draggable:!0,title:x("cards.doubleClickHint"),children:[e.jsxs("div",{className:"dash-card__row1",children:[e.jsx("span",{className:`dash-card__status-dot dash-card__status-dot--${o}`}),e.jsx("span",{className:"dash-card__name",children:s.name}),e.jsxs("span",{className:"dash-card__class",children:[N," ",s.class]}),e.jsxs("span",{className:`dash-card__provider dash-card__provider--${s.provider}`,children:[s.provider==="codex"?"🔸":s.provider==="opencode"?"🟢":"🤖"," ",s.provider]}),j&&e.jsx("span",{className:"dash-card__unseen-badge",title:"New output available - click to view",children:"!"})]}),e.jsxs("div",{className:"dash-card__row2",children:[e.jsx("span",{className:`dash-card__status dash-card__status--${o}`,children:j?"Unseen":s.status}),e.jsxs("div",{className:"dash-card__context",children:[e.jsx("div",{className:"dash-card__context-bar",children:e.jsx("div",{className:`dash-card__context-fill dash-card__context-fill--${E}`,style:{width:`${C}%`}})}),e.jsxs("span",{className:`dash-card__context-pct dash-card__context-pct--${E}`,children:[C,"%"]})]})]}),e.jsxs("div",{className:"dash-card__row3",children:[e.jsxs("span",{className:"dash-card__workdir",title:s.cwd,children:["📁 ",s.cwd.split("/").pop()||s.cwd]}),X&&e.jsxs("span",{className:"dash-card__idle-time",style:{color:Es(s.lastActivity)},title:Ms(s.lastActivity),children:["⏱ ",Is(s.lastActivity)]})]}),_&&e.jsx("div",{className:"dash-card__row4",children:e.jsx("span",{className:"dash-card__task",children:_})}),e.jsxs("div",{className:"dash-card__actions",children:[i&&e.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--chat",onClick:z=>{z.stopPropagation(),i()},title:x("cards.openTerminal"),children:x("cards.chat")}),u&&e.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--danger",onClick:z=>{z.stopPropagation(),u()},title:x("cards.killAgent"),children:x("cards.stop")})]})]})});bs.displayName="AgentCard";const ps=({buildings:s,onSelectBuilding:v})=>{const{t:d}=ns(["dashboard"]),l=g.useMemo(()=>Array.from(s.values()).sort((t,i)=>t.name.localeCompare(i.name)),[s]);return e.jsxs("div",{className:"dashboard-view__buildings",children:[e.jsxs("div",{className:"dashboard-view__buildings-header",children:[e.jsx("span",{className:"dashboard-view__buildings-title",children:d("buildings.title")}),e.jsx("span",{className:"dashboard-view__buildings-count",children:l.length})]}),e.jsx("div",{className:"dashboard-view__buildings-row",children:l.map(t=>{const i=vs(t.status),n=Us(t.type);return e.jsxs("button",{className:`dash-pill dash-pill--${i}`,onClick:()=>v==null?void 0:v(t.id),title:`${t.name} (${t.type}) - ${t.status}`,children:[e.jsx("span",{className:"dash-pill__icon",children:n}),e.jsx("span",{className:"dash-pill__name",children:t.name}),e.jsx("span",{className:`dash-pill__dot dash-pill__dot--${i}`})]},t.id)})})]})};ps.displayName="BuildingPills";function Ks({onSelectAgent:s,onFocusAgent:v,onKillAgent:d,onSelectBuilding:l,onOpenTerminal:t,onFocusZone:i}){const{t:n}=ns(["dashboard","common"]),u=$s(),b=Ds(),x=Ss(),S=Ls(),j=_s(),[o,N]=g.useState(""),[C,E]=g.useState("all"),[_,X]=g.useState("zone"),[F,z]=g.useState(new Set),[I,J]=g.useState(null),[ws,V]=g.useState(null),[G,Q]=g.useState(!1),[M,T]=g.useState(null),W=g.useMemo(()=>{const a=Array.from(u.values());return{total:a.length,working:a.filter(h=>h.status==="working"||h.status==="waiting"||h.status==="waiting_permission").length,idle:a.filter(h=>h.status==="idle").length,error:a.filter(h=>h.status==="error"||h.status==="offline"||h.status==="orphaned").length}},[u]),rs=g.useMemo(()=>_==="zone"?Ys(u,x):_==="status"?Gs(u,j):Hs(u),[u,x,_,j]),K=g.useMemo(()=>{const a=o.toLowerCase().trim(),h=rs.map(p=>({...p,agents:p.agents.filter(k=>{if(C==="working"){if(k.status!=="working"&&k.status!=="waiting"&&k.status!=="waiting_permission")return!1}else if(C==="error"&&k.status!=="error"&&k.status!=="offline"&&k.status!=="orphaned")return!1;return!(a&&!k.name.toLowerCase().includes(a)&&!k.class.toLowerCase().includes(a))})}));return _==="zone"?h:h.filter(p=>p.agents.length>0)},[rs,C,o,_]),O=g.useCallback(a=>a.area?`area:${a.area.id}`:`${_}:${a.label}`,[_]),$=g.useMemo(()=>{const a=[];return K.forEach(h=>{const p=O(h);if(F.has(p))return;const k=_==="status"?as(h.agents,{prioritizeRecentlyIdle:!0}):ms(h.agents);a.push(...k)}),a},[K,F,_,O]),xs=g.useCallback(a=>{z(h=>{const p=new Set(h);return p.has(a)?p.delete(a):p.add(a),p})},[]),Ns=g.useCallback(a=>{t==null||t(a)},[t]),ks=g.useCallback(a=>{J(a)},[]),js=g.useCallback((a,h)=>{a.preventDefault(),a.dataTransfer.dropEffect="move",V(h)},[]),ys=g.useCallback(()=>{V(null)},[]),Cs=g.useCallback(a=>{if(!I)return;if(a===null){const R=Y.getState(),r=Array.from(R.areas.values()).find(c=>c.assignedAgentIds.includes(I.id));r&&Y.unassignAgentFromArea(I.id,r.id),J(null),V(null);return}const h=x.get(a);if(!h)return;const p=Array.from(u.values()),k=Rs(h,p,I.position);Y.updateAgent({...I,position:{...I.position,x:k.x,z:k.z}}),Y.assignAgentToArea(I.id,a),J(null),V(null)},[I,x,u]);return g.useEffect(()=>{if($.length===0){Q(!1),T(null);return}G&&(!M||!$.some(a=>a.id===M))&&(T($[0].id),s==null||s($[0].id))},[$,G,M,s]),g.useEffect(()=>{const a=r=>r instanceof HTMLElement?r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.tagName==="SELECT"||r.isContentEditable:!1,h=r=>r instanceof HTMLElement?!!r.closest(".guake-terminal")||r.classList.contains("guake-input")||r.classList.contains("agent-panel-input"):!1,p=r=>{const c=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).find(L=>L.dataset.agentId===r);c==null||c.scrollIntoView({block:"nearest",inline:"nearest"})},k=(r,c)=>{var os,cs,ds,ls,us,hs;const L=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).map(f=>{const w=f.dataset.agentId;if(!w)return null;const D=f.getBoundingClientRect();return{id:w,centerX:D.left+D.width/2,centerY:D.top+D.height/2,height:D.height}}).filter(f=>f!==null).sort((f,w)=>f.centerY-w.centerY||f.centerX-w.centerX);if(L.length===0)return r;const ss=L.reduce((f,w)=>f+w.height,0)/L.length,es=Math.max(18,ss*.6),A=[];for(const f of L){const w=A[A.length-1];if(!w){A.push([{id:f.id,centerX:f.centerX,centerY:f.centerY}]);continue}const D=w.reduce((As,zs)=>As+zs.centerY,0)/w.length;Math.abs(f.centerY-D)<=es?w.push({id:f.id,centerX:f.centerX,centerY:f.centerY}):A.push([{id:f.id,centerX:f.centerX,centerY:f.centerY}])}A.forEach(f=>f.sort((w,D)=>w.centerX-D.centerX));const H=A.findIndex(f=>f.some(w=>w.id===r));if(H===-1)return((cs=(os=A[0])==null?void 0:os[0])==null?void 0:cs.id)??r;const P=A[H],y=P.findIndex(f=>f.id===r);if(y===-1)return((ls=(ds=A[0])==null?void 0:ds[0])==null?void 0:ls.id)??r;if(c==="left")return((us=P[Math.max(0,y-1)])==null?void 0:us.id)??r;if(c==="right")return((hs=P[Math.min(P.length-1,y+1)])==null?void 0:hs.id)??r;const q=c==="up"?Math.max(0,H-1):Math.min(A.length-1,H+1),m=A[q],Z=P[y].centerX;let U=m[0],is=Math.abs(U.centerX-Z);for(const f of m){const w=Math.abs(f.centerX-Z);w<is&&(U=f,is=w)}return(U==null?void 0:U.id)??r},R=r=>{const c=Y.getShortcuts(),L=c.find(m=>m.id==="dashboard-selector-toggle"),ss=c.find(m=>m.id==="dashboard-vim-left"),es=c.find(m=>m.id==="dashboard-vim-down"),A=c.find(m=>m.id==="dashboard-vim-up"),H=c.find(m=>m.id==="dashboard-vim-right"),P=c.find(m=>m.id==="open-terminal"),y=Y.getState();if(a(r.target))if(!y.terminalOpen&&h(r.target)&&document.activeElement instanceof HTMLElement)document.activeElement.blur();else return;if(B(r,L)){if($.length===0)return;r.preventDefault(),r.stopPropagation(),Q(!0),T(m=>{const Z=m&&$.some(U=>U.id===m)?m:$[0].id;return s==null||s(Z),window.setTimeout(()=>p(Z),0),Z});return}const q=B(r,ss)||r.key==="ArrowLeft"?"left":B(r,es)||r.key==="ArrowDown"?"down":B(r,A)||r.key==="ArrowUp"?"up":B(r,H)||r.key==="ArrowRight"?"right":null;if(q&&G&&M){r.preventDefault(),r.stopPropagation();const m=k(M,q);m!==M&&(T(m),s==null||s(m),window.setTimeout(()=>p(m),0));return}if(B(r,P)){if(y.terminalOpen)return;if(G&&M&&y.agents.has(M)){r.preventDefault(),t==null||t(M);return}if(y.selectedAgentIds.size===1){r.preventDefault();const m=Array.from(y.selectedAgentIds)[0];t==null||t(m);return}if(y.lastSelectedAgentId&&y.agents.has(y.lastSelectedAgentId)){r.preventDefault(),t==null||t(y.lastSelectedAgentId);return}}};return document.addEventListener("keydown",R,!0),()=>document.removeEventListener("keydown",R,!0)},[$,G,M,t,s]),g.useEffect(()=>{const a=document.activeElement;a instanceof HTMLElement&&a.closest(".guake-terminal")&&!Y.getState().terminalOpen&&a.blur()},[]),e.jsxs("div",{className:"dashboard-view",children:[e.jsxs("div",{className:"dashboard-view__topbar",children:[e.jsxs("div",{className:"dashboard-view__metrics",children:[e.jsxs("button",{className:`dashboard-view__metric-btn ${C==="all"?"dashboard-view__metric-btn--active":""}`,onClick:()=>E("all"),children:[e.jsx("span",{className:"dashboard-view__metric-value",children:W.total}),e.jsx("span",{className:"dashboard-view__metric-label",children:n("common:labels.agents")})]}),e.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--working ${C==="working"?"dashboard-view__metric-btn--active":""}`,onClick:()=>E("working"),children:[e.jsx("span",{className:"dashboard-view__metric-value",children:W.working}),e.jsx("span",{className:"dashboard-view__metric-label",children:n("common:status.working")})]}),e.jsxs("button",{className:"dashboard-view__metric-btn dashboard-view__metric-btn--idle ",onClick:()=>E("all"),children:[e.jsx("span",{className:"dashboard-view__metric-value",children:W.idle}),e.jsx("span",{className:"dashboard-view__metric-label",children:n("common:status.idle")})]}),e.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--error ${C==="error"?"dashboard-view__metric-btn--active":""}`,onClick:()=>E("error"),children:[e.jsx("span",{className:"dashboard-view__metric-value",children:W.error}),e.jsx("span",{className:"dashboard-view__metric-label",children:n("common:status.error")})]})]}),e.jsx("input",{className:"dashboard-view__search",type:"text",placeholder:n("searchPlaceholder"),value:o,onChange:a=>N(a.target.value)})]}),e.jsxs("div",{className:"dashboard-view__grouping",children:[e.jsx("button",{className:`dashboard-view__grouping-btn ${_==="zone"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>X("zone"),children:n("grouping.byZone")}),e.jsx("button",{className:`dashboard-view__grouping-btn ${_==="status"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>X("status"),children:n("grouping.byStatus")}),e.jsx("button",{className:`dashboard-view__grouping-btn ${_==="activity"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>X("activity"),children:n("grouping.byActivity")})]}),e.jsxs("div",{className:"dashboard-view__content",children:[K.map(a=>{const h=O(a),p=F.has(h),k=_==="status"?as(a.agents,{prioritizeRecentlyIdle:!0}):ms(a.agents),R=a.agents.filter(c=>c.status==="working"||c.status==="waiting"||c.status==="waiting_permission").length,r=a.agents.filter(c=>j.has(c.id)).length;return e.jsxs("div",{className:`dashboard-view__zone ${ws===(a.area?a.area.id:null)&&I?"dashboard-view__zone--drag-over":""}`,onDragOver:c=>js(c,a.area?a.area.id:null),onDragLeave:ys,onDrop:()=>Cs(a.area?a.area.id:null),children:[e.jsxs("div",{className:"dashboard-view__zone-header",onClick:()=>xs(h),children:[e.jsxs("div",{className:"dashboard-view__zone-left",children:[e.jsx("span",{className:`dashboard-view__zone-chevron ${p?"dashboard-view__zone-chevron--collapsed":""}`,children:"▼"}),e.jsx("span",{className:"dashboard-view__zone-dot",style:{backgroundColor:a.color}}),e.jsx("span",{className:"dashboard-view__zone-name",children:a.label}),e.jsxs("span",{className:"dashboard-view__zone-count",children:[n("agentCount",{count:a.agents.length}),R>0&&e.jsxs("span",{className:"dashboard-view__zone-working",children:[" · ",R," ",n("working")]}),r>0&&e.jsxs("span",{className:"dashboard-view__zone-unseen",children:[" · ",r," Unseen"]})]})]}),a.area&&i&&e.jsx("button",{className:"dashboard-view__zone-focus",onClick:c=>{c.stopPropagation(),i(a.area.id)},title:n("focusZone"),children:n("focusZone")})]}),!p&&e.jsx("div",{className:"dashboard-view__zone-grid",children:k.map(c=>e.jsx(bs,{agent:c,isSelected:S.has(c.id),isKeyboardFocused:G&&M===c.id,onSelect:()=>{s==null||s(c.id),Q(!0),T(c.id)},onDoubleClick:()=>Ns(c.id),onChat:()=>t==null?void 0:t(c.id),onFocus:v?()=>v(c.id):void 0,onKill:d?()=>d(c.id):void 0,onDragStart:ks},c.id))})]},h)}),K.length===0&&e.jsx("div",{className:"dashboard-view__empty",children:o?n("noAgentsMatching",{search:o}):n("noAgentsSpawned")}),b.size>0&&e.jsx(ps,{buildings:b,onSelectBuilding:l})]})]})}export{Ks as DashboardView};