tide-commander 1.44.0 → 1.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{BossLogsModal-CTo4Bbm7.js → BossLogsModal-N4CnX-0x.js} +1 -1
- package/dist/assets/{BossSpawnModal-DOk9u7EW.js → BossSpawnModal-4CPjS2xn.js} +1 -1
- package/dist/assets/ControlsModal-Cr5klRxS.js +1 -0
- package/dist/assets/{DockerLogsModal-CrHd6OZ3.js → DockerLogsModal-D6U9obTe.js} +1 -1
- package/dist/assets/{EmbeddedEditor-h8IrAy4E.js → EmbeddedEditor-Bnm-9Q73.js} +1 -1
- package/dist/assets/{GmailOAuthSetup-io57q0N8.js → GmailOAuthSetup-GoKvyYWS.js} +1 -1
- package/dist/assets/{GoogleOAuthSetup-YyNFVd9Y.js → GoogleOAuthSetup-D3sAGlZq.js} +1 -1
- package/dist/assets/{IframeModal-DqmSDXCT.js → IframeModal-DQqev6_V.js} +1 -1
- package/dist/assets/{IntegrationsPanel-DiW8UeG5.js → IntegrationsPanel-C9hWD7mO.js} +2 -2
- package/dist/assets/{LogViewerModal-CGW8yajP.js → LogViewerModal-DB0xx-oB.js} +1 -1
- package/dist/assets/{MonitoringModal-BfsYrF1j.js → MonitoringModal-BspW74kP.js} +1 -1
- package/dist/assets/{PM2LogsModal-BJytXxKY.js → PM2LogsModal-Cz4GZtyl.js} +1 -1
- package/dist/assets/{RestoreArchivedAreaModal-CtRiwwzT.js → RestoreArchivedAreaModal-KCCSJy3B.js} +1 -1
- package/dist/assets/{SaveSnapshotModal-BHBdh1dK.js → SaveSnapshotModal-DqZ1JedM.js} +1 -1
- package/dist/assets/{Scene2DCanvas-BYUuUYur.js → Scene2DCanvas-MRhWT6EA.js} +1 -1
- package/dist/assets/{SceneManager-u4hiSYdk.js → SceneManager-DggU0iAh.js} +1 -1
- package/dist/assets/{SkillsPanel-D4IHFehE.js → SkillsPanel-DZC0Im2z.js} +1 -1
- package/dist/assets/{SnapshotManager-Cys1dllC.js → SnapshotManager-3LQMRFLh.js} +1 -1
- package/dist/assets/{SpawnModal-DUK7X8ql.js → SpawnModal-C_e6q2uv.js} +1 -1
- package/dist/assets/{SubordinateAssignmentModal-DeH34tA3.js → SubordinateAssignmentModal-BZdSk9WL.js} +1 -1
- package/dist/assets/{SupervisorPanel-D0c7Kkzt.js → SupervisorPanel-CxId5lI7.js} +1 -1
- package/dist/assets/{TriggerManagerPanel-RsbYDmIC.js → TriggerManagerPanel-BCzGGCPD.js} +1 -1
- package/dist/assets/{WorkflowEditorPanel-lpYmT8iN.js → WorkflowEditorPanel-BmNCGmxP.js} +1 -1
- package/dist/assets/{index-BqPgrat9.js → index-8WVMR823.js} +1 -1
- package/dist/assets/{index-t5WzFf-W.js → index-B8SWRPUd.js} +1 -1
- package/dist/assets/{index-BexCA27h.js → index-Bhb-rse9.js} +3 -3
- package/dist/assets/{index-BQdQ0iv_.js → index-C9B8kaWK.js} +1 -1
- package/dist/assets/{index-BOY5J4U4.js → index-COBkxsEU.js} +1 -1
- package/dist/assets/{index-C6GdsxBK.js → index-CcYTUJp1.js} +1 -1
- package/dist/assets/{index-X9qZZBXG.js → index-CvJuv-ho.js} +2 -2
- package/dist/assets/{index-CpwhIgf8.js → index-Sej69v19.js} +1 -1
- package/dist/assets/{main-CrRMpn-n.js → main-6CnCKW13.js} +77 -77
- package/dist/assets/{web-D94DaG2N.js → web-CrUhsC9T.js} +1 -1
- package/dist/assets/{web-XswRIovf.js → web-RTEsf66y.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/src/packages/server/data/index.js +3 -0
- package/dist/src/packages/server/websocket/handlers/agent-handler.js +3 -0
- package/package.json +1 -1
- package/dist/assets/ControlsModal-BzBzF0Cw.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as J,a as Z,r as n,s as b,j as e,D as re,b as le,c as ce,d as ie,g as de,e as oe,Q as ue,R as be}from"./main-CrRMpn-n.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const me=({building:a,connections:p,activeConnectionId:l,activeDatabase:i,collapsed:y,onToggleCollapse:x,onConnectionChange:$,onDatabaseChange:N,onInsertTable:Q,onSelectTableQuery:P})=>{const{t:d}=J(["terminal"]),w=Z(a.id),[M,r]=n.useState(new Set),[o,v]=n.useState(""),[S,F]=n.useState(""),[H,k]=n.useState(!1),[U,R]=n.useState(null),O=n.useRef(null),q=n.useRef(null),A=n.useRef(null),j=l?w.databases.get(l)??[]:[],G=l&&i?`${l}:${i}`:"",f=G?w.tables.get(G)??[]:[],_=l?w.connectionStatus.get(l):void 0,D=n.useMemo(()=>{if(!o.trim())return j;const t=o.toLowerCase();return j.filter(u=>u.toLowerCase().includes(t))},[j,o]),h=n.useMemo(()=>{if(!S.trim())return f;const t=S.toLowerCase();return f.filter(u=>u.name.toLowerCase().includes(t))},[f,S]);n.useEffect(()=>{const t=u=>{q.current&&!q.current.contains(u.target)&&k(!1)};return H&&document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[H]),n.useEffect(()=>{l&&!_&&b.testDatabaseConnection(a.id,l)},[a.id,l,_]),n.useEffect(()=>{l&&(_!=null&&_.connected)&&j.length===0&&b.listDatabases(a.id,l)},[a.id,l,_==null?void 0:_.connected,j.length]),n.useEffect(()=>{l&&i&&f.length===0&&b.listTables(a.id,l,i)},[a.id,l,i,f.length]),n.useEffect(()=>{R(null),F("")},[l,i]);const C=n.useCallback(t=>{r(u=>{const g=new Set(u);if(g.has(t))g.delete(t);else if(g.add(t),l&&i){const T=`${l}:${i}:${t}`;w.tableSchemas.has(T)||b.getTableSchema(a.id,l,i,t)}return g})},[a.id,l,i,w.tableSchemas]),K=t=>{if(!l||!i)return null;const u=`${l}:${i}:${t}`;return w.tableSchemas.get(u)};return y?e.jsx("div",{className:"database-sidebar database-sidebar--collapsed",children:e.jsx("button",{className:"database-sidebar__toggle",onClick:x,title:d("terminal:database.expandSidebar"),children:"»"})}):e.jsxs("div",{className:"database-sidebar",children:[e.jsxs("div",{className:"database-sidebar__header",children:[e.jsx("span",{children:d("terminal:database.explorer")}),e.jsx("button",{className:"database-sidebar__toggle",onClick:x,title:d("terminal:database.collapseSidebar"),children:"«"})]}),e.jsxs("div",{className:"database-sidebar__section",children:[e.jsx("div",{className:"database-sidebar__section-title",children:d("terminal:database.connection")}),e.jsx("select",{className:"database-sidebar__select",value:l||"",onChange:t=>$(t.target.value),children:p.length===0?e.jsx("option",{value:"",children:d("terminal:database.noConnections")}):p.map(t=>{var u;return e.jsxs("option",{value:t.id,children:[((u=re[t.engine])==null?void 0:u.icon)??"🗄️"," ",t.name]},t.id)})}),_&&e.jsx("div",{className:`database-sidebar__status ${_.connected?"database-sidebar__status--connected":"database-sidebar__status--error"}`,children:_.connected?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"database-sidebar__status-icon",children:"✓"}),d("terminal:database.connected"),_.serverVersion&&e.jsxs("span",{className:"database-sidebar__version",children:["(",_.serverVersion,")"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"database-sidebar__status-icon",children:"✗"}),_.error||d("terminal:database.disconnected")]})})]}),j.length>0&&e.jsxs("div",{className:"database-sidebar__section",children:[e.jsx("div",{className:"database-sidebar__section-title",children:d("terminal:database.databaseTitle")}),e.jsxs("div",{className:"database-sidebar__searchable-select",ref:q,children:[e.jsx("input",{ref:O,className:"database-sidebar__search-input",type:"text",value:H?o:i||"",placeholder:d("terminal:database.selectDatabase"),onChange:t=>{v(t.target.value),H||k(!0)},onFocus:()=>{k(!0),v("")},onKeyDown:t=>{var u,g;t.key==="Escape"?(k(!1),v(""),(u=O.current)==null||u.blur()):t.key==="Enter"&&D.length===1&&(N(D[0]),k(!1),v(""),(g=O.current)==null||g.blur())}}),H&&e.jsx("div",{className:"database-sidebar__dropdown",children:D.length===0?e.jsx("div",{className:"database-sidebar__dropdown-empty",children:"No matches"}):D.map(t=>e.jsx("div",{className:`database-sidebar__dropdown-item ${t===i?"database-sidebar__dropdown-item--active":""}`,onMouseDown:u=>{u.preventDefault(),N(t),k(!1),v("")},children:t},t))})]})]}),f.length>0&&e.jsxs("div",{className:"database-sidebar__section database-sidebar__section--tables",children:[e.jsx("div",{className:"database-sidebar__section-title",children:S.trim()?d("terminal:database.tablesCount",{count:h.length})+` / ${f.length}`:d("terminal:database.tablesCount",{count:f.length})}),e.jsxs("div",{className:"database-sidebar__table-filter",children:[e.jsx("input",{ref:A,className:"database-sidebar__table-filter-input",type:"text",value:S,placeholder:d("terminal:database.filterTables"),onChange:t=>F(t.target.value),onKeyDown:t=>{var u;t.key==="Escape"&&(S?F(""):(u=A.current)==null||u.blur(),t.stopPropagation())}}),S&&e.jsx("button",{className:"database-sidebar__table-filter-clear",onClick:()=>{var t;F(""),(t=A.current)==null||t.focus()},title:"Clear filter",children:"×"})]}),e.jsxs("div",{className:"database-sidebar__tables",children:[S.trim()&&h.length===0&&e.jsx("div",{className:"database-sidebar__tables-empty",children:d("terminal:database.noTablesMatch")}),h.map(t=>{const u=M.has(t.name),g=u?K(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:()=>C(t.name),title:u?"Collapse table schema":"Expand table schema",children:u?"▼":"▶"}),e.jsx("span",{className:"database-sidebar__table-icon",children:t.type==="view"?"👁":"📋"}),e.jsx("span",{className:`database-sidebar__table-name ${U===t.name?"database-sidebar__table-name--selected":""}`,onClick:()=>R(t.name),onDoubleClick:()=>{R(t.name),P(t.name)},children:t.name}),e.jsx("button",{className:"database-sidebar__table-insert",onClick:T=>{T.stopPropagation(),Q(t.name)},title:d("terminal:database.insertTableName"),children:"+"})]}),u&&g&&e.jsx("div",{className:"database-sidebar__table-columns",children:g.columns.map(T=>e.jsxs("div",{className:"database-sidebar__column",onClick:()=>Q(T.name),title:`${T.type}${T.nullable?" NULL":" NOT NULL"}${T.primaryKey?" PK":""}`,children:[e.jsx("span",{className:"database-sidebar__column-icon",children:T.primaryKey?"🔑":""}),e.jsx("span",{className:"database-sidebar__column-name",children:T.name}),e.jsx("span",{className:"database-sidebar__column-type",children:T.type})]},T.name))})]},t.name)})]})]})]})},he=({buildingId:a,history:p,onLoadQuery:l})=>{const{t:i}=J(["terminal"]),[y,x]=n.useState(""),[$,N]=n.useState(!1),Q=n.useMemo(()=>{let r=p;if($&&(r=r.filter(o=>o.favorite)),y.trim()){const o=y.toLowerCase();r=r.filter(v=>v.query.toLowerCase().includes(o)||v.database.toLowerCase().includes(o))}return r},[p,$,y]),P=r=>{const o=new Date(r),S=new Date().getTime()-o.getTime();return S<1440*60*1e3?o.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):S<10080*60*1e3?o.toLocaleDateString([],{weekday:"short"})+" "+o.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):o.toLocaleDateString([],{month:"short",day:"numeric"})},d=n.useCallback((r,o)=>{o.stopPropagation(),b.toggleQueryFavorite(a,r)},[a]),w=n.useCallback((r,o)=>{o.stopPropagation(),b.deleteQueryFromHistory(a,r)},[a]),M=n.useCallback(()=>{confirm(i("terminal:database.confirmClearHistory"))&&b.clearQueryHistory(a)},[a,i]);return p.length===0?e.jsxs("div",{className:"query-history query-history--empty",children:[e.jsx("p",{children:i("terminal:database.noHistory")}),e.jsx("p",{children:i("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:i("terminal:database.searchQueries"),value:y,onChange:r=>x(r.target.value)}),e.jsxs("label",{className:"query-history__filter",children:[e.jsx("input",{type:"checkbox",checked:$,onChange:r=>N(r.target.checked)}),i("terminal:database.favoritesOnly")]}),e.jsx("button",{className:"query-history__clear",onClick:M,title:i("terminal:database.clearAll"),children:i("terminal:database.clearAll")})]}),e.jsxs("div",{className:"query-history__list",children:[Q.map(r=>e.jsxs("div",{className:`query-history__item ${r.status==="error"?"query-history__item--error":""}`,onClick:()=>l(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:r.status==="success"?"✓":"✗"}),e.jsx("span",{className:"query-history__database",children:r.database}),e.jsx("span",{className:"query-history__date",children:P(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:i("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:o=>d(r.id,o),title:r.favorite?i("terminal:database.removeFromFavorites"):i("terminal:database.addToFavorites"),children:r.favorite?"★":"☆"}),e.jsx("button",{className:"query-history__delete",onClick:o=>w(r.id,o),title:i("terminal:database.deleteFromHistory"),children:"🗑"})]})]},r.id)),Q.length===0&&e.jsx("div",{className:"query-history__no-results",children:i("terminal:database.noQueriesMatch")})]})]})},_e=({tabs:a,activeTabId:p,onTabClick:l,onTabClose:i})=>{const{t:y}=J(["terminal"]);return e.jsx("div",{className:"database-tabs",children:a.map(x=>e.jsxs("div",{className:`database-tabs__tab ${p===x.id?"database-tabs__tab--active":""}`,children:[e.jsxs("button",{className:"database-tabs__tab-label",onClick:()=>l(x),title:`${x.connectionName} / ${x.database}`,children:[x.database,e.jsx("span",{className:"database-tabs__tab-connection",children:x.connectionName})]}),e.jsx("button",{className:"database-tabs__tab-close",onClick:()=>i(x.id),title:y("terminal:database.closeTab"),"aria-label":`Close ${x.database} tab`,children:"×"})]},x.id))})},I=a=>`db-panel-${a}`;function pe(a){try{const p=localStorage.getItem(I(a));return p?JSON.parse(p):{}}catch{return{}}}function xe(a,p){try{localStorage.setItem(I(a),JSON.stringify(p))}catch{}}const ve=({building:a,onClose:p})=>{var B,Y,W,X;const{t:l}=J(["terminal","common"]),i=Z(a.id),y=le(a.id),x=ce(a.id),$=ie(a.id),N=n.useRef(pe(a.id)),Q=n.useRef(null),P=n.useRef(0),d=((B=a.database)==null?void 0:B.connections)??[],w=(s,c)=>`${s}:${c}`,M=s=>s?(N.current.queries??{})[s]??"":N.current.generalQuery??"",[r,o]=n.useState("results"),[v,S]=n.useState(0),[F,H]=n.useState(!1),[k,U]=n.useState(!1),[R,O]=n.useState(()=>(N.current.openTabs??[]).map(c=>{var m;return{id:`${c.connectionId}:${c.database}`,connectionId:c.connectionId,connectionName:((m=d.find(L=>L.id===c.connectionId))==null?void 0:m.name)??c.connectionId,database:c.database}})),[q,A]=n.useState(N.current.activeTabId??null),[j,G]=n.useState(()=>{const s=N.current.queries??{};return N.current.generalQuery,s}),[f,_]=n.useState(M(q)),D=n.useCallback(s=>{_(c=>{const m=typeof s=="function"?s(c):s;return G(L=>{const E={...L};return q&&(E[q]=m),E}),m})},[q]),h=i.activeConnectionId??N.current.connectionId??((Y=a.database)==null?void 0:Y.activeConnectionId)??((W=d[0])==null?void 0:W.id),C=i.activeDatabase??N.current.database??((X=a.database)==null?void 0:X.activeDatabase),K=d.find(s=>s.id===h),t=n.useCallback((s,c)=>{var E;const m=w(s,c),L=((E=d.find(z=>z.id===s))==null?void 0:E.name)??s;O(z=>{if(z.some(ne=>ne.id===m))return z;const te={id:m,connectionId:s,connectionName:L,database:c};return[...z,te]}),A(m),_(j[m]??""),b.setActiveConnection(a.id,s),b.setActiveDatabase(a.id,c)},[a.id,d,j]),u=n.useCallback(s=>{O(c=>c.filter(m=>m.id!==s)),q===s&&O(c=>{if(c.length>0){const m=c[0];A(m.id),_(j[m.id]??""),b.setActiveConnection(a.id,m.connectionId),b.setActiveDatabase(a.id,m.database)}else A(null),_("");return c})},[q,a.id,j]),g=n.useCallback(s=>{A(s.id),_(j[s.id]??""),b.setActiveConnection(a.id,s.connectionId),b.setActiveDatabase(a.id,s.database)},[a.id,j]);n.useEffect(()=>{if(!k&&d.length>0){const s=N.current;s.connectionId&&d.some(c=>c.id===s.connectionId)&&(b.setActiveConnection(a.id,s.connectionId),b.listDatabases(a.id,s.connectionId),s.database&&(b.setActiveDatabase(a.id,s.database),b.listTables(a.id,s.connectionId,s.database))),U(!0)}},[a.id,d,k]),n.useEffect(()=>{b.requestQueryHistory(a.id)},[a.id]),n.useEffect(()=>{const s=c=>{c.key==="Escape"&&(c.preventDefault(),c.stopPropagation(),p())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[p]),n.useEffect(()=>{k&&h&&xe(a.id,{connectionId:h,database:C,lastQuery:f,queries:j,generalQuery:"",openTabs:R.map(s=>({connectionId:s.connectionId,database:s.database})),activeTabId:q??void 0})},[a.id,h,C,f,k,R,q,j]);const T=n.useCallback(s=>{var c;if(!(!h||!C||!f.trim()||$))if(s==="cursor"){const m=(c=Q.current)==null?void 0:c.querySelector(".query-editor__textarea"),L=(m==null?void 0:m.selectionStart)??P.current,E=de(f,L);E&&b.executeQuery(a.id,h,C,E)}else{const m=oe(f);m.length<=1?b.executeQuery(a.id,h,C,f.trim()):m.forEach((L,E)=>{setTimeout(()=>{b.executeQuery(a.id,h,C,L.sql)},E*150)})}},[a.id,h,C,f,$]),ee=n.useCallback(s=>{D(s),o("results")},[]),ae=n.useCallback(s=>{b.setActiveConnection(a.id,s),b.listDatabases(a.id,s)},[a.id]),se=n.useCallback(s=>{h&&(t(h,s),b.listTables(a.id,h,s))},[a.id,h,t]),V=y[v];return d.length===0?e.jsxs("div",{className:"database-panel",ref:Q,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("span",{className:"database-panel__name",children:a.name})]}),e.jsx("button",{className:"database-panel__close",onClick:p,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("h3",{children:l("terminal:database.noConnections")}),e.jsx("p",{children:l("terminal:database.noConnectionsDesc")}),e.jsx("p",{children:l("terminal:database.toGetStarted")}),e.jsxs("ol",{children:[e.jsx("li",{children:l("terminal:database.step1Close")}),e.jsx("li",{children:l("terminal:database.step2Settings")}),e.jsx("li",{children:l("terminal:database.step3AddConnection")}),e.jsx("li",{children:l("terminal:database.step4Reopen")})]})]})})]}):e.jsxs("div",{className:"database-panel",ref:Q,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:(K==null?void 0:K.engine)==="mysql"?"🐬":"🐘"}),e.jsx("span",{className:"database-panel__name",children:a.name}),K&&e.jsxs("span",{className:"database-panel__connection-info",children:[K.name," / ",C||l("terminal:database.noDatabaseSelected")]})]}),e.jsx("button",{className:"database-panel__close",onClick:p,children:"×"})]}),e.jsxs("div",{className:"database-panel__body",children:[e.jsx(me,{building:a,connections:d,activeConnectionId:h,activeDatabase:C,collapsed:F,onToggleCollapse:()=>H(!F),onConnectionChange:ae,onDatabaseChange:se,onInsertTable:s=>D(c=>c+` ${s}`),onSelectTableQuery:s=>{const c=`SELECT * FROM ${s}`;D(c),h&&C&&b.executeQuery(a.id,h,C,c)}}),e.jsxs("div",{className:"database-panel__main",children:[R.length>0&&e.jsx(_e,{tabs:R,activeTabId:q,onTabClick:g,onTabClose:u}),e.jsx(ue,{query:f,onChange:D,onExecute:T,isExecuting:$,disabled:!h||!C}),e.jsxs("div",{className:"database-panel__tabs",children:[e.jsxs("button",{className:`database-panel__tab ${r==="results"?"database-panel__tab--active":""}`,onClick:()=>o("results"),children:[l("terminal:database.results"),y.length>0&&e.jsx("span",{className:"database-panel__tab-badge",children:y.length})]}),e.jsxs("button",{className:`database-panel__tab ${r==="history"?"database-panel__tab--active":""}`,onClick:()=>o("history"),children:[l("terminal:database.history"),x.length>0&&e.jsx("span",{className:"database-panel__tab-badge",children:x.length})]}),r==="results"&&y.length>1&&e.jsxs("div",{className:"database-panel__result-nav",children:[e.jsxs("button",{disabled:v>=y.length-1,onClick:()=>S(s=>s+1),children:["← ",l("terminal:database.older")]}),e.jsxs("span",{children:[v+1," / ",y.length]}),e.jsxs("button",{disabled:v<=0,onClick:()=>S(s=>s-1),children:[l("terminal:database.newer")," →"]})]})]}),e.jsx("div",{className:"database-panel__tab-content",children:r==="results"?V?e.jsx(be,{result:V,buildingId:a.id,building:a}):e.jsxs("div",{className:"database-panel__empty",children:[e.jsx("p",{children:l("terminal:database.noResultsYet")}),e.jsx("p",{children:l("terminal:database.selectDbAndRun")})]}):e.jsx(he,{buildingId:a.id,history:x,onLoadQuery:ee})})]})]})]})};export{ve as DatabasePanel,me as DatabaseSidebar,_e as DatabaseTabs,ue as QueryEditor,he as QueryHistoryPanel,be as ResultsTable};
|
|
1
|
+
import{u as J,a as Z,r as n,s as b,j as e,D as re,b as le,c as ce,d as ie,g as de,e as oe,Q as ue,R as be}from"./main-6CnCKW13.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const me=({building:a,connections:p,activeConnectionId:l,activeDatabase:i,collapsed:y,onToggleCollapse:x,onConnectionChange:$,onDatabaseChange:N,onInsertTable:Q,onSelectTableQuery:P})=>{const{t:d}=J(["terminal"]),w=Z(a.id),[M,r]=n.useState(new Set),[o,v]=n.useState(""),[S,F]=n.useState(""),[H,k]=n.useState(!1),[U,R]=n.useState(null),O=n.useRef(null),q=n.useRef(null),A=n.useRef(null),j=l?w.databases.get(l)??[]:[],G=l&&i?`${l}:${i}`:"",f=G?w.tables.get(G)??[]:[],_=l?w.connectionStatus.get(l):void 0,D=n.useMemo(()=>{if(!o.trim())return j;const t=o.toLowerCase();return j.filter(u=>u.toLowerCase().includes(t))},[j,o]),h=n.useMemo(()=>{if(!S.trim())return f;const t=S.toLowerCase();return f.filter(u=>u.name.toLowerCase().includes(t))},[f,S]);n.useEffect(()=>{const t=u=>{q.current&&!q.current.contains(u.target)&&k(!1)};return H&&document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[H]),n.useEffect(()=>{l&&!_&&b.testDatabaseConnection(a.id,l)},[a.id,l,_]),n.useEffect(()=>{l&&(_!=null&&_.connected)&&j.length===0&&b.listDatabases(a.id,l)},[a.id,l,_==null?void 0:_.connected,j.length]),n.useEffect(()=>{l&&i&&f.length===0&&b.listTables(a.id,l,i)},[a.id,l,i,f.length]),n.useEffect(()=>{R(null),F("")},[l,i]);const C=n.useCallback(t=>{r(u=>{const g=new Set(u);if(g.has(t))g.delete(t);else if(g.add(t),l&&i){const T=`${l}:${i}:${t}`;w.tableSchemas.has(T)||b.getTableSchema(a.id,l,i,t)}return g})},[a.id,l,i,w.tableSchemas]),K=t=>{if(!l||!i)return null;const u=`${l}:${i}:${t}`;return w.tableSchemas.get(u)};return y?e.jsx("div",{className:"database-sidebar database-sidebar--collapsed",children:e.jsx("button",{className:"database-sidebar__toggle",onClick:x,title:d("terminal:database.expandSidebar"),children:"»"})}):e.jsxs("div",{className:"database-sidebar",children:[e.jsxs("div",{className:"database-sidebar__header",children:[e.jsx("span",{children:d("terminal:database.explorer")}),e.jsx("button",{className:"database-sidebar__toggle",onClick:x,title:d("terminal:database.collapseSidebar"),children:"«"})]}),e.jsxs("div",{className:"database-sidebar__section",children:[e.jsx("div",{className:"database-sidebar__section-title",children:d("terminal:database.connection")}),e.jsx("select",{className:"database-sidebar__select",value:l||"",onChange:t=>$(t.target.value),children:p.length===0?e.jsx("option",{value:"",children:d("terminal:database.noConnections")}):p.map(t=>{var u;return e.jsxs("option",{value:t.id,children:[((u=re[t.engine])==null?void 0:u.icon)??"🗄️"," ",t.name]},t.id)})}),_&&e.jsx("div",{className:`database-sidebar__status ${_.connected?"database-sidebar__status--connected":"database-sidebar__status--error"}`,children:_.connected?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"database-sidebar__status-icon",children:"✓"}),d("terminal:database.connected"),_.serverVersion&&e.jsxs("span",{className:"database-sidebar__version",children:["(",_.serverVersion,")"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"database-sidebar__status-icon",children:"✗"}),_.error||d("terminal:database.disconnected")]})})]}),j.length>0&&e.jsxs("div",{className:"database-sidebar__section",children:[e.jsx("div",{className:"database-sidebar__section-title",children:d("terminal:database.databaseTitle")}),e.jsxs("div",{className:"database-sidebar__searchable-select",ref:q,children:[e.jsx("input",{ref:O,className:"database-sidebar__search-input",type:"text",value:H?o:i||"",placeholder:d("terminal:database.selectDatabase"),onChange:t=>{v(t.target.value),H||k(!0)},onFocus:()=>{k(!0),v("")},onKeyDown:t=>{var u,g;t.key==="Escape"?(k(!1),v(""),(u=O.current)==null||u.blur()):t.key==="Enter"&&D.length===1&&(N(D[0]),k(!1),v(""),(g=O.current)==null||g.blur())}}),H&&e.jsx("div",{className:"database-sidebar__dropdown",children:D.length===0?e.jsx("div",{className:"database-sidebar__dropdown-empty",children:"No matches"}):D.map(t=>e.jsx("div",{className:`database-sidebar__dropdown-item ${t===i?"database-sidebar__dropdown-item--active":""}`,onMouseDown:u=>{u.preventDefault(),N(t),k(!1),v("")},children:t},t))})]})]}),f.length>0&&e.jsxs("div",{className:"database-sidebar__section database-sidebar__section--tables",children:[e.jsx("div",{className:"database-sidebar__section-title",children:S.trim()?d("terminal:database.tablesCount",{count:h.length})+` / ${f.length}`:d("terminal:database.tablesCount",{count:f.length})}),e.jsxs("div",{className:"database-sidebar__table-filter",children:[e.jsx("input",{ref:A,className:"database-sidebar__table-filter-input",type:"text",value:S,placeholder:d("terminal:database.filterTables"),onChange:t=>F(t.target.value),onKeyDown:t=>{var u;t.key==="Escape"&&(S?F(""):(u=A.current)==null||u.blur(),t.stopPropagation())}}),S&&e.jsx("button",{className:"database-sidebar__table-filter-clear",onClick:()=>{var t;F(""),(t=A.current)==null||t.focus()},title:"Clear filter",children:"×"})]}),e.jsxs("div",{className:"database-sidebar__tables",children:[S.trim()&&h.length===0&&e.jsx("div",{className:"database-sidebar__tables-empty",children:d("terminal:database.noTablesMatch")}),h.map(t=>{const u=M.has(t.name),g=u?K(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:()=>C(t.name),title:u?"Collapse table schema":"Expand table schema",children:u?"▼":"▶"}),e.jsx("span",{className:"database-sidebar__table-icon",children:t.type==="view"?"👁":"📋"}),e.jsx("span",{className:`database-sidebar__table-name ${U===t.name?"database-sidebar__table-name--selected":""}`,onClick:()=>R(t.name),onDoubleClick:()=>{R(t.name),P(t.name)},children:t.name}),e.jsx("button",{className:"database-sidebar__table-insert",onClick:T=>{T.stopPropagation(),Q(t.name)},title:d("terminal:database.insertTableName"),children:"+"})]}),u&&g&&e.jsx("div",{className:"database-sidebar__table-columns",children:g.columns.map(T=>e.jsxs("div",{className:"database-sidebar__column",onClick:()=>Q(T.name),title:`${T.type}${T.nullable?" NULL":" NOT NULL"}${T.primaryKey?" PK":""}`,children:[e.jsx("span",{className:"database-sidebar__column-icon",children:T.primaryKey?"🔑":""}),e.jsx("span",{className:"database-sidebar__column-name",children:T.name}),e.jsx("span",{className:"database-sidebar__column-type",children:T.type})]},T.name))})]},t.name)})]})]})]})},he=({buildingId:a,history:p,onLoadQuery:l})=>{const{t:i}=J(["terminal"]),[y,x]=n.useState(""),[$,N]=n.useState(!1),Q=n.useMemo(()=>{let r=p;if($&&(r=r.filter(o=>o.favorite)),y.trim()){const o=y.toLowerCase();r=r.filter(v=>v.query.toLowerCase().includes(o)||v.database.toLowerCase().includes(o))}return r},[p,$,y]),P=r=>{const o=new Date(r),S=new Date().getTime()-o.getTime();return S<1440*60*1e3?o.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):S<10080*60*1e3?o.toLocaleDateString([],{weekday:"short"})+" "+o.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):o.toLocaleDateString([],{month:"short",day:"numeric"})},d=n.useCallback((r,o)=>{o.stopPropagation(),b.toggleQueryFavorite(a,r)},[a]),w=n.useCallback((r,o)=>{o.stopPropagation(),b.deleteQueryFromHistory(a,r)},[a]),M=n.useCallback(()=>{confirm(i("terminal:database.confirmClearHistory"))&&b.clearQueryHistory(a)},[a,i]);return p.length===0?e.jsxs("div",{className:"query-history query-history--empty",children:[e.jsx("p",{children:i("terminal:database.noHistory")}),e.jsx("p",{children:i("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:i("terminal:database.searchQueries"),value:y,onChange:r=>x(r.target.value)}),e.jsxs("label",{className:"query-history__filter",children:[e.jsx("input",{type:"checkbox",checked:$,onChange:r=>N(r.target.checked)}),i("terminal:database.favoritesOnly")]}),e.jsx("button",{className:"query-history__clear",onClick:M,title:i("terminal:database.clearAll"),children:i("terminal:database.clearAll")})]}),e.jsxs("div",{className:"query-history__list",children:[Q.map(r=>e.jsxs("div",{className:`query-history__item ${r.status==="error"?"query-history__item--error":""}`,onClick:()=>l(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:r.status==="success"?"✓":"✗"}),e.jsx("span",{className:"query-history__database",children:r.database}),e.jsx("span",{className:"query-history__date",children:P(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:i("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:o=>d(r.id,o),title:r.favorite?i("terminal:database.removeFromFavorites"):i("terminal:database.addToFavorites"),children:r.favorite?"★":"☆"}),e.jsx("button",{className:"query-history__delete",onClick:o=>w(r.id,o),title:i("terminal:database.deleteFromHistory"),children:"🗑"})]})]},r.id)),Q.length===0&&e.jsx("div",{className:"query-history__no-results",children:i("terminal:database.noQueriesMatch")})]})]})},_e=({tabs:a,activeTabId:p,onTabClick:l,onTabClose:i})=>{const{t:y}=J(["terminal"]);return e.jsx("div",{className:"database-tabs",children:a.map(x=>e.jsxs("div",{className:`database-tabs__tab ${p===x.id?"database-tabs__tab--active":""}`,children:[e.jsxs("button",{className:"database-tabs__tab-label",onClick:()=>l(x),title:`${x.connectionName} / ${x.database}`,children:[x.database,e.jsx("span",{className:"database-tabs__tab-connection",children:x.connectionName})]}),e.jsx("button",{className:"database-tabs__tab-close",onClick:()=>i(x.id),title:y("terminal:database.closeTab"),"aria-label":`Close ${x.database} tab`,children:"×"})]},x.id))})},I=a=>`db-panel-${a}`;function pe(a){try{const p=localStorage.getItem(I(a));return p?JSON.parse(p):{}}catch{return{}}}function xe(a,p){try{localStorage.setItem(I(a),JSON.stringify(p))}catch{}}const ve=({building:a,onClose:p})=>{var B,Y,W,X;const{t:l}=J(["terminal","common"]),i=Z(a.id),y=le(a.id),x=ce(a.id),$=ie(a.id),N=n.useRef(pe(a.id)),Q=n.useRef(null),P=n.useRef(0),d=((B=a.database)==null?void 0:B.connections)??[],w=(s,c)=>`${s}:${c}`,M=s=>s?(N.current.queries??{})[s]??"":N.current.generalQuery??"",[r,o]=n.useState("results"),[v,S]=n.useState(0),[F,H]=n.useState(!1),[k,U]=n.useState(!1),[R,O]=n.useState(()=>(N.current.openTabs??[]).map(c=>{var m;return{id:`${c.connectionId}:${c.database}`,connectionId:c.connectionId,connectionName:((m=d.find(L=>L.id===c.connectionId))==null?void 0:m.name)??c.connectionId,database:c.database}})),[q,A]=n.useState(N.current.activeTabId??null),[j,G]=n.useState(()=>{const s=N.current.queries??{};return N.current.generalQuery,s}),[f,_]=n.useState(M(q)),D=n.useCallback(s=>{_(c=>{const m=typeof s=="function"?s(c):s;return G(L=>{const E={...L};return q&&(E[q]=m),E}),m})},[q]),h=i.activeConnectionId??N.current.connectionId??((Y=a.database)==null?void 0:Y.activeConnectionId)??((W=d[0])==null?void 0:W.id),C=i.activeDatabase??N.current.database??((X=a.database)==null?void 0:X.activeDatabase),K=d.find(s=>s.id===h),t=n.useCallback((s,c)=>{var E;const m=w(s,c),L=((E=d.find(z=>z.id===s))==null?void 0:E.name)??s;O(z=>{if(z.some(ne=>ne.id===m))return z;const te={id:m,connectionId:s,connectionName:L,database:c};return[...z,te]}),A(m),_(j[m]??""),b.setActiveConnection(a.id,s),b.setActiveDatabase(a.id,c)},[a.id,d,j]),u=n.useCallback(s=>{O(c=>c.filter(m=>m.id!==s)),q===s&&O(c=>{if(c.length>0){const m=c[0];A(m.id),_(j[m.id]??""),b.setActiveConnection(a.id,m.connectionId),b.setActiveDatabase(a.id,m.database)}else A(null),_("");return c})},[q,a.id,j]),g=n.useCallback(s=>{A(s.id),_(j[s.id]??""),b.setActiveConnection(a.id,s.connectionId),b.setActiveDatabase(a.id,s.database)},[a.id,j]);n.useEffect(()=>{if(!k&&d.length>0){const s=N.current;s.connectionId&&d.some(c=>c.id===s.connectionId)&&(b.setActiveConnection(a.id,s.connectionId),b.listDatabases(a.id,s.connectionId),s.database&&(b.setActiveDatabase(a.id,s.database),b.listTables(a.id,s.connectionId,s.database))),U(!0)}},[a.id,d,k]),n.useEffect(()=>{b.requestQueryHistory(a.id)},[a.id]),n.useEffect(()=>{const s=c=>{c.key==="Escape"&&(c.preventDefault(),c.stopPropagation(),p())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[p]),n.useEffect(()=>{k&&h&&xe(a.id,{connectionId:h,database:C,lastQuery:f,queries:j,generalQuery:"",openTabs:R.map(s=>({connectionId:s.connectionId,database:s.database})),activeTabId:q??void 0})},[a.id,h,C,f,k,R,q,j]);const T=n.useCallback(s=>{var c;if(!(!h||!C||!f.trim()||$))if(s==="cursor"){const m=(c=Q.current)==null?void 0:c.querySelector(".query-editor__textarea"),L=(m==null?void 0:m.selectionStart)??P.current,E=de(f,L);E&&b.executeQuery(a.id,h,C,E)}else{const m=oe(f);m.length<=1?b.executeQuery(a.id,h,C,f.trim()):m.forEach((L,E)=>{setTimeout(()=>{b.executeQuery(a.id,h,C,L.sql)},E*150)})}},[a.id,h,C,f,$]),ee=n.useCallback(s=>{D(s),o("results")},[]),ae=n.useCallback(s=>{b.setActiveConnection(a.id,s),b.listDatabases(a.id,s)},[a.id]),se=n.useCallback(s=>{h&&(t(h,s),b.listTables(a.id,h,s))},[a.id,h,t]),V=y[v];return d.length===0?e.jsxs("div",{className:"database-panel",ref:Q,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("span",{className:"database-panel__name",children:a.name})]}),e.jsx("button",{className:"database-panel__close",onClick:p,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("h3",{children:l("terminal:database.noConnections")}),e.jsx("p",{children:l("terminal:database.noConnectionsDesc")}),e.jsx("p",{children:l("terminal:database.toGetStarted")}),e.jsxs("ol",{children:[e.jsx("li",{children:l("terminal:database.step1Close")}),e.jsx("li",{children:l("terminal:database.step2Settings")}),e.jsx("li",{children:l("terminal:database.step3AddConnection")}),e.jsx("li",{children:l("terminal:database.step4Reopen")})]})]})})]}):e.jsxs("div",{className:"database-panel",ref:Q,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:(K==null?void 0:K.engine)==="mysql"?"🐬":"🐘"}),e.jsx("span",{className:"database-panel__name",children:a.name}),K&&e.jsxs("span",{className:"database-panel__connection-info",children:[K.name," / ",C||l("terminal:database.noDatabaseSelected")]})]}),e.jsx("button",{className:"database-panel__close",onClick:p,children:"×"})]}),e.jsxs("div",{className:"database-panel__body",children:[e.jsx(me,{building:a,connections:d,activeConnectionId:h,activeDatabase:C,collapsed:F,onToggleCollapse:()=>H(!F),onConnectionChange:ae,onDatabaseChange:se,onInsertTable:s=>D(c=>c+` ${s}`),onSelectTableQuery:s=>{const c=`SELECT * FROM ${s}`;D(c),h&&C&&b.executeQuery(a.id,h,C,c)}}),e.jsxs("div",{className:"database-panel__main",children:[R.length>0&&e.jsx(_e,{tabs:R,activeTabId:q,onTabClick:g,onTabClose:u}),e.jsx(ue,{query:f,onChange:D,onExecute:T,isExecuting:$,disabled:!h||!C}),e.jsxs("div",{className:"database-panel__tabs",children:[e.jsxs("button",{className:`database-panel__tab ${r==="results"?"database-panel__tab--active":""}`,onClick:()=>o("results"),children:[l("terminal:database.results"),y.length>0&&e.jsx("span",{className:"database-panel__tab-badge",children:y.length})]}),e.jsxs("button",{className:`database-panel__tab ${r==="history"?"database-panel__tab--active":""}`,onClick:()=>o("history"),children:[l("terminal:database.history"),x.length>0&&e.jsx("span",{className:"database-panel__tab-badge",children:x.length})]}),r==="results"&&y.length>1&&e.jsxs("div",{className:"database-panel__result-nav",children:[e.jsxs("button",{disabled:v>=y.length-1,onClick:()=>S(s=>s+1),children:["← ",l("terminal:database.older")]}),e.jsxs("span",{children:[v+1," / ",y.length]}),e.jsxs("button",{disabled:v<=0,onClick:()=>S(s=>s-1),children:[l("terminal:database.newer")," →"]})]})]}),e.jsx("div",{className:"database-panel__tab-content",children:r==="results"?V?e.jsx(be,{result:V,buildingId:a.id,building:a}):e.jsxs("div",{className:"database-panel__empty",children:[e.jsx("p",{children:l("terminal:database.noResultsYet")}),e.jsx("p",{children:l("terminal:database.selectDbAndRun")})]}):e.jsx(he,{buildingId:a.id,history:x,onLoadQuery:ee})})]})]})]})};export{ve as DatabasePanel,me as DatabaseSidebar,_e as DatabaseTabs,ue as QueryEditor,he as QueryHistoryPanel,be as ResultsTable};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a2 as se,H as ne,J as ie,I as re,b7 as ce,r as g,s as O,b8 as bt,z as pt,u as Mt,j as m}from"./main-CrRMpn-n.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function et(e){return Array.isArray?Array.isArray(e):zt(e)==="[object Array]"}function oe(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function ae(e){return e==null?"":oe(e)}function X(e){return typeof e=="string"}function Qt(e){return typeof e=="number"}function ue(e){return e===!0||e===!1||le(e)&&zt(e)=="[object Boolean]"}function Wt(e){return typeof e=="object"}function le(e){return Wt(e)&&e!==null}function H(e){return e!=null}function gt(e){return!e.trim().length}function zt(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const he="Incorrect 'index' type",de=e=>`Invalid value for key ${e}`,fe=e=>`Pattern length exceeds max of ${e}.`,me=e=>`Missing ${e} property in key`,pe=e=>`Property 'weight' in key '${e}' must be a positive integer`,Rt=Object.prototype.hasOwnProperty;class ge{constructor(t){this._keys=[],this._keyMap={};let s=0;t.forEach(n=>{let i=Vt(n);this._keys.push(i),this._keyMap[i.id]=i,s+=i.weight}),this._keys.forEach(n=>{n.weight/=s})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Vt(e){let t=null,s=null,n=null,i=1,c=null;if(X(e)||et(e))n=e,t=_t(e),s=yt(e);else{if(!Rt.call(e,"name"))throw new Error(me("name"));const o=e.name;if(n=o,Rt.call(e,"weight")&&(i=e.weight,i<=0))throw new Error(pe(o));t=_t(o),s=yt(o),c=e.getFn}return{path:t,id:s,weight:i,src:n,getFn:c}}function _t(e){return et(e)?e:e.split(".")}function yt(e){return et(e)?e.join("."):e}function ye(e,t){let s=[],n=!1;const i=(c,o,a)=>{if(H(c))if(!o[a])s.push(c);else{let u=o[a];const l=c[u];if(!H(l))return;if(a===o.length-1&&(X(l)||Qt(l)||ue(l)))s.push(ae(l));else if(et(l)){n=!0;for(let d=0,h=l.length;d<h;d+=1)i(l[d],o,a+1)}else o.length&&i(l,o,a+1)}};return i(e,X(t)?t.split("."):t,0),n?s:s[0]}const Ae={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},xe={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},Ee={location:0,threshold:.6,distance:100},Ce={useExtendedSearch:!1,getFn:ye,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var p={...xe,...Ae,...Ee,...Ce};const Fe=/[^ ]+/g;function Me(e=1,t=3){const s=new Map,n=Math.pow(10,t);return{get(i){const c=i.match(Fe).length;if(s.has(c))return s.get(c);const o=1/Math.pow(c,.5*e),a=parseFloat(Math.round(o*n)/n);return s.set(c,a),a},clear(){s.clear()}}}class wt{constructor({getFn:t=p.getFn,fieldNormWeight:s=p.fieldNormWeight}={}){this.norm=Me(s,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((s,n)=>{this._keysMap[s.id]=n})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,X(this.docs[0])?this.docs.forEach((t,s)=>{this._addString(t,s)}):this.docs.forEach((t,s)=>{this._addObject(t,s)}),this.norm.clear())}add(t){const s=this.size();X(t)?this._addString(t,s):this._addObject(t,s)}removeAt(t){this.records.splice(t,1);for(let s=t,n=this.size();s<n;s+=1)this.records[s].i-=1}getValueForItemAtKeyId(t,s){return t[this._keysMap[s]]}size(){return this.records.length}_addString(t,s){if(!H(t)||gt(t))return;let n={v:t,i:s,n:this.norm.get(t)};this.records.push(n)}_addObject(t,s){let n={i:s,$:{}};this.keys.forEach((i,c)=>{let o=i.getFn?i.getFn(t):this.getFn(t,i.path);if(H(o)){if(et(o)){let a=[];const u=[{nestedArrIndex:-1,value:o}];for(;u.length;){const{nestedArrIndex:l,value:d}=u.pop();if(H(d))if(X(d)&&!gt(d)){let h={v:d,i:l,n:this.norm.get(d)};a.push(h)}else et(d)&&d.forEach((h,f)=>{u.push({nestedArrIndex:f,value:h})})}n.$[c]=a}else if(X(o)&&!gt(o)){let a={v:o,n:this.norm.get(o)};n.$[c]=a}}}),this.records.push(n)}toJSON(){return{keys:this.keys,records:this.records}}}function Ut(e,t,{getFn:s=p.getFn,fieldNormWeight:n=p.fieldNormWeight}={}){const i=new wt({getFn:s,fieldNormWeight:n});return i.setKeys(e.map(Vt)),i.setSources(t),i.create(),i}function we(e,{getFn:t=p.getFn,fieldNormWeight:s=p.fieldNormWeight}={}){const{keys:n,records:i}=e,c=new wt({getFn:t,fieldNormWeight:s});return c.setKeys(n),c.setIndexRecords(i),c}function ht(e,{errors:t=0,currentLocation:s=0,expectedLocation:n=0,distance:i=p.distance,ignoreLocation:c=p.ignoreLocation}={}){const o=t/e.length;if(c)return o;const a=Math.abs(n-s);return i?o+a/i:a?1:o}function ve(e=[],t=p.minMatchCharLength){let s=[],n=-1,i=-1,c=0;for(let o=e.length;c<o;c+=1){let a=e[c];a&&n===-1?n=c:!a&&n!==-1&&(i=c-1,i-n+1>=t&&s.push([n,i]),n=-1)}return e[c-1]&&c-n>=t&&s.push([n,c-1]),s}const ot=32;function De(e,t,s,{location:n=p.location,distance:i=p.distance,threshold:c=p.threshold,findAllMatches:o=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,includeMatches:u=p.includeMatches,ignoreLocation:l=p.ignoreLocation}={}){if(t.length>ot)throw new Error(fe(ot));const d=t.length,h=e.length,f=Math.max(0,Math.min(n,h));let y=c,C=f;const k=a>1||u,D=k?Array(h):[];let b;for(;(b=e.indexOf(t,C))>-1;){let S=ht(t,{currentLocation:b,expectedLocation:f,distance:i,ignoreLocation:l});if(y=Math.min(S,y),C=b+d,k){let v=0;for(;v<d;)D[b+v]=1,v+=1}}C=-1;let N=[],z=1,Q=d+h;const at=1<<d-1;for(let S=0;S<d;S+=1){let v=0,j=Q;for(;v<j;)ht(t,{errors:S,currentLocation:f+j,expectedLocation:f,distance:i,ignoreLocation:l})<=y?v=j:Q=j,j=Math.floor((Q-v)/2+v);Q=j;let _=Math.max(1,f-j+1),W=o?h:Math.min(f+j,h)+d,K=Array(W+2);K[W+1]=(1<<S)-1;for(let T=W;T>=_;T-=1){let Z=T-1,ct=s[e.charAt(Z)];if(k&&(D[Z]=+!!ct),K[T]=(K[T+1]<<1|1)&ct,S&&(K[T]|=(N[T+1]|N[T])<<1|1|N[T+1]),K[T]&at&&(z=ht(t,{errors:S,currentLocation:Z,expectedLocation:f,distance:i,ignoreLocation:l}),z<=y)){if(y=z,C=Z,C<=f)break;_=Math.max(1,2*f-C)}}if(ht(t,{errors:S+1,currentLocation:f,expectedLocation:f,distance:i,ignoreLocation:l})>y)break;N=K}const st={isMatch:C>=0,score:Math.max(.001,z)};if(k){const S=ve(D,a);S.length?u&&(st.indices=S):st.isMatch=!1}return st}function Se(e){let t={};for(let s=0,n=e.length;s<n;s+=1){const i=e.charAt(s);t[i]=(t[i]||0)|1<<n-s-1}return t}const dt=String.prototype.normalize?(e=>e.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(e=>e);class Gt{constructor(t,{location:s=p.location,threshold:n=p.threshold,distance:i=p.distance,includeMatches:c=p.includeMatches,findAllMatches:o=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,isCaseSensitive:u=p.isCaseSensitive,ignoreDiacritics:l=p.ignoreDiacritics,ignoreLocation:d=p.ignoreLocation}={}){if(this.options={location:s,threshold:n,distance:i,includeMatches:c,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:d},t=u?t:t.toLowerCase(),t=l?dt(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const h=(y,C)=>{this.chunks.push({pattern:y,alphabet:Se(y),startIndex:C})},f=this.pattern.length;if(f>ot){let y=0;const C=f%ot,k=f-C;for(;y<k;)h(this.pattern.substr(y,ot),y),y+=ot;if(C){const D=f-ot;h(this.pattern.substr(D),D)}}else h(this.pattern,0)}searchIn(t){const{isCaseSensitive:s,ignoreDiacritics:n,includeMatches:i}=this.options;if(t=s?t:t.toLowerCase(),t=n?dt(t):t,this.pattern===t){let k={isMatch:!0,score:0};return i&&(k.indices=[[0,t.length-1]]),k}const{location:c,distance:o,threshold:a,findAllMatches:u,minMatchCharLength:l,ignoreLocation:d}=this.options;let h=[],f=0,y=!1;this.chunks.forEach(({pattern:k,alphabet:D,startIndex:b})=>{const{isMatch:N,score:z,indices:Q}=De(t,k,D,{location:c+b,distance:o,threshold:a,findAllMatches:u,minMatchCharLength:l,includeMatches:i,ignoreLocation:d});N&&(y=!0),f+=z,N&&Q&&(h=[...h,...Q])});let C={isMatch:y,score:y?f/this.chunks.length:1};return y&&i&&(C.indices=h),C}}class rt{constructor(t){this.pattern=t}static isMultiMatch(t){return Lt(t,this.multiRegex)}static isSingleMatch(t){return Lt(t,this.singleRegex)}search(){}}function Lt(e,t){const s=e.match(t);return s?s[1]:null}class Be extends rt{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const s=t===this.pattern;return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Ie extends rt{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const n=t.indexOf(this.pattern)===-1;return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}}class ke extends rt{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const s=t.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class $e extends rt{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const s=!t.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}}class be extends rt{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const s=t.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class Re extends rt{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const s=!t.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}}class Yt extends rt{constructor(t,{location:s=p.location,threshold:n=p.threshold,distance:i=p.distance,includeMatches:c=p.includeMatches,findAllMatches:o=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,isCaseSensitive:u=p.isCaseSensitive,ignoreDiacritics:l=p.ignoreDiacritics,ignoreLocation:d=p.ignoreLocation}={}){super(t),this._bitapSearch=new Gt(t,{location:s,threshold:n,distance:i,includeMatches:c,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:d})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class Jt extends rt{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let s=0,n;const i=[],c=this.pattern.length;for(;(n=t.indexOf(this.pattern,s))>-1;)s=n+c,i.push([n,s-1]);const o=!!i.length;return{isMatch:o,score:o?0:1,indices:i}}}const At=[Be,Jt,ke,$e,Re,be,Ie,Yt],Nt=At.length,_e=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Le="|";function Ne(e,t={}){return e.split(Le).map(s=>{let n=s.trim().split(_e).filter(c=>c&&!!c.trim()),i=[];for(let c=0,o=n.length;c<o;c+=1){const a=n[c];let u=!1,l=-1;for(;!u&&++l<Nt;){const d=At[l];let h=d.isMultiMatch(a);h&&(i.push(new d(h,t)),u=!0)}if(!u)for(l=-1;++l<Nt;){const d=At[l];let h=d.isSingleMatch(a);if(h){i.push(new d(h,t));break}}}return i})}const je=new Set([Yt.type,Jt.type]);class Te{constructor(t,{isCaseSensitive:s=p.isCaseSensitive,ignoreDiacritics:n=p.ignoreDiacritics,includeMatches:i=p.includeMatches,minMatchCharLength:c=p.minMatchCharLength,ignoreLocation:o=p.ignoreLocation,findAllMatches:a=p.findAllMatches,location:u=p.location,threshold:l=p.threshold,distance:d=p.distance}={}){this.query=null,this.options={isCaseSensitive:s,ignoreDiacritics:n,includeMatches:i,minMatchCharLength:c,findAllMatches:a,ignoreLocation:o,location:u,threshold:l,distance:d},t=s?t:t.toLowerCase(),t=n?dt(t):t,this.pattern=t,this.query=Ne(this.pattern,this.options)}static condition(t,s){return s.useExtendedSearch}searchIn(t){const s=this.query;if(!s)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:i,ignoreDiacritics:c}=this.options;t=i?t:t.toLowerCase(),t=c?dt(t):t;let o=0,a=[],u=0;for(let l=0,d=s.length;l<d;l+=1){const h=s[l];a.length=0,o=0;for(let f=0,y=h.length;f<y;f+=1){const C=h[f],{isMatch:k,indices:D,score:b}=C.search(t);if(k){if(o+=1,u+=b,n){const N=C.constructor.type;je.has(N)?a=[...a,...D]:a.push(D)}}else{u=0,o=0,a.length=0;break}}if(o){let f={isMatch:!0,score:u/o};return n&&(f.indices=a),f}}return{isMatch:!1,score:1}}}const xt=[];function Pe(...e){xt.push(...e)}function Et(e,t){for(let s=0,n=xt.length;s<n;s+=1){let i=xt[s];if(i.condition(e,t))return new i(e,t)}return new Gt(e,t)}const ft={AND:"$and",OR:"$or"},Ct={PATH:"$path",PATTERN:"$val"},Ft=e=>!!(e[ft.AND]||e[ft.OR]),Ke=e=>!!e[Ct.PATH],Oe=e=>!et(e)&&Wt(e)&&!Ft(e),jt=e=>({[ft.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function Xt(e,t,{auto:s=!0}={}){const n=i=>{let c=Object.keys(i);const o=Ke(i);if(!o&&c.length>1&&!Ft(i))return n(jt(i));if(Oe(i)){const u=o?i[Ct.PATH]:c[0],l=o?i[Ct.PATTERN]:i[u];if(!X(l))throw new Error(de(u));const d={keyId:yt(u),pattern:l};return s&&(d.searcher=Et(l,t)),d}let a={children:[],operator:c[0]};return c.forEach(u=>{const l=i[u];et(l)&&l.forEach(d=>{a.children.push(n(d))})}),a};return Ft(e)||(e=jt(e)),n(e)}function He(e,{ignoreFieldNorm:t=p.ignoreFieldNorm}){e.forEach(s=>{let n=1;s.matches.forEach(({key:i,norm:c,score:o})=>{const a=i?i.weight:null;n*=Math.pow(o===0&&a?Number.EPSILON:o,(a||1)*(t?1:c))}),s.score=n})}function Qe(e,t){const s=e.matches;t.matches=[],H(s)&&s.forEach(n=>{if(!H(n.indices)||!n.indices.length)return;const{indices:i,value:c}=n;let o={indices:i,value:c};n.key&&(o.key=n.key.src),n.idx>-1&&(o.refIndex=n.idx),t.matches.push(o)})}function We(e,t){t.score=e.score}function ze(e,t,{includeMatches:s=p.includeMatches,includeScore:n=p.includeScore}={}){const i=[];return s&&i.push(Qe),n&&i.push(We),e.map(c=>{const{idx:o}=c,a={item:t[o],refIndex:o};return i.length&&i.forEach(u=>{u(c,a)}),a})}class G{constructor(t,s={},n){this.options={...p,...s},this.options.useExtendedSearch,this._keyStore=new ge(this.options.keys),this.setCollection(t,n)}setCollection(t,s){if(this._docs=t,s&&!(s instanceof wt))throw new Error(he);this._myIndex=s||Ut(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){H(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const s=[];for(let n=0,i=this._docs.length;n<i;n+=1){const c=this._docs[n];t(c,n)&&(this.removeAt(n),n-=1,i-=1,s.push(c))}return s}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:s=-1}={}){const{includeMatches:n,includeScore:i,shouldSort:c,sortFn:o,ignoreFieldNorm:a}=this.options;let u=X(t)?X(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return He(u,{ignoreFieldNorm:a}),c&&u.sort(o),Qt(s)&&s>-1&&(u=u.slice(0,s)),ze(u,this._docs,{includeMatches:n,includeScore:i})}_searchStringList(t){const s=Et(t,this.options),{records:n}=this._myIndex,i=[];return n.forEach(({v:c,i:o,n:a})=>{if(!H(c))return;const{isMatch:u,score:l,indices:d}=s.searchIn(c);u&&i.push({item:c,idx:o,matches:[{score:l,value:c,norm:a,indices:d}]})}),i}_searchLogical(t){const s=Xt(t,this.options),n=(a,u,l)=>{if(!a.children){const{keyId:h,searcher:f}=a,y=this._findMatches({key:this._keyStore.get(h),value:this._myIndex.getValueForItemAtKeyId(u,h),searcher:f});return y&&y.length?[{idx:l,item:u,matches:y}]:[]}const d=[];for(let h=0,f=a.children.length;h<f;h+=1){const y=a.children[h],C=n(y,u,l);if(C.length)d.push(...C);else if(a.operator===ft.AND)return[]}return d},i=this._myIndex.records,c={},o=[];return i.forEach(({$:a,i:u})=>{if(H(a)){let l=n(s,a,u);l.length&&(c[u]||(c[u]={idx:u,item:a,matches:[]},o.push(c[u])),l.forEach(({matches:d})=>{c[u].matches.push(...d)}))}}),o}_searchObjectList(t){const s=Et(t,this.options),{keys:n,records:i}=this._myIndex,c=[];return i.forEach(({$:o,i:a})=>{if(!H(o))return;let u=[];n.forEach((l,d)=>{u.push(...this._findMatches({key:l,value:o[d],searcher:s}))}),u.length&&c.push({idx:a,item:o,matches:u})}),c}_findMatches({key:t,value:s,searcher:n}){if(!H(s))return[];let i=[];if(et(s))s.forEach(({v:c,i:o,n:a})=>{if(!H(c))return;const{isMatch:u,score:l,indices:d}=n.searchIn(c);u&&i.push({score:l,key:t,value:c,idx:o,norm:a,indices:d})});else{const{v:c,n:o}=s,{isMatch:a,score:u,indices:l}=n.searchIn(c);a&&i.push({score:u,key:t,value:c,norm:o,indices:l})}return i}}G.version="7.1.0";G.createIndex=Ut;G.parseIndex=we;G.config=p;G.parseQuery=Xt;Pe(Te);const Tt={".ts":"📘",".tsx":"⚛️",".js":"📒",".jsx":"⚛️",".py":"🐍",".rs":"🦀",".go":"🔷",".md":"📝",".json":"📋",".yaml":"⚙️",".yml":"⚙️",".css":"🎨",".scss":"🎨",".html":"🌐",".sql":"🗃️",".sh":"💻",".env":"🔐",".toml":"⚙️",".lock":"🔒",default:"📄"};function Ve(e){var s;const t="."+((s=e.split(".").pop())==null?void 0:s.toLowerCase());return Tt[t]||Tt.default}function Pt(e){const t=se[e];return(t==null?void 0:t.icon)||"🤖"}function Zt(e){const t=Math.floor(e/1e3),s=Math.floor(t/60),n=Math.floor(s/60),i=Math.floor(n/24);return i>0?`${i}d ${n%24}h ago`:n>0?`${n}h ${s%60}m ago`:s>0?`${s}m ago`:"just now"}function Kt(e){const s=Date.now()-e;return Zt(s)}function Ot(e){switch(e){case"agent":return"Agent";case"command":return"Command";case"area":return"Area";case"activity":return"Activity";case"modified-file":return"Changed";case"building":return"Server";default:return e}}const Ht=["command","agent","building","area","modified-file","activity"];function Ue({isOpen:e,onClose:t,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:i,onOpenSupervisor:c,onOpenFileExplorer:o,onOpenPM2LogsModal:a,onOpenBossLogsModal:u,onOpenDatabasePanel:l,onOpenMonitoringModal:d}){const h=ne(),f=ie(),y=re(),C=ce(),k=g.useMemo(()=>{const r=O.getState().supervisor.agentHistories;let A="";for(const[F,M]of r)A+=`${F}:${M.length},`;return A},[h]),D=g.useRef(t);D.current=t;const b=g.useRef(s);b.current=s;const N=g.useRef(n);N.current=n;const z=g.useRef(i);z.current=i;const Q=g.useRef(c);Q.current=c;const at=g.useRef(o);at.current=o;const st=g.useRef(a);st.current=a;const S=g.useRef(u);S.current=u;const v=g.useRef(l);v.current=l;const j=g.useRef(d);j.current=d;const[_,W]=g.useState(""),[K,nt]=g.useState(0);g.useEffect(()=>{if(e){W(""),nt(0);const r=Array.from(h.values());for(const A of r)!O.hasHistoryBeenFetched(A.id)&&!O.isLoadingHistoryForAgent(A.id)&&O.requestAgentSupervisorHistory(A.id)}},[e,h]);const T=O.getShortcuts(),Z=g.useMemo(()=>{if(!e)return[];const r=T.find(F=>F.id==="spawn-agent"),A=T.find(F=>F.id==="toggle-commander");return[{id:"cmd-spawn",type:"command",title:"Spawn New Agent",subtitle:r?bt(r):"Alt+N",icon:"➕",action:()=>{D.current(),b.current()}},{id:"cmd-commander",type:"command",title:"Commander View",subtitle:A?bt(A):"Ctrl+K",icon:"📊",action:()=>{D.current(),N.current()}},{id:"cmd-settings",type:"command",title:"Settings & Tools",subtitle:"Configure Tide Commander",icon:"⚙️",action:()=>{D.current(),z.current()}},{id:"cmd-supervisor",type:"command",title:"Supervisor Overview",subtitle:"View agent analysis",icon:"🎖️",action:()=>{D.current(),Q.current()}},{id:"cmd-monitoring",type:"command",title:"Monitoring & Logs",subtitle:"Triggers, workflows, events",icon:"📊",action:()=>{var F;D.current(),(F=j.current)==null||F.call(j)}}]},[e,T]),ct=g.useMemo(()=>e?Array.from(h.values()).map(r=>{const A=O.getAgentSupervisorHistory(r.id),F=A.length>0?A[0]:null,M=A.map(x=>({text:`${x.analysis.statusDescription} ${x.analysis.recentWorkSummary}`,timestamp:x.timestamp})),$=(C||[]).filter(x=>x.agentId===r.id).map(x=>x.filePath),I=[...new Set($)],R=I.map(x=>x.split("/").pop()||x),B=[];r.lastAssignedTask&&B.push(r.lastAssignedTask);const Y=`${r.class} • ${r.status} • ${r.cwd}`;let J=`${r.name} ${Y}`,L,ut,E;for(const x of M)J+=` ${x.text}`;F&&(L=F.analysis.recentWorkSummary,ut=F.analysis.statusDescription,E=F.timestamp),R.length>0&&(J+=` ${R.join(" ")} ${I.join(" ")}`),B.length>0&&(J+=` ${B.join(" ")}`);const w=Date.now()-r.lastActivity;let U;return r.lastAssignedTask&&(r.lastAssignedTask.length>150?U=r.lastAssignedTask.slice(0,150)+"...":U=r.lastAssignedTask),{id:`agent-${r.id}`,type:"agent",title:r.name,subtitle:Y,lastUserInput:U,statusDescription:ut,activityText:L,matchedText:L,timeAway:w,lastStatusTime:E,icon:Pt(r.class),_searchText:J,_modifiedFiles:I,_userQueries:B,_historyEntries:M,action:()=>{D.current(),O.selectAgent(r.id)}}}):[],[e,h,k,C]),lt=g.useMemo(()=>e?Array.from(f.values()).map(r=>{var A;return{id:`area-${r.id}`,type:"area",title:r.name,subtitle:`${r.assignedAgentIds.length} agents • ${((A=r.directories)==null?void 0:A.length)||0} folders`,icon:"🗺️",action:()=>{D.current(),O.selectArea(r.id)}}}):[],[e,f]),mt=g.useMemo(()=>e?Array.from(y.values()).filter(r=>r.type==="server"||r.type==="boss"||r.type==="database").map(r=>{var R,B,Y,J;const A=r.status==="running"?"🟢":r.status==="stopped"?"🔴":"🟡",F=r.type==="boss"?"👑":r.type==="database"?"🗄️":"🖥️";let $=`${r.type==="boss"?"Boss":r.type==="database"?"Database":"Server"} • ${r.status}`;if(r.type==="database"&&((B=(R=r.database)==null?void 0:R.connections)!=null&&B.length)){const L=r.database.connections[0];$+=` • ${L.engine} @ ${L.host}`}else r.cwd&&($+=` • ${r.cwd}`);let I=`${r.name} ${r.type} ${r.status} ${r.cwd||""} ${((Y=r.pm2)==null?void 0:Y.name)||""}`;if(r.type==="database"&&((J=r.database)!=null&&J.connections))for(const L of r.database.connections)I+=` ${L.name} ${L.engine} ${L.host} ${L.database||""} mysql postgresql sql`;return{id:`building-${r.id}`,type:"building",title:r.name,subtitle:$,icon:`${A} ${F}`,_searchText:I,action:()=>{var L;D.current(),r.type==="boss"?S.current(r.id):r.type==="database"?v.current(r.id):(L=r.pm2)!=null&&L.enabled&&st.current(r.id)}}}):[],[e,y]),vt=g.useMemo(()=>{if(!e)return[];const r=C||[],A=new Set,F=[];for(const M of r){if(A.has(M.filePath))continue;A.add(M.filePath);const $=M.filePath.split("/").pop()||M.filePath,I=M.action==="created"?"Created":M.action==="modified"?"Modified":M.action==="deleted"?"Deleted":"Read";if(F.push({id:`modified-${M.filePath}-${M.timestamp}`,type:"modified-file",title:$,subtitle:`${I} by ${M.agentName} • ${M.filePath}`,matchedText:M.filePath,icon:M.action==="deleted"?"🗑️":Ve(M.filePath),action:()=>{D.current();const R=Array.from(O.getState().areas.values());for(const B of R)for(const Y of B.directories||[])if(M.filePath.startsWith(Y)){O.setFileViewerPath(M.filePath),at.current(B.id);return}O.selectAgent(M.agentId)}}),F.length>=50)break}return F},[e,C]),Dt=g.useMemo(()=>{if(!e)return[];const r=[],A=Array.from(h.values());for(const F of A){const M=O.getAgentSupervisorHistory(F.id);if(M.length>0){const $=M[0],I=$.analysis;r.push({id:`activity-${F.id}-${$.timestamp}`,type:"activity",title:F.name,subtitle:I.statusDescription,activityText:I.recentWorkSummary,matchedText:I.recentWorkSummary,icon:Pt(F.class),action:()=>{D.current(),O.selectAgent(F.id)}})}}return r},[e,h,k]),St=g.useMemo(()=>new G(ct,{keys:["title","subtitle","_searchText","activityText","lastUserInput"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[ct]),Bt=g.useMemo(()=>new G(Z,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[Z]),It=g.useMemo(()=>new G(lt,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[lt]),kt=g.useMemo(()=>new G(vt,{keys:["title","subtitle","matchedText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[vt]),$t=g.useMemo(()=>new G(Dt,{keys:["title","subtitle","matchedText","activityText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[Dt]),qt=g.useMemo(()=>new G(mt,{keys:["title","subtitle","_searchText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[mt]),V=g.useMemo(()=>{if(!_.trim()){const E=[];E.push(...mt);const w=[...ct].sort((x,P)=>{const q=x.timeAway??0,tt=P.timeAway??0;return q-tt});E.push(...w),E.push(...Z.slice(0,2)),E.push(...lt.slice(0,2));const U={};return Ht.forEach((x,P)=>{U[x]=P}),E.sort((x,P)=>(U[x.type]??999)-(U[P.type]??999)),E}const r=_.toLowerCase(),A=St.search(_).slice(0,8),F=Bt.search(_).slice(0,3),M=It.search(_).slice(0,2),$=kt.search(_).slice(0,3),I=$t.search(_).slice(0,3),R=qt.search(_).filter(E=>{const w=E.score??1;return`${E.item.title} ${E.item.subtitle||""} ${E.item._searchText||""}`.toLowerCase().includes(r)||w<=.2}).slice(0,4),B=[],Y=[],J=[];for(const E of A){const w={...E.item};if(w._modifiedFiles&&w._modifiedFiles.length>0){const x=w._modifiedFiles.filter(P=>{var it;const q=((it=P.split("/").pop())==null?void 0:it.toLowerCase())||"",tt=P.toLowerCase();return q.includes(r)||tt.includes(r)});x.length>0&&(w.matchedFiles=x)}if(w._userQueries&&w._userQueries.length>0){const x=w._userQueries.find(P=>P.toLowerCase().includes(r));if(x)if(x.length>200){const q=x.toLowerCase().indexOf(r),tt=Math.max(0,q-60),it=Math.min(x.length,q+r.length+100);w.matchedQuery=(tt>0?"...":"")+x.slice(tt,it)+(it<x.length?"...":"")}else w.matchedQuery=x}if(w._historyEntries&&w._historyEntries.length>0){const x=w._historyEntries.find(P=>P.text.toLowerCase().includes(r));if(x)if(x.text.length>250){const q=x.text.toLowerCase().indexOf(r),tt=Math.max(0,q-80),it=Math.min(x.text.length,q+r.length+120);w.matchedHistory={text:(tt>0?"...":"")+x.text.slice(tt,it)+(it<x.text.length?"...":""),timestamp:x.timestamp}}else w.matchedHistory=x}const U=w.title.toLowerCase();U===r||U.startsWith(r)?Y.push(w):J.push(w)}for(const E of Y)B.push(E);for(const E of R)B.push(E.item);for(const E of J)B.push(E);for(const E of F)B.push(E.item);for(const E of M)B.push(E.item);for(const E of $)B.push(E.item);const L=new Set(A.map(E=>E.item.id));for(const E of I){const w=E.item.id.replace("activity-","").split("-")[0];L.has(`agent-${w}`)||B.push(E.item)}const ut={};return Ht.forEach((E,w)=>{ut[E]=w}),B.sort((E,w)=>(ut[E.type]??999)-(ut[w.type]??999)),B},[_,St,Bt,It,kt,$t,Z,ct,lt]);g.useEffect(()=>{K>=V.length&&nt(Math.max(0,V.length-1))},[V.length,K]);const te=g.useCallback(r=>{if(r.altKey&&!r.ctrlKey&&!r.metaKey&&(r.key==="p"||r.key==="n"||r.key==="P"||r.key==="N")){r.preventDefault(),r.stopPropagation(),r.nativeEvent.stopImmediatePropagation();const A=r.key.toLowerCase();nt(A==="p"?F=>F>0?F-1:V.length-1:F=>F<V.length-1?F+1:0);return}switch(r.key){case"Escape":r.preventDefault(),D.current();break;case"ArrowUp":r.preventDefault(),nt(A=>A>0?A-1:V.length-1);break;case"ArrowDown":r.preventDefault(),nt(A=>A<V.length-1?A+1:0);break;case"Enter":r.preventDefault(),V[K]&&V[K].action();break}},[V,K]),ee=g.useCallback((r,A)=>{if(!A||!r)return r;const F=r.toLowerCase(),M=A.toLowerCase(),$=[];let I=0,R=F.indexOf(M),B=0;for(;R!==-1;)R>I&&$.push(r.slice(I,R)),$.push(pt.createElement("mark",{key:B++,className:"spotlight-highlight"},r.slice(R,R+A.length))),I=R+A.length,R=F.indexOf(M,I);return I<r.length&&$.push(r.slice(I)),$.length>0?pt.createElement(pt.Fragment,null,...$):r},[]);return{query:_,setQuery:W,selectedIndex:K,setSelectedIndex:nt,results:V,handleKeyDown:te,highlightMatch:ee}}const Ge=g.forwardRef(function({query:t,onQueryChange:s,onKeyDown:n,onResetSelection:i},c){const{t:o}=Mt(["common"]);return m.jsxs("div",{className:"spotlight-input-wrapper",children:[m.jsx("span",{className:"spotlight-search-icon",children:"⌘"}),m.jsx("input",{ref:c,type:"text",className:"spotlight-input",placeholder:o("common:search.spotlightPlaceholder"),value:t,onChange:a=>{s(a.target.value),i()},onKeyDown:n,autoFocus:!0,spellCheck:!1}),m.jsxs("div",{className:"spotlight-input-hints",children:[m.jsx("span",{className:"spotlight-shortcut-hint",children:"↑↓"}),m.jsx("span",{className:"spotlight-shortcut-hint",children:"Enter"}),m.jsx("span",{className:"spotlight-shortcut-hint",children:"Esc"})]})]})}),Ye=g.memo(function({result:t,isSelected:s,query:n,highlightMatch:i,onClick:c,onMouseEnter:o}){const a=t.activityText||t.statusDescription||t.matchedFiles&&t.matchedFiles.length>0||t.matchedQuery||t.matchedHistory;return m.jsxs("div",{className:`spotlight-item ${s?"selected":""} ${t.activityText?"has-activity":""}`,onClick:c,onMouseEnter:o,role:"option","aria-selected":s,children:[m.jsx("span",{className:"spotlight-item-icon","aria-hidden":"true",children:t.icon}),m.jsxs("div",{className:"spotlight-item-content",children:[m.jsxs("div",{className:"spotlight-item-header",children:[m.jsx("span",{className:"spotlight-item-title",children:i(t.title,n)}),m.jsx("span",{className:`spotlight-item-type ${t.type}`,"aria-label":Ot(t.type),children:Ot(t.type)})]}),t.subtitle&&m.jsx("span",{className:"spotlight-item-subtitle",children:i(t.subtitle,n)}),t.statusDescription&&m.jsx("span",{className:"spotlight-item-status",children:i(t.statusDescription,n)}),t.activityText&&m.jsx("span",{className:"spotlight-item-activity",children:i(t.activityText,n)}),a&&m.jsxs("div",{className:"spotlight-item-details",children:[t.matchedFiles&&t.matchedFiles.length>0&&m.jsx("span",{className:"spotlight-item-files",children:t.matchedFiles.map((u,l)=>m.jsxs("span",{className:"file-badge",children:[l>0&&m.jsx("span",{className:"file-separator",children:"•"}),i(u.split("/").pop()||u,n)]},u))}),t.matchedQuery&&m.jsx("span",{className:"spotlight-item-query",children:i(t.matchedQuery,n)}),t.matchedHistory&&m.jsxs("span",{className:"spotlight-item-history",children:[i(t.matchedHistory.text,n),m.jsx("span",{className:"spotlight-history-time",children:Kt(t.matchedHistory.timestamp)})]})]}),(t.timeAway!==void 0||t.lastStatusTime!==void 0)&&m.jsxs("span",{className:"spotlight-item-time",children:[t.timeAway!==void 0&&m.jsxs("span",{className:"spotlight-time-away",children:["Idle: ",Zt(t.timeAway)]}),t.lastStatusTime!==void 0&&m.jsxs("span",{className:"spotlight-status-time",children:["Updated ",Kt(t.lastStatusTime)]})]}),t.lastUserInput&&!t.matchedQuery&&m.jsxs("span",{className:"spotlight-item-last-input",children:['"',i(t.lastUserInput,n),'"']})]})]})}),Je=g.forwardRef(function({results:t,selectedIndex:s,query:n,highlightMatch:i,onSelectIndex:c},o){const{t:a}=Mt(["terminal"]),u=g.useRef(!1);g.useEffect(()=>{u.current=!1},[t]),g.useEffect(()=>{const h=typeof o=="function"?null:o==null?void 0:o.current;if(!h)return;const f=()=>{u.current=!0};return h.addEventListener("mousemove",f),()=>{h.removeEventListener("mousemove",f)}},[o,t]);const l={command:a("terminal:spotlight.categories.commands"),agent:a("terminal:spotlight.categories.agents"),building:a("terminal:spotlight.categories.infrastructure"),area:a("terminal:spotlight.categories.areas"),"modified-file":a("terminal:spotlight.categories.modifiedFiles"),activity:a("terminal:spotlight.categories.recentActivity")},d=g.useMemo(()=>{const h=[];let f=null,y=[];return t.forEach((C,k)=>{C.type!==f&&(f!==null&&y.length>0&&h.push([f,y]),f=C.type,y=[]),y.push({result:C,index:k})}),f!==null&&y.length>0&&h.push([f,y]),h},[t]);return g.useEffect(()=>{if(!o||typeof o=="function")return;const h=o.current;if(!h)return;const f=h.querySelector(".spotlight-item.selected");f&&f.scrollIntoView({block:"nearest",behavior:"smooth"})},[s,o]),t.length===0?m.jsx("div",{className:"spotlight-results",ref:o,children:m.jsx("div",{className:"spotlight-empty",children:a("terminal:spotlight.noResults")})}):m.jsx("div",{className:"spotlight-results",ref:o,children:d.map(([h,f])=>m.jsxs("div",{children:[d.length>1&&m.jsx("div",{className:"spotlight-category-header",children:l[h]||h}),f.map(({result:y,index:C})=>m.jsx(Ye,{result:y,isSelected:C===s,query:n,highlightMatch:i,onClick:()=>y.action(),onMouseEnter:()=>{u.current&&c(C)}},y.id))]},h))})}),Xe=g.memo(function(){const{t}=Mt(["terminal"]);return m.jsxs("div",{className:"spotlight-footer",children:[m.jsxs("div",{className:"spotlight-footer-left",children:[m.jsxs("span",{className:"spotlight-footer-hint",children:[m.jsx("kbd",{children:"↑"}),m.jsx("kbd",{children:"↓"})," ",m.jsx("kbd",{children:"Alt+N"}),m.jsx("kbd",{children:"Alt+P"})," ",t("terminal:spotlight.navigate")]}),m.jsxs("span",{className:"spotlight-footer-hint",children:[m.jsx("kbd",{children:"Enter"})," ",t("terminal:spotlight.select")]})]}),m.jsx("div",{className:"spotlight-footer-right",children:m.jsxs("span",{className:"spotlight-footer-hint",children:[m.jsx("kbd",{children:"Esc"})," ",t("common:buttons.close")]})})]})});function ss({isOpen:e,onClose:t,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:i,onOpenSupervisor:c,onOpenFileExplorer:o,onOpenPM2LogsModal:a,onOpenBossLogsModal:u,onOpenDatabasePanel:l,onOpenMonitoringModal:d}){const h=g.useRef(null),f=g.useRef(null),y=g.useRef(0),{query:C,setQuery:k,selectedIndex:D,setSelectedIndex:b,results:N,handleKeyDown:z,highlightMatch:Q}=Ue({isOpen:e,onClose:t,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:i,onOpenSupervisor:c,onOpenFileExplorer:o,onOpenPM2LogsModal:a,onOpenBossLogsModal:u,onOpenDatabasePanel:l,onOpenMonitoringModal:d});y.current=N.length,g.useEffect(()=>{e&&setTimeout(()=>{var S;(S=h.current)==null||S.focus()},50)},[e]),g.useEffect(()=>{if(!e)return;const S=v=>{if(v.key==="Escape"){v.preventDefault(),v.stopPropagation(),v.stopImmediatePropagation(),t();return}if(v.altKey&&!v.ctrlKey&&!v.metaKey&&(v.key==="n"||v.key==="p"||v.key==="N"||v.key==="P")){v.preventDefault(),v.stopPropagation(),v.stopImmediatePropagation();const j=v.key.toLowerCase(),_=y.current;b(j==="p"?W=>W>0?W-1:_-1:W=>W<_-1?W+1:0);return}};return window.addEventListener("keydown",S,{capture:!0}),()=>{window.removeEventListener("keydown",S,{capture:!0})}},[e,t]);const at=g.useCallback(S=>{S.target===S.currentTarget&&t()},[t]),st=g.useCallback(()=>{b(0)},[b]);return e?m.jsx("div",{className:"spotlight-overlay",onClick:at,children:m.jsxs("div",{className:"spotlight-modal",children:[m.jsx(Ge,{ref:h,query:C,onQueryChange:k,onKeyDown:z,onResetSelection:st}),m.jsx(Je,{ref:f,results:N,selectedIndex:D,query:C,highlightMatch:Q,onSelectIndex:b}),m.jsx(Xe,{})]})}):null}export{Tt as FILE_ICONS,ss as Spotlight,Xe as SpotlightFooter,Ge as SpotlightInput,Ye as SpotlightItem,Je as SpotlightResults,Zt as formatDuration,Kt as formatRelativeTime,Pt as getAgentIcon,Ve as getFileIconFromPath,Ot as getTypeLabel,Ue as useSpotlightSearch};
|
|
1
|
+
import{a2 as se,H as ne,J as ie,I as re,b7 as ce,r as g,s as O,b8 as bt,z as pt,u as Mt,j as m}from"./main-6CnCKW13.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function et(e){return Array.isArray?Array.isArray(e):zt(e)==="[object Array]"}function oe(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function ae(e){return e==null?"":oe(e)}function X(e){return typeof e=="string"}function Qt(e){return typeof e=="number"}function ue(e){return e===!0||e===!1||le(e)&&zt(e)=="[object Boolean]"}function Wt(e){return typeof e=="object"}function le(e){return Wt(e)&&e!==null}function H(e){return e!=null}function gt(e){return!e.trim().length}function zt(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const he="Incorrect 'index' type",de=e=>`Invalid value for key ${e}`,fe=e=>`Pattern length exceeds max of ${e}.`,me=e=>`Missing ${e} property in key`,pe=e=>`Property 'weight' in key '${e}' must be a positive integer`,Rt=Object.prototype.hasOwnProperty;class ge{constructor(t){this._keys=[],this._keyMap={};let s=0;t.forEach(n=>{let i=Vt(n);this._keys.push(i),this._keyMap[i.id]=i,s+=i.weight}),this._keys.forEach(n=>{n.weight/=s})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Vt(e){let t=null,s=null,n=null,i=1,c=null;if(X(e)||et(e))n=e,t=_t(e),s=yt(e);else{if(!Rt.call(e,"name"))throw new Error(me("name"));const o=e.name;if(n=o,Rt.call(e,"weight")&&(i=e.weight,i<=0))throw new Error(pe(o));t=_t(o),s=yt(o),c=e.getFn}return{path:t,id:s,weight:i,src:n,getFn:c}}function _t(e){return et(e)?e:e.split(".")}function yt(e){return et(e)?e.join("."):e}function ye(e,t){let s=[],n=!1;const i=(c,o,a)=>{if(H(c))if(!o[a])s.push(c);else{let u=o[a];const l=c[u];if(!H(l))return;if(a===o.length-1&&(X(l)||Qt(l)||ue(l)))s.push(ae(l));else if(et(l)){n=!0;for(let d=0,h=l.length;d<h;d+=1)i(l[d],o,a+1)}else o.length&&i(l,o,a+1)}};return i(e,X(t)?t.split("."):t,0),n?s:s[0]}const Ae={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},xe={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},Ee={location:0,threshold:.6,distance:100},Ce={useExtendedSearch:!1,getFn:ye,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var p={...xe,...Ae,...Ee,...Ce};const Fe=/[^ ]+/g;function Me(e=1,t=3){const s=new Map,n=Math.pow(10,t);return{get(i){const c=i.match(Fe).length;if(s.has(c))return s.get(c);const o=1/Math.pow(c,.5*e),a=parseFloat(Math.round(o*n)/n);return s.set(c,a),a},clear(){s.clear()}}}class wt{constructor({getFn:t=p.getFn,fieldNormWeight:s=p.fieldNormWeight}={}){this.norm=Me(s,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((s,n)=>{this._keysMap[s.id]=n})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,X(this.docs[0])?this.docs.forEach((t,s)=>{this._addString(t,s)}):this.docs.forEach((t,s)=>{this._addObject(t,s)}),this.norm.clear())}add(t){const s=this.size();X(t)?this._addString(t,s):this._addObject(t,s)}removeAt(t){this.records.splice(t,1);for(let s=t,n=this.size();s<n;s+=1)this.records[s].i-=1}getValueForItemAtKeyId(t,s){return t[this._keysMap[s]]}size(){return this.records.length}_addString(t,s){if(!H(t)||gt(t))return;let n={v:t,i:s,n:this.norm.get(t)};this.records.push(n)}_addObject(t,s){let n={i:s,$:{}};this.keys.forEach((i,c)=>{let o=i.getFn?i.getFn(t):this.getFn(t,i.path);if(H(o)){if(et(o)){let a=[];const u=[{nestedArrIndex:-1,value:o}];for(;u.length;){const{nestedArrIndex:l,value:d}=u.pop();if(H(d))if(X(d)&&!gt(d)){let h={v:d,i:l,n:this.norm.get(d)};a.push(h)}else et(d)&&d.forEach((h,f)=>{u.push({nestedArrIndex:f,value:h})})}n.$[c]=a}else if(X(o)&&!gt(o)){let a={v:o,n:this.norm.get(o)};n.$[c]=a}}}),this.records.push(n)}toJSON(){return{keys:this.keys,records:this.records}}}function Ut(e,t,{getFn:s=p.getFn,fieldNormWeight:n=p.fieldNormWeight}={}){const i=new wt({getFn:s,fieldNormWeight:n});return i.setKeys(e.map(Vt)),i.setSources(t),i.create(),i}function we(e,{getFn:t=p.getFn,fieldNormWeight:s=p.fieldNormWeight}={}){const{keys:n,records:i}=e,c=new wt({getFn:t,fieldNormWeight:s});return c.setKeys(n),c.setIndexRecords(i),c}function ht(e,{errors:t=0,currentLocation:s=0,expectedLocation:n=0,distance:i=p.distance,ignoreLocation:c=p.ignoreLocation}={}){const o=t/e.length;if(c)return o;const a=Math.abs(n-s);return i?o+a/i:a?1:o}function ve(e=[],t=p.minMatchCharLength){let s=[],n=-1,i=-1,c=0;for(let o=e.length;c<o;c+=1){let a=e[c];a&&n===-1?n=c:!a&&n!==-1&&(i=c-1,i-n+1>=t&&s.push([n,i]),n=-1)}return e[c-1]&&c-n>=t&&s.push([n,c-1]),s}const ot=32;function De(e,t,s,{location:n=p.location,distance:i=p.distance,threshold:c=p.threshold,findAllMatches:o=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,includeMatches:u=p.includeMatches,ignoreLocation:l=p.ignoreLocation}={}){if(t.length>ot)throw new Error(fe(ot));const d=t.length,h=e.length,f=Math.max(0,Math.min(n,h));let y=c,C=f;const k=a>1||u,D=k?Array(h):[];let b;for(;(b=e.indexOf(t,C))>-1;){let S=ht(t,{currentLocation:b,expectedLocation:f,distance:i,ignoreLocation:l});if(y=Math.min(S,y),C=b+d,k){let v=0;for(;v<d;)D[b+v]=1,v+=1}}C=-1;let N=[],z=1,Q=d+h;const at=1<<d-1;for(let S=0;S<d;S+=1){let v=0,j=Q;for(;v<j;)ht(t,{errors:S,currentLocation:f+j,expectedLocation:f,distance:i,ignoreLocation:l})<=y?v=j:Q=j,j=Math.floor((Q-v)/2+v);Q=j;let _=Math.max(1,f-j+1),W=o?h:Math.min(f+j,h)+d,K=Array(W+2);K[W+1]=(1<<S)-1;for(let T=W;T>=_;T-=1){let Z=T-1,ct=s[e.charAt(Z)];if(k&&(D[Z]=+!!ct),K[T]=(K[T+1]<<1|1)&ct,S&&(K[T]|=(N[T+1]|N[T])<<1|1|N[T+1]),K[T]&at&&(z=ht(t,{errors:S,currentLocation:Z,expectedLocation:f,distance:i,ignoreLocation:l}),z<=y)){if(y=z,C=Z,C<=f)break;_=Math.max(1,2*f-C)}}if(ht(t,{errors:S+1,currentLocation:f,expectedLocation:f,distance:i,ignoreLocation:l})>y)break;N=K}const st={isMatch:C>=0,score:Math.max(.001,z)};if(k){const S=ve(D,a);S.length?u&&(st.indices=S):st.isMatch=!1}return st}function Se(e){let t={};for(let s=0,n=e.length;s<n;s+=1){const i=e.charAt(s);t[i]=(t[i]||0)|1<<n-s-1}return t}const dt=String.prototype.normalize?(e=>e.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(e=>e);class Gt{constructor(t,{location:s=p.location,threshold:n=p.threshold,distance:i=p.distance,includeMatches:c=p.includeMatches,findAllMatches:o=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,isCaseSensitive:u=p.isCaseSensitive,ignoreDiacritics:l=p.ignoreDiacritics,ignoreLocation:d=p.ignoreLocation}={}){if(this.options={location:s,threshold:n,distance:i,includeMatches:c,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:d},t=u?t:t.toLowerCase(),t=l?dt(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const h=(y,C)=>{this.chunks.push({pattern:y,alphabet:Se(y),startIndex:C})},f=this.pattern.length;if(f>ot){let y=0;const C=f%ot,k=f-C;for(;y<k;)h(this.pattern.substr(y,ot),y),y+=ot;if(C){const D=f-ot;h(this.pattern.substr(D),D)}}else h(this.pattern,0)}searchIn(t){const{isCaseSensitive:s,ignoreDiacritics:n,includeMatches:i}=this.options;if(t=s?t:t.toLowerCase(),t=n?dt(t):t,this.pattern===t){let k={isMatch:!0,score:0};return i&&(k.indices=[[0,t.length-1]]),k}const{location:c,distance:o,threshold:a,findAllMatches:u,minMatchCharLength:l,ignoreLocation:d}=this.options;let h=[],f=0,y=!1;this.chunks.forEach(({pattern:k,alphabet:D,startIndex:b})=>{const{isMatch:N,score:z,indices:Q}=De(t,k,D,{location:c+b,distance:o,threshold:a,findAllMatches:u,minMatchCharLength:l,includeMatches:i,ignoreLocation:d});N&&(y=!0),f+=z,N&&Q&&(h=[...h,...Q])});let C={isMatch:y,score:y?f/this.chunks.length:1};return y&&i&&(C.indices=h),C}}class rt{constructor(t){this.pattern=t}static isMultiMatch(t){return Lt(t,this.multiRegex)}static isSingleMatch(t){return Lt(t,this.singleRegex)}search(){}}function Lt(e,t){const s=e.match(t);return s?s[1]:null}class Be extends rt{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const s=t===this.pattern;return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Ie extends rt{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const n=t.indexOf(this.pattern)===-1;return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}}class ke extends rt{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const s=t.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class $e extends rt{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const s=!t.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}}class be extends rt{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const s=t.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class Re extends rt{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const s=!t.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}}class Yt extends rt{constructor(t,{location:s=p.location,threshold:n=p.threshold,distance:i=p.distance,includeMatches:c=p.includeMatches,findAllMatches:o=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,isCaseSensitive:u=p.isCaseSensitive,ignoreDiacritics:l=p.ignoreDiacritics,ignoreLocation:d=p.ignoreLocation}={}){super(t),this._bitapSearch=new Gt(t,{location:s,threshold:n,distance:i,includeMatches:c,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:d})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class Jt extends rt{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let s=0,n;const i=[],c=this.pattern.length;for(;(n=t.indexOf(this.pattern,s))>-1;)s=n+c,i.push([n,s-1]);const o=!!i.length;return{isMatch:o,score:o?0:1,indices:i}}}const At=[Be,Jt,ke,$e,Re,be,Ie,Yt],Nt=At.length,_e=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Le="|";function Ne(e,t={}){return e.split(Le).map(s=>{let n=s.trim().split(_e).filter(c=>c&&!!c.trim()),i=[];for(let c=0,o=n.length;c<o;c+=1){const a=n[c];let u=!1,l=-1;for(;!u&&++l<Nt;){const d=At[l];let h=d.isMultiMatch(a);h&&(i.push(new d(h,t)),u=!0)}if(!u)for(l=-1;++l<Nt;){const d=At[l];let h=d.isSingleMatch(a);if(h){i.push(new d(h,t));break}}}return i})}const je=new Set([Yt.type,Jt.type]);class Te{constructor(t,{isCaseSensitive:s=p.isCaseSensitive,ignoreDiacritics:n=p.ignoreDiacritics,includeMatches:i=p.includeMatches,minMatchCharLength:c=p.minMatchCharLength,ignoreLocation:o=p.ignoreLocation,findAllMatches:a=p.findAllMatches,location:u=p.location,threshold:l=p.threshold,distance:d=p.distance}={}){this.query=null,this.options={isCaseSensitive:s,ignoreDiacritics:n,includeMatches:i,minMatchCharLength:c,findAllMatches:a,ignoreLocation:o,location:u,threshold:l,distance:d},t=s?t:t.toLowerCase(),t=n?dt(t):t,this.pattern=t,this.query=Ne(this.pattern,this.options)}static condition(t,s){return s.useExtendedSearch}searchIn(t){const s=this.query;if(!s)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:i,ignoreDiacritics:c}=this.options;t=i?t:t.toLowerCase(),t=c?dt(t):t;let o=0,a=[],u=0;for(let l=0,d=s.length;l<d;l+=1){const h=s[l];a.length=0,o=0;for(let f=0,y=h.length;f<y;f+=1){const C=h[f],{isMatch:k,indices:D,score:b}=C.search(t);if(k){if(o+=1,u+=b,n){const N=C.constructor.type;je.has(N)?a=[...a,...D]:a.push(D)}}else{u=0,o=0,a.length=0;break}}if(o){let f={isMatch:!0,score:u/o};return n&&(f.indices=a),f}}return{isMatch:!1,score:1}}}const xt=[];function Pe(...e){xt.push(...e)}function Et(e,t){for(let s=0,n=xt.length;s<n;s+=1){let i=xt[s];if(i.condition(e,t))return new i(e,t)}return new Gt(e,t)}const ft={AND:"$and",OR:"$or"},Ct={PATH:"$path",PATTERN:"$val"},Ft=e=>!!(e[ft.AND]||e[ft.OR]),Ke=e=>!!e[Ct.PATH],Oe=e=>!et(e)&&Wt(e)&&!Ft(e),jt=e=>({[ft.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function Xt(e,t,{auto:s=!0}={}){const n=i=>{let c=Object.keys(i);const o=Ke(i);if(!o&&c.length>1&&!Ft(i))return n(jt(i));if(Oe(i)){const u=o?i[Ct.PATH]:c[0],l=o?i[Ct.PATTERN]:i[u];if(!X(l))throw new Error(de(u));const d={keyId:yt(u),pattern:l};return s&&(d.searcher=Et(l,t)),d}let a={children:[],operator:c[0]};return c.forEach(u=>{const l=i[u];et(l)&&l.forEach(d=>{a.children.push(n(d))})}),a};return Ft(e)||(e=jt(e)),n(e)}function He(e,{ignoreFieldNorm:t=p.ignoreFieldNorm}){e.forEach(s=>{let n=1;s.matches.forEach(({key:i,norm:c,score:o})=>{const a=i?i.weight:null;n*=Math.pow(o===0&&a?Number.EPSILON:o,(a||1)*(t?1:c))}),s.score=n})}function Qe(e,t){const s=e.matches;t.matches=[],H(s)&&s.forEach(n=>{if(!H(n.indices)||!n.indices.length)return;const{indices:i,value:c}=n;let o={indices:i,value:c};n.key&&(o.key=n.key.src),n.idx>-1&&(o.refIndex=n.idx),t.matches.push(o)})}function We(e,t){t.score=e.score}function ze(e,t,{includeMatches:s=p.includeMatches,includeScore:n=p.includeScore}={}){const i=[];return s&&i.push(Qe),n&&i.push(We),e.map(c=>{const{idx:o}=c,a={item:t[o],refIndex:o};return i.length&&i.forEach(u=>{u(c,a)}),a})}class G{constructor(t,s={},n){this.options={...p,...s},this.options.useExtendedSearch,this._keyStore=new ge(this.options.keys),this.setCollection(t,n)}setCollection(t,s){if(this._docs=t,s&&!(s instanceof wt))throw new Error(he);this._myIndex=s||Ut(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){H(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const s=[];for(let n=0,i=this._docs.length;n<i;n+=1){const c=this._docs[n];t(c,n)&&(this.removeAt(n),n-=1,i-=1,s.push(c))}return s}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:s=-1}={}){const{includeMatches:n,includeScore:i,shouldSort:c,sortFn:o,ignoreFieldNorm:a}=this.options;let u=X(t)?X(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return He(u,{ignoreFieldNorm:a}),c&&u.sort(o),Qt(s)&&s>-1&&(u=u.slice(0,s)),ze(u,this._docs,{includeMatches:n,includeScore:i})}_searchStringList(t){const s=Et(t,this.options),{records:n}=this._myIndex,i=[];return n.forEach(({v:c,i:o,n:a})=>{if(!H(c))return;const{isMatch:u,score:l,indices:d}=s.searchIn(c);u&&i.push({item:c,idx:o,matches:[{score:l,value:c,norm:a,indices:d}]})}),i}_searchLogical(t){const s=Xt(t,this.options),n=(a,u,l)=>{if(!a.children){const{keyId:h,searcher:f}=a,y=this._findMatches({key:this._keyStore.get(h),value:this._myIndex.getValueForItemAtKeyId(u,h),searcher:f});return y&&y.length?[{idx:l,item:u,matches:y}]:[]}const d=[];for(let h=0,f=a.children.length;h<f;h+=1){const y=a.children[h],C=n(y,u,l);if(C.length)d.push(...C);else if(a.operator===ft.AND)return[]}return d},i=this._myIndex.records,c={},o=[];return i.forEach(({$:a,i:u})=>{if(H(a)){let l=n(s,a,u);l.length&&(c[u]||(c[u]={idx:u,item:a,matches:[]},o.push(c[u])),l.forEach(({matches:d})=>{c[u].matches.push(...d)}))}}),o}_searchObjectList(t){const s=Et(t,this.options),{keys:n,records:i}=this._myIndex,c=[];return i.forEach(({$:o,i:a})=>{if(!H(o))return;let u=[];n.forEach((l,d)=>{u.push(...this._findMatches({key:l,value:o[d],searcher:s}))}),u.length&&c.push({idx:a,item:o,matches:u})}),c}_findMatches({key:t,value:s,searcher:n}){if(!H(s))return[];let i=[];if(et(s))s.forEach(({v:c,i:o,n:a})=>{if(!H(c))return;const{isMatch:u,score:l,indices:d}=n.searchIn(c);u&&i.push({score:l,key:t,value:c,idx:o,norm:a,indices:d})});else{const{v:c,n:o}=s,{isMatch:a,score:u,indices:l}=n.searchIn(c);a&&i.push({score:u,key:t,value:c,norm:o,indices:l})}return i}}G.version="7.1.0";G.createIndex=Ut;G.parseIndex=we;G.config=p;G.parseQuery=Xt;Pe(Te);const Tt={".ts":"📘",".tsx":"⚛️",".js":"📒",".jsx":"⚛️",".py":"🐍",".rs":"🦀",".go":"🔷",".md":"📝",".json":"📋",".yaml":"⚙️",".yml":"⚙️",".css":"🎨",".scss":"🎨",".html":"🌐",".sql":"🗃️",".sh":"💻",".env":"🔐",".toml":"⚙️",".lock":"🔒",default:"📄"};function Ve(e){var s;const t="."+((s=e.split(".").pop())==null?void 0:s.toLowerCase());return Tt[t]||Tt.default}function Pt(e){const t=se[e];return(t==null?void 0:t.icon)||"🤖"}function Zt(e){const t=Math.floor(e/1e3),s=Math.floor(t/60),n=Math.floor(s/60),i=Math.floor(n/24);return i>0?`${i}d ${n%24}h ago`:n>0?`${n}h ${s%60}m ago`:s>0?`${s}m ago`:"just now"}function Kt(e){const s=Date.now()-e;return Zt(s)}function Ot(e){switch(e){case"agent":return"Agent";case"command":return"Command";case"area":return"Area";case"activity":return"Activity";case"modified-file":return"Changed";case"building":return"Server";default:return e}}const Ht=["command","agent","building","area","modified-file","activity"];function Ue({isOpen:e,onClose:t,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:i,onOpenSupervisor:c,onOpenFileExplorer:o,onOpenPM2LogsModal:a,onOpenBossLogsModal:u,onOpenDatabasePanel:l,onOpenMonitoringModal:d}){const h=ne(),f=ie(),y=re(),C=ce(),k=g.useMemo(()=>{const r=O.getState().supervisor.agentHistories;let A="";for(const[F,M]of r)A+=`${F}:${M.length},`;return A},[h]),D=g.useRef(t);D.current=t;const b=g.useRef(s);b.current=s;const N=g.useRef(n);N.current=n;const z=g.useRef(i);z.current=i;const Q=g.useRef(c);Q.current=c;const at=g.useRef(o);at.current=o;const st=g.useRef(a);st.current=a;const S=g.useRef(u);S.current=u;const v=g.useRef(l);v.current=l;const j=g.useRef(d);j.current=d;const[_,W]=g.useState(""),[K,nt]=g.useState(0);g.useEffect(()=>{if(e){W(""),nt(0);const r=Array.from(h.values());for(const A of r)!O.hasHistoryBeenFetched(A.id)&&!O.isLoadingHistoryForAgent(A.id)&&O.requestAgentSupervisorHistory(A.id)}},[e,h]);const T=O.getShortcuts(),Z=g.useMemo(()=>{if(!e)return[];const r=T.find(F=>F.id==="spawn-agent"),A=T.find(F=>F.id==="toggle-commander");return[{id:"cmd-spawn",type:"command",title:"Spawn New Agent",subtitle:r?bt(r):"Alt+N",icon:"➕",action:()=>{D.current(),b.current()}},{id:"cmd-commander",type:"command",title:"Commander View",subtitle:A?bt(A):"Ctrl+K",icon:"📊",action:()=>{D.current(),N.current()}},{id:"cmd-settings",type:"command",title:"Settings & Tools",subtitle:"Configure Tide Commander",icon:"⚙️",action:()=>{D.current(),z.current()}},{id:"cmd-supervisor",type:"command",title:"Supervisor Overview",subtitle:"View agent analysis",icon:"🎖️",action:()=>{D.current(),Q.current()}},{id:"cmd-monitoring",type:"command",title:"Monitoring & Logs",subtitle:"Triggers, workflows, events",icon:"📊",action:()=>{var F;D.current(),(F=j.current)==null||F.call(j)}}]},[e,T]),ct=g.useMemo(()=>e?Array.from(h.values()).map(r=>{const A=O.getAgentSupervisorHistory(r.id),F=A.length>0?A[0]:null,M=A.map(x=>({text:`${x.analysis.statusDescription} ${x.analysis.recentWorkSummary}`,timestamp:x.timestamp})),$=(C||[]).filter(x=>x.agentId===r.id).map(x=>x.filePath),I=[...new Set($)],R=I.map(x=>x.split("/").pop()||x),B=[];r.lastAssignedTask&&B.push(r.lastAssignedTask);const Y=`${r.class} • ${r.status} • ${r.cwd}`;let J=`${r.name} ${Y}`,L,ut,E;for(const x of M)J+=` ${x.text}`;F&&(L=F.analysis.recentWorkSummary,ut=F.analysis.statusDescription,E=F.timestamp),R.length>0&&(J+=` ${R.join(" ")} ${I.join(" ")}`),B.length>0&&(J+=` ${B.join(" ")}`);const w=Date.now()-r.lastActivity;let U;return r.lastAssignedTask&&(r.lastAssignedTask.length>150?U=r.lastAssignedTask.slice(0,150)+"...":U=r.lastAssignedTask),{id:`agent-${r.id}`,type:"agent",title:r.name,subtitle:Y,lastUserInput:U,statusDescription:ut,activityText:L,matchedText:L,timeAway:w,lastStatusTime:E,icon:Pt(r.class),_searchText:J,_modifiedFiles:I,_userQueries:B,_historyEntries:M,action:()=>{D.current(),O.selectAgent(r.id)}}}):[],[e,h,k,C]),lt=g.useMemo(()=>e?Array.from(f.values()).map(r=>{var A;return{id:`area-${r.id}`,type:"area",title:r.name,subtitle:`${r.assignedAgentIds.length} agents • ${((A=r.directories)==null?void 0:A.length)||0} folders`,icon:"🗺️",action:()=>{D.current(),O.selectArea(r.id)}}}):[],[e,f]),mt=g.useMemo(()=>e?Array.from(y.values()).filter(r=>r.type==="server"||r.type==="boss"||r.type==="database").map(r=>{var R,B,Y,J;const A=r.status==="running"?"🟢":r.status==="stopped"?"🔴":"🟡",F=r.type==="boss"?"👑":r.type==="database"?"🗄️":"🖥️";let $=`${r.type==="boss"?"Boss":r.type==="database"?"Database":"Server"} • ${r.status}`;if(r.type==="database"&&((B=(R=r.database)==null?void 0:R.connections)!=null&&B.length)){const L=r.database.connections[0];$+=` • ${L.engine} @ ${L.host}`}else r.cwd&&($+=` • ${r.cwd}`);let I=`${r.name} ${r.type} ${r.status} ${r.cwd||""} ${((Y=r.pm2)==null?void 0:Y.name)||""}`;if(r.type==="database"&&((J=r.database)!=null&&J.connections))for(const L of r.database.connections)I+=` ${L.name} ${L.engine} ${L.host} ${L.database||""} mysql postgresql sql`;return{id:`building-${r.id}`,type:"building",title:r.name,subtitle:$,icon:`${A} ${F}`,_searchText:I,action:()=>{var L;D.current(),r.type==="boss"?S.current(r.id):r.type==="database"?v.current(r.id):(L=r.pm2)!=null&&L.enabled&&st.current(r.id)}}}):[],[e,y]),vt=g.useMemo(()=>{if(!e)return[];const r=C||[],A=new Set,F=[];for(const M of r){if(A.has(M.filePath))continue;A.add(M.filePath);const $=M.filePath.split("/").pop()||M.filePath,I=M.action==="created"?"Created":M.action==="modified"?"Modified":M.action==="deleted"?"Deleted":"Read";if(F.push({id:`modified-${M.filePath}-${M.timestamp}`,type:"modified-file",title:$,subtitle:`${I} by ${M.agentName} • ${M.filePath}`,matchedText:M.filePath,icon:M.action==="deleted"?"🗑️":Ve(M.filePath),action:()=>{D.current();const R=Array.from(O.getState().areas.values());for(const B of R)for(const Y of B.directories||[])if(M.filePath.startsWith(Y)){O.setFileViewerPath(M.filePath),at.current(B.id);return}O.selectAgent(M.agentId)}}),F.length>=50)break}return F},[e,C]),Dt=g.useMemo(()=>{if(!e)return[];const r=[],A=Array.from(h.values());for(const F of A){const M=O.getAgentSupervisorHistory(F.id);if(M.length>0){const $=M[0],I=$.analysis;r.push({id:`activity-${F.id}-${$.timestamp}`,type:"activity",title:F.name,subtitle:I.statusDescription,activityText:I.recentWorkSummary,matchedText:I.recentWorkSummary,icon:Pt(F.class),action:()=>{D.current(),O.selectAgent(F.id)}})}}return r},[e,h,k]),St=g.useMemo(()=>new G(ct,{keys:["title","subtitle","_searchText","activityText","lastUserInput"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[ct]),Bt=g.useMemo(()=>new G(Z,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[Z]),It=g.useMemo(()=>new G(lt,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[lt]),kt=g.useMemo(()=>new G(vt,{keys:["title","subtitle","matchedText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[vt]),$t=g.useMemo(()=>new G(Dt,{keys:["title","subtitle","matchedText","activityText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[Dt]),qt=g.useMemo(()=>new G(mt,{keys:["title","subtitle","_searchText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[mt]),V=g.useMemo(()=>{if(!_.trim()){const E=[];E.push(...mt);const w=[...ct].sort((x,P)=>{const q=x.timeAway??0,tt=P.timeAway??0;return q-tt});E.push(...w),E.push(...Z.slice(0,2)),E.push(...lt.slice(0,2));const U={};return Ht.forEach((x,P)=>{U[x]=P}),E.sort((x,P)=>(U[x.type]??999)-(U[P.type]??999)),E}const r=_.toLowerCase(),A=St.search(_).slice(0,8),F=Bt.search(_).slice(0,3),M=It.search(_).slice(0,2),$=kt.search(_).slice(0,3),I=$t.search(_).slice(0,3),R=qt.search(_).filter(E=>{const w=E.score??1;return`${E.item.title} ${E.item.subtitle||""} ${E.item._searchText||""}`.toLowerCase().includes(r)||w<=.2}).slice(0,4),B=[],Y=[],J=[];for(const E of A){const w={...E.item};if(w._modifiedFiles&&w._modifiedFiles.length>0){const x=w._modifiedFiles.filter(P=>{var it;const q=((it=P.split("/").pop())==null?void 0:it.toLowerCase())||"",tt=P.toLowerCase();return q.includes(r)||tt.includes(r)});x.length>0&&(w.matchedFiles=x)}if(w._userQueries&&w._userQueries.length>0){const x=w._userQueries.find(P=>P.toLowerCase().includes(r));if(x)if(x.length>200){const q=x.toLowerCase().indexOf(r),tt=Math.max(0,q-60),it=Math.min(x.length,q+r.length+100);w.matchedQuery=(tt>0?"...":"")+x.slice(tt,it)+(it<x.length?"...":"")}else w.matchedQuery=x}if(w._historyEntries&&w._historyEntries.length>0){const x=w._historyEntries.find(P=>P.text.toLowerCase().includes(r));if(x)if(x.text.length>250){const q=x.text.toLowerCase().indexOf(r),tt=Math.max(0,q-80),it=Math.min(x.text.length,q+r.length+120);w.matchedHistory={text:(tt>0?"...":"")+x.text.slice(tt,it)+(it<x.text.length?"...":""),timestamp:x.timestamp}}else w.matchedHistory=x}const U=w.title.toLowerCase();U===r||U.startsWith(r)?Y.push(w):J.push(w)}for(const E of Y)B.push(E);for(const E of R)B.push(E.item);for(const E of J)B.push(E);for(const E of F)B.push(E.item);for(const E of M)B.push(E.item);for(const E of $)B.push(E.item);const L=new Set(A.map(E=>E.item.id));for(const E of I){const w=E.item.id.replace("activity-","").split("-")[0];L.has(`agent-${w}`)||B.push(E.item)}const ut={};return Ht.forEach((E,w)=>{ut[E]=w}),B.sort((E,w)=>(ut[E.type]??999)-(ut[w.type]??999)),B},[_,St,Bt,It,kt,$t,Z,ct,lt]);g.useEffect(()=>{K>=V.length&&nt(Math.max(0,V.length-1))},[V.length,K]);const te=g.useCallback(r=>{if(r.altKey&&!r.ctrlKey&&!r.metaKey&&(r.key==="p"||r.key==="n"||r.key==="P"||r.key==="N")){r.preventDefault(),r.stopPropagation(),r.nativeEvent.stopImmediatePropagation();const A=r.key.toLowerCase();nt(A==="p"?F=>F>0?F-1:V.length-1:F=>F<V.length-1?F+1:0);return}switch(r.key){case"Escape":r.preventDefault(),D.current();break;case"ArrowUp":r.preventDefault(),nt(A=>A>0?A-1:V.length-1);break;case"ArrowDown":r.preventDefault(),nt(A=>A<V.length-1?A+1:0);break;case"Enter":r.preventDefault(),V[K]&&V[K].action();break}},[V,K]),ee=g.useCallback((r,A)=>{if(!A||!r)return r;const F=r.toLowerCase(),M=A.toLowerCase(),$=[];let I=0,R=F.indexOf(M),B=0;for(;R!==-1;)R>I&&$.push(r.slice(I,R)),$.push(pt.createElement("mark",{key:B++,className:"spotlight-highlight"},r.slice(R,R+A.length))),I=R+A.length,R=F.indexOf(M,I);return I<r.length&&$.push(r.slice(I)),$.length>0?pt.createElement(pt.Fragment,null,...$):r},[]);return{query:_,setQuery:W,selectedIndex:K,setSelectedIndex:nt,results:V,handleKeyDown:te,highlightMatch:ee}}const Ge=g.forwardRef(function({query:t,onQueryChange:s,onKeyDown:n,onResetSelection:i},c){const{t:o}=Mt(["common"]);return m.jsxs("div",{className:"spotlight-input-wrapper",children:[m.jsx("span",{className:"spotlight-search-icon",children:"⌘"}),m.jsx("input",{ref:c,type:"text",className:"spotlight-input",placeholder:o("common:search.spotlightPlaceholder"),value:t,onChange:a=>{s(a.target.value),i()},onKeyDown:n,autoFocus:!0,spellCheck:!1}),m.jsxs("div",{className:"spotlight-input-hints",children:[m.jsx("span",{className:"spotlight-shortcut-hint",children:"↑↓"}),m.jsx("span",{className:"spotlight-shortcut-hint",children:"Enter"}),m.jsx("span",{className:"spotlight-shortcut-hint",children:"Esc"})]})]})}),Ye=g.memo(function({result:t,isSelected:s,query:n,highlightMatch:i,onClick:c,onMouseEnter:o}){const a=t.activityText||t.statusDescription||t.matchedFiles&&t.matchedFiles.length>0||t.matchedQuery||t.matchedHistory;return m.jsxs("div",{className:`spotlight-item ${s?"selected":""} ${t.activityText?"has-activity":""}`,onClick:c,onMouseEnter:o,role:"option","aria-selected":s,children:[m.jsx("span",{className:"spotlight-item-icon","aria-hidden":"true",children:t.icon}),m.jsxs("div",{className:"spotlight-item-content",children:[m.jsxs("div",{className:"spotlight-item-header",children:[m.jsx("span",{className:"spotlight-item-title",children:i(t.title,n)}),m.jsx("span",{className:`spotlight-item-type ${t.type}`,"aria-label":Ot(t.type),children:Ot(t.type)})]}),t.subtitle&&m.jsx("span",{className:"spotlight-item-subtitle",children:i(t.subtitle,n)}),t.statusDescription&&m.jsx("span",{className:"spotlight-item-status",children:i(t.statusDescription,n)}),t.activityText&&m.jsx("span",{className:"spotlight-item-activity",children:i(t.activityText,n)}),a&&m.jsxs("div",{className:"spotlight-item-details",children:[t.matchedFiles&&t.matchedFiles.length>0&&m.jsx("span",{className:"spotlight-item-files",children:t.matchedFiles.map((u,l)=>m.jsxs("span",{className:"file-badge",children:[l>0&&m.jsx("span",{className:"file-separator",children:"•"}),i(u.split("/").pop()||u,n)]},u))}),t.matchedQuery&&m.jsx("span",{className:"spotlight-item-query",children:i(t.matchedQuery,n)}),t.matchedHistory&&m.jsxs("span",{className:"spotlight-item-history",children:[i(t.matchedHistory.text,n),m.jsx("span",{className:"spotlight-history-time",children:Kt(t.matchedHistory.timestamp)})]})]}),(t.timeAway!==void 0||t.lastStatusTime!==void 0)&&m.jsxs("span",{className:"spotlight-item-time",children:[t.timeAway!==void 0&&m.jsxs("span",{className:"spotlight-time-away",children:["Idle: ",Zt(t.timeAway)]}),t.lastStatusTime!==void 0&&m.jsxs("span",{className:"spotlight-status-time",children:["Updated ",Kt(t.lastStatusTime)]})]}),t.lastUserInput&&!t.matchedQuery&&m.jsxs("span",{className:"spotlight-item-last-input",children:['"',i(t.lastUserInput,n),'"']})]})]})}),Je=g.forwardRef(function({results:t,selectedIndex:s,query:n,highlightMatch:i,onSelectIndex:c},o){const{t:a}=Mt(["terminal"]),u=g.useRef(!1);g.useEffect(()=>{u.current=!1},[t]),g.useEffect(()=>{const h=typeof o=="function"?null:o==null?void 0:o.current;if(!h)return;const f=()=>{u.current=!0};return h.addEventListener("mousemove",f),()=>{h.removeEventListener("mousemove",f)}},[o,t]);const l={command:a("terminal:spotlight.categories.commands"),agent:a("terminal:spotlight.categories.agents"),building:a("terminal:spotlight.categories.infrastructure"),area:a("terminal:spotlight.categories.areas"),"modified-file":a("terminal:spotlight.categories.modifiedFiles"),activity:a("terminal:spotlight.categories.recentActivity")},d=g.useMemo(()=>{const h=[];let f=null,y=[];return t.forEach((C,k)=>{C.type!==f&&(f!==null&&y.length>0&&h.push([f,y]),f=C.type,y=[]),y.push({result:C,index:k})}),f!==null&&y.length>0&&h.push([f,y]),h},[t]);return g.useEffect(()=>{if(!o||typeof o=="function")return;const h=o.current;if(!h)return;const f=h.querySelector(".spotlight-item.selected");f&&f.scrollIntoView({block:"nearest",behavior:"smooth"})},[s,o]),t.length===0?m.jsx("div",{className:"spotlight-results",ref:o,children:m.jsx("div",{className:"spotlight-empty",children:a("terminal:spotlight.noResults")})}):m.jsx("div",{className:"spotlight-results",ref:o,children:d.map(([h,f])=>m.jsxs("div",{children:[d.length>1&&m.jsx("div",{className:"spotlight-category-header",children:l[h]||h}),f.map(({result:y,index:C})=>m.jsx(Ye,{result:y,isSelected:C===s,query:n,highlightMatch:i,onClick:()=>y.action(),onMouseEnter:()=>{u.current&&c(C)}},y.id))]},h))})}),Xe=g.memo(function(){const{t}=Mt(["terminal"]);return m.jsxs("div",{className:"spotlight-footer",children:[m.jsxs("div",{className:"spotlight-footer-left",children:[m.jsxs("span",{className:"spotlight-footer-hint",children:[m.jsx("kbd",{children:"↑"}),m.jsx("kbd",{children:"↓"})," ",m.jsx("kbd",{children:"Alt+N"}),m.jsx("kbd",{children:"Alt+P"})," ",t("terminal:spotlight.navigate")]}),m.jsxs("span",{className:"spotlight-footer-hint",children:[m.jsx("kbd",{children:"Enter"})," ",t("terminal:spotlight.select")]})]}),m.jsx("div",{className:"spotlight-footer-right",children:m.jsxs("span",{className:"spotlight-footer-hint",children:[m.jsx("kbd",{children:"Esc"})," ",t("common:buttons.close")]})})]})});function ss({isOpen:e,onClose:t,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:i,onOpenSupervisor:c,onOpenFileExplorer:o,onOpenPM2LogsModal:a,onOpenBossLogsModal:u,onOpenDatabasePanel:l,onOpenMonitoringModal:d}){const h=g.useRef(null),f=g.useRef(null),y=g.useRef(0),{query:C,setQuery:k,selectedIndex:D,setSelectedIndex:b,results:N,handleKeyDown:z,highlightMatch:Q}=Ue({isOpen:e,onClose:t,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:i,onOpenSupervisor:c,onOpenFileExplorer:o,onOpenPM2LogsModal:a,onOpenBossLogsModal:u,onOpenDatabasePanel:l,onOpenMonitoringModal:d});y.current=N.length,g.useEffect(()=>{e&&setTimeout(()=>{var S;(S=h.current)==null||S.focus()},50)},[e]),g.useEffect(()=>{if(!e)return;const S=v=>{if(v.key==="Escape"){v.preventDefault(),v.stopPropagation(),v.stopImmediatePropagation(),t();return}if(v.altKey&&!v.ctrlKey&&!v.metaKey&&(v.key==="n"||v.key==="p"||v.key==="N"||v.key==="P")){v.preventDefault(),v.stopPropagation(),v.stopImmediatePropagation();const j=v.key.toLowerCase(),_=y.current;b(j==="p"?W=>W>0?W-1:_-1:W=>W<_-1?W+1:0);return}};return window.addEventListener("keydown",S,{capture:!0}),()=>{window.removeEventListener("keydown",S,{capture:!0})}},[e,t]);const at=g.useCallback(S=>{S.target===S.currentTarget&&t()},[t]),st=g.useCallback(()=>{b(0)},[b]);return e?m.jsx("div",{className:"spotlight-overlay",onClick:at,children:m.jsxs("div",{className:"spotlight-modal",children:[m.jsx(Ge,{ref:h,query:C,onQueryChange:k,onKeyDown:z,onResetSelection:st}),m.jsx(Je,{ref:f,results:N,selectedIndex:D,query:C,highlightMatch:Q,onSelectIndex:b}),m.jsx(Xe,{})]})}):null}export{Tt as FILE_ICONS,ss as Spotlight,Xe as SpotlightFooter,Ge as SpotlightInput,Ye as SpotlightItem,Je as SpotlightResults,Zt as formatDuration,Kt as formatRelativeTime,Pt as getAgentIcon,Ve as getFileIconFromPath,Ot as getTypeLabel,Ue as useSpotlightSearch};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{al as sa,u as E,j as e,X as v,ao as Fs,ap as $s,Y as He,s as P,aq as Ms,D as V,a7 as ee,a8 as Ge,f as aa,ar as ta,r as o,P as na,S as la,h as ia,a9 as Ke}from"./main-
|
|
1
|
+
import{al as sa,u as E,j as e,X as v,ao as Fs,ap as $s,Y as He,s as P,aq as Ms,D as V,a7 as ee,a8 as Ge,f as aa,ar as ta,r as o,P as na,S as la,h as ia,a9 as Ke}from"./main-6CnCKW13.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const ra=[{value:"",labelKey:"terminal:building.colorDefault"},{value:"#2a2a3a",labelKey:"terminal:building.colorDarkGray"},{value:"#3a2a2a",labelKey:"terminal:building.colorDarkRed"},{value:"#2a3a2a",labelKey:"terminal:building.colorDarkGreen"},{value:"#2a2a4a",labelKey:"terminal:building.colorDarkBlue"},{value:"#3a3a2a",labelKey:"terminal:building.colorDarkYellow"},{value:"#3a2a3a",labelKey:"terminal:building.colorDarkPurple"},{value:"#2a3a3a",labelKey:"terminal:building.colorDarkCyan"},{value:"#4a3a3a",labelKey:"terminal:building.colorWarmBrown"},{value:"#3a4a4a",labelKey:"terminal:building.colorCoolSteel"}];function oa(a){return sa.t(a)}function qe(a){if(a===0)return"0 B";const l=1024,c=["B","KB","MB","GB"],h=Math.floor(Math.log(a)/Math.log(l));return parseFloat((a/Math.pow(l,h)).toFixed(1))+" "+c[h]}function ca(a){const c=Date.now()-a,h=Math.floor(c/(1e3*60*60)),t=Math.floor(c%(1e3*60*60)/(1e3*60));return h>0?`${h}h ${t}m`:`${t}m`}const Us={30:"#1a1a1a",31:"#e74c3c",32:"#2ecc71",33:"#f39c12",34:"#3498db",35:"#9b59b6",36:"#00bcd4",37:"#ecf0f1",90:"#7f8c8d",91:"#ff6b6b",92:"#4ade80",93:"#fbbf24",94:"#60a5fa",95:"#c084fc",96:"#22d3ee",97:"#ffffff"};function Ks(a){const l=[],c=/\x1B\[([0-9;]*)m/g;let h=0,t=null,r;for(;(r=c.exec(a))!==null;){if(r.index>h){const m=a.slice(h,r.index);t?l.push(e.jsx("span",{style:{color:t},children:m},l.length)):l.push(m)}const g=r[1].split(";").map(Number);for(const m of g)m===0||m===39?t=null:Us[m]&&(t=Us[m]);h=c.lastIndex}if(h<a.length){const g=a.slice(h);t?l.push(e.jsx("span",{style:{color:t},children:g},l.length)):l.push(g)}return l.length>0?l:[a]}function ma({buildingName:a,onClose:l,onConfirm:c}){const{t:h}=E(["terminal","common"]);return e.jsx("div",{className:"modal-overlay visible",onClick:l,children:e.jsxs("div",{className:"modal confirm-modal",onClick:t=>t.stopPropagation(),children:[e.jsx("div",{className:"modal-header",children:h("terminal:building.deleteBuilding")}),e.jsxs("div",{className:"modal-body confirm-modal-body",children:[e.jsx("p",{children:h("terminal:building.deleteConfirm",{name:a})}),e.jsx("p",{className:"confirm-modal-note",children:h("terminal:building.deleteNote")})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn btn-secondary",onClick:l,children:h("common:buttons.cancel")}),e.jsx("button",{className:"btn btn-danger",onClick:c,autoFocus:!0,children:h("common:buttons.delete")})]})]})})}function da({usePM2:a,setUsePM2:l}){const{t:c}=E(["terminal"]);return e.jsxs("div",{className:"form-section pm2-toggle-section",children:[e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",className:"toggle-input",checked:a,onChange:h=>l(h.target.checked)}),e.jsx("span",{className:"toggle-track",children:e.jsx("span",{className:"toggle-thumb"})}),e.jsxs("span",{className:"toggle-label",children:[e.jsx("span",{className:"pm2-badge",children:"PM2"}),c("terminal:building.usePM2")]})]}),e.jsx("div",{className:"form-hint",children:c("terminal:building.pm2Hint")})]})}function ua({usePM2:a,pm2Script:l,setPm2Script:c,pm2Args:h,setPm2Args:t,pm2Interpreter:r,setPm2Interpreter:g,pm2InterpreterArgs:m,setPm2InterpreterArgs:d,pm2Env:s,setPm2Env:u,isEditMode:b,building:x,handleCommand:N}){var y;const{t:p}=E(["terminal","common"]);return a?e.jsxs("div",{className:"form-section pm2-config-section",children:[e.jsx("label",{className:"form-label",children:p("terminal:building.pm2Configuration")}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Script"),e.jsx(v,{text:p("terminal:building.helpPm2Script"),title:p("terminal:building.pm2Script"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:l,onChange:j=>c(j.target.value),placeholder:"npm, java, python, ./app.js",required:a})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Arguments"),e.jsx(v,{text:p("terminal:building.helpPm2Arguments"),title:p("terminal:building.pm2Arguments"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:h,onChange:j=>t(j.target.value),placeholder:"run dev, -jar app.jar, app.py"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Interpreter"),e.jsx(v,{text:p("terminal:building.helpPm2Interpreter"),title:p("terminal:building.pm2Interpreter"),position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:r,onChange:j=>g(j.target.value),children:Object.keys(Fs).map(j=>e.jsx("option",{value:j,children:Fs[j].label},j))})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2InterpArgs"),e.jsx(v,{text:p("terminal:building.helpPm2InterpArgs"),title:p("terminal:building.pm2InterpArgs"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:m,onChange:j=>d(j.target.value),placeholder:"-jar (for Java)"})]}),e.jsxs("div",{className:"command-row env-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Environment"),e.jsx(v,{text:p("terminal:building.helpPm2Environment"),title:p("terminal:building.pm2Environment"),position:"top",size:"sm"})]}),e.jsx("textarea",{className:"form-input form-textarea",value:s,onChange:j=>u(j.target.value),placeholder:`KEY=value
|
|
2
2
|
SERVER_PORT=7201
|
|
3
3
|
NODE_ENV=production`,rows:3})]}),e.jsx("div",{className:"pm2-examples",children:e.jsxs("details",{children:[e.jsx("summary",{children:p("terminal:building.pm2Examples")}),e.jsxs("div",{className:"pm2-examples-content",children:[e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Node.js:"})," Script: ",e.jsx("code",{children:"npm"}),", Args: ",e.jsx("code",{children:"run dev"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Symfony:"})," Script: ",e.jsx("code",{children:"symfony"}),", Args: ",e.jsx("code",{children:"serve --no-daemon"}),", Interpreter: ",e.jsx("code",{children:"None"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Java JAR:"})," Script: ",e.jsx("code",{children:"app.jar"}),", Interpreter: ",e.jsx("code",{children:"Java"}),", Interp. Args: ",e.jsx("code",{children:"-jar"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Python:"})," Script: ",e.jsx("code",{children:"app.py"}),", Interpreter: ",e.jsx("code",{children:"Python 3"})]})]})]})}),b&&(x==null?void 0:x.pm2Status)&&e.jsx("div",{className:"pm2-status-display",children:e.jsxs("div",{className:"pm2-status-row",children:[e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"PID"}),e.jsx("span",{className:"pm2-metric-value",children:x.pm2Status.pid||"-"})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"CPU"}),e.jsxs("span",{className:"pm2-metric-value",children:[((y=x.pm2Status.cpu)==null?void 0:y.toFixed(1))||"0","%"]})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"MEM"}),e.jsx("span",{className:"pm2-metric-value",children:qe(x.pm2Status.memory||0)})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"Restarts"}),e.jsx("span",{className:"pm2-metric-value",children:x.pm2Status.restarts||0})]}),x.pm2Status.uptime&&e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"Uptime"}),e.jsx("span",{className:"pm2-metric-value",children:ca(x.pm2Status.uptime)})]})]})}),b&&e.jsxs("div",{className:"pm2-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>N("start"),children:p("common:buttons.start")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>N("stop"),children:p("common:buttons.stop")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>N("restart"),children:p("terminal:buildingAction.restart")}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>N("logs"),children:p("terminal:logs.title")})]})]}):null}function pa({dockerMode:a,setDockerMode:l,dockerImage:c,setDockerImage:h,dockerContainerName:t,setDockerContainerName:r,dockerCommand:g,setDockerCommand:m,dockerPorts:d,setDockerPorts:s,dockerVolumes:u,setDockerVolumes:b,dockerNetwork:x,setDockerNetwork:N,dockerRestart:p,setDockerRestart:y,dockerPull:j,setDockerPull:F,dockerEnv:$,setDockerEnv:z,dockerComposePath:Y,setDockerComposePath:M,dockerComposeProject:J,setDockerComposeProject:U,dockerComposeServices:W,setDockerComposeServices:K,selectedExistingContainer:R,setSelectedExistingContainer:H,dockerContainersList:O,isEditMode:T,building:k,handleCommand:L}){const{t:A}=E(["config","common"]);return e.jsxs("div",{className:"form-section docker-config-section",children:[e.jsx("label",{className:"form-label",children:A("config:buildings.dockerConfig")}),e.jsxs("div",{className:"docker-mode-selector",children:[e.jsxs("label",{className:`docker-mode-option ${a==="container"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"container",checked:a==="container",onChange:()=>l("container")}),e.jsx("span",{className:"docker-mode-icon",children:"📦"}),e.jsx("span",{className:"docker-mode-label",children:"Container"}),e.jsx("span",{className:"docker-mode-desc",children:"Create a new container"})]}),e.jsxs("label",{className:`docker-mode-option ${a==="compose"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"compose",checked:a==="compose",onChange:()=>l("compose")}),e.jsx("span",{className:"docker-mode-icon",children:"🛠"}),e.jsx("span",{className:"docker-mode-label",children:"Compose"}),e.jsx("span",{className:"docker-mode-desc",children:"Manage multiple services"})]}),e.jsxs("label",{className:`docker-mode-option ${a==="existing"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"existing",checked:a==="existing",onChange:()=>l("existing")}),e.jsx("span",{className:"docker-mode-icon",children:"🔎"}),e.jsx("span",{className:"docker-mode-label",children:"Existing"}),e.jsx("span",{className:"docker-mode-desc",children:"Adopt existing container"})]})]}),a==="container"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Image:",e.jsx(v,{text:"Docker image to run, e.g., nginx:latest, redis:alpine, my-app:v1",title:"Image",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:c,onChange:n=>h(n.target.value),placeholder:"nginx:latest",required:!0})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Container Name:",e.jsx(v,{text:"Custom name for the container. If empty, auto-generated based on building name.",title:"Container Name",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:t,onChange:n=>r(n.target.value),placeholder:"Auto-generated (tc-{name}-{id})"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Command:",e.jsx(v,{text:"Override the default container command. Leave empty to use image's CMD.",title:"Command Override",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:g,onChange:n=>m(n.target.value),placeholder:"Optional command override"})]}),e.jsxs("div",{className:"form-section docker-ports-section",children:[e.jsxs("label",{className:"form-label",children:["Port Mappings",e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>s([...d,""]),children:"+ Add"})]}),d.map((n,C)=>e.jsxs("div",{className:"docker-mapping-row",children:[e.jsx("input",{type:"text",className:"form-input",value:n,onChange:B=>{const D=[...d];D[C]=B.target.value,s(D)},placeholder:"8080:80 or 3000"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>s(d.filter((B,D)=>D!==C)),children:"x"})]},C)),d.length===0&&e.jsx("div",{className:"form-hint",children:"Format: host:container (e.g., 8080:80) or same port (e.g., 3000)"})]}),e.jsxs("div",{className:"form-section docker-volumes-section",children:[e.jsxs("label",{className:"form-label",children:["Volume Mounts",e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>b([...u,""]),children:"+ Add"})]}),u.map((n,C)=>e.jsxs("div",{className:"docker-mapping-row",children:[e.jsx("input",{type:"text",className:"form-input",value:n,onChange:B=>{const D=[...u];D[C]=B.target.value,b(D)},placeholder:"./data:/app/data or /host/path:/container/path"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>b(u.filter((B,D)=>D!==C)),children:"x"})]},C)),u.length===0&&e.jsx("div",{className:"form-hint",children:"Format: host_path:container_path (relative paths resolved from working directory)"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Network:",e.jsx(v,{text:"Docker network to connect to. Leave empty for default bridge network.",title:"Network",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:x,onChange:n=>N(n.target.value),placeholder:"bridge (default)"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Restart Policy:",e.jsx(v,{text:"When should Docker restart the container automatically?",title:"Restart Policy",position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:p,onChange:n=>y(n.target.value),children:Object.keys($s).map(n=>e.jsx("option",{value:n,children:$s[n].label},n))})]})]}),a==="compose"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Compose File:",e.jsx(v,{text:"Path to docker-compose.yml file, relative to working directory.",title:"Compose File",position:"top",size:"sm"})]}),e.jsx(He,{value:Y,onChange:M,placeholder:"docker-compose.yml",className:"form-input",directoriesOnly:!1})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Project Name:",e.jsx(v,{text:"Override the compose project name. Leave empty for auto-generated name.",title:"Project Name",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:J,onChange:n=>U(n.target.value),placeholder:"Auto-generated"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Services:",e.jsx(v,{text:"Specific services to manage (comma-separated). Leave empty for all services.",title:"Services",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:W,onChange:n=>K(n.target.value),placeholder:"All services (or: api, db, redis)"})]})]}),a==="existing"&&e.jsxs("div",{className:"docker-existing-section",children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Select Container:",e.jsx(v,{text:"Choose an existing Docker container to monitor and control. The container will not be deleted when removing the building.",title:"Existing Container",position:"top",size:"sm"})]}),e.jsxs("div",{className:"docker-existing-select-wrapper",children:[e.jsxs("select",{className:"form-input form-select",value:R,onChange:n=>H(n.target.value),required:a==="existing",children:[e.jsx("option",{value:"",children:"Select a container..."}),O.map(n=>e.jsxs("option",{value:n.name,children:[n.name," (",n.image,") - ",n.state]},n.id))]}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>P.requestDockerContainersList(),title:"Refresh container list",children:"↻"})]})]}),O.length===0&&e.jsx("div",{className:"form-hint docker-existing-hint",children:"No containers found. Make sure Docker is running and you have containers available."}),R&&e.jsx("div",{className:"docker-existing-info",children:(()=>{const n=O.find(C=>C.name===R);return n?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Image:"}),e.jsx("span",{className:"docker-existing-info-value",children:n.image})]}),e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Status:"}),e.jsx("span",{className:`docker-existing-info-value docker-status-${n.status}`,children:n.state})]}),e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"ID:"}),e.jsx("span",{className:"docker-existing-info-value",children:n.id.slice(0,12)})]}),n.ports.length>0&&e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Ports:"}),e.jsx("span",{className:"docker-existing-info-value",children:n.ports.map(C=>`${C.host}:${C.container}/${C.protocol}`).join(", ")})]})]}):null})()}),e.jsx("div",{className:"form-hint",children:"Note: Existing containers will not be deleted when you remove this building."})]}),a!=="existing"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Pull Policy:",e.jsx(v,{text:"When to pull images: always, only if missing, or never.",title:"Pull Policy",position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:j,onChange:n=>F(n.target.value),children:Object.keys(Ms).map(n=>e.jsx("option",{value:n,children:Ms[n].label},n))})]}),e.jsxs("div",{className:"command-row env-row",children:[e.jsxs("span",{className:"command-label",children:["Environment:",e.jsx(v,{text:"Environment variables in KEY=value format, one per line.",title:"Environment Variables",position:"top",size:"sm"})]}),e.jsx("textarea",{className:"form-input form-textarea",value:$,onChange:n=>z(n.target.value),placeholder:`KEY=value
|
|
4
4
|
DATABASE_URL=postgres://...
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/web-
|
|
2
|
-
import{
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/web-CrUhsC9T.js","assets/main-6CnCKW13.js","assets/modulepreload-polyfill-B5Qt9EMX.js","assets/vendor-react--Eh9ivFN.js","assets/vendor-three-Chj50gSY.js","assets/main-DjGrMNoB.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{bn as e,aN as o}from"./main-6CnCKW13.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";var i;(function(r){r.Heavy="HEAVY",r.Medium="MEDIUM",r.Light="LIGHT"})(i||(i={}));var t;(function(r){r.Success="SUCCESS",r.Warning="WARNING",r.Error="ERROR"})(t||(t={}));const E=e("Haptics",{web:()=>o(()=>import("./web-CrUhsC9T.js"),__vite__mapDeps([0,1,2,3,4,5])).then(r=>new r.HapticsWeb)});export{E as Haptics,i as ImpactStyle,t as NotificationType};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{as as _e,r as t,s as I,w as Ee,at as De,V as Be,j as e,u as pe,au as Ue,av as Ke,aw as $e,ax as We,ay as Ve,k as ze,az as Ge,aA as Pe,aB as qe,aC as Ye,aD as Je,aE as Xe,a3 as Qe,P as Me,S as ce,Y as Ze,U as et,A as tt,a1 as Ie,H as st,J as nt,aF as at,m as Q,aG as ot}from"./main-
|
|
1
|
+
import{as as _e,r as t,s as I,w as Ee,at as De,V as Be,j as e,u as pe,au as Ue,av as Ke,aw as $e,ax as We,ay as Ve,k as ze,az as Ge,aA as Pe,aB as qe,aC as Ye,aD as Je,aE as Xe,a3 as Qe,P as Me,S as ce,Y as Ze,U as et,A as tt,a1 as Ie,H as st,J as nt,aF as at,m as Q,aG as ot}from"./main-6CnCKW13.js";import{F as ct}from"./index-Bhb-rse9.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Ne={status:"all",activity:"all",sort:"activity"},lt={"1h":3600*1e3,"6h":360*60*1e3,"24h":1440*60*1e3},Ae=20,fe=3,rt={idle:"#4aff9e",working:"#4a9eff",waiting:"#ff9e4a",waiting_permission:"#ffcc00",error:"#ff4a4a",offline:"#888888",orphaned:"#ff9e4a"},it=12e4;function dt(s){return s.trim().replace(/\r\n/g,`
|
|
2
2
|
`)}function Fe(s,a){return`${s}:${dt(a)}`}function ut(s,a,o,f){if(s.uuid&&a.has(s.uuid))return!1;const h=s.isUserPrompt?"user":"assistant",u=Fe(h,s.text),M=s.timestamp||0,N=o.get(u);return N!==void 0&&Math.abs(M-N)<=it?!1:M>f}function mt({isOpen:s,agents:a}){const o=_e(),[f,h]=t.useState(new Map),u=t.useRef(new Set);t.useRef(a);const M=t.useMemo(()=>Array.from(a.keys()).sort().join(","),[a]),N=t.useMemo(()=>Array.from(a.values()).map(x=>`${x.id}:${x.sessionId||""}`).sort().join(","),[a]);t.useEffect(()=>{s||(u.current.clear(),h(new Map))},[s]),t.useEffect(()=>{if(!s)return;const x=new Set(Array.from(a.keys()));for(const m of u.current)x.has(m)||u.current.delete(m);let w=null;o>0&&(w=I.preserveOutputs(),u.current.clear());const v=async(m,C,H=0)=>{if(u.current.add(m.id),H>0&&await new Promise(p=>setTimeout(p,H)),h(p=>{const A=new Map(p);return A.set(m.id,{agentId:m.id,messages:[],loading:!0,hasMore:!1,totalCount:0}),A}),!m.sessionId){C&&C.length>0&&I.mergeOutputsWithHistory(m.id,[],C),h(p=>{const A=new Map(p);return A.set(m.id,{agentId:m.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),A});return}try{const A=await(await Be(Ee(`/api/agents/${m.id}/history?limit=${De}&offset=0`))).json(),E=A.messages||[],U=E.length>0?Math.max(...E.map(k=>k.timestamp?new Date(k.timestamp).getTime():0)):0,G=new Set(E.map(k=>k.uuid).filter(k=>!!k)),K=new Map;for(const k of E){if(k.type!=="user"&&k.type!=="assistant")continue;const c=Fe(k.type,k.content),_=k.timestamp?new Date(k.timestamp).getTime():0,L=K.get(c)??0;_>L&&K.set(c,_)}const W=I.getOutputs(m.id),Y=(C&&C.length>0?[...C,...W]:W).filter(k=>ut(k,G,K,U));I.clearOutputs(m.id);for(const k of Y)I.addOutput(m.id,k);h(k=>{const c=new Map(k);return c.set(m.id,{agentId:m.id,messages:E,loading:!1,hasMore:A.hasMore||!1,totalCount:A.totalCount||0}),c})}catch(p){if(console.error(`Failed to load history for ${m.name}:`,p),C&&C.length>0){I.clearOutputs(m.id);for(const A of C)I.addOutput(m.id,A)}h(A=>{const E=new Map(A);return E.set(m.id,{agentId:m.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),E})}},i=o>0?500:0,R=Array.from(a.values());for(const m of R)if(!u.current.has(m.id)){const C=w==null?void 0:w.get(m.id);v(m,C,i)}},[s,M,N,o]);const y=t.useRef(a),S=t.useRef(f);y.current=a,S.current=f;const b=t.useCallback(async x=>{const w=y.current.get(x),v=S.current.get(x);if(!(w!=null&&w.sessionId)||!v||!v.hasMore)return;const i=v.messages.length;try{const m=await(await fetch(Ee(`/api/agents/${x}/history?limit=${De}&offset=${i}`))).json();m.messages&&m.messages.length>0&&h(C=>{const H=new Map(C),p=C.get(x);return p&&H.set(x,{...p,messages:[...m.messages,...p.messages],hasMore:m.hasMore||!1}),H})}catch(R){console.error(`Failed to load more history for agent ${x}:`,R)}},[]),D=t.useCallback(x=>{u.current.delete(x),h(w=>{const v=new Map(w),i=w.get(x);return i&&v.set(x,{...i,messages:[],hasMore:!1,totalCount:0,loading:!1}),v})},[]);return{histories:f,loadMoreHistory:b,clearAgentHistory:D}}function ft({command:s,onCommandChange:a,useTextarea:o,forceTextarea:f,onForceTextarea:h,onSend:u,canSend:M,attachedFiles:N,onAddFile:y,onRemoveFile:S,uploadFile:b,onAddPastedText:D,placeholder:x="Message...",className:w="",compact:v=!1,inputRef:i}){const R=t.useRef(null),m=t.useRef(null),C=t.useRef(o);t.useEffect(()=>{if(o&&!C.current&&m.current){const c=m.current;c.focus(),c.selectionStart=c.selectionEnd=c.value.length}C.current=o},[o]),t.useEffect(()=>{const c=m.current;if(!c||!o)return;c.style.height="auto";const _=v?120:180,L=Math.min(c.scrollHeight,_);c.style.height=`${L}px`},[s,o,v]);const H=t.useCallback(async c=>{const _=c.clipboardData.items;for(const B of _)if(B.type.startsWith("image/")){c.preventDefault();const F=B.getAsFile();if(F){const T=await b(F);T&&y(T)}return}const L=c.clipboardData.files;if(L.length>0){c.preventDefault();for(const B of L){const F=await b(B);F&&y(F)}return}const J=c.clipboardData.getData("text"),q=(J.match(/\n/g)||[]).length+1;if(q>5){c.preventDefault();const F=`[Pasted text #${D(J)} +${q} lines]`,T=c.target,V=T.selectionStart||0,se=T.selectionEnd||0,ne=s.slice(0,V)+F+s.slice(se);a(ne),o||h(!0)}},[s,a,o,h,b,y,D]),p=t.useCallback(async c=>{const _=c.target.files;if(_){for(const L of _){const J=await b(L);J&&y(J)}R.current&&(R.current.value="")}},[b,y]),A=t.useCallback(c=>{if(c.key==="Enter"&&c.shiftKey){o||(c.preventDefault(),h(!0));return}c.key==="Enter"&&(c.preventDefault(),u())},[o,h,u]),E=t.useCallback(c=>{},[]),U=t.useCallback(c=>{c.button===1&&(c.preventDefault(),c.stopPropagation())},[]),G=t.useCallback(c=>{m.current=c,i==null||i(c)},[i]),K=v?"agent-panel-input":"guake-input",W=v?"agent-panel-input-container":"guake-input-container",ee=v?"agent-panel-attach-btn":"guake-attach-btn",Y=v?"agent-panel-send-btn":"",k=o?v?"agent-panel-input-expanded":"guake-input-expanded":"";return e.jsxs(e.Fragment,{children:[N.length>0&&e.jsx("div",{className:v?"agent-panel-attachments":"guake-attachments",children:N.map(c=>e.jsxs("div",{className:`${v?"agent-panel-attachment":"guake-attachment"} ${c.isImage?"is-image":""}`,children:[e.jsx("span",{className:v?"agent-panel-attachment-icon":"guake-attachment-icon",children:c.isImage?"🖼️":"📎"}),e.jsx("span",{className:v?"agent-panel-attachment-name":"guake-attachment-name",title:c.path,children:c.name}),!v&&e.jsxs("span",{className:"guake-attachment-size",children:["(",Math.round(c.size/1024),"KB)"]}),e.jsx("button",{className:v?"agent-panel-attachment-remove":"guake-attachment-remove",onClick:()=>S(c.id),title:"Remove",children:"×"})]},c.id))}),e.jsxs("div",{className:`${K} ${k} ${w}`,children:[e.jsx("input",{ref:R,type:"file",multiple:!0,onChange:p,style:{display:"none"},accept:"*"}),e.jsxs("div",{className:W,onAuxClick:U,children:[e.jsx("button",{className:ee,onClick:()=>{var c;return(c=R.current)==null?void 0:c.click()},title:"Attach file (or paste image)",children:"📎"}),o?e.jsx("textarea",{ref:G,placeholder:x,value:s,onChange:c=>a(c.target.value),onKeyDown:A,onPaste:H,onMouseDown:E}):e.jsx("input",{ref:i,type:"text",placeholder:x,value:s,onChange:c=>a(c.target.value),onKeyDown:A,onPaste:H,onMouseDown:E}),e.jsx("button",{className:Y,onClick:u,disabled:!M,title:"Send",children:"➤"})]})]})]})}function pt(s){const a=Math.floor(s/1e3),o=Math.floor(a/60),f=a%60;return`${o}:${f.toString().padStart(2,"0")}`}const ht=t.memo(function({agentId:a,isWorking:o,timestamp:f}){const{t:h}=pe(["terminal"]),[u,M]=t.useState(0);return t.useEffect(()=>{if(!o||!f){M(0);return}M(Date.now()-f);const N=setInterval(()=>{M(Date.now()-f)},1e3);return()=>clearInterval(N)},[o,f]),o?e.jsxs("div",{className:"guake-stop-bar",children:[e.jsx("span",{className:"guake-elapsed-timer",children:pt(u)}),e.jsxs("button",{className:"guake-stop-btn",onClick:()=>I.stopAgent(a),title:h("terminal:input.stopOperation"),children:[e.jsx("span",{className:"stop-icon",children:"■"}),e.jsx("span",{className:"stop-label",children:h("terminal:input.stop")})]})]}):null});function gt({agent:s,history:a,outputs:o,isExpanded:f,isFocused:h,advancedView:u,onExpand:M,onFocus:N,inputRef:y,onLoadMore:S,onClearHistory:b}){const{t:D}=pe(["terminal","common"]),x=Ue(),w=Ke(s.id),v=t.useRef(null),[i,R]=t.useState(!1),m=t.useRef(0),C=t.useRef(!1),[H,p]=t.useState(!0),[A,E]=t.useState(!1),[U,G]=t.useState(null),[K,W]=t.useState(null),[ee,Y]=t.useState(null);$e(`commander-image-modal-${s.id}`,U!==null,()=>G(null));const{command:k,setCommand:c,forceTextarea:_,setForceTextarea:L,useTextarea:J,setPastedTexts:q,incrementPastedCount:B,resetPastedCount:F,attachedFiles:T,setAttachedFiles:V,removeAttachedFile:se,uploadFile:ne,expandPastedTexts:le}=We({selectedAgentId:s.id}),ae=k.trim().length>0||T.length>0,l=Ve({outputs:o,viewMode:u?"advanced":"simple"}),g=t.useMemo(()=>x!=null&&x.agentSummaries?x.agentSummaries.find(j=>j.agentId===s.id||j.agentName===s.name):null,[x,s.id,s.name]),d=t.useMemo(()=>{const j=ze(s);return{usedPercent:j.usedPercent,freePercent:j.freePercent,hasData:!!s.contextStats,totalTokens:j.totalTokens,contextWindow:j.contextWindow}},[s.contextStats,s.contextUsed,s.contextLimit]),P=t.useCallback(()=>{!i&&(a!=null&&a.hasMore)&&S&&(R(!0),m.current=v.current?v.current.scrollHeight-v.current.scrollTop:0,S())},[i,a==null?void 0:a.hasMore,S]);t.useEffect(()=>{i&&a&&!a.loading&&R(!1)},[a,i]);const te=t.useCallback(()=>{C.current=!0,p(!1)},[]),Z=t.useRef(f),z=t.useRef(h);t.useEffect(()=>{(f&&!Z.current||h&&!z.current)&&(C.current=!1,p(!0),E(!0)),Z.current=f,z.current=h},[f,h]);const re=t.useRef(a==null?void 0:a.loading);t.useEffect(()=>{re.current&&!(a!=null&&a.loading)&&(C.current=!1,p(!0),E(!0)),re.current=a==null?void 0:a.loading},[a==null?void 0:a.loading]),t.useEffect(()=>{if(!A)return;const j=v.current;if(!j)return;const $=performance.now();let O=0,me=-1,be;const ye=()=>{const{scrollTop:Le,scrollHeight:Se,clientHeight:He}=j,Oe=Se-Le-He<=2;if(Math.abs(Se-me)<=1&&Oe?O+=1:O=0,me=Se,O>=3){E(!1);return}if(performance.now()-$>5e3){E(!1);return}be=requestAnimationFrame(ye)};return be=requestAnimationFrame(ye),()=>cancelAnimationFrame(be)},[A]),t.useEffect(()=>{C.current||p(!0)},[l.length]);const he=t.useCallback(()=>!1,[]),ge=t.useCallback(j=>{const $=B();return q(O=>new Map(O).set($,j)),$},[B,q]),xe=t.useCallback(j=>{V($=>[...$,j])},[V]),ve=t.useCallback(()=>{if(!ae)return;if(k.trim()==="/clear"&&T.length===0){I.clearContext(s.id),b(),c(""),L(!1),q(new Map),V([]),F();return}let j=le(k.trim());if(T.length>0){const $=T.map(O=>O.isImage?`[Image: ${O.path}]`:`[File: ${O.path}]`).join(`
|
|
3
3
|
`);j=j?`${j}
|
|
4
4
|
|