@hienlh/ppm 0.13.65 → 0.13.67

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 (52) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/assets/skills/ppm/SKILL.md +1 -1
  3. package/assets/skills/ppm/references/http-api.md +2 -1
  4. package/dist/web/assets/{audio-preview-Bog1sIoF.js → audio-preview-Iq-XRBGw.js} +1 -1
  5. package/dist/web/assets/{chat-tab-B-uVAh4d.js → chat-tab-DkVXRD9e.js} +3 -3
  6. package/dist/web/assets/{code-editor-cDv3opsJ.js → code-editor-M6wHw8AZ.js} +2 -2
  7. package/dist/web/assets/{conflict-editor-D5sEfbcX.js → conflict-editor-D_8t44Wi.js} +1 -1
  8. package/dist/web/assets/{database-viewer-BGBVsG5J.js → database-viewer-Cj5yCn4w.js} +1 -1
  9. package/dist/web/assets/diff-viewer-BgPv67fJ.js +4 -0
  10. package/dist/web/assets/{docx-preview-ByzSlSgn.js → docx-preview-BbmDvXdS.js} +1 -1
  11. package/dist/web/assets/extension-webview-CP_AtfYs.js +3 -0
  12. package/dist/web/assets/{git-log-panel-C1T8bav0.js → git-log-panel-DPRoZgWG.js} +1 -1
  13. package/dist/web/assets/{glide-data-grid-DV8ht1BP.js → glide-data-grid-BrtUKC3w.js} +1 -1
  14. package/dist/web/assets/{image-preview-Dbo7SAVb.js → image-preview-BFj-ipom.js} +1 -1
  15. package/dist/web/assets/{index-DU_JZ5MY.js → index-CJZZ6v1o.js} +3 -3
  16. package/dist/web/assets/keybindings-store-BOV4khyp.js +1 -0
  17. package/dist/web/assets/{markdown-renderer-D-QbsfIC.js → markdown-renderer-B63eYfrn.js} +1 -1
  18. package/dist/web/assets/notification-store-BklO85um.js +1 -0
  19. package/dist/web/assets/{pdf-preview-DV96VPTb.js → pdf-preview-JOwOGTIk.js} +1 -1
  20. package/dist/web/assets/{port-forwarding-tab-C4OYC71C.js → port-forwarding-tab-DJRRbLGF.js} +1 -1
  21. package/dist/web/assets/{postgres-viewer-hb-_twEU.js → postgres-viewer-AIOBOfCg.js} +1 -1
  22. package/dist/web/assets/{settings-tab-BUCIqVAl.js → settings-tab-BMHf9pO5.js} +1 -1
  23. package/dist/web/assets/{sql-query-editor-C7YgtDR3.js → sql-query-editor-Dw9UvzWt.js} +1 -1
  24. package/dist/web/assets/{sqlite-viewer-z3pGFSje.js → sqlite-viewer-HusTxs1Z.js} +1 -1
  25. package/dist/web/assets/system-monitor-tab-BNJIkOan.js +1 -0
  26. package/dist/web/assets/{terminal-tab-DbxLHofN.js → terminal-tab-W1VShnP7.js} +1 -1
  27. package/dist/web/assets/{video-preview-DylSBAzo.js → video-preview-BPAYbuvs.js} +1 -1
  28. package/dist/web/index.html +1 -1
  29. package/dist/web/sw.js +1 -1
  30. package/package.json +1 -1
  31. package/src/index.ts +0 -0
  32. package/src/server/middleware/auth.ts +1 -1
  33. package/src/server/routes/fs-browse.ts +18 -4
  34. package/src/server/routes/git.ts +2 -1
  35. package/src/services/download-token.service.ts +1 -2
  36. package/src/services/git.service.ts +17 -7
  37. package/src/services/resource-monitor-utils.ts +18 -6
  38. package/src/services/resource-monitor.service.ts +3 -2
  39. package/src/web/components/editor/diff-viewer.tsx +1 -0
  40. package/src/web/components/extensions/extension-webview.tsx +2 -2
  41. package/src/web/components/system/system-monitor-group-row.tsx +27 -7
  42. package/src/web/components/system/system-monitor-tab.tsx +1 -1
  43. package/src/web/hooks/use-extension-ws.ts +16 -3
  44. package/src/web/hooks/use-resource-monitor.ts +1 -1
  45. package/src/web/lib/file-download.ts +8 -0
  46. package/bun.lock +0 -2170
  47. package/bunfig.toml +0 -2
  48. package/dist/web/assets/diff-viewer-B-O1mvHO.js +0 -4
  49. package/dist/web/assets/extension-webview-0qfU1r7z.js +0 -3
  50. package/dist/web/assets/keybindings-store-0FUOwc9I.js +0 -1
  51. package/dist/web/assets/notification-store-bwd1UKbs.js +0 -1
  52. package/dist/web/assets/system-monitor-tab-Bj6pcRmV.js +0 -1
