@hienlh/ppm 0.13.62 → 0.13.64

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 (60) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/assets/skills/ppm/SKILL.md +1 -1
  3. package/assets/skills/ppm/references/http-api.md +2 -1
  4. package/bun.lock +2170 -0
  5. package/bunfig.toml +2 -0
  6. package/dist/web/assets/audio-preview-Bog1sIoF.js +1 -0
  7. package/dist/web/assets/{chat-tab-nNh5rLB2.js → chat-tab-B-uVAh4d.js} +7 -7
  8. package/dist/web/assets/code-editor-cDv3opsJ.js +8 -0
  9. package/dist/web/assets/{conflict-editor-B4f2ilts.js → conflict-editor-D5sEfbcX.js} +3 -3
  10. package/dist/web/assets/database-viewer-BGBVsG5J.js +1 -0
  11. package/dist/web/assets/diff-viewer-B-O1mvHO.js +4 -0
  12. package/dist/web/assets/docx-preview-ByzSlSgn.js +12 -0
  13. package/dist/web/assets/{extension-webview-CUPyfczi.js → extension-webview-0qfU1r7z.js} +1 -1
  14. package/dist/web/assets/git-log-panel-C1T8bav0.js +1 -0
  15. package/dist/web/assets/{glide-data-grid-1rBqhi2J.js → glide-data-grid-DV8ht1BP.js} +3 -3
  16. package/dist/web/assets/image-preview-Dbo7SAVb.js +1 -0
  17. package/dist/web/assets/{index-DwvSM9vu.css → index-BuXdQZjD.css} +1 -1
  18. package/dist/web/assets/index-DU_JZ5MY.js +27 -0
  19. package/dist/web/assets/keybindings-store-0FUOwc9I.js +1 -0
  20. package/dist/web/assets/{markdown-renderer-BS-EgLZm.js → markdown-renderer-D-QbsfIC.js} +1 -1
  21. package/dist/web/assets/notification-store-bwd1UKbs.js +1 -0
  22. package/dist/web/assets/pdf-preview-DV96VPTb.js +1 -0
  23. package/dist/web/assets/port-forwarding-tab-C4OYC71C.js +1 -0
  24. package/dist/web/assets/{postgres-viewer-BZ7RHn6E.js → postgres-viewer-hb-_twEU.js} +2 -2
  25. package/dist/web/assets/{settings-tab-B3U6o2Cv.js → settings-tab-BUCIqVAl.js} +1 -1
  26. package/dist/web/assets/sql-query-editor-C7YgtDR3.js +3 -0
  27. package/dist/web/assets/sqlite-viewer-z3pGFSje.js +1 -0
  28. package/dist/web/assets/system-monitor-tab-Bj6pcRmV.js +1 -0
  29. package/dist/web/assets/{terminal-tab-BEGaXjCj.js → terminal-tab-DbxLHofN.js} +2 -2
  30. package/dist/web/assets/video-preview-DylSBAzo.js +1 -0
  31. package/dist/web/index.html +2 -2
  32. package/dist/web/sw.js +1 -1
  33. package/docs/codebase-summary.md +2 -1
  34. package/docs/project-changelog.md +10 -1
  35. package/package.json +2 -1
  36. package/src/index.ts +0 -0
  37. package/src/server/routes/files.ts +20 -0
  38. package/src/server/routes/fs-browse.ts +16 -0
  39. package/src/web/components/database/database-viewer.tsx +13 -2
  40. package/src/web/components/database/sql-query-editor.tsx +8 -10
  41. package/src/web/components/editor/code-editor.tsx +5 -2
  42. package/src/web/components/editor/docx-preview.tsx +92 -0
  43. package/src/web/components/layout/command-palette-filter-chips.tsx +61 -0
  44. package/src/web/components/layout/command-palette.tsx +54 -7
  45. package/dist/web/assets/audio-preview-B3rIhhbi.js +0 -1
  46. package/dist/web/assets/code-editor-CMSwWKuR.js +0 -8
  47. package/dist/web/assets/database-viewer-D-28-BdV.js +0 -1
  48. package/dist/web/assets/diff-viewer-Bv8DUUIR.js +0 -4
  49. package/dist/web/assets/git-log-panel-CFLQD23g.js +0 -1
  50. package/dist/web/assets/image-preview-DHrZPetH.js +0 -1
  51. package/dist/web/assets/index-CkQX29w3.js +0 -27
  52. package/dist/web/assets/keybindings-store-Bigfs0Ss.js +0 -1
  53. package/dist/web/assets/notification-store-NXr7Mag_.js +0 -1
  54. package/dist/web/assets/pdf-preview-CeN9W7kd.js +0 -1
  55. package/dist/web/assets/port-forwarding-tab-CYUcx2_j.js +0 -1
  56. package/dist/web/assets/sql-query-editor-CfDG3duv.js +0 -3
  57. package/dist/web/assets/sqlite-viewer-ofYBAsHX.js +0 -1
  58. package/dist/web/assets/system-monitor-tab-By-j_TO1.js +0 -1
  59. package/dist/web/assets/video-preview-CHOiQ3I9.js +0 -1
  60. /package/dist/web/assets/{vendor-xterm-t3d5xZdz.js → vendor-xterm-msgiskDb.js} +0 -0
