tide-commander 1.158.1 → 1.159.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/assets/{BossLogsModal-B93nAi6w.js → BossLogsModal-CL5C40v7.js} +1 -1
- package/dist/assets/{BossSpawnModal-BZfkBIUP.js → BossSpawnModal-QRrIVSsE.js} +1 -1
- package/dist/assets/{ControlsModal-CokH7-Ch.js → ControlsModal-_cw1dgUl.js} +1 -1
- package/dist/assets/{DockerLogsModal-CE7voebe.js → DockerLogsModal-BMzpUMYF.js} +1 -1
- package/dist/assets/{EmbeddedEditor-2SZUK5kL.js → EmbeddedEditor-DqY3hqbU.js} +1 -1
- package/dist/assets/{GmailOAuthSetup-loIWx7N6.js → GmailOAuthSetup-Bc9srJE4.js} +1 -1
- package/dist/assets/{GoogleOAuthSetup-vJXIANe_.js → GoogleOAuthSetup-DeaxWPCd.js} +1 -1
- package/dist/assets/{IframeModal-Ckvn_Lzf.js → IframeModal-3uoqeRAN.js} +1 -1
- package/dist/assets/{IntegrationsPanel-B3zzS9Nh.js → IntegrationsPanel-DL9VTiWv.js} +2 -2
- package/dist/assets/{LogViewerModal-D0XO9IMx.js → LogViewerModal-Bp80nuou.js} +1 -1
- package/dist/assets/{MonitoringModal-Chl__aV6.js → MonitoringModal-p_ucVk30.js} +1 -1
- package/dist/assets/{PM2LogsModal-BIrvZOaj.js → PM2LogsModal-Bk060m4u.js} +1 -1
- package/dist/assets/{RestoreArchivedAreaModal-CWLku6hW.js → RestoreArchivedAreaModal-DgYKagxt.js} +1 -1
- package/dist/assets/{Scene2DCanvas-7cZb2Lf_.js → Scene2DCanvas-C7Xc_5Dz.js} +1 -1
- package/dist/assets/{SceneManager-Bjr_vL-G.js → SceneManager-D1HZULQL.js} +1 -1
- package/dist/assets/{SkillsPanel-B4xujErO.js → SkillsPanel-DR0YQBuD.js} +1 -1
- package/dist/assets/{SlackMultiInstanceSetup-CHtPdLjB.js → SlackMultiInstanceSetup-W9boSb9T.js} +1 -1
- package/dist/assets/{SpawnModal-CMo1ONqI.js → SpawnModal-CN0uPU2H.js} +1 -1
- package/dist/assets/{StatisticsModal-CFmf5imp.js → StatisticsModal-Bs8WGrk8.js} +1 -1
- package/dist/assets/{SubordinateAssignmentModal-lHpc0gZ6.js → SubordinateAssignmentModal-CppZw5TE.js} +1 -1
- package/dist/assets/{TriggerManagerPanel-DnlJPZPN.js → TriggerManagerPanel-BZeMe-9r.js} +1 -1
- package/dist/assets/{WorkflowEditorPanel-BGlj99Mc.js → WorkflowEditorPanel-BH5HqvN2.js} +1 -1
- package/dist/assets/{area-logos-B6vGTcNz.js → area-logos-B6CrA1uD.js} +1 -1
- package/dist/assets/{index-Bhuukfvi.js → index-B_RzzK2X.js} +3 -3
- package/dist/assets/{index-DjcG_URX.js → index-BtnAoK73.js} +1 -1
- package/dist/assets/index-CN1Rq7ZV.js +2 -0
- package/dist/assets/{index-BzfQHwRj.js → index-Cmhnprql.js} +1 -1
- package/dist/assets/{index-CMBYmIwC.js → index-D3ivqCnn.js} +2 -2
- package/dist/assets/{index-CTGjGlWc.js → index-DHio1aFH.js} +1 -1
- package/dist/assets/{index-B283Ampa.js → index-DI8A9Ggk.js} +1 -1
- package/dist/assets/{index-E5gXqQz2.js → index-DnOc4jz6.js} +1 -1
- package/dist/assets/{index-CZGcOnhI.js → index-ZZxeSHEQ.js} +1 -1
- package/dist/assets/main-BZcOdtO_.css +1 -0
- package/dist/assets/main-BbNRp516.js +297 -0
- package/dist/assets/{web-BGYTb0Uy.js → web-BCXtfjWo.js} +1 -1
- package/dist/assets/{web-CtMcJxQ0.js → web-C24Z_D9n.js} +1 -1
- package/dist/assets/{web-DWhg3yLF.js → web-CC__8ncF.js} +1 -1
- package/dist/build-info.json +1 -1
- package/dist/index.html +2 -2
- package/dist/src/packages/server/cli.js +22 -1
- package/dist/src/packages/server/data/builtin-skills/computer-use.js +102 -0
- package/dist/src/packages/server/data/builtin-skills/index.js +2 -0
- package/package.json +1 -1
- package/dist/assets/index-BBDS1FfV.js +0 -2
- package/dist/assets/main-B9woGcB4.css +0 -1
- package/dist/assets/main-FwlHcqGj.js +0 -300
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as U,a as ee,r as l,s as u,j as e,D as oe,I as L,C as me,b as be,c as ue,d as he,g as _e,e as pe,Q as xe,R as fe}from"./main-FwlHcqGj.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const je=({building:a,connections:j,activeConnectionId:d,activeDatabase:n,collapsed:y,onToggleCollapse:_,onConnectionChange:D,onDatabaseChange:R,onInsertTable:N,onSelectTableQuery:F})=>{const{t:x}=U(["terminal"]),f=ee(a.id),[I,G]=l.useState(new Set),[T,r]=l.useState(""),[i,g]=l.useState(""),[w,O]=l.useState(!1),[P,J]=l.useState(null),H=l.useRef(null),K=l.useRef(null),C=l.useRef(null),k=d?f.databases.get(d)??[]:[],q=d&&n?`${d}:${n}`:"",$=q?f.tables.get(q)??[]:[],h=d?f.connectionStatus.get(d):void 0,E=l.useMemo(()=>{if(!T.trim())return k;const t=T.toLowerCase();return k.filter(o=>o.toLowerCase().includes(t))},[k,T]),z=l.useMemo(()=>{if(!i.trim())return $;const t=i.toLowerCase();return $.filter(o=>o.name.toLowerCase().includes(t))},[$,i]);l.useEffect(()=>{const t=o=>{K.current&&!K.current.contains(o.target)&&O(!1)};return w&&document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[w]),l.useEffect(()=>{d&&!h&&u.testDatabaseConnection(a.id,d)},[a.id,d,h]),l.useEffect(()=>{d&&(h!=null&&h.connected)&&k.length===0&&u.listDatabases(a.id,d)},[a.id,d,h==null?void 0:h.connected,k.length]),l.useEffect(()=>{d&&n&&$.length===0&&u.listTables(a.id,d,n)},[a.id,d,n,$.length]),l.useEffect(()=>{J(null),g("")},[d,n]);const b=l.useCallback(t=>{G(o=>{const v=new Set(o);if(v.has(t))v.delete(t);else if(v.add(t),d&&n){const S=`${d}:${n}:${t}`;f.tableSchemas.has(S)||u.getTableSchema(a.id,d,n,t)}return v})},[a.id,d,n,f.tableSchemas]),p=t=>{if(!d||!n)return null;const o=`${d}:${n}:${t}`;return f.tableSchemas.get(o)};return y?e.jsx("div",{className:"database-sidebar database-sidebar--collapsed",children:e.jsx("button",{className:"database-sidebar__toggle",onClick:_,title:x("terminal:database.expandSidebar"),children:"»"})}):e.jsxs("div",{className:"database-sidebar",children:[e.jsxs("div",{className:"database-sidebar__header",children:[e.jsx("span",{children:x("terminal:database.explorer")}),e.jsx("button",{className:"database-sidebar__toggle",onClick:_,title:x("terminal:database.collapseSidebar"),children:"«"})]}),e.jsxs("div",{className:"database-sidebar__section",children:[e.jsx("div",{className:"database-sidebar__section-title",children:x("terminal:database.connection")}),e.jsx("select",{className:"database-sidebar__select",value:d||"",onChange:t=>D(t.target.value),children:j.length===0?e.jsx("option",{value:"",children:x("terminal:database.noConnections")}):j.map(t=>{var o;return e.jsxs("option",{value:t.id,children:[((o=oe[t.engine])==null?void 0:o.icon)??"🗄️"," ",t.name]},t.id)})}),h&&e.jsx("div",{className:`database-sidebar__status ${h.connected?"database-sidebar__status--connected":"database-sidebar__status--error"}`,children:h.connected?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"database-sidebar__status-icon",children:"✓"}),x("terminal:database.connected"),h.serverVersion&&e.jsxs("span",{className:"database-sidebar__version",children:["(",h.serverVersion,")"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"database-sidebar__status-icon",children:"✗"}),h.error||x("terminal:database.disconnected")]})})]}),k.length>0&&e.jsxs("div",{className:"database-sidebar__section",children:[e.jsx("div",{className:"database-sidebar__section-title",children:x("terminal:database.databaseTitle")}),e.jsxs("div",{className:"database-sidebar__searchable-select",ref:K,children:[e.jsx("input",{ref:H,className:"database-sidebar__search-input",type:"text",value:w?T:n||"",placeholder:x("terminal:database.selectDatabase"),onChange:t=>{r(t.target.value),w||O(!0)},onFocus:()=>{O(!0),r("")},onKeyDown:t=>{var o,v;t.key==="Escape"?(O(!1),r(""),(o=H.current)==null||o.blur()):t.key==="Enter"&&E.length===1&&(R(E[0]),O(!1),r(""),(v=H.current)==null||v.blur())}}),w&&e.jsx("div",{className:"database-sidebar__dropdown",children:E.length===0?e.jsx("div",{className:"database-sidebar__dropdown-empty",children:"No matches"}):E.map(t=>e.jsx("div",{className:`database-sidebar__dropdown-item ${t===n?"database-sidebar__dropdown-item--active":""}`,onMouseDown:o=>{o.preventDefault(),R(t),O(!1),r("")},children:t},t))})]})]}),$.length>0&&e.jsxs("div",{className:"database-sidebar__section database-sidebar__section--tables",children:[e.jsx("div",{className:"database-sidebar__section-title",children:i.trim()?x("terminal:database.tablesCount",{count:z.length})+` / ${$.length}`:x("terminal:database.tablesCount",{count:$.length})}),e.jsxs("div",{className:"database-sidebar__table-filter",children:[e.jsx("input",{ref:C,className:"database-sidebar__table-filter-input",type:"text",value:i,placeholder:x("terminal:database.filterTables"),onChange:t=>g(t.target.value),onKeyDown:t=>{var o;t.key==="Escape"&&(i?g(""):(o=C.current)==null||o.blur(),t.stopPropagation())}}),i&&e.jsx("button",{className:"database-sidebar__table-filter-clear",onClick:()=>{var t;g(""),(t=C.current)==null||t.focus()},title:"Clear filter",children:"×"})]}),e.jsxs("div",{className:"database-sidebar__tables",children:[i.trim()&&z.length===0&&e.jsx("div",{className:"database-sidebar__tables-empty",children:x("terminal:database.noTablesMatch")}),z.map(t=>{const o=I.has(t.name),v=o?p(t.name):null;return e.jsxs("div",{className:"database-sidebar__table",children:[e.jsxs("div",{className:"database-sidebar__table-header",children:[e.jsx("button",{className:"database-sidebar__table-expand",onClick:()=>b(t.name),title:o?"Collapse table schema":"Expand table schema",children:e.jsx(L,{name:o?"caret-down":"caret-right",size:10})}),e.jsx("span",{className:"database-sidebar__table-icon",children:e.jsx(L,{name:t.type==="view"?"eye":"clipboard",size:12})}),e.jsx("span",{className:`database-sidebar__table-name ${P===t.name?"database-sidebar__table-name--selected":""}`,onClick:()=>J(t.name),onDoubleClick:()=>{J(t.name),F(t.name)},children:t.name}),e.jsx("button",{className:"database-sidebar__table-insert",onClick:S=>{S.stopPropagation(),N(t.name)},title:x("terminal:database.insertTableName"),children:"+"})]}),o&&v&&e.jsx("div",{className:"database-sidebar__table-columns",children:v.columns.map(S=>e.jsxs("div",{className:"database-sidebar__column",onClick:()=>N(S.name),title:`${S.type}${S.nullable?" NULL":" NOT NULL"}${S.primaryKey?" PK":""}`,children:[e.jsx("span",{className:"database-sidebar__column-icon",children:S.primaryKey?e.jsx(L,{name:"key",size:11}):null}),e.jsx("span",{className:"database-sidebar__column-name",children:S.name}),e.jsx("span",{className:"database-sidebar__column-type",children:S.type})]},S.name))})]},t.name)})]})]})]})},ye=({buildingId:a,history:j,onLoadQuery:d})=>{const{t:n}=U(["terminal","common"]),[y,_]=l.useState(""),[D,R]=l.useState(!1),[N,F]=l.useState(!1),x=l.useMemo(()=>{let r=j;if(D&&(r=r.filter(i=>i.favorite)),y.trim()){const i=y.toLowerCase();r=r.filter(g=>g.query.toLowerCase().includes(i)||g.database.toLowerCase().includes(i))}return r},[j,D,y]),f=r=>{const i=new Date(r),w=new Date().getTime()-i.getTime();return w<1440*60*1e3?i.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):w<10080*60*1e3?i.toLocaleDateString([],{weekday:"short"})+" "+i.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):i.toLocaleDateString([],{month:"short",day:"numeric"})},I=l.useCallback((r,i)=>{i.stopPropagation(),u.toggleQueryFavorite(a,r)},[a]),G=l.useCallback((r,i)=>{i.stopPropagation(),u.deleteQueryFromHistory(a,r)},[a]),T=l.useCallback(()=>{F(!0)},[]);return j.length===0?e.jsxs("div",{className:"query-history query-history--empty",children:[e.jsx("p",{children:n("terminal:database.noHistory")}),e.jsx("p",{children:n("terminal:database.queriesAppearHere")})]}):e.jsxs("div",{className:"query-history",children:[e.jsxs("div",{className:"query-history__toolbar",children:[e.jsx("input",{type:"text",className:"query-history__search",placeholder:n("terminal:database.searchQueries"),value:y,onChange:r=>_(r.target.value)}),e.jsxs("label",{className:"query-history__filter",children:[e.jsx("input",{type:"checkbox",checked:D,onChange:r=>R(r.target.checked)}),n("terminal:database.favoritesOnly")]}),e.jsx("button",{className:"query-history__clear",onClick:T,title:n("terminal:database.clearAll"),children:n("terminal:database.clearAll")})]}),e.jsxs("div",{className:"query-history__list",children:[x.map(r=>e.jsxs("div",{className:`query-history__item ${r.status==="error"?"query-history__item--error":""}`,onClick:()=>d(r.query),children:[e.jsxs("div",{className:"query-history__item-header",children:[e.jsx("span",{className:`query-history__status ${r.status==="success"?"query-history__status--success":"query-history__status--error"}`,children:e.jsx(L,{name:r.status==="success"?"check":"cross",size:12})}),e.jsx("span",{className:"query-history__database",children:r.database}),e.jsx("span",{className:"query-history__date",children:f(r.executedAt)}),e.jsxs("span",{className:"query-history__duration",children:[r.duration,"ms"]}),r.rowCount!==void 0&&e.jsx("span",{className:"query-history__row-count",children:n("terminal:database.rowCount",{count:r.rowCount})})]}),e.jsx("div",{className:"query-history__query",children:e.jsx("code",{children:r.query.length>200?r.query.substring(0,200)+"...":r.query})}),r.error&&e.jsx("div",{className:"query-history__error",children:r.error}),e.jsxs("div",{className:"query-history__actions",children:[e.jsx("button",{className:`query-history__favorite ${r.favorite?"query-history__favorite--active":""}`,onClick:i=>I(r.id,i),title:r.favorite?n("terminal:database.removeFromFavorites"):n("terminal:database.addToFavorites"),children:e.jsx(L,{name:"star",size:12,weight:r.favorite?"fill":"regular",color:r.favorite?"#facc15":void 0})}),e.jsx("button",{className:"query-history__delete",onClick:i=>G(r.id,i),title:n("terminal:database.deleteFromHistory"),children:e.jsx(L,{name:"trash",size:12})})]})]},r.id)),x.length===0&&e.jsx("div",{className:"query-history__no-results",children:n("terminal:database.noQueriesMatch")})]}),e.jsx(me,{isOpen:N,title:n("terminal:database.clearAll"),message:n("terminal:database.confirmClearHistory"),confirmLabel:n("terminal:database.clearAll"),cancelLabel:n("common:buttons.cancel"),variant:"danger",onConfirm:()=>u.clearQueryHistory(a),onClose:()=>F(!1)})]})},Ne=({tabs:a,activeTabId:j,onTabClick:d,onTabClose:n})=>{const{t:y}=U(["terminal"]);return e.jsx("div",{className:"database-tabs",children:a.map(_=>e.jsxs("div",{className:`database-tabs__tab ${j===_.id?"database-tabs__tab--active":""}`,children:[e.jsxs("button",{className:"database-tabs__tab-label",onClick:()=>d(_),title:`${_.connectionName} / ${_.database}`,children:[_.database,e.jsx("span",{className:"database-tabs__tab-connection",children:_.connectionName})]}),e.jsx("button",{className:"database-tabs__tab-close",onClick:()=>n(_.id),title:y("terminal:database.closeTab"),"aria-label":`Close ${_.database} tab`,children:"×"})]},_.id))})},ae=a=>`db-panel-${a}`;function ve(a){try{const j=localStorage.getItem(ae(a));return j?JSON.parse(j):{}}catch{return{}}}function Se(a,j){try{localStorage.setItem(ae(a),JSON.stringify(j))}catch{}}const we=({building:a,onClose:j,onMinimize:d})=>{var W,Y,X,Z;const{t:n}=U(["terminal","common"]),y=ee(a.id),_=be(a.id),D=ue(a.id),R=he(a.id),N=l.useRef(ve(a.id)),F=l.useRef(null),x=l.useRef(0),f=((W=a.database)==null?void 0:W.connections)??[],I=(s,c)=>`${s}:${c}`,G=s=>s?(N.current.queries??{})[s]??"":N.current.generalQuery??"",[T,r]=l.useState("results"),[i,g]=l.useState(0),[w,O]=l.useState(!1),[P,J]=l.useState(!1),[H,K]=l.useState(()=>(N.current.openTabs??[]).map(c=>{var m;return{id:`${c.connectionId}:${c.database}`,connectionId:c.connectionId,connectionName:((m=f.find(A=>A.id===c.connectionId))==null?void 0:m.name)??c.connectionId,database:c.database}})),[C,k]=l.useState(N.current.activeTabId??null),[q,$]=l.useState(()=>{const s=N.current.queries??{};return N.current.generalQuery,s}),[h,E]=l.useState(G(C)),z=l.useCallback(s=>{E(c=>{const m=typeof s=="function"?s(c):s;return $(A=>{const Q={...A};return C&&(Q[C]=m),Q}),m})},[C]),b=y.activeConnectionId??N.current.connectionId??((Y=a.database)==null?void 0:Y.activeConnectionId)??((X=f[0])==null?void 0:X.id),p=y.activeDatabase??N.current.database??((Z=a.database)==null?void 0:Z.activeDatabase),t=f.find(s=>s.id===b),o=b&&p?`${b}:${p}`:"",v=o?y.tables.get(o)??[]:[],S=l.useMemo(()=>{const s=new Map;return!b||!p||v.forEach(c=>{const m=y.tableSchemas.get(`${b}:${p}:${c.name}`);m&&s.set(c.name,{columns:m.columns})}),s},[b,p,v,y.tableSchemas]),V=l.useCallback((s,c)=>{var Q;const m=I(s,c),A=((Q=f.find(M=>M.id===s))==null?void 0:Q.name)??s;K(M=>{if(M.some(de=>de.id===m))return M;const ie={id:m,connectionId:s,connectionName:A,database:c};return[...M,ie]}),k(m),E(q[m]??""),u.setActiveConnection(a.id,s),u.setActiveDatabase(a.id,c)},[a.id,f,q]),se=l.useCallback(s=>{K(c=>c.filter(m=>m.id!==s)),C===s&&K(c=>{if(c.length>0){const m=c[0];k(m.id),E(q[m.id]??""),u.setActiveConnection(a.id,m.connectionId),u.setActiveDatabase(a.id,m.database)}else k(null),E("");return c})},[C,a.id,q]),te=l.useCallback(s=>{k(s.id),E(q[s.id]??""),u.setActiveConnection(a.id,s.connectionId),u.setActiveDatabase(a.id,s.database)},[a.id,q]);l.useEffect(()=>{if(!P&&f.length>0){const s=N.current;s.connectionId&&f.some(c=>c.id===s.connectionId)&&(u.setActiveConnection(a.id,s.connectionId),u.listDatabases(a.id,s.connectionId),s.database&&(u.setActiveDatabase(a.id,s.database),u.listTables(a.id,s.connectionId,s.database))),J(!0)}},[a.id,f,P]),l.useEffect(()=>{u.requestQueryHistory(a.id)},[a.id]),l.useEffect(()=>{const s=c=>{c.key==="Escape"&&(c.preventDefault(),c.stopPropagation(),j())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[j]),l.useEffect(()=>{P&&b&&Se(a.id,{connectionId:b,database:p,lastQuery:h,queries:q,generalQuery:"",openTabs:H.map(s=>({connectionId:s.connectionId,database:s.database})),activeTabId:C??void 0})},[a.id,b,p,h,P,H,C,q]);const ne=l.useCallback(s=>{var c;if(!(!b||!p||!h.trim()||R))if(s==="cursor"){const m=(c=F.current)==null?void 0:c.querySelector(".query-editor__textarea"),A=(m==null?void 0:m.selectionStart)??x.current,Q=_e(h,A);Q&&u.executeQuery(a.id,b,p,Q)}else{const m=pe(h);if(m.length<=1)u.executeQuery(a.id,b,p,h.trim());else{const A=b,Q=p;(async()=>{for(const M of m)await u.executeQueryAndWait(a.id,A,Q,M.sql)})()}}},[a.id,b,p,h,R]),re=l.useCallback(s=>{z(s),r("results")},[]),le=l.useCallback(s=>{u.setActiveConnection(a.id,s),u.listDatabases(a.id,s)},[a.id]),ce=l.useCallback(s=>{b&&(V(b,s),u.listTables(a.id,b,s))},[a.id,b,V]),B=_[i];return f.length===0?e.jsxs("div",{className:"database-panel",ref:F,children:[e.jsxs("div",{className:"database-panel__header",children:[e.jsxs("div",{className:"database-panel__title",children:[e.jsx("span",{className:"database-panel__icon",children:e.jsx(L,{name:"database",size:16})}),e.jsx("span",{className:"database-panel__name",children:a.name})]}),e.jsx("button",{className:"database-panel__close",onClick:j,children:"×"})]}),e.jsx("div",{className:"database-panel__body",children:e.jsxs("div",{className:"database-panel__no-connections",children:[e.jsx("div",{className:"database-panel__no-connections-icon",children:e.jsx(L,{name:"plug",size:32})}),e.jsx("h3",{children:n("terminal:database.noConnections")}),e.jsx("p",{children:n("terminal:database.noConnectionsDesc")}),e.jsx("p",{children:n("terminal:database.toGetStarted")}),e.jsxs("ol",{children:[e.jsx("li",{children:n("terminal:database.step1Close")}),e.jsx("li",{children:n("terminal:database.step2Settings")}),e.jsx("li",{children:n("terminal:database.step3AddConnection")}),e.jsx("li",{children:n("terminal:database.step4Reopen")})]})]})})]}):e.jsxs("div",{className:"database-panel",ref:F,children:[e.jsxs("div",{className:"database-panel__header",children:[e.jsxs("div",{className:"database-panel__title",children:[e.jsx("span",{className:"database-panel__icon",children:(t==null?void 0:t.engine)==="mysql"?"🐬":"🐘"}),e.jsx("span",{className:"database-panel__name",children:a.name}),t&&e.jsxs("span",{className:"database-panel__connection-info",children:[t.name," / ",p||n("terminal:database.noDatabaseSelected")]})]}),e.jsxs("div",{className:"database-panel__header-actions",children:[d&&e.jsx("button",{className:"database-panel__close",onClick:d,title:"Minimize — dock below the terminal input",children:e.jsx(L,{name:"arrow-down",size:14})}),e.jsx("button",{className:"database-panel__close",onClick:j,children:"×"})]})]}),e.jsxs("div",{className:"database-panel__body",children:[e.jsx(je,{building:a,connections:f,activeConnectionId:b,activeDatabase:p,collapsed:w,onToggleCollapse:()=>O(!w),onConnectionChange:le,onDatabaseChange:ce,onInsertTable:s=>z(c=>c+` ${s}`),onSelectTableQuery:s=>{const c=`SELECT * FROM ${s}`;z(c),b&&p&&u.executeQuery(a.id,b,p,c)}}),e.jsxs("div",{className:"database-panel__main",children:[H.length>0&&e.jsx(Ne,{tabs:H,activeTabId:C,onTabClick:te,onTabClose:se}),e.jsx(xe,{query:h,onChange:z,onExecute:ne,isExecuting:R,disabled:!b||!p,tables:v,tableSchemas:S,onRequestTableSchema:s=>{b&&p&&u.getTableSchema(a.id,b,p,s)}}),e.jsxs("div",{className:"database-panel__tabs",children:[e.jsxs("button",{className:`database-panel__tab ${T==="results"?"database-panel__tab--active":""}`,onClick:()=>r("results"),children:[n("terminal:database.results"),_.length>0&&e.jsx("span",{className:"database-panel__tab-badge",children:_.length})]}),e.jsxs("button",{className:`database-panel__tab ${T==="history"?"database-panel__tab--active":""}`,onClick:()=>r("history"),children:[n("terminal:database.history"),D.length>0&&e.jsx("span",{className:"database-panel__tab-badge",children:D.length})]}),T==="results"&&_.length>1&&e.jsxs("div",{className:"database-panel__result-nav",children:[e.jsxs("button",{disabled:i>=_.length-1,onClick:()=>g(s=>s+1),children:["← ",n("terminal:database.older")]}),e.jsxs("span",{children:[i+1," / ",_.length]}),e.jsxs("button",{disabled:i<=0,onClick:()=>g(s=>s-1),children:[n("terminal:database.newer")," →"]})]})]}),e.jsx("div",{className:"database-panel__tab-content",children:T==="results"?B?e.jsx(fe,{result:B,buildingId:a.id,building:a}):e.jsxs("div",{className:"database-panel__empty",children:[e.jsx("p",{children:n("terminal:database.noResultsYet")}),e.jsx("p",{children:n("terminal:database.selectDbAndRun")})]}):e.jsx(ye,{buildingId:a.id,history:D,onLoadQuery:re})})]})]})]})};export{we as DatabasePanel,je as DatabaseSidebar,Ne as DatabaseTabs,xe as QueryEditor,ye as QueryHistoryPanel,fe as ResultsTable};
|
|
1
|
+
import{u as U,a as ee,r as l,s as u,j as e,D as oe,I as L,C as me,b as be,c as ue,d as he,g as _e,e as pe,Q as xe,R as fe}from"./main-BbNRp516.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const je=({building:a,connections:j,activeConnectionId:d,activeDatabase:n,collapsed:y,onToggleCollapse:_,onConnectionChange:D,onDatabaseChange:R,onInsertTable:N,onSelectTableQuery:F})=>{const{t:x}=U(["terminal"]),f=ee(a.id),[I,G]=l.useState(new Set),[T,r]=l.useState(""),[i,g]=l.useState(""),[w,O]=l.useState(!1),[P,J]=l.useState(null),H=l.useRef(null),K=l.useRef(null),C=l.useRef(null),k=d?f.databases.get(d)??[]:[],q=d&&n?`${d}:${n}`:"",$=q?f.tables.get(q)??[]:[],h=d?f.connectionStatus.get(d):void 0,E=l.useMemo(()=>{if(!T.trim())return k;const t=T.toLowerCase();return k.filter(o=>o.toLowerCase().includes(t))},[k,T]),z=l.useMemo(()=>{if(!i.trim())return $;const t=i.toLowerCase();return $.filter(o=>o.name.toLowerCase().includes(t))},[$,i]);l.useEffect(()=>{const t=o=>{K.current&&!K.current.contains(o.target)&&O(!1)};return w&&document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[w]),l.useEffect(()=>{d&&!h&&u.testDatabaseConnection(a.id,d)},[a.id,d,h]),l.useEffect(()=>{d&&(h!=null&&h.connected)&&k.length===0&&u.listDatabases(a.id,d)},[a.id,d,h==null?void 0:h.connected,k.length]),l.useEffect(()=>{d&&n&&$.length===0&&u.listTables(a.id,d,n)},[a.id,d,n,$.length]),l.useEffect(()=>{J(null),g("")},[d,n]);const b=l.useCallback(t=>{G(o=>{const v=new Set(o);if(v.has(t))v.delete(t);else if(v.add(t),d&&n){const S=`${d}:${n}:${t}`;f.tableSchemas.has(S)||u.getTableSchema(a.id,d,n,t)}return v})},[a.id,d,n,f.tableSchemas]),p=t=>{if(!d||!n)return null;const o=`${d}:${n}:${t}`;return f.tableSchemas.get(o)};return y?e.jsx("div",{className:"database-sidebar database-sidebar--collapsed",children:e.jsx("button",{className:"database-sidebar__toggle",onClick:_,title:x("terminal:database.expandSidebar"),children:"»"})}):e.jsxs("div",{className:"database-sidebar",children:[e.jsxs("div",{className:"database-sidebar__header",children:[e.jsx("span",{children:x("terminal:database.explorer")}),e.jsx("button",{className:"database-sidebar__toggle",onClick:_,title:x("terminal:database.collapseSidebar"),children:"«"})]}),e.jsxs("div",{className:"database-sidebar__section",children:[e.jsx("div",{className:"database-sidebar__section-title",children:x("terminal:database.connection")}),e.jsx("select",{className:"database-sidebar__select",value:d||"",onChange:t=>D(t.target.value),children:j.length===0?e.jsx("option",{value:"",children:x("terminal:database.noConnections")}):j.map(t=>{var o;return e.jsxs("option",{value:t.id,children:[((o=oe[t.engine])==null?void 0:o.icon)??"🗄️"," ",t.name]},t.id)})}),h&&e.jsx("div",{className:`database-sidebar__status ${h.connected?"database-sidebar__status--connected":"database-sidebar__status--error"}`,children:h.connected?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"database-sidebar__status-icon",children:"✓"}),x("terminal:database.connected"),h.serverVersion&&e.jsxs("span",{className:"database-sidebar__version",children:["(",h.serverVersion,")"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"database-sidebar__status-icon",children:"✗"}),h.error||x("terminal:database.disconnected")]})})]}),k.length>0&&e.jsxs("div",{className:"database-sidebar__section",children:[e.jsx("div",{className:"database-sidebar__section-title",children:x("terminal:database.databaseTitle")}),e.jsxs("div",{className:"database-sidebar__searchable-select",ref:K,children:[e.jsx("input",{ref:H,className:"database-sidebar__search-input",type:"text",value:w?T:n||"",placeholder:x("terminal:database.selectDatabase"),onChange:t=>{r(t.target.value),w||O(!0)},onFocus:()=>{O(!0),r("")},onKeyDown:t=>{var o,v;t.key==="Escape"?(O(!1),r(""),(o=H.current)==null||o.blur()):t.key==="Enter"&&E.length===1&&(R(E[0]),O(!1),r(""),(v=H.current)==null||v.blur())}}),w&&e.jsx("div",{className:"database-sidebar__dropdown",children:E.length===0?e.jsx("div",{className:"database-sidebar__dropdown-empty",children:"No matches"}):E.map(t=>e.jsx("div",{className:`database-sidebar__dropdown-item ${t===n?"database-sidebar__dropdown-item--active":""}`,onMouseDown:o=>{o.preventDefault(),R(t),O(!1),r("")},children:t},t))})]})]}),$.length>0&&e.jsxs("div",{className:"database-sidebar__section database-sidebar__section--tables",children:[e.jsx("div",{className:"database-sidebar__section-title",children:i.trim()?x("terminal:database.tablesCount",{count:z.length})+` / ${$.length}`:x("terminal:database.tablesCount",{count:$.length})}),e.jsxs("div",{className:"database-sidebar__table-filter",children:[e.jsx("input",{ref:C,className:"database-sidebar__table-filter-input",type:"text",value:i,placeholder:x("terminal:database.filterTables"),onChange:t=>g(t.target.value),onKeyDown:t=>{var o;t.key==="Escape"&&(i?g(""):(o=C.current)==null||o.blur(),t.stopPropagation())}}),i&&e.jsx("button",{className:"database-sidebar__table-filter-clear",onClick:()=>{var t;g(""),(t=C.current)==null||t.focus()},title:"Clear filter",children:"×"})]}),e.jsxs("div",{className:"database-sidebar__tables",children:[i.trim()&&z.length===0&&e.jsx("div",{className:"database-sidebar__tables-empty",children:x("terminal:database.noTablesMatch")}),z.map(t=>{const o=I.has(t.name),v=o?p(t.name):null;return e.jsxs("div",{className:"database-sidebar__table",children:[e.jsxs("div",{className:"database-sidebar__table-header",children:[e.jsx("button",{className:"database-sidebar__table-expand",onClick:()=>b(t.name),title:o?"Collapse table schema":"Expand table schema",children:e.jsx(L,{name:o?"caret-down":"caret-right",size:10})}),e.jsx("span",{className:"database-sidebar__table-icon",children:e.jsx(L,{name:t.type==="view"?"eye":"clipboard",size:12})}),e.jsx("span",{className:`database-sidebar__table-name ${P===t.name?"database-sidebar__table-name--selected":""}`,onClick:()=>J(t.name),onDoubleClick:()=>{J(t.name),F(t.name)},children:t.name}),e.jsx("button",{className:"database-sidebar__table-insert",onClick:S=>{S.stopPropagation(),N(t.name)},title:x("terminal:database.insertTableName"),children:"+"})]}),o&&v&&e.jsx("div",{className:"database-sidebar__table-columns",children:v.columns.map(S=>e.jsxs("div",{className:"database-sidebar__column",onClick:()=>N(S.name),title:`${S.type}${S.nullable?" NULL":" NOT NULL"}${S.primaryKey?" PK":""}`,children:[e.jsx("span",{className:"database-sidebar__column-icon",children:S.primaryKey?e.jsx(L,{name:"key",size:11}):null}),e.jsx("span",{className:"database-sidebar__column-name",children:S.name}),e.jsx("span",{className:"database-sidebar__column-type",children:S.type})]},S.name))})]},t.name)})]})]})]})},ye=({buildingId:a,history:j,onLoadQuery:d})=>{const{t:n}=U(["terminal","common"]),[y,_]=l.useState(""),[D,R]=l.useState(!1),[N,F]=l.useState(!1),x=l.useMemo(()=>{let r=j;if(D&&(r=r.filter(i=>i.favorite)),y.trim()){const i=y.toLowerCase();r=r.filter(g=>g.query.toLowerCase().includes(i)||g.database.toLowerCase().includes(i))}return r},[j,D,y]),f=r=>{const i=new Date(r),w=new Date().getTime()-i.getTime();return w<1440*60*1e3?i.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):w<10080*60*1e3?i.toLocaleDateString([],{weekday:"short"})+" "+i.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):i.toLocaleDateString([],{month:"short",day:"numeric"})},I=l.useCallback((r,i)=>{i.stopPropagation(),u.toggleQueryFavorite(a,r)},[a]),G=l.useCallback((r,i)=>{i.stopPropagation(),u.deleteQueryFromHistory(a,r)},[a]),T=l.useCallback(()=>{F(!0)},[]);return j.length===0?e.jsxs("div",{className:"query-history query-history--empty",children:[e.jsx("p",{children:n("terminal:database.noHistory")}),e.jsx("p",{children:n("terminal:database.queriesAppearHere")})]}):e.jsxs("div",{className:"query-history",children:[e.jsxs("div",{className:"query-history__toolbar",children:[e.jsx("input",{type:"text",className:"query-history__search",placeholder:n("terminal:database.searchQueries"),value:y,onChange:r=>_(r.target.value)}),e.jsxs("label",{className:"query-history__filter",children:[e.jsx("input",{type:"checkbox",checked:D,onChange:r=>R(r.target.checked)}),n("terminal:database.favoritesOnly")]}),e.jsx("button",{className:"query-history__clear",onClick:T,title:n("terminal:database.clearAll"),children:n("terminal:database.clearAll")})]}),e.jsxs("div",{className:"query-history__list",children:[x.map(r=>e.jsxs("div",{className:`query-history__item ${r.status==="error"?"query-history__item--error":""}`,onClick:()=>d(r.query),children:[e.jsxs("div",{className:"query-history__item-header",children:[e.jsx("span",{className:`query-history__status ${r.status==="success"?"query-history__status--success":"query-history__status--error"}`,children:e.jsx(L,{name:r.status==="success"?"check":"cross",size:12})}),e.jsx("span",{className:"query-history__database",children:r.database}),e.jsx("span",{className:"query-history__date",children:f(r.executedAt)}),e.jsxs("span",{className:"query-history__duration",children:[r.duration,"ms"]}),r.rowCount!==void 0&&e.jsx("span",{className:"query-history__row-count",children:n("terminal:database.rowCount",{count:r.rowCount})})]}),e.jsx("div",{className:"query-history__query",children:e.jsx("code",{children:r.query.length>200?r.query.substring(0,200)+"...":r.query})}),r.error&&e.jsx("div",{className:"query-history__error",children:r.error}),e.jsxs("div",{className:"query-history__actions",children:[e.jsx("button",{className:`query-history__favorite ${r.favorite?"query-history__favorite--active":""}`,onClick:i=>I(r.id,i),title:r.favorite?n("terminal:database.removeFromFavorites"):n("terminal:database.addToFavorites"),children:e.jsx(L,{name:"star",size:12,weight:r.favorite?"fill":"regular",color:r.favorite?"#facc15":void 0})}),e.jsx("button",{className:"query-history__delete",onClick:i=>G(r.id,i),title:n("terminal:database.deleteFromHistory"),children:e.jsx(L,{name:"trash",size:12})})]})]},r.id)),x.length===0&&e.jsx("div",{className:"query-history__no-results",children:n("terminal:database.noQueriesMatch")})]}),e.jsx(me,{isOpen:N,title:n("terminal:database.clearAll"),message:n("terminal:database.confirmClearHistory"),confirmLabel:n("terminal:database.clearAll"),cancelLabel:n("common:buttons.cancel"),variant:"danger",onConfirm:()=>u.clearQueryHistory(a),onClose:()=>F(!1)})]})},Ne=({tabs:a,activeTabId:j,onTabClick:d,onTabClose:n})=>{const{t:y}=U(["terminal"]);return e.jsx("div",{className:"database-tabs",children:a.map(_=>e.jsxs("div",{className:`database-tabs__tab ${j===_.id?"database-tabs__tab--active":""}`,children:[e.jsxs("button",{className:"database-tabs__tab-label",onClick:()=>d(_),title:`${_.connectionName} / ${_.database}`,children:[_.database,e.jsx("span",{className:"database-tabs__tab-connection",children:_.connectionName})]}),e.jsx("button",{className:"database-tabs__tab-close",onClick:()=>n(_.id),title:y("terminal:database.closeTab"),"aria-label":`Close ${_.database} tab`,children:"×"})]},_.id))})},ae=a=>`db-panel-${a}`;function ve(a){try{const j=localStorage.getItem(ae(a));return j?JSON.parse(j):{}}catch{return{}}}function Se(a,j){try{localStorage.setItem(ae(a),JSON.stringify(j))}catch{}}const we=({building:a,onClose:j,onMinimize:d})=>{var W,Y,X,Z;const{t:n}=U(["terminal","common"]),y=ee(a.id),_=be(a.id),D=ue(a.id),R=he(a.id),N=l.useRef(ve(a.id)),F=l.useRef(null),x=l.useRef(0),f=((W=a.database)==null?void 0:W.connections)??[],I=(s,c)=>`${s}:${c}`,G=s=>s?(N.current.queries??{})[s]??"":N.current.generalQuery??"",[T,r]=l.useState("results"),[i,g]=l.useState(0),[w,O]=l.useState(!1),[P,J]=l.useState(!1),[H,K]=l.useState(()=>(N.current.openTabs??[]).map(c=>{var m;return{id:`${c.connectionId}:${c.database}`,connectionId:c.connectionId,connectionName:((m=f.find(A=>A.id===c.connectionId))==null?void 0:m.name)??c.connectionId,database:c.database}})),[C,k]=l.useState(N.current.activeTabId??null),[q,$]=l.useState(()=>{const s=N.current.queries??{};return N.current.generalQuery,s}),[h,E]=l.useState(G(C)),z=l.useCallback(s=>{E(c=>{const m=typeof s=="function"?s(c):s;return $(A=>{const Q={...A};return C&&(Q[C]=m),Q}),m})},[C]),b=y.activeConnectionId??N.current.connectionId??((Y=a.database)==null?void 0:Y.activeConnectionId)??((X=f[0])==null?void 0:X.id),p=y.activeDatabase??N.current.database??((Z=a.database)==null?void 0:Z.activeDatabase),t=f.find(s=>s.id===b),o=b&&p?`${b}:${p}`:"",v=o?y.tables.get(o)??[]:[],S=l.useMemo(()=>{const s=new Map;return!b||!p||v.forEach(c=>{const m=y.tableSchemas.get(`${b}:${p}:${c.name}`);m&&s.set(c.name,{columns:m.columns})}),s},[b,p,v,y.tableSchemas]),V=l.useCallback((s,c)=>{var Q;const m=I(s,c),A=((Q=f.find(M=>M.id===s))==null?void 0:Q.name)??s;K(M=>{if(M.some(de=>de.id===m))return M;const ie={id:m,connectionId:s,connectionName:A,database:c};return[...M,ie]}),k(m),E(q[m]??""),u.setActiveConnection(a.id,s),u.setActiveDatabase(a.id,c)},[a.id,f,q]),se=l.useCallback(s=>{K(c=>c.filter(m=>m.id!==s)),C===s&&K(c=>{if(c.length>0){const m=c[0];k(m.id),E(q[m.id]??""),u.setActiveConnection(a.id,m.connectionId),u.setActiveDatabase(a.id,m.database)}else k(null),E("");return c})},[C,a.id,q]),te=l.useCallback(s=>{k(s.id),E(q[s.id]??""),u.setActiveConnection(a.id,s.connectionId),u.setActiveDatabase(a.id,s.database)},[a.id,q]);l.useEffect(()=>{if(!P&&f.length>0){const s=N.current;s.connectionId&&f.some(c=>c.id===s.connectionId)&&(u.setActiveConnection(a.id,s.connectionId),u.listDatabases(a.id,s.connectionId),s.database&&(u.setActiveDatabase(a.id,s.database),u.listTables(a.id,s.connectionId,s.database))),J(!0)}},[a.id,f,P]),l.useEffect(()=>{u.requestQueryHistory(a.id)},[a.id]),l.useEffect(()=>{const s=c=>{c.key==="Escape"&&(c.preventDefault(),c.stopPropagation(),j())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[j]),l.useEffect(()=>{P&&b&&Se(a.id,{connectionId:b,database:p,lastQuery:h,queries:q,generalQuery:"",openTabs:H.map(s=>({connectionId:s.connectionId,database:s.database})),activeTabId:C??void 0})},[a.id,b,p,h,P,H,C,q]);const ne=l.useCallback(s=>{var c;if(!(!b||!p||!h.trim()||R))if(s==="cursor"){const m=(c=F.current)==null?void 0:c.querySelector(".query-editor__textarea"),A=(m==null?void 0:m.selectionStart)??x.current,Q=_e(h,A);Q&&u.executeQuery(a.id,b,p,Q)}else{const m=pe(h);if(m.length<=1)u.executeQuery(a.id,b,p,h.trim());else{const A=b,Q=p;(async()=>{for(const M of m)await u.executeQueryAndWait(a.id,A,Q,M.sql)})()}}},[a.id,b,p,h,R]),re=l.useCallback(s=>{z(s),r("results")},[]),le=l.useCallback(s=>{u.setActiveConnection(a.id,s),u.listDatabases(a.id,s)},[a.id]),ce=l.useCallback(s=>{b&&(V(b,s),u.listTables(a.id,b,s))},[a.id,b,V]),B=_[i];return f.length===0?e.jsxs("div",{className:"database-panel",ref:F,children:[e.jsxs("div",{className:"database-panel__header",children:[e.jsxs("div",{className:"database-panel__title",children:[e.jsx("span",{className:"database-panel__icon",children:e.jsx(L,{name:"database",size:16})}),e.jsx("span",{className:"database-panel__name",children:a.name})]}),e.jsx("button",{className:"database-panel__close",onClick:j,children:"×"})]}),e.jsx("div",{className:"database-panel__body",children:e.jsxs("div",{className:"database-panel__no-connections",children:[e.jsx("div",{className:"database-panel__no-connections-icon",children:e.jsx(L,{name:"plug",size:32})}),e.jsx("h3",{children:n("terminal:database.noConnections")}),e.jsx("p",{children:n("terminal:database.noConnectionsDesc")}),e.jsx("p",{children:n("terminal:database.toGetStarted")}),e.jsxs("ol",{children:[e.jsx("li",{children:n("terminal:database.step1Close")}),e.jsx("li",{children:n("terminal:database.step2Settings")}),e.jsx("li",{children:n("terminal:database.step3AddConnection")}),e.jsx("li",{children:n("terminal:database.step4Reopen")})]})]})})]}):e.jsxs("div",{className:"database-panel",ref:F,children:[e.jsxs("div",{className:"database-panel__header",children:[e.jsxs("div",{className:"database-panel__title",children:[e.jsx("span",{className:"database-panel__icon",children:(t==null?void 0:t.engine)==="mysql"?"🐬":"🐘"}),e.jsx("span",{className:"database-panel__name",children:a.name}),t&&e.jsxs("span",{className:"database-panel__connection-info",children:[t.name," / ",p||n("terminal:database.noDatabaseSelected")]})]}),e.jsxs("div",{className:"database-panel__header-actions",children:[d&&e.jsx("button",{className:"database-panel__close",onClick:d,title:"Minimize — dock below the terminal input",children:e.jsx(L,{name:"arrow-down",size:14})}),e.jsx("button",{className:"database-panel__close",onClick:j,children:"×"})]})]}),e.jsxs("div",{className:"database-panel__body",children:[e.jsx(je,{building:a,connections:f,activeConnectionId:b,activeDatabase:p,collapsed:w,onToggleCollapse:()=>O(!w),onConnectionChange:le,onDatabaseChange:ce,onInsertTable:s=>z(c=>c+` ${s}`),onSelectTableQuery:s=>{const c=`SELECT * FROM ${s}`;z(c),b&&p&&u.executeQuery(a.id,b,p,c)}}),e.jsxs("div",{className:"database-panel__main",children:[H.length>0&&e.jsx(Ne,{tabs:H,activeTabId:C,onTabClick:te,onTabClose:se}),e.jsx(xe,{query:h,onChange:z,onExecute:ne,isExecuting:R,disabled:!b||!p,tables:v,tableSchemas:S,onRequestTableSchema:s=>{b&&p&&u.getTableSchema(a.id,b,p,s)}}),e.jsxs("div",{className:"database-panel__tabs",children:[e.jsxs("button",{className:`database-panel__tab ${T==="results"?"database-panel__tab--active":""}`,onClick:()=>r("results"),children:[n("terminal:database.results"),_.length>0&&e.jsx("span",{className:"database-panel__tab-badge",children:_.length})]}),e.jsxs("button",{className:`database-panel__tab ${T==="history"?"database-panel__tab--active":""}`,onClick:()=>r("history"),children:[n("terminal:database.history"),D.length>0&&e.jsx("span",{className:"database-panel__tab-badge",children:D.length})]}),T==="results"&&_.length>1&&e.jsxs("div",{className:"database-panel__result-nav",children:[e.jsxs("button",{disabled:i>=_.length-1,onClick:()=>g(s=>s+1),children:["← ",n("terminal:database.older")]}),e.jsxs("span",{children:[i+1," / ",_.length]}),e.jsxs("button",{disabled:i<=0,onClick:()=>g(s=>s-1),children:[n("terminal:database.newer")," →"]})]})]}),e.jsx("div",{className:"database-panel__tab-content",children:T==="results"?B?e.jsx(fe,{result:B,buildingId:a.id,building:a}):e.jsxs("div",{className:"database-panel__empty",children:[e.jsx("p",{children:n("terminal:database.noResultsYet")}),e.jsx("p",{children:n("terminal:database.selectDbAndRun")})]}):e.jsx(ye,{buildingId:a.id,history:D,onLoadQuery:re})})]})]})]})};export{we as DatabasePanel,je as DatabaseSidebar,Ne as DatabaseTabs,xe as QueryEditor,ye as QueryHistoryPanel,fe as ResultsTable};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as At,k as yt,aC as Et,a5 as xt,m as Ct,cB as Mt,cC as Ft,aU as wt,r as d,$ as St,S as pe,cD as Bt,cE as fe,s as V,cF as vt,j as f,I as ne,cG as Ve,cH as It,a9 as _t,cI as Dt,cJ as kt,cK as Ee,aq as ve,_ as Rt,v as nt,u as Fe,cL as Je}from"./main-FwlHcqGj.js";import{cM as Ls,cN as $s,cO as js,cP as Ns,cQ as Ps}from"./main-FwlHcqGj.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function re(t){return Array.isArray?Array.isArray(t):ct(t)==="[object Array]"}function bt(t){if(typeof t=="string")return t;let e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function Tt(t){return t==null?"":bt(t)}function Z(t){return typeof t=="string"}function rt(t){return typeof t=="number"}function Lt(t){return t===!0||t===!1||$t(t)&&ct(t)=="[object Boolean]"}function it(t){return typeof t=="object"}function $t(t){return it(t)&&t!==null}function G(t){return t!=null}function Ie(t){return!t.trim().length}function ct(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const jt="Incorrect 'index' type",Nt=t=>`Invalid value for key ${t}`,Pt=t=>`Pattern length exceeds max of ${t}.`,Kt=t=>`Missing ${t} property in key`,Ot=t=>`Property 'weight' in key '${t}' must be a positive integer`,Xe=Object.prototype.hasOwnProperty;class zt{constructor(e){this._keys=[],this._keyMap={};let n=0;e.forEach(r=>{let i=ot(r);this._keys.push(i),this._keyMap[i.id]=i,n+=i.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 ot(t){let e=null,n=null,r=null,i=1,c=null;if(Z(t)||re(t))r=t,e=qe(t),n=_e(t);else{if(!Xe.call(t,"name"))throw new Error(Kt("name"));const o=t.name;if(r=o,Xe.call(t,"weight")&&(i=t.weight,i<=0))throw new Error(Ot(o));e=qe(o),n=_e(o),c=t.getFn}return{path:e,id:n,weight:i,src:r,getFn:c}}function qe(t){return re(t)?t:t.split(".")}function _e(t){return re(t)?t.join("."):t}function Gt(t,e){let n=[],r=!1;const i=(c,o,a)=>{if(G(c))if(!o[a])n.push(c);else{let u=o[a];const l=c[u];if(!G(l))return;if(a===o.length-1&&(Z(l)||rt(l)||Lt(l)))n.push(Tt(l));else if(re(l)){r=!0;for(let h=0,E=l.length;h<E;h+=1)i(l[h],o,a+1)}else o.length&&i(l,o,a+1)}};return i(t,Z(e)?e.split("."):e,0),r?n:n[0]}const Qt={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Wt={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},Ht={location:0,threshold:.6,distance:100},Ut={useExtendedSearch:!1,getFn:Gt,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var y={...Wt,...Qt,...Ht,...Ut};const Yt=/[^ ]+/g;function Vt(t=1,e=3){const n=new Map,r=Math.pow(10,e);return{get(i){const c=i.match(Yt).length;if(n.has(c))return n.get(c);const o=1/Math.pow(c,.5*t),a=parseFloat(Math.round(o*r)/r);return n.set(c,a),a},clear(){n.clear()}}}class Le{constructor({getFn:e=y.getFn,fieldNormWeight:n=y.fieldNormWeight}={}){this.norm=Vt(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,Z(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();Z(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(!G(e)||Ie(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((i,c)=>{let o=i.getFn?i.getFn(e):this.getFn(e,i.path);if(G(o)){if(re(o)){let a=[];const u=[{nestedArrIndex:-1,value:o}];for(;u.length;){const{nestedArrIndex:l,value:h}=u.pop();if(G(h))if(Z(h)&&!Ie(h)){let E={v:h,i:l,n:this.norm.get(h)};a.push(E)}else re(h)&&h.forEach((E,C)=>{u.push({nestedArrIndex:C,value:E})})}r.$[c]=a}else if(Z(o)&&!Ie(o)){let a={v:o,n:this.norm.get(o)};r.$[c]=a}}}),this.records.push(r)}toJSON(){return{keys:this.keys,records:this.records}}}function at(t,e,{getFn:n=y.getFn,fieldNormWeight:r=y.fieldNormWeight}={}){const i=new Le({getFn:n,fieldNormWeight:r});return i.setKeys(t.map(ot)),i.setSources(e),i.create(),i}function Jt(t,{getFn:e=y.getFn,fieldNormWeight:n=y.fieldNormWeight}={}){const{keys:r,records:i}=t,c=new Le({getFn:e,fieldNormWeight:n});return c.setKeys(r),c.setIndexRecords(i),c}function xe(t,{errors:e=0,currentLocation:n=0,expectedLocation:r=0,distance:i=y.distance,ignoreLocation:c=y.ignoreLocation}={}){const o=e/t.length;if(c)return o;const a=Math.abs(r-n);return i?o+a/i:a?1:o}function Xt(t=[],e=y.minMatchCharLength){let n=[],r=-1,i=-1,c=0;for(let o=t.length;c<o;c+=1){let a=t[c];a&&r===-1?r=c:!a&&r!==-1&&(i=c-1,i-r+1>=e&&n.push([r,i]),r=-1)}return t[c-1]&&c-r>=e&&n.push([r,c-1]),n}const le=32;function qt(t,e,n,{location:r=y.location,distance:i=y.distance,threshold:c=y.threshold,findAllMatches:o=y.findAllMatches,minMatchCharLength:a=y.minMatchCharLength,includeMatches:u=y.includeMatches,ignoreLocation:l=y.ignoreLocation}={}){if(e.length>le)throw new Error(Pt(le));const h=e.length,E=t.length,C=Math.max(0,Math.min(r,E));let g=c,p=C;const S=a>1||u,w=S?Array(E):[];let T;for(;(T=t.indexOf(e,p))>-1;){let $=xe(e,{currentLocation:T,expectedLocation:C,distance:i,ignoreLocation:l});if(g=Math.min($,g),p=T+h,S){let N=0;for(;N<h;)w[T+N]=1,N+=1}}p=-1;let j=[],Q=1,W=h+E;const oe=1<<h-1;for(let $=0;$<h;$+=1){let N=0,D=W;for(;N<D;)xe(e,{errors:$,currentLocation:C+D,expectedLocation:C,distance:i,ignoreLocation:l})<=g?N=D:W=D,D=Math.floor((W-N)/2+N);W=D;let ae=Math.max(1,C-D+1),H=o?E:Math.min(C+D,E)+h,B=Array(H+2);B[H+1]=(1<<$)-1;for(let R=H;R>=ae;R-=1){let X=R-1,O=n[t.charAt(X)];if(S&&(w[X]=+!!O),B[R]=(B[R+1]<<1|1)&O,$&&(B[R]|=(j[R+1]|j[R])<<1|1|j[R+1]),B[R]&oe&&(Q=xe(e,{errors:$,currentLocation:X,expectedLocation:C,distance:i,ignoreLocation:l}),Q<=g)){if(g=Q,p=X,p<=C)break;ae=Math.max(1,2*C-p)}}if(xe(e,{errors:$+1,currentLocation:C,expectedLocation:C,distance:i,ignoreLocation:l})>g)break;j=B}const ie={isMatch:p>=0,score:Math.max(.001,Q)};if(S){const $=Xt(w,a);$.length?u&&(ie.indices=$):ie.isMatch=!1}return ie}function Zt(t){let e={};for(let n=0,r=t.length;n<r;n+=1){const i=t.charAt(n);e[i]=(e[i]||0)|1<<r-n-1}return e}const Ce=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 ut{constructor(e,{location:n=y.location,threshold:r=y.threshold,distance:i=y.distance,includeMatches:c=y.includeMatches,findAllMatches:o=y.findAllMatches,minMatchCharLength:a=y.minMatchCharLength,isCaseSensitive:u=y.isCaseSensitive,ignoreDiacritics:l=y.ignoreDiacritics,ignoreLocation:h=y.ignoreLocation}={}){if(this.options={location:n,threshold:r,distance:i,includeMatches:c,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:h},e=u?e:e.toLowerCase(),e=l?Ce(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const E=(g,p)=>{this.chunks.push({pattern:g,alphabet:Zt(g),startIndex:p})},C=this.pattern.length;if(C>le){let g=0;const p=C%le,S=C-p;for(;g<S;)E(this.pattern.substr(g,le),g),g+=le;if(p){const w=C-le;E(this.pattern.substr(w),w)}}else E(this.pattern,0)}searchIn(e){const{isCaseSensitive:n,ignoreDiacritics:r,includeMatches:i}=this.options;if(e=n?e:e.toLowerCase(),e=r?Ce(e):e,this.pattern===e){let S={isMatch:!0,score:0};return i&&(S.indices=[[0,e.length-1]]),S}const{location:c,distance:o,threshold:a,findAllMatches:u,minMatchCharLength:l,ignoreLocation:h}=this.options;let E=[],C=0,g=!1;this.chunks.forEach(({pattern:S,alphabet:w,startIndex:T})=>{const{isMatch:j,score:Q,indices:W}=qt(e,S,w,{location:c+T,distance:o,threshold:a,findAllMatches:u,minMatchCharLength:l,includeMatches:i,ignoreLocation:h});j&&(g=!0),C+=Q,j&&W&&(E=[...E,...W])});let p={isMatch:g,score:g?C/this.chunks.length:1};return g&&i&&(p.indices=E),p}}class ce{constructor(e){this.pattern=e}static isMultiMatch(e){return Ze(e,this.multiRegex)}static isSingleMatch(e){return Ze(e,this.singleRegex)}search(){}}function Ze(t,e){const n=t.match(e);return n?n[1]:null}class es extends ce{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 ts extends ce{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 ss extends ce{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 ns extends ce{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 rs extends ce{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 is extends ce{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 lt extends ce{constructor(e,{location:n=y.location,threshold:r=y.threshold,distance:i=y.distance,includeMatches:c=y.includeMatches,findAllMatches:o=y.findAllMatches,minMatchCharLength:a=y.minMatchCharLength,isCaseSensitive:u=y.isCaseSensitive,ignoreDiacritics:l=y.ignoreDiacritics,ignoreLocation:h=y.ignoreLocation}={}){super(e),this._bitapSearch=new ut(e,{location:n,threshold:r,distance:i,includeMatches:c,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:h})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class ht extends ce{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let n=0,r;const i=[],c=this.pattern.length;for(;(r=e.indexOf(this.pattern,n))>-1;)n=r+c,i.push([r,n-1]);const o=!!i.length;return{isMatch:o,score:o?0:1,indices:i}}}const De=[es,ht,ss,ns,is,rs,ts,lt],et=De.length,cs=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,os="|";function as(t,e={}){return t.split(os).map(n=>{let r=n.trim().split(cs).filter(c=>c&&!!c.trim()),i=[];for(let c=0,o=r.length;c<o;c+=1){const a=r[c];let u=!1,l=-1;for(;!u&&++l<et;){const h=De[l];let E=h.isMultiMatch(a);E&&(i.push(new h(E,e)),u=!0)}if(!u)for(l=-1;++l<et;){const h=De[l];let E=h.isSingleMatch(a);if(E){i.push(new h(E,e));break}}}return i})}const us=new Set([lt.type,ht.type]);class ls{constructor(e,{isCaseSensitive:n=y.isCaseSensitive,ignoreDiacritics:r=y.ignoreDiacritics,includeMatches:i=y.includeMatches,minMatchCharLength:c=y.minMatchCharLength,ignoreLocation:o=y.ignoreLocation,findAllMatches:a=y.findAllMatches,location:u=y.location,threshold:l=y.threshold,distance:h=y.distance}={}){this.query=null,this.options={isCaseSensitive:n,ignoreDiacritics:r,includeMatches:i,minMatchCharLength:c,findAllMatches:a,ignoreLocation:o,location:u,threshold:l,distance:h},e=n?e:e.toLowerCase(),e=r?Ce(e):e,this.pattern=e,this.query=as(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:i,ignoreDiacritics:c}=this.options;e=i?e:e.toLowerCase(),e=c?Ce(e):e;let o=0,a=[],u=0;for(let l=0,h=n.length;l<h;l+=1){const E=n[l];a.length=0,o=0;for(let C=0,g=E.length;C<g;C+=1){const p=E[C],{isMatch:S,indices:w,score:T}=p.search(e);if(S){if(o+=1,u+=T,r){const j=p.constructor.type;us.has(j)?a=[...a,...w]:a.push(w)}}else{u=0,o=0,a.length=0;break}}if(o){let C={isMatch:!0,score:u/o};return r&&(C.indices=a),C}}return{isMatch:!1,score:1}}}const ke=[];function hs(...t){ke.push(...t)}function Re(t,e){for(let n=0,r=ke.length;n<r;n+=1){let i=ke[n];if(i.condition(t,e))return new i(t,e)}return new ut(t,e)}const Me={AND:"$and",OR:"$or"},be={PATH:"$path",PATTERN:"$val"},Te=t=>!!(t[Me.AND]||t[Me.OR]),ds=t=>!!t[be.PATH],fs=t=>!re(t)&&it(t)&&!Te(t),tt=t=>({[Me.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function dt(t,e,{auto:n=!0}={}){const r=i=>{let c=Object.keys(i);const o=ds(i);if(!o&&c.length>1&&!Te(i))return r(tt(i));if(fs(i)){const u=o?i[be.PATH]:c[0],l=o?i[be.PATTERN]:i[u];if(!Z(l))throw new Error(Nt(u));const h={keyId:_e(u),pattern:l};return n&&(h.searcher=Re(l,e)),h}let a={children:[],operator:c[0]};return c.forEach(u=>{const l=i[u];re(l)&&l.forEach(h=>{a.children.push(r(h))})}),a};return Te(t)||(t=tt(t)),r(t)}function gs(t,{ignoreFieldNorm:e=y.ignoreFieldNorm}){t.forEach(n=>{let r=1;n.matches.forEach(({key:i,norm:c,score:o})=>{const a=i?i.weight:null;r*=Math.pow(o===0&&a?Number.EPSILON:o,(a||1)*(e?1:c))}),n.score=r})}function ps(t,e){const n=t.matches;e.matches=[],G(n)&&n.forEach(r=>{if(!G(r.indices)||!r.indices.length)return;const{indices:i,value:c}=r;let o={indices:i,value:c};r.key&&(o.key=r.key.src),r.idx>-1&&(o.refIndex=r.idx),e.matches.push(o)})}function ms(t,e){e.score=t.score}function As(t,e,{includeMatches:n=y.includeMatches,includeScore:r=y.includeScore}={}){const i=[];return n&&i.push(ps),r&&i.push(ms),t.map(c=>{const{idx:o}=c,a={item:e[o],refIndex:o};return i.length&&i.forEach(u=>{u(c,a)}),a})}class q{constructor(e,n={},r){this.options={...y,...n},this.options.useExtendedSearch,this._keyStore=new zt(this.options.keys),this.setCollection(e,r)}setCollection(e,n){if(this._docs=e,n&&!(n instanceof Le))throw new Error(jt);this._myIndex=n||at(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){G(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const n=[];for(let r=0,i=this._docs.length;r<i;r+=1){const c=this._docs[r];e(c,r)&&(this.removeAt(r),r-=1,i-=1,n.push(c))}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:i,shouldSort:c,sortFn:o,ignoreFieldNorm:a}=this.options;let u=Z(e)?Z(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return gs(u,{ignoreFieldNorm:a}),c&&u.sort(o),rt(n)&&n>-1&&(u=u.slice(0,n)),As(u,this._docs,{includeMatches:r,includeScore:i})}_searchStringList(e){const n=Re(e,this.options),{records:r}=this._myIndex,i=[];return r.forEach(({v:c,i:o,n:a})=>{if(!G(c))return;const{isMatch:u,score:l,indices:h}=n.searchIn(c);u&&i.push({item:c,idx:o,matches:[{score:l,value:c,norm:a,indices:h}]})}),i}_searchLogical(e){const n=dt(e,this.options),r=(a,u,l)=>{if(!a.children){const{keyId:E,searcher:C}=a,g=this._findMatches({key:this._keyStore.get(E),value:this._myIndex.getValueForItemAtKeyId(u,E),searcher:C});return g&&g.length?[{idx:l,item:u,matches:g}]:[]}const h=[];for(let E=0,C=a.children.length;E<C;E+=1){const g=a.children[E],p=r(g,u,l);if(p.length)h.push(...p);else if(a.operator===Me.AND)return[]}return h},i=this._myIndex.records,c={},o=[];return i.forEach(({$:a,i:u})=>{if(G(a)){let l=r(n,a,u);l.length&&(c[u]||(c[u]={idx:u,item:a,matches:[]},o.push(c[u])),l.forEach(({matches:h})=>{c[u].matches.push(...h)}))}}),o}_searchObjectList(e){const n=Re(e,this.options),{keys:r,records:i}=this._myIndex,c=[];return i.forEach(({$:o,i:a})=>{if(!G(o))return;let u=[];r.forEach((l,h)=>{u.push(...this._findMatches({key:l,value:o[h],searcher:n}))}),u.length&&c.push({idx:a,item:o,matches:u})}),c}_findMatches({key:e,value:n,searcher:r}){if(!G(n))return[];let i=[];if(re(n))n.forEach(({v:c,i:o,n:a})=>{if(!G(c))return;const{isMatch:u,score:l,indices:h}=r.searchIn(c);u&&i.push({score:l,key:e,value:c,idx:o,norm:a,indices:h})});else{const{v:c,n:o}=n,{isMatch:a,score:u,indices:l}=r.searchIn(c);a&&i.push({score:u,key:e,value:c,norm:o,indices:l})}return i}}q.version="7.1.0";q.createIndex=at;q.parseIndex=Jt;q.config=y;q.parseQuery=dt;hs(ls);async function ys(t){const e=new URLSearchParams({q:t}),n=await At(yt(`/api/folders/search?${e.toString()}`));if(!n.ok){const i=await n.json().catch(()=>({}));throw new Error(i.error||`Failed to search folders: ${n.statusText}`)}const r=await n.json();return Array.isArray(r.folders)?r.folders:[]}const Es=["command","agent","building","area","folder","modified-file"],xs=2;function Cs(){const t=nt(pe.SPOTLIGHT_TAB,"all");return fe.includes(t)?t:"all"}function st(){return Rt(pe.SPOTLIGHT_QUERY,"")}function Ms(){const t=nt(pe.AOP_CONFIG,{});return t.sortMode==="name"||t.sortMode==="status"||t.sortMode==="recent"?t.sortMode:"recent"}function Fs({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:i,onOpenFileExplorer:c,onOpenPM2LogsModal:o,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l}){const h=Et(),E=xt(),C=Ct(),g=Mt(),p=Ft(),S=wt(),w=d.useRef(e);w.current=e;const T=d.useRef(n);T.current=n;const j=d.useRef(r);j.current=r;const Q=d.useRef(i);Q.current=i;const W=d.useRef(c);W.current=c;const oe=d.useRef(o);oe.current=o;const ie=d.useRef(a);ie.current=a;const $=d.useRef(u);$.current=u;const N=d.useRef(l);N.current=l;const[D,ae]=d.useState(st),[H,B]=d.useState(0),[M,R]=d.useState(Cs),[X,O]=d.useState([]),ft=d.useCallback(s=>{ae(s),St(pe.SPOTLIGHT_QUERY,s)},[]);d.useEffect(()=>{t&&(ae(st()),B(0))},[t]),d.useEffect(()=>{if(!t){O([]);return}const s=D.trim();if(s.length<xs){O([]);return}let m=!1;const F=setTimeout(()=>{ys(s).then(x=>{m||O(x)}).catch(()=>{m||O([])})},250);return()=>{m=!0,clearTimeout(F)}},[t,D]);const we=d.useCallback(s=>{R(s),Bt(pe.SPOTLIGHT_TAB,s)},[]),$e=d.useRef(M);$e.current=M;const gt=d.useCallback(s=>{const m=fe.indexOf($e.current),F=fe[(m+s+fe.length)%fe.length];we(F)},[we]);d.useEffect(()=>{B(0)},[M]);const Se=V.getShortcuts(),ge=d.useMemo(()=>t?vt():{},[t]),me=d.useMemo(()=>{if(!t)return[];const s=window.matchMedia("(pointer: coarse)").matches,m=Se.find(x=>x.id==="spawn-agent"),F=Se.find(x=>x.id==="toggle-commander");return[{id:"cmd-spawn",type:"command",title:"Spawn New Agent",subtitle:s?"":m?Ve(m):"Alt+N",icon:f.jsx(ne,{name:"plus",size:16}),action:()=>{w.current(),T.current()}},{id:"cmd-commander",type:"command",title:"Commander View",subtitle:s?"":F!=null&&F.key?Ve(F):"Tab",icon:f.jsx(ne,{name:"dashboard",size:16}),action:()=>{w.current(),j.current()}},{id:"cmd-settings",type:"command",title:"Settings & Tools",subtitle:"Configure Tide Commander",icon:f.jsx(ne,{name:"gear",size:16}),action:()=>{w.current(),Q.current()}},{id:"cmd-monitoring",type:"command",title:"Monitoring & Logs",subtitle:"Triggers, workflows, events",icon:f.jsx(ne,{name:"chart-line",size:16}),action:()=>{var x;w.current(),(x=N.current)==null||x.call(N)}}]},[t,Se]),he=d.useMemo(()=>t?Array.from(h.values()).map(s=>{const m=(g||[]).filter(Y=>Y.agentId===s.id).map(Y=>Y.filePath),F=[...new Set(m)],x=F.map(Y=>Y.split("/").pop()||Y),v=[];s.lastAssignedTask&&v.push(s.lastAssignedTask);const L=`${s.class} • ${s.cwd}`;let k=`${s.name} ${s.class} ${s.status} ${s.cwd}`;s.taskLabel&&(k+=` ${s.taskLabel}`),x.length>0&&(k+=` ${x.join(" ")} ${F.join(" ")}`),v.length>0&&(k+=` ${v.join(" ")}`);const P=Date.now()-s.lastActivity;let U;return s.lastAssignedTask&&(s.lastAssignedTask.length>150?U=s.lastAssignedTask.slice(0,150)+"...":U=s.lastAssignedTask),{id:`agent-${s.id}`,type:"agent",title:s.name,subtitle:L,lastUserInput:U,timeAway:P,icon:f.jsx(_t,{agent:s,size:20}),_searchText:k,_modifiedFiles:F,_userQueries:v,_agentId:s.id,_lastActivity:s.lastActivity,_taskLabel:s.taskLabel,_status:s.status,action:()=>{w.current(),It(s.id),V.selectAgent(s.id),V.getState().viewMode!=="flat"&&V.requestTerminalExpand()}}}):[],[t,h,g]),Ae=d.useMemo(()=>t?Array.from(E.values()).map(s=>{var m;return{id:`area-${s.id}`,type:"area",title:s.name,subtitle:`${s.assignedAgentIds.length} agents • ${((m=s.directories)==null?void 0:m.length)||0} folders`,icon:f.jsx(ne,{name:"map",size:16}),action:()=>{w.current(),V.selectArea(s.id)}}}):[],[t,E]),je=d.useMemo(()=>{const s=new Map;for(const m of he)m._agentId&&s.set(m._agentId,m);return s},[he]),Ne=d.useMemo(()=>{const s=new Map;if(!t)return s;for(const m of h.values()){const F=V.getAreaForAgent(m.id);if(!F||F.archived)continue;const x=s.get(F.id);x?x.push(m):s.set(F.id,[m])}return s},[t,h,E]),Pe=d.useMemo(()=>{const s=new Map;for(const m of p)s.has(m.agentId)||s.set(m.agentId,m.timestamp);return s},[p]),Be=d.useMemo(()=>{if(!t)return[];const s=D.trim().toLowerCase(),m=Dt({sortMode:Ms(),agentsWithUnseenOutput:S,getLatestToolTimestamp:v=>Pe.get(v)}),F=Array.from(E.values()).filter(v=>!v.archived).filter(v=>s?v.name.toLowerCase().includes(s):!0).sort((v,L)=>v.name.localeCompare(L.name,void 0,{sensitivity:"base"})),x=[];for(const v of F){const k=(Ne.get(v.id)||[]).slice().sort(m).map(P=>je.get(P.id)).filter(P=>!!P);!s&&k.length===0||x.push({areaId:v.id,areaName:v.name,areaColor:v.color,agents:k})}return x},[t,D,E,Ne,je,S,Pe]),ye=d.useMemo(()=>t?Array.from(C.values()).filter(s=>s.type==="server"||s.type==="boss"||s.type==="database"||s.type==="tests").map(s=>{var P,U,Y,ue,ee;const m=s.status==="running"?"#4ade80":s.status==="stopped"?"#f87171":"#facc15",F=s.type==="boss"?"crown":s.type==="database"?"database":s.type==="tests"?"flask":"desktop",x=s.type==="boss"?"Boss":s.type==="database"?"Database":s.type==="tests"?"Tests":"Server";let v=`${x} • ${s.status}`;if(s.type==="database"&&((U=(P=s.database)==null?void 0:P.connections)!=null&&U.length)){const z=s.database.connections[0];v+=` • ${z.engine} @ ${z.host}`}else s.type==="tests"&&s.folderPath?v=`${x} • ${s.folderPath}`:s.cwd&&(v+=` • ${s.cwd}`);const L=((Y=s.pm2Status)==null?void 0:Y.ports)||[];let k=`${s.name} ${s.type} ${s.status} ${s.cwd||""} ${((ue=s.pm2)==null?void 0:ue.name)||""}`;if(s.type==="tests"&&(k+=` ${s.folderPath||""} tests junit maven`),L.length>0&&(k+=` ${L.join(" ")}`),s.type==="database"&&((ee=s.database)!=null&&ee.connections))for(const z of s.database.connections)k+=` ${z.name} ${z.engine} ${z.host} ${z.database||""} mysql postgresql sql`;return{id:`building-${s.id}`,type:"building",title:s.name,subtitle:v,_ports:L,icon:f.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[f.jsx(ne,{name:"status-pending",size:10,weight:"fill",color:m}),f.jsx(ne,{name:F,size:16})]}),_searchText:k,action:()=>{var z;w.current(),s.type==="boss"?ie.current(s.id):s.type==="database"?$.current(s.id):s.type==="tests"?V.openTestsBuilding(s.id):s.type==="http"?V.openHttpBuilding(s.id):(z=s.pm2)!=null&&z.enabled&&oe.current(s.id)}}}):[],[t,C]),Ke=d.useMemo(()=>{if(!t)return[];const s=g||[],m=new Set,F=[];for(const x of s){if(m.has(x.filePath))continue;m.add(x.filePath);const v=x.filePath.split("/").pop()||x.filePath,L=x.action==="created"?"Created":x.action==="modified"?"Modified":x.action==="deleted"?"Deleted":"Read";if(F.push({id:`modified-${x.filePath}-${x.timestamp}`,type:"modified-file",title:v,subtitle:`${L} by ${x.agentName} • ${x.filePath}`,matchedText:x.filePath,icon:x.action==="deleted"?f.jsx(ne,{name:"trash",size:16}):kt(x.filePath),action:()=>{w.current();const k=Array.from(V.getState().areas.values());for(const P of k)for(const U of P.directories||[])if(x.filePath.startsWith(U)){V.setFileViewerPath(x.filePath),W.current(P.id);return}V.selectAgent(x.agentId)}}),F.length>=50)break}return F},[t,g]),Oe=d.useMemo(()=>t?X.map(s=>{const m=s.isGitRepo&&s.gitBranch?`${s.path} • ${s.gitBranch}`:s.path;return{id:`folder-${s.path}`,type:"folder",title:s.name,subtitle:m,matchedText:s.path,icon:f.jsx(ne,{name:s.isGitRepo?"git-branch":"folder",size:16}),_searchText:`${s.name} ${s.path}`,_isGitRepo:s.isGitRepo,_gitBranch:s.gitBranch,action:()=>{w.current(),V.openFileExplorer(s.path)}}}):[],[t,X]),ze=d.useMemo(()=>new q(he,{keys:["title","subtitle","_searchText","lastUserInput"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[he]),Ge=d.useMemo(()=>new q(me,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[me]),Qe=d.useMemo(()=>new q(Ae,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[Ae]),We=d.useMemo(()=>new q(Ke,{keys:["title","subtitle","matchedText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[Ke]),He=d.useMemo(()=>new q(ye,{keys:["title","subtitle","_searchText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[ye]),de=d.useMemo(()=>{if(!D.trim()){const A=[];A.push(...ye);const I=[...he].sort((b,K)=>{const te=Ee(b._agentId,b._lastActivity,ge);return Ee(K._agentId,K._lastActivity,ge)-te});A.push(...I),A.push(...me.slice(0,2)),A.push(...Ae.slice(0,2));const _={};return Es.forEach((b,K)=>{_[b]=K}),A.sort((b,K)=>(_[b.type]??999)-(_[K.type]??999)),A}const s=D.trim().toLowerCase(),m=ze.search(D).slice(0,8),F=Ge.search(D).slice(0,3),x=Qe.search(D).slice(0,2),v=We.search(D).slice(0,3),L=Oe.slice(0,8),k=He.search(D).filter(A=>{const I=A.score??1;return`${A.item.title} ${A.item.subtitle||""} ${A.item._searchText||""}`.toLowerCase().includes(s)||I<=.2}).slice(0,4),P={agent:6,building:5,folder:4,command:3,area:2,"modified-file":1},U=A=>{if(!s)return 1;const I=A.title.toLowerCase();return I===s?6:I.startsWith(s)?5:I.split(/[^a-z0-9]+/i).includes(s)?4:I.includes(s)?3:`${A.subtitle||""} ${A._searchText||""} ${A.matchedText||""}`.toLowerCase().includes(s)?2:1},Y=(A,I)=>{const _=(1-Math.min(1,I??1))*4;return U(A)*100+(P[A.type]??0)*5+_},ue=new Map,ee=(A,I)=>{const _=ue.get(A.type),b={item:A,score:Y(A,I)};_?_.push(b):ue.set(A.type,[b])};for(const A of m){const I={...A.item};if(I._modifiedFiles&&I._modifiedFiles.length>0){const _=I._modifiedFiles.filter(b=>{var se;const K=((se=b.split("/").pop())==null?void 0:se.toLowerCase())||"",te=b.toLowerCase();return K.includes(s)||te.includes(s)});_.length>0&&(I.matchedFiles=_)}if(I._userQueries&&I._userQueries.length>0){const _=I._userQueries.find(b=>b.toLowerCase().includes(s));if(_)if(_.length>200){const K=_.toLowerCase().indexOf(s),te=Math.max(0,K-60),se=Math.min(_.length,K+s.length+100);I.matchedQuery=(te>0?"...":"")+_.slice(te,se)+(se<_.length?"...":"")}else I.matchedQuery=_}ee(I,A.score)}for(const A of k)ee(A.item,A.score);for(const A of F)ee(A.item,A.score);for(const A of x)ee(A.item,A.score);for(const A of v)ee(A.item,A.score);for(const A of L)ee(A,void 0);for(const[A,I]of ue)A==="agent"?I.sort((_,b)=>{const K=U(_.item),te=U(b.item);if(te!==K)return te-K;const se=Ee(_.item._agentId,_.item._lastActivity,ge),Ye=Ee(b.item._agentId,b.item._lastActivity,ge);return Ye!==se?Ye-se:b.score-_.score}):I.sort((_,b)=>b.score-_.score);const z=A=>A.reduce((I,_)=>Math.max(I,_.score),-1),Ue=[];return Array.from(ue.values()).sort((A,I)=>z(I)-z(A)).forEach(A=>{for(const I of A)Ue.push(I.item)}),Ue},[D,ze,Ge,Qe,We,He,me,he,Ae,ye,Oe,ge]),J=d.useMemo(()=>{switch(M){case"agents":return de.filter(s=>s.type==="agent");case"buildings":return de.filter(s=>s.type==="building");case"commands":return de.filter(s=>s.type==="command");case"folders":return de.filter(s=>s.type==="folder");case"areas":return Be.flatMap(s=>s.agents);case"all":default:return de}},[M,de,Be]);d.useEffect(()=>{H>=J.length&&B(Math.max(0,J.length-1))},[J.length,H]);const pt=d.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 m=s.key.toLowerCase();B(m==="p"?F=>F>0?F-1:J.length-1:F=>F<J.length-1?F+1:0);return}switch(s.key){case"Escape":s.preventDefault(),w.current();break;case"ArrowUp":s.preventDefault(),B(m=>m>0?m-1:J.length-1);break;case"ArrowDown":s.preventDefault(),B(m=>m<J.length-1?m+1:0);break;case"Enter":s.preventDefault(),J[H]&&J[H].action();break}},[J,H]),mt=d.useCallback((s,m)=>{if(!m||!s)return s;const F=s.toLowerCase(),x=m.toLowerCase(),v=[];let L=0,k=F.indexOf(x),P=0;for(;k!==-1;)k>L&&v.push(s.slice(L,k)),v.push(ve.createElement("mark",{key:P++,className:"spotlight-highlight"},s.slice(k,k+m.length))),L=k+m.length,k=F.indexOf(x,L);return L<s.length&&v.push(s.slice(L)),v.length>0?ve.createElement(ve.Fragment,null,...v):s},[]);return{query:D,setQuery:ft,selectedIndex:H,setSelectedIndex:B,results:J,activeTab:M,setActiveTab:we,cycleTab:gt,areaSections:Be,handleKeyDown:pt,highlightMatch:mt}}const ws=d.forwardRef(function({query:e,onQueryChange:n,onKeyDown:r,onResetSelection:i},c){const{t:o}=Fe(["common"]);return f.jsxs("div",{className:"spotlight-input-wrapper",children:[f.jsx("span",{className:"spotlight-search-icon",children:"⌘"}),f.jsx("input",{ref:c,type:"text",className:"spotlight-input",placeholder:o("common:search.spotlightPlaceholder"),value:e,onChange:a=>{n(a.target.value),i()},onKeyDown:r,autoFocus:!0,spellCheck:!1}),f.jsxs("div",{className:"spotlight-input-hints",children:[f.jsx("span",{className:"spotlight-shortcut-hint",children:"↑↓"}),f.jsx("span",{className:"spotlight-shortcut-hint",children:"Enter"}),f.jsx("span",{className:"spotlight-shortcut-hint",children:"Esc"})]})]})}),Ss=d.memo(function({activeTab:e,onSelect:n}){const{t:r}=Fe(["terminal"]);return f.jsxs("div",{className:"spotlight-tabs",role:"tablist","aria-label":r("terminal:spotlight.tabsLabel"),children:[fe.map(i=>f.jsx("button",{type:"button",role:"tab","aria-selected":i===e,tabIndex:-1,className:`spotlight-tab${i===e?" active":""}`,onClick:()=>n(i),children:r(`terminal:spotlight.tabs.${i}`)},i)),f.jsx("span",{className:"spotlight-tabs-hint",children:f.jsx("kbd",{children:"Tab"})})]})}),Bs=d.forwardRef(function({results:e,selectedIndex:n,query:r,activeTab:i,areaSections:c,highlightMatch:o,onSelectIndex:a},u){const{t:l}=Fe(["terminal"]),h=d.useRef(!1);d.useEffect(()=>{h.current=!1},[e]),d.useEffect(()=>{const g=typeof u=="function"?null:u==null?void 0:u.current;if(!g)return;const p=()=>{h.current=!0};return g.addEventListener("mousemove",p),()=>{g.removeEventListener("mousemove",p)}},[u,e]);const E={command:l("terminal:spotlight.categories.commands"),agent:l("terminal:spotlight.categories.agents"),building:l("terminal:spotlight.categories.infrastructure"),area:l("terminal:spotlight.categories.areas"),folder:l("terminal:spotlight.categories.folders"),"modified-file":l("terminal:spotlight.categories.modifiedFiles")},C=d.useMemo(()=>{const g=[];let p=null,S=[];return e.forEach((w,T)=>{w.type!==p&&(p!==null&&S.length>0&&g.push([p,S]),p=w.type,S=[]),S.push({result:w,index:T})}),p!==null&&S.length>0&&g.push([p,S]),g},[e]);if(d.useEffect(()=>{if(!u||typeof u=="function")return;const g=u.current;if(!g)return;const p=g.querySelector(".spotlight-item.selected");p&&p.scrollIntoView({block:"nearest",behavior:"smooth"})},[n,u]),i==="areas"){if(c.length===0)return f.jsx("div",{className:"spotlight-results",ref:u,children:f.jsx("div",{className:"spotlight-empty",children:l("terminal:spotlight.noResults")})});let g=0;return f.jsx("div",{className:"spotlight-results",ref:u,children:c.map(p=>f.jsxs("div",{children:[f.jsxs("div",{className:"spotlight-category-header spotlight-area-section-header",children:[f.jsx("span",{className:"spotlight-area-dot",style:{background:p.areaColor},"aria-hidden":"true"}),f.jsx("span",{className:"spotlight-area-name",children:p.areaName}),f.jsx("span",{className:"spotlight-area-count",children:p.agents.length})]}),p.agents.length===0?f.jsx("div",{className:"spotlight-area-empty",children:l("terminal:spotlight.noAgentsInArea")}):p.agents.map(S=>{const w=g++;return f.jsx(Je,{result:S,isSelected:w===n,query:r,highlightMatch:o,onClick:()=>S.action(),onMouseEnter:()=>{h.current&&a(w)}},S.id)})]},p.areaId))})}return e.length===0?f.jsx("div",{className:"spotlight-results",ref:u,children:f.jsx("div",{className:"spotlight-empty",children:l("terminal:spotlight.noResults")})}):f.jsx("div",{className:"spotlight-results",ref:u,children:C.map(([g,p])=>f.jsxs("div",{children:[C.length>1&&f.jsx("div",{className:"spotlight-category-header",children:E[g]||g}),p.map(({result:S,index:w})=>f.jsx(Je,{result:S,isSelected:w===n,query:r,highlightMatch:o,onClick:()=>S.action(),onMouseEnter:()=>{h.current&&a(w)}},S.id))]},g))})}),vs=d.memo(function(){const{t:e}=Fe(["terminal"]);return f.jsxs("div",{className:"spotlight-footer",children:[f.jsxs("div",{className:"spotlight-footer-left",children:[f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"↑"}),f.jsx("kbd",{children:"↓"})," ",f.jsx("kbd",{children:"Alt+N"}),f.jsx("kbd",{children:"Alt+P"})," ",e("terminal:spotlight.navigate")]}),f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"Enter"})," ",e("terminal:spotlight.select")]}),f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"Tab"})," ",e("terminal:spotlight.switchTabs")]})]}),f.jsx("div",{className:"spotlight-footer-right",children:f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"Esc"})," ",e("common:buttons.close")]})})]})}),Is=768;function Rs({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:i,onOpenFileExplorer:c,onOpenPM2LogsModal:o,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l}){const h=d.useRef(null),E=d.useRef(null),C=d.useRef(null),g=d.useRef(0),{query:p,setQuery:S,selectedIndex:w,setSelectedIndex:T,results:j,activeTab:Q,setActiveTab:W,cycleTab:oe,areaSections:ie,handleKeyDown:$,highlightMatch:N}=Fs({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:i,onOpenFileExplorer:c,onOpenPM2LogsModal:o,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l});g.current=j.length;const D=d.useRef(oe);D.current=oe,d.useEffect(()=>{t&&setTimeout(()=>{var B,M;(B=h.current)==null||B.focus(),(M=h.current)==null||M.select()},50)},[t]),d.useEffect(()=>{if(!t)return;const B=window.visualViewport;if(!B||window.innerWidth>Is)return;const M=()=>{const R=E.current;R&&(R.style.height=`${B.height}px`,R.style.top=`${B.offsetTop}px`)};return M(),B.addEventListener("resize",M),B.addEventListener("scroll",M),()=>{B.removeEventListener("resize",M),B.removeEventListener("scroll",M);const R=E.current;R&&(R.style.height="",R.style.top="")}},[t]),d.useEffect(()=>{if(!t)return;const B=M=>{if(M.key==="Escape"){M.preventDefault(),M.stopPropagation(),M.stopImmediatePropagation(),e();return}if(M.key==="Tab"){M.preventDefault(),M.stopPropagation(),M.stopImmediatePropagation(),D.current(M.shiftKey?-1:1);return}if(M.altKey&&!M.ctrlKey&&!M.metaKey&&(M.key==="n"||M.key==="p"||M.key==="N"||M.key==="P")){M.preventDefault(),M.stopPropagation(),M.stopImmediatePropagation();const R=M.key.toLowerCase(),X=g.current;T(R==="p"?O=>O>0?O-1:X-1:O=>O<X-1?O+1:0);return}};return window.addEventListener("keydown",B,{capture:!0}),()=>{window.removeEventListener("keydown",B,{capture:!0})}},[t,e]);const ae=d.useCallback(B=>{B.target===B.currentTarget&&e()},[e]),H=d.useCallback(()=>{T(0)},[T]);return t?f.jsx("div",{ref:E,className:"spotlight-overlay",onClick:ae,children:f.jsxs("div",{className:"spotlight-modal",children:[f.jsx(ws,{ref:h,query:p,onQueryChange:S,onKeyDown:$,onResetSelection:H}),f.jsx(Ss,{activeTab:Q,onSelect:W}),f.jsx(Bs,{ref:C,results:j,selectedIndex:w,query:p,activeTab:Q,areaSections:ie,highlightMatch:N,onSelectIndex:T}),f.jsx(vs,{})]})}):null}export{Ls as FILE_ICON_NAMES,Rs as Spotlight,vs as SpotlightFooter,ws as SpotlightInput,Je as SpotlightItem,Bs as SpotlightResults,$s as formatDuration,js as formatRelativeTime,Ns as getAgentIcon,kt as getFileIconFromPath,Ps as getTypeLabel,Fs as useSpotlightSearch};
|
|
1
|
+
import{i as At,k as yt,aC as Et,a5 as xt,m as Ct,cB as Mt,cC as Ft,aU as wt,r as d,$ as St,S as pe,cD as Bt,cE as fe,s as V,cF as vt,j as f,I as ne,cG as Ve,cH as It,a9 as _t,cI as Dt,cJ as kt,cK as Ee,aq as ve,_ as Rt,v as nt,u as Fe,cL as Je}from"./main-BbNRp516.js";import{cM as Ls,cN as $s,cO as js,cP as Ns,cQ as Ps}from"./main-BbNRp516.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function re(t){return Array.isArray?Array.isArray(t):ct(t)==="[object Array]"}function bt(t){if(typeof t=="string")return t;let e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function Tt(t){return t==null?"":bt(t)}function Z(t){return typeof t=="string"}function rt(t){return typeof t=="number"}function Lt(t){return t===!0||t===!1||$t(t)&&ct(t)=="[object Boolean]"}function it(t){return typeof t=="object"}function $t(t){return it(t)&&t!==null}function G(t){return t!=null}function Ie(t){return!t.trim().length}function ct(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const jt="Incorrect 'index' type",Nt=t=>`Invalid value for key ${t}`,Pt=t=>`Pattern length exceeds max of ${t}.`,Kt=t=>`Missing ${t} property in key`,Ot=t=>`Property 'weight' in key '${t}' must be a positive integer`,Xe=Object.prototype.hasOwnProperty;class zt{constructor(e){this._keys=[],this._keyMap={};let n=0;e.forEach(r=>{let i=ot(r);this._keys.push(i),this._keyMap[i.id]=i,n+=i.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 ot(t){let e=null,n=null,r=null,i=1,c=null;if(Z(t)||re(t))r=t,e=qe(t),n=_e(t);else{if(!Xe.call(t,"name"))throw new Error(Kt("name"));const o=t.name;if(r=o,Xe.call(t,"weight")&&(i=t.weight,i<=0))throw new Error(Ot(o));e=qe(o),n=_e(o),c=t.getFn}return{path:e,id:n,weight:i,src:r,getFn:c}}function qe(t){return re(t)?t:t.split(".")}function _e(t){return re(t)?t.join("."):t}function Gt(t,e){let n=[],r=!1;const i=(c,o,a)=>{if(G(c))if(!o[a])n.push(c);else{let u=o[a];const l=c[u];if(!G(l))return;if(a===o.length-1&&(Z(l)||rt(l)||Lt(l)))n.push(Tt(l));else if(re(l)){r=!0;for(let h=0,E=l.length;h<E;h+=1)i(l[h],o,a+1)}else o.length&&i(l,o,a+1)}};return i(t,Z(e)?e.split("."):e,0),r?n:n[0]}const Qt={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Wt={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},Ht={location:0,threshold:.6,distance:100},Ut={useExtendedSearch:!1,getFn:Gt,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var y={...Wt,...Qt,...Ht,...Ut};const Yt=/[^ ]+/g;function Vt(t=1,e=3){const n=new Map,r=Math.pow(10,e);return{get(i){const c=i.match(Yt).length;if(n.has(c))return n.get(c);const o=1/Math.pow(c,.5*t),a=parseFloat(Math.round(o*r)/r);return n.set(c,a),a},clear(){n.clear()}}}class Le{constructor({getFn:e=y.getFn,fieldNormWeight:n=y.fieldNormWeight}={}){this.norm=Vt(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,Z(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();Z(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(!G(e)||Ie(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((i,c)=>{let o=i.getFn?i.getFn(e):this.getFn(e,i.path);if(G(o)){if(re(o)){let a=[];const u=[{nestedArrIndex:-1,value:o}];for(;u.length;){const{nestedArrIndex:l,value:h}=u.pop();if(G(h))if(Z(h)&&!Ie(h)){let E={v:h,i:l,n:this.norm.get(h)};a.push(E)}else re(h)&&h.forEach((E,C)=>{u.push({nestedArrIndex:C,value:E})})}r.$[c]=a}else if(Z(o)&&!Ie(o)){let a={v:o,n:this.norm.get(o)};r.$[c]=a}}}),this.records.push(r)}toJSON(){return{keys:this.keys,records:this.records}}}function at(t,e,{getFn:n=y.getFn,fieldNormWeight:r=y.fieldNormWeight}={}){const i=new Le({getFn:n,fieldNormWeight:r});return i.setKeys(t.map(ot)),i.setSources(e),i.create(),i}function Jt(t,{getFn:e=y.getFn,fieldNormWeight:n=y.fieldNormWeight}={}){const{keys:r,records:i}=t,c=new Le({getFn:e,fieldNormWeight:n});return c.setKeys(r),c.setIndexRecords(i),c}function xe(t,{errors:e=0,currentLocation:n=0,expectedLocation:r=0,distance:i=y.distance,ignoreLocation:c=y.ignoreLocation}={}){const o=e/t.length;if(c)return o;const a=Math.abs(r-n);return i?o+a/i:a?1:o}function Xt(t=[],e=y.minMatchCharLength){let n=[],r=-1,i=-1,c=0;for(let o=t.length;c<o;c+=1){let a=t[c];a&&r===-1?r=c:!a&&r!==-1&&(i=c-1,i-r+1>=e&&n.push([r,i]),r=-1)}return t[c-1]&&c-r>=e&&n.push([r,c-1]),n}const le=32;function qt(t,e,n,{location:r=y.location,distance:i=y.distance,threshold:c=y.threshold,findAllMatches:o=y.findAllMatches,minMatchCharLength:a=y.minMatchCharLength,includeMatches:u=y.includeMatches,ignoreLocation:l=y.ignoreLocation}={}){if(e.length>le)throw new Error(Pt(le));const h=e.length,E=t.length,C=Math.max(0,Math.min(r,E));let g=c,p=C;const S=a>1||u,w=S?Array(E):[];let T;for(;(T=t.indexOf(e,p))>-1;){let $=xe(e,{currentLocation:T,expectedLocation:C,distance:i,ignoreLocation:l});if(g=Math.min($,g),p=T+h,S){let N=0;for(;N<h;)w[T+N]=1,N+=1}}p=-1;let j=[],Q=1,W=h+E;const oe=1<<h-1;for(let $=0;$<h;$+=1){let N=0,D=W;for(;N<D;)xe(e,{errors:$,currentLocation:C+D,expectedLocation:C,distance:i,ignoreLocation:l})<=g?N=D:W=D,D=Math.floor((W-N)/2+N);W=D;let ae=Math.max(1,C-D+1),H=o?E:Math.min(C+D,E)+h,B=Array(H+2);B[H+1]=(1<<$)-1;for(let R=H;R>=ae;R-=1){let X=R-1,O=n[t.charAt(X)];if(S&&(w[X]=+!!O),B[R]=(B[R+1]<<1|1)&O,$&&(B[R]|=(j[R+1]|j[R])<<1|1|j[R+1]),B[R]&oe&&(Q=xe(e,{errors:$,currentLocation:X,expectedLocation:C,distance:i,ignoreLocation:l}),Q<=g)){if(g=Q,p=X,p<=C)break;ae=Math.max(1,2*C-p)}}if(xe(e,{errors:$+1,currentLocation:C,expectedLocation:C,distance:i,ignoreLocation:l})>g)break;j=B}const ie={isMatch:p>=0,score:Math.max(.001,Q)};if(S){const $=Xt(w,a);$.length?u&&(ie.indices=$):ie.isMatch=!1}return ie}function Zt(t){let e={};for(let n=0,r=t.length;n<r;n+=1){const i=t.charAt(n);e[i]=(e[i]||0)|1<<r-n-1}return e}const Ce=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 ut{constructor(e,{location:n=y.location,threshold:r=y.threshold,distance:i=y.distance,includeMatches:c=y.includeMatches,findAllMatches:o=y.findAllMatches,minMatchCharLength:a=y.minMatchCharLength,isCaseSensitive:u=y.isCaseSensitive,ignoreDiacritics:l=y.ignoreDiacritics,ignoreLocation:h=y.ignoreLocation}={}){if(this.options={location:n,threshold:r,distance:i,includeMatches:c,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:h},e=u?e:e.toLowerCase(),e=l?Ce(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const E=(g,p)=>{this.chunks.push({pattern:g,alphabet:Zt(g),startIndex:p})},C=this.pattern.length;if(C>le){let g=0;const p=C%le,S=C-p;for(;g<S;)E(this.pattern.substr(g,le),g),g+=le;if(p){const w=C-le;E(this.pattern.substr(w),w)}}else E(this.pattern,0)}searchIn(e){const{isCaseSensitive:n,ignoreDiacritics:r,includeMatches:i}=this.options;if(e=n?e:e.toLowerCase(),e=r?Ce(e):e,this.pattern===e){let S={isMatch:!0,score:0};return i&&(S.indices=[[0,e.length-1]]),S}const{location:c,distance:o,threshold:a,findAllMatches:u,minMatchCharLength:l,ignoreLocation:h}=this.options;let E=[],C=0,g=!1;this.chunks.forEach(({pattern:S,alphabet:w,startIndex:T})=>{const{isMatch:j,score:Q,indices:W}=qt(e,S,w,{location:c+T,distance:o,threshold:a,findAllMatches:u,minMatchCharLength:l,includeMatches:i,ignoreLocation:h});j&&(g=!0),C+=Q,j&&W&&(E=[...E,...W])});let p={isMatch:g,score:g?C/this.chunks.length:1};return g&&i&&(p.indices=E),p}}class ce{constructor(e){this.pattern=e}static isMultiMatch(e){return Ze(e,this.multiRegex)}static isSingleMatch(e){return Ze(e,this.singleRegex)}search(){}}function Ze(t,e){const n=t.match(e);return n?n[1]:null}class es extends ce{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 ts extends ce{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 ss extends ce{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 ns extends ce{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 rs extends ce{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 is extends ce{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 lt extends ce{constructor(e,{location:n=y.location,threshold:r=y.threshold,distance:i=y.distance,includeMatches:c=y.includeMatches,findAllMatches:o=y.findAllMatches,minMatchCharLength:a=y.minMatchCharLength,isCaseSensitive:u=y.isCaseSensitive,ignoreDiacritics:l=y.ignoreDiacritics,ignoreLocation:h=y.ignoreLocation}={}){super(e),this._bitapSearch=new ut(e,{location:n,threshold:r,distance:i,includeMatches:c,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:h})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class ht extends ce{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let n=0,r;const i=[],c=this.pattern.length;for(;(r=e.indexOf(this.pattern,n))>-1;)n=r+c,i.push([r,n-1]);const o=!!i.length;return{isMatch:o,score:o?0:1,indices:i}}}const De=[es,ht,ss,ns,is,rs,ts,lt],et=De.length,cs=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,os="|";function as(t,e={}){return t.split(os).map(n=>{let r=n.trim().split(cs).filter(c=>c&&!!c.trim()),i=[];for(let c=0,o=r.length;c<o;c+=1){const a=r[c];let u=!1,l=-1;for(;!u&&++l<et;){const h=De[l];let E=h.isMultiMatch(a);E&&(i.push(new h(E,e)),u=!0)}if(!u)for(l=-1;++l<et;){const h=De[l];let E=h.isSingleMatch(a);if(E){i.push(new h(E,e));break}}}return i})}const us=new Set([lt.type,ht.type]);class ls{constructor(e,{isCaseSensitive:n=y.isCaseSensitive,ignoreDiacritics:r=y.ignoreDiacritics,includeMatches:i=y.includeMatches,minMatchCharLength:c=y.minMatchCharLength,ignoreLocation:o=y.ignoreLocation,findAllMatches:a=y.findAllMatches,location:u=y.location,threshold:l=y.threshold,distance:h=y.distance}={}){this.query=null,this.options={isCaseSensitive:n,ignoreDiacritics:r,includeMatches:i,minMatchCharLength:c,findAllMatches:a,ignoreLocation:o,location:u,threshold:l,distance:h},e=n?e:e.toLowerCase(),e=r?Ce(e):e,this.pattern=e,this.query=as(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:i,ignoreDiacritics:c}=this.options;e=i?e:e.toLowerCase(),e=c?Ce(e):e;let o=0,a=[],u=0;for(let l=0,h=n.length;l<h;l+=1){const E=n[l];a.length=0,o=0;for(let C=0,g=E.length;C<g;C+=1){const p=E[C],{isMatch:S,indices:w,score:T}=p.search(e);if(S){if(o+=1,u+=T,r){const j=p.constructor.type;us.has(j)?a=[...a,...w]:a.push(w)}}else{u=0,o=0,a.length=0;break}}if(o){let C={isMatch:!0,score:u/o};return r&&(C.indices=a),C}}return{isMatch:!1,score:1}}}const ke=[];function hs(...t){ke.push(...t)}function Re(t,e){for(let n=0,r=ke.length;n<r;n+=1){let i=ke[n];if(i.condition(t,e))return new i(t,e)}return new ut(t,e)}const Me={AND:"$and",OR:"$or"},be={PATH:"$path",PATTERN:"$val"},Te=t=>!!(t[Me.AND]||t[Me.OR]),ds=t=>!!t[be.PATH],fs=t=>!re(t)&&it(t)&&!Te(t),tt=t=>({[Me.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function dt(t,e,{auto:n=!0}={}){const r=i=>{let c=Object.keys(i);const o=ds(i);if(!o&&c.length>1&&!Te(i))return r(tt(i));if(fs(i)){const u=o?i[be.PATH]:c[0],l=o?i[be.PATTERN]:i[u];if(!Z(l))throw new Error(Nt(u));const h={keyId:_e(u),pattern:l};return n&&(h.searcher=Re(l,e)),h}let a={children:[],operator:c[0]};return c.forEach(u=>{const l=i[u];re(l)&&l.forEach(h=>{a.children.push(r(h))})}),a};return Te(t)||(t=tt(t)),r(t)}function gs(t,{ignoreFieldNorm:e=y.ignoreFieldNorm}){t.forEach(n=>{let r=1;n.matches.forEach(({key:i,norm:c,score:o})=>{const a=i?i.weight:null;r*=Math.pow(o===0&&a?Number.EPSILON:o,(a||1)*(e?1:c))}),n.score=r})}function ps(t,e){const n=t.matches;e.matches=[],G(n)&&n.forEach(r=>{if(!G(r.indices)||!r.indices.length)return;const{indices:i,value:c}=r;let o={indices:i,value:c};r.key&&(o.key=r.key.src),r.idx>-1&&(o.refIndex=r.idx),e.matches.push(o)})}function ms(t,e){e.score=t.score}function As(t,e,{includeMatches:n=y.includeMatches,includeScore:r=y.includeScore}={}){const i=[];return n&&i.push(ps),r&&i.push(ms),t.map(c=>{const{idx:o}=c,a={item:e[o],refIndex:o};return i.length&&i.forEach(u=>{u(c,a)}),a})}class q{constructor(e,n={},r){this.options={...y,...n},this.options.useExtendedSearch,this._keyStore=new zt(this.options.keys),this.setCollection(e,r)}setCollection(e,n){if(this._docs=e,n&&!(n instanceof Le))throw new Error(jt);this._myIndex=n||at(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){G(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const n=[];for(let r=0,i=this._docs.length;r<i;r+=1){const c=this._docs[r];e(c,r)&&(this.removeAt(r),r-=1,i-=1,n.push(c))}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:i,shouldSort:c,sortFn:o,ignoreFieldNorm:a}=this.options;let u=Z(e)?Z(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return gs(u,{ignoreFieldNorm:a}),c&&u.sort(o),rt(n)&&n>-1&&(u=u.slice(0,n)),As(u,this._docs,{includeMatches:r,includeScore:i})}_searchStringList(e){const n=Re(e,this.options),{records:r}=this._myIndex,i=[];return r.forEach(({v:c,i:o,n:a})=>{if(!G(c))return;const{isMatch:u,score:l,indices:h}=n.searchIn(c);u&&i.push({item:c,idx:o,matches:[{score:l,value:c,norm:a,indices:h}]})}),i}_searchLogical(e){const n=dt(e,this.options),r=(a,u,l)=>{if(!a.children){const{keyId:E,searcher:C}=a,g=this._findMatches({key:this._keyStore.get(E),value:this._myIndex.getValueForItemAtKeyId(u,E),searcher:C});return g&&g.length?[{idx:l,item:u,matches:g}]:[]}const h=[];for(let E=0,C=a.children.length;E<C;E+=1){const g=a.children[E],p=r(g,u,l);if(p.length)h.push(...p);else if(a.operator===Me.AND)return[]}return h},i=this._myIndex.records,c={},o=[];return i.forEach(({$:a,i:u})=>{if(G(a)){let l=r(n,a,u);l.length&&(c[u]||(c[u]={idx:u,item:a,matches:[]},o.push(c[u])),l.forEach(({matches:h})=>{c[u].matches.push(...h)}))}}),o}_searchObjectList(e){const n=Re(e,this.options),{keys:r,records:i}=this._myIndex,c=[];return i.forEach(({$:o,i:a})=>{if(!G(o))return;let u=[];r.forEach((l,h)=>{u.push(...this._findMatches({key:l,value:o[h],searcher:n}))}),u.length&&c.push({idx:a,item:o,matches:u})}),c}_findMatches({key:e,value:n,searcher:r}){if(!G(n))return[];let i=[];if(re(n))n.forEach(({v:c,i:o,n:a})=>{if(!G(c))return;const{isMatch:u,score:l,indices:h}=r.searchIn(c);u&&i.push({score:l,key:e,value:c,idx:o,norm:a,indices:h})});else{const{v:c,n:o}=n,{isMatch:a,score:u,indices:l}=r.searchIn(c);a&&i.push({score:u,key:e,value:c,norm:o,indices:l})}return i}}q.version="7.1.0";q.createIndex=at;q.parseIndex=Jt;q.config=y;q.parseQuery=dt;hs(ls);async function ys(t){const e=new URLSearchParams({q:t}),n=await At(yt(`/api/folders/search?${e.toString()}`));if(!n.ok){const i=await n.json().catch(()=>({}));throw new Error(i.error||`Failed to search folders: ${n.statusText}`)}const r=await n.json();return Array.isArray(r.folders)?r.folders:[]}const Es=["command","agent","building","area","folder","modified-file"],xs=2;function Cs(){const t=nt(pe.SPOTLIGHT_TAB,"all");return fe.includes(t)?t:"all"}function st(){return Rt(pe.SPOTLIGHT_QUERY,"")}function Ms(){const t=nt(pe.AOP_CONFIG,{});return t.sortMode==="name"||t.sortMode==="status"||t.sortMode==="recent"?t.sortMode:"recent"}function Fs({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:i,onOpenFileExplorer:c,onOpenPM2LogsModal:o,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l}){const h=Et(),E=xt(),C=Ct(),g=Mt(),p=Ft(),S=wt(),w=d.useRef(e);w.current=e;const T=d.useRef(n);T.current=n;const j=d.useRef(r);j.current=r;const Q=d.useRef(i);Q.current=i;const W=d.useRef(c);W.current=c;const oe=d.useRef(o);oe.current=o;const ie=d.useRef(a);ie.current=a;const $=d.useRef(u);$.current=u;const N=d.useRef(l);N.current=l;const[D,ae]=d.useState(st),[H,B]=d.useState(0),[M,R]=d.useState(Cs),[X,O]=d.useState([]),ft=d.useCallback(s=>{ae(s),St(pe.SPOTLIGHT_QUERY,s)},[]);d.useEffect(()=>{t&&(ae(st()),B(0))},[t]),d.useEffect(()=>{if(!t){O([]);return}const s=D.trim();if(s.length<xs){O([]);return}let m=!1;const F=setTimeout(()=>{ys(s).then(x=>{m||O(x)}).catch(()=>{m||O([])})},250);return()=>{m=!0,clearTimeout(F)}},[t,D]);const we=d.useCallback(s=>{R(s),Bt(pe.SPOTLIGHT_TAB,s)},[]),$e=d.useRef(M);$e.current=M;const gt=d.useCallback(s=>{const m=fe.indexOf($e.current),F=fe[(m+s+fe.length)%fe.length];we(F)},[we]);d.useEffect(()=>{B(0)},[M]);const Se=V.getShortcuts(),ge=d.useMemo(()=>t?vt():{},[t]),me=d.useMemo(()=>{if(!t)return[];const s=window.matchMedia("(pointer: coarse)").matches,m=Se.find(x=>x.id==="spawn-agent"),F=Se.find(x=>x.id==="toggle-commander");return[{id:"cmd-spawn",type:"command",title:"Spawn New Agent",subtitle:s?"":m?Ve(m):"Alt+N",icon:f.jsx(ne,{name:"plus",size:16}),action:()=>{w.current(),T.current()}},{id:"cmd-commander",type:"command",title:"Commander View",subtitle:s?"":F!=null&&F.key?Ve(F):"Tab",icon:f.jsx(ne,{name:"dashboard",size:16}),action:()=>{w.current(),j.current()}},{id:"cmd-settings",type:"command",title:"Settings & Tools",subtitle:"Configure Tide Commander",icon:f.jsx(ne,{name:"gear",size:16}),action:()=>{w.current(),Q.current()}},{id:"cmd-monitoring",type:"command",title:"Monitoring & Logs",subtitle:"Triggers, workflows, events",icon:f.jsx(ne,{name:"chart-line",size:16}),action:()=>{var x;w.current(),(x=N.current)==null||x.call(N)}}]},[t,Se]),he=d.useMemo(()=>t?Array.from(h.values()).map(s=>{const m=(g||[]).filter(Y=>Y.agentId===s.id).map(Y=>Y.filePath),F=[...new Set(m)],x=F.map(Y=>Y.split("/").pop()||Y),v=[];s.lastAssignedTask&&v.push(s.lastAssignedTask);const L=`${s.class} • ${s.cwd}`;let k=`${s.name} ${s.class} ${s.status} ${s.cwd}`;s.taskLabel&&(k+=` ${s.taskLabel}`),x.length>0&&(k+=` ${x.join(" ")} ${F.join(" ")}`),v.length>0&&(k+=` ${v.join(" ")}`);const P=Date.now()-s.lastActivity;let U;return s.lastAssignedTask&&(s.lastAssignedTask.length>150?U=s.lastAssignedTask.slice(0,150)+"...":U=s.lastAssignedTask),{id:`agent-${s.id}`,type:"agent",title:s.name,subtitle:L,lastUserInput:U,timeAway:P,icon:f.jsx(_t,{agent:s,size:20}),_searchText:k,_modifiedFiles:F,_userQueries:v,_agentId:s.id,_lastActivity:s.lastActivity,_taskLabel:s.taskLabel,_status:s.status,action:()=>{w.current(),It(s.id),V.selectAgent(s.id),V.getState().viewMode!=="flat"&&V.requestTerminalExpand()}}}):[],[t,h,g]),Ae=d.useMemo(()=>t?Array.from(E.values()).map(s=>{var m;return{id:`area-${s.id}`,type:"area",title:s.name,subtitle:`${s.assignedAgentIds.length} agents • ${((m=s.directories)==null?void 0:m.length)||0} folders`,icon:f.jsx(ne,{name:"map",size:16}),action:()=>{w.current(),V.selectArea(s.id)}}}):[],[t,E]),je=d.useMemo(()=>{const s=new Map;for(const m of he)m._agentId&&s.set(m._agentId,m);return s},[he]),Ne=d.useMemo(()=>{const s=new Map;if(!t)return s;for(const m of h.values()){const F=V.getAreaForAgent(m.id);if(!F||F.archived)continue;const x=s.get(F.id);x?x.push(m):s.set(F.id,[m])}return s},[t,h,E]),Pe=d.useMemo(()=>{const s=new Map;for(const m of p)s.has(m.agentId)||s.set(m.agentId,m.timestamp);return s},[p]),Be=d.useMemo(()=>{if(!t)return[];const s=D.trim().toLowerCase(),m=Dt({sortMode:Ms(),agentsWithUnseenOutput:S,getLatestToolTimestamp:v=>Pe.get(v)}),F=Array.from(E.values()).filter(v=>!v.archived).filter(v=>s?v.name.toLowerCase().includes(s):!0).sort((v,L)=>v.name.localeCompare(L.name,void 0,{sensitivity:"base"})),x=[];for(const v of F){const k=(Ne.get(v.id)||[]).slice().sort(m).map(P=>je.get(P.id)).filter(P=>!!P);!s&&k.length===0||x.push({areaId:v.id,areaName:v.name,areaColor:v.color,agents:k})}return x},[t,D,E,Ne,je,S,Pe]),ye=d.useMemo(()=>t?Array.from(C.values()).filter(s=>s.type==="server"||s.type==="boss"||s.type==="database"||s.type==="tests").map(s=>{var P,U,Y,ue,ee;const m=s.status==="running"?"#4ade80":s.status==="stopped"?"#f87171":"#facc15",F=s.type==="boss"?"crown":s.type==="database"?"database":s.type==="tests"?"flask":"desktop",x=s.type==="boss"?"Boss":s.type==="database"?"Database":s.type==="tests"?"Tests":"Server";let v=`${x} • ${s.status}`;if(s.type==="database"&&((U=(P=s.database)==null?void 0:P.connections)!=null&&U.length)){const z=s.database.connections[0];v+=` • ${z.engine} @ ${z.host}`}else s.type==="tests"&&s.folderPath?v=`${x} • ${s.folderPath}`:s.cwd&&(v+=` • ${s.cwd}`);const L=((Y=s.pm2Status)==null?void 0:Y.ports)||[];let k=`${s.name} ${s.type} ${s.status} ${s.cwd||""} ${((ue=s.pm2)==null?void 0:ue.name)||""}`;if(s.type==="tests"&&(k+=` ${s.folderPath||""} tests junit maven`),L.length>0&&(k+=` ${L.join(" ")}`),s.type==="database"&&((ee=s.database)!=null&&ee.connections))for(const z of s.database.connections)k+=` ${z.name} ${z.engine} ${z.host} ${z.database||""} mysql postgresql sql`;return{id:`building-${s.id}`,type:"building",title:s.name,subtitle:v,_ports:L,icon:f.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[f.jsx(ne,{name:"status-pending",size:10,weight:"fill",color:m}),f.jsx(ne,{name:F,size:16})]}),_searchText:k,action:()=>{var z;w.current(),s.type==="boss"?ie.current(s.id):s.type==="database"?$.current(s.id):s.type==="tests"?V.openTestsBuilding(s.id):s.type==="http"?V.openHttpBuilding(s.id):(z=s.pm2)!=null&&z.enabled&&oe.current(s.id)}}}):[],[t,C]),Ke=d.useMemo(()=>{if(!t)return[];const s=g||[],m=new Set,F=[];for(const x of s){if(m.has(x.filePath))continue;m.add(x.filePath);const v=x.filePath.split("/").pop()||x.filePath,L=x.action==="created"?"Created":x.action==="modified"?"Modified":x.action==="deleted"?"Deleted":"Read";if(F.push({id:`modified-${x.filePath}-${x.timestamp}`,type:"modified-file",title:v,subtitle:`${L} by ${x.agentName} • ${x.filePath}`,matchedText:x.filePath,icon:x.action==="deleted"?f.jsx(ne,{name:"trash",size:16}):kt(x.filePath),action:()=>{w.current();const k=Array.from(V.getState().areas.values());for(const P of k)for(const U of P.directories||[])if(x.filePath.startsWith(U)){V.setFileViewerPath(x.filePath),W.current(P.id);return}V.selectAgent(x.agentId)}}),F.length>=50)break}return F},[t,g]),Oe=d.useMemo(()=>t?X.map(s=>{const m=s.isGitRepo&&s.gitBranch?`${s.path} • ${s.gitBranch}`:s.path;return{id:`folder-${s.path}`,type:"folder",title:s.name,subtitle:m,matchedText:s.path,icon:f.jsx(ne,{name:s.isGitRepo?"git-branch":"folder",size:16}),_searchText:`${s.name} ${s.path}`,_isGitRepo:s.isGitRepo,_gitBranch:s.gitBranch,action:()=>{w.current(),V.openFileExplorer(s.path)}}}):[],[t,X]),ze=d.useMemo(()=>new q(he,{keys:["title","subtitle","_searchText","lastUserInput"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[he]),Ge=d.useMemo(()=>new q(me,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[me]),Qe=d.useMemo(()=>new q(Ae,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[Ae]),We=d.useMemo(()=>new q(Ke,{keys:["title","subtitle","matchedText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[Ke]),He=d.useMemo(()=>new q(ye,{keys:["title","subtitle","_searchText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[ye]),de=d.useMemo(()=>{if(!D.trim()){const A=[];A.push(...ye);const I=[...he].sort((b,K)=>{const te=Ee(b._agentId,b._lastActivity,ge);return Ee(K._agentId,K._lastActivity,ge)-te});A.push(...I),A.push(...me.slice(0,2)),A.push(...Ae.slice(0,2));const _={};return Es.forEach((b,K)=>{_[b]=K}),A.sort((b,K)=>(_[b.type]??999)-(_[K.type]??999)),A}const s=D.trim().toLowerCase(),m=ze.search(D).slice(0,8),F=Ge.search(D).slice(0,3),x=Qe.search(D).slice(0,2),v=We.search(D).slice(0,3),L=Oe.slice(0,8),k=He.search(D).filter(A=>{const I=A.score??1;return`${A.item.title} ${A.item.subtitle||""} ${A.item._searchText||""}`.toLowerCase().includes(s)||I<=.2}).slice(0,4),P={agent:6,building:5,folder:4,command:3,area:2,"modified-file":1},U=A=>{if(!s)return 1;const I=A.title.toLowerCase();return I===s?6:I.startsWith(s)?5:I.split(/[^a-z0-9]+/i).includes(s)?4:I.includes(s)?3:`${A.subtitle||""} ${A._searchText||""} ${A.matchedText||""}`.toLowerCase().includes(s)?2:1},Y=(A,I)=>{const _=(1-Math.min(1,I??1))*4;return U(A)*100+(P[A.type]??0)*5+_},ue=new Map,ee=(A,I)=>{const _=ue.get(A.type),b={item:A,score:Y(A,I)};_?_.push(b):ue.set(A.type,[b])};for(const A of m){const I={...A.item};if(I._modifiedFiles&&I._modifiedFiles.length>0){const _=I._modifiedFiles.filter(b=>{var se;const K=((se=b.split("/").pop())==null?void 0:se.toLowerCase())||"",te=b.toLowerCase();return K.includes(s)||te.includes(s)});_.length>0&&(I.matchedFiles=_)}if(I._userQueries&&I._userQueries.length>0){const _=I._userQueries.find(b=>b.toLowerCase().includes(s));if(_)if(_.length>200){const K=_.toLowerCase().indexOf(s),te=Math.max(0,K-60),se=Math.min(_.length,K+s.length+100);I.matchedQuery=(te>0?"...":"")+_.slice(te,se)+(se<_.length?"...":"")}else I.matchedQuery=_}ee(I,A.score)}for(const A of k)ee(A.item,A.score);for(const A of F)ee(A.item,A.score);for(const A of x)ee(A.item,A.score);for(const A of v)ee(A.item,A.score);for(const A of L)ee(A,void 0);for(const[A,I]of ue)A==="agent"?I.sort((_,b)=>{const K=U(_.item),te=U(b.item);if(te!==K)return te-K;const se=Ee(_.item._agentId,_.item._lastActivity,ge),Ye=Ee(b.item._agentId,b.item._lastActivity,ge);return Ye!==se?Ye-se:b.score-_.score}):I.sort((_,b)=>b.score-_.score);const z=A=>A.reduce((I,_)=>Math.max(I,_.score),-1),Ue=[];return Array.from(ue.values()).sort((A,I)=>z(I)-z(A)).forEach(A=>{for(const I of A)Ue.push(I.item)}),Ue},[D,ze,Ge,Qe,We,He,me,he,Ae,ye,Oe,ge]),J=d.useMemo(()=>{switch(M){case"agents":return de.filter(s=>s.type==="agent");case"buildings":return de.filter(s=>s.type==="building");case"commands":return de.filter(s=>s.type==="command");case"folders":return de.filter(s=>s.type==="folder");case"areas":return Be.flatMap(s=>s.agents);case"all":default:return de}},[M,de,Be]);d.useEffect(()=>{H>=J.length&&B(Math.max(0,J.length-1))},[J.length,H]);const pt=d.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 m=s.key.toLowerCase();B(m==="p"?F=>F>0?F-1:J.length-1:F=>F<J.length-1?F+1:0);return}switch(s.key){case"Escape":s.preventDefault(),w.current();break;case"ArrowUp":s.preventDefault(),B(m=>m>0?m-1:J.length-1);break;case"ArrowDown":s.preventDefault(),B(m=>m<J.length-1?m+1:0);break;case"Enter":s.preventDefault(),J[H]&&J[H].action();break}},[J,H]),mt=d.useCallback((s,m)=>{if(!m||!s)return s;const F=s.toLowerCase(),x=m.toLowerCase(),v=[];let L=0,k=F.indexOf(x),P=0;for(;k!==-1;)k>L&&v.push(s.slice(L,k)),v.push(ve.createElement("mark",{key:P++,className:"spotlight-highlight"},s.slice(k,k+m.length))),L=k+m.length,k=F.indexOf(x,L);return L<s.length&&v.push(s.slice(L)),v.length>0?ve.createElement(ve.Fragment,null,...v):s},[]);return{query:D,setQuery:ft,selectedIndex:H,setSelectedIndex:B,results:J,activeTab:M,setActiveTab:we,cycleTab:gt,areaSections:Be,handleKeyDown:pt,highlightMatch:mt}}const ws=d.forwardRef(function({query:e,onQueryChange:n,onKeyDown:r,onResetSelection:i},c){const{t:o}=Fe(["common"]);return f.jsxs("div",{className:"spotlight-input-wrapper",children:[f.jsx("span",{className:"spotlight-search-icon",children:"⌘"}),f.jsx("input",{ref:c,type:"text",className:"spotlight-input",placeholder:o("common:search.spotlightPlaceholder"),value:e,onChange:a=>{n(a.target.value),i()},onKeyDown:r,autoFocus:!0,spellCheck:!1}),f.jsxs("div",{className:"spotlight-input-hints",children:[f.jsx("span",{className:"spotlight-shortcut-hint",children:"↑↓"}),f.jsx("span",{className:"spotlight-shortcut-hint",children:"Enter"}),f.jsx("span",{className:"spotlight-shortcut-hint",children:"Esc"})]})]})}),Ss=d.memo(function({activeTab:e,onSelect:n}){const{t:r}=Fe(["terminal"]);return f.jsxs("div",{className:"spotlight-tabs",role:"tablist","aria-label":r("terminal:spotlight.tabsLabel"),children:[fe.map(i=>f.jsx("button",{type:"button",role:"tab","aria-selected":i===e,tabIndex:-1,className:`spotlight-tab${i===e?" active":""}`,onClick:()=>n(i),children:r(`terminal:spotlight.tabs.${i}`)},i)),f.jsx("span",{className:"spotlight-tabs-hint",children:f.jsx("kbd",{children:"Tab"})})]})}),Bs=d.forwardRef(function({results:e,selectedIndex:n,query:r,activeTab:i,areaSections:c,highlightMatch:o,onSelectIndex:a},u){const{t:l}=Fe(["terminal"]),h=d.useRef(!1);d.useEffect(()=>{h.current=!1},[e]),d.useEffect(()=>{const g=typeof u=="function"?null:u==null?void 0:u.current;if(!g)return;const p=()=>{h.current=!0};return g.addEventListener("mousemove",p),()=>{g.removeEventListener("mousemove",p)}},[u,e]);const E={command:l("terminal:spotlight.categories.commands"),agent:l("terminal:spotlight.categories.agents"),building:l("terminal:spotlight.categories.infrastructure"),area:l("terminal:spotlight.categories.areas"),folder:l("terminal:spotlight.categories.folders"),"modified-file":l("terminal:spotlight.categories.modifiedFiles")},C=d.useMemo(()=>{const g=[];let p=null,S=[];return e.forEach((w,T)=>{w.type!==p&&(p!==null&&S.length>0&&g.push([p,S]),p=w.type,S=[]),S.push({result:w,index:T})}),p!==null&&S.length>0&&g.push([p,S]),g},[e]);if(d.useEffect(()=>{if(!u||typeof u=="function")return;const g=u.current;if(!g)return;const p=g.querySelector(".spotlight-item.selected");p&&p.scrollIntoView({block:"nearest",behavior:"smooth"})},[n,u]),i==="areas"){if(c.length===0)return f.jsx("div",{className:"spotlight-results",ref:u,children:f.jsx("div",{className:"spotlight-empty",children:l("terminal:spotlight.noResults")})});let g=0;return f.jsx("div",{className:"spotlight-results",ref:u,children:c.map(p=>f.jsxs("div",{children:[f.jsxs("div",{className:"spotlight-category-header spotlight-area-section-header",children:[f.jsx("span",{className:"spotlight-area-dot",style:{background:p.areaColor},"aria-hidden":"true"}),f.jsx("span",{className:"spotlight-area-name",children:p.areaName}),f.jsx("span",{className:"spotlight-area-count",children:p.agents.length})]}),p.agents.length===0?f.jsx("div",{className:"spotlight-area-empty",children:l("terminal:spotlight.noAgentsInArea")}):p.agents.map(S=>{const w=g++;return f.jsx(Je,{result:S,isSelected:w===n,query:r,highlightMatch:o,onClick:()=>S.action(),onMouseEnter:()=>{h.current&&a(w)}},S.id)})]},p.areaId))})}return e.length===0?f.jsx("div",{className:"spotlight-results",ref:u,children:f.jsx("div",{className:"spotlight-empty",children:l("terminal:spotlight.noResults")})}):f.jsx("div",{className:"spotlight-results",ref:u,children:C.map(([g,p])=>f.jsxs("div",{children:[C.length>1&&f.jsx("div",{className:"spotlight-category-header",children:E[g]||g}),p.map(({result:S,index:w})=>f.jsx(Je,{result:S,isSelected:w===n,query:r,highlightMatch:o,onClick:()=>S.action(),onMouseEnter:()=>{h.current&&a(w)}},S.id))]},g))})}),vs=d.memo(function(){const{t:e}=Fe(["terminal"]);return f.jsxs("div",{className:"spotlight-footer",children:[f.jsxs("div",{className:"spotlight-footer-left",children:[f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"↑"}),f.jsx("kbd",{children:"↓"})," ",f.jsx("kbd",{children:"Alt+N"}),f.jsx("kbd",{children:"Alt+P"})," ",e("terminal:spotlight.navigate")]}),f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"Enter"})," ",e("terminal:spotlight.select")]}),f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"Tab"})," ",e("terminal:spotlight.switchTabs")]})]}),f.jsx("div",{className:"spotlight-footer-right",children:f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"Esc"})," ",e("common:buttons.close")]})})]})}),Is=768;function Rs({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:i,onOpenFileExplorer:c,onOpenPM2LogsModal:o,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l}){const h=d.useRef(null),E=d.useRef(null),C=d.useRef(null),g=d.useRef(0),{query:p,setQuery:S,selectedIndex:w,setSelectedIndex:T,results:j,activeTab:Q,setActiveTab:W,cycleTab:oe,areaSections:ie,handleKeyDown:$,highlightMatch:N}=Fs({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:i,onOpenFileExplorer:c,onOpenPM2LogsModal:o,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l});g.current=j.length;const D=d.useRef(oe);D.current=oe,d.useEffect(()=>{t&&setTimeout(()=>{var B,M;(B=h.current)==null||B.focus(),(M=h.current)==null||M.select()},50)},[t]),d.useEffect(()=>{if(!t)return;const B=window.visualViewport;if(!B||window.innerWidth>Is)return;const M=()=>{const R=E.current;R&&(R.style.height=`${B.height}px`,R.style.top=`${B.offsetTop}px`)};return M(),B.addEventListener("resize",M),B.addEventListener("scroll",M),()=>{B.removeEventListener("resize",M),B.removeEventListener("scroll",M);const R=E.current;R&&(R.style.height="",R.style.top="")}},[t]),d.useEffect(()=>{if(!t)return;const B=M=>{if(M.key==="Escape"){M.preventDefault(),M.stopPropagation(),M.stopImmediatePropagation(),e();return}if(M.key==="Tab"){M.preventDefault(),M.stopPropagation(),M.stopImmediatePropagation(),D.current(M.shiftKey?-1:1);return}if(M.altKey&&!M.ctrlKey&&!M.metaKey&&(M.key==="n"||M.key==="p"||M.key==="N"||M.key==="P")){M.preventDefault(),M.stopPropagation(),M.stopImmediatePropagation();const R=M.key.toLowerCase(),X=g.current;T(R==="p"?O=>O>0?O-1:X-1:O=>O<X-1?O+1:0);return}};return window.addEventListener("keydown",B,{capture:!0}),()=>{window.removeEventListener("keydown",B,{capture:!0})}},[t,e]);const ae=d.useCallback(B=>{B.target===B.currentTarget&&e()},[e]),H=d.useCallback(()=>{T(0)},[T]);return t?f.jsx("div",{ref:E,className:"spotlight-overlay",onClick:ae,children:f.jsxs("div",{className:"spotlight-modal",children:[f.jsx(ws,{ref:h,query:p,onQueryChange:S,onKeyDown:$,onResetSelection:H}),f.jsx(Ss,{activeTab:Q,onSelect:W}),f.jsx(Bs,{ref:C,results:j,selectedIndex:w,query:p,activeTab:Q,areaSections:ie,highlightMatch:N,onSelectIndex:T}),f.jsx(vs,{})]})}):null}export{Ls as FILE_ICON_NAMES,Rs as Spotlight,vs as SpotlightFooter,ws as SpotlightInput,Je as SpotlightItem,Bs as SpotlightResults,$s as formatDuration,js as formatRelativeTime,Ns as getAgentIcon,kt as getFileIconFromPath,Ps as getTypeLabel,Fs as useSpotlightSearch};
|