tide-commander 1.76.0 → 1.76.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/assets/{BossLogsModal-BSAIyY5Q.js → BossLogsModal-B41BvcEF.js} +1 -1
  2. package/dist/assets/{BossSpawnModal-DWG3vywZ.js → BossSpawnModal-DUTcju8I.js} +1 -1
  3. package/dist/assets/{ControlsModal-D7sQMy9U.js → ControlsModal-DbiIdKPt.js} +1 -1
  4. package/dist/assets/{DockerLogsModal-BxebN9cf.js → DockerLogsModal-5mrsMmlQ.js} +1 -1
  5. package/dist/assets/{EmbeddedEditor-BJ7l5Zuf.js → EmbeddedEditor-DirMT3E8.js} +1 -1
  6. package/dist/assets/{GmailOAuthSetup-CzdqIXK3.js → GmailOAuthSetup-CmGKGxui.js} +1 -1
  7. package/dist/assets/{GoogleOAuthSetup-DKjU--mc.js → GoogleOAuthSetup-CbWwCAK0.js} +1 -1
  8. package/dist/assets/{IframeModal-DkK8asfI.js → IframeModal-Dboa4JXN.js} +1 -1
  9. package/dist/assets/{IntegrationsPanel--yZ_3y5S.js → IntegrationsPanel-DS28YNJo.js} +2 -2
  10. package/dist/assets/{LogViewerModal-CxAnXG6j.js → LogViewerModal-UbrMLs2v.js} +1 -1
  11. package/dist/assets/{MonitoringModal-B2AaGtlF.js → MonitoringModal-B_XI1vTS.js} +1 -1
  12. package/dist/assets/{PM2LogsModal-auR8lVnW.js → PM2LogsModal-ChvPf5Uv.js} +1 -1
  13. package/dist/assets/{RestoreArchivedAreaModal-BJn-apo4.js → RestoreArchivedAreaModal-CEq_4zoQ.js} +1 -1
  14. package/dist/assets/{Scene2DCanvas-Q-FykJjz.js → Scene2DCanvas-DYDA_fv5.js} +1 -1
  15. package/dist/assets/{SceneManager-JpuslnCc.js → SceneManager-Be_I2Z9r.js} +1 -1
  16. package/dist/assets/{SkillsPanel-BYfp0jLH.js → SkillsPanel-CNIkJScD.js} +1 -1
  17. package/dist/assets/{SpawnModal-_wxlHhYk.js → SpawnModal-BXV32TQn.js} +1 -1
  18. package/dist/assets/{SubordinateAssignmentModal-tvfKFyRh.js → SubordinateAssignmentModal-DK3uJtBR.js} +1 -1
  19. package/dist/assets/{TriggerManagerPanel-DRKDuQAM.js → TriggerManagerPanel-C8JheOOO.js} +1 -1
  20. package/dist/assets/{WorkflowEditorPanel-BPBBCTem.js → WorkflowEditorPanel-DeLnt3ou.js} +1 -1
  21. package/dist/assets/{index-bu2bf20Y.js → index-B7BnOlMV.js} +2 -2
  22. package/dist/assets/index-BR3DNqtn.js +5 -0
  23. package/dist/assets/{index-DIDFZjvm.js → index-BZFjiZW2.js} +1 -1
  24. package/dist/assets/{index-CNo8F4Hv.js → index-C-HNvKyN.js} +1 -1
  25. package/dist/assets/{index-W693QVuI.js → index-C2QVwmIa.js} +1 -1
  26. package/dist/assets/{index-B87wqtN7.js → index-CymWdB1l.js} +1 -1
  27. package/dist/assets/{index-C8wnSaGW.js → index-D6ez6g4v.js} +1 -1
  28. package/dist/assets/{index-CPEajh-P.js → index-DHlpIGVI.js} +1 -1
  29. package/dist/assets/{index-snzCcqn6.js → index-DXjESpea.js} +3 -3
  30. package/dist/assets/{main-CjPuuFGh.js → main-BvvvhWnd.js} +6 -6
  31. package/dist/assets/{web-CY6mLlQ5.js → web-B-5bt6Uj.js} +1 -1
  32. package/dist/assets/{web-Bd3T_lvT.js → web-Dyi_JNTJ.js} +1 -1
  33. package/dist/index.html +1 -1
  34. package/dist/src/packages/server/services/runtime-command-execution.js +9 -0
  35. package/package.json +1 -1
  36. package/dist/assets/index-DybFI3Yz.js +0 -5
