@tomehq/theme 0.3.4 → 0.4.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.
Files changed (76) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/chunk-2APCPR2Y.js +2110 -0
  3. package/dist/chunk-2AXAEADQ.js +2525 -0
  4. package/dist/chunk-2WNOJXK3.js +2581 -0
  5. package/dist/chunk-37JI6XGT.js +1720 -0
  6. package/dist/chunk-3A2LPGUL.js +1991 -0
  7. package/dist/chunk-3I2QTWTW.js +1948 -0
  8. package/dist/chunk-3I4SJMER.js +2538 -0
  9. package/dist/chunk-45M5UIAB.js +2110 -0
  10. package/dist/chunk-462AGU3S.js +1959 -0
  11. package/dist/chunk-5GVQFIPI.js +2581 -0
  12. package/dist/chunk-7MUTU5D4.js +1720 -0
  13. package/dist/chunk-7NQ4IMDY.js +2294 -0
  14. package/dist/chunk-ABNPB6BB.js +2133 -0
  15. package/dist/chunk-BZGWSKT2.js +573 -0
  16. package/dist/chunk-BZIB2LMI.js +2519 -0
  17. package/dist/chunk-CMQCNCSY.js +2127 -0
  18. package/dist/chunk-CTPOZMMK.js +1703 -0
  19. package/dist/chunk-DKSQZLWR.js +2569 -0
  20. package/dist/chunk-DO544M3G.js +1702 -0
  21. package/dist/chunk-DPKZBFQP.js +1777 -0
  22. package/dist/chunk-EK7PZUEB.js +2147 -0
  23. package/dist/chunk-FMOLIHQF.js +2182 -0
  24. package/dist/chunk-FWBTK5TL.js +1444 -0
  25. package/dist/chunk-GDQIBNX5.js +1962 -0
  26. package/dist/chunk-GHQ2MODM.js +2127 -0
  27. package/dist/chunk-GR2WCRGK.js +2182 -0
  28. package/dist/chunk-H5XZVNBW.js +2291 -0
  29. package/dist/chunk-HNLKDQ64.js +2139 -0
  30. package/dist/chunk-INUMUXN5.js +2095 -0
  31. package/dist/chunk-IW3NHNOQ.js +2187 -0
  32. package/dist/chunk-JA4PMX6M.js +1500 -0
  33. package/dist/chunk-JSPFS7G5.js +2102 -0
  34. package/dist/chunk-JZRT4WNC.js +1441 -0
  35. package/dist/chunk-KQBY2JDB.js +2112 -0
  36. package/dist/chunk-LIMYFTPC.js +1468 -0
  37. package/dist/chunk-LIY62BGC.js +2519 -0
  38. package/dist/chunk-MEP7P6A7.js +1500 -0
  39. package/dist/chunk-MHYKO7KM.js +2570 -0
  40. package/dist/chunk-MSXVVBDW.js +2542 -0
  41. package/dist/chunk-NOZBIES7.js +1948 -0
  42. package/dist/chunk-O4GH3KYX.js +1712 -0
  43. package/dist/chunk-OEDJTH5F.js +2569 -0
  44. package/dist/chunk-OEXM3BEC.js +1702 -0
  45. package/dist/chunk-PGKSFQ7A.js +2459 -0
  46. package/dist/chunk-PIV6CPY2.js +2395 -0
  47. package/dist/chunk-Q7PYTVW3.js +1771 -0
  48. package/dist/chunk-QCWZYABW.js +1468 -0
  49. package/dist/chunk-RDF25WB2.js +2085 -0
  50. package/dist/chunk-RKTT3ZEX.js +1500 -0
  51. package/dist/chunk-S47BRMNQ.js +1715 -0
  52. package/dist/chunk-S4ZH5F56.js +1949 -0
  53. package/dist/chunk-SRD7NJHS.js +1949 -0
  54. package/dist/chunk-SWFYJO5H.js +2187 -0
  55. package/dist/chunk-TQDWPSTO.js +2087 -0
  56. package/dist/chunk-TTRXRPP6.js +1941 -0
  57. package/dist/chunk-UKYFJSUA.js +509 -0
  58. package/dist/chunk-VKEQHP2E.js +2133 -0
  59. package/dist/chunk-VUT2FMSI.js +1937 -0
  60. package/dist/chunk-VVCC5JHK.js +1949 -0
  61. package/dist/chunk-W732TVBK.js +1944 -0
  62. package/dist/chunk-X4VQYPKO.js +1768 -0
  63. package/dist/chunk-YX7HV4EP.js +2568 -0
  64. package/dist/chunk-YXKONM3A.js +2192 -0
  65. package/dist/chunk-YZ3P3TNS.js +1760 -0
  66. package/dist/chunk-ZVZ7JN3V.js +2568 -0
  67. package/dist/chunk-ZXW4STTN.js +2568 -0
  68. package/dist/entry.js +1 -1
  69. package/dist/index.js +1 -1
  70. package/package.json +3 -3
  71. package/src/Shell.test.tsx +25 -0
  72. package/src/Shell.tsx +8 -8
  73. package/src/entry-helpers.test.ts +60 -12
  74. package/src/entry-helpers.ts +56 -30
  75. package/src/entry.test.tsx +208 -3
  76. package/src/entry.tsx +27 -4
