pagedex 0.1.4 → 0.1.6

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.
@@ -0,0 +1,185 @@
1
+ import{a as u,j as e,R as On,c as Vn}from"./vendor-react-E4kvVwMA.js";import{m as Qt}from"./vendor-markdown-C94ubdL7.js";import{H as Oe,d as Xn}from"./vendor-hljs-B8we2J8a.js";import{u as Gn,E as Kn,s as Jn,M as Yn}from"./vendor-tiptap-ChgD7Piv.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))i(a);new MutationObserver(a=>{for(const c of a)if(c.type==="childList")for(const p of c.addedNodes)p.tagName==="LINK"&&p.rel==="modulepreload"&&i(p)}).observe(document,{childList:!0,subtree:!0});function o(a){const c={};return a.integrity&&(c.integrity=a.integrity),a.referrerPolicy&&(c.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?c.credentials="include":a.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function i(a){if(a.ep)return;a.ep=!0;const c=o(a);fetch(a.href,c)}})();const he={theme:"dark",fontSize:15,lineHeight:1.65,maxWidth:780,outlinePosition:"right",startupMode:"newtab",startupPath:"README.md",autoCollapsed:["apps"],hiddenFolders:[]};function Qn(){try{const s=localStorage.getItem("vault-settings");if(!s)return he;const t=JSON.parse(s);return{...he,...t,theme:t.theme==="light"?"light":"dark",fontSize:Number(t.fontSize)>=12&&Number(t.fontSize)<=22?Number(t.fontSize):15,lineHeight:Number(t.lineHeight)>=1.3&&Number(t.lineHeight)<=2.1?Number(t.lineHeight):1.65,maxWidth:Number(t.maxWidth)>=560&&Number(t.maxWidth)<=1040?Number(t.maxWidth):780,outlinePosition:["right","bottom","hidden"].includes(t.outlinePosition)?t.outlinePosition:"right",autoCollapsed:Array.isArray(t.autoCollapsed)?t.autoCollapsed:["apps"],hiddenFolders:Array.isArray(t.hiddenFolders)?t.hiddenFolders:[]}}catch{return he}}function Zn(s){const t=decodeURIComponent(location.hash.slice(1)||"");return t||(s.startupMode==="readme"?"README.md":s.startupMode==="last"?localStorage.getItem("vault-last-path")||null:s.startupMode==="custom"&&s.startupPath.trim()||null)}function ge(s){return s?s.split("/").pop().replace(/\.md$/i,""):"New tab"}function Ze(s){return/\.(md|markdown|mdx)$/i.test(s)}function Pe(s){return/\.(png|jpe?g|gif|webp|svg|ico)$/i.test(s)}function Zt(s){return/\.svg$/i.test(s)}function et(s){return/\.pdf$/i.test(s)}function tt(s){return/\.(mp3|wav|m4a|ogg)$/i.test(s)}function st(s){return/\.(mp4|webm|mov)$/i.test(s)}function ea(s){return/\.html?$/i.test(s)}function ta(s){return/\.(csv|tsv)$/i.test(s)}function nt(s){return/\.(epub|zip|tar|gz|tgz|7z|rar|docx?|xlsx?|pptx?|odt|ods|odp|mkv|avi|dmg|exe|bin|whl|sqlite|db)$/i.test(s)}function cs(s,t){const o=t.split("#")[0],i=s.includes("/")?s.split("/").slice(0,-1).join("/"):"",a=(i?`${i}/`:"")+o,c=[];for(const p of a.split("/"))p==="."||p===""||(p===".."?c.pop():c.push(p));return c.join("/")}function sa(s,t){const o=s.split("|")[0].split("#")[0].trim().replace(/\.md$/i,"").replace(/^\/+/,"").toLowerCase();if(!o)return null;const i=t.filter(p=>p.endsWith(".md")),a=i.find(p=>p.slice(0,-3).toLowerCase()===o);if(a)return a;const c=o.split("/").pop();return i.find(p=>p.slice(0,-3).split("/").pop().toLowerCase()===c)||null}function it(s,t){const o=(s||"").trim().replace(/^\/+|\/+$/g,"");if(!o)return"";const i=/\.[a-z0-9]+$/i.test(o)?o:`${o}.md`,a=(t||"").trim().replace(/^\/+|\/+$/g,"");return a?`${a}/${i}`:i}Oe.registerLanguage("dockerfile",Xn);const es={js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",ts:"typescript",tsx:"typescript",py:"python",pyw:"python",sh:"bash",bash:"bash",zsh:"bash",json:"json",jsonc:"json",yml:"yaml",yaml:"yaml",css:"css",scss:"scss",less:"less",html:"xml",htm:"xml",xml:"xml",svg:"xml",md:"markdown",markdown:"markdown",sql:"sql",rs:"rust",go:"go",java:"java",kt:"kotlin",c:"c",h:"c",cpp:"cpp",hpp:"cpp",cc:"cpp",toml:"ini",ini:"ini",conf:"ini",env:"ini",diff:"diff",patch:"diff",rb:"ruby",php:"php",swift:"swift",makefile:"makefile",dockerfile:"dockerfile"};function ds(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function hs(s,t){const o=String(s??"");try{const i=(t||"").trim().toLowerCase();if(i&&Oe.getLanguage(i))return Oe.highlight(o,{language:i,ignoreIllegals:!0}).value;if(o.length<=15e4)return Oe.highlightAuto(o).value}catch{}return ds(o)}function na(s,t,o){const i=[],c=s.split(/(```[\s\S]*?```)/g).map((r,d)=>d%2===1?r:r.replace(/\[\[([^\]]+)\]\]/g,(k,j)=>{const[f,E]=j.split("|"),$=(E||f).trim(),C=sa(j,o);return C?`<a class="wikilink" data-path="${C.replace(/"/g,"&quot;")}">${$}</a>`:`<span class="wikilink broken" title="Note not created yet">${$}</span>`})).join(""),p=new Qt.Renderer;return p.heading=({tokens:r,depth:d})=>{const k=p.parser.parseInline(r),j=k.replace(/<[^>]+>/g,""),f=j.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");return i.push({level:d,text:j,id:f}),`<h${d} id="${f}">${k}</h${d}>`},p.image=({href:r,title:d,text:k})=>`<img src="${/^https?:\/\//.test(r)?r:`/api/v1/file?path=${encodeURIComponent(cs(t,r))}`}" alt="${k||""}"${d?` title="${d}"`:""} />`,p.link=({href:r,title:d,tokens:k})=>{const j=p.parser.parseInline(k);return/^https?:\/\//.test(r)?`<a href="${r}" target="_blank" rel="noreferrer"${d?` title="${d}"`:""}>${j}</a>`:`<a class="md-rel-link" data-href="${r.replace(/"/g,"&quot;")}">${j}</a>`},p.code=({text:r,lang:d})=>{const k=hs(r,d);return`<pre><code class="${d?`hljs language-${ds(d.trim())}`:"hljs"}">${k}</code></pre>`},{renderedHtml:Qt.parse(c,{renderer:p,gfm:!0,breaks:!1}),headings:i}}function aa(s,t){if(!s)return"";const o=t.split("/").pop().toLowerCase(),i=o.includes(".")?o.split(".").pop():o,a=es[i]||es[o]||"";return hs(s,a)}const ia=120,oa=.28,ts=6,Be=.25,Ue=.28,qe=18;function la(s){let t=s;for(;t&&t!==document.body;){const o=t.tagName;if(o==="PRE"||o==="TABLE"||o==="INPUT"||o==="TEXTAREA"||o==="SELECT"||t.isContentEditable)return!0;if(t.scrollWidth>t.clientWidth+2){const i=getComputedStyle(t).overflowX;if(i==="auto"||i==="scroll")return!0}t=t.parentElement}return!1}function ss(s,t){if(s)for(const o of t)s.style[o]=""}function ra({drawerOpen:s,outlineDrawerOpen:t,outlinePosition:o="right",setDrawerOpen:i,onOpenOutline:a,setOutlineDrawerOpen:c,disabled:p=!1}){const b=u.useRef({drawerOpen:s,outlineDrawerOpen:t,outlinePosition:o,setDrawerOpen:i,onOpenOutline:a,setOutlineDrawerOpen:c,disabled:p});b.current={drawerOpen:s,outlineDrawerOpen:t,outlinePosition:o,setDrawerOpen:i,onOpenOutline:a,setOutlineDrawerOpen:c,disabled:p},u.useEffect(()=>{let r=null;const d=C=>{C&&(ss(C.panelEl,["transform","transition"]),ss(C.backdropEl,["display","position","inset","zIndex","background","opacity","transition"]))},k=C=>{const g=b.current;if(g.disabled||C.touches.length!==1)return;const l=C.touches[0],v=l.clientX,N=l.clientY,x=document.documentElement.clientWidth||window.innerWidth,z=Math.min(ia,Math.round(x*oa));let y=null,A=null;if(g.drawerOpen&&x<=768?(y="left",A="close"):g.outlineDrawerOpen&&x<=960&&g.outlinePosition!=="bottom"?(y="right",A="close"):!g.drawerOpen&&!g.outlineDrawerOpen&&!la(C.target)&&(v<=z&&x<=768?(y="left",A="open"):v>=x-z&&x<=960&&g.outlinePosition!=="bottom"&&(y="right",A="open")),!y)return;const M=document.querySelector(y==="left"?".sidebar":".rightbar"),U=document.querySelector(".backdrop"),Y=(M==null?void 0:M.offsetWidth)||(y==="left"?310:300);r={side:y,action:A,startX:v,startY:N,lastX:v,startTime:performance.now(),lastTime:performance.now(),locked:null,panelEl:M,backdropEl:U,width:Y}},j=C=>{if(!r||C.touches.length!==1)return;const g=C.touches[0],l=g.clientX-r.startX,v=g.clientY-r.startY;if(r.lastX=g.clientX,r.lastTime=performance.now(),!r.locked){if(Math.abs(v)>=ts&&Math.abs(v)>=Math.abs(l)){r.locked="vertical",r=null;return}if(Math.abs(l)>=ts&&Math.abs(l)>Math.abs(v)){if(!(r.side==="left"&&r.action==="open"&&l>0||r.side==="left"&&r.action==="close"&&l<0||r.side==="right"&&r.action==="open"&&l<0||r.side==="right"&&r.action==="close"&&l>0)){r=null;return}r.locked="horizontal",r.panelEl&&(r.panelEl.style.transition="none"),r.backdropEl&&(r.backdropEl.style.display="block",r.backdropEl.style.position="fixed",r.backdropEl.style.inset="0",r.backdropEl.style.zIndex="20",r.backdropEl.style.background="rgba(0, 0, 0, 0.5)",r.backdropEl.style.transition="none")}else return}r.locked==="horizontal"&&C.cancelable&&C.preventDefault();const N=r.width;let x;if(r.side==="left"?x=r.action==="open"?l/N:1+l/N:x=r.action==="open"?-l/N:1-l/N,x=Math.max(0,Math.min(1,x)),r.panelEl){const z=r.side==="left"?(x-1)*100:(1-x)*100;r.panelEl.style.transform=`translateX(${z}%)`}r.backdropEl&&(r.backdropEl.style.opacity=String(x))},f=C=>{if(!r)return;const g=r;if(r=null,g.locked!=="horizontal"){d(g);return}const l=g.lastX-g.startX,v=Math.max(1,g.lastTime-g.startTime),N=l/v;let x=!1;if(C||(g.side==="left"&&g.action==="open"?x=l>=g.width*Be||l>=qe&&N>=Ue:g.side==="left"&&g.action==="close"||g.side==="right"&&g.action==="open"?x=-l>=g.width*Be||-l>=qe&&-N>=Ue:g.side==="right"&&g.action==="close"&&(x=l>=g.width*Be||l>=qe&&N>=Ue)),d(g),!x)return;const z=b.current;g.side==="left"?g.action==="open"?(z.setOutlineDrawerOpen(!1),z.setDrawerOpen(!0)):z.setDrawerOpen(!1):g.action==="open"?z.onOpenOutline():z.setOutlineDrawerOpen(!1)},E=()=>f(!1),$=()=>f(!0);return window.addEventListener("touchstart",k,{passive:!0}),window.addEventListener("touchmove",j,{passive:!1}),window.addEventListener("touchend",E,{passive:!0}),window.addEventListener("touchcancel",$,{passive:!0}),()=>{window.removeEventListener("touchstart",k),window.removeEventListener("touchmove",j),window.removeEventListener("touchend",E),window.removeEventListener("touchcancel",$)}},[])}/**
2
+ * @license lucide-react v1.73.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const ca=s=>s==null?void 0:s.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
7
+ * @license lucide-react v1.73.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */function da(s,t,o=[]){if(t==null)throw new Error("[lucide]: iconNode is required when icon name is used");return{name:ca(s),size:24,node:t,...o.length>0?{aliases:o}:{}}}/**
12
+ * @license lucide-react v1.73.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const ha=s=>{let t="",o=!1;for(const i of s){if(i==="-"||i==="_"||i<=" "){o=t.length>0;continue}t.length===0?t+=i.toLowerCase():t+=o?i.toUpperCase():i,o=!1}return t};/**
17
+ * @license lucide-react v1.73.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const ua=s=>{const t=ha(s);return t.charAt(0).toUpperCase()+t.slice(1)};/**
22
+ * @license lucide-react v1.73.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const ot=(...s)=>s.filter((t,o,i)=>!!t&&t.trim()!==""&&i.indexOf(t)===o).join(" ").trim();/**
27
+ * @license lucide-react v1.73.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */const de={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};/**
32
+ * @license lucide-react v1.73.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */function at(s){return s!=null}function pa(s,t={}){var f,E;const o=t.attributeNames??{},i=$=>o[$]??$,a=s.size??s.width??de.width,c=s.size??s.height??de.height,p=((f=s.aliases)==null?void 0:f.filter($=>typeof $=="string"&&$.trim()!=="").map($=>`lucide-${$}`))??[],b=[...s.name?[`lucide-${s.name}`]:[],...p],r=((E=t.className)==null?void 0:E.split(" ").filter(Boolean))??[],d=t.includeDefaultClasses===!1?ot(...r):ot("lucide",...b,...r),k=t.absoluteStrokeWidth?Number(t.strokeWidth??de["stroke-width"])*Number(s.size??s.width??de.width)/Number(t.size??t.width??de.width):t.strokeWidth??de["stroke-width"];return["svg",{...Object.entries(de).reduce(($,[C,g])=>($[i(C)]=g,$),{}),..."color"in t&&t.color&&{[i("stroke")]:t.color},..."size"in t&&at(t.size)&&{[i("width")]:t.size,[i("height")]:t.size},..."width"in t&&at(t.width)&&{[i("width")]:t.width},..."height"in t&&at(t.height)&&{[i("height")]:t.height},[i("stroke-width")]:k,...d&&{[i("class")]:d},[i("viewBox")]:`0 0 ${a} ${c}`,...t.hasA11yProp===!1?{[i("aria-hidden")]:"true"}:{},..."attributes"in t&&t.attributes},s.node.map($=>{const[C,g,l]=$,v=t.nonScalingStroke?{[i("vector-effect")]:"non-scaling-stroke",...g}:g;return l?[C,v,l]:[C,v]})]}/**
37
+ * @license lucide-react v1.73.0 - ISC
38
+ *
39
+ * This source code is licensed under the ISC license.
40
+ * See the LICENSE file in the root directory of this source tree.
41
+ */function ma(s,t={}){return pa(s,{...t,attributeNames:{...t.attributeNames,class:"className","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","vector-effect":"vectorEffect"}})}/**
42
+ * @license lucide-react v1.73.0 - ISC
43
+ *
44
+ * This source code is licensed under the ISC license.
45
+ * See the LICENSE file in the root directory of this source tree.
46
+ */const fa=s=>{for(const t in s)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1},xa=u.createContext({}),ja=()=>u.useContext(xa),va=u.forwardRef(({color:s,size:t,width:o,height:i,strokeWidth:a,absoluteStrokeWidth:c,nonScalingStroke:p,className:b="",children:r,iconNode:d=[],icon:k={node:d,aliases:[],size:24},...j},f)=>{const{size:E=24,strokeWidth:$=2,absoluteStrokeWidth:C=!1,nonScalingStroke:g=!1,color:l="currentColor",className:v=""}=ja()??{},N=!!r||fa(j),[x,z,y=[]]=ma(k,{color:s??l,width:o??t??E,height:i??t??E,strokeWidth:a??$,absoluteStrokeWidth:c??C,nonScalingStroke:p??g,className:ot(v,b),hasA11yProp:N,attributes:j});return u.createElement(x,{ref:f,...z},[...y.map(([A,M])=>u.createElement(A,M)),...Array.isArray(r)?r:[r]])});/**
47
+ * @license lucide-react v1.73.0 - ISC
48
+ *
49
+ * This source code is licensed under the ISC license.
50
+ * See the LICENSE file in the root directory of this source tree.
51
+ */function R(s,t=[],o=[]){const i=typeof s=="string"?da(s,t,o):s,a=u.forwardRef(({className:c,...p},b)=>u.createElement(va,{ref:b,icon:i,className:c,...p}));return i.name&&(a.displayName=ua(i.name)),a}/**
52
+ * @license lucide-react v1.73.0 - ISC
53
+ *
54
+ * This source code is licensed under the ISC license.
55
+ * See the LICENSE file in the root directory of this source tree.
56
+ */const us={name:"arrow-up",size:24,node:[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]};us.node;const ka=R(us);/**
57
+ * @license lucide-react v1.73.0 - ISC
58
+ *
59
+ * This source code is licensed under the ISC license.
60
+ * See the LICENSE file in the root directory of this source tree.
61
+ */const ps={name:"book-open",size:24,node:[["path",{d:"M12 5v16",key:"1f6ucr"}],["path",{d:"M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z",key:"1fyvmf"}]]};ps.node;const ga=R(ps);/**
62
+ * @license lucide-react v1.73.0 - ISC
63
+ *
64
+ * This source code is licensed under the ISC license.
65
+ * See the LICENSE file in the root directory of this source tree.
66
+ */const ms={name:"chevron-left",size:24,node:[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]};ms.node;const ba=R(ms);/**
67
+ * @license lucide-react v1.73.0 - ISC
68
+ *
69
+ * This source code is licensed under the ISC license.
70
+ * See the LICENSE file in the root directory of this source tree.
71
+ */const fs={name:"chevron-right",size:24,node:[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]};fs.node;const wa=R(fs);/**
72
+ * @license lucide-react v1.73.0 - ISC
73
+ *
74
+ * This source code is licensed under the ISC license.
75
+ * See the LICENSE file in the root directory of this source tree.
76
+ */const xs={name:"copy",size:24,node:[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]};xs.node;const ns=R(xs);/**
77
+ * @license lucide-react v1.73.0 - ISC
78
+ *
79
+ * This source code is licensed under the ISC license.
80
+ * See the LICENSE file in the root directory of this source tree.
81
+ */const js={name:"ellipsis-vertical",size:24,node:[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],aliases:["more-vertical"]};js.node;const vs=R(js);/**
82
+ * @license lucide-react v1.73.0 - ISC
83
+ *
84
+ * This source code is licensed under the ISC license.
85
+ * See the LICENSE file in the root directory of this source tree.
86
+ */const ks={name:"external-link",size:24,node:[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]};ks.node;const Na=R(ks);/**
87
+ * @license lucide-react v1.73.0 - ISC
88
+ *
89
+ * This source code is licensed under the ISC license.
90
+ * See the LICENSE file in the root directory of this source tree.
91
+ */const gs={name:"folder-input",size:24,node:[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]]};gs.node;const as=R(gs);/**
92
+ * @license lucide-react v1.73.0 - ISC
93
+ *
94
+ * This source code is licensed under the ISC license.
95
+ * See the LICENSE file in the root directory of this source tree.
96
+ */const bs={name:"folder",size:24,node:[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]};bs.node;const ya=R(bs);/**
97
+ * @license lucide-react v1.73.0 - ISC
98
+ *
99
+ * This source code is licensed under the ISC license.
100
+ * See the LICENSE file in the root directory of this source tree.
101
+ */const ws={name:"git-compare",size:24,node:[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]]};ws.node;const Ns=R(ws);/**
102
+ * @license lucide-react v1.73.0 - ISC
103
+ *
104
+ * This source code is licensed under the ISC license.
105
+ * See the LICENSE file in the root directory of this source tree.
106
+ */const ys={name:"house",size:24,node:[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],aliases:["home"]};ys.node;const Cs=R(ys);/**
107
+ * @license lucide-react v1.73.0 - ISC
108
+ *
109
+ * This source code is licensed under the ISC license.
110
+ * See the LICENSE file in the root directory of this source tree.
111
+ */const Ss={name:"link-2",size:24,node:[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]};Ss.node;const Ca=R(Ss);/**
112
+ * @license lucide-react v1.73.0 - ISC
113
+ *
114
+ * This source code is licensed under the ISC license.
115
+ * See the LICENSE file in the root directory of this source tree.
116
+ */const $s={name:"menu",size:24,node:[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]]};$s.node;const Sa=R($s);/**
117
+ * @license lucide-react v1.73.0 - ISC
118
+ *
119
+ * This source code is licensed under the ISC license.
120
+ * See the LICENSE file in the root directory of this source tree.
121
+ */const Es={name:"moon",size:24,node:[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]};Es.node;const zs=R(Es);/**
122
+ * @license lucide-react v1.73.0 - ISC
123
+ *
124
+ * This source code is licensed under the ISC license.
125
+ * See the LICENSE file in the root directory of this source tree.
126
+ */const Ds={name:"panel-left",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],aliases:["sidebar"]};Ds.node;const lt=R(Ds);/**
127
+ * @license lucide-react v1.73.0 - ISC
128
+ *
129
+ * This source code is licensed under the ISC license.
130
+ * See the LICENSE file in the root directory of this source tree.
131
+ */const Ls={name:"panel-right",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]};Ls.node;const Ts=R(Ls);/**
132
+ * @license lucide-react v1.73.0 - ISC
133
+ *
134
+ * This source code is licensed under the ISC license.
135
+ * See the LICENSE file in the root directory of this source tree.
136
+ */const Ws={name:"pencil",size:24,node:[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]};Ws.node;const rt=R(Ws);/**
137
+ * @license lucide-react v1.73.0 - ISC
138
+ *
139
+ * This source code is licensed under the ISC license.
140
+ * See the LICENSE file in the root directory of this source tree.
141
+ */const Rs={name:"pin-off",size:24,node:[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]};Rs.node;const is=R(Rs);/**
142
+ * @license lucide-react v1.73.0 - ISC
143
+ *
144
+ * This source code is licensed under the ISC license.
145
+ * See the LICENSE file in the root directory of this source tree.
146
+ */const Ms={name:"pin",size:24,node:[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]};Ms.node;const ct=R(Ms);/**
147
+ * @license lucide-react v1.73.0 - ISC
148
+ *
149
+ * This source code is licensed under the ISC license.
150
+ * See the LICENSE file in the root directory of this source tree.
151
+ */const As={name:"plus",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]};As.node;const ut=R(As);/**
152
+ * @license lucide-react v1.73.0 - ISC
153
+ *
154
+ * This source code is licensed under the ISC license.
155
+ * See the LICENSE file in the root directory of this source tree.
156
+ */const _s={name:"rotate-ccw",size:24,node:[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]};_s.node;const $a=R(_s);/**
157
+ * @license lucide-react v1.73.0 - ISC
158
+ *
159
+ * This source code is licensed under the ISC license.
160
+ * See the LICENSE file in the root directory of this source tree.
161
+ */const Is={name:"search",size:24,node:[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]};Is.node;const dt=R(Is);/**
162
+ * @license lucide-react v1.73.0 - ISC
163
+ *
164
+ * This source code is licensed under the ISC license.
165
+ * See the LICENSE file in the root directory of this source tree.
166
+ */const Hs={name:"settings",size:24,node:[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]};Hs.node;const Fs=R(Hs);/**
167
+ * @license lucide-react v1.73.0 - ISC
168
+ *
169
+ * This source code is licensed under the ISC license.
170
+ * See the LICENSE file in the root directory of this source tree.
171
+ */const Ps={name:"sun",size:24,node:[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]};Ps.node;const Bs=R(Ps);/**
172
+ * @license lucide-react v1.73.0 - ISC
173
+ *
174
+ * This source code is licensed under the ISC license.
175
+ * See the LICENSE file in the root directory of this source tree.
176
+ */const Us={name:"trash",size:24,node:[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],aliases:["trash-2"]};Us.node;const Ea=R(Us);/**
177
+ * @license lucide-react v1.73.0 - ISC
178
+ *
179
+ * This source code is licensed under the ISC license.
180
+ * See the LICENSE file in the root directory of this source tree.
181
+ */const qs={name:"upload",size:24,node:[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]};qs.node;const za=R(qs);function Os(s,t){var o;for(const i of s||[]){if(i.path===t)return i;if(i.type==="dir"&&((o=i.children)!=null&&o.length)){const a=Os(i.children,t);if(a)return a}}return null}const Da=450,os=8;function ls(s){const t=u.useRef(null),o=u.useRef(null),i=u.useRef(!1),a=()=>{t.current&&(clearTimeout(t.current),t.current=null)};return{onTouchStart:c=>{if(c.touches.length!==1)return;const p=c.touches[0],b=c.currentTarget.closest(".tree-file-row")||c.currentTarget;o.current={x:p.clientX,y:p.clientY},i.current=!1,a(),t.current=setTimeout(()=>{var r;t.current=null,i.current=!0,(r=navigator.vibrate)==null||r.call(navigator,10),s(b.getBoundingClientRect())},Da)},onTouchMove:c=>{if(!t.current||!o.current||c.touches.length!==1)return;const p=c.touches[0];(Math.abs(p.clientX-o.current.x)>os||Math.abs(p.clientY-o.current.y)>os)&&a()},onTouchEnd:()=>a(),onTouchCancel:()=>a(),onContextMenu:c=>{c.preventDefault();const p=c.currentTarget.closest(".tree-file-row")||c.currentTarget;s(p.getBoundingClientRect())},consumeClick:c=>i.current?(i.current=!1,c.preventDefault(),c.stopPropagation(),!0):!1}}function ht({node:s,activePath:t,filter:o,collapsed:i,hiddenSet:a,onToggleDir:c,onSelectFile:p,onOpenMenu:b}){const r=ls(k=>b(s.path,k,"dir")),d=ls(k=>b(s.path,k,"file"));if(s.type==="dir"){if(a.has(s.path.toLowerCase())||a.has(s.name.toLowerCase()))return null;const k=f=>f.type==="file"?f.path.toLowerCase().includes(o):f.children.some(k);if(o&&!k(s))return null;const j=!o&&i.has(s.path);return e.jsxs("div",{children:[e.jsxs("div",{className:"tree-file-row",children:[e.jsxs("button",{className:"tree-dir-btn",title:s.path,onTouchStart:r.onTouchStart,onTouchMove:r.onTouchMove,onTouchEnd:r.onTouchEnd,onTouchCancel:r.onTouchCancel,onContextMenu:r.onContextMenu,onClick:f=>{r.consumeClick(f)||c(s.path)},children:[j?"▸ ":"▾ ",s.name]}),e.jsx("button",{className:"tree-row-more","aria-label":`Actions for folder ${s.name}`,onClick:f=>{f.stopPropagation(),b(s.path,f.currentTarget.getBoundingClientRect(),"dir")},children:"⋯"})]}),!j&&e.jsx("div",{className:"tree-children",children:s.children.map(f=>e.jsx(ht,{node:f,activePath:t,filter:o,collapsed:i,hiddenSet:a,onToggleDir:c,onSelectFile:p,onOpenMenu:b},f.path))})]})}return o&&!s.path.toLowerCase().includes(o)?null:e.jsxs("div",{className:`tree-file-row${s.path===t?" active":""}`,children:[e.jsx("button",{className:`tree-file${s.path===t?" active":""}`,title:s.path,onTouchStart:d.onTouchStart,onTouchMove:d.onTouchMove,onTouchEnd:d.onTouchEnd,onTouchCancel:d.onTouchCancel,onContextMenu:d.onContextMenu,onClick:k=>{d.consumeClick(k)||p(s.path)},children:s.name}),e.jsx("button",{className:"tree-row-more","aria-label":`Actions for ${s.name}`,onClick:k=>{k.stopPropagation(),b(s.path,k.currentTarget.getBoundingClientRect())},children:"⋯"})]})}function La({drawerOpen:s,live:t,settings:o,setSettings:i,sidebarTab:a,setSidebarTab:c,gitChanges:p,searchRef:b,filter:r,setFilter:d,tree:k,pinned:j=[],activePath:f,collapsed:E,hiddenSet:$,toggleDir:C,setViewMode:g,openFile:l,openRowMenu:v,changesSort:N,setChangesSort:x,openCommitDialog:z,sortedChanges:y,loadDiff:A}){const[M,U]=u.useState(!0),[Y,be]=u.useState(()=>new Set),ue=D=>{be(q=>{const K=new Set(q);return K.has(D)?K.delete(D):K.add(D),K})},G=j.map(D=>Os(k,D.path)).filter(Boolean);return e.jsxs("aside",{className:`sidebar${s?" open":""}`,children:[e.jsxs("div",{className:"brand",children:[e.jsxs("div",{className:"brand-title",children:[e.jsx("img",{src:"/vault-logo.svg",alt:"",width:"20",height:"20",className:"brand-logo"}),e.jsx("span",{children:"Vault"}),e.jsx("span",{className:`pill${t?"":" off"}`,children:t?"Live":"Reconnecting"})]}),e.jsx("button",{className:"icon-btn","aria-label":o.theme==="dark"?"Switch to light theme":"Switch to dark theme",title:o.theme==="dark"?"Switch to light theme":"Switch to dark theme",onClick:()=>i(D=>({...D,theme:D.theme==="dark"?"light":"dark"})),children:o.theme==="dark"?e.jsx(Bs,{size:15,strokeWidth:1.9}):e.jsx(zs,{size:15,strokeWidth:1.9})})]}),e.jsxs("div",{className:"sidebar-tabs",children:[e.jsx("button",{className:`sidebar-tab${a==="files"?" active":""}`,onClick:()=>c("files"),children:"Files"}),e.jsxs("button",{className:`sidebar-tab${a==="changes"?" active":""}`,onClick:()=>c("changes"),children:[e.jsx("span",{children:"Changes"}),p.length>0&&e.jsx("span",{className:"pill",children:p.length})]})]}),e.jsx("div",{className:"search-wrap",children:e.jsx("input",{ref:b,className:"search",type:"search",placeholder:a==="files"?"Filter files... (/)":"Filter changes...",value:r,onChange:D=>d(D.target.value.trim().toLowerCase())})}),e.jsx("div",{className:"tree",children:a==="files"?e.jsxs(e.Fragment,{children:[G.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pinned-section",children:[e.jsxs("button",{type:"button",className:"pinned-toggle","aria-expanded":M,onClick:()=>U(D=>!D),children:[e.jsx("span",{className:"chev",children:M?"▾":"▸"}),e.jsx(ct,{size:12,strokeWidth:2,className:"pinned-icon","aria-hidden":"true"}),e.jsx("span",{children:"Pinned"}),e.jsx("span",{className:"pinned-count",children:G.length})]}),M&&e.jsx("div",{className:"pinned-list",children:G.map(D=>e.jsx(ht,{node:D,activePath:f,filter:r,collapsed:Y,hiddenSet:$,onToggleDir:ue,onSelectFile:q=>{g("preview"),l(q)},onOpenMenu:v},`pinned:${D.path}`))})]}),e.jsx("div",{className:"tree-section-divider",children:e.jsx("span",{children:"All files"})})]}),k.map(D=>e.jsx(ht,{node:D,activePath:f,filter:r,collapsed:E,hiddenSet:$,onToggleDir:C,onSelectFile:q=>{g("preview"),l(q)},onOpenMenu:v},D.path))]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"changes-bar",children:[e.jsxs("select",{className:"changes-select","aria-label":"Sort changes",value:N,onChange:D=>x(D.target.value),children:[e.jsx("option",{value:"path",children:"Sort: Path"}),e.jsx("option",{value:"recent",children:"Sort: Recent"}),e.jsx("option",{value:"status",children:"Sort: Status"})]}),p.length>0&&e.jsx("button",{className:"btn primary",onClick:z,children:"Commit"})]}),y.length===0?e.jsx("div",{className:"empty-note",style:{padding:"10px 8px"},children:"Working tree clean"}):y.map(D=>e.jsxs("div",{className:`tree-file-row${D.path===f?" active":""}`,children:[e.jsxs("button",{className:`tree-file${D.path===f?" active":""}`,title:D.path,onClick:()=>{D.status!=="D"&&(g("diff"),l(D.path),A(D.path))},children:[e.jsx("span",{className:`git-badge git-${D.status}`,children:D.status}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:D.path})]}),e.jsx("button",{className:"tree-row-more","aria-label":`Actions for ${D.path}`,onClick:q=>{q.stopPropagation(),v(D.path,q.currentTarget.getBoundingClientRect())},children:"⋯"})]},D.path))]})})]})}function Ta({tabs:s,activeTabId:t,switchTab:o,closeTab:i,createNewTab:a}){return e.jsxs("div",{className:"desktop-tabs",children:[s.map(c=>e.jsxs("div",{className:`desktop-tab${c.id===t?" active":""}`,onClick:()=>o(c),children:[e.jsx("span",{className:"desktop-tab-title",children:c.title}),e.jsx("button",{className:"desktop-tab-close",onClick:p=>i(c.id,p),children:"×"})]},c.id)),e.jsx("button",{className:"desktop-tab-add",title:"New tab",onClick:a,children:"+"})]})}function Wa({setDrawerOpen:s,activePath:t,moreMenuOpen:o,setMoreMenuOpen:i,viewMode:a,setViewMode:c,loadDiff:p,setDeleteError:b,setDeleteTarget:r,outlinePosition:d,outlineDrawerOpen:k,onToggleOutline:j,onOpenOutline:f}){const E=k||d!=="hidden";return e.jsxs("div",{className:"topbar",children:[e.jsxs("div",{className:"topbar-left",children:[e.jsx("button",{className:"icon-btn menu-btn","aria-label":"Toggle files",onClick:()=>s($=>!$),children:e.jsx(lt,{size:17,strokeWidth:1.8})}),e.jsx("div",{className:"crumbs",children:t||"New tab"})]}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{className:`icon-btn outline-toggle-btn${E?" active":""}`,"aria-label":"Toggle outline",title:"Toggle outline & backlinks",onClick:j,children:e.jsx(Ts,{size:17,strokeWidth:1.8})}),e.jsx("button",{className:"icon-btn","aria-label":"Note options",title:"Note options",onClick:()=>i($=>!$),children:e.jsx(vs,{size:16,strokeWidth:1.9})}),o&&e.jsxs("div",{className:"more-menu",onMouseLeave:()=>i(!1),children:[t&&e.jsx("a",{className:"more-item",href:`/api/v1/file?path=${encodeURIComponent(t)}&download=1`,download:t.split("/").pop(),style:{textDecoration:"none",borderBottom:"1px solid var(--border)",marginBottom:3,paddingBottom:9},onClick:()=>i(!1),children:e.jsx("span",{children:"Download"})}),e.jsxs("button",{className:`more-item${a==="preview"?" active":""}`,onClick:()=>{c("preview"),i(!1)},children:[e.jsx("span",{children:"Preview"}),a==="preview"&&e.jsx("span",{children:"✓"})]}),e.jsxs("button",{className:`more-item${a==="edit"?" active":""}`,onClick:()=>{c("edit"),i(!1)},children:[e.jsx("span",{children:"Edit"}),a==="edit"&&e.jsx("span",{children:"✓"})]}),e.jsxs("button",{className:`more-item${a==="diff"?" active":""}`,onClick:()=>{c("diff"),i(!1),p(t)},children:[e.jsx("span",{children:"Diff"}),a==="diff"&&e.jsx("span",{children:"✓"})]}),e.jsxs("button",{className:`more-item${a==="raw"?" active":""}`,onClick:()=>{c("raw"),i(!1)},children:[e.jsx("span",{children:"Raw"}),a==="raw"&&e.jsx("span",{children:"✓"})]}),e.jsx("button",{className:`more-item outline-menu-trigger${d==="hidden"?" show-desktop":""}`,style:{borderTop:"1px solid var(--border)",marginTop:3,paddingTop:9},onClick:()=>{i(!1),f()},children:e.jsx("span",{children:"Outline"})}),t&&e.jsx("button",{className:"more-item",style:{color:"#f87171",borderTop:"1px solid var(--border)",marginTop:3,paddingTop:9},onClick:()=>{i(!1),b(""),r(t)},children:e.jsx("span",{children:"Delete"})})]})]})]})}function Ra(s,t=","){const o=[];let i=[],a="",c=!1;for(let p=0;p<s.length;p+=1){const b=s[p];if(c){b==='"'?s[p+1]==='"'?(a+='"',p+=1):c=!1:a+=b;continue}b==='"'?c=!0:b===t?(i.push(a),a=""):b==="\r"?(s[p+1]===`
182
+ `&&(p+=1),i.push(a),o.push(i),i=[],a=""):b===`
183
+ `?(i.push(a),o.push(i),i=[],a=""):a+=b}return(a.length>0||i.length>0)&&(i.push(a),o.push(i)),o}function Ma({content:s,fileKey:t,fontSize:o,lineHeight:i,maxWidth:a,saving:c,dirty:p,onChange:b,onSave:r}){const d=Gn({extensions:[Jn,Yn],content:s});return u.useEffect(()=>{var j,f;if(!d)return;(((f=(j=d.storage.markdown)==null?void 0:j.getMarkdown)==null?void 0:f.call(j))??"")!==s&&!p&&d.commands.setContent(s)},[t,s,d,p]),u.useEffect(()=>{if(!d)return;const k=()=>{var f,E;const j=((E=(f=d.storage.markdown)==null?void 0:f.getMarkdown)==null?void 0:E.call(f))??"";b(j)};return d.on("update",k),()=>d.off("update",k)},[d,b]),d?e.jsxs("div",{className:"tiptap-wrap",style:{maxWidth:`${a}px`},children:[e.jsxs("div",{className:"tiptap-toolbar",children:[e.jsx("button",{className:`btn${d.isActive("bold")?" active":""}`,onClick:()=>d.chain().focus().toggleBold().run(),children:"B"}),e.jsx("button",{className:`btn${d.isActive("italic")?" active":""}`,onClick:()=>d.chain().focus().toggleItalic().run(),children:"I"}),e.jsx("button",{className:`btn${d.isActive("heading",{level:1})?" active":""}`,onClick:()=>d.chain().focus().toggleHeading({level:1}).run(),children:"H1"}),e.jsx("button",{className:`btn${d.isActive("heading",{level:2})?" active":""}`,onClick:()=>d.chain().focus().toggleHeading({level:2}).run(),children:"H2"}),e.jsx("button",{className:`btn${d.isActive("bulletList")?" active":""}`,onClick:()=>d.chain().focus().toggleBulletList().run(),children:"List"}),e.jsx("button",{className:`btn${d.isActive("codeBlock")?" active":""}`,onClick:()=>d.chain().focus().toggleCodeBlock().run(),children:"Code"}),e.jsx("button",{className:`btn${p?" primary":""}`,style:{marginLeft:"auto"},disabled:c,onClick:()=>{var k,j;return r(((j=(k=d.storage.markdown)==null?void 0:k.getMarkdown)==null?void 0:j.call(k))??"")},children:c?"Saving...":p?"Save *":"Saved"})]}),e.jsx("div",{className:"doc tiptap-body",style:{fontSize:`${o}px`,lineHeight:i},children:e.jsx(Kn,{editor:d})})]}):null}function Aa({scrollRef:s,activePath:t,openNewNoteDialog:o,openFile:i,openSwitcher:a,setDrawerOpen:c,setSettingsOpen:p,isImg:b,isSvg:r,isMarkdown:d,isPdf:k,isAudio:j,isVideo:f,isHtml:E,isCsv:$,reloadTick:C,isBinaryDownload:g,viewMode:l,settings:v,diffData:N,requestDiscard:x,content:z,saving:y,dirty:A,setDraftContent:M,setDirty:U,saveActiveNote:Y,highlightedRawHtml:be,handleDocClick:ue,renderedHtml:G}){var oe,Se;const D=u.useMemo(()=>{if(!$||l!=="preview"||!z)return[];const P=t.toLowerCase().endsWith(".tsv")?" ":",";return Ra(z,P)},[$,l,z,t]),q=t?`/api/v1/file?path=${encodeURIComponent(t)}&t=${C}`:"",K=t?`/api/v1/file?path=${encodeURIComponent(t)}&download=1`:"",ie=t?`/raw/${t.split("/").map(encodeURIComponent).join("/")}?t=${C}`:"";return e.jsx("div",{ref:s,className:"content-scroll",children:t?b&&!(r&&l==="raw")?e.jsx("div",{className:"doc img-wrap",children:e.jsx("img",{src:q,alt:t})}):k?e.jsxs("div",{className:"media-viewer pdf-viewer",children:[e.jsxs("div",{className:"media-bar",children:[e.jsx("span",{children:t.split("/").pop()}),e.jsx("a",{className:"btn",href:K,download:t.split("/").pop(),children:"Download PDF"})]}),e.jsx("iframe",{className:"pdf-frame",src:q,title:t})]}):j?e.jsxs("div",{className:"doc binary-card audio-viewer",children:[e.jsx("div",{className:"binary-card-name",children:t.split("/").pop()}),e.jsx("div",{className:"binary-card-path",children:t}),e.jsx("audio",{controls:!0,src:q,style:{width:"100%",maxWidth:460}}),e.jsx("a",{className:"btn",href:K,download:t.split("/").pop(),style:{textDecoration:"none",display:"inline-flex",alignItems:"center",gap:6,marginTop:12},children:"Download audio"})]}):f?e.jsxs("div",{className:"media-viewer video-viewer",children:[e.jsxs("div",{className:"media-bar",children:[e.jsx("span",{children:t.split("/").pop()}),e.jsx("a",{className:"btn",href:K,download:t.split("/").pop(),children:"Download video"})]}),e.jsx("video",{controls:!0,src:q,className:"video-player"})]}):g?e.jsxs("div",{className:"doc binary-card",children:[e.jsx("div",{className:"binary-card-name",children:t.split("/").pop()}),e.jsx("div",{className:"binary-card-path",children:t}),e.jsx("a",{className:"btn primary",href:`/api/v1/file?path=${encodeURIComponent(t)}&download=1`,download:t.split("/").pop(),style:{textDecoration:"none",display:"inline-flex",alignItems:"center",gap:6},children:"Download file"})]}):l==="diff"?e.jsxs("div",{className:"diff-wrap",style:{maxWidth:`${v.maxWidth+80}px`},children:[e.jsxs("div",{className:"diff-head",children:[e.jsx("span",{style:{fontSize:13,color:"var(--muted)"},children:N!=null&&N.untracked?"Untracked file":`${((oe=N==null?void 0:N.hunks)==null?void 0:oe.length)||0} hunk(s)`}),((Se=N==null?void 0:N.hunks)==null?void 0:Se.length)>0&&e.jsx("button",{className:"btn",style:{color:"#f87171"},onClick:()=>x(),children:"Discard file"})]}),!N||N.hunks.length===0?e.jsx("div",{className:"empty-note",children:"No uncommitted changes for this file."}):N.hunks.map((P,ee)=>e.jsxs("div",{className:"diff-hunk",children:[e.jsxs("div",{className:"diff-hunk-bar",children:[e.jsx("span",{children:P.header}),!N.untracked&&e.jsx("button",{className:"btn",onClick:()=>x({hunkIndex:ee}),children:"Discard hunk"})]}),P.lines.map((X,F)=>e.jsxs("div",{className:`diff-line ${X.type}`,children:[e.jsx("span",{className:"diff-ln",children:X.newLine??X.oldLine??""}),e.jsx("span",{className:"diff-sig",children:X.type==="add"?"+":X.type==="del"?"-":" "}),e.jsx("span",{className:"diff-txt",children:X.text||" "}),!N.untracked&&X.type!=="context"?e.jsx("button",{className:"diff-discard-btn",title:"Discard line",onClick:()=>x({hunkIndex:ee,lineIndex:F,previewText:`${X.type==="add"?"+":"-"} ${X.text}`}),children:"↺"}):e.jsx("span",{})]},F))]},ee))]}):l==="edit"&&d?e.jsx(Ma,{fileKey:t,content:z,fontSize:v.fontSize,lineHeight:v.lineHeight,maxWidth:v.maxWidth,saving:y,dirty:A,onChange:P=>{M(P),U(P!==z)},onSave:Y}):E&&l==="preview"?e.jsx("div",{className:"media-viewer html-viewer",children:e.jsx("iframe",{className:"html-frame",src:ie,sandbox:"allow-scripts",title:t})}):$&&l==="preview"?e.jsx("div",{className:"doc csv-wrap",style:{fontSize:`${Math.max(12,v.fontSize-1)}px`,maxWidth:`${v.maxWidth+160}px`},children:D.length===0?e.jsx("div",{className:"empty-note",children:"Empty table."}):e.jsx("div",{className:"csv-scroll",children:e.jsxs("table",{children:[e.jsx("thead",{children:e.jsx("tr",{children:D[0].map((P,ee)=>e.jsx("th",{children:P},ee))})}),e.jsx("tbody",{children:D.slice(1).map((P,ee)=>e.jsx("tr",{children:D[0].map((X,F)=>e.jsx("td",{children:P[F]??""},F))},ee))})]})})}):l==="raw"||!d?e.jsx("pre",{className:"raw-view",style:{fontSize:`${Math.max(12,v.fontSize-2)}px`,maxWidth:`${v.maxWidth+80}px`},children:e.jsx("code",{className:"hljs",dangerouslySetInnerHTML:{__html:be}})}):e.jsx("div",{className:"doc",style:{fontSize:`${v.fontSize}px`,lineHeight:v.lineHeight,maxWidth:`${v.maxWidth}px`},onClick:ue,dangerouslySetInnerHTML:{__html:G}}):e.jsxs("div",{className:"new-tab-view",children:[e.jsxs("button",{className:"new-tab-btn",onClick:()=>o(""),children:[e.jsx(ut,{size:16,strokeWidth:1.9}),e.jsx("span",{children:"Create new note"})]}),e.jsxs("button",{className:"new-tab-btn",onClick:()=>i("README.md"),children:[e.jsx(Cs,{size:16,strokeWidth:1.9}),e.jsx("span",{children:"Go to README"})]}),e.jsxs("button",{className:"new-tab-btn",onClick:a,children:[e.jsx(dt,{size:16,strokeWidth:1.9}),e.jsx("span",{children:"Go to file"})]}),e.jsxs("button",{className:"new-tab-btn",onClick:()=>c(!0),children:[e.jsx(ya,{size:16,strokeWidth:1.9}),e.jsx("span",{children:"Browse files"})]}),e.jsxs("button",{className:"new-tab-btn",onClick:()=>p(!0),children:[e.jsx(Fs,{size:16,strokeWidth:1.9}),e.jsx("span",{children:"Settings"})]})]})})}function _a({headings:s,isImg:t,isBinaryDownload:o,viewMode:i,currentBacklinks:a,openFile:c,position:p="right",onChangePosition:b,mobileOpen:r=!1,onCloseMobile:d}){const[k,j]=u.useState(!1);if(p==="hidden"&&!r&&window.innerWidth>960)return null;const f=t?"Image preview":o?"Binary file":i==="raw"?"Raw view":i==="edit"?"Edit mode":i==="diff"?"Diff mode":"No headings";return e.jsxs("aside",{className:`rightbar${r?" mobile-open":""}`,children:[e.jsxs("div",{className:"rightbar-head",children:[e.jsx("div",{className:"panel-title",style:{margin:0},children:p==="bottom"?"Outline & Backlinks":"Outline"}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{className:"icon-btn","aria-label":"Outline panel options",title:"Outline panel options",onClick:()=>j(E=>!E),children:e.jsx(vs,{size:16,strokeWidth:1.9})}),k&&e.jsxs("div",{className:"more-menu",onMouseLeave:()=>j(!1),children:[e.jsxs("button",{className:`more-item${p==="right"?" active":""}`,onClick:()=>{b("right"),j(!1)},children:[e.jsx("span",{children:"Position: Right"}),p==="right"&&e.jsx("span",{children:"✓"})]}),e.jsxs("button",{className:`more-item${p==="bottom"?" active":""}`,onClick:()=>{b("bottom"),d==null||d(),j(!1)},children:[e.jsx("span",{children:"Position: Bottom"}),p==="bottom"&&e.jsx("span",{children:"✓"})]}),e.jsx("button",{className:"more-item",style:{borderTop:"1px solid var(--border)",marginTop:2,paddingTop:8},onClick:()=>{window.innerWidth<=960&&r?d==null||d():b("hidden"),j(!1)},children:e.jsx("span",{children:"Hide panel"})})]})]})]}),e.jsxs("div",{className:"rightbar-body",children:[e.jsxs("div",{className:"rightbar-sec",children:[e.jsx("div",{className:"panel-subtitle",children:"Outline"}),s.length===0?e.jsx("div",{className:"empty-note",children:f}):s.map((E,$)=>e.jsx("a",{className:`toc-item toc-h${E.level}`,onClick:()=>{var C;(C=document.getElementById(E.id))==null||C.scrollIntoView({behavior:"smooth"}),d==null||d()},children:E.text},`${E.id}-${$}`))]}),e.jsxs("div",{className:"rightbar-sec",children:[e.jsx("div",{className:"panel-title backlinks-title",children:"Backlinks"}),a.length===0?e.jsx("div",{className:"empty-note",children:"No backlinks yet"}):a.map(E=>e.jsx("a",{className:"backlink-item",onClick:()=>{c(E),d==null||d()},children:E},E))]})]})]})}function Ia({fabOpen:s,setFabOpen:t,openSwitcher:o,drawerOpen:i,setDrawerOpen:a,openFile:c,viewMode:p,setViewMode:b,settings:r,setSettings:d,setSettingsOpen:k,scrollRef:j,loadDiff:f,activePath:E,createNewTab:$,tabsOpen:C,setTabsOpen:g,tabs:l,activeTabId:v,switchTab:N,closeTab:x,onToggleOutline:z}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"fab-wrap",children:[s&&e.jsxs("div",{className:"fab-menu",children:[e.jsx("button",{className:"fab-item",onClick:()=>{t(!1),o()},children:"🔍 Quick switcher"}),e.jsx("button",{className:"fab-item",onClick:()=>{t(!1),a(y=>!y)},children:"📁 Toggle files"}),e.jsx("button",{className:"fab-item",onClick:()=>{t(!1),z==null||z()},children:"📑 Toggle outline"}),e.jsx("button",{className:"fab-item",onClick:()=>{t(!1),c("README.md")},children:"🏠 Home (README)"}),e.jsx("button",{className:"fab-item",onClick:()=>{t(!1),b(y=>y==="raw"?"preview":"raw")},children:p==="raw"?"📄 Preview mode":"🧾 Raw view"}),e.jsx("button",{className:"fab-item",onClick:()=>{t(!1),d(y=>({...y,theme:y.theme==="dark"?"light":"dark"}))},children:r.theme==="dark"?"☀️ Light theme":"🌙 Dark theme"}),e.jsx("button",{className:"fab-item",onClick:()=>{t(!1),k(!0)},children:"⚙️ Settings"}),e.jsx("button",{className:"fab-item",onClick:()=>{var y;t(!1),(y=j.current)==null||y.scrollTo({top:0,behavior:"smooth"})},children:"⬆️ Scroll to top"})]}),e.jsx("button",{className:"fab-btn","aria-label":"Quick actions",onClick:()=>t(y=>!y),children:s?"×":"+"})]}),s&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sheet-backdrop",onClick:()=>t(!1)}),e.jsxs("div",{className:"bottom-sheet",role:"dialog","aria-label":"Quick actions",children:[e.jsx("div",{className:"sheet-handle"}),e.jsxs("div",{className:"sheet-list",children:[e.jsxs("button",{className:"sheet-item",onClick:()=>{t(!1),o()},children:[e.jsx(dt,{size:18,strokeWidth:1.9}),e.jsx("span",{children:"Open quick switcher"})]}),e.jsxs("button",{className:"sheet-item",onClick:()=>{t(!1),a(y=>!y)},children:[e.jsx(lt,{size:18,strokeWidth:1.9}),e.jsx("span",{children:"Toggle files sidebar"})]}),e.jsxs("button",{className:"sheet-item",onClick:()=>{t(!1),z==null||z()},children:[e.jsx(Ts,{size:18,strokeWidth:1.9}),e.jsx("span",{children:"Toggle outline sidebar"})]}),e.jsxs("button",{className:"sheet-item",onClick:()=>{t(!1),c("README.md")},children:[e.jsx(Cs,{size:18,strokeWidth:1.9}),e.jsx("span",{children:"Go to Home (README)"})]}),e.jsxs("button",{className:"sheet-item",onClick:()=>{t(!1),b(y=>y==="edit"?"preview":"edit")},children:[e.jsx(rt,{size:18,strokeWidth:1.9}),e.jsx("span",{children:p==="edit"?"Switch to Preview mode":"Switch to Edit mode"})]}),e.jsxs("button",{className:"sheet-item",onClick:()=>{t(!1),b("diff"),f(E)},children:[e.jsx(Ns,{size:18,strokeWidth:1.9}),e.jsx("span",{children:"View Git Diff"})]}),e.jsxs("button",{className:"sheet-item",onClick:()=>{t(!1),b(y=>y==="raw"?"preview":"raw")},children:[e.jsx(ga,{size:18,strokeWidth:1.9}),e.jsx("span",{children:p==="raw"?"Switch to Preview mode":"Switch to Raw view"})]}),e.jsxs("button",{className:"sheet-item",onClick:()=>{var y;t(!1),(y=j.current)==null||y.scrollTo({top:0,behavior:"smooth"})},children:[e.jsx(ka,{size:18,strokeWidth:1.9}),e.jsx("span",{children:"Scroll to top"})]}),e.jsxs("button",{className:"sheet-item",onClick:()=>{t(!1),d(y=>({...y,theme:y.theme==="dark"?"light":"dark"}))},children:[r.theme==="dark"?e.jsx(Bs,{size:18,strokeWidth:1.9}):e.jsx(zs,{size:18,strokeWidth:1.9}),e.jsx("span",{children:r.theme==="dark"?"Switch to Light theme":"Switch to Dark theme"})]}),e.jsxs("button",{className:"sheet-item",onClick:()=>{t(!1),k(!0)},children:[e.jsx(Fs,{size:18,strokeWidth:1.9}),e.jsx("span",{children:"Settings"})]})]})]})]}),e.jsxs("nav",{className:"mobile-bar","aria-label":"Mobile quick actions",children:[e.jsx("button",{className:`mobile-bar-btn${i?" active":""}`,"aria-label":"Files",onClick:()=>{t(!1),a(y=>!y)},children:e.jsx(lt,{size:19,strokeWidth:1.9})}),e.jsx("button",{className:"mobile-bar-btn","aria-label":"Back",onClick:()=>window.history.back(),children:e.jsx(ba,{size:19,strokeWidth:1.9})}),e.jsx("button",{className:"mobile-bar-btn","aria-label":"Forward",onClick:()=>window.history.forward(),children:e.jsx(wa,{size:19,strokeWidth:1.9})}),e.jsx("button",{className:"mobile-bar-btn","aria-label":"Search",onClick:()=>{t(!1),o()},children:e.jsx(dt,{size:19,strokeWidth:1.9})}),e.jsx("button",{className:"mobile-bar-btn","aria-label":"New tab",onClick:$,children:e.jsx(ut,{size:19,strokeWidth:1.9})}),e.jsx("button",{className:`mobile-bar-btn${C?" active":""}`,"aria-label":"Open tabs",onClick:()=>{t(!1),g(!0)},children:e.jsx("span",{className:"tabs-count-badge",children:l.length})}),e.jsx("button",{className:`mobile-bar-btn${s?" active":""}`,"aria-label":"Menu",onClick:()=>t(y=>!y),children:e.jsx(Sa,{size:19,strokeWidth:1.9})})]}),C&&e.jsxs("div",{className:"tabs-overlay",onClick:()=>g(!1),children:[e.jsx("div",{className:"tabs-grid",onClick:y=>y.stopPropagation(),children:l.map(y=>e.jsxs("div",{className:"tab-card-wrap",children:[e.jsxs("div",{className:`tab-card${y.id===v?" active":""}`,onClick:()=>N(y),children:[e.jsx("button",{className:"tab-card-close","aria-label":"Close tab",onClick:A=>x(y.id,A),children:"×"}),e.jsx("div",{className:"tab-card-title",children:y.title}),e.jsx("div",{className:"tab-card-preview",children:y.preview||(y.path?y.path:"Empty tab")})]}),e.jsx("div",{className:"tab-card-label",children:y.title})]},y.id))}),e.jsxs("div",{className:"tabs-footer",onClick:y=>y.stopPropagation(),children:[e.jsx("button",{className:"tabs-footer-btn","aria-label":"New tab",onClick:$,children:"+"}),e.jsxs("span",{style:{fontSize:14,fontWeight:600},children:[l.length," ",l.length===1?"tab":"tabs"]}),e.jsx("button",{className:"tabs-footer-btn",onClick:()=>g(!1),children:"Done"})]})]})]})}function Ha({switcherOpen:s,setSwitcherOpen:t,switcherTab:o,setSwitcherTab:i,switcherIdx:a,setSwitcherIdx:c,switcherInputRef:p,totalFiles:b,fileStats:r,switcherItems:d,switcherData:k,openFile:j,isLargeVault:f,pagedFiles:E,loadMorePagedFiles:$,switcherQuery:C,setSwitcherQuery:g}){return s?e.jsx("div",{className:"switcher-backdrop",onClick:()=>t(!1),children:e.jsxs("div",{className:"switcher",onClick:l=>l.stopPropagation(),children:[e.jsxs("div",{className:"switcher-head",children:[e.jsxs("div",{className:"switcher-tabs",children:[e.jsx("button",{className:`switcher-tab${o==="recent"?" active":""}`,onClick:()=>{var l;i("recent"),c(0),(l=p.current)==null||l.focus()},children:"Recent"}),e.jsx("button",{className:`switcher-tab${o==="alpha"?" active":""}`,onClick:()=>{var l;i("alpha"),c(0),(l=p.current)==null||l.focus()},children:"A–Z"})]}),b>r.length&&e.jsxs("span",{className:"switcher-cap",children:[r.length.toLocaleString()," / ",b.toLocaleString()," indexed"]})]}),e.jsxs("div",{className:"switcher-list",children:[d.length===0?e.jsx("div",{className:"empty-note",style:{padding:"12px"},children:"No matching notes"}):(()=>{let l=0;const v=Date.now(),N=x=>{if(!x)return"";const z=Math.max(0,v-x);return z<6e4?"now":z<36e5?`${Math.floor(z/6e4)}m`:z<864e5?`${Math.floor(z/36e5)}h`:z<7*864e5?`${Math.floor(z/864e5)}d`:new Date(x).toLocaleDateString(void 0,{month:"short",day:"numeric"})};return k.groups.map(x=>e.jsxs(On.Fragment,{children:[x.label&&e.jsx("div",{className:"switcher-group-title",children:x.label}),x.items.map(z=>{const y=l++;return e.jsxs("button",{className:`switcher-item${y===a?" selected":""}`,onClick:()=>{t(!1),j(z.path)},children:[e.jsxs("div",{className:"switcher-row-top",children:[e.jsx("span",{className:"switcher-path",children:z.path}),z.mtimeMs>0&&e.jsx("span",{className:"switcher-time",children:N(z.mtimeMs)})]}),z.snippet&&e.jsx("span",{className:"switcher-snippet",children:z.snippet})]},z.path)})]},x.label||"all"))})(),f&&E.hasMore&&e.jsx("button",{className:"btn",style:{margin:"8px auto",display:"block"},onClick:$,children:"Load more"})]}),e.jsxs("div",{className:"switcher-input-wrap",children:[e.jsx("input",{ref:p,className:"switcher-input",type:"text",placeholder:"Find a note...",value:C,onChange:l=>{g(l.target.value),c(0)},onKeyDown:l=>{l.key==="ArrowDown"?(l.preventDefault(),c(v=>Math.min(v+1,Math.max(0,d.length-1)))):l.key==="ArrowUp"?(l.preventDefault(),c(v=>Math.max(v-1,0))):l.key==="Enter"&&d[a]&&(l.preventDefault(),t(!1),j(d[a].path))}}),e.jsx("button",{className:"switcher-clear","aria-label":"Clear or close",onClick:()=>C?g(""):t(!1),children:"×"})]})]})}):null}function O({icon:s}){return e.jsx(s,{className:"file-ctx-menu-icon",size:14,strokeWidth:1.9,"aria-hidden":"true"})}function Fa({fileMenu:s,setFileMenu:t,openNewNoteDialog:o,uploadDirRef:i,uploadInputRef:a,setRenameError:c,setRenameTarget:p,setMoveError:b,setMoveTarget:r,openInNewTab:d,gitChanges:k,loadDiff:j,requestDiscard:f,setDeleteError:E,setDeleteTarget:$,isPinned:C,togglePin:g}){return s?e.jsx("div",{style:{position:"fixed",inset:0,zIndex:59},onClick:()=>t(null),children:e.jsx("div",{className:"file-ctx-menu",style:{left:s.x,top:s.y,maxHeight:`calc(100dvh - ${s.y+8}px)`},onClick:l=>l.stopPropagation(),children:s.type==="dir"?e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"more-item",onClick:()=>{const l=s.path;t(null),o(l)},children:[e.jsx(O,{icon:ut}),e.jsx("span",{children:"New note here"})]}),e.jsxs("button",{className:"more-item",onClick:()=>{var l;i.current=s.path,t(null),(l=a.current)==null||l.click()},children:[e.jsx(O,{icon:za}),e.jsx("span",{children:"Upload file..."})]}),e.jsxs("button",{className:"more-item",onClick:()=>{const l=s.path,v=l.split("/"),N=v.pop()||"",x=v.join("/");t(null),c(""),p({type:"dir",oldPath:l,parentDir:x,newName:N})},children:[e.jsx(O,{icon:rt}),e.jsx("span",{children:"Rename"})]}),e.jsxs("button",{className:"more-item",onClick:()=>{const l=s.path,v=l.split("/"),N=v.pop()||"",x=v.join("/");t(null),b(""),r({type:"dir",oldPath:l,name:N,destFolder:x})},children:[e.jsx(O,{icon:as}),e.jsx("span",{children:"Move"})]}),e.jsxs("button",{className:"more-item",onClick:()=>{const l=s.path,v=s.type;t(null),g(l,v)},children:[e.jsx(O,{icon:C(s.path)?is:ct}),e.jsx("span",{children:C(s.path)?"Unpin":"Pin"})]}),e.jsxs("button",{className:"more-item",onClick:()=>{var l;(l=navigator.clipboard)==null||l.writeText(s.path),t(null)},children:[e.jsx(O,{icon:ns}),e.jsx("span",{children:"Copy path"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"more-item",onClick:()=>{const l=s.path;t(null),d(l,"preview")},children:[e.jsx(O,{icon:Na}),e.jsx("span",{children:"Open in new tab"})]}),e.jsxs("button",{className:"more-item",onClick:()=>{const l=s.path,v=s.type;t(null),g(l,v)},children:[e.jsx(O,{icon:C(s.path)?is:ct}),e.jsx("span",{children:C(s.path)?"Unpin":"Pin"})]}),e.jsxs("button",{className:"more-item",onClick:()=>{const l=s.path,v=l.split("/"),N=v.pop()||"",x=v.join("/");t(null),c(""),p({type:"file",oldPath:l,parentDir:x,newName:N})},children:[e.jsx(O,{icon:rt}),e.jsx("span",{children:"Rename"})]}),e.jsxs("button",{className:"more-item",onClick:()=>{const l=s.path,v=l.split("/"),N=v.pop()||"",x=v.join("/");t(null),b(""),r({type:"file",oldPath:l,name:N,destFolder:x})},children:[e.jsx(O,{icon:as}),e.jsx("span",{children:"Move"})]}),e.jsxs("button",{className:"more-item",onClick:()=>{var l;(l=navigator.clipboard)==null||l.writeText(s.path),t(null)},children:[e.jsx(O,{icon:ns}),e.jsx("span",{children:"Copy path"})]}),s.path.endsWith(".md")&&e.jsxs("button",{className:"more-item",onClick:()=>{var l;(l=navigator.clipboard)==null||l.writeText(`[[${s.path.replace(/\.md$/i,"")}]]`),t(null)},children:[e.jsx(O,{icon:Ca}),e.jsx("span",{children:"Copy [[wikilink]]"})]}),k.some(l=>l.path===s.path)&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"more-item",onClick:()=>{const l=s.path;t(null),setViewMode("diff"),openFile(l),j(l)},children:[e.jsx(O,{icon:Ns}),e.jsx("span",{children:"View Diff"})]}),e.jsxs("button",{className:"more-item",style:{color:"var(--amber)"},onClick:()=>{const l=s.path;t(null),f({path:l})},children:[e.jsx(O,{icon:$a}),e.jsx("span",{children:"Discard changes"})]})]}),e.jsxs("button",{className:"more-item",style:{color:"#f87171",borderTop:"1px solid var(--border)",marginTop:2,paddingTop:8},onClick:()=>{const l=s.path;t(null),E(""),$(l)},children:[e.jsx(O,{icon:Ea}),e.jsx("span",{children:"Delete"})]})]})})}):null}function Vs({value:s,onChange:t,allFolders:o,excludePrefix:i="",allowCreate:a=!1,defaultExpanded:c=!1,onEnter:p}){const[b,r]=u.useState(c),[d,k]=u.useState(""),j=u.useMemo(()=>{const v=i.trim().replace(/^\/+|\/+$/g,"");return o.filter(N=>v?N!==v&&!N.startsWith(`${v}/`):!0)},[o,i]),f=d.trim().replace(/^\/+|\/+$/g,""),E=f.toLowerCase(),$=u.useMemo(()=>E?j.filter(v=>(v||"/ (vault root)").toLowerCase().includes(E)):j,[j,E]),C=(s||"").trim().replace(/^\/+|\/+$/g,""),g=a&&f&&!j.some(v=>v.toLowerCase()===E);function l(v){t(v),k(""),r(!1)}return e.jsxs("div",{className:"folder-picker-wrap",children:[e.jsxs("button",{type:"button",className:"folder-picker-toggle","aria-expanded":b,onClick:()=>r(v=>!v),children:[e.jsx("span",{className:"folder-picker-value",children:C||"/ (vault root)"}),e.jsx("span",{className:"folder-picker-caret",children:b?"▴":"▾"})]}),b&&e.jsxs("div",{className:"folder-picker-panel",children:[e.jsx("input",{type:"text",placeholder:a?"Filter or type new folder...":"Filter folders...",value:d,onChange:v=>k(v.target.value),onKeyDown:v=>v.key==="Enter"&&(p==null?void 0:p())}),e.jsxs("div",{className:"folder-picker",children:[$.map(v=>{const N=C===v;return e.jsx("button",{type:"button",className:`folder-pick-item${N?" active":""}`,onClick:()=>l(v),children:v||"/ (vault root)"},v||"__root__")}),g&&e.jsxs("button",{type:"button",className:"folder-pick-item",onClick:()=>l(f),children:['+ Use "',f,'"']}),$.length===0&&!g&&e.jsx("div",{style:{padding:"8px 10px",fontSize:12,color:"var(--muted)"},children:"No matching folders"})]})]})]})}function Pa({newNoteOpen:s,setNewNoteOpen:t,newNoteTitle:o,setNewNoteTitle:i,newNoteFolder:a,setNewNoteFolder:c,allFolders:p,newNoteError:b,confirmNewNote:r}){return s?e.jsx("div",{className:"modal-backdrop",onClick:()=>t(!1),children:e.jsxs("div",{className:"modal",style:{height:"auto",maxWidth:460},onClick:d=>d.stopPropagation(),children:[e.jsxs("div",{className:"modal-head",children:[e.jsx("h2",{children:"New note"}),e.jsx("button",{className:"btn",onClick:()=>t(!1),children:"Close"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Title"}),e.jsx("input",{type:"text",autoFocus:!0,placeholder:"My note title",value:o,onChange:d=>i(d.target.value),onKeyDown:d=>d.key==="Enter"&&r()})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Folder"}),e.jsx(Vs,{value:a,onChange:c,allFolders:p,allowCreate:!0,defaultExpanded:!1,onEnter:r})]}),it(o,a)&&e.jsxs("div",{style:{fontSize:12,color:"var(--muted)",fontFamily:"var(--font-mono)"},children:["Path: ",it(o,a)]}),b&&e.jsx("div",{className:"git-output",style:{color:"#f87171"},children:b})]}),e.jsxs("div",{className:"modal-foot",children:[e.jsx("button",{className:"btn",onClick:()=>t(!1),children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:r,children:"Create note"})]})]})}):null}function Ba({renameTarget:s,setRenameTarget:t,renameError:o,confirmRenameFile:i}){return s?e.jsx("div",{className:"modal-backdrop",onClick:()=>t(null),children:e.jsxs("div",{className:"modal",style:{height:"auto",maxWidth:440},onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{className:"modal-head",children:[e.jsx("h2",{children:s.type==="dir"?"Rename folder":"Rename file"}),e.jsx("button",{className:"btn",onClick:()=>t(null),children:"Close"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{style:{fontSize:12,color:"var(--muted)",fontFamily:"var(--font-mono)"},children:["Folder: ",s.parentDir?`${s.parentDir}/`:"/"]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"New name"}),e.jsx("input",{type:"text",autoFocus:!0,value:s.newName,onChange:a=>t(c=>({...c,newName:a.target.value})),onKeyDown:a=>a.key==="Enter"&&i()})]}),o&&e.jsx("div",{className:"git-output",style:{color:"#f87171"},children:o})]}),e.jsxs("div",{className:"modal-foot",children:[e.jsx("button",{className:"btn",onClick:()=>t(null),children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:i,children:"Rename"})]})]})}):null}function Ua({moveTarget:s,setMoveTarget:t,allFolders:o,moveError:i,confirmMoveItem:a}){if(!s)return null;const c=(s.destFolder||"").trim().replace(/^\/+|\/+$/g,""),p=c?`${c}/${s.name}`:s.name;return e.jsx("div",{className:"modal-backdrop",onClick:()=>t(null),children:e.jsxs("div",{className:"modal",style:{height:"auto",maxWidth:460},onClick:b=>b.stopPropagation(),children:[e.jsxs("div",{className:"modal-head",children:[e.jsx("h2",{children:s.type==="dir"?"Move folder":"Move file"}),e.jsx("button",{className:"btn",onClick:()=>t(null),children:"Close"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{style:{fontSize:12,color:"var(--muted)",fontFamily:"var(--font-mono)"},children:["From: ",s.oldPath]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Destination folder"}),e.jsx(Vs,{value:s.destFolder,onChange:b=>t(r=>({...r,destFolder:b})),allFolders:o,excludePrefix:s.type==="dir"?s.oldPath:"",defaultExpanded:!0,onEnter:a})]}),e.jsxs("div",{style:{fontSize:12,color:"var(--muted)",fontFamily:"var(--font-mono)"},children:["To: ",p]}),i&&e.jsx("div",{className:"git-output",style:{color:"#f87171"},children:i})]}),e.jsxs("div",{className:"modal-foot",children:[e.jsx("button",{className:"btn",onClick:()=>t(null),children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:a,children:"Move"})]})]})})}function qa({deleteTarget:s,setDeleteTarget:t,deleteError:o,confirmDeleteFile:i}){return s?e.jsx("div",{className:"modal-backdrop",onClick:()=>t(null),children:e.jsxs("div",{className:"modal",style:{height:"auto",maxWidth:420},onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{className:"modal-head",children:[e.jsx("h2",{children:"Delete file?"}),e.jsx("button",{className:"btn",onClick:()=>t(null),children:"Close"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{style:{fontSize:13,color:"var(--muted)"},children:["This will permanently remove ",e.jsx("strong",{style:{color:"var(--text)"},children:s})," from disk."]}),o&&e.jsx("div",{className:"git-output",style:{color:"#f87171"},children:o})]}),e.jsxs("div",{className:"modal-foot",children:[e.jsx("button",{className:"btn",onClick:()=>t(null),children:"Cancel"}),e.jsx("button",{className:"btn",style:{background:"#ef4444",borderColor:"#ef4444",color:"#ffffff",fontWeight:600},onClick:i,children:"Delete"})]})]})}):null}function Oa({discardTarget:s,setDiscardTarget:t,discardError:o,confirmDiscard:i}){return s?e.jsx("div",{className:"modal-backdrop",onClick:()=>t(null),children:e.jsxs("div",{className:"modal",style:{height:"auto",maxWidth:440},onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{className:"modal-head",children:[e.jsx("h2",{children:s.hunkIndex===void 0?"Discard file changes?":s.lineIndex===void 0?"Discard hunk?":"Discard line?"}),e.jsx("button",{className:"btn",onClick:()=>t(null),children:"Close"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsx("div",{style:{fontSize:13,color:"var(--muted)",marginBottom:10},children:s.path}),s.previewText&&e.jsx("div",{className:"git-output",style:{marginTop:0},children:s.previewText}),o&&e.jsx("div",{className:"git-output",style:{color:"#f87171"},children:o})]}),e.jsxs("div",{className:"modal-foot",children:[e.jsx("button",{className:"btn",onClick:()=>t(null),children:"Cancel"}),e.jsx("button",{className:"btn",style:{background:"#ef4444",borderColor:"#ef4444",color:"#ffffff",fontWeight:600},onClick:i,children:"Discard"})]})]})}):null}function Va({commitOpen:s,setCommitOpen:t,commitSelected:o,setCommitSelected:i,gitChanges:a,commitMessage:c,setCommitMessage:p,commitPush:b,setCommitPush:r,commitStatus:d,commitBusy:k,handleCommitSubmit:j}){return s?e.jsx("div",{className:"modal-backdrop",onClick:()=>t(!1),children:e.jsxs("div",{className:"modal",onClick:f=>f.stopPropagation(),children:[e.jsxs("div",{className:"modal-head",children:[e.jsx("h2",{children:"Commit & Push"}),e.jsx("button",{className:"btn",onClick:()=>t(!1),children:"Close"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{className:"field",children:[e.jsxs("label",{children:["Files (",o.size," selected)"]}),e.jsx("div",{className:"commit-files",children:a.map(f=>e.jsxs("label",{className:"commit-file-row",children:[e.jsx("input",{type:"checkbox",checked:o.has(f.path),onChange:E=>{i($=>{const C=new Set($);return E.target.checked?C.add(f.path):C.delete(f.path),C})}}),e.jsx("span",{className:`git-badge git-${f.status}`,children:f.status}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f.path})]},f.path))})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Commit message"}),e.jsx("input",{type:"text",placeholder:"docs: update vault notes",value:c,onChange:f=>p(f.target.value)})]}),e.jsxs("label",{className:"toggle-row",children:[e.jsx("span",{children:"Push to remote after commit"}),e.jsx("input",{type:"checkbox",checked:b,onChange:f=>r(f.target.checked)})]}),d&&e.jsx("div",{className:"git-output",style:{color:d.ok?"var(--green)":"#f87171"},children:d.text})]}),e.jsxs("div",{className:"modal-foot",children:[e.jsx("button",{className:"btn",onClick:()=>t(!1),children:"Cancel"}),e.jsx("button",{className:"btn primary",disabled:k||!c.trim()||o.size===0,onClick:j,children:k?"Running...":b?"Commit & Push":"Commit"})]})]})}):null}function rs(s){return s.split(",").map(t=>t.trim().replace(/^\/+|\/+$/g,"")).filter(Boolean)}function Xa({settingsOpen:s,setSettingsOpen:t,settingsTab:o,setSettingsTab:i,settings:a,setSettings:c,setCollapsed:p}){const[b,r]=u.useState(()=>a.autoCollapsed.join(", ")),[d,k]=u.useState(()=>a.hiddenFolders.join(", "));return u.useEffect(()=>{s&&(r(a.autoCollapsed.join(", ")),k(a.hiddenFolders.join(", ")))},[s]),s?e.jsx("div",{className:"modal-backdrop",onClick:()=>t(!1),children:e.jsxs("div",{className:"modal",onClick:j=>j.stopPropagation(),children:[e.jsxs("div",{className:"modal-head",children:[e.jsx("h2",{children:"Settings"}),e.jsx("button",{className:"btn",onClick:()=>t(!1),children:"Close"})]}),e.jsx("div",{className:"settings-tabs",children:[["general","General"],["appearance","Appearance"],["files","Files & Search"],["endpoints","API & MCP"]].map(([j,f])=>e.jsx("button",{className:`settings-tab${o===j?" active":""}`,onClick:()=>i(j),children:f},j))}),e.jsxs("div",{className:"modal-body",children:[o==="general"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"On startup / first open"}),e.jsxs("select",{value:a.startupMode,onChange:j=>c(f=>({...f,startupMode:j.target.value})),children:[e.jsx("option",{value:"readme",children:"README.md"}),e.jsx("option",{value:"last",children:"Last opened note"}),e.jsx("option",{value:"newtab",children:"New tab launcher"}),e.jsx("option",{value:"custom",children:"Custom note path"})]}),e.jsx("div",{className:"field-hint",children:"Used when opening the vault without a specific #note in the URL."})]}),a.startupMode==="custom"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Custom startup note path"}),e.jsx("input",{type:"text",placeholder:"core/README.md",value:a.startupPath,onChange:j=>c(f=>({...f,startupPath:j.target.value}))})]})]}),o==="appearance"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Theme"}),e.jsxs("select",{value:a.theme,onChange:j=>c(f=>({...f,theme:j.target.value})),children:[e.jsx("option",{value:"dark",children:"Dark"}),e.jsx("option",{value:"light",children:"Light"})]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Outline & Backlinks panel"}),e.jsxs("select",{value:a.outlinePosition,onChange:j=>c(f=>({...f,outlinePosition:j.target.value})),children:[e.jsx("option",{value:"right",children:"Right sidebar"}),e.jsx("option",{value:"bottom",children:"Bottom panel"}),e.jsx("option",{value:"hidden",children:"Hidden"})]})]}),e.jsxs("div",{className:"field",children:[e.jsxs("label",{children:["Reader font size: ",a.fontSize,"px"]}),e.jsx("input",{type:"range",min:"13",max:"20",value:a.fontSize,onChange:j=>c(f=>({...f,fontSize:Number(j.target.value)}))})]}),e.jsxs("div",{className:"field",children:[e.jsxs("label",{children:["Line height: ",a.lineHeight]}),e.jsx("input",{type:"range",min:"1.35",max:"2.0",step:"0.05",value:a.lineHeight,onChange:j=>c(f=>({...f,lineHeight:Number(j.target.value)}))})]}),e.jsxs("div",{className:"field",children:[e.jsxs("label",{children:["Max reading width: ",a.maxWidth,"px"]}),e.jsx("input",{type:"range",min:"580",max:"980",step:"20",value:a.maxWidth,onChange:j=>c(f=>({...f,maxWidth:Number(j.target.value)}))})]})]}),o==="files"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Auto-collapsed folders (comma-separated)"}),e.jsx("input",{type:"text",placeholder:"apps, templates",value:b,onChange:j=>{const f=j.target.value;r(f);const E=rs(f);c($=>({...$,autoCollapsed:E})),p(new Set(E))},onBlur:()=>r(a.autoCollapsed.join(", "))})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Hidden folders (hide from sidebar & search)"}),e.jsx("input",{type:"text",placeholder:"ideas, templates",value:d,onChange:j=>{const f=j.target.value;k(f);const E=rs(f);c($=>({...$,hiddenFolders:E}))},onBlur:()=>k(a.hiddenFolders.join(", "))})]})]}),o==="endpoints"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"REST API (v1)"}),e.jsx("div",{className:"endpoint-box",children:"GET /api/v1/health"}),e.jsx("div",{className:"endpoint-box",children:"GET /api/v1/tree"}),e.jsx("div",{className:"endpoint-box",children:"GET /api/v1/file?path=README.md"}),e.jsxs("div",{className:"endpoint-box",children:["PUT / POST / PATCH /api/v1/file — ","{ path, content, append? } or { path, target, replacement, replaceAll? }"]}),e.jsx("div",{className:"endpoint-box",children:"DELETE /api/v1/file?path=..."}),e.jsx("div",{className:"endpoint-box",children:"GET /api/v1/search?q=python"}),e.jsx("div",{className:"endpoint-box",children:"GET /api/v1/events (SSE)"})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"MCP Endpoint (Streamable HTTP)"}),e.jsx("div",{className:"endpoint-box",children:"POST /mcp — tools: list_vault, read_note, search_vault, write_note, delete_note"})]})]})]}),e.jsxs("div",{className:"modal-foot",children:[e.jsx("button",{className:"btn",onClick:()=>{c(he),p(new Set(he.autoCollapsed)),r(he.autoCollapsed.join(", ")),k(he.hiddenFolders.join(", "))},children:"Reset defaults"}),e.jsx("button",{className:"btn primary",onClick:()=>t(!1),children:"Done"})]})]})}):null}function Ga(){const[s,t]=u.useState([]),[o,i]=u.useState([]),[a,c]=u.useState([]),[p,b]=u.useState(0),[r,d]=u.useState({}),[k,j]=u.useState(Qn),[f,E]=u.useState("general"),$=Zn(k),[C,g]=u.useState(()=>[{id:"tab-1",path:$,title:ge($),preview:""}]),[l,v]=u.useState("tab-1"),N=C.find(n=>n.id===l)||C[0],x=(N==null?void 0:N.path)||"",[z,y]=u.useState(!1),[A,M]=u.useState(""),[U,Y]=u.useState("preview"),[be,ue]=u.useState(null),[G,D]=u.useState(null),[q,K]=u.useState(""),[ie,oe]=u.useState(null),[Se,P]=u.useState(""),[ee,X]=u.useState(null),[F,$e]=u.useState(null),[Xs,we]=u.useState(""),[Q,Ee]=u.useState(null),[Gs,Ve]=u.useState(""),[pt,Xe]=u.useState(!1),[Ge,mt]=u.useState(""),[ft,xt]=u.useState(""),[Ks,Ne]=u.useState(""),jt=u.useRef(null),vt=u.useRef(""),[Js,Ys]=u.useState(!1),[Ka,pe]=u.useState(""),[Qs,le]=u.useState(!1),[Zs,kt]=u.useState(!1),[en,tn]=u.useState("files"),[me,gt]=u.useState([]),[ze,sn]=u.useState("path"),[bt,wt]=u.useState(!1),[Ke,Nt]=u.useState(""),[yt,nn]=u.useState(!1),[Ct,St]=u.useState(()=>new Set),[an,$t]=u.useState(!1),[on,ye]=u.useState(null),[De,ln]=u.useState(""),[rn,Et]=u.useState(()=>new Set(k.autoCollapsed)),[cn,zt]=u.useState(!0),[Le,te]=u.useState(!1),[Te,fe]=u.useState(!1),[Dt,Lt]=u.useState(!1),[Tt,Je]=u.useState(!1),[se,Ye]=u.useState(!1),[xe,dn]=u.useState("recent"),[ne,Wt]=u.useState(""),[hn,Rt]=u.useState(0),[Mt,We]=u.useState([]),[Re,Me]=u.useState({items:[],hasMore:!1}),[un,pn]=u.useState(0),[Ae,Qe]=u.useState(()=>{try{const n=JSON.parse(localStorage.getItem("pagedex-pinned")||"[]");return Array.isArray(n)?n.filter(h=>h&&typeof h.path=="string"&&(h.type==="file"||h.type==="dir")):[]}catch{return[]}}),mn=u.useRef(null),At=u.useRef(null),re=u.useRef(null),_e=u.useRef(x),Ie=u.useRef((N==null?void 0:N.id)||l);_e.current=x,Ie.current=(N==null?void 0:N.id)||l,u.useEffect(()=>{document.documentElement.setAttribute("data-theme",k.theme),localStorage.setItem("vault-settings",JSON.stringify(k))},[k]),u.useEffect(()=>{try{localStorage.setItem("pagedex-pinned",JSON.stringify(Ae))}catch{}},[Ae]);function fn(n){return Ae.some(h=>h.path===n)}function xn(n,h){Qe(m=>m.some(w=>w.path===n)?m.filter(w=>w.path!==n):[...m,{path:n,type:h}])}u.useEffect(()=>{const n=h=>{var m;if((h.metaKey||h.ctrlKey)&&h.key.toLowerCase()==="k"){h.preventDefault(),He();return}h.key==="/"&&((m=document.activeElement)==null?void 0:m.tagName)!=="INPUT"&&(h.preventDefault(),He()),h.key==="Escape"&&se&&Ye(!1)};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[se]);function He(){Wt(""),Rt(0),We([]),Ye(!0),setTimeout(()=>{var n;return(n=At.current)==null?void 0:n.focus()},40)}u.useEffect(()=>{if(!se)return;const n=ne.trim();if(!n){We([]);return}const h=setTimeout(async()=>{try{const w=await(await fetch(`/api/v1/search?q=${encodeURIComponent(n)}`)).json();We(w.results||[])}catch{We([])}},150);return()=>clearTimeout(h)},[ne,se]);const Fe=u.useMemo(()=>new Set(k.hiddenFolders.map(n=>n.toLowerCase())),[k.hiddenFolders]),_t=u.useMemo(()=>{const n=[""],h=m=>{for(const w of m)if(w.type==="dir"){if(Fe.has(w.path.toLowerCase())||Fe.has(w.name.toLowerCase()))continue;n.push(w.path),h(w.children||[])}};return h(s),n},[s,Fe]),je=p>a.length;u.useEffect(()=>{if(!se||!je){Me({items:[],hasMore:!1});return}const n=xe==="alpha"?"name":"mtime",h=ne.trim(),m=setTimeout(async()=>{try{const S=await(await fetch(`/api/v1/files?sort=${n}&offset=0&limit=100&q=${encodeURIComponent(h)}`)).json();Me({items:S.items||[],hasMore:!!S.hasMore})}catch{Me({items:[],hasMore:!1})}},100);return()=>clearTimeout(m)},[se,je,xe,ne]);async function jn(){const n=xe==="alpha"?"name":"mtime",h=ne.trim(),m=Re.items.length,S=await(await fetch(`/api/v1/files?sort=${n}&offset=${m}&limit=100&q=${encodeURIComponent(h)}`)).json();Me(L=>({items:[...L.items,...S.items||[]],hasMore:!!S.hasMore}))}const It=u.useMemo(()=>{const n=ne.trim().toLowerCase(),h=T=>{const H=T.toLowerCase();return k.hiddenFolders.some(_=>H.startsWith(_.toLowerCase()+"/"))},m=je?Re.items:a.length>0?a:o.map(T=>({path:T,mtimeMs:0})),w=new Map(m.map(T=>[T.path,T.mtimeMs||0]));let S;if(!n)S=m.filter(T=>!h(T.path)).map(T=>({path:T.path,mtimeMs:T.mtimeMs||0,snippet:""}));else{const T=m.filter(_=>!h(_.path)&&_.path.toLowerCase().includes(n)).map(_=>({path:_.path,mtimeMs:_.mtimeMs||0,snippet:""})),H=new Set(T.map(_=>_.path));for(const _ of Mt)!h(_.path)&&!H.has(_.path)&&(H.add(_.path),T.push({path:_.path,mtimeMs:_.mtimeMs??w.get(_.path)??0,snippet:_.snippet||""}));S=T}const L=je?S.length:100;if(xe==="alpha"){const T=[...S].sort((H,_)=>{const Un=H.path.split("/").pop().toLowerCase(),qn=_.path.split("/").pop().toLowerCase();return Un.localeCompare(qn)||H.path.localeCompare(_.path)}).slice(0,L);return{groups:[{label:null,items:T}],items:T}}const J=[...S].sort((T,H)=>(H.mtimeMs||0)-(T.mtimeMs||0)).slice(0,L),V=Date.now(),B=new Date(V);B.setHours(0,0,0,0);const W=B.getTime(),Z=864e5,ke=new Map([["Today",[]],["Yesterday",[]],["Last 7 days",[]],["Last 30 days",[]],["Older",[]]]);for(const T of J){const H=T.mtimeMs||0;H>=W?ke.get("Today").push(T):H>=W-Z?ke.get("Yesterday").push(T):H>=W-7*Z?ke.get("Last 7 days").push(T):H>=W-30*Z?ke.get("Last 30 days").push(T):ke.get("Older").push(T)}const Jt=[],Yt=[];for(const[T,H]of ke)H.length>0&&(Jt.push({label:T,items:H}),Yt.push(...H));return{groups:Jt,items:Yt}},[ne,xe,je,Re.items,a,o,Mt,k.hiddenFolders]),vn=It.items;async function ae(){var w;const[n,h]=await Promise.all([fetch("/api/v1/tree?limit=10000"),fetch("/api/v1/changes")]),m=await n.json();if(t(m.tree),i(m.flatFiles),c(m.fileStats||[]),b(m.totalFiles??((w=m.flatFiles)==null?void 0:w.length)??0),d(m.backlinks),h.ok){const S=await h.json();gt(S.changes||[])}}async function Ht(n,h="preview"){const m=`tab-${Date.now()}`;_e.current=n,Ie.current=m,g(w=>w.length===1&&!w[0].path?[{id:m,path:n,title:ge(n),preview:""}]:[...w,{id:m,path:n,title:ge(n),preview:""}]),v(m),await I(n,!1,m),Y(h)}function Ft(){const n=`tab-${Date.now()}`;g(h=>[...h,{id:n,path:null,title:"New tab",preview:""}]),v(n),M(""),y(!1),te(!1),Lt(!1)}function Pt(n,h){h==null||h.stopPropagation();const m=C.filter(w=>w.id!==n);if(m.length===0){const w={id:`tab-${Date.now()}`,path:null,title:"New tab",preview:""};g([w]),v(w.id),M(""),location.hash="";return}if(g(m),n===((N==null?void 0:N.id)||l)){const w=m[m.length-1];v(w.id),w.path?I(w.path,!1,w.id):(M(""),location.hash="")}}function Bt(n){v(n.id),y(!1),n.path?I(n.path,!1,n.id):(M(""),location.hash="")}async function I(n,h=!1,m=(N==null?void 0:N.id)||l){var J;if(!n){M("");return}const w=((J=re.current)==null?void 0:J.scrollTop)??0;let S="";if(Pe(n)&&!Zt(n)||et(n)||tt(n)||st(n)||nt(n)){if(!(await fetch(`/api/v1/file?path=${encodeURIComponent(n)}`,{method:"HEAD"})).ok){M(""),pe(""),le(!1),g(B=>B.map(W=>W.id===m?{...W,path:null,title:"New tab",preview:""}:W));return}M(""),pe(""),le(!1),Pe(n)?S="[Image preview]":et(n)?S="[PDF document]":tt(n)?S="[Audio]":st(n)?S="[Video]":S="[Binary file — download]"}else{const V=await fetch(`/api/v1/file?path=${encodeURIComponent(n)}`);if(!V.ok){M(""),pe(""),le(!1),g(W=>W.map(Z=>Z.id===m?{...Z,path:null,title:"New tab",preview:""}:Z));return}const B=await V.text();M(B),pe(B),le(!1),S=B.replace(/^#+\s*/gm,"").slice(0,260)}location.hash=encodeURIComponent(n),localStorage.setItem("vault-last-path",n),g(V=>V.map(B=>B.id===m?{...B,path:n,title:ge(n),preview:S}:B)),h?requestAnimationFrame(()=>{re.current&&(re.current.scrollTop=w)}):(te(!1),requestAnimationFrame(()=>{re.current&&(re.current.scrollTop=0)})),U==="diff"&&ve(n)}async function ve(n=x){if(!n)return;const h=await fetch(`/api/v1/git/diff?path=${encodeURIComponent(n)}`);h.ok?ue(await h.json()):ue(null)}function Ut({path:n=x,hunkIndex:h,lineIndex:m,previewText:w}={}){n&&(K(""),D({path:n,hunkIndex:h,lineIndex:m,previewText:w}))}async function kn(){if(!(G!=null&&G.path))return;const{path:n,hunkIndex:h,lineIndex:m}=G,w=await fetch("/api/v1/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,hunkIndex:h,lineIndex:m})}),S=await w.json().catch(()=>({}));w.ok?(D(null),K(""),await ae(),n===x&&(await I(x,!0),await ve(x))):K(S.error||"Failed to discard")}async function gn(){if(!ie)return;P("");const n=await fetch(`/api/v1/file?path=${encodeURIComponent(ie)}`,{method:"DELETE"}),h=await n.json().catch(()=>({}));if(n.ok){const m=ie;oe(null),localStorage.getItem("vault-last-path")===m&&localStorage.removeItem("vault-last-path");const w=S=>S.filter(L=>!(L.type==="file"&&L.path===m)).map(L=>L.type==="dir"?{...L,children:w(L.children||[])}:L);if(t(S=>w(S)),i(S=>S.filter(L=>L!==m)),c(S=>S.filter(L=>L.path!==m)),gt(S=>S.filter(L=>L.path!==m)),Qe(S=>S.filter(L=>L.path!==m&&!L.path.startsWith(`${m}/`))),m===x){Y("preview");const S=C.filter(L=>L.path!==m);if(S.length>0){const L=S[S.length-1];g(S),v(L.id),L.path?await I(L.path,!1,L.id):(M(""),location.hash="")}else{const L={id:`tab-${Date.now()}`,path:null,title:"New tab",preview:""};g([L]),v(L.id),M(""),le(!1),location.hash=""}}else g(S=>S.filter(L=>L.path!==m));await ae()}else P(h.error||"Failed to delete file")}async function bn(n){var J;const h=Array.from(n||[]);if(!h.length)return;const m=vt.current||"",w=new FormData;w.append("dir",m);for(const V of h)w.append("files",V);const S=await fetch("/api/v1/file/upload",{method:"POST",body:w}),L=await S.json().catch(()=>({}));if(S.ok&&(await ae(),((J=L.uploaded)==null?void 0:J.length)===1)){const V=L.uploaded[0].path;/\.(md|markdown|txt|png|jpe?g|gif|webp|svg|ico)$/i.test(V)&&I(V)}}async function qt(n,h,m,w){const S=n==="dir",J=await fetch(S?"/api/v1/dir/rename":"/api/v1/file/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPath:h,newPath:m})}),V=await J.json().catch(()=>({}));return J.ok?(await ae(),g(B=>B.map(W=>{if(!W.path)return W;if(S&&W.path.startsWith(`${h}/`)){const Z=`${m}${W.path.slice(h.length)}`;return{...W,path:Z,title:ge(Z)}}return!S&&W.path===h?{...W,path:m,title:ge(m)}:W})),Qe(B=>B.map(W=>{if(S){if(W.path===h)return{...W,path:m};if(W.path.startsWith(`${h}/`))return{...W,path:`${m}${W.path.slice(h.length)}`}}else if(W.path===h)return{...W,path:m};return W})),S?x.startsWith(`${h}/`)&&I(`${m}${x.slice(h.length)}`):h===x&&I(m),!0):(w(V.error||"Operation failed"),!1)}async function wn(){if(!(F!=null&&F.oldPath))return;const n=F.newName.trim();if(!n){we("Please enter a name");return}if(n.includes("/")){we("Name cannot contain / (use Move to change folder)");return}we("");const h=F.parentDir?`${F.parentDir}/${n}`:n;if(h===F.oldPath){$e(null);return}await qt(F.type,F.oldPath,h,we)&&$e(null)}async function Nn(){if(!(Q!=null&&Q.oldPath))return;Ve("");const n=(Q.destFolder||"").trim().replace(/^\/+|\/+$/g,""),h=n?`${n}/${Q.name}`:Q.name;if(h===Q.oldPath){Ee(null);return}await qt(Q.type,Q.oldPath,h,Ve)&&Ee(null)}function yn(n,h,m="file"){const w=window.innerWidth<=768?215:175,S=window.innerWidth<=768?360:300,L=Math.min(h.right-w,window.innerWidth-(w+12)),J=Math.min(h.bottom+4,window.innerHeight-S);X({type:m,path:n,x:Math.max(8,L),y:Math.max(8,J)})}function Ot(n=null){const h=x.includes("/")?x.split("/").slice(0,-1).join("/"):"",m=typeof n=="string"?n:h;mt(""),xt(m.replace(/^\/+|\/+$/g,"")),Ne(""),Xe(!0)}async function Cn(){const n=it(Ge,ft);if(!n){Ne("Please enter a note title");return}if(o.includes(n)){Ne(`Already exists: ${n}`);return}Ne("");const h=Ge.trim().replace(/\.md$/i,""),m=await fetch("/api/v1/file",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,content:`# ${h}
184
+
185
+ `})}),w=await m.json().catch(()=>({}));if(!m.ok||w.error){Ne(w.error||"Failed to create note");return}Xe(!1),await ae(),await Ht(n,"preview")}u.useEffect(()=>{ae(),I(x)},[]),u.useEffect(()=>{const n=()=>{const h=decodeURIComponent(location.hash.slice(1)||"");h&&h!==_e.current&&I(h,!1,Ie.current)};return window.addEventListener("hashchange",n),()=>window.removeEventListener("hashchange",n)},[]),u.useEffect(()=>{const n=new EventSource("/api/v1/events");return n.onopen=()=>zt(!0),n.onmessage=async h=>{if(JSON.parse(h.data).type==="reload"){await ae(),pn(S=>S+1);const w=_e.current;w&&await I(w,!0,Ie.current)}},n.onerror=()=>zt(!1),()=>n.close()},[]);async function Sn(n){if(x){kt(!0);try{(await fetch("/api/v1/file",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:x,content:n})})).ok&&(M(n),pe(n),le(!1))}finally{kt(!1)}}}const{renderedHtml:$n,headings:En}=u.useMemo(()=>!Ze(x)||U!=="preview"||Pe(x)||nt(x)?{renderedHtml:"",headings:[]}:na(A,x,o),[A,x,U,o]),zn=u.useMemo(()=>!A||U!=="raw"&&Ze(x)?"":aa(A,x),[A,x,U]);function Dn(n){const h=n.target.closest("a.wikilink");if(h){n.preventDefault(),I(h.dataset.path);return}const m=n.target.closest("a.md-rel-link");if(m){n.preventDefault();const w=cs(x,m.dataset.href);o.includes(w)&&I(w)}}function Ln(n){Et(h=>{const m=new Set(h);return m.has(n)?m.delete(n):m.add(n),m})}const Tn=u.useMemo(()=>{const h=[...me.filter(m=>!De||m.path.toLowerCase().includes(De))];return ze==="recent"?h.sort((m,w)=>(w.mtimeMs||0)-(m.mtimeMs||0)||m.path.localeCompare(w.path)):ze==="status"?h.sort((m,w)=>m.status.localeCompare(w.status)||m.path.localeCompare(w.path)):h.sort((m,w)=>m.path.localeCompare(w.path)),h},[me,De,ze]);function Wn(){St(new Set(me.map(n=>n.path))),Nt(""),ye(null),wt(!0)}async function Rn(){if(Ke.trim()){$t(!0),ye(null);try{const n=await fetch("/api/v1/git/commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:Ke.trim(),files:Array.from(Ct),push:yt})}),h=await n.json();!n.ok||h.error?ye({ok:!1,text:h.error||"Commit failed"}):(ye({ok:!0,text:h.output||"Committed successfully"}),await ae())}catch(n){ye({ok:!1,text:n.message})}finally{$t(!1)}}}const Mn=r[x]||[],Vt=Pe(x),An=Zt(x),_n=Ze(x),In=et(x),Hn=tt(x),Fn=st(x),Pn=ea(x),Bn=ta(x),Xt=nt(x),ce=k.outlinePosition||"right",Ce=n=>j(h=>({...h,outlinePosition:n})),Gt=()=>{Ce("right"),window.innerWidth<=960&&(te(!1),fe(!0))},Kt=()=>{window.innerWidth<=960?ce==="bottom"?(Ce("hidden"),fe(!1)):(ce==="hidden"&&Ce("right"),te(!1),fe(n=>!n)):Ce(ce==="hidden"?"right":"hidden")};return ra({drawerOpen:Le,outlineDrawerOpen:Te,outlinePosition:ce,setDrawerOpen:te,onOpenOutline:Gt,setOutlineDrawerOpen:fe,disabled:!!(se||Tt||z||bt||Dt||pt||F||Q||ie||G)}),e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`backdrop${Le||Te?" open":""}`,onClick:()=>{te(!1),fe(!1)}}),e.jsxs("div",{className:"app",children:[e.jsx(La,{drawerOpen:Le,live:cn,settings:k,setSettings:j,sidebarTab:en,setSidebarTab:tn,gitChanges:me,searchRef:mn,filter:De,setFilter:ln,tree:s,pinned:Ae,activePath:x,collapsed:rn,hiddenSet:Fe,toggleDir:Ln,setViewMode:Y,openFile:I,openRowMenu:yn,changesSort:ze,setChangesSort:sn,openCommitDialog:Wn,sortedChanges:Tn,loadDiff:ve}),e.jsxs("main",{className:"main",children:[e.jsx(Ta,{tabs:C,activeTabId:l,switchTab:Bt,closeTab:Pt,createNewTab:Ft}),e.jsxs("div",{className:`workspace-body outline-${ce}`,children:[e.jsxs("div",{className:"note-pane",children:[e.jsx(Wa,{setDrawerOpen:te,activePath:x,moreMenuOpen:Js,setMoreMenuOpen:Ys,viewMode:U,setViewMode:Y,loadDiff:ve,setDeleteError:P,setDeleteTarget:oe,outlinePosition:ce,outlineDrawerOpen:Te,onToggleOutline:Kt,onOpenOutline:Gt}),e.jsx(Aa,{scrollRef:re,activePath:x,openNewNoteDialog:Ot,openFile:I,openSwitcher:He,setDrawerOpen:te,setSettingsOpen:Je,isImg:Vt,isSvg:An,isMarkdown:_n,isPdf:In,isAudio:Hn,isVideo:Fn,isHtml:Pn,isCsv:Bn,reloadTick:un,isBinaryDownload:Xt,viewMode:U,settings:k,diffData:be,requestDiscard:Ut,content:A,saving:Zs,dirty:Qs,setDraftContent:pe,setDirty:le,saveActiveNote:Sn,highlightedRawHtml:zn,handleDocClick:Dn,renderedHtml:$n})]}),e.jsx(_a,{headings:En,isImg:Vt,isBinaryDownload:Xt,viewMode:U,currentBacklinks:Mn,openFile:I,position:ce,onChangePosition:Ce,mobileOpen:Te,onCloseMobile:()=>fe(!1)})]})]})]}),e.jsx(Ia,{fabOpen:Dt,setFabOpen:Lt,openSwitcher:He,drawerOpen:Le,setDrawerOpen:te,onToggleOutline:Kt,openFile:I,viewMode:U,setViewMode:Y,settings:k,setSettings:j,setSettingsOpen:Je,scrollRef:re,loadDiff:ve,activePath:x,createNewTab:Ft,tabsOpen:z,setTabsOpen:y,tabs:C,activeTabId:l,switchTab:Bt,closeTab:Pt}),e.jsx(Ha,{switcherOpen:se,setSwitcherOpen:Ye,switcherTab:xe,setSwitcherTab:dn,switcherIdx:hn,setSwitcherIdx:Rt,switcherInputRef:At,totalFiles:p,fileStats:a,switcherItems:vn,switcherData:It,openFile:I,isLargeVault:je,pagedFiles:Re,loadMorePagedFiles:jn,switcherQuery:ne,setSwitcherQuery:Wt}),e.jsx("input",{ref:jt,type:"file",multiple:!0,style:{display:"none"},onChange:n=>{bn(n.target.files),n.target.value=""}}),e.jsx(Fa,{fileMenu:ee,setFileMenu:X,openNewNoteDialog:Ot,uploadDirRef:vt,uploadInputRef:jt,setRenameError:we,setRenameTarget:$e,setMoveError:Ve,setMoveTarget:Ee,openInNewTab:Ht,gitChanges:me,loadDiff:ve,requestDiscard:Ut,setDeleteError:P,setDeleteTarget:oe,isPinned:fn,togglePin:xn}),e.jsx(Pa,{newNoteOpen:pt,setNewNoteOpen:Xe,newNoteTitle:Ge,setNewNoteTitle:mt,newNoteFolder:ft,setNewNoteFolder:xt,allFolders:_t,newNoteError:Ks,confirmNewNote:Cn}),e.jsx(Ba,{renameTarget:F,setRenameTarget:$e,renameError:Xs,confirmRenameFile:wn}),e.jsx(Ua,{moveTarget:Q,setMoveTarget:Ee,allFolders:_t,moveError:Gs,confirmMoveItem:Nn}),e.jsx(qa,{deleteTarget:ie,setDeleteTarget:oe,deleteError:Se,confirmDeleteFile:gn}),e.jsx(Oa,{discardTarget:G,setDiscardTarget:D,discardError:q,confirmDiscard:kn}),e.jsx(Va,{commitOpen:bt,setCommitOpen:wt,commitSelected:Ct,setCommitSelected:St,gitChanges:me,commitMessage:Ke,setCommitMessage:Nt,commitPush:yt,setCommitPush:nn,commitStatus:on,commitBusy:an,handleCommitSubmit:Rn}),e.jsx(Xa,{settingsOpen:Tt,setSettingsOpen:Je,settingsTab:f,setSettingsTab:E,settings:k,setSettings:j,setCollapsed:Et})]})}Vn.createRoot(document.getElementById("root")).render(e.jsx(Ga,{}));
package/dist/index.html CHANGED
@@ -10,11 +10,12 @@
10
10
  <link rel="icon" href="/favicon.ico" sizes="any" />
11
11
  <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
12
12
  <title>Vault</title>
13
- <script type="module" crossorigin src="/assets/index-ZVjt99Mq.js"></script>
13
+ <script type="module" crossorigin src="/assets/index-vKzhpzX9.js"></script>
14
14
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-E4kvVwMA.js">
15
15
  <link rel="modulepreload" crossorigin href="/assets/vendor-markdown-C94ubdL7.js">
16
16
  <link rel="modulepreload" crossorigin href="/assets/vendor-hljs-B8we2J8a.js">
17
- <link rel="stylesheet" crossorigin href="/assets/index-BXGU3AiE.css">
17
+ <link rel="modulepreload" crossorigin href="/assets/vendor-tiptap-ChgD7Piv.js">
18
+ <link rel="stylesheet" crossorigin href="/assets/index-A_l6j1w5.css">
18
19
  </head>
19
20
  <body>
20
21
  <div id="root"></div>
package/docs/MCP.md ADDED
@@ -0,0 +1,107 @@
1
+ # MCP Server Guide (`docs/MCP.md`)
2
+
3
+ `pagedex` includes a built-in **Model Context Protocol (MCP)** server at `/mcp` supporting three protocol eras simultaneously:
4
+ - **`2026-07-28`** (`server/discover` + Streamable HTTP)
5
+ - **`2025-11-25`** (legacy Streamable HTTP `initialize`)
6
+ - **`2024-11-05`** (legacy HTTP+SSE)
7
+
8
+ ## Access Control & CLI Flags
9
+
10
+ | Flag | Env Var | Default | Behavior |
11
+ |---|---|---|---|
12
+ | `--mcp <mode>` | `PAGEDEX_MCP_MODE` | `full` | Controls which MCP tools are exposed (`read`, `write`, `full`, or `off`) |
13
+ | `--mcp-git` | `PAGEDEX_MCP_GIT` | `false` | Opt-in flag to expose `git_commit` and `git_discard` (requires `write` or `full`) |
14
+ | `--mcp-token-file <path>` | `PAGEDEX_MCP_TOKEN_FILE` | — | File containing Bearer token required in `Authorization: Bearer <token>` on `/mcp` |
15
+ | — | `PAGEDEX_MCP_TOKEN` | — | Optional env fallback if `--mcp-token-file` is not set |
16
+ | `--read-only` | `PAGEDEX_READ_ONLY` | `false` | Blocks all REST mutations (`403`) and forces MCP to `read` mode (unless `off`) |
17
+
18
+ ### MCP Modes
19
+
20
+ | Mode | Read Tools | Write / Move Tools | `delete_note` | `git_commit` / `git_discard` |
21
+ |---|---|---|---|---|
22
+ | `read` | Yes | No | No | No |
23
+ | `write` | Yes | Yes | No | Only with `--mcp-git` |
24
+ | `full` *(default)* | Yes | Yes | Yes | Only with `--mcp-git` |
25
+ | `off` | Disabled (`404` on `/mcp`) | No | No | No |
26
+
27
+ ### Examples
28
+
29
+ ```bash
30
+ # Safe read-only MCP for browsing/searching notes
31
+ pagedex ~/vault --mcp read
32
+
33
+ # Allow AI agents to create/edit/move notes, but forbid deletions
34
+ pagedex ~/vault --mcp write
35
+
36
+ # Expose on LAN with Bearer token stored in a 0600 file (not in ps/shell history)
37
+ pagedex ~/vault --host 0.0.0.0 --mcp write --mcp-token-file ~/.config/pagedex/mcp-token
38
+
39
+ # Allow local git commit/discard via MCP (never pushes)
40
+ pagedex ~/vault --mcp write --mcp-git
41
+
42
+ # Lock down both Web UI/REST and MCP completely
43
+ pagedex ~/vault --read-only
44
+ ```
45
+
46
+ ## Client Configuration
47
+
48
+ Without token auth:
49
+
50
+ ```json
51
+ {
52
+ "mcpServers": {
53
+ "pagedex": {
54
+ "url": "http://127.0.0.1:4321/mcp"
55
+ }
56
+ }
57
+ }
58
+ ```
59
+
60
+ With `--mcp-token-file`:
61
+
62
+ ```json
63
+ {
64
+ "mcpServers": {
65
+ "pagedex": {
66
+ "url": "http://127.0.0.1:4321/mcp",
67
+ "headers": {
68
+ "Authorization": "Bearer YOUR_TOKEN_HERE"
69
+ }
70
+ }
71
+ }
72
+ }
73
+ ```
74
+
75
+ ## Exposed Tools
76
+
77
+ ### Read Tools (`read`, `write`, `full`)
78
+
79
+ | Tool | Inputs | Purpose |
80
+ |---|---|---|
81
+ | `list_vault` | `{ folder? }` | List immediate subfolders and files in `/` or a subfolder |
82
+ | `read_note` | `{ path }` | Read a file's contents and incoming backlinks |
83
+ | `search_vault` | `{ query, limit? }` | Run SQLite FTS5 trigram full-text search across filenames & contents |
84
+ | `get_vault_info` | `{ recentLimit? }` | Get total file count and most recently modified files |
85
+ | `get_note_links` | `{ path }` | Get outgoing `[[wikilinks]]`, incoming backlinks, and Markdown headings |
86
+ | `git_status` | `{}` | List uncommitted modified, added, or untracked files |
87
+ | `git_diff` | `{ path }` | Get unified git diff for a specific file |
88
+
89
+ ### Write Tools (`write`, `full`)
90
+
91
+ | Tool | Inputs | Purpose |
92
+ |---|---|---|
93
+ | `write_note` | `{ path, content?, append?, target?, replacement?, replaceAll? }` | Create, overwrite, append, or patch (`target` → `replacement`) a file |
94
+ | `move_path` | `{ oldPath, newPath, type? }` | Rename or move a file or directory (`type`: `auto` \| `file` \| `dir`) |
95
+
96
+ ### Destructive Tool (`full` only)
97
+
98
+ | Tool | Inputs | Purpose |
99
+ |---|---|---|
100
+ | `delete_note` | `{ path }` | Delete a file from disk and remove it from the search index |
101
+
102
+ ### Git Mutation Tools (`--mcp-git` with `write` or `full`)
103
+
104
+ | Tool | Inputs | Purpose |
105
+ |---|---|---|
106
+ | `git_commit` | `{ message, files? }` | Stage and commit changes locally (never pushes) |
107
+ | `git_discard` | `{ path }` | Discard uncommitted changes to a file (or delete an untracked file) |
package/docs/README.md CHANGED
@@ -4,6 +4,7 @@ User, integration, and developer guides for **pagedex**.
4
4
 
5
5
  - [Getting Started](./getting-started.md) — CLI flags, environment variables, UI features, wikilinks, Git sync, and mobile gestures.
6
6
  - [Supported File Types](./supported-files.md) — Markdown/MDX, sandboxed HTML + sibling assets, PDF, audio/video, CSV/TSV, SVG, code, and binaries.
7
- - [MCP & REST API](./mcp-and-api.md) — Connecting AI clients to `/mcp`, the 5 vault tools, REST endpoints, `/raw/*`, and SSE live reload.
7
+ - [MCP Server Guide](./MCP.md) — MCP modes (`read`, `write`, `full`, `off`), `--mcp-token-file`, `--mcp-git`, and all 12 vault tools.
8
+ - [MCP & REST API](./mcp-and-api.md) — Quick reference for `/mcp`, REST endpoints, `/raw/*`, and SSE live reload.
8
9
  - [Security Model](./security.md) — Sandboxed HTML iframes, CSP/CORS behavior, `Origin: null` guard, and path protection.
9
10
  - [Development & Release](./development.md) — Running `pnpm dev`, unit & smoke tests, and npm packaging.
@@ -27,6 +27,10 @@ npx pagedex ~/vault --host 0.0.0.0 --port 4321
27
27
  | `-p, --port <port>` | `PORT` | `4321` | HTTP port |
28
28
  | `-H, --host <host>` | `HOST` | `127.0.0.1` | Bind address (`0.0.0.0` for LAN/Tailscale) |
29
29
  | `-o, --open` | — | `false` | Open browser on startup |
30
+ | `--mcp <mode>` | `PAGEDEX_MCP_MODE` | `full` | MCP mode: `read`, `write`, `full`, or `off` |
31
+ | `--mcp-git` | `PAGEDEX_MCP_GIT` | `false` | Enable `git_commit` and `git_discard` MCP tools |
32
+ | `--mcp-token-file <path>` | `PAGEDEX_MCP_TOKEN_FILE` | — | File containing Bearer token for `/mcp` |
33
+ | `--read-only` | `PAGEDEX_READ_ONLY` | `false` | Disable all REST & MCP write/delete mutations |
30
34
  | `-v, --version` | — | — | Print version |
31
35
  | `-h, --help` | — | — | Print CLI help |
32
36
 
@@ -40,6 +44,8 @@ Override the cache location with:
40
44
 
41
45
  ## Web UI Highlights
42
46
 
47
+ ![Desktop Preview](./images/desktop-preview.png)
48
+
43
49
  - **View Modes (top-right `⋮` menu):**
44
50
  - **Download** — downloads any open file via `/api/v1/file?path=...&download=1`
45
51
  - **Preview** — rendered Markdown, sandboxed HTML, PDF, audio/video, CSV/TSV tables, or images
Binary file
Binary file
Binary file
Binary file
@@ -25,13 +25,14 @@ Point any HTTP-capable MCP client (Claude Code, Cursor, VS Code, etc.) at:
25
25
 
26
26
  ### Exposed MCP Tools
27
27
 
28
- | Tool | Purpose |
28
+ See the full **[MCP Server Guide](./MCP.md)** for CLI access control (`--mcp`, `--mcp-git`, `--mcp-token-file`, `--read-only`) and detailed schemas.
29
+
30
+ | Tier | Tools |
29
31
  |---|---|
30
- | `list_vault` | List files/folders and metadata in the served root |
31
- | `read_note` | Read file contents and backlinks |
32
- | `search_vault` | Run SQLite FTS5 trigram full-text search |
33
- | `write_note` | Create, overwrite, append, or patch (`target` → `replacement`) files |
34
- | `delete_note` | Delete a file from disk and update the search index |
32
+ | Read (`read`, `write`, `full`) | `list_vault`, `read_note`, `search_vault`, `get_vault_info`, `get_note_links`, `git_status`, `git_diff` |
33
+ | Write (`write`, `full`) | `write_note`, `move_path` |
34
+ | Full (`full` default) | `delete_note` |
35
+ | Git mutations (`--mcp-git`) | `git_commit`, `git_discard` |
35
36
 
36
37
  ## REST API (`/api/v1/*`)
37
38