@makuja/peek 1.10.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/dist/index.mjs +527 -50
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@ Markdown and HTML preview CLI with live reload. Spins up a local web server and
|
|
|
10
10
|
- **Syntax highlighting** - Code blocks are highlighted with Shiki
|
|
11
11
|
- **Custom CSS** - Customize Markdown styles via `--css` flag or `~/.config/peek/style.css`
|
|
12
12
|
- **Dark / Light theme** - Built-in theme toggle
|
|
13
|
+
- **Save as PDF** - In directory mode, save the shown file, or all Markdown files under a directory, as a PDF without the header and sidebar
|
|
13
14
|
|
|
14
15
|
## Requirements
|
|
15
16
|
|
|
@@ -70,6 +71,15 @@ peek serves these files from the browsed directory (directory mode) or from the
|
|
|
70
71
|
- Fonts: `woff`, `woff2`, `ttf`, `otf`
|
|
71
72
|
- HTML: `html`, `htm`
|
|
72
73
|
|
|
74
|
+
## Save as PDF
|
|
75
|
+
|
|
76
|
+
In directory mode, the **Save as PDF** button in the header opens a menu:
|
|
77
|
+
|
|
78
|
+
- **This file** - The shown file. Markdown prints in the light theme; an HTML file prints as its own page, whole.
|
|
79
|
+
- **A directory** - The browsed directory or a directory containing the shown file. All Markdown files under it, as listed in the file tree (so without files excluded by `.gitignore`), go into one PDF, each starting on a new page. HTML files are left out, and a directory with more than 200 Markdown files cannot be saved.
|
|
80
|
+
|
|
81
|
+
The choice opens in a new tab with the browser's print dialog. Choose **Save as PDF** as the destination; the file is named after the file (`README.md` → `README.pdf`) or the directory (`docs` → `docs.pdf`). Allow pop-ups for the peek URL if the browser blocks the new tab.
|
|
82
|
+
|
|
73
83
|
## Custom CSS
|
|
74
84
|
|
|
75
85
|
Content styles for Markdown files can be customized in three ways (in priority order):
|
package/dist/index.mjs
CHANGED
|
@@ -17,6 +17,8 @@ import ignore from "ignore";
|
|
|
17
17
|
import { constants, watch } from "node:fs";
|
|
18
18
|
import renderToString from "preact-render-to-string";
|
|
19
19
|
import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
|
|
20
|
+
import { Fragment as Fragment$1 } from "preact";
|
|
21
|
+
import { useEffect, useRef, useState } from "preact/hooks";
|
|
20
22
|
import { createHash } from "node:crypto";
|
|
21
23
|
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
22
24
|
import { streamSSE } from "hono/streaming";
|
|
@@ -80,6 +82,19 @@ function resolveMarkdownImageSrc(src, markdownPath) {
|
|
|
80
82
|
const url = new URL(src, base);
|
|
81
83
|
return `${url.pathname}${url.search}${url.hash}`;
|
|
82
84
|
}
|
|
85
|
+
/** Route of the page that holds only the content to print as a PDF. */
|
|
86
|
+
const PRINT_PAGE_PATH = "/__peek/print";
|
|
87
|
+
/** Print page of one Markdown file (relative to the base directory). */
|
|
88
|
+
function printFileUrl(relativePath) {
|
|
89
|
+
return `${PRINT_PAGE_PATH}?file=${encodeURIComponent(relativePath)}`;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Print page of the Markdown files under a directory (relative to the base
|
|
93
|
+
* directory); `null` is the base directory itself.
|
|
94
|
+
*/
|
|
95
|
+
function printDirectoryUrl(relativePath) {
|
|
96
|
+
return `${PRINT_PAGE_PATH}?dir=${encodeURIComponent(relativePath ?? "")}`;
|
|
97
|
+
}
|
|
83
98
|
//#endregion
|
|
84
99
|
//#region src/lib/markdown.ts
|
|
85
100
|
let md = null;
|
|
@@ -202,6 +217,29 @@ async function resolveStyles(cssOption) {
|
|
|
202
217
|
return ok({ contentCss: content_default });
|
|
203
218
|
}
|
|
204
219
|
//#endregion
|
|
220
|
+
//#region src/core/path.ts
|
|
221
|
+
function isWithinBase(base, target) {
|
|
222
|
+
const resolvedBase = resolve(base);
|
|
223
|
+
const resolvedTarget = resolve(target);
|
|
224
|
+
const prefix = resolvedBase.endsWith(sep) ? resolvedBase : resolvedBase + sep;
|
|
225
|
+
return resolvedTarget === resolvedBase || resolvedTarget.startsWith(prefix);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Whether `relativePath`, resolved against `base` without touching the file
|
|
229
|
+
* system, stays inside `base`.
|
|
230
|
+
*/
|
|
231
|
+
function isRelativePathWithinBase(base, relativePath) {
|
|
232
|
+
return isWithinBase(base, resolve(base, normalize(relativePath)));
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Rewrites a relative path taken from the OS (`path.relative`, `fs.watch`, a
|
|
236
|
+
* URL typed on Windows) into a `SlashPath`. On POSIX `\` is an ordinary file
|
|
237
|
+
* name character and is kept.
|
|
238
|
+
*/
|
|
239
|
+
function toSlashPath(osPath) {
|
|
240
|
+
return osPath.split(sep).join("/");
|
|
241
|
+
}
|
|
242
|
+
//#endregion
|
|
205
243
|
//#region src/lib/file-tree.ts
|
|
206
244
|
const DEFAULT_IGNORE_PATTERNS = [".git/"];
|
|
207
245
|
async function readGitignore(path) {
|
|
@@ -294,11 +332,12 @@ async function processEntries(entries, dir, rootDir, rules, visited) {
|
|
|
294
332
|
for (const entry of entries) {
|
|
295
333
|
const fullPath = join(dir, entry.name);
|
|
296
334
|
const relPath = relative(rootDir, fullPath);
|
|
335
|
+
const path = toSlashPath(relPath);
|
|
297
336
|
if (entry.isDirectory()) {
|
|
298
337
|
if (isPathIgnored(relPath, true, rules)) continue;
|
|
299
338
|
dirPromises.push(scanDirectory(fullPath, rootDir, rules, visited).then((children) => children.length > 0 ? {
|
|
300
339
|
name: entry.name,
|
|
301
|
-
path
|
|
340
|
+
path,
|
|
302
341
|
type: "directory",
|
|
303
342
|
children
|
|
304
343
|
} : null));
|
|
@@ -306,7 +345,7 @@ async function processEntries(entries, dir, rootDir, rules, visited) {
|
|
|
306
345
|
if (isPathIgnored(relPath, false, rules)) continue;
|
|
307
346
|
fileNodes.push({
|
|
308
347
|
name: entry.name,
|
|
309
|
-
path
|
|
348
|
+
path,
|
|
310
349
|
type: "file"
|
|
311
350
|
});
|
|
312
351
|
}
|
|
@@ -452,21 +491,6 @@ const FULLSCREEN_IFRAME_STYLE = {
|
|
|
452
491
|
left: "0"
|
|
453
492
|
};
|
|
454
493
|
//#endregion
|
|
455
|
-
//#region src/core/path.ts
|
|
456
|
-
function isWithinBase(base, target) {
|
|
457
|
-
const resolvedBase = resolve(base);
|
|
458
|
-
const resolvedTarget = resolve(target);
|
|
459
|
-
const prefix = resolvedBase.endsWith(sep) ? resolvedBase : resolvedBase + sep;
|
|
460
|
-
return resolvedTarget === resolvedBase || resolvedTarget.startsWith(prefix);
|
|
461
|
-
}
|
|
462
|
-
/**
|
|
463
|
-
* Whether `relativePath`, resolved against `base` without touching the file
|
|
464
|
-
* system, stays inside `base`.
|
|
465
|
-
*/
|
|
466
|
-
function isRelativePathWithinBase(base, relativePath) {
|
|
467
|
-
return isWithinBase(base, resolve(base, normalize(relativePath)));
|
|
468
|
-
}
|
|
469
|
-
//#endregion
|
|
470
494
|
//#region src/lib/real-path.ts
|
|
471
495
|
/**
|
|
472
496
|
* Resolves `relativePath` against `base`, following symlinks, and checks that
|
|
@@ -658,6 +682,19 @@ function ExternalLinkIcon({ class: className }) {
|
|
|
658
682
|
});
|
|
659
683
|
}
|
|
660
684
|
//#endregion
|
|
685
|
+
//#region src/components/icons/file-down-icon.tsx
|
|
686
|
+
function FileDownIcon(props) {
|
|
687
|
+
return /* @__PURE__ */ jsxs(SvgBase, {
|
|
688
|
+
...props,
|
|
689
|
+
children: [
|
|
690
|
+
/* @__PURE__ */ jsx("path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z" }),
|
|
691
|
+
/* @__PURE__ */ jsx("path", { d: "M14 2v4a2 2 0 0 0 2 2h4" }),
|
|
692
|
+
/* @__PURE__ */ jsx("path", { d: "M12 18v-6" }),
|
|
693
|
+
/* @__PURE__ */ jsx("path", { d: "m9 15 3 3 3-3" })
|
|
694
|
+
]
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
//#endregion
|
|
661
698
|
//#region src/components/icons/file-icon.tsx
|
|
662
699
|
function FileIcon(props) {
|
|
663
700
|
return /* @__PURE__ */ jsxs(SvgBase, {
|
|
@@ -838,7 +875,7 @@ function ThemeToggle() {
|
|
|
838
875
|
}
|
|
839
876
|
//#endregion
|
|
840
877
|
//#region src/components/layout/page-header.tsx
|
|
841
|
-
function PageHeader({ id, breadcrumbs, showSidebarToggle, onToggleSidebar, externalLinkHref }) {
|
|
878
|
+
function PageHeader({ id, breadcrumbs, showSidebarToggle, onToggleSidebar, externalLinkHref, actions }) {
|
|
842
879
|
return /* @__PURE__ */ jsx("header", {
|
|
843
880
|
id,
|
|
844
881
|
class: "sticky top-0 z-50 bg-background border-b border-border",
|
|
@@ -861,16 +898,290 @@ function PageHeader({ id, breadcrumbs, showSidebarToggle, onToggleSidebar, exter
|
|
|
861
898
|
}), /* @__PURE__ */ jsx(Breadcrumb, { items: breadcrumbs })]
|
|
862
899
|
}), /* @__PURE__ */ jsxs("div", {
|
|
863
900
|
class: "flex items-center gap-1",
|
|
864
|
-
children: [
|
|
901
|
+
children: [
|
|
902
|
+
actions,
|
|
903
|
+
/* @__PURE__ */ jsx(ThemeToggle, {}),
|
|
904
|
+
externalLinkHref !== void 0 && /* @__PURE__ */ jsx(ExternalLink, { href: externalLinkHref })
|
|
905
|
+
]
|
|
865
906
|
})]
|
|
866
907
|
})
|
|
867
908
|
});
|
|
868
909
|
}
|
|
869
910
|
//#endregion
|
|
911
|
+
//#region src/core/file-tree.ts
|
|
912
|
+
/**
|
|
913
|
+
* Paths of the directories in the tree that contain `targetPath`, outermost
|
|
914
|
+
* first. `targetPath` itself need not be in the tree: a file excluded by
|
|
915
|
+
* `.gitignore` can still be displayed, and its directories are found.
|
|
916
|
+
*/
|
|
917
|
+
function findAncestorPaths(nodes, targetPath) {
|
|
918
|
+
for (const node of nodes) {
|
|
919
|
+
if (node.type !== "directory") continue;
|
|
920
|
+
if (targetPath.startsWith(`${node.path}/`)) return [node.path, ...findAncestorPaths(node.children ?? [], targetPath)];
|
|
921
|
+
}
|
|
922
|
+
return [];
|
|
923
|
+
}
|
|
924
|
+
/**
|
|
925
|
+
* Title of the document printed for a single file. Browsers name a PDF saved
|
|
926
|
+
* from the print dialog after the document title, so `README.md` gives
|
|
927
|
+
* `README.pdf`.
|
|
928
|
+
*/
|
|
929
|
+
function filePdfTitle(path) {
|
|
930
|
+
const name = path.slice(path.lastIndexOf("/") + 1);
|
|
931
|
+
const extension = getExtension(name);
|
|
932
|
+
return extension === "" ? name : name.slice(0, -extension.length);
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* Name of a directory, which also titles its PDF. The browsed directory goes
|
|
936
|
+
* by `rootName`.
|
|
937
|
+
*/
|
|
938
|
+
function directoryName(path, rootName) {
|
|
939
|
+
return path === null ? rootName : path.slice(path.lastIndexOf("/") + 1);
|
|
940
|
+
}
|
|
941
|
+
function directoryPdfStatus(fileCount) {
|
|
942
|
+
if (fileCount === 0) return "empty";
|
|
943
|
+
if (fileCount > 200) return "too-many";
|
|
944
|
+
return "ok";
|
|
945
|
+
}
|
|
946
|
+
function collectMarkdownFiles(nodes) {
|
|
947
|
+
return nodes.flatMap((node) => {
|
|
948
|
+
if (node.type === "directory") return collectMarkdownFiles(node.children ?? []);
|
|
949
|
+
return getContentType(node.path) === "markdown" ? [node.path] : [];
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
function findDirectoryChildren(nodes, path) {
|
|
953
|
+
for (const node of nodes) {
|
|
954
|
+
if (node.type !== "directory") continue;
|
|
955
|
+
if (node.path === path) return node.children ?? [];
|
|
956
|
+
if (path.startsWith(`${node.path}/`)) return findDirectoryChildren(node.children ?? [], path);
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
/**
|
|
960
|
+
* The Markdown files under `directory`, in the order the file tree lists them,
|
|
961
|
+
* or `undefined` when the tree has no such directory. The tree already leaves
|
|
962
|
+
* out what `.gitignore` excludes.
|
|
963
|
+
*/
|
|
964
|
+
function directoryMarkdownFiles(tree, directory) {
|
|
965
|
+
const children = directory === null ? tree : findDirectoryChildren(tree, directory);
|
|
966
|
+
return children && collectMarkdownFiles(children);
|
|
967
|
+
}
|
|
968
|
+
function directoryEntry(tree, path, rootName) {
|
|
969
|
+
return {
|
|
970
|
+
path,
|
|
971
|
+
name: directoryName(path, rootName),
|
|
972
|
+
markdownFileCount: directoryMarkdownFiles(tree, path)?.length ?? 0
|
|
973
|
+
};
|
|
974
|
+
}
|
|
975
|
+
/**
|
|
976
|
+
* The directories that can be saved as one PDF while `currentPath` is shown:
|
|
977
|
+
* the browsed directory, then each directory containing `currentPath`,
|
|
978
|
+
* outermost first.
|
|
979
|
+
*/
|
|
980
|
+
function directoryPdfEntries(tree, currentPath, rootName) {
|
|
981
|
+
return [directoryEntry(tree, null, rootName), ...findAncestorPaths(tree, currentPath).map((path) => directoryEntry(tree, path, rootName))];
|
|
982
|
+
}
|
|
983
|
+
/**
|
|
984
|
+
* An HTML file is printed from its own page, so that it comes out whole and
|
|
985
|
+
* as it styles itself; a Markdown file from the print page.
|
|
986
|
+
*/
|
|
987
|
+
function filePrintRequest(path, contentType) {
|
|
988
|
+
return {
|
|
989
|
+
url: contentType === "html" ? rawFileUrl(path) : printFileUrl(path),
|
|
990
|
+
title: filePdfTitle(path)
|
|
991
|
+
};
|
|
992
|
+
}
|
|
993
|
+
function directoryPrintRequest(entry) {
|
|
994
|
+
return {
|
|
995
|
+
url: printDirectoryUrl(entry.path),
|
|
996
|
+
title: entry.name
|
|
997
|
+
};
|
|
998
|
+
}
|
|
999
|
+
//#endregion
|
|
1000
|
+
//#region src/components/layout/menu-keys.ts
|
|
1001
|
+
/**
|
|
1002
|
+
* What a key pressed inside a menu does, given the focused item's index among
|
|
1003
|
+
* the `count` enabled items (-1 when none has focus). Arrow keys wrap around;
|
|
1004
|
+
* Escape closes the menu and returns focus to its button, Tab closes it and
|
|
1005
|
+
* lets focus move on. Other keys do nothing (`undefined`).
|
|
1006
|
+
*/
|
|
1007
|
+
function menuKeyAction(key, index, count) {
|
|
1008
|
+
switch (key) {
|
|
1009
|
+
case "Escape": return {
|
|
1010
|
+
type: "close",
|
|
1011
|
+
returnFocus: true
|
|
1012
|
+
};
|
|
1013
|
+
case "Tab": return {
|
|
1014
|
+
type: "close",
|
|
1015
|
+
returnFocus: false
|
|
1016
|
+
};
|
|
1017
|
+
}
|
|
1018
|
+
if (count === 0) return void 0;
|
|
1019
|
+
switch (key) {
|
|
1020
|
+
case "ArrowDown": return {
|
|
1021
|
+
type: "focus",
|
|
1022
|
+
index: index < 0 ? 0 : (index + 1) % count
|
|
1023
|
+
};
|
|
1024
|
+
case "ArrowUp": return {
|
|
1025
|
+
type: "focus",
|
|
1026
|
+
index: index < 0 ? count - 1 : (index - 1 + count) % count
|
|
1027
|
+
};
|
|
1028
|
+
case "Home": return {
|
|
1029
|
+
type: "focus",
|
|
1030
|
+
index: 0
|
|
1031
|
+
};
|
|
1032
|
+
case "End": return {
|
|
1033
|
+
type: "focus",
|
|
1034
|
+
index: count - 1
|
|
1035
|
+
};
|
|
1036
|
+
default: return;
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
//#endregion
|
|
1040
|
+
//#region src/components/layout/pdf-menu.tsx
|
|
1041
|
+
const ITEM_CLASS = "flex items-center gap-x-3 w-full py-2 px-3 text-left text-sm text-foreground rounded-md enabled:cursor-pointer enabled:hover:bg-sidebar-accent focus-visible:bg-sidebar-accent disabled:opacity-50";
|
|
1042
|
+
/** How the menu shows a directory with `count` Markdown files. */
|
|
1043
|
+
function directoryItemState(count) {
|
|
1044
|
+
switch (directoryPdfStatus(count)) {
|
|
1045
|
+
case "empty": return {
|
|
1046
|
+
description: "No Markdown files",
|
|
1047
|
+
disabled: true
|
|
1048
|
+
};
|
|
1049
|
+
case "too-many": return {
|
|
1050
|
+
description: `More than 200 Markdown files`,
|
|
1051
|
+
disabled: true
|
|
1052
|
+
};
|
|
1053
|
+
case "ok": return {
|
|
1054
|
+
description: `${count} Markdown file${count === 1 ? "" : "s"}`,
|
|
1055
|
+
disabled: false
|
|
1056
|
+
};
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
function MenuItem({ icon, label, description, disabled, onSelect }) {
|
|
1060
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
1061
|
+
type: "button",
|
|
1062
|
+
role: "menuitem",
|
|
1063
|
+
disabled,
|
|
1064
|
+
onClick: onSelect,
|
|
1065
|
+
class: ITEM_CLASS,
|
|
1066
|
+
children: [icon, /* @__PURE__ */ jsxs("span", {
|
|
1067
|
+
class: "min-w-0 flex-1",
|
|
1068
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1069
|
+
class: "block truncate",
|
|
1070
|
+
children: label
|
|
1071
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
1072
|
+
class: "block text-xs text-muted-foreground",
|
|
1073
|
+
children: description
|
|
1074
|
+
})]
|
|
1075
|
+
})]
|
|
1076
|
+
});
|
|
1077
|
+
}
|
|
1078
|
+
/** The menu's items: the shown file, then each directory. */
|
|
1079
|
+
function pdfMenuItems({ currentPath, currentName, contentType, directories }) {
|
|
1080
|
+
return [{
|
|
1081
|
+
kind: "file",
|
|
1082
|
+
key: `file:${currentPath}`,
|
|
1083
|
+
label: currentName,
|
|
1084
|
+
description: "This file",
|
|
1085
|
+
disabled: false,
|
|
1086
|
+
request: filePrintRequest(currentPath, contentType)
|
|
1087
|
+
}, ...directories.map((directory) => ({
|
|
1088
|
+
kind: "directory",
|
|
1089
|
+
key: `dir:${directory.path ?? ""}`,
|
|
1090
|
+
label: directory.name,
|
|
1091
|
+
...directoryItemState(directory.markdownFileCount),
|
|
1092
|
+
request: directoryPrintRequest(directory)
|
|
1093
|
+
}))];
|
|
1094
|
+
}
|
|
1095
|
+
/**
|
|
1096
|
+
* Header button whose menu saves the shown file, or the Markdown files under
|
|
1097
|
+
* one of its directories, as a PDF.
|
|
1098
|
+
*/
|
|
1099
|
+
function PdfMenu({ onPrint, ...source }) {
|
|
1100
|
+
const [open, setOpen] = useState(false);
|
|
1101
|
+
const rootRef = useRef(null);
|
|
1102
|
+
const buttonRef = useRef(null);
|
|
1103
|
+
const menuRef = useRef(null);
|
|
1104
|
+
const items = () => Array.from(menuRef.current?.querySelectorAll("[role=menuitem]:not(:disabled)") ?? []);
|
|
1105
|
+
useEffect(() => {
|
|
1106
|
+
if (!open) return;
|
|
1107
|
+
items()[0]?.focus();
|
|
1108
|
+
const onPointerDown = (e) => {
|
|
1109
|
+
if (!rootRef.current?.contains(e.target)) setOpen(false);
|
|
1110
|
+
};
|
|
1111
|
+
const onWindowBlur = () => setOpen(false);
|
|
1112
|
+
document.addEventListener("pointerdown", onPointerDown);
|
|
1113
|
+
window.addEventListener("blur", onWindowBlur);
|
|
1114
|
+
return () => {
|
|
1115
|
+
document.removeEventListener("pointerdown", onPointerDown);
|
|
1116
|
+
window.removeEventListener("blur", onWindowBlur);
|
|
1117
|
+
};
|
|
1118
|
+
}, [open]);
|
|
1119
|
+
const close = () => {
|
|
1120
|
+
setOpen(false);
|
|
1121
|
+
buttonRef.current?.focus();
|
|
1122
|
+
};
|
|
1123
|
+
const select = (request) => {
|
|
1124
|
+
close();
|
|
1125
|
+
onPrint(request);
|
|
1126
|
+
};
|
|
1127
|
+
const onMenuKeyDown = (e) => {
|
|
1128
|
+
const enabled = items();
|
|
1129
|
+
const action = menuKeyAction(e.key, enabled.indexOf(document.activeElement), enabled.length);
|
|
1130
|
+
if (!action) return;
|
|
1131
|
+
if (action.type === "focus") enabled[action.index]?.focus();
|
|
1132
|
+
else if (action.returnFocus) close();
|
|
1133
|
+
else {
|
|
1134
|
+
setOpen(false);
|
|
1135
|
+
return;
|
|
1136
|
+
}
|
|
1137
|
+
e.preventDefault();
|
|
1138
|
+
};
|
|
1139
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1140
|
+
ref: rootRef,
|
|
1141
|
+
class: "relative",
|
|
1142
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
1143
|
+
ref: buttonRef,
|
|
1144
|
+
type: "button",
|
|
1145
|
+
id: "pdf-menu-button",
|
|
1146
|
+
"aria-label": "Save as PDF",
|
|
1147
|
+
"aria-haspopup": "menu",
|
|
1148
|
+
"aria-expanded": open,
|
|
1149
|
+
"aria-controls": open ? "pdf-menu" : void 0,
|
|
1150
|
+
onClick: () => setOpen((o) => !o),
|
|
1151
|
+
onKeyDown: (e) => {
|
|
1152
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
1153
|
+
e.preventDefault();
|
|
1154
|
+
setOpen(true);
|
|
1155
|
+
}
|
|
1156
|
+
},
|
|
1157
|
+
class: "shrink-0 w-7 h-7 inline-flex justify-center items-center rounded-lg text-muted-foreground hover:text-foreground cursor-pointer",
|
|
1158
|
+
children: /* @__PURE__ */ jsx(FileDownIcon, { class: "size-4" })
|
|
1159
|
+
}), open && /* @__PURE__ */ jsxs("div", {
|
|
1160
|
+
ref: menuRef,
|
|
1161
|
+
id: "pdf-menu",
|
|
1162
|
+
role: "menu",
|
|
1163
|
+
"aria-labelledby": "pdf-menu-button",
|
|
1164
|
+
onKeyDown: onMenuKeyDown,
|
|
1165
|
+
class: "absolute end-0 top-full mt-1 z-60 w-64 max-w-[calc(100vw-1rem)] p-1 bg-background border border-muted-foreground/25 rounded-lg shadow-lg",
|
|
1166
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
1167
|
+
"aria-hidden": "true",
|
|
1168
|
+
class: "px-3 pt-1.5 pb-1 text-xs font-medium text-muted-foreground",
|
|
1169
|
+
children: "Save as PDF"
|
|
1170
|
+
}), pdfMenuItems(source).map((item) => /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(MenuItem, {
|
|
1171
|
+
icon: item.kind === "file" ? /* @__PURE__ */ jsx(FileIcon, { class: "shrink-0 size-4" }) : /* @__PURE__ */ jsx(FolderIcon, { class: "shrink-0 size-4" }),
|
|
1172
|
+
label: item.label,
|
|
1173
|
+
description: item.description,
|
|
1174
|
+
disabled: item.disabled,
|
|
1175
|
+
onSelect: () => select(item.request)
|
|
1176
|
+
}), item.kind === "file" && /* @__PURE__ */ jsx("hr", { class: "my-1 border-border" })] }, item.key))]
|
|
1177
|
+
})]
|
|
1178
|
+
});
|
|
1179
|
+
}
|
|
1180
|
+
//#endregion
|
|
870
1181
|
//#region src/components/navigation/file-tree-items.tsx
|
|
871
1182
|
const MAX_DEPTH = 20;
|
|
872
1183
|
function DirectoryItem({ node, currentPath, depth, isOpen, onToggle }) {
|
|
873
|
-
const open = isOpen
|
|
1184
|
+
const open = isOpen(node.path);
|
|
874
1185
|
return /* @__PURE__ */ jsxs("li", {
|
|
875
1186
|
class: depth === 0 ? "px-2 lg:px-5" : "",
|
|
876
1187
|
children: [/* @__PURE__ */ jsxs("button", {
|
|
@@ -884,7 +1195,7 @@ function DirectoryItem({ node, currentPath, depth, isOpen, onToggle }) {
|
|
|
884
1195
|
class: "min-w-0 truncate",
|
|
885
1196
|
children: node.name
|
|
886
1197
|
}),
|
|
887
|
-
/* @__PURE__ */ jsx(ChevronDownIcon, { class: `${open ? "" : "-rotate-
|
|
1198
|
+
/* @__PURE__ */ jsx(ChevronDownIcon, { class: `${open ? "" : "-rotate-90 "}shrink-0 size-3.5 ms-auto transition-transform` })
|
|
888
1199
|
]
|
|
889
1200
|
}), open && /* @__PURE__ */ jsx("ul", {
|
|
890
1201
|
class: "ps-7 mt-1 flex flex-col gap-y-1 relative before:absolute before:top-0 before:start-[1.125rem] before:w-px before:h-full before:bg-sidebar-border",
|
|
@@ -999,6 +1310,22 @@ function Sidebar({ title, tree, currentPath, onClose, isOpen, onToggle, searchQu
|
|
|
999
1310
|
})] });
|
|
1000
1311
|
}
|
|
1001
1312
|
//#endregion
|
|
1313
|
+
//#region src/core/file-tree-open-state.ts
|
|
1314
|
+
/**
|
|
1315
|
+
* State before any persisted state is known: only the ancestors of the
|
|
1316
|
+
* displayed file are open. Shared by SSR and the first client render so that
|
|
1317
|
+
* hydration sees identical markup.
|
|
1318
|
+
*/
|
|
1319
|
+
function initialOpenState(tree, currentPath) {
|
|
1320
|
+
return {
|
|
1321
|
+
expanded: /* @__PURE__ */ new Set(),
|
|
1322
|
+
revealed: new Set(findAncestorPaths(tree, currentPath))
|
|
1323
|
+
};
|
|
1324
|
+
}
|
|
1325
|
+
function isDirectoryOpen(state, path) {
|
|
1326
|
+
return state.expanded.has(path) || state.revealed.has(path);
|
|
1327
|
+
}
|
|
1328
|
+
//#endregion
|
|
1002
1329
|
//#region src/lib/project-id.ts
|
|
1003
1330
|
/**
|
|
1004
1331
|
* Create a stable, short project identifier from an absolute path.
|
|
@@ -1015,10 +1342,16 @@ function createProjectId(absolutePath) {
|
|
|
1015
1342
|
}
|
|
1016
1343
|
//#endregion
|
|
1017
1344
|
//#region src/server/renderer/client-bundle.js
|
|
1018
|
-
const clientBundle = "\"use strict\";(()=>{var G,h,Ze,Vt,N,Ye,Ge,et,pe,X,z,tt,me,_e,fe,Xt,Q={},J=[],Yt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ee=Array.isArray;function M(e,t){for(var n in t)e[n]=t[n];return e}function he(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function qt(e,t,n){var r,s,o,l={};for(o in t)o==\"key\"?r=t[o]:o==\"ref\"?s=t[o]:l[o]=t[o];if(arguments.length>2&&(l.children=arguments.length>3?G.call(arguments,2):n),typeof e==\"function\"&&e.defaultProps!=null)for(o in e.defaultProps)l[o]===void 0&&(l[o]=e.defaultProps[o]);return Y(e,l,r,s,null)}function Y(e,t,n,r,s){var o={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:s??++Ze,__i:-1,__u:0};return s==null&&h.vnode!=null&&h.vnode(o),o}function k(e){return e.children}function q(e,t){this.props=e,this.context=t}function U(e,t){if(t==null)return e.__?U(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==\"function\"?U(e):null}function Qt(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],s=[],o=M({},t);o.__v=t.__v+1,h.vnode&&h.vnode(o),ge(e.__P,o,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??U(t),!!(32&t.__u),s),o.__v=t.__v,o.__.__k[o.__i]=o,st(r,o,s),t.__e=t.__=null,o.__e!=n&&nt(o)}}function nt(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),nt(e)}function qe(e){(!e.__d&&(e.__d=!0)&&N.push(e)&&!Z.__r++||Ye!=h.debounceRendering)&&((Ye=h.debounceRendering)||Ge)(Z)}function Z(){try{for(var e,t=1;N.length;)N.length>t&&N.sort(et),e=N.shift(),t=N.length,Qt(e)}finally{N.length=Z.__r=0}}function rt(e,t,n,r,s,o,l,u,d,c,p){var f,a,_,g,T,x,v=r&&r.__k||J,m=t.length;for(d=Jt(n,t,v,d,m),f=0;f<m;f++)(_=n.__k[f])!=null&&(a=_.__i!=-1&&v[_.__i]||Q,_.__i=f,x=ge(e,_,a,s,o,l,u,d,c,p),g=_.__e,_.ref&&a.ref!=_.ref&&(a.ref&&ye(a.ref,null,_),p.push(_.ref,_.__c||g,_)),T==null&&g!=null&&(T=g),4&_.__u?(d=ot(_,d,e),a.__e&&(a.__e=null)):typeof _.type==\"function\"&&x!==void 0?d=x:g&&(d=g.nextSibling),_.__u&=-7);return n.__e=T,d}function Jt(e,t,n,r,s){var o,l,u,d,c,p=n.length,f=p,a=0;for(e.__k=new Array(s),o=0;o<s;o++)(l=t[o])!=null&&typeof l!=\"boolean\"&&typeof l!=\"function\"?(typeof l==\"string\"||typeof l==\"number\"||typeof l==\"bigint\"||l.constructor==String?l=e.__k[o]=Y(null,l,null,null,null):ee(l)?l=e.__k[o]=Y(k,{children:l},null,null,null):l.constructor===void 0&&l.__b>0?l=e.__k[o]=Y(l.type,l.props,l.key,l.ref?l.ref:null,l.__v):e.__k[o]=l,d=o+a,l.__=e,l.__b=e.__b+1,u=null,(c=l.__i=Zt(l,n,d,f))!=-1&&(f--,(u=n[c])&&(u.__u|=2)),u==null||u.__v==null?(c==-1&&(s>p?a--:s<p&&a++),typeof l.type!=\"function\"&&(l.__u|=4)):c!=d&&(c==d-1?a--:c==d+1?a++:(c>d?a--:a++,l.__u|=4))):e.__k[o]=null;if(f)for(o=0;o<p;o++)(u=n[o])!=null&&(2&u.__u)==0&&(u.__e==r&&(r=U(u)),at(u,u));return r}function ot(e,t,n){var r,s;if(typeof e.type==\"function\"){for(r=e.__k,s=0;r&&s<r.length;s++)r[s]&&(r[s].__=e,t=ot(r[s],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=U(e)),t=n.insertBefore(e.__e,t||null));do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Zt(e,t,n,r){var s,o,l,u=e.key,d=e.type,c=t[n],p=c!=null&&(2&c.__u)==0;if(c===null&&u==null||p&&u==c.key&&d==c.type)return n;if(r>(p?1:0)){for(s=n-1,o=n+1;s>=0||o<t.length;)if((c=t[l=s>=0?s--:o++])!=null&&(2&c.__u)==0&&u==c.key&&d==c.type)return l}return-1}function Qe(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||Yt.test(t)?n:n+\"px\"}function V(e,t,n,r,s){var o,l;e:if(t==\"style\")if(typeof n==\"string\")e.style.cssText=n;else{if(typeof r==\"string\"&&(e.style.cssText=r=\"\"),r)for(t in r)n&&t in n||Qe(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||Qe(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")o=t!=(t=t.replace(tt,\"$1\")),l=t.toLowerCase(),t=l in e||t==\"onFocusOut\"||t==\"onFocusIn\"?l.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=n,n?r?n[z]=r[z]:(n[z]=me,e.addEventListener(t,o?fe:_e,o)):e.removeEventListener(t,o?fe:_e,o);else{if(s==\"http://www.w3.org/2000/svg\")t=t.replace(/xlink(H|:h)/,\"h\").replace(/sName$/,\"s\");else if(t!=\"width\"&&t!=\"height\"&&t!=\"href\"&&t!=\"list\"&&t!=\"form\"&&t!=\"tabIndex\"&&t!=\"download\"&&t!=\"rowSpan\"&&t!=\"colSpan\"&&t!=\"role\"&&t!=\"popover\"&&t in e)try{e[t]=n??\"\";break e}catch{}typeof n==\"function\"||(n==null||n===!1&&t[4]!=\"-\"?e.removeAttribute(t):e.setAttribute(t,t==\"popover\"&&n==1?\"\":n))}}function Je(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[X]==null)t[X]=me++;else if(t[X]<n[z])return;return n(h.event?h.event(t):t)}}}function ge(e,t,n,r,s,o,l,u,d,c){var p,f,a,_,g,T,x,v,m,w,R,I,B,$,D,F,C=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(d=!!(32&n.__u),o=[u=t.__e=n.__e]),(p=h.__b)&&p(t);e:if(typeof C==\"function\"){f=l.length;try{if(m=t.props,w=C.prototype&&C.prototype.render,R=(p=C.contextType)&&r[p.__c],I=p?R?R.props.value:p.__:r,n.__c?v=(a=t.__c=n.__c).__=a.__E:(w?t.__c=a=new C(m,I):(t.__c=a=new q(m,I),a.constructor=C,a.render=en),R&&R.sub(a),a.state||(a.state={}),a.__n=r,_=a.__d=!0,a.__h=[],a._sb=[]),w&&a.__s==null&&(a.__s=a.state),w&&C.getDerivedStateFromProps!=null&&(a.__s==a.state&&(a.__s=M({},a.__s)),M(a.__s,C.getDerivedStateFromProps(m,a.__s))),g=a.props,T=a.state,a.__v=t,_)w&&C.getDerivedStateFromProps==null&&a.componentWillMount!=null&&a.componentWillMount(),w&&a.componentDidMount!=null&&a.__h.push(a.componentDidMount);else{if(w&&C.getDerivedStateFromProps==null&&m!==g&&a.componentWillReceiveProps!=null&&a.componentWillReceiveProps(m,I),t.__v==n.__v||!a.__e&&a.shouldComponentUpdate!=null&&a.shouldComponentUpdate(m,a.__s,I)===!1){t.__v!=n.__v&&(a.props=m,a.state=a.__s,a.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(A){A&&(A.__=t)}),J.push.apply(a.__h,a._sb),a._sb=[],a.__h.length&&l.push(a),u=U(n);break e}a.componentWillUpdate!=null&&a.componentWillUpdate(m,a.__s,I),w&&a.componentDidUpdate!=null&&a.__h.push(function(){a.componentDidUpdate(g,T,x)})}if(a.context=I,a.props=m,a.__P=e,a.__e=!1,B=h.__r,$=0,w)a.state=a.__s,a.__d=!1,B&&B(t),p=a.render(a.props,a.state,a.context),J.push.apply(a.__h,a._sb),a._sb=[];else do a.__d=!1,B&&B(t),p=a.render(a.props,a.state,a.context),a.state=a.__s;while(a.__d&&++$<25);a.state=a.__s,a.getChildContext!=null&&(r=M(M({},r),a.getChildContext())),w&&!_&&a.getSnapshotBeforeUpdate!=null&&(x=a.getSnapshotBeforeUpdate(g,T)),D=p!=null&&p.type===k&&p.key==null?lt(p.props.children):p,u=rt(e,ee(D)?D:[D],t,n,r,s,o,l,u,d,c),a.base=t.__e,t.__u&=-161,a.__h.length&&l.push(a),v&&(a.__E=a.__=null)}catch(A){if(l.length=f,t.__v=null,d||o!=null){if(A.then){for(t.__u|=d?160:128;u&&u.nodeType==8&&u.nextSibling;)u=u.nextSibling;o!=null&&(o[o.indexOf(u)]=null),t.__e=u}else if(o!=null)for(F=o.length;F--;)he(o[F])}else t.__e=n.__e;t.__k==null&&(t.__k=n.__k||[]),A.then||it(t),h.__e(A,t,n)}}else o==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):u=t.__e=Gt(n.__e,t,n,r,s,o,l,d,c);return(p=h.diffed)&&p(t),128&t.__u?void 0:u}function it(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(it))}function st(e,t,n){for(var r=0;r<n.length;r++)ye(n[r],n[++r],n[++r]);h.__c&&h.__c(t,e),e.some(function(s){try{e=s.__h,s.__h=[],e.some(function(o){o.call(s)})}catch(o){h.__e(o,s.__v)}})}function lt(e){return typeof e!=\"object\"||e==null||e.__b>0?e:ee(e)?e.map(lt):e.constructor!==void 0?null:M({},e)}function Gt(e,t,n,r,s,o,l,u,d){var c,p,f,a,_,g,T,x=n.props||Q,v=t.props,m=t.type;if(m==\"svg\"?s=\"http://www.w3.org/2000/svg\":m==\"math\"?s=\"http://www.w3.org/1998/Math/MathML\":s||(s=\"http://www.w3.org/1999/xhtml\"),o!=null){for(c=0;c<o.length;c++)if((_=o[c])&&\"setAttribute\"in _==!!m&&(m?_.localName==m:_.nodeType==3)){e=_,o[c]=null;break}}if(e==null){if(m==null)return document.createTextNode(v);e=document.createElementNS(s,m,v.is&&v),u&&(h.__m&&h.__m(t,o),u=!1),o=null}if(m==null)x===v||u&&e.data==v||(e.data=v);else{if(o=m==\"textarea\"&&v.defaultValue!=null?null:o&&G.call(e.childNodes),!u&&o!=null)for(x={},c=0;c<e.attributes.length;c++)x[(_=e.attributes[c]).name]=_.value;for(c in x)_=x[c],c==\"dangerouslySetInnerHTML\"?f=_:c==\"children\"||c in v||c==\"value\"&&\"defaultValue\"in v||c==\"checked\"&&\"defaultChecked\"in v||V(e,c,null,_,s);for(c in v)_=v[c],c==\"children\"?a=_:c==\"dangerouslySetInnerHTML\"?p=_:c==\"value\"?g=_:c==\"checked\"?T=_:u&&typeof _!=\"function\"||x[c]===_||V(e,c,_,x[c],s);if(p)u||f&&(p.__html==f.__html||p.__html==e.innerHTML)||(e.innerHTML=p.__html),t.__k=[];else if(f&&(e.innerHTML=\"\"),rt(t.type==\"template\"?e.content:e,ee(a)?a:[a],t,n,r,m==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":s,o,l,o?o[0]:n.__k&&U(n,0),u,d),o!=null)for(c=o.length;c--;)he(o[c]);u&&m!=\"textarea\"||(c=\"value\",m==\"progress\"&&g==null?e.removeAttribute(\"value\"):g!=null&&(g!==e[c]||m==\"progress\"&&!g||m==\"option\"&&g!=x[c])&&V(e,c,g,x[c],s),c=\"checked\",T!=null&&T!=e[c]&&V(e,c,T,x[c],s))}return e}function ye(e,t,n){try{if(typeof e==\"function\"){var r=typeof e.__u==\"function\";r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(s){h.__e(s,n)}}function at(e,t,n){var r,s;if(h.unmount&&h.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||ye(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){h.__e(o,t)}r.base=r.__P=r.__n=null}if(r=e.__k)for(s=0;s<r.length;s++)r[s]&&at(r[s],t,n||typeof e.type!=\"function\");n||he(e.__e),e.__c=e.__=e.__e=void 0}function en(e,t,n){return this.constructor(e,n)}function tn(e,t,n){var r,s,o,l;t==document&&(t=document.documentElement),h.__&&h.__(e,t),s=(r=typeof n==\"function\")?null:n&&n.__k||t.__k,o=[],l=[],ge(t,e=(!r&&n||t).__k=qt(k,null,[e]),s||Q,Q,t.namespaceURI,!r&&n?[n]:s?null:t.firstChild?G.call(t.childNodes):null,o,!r&&n?n:s?s.__e:t.firstChild,r,l),st(o,e,l),e.props.children=null}function te(e,t){tn(e,t,te)}G=J.slice,h={__e:function(e,t,n,r){for(var s,o,l;t=t.__;)if((s=t.__c)&&!s.__)try{if((o=s.constructor)&&o.getDerivedStateFromError!=null&&(s.setState(o.getDerivedStateFromError(e)),l=s.__d),s.componentDidCatch!=null&&(s.componentDidCatch(e,r||{}),l=s.__d),l)return s.__E=s}catch(u){e=u}throw e}},Ze=0,Vt=function(e){return e!=null&&e.constructor===void 0},q.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=M({},this.state),typeof e==\"function\"&&(e=e(M({},n),this.props)),e&&M(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),qe(this))},q.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),qe(this))},q.prototype.render=k,N=[],Ge=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,et=function(e,t){return e.__v.__b-t.__v.__b},Z.__r=0,pe=Math.random().toString(8),X=\"__d\"+pe,z=\"__a\"+pe,tt=/(PointerCapture)$|Capture$/i,me=0,_e=Je(!1),fe=Je(!0),Xt=0;var O,y,ve,ct,j=0,gt=[],b=h,ut=b.__b,dt=b.__r,pt=b.diffed,_t=b.__c,ft=b.unmount,mt=b.__;function re(e,t){b.__h&&b.__h(y,e,j||t),j=0;var n=y.__H||(y.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function E(e){return j=1,nn(yt,e)}function nn(e,t,n){var r=re(O++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):yt(void 0,t),function(u){var d=r.__N?r.__N[0]:r.__[0],c=r.t(d,u);d!==c&&(r.__N=[c,r.__[1]],r.__c.setState({}))}],r.__c=y,!y.__f)){var s=function(u,d,c){if(!r.__c.__H)return!0;var p=!1,f=r.__c.props!==u;if(r.__c.__H.__.some(function(_){if(_.__N){p=!0;var g=_.__[0];_.__=_.__N,_.__N=void 0,g!==_.__[0]&&(f=!0)}}),o){var a=o.call(this,u,d,c);return p?a||f:a}return!p||f};y.__f=!0;var o=y.shouldComponentUpdate,l=y.componentWillUpdate;y.componentWillUpdate=function(u,d,c){if(this.__e){var p=o;o=void 0,s(u,d,c),o=p}l&&l.call(this,u,d,c)},y.shouldComponentUpdate=s}return r.__N||r.__}function H(e,t){var n=re(O++,3);!b.__s&&Se(n.__H,t)&&(n.__=e,n.u=t,y.__H.__h.push(n))}function oe(e,t){var n=re(O++,4);!b.__s&&Se(n.__H,t)&&(n.__=e,n.u=t,y.__h.push(n))}function P(e){return j=5,ie(function(){return{current:e}},[])}function ie(e,t){var n=re(O++,7);return Se(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function L(e,t){return j=8,ie(function(){return e},t)}function rn(){for(var e;e=gt.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(ne),t.__h.some(be),t.__h=[]}catch(n){t.__h=[],b.__e(n,e.__v)}}}b.__b=function(e){y=null,ut&&ut(e)},b.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),mt&&mt(e,t)},b.__r=function(e){dt&&dt(e),O=0;var t=(y=e.__c).__H;t&&(ve===y?(t.__h=[],y.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(ne),t.__h.some(be),t.__h=[],O=0)),ve=y},b.diffed=function(e){pt&&pt(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(gt.push(t)!==1&&ct===b.requestAnimationFrame||((ct=b.requestAnimationFrame)||on)(rn)),t.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),ve=y=null},b.__c=function(e,t){t.some(function(n){try{n.__h.some(ne),n.__h=n.__h.filter(function(r){return!r.__||be(r)})}catch(r){t.some(function(s){s.__h&&(s.__h=[])}),t=[],b.__e(r,n.__v)}}),_t&&_t(e,t)},b.unmount=function(e){ft&&ft(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{ne(r)}catch(s){t=s}}),n.__H=void 0,t&&b.__e(t,n.__v))};var ht=typeof requestAnimationFrame==\"function\";function on(e){var t,n=function(){clearTimeout(r),ht&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);ht&&(t=requestAnimationFrame(n))}function ne(e){var t=y,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),y=t}function be(e){var t=y;e.__c=e.__(),y=t}function Se(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function yt(e,t){return typeof t==\"function\"?t(e):t}var vt={border:\"none\",width:\"100%\",height:\"100%\",position:\"absolute\",top:\"0\",left:\"0\"};var sn=\"/__peek/raw/\";function xe(e){return e.split(\"/\").map(encodeURIComponent).join(\"/\")}function bt(e){return`${sn}${xe(e)}`}var ln=0;function i(e,t,n,r,s,o){t||(t={});var l,u,d=t;if(\"ref\"in d)for(u in d={},t)u==\"ref\"?l=t[u]:d[u]=t[u];var c={type:e,props:d,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ln,__i:-1,__u:0,__source:s,__self:o};if(typeof e==\"function\"&&(l=e.defaultProps))for(u in l)d[u]===void 0&&(d[u]=l[u]);return h.vnode&&h.vnode(c),c}function Te({class:e,children:t}){return i(\"main\",{id:\"main-content\",class:e??\"\",children:t})}function se({htmlContent:e}){return i(\"div\",{id:\"markdown-content\",class:\"markdown-body\",dangerouslySetInnerHTML:{__html:e}})}function St({contentType:e,fileTitle:t,filePath:n,htmlContent:r,htmlReloadKey:s,markdownClass:o=\"px-5 sm:px-10 py-5 sm:py-10\"}){return e===\"html\"?i(Te,{class:\"relative flex-1 overflow-hidden\",children:i(\"iframe\",{title:t,src:bt(n),style:vt},s)}):i(Te,{class:o,children:i(\"div\",{class:\"max-w-4xl mx-auto\",children:i(se,{htmlContent:r})})})}function S({class:e,children:t,width:n=\"24\",height:r=\"24\",viewBox:s=\"0 0 24 24\",...o}){return i(\"svg\",{...o,class:e,\"aria-hidden\":\"true\",xmlns:\"http://www.w3.org/2000/svg\",width:n,height:r,viewBox:s,fill:\"none\",stroke:\"currentColor\",\"stroke-width\":\"2\",\"stroke-linecap\":\"round\",\"stroke-linejoin\":\"round\",children:t})}function we(e){return i(S,{...e,children:i(\"path\",{d:\"m6 9 6 6 6-6\"})})}function ke({class:e}){return i(S,{class:e,children:[i(\"path\",{d:\"M15 3h6v6\"}),i(\"path\",{d:\"M10 14 21 3\"}),i(\"path\",{d:\"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6\"})]})}function Ee(e){return i(S,{...e,children:[i(\"path\",{d:\"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z\"}),i(\"path\",{d:\"M14 2v4a2 2 0 0 0 2 2h4\"})]})}function Ce(e){return i(S,{...e,children:i(\"path\",{d:\"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 0-1.69.9L9.6 8H4a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2Z\"})})}function Ie({class:e,...t}){return i(S,{class:e,...t,children:i(\"path\",{d:\"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z\"})})}function Pe({class:e,...t}){return i(S,{class:e,...t,children:[i(\"polyline\",{points:\"7 8 3 12 7 16\"}),i(\"line\",{x1:\"21\",x2:\"11\",y1:\"12\",y2:\"12\"}),i(\"line\",{x1:\"21\",x2:\"11\",y1:\"6\",y2:\"6\"}),i(\"line\",{x1:\"21\",x2:\"11\",y1:\"18\",y2:\"18\"})]})}function Fe({class:e,...t}){return i(S,{class:e,...t,children:i(\"path\",{d:\"M17 8L21 12L17 16M3 12H13M3 6H13M3 18H13\"})})}function Ae(e){return i(S,{...e,width:\"16\",height:\"16\",viewBox:\"0 0 16 16\",children:i(\"path\",{d:\"M6 13L10 3\",\"stroke-linecap\":\"round\"})})}function Me({class:e,...t}){return i(S,{class:e,...t,children:[i(\"circle\",{cx:\"12\",cy:\"12\",r:\"4\"}),i(\"path\",{d:\"M12 2v2\"}),i(\"path\",{d:\"M12 20v2\"}),i(\"path\",{d:\"m4.93 4.93 1.41 1.41\"}),i(\"path\",{d:\"m17.66 17.66 1.41 1.41\"}),i(\"path\",{d:\"M2 12h2\"}),i(\"path\",{d:\"M20 12h2\"}),i(\"path\",{d:\"m6.34 17.66-1.41 1.41\"}),i(\"path\",{d:\"m19.07 4.93-1.41 1.41\"})]})}function Le({class:e,...t}){return i(S,{class:e,...t,children:[i(\"path\",{d:\"M12 2v2\"}),i(\"path\",{d:\"M14.837 16.385a6 6 0 1 1-7.223-7.222c.624-.147.97.66.715 1.248a4 4 0 0 0 5.26 5.259c.589-.255 1.396.09 1.248.715\"}),i(\"path\",{d:\"M16 12a4 4 0 0 0-4-4\"}),i(\"path\",{d:\"m19 5-1.256 1.256\"}),i(\"path\",{d:\"M20 12h2\"})]})}var Re={dirItem:\"inline-flex items-center shrink-0\",dirLink:\"text-sm text-muted-foreground hover:text-foreground\",fileItem:\"inline-flex items-center text-sm font-semibold text-foreground truncate\"},an=\"shrink-0 mx-1 size-4 text-muted-foreground\";function xt({items:e}){return i(\"nav\",{\"aria-label\":\"Breadcrumb\",children:i(\"ol\",{class:\"flex items-center min-w-0\",children:e.map((t,n)=>{let r=n===e.length-1;return i(\"li\",{class:r?Re.fileItem:Re.dirItem,\"aria-current\":r?\"page\":void 0,children:r?t.label:i(k,{children:[i(\"a\",{class:Re.dirLink,href:t.href??\"#\",children:t.label}),i(Ae,{class:an})]})},n)})})})}function Tt({href:e}){return i(\"a\",{href:e,target:\"_blank\",rel:\"noopener noreferrer\",class:\"shrink-0 w-7 h-7 inline-flex justify-center items-center rounded-lg text-muted-foreground hover:text-foreground cursor-pointer\",\"aria-label\":\"Open in new tab\",children:i(ke,{class:\"size-4\"})})}function wt(){return i(\"button\",{type:\"button\",id:\"theme-toggle\",class:\"shrink-0 w-7 h-7 inline-flex justify-center items-center rounded-lg text-muted-foreground hover:text-foreground cursor-pointer\",\"aria-label\":\"Toggle theme\",children:[i(Me,{class:\"hidden size-4\",id:\"icon-theme-light\"}),i(Ie,{class:\"hidden size-4\",id:\"icon-theme-dark\"}),i(Le,{class:\"hidden size-4\",id:\"icon-theme-system\"})]})}function kt({id:e,breadcrumbs:t,showSidebarToggle:n,onToggleSidebar:r,externalLinkHref:s}){return i(\"header\",{id:e,class:\"sticky top-0 z-50 bg-background border-b border-border\",children:i(\"div\",{class:\"flex items-center justify-between w-full py-2 px-2 sm:px-5\",children:[i(\"div\",{class:\"flex items-center gap-1 min-w-0\",children:[n&&i(\"button\",{type:\"button\",id:\"sidebar-toggle\",onClick:r,class:\"shrink-0 w-7 h-7 inline-flex justify-center items-center rounded-lg text-muted-foreground hover:bg-sidebar-accent cursor-pointer\",children:[i(Fe,{class:\"shrink-0 size-4\",id:\"icon-sidebar-open\"}),i(Pe,{class:\"shrink-0 size-4 hidden\",id:\"icon-sidebar-close\"})]}),i(xt,{items:t})]}),i(\"div\",{class:\"flex items-center gap-1\",children:[i(wt,{}),s!==void 0&&i(Tt,{href:s})]})]})})}var cn=20;function un({node:e,currentPath:t,depth:n,isOpen:r,onToggle:s}){let o=r?r(e.path):!0;return i(\"li\",{class:n===0?\"px-2 lg:px-5\":\"\",children:[i(\"button\",{type:\"button\",\"aria-expanded\":o,onClick:()=>s?.(e.path),class:\"flex items-center gap-x-3 w-full py-2 px-3 text-left text-sm text-sidebar-foreground hover:bg-sidebar-accent rounded-lg overflow-hidden\",children:[i(Ce,{class:\"shrink-0 size-4\"}),i(\"span\",{class:\"min-w-0 truncate\",children:e.name}),i(we,{class:`${o?\"\":\"-rotate-180 \"}shrink-0 size-3.5 ms-auto transition-transform`})]}),o&&i(\"ul\",{class:\"ps-7 mt-1 flex flex-col gap-y-1 relative before:absolute before:top-0 before:start-[1.125rem] before:w-px before:h-full before:bg-sidebar-border\",children:e.children&&n<cn?i(Ne,{nodes:e.children,currentPath:t,depth:n+1,isOpen:r,onToggle:s}):null})]})}function Ne({nodes:e,currentPath:t,depth:n=0,isOpen:r,onToggle:s}){return i(k,{children:e.map(o=>{if(o.type===\"directory\")return i(un,{node:o,currentPath:t,depth:n,isOpen:r,onToggle:s},o.path);let l=t===o.path;return i(\"li\",{class:n===0?\"px-2 lg:px-5\":\"\",children:i(\"a\",{href:`/view?path=${encodeURIComponent(o.path)}`,class:`flex items-center gap-x-3 py-2 px-3 text-sm rounded-lg overflow-hidden ${l?\"bg-sidebar-accent text-sidebar-primary font-medium\":\"hover:bg-sidebar-accent text-sidebar-foreground\"}`,children:[i(Ee,{class:\"shrink-0 size-4\"}),i(\"span\",{class:\"min-w-0 truncate\",children:o.name})]})},o.path)})})}function Et({nodes:e,currentPath:t,isOpen:n,onToggle:r}){return i(\"ul\",{id:\"file-tree\",class:\"flex flex-col gap-y-1\",children:i(Ne,{nodes:e,currentPath:t,isOpen:n,onToggle:r})})}function Ct({title:e,tree:t,currentPath:n,onClose:r,isOpen:s,onToggle:o,searchQuery:l,onSearchChange:u,isSearching:d}){return i(k,{children:[i(\"div\",{role:\"none\",id:\"sidebar-overlay\",class:\"fixed inset-0 z-50 bg-black/50 hidden\",onClick:r}),i(\"aside\",{id:\"sidebar\",\"aria-label\":\"File navigation\",class:\"fixed inset-y-0 start-0 z-60 w-72 lg:w-auto overflow-hidden bg-sidebar border-e border-sidebar-border -translate-x-full\",children:[i(\"div\",{class:\"relative flex flex-col h-full max-h-full pt-3\",children:[i(\"header\",{class:\"flex-none h-11.5 ps-5 pe-2 lg:ps-8 flex items-center\",children:i(\"a\",{href:\"/\",class:\"flex-none text-sm font-semibold text-sidebar-foreground hover:text-sidebar-primary\",children:e})}),i(\"div\",{class:\"flex-none px-2 lg:px-5 mt-1.5 mb-1\",children:i(\"input\",{id:\"sidebar-search\",type:\"search\",\"aria-label\":\"Search files\",placeholder:\"Search files\\u2026\",value:l??\"\",onInput:c=>u?.(c.target.value),onKeyDown:c=>{c.key===\"Escape\"&&!c.isComposing&&(u?.(\"\"),c.currentTarget.blur())},class:\"w-full py-1.5 px-3 text-sm text-sidebar-foreground bg-sidebar-accent border border-sidebar-border rounded-lg outline-none focus:border-sidebar-primary placeholder:text-sidebar-foreground/50\"})}),i(\"div\",{class:\"flex-1 min-h-0 overflow-x-hidden overflow-y-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-none [&::-webkit-scrollbar-track]:bg-scrollbar-track [&::-webkit-scrollbar-thumb]:bg-scrollbar-thumb\",children:i(\"nav\",{class:\"pb-3 w-full flex flex-col\",children:d&&t.length===0?i(\"p\",{class:\"px-5 py-3 text-sm text-sidebar-foreground/60\",children:\"No matches found\"}):i(Et,{nodes:t,currentPath:n,isOpen:s,onToggle:o})})})]}),i(\"div\",{id:\"sidebar-resize\",class:\"absolute inset-y-0 end-0 w-1 cursor-col-resize hover:bg-sidebar-border hidden lg:block pointer-events-auto\"})]})]})}var dn=new Map([[\".md\",\"markdown\"],[\".html\",\"html\"],[\".htm\",\"html\"]]);function pn(e){let t=Math.max(e.lastIndexOf(\"/\"),e.lastIndexOf(\"\\\\\")),n=t===-1?e:e.slice(t+1),r=n.lastIndexOf(\".\");return r===-1||r===n.length-1?\"\":n.slice(r).toLowerCase()}function It(e){return dn.get(pn(e))??null}function Pt(e,t){return e.name.toLowerCase().includes(t)}function Ft(e,t){let n=t.trim().toLowerCase();return n===\"\"?e:At(e,n)}function At(e,t){let n=[];for(let r of e){if(r.type===\"directory\"){if(Pt(r,t)){n.push(r);continue}let s=r.children?At(r.children,t):[];s.length>0&&n.push({...r,children:s});continue}Pt(r,t)&&n.push(r)}return n}var He=\"file-tree-state\";function Mt(e){if(!e)return{};try{let t=JSON.parse(e);if(!t||typeof t!=\"object\"||Array.isArray(t))return{};let n={};for(let[r,s]of Object.entries(t)){if(!s||typeof s!=\"object\"||Array.isArray(s))continue;let{collapsed:o,lastAccess:l}=s;typeof l!=\"number\"||!Array.isArray(o)||(n[r]={collapsed:o.filter(u=>typeof u==\"string\"),lastAccess:l})}return n}catch{return{}}}function Lt(e,t,n){let r={};for(let[s,o]of Object.entries(e))t-o.lastAccess<=n&&(r[s]=o);return r}function Be(e,t){return new Set(e[t]?.collapsed??[])}function De(e,t,n,r){return{...e,[t]:{collapsed:Array.from(n),lastAccess:r}}}function Rt(e){return JSON.stringify(e)}function Nt(e){let[t,n]=E(()=>new Set),r=P(!0),s=P(t);s.current=t;function o(){try{return Mt(localStorage.getItem(He))}catch{return{}}}function l(c){try{localStorage.setItem(He,Rt(c))}catch{}}oe(()=>{if(!r.current)return;r.current=!1;let c=Date.now(),p=Lt(o(),c,2592e6),f=De(p,e,Be(p,e),c);l(f),n(Be(f,e))},[e]);let u=L(c=>{let p=new Set(s.current);p.has(c)?p.delete(c):p.add(c),s.current=p,n(p);let f=De(o(),e,p,Date.now());l(f)},[e]);return{isOpen:L(c=>!t.has(c),[t]),toggle:u}}async function W(e,t){try{let n=e?`/api/content?path=${encodeURIComponent(e)}`:\"/api/content\",r=await fetch(n,t?.signal?{signal:t.signal}:void 0);return r.ok?await r.text():(console.error(`[peek] Failed to fetch content: HTTP ${r.status}`),null)}catch(n){if(n instanceof DOMException&&n.name===\"AbortError\")throw n;return console.error(\"[peek] Failed to fetch content:\",n),null}}async function Ht(e){try{let t=await fetch(\"/api/tree\",e?.signal?{signal:e.signal}:void 0);if(!t.ok)return console.error(`[peek] Failed to fetch tree: HTTP ${t.status}`),null;let n=await t.json();return Array.isArray(n)?n:(console.error(\"[peek] Unexpected tree response format\"),null)}catch(t){if(t instanceof DOMException&&t.name===\"AbortError\")throw t;return console.error(\"[peek] Failed to fetch tree:\",t),null}}function K(e){return e&&e.replace(/\\\\/g,\"/\")}function le(e){let n=e.replace(/\\/+$/,\"\").split(\"/\");return n[n.length-1]||e}function Bt(e){let t=P(null),n=P(e);n.current=e;let r=L(async(s,o)=>{t.current&&t.current.abort();let l=new AbortController;t.current=l;try{let u=await W(s,{signal:l.signal});if(u===null)return;n.current(s,u),document.title=`${le(s)} - peek`;let d=`/view?path=${encodeURIComponent(s)}`;o&&history.pushState({path:s},\"\",d)}catch(u){if(u instanceof DOMException&&u.name===\"AbortError\")return;console.error(\"[peek] Failed to navigate:\",u)}},[]);return H(()=>{let s=new URLSearchParams(window.location.search).get(\"path\");s&&history.replaceState({path:s},\"\");function o(u){if(u.ctrlKey||u.metaKey||u.shiftKey||u.altKey)return;let d=u.target.closest(\"a[href]\");if(!d)return;let c;try{c=new URL(d.href,window.location.origin)}catch{return}if(c.origin!==window.location.origin||c.pathname!==\"/view\")return;let p=c.searchParams.get(\"path\");p&&(u.preventDefault(),r(p,!0))}function l(u){let c=u.state?.path??new URLSearchParams(window.location.search).get(\"path\");c?r(c,!1):window.location.reload()}return document.addEventListener(\"click\",o),window.addEventListener(\"popstate\",l),()=>{document.removeEventListener(\"click\",o),window.removeEventListener(\"popstate\",l)}},[r]),r}var fn=\"sidebar-search\";function mn(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t===\"INPUT\"||t===\"TEXTAREA\"||t===\"SELECT\"||e.isContentEditable}function Dt(e){H(()=>{function t(n){n.key===\"/\"&&(n.isComposing||mn(n.target)||(n.preventDefault(),e?.(),document.getElementById(fn)?.focus()))}return window.addEventListener(\"keydown\",t),()=>window.removeEventListener(\"keydown\",t)},[e])}var ae=\"sidebar-open\",Ut=\"sidebar-width\",Ue=200,Oe=480,hn=1024;function ce(){return window.innerWidth>=hn}function Ot(){let[e,t]=E(!1),n=P(!0);oe(()=>{if(n.current){n.current=!1;let l=localStorage.getItem(Ut);if(l){let u=Number(l);u>=Ue&&u<=Oe&&document.documentElement.style.setProperty(\"--sidebar-width\",`${u}px`)}if(ce()&&localStorage.getItem(ae)!==\"false\"){let u=[document.getElementById(\"sidebar\"),document.getElementById(\"header-bar\"),document.getElementById(\"main-content\")];for(let d of u)d&&(d.style.transition=\"none\");document.body.setAttribute(\"data-sidebar-open\",\"\"),document.body.offsetHeight,requestAnimationFrame(()=>{for(let d of u)d&&d.style.removeProperty(\"transition\")}),t(!0)}return}e?document.body.setAttribute(\"data-sidebar-open\",\"\"):document.body.removeAttribute(\"data-sidebar-open\")},[e]),H(()=>{let l=document.getElementById(\"sidebar-resize\");if(!l)return;function u(d){d.preventDefault(),l.setPointerCapture(d.pointerId);let c=document.getElementById(\"sidebar\");document.body.style.setProperty(\"user-select\",\"none\"),c?.style.setProperty(\"transition\",\"none\");function p(a){let _=Math.min(Math.max(a.clientX,Ue),Oe);document.documentElement.style.setProperty(\"--sidebar-width\",`${_}px`)}function f(a){if(l.releasePointerCapture(a.pointerId),l.removeEventListener(\"pointermove\",p),l.removeEventListener(\"pointerup\",f),l.removeEventListener(\"pointercancel\",f),document.body.style.removeProperty(\"user-select\"),c?.style.removeProperty(\"transition\"),a.type===\"pointerup\"){let _=Math.min(Math.max(a.clientX,Ue),Oe);localStorage.setItem(Ut,String(_))}}l.addEventListener(\"pointermove\",p),l.addEventListener(\"pointerup\",f),l.addEventListener(\"pointercancel\",f)}return l.addEventListener(\"pointerdown\",u),()=>l.removeEventListener(\"pointerdown\",u)},[]);let r=L(()=>{t(l=>{let u=!l;return ce()&&localStorage.setItem(ae,String(u)),u})},[]),s=L(()=>{t(!1),ce()&&localStorage.setItem(ae,\"false\")},[]),o=L(()=>{t(!0),ce()&&localStorage.setItem(ae,\"true\")},[]);return{toggle:r,close:s,open:o}}var $e=\"[peek]\",ze={info:(...e)=>console.log($e,...e),warn:(...e)=>console.warn($e,...e),error:(...e)=>console.error($e,...e)};function bn(e){let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=\"object\")return null;let n=t;return typeof n.path!=\"string\"?null:{path:n.path}}function $t(e){let t=0,n=null,r=null,s=null;function o(){r&&(clearTimeout(r),r=null);let l=new EventSource(\"/sse\");if(s=l,l.addEventListener(\"file-changed\",u=>{let d=bn(u.data);e.onFileChanged(d?K(d.path):null)}),e.onTreeChanged){let u=e.onTreeChanged;l.addEventListener(\"tree-changed\",()=>{u()})}l.onerror=()=>{if(l.close(),s=null,r&&(clearTimeout(r),r=null),t++,t>10){ze.warn(`SSE connection lost after ${10} retries, giving up.`);return}let u=Math.min(1e3*2**(t-1),3e4);ze.info(`SSE reconnecting in ${u}ms (${t}/${10})...`),n=setTimeout(o,u)},r=setTimeout(()=>{t=0,r=null},5e3)}return o(),()=>{n&&clearTimeout(n),r&&clearTimeout(r),s&&s.close()}}function ue(e){let{onContentUpdate:t,getCurrentPath:n,getCurrentContentType:r,onHtmlReload:s,onTreeUpdate:o}=e;H(()=>{let l=null,u=null,d=$t({onFileChanged:c=>{if(n){if(c===null)return;let p=n();if(K(c)!==K(p))return;if(r?.()===\"html\"){s?.();return}l?.abort(),l=new AbortController,W(p,{signal:l.signal}).then(f=>{f!==null&&t(f)}).catch(f=>{f instanceof DOMException&&f.name===\"AbortError\"||console.error(\"[peek] Failed to refresh content:\",f)})}else l?.abort(),l=new AbortController,W(void 0,{signal:l.signal}).then(p=>{p!==null&&t(p)}).catch(p=>{p instanceof DOMException&&p.name===\"AbortError\"||console.error(\"[peek] Failed to refresh content:\",p)})},onTreeChanged:o?()=>{u?.abort(),u=new AbortController,Ht({signal:u.signal}).then(c=>{c&&o(c)}).catch(c=>{c instanceof DOMException&&c.name===\"AbortError\"||console.error(\"[peek] Failed to refresh tree:\",c)})}:void 0});return()=>{l?.abort(),u?.abort(),d()}},[])}function zt({projectId:e,dirTitle:t,currentPath:n,contentType:r,content:s,tree:o}){let[l,u]=E(n),[d,c]=E(r),[p,f]=E(s),[a,_]=E(o),[g,T]=E(\"\"),[x,v]=E(0),m=P(l);m.current=l;let w=Ot(),R=Nt(e),I=g.trim()!==\"\",B=ie(()=>Ft(a,g),[a,g]);Dt(w.open),Bt((F,C)=>{let A=It(F);if(!A){console.error(`Unexpected unsupported file type: ${F}`);return}m.current=F,u(F),c(A),f(C),v(0)});let $=P(d);$.current=d,ue({getCurrentPath:()=>m.current,getCurrentContentType:()=>$.current,onContentUpdate:f,onHtmlReload:()=>v(F=>F+1),onTreeUpdate:_});let D=le(l);return i(k,{children:[i(Ct,{title:t,tree:B,currentPath:l,onClose:w.close,isOpen:I?()=>!0:R.isOpen,onToggle:I?void 0:R.toggle,searchQuery:g,onSearchChange:T,isSearching:I}),i(kt,{id:\"header-bar\",breadcrumbs:[{label:t,href:\"/\"},{label:D}],showSidebarToggle:!0,onToggleSidebar:w.toggle,externalLinkHref:`/${xe(l)}`}),i(St,{contentType:d,fileTitle:D,filePath:l,htmlContent:p,htmlReloadKey:x})]})}function jt({content:e}){let[t,n]=E(e);return ue({onContentUpdate:n}),i(\"main\",{class:\"px-2 sm:px-5 py-5 sm:py-15\",children:i(\"div\",{class:\"max-w-4xl mx-auto\",children:i(se,{htmlContent:t})})})}var Ve=\"theme\";function We(){let e=localStorage.getItem(Ve);return e===\"light\"||e===\"dark\"?e:\"system\"}function Ke(e){let t=document.documentElement;e===\"dark\"?t.classList.add(\"dark\"):e===\"light\"?t.classList.remove(\"dark\"):window.matchMedia(\"(prefers-color-scheme: dark)\").matches?t.classList.add(\"dark\"):t.classList.remove(\"dark\")}function Wt(e){let t=document.getElementById(\"icon-theme-light\"),n=document.getElementById(\"icon-theme-dark\"),r=document.getElementById(\"icon-theme-system\");!t||!n||!r||(t.classList.add(\"hidden\"),n.classList.add(\"hidden\"),r.classList.add(\"hidden\"),e===\"light\"?t.classList.remove(\"hidden\"):e===\"dark\"?n.classList.remove(\"hidden\"):r.classList.remove(\"hidden\"))}function Sn(e){return e===\"light\"?\"dark\":e===\"dark\"?\"system\":\"light\"}function Kt(){let e=We();Ke(e),Wt(e);let t=document.getElementById(\"theme-toggle\");t&&t.addEventListener(\"click\",()=>{let n=Sn(We());n===\"system\"?localStorage.removeItem(Ve):localStorage.setItem(Ve,n),Ke(n),Wt(n)}),window.matchMedia(\"(prefers-color-scheme: dark)\").addEventListener(\"change\",()=>{We()===\"system\"&&Ke(\"system\")})}var de=window.__INITIAL_STATE__,Xe=document.getElementById(\"app\");Xe&&de?de.mode===\"directory\"?te(i(zt,{...de}),Xe):te(i(jt,{...de}),Xe):console.error(\"[peek] hydration failed: missing #app or initial state\");Kt();})();\n";
|
|
1345
|
+
const clientBundle = "\"use strict\";(()=>{var ne,y,ot,mn,D,et,it,at,he,Q,W,st,ve,ye,ge,hn,G={},ee=[],yn=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,re=Array.isArray;function L(e,t){for(var n in t)e[n]=t[n];return e}function be(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function gn(e,t,n){var r,a,i,s={};for(i in t)i==\"key\"?r=t[i]:i==\"ref\"?a=t[i]:s[i]=t[i];if(arguments.length>2&&(s.children=arguments.length>3?ne.call(arguments,2):n),typeof e==\"function\"&&e.defaultProps!=null)for(i in e.defaultProps)s[i]===void 0&&(s[i]=e.defaultProps[i]);return Z(e,s,r,a,null)}function Z(e,t,n,r,a){var i={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:a??++ot,__i:-1,__u:0};return a==null&&y.vnode!=null&&y.vnode(i),i}function w(e){return e.children}function J(e,t){this.props=e,this.context=t}function B(e,t){if(t==null)return e.__?B(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==\"function\"?B(e):null}function vn(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],a=[],i=L({},t);i.__v=t.__v+1,y.vnode&&y.vnode(i),Se(e.__P,i,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??B(t),!!(32&t.__u),a),i.__v=t.__v,i.__.__k[i.__i]=i,pt(r,i,a),t.__e=t.__=null,i.__e!=n&<(i)}}function lt(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),lt(e)}function tt(e){(!e.__d&&(e.__d=!0)&&D.push(e)&&!te.__r++||et!=y.debounceRendering)&&((et=y.debounceRendering)||it)(te)}function te(){try{for(var e,t=1;D.length;)D.length>t&&D.sort(at),e=D.shift(),t=D.length,vn(e)}finally{D.length=te.__r=0}}function ct(e,t,n,r,a,i,s,c,u,d,p){var f,l,_,m,P,g,S=r&&r.__k||ee,h=t.length;for(u=bn(n,t,S,u,h),f=0;f<h;f++)(_=n.__k[f])!=null&&(l=_.__i!=-1&&S[_.__i]||G,_.__i=f,g=Se(e,_,l,a,i,s,c,u,d,p),m=_.__e,_.ref&&l.ref!=_.ref&&(l.ref&&xe(l.ref,null,_),p.push(_.ref,_.__c||m,_)),P==null&&m!=null&&(P=m),4&_.__u?(u=dt(_,u,e),l.__e&&(l.__e=null)):typeof _.type==\"function\"&&g!==void 0?u=g:m&&(u=m.nextSibling),_.__u&=-7);return n.__e=P,u}function bn(e,t,n,r,a){var i,s,c,u,d,p=n.length,f=p,l=0;for(e.__k=new Array(a),i=0;i<a;i++)(s=t[i])!=null&&typeof s!=\"boolean\"&&typeof s!=\"function\"?(typeof s==\"string\"||typeof s==\"number\"||typeof s==\"bigint\"||s.constructor==String?s=e.__k[i]=Z(null,s,null,null,null):re(s)?s=e.__k[i]=Z(w,{children:s},null,null,null):s.constructor===void 0&&s.__b>0?s=e.__k[i]=Z(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):e.__k[i]=s,u=i+l,s.__=e,s.__b=e.__b+1,c=null,(d=s.__i=Sn(s,n,u,f))!=-1&&(f--,(c=n[d])&&(c.__u|=2)),c==null||c.__v==null?(d==-1&&(a>p?l--:a<p&&l++),typeof s.type!=\"function\"&&(s.__u|=4)):d!=u&&(d==u-1?l--:d==u+1?l++:(d>u?l--:l++,s.__u|=4))):e.__k[i]=null;if(f)for(i=0;i<p;i++)(c=n[i])!=null&&(2&c.__u)==0&&(c.__e==r&&(r=B(c)),_t(c,c));return r}function dt(e,t,n){var r,a;if(typeof e.type==\"function\"){for(r=e.__k,a=0;r&&a<r.length;a++)r[a]&&(r[a].__=e,t=dt(r[a],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=B(e)),t=n.insertBefore(e.__e,t||null));do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Sn(e,t,n,r){var a,i,s,c=e.key,u=e.type,d=t[n],p=d!=null&&(2&d.__u)==0;if(d===null&&c==null||p&&c==d.key&&u==d.type)return n;if(r>(p?1:0)){for(a=n-1,i=n+1;a>=0||i<t.length;)if((d=t[s=a>=0?a--:i++])!=null&&(2&d.__u)==0&&c==d.key&&u==d.type)return s}return-1}function nt(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||yn.test(t)?n:n+\"px\"}function Y(e,t,n,r,a){var i,s;e:if(t==\"style\")if(typeof n==\"string\")e.style.cssText=n;else{if(typeof r==\"string\"&&(e.style.cssText=r=\"\"),r)for(t in r)n&&t in n||nt(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||nt(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")i=t!=(t=t.replace(st,\"$1\")),s=t.toLowerCase(),t=s in e||t==\"onFocusOut\"||t==\"onFocusIn\"?s.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+i]=n,n?r?n[W]=r[W]:(n[W]=ve,e.addEventListener(t,i?ge:ye,i)):e.removeEventListener(t,i?ge:ye,i);else{if(a==\"http://www.w3.org/2000/svg\")t=t.replace(/xlink(H|:h)/,\"h\").replace(/sName$/,\"s\");else if(t!=\"width\"&&t!=\"height\"&&t!=\"href\"&&t!=\"list\"&&t!=\"form\"&&t!=\"tabIndex\"&&t!=\"download\"&&t!=\"rowSpan\"&&t!=\"colSpan\"&&t!=\"role\"&&t!=\"popover\"&&t in e)try{e[t]=n??\"\";break e}catch{}typeof n==\"function\"||(n==null||n===!1&&t[4]!=\"-\"?e.removeAttribute(t):e.setAttribute(t,t==\"popover\"&&n==1?\"\":n))}}function rt(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[Q]==null)t[Q]=ve++;else if(t[Q]<n[W])return;return n(y.event?y.event(t):t)}}}function Se(e,t,n,r,a,i,s,c,u,d){var p,f,l,_,m,P,g,S,h,C,A,I,N,j,U,H,T=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),i=[c=t.__e=n.__e]),(p=y.__b)&&p(t);e:if(typeof T==\"function\"){f=s.length;try{if(h=t.props,C=T.prototype&&T.prototype.render,A=(p=T.contextType)&&r[p.__c],I=p?A?A.props.value:p.__:r,n.__c?S=(l=t.__c=n.__c).__=l.__E:(C?t.__c=l=new T(h,I):(t.__c=l=new J(h,I),l.constructor=T,l.render=Pn),A&&A.sub(l),l.state||(l.state={}),l.__n=r,_=l.__d=!0,l.__h=[],l._sb=[]),C&&l.__s==null&&(l.__s=l.state),C&&T.getDerivedStateFromProps!=null&&(l.__s==l.state&&(l.__s=L({},l.__s)),L(l.__s,T.getDerivedStateFromProps(h,l.__s))),m=l.props,P=l.state,l.__v=t,_)C&&T.getDerivedStateFromProps==null&&l.componentWillMount!=null&&l.componentWillMount(),C&&l.componentDidMount!=null&&l.__h.push(l.componentDidMount);else{if(C&&T.getDerivedStateFromProps==null&&h!==m&&l.componentWillReceiveProps!=null&&l.componentWillReceiveProps(h,I),t.__v==n.__v||!l.__e&&l.shouldComponentUpdate!=null&&l.shouldComponentUpdate(h,l.__s,I)===!1){t.__v!=n.__v&&(l.props=h,l.state=l.__s,l.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(R){R&&(R.__=t)}),ee.push.apply(l.__h,l._sb),l._sb=[],l.__h.length&&s.push(l),c=B(n);break e}l.componentWillUpdate!=null&&l.componentWillUpdate(h,l.__s,I),C&&l.componentDidUpdate!=null&&l.__h.push(function(){l.componentDidUpdate(m,P,g)})}if(l.context=I,l.props=h,l.__P=e,l.__e=!1,N=y.__r,j=0,C)l.state=l.__s,l.__d=!1,N&&N(t),p=l.render(l.props,l.state,l.context),ee.push.apply(l.__h,l._sb),l._sb=[];else do l.__d=!1,N&&N(t),p=l.render(l.props,l.state,l.context),l.state=l.__s;while(l.__d&&++j<25);l.state=l.__s,l.getChildContext!=null&&(r=L(L({},r),l.getChildContext())),C&&!_&&l.getSnapshotBeforeUpdate!=null&&(g=l.getSnapshotBeforeUpdate(m,P)),U=p!=null&&p.type===w&&p.key==null?ft(p.props.children):p,c=ct(e,re(U)?U:[U],t,n,r,a,i,s,c,u,d),l.base=t.__e,t.__u&=-161,l.__h.length&&s.push(l),S&&(l.__E=l.__=null)}catch(R){if(s.length=f,t.__v=null,u||i!=null){if(R.then){for(t.__u|=u?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;i!=null&&(i[i.indexOf(c)]=null),t.__e=c}else if(i!=null)for(H=i.length;H--;)be(i[H])}else t.__e=n.__e;t.__k==null&&(t.__k=n.__k||[]),R.then||ut(t),y.__e(R,t,n)}}else i==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):c=t.__e=xn(n.__e,t,n,r,a,i,s,u,d);return(p=y.diffed)&&p(t),128&t.__u?void 0:c}function ut(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(ut))}function pt(e,t,n){for(var r=0;r<n.length;r++)xe(n[r],n[++r],n[++r]);y.__c&&y.__c(t,e),e.some(function(a){try{e=a.__h,a.__h=[],e.some(function(i){i.call(a)})}catch(i){y.__e(i,a.__v)}})}function ft(e){return typeof e!=\"object\"||e==null||e.__b>0?e:re(e)?e.map(ft):e.constructor!==void 0?null:L({},e)}function xn(e,t,n,r,a,i,s,c,u){var d,p,f,l,_,m,P,g=n.props||G,S=t.props,h=t.type;if(h==\"svg\"?a=\"http://www.w3.org/2000/svg\":h==\"math\"?a=\"http://www.w3.org/1998/Math/MathML\":a||(a=\"http://www.w3.org/1999/xhtml\"),i!=null){for(d=0;d<i.length;d++)if((_=i[d])&&\"setAttribute\"in _==!!h&&(h?_.localName==h:_.nodeType==3)){e=_,i[d]=null;break}}if(e==null){if(h==null)return document.createTextNode(S);e=document.createElementNS(a,h,S.is&&S),c&&(y.__m&&y.__m(t,i),c=!1),i=null}if(h==null)g===S||c&&e.data==S||(e.data=S);else{if(i=h==\"textarea\"&&S.defaultValue!=null?null:i&&ne.call(e.childNodes),!c&&i!=null)for(g={},d=0;d<e.attributes.length;d++)g[(_=e.attributes[d]).name]=_.value;for(d in g)_=g[d],d==\"dangerouslySetInnerHTML\"?f=_:d==\"children\"||d in S||d==\"value\"&&\"defaultValue\"in S||d==\"checked\"&&\"defaultChecked\"in S||Y(e,d,null,_,a);for(d in S)_=S[d],d==\"children\"?l=_:d==\"dangerouslySetInnerHTML\"?p=_:d==\"value\"?m=_:d==\"checked\"?P=_:c&&typeof _!=\"function\"||g[d]===_||Y(e,d,_,g[d],a);if(p)c||f&&(p.__html==f.__html||p.__html==e.innerHTML)||(e.innerHTML=p.__html),t.__k=[];else if(f&&(e.innerHTML=\"\"),ct(t.type==\"template\"?e.content:e,re(l)?l:[l],t,n,r,h==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":a,i,s,i?i[0]:n.__k&&B(n,0),c,u),i!=null)for(d=i.length;d--;)be(i[d]);c&&h!=\"textarea\"||(d=\"value\",h==\"progress\"&&m==null?e.removeAttribute(\"value\"):m!=null&&(m!==e[d]||h==\"progress\"&&!m||h==\"option\"&&m!=g[d])&&Y(e,d,m,g[d],a),d=\"checked\",P!=null&&P!=e[d]&&Y(e,d,P,g[d],a))}return e}function xe(e,t,n){try{if(typeof e==\"function\"){var r=typeof e.__u==\"function\";r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(a){y.__e(a,n)}}function _t(e,t,n){var r,a;if(y.unmount&&y.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||xe(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(i){y.__e(i,t)}r.base=r.__P=r.__n=null}if(r=e.__k)for(a=0;a<r.length;a++)r[a]&&_t(r[a],t,n||typeof e.type!=\"function\");n||be(e.__e),e.__c=e.__=e.__e=void 0}function Pn(e,t,n){return this.constructor(e,n)}function Tn(e,t,n){var r,a,i,s;t==document&&(t=document.documentElement),y.__&&y.__(e,t),a=(r=typeof n==\"function\")?null:n&&n.__k||t.__k,i=[],s=[],Se(t,e=(!r&&n||t).__k=gn(w,null,[e]),a||G,G,t.namespaceURI,!r&&n?[n]:a?null:t.firstChild?ne.call(t.childNodes):null,i,!r&&n?n:a?a.__e:t.firstChild,r,s),pt(i,e,s),e.props.children=null}function oe(e,t){Tn(e,t,oe)}ne=ee.slice,y={__e:function(e,t,n,r){for(var a,i,s;t=t.__;)if((a=t.__c)&&!a.__)try{if((i=a.constructor)&&i.getDerivedStateFromError!=null&&(a.setState(i.getDerivedStateFromError(e)),s=a.__d),a.componentDidCatch!=null&&(a.componentDidCatch(e,r||{}),s=a.__d),s)return a.__E=a}catch(c){e=c}throw e}},ot=0,mn=function(e){return e!=null&&e.constructor===void 0},J.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=L({},this.state),typeof e==\"function\"&&(e=e(L({},n),this.props)),e&&L(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),tt(this))},J.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),tt(this))},J.prototype.render=w,D=[],it=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,at=function(e,t){return e.__v.__b-t.__v.__b},te.__r=0,he=Math.random().toString(8),Q=\"__d\"+he,W=\"__a\"+he,st=/(PointerCapture)$|Capture$/i,ve=0,ye=rt(!1),ge=rt(!0),hn=0;var $,v,Pe,mt,K=0,Pt=[],x=y,ht=x.__b,yt=x.__r,gt=x.diffed,vt=x.__c,bt=x.unmount,St=x.__;function ae(e,t){x.__h&&x.__h(v,e,K||t),K=0;var n=v.__H||(v.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function E(e){return K=1,wn(Tt,e)}function wn(e,t,n){var r=ae($++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Tt(void 0,t),function(c){var u=r.__N?r.__N[0]:r.__[0],d=r.t(u,c);u!==d&&(r.__N=[d,r.__[1]],r.__c.setState({}))}],r.__c=v,!v.__f)){var a=function(c,u,d){if(!r.__c.__H)return!0;var p=!1,f=r.__c.props!==c;if(r.__c.__H.__.some(function(_){if(_.__N){p=!0;var m=_.__[0];_.__=_.__N,_.__N=void 0,m!==_.__[0]&&(f=!0)}}),i){var l=i.call(this,c,u,d);return p?l||f:l}return!p||f};v.__f=!0;var i=v.shouldComponentUpdate,s=v.componentWillUpdate;v.componentWillUpdate=function(c,u,d){if(this.__e){var p=i;i=void 0,a(c,u,d),i=p}s&&s.call(this,c,u,d)},v.shouldComponentUpdate=a}return r.__N||r.__}function F(e,t){var n=ae($++,3);!x.__s&&we(n.__H,t)&&(n.__=e,n.u=t,v.__H.__h.push(n))}function se(e,t){var n=ae($++,4);!x.__s&&we(n.__H,t)&&(n.__=e,n.u=t,v.__h.push(n))}function k(e){return K=5,q(function(){return{current:e}},[])}function q(e,t){var n=ae($++,7);return we(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function M(e,t){return K=8,q(function(){return e},t)}function kn(){for(var e;e=Pt.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(ie),t.__h.some(Te),t.__h=[]}catch(n){t.__h=[],x.__e(n,e.__v)}}}x.__b=function(e){v=null,ht&&ht(e)},x.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),St&&St(e,t)},x.__r=function(e){yt&&yt(e),$=0;var t=(v=e.__c).__H;t&&(Pe===v?(t.__h=[],v.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(ie),t.__h.some(Te),t.__h=[],$=0)),Pe=v},x.diffed=function(e){gt&>(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Pt.push(t)!==1&&mt===x.requestAnimationFrame||((mt=x.requestAnimationFrame)||En)(kn)),t.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),Pe=v=null},x.__c=function(e,t){t.some(function(n){try{n.__h.some(ie),n.__h=n.__h.filter(function(r){return!r.__||Te(r)})}catch(r){t.some(function(a){a.__h&&(a.__h=[])}),t=[],x.__e(r,n.__v)}}),vt&&vt(e,t)},x.unmount=function(e){bt&&bt(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{ie(r)}catch(a){t=a}}),n.__H=void 0,t&&x.__e(t,n.__v))};var xt=typeof requestAnimationFrame==\"function\";function En(e){var t,n=function(){clearTimeout(r),xt&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);xt&&(t=requestAnimationFrame(n))}function ie(e){var t=v,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),v=t}function Te(e){var t=v;e.__c=e.__(),v=t}function we(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function Tt(e,t){return typeof t==\"function\"?t(e):t}var wt={border:\"none\",width:\"100%\",height:\"100%\",position:\"absolute\",top:\"0\",left:\"0\"};var Cn=\"/__peek/raw/\";function ke(e){return e.split(\"/\").map(encodeURIComponent).join(\"/\")}function le(e){return`${Cn}${ke(e)}`}var kt=\"/__peek/print\";function Et(e){return`${kt}?file=${encodeURIComponent(e)}`}function Ct(e){return`${kt}?dir=${encodeURIComponent(e??\"\")}`}var In=0;function o(e,t,n,r,a,i){t||(t={});var s,c,u=t;if(\"ref\"in u)for(c in u={},t)c==\"ref\"?s=t[c]:u[c]=t[c];var d={type:e,props:u,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--In,__i:-1,__u:0,__source:a,__self:i};if(typeof e==\"function\"&&(s=e.defaultProps))for(c in s)u[c]===void 0&&(u[c]=s[c]);return y.vnode&&y.vnode(d),d}function Ee({class:e,children:t}){return o(\"main\",{id:\"main-content\",class:e??\"\",children:t})}function ce({htmlContent:e}){return o(\"div\",{id:\"markdown-content\",class:\"markdown-body\",dangerouslySetInnerHTML:{__html:e}})}function It({contentType:e,fileTitle:t,filePath:n,htmlContent:r,htmlReloadKey:a,markdownClass:i=\"px-5 sm:px-10 py-5 sm:py-10\"}){return e===\"html\"?o(Ee,{class:\"relative flex-1 overflow-hidden\",children:o(\"iframe\",{title:t,src:le(n),style:wt},a)}):o(Ee,{class:i,children:o(\"div\",{class:\"max-w-4xl mx-auto\",children:o(ce,{htmlContent:r})})})}function b({class:e,children:t,width:n=\"24\",height:r=\"24\",viewBox:a=\"0 0 24 24\",...i}){return o(\"svg\",{...i,class:e,\"aria-hidden\":\"true\",xmlns:\"http://www.w3.org/2000/svg\",width:n,height:r,viewBox:a,fill:\"none\",stroke:\"currentColor\",\"stroke-width\":\"2\",\"stroke-linecap\":\"round\",\"stroke-linejoin\":\"round\",children:t})}function Ce(e){return o(b,{...e,children:o(\"path\",{d:\"m6 9 6 6 6-6\"})})}function Ie({class:e}){return o(b,{class:e,children:[o(\"path\",{d:\"M15 3h6v6\"}),o(\"path\",{d:\"M10 14 21 3\"}),o(\"path\",{d:\"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6\"})]})}function Fe(e){return o(b,{...e,children:[o(\"path\",{d:\"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z\"}),o(\"path\",{d:\"M14 2v4a2 2 0 0 0 2 2h4\"}),o(\"path\",{d:\"M12 18v-6\"}),o(\"path\",{d:\"m9 15 3 3 3-3\"})]})}function z(e){return o(b,{...e,children:[o(\"path\",{d:\"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z\"}),o(\"path\",{d:\"M14 2v4a2 2 0 0 0 2 2h4\"})]})}function V(e){return o(b,{...e,children:o(\"path\",{d:\"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 0-1.69.9L9.6 8H4a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2Z\"})})}function Me({class:e,...t}){return o(b,{class:e,...t,children:o(\"path\",{d:\"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z\"})})}function Ae({class:e,...t}){return o(b,{class:e,...t,children:[o(\"polyline\",{points:\"7 8 3 12 7 16\"}),o(\"line\",{x1:\"21\",x2:\"11\",y1:\"12\",y2:\"12\"}),o(\"line\",{x1:\"21\",x2:\"11\",y1:\"6\",y2:\"6\"}),o(\"line\",{x1:\"21\",x2:\"11\",y1:\"18\",y2:\"18\"})]})}function Le({class:e,...t}){return o(b,{class:e,...t,children:o(\"path\",{d:\"M17 8L21 12L17 16M3 12H13M3 6H13M3 18H13\"})})}function Re(e){return o(b,{...e,width:\"16\",height:\"16\",viewBox:\"0 0 16 16\",children:o(\"path\",{d:\"M6 13L10 3\",\"stroke-linecap\":\"round\"})})}function De({class:e,...t}){return o(b,{class:e,...t,children:[o(\"circle\",{cx:\"12\",cy:\"12\",r:\"4\"}),o(\"path\",{d:\"M12 2v2\"}),o(\"path\",{d:\"M12 20v2\"}),o(\"path\",{d:\"m4.93 4.93 1.41 1.41\"}),o(\"path\",{d:\"m17.66 17.66 1.41 1.41\"}),o(\"path\",{d:\"M2 12h2\"}),o(\"path\",{d:\"M20 12h2\"}),o(\"path\",{d:\"m6.34 17.66-1.41 1.41\"}),o(\"path\",{d:\"m19.07 4.93-1.41 1.41\"})]})}function Ne({class:e,...t}){return o(b,{class:e,...t,children:[o(\"path\",{d:\"M12 2v2\"}),o(\"path\",{d:\"M14.837 16.385a6 6 0 1 1-7.223-7.222c.624-.147.97.66.715 1.248a4 4 0 0 0 5.26 5.259c.589-.255 1.396.09 1.248.715\"}),o(\"path\",{d:\"M16 12a4 4 0 0 0-4-4\"}),o(\"path\",{d:\"m19 5-1.256 1.256\"}),o(\"path\",{d:\"M20 12h2\"})]})}var He={dirItem:\"inline-flex items-center shrink-0\",dirLink:\"text-sm text-muted-foreground hover:text-foreground\",fileItem:\"inline-flex items-center text-sm font-semibold text-foreground truncate\"},Fn=\"shrink-0 mx-1 size-4 text-muted-foreground\";function Ft({items:e}){return o(\"nav\",{\"aria-label\":\"Breadcrumb\",children:o(\"ol\",{class:\"flex items-center min-w-0\",children:e.map((t,n)=>{let r=n===e.length-1;return o(\"li\",{class:r?He.fileItem:He.dirItem,\"aria-current\":r?\"page\":void 0,children:r?t.label:o(w,{children:[o(\"a\",{class:He.dirLink,href:t.href??\"#\",children:t.label}),o(Re,{class:Fn})]})},n)})})})}function Mt({href:e}){return o(\"a\",{href:e,target:\"_blank\",rel:\"noopener noreferrer\",class:\"shrink-0 w-7 h-7 inline-flex justify-center items-center rounded-lg text-muted-foreground hover:text-foreground cursor-pointer\",\"aria-label\":\"Open in new tab\",children:o(Ie,{class:\"size-4\"})})}function At(){return o(\"button\",{type:\"button\",id:\"theme-toggle\",class:\"shrink-0 w-7 h-7 inline-flex justify-center items-center rounded-lg text-muted-foreground hover:text-foreground cursor-pointer\",\"aria-label\":\"Toggle theme\",children:[o(De,{class:\"hidden size-4\",id:\"icon-theme-light\"}),o(Me,{class:\"hidden size-4\",id:\"icon-theme-dark\"}),o(Ne,{class:\"hidden size-4\",id:\"icon-theme-system\"})]})}function Lt({id:e,breadcrumbs:t,showSidebarToggle:n,onToggleSidebar:r,externalLinkHref:a,actions:i}){return o(\"header\",{id:e,class:\"sticky top-0 z-50 bg-background border-b border-border\",children:o(\"div\",{class:\"flex items-center justify-between w-full py-2 px-2 sm:px-5\",children:[o(\"div\",{class:\"flex items-center gap-1 min-w-0\",children:[n&&o(\"button\",{type:\"button\",id:\"sidebar-toggle\",onClick:r,class:\"shrink-0 w-7 h-7 inline-flex justify-center items-center rounded-lg text-muted-foreground hover:bg-sidebar-accent cursor-pointer\",children:[o(Le,{class:\"shrink-0 size-4\",id:\"icon-sidebar-open\"}),o(Ae,{class:\"shrink-0 size-4 hidden\",id:\"icon-sidebar-close\"})]}),o(Ft,{items:t})]}),o(\"div\",{class:\"flex items-center gap-1\",children:[i,o(At,{}),a!==void 0&&o(Mt,{href:a})]})]})})}var Mn=new Map([[\".md\",\"markdown\"],[\".html\",\"html\"],[\".htm\",\"html\"]]);function Be(e){let t=Math.max(e.lastIndexOf(\"/\"),e.lastIndexOf(\"\\\\\")),n=t===-1?e:e.slice(t+1),r=n.lastIndexOf(\".\");return r===-1||r===n.length-1?\"\":n.slice(r).toLowerCase()}function de(e){return Mn.get(Be(e))??null}function Rt(e,t){return e.name.toLowerCase().includes(t)}function O(e,t){for(let n of e)if(n.type===\"directory\"&&t.startsWith(`${n.path}/`))return[n.path,...O(n.children??[],t)];return[]}function Dt(e,t){let n=t.trim().toLowerCase();return n===\"\"?e:Nt(e,n)}function Nt(e,t){let n=[];for(let r of e){if(r.type===\"directory\"){if(Rt(r,t)){n.push(r);continue}let a=r.children?Nt(r.children,t):[];a.length>0&&n.push({...r,children:a});continue}Rt(r,t)&&n.push(r)}return n}var Oe=200;function An(e){let t=e.slice(e.lastIndexOf(\"/\")+1),n=Be(t);return n===\"\"?t:t.slice(0,-n.length)}function Ln(e,t){return e===null?t:e.slice(e.lastIndexOf(\"/\")+1)}function Bt(e){return e===0?\"empty\":e>Oe?\"too-many\":\"ok\"}function Ot(e){return e.flatMap(t=>t.type===\"directory\"?Ot(t.children??[]):de(t.path)===\"markdown\"?[t.path]:[])}function Ut(e,t){for(let n of e)if(n.type===\"directory\"){if(n.path===t)return n.children??[];if(t.startsWith(`${n.path}/`))return Ut(n.children??[],t)}}function Rn(e,t){let n=t===null?e:Ut(e,t);return n&&Ot(n)}function Ht(e,t,n){return{path:t,name:Ln(t,n),markdownFileCount:Rn(e,t)?.length??0}}function $t(e,t,n){return[Ht(e,null,n),...O(e,t).map(r=>Ht(e,r,n))]}function jt(e,t){return{url:t===\"html\"?le(e):Et(e),title:An(e)}}function Wt(e){return{url:Ct(e.path),title:e.name}}function Kt(e,t,n){switch(e){case\"Escape\":return{type:\"close\",returnFocus:!0};case\"Tab\":return{type:\"close\",returnFocus:!1}}if(n!==0)switch(e){case\"ArrowDown\":return{type:\"focus\",index:t<0?0:(t+1)%n};case\"ArrowUp\":return{type:\"focus\",index:t<0?n-1:(t-1+n)%n};case\"Home\":return{type:\"focus\",index:0};case\"End\":return{type:\"focus\",index:n-1};default:return}}var Dn=\"flex items-center gap-x-3 w-full py-2 px-3 text-left text-sm text-foreground rounded-md enabled:cursor-pointer enabled:hover:bg-sidebar-accent focus-visible:bg-sidebar-accent disabled:opacity-50\";function Nn(e){switch(Bt(e)){case\"empty\":return{description:\"No Markdown files\",disabled:!0};case\"too-many\":return{description:`More than ${Oe} Markdown files`,disabled:!0};case\"ok\":return{description:`${e} Markdown file${e===1?\"\":\"s\"}`,disabled:!1}}}function Hn({icon:e,label:t,description:n,disabled:r,onSelect:a}){return o(\"button\",{type:\"button\",role:\"menuitem\",disabled:r,onClick:a,class:Dn,children:[e,o(\"span\",{class:\"min-w-0 flex-1\",children:[o(\"span\",{class:\"block truncate\",children:t}),o(\"span\",{class:\"block text-xs text-muted-foreground\",children:n})]})]})}function Bn({currentPath:e,currentName:t,contentType:n,directories:r}){return[{kind:\"file\",key:`file:${e}`,label:t,description:\"This file\",disabled:!1,request:jt(e,n)},...r.map(a=>({kind:\"directory\",key:`dir:${a.path??\"\"}`,label:a.name,...Nn(a.markdownFileCount),request:Wt(a)}))]}function qt({onPrint:e,...t}){let[n,r]=E(!1),a=k(null),i=k(null),s=k(null),c=()=>Array.from(s.current?.querySelectorAll(\"[role=menuitem]:not(:disabled)\")??[]);F(()=>{if(!n)return;c()[0]?.focus();let f=_=>{a.current?.contains(_.target)||r(!1)},l=()=>r(!1);return document.addEventListener(\"pointerdown\",f),window.addEventListener(\"blur\",l),()=>{document.removeEventListener(\"pointerdown\",f),window.removeEventListener(\"blur\",l)}},[n]);let u=()=>{r(!1),i.current?.focus()},d=f=>{u(),e(f)};return o(\"div\",{ref:a,class:\"relative\",children:[o(\"button\",{ref:i,type:\"button\",id:\"pdf-menu-button\",\"aria-label\":\"Save as PDF\",\"aria-haspopup\":\"menu\",\"aria-expanded\":n,\"aria-controls\":n?\"pdf-menu\":void 0,onClick:()=>r(f=>!f),onKeyDown:f=>{(f.key===\"ArrowDown\"||f.key===\"ArrowUp\")&&(f.preventDefault(),r(!0))},class:\"shrink-0 w-7 h-7 inline-flex justify-center items-center rounded-lg text-muted-foreground hover:text-foreground cursor-pointer\",children:o(Fe,{class:\"size-4\"})}),n&&o(\"div\",{ref:s,id:\"pdf-menu\",role:\"menu\",\"aria-labelledby\":\"pdf-menu-button\",onKeyDown:f=>{let l=c(),_=Kt(f.key,l.indexOf(document.activeElement),l.length);if(_){if(_.type===\"focus\")l[_.index]?.focus();else if(_.returnFocus)u();else{r(!1);return}f.preventDefault()}},class:\"absolute end-0 top-full mt-1 z-60 w-64 max-w-[calc(100vw-1rem)] p-1 bg-background border border-muted-foreground/25 rounded-lg shadow-lg\",children:[o(\"p\",{\"aria-hidden\":\"true\",class:\"px-3 pt-1.5 pb-1 text-xs font-medium text-muted-foreground\",children:\"Save as PDF\"}),Bn(t).map(f=>o(w,{children:[o(Hn,{icon:f.kind===\"file\"?o(z,{class:\"shrink-0 size-4\"}):o(V,{class:\"shrink-0 size-4\"}),label:f.label,description:f.description,disabled:f.disabled,onSelect:()=>d(f.request)}),f.kind===\"file\"&&o(\"hr\",{class:\"my-1 border-border\"})]},f.key))]})]})}var On=20;function Un({node:e,currentPath:t,depth:n,isOpen:r,onToggle:a}){let i=r(e.path);return o(\"li\",{class:n===0?\"px-2 lg:px-5\":\"\",children:[o(\"button\",{type:\"button\",\"aria-expanded\":i,onClick:()=>a?.(e.path),class:\"flex items-center gap-x-3 w-full py-2 px-3 text-left text-sm text-sidebar-foreground hover:bg-sidebar-accent rounded-lg overflow-hidden\",children:[o(V,{class:\"shrink-0 size-4\"}),o(\"span\",{class:\"min-w-0 truncate\",children:e.name}),o(Ce,{class:`${i?\"\":\"-rotate-90 \"}shrink-0 size-3.5 ms-auto transition-transform`})]}),i&&o(\"ul\",{class:\"ps-7 mt-1 flex flex-col gap-y-1 relative before:absolute before:top-0 before:start-[1.125rem] before:w-px before:h-full before:bg-sidebar-border\",children:e.children&&n<On?o(Ue,{nodes:e.children,currentPath:t,depth:n+1,isOpen:r,onToggle:a}):null})]})}function Ue({nodes:e,currentPath:t,depth:n=0,isOpen:r,onToggle:a}){return o(w,{children:e.map(i=>{if(i.type===\"directory\")return o(Un,{node:i,currentPath:t,depth:n,isOpen:r,onToggle:a},i.path);let s=t===i.path;return o(\"li\",{class:n===0?\"px-2 lg:px-5\":\"\",children:o(\"a\",{href:`/view?path=${encodeURIComponent(i.path)}`,class:`flex items-center gap-x-3 py-2 px-3 text-sm rounded-lg overflow-hidden ${s?\"bg-sidebar-accent text-sidebar-primary font-medium\":\"hover:bg-sidebar-accent text-sidebar-foreground\"}`,children:[o(z,{class:\"shrink-0 size-4\"}),o(\"span\",{class:\"min-w-0 truncate\",children:i.name})]})},i.path)})})}function zt({nodes:e,currentPath:t,isOpen:n,onToggle:r}){return o(\"ul\",{id:\"file-tree\",class:\"flex flex-col gap-y-1\",children:o(Ue,{nodes:e,currentPath:t,isOpen:n,onToggle:r})})}function Vt({title:e,tree:t,currentPath:n,onClose:r,isOpen:a,onToggle:i,searchQuery:s,onSearchChange:c,isSearching:u}){return o(w,{children:[o(\"div\",{role:\"none\",id:\"sidebar-overlay\",class:\"fixed inset-0 z-50 bg-black/50 hidden\",onClick:r}),o(\"aside\",{id:\"sidebar\",\"aria-label\":\"File navigation\",class:\"fixed inset-y-0 start-0 z-60 w-72 lg:w-auto overflow-hidden bg-sidebar border-e border-sidebar-border -translate-x-full\",children:[o(\"div\",{class:\"relative flex flex-col h-full max-h-full pt-3\",children:[o(\"header\",{class:\"flex-none h-11.5 ps-5 pe-2 lg:ps-8 flex items-center\",children:o(\"a\",{href:\"/\",class:\"flex-none text-sm font-semibold text-sidebar-foreground hover:text-sidebar-primary\",children:e})}),o(\"div\",{class:\"flex-none px-2 lg:px-5 mt-1.5 mb-1\",children:o(\"input\",{id:\"sidebar-search\",type:\"search\",\"aria-label\":\"Search files\",placeholder:\"Search files\\u2026\",value:s??\"\",onInput:d=>c?.(d.target.value),onKeyDown:d=>{d.key===\"Escape\"&&!d.isComposing&&(c?.(\"\"),d.currentTarget.blur())},class:\"w-full py-1.5 px-3 text-sm text-sidebar-foreground bg-sidebar-accent border border-sidebar-border rounded-lg outline-none focus:border-sidebar-primary placeholder:text-sidebar-foreground/50\"})}),o(\"div\",{class:\"flex-1 min-h-0 overflow-x-hidden overflow-y-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-none [&::-webkit-scrollbar-track]:bg-scrollbar-track [&::-webkit-scrollbar-thumb]:bg-scrollbar-thumb\",children:o(\"nav\",{class:\"pb-3 w-full flex flex-col\",children:u&&t.length===0?o(\"p\",{class:\"px-5 py-3 text-sm text-sidebar-foreground/60\",children:\"No matches found\"}):o(zt,{nodes:t,currentPath:n,isOpen:a,onToggle:i})})})]}),o(\"div\",{id:\"sidebar-resize\",class:\"absolute inset-y-0 end-0 w-1 cursor-col-resize hover:bg-sidebar-border hidden lg:block pointer-events-auto\"})]})]})}function Yt(e,t){return{expanded:new Set,revealed:new Set(O(e,t))}}function $e(e,t){return e.expanded.has(t)||e.revealed.has(t)}function Qt(e,t,n){return $e(e,n)?{expanded:Xt(e.expanded,n),revealed:Xt(e.revealed,n)}:{expanded:new Set([...e.expanded,...O(t,n),n]),revealed:e.revealed}}function Zt(e,t,n){return{expanded:e.expanded,revealed:new Set([...e.revealed,...O(t,n)])}}function Xt(e,t){let n=new Set(e);return n.delete(t),n}var je=\"file-tree-state\";function Jt(e){if(!e)return{};try{let t=JSON.parse(e);if(!t||typeof t!=\"object\"||Array.isArray(t))return{};let n={};for(let[r,a]of Object.entries(t)){if(!a||typeof a!=\"object\"||Array.isArray(a))continue;let{expanded:i,lastAccess:s}=a;typeof s!=\"number\"||!Array.isArray(i)||(n[r]={expanded:i.filter(c=>typeof c==\"string\"),lastAccess:s})}return n}catch{return{}}}function Gt(e,t,n){let r={};for(let[a,i]of Object.entries(e))t-i.lastAccess<=n&&(r[a]=i);return r}function en(e,t){return new Set(e[t]?.expanded??[])}function We(e,t,n,r){return{...e,[t]:{expanded:Array.from(n),lastAccess:r}}}function tn(e){return JSON.stringify(e)}function nn(e,t,n){let[r,a]=E(()=>Yt(t,n)),i=k(!0),s=k(t);s.current=t;let c=k(r);c.current=r;function u(m){c.current=m,a(m)}function d(){try{return Jt(localStorage.getItem(je))}catch{return{}}}function p(m){try{localStorage.setItem(je,tn(m))}catch{}}se(()=>{if(!i.current)return;i.current=!1;let m=Date.now(),P=Gt(d(),m,2592e6),g=en(P,e);p(We(P,e,g,m)),u({...c.current,expanded:g})},[e]);let f=M(m=>{let P=Qt(c.current,s.current,m);u(P),p(We(d(),e,P.expanded,Date.now()))},[e]),l=M(m=>{u(Zt(c.current,s.current,m))},[]);return{isOpen:M(m=>$e(r,m),[r]),toggle:f,reveal:l}}async function X(e,t){try{let n=e?`/api/content?path=${encodeURIComponent(e)}`:\"/api/content\",r=await fetch(n,t?.signal?{signal:t.signal}:void 0);return r.ok?await r.text():(console.error(`[peek] Failed to fetch content: HTTP ${r.status}`),null)}catch(n){if(n instanceof DOMException&&n.name===\"AbortError\")throw n;return console.error(\"[peek] Failed to fetch content:\",n),null}}async function rn(e){try{let t=await fetch(\"/api/tree\",e?.signal?{signal:e.signal}:void 0);if(!t.ok)return console.error(`[peek] Failed to fetch tree: HTTP ${t.status}`),null;let n=await t.json();return Array.isArray(n)?n:(console.error(\"[peek] Unexpected tree response format\"),null)}catch(t){if(t instanceof DOMException&&t.name===\"AbortError\")throw t;return console.error(\"[peek] Failed to fetch tree:\",t),null}}function ue(e){let n=e.replace(/\\/+$/,\"\").split(\"/\");return n[n.length-1]||e}function on(e){let t=k(null),n=k(e);n.current=e;let r=M(async(a,i)=>{t.current&&t.current.abort();let s=new AbortController;t.current=s;try{let c=await X(a,{signal:s.signal});if(c===null)return;n.current(a,c),document.title=`${ue(a)} - peek`;let u=`/view?path=${encodeURIComponent(a)}`;i&&history.pushState({path:a},\"\",u)}catch(c){if(c instanceof DOMException&&c.name===\"AbortError\")return;console.error(\"[peek] Failed to navigate:\",c)}},[]);return F(()=>{let a=new URLSearchParams(window.location.search).get(\"path\");a&&history.replaceState({path:a},\"\");function i(c){if(c.ctrlKey||c.metaKey||c.shiftKey||c.altKey)return;let u=c.target.closest(\"a[href]\");if(!u)return;let d;try{d=new URL(u.href,window.location.origin)}catch{return}if(d.origin!==window.location.origin||d.pathname!==\"/view\")return;let p=d.searchParams.get(\"path\");p&&(c.preventDefault(),r(p,!0))}function s(c){let d=c.state?.path??new URLSearchParams(window.location.search).get(\"path\");d?r(d,!1):window.location.reload()}return document.addEventListener(\"click\",i),window.addEventListener(\"popstate\",s),()=>{document.removeEventListener(\"click\",i),window.removeEventListener(\"popstate\",s)}},[r]),r}var jn=\"sidebar-search\";function Wn(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t===\"INPUT\"||t===\"TEXTAREA\"||t===\"SELECT\"||e.isContentEditable}function an(e){F(()=>{function t(n){n.key===\"/\"&&(n.isComposing||Wn(n.target)||(n.preventDefault(),e?.(),document.getElementById(jn)?.focus()))}return window.addEventListener(\"keydown\",t),()=>window.removeEventListener(\"keydown\",t)},[e])}var pe=\"sidebar-open\",sn=\"sidebar-width\",Ke=200,qe=480,Kn=1024;function fe(){return window.innerWidth>=Kn}function ln(){let[e,t]=E(!1),n=k(!0);se(()=>{if(n.current){n.current=!1;let s=localStorage.getItem(sn);if(s){let c=Number(s);c>=Ke&&c<=qe&&document.documentElement.style.setProperty(\"--sidebar-width\",`${c}px`)}if(fe()&&localStorage.getItem(pe)!==\"false\"){let c=[document.getElementById(\"sidebar\"),document.getElementById(\"header-bar\"),document.getElementById(\"main-content\")];for(let u of c)u&&(u.style.transition=\"none\");document.body.setAttribute(\"data-sidebar-open\",\"\"),document.body.offsetHeight,requestAnimationFrame(()=>{for(let u of c)u&&u.style.removeProperty(\"transition\")}),t(!0)}return}e?document.body.setAttribute(\"data-sidebar-open\",\"\"):document.body.removeAttribute(\"data-sidebar-open\")},[e]),F(()=>{let s=document.getElementById(\"sidebar-resize\");if(!s)return;let c=u=>{u.preventDefault(),s.setPointerCapture(u.pointerId);let d=document.getElementById(\"sidebar\");document.body.style.setProperty(\"user-select\",\"none\"),d?.style.setProperty(\"transition\",\"none\");function p(l){let _=Math.min(Math.max(l.clientX,Ke),qe);document.documentElement.style.setProperty(\"--sidebar-width\",`${_}px`)}let f=l=>{if(s.releasePointerCapture(l.pointerId),s.removeEventListener(\"pointermove\",p),s.removeEventListener(\"pointerup\",f),s.removeEventListener(\"pointercancel\",f),document.body.style.removeProperty(\"user-select\"),d?.style.removeProperty(\"transition\"),l.type===\"pointerup\"){let _=Math.min(Math.max(l.clientX,Ke),qe);localStorage.setItem(sn,String(_))}};s.addEventListener(\"pointermove\",p),s.addEventListener(\"pointerup\",f),s.addEventListener(\"pointercancel\",f)};return s.addEventListener(\"pointerdown\",c),()=>s.removeEventListener(\"pointerdown\",c)},[]);let r=M(()=>{t(s=>{let c=!s;return fe()&&localStorage.setItem(pe,String(c)),c})},[]),a=M(()=>{t(!1),fe()&&localStorage.setItem(pe,\"false\")},[]),i=M(()=>{t(!0),fe()&&localStorage.setItem(pe,\"true\")},[]);return{toggle:r,close:a,open:i}}var ze=\"[peek]\",Ve={info:(...e)=>console.log(ze,...e),warn:(...e)=>console.warn(ze,...e),error:(...e)=>console.error(ze,...e)};function Xn(e){let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=\"object\")return null;let n=t;return typeof n.path!=\"string\"?null:{path:n.path}}function cn(e){let t=0,n=null,r=null,a=null;function i(){r&&(clearTimeout(r),r=null);let s=new EventSource(\"/sse\");if(a=s,s.addEventListener(\"file-changed\",c=>{let u=Xn(c.data);e.onFileChanged(u?u.path:null)}),e.onTreeChanged){let c=e.onTreeChanged;s.addEventListener(\"tree-changed\",()=>{c()})}s.onerror=()=>{if(s.close(),a=null,r&&(clearTimeout(r),r=null),t++,t>10){Ve.warn(`SSE connection lost after ${10} retries, giving up.`);return}let c=Math.min(1e3*2**(t-1),3e4);Ve.info(`SSE reconnecting in ${c}ms (${t}/${10})...`),n=setTimeout(i,c)},r=setTimeout(()=>{t=0,r=null},5e3)}return i(),()=>{n&&clearTimeout(n),r&&clearTimeout(r),a&&a.close()}}function _e(e){let{onContentUpdate:t,getCurrentPath:n,getCurrentContentType:r,onHtmlReload:a,onTreeUpdate:i}=e;F(()=>{let s=null,c=null,u=cn({onFileChanged:d=>{if(n){if(d===null)return;let p=n();if(d!==p)return;if(r?.()===\"html\"){a?.();return}s?.abort(),s=new AbortController,X(p,{signal:s.signal}).then(f=>{f!==null&&t(f)}).catch(f=>{f instanceof DOMException&&f.name===\"AbortError\"||console.error(\"[peek] Failed to refresh content:\",f)})}else s?.abort(),s=new AbortController,X(void 0,{signal:s.signal}).then(p=>{p!==null&&t(p)}).catch(p=>{p instanceof DOMException&&p.name===\"AbortError\"||console.error(\"[peek] Failed to refresh content:\",p)})},onTreeChanged:i?()=>{c?.abort(),c=new AbortController,rn({signal:c.signal}).then(d=>{d&&i(d)}).catch(d=>{d instanceof DOMException&&d.name===\"AbortError\"||console.error(\"[peek] Failed to refresh tree:\",d)})}:void 0});return()=>{s?.abort(),c?.abort(),u()}},[])}function Yn(e,t,n){let r=n(e);return r?(r.addEventListener(\"load\",()=>{r.document.contentType===\"text/html\"&&(r.document.title=t,r.addEventListener(\"afterprint\",()=>r.close(),{once:!0}),r.print())},{once:!0}),!0):!1}var Qn=\"Pop-ups are blocked. Allow pop-ups for this site to save as PDF.\";function dn({url:e,title:t},n){Yn(e,t,r=>n.open(r,\"_blank\"))||n.alert(Qn)}function un({projectId:e,dirTitle:t,currentPath:n,contentType:r,content:a,tree:i}){let[s,c]=E(n),[u,d]=E(r),[p,f]=E(a),[l,_]=E(i),[m,P]=E(\"\"),[g,S]=E(0),h=k(s);h.current=s;let C=ln(),A=nn(e,l,n),I=m.trim()!==\"\",N=q(()=>Dt(l,m),[l,m]);an(C.open),on((T,R)=>{let Ge=de(T);if(!Ge){console.error(`Unexpected unsupported file type: ${T}`);return}h.current=T,c(T),d(Ge),f(R),S(0),A.reveal(T)});let j=k(u);j.current=u,_e({getCurrentPath:()=>h.current,getCurrentContentType:()=>j.current,onContentUpdate:f,onHtmlReload:()=>S(T=>T+1),onTreeUpdate:_});let U=q(()=>$t(l,s,t),[l,s,t]),H=ue(s);return o(w,{children:[o(Vt,{title:t,tree:N,currentPath:s,onClose:C.close,isOpen:I?()=>!0:A.isOpen,onToggle:I?void 0:A.toggle,searchQuery:m,onSearchChange:P,isSearching:I}),o(Lt,{id:\"header-bar\",breadcrumbs:[{label:t,href:\"/\"},{label:H}],showSidebarToggle:!0,onToggleSidebar:C.toggle,externalLinkHref:`/${ke(s)}`,actions:o(qt,{currentPath:s,currentName:H,contentType:u,directories:U,onPrint:T=>dn(T,window)})}),o(It,{contentType:u,fileTitle:H,filePath:s,htmlContent:p,htmlReloadKey:g})]})}function pn({content:e}){let[t,n]=E(e);return _e({onContentUpdate:n}),o(\"main\",{class:\"px-2 sm:px-5 py-5 sm:py-15\",children:o(\"div\",{class:\"max-w-4xl mx-auto\",children:o(ce,{htmlContent:t})})})}var Ze=\"theme\";function Ye(){let e=localStorage.getItem(Ze);return e===\"light\"||e===\"dark\"?e:\"system\"}function Qe(e){let t=document.documentElement;e===\"dark\"?t.classList.add(\"dark\"):e===\"light\"?t.classList.remove(\"dark\"):window.matchMedia(\"(prefers-color-scheme: dark)\").matches?t.classList.add(\"dark\"):t.classList.remove(\"dark\")}function fn(e){let t=document.getElementById(\"icon-theme-light\"),n=document.getElementById(\"icon-theme-dark\"),r=document.getElementById(\"icon-theme-system\");!t||!n||!r||(t.classList.add(\"hidden\"),n.classList.add(\"hidden\"),r.classList.add(\"hidden\"),e===\"light\"?t.classList.remove(\"hidden\"):e===\"dark\"?n.classList.remove(\"hidden\"):r.classList.remove(\"hidden\"))}function Zn(e){return e===\"light\"?\"dark\":e===\"dark\"?\"system\":\"light\"}function _n(){let e=Ye();Qe(e),fn(e);let t=document.getElementById(\"theme-toggle\");t&&t.addEventListener(\"click\",()=>{let n=Zn(Ye());n===\"system\"?localStorage.removeItem(Ze):localStorage.setItem(Ze,n),Qe(n),fn(n)}),window.matchMedia(\"(prefers-color-scheme: dark)\").addEventListener(\"change\",()=>{Ye()===\"system\"&&Qe(\"system\")})}var me=window.__INITIAL_STATE__,Je=document.getElementById(\"app\");Je&&me?me.mode===\"directory\"?oe(o(un,{...me}),Je):oe(o(pn,{...me}),Je):console.error(\"[peek] hydration failed: missing #app or initial state\");_n();})();\n";
|
|
1019
1346
|
//#endregion
|
|
1020
1347
|
//#region src/server/renderer/global.css?inline
|
|
1021
|
-
var global_default = "/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n@layer properties {\n @supports (((-webkit-hyphens: none)) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color: rgb(from red r g b)))) {\n *, :before, :after, ::backdrop {\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-translate-z: 0;\n --tw-rotate-x: initial;\n --tw-rotate-y: initial;\n --tw-rotate-z: initial;\n --tw-skew-x: initial;\n --tw-skew-y: initial;\n --tw-border-style: solid;\n --tw-font-weight: initial;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-color: initial;\n --tw-shadow-alpha: 100%;\n --tw-inset-shadow: 0 0 #0000;\n --tw-inset-shadow-color: initial;\n --tw-inset-shadow-alpha: 100%;\n --tw-ring-color: initial;\n --tw-ring-shadow: 0 0 #0000;\n --tw-inset-ring-color: initial;\n --tw-inset-ring-shadow: 0 0 #0000;\n --tw-ring-inset: initial;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ease: initial;\n --tw-content: \"\";\n }\n }\n}\n\n@layer theme {\n :root, :host {\n --font-sans: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", \"Noto Sans\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\";\n --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace;\n --color-black: #000;\n --spacing: .25rem;\n --container-4xl: 56rem;\n --text-sm: .875rem;\n --text-sm--line-height: calc(1.25 / .875);\n --font-weight-medium: 500;\n --font-weight-semibold: 600;\n --radius-lg: .5rem;\n --radius-xl: .75rem;\n --ease-in-out: cubic-bezier(.4, 0, .2, 1);\n --animate-spin: spin 1s linear infinite;\n --animate-pulse: pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;\n --default-transition-duration: .15s;\n --default-transition-timing-function: cubic-bezier(.4, 0, .2, 1);\n --default-font-family: var(--font-sans);\n --default-mono-font-family: var(--font-mono);\n --color-background: var(--background);\n --color-foreground: var(--foreground);\n --color-card: var(--card);\n --color-muted-foreground: var(--muted-foreground);\n --color-border: var(--border);\n --color-sidebar: var(--sidebar);\n --color-sidebar-foreground: var(--sidebar-foreground);\n --color-sidebar-primary: var(--sidebar-primary);\n --color-sidebar-accent: var(--sidebar-accent);\n --color-sidebar-border: var(--sidebar-border);\n --color-scrollbar-track: var(--scrollbar-track);\n --color-scrollbar-thumb: var(--scrollbar-thumb);\n }\n}\n\n@layer base {\n *, :after, :before, ::backdrop {\n box-sizing: border-box;\n border: 0 solid;\n margin: 0;\n padding: 0;\n }\n\n ::file-selector-button {\n box-sizing: border-box;\n border: 0 solid;\n margin: 0;\n padding: 0;\n }\n\n html, :host {\n -webkit-text-size-adjust: 100%;\n tab-size: 4;\n line-height: 1.5;\n font-family: var(--default-font-family, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", \"Noto Sans\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\");\n font-feature-settings: var(--default-font-feature-settings, normal);\n font-variation-settings: var(--default-font-variation-settings, normal);\n -webkit-tap-highlight-color: transparent;\n }\n\n hr {\n height: 0;\n color: inherit;\n border-top-width: 1px;\n }\n\n abbr:where([title]) {\n text-decoration: underline dotted;\n }\n\n h1, h2, h3, h4, h5, h6 {\n font-size: inherit;\n font-weight: inherit;\n }\n\n a {\n color: inherit;\n -webkit-text-decoration: inherit;\n -webkit-text-decoration: inherit;\n -webkit-text-decoration: inherit;\n text-decoration: inherit;\n }\n\n b, strong {\n font-weight: bolder;\n }\n\n code, kbd, samp, pre {\n font-family: var(--default-mono-font-family, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace);\n font-feature-settings: var(--default-mono-font-feature-settings, normal);\n font-variation-settings: var(--default-mono-font-variation-settings, normal);\n font-size: 1em;\n }\n\n small {\n font-size: 80%;\n }\n\n sub, sup {\n vertical-align: baseline;\n font-size: 75%;\n line-height: 0;\n position: relative;\n }\n\n sub {\n bottom: -.25em;\n }\n\n sup {\n top: -.5em;\n }\n\n table {\n text-indent: 0;\n border-color: inherit;\n border-collapse: collapse;\n }\n\n :-moz-focusring:where(:not(iframe)) {\n outline: auto;\n }\n\n progress {\n vertical-align: baseline;\n }\n\n summary {\n display: list-item;\n }\n\n ol, ul, menu {\n list-style: none;\n }\n\n img, svg, video, canvas, audio, iframe, embed, object {\n vertical-align: middle;\n display: block;\n }\n\n img, video {\n max-width: 100%;\n height: auto;\n }\n\n button, input, select, optgroup, textarea {\n font: inherit;\n font-feature-settings: inherit;\n font-variation-settings: inherit;\n letter-spacing: inherit;\n color: inherit;\n opacity: 1;\n background-color: #0000;\n border-radius: 0;\n }\n\n ::file-selector-button {\n font: inherit;\n font-feature-settings: inherit;\n font-variation-settings: inherit;\n letter-spacing: inherit;\n color: inherit;\n opacity: 1;\n background-color: #0000;\n border-radius: 0;\n }\n\n :where(select:is([multiple], [size])) optgroup {\n font-weight: bolder;\n }\n\n :where(select:is([multiple], [size])) optgroup option {\n padding-inline-start: 20px;\n }\n\n ::file-selector-button {\n margin-inline-end: 4px;\n }\n\n ::placeholder {\n opacity: 1;\n }\n\n @supports (not ((-webkit-appearance: -apple-pay-button))) or (contain-intrinsic-size: 1px) {\n ::placeholder {\n color: currentColor;\n }\n\n @supports (color: color-mix(in lab, red, red)) {\n ::placeholder {\n color: color-mix(in oklab, currentcolor 50%, transparent);\n }\n }\n }\n\n textarea {\n resize: vertical;\n }\n\n ::-webkit-search-decoration {\n -webkit-appearance: none;\n }\n\n ::-webkit-date-and-time-value {\n min-height: 1lh;\n text-align: inherit;\n }\n\n ::-webkit-datetime-edit {\n display: inline-flex;\n }\n\n ::-webkit-datetime-edit-fields-wrapper {\n padding: 0;\n }\n\n ::-webkit-datetime-edit {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-year-field {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-month-field {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-day-field {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-hour-field {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-minute-field {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-second-field {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-millisecond-field {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-meridiem-field {\n padding-block: 0;\n }\n\n ::-webkit-calendar-picker-indicator {\n line-height: 1;\n }\n\n :-moz-ui-invalid {\n box-shadow: none;\n }\n\n button, input:where([type=\"button\"], [type=\"reset\"], [type=\"submit\"]) {\n appearance: button;\n }\n\n ::file-selector-button {\n appearance: button;\n }\n\n ::-webkit-inner-spin-button {\n height: auto;\n }\n\n ::-webkit-outer-spin-button {\n height: auto;\n }\n\n [hidden]:where(:not([hidden=\"until-found\"])) {\n display: none !important;\n }\n}\n\n@layer components;\n\n@layer utilities {\n .pointer-events-auto {\n pointer-events: auto;\n }\n\n .collapse {\n visibility: collapse;\n }\n\n .visible {\n visibility: visible;\n }\n\n .absolute {\n position: absolute;\n }\n\n .fixed {\n position: fixed;\n }\n\n .relative {\n position: relative;\n }\n\n .sticky {\n position: sticky;\n }\n\n .inset-0 {\n inset: 0;\n }\n\n .inset-y-0 {\n inset-block: 0;\n }\n\n .start-0 {\n inset-inline-start: calc(var(--spacing) * 0);\n }\n\n .end-0 {\n inset-inline-end: calc(var(--spacing) * 0);\n }\n\n .top-0 {\n top: 0;\n }\n\n .z-50 {\n z-index: 50;\n }\n\n .z-60 {\n z-index: 60;\n }\n\n .container {\n width: 100%;\n }\n\n @media (width >= 40rem) {\n .container {\n max-width: 40rem;\n }\n }\n\n @media (width >= 48rem) {\n .container {\n max-width: 48rem;\n }\n }\n\n @media (width >= 64rem) {\n .container {\n max-width: 64rem;\n }\n }\n\n @media (width >= 80rem) {\n .container {\n max-width: 80rem;\n }\n }\n\n @media (width >= 96rem) {\n .container {\n max-width: 96rem;\n }\n }\n\n .mx-1 {\n margin-inline: var(--spacing);\n }\n\n .mx-auto {\n margin-inline: auto;\n }\n\n .ms-auto {\n margin-inline-start: auto;\n }\n\n .mt-1 {\n margin-top: var(--spacing);\n }\n\n .mt-1\\.5 {\n margin-top: calc(var(--spacing) * 1.5);\n }\n\n .mb-1 {\n margin-bottom: var(--spacing);\n }\n\n .block {\n display: block;\n }\n\n .contents {\n display: contents;\n }\n\n .flex {\n display: flex;\n }\n\n .hidden {\n display: none;\n }\n\n .inline {\n display: inline;\n }\n\n .inline-flex {\n display: inline-flex;\n }\n\n .table {\n display: table;\n }\n\n .size-3\\.5 {\n width: calc(var(--spacing) * 3.5);\n height: calc(var(--spacing) * 3.5);\n }\n\n .size-4 {\n width: calc(var(--spacing) * 4);\n height: calc(var(--spacing) * 4);\n }\n\n .h-7 {\n height: calc(var(--spacing) * 7);\n }\n\n .h-11\\.5 {\n height: calc(var(--spacing) * 11.5);\n }\n\n .h-full {\n height: 100%;\n }\n\n .max-h-full {\n max-height: 100%;\n }\n\n .min-h-0 {\n min-height: 0;\n }\n\n .min-h-dvh {\n min-height: 100dvh;\n }\n\n .min-h-screen {\n min-height: 100vh;\n }\n\n .w-1 {\n width: var(--spacing);\n }\n\n .w-7 {\n width: calc(var(--spacing) * 7);\n }\n\n .w-72 {\n width: calc(var(--spacing) * 72);\n }\n\n .w-full {\n width: 100%;\n }\n\n .max-w-4xl {\n max-width: var(--container-4xl);\n }\n\n .min-w-0 {\n min-width: 0;\n }\n\n .flex-1 {\n flex: 1;\n }\n\n .flex-none {\n flex: none;\n }\n\n .shrink-0 {\n flex-shrink: 0;\n }\n\n .border-collapse {\n border-collapse: collapse;\n }\n\n .-translate-x-full {\n --tw-translate-x: -100%;\n translate: var(--tw-translate-x) var(--tw-translate-y);\n }\n\n .-rotate-180 {\n rotate: -180deg;\n }\n\n .transform {\n transform: var(--tw-rotate-x, ) var(--tw-rotate-y, ) var(--tw-rotate-z, ) var(--tw-skew-x, ) var(--tw-skew-y, );\n }\n\n .animate-pulse {\n animation: var(--animate-pulse);\n }\n\n .animate-spin {\n animation: var(--animate-spin);\n }\n\n .cursor-col-resize {\n cursor: col-resize;\n }\n\n .cursor-pointer {\n cursor: pointer;\n }\n\n .resize {\n resize: both;\n }\n\n .flex-col {\n flex-direction: column;\n }\n\n .flex-wrap {\n flex-wrap: wrap;\n }\n\n .items-center {\n align-items: center;\n }\n\n .justify-between {\n justify-content: space-between;\n }\n\n .justify-center {\n justify-content: center;\n }\n\n .gap-1 {\n gap: var(--spacing);\n }\n\n .gap-x-3 {\n column-gap: calc(var(--spacing) * 3);\n }\n\n .gap-y-1 {\n row-gap: var(--spacing);\n }\n\n .truncate {\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n }\n\n .overflow-hidden {\n overflow: hidden;\n }\n\n .overflow-x-hidden {\n overflow-x: hidden;\n }\n\n .overflow-y-auto {\n overflow-y: auto;\n }\n\n .rounded-lg {\n border-radius: var(--radius-lg);\n }\n\n .rounded-xl {\n border-radius: var(--radius-xl);\n }\n\n .border {\n border-style: var(--tw-border-style);\n border-width: 1px;\n }\n\n .border-e {\n border-inline-end-style: var(--tw-border-style);\n border-inline-end-width: 1px;\n }\n\n .border-b {\n border-bottom-style: var(--tw-border-style);\n border-bottom-width: 1px;\n }\n\n .border-border {\n border-color: var(--color-border);\n }\n\n .border-sidebar-border {\n border-color: var(--color-sidebar-border);\n }\n\n .bg-background {\n background-color: var(--color-background);\n }\n\n .bg-black\\/50 {\n background-color: #00000080;\n }\n\n @supports (color: color-mix(in lab, red, red)) {\n .bg-black\\/50 {\n background-color: color-mix(in oklab, var(--color-black) 50%, transparent);\n }\n }\n\n .bg-card {\n background-color: var(--color-card);\n }\n\n .bg-sidebar {\n background-color: var(--color-sidebar);\n }\n\n .bg-sidebar-accent {\n background-color: var(--color-sidebar-accent);\n }\n\n .px-2 {\n padding-inline: calc(var(--spacing) * 2);\n }\n\n .px-3 {\n padding-inline: calc(var(--spacing) * 3);\n }\n\n .px-5 {\n padding-inline: calc(var(--spacing) * 5);\n }\n\n .px-6 {\n padding-inline: calc(var(--spacing) * 6);\n }\n\n .py-1\\.5 {\n padding-block: calc(var(--spacing) * 1.5);\n }\n\n .py-2 {\n padding-block: calc(var(--spacing) * 2);\n }\n\n .py-3 {\n padding-block: calc(var(--spacing) * 3);\n }\n\n .py-5 {\n padding-block: calc(var(--spacing) * 5);\n }\n\n .py-8 {\n padding-block: calc(var(--spacing) * 8);\n }\n\n .ps-5 {\n padding-inline-start: calc(var(--spacing) * 5);\n }\n\n .ps-7 {\n padding-inline-start: calc(var(--spacing) * 7);\n }\n\n .pe-2 {\n padding-inline-end: calc(var(--spacing) * 2);\n }\n\n .pt-3 {\n padding-top: calc(var(--spacing) * 3);\n }\n\n .pb-3 {\n padding-bottom: calc(var(--spacing) * 3);\n }\n\n .text-left {\n text-align: left;\n }\n\n .text-sm {\n font-size: var(--text-sm);\n line-height: var(--tw-leading, var(--text-sm--line-height));\n }\n\n .font-medium {\n --tw-font-weight: var(--font-weight-medium);\n font-weight: var(--font-weight-medium);\n }\n\n .font-semibold {\n --tw-font-weight: var(--font-weight-semibold);\n font-weight: var(--font-weight-semibold);\n }\n\n .text-foreground {\n color: var(--color-foreground);\n }\n\n .text-muted-foreground {\n color: var(--color-muted-foreground);\n }\n\n .text-sidebar-foreground, .text-sidebar-foreground\\/60 {\n color: var(--color-sidebar-foreground);\n }\n\n @supports (color: color-mix(in lab, red, red)) {\n .text-sidebar-foreground\\/60 {\n color: color-mix(in oklab, var(--color-sidebar-foreground) 60%, transparent);\n }\n }\n\n .text-sidebar-primary {\n color: var(--color-sidebar-primary);\n }\n\n .italic {\n font-style: italic;\n }\n\n .shadow-2xs {\n --tw-shadow: 0 1px var(--tw-shadow-color, #0000000d);\n box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);\n }\n\n .transition {\n transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to, opacity, box-shadow, transform, translate, scale, rotate, filter, -webkit-backdrop-filter, backdrop-filter, display, content-visibility, overlay, pointer-events;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n\n .transition-transform {\n transition-property: transform, translate, scale, rotate;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n\n .ease-in-out {\n --tw-ease: var(--ease-in-out);\n transition-timing-function: var(--ease-in-out);\n }\n\n .outline-none {\n --tw-outline-style: none;\n outline-style: none;\n }\n\n .placeholder\\:text-sidebar-foreground\\/50::placeholder {\n color: var(--color-sidebar-foreground);\n }\n\n @supports (color: color-mix(in lab, red, red)) {\n .placeholder\\:text-sidebar-foreground\\/50::placeholder {\n color: color-mix(in oklab, var(--color-sidebar-foreground) 50%, transparent);\n }\n }\n\n .before\\:absolute:before {\n content: var(--tw-content);\n position: absolute;\n }\n\n .before\\:start-\\[1\\.125rem\\]:before {\n content: var(--tw-content);\n inset-inline-start: 1.125rem;\n }\n\n .before\\:top-0:before {\n content: var(--tw-content);\n top: 0;\n }\n\n .before\\:h-full:before {\n content: var(--tw-content);\n height: 100%;\n }\n\n .before\\:w-px:before {\n content: var(--tw-content);\n width: 1px;\n }\n\n .before\\:bg-sidebar-border:before {\n content: var(--tw-content);\n background-color: var(--color-sidebar-border);\n }\n\n @media (hover: hover) {\n .hover\\:bg-sidebar-accent:hover {\n background-color: var(--color-sidebar-accent);\n }\n\n .hover\\:bg-sidebar-border:hover {\n background-color: var(--color-sidebar-border);\n }\n\n .hover\\:text-foreground:hover {\n color: var(--color-foreground);\n }\n\n .hover\\:text-sidebar-primary:hover {\n color: var(--color-sidebar-primary);\n }\n }\n\n .focus\\:border-sidebar-primary:focus {\n border-color: var(--color-sidebar-primary);\n }\n\n @media (width >= 40rem) {\n .sm\\:px-5 {\n padding-inline: calc(var(--spacing) * 5);\n }\n\n .sm\\:px-10 {\n padding-inline: calc(var(--spacing) * 10);\n }\n\n .sm\\:py-10 {\n padding-block: calc(var(--spacing) * 10);\n }\n\n .sm\\:py-15 {\n padding-block: calc(var(--spacing) * 15);\n }\n }\n\n @media (width >= 64rem) {\n .lg\\:block {\n display: block;\n }\n\n .lg\\:w-auto {\n width: auto;\n }\n\n .lg\\:px-5 {\n padding-inline: calc(var(--spacing) * 5);\n }\n\n .lg\\:ps-8 {\n padding-inline-start: calc(var(--spacing) * 8);\n }\n }\n\n .\\[\\&\\:\\:-webkit-scrollbar\\]\\:w-2::-webkit-scrollbar {\n width: calc(var(--spacing) * 2);\n }\n\n .\\[\\&\\:\\:-webkit-scrollbar-thumb\\]\\:rounded-none::-webkit-scrollbar-thumb {\n border-radius: 0;\n }\n\n .\\[\\&\\:\\:-webkit-scrollbar-thumb\\]\\:bg-scrollbar-thumb::-webkit-scrollbar-thumb {\n background-color: var(--color-scrollbar-thumb);\n }\n\n .\\[\\&\\:\\:-webkit-scrollbar-track\\]\\:bg-scrollbar-track::-webkit-scrollbar-track {\n background-color: var(--color-scrollbar-track);\n }\n}\n\n:root {\n --background: #fff;\n --foreground: #393a34;\n --card: #fff;\n --card-foreground: #393a34;\n --primary: #1c6b48;\n --primary-foreground: #fff;\n --muted: #f7f7f7;\n --muted-foreground: #6a737d;\n --border: #f0f0f0;\n --sidebar: #fff;\n --sidebar-foreground: #4e4f47;\n --sidebar-primary: #1c6b48;\n --sidebar-accent: #f7f7f7;\n --sidebar-accent-foreground: #393a34;\n --sidebar-border: #f0f0f0;\n --font-sans: ui-sans-serif, system-ui, sans-serif;\n --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n --scrollbar-track: #f7f7f7;\n --scrollbar-thumb: #393a3450;\n --radius: .5rem;\n}\n\n.dark {\n --background: #121212;\n --foreground: #dbd7caee;\n --card: #181818;\n --card-foreground: #dbd7caee;\n --primary: #4d9375;\n --primary-foreground: #121212;\n --muted: #181818;\n --muted-foreground: #959da5;\n --border: #191919;\n --sidebar: #121212;\n --sidebar-foreground: #bfbaaa;\n --sidebar-primary: #4d9375;\n --sidebar-accent: #181818;\n --sidebar-accent-foreground: #dbd7caee;\n --sidebar-border: #191919;\n --scrollbar-track: #181818;\n --scrollbar-thumb: #dedcd550;\n}\n\n#sidebar {\n transition: translate .3s;\n}\n\nbody[data-sidebar-open] #sidebar {\n translate: 0;\n}\n\nbody[data-sidebar-open] #sidebar-overlay {\n display: block;\n}\n\nbody[data-sidebar-open] #icon-sidebar-open {\n display: none;\n}\n\nbody[data-sidebar-open] #icon-sidebar-close {\n display: inline;\n}\n\n@media (width >= 1024px) {\n #sidebar {\n width: var(--sidebar-width, 18rem);\n }\n\n #header-bar, #main-content {\n transition: margin .3s;\n }\n\n body[data-sidebar-open] #sidebar-overlay {\n display: none;\n }\n\n body[data-sidebar-open] #header-bar, body[data-sidebar-open] #main-content {\n margin-inline-start: var(--sidebar-width, 18rem);\n }\n}\n\n@property --tw-translate-x {\n syntax: \"*\";\n inherits: false;\n initial-value: 0;\n}\n\n@property --tw-translate-y {\n syntax: \"*\";\n inherits: false;\n initial-value: 0;\n}\n\n@property --tw-translate-z {\n syntax: \"*\";\n inherits: false;\n initial-value: 0;\n}\n\n@property --tw-rotate-x {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-rotate-y {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-rotate-z {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-skew-x {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-skew-y {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-border-style {\n syntax: \"*\";\n inherits: false;\n initial-value: solid;\n}\n\n@property --tw-font-weight {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n\n@property --tw-shadow-color {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-shadow-alpha {\n syntax: \"<percentage>\";\n inherits: false;\n initial-value: 100%;\n}\n\n@property --tw-inset-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n\n@property --tw-inset-shadow-color {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-inset-shadow-alpha {\n syntax: \"<percentage>\";\n inherits: false;\n initial-value: 100%;\n}\n\n@property --tw-ring-color {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-ring-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n\n@property --tw-inset-ring-color {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-inset-ring-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n\n@property --tw-ring-inset {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-ring-offset-width {\n syntax: \"<length>\";\n inherits: false;\n initial-value: 0;\n}\n\n@property --tw-ring-offset-color {\n syntax: \"*\";\n inherits: false;\n initial-value: #fff;\n}\n\n@property --tw-ring-offset-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n\n@property --tw-ease {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-content {\n syntax: \"*\";\n inherits: false;\n initial-value: \"\";\n}\n\n@keyframes spin {\n to {\n transform: rotate(360deg);\n }\n}\n\n@keyframes pulse {\n 50% {\n opacity: .5;\n }\n}\n";
|
|
1348
|
+
var global_default = "/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n@layer properties {\n @supports (((-webkit-hyphens: none)) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color: rgb(from red r g b)))) {\n *, :before, :after, ::backdrop {\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-translate-z: 0;\n --tw-rotate-x: initial;\n --tw-rotate-y: initial;\n --tw-rotate-z: initial;\n --tw-skew-x: initial;\n --tw-skew-y: initial;\n --tw-border-style: solid;\n --tw-font-weight: initial;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-color: initial;\n --tw-shadow-alpha: 100%;\n --tw-inset-shadow: 0 0 #0000;\n --tw-inset-shadow-color: initial;\n --tw-inset-shadow-alpha: 100%;\n --tw-ring-color: initial;\n --tw-ring-shadow: 0 0 #0000;\n --tw-inset-ring-color: initial;\n --tw-inset-ring-shadow: 0 0 #0000;\n --tw-ring-inset: initial;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-blur: initial;\n --tw-brightness: initial;\n --tw-contrast: initial;\n --tw-grayscale: initial;\n --tw-hue-rotate: initial;\n --tw-invert: initial;\n --tw-opacity: initial;\n --tw-saturate: initial;\n --tw-sepia: initial;\n --tw-drop-shadow: initial;\n --tw-drop-shadow-color: initial;\n --tw-drop-shadow-alpha: 100%;\n --tw-drop-shadow-size: initial;\n --tw-ease: initial;\n --tw-content: \"\";\n }\n }\n}\n\n@layer theme {\n :root, :host {\n --font-sans: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", \"Noto Sans\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\";\n --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace;\n --color-black: #000;\n --spacing: .25rem;\n --container-4xl: 56rem;\n --text-xs: .75rem;\n --text-xs--line-height: calc(1 / .75);\n --text-sm: .875rem;\n --text-sm--line-height: calc(1.25 / .875);\n --font-weight-medium: 500;\n --font-weight-semibold: 600;\n --radius-md: .375rem;\n --radius-lg: .5rem;\n --radius-xl: .75rem;\n --ease-in-out: cubic-bezier(.4, 0, .2, 1);\n --animate-spin: spin 1s linear infinite;\n --animate-pulse: pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;\n --default-transition-duration: .15s;\n --default-transition-timing-function: cubic-bezier(.4, 0, .2, 1);\n --default-font-family: var(--font-sans);\n --default-mono-font-family: var(--font-mono);\n --color-background: var(--background);\n --color-foreground: var(--foreground);\n --color-card: var(--card);\n --color-muted-foreground: var(--muted-foreground);\n --color-border: var(--border);\n --color-sidebar: var(--sidebar);\n --color-sidebar-foreground: var(--sidebar-foreground);\n --color-sidebar-primary: var(--sidebar-primary);\n --color-sidebar-accent: var(--sidebar-accent);\n --color-sidebar-border: var(--sidebar-border);\n --color-scrollbar-track: var(--scrollbar-track);\n --color-scrollbar-thumb: var(--scrollbar-thumb);\n }\n}\n\n@layer base {\n *, :after, :before, ::backdrop {\n box-sizing: border-box;\n border: 0 solid;\n margin: 0;\n padding: 0;\n }\n\n ::file-selector-button {\n box-sizing: border-box;\n border: 0 solid;\n margin: 0;\n padding: 0;\n }\n\n html, :host {\n -webkit-text-size-adjust: 100%;\n tab-size: 4;\n line-height: 1.5;\n font-family: var(--default-font-family, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", \"Noto Sans\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\");\n font-feature-settings: var(--default-font-feature-settings, normal);\n font-variation-settings: var(--default-font-variation-settings, normal);\n -webkit-tap-highlight-color: transparent;\n }\n\n hr {\n height: 0;\n color: inherit;\n border-top-width: 1px;\n }\n\n abbr:where([title]) {\n text-decoration: underline dotted;\n }\n\n h1, h2, h3, h4, h5, h6 {\n font-size: inherit;\n font-weight: inherit;\n }\n\n a {\n color: inherit;\n -webkit-text-decoration: inherit;\n -webkit-text-decoration: inherit;\n -webkit-text-decoration: inherit;\n text-decoration: inherit;\n }\n\n b, strong {\n font-weight: bolder;\n }\n\n code, kbd, samp, pre {\n font-family: var(--default-mono-font-family, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace);\n font-feature-settings: var(--default-mono-font-feature-settings, normal);\n font-variation-settings: var(--default-mono-font-variation-settings, normal);\n font-size: 1em;\n }\n\n small {\n font-size: 80%;\n }\n\n sub, sup {\n vertical-align: baseline;\n font-size: 75%;\n line-height: 0;\n position: relative;\n }\n\n sub {\n bottom: -.25em;\n }\n\n sup {\n top: -.5em;\n }\n\n table {\n text-indent: 0;\n border-color: inherit;\n border-collapse: collapse;\n }\n\n :-moz-focusring:where(:not(iframe)) {\n outline: auto;\n }\n\n progress {\n vertical-align: baseline;\n }\n\n summary {\n display: list-item;\n }\n\n ol, ul, menu {\n list-style: none;\n }\n\n img, svg, video, canvas, audio, iframe, embed, object {\n vertical-align: middle;\n display: block;\n }\n\n img, video {\n max-width: 100%;\n height: auto;\n }\n\n button, input, select, optgroup, textarea {\n font: inherit;\n font-feature-settings: inherit;\n font-variation-settings: inherit;\n letter-spacing: inherit;\n color: inherit;\n opacity: 1;\n background-color: #0000;\n border-radius: 0;\n }\n\n ::file-selector-button {\n font: inherit;\n font-feature-settings: inherit;\n font-variation-settings: inherit;\n letter-spacing: inherit;\n color: inherit;\n opacity: 1;\n background-color: #0000;\n border-radius: 0;\n }\n\n :where(select:is([multiple], [size])) optgroup {\n font-weight: bolder;\n }\n\n :where(select:is([multiple], [size])) optgroup option {\n padding-inline-start: 20px;\n }\n\n ::file-selector-button {\n margin-inline-end: 4px;\n }\n\n ::placeholder {\n opacity: 1;\n }\n\n @supports (not ((-webkit-appearance: -apple-pay-button))) or (contain-intrinsic-size: 1px) {\n ::placeholder {\n color: currentColor;\n }\n\n @supports (color: color-mix(in lab, red, red)) {\n ::placeholder {\n color: color-mix(in oklab, currentcolor 50%, transparent);\n }\n }\n }\n\n textarea {\n resize: vertical;\n }\n\n ::-webkit-search-decoration {\n -webkit-appearance: none;\n }\n\n ::-webkit-date-and-time-value {\n min-height: 1lh;\n text-align: inherit;\n }\n\n ::-webkit-datetime-edit {\n display: inline-flex;\n }\n\n ::-webkit-datetime-edit-fields-wrapper {\n padding: 0;\n }\n\n ::-webkit-datetime-edit {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-year-field {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-month-field {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-day-field {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-hour-field {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-minute-field {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-second-field {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-millisecond-field {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-meridiem-field {\n padding-block: 0;\n }\n\n ::-webkit-calendar-picker-indicator {\n line-height: 1;\n }\n\n :-moz-ui-invalid {\n box-shadow: none;\n }\n\n button, input:where([type=\"button\"], [type=\"reset\"], [type=\"submit\"]) {\n appearance: button;\n }\n\n ::file-selector-button {\n appearance: button;\n }\n\n ::-webkit-inner-spin-button {\n height: auto;\n }\n\n ::-webkit-outer-spin-button {\n height: auto;\n }\n\n [hidden]:where(:not([hidden=\"until-found\"])) {\n display: none !important;\n }\n}\n\n@layer components;\n\n@layer utilities {\n .pointer-events-auto {\n pointer-events: auto;\n }\n\n .collapse {\n visibility: collapse;\n }\n\n .visible {\n visibility: visible;\n }\n\n .absolute {\n position: absolute;\n }\n\n .fixed {\n position: fixed;\n }\n\n .relative {\n position: relative;\n }\n\n .sticky {\n position: sticky;\n }\n\n .inset-0 {\n inset: 0;\n }\n\n .inset-y-0 {\n inset-block: 0;\n }\n\n .start-0 {\n inset-inline-start: calc(var(--spacing) * 0);\n }\n\n .end-0 {\n inset-inline-end: calc(var(--spacing) * 0);\n }\n\n .top-0 {\n top: 0;\n }\n\n .top-full {\n top: 100%;\n }\n\n .z-50 {\n z-index: 50;\n }\n\n .z-60 {\n z-index: 60;\n }\n\n .container {\n width: 100%;\n }\n\n @media (width >= 40rem) {\n .container {\n max-width: 40rem;\n }\n }\n\n @media (width >= 48rem) {\n .container {\n max-width: 48rem;\n }\n }\n\n @media (width >= 64rem) {\n .container {\n max-width: 64rem;\n }\n }\n\n @media (width >= 80rem) {\n .container {\n max-width: 80rem;\n }\n }\n\n @media (width >= 96rem) {\n .container {\n max-width: 96rem;\n }\n }\n\n .mx-1 {\n margin-inline: var(--spacing);\n }\n\n .mx-auto {\n margin-inline: auto;\n }\n\n .my-1 {\n margin-block: var(--spacing);\n }\n\n .ms-auto {\n margin-inline-start: auto;\n }\n\n .mt-1 {\n margin-top: var(--spacing);\n }\n\n .mt-1\\.5 {\n margin-top: calc(var(--spacing) * 1.5);\n }\n\n .mb-1 {\n margin-bottom: var(--spacing);\n }\n\n .block {\n display: block;\n }\n\n .contents {\n display: contents;\n }\n\n .flex {\n display: flex;\n }\n\n .hidden {\n display: none;\n }\n\n .inline {\n display: inline;\n }\n\n .inline-flex {\n display: inline-flex;\n }\n\n .table {\n display: table;\n }\n\n .size-3\\.5 {\n width: calc(var(--spacing) * 3.5);\n height: calc(var(--spacing) * 3.5);\n }\n\n .size-4 {\n width: calc(var(--spacing) * 4);\n height: calc(var(--spacing) * 4);\n }\n\n .h-7 {\n height: calc(var(--spacing) * 7);\n }\n\n .h-11\\.5 {\n height: calc(var(--spacing) * 11.5);\n }\n\n .h-full {\n height: 100%;\n }\n\n .max-h-full {\n max-height: 100%;\n }\n\n .min-h-0 {\n min-height: 0;\n }\n\n .min-h-dvh {\n min-height: 100dvh;\n }\n\n .min-h-screen {\n min-height: 100vh;\n }\n\n .w-1 {\n width: var(--spacing);\n }\n\n .w-7 {\n width: calc(var(--spacing) * 7);\n }\n\n .w-64 {\n width: calc(var(--spacing) * 64);\n }\n\n .w-72 {\n width: calc(var(--spacing) * 72);\n }\n\n .w-full {\n width: 100%;\n }\n\n .max-w-4xl {\n max-width: var(--container-4xl);\n }\n\n .max-w-\\[calc\\(100vw-1rem\\)\\] {\n max-width: calc(100vw - 1rem);\n }\n\n .min-w-0 {\n min-width: 0;\n }\n\n .flex-1 {\n flex: 1;\n }\n\n .flex-none {\n flex: none;\n }\n\n .shrink-0 {\n flex-shrink: 0;\n }\n\n .border-collapse {\n border-collapse: collapse;\n }\n\n .-translate-x-full {\n --tw-translate-x: -100%;\n translate: var(--tw-translate-x) var(--tw-translate-y);\n }\n\n .-rotate-90 {\n rotate: -90deg;\n }\n\n .transform {\n transform: var(--tw-rotate-x, ) var(--tw-rotate-y, ) var(--tw-rotate-z, ) var(--tw-skew-x, ) var(--tw-skew-y, );\n }\n\n .animate-pulse {\n animation: var(--animate-pulse);\n }\n\n .animate-spin {\n animation: var(--animate-spin);\n }\n\n .cursor-col-resize {\n cursor: col-resize;\n }\n\n .cursor-pointer {\n cursor: pointer;\n }\n\n .resize {\n resize: both;\n }\n\n .break-before-page {\n break-before: page;\n }\n\n .flex-col {\n flex-direction: column;\n }\n\n .flex-wrap {\n flex-wrap: wrap;\n }\n\n .items-center {\n align-items: center;\n }\n\n .justify-between {\n justify-content: space-between;\n }\n\n .justify-center {\n justify-content: center;\n }\n\n .gap-1 {\n gap: var(--spacing);\n }\n\n .gap-x-3 {\n column-gap: calc(var(--spacing) * 3);\n }\n\n .gap-y-1 {\n row-gap: var(--spacing);\n }\n\n .truncate {\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n }\n\n .overflow-hidden {\n overflow: hidden;\n }\n\n .overflow-x-hidden {\n overflow-x: hidden;\n }\n\n .overflow-y-auto {\n overflow-y: auto;\n }\n\n .rounded-lg {\n border-radius: var(--radius-lg);\n }\n\n .rounded-md {\n border-radius: var(--radius-md);\n }\n\n .rounded-xl {\n border-radius: var(--radius-xl);\n }\n\n .border {\n border-style: var(--tw-border-style);\n border-width: 1px;\n }\n\n .border-e {\n border-inline-end-style: var(--tw-border-style);\n border-inline-end-width: 1px;\n }\n\n .border-b {\n border-bottom-style: var(--tw-border-style);\n border-bottom-width: 1px;\n }\n\n .border-border {\n border-color: var(--color-border);\n }\n\n .border-muted-foreground\\/25 {\n border-color: var(--color-muted-foreground);\n }\n\n @supports (color: color-mix(in lab, red, red)) {\n .border-muted-foreground\\/25 {\n border-color: color-mix(in oklab, var(--color-muted-foreground) 25%, transparent);\n }\n }\n\n .border-sidebar-border {\n border-color: var(--color-sidebar-border);\n }\n\n .bg-background {\n background-color: var(--color-background);\n }\n\n .bg-black\\/50 {\n background-color: #00000080;\n }\n\n @supports (color: color-mix(in lab, red, red)) {\n .bg-black\\/50 {\n background-color: color-mix(in oklab, var(--color-black) 50%, transparent);\n }\n }\n\n .bg-card {\n background-color: var(--color-card);\n }\n\n .bg-sidebar {\n background-color: var(--color-sidebar);\n }\n\n .bg-sidebar-accent {\n background-color: var(--color-sidebar-accent);\n }\n\n .p-1 {\n padding: var(--spacing);\n }\n\n .px-2 {\n padding-inline: calc(var(--spacing) * 2);\n }\n\n .px-3 {\n padding-inline: calc(var(--spacing) * 3);\n }\n\n .px-5 {\n padding-inline: calc(var(--spacing) * 5);\n }\n\n .px-6 {\n padding-inline: calc(var(--spacing) * 6);\n }\n\n .py-1\\.5 {\n padding-block: calc(var(--spacing) * 1.5);\n }\n\n .py-2 {\n padding-block: calc(var(--spacing) * 2);\n }\n\n .py-3 {\n padding-block: calc(var(--spacing) * 3);\n }\n\n .py-5 {\n padding-block: calc(var(--spacing) * 5);\n }\n\n .py-8 {\n padding-block: calc(var(--spacing) * 8);\n }\n\n .ps-5 {\n padding-inline-start: calc(var(--spacing) * 5);\n }\n\n .ps-7 {\n padding-inline-start: calc(var(--spacing) * 7);\n }\n\n .pe-2 {\n padding-inline-end: calc(var(--spacing) * 2);\n }\n\n .pt-1\\.5 {\n padding-top: calc(var(--spacing) * 1.5);\n }\n\n .pt-3 {\n padding-top: calc(var(--spacing) * 3);\n }\n\n .pb-1 {\n padding-bottom: var(--spacing);\n }\n\n .pb-3 {\n padding-bottom: calc(var(--spacing) * 3);\n }\n\n .text-left {\n text-align: left;\n }\n\n .text-sm {\n font-size: var(--text-sm);\n line-height: var(--tw-leading, var(--text-sm--line-height));\n }\n\n .text-xs {\n font-size: var(--text-xs);\n line-height: var(--tw-leading, var(--text-xs--line-height));\n }\n\n .font-medium {\n --tw-font-weight: var(--font-weight-medium);\n font-weight: var(--font-weight-medium);\n }\n\n .font-semibold {\n --tw-font-weight: var(--font-weight-semibold);\n font-weight: var(--font-weight-semibold);\n }\n\n .text-foreground {\n color: var(--color-foreground);\n }\n\n .text-muted-foreground {\n color: var(--color-muted-foreground);\n }\n\n .text-sidebar-foreground, .text-sidebar-foreground\\/60 {\n color: var(--color-sidebar-foreground);\n }\n\n @supports (color: color-mix(in lab, red, red)) {\n .text-sidebar-foreground\\/60 {\n color: color-mix(in oklab, var(--color-sidebar-foreground) 60%, transparent);\n }\n }\n\n .text-sidebar-primary {\n color: var(--color-sidebar-primary);\n }\n\n .italic {\n font-style: italic;\n }\n\n .shadow-2xs {\n --tw-shadow: 0 1px var(--tw-shadow-color, #0000000d);\n box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);\n }\n\n .shadow-lg {\n --tw-shadow: 0 10px 15px -3px var(--tw-shadow-color, #0000001a), 0 4px 6px -4px var(--tw-shadow-color, #0000001a);\n box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);\n }\n\n .blur {\n --tw-blur: blur(8px);\n filter: var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, );\n }\n\n .transition {\n transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to, opacity, box-shadow, transform, translate, scale, rotate, filter, -webkit-backdrop-filter, backdrop-filter, display, content-visibility, overlay, pointer-events;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n\n .transition-transform {\n transition-property: transform, translate, scale, rotate;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n\n .ease-in-out {\n --tw-ease: var(--ease-in-out);\n transition-timing-function: var(--ease-in-out);\n }\n\n .outline-none {\n --tw-outline-style: none;\n outline-style: none;\n }\n\n .\\[print-color-adjust\\:exact\\] {\n -webkit-print-color-adjust: exact;\n print-color-adjust: exact;\n }\n\n .placeholder\\:text-sidebar-foreground\\/50::placeholder {\n color: var(--color-sidebar-foreground);\n }\n\n @supports (color: color-mix(in lab, red, red)) {\n .placeholder\\:text-sidebar-foreground\\/50::placeholder {\n color: color-mix(in oklab, var(--color-sidebar-foreground) 50%, transparent);\n }\n }\n\n .before\\:absolute:before {\n content: var(--tw-content);\n position: absolute;\n }\n\n .before\\:start-\\[1\\.125rem\\]:before {\n content: var(--tw-content);\n inset-inline-start: 1.125rem;\n }\n\n .before\\:top-0:before {\n content: var(--tw-content);\n top: 0;\n }\n\n .before\\:h-full:before {\n content: var(--tw-content);\n height: 100%;\n }\n\n .before\\:w-px:before {\n content: var(--tw-content);\n width: 1px;\n }\n\n .before\\:bg-sidebar-border:before {\n content: var(--tw-content);\n background-color: var(--color-sidebar-border);\n }\n\n @media (hover: hover) {\n .hover\\:bg-sidebar-accent:hover {\n background-color: var(--color-sidebar-accent);\n }\n\n .hover\\:bg-sidebar-border:hover {\n background-color: var(--color-sidebar-border);\n }\n\n .hover\\:text-foreground:hover {\n color: var(--color-foreground);\n }\n\n .hover\\:text-sidebar-primary:hover {\n color: var(--color-sidebar-primary);\n }\n }\n\n .focus\\:border-sidebar-primary:focus {\n border-color: var(--color-sidebar-primary);\n }\n\n .focus-visible\\:bg-sidebar-accent:focus-visible {\n background-color: var(--color-sidebar-accent);\n }\n\n .enabled\\:cursor-pointer:enabled {\n cursor: pointer;\n }\n\n @media (hover: hover) {\n .enabled\\:hover\\:bg-sidebar-accent:enabled:hover {\n background-color: var(--color-sidebar-accent);\n }\n }\n\n .disabled\\:opacity-50:disabled {\n opacity: .5;\n }\n\n @media (width >= 40rem) {\n .sm\\:px-5 {\n padding-inline: calc(var(--spacing) * 5);\n }\n\n .sm\\:px-10 {\n padding-inline: calc(var(--spacing) * 10);\n }\n\n .sm\\:py-10 {\n padding-block: calc(var(--spacing) * 10);\n }\n\n .sm\\:py-15 {\n padding-block: calc(var(--spacing) * 15);\n }\n }\n\n @media (width >= 64rem) {\n .lg\\:block {\n display: block;\n }\n\n .lg\\:w-auto {\n width: auto;\n }\n\n .lg\\:px-5 {\n padding-inline: calc(var(--spacing) * 5);\n }\n\n .lg\\:ps-8 {\n padding-inline-start: calc(var(--spacing) * 8);\n }\n }\n\n .\\[\\&\\:\\:-webkit-scrollbar\\]\\:w-2::-webkit-scrollbar {\n width: calc(var(--spacing) * 2);\n }\n\n .\\[\\&\\:\\:-webkit-scrollbar-thumb\\]\\:rounded-none::-webkit-scrollbar-thumb {\n border-radius: 0;\n }\n\n .\\[\\&\\:\\:-webkit-scrollbar-thumb\\]\\:bg-scrollbar-thumb::-webkit-scrollbar-thumb {\n background-color: var(--color-scrollbar-thumb);\n }\n\n .\\[\\&\\:\\:-webkit-scrollbar-track\\]\\:bg-scrollbar-track::-webkit-scrollbar-track {\n background-color: var(--color-scrollbar-track);\n }\n}\n\n:root {\n --background: #fff;\n --foreground: #393a34;\n --card: #fff;\n --card-foreground: #393a34;\n --primary: #1c6b48;\n --primary-foreground: #fff;\n --muted: #f7f7f7;\n --muted-foreground: #6a737d;\n --border: #f0f0f0;\n --sidebar: #fff;\n --sidebar-foreground: #4e4f47;\n --sidebar-primary: #1c6b48;\n --sidebar-accent: #f7f7f7;\n --sidebar-accent-foreground: #393a34;\n --sidebar-border: #f0f0f0;\n --font-sans: ui-sans-serif, system-ui, sans-serif;\n --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n --scrollbar-track: #f7f7f7;\n --scrollbar-thumb: #393a3450;\n --radius: .5rem;\n}\n\n.dark {\n --background: #121212;\n --foreground: #dbd7caee;\n --card: #181818;\n --card-foreground: #dbd7caee;\n --primary: #4d9375;\n --primary-foreground: #121212;\n --muted: #181818;\n --muted-foreground: #959da5;\n --border: #191919;\n --sidebar: #121212;\n --sidebar-foreground: #bfbaaa;\n --sidebar-primary: #4d9375;\n --sidebar-accent: #181818;\n --sidebar-accent-foreground: #dbd7caee;\n --sidebar-border: #191919;\n --scrollbar-track: #181818;\n --scrollbar-thumb: #dedcd550;\n}\n\n#sidebar {\n transition: translate .3s;\n}\n\nbody[data-sidebar-open] #sidebar {\n translate: 0;\n}\n\nbody[data-sidebar-open] #sidebar-overlay {\n display: block;\n}\n\nbody[data-sidebar-open] #icon-sidebar-open {\n display: none;\n}\n\nbody[data-sidebar-open] #icon-sidebar-close {\n display: inline;\n}\n\n@media (width >= 1024px) {\n #sidebar {\n width: var(--sidebar-width, 18rem);\n }\n\n #header-bar, #main-content {\n transition: margin .3s;\n }\n\n body[data-sidebar-open] #sidebar-overlay {\n display: none;\n }\n\n body[data-sidebar-open] #header-bar, body[data-sidebar-open] #main-content {\n margin-inline-start: var(--sidebar-width, 18rem);\n }\n}\n\n@property --tw-translate-x {\n syntax: \"*\";\n inherits: false;\n initial-value: 0;\n}\n\n@property --tw-translate-y {\n syntax: \"*\";\n inherits: false;\n initial-value: 0;\n}\n\n@property --tw-translate-z {\n syntax: \"*\";\n inherits: false;\n initial-value: 0;\n}\n\n@property --tw-rotate-x {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-rotate-y {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-rotate-z {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-skew-x {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-skew-y {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-border-style {\n syntax: \"*\";\n inherits: false;\n initial-value: solid;\n}\n\n@property --tw-font-weight {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n\n@property --tw-shadow-color {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-shadow-alpha {\n syntax: \"<percentage>\";\n inherits: false;\n initial-value: 100%;\n}\n\n@property --tw-inset-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n\n@property --tw-inset-shadow-color {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-inset-shadow-alpha {\n syntax: \"<percentage>\";\n inherits: false;\n initial-value: 100%;\n}\n\n@property --tw-ring-color {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-ring-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n\n@property --tw-inset-ring-color {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-inset-ring-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n\n@property --tw-ring-inset {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-ring-offset-width {\n syntax: \"<length>\";\n inherits: false;\n initial-value: 0;\n}\n\n@property --tw-ring-offset-color {\n syntax: \"*\";\n inherits: false;\n initial-value: #fff;\n}\n\n@property --tw-ring-offset-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n\n@property --tw-blur {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-brightness {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-contrast {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-grayscale {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-hue-rotate {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-invert {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-opacity {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-saturate {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-sepia {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-drop-shadow {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-drop-shadow-color {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-drop-shadow-alpha {\n syntax: \"<percentage>\";\n inherits: false;\n initial-value: 100%;\n}\n\n@property --tw-drop-shadow-size {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-ease {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-content {\n syntax: \"*\";\n inherits: false;\n initial-value: \"\";\n}\n\n@keyframes spin {\n to {\n transform: rotate(360deg);\n }\n}\n\n@keyframes pulse {\n 50% {\n opacity: .5;\n }\n}\n";
|
|
1349
|
+
//#endregion
|
|
1350
|
+
//#region src/server/renderer/page-styles.tsx
|
|
1351
|
+
/** The layout stylesheet, then the Markdown content stylesheet. */
|
|
1352
|
+
function PageStyles({ styles }) {
|
|
1353
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("style", { dangerouslySetInnerHTML: { __html: global_default } }), /* @__PURE__ */ jsx("style", { dangerouslySetInnerHTML: { __html: styles.contentCss.replaceAll("</style", "<\\/style") } })] });
|
|
1354
|
+
}
|
|
1022
1355
|
//#endregion
|
|
1023
1356
|
//#region src/server/renderer/document.tsx
|
|
1024
1357
|
const themeInitScript = `(function(){var t=localStorage.getItem("theme");if(t==="dark"||(t!=="light"&&window.matchMedia("(prefers-color-scheme: dark)").matches))document.documentElement.classList.add("dark")})()`;
|
|
@@ -1039,8 +1372,7 @@ function Document({ title, styles, initialState, children }) {
|
|
|
1039
1372
|
type: "image/x-icon"
|
|
1040
1373
|
}),
|
|
1041
1374
|
/* @__PURE__ */ jsx("script", { dangerouslySetInnerHTML: { __html: themeInitScript } }),
|
|
1042
|
-
/* @__PURE__ */ jsx(
|
|
1043
|
-
/* @__PURE__ */ jsx("style", { dangerouslySetInnerHTML: { __html: styles.contentCss.replaceAll("</style", "<\\/style") } })
|
|
1375
|
+
/* @__PURE__ */ jsx(PageStyles, { styles })
|
|
1044
1376
|
] }), /* @__PURE__ */ jsxs("body", {
|
|
1045
1377
|
class: "bg-background text-foreground min-h-screen",
|
|
1046
1378
|
children: [
|
|
@@ -1124,7 +1456,38 @@ function renderHtmlDocument(title, rawContentUrl) {
|
|
|
1124
1456
|
}))}`;
|
|
1125
1457
|
}
|
|
1126
1458
|
//#endregion
|
|
1459
|
+
//#region src/server/routes/markdown-file.ts
|
|
1460
|
+
/**
|
|
1461
|
+
* Reads the Markdown file at `realPath` (already checked to be inside the base
|
|
1462
|
+
* directory) and renders it, resolving its relative images against
|
|
1463
|
+
* `relativePath`.
|
|
1464
|
+
*/
|
|
1465
|
+
async function renderMarkdownAt(realPath, relativePath) {
|
|
1466
|
+
const result = await readTextFile(realPath);
|
|
1467
|
+
if (!result.ok) {
|
|
1468
|
+
if (result.error.type === "file-not-found") return {
|
|
1469
|
+
ok: false,
|
|
1470
|
+
status: 404,
|
|
1471
|
+
message: "File not found"
|
|
1472
|
+
};
|
|
1473
|
+
logger.error("Failed to read file:", result.error);
|
|
1474
|
+
return {
|
|
1475
|
+
ok: false,
|
|
1476
|
+
status: 500,
|
|
1477
|
+
message: "Internal server error"
|
|
1478
|
+
};
|
|
1479
|
+
}
|
|
1480
|
+
return {
|
|
1481
|
+
ok: true,
|
|
1482
|
+
html: await renderMarkdown(result.value, relativePath)
|
|
1483
|
+
};
|
|
1484
|
+
}
|
|
1485
|
+
//#endregion
|
|
1127
1486
|
//#region src/server/routes/directory.tsx
|
|
1487
|
+
/** Name the UI shows for the browsed directory. */
|
|
1488
|
+
function directoryTitle(dirPath) {
|
|
1489
|
+
return basename(dirPath) || dirPath;
|
|
1490
|
+
}
|
|
1128
1491
|
function findFirstFile(nodes) {
|
|
1129
1492
|
for (const node of nodes) {
|
|
1130
1493
|
if (node.type === "file") return node;
|
|
@@ -1136,6 +1499,7 @@ function findFirstFile(nodes) {
|
|
|
1136
1499
|
}
|
|
1137
1500
|
function renderDirectoryView(params) {
|
|
1138
1501
|
const { projectId, dirTitle, fileTitle, currentPath, contentType, html, tree, styles } = params;
|
|
1502
|
+
const openState = initialOpenState(tree, currentPath);
|
|
1139
1503
|
return renderDocument(/* @__PURE__ */ jsxs(Document, {
|
|
1140
1504
|
title: fileTitle,
|
|
1141
1505
|
styles,
|
|
@@ -1152,7 +1516,8 @@ function renderDirectoryView(params) {
|
|
|
1152
1516
|
/* @__PURE__ */ jsx(Sidebar, {
|
|
1153
1517
|
title: dirTitle,
|
|
1154
1518
|
tree,
|
|
1155
|
-
currentPath
|
|
1519
|
+
currentPath,
|
|
1520
|
+
isOpen: (path) => isDirectoryOpen(openState, path)
|
|
1156
1521
|
}),
|
|
1157
1522
|
/* @__PURE__ */ jsx(PageHeader, {
|
|
1158
1523
|
id: "header-bar",
|
|
@@ -1161,7 +1526,14 @@ function renderDirectoryView(params) {
|
|
|
1161
1526
|
href: "/"
|
|
1162
1527
|
}, { label: fileTitle }],
|
|
1163
1528
|
showSidebarToggle: true,
|
|
1164
|
-
externalLinkHref: `/${encodeUrlPath(currentPath)}
|
|
1529
|
+
externalLinkHref: `/${encodeUrlPath(currentPath)}`,
|
|
1530
|
+
actions: /* @__PURE__ */ jsx(PdfMenu, {
|
|
1531
|
+
currentPath,
|
|
1532
|
+
currentName: fileTitle,
|
|
1533
|
+
contentType,
|
|
1534
|
+
directories: directoryPdfEntries(tree, currentPath, dirTitle),
|
|
1535
|
+
onPrint: () => {}
|
|
1536
|
+
})
|
|
1165
1537
|
}),
|
|
1166
1538
|
/* @__PURE__ */ jsx(ContentView, {
|
|
1167
1539
|
contentType,
|
|
@@ -1199,24 +1571,7 @@ async function renderFileContent(dirPath, relativePath, contentType) {
|
|
|
1199
1571
|
html: ""
|
|
1200
1572
|
};
|
|
1201
1573
|
}
|
|
1202
|
-
|
|
1203
|
-
if (!result.ok) {
|
|
1204
|
-
if (result.error.type === "file-not-found") return {
|
|
1205
|
-
ok: false,
|
|
1206
|
-
status: 404,
|
|
1207
|
-
message: "File not found"
|
|
1208
|
-
};
|
|
1209
|
-
logger.error("Failed to read file:", result.error);
|
|
1210
|
-
return {
|
|
1211
|
-
ok: false,
|
|
1212
|
-
status: 500,
|
|
1213
|
-
message: "Internal server error"
|
|
1214
|
-
};
|
|
1215
|
-
}
|
|
1216
|
-
return {
|
|
1217
|
-
ok: true,
|
|
1218
|
-
html: await renderMarkdown(result.value, relativePath)
|
|
1219
|
-
};
|
|
1574
|
+
return renderMarkdownAt(realPath.value, relativePath);
|
|
1220
1575
|
}
|
|
1221
1576
|
function createDirectoryRoutes(dirPath, styles, treeCache) {
|
|
1222
1577
|
const app = new Hono();
|
|
@@ -1236,7 +1591,7 @@ function createDirectoryRoutes(dirPath, styles, treeCache) {
|
|
|
1236
1591
|
}
|
|
1237
1592
|
const rendered = await renderFileContent(dirPath, firstFile.path, contentType);
|
|
1238
1593
|
if (!rendered.ok) return c.text(rendered.message, rendered.status);
|
|
1239
|
-
const dirTitle =
|
|
1594
|
+
const dirTitle = directoryTitle(dirPath);
|
|
1240
1595
|
return c.html(renderDirectoryView({
|
|
1241
1596
|
projectId,
|
|
1242
1597
|
dirTitle,
|
|
@@ -1251,6 +1606,8 @@ function createDirectoryRoutes(dirPath, styles, treeCache) {
|
|
|
1251
1606
|
app.get("/view", async (c) => {
|
|
1252
1607
|
const relativePath = c.req.query("path");
|
|
1253
1608
|
if (!relativePath) return c.redirect("/");
|
|
1609
|
+
const slashPath = toSlashPath(relativePath);
|
|
1610
|
+
if (slashPath !== relativePath) return c.redirect(`/view?path=${encodeURIComponent(slashPath)}`);
|
|
1254
1611
|
if (!isRelativePathWithinBase(dirPath, relativePath)) return c.text("Forbidden", 403);
|
|
1255
1612
|
const contentType = getContentType(relativePath);
|
|
1256
1613
|
if (!contentType) return c.text("Not found", 404);
|
|
@@ -1261,12 +1618,12 @@ function createDirectoryRoutes(dirPath, styles, treeCache) {
|
|
|
1261
1618
|
logger.error("Failed to build file tree:", treeResult.error);
|
|
1262
1619
|
return c.text("Internal server error", 500);
|
|
1263
1620
|
}
|
|
1264
|
-
const dirTitle =
|
|
1621
|
+
const dirTitle = directoryTitle(dirPath);
|
|
1265
1622
|
return c.html(renderDirectoryView({
|
|
1266
1623
|
projectId,
|
|
1267
1624
|
dirTitle,
|
|
1268
1625
|
fileTitle: basename(relativePath),
|
|
1269
|
-
currentPath:
|
|
1626
|
+
currentPath: slashPath,
|
|
1270
1627
|
contentType,
|
|
1271
1628
|
html: rendered.html,
|
|
1272
1629
|
tree: treeResult.value,
|
|
@@ -1340,6 +1697,126 @@ function createHtmlFileRoutes(filePath) {
|
|
|
1340
1697
|
});
|
|
1341
1698
|
return app;
|
|
1342
1699
|
}
|
|
1700
|
+
//#endregion
|
|
1701
|
+
//#region src/server/renderer/print-document.tsx
|
|
1702
|
+
/**
|
|
1703
|
+
* A page that holds only Markdown content, for the browser to print as a PDF.
|
|
1704
|
+
* It has no theme script, so it always renders in the light theme, and no
|
|
1705
|
+
* client bundle, since nothing on it is interactive.
|
|
1706
|
+
*/
|
|
1707
|
+
function PrintDocument({ title, styles, contents }) {
|
|
1708
|
+
return /* @__PURE__ */ jsxs("html", {
|
|
1709
|
+
lang: "en",
|
|
1710
|
+
children: [/* @__PURE__ */ jsxs("head", { children: [
|
|
1711
|
+
/* @__PURE__ */ jsx("meta", { charSet: "UTF-8" }),
|
|
1712
|
+
/* @__PURE__ */ jsx("meta", {
|
|
1713
|
+
name: "viewport",
|
|
1714
|
+
content: "width=device-width, initial-scale=1.0"
|
|
1715
|
+
}),
|
|
1716
|
+
/* @__PURE__ */ jsx("title", { children: title }),
|
|
1717
|
+
/* @__PURE__ */ jsx(PageStyles, { styles })
|
|
1718
|
+
] }), /* @__PURE__ */ jsx("body", {
|
|
1719
|
+
class: "bg-background text-foreground [print-color-adjust:exact]",
|
|
1720
|
+
children: /* @__PURE__ */ jsx("main", { children: contents.map((html, index) => /* @__PURE__ */ jsx("article", {
|
|
1721
|
+
class: `markdown-body${index > 0 ? " break-before-page" : ""}`,
|
|
1722
|
+
dangerouslySetInnerHTML: { __html: html }
|
|
1723
|
+
}, index)) })
|
|
1724
|
+
})]
|
|
1725
|
+
});
|
|
1726
|
+
}
|
|
1727
|
+
function renderPrintDocument(props) {
|
|
1728
|
+
return `<!DOCTYPE html>${renderToString(/* @__PURE__ */ jsx(PrintDocument, { ...props }))}`;
|
|
1729
|
+
}
|
|
1730
|
+
//#endregion
|
|
1731
|
+
//#region src/server/routes/print.tsx
|
|
1732
|
+
async function renderMarkdownFile(dirPath, relativePath) {
|
|
1733
|
+
const realPath = await realPathWithinBase(dirPath, relativePath);
|
|
1734
|
+
if (!realPath.ok) return {
|
|
1735
|
+
ok: false,
|
|
1736
|
+
...realPathErrorResponse(realPath.error)
|
|
1737
|
+
};
|
|
1738
|
+
return renderMarkdownAt(realPath.value, relativePath);
|
|
1739
|
+
}
|
|
1740
|
+
async function filePrintPage(dirPath, relativePath) {
|
|
1741
|
+
if (!isRelativePathWithinBase(dirPath, relativePath)) return {
|
|
1742
|
+
ok: false,
|
|
1743
|
+
status: 403,
|
|
1744
|
+
message: "Forbidden"
|
|
1745
|
+
};
|
|
1746
|
+
if (getContentType(relativePath) !== "markdown") return {
|
|
1747
|
+
ok: false,
|
|
1748
|
+
status: 415,
|
|
1749
|
+
message: "Unsupported file type"
|
|
1750
|
+
};
|
|
1751
|
+
const rendered = await renderMarkdownFile(dirPath, relativePath);
|
|
1752
|
+
if (!rendered.ok) return rendered;
|
|
1753
|
+
return {
|
|
1754
|
+
ok: true,
|
|
1755
|
+
title: filePdfTitle(relativePath),
|
|
1756
|
+
contents: [rendered.html]
|
|
1757
|
+
};
|
|
1758
|
+
}
|
|
1759
|
+
async function directoryPrintPage(dirPath, treeCache, directory) {
|
|
1760
|
+
const tree = await treeCache.get();
|
|
1761
|
+
if (!tree.ok) {
|
|
1762
|
+
logger.error("Failed to build file tree:", tree.error);
|
|
1763
|
+
return {
|
|
1764
|
+
ok: false,
|
|
1765
|
+
status: 500,
|
|
1766
|
+
message: "Internal server error"
|
|
1767
|
+
};
|
|
1768
|
+
}
|
|
1769
|
+
const files = directoryMarkdownFiles(tree.value, directory);
|
|
1770
|
+
if (!files) return {
|
|
1771
|
+
ok: false,
|
|
1772
|
+
status: 404,
|
|
1773
|
+
message: "Directory not found"
|
|
1774
|
+
};
|
|
1775
|
+
switch (directoryPdfStatus(files.length)) {
|
|
1776
|
+
case "empty": return {
|
|
1777
|
+
ok: false,
|
|
1778
|
+
status: 404,
|
|
1779
|
+
message: "No Markdown files in this directory"
|
|
1780
|
+
};
|
|
1781
|
+
case "too-many": return {
|
|
1782
|
+
ok: false,
|
|
1783
|
+
status: 422,
|
|
1784
|
+
message: `Too many Markdown files: ${files.length} (limit 200)`
|
|
1785
|
+
};
|
|
1786
|
+
case "ok": break;
|
|
1787
|
+
}
|
|
1788
|
+
const contents = [];
|
|
1789
|
+
for (const rendered of await Promise.all(files.map((file) => renderMarkdownFile(dirPath, file)))) {
|
|
1790
|
+
if (!rendered.ok) return rendered;
|
|
1791
|
+
contents.push(rendered.html);
|
|
1792
|
+
}
|
|
1793
|
+
return {
|
|
1794
|
+
ok: true,
|
|
1795
|
+
title: directoryName(directory, directoryTitle(dirPath)),
|
|
1796
|
+
contents
|
|
1797
|
+
};
|
|
1798
|
+
}
|
|
1799
|
+
/**
|
|
1800
|
+
* Serves the page that the browser prints as a PDF: one Markdown file
|
|
1801
|
+
* (`?file=<path>`), or every Markdown file under a directory in file tree
|
|
1802
|
+
* order (`?dir=<path>`, empty for the browsed directory itself).
|
|
1803
|
+
*/
|
|
1804
|
+
function createPrintRoutes(dirPath, styles, treeCache) {
|
|
1805
|
+
const app = new Hono();
|
|
1806
|
+
app.get(PRINT_PAGE_PATH, async (c) => {
|
|
1807
|
+
const file = c.req.query("file");
|
|
1808
|
+
const dir = c.req.query("dir");
|
|
1809
|
+
if (file === void 0 === (dir === void 0)) return c.text("Specify either file or dir", 400);
|
|
1810
|
+
const page = file !== void 0 ? await filePrintPage(dirPath, file) : await directoryPrintPage(dirPath, treeCache, dir ? toSlashPath(dir) : null);
|
|
1811
|
+
if (!page.ok) return c.text(page.message, page.status);
|
|
1812
|
+
return c.html(renderPrintDocument({
|
|
1813
|
+
title: page.title,
|
|
1814
|
+
styles,
|
|
1815
|
+
contents: page.contents
|
|
1816
|
+
}));
|
|
1817
|
+
});
|
|
1818
|
+
return app;
|
|
1819
|
+
}
|
|
1343
1820
|
/**
|
|
1344
1821
|
* Extensions that `/__peek/raw/` may serve, mapped to their `Content-Type`.
|
|
1345
1822
|
* Anything absent is refused, which keeps `--host 0.0.0.0` from exposing
|
|
@@ -1524,6 +2001,7 @@ function createApp(ctx, sse) {
|
|
|
1524
2001
|
treeCache: ctx.treeCache
|
|
1525
2002
|
};
|
|
1526
2003
|
app.route("/", createApiRoutes(apiConfig));
|
|
2004
|
+
app.route("/", createPrintRoutes(ctx.targetPath, ctx.styles, ctx.treeCache));
|
|
1527
2005
|
app.route("/", createDirectoryRoutes(ctx.targetPath, ctx.styles, ctx.treeCache));
|
|
1528
2006
|
}
|
|
1529
2007
|
return app;
|
|
@@ -1534,9 +2012,8 @@ function setupWatcher(ctx, sse) {
|
|
|
1534
2012
|
sse.broadcast("file-changed", JSON.stringify({}));
|
|
1535
2013
|
});
|
|
1536
2014
|
else watcher.watchDirectory(ctx.targetPath, (filePath) => {
|
|
1537
|
-
const normalizedPath = filePath.replace(/\\/g, "/");
|
|
1538
2015
|
ctx.treeCache.invalidate();
|
|
1539
|
-
sse.broadcast("file-changed", JSON.stringify({ path:
|
|
2016
|
+
sse.broadcast("file-changed", JSON.stringify({ path: toSlashPath(filePath) }));
|
|
1540
2017
|
sse.broadcast("tree-changed", JSON.stringify({}));
|
|
1541
2018
|
});
|
|
1542
2019
|
return watcher;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@makuja/peek",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
4
4
|
"description": "Markdown and HTML preview CLI with live reload",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"lint:fix": "biome check --write",
|
|
24
24
|
"format": "biome format --write",
|
|
25
25
|
"format:check": "biome format",
|
|
26
|
-
"typecheck": "tsgo",
|
|
26
|
+
"typecheck": "tsgo && tsgo -p tsconfig.client.json",
|
|
27
27
|
"test": "vitest run",
|
|
28
28
|
"test:watch": "vitest",
|
|
29
29
|
"test:coverage": "vitest run --coverage",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"engines": {
|
|
49
49
|
"node": ">=22.0.0"
|
|
50
50
|
},
|
|
51
|
-
"packageManager": "pnpm@10.34.
|
|
51
|
+
"packageManager": "pnpm@10.34.9",
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@clack/prompts": "^1.0.1",
|
|
54
54
|
"@hono/node-server": "^1.19.9",
|