@@ -0,0 +1,1702 @@
1
+ // src/entry.tsx
2
+ import { useState as useState3, useEffect as useEffect3, useCallback as useCallback3 } from "react";
3
+ import { createRoot } from "react-dom/client";
4
+
5
+ // src/Shell.tsx
6
+ import { useState as useState2, useEffect as useEffect2, useRef as useRef2, useCallback as useCallback2 } from "react";
7
+
8
+ // src/presets.ts
9
+ var THEME_PRESETS = {
10
+ amber: {
11
+ dark: {
12
+ bg: "#09090b",
13
+ sf: "#111114",
14
+ sfH: "#18181c",
15
+ bd: "#1e1e24",
16
+ tx: "#e4e4e7",
17
+ tx2: "#a1a1aa",
18
+ txM: "#919199",
19
+ ac: "#e8a845",
20
+ acD: "rgba(232,168,69,0.12)",
21
+ acT: "#fbbf24",
22
+ cdBg: "#0c0c0f",
23
+ cdTx: "#c4c4cc",
24
+ sbBg: "#0c0c0e",
25
+ hdBg: "rgba(9,9,11,0.85)"
26
+ },
27
+ light: {
28
+ bg: "#fafaf9",
29
+ sf: "#ffffff",
30
+ sfH: "#f5f5f4",
31
+ bd: "#e7e5e4",
32
+ tx: "#1c1917",
33
+ tx2: "#57534e",
34
+ txM: "#706b66",
35
+ ac: "#96640a",
36
+ acD: "rgba(150,100,10,0.08)",
37
+ acT: "#7a5208",
38
+ cdBg: "#f5f3f0",
39
+ cdTx: "#2c2520",
40
+ sbBg: "#f5f5f3",
41
+ hdBg: "rgba(250,250,249,0.85)"
42
+ },
43
+ fonts: { heading: "Instrument Serif", body: "DM Sans", code: "JetBrains Mono" }
44
+ },
45
+ editorial: {
46
+ dark: {
47
+ bg: "#080c1f",
48
+ sf: "#0e1333",
49
+ sfH: "#141940",
50
+ bd: "#1a2050",
51
+ tx: "#e8e6f0",
52
+ tx2: "#b5b1c8",
53
+ txM: "#9490ae",
54
+ ac: "#ff6b4a",
55
+ acD: "rgba(255,107,74,0.1)",
56
+ acT: "#ff8a70",
57
+ cdBg: "#0a0e27",
58
+ cdTx: "#b8b4cc",
59
+ sbBg: "#0a0e27",
60
+ hdBg: "rgba(8,12,31,0.9)"
61
+ },
62
+ light: {
63
+ bg: "#f6f4f0",
64
+ sf: "#ffffff",
65
+ sfH: "#eeece6",
66
+ bd: "#ddd9d0",
67
+ tx: "#1a1716",
68
+ tx2: "#4a443e",
69
+ txM: "#706960",
70
+ ac: "#b83d22",
71
+ acD: "rgba(184,61,34,0.07)",
72
+ acT: "#9c3019",
73
+ cdBg: "#edeae4",
74
+ cdTx: "#3a3530",
75
+ sbBg: "#f0ede8",
76
+ hdBg: "rgba(246,244,240,0.92)"
77
+ },
78
+ fonts: { heading: "Cormorant Garamond", body: "Bricolage Grotesque", code: "Fira Code" }
79
+ }
80
+ };
81
+
82
+ // src/AiChat.tsx
83
+ import { useState, useRef, useEffect, useCallback } from "react";
84
+ import { jsx, jsxs } from "react/jsx-runtime";
85
+ var ChatIcon = () => /* @__PURE__ */ jsx(
86
+ "svg",
87
+ {
88
+ width: 22,
89
+ height: 22,
90
+ viewBox: "0 0 24 24",
91
+ fill: "none",
92
+ stroke: "currentColor",
93
+ strokeWidth: "1.5",
94
+ strokeLinecap: "round",
95
+ strokeLinejoin: "round",
96
+ children: /* @__PURE__ */ jsx("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" })
97
+ }
98
+ );
99
+ var CloseIcon = () => /* @__PURE__ */ jsx(
100
+ "svg",
101
+ {
102
+ width: 18,
103
+ height: 18,
104
+ viewBox: "0 0 24 24",
105
+ fill: "none",
106
+ stroke: "currentColor",
107
+ strokeWidth: "1.5",
108
+ strokeLinecap: "round",
109
+ strokeLinejoin: "round",
110
+ children: /* @__PURE__ */ jsx("path", { d: "M18 6L6 18M6 6l12 12" })
111
+ }
112
+ );
113
+ var SendIcon = () => /* @__PURE__ */ jsx(
114
+ "svg",
115
+ {
116
+ width: 16,
117
+ height: 16,
118
+ viewBox: "0 0 24 24",
119
+ fill: "none",
120
+ stroke: "currentColor",
121
+ strokeWidth: "2",
122
+ strokeLinecap: "round",
123
+ strokeLinejoin: "round",
124
+ children: /* @__PURE__ */ jsx("path", { d: "M22 2L11 13M22 2l-7 20-4-9-9-4z" })
125
+ }
126
+ );
127
+ function buildSystemPrompt(context) {
128
+ let prompt = "You are a helpful documentation assistant. Answer questions accurately based on the documentation provided below. If the answer isn't in the documentation, say so clearly. Keep answers concise and reference specific sections when possible.";
129
+ if (context) {
130
+ const trimmed = context.length > 1e5 ? context.slice(0, 1e5) + "\n\n[Documentation truncated...]" : context;
131
+ prompt += `
132
+
133
+ Documentation:
134
+ ${trimmed}`;
135
+ }
136
+ return prompt;
137
+ }
138
+ async function callOpenAI(messages, apiKey, model, context) {
139
+ const res = await fetch("https://api.openai.com/v1/chat/completions", {
140
+ method: "POST",
141
+ headers: {
142
+ "Content-Type": "application/json",
143
+ "Authorization": `Bearer ${apiKey}`
144
+ },
145
+ body: JSON.stringify({
146
+ model,
147
+ messages: [
148
+ { role: "system", content: buildSystemPrompt(context) },
149
+ ...messages.map((m) => ({ role: m.role, content: m.content }))
150
+ ]
151
+ })
152
+ });
153
+ if (!res.ok) {
154
+ const err = await res.text();
155
+ throw new Error(`OpenAI API error (${res.status}): ${err}`);
156
+ }
157
+ const data = await res.json();
158
+ return data.choices?.[0]?.message?.content || "No response.";
159
+ }
160
+ async function callAnthropic(messages, apiKey, model, context) {
161
+ const res = await fetch("https://api.anthropic.com/v1/messages", {
162
+ method: "POST",
163
+ headers: {
164
+ "Content-Type": "application/json",
165
+ "x-api-key": apiKey,
166
+ "anthropic-version": "2023-06-01",
167
+ "anthropic-dangerous-direct-browser-access": "true"
168
+ },
169
+ body: JSON.stringify({
170
+ model,
171
+ max_tokens: 1024,
172
+ system: buildSystemPrompt(context),
173
+ messages: messages.map((m) => ({ role: m.role, content: m.content }))
174
+ })
175
+ });
176
+ if (!res.ok) {
177
+ const err = await res.text();
178
+ throw new Error(`Anthropic API error (${res.status}): ${err}`);
179
+ }
180
+ const data = await res.json();
181
+ return data.content?.[0]?.text || "No response.";
182
+ }
183
+ function getDefaultModel(provider) {
184
+ if (provider === "openai") return "gpt-4o-mini";
185
+ return "claude-sonnet-4-20250514";
186
+ }
187
+ function AiChat({ provider, model, apiKey, context }) {
188
+ const [open, setOpen] = useState(false);
189
+ const [messages, setMessages] = useState([]);
190
+ const [input, setInput] = useState("");
191
+ const [loading, setLoading] = useState(false);
192
+ const [error, setError] = useState(null);
193
+ const messagesEndRef = useRef(null);
194
+ const inputRef = useRef(null);
195
+ const resolvedKey = apiKey || (typeof window !== "undefined" ? window.__TOME_AI_API_KEY__ : void 0);
196
+ const resolvedModel = model || getDefaultModel(provider);
197
+ useEffect(() => {
198
+ messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
199
+ }, [messages]);
200
+ useEffect(() => {
201
+ if (open) {
202
+ setTimeout(() => inputRef.current?.focus(), 100);
203
+ }
204
+ }, [open]);
205
+ const sendMessage = useCallback(async () => {
206
+ const text = input.trim();
207
+ if (!text || loading) return;
208
+ if (!resolvedKey) return;
209
+ const userMsg = { role: "user", content: text };
210
+ const updatedMessages = [...messages, userMsg];
211
+ setMessages(updatedMessages);
212
+ setInput("");
213
+ setLoading(true);
214
+ setError(null);
215
+ try {
216
+ let response;
217
+ if (provider === "openai") {
218
+ response = await callOpenAI(updatedMessages, resolvedKey, resolvedModel, context);
219
+ } else {
220
+ response = await callAnthropic(updatedMessages, resolvedKey, resolvedModel, context);
221
+ }
222
+ setMessages((prev) => [...prev, { role: "assistant", content: response }]);
223
+ } catch (err) {
224
+ setError(err instanceof Error ? err.message : "Failed to get response");
225
+ } finally {
226
+ setLoading(false);
227
+ }
228
+ }, [input, loading, messages, provider, resolvedKey, resolvedModel, context]);
229
+ const handleKeyDown = useCallback(
230
+ (e) => {
231
+ if (e.key === "Enter" && !e.shiftKey) {
232
+ e.preventDefault();
233
+ sendMessage();
234
+ }
235
+ },
236
+ [sendMessage]
237
+ );
238
+ if (!open) {
239
+ return /* @__PURE__ */ jsx(
240
+ "button",
241
+ {
242
+ "data-testid": "ai-chat-button",
243
+ onClick: () => setOpen(true),
244
+ "aria-label": "Open AI chat",
245
+ style: {
246
+ position: "fixed",
247
+ bottom: 24,
248
+ right: 24,
249
+ zIndex: 900,
250
+ width: 48,
251
+ height: 48,
252
+ borderRadius: "50%",
253
+ background: "var(--ac)",
254
+ color: "#fff",
255
+ border: "none",
256
+ cursor: "pointer",
257
+ display: "flex",
258
+ alignItems: "center",
259
+ justifyContent: "center",
260
+ boxShadow: "0 4px 16px rgba(0,0,0,0.25)",
261
+ transition: "transform 0.15s"
262
+ },
263
+ children: /* @__PURE__ */ jsx(ChatIcon, {})
264
+ }
265
+ );
266
+ }
267
+ return /* @__PURE__ */ jsxs(
268
+ "div",
269
+ {
270
+ "data-testid": "ai-chat-panel",
271
+ style: {
272
+ position: "fixed",
273
+ bottom: 24,
274
+ right: 24,
275
+ zIndex: 900,
276
+ width: 380,
277
+ maxWidth: "calc(100vw - 48px)",
278
+ height: 520,
279
+ maxHeight: "calc(100vh - 48px)",
280
+ background: "var(--sf)",
281
+ border: "1px solid var(--bd)",
282
+ borderRadius: 12,
283
+ boxShadow: "0 16px 64px rgba(0,0,0,0.3)",
284
+ display: "flex",
285
+ flexDirection: "column",
286
+ overflow: "hidden",
287
+ fontFamily: "var(--font-body)"
288
+ },
289
+ children: [
290
+ /* @__PURE__ */ jsxs(
291
+ "div",
292
+ {
293
+ style: {
294
+ display: "flex",
295
+ alignItems: "center",
296
+ justifyContent: "space-between",
297
+ padding: "12px 16px",
298
+ borderBottom: "1px solid var(--bd)",
299
+ flexShrink: 0
300
+ },
301
+ children: [
302
+ /* @__PURE__ */ jsx(
303
+ "span",
304
+ {
305
+ style: {
306
+ fontSize: 14,
307
+ fontWeight: 600,
308
+ color: "var(--tx)"
309
+ },
310
+ children: "Ask AI"
311
+ }
312
+ ),
313
+ /* @__PURE__ */ jsx(
314
+ "button",
315
+ {
316
+ "data-testid": "ai-chat-close",
317
+ onClick: () => setOpen(false),
318
+ "aria-label": "Close AI chat",
319
+ style: {
320
+ background: "none",
321
+ border: "none",
322
+ color: "var(--txM)",
323
+ cursor: "pointer",
324
+ display: "flex",
325
+ padding: 4
326
+ },
327
+ children: /* @__PURE__ */ jsx(CloseIcon, {})
328
+ }
329
+ )
330
+ ]
331
+ }
332
+ ),
333
+ /* @__PURE__ */ jsxs(
334
+ "div",
335
+ {
336
+ style: {
337
+ flex: 1,
338
+ overflow: "auto",
339
+ padding: "12px 16px"
340
+ },
341
+ children: [
342
+ !resolvedKey && /* @__PURE__ */ jsxs(
343
+ "div",
344
+ {
345
+ "data-testid": "ai-chat-no-key",
346
+ style: {
347
+ textAlign: "center",
348
+ color: "var(--txM)",
349
+ fontSize: 13,
350
+ padding: "24px 8px",
351
+ lineHeight: 1.6
352
+ },
353
+ children: [
354
+ /* @__PURE__ */ jsx("p", { style: { marginBottom: 8, fontWeight: 500, color: "var(--tx)" }, children: "AI not configured" }),
355
+ /* @__PURE__ */ jsxs("p", { style: { marginBottom: 8 }, children: [
356
+ "To enable AI chat, set the ",
357
+ /* @__PURE__ */ jsx("code", { style: {
358
+ fontFamily: "var(--font-code)",
359
+ fontSize: "0.88em",
360
+ background: "var(--cdBg)",
361
+ padding: "0.15em 0.4em",
362
+ borderRadius: 4
363
+ }, children: "apiKeyEnv" }),
364
+ " in ",
365
+ /* @__PURE__ */ jsx("code", { style: {
366
+ fontFamily: "var(--font-code)",
367
+ fontSize: "0.88em",
368
+ background: "var(--cdBg)",
369
+ padding: "0.15em 0.4em",
370
+ borderRadius: 4
371
+ }, children: "tome.config.js" }),
372
+ " and provide the environment variable at build time."
373
+ ] }),
374
+ /* @__PURE__ */ jsxs("p", { style: { fontSize: 11.5, color: "var(--txM)" }, children: [
375
+ "Example: ",
376
+ /* @__PURE__ */ jsx("code", { style: {
377
+ fontFamily: "var(--font-code)",
378
+ fontSize: "0.88em",
379
+ background: "var(--cdBg)",
380
+ padding: "0.15em 0.4em",
381
+ borderRadius: 4
382
+ }, children: "TOME_AI_KEY=sk-... tome build" })
383
+ ] })
384
+ ]
385
+ }
386
+ ),
387
+ messages.map((msg, i) => /* @__PURE__ */ jsx(
388
+ "div",
389
+ {
390
+ "data-testid": `ai-chat-message-${msg.role}`,
391
+ style: {
392
+ marginBottom: 12,
393
+ display: "flex",
394
+ justifyContent: msg.role === "user" ? "flex-end" : "flex-start"
395
+ },
396
+ children: /* @__PURE__ */ jsx(
397
+ "div",
398
+ {
399
+ style: {
400
+ maxWidth: "85%",
401
+ padding: "8px 12px",
402
+ borderRadius: 10,
403
+ fontSize: 13,
404
+ lineHeight: 1.55,
405
+ whiteSpace: "pre-wrap",
406
+ wordBreak: "break-word",
407
+ background: msg.role === "user" ? "var(--ac)" : "var(--cdBg)",
408
+ color: msg.role === "user" ? "#fff" : "var(--tx)"
409
+ },
410
+ children: msg.content
411
+ }
412
+ )
413
+ },
414
+ i
415
+ )),
416
+ loading && /* @__PURE__ */ jsx(
417
+ "div",
418
+ {
419
+ "data-testid": "ai-chat-loading",
420
+ style: {
421
+ display: "flex",
422
+ justifyContent: "flex-start",
423
+ marginBottom: 12
424
+ },
425
+ children: /* @__PURE__ */ jsx(
426
+ "div",
427
+ {
428
+ style: {
429
+ padding: "8px 12px",
430
+ borderRadius: 10,
431
+ fontSize: 13,
432
+ background: "var(--cdBg)",
433
+ color: "var(--txM)"
434
+ },
435
+ children: "Thinking..."
436
+ }
437
+ )
438
+ }
439
+ ),
440
+ error && /* @__PURE__ */ jsx(
441
+ "div",
442
+ {
443
+ "data-testid": "ai-chat-error",
444
+ style: {
445
+ padding: "8px 12px",
446
+ borderRadius: 8,
447
+ fontSize: 12,
448
+ background: "rgba(220,50,50,0.1)",
449
+ color: "#d44",
450
+ marginBottom: 12
451
+ },
452
+ children: error
453
+ }
454
+ ),
455
+ /* @__PURE__ */ jsx("div", { ref: messagesEndRef })
456
+ ]
457
+ }
458
+ ),
459
+ /* @__PURE__ */ jsxs(
460
+ "div",
461
+ {
462
+ style: {
463
+ display: "flex",
464
+ alignItems: "center",
465
+ gap: 8,
466
+ padding: "10px 12px",
467
+ borderTop: "1px solid var(--bd)",
468
+ flexShrink: 0
469
+ },
470
+ children: [
471
+ /* @__PURE__ */ jsx(
472
+ "input",
473
+ {
474
+ ref: inputRef,
475
+ "data-testid": "ai-chat-input",
476
+ value: input,
477
+ onChange: (e) => setInput(e.target.value),
478
+ onKeyDown: handleKeyDown,
479
+ placeholder: resolvedKey ? "Ask a question..." : "API key required",
480
+ disabled: !resolvedKey,
481
+ style: {
482
+ flex: 1,
483
+ background: "var(--cdBg)",
484
+ border: "1px solid var(--bd)",
485
+ borderRadius: 8,
486
+ padding: "8px 12px",
487
+ color: "var(--tx)",
488
+ fontSize: 13,
489
+ fontFamily: "var(--font-body)",
490
+ outline: "none"
491
+ }
492
+ }
493
+ ),
494
+ /* @__PURE__ */ jsx(
495
+ "button",
496
+ {
497
+ "data-testid": "ai-chat-send",
498
+ onClick: sendMessage,
499
+ disabled: !resolvedKey || !input.trim() || loading,
500
+ "aria-label": "Send message",
501
+ style: {
502
+ width: 34,
503
+ height: 34,
504
+ borderRadius: 8,
505
+ background: resolvedKey && input.trim() ? "var(--ac)" : "var(--cdBg)",
506
+ color: resolvedKey && input.trim() ? "#fff" : "var(--txM)",
507
+ border: "none",
508
+ cursor: resolvedKey && input.trim() ? "pointer" : "default",
509
+ display: "flex",
510
+ alignItems: "center",
511
+ justifyContent: "center",
512
+ flexShrink: 0
513
+ },
514
+ children: /* @__PURE__ */ jsx(SendIcon, {})
515
+ }
516
+ )
517
+ ]
518
+ }
519
+ )
520
+ ]
521
+ }
522
+ );
523
+ }
524
+
525
+ // src/Shell.tsx
526
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
527
+ function hexToRgb(hex) {
528
+ const m = /^#([0-9a-f]{6})$/i.exec(hex.trim());
529
+ if (!m) return null;
530
+ const n = parseInt(m[1], 16);
531
+ return [n >> 16 & 255, n >> 8 & 255, n & 255];
532
+ }
533
+ function buildAccentOverride(hex, isDark) {
534
+ const rgb = hexToRgb(hex);
535
+ if (!rgb) return null;
536
+ const [r, g, b] = rgb;
537
+ const acD = `rgba(${r},${g},${b},${isDark ? 0.12 : 0.08})`;
538
+ const factor = isDark ? 1.15 : 0.85;
539
+ const tr = Math.min(255, Math.round(r * factor));
540
+ const tg = Math.min(255, Math.round(g * factor));
541
+ const tb = Math.min(255, Math.round(b * factor));
542
+ const acT = `rgb(${tr},${tg},${tb})`;
543
+ return { ac: hex, acD, acT };
544
+ }
545
+ var Icon = ({ d, size = 16 }) => /* @__PURE__ */ jsx2(
546
+ "svg",
547
+ {
548
+ width: size,
549
+ height: size,
550
+ viewBox: "0 0 24 24",
551
+ fill: "none",
552
+ stroke: "currentColor",
553
+ strokeWidth: "1.5",
554
+ strokeLinecap: "round",
555
+ strokeLinejoin: "round",
556
+ children: /* @__PURE__ */ jsx2("path", { d })
557
+ }
558
+ );
559
+ var SearchIcon = () => /* @__PURE__ */ jsx2(Icon, { d: "M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16ZM21 21l-4.3-4.3" });
560
+ var ChevRight = () => /* @__PURE__ */ jsx2(Icon, { d: "M9 18l6-6-6-6", size: 14 });
561
+ var ChevDown = () => /* @__PURE__ */ jsx2(Icon, { d: "M6 9l6 6 6-6", size: 14 });
562
+ var MenuIcon = () => /* @__PURE__ */ jsx2(Icon, { d: "M3 12h18M3 6h18M3 18h18", size: 20 });
563
+ var XIcon = () => /* @__PURE__ */ jsx2(Icon, { d: "M18 6L6 18M6 6l12 12", size: 18 });
564
+ var MoonIcon = () => /* @__PURE__ */ jsx2(Icon, { d: "M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" });
565
+ var SunIcon = () => /* @__PURE__ */ jsx2(Icon, { d: "M12 7a5 5 0 1 0 0 10 5 5 0 0 0 0-10Z" });
566
+ var ArrowLeft = () => /* @__PURE__ */ jsx2(Icon, { d: "M19 12H5M12 19l-7-7 7-7", size: 14 });
567
+ var ArrowRight = () => /* @__PURE__ */ jsx2(Icon, { d: "M5 12h14M12 5l7 7-7 7", size: 14 });
568
+ var PencilIcon = () => /* @__PURE__ */ jsx2(Icon, { d: "M17 3a2.83 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z", size: 13 });
569
+ function formatRelativeDate(isoDate) {
570
+ const date = new Date(isoDate);
571
+ const now = /* @__PURE__ */ new Date();
572
+ const diffMs = now.getTime() - date.getTime();
573
+ if (isNaN(diffMs)) return "";
574
+ const seconds = Math.floor(diffMs / 1e3);
575
+ const minutes = Math.floor(seconds / 60);
576
+ const hours = Math.floor(minutes / 60);
577
+ const days = Math.floor(hours / 24);
578
+ const months = Math.floor(days / 30);
579
+ const years = Math.floor(days / 365);
580
+ if (seconds < 60) return "just now";
581
+ if (minutes < 60) return `${minutes} minute${minutes === 1 ? "" : "s"} ago`;
582
+ if (hours < 24) return `${hours} hour${hours === 1 ? "" : "s"} ago`;
583
+ if (days < 30) return `${days} day${days === 1 ? "" : "s"} ago`;
584
+ if (months < 12) return `${months} month${months === 1 ? "" : "s"} ago`;
585
+ if (years >= 1) return `${years} year${years === 1 ? "" : "s"} ago`;
586
+ return date.toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric" });
587
+ }
588
+ var pagefindInstance = null;
589
+ var PAGEFIND_PATH = "/_pagefind/pagefind.js";
590
+ async function initPagefind() {
591
+ if (pagefindInstance) return pagefindInstance;
592
+ try {
593
+ pagefindInstance = await import(
594
+ /* @vite-ignore */
595
+ PAGEFIND_PATH
596
+ );
597
+ await pagefindInstance.init();
598
+ return pagefindInstance;
599
+ } catch {
600
+ return null;
601
+ }
602
+ }
603
+ var docSearchLoaded = null;
604
+ function loadDocSearch() {
605
+ if (docSearchLoaded) return docSearchLoaded;
606
+ docSearchLoaded = import("@docsearch/react").catch(() => null);
607
+ return docSearchLoaded;
608
+ }
609
+ function AlgoliaSearchModal({
610
+ appId,
611
+ apiKey,
612
+ indexName,
613
+ onNavigate,
614
+ onClose
615
+ }) {
616
+ const [DocSearchComponent, setDocSearchComponent] = useState2(null);
617
+ const [loadFailed, setLoadFailed] = useState2(false);
618
+ useEffect2(() => {
619
+ loadDocSearch().then((mod) => {
620
+ if (mod && mod.DocSearch) {
621
+ setDocSearchComponent(() => mod.DocSearch);
622
+ } else if (mod && mod.default) {
623
+ setDocSearchComponent(() => mod.default);
624
+ } else {
625
+ setLoadFailed(true);
626
+ }
627
+ });
628
+ }, []);
629
+ const extractPageId = useCallback2((url) => {
630
+ try {
631
+ const parsed = new URL(url, "http://localhost");
632
+ const pathname = parsed.pathname;
633
+ return pathname.replace(/^\//, "").replace(/\/index\.html$/, "").replace(/\.html$/, "") || "index";
634
+ } catch {
635
+ return "index";
636
+ }
637
+ }, []);
638
+ if (loadFailed) {
639
+ return /* @__PURE__ */ jsx2("div", { onClick: onClose, style: {
640
+ position: "fixed",
641
+ inset: 0,
642
+ zIndex: 1e3,
643
+ background: "rgba(0,0,0,0.55)",
644
+ backdropFilter: "blur(6px)",
645
+ display: "flex",
646
+ alignItems: "flex-start",
647
+ justifyContent: "center",
648
+ paddingTop: "12vh"
649
+ }, children: /* @__PURE__ */ jsx2("div", { onClick: (e) => e.stopPropagation(), style: {
650
+ background: "var(--sf)",
651
+ border: "1px solid var(--bd)",
652
+ borderRadius: 12,
653
+ width: "100%",
654
+ maxWidth: 520,
655
+ boxShadow: "0 24px 80px rgba(0,0,0,0.4)",
656
+ padding: "32px 18px",
657
+ textAlign: "center",
658
+ color: "var(--txM)",
659
+ fontSize: 14
660
+ }, children: "Algolia DocSearch is not available. Install @docsearch/react to enable it." }) });
661
+ }
662
+ if (!DocSearchComponent) {
663
+ return /* @__PURE__ */ jsx2("div", { onClick: onClose, style: {
664
+ position: "fixed",
665
+ inset: 0,
666
+ zIndex: 1e3,
667
+ background: "rgba(0,0,0,0.55)",
668
+ backdropFilter: "blur(6px)",
669
+ display: "flex",
670
+ alignItems: "flex-start",
671
+ justifyContent: "center",
672
+ paddingTop: "12vh"
673
+ }, children: /* @__PURE__ */ jsx2("div", { style: {
674
+ background: "var(--sf)",
675
+ border: "1px solid var(--bd)",
676
+ borderRadius: 12,
677
+ width: "100%",
678
+ maxWidth: 520,
679
+ boxShadow: "0 24px 80px rgba(0,0,0,0.4)",
680
+ padding: "32px 18px",
681
+ textAlign: "center",
682
+ color: "var(--txM)",
683
+ fontSize: 14
684
+ }, children: "Loading search..." }) });
685
+ }
686
+ return /* @__PURE__ */ jsx2("div", { "data-testid": "algolia-search-modal", children: /* @__PURE__ */ jsx2(
687
+ DocSearchComponent,
688
+ {
689
+ appId,
690
+ apiKey,
691
+ indexName,
692
+ navigator: {
693
+ navigate({ itemUrl }) {
694
+ const pageId = extractPageId(itemUrl);
695
+ onNavigate(pageId);
696
+ }
697
+ },
698
+ hitComponent: ({ hit, children }) => /* @__PURE__ */ jsx2("a", { href: hit.url, onClick: (e) => {
699
+ e.preventDefault();
700
+ const pageId = extractPageId(hit.url);
701
+ onNavigate(pageId);
702
+ }, children })
703
+ }
704
+ ) });
705
+ }
706
+ var VersionIcon = () => /* @__PURE__ */ jsx2(Icon, { d: "M12 8v4l3 3m6-3a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z", size: 14 });
707
+ var GlobeIcon = () => /* @__PURE__ */ jsx2(Icon, { d: "M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18ZM3.6 9h16.8M3.6 15h16.8M12 3a15 15 0 0 1 4 9 15 15 0 0 1-4 9 15 15 0 0 1-4-9 15 15 0 0 1 4-9Z", size: 14 });
708
+ var ExtLinkIcon = () => /* @__PURE__ */ jsx2(Icon, { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6M15 3h6v6M10 14L21 3", size: 11 });
709
+ var CHANGELOG_SECTION_COLORS = {
710
+ Added: "#22c55e",
711
+ Changed: "#3b82f6",
712
+ Deprecated: "#f59e0b",
713
+ Removed: "#ef4444",
714
+ Fixed: "#8b5cf6",
715
+ Security: "#f97316"
716
+ };
717
+ function ChangelogView({ entries }) {
718
+ const [showAll, setShowAll] = useState2(entries.length <= 5);
719
+ const visible = showAll ? entries : entries.slice(0, 5);
720
+ return /* @__PURE__ */ jsxs2("div", { "data-testid": "changelog-timeline", style: { position: "relative" }, children: [
721
+ /* @__PURE__ */ jsx2("div", { style: { position: "absolute", left: 15, top: 8, bottom: 8, width: 2, background: "var(--bd)" } }),
722
+ visible.map((entry, i) => /* @__PURE__ */ jsxs2(
723
+ "div",
724
+ {
725
+ "data-testid": `changelog-entry-${entry.version}`,
726
+ style: { position: "relative", paddingLeft: 44, paddingBottom: i < visible.length - 1 ? 32 : 0 },
727
+ children: [
728
+ /* @__PURE__ */ jsx2("div", { style: {
729
+ position: "absolute",
730
+ left: 8,
731
+ top: 6,
732
+ width: 16,
733
+ height: 16,
734
+ borderRadius: "50%",
735
+ background: entry.version === "Unreleased" ? "var(--txM)" : "var(--ac)",
736
+ border: "3px solid var(--bg, #1a1a1a)"
737
+ } }),
738
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "baseline", gap: 12, marginBottom: 12 }, children: [
739
+ /* @__PURE__ */ jsx2("span", { style: { fontSize: 18, fontWeight: 700, color: "var(--tx)", fontFamily: "var(--font-heading, inherit)" }, children: entry.url ? /* @__PURE__ */ jsx2("a", { href: entry.url, target: "_blank", rel: "noopener noreferrer", style: { color: "inherit", textDecoration: "none" }, children: entry.version }) : entry.version }),
740
+ entry.date && /* @__PURE__ */ jsx2("span", { style: { fontSize: 13, color: "var(--txM)", fontFamily: "var(--font-code, monospace)" }, children: entry.date })
741
+ ] }),
742
+ entry.sections.map((section) => {
743
+ const sColor = CHANGELOG_SECTION_COLORS[section.type] || "#6b7280";
744
+ return /* @__PURE__ */ jsxs2("div", { style: { marginBottom: 16 }, children: [
745
+ /* @__PURE__ */ jsxs2("div", { style: { display: "inline-flex", alignItems: "center", gap: 6, marginBottom: 8 }, children: [
746
+ /* @__PURE__ */ jsx2("span", { style: { display: "inline-block", width: 8, height: 8, borderRadius: "50%", background: sColor } }),
747
+ /* @__PURE__ */ jsx2("span", { style: { fontSize: 12, fontWeight: 600, textTransform: "uppercase", letterSpacing: ".06em", color: sColor, fontFamily: "var(--font-code, monospace)" }, children: section.type })
748
+ ] }),
749
+ /* @__PURE__ */ jsx2("ul", { style: { margin: 0, paddingLeft: 18, listStyleType: "disc", color: "var(--tx2)" }, children: section.items.map((item, j) => /* @__PURE__ */ jsx2("li", { style: { fontSize: 14, lineHeight: 1.7, color: "var(--tx2)", marginBottom: 2 }, children: item }, j)) })
750
+ ] }, section.type);
751
+ })
752
+ ]
753
+ },
754
+ entry.version
755
+ )),
756
+ !showAll && entries.length > 5 && /* @__PURE__ */ jsx2("div", { style: { textAlign: "center", marginTop: 24 }, children: /* @__PURE__ */ jsxs2(
757
+ "button",
758
+ {
759
+ "data-testid": "changelog-show-more",
760
+ onClick: () => setShowAll(true),
761
+ style: { background: "none", border: "1px solid var(--bd)", borderRadius: 2, padding: "8px 20px", color: "var(--tx2)", fontSize: 13, fontFamily: "var(--font-body, inherit)", cursor: "pointer" },
762
+ children: [
763
+ "Show all ",
764
+ entries.length,
765
+ " releases"
766
+ ]
767
+ }
768
+ ) })
769
+ ] });
770
+ }
771
+ function Shell({
772
+ config: config2,
773
+ navigation: navigation2,
774
+ currentPageId,
775
+ pageHtml,
776
+ pageComponent,
777
+ mdxComponents,
778
+ pageTitle,
779
+ pageDescription,
780
+ headings,
781
+ tocEnabled = true,
782
+ editUrl,
783
+ lastUpdated,
784
+ changelogEntries,
785
+ onNavigate,
786
+ allPages,
787
+ versioning,
788
+ currentVersion,
789
+ i18n,
790
+ currentLocale,
791
+ docContext: docContext2
792
+ }) {
793
+ const themeMode = config2.theme?.mode || "auto";
794
+ const [isDark, setDark] = useState2(() => {
795
+ if (themeMode === "dark") return true;
796
+ if (themeMode === "light") return false;
797
+ return window.matchMedia?.("(prefers-color-scheme: dark)").matches ?? true;
798
+ });
799
+ const [sbOpen, setSb] = useState2(true);
800
+ const [searchOpen, setSearch] = useState2(false);
801
+ const [versionDropdownOpen, setVersionDropdown] = useState2(false);
802
+ const [localeDropdownOpen, setLocaleDropdown] = useState2(false);
803
+ const isOldVersion = versioning && currentVersion && currentVersion !== versioning.current;
804
+ const [expanded, setExpanded] = useState2(navigation2.map((n) => n.section));
805
+ const contentRef = useRef2(null);
806
+ const [wide, setWide] = useState2(true);
807
+ const preset = config2.theme?.preset || "amber";
808
+ const baseTokens = THEME_PRESETS[preset]?.[isDark ? "dark" : "light"] || THEME_PRESETS.amber.dark;
809
+ const accentOverride = config2.theme?.accent ? buildAccentOverride(config2.theme.accent, isDark) : null;
810
+ const t = accentOverride ? { ...baseTokens, ...accentOverride } : baseTokens;
811
+ const presetFonts = THEME_PRESETS[preset]?.fonts || THEME_PRESETS.amber.fonts;
812
+ const fonts = {
813
+ heading: config2.theme?.fonts?.heading || presetFonts.heading,
814
+ body: config2.theme?.fonts?.body || presetFonts.body,
815
+ code: config2.theme?.fonts?.code || presetFonts.code
816
+ };
817
+ useEffect2(() => {
818
+ if (themeMode !== "auto") return;
819
+ const mq = window.matchMedia("(prefers-color-scheme: dark)");
820
+ const handler = (e) => setDark(e.matches);
821
+ mq.addEventListener("change", handler);
822
+ return () => mq.removeEventListener("change", handler);
823
+ }, [themeMode]);
824
+ useEffect2(() => {
825
+ const c = () => setWide(window.innerWidth > 1100);
826
+ c();
827
+ window.addEventListener("resize", c);
828
+ return () => window.removeEventListener("resize", c);
829
+ }, []);
830
+ useEffect2(() => {
831
+ contentRef.current?.scrollTo(0, 0);
832
+ }, [currentPageId]);
833
+ const tocConfig = config2.toc;
834
+ const tocDepth = tocConfig?.depth ?? 3;
835
+ const tocGlobalEnabled = tocConfig?.enabled !== false;
836
+ const showToc = tocGlobalEnabled && tocEnabled;
837
+ const filteredHeadings = headings.filter((h) => h.depth <= tocDepth);
838
+ const [activeHeadingId, setActiveHeadingId] = useState2("");
839
+ useEffect2(() => {
840
+ if (!showToc || filteredHeadings.length < 2) return;
841
+ const scrollRoot = contentRef.current;
842
+ if (!scrollRoot) return;
843
+ const timerId = setTimeout(() => {
844
+ const headingElements = [];
845
+ for (const h of filteredHeadings) {
846
+ const el = scrollRoot.querySelector(`#${CSS.escape(h.id)}`);
847
+ if (el) headingElements.push(el);
848
+ }
849
+ if (headingElements.length === 0) return;
850
+ const observer = new IntersectionObserver(
851
+ (entries) => {
852
+ const visible = entries.filter((e) => e.isIntersecting).sort((a, b) => a.boundingClientRect.top - b.boundingClientRect.top);
853
+ if (visible.length > 0) {
854
+ setActiveHeadingId(visible[0].target.id);
855
+ }
856
+ },
857
+ {
858
+ root: scrollRoot,
859
+ // Trigger when heading enters the top 20% of the scroll container
860
+ rootMargin: "0px 0px -80% 0px",
861
+ threshold: 0
862
+ }
863
+ );
864
+ for (const el of headingElements) observer.observe(el);
865
+ observerRef.current = observer;
866
+ }, 100);
867
+ return () => {
868
+ clearTimeout(timerId);
869
+ observerRef.current?.disconnect();
870
+ observerRef.current = null;
871
+ };
872
+ }, [currentPageId, showToc, filteredHeadings.map((h) => h.id).join(",")]);
873
+ const observerRef = useRef2(null);
874
+ useEffect2(() => {
875
+ setActiveHeadingId("");
876
+ }, [currentPageId]);
877
+ const scrollToHeading = useCallback2((e, id) => {
878
+ e.preventDefault();
879
+ const scrollRoot = contentRef.current;
880
+ if (!scrollRoot) return;
881
+ const target = scrollRoot.querySelector(`#${CSS.escape(id)}`);
882
+ if (target) {
883
+ target.scrollIntoView({ behavior: "smooth", block: "start" });
884
+ setActiveHeadingId(id);
885
+ }
886
+ }, []);
887
+ useEffect2(() => {
888
+ const h = (e) => {
889
+ if ((e.metaKey || e.ctrlKey) && e.key === "k") {
890
+ e.preventDefault();
891
+ setSearch(true);
892
+ }
893
+ if (e.key === "Escape") setSearch(false);
894
+ };
895
+ window.addEventListener("keydown", h);
896
+ return () => window.removeEventListener("keydown", h);
897
+ }, []);
898
+ const allNavPages = navigation2.flatMap((g) => g.pages);
899
+ const idx = allNavPages.findIndex((p) => p.id === currentPageId);
900
+ const prev = idx > 0 ? allNavPages[idx - 1] : null;
901
+ const next = idx < allNavPages.length - 1 ? allNavPages[idx + 1] : null;
902
+ const togSec = (s) => setExpanded((p) => p.includes(s) ? p.filter((x) => x !== s) : [...p, s]);
903
+ const cssVars = {
904
+ "--bg": t.bg,
905
+ "--sf": t.sf,
906
+ "--sfH": t.sfH,
907
+ "--bd": t.bd,
908
+ "--tx": t.tx,
909
+ "--tx2": t.tx2,
910
+ "--txM": t.txM,
911
+ "--ac": t.ac,
912
+ "--acD": t.acD,
913
+ "--acT": t.acT,
914
+ "--cdBg": t.cdBg,
915
+ "--cdTx": t.cdTx,
916
+ "--sbBg": t.sbBg,
917
+ "--hdBg": t.hdBg,
918
+ "--font-heading": `"${fonts.heading}", serif`,
919
+ "--font-body": `"${fonts.body}", sans-serif`,
920
+ "--font-code": `"${fonts.code}", monospace`
921
+ };
922
+ const PageComponent = pageComponent;
923
+ return /* @__PURE__ */ jsxs2("div", { className: "tome-grain", style: { ...cssVars, color: "var(--tx)", background: "var(--bg)", fontFamily: "var(--font-body)", minHeight: "100vh" }, children: [
924
+ searchOpen && config2.search?.provider === "algolia" && config2.search.appId && config2.search.apiKey && config2.search.indexName ? /* @__PURE__ */ jsx2(
925
+ AlgoliaSearchModal,
926
+ {
927
+ appId: config2.search.appId,
928
+ apiKey: config2.search.apiKey,
929
+ indexName: config2.search.indexName,
930
+ onNavigate: (id) => {
931
+ onNavigate(id);
932
+ setSearch(false);
933
+ },
934
+ onClose: () => setSearch(false)
935
+ }
936
+ ) : searchOpen ? /* @__PURE__ */ jsx2(
937
+ SearchModal,
938
+ {
939
+ allPages,
940
+ onNavigate: (id) => {
941
+ onNavigate(id);
942
+ setSearch(false);
943
+ },
944
+ onClose: () => setSearch(false)
945
+ }
946
+ ) : null,
947
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", height: "100vh" }, children: [
948
+ /* @__PURE__ */ jsxs2("aside", { style: {
949
+ width: sbOpen ? 270 : 0,
950
+ minWidth: sbOpen ? 270 : 0,
951
+ background: "var(--sbBg)",
952
+ borderRight: "1px solid var(--bd)",
953
+ display: "flex",
954
+ flexDirection: "column",
955
+ transition: "width .2s, min-width .2s",
956
+ overflow: "hidden"
957
+ }, children: [
958
+ /* @__PURE__ */ jsxs2("a", { href: "/", style: { padding: "18px 20px", display: "flex", alignItems: "baseline", gap: 6, borderBottom: "1px solid var(--bd)", textDecoration: "none", color: "inherit" }, children: [
959
+ /* @__PURE__ */ jsx2("span", { style: { fontFamily: "var(--font-heading)", fontSize: 22, fontWeight: 700, fontStyle: "italic" }, children: config2.name }),
960
+ /* @__PURE__ */ jsx2("span", { style: { width: 5, height: 5, borderRadius: "50%", background: "var(--ac)", display: "inline-block" } })
961
+ ] }),
962
+ /* @__PURE__ */ jsx2("div", { style: { padding: "12px 14px" }, children: /* @__PURE__ */ jsxs2("button", { onClick: () => setSearch(true), style: {
963
+ display: "flex",
964
+ alignItems: "center",
965
+ gap: 8,
966
+ width: "100%",
967
+ background: "var(--cdBg)",
968
+ border: "1px solid var(--bd)",
969
+ borderRadius: 2,
970
+ padding: "8px 12px",
971
+ cursor: "pointer",
972
+ color: "var(--txM)",
973
+ fontSize: 12.5,
974
+ fontFamily: "var(--font-body)"
975
+ }, children: [
976
+ /* @__PURE__ */ jsx2(SearchIcon, {}),
977
+ /* @__PURE__ */ jsx2("span", { style: { flex: 1, textAlign: "left" }, children: "Search..." }),
978
+ /* @__PURE__ */ jsx2("kbd", { style: { fontFamily: "var(--font-code)", fontSize: 9, background: "var(--sf)", border: "1px solid var(--bd)", borderRadius: 2, padding: "2px 6px" }, children: "\u2318K" })
979
+ ] }) }),
980
+ /* @__PURE__ */ jsx2("nav", { style: { flex: 1, overflow: "auto", padding: "4px 10px 20px" }, children: navigation2.map((sec) => /* @__PURE__ */ jsxs2("div", { style: { marginBottom: 8 }, children: [
981
+ /* @__PURE__ */ jsxs2("button", { onClick: () => togSec(sec.section), style: {
982
+ display: "flex",
983
+ alignItems: "center",
984
+ gap: 6,
985
+ width: "100%",
986
+ background: "none",
987
+ border: "none",
988
+ padding: "8px 10px",
989
+ cursor: "pointer",
990
+ borderRadius: 2,
991
+ color: "var(--txM)",
992
+ fontSize: 10,
993
+ fontWeight: 600,
994
+ textTransform: "uppercase",
995
+ letterSpacing: ".1em",
996
+ fontFamily: "var(--font-code)"
997
+ }, children: [
998
+ expanded.includes(sec.section) ? /* @__PURE__ */ jsx2(ChevDown, {}) : /* @__PURE__ */ jsx2(ChevRight, {}),
999
+ sec.section
1000
+ ] }),
1001
+ expanded.includes(sec.section) && /* @__PURE__ */ jsx2("div", { style: { marginLeft: 8, borderLeft: "1px solid var(--bd)", paddingLeft: 0 }, children: sec.pages.map((p) => {
1002
+ const active = currentPageId === p.id;
1003
+ return /* @__PURE__ */ jsx2("button", { onClick: () => onNavigate(p.id), style: {
1004
+ display: "flex",
1005
+ alignItems: "center",
1006
+ gap: 10,
1007
+ width: "100%",
1008
+ textAlign: "left",
1009
+ background: "none",
1010
+ border: "none",
1011
+ borderRadius: 0,
1012
+ borderLeft: active ? "2px solid var(--ac)" : "2px solid transparent",
1013
+ padding: "7px 14px",
1014
+ cursor: "pointer",
1015
+ color: active ? "var(--ac)" : "var(--tx2)",
1016
+ fontSize: 13,
1017
+ fontWeight: active ? 500 : 400,
1018
+ fontFamily: "var(--font-body)",
1019
+ transition: "all .12s"
1020
+ }, children: p.title }, p.id);
1021
+ }) })
1022
+ ] }, sec.section)) }),
1023
+ /* @__PURE__ */ jsxs2("div", { style: { padding: "12px 16px", borderTop: "1px solid var(--bd)", display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
1024
+ themeMode === "auto" ? /* @__PURE__ */ jsx2("button", { onClick: () => setDark((d) => !d), style: { background: "none", border: "none", color: "var(--txM)", cursor: "pointer", display: "flex" }, children: isDark ? /* @__PURE__ */ jsx2(SunIcon, {}) : /* @__PURE__ */ jsx2(MoonIcon, {}) }) : /* @__PURE__ */ jsx2("div", {}),
1025
+ /* @__PURE__ */ jsx2("span", { style: { fontFamily: "var(--font-code)", fontSize: 10, color: "var(--txM)" }, children: typeof __TOME_VERSION__ !== "undefined" && __TOME_VERSION__ ? `v${__TOME_VERSION__}` : "v0.1.0" })
1026
+ ] })
1027
+ ] }),
1028
+ /* @__PURE__ */ jsxs2("div", { style: { flex: 1, display: "flex", flexDirection: "column", overflow: "hidden" }, children: [
1029
+ /* @__PURE__ */ jsxs2("header", { style: {
1030
+ display: "flex",
1031
+ alignItems: "center",
1032
+ gap: 12,
1033
+ padding: "10px 24px",
1034
+ borderBottom: "1px solid var(--bd)",
1035
+ background: "var(--hdBg)",
1036
+ backdropFilter: "blur(12px)"
1037
+ }, children: [
1038
+ /* @__PURE__ */ jsx2("button", { onClick: () => setSb(!sbOpen), style: { background: "none", border: "none", color: "var(--txM)", cursor: "pointer", display: "flex" }, children: sbOpen ? /* @__PURE__ */ jsx2(XIcon, {}) : /* @__PURE__ */ jsx2(MenuIcon, {}) }),
1039
+ /* @__PURE__ */ jsx2("div", { style: { display: "flex", alignItems: "center", gap: 8, fontFamily: "var(--font-code)", fontSize: 11, color: "var(--txM)", letterSpacing: ".03em", flex: 1 }, children: navigation2.map((s) => {
1040
+ const f = s.pages.find((p) => p.id === currentPageId);
1041
+ if (!f) return null;
1042
+ return /* @__PURE__ */ jsxs2("span", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
1043
+ /* @__PURE__ */ jsx2("span", { children: s.section }),
1044
+ /* @__PURE__ */ jsx2(ChevRight, {}),
1045
+ /* @__PURE__ */ jsx2("span", { style: { color: "var(--ac)" }, children: f.title })
1046
+ ] }, s.section);
1047
+ }) }),
1048
+ config2.topNav && config2.topNav.length > 0 && /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", gap: 12 }, children: [
1049
+ config2.topNav.map((link) => {
1050
+ const isExternal = link.href.startsWith("http") || !link.href.startsWith("#");
1051
+ return /* @__PURE__ */ jsxs2(
1052
+ "a",
1053
+ {
1054
+ href: link.href,
1055
+ ...isExternal ? { target: "_blank", rel: "noopener noreferrer" } : {},
1056
+ style: {
1057
+ display: "flex",
1058
+ alignItems: "center",
1059
+ gap: 4,
1060
+ color: "var(--txM)",
1061
+ textDecoration: "none",
1062
+ fontSize: 12,
1063
+ fontFamily: "var(--font-body)",
1064
+ fontWeight: 500,
1065
+ transition: "color .15s"
1066
+ },
1067
+ onMouseOver: (e) => e.currentTarget.style.color = "var(--ac)",
1068
+ onMouseOut: (e) => e.currentTarget.style.color = "var(--txM)",
1069
+ children: [
1070
+ link.label,
1071
+ isExternal && /* @__PURE__ */ jsx2(ExtLinkIcon, {})
1072
+ ]
1073
+ },
1074
+ link.label
1075
+ );
1076
+ }),
1077
+ /* @__PURE__ */ jsx2("span", { style: { width: 1, height: 16, background: "var(--bd)" } })
1078
+ ] }),
1079
+ versioning && /* @__PURE__ */ jsxs2("div", { style: { position: "relative" }, children: [
1080
+ /* @__PURE__ */ jsxs2(
1081
+ "button",
1082
+ {
1083
+ "data-testid": "version-switcher",
1084
+ onClick: () => setVersionDropdown((o) => !o),
1085
+ style: {
1086
+ display: "flex",
1087
+ alignItems: "center",
1088
+ gap: 6,
1089
+ background: "var(--sf)",
1090
+ border: "1px solid var(--bd)",
1091
+ borderRadius: 2,
1092
+ padding: "5px 10px",
1093
+ cursor: "pointer",
1094
+ color: "var(--tx2)",
1095
+ fontSize: 12,
1096
+ fontFamily: "var(--font-code)"
1097
+ },
1098
+ children: [
1099
+ /* @__PURE__ */ jsx2(VersionIcon, {}),
1100
+ currentVersion || versioning.current,
1101
+ /* @__PURE__ */ jsx2(ChevDown, {})
1102
+ ]
1103
+ }
1104
+ ),
1105
+ versionDropdownOpen && /* @__PURE__ */ jsx2(
1106
+ "div",
1107
+ {
1108
+ "data-testid": "version-dropdown",
1109
+ style: {
1110
+ position: "absolute",
1111
+ top: "100%",
1112
+ right: 0,
1113
+ marginTop: 4,
1114
+ background: "var(--sf)",
1115
+ border: "1px solid var(--bd)",
1116
+ borderRadius: 2,
1117
+ boxShadow: "0 8px 32px rgba(0,0,0,0.2)",
1118
+ overflow: "hidden",
1119
+ zIndex: 100,
1120
+ minWidth: 120
1121
+ },
1122
+ children: versioning.versions.map((v) => /* @__PURE__ */ jsxs2(
1123
+ "button",
1124
+ {
1125
+ onClick: () => {
1126
+ setVersionDropdown(false);
1127
+ const targetUrl = v === versioning.current ? "/" : `/${v}`;
1128
+ window.location.href = targetUrl;
1129
+ },
1130
+ style: {
1131
+ display: "block",
1132
+ width: "100%",
1133
+ textAlign: "left",
1134
+ background: v === (currentVersion || versioning.current) ? "var(--acD)" : "none",
1135
+ border: "none",
1136
+ padding: "8px 14px",
1137
+ cursor: "pointer",
1138
+ color: v === (currentVersion || versioning.current) ? "var(--ac)" : "var(--tx2)",
1139
+ fontSize: 12,
1140
+ fontFamily: "var(--font-code)",
1141
+ fontWeight: v === versioning.current ? 600 : 400
1142
+ },
1143
+ children: [
1144
+ v,
1145
+ v === versioning.current ? " (latest)" : ""
1146
+ ]
1147
+ },
1148
+ v
1149
+ ))
1150
+ }
1151
+ )
1152
+ ] }),
1153
+ i18n && i18n.locales.length > 1 && /* @__PURE__ */ jsxs2("div", { style: { position: "relative" }, children: [
1154
+ /* @__PURE__ */ jsxs2(
1155
+ "button",
1156
+ {
1157
+ "data-testid": "language-switcher",
1158
+ onClick: () => setLocaleDropdown((o) => !o),
1159
+ style: {
1160
+ display: "flex",
1161
+ alignItems: "center",
1162
+ gap: 6,
1163
+ background: "var(--sf)",
1164
+ border: "1px solid var(--bd)",
1165
+ borderRadius: 2,
1166
+ padding: "5px 10px",
1167
+ cursor: "pointer",
1168
+ color: "var(--tx2)",
1169
+ fontSize: 12,
1170
+ fontFamily: "var(--font-body)"
1171
+ },
1172
+ children: [
1173
+ /* @__PURE__ */ jsx2(GlobeIcon, {}),
1174
+ i18n.localeNames?.[currentLocale || i18n.defaultLocale] || currentLocale || i18n.defaultLocale,
1175
+ /* @__PURE__ */ jsx2(ChevDown, {})
1176
+ ]
1177
+ }
1178
+ ),
1179
+ localeDropdownOpen && /* @__PURE__ */ jsx2(
1180
+ "div",
1181
+ {
1182
+ "data-testid": "language-dropdown",
1183
+ style: {
1184
+ position: "absolute",
1185
+ top: "100%",
1186
+ right: 0,
1187
+ marginTop: 4,
1188
+ background: "var(--sf)",
1189
+ border: "1px solid var(--bd)",
1190
+ borderRadius: 2,
1191
+ boxShadow: "0 8px 32px rgba(0,0,0,0.2)",
1192
+ overflow: "hidden",
1193
+ zIndex: 100,
1194
+ minWidth: 120
1195
+ },
1196
+ children: i18n.locales.map((locale) => {
1197
+ const isActive = locale === (currentLocale || i18n.defaultLocale);
1198
+ const displayName = i18n.localeNames?.[locale] || locale;
1199
+ const activeLocale = currentLocale || i18n.defaultLocale;
1200
+ let basePageId = currentPageId;
1201
+ if (activeLocale !== i18n.defaultLocale && currentPageId.startsWith(`${activeLocale}/`)) {
1202
+ basePageId = currentPageId.slice(activeLocale.length + 1);
1203
+ }
1204
+ const targetId = locale === i18n.defaultLocale ? basePageId : `${locale}/${basePageId}`;
1205
+ return /* @__PURE__ */ jsx2(
1206
+ "button",
1207
+ {
1208
+ onClick: () => {
1209
+ setLocaleDropdown(false);
1210
+ onNavigate(targetId);
1211
+ },
1212
+ style: {
1213
+ display: "block",
1214
+ width: "100%",
1215
+ textAlign: "left",
1216
+ background: isActive ? "var(--acD)" : "none",
1217
+ border: "none",
1218
+ padding: "8px 14px",
1219
+ cursor: "pointer",
1220
+ color: isActive ? "var(--ac)" : "var(--tx2)",
1221
+ fontSize: 12,
1222
+ fontFamily: "var(--font-body)",
1223
+ fontWeight: isActive ? 600 : 400
1224
+ },
1225
+ children: displayName
1226
+ },
1227
+ locale
1228
+ );
1229
+ })
1230
+ }
1231
+ )
1232
+ ] })
1233
+ ] }),
1234
+ isOldVersion && /* @__PURE__ */ jsxs2(
1235
+ "div",
1236
+ {
1237
+ "data-testid": "old-version-banner",
1238
+ style: {
1239
+ display: "flex",
1240
+ alignItems: "center",
1241
+ justifyContent: "center",
1242
+ gap: 8,
1243
+ background: "var(--acD)",
1244
+ borderBottom: "1px solid var(--bd)",
1245
+ padding: "8px 24px",
1246
+ fontSize: 13,
1247
+ color: "var(--tx2)"
1248
+ },
1249
+ children: [
1250
+ /* @__PURE__ */ jsxs2("span", { children: [
1251
+ "You're viewing docs for ",
1252
+ currentVersion,
1253
+ "."
1254
+ ] }),
1255
+ /* @__PURE__ */ jsx2(
1256
+ "button",
1257
+ {
1258
+ onClick: () => {
1259
+ window.location.href = "/";
1260
+ },
1261
+ style: {
1262
+ background: "none",
1263
+ border: "none",
1264
+ color: "var(--ac)",
1265
+ cursor: "pointer",
1266
+ fontWeight: 600,
1267
+ fontSize: 13,
1268
+ fontFamily: "var(--font-body)",
1269
+ textDecoration: "underline"
1270
+ },
1271
+ children: "Switch to latest."
1272
+ }
1273
+ )
1274
+ ]
1275
+ }
1276
+ ),
1277
+ /* @__PURE__ */ jsxs2("div", { ref: contentRef, style: { flex: 1, overflow: "auto", display: "flex" }, children: [
1278
+ /* @__PURE__ */ jsxs2("main", { style: { flex: 1, maxWidth: 760, padding: "40px 48px 80px", margin: "0 auto" }, children: [
1279
+ /* @__PURE__ */ jsx2("h1", { style: { fontFamily: "var(--font-heading)", fontSize: 38, fontWeight: 400, fontStyle: "italic", lineHeight: 1.15, marginBottom: 8 }, children: pageTitle }),
1280
+ pageDescription && /* @__PURE__ */ jsx2("p", { style: { fontSize: 16, color: "var(--tx2)", lineHeight: 1.6, marginBottom: 32 }, children: pageDescription }),
1281
+ /* @__PURE__ */ jsx2("div", { style: { borderTop: "1px solid var(--bd)", paddingTop: 28 }, children: changelogEntries && changelogEntries.length > 0 ? /* @__PURE__ */ jsx2(ChangelogView, { entries: changelogEntries }) : PageComponent ? /* @__PURE__ */ jsx2("div", { className: "tome-content", children: /* @__PURE__ */ jsx2(PageComponent, { components: mdxComponents || {} }) }) : /* @__PURE__ */ jsx2(
1282
+ "div",
1283
+ {
1284
+ className: "tome-content",
1285
+ dangerouslySetInnerHTML: { __html: pageHtml || "" }
1286
+ }
1287
+ ) }),
1288
+ (editUrl || lastUpdated) && /* @__PURE__ */ jsxs2("div", { style: { marginTop: 40, display: "flex", alignItems: "center", justifyContent: "space-between", gap: 16 }, children: [
1289
+ editUrl && /* @__PURE__ */ jsx2("div", { "data-testid": "edit-page-link", children: /* @__PURE__ */ jsxs2(
1290
+ "a",
1291
+ {
1292
+ href: editUrl,
1293
+ target: "_blank",
1294
+ rel: "noopener noreferrer",
1295
+ style: {
1296
+ display: "inline-flex",
1297
+ alignItems: "center",
1298
+ gap: 6,
1299
+ color: "var(--txM)",
1300
+ textDecoration: "none",
1301
+ fontSize: 13,
1302
+ fontFamily: "var(--font-body)",
1303
+ transition: "color .15s"
1304
+ },
1305
+ onMouseOver: (e) => e.currentTarget.style.color = "var(--ac)",
1306
+ onMouseOut: (e) => e.currentTarget.style.color = "var(--txM)",
1307
+ children: [
1308
+ /* @__PURE__ */ jsx2(PencilIcon, {}),
1309
+ " Edit this page on GitHub"
1310
+ ]
1311
+ }
1312
+ ) }),
1313
+ lastUpdated && /* @__PURE__ */ jsxs2("div", { "data-testid": "last-updated", style: { fontSize: 12, color: "var(--txM)", fontFamily: "var(--font-body)" }, children: [
1314
+ "Last updated ",
1315
+ formatRelativeDate(lastUpdated)
1316
+ ] })
1317
+ ] }),
1318
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", justifyContent: "space-between", marginTop: editUrl || lastUpdated ? 16 : 48, paddingTop: 24, borderTop: "1px solid var(--bd)", gap: 16 }, children: [
1319
+ prev ? /* @__PURE__ */ jsxs2("button", { onClick: () => onNavigate(prev.id), style: {
1320
+ display: "flex",
1321
+ alignItems: "center",
1322
+ gap: 8,
1323
+ background: "none",
1324
+ border: "1px solid var(--bd)",
1325
+ borderRadius: 2,
1326
+ padding: "10px 16px",
1327
+ cursor: "pointer",
1328
+ color: "var(--tx2)",
1329
+ fontSize: 13,
1330
+ fontFamily: "var(--font-body)",
1331
+ transition: "border-color .15s, color .15s"
1332
+ }, children: [
1333
+ /* @__PURE__ */ jsx2(ArrowLeft, {}),
1334
+ " ",
1335
+ prev.title
1336
+ ] }) : /* @__PURE__ */ jsx2("div", {}),
1337
+ next ? /* @__PURE__ */ jsxs2("button", { onClick: () => onNavigate(next.id), style: {
1338
+ display: "flex",
1339
+ alignItems: "center",
1340
+ gap: 8,
1341
+ background: "none",
1342
+ border: "1px solid var(--bd)",
1343
+ borderRadius: 2,
1344
+ padding: "10px 16px",
1345
+ cursor: "pointer",
1346
+ color: "var(--tx2)",
1347
+ fontSize: 13,
1348
+ fontFamily: "var(--font-body)",
1349
+ transition: "border-color .15s, color .15s"
1350
+ }, children: [
1351
+ next.title,
1352
+ " ",
1353
+ /* @__PURE__ */ jsx2(ArrowRight, {})
1354
+ ] }) : /* @__PURE__ */ jsx2("div", {})
1355
+ ] })
1356
+ ] }),
1357
+ showToc && filteredHeadings.length >= 2 && wide && /* @__PURE__ */ jsxs2("aside", { "data-testid": "toc-sidebar", style: { width: 200, padding: "40px 16px 40px 0", position: "sticky", top: 0, alignSelf: "flex-start", flexShrink: 0 }, children: [
1358
+ /* @__PURE__ */ jsx2("div", { style: { fontSize: 10, fontWeight: 600, textTransform: "uppercase", letterSpacing: ".1em", color: "var(--txM)", marginBottom: 12, fontFamily: "var(--font-code)" }, children: "On this page" }),
1359
+ /* @__PURE__ */ jsx2("nav", { "aria-label": "Table of contents", style: { borderLeft: "1px solid var(--bd)", paddingLeft: 0 }, children: filteredHeadings.map((h, i) => {
1360
+ const isActive = activeHeadingId === h.id;
1361
+ return /* @__PURE__ */ jsx2(
1362
+ "a",
1363
+ {
1364
+ href: `#${h.id}`,
1365
+ onClick: (e) => scrollToHeading(e, h.id),
1366
+ "data-testid": `toc-link-${h.id}`,
1367
+ style: {
1368
+ display: "block",
1369
+ fontSize: 12,
1370
+ color: isActive ? "var(--ac)" : "var(--txM)",
1371
+ fontWeight: isActive ? 500 : 400,
1372
+ textDecoration: "none",
1373
+ padding: "4px 12px",
1374
+ paddingLeft: 12 + (h.depth - 2) * 12,
1375
+ lineHeight: 1.4,
1376
+ transition: "color .15s, font-weight .15s",
1377
+ borderLeft: isActive ? "2px solid var(--ac)" : "2px solid transparent",
1378
+ marginLeft: -1
1379
+ },
1380
+ children: h.text
1381
+ },
1382
+ i
1383
+ );
1384
+ }) })
1385
+ ] })
1386
+ ] })
1387
+ ] })
1388
+ ] }),
1389
+ config2.ai?.enabled && /* @__PURE__ */ jsx2(
1390
+ AiChat,
1391
+ {
1392
+ provider: config2.ai.provider || "anthropic",
1393
+ model: config2.ai.model,
1394
+ apiKey: typeof __TOME_AI_API_KEY__ !== "undefined" && __TOME_AI_API_KEY__ ? __TOME_AI_API_KEY__ : void 0,
1395
+ context: docContext2?.map((d) => `## ${d.title}
1396
+ ${d.content}`).join("\n\n") ?? allPages.map((p) => `- ${p.title}${p.description ? ": " + p.description : ""}`).join("\n")
1397
+ }
1398
+ )
1399
+ ] });
1400
+ }
1401
+ function SearchModal({ allPages, onNavigate, onClose }) {
1402
+ const [q, setQ] = useState2("");
1403
+ const [results, setResults] = useState2([]);
1404
+ const [selected, setSelected] = useState2(0);
1405
+ const [pagefindReady, setPagefindReady] = useState2(null);
1406
+ const inputRef = useRef2(null);
1407
+ const debounceRef = useRef2(void 0);
1408
+ useEffect2(() => {
1409
+ initPagefind().then((pf) => setPagefindReady(!!pf));
1410
+ setTimeout(() => inputRef.current?.focus(), 50);
1411
+ }, []);
1412
+ const fallbackSearch = useCallback2((query) => {
1413
+ if (!query.trim()) return [];
1414
+ const ql = query.toLowerCase();
1415
+ return allPages.filter((p) => p.title.toLowerCase().includes(ql) || (p.description || "").toLowerCase().includes(ql)).slice(0, 8).map((p) => ({ id: p.id, title: p.title, excerpt: p.description }));
1416
+ }, [allPages]);
1417
+ const doSearch = useCallback2(async (query) => {
1418
+ if (!query.trim()) {
1419
+ setResults([]);
1420
+ setSelected(0);
1421
+ return;
1422
+ }
1423
+ const pf = pagefindInstance;
1424
+ if (pf) {
1425
+ try {
1426
+ const search = await pf.search(query);
1427
+ const items = [];
1428
+ for (const result of search.results.slice(0, 8)) {
1429
+ const data = await result.data();
1430
+ const url = data.url || "";
1431
+ const id = url.replace(/^\//, "").replace(/\/index\.html$/, "").replace(/\.html$/, "") || "index";
1432
+ items.push({
1433
+ id,
1434
+ title: data.meta?.title || id,
1435
+ excerpt: data.excerpt || void 0
1436
+ });
1437
+ }
1438
+ setResults(items);
1439
+ setSelected(0);
1440
+ return;
1441
+ } catch {
1442
+ }
1443
+ }
1444
+ setResults(fallbackSearch(query));
1445
+ setSelected(0);
1446
+ }, [fallbackSearch]);
1447
+ useEffect2(() => {
1448
+ if (debounceRef.current) clearTimeout(debounceRef.current);
1449
+ debounceRef.current = setTimeout(() => doSearch(q), 120);
1450
+ return () => {
1451
+ if (debounceRef.current) clearTimeout(debounceRef.current);
1452
+ };
1453
+ }, [q, doSearch]);
1454
+ const handleKeyDown = useCallback2((e) => {
1455
+ if (e.key === "ArrowDown") {
1456
+ e.preventDefault();
1457
+ setSelected((i) => Math.min(i + 1, results.length - 1));
1458
+ } else if (e.key === "ArrowUp") {
1459
+ e.preventDefault();
1460
+ setSelected((i) => Math.max(i - 1, 0));
1461
+ } else if (e.key === "Enter" && results.length > 0) {
1462
+ e.preventDefault();
1463
+ onNavigate(results[selected].id);
1464
+ }
1465
+ }, [results, selected, onNavigate]);
1466
+ return /* @__PURE__ */ jsx2("div", { onClick: onClose, style: {
1467
+ position: "fixed",
1468
+ inset: 0,
1469
+ zIndex: 1e3,
1470
+ background: "rgba(0,0,0,0.55)",
1471
+ backdropFilter: "blur(6px)",
1472
+ display: "flex",
1473
+ alignItems: "flex-start",
1474
+ justifyContent: "center",
1475
+ paddingTop: "12vh"
1476
+ }, children: /* @__PURE__ */ jsxs2("div", { onClick: (e) => e.stopPropagation(), style: {
1477
+ background: "var(--sf)",
1478
+ border: "1px solid var(--bd)",
1479
+ borderRadius: 2,
1480
+ width: "100%",
1481
+ maxWidth: 520,
1482
+ boxShadow: "0 24px 80px rgba(0,0,0,0.4)",
1483
+ overflow: "hidden"
1484
+ }, children: [
1485
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", gap: 10, padding: "14px 18px", borderBottom: "1px solid var(--bd)" }, children: [
1486
+ /* @__PURE__ */ jsx2(SearchIcon, {}),
1487
+ /* @__PURE__ */ jsx2(
1488
+ "input",
1489
+ {
1490
+ ref: inputRef,
1491
+ value: q,
1492
+ onChange: (e) => setQ(e.target.value),
1493
+ onKeyDown: handleKeyDown,
1494
+ placeholder: "Search documentation...",
1495
+ style: { flex: 1, background: "none", border: "none", outline: "none", color: "var(--tx)", fontSize: 15, fontFamily: "var(--font-body)" }
1496
+ }
1497
+ ),
1498
+ /* @__PURE__ */ jsx2("kbd", { style: { fontFamily: "var(--font-code)", fontSize: 10, color: "var(--txM)", background: "var(--cdBg)", padding: "2px 6px", borderRadius: 2, border: "1px solid var(--bd)" }, children: "ESC" })
1499
+ ] }),
1500
+ results.length > 0 && /* @__PURE__ */ jsx2("div", { style: { padding: 6, maxHeight: 360, overflow: "auto" }, children: results.map((r, i) => /* @__PURE__ */ jsxs2(
1501
+ "button",
1502
+ {
1503
+ onClick: () => onNavigate(r.id),
1504
+ style: {
1505
+ display: "block",
1506
+ width: "100%",
1507
+ textAlign: "left",
1508
+ background: i === selected ? "var(--acD)" : "none",
1509
+ border: "none",
1510
+ borderRadius: 2,
1511
+ padding: "10px 14px",
1512
+ cursor: "pointer",
1513
+ color: "var(--tx)",
1514
+ fontFamily: "var(--font-body)"
1515
+ },
1516
+ onMouseEnter: () => setSelected(i),
1517
+ children: [
1518
+ /* @__PURE__ */ jsx2("div", { style: { fontWeight: 500, fontSize: 14, marginBottom: 2 }, children: r.title }),
1519
+ r.excerpt && /* @__PURE__ */ jsx2("div", { style: {
1520
+ fontSize: 12,
1521
+ color: "var(--txM)",
1522
+ lineHeight: 1.3
1523
+ }, dangerouslySetInnerHTML: { __html: r.excerpt } })
1524
+ ]
1525
+ },
1526
+ r.id + i
1527
+ )) }),
1528
+ q && !results.length && /* @__PURE__ */ jsx2("div", { style: { padding: "32px 18px", textAlign: "center", color: "var(--txM)", fontSize: 14 }, children: "No results found" }),
1529
+ pagefindReady === false && q && results.length > 0 && /* @__PURE__ */ jsx2("div", { style: { padding: "6px 18px 10px", fontSize: 11, color: "var(--txM)", textAlign: "center" }, children: "Showing title matches. Build your site for full-text search." })
1530
+ ] }) });
1531
+ }
1532
+
1533
+ // src/entry.tsx
1534
+ import config from "virtual:tome/config";
1535
+ import { routes, navigation } from "virtual:tome/routes";
1536
+ import loadPageModule from "virtual:tome/page-loader";
1537
+ import docContext from "virtual:tome/doc-context";
1538
+ import {
1539
+ Callout,
1540
+ Tabs,
1541
+ Card,
1542
+ CardGroup,
1543
+ Steps,
1544
+ Accordion,
1545
+ ChangelogTimeline
1546
+ } from "@tomehq/components";
1547
+ import { Fragment, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
1548
+ var MDX_COMPONENTS = {
1549
+ Callout,
1550
+ Tabs,
1551
+ Card,
1552
+ CardGroup,
1553
+ Steps,
1554
+ Accordion,
1555
+ ChangelogTimeline
1556
+ };
1557
+ var contentStyles = `
1558
+ @import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:wght@300;400;500;600;700&family=Cormorant+Garamond:ital,wght@0,300;0,400;0,600;0,700;1,300;1,400;1,700&family=Fira+Code:wght@400;500;600&display=swap');
1559
+
1560
+ .tome-content h2 { font-family: var(--font-body); font-size: 1.35em; font-weight: 600; margin-top: 2em; margin-bottom: 0.5em; display: flex; align-items: center; gap: 10px; letter-spacing: 0.01em; }
1561
+ .tome-content h2::before { content: "#"; font-family: var(--font-heading); font-size: 1.2em; font-weight: 300; font-style: italic; color: var(--ac); opacity: 0.5; }
1562
+ .tome-content h3 { font-family: var(--font-body); font-size: 1.15em; font-weight: 600; margin-top: 1.5em; margin-bottom: 0.5em; }
1563
+ .tome-content h4 { font-family: var(--font-body); font-size: 1.05em; font-weight: 600; margin-top: 1.2em; margin-bottom: 0.5em; }
1564
+ .tome-content p { color: var(--tx2); line-height: 1.8; margin-bottom: 1em; font-size: 14.5px; }
1565
+ .tome-content a { color: var(--ac); text-decoration: none; }
1566
+ .tome-content a:hover { text-decoration: underline; }
1567
+ .tome-content .heading-anchor { display: none; }
1568
+ .tome-content ul, .tome-content ol { color: var(--tx2); padding-left: 1.5em; margin-bottom: 1em; }
1569
+ .tome-content li { margin-bottom: 0.3em; line-height: 1.7; }
1570
+ .tome-content code { font-family: var(--font-code); font-size: 0.88em; background: var(--cdBg); padding: 0.15em 0.4em; border-radius: 2px; color: var(--ac); }
1571
+ .tome-content pre { margin-bottom: 1.2em; border-radius: 2px; overflow-x: auto; border: 1px solid var(--bd); }
1572
+ .tome-content pre code { background: none; padding: 1em 1.2em; display: block; font-size: 12.5px; line-height: 1.7; color: var(--cdTx); }
1573
+ .tome-content blockquote { border-left: 3px solid var(--ac); padding: 0.5em 1em; margin: 1em 0; background: var(--acD); border-radius: 0 2px 2px 0; }
1574
+ .tome-content blockquote p { color: var(--tx2); margin: 0; }
1575
+ .tome-content table { width: 100%; border-collapse: collapse; margin-bottom: 1em; }
1576
+ .tome-content th, .tome-content td { padding: 0.5em 0.8em; border: 1px solid var(--bd); text-align: left; font-size: 0.9em; }
1577
+ .tome-content th { background: var(--sf); font-weight: 600; }
1578
+ .tome-content img { max-width: 100%; border-radius: 2px; }
1579
+ .tome-content hr { border: none; border-top: 1px solid var(--bd); margin: 2em 0; }
1580
+
1581
+ /* Selection style */
1582
+ ::selection { background: var(--acD); color: var(--ac); }
1583
+
1584
+ /* Scrollbar style */
1585
+ ::-webkit-scrollbar { width: 5px; height: 5px; }
1586
+ ::-webkit-scrollbar-track { background: transparent; }
1587
+ ::-webkit-scrollbar-thumb { background: var(--bd); border-radius: 10px; }
1588
+
1589
+ /* Grain overlay */
1590
+ .tome-grain::before {
1591
+ content: ""; position: fixed; inset: 0; z-index: 9999; pointer-events: none;
1592
+ opacity: .35;
1593
+ background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
1594
+ background-repeat: repeat; background-size: 256px;
1595
+ }
1596
+
1597
+ /* Shiki dual-theme support */
1598
+ .shiki { background: var(--cdBg) !important; }
1599
+ html.dark .shiki .shiki-light { display: none; }
1600
+ html.light .shiki .shiki-dark { display: none; }
1601
+ `;
1602
+ async function loadPage(id) {
1603
+ try {
1604
+ const route = routes.find((r) => r.id === id);
1605
+ const mod = await loadPageModule(id);
1606
+ if (route?.isMdx && mod.meta) {
1607
+ return {
1608
+ isMdx: true,
1609
+ component: mod.default,
1610
+ frontmatter: mod.meta.frontmatter,
1611
+ headings: mod.meta.headings
1612
+ };
1613
+ }
1614
+ if (!mod.default) return null;
1615
+ if (mod.isChangelog && mod.changelogEntries) {
1616
+ return { isMdx: false, ...mod.default, changelogEntries: mod.changelogEntries };
1617
+ }
1618
+ return { isMdx: false, ...mod.default };
1619
+ } catch (err) {
1620
+ console.error(`Failed to load page: ${id}`, err);
1621
+ return null;
1622
+ }
1623
+ }
1624
+ function App() {
1625
+ const [currentPageId, setCurrentPageId] = useState3(() => {
1626
+ const hash = window.location.hash.slice(1);
1627
+ if (hash && routes.some((r) => r.id === hash)) return hash;
1628
+ return routes[0]?.id || "index";
1629
+ });
1630
+ const [pageData, setPageData] = useState3(null);
1631
+ const [loading, setLoading] = useState3(true);
1632
+ const navigateTo = useCallback3(async (id) => {
1633
+ setLoading(true);
1634
+ setCurrentPageId(id);
1635
+ window.location.hash = id;
1636
+ const data = await loadPage(id);
1637
+ setPageData(data);
1638
+ setLoading(false);
1639
+ }, []);
1640
+ useEffect3(() => {
1641
+ navigateTo(currentPageId);
1642
+ }, []);
1643
+ useEffect3(() => {
1644
+ const onHashChange = () => {
1645
+ const hash = window.location.hash.slice(1);
1646
+ if (hash && hash !== currentPageId && routes.some((r) => r.id === hash)) {
1647
+ navigateTo(hash);
1648
+ }
1649
+ };
1650
+ window.addEventListener("hashchange", onHashChange);
1651
+ return () => window.removeEventListener("hashchange", onHashChange);
1652
+ }, [currentPageId, navigateTo]);
1653
+ const allPages = routes.map((r) => ({
1654
+ id: r.id,
1655
+ title: r.frontmatter.title,
1656
+ description: r.frontmatter.description
1657
+ }));
1658
+ const currentRoute = routes.find((r) => r.id === currentPageId);
1659
+ let editUrl;
1660
+ if (config.editLink && currentRoute?.filePath) {
1661
+ const { repo, branch = "main", dir = "" } = config.editLink;
1662
+ const dirPrefix = dir ? `${dir.replace(/\/$/, "")}/` : "";
1663
+ editUrl = `https://github.com/${repo}/edit/${branch}/${dirPrefix}${currentRoute.filePath}`;
1664
+ }
1665
+ return /* @__PURE__ */ jsxs3(Fragment, { children: [
1666
+ /* @__PURE__ */ jsx3("style", { children: contentStyles }),
1667
+ /* @__PURE__ */ jsx3(
1668
+ Shell,
1669
+ {
1670
+ config,
1671
+ navigation,
1672
+ currentPageId,
1673
+ pageHtml: !pageData?.isMdx ? loading ? "<p>Loading...</p>" : pageData?.html || "<p>Page not found</p>" : void 0,
1674
+ pageComponent: pageData?.isMdx ? pageData.component : void 0,
1675
+ mdxComponents: MDX_COMPONENTS,
1676
+ pageTitle: pageData?.frontmatter.title || (loading ? "Loading..." : "Not Found"),
1677
+ pageDescription: pageData?.frontmatter.description,
1678
+ headings: pageData?.headings || [],
1679
+ tocEnabled: pageData?.frontmatter.toc !== false,
1680
+ editUrl,
1681
+ lastUpdated: currentRoute?.lastUpdated,
1682
+ changelogEntries: !pageData?.isMdx ? pageData?.changelogEntries : void 0,
1683
+ onNavigate: navigateTo,
1684
+ allPages,
1685
+ docContext
1686
+ }
1687
+ )
1688
+ ] });
1689
+ }
1690
+ var container = document.getElementById("tome-root");
1691
+ if (container) {
1692
+ const root = createRoot(container);
1693
+ root.render(/* @__PURE__ */ jsx3(App, {}));
1694
+ }
1695
+ var entry_default = App;
1696
+
1697
+ export {
1698
+ THEME_PRESETS,
1699
+ AiChat,
1700
+ Shell,
1701
+ entry_default
1702
+ };