@@ -0,0 +1,8 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/markdown-renderer-D-QbsfIC.js","assets/rolldown-runtime-FhOqtrmT.js","assets/index-DU_JZ5MY.js","assets/vendor-mermaid-DCie7hiR.js","assets/vendor-ui-UXCWAcmi.js","assets/vendor-markdown-0Mxgxy0L.js","assets/input-B78ol0hV.js","assets/utils-E0yyGxXt.js","assets/createLucideIcon-BjHrJDVb.js","assets/x-DfF6D5Js.js","assets/settings-store-CSDOihqv.js","assets/react-CfveccaI.js","assets/api-client-DiZgVOok.js","assets/eye-off-BacF7RVS.js","assets/ai-settings-section-BH2UOQH-.js","assets/chevron-down-BMo4cBth.js","assets/globe-CQ8NAYvi.js","assets/trash-2-DkIfBY8d.js","assets/refresh-cw-CRD2qr4U.js","assets/api-settings-uQKmeGkl.js","assets/database-Dc8mr-dP.js","assets/chevron-right-CD8e6Aj4.js","assets/search-D90WJ5fo.js","assets/panel-store-B1pOXkyS.js","assets/project-store-BnvrVKBw.js","assets/tab-store-DzftzxTL.js","assets/index-BuXdQZjD.css","assets/csv-preview-DgArUJhd.js","assets/lib-DrypSCq8.js","assets/arrow-down-D825m4vm.js","assets/arrow-up-Rcw6_KKu.js","assets/csv-parser-D8VHWVA6.js","assets/image-preview-Dbo7SAVb.js","assets/file-exclamation-point-B__2Hrd6.js","assets/use-blob-url-DCUIEzjB.js","assets/pdf-preview-DV96VPTb.js","assets/video-preview-DylSBAzo.js","assets/audio-preview-Bog1sIoF.js","assets/docx-preview-ByzSlSgn.js"])))=>i.map(i=>d[i]);
2
+ 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"./database-Dc8mr-dP.js";import{t as a}from"./chevron-right-CD8e6Aj4.js";import{a as o,l as s,n as c,o as l,r as u,s as d,t as f}from"./input-B78ol0hV.js";import{t as p}from"./code-DiNmA3eR.js";import{i as m,r as h}from"./trash-2-DkIfBY8d.js";import{t as ee}from"./file-exclamation-point-B__2Hrd6.js";import{i as g,r as te,t as _}from"./glide-data-grid-DV8ht1BP.js";import{t as v}from"./table-2wDtM4_B.js";import{t as y}from"./text-wrap-AZErifCu.js";import{t as b}from"./x-DfF6D5Js.js";import{i as ne,t as x}from"./api-client-DiZgVOok.js";import{n as re}from"./settings-store-CSDOihqv.js";import{K as S}from"./vendor-mermaid-DCie7hiR.js";import{t as C}from"./utils-E0yyGxXt.js";import{t as ie}from"./panel-store-B1pOXkyS.js";import{n as w}from"./project-store-BnvrVKBw.js";import{t as ae}from"./tab-store-DzftzxTL.js";import{H as T,O as E,X as oe,_ as se,at as ce,ct as D,d as O,et as k,f as le,ft as A,h as j,it as M,l as N,lt as P,m as F,o as ue,ot as de,p as fe,rt as pe,s as me,st as I,tt as L,u as he,v as ge}from"./index-DU_JZ5MY.js";import"./data-grid-types-C29KDkZJ.js";import{n as _e,t as ve}from"./use-monaco-theme-qx6SfVRk.js";var ye=r(`redo-2`,[[`path`,{d:`m15 14 5-5-5-5`,key:`12vg1m`}],[`path`,{d:`M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13`,key:`6uklza`}]]),R=e(n(),1),z=t(),be={ts:I,tsx:I,js:I,jsx:I,py:I,rs:I,go:I,html:I,css:I,scss:I,json:D,md:de,txt:de,yaml:ce,yml:ce};function B(e,t){return t?pe:be[e.split(`.`).pop()?.toLowerCase()??``]??M}function xe(e,t){let n=[],r=e,i=``;for(let e=0;e<t.length;e++){let a=t[e],o=t.slice(0,e+1).join(`/`),s=r.find(e=>e.name===a);if(n.push({name:a,fullPath:o,node:s??null,siblings:r,parentPath:i}),s?.children)i=s.path,r=s.children;else{for(let r=e+1;r<t.length;r++)n.push({name:t[r],fullPath:t.slice(0,r+1).join(`/`),node:null,siblings:[],parentPath:t.slice(0,r).join(`/`)});break}}return n}function V(e){return[...e].sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1)}function Se({filePath:e,projectName:t,tabId:n,className:r}){let i=E(e=>e.tree),{updateTab:o,openTab:s}=ae(se(e=>({updateTab:e.updateTab,openTab:e.openTab}))),c=w(e=>e.projects.find(e=>e.name===t)?.path??``),l=(0,R.useRef)(null),{prefixParts:u,relativePath:d}=(0,R.useMemo)(()=>{let t=e.startsWith(`/`)?e.slice(1):e,n=c.startsWith(`/`)?c.slice(1):c;if(n&&t.startsWith(n+`/`)){let e=t.slice(n.length+1);return{prefixParts:n.split(`/`),relativePath:e}}return{prefixParts:[],relativePath:t}},[e,c]),f=(0,R.useMemo)(()=>xe(i,d.split(`/`).filter(Boolean)),[i,d]);(0,R.useEffect)(()=>{l.current&&(l.current.scrollLeft=l.current.scrollWidth)},[f]);function p(e,r){let i=C(e);r.metaKey||r.ctrlKey?s({type:`editor`,title:i,metadata:{filePath:e,projectName:t},projectId:t,closable:!0}):o(n,{title:i,metadata:{filePath:e,projectName:t}})}return(0,z.jsxs)(`div`,{ref:l,className:r,children:[u.map((e,t)=>(0,z.jsxs)(`div`,{className:`flex items-center shrink-0`,children:[t>0&&(0,z.jsx)(a,{className:`size-3 text-muted-foreground shrink-0 mx-0.5`}),(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground px-1 py-0.5`,children:e})]},`prefix-${t}`)),f.map((e,n)=>(0,z.jsxs)(`div`,{className:`flex items-center shrink-0`,children:[(n>0||u.length>0)&&(0,z.jsx)(a,{className:`size-3 text-muted-foreground shrink-0 mx-0.5`}),(0,z.jsx)(H,{segment:e,isLast:n===f.length-1,projectName:t,onFileClick:p})]},e.fullPath))]})}function H({segment:e,isLast:t,projectName:n,onFileClick:r}){let i=E(e=>e.loadChildren),a=E(e=>e.loadedPaths),o=(0,R.useMemo)(()=>V(e.siblings),[e.siblings]),s=a.has(e.parentPath);function c(t){if(t&&!s){let t=e.parentPath.split(`/`).filter(Boolean);(async()=>{for(let e=0;e<=t.length;e++)await i(n,t.slice(0,e).join(`/`))})()}}return(0,z.jsxs)(N,{onOpenChange:c,children:[(0,z.jsx)(j,{asChild:!0,children:(0,z.jsx)(`button`,{type:`button`,className:`text-xs px-1 py-0.5 rounded hover:bg-muted transition-colors truncate max-w-[120px] ${t?`text-foreground font-medium`:`text-muted-foreground`}`,children:e.name})}),(0,z.jsx)(he,{align:`start`,className:`max-h-[300px] p-1`,children:o.length===0?(0,z.jsx)(O,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):o.map(t=>(0,z.jsx)(Ce,{node:t,projectName:n,activePath:e.fullPath,onFileClick:r},t.path))})]})}function Ce({node:e,projectName:t,activePath:n,onFileClick:r}){let i=B(e.name,e.type===`directory`),a=e.path===n,o=E(e=>e.loadChildren),s=E(e=>e.loadedPaths);if(e.type===`directory`){let c=e.children??[],l=s.has(e.path);function u(n){n&&!l&&o(t,e.path)}return(0,z.jsxs)(le,{onOpenChange:u,children:[(0,z.jsxs)(F,{className:`text-xs gap-1.5 ${a?`bg-muted`:``}`,children:[(0,z.jsx)(i,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,z.jsx)(`span`,{className:`truncate`,children:e.name})]}),(0,z.jsx)(fe,{className:`max-h-[300px] overflow-y-auto p-1`,children:c.length===0?(0,z.jsx)(O,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):V(c).map(e=>(0,z.jsx)(Ce,{node:e,projectName:t,activePath:n,onFileClick:r},e.path))})]})}return(0,z.jsxs)(O,{className:`text-xs gap-1.5 cursor-pointer ${a?`bg-muted`:``}`,onSelect:e=>{},onClick:t=>{r(e.path,t)},children:[(0,z.jsx)(i,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,z.jsx)(`span`,{className:`truncate`,children:e.name})]})}function U({active:e,onClick:t,icon:n,label:r}){return(0,z.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-1 px-2 py-1 rounded text-xs transition-colors ${e?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[(0,z.jsx)(n,{className:`size-3`}),(0,z.jsx)(`span`,{className:`hidden sm:inline`,children:r})]})}function we({ext:e,mdMode:t,onMdModeChange:n,csvMode:r,onCsvModeChange:i,wordWrap:a,onToggleWordWrap:o,filePath:s,projectName:c,className:l}){return(0,z.jsxs)(`div`,{className:l,children:[(e===`md`||e===`mdx`)&&n&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(U,{active:t===`edit`,onClick:()=>n(`edit`),icon:p,label:`Edit`}),(0,z.jsx)(U,{active:t===`preview`,onClick:()=>n(`preview`),icon:h,label:`Preview`})]}),e===`csv`&&i&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(U,{active:r===`table`,onClick:()=>i(`table`),icon:v,label:`Table`}),(0,z.jsx)(U,{active:r===`raw`,onClick:()=>i(`raw`),icon:p,label:`Raw`})]}),(0,z.jsx)(U,{active:a,onClick:o,icon:y,label:`Wrap`}),s&&c&&(0,z.jsx)(U,{active:!1,onClick:()=>ge(c,s),icon:m,label:`Download`})]})}function Te({open:e,defaultName:t,content:n,onSave:r,onCancel:i}){let[a,p]=(0,R.useState)(t),[m,h]=(0,R.useState)(!1),[ee,g]=(0,R.useState)(``),te=w(e=>e.activeProject),_=(0,R.useCallback)(()=>{let e=a.trim();if(!e){g(`Filename cannot be empty`);return}if(/[/\\]/.test(e)){g(`Filename cannot contain / or \\`);return}g(``),h(!0)},[a]),v=(0,R.useCallback)(e=>{let t=e.includes(`\\`)?`\\`:`/`;r(e.endsWith(t)?`${e}${a.trim()}`:`${e}${t}${a.trim()}`,n)},[a,n,r]);return m?(0,z.jsx)(me,{open:!0,mode:`folder`,root:te?.path,title:`Save "${a.trim()}" to...`,onSelect:v,onCancel:()=>h(!1)}):(0,z.jsx)(c,{open:e,onOpenChange:e=>{e||i()},children:(0,z.jsxs)(u,{className:`sm:max-w-md`,children:[(0,z.jsx)(l,{children:(0,z.jsx)(d,{children:`Save As`})}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[(0,z.jsx)(`label`,{className:`text-sm text-muted-foreground`,children:`Filename`}),(0,z.jsx)(f,{value:a,onChange:e=>{p(e.target.value),g(``)},onKeyDown:e=>{e.key===`Enter`&&_()},placeholder:`e.g. my-file.ts`,autoFocus:!0}),ee&&(0,z.jsx)(`p`,{className:`text-xs text-destructive`,children:ee})]}),(0,z.jsxs)(o,{children:[(0,z.jsx)(s,{variant:`outline`,onClick:i,children:`Cancel`}),(0,z.jsx)(s,{onClick:_,children:`Choose Folder...`})]})]})})}var W=typeof window<`u`&&window.isSecureContext,G=[`(`,`)`,`{`,`}`,`[`,`]`,`<`,`>`,`;`,`:`,`=`,`"`,`'`,"`",`/`,`\\`,`_`,`#`],K=`px-2 py-1.5 rounded text-xs min-w-[36px] min-h-[32px] bg-surface-elevated text-text-primary active:bg-primary active:text-primary-foreground transition-colors select-none`,q=`px-3 py-1.5 rounded text-xs font-mono min-w-[36px] min-h-[32px] bg-surface-elevated text-text-primary active:bg-primary active:text-primary-foreground transition-colors select-none`,J=`w-px h-5 bg-border mx-0.5 shrink-0`;function Ee({editorRef:e,readOnly:t}){let n=(0,R.useCallback)(()=>e.current,[e]),r=(0,R.useCallback)(e=>{let t=n();if(!t)return;t.focus();let r=t.getSelection();r&&t.executeEdits(`mobile-toolbar`,[{range:r,text:e}])},[n]),[i,a]=(0,R.useState)(!1),o=(0,R.useRef)(null),s=(0,R.useCallback)(async()=>{try{let e=await navigator.clipboard.readText();e&&r(e)}catch{}},[r]),c=(0,R.useCallback)(()=>{a(!0),requestAnimationFrame(()=>o.current?.focus())},[]),l=(0,R.useCallback)(e=>{e.preventDefault();let t=e.clipboardData.getData(`text/plain`);t&&(a(!1),r(t))},[r]),u=(0,R.useCallback)(()=>{let e=n();e&&(e.focus(),e.trigger(`mobile-toolbar`,`undo`,null))},[n]),d=(0,R.useCallback)(()=>{let e=n();e&&(e.focus(),e.trigger(`mobile-toolbar`,`redo`,null))},[n]),f=(0,R.useCallback)(()=>{let e=n();e&&(e.focus(),e.trigger(`mobile-toolbar`,`tab`,null))},[n]);return t?null:(0,z.jsxs)(`div`,{className:`shrink-0 border-t border-border bg-surface`,children:[!W&&i&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 border-b border-border bg-muted/50`,children:[(0,z.jsx)(`textarea`,{ref:o,onPaste:l,placeholder:`Long-press here → Paste`,className:`flex-1 h-8 rounded border border-border bg-background text-foreground text-xs px-2 py-1.5 resize-none focus:outline-none focus:ring-1 focus:ring-primary`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>a(!1),className:`p-1.5 rounded text-muted-foreground active:bg-muted transition-colors`,children:(0,z.jsx)(b,{size:14})})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1.5 overflow-x-auto`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:W?s:c,className:K,title:`Paste`,children:(0,z.jsx)(A,{size:14})}),(0,z.jsx)(`button`,{type:`button`,onClick:u,className:K,title:`Undo`,children:(0,z.jsx)(T,{size:14})}),(0,z.jsx)(`button`,{type:`button`,onClick:d,className:K,title:`Redo`,children:(0,z.jsx)(ye,{size:14})}),(0,z.jsx)(`div`,{className:J}),(0,z.jsx)(`button`,{type:`button`,onClick:f,className:q,children:`Tab`}),(0,z.jsx)(`div`,{className:J}),G.map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:q,children:e},e))]})]})}var De=(0,R.lazy)(()=>S(()=>import(`./markdown-renderer-D-QbsfIC.js`).then(e=>({default:e.MarkdownRenderer})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]))),Oe=(0,R.lazy)(()=>S(()=>import(`./csv-preview-DgArUJhd.js`).then(e=>({default:e.CsvPreview})),__vite__mapDeps([27,1,4,5,28,29,8,30,31]))),ke=(0,R.lazy)(()=>S(()=>import(`./image-preview-Dbo7SAVb.js`).then(e=>({default:e.ImagePreview})),__vite__mapDeps([32,2,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,33,34]))),Ae=(0,R.lazy)(()=>S(()=>import(`./pdf-preview-DV96VPTb.js`).then(e=>({default:e.PdfPreview})),__vite__mapDeps([35,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,33]))),je=(0,R.lazy)(()=>S(()=>import(`./video-preview-DylSBAzo.js`).then(e=>({default:e.VideoPreview})),__vite__mapDeps([36,2,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,33,34]))),Me=(0,R.lazy)(()=>S(()=>import(`./audio-preview-Bog1sIoF.js`).then(e=>({default:e.AudioPreview})),__vite__mapDeps([37,2,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,33,34]))),Ne=(0,R.lazy)(()=>S(()=>import(`./docx-preview-ByzSlSgn.js`).then(e=>({default:e.DocxPreview})),__vite__mapDeps([38,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,33]))),Pe=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`ico`]),Fe=new Set([`mp4`,`webm`,`mov`,`ogg`,`avi`,`mkv`]),Ie=new Set([`mp3`,`wav`,`flac`,`aac`,`m4a`,`wma`]),Le=new Set([`db`,`sqlite`,`sqlite3`]);function Re(e){return e.split(`.`).pop()?.toLowerCase()??``}function ze(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`,sql:`sql`}[Re(e)]??`plaintext`}var Be=(0,R.memo)(function({metadata:e,tabId:t}){let n=e?.filePath,r=e?.projectName,a=e?.inlineContent,o=e?.inlineLanguage,[s,c]=(0,R.useState)(a??null),[l,u]=(0,R.useState)(`utf-8`),[d,f]=(0,R.useState)(!0),[p,m]=(0,R.useState)(null),[h,_]=(0,R.useState)(!1),v=(0,R.useRef)(null),y=(0,R.useRef)(``),b=(0,R.useRef)(null),{tabs:S,updateTab:w}=ae(se(e=>({tabs:e.tabs,updateTab:e.updateTab}))),{wordWrap:T,toggleWordWrap:E}=re(se(e=>({wordWrap:e.wordWrap,toggleWordWrap:e.toggleWordWrap}))),ce=ve(),D=e?.isUntitled===!0,O=e?.unsavedContent,[le,A]=(0,R.useState)(!1),j=S.find(e=>e.id===t),M=n?Re(n):``,N=Pe.has(M),P=M===`pdf`,F=M===`docx`,de=Fe.has(M),fe=Ie.has(M),pe=Le.has(M),me=M===`md`||M===`mdx`,I=M===`csv`,L=M===`sql`,[he,ge]=(0,R.useState)(`preview`),[ye,be]=(0,R.useState)(`table`),{connections:B,cachedTables:xe,refreshTables:V}=ue(),[H,Ce]=(0,R.useState)(()=>{if(!L||!n)return null;let e=localStorage.getItem(`ppm:sql-conn:${n}`);return e?Number(e):null}),U=(0,R.useRef)(null),W=(0,R.useRef)(null),G=(0,R.useMemo)(()=>B.find(e=>e.id===H)??null,[B,H]),K=a!=null&&(o===`json`||o===`xml`),[q,J]=(0,R.useState)(!1),De=(0,R.useCallback)(()=>{if(a)if(q)c(a),J(!1);else{let e=a.trimStart();if(o===`json`)try{c(JSON.stringify(JSON.parse(e),null,2)),J(!0)}catch{}else if(o===`xml`){let t=0;c(e.replace(/(>)(<)(\/*)/g,`$1
3
+ $2$3`).split(`
4
+ `).map(e=>{let n=e.trim();n.startsWith(`</`)&&(t=Math.max(0,t-1));let r=` `.repeat(t)+n;return n.startsWith(`<`)&&!n.startsWith(`</`)&&!n.endsWith(`/>`)&&!n.includes(`</`)&&t++,r}).join(`
5
+ `)),J(!0)}}},[a,o,q]),Be=(0,R.useCallback)(e=>{Ce(e),n&&localStorage.setItem(`ppm:sql-conn:${n}`,String(e)),V(e).catch(()=>{})},[n,V]),Y=(0,R.useMemo)(()=>{if(!L||!H)return;let e=(xe.get(H)??[]).map(e=>({name:e.tableName,schema:e.schemaName}));if(e.length!==0)return{tables:e,getColumns:async(e,t)=>x.get(`/api/db/connections/${H}/schema?table=${encodeURIComponent(e)}${t?`&schema=${encodeURIComponent(t)}`:``}`)}},[L,H,xe]);(0,R.useEffect)(()=>{if(!(!U.current||!Y))return W.current?.dispose(),te(),W.current=U.current.languages.registerCompletionItemProvider(`sql`,g(U.current,Y)),()=>{W.current?.dispose()}},[Y]);let Ue=ae(e=>e.openTab),[We,Ge]=(0,R.useState)(null),[Ke,qe]=(0,R.useState)(null),[Je,Ye]=(0,R.useState)(!1),[Xe,Ze]=(0,R.useState)(``),Z=(0,R.useCallback)(async e=>{if(G){Ye(!0),qe(null),Ze(e);try{Ge(await x.post(`/api/db/connections/${G.id}/query`,{sql:e}))}catch(e){qe(e.message),Ge(null)}finally{Ye(!1)}}},[G]),Qe=(0,R.useCallback)(()=>{!G||!Xe||Ue({type:`database`,title:`${G.name} · Query`,projectId:null,closable:!0,metadata:{connectionId:G.id,connectionName:G.name,dbType:G.type,initialSql:Xe}})},[G,Ue,Xe]),$e=(0,R.useCallback)(()=>{if(!b.current||!G)return;let e=b.current,t=e.getSelection();Z(t&&!t.isEmpty()?e.getModel()?.getValueInRange(t)??e.getValue():e.getValue())},[G,Z]),et=typeof window<`u`&&`ontouchstart`in window,tt=(0,R.useRef)(null),[nt,rt]=(0,R.useState)(null);(0,R.useEffect)(()=>{if(!et)return;let e=window.visualViewport;if(!e)return;let t=()=>{let t=tt.current;if(!t)return;let n=t.getBoundingClientRect().top;rt(e.height-Math.max(0,n))};return e.addEventListener(`resize`,t),e.addEventListener(`scroll`,t),()=>{e.removeEventListener(`resize`,t),e.removeEventListener(`scroll`,t)}},[et]);let Q=(0,R.useRef)([]),it=(0,R.useRef)(Z);it.current=Z,(0,R.useEffect)(()=>()=>{Q.current.forEach(e=>e.dispose()),Q.current=[]},[]),(0,R.useEffect)(()=>{pe&&t&&w(t,{type:`sqlite`})},[pe,t,w]);let $=n?/^(\/|[A-Za-z]:[/\\])/.test(n):!1;(0,R.useEffect)(()=>{if(a!=null){f(!1);return}if(D){c(O??``),y.current=O??``,f(!1),O&&_(!0);return}if(!n||!$&&!r)return;if(N||P||F||de||fe){f(!1);return}f(!0),m(null);let e=$?`/api/fs/read?path=${encodeURIComponent(n)}`:`${ne(r)}/files/read?path=${encodeURIComponent(n)}`;return x.get(e).then(e=>{c(e.content),e.encoding&&u(e.encoding),y.current=e.content,f(!1)}).catch(e=>{m(e instanceof Error?e.message:`Failed to load file`),f(!1)}),()=>{v.current&&clearTimeout(v.current)}},[n,r,N,P,F,$,D]);let at=(0,R.useRef)(h);at.current=h,(0,R.useEffect)(()=>{if(!n||!r||a!=null||D)return;let e=e=>{let t=e.detail;if(t.projectName!==r||t.path!==n||at.current)return;let i=$?`/api/fs/read?path=${encodeURIComponent(n)}`:`${ne(r)}/files/read?path=${encodeURIComponent(n)}`;x.get(i).then(e=>{e.content!==y.current&&(c(e.content),y.current=e.content,e.encoding&&u(e.encoding))}).catch(()=>{})};return window.addEventListener(`file:changed`,e),()=>window.removeEventListener(`file:changed`,e)},[n,r,$,a,D]),(0,R.useEffect)(()=>{if(!j||a!=null)return;let t=D?`Untitled-${e?.untitledNumber??1}`:n?C(n):`Untitled`,r=h?`${t} \u25CF`:t;j.title!==r&&w(j.id,{title:r})},[h]);let ot=(0,R.useCallback)(async e=>{if(n&&!(!$&&!r))try{$?await x.put(`/api/fs/write`,{path:n,content:e}):await x.put(`${ne(r)}/files/write`,{path:n,content:e}),_(!1)}catch{}},[n,r,$]);function st(n){let r=n??``;c(r),y.current=r,_(!0),v.current&&clearTimeout(v.current),D?v.current=setTimeout(()=>{t&&w(t,{metadata:{...e,unsavedContent:y.current}})},2e3):v.current=setTimeout(()=>ot(y.current),1e3)}let ct=(0,R.useCallback)(async(e,n)=>{try{if(v.current&&clearTimeout(v.current),await x.put(`/api/fs/write`,{path:e,content:n}),t){let{closeTab:n,openTab:r}=ie.getState();n(t),r({type:`editor`,title:C(e),projectId:null,metadata:{filePath:e},closable:!0})}_(!1),A(!1)}catch{}},[t]),lt=e?.lineNumber,ut=(0,R.useCallback)((e,t)=>{if(b.current=e,U.current=t,lt&&lt>0&&setTimeout(()=>{e.revealLineInCenter(lt),e.setPosition({lineNumber:lt,column:1}),e.focus()},100),D&&e.addCommand(t.KeyMod.CtrlCmd|t.KeyCode.KeyS,()=>A(!0)),e.addCommand(t.KeyMod.Alt|t.KeyCode.KeyZ,()=>re.getState().toggleWordWrap()),t.languages.typescript.typescriptDefaults.setDiagnosticsOptions({noSemanticValidation:!0,noSyntaxValidation:!0,noSuggestionDiagnostics:!0}),t.languages.typescript.javascriptDefaults.setDiagnosticsOptions({noSemanticValidation:!0,noSyntaxValidation:!0,noSuggestionDiagnostics:!0}),Y&&(W.current?.dispose(),W.current=t.languages.registerCompletionItemProvider(`sql`,g(t,Y))),L){Q.current.forEach(e=>e.dispose()),Q.current=[];let n=e.getModel(),r=e.addCommand(0,(e,t)=>{t&&it.current(t)});if(r&&n){let e=t.languages.registerCodeLensProvider(`sql`,{provideCodeLenses:e=>{if(e!==n)return{lenses:[],dispose:()=>{}};let t=[],i=e.getValue().split(`
6
+ `),a=-1,o=[],s=!1,c=(e,n)=>{let i=n.trim();!i||i.startsWith(`--`)||t.push({range:{startLineNumber:e,startColumn:1,endLineNumber:e,endColumn:1},command:{id:r,title:`▷ Run`,arguments:[i]}})};for(let e=0;e<i.length;e++){let t=i[e].trim();if(a===-1){if(!t||t.startsWith(`--`))continue;a=e+1,o=[]}o.push(i[e]),(t.match(/\$\$/g)||[]).length%2==1&&(s=!s),!s&&t.endsWith(`;`)&&(c(a,o.join(`
7
+ `)),a=-1,o=[])}return a>0&&o.join(``).trim()&&c(a,o.join(`
8
+ `)),{lenses:t,dispose:()=>{}}}});Q.current.push(e)}}},[Y]);if(!a&&!D&&(!n||!$&&!r))return(0,z.jsx)(`div`,{className:`flex items-center justify-center h-full text-text-secondary text-sm`,children:`No file selected.`});if(d)return(0,z.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-text-secondary`,children:[(0,z.jsx)(k,{className:`size-5 animate-spin`}),(0,z.jsx)(`span`,{className:`text-sm`,children:`Loading file...`})]});if(p)return(0,z.jsx)(`div`,{className:`flex items-center justify-center h-full text-error text-sm`,children:p});if(N)return(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(X,{}),children:(0,z.jsx)(ke,{filePath:n,projectName:r})});if(P)return(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(X,{}),children:(0,z.jsx)(Ae,{filePath:n,projectName:r})});if(F)return(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(X,{}),children:(0,z.jsx)(Ne,{filePath:n,projectName:r})});if(de)return(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(X,{}),children:(0,z.jsx)(je,{filePath:n,projectName:r})});if(fe)return(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(X,{}),children:(0,z.jsx)(Me,{filePath:n,projectName:r})});if(l===`base64`)return(0,z.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,z.jsx)(ee,{className:`size-10 text-text-subtle`}),(0,z.jsx)(`p`,{className:`text-sm`,children:`This file is a binary format and cannot be displayed.`}),(0,z.jsx)(`p`,{className:`text-xs text-text-subtle`,children:n})]});let dt=L?(0,z.jsxs)(`div`,{className:`shrink-0 flex items-center gap-1 px-2 border-l border-border`,children:[(0,z.jsx)(i,{className:`size-3 text-muted-foreground`}),(0,z.jsxs)(`select`,{value:H??``,onChange:e=>{let t=Number(e.target.value);t&&Be(t)},className:`h-5 text-[10px] bg-transparent border border-border rounded px-1 text-foreground outline-none max-w-[140px]`,title:`Select connection for autocomplete`,children:[(0,z.jsx)(`option`,{value:``,children:`Connection…`}),B.map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,z.jsx)(`button`,{type:`button`,onClick:$e,disabled:!G,className:`p-0.5 rounded text-muted-foreground hover:text-primary disabled:opacity-30 transition-colors`,title:`Run SQL`,children:(0,z.jsx)(oe,{className:`size-3.5`})})]}):null;return(0,z.jsxs)(`div`,{ref:tt,className:`flex flex-col h-full w-full overflow-hidden`,style:nt?{height:`${nt}px`,maxHeight:`${nt}px`}:void 0,children:[a!=null&&K&&(0,z.jsx)(`div`,{className:`flex items-center h-7 border-b border-border bg-background shrink-0 px-2 gap-2`,children:(0,z.jsx)(`button`,{type:`button`,onClick:De,className:`text-[10px] px-2 py-0.5 rounded border border-border hover:bg-muted transition-colors text-foreground`,children:q?`Raw`:`Beautify`})}),n&&r&&t&&(0,z.jsxs)(`div`,{className:`hidden md:flex items-center h-7 border-b border-border bg-background shrink-0`,children:[(0,z.jsx)(Se,{filePath:n,projectName:r,tabId:t,className:`flex items-center flex-1 min-w-0 overflow-x-auto scrollbar-none px-2 gap-0.5`}),dt,(0,z.jsx)(we,{ext:M,mdMode:he,onMdModeChange:ge,csvMode:ye,onCsvModeChange:be,wordWrap:T,onToggleWordWrap:E,filePath:n,projectName:r,className:`shrink-0 flex items-center gap-1 px-2`})]}),L&&(!r||!t)&&(0,z.jsxs)(`div`,{className:`hidden md:flex items-center h-7 border-b border-border bg-background shrink-0 px-2`,children:[(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground truncate flex-1`,children:n?C(n):`SQL`}),dt]}),I&&ye===`table`?(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,z.jsx)(k,{className:`size-5 animate-spin text-text-subtle`})}),children:(0,z.jsx)(Oe,{content:s??``,onContentChange:st,wordWrap:T})}):me&&he===`preview`?(0,z.jsx)(He,{content:s??``}):(0,z.jsx)(`div`,{className:`flex-1 overflow-hidden min-h-0`,children:(0,z.jsx)(_e,{height:`100%`,language:o??ze(n??``),value:s??``,onChange:a==null?st:void 0,onMount:ut,theme:ce,options:{fontSize:13,fontFamily:`Menlo, Monaco, Consolas, monospace`,wordWrap:T?`on`:`off`,minimap:{enabled:!1},scrollBeyondLastLine:!1,automaticLayout:!0,lineNumbers:`on`,folding:!0,bracketPairColorization:{enabled:!0},readOnly:a!=null},loading:(0,z.jsx)(k,{className:`size-5 animate-spin text-text-subtle`})})}),L&&(We||Ke||Je)&&(0,z.jsx)(Ve,{result:We,error:Ke,loading:Je,connName:G?.name,onClose:()=>{Ge(null),qe(null),Ye(!1)},onOpenInTab:Qe}),et&&(0,z.jsx)(Ee,{editorRef:b,readOnly:a!=null}),le&&(0,z.jsx)(Te,{open:le,defaultName:`Untitled-${e?.untitledNumber??1}`,content:y.current,onSave:ct,onCancel:()=>A(!1)})]})}),Y=()=>{};function Ve({result:e,error:t,loading:n,connName:r,onClose:a,onOpenInTab:o}){let s=(0,R.useMemo)(()=>e?.changeType===`select`&&e.rows.length>0?{columns:e.columns,rows:e.rows,total:e.rows.length,limit:e.rows.length}:null,[e]),c=(0,R.useMemo)(()=>(e?.columns??[]).map(e=>({name:e,type:`text`,nullable:!0,pk:!1,defaultValue:null})),[e?.columns]),[l,u]=(0,R.useState)(250),d=(0,R.useCallback)(e=>{e.preventDefault();let t=e.clientY,n=l,r=e=>u(Math.max(80,n+(t-e.clientY))),i=()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)},[l]);return(0,z.jsxs)(`div`,{className:`shrink-0 border-t border-border flex flex-col`,style:{height:l},children:[(0,z.jsx)(`div`,{onMouseDown:d,className:`shrink-0 h-1.5 cursor-row-resize bg-border/50 hover:bg-primary/30 flex items-center justify-center transition-colors`,children:(0,z.jsx)(L,{className:`size-3 text-muted-foreground/50`})}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1 bg-muted/50 border-b border-border shrink-0`,children:[(0,z.jsx)(i,{className:`size-3 text-muted-foreground`}),(0,z.jsxs)(`span`,{className:`text-xs font-medium text-foreground truncate flex-1`,children:[r?`${r} · Results`:`Query Results`,e?.executionTimeMs!=null&&(0,z.jsxs)(`span`,{className:`text-muted-foreground ml-1.5 font-normal`,children:[e.executionTimeMs,`ms`]})]}),(0,z.jsxs)(`button`,{type:`button`,onClick:o,title:`Open in DB Viewer tab`,className:`flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] text-muted-foreground hover:text-foreground hover:bg-muted transition-colors`,children:[(0,z.jsx)(P,{className:`size-3`}),(0,z.jsx)(`span`,{className:`hidden sm:inline`,children:`Open in Tab`})]}),(0,z.jsx)(`button`,{type:`button`,onClick:a,title:`Close results`,className:`p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors`,children:(0,z.jsx)(b,{className:`size-3`})})]}),(0,z.jsxs)(`div`,{className:`flex-1 overflow-hidden min-h-0`,children:[n&&(0,z.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,z.jsx)(k,{className:`size-4 animate-spin text-muted-foreground`})}),t&&(0,z.jsx)(`div`,{className:`px-3 py-2 text-xs text-destructive bg-destructive/5`,children:t}),e?.changeType===`modify`&&(0,z.jsxs)(`div`,{className:`px-3 py-2 text-xs text-green-500`,children:[e.rowsAffected,` row(s) affected`]}),s&&(0,z.jsx)(_,{columns:s.columns,rows:s.rows,total:s.total,limit:s.limit,schema:c,loading:!1,page:1,onPageChange:Y,onCellUpdate:Y,orderBy:null,orderDir:`ASC`,onToggleSort:Y,connectionName:r}),e?.changeType===`select`&&e.rows.length===0&&(0,z.jsx)(`div`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:`No results`})]})]})}function X(){return(0,z.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,z.jsx)(k,{className:`size-5 animate-spin text-text-subtle`})})}function He({content:e}){return(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(`div`,{className:`animate-pulse h-4 bg-muted rounded m-4`}),children:(0,z.jsx)(De,{content:e,className:`flex-1 overflow-auto p-4`})})}export{Be as CodeEditor};
@@ -1,7 +1,7 @@
1
- import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import{i as r,t as i}from"./api-client-DiZgVOok.js";import{n as a}from"./settings-store-CSDOihqv.js";import"./vendor-mermaid-DCie7hiR.js";import{$ as o,_ as s}from"./index-CkQX29w3.js";import{n as c,t as l}from"./use-monaco-theme-qx6SfVRk.js";var u=e(n(),1),d=t();function f(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`,go:`go`,rs:`rust`,java:`java`,rb:`ruby`,php:`php`,swift:`swift`,sql:`sql`,xml:`xml`,toml:`toml`}[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function p(e){let t=e.split(`
1
+ import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import{i as r,t as i}from"./api-client-DiZgVOok.js";import{n as a}from"./settings-store-CSDOihqv.js";import"./vendor-mermaid-DCie7hiR.js";import{_ as o,et as s}from"./index-DU_JZ5MY.js";import{n as c,t as l}from"./use-monaco-theme-qx6SfVRk.js";var u=e(n(),1),d=t();function f(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`,go:`go`,rs:`rust`,java:`java`,rb:`ruby`,php:`php`,swift:`swift`,sql:`sql`,xml:`xml`,toml:`toml`}[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function p(e){let t=e.split(`
2
2
  `),n=[],r=0,i=0;for(;r<t.length;){let e=t[r];if(e.startsWith(`<<<<<<<`)){let a=r,o=e.substring(7).trim(),s=[];for(r++;r<t.length&&!t[r].startsWith(`=======`);)s.push(t[r]),r++;if(r>=t.length)break;let c=r,l=[];for(r++;r<t.length&&!t[r].startsWith(`>>>>>>>`);)l.push(t[r]),r++;if(r>=t.length)break;let u=t[r].substring(7).trim();n.push({id:i++,startLine:a+1,separatorLine:c+1,endLine:r+1,currentContent:s.join(`
3
3
  `),incomingContent:l.join(`
4
- `),currentLabel:o,incomingLabel:u})}r++}return n}function m({metadata:e}){let t=e?.filePath,n=e?.projectName,[m,g]=(0,u.useState)(null),[_,v]=(0,u.useState)(!0),[y,b]=(0,u.useState)(null),[x,S]=(0,u.useState)(0),C=(0,u.useRef)(null),w=(0,u.useRef)(null),T=(0,u.useRef)([]),E=(0,u.useRef)(null),{wordWrap:D}=a(s(e=>({wordWrap:e.wordWrap}))),O=l(),k=(0,u.useRef)(null),[A,j]=(0,u.useState)();(0,u.useEffect)(()=>{let e=k.current;if(!e)return;let t=new ResizeObserver(([e])=>{e&&j(Math.floor(e.contentRect.height))});return t.observe(e),()=>t.disconnect()},[]),(0,u.useEffect)(()=>{!t||!n||(v(!0),i.get(`${r(n)}/files/read?path=${encodeURIComponent(t)}`).then(e=>{g(e.content),v(!1)}).catch(e=>{b(e.message||`Failed to load file`),v(!1)}))},[t,n]);let M=(0,u.useCallback)(()=>{let e=C.current,t=w.current;if(!e||!t)return;let n=p(e.getModel()?.getValue()||``);S(n.length);for(let t of T.current)e.removeContentWidget(t);if(T.current=[],E.current&&E.current.clear(),n.length===0)return;let r=[];for(let e of n)r.push({range:new t.Range(e.startLine,1,e.startLine,1),options:{isWholeLine:!0,className:`conflict-marker-line`,glyphMarginClassName:`conflict-glyph-current`}}),r.push({range:new t.Range(e.separatorLine,1,e.separatorLine,1),options:{isWholeLine:!0,className:`conflict-marker-line`}}),r.push({range:new t.Range(e.endLine,1,e.endLine,1),options:{isWholeLine:!0,className:`conflict-marker-line`,glyphMarginClassName:`conflict-glyph-incoming`}}),e.separatorLine-e.startLine>1&&r.push({range:new t.Range(e.startLine+1,1,e.separatorLine-1,1),options:{isWholeLine:!0,className:`conflict-current-content`}}),e.endLine-e.separatorLine>1&&r.push({range:new t.Range(e.separatorLine+1,1,e.endLine-1,1),options:{isWholeLine:!0,className:`conflict-incoming-content`}});E.current=e.createDecorationsCollection(r);for(let r of n){let n=`conflict-widget-${r.id}`,i=document.createElement(`div`);i.className=`conflict-actions`,i.innerHTML=`<span class="conflict-label">Current Change (${h(r.currentLabel||`HEAD`)})</span><button class="conflict-btn conflict-btn-current" data-action="current">Accept Current</button><button class="conflict-btn conflict-btn-incoming" data-action="incoming">Accept Incoming</button><button class="conflict-btn conflict-btn-both" data-action="both">Accept Both</button>`,i.addEventListener(`click`,e=>{let t=e.target.closest(`[data-action]`);if(!t)return;let n=t.getAttribute(`data-action`);N(r.id,n)});let a={getId:()=>n,getDomNode:()=>i,getPosition:()=>({position:{lineNumber:r.startLine,column:1},preference:[t.editor.ContentWidgetPositionPreference.ABOVE]})};e.addContentWidget(a),T.current.push(a)}},[]),N=(0,u.useCallback)((e,t)=>{let n=C.current,r=w.current;if(!n||!r)return;let i=n.getModel();if(!i)return;let a=p(i.getValue()).find(t=>t.id===e);if(!a)return;let o;switch(t){case`current`:o=a.currentContent;break;case`incoming`:o=a.incomingContent;break;case`both`:o=a.currentContent+`
4
+ `),currentLabel:o,incomingLabel:u})}r++}return n}function m({metadata:e}){let t=e?.filePath,n=e?.projectName,[m,g]=(0,u.useState)(null),[_,v]=(0,u.useState)(!0),[y,b]=(0,u.useState)(null),[x,S]=(0,u.useState)(0),C=(0,u.useRef)(null),w=(0,u.useRef)(null),T=(0,u.useRef)([]),E=(0,u.useRef)(null),{wordWrap:D}=a(o(e=>({wordWrap:e.wordWrap}))),O=l(),k=(0,u.useRef)(null),[A,j]=(0,u.useState)();(0,u.useEffect)(()=>{let e=k.current;if(!e)return;let t=new ResizeObserver(([e])=>{e&&j(Math.floor(e.contentRect.height))});return t.observe(e),()=>t.disconnect()},[]),(0,u.useEffect)(()=>{!t||!n||(v(!0),i.get(`${r(n)}/files/read?path=${encodeURIComponent(t)}`).then(e=>{g(e.content),v(!1)}).catch(e=>{b(e.message||`Failed to load file`),v(!1)}))},[t,n]);let M=(0,u.useCallback)(()=>{let e=C.current,t=w.current;if(!e||!t)return;let n=p(e.getModel()?.getValue()||``);S(n.length);for(let t of T.current)e.removeContentWidget(t);if(T.current=[],E.current&&E.current.clear(),n.length===0)return;let r=[];for(let e of n)r.push({range:new t.Range(e.startLine,1,e.startLine,1),options:{isWholeLine:!0,className:`conflict-marker-line`,glyphMarginClassName:`conflict-glyph-current`}}),r.push({range:new t.Range(e.separatorLine,1,e.separatorLine,1),options:{isWholeLine:!0,className:`conflict-marker-line`}}),r.push({range:new t.Range(e.endLine,1,e.endLine,1),options:{isWholeLine:!0,className:`conflict-marker-line`,glyphMarginClassName:`conflict-glyph-incoming`}}),e.separatorLine-e.startLine>1&&r.push({range:new t.Range(e.startLine+1,1,e.separatorLine-1,1),options:{isWholeLine:!0,className:`conflict-current-content`}}),e.endLine-e.separatorLine>1&&r.push({range:new t.Range(e.separatorLine+1,1,e.endLine-1,1),options:{isWholeLine:!0,className:`conflict-incoming-content`}});E.current=e.createDecorationsCollection(r);for(let r of n){let n=`conflict-widget-${r.id}`,i=document.createElement(`div`);i.className=`conflict-actions`,i.innerHTML=`<span class="conflict-label">Current Change (${h(r.currentLabel||`HEAD`)})</span><button class="conflict-btn conflict-btn-current" data-action="current">Accept Current</button><button class="conflict-btn conflict-btn-incoming" data-action="incoming">Accept Incoming</button><button class="conflict-btn conflict-btn-both" data-action="both">Accept Both</button>`,i.addEventListener(`click`,e=>{let t=e.target.closest(`[data-action]`);if(!t)return;let n=t.getAttribute(`data-action`);N(r.id,n)});let a={getId:()=>n,getDomNode:()=>i,getPosition:()=>({position:{lineNumber:r.startLine,column:1},preference:[t.editor.ContentWidgetPositionPreference.ABOVE]})};e.addContentWidget(a),T.current.push(a)}},[]),N=(0,u.useCallback)((e,t)=>{let n=C.current,r=w.current;if(!n||!r)return;let i=n.getModel();if(!i)return;let a=p(i.getValue()).find(t=>t.id===e);if(!a)return;let o;switch(t){case`current`:o=a.currentContent;break;case`incoming`:o=a.incomingContent;break;case`both`:o=a.currentContent+`
5
5
  `+a.incomingContent;break}let s=new r.Range(a.startLine,1,a.endLine+1,1);i.pushEditOperations([],[{range:s,text:o+`
6
6
  `}],()=>null),P(i.getValue()),setTimeout(()=>M(),50)},[M]),P=(0,u.useCallback)(async e=>{if(!(!t||!n))try{await i.put(`${r(n)}/files/write`,{path:t,content:e})}catch(e){console.error(`[conflict-editor] save failed:`,e)}},[t,n]),F=(e,t)=>{C.current=e,w.current=t;let n=e.getDomNode()?.ownerDocument??document;if(!n.getElementById(`conflict-editor-styles`)){let e=n.createElement(`style`);e.id=`conflict-editor-styles`,e.textContent=`
7
7
  .conflict-current-content { background: rgba(34, 197, 94, 0.1) !important; }
@@ -16,4 +16,4 @@ import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./v
16
16
  .conflict-btn-current { color: #22c55e; background: rgba(34, 197, 94, 0.15); }
17
17
  .conflict-btn-incoming { color: #3b82f6; background: rgba(59, 130, 246, 0.15); }
18
18
  .conflict-btn-both { color: #a855f7; background: rgba(168, 85, 247, 0.15); }
19
- `,n.head?.appendChild(e)}M()},I=t?.split(/[\\/]/).pop()??`unknown`,L=f(I);return _?(0,d.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,d.jsx)(o,{className:`size-6 animate-spin text-primary`})}):y?(0,d.jsx)(`div`,{className:`flex items-center justify-center h-full text-destructive`,children:y}):(0,d.jsxs)(`div`,{className:`h-full w-full flex flex-col`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 text-xs border-b border-border bg-muted/50 flex-shrink-0`,children:[(0,d.jsx)(`span`,{className:`font-medium`,children:I}),(0,d.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}),x>0?(0,d.jsxs)(`span`,{className:`text-destructive font-medium`,children:[x,` conflict`,x===1?``:`s`,` remaining`]}):(0,d.jsx)(`span`,{className:`text-green-500 font-medium`,children:`All conflicts resolved`})]}),(0,d.jsx)(`div`,{ref:k,className:`flex-1 min-h-0`,children:m!==null&&A&&(0,d.jsx)(c,{height:A,language:L,value:m,onMount:F,theme:O,options:{fontSize:13,fontFamily:`Menlo, Monaco, Consolas, monospace`,wordWrap:D?`on`:`off`,glyphMargin:!0,readOnly:!1,automaticLayout:!0,scrollBeyondLastLine:!1,minimap:{enabled:!1}}})})]})}function h(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}export{m as ConflictEditor};
19
+ `,n.head?.appendChild(e)}M()},I=t?.split(/[\\/]/).pop()??`unknown`,L=f(I);return _?(0,d.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,d.jsx)(s,{className:`size-6 animate-spin text-primary`})}):y?(0,d.jsx)(`div`,{className:`flex items-center justify-center h-full text-destructive`,children:y}):(0,d.jsxs)(`div`,{className:`h-full w-full flex flex-col`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 text-xs border-b border-border bg-muted/50 flex-shrink-0`,children:[(0,d.jsx)(`span`,{className:`font-medium`,children:I}),(0,d.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}),x>0?(0,d.jsxs)(`span`,{className:`text-destructive font-medium`,children:[x,` conflict`,x===1?``:`s`,` remaining`]}):(0,d.jsx)(`span`,{className:`text-green-500 font-medium`,children:`All conflicts resolved`})]}),(0,d.jsx)(`div`,{ref:k,className:`flex-1 min-h-0`,children:m!==null&&A&&(0,d.jsx)(c,{height:A,language:L,value:m,onMount:F,theme:O,options:{fontSize:13,fontFamily:`Menlo, Monaco, Consolas, monospace`,wordWrap:D?`on`:`off`,glyphMargin:!0,readOnly:!1,automaticLayout:!0,scrollBeyondLastLine:!1,minimap:{enabled:!1}}})})]})}function h(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}export{m as ConflictEditor};
@@ -0,0 +1 @@
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"./database-Dc8mr-dP.js";import{n as i,t as a}from"./glide-data-grid-DV8ht1BP.js";import{t as o}from"./refresh-cw-CRD2qr4U.js";import{t as s}from"./api-client-DiZgVOok.js";import"./settings-store-CSDOihqv.js";import"./vendor-mermaid-DCie7hiR.js";import"./panel-store-B1pOXkyS.js";import{t as c}from"./tab-store-DzftzxTL.js";import{et as l,tt as u}from"./index-DU_JZ5MY.js";import"./data-grid-types-C29KDkZJ.js";import"./use-monaco-theme-qx6SfVRk.js";import{t as d}from"./sql-query-editor-C7YgtDR3.js";var f=e(n(),1);function p(e,t,n,r){return`ppm-db-${e}-${n}.${t}-p${r}`}function m(e,t,n,r){try{let i=sessionStorage.getItem(p(e,t,n,r));return i?JSON.parse(i):null}catch{return null}}function h(e,t,n,r,i,a){try{sessionStorage.setItem(p(e,t,n,r),JSON.stringify({data:i,cols:a}))}catch{}}function g(e){let t=`/api/db/connections/${e}`,[n,r]=(0,f.useState)(null),[i,a]=(0,f.useState)(`public`),[o,c]=(0,f.useState)(null),[l,u]=(0,f.useState)([]),[d,p]=(0,f.useState)(!1),[g,_]=(0,f.useState)(null),[v,y]=(0,f.useState)(1),[b,x]=(0,f.useState)(null),[S,C]=(0,f.useState)(null),[w,T]=(0,f.useState)(!1),[E,D]=(0,f.useState)(null),[O,k]=(0,f.useState)(`ASC`),A=(0,f.useCallback)(async(r,a,o,l,d)=>{let f=r??n,m=a??i;if(!f)return;p(!0);let g=l===void 0?E:l,y=d??O;try{let n=g?`&orderBy=${encodeURIComponent(g)}&orderDir=${y}`:``,[r,i]=await Promise.all([s.get(`${t}/data?table=${encodeURIComponent(f)}&schema=${m}&page=${o??v}&limit=100${n}`),s.get(`${t}/schema?table=${encodeURIComponent(f)}&schema=${m}`)]);c(r),u(i),h(e,f,m,o??v,r,i)}catch(e){_(e.message)}finally{p(!1)}},[t,e,n,i,v,E,O]),j=(0,f.useCallback)((t,n=`public`)=>{r(t),a(n),y(1),x(null);let i=m(e,t,n,1);i?(c(i.data),u(i.cols),p(!1),A(t,n,1)):A(t,n,1)},[e,A]),M=(0,f.useCallback)(e=>{y(e),A(void 0,void 0,e)},[A]),N=(0,f.useCallback)(async e=>{T(!0),C(null);try{let r=await s.post(`${t}/query`,{sql:e});x(r),r.changeType===`modify`&&A(n??void 0,i)}catch(e){C(e.message)}finally{T(!1)}},[t,n,i,A]),P=(0,f.useCallback)(async(e,r,a,o)=>{if(!n)return;let c=n,l=i;try{await s.put(`${t}/cell`,{table:c,schema:l,pkColumn:e,pkValue:r,column:a,value:o}),A(c,l)}catch(e){_(e.message)}},[t,n,i,A]),F=(0,f.useCallback)(async(e,r)=>{if(!n)return;let a=n,o=i;try{await s.del(`${t}/row`,{table:a,schema:o,pkColumn:e,pkValue:r}),A(a,o)}catch(e){_(e.message)}},[t,n,i,A]);return{selectedTable:n,selectedSchema:i,selectTable:j,tableData:o,schema:l,loading:d,error:g,page:v,setPage:M,orderBy:E,orderDir:O,toggleSort:(0,f.useCallback)(e=>{let t,n=`ASC`;E===e?O===`ASC`?(t=e,n=`DESC`):(t=null,n=`ASC`):(t=e,n=`ASC`),D(t),k(n),y(1),A(void 0,void 0,1,t,n)},[E,O,A]),clearSort:(0,f.useCallback)(()=>{D(null),k(`ASC`),y(1),A(void 0,void 0,1,null,`ASC`)},[A]),queryResult:b,queryError:S,queryLoading:w,executeQuery:N,updateCell:P,deleteRow:F,bulkDelete:(0,f.useCallback)(async(e,r)=>{if(!n)return;let a=n,o=i;try{await s.post(`${t}/rows/delete`,{table:a,schema:o,pkColumn:e,pkValues:r}),A(a,o)}catch(e){_(e.message)}},[t,n,i,A]),insertRow:(0,f.useCallback)(async e=>{if(!n)return;let r=n,a=i;try{await s.post(`${t}/row`,{table:r,schema:a,values:e}),A(r,a)}catch(e){throw _(e.message),e}},[t,n,i,A]),refreshData:A,queryAsTable:(0,f.useCallback)(async e=>{p(!0);try{let n=await s.post(`${t}/query`,{sql:e});n.changeType===`select`&&c({columns:n.columns,rows:n.rows,total:n.rows.length,page:1,limit:n.rows.length})}catch(e){_(e.message)}finally{p(!1)}},[t])}}var _=t();function v(e){let t={},n=/"(\w+)"\s+ILIKE\s+'%([^']*?)%'/gi,r;for(;(r=n.exec(e))!==null;)t[r[1]]=r[2].replace(/''/g,`'`);return t}function y({metadata:e,tabId:t}){let n=e?.connectionId,l=e?.connectionName,p=e?.tableName,m=e?.schemaName??`public`,h=e?.initialSql,y=e?.currentSql,b=c(e=>e.updateTab),S=(0,f.useRef)(e);S.current=e;let C=(0,f.useCallback)(e=>{t&&b(t,{metadata:{...S.current,currentSql:e}})},[t,b]),w=g(n),[T,E]=(0,f.useState)([]),[D,O]=(0,f.useState)(180),k=(0,f.useRef)(null),[A,j]=(0,f.useState)({}),M=(0,f.useMemo)(()=>{if(h&&!w.selectedTable)return h;if(w.selectedTable){let e=`SELECT * FROM "${w.selectedTable}"`,t=Object.entries(A).filter(([,e])=>e.trim()).map(([e,t])=>`"${e}" ILIKE '%${t.replace(/'/g,`''`)}%'`);t.length>0&&(e+=` WHERE ${t.join(` AND `)}`),w.orderBy&&(e+=` ORDER BY "${w.orderBy}" ${w.orderDir}`);let n=(w.page-1)*100;return e+=` LIMIT 100`,n>0&&(e+=` OFFSET ${n}`),e}return`SELECT * FROM `},[h,w.selectedTable,w.orderBy,w.orderDir,w.page,A]),N=(0,f.useCallback)(e=>{j(e)},[]),P=(0,f.useRef)(void 0);(0,f.useEffect)(()=>{if(!(!w.selectedTable||Object.keys(A).length===0))return clearTimeout(P.current),P.current=setTimeout(()=>{w.queryAsTable(M)},500),()=>clearTimeout(P.current)},[A]);let F=(0,f.useCallback)(e=>{e.preventDefault();let t=e.clientY,n=D,r=e=>{let r=e.clientY-t;O(Math.max(80,Math.min(n+r,(k.current?.clientHeight??600)-100)))},i=()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)},[D]);(0,f.useEffect)(()=>{s.get(`/api/db/connections/${n}/tables?cached=1`).then(e=>E(e.map(e=>({name:e.name,schema:e.schema})))).catch(()=>{})},[n]);let I=(0,f.useMemo)(()=>{if(T.length!==0)return{tables:T,getColumns:async(e,t)=>await s.get(`/api/db/connections/${n}/schema?table=${encodeURIComponent(e)}${t?`&schema=${encodeURIComponent(t)}`:``}`)}},[n,T]),L=(0,f.useRef)(!1);(0,f.useEffect)(()=>{L.current||(L.current=!0,h?w.executeQuery(h):p&&w.selectTable(p,m))},[p,m,h]);let[R,z]=(0,f.useState)(!!h),B=(0,f.useCallback)(e=>{let t=e.trim();if(w.selectedTable&&RegExp(`^SELECT\\s+\\*\\s+FROM\\s+"?${w.selectedTable.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}"?\\b`,`i`).test(t)){j(v(t)),w.queryAsTable(t);return}z(!0),w.executeQuery(e)},[w.executeQuery,w.queryAsTable,w.selectedTable]),V=(0,f.useCallback)(e=>{z(!1),w.toggleSort(e)},[w.toggleSort]),H=(0,f.useCallback)(()=>{z(!1),w.clearSort()},[w.clearSort]),U=(0,f.useCallback)(e=>{z(!1),w.setPage(e)},[w.setPage]),W=w.queryResult,G=R&&!!(W||w.queryError),K=w.selectedTable&&!G;return(0,_.jsx)(`div`,{ref:k,className:`flex h-full w-full overflow-hidden`,children:(0,_.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b border-border bg-background shrink-0`,children:[(0,_.jsx)(r,{className:`size-3.5 text-muted-foreground`}),(0,_.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:l??`Database`}),w.selectedTable&&(0,_.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`/ `,w.selectedTable]}),(0,_.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[w.tableData&&(0,_.jsx)(i,{columns:w.tableData.columns,rows:w.tableData.rows,filename:l?`${l}-${w.selectedTable??`data`}`:w.selectedTable??`data`,exportAllUrl:w.selectedTable?`/api/db/connections/${n}/export?table=${encodeURIComponent(w.selectedTable)}&schema=${w.selectedSchema}`:void 0}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>w.refreshData(),title:`Reload data`,className:`p-1 rounded text-muted-foreground hover:text-foreground transition-colors`,children:(0,_.jsx)(o,{className:`size-3 ${w.loading?`animate-spin`:``}`})})]})]}),(0,_.jsx)(`div`,{className:`shrink-0 border-b border-border`,style:{height:D},children:(0,_.jsx)(d,{onExecute:B,loading:w.queryLoading,defaultValue:M,schemaInfo:I,onSqlChange:C,persistedSql:y})}),(0,_.jsx)(`div`,{onMouseDown:F,className:`shrink-0 h-1.5 cursor-row-resize bg-border/50 hover:bg-primary/30 flex items-center justify-center transition-colors`,children:(0,_.jsx)(u,{className:`size-3 text-muted-foreground/50`})}),(0,_.jsxs)(`div`,{className:`flex-1 overflow-hidden`,children:[K&&w.tableData&&(0,_.jsx)(a,{columns:w.tableData.columns,rows:w.tableData.rows,total:w.tableData.total,limit:w.tableData.limit,schema:w.schema,loading:w.loading,page:w.page,onPageChange:U,onCellUpdate:w.updateCell,onRowDelete:w.deleteRow,orderBy:w.orderBy,orderDir:w.orderDir,onToggleSort:V,onClearSort:H,onBulkDelete:w.bulkDelete,onInsertRow:w.insertRow,connectionId:n,selectedTable:w.selectedTable,selectedSchema:w.selectedSchema,connectionName:l,columnFilters:A,onColumnFilter:N}),G&&(0,_.jsx)(x,{result:W,error:w.queryError,loading:w.queryLoading,schema:w.schema,connectionName:l})]})]})})}var b=()=>{};function x({result:e,error:t,loading:n,schema:r,connectionName:i}){let o=(0,f.useMemo)(()=>e?.changeType===`select`&&e.rows.length>0?{columns:e.columns,rows:e.rows,total:e.rows.length,limit:e.rows.length}:null,[e]),s=(0,f.useMemo)(()=>r?.length?r:(e?.columns??[]).map(e=>({name:e,type:`text`,nullable:!0,pk:!1,defaultValue:null})),[r,e?.columns]);return(0,_.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden text-xs`,children:[t&&(0,_.jsx)(`div`,{className:`px-3 py-2 text-destructive bg-destructive/5 shrink-0`,children:t}),e?.changeType===`modify`&&(0,_.jsxs)(`div`,{className:`px-3 py-2 text-green-500 shrink-0`,children:[e.rowsAffected,` row(s) affected`,e.executionTimeMs!=null&&(0,_.jsxs)(`span`,{className:`text-muted-foreground ml-2`,children:[e.executionTimeMs,`ms`]})]}),o&&(0,_.jsxs)(`div`,{className:`flex-1 overflow-hidden`,children:[(0,_.jsx)(a,{columns:o.columns,rows:o.rows,total:o.total,limit:o.limit,schema:s,loading:!!n,page:1,onPageChange:b,onCellUpdate:b,orderBy:null,orderDir:`ASC`,onToggleSort:b,connectionName:i}),e?.executionTimeMs!=null&&(0,_.jsxs)(`div`,{className:`px-3 py-0.5 border-t border-border text-[10px] text-muted-foreground shrink-0`,children:[e.rows.length,` rows · `,e.executionTimeMs,`ms`]})]}),e?.changeType===`select`&&e.rows.length===0&&(0,_.jsxs)(`div`,{className:`px-3 py-2 text-muted-foreground shrink-0`,children:[`No results`,e.executionTimeMs!=null&&(0,_.jsxs)(`span`,{className:`ml-2 text-muted-foreground/60`,children:[e.executionTimeMs,`ms`]})]}),!e&&!t&&(0,_.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:n?(0,_.jsx)(l,{className:`size-4 animate-spin`}):`Run a query to see results`})]})}export{y as DatabaseViewer};
@@ -0,0 +1,4 @@
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};
@@ -0,0 +1,12 @@
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"./file-exclamation-point-B__2Hrd6.js";import{i,t as a}from"./api-client-DiZgVOok.js";import{et as o}from"./index-DU_JZ5MY.js";var s=e(n(),1),c=t();function l({filePath:e,projectName:t}){let[n,l]=(0,s.useState)(null),[u,d]=(0,s.useState)(!0),[f,p]=(0,s.useState)(null);return(0,s.useEffect)(()=>{d(!0),p(null);let n=/^(\/|[A-Za-z]:[/\\])/.test(e)?`/api/fs/docx-html?path=${encodeURIComponent(e)}`:`${i(t)}/files/docx-html?path=${encodeURIComponent(e)}`;a.get(n).then(e=>{l(e.html),d(!1)}).catch(e=>{p(e instanceof Error?e.message:`Failed to convert docx`),d(!1)})},[e,t]),(0,s.useEffect)(()=>{let n=n=>{let r=n.detail;if(r.projectName!==t||r.path!==e)return;let o=/^(\/|[A-Za-z]:[/\\])/.test(e)?`/api/fs/docx-html?path=${encodeURIComponent(e)}`:`${i(t)}/files/docx-html?path=${encodeURIComponent(e)}`;a.get(o).then(e=>l(e.html)).catch(()=>{})};return window.addEventListener(`file:changed`,n),()=>window.removeEventListener(`file:changed`,n)},[e,t]),u?(0,c.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-text-secondary`,children:[(0,c.jsx)(o,{className:`size-5 animate-spin`}),(0,c.jsx)(`span`,{className:`text-sm`,children:`Converting document...`})]}):f?(0,c.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,c.jsx)(r,{className:`size-10 text-text-subtle`}),(0,c.jsx)(`p`,{className:`text-sm`,children:`Failed to load document.`}),(0,c.jsx)(`p`,{className:`text-xs text-text-subtle`,children:f})]}):(0,c.jsx)(`div`,{className:`h-full overflow-auto bg-white dark:bg-zinc-900`,children:(0,c.jsx)(`div`,{className:`docx-preview max-w-3xl mx-auto px-6 py-8 text-sm text-foreground leading-relaxed
2
+ [&_table]:border-collapse [&_table]:w-full [&_table]:my-3
3
+ [&_td]:border [&_td]:border-border [&_td]:px-2 [&_td]:py-1
4
+ [&_th]:border [&_th]:border-border [&_th]:px-2 [&_th]:py-1 [&_th]:font-semibold [&_th]:bg-muted/50
5
+ [&_img]:max-w-full [&_img]:h-auto [&_img]:rounded
6
+ [&_h1]:text-2xl [&_h1]:font-bold [&_h1]:mt-6 [&_h1]:mb-3
7
+ [&_h2]:text-xl [&_h2]:font-semibold [&_h2]:mt-5 [&_h2]:mb-2
8
+ [&_h3]:text-lg [&_h3]:font-medium [&_h3]:mt-4 [&_h3]:mb-2
9
+ [&_p]:my-2
10
+ [&_ul]:list-disc [&_ul]:pl-6 [&_ul]:my-2
11
+ [&_ol]:list-decimal [&_ol]:pl-6 [&_ol]:my-2
12
+ [&_li]:my-0.5`,dangerouslySetInnerHTML:{__html:n??``}})})}export{l as DocxPreview};
@@ -1,3 +1,3 @@
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{$ as i,x as a}from"./index-CkQX29w3.js";var o=e(n(),1),s=t(),c=`<script>
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
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
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};
@@ -0,0 +1 @@
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{t as o}from"./refresh-cw-CRD2qr4U.js";import{i as s,t as c}from"./api-client-DiZgVOok.js";import{n as l}from"./utils-E0yyGxXt.js";import{n as u}from"./project-store-BnvrVKBw.js";import{W as d,_ as f,dt as p,et as m,nt as h}from"./index-DU_JZ5MY.js";var g=r(`cloud-off`,[[`path`,{d:`M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057`,key:`1uxyv8`}],[`path`,{d:`M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78`,key:`99tcn7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),_=e(n(),1),v=t(),y=[`#2563eb`,`#16a34a`,`#d97706`,`#9333ea`,`#dc2626`,`#0891b2`,`#c026d3`,`#ea580c`];function b(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)|0;return y[Math.abs(t)%y.length]}function x({name:e,syncState:t,isHead:n,isTag:r,className:o}){let s=r?`#d97706`:b(e),c=r?d:t===`synced`?p:t===`ahead`?a:t===`behind`?i:t===`remote-only`?p:g,u=r?`Tag: ${e}`:t===`synced`?`${e} — synced with remote`:t===`ahead`?`${e} — ahead of remote`:t===`behind`?`${e} — behind remote`:t===`remote-only`?`${e} — remote only`:`${e} — local only`;return(0,v.jsxs)(`span`,{className:l(`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-[11px] font-medium leading-tight max-w-[220px]`,n&&`ring-1 ring-offset-1 ring-offset-background`,t===`remote-only`&&`opacity-70`,o),style:{borderColor:s,backgroundColor:s+`1A`,color:`#1a1a1a`,...n?{"--tw-ring-color":s}:{}},title:u,children:[(0,v.jsx)(c,{className:`size-3 shrink-0`,style:{color:s}}),(0,v.jsx)(`span`,{className:`truncate`,children:e})]})}function S(e,t,n,r){let i=[],a=e===r;for(let e of t)e.startsWith(`tag: `)&&i.push({name:e.slice(5),syncState:`synced`,isTag:!0});let o=n.filter(t=>t.commitHash===e),s=o.filter(e=>!e.remote),c=o.filter(e=>e.remote);new Set(s.map(e=>e.name));let l=new Set;for(let e of s){let t=`local-only`;e.remotes.length>0&&(t=e.ahead>0&&e.behind===0?`ahead`:e.behind>0&&e.ahead===0?`behind`:`synced`),i.push({name:e.name,syncState:t,isHead:a&&e.current});for(let t of c){let n=t.name.replace(/^remotes\//,``),r=n.indexOf(`/`);r<0||n.slice(r+1)===e.name&&l.add(t.name)}}for(let e of c){if(l.has(e.name))continue;let t=e.name.replace(/^remotes\//,``);i.push({name:t,syncState:`remote-only`})}return i}var C=100;function w({metadata:e}){let t=e?.projectName??u(f(e=>e.activeProject))?.name,[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(!1),[l,d]=(0,_.useState)(!0),p=(0,_.useRef)(null),g=(0,_.useCallback)(async(e=0,n=!1)=>{if(t){a(!0);try{let i=await c.get(`${s(t)}/git/graph?max=${C}&skip=${e}`);r(e=>n&&e?{...i,commits:[...e.commits,...i.commits]}:i),d(i.commits.length===C)}catch{}a(!1)}},[t]);(0,_.useEffect)(()=>{g()},[g]);let y=(0,_.useCallback)(()=>{i||!l||!n||g(n.commits.length,!0)},[i,l,n,g]),b=(0,_.useCallback)(e=>{let t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight<200&&y()},[y]);return t?(0,v.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-border shrink-0`,children:[(0,v.jsx)(h,{className:`size-4 text-text-secondary`}),(0,v.jsx)(`span`,{className:`text-xs font-medium text-text-primary`,children:`Git Log`}),(0,v.jsx)(`span`,{className:`text-[10px] text-text-subtle`,children:n?`${n.commits.length} commits`:``}),(0,v.jsx)(`div`,{className:`flex-1`}),(0,v.jsx)(`button`,{onClick:()=>g(),disabled:i,className:`p-1 rounded text-text-subtle hover:text-text-secondary transition-colors`,title:`Refresh`,children:(0,v.jsx)(o,{className:`size-3.5 ${i?`animate-spin`:``}`})})]}),!n&&i?(0,v.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,v.jsx)(m,{className:`size-5 animate-spin text-primary`})}):n&&n.commits.length===0?(0,v.jsx)(`div`,{className:`flex items-center justify-center h-full text-text-secondary text-sm`,children:`No commits yet`}):n?(0,v.jsxs)(`div`,{ref:p,className:`flex-1 overflow-y-auto min-h-0`,onScroll:b,children:[n.commits.map(e=>(0,v.jsx)(T,{commit:e,branches:n.branches,head:n.head},e.hash)),i&&(0,v.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,v.jsx)(m,{className:`size-4 animate-spin text-text-subtle`})}),!l&&n.commits.length>0&&(0,v.jsx)(`div`,{className:`text-center text-[10px] text-text-subtle py-3`,children:`End of history`})]}):null]}):(0,v.jsx)(`div`,{className:`flex items-center justify-center h-full text-text-secondary text-sm`,children:`Select a project to view git log`})}function T({commit:e,branches:t,head:n}){let r=e.hash===n,i=S(e.hash,e.refs,t,n);return(0,v.jsxs)(`div`,{className:`flex items-start gap-2 px-3 py-1.5 border-b border-border/50 hover:bg-surface-elevated transition-colors ${r?`bg-primary/5`:``}`,children:[(0,v.jsx)(`div`,{className:`flex items-center pt-1 shrink-0`,children:(0,v.jsx)(`span`,{className:`size-2.5 rounded-full border-2 ${r?`border-primary bg-primary`:`border-text-subtle bg-transparent`}`})}),(0,v.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[i.length>0&&(0,v.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 mb-0.5`,children:i.map(e=>(0,v.jsx)(x,{...e},`${e.name}-${e.syncState}`))}),(0,v.jsx)(`p`,{className:`text-xs text-text-primary truncate leading-snug`,children:e.subject}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,v.jsx)(`span`,{className:`text-[10px] font-mono text-text-subtle`,children:e.abbreviatedHash}),(0,v.jsx)(`span`,{className:`text-[10px] text-text-subtle truncate`,children:e.authorName}),(0,v.jsx)(`span`,{className:`text-[10px] text-text-subtle shrink-0`,children:E(e.authorDate)})]})]})]})}function E(e){let t=new Date(e),n=Date.now()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`now`;if(r<60)return`${r}m`;let i=Math.floor(r/60);if(i<24)return`${i}h`;let a=Math.floor(i/24);return a<30?`${a}d`:t.toLocaleDateString(`en`,{month:`short`,day:`numeric`})}export{w as GitLogPanel};