@@ -1 +1 @@
1
- import{j as f,I as H,ab as He,N as Je,a6 as Xe,bI as Ze,r as A,s as se,bJ as be,a4 as fe,u as Ce}from"./main-CjPuuFGh.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function q(t){return Array.isArray?Array.isArray(t):Pe(t)==="[object Array]"}function qe(t){if(typeof t=="string")return t;let e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function et(t){return t==null?"":qe(t)}function X(t){return typeof t=="string"}function $e(t){return typeof t=="number"}function tt(t){return t===!0||t===!1||st(t)&&Pe(t)=="[object Boolean]"}function Te(t){return typeof t=="object"}function st(t){return Te(t)&&t!==null}function O(t){return t!=null}function me(t){return!t.trim().length}function Pe(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const nt="Incorrect 'index' type",rt=t=>`Invalid value for key ${t}`,it=t=>`Pattern length exceeds max of ${t}.`,ct=t=>`Missing ${t} property in key`,ot=t=>`Property 'weight' in key '${t}' must be a positive integer`,ve=Object.prototype.hasOwnProperty;class at{constructor(e){this._keys=[],this._keyMap={};let s=0;e.forEach(n=>{let r=Ke(n);this._keys.push(r),this._keyMap[r.id]=r,s+=r.weight}),this._keys.forEach(n=>{n.weight/=s})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Ke(t){let e=null,s=null,n=null,r=1,i=null;if(X(t)||q(t))n=t,e=Se(t),s=pe(t);else{if(!ve.call(t,"name"))throw new Error(ct("name"));const c=t.name;if(n=c,ve.call(t,"weight")&&(r=t.weight,r<=0))throw new Error(ot(c));e=Se(c),s=pe(c),i=t.getFn}return{path:e,id:s,weight:r,src:n,getFn:i}}function Se(t){return q(t)?t:t.split(".")}function pe(t){return q(t)?t.join("."):t}function ut(t,e){let s=[],n=!1;const r=(i,c,a)=>{if(O(i))if(!c[a])s.push(i);else{let u=c[a];const l=i[u];if(!O(l))return;if(a===c.length-1&&(X(l)||$e(l)||tt(l)))s.push(et(l));else if(q(l)){n=!0;for(let h=0,d=l.length;h<d;h+=1)r(l[h],c,a+1)}else c.length&&r(l,c,a+1)}};return r(t,X(e)?e.split("."):e,0),n?s:s[0]}const lt={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},ht={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},dt={location:0,threshold:.6,distance:100},ft={useExtendedSearch:!1,getFn:ut,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var p={...ht,...lt,...dt,...ft};const mt=/[^ ]+/g;function pt(t=1,e=3){const s=new Map,n=Math.pow(10,e);return{get(r){const i=r.match(mt).length;if(s.has(i))return s.get(i);const c=1/Math.pow(i,.5*t),a=parseFloat(Math.round(c*n)/n);return s.set(i,a),a},clear(){s.clear()}}}class we{constructor({getFn:e=p.getFn,fieldNormWeight:s=p.fieldNormWeight}={}){this.norm=pt(s,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((s,n)=>{this._keysMap[s.id]=n})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,X(this.docs[0])?this.docs.forEach((e,s)=>{this._addString(e,s)}):this.docs.forEach((e,s)=>{this._addObject(e,s)}),this.norm.clear())}add(e){const s=this.size();X(e)?this._addString(e,s):this._addObject(e,s)}removeAt(e){this.records.splice(e,1);for(let s=e,n=this.size();s<n;s+=1)this.records[s].i-=1}getValueForItemAtKeyId(e,s){return e[this._keysMap[s]]}size(){return this.records.length}_addString(e,s){if(!O(e)||me(e))return;let n={v:e,i:s,n:this.norm.get(e)};this.records.push(n)}_addObject(e,s){let n={i:s,$:{}};this.keys.forEach((r,i)=>{let c=r.getFn?r.getFn(e):this.getFn(e,r.path);if(O(c)){if(q(c)){let a=[];const u=[{nestedArrIndex:-1,value:c}];for(;u.length;){const{nestedArrIndex:l,value:h}=u.pop();if(O(h))if(X(h)&&!me(h)){let d={v:h,i:l,n:this.norm.get(h)};a.push(d)}else q(h)&&h.forEach((d,m)=>{u.push({nestedArrIndex:m,value:d})})}n.$[i]=a}else if(X(c)&&!me(c)){let a={v:c,n:this.norm.get(c)};n.$[i]=a}}}),this.records.push(n)}toJSON(){return{keys:this.keys,records:this.records}}}function Oe(t,e,{getFn:s=p.getFn,fieldNormWeight:n=p.fieldNormWeight}={}){const r=new we({getFn:s,fieldNormWeight:n});return r.setKeys(t.map(Ke)),r.setSources(e),r.create(),r}function gt(t,{getFn:e=p.getFn,fieldNormWeight:s=p.fieldNormWeight}={}){const{keys:n,records:r}=t,i=new we({getFn:e,fieldNormWeight:s});return i.setKeys(n),i.setIndexRecords(r),i}function le(t,{errors:e=0,currentLocation:s=0,expectedLocation:n=0,distance:r=p.distance,ignoreLocation:i=p.ignoreLocation}={}){const c=e/t.length;if(i)return c;const a=Math.abs(n-s);return r?c+a/r:a?1:c}function At(t=[],e=p.minMatchCharLength){let s=[],n=-1,r=-1,i=0;for(let c=t.length;i<c;i+=1){let a=t[i];a&&n===-1?n=i:!a&&n!==-1&&(r=i-1,r-n+1>=e&&s.push([n,r]),n=-1)}return t[i-1]&&i-n>=e&&s.push([n,i-1]),s}const ne=32;function yt(t,e,s,{location:n=p.location,distance:r=p.distance,threshold:i=p.threshold,findAllMatches:c=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,includeMatches:u=p.includeMatches,ignoreLocation:l=p.ignoreLocation}={}){if(e.length>ne)throw new Error(it(ne));const h=e.length,d=t.length,m=Math.max(0,Math.min(n,d));let g=i,y=m;const b=a>1||u,k=b?Array(d):[];let S;for(;(S=t.indexOf(e,y))>-1;){let x=le(e,{currentLocation:S,expectedLocation:m,distance:r,ignoreLocation:l});if(g=Math.min(x,g),y=S+h,b){let E=0;for(;E<h;)k[S+E]=1,E+=1}}y=-1;let _=[],W=1,z=h+d;const re=1<<h-1;for(let x=0;x<h;x+=1){let E=0,I=z;for(;E<I;)le(e,{errors:x,currentLocation:m+I,expectedLocation:m,distance:r,ignoreLocation:l})<=g?E=I:z=I,I=Math.floor((z-E)/2+E);z=I;let $=Math.max(1,m-I+1),T=c?d:Math.min(m+I,d)+h,V=Array(T+2);V[T+1]=(1<<x)-1;for(let N=T;N>=$;N-=1){let Z=N-1,ae=s[t.charAt(Z)];if(b&&(k[Z]=+!!ae),V[N]=(V[N+1]<<1|1)&ae,x&&(V[N]|=(_[N+1]|_[N])<<1|1|_[N+1]),V[N]&re&&(W=le(e,{errors:x,currentLocation:Z,expectedLocation:m,distance:r,ignoreLocation:l}),W<=g)){if(g=W,y=Z,y<=m)break;$=Math.max(1,2*m-y)}}if(le(e,{errors:x+1,currentLocation:m,expectedLocation:m,distance:r,ignoreLocation:l})>g)break;_=V}const G={isMatch:y>=0,score:Math.max(.001,W)};if(b){const x=At(k,a);x.length?u&&(G.indices=x):G.isMatch=!1}return G}function xt(t){let e={};for(let s=0,n=t.length;s<n;s+=1){const r=t.charAt(s);e[r]=(e[r]||0)|1<<n-s-1}return e}const he=String.prototype.normalize?(t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(t=>t);class ze{constructor(e,{location:s=p.location,threshold:n=p.threshold,distance:r=p.distance,includeMatches:i=p.includeMatches,findAllMatches:c=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,isCaseSensitive:u=p.isCaseSensitive,ignoreDiacritics:l=p.ignoreDiacritics,ignoreLocation:h=p.ignoreLocation}={}){if(this.options={location:s,threshold:n,distance:r,includeMatches:i,findAllMatches:c,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:h},e=u?e:e.toLowerCase(),e=l?he(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const d=(g,y)=>{this.chunks.push({pattern:g,alphabet:xt(g),startIndex:y})},m=this.pattern.length;if(m>ne){let g=0;const y=m%ne,b=m-y;for(;g<b;)d(this.pattern.substr(g,ne),g),g+=ne;if(y){const k=m-ne;d(this.pattern.substr(k),k)}}else d(this.pattern,0)}searchIn(e){const{isCaseSensitive:s,ignoreDiacritics:n,includeMatches:r}=this.options;if(e=s?e:e.toLowerCase(),e=n?he(e):e,this.pattern===e){let b={isMatch:!0,score:0};return r&&(b.indices=[[0,e.length-1]]),b}const{location:i,distance:c,threshold:a,findAllMatches:u,minMatchCharLength:l,ignoreLocation:h}=this.options;let d=[],m=0,g=!1;this.chunks.forEach(({pattern:b,alphabet:k,startIndex:S})=>{const{isMatch:_,score:W,indices:z}=yt(e,b,k,{location:i+S,distance:c,threshold:a,findAllMatches:u,minMatchCharLength:l,includeMatches:r,ignoreLocation:h});_&&(g=!0),m+=W,_&&z&&(d=[...d,...z])});let y={isMatch:g,score:g?m/this.chunks.length:1};return g&&r&&(y.indices=d),y}}class ee{constructor(e){this.pattern=e}static isMultiMatch(e){return ke(e,this.multiRegex)}static isSingleMatch(e){return ke(e,this.singleRegex)}search(){}}function ke(t,e){const s=t.match(e);return s?s[1]:null}class Et extends ee{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const s=e===this.pattern;return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Ct extends ee{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const n=e.indexOf(this.pattern)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class wt extends ee{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const s=e.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Ft extends ee{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const s=!e.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,e.length-1]}}}class Mt extends ee{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const s=e.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class It extends ee{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const s=!e.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,e.length-1]}}}class Qe extends ee{constructor(e,{location:s=p.location,threshold:n=p.threshold,distance:r=p.distance,includeMatches:i=p.includeMatches,findAllMatches:c=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,isCaseSensitive:u=p.isCaseSensitive,ignoreDiacritics:l=p.ignoreDiacritics,ignoreLocation:h=p.ignoreLocation}={}){super(e),this._bitapSearch=new ze(e,{location:s,threshold:n,distance:r,includeMatches:i,findAllMatches:c,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:h})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class We extends ee{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let s=0,n;const r=[],i=this.pattern.length;for(;(n=e.indexOf(this.pattern,s))>-1;)s=n+i,r.push([n,s-1]);const c=!!r.length;return{isMatch:c,score:c?0:1,indices:r}}}const ge=[Et,We,wt,Ft,It,Mt,Ct,Qe],Ne=ge.length,Dt=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Bt="|";function bt(t,e={}){return t.split(Bt).map(s=>{let n=s.trim().split(Dt).filter(i=>i&&!!i.trim()),r=[];for(let i=0,c=n.length;i<c;i+=1){const a=n[i];let u=!1,l=-1;for(;!u&&++l<Ne;){const h=ge[l];let d=h.isMultiMatch(a);d&&(r.push(new h(d,e)),u=!0)}if(!u)for(l=-1;++l<Ne;){const h=ge[l];let d=h.isSingleMatch(a);if(d){r.push(new h(d,e));break}}}return r})}const vt=new Set([Qe.type,We.type]);class St{constructor(e,{isCaseSensitive:s=p.isCaseSensitive,ignoreDiacritics:n=p.ignoreDiacritics,includeMatches:r=p.includeMatches,minMatchCharLength:i=p.minMatchCharLength,ignoreLocation:c=p.ignoreLocation,findAllMatches:a=p.findAllMatches,location:u=p.location,threshold:l=p.threshold,distance:h=p.distance}={}){this.query=null,this.options={isCaseSensitive:s,ignoreDiacritics:n,includeMatches:r,minMatchCharLength:i,findAllMatches:a,ignoreLocation:c,location:u,threshold:l,distance:h},e=s?e:e.toLowerCase(),e=n?he(e):e,this.pattern=e,this.query=bt(this.pattern,this.options)}static condition(e,s){return s.useExtendedSearch}searchIn(e){const s=this.query;if(!s)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:r,ignoreDiacritics:i}=this.options;e=r?e:e.toLowerCase(),e=i?he(e):e;let c=0,a=[],u=0;for(let l=0,h=s.length;l<h;l+=1){const d=s[l];a.length=0,c=0;for(let m=0,g=d.length;m<g;m+=1){const y=d[m],{isMatch:b,indices:k,score:S}=y.search(e);if(b){if(c+=1,u+=S,n){const _=y.constructor.type;vt.has(_)?a=[...a,...k]:a.push(k)}}else{u=0,c=0,a.length=0;break}}if(c){let m={isMatch:!0,score:u/c};return n&&(m.indices=a),m}}return{isMatch:!1,score:1}}}const Ae=[];function kt(...t){Ae.push(...t)}function ye(t,e){for(let s=0,n=Ae.length;s<n;s+=1){let r=Ae[s];if(r.condition(t,e))return new r(t,e)}return new ze(t,e)}const de={AND:"$and",OR:"$or"},xe={PATH:"$path",PATTERN:"$val"},Ee=t=>!!(t[de.AND]||t[de.OR]),Nt=t=>!!t[xe.PATH],jt=t=>!q(t)&&Te(t)&&!Ee(t),je=t=>({[de.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function Ve(t,e,{auto:s=!0}={}){const n=r=>{let i=Object.keys(r);const c=Nt(r);if(!c&&i.length>1&&!Ee(r))return n(je(r));if(jt(r)){const u=c?r[xe.PATH]:i[0],l=c?r[xe.PATTERN]:r[u];if(!X(l))throw new Error(rt(u));const h={keyId:pe(u),pattern:l};return s&&(h.searcher=ye(l,e)),h}let a={children:[],operator:i[0]};return i.forEach(u=>{const l=r[u];q(l)&&l.forEach(h=>{a.children.push(n(h))})}),a};return Ee(t)||(t=je(t)),n(t)}function Rt(t,{ignoreFieldNorm:e=p.ignoreFieldNorm}){t.forEach(s=>{let n=1;s.matches.forEach(({key:r,norm:i,score:c})=>{const a=r?r.weight:null;n*=Math.pow(c===0&&a?Number.EPSILON:c,(a||1)*(e?1:i))}),s.score=n})}function _t(t,e){const s=t.matches;e.matches=[],O(s)&&s.forEach(n=>{if(!O(n.indices)||!n.indices.length)return;const{indices:r,value:i}=n;let c={indices:r,value:i};n.key&&(c.key=n.key.src),n.idx>-1&&(c.refIndex=n.idx),e.matches.push(c)})}function Lt(t,e){e.score=t.score}function $t(t,e,{includeMatches:s=p.includeMatches,includeScore:n=p.includeScore}={}){const r=[];return s&&r.push(_t),n&&r.push(Lt),t.map(i=>{const{idx:c}=i,a={item:e[c],refIndex:c};return r.length&&r.forEach(u=>{u(i,a)}),a})}class J{constructor(e,s={},n){this.options={...p,...s},this.options.useExtendedSearch,this._keyStore=new at(this.options.keys),this.setCollection(e,n)}setCollection(e,s){if(this._docs=e,s&&!(s instanceof we))throw new Error(nt);this._myIndex=s||Oe(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){O(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const s=[];for(let n=0,r=this._docs.length;n<r;n+=1){const i=this._docs[n];e(i,n)&&(this.removeAt(n),n-=1,r-=1,s.push(i))}return s}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:s=-1}={}){const{includeMatches:n,includeScore:r,shouldSort:i,sortFn:c,ignoreFieldNorm:a}=this.options;let u=X(e)?X(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return Rt(u,{ignoreFieldNorm:a}),i&&u.sort(c),$e(s)&&s>-1&&(u=u.slice(0,s)),$t(u,this._docs,{includeMatches:n,includeScore:r})}_searchStringList(e){const s=ye(e,this.options),{records:n}=this._myIndex,r=[];return n.forEach(({v:i,i:c,n:a})=>{if(!O(i))return;const{isMatch:u,score:l,indices:h}=s.searchIn(i);u&&r.push({item:i,idx:c,matches:[{score:l,value:i,norm:a,indices:h}]})}),r}_searchLogical(e){const s=Ve(e,this.options),n=(a,u,l)=>{if(!a.children){const{keyId:d,searcher:m}=a,g=this._findMatches({key:this._keyStore.get(d),value:this._myIndex.getValueForItemAtKeyId(u,d),searcher:m});return g&&g.length?[{idx:l,item:u,matches:g}]:[]}const h=[];for(let d=0,m=a.children.length;d<m;d+=1){const g=a.children[d],y=n(g,u,l);if(y.length)h.push(...y);else if(a.operator===de.AND)return[]}return h},r=this._myIndex.records,i={},c=[];return r.forEach(({$:a,i:u})=>{if(O(a)){let l=n(s,a,u);l.length&&(i[u]||(i[u]={idx:u,item:a,matches:[]},c.push(i[u])),l.forEach(({matches:h})=>{i[u].matches.push(...h)}))}}),c}_searchObjectList(e){const s=ye(e,this.options),{keys:n,records:r}=this._myIndex,i=[];return r.forEach(({$:c,i:a})=>{if(!O(c))return;let u=[];n.forEach((l,h)=>{u.push(...this._findMatches({key:l,value:c[h],searcher:s}))}),u.length&&i.push({idx:a,item:c,matches:u})}),i}_findMatches({key:e,value:s,searcher:n}){if(!O(s))return[];let r=[];if(q(s))s.forEach(({v:i,i:c,n:a})=>{if(!O(i))return;const{isMatch:u,score:l,indices:h}=n.searchIn(i);u&&r.push({score:l,key:e,value:i,idx:c,norm:a,indices:h})});else{const{v:i,n:c}=s,{isMatch:a,score:u,indices:l}=n.searchIn(i);a&&r.push({score:u,key:e,value:i,norm:c,indices:l})}return r}}J.version="7.1.0";J.createIndex=Oe;J.parseIndex=gt;J.config=p;J.parseQuery=Ve;kt(St);const Re={".ts":"file-code",".tsx":"atom",".js":"file-code",".jsx":"atom",".py":"file-code",".rs":"file-code",".go":"file-code",".md":"file-text",".json":"clipboard",".yaml":"gear",".yml":"gear",".css":"palette",".scss":"palette",".html":"globe",".sql":"database",".sh":"terminal",".env":"lock",".toml":"gear",".lock":"lock",default:"file-text"};function Tt(t){switch(t){case"scout":return"class-scout";case"builder":return"class-builder";case"debugger":return"class-debugger";case"architect":return"class-architect";case"warrior":return"class-warrior";case"support":return"class-support";case"boss":return"class-boss";default:return"class-default"}}function Pt(t,e=16){var r;const s="."+(((r=t.split(".").pop())==null?void 0:r.toLowerCase())??""),n=Re[s]||Re.default;return f.jsx(H,{name:n,size:e})}function Kt(t,e=16){return f.jsx(H,{name:Tt(t),size:e,weight:"fill"})}function Ue(t){const e=Math.floor(t/1e3),s=Math.floor(e/60),n=Math.floor(s/60),r=Math.floor(n/24);return r>0?`${r}d ${n%24}h ago`:n>0?`${n}h ${s%60}m ago`:s>0?`${s}m ago`:"just now"}function Jt(t){const s=Date.now()-t;return Ue(s)}function _e(t){switch(t){case"agent":return"Agent";case"command":return"Command";case"area":return"Area";case"modified-file":return"Changed";case"building":return"Server";default:return t}}const Le=["command","agent","building","area","modified-file"];function Ot({isOpen:t,onClose:e,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:r,onOpenFileExplorer:i,onOpenPM2LogsModal:c,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l}){const h=He(),d=Je(),m=Xe(),g=Ze(),y=A.useRef(e);y.current=e;const b=A.useRef(s);b.current=s;const k=A.useRef(n);k.current=n;const S=A.useRef(r);S.current=r;const _=A.useRef(i);_.current=i;const W=A.useRef(c);W.current=c;const z=A.useRef(a);z.current=a;const re=A.useRef(u);re.current=u;const G=A.useRef(l);G.current=l;const[x,E]=A.useState(""),[I,$]=A.useState(0);A.useEffect(()=>{t&&(E(""),$(0))},[t]);const T=se.getShortcuts(),V=A.useMemo(()=>{if(!t)return[];const o=T.find(F=>F.id==="spawn-agent"),w=T.find(F=>F.id==="toggle-commander");return[{id:"cmd-spawn",type:"command",title:"Spawn New Agent",subtitle:o?be(o):"Alt+N",icon:f.jsx(H,{name:"plus",size:16}),action:()=>{y.current(),b.current()}},{id:"cmd-commander",type:"command",title:"Commander View",subtitle:w?be(w):"Ctrl+K",icon:f.jsx(H,{name:"dashboard",size:16}),action:()=>{y.current(),k.current()}},{id:"cmd-settings",type:"command",title:"Settings & Tools",subtitle:"Configure Tide Commander",icon:f.jsx(H,{name:"gear",size:16}),action:()=>{y.current(),S.current()}},{id:"cmd-monitoring",type:"command",title:"Monitoring & Logs",subtitle:"Triggers, workflows, events",icon:f.jsx(H,{name:"chart-line",size:16}),action:()=>{var F;y.current(),(F=G.current)==null||F.call(G)}}]},[t,T]),oe=A.useMemo(()=>t?Array.from(h.values()).map(o=>{const w=(g||[]).filter(K=>K.agentId===o.id).map(K=>K.filePath),F=[...new Set(w)],M=F.map(K=>K.split("/").pop()||K),v=[];o.lastAssignedTask&&v.push(o.lastAssignedTask);const j=`${o.class} • ${o.status} • ${o.cwd}`;let D=`${o.name} ${j}`;M.length>0&&(D+=` ${M.join(" ")} ${F.join(" ")}`),v.length>0&&(D+=` ${v.join(" ")}`);const P=Date.now()-o.lastActivity;let Q;return o.lastAssignedTask&&(o.lastAssignedTask.length>150?Q=o.lastAssignedTask.slice(0,150)+"...":Q=o.lastAssignedTask),{id:`agent-${o.id}`,type:"agent",title:o.name,subtitle:j,lastUserInput:Q,timeAway:P,icon:Kt(o.class),_searchText:D,_modifiedFiles:F,_userQueries:v,action:()=>{y.current(),se.selectAgent(o.id),se.requestTerminalExpand()}}}):[],[t,h,g]),N=A.useMemo(()=>t?Array.from(d.values()).map(o=>{var w;return{id:`area-${o.id}`,type:"area",title:o.name,subtitle:`${o.assignedAgentIds.length} agents • ${((w=o.directories)==null?void 0:w.length)||0} folders`,icon:f.jsx(H,{name:"map",size:16}),action:()=>{y.current(),se.selectArea(o.id)}}}):[],[t,d]),Z=A.useMemo(()=>t?Array.from(m.values()).filter(o=>o.type==="server"||o.type==="boss"||o.type==="database").map(o=>{var D,P,Q,K;const w=o.status==="running"?"#4ade80":o.status==="stopped"?"#f87171":"#facc15",F=o.type==="boss"?"crown":o.type==="database"?"database":"desktop";let v=`${o.type==="boss"?"Boss":o.type==="database"?"Database":"Server"} • ${o.status}`;if(o.type==="database"&&((P=(D=o.database)==null?void 0:D.connections)!=null&&P.length)){const L=o.database.connections[0];v+=` • ${L.engine} @ ${L.host}`}else o.cwd&&(v+=` • ${o.cwd}`);let j=`${o.name} ${o.type} ${o.status} ${o.cwd||""} ${((Q=o.pm2)==null?void 0:Q.name)||""}`;if(o.type==="database"&&((K=o.database)!=null&&K.connections))for(const L of o.database.connections)j+=` ${L.name} ${L.engine} ${L.host} ${L.database||""} mysql postgresql sql`;return{id:`building-${o.id}`,type:"building",title:o.name,subtitle:v,icon:f.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[f.jsx(H,{name:"status-pending",size:10,weight:"fill",color:w}),f.jsx(H,{name:F,size:16})]}),_searchText:j,action:()=>{var L;y.current(),o.type==="boss"?z.current(o.id):o.type==="database"?re.current(o.id):(L=o.pm2)!=null&&L.enabled&&W.current(o.id)}}}):[],[t,m]),ae=A.useMemo(()=>{if(!t)return[];const o=g||[],w=new Set,F=[];for(const M of o){if(w.has(M.filePath))continue;w.add(M.filePath);const v=M.filePath.split("/").pop()||M.filePath,j=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:v,subtitle:`${j} by ${M.agentName} • ${M.filePath}`,matchedText:M.filePath,icon:M.action==="deleted"?f.jsx(H,{name:"trash",size:16}):Pt(M.filePath),action:()=>{y.current();const D=Array.from(se.getState().areas.values());for(const P of D)for(const Q of P.directories||[])if(M.filePath.startsWith(Q)){se.setFileViewerPath(M.filePath),_.current(P.id);return}se.selectAgent(M.agentId)}}),F.length>=50)break}return F},[t,g]),Fe=A.useMemo(()=>new J(oe,{keys:["title","subtitle","_searchText","lastUserInput"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[oe]),Me=A.useMemo(()=>new J(V,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[V]),Ie=A.useMemo(()=>new J(N,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[N]),De=A.useMemo(()=>new J(ae,{keys:["title","subtitle","matchedText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[ae]),Be=A.useMemo(()=>new J(Z,{keys:["title","subtitle","_searchText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[Z]),U=A.useMemo(()=>{if(!x.trim()){const C=[];C.push(...Z);const B=[...oe].sort((R,Y)=>{const ie=R.timeAway??0,ce=Y.timeAway??0;return ie-ce});C.push(...B),C.push(...V.slice(0,2)),C.push(...N.slice(0,2));const te={};return Le.forEach((R,Y)=>{te[R]=Y}),C.sort((R,Y)=>(te[R.type]??999)-(te[Y.type]??999)),C}const o=x.toLowerCase(),w=Fe.search(x).slice(0,8),F=Me.search(x).slice(0,3),M=Ie.search(x).slice(0,2),v=De.search(x).slice(0,3),j=Be.search(x).filter(C=>{const B=C.score??1;return`${C.item.title} ${C.item.subtitle||""} ${C.item._searchText||""}`.toLowerCase().includes(o)||B<=.2}).slice(0,4),D=[],P=[],Q=[];for(const C of w){const B={...C.item};if(B._modifiedFiles&&B._modifiedFiles.length>0){const R=B._modifiedFiles.filter(Y=>{var ue;const ie=((ue=Y.split("/").pop())==null?void 0:ue.toLowerCase())||"",ce=Y.toLowerCase();return ie.includes(o)||ce.includes(o)});R.length>0&&(B.matchedFiles=R)}if(B._userQueries&&B._userQueries.length>0){const R=B._userQueries.find(Y=>Y.toLowerCase().includes(o));if(R)if(R.length>200){const ie=R.toLowerCase().indexOf(o),ce=Math.max(0,ie-60),ue=Math.min(R.length,ie+o.length+100);B.matchedQuery=(ce>0?"...":"")+R.slice(ce,ue)+(ue<R.length?"...":"")}else B.matchedQuery=R}const te=B.title.toLowerCase();te===o||te.startsWith(o)?P.push(B):Q.push(B)}const K=(C,B)=>(C.timeAway??Number.POSITIVE_INFINITY)-(B.timeAway??Number.POSITIVE_INFINITY);P.sort(K),Q.sort(K);for(const C of P)D.push(C);for(const C of j)D.push(C.item);for(const C of Q)D.push(C);for(const C of F)D.push(C.item);for(const C of M)D.push(C.item);for(const C of v)D.push(C.item);const L={};return Le.forEach((C,B)=>{L[C]=B}),D.sort((C,B)=>(L[C.type]??999)-(L[B.type]??999)),D},[x,Fe,Me,Ie,De,Be,V,oe,N,Z]);A.useEffect(()=>{I>=U.length&&$(Math.max(0,U.length-1))},[U.length,I]);const Ye=A.useCallback(o=>{if(o.altKey&&!o.ctrlKey&&!o.metaKey&&(o.key==="p"||o.key==="n"||o.key==="P"||o.key==="N")){o.preventDefault(),o.stopPropagation(),o.nativeEvent.stopImmediatePropagation();const w=o.key.toLowerCase();$(w==="p"?F=>F>0?F-1:U.length-1:F=>F<U.length-1?F+1:0);return}switch(o.key){case"Escape":o.preventDefault(),y.current();break;case"ArrowUp":o.preventDefault(),$(w=>w>0?w-1:U.length-1);break;case"ArrowDown":o.preventDefault(),$(w=>w<U.length-1?w+1:0);break;case"Enter":o.preventDefault(),U[I]&&U[I].action();break}},[U,I]),Ge=A.useCallback((o,w)=>{if(!w||!o)return o;const F=o.toLowerCase(),M=w.toLowerCase(),v=[];let j=0,D=F.indexOf(M),P=0;for(;D!==-1;)D>j&&v.push(o.slice(j,D)),v.push(fe.createElement("mark",{key:P++,className:"spotlight-highlight"},o.slice(D,D+w.length))),j=D+w.length,D=F.indexOf(M,j);return j<o.length&&v.push(o.slice(j)),v.length>0?fe.createElement(fe.Fragment,null,...v):o},[]);return{query:x,setQuery:E,selectedIndex:I,setSelectedIndex:$,results:U,handleKeyDown:Ye,highlightMatch:Ge}}const zt=A.forwardRef(function({query:e,onQueryChange:s,onKeyDown:n,onResetSelection:r},i){const{t:c}=Ce(["common"]);return f.jsxs("div",{className:"spotlight-input-wrapper",children:[f.jsx("span",{className:"spotlight-search-icon",children:"⌘"}),f.jsx("input",{ref:i,type:"text",className:"spotlight-input",placeholder:c("common:search.spotlightPlaceholder"),value:e,onChange:a=>{s(a.target.value),r()},onKeyDown:n,autoFocus:!0,spellCheck:!1}),f.jsxs("div",{className:"spotlight-input-hints",children:[f.jsx("span",{className:"spotlight-shortcut-hint",children:"↑↓"}),f.jsx("span",{className:"spotlight-shortcut-hint",children:"Enter"}),f.jsx("span",{className:"spotlight-shortcut-hint",children:"Esc"})]})]})}),Qt=A.memo(function({result:e,isSelected:s,query:n,highlightMatch:r,onClick:i,onMouseEnter:c}){const a=e.activityText||e.matchedFiles&&e.matchedFiles.length>0||e.matchedQuery;return f.jsxs("div",{className:`spotlight-item ${s?"selected":""} ${e.activityText?"has-activity":""}`,onClick:i,onMouseEnter:c,role:"option","aria-selected":s,children:[f.jsx("span",{className:"spotlight-item-icon","aria-hidden":"true",children:e.icon}),f.jsxs("div",{className:"spotlight-item-content",children:[f.jsxs("div",{className:"spotlight-item-header",children:[f.jsx("span",{className:"spotlight-item-title",children:r(e.title,n)}),f.jsx("span",{className:`spotlight-item-type ${e.type}`,"aria-label":_e(e.type),children:_e(e.type)})]}),e.subtitle&&f.jsx("span",{className:"spotlight-item-subtitle",children:r(e.subtitle,n)}),e.activityText&&f.jsx("span",{className:"spotlight-item-activity",children:r(e.activityText,n)}),a&&f.jsxs("div",{className:"spotlight-item-details",children:[e.matchedFiles&&e.matchedFiles.length>0&&f.jsx("span",{className:"spotlight-item-files",children:e.matchedFiles.map((u,l)=>f.jsxs("span",{className:"file-badge",children:[l>0&&f.jsx("span",{className:"file-separator",children:"•"}),r(u.split("/").pop()||u,n)]},u))}),e.matchedQuery&&f.jsx("span",{className:"spotlight-item-query",children:r(e.matchedQuery,n)})]}),e.timeAway!==void 0&&f.jsx("span",{className:"spotlight-item-time",children:f.jsxs("span",{className:"spotlight-time-away",children:["Idle: ",Ue(e.timeAway)]})}),e.lastUserInput&&!e.matchedQuery&&f.jsxs("span",{className:"spotlight-item-last-input",children:['"',r(e.lastUserInput,n),'"']})]})]})}),Wt=A.forwardRef(function({results:e,selectedIndex:s,query:n,highlightMatch:r,onSelectIndex:i},c){const{t:a}=Ce(["terminal"]),u=A.useRef(!1);A.useEffect(()=>{u.current=!1},[e]),A.useEffect(()=>{const d=typeof c=="function"?null:c==null?void 0:c.current;if(!d)return;const m=()=>{u.current=!0};return d.addEventListener("mousemove",m),()=>{d.removeEventListener("mousemove",m)}},[c,e]);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")},h=A.useMemo(()=>{const d=[];let m=null,g=[];return e.forEach((y,b)=>{y.type!==m&&(m!==null&&g.length>0&&d.push([m,g]),m=y.type,g=[]),g.push({result:y,index:b})}),m!==null&&g.length>0&&d.push([m,g]),d},[e]);return A.useEffect(()=>{if(!c||typeof c=="function")return;const d=c.current;if(!d)return;const m=d.querySelector(".spotlight-item.selected");m&&m.scrollIntoView({block:"nearest",behavior:"smooth"})},[s,c]),e.length===0?f.jsx("div",{className:"spotlight-results",ref:c,children:f.jsx("div",{className:"spotlight-empty",children:a("terminal:spotlight.noResults")})}):f.jsx("div",{className:"spotlight-results",ref:c,children:h.map(([d,m])=>f.jsxs("div",{children:[h.length>1&&f.jsx("div",{className:"spotlight-category-header",children:l[d]||d}),m.map(({result:g,index:y})=>f.jsx(Qt,{result:g,isSelected:y===s,query:n,highlightMatch:r,onClick:()=>g.action(),onMouseEnter:()=>{u.current&&i(y)}},g.id))]},d))})}),Vt=A.memo(function(){const{t:e}=Ce(["terminal"]);return f.jsxs("div",{className:"spotlight-footer",children:[f.jsxs("div",{className:"spotlight-footer-left",children:[f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"↑"}),f.jsx("kbd",{children:"↓"})," ",f.jsx("kbd",{children:"Alt+N"}),f.jsx("kbd",{children:"Alt+P"})," ",e("terminal:spotlight.navigate")]}),f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"Enter"})," ",e("terminal:spotlight.select")]})]}),f.jsx("div",{className:"spotlight-footer-right",children:f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"Esc"})," ",e("common:buttons.close")]})})]})}),Ut=768;function Xt({isOpen:t,onClose:e,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:r,onOpenFileExplorer:i,onOpenPM2LogsModal:c,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l}){const h=A.useRef(null),d=A.useRef(null),m=A.useRef(null),g=A.useRef(0),{query:y,setQuery:b,selectedIndex:k,setSelectedIndex:S,results:_,handleKeyDown:W,highlightMatch:z}=Ot({isOpen:t,onClose:e,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:r,onOpenFileExplorer:i,onOpenPM2LogsModal:c,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l});g.current=_.length,A.useEffect(()=>{t&&setTimeout(()=>{var x;(x=h.current)==null||x.focus()},50)},[t]),A.useEffect(()=>{if(!t)return;const x=window.visualViewport;if(!x||window.innerWidth>Ut)return;const E=()=>{const I=d.current;I&&(I.style.height=`${x.height}px`,I.style.top=`${x.offsetTop}px`)};return E(),x.addEventListener("resize",E),x.addEventListener("scroll",E),()=>{x.removeEventListener("resize",E),x.removeEventListener("scroll",E);const I=d.current;I&&(I.style.height="",I.style.top="")}},[t]),A.useEffect(()=>{if(!t)return;const x=E=>{if(E.key==="Escape"){E.preventDefault(),E.stopPropagation(),E.stopImmediatePropagation(),e();return}if(E.altKey&&!E.ctrlKey&&!E.metaKey&&(E.key==="n"||E.key==="p"||E.key==="N"||E.key==="P")){E.preventDefault(),E.stopPropagation(),E.stopImmediatePropagation();const I=E.key.toLowerCase(),$=g.current;S(I==="p"?T=>T>0?T-1:$-1:T=>T<$-1?T+1:0);return}};return window.addEventListener("keydown",x,{capture:!0}),()=>{window.removeEventListener("keydown",x,{capture:!0})}},[t,e]);const re=A.useCallback(x=>{x.target===x.currentTarget&&e()},[e]),G=A.useCallback(()=>{S(0)},[S]);return t?f.jsx("div",{ref:d,className:"spotlight-overlay",onClick:re,children:f.jsxs("div",{className:"spotlight-modal",children:[f.jsx(zt,{ref:h,query:y,onQueryChange:b,onKeyDown:W,onResetSelection:G}),f.jsx(Wt,{ref:m,results:_,selectedIndex:k,query:y,highlightMatch:z,onSelectIndex:S}),f.jsx(Vt,{})]})}):null}export{Re as FILE_ICON_NAMES,Xt as Spotlight,Vt as SpotlightFooter,zt as SpotlightInput,Qt as SpotlightItem,Wt as SpotlightResults,Ue as formatDuration,Jt as formatRelativeTime,Kt as getAgentIcon,Pt as getFileIconFromPath,_e as getTypeLabel,Ot as useSpotlightSearch};
1
+ import{j as f,I as H,ab as He,N as Je,a6 as Xe,bI as Ze,r as A,s as se,bJ as be,a4 as fe,u as Ce}from"./main-BvvvhWnd.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function q(t){return Array.isArray?Array.isArray(t):Pe(t)==="[object Array]"}function qe(t){if(typeof t=="string")return t;let e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function et(t){return t==null?"":qe(t)}function X(t){return typeof t=="string"}function $e(t){return typeof t=="number"}function tt(t){return t===!0||t===!1||st(t)&&Pe(t)=="[object Boolean]"}function Te(t){return typeof t=="object"}function st(t){return Te(t)&&t!==null}function O(t){return t!=null}function me(t){return!t.trim().length}function Pe(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const nt="Incorrect 'index' type",rt=t=>`Invalid value for key ${t}`,it=t=>`Pattern length exceeds max of ${t}.`,ct=t=>`Missing ${t} property in key`,ot=t=>`Property 'weight' in key '${t}' must be a positive integer`,ve=Object.prototype.hasOwnProperty;class at{constructor(e){this._keys=[],this._keyMap={};let s=0;e.forEach(n=>{let r=Ke(n);this._keys.push(r),this._keyMap[r.id]=r,s+=r.weight}),this._keys.forEach(n=>{n.weight/=s})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Ke(t){let e=null,s=null,n=null,r=1,i=null;if(X(t)||q(t))n=t,e=Se(t),s=pe(t);else{if(!ve.call(t,"name"))throw new Error(ct("name"));const c=t.name;if(n=c,ve.call(t,"weight")&&(r=t.weight,r<=0))throw new Error(ot(c));e=Se(c),s=pe(c),i=t.getFn}return{path:e,id:s,weight:r,src:n,getFn:i}}function Se(t){return q(t)?t:t.split(".")}function pe(t){return q(t)?t.join("."):t}function ut(t,e){let s=[],n=!1;const r=(i,c,a)=>{if(O(i))if(!c[a])s.push(i);else{let u=c[a];const l=i[u];if(!O(l))return;if(a===c.length-1&&(X(l)||$e(l)||tt(l)))s.push(et(l));else if(q(l)){n=!0;for(let h=0,d=l.length;h<d;h+=1)r(l[h],c,a+1)}else c.length&&r(l,c,a+1)}};return r(t,X(e)?e.split("."):e,0),n?s:s[0]}const lt={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},ht={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},dt={location:0,threshold:.6,distance:100},ft={useExtendedSearch:!1,getFn:ut,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var p={...ht,...lt,...dt,...ft};const mt=/[^ ]+/g;function pt(t=1,e=3){const s=new Map,n=Math.pow(10,e);return{get(r){const i=r.match(mt).length;if(s.has(i))return s.get(i);const c=1/Math.pow(i,.5*t),a=parseFloat(Math.round(c*n)/n);return s.set(i,a),a},clear(){s.clear()}}}class we{constructor({getFn:e=p.getFn,fieldNormWeight:s=p.fieldNormWeight}={}){this.norm=pt(s,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((s,n)=>{this._keysMap[s.id]=n})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,X(this.docs[0])?this.docs.forEach((e,s)=>{this._addString(e,s)}):this.docs.forEach((e,s)=>{this._addObject(e,s)}),this.norm.clear())}add(e){const s=this.size();X(e)?this._addString(e,s):this._addObject(e,s)}removeAt(e){this.records.splice(e,1);for(let s=e,n=this.size();s<n;s+=1)this.records[s].i-=1}getValueForItemAtKeyId(e,s){return e[this._keysMap[s]]}size(){return this.records.length}_addString(e,s){if(!O(e)||me(e))return;let n={v:e,i:s,n:this.norm.get(e)};this.records.push(n)}_addObject(e,s){let n={i:s,$:{}};this.keys.forEach((r,i)=>{let c=r.getFn?r.getFn(e):this.getFn(e,r.path);if(O(c)){if(q(c)){let a=[];const u=[{nestedArrIndex:-1,value:c}];for(;u.length;){const{nestedArrIndex:l,value:h}=u.pop();if(O(h))if(X(h)&&!me(h)){let d={v:h,i:l,n:this.norm.get(h)};a.push(d)}else q(h)&&h.forEach((d,m)=>{u.push({nestedArrIndex:m,value:d})})}n.$[i]=a}else if(X(c)&&!me(c)){let a={v:c,n:this.norm.get(c)};n.$[i]=a}}}),this.records.push(n)}toJSON(){return{keys:this.keys,records:this.records}}}function Oe(t,e,{getFn:s=p.getFn,fieldNormWeight:n=p.fieldNormWeight}={}){const r=new we({getFn:s,fieldNormWeight:n});return r.setKeys(t.map(Ke)),r.setSources(e),r.create(),r}function gt(t,{getFn:e=p.getFn,fieldNormWeight:s=p.fieldNormWeight}={}){const{keys:n,records:r}=t,i=new we({getFn:e,fieldNormWeight:s});return i.setKeys(n),i.setIndexRecords(r),i}function le(t,{errors:e=0,currentLocation:s=0,expectedLocation:n=0,distance:r=p.distance,ignoreLocation:i=p.ignoreLocation}={}){const c=e/t.length;if(i)return c;const a=Math.abs(n-s);return r?c+a/r:a?1:c}function At(t=[],e=p.minMatchCharLength){let s=[],n=-1,r=-1,i=0;for(let c=t.length;i<c;i+=1){let a=t[i];a&&n===-1?n=i:!a&&n!==-1&&(r=i-1,r-n+1>=e&&s.push([n,r]),n=-1)}return t[i-1]&&i-n>=e&&s.push([n,i-1]),s}const ne=32;function yt(t,e,s,{location:n=p.location,distance:r=p.distance,threshold:i=p.threshold,findAllMatches:c=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,includeMatches:u=p.includeMatches,ignoreLocation:l=p.ignoreLocation}={}){if(e.length>ne)throw new Error(it(ne));const h=e.length,d=t.length,m=Math.max(0,Math.min(n,d));let g=i,y=m;const b=a>1||u,k=b?Array(d):[];let S;for(;(S=t.indexOf(e,y))>-1;){let x=le(e,{currentLocation:S,expectedLocation:m,distance:r,ignoreLocation:l});if(g=Math.min(x,g),y=S+h,b){let E=0;for(;E<h;)k[S+E]=1,E+=1}}y=-1;let _=[],W=1,z=h+d;const re=1<<h-1;for(let x=0;x<h;x+=1){let E=0,I=z;for(;E<I;)le(e,{errors:x,currentLocation:m+I,expectedLocation:m,distance:r,ignoreLocation:l})<=g?E=I:z=I,I=Math.floor((z-E)/2+E);z=I;let $=Math.max(1,m-I+1),T=c?d:Math.min(m+I,d)+h,V=Array(T+2);V[T+1]=(1<<x)-1;for(let N=T;N>=$;N-=1){let Z=N-1,ae=s[t.charAt(Z)];if(b&&(k[Z]=+!!ae),V[N]=(V[N+1]<<1|1)&ae,x&&(V[N]|=(_[N+1]|_[N])<<1|1|_[N+1]),V[N]&re&&(W=le(e,{errors:x,currentLocation:Z,expectedLocation:m,distance:r,ignoreLocation:l}),W<=g)){if(g=W,y=Z,y<=m)break;$=Math.max(1,2*m-y)}}if(le(e,{errors:x+1,currentLocation:m,expectedLocation:m,distance:r,ignoreLocation:l})>g)break;_=V}const G={isMatch:y>=0,score:Math.max(.001,W)};if(b){const x=At(k,a);x.length?u&&(G.indices=x):G.isMatch=!1}return G}function xt(t){let e={};for(let s=0,n=t.length;s<n;s+=1){const r=t.charAt(s);e[r]=(e[r]||0)|1<<n-s-1}return e}const he=String.prototype.normalize?(t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(t=>t);class ze{constructor(e,{location:s=p.location,threshold:n=p.threshold,distance:r=p.distance,includeMatches:i=p.includeMatches,findAllMatches:c=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,isCaseSensitive:u=p.isCaseSensitive,ignoreDiacritics:l=p.ignoreDiacritics,ignoreLocation:h=p.ignoreLocation}={}){if(this.options={location:s,threshold:n,distance:r,includeMatches:i,findAllMatches:c,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:h},e=u?e:e.toLowerCase(),e=l?he(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const d=(g,y)=>{this.chunks.push({pattern:g,alphabet:xt(g),startIndex:y})},m=this.pattern.length;if(m>ne){let g=0;const y=m%ne,b=m-y;for(;g<b;)d(this.pattern.substr(g,ne),g),g+=ne;if(y){const k=m-ne;d(this.pattern.substr(k),k)}}else d(this.pattern,0)}searchIn(e){const{isCaseSensitive:s,ignoreDiacritics:n,includeMatches:r}=this.options;if(e=s?e:e.toLowerCase(),e=n?he(e):e,this.pattern===e){let b={isMatch:!0,score:0};return r&&(b.indices=[[0,e.length-1]]),b}const{location:i,distance:c,threshold:a,findAllMatches:u,minMatchCharLength:l,ignoreLocation:h}=this.options;let d=[],m=0,g=!1;this.chunks.forEach(({pattern:b,alphabet:k,startIndex:S})=>{const{isMatch:_,score:W,indices:z}=yt(e,b,k,{location:i+S,distance:c,threshold:a,findAllMatches:u,minMatchCharLength:l,includeMatches:r,ignoreLocation:h});_&&(g=!0),m+=W,_&&z&&(d=[...d,...z])});let y={isMatch:g,score:g?m/this.chunks.length:1};return g&&r&&(y.indices=d),y}}class ee{constructor(e){this.pattern=e}static isMultiMatch(e){return ke(e,this.multiRegex)}static isSingleMatch(e){return ke(e,this.singleRegex)}search(){}}function ke(t,e){const s=t.match(e);return s?s[1]:null}class Et extends ee{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const s=e===this.pattern;return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Ct extends ee{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const n=e.indexOf(this.pattern)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class wt extends ee{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const s=e.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Ft extends ee{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const s=!e.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,e.length-1]}}}class Mt extends ee{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const s=e.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class It extends ee{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const s=!e.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,e.length-1]}}}class Qe extends ee{constructor(e,{location:s=p.location,threshold:n=p.threshold,distance:r=p.distance,includeMatches:i=p.includeMatches,findAllMatches:c=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,isCaseSensitive:u=p.isCaseSensitive,ignoreDiacritics:l=p.ignoreDiacritics,ignoreLocation:h=p.ignoreLocation}={}){super(e),this._bitapSearch=new ze(e,{location:s,threshold:n,distance:r,includeMatches:i,findAllMatches:c,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:h})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class We extends ee{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let s=0,n;const r=[],i=this.pattern.length;for(;(n=e.indexOf(this.pattern,s))>-1;)s=n+i,r.push([n,s-1]);const c=!!r.length;return{isMatch:c,score:c?0:1,indices:r}}}const ge=[Et,We,wt,Ft,It,Mt,Ct,Qe],Ne=ge.length,Dt=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Bt="|";function bt(t,e={}){return t.split(Bt).map(s=>{let n=s.trim().split(Dt).filter(i=>i&&!!i.trim()),r=[];for(let i=0,c=n.length;i<c;i+=1){const a=n[i];let u=!1,l=-1;for(;!u&&++l<Ne;){const h=ge[l];let d=h.isMultiMatch(a);d&&(r.push(new h(d,e)),u=!0)}if(!u)for(l=-1;++l<Ne;){const h=ge[l];let d=h.isSingleMatch(a);if(d){r.push(new h(d,e));break}}}return r})}const vt=new Set([Qe.type,We.type]);class St{constructor(e,{isCaseSensitive:s=p.isCaseSensitive,ignoreDiacritics:n=p.ignoreDiacritics,includeMatches:r=p.includeMatches,minMatchCharLength:i=p.minMatchCharLength,ignoreLocation:c=p.ignoreLocation,findAllMatches:a=p.findAllMatches,location:u=p.location,threshold:l=p.threshold,distance:h=p.distance}={}){this.query=null,this.options={isCaseSensitive:s,ignoreDiacritics:n,includeMatches:r,minMatchCharLength:i,findAllMatches:a,ignoreLocation:c,location:u,threshold:l,distance:h},e=s?e:e.toLowerCase(),e=n?he(e):e,this.pattern=e,this.query=bt(this.pattern,this.options)}static condition(e,s){return s.useExtendedSearch}searchIn(e){const s=this.query;if(!s)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:r,ignoreDiacritics:i}=this.options;e=r?e:e.toLowerCase(),e=i?he(e):e;let c=0,a=[],u=0;for(let l=0,h=s.length;l<h;l+=1){const d=s[l];a.length=0,c=0;for(let m=0,g=d.length;m<g;m+=1){const y=d[m],{isMatch:b,indices:k,score:S}=y.search(e);if(b){if(c+=1,u+=S,n){const _=y.constructor.type;vt.has(_)?a=[...a,...k]:a.push(k)}}else{u=0,c=0,a.length=0;break}}if(c){let m={isMatch:!0,score:u/c};return n&&(m.indices=a),m}}return{isMatch:!1,score:1}}}const Ae=[];function kt(...t){Ae.push(...t)}function ye(t,e){for(let s=0,n=Ae.length;s<n;s+=1){let r=Ae[s];if(r.condition(t,e))return new r(t,e)}return new ze(t,e)}const de={AND:"$and",OR:"$or"},xe={PATH:"$path",PATTERN:"$val"},Ee=t=>!!(t[de.AND]||t[de.OR]),Nt=t=>!!t[xe.PATH],jt=t=>!q(t)&&Te(t)&&!Ee(t),je=t=>({[de.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function Ve(t,e,{auto:s=!0}={}){const n=r=>{let i=Object.keys(r);const c=Nt(r);if(!c&&i.length>1&&!Ee(r))return n(je(r));if(jt(r)){const u=c?r[xe.PATH]:i[0],l=c?r[xe.PATTERN]:r[u];if(!X(l))throw new Error(rt(u));const h={keyId:pe(u),pattern:l};return s&&(h.searcher=ye(l,e)),h}let a={children:[],operator:i[0]};return i.forEach(u=>{const l=r[u];q(l)&&l.forEach(h=>{a.children.push(n(h))})}),a};return Ee(t)||(t=je(t)),n(t)}function Rt(t,{ignoreFieldNorm:e=p.ignoreFieldNorm}){t.forEach(s=>{let n=1;s.matches.forEach(({key:r,norm:i,score:c})=>{const a=r?r.weight:null;n*=Math.pow(c===0&&a?Number.EPSILON:c,(a||1)*(e?1:i))}),s.score=n})}function _t(t,e){const s=t.matches;e.matches=[],O(s)&&s.forEach(n=>{if(!O(n.indices)||!n.indices.length)return;const{indices:r,value:i}=n;let c={indices:r,value:i};n.key&&(c.key=n.key.src),n.idx>-1&&(c.refIndex=n.idx),e.matches.push(c)})}function Lt(t,e){e.score=t.score}function $t(t,e,{includeMatches:s=p.includeMatches,includeScore:n=p.includeScore}={}){const r=[];return s&&r.push(_t),n&&r.push(Lt),t.map(i=>{const{idx:c}=i,a={item:e[c],refIndex:c};return r.length&&r.forEach(u=>{u(i,a)}),a})}class J{constructor(e,s={},n){this.options={...p,...s},this.options.useExtendedSearch,this._keyStore=new at(this.options.keys),this.setCollection(e,n)}setCollection(e,s){if(this._docs=e,s&&!(s instanceof we))throw new Error(nt);this._myIndex=s||Oe(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){O(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const s=[];for(let n=0,r=this._docs.length;n<r;n+=1){const i=this._docs[n];e(i,n)&&(this.removeAt(n),n-=1,r-=1,s.push(i))}return s}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:s=-1}={}){const{includeMatches:n,includeScore:r,shouldSort:i,sortFn:c,ignoreFieldNorm:a}=this.options;let u=X(e)?X(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return Rt(u,{ignoreFieldNorm:a}),i&&u.sort(c),$e(s)&&s>-1&&(u=u.slice(0,s)),$t(u,this._docs,{includeMatches:n,includeScore:r})}_searchStringList(e){const s=ye(e,this.options),{records:n}=this._myIndex,r=[];return n.forEach(({v:i,i:c,n:a})=>{if(!O(i))return;const{isMatch:u,score:l,indices:h}=s.searchIn(i);u&&r.push({item:i,idx:c,matches:[{score:l,value:i,norm:a,indices:h}]})}),r}_searchLogical(e){const s=Ve(e,this.options),n=(a,u,l)=>{if(!a.children){const{keyId:d,searcher:m}=a,g=this._findMatches({key:this._keyStore.get(d),value:this._myIndex.getValueForItemAtKeyId(u,d),searcher:m});return g&&g.length?[{idx:l,item:u,matches:g}]:[]}const h=[];for(let d=0,m=a.children.length;d<m;d+=1){const g=a.children[d],y=n(g,u,l);if(y.length)h.push(...y);else if(a.operator===de.AND)return[]}return h},r=this._myIndex.records,i={},c=[];return r.forEach(({$:a,i:u})=>{if(O(a)){let l=n(s,a,u);l.length&&(i[u]||(i[u]={idx:u,item:a,matches:[]},c.push(i[u])),l.forEach(({matches:h})=>{i[u].matches.push(...h)}))}}),c}_searchObjectList(e){const s=ye(e,this.options),{keys:n,records:r}=this._myIndex,i=[];return r.forEach(({$:c,i:a})=>{if(!O(c))return;let u=[];n.forEach((l,h)=>{u.push(...this._findMatches({key:l,value:c[h],searcher:s}))}),u.length&&i.push({idx:a,item:c,matches:u})}),i}_findMatches({key:e,value:s,searcher:n}){if(!O(s))return[];let r=[];if(q(s))s.forEach(({v:i,i:c,n:a})=>{if(!O(i))return;const{isMatch:u,score:l,indices:h}=n.searchIn(i);u&&r.push({score:l,key:e,value:i,idx:c,norm:a,indices:h})});else{const{v:i,n:c}=s,{isMatch:a,score:u,indices:l}=n.searchIn(i);a&&r.push({score:u,key:e,value:i,norm:c,indices:l})}return r}}J.version="7.1.0";J.createIndex=Oe;J.parseIndex=gt;J.config=p;J.parseQuery=Ve;kt(St);const Re={".ts":"file-code",".tsx":"atom",".js":"file-code",".jsx":"atom",".py":"file-code",".rs":"file-code",".go":"file-code",".md":"file-text",".json":"clipboard",".yaml":"gear",".yml":"gear",".css":"palette",".scss":"palette",".html":"globe",".sql":"database",".sh":"terminal",".env":"lock",".toml":"gear",".lock":"lock",default:"file-text"};function Tt(t){switch(t){case"scout":return"class-scout";case"builder":return"class-builder";case"debugger":return"class-debugger";case"architect":return"class-architect";case"warrior":return"class-warrior";case"support":return"class-support";case"boss":return"class-boss";default:return"class-default"}}function Pt(t,e=16){var r;const s="."+(((r=t.split(".").pop())==null?void 0:r.toLowerCase())??""),n=Re[s]||Re.default;return f.jsx(H,{name:n,size:e})}function Kt(t,e=16){return f.jsx(H,{name:Tt(t),size:e,weight:"fill"})}function Ue(t){const e=Math.floor(t/1e3),s=Math.floor(e/60),n=Math.floor(s/60),r=Math.floor(n/24);return r>0?`${r}d ${n%24}h ago`:n>0?`${n}h ${s%60}m ago`:s>0?`${s}m ago`:"just now"}function Jt(t){const s=Date.now()-t;return Ue(s)}function _e(t){switch(t){case"agent":return"Agent";case"command":return"Command";case"area":return"Area";case"modified-file":return"Changed";case"building":return"Server";default:return t}}const Le=["command","agent","building","area","modified-file"];function Ot({isOpen:t,onClose:e,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:r,onOpenFileExplorer:i,onOpenPM2LogsModal:c,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l}){const h=He(),d=Je(),m=Xe(),g=Ze(),y=A.useRef(e);y.current=e;const b=A.useRef(s);b.current=s;const k=A.useRef(n);k.current=n;const S=A.useRef(r);S.current=r;const _=A.useRef(i);_.current=i;const W=A.useRef(c);W.current=c;const z=A.useRef(a);z.current=a;const re=A.useRef(u);re.current=u;const G=A.useRef(l);G.current=l;const[x,E]=A.useState(""),[I,$]=A.useState(0);A.useEffect(()=>{t&&(E(""),$(0))},[t]);const T=se.getShortcuts(),V=A.useMemo(()=>{if(!t)return[];const o=T.find(F=>F.id==="spawn-agent"),w=T.find(F=>F.id==="toggle-commander");return[{id:"cmd-spawn",type:"command",title:"Spawn New Agent",subtitle:o?be(o):"Alt+N",icon:f.jsx(H,{name:"plus",size:16}),action:()=>{y.current(),b.current()}},{id:"cmd-commander",type:"command",title:"Commander View",subtitle:w?be(w):"Ctrl+K",icon:f.jsx(H,{name:"dashboard",size:16}),action:()=>{y.current(),k.current()}},{id:"cmd-settings",type:"command",title:"Settings & Tools",subtitle:"Configure Tide Commander",icon:f.jsx(H,{name:"gear",size:16}),action:()=>{y.current(),S.current()}},{id:"cmd-monitoring",type:"command",title:"Monitoring & Logs",subtitle:"Triggers, workflows, events",icon:f.jsx(H,{name:"chart-line",size:16}),action:()=>{var F;y.current(),(F=G.current)==null||F.call(G)}}]},[t,T]),oe=A.useMemo(()=>t?Array.from(h.values()).map(o=>{const w=(g||[]).filter(K=>K.agentId===o.id).map(K=>K.filePath),F=[...new Set(w)],M=F.map(K=>K.split("/").pop()||K),v=[];o.lastAssignedTask&&v.push(o.lastAssignedTask);const j=`${o.class} • ${o.status} • ${o.cwd}`;let D=`${o.name} ${j}`;M.length>0&&(D+=` ${M.join(" ")} ${F.join(" ")}`),v.length>0&&(D+=` ${v.join(" ")}`);const P=Date.now()-o.lastActivity;let Q;return o.lastAssignedTask&&(o.lastAssignedTask.length>150?Q=o.lastAssignedTask.slice(0,150)+"...":Q=o.lastAssignedTask),{id:`agent-${o.id}`,type:"agent",title:o.name,subtitle:j,lastUserInput:Q,timeAway:P,icon:Kt(o.class),_searchText:D,_modifiedFiles:F,_userQueries:v,action:()=>{y.current(),se.selectAgent(o.id),se.requestTerminalExpand()}}}):[],[t,h,g]),N=A.useMemo(()=>t?Array.from(d.values()).map(o=>{var w;return{id:`area-${o.id}`,type:"area",title:o.name,subtitle:`${o.assignedAgentIds.length} agents • ${((w=o.directories)==null?void 0:w.length)||0} folders`,icon:f.jsx(H,{name:"map",size:16}),action:()=>{y.current(),se.selectArea(o.id)}}}):[],[t,d]),Z=A.useMemo(()=>t?Array.from(m.values()).filter(o=>o.type==="server"||o.type==="boss"||o.type==="database").map(o=>{var D,P,Q,K;const w=o.status==="running"?"#4ade80":o.status==="stopped"?"#f87171":"#facc15",F=o.type==="boss"?"crown":o.type==="database"?"database":"desktop";let v=`${o.type==="boss"?"Boss":o.type==="database"?"Database":"Server"} • ${o.status}`;if(o.type==="database"&&((P=(D=o.database)==null?void 0:D.connections)!=null&&P.length)){const L=o.database.connections[0];v+=` • ${L.engine} @ ${L.host}`}else o.cwd&&(v+=` • ${o.cwd}`);let j=`${o.name} ${o.type} ${o.status} ${o.cwd||""} ${((Q=o.pm2)==null?void 0:Q.name)||""}`;if(o.type==="database"&&((K=o.database)!=null&&K.connections))for(const L of o.database.connections)j+=` ${L.name} ${L.engine} ${L.host} ${L.database||""} mysql postgresql sql`;return{id:`building-${o.id}`,type:"building",title:o.name,subtitle:v,icon:f.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[f.jsx(H,{name:"status-pending",size:10,weight:"fill",color:w}),f.jsx(H,{name:F,size:16})]}),_searchText:j,action:()=>{var L;y.current(),o.type==="boss"?z.current(o.id):o.type==="database"?re.current(o.id):(L=o.pm2)!=null&&L.enabled&&W.current(o.id)}}}):[],[t,m]),ae=A.useMemo(()=>{if(!t)return[];const o=g||[],w=new Set,F=[];for(const M of o){if(w.has(M.filePath))continue;w.add(M.filePath);const v=M.filePath.split("/").pop()||M.filePath,j=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:v,subtitle:`${j} by ${M.agentName} • ${M.filePath}`,matchedText:M.filePath,icon:M.action==="deleted"?f.jsx(H,{name:"trash",size:16}):Pt(M.filePath),action:()=>{y.current();const D=Array.from(se.getState().areas.values());for(const P of D)for(const Q of P.directories||[])if(M.filePath.startsWith(Q)){se.setFileViewerPath(M.filePath),_.current(P.id);return}se.selectAgent(M.agentId)}}),F.length>=50)break}return F},[t,g]),Fe=A.useMemo(()=>new J(oe,{keys:["title","subtitle","_searchText","lastUserInput"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[oe]),Me=A.useMemo(()=>new J(V,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[V]),Ie=A.useMemo(()=>new J(N,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[N]),De=A.useMemo(()=>new J(ae,{keys:["title","subtitle","matchedText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[ae]),Be=A.useMemo(()=>new J(Z,{keys:["title","subtitle","_searchText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[Z]),U=A.useMemo(()=>{if(!x.trim()){const C=[];C.push(...Z);const B=[...oe].sort((R,Y)=>{const ie=R.timeAway??0,ce=Y.timeAway??0;return ie-ce});C.push(...B),C.push(...V.slice(0,2)),C.push(...N.slice(0,2));const te={};return Le.forEach((R,Y)=>{te[R]=Y}),C.sort((R,Y)=>(te[R.type]??999)-(te[Y.type]??999)),C}const o=x.toLowerCase(),w=Fe.search(x).slice(0,8),F=Me.search(x).slice(0,3),M=Ie.search(x).slice(0,2),v=De.search(x).slice(0,3),j=Be.search(x).filter(C=>{const B=C.score??1;return`${C.item.title} ${C.item.subtitle||""} ${C.item._searchText||""}`.toLowerCase().includes(o)||B<=.2}).slice(0,4),D=[],P=[],Q=[];for(const C of w){const B={...C.item};if(B._modifiedFiles&&B._modifiedFiles.length>0){const R=B._modifiedFiles.filter(Y=>{var ue;const ie=((ue=Y.split("/").pop())==null?void 0:ue.toLowerCase())||"",ce=Y.toLowerCase();return ie.includes(o)||ce.includes(o)});R.length>0&&(B.matchedFiles=R)}if(B._userQueries&&B._userQueries.length>0){const R=B._userQueries.find(Y=>Y.toLowerCase().includes(o));if(R)if(R.length>200){const ie=R.toLowerCase().indexOf(o),ce=Math.max(0,ie-60),ue=Math.min(R.length,ie+o.length+100);B.matchedQuery=(ce>0?"...":"")+R.slice(ce,ue)+(ue<R.length?"...":"")}else B.matchedQuery=R}const te=B.title.toLowerCase();te===o||te.startsWith(o)?P.push(B):Q.push(B)}const K=(C,B)=>(C.timeAway??Number.POSITIVE_INFINITY)-(B.timeAway??Number.POSITIVE_INFINITY);P.sort(K),Q.sort(K);for(const C of P)D.push(C);for(const C of j)D.push(C.item);for(const C of Q)D.push(C);for(const C of F)D.push(C.item);for(const C of M)D.push(C.item);for(const C of v)D.push(C.item);const L={};return Le.forEach((C,B)=>{L[C]=B}),D.sort((C,B)=>(L[C.type]??999)-(L[B.type]??999)),D},[x,Fe,Me,Ie,De,Be,V,oe,N,Z]);A.useEffect(()=>{I>=U.length&&$(Math.max(0,U.length-1))},[U.length,I]);const Ye=A.useCallback(o=>{if(o.altKey&&!o.ctrlKey&&!o.metaKey&&(o.key==="p"||o.key==="n"||o.key==="P"||o.key==="N")){o.preventDefault(),o.stopPropagation(),o.nativeEvent.stopImmediatePropagation();const w=o.key.toLowerCase();$(w==="p"?F=>F>0?F-1:U.length-1:F=>F<U.length-1?F+1:0);return}switch(o.key){case"Escape":o.preventDefault(),y.current();break;case"ArrowUp":o.preventDefault(),$(w=>w>0?w-1:U.length-1);break;case"ArrowDown":o.preventDefault(),$(w=>w<U.length-1?w+1:0);break;case"Enter":o.preventDefault(),U[I]&&U[I].action();break}},[U,I]),Ge=A.useCallback((o,w)=>{if(!w||!o)return o;const F=o.toLowerCase(),M=w.toLowerCase(),v=[];let j=0,D=F.indexOf(M),P=0;for(;D!==-1;)D>j&&v.push(o.slice(j,D)),v.push(fe.createElement("mark",{key:P++,className:"spotlight-highlight"},o.slice(D,D+w.length))),j=D+w.length,D=F.indexOf(M,j);return j<o.length&&v.push(o.slice(j)),v.length>0?fe.createElement(fe.Fragment,null,...v):o},[]);return{query:x,setQuery:E,selectedIndex:I,setSelectedIndex:$,results:U,handleKeyDown:Ye,highlightMatch:Ge}}const zt=A.forwardRef(function({query:e,onQueryChange:s,onKeyDown:n,onResetSelection:r},i){const{t:c}=Ce(["common"]);return f.jsxs("div",{className:"spotlight-input-wrapper",children:[f.jsx("span",{className:"spotlight-search-icon",children:"⌘"}),f.jsx("input",{ref:i,type:"text",className:"spotlight-input",placeholder:c("common:search.spotlightPlaceholder"),value:e,onChange:a=>{s(a.target.value),r()},onKeyDown:n,autoFocus:!0,spellCheck:!1}),f.jsxs("div",{className:"spotlight-input-hints",children:[f.jsx("span",{className:"spotlight-shortcut-hint",children:"↑↓"}),f.jsx("span",{className:"spotlight-shortcut-hint",children:"Enter"}),f.jsx("span",{className:"spotlight-shortcut-hint",children:"Esc"})]})]})}),Qt=A.memo(function({result:e,isSelected:s,query:n,highlightMatch:r,onClick:i,onMouseEnter:c}){const a=e.activityText||e.matchedFiles&&e.matchedFiles.length>0||e.matchedQuery;return f.jsxs("div",{className:`spotlight-item ${s?"selected":""} ${e.activityText?"has-activity":""}`,onClick:i,onMouseEnter:c,role:"option","aria-selected":s,children:[f.jsx("span",{className:"spotlight-item-icon","aria-hidden":"true",children:e.icon}),f.jsxs("div",{className:"spotlight-item-content",children:[f.jsxs("div",{className:"spotlight-item-header",children:[f.jsx("span",{className:"spotlight-item-title",children:r(e.title,n)}),f.jsx("span",{className:`spotlight-item-type ${e.type}`,"aria-label":_e(e.type),children:_e(e.type)})]}),e.subtitle&&f.jsx("span",{className:"spotlight-item-subtitle",children:r(e.subtitle,n)}),e.activityText&&f.jsx("span",{className:"spotlight-item-activity",children:r(e.activityText,n)}),a&&f.jsxs("div",{className:"spotlight-item-details",children:[e.matchedFiles&&e.matchedFiles.length>0&&f.jsx("span",{className:"spotlight-item-files",children:e.matchedFiles.map((u,l)=>f.jsxs("span",{className:"file-badge",children:[l>0&&f.jsx("span",{className:"file-separator",children:"•"}),r(u.split("/").pop()||u,n)]},u))}),e.matchedQuery&&f.jsx("span",{className:"spotlight-item-query",children:r(e.matchedQuery,n)})]}),e.timeAway!==void 0&&f.jsx("span",{className:"spotlight-item-time",children:f.jsxs("span",{className:"spotlight-time-away",children:["Idle: ",Ue(e.timeAway)]})}),e.lastUserInput&&!e.matchedQuery&&f.jsxs("span",{className:"spotlight-item-last-input",children:['"',r(e.lastUserInput,n),'"']})]})]})}),Wt=A.forwardRef(function({results:e,selectedIndex:s,query:n,highlightMatch:r,onSelectIndex:i},c){const{t:a}=Ce(["terminal"]),u=A.useRef(!1);A.useEffect(()=>{u.current=!1},[e]),A.useEffect(()=>{const d=typeof c=="function"?null:c==null?void 0:c.current;if(!d)return;const m=()=>{u.current=!0};return d.addEventListener("mousemove",m),()=>{d.removeEventListener("mousemove",m)}},[c,e]);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")},h=A.useMemo(()=>{const d=[];let m=null,g=[];return e.forEach((y,b)=>{y.type!==m&&(m!==null&&g.length>0&&d.push([m,g]),m=y.type,g=[]),g.push({result:y,index:b})}),m!==null&&g.length>0&&d.push([m,g]),d},[e]);return A.useEffect(()=>{if(!c||typeof c=="function")return;const d=c.current;if(!d)return;const m=d.querySelector(".spotlight-item.selected");m&&m.scrollIntoView({block:"nearest",behavior:"smooth"})},[s,c]),e.length===0?f.jsx("div",{className:"spotlight-results",ref:c,children:f.jsx("div",{className:"spotlight-empty",children:a("terminal:spotlight.noResults")})}):f.jsx("div",{className:"spotlight-results",ref:c,children:h.map(([d,m])=>f.jsxs("div",{children:[h.length>1&&f.jsx("div",{className:"spotlight-category-header",children:l[d]||d}),m.map(({result:g,index:y})=>f.jsx(Qt,{result:g,isSelected:y===s,query:n,highlightMatch:r,onClick:()=>g.action(),onMouseEnter:()=>{u.current&&i(y)}},g.id))]},d))})}),Vt=A.memo(function(){const{t:e}=Ce(["terminal"]);return f.jsxs("div",{className:"spotlight-footer",children:[f.jsxs("div",{className:"spotlight-footer-left",children:[f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"↑"}),f.jsx("kbd",{children:"↓"})," ",f.jsx("kbd",{children:"Alt+N"}),f.jsx("kbd",{children:"Alt+P"})," ",e("terminal:spotlight.navigate")]}),f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"Enter"})," ",e("terminal:spotlight.select")]})]}),f.jsx("div",{className:"spotlight-footer-right",children:f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"Esc"})," ",e("common:buttons.close")]})})]})}),Ut=768;function Xt({isOpen:t,onClose:e,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:r,onOpenFileExplorer:i,onOpenPM2LogsModal:c,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l}){const h=A.useRef(null),d=A.useRef(null),m=A.useRef(null),g=A.useRef(0),{query:y,setQuery:b,selectedIndex:k,setSelectedIndex:S,results:_,handleKeyDown:W,highlightMatch:z}=Ot({isOpen:t,onClose:e,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:r,onOpenFileExplorer:i,onOpenPM2LogsModal:c,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l});g.current=_.length,A.useEffect(()=>{t&&setTimeout(()=>{var x;(x=h.current)==null||x.focus()},50)},[t]),A.useEffect(()=>{if(!t)return;const x=window.visualViewport;if(!x||window.innerWidth>Ut)return;const E=()=>{const I=d.current;I&&(I.style.height=`${x.height}px`,I.style.top=`${x.offsetTop}px`)};return E(),x.addEventListener("resize",E),x.addEventListener("scroll",E),()=>{x.removeEventListener("resize",E),x.removeEventListener("scroll",E);const I=d.current;I&&(I.style.height="",I.style.top="")}},[t]),A.useEffect(()=>{if(!t)return;const x=E=>{if(E.key==="Escape"){E.preventDefault(),E.stopPropagation(),E.stopImmediatePropagation(),e();return}if(E.altKey&&!E.ctrlKey&&!E.metaKey&&(E.key==="n"||E.key==="p"||E.key==="N"||E.key==="P")){E.preventDefault(),E.stopPropagation(),E.stopImmediatePropagation();const I=E.key.toLowerCase(),$=g.current;S(I==="p"?T=>T>0?T-1:$-1:T=>T<$-1?T+1:0);return}};return window.addEventListener("keydown",x,{capture:!0}),()=>{window.removeEventListener("keydown",x,{capture:!0})}},[t,e]);const re=A.useCallback(x=>{x.target===x.currentTarget&&e()},[e]),G=A.useCallback(()=>{S(0)},[S]);return t?f.jsx("div",{ref:d,className:"spotlight-overlay",onClick:re,children:f.jsxs("div",{className:"spotlight-modal",children:[f.jsx(zt,{ref:h,query:y,onQueryChange:b,onKeyDown:W,onResetSelection:G}),f.jsx(Wt,{ref:m,results:_,selectedIndex:k,query:y,highlightMatch:z,onSelectIndex:S}),f.jsx(Vt,{})]})}):null}export{Re as FILE_ICON_NAMES,Xt as Spotlight,Vt as SpotlightFooter,zt as SpotlightInput,Qt as SpotlightItem,Wt as SpotlightResults,Ue as formatDuration,Jt as formatRelativeTime,Kt as getAgentIcon,Pt as getFileIconFromPath,_e as getTypeLabel,Ot as useSpotlightSearch};
@@ -1 +1 @@
1
- import{u as J,a as Z,r,s as u,j as e,D as le,I as H,C as ce,b as ie,c as de,d as oe,g as me,e as ue,Q as be,R as he}from"./main-CjPuuFGh.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const _e=({building:a,connections:x,activeConnectionId:l,activeDatabase:c,collapsed:j,onToggleCollapse:p,onConnectionChange:Q,onDatabaseChange:N,onInsertTable:A,onSelectTableQuery:P})=>{const{t:o}=J(["terminal"]),q=Z(a.id),[M,R]=r.useState(new Set),[w,n]=r.useState(""),[d,T]=r.useState(""),[E,k]=r.useState(!1),[U,F]=r.useState(null),z=r.useRef(null),S=r.useRef(null),O=r.useRef(null),y=l?q.databases.get(l)??[]:[],I=l&&c?`${l}:${c}`:"",f=I?q.tables.get(I)??[]:[],_=l?q.connectionStatus.get(l):void 0,D=r.useMemo(()=>{if(!w.trim())return y;const t=w.toLowerCase();return y.filter(m=>m.toLowerCase().includes(t))},[y,w]),h=r.useMemo(()=>{if(!d.trim())return f;const t=d.toLowerCase();return f.filter(m=>m.name.toLowerCase().includes(t))},[f,d]);r.useEffect(()=>{const t=m=>{S.current&&!S.current.contains(m.target)&&k(!1)};return E&&document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[E]),r.useEffect(()=>{l&&!_&&u.testDatabaseConnection(a.id,l)},[a.id,l,_]),r.useEffect(()=>{l&&(_!=null&&_.connected)&&y.length===0&&u.listDatabases(a.id,l)},[a.id,l,_==null?void 0:_.connected,y.length]),r.useEffect(()=>{l&&c&&f.length===0&&u.listTables(a.id,l,c)},[a.id,l,c,f.length]),r.useEffect(()=>{F(null),T("")},[l,c]);const v=r.useCallback(t=>{R(m=>{const g=new Set(m);if(g.has(t))g.delete(t);else if(g.add(t),l&&c){const C=`${l}:${c}:${t}`;q.tableSchemas.has(C)||u.getTableSchema(a.id,l,c,t)}return g})},[a.id,l,c,q.tableSchemas]),K=t=>{if(!l||!c)return null;const m=`${l}:${c}:${t}`;return q.tableSchemas.get(m)};return j?e.jsx("div",{className:"database-sidebar database-sidebar--collapsed",children:e.jsx("button",{className:"database-sidebar__toggle",onClick:p,title:o("terminal:database.expandSidebar"),children:"»"})}):e.jsxs("div",{className:"database-sidebar",children:[e.jsxs("div",{className:"database-sidebar__header",children:[e.jsx("span",{children:o("terminal:database.explorer")}),e.jsx("button",{className:"database-sidebar__toggle",onClick:p,title:o("terminal:database.collapseSidebar"),children:"«"})]}),e.jsxs("div",{className:"database-sidebar__section",children:[e.jsx("div",{className:"database-sidebar__section-title",children:o("terminal:database.connection")}),e.jsx("select",{className:"database-sidebar__select",value:l||"",onChange:t=>Q(t.target.value),children:x.length===0?e.jsx("option",{value:"",children:o("terminal:database.noConnections")}):x.map(t=>{var m;return e.jsxs("option",{value:t.id,children:[((m=le[t.engine])==null?void 0:m.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:"✓"}),o("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||o("terminal:database.disconnected")]})})]}),y.length>0&&e.jsxs("div",{className:"database-sidebar__section",children:[e.jsx("div",{className:"database-sidebar__section-title",children:o("terminal:database.databaseTitle")}),e.jsxs("div",{className:"database-sidebar__searchable-select",ref:S,children:[e.jsx("input",{ref:z,className:"database-sidebar__search-input",type:"text",value:E?w:c||"",placeholder:o("terminal:database.selectDatabase"),onChange:t=>{n(t.target.value),E||k(!0)},onFocus:()=>{k(!0),n("")},onKeyDown:t=>{var m,g;t.key==="Escape"?(k(!1),n(""),(m=z.current)==null||m.blur()):t.key==="Enter"&&D.length===1&&(N(D[0]),k(!1),n(""),(g=z.current)==null||g.blur())}}),E&&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===c?"database-sidebar__dropdown-item--active":""}`,onMouseDown:m=>{m.preventDefault(),N(t),k(!1),n("")},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:d.trim()?o("terminal:database.tablesCount",{count:h.length})+` / ${f.length}`:o("terminal:database.tablesCount",{count:f.length})}),e.jsxs("div",{className:"database-sidebar__table-filter",children:[e.jsx("input",{ref:O,className:"database-sidebar__table-filter-input",type:"text",value:d,placeholder:o("terminal:database.filterTables"),onChange:t=>T(t.target.value),onKeyDown:t=>{var m;t.key==="Escape"&&(d?T(""):(m=O.current)==null||m.blur(),t.stopPropagation())}}),d&&e.jsx("button",{className:"database-sidebar__table-filter-clear",onClick:()=>{var t;T(""),(t=O.current)==null||t.focus()},title:"Clear filter",children:"×"})]}),e.jsxs("div",{className:"database-sidebar__tables",children:[d.trim()&&h.length===0&&e.jsx("div",{className:"database-sidebar__tables-empty",children:o("terminal:database.noTablesMatch")}),h.map(t=>{const m=M.has(t.name),g=m?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:()=>v(t.name),title:m?"Collapse table schema":"Expand table schema",children:e.jsx(H,{name:m?"caret-down":"caret-right",size:10})}),e.jsx("span",{className:"database-sidebar__table-icon",children:e.jsx(H,{name:t.type==="view"?"eye":"clipboard",size:12})}),e.jsx("span",{className:`database-sidebar__table-name ${U===t.name?"database-sidebar__table-name--selected":""}`,onClick:()=>F(t.name),onDoubleClick:()=>{F(t.name),P(t.name)},children:t.name}),e.jsx("button",{className:"database-sidebar__table-insert",onClick:C=>{C.stopPropagation(),A(t.name)},title:o("terminal:database.insertTableName"),children:"+"})]}),m&&g&&e.jsx("div",{className:"database-sidebar__table-columns",children:g.columns.map(C=>e.jsxs("div",{className:"database-sidebar__column",onClick:()=>A(C.name),title:`${C.type}${C.nullable?" NULL":" NOT NULL"}${C.primaryKey?" PK":""}`,children:[e.jsx("span",{className:"database-sidebar__column-icon",children:C.primaryKey?e.jsx(H,{name:"key",size:11}):null}),e.jsx("span",{className:"database-sidebar__column-name",children:C.name}),e.jsx("span",{className:"database-sidebar__column-type",children:C.type})]},C.name))})]},t.name)})]})]})]})},xe=({buildingId:a,history:x,onLoadQuery:l})=>{const{t:c}=J(["terminal","common"]),[j,p]=r.useState(""),[Q,N]=r.useState(!1),[A,P]=r.useState(!1),o=r.useMemo(()=>{let n=x;if(Q&&(n=n.filter(d=>d.favorite)),j.trim()){const d=j.toLowerCase();n=n.filter(T=>T.query.toLowerCase().includes(d)||T.database.toLowerCase().includes(d))}return n},[x,Q,j]),q=n=>{const d=new Date(n),E=new Date().getTime()-d.getTime();return E<1440*60*1e3?d.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):E<10080*60*1e3?d.toLocaleDateString([],{weekday:"short"})+" "+d.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):d.toLocaleDateString([],{month:"short",day:"numeric"})},M=r.useCallback((n,d)=>{d.stopPropagation(),u.toggleQueryFavorite(a,n)},[a]),R=r.useCallback((n,d)=>{d.stopPropagation(),u.deleteQueryFromHistory(a,n)},[a]),w=r.useCallback(()=>{P(!0)},[]);return x.length===0?e.jsxs("div",{className:"query-history query-history--empty",children:[e.jsx("p",{children:c("terminal:database.noHistory")}),e.jsx("p",{children:c("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:c("terminal:database.searchQueries"),value:j,onChange:n=>p(n.target.value)}),e.jsxs("label",{className:"query-history__filter",children:[e.jsx("input",{type:"checkbox",checked:Q,onChange:n=>N(n.target.checked)}),c("terminal:database.favoritesOnly")]}),e.jsx("button",{className:"query-history__clear",onClick:w,title:c("terminal:database.clearAll"),children:c("terminal:database.clearAll")})]}),e.jsxs("div",{className:"query-history__list",children:[o.map(n=>e.jsxs("div",{className:`query-history__item ${n.status==="error"?"query-history__item--error":""}`,onClick:()=>l(n.query),children:[e.jsxs("div",{className:"query-history__item-header",children:[e.jsx("span",{className:`query-history__status ${n.status==="success"?"query-history__status--success":"query-history__status--error"}`,children:e.jsx(H,{name:n.status==="success"?"check":"cross",size:12})}),e.jsx("span",{className:"query-history__database",children:n.database}),e.jsx("span",{className:"query-history__date",children:q(n.executedAt)}),e.jsxs("span",{className:"query-history__duration",children:[n.duration,"ms"]}),n.rowCount!==void 0&&e.jsx("span",{className:"query-history__row-count",children:c("terminal:database.rowCount",{count:n.rowCount})})]}),e.jsx("div",{className:"query-history__query",children:e.jsx("code",{children:n.query.length>200?n.query.substring(0,200)+"...":n.query})}),n.error&&e.jsx("div",{className:"query-history__error",children:n.error}),e.jsxs("div",{className:"query-history__actions",children:[e.jsx("button",{className:`query-history__favorite ${n.favorite?"query-history__favorite--active":""}`,onClick:d=>M(n.id,d),title:n.favorite?c("terminal:database.removeFromFavorites"):c("terminal:database.addToFavorites"),children:e.jsx(H,{name:"star",size:12,weight:n.favorite?"fill":"regular",color:n.favorite?"#facc15":void 0})}),e.jsx("button",{className:"query-history__delete",onClick:d=>R(n.id,d),title:c("terminal:database.deleteFromHistory"),children:e.jsx(H,{name:"trash",size:12})})]})]},n.id)),o.length===0&&e.jsx("div",{className:"query-history__no-results",children:c("terminal:database.noQueriesMatch")})]}),e.jsx(ce,{isOpen:A,title:c("terminal:database.clearAll"),message:c("terminal:database.confirmClearHistory"),confirmLabel:c("terminal:database.clearAll"),cancelLabel:c("common:buttons.cancel"),variant:"danger",onConfirm:()=>u.clearQueryHistory(a),onClose:()=>P(!1)})]})},pe=({tabs:a,activeTabId:x,onTabClick:l,onTabClose:c})=>{const{t:j}=J(["terminal"]);return e.jsx("div",{className:"database-tabs",children:a.map(p=>e.jsxs("div",{className:`database-tabs__tab ${x===p.id?"database-tabs__tab--active":""}`,children:[e.jsxs("button",{className:"database-tabs__tab-label",onClick:()=>l(p),title:`${p.connectionName} / ${p.database}`,children:[p.database,e.jsx("span",{className:"database-tabs__tab-connection",children:p.connectionName})]}),e.jsx("button",{className:"database-tabs__tab-close",onClick:()=>c(p.id),title:j("terminal:database.closeTab"),"aria-label":`Close ${p.database} tab`,children:"×"})]},p.id))})},ee=a=>`db-panel-${a}`;function fe(a){try{const x=localStorage.getItem(ee(a));return x?JSON.parse(x):{}}catch{return{}}}function je(a,x){try{localStorage.setItem(ee(a),JSON.stringify(x))}catch{}}const Ce=({building:a,onClose:x})=>{var B,Y,W,X;const{t:l}=J(["terminal","common"]),c=Z(a.id),j=ie(a.id),p=de(a.id),Q=oe(a.id),N=r.useRef(fe(a.id)),A=r.useRef(null),P=r.useRef(0),o=((B=a.database)==null?void 0:B.connections)??[],q=(s,i)=>`${s}:${i}`,M=s=>s?(N.current.queries??{})[s]??"":N.current.generalQuery??"",[R,w]=r.useState("results"),[n,d]=r.useState(0),[T,E]=r.useState(!1),[k,U]=r.useState(!1),[F,z]=r.useState(()=>(N.current.openTabs??[]).map(i=>{var b;return{id:`${i.connectionId}:${i.database}`,connectionId:i.connectionId,connectionName:((b=o.find(L=>L.id===i.connectionId))==null?void 0:b.name)??i.connectionId,database:i.database}})),[S,O]=r.useState(N.current.activeTabId??null),[y,I]=r.useState(()=>{const s=N.current.queries??{};return N.current.generalQuery,s}),[f,_]=r.useState(M(S)),D=r.useCallback(s=>{_(i=>{const b=typeof s=="function"?s(i):s;return I(L=>{const $={...L};return S&&($[S]=b),$}),b})},[S]),h=c.activeConnectionId??N.current.connectionId??((Y=a.database)==null?void 0:Y.activeConnectionId)??((W=o[0])==null?void 0:W.id),v=c.activeDatabase??N.current.database??((X=a.database)==null?void 0:X.activeDatabase),K=o.find(s=>s.id===h),t=r.useCallback((s,i)=>{var $;const b=q(s,i),L=(($=o.find(G=>G.id===s))==null?void 0:$.name)??s;z(G=>{if(G.some(re=>re.id===b))return G;const ne={id:b,connectionId:s,connectionName:L,database:i};return[...G,ne]}),O(b),_(y[b]??""),u.setActiveConnection(a.id,s),u.setActiveDatabase(a.id,i)},[a.id,o,y]),m=r.useCallback(s=>{z(i=>i.filter(b=>b.id!==s)),S===s&&z(i=>{if(i.length>0){const b=i[0];O(b.id),_(y[b.id]??""),u.setActiveConnection(a.id,b.connectionId),u.setActiveDatabase(a.id,b.database)}else O(null),_("");return i})},[S,a.id,y]),g=r.useCallback(s=>{O(s.id),_(y[s.id]??""),u.setActiveConnection(a.id,s.connectionId),u.setActiveDatabase(a.id,s.database)},[a.id,y]);r.useEffect(()=>{if(!k&&o.length>0){const s=N.current;s.connectionId&&o.some(i=>i.id===s.connectionId)&&(u.setActiveConnection(a.id,s.connectionId),u.listDatabases(a.id,s.connectionId),s.database&&(u.setActiveDatabase(a.id,s.database),u.listTables(a.id,s.connectionId,s.database))),U(!0)}},[a.id,o,k]),r.useEffect(()=>{u.requestQueryHistory(a.id)},[a.id]),r.useEffect(()=>{const s=i=>{i.key==="Escape"&&(i.preventDefault(),i.stopPropagation(),x())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[x]),r.useEffect(()=>{k&&h&&je(a.id,{connectionId:h,database:v,lastQuery:f,queries:y,generalQuery:"",openTabs:F.map(s=>({connectionId:s.connectionId,database:s.database})),activeTabId:S??void 0})},[a.id,h,v,f,k,F,S,y]);const C=r.useCallback(s=>{var i;if(!(!h||!v||!f.trim()||Q))if(s==="cursor"){const b=(i=A.current)==null?void 0:i.querySelector(".query-editor__textarea"),L=(b==null?void 0:b.selectionStart)??P.current,$=me(f,L);$&&u.executeQuery(a.id,h,v,$)}else{const b=ue(f);b.length<=1?u.executeQuery(a.id,h,v,f.trim()):b.forEach((L,$)=>{setTimeout(()=>{u.executeQuery(a.id,h,v,L.sql)},$*150)})}},[a.id,h,v,f,Q]),ae=r.useCallback(s=>{D(s),w("results")},[]),se=r.useCallback(s=>{u.setActiveConnection(a.id,s),u.listDatabases(a.id,s)},[a.id]),te=r.useCallback(s=>{h&&(t(h,s),u.listTables(a.id,h,s))},[a.id,h,t]),V=j[n];return o.length===0?e.jsxs("div",{className:"database-panel",ref:A,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(H,{name:"database",size:16})}),e.jsx("span",{className:"database-panel__name",children:a.name})]}),e.jsx("button",{className:"database-panel__close",onClick:x,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(H,{name:"plug",size:32})}),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:A,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," / ",v||l("terminal:database.noDatabaseSelected")]})]}),e.jsx("button",{className:"database-panel__close",onClick:x,children:"×"})]}),e.jsxs("div",{className:"database-panel__body",children:[e.jsx(_e,{building:a,connections:o,activeConnectionId:h,activeDatabase:v,collapsed:T,onToggleCollapse:()=>E(!T),onConnectionChange:se,onDatabaseChange:te,onInsertTable:s=>D(i=>i+` ${s}`),onSelectTableQuery:s=>{const i=`SELECT * FROM ${s}`;D(i),h&&v&&u.executeQuery(a.id,h,v,i)}}),e.jsxs("div",{className:"database-panel__main",children:[F.length>0&&e.jsx(pe,{tabs:F,activeTabId:S,onTabClick:g,onTabClose:m}),e.jsx(be,{query:f,onChange:D,onExecute:C,isExecuting:Q,disabled:!h||!v}),e.jsxs("div",{className:"database-panel__tabs",children:[e.jsxs("button",{className:`database-panel__tab ${R==="results"?"database-panel__tab--active":""}`,onClick:()=>w("results"),children:[l("terminal:database.results"),j.length>0&&e.jsx("span",{className:"database-panel__tab-badge",children:j.length})]}),e.jsxs("button",{className:`database-panel__tab ${R==="history"?"database-panel__tab--active":""}`,onClick:()=>w("history"),children:[l("terminal:database.history"),p.length>0&&e.jsx("span",{className:"database-panel__tab-badge",children:p.length})]}),R==="results"&&j.length>1&&e.jsxs("div",{className:"database-panel__result-nav",children:[e.jsxs("button",{disabled:n>=j.length-1,onClick:()=>d(s=>s+1),children:["← ",l("terminal:database.older")]}),e.jsxs("span",{children:[n+1," / ",j.length]}),e.jsxs("button",{disabled:n<=0,onClick:()=>d(s=>s-1),children:[l("terminal:database.newer")," →"]})]})]}),e.jsx("div",{className:"database-panel__tab-content",children:R==="results"?V?e.jsx(he,{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(xe,{buildingId:a.id,history:p,onLoadQuery:ae})})]})]})]})};export{Ce as DatabasePanel,_e as DatabaseSidebar,pe as DatabaseTabs,be as QueryEditor,xe as QueryHistoryPanel,he as ResultsTable};
1
+ import{u as J,a as Z,r,s as u,j as e,D as le,I as H,C as ce,b as ie,c as de,d as oe,g as me,e as ue,Q as be,R as he}from"./main-BvvvhWnd.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const _e=({building:a,connections:x,activeConnectionId:l,activeDatabase:c,collapsed:j,onToggleCollapse:p,onConnectionChange:Q,onDatabaseChange:N,onInsertTable:A,onSelectTableQuery:P})=>{const{t:o}=J(["terminal"]),q=Z(a.id),[M,R]=r.useState(new Set),[w,n]=r.useState(""),[d,T]=r.useState(""),[E,k]=r.useState(!1),[U,F]=r.useState(null),z=r.useRef(null),S=r.useRef(null),O=r.useRef(null),y=l?q.databases.get(l)??[]:[],I=l&&c?`${l}:${c}`:"",f=I?q.tables.get(I)??[]:[],_=l?q.connectionStatus.get(l):void 0,D=r.useMemo(()=>{if(!w.trim())return y;const t=w.toLowerCase();return y.filter(m=>m.toLowerCase().includes(t))},[y,w]),h=r.useMemo(()=>{if(!d.trim())return f;const t=d.toLowerCase();return f.filter(m=>m.name.toLowerCase().includes(t))},[f,d]);r.useEffect(()=>{const t=m=>{S.current&&!S.current.contains(m.target)&&k(!1)};return E&&document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[E]),r.useEffect(()=>{l&&!_&&u.testDatabaseConnection(a.id,l)},[a.id,l,_]),r.useEffect(()=>{l&&(_!=null&&_.connected)&&y.length===0&&u.listDatabases(a.id,l)},[a.id,l,_==null?void 0:_.connected,y.length]),r.useEffect(()=>{l&&c&&f.length===0&&u.listTables(a.id,l,c)},[a.id,l,c,f.length]),r.useEffect(()=>{F(null),T("")},[l,c]);const v=r.useCallback(t=>{R(m=>{const g=new Set(m);if(g.has(t))g.delete(t);else if(g.add(t),l&&c){const C=`${l}:${c}:${t}`;q.tableSchemas.has(C)||u.getTableSchema(a.id,l,c,t)}return g})},[a.id,l,c,q.tableSchemas]),K=t=>{if(!l||!c)return null;const m=`${l}:${c}:${t}`;return q.tableSchemas.get(m)};return j?e.jsx("div",{className:"database-sidebar database-sidebar--collapsed",children:e.jsx("button",{className:"database-sidebar__toggle",onClick:p,title:o("terminal:database.expandSidebar"),children:"»"})}):e.jsxs("div",{className:"database-sidebar",children:[e.jsxs("div",{className:"database-sidebar__header",children:[e.jsx("span",{children:o("terminal:database.explorer")}),e.jsx("button",{className:"database-sidebar__toggle",onClick:p,title:o("terminal:database.collapseSidebar"),children:"«"})]}),e.jsxs("div",{className:"database-sidebar__section",children:[e.jsx("div",{className:"database-sidebar__section-title",children:o("terminal:database.connection")}),e.jsx("select",{className:"database-sidebar__select",value:l||"",onChange:t=>Q(t.target.value),children:x.length===0?e.jsx("option",{value:"",children:o("terminal:database.noConnections")}):x.map(t=>{var m;return e.jsxs("option",{value:t.id,children:[((m=le[t.engine])==null?void 0:m.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:"✓"}),o("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||o("terminal:database.disconnected")]})})]}),y.length>0&&e.jsxs("div",{className:"database-sidebar__section",children:[e.jsx("div",{className:"database-sidebar__section-title",children:o("terminal:database.databaseTitle")}),e.jsxs("div",{className:"database-sidebar__searchable-select",ref:S,children:[e.jsx("input",{ref:z,className:"database-sidebar__search-input",type:"text",value:E?w:c||"",placeholder:o("terminal:database.selectDatabase"),onChange:t=>{n(t.target.value),E||k(!0)},onFocus:()=>{k(!0),n("")},onKeyDown:t=>{var m,g;t.key==="Escape"?(k(!1),n(""),(m=z.current)==null||m.blur()):t.key==="Enter"&&D.length===1&&(N(D[0]),k(!1),n(""),(g=z.current)==null||g.blur())}}),E&&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===c?"database-sidebar__dropdown-item--active":""}`,onMouseDown:m=>{m.preventDefault(),N(t),k(!1),n("")},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:d.trim()?o("terminal:database.tablesCount",{count:h.length})+` / ${f.length}`:o("terminal:database.tablesCount",{count:f.length})}),e.jsxs("div",{className:"database-sidebar__table-filter",children:[e.jsx("input",{ref:O,className:"database-sidebar__table-filter-input",type:"text",value:d,placeholder:o("terminal:database.filterTables"),onChange:t=>T(t.target.value),onKeyDown:t=>{var m;t.key==="Escape"&&(d?T(""):(m=O.current)==null||m.blur(),t.stopPropagation())}}),d&&e.jsx("button",{className:"database-sidebar__table-filter-clear",onClick:()=>{var t;T(""),(t=O.current)==null||t.focus()},title:"Clear filter",children:"×"})]}),e.jsxs("div",{className:"database-sidebar__tables",children:[d.trim()&&h.length===0&&e.jsx("div",{className:"database-sidebar__tables-empty",children:o("terminal:database.noTablesMatch")}),h.map(t=>{const m=M.has(t.name),g=m?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:()=>v(t.name),title:m?"Collapse table schema":"Expand table schema",children:e.jsx(H,{name:m?"caret-down":"caret-right",size:10})}),e.jsx("span",{className:"database-sidebar__table-icon",children:e.jsx(H,{name:t.type==="view"?"eye":"clipboard",size:12})}),e.jsx("span",{className:`database-sidebar__table-name ${U===t.name?"database-sidebar__table-name--selected":""}`,onClick:()=>F(t.name),onDoubleClick:()=>{F(t.name),P(t.name)},children:t.name}),e.jsx("button",{className:"database-sidebar__table-insert",onClick:C=>{C.stopPropagation(),A(t.name)},title:o("terminal:database.insertTableName"),children:"+"})]}),m&&g&&e.jsx("div",{className:"database-sidebar__table-columns",children:g.columns.map(C=>e.jsxs("div",{className:"database-sidebar__column",onClick:()=>A(C.name),title:`${C.type}${C.nullable?" NULL":" NOT NULL"}${C.primaryKey?" PK":""}`,children:[e.jsx("span",{className:"database-sidebar__column-icon",children:C.primaryKey?e.jsx(H,{name:"key",size:11}):null}),e.jsx("span",{className:"database-sidebar__column-name",children:C.name}),e.jsx("span",{className:"database-sidebar__column-type",children:C.type})]},C.name))})]},t.name)})]})]})]})},xe=({buildingId:a,history:x,onLoadQuery:l})=>{const{t:c}=J(["terminal","common"]),[j,p]=r.useState(""),[Q,N]=r.useState(!1),[A,P]=r.useState(!1),o=r.useMemo(()=>{let n=x;if(Q&&(n=n.filter(d=>d.favorite)),j.trim()){const d=j.toLowerCase();n=n.filter(T=>T.query.toLowerCase().includes(d)||T.database.toLowerCase().includes(d))}return n},[x,Q,j]),q=n=>{const d=new Date(n),E=new Date().getTime()-d.getTime();return E<1440*60*1e3?d.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):E<10080*60*1e3?d.toLocaleDateString([],{weekday:"short"})+" "+d.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):d.toLocaleDateString([],{month:"short",day:"numeric"})},M=r.useCallback((n,d)=>{d.stopPropagation(),u.toggleQueryFavorite(a,n)},[a]),R=r.useCallback((n,d)=>{d.stopPropagation(),u.deleteQueryFromHistory(a,n)},[a]),w=r.useCallback(()=>{P(!0)},[]);return x.length===0?e.jsxs("div",{className:"query-history query-history--empty",children:[e.jsx("p",{children:c("terminal:database.noHistory")}),e.jsx("p",{children:c("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:c("terminal:database.searchQueries"),value:j,onChange:n=>p(n.target.value)}),e.jsxs("label",{className:"query-history__filter",children:[e.jsx("input",{type:"checkbox",checked:Q,onChange:n=>N(n.target.checked)}),c("terminal:database.favoritesOnly")]}),e.jsx("button",{className:"query-history__clear",onClick:w,title:c("terminal:database.clearAll"),children:c("terminal:database.clearAll")})]}),e.jsxs("div",{className:"query-history__list",children:[o.map(n=>e.jsxs("div",{className:`query-history__item ${n.status==="error"?"query-history__item--error":""}`,onClick:()=>l(n.query),children:[e.jsxs("div",{className:"query-history__item-header",children:[e.jsx("span",{className:`query-history__status ${n.status==="success"?"query-history__status--success":"query-history__status--error"}`,children:e.jsx(H,{name:n.status==="success"?"check":"cross",size:12})}),e.jsx("span",{className:"query-history__database",children:n.database}),e.jsx("span",{className:"query-history__date",children:q(n.executedAt)}),e.jsxs("span",{className:"query-history__duration",children:[n.duration,"ms"]}),n.rowCount!==void 0&&e.jsx("span",{className:"query-history__row-count",children:c("terminal:database.rowCount",{count:n.rowCount})})]}),e.jsx("div",{className:"query-history__query",children:e.jsx("code",{children:n.query.length>200?n.query.substring(0,200)+"...":n.query})}),n.error&&e.jsx("div",{className:"query-history__error",children:n.error}),e.jsxs("div",{className:"query-history__actions",children:[e.jsx("button",{className:`query-history__favorite ${n.favorite?"query-history__favorite--active":""}`,onClick:d=>M(n.id,d),title:n.favorite?c("terminal:database.removeFromFavorites"):c("terminal:database.addToFavorites"),children:e.jsx(H,{name:"star",size:12,weight:n.favorite?"fill":"regular",color:n.favorite?"#facc15":void 0})}),e.jsx("button",{className:"query-history__delete",onClick:d=>R(n.id,d),title:c("terminal:database.deleteFromHistory"),children:e.jsx(H,{name:"trash",size:12})})]})]},n.id)),o.length===0&&e.jsx("div",{className:"query-history__no-results",children:c("terminal:database.noQueriesMatch")})]}),e.jsx(ce,{isOpen:A,title:c("terminal:database.clearAll"),message:c("terminal:database.confirmClearHistory"),confirmLabel:c("terminal:database.clearAll"),cancelLabel:c("common:buttons.cancel"),variant:"danger",onConfirm:()=>u.clearQueryHistory(a),onClose:()=>P(!1)})]})},pe=({tabs:a,activeTabId:x,onTabClick:l,onTabClose:c})=>{const{t:j}=J(["terminal"]);return e.jsx("div",{className:"database-tabs",children:a.map(p=>e.jsxs("div",{className:`database-tabs__tab ${x===p.id?"database-tabs__tab--active":""}`,children:[e.jsxs("button",{className:"database-tabs__tab-label",onClick:()=>l(p),title:`${p.connectionName} / ${p.database}`,children:[p.database,e.jsx("span",{className:"database-tabs__tab-connection",children:p.connectionName})]}),e.jsx("button",{className:"database-tabs__tab-close",onClick:()=>c(p.id),title:j("terminal:database.closeTab"),"aria-label":`Close ${p.database} tab`,children:"×"})]},p.id))})},ee=a=>`db-panel-${a}`;function fe(a){try{const x=localStorage.getItem(ee(a));return x?JSON.parse(x):{}}catch{return{}}}function je(a,x){try{localStorage.setItem(ee(a),JSON.stringify(x))}catch{}}const Ce=({building:a,onClose:x})=>{var B,Y,W,X;const{t:l}=J(["terminal","common"]),c=Z(a.id),j=ie(a.id),p=de(a.id),Q=oe(a.id),N=r.useRef(fe(a.id)),A=r.useRef(null),P=r.useRef(0),o=((B=a.database)==null?void 0:B.connections)??[],q=(s,i)=>`${s}:${i}`,M=s=>s?(N.current.queries??{})[s]??"":N.current.generalQuery??"",[R,w]=r.useState("results"),[n,d]=r.useState(0),[T,E]=r.useState(!1),[k,U]=r.useState(!1),[F,z]=r.useState(()=>(N.current.openTabs??[]).map(i=>{var b;return{id:`${i.connectionId}:${i.database}`,connectionId:i.connectionId,connectionName:((b=o.find(L=>L.id===i.connectionId))==null?void 0:b.name)??i.connectionId,database:i.database}})),[S,O]=r.useState(N.current.activeTabId??null),[y,I]=r.useState(()=>{const s=N.current.queries??{};return N.current.generalQuery,s}),[f,_]=r.useState(M(S)),D=r.useCallback(s=>{_(i=>{const b=typeof s=="function"?s(i):s;return I(L=>{const $={...L};return S&&($[S]=b),$}),b})},[S]),h=c.activeConnectionId??N.current.connectionId??((Y=a.database)==null?void 0:Y.activeConnectionId)??((W=o[0])==null?void 0:W.id),v=c.activeDatabase??N.current.database??((X=a.database)==null?void 0:X.activeDatabase),K=o.find(s=>s.id===h),t=r.useCallback((s,i)=>{var $;const b=q(s,i),L=(($=o.find(G=>G.id===s))==null?void 0:$.name)??s;z(G=>{if(G.some(re=>re.id===b))return G;const ne={id:b,connectionId:s,connectionName:L,database:i};return[...G,ne]}),O(b),_(y[b]??""),u.setActiveConnection(a.id,s),u.setActiveDatabase(a.id,i)},[a.id,o,y]),m=r.useCallback(s=>{z(i=>i.filter(b=>b.id!==s)),S===s&&z(i=>{if(i.length>0){const b=i[0];O(b.id),_(y[b.id]??""),u.setActiveConnection(a.id,b.connectionId),u.setActiveDatabase(a.id,b.database)}else O(null),_("");return i})},[S,a.id,y]),g=r.useCallback(s=>{O(s.id),_(y[s.id]??""),u.setActiveConnection(a.id,s.connectionId),u.setActiveDatabase(a.id,s.database)},[a.id,y]);r.useEffect(()=>{if(!k&&o.length>0){const s=N.current;s.connectionId&&o.some(i=>i.id===s.connectionId)&&(u.setActiveConnection(a.id,s.connectionId),u.listDatabases(a.id,s.connectionId),s.database&&(u.setActiveDatabase(a.id,s.database),u.listTables(a.id,s.connectionId,s.database))),U(!0)}},[a.id,o,k]),r.useEffect(()=>{u.requestQueryHistory(a.id)},[a.id]),r.useEffect(()=>{const s=i=>{i.key==="Escape"&&(i.preventDefault(),i.stopPropagation(),x())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[x]),r.useEffect(()=>{k&&h&&je(a.id,{connectionId:h,database:v,lastQuery:f,queries:y,generalQuery:"",openTabs:F.map(s=>({connectionId:s.connectionId,database:s.database})),activeTabId:S??void 0})},[a.id,h,v,f,k,F,S,y]);const C=r.useCallback(s=>{var i;if(!(!h||!v||!f.trim()||Q))if(s==="cursor"){const b=(i=A.current)==null?void 0:i.querySelector(".query-editor__textarea"),L=(b==null?void 0:b.selectionStart)??P.current,$=me(f,L);$&&u.executeQuery(a.id,h,v,$)}else{const b=ue(f);b.length<=1?u.executeQuery(a.id,h,v,f.trim()):b.forEach((L,$)=>{setTimeout(()=>{u.executeQuery(a.id,h,v,L.sql)},$*150)})}},[a.id,h,v,f,Q]),ae=r.useCallback(s=>{D(s),w("results")},[]),se=r.useCallback(s=>{u.setActiveConnection(a.id,s),u.listDatabases(a.id,s)},[a.id]),te=r.useCallback(s=>{h&&(t(h,s),u.listTables(a.id,h,s))},[a.id,h,t]),V=j[n];return o.length===0?e.jsxs("div",{className:"database-panel",ref:A,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(H,{name:"database",size:16})}),e.jsx("span",{className:"database-panel__name",children:a.name})]}),e.jsx("button",{className:"database-panel__close",onClick:x,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(H,{name:"plug",size:32})}),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:A,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," / ",v||l("terminal:database.noDatabaseSelected")]})]}),e.jsx("button",{className:"database-panel__close",onClick:x,children:"×"})]}),e.jsxs("div",{className:"database-panel__body",children:[e.jsx(_e,{building:a,connections:o,activeConnectionId:h,activeDatabase:v,collapsed:T,onToggleCollapse:()=>E(!T),onConnectionChange:se,onDatabaseChange:te,onInsertTable:s=>D(i=>i+` ${s}`),onSelectTableQuery:s=>{const i=`SELECT * FROM ${s}`;D(i),h&&v&&u.executeQuery(a.id,h,v,i)}}),e.jsxs("div",{className:"database-panel__main",children:[F.length>0&&e.jsx(pe,{tabs:F,activeTabId:S,onTabClick:g,onTabClose:m}),e.jsx(be,{query:f,onChange:D,onExecute:C,isExecuting:Q,disabled:!h||!v}),e.jsxs("div",{className:"database-panel__tabs",children:[e.jsxs("button",{className:`database-panel__tab ${R==="results"?"database-panel__tab--active":""}`,onClick:()=>w("results"),children:[l("terminal:database.results"),j.length>0&&e.jsx("span",{className:"database-panel__tab-badge",children:j.length})]}),e.jsxs("button",{className:`database-panel__tab ${R==="history"?"database-panel__tab--active":""}`,onClick:()=>w("history"),children:[l("terminal:database.history"),p.length>0&&e.jsx("span",{className:"database-panel__tab-badge",children:p.length})]}),R==="results"&&j.length>1&&e.jsxs("div",{className:"database-panel__result-nav",children:[e.jsxs("button",{disabled:n>=j.length-1,onClick:()=>d(s=>s+1),children:["← ",l("terminal:database.older")]}),e.jsxs("span",{children:[n+1," / ",j.length]}),e.jsxs("button",{disabled:n<=0,onClick:()=>d(s=>s-1),children:[l("terminal:database.newer")," →"]})]})]}),e.jsx("div",{className:"database-panel__tab-content",children:R==="results"?V?e.jsx(he,{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(xe,{buildingId:a.id,history:p,onLoadQuery:ae})})]})]})]})};export{Ce as DatabasePanel,_e as DatabaseSidebar,pe as DatabaseTabs,be as QueryEditor,xe as QueryHistoryPanel,he as ResultsTable};