@hienlh/ppm 0.13.54 → 0.13.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/assets/skills/ppm/SKILL.md +1 -1
- package/assets/skills/ppm/references/http-api.md +8 -1
- package/dist/web/assets/ai-settings-section-BH2UOQH-.js +1 -0
- package/dist/web/assets/{api-settings-C3T95dWg.js → api-settings-uQKmeGkl.js} +1 -1
- package/dist/web/assets/architecture-PBZL5I3N-DLKD1Xjj.js +1 -0
- package/dist/web/assets/arrow-down-D825m4vm.js +1 -0
- package/dist/web/assets/{audio-preview-BF1LU0eY.js → audio-preview-LCxWo-25.js} +1 -1
- package/dist/web/assets/chat-tab-3GUmdAJN.js +16 -0
- package/dist/web/assets/chevron-down-BMo4cBth.js +1 -0
- package/dist/web/assets/code-editor-Cd7NZ0VX.js +8 -0
- package/dist/web/assets/{conflict-editor-DcVj0Z-q.js → conflict-editor-No7IVPRN.js} +3 -3
- package/dist/web/assets/csv-parser-D8VHWVA6.js +6 -0
- package/dist/web/assets/{csv-preview-B3Dyhgho.js → csv-preview-DgArUJhd.js} +2 -2
- package/dist/web/assets/{data-grid-overlay-editor-C1UUm7Ob.js → data-grid-overlay-editor-CmduzuPM.js} +1 -1
- package/dist/web/assets/database-viewer-zeQXxkg-.js +1 -0
- package/dist/web/assets/diff-viewer-DmSkyBaT.js +4 -0
- package/dist/web/assets/{esm-DCbn6xno.js → esm-JPvheKDJ.js} +1 -1
- package/dist/web/assets/{extension-webview-DCmfZH6p.js → extension-webview-DCwz2Wso.js} +1 -1
- package/dist/web/assets/eye-off-BacF7RVS.js +1 -0
- package/dist/web/assets/git-log-panel-Bk7Eh-Bn.js +1 -0
- package/dist/web/assets/gitGraph-HDMCJU4V-2a0r4GHr.js +1 -0
- package/dist/web/assets/glide-data-grid-ha8hjunf.js +136 -0
- package/dist/web/assets/{image-preview-BIJGvZ5-.js → image-preview-C1VLHLdJ.js} +1 -1
- package/dist/web/assets/index-CP6EIXkh.js +27 -0
- package/dist/web/assets/index-DwvSM9vu.css +2 -0
- package/dist/web/assets/info-3K5VOQVL-CWKw4e0V.js +1 -0
- package/dist/web/assets/{input-_LFQwhzd.js → input-B78ol0hV.js} +1 -1
- package/dist/web/assets/keybindings-store-Rf9YKWAp.js +1 -0
- package/dist/web/assets/{markdown-renderer-CwKRCQuc.js → markdown-renderer-C7ZoGWso.js} +3 -3
- package/dist/web/assets/notification-store-C3tg-ZXm.js +1 -0
- package/dist/web/assets/{number-overlay-editor-CyEqxXcg.js → number-overlay-editor-DS-qf63L.js} +1 -1
- package/dist/web/assets/packet-RMMSAZCW-Ar00Wbhd.js +1 -0
- package/dist/web/assets/panel-store-B1pOXkyS.js +1 -0
- package/dist/web/assets/{pdf-preview-CbUTv4dX.js → pdf-preview-BdmR2RsT.js} +1 -1
- package/dist/web/assets/pie-UPGHQEXC-Q4ssDdib.js +1 -0
- package/dist/web/assets/port-forwarding-tab-BMb8neu0.js +1 -0
- package/dist/web/assets/{postgres-viewer-C-A4MMtt.js → postgres-viewer-DkM6ndux.js} +3 -3
- package/dist/web/assets/project-store-BnvrVKBw.js +1 -0
- package/dist/web/assets/radar-KQ55EAFF-kq5v4OKX.js +1 -0
- package/dist/web/assets/{settings-store-8FpQDjEA.js → settings-store-CSDOihqv.js} +2 -2
- package/dist/web/assets/settings-tab-WdL5pYxG.js +1 -0
- package/dist/web/assets/{sql-query-editor-Cu9mYyfb.js → sql-query-editor-CNwOnFgF.js} +1 -1
- package/dist/web/assets/{sqlite-viewer-D6ngJJgP.js → sqlite-viewer-FFlsRPWf.js} +1 -1
- package/dist/web/assets/system-monitor-tab-CefzxLVi.js +1 -0
- package/dist/web/assets/{tab-store-CNas5Ny8.js → tab-store-DzftzxTL.js} +1 -1
- package/dist/web/assets/{terminal-tab-CyuBxW2x.js → terminal-tab-C4MNU5S3.js} +2 -2
- package/dist/web/assets/{x-BPReZWnP.js → trash-2-DkIfBY8d.js} +1 -1
- package/dist/web/assets/treemap-KZPCXAKY-DChODgHt.js +1 -0
- package/dist/web/assets/{use-blob-url-DB4nNruT.js → use-blob-url-CI2h4qu0.js} +1 -1
- package/dist/web/assets/{use-monaco-theme-DEI-tJAh.js → use-monaco-theme-qx6SfVRk.js} +1 -1
- package/dist/web/assets/{vendor-mermaid-D2KKkqNs.js → vendor-mermaid-DCie7hiR.js} +2 -2
- package/dist/web/assets/{video-preview-ChP5ypMo.js → video-preview-izCy3xj7.js} +1 -1
- package/dist/web/assets/wifi-LJEyIdXf.js +1 -0
- package/dist/web/assets/x-DfF6D5Js.js +1 -0
- package/dist/web/index.html +22 -20
- package/dist/web/sw.js +1 -1
- package/docs/project-changelog.md +38 -1
- package/docs/system-architecture.md +2 -1
- package/package.json +1 -1
- package/packages/ext-git-graph/src/webview-html.ts +29 -8
- package/src/server/index.ts +4 -0
- package/src/server/middleware/auth.ts +9 -0
- package/src/server/routes/resources.ts +88 -0
- package/src/services/resource-monitor-utils.ts +129 -0
- package/src/services/resource-monitor.service.ts +122 -0
- package/src/web/components/git/git-log-panel.tsx +206 -0
- package/src/web/components/git/git-ref-badge.tsx +150 -0
- package/src/web/components/git/git-status-panel.tsx +18 -0
- package/src/web/components/layout/mobile-nav.tsx +2 -0
- package/src/web/components/layout/sidebar.tsx +6 -0
- package/src/web/components/layout/tab-bar.tsx +3 -0
- package/src/web/components/layout/tab-content.tsx +10 -0
- package/src/web/components/layout/tab-pool.tsx +2 -0
- package/src/web/components/system/resource-status-bar.tsx +66 -0
- package/src/web/components/system/sparkline-canvas.tsx +64 -0
- package/src/web/components/system/system-monitor-group-row.tsx +133 -0
- package/src/web/components/system/system-monitor-tab.tsx +186 -0
- package/src/web/hooks/use-resource-monitor.ts +114 -0
- package/src/web/stores/panel-store.ts +1 -1
- package/src/web/stores/tab-store.ts +3 -1
- package/dist/web/assets/ai-settings-section-AuV6Lzz2.js +0 -1
- package/dist/web/assets/architecture-PBZL5I3N-fAJMexNi.js +0 -1
- package/dist/web/assets/chat-tab-CCOkAmh8.js +0 -16
- package/dist/web/assets/code-editor-BptkAFVa.js +0 -8
- package/dist/web/assets/csv-parser-Dly5nqE1.js +0 -6
- package/dist/web/assets/database-viewer-CYrsNjRy.js +0 -1
- package/dist/web/assets/diff-viewer-DMBviO6l.js +0 -4
- package/dist/web/assets/file-store-DOxcU_7s.js +0 -1
- package/dist/web/assets/gitGraph-HDMCJU4V-ClRAoBAn.js +0 -1
- package/dist/web/assets/glide-data-grid-DhZjCUqu.js +0 -136
- package/dist/web/assets/index-BA8zQtSN.js +0 -27
- package/dist/web/assets/index-CKKoR3gY.css +0 -2
- package/dist/web/assets/info-3K5VOQVL-D8uyBfC_.js +0 -1
- package/dist/web/assets/keybindings-store-BXumit4n.js +0 -1
- package/dist/web/assets/notification-store-B3Fgo6Qw.js +0 -1
- package/dist/web/assets/packet-RMMSAZCW-BJj3FH_w.js +0 -1
- package/dist/web/assets/panel-store-C8wwxBpn.js +0 -1
- package/dist/web/assets/pie-UPGHQEXC-BKfHRBz7.js +0 -1
- package/dist/web/assets/port-forwarding-tab-Nn3-C-Vu.js +0 -1
- package/dist/web/assets/radar-KQ55EAFF-DkybKTt9.js +0 -1
- package/dist/web/assets/scroll-area-BDi_FNzr.js +0 -1
- package/dist/web/assets/settings-tab-Bzlcvim9.js +0 -1
- package/dist/web/assets/treemap-KZPCXAKY-BvDgIWW9.js +0 -1
- /package/dist/web/assets/{api-client-DIhJ5qVW.js → api-client-DiZgVOok.js} +0 -0
- /package/dist/web/assets/{chevron-right-DnHIvvcy.js → chevron-right-CD8e6Aj4.js} +0 -0
- /package/dist/web/assets/{code-DGBecc50.js → code-DiNmA3eR.js} +0 -0
- /package/dist/web/assets/{data-grid-types-D2cHE8hx.js → data-grid-types-C29KDkZJ.js} +0 -0
- /package/dist/web/assets/{database-DOWH9-Vv.js → database-Dc8mr-dP.js} +0 -0
- /package/dist/web/assets/{dist-DVk8T0R5.js → dist-DeY41KFi.js} +0 -0
- /package/dist/web/assets/{dist-BoIkGNC8.js → dist-PPUhQONj.js} +0 -0
- /package/dist/web/assets/{file-exclamation-point-BwzaQ50n.js → file-exclamation-point-B__2Hrd6.js} +0 -0
- /package/dist/web/assets/{globe-B4Ilypbs.js → globe-CQ8NAYvi.js} +0 -0
- /package/dist/web/assets/{katex-C10ndCVt.js → katex-DUj5OG1J.js} +0 -0
- /package/dist/web/assets/{lib-C2D8j3K3.js → lib-DrypSCq8.js} +0 -0
- /package/dist/web/assets/{react-DMIOAtcX.js → react-CfveccaI.js} +0 -0
- /package/dist/web/assets/{refresh-cw-BjrAbUJe.js → refresh-cw-CRD2qr4U.js} +0 -0
- /package/dist/web/assets/{search-tM8K5zWU.js → search-D90WJ5fo.js} +0 -0
- /package/dist/web/assets/{sparkles-CulWHe4c.js → sparkles-KCOEy7QI.js} +0 -0
- /package/dist/web/assets/{table-BzjWcs87.js → table-2wDtM4_B.js} +0 -0
- /package/dist/web/assets/{text-wrap-DJz9Bgpa.js → text-wrap-AZErifCu.js} +0 -0
- /package/dist/web/assets/{utils-CQux7CsO.js → utils-E0yyGxXt.js} +0 -0
- /package/dist/web/assets/{vendor-xterm-D1P36hcr.js → vendor-xterm-t3d5xZdz.js} +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/markdown-renderer-C7ZoGWso.js","assets/rolldown-runtime-FhOqtrmT.js","assets/index-CP6EIXkh.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-DwvSM9vu.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-C1VLHLdJ.js","assets/file-exclamation-point-B__2Hrd6.js","assets/use-blob-url-CI2h4qu0.js","assets/pdf-preview-BdmR2RsT.js","assets/video-preview-izCy3xj7.js","assets/audio-preview-LCxWo-25.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-ha8hjunf.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 x,t as S}from"./api-client-DiZgVOok.js";import{n as ne}from"./settings-store-CSDOihqv.js";import{K as C}from"./vendor-mermaid-DCie7hiR.js";import{t as w}from"./utils-E0yyGxXt.js";import{t as re}from"./panel-store-B1pOXkyS.js";import{n as T}from"./project-store-BnvrVKBw.js";import{t as ie}from"./tab-store-DzftzxTL.js";import{$ as E,O as D,V as ae,Y as oe,_ as se,at as ce,ct as O,d as k,dt as le,et as A,f as j,h as M,it as N,l as P,m as F,nt as ue,o as de,ot as I,p as fe,rt as pe,s as L,st as me,u as he,v as ge}from"./index-CP6EIXkh.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(),B={ts:I,tsx:I,js:I,jsx:I,py:I,rs:I,go:I,html:I,css:I,scss:I,json:me,md:ce,txt:ce,yaml:N,yml:N};function be(e,t){return t?ue:B[e.split(`.`).pop()?.toLowerCase()??``]??pe}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=D(e=>e.tree),{updateTab:o,openTab:s}=ie(se(e=>({updateTab:e.updateTab,openTab:e.openTab}))),c=T(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=w(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)(Ce,{segment:e,isLast:n===f.length-1,projectName:t,onFileClick:p})]},e.fullPath))]})}function Ce({segment:e,isLast:t,projectName:n,onFileClick:r}){let i=D(e=>e.loadChildren),a=D(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)(P,{onOpenChange:c,children:[(0,z.jsx)(M,{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)(k,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):o.map(t=>(0,z.jsx)(H,{node:t,projectName:n,activePath:e.fullPath,onFileClick:r},t.path))})]})}function H({node:e,projectName:t,activePath:n,onFileClick:r}){let i=be(e.name,e.type===`directory`),a=e.path===n,o=D(e=>e.loadChildren),s=D(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)(j,{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)(k,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):V(c).map(e=>(0,z.jsx)(H,{node:e,projectName:t,activePath:n,onFileClick:r},e.path))})]})}return(0,z.jsxs)(k,{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=T(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)(L,{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,Ee=[`(`,`)`,`{`,`}`,`[`,`]`,`<`,`>`,`;`,`:`,`=`,`"`,`'`,"`",`/`,`\\`,`_`,`#`],G=`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`,K=`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`,De=`w-px h-5 bg-border mx-0.5 shrink-0`;function Oe({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:G,title:`Paste`,children:(0,z.jsx)(le,{size:14})}),(0,z.jsx)(`button`,{type:`button`,onClick:u,className:G,title:`Undo`,children:(0,z.jsx)(ae,{size:14})}),(0,z.jsx)(`button`,{type:`button`,onClick:d,className:G,title:`Redo`,children:(0,z.jsx)(ye,{size:14})}),(0,z.jsx)(`div`,{className:De}),(0,z.jsx)(`button`,{type:`button`,onClick:f,className:K,children:`Tab`}),(0,z.jsx)(`div`,{className:De}),Ee.map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:K,children:e},e))]})]})}var ke=(0,R.lazy)(()=>C(()=>import(`./markdown-renderer-C7ZoGWso.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]))),Ae=(0,R.lazy)(()=>C(()=>import(`./csv-preview-DgArUJhd.js`).then(e=>({default:e.CsvPreview})),__vite__mapDeps([27,1,4,5,28,29,8,30,31]))),je=(0,R.lazy)(()=>C(()=>import(`./image-preview-C1VLHLdJ.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]))),Me=(0,R.lazy)(()=>C(()=>import(`./pdf-preview-BdmR2RsT.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,34]))),Ne=(0,R.lazy)(()=>C(()=>import(`./video-preview-izCy3xj7.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]))),Pe=(0,R.lazy)(()=>C(()=>import(`./audio-preview-LCxWo-25.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]))),Fe=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`ico`]),Ie=new Set([`mp4`,`webm`,`mov`,`ogg`,`avi`,`mkv`]),Le=new Set([`mp3`,`wav`,`flac`,`aac`,`m4a`,`wma`]),Re=new Set([`db`,`sqlite`,`sqlite3`]);function ze(e){return e.split(`.`).pop()?.toLowerCase()??``}function Be(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`}[ze(e)]??`plaintext`}var q=(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:C,updateTab:T}=ie(se(e=>({tabs:e.tabs,updateTab:e.updateTab}))),{wordWrap:D,toggleWordWrap:ae}=ne(se(e=>({wordWrap:e.wordWrap,toggleWordWrap:e.toggleWordWrap}))),ce=ve(),O=e?.isUntitled===!0,k=e?.unsavedContent,[le,A]=(0,R.useState)(!1),j=C.find(e=>e.id===t),M=n?ze(n):``,N=Fe.has(M),P=M===`pdf`,F=Ie.has(M),ue=Le.has(M),I=Re.has(M),fe=M===`md`||M===`mdx`,pe=M===`csv`,L=M===`sql`,[me,he]=(0,R.useState)(`preview`),[ge,ye]=(0,R.useState)(`table`),{connections:B,cachedTables:be,refreshTables:xe}=de(),[V,Ce]=(0,R.useState)(()=>{if(!L||!n)return null;let e=localStorage.getItem(`ppm:sql-conn:${n}`);return e?Number(e):null}),H=(0,R.useRef)(null),U=(0,R.useRef)(null),W=(0,R.useMemo)(()=>B.find(e=>e.id===V)??null,[B,V]),Ee=a!=null&&(o===`json`||o===`xml`),[G,K]=(0,R.useState)(!1),De=(0,R.useCallback)(()=>{if(a)if(G)c(a),K(!1);else{let e=a.trimStart();if(o===`json`)try{c(JSON.stringify(JSON.parse(e),null,2)),K(!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
|
+
`)),K(!0)}}},[a,o,G]),ke=(0,R.useCallback)(e=>{Ce(e),n&&localStorage.setItem(`ppm:sql-conn:${n}`,String(e)),xe(e).catch(()=>{})},[n,xe]),q=(0,R.useMemo)(()=>{if(!L||!V)return;let e=(be.get(V)??[]).map(e=>({name:e.tableName,schema:e.schemaName}));if(e.length!==0)return{tables:e,getColumns:async(e,t)=>S.get(`/api/db/connections/${V}/schema?table=${encodeURIComponent(e)}${t?`&schema=${encodeURIComponent(t)}`:``}`)}},[L,V,be]);(0,R.useEffect)(()=>{if(!(!H.current||!q))return U.current?.dispose(),te(),U.current=H.current.languages.registerCompletionItemProvider(`sql`,g(H.current,q)),()=>{U.current?.dispose()}},[q]);let J=ie(e=>e.openTab),[Ue,We]=(0,R.useState)(null),[Ge,Ke]=(0,R.useState)(null),[qe,Je]=(0,R.useState)(!1),[Ye,Xe]=(0,R.useState)(``),X=(0,R.useCallback)(async e=>{if(W){Je(!0),Ke(null),Xe(e);try{We(await S.post(`/api/db/connections/${W.id}/query`,{sql:e}))}catch(e){Ke(e.message),We(null)}finally{Je(!1)}}},[W]),Ze=(0,R.useCallback)(()=>{!W||!Ye||J({type:`database`,title:`${W.name} · Query`,projectId:null,closable:!0,metadata:{connectionId:W.id,connectionName:W.name,dbType:W.type,initialSql:Ye}})},[W,J,Ye]),Qe=(0,R.useCallback)(()=>{if(!b.current||!W)return;let e=b.current,t=e.getSelection();X(t&&!t.isEmpty()?e.getModel()?.getValueInRange(t)??e.getValue():e.getValue())},[W,X]),$e=typeof window<`u`&&`ontouchstart`in window,et=(0,R.useRef)(null),[tt,nt]=(0,R.useState)(null);(0,R.useEffect)(()=>{if(!$e)return;let e=window.visualViewport;if(!e)return;let t=()=>{let t=et.current;if(!t)return;let n=t.getBoundingClientRect().top;nt(e.height-Math.max(0,n))};return e.addEventListener(`resize`,t),e.addEventListener(`scroll`,t),()=>{e.removeEventListener(`resize`,t),e.removeEventListener(`scroll`,t)}},[$e]);let Z=(0,R.useRef)([]),rt=(0,R.useRef)(X);rt.current=X,(0,R.useEffect)(()=>()=>{Z.current.forEach(e=>e.dispose()),Z.current=[]},[]),(0,R.useEffect)(()=>{I&&t&&T(t,{type:`sqlite`})},[I,t,T]);let Q=n?/^(\/|[A-Za-z]:[/\\])/.test(n):!1;(0,R.useEffect)(()=>{if(a!=null){f(!1);return}if(O){c(k??``),y.current=k??``,f(!1),k&&_(!0);return}if(!n||!Q&&!r)return;if(N||P||F||ue){f(!1);return}f(!0),m(null);let e=Q?`/api/fs/read?path=${encodeURIComponent(n)}`:`${x(r)}/files/read?path=${encodeURIComponent(n)}`;return S.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,Q,O]);let it=(0,R.useRef)(h);it.current=h,(0,R.useEffect)(()=>{if(!n||!r||a!=null||O)return;let e=e=>{let t=e.detail;if(t.projectName!==r||t.path!==n||it.current)return;let i=Q?`/api/fs/read?path=${encodeURIComponent(n)}`:`${x(r)}/files/read?path=${encodeURIComponent(n)}`;S.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,Q,a,O]),(0,R.useEffect)(()=>{if(!j||a!=null)return;let t=O?`Untitled-${e?.untitledNumber??1}`:n?w(n):`Untitled`,r=h?`${t} \u25CF`:t;j.title!==r&&T(j.id,{title:r})},[h]);let at=(0,R.useCallback)(async e=>{if(n&&!(!Q&&!r))try{Q?await S.put(`/api/fs/write`,{path:n,content:e}):await S.put(`${x(r)}/files/write`,{path:n,content:e}),_(!1)}catch{}},[n,r,Q]);function ot(n){let r=n??``;c(r),y.current=r,_(!0),v.current&&clearTimeout(v.current),O?v.current=setTimeout(()=>{t&&T(t,{metadata:{...e,unsavedContent:y.current}})},2e3):v.current=setTimeout(()=>at(y.current),1e3)}let st=(0,R.useCallback)(async(e,n)=>{try{if(v.current&&clearTimeout(v.current),await S.put(`/api/fs/write`,{path:e,content:n}),t){let{closeTab:n,openTab:r}=re.getState();n(t),r({type:`editor`,title:w(e),projectId:null,metadata:{filePath:e},closable:!0})}_(!1),A(!1)}catch{}},[t]),$=e?.lineNumber,ct=(0,R.useCallback)((e,t)=>{if(b.current=e,H.current=t,$&&$>0&&setTimeout(()=>{e.revealLineInCenter($),e.setPosition({lineNumber:$,column:1}),e.focus()},100),O&&e.addCommand(t.KeyMod.CtrlCmd|t.KeyCode.KeyS,()=>A(!0)),e.addCommand(t.KeyMod.Alt|t.KeyCode.KeyZ,()=>ne.getState().toggleWordWrap()),t.languages.typescript.typescriptDefaults.setDiagnosticsOptions({noSemanticValidation:!0,noSyntaxValidation:!0,noSuggestionDiagnostics:!0}),t.languages.typescript.javascriptDefaults.setDiagnosticsOptions({noSemanticValidation:!0,noSyntaxValidation:!0,noSuggestionDiagnostics:!0}),q&&(U.current?.dispose(),U.current=t.languages.registerCompletionItemProvider(`sql`,g(t,q))),L){Z.current.forEach(e=>e.dispose()),Z.current=[];let n=e.getModel(),r=e.addCommand(0,(e,t)=>{t&&rt.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:()=>{}}}});Z.current.push(e)}}},[q]);if(!a&&!O&&(!n||!Q&&!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)(E,{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)(Y,{}),children:(0,z.jsx)(je,{filePath:n,projectName:r})});if(P)return(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(Y,{}),children:(0,z.jsx)(Me,{filePath:n,projectName:r})});if(F)return(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(Y,{}),children:(0,z.jsx)(Ne,{filePath:n,projectName:r})});if(ue)return(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(Y,{}),children:(0,z.jsx)(Pe,{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 lt=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:V??``,onChange:e=>{let t=Number(e.target.value);t&&ke(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:Qe,disabled:!W,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:et,className:`flex flex-col h-full w-full overflow-hidden`,style:tt?{height:`${tt}px`,maxHeight:`${tt}px`}:void 0,children:[a!=null&&Ee&&(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:G?`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`}),lt,(0,z.jsx)(we,{ext:M,mdMode:me,onMdModeChange:he,csvMode:ge,onCsvModeChange:ye,wordWrap:D,onToggleWordWrap:ae,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?w(n):`SQL`}),lt]}),pe&&ge===`table`?(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,z.jsx)(E,{className:`size-5 animate-spin text-text-subtle`})}),children:(0,z.jsx)(Ae,{content:s??``,onContentChange:ot,wordWrap:D})}):fe&&me===`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??Be(n??``),value:s??``,onChange:a==null?ot:void 0,onMount:ct,theme:ce,options:{fontSize:13,fontFamily:`Menlo, Monaco, Consolas, monospace`,wordWrap:D?`on`:`off`,minimap:{enabled:!1},scrollBeyondLastLine:!1,automaticLayout:!0,lineNumbers:`on`,folding:!0,bracketPairColorization:{enabled:!0},readOnly:a!=null},loading:(0,z.jsx)(E,{className:`size-5 animate-spin text-text-subtle`})})}),L&&(Ue||Ge||qe)&&(0,z.jsx)(Ve,{result:Ue,error:Ge,loading:qe,connName:W?.name,onClose:()=>{We(null),Ke(null),Je(!1)},onOpenInTab:Ze}),$e&&(0,z.jsx)(Oe,{editorRef:b,readOnly:a!=null}),le&&(0,z.jsx)(Te,{open:le,defaultName:`Untitled-${e?.untitledNumber??1}`,content:y.current,onSave:st,onCancel:()=>A(!1)})]})}),J=()=>{};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)(A,{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)(O,{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)(E,{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:J,onCellUpdate:J,orderBy:null,orderDir:`ASC`,onToggleSort:J,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 Y(){return(0,z.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,z.jsx)(E,{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)(ke,{content:e,className:`flex-1 overflow-auto p-4`})})}export{q 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-
|
|
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-CP6EIXkh.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(
|
|
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+`
|
|
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)(
|
|
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,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}export{m as ConflictEditor};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
var e=function(e){return e[e.FIELD_START=0]=`FIELD_START`,e[e.UNQUOTED=1]=`UNQUOTED`,e[e.QUOTED=2]=`QUOTED`,e[e.QUOTE_IN_QUOTED=3]=`QUOTE_IN_QUOTED`,e}(e||{});function t(t){let n=[],r=[],i=``,a=e.FIELD_START;for(let o=0;o<t.length;o++){let s=t[o];switch(a){case e.FIELD_START:s===`"`?a=e.QUOTED:s===`,`?(r.push(i),i=``):s===`\r`||(s===`
|
|
2
|
+
`?(r.push(i),i=``,n.push(r),r=[]):(i+=s,a=e.UNQUOTED));break;case e.UNQUOTED:s===`,`?(r.push(i),i=``,a=e.FIELD_START):s===`\r`||(s===`
|
|
3
|
+
`?(r.push(i),i=``,n.push(r),r=[],a=e.FIELD_START):i+=s);break;case e.QUOTED:s===`"`?a=e.QUOTE_IN_QUOTED:i+=s;break;case e.QUOTE_IN_QUOTED:s===`"`?(i+=`"`,a=e.QUOTED):s===`,`?(r.push(i),i=``,a=e.FIELD_START):s===`\r`||(s===`
|
|
4
|
+
`?(r.push(i),i=``,n.push(r),r=[],a=e.FIELD_START):(i+=s,a=e.UNQUOTED));break}}if((i||r.length>0)&&(r.push(i),n.push(r)),n.length===0)return{headers:[],rows:[]};let o=n[0],s=n.slice(1),c=o.length;for(let e=0;e<s.length;e++){let t=s[e];if(t.length<c)for(;t.length<c;)t.push(``);else t.length>c&&(s[e]=t.slice(0,c))}return{headers:o,rows:s}}function n(e,t){let n=e=>e.includes(`,`)||e.includes(`"`)||e.includes(`
|
|
5
|
+
`)?`"${e.replace(/"/g,`""`)}"`:e,r=[e.map(n).join(`,`)];for(let e of t)r.push(e.map(n).join(`,`));return r.join(`
|
|
6
|
+
`)}export{n,t};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import{Y as r}from"./vendor-ui-UXCWAcmi.js";import{
|
|
1
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import{Y as r}from"./vendor-ui-UXCWAcmi.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"./csv-parser-D8VHWVA6.js";import{i as c,n as l,r as u,t as d}from"./lib-DrypSCq8.js";var f=e(r(),1),p=e(n(),1);function m(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o;n.key&&n.debug?.call(n)&&(o=Date.now());let s=e();if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug?.call(n)&&(c=Date.now()),i=t(...s),n.key&&n.debug?.call(n)){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
|
|
2
2
|
font-size: .6rem;
|
|
3
3
|
font-weight: bold;
|
|
4
|
-
color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i}return o.updateDeps=e=>{r=e},o}function h(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var g=(e,t)=>Math.abs(e-t)<1.01,_=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},v=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},y=e=>e,b=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},x=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(v(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(v(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},S={passive:!0},C=typeof window>`u`?!0:`onscrollend`in window,w=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&C?()=>void 0:_(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,S);let l=e.options.useScrollendEvent&&C;return l&&n.addEventListener(`scrollend`,c,S),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},T=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},E=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},D=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:y,rangeExtractor:b,onChange:()=>{},measureElement:T,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=m(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=m(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(e,t,n,r,i,a)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a}),{key:!1}),this.getMeasurements=m(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a},o)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let s=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let c=this.measurementsCache.slice(0,s),l=Array(a).fill(void 0);for(let e=0;e<s;e++){let t=c[e];t&&(l[t.lane]=e)}for(let i=s;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,u;if(a!==void 0&&this.options.lanes>1){s=a;let e=l[s],r=e===void 0?void 0:c[e];u=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?c[i-1]:this.getFurthestMeasurement(c,i);u=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(i,s)}let d=o.get(e),f=typeof d==`number`?d:this.options.estimateSize(i),p=u+f;c[i]={index:i,start:u,size:f,end:p,key:e,lane:s},l[s]=i}return this.measurementsCache=c,c},{key:!1,debug:()=>this.options.debug}),this.calculateRange=m(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?k({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=m(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{let n=this.measurementsCache[e];if(!n)return;let r=t-(this.itemSizeCache.get(n.key)??n.size);r!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?n.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,t)),this.notify(!1))},this.getVirtualItems=m(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return h(t[O(0,t.length-1,e=>h(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t);this.scrollState={index:null,align:t,behavior:n,startedAt:this.now(),lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e;this.scrollState={index:null,align:`start`,behavior:t,startedAt:this.now(),lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=e[e.length-1]?.end??0;else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&g(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},O=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function k({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=O(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var A=typeof document<`u`?p.useLayoutEffect:p.useEffect;function j({useFlushSync:e=!0,...t}){let n=p.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,f.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=p.useState(()=>new D(r));return i.setOptions(r),A(()=>i._didMount(),[]),A(()=>i._willUpdate()),i}function M(e){return j({observeElementRect:x,observeElementOffset:w,scrollToFn:E,...e})}var N=t();function P({content:e,onContentChange:t,wordWrap:n}){let r=(0,p.useMemo)(()=>o(e),[e]),[f,m]=(0,p.useState)(()=>r.rows),[h,g]=(0,p.useState)([]),_=(0,p.useRef)(null),v=(0,p.useRef)(!1);(0,p.useEffect)(()=>{if(v.current){v.current=!1;return}m(r.rows)},[r.rows]);let y=r.headers,b=(0,p.useCallback)((e,n,r)=>{m(a=>{let o=a.map((t,n)=>n===e?[...t]:t);return o[e][n]=r,v.current=!0,t(i(y,o)),o})},[y,t]),x=l({data:f,columns:(0,p.useMemo)(()=>y.map((e,t)=>({id:`col-${t}`,header:e||`Column ${t+1}`,accessorFn:e=>e[t]??``,cell:({row:e,getValue:r})=>(0,N.jsx)(F,{value:r(),onSave:n=>b(e.index,t,n),wordWrap:n}),size:150,minSize:80})),[y,b,n]),state:{sorting:h},onSortingChange:g,getCoreRowModel:u(),getSortedRowModel:c(),enableColumnResizing:!0,columnResizeMode:`onChange`}),{rows:S}=x.getRowModel(),C=M({count:S.length,getScrollElement:()=>_.current,estimateSize:()=>32,overscan:20});return y.length===0?(0,N.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`Empty CSV file`}):(0,N.jsx)(`div`,{ref:_,className:`flex-1 overflow-auto`,children:(0,N.jsxs)(`table`,{className:`w-full text-xs font-mono border-collapse`,children:[(0,N.jsx)(`thead`,{className:`sticky top-0 bg-background z-10 border-b border-border block`,children:x.getHeaderGroups().map(e=>(0,N.jsx)(`tr`,{className:`flex w-full`,children:e.headers.map(e=>(0,N.jsxs)(`th`,{className:`relative text-left px-2 py-1.5 font-medium text-muted-foreground select-none cursor-pointer hover:bg-muted/50 border-r border-border last:border-r-0`,style:{width:e.getSize(),minWidth:e.getSize()},onClick:e.column.getToggleSortingHandler(),children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,N.jsx)(`span`,{className:`truncate`,children:d(e.column.columnDef.header,e.getContext())}),e.column.getIsSorted()===`asc`&&(0,N.jsx)(s,{className:`size-3 shrink-0`}),e.column.getIsSorted()===`desc`&&(0,N.jsx)(a,{className:`size-3 shrink-0`})]}),(0,N.jsx)(`div`,{onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler(),onClick:e=>e.stopPropagation(),className:`absolute right-0 top-0 h-full w-1 cursor-col-resize hover:bg-primary/50 active:bg-primary`})]},e.id))},e.id))}),(0,N.jsx)(`tbody`,{style:{height:C.getTotalSize(),position:`relative`,display:`block`},children:C.getVirtualItems().map(e=>{let t=S[e.index];return(0,N.jsx)(`tr`,{"data-index":e.index,ref:e=>C.measureElement(e),style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`,display:`flex`},children:t.getVisibleCells().map(e=>(0,N.jsx)(`td`,{className:`px-2 py-1 border-b border-border/50 border-r border-r-border/30 last:border-r-0 ${n?`whitespace-pre-wrap break-words`:`truncate`}`,style:{width:e.column.getSize(),minWidth:e.column.getSize()},children:d(e.column.columnDef.cell,e.getContext())},e.id))},t.id)})})]})})}function F({value:e,onSave:t,wordWrap:n}){let[r,i]=(0,p.useState)(!1),[a,o]=(0,p.useState)(e),s=(0,p.useRef)(null),c=(0,p.useCallback)(e=>{e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)},[]);return(0,p.useEffect)(()=>{r&&s.current&&(s.current.focus(),c(s.current))},[r,c]),r?(0,N.jsx)(`textarea`,{ref:s,className:`w-full bg-transparent outline-none border border-primary/50 rounded text-xs font-mono resize-none p-0.5`,style:{minHeight:a.includes(`
|
|
4
|
+
color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i}return o.updateDeps=e=>{r=e},o}function h(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var g=(e,t)=>Math.abs(e-t)<1.01,_=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},v=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},y=e=>e,b=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},x=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(v(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(v(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},S={passive:!0},C=typeof window>`u`?!0:`onscrollend`in window,w=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&C?()=>void 0:_(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,S);let l=e.options.useScrollendEvent&&C;return l&&n.addEventListener(`scrollend`,c,S),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},T=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},E=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},D=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:y,rangeExtractor:b,onChange:()=>{},measureElement:T,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=m(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=m(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(e,t,n,r,i,a)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a}),{key:!1}),this.getMeasurements=m(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a},o)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let s=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let c=this.measurementsCache.slice(0,s),l=Array(a).fill(void 0);for(let e=0;e<s;e++){let t=c[e];t&&(l[t.lane]=e)}for(let i=s;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,u;if(a!==void 0&&this.options.lanes>1){s=a;let e=l[s],r=e===void 0?void 0:c[e];u=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?c[i-1]:this.getFurthestMeasurement(c,i);u=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(i,s)}let d=o.get(e),f=typeof d==`number`?d:this.options.estimateSize(i),p=u+f;c[i]={index:i,start:u,size:f,end:p,key:e,lane:s},l[s]=i}return this.measurementsCache=c,c},{key:!1,debug:()=>this.options.debug}),this.calculateRange=m(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?k({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=m(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{let n=this.measurementsCache[e];if(!n)return;let r=t-(this.itemSizeCache.get(n.key)??n.size);r!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?n.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,t)),this.notify(!1))},this.getVirtualItems=m(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return h(t[O(0,t.length-1,e=>h(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t);this.scrollState={index:null,align:t,behavior:n,startedAt:this.now(),lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e;this.scrollState={index:null,align:`start`,behavior:t,startedAt:this.now(),lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=e[e.length-1]?.end??0;else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&g(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},O=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function k({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=O(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var A=typeof document<`u`?p.useLayoutEffect:p.useEffect;function j({useFlushSync:e=!0,...t}){let n=p.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,f.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=p.useState(()=>new D(r));return i.setOptions(r),A(()=>i._didMount(),[]),A(()=>i._willUpdate()),i}function M(e){return j({observeElementRect:x,observeElementOffset:w,scrollToFn:E,...e})}var N=t();function P({content:e,onContentChange:t,wordWrap:n}){let r=(0,p.useMemo)(()=>s(e),[e]),[f,m]=(0,p.useState)(()=>r.rows),[h,g]=(0,p.useState)([]),_=(0,p.useRef)(null),v=(0,p.useRef)(!1);(0,p.useEffect)(()=>{if(v.current){v.current=!1;return}m(r.rows)},[r.rows]);let y=r.headers,b=(0,p.useCallback)((e,n,r)=>{m(i=>{let a=i.map((t,n)=>n===e?[...t]:t);return a[e][n]=r,v.current=!0,t(o(y,a)),a})},[y,t]),x=l({data:f,columns:(0,p.useMemo)(()=>y.map((e,t)=>({id:`col-${t}`,header:e||`Column ${t+1}`,accessorFn:e=>e[t]??``,cell:({row:e,getValue:r})=>(0,N.jsx)(F,{value:r(),onSave:n=>b(e.index,t,n),wordWrap:n}),size:150,minSize:80})),[y,b,n]),state:{sorting:h},onSortingChange:g,getCoreRowModel:u(),getSortedRowModel:c(),enableColumnResizing:!0,columnResizeMode:`onChange`}),{rows:S}=x.getRowModel(),C=M({count:S.length,getScrollElement:()=>_.current,estimateSize:()=>32,overscan:20});return y.length===0?(0,N.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`Empty CSV file`}):(0,N.jsx)(`div`,{ref:_,className:`flex-1 overflow-auto`,children:(0,N.jsxs)(`table`,{className:`w-full text-xs font-mono border-collapse`,children:[(0,N.jsx)(`thead`,{className:`sticky top-0 bg-background z-10 border-b border-border block`,children:x.getHeaderGroups().map(e=>(0,N.jsx)(`tr`,{className:`flex w-full`,children:e.headers.map(e=>(0,N.jsxs)(`th`,{className:`relative text-left px-2 py-1.5 font-medium text-muted-foreground select-none cursor-pointer hover:bg-muted/50 border-r border-border last:border-r-0`,style:{width:e.getSize(),minWidth:e.getSize()},onClick:e.column.getToggleSortingHandler(),children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,N.jsx)(`span`,{className:`truncate`,children:d(e.column.columnDef.header,e.getContext())}),e.column.getIsSorted()===`asc`&&(0,N.jsx)(a,{className:`size-3 shrink-0`}),e.column.getIsSorted()===`desc`&&(0,N.jsx)(i,{className:`size-3 shrink-0`})]}),(0,N.jsx)(`div`,{onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler(),onClick:e=>e.stopPropagation(),className:`absolute right-0 top-0 h-full w-1 cursor-col-resize hover:bg-primary/50 active:bg-primary`})]},e.id))},e.id))}),(0,N.jsx)(`tbody`,{style:{height:C.getTotalSize(),position:`relative`,display:`block`},children:C.getVirtualItems().map(e=>{let t=S[e.index];return(0,N.jsx)(`tr`,{"data-index":e.index,ref:e=>C.measureElement(e),style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`,display:`flex`},children:t.getVisibleCells().map(e=>(0,N.jsx)(`td`,{className:`px-2 py-1 border-b border-border/50 border-r border-r-border/30 last:border-r-0 ${n?`whitespace-pre-wrap break-words`:`truncate`}`,style:{width:e.column.getSize(),minWidth:e.column.getSize()},children:d(e.column.columnDef.cell,e.getContext())},e.id))},t.id)})})]})})}function F({value:e,onSave:t,wordWrap:n}){let[r,i]=(0,p.useState)(!1),[a,o]=(0,p.useState)(e),s=(0,p.useRef)(null),c=(0,p.useCallback)(e=>{e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)},[]);return(0,p.useEffect)(()=>{r&&s.current&&(s.current.focus(),c(s.current))},[r,c]),r?(0,N.jsx)(`textarea`,{ref:s,className:`w-full bg-transparent outline-none border border-primary/50 rounded text-xs font-mono resize-none p-0.5`,style:{minHeight:a.includes(`
|
|
5
5
|
`)?48:20},rows:1,value:a,onChange:e=>{o(e.target.value),c(e.target)},onBlur:()=>{i(!1),a!==e&&t(a)},onKeyDown:n=>{n.key===`Enter`&&!n.shiftKey?(n.preventDefault(),i(!1),a!==e&&t(a)):n.key===`Escape`&&(i(!1),o(e))}}):(0,N.jsx)(`span`,{className:`block cursor-text ${n?`whitespace-pre-wrap break-words`:`truncate`}`,onClick:()=>{o(e),i(!0)},children:e||`\xA0`})}export{P as CsvPreview};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{x as t}from"./vendor-markdown-0Mxgxy0L.js";import{Y as n}from"./vendor-ui-UXCWAcmi.js";import{B as r,G as i,R as a,c as o,o as s,s as c}from"./data-grid-types-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{x as t}from"./vendor-markdown-0Mxgxy0L.js";import{Y as n}from"./vendor-ui-UXCWAcmi.js";import{B as r,G as i,R as a,c as o,o as s,s as c}from"./data-grid-types-C29KDkZJ.js";import{t as l}from"./dist-PPUhQONj.js";var u=e(n(),1),d=e(t(),1),f=()=>e=>e.targetX,p=()=>e=>e.targetY,m=()=>e=>e.targetWidth,h=()=>e=>e.targetHeight,g=()=>e=>e.targetY+10,_=()=>e=>Math.max(0,(e.targetHeight-28)/2),v=l(`div`)({name:`DataGridOverlayEditorStyle`,class:`gdg-d19meir1`,propsAsIs:!1,vars:{"d19meir1-0":[p(),`px`],"d19meir1-1":[f(),`px`],"d19meir1-2":[m(),`px`],"d19meir1-3":[h(),`px`],"d19meir1-4":[g(),`px`],"d19meir1-5":[_(),`px`]}});function y(){let[e,t]=d.useState();return[e??void 0,t]}function b(){let[e,t]=y(),[n,r]=d.useState(0),[i,a]=d.useState(!0);return d.useLayoutEffect(()=>{if(e===void 0||!(`IntersectionObserver`in window))return;let t=new IntersectionObserver(e=>{e.length!==0&&a(e[0].isIntersecting)},{threshold:1});return t.observe(e),()=>t.disconnect()},[e]),d.useEffect(()=>{if(i||e===void 0)return;let t,n=()=>{let{right:i}=e.getBoundingClientRect();r(e=>Math.min(e+window.innerWidth-i-10,0)),t=requestAnimationFrame(n)};return t=requestAnimationFrame(n),()=>{t!==void 0&&cancelAnimationFrame(t)}},[e,i]),{ref:t,style:d.useMemo(()=>({transform:`translateX(${n}px)`}),[n])}}var x=e=>{let{target:t,content:n,onFinishEditing:l,forceEditMode:f,initialValue:p,imageEditorOverride:m,markdownDivCreateNode:h,highlight:g,className:_,theme:y,id:x,cell:S,bloom:C,validateCell:w,getCellRenderer:T,provideEditor:E,isOutsideClick:D}=e,[O,k]=d.useState(f?n:void 0),A=d.useRef(O??n);A.current=O??n;let[j,M]=d.useState(()=>w===void 0?!0:!(s(n)&&w?.(S,n,A.current)===!1)),N=d.useCallback((e,t)=>{l(j?e:void 0,t)},[j,l]),P=d.useCallback(e=>{if(w!==void 0&&e!==void 0&&s(e)){let t=w(S,e,A.current);t===!1?M(!1):(typeof t==`object`&&(e=t),M(!0))}k(e)},[S,w]),F=d.useRef(!1),I=d.useRef(void 0),L=d.useCallback(()=>{N(O,[0,0]),F.current=!0},[O,N]),R=d.useCallback((e,t)=>{N(e,t??I.current??[0,0]),F.current=!0},[N]),z=d.useCallback(async e=>{let t=!1;e.key===`Escape`?(e.stopPropagation(),e.preventDefault(),I.current=[0,0]):e.key===`Enter`&&!e.shiftKey?(e.stopPropagation(),e.preventDefault(),I.current=[0,1],t=!0):e.key===`Tab`&&(e.stopPropagation(),e.preventDefault(),I.current=[e.shiftKey?-1:1,0],t=!0),window.setTimeout(()=>{!F.current&&I.current!==void 0&&(N(t?O:void 0,I.current),F.current=!0)},0)},[N,O]),B=O??n,[V,H]=d.useMemo(()=>{if(c(n))return[];let e=E?.(n);return e===void 0?[T(n)?.provideEditor?.(n),!1]:[e,!1]},[n,T,E]),{ref:U,style:W}=b(),G=!0,K,q=!0,J;if(V!==void 0){G=V.disablePadding!==!0,q=V.disableStyling!==!0;let e=o(V);e&&(J=V.styleOverride);let n=e?V.editor:V;K=d.createElement(n,{isHighlighted:g,onChange:P,value:B,initialValue:p,onFinishedEditing:R,validatedSelection:s(B)?B.selectionRange:void 0,forceEditMode:f,target:t,imageEditorOverride:m,markdownDivCreateNode:h,isValid:j,theme:y})}J={...J,...W};let Y=document.getElementById(`portal`);if(Y===null)return console.error('Cannot open Data Grid overlay editor, because portal not found. Please add `<div id="portal" />` as the last child of your `<body>`.'),null;let X=q?`gdg-style`:`gdg-unstyle`;j||(X+=` gdg-invalid`),G&&(X+=` gdg-pad`);let Z=C?.[0]??1,Q=C?.[1]??1;return(0,u.createPortal)(d.createElement(a.Provider,{value:y},d.createElement(i,{style:r(y),className:_,onClickOutside:L,isOutsideClick:D},d.createElement(v,{ref:U,id:x,className:X,style:J,as:H===!0?`label`:void 0,targetX:t.x-Z,targetY:t.y-Q,targetWidth:t.width+Z*2,targetHeight:t.height+Q*2},d.createElement(`div`,{className:`gdg-clip-region`,onKeyDown:z},K)))),Y)};export{x as default};
|
|
@@ -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-ha8hjunf.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"./tab-store-DzftzxTL.js";import{$ as c,et as l}from"./index-CP6EIXkh.js";import"./data-grid-types-C29KDkZJ.js";import"./use-monaco-theme-qx6SfVRk.js";import{t as u}from"./sql-query-editor-CNwOnFgF.js";var d=e(n(),1);function f(e,t,n,r){return`ppm-db-${e}-${n}.${t}-p${r}`}function p(e,t,n,r){try{let i=sessionStorage.getItem(f(e,t,n,r));return i?JSON.parse(i):null}catch{return null}}function m(e,t,n,r,i,a){try{sessionStorage.setItem(f(e,t,n,r),JSON.stringify({data:i,cols:a}))}catch{}}function h(e){let t=`/api/db/connections/${e}`,[n,r]=(0,d.useState)(null),[i,a]=(0,d.useState)(`public`),[o,c]=(0,d.useState)(null),[l,u]=(0,d.useState)([]),[f,h]=(0,d.useState)(!1),[g,_]=(0,d.useState)(null),[v,y]=(0,d.useState)(1),[b,x]=(0,d.useState)(null),[S,C]=(0,d.useState)(null),[w,T]=(0,d.useState)(!1),[E,D]=(0,d.useState)(null),[O,k]=(0,d.useState)(`ASC`),A=(0,d.useCallback)(async(r,a,o,l,d)=>{let f=r??n,p=a??i;if(!f)return;h(!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=${p}&page=${o??v}&limit=100${n}`),s.get(`${t}/schema?table=${encodeURIComponent(f)}&schema=${p}`)]);c(r),u(i),m(e,f,p,o??v,r,i)}catch(e){_(e.message)}finally{h(!1)}},[t,e,n,i,v,E,O]),j=(0,d.useCallback)((t,n=`public`)=>{r(t),a(n),y(1),x(null);let i=p(e,t,n,1);i?(c(i.data),u(i.cols),h(!1),A(t,n,1)):A(t,n,1)},[e,A]),M=(0,d.useCallback)(e=>{y(e),A(void 0,void 0,e)},[A]),N=(0,d.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,d.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,d.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:f,error:g,page:v,setPage:M,orderBy:E,orderDir:O,toggleSort:(0,d.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,d.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,d.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,d.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,d.useCallback)(async e=>{h(!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{h(!1)}},[t])}}var g=t();function _(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 v({metadata:e}){let t=e?.connectionId,n=e?.connectionName,c=e?.tableName,f=e?.schemaName??`public`,p=e?.initialSql,m=h(t),[v,y]=(0,d.useState)([]),[x,S]=(0,d.useState)(180),C=(0,d.useRef)(null),[w,T]=(0,d.useState)({}),E=(0,d.useMemo)(()=>{if(p&&!m.selectedTable)return p;if(m.selectedTable){let e=`SELECT * FROM "${m.selectedTable}"`,t=Object.entries(w).filter(([,e])=>e.trim()).map(([e,t])=>`"${e}" ILIKE '%${t.replace(/'/g,`''`)}%'`);t.length>0&&(e+=` WHERE ${t.join(` AND `)}`),m.orderBy&&(e+=` ORDER BY "${m.orderBy}" ${m.orderDir}`);let n=(m.page-1)*100;return e+=` LIMIT 100`,n>0&&(e+=` OFFSET ${n}`),e}return`SELECT * FROM `},[p,m.selectedTable,m.orderBy,m.orderDir,m.page,w]),D=(0,d.useCallback)(e=>{T(e)},[]),O=(0,d.useRef)(void 0);(0,d.useEffect)(()=>{if(!(!m.selectedTable||Object.keys(w).length===0))return clearTimeout(O.current),O.current=setTimeout(()=>{m.queryAsTable(E)},500),()=>clearTimeout(O.current)},[w]);let k=(0,d.useCallback)(e=>{e.preventDefault();let t=e.clientY,n=x,r=e=>{let r=e.clientY-t;S(Math.max(80,Math.min(n+r,(C.current?.clientHeight??600)-100)))},i=()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)},[x]);(0,d.useEffect)(()=>{s.get(`/api/db/connections/${t}/tables?cached=1`).then(e=>y(e.map(e=>({name:e.name,schema:e.schema})))).catch(()=>{})},[t]);let A=(0,d.useMemo)(()=>{if(v.length!==0)return{tables:v,getColumns:async(e,n)=>await s.get(`/api/db/connections/${t}/schema?table=${encodeURIComponent(e)}${n?`&schema=${encodeURIComponent(n)}`:``}`)}},[t,v]),j=(0,d.useRef)(!1);(0,d.useEffect)(()=>{j.current||(j.current=!0,p?m.executeQuery(p):c&&m.selectTable(c,f))},[c,f,p]);let[M,N]=(0,d.useState)(!!p),P=(0,d.useCallback)(e=>{let t=e.trim();if(m.selectedTable&&RegExp(`^SELECT\\s+\\*\\s+FROM\\s+"?${m.selectedTable.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}"?\\b`,`i`).test(t)){T(_(t)),m.queryAsTable(t);return}N(!0),m.executeQuery(e)},[m.executeQuery,m.queryAsTable,m.selectedTable]),F=(0,d.useCallback)(e=>{N(!1),m.toggleSort(e)},[m.toggleSort]),I=(0,d.useCallback)(()=>{N(!1),m.clearSort()},[m.clearSort]),L=(0,d.useCallback)(e=>{N(!1),m.setPage(e)},[m.setPage]),R=m.queryResult,z=M&&!!(R||m.queryError),B=m.selectedTable&&!z;return(0,g.jsx)(`div`,{ref:C,className:`flex h-full w-full overflow-hidden`,children:(0,g.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b border-border bg-background shrink-0`,children:[(0,g.jsx)(r,{className:`size-3.5 text-muted-foreground`}),(0,g.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:n??`Database`}),m.selectedTable&&(0,g.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`/ `,m.selectedTable]}),(0,g.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[m.tableData&&(0,g.jsx)(i,{columns:m.tableData.columns,rows:m.tableData.rows,filename:n?`${n}-${m.selectedTable??`data`}`:m.selectedTable??`data`,exportAllUrl:m.selectedTable?`/api/db/connections/${t}/export?table=${encodeURIComponent(m.selectedTable)}&schema=${m.selectedSchema}`:void 0}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>m.refreshData(),title:`Reload data`,className:`p-1 rounded text-muted-foreground hover:text-foreground transition-colors`,children:(0,g.jsx)(o,{className:`size-3 ${m.loading?`animate-spin`:``}`})})]})]}),(0,g.jsx)(`div`,{className:`shrink-0 border-b border-border`,style:{height:x},children:(0,g.jsx)(u,{onExecute:P,loading:m.queryLoading,defaultValue:E,schemaInfo:A,cacheKey:t?String(t):void 0})}),(0,g.jsx)(`div`,{onMouseDown:k,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,g.jsx)(l,{className:`size-3 text-muted-foreground/50`})}),(0,g.jsxs)(`div`,{className:`flex-1 overflow-hidden`,children:[B&&m.tableData&&(0,g.jsx)(a,{columns:m.tableData.columns,rows:m.tableData.rows,total:m.tableData.total,limit:m.tableData.limit,schema:m.schema,loading:m.loading,page:m.page,onPageChange:L,onCellUpdate:m.updateCell,onRowDelete:m.deleteRow,orderBy:m.orderBy,orderDir:m.orderDir,onToggleSort:F,onClearSort:I,onBulkDelete:m.bulkDelete,onInsertRow:m.insertRow,connectionId:t,selectedTable:m.selectedTable,selectedSchema:m.selectedSchema,connectionName:n,columnFilters:w,onColumnFilter:D}),z&&(0,g.jsx)(b,{result:R,error:m.queryError,loading:m.queryLoading,schema:m.schema,connectionName:n})]})]})})}var y=()=>{};function b({result:e,error:t,loading:n,schema:r,connectionName:i}){let o=(0,d.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,d.useMemo)(()=>r?.length?r:(e?.columns??[]).map(e=>({name:e,type:`text`,nullable:!0,pk:!1,defaultValue:null})),[r,e?.columns]);return(0,g.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden text-xs`,children:[t&&(0,g.jsx)(`div`,{className:`px-3 py-2 text-destructive bg-destructive/5 shrink-0`,children:t}),e?.changeType===`modify`&&(0,g.jsxs)(`div`,{className:`px-3 py-2 text-green-500 shrink-0`,children:[e.rowsAffected,` row(s) affected`,e.executionTimeMs!=null&&(0,g.jsxs)(`span`,{className:`text-muted-foreground ml-2`,children:[e.executionTimeMs,`ms`]})]}),o&&(0,g.jsxs)(`div`,{className:`flex-1 overflow-hidden`,children:[(0,g.jsx)(a,{columns:o.columns,rows:o.rows,total:o.total,limit:o.limit,schema:s,loading:!!n,page:1,onPageChange:y,onCellUpdate:y,orderBy:null,orderDir:`ASC`,onToggleSort:y,connectionName:i}),e?.executionTimeMs!=null&&(0,g.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,g.jsxs)(`div`,{className:`px-3 py-2 text-muted-foreground shrink-0`,children:[`No results`,e.executionTimeMs!=null&&(0,g.jsxs)(`span`,{className:`ml-2 text-muted-foreground/60`,children:[e.executionTimeMs,`ms`]})]}),!e&&!t&&(0,g.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:n?(0,g.jsx)(c,{className:`size-4 animate-spin`}):`Run a query to see results`})]})}export{v 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,_ as c,ot as l}from"./index-CP6EIXkh.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(c(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)(s,{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)(s,{className:`size-5 animate-spin text-muted-foreground`})}):(0,p.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,p.jsx)(s,{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,2 +1,2 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import{$ as r,$t as i,A as a,At as o,B as s,Bt as c,C as l,Ct as u,D as d,Dt as f,Et as p,F as m,Ft as h,G as g,Gt as _,H as ee,Ht as v,I as te,It as ne,J as y,Jt as b,K as x,Kt as re,L as S,Lt as C,Mt as w,Nt as T,Ot as E,Pt as D,Q as ie,Qt as O,R as ae,Rt as k,S as oe,St as se,T as ce,Tt as le,U as ue,Ut as de,V as A,Vt as fe,W as pe,Wt as me,X as he,Xt as ge,Y as _e,Yt as ve,Z as ye,Zt as be,_ as xe,_t as Se,a as Ce,an as we,at as Te,b as Ee,bt as De,c as Oe,ct as ke,d as Ae,dt as je,en as Me,et as Ne,ft as Pe,gt as Fe,h as Ie,ht as Le,in as Re,it as ze,jt as Be,kt as Ve,lt as He,m as Ue,mt as We,n as Ge,nn as Ke,nt as qe,ot as Je,p as Ye,pt as Xe,q as Ze,qt as Qe,r as $e,rn as j,rt as et,s as tt,st as nt,t as rt,tn as M,tt as it,ut as at,v as ot,vt as st,w as ct,wt as lt,x as ut,xt as dt,yt as ft,z as N,zt as P}from"./dist-DVk8T0R5.js";function pt(){return pt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},pt.apply(null,arguments)}function mt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var F=e(n()),ht=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=bt(e.state,n.from);return r.line?_t(e):r.block?yt(e):!1};function gt(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var _t=gt(wt,0),vt=gt(Ct,0),yt=gt((e,t)=>Ct(e,t,St(t)),0);function bt(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var I=50;function xt(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-I,r),o=e.sliceDoc(i,i+I),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=2*I?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+I),d=e.sliceDoc(i-I,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:/\s/.test(u.charAt(f+t.length))?1:0},close:{pos:i-p-n.length,margin:/\s/.test(d.charAt(m-1))?1:0}}:null}function St(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function Ct(e,t,n=t.selection.ranges){let r=n.map(e=>bt(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>xt(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function wt(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=bt(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}else if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var Tt=Be.define(),Et=Be.define(),Dt=P.define(),Ot=P.define({combine(e){return M(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),kt=ge.define({create(){return z.empty},update(e,t){let n=t.state.facet(Ot),r=t.annotation(Tt);if(r){let i=L.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?It(o,o.length,n.minDepth,i):Vt(o,t.startState.selection),new z(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(Et);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(O.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=L.fromTransaction(t),o=t.annotation(O.time),s=t.annotation(O.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new z(e.done.map(L.fromJSON),e.undone.map(L.fromJSON))}});function At(e={}){return[kt,Ot.of(e),A.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?Mt:e.inputType==`historyRedo`?Nt:null;return n?(e.preventDefault(),n(t)):!1}})]}function jt(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(kt,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var Mt=jt(0,!1),Nt=jt(1,!1),Pt=jt(0,!0),Ft=jt(1,!0),L=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&D.fromJSON(t.changes),[],t.mapped&&T.fromJSON(t.mapped),t.startSelection&&C.fromJSON(t.startSelection),t.selectionsAfter.map(C.fromJSON))}static fromTransaction(t,n){let r=R;for(let e of t.startState.facet(Dt)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,R)}static selection(t){return new e(void 0,R,void 0,void 0,t)}};function It(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function Lt(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function Rt(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function zt(e,t){return e.length?t.length?e.concat(t):e:t}var R=[],Bt=200;function Vt(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Bt));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),It(e,e.length-1,1e9,n.setSelAfter(r)))}else return[L.selection([t])]}function Ht(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function Ut(e,t){if(!e.length)return e;let n=e.length,r=R;for(;n;){let i=Wt(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[L.selection(r)]:R}function Wt(e,t,n){let r=zt(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):R,n);if(!e.changes)return L.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new L(i,b.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var Gt=/^(input\.type|delete)($|\.)/,z=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||Gt.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,Lt(s.changes,t.changes))||r==`input.type.compose`)?It(o,o.length-1,i.minDepth,new L(t.changes.compose(s.changes),zt(b.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,R)):It(o,o.length,i.minDepth,t),new e(o,R,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:R;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&Rt(a[a.length-1],t)?this:new e(Vt(this.done,t),this.undone,n,r)}addMapping(t){return new e(Ut(this.done,t),Ut(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:Tt.of({side:e,rest:Ht(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?R:r.slice(0,r.length-1);return i.mapped&&(n=Ut(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:Tt.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};z.empty=new z(R,R);var Kt=[{key:`Mod-z`,run:Mt,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:Nt,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:Nt,preventDefault:!0},{key:`Mod-u`,run:Pt,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:Ft,preventDefault:!0}];function B(e,t){return C.create(e.ranges.map(t),e.mainIndex)}function V(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function H({state:e,dispatch:t},n){let r=B(e.selection,n);return r.eq(e.selection,!0)?!1:(t(V(e,r)),!0)}function qt(e,t){return C.cursor(t?e.to:e.from)}function Jt(e,t){return H(e,n=>n.empty?e.moveByChar(n,t):qt(n,t))}function U(e){return e.textDirectionAt(e.state.selection.main.head)==s.LTR}var Yt=e=>Jt(e,!U(e)),Xt=e=>Jt(e,U(e));function Zt(e,t){return H(e,n=>n.empty?e.moveByGroup(n,t):qt(n,t))}var Qt=e=>Zt(e,!U(e)),$t=e=>Zt(e,U(e));typeof Intl<`u`&&Intl.Segmenter&&new Intl.Segmenter(void 0,{granularity:`word`});function en(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function tn(e,t,n){let r=ce(e).resolveInner(t.head),i=n?a.closedBy:a.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;en(e,t,i)?r=t:a=n?t.to:t.from}let o=r.type.prop(i),s,c;return c=o&&(s=n?l(e,r.from,1):l(e,r.to,-1))&&s.matched?n?s.end.to:s.end.from:n?r.to:r.from,C.cursor(c,n?-1:1)}var nn=e=>H(e,t=>tn(e.state,t,!U(e))),rn=e=>H(e,t=>tn(e.state,t,U(e)));function an(e,t){return H(e,n=>{if(!n.empty)return qt(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var on=e=>an(e,!1),sn=e=>an(e,!0);function cn(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(A.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function ln(e,t){let n=cn(e),{state:r}=e,i=B(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):qt(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=A.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(V(r,i),{effects:a}),!0}var un=e=>ln(e,!1),dn=e=>ln(e,!0);function W(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=C.cursor(r.from+n))}return i}var fn=e=>H(e,t=>W(e,t,!0)),pn=e=>H(e,t=>W(e,t,!1)),mn=e=>H(e,t=>W(e,t,!U(e))),hn=e=>H(e,t=>W(e,t,U(e))),gn=e=>H(e,t=>C.cursor(e.lineBlockAt(t.head).from,1)),_n=e=>H(e,t=>C.cursor(e.lineBlockAt(t.head).to,-1));function vn(e,t,n){let r=!1,i=B(e.selection,t=>{let i=l(e,t.head,-1)||l(e,t.head,1)||t.head>0&&l(e,t.head-1,1)||t.head<e.doc.length&&l(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?C.range(t.anchor,a):C.cursor(a)});return r?(t(V(e,i)),!0):!1}var yn=({state:e,dispatch:t})=>vn(e,t,!1);function G(e,t){let n=B(e.state.selection,e=>{let n=t(e);return C.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(V(e.state,n)),!0)}function bn(e,t){return G(e,n=>e.moveByChar(n,t))}var xn=e=>bn(e,!U(e)),Sn=e=>bn(e,U(e));function Cn(e,t){return G(e,n=>e.moveByGroup(n,t))}var wn=e=>Cn(e,!U(e)),Tn=e=>Cn(e,U(e)),En=e=>G(e,t=>tn(e.state,t,!U(e))),Dn=e=>G(e,t=>tn(e.state,t,U(e)));function On(e,t){return G(e,n=>e.moveVertically(n,t))}var kn=e=>On(e,!1),An=e=>On(e,!0);function jn(e,t){return G(e,n=>e.moveVertically(n,t,cn(e).height))}var Mn=e=>jn(e,!1),Nn=e=>jn(e,!0),Pn=e=>G(e,t=>W(e,t,!0)),Fn=e=>G(e,t=>W(e,t,!1)),In=e=>G(e,t=>W(e,t,!U(e))),Ln=e=>G(e,t=>W(e,t,U(e))),Rn=e=>G(e,t=>C.cursor(e.lineBlockAt(t.head).from)),zn=e=>G(e,t=>C.cursor(e.lineBlockAt(t.head).to)),Bn=({state:e,dispatch:t})=>(t(V(e,{anchor:0})),!0),Vn=({state:e,dispatch:t})=>(t(V(e,{anchor:e.doc.length})),!0),Hn=({state:e,dispatch:t})=>(t(V(e,{anchor:e.selection.main.anchor,head:0})),!0),Un=({state:e,dispatch:t})=>(t(V(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Wn=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),Gn=({state:e,dispatch:t})=>{let n=ur(e).map(({from:t,to:n})=>C.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:C.create(n),userEvent:`select`})),!0},Kn=({state:e,dispatch:t})=>{let n=B(e.selection,t=>{let n=ce(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return C.range(n.to,n.from)}return t});return n.eq(e.selection)?!1:(t(V(e,n)),!0)};function qn(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}else if(r.head==n.head)break;else n=r}}return i.length==r.ranges.length?!1:(e.dispatch(V(n,C.create(i,i.length-1))),!0)}var Jn=e=>qn(e,!1),Yn=e=>qn(e,!0),Xn=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=C.create([n.main]):n.main.empty||(r=C.create([C.cursor(n.main.head)])),r?(t(V(e,r)),!0):!1};function Zn(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=Qn(e,o,!1)):o>i&&(n=`delete.forward`,o=Qn(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=Qn(e,i,!1),a=Qn(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:C.cursor(i,i<r.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?A.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function Qn(e,t,n){if(e instanceof A)for(let r of e.state.facet(A.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var $n=(e,t,n)=>Zn(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=Ke(s,a.tabSize)%xe(a)||xe(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=j(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=j(o.text,c-o.from,!1,!1)+o.from);return c}),er=e=>$n(e,!1,!0),tr=e=>$n(e,!0,!1),nr=(e,t)=>Zn(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=j(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),rr=e=>nr(e,!1),ir=e=>nr(e,!0),ar=e=>Zn(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),or=e=>Zn(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),sr=e=>Zn(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),cr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:be.of([``,``])},range:C.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},lr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:j(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:j(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:C.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function ur(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function dr(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of ur(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(C.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(C.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:C.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var fr=({state:e,dispatch:t})=>dr(e,t,!1),pr=({state:e,dispatch:t})=>dr(e,t,!0);function mr(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of ur(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var hr=({state:e,dispatch:t})=>mr(e,t,!1),gr=({state:e,dispatch:t})=>mr(e,t,!0),_r=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(ur(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=B(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function vr(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=ce(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),o;return r&&i&&r.to<=t&&i.from>=t&&(o=r.type.prop(a.closedBy))&&o.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var yr=xr(!1),br=xr(!0);function xr(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&vr(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new Oe(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=ot(s,r);for(c??=Ke(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,ut(t,c)];return o&&l.push(ut(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:be.of(l)},range:C.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function Sr(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:C.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var Cr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new Oe(e,{overrideIndentation:e=>n[e]??-1}),i=Sr(e,(t,i,a)=>{let o=ot(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=ut(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},wr=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Sr(e,(t,n)=>{n.push({from:t.from,insert:e.facet(oe)})}),{userEvent:`input.indent`})),!0),Tr=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Sr(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=Ke(r,e.tabSize),a=0,o=ut(e,Math.max(0,i-xe(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),Er=e=>(e.setTabFocusMode(),!0),Dr=[{key:`Ctrl-b`,run:Yt,shift:xn,preventDefault:!0},{key:`Ctrl-f`,run:Xt,shift:Sn},{key:`Ctrl-p`,run:on,shift:kn},{key:`Ctrl-n`,run:sn,shift:An},{key:`Ctrl-a`,run:gn,shift:Rn},{key:`Ctrl-e`,run:_n,shift:zn},{key:`Ctrl-d`,run:tr},{key:`Ctrl-h`,run:er},{key:`Ctrl-k`,run:ar},{key:`Ctrl-Alt-h`,run:rr},{key:`Ctrl-o`,run:cr},{key:`Ctrl-t`,run:lr},{key:`Ctrl-v`,run:dn}],Or=[{key:`ArrowLeft`,run:Yt,shift:xn,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:Qt,shift:wn,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:mn,shift:In,preventDefault:!0},{key:`ArrowRight`,run:Xt,shift:Sn,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:$t,shift:Tn,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:hn,shift:Ln,preventDefault:!0},{key:`ArrowUp`,run:on,shift:kn,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:Bn,shift:Hn},{mac:`Ctrl-ArrowUp`,run:un,shift:Mn},{key:`ArrowDown`,run:sn,shift:An,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:Vn,shift:Un},{mac:`Ctrl-ArrowDown`,run:dn,shift:Nn},{key:`PageUp`,run:un,shift:Mn},{key:`PageDown`,run:dn,shift:Nn},{key:`Home`,run:pn,shift:Fn,preventDefault:!0},{key:`Mod-Home`,run:Bn,shift:Hn},{key:`End`,run:fn,shift:Pn,preventDefault:!0},{key:`Mod-End`,run:Vn,shift:Un},{key:`Enter`,run:yr,shift:yr},{key:`Mod-a`,run:Wn},{key:`Backspace`,run:er,shift:er,preventDefault:!0},{key:`Delete`,run:tr,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:rr,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:ir,preventDefault:!0},{mac:`Mod-Backspace`,run:or,preventDefault:!0},{mac:`Mod-Delete`,run:sr,preventDefault:!0}].concat(Dr.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),kr=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:nn,shift:En},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:rn,shift:Dn},{key:`Alt-ArrowUp`,run:fr},{key:`Shift-Alt-ArrowUp`,run:hr},{key:`Alt-ArrowDown`,run:pr},{key:`Shift-Alt-ArrowDown`,run:gr},{key:`Mod-Alt-ArrowUp`,run:Jn},{key:`Mod-Alt-ArrowDown`,run:Yn},{key:`Escape`,run:Xn},{key:`Mod-Enter`,run:br},{key:`Alt-l`,mac:`Ctrl-l`,run:Gn},{key:`Mod-i`,run:Kn,preventDefault:!0},{key:`Mod-[`,run:Tr},{key:`Mod-]`,run:wr},{key:`Mod-Alt-\\`,run:Cr},{key:`Shift-Mod-k`,run:_r},{key:`Shift-Mod-\\`,run:yn},{key:`Mod-/`,run:ht},{key:`Alt-A`,run:vt},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:Er}].concat(Or),Ar={key:`Tab`,run:wr,shift:Tr},jr=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,K=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(jr(e)):jr,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return i(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=we(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=Me(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let a=r.charCodeAt(e),o=this.match(a,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(o)return this.value=o,this;break}i==n&&e<t.length&&t.charCodeAt(e)==a&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],a=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,a=!0)),a||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol<`u`&&(K.prototype[Symbol.iterator]=function(){return this});var Mr={from:-1,to:-1,match:/.*/.exec(``)},Nr=`gm`+(/x/.unicode==null?``:`u`),Pr=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=Mr,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Lr(e,t,n,r,i);this.re=new RegExp(t,Nr+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter(),this.curLineStart=e.lineAt(r).from,this.matchPos=zr(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=zr(this.text,r+(n==r?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},Fr=new WeakMap,Ir=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=Fr.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return Fr.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),Fr.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},Lr=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=Mr,this.matchPos=zr(e,r),this.re=new RegExp(t,Nr+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=Ir.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=zr(this.text,n+(e==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Ir.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(Pr.prototype[Symbol.iterator]=Lr.prototype[Symbol.iterator]=function(){return this});function Rr(e){try{return new RegExp(e,Nr),!0}catch{return!1}}function zr(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var Br=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=p(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),p=C.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,A.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},Vr={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Hr=P.define({combine(e){return M(e,Vr,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Ur(e){let t=[Yr,Jr];return e&&t.push(Hr.of(e)),t}var Wr=N.mark({class:`cm-selectionMatch`}),Gr=N.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function Kr(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=h.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=h.Word)}function qr(e,t,n,r){return e(t.sliceDoc(n,n+1))==h.Word&&e(t.sliceDoc(r-1,r))==h.Word}var Jr=g.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(Hr),{state:n}=e,r=n.selection;if(r.ranges.length>1)return N.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return N.none;let e=n.wordAt(i.head);if(!e)return N.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return N.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(Kr(o,n,i.from,i.to)&&qr(o,n,i.from,i.to)))return N.none}else if(a=n.sliceDoc(i.from,i.to),!a)return N.none}let s=[];for(let r of e.visibleRanges){let e=new K(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||Kr(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(Gr.range(r,a)):(r>=i.to||a<=i.from)&&s.push(Wr.range(r,a)),s.length>t.maxMatches))return N.none}}return N.set(s)}},{decorations:e=>e.decorations}),Yr=A.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),Xr=({state:e,dispatch:t})=>{let{selection:n}=e,r=C.create(n.ranges.map(t=>e.wordAt(t.head)||C.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function Zr(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new K(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new K(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var Qr=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return Xr({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=Zr(e,r);return i?(t(e.update({selection:e.selection.addRange(C.range(i.from,i.to),!1),effects:A.scrollIntoView(i.to)})),!0):!1},q=P.define({combine(e){return M(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new ki(e),scrollToMatch:e=>A.scrollIntoView(e)})}}),$r=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||Rr(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
|
|
1
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import{$ as r,$t as i,A as a,At as o,B as s,Bt as c,C as l,Ct as u,D as d,Dt as f,Et as p,F as m,Ft as h,G as g,Gt as _,H as ee,Ht as v,I as te,It as ne,J as y,Jt as b,K as x,Kt as re,L as S,Lt as C,Mt as w,Nt as T,Ot as E,Pt as D,Q as ie,Qt as O,R as ae,Rt as k,S as oe,St as se,T as ce,Tt as le,U as ue,Ut as de,V as A,Vt as fe,W as pe,Wt as me,X as he,Xt as ge,Y as _e,Yt as ve,Z as ye,Zt as be,_ as xe,_t as Se,a as Ce,an as we,at as Te,b as Ee,bt as De,c as Oe,ct as ke,d as Ae,dt as je,en as Me,et as Ne,ft as Pe,gt as Fe,h as Ie,ht as Le,in as Re,it as ze,jt as Be,kt as Ve,lt as He,m as Ue,mt as We,n as Ge,nn as Ke,nt as qe,ot as Je,p as Ye,pt as Xe,q as Ze,qt as Qe,r as $e,rn as j,rt as et,s as tt,st as nt,t as rt,tn as M,tt as it,ut as at,v as ot,vt as st,w as ct,wt as lt,x as ut,xt as dt,yt as ft,z as N,zt as P}from"./dist-DeY41KFi.js";function pt(){return pt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},pt.apply(null,arguments)}function mt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var F=e(n()),ht=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=bt(e.state,n.from);return r.line?_t(e):r.block?yt(e):!1};function gt(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var _t=gt(wt,0),vt=gt(Ct,0),yt=gt((e,t)=>Ct(e,t,St(t)),0);function bt(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var I=50;function xt(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-I,r),o=e.sliceDoc(i,i+I),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=2*I?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+I),d=e.sliceDoc(i-I,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:/\s/.test(u.charAt(f+t.length))?1:0},close:{pos:i-p-n.length,margin:/\s/.test(d.charAt(m-1))?1:0}}:null}function St(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function Ct(e,t,n=t.selection.ranges){let r=n.map(e=>bt(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>xt(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function wt(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=bt(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}else if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var Tt=Be.define(),Et=Be.define(),Dt=P.define(),Ot=P.define({combine(e){return M(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),kt=ge.define({create(){return z.empty},update(e,t){let n=t.state.facet(Ot),r=t.annotation(Tt);if(r){let i=L.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?It(o,o.length,n.minDepth,i):Vt(o,t.startState.selection),new z(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(Et);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(O.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=L.fromTransaction(t),o=t.annotation(O.time),s=t.annotation(O.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new z(e.done.map(L.fromJSON),e.undone.map(L.fromJSON))}});function At(e={}){return[kt,Ot.of(e),A.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?Mt:e.inputType==`historyRedo`?Nt:null;return n?(e.preventDefault(),n(t)):!1}})]}function jt(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(kt,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var Mt=jt(0,!1),Nt=jt(1,!1),Pt=jt(0,!0),Ft=jt(1,!0),L=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&D.fromJSON(t.changes),[],t.mapped&&T.fromJSON(t.mapped),t.startSelection&&C.fromJSON(t.startSelection),t.selectionsAfter.map(C.fromJSON))}static fromTransaction(t,n){let r=R;for(let e of t.startState.facet(Dt)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,R)}static selection(t){return new e(void 0,R,void 0,void 0,t)}};function It(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function Lt(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function Rt(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function zt(e,t){return e.length?t.length?e.concat(t):e:t}var R=[],Bt=200;function Vt(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Bt));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),It(e,e.length-1,1e9,n.setSelAfter(r)))}else return[L.selection([t])]}function Ht(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function Ut(e,t){if(!e.length)return e;let n=e.length,r=R;for(;n;){let i=Wt(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[L.selection(r)]:R}function Wt(e,t,n){let r=zt(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):R,n);if(!e.changes)return L.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new L(i,b.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var Gt=/^(input\.type|delete)($|\.)/,z=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||Gt.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,Lt(s.changes,t.changes))||r==`input.type.compose`)?It(o,o.length-1,i.minDepth,new L(t.changes.compose(s.changes),zt(b.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,R)):It(o,o.length,i.minDepth,t),new e(o,R,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:R;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&Rt(a[a.length-1],t)?this:new e(Vt(this.done,t),this.undone,n,r)}addMapping(t){return new e(Ut(this.done,t),Ut(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:Tt.of({side:e,rest:Ht(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?R:r.slice(0,r.length-1);return i.mapped&&(n=Ut(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:Tt.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};z.empty=new z(R,R);var Kt=[{key:`Mod-z`,run:Mt,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:Nt,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:Nt,preventDefault:!0},{key:`Mod-u`,run:Pt,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:Ft,preventDefault:!0}];function B(e,t){return C.create(e.ranges.map(t),e.mainIndex)}function V(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function H({state:e,dispatch:t},n){let r=B(e.selection,n);return r.eq(e.selection,!0)?!1:(t(V(e,r)),!0)}function qt(e,t){return C.cursor(t?e.to:e.from)}function Jt(e,t){return H(e,n=>n.empty?e.moveByChar(n,t):qt(n,t))}function U(e){return e.textDirectionAt(e.state.selection.main.head)==s.LTR}var Yt=e=>Jt(e,!U(e)),Xt=e=>Jt(e,U(e));function Zt(e,t){return H(e,n=>n.empty?e.moveByGroup(n,t):qt(n,t))}var Qt=e=>Zt(e,!U(e)),$t=e=>Zt(e,U(e));typeof Intl<`u`&&Intl.Segmenter&&new Intl.Segmenter(void 0,{granularity:`word`});function en(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function tn(e,t,n){let r=ce(e).resolveInner(t.head),i=n?a.closedBy:a.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;en(e,t,i)?r=t:a=n?t.to:t.from}let o=r.type.prop(i),s,c;return c=o&&(s=n?l(e,r.from,1):l(e,r.to,-1))&&s.matched?n?s.end.to:s.end.from:n?r.to:r.from,C.cursor(c,n?-1:1)}var nn=e=>H(e,t=>tn(e.state,t,!U(e))),rn=e=>H(e,t=>tn(e.state,t,U(e)));function an(e,t){return H(e,n=>{if(!n.empty)return qt(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var on=e=>an(e,!1),sn=e=>an(e,!0);function cn(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(A.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function ln(e,t){let n=cn(e),{state:r}=e,i=B(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):qt(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=A.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(V(r,i),{effects:a}),!0}var un=e=>ln(e,!1),dn=e=>ln(e,!0);function W(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=C.cursor(r.from+n))}return i}var fn=e=>H(e,t=>W(e,t,!0)),pn=e=>H(e,t=>W(e,t,!1)),mn=e=>H(e,t=>W(e,t,!U(e))),hn=e=>H(e,t=>W(e,t,U(e))),gn=e=>H(e,t=>C.cursor(e.lineBlockAt(t.head).from,1)),_n=e=>H(e,t=>C.cursor(e.lineBlockAt(t.head).to,-1));function vn(e,t,n){let r=!1,i=B(e.selection,t=>{let i=l(e,t.head,-1)||l(e,t.head,1)||t.head>0&&l(e,t.head-1,1)||t.head<e.doc.length&&l(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?C.range(t.anchor,a):C.cursor(a)});return r?(t(V(e,i)),!0):!1}var yn=({state:e,dispatch:t})=>vn(e,t,!1);function G(e,t){let n=B(e.state.selection,e=>{let n=t(e);return C.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(V(e.state,n)),!0)}function bn(e,t){return G(e,n=>e.moveByChar(n,t))}var xn=e=>bn(e,!U(e)),Sn=e=>bn(e,U(e));function Cn(e,t){return G(e,n=>e.moveByGroup(n,t))}var wn=e=>Cn(e,!U(e)),Tn=e=>Cn(e,U(e)),En=e=>G(e,t=>tn(e.state,t,!U(e))),Dn=e=>G(e,t=>tn(e.state,t,U(e)));function On(e,t){return G(e,n=>e.moveVertically(n,t))}var kn=e=>On(e,!1),An=e=>On(e,!0);function jn(e,t){return G(e,n=>e.moveVertically(n,t,cn(e).height))}var Mn=e=>jn(e,!1),Nn=e=>jn(e,!0),Pn=e=>G(e,t=>W(e,t,!0)),Fn=e=>G(e,t=>W(e,t,!1)),In=e=>G(e,t=>W(e,t,!U(e))),Ln=e=>G(e,t=>W(e,t,U(e))),Rn=e=>G(e,t=>C.cursor(e.lineBlockAt(t.head).from)),zn=e=>G(e,t=>C.cursor(e.lineBlockAt(t.head).to)),Bn=({state:e,dispatch:t})=>(t(V(e,{anchor:0})),!0),Vn=({state:e,dispatch:t})=>(t(V(e,{anchor:e.doc.length})),!0),Hn=({state:e,dispatch:t})=>(t(V(e,{anchor:e.selection.main.anchor,head:0})),!0),Un=({state:e,dispatch:t})=>(t(V(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Wn=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),Gn=({state:e,dispatch:t})=>{let n=ur(e).map(({from:t,to:n})=>C.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:C.create(n),userEvent:`select`})),!0},Kn=({state:e,dispatch:t})=>{let n=B(e.selection,t=>{let n=ce(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return C.range(n.to,n.from)}return t});return n.eq(e.selection)?!1:(t(V(e,n)),!0)};function qn(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}else if(r.head==n.head)break;else n=r}}return i.length==r.ranges.length?!1:(e.dispatch(V(n,C.create(i,i.length-1))),!0)}var Jn=e=>qn(e,!1),Yn=e=>qn(e,!0),Xn=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=C.create([n.main]):n.main.empty||(r=C.create([C.cursor(n.main.head)])),r?(t(V(e,r)),!0):!1};function Zn(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=Qn(e,o,!1)):o>i&&(n=`delete.forward`,o=Qn(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=Qn(e,i,!1),a=Qn(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:C.cursor(i,i<r.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?A.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function Qn(e,t,n){if(e instanceof A)for(let r of e.state.facet(A.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var $n=(e,t,n)=>Zn(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=Ke(s,a.tabSize)%xe(a)||xe(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=j(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=j(o.text,c-o.from,!1,!1)+o.from);return c}),er=e=>$n(e,!1,!0),tr=e=>$n(e,!0,!1),nr=(e,t)=>Zn(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=j(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),rr=e=>nr(e,!1),ir=e=>nr(e,!0),ar=e=>Zn(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),or=e=>Zn(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),sr=e=>Zn(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),cr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:be.of([``,``])},range:C.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},lr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:j(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:j(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:C.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function ur(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function dr(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of ur(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(C.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(C.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:C.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var fr=({state:e,dispatch:t})=>dr(e,t,!1),pr=({state:e,dispatch:t})=>dr(e,t,!0);function mr(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of ur(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var hr=({state:e,dispatch:t})=>mr(e,t,!1),gr=({state:e,dispatch:t})=>mr(e,t,!0),_r=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(ur(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=B(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function vr(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=ce(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),o;return r&&i&&r.to<=t&&i.from>=t&&(o=r.type.prop(a.closedBy))&&o.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var yr=xr(!1),br=xr(!0);function xr(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&vr(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new Oe(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=ot(s,r);for(c??=Ke(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,ut(t,c)];return o&&l.push(ut(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:be.of(l)},range:C.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function Sr(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:C.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var Cr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new Oe(e,{overrideIndentation:e=>n[e]??-1}),i=Sr(e,(t,i,a)=>{let o=ot(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=ut(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},wr=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Sr(e,(t,n)=>{n.push({from:t.from,insert:e.facet(oe)})}),{userEvent:`input.indent`})),!0),Tr=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Sr(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=Ke(r,e.tabSize),a=0,o=ut(e,Math.max(0,i-xe(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),Er=e=>(e.setTabFocusMode(),!0),Dr=[{key:`Ctrl-b`,run:Yt,shift:xn,preventDefault:!0},{key:`Ctrl-f`,run:Xt,shift:Sn},{key:`Ctrl-p`,run:on,shift:kn},{key:`Ctrl-n`,run:sn,shift:An},{key:`Ctrl-a`,run:gn,shift:Rn},{key:`Ctrl-e`,run:_n,shift:zn},{key:`Ctrl-d`,run:tr},{key:`Ctrl-h`,run:er},{key:`Ctrl-k`,run:ar},{key:`Ctrl-Alt-h`,run:rr},{key:`Ctrl-o`,run:cr},{key:`Ctrl-t`,run:lr},{key:`Ctrl-v`,run:dn}],Or=[{key:`ArrowLeft`,run:Yt,shift:xn,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:Qt,shift:wn,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:mn,shift:In,preventDefault:!0},{key:`ArrowRight`,run:Xt,shift:Sn,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:$t,shift:Tn,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:hn,shift:Ln,preventDefault:!0},{key:`ArrowUp`,run:on,shift:kn,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:Bn,shift:Hn},{mac:`Ctrl-ArrowUp`,run:un,shift:Mn},{key:`ArrowDown`,run:sn,shift:An,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:Vn,shift:Un},{mac:`Ctrl-ArrowDown`,run:dn,shift:Nn},{key:`PageUp`,run:un,shift:Mn},{key:`PageDown`,run:dn,shift:Nn},{key:`Home`,run:pn,shift:Fn,preventDefault:!0},{key:`Mod-Home`,run:Bn,shift:Hn},{key:`End`,run:fn,shift:Pn,preventDefault:!0},{key:`Mod-End`,run:Vn,shift:Un},{key:`Enter`,run:yr,shift:yr},{key:`Mod-a`,run:Wn},{key:`Backspace`,run:er,shift:er,preventDefault:!0},{key:`Delete`,run:tr,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:rr,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:ir,preventDefault:!0},{mac:`Mod-Backspace`,run:or,preventDefault:!0},{mac:`Mod-Delete`,run:sr,preventDefault:!0}].concat(Dr.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),kr=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:nn,shift:En},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:rn,shift:Dn},{key:`Alt-ArrowUp`,run:fr},{key:`Shift-Alt-ArrowUp`,run:hr},{key:`Alt-ArrowDown`,run:pr},{key:`Shift-Alt-ArrowDown`,run:gr},{key:`Mod-Alt-ArrowUp`,run:Jn},{key:`Mod-Alt-ArrowDown`,run:Yn},{key:`Escape`,run:Xn},{key:`Mod-Enter`,run:br},{key:`Alt-l`,mac:`Ctrl-l`,run:Gn},{key:`Mod-i`,run:Kn,preventDefault:!0},{key:`Mod-[`,run:Tr},{key:`Mod-]`,run:wr},{key:`Mod-Alt-\\`,run:Cr},{key:`Shift-Mod-k`,run:_r},{key:`Shift-Mod-\\`,run:yn},{key:`Mod-/`,run:ht},{key:`Alt-A`,run:vt},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:Er}].concat(Or),Ar={key:`Tab`,run:wr,shift:Tr},jr=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,K=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(jr(e)):jr,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return i(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=we(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=Me(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let a=r.charCodeAt(e),o=this.match(a,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(o)return this.value=o,this;break}i==n&&e<t.length&&t.charCodeAt(e)==a&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],a=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,a=!0)),a||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol<`u`&&(K.prototype[Symbol.iterator]=function(){return this});var Mr={from:-1,to:-1,match:/.*/.exec(``)},Nr=`gm`+(/x/.unicode==null?``:`u`),Pr=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=Mr,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Lr(e,t,n,r,i);this.re=new RegExp(t,Nr+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter(),this.curLineStart=e.lineAt(r).from,this.matchPos=zr(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=zr(this.text,r+(n==r?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},Fr=new WeakMap,Ir=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=Fr.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return Fr.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),Fr.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},Lr=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=Mr,this.matchPos=zr(e,r),this.re=new RegExp(t,Nr+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=Ir.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=zr(this.text,n+(e==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Ir.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(Pr.prototype[Symbol.iterator]=Lr.prototype[Symbol.iterator]=function(){return this});function Rr(e){try{return new RegExp(e,Nr),!0}catch{return!1}}function zr(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var Br=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=p(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),p=C.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,A.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},Vr={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Hr=P.define({combine(e){return M(e,Vr,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Ur(e){let t=[Yr,Jr];return e&&t.push(Hr.of(e)),t}var Wr=N.mark({class:`cm-selectionMatch`}),Gr=N.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function Kr(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=h.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=h.Word)}function qr(e,t,n,r){return e(t.sliceDoc(n,n+1))==h.Word&&e(t.sliceDoc(r-1,r))==h.Word}var Jr=g.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(Hr),{state:n}=e,r=n.selection;if(r.ranges.length>1)return N.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return N.none;let e=n.wordAt(i.head);if(!e)return N.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return N.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(Kr(o,n,i.from,i.to)&&qr(o,n,i.from,i.to)))return N.none}else if(a=n.sliceDoc(i.from,i.to),!a)return N.none}let s=[];for(let r of e.visibleRanges){let e=new K(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||Kr(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(Gr.range(r,a)):(r>=i.to||a<=i.from)&&s.push(Wr.range(r,a)),s.length>t.maxMatches))return N.none}}return N.set(s)}},{decorations:e=>e.decorations}),Yr=A.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),Xr=({state:e,dispatch:t})=>{let{selection:n}=e,r=C.create(n.ranges.map(t=>e.wordAt(t.head)||C.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function Zr(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new K(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new K(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var Qr=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return Xr({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=Zr(e,r);return i?(t(e.update({selection:e.selection.addRange(C.range(i.from,i.to),!1),effects:A.scrollIntoView(i.to)})),!0):!1},q=P.define({combine(e){return M(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new ki(e),scrollToMatch:e=>A.scrollIntoView(e)})}}),$r=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||Rr(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
|
|
2
2
|
`:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new ci(this):new ri(this)}getCursor(e,t=0,n){let r=e.doc?e:k.create({doc:e});return n??=r.doc.length,this.regexp?Y(this,r,t,n):J(this,r,t,n)}},ei=class{constructor(e){this.spec=e}};function ti(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function J(e,t,n,r){let i;return e.wholeWord&&(i=ni(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=ti(e.test,t,i)),new K(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function ni(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(ai(i,n-a))!=h.Word||t(oi(i,n-a))!=h.Word)&&(t(oi(i,r-a))!=h.Word||t(ai(i,r-a))!=h.Word))}var ri=class extends ei{constructor(e){super(e)}nextMatch(e,t,n){let r=J(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=J(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=J(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=J(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=J(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function ii(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function Y(e,t,n,r){let i;return e.wholeWord&&(i=si(t.charCategorizer(t.selection.main.head))),e.test&&(i=ii(e.test,t,i)),new Pr(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function ai(e,t){return e.slice(j(e,t,!1),t)}function oi(e,t){return e.slice(t,j(e,t))}function si(e){return(t,n,r)=>!r[0].length||(e(ai(r.input,r.index))!=h.Word||e(oi(r.input,r.index))!=h.Word)&&(e(oi(r.input,r.index+r[0].length))!=h.Word||e(ai(r.input,r.index+r[0].length))!=h.Word)}var ci=class extends ei{nextMatch(e,t,n){let r=Y(this.spec,e,n,e.doc.length).next();return r.done&&(r=Y(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=Y(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=Y(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=Y(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},li=b.define(),ui=b.define(),X=ge.define({create(e){return new di(Ci(e).create(),null)},update(e,t){for(let n of t.effects)n.is(li)?e=new di(n.value.create(),e.panel):n.is(ui)&&(e=new di(e.query,n.value?Si:null));return e},provide:e=>f.from(e,e=>e.panel)}),di=class{constructor(e,t){this.query=e,this.panel=t}},fi=N.mark({class:`cm-searchMatch`}),pi=N.mark({class:`cm-searchMatch cm-searchMatch-selected`}),mi=g.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(X))}update(e){let t=e.state.field(X);(t!=e.startState.field(X)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return N.none;let{view:n}=this,r=new _;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?pi:fi)})}return r.finish()}},{decorations:e=>e.decorations});function hi(e){return t=>{let n=t.state.field(X,!1);return n&&n.query.spec.valid?e(t,n):Ei(t)}}var gi=hi((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=C.single(r.from,r.to),a=e.state.facet(q);return e.dispatch({selection:i,effects:[Mi(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),Ti(e),!0}),_i=hi((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=C.single(i.from,i.to),o=e.state.facet(q);return e.dispatch({selection:a,effects:[Mi(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),Ti(e),!0}),vi=hi((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:C.create(n.map(e=>C.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),yi=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new K(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(C.range(t.value.from,t.value.to))}return t(e.update({selection:C.create(a,o),userEvent:`select.search.matches`})),!0},bi=hi((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n,o.from,o.to),u.push(A.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`)));let d=e.state.changes(s);return o&&(c=C.single(o.from,o.to).map(d),u.push(Mi(e,o)),u.push(n.facet(q).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),xi=hi((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(e=>{let{from:n,to:r}=e;return{from:n,to:r,insert:t.getReplacement(e)}});if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:A.announce.of(r),userEvent:`input.replace.all`}),!0});function Si(e){return e.state.facet(q).createPanel(e)}function Ci(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(q);return new $r({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function wi(e){let t=it(e,Si);return t&&t.dom.querySelector(`[main-field]`)}function Ti(e){let t=wi(e);t&&t==e.root.activeElement&&t.select()}var Ei=e=>{let t=e.state.field(X,!1);if(t&&t.panel){let n=wi(e);if(n&&n!=e.root.activeElement){let r=Ci(e.state,t.query.spec);r.valid&&e.dispatch({effects:li.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[ui.of(!0),t?li.of(Ci(e.state,t.query.spec)):b.appendConfig.of(Pi)]});return!0},Di=e=>{let t=e.state.field(X,!1);if(!t||!t.panel)return!1;let n=it(e,Si);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:ui.of(!1)}),!0},Oi=[{key:`Mod-f`,run:Ei,scope:`editor search-panel`},{key:`F3`,run:gi,shift:_i,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:gi,shift:_i,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:Di,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:yi},{key:`Mod-Alt-g`,run:Br},{key:`Mod-d`,run:Qr,preventDefault:!0}],ki=class{constructor(e){this.view=e;let t=this.query=e.state.field(X).query.spec;this.commit=this.commit.bind(this),this.searchField=o(`input`,{value:t.search,placeholder:Z(e,`Find`),"aria-label":Z(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=o(`input`,{value:t.replace,placeholder:Z(e,`Replace`),"aria-label":Z(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=o(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=o(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=o(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return o(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=o(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>gi(e),[Z(e,`next`)]),n(`prev`,()=>_i(e),[Z(e,`previous`)]),n(`select`,()=>vi(e),[Z(e,`all`)]),o(`label`,null,[this.caseField,Z(e,`match case`)]),o(`label`,null,[this.reField,Z(e,`regexp`)]),o(`label`,null,[this.wordField,Z(e,`by word`)]),...e.state.readOnly?[]:[o(`br`),this.replaceField,n(`replace`,()=>bi(e),[Z(e,`replace`)]),n(`replaceAll`,()=>xi(e),[Z(e,`replace all`)])],o(`button`,{name:`close`,onclick:()=>Di(e),"aria-label":Z(e,`close`),type:`button`},[`×`])])}commit(){let e=new $r({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:li.of(e)}))}keydown(e){lt(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?_i:gi)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),bi(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(li)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(q).top}};function Z(e,t){return e.state.phrase(t)}var Ai=30,ji=/[\s\.,:;?!]/;function Mi(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-Ai),o=Math.min(i,n+Ai),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<Ai;e++)if(!ji.test(s[e+1])&&ji.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-Ai;e--)if(!ji.test(s[e-1])&&ji.test(s[e])){s=s.slice(0,e);break}}return A.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var Ni=A.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),Pi=[X,v.low(mi),Ni],Fi=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},Ii=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(Ji).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new _,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;e<a.length;){let t=a[e];if(t.from==n&&(t.to>t.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=aa(s);if(i)o.add(n,n,N.widget({widget:new Qi(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,N.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e<s.length;e++)s[e].to<=c&&s.splice(e--,1)}let f=o.finish();return new e(f,n,Q(f))}};function Q(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(!r)r=new Fi(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new Fi(r.from,n,r.diagnostic)}),r}function Li(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(Ji).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(zi))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function Ri(e,t){return e.field($,!1)?t:t.concat(b.appendConfig.of(oa))}var zi=b.define(),Bi=b.define(),Vi=b.define(),$=ge.define({create(){return new Ii(N.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=Q(n,e.selected.diagnostic,i)||Q(n,null,i)}!n.size&&i&&t.state.facet(Ji).autoPanel&&(i=null),e=new Ii(n,i,r)}for(let n of t.effects)if(n.is(zi)){let r=t.state.facet(Ji).autoPanel?n.value.length?ea.open:null:e.panel;e=Ii.init(n.value,r,t.state)}else n.is(Bi)?e=new Ii(e.diagnostics,n.value?ea.open:null,e.selected):n.is(Vi)&&(e=new Ii(e.diagnostics,e.panel,n.value));return e},provide:e=>[f.from(e,e=>e.panel),A.decorations.from(e,e=>e.diagnostics)]}),Hi=N.mark({class:`cm-lintRange cm-lintRange-active`});function Ui(e,t,n){let{diagnostics:r}=e.state.field($),i,a=-1,o=-1;r.between(t-(n<0?1:0),t+(n>0?1:0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,a=e,o=r,!1});let s=e.state.facet(Ji).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:e.state.doc.lineAt(a).to<o,create(){return{dom:Wi(e,i)}}}:null}function Wi(e,t){return o(`ul`,{class:`cm-tooltip-lint`},t.map(t=>Zi(e,t,!1)))}var Gi=e=>{let t=e.state.field($,!1);(!t||!t.panel)&&e.dispatch({effects:Ri(e.state,[Bi.of(!0)])});let n=it(e,ea.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},Ki=e=>{let t=e.state.field($,!1);return!t||!t.panel?!1:(e.dispatch({effects:Bi.of(!1)}),!0)},qi=[{key:`Mod-Shift-m`,run:Gi,preventDefault:!0},{key:`F8`,run:e=>{let t=e.state.field($,!1);if(!t)return!1;let n=e.state.selection.main,r=Q(t.diagnostics,null,n.to+1);return!r&&(r=Q(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],Ji=P.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...M(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Yi,tooltipFilter:Yi,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function Yi(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function Xi(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function Zi(e,t,n){let r=n?Xi(t.actions):[];return o(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},o(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,s=r=>{if(r.preventDefault(),a)return;a=!0;let i=Q(e.state.field($).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:c}=n,l=r[i]?c.indexOf(r[i]):-1,u=l<0?c:[c.slice(0,l),o(`u`,c.slice(l,l+1)),c.slice(l+1)];return o(`button`,{type:`button`,class:`cm-diagnosticAction`+(n.markClass?` `+n.markClass:``),onclick:s,onmousedown:s,"aria-label":` Action: ${c}${l<0?``:` (access key "${r[i]})"`}.`},u)}),t.source&&o(`div`,{class:`cm-diagnosticSource`},t.source))}var Qi=class extends Ze{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return o(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},$i=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=Zi(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},ea=class e{constructor(e){this.view=e,this.items=[];let t=t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)Ki(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=Xi(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=Q(this.view.state.field($).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}else return;t.preventDefault()}},n=e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)};this.list=o(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t,onclick:n}),this.dom=o(`div`,{class:`cm-panel-lint`},this.list,o(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>Ki(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field($).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field($),n=0,r=!1,i=null,a=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:s})=>{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(s=new $i(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new $i(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),r=!0),i?(this.list.setAttribute(`aria-activedescendant`,i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=Q(this.view.state.field($).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:Vi.of(t)})}static open(t){return new e(t)}};function ta(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function na(e){return ta(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`)}var ra=A.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:na(`#d11`)},".cm-lintRange-warning":{backgroundImage:na(`orange`)},".cm-lintRange-info":{backgroundImage:na(`#999`)},".cm-lintRange-hint":{backgroundImage:na(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function ia(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function aa(e){let t=`hint`,n=1;for(let r of e){let e=ia(r.severity);e>n&&(n=e,t=r.severity)}return t}var oa=[$,A.decorations.compute([$],e=>{let{selected:t,panel:n}=e.field($);return!t||!n||t.from==t.to?N.none:N.set([Hi.range(t.from,t.to)])}),Xe(Ui,{hideOn:Li}),ra],sa=function(e){e===void 0&&(e={});var{crosshairCursor:t=!1}=e,n=[];e.closeBracketsKeymap!==!1&&(n=n.concat($e)),e.defaultKeymap!==!1&&(n=n.concat(kr)),e.searchKeymap!==!1&&(n=n.concat(Oi)),e.historyKeymap!==!1&&(n=n.concat(Kt)),e.foldKeymap!==!1&&(n=n.concat(Ie)),e.completionKeymap!==!1&&(n=n.concat(Ce)),e.lintKeymap!==!1&&(n=n.concat(qi));var r=[];return e.lineNumbers!==!1&&r.push(st()),e.highlightActiveLineGutter!==!1&&r.push(He()),e.highlightSpecialChars!==!1&&r.push(at()),e.history!==!1&&r.push(At()),e.foldGutter!==!1&&r.push(Ue()),e.drawSelection!==!1&&r.push(ye()),e.dropCursor!==!1&&r.push(ie()),e.allowMultipleSelections!==!1&&r.push(k.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&r.push(Ee()),e.syntaxHighlighting!==!1&&r.push(ct(Ye,{fallback:!0})),e.bracketMatching!==!1&&r.push(Ae()),e.closeBrackets!==!1&&r.push(Ge()),e.autocompletion!==!1&&r.push(rt()),e.rectangularSelection!==!1&&r.push(se()),t!==!1&&r.push(he()),e.highlightActiveLine!==!1&&r.push(ke()),e.highlightSelectionMatches!==!1&&r.push(Ur()),e.tabSize&&typeof e.tabSize==`number`&&r.push(oe.of(` `.repeat(e.tabSize))),r.concat([We.of(n.flat())]).filter(Boolean)},ca=function(e){e===void 0&&(e={});var t=[];e.defaultKeymap!==!1&&(t=t.concat(kr)),e.historyKeymap!==!1&&(t=t.concat(Kt));var n=[];return e.highlightSpecialChars!==!1&&n.push(at()),e.history!==!1&&n.push(At()),e.drawSelection!==!1&&n.push(ye()),e.syntaxHighlighting!==!1&&n.push(ct(Ye,{fallback:!0})),n.concat([We.of(t.flat())]).filter(Boolean)},la=`#e5c07b`,ua=`#e06c75`,da=`#56b6c2`,fa=`#ffffff`,pa=`#abb2bf`,ma=`#7d8799`,ha=`#61afef`,ga=`#98c379`,_a=`#d19a66`,va=`#c678dd`,ya=`#21252b`,ba=`#2c313a`,xa=`#282c34`,Sa=`#353a42`,Ca=`#3E4451`,wa=`#528bff`,Ta={chalky:la,coral:ua,cyan:da,invalid:fa,ivory:pa,stone:ma,malibu:ha,sage:ga,whiskey:_a,violet:va,darkBackground:ya,highlightBackground:ba,background:xa,tooltipBackground:Sa,selection:Ca,cursor:wa},Ea=A.theme({"&":{color:pa,backgroundColor:xa},".cm-content":{caretColor:wa},".cm-cursor, .cm-dropCursor":{borderLeftColor:wa},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Ca},".cm-panels":{backgroundColor:ya,color:pa},".cm-panels.cm-panels-top":{borderBottom:`2px solid black`},".cm-panels.cm-panels-bottom":{borderTop:`2px solid black`},".cm-searchMatch":{backgroundColor:`#72a1ff59`,outline:`1px solid #457dff`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:`#6199ff2f`},".cm-activeLine":{backgroundColor:`#6699ff0b`},".cm-selectionMatch":{backgroundColor:`#aafe661a`},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bad0f847`},".cm-gutters":{backgroundColor:xa,color:ma,border:`none`},".cm-activeLineGutter":{backgroundColor:ba},".cm-foldPlaceholder":{backgroundColor:`transparent`,border:`none`,color:`#ddd`},".cm-tooltip":{border:`none`,backgroundColor:Sa},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:`transparent`,borderBottomColor:`transparent`},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Sa,borderBottomColor:Sa},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:ba,color:pa}}},{dark:!0}),Da=tt.define([{tag:d.keyword,color:va},{tag:[d.name,d.deleted,d.character,d.propertyName,d.macroName],color:ua},{tag:[d.function(d.variableName),d.labelName],color:ha},{tag:[d.color,d.constant(d.name),d.standard(d.name)],color:_a},{tag:[d.definition(d.name),d.separator],color:pa},{tag:[d.typeName,d.className,d.number,d.changed,d.annotation,d.modifier,d.self,d.namespace],color:la},{tag:[d.operator,d.operatorKeyword,d.url,d.escape,d.regexp,d.link,d.special(d.string)],color:da},{tag:[d.meta,d.comment],color:ma},{tag:d.strong,fontWeight:`bold`},{tag:d.emphasis,fontStyle:`italic`},{tag:d.strikethrough,textDecoration:`line-through`},{tag:d.link,color:ma,textDecoration:`underline`},{tag:d.heading,fontWeight:`bold`,color:ua},{tag:[d.atom,d.bool,d.special(d.variableName)],color:_a},{tag:[d.processingInstruction,d.string,d.inserted],color:ga},{tag:d.invalid,color:fa}]),Oa=[Ea,ct(Da)],ka=A.theme({"&":{backgroundColor:`#fff`}},{dark:!1}),Aa=function(e){e===void 0&&(e={});var{indentWithTab:t=!0,editable:n=!0,readOnly:r=!1,theme:i=`light`,placeholder:a=``,basicSetup:o=!0}=e,s=[];switch(t&&s.unshift(We.of([Ar])),o&&(typeof o==`boolean`?s.unshift(sa()):s.unshift(sa(o))),a&&s.unshift(dt(a)),i){case`light`:s.push(ka);break;case`dark`:s.push(Oa);break;case`none`:break;default:s.push(i);break}return n===!1&&s.push(A.editable.of(!1)),r&&s.push(k.readOnly.of(!0)),[...s]},ja=e=>({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to)),selectedText:e.state.selection.ranges.some(e=>!e.empty)}),Ma=class{constructor(e,t){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=t,this.timeoutMS=t,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(e=>{try{e()}catch(e){console.error(`TimeoutLatch callback error:`,e)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}},Na=class{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}},Pa=null,Fa=()=>typeof window>`u`?new Na:(Pa||=new Na,Pa),Ia=Be.define(),La=200,Ra=[];function za(e){var{value:t,selection:n,onChange:r,onStatistics:i,onCreateEditor:a,onUpdate:o,extensions:s=Ra,autoFocus:c,theme:l=`light`,height:u=null,minHeight:d=null,maxHeight:f=null,width:p=null,minWidth:m=null,maxWidth:h=null,placeholder:g=``,editable:_=!0,readOnly:ee=!1,indentWithTab:v=!0,basicSetup:te=!0,root:ne,initialState:y}=e,[x,re]=(0,F.useState)(),[S,C]=(0,F.useState)(),[w,T]=(0,F.useState)(),E=(0,F.useState)(()=>({current:null}))[0],D=(0,F.useState)(()=>({current:null}))[0],ie=A.theme({"&":{height:u,minHeight:d,maxHeight:f,width:p,minWidth:m,maxWidth:h},"& .cm-scroller":{height:`100% !important`}}),O=[A.updateListener.of(e=>{e.docChanged&&typeof r==`function`&&!e.transactions.some(e=>e.annotation(Ia))&&(E.current?E.current.reset():(E.current=new Ma(()=>{if(D.current){var e=D.current;D.current=null,e()}E.current=null},La),Fa().add(E.current)),r(e.state.doc.toString(),e)),i&&i(ja(e))}),ie,...Aa({theme:l,editable:_,readOnly:ee,placeholder:g,indentWithTab:v,basicSetup:te})];return o&&typeof o==`function`&&O.push(A.updateListener.of(o)),O=O.concat(s),(0,F.useLayoutEffect)(()=>{if(x&&!w){var e={doc:t,selection:n,extensions:O},r=y?k.fromJSON(y.json,e,y.fields):k.create(e);if(T(r),!S){var i=new A({state:r,parent:x,root:ne});C(i),a&&a(i,r)}}return()=>{S&&(T(void 0),C(void 0))}},[x,w]),(0,F.useEffect)(()=>{e.container&&re(e.container)},[e.container]),(0,F.useEffect)(()=>()=>{S&&(S.destroy(),C(void 0)),E.current&&=(E.current.cancel(),null)},[S]),(0,F.useEffect)(()=>{c&&S&&S.focus()},[c,S]),(0,F.useEffect)(()=>{S&&S.dispatch({effects:b.reconfigure.of(O)})},[l,s,u,d,f,p,m,h,g,_,ee,v,te,r,o]),(0,F.useEffect)(()=>{if(t!==void 0){var e=S?S.state.doc.toString():``;if(S&&t!==e){var n=E.current&&!E.current.isDone,r=()=>{S&&t!==S.state.doc.toString()&&S.dispatch({changes:{from:0,to:S.state.doc.toString().length,insert:t||``},annotations:[Ia.of(!0)]})};n?D.current=r:r()}}},[t,S]),{state:w,setState:T,view:S,setView:C,container:x,setContainer:re}}var Ba=t(),Va=[`className`,`value`,`selection`,`extensions`,`onChange`,`onStatistics`,`onCreateEditor`,`onUpdate`,`autoFocus`,`theme`,`height`,`minHeight`,`maxHeight`,`width`,`minWidth`,`maxWidth`,`basicSetup`,`placeholder`,`indentWithTab`,`editable`,`readOnly`,`root`,`initialState`],Ha=(0,F.forwardRef)((e,t)=>{var{className:n,value:r=``,selection:i,extensions:a=[],onChange:o,onStatistics:s,onCreateEditor:c,onUpdate:l,autoFocus:u,theme:d=`light`,height:f,minHeight:p,maxHeight:m,width:h,minWidth:g,maxWidth:_,basicSetup:ee,placeholder:v,indentWithTab:te,editable:ne,readOnly:y,root:b,initialState:x}=e,re=mt(e,Va),S=(0,F.useRef)(null),{state:C,view:w,container:T,setContainer:E}=za({root:b,value:r,autoFocus:u,theme:d,height:f,minHeight:p,maxHeight:m,width:h,minWidth:g,maxWidth:_,basicSetup:ee,placeholder:v,indentWithTab:te,editable:ne,readOnly:y,selection:i,onChange:o,onStatistics:s,onCreateEditor:c,onUpdate:l,extensions:a,initialState:x});(0,F.useImperativeHandle)(t,()=>({editor:S.current,state:C,view:w}),[S,T,C,w]);var D=(0,F.useCallback)(e=>{S.current=e,E(e)},[E]);if(typeof r!=`string`)throw Error(`value must be typeof string but got `+typeof r);return(0,Ba.jsx)(`div`,pt({ref:D,className:(typeof d==`string`?`cm-theme-`+d:`cm-theme`)+(n?` `+n:``)},re))});Ha.displayName=`CodeMirror`;export{Be as Annotation,w as AnnotationType,m as BidiSpan,te as BlockInfo,S as BlockType,ae as BlockWrapper,T as ChangeDesc,D as ChangeSet,h as CharCategory,ne as Compartment,N as Decoration,s as Direction,C as EditorSelection,k as EditorState,A as EditorView,Ia as ExternalChange,P as Facet,ee as GutterMarker,c as Line,fe as MapMode,ue as MatchDecorator,v as Prec,de as Range,me as RangeSet,_ as RangeSetBuilder,re as RangeValue,pe as RectangleMarker,Qe as SelectionRange,b as StateEffect,ve as StateEffectType,ge as StateField,be as Text,O as Transaction,g as ViewPlugin,x as ViewUpdate,Ze as WidgetType,y as __test,sa as basicSetup,_e as closeHoverTooltips,i as codePointAt,Me as codePointSize,Ta as color,M as combineConfig,Ke as countColumn,he as crosshairCursor,Ha as default,ka as defaultLightThemeOption,ye as drawSelection,ie as dropCursor,j as findClusterBreak,Re as findColumn,we as fromCodePoint,Aa as getDefaultExtensions,r as getDialog,Ne as getDrawSelectionConfig,it as getPanel,ja as getStatistics,qe as getTooltip,et as gutter,ze as gutterLineClass,Te as gutterWidgetClass,Je as gutters,nt as hasHoverTooltips,ke as highlightActiveLine,He as highlightActiveLineGutter,at as highlightSpecialChars,je as highlightTrailingWhitespace,Pe as highlightWhitespace,Xe as hoverTooltip,We as keymap,Le as layer,Fe as lineNumberMarkers,Se as lineNumberWidgetMarker,st as lineNumbers,ft as logException,ca as minimalSetup,Oa as oneDark,Da as oneDarkHighlightStyle,Ea as oneDarkTheme,De as panels,dt as placeholder,se as rectangularSelection,u as repositionTooltips,lt as runScopeHandlers,le as scrollPastEnd,p as showDialog,f as showPanel,E as showTooltip,Ve as tooltips,za as useCodeMirror};
|
|
@@ -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-
|
|
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-CP6EIXkh.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{t as e}from"./createLucideIcon-BjHrJDVb.js";var t=e(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),n=e(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]);export{t as n,n as t};
|
|
@@ -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{$ as d,U as f,_ as p,tt as m,ut as h}from"./index-CP6EIXkh.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?f:t===`synced`?h:t===`ahead`?a:t===`behind`?i:t===`remote-only`?h: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(p(e=>e.activeProject))?.name,[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(!1),[l,f]=(0,_.useState)(!0),h=(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),f(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)(m,{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)(d,{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:h,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)(d,{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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{U as e}from"./vendor-mermaid-DCie7hiR.js";export{e as createGitGraphServices};
|