package/bunfig.toml DELETED
@@ -1,2 +0,0 @@
1
- [test]
2
- preload = ["./tests/test-setup.ts"]
@@ -1,4 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import{t as r}from"./text-wrap-AZErifCu.js";import{i,t as a}from"./api-client-DiZgVOok.js";import{n as o}from"./settings-store-CSDOihqv.js";import"./vendor-mermaid-DCie7hiR.js";import{_ as s,et as c,st as l}from"./index-DU_JZ5MY.js";import{r as u,t as d}from"./use-monaco-theme-qx6SfVRk.js";var f=e(n(),1),p=t();function m(e){return{js:`javascript`,jsx:`javascript`,ts:`typescript`,tsx:`typescript`,py:`python`,html:`html`,css:`css`,scss:`scss`,json:`json`,md:`markdown`,mdx:`markdown`,yaml:`yaml`,yml:`yaml`,sh:`shell`,bash:`shell`}[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function h({metadata:e}){let t=e?.filePath,n=e?.projectName,h=e?.ref1,_=e?.ref2,v=e?.file1,y=e?.file2,b=e?.original,x=e?.modified,S=b!=null||x!=null,C=!!(v&&y),[w,T]=(0,f.useState)(null),[E,D]=(0,f.useState)(null),[O,k]=(0,f.useState)(null),[A,j]=(0,f.useState)(!S),[M,N]=(0,f.useState)(null),{wordWrap:P,toggleWordWrap:F}=o(s(e=>({wordWrap:e.wordWrap,toggleWordWrap:e.toggleWordWrap}))),I=d(),L=(0,f.useRef)(null),R=(0,f.useRef)(null),[z,B]=(0,f.useState)(!1),[V,H]=(0,f.useState)();(0,f.useEffect)(()=>{let e=L.current;if(!e)return;let t=new ResizeObserver(([e])=>{e&&H(Math.floor(e.contentRect.height))});return t.observe(e),()=>t.disconnect()},[A,M]),(0,f.useEffect)(()=>{if(S||!n)return;if(j(!0),N(null),k(null),D(null),T(null),v&&y){let e=new URLSearchParams({file1:v,file2:y});a.get(`${i(n)}/files/compare?${e}`).then(e=>{D(e),j(!1)}).catch(e=>{N(e instanceof Error?e.message:`Failed to compare files`),j(!1)});return}if(t){let e=new URLSearchParams({file:t});h&&e.set(`ref`,h),a.get(`${i(n)}/git/file-full-diff?${e}`).then(e=>{k(e),j(!1)}).catch(e=>{N(e instanceof Error?e.message:`Failed to load diff`),j(!1)});return}let e;if(h||_){let t=new URLSearchParams;h&&t.set(`ref1`,h),_&&t.set(`ref2`,_),e=`${i(n)}/git/diff?${t}`}else e=`${i(n)}/git/diff`;a.get(e).then(e=>{T(e.diff),j(!1)}).catch(e=>{N(e instanceof Error?e.message:`Failed to load diff`),j(!1)})},[t,n,h,_,v,y,S]);let{original:U,modified:W}=(0,f.useMemo)(()=>S?{original:b??``,modified:x??``}:C&&E?E:O||(w?g(w):{original:``,modified:``}),[w,S,b,x,C,E,O]),G=(0,f.useMemo)(()=>{let e=t??y??v;return e?m(e):`plaintext`},[t,v,y]),K=typeof window<`u`&&window.innerWidth<768,q=!K;return(0,f.useEffect)(()=>{let e=R.current;if(!e)return;let t=K||P?`on`:`off`;e.updateOptions({diffWordWrap:t}),e.getOriginalEditor().updateOptions({wordWrapOverride2:t}),e.getModifiedEditor().updateOptions({wordWrapOverride2:t})},[P,K,z]),!n&&!S?(0,p.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`No project selected.`}):A?(0,p.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,p.jsx)(c,{className:`size-5 animate-spin`}),(0,p.jsx)(`span`,{className:`text-sm`,children:`Loading diff...`})]}):M?(0,p.jsx)(`div`,{className:`flex items-center justify-center h-full text-destructive text-sm`,children:M}):!S&&!C&&!O&&!U&&!W?(0,p.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,p.jsx)(l,{className:`size-8`}),(0,p.jsx)(`p`,{className:`text-sm`,children:`No content changes`}),t&&(0,p.jsx)(`p`,{className:`text-xs font-mono`,children:t})]}):(0,p.jsxs)(`div`,{className:`flex flex-col h-full`,children:[!K&&(0,p.jsx)(`div`,{className:`flex items-center justify-end gap-0.5 px-2 py-0.5 border-b border-border shrink-0`,children:(0,p.jsx)(`button`,{type:`button`,onClick:F,title:`Toggle word wrap`,className:`p-1 rounded hover:bg-muted transition-colors ${P?`bg-muted text-foreground`:``}`,children:(0,p.jsx)(r,{className:`size-3.5`})})}),(0,p.jsx)(`div`,{ref:L,className:`flex-1 overflow-hidden`,children:V&&V>0?(0,p.jsx)(u,{height:V,language:G,original:U,modified:W,theme:I,onMount:e=>{R.current=e,B(!0)},options:{fontSize:K?11:13,fontFamily:`Menlo, Monaco, Consolas, monospace`,diffWordWrap:K||P?`on`:`off`,renderSideBySide:q,useInlineViewWhenSpaceIsLimited:!1,readOnly:!0,automaticLayout:!0,scrollBeyondLastLine:!1},loading:(0,p.jsx)(c,{className:`size-5 animate-spin text-muted-foreground`})}):(0,p.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,p.jsx)(c,{className:`size-5 animate-spin text-muted-foreground`})})})]})}function g(e){let t=e.split(`
2
- `),n=[],r=[],i=!1;for(let e of t)if(!(e.startsWith(`diff --git`)||e.startsWith(`diff --no-index`)||e.startsWith(`index `)||e.startsWith(`new file`)||e.startsWith(`deleted file`)||e.startsWith(`old mode`)||e.startsWith(`new mode`)||e.startsWith(`---`)||e.startsWith(`+++`)||e.startsWith(`Binary files`)||e.startsWith(`\\ No newline`))){if(e.startsWith(`@@`)){i=!0;continue}if(i)if(e.startsWith(`-`))n.push(e.slice(1));else if(e.startsWith(`+`))r.push(e.slice(1));else{let t=e.startsWith(` `)?e.slice(1):e;n.push(t),r.push(t)}}return{original:n.join(`
3
- `),modified:r.join(`
4
- `)}}export{h as DiffViewer};
@@ -1,3 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import{r}from"./api-client-DiZgVOok.js";import{et as i,x as a}from"./index-DU_JZ5MY.js";var o=e(n(),1),s=t(),c=`<script>
2
- function acquireVsCodeApi(){return{postMessage:function(m){window.parent.postMessage(m,"*")},getState:function(){try{return JSON.parse(sessionStorage.getItem("vscode-state")||"null")}catch{return null}},setState:function(s){sessionStorage.setItem("vscode-state",JSON.stringify(s));return s}}}
3
- <\/script>`;function l(e){if(!e)return e;let t=e.indexOf(`<head>`);return t===-1?c+e:e.slice(0,t+6)+c+e.slice(t+6)}function u({metadata:e}){let t=e?.panelId,n=e?.viewType,c=e?.projectName||void 0,[u,d]=(0,o.useState)(!1),f=a(e=>e.contributions!==null),p=a(e=>{if(t&&e.webviewPanels[t])return e.webviewPanels[t];if(n){let t=n.includes(`.`)?n:`${n}.view`;return Object.values(e.webviewPanels).find(e=>e.viewType===n||e.viewType===t)}}),m=p?.id??t,h=(0,o.useRef)(null),g=p?.html??``,_=l(g),v=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(p||!n||!f||c&&c===v.current)return;c&&(v.current=c);let e=n.includes(`.`)?n:`${n}.view`,t=!1;async function i(){let n=[];if(c)try{let e=r(),t=(await(await fetch(`/api/projects`,e?{headers:{Authorization:`Bearer ${e}`}}:{})).json()).data?.find(e=>e.name===c);t&&(n=[t.path])}catch{}t||window.dispatchEvent(new CustomEvent(`ext:command:execute`,{detail:{command:e,args:n}}))}return i(),()=>{t=!0}},[p,n,c,f]);let y=e?.extensionId,b=a(e=>{if(y&&e.activationErrors[y])return e.activationErrors[y];if(n){for(let[t,r]of Object.entries(e.activationErrors))if(t===`ext-${n}`)return r}}),x=(0,o.useCallback)(()=>{if(d(!1),!n)return;let e=n.includes(`.`)?n:`${n}.view`;(async()=>{try{let t=r(),n=(await(await fetch(`/api/projects`,t?{headers:{Authorization:`Bearer ${t}`}}:{})).json()).data?.find(e=>e.name===c),i=n?[n.path]:[];window.dispatchEvent(new CustomEvent(`ext:command:execute`,{detail:{command:e,args:i}}))}catch{}})()},[n,c]),S=(0,o.useRef)(null),C=(0,o.useRef)(n);return(0,o.useEffect)(()=>{S.current=m??null},[m]),(0,o.useEffect)(()=>{C.current=n},[n]),(0,o.useEffect)(()=>()=>{let e=S.current;if(e){let t=C.current;a.getState().removeWebviewPanel(e),window.dispatchEvent(new CustomEvent(`ext:webview:close`,{detail:{panelId:e,viewType:t}}))}},[]),(0,o.useEffect)(()=>{if(p){d(!1);return}if(!f||!n)return;let e=0,t=setInterval(()=>{if(e++,e>3){clearInterval(t),d(!0);return}x()},2e3);return()=>clearInterval(t)},[p,f,n,x]),(0,o.useEffect)(()=>{if(!m)return;let e=e=>{h.current&&e.source===h.current.contentWindow&&window.dispatchEvent(new CustomEvent(`ext:webview:send`,{detail:{panelId:m,message:e.data}}))};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[m]),(0,o.useEffect)(()=>{if(!m)return;let e=e=>{let{panelId:t,message:n}=e.detail;t===m&&h.current?.contentWindow?.postMessage(n,`*`)};return window.addEventListener(`ext:webview:message`,e),()=>window.removeEventListener(`ext:webview:message`,e)},[m]),!p||!g?(0,s.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-sm text-text-subtle`,children:u?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`span`,{className:`text-destructive font-medium`,children:`Extension failed to load`}),b&&(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground max-w-md text-center`,children:b}),(0,s.jsx)(`button`,{onClick:x,className:`text-xs text-primary hover:underline`,children:`Retry`})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i,{className:`size-5 animate-spin`}),(0,s.jsx)(`span`,{children:`Loading extension...`})]})}):(0,s.jsx)(`div`,{className:`h-full w-full relative`,children:(0,s.jsx)(`iframe`,{ref:h,srcDoc:_,sandbox:`allow-scripts`,className:`w-full h-full border-0 bg-white dark:bg-zinc-900`,title:p.title},m)})}export{u as ExtensionWebview};
@@ -1 +0,0 @@
1
- import"./vendor-markdown-0Mxgxy0L.js";import"./api-client-DiZgVOok.js";import{D as e}from"./index-DU_JZ5MY.js";export{e as useKeybindingsStore};
@@ -1 +0,0 @@
1
- import"./vendor-markdown-0Mxgxy0L.js";import"./api-client-DiZgVOok.js";import{P as e}from"./index-DU_JZ5MY.js";export{e as useNotificationStore};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import"./vendor-ui-UXCWAcmi.js";import{t as r}from"./createLucideIcon-BjHrJDVb.js";import{t as i}from"./arrow-down-D825m4vm.js";import{t as a}from"./arrow-up-Rcw6_KKu.js";import{n as o,t as s}from"./chevron-down-BMo4cBth.js";import{t as c}from"./chevron-right-CD8e6Aj4.js";import{t as l}from"./wifi-LJEyIdXf.js";import{t as u}from"./x-DfF6D5Js.js";import{t as d}from"./api-client-DiZgVOok.js";import{n as f}from"./utils-E0yyGxXt.js";import{B as p,J as m,R as h,Z as g,a as _,g as v}from"./index-DU_JZ5MY.js";var y=r(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),b=r(`hammer`,[[`path`,{d:`m15 12-9.373 9.373a1 1 0 0 1-3.001-3L12 9`,key:`1hayfq`}],[`path`,{d:`m18 15 4-4`,key:`16gjal`}],[`path`,{d:`m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172v-.344a2 2 0 0 0-.586-1.414l-1.657-1.657A6 6 0 0 0 12.516 3H9l1.243 1.243A6 6 0 0 1 12 8.485V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5`,key:`15ts47`}]]),x=e(n(),1),S=t(),C=(0,x.memo)(function({data:e,width:t=120,height:n=24,color:r=`#3b82f6`}){let i=(0,x.useRef)(null),a=(0,x.useRef)(0);return(0,x.useEffect)(()=>{let o=Date.now();if(o-a.current<1e3)return;a.current=o;let s=i.current;if(!s||e.length<2)return;let c=s.getContext(`2d`);if(!c)return;let l=window.devicePixelRatio||1;s.width=t*l,s.height=n*l,c.scale(l,l),c.clearRect(0,0,t,n);let u=Math.max(...e,1),d=t/(e.length-1),f=n-4;c.beginPath(),c.strokeStyle=r,c.lineWidth=1.5,c.lineJoin=`round`;for(let t=0;t<e.length;t++){let n=t*d,r=2+f-e[t]/u*f;t===0?c.moveTo(n,r):c.lineTo(n,r)}c.stroke()},[e,t,n,r]),(0,S.jsx)(`canvas`,{ref:i,style:{width:t,height:n},className:`inline-block`})});function w(e){return e>80?`text-red-500`:e>50?`text-yellow-500`:`text-green-500`}function T(e){return e<1024?`${e.toFixed(0)} MB`:`${(e/1024).toFixed(1)} GB`}var E=(0,x.memo)(function({group:e,Icon:t,isExpanded:n,sparkData:r,isMobile:i,sortKey:a,sortDir:o,onToggle:l,onKill:d}){let p=n?s:c,m=(0,x.useMemo)(()=>a?[...e.processes].sort((e,t)=>{let n=a===`cpu`?e.cpu:e.ramMB,r=a===`cpu`?t.cpu:t.ramMB;return o===`asc`?n-r:r-n}):e.processes,[e.processes,a,o]);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`tr`,{className:`hover:bg-surface-hover cursor-pointer transition-colors`,onClick:l,children:[(0,S.jsx)(`td`,{className:`py-1.5 px-3`,children:(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,S.jsx)(p,{className:`size-3 text-text-subtle shrink-0`}),(0,S.jsx)(t,{className:`size-3.5 text-text-secondary shrink-0`}),(0,S.jsx)(`span`,{className:`truncate`,children:e.label}),(0,S.jsxs)(`span`,{className:`text-text-subtle`,children:[`(`,e.processes.length,`)`]})]})}),(0,S.jsxs)(`td`,{className:f(`text-right py-1.5 px-2`,w(e.cpu)),children:[e.cpu.toFixed(1),`%`]}),(0,S.jsx)(`td`,{className:`text-right py-1.5 px-2 text-text-secondary`,children:T(e.ramMB)}),!i&&(0,S.jsx)(`td`,{className:`py-1.5 px-2`,children:r.length>1&&(0,S.jsx)(C,{data:r,width:120,height:20})})]}),n&&m.map(e=>(0,S.jsxs)(`tr`,{className:`text-text-subtle group/proc hover:bg-surface-hover transition-colors`,children:[(0,S.jsx)(`td`,{className:`py-1 px-3 pl-10`,children:(0,S.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,S.jsx)(`span`,{className:`text-text-subtle shrink-0`,children:e.pid}),(0,S.jsx)(`span`,{className:`break-all text-text-secondary`,title:e.command,children:e.command})]})}),(0,S.jsxs)(`td`,{className:`text-right py-1 px-2 align-top`,children:[e.cpu.toFixed(1),`%`]}),(0,S.jsx)(`td`,{className:`text-right py-1 px-2 align-top`,children:T(e.ramMB)}),!i&&(0,S.jsx)(`td`,{className:`align-top py-1 px-2`,children:(0,S.jsx)(`button`,{onClick:t=>{t.stopPropagation(),d(e.pid)},className:`opacity-0 group-hover/proc:opacity-100 p-0.5 rounded hover:bg-red-500/20 hover:text-red-500 transition-all`,title:`End process ${e.pid}`,children:(0,S.jsx)(u,{className:`size-3`})})})]},e.pid))]})});function D({label:e,field:t,activeKey:n,activeDir:r,onClick:o,className:s}){let c=n===t,l=c?r===`asc`?a:i:null;return(0,S.jsx)(`th`,{className:f(`text-right py-1.5 px-2 font-medium cursor-pointer select-none hover:text-text-primary transition-colors`,c&&`text-text-primary`,s),onClick:()=>o(t),children:(0,S.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,S.jsx)(`span`,{children:e}),l&&(0,S.jsx)(l,{className:`size-3`})]})})}var O={server:m,terminal:g,"ai-tool":o,build:b,unknown:y},k=200;function A(e,t,n){return e===n?t===`desc`?[n,`asc`]:[null,`desc`]:[n,`desc`]}function j(e,t,n){return t?[...e].sort((e,r)=>{let i=t===`cpu`?e.cpu:e.ramMB,a=t===`cpu`?r.cpu:r.ramMB;return n===`asc`?i-a:a-i}):e}var M=(0,x.memo)(function(){let{latest:e,history:t,isConnected:n}=_(),[r,i]=(0,x.useState)(()=>new Set([`server`])),[a,o]=(0,x.useState)(null),[s,c]=(0,x.useState)(`desc`),u=v(),m=(0,x.useMemo)(()=>{let e=new Map,n=t.slice(-k);for(let t of n)for(let n of t.groups){let t=`${n.type}:${n.label}`,r=e.get(t)??[];r.push(n.cpu),e.set(t,r)}return e},[t]),g=(0,x.useMemo)(()=>e?j(e.groups,a,s):[],[e,a,s]),b=(0,x.useCallback)(async e=>{try{await d.post(`/api/system/resources/kill/${e}`),h.success(`Sent SIGTERM to PID ${e}`)}catch(t){h.error(t.message||`Failed to kill PID ${e}`)}},[]),C=e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},M=e=>{let[t,n]=A(a,s,e);o(t),c(n)};if(!e)return(0,S.jsx)(`div`,{className:`flex items-center justify-center h-full text-text-subtle text-sm`,children:n?`Waiting for data...`:`Connecting to resource monitor...`});let N=Math.round((Date.now()-e.timestamp)/1e3);return(0,S.jsxs)(`div`,{className:`h-full flex flex-col overflow-hidden`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border shrink-0`,children:[(0,S.jsx)(`h2`,{className:`text-sm font-medium`,children:`System Monitor`}),(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-text-subtle`,children:[n?(0,S.jsx)(l,{className:`size-3 text-green-500`}):(0,S.jsx)(p,{className:`size-3 text-red-500`}),(0,S.jsx)(`span`,{children:n?`Updated ${N}s ago`:`Disconnected`})]})]}),(0,S.jsx)(`div`,{className:`flex-1 overflow-y-auto min-h-0`,children:(0,S.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`text-text-subtle border-b border-border`,children:[(0,S.jsx)(`th`,{className:`text-left py-1.5 px-3 font-medium`,children:`Process`}),(0,S.jsx)(D,{label:`CPU`,field:`cpu`,activeKey:a,activeDir:s,onClick:M,className:`w-16`}),(0,S.jsx)(D,{label:`RAM`,field:`ram`,activeKey:a,activeDir:s,onClick:M,className:`w-20`}),!u&&(0,S.jsx)(`th`,{className:`py-1.5 px-2 font-medium w-[130px]`,children:`Trend`})]})}),(0,S.jsx)(`tbody`,{children:g.map(e=>{let t=`${e.type}:${e.label}`;return(0,S.jsx)(E,{group:e,Icon:O[e.type]??y,isExpanded:r.has(t),sparkData:m.get(t)??[],isMobile:u,sortKey:a,sortDir:s,onToggle:()=>C(t),onKill:b},t)})}),(0,S.jsx)(`tfoot`,{children:(0,S.jsxs)(`tr`,{className:`border-t border-border font-medium`,children:[(0,S.jsxs)(`td`,{className:`py-1.5 px-3`,children:[`Total (`,e.total.processCount,` processes)`]}),(0,S.jsxs)(`td`,{className:f(`text-right py-1.5 px-2`,w(e.total.cpu)),children:[e.total.cpu.toFixed(1),`%`]}),(0,S.jsx)(`td`,{className:`text-right py-1.5 px-2 text-text-secondary`,children:T(e.total.ramMB)}),!u&&(0,S.jsx)(`td`,{})]})})]})})]})});export{M as SystemMonitorTab};