tide-commander 1.211.0 → 1.213.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/assets/{AudioPlayer-BkW6rbHa.js → AudioPlayer-0XoYDzY7.js} +1 -1
- package/dist/assets/{BossLogsModal-CWJfLRLA.js → BossLogsModal-Bod63t3S.js} +1 -1
- package/dist/assets/{BossSpawnModal-DMxCXROC.js → BossSpawnModal-CBAbxdbF.js} +1 -1
- package/dist/assets/{ControlsModal-BaSSGPXP.js → ControlsModal-ClQA01Ds.js} +1 -1
- package/dist/assets/{DockerLogsModal-C_Nb5L_a.js → DockerLogsModal-XYgD5MGG.js} +1 -1
- package/dist/assets/{EmbeddedEditor-CG0ULJUZ.js → EmbeddedEditor-BoI_2YQu.js} +1 -1
- package/dist/assets/{FcStdViewer-BgEgrxaw.js → FcStdViewer-CHyQKC6X.js} +1 -1
- package/dist/assets/{GcodeViewer-CTlX7eA7.js → GcodeViewer-DiQHpS1l.js} +1 -1
- package/dist/assets/{GlbViewer-CKaX8cFI.js → GlbViewer-DGul3n90.js} +1 -1
- package/dist/assets/{GmailOAuthSetup-1AhXjBRc.js → GmailOAuthSetup-DX-d12Ru.js} +1 -1
- package/dist/assets/{GoogleOAuthSetup-DqPgZjOY.js → GoogleOAuthSetup-Co5P70hM.js} +1 -1
- package/dist/assets/{IframeModal-ClN_kGcP.js → IframeModal-DHZGNCTd.js} +1 -1
- package/dist/assets/{IntegrationsPanel-ckrmRwYi.js → IntegrationsPanel-BPclkyML.js} +2 -2
- package/dist/assets/{LogViewerModal-D_eGItAQ.js → LogViewerModal-ByjB2seT.js} +1 -1
- package/dist/assets/{MonitoringModal-BrsQN8tD.js → MonitoringModal-gUhUFyfc.js} +1 -1
- package/dist/assets/{PM2LogsModal-CKfdmFqw.js → PM2LogsModal-C-k2vE9y.js} +1 -1
- package/dist/assets/{PluginsPanel-Bfqcnrsb.js → PluginsPanel-B5_HFZE2.js} +1 -1
- package/dist/assets/{RestoreArchivedAreaModal-oZSTlXhf.js → RestoreArchivedAreaModal-ChCA7e1o.js} +1 -1
- package/dist/assets/{Scene2DCanvas-B2oTAqlK.js → Scene2DCanvas-CUIwcRFS.js} +1 -1
- package/dist/assets/{SceneManager-pnDsJdS-.js → SceneManager-Cv9nvN7Y.js} +1 -1
- package/dist/assets/{SkillsPanel-AQimvs-1.js → SkillsPanel-CKZjcpyA.js} +1 -1
- package/dist/assets/{SlackMultiInstanceSetup-U4d0XsWJ.js → SlackMultiInstanceSetup-DkaFYIT4.js} +1 -1
- package/dist/assets/{SpawnModal-DgKO0K6L.js → SpawnModal-Bk5wz6qM.js} +1 -1
- package/dist/assets/{StatisticsModal-DDC8OYen.js → StatisticsModal-CSI4I5dD.js} +1 -1
- package/dist/assets/{StlViewer-DJZ7Qgp0.js → StlViewer-C50PVmER.js} +1 -1
- package/dist/assets/{SubordinateAssignmentModal-DCM6PpB_.js → SubordinateAssignmentModal-B6HBv3jI.js} +1 -1
- package/dist/assets/{ThreeAreaSelector-CjEcL3Kh.js → ThreeAreaSelector-BH6Jl_wy.js} +1 -1
- package/dist/assets/{ThreeViewShortcuts-UakjRD8w.js → ThreeViewShortcuts-DWI1rRyg.js} +1 -1
- package/dist/assets/{TriggerManagerPanel-C42VLQu6.js → TriggerManagerPanel-CIM3fekd.js} +1 -1
- package/dist/assets/{VideoPlayer-UW43AiLH.js → VideoPlayer-BqXneIFS.js} +1 -1
- package/dist/assets/{WorkflowEditorPanel-DUvf5X0c.js → WorkflowEditorPanel-Dnc8JUGC.js} +1 -1
- package/dist/assets/{abnfDiagram-VRR7QNED-KDmvD_Gi.js → abnfDiagram-VRR7QNED--d8igfFs.js} +1 -1
- package/dist/assets/{arc-D8Dnwz7O.js → arc-CQZ9HaPq.js} +1 -1
- package/dist/assets/{architectureDiagram-ZJ3FMSHR-DzHUfCXK.js → architectureDiagram-ZJ3FMSHR-BzkW_z4S.js} +1 -1
- package/dist/assets/{area-logos-JqUib9Ux.js → area-logos-C_Dt4sR6.js} +1 -1
- package/dist/assets/{blockDiagram-677ZJIJ3-CwOc3I3e.js → blockDiagram-677ZJIJ3-Dv97cSYA.js} +1 -1
- package/dist/assets/{c4Diagram-LMCZKHZV-ByDTz6Pi.js → c4Diagram-LMCZKHZV-C06G-yIj.js} +1 -1
- package/dist/assets/channel-D3YwkWcG.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-CJ-5lUjr.js → chunk-2Q5K7J3B-BsyNFa-J.js} +1 -1
- package/dist/assets/{chunk-32BRIVSS-ClxbX6JR.js → chunk-32BRIVSS-CgRk3-tJ.js} +1 -1
- package/dist/assets/{chunk-5VM5RSS4-D-B4g6BP.js → chunk-5VM5RSS4-CMnRwv4f.js} +1 -1
- package/dist/assets/{chunk-EX3LRPZG-DE_ym6tm.js → chunk-EX3LRPZG-_QBKsKXW.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-DbFNU_Ef.js → chunk-JWPE2WC7-k9YbHD_j.js} +1 -1
- package/dist/assets/{chunk-MOJQB5TN-BonkkykU.js → chunk-MOJQB5TN-CKXUL6Fi.js} +1 -1
- package/dist/assets/{chunk-RYQCIY6F-CqaRznBG.js → chunk-RYQCIY6F-BIAhlmfk.js} +1 -1
- package/dist/assets/{chunk-V7JOEXUC-DI5OpSJo.js → chunk-V7JOEXUC-DcYniTD8.js} +1 -1
- package/dist/assets/{chunk-VR4S4FIN-DzHJs5bu.js → chunk-VR4S4FIN-D-bNt12a.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-x9Zsg6mD.js → chunk-XXDRQBXY-DobHwO4_.js} +1 -1
- package/dist/assets/classDiagram-OUVF2IWQ-DocPV6XK.js +1 -0
- package/dist/assets/classDiagram-v2-EOCWNBFH-DocPV6XK.js +1 -0
- package/dist/assets/{cose-bilkent-JH36ORCC-B4Gh0RgK.js → cose-bilkent-JH36ORCC-Ba_C8Q81.js} +1 -1
- package/dist/assets/{cynefin-VYW2F7L2-1rocbocI.js → cynefin-VYW2F7L2-Hb-1zR6k.js} +1 -1
- package/dist/assets/{cynefinDiagram-TSTJHNR4-BCbOrdTH.js → cynefinDiagram-TSTJHNR4-amXmiyQW.js} +1 -1
- package/dist/assets/{dagre-VKFMJZFB-CquTDGCQ.js → dagre-VKFMJZFB-BNUucpZJ.js} +1 -1
- package/dist/assets/{diagram-FQU43EPY-CtRps2DK.js → diagram-FQU43EPY-CuYw58Um.js} +1 -1
- package/dist/assets/{diagram-G47NLZAW-C8uHzoun.js → diagram-G47NLZAW-Dg9fCLeP.js} +1 -1
- package/dist/assets/{diagram-NH7WQ7WH-BzGxTXmO.js → diagram-NH7WQ7WH-qeg5sjuS.js} +1 -1
- package/dist/assets/{diagram-OA4YK3LP-BoUlY6He.js → diagram-OA4YK3LP-DOwtG87b.js} +1 -1
- package/dist/assets/{diagram-WEI45ONY-EewNkn4I.js → diagram-WEI45ONY-BM33pC3i.js} +1 -1
- package/dist/assets/{ebnfDiagram-CCIWWBDH-DAp0_rYI.js → ebnfDiagram-CCIWWBDH-hJnMt_nO.js} +1 -1
- package/dist/assets/{erDiagram-Q63AITRT-CIDiaIv_.js → erDiagram-Q63AITRT-Dv4DTadC.js} +1 -1
- package/dist/assets/{flowDiagram-23GEKE2U-ZQudeco2.js → flowDiagram-23GEKE2U-8DDRTZ5q.js} +1 -1
- package/dist/assets/{ganttDiagram-NO4QXBWP-DDa9u7Kj.js → ganttDiagram-NO4QXBWP-IWVSonaN.js} +1 -1
- package/dist/assets/{gitGraphDiagram-IHSO6WYX-D0LPqp_M.js → gitGraphDiagram-IHSO6WYX-B8SRF6Rm.js} +1 -1
- package/dist/assets/{index-CmZ79Am7.js → index-B99LPOqY.js} +1 -1
- package/dist/assets/{index-BuW-OFAQ.js → index-BIXZ5ma2.js} +1 -1
- package/dist/assets/{index-CM0wRsAP.js → index-C8sTxLSh.js} +1 -1
- package/dist/assets/{index-tU947Zt1.js → index-CPxwxV3y.js} +1 -1
- package/dist/assets/{index-CgtrBMsu.js → index-CfzJePLs.js} +1 -1
- package/dist/assets/{index-D0O_xUmt.js → index-CoQeR3M4.js} +1 -1
- package/dist/assets/{index-BMILmzZt.js → index-DZXJouwG.js} +3 -3
- package/dist/assets/{index-DjZWtEFJ.js → index-H2kZgwuS.js} +1 -1
- package/dist/assets/{index-CbjaD3wY.js → index-iox2Avj1.js} +2 -2
- package/dist/assets/{infoDiagram-FWYZ7A6U-CD4Ws76i.js → infoDiagram-FWYZ7A6U-DiW8Da6O.js} +1 -1
- package/dist/assets/{ishikawaDiagram-FXEZZL3T-DSEmTd2f.js → ishikawaDiagram-FXEZZL3T-BX9Iv2Bx.js} +1 -1
- package/dist/assets/{journeyDiagram-5HDEW3XC-3_c5LjHs.js → journeyDiagram-5HDEW3XC-DxOx3HNu.js} +1 -1
- package/dist/assets/{kanban-definition-HUTT4EX6-24lijuGn.js → kanban-definition-HUTT4EX6-CXU91xhp.js} +1 -1
- package/dist/assets/{linear-B_K6Qcv3.js → linear-BN1q8PcL.js} +1 -1
- package/dist/assets/{main-D0r07JA_.js → main-DAjvgfMx.js} +13 -13
- package/dist/assets/{mermaid.core-B6sgvfs-.js → mermaid.core-DDz9Iaty.js} +4 -4
- package/dist/assets/{mindmap-definition-LN4V7U3C-BsAOrAHj.js → mindmap-definition-LN4V7U3C-DpJ8aYp2.js} +1 -1
- package/dist/assets/{pegDiagram-2B236MQR-DdfupKz5.js → pegDiagram-2B236MQR-DNWtKvhp.js} +1 -1
- package/dist/assets/{pieDiagram-ENE6RG2P-D1YBZYdK.js → pieDiagram-ENE6RG2P-B5qvWe8-.js} +1 -1
- package/dist/assets/{quadrantDiagram-ABIIQ3AL-Bw-hoDGQ.js → quadrantDiagram-ABIIQ3AL-DcxOc9Jk.js} +1 -1
- package/dist/assets/{railroadDiagram-RFXS5EU6-CkmO-Wgv.js → railroadDiagram-RFXS5EU6-CHK9rRAr.js} +1 -1
- package/dist/assets/{requirementDiagram-TGXJPOKE-CSI19yqY.js → requirementDiagram-TGXJPOKE-B1q3f28r.js} +1 -1
- package/dist/assets/{sankeyDiagram-HTMAVEWB-BvLYUk8J.js → sankeyDiagram-HTMAVEWB-SDg0XTUl.js} +1 -1
- package/dist/assets/{sequenceDiagram-DBY2YBRQ-DSQLX4Eb.js → sequenceDiagram-DBY2YBRQ-C5zqmKlJ.js} +1 -1
- package/dist/assets/{sizeCapture-X5ZJPWSS-DfyzoJ-u.js → sizeCapture-X5ZJPWSS-B1w0ijos.js} +1 -1
- package/dist/assets/{stateDiagram-2N3HPSRC-G3bxzIPH.js → stateDiagram-2N3HPSRC-Dx17zSPT.js} +1 -1
- package/dist/assets/stateDiagram-v2-6OUMAXLB-CoNQS9IV.js +1 -0
- package/dist/assets/{swimlanes-5IMT3BWC-CDZGonhF.js → swimlanes-5IMT3BWC-C49X991f.js} +2 -2
- package/dist/assets/swimlanesDiagram-G3AALYLV-Yyot49f1.js +8 -0
- package/dist/assets/{timeline-definition-FHXFAJF6-C5QDZq49.js → timeline-definition-FHXFAJF6-DpOqNBNt.js} +1 -1
- package/dist/assets/{vennDiagram-L72KCM5P-0a1v0gi5.js → vennDiagram-L72KCM5P-CkMpg3xS.js} +1 -1
- package/dist/assets/{wardleyDiagram-EHGQE667-DArhtjvR.js → wardleyDiagram-EHGQE667-zJk9PTKN.js} +1 -1
- package/dist/assets/{web-BgCc_AGi.js → web-3dLaLyVf.js} +1 -1
- package/dist/assets/{web-BU7b4YVF.js → web-BL_6uaSX.js} +1 -1
- package/dist/assets/{web-BiQ9JdSl.js → web-DI0lko8Q.js} +1 -1
- package/dist/assets/{xychartDiagram-FW5EYKEG-BIZcXzGL.js → xychartDiagram-FW5EYKEG-DqYA8n2Y.js} +1 -1
- package/dist/build-info.json +1 -1
- package/dist/index.html +1 -1
- package/dist/src/packages/server/integrations/google-calendar/calendar-client.js +11 -4
- package/dist/src/packages/server/integrations/google-calendar/calendar-routes.js +3 -1
- package/dist/src/packages/server/integrations/google-calendar/calendar-skill.js +9 -1
- package/dist/src/packages/server/integrations/google-drive/drive-client.js +189 -19
- package/dist/src/packages/server/integrations/google-drive/drive-routes.js +48 -0
- package/dist/src/packages/server/integrations/google-drive/drive-skill.js +29 -1
- package/package.json +1 -1
- package/dist/assets/channel-C9DXs2xS.js +0 -1
- package/dist/assets/classDiagram-OUVF2IWQ-apBPMHmB.js +0 -1
- package/dist/assets/classDiagram-v2-EOCWNBFH-apBPMHmB.js +0 -1
- package/dist/assets/stateDiagram-v2-6OUMAXLB-DCUADcVF.js +0 -1
- package/dist/assets/swimlanesDiagram-G3AALYLV-Ddwy1JnL.js +0 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as dt,d as ft,E as us,a1 as hs,f as ds,bm as fs,c8 as ms,ah as gs,r as l,z as ps,S as Fe,c9 as it,ca as ys,cb as As,cc as xs,az as Es,cd as we,s as X,ce as Ms,j as c,I as O,W as Rt,cf as Lt,t as Dt,cg as Cs,ch as kt,ci as at,V as ct,m as Ss,ay as Wt,u as st,cj as Ft,aJ as _s,ck as $t,cl as Is,cm as vs,cn as Ns,co as bs,cp as js,cq as ws,cr as Ts}from"./main-D0r07JA_.js";import{cs as er,ct as tr,cu as sr,cv as nr,cw as rr}from"./main-D0r07JA_.js";import{s as Rs,S as Ls}from"./settingsSearch-DYr4vFyy.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-DYBBrXTx.js";function fe(t){return Array.isArray?Array.isArray(t):Vt(t)==="[object Array]"}function Ds(t){if(typeof t=="string")return t;let e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function ks(t){return t==null?"":Ds(t)}function ue(t){return typeof t=="string"}function Yt(t){return typeof t=="number"}function Fs(t){return t===!0||t===!1||$s(t)&&Vt(t)=="[object Boolean]"}function qt(t){return typeof t=="object"}function $s(t){return qt(t)&&t!==null}function ne(t){return t!=null}function lt(t){return!t.trim().length}function Vt(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const Bs="Incorrect 'index' type",Ps=t=>`Invalid value for key ${t}`,Qs=t=>`Pattern length exceeds max of ${t}.`,zs=t=>`Missing ${t} property in key`,Ks=t=>`Property 'weight' in key '${t}' must be a positive integer`,Bt=Object.prototype.hasOwnProperty;class Os{constructor(e){this._keys=[],this._keyMap={};let n=0;e.forEach(r=>{let o=Xt(r);this._keys.push(o),this._keyMap[o.id]=o,n+=o.weight}),this._keys.forEach(r=>{r.weight/=n})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Xt(t){let e=null,n=null,r=null,o=1,a=null;if(ue(t)||fe(t))r=t,e=Pt(t),n=mt(t);else{if(!Bt.call(t,"name"))throw new Error(zs("name"));const u=t.name;if(r=u,Bt.call(t,"weight")&&(o=t.weight,o<=0))throw new Error(Ks(u));e=Pt(u),n=mt(u),a=t.getFn}return{path:e,id:n,weight:o,src:r,getFn:a}}function Pt(t){return fe(t)?t:t.split(".")}function mt(t){return fe(t)?t.join("."):t}function Gs(t,e){let n=[],r=!1;const o=(a,u,d)=>{if(ne(a))if(!u[d])n.push(a);else{let h=u[d];const f=a[h];if(!ne(f))return;if(d===u.length-1&&(ue(f)||Yt(f)||Fs(f)))n.push(ks(f));else if(fe(f)){r=!0;for(let m=0,x=f.length;m<x;m+=1)o(f[m],u,d+1)}else u.length&&o(f,u,d+1)}};return o(t,ue(e)?e.split("."):e,0),r?n:n[0]}const Us={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Hs={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},Ws={location:0,threshold:.6,distance:100},Ys={useExtendedSearch:!1,getFn:Gs,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var C={...Hs,...Us,...Ws,...Ys};const qs=/[^ ]+/g;function Vs(t=1,e=3){const n=new Map,r=Math.pow(10,e);return{get(o){const a=o.match(qs).length;if(n.has(a))return n.get(a);const u=1/Math.pow(a,.5*t),d=parseFloat(Math.round(u*r)/r);return n.set(a,d),d},clear(){n.clear()}}}class Et{constructor({getFn:e=C.getFn,fieldNormWeight:n=C.fieldNormWeight}={}){this.norm=Vs(n,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((n,r)=>{this._keysMap[n.id]=r})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,ue(this.docs[0])?this.docs.forEach((e,n)=>{this._addString(e,n)}):this.docs.forEach((e,n)=>{this._addObject(e,n)}),this.norm.clear())}add(e){const n=this.size();ue(e)?this._addString(e,n):this._addObject(e,n)}removeAt(e){this.records.splice(e,1);for(let n=e,r=this.size();n<r;n+=1)this.records[n].i-=1}getValueForItemAtKeyId(e,n){return e[this._keysMap[n]]}size(){return this.records.length}_addString(e,n){if(!ne(e)||lt(e))return;let r={v:e,i:n,n:this.norm.get(e)};this.records.push(r)}_addObject(e,n){let r={i:n,$:{}};this.keys.forEach((o,a)=>{let u=o.getFn?o.getFn(e):this.getFn(e,o.path);if(ne(u)){if(fe(u)){let d=[];const h=[{nestedArrIndex:-1,value:u}];for(;h.length;){const{nestedArrIndex:f,value:m}=h.pop();if(ne(m))if(ue(m)&&!lt(m)){let x={v:m,i:f,n:this.norm.get(m)};d.push(x)}else fe(m)&&m.forEach((x,y)=>{h.push({nestedArrIndex:y,value:x})})}r.$[a]=d}else if(ue(u)&&!lt(u)){let d={v:u,n:this.norm.get(u)};r.$[a]=d}}}),this.records.push(r)}toJSON(){return{keys:this.keys,records:this.records}}}function Jt(t,e,{getFn:n=C.getFn,fieldNormWeight:r=C.fieldNormWeight}={}){const o=new Et({getFn:n,fieldNormWeight:r});return o.setKeys(t.map(Xt)),o.setSources(e),o.create(),o}function Xs(t,{getFn:e=C.getFn,fieldNormWeight:n=C.fieldNormWeight}={}){const{keys:r,records:o}=t,a=new Et({getFn:e,fieldNormWeight:n});return a.setKeys(r),a.setIndexRecords(o),a}function Je(t,{errors:e=0,currentLocation:n=0,expectedLocation:r=0,distance:o=C.distance,ignoreLocation:a=C.ignoreLocation}={}){const u=e/t.length;if(a)return u;const d=Math.abs(r-n);return o?u+d/o:d?1:u}function Js(t=[],e=C.minMatchCharLength){let n=[],r=-1,o=-1,a=0;for(let u=t.length;a<u;a+=1){let d=t[a];d&&r===-1?r=a:!d&&r!==-1&&(o=a-1,o-r+1>=e&&n.push([r,o]),r=-1)}return t[a-1]&&a-r>=e&&n.push([r,a-1]),n}const _e=32;function Zs(t,e,n,{location:r=C.location,distance:o=C.distance,threshold:a=C.threshold,findAllMatches:u=C.findAllMatches,minMatchCharLength:d=C.minMatchCharLength,includeMatches:h=C.includeMatches,ignoreLocation:f=C.ignoreLocation}={}){if(e.length>_e)throw new Error(Qs(_e));const m=e.length,x=t.length,y=Math.max(0,Math.min(r,x));let E=a,A=y;const M=d>1||h,N=M?Array(x):[];let D;for(;(D=t.indexOf(e,A))>-1;){let U=Je(e,{currentLocation:D,expectedLocation:y,distance:o,ignoreLocation:f});if(E=Math.min(U,E),A=D+m,M){let Y=0;for(;Y<m;)N[D+Y]=1,Y+=1}}A=-1;let b=[],L=1,G=m+x;const ce=1<<m-1;for(let U=0;U<m;U+=1){let Y=0,J=G;for(;Y<J;)Je(e,{errors:U,currentLocation:y+J,expectedLocation:y,distance:o,ignoreLocation:f})<=E?Y=J:G=J,J=Math.floor((G-Y)/2+Y);G=J;let oe=Math.max(1,y-J+1),le=u?x:Math.min(y+J,x)+m,Q=Array(le+2);Q[le+1]=(1<<U)-1;for(let q=le;q>=oe;q-=1){let V=q-1,ee=n[t.charAt(V)];if(M&&(N[V]=+!!ee),Q[q]=(Q[q+1]<<1|1)&ee,U&&(Q[q]|=(b[q+1]|b[q])<<1|1|b[q+1]),Q[q]&ce&&(L=Je(e,{errors:U,currentLocation:V,expectedLocation:y,distance:o,ignoreLocation:f}),L<=E)){if(E=L,A=V,A<=y)break;oe=Math.max(1,2*y-A)}}if(Je(e,{errors:U+1,currentLocation:y,expectedLocation:y,distance:o,ignoreLocation:f})>E)break;b=Q}const me={isMatch:A>=0,score:Math.max(.001,L)};if(M){const U=Js(N,d);U.length?h&&(me.indices=U):me.isMatch=!1}return me}function en(t){let e={};for(let n=0,r=t.length;n<r;n+=1){const o=t.charAt(n);e[o]=(e[o]||0)|1<<r-n-1}return e}const et=String.prototype.normalize?(t=>t.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,"")):(t=>t);class Zt{constructor(e,{location:n=C.location,threshold:r=C.threshold,distance:o=C.distance,includeMatches:a=C.includeMatches,findAllMatches:u=C.findAllMatches,minMatchCharLength:d=C.minMatchCharLength,isCaseSensitive:h=C.isCaseSensitive,ignoreDiacritics:f=C.ignoreDiacritics,ignoreLocation:m=C.ignoreLocation}={}){if(this.options={location:n,threshold:r,distance:o,includeMatches:a,findAllMatches:u,minMatchCharLength:d,isCaseSensitive:h,ignoreDiacritics:f,ignoreLocation:m},e=h?e:e.toLowerCase(),e=f?et(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const x=(E,A)=>{this.chunks.push({pattern:E,alphabet:en(E),startIndex:A})},y=this.pattern.length;if(y>_e){let E=0;const A=y%_e,M=y-A;for(;E<M;)x(this.pattern.substr(E,_e),E),E+=_e;if(A){const N=y-_e;x(this.pattern.substr(N),N)}}else x(this.pattern,0)}searchIn(e){const{isCaseSensitive:n,ignoreDiacritics:r,includeMatches:o}=this.options;if(e=n?e:e.toLowerCase(),e=r?et(e):e,this.pattern===e){let M={isMatch:!0,score:0};return o&&(M.indices=[[0,e.length-1]]),M}const{location:a,distance:u,threshold:d,findAllMatches:h,minMatchCharLength:f,ignoreLocation:m}=this.options;let x=[],y=0,E=!1;this.chunks.forEach(({pattern:M,alphabet:N,startIndex:D})=>{const{isMatch:b,score:L,indices:G}=Zs(e,M,N,{location:a+D,distance:u,threshold:d,findAllMatches:h,minMatchCharLength:f,includeMatches:o,ignoreLocation:m});b&&(E=!0),y+=L,b&&G&&(x=[...x,...G])});let A={isMatch:E,score:E?y/this.chunks.length:1};return E&&o&&(A.indices=x),A}}class Ae{constructor(e){this.pattern=e}static isMultiMatch(e){return Qt(e,this.multiRegex)}static isSingleMatch(e){return Qt(e,this.singleRegex)}search(){}}function Qt(t,e){const n=t.match(e);return n?n[1]:null}class tn extends Ae{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const n=e===this.pattern;return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class sn extends Ae{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const r=e.indexOf(this.pattern)===-1;return{isMatch:r,score:r?0:1,indices:[0,e.length-1]}}}class nn extends Ae{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const n=e.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class rn extends Ae{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const n=!e.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class on extends Ae{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const n=e.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class an extends Ae{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const n=!e.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class es extends Ae{constructor(e,{location:n=C.location,threshold:r=C.threshold,distance:o=C.distance,includeMatches:a=C.includeMatches,findAllMatches:u=C.findAllMatches,minMatchCharLength:d=C.minMatchCharLength,isCaseSensitive:h=C.isCaseSensitive,ignoreDiacritics:f=C.ignoreDiacritics,ignoreLocation:m=C.ignoreLocation}={}){super(e),this._bitapSearch=new Zt(e,{location:n,threshold:r,distance:o,includeMatches:a,findAllMatches:u,minMatchCharLength:d,isCaseSensitive:h,ignoreDiacritics:f,ignoreLocation:m})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class ts extends Ae{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let n=0,r;const o=[],a=this.pattern.length;for(;(r=e.indexOf(this.pattern,n))>-1;)n=r+a,o.push([r,n-1]);const u=!!o.length;return{isMatch:u,score:u?0:1,indices:o}}}const gt=[tn,ts,nn,rn,an,on,sn,es],zt=gt.length,cn=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,ln="|";function un(t,e={}){return t.split(ln).map(n=>{let r=n.trim().split(cn).filter(a=>a&&!!a.trim()),o=[];for(let a=0,u=r.length;a<u;a+=1){const d=r[a];let h=!1,f=-1;for(;!h&&++f<zt;){const m=gt[f];let x=m.isMultiMatch(d);x&&(o.push(new m(x,e)),h=!0)}if(!h)for(f=-1;++f<zt;){const m=gt[f];let x=m.isSingleMatch(d);if(x){o.push(new m(x,e));break}}}return o})}const hn=new Set([es.type,ts.type]);class dn{constructor(e,{isCaseSensitive:n=C.isCaseSensitive,ignoreDiacritics:r=C.ignoreDiacritics,includeMatches:o=C.includeMatches,minMatchCharLength:a=C.minMatchCharLength,ignoreLocation:u=C.ignoreLocation,findAllMatches:d=C.findAllMatches,location:h=C.location,threshold:f=C.threshold,distance:m=C.distance}={}){this.query=null,this.options={isCaseSensitive:n,ignoreDiacritics:r,includeMatches:o,minMatchCharLength:a,findAllMatches:d,ignoreLocation:u,location:h,threshold:f,distance:m},e=n?e:e.toLowerCase(),e=r?et(e):e,this.pattern=e,this.query=un(this.pattern,this.options)}static condition(e,n){return n.useExtendedSearch}searchIn(e){const n=this.query;if(!n)return{isMatch:!1,score:1};const{includeMatches:r,isCaseSensitive:o,ignoreDiacritics:a}=this.options;e=o?e:e.toLowerCase(),e=a?et(e):e;let u=0,d=[],h=0;for(let f=0,m=n.length;f<m;f+=1){const x=n[f];d.length=0,u=0;for(let y=0,E=x.length;y<E;y+=1){const A=x[y],{isMatch:M,indices:N,score:D}=A.search(e);if(M){if(u+=1,h+=D,r){const b=A.constructor.type;hn.has(b)?d=[...d,...N]:d.push(N)}}else{h=0,u=0,d.length=0;break}}if(u){let y={isMatch:!0,score:h/u};return r&&(y.indices=d),y}}return{isMatch:!1,score:1}}}const pt=[];function fn(...t){pt.push(...t)}function yt(t,e){for(let n=0,r=pt.length;n<r;n+=1){let o=pt[n];if(o.condition(t,e))return new o(t,e)}return new Zt(t,e)}const tt={AND:"$and",OR:"$or"},At={PATH:"$path",PATTERN:"$val"},xt=t=>!!(t[tt.AND]||t[tt.OR]),mn=t=>!!t[At.PATH],gn=t=>!fe(t)&&qt(t)&&!xt(t),Kt=t=>({[tt.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function ss(t,e,{auto:n=!0}={}){const r=o=>{let a=Object.keys(o);const u=mn(o);if(!u&&a.length>1&&!xt(o))return r(Kt(o));if(gn(o)){const h=u?o[At.PATH]:a[0],f=u?o[At.PATTERN]:o[h];if(!ue(f))throw new Error(Ps(h));const m={keyId:mt(h),pattern:f};return n&&(m.searcher=yt(f,e)),m}let d={children:[],operator:a[0]};return a.forEach(h=>{const f=o[h];fe(f)&&f.forEach(m=>{d.children.push(r(m))})}),d};return xt(t)||(t=Kt(t)),r(t)}function pn(t,{ignoreFieldNorm:e=C.ignoreFieldNorm}){t.forEach(n=>{let r=1;n.matches.forEach(({key:o,norm:a,score:u})=>{const d=o?o.weight:null;r*=Math.pow(u===0&&d?Number.EPSILON:u,(d||1)*(e?1:a))}),n.score=r})}function yn(t,e){const n=t.matches;e.matches=[],ne(n)&&n.forEach(r=>{if(!ne(r.indices)||!r.indices.length)return;const{indices:o,value:a}=r;let u={indices:o,value:a};r.key&&(u.key=r.key.src),r.idx>-1&&(u.refIndex=r.idx),e.matches.push(u)})}function An(t,e){e.score=t.score}function xn(t,e,{includeMatches:n=C.includeMatches,includeScore:r=C.includeScore}={}){const o=[];return n&&o.push(yn),r&&o.push(An),t.map(a=>{const{idx:u}=a,d={item:e[u],refIndex:u};return o.length&&o.forEach(h=>{h(a,d)}),d})}class de{constructor(e,n={},r){this.options={...C,...n},this.options.useExtendedSearch,this._keyStore=new Os(this.options.keys),this.setCollection(e,r)}setCollection(e,n){if(this._docs=e,n&&!(n instanceof Et))throw new Error(Bs);this._myIndex=n||Jt(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){ne(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const n=[];for(let r=0,o=this._docs.length;r<o;r+=1){const a=this._docs[r];e(a,r)&&(this.removeAt(r),r-=1,o-=1,n.push(a))}return n}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:n=-1}={}){const{includeMatches:r,includeScore:o,shouldSort:a,sortFn:u,ignoreFieldNorm:d}=this.options;let h=ue(e)?ue(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return pn(h,{ignoreFieldNorm:d}),a&&h.sort(u),Yt(n)&&n>-1&&(h=h.slice(0,n)),xn(h,this._docs,{includeMatches:r,includeScore:o})}_searchStringList(e){const n=yt(e,this.options),{records:r}=this._myIndex,o=[];return r.forEach(({v:a,i:u,n:d})=>{if(!ne(a))return;const{isMatch:h,score:f,indices:m}=n.searchIn(a);h&&o.push({item:a,idx:u,matches:[{score:f,value:a,norm:d,indices:m}]})}),o}_searchLogical(e){const n=ss(e,this.options),r=(d,h,f)=>{if(!d.children){const{keyId:x,searcher:y}=d,E=this._findMatches({key:this._keyStore.get(x),value:this._myIndex.getValueForItemAtKeyId(h,x),searcher:y});return E&&E.length?[{idx:f,item:h,matches:E}]:[]}const m=[];for(let x=0,y=d.children.length;x<y;x+=1){const E=d.children[x],A=r(E,h,f);if(A.length)m.push(...A);else if(d.operator===tt.AND)return[]}return m},o=this._myIndex.records,a={},u=[];return o.forEach(({$:d,i:h})=>{if(ne(d)){let f=r(n,d,h);f.length&&(a[h]||(a[h]={idx:h,item:d,matches:[]},u.push(a[h])),f.forEach(({matches:m})=>{a[h].matches.push(...m)}))}}),u}_searchObjectList(e){const n=yt(e,this.options),{keys:r,records:o}=this._myIndex,a=[];return o.forEach(({$:u,i:d})=>{if(!ne(u))return;let h=[];r.forEach((f,m)=>{h.push(...this._findMatches({key:f,value:u[m],searcher:n}))}),h.length&&a.push({idx:d,item:u,matches:h})}),a}_findMatches({key:e,value:n,searcher:r}){if(!ne(n))return[];let o=[];if(fe(n))n.forEach(({v:a,i:u,n:d})=>{if(!ne(a))return;const{isMatch:h,score:f,indices:m}=r.searchIn(a);h&&o.push({score:f,key:e,value:a,idx:u,norm:d,indices:m})});else{const{v:a,n:u}=n,{isMatch:d,score:h,indices:f}=r.searchIn(a);d&&o.push({score:h,key:e,value:a,norm:u,indices:f})}return o}}de.version="7.1.0";de.createIndex=Jt;de.parseIndex=Xs;de.config=C;de.parseQuery=ss;fn(dn);function ke(t){return t.trim().toLowerCase().split(/\s+/).filter(Boolean)}function En(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ze(t,e){const n=e.trim(),r=ke(n);if(r.length<=1)return t.search(n);const[o,...a]=r.map(h=>t.search(h)),u=a.map(h=>{const f=new Map;for(const m of h)f.set(m.refIndex,m.score??1);return f}),d=[];for(const h of o){let f=h.score??1,m=!0;for(const x of u){const y=x.get(h.refIndex);if(y===void 0){m=!1;break}f+=y}m&&d.push({item:h.item,score:f/r.length})}return d.sort((h,f)=>(h.score??1)-(f.score??1)),d}function Ot(t,e,n){return e===t?6:e.startsWith(t)?5:e.split(/[^a-z0-9]+/i).includes(t)?4:e.includes(t)?3:n.includes(t)?2:1}function Mn(t,e,n){const r=ke(t);if(r.length===0)return 1;const o=e.toLowerCase(),a=n.toLowerCase(),u=Ot(r.join(" "),o,a);if(r.length===1)return u;let d=6;for(const h of r)d=Math.min(d,Ot(h,o,a));return Math.max(u,d)}const Cn=4;function Gt(t){return t.replace(/…|\.\.\./g," ").replace(/\s+/g," ").trim().toLowerCase()}const Sn=24;function _n(t,e){const n=Gt(t),r=Gt(e);return n===r?!0:Math.min(n.length,r.length)<Sn?!1:n.includes(r)||r.includes(n)}function In(t,e){const n=[],r=o=>{!o||!o.text.trim()||n.length>=Cn||n.some(a=>_n(a.text,o.text))||n.push(o)};t&&r({text:t,kind:"user"});for(const o of e??[])r(o);return n.length>0?n:void 0}async function vn(t){const e=new URLSearchParams({q:t}),n=await dt(ft(`/api/folders/search?${e.toString()}`));if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(o.error||`Failed to search folders: ${n.statusText}`)}const r=await n.json();return Array.isArray(r.folders)?r.folders:[]}const Ut=["agent","session","building","setting","file","file-content","folder","area"],Nn=2,bn=2,jn=50,wn=10,Tn=3,Rn=30,Ln=8,Dn=8,kn=3,Fn=15,ut=5,ht=5;function $n(){const t=Wt(Fe.SPOTLIGHT_TAB,"all");return we.includes(t)?t:"all"}function Ht(){return Ss(Fe.SPOTLIGHT_QUERY,"")}function Bn(){const t=Wt(Fe.AOP_CONFIG,{});return t.sortMode==="name"||t.sortMode==="status"||t.sortMode==="recent"?t.sortMode:"recent"}function Pn({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:o,onOpenFileExplorer:a,onOpenPM2LogsModal:u,onOpenBossLogsModal:d,onOpenDatabasePanel:h,onOpenMonitoringModal:f,onOpenSessionFinder:m,onOpenFileDetail:x}){const y=us(),E=hs(),A=ds(),M=fs(),N=ms(),D=gs(),b=l.useRef(e);b.current=e;const L=l.useRef(n);L.current=n;const G=l.useRef(r);G.current=r;const ce=l.useRef(o);ce.current=o;const me=l.useRef(a);me.current=a;const U=l.useRef(u);U.current=u;const Y=l.useRef(d);Y.current=d;const J=l.useRef(h);J.current=h;const oe=l.useRef(f);oe.current=f;const le=l.useRef(m);le.current=m;const Q=l.useRef(x);Q.current=x;const[R,q]=l.useState(Ht),[V,ee]=l.useState(0),[ie,$e]=l.useState($n),[Be,ge]=l.useState([]),[Pe,pe]=l.useState([]),[Qe,te]=l.useState([]),[se,ye]=l.useState(!1),[Ie,xe]=l.useState(!1),[ze,ve]=l.useState(!1),[Ke,v]=l.useState(!1),[S,k]=l.useState({query:"",rows:[]}),[Ne,Te]=l.useState(!1),[Ee,Mt]=l.useState(!1);l.useEffect(()=>{Te(!1),Mt(!1)},[R,t]);const ns=l.useCallback(s=>{q(s),ps(Fe.SPOTLIGHT_QUERY,s)},[]);l.useEffect(()=>{t&&(q(Ht()),ee(0))},[t]),l.useEffect(()=>{if(!t){ge([]),ye(!1);return}const s=R.trim();if(s.length<Nn){ge([]),ye(!1);return}ge([]),ye(!0);let i=!1;const g=setTimeout(()=>{vn(s).then(I=>{i||ge(I)}).catch(()=>{i||ge([])}).finally(()=>{i||ye(!1)})},250);return()=>{i=!0,clearTimeout(g)}},[t,R]);const Ct=(M.fileSearchExcludeDirs??it).join(",");l.useEffect(()=>{if(!t){pe([]),xe(!1);return}const s=R.trim();if(s.length<bn){pe([]),xe(!1);return}pe([]),xe(!0);let i=!1;const g=setTimeout(()=>{ys(s,{exclude:M.fileSearchExcludeDirs??[...it],limit:jn}).then(I=>{i||pe(I)}).catch(()=>{i||pe([])}).finally(()=>{i||xe(!1)})},250);return()=>{i=!0,clearTimeout(g)}},[t,R,Ct,M.fileSearchExcludeDirs]),l.useEffect(()=>{if(!t){te([]),ve(!1);return}const s=R.trim();if(s.length<Tn){te([]),ve(!1);return}te([]),ve(!0);const i=new AbortController,g=setTimeout(()=>{As(s,{exclude:M.fileSearchExcludeDirs??[...it],limit:Rn,signal:i.signal}).then(I=>{i.signal.aborted||te(I)}).catch(()=>{i.signal.aborted||te([])}).finally(()=>{i.signal.aborted||ve(!1)})},300);return()=>{clearTimeout(g),i.abort()}},[t,R,Ct,M.fileSearchExcludeDirs]),l.useEffect(()=>{if(!t){k({query:"",rows:[]}),v(!1);return}const s=R.trim();if(s.length<kn){k({query:"",rows:[]}),v(!1);return}k({query:"",rows:[]}),v(!0);let i=!1;const g=setTimeout(()=>{xs(s,{limit:Fn}).then(I=>{i||k({query:s,rows:I})}).catch(()=>{i||k({query:"",rows:[]})}).finally(()=>{i||v(!1)})},250);return()=>{i=!0,clearTimeout(g)}},[t,R]);const nt=l.useCallback(s=>{$e(s),Es(Fe.SPOTLIGHT_TAB,s)},[]),St=l.useRef(ie);St.current=ie;const rs=l.useCallback(s=>{const i=we.indexOf(St.current),g=we[(i+s+we.length)%we.length];nt(g)},[nt]);l.useEffect(()=>{ee(0)},[ie]);const rt=X.getShortcuts(),Oe=l.useMemo(()=>t?Ms():{},[t]),Ge=l.useMemo(()=>{if(!t)return[];const s=window.matchMedia("(pointer: coarse)").matches,i=rt.find(I=>I.id==="spawn-agent"),g=rt.find(I=>I.id==="toggle-commander");return[{id:"cmd-spawn",type:"command",title:"Spawn New Agent",subtitle:s?"":i?Rt(i):"Alt+N",icon:c.jsx(O,{name:"plus",size:16}),action:()=>{b.current(),L.current()}},{id:"cmd-commander",type:"command",title:"Commander View",subtitle:s?"":g!=null&&g.key?Rt(g):"Tab",icon:c.jsx(O,{name:"dashboard",size:16}),action:()=>{b.current(),G.current()}},{id:"cmd-settings",type:"command",title:"Settings & Tools",subtitle:"Configure Tide Commander",icon:c.jsx(O,{name:"gear",size:16}),action:()=>{b.current(),ce.current()}},{id:"cmd-monitoring",type:"command",title:"Monitoring & Logs",subtitle:"Triggers, workflows, events",icon:c.jsx(O,{name:"chart-line",size:16}),action:()=>{var I;b.current(),(I=oe.current)==null||I.call(oe)}}]},[t,rt]),Ue=l.useMemo(()=>{if(!t)return[];const s=R.trim();return(s?Rs(s):Ls).map(g=>({id:`setting-${g.id}`,type:"setting",title:g.title,subtitle:s?`Settings section • ${s}`:"Settings section",icon:c.jsx(O,{name:"gear",size:16}),_searchText:`${g.title} ${g.keywords.join(" ")}`,action:()=>{b.current(),ce.current(s||g.title)}}))},[t,R]),He=l.useMemo(()=>{const s=new Map;if(!t)return s;const i=Array.from(E.values());for(const g of y.values())for(const I of i)if(X.isPositionInArea({x:g.position.x,z:g.position.z},I)){s.set(g.id,I);break}return s},[t,y,E]),be=l.useMemo(()=>t?Array.from(y.values()).map(s=>{const i=[];s.lastAssignedTask&&i.push(s.lastAssignedTask);const g=`${s.class} • ${s.cwd}`,I=He.get(s.id),B=(I==null?void 0:I.name)||"";let T=`${s.name} ${s.class} ${s.status} ${s.cwd}`;s.taskLabel&&(T+=` ${s.taskLabel}`),B&&(T+=` ${B}`),i.length>0&&(T+=` ${i.join(" ")}`);const K=Date.now()-s.lastActivity;let $;return s.lastAssignedTask&&(s.lastAssignedTask.length>150?$=s.lastAssignedTask.slice(0,150)+"...":$=s.lastAssignedTask),{id:`agent-${s.id}`,type:"agent",title:s.name,subtitle:g,lastUserInput:$,timeAway:K,icon:c.jsx(Dt,{agent:s,size:20}),_searchText:T,_userQueries:i,_agentId:s.id,_lastActivity:s.lastActivity,_taskLabel:s.taskLabel,_status:s.status,_provider:s.provider??"claude",_piModel:s.piModel,_piModelProvider:s.piModelProvider,_areaName:B||void 0,_areaColor:I==null?void 0:I.color,action:()=>{b.current(),Lt(s.id),X.selectAgent(s.id),X.getState().viewMode!=="flat"&&X.requestTerminalExpand()}}}):[],[t,y,He]),We=l.useMemo(()=>t?Array.from(E.values()).map(s=>{var i;return{id:`area-${s.id}`,type:"area",title:s.name,subtitle:`${s.assignedAgentIds.length} agents • ${((i=s.directories)==null?void 0:i.length)||0} folders`,icon:c.jsx(O,{name:"map",size:16}),action:()=>{b.current(),X.selectArea(s.id)}}}):[],[t,E]),Ye=l.useMemo(()=>{const s=new Map;for(const i of be)i._agentId&&s.set(i._agentId,i);return s},[be]),_t=l.useMemo(()=>{const s=new Map;if(!t)return s;for(const i of y.values()){const g=He.get(i.id);if(!g||g.archived)continue;const I=s.get(g.id);I?I.push(i):s.set(g.id,[i])}return s},[t,y,He]),It=l.useMemo(()=>{const s=new Map;for(const i of N)s.has(i.agentId)||s.set(i.agentId,i.timestamp);return s},[N]),ot=l.useMemo(()=>{if(!t)return[];const s=R.trim().toLowerCase(),i=ke(s),g=Cs({sortMode:Bn(),agentsWithUnseenOutput:D,getLatestToolTimestamp:T=>It.get(T)}),I=Array.from(E.values()).filter(T=>!T.archived).filter(T=>{if(i.length===0)return!0;const K=T.name.toLowerCase();return i.some($=>K.includes($))}).sort((T,K)=>T.name.localeCompare(K.name,void 0,{sensitivity:"base"})),B=[];for(const T of I){const K=T.name.toLowerCase(),$=i.filter(W=>!K.includes(W));let H=(_t.get(T.id)||[]).slice().sort(g).map(W=>Ye.get(W.id)).filter(W=>!!W);$.length>0&&(H=H.filter(W=>{const z=`${W.title} ${W.subtitle||""} ${W._searchText||""}`.toLowerCase();return $.every(F=>z.includes(F))}),H.length===0)||!s&&H.length===0||B.push({areaId:T.id,areaName:T.name,areaColor:T.color,agents:H})}return B},[t,R,E,_t,Ye,D,It]),qe=l.useMemo(()=>t?Array.from(A.values()).filter(s=>s.type==="server"||s.type==="boss"||s.type==="database"||s.type==="tests").map(s=>{var $,re,H,W,z;const i=s.status==="running"?"#4ade80":s.status==="stopped"?"#f87171":"#facc15",g=s.type==="boss"?"crown":s.type==="database"?"database":s.type==="tests"?"flask":"desktop",I=s.type==="boss"?"Boss":s.type==="database"?"Database":s.type==="tests"?"Tests":"Server";let B=`${I} • ${s.status}`;if(s.type==="database"&&((re=($=s.database)==null?void 0:$.connections)!=null&&re.length)){const F=s.database.connections[0];B+=` • ${F.engine} @ ${F.host}`}else s.type==="tests"&&s.folderPath?B=`${I} • ${s.folderPath}`:s.cwd&&(B+=` • ${s.cwd}`);const T=((H=s.pm2Status)==null?void 0:H.ports)||[];let K=`${s.name} ${s.type} ${s.status} ${s.cwd||""} ${((W=s.pm2)==null?void 0:W.name)||""}`;if(s.type==="tests"&&(K+=` ${s.folderPath||""} tests junit maven`),T.length>0&&(K+=` ${T.join(" ")}`),s.type==="database"&&((z=s.database)!=null&&z.connections))for(const F of s.database.connections)K+=` ${F.name} ${F.engine} ${F.host} ${F.database||""} mysql postgresql sql`;return{id:`building-${s.id}`,type:"building",title:s.name,subtitle:B,_ports:T,icon:c.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[c.jsx(O,{name:"status-pending",size:10,weight:"fill",color:i}),c.jsx(O,{name:g,size:16})]}),_searchText:K,action:()=>{var F;b.current(),s.type==="boss"?Y.current(s.id):s.type==="database"?J.current(s.id):s.type==="tests"?X.openTestsBuilding(s.id):s.type==="http"?X.openHttpBuilding(s.id):(F=s.pm2)!=null&&F.enabled&&U.current(s.id)}}}):[],[t,A]),vt=l.useMemo(()=>t?Be.map(s=>{const i=s.isGitRepo&&s.gitBranch?`${s.path} • ${s.gitBranch}`:s.path;return{id:`folder-${s.path}`,type:"folder",title:s.name,subtitle:i,matchedText:s.path,icon:c.jsx(O,{name:s.isGitRepo?"git-branch":"folder",size:16}),_searchText:`${s.name} ${s.path}`,_isGitRepo:s.isGitRepo,_gitBranch:s.gitBranch,action:()=>{b.current(),X.openFileExplorer(s.path)}}}):[],[t,Be]),Ve=l.useMemo(()=>t?Pe.map(s=>{const i=s.areaName&&s.areaName!==s.projectName?`${s.projectName} · ${s.areaName}`:s.projectName;return{id:`file-${s.path}`,type:"file",title:s.name,subtitle:s.relativePath,matchedText:`${s.path} ${i}`,icon:kt(s.path),_searchText:`${s.name} ${s.relativePath} ${s.path} ${s.projectName} ${s.areaName}`,_projectName:s.projectName,_areaName:s.areaName,action:()=>{b.current(),Q.current({filePath:s.path,projectRoot:s.projectRoot,searchQuery:R.trim()})}}}):[],[t,Pe,R]),Xe=l.useMemo(()=>t?Qe.map(s=>{const i=s.matches[0],g=s.areaName&&s.areaName!==s.projectName?`${s.projectName} · ${s.areaName}`:s.projectName;return{id:`file-content-${s.path}`,type:"file-content",title:s.name,subtitle:`${s.relativePath}${i!=null&&i.line?`:${i.line}`:""}`,matchedQuery:i==null?void 0:i.content,matchedText:`${s.path} ${g}`,icon:kt(s.path),_projectName:s.projectName,_areaName:s.areaName,_lineNumber:i==null?void 0:i.line,action:()=>{b.current(),Q.current({filePath:s.path,projectRoot:s.projectRoot,targetLine:i==null?void 0:i.line,searchQuery:R.trim()})}}}):[],[t,Qe,R]),Me=l.useMemo(()=>{if(!t)return[];const s=i=>{const g=Date.now()-new Date(i).getTime();return!Number.isFinite(g)||g<0?"":g<36e5?`${Math.max(1,Math.floor(g/6e4))}m`:g<864e5?`${Math.floor(g/36e5)}h`:`${Math.floor(g/864e5)}d`};return S.rows.map(i=>{var W;const g=Array.from(y.values()).find(z=>z.sessionId===i.sessionId),I=g??(i.agentId?y.get(i.agentId):void 0),B=(i.firstPrompt||i.snippet||i.sessionId).slice(0,90),T=[i.projectPath||i.projectDir];I&&T.push(`→ ${I.name}${g?"":" (past session)"}`);const K=(W=i.extracts)==null?void 0:W.map(z=>z.timestamp?Date.parse(z.timestamp):Number.NaN).find(Number.isFinite),$=Date.parse(i.lastModified),re=K??(Number.isFinite($)?$:void 0),H=re===void 0?"":s(re);return H&&T.push(H),T.push(`${i.totalMatches}×`),{id:`session-${i.sessionId}`,type:"session",title:B,subtitle:T.join(" • "),matchedQuery:i.snippet||void 0,matchedExtracts:i.extracts&&i.extracts.length>0?i.extracts:void 0,_agentId:I==null?void 0:I.id,_sessionMatches:i.totalMatches,_sessionNearbyMatches:i.nearbyMatches,_matchedMessageAt:re,_provider:i.provider||"claude",icon:I?c.jsx(Dt,{agent:I,size:20}):c.jsx(O,{name:"history",size:16}),action:()=>{var F;b.current();const z=Array.from(X.getState().agents.values()).find(je=>je.sessionId===i.sessionId);z?(Lt(z.id),X.selectAgent(z.id),X.getState().viewMode!=="flat"&&X.requestTerminalExpand(),X.requestTerminalSearch(z.id,S.query)):(F=le.current)==null||F.call(le,{initialQuery:S.query,initialSessionKey:`${i.projectPath}::${i.sessionId}`})}}})},[t,S,y]),Nt=l.useMemo(()=>new de(be,{keys:["title","subtitle","_searchText","lastUserInput"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[be]),bt=l.useMemo(()=>new de(Ge,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[Ge]),jt=l.useMemo(()=>new de(We,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[We]),wt=l.useMemo(()=>new de(qe,{keys:["title","subtitle","_searchText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[qe]),Re=l.useMemo(()=>{if(!R.trim()){const p=[];p.push(...qe);const _=[...be].sort((w,P)=>{const Z=at(w._agentId,w._lastActivity,Oe);return at(P._agentId,P._lastActivity,Oe)-Z});p.push(..._),p.push(...We.slice(0,2));const j={};return Ut.forEach((w,P)=>{j[w]=P}),p.sort((w,P)=>(j[w.type]??999)-(j[P.type]??999)),p}const s=R.trim().toLowerCase(),i=ke(s),g=Ze(Nt,R).slice(0,30),I=Ze(jt,R).slice(0,2),B=vt.slice(0,8),T=Ve.slice(0,wn),K=Ue.slice(0,Dn),$=Ze(wt,R).filter(p=>{const _=p.score??1,j=`${p.item.title} ${p.item.subtitle||""} ${p.item._searchText||""}`.toLowerCase();return i.every(w=>j.includes(w))||_<=.2}).slice(0,4),re={agent:6,building:5,folder:4,file:4,"file-content":4,setting:4,command:3,area:2,"modified-file":1,session:0},H=p=>Mn(s,p.title,`${p.subtitle||""} ${p._searchText||""} ${p.matchedText||""}`),W=(p,_)=>{const j=(1-Math.min(1,_??1))*4;return H(p)*100+(re[p.type]??0)*5+j},z=new Map,F=(p,_)=>{const j=z.get(p.type),w={item:p,score:W(p,_)};j?j.push(w):z.set(p.type,[w])},je=new Map;for(const p of Me)p._agentId&&!je.has(p._agentId)&&je.set(p._agentId,p);for(const p of g){const _={...p.item};if(_._userQueries&&_._userQueries.length>0){const w=_._userQueries.find(P=>i.some(Z=>P.toLowerCase().includes(Z)));if(w){const P=w.toLowerCase(),Z=P.includes(s)?s:i.find(he=>P.includes(he))??s;if(w.length>200){const he=P.indexOf(Z),Le=Math.max(0,he-60),De=Math.min(w.length,he+Z.length+100);_.matchedQuery=(Le>0?"...":"")+w.slice(Le,De)+(De<w.length?"...":"")}else _.matchedQuery=w}}const j=_._agentId?je.get(_._agentId):void 0;if(j){_.matchedQuery||(_.matchedQuery=j.matchedQuery);const w=_.matchedQuery,P=(w==null?void 0:w.toLowerCase())??"";_.matchedExtracts=In(w&&i.every(Z=>P.includes(Z))?w:void 0,j.matchedExtracts),_.action=j.action,_._sessionMatches=j._sessionMatches,_._sessionNearbyMatches=j._sessionNearbyMatches,_._matchedMessageAt=j._matchedMessageAt,_._searchText=`${_._searchText||""} ${j.matchedQuery||""} ${s}`}F(_,p.score)}for(const[p,_]of je){if(g.some(w=>w.item._agentId===p))continue;const j=Ye.get(p);j&&F({...j,matchedQuery:_.matchedQuery,matchedExtracts:_.matchedExtracts,action:_.action,_sessionMatches:_._sessionMatches,_sessionNearbyMatches:_._sessionNearbyMatches,_matchedMessageAt:_._matchedMessageAt,_searchText:`${j._searchText||""} ${_.matchedQuery||""} ${s}`},void 0)}for(const p of $)F(p.item,p.score);for(const p of I)F(p.item,p.score);for(const p of K)F(p,void 0);for(const p of B)F(p,void 0);for(const p of T)F(p,void 0);for(const p of Xe.slice(0,Ln))F(p,void 0);const cs=24*36e5,ls=Date.now(),Tt=p=>{const _=at(p.item._agentId,p.item._lastActivity,Oe),j=Math.exp(-Math.LN2*Math.max(0,ls-_)/cs),w=p.item._sessionMatches??0,P=Math.log2(1+w),Z=p.item._sessionNearbyMatches;return(Z===void 0?P:Z>0?8+Math.log2(1+Z)+P*.1:P*.2)+(p.item._matchedMessageAt===void 0?2*j:0)};for(const[p,_]of z)p==="agent"?_.sort((j,w)=>{const P=H(j.item),Z=H(w.item);if(Z!==P)return Z-P;const Se=j.item._matchedMessageAt,he=w.item._matchedMessageAt;if(Se!==void 0||he!==void 0){if(Se===void 0)return 1;if(he===void 0)return-1;if(he!==Se)return he-Se}const Le=Tt(j),De=Tt(w);return De!==Le?De-Le:w.score-j.score}):_.sort((j,w)=>w.score-j.score);const Ce=[];for(const p of Ut){if(p==="session"){!Ee&&Me.length>ut?(Ce.push(...Me.slice(0,ut)),Ce.push({id:"session-show-all",type:"session",title:`Show all conversations (${Me.length})`,subtitle:`${Me.length-ut} more matches`,icon:c.jsx(O,{name:"arrow-down",size:16}),action:()=>Mt(!0)})):Ce.push(...Me);continue}const _=z.get(p);if(_){if(p==="agent"&&!Ne&&_.length>ht){for(const j of _.slice(0,ht))Ce.push(j.item);Ce.push({id:"agent-show-all",type:"agent",title:`Show all agents (${_.length})`,subtitle:`${_.length-ht} more matches`,icon:c.jsx(O,{name:"arrow-down",size:16}),action:()=>Te(!0)});continue}for(const j of _)Ce.push(j.item)}}return Ce},[R,Nt,jt,wt,be,Ye,We,qe,Ue,vt,Ve,Xe,Me,Oe,Ne,Ee]),ae=l.useMemo(()=>{switch(ie){case"agents":return Re.filter(s=>s.type==="agent");case"buildings":return Re.filter(s=>s.type==="building");case"commands":return R.trim()?Ze(bt,R).slice(0,3).map(s=>s.item):Ge;case"folders":return Re.filter(s=>s.type==="folder");case"files":return Ve;case"contents":return Xe;case"settings":return Ue;case"areas":return ot.flatMap(s=>s.agents);case"all":default:return Re}},[ie,Re,ot,Ve,Xe,Ue,R,bt,Ge]),os=l.useMemo(()=>{const s=[];if(Ke&&s.push("session"),Ie&&s.push("file"),ze&&s.push("file-content"),se&&s.push("folder"),ie==="all")return s;const g={buildings:"building",folders:"folder",files:"file",contents:"file-content",agents:"agent",settings:"setting",commands:"command"}[ie];return g&&s.includes(g)?[g]:[]},[ie,Ke,Ie,ze,se]);l.useEffect(()=>{V>=ae.length&&ee(Math.max(0,ae.length-1))},[ae.length,V]);const is=l.useCallback(s=>{if(s.altKey&&!s.ctrlKey&&!s.metaKey&&(s.key==="p"||s.key==="n"||s.key==="P"||s.key==="N")){s.preventDefault(),s.stopPropagation(),s.nativeEvent.stopImmediatePropagation();const i=s.key.toLowerCase();ee(i==="p"?g=>g>0?g-1:ae.length-1:g=>g<ae.length-1?g+1:0);return}switch(s.key){case"Escape":s.preventDefault(),b.current();break;case"ArrowUp":s.preventDefault(),ee(i=>i>0?i-1:ae.length-1);break;case"ArrowDown":s.preventDefault(),ee(i=>i<ae.length-1?i+1:0);break;case"Enter":s.preventDefault(),ae[V]&&ae[V].action();break}},[ae,V]),as=l.useCallback((s,i)=>{if(!i||!s)return s;const g=ke(i);if(g.length===0)return s;const I=new RegExp(g.map(En).sort((re,H)=>H.length-re.length).join("|"),"gi"),B=[];let T=0,K=0,$;for(;($=I.exec(s))!==null;)$.index>T&&B.push(s.slice(T,$.index)),B.push(ct.createElement("mark",{key:K++,className:"spotlight-highlight"},$[0])),T=$.index+$[0].length;return T<s.length&&B.push(s.slice(T)),B.length>0?ct.createElement(ct.Fragment,null,...B):s},[]);return{query:R,setQuery:ns,selectedIndex:V,setSelectedIndex:ee,results:ae,loadingTypes:os,activeTab:ie,setActiveTab:nt,cycleTab:rs,areaSections:ot,handleKeyDown:is,highlightMatch:as}}const Qn=l.forwardRef(function({query:e,onQueryChange:n,onKeyDown:r,onResetSelection:o,commandMode:a=!1,executingCommand:u=!1},d){const{t:h}=st(["common"]);return c.jsxs("div",{className:`spotlight-input-wrapper${a?" is-command-mode":""}`,children:[c.jsx("span",{className:"spotlight-search-icon",children:a?"›_":"⌘"}),c.jsx("input",{ref:d,type:"text",className:"spotlight-input",placeholder:h("common:search.spotlightPlaceholder"),value:e,onChange:f=>{n(f.target.value),o()},onKeyDown:r,autoFocus:!0,spellCheck:!1,disabled:u,"aria-label":a?"Plugin command":void 0}),c.jsxs("div",{className:"spotlight-input-hints",children:[c.jsx("span",{className:"spotlight-shortcut-hint",children:"↑↓"}),c.jsx("span",{className:"spotlight-shortcut-hint",children:"Enter"}),c.jsx("span",{className:"spotlight-shortcut-hint",children:"Esc"})]})]})}),zn=l.memo(function({activeTab:e,onSelect:n}){const{t:r}=st(["terminal"]);return c.jsxs("div",{className:"spotlight-tabs",role:"tablist","aria-label":r("terminal:spotlight.tabsLabel"),children:[we.map(o=>c.jsx("button",{type:"button",role:"tab","aria-selected":o===e,tabIndex:-1,className:`spotlight-tab${o===e?" active":""}`,onClick:()=>n(o),children:r(`terminal:spotlight.tabs.${o}`)},o)),c.jsx("span",{className:"spotlight-tabs-hint",children:c.jsx("kbd",{children:"Tab"})})]})}),Kn=l.forwardRef(function({results:e,loadingTypes:n,selectedIndex:r,query:o,activeTab:a,areaSections:u,highlightMatch:d,onSelectIndex:h},f){const{t:m}=st(["terminal"]),x=l.useRef(!1);l.useEffect(()=>{x.current=!1},[e]),l.useEffect(()=>{const A=typeof f=="function"?null:f==null?void 0:f.current;if(!A)return;const M=()=>{x.current=!0};return A.addEventListener("mousemove",M),()=>{A.removeEventListener("mousemove",M)}},[f,e]);const y={command:m("terminal:spotlight.categories.commands"),agent:m("terminal:spotlight.categories.agents"),building:m("terminal:spotlight.categories.infrastructure"),setting:m("terminal:spotlight.categories.settings"),area:m("terminal:spotlight.categories.areas"),folder:m("terminal:spotlight.categories.folders"),file:m("terminal:spotlight.categories.files"),"file-content":m("terminal:spotlight.categories.fileContents"),"modified-file":m("terminal:spotlight.categories.modifiedFiles"),session:m("terminal:spotlight.categories.sessions")},E=l.useMemo(()=>{const A=[];let M=null,N=[];e.forEach((b,L)=>{b.type!==M&&(M!==null&&N.length>0&&A.push([M,N]),M=b.type,N=[]),N.push({result:b,index:L})}),M!==null&&N.length>0&&A.push([M,N]);for(const b of n)A.some(([L])=>L===b)||A.push([b,[]]);const D=["agent","session","building","setting","file","file-content","folder","area","command"];return A.sort(([b],[L])=>D.indexOf(b)-D.indexOf(L)),A},[e,n]);if(l.useEffect(()=>{if(!f||typeof f=="function")return;const A=f.current;if(!A)return;const M=A.querySelector(".spotlight-item.selected");M&&M.scrollIntoView({block:"nearest",behavior:"smooth"})},[r,f]),a==="areas"){if(u.length===0)return c.jsx("div",{className:"spotlight-results",ref:f,children:c.jsx("div",{className:"spotlight-empty",children:m("terminal:spotlight.noResults")})});let A=0;return c.jsx("div",{className:"spotlight-results",ref:f,children:u.map(M=>c.jsxs("div",{children:[c.jsxs("div",{className:"spotlight-category-header spotlight-area-section-header",children:[c.jsx("span",{className:"spotlight-area-dot",style:{background:M.areaColor},"aria-hidden":"true"}),c.jsx("span",{className:"spotlight-area-name",children:M.areaName}),c.jsx("span",{className:"spotlight-area-count",children:M.agents.length})]}),M.agents.length===0?c.jsx("div",{className:"spotlight-area-empty",children:m("terminal:spotlight.noAgentsInArea")}):M.agents.map(N=>{const D=A++;return c.jsx(Ft,{result:N,isSelected:D===r,query:o,highlightMatch:d,onClick:()=>N.action(),onMouseEnter:()=>{x.current&&h(D)}},N.id)})]},M.areaId))})}return e.length===0&&n.length===0?c.jsx("div",{className:"spotlight-results",ref:f,children:c.jsx("div",{className:"spotlight-empty",children:m("terminal:spotlight.noResults")})}):c.jsx("div",{className:"spotlight-results",ref:f,children:E.map(([A,M])=>c.jsxs("div",{children:[(a==="all"||E.length>1)&&c.jsx("div",{className:"spotlight-category-header",children:y[A]||A}),n.includes(A)&&c.jsxs("div",{className:"spotlight-block-loading",role:"status",children:[c.jsx("span",{className:"spotlight-loading-spinner","aria-hidden":"true"}),m("terminal:spotlight.searching")]}),M.map(({result:N,index:D})=>c.jsx(Ft,{result:N,isSelected:D===r,query:o,highlightMatch:d,onClick:()=>N.action(),onMouseEnter:()=>{x.current&&h(D)}},N.id))]},A))})}),On=l.memo(function({commandMode:e=!1}){const{t:n}=st(["terminal"]);return c.jsxs("div",{className:"spotlight-footer",children:[c.jsxs("div",{className:"spotlight-footer-left",children:[c.jsxs("span",{className:"spotlight-footer-hint",children:[c.jsx("kbd",{children:"↑"}),c.jsx("kbd",{children:"↓"})," ",c.jsx("kbd",{children:"Alt+N"}),c.jsx("kbd",{children:"Alt+P"})," ",n("terminal:spotlight.navigate")]}),c.jsxs("span",{className:"spotlight-footer-hint",children:[c.jsx("kbd",{children:"Enter"})," ",e?"run command":n("terminal:spotlight.select")]}),c.jsxs("span",{className:"spotlight-footer-hint",children:[c.jsx("kbd",{children:"Tab"})," ",e?"complete command":n("terminal:spotlight.switchTabs")]})]}),c.jsx("div",{className:"spotlight-footer-right",children:c.jsxs("span",{className:"spotlight-footer-hint",children:[c.jsx("kbd",{children:"Esc"})," ",n("common:buttons.close")]})})]})});function Gn({detail:t,onClose:e}){const[n,r]=l.useState(null),[o,a]=l.useState(!0),[u,d]=l.useState(null);_s("spotlight-file-detail",!0,e),l.useEffect(()=>{const E=new AbortController;return a(!0),d(null),r(null),(async()=>{try{const M=await dt(ft(`/api/files/read?path=${encodeURIComponent(t.filePath)}`),{signal:E.signal}),N=await M.json();if(!M.ok)throw new Error(N.error||"Unable to read file");let D=null;if(!N.binary)try{const b=await dt(ft(`/api/files/git-original?path=${encodeURIComponent(t.filePath)}`),{signal:E.signal}),L=await b.json();b.ok&&!L.binary&&typeof L.content=="string"&&(D=L.content)}catch{}E.signal.aborted||r({filename:N.filename||t.filePath.split("/").pop()||t.filePath,content:typeof N.content=="string"?N.content:"",originalContent:D,binary:N.binary===!0})}catch(M){E.signal.aborted||d(M instanceof Error?M.message:"Unable to load file")}finally{E.signal.aborted||a(!1)}})(),()=>E.abort()},[t.filePath]),l.useEffect(()=>{const E=A=>{A.key==="Escape"&&(A.preventDefault(),A.stopImmediatePropagation(),e())};return document.addEventListener("keydown",E,!0),()=>document.removeEventListener("keydown",E,!0)},[e]);const h=()=>{X.revealFileInExplorer(t.filePath,t.projectRoot,t.targetLine),e()},f=(n==null?void 0:n.filename)||t.filePath,m=f.lastIndexOf(".")>=0?f.slice(f.lastIndexOf(".")):"",x=Is(m),y=(n==null?void 0:n.originalContent)!=null&&n.originalContent!==n.content;return c.jsx("div",{className:"guake-git-diff-modal-overlay",onClick:e,children:c.jsxs("div",{className:"guake-git-diff-modal",onClick:E=>E.stopPropagation(),children:[c.jsxs("div",{className:"guake-git-diff-modal-header",children:[c.jsxs("div",{className:"guake-git-diff-path spotlight-file-detail-path",title:t.filePath,children:[t.filePath,t.targetLine?c.jsxs("span",{className:"spotlight-file-detail-line",children:[":",t.targetLine]}):null]}),c.jsxs("button",{type:"button",className:"spotlight-file-detail-explorer",onClick:h,title:"Open in File Explorer",children:[c.jsx(O,{name:"folder-open",size:14}),"Open in File Explorer"]}),c.jsx("button",{className:"guake-git-close",onClick:e,title:"Close (Esc)",children:c.jsx(O,{name:"close",size:14})})]}),c.jsxs("div",{className:"guake-git-diff-content",children:[o&&c.jsx("div",{className:"guake-git-diff-loading-overlay",children:c.jsx("div",{className:"diff-image-spinner"})}),u&&c.jsx("div",{className:"spotlight-file-detail-message",children:u}),(n==null?void 0:n.binary)&&c.jsx("div",{className:"spotlight-file-detail-message",children:"Binary preview is available in the File Explorer."}),n&&!n.binary&&(y?c.jsx($t,{originalContent:n.originalContent||"",modifiedContent:n.content,filename:n.filename,filePath:t.filePath,language:x,searchQuery:t.searchQuery,targetLine:t.targetLine}):c.jsx($t,{originalContent:"",modifiedContent:n.content,filename:n.filename,filePath:t.filePath,language:x,initialModifiedOnly:!0,searchQuery:t.searchQuery,targetLine:t.targetLine,readOnly:!0}))]})]})})}const Un=l.forwardRef(function({commands:e,selectedIndex:n,executing:r,error:o,onSelectIndex:a,onExecute:u},d){return l.useEffect(()=>{var h,f;!d||typeof d=="function"||(f=(h=d.current)==null?void 0:h.querySelector(".spotlight-command-item.selected"))==null||f.scrollIntoView({block:"nearest"})},[d,n]),c.jsxs("div",{className:"spotlight-results spotlight-command-results",ref:d,children:[c.jsxs("div",{className:"spotlight-command-mode-banner",children:[c.jsx("span",{className:"spotlight-command-mode-icon",children:c.jsx(O,{name:"terminal",size:13})}),c.jsxs("div",{children:[c.jsx("strong",{children:"Plugin command mode"}),c.jsx("span",{children:"Runs locally without sending a prompt to an AI agent"})]})]}),o&&c.jsxs("div",{className:"spotlight-command-error",role:"alert",children:[c.jsx(O,{name:"warn",size:13}),c.jsx("span",{children:o})]}),e.length===0?c.jsxs("div",{className:"spotlight-empty spotlight-command-empty",children:[c.jsx(O,{name:"search",size:18}),c.jsx("strong",{children:"No matching plugin command"}),c.jsxs("span",{children:["Type ",c.jsx("code",{children:"/"})," to see enabled plugin commands."]})]}):e.map((h,f)=>c.jsxs("button",{type:"button",className:`spotlight-item spotlight-command-item${f===n?" selected":""}`,disabled:r,onMouseEnter:()=>a(f),onClick:()=>u(h),children:[c.jsx("span",{className:"spotlight-item-icon spotlight-command-item-icon",children:c.jsx(O,{name:"plug",size:16})}),c.jsxs("span",{className:"spotlight-item-content",children:[c.jsxs("span",{className:"spotlight-item-header",children:[c.jsx("code",{className:"spotlight-command-name",children:h.name}),h.name!==h.canonicalName&&c.jsxs("span",{className:"spotlight-command-alias",children:["alias of ",h.canonicalName]})]}),c.jsx("span",{className:"spotlight-item-subtitle",children:h.summary})]}),c.jsx("span",{className:"spotlight-command-plugin-badge",children:h.pluginName}),r&&f===n?c.jsx("span",{className:"spotlight-loading-spinner","aria-label":"Running command"}):c.jsx("span",{className:"spotlight-command-enter",children:"↵"})]},`${h.pluginId}:${h.name}`))]})}),Hn=768;function Xn({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:o,onOpenFileExplorer:a,onOpenPM2LogsModal:u,onOpenBossLogsModal:d,onOpenDatabasePanel:h,onOpenMonitoringModal:f,onOpenSessionFinder:m}){const x=l.useRef(null),y=l.useRef(null),E=l.useRef(null),A=l.useRef(0),M=l.useRef(!1),N=l.useRef(()=>{}),[D,b]=l.useState(null),[L,G]=l.useState(0),[ce,me]=l.useState(!1),[U,Y]=l.useState(null),[J,oe]=l.useState(null),le=vs(),{query:Q,setQuery:R,selectedIndex:q,setSelectedIndex:V,results:ee,loadingTypes:ie,activeTab:$e,setActiveTab:Be,cycleTab:ge,areaSections:Pe,handleKeyDown:pe,highlightMatch:Qe}=Pn({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:o,onOpenFileExplorer:a,onOpenPM2LogsModal:u,onOpenBossLogsModal:d,onOpenDatabasePanel:h,onOpenMonitoringModal:f,onOpenSessionFinder:m,onOpenFileDetail:b}),te=Q.startsWith("/"),se=l.useMemo(()=>Ns(Q,bs()),[Q,le]),ye=l.useCallback(()=>{const v=se[L];if(!v)return;const S=Q.trim().replace(/^\S+/,"");R(`${v.name}${S}`),G(0)},[se,L,Q,R]),Ie=l.useCallback(async v=>{me(!0),Y(null);try{const S=v.pluginId===js||v.requiresAgent?X.getState().selectedAgentIds.values().next().value:void 0,k=await ws(v,Q,{agentId:S});k.kind==="output"&&oe(k),e()}catch(S){Y(S instanceof Error?S.message:String(S))}finally{me(!1)}},[e,Q]);A.current=te?se.length:ee.length,M.current=te,N.current=ye;const xe=l.useRef(ge);xe.current=ge,l.useEffect(()=>{t&&(oe(null),Y(null),setTimeout(()=>{var v,S;(v=x.current)==null||v.focus(),(S=x.current)==null||S.select()},50))},[t]),l.useEffect(()=>{if(!t)return;const v=window.visualViewport;if(!v||window.innerWidth>Hn)return;const S=()=>{const k=y.current;k&&(k.style.height=`${v.height}px`,k.style.top=`${v.offsetTop}px`)};return S(),v.addEventListener("resize",S),v.addEventListener("scroll",S),()=>{v.removeEventListener("resize",S),v.removeEventListener("scroll",S);const k=y.current;k&&(k.style.height="",k.style.top="")}},[t]),l.useEffect(()=>{if(!t)return;const v=S=>{if(S.key==="Escape"){S.preventDefault(),S.stopPropagation(),S.stopImmediatePropagation(),e();return}if(S.key==="Tab"){S.preventDefault(),S.stopPropagation(),S.stopImmediatePropagation(),M.current?N.current():xe.current(S.shiftKey?-1:1);return}if(S.altKey&&!S.ctrlKey&&!S.metaKey&&(S.key==="n"||S.key==="p"||S.key==="N"||S.key==="P")){S.preventDefault(),S.stopPropagation(),S.stopImmediatePropagation();const k=S.key.toLowerCase(),Ne=A.current;if(Ne===0)return;const Te=Ee=>k==="p"?Ee>0?Ee-1:Ne-1:Ee<Ne-1?Ee+1:0;M.current?G(Te):V(Te);return}};return window.addEventListener("keydown",v,{capture:!0}),()=>{window.removeEventListener("keydown",v,{capture:!0})}},[t,e]);const ze=l.useCallback(v=>{v.target===v.currentTarget&&e()},[e]),ve=l.useCallback(()=>{V(0),G(0),Y(null)},[V]);l.useEffect(()=>{L>=se.length&&G(Math.max(0,se.length-1))},[se.length,L]);const Ke=l.useCallback(v=>{if(!te){pe(v);return}const S=se.length;if(v.key==="ArrowUp"||v.key==="ArrowDown"){if(v.preventDefault(),S===0)return;G(k=>v.key==="ArrowUp"?k>0?k-1:S-1:k<S-1?k+1:0);return}if(v.key==="Tab"){v.preventDefault(),ye();return}if(v.key==="Enter"){v.preventDefault();const k=se[L];k&&!ce&&Ie(k)}},[se,te,L,ye,Ie,ce,pe]);return t?c.jsx("div",{ref:y,className:"spotlight-overlay",onClick:ze,children:c.jsxs("div",{className:"spotlight-modal",children:[c.jsx(Qn,{ref:x,query:Q,onQueryChange:R,onKeyDown:Ke,onResetSelection:ve,commandMode:te,executingCommand:ce}),!te&&c.jsx(zn,{activeTab:$e,onSelect:Be}),te?c.jsx(Un,{ref:E,commands:se,selectedIndex:L,executing:ce,error:U,onSelectIndex:G,onExecute:v=>void Ie(v)}):c.jsx(Kn,{ref:E,results:ee,loadingTypes:ie,selectedIndex:q,query:Q,activeTab:$e,areaSections:Pe,highlightMatch:Qe,onSelectIndex:V}),c.jsx(On,{commandMode:te})]})}):J?c.jsx(Ts,{command:J.command,output:J.output,onClose:()=>oe(null)}):D?c.jsx(Gn,{detail:D,onClose:()=>b(null)}):null}export{er as FILE_ICON_NAMES,Xn as Spotlight,On as SpotlightFooter,Qn as SpotlightInput,Ft as SpotlightItem,Kn as SpotlightResults,tr as formatDuration,sr as formatRelativeTime,nr as getAgentIcon,kt as getFileIconFromPath,rr as getTypeLabel,Pn as useSpotlightSearch};
|
|
1
|
+
import{c as dt,d as ft,E as us,a1 as hs,f as ds,bm as fs,c8 as ms,ah as gs,r as l,z as ps,S as Fe,c9 as it,ca as ys,cb as As,cc as xs,az as Es,cd as we,s as X,ce as Ms,j as c,I as O,W as Rt,cf as Lt,t as Dt,cg as Cs,ch as kt,ci as at,V as ct,m as Ss,ay as Wt,u as st,cj as Ft,aJ as _s,ck as $t,cl as Is,cm as vs,cn as Ns,co as bs,cp as js,cq as ws,cr as Ts}from"./main-DAjvgfMx.js";import{cs as er,ct as tr,cu as sr,cv as nr,cw as rr}from"./main-DAjvgfMx.js";import{s as Rs,S as Ls}from"./settingsSearch-DYr4vFyy.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-DYBBrXTx.js";function fe(t){return Array.isArray?Array.isArray(t):Vt(t)==="[object Array]"}function Ds(t){if(typeof t=="string")return t;let e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function ks(t){return t==null?"":Ds(t)}function ue(t){return typeof t=="string"}function Yt(t){return typeof t=="number"}function Fs(t){return t===!0||t===!1||$s(t)&&Vt(t)=="[object Boolean]"}function qt(t){return typeof t=="object"}function $s(t){return qt(t)&&t!==null}function ne(t){return t!=null}function lt(t){return!t.trim().length}function Vt(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const Bs="Incorrect 'index' type",Ps=t=>`Invalid value for key ${t}`,Qs=t=>`Pattern length exceeds max of ${t}.`,zs=t=>`Missing ${t} property in key`,Ks=t=>`Property 'weight' in key '${t}' must be a positive integer`,Bt=Object.prototype.hasOwnProperty;class Os{constructor(e){this._keys=[],this._keyMap={};let n=0;e.forEach(r=>{let o=Xt(r);this._keys.push(o),this._keyMap[o.id]=o,n+=o.weight}),this._keys.forEach(r=>{r.weight/=n})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Xt(t){let e=null,n=null,r=null,o=1,a=null;if(ue(t)||fe(t))r=t,e=Pt(t),n=mt(t);else{if(!Bt.call(t,"name"))throw new Error(zs("name"));const u=t.name;if(r=u,Bt.call(t,"weight")&&(o=t.weight,o<=0))throw new Error(Ks(u));e=Pt(u),n=mt(u),a=t.getFn}return{path:e,id:n,weight:o,src:r,getFn:a}}function Pt(t){return fe(t)?t:t.split(".")}function mt(t){return fe(t)?t.join("."):t}function Gs(t,e){let n=[],r=!1;const o=(a,u,d)=>{if(ne(a))if(!u[d])n.push(a);else{let h=u[d];const f=a[h];if(!ne(f))return;if(d===u.length-1&&(ue(f)||Yt(f)||Fs(f)))n.push(ks(f));else if(fe(f)){r=!0;for(let m=0,x=f.length;m<x;m+=1)o(f[m],u,d+1)}else u.length&&o(f,u,d+1)}};return o(t,ue(e)?e.split("."):e,0),r?n:n[0]}const Us={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Hs={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},Ws={location:0,threshold:.6,distance:100},Ys={useExtendedSearch:!1,getFn:Gs,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var C={...Hs,...Us,...Ws,...Ys};const qs=/[^ ]+/g;function Vs(t=1,e=3){const n=new Map,r=Math.pow(10,e);return{get(o){const a=o.match(qs).length;if(n.has(a))return n.get(a);const u=1/Math.pow(a,.5*t),d=parseFloat(Math.round(u*r)/r);return n.set(a,d),d},clear(){n.clear()}}}class Et{constructor({getFn:e=C.getFn,fieldNormWeight:n=C.fieldNormWeight}={}){this.norm=Vs(n,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((n,r)=>{this._keysMap[n.id]=r})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,ue(this.docs[0])?this.docs.forEach((e,n)=>{this._addString(e,n)}):this.docs.forEach((e,n)=>{this._addObject(e,n)}),this.norm.clear())}add(e){const n=this.size();ue(e)?this._addString(e,n):this._addObject(e,n)}removeAt(e){this.records.splice(e,1);for(let n=e,r=this.size();n<r;n+=1)this.records[n].i-=1}getValueForItemAtKeyId(e,n){return e[this._keysMap[n]]}size(){return this.records.length}_addString(e,n){if(!ne(e)||lt(e))return;let r={v:e,i:n,n:this.norm.get(e)};this.records.push(r)}_addObject(e,n){let r={i:n,$:{}};this.keys.forEach((o,a)=>{let u=o.getFn?o.getFn(e):this.getFn(e,o.path);if(ne(u)){if(fe(u)){let d=[];const h=[{nestedArrIndex:-1,value:u}];for(;h.length;){const{nestedArrIndex:f,value:m}=h.pop();if(ne(m))if(ue(m)&&!lt(m)){let x={v:m,i:f,n:this.norm.get(m)};d.push(x)}else fe(m)&&m.forEach((x,y)=>{h.push({nestedArrIndex:y,value:x})})}r.$[a]=d}else if(ue(u)&&!lt(u)){let d={v:u,n:this.norm.get(u)};r.$[a]=d}}}),this.records.push(r)}toJSON(){return{keys:this.keys,records:this.records}}}function Jt(t,e,{getFn:n=C.getFn,fieldNormWeight:r=C.fieldNormWeight}={}){const o=new Et({getFn:n,fieldNormWeight:r});return o.setKeys(t.map(Xt)),o.setSources(e),o.create(),o}function Xs(t,{getFn:e=C.getFn,fieldNormWeight:n=C.fieldNormWeight}={}){const{keys:r,records:o}=t,a=new Et({getFn:e,fieldNormWeight:n});return a.setKeys(r),a.setIndexRecords(o),a}function Je(t,{errors:e=0,currentLocation:n=0,expectedLocation:r=0,distance:o=C.distance,ignoreLocation:a=C.ignoreLocation}={}){const u=e/t.length;if(a)return u;const d=Math.abs(r-n);return o?u+d/o:d?1:u}function Js(t=[],e=C.minMatchCharLength){let n=[],r=-1,o=-1,a=0;for(let u=t.length;a<u;a+=1){let d=t[a];d&&r===-1?r=a:!d&&r!==-1&&(o=a-1,o-r+1>=e&&n.push([r,o]),r=-1)}return t[a-1]&&a-r>=e&&n.push([r,a-1]),n}const _e=32;function Zs(t,e,n,{location:r=C.location,distance:o=C.distance,threshold:a=C.threshold,findAllMatches:u=C.findAllMatches,minMatchCharLength:d=C.minMatchCharLength,includeMatches:h=C.includeMatches,ignoreLocation:f=C.ignoreLocation}={}){if(e.length>_e)throw new Error(Qs(_e));const m=e.length,x=t.length,y=Math.max(0,Math.min(r,x));let E=a,A=y;const M=d>1||h,N=M?Array(x):[];let D;for(;(D=t.indexOf(e,A))>-1;){let U=Je(e,{currentLocation:D,expectedLocation:y,distance:o,ignoreLocation:f});if(E=Math.min(U,E),A=D+m,M){let Y=0;for(;Y<m;)N[D+Y]=1,Y+=1}}A=-1;let b=[],L=1,G=m+x;const ce=1<<m-1;for(let U=0;U<m;U+=1){let Y=0,J=G;for(;Y<J;)Je(e,{errors:U,currentLocation:y+J,expectedLocation:y,distance:o,ignoreLocation:f})<=E?Y=J:G=J,J=Math.floor((G-Y)/2+Y);G=J;let oe=Math.max(1,y-J+1),le=u?x:Math.min(y+J,x)+m,Q=Array(le+2);Q[le+1]=(1<<U)-1;for(let q=le;q>=oe;q-=1){let V=q-1,ee=n[t.charAt(V)];if(M&&(N[V]=+!!ee),Q[q]=(Q[q+1]<<1|1)&ee,U&&(Q[q]|=(b[q+1]|b[q])<<1|1|b[q+1]),Q[q]&ce&&(L=Je(e,{errors:U,currentLocation:V,expectedLocation:y,distance:o,ignoreLocation:f}),L<=E)){if(E=L,A=V,A<=y)break;oe=Math.max(1,2*y-A)}}if(Je(e,{errors:U+1,currentLocation:y,expectedLocation:y,distance:o,ignoreLocation:f})>E)break;b=Q}const me={isMatch:A>=0,score:Math.max(.001,L)};if(M){const U=Js(N,d);U.length?h&&(me.indices=U):me.isMatch=!1}return me}function en(t){let e={};for(let n=0,r=t.length;n<r;n+=1){const o=t.charAt(n);e[o]=(e[o]||0)|1<<r-n-1}return e}const et=String.prototype.normalize?(t=>t.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,"")):(t=>t);class Zt{constructor(e,{location:n=C.location,threshold:r=C.threshold,distance:o=C.distance,includeMatches:a=C.includeMatches,findAllMatches:u=C.findAllMatches,minMatchCharLength:d=C.minMatchCharLength,isCaseSensitive:h=C.isCaseSensitive,ignoreDiacritics:f=C.ignoreDiacritics,ignoreLocation:m=C.ignoreLocation}={}){if(this.options={location:n,threshold:r,distance:o,includeMatches:a,findAllMatches:u,minMatchCharLength:d,isCaseSensitive:h,ignoreDiacritics:f,ignoreLocation:m},e=h?e:e.toLowerCase(),e=f?et(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const x=(E,A)=>{this.chunks.push({pattern:E,alphabet:en(E),startIndex:A})},y=this.pattern.length;if(y>_e){let E=0;const A=y%_e,M=y-A;for(;E<M;)x(this.pattern.substr(E,_e),E),E+=_e;if(A){const N=y-_e;x(this.pattern.substr(N),N)}}else x(this.pattern,0)}searchIn(e){const{isCaseSensitive:n,ignoreDiacritics:r,includeMatches:o}=this.options;if(e=n?e:e.toLowerCase(),e=r?et(e):e,this.pattern===e){let M={isMatch:!0,score:0};return o&&(M.indices=[[0,e.length-1]]),M}const{location:a,distance:u,threshold:d,findAllMatches:h,minMatchCharLength:f,ignoreLocation:m}=this.options;let x=[],y=0,E=!1;this.chunks.forEach(({pattern:M,alphabet:N,startIndex:D})=>{const{isMatch:b,score:L,indices:G}=Zs(e,M,N,{location:a+D,distance:u,threshold:d,findAllMatches:h,minMatchCharLength:f,includeMatches:o,ignoreLocation:m});b&&(E=!0),y+=L,b&&G&&(x=[...x,...G])});let A={isMatch:E,score:E?y/this.chunks.length:1};return E&&o&&(A.indices=x),A}}class Ae{constructor(e){this.pattern=e}static isMultiMatch(e){return Qt(e,this.multiRegex)}static isSingleMatch(e){return Qt(e,this.singleRegex)}search(){}}function Qt(t,e){const n=t.match(e);return n?n[1]:null}class tn extends Ae{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const n=e===this.pattern;return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class sn extends Ae{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const r=e.indexOf(this.pattern)===-1;return{isMatch:r,score:r?0:1,indices:[0,e.length-1]}}}class nn extends Ae{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const n=e.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class rn extends Ae{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const n=!e.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class on extends Ae{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const n=e.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class an extends Ae{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const n=!e.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class es extends Ae{constructor(e,{location:n=C.location,threshold:r=C.threshold,distance:o=C.distance,includeMatches:a=C.includeMatches,findAllMatches:u=C.findAllMatches,minMatchCharLength:d=C.minMatchCharLength,isCaseSensitive:h=C.isCaseSensitive,ignoreDiacritics:f=C.ignoreDiacritics,ignoreLocation:m=C.ignoreLocation}={}){super(e),this._bitapSearch=new Zt(e,{location:n,threshold:r,distance:o,includeMatches:a,findAllMatches:u,minMatchCharLength:d,isCaseSensitive:h,ignoreDiacritics:f,ignoreLocation:m})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class ts extends Ae{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let n=0,r;const o=[],a=this.pattern.length;for(;(r=e.indexOf(this.pattern,n))>-1;)n=r+a,o.push([r,n-1]);const u=!!o.length;return{isMatch:u,score:u?0:1,indices:o}}}const gt=[tn,ts,nn,rn,an,on,sn,es],zt=gt.length,cn=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,ln="|";function un(t,e={}){return t.split(ln).map(n=>{let r=n.trim().split(cn).filter(a=>a&&!!a.trim()),o=[];for(let a=0,u=r.length;a<u;a+=1){const d=r[a];let h=!1,f=-1;for(;!h&&++f<zt;){const m=gt[f];let x=m.isMultiMatch(d);x&&(o.push(new m(x,e)),h=!0)}if(!h)for(f=-1;++f<zt;){const m=gt[f];let x=m.isSingleMatch(d);if(x){o.push(new m(x,e));break}}}return o})}const hn=new Set([es.type,ts.type]);class dn{constructor(e,{isCaseSensitive:n=C.isCaseSensitive,ignoreDiacritics:r=C.ignoreDiacritics,includeMatches:o=C.includeMatches,minMatchCharLength:a=C.minMatchCharLength,ignoreLocation:u=C.ignoreLocation,findAllMatches:d=C.findAllMatches,location:h=C.location,threshold:f=C.threshold,distance:m=C.distance}={}){this.query=null,this.options={isCaseSensitive:n,ignoreDiacritics:r,includeMatches:o,minMatchCharLength:a,findAllMatches:d,ignoreLocation:u,location:h,threshold:f,distance:m},e=n?e:e.toLowerCase(),e=r?et(e):e,this.pattern=e,this.query=un(this.pattern,this.options)}static condition(e,n){return n.useExtendedSearch}searchIn(e){const n=this.query;if(!n)return{isMatch:!1,score:1};const{includeMatches:r,isCaseSensitive:o,ignoreDiacritics:a}=this.options;e=o?e:e.toLowerCase(),e=a?et(e):e;let u=0,d=[],h=0;for(let f=0,m=n.length;f<m;f+=1){const x=n[f];d.length=0,u=0;for(let y=0,E=x.length;y<E;y+=1){const A=x[y],{isMatch:M,indices:N,score:D}=A.search(e);if(M){if(u+=1,h+=D,r){const b=A.constructor.type;hn.has(b)?d=[...d,...N]:d.push(N)}}else{h=0,u=0,d.length=0;break}}if(u){let y={isMatch:!0,score:h/u};return r&&(y.indices=d),y}}return{isMatch:!1,score:1}}}const pt=[];function fn(...t){pt.push(...t)}function yt(t,e){for(let n=0,r=pt.length;n<r;n+=1){let o=pt[n];if(o.condition(t,e))return new o(t,e)}return new Zt(t,e)}const tt={AND:"$and",OR:"$or"},At={PATH:"$path",PATTERN:"$val"},xt=t=>!!(t[tt.AND]||t[tt.OR]),mn=t=>!!t[At.PATH],gn=t=>!fe(t)&&qt(t)&&!xt(t),Kt=t=>({[tt.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function ss(t,e,{auto:n=!0}={}){const r=o=>{let a=Object.keys(o);const u=mn(o);if(!u&&a.length>1&&!xt(o))return r(Kt(o));if(gn(o)){const h=u?o[At.PATH]:a[0],f=u?o[At.PATTERN]:o[h];if(!ue(f))throw new Error(Ps(h));const m={keyId:mt(h),pattern:f};return n&&(m.searcher=yt(f,e)),m}let d={children:[],operator:a[0]};return a.forEach(h=>{const f=o[h];fe(f)&&f.forEach(m=>{d.children.push(r(m))})}),d};return xt(t)||(t=Kt(t)),r(t)}function pn(t,{ignoreFieldNorm:e=C.ignoreFieldNorm}){t.forEach(n=>{let r=1;n.matches.forEach(({key:o,norm:a,score:u})=>{const d=o?o.weight:null;r*=Math.pow(u===0&&d?Number.EPSILON:u,(d||1)*(e?1:a))}),n.score=r})}function yn(t,e){const n=t.matches;e.matches=[],ne(n)&&n.forEach(r=>{if(!ne(r.indices)||!r.indices.length)return;const{indices:o,value:a}=r;let u={indices:o,value:a};r.key&&(u.key=r.key.src),r.idx>-1&&(u.refIndex=r.idx),e.matches.push(u)})}function An(t,e){e.score=t.score}function xn(t,e,{includeMatches:n=C.includeMatches,includeScore:r=C.includeScore}={}){const o=[];return n&&o.push(yn),r&&o.push(An),t.map(a=>{const{idx:u}=a,d={item:e[u],refIndex:u};return o.length&&o.forEach(h=>{h(a,d)}),d})}class de{constructor(e,n={},r){this.options={...C,...n},this.options.useExtendedSearch,this._keyStore=new Os(this.options.keys),this.setCollection(e,r)}setCollection(e,n){if(this._docs=e,n&&!(n instanceof Et))throw new Error(Bs);this._myIndex=n||Jt(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){ne(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const n=[];for(let r=0,o=this._docs.length;r<o;r+=1){const a=this._docs[r];e(a,r)&&(this.removeAt(r),r-=1,o-=1,n.push(a))}return n}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:n=-1}={}){const{includeMatches:r,includeScore:o,shouldSort:a,sortFn:u,ignoreFieldNorm:d}=this.options;let h=ue(e)?ue(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return pn(h,{ignoreFieldNorm:d}),a&&h.sort(u),Yt(n)&&n>-1&&(h=h.slice(0,n)),xn(h,this._docs,{includeMatches:r,includeScore:o})}_searchStringList(e){const n=yt(e,this.options),{records:r}=this._myIndex,o=[];return r.forEach(({v:a,i:u,n:d})=>{if(!ne(a))return;const{isMatch:h,score:f,indices:m}=n.searchIn(a);h&&o.push({item:a,idx:u,matches:[{score:f,value:a,norm:d,indices:m}]})}),o}_searchLogical(e){const n=ss(e,this.options),r=(d,h,f)=>{if(!d.children){const{keyId:x,searcher:y}=d,E=this._findMatches({key:this._keyStore.get(x),value:this._myIndex.getValueForItemAtKeyId(h,x),searcher:y});return E&&E.length?[{idx:f,item:h,matches:E}]:[]}const m=[];for(let x=0,y=d.children.length;x<y;x+=1){const E=d.children[x],A=r(E,h,f);if(A.length)m.push(...A);else if(d.operator===tt.AND)return[]}return m},o=this._myIndex.records,a={},u=[];return o.forEach(({$:d,i:h})=>{if(ne(d)){let f=r(n,d,h);f.length&&(a[h]||(a[h]={idx:h,item:d,matches:[]},u.push(a[h])),f.forEach(({matches:m})=>{a[h].matches.push(...m)}))}}),u}_searchObjectList(e){const n=yt(e,this.options),{keys:r,records:o}=this._myIndex,a=[];return o.forEach(({$:u,i:d})=>{if(!ne(u))return;let h=[];r.forEach((f,m)=>{h.push(...this._findMatches({key:f,value:u[m],searcher:n}))}),h.length&&a.push({idx:d,item:u,matches:h})}),a}_findMatches({key:e,value:n,searcher:r}){if(!ne(n))return[];let o=[];if(fe(n))n.forEach(({v:a,i:u,n:d})=>{if(!ne(a))return;const{isMatch:h,score:f,indices:m}=r.searchIn(a);h&&o.push({score:f,key:e,value:a,idx:u,norm:d,indices:m})});else{const{v:a,n:u}=n,{isMatch:d,score:h,indices:f}=r.searchIn(a);d&&o.push({score:h,key:e,value:a,norm:u,indices:f})}return o}}de.version="7.1.0";de.createIndex=Jt;de.parseIndex=Xs;de.config=C;de.parseQuery=ss;fn(dn);function ke(t){return t.trim().toLowerCase().split(/\s+/).filter(Boolean)}function En(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ze(t,e){const n=e.trim(),r=ke(n);if(r.length<=1)return t.search(n);const[o,...a]=r.map(h=>t.search(h)),u=a.map(h=>{const f=new Map;for(const m of h)f.set(m.refIndex,m.score??1);return f}),d=[];for(const h of o){let f=h.score??1,m=!0;for(const x of u){const y=x.get(h.refIndex);if(y===void 0){m=!1;break}f+=y}m&&d.push({item:h.item,score:f/r.length})}return d.sort((h,f)=>(h.score??1)-(f.score??1)),d}function Ot(t,e,n){return e===t?6:e.startsWith(t)?5:e.split(/[^a-z0-9]+/i).includes(t)?4:e.includes(t)?3:n.includes(t)?2:1}function Mn(t,e,n){const r=ke(t);if(r.length===0)return 1;const o=e.toLowerCase(),a=n.toLowerCase(),u=Ot(r.join(" "),o,a);if(r.length===1)return u;let d=6;for(const h of r)d=Math.min(d,Ot(h,o,a));return Math.max(u,d)}const Cn=4;function Gt(t){return t.replace(/…|\.\.\./g," ").replace(/\s+/g," ").trim().toLowerCase()}const Sn=24;function _n(t,e){const n=Gt(t),r=Gt(e);return n===r?!0:Math.min(n.length,r.length)<Sn?!1:n.includes(r)||r.includes(n)}function In(t,e){const n=[],r=o=>{!o||!o.text.trim()||n.length>=Cn||n.some(a=>_n(a.text,o.text))||n.push(o)};t&&r({text:t,kind:"user"});for(const o of e??[])r(o);return n.length>0?n:void 0}async function vn(t){const e=new URLSearchParams({q:t}),n=await dt(ft(`/api/folders/search?${e.toString()}`));if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(o.error||`Failed to search folders: ${n.statusText}`)}const r=await n.json();return Array.isArray(r.folders)?r.folders:[]}const Ut=["agent","session","building","setting","file","file-content","folder","area"],Nn=2,bn=2,jn=50,wn=10,Tn=3,Rn=30,Ln=8,Dn=8,kn=3,Fn=15,ut=5,ht=5;function $n(){const t=Wt(Fe.SPOTLIGHT_TAB,"all");return we.includes(t)?t:"all"}function Ht(){return Ss(Fe.SPOTLIGHT_QUERY,"")}function Bn(){const t=Wt(Fe.AOP_CONFIG,{});return t.sortMode==="name"||t.sortMode==="status"||t.sortMode==="recent"?t.sortMode:"recent"}function Pn({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:o,onOpenFileExplorer:a,onOpenPM2LogsModal:u,onOpenBossLogsModal:d,onOpenDatabasePanel:h,onOpenMonitoringModal:f,onOpenSessionFinder:m,onOpenFileDetail:x}){const y=us(),E=hs(),A=ds(),M=fs(),N=ms(),D=gs(),b=l.useRef(e);b.current=e;const L=l.useRef(n);L.current=n;const G=l.useRef(r);G.current=r;const ce=l.useRef(o);ce.current=o;const me=l.useRef(a);me.current=a;const U=l.useRef(u);U.current=u;const Y=l.useRef(d);Y.current=d;const J=l.useRef(h);J.current=h;const oe=l.useRef(f);oe.current=f;const le=l.useRef(m);le.current=m;const Q=l.useRef(x);Q.current=x;const[R,q]=l.useState(Ht),[V,ee]=l.useState(0),[ie,$e]=l.useState($n),[Be,ge]=l.useState([]),[Pe,pe]=l.useState([]),[Qe,te]=l.useState([]),[se,ye]=l.useState(!1),[Ie,xe]=l.useState(!1),[ze,ve]=l.useState(!1),[Ke,v]=l.useState(!1),[S,k]=l.useState({query:"",rows:[]}),[Ne,Te]=l.useState(!1),[Ee,Mt]=l.useState(!1);l.useEffect(()=>{Te(!1),Mt(!1)},[R,t]);const ns=l.useCallback(s=>{q(s),ps(Fe.SPOTLIGHT_QUERY,s)},[]);l.useEffect(()=>{t&&(q(Ht()),ee(0))},[t]),l.useEffect(()=>{if(!t){ge([]),ye(!1);return}const s=R.trim();if(s.length<Nn){ge([]),ye(!1);return}ge([]),ye(!0);let i=!1;const g=setTimeout(()=>{vn(s).then(I=>{i||ge(I)}).catch(()=>{i||ge([])}).finally(()=>{i||ye(!1)})},250);return()=>{i=!0,clearTimeout(g)}},[t,R]);const Ct=(M.fileSearchExcludeDirs??it).join(",");l.useEffect(()=>{if(!t){pe([]),xe(!1);return}const s=R.trim();if(s.length<bn){pe([]),xe(!1);return}pe([]),xe(!0);let i=!1;const g=setTimeout(()=>{ys(s,{exclude:M.fileSearchExcludeDirs??[...it],limit:jn}).then(I=>{i||pe(I)}).catch(()=>{i||pe([])}).finally(()=>{i||xe(!1)})},250);return()=>{i=!0,clearTimeout(g)}},[t,R,Ct,M.fileSearchExcludeDirs]),l.useEffect(()=>{if(!t){te([]),ve(!1);return}const s=R.trim();if(s.length<Tn){te([]),ve(!1);return}te([]),ve(!0);const i=new AbortController,g=setTimeout(()=>{As(s,{exclude:M.fileSearchExcludeDirs??[...it],limit:Rn,signal:i.signal}).then(I=>{i.signal.aborted||te(I)}).catch(()=>{i.signal.aborted||te([])}).finally(()=>{i.signal.aborted||ve(!1)})},300);return()=>{clearTimeout(g),i.abort()}},[t,R,Ct,M.fileSearchExcludeDirs]),l.useEffect(()=>{if(!t){k({query:"",rows:[]}),v(!1);return}const s=R.trim();if(s.length<kn){k({query:"",rows:[]}),v(!1);return}k({query:"",rows:[]}),v(!0);let i=!1;const g=setTimeout(()=>{xs(s,{limit:Fn}).then(I=>{i||k({query:s,rows:I})}).catch(()=>{i||k({query:"",rows:[]})}).finally(()=>{i||v(!1)})},250);return()=>{i=!0,clearTimeout(g)}},[t,R]);const nt=l.useCallback(s=>{$e(s),Es(Fe.SPOTLIGHT_TAB,s)},[]),St=l.useRef(ie);St.current=ie;const rs=l.useCallback(s=>{const i=we.indexOf(St.current),g=we[(i+s+we.length)%we.length];nt(g)},[nt]);l.useEffect(()=>{ee(0)},[ie]);const rt=X.getShortcuts(),Oe=l.useMemo(()=>t?Ms():{},[t]),Ge=l.useMemo(()=>{if(!t)return[];const s=window.matchMedia("(pointer: coarse)").matches,i=rt.find(I=>I.id==="spawn-agent"),g=rt.find(I=>I.id==="toggle-commander");return[{id:"cmd-spawn",type:"command",title:"Spawn New Agent",subtitle:s?"":i?Rt(i):"Alt+N",icon:c.jsx(O,{name:"plus",size:16}),action:()=>{b.current(),L.current()}},{id:"cmd-commander",type:"command",title:"Commander View",subtitle:s?"":g!=null&&g.key?Rt(g):"Tab",icon:c.jsx(O,{name:"dashboard",size:16}),action:()=>{b.current(),G.current()}},{id:"cmd-settings",type:"command",title:"Settings & Tools",subtitle:"Configure Tide Commander",icon:c.jsx(O,{name:"gear",size:16}),action:()=>{b.current(),ce.current()}},{id:"cmd-monitoring",type:"command",title:"Monitoring & Logs",subtitle:"Triggers, workflows, events",icon:c.jsx(O,{name:"chart-line",size:16}),action:()=>{var I;b.current(),(I=oe.current)==null||I.call(oe)}}]},[t,rt]),Ue=l.useMemo(()=>{if(!t)return[];const s=R.trim();return(s?Rs(s):Ls).map(g=>({id:`setting-${g.id}`,type:"setting",title:g.title,subtitle:s?`Settings section • ${s}`:"Settings section",icon:c.jsx(O,{name:"gear",size:16}),_searchText:`${g.title} ${g.keywords.join(" ")}`,action:()=>{b.current(),ce.current(s||g.title)}}))},[t,R]),He=l.useMemo(()=>{const s=new Map;if(!t)return s;const i=Array.from(E.values());for(const g of y.values())for(const I of i)if(X.isPositionInArea({x:g.position.x,z:g.position.z},I)){s.set(g.id,I);break}return s},[t,y,E]),be=l.useMemo(()=>t?Array.from(y.values()).map(s=>{const i=[];s.lastAssignedTask&&i.push(s.lastAssignedTask);const g=`${s.class} • ${s.cwd}`,I=He.get(s.id),B=(I==null?void 0:I.name)||"";let T=`${s.name} ${s.class} ${s.status} ${s.cwd}`;s.taskLabel&&(T+=` ${s.taskLabel}`),B&&(T+=` ${B}`),i.length>0&&(T+=` ${i.join(" ")}`);const K=Date.now()-s.lastActivity;let $;return s.lastAssignedTask&&(s.lastAssignedTask.length>150?$=s.lastAssignedTask.slice(0,150)+"...":$=s.lastAssignedTask),{id:`agent-${s.id}`,type:"agent",title:s.name,subtitle:g,lastUserInput:$,timeAway:K,icon:c.jsx(Dt,{agent:s,size:20}),_searchText:T,_userQueries:i,_agentId:s.id,_lastActivity:s.lastActivity,_taskLabel:s.taskLabel,_status:s.status,_provider:s.provider??"claude",_piModel:s.piModel,_piModelProvider:s.piModelProvider,_areaName:B||void 0,_areaColor:I==null?void 0:I.color,action:()=>{b.current(),Lt(s.id),X.selectAgent(s.id),X.getState().viewMode!=="flat"&&X.requestTerminalExpand()}}}):[],[t,y,He]),We=l.useMemo(()=>t?Array.from(E.values()).map(s=>{var i;return{id:`area-${s.id}`,type:"area",title:s.name,subtitle:`${s.assignedAgentIds.length} agents • ${((i=s.directories)==null?void 0:i.length)||0} folders`,icon:c.jsx(O,{name:"map",size:16}),action:()=>{b.current(),X.selectArea(s.id)}}}):[],[t,E]),Ye=l.useMemo(()=>{const s=new Map;for(const i of be)i._agentId&&s.set(i._agentId,i);return s},[be]),_t=l.useMemo(()=>{const s=new Map;if(!t)return s;for(const i of y.values()){const g=He.get(i.id);if(!g||g.archived)continue;const I=s.get(g.id);I?I.push(i):s.set(g.id,[i])}return s},[t,y,He]),It=l.useMemo(()=>{const s=new Map;for(const i of N)s.has(i.agentId)||s.set(i.agentId,i.timestamp);return s},[N]),ot=l.useMemo(()=>{if(!t)return[];const s=R.trim().toLowerCase(),i=ke(s),g=Cs({sortMode:Bn(),agentsWithUnseenOutput:D,getLatestToolTimestamp:T=>It.get(T)}),I=Array.from(E.values()).filter(T=>!T.archived).filter(T=>{if(i.length===0)return!0;const K=T.name.toLowerCase();return i.some($=>K.includes($))}).sort((T,K)=>T.name.localeCompare(K.name,void 0,{sensitivity:"base"})),B=[];for(const T of I){const K=T.name.toLowerCase(),$=i.filter(W=>!K.includes(W));let H=(_t.get(T.id)||[]).slice().sort(g).map(W=>Ye.get(W.id)).filter(W=>!!W);$.length>0&&(H=H.filter(W=>{const z=`${W.title} ${W.subtitle||""} ${W._searchText||""}`.toLowerCase();return $.every(F=>z.includes(F))}),H.length===0)||!s&&H.length===0||B.push({areaId:T.id,areaName:T.name,areaColor:T.color,agents:H})}return B},[t,R,E,_t,Ye,D,It]),qe=l.useMemo(()=>t?Array.from(A.values()).filter(s=>s.type==="server"||s.type==="boss"||s.type==="database"||s.type==="tests").map(s=>{var $,re,H,W,z;const i=s.status==="running"?"#4ade80":s.status==="stopped"?"#f87171":"#facc15",g=s.type==="boss"?"crown":s.type==="database"?"database":s.type==="tests"?"flask":"desktop",I=s.type==="boss"?"Boss":s.type==="database"?"Database":s.type==="tests"?"Tests":"Server";let B=`${I} • ${s.status}`;if(s.type==="database"&&((re=($=s.database)==null?void 0:$.connections)!=null&&re.length)){const F=s.database.connections[0];B+=` • ${F.engine} @ ${F.host}`}else s.type==="tests"&&s.folderPath?B=`${I} • ${s.folderPath}`:s.cwd&&(B+=` • ${s.cwd}`);const T=((H=s.pm2Status)==null?void 0:H.ports)||[];let K=`${s.name} ${s.type} ${s.status} ${s.cwd||""} ${((W=s.pm2)==null?void 0:W.name)||""}`;if(s.type==="tests"&&(K+=` ${s.folderPath||""} tests junit maven`),T.length>0&&(K+=` ${T.join(" ")}`),s.type==="database"&&((z=s.database)!=null&&z.connections))for(const F of s.database.connections)K+=` ${F.name} ${F.engine} ${F.host} ${F.database||""} mysql postgresql sql`;return{id:`building-${s.id}`,type:"building",title:s.name,subtitle:B,_ports:T,icon:c.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[c.jsx(O,{name:"status-pending",size:10,weight:"fill",color:i}),c.jsx(O,{name:g,size:16})]}),_searchText:K,action:()=>{var F;b.current(),s.type==="boss"?Y.current(s.id):s.type==="database"?J.current(s.id):s.type==="tests"?X.openTestsBuilding(s.id):s.type==="http"?X.openHttpBuilding(s.id):(F=s.pm2)!=null&&F.enabled&&U.current(s.id)}}}):[],[t,A]),vt=l.useMemo(()=>t?Be.map(s=>{const i=s.isGitRepo&&s.gitBranch?`${s.path} • ${s.gitBranch}`:s.path;return{id:`folder-${s.path}`,type:"folder",title:s.name,subtitle:i,matchedText:s.path,icon:c.jsx(O,{name:s.isGitRepo?"git-branch":"folder",size:16}),_searchText:`${s.name} ${s.path}`,_isGitRepo:s.isGitRepo,_gitBranch:s.gitBranch,action:()=>{b.current(),X.openFileExplorer(s.path)}}}):[],[t,Be]),Ve=l.useMemo(()=>t?Pe.map(s=>{const i=s.areaName&&s.areaName!==s.projectName?`${s.projectName} · ${s.areaName}`:s.projectName;return{id:`file-${s.path}`,type:"file",title:s.name,subtitle:s.relativePath,matchedText:`${s.path} ${i}`,icon:kt(s.path),_searchText:`${s.name} ${s.relativePath} ${s.path} ${s.projectName} ${s.areaName}`,_projectName:s.projectName,_areaName:s.areaName,action:()=>{b.current(),Q.current({filePath:s.path,projectRoot:s.projectRoot,searchQuery:R.trim()})}}}):[],[t,Pe,R]),Xe=l.useMemo(()=>t?Qe.map(s=>{const i=s.matches[0],g=s.areaName&&s.areaName!==s.projectName?`${s.projectName} · ${s.areaName}`:s.projectName;return{id:`file-content-${s.path}`,type:"file-content",title:s.name,subtitle:`${s.relativePath}${i!=null&&i.line?`:${i.line}`:""}`,matchedQuery:i==null?void 0:i.content,matchedText:`${s.path} ${g}`,icon:kt(s.path),_projectName:s.projectName,_areaName:s.areaName,_lineNumber:i==null?void 0:i.line,action:()=>{b.current(),Q.current({filePath:s.path,projectRoot:s.projectRoot,targetLine:i==null?void 0:i.line,searchQuery:R.trim()})}}}):[],[t,Qe,R]),Me=l.useMemo(()=>{if(!t)return[];const s=i=>{const g=Date.now()-new Date(i).getTime();return!Number.isFinite(g)||g<0?"":g<36e5?`${Math.max(1,Math.floor(g/6e4))}m`:g<864e5?`${Math.floor(g/36e5)}h`:`${Math.floor(g/864e5)}d`};return S.rows.map(i=>{var W;const g=Array.from(y.values()).find(z=>z.sessionId===i.sessionId),I=g??(i.agentId?y.get(i.agentId):void 0),B=(i.firstPrompt||i.snippet||i.sessionId).slice(0,90),T=[i.projectPath||i.projectDir];I&&T.push(`→ ${I.name}${g?"":" (past session)"}`);const K=(W=i.extracts)==null?void 0:W.map(z=>z.timestamp?Date.parse(z.timestamp):Number.NaN).find(Number.isFinite),$=Date.parse(i.lastModified),re=K??(Number.isFinite($)?$:void 0),H=re===void 0?"":s(re);return H&&T.push(H),T.push(`${i.totalMatches}×`),{id:`session-${i.sessionId}`,type:"session",title:B,subtitle:T.join(" • "),matchedQuery:i.snippet||void 0,matchedExtracts:i.extracts&&i.extracts.length>0?i.extracts:void 0,_agentId:I==null?void 0:I.id,_sessionMatches:i.totalMatches,_sessionNearbyMatches:i.nearbyMatches,_matchedMessageAt:re,_provider:i.provider||"claude",icon:I?c.jsx(Dt,{agent:I,size:20}):c.jsx(O,{name:"history",size:16}),action:()=>{var F;b.current();const z=Array.from(X.getState().agents.values()).find(je=>je.sessionId===i.sessionId);z?(Lt(z.id),X.selectAgent(z.id),X.getState().viewMode!=="flat"&&X.requestTerminalExpand(),X.requestTerminalSearch(z.id,S.query)):(F=le.current)==null||F.call(le,{initialQuery:S.query,initialSessionKey:`${i.projectPath}::${i.sessionId}`})}}})},[t,S,y]),Nt=l.useMemo(()=>new de(be,{keys:["title","subtitle","_searchText","lastUserInput"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[be]),bt=l.useMemo(()=>new de(Ge,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[Ge]),jt=l.useMemo(()=>new de(We,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[We]),wt=l.useMemo(()=>new de(qe,{keys:["title","subtitle","_searchText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[qe]),Re=l.useMemo(()=>{if(!R.trim()){const p=[];p.push(...qe);const _=[...be].sort((w,P)=>{const Z=at(w._agentId,w._lastActivity,Oe);return at(P._agentId,P._lastActivity,Oe)-Z});p.push(..._),p.push(...We.slice(0,2));const j={};return Ut.forEach((w,P)=>{j[w]=P}),p.sort((w,P)=>(j[w.type]??999)-(j[P.type]??999)),p}const s=R.trim().toLowerCase(),i=ke(s),g=Ze(Nt,R).slice(0,30),I=Ze(jt,R).slice(0,2),B=vt.slice(0,8),T=Ve.slice(0,wn),K=Ue.slice(0,Dn),$=Ze(wt,R).filter(p=>{const _=p.score??1,j=`${p.item.title} ${p.item.subtitle||""} ${p.item._searchText||""}`.toLowerCase();return i.every(w=>j.includes(w))||_<=.2}).slice(0,4),re={agent:6,building:5,folder:4,file:4,"file-content":4,setting:4,command:3,area:2,"modified-file":1,session:0},H=p=>Mn(s,p.title,`${p.subtitle||""} ${p._searchText||""} ${p.matchedText||""}`),W=(p,_)=>{const j=(1-Math.min(1,_??1))*4;return H(p)*100+(re[p.type]??0)*5+j},z=new Map,F=(p,_)=>{const j=z.get(p.type),w={item:p,score:W(p,_)};j?j.push(w):z.set(p.type,[w])},je=new Map;for(const p of Me)p._agentId&&!je.has(p._agentId)&&je.set(p._agentId,p);for(const p of g){const _={...p.item};if(_._userQueries&&_._userQueries.length>0){const w=_._userQueries.find(P=>i.some(Z=>P.toLowerCase().includes(Z)));if(w){const P=w.toLowerCase(),Z=P.includes(s)?s:i.find(he=>P.includes(he))??s;if(w.length>200){const he=P.indexOf(Z),Le=Math.max(0,he-60),De=Math.min(w.length,he+Z.length+100);_.matchedQuery=(Le>0?"...":"")+w.slice(Le,De)+(De<w.length?"...":"")}else _.matchedQuery=w}}const j=_._agentId?je.get(_._agentId):void 0;if(j){_.matchedQuery||(_.matchedQuery=j.matchedQuery);const w=_.matchedQuery,P=(w==null?void 0:w.toLowerCase())??"";_.matchedExtracts=In(w&&i.every(Z=>P.includes(Z))?w:void 0,j.matchedExtracts),_.action=j.action,_._sessionMatches=j._sessionMatches,_._sessionNearbyMatches=j._sessionNearbyMatches,_._matchedMessageAt=j._matchedMessageAt,_._searchText=`${_._searchText||""} ${j.matchedQuery||""} ${s}`}F(_,p.score)}for(const[p,_]of je){if(g.some(w=>w.item._agentId===p))continue;const j=Ye.get(p);j&&F({...j,matchedQuery:_.matchedQuery,matchedExtracts:_.matchedExtracts,action:_.action,_sessionMatches:_._sessionMatches,_sessionNearbyMatches:_._sessionNearbyMatches,_matchedMessageAt:_._matchedMessageAt,_searchText:`${j._searchText||""} ${_.matchedQuery||""} ${s}`},void 0)}for(const p of $)F(p.item,p.score);for(const p of I)F(p.item,p.score);for(const p of K)F(p,void 0);for(const p of B)F(p,void 0);for(const p of T)F(p,void 0);for(const p of Xe.slice(0,Ln))F(p,void 0);const cs=24*36e5,ls=Date.now(),Tt=p=>{const _=at(p.item._agentId,p.item._lastActivity,Oe),j=Math.exp(-Math.LN2*Math.max(0,ls-_)/cs),w=p.item._sessionMatches??0,P=Math.log2(1+w),Z=p.item._sessionNearbyMatches;return(Z===void 0?P:Z>0?8+Math.log2(1+Z)+P*.1:P*.2)+(p.item._matchedMessageAt===void 0?2*j:0)};for(const[p,_]of z)p==="agent"?_.sort((j,w)=>{const P=H(j.item),Z=H(w.item);if(Z!==P)return Z-P;const Se=j.item._matchedMessageAt,he=w.item._matchedMessageAt;if(Se!==void 0||he!==void 0){if(Se===void 0)return 1;if(he===void 0)return-1;if(he!==Se)return he-Se}const Le=Tt(j),De=Tt(w);return De!==Le?De-Le:w.score-j.score}):_.sort((j,w)=>w.score-j.score);const Ce=[];for(const p of Ut){if(p==="session"){!Ee&&Me.length>ut?(Ce.push(...Me.slice(0,ut)),Ce.push({id:"session-show-all",type:"session",title:`Show all conversations (${Me.length})`,subtitle:`${Me.length-ut} more matches`,icon:c.jsx(O,{name:"arrow-down",size:16}),action:()=>Mt(!0)})):Ce.push(...Me);continue}const _=z.get(p);if(_){if(p==="agent"&&!Ne&&_.length>ht){for(const j of _.slice(0,ht))Ce.push(j.item);Ce.push({id:"agent-show-all",type:"agent",title:`Show all agents (${_.length})`,subtitle:`${_.length-ht} more matches`,icon:c.jsx(O,{name:"arrow-down",size:16}),action:()=>Te(!0)});continue}for(const j of _)Ce.push(j.item)}}return Ce},[R,Nt,jt,wt,be,Ye,We,qe,Ue,vt,Ve,Xe,Me,Oe,Ne,Ee]),ae=l.useMemo(()=>{switch(ie){case"agents":return Re.filter(s=>s.type==="agent");case"buildings":return Re.filter(s=>s.type==="building");case"commands":return R.trim()?Ze(bt,R).slice(0,3).map(s=>s.item):Ge;case"folders":return Re.filter(s=>s.type==="folder");case"files":return Ve;case"contents":return Xe;case"settings":return Ue;case"areas":return ot.flatMap(s=>s.agents);case"all":default:return Re}},[ie,Re,ot,Ve,Xe,Ue,R,bt,Ge]),os=l.useMemo(()=>{const s=[];if(Ke&&s.push("session"),Ie&&s.push("file"),ze&&s.push("file-content"),se&&s.push("folder"),ie==="all")return s;const g={buildings:"building",folders:"folder",files:"file",contents:"file-content",agents:"agent",settings:"setting",commands:"command"}[ie];return g&&s.includes(g)?[g]:[]},[ie,Ke,Ie,ze,se]);l.useEffect(()=>{V>=ae.length&&ee(Math.max(0,ae.length-1))},[ae.length,V]);const is=l.useCallback(s=>{if(s.altKey&&!s.ctrlKey&&!s.metaKey&&(s.key==="p"||s.key==="n"||s.key==="P"||s.key==="N")){s.preventDefault(),s.stopPropagation(),s.nativeEvent.stopImmediatePropagation();const i=s.key.toLowerCase();ee(i==="p"?g=>g>0?g-1:ae.length-1:g=>g<ae.length-1?g+1:0);return}switch(s.key){case"Escape":s.preventDefault(),b.current();break;case"ArrowUp":s.preventDefault(),ee(i=>i>0?i-1:ae.length-1);break;case"ArrowDown":s.preventDefault(),ee(i=>i<ae.length-1?i+1:0);break;case"Enter":s.preventDefault(),ae[V]&&ae[V].action();break}},[ae,V]),as=l.useCallback((s,i)=>{if(!i||!s)return s;const g=ke(i);if(g.length===0)return s;const I=new RegExp(g.map(En).sort((re,H)=>H.length-re.length).join("|"),"gi"),B=[];let T=0,K=0,$;for(;($=I.exec(s))!==null;)$.index>T&&B.push(s.slice(T,$.index)),B.push(ct.createElement("mark",{key:K++,className:"spotlight-highlight"},$[0])),T=$.index+$[0].length;return T<s.length&&B.push(s.slice(T)),B.length>0?ct.createElement(ct.Fragment,null,...B):s},[]);return{query:R,setQuery:ns,selectedIndex:V,setSelectedIndex:ee,results:ae,loadingTypes:os,activeTab:ie,setActiveTab:nt,cycleTab:rs,areaSections:ot,handleKeyDown:is,highlightMatch:as}}const Qn=l.forwardRef(function({query:e,onQueryChange:n,onKeyDown:r,onResetSelection:o,commandMode:a=!1,executingCommand:u=!1},d){const{t:h}=st(["common"]);return c.jsxs("div",{className:`spotlight-input-wrapper${a?" is-command-mode":""}`,children:[c.jsx("span",{className:"spotlight-search-icon",children:a?"›_":"⌘"}),c.jsx("input",{ref:d,type:"text",className:"spotlight-input",placeholder:h("common:search.spotlightPlaceholder"),value:e,onChange:f=>{n(f.target.value),o()},onKeyDown:r,autoFocus:!0,spellCheck:!1,disabled:u,"aria-label":a?"Plugin command":void 0}),c.jsxs("div",{className:"spotlight-input-hints",children:[c.jsx("span",{className:"spotlight-shortcut-hint",children:"↑↓"}),c.jsx("span",{className:"spotlight-shortcut-hint",children:"Enter"}),c.jsx("span",{className:"spotlight-shortcut-hint",children:"Esc"})]})]})}),zn=l.memo(function({activeTab:e,onSelect:n}){const{t:r}=st(["terminal"]);return c.jsxs("div",{className:"spotlight-tabs",role:"tablist","aria-label":r("terminal:spotlight.tabsLabel"),children:[we.map(o=>c.jsx("button",{type:"button",role:"tab","aria-selected":o===e,tabIndex:-1,className:`spotlight-tab${o===e?" active":""}`,onClick:()=>n(o),children:r(`terminal:spotlight.tabs.${o}`)},o)),c.jsx("span",{className:"spotlight-tabs-hint",children:c.jsx("kbd",{children:"Tab"})})]})}),Kn=l.forwardRef(function({results:e,loadingTypes:n,selectedIndex:r,query:o,activeTab:a,areaSections:u,highlightMatch:d,onSelectIndex:h},f){const{t:m}=st(["terminal"]),x=l.useRef(!1);l.useEffect(()=>{x.current=!1},[e]),l.useEffect(()=>{const A=typeof f=="function"?null:f==null?void 0:f.current;if(!A)return;const M=()=>{x.current=!0};return A.addEventListener("mousemove",M),()=>{A.removeEventListener("mousemove",M)}},[f,e]);const y={command:m("terminal:spotlight.categories.commands"),agent:m("terminal:spotlight.categories.agents"),building:m("terminal:spotlight.categories.infrastructure"),setting:m("terminal:spotlight.categories.settings"),area:m("terminal:spotlight.categories.areas"),folder:m("terminal:spotlight.categories.folders"),file:m("terminal:spotlight.categories.files"),"file-content":m("terminal:spotlight.categories.fileContents"),"modified-file":m("terminal:spotlight.categories.modifiedFiles"),session:m("terminal:spotlight.categories.sessions")},E=l.useMemo(()=>{const A=[];let M=null,N=[];e.forEach((b,L)=>{b.type!==M&&(M!==null&&N.length>0&&A.push([M,N]),M=b.type,N=[]),N.push({result:b,index:L})}),M!==null&&N.length>0&&A.push([M,N]);for(const b of n)A.some(([L])=>L===b)||A.push([b,[]]);const D=["agent","session","building","setting","file","file-content","folder","area","command"];return A.sort(([b],[L])=>D.indexOf(b)-D.indexOf(L)),A},[e,n]);if(l.useEffect(()=>{if(!f||typeof f=="function")return;const A=f.current;if(!A)return;const M=A.querySelector(".spotlight-item.selected");M&&M.scrollIntoView({block:"nearest",behavior:"smooth"})},[r,f]),a==="areas"){if(u.length===0)return c.jsx("div",{className:"spotlight-results",ref:f,children:c.jsx("div",{className:"spotlight-empty",children:m("terminal:spotlight.noResults")})});let A=0;return c.jsx("div",{className:"spotlight-results",ref:f,children:u.map(M=>c.jsxs("div",{children:[c.jsxs("div",{className:"spotlight-category-header spotlight-area-section-header",children:[c.jsx("span",{className:"spotlight-area-dot",style:{background:M.areaColor},"aria-hidden":"true"}),c.jsx("span",{className:"spotlight-area-name",children:M.areaName}),c.jsx("span",{className:"spotlight-area-count",children:M.agents.length})]}),M.agents.length===0?c.jsx("div",{className:"spotlight-area-empty",children:m("terminal:spotlight.noAgentsInArea")}):M.agents.map(N=>{const D=A++;return c.jsx(Ft,{result:N,isSelected:D===r,query:o,highlightMatch:d,onClick:()=>N.action(),onMouseEnter:()=>{x.current&&h(D)}},N.id)})]},M.areaId))})}return e.length===0&&n.length===0?c.jsx("div",{className:"spotlight-results",ref:f,children:c.jsx("div",{className:"spotlight-empty",children:m("terminal:spotlight.noResults")})}):c.jsx("div",{className:"spotlight-results",ref:f,children:E.map(([A,M])=>c.jsxs("div",{children:[(a==="all"||E.length>1)&&c.jsx("div",{className:"spotlight-category-header",children:y[A]||A}),n.includes(A)&&c.jsxs("div",{className:"spotlight-block-loading",role:"status",children:[c.jsx("span",{className:"spotlight-loading-spinner","aria-hidden":"true"}),m("terminal:spotlight.searching")]}),M.map(({result:N,index:D})=>c.jsx(Ft,{result:N,isSelected:D===r,query:o,highlightMatch:d,onClick:()=>N.action(),onMouseEnter:()=>{x.current&&h(D)}},N.id))]},A))})}),On=l.memo(function({commandMode:e=!1}){const{t:n}=st(["terminal"]);return c.jsxs("div",{className:"spotlight-footer",children:[c.jsxs("div",{className:"spotlight-footer-left",children:[c.jsxs("span",{className:"spotlight-footer-hint",children:[c.jsx("kbd",{children:"↑"}),c.jsx("kbd",{children:"↓"})," ",c.jsx("kbd",{children:"Alt+N"}),c.jsx("kbd",{children:"Alt+P"})," ",n("terminal:spotlight.navigate")]}),c.jsxs("span",{className:"spotlight-footer-hint",children:[c.jsx("kbd",{children:"Enter"})," ",e?"run command":n("terminal:spotlight.select")]}),c.jsxs("span",{className:"spotlight-footer-hint",children:[c.jsx("kbd",{children:"Tab"})," ",e?"complete command":n("terminal:spotlight.switchTabs")]})]}),c.jsx("div",{className:"spotlight-footer-right",children:c.jsxs("span",{className:"spotlight-footer-hint",children:[c.jsx("kbd",{children:"Esc"})," ",n("common:buttons.close")]})})]})});function Gn({detail:t,onClose:e}){const[n,r]=l.useState(null),[o,a]=l.useState(!0),[u,d]=l.useState(null);_s("spotlight-file-detail",!0,e),l.useEffect(()=>{const E=new AbortController;return a(!0),d(null),r(null),(async()=>{try{const M=await dt(ft(`/api/files/read?path=${encodeURIComponent(t.filePath)}`),{signal:E.signal}),N=await M.json();if(!M.ok)throw new Error(N.error||"Unable to read file");let D=null;if(!N.binary)try{const b=await dt(ft(`/api/files/git-original?path=${encodeURIComponent(t.filePath)}`),{signal:E.signal}),L=await b.json();b.ok&&!L.binary&&typeof L.content=="string"&&(D=L.content)}catch{}E.signal.aborted||r({filename:N.filename||t.filePath.split("/").pop()||t.filePath,content:typeof N.content=="string"?N.content:"",originalContent:D,binary:N.binary===!0})}catch(M){E.signal.aborted||d(M instanceof Error?M.message:"Unable to load file")}finally{E.signal.aborted||a(!1)}})(),()=>E.abort()},[t.filePath]),l.useEffect(()=>{const E=A=>{A.key==="Escape"&&(A.preventDefault(),A.stopImmediatePropagation(),e())};return document.addEventListener("keydown",E,!0),()=>document.removeEventListener("keydown",E,!0)},[e]);const h=()=>{X.revealFileInExplorer(t.filePath,t.projectRoot,t.targetLine),e()},f=(n==null?void 0:n.filename)||t.filePath,m=f.lastIndexOf(".")>=0?f.slice(f.lastIndexOf(".")):"",x=Is(m),y=(n==null?void 0:n.originalContent)!=null&&n.originalContent!==n.content;return c.jsx("div",{className:"guake-git-diff-modal-overlay",onClick:e,children:c.jsxs("div",{className:"guake-git-diff-modal",onClick:E=>E.stopPropagation(),children:[c.jsxs("div",{className:"guake-git-diff-modal-header",children:[c.jsxs("div",{className:"guake-git-diff-path spotlight-file-detail-path",title:t.filePath,children:[t.filePath,t.targetLine?c.jsxs("span",{className:"spotlight-file-detail-line",children:[":",t.targetLine]}):null]}),c.jsxs("button",{type:"button",className:"spotlight-file-detail-explorer",onClick:h,title:"Open in File Explorer",children:[c.jsx(O,{name:"folder-open",size:14}),"Open in File Explorer"]}),c.jsx("button",{className:"guake-git-close",onClick:e,title:"Close (Esc)",children:c.jsx(O,{name:"close",size:14})})]}),c.jsxs("div",{className:"guake-git-diff-content",children:[o&&c.jsx("div",{className:"guake-git-diff-loading-overlay",children:c.jsx("div",{className:"diff-image-spinner"})}),u&&c.jsx("div",{className:"spotlight-file-detail-message",children:u}),(n==null?void 0:n.binary)&&c.jsx("div",{className:"spotlight-file-detail-message",children:"Binary preview is available in the File Explorer."}),n&&!n.binary&&(y?c.jsx($t,{originalContent:n.originalContent||"",modifiedContent:n.content,filename:n.filename,filePath:t.filePath,language:x,searchQuery:t.searchQuery,targetLine:t.targetLine}):c.jsx($t,{originalContent:"",modifiedContent:n.content,filename:n.filename,filePath:t.filePath,language:x,initialModifiedOnly:!0,searchQuery:t.searchQuery,targetLine:t.targetLine,readOnly:!0}))]})]})})}const Un=l.forwardRef(function({commands:e,selectedIndex:n,executing:r,error:o,onSelectIndex:a,onExecute:u},d){return l.useEffect(()=>{var h,f;!d||typeof d=="function"||(f=(h=d.current)==null?void 0:h.querySelector(".spotlight-command-item.selected"))==null||f.scrollIntoView({block:"nearest"})},[d,n]),c.jsxs("div",{className:"spotlight-results spotlight-command-results",ref:d,children:[c.jsxs("div",{className:"spotlight-command-mode-banner",children:[c.jsx("span",{className:"spotlight-command-mode-icon",children:c.jsx(O,{name:"terminal",size:13})}),c.jsxs("div",{children:[c.jsx("strong",{children:"Plugin command mode"}),c.jsx("span",{children:"Runs locally without sending a prompt to an AI agent"})]})]}),o&&c.jsxs("div",{className:"spotlight-command-error",role:"alert",children:[c.jsx(O,{name:"warn",size:13}),c.jsx("span",{children:o})]}),e.length===0?c.jsxs("div",{className:"spotlight-empty spotlight-command-empty",children:[c.jsx(O,{name:"search",size:18}),c.jsx("strong",{children:"No matching plugin command"}),c.jsxs("span",{children:["Type ",c.jsx("code",{children:"/"})," to see enabled plugin commands."]})]}):e.map((h,f)=>c.jsxs("button",{type:"button",className:`spotlight-item spotlight-command-item${f===n?" selected":""}`,disabled:r,onMouseEnter:()=>a(f),onClick:()=>u(h),children:[c.jsx("span",{className:"spotlight-item-icon spotlight-command-item-icon",children:c.jsx(O,{name:"plug",size:16})}),c.jsxs("span",{className:"spotlight-item-content",children:[c.jsxs("span",{className:"spotlight-item-header",children:[c.jsx("code",{className:"spotlight-command-name",children:h.name}),h.name!==h.canonicalName&&c.jsxs("span",{className:"spotlight-command-alias",children:["alias of ",h.canonicalName]})]}),c.jsx("span",{className:"spotlight-item-subtitle",children:h.summary})]}),c.jsx("span",{className:"spotlight-command-plugin-badge",children:h.pluginName}),r&&f===n?c.jsx("span",{className:"spotlight-loading-spinner","aria-label":"Running command"}):c.jsx("span",{className:"spotlight-command-enter",children:"↵"})]},`${h.pluginId}:${h.name}`))]})}),Hn=768;function Xn({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:o,onOpenFileExplorer:a,onOpenPM2LogsModal:u,onOpenBossLogsModal:d,onOpenDatabasePanel:h,onOpenMonitoringModal:f,onOpenSessionFinder:m}){const x=l.useRef(null),y=l.useRef(null),E=l.useRef(null),A=l.useRef(0),M=l.useRef(!1),N=l.useRef(()=>{}),[D,b]=l.useState(null),[L,G]=l.useState(0),[ce,me]=l.useState(!1),[U,Y]=l.useState(null),[J,oe]=l.useState(null),le=vs(),{query:Q,setQuery:R,selectedIndex:q,setSelectedIndex:V,results:ee,loadingTypes:ie,activeTab:$e,setActiveTab:Be,cycleTab:ge,areaSections:Pe,handleKeyDown:pe,highlightMatch:Qe}=Pn({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:o,onOpenFileExplorer:a,onOpenPM2LogsModal:u,onOpenBossLogsModal:d,onOpenDatabasePanel:h,onOpenMonitoringModal:f,onOpenSessionFinder:m,onOpenFileDetail:b}),te=Q.startsWith("/"),se=l.useMemo(()=>Ns(Q,bs()),[Q,le]),ye=l.useCallback(()=>{const v=se[L];if(!v)return;const S=Q.trim().replace(/^\S+/,"");R(`${v.name}${S}`),G(0)},[se,L,Q,R]),Ie=l.useCallback(async v=>{me(!0),Y(null);try{const S=v.pluginId===js||v.requiresAgent?X.getState().selectedAgentIds.values().next().value:void 0,k=await ws(v,Q,{agentId:S});k.kind==="output"&&oe(k),e()}catch(S){Y(S instanceof Error?S.message:String(S))}finally{me(!1)}},[e,Q]);A.current=te?se.length:ee.length,M.current=te,N.current=ye;const xe=l.useRef(ge);xe.current=ge,l.useEffect(()=>{t&&(oe(null),Y(null),setTimeout(()=>{var v,S;(v=x.current)==null||v.focus(),(S=x.current)==null||S.select()},50))},[t]),l.useEffect(()=>{if(!t)return;const v=window.visualViewport;if(!v||window.innerWidth>Hn)return;const S=()=>{const k=y.current;k&&(k.style.height=`${v.height}px`,k.style.top=`${v.offsetTop}px`)};return S(),v.addEventListener("resize",S),v.addEventListener("scroll",S),()=>{v.removeEventListener("resize",S),v.removeEventListener("scroll",S);const k=y.current;k&&(k.style.height="",k.style.top="")}},[t]),l.useEffect(()=>{if(!t)return;const v=S=>{if(S.key==="Escape"){S.preventDefault(),S.stopPropagation(),S.stopImmediatePropagation(),e();return}if(S.key==="Tab"){S.preventDefault(),S.stopPropagation(),S.stopImmediatePropagation(),M.current?N.current():xe.current(S.shiftKey?-1:1);return}if(S.altKey&&!S.ctrlKey&&!S.metaKey&&(S.key==="n"||S.key==="p"||S.key==="N"||S.key==="P")){S.preventDefault(),S.stopPropagation(),S.stopImmediatePropagation();const k=S.key.toLowerCase(),Ne=A.current;if(Ne===0)return;const Te=Ee=>k==="p"?Ee>0?Ee-1:Ne-1:Ee<Ne-1?Ee+1:0;M.current?G(Te):V(Te);return}};return window.addEventListener("keydown",v,{capture:!0}),()=>{window.removeEventListener("keydown",v,{capture:!0})}},[t,e]);const ze=l.useCallback(v=>{v.target===v.currentTarget&&e()},[e]),ve=l.useCallback(()=>{V(0),G(0),Y(null)},[V]);l.useEffect(()=>{L>=se.length&&G(Math.max(0,se.length-1))},[se.length,L]);const Ke=l.useCallback(v=>{if(!te){pe(v);return}const S=se.length;if(v.key==="ArrowUp"||v.key==="ArrowDown"){if(v.preventDefault(),S===0)return;G(k=>v.key==="ArrowUp"?k>0?k-1:S-1:k<S-1?k+1:0);return}if(v.key==="Tab"){v.preventDefault(),ye();return}if(v.key==="Enter"){v.preventDefault();const k=se[L];k&&!ce&&Ie(k)}},[se,te,L,ye,Ie,ce,pe]);return t?c.jsx("div",{ref:y,className:"spotlight-overlay",onClick:ze,children:c.jsxs("div",{className:"spotlight-modal",children:[c.jsx(Qn,{ref:x,query:Q,onQueryChange:R,onKeyDown:Ke,onResetSelection:ve,commandMode:te,executingCommand:ce}),!te&&c.jsx(zn,{activeTab:$e,onSelect:Be}),te?c.jsx(Un,{ref:E,commands:se,selectedIndex:L,executing:ce,error:U,onSelectIndex:G,onExecute:v=>void Ie(v)}):c.jsx(Kn,{ref:E,results:ee,loadingTypes:ie,selectedIndex:q,query:Q,activeTab:$e,areaSections:Pe,highlightMatch:Qe,onSelectIndex:V}),c.jsx(On,{commandMode:te})]})}):J?c.jsx(Ts,{command:J.command,output:J.output,onClose:()=>oe(null)}):D?c.jsx(Gn,{detail:D,onClose:()=>b(null)}):null}export{er as FILE_ICON_NAMES,Xn as Spotlight,On as SpotlightFooter,Qn as SpotlightInput,Ft as SpotlightItem,Kn as SpotlightResults,tr as formatDuration,sr as formatRelativeTime,nr as getAgentIcon,kt as getFileIconFromPath,rr as getTypeLabel,Pn as useSpotlightSearch};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{aG as Oe,r as t,s as I,d as ye,aH as Ee,c as ze,j as e,I as z,u as fe,aI as _e,aJ as Te,aK as Ue,aL as Be,aM as Ke,aN as We,ak as Ve,a6 as De,aO as Ge,aP as qe,aQ as Je,aR as Ye,K as Qe,m as Me,S as oe,F as Xe,q as Ze,t as et,z as Ie,E as tt,a1 as st,aS as nt,ax as Q,aT as at,aU as ct}from"./main-
|
|
1
|
+
import{aG as Oe,r as t,s as I,d as ye,aH as Ee,c as ze,j as e,I as z,u as fe,aI as _e,aJ as Te,aK as Ue,aL as Be,aM as Ke,aN as We,ak as Ve,a6 as De,aO as Ge,aP as qe,aQ as Je,aR as Ye,K as Qe,m as Me,S as oe,F as Xe,q as Ze,t as et,z as Ie,E as tt,a1 as st,aS as nt,ax as Q,aT as at,aU as ct}from"./main-DAjvgfMx.js";import{FileExplorerPanel as ot}from"./index-DZXJouwG.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-DYBBrXTx.js";const Se={status:"all",activity:"all",sort:"activity"},lt={"1h":3600*1e3,"6h":360*60*1e3,"24h":1440*60*1e3},Ae=20,me=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 $e(s,a){return`${s}:${dt(a)}`}function ut(s,a,c,f){if(s.uuid&&a.has(s.uuid))return!1;if(s.uuid)return!0;const p=s.isUserPrompt?"user":"assistant",d=$e(p,s.text),M=s.timestamp||0,A=c.get(d);return A!==void 0&&Math.abs(M-A)<=it?!1:M>f}function mt({isOpen:s,agents:a}){const c=Oe(),[f,p]=t.useState(new Map),d=t.useRef(new Set);t.useRef(a);const M=t.useMemo(()=>Array.from(a.keys()).sort().join(","),[a]),A=t.useMemo(()=>Array.from(a.values()).map(j=>`${j.id}:${j.sessionId||""}`).sort().join(","),[a]);t.useEffect(()=>{s||(d.current.clear(),p(new Map))},[s]),t.useEffect(()=>{if(!s)return;const j=new Set(Array.from(a.keys()));for(const i of d.current)j.has(i)||d.current.delete(i);let h=null;c>0&&(h=I.preserveOutputs(),d.current.clear());const v=async(i,b,$=0)=>{if(d.current.add(i.id),$>0&&await new Promise(x=>setTimeout(x,$)),p(x=>{const N=new Map(x);return N.set(i.id,{agentId:i.id,messages:[],loading:!0,hasMore:!1,totalCount:0}),N}),!i.sessionId){b&&b.length>0&&I.mergeOutputsWithHistory(i.id,[],b),p(x=>{const N=new Map(x);return N.set(i.id,{agentId:i.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),N});return}try{const N=await(await ze(ye(`/api/agents/${i.id}/history?limit=${Ee}&offset=0`))).json(),P=N.messages||[],W=P.length>0?Math.max(...P.map(C=>C.timestamp?new Date(C.timestamp).getTime():0)):0,J=new Set(P.map(C=>C.uuid).filter(C=>!!C)),V=new Map;for(const C of P){if(C.type!=="user"&&C.type!=="assistant")continue;const l=$e(C.type,C.content),L=C.timestamp?new Date(C.timestamp).getTime():0,K=V.get(l)??0;L>K&&V.set(l,L)}const q=I.getOutputs(i.id),B=(b&&b.length>0?[...b,...q]:q).filter(C=>ut(C,J,V,W));I.clearOutputs(i.id);for(const C of B)I.addOutput(i.id,C);p(C=>{const l=new Map(C);return l.set(i.id,{agentId:i.id,messages:P,loading:!1,hasMore:N.hasMore||!1,totalCount:N.totalCount||0}),l})}catch(x){if(console.error(`Failed to load history for ${i.name}:`,x),b&&b.length>0){I.clearOutputs(i.id);for(const N of b)I.addOutput(i.id,N)}p(N=>{const P=new Map(N);return P.set(i.id,{agentId:i.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),P})}},u=c>0?500:0,D=Array.from(a.values());for(const i of D)if(!d.current.has(i.id)){const b=h==null?void 0:h.get(i.id);v(i,b,u)}},[s,M,A,c]);const R=t.useRef(a),k=t.useRef(f);R.current=a,k.current=f;const w=t.useCallback(async j=>{const h=R.current.get(j),v=k.current.get(j);if(!(h!=null&&h.sessionId)||!v||!v.hasMore)return;const u=v.messages.length;try{const i=await(await fetch(ye(`/api/agents/${j}/history?limit=${Ee}&offset=${u}`))).json();i.messages&&i.messages.length>0&&p(b=>{const $=new Map(b),x=b.get(j);return x&&$.set(j,{...x,messages:[...i.messages,...x.messages],hasMore:i.hasMore||!1}),$})}catch(D){console.error(`Failed to load more history for agent ${j}:`,D)}},[]),E=t.useCallback(j=>{d.current.delete(j),p(h=>{const v=new Map(h),u=h.get(j);return u&&v.set(j,{...u,messages:[],hasMore:!1,totalCount:0,loading:!1}),v})},[]);return{histories:f,loadMoreHistory:w,clearAgentHistory:E}}function ft({command:s,onCommandChange:a,useTextarea:c,forceTextarea:f,onForceTextarea:p,onSend:d,canSend:M,attachedFiles:A,onAddFile:R,onRemoveFile:k,uploadFile:w,onAddPastedText:E,placeholder:j="Message...",className:h="",compact:v=!1,inputRef:u}){const D=t.useRef(null),i=t.useRef(null),b=t.useRef(c);t.useEffect(()=>{if(c&&!b.current&&i.current){const l=i.current;l.focus(),l.selectionStart=l.selectionEnd=l.value.length}b.current=c},[c]),t.useEffect(()=>{const l=i.current;if(!l||!c)return;l.style.height="auto";const L=v?120:180,K=Math.min(l.scrollHeight,L);l.style.height=`${K}px`},[s,c,v]);const $=t.useCallback(async l=>{const L=l.clipboardData.items;for(const _ of L)if(_.type.startsWith("image/")){l.preventDefault();const F=_.getAsFile();if(F){const H=await w(F);H&&R(H)}return}const K=l.clipboardData.files;if(K.length>0){l.preventDefault();for(const _ of K){const F=await w(_);F&&R(F)}return}const U=l.clipboardData.getData("text"),te=(U.match(/\n/g)||[]).length+1;if(te>5){l.preventDefault();const F=`[Pasted text #${E(U)} +${te} lines]`,H=l.target,se=H.selectionStart||0,ae=H.selectionEnd||0,ne=s.slice(0,se)+F+s.slice(ae);a(ne),c||p(!0)}},[s,a,c,p,w,R,E]),x=t.useCallback(async l=>{const L=l.target.files;if(L){for(const K of L){const U=await w(K);U&&R(U)}D.current&&(D.current.value="")}},[w,R]),N=t.useCallback(l=>{if(l.key==="Enter"&&l.shiftKey){c||(l.preventDefault(),p(!0));return}l.key==="Enter"&&(l.preventDefault(),d())},[c,p,d]),P=t.useCallback(l=>{},[]),W=t.useCallback(l=>{l.button===1&&(l.preventDefault(),l.stopPropagation())},[]),J=t.useCallback(l=>{i.current=l,u==null||u(l)},[u]),V=v?"agent-panel-input":"guake-input",q=v?"agent-panel-input-container":"guake-input-container",X=v?"agent-panel-attach-btn":"guake-attach-btn",B=v?"agent-panel-send-btn":"",C=c?v?"agent-panel-input-expanded":"guake-input-expanded":"";return e.jsxs(e.Fragment,{children:[A.length>0&&e.jsx("div",{className:v?"agent-panel-attachments":"guake-attachments",children:A.map(l=>e.jsxs("div",{className:`${v?"agent-panel-attachment":"guake-attachment"} ${l.isImage?"is-image":""}`,children:[e.jsx("span",{className:v?"agent-panel-attachment-icon":"guake-attachment-icon",children:e.jsx(z,{name:l.isImage?"file":"paperclip",size:12})}),e.jsx("span",{className:v?"agent-panel-attachment-name":"guake-attachment-name",title:l.path,children:l.name}),!v&&e.jsxs("span",{className:"guake-attachment-size",children:["(",Math.round(l.size/1024),"KB)"]}),e.jsx("button",{className:v?"agent-panel-attachment-remove":"guake-attachment-remove",onClick:()=>k(l.id),title:"Remove",children:"×"})]},l.id))}),e.jsxs("div",{className:`${V} ${C} ${h}`,children:[e.jsx("input",{ref:D,type:"file",multiple:!0,onChange:x,style:{display:"none"},accept:"*"}),e.jsxs("div",{className:q,onAuxClick:W,children:[e.jsx("button",{className:X,onClick:()=>{var l;return(l=D.current)==null?void 0:l.click()},title:"Attach file (or paste image)",children:e.jsx(z,{name:"paperclip",size:14})}),c?e.jsx("textarea",{ref:J,placeholder:j,value:s,onChange:l=>a(l.target.value),onKeyDown:N,onPaste:$,onMouseDown:P}):e.jsx("input",{ref:u,type:"text",placeholder:j,value:s,onChange:l=>a(l.target.value),onKeyDown:N,onPaste:$,onMouseDown:P}),e.jsx("button",{className:B,onClick:d,disabled:!M,title:"Send",children:e.jsx(z,{name:"send",size:14})})]})]})]})}function pt(s){const a=Math.floor(s/1e3),c=Math.floor(a/60),f=a%60;return`${c}:${f.toString().padStart(2,"0")}`}const ht=t.memo(function({agentId:a,isWorking:c,timestamp:f}){const{t:p}=fe(["terminal"]),[d,M]=t.useState(0);return t.useEffect(()=>{if(!c||!f){M(0);return}M(Date.now()-f);const A=setInterval(()=>{M(Date.now()-f)},1e3);return()=>clearInterval(A)},[c,f]),c?e.jsxs("div",{className:"guake-stop-bar",children:[e.jsx("span",{className:"guake-elapsed-timer",children:pt(d)}),e.jsxs("button",{className:"guake-stop-btn",onClick:()=>I.stopAgent(a),title:p("terminal:input.stopOperation"),children:[e.jsx("span",{className:"stop-icon",children:e.jsx(z,{name:"stop",size:12,weight:"fill"})}),e.jsx("span",{className:"stop-label",children:p("terminal:input.stop")})]})]}):null});function xt({agent:s,history:a,outputs:c,isExpanded:f,isFocused:p,advancedView:d,onExpand:M,onFocus:A,inputRef:R,onLoadMore:k,onClearHistory:w}){const{t:E}=fe(["terminal","common"]),j=_e(s.id),h=t.useRef(null),[v,u]=t.useState(!1),D=t.useRef(0),i=t.useRef(!1),[b,$]=t.useState(!0),[x,N]=t.useState(!1),[P,W]=t.useState(null),[J,V]=t.useState(null),[q,X]=t.useState(null);Te(`commander-image-modal-${s.id}`,P!==null,()=>W(null));const{command:B,setCommand:C,forceTextarea:l,setForceTextarea:L,useTextarea:K,setPastedTexts:U,incrementPastedCount:te,resetPastedCount:_,attachedFiles:F,setAttachedFiles:H,removeAttachedFile:se,uploadFile:ae,expandPastedTexts:ne}=Ue({selectedAgentId:s.id}),ce=B.trim().length>0||F.length>0,n=Be({outputs:c,viewMode:d?"advanced":"simple"}),o=t.useMemo(()=>{const S=Ke(s);return{usedPercent:S.usedPercent,freePercent:S.freePercent,hasData:!!s.contextStats,totalTokens:S.totalTokens,contextWindow:S.contextWindow}},[s.contextStats,s.contextUsed,s.contextLimit]),g=t.useCallback(()=>{!v&&(a!=null&&a.hasMore)&&k&&(u(!0),D.current=h.current?h.current.scrollHeight-h.current.scrollTop:0,k())},[v,a==null?void 0:a.hasMore,k]);t.useEffect(()=>{v&&a&&!a.loading&&u(!1)},[a,v]);const m=t.useCallback(()=>{i.current=!0,$(!1)},[]),T=t.useRef(f),Z=t.useRef(p);t.useEffect(()=>{(f&&!T.current||p&&!Z.current)&&(i.current=!1,$(!0),N(!0)),T.current=f,Z.current=p},[f,p]);const ee=t.useRef(a==null?void 0:a.loading);t.useEffect(()=>{ee.current&&!(a!=null&&a.loading)&&(i.current=!1,$(!0),N(!0)),ee.current=a==null?void 0:a.loading},[a==null?void 0:a.loading]),t.useEffect(()=>{if(!x)return;const S=h.current;if(!S)return;const y=performance.now();let O=0,ue=-1,be;const Re=()=>{const{scrollTop:Fe,scrollHeight:Ne,clientHeight:Le}=S,He=Ne-Fe-Le<=2;if(Math.abs(Ne-ue)<=1&&He?O+=1:O=0,ue=Ne,O>=3){N(!1);return}if(performance.now()-y>5e3){N(!1);return}be=requestAnimationFrame(Re)};return be=requestAnimationFrame(Re),()=>cancelAnimationFrame(be)},[x]),t.useEffect(()=>{i.current||$(!0)},[n.length]);const G=t.useCallback(()=>!1,[]),de=t.useCallback(S=>{const y=te();return U(O=>new Map(O).set(y,S)),y},[te,U]),he=t.useCallback(S=>{H(y=>[...y,S])},[H]),xe=t.useCallback(()=>{if(!ce)return;if(B.trim()==="/clear"&&F.length===0){I.clearContext(s.id),w(),C(""),L(!1),U(new Map),H([]),_();return}let S=ne(B.trim());if(F.length>0){const y=F.map(O=>O.isImage?`[Image: ${O.path}]`:`[File: ${O.path}]`).join(`
|
|
3
3
|
`);S=S?`${S}
|
|
4
4
|
|