@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,2569 @@
1
+ // src/entry.tsx
2
+ import { useState as useState3, useEffect as useEffect3, useCallback as useCallback3, useRef as useRef3 } from "react";
3
+ import { createRoot } from "react-dom/client";
4
+
5
+ // src/Shell.tsx
6
+ import React2, { useState as useState2, useEffect as useEffect2, useLayoutEffect, 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 { Fragment, 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 8a4 4 0 1 0 0 8 4 4 0 0 0 0-8Zm0-4a1 1 0 0 1 1-1v-1a1 1 0 0 1-2 0v1a1 1 0 0 1 1 1Zm0 16a1 1 0 0 1 1 1v1a1 1 0 0 1-2 0v-1a1 1 0 0 1 1-1ZM4 12a1 1 0 0 1-1 1H2a1 1 0 0 1 0-2h1a1 1 0 0 1 1 1Zm18-1h-1a1 1 0 0 1 0 2h1a1 1 0 0 1 0-2ZM6.34 6.34a1 1 0 0 1-1.41 0l-.71-.71a1 1 0 0 1 1.41-1.41l.71.71a1 1 0 0 1 0 1.41Zm12.73-2.12-.71.71a1 1 0 0 1-1.41-1.41l.71-.71a1 1 0 1 1 1.41 1.41ZM6.34 17.66l-.71.71a1 1 0 0 1-1.41-1.41l.71-.71a1 1 0 0 1 1.41 1.41Zm12.73 2.12-.71-.71a1 1 0 0 1 1.41-1.41l.71.71a1 1 0 0 1-1.41 1.41Z" });
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
+ basePath: basePath2 = ""
616
+ }) {
617
+ const [DocSearchComponent, setDocSearchComponent] = useState2(null);
618
+ const [loadFailed, setLoadFailed] = useState2(false);
619
+ useEffect2(() => {
620
+ loadDocSearch().then((mod) => {
621
+ if (mod && mod.DocSearch) {
622
+ setDocSearchComponent(() => mod.DocSearch);
623
+ } else if (mod && mod.default) {
624
+ setDocSearchComponent(() => mod.default);
625
+ } else {
626
+ setLoadFailed(true);
627
+ }
628
+ });
629
+ }, []);
630
+ const extractPageId = useCallback2((url) => {
631
+ try {
632
+ const parsed = new URL(url, "http://localhost");
633
+ let pathname = parsed.pathname;
634
+ if (basePath2) {
635
+ const bp = basePath2.replace(/\/$/, "");
636
+ if (pathname.startsWith(bp)) pathname = pathname.slice(bp.length);
637
+ }
638
+ return pathname.replace(/^\//, "").replace(/\/index\.html$/, "").replace(/\.html$/, "") || "index";
639
+ } catch {
640
+ return "index";
641
+ }
642
+ }, [basePath2]);
643
+ if (loadFailed) {
644
+ return /* @__PURE__ */ jsx2("div", { onClick: onClose, style: {
645
+ position: "fixed",
646
+ inset: 0,
647
+ zIndex: 1e3,
648
+ background: "rgba(0,0,0,0.55)",
649
+ backdropFilter: "blur(6px)",
650
+ display: "flex",
651
+ alignItems: "flex-start",
652
+ justifyContent: "center",
653
+ paddingTop: "12vh"
654
+ }, children: /* @__PURE__ */ jsx2("div", { onClick: (e) => e.stopPropagation(), style: {
655
+ background: "var(--sf)",
656
+ border: "1px solid var(--bd)",
657
+ borderRadius: 12,
658
+ width: "100%",
659
+ maxWidth: 520,
660
+ boxShadow: "0 24px 80px rgba(0,0,0,0.4)",
661
+ padding: "32px 18px",
662
+ textAlign: "center",
663
+ color: "var(--txM)",
664
+ fontSize: 14
665
+ }, children: "Algolia DocSearch is not available. Install @docsearch/react to enable it." }) });
666
+ }
667
+ if (!DocSearchComponent) {
668
+ return /* @__PURE__ */ jsx2("div", { onClick: onClose, style: {
669
+ position: "fixed",
670
+ inset: 0,
671
+ zIndex: 1e3,
672
+ background: "rgba(0,0,0,0.55)",
673
+ backdropFilter: "blur(6px)",
674
+ display: "flex",
675
+ alignItems: "flex-start",
676
+ justifyContent: "center",
677
+ paddingTop: "12vh"
678
+ }, children: /* @__PURE__ */ jsx2("div", { style: {
679
+ background: "var(--sf)",
680
+ border: "1px solid var(--bd)",
681
+ borderRadius: 12,
682
+ width: "100%",
683
+ maxWidth: 520,
684
+ boxShadow: "0 24px 80px rgba(0,0,0,0.4)",
685
+ padding: "32px 18px",
686
+ textAlign: "center",
687
+ color: "var(--txM)",
688
+ fontSize: 14
689
+ }, children: "Loading search..." }) });
690
+ }
691
+ return /* @__PURE__ */ jsx2("div", { "data-testid": "algolia-search-modal", children: /* @__PURE__ */ jsx2(
692
+ DocSearchComponent,
693
+ {
694
+ appId,
695
+ apiKey,
696
+ indexName,
697
+ navigator: {
698
+ navigate({ itemUrl }) {
699
+ const pageId = extractPageId(itemUrl);
700
+ onNavigate(pageId);
701
+ }
702
+ },
703
+ hitComponent: ({ hit, children }) => /* @__PURE__ */ jsx2("a", { href: hit.url, onClick: (e) => {
704
+ e.preventDefault();
705
+ const pageId = extractPageId(hit.url);
706
+ onNavigate(pageId);
707
+ }, children })
708
+ }
709
+ ) });
710
+ }
711
+ 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 });
712
+ 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 });
713
+ 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 });
714
+ var SOCIAL_ICON_PATHS = {
715
+ github: "M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z",
716
+ twitter: "M12.6.75h2.454l-5.36 6.142L16 15.25h-4.937l-3.867-5.07-4.425 5.07H.316l5.733-6.57L0 .75h5.063l3.495 4.633L12.601.75Zm-.86 13.028h1.36L4.323 2.145H2.865l8.875 11.633Z",
717
+ discord: "M13.545 2.907a13.227 13.227 0 00-3.257-1.011.05.05 0 00-.052.025c-.141.25-.297.577-.406.833a12.19 12.19 0 00-3.658 0 8.258 8.258 0 00-.412-.833.051.051 0 00-.052-.025c-1.125.194-2.22.534-3.257 1.011a.041.041 0 00-.021.018C.356 6.024-.213 9.047.066 12.032c.001.014.01.028.021.037a13.276 13.276 0 003.995 2.02.05.05 0 00.056-.019c.308-.42.582-.863.818-1.329a.05.05 0 00-.028-.07 8.735 8.735 0 01-1.248-.595.05.05 0 01-.005-.083c.084-.063.168-.129.248-.195a.05.05 0 01.051-.007c2.619 1.196 5.454 1.196 8.041 0a.052.052 0 01.053.007c.08.066.164.132.248.195a.051.051 0 01-.004.085c-.399.232-.813.431-1.249.594a.05.05 0 00-.03.07c.24.465.515.909.817 1.329a.05.05 0 00.056.019 13.235 13.235 0 004.001-2.02.049.049 0 00.021-.037c.334-3.451-.559-6.449-2.366-9.106a.034.034 0 00-.02-.019z",
718
+ linkedin: "M0 1.146C0 .513.526 0 1.175 0h13.65C15.474 0 16 .513 16 1.146v13.708c0 .633-.526 1.146-1.175 1.146H1.175C.526 16 0 15.487 0 14.854V1.146zm4.943 12.248V6.169H2.542v7.225h2.401zm-1.2-8.212c.837 0 1.358-.554 1.358-1.248-.015-.709-.52-1.248-1.342-1.248-.822 0-1.359.54-1.359 1.248 0 .694.521 1.248 1.327 1.248h.016zm4.908 8.212V9.359c0-.216.016-.432.08-.586.173-.431.568-.878 1.232-.878.869 0 1.216.662 1.216 1.634v3.865h2.401V9.25c0-2.22-1.184-3.252-2.764-3.252-1.274 0-1.845.7-2.165 1.193v.025h-.016a5.54 5.54 0 01.016-.025V6.169h-2.4c.03.678 0 7.225 0 7.225h2.4z",
719
+ youtube: "M8.051 1.999h.089c.822.003 4.987.033 6.11.335a2.01 2.01 0 011.415 1.42c.101.38.172.883.22 1.402l.01.104.022.26.008.104c.065.914.073 1.77.074 1.957v.075c-.001.194-.01 1.108-.082 2.06l-.008.105-.009.104c-.05.572-.124 1.14-.235 1.558a2.007 2.007 0 01-1.415 1.42c-1.16.312-5.569.334-6.18.335h-.142c-.309 0-1.587-.006-2.927-.052l-.17-.006-.087-.004-.171-.007-.171-.007c-1.11-.049-2.167-.128-2.654-.26a2.007 2.007 0 01-1.415-1.419c-.111-.417-.185-.986-.235-1.558L.09 9.82l-.008-.104A31.4 31.4 0 010 7.68v-.123c.002-.215.01-.958.064-1.778l.007-.103.003-.052.008-.104.022-.26.01-.104c.048-.519.119-1.023.22-1.402a2.007 2.007 0 011.415-1.42c.487-.13 1.544-.21 2.654-.26l.17-.007.172-.006.086-.003.171-.007A99.788 99.788 0 017.858 2h.193zM6.4 5.209v4.818l4.157-2.408L6.4 5.209z",
720
+ mastodon: "M11.19 12.195c2.016-.24 3.77-1.475 3.99-2.603.348-1.778.32-4.339.32-4.339 0-3.47-2.286-4.488-2.286-4.488C12.062.238 10.083.017 8.027 0h-.05C5.92.017 3.942.238 2.79.765 2.79.765.504 1.783.504 5.253c-.005.995-.01 2.19.013 3.44.075 4.21.56 8.354 3.383 9.386 1.302.476 2.418.576 3.317.507 1.628-.125 2.541-.8 2.541-.8l-.054-1.182s-1.163.366-2.47.322c-1.293-.044-2.658-.138-2.867-1.716a3.23 3.23 0 01-.028-.465s1.27.31 2.879.384c.984.045 1.905-.058 2.842-.17zM13 8.59V5.319c0-.67-.17-1.2-.507-1.592-.348-.4-.806-.605-1.373-.605-.656 0-1.154.252-1.486.756L9.2 4.595l-.434-.717c-.332-.504-.83-.756-1.486-.756-.567 0-1.025.204-1.373.605-.338.392-.507.923-.507 1.592V8.59h1.69V5.468c0-.67.285-1.012.855-1.012.63 0 .946.404.946 1.204V7.11h1.682V5.66c0-.8.316-1.204.946-1.204.57 0 .855.342.855 1.012V8.59H13z",
721
+ bluesky: "M3.468 1.948C5.303 3.325 7.276 6.118 8 7.616c.724-1.498 2.697-4.29 4.532-5.668C13.855 1.013 16 .638 16 3.14c0 .5-.286 4.2-.454 4.8-.585 2.093-2.716 2.628-4.544 2.305 3.195.564 4.007 2.433 2.25 4.302-3.337 3.548-4.8-1.244-5.252-2.547 0 0-.116-.334-.166-.334h.332C8.166 11.666 8.05 12 8.05 12c-.452 1.303-1.916 6.095-5.252 2.547-1.756-1.869-.946-3.738 2.25-4.302-1.829.323-3.96-.212-4.544-2.305C.336 7.34.05 3.64.05 3.14.05.638 2.195 1.013 3.468 1.948z"
722
+ };
723
+ var SocialIcon = ({ platform, customIcon }) => {
724
+ const d = platform === "custom" && customIcon ? customIcon : SOCIAL_ICON_PATHS[platform];
725
+ if (!d) return null;
726
+ return /* @__PURE__ */ jsx2("svg", { width: 16, height: 16, viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ jsx2("path", { d }) });
727
+ };
728
+ var CHANGELOG_SECTION_COLORS = {
729
+ Added: "#22c55e",
730
+ Changed: "#3b82f6",
731
+ Deprecated: "#f59e0b",
732
+ Removed: "#ef4444",
733
+ Fixed: "#8b5cf6",
734
+ Security: "#f97316"
735
+ };
736
+ function ChangelogView({ entries }) {
737
+ const [showAll, setShowAll] = useState2(entries.length <= 5);
738
+ const visible = showAll ? entries : entries.slice(0, 5);
739
+ return /* @__PURE__ */ jsxs2("div", { "data-testid": "changelog-timeline", style: { position: "relative" }, children: [
740
+ /* @__PURE__ */ jsx2("div", { style: { position: "absolute", left: 15, top: 8, bottom: 8, width: 2, background: "var(--bd)" } }),
741
+ visible.map((entry, i) => /* @__PURE__ */ jsxs2(
742
+ "div",
743
+ {
744
+ "data-testid": `changelog-entry-${entry.version}`,
745
+ style: { position: "relative", paddingLeft: 44, paddingBottom: i < visible.length - 1 ? 32 : 0 },
746
+ children: [
747
+ /* @__PURE__ */ jsx2("div", { style: {
748
+ position: "absolute",
749
+ left: 8,
750
+ top: 6,
751
+ width: 16,
752
+ height: 16,
753
+ borderRadius: "50%",
754
+ background: entry.version === "Unreleased" ? "var(--txM)" : "var(--ac)",
755
+ border: "3px solid var(--bg, #1a1a1a)"
756
+ } }),
757
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "baseline", gap: 12, marginBottom: 12 }, children: [
758
+ /* @__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 }),
759
+ entry.date && /* @__PURE__ */ jsx2("span", { style: { fontSize: 13, color: "var(--txM)", fontFamily: "var(--font-code, monospace)" }, children: entry.date })
760
+ ] }),
761
+ entry.sections.map((section) => {
762
+ const sColor = CHANGELOG_SECTION_COLORS[section.type] || "#6b7280";
763
+ return /* @__PURE__ */ jsxs2("div", { style: { marginBottom: 16 }, children: [
764
+ /* @__PURE__ */ jsxs2("div", { style: { display: "inline-flex", alignItems: "center", gap: 6, marginBottom: 8 }, children: [
765
+ /* @__PURE__ */ jsx2("span", { style: { display: "inline-block", width: 8, height: 8, borderRadius: "50%", background: sColor } }),
766
+ /* @__PURE__ */ jsx2("span", { style: { fontSize: 12, fontWeight: 600, textTransform: "uppercase", letterSpacing: ".06em", color: sColor, fontFamily: "var(--font-code, monospace)" }, children: section.type })
767
+ ] }),
768
+ /* @__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)) })
769
+ ] }, section.type);
770
+ })
771
+ ]
772
+ },
773
+ entry.version
774
+ )),
775
+ !showAll && entries.length > 5 && /* @__PURE__ */ jsx2("div", { style: { textAlign: "center", marginTop: 24 }, children: /* @__PURE__ */ jsxs2(
776
+ "button",
777
+ {
778
+ "data-testid": "changelog-show-more",
779
+ onClick: () => setShowAll(true),
780
+ 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" },
781
+ children: [
782
+ "Show all ",
783
+ entries.length,
784
+ " releases"
785
+ ]
786
+ }
787
+ ) })
788
+ ] });
789
+ }
790
+ function getBreadcrumbs(navigation2, currentPageId, pageTitle) {
791
+ if (currentPageId === "index") return [];
792
+ for (const section of navigation2) {
793
+ const found = section.pages.find((p) => p.id === currentPageId);
794
+ if (found) {
795
+ const crumbs = [];
796
+ const firstPage = section.pages[0];
797
+ crumbs.push({
798
+ label: section.section,
799
+ href: firstPage ? firstPage.urlPath : null
800
+ });
801
+ crumbs.push({ label: pageTitle, href: null });
802
+ return crumbs;
803
+ }
804
+ }
805
+ return [];
806
+ }
807
+ function Shell({
808
+ config: config2,
809
+ navigation: navigation2,
810
+ currentPageId,
811
+ pageHtml,
812
+ pageComponent,
813
+ mdxComponents,
814
+ pageTitle,
815
+ pageDescription,
816
+ headings,
817
+ tocEnabled = true,
818
+ editUrl,
819
+ lastUpdated,
820
+ changelogEntries,
821
+ apiManifest,
822
+ apiBaseUrl,
823
+ apiPlayground,
824
+ apiAuth,
825
+ ApiReferenceComponent,
826
+ onNavigate,
827
+ allPages,
828
+ versioning,
829
+ currentVersion,
830
+ i18n: i18n2,
831
+ currentLocale,
832
+ docContext: docContext2,
833
+ basePath: basePath2 = "",
834
+ isDraft,
835
+ dir: dirProp,
836
+ overrides: overrides2
837
+ }) {
838
+ const resolvedLocale = currentLocale || i18n2?.defaultLocale || "en";
839
+ const dir = dirProp || i18n2?.localeDirs?.[resolvedLocale] || "ltr";
840
+ const isRtl = dir === "rtl";
841
+ const themeMode = config2.theme?.mode || "auto";
842
+ const [isDark, setDark] = useState2(() => {
843
+ if (themeMode === "dark") return true;
844
+ if (themeMode === "light") return false;
845
+ return window.matchMedia?.("(prefers-color-scheme: dark)").matches ?? true;
846
+ });
847
+ const [mobile, setMobile] = useState2(() => typeof window !== "undefined" && window.innerWidth < 768);
848
+ const [sbOpen, setSb] = useState2(() => typeof window !== "undefined" && window.innerWidth >= 768);
849
+ const [searchOpen, setSearch] = useState2(false);
850
+ const [versionDropdownOpen, setVersionDropdown] = useState2(false);
851
+ const [localeDropdownOpen, setLocaleDropdown] = useState2(false);
852
+ const [zoomSrc, setZoomSrc] = useState2(null);
853
+ const [feedbackGiven, setFeedbackGiven] = useState2({});
854
+ const [bannerDismissed, setBannerDismissed] = useState2(() => {
855
+ if (!config2.banner?.text) return true;
856
+ try {
857
+ const hash = Array.from(config2.banner.text).reduce((h, c) => (h << 5) - h + c.charCodeAt(0) | 0, 0).toString(36);
858
+ return localStorage.getItem("tome-banner-dismissed") === hash;
859
+ } catch {
860
+ return false;
861
+ }
862
+ });
863
+ const isOldVersion = versioning && currentVersion && currentVersion !== versioning.current;
864
+ const [expanded, setExpanded] = useState2(navigation2.map((n) => n.section));
865
+ const contentRef = useRef2(null);
866
+ const htmlContentRef = useRef2(null);
867
+ const lastHtmlRef = useRef2("");
868
+ const [wide, setWide] = useState2(() => typeof window !== "undefined" && window.innerWidth > 1100);
869
+ const preset = config2.theme?.preset || "amber";
870
+ const baseTokens = THEME_PRESETS[preset]?.[isDark ? "dark" : "light"] || THEME_PRESETS.amber.dark;
871
+ const accentOverride = config2.theme?.accent ? buildAccentOverride(config2.theme.accent, isDark) : null;
872
+ const t = accentOverride ? { ...baseTokens, ...accentOverride } : baseTokens;
873
+ const presetFonts = THEME_PRESETS[preset]?.fonts || THEME_PRESETS.amber.fonts;
874
+ const fonts = {
875
+ heading: config2.theme?.fonts?.heading || presetFonts.heading,
876
+ body: config2.theme?.fonts?.body || presetFonts.body,
877
+ code: config2.theme?.fonts?.code || presetFonts.code
878
+ };
879
+ useEffect2(() => {
880
+ if (themeMode !== "auto") return;
881
+ const mq = window.matchMedia("(prefers-color-scheme: dark)");
882
+ const handler = (e) => setDark(e.matches);
883
+ mq.addEventListener("change", handler);
884
+ return () => mq.removeEventListener("change", handler);
885
+ }, [themeMode]);
886
+ useEffect2(() => {
887
+ document.documentElement.classList.toggle("dark", isDark);
888
+ }, [isDark]);
889
+ useEffect2(() => {
890
+ const handleResize = () => {
891
+ const w = window.innerWidth;
892
+ setWide(w > 1100);
893
+ setMobile(w < 768);
894
+ };
895
+ handleResize();
896
+ window.addEventListener("resize", handleResize);
897
+ return () => window.removeEventListener("resize", handleResize);
898
+ }, []);
899
+ useEffect2(() => {
900
+ if (mobile && sbOpen) {
901
+ document.body.style.overflow = "hidden";
902
+ return () => {
903
+ document.body.style.overflow = "";
904
+ };
905
+ }
906
+ }, [mobile, sbOpen]);
907
+ useEffect2(() => {
908
+ contentRef.current?.scrollTo(0, 0);
909
+ }, [currentPageId]);
910
+ useEffect2(() => {
911
+ const el = contentRef.current;
912
+ if (!el) return;
913
+ const handler = (e) => {
914
+ const target = e.target;
915
+ if (target.tagName === "IMG" && target.closest(".tome-content")) {
916
+ setZoomSrc(target.src);
917
+ }
918
+ };
919
+ el.addEventListener("click", handler);
920
+ return () => el.removeEventListener("click", handler);
921
+ }, []);
922
+ useEffect2(() => {
923
+ const el = contentRef.current;
924
+ if (!el) return;
925
+ const handler = (e) => {
926
+ const anchor = e.target.closest("a");
927
+ if (!anchor) return;
928
+ const href = anchor.getAttribute("href");
929
+ if (!href) return;
930
+ if (href.startsWith("http://") || href.startsWith("https://") || href.startsWith("mailto:") || href.startsWith("tel:") || href.startsWith("//")) return;
931
+ if (href.startsWith("#")) return;
932
+ e.preventDefault();
933
+ let pageId = href.replace(/^\.\//, "").replace(/^\//, "").replace(/\.mdx?$/, "").replace(/\/$/, "");
934
+ if (basePath2) {
935
+ const normalized = basePath2.replace(/^\//, "").replace(/\/$/, "");
936
+ if (normalized && pageId.startsWith(normalized + "/")) {
937
+ pageId = pageId.slice(normalized.length + 1);
938
+ } else if (normalized && pageId === normalized) {
939
+ pageId = "index";
940
+ }
941
+ }
942
+ if (!pageId) pageId = "index";
943
+ onNavigate(pageId);
944
+ };
945
+ el.addEventListener("click", handler);
946
+ return () => el.removeEventListener("click", handler);
947
+ }, [onNavigate, basePath2]);
948
+ useEffect2(() => {
949
+ if (!zoomSrc) return;
950
+ const handler = (e) => {
951
+ if (e.key === "Escape") setZoomSrc(null);
952
+ };
953
+ window.addEventListener("keydown", handler);
954
+ return () => window.removeEventListener("keydown", handler);
955
+ }, [zoomSrc]);
956
+ const tocConfig = config2.toc;
957
+ const tocDepth = tocConfig?.depth ?? 3;
958
+ const tocGlobalEnabled = tocConfig?.enabled !== false;
959
+ const showToc = tocGlobalEnabled && tocEnabled;
960
+ const filteredHeadings = headings.filter((h) => h.depth <= tocDepth);
961
+ const [activeHeadingId, setActiveHeadingId] = useState2("");
962
+ useEffect2(() => {
963
+ if (!showToc || filteredHeadings.length < 2) return;
964
+ const scrollRoot = contentRef.current;
965
+ if (!scrollRoot) return;
966
+ const timerId = setTimeout(() => {
967
+ const headingElements = [];
968
+ for (const h of filteredHeadings) {
969
+ const el = scrollRoot.querySelector(`#${CSS.escape(h.id)}`);
970
+ if (el) headingElements.push(el);
971
+ }
972
+ if (headingElements.length === 0) return;
973
+ const observer = new IntersectionObserver(
974
+ (entries) => {
975
+ const visible = entries.filter((e) => e.isIntersecting).sort((a, b) => a.boundingClientRect.top - b.boundingClientRect.top);
976
+ if (visible.length > 0) {
977
+ setActiveHeadingId(visible[0].target.id);
978
+ }
979
+ },
980
+ {
981
+ root: scrollRoot,
982
+ // Trigger when heading enters the top 20% of the scroll container
983
+ rootMargin: "0px 0px -80% 0px",
984
+ threshold: 0
985
+ }
986
+ );
987
+ for (const el of headingElements) observer.observe(el);
988
+ observerRef.current = observer;
989
+ }, 100);
990
+ return () => {
991
+ clearTimeout(timerId);
992
+ observerRef.current?.disconnect();
993
+ observerRef.current = null;
994
+ };
995
+ }, [currentPageId, showToc, filteredHeadings.map((h) => h.id).join(",")]);
996
+ const observerRef = useRef2(null);
997
+ useEffect2(() => {
998
+ setActiveHeadingId("");
999
+ }, [currentPageId]);
1000
+ useLayoutEffect(() => {
1001
+ if (!htmlContentRef.current || !pageHtml) return;
1002
+ const stripped = pageHtml.replace(/<h1[^>]*>[\s\S]*?<\/h1>\s*/, "");
1003
+ htmlContentRef.current.innerHTML = stripped;
1004
+ lastHtmlRef.current = stripped;
1005
+ }, [pageHtml, currentPageId]);
1006
+ const scrollToHeading = useCallback2((e, id) => {
1007
+ e.preventDefault();
1008
+ const scrollRoot = contentRef.current;
1009
+ if (!scrollRoot) return;
1010
+ const target = scrollRoot.querySelector(`#${CSS.escape(id)}`);
1011
+ if (target) {
1012
+ target.scrollIntoView({ behavior: "smooth", block: "start" });
1013
+ setActiveHeadingId(id);
1014
+ }
1015
+ }, []);
1016
+ useEffect2(() => {
1017
+ const h = (e) => {
1018
+ if ((e.metaKey || e.ctrlKey) && e.key === "k") {
1019
+ e.preventDefault();
1020
+ setSearch(true);
1021
+ }
1022
+ if (e.key === "Escape") setSearch(false);
1023
+ };
1024
+ window.addEventListener("keydown", h);
1025
+ return () => window.removeEventListener("keydown", h);
1026
+ }, []);
1027
+ const allNavPages = navigation2.flatMap((g) => g.pages);
1028
+ const idx = allNavPages.findIndex((p) => p.id === currentPageId);
1029
+ const prev = idx > 0 ? allNavPages[idx - 1] : null;
1030
+ const next = idx < allNavPages.length - 1 ? allNavPages[idx + 1] : null;
1031
+ const breadcrumbs = getBreadcrumbs(navigation2, currentPageId, pageTitle);
1032
+ const togSec = (s) => setExpanded((p) => p.includes(s) ? p.filter((x) => x !== s) : [...p, s]);
1033
+ const cssVars = {
1034
+ "--bg": t.bg,
1035
+ "--sf": t.sf,
1036
+ "--sfH": t.sfH,
1037
+ "--bd": t.bd,
1038
+ "--tx": t.tx,
1039
+ "--tx2": t.tx2,
1040
+ "--txM": t.txM,
1041
+ "--ac": t.ac,
1042
+ "--acD": t.acD,
1043
+ "--acT": t.acT,
1044
+ "--cdBg": t.cdBg,
1045
+ "--cdTx": t.cdTx,
1046
+ "--sbBg": t.sbBg,
1047
+ "--hdBg": t.hdBg,
1048
+ "--font-heading": `"${fonts.heading}", serif`,
1049
+ "--font-body": `"${fonts.body}", sans-serif`,
1050
+ "--font-code": `"${fonts.code}", monospace`
1051
+ };
1052
+ const PageComponent = pageComponent;
1053
+ const bannerLink = config2.banner?.link;
1054
+ const bannerIsInternal = bannerLink ? bannerLink.startsWith("#") || basePath2 && bannerLink.startsWith(basePath2 + "/") : false;
1055
+ return /* @__PURE__ */ jsxs2("div", { dir, className: "tome-grain", style: { ...cssVars, color: "var(--tx)", background: "var(--bg)", fontFamily: "var(--font-body)", height: "100vh", overflow: "clip" }, children: [
1056
+ config2.banner?.text && !bannerDismissed && /* @__PURE__ */ jsxs2("div", { style: {
1057
+ display: "flex",
1058
+ alignItems: "center",
1059
+ justifyContent: "center",
1060
+ gap: 12,
1061
+ background: "var(--ac)",
1062
+ color: "#fff",
1063
+ padding: "8px 16px",
1064
+ fontSize: 13,
1065
+ fontFamily: "var(--font-body)",
1066
+ fontWeight: 500,
1067
+ textAlign: "center",
1068
+ width: "100vw",
1069
+ boxSizing: "border-box"
1070
+ }, children: [
1071
+ config2.banner.link ? /* @__PURE__ */ jsx2(
1072
+ "a",
1073
+ {
1074
+ href: bannerIsInternal && bannerLink.startsWith("#") ? basePath2 + "/" + bannerLink.slice(1) : bannerLink,
1075
+ ...bannerIsInternal ? {} : { target: "_blank", rel: "noopener noreferrer" },
1076
+ style: { color: "#fff", textDecoration: "underline" },
1077
+ onClick: bannerIsInternal ? (e) => {
1078
+ e.preventDefault();
1079
+ const bp = basePath2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1080
+ const pageId = bannerLink.startsWith("#") ? bannerLink.slice(1) : bannerLink.replace(new RegExp("^" + bp + "/?"), "");
1081
+ onNavigate(pageId || "index");
1082
+ } : void 0,
1083
+ children: config2.banner.text
1084
+ }
1085
+ ) : /* @__PURE__ */ jsx2("span", { children: config2.banner.text }),
1086
+ config2.banner.dismissible !== false && /* @__PURE__ */ jsx2(
1087
+ "button",
1088
+ {
1089
+ onClick: () => {
1090
+ setBannerDismissed(true);
1091
+ try {
1092
+ const hash = Array.from(config2.banner.text).reduce((h, c) => (h << 5) - h + c.charCodeAt(0) | 0, 0).toString(36);
1093
+ localStorage.setItem("tome-banner-dismissed", hash);
1094
+ } catch {
1095
+ }
1096
+ },
1097
+ "aria-label": "Dismiss banner",
1098
+ style: { background: "none", border: "none", color: "#fff", cursor: "pointer", fontSize: 16, lineHeight: 1, padding: 0, opacity: 0.8 },
1099
+ children: "\xD7"
1100
+ }
1101
+ )
1102
+ ] }),
1103
+ searchOpen && config2.search?.provider === "algolia" && config2.search.appId && config2.search.apiKey && config2.search.indexName ? /* @__PURE__ */ jsx2(
1104
+ AlgoliaSearchModal,
1105
+ {
1106
+ appId: config2.search.appId,
1107
+ apiKey: config2.search.apiKey,
1108
+ indexName: config2.search.indexName,
1109
+ onNavigate: (id) => {
1110
+ onNavigate(id);
1111
+ setSearch(false);
1112
+ },
1113
+ onClose: () => setSearch(false),
1114
+ basePath: basePath2
1115
+ }
1116
+ ) : searchOpen ? /* @__PURE__ */ jsx2(
1117
+ SearchModal,
1118
+ {
1119
+ allPages,
1120
+ onNavigate: (id) => {
1121
+ onNavigate(id);
1122
+ setSearch(false);
1123
+ },
1124
+ onClose: () => setSearch(false),
1125
+ mobile
1126
+ }
1127
+ ) : null,
1128
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", flexDirection: isRtl ? "row-reverse" : "row", flex: 1, height: config2.banner?.text && !bannerDismissed ? "calc(100vh - 32px)" : "100vh" }, children: [
1129
+ mobile && sbOpen && /* @__PURE__ */ jsx2("div", { onClick: () => setSb(false), style: {
1130
+ position: "fixed",
1131
+ inset: 0,
1132
+ zIndex: 200,
1133
+ background: "rgba(0,0,0,0.4)",
1134
+ backdropFilter: "blur(2px)"
1135
+ } }),
1136
+ overrides2?.Sidebar ? /* @__PURE__ */ jsx2(
1137
+ overrides2.Sidebar,
1138
+ {
1139
+ config: config2,
1140
+ navigation: navigation2,
1141
+ currentPageId,
1142
+ onNavigate,
1143
+ mobile,
1144
+ sbOpen,
1145
+ setSbOpen: setSb,
1146
+ versioning,
1147
+ currentVersion
1148
+ }
1149
+ ) : /* @__PURE__ */ jsxs2("aside", { style: {
1150
+ width: sbOpen ? 270 : 0,
1151
+ minWidth: sbOpen ? 270 : 0,
1152
+ background: "var(--sbBg)",
1153
+ [isRtl ? "borderLeft" : "borderRight"]: "1px solid var(--bd)",
1154
+ display: "flex",
1155
+ flexDirection: "column",
1156
+ transition: "width .2s, min-width .2s",
1157
+ overflow: "hidden",
1158
+ ...mobile ? { position: "fixed", top: 0, [isRtl ? "right" : "left"]: 0, bottom: 0, zIndex: 201 } : {}
1159
+ }, children: [
1160
+ /* @__PURE__ */ jsxs2("a", { href: "/", style: { padding: "18px 20px", display: "flex", alignItems: "baseline", gap: 6, borderBottom: "1px solid var(--bd)", textDecoration: "none", color: "inherit" }, children: [
1161
+ /* @__PURE__ */ jsx2("span", { style: { fontFamily: "var(--font-heading)", fontSize: 22, fontWeight: 700, fontStyle: "italic" }, children: config2.name }),
1162
+ /* @__PURE__ */ jsx2("span", { style: { width: 5, height: 5, borderRadius: "50%", background: "var(--ac)", display: "inline-block" } })
1163
+ ] }),
1164
+ /* @__PURE__ */ jsx2("div", { style: { padding: "12px 14px" }, children: /* @__PURE__ */ jsxs2("button", { onClick: () => {
1165
+ setSearch(true);
1166
+ if (mobile) setSb(false);
1167
+ }, style: {
1168
+ display: "flex",
1169
+ alignItems: "center",
1170
+ gap: 8,
1171
+ width: "100%",
1172
+ background: "var(--cdBg)",
1173
+ border: "1px solid var(--bd)",
1174
+ borderRadius: 2,
1175
+ padding: "8px 12px",
1176
+ cursor: "pointer",
1177
+ color: "var(--txM)",
1178
+ fontSize: 12.5,
1179
+ fontFamily: "var(--font-body)"
1180
+ }, children: [
1181
+ /* @__PURE__ */ jsx2(SearchIcon, {}),
1182
+ /* @__PURE__ */ jsx2("span", { style: { flex: 1, textAlign: isRtl ? "right" : "left" }, children: "Search..." }),
1183
+ /* @__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" })
1184
+ ] }) }),
1185
+ /* @__PURE__ */ jsx2("nav", { style: { flex: 1, overflow: "auto", padding: "4px 10px 20px" }, children: navigation2.map((sec) => /* @__PURE__ */ jsxs2("div", { style: { marginBottom: 8 }, children: [
1186
+ /* @__PURE__ */ jsxs2("button", { onClick: () => togSec(sec.section), style: {
1187
+ display: "flex",
1188
+ alignItems: "center",
1189
+ gap: 6,
1190
+ width: "100%",
1191
+ background: "none",
1192
+ border: "none",
1193
+ padding: "8px 10px",
1194
+ cursor: "pointer",
1195
+ borderRadius: 2,
1196
+ color: "var(--txM)",
1197
+ fontSize: 10,
1198
+ fontWeight: 600,
1199
+ textTransform: "uppercase",
1200
+ letterSpacing: ".1em",
1201
+ fontFamily: "var(--font-code)"
1202
+ }, children: [
1203
+ expanded.includes(sec.section) ? /* @__PURE__ */ jsx2(ChevDown, {}) : /* @__PURE__ */ jsx2(ChevRight, {}),
1204
+ sec.section
1205
+ ] }),
1206
+ expanded.includes(sec.section) && /* @__PURE__ */ jsx2("div", { style: { [isRtl ? "marginRight" : "marginLeft"]: 8, [isRtl ? "borderRight" : "borderLeft"]: "1px solid var(--bd)", [isRtl ? "paddingRight" : "paddingLeft"]: 0 }, children: sec.pages.map((p) => {
1207
+ const active = currentPageId === p.id;
1208
+ return /* @__PURE__ */ jsxs2("button", { onClick: () => {
1209
+ onNavigate(p.id);
1210
+ if (mobile) setSb(false);
1211
+ }, style: {
1212
+ display: "flex",
1213
+ alignItems: "center",
1214
+ gap: 10,
1215
+ width: "100%",
1216
+ textAlign: isRtl ? "right" : "left",
1217
+ background: "none",
1218
+ border: "none",
1219
+ borderRadius: 0,
1220
+ [isRtl ? "borderRight" : "borderLeft"]: active ? "2px solid var(--ac)" : "2px solid transparent",
1221
+ padding: "7px 14px",
1222
+ cursor: "pointer",
1223
+ color: active ? "var(--ac)" : "var(--tx2)",
1224
+ fontSize: 13,
1225
+ fontWeight: active ? 500 : 400,
1226
+ fontFamily: "var(--font-body)",
1227
+ transition: "all .12s"
1228
+ }, children: [
1229
+ p.title,
1230
+ p.badge && (() => {
1231
+ const badgeColors = {
1232
+ default: { bg: "var(--sf)", text: "var(--tx2)" },
1233
+ info: { bg: "rgba(59,130,246,0.15)", text: "rgb(59,130,246)" },
1234
+ success: { bg: "rgba(34,197,94,0.15)", text: "rgb(34,197,94)" },
1235
+ warning: { bg: "rgba(234,179,8,0.15)", text: "rgb(202,138,4)" },
1236
+ danger: { bg: "rgba(239,68,68,0.15)", text: "rgb(239,68,68)" }
1237
+ };
1238
+ const bc = badgeColors[p.badge.variant || "default"] || badgeColors.default;
1239
+ return /* @__PURE__ */ jsx2("span", { style: {
1240
+ fontSize: 10,
1241
+ fontWeight: 600,
1242
+ padding: "2px 6px",
1243
+ borderRadius: 4,
1244
+ marginLeft: 6,
1245
+ whiteSpace: "nowrap",
1246
+ background: bc.bg,
1247
+ color: bc.text
1248
+ }, children: p.badge.text });
1249
+ })()
1250
+ ] }, p.id);
1251
+ }) })
1252
+ ] }, sec.section)) }),
1253
+ versioning && mobile && /* @__PURE__ */ jsx2("div", { style: { padding: "8px 16px", borderTop: "1px solid var(--bd)", display: "flex", gap: 6 }, children: versioning.versions.map((v) => /* @__PURE__ */ jsxs2(
1254
+ "button",
1255
+ {
1256
+ onClick: () => {
1257
+ const targetId = v === versioning.current ? "index" : `${v}/index`;
1258
+ onNavigate(targetId);
1259
+ },
1260
+ style: {
1261
+ flex: 1,
1262
+ padding: "3px 0",
1263
+ textAlign: "center",
1264
+ background: v === (currentVersion || versioning.current) ? "var(--acD)" : "var(--sf)",
1265
+ border: "1px solid var(--bd)",
1266
+ borderRadius: 2,
1267
+ cursor: "pointer",
1268
+ color: v === (currentVersion || versioning.current) ? "var(--ac)" : "var(--tx2)",
1269
+ fontSize: 11,
1270
+ fontFamily: "var(--font-code)",
1271
+ fontWeight: v === versioning.current ? 600 : 400
1272
+ },
1273
+ children: [
1274
+ v,
1275
+ v === versioning.current ? " (latest)" : ""
1276
+ ]
1277
+ },
1278
+ v
1279
+ )) }),
1280
+ /* @__PURE__ */ jsxs2("div", { style: { padding: "12px 16px", borderTop: "1px solid var(--bd)", display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
1281
+ themeMode === "auto" ? /* @__PURE__ */ jsx2("button", { "aria-label": isDark ? "Switch to light mode" : "Switch to dark mode", 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", {}),
1282
+ /* @__PURE__ */ jsxs2("span", { style: { fontSize: 11, color: "var(--txM)", letterSpacing: 0.2 }, children: [
1283
+ "Built with ",
1284
+ "\u2661",
1285
+ " by Tome"
1286
+ ] }),
1287
+ /* @__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" })
1288
+ ] })
1289
+ ] }),
1290
+ /* @__PURE__ */ jsxs2("div", { style: { flex: 1, display: "flex", flexDirection: "column", overflow: "hidden" }, children: [
1291
+ overrides2?.Header ? /* @__PURE__ */ jsx2(
1292
+ overrides2.Header,
1293
+ {
1294
+ config: config2,
1295
+ navigation: navigation2,
1296
+ currentPageId,
1297
+ onNavigate,
1298
+ mobile,
1299
+ sbOpen,
1300
+ setSbOpen: setSb,
1301
+ isDark,
1302
+ setDark,
1303
+ versioning,
1304
+ currentVersion,
1305
+ i18n: i18n2,
1306
+ currentLocale,
1307
+ onSearchOpen: () => setSearch(true),
1308
+ basePath: basePath2
1309
+ }
1310
+ ) : /* @__PURE__ */ jsxs2("header", { style: {
1311
+ display: "flex",
1312
+ alignItems: "center",
1313
+ gap: mobile ? 8 : 12,
1314
+ padding: mobile ? "8px 12px" : "10px 24px",
1315
+ borderBottom: "1px solid var(--bd)",
1316
+ background: "var(--hdBg)",
1317
+ backdropFilter: "blur(12px)",
1318
+ maxWidth: "100vw",
1319
+ overflow: "visible",
1320
+ position: "relative",
1321
+ zIndex: 200
1322
+ }, children: [
1323
+ /* @__PURE__ */ jsx2("button", { "aria-label": sbOpen ? "Close sidebar" : "Open sidebar", onClick: () => setSb(!sbOpen), style: { background: "none", border: "none", color: "var(--txM)", cursor: "pointer", display: "flex" }, children: sbOpen ? /* @__PURE__ */ jsx2(XIcon, {}) : /* @__PURE__ */ jsx2(MenuIcon, {}) }),
1324
+ mobile ? /* @__PURE__ */ jsx2("span", { style: { fontSize: 13, color: "var(--ac)", fontFamily: "var(--font-code)", flex: 1, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: navigation2.flatMap((s) => s.pages).find((p) => p.id === currentPageId)?.title || "" }) : /* @__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) => {
1325
+ const f = s.pages.find((p) => p.id === currentPageId);
1326
+ if (!f) return null;
1327
+ return /* @__PURE__ */ jsxs2("span", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
1328
+ /* @__PURE__ */ jsx2("span", { children: s.section }),
1329
+ /* @__PURE__ */ jsx2(ChevRight, {}),
1330
+ /* @__PURE__ */ jsx2("span", { style: { color: "var(--ac)" }, children: f.title })
1331
+ ] }, s.section);
1332
+ }) }),
1333
+ config2.topNav && config2.topNav.length > 0 && !mobile && /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", gap: 12 }, children: [
1334
+ config2.topNav.map((link) => {
1335
+ const isInternal = link.href.startsWith("#") || basePath2 && link.href.startsWith(basePath2 + "/");
1336
+ const isExternal = !isInternal;
1337
+ return /* @__PURE__ */ jsxs2(
1338
+ "a",
1339
+ {
1340
+ href: isInternal && link.href.startsWith("#") ? basePath2 + "/" + link.href.slice(1) : link.href,
1341
+ ...isExternal ? { target: "_blank", rel: "noopener noreferrer" } : {},
1342
+ onClick: isInternal ? (e) => {
1343
+ e.preventDefault();
1344
+ const pageId = link.href.startsWith("#") ? link.href.slice(1) : link.href.replace(new RegExp("^" + basePath2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + "/?"), "");
1345
+ onNavigate(pageId);
1346
+ } : void 0,
1347
+ style: {
1348
+ display: "flex",
1349
+ alignItems: "center",
1350
+ gap: 4,
1351
+ color: "var(--txM)",
1352
+ textDecoration: "none",
1353
+ fontSize: 12,
1354
+ fontFamily: "var(--font-body)",
1355
+ fontWeight: 500,
1356
+ transition: "color .15s"
1357
+ },
1358
+ onMouseOver: (e) => e.currentTarget.style.color = "var(--ac)",
1359
+ onMouseOut: (e) => e.currentTarget.style.color = "var(--txM)",
1360
+ children: [
1361
+ link.label,
1362
+ isExternal && /* @__PURE__ */ jsx2(ExtLinkIcon, {})
1363
+ ]
1364
+ },
1365
+ link.label
1366
+ );
1367
+ }),
1368
+ /* @__PURE__ */ jsx2("span", { style: { width: 1, height: 16, background: "var(--bd)" } })
1369
+ ] }),
1370
+ config2.socialLinks && config2.socialLinks.length > 0 && !mobile && /* @__PURE__ */ jsx2("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: config2.socialLinks.map((link) => /* @__PURE__ */ jsx2(
1371
+ "a",
1372
+ {
1373
+ href: link.url,
1374
+ target: "_blank",
1375
+ rel: "noopener noreferrer",
1376
+ "aria-label": link.label || link.platform,
1377
+ "data-testid": `social-link-${link.platform}`,
1378
+ style: {
1379
+ display: "flex",
1380
+ alignItems: "center",
1381
+ justifyContent: "center",
1382
+ color: "var(--tx2)",
1383
+ cursor: "pointer",
1384
+ transition: "color .15s"
1385
+ },
1386
+ onMouseOver: (e) => e.currentTarget.style.color = "var(--tx)",
1387
+ onMouseOut: (e) => e.currentTarget.style.color = "var(--tx2)",
1388
+ children: /* @__PURE__ */ jsx2(SocialIcon, { platform: link.platform, customIcon: link.icon })
1389
+ },
1390
+ link.url
1391
+ )) }),
1392
+ mobile && themeMode === "auto" && /* @__PURE__ */ jsx2("button", { "aria-label": isDark ? "Switch to light mode" : "Switch to dark mode", onClick: () => setDark((d) => !d), style: { background: "none", border: "none", color: "var(--txM)", cursor: "pointer", display: "flex", flexShrink: 0 }, children: isDark ? /* @__PURE__ */ jsx2(SunIcon, {}) : /* @__PURE__ */ jsx2(MoonIcon, {}) }),
1393
+ versioning && !mobile && /* @__PURE__ */ jsxs2("div", { style: { position: "relative" }, children: [
1394
+ /* @__PURE__ */ jsxs2(
1395
+ "button",
1396
+ {
1397
+ "data-testid": "version-switcher",
1398
+ onClick: () => setVersionDropdown((o) => !o),
1399
+ style: {
1400
+ display: "flex",
1401
+ alignItems: "center",
1402
+ gap: 6,
1403
+ background: "var(--sf)",
1404
+ border: "1px solid var(--bd)",
1405
+ borderRadius: 2,
1406
+ padding: "5px 10px",
1407
+ cursor: "pointer",
1408
+ color: "var(--tx2)",
1409
+ fontSize: 12,
1410
+ fontFamily: "var(--font-code)"
1411
+ },
1412
+ children: [
1413
+ /* @__PURE__ */ jsx2(VersionIcon, {}),
1414
+ currentVersion || versioning.current,
1415
+ /* @__PURE__ */ jsx2(ChevDown, {})
1416
+ ]
1417
+ }
1418
+ ),
1419
+ versionDropdownOpen && /* @__PURE__ */ jsx2(
1420
+ "div",
1421
+ {
1422
+ "data-testid": "version-dropdown",
1423
+ style: {
1424
+ position: "absolute",
1425
+ top: "100%",
1426
+ right: 0,
1427
+ marginTop: 4,
1428
+ background: "var(--sf)",
1429
+ border: "1px solid var(--bd)",
1430
+ borderRadius: 2,
1431
+ boxShadow: "0 8px 32px rgba(0,0,0,0.2)",
1432
+ overflow: "hidden",
1433
+ zIndex: 100,
1434
+ minWidth: 120
1435
+ },
1436
+ children: versioning.versions.map((v) => /* @__PURE__ */ jsxs2(
1437
+ "button",
1438
+ {
1439
+ onClick: () => {
1440
+ setVersionDropdown(false);
1441
+ const targetId = v === versioning.current ? "index" : `${v}/index`;
1442
+ onNavigate(targetId);
1443
+ },
1444
+ style: {
1445
+ display: "block",
1446
+ width: "100%",
1447
+ textAlign: "left",
1448
+ background: v === (currentVersion || versioning.current) ? "var(--acD)" : "none",
1449
+ border: "none",
1450
+ padding: "8px 14px",
1451
+ cursor: "pointer",
1452
+ color: v === (currentVersion || versioning.current) ? "var(--ac)" : "var(--tx2)",
1453
+ fontSize: 12,
1454
+ fontFamily: "var(--font-code)",
1455
+ fontWeight: v === versioning.current ? 600 : 400
1456
+ },
1457
+ children: [
1458
+ v,
1459
+ v === versioning.current ? " (latest)" : ""
1460
+ ]
1461
+ },
1462
+ v
1463
+ ))
1464
+ }
1465
+ )
1466
+ ] }),
1467
+ i18n2 && i18n2.locales.length > 1 && !mobile && /* @__PURE__ */ jsxs2("div", { style: { position: "relative" }, children: [
1468
+ /* @__PURE__ */ jsxs2(
1469
+ "button",
1470
+ {
1471
+ "data-testid": "language-switcher",
1472
+ onClick: () => setLocaleDropdown((o) => !o),
1473
+ style: {
1474
+ display: "flex",
1475
+ alignItems: "center",
1476
+ gap: 6,
1477
+ background: "var(--sf)",
1478
+ border: "1px solid var(--bd)",
1479
+ borderRadius: 2,
1480
+ padding: "5px 10px",
1481
+ cursor: "pointer",
1482
+ color: "var(--tx2)",
1483
+ fontSize: 12,
1484
+ fontFamily: "var(--font-body)"
1485
+ },
1486
+ children: [
1487
+ /* @__PURE__ */ jsx2(GlobeIcon, {}),
1488
+ i18n2.localeNames?.[currentLocale || i18n2.defaultLocale] || currentLocale || i18n2.defaultLocale,
1489
+ /* @__PURE__ */ jsx2(ChevDown, {})
1490
+ ]
1491
+ }
1492
+ ),
1493
+ localeDropdownOpen && /* @__PURE__ */ jsx2(
1494
+ "div",
1495
+ {
1496
+ "data-testid": "language-dropdown",
1497
+ style: {
1498
+ position: "absolute",
1499
+ top: "100%",
1500
+ right: 0,
1501
+ marginTop: 4,
1502
+ background: "var(--sf)",
1503
+ border: "1px solid var(--bd)",
1504
+ borderRadius: 2,
1505
+ boxShadow: "0 8px 32px rgba(0,0,0,0.2)",
1506
+ overflow: "hidden",
1507
+ zIndex: 100,
1508
+ minWidth: 120
1509
+ },
1510
+ children: i18n2.locales.map((locale) => {
1511
+ const isActive = locale === (currentLocale || i18n2.defaultLocale);
1512
+ const displayName = i18n2.localeNames?.[locale] || locale;
1513
+ const activeLocale = currentLocale || i18n2.defaultLocale;
1514
+ let basePageId = currentPageId;
1515
+ if (activeLocale !== i18n2.defaultLocale && currentPageId.startsWith(`${activeLocale}/`)) {
1516
+ basePageId = currentPageId.slice(activeLocale.length + 1);
1517
+ }
1518
+ const targetId = locale === i18n2.defaultLocale ? basePageId : `${locale}/${basePageId}`;
1519
+ return /* @__PURE__ */ jsx2(
1520
+ "button",
1521
+ {
1522
+ onClick: () => {
1523
+ setLocaleDropdown(false);
1524
+ onNavigate(targetId);
1525
+ },
1526
+ style: {
1527
+ display: "block",
1528
+ width: "100%",
1529
+ textAlign: "left",
1530
+ background: isActive ? "var(--acD)" : "none",
1531
+ border: "none",
1532
+ padding: "8px 14px",
1533
+ cursor: "pointer",
1534
+ color: isActive ? "var(--ac)" : "var(--tx2)",
1535
+ fontSize: 12,
1536
+ fontFamily: "var(--font-body)",
1537
+ fontWeight: isActive ? 600 : 400
1538
+ },
1539
+ children: displayName
1540
+ },
1541
+ locale
1542
+ );
1543
+ })
1544
+ }
1545
+ )
1546
+ ] })
1547
+ ] }),
1548
+ isOldVersion && /* @__PURE__ */ jsxs2(
1549
+ "div",
1550
+ {
1551
+ "data-testid": "old-version-banner",
1552
+ style: {
1553
+ display: "flex",
1554
+ alignItems: "center",
1555
+ justifyContent: "center",
1556
+ gap: 8,
1557
+ background: "var(--acD)",
1558
+ borderBottom: "1px solid var(--bd)",
1559
+ padding: "8px 24px",
1560
+ fontSize: 13,
1561
+ color: "var(--tx2)"
1562
+ },
1563
+ children: [
1564
+ /* @__PURE__ */ jsxs2("span", { children: [
1565
+ "You're viewing docs for ",
1566
+ currentVersion,
1567
+ "."
1568
+ ] }),
1569
+ /* @__PURE__ */ jsx2(
1570
+ "button",
1571
+ {
1572
+ onClick: () => {
1573
+ onNavigate("index");
1574
+ },
1575
+ style: {
1576
+ background: "none",
1577
+ border: "none",
1578
+ color: "var(--ac)",
1579
+ cursor: "pointer",
1580
+ fontWeight: 600,
1581
+ fontSize: 13,
1582
+ fontFamily: "var(--font-body)",
1583
+ textDecoration: "underline"
1584
+ },
1585
+ children: "Switch to latest."
1586
+ }
1587
+ )
1588
+ ]
1589
+ }
1590
+ ),
1591
+ /* @__PURE__ */ jsxs2("div", { ref: contentRef, style: { flex: 1, overflow: "auto", display: "flex" }, children: [
1592
+ /* @__PURE__ */ jsxs2("main", { style: { flex: 1, maxWidth: mobile ? "100%" : 760, padding: mobile ? "24px 16px 60px" : "40px 48px 80px", margin: "0 auto", minWidth: 0 }, children: [
1593
+ breadcrumbs.length > 0 && /* @__PURE__ */ jsx2("nav", { "aria-label": "Breadcrumbs", "data-testid": "breadcrumbs", style: {
1594
+ display: "flex",
1595
+ alignItems: "center",
1596
+ gap: 6,
1597
+ fontSize: 13,
1598
+ color: "var(--tx2)",
1599
+ marginBottom: 8
1600
+ }, children: breadcrumbs.map((crumb, i) => /* @__PURE__ */ jsxs2(React2.Fragment, { children: [
1601
+ i > 0 && /* @__PURE__ */ jsx2("span", { style: { color: "var(--tx2)", opacity: 0.5 }, children: "\u203A" }),
1602
+ i < breadcrumbs.length - 1 && crumb.href !== null ? /* @__PURE__ */ jsx2(
1603
+ "a",
1604
+ {
1605
+ href: crumb.href,
1606
+ onClick: (e) => {
1607
+ e.preventDefault();
1608
+ const page = navigation2.flatMap((s) => s.pages).find((p) => p.urlPath === crumb.href);
1609
+ if (page) onNavigate(page.id);
1610
+ },
1611
+ style: { color: "var(--tx2)", textDecoration: "none", cursor: "pointer" },
1612
+ children: crumb.label
1613
+ }
1614
+ ) : /* @__PURE__ */ jsx2("span", { style: i === breadcrumbs.length - 1 ? { color: "var(--tx)" } : void 0, children: crumb.label })
1615
+ ] }, i)) }),
1616
+ /* @__PURE__ */ jsx2("h1", { style: { fontFamily: "var(--font-heading)", fontSize: mobile ? 26 : 38, fontWeight: 400, fontStyle: "italic", lineHeight: 1.15, marginBottom: 8 }, children: pageTitle }),
1617
+ isDraft && /* @__PURE__ */ jsx2("div", { "data-testid": "draft-banner", style: { background: "#fef3c7", color: "#92400e", padding: "8px 16px", borderRadius: 6, fontSize: 13, marginBottom: 16 }, children: "Draft \u2014 This page is only visible in development" }),
1618
+ pageDescription && /* @__PURE__ */ jsx2("p", { style: { fontSize: 16, color: "var(--tx2)", lineHeight: 1.6, marginBottom: 32 }, children: pageDescription }),
1619
+ /* @__PURE__ */ jsx2("div", { style: { borderTop: "1px solid var(--bd)", paddingTop: 28 }, children: apiManifest && ApiReferenceComponent ? /* @__PURE__ */ jsx2(ApiReferenceComponent, { manifest: apiManifest, baseUrl: apiBaseUrl, showPlayground: apiPlayground, playgroundAuth: apiAuth }) : (
1620
+ /* TOM-49: Changelog page type */
1621
+ changelogEntries && changelogEntries.length > 0 ? /* @__PURE__ */ jsx2(ChangelogView, { entries: changelogEntries }) : PageComponent ? /* @__PURE__ */ jsx2("div", { className: "tome-content", children: /* @__PURE__ */ jsx2(PageComponent, { components: mdxComponents || {} }) }) : /* @__PURE__ */ jsx2(
1622
+ "div",
1623
+ {
1624
+ className: "tome-content",
1625
+ ref: htmlContentRef
1626
+ },
1627
+ currentPageId
1628
+ )
1629
+ ) }),
1630
+ overrides2?.PageFooter ? /* @__PURE__ */ jsx2(
1631
+ overrides2.PageFooter,
1632
+ {
1633
+ editUrl,
1634
+ lastUpdated,
1635
+ currentPageId,
1636
+ prev,
1637
+ next,
1638
+ onNavigate,
1639
+ mobile
1640
+ }
1641
+ ) : /* @__PURE__ */ jsxs2(Fragment, { children: [
1642
+ (editUrl || lastUpdated) && /* @__PURE__ */ jsxs2("div", { style: { marginTop: 40, display: "flex", flexDirection: mobile ? "column" : "row", alignItems: mobile ? "flex-start" : "center", justifyContent: "space-between", gap: mobile ? 8 : 16 }, children: [
1643
+ editUrl && /* @__PURE__ */ jsx2("div", { "data-testid": "edit-page-link", children: /* @__PURE__ */ jsxs2(
1644
+ "a",
1645
+ {
1646
+ href: editUrl,
1647
+ target: "_blank",
1648
+ rel: "noopener noreferrer",
1649
+ style: {
1650
+ display: "inline-flex",
1651
+ alignItems: "center",
1652
+ gap: 6,
1653
+ color: "var(--txM)",
1654
+ textDecoration: "none",
1655
+ fontSize: 13,
1656
+ fontFamily: "var(--font-body)",
1657
+ transition: "color .15s"
1658
+ },
1659
+ onMouseOver: (e) => e.currentTarget.style.color = "var(--ac)",
1660
+ onMouseOut: (e) => e.currentTarget.style.color = "var(--txM)",
1661
+ children: [
1662
+ /* @__PURE__ */ jsx2(PencilIcon, {}),
1663
+ " Edit this page on GitHub"
1664
+ ]
1665
+ }
1666
+ ) }),
1667
+ lastUpdated && /* @__PURE__ */ jsxs2("div", { "data-testid": "last-updated", style: { fontSize: 12, color: "var(--txM)", fontFamily: "var(--font-body)" }, children: [
1668
+ "Last updated ",
1669
+ formatRelativeDate(lastUpdated)
1670
+ ] })
1671
+ ] }),
1672
+ /* @__PURE__ */ jsx2("div", { style: { display: "flex", alignItems: "center", gap: 12, marginTop: 24, padding: "12px 0" }, children: feedbackGiven[currentPageId] ? /* @__PURE__ */ jsx2("span", { style: { fontSize: 13, color: "var(--txM)", fontFamily: "var(--font-body)" }, children: "Thanks for your feedback!" }) : /* @__PURE__ */ jsxs2(Fragment, { children: [
1673
+ /* @__PURE__ */ jsx2("span", { style: { fontSize: 13, color: "var(--txM)", fontFamily: "var(--font-body)" }, children: "Was this helpful?" }),
1674
+ /* @__PURE__ */ jsx2("button", { onClick: () => {
1675
+ setFeedbackGiven((prev2) => ({ ...prev2, [currentPageId]: true }));
1676
+ try {
1677
+ localStorage.setItem(`tome-feedback-${currentPageId}`, "up");
1678
+ } catch {
1679
+ }
1680
+ }, style: {
1681
+ background: "none",
1682
+ border: "1px solid var(--bd)",
1683
+ borderRadius: 2,
1684
+ padding: "4px 10px",
1685
+ cursor: "pointer",
1686
+ fontSize: 13,
1687
+ color: "var(--txM)",
1688
+ transition: "border-color .15s"
1689
+ }, children: "\u{1F44D}" }),
1690
+ /* @__PURE__ */ jsx2("button", { onClick: () => {
1691
+ setFeedbackGiven((prev2) => ({ ...prev2, [currentPageId]: true }));
1692
+ try {
1693
+ localStorage.setItem(`tome-feedback-${currentPageId}`, "down");
1694
+ } catch {
1695
+ }
1696
+ }, style: {
1697
+ background: "none",
1698
+ border: "1px solid var(--bd)",
1699
+ borderRadius: 2,
1700
+ padding: "4px 10px",
1701
+ cursor: "pointer",
1702
+ fontSize: 13,
1703
+ color: "var(--txM)",
1704
+ transition: "border-color .15s"
1705
+ }, children: "\u{1F44E}" })
1706
+ ] }) }),
1707
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", flexDirection: mobile ? "column" : "row", justifyContent: "space-between", marginTop: 16, paddingTop: 24, borderTop: "1px solid var(--bd)", gap: mobile ? 12 : 16 }, children: [
1708
+ prev ? /* @__PURE__ */ jsxs2("button", { onClick: () => onNavigate(prev.id), style: {
1709
+ display: "flex",
1710
+ alignItems: "center",
1711
+ gap: 8,
1712
+ background: "none",
1713
+ border: "1px solid var(--bd)",
1714
+ borderRadius: 2,
1715
+ padding: "10px 16px",
1716
+ cursor: "pointer",
1717
+ color: "var(--tx2)",
1718
+ fontSize: 13,
1719
+ fontFamily: "var(--font-body)",
1720
+ transition: "border-color .15s, color .15s"
1721
+ }, children: [
1722
+ isRtl ? /* @__PURE__ */ jsx2(ArrowRight, {}) : /* @__PURE__ */ jsx2(ArrowLeft, {}),
1723
+ " ",
1724
+ prev.title
1725
+ ] }) : /* @__PURE__ */ jsx2("div", {}),
1726
+ next ? /* @__PURE__ */ jsxs2("button", { onClick: () => onNavigate(next.id), style: {
1727
+ display: "flex",
1728
+ alignItems: "center",
1729
+ gap: 8,
1730
+ background: "none",
1731
+ border: "1px solid var(--bd)",
1732
+ borderRadius: 2,
1733
+ padding: "10px 16px",
1734
+ cursor: "pointer",
1735
+ color: "var(--tx2)",
1736
+ fontSize: 13,
1737
+ fontFamily: "var(--font-body)",
1738
+ transition: "border-color .15s, color .15s"
1739
+ }, children: [
1740
+ next.title,
1741
+ " ",
1742
+ isRtl ? /* @__PURE__ */ jsx2(ArrowLeft, {}) : /* @__PURE__ */ jsx2(ArrowRight, {})
1743
+ ] }) : /* @__PURE__ */ jsx2("div", {})
1744
+ ] })
1745
+ ] })
1746
+ ] }),
1747
+ overrides2?.Toc ? showToc && filteredHeadings.length >= 2 && wide && /* @__PURE__ */ jsx2(
1748
+ overrides2.Toc,
1749
+ {
1750
+ headings: filteredHeadings,
1751
+ activeHeadingId,
1752
+ onScrollToHeading: scrollToHeading
1753
+ }
1754
+ ) : showToc && filteredHeadings.length >= 2 && wide && /* @__PURE__ */ jsxs2("aside", { "data-testid": "toc-sidebar", style: { width: 200, padding: isRtl ? "40px 0 40px 16px" : "40px 16px 40px 0", position: "sticky", top: 0, alignSelf: "flex-start", flexShrink: 0 }, children: [
1755
+ /* @__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" }),
1756
+ /* @__PURE__ */ jsx2("nav", { "aria-label": "Table of contents", style: { [isRtl ? "borderRight" : "borderLeft"]: "1px solid var(--bd)", [isRtl ? "paddingRight" : "paddingLeft"]: 0 }, children: filteredHeadings.map((h, i) => {
1757
+ const isActive = activeHeadingId === h.id;
1758
+ return /* @__PURE__ */ jsx2(
1759
+ "a",
1760
+ {
1761
+ href: `#${h.id}`,
1762
+ onClick: (e) => scrollToHeading(e, h.id),
1763
+ "data-testid": `toc-link-${h.id}`,
1764
+ style: {
1765
+ display: "block",
1766
+ fontSize: 12,
1767
+ color: isActive ? "var(--ac)" : "var(--txM)",
1768
+ fontWeight: isActive ? 500 : 400,
1769
+ textDecoration: "none",
1770
+ padding: "4px 12px",
1771
+ [isRtl ? "paddingRight" : "paddingLeft"]: 12 + (h.depth - 2) * 12,
1772
+ lineHeight: 1.4,
1773
+ transition: "color .15s, font-weight .15s",
1774
+ [isRtl ? "borderRight" : "borderLeft"]: isActive ? "2px solid var(--ac)" : "2px solid transparent",
1775
+ [isRtl ? "marginRight" : "marginLeft"]: -1
1776
+ },
1777
+ children: h.text
1778
+ },
1779
+ i
1780
+ );
1781
+ }) })
1782
+ ] })
1783
+ ] })
1784
+ ] })
1785
+ ] }),
1786
+ overrides2?.Footer && /* @__PURE__ */ jsx2(
1787
+ overrides2.Footer,
1788
+ {
1789
+ config: config2,
1790
+ navigation: navigation2,
1791
+ currentPageId,
1792
+ onNavigate
1793
+ }
1794
+ ),
1795
+ config2.ai?.enabled && /* @__PURE__ */ jsx2(
1796
+ AiChat,
1797
+ {
1798
+ provider: config2.ai.provider || "anthropic",
1799
+ model: config2.ai.model,
1800
+ apiKey: typeof __TOME_AI_API_KEY__ !== "undefined" && __TOME_AI_API_KEY__ ? __TOME_AI_API_KEY__ : void 0,
1801
+ context: docContext2?.map((d) => `## ${d.title}
1802
+ ${d.content}`).join("\n\n") ?? allPages.map((p) => `- ${p.title}${p.description ? ": " + p.description : ""}`).join("\n")
1803
+ }
1804
+ ),
1805
+ zoomSrc && /* @__PURE__ */ jsx2("div", { onClick: () => setZoomSrc(null), style: {
1806
+ position: "fixed",
1807
+ inset: 0,
1808
+ zIndex: 9999,
1809
+ display: "flex",
1810
+ alignItems: "center",
1811
+ justifyContent: "center",
1812
+ background: "rgba(0,0,0,0.7)",
1813
+ backdropFilter: "blur(8px)",
1814
+ cursor: "zoom-out"
1815
+ }, children: /* @__PURE__ */ jsx2("img", { src: zoomSrc, alt: "", style: { maxWidth: "90vw", maxHeight: "90vh", objectFit: "contain", borderRadius: 4, boxShadow: "0 16px 64px rgba(0,0,0,0.4)" } }) })
1816
+ ] });
1817
+ }
1818
+ function SearchModal({ allPages, onNavigate, onClose, mobile }) {
1819
+ const [q, setQ] = useState2("");
1820
+ const [results, setResults] = useState2([]);
1821
+ const [selected, setSelected] = useState2(0);
1822
+ const [pagefindReady, setPagefindReady] = useState2(null);
1823
+ const inputRef = useRef2(null);
1824
+ const debounceRef = useRef2(void 0);
1825
+ useEffect2(() => {
1826
+ initPagefind().then((pf) => setPagefindReady(!!pf));
1827
+ setTimeout(() => inputRef.current?.focus(), 50);
1828
+ }, []);
1829
+ const fallbackSearch = useCallback2((query) => {
1830
+ if (!query.trim()) return [];
1831
+ const ql = query.toLowerCase();
1832
+ 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 }));
1833
+ }, [allPages]);
1834
+ const doSearch = useCallback2(async (query) => {
1835
+ if (!query.trim()) {
1836
+ setResults([]);
1837
+ setSelected(0);
1838
+ return;
1839
+ }
1840
+ const pf = pagefindInstance;
1841
+ if (pf) {
1842
+ try {
1843
+ const search = await pf.search(query);
1844
+ const items = [];
1845
+ for (const result of search.results.slice(0, 8)) {
1846
+ const data = await result.data();
1847
+ const url = data.url || "";
1848
+ const id = url.replace(/^\//, "").replace(/\/index\.html$/, "").replace(/\.html$/, "") || "index";
1849
+ items.push({
1850
+ id,
1851
+ title: data.meta?.title || id,
1852
+ excerpt: data.excerpt || void 0
1853
+ });
1854
+ }
1855
+ setResults(items);
1856
+ setSelected(0);
1857
+ return;
1858
+ } catch {
1859
+ }
1860
+ }
1861
+ setResults(fallbackSearch(query));
1862
+ setSelected(0);
1863
+ }, [fallbackSearch]);
1864
+ useEffect2(() => {
1865
+ if (debounceRef.current) clearTimeout(debounceRef.current);
1866
+ debounceRef.current = setTimeout(() => doSearch(q), 120);
1867
+ return () => {
1868
+ if (debounceRef.current) clearTimeout(debounceRef.current);
1869
+ };
1870
+ }, [q, doSearch]);
1871
+ const handleKeyDown = useCallback2((e) => {
1872
+ if (e.key === "ArrowDown") {
1873
+ e.preventDefault();
1874
+ setSelected((i) => Math.min(i + 1, results.length - 1));
1875
+ } else if (e.key === "ArrowUp") {
1876
+ e.preventDefault();
1877
+ setSelected((i) => Math.max(i - 1, 0));
1878
+ } else if (e.key === "Enter" && results.length > 0) {
1879
+ e.preventDefault();
1880
+ onNavigate(results[selected].id);
1881
+ }
1882
+ }, [results, selected, onNavigate]);
1883
+ return /* @__PURE__ */ jsx2("div", { onClick: onClose, style: {
1884
+ position: "fixed",
1885
+ inset: 0,
1886
+ zIndex: 1e3,
1887
+ background: "rgba(0,0,0,0.55)",
1888
+ backdropFilter: "blur(6px)",
1889
+ display: "flex",
1890
+ alignItems: mobile ? "stretch" : "flex-start",
1891
+ justifyContent: "center",
1892
+ paddingTop: mobile ? 0 : "12vh"
1893
+ }, children: /* @__PURE__ */ jsxs2("div", { onClick: (e) => e.stopPropagation(), style: {
1894
+ background: "var(--sf)",
1895
+ border: mobile ? "none" : "1px solid var(--bd)",
1896
+ borderRadius: mobile ? 0 : 2,
1897
+ width: "100%",
1898
+ maxWidth: mobile ? "100%" : 520,
1899
+ boxShadow: mobile ? "none" : "0 24px 80px rgba(0,0,0,0.4)",
1900
+ overflow: "hidden",
1901
+ display: "flex",
1902
+ flexDirection: "column",
1903
+ ...mobile ? { height: "100%" } : {}
1904
+ }, children: [
1905
+ /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", gap: 10, padding: "14px 18px", borderBottom: "1px solid var(--bd)" }, children: [
1906
+ /* @__PURE__ */ jsx2(SearchIcon, {}),
1907
+ /* @__PURE__ */ jsx2(
1908
+ "input",
1909
+ {
1910
+ ref: inputRef,
1911
+ value: q,
1912
+ onChange: (e) => setQ(e.target.value),
1913
+ onKeyDown: handleKeyDown,
1914
+ placeholder: "Search documentation...",
1915
+ style: { flex: 1, background: "none", border: "none", outline: "none", color: "var(--tx)", fontSize: 15, fontFamily: "var(--font-body)" }
1916
+ }
1917
+ ),
1918
+ /* @__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" })
1919
+ ] }),
1920
+ results.length > 0 && /* @__PURE__ */ jsx2("div", { style: { padding: 6, maxHeight: mobile ? "none" : 360, overflow: "auto", flex: mobile ? 1 : void 0 }, children: results.map((r, i) => /* @__PURE__ */ jsxs2(
1921
+ "button",
1922
+ {
1923
+ onClick: () => onNavigate(r.id),
1924
+ style: {
1925
+ display: "block",
1926
+ width: "100%",
1927
+ textAlign: "left",
1928
+ background: i === selected ? "var(--acD)" : "none",
1929
+ border: "none",
1930
+ borderRadius: 2,
1931
+ padding: "10px 14px",
1932
+ cursor: "pointer",
1933
+ color: "var(--tx)",
1934
+ fontFamily: "var(--font-body)"
1935
+ },
1936
+ onMouseEnter: () => setSelected(i),
1937
+ children: [
1938
+ /* @__PURE__ */ jsx2("div", { style: { fontWeight: 500, fontSize: 14, marginBottom: 2 }, children: r.title }),
1939
+ r.excerpt && /* @__PURE__ */ jsx2("div", { style: {
1940
+ fontSize: 12,
1941
+ color: "var(--txM)",
1942
+ lineHeight: 1.3
1943
+ }, dangerouslySetInnerHTML: { __html: r.excerpt } })
1944
+ ]
1945
+ },
1946
+ r.id + i
1947
+ )) }),
1948
+ q && !results.length && /* @__PURE__ */ jsx2("div", { style: { padding: "32px 18px", textAlign: "center", color: "var(--txM)", fontSize: 14 }, children: "No results found" }),
1949
+ 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." })
1950
+ ] }) });
1951
+ }
1952
+
1953
+ // src/routing.ts
1954
+ function pathnameToPageId(pathname, basePath2, routes2) {
1955
+ let relative = pathname;
1956
+ if (basePath2 && relative.startsWith(basePath2)) {
1957
+ relative = relative.slice(basePath2.length);
1958
+ }
1959
+ const id = relative.replace(/^\//, "").replace(/\/index\.html$/, "").replace(/\.html$/, "").replace(/\/$/, "") || "index";
1960
+ const route = routes2.find((r) => r.id === id);
1961
+ return route ? id : null;
1962
+ }
1963
+ function pageIdToPath(id, basePath2, routes2) {
1964
+ const route = routes2.find((r) => r.id === id);
1965
+ if (route) return basePath2 + route.urlPath;
1966
+ return basePath2 + "/" + id;
1967
+ }
1968
+
1969
+ // src/entry-helpers.ts
1970
+ var PageNotFoundError = class extends Error {
1971
+ code = "PAGE_NOT_FOUND";
1972
+ constructor(pageId) {
1973
+ super(`Page not found: ${pageId}`);
1974
+ this.name = "PageNotFoundError";
1975
+ }
1976
+ };
1977
+ var PageLoadError = class extends Error {
1978
+ code = "PAGE_LOAD_ERROR";
1979
+ constructor(pageId, cause) {
1980
+ super(`Failed to load page: ${pageId}`);
1981
+ this.name = "PageLoadError";
1982
+ if (cause) this.cause = cause;
1983
+ }
1984
+ };
1985
+ function computeEditUrl(editLink, filePath) {
1986
+ if (!editLink || !filePath) return void 0;
1987
+ const { repo, branch = "main", dir = "" } = editLink;
1988
+ const dirPrefix = dir ? `${dir.replace(/\/$/, "")}/` : "";
1989
+ return `https://github.com/${repo}/edit/${branch}/${dirPrefix}${filePath}`;
1990
+ }
1991
+ function resolveInitialPageId(pathname, hash, routes2, basePath2, pathnameToPageIdFn) {
1992
+ const resolved = pathnameToPageIdFn(pathname, basePath2, routes2);
1993
+ if (resolved) return resolved;
1994
+ const hashId = hash.startsWith("#") ? hash.slice(1) : hash;
1995
+ if (hashId && routes2.some((r) => r.id === hashId)) return hashId;
1996
+ return routes2[0]?.id || "index";
1997
+ }
1998
+ async function loadPage(id, routes2, loadPageModule2) {
1999
+ const route = routes2.find((r) => r.id === id);
2000
+ let mod;
2001
+ try {
2002
+ mod = await loadPageModule2(id);
2003
+ } catch (err) {
2004
+ throw new PageLoadError(id, err);
2005
+ }
2006
+ if (route?.isMdx && mod.meta) {
2007
+ return {
2008
+ isMdx: true,
2009
+ component: mod.default,
2010
+ frontmatter: mod.meta.frontmatter,
2011
+ headings: mod.meta.headings
2012
+ };
2013
+ }
2014
+ if (!mod.default) throw new PageNotFoundError(id);
2015
+ if (mod.isApiReference && mod.apiManifest) {
2016
+ return { isMdx: false, isApiReference: true, ...mod.default, apiManifest: mod.apiManifest };
2017
+ }
2018
+ if (mod.isChangelog && mod.changelogEntries) {
2019
+ return { isMdx: false, ...mod.default, changelogEntries: mod.changelogEntries };
2020
+ }
2021
+ return { isMdx: false, ...mod.default };
2022
+ }
2023
+ function detectCurrentVersion(currentRoute, versions2) {
2024
+ return currentRoute?.version || (versions2?.current ?? void 0);
2025
+ }
2026
+
2027
+ // src/entry.tsx
2028
+ import config from "virtual:tome/config";
2029
+ import { routes, navigation, versions, i18n } from "virtual:tome/routes";
2030
+ import loadPageModule from "virtual:tome/page-loader";
2031
+ import docContext from "virtual:tome/doc-context";
2032
+ import overrides from "virtual:tome/overrides";
2033
+ import {
2034
+ Callout,
2035
+ Tabs,
2036
+ Card,
2037
+ CardGroup,
2038
+ Steps,
2039
+ Accordion,
2040
+ ChangelogTimeline,
2041
+ PackageManager,
2042
+ TypeTable,
2043
+ FileTree,
2044
+ CodeSamples,
2045
+ LinkCard,
2046
+ CardGrid,
2047
+ ApiReference
2048
+ } from "@tomehq/components";
2049
+ import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
2050
+ var MDX_COMPONENTS = {
2051
+ Callout,
2052
+ Tabs,
2053
+ Card,
2054
+ CardGroup,
2055
+ Steps,
2056
+ Accordion,
2057
+ ChangelogTimeline,
2058
+ PackageManager,
2059
+ TypeTable,
2060
+ FileTree,
2061
+ // Sub-components accessible as <FileTree.File /> and <FileTree.Folder /> in MDX
2062
+ CodeSamples,
2063
+ LinkCard,
2064
+ CardGrid
2065
+ };
2066
+ var contentStyles = `
2067
+ @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');
2068
+
2069
+ html, body { margin: 0; padding: 0; height: 100%; overflow: clip; }
2070
+ #tome-root { height: 100%; overflow: clip; }
2071
+
2072
+ .tome-content h1 { display: none; }
2073
+ .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; }
2074
+ .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; }
2075
+ .tome-content h3 { font-family: var(--font-body); font-size: 1.15em; font-weight: 600; margin-top: 1.5em; margin-bottom: 0.5em; }
2076
+ .tome-content h4 { font-family: var(--font-body); font-size: 1.05em; font-weight: 600; margin-top: 1.2em; margin-bottom: 0.5em; }
2077
+ .tome-content p { color: var(--tx2); line-height: 1.8; margin-bottom: 1em; font-size: 14.5px; }
2078
+ .tome-content a { color: var(--ac); text-decoration: none; }
2079
+ .tome-content a:hover { text-decoration: underline; }
2080
+ .tome-content .heading-anchor { display: none; }
2081
+ .tome-content ul, .tome-content ol { color: var(--tx2); padding-inline-start: 1.5em; margin-bottom: 1em; }
2082
+ .tome-content li { margin-bottom: 0.3em; line-height: 1.7; }
2083
+ .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); }
2084
+ .tome-content pre { margin-bottom: 1.2em; border-radius: 2px; overflow-x: auto; border: 1px solid var(--bd); }
2085
+ .tome-content pre code { background: none; padding: 1em 1.2em; display: block; font-size: 12.5px; line-height: 1.7; color: var(--cdTx); }
2086
+ .tome-content blockquote { border-inline-start: 3px solid var(--ac); padding: 0.5em 1em; margin: 1em 0; background: var(--acD); border-radius: 0 2px 2px 0; }
2087
+ .tome-content blockquote p { color: var(--tx2); margin: 0; }
2088
+ .tome-content table { width: 100%; border-collapse: collapse; margin-bottom: 1em; }
2089
+ .tome-content th, .tome-content td { padding: 0.5em 0.8em; border: 1px solid var(--bd); text-align: start; font-size: 0.9em; }
2090
+ .tome-content th { background: var(--sf); font-weight: 600; }
2091
+ .tome-content img { max-width: 100%; border-radius: 2px; cursor: zoom-in; }
2092
+ .tome-content hr { border: none; border-top: 1px solid var(--bd); margin: 2em 0; }
2093
+ .tome-mermaid { margin: 1.2em 0; text-align: center; overflow-x: auto; }
2094
+ .tome-mermaid svg { max-width: 100%; height: auto; overflow: visible; }
2095
+ .tome-mermaid svg .nodeLabel { overflow: visible; white-space: nowrap; }
2096
+ /* Ensure mermaid text meets WCAG AA contrast in light mode */
2097
+ /* Mermaid v11 uses foreignObject with inline-styled spans \u2014 !important needed */
2098
+ html:not(.dark) .tome-mermaid svg .nodeLabel,
2099
+ html:not(.dark) .tome-mermaid svg .nodeLabel span,
2100
+ html:not(.dark) .tome-mermaid svg .nodeLabel div,
2101
+ html:not(.dark) .tome-mermaid svg foreignObject div,
2102
+ html:not(.dark) .tome-mermaid svg foreignObject span { color: #1a1a1a !important; }
2103
+ html:not(.dark) .tome-mermaid svg .edgeLabel,
2104
+ html:not(.dark) .tome-mermaid svg .edgeLabel span { color: #333 !important; }
2105
+ html:not(.dark) .tome-mermaid svg text { fill: #1a1a1a !important; }
2106
+ html:not(.dark) .tome-mermaid svg .node rect,
2107
+ html:not(.dark) .tome-mermaid svg .node polygon { stroke: #555 !important; }
2108
+ /* Dark mode: force bright text in mermaid nodes for readability */
2109
+ html.dark .tome-mermaid svg .nodeLabel,
2110
+ html.dark .tome-mermaid svg .nodeLabel span,
2111
+ html.dark .tome-mermaid svg .nodeLabel div,
2112
+ html.dark .tome-mermaid svg foreignObject div,
2113
+ html.dark .tome-mermaid svg foreignObject span { color: #f0f0f0 !important; }
2114
+ html.dark .tome-mermaid svg .edgeLabel,
2115
+ html.dark .tome-mermaid svg .edgeLabel span { color: #ddd !important; }
2116
+ html.dark .tome-mermaid svg text { fill: #f0f0f0 !important; }
2117
+
2118
+ /* Mobile responsive content */
2119
+ @media (max-width: 767px) {
2120
+ .tome-content h2 { font-size: 1.2em; margin-top: 1.5em; }
2121
+ .tome-content h3 { font-size: 1.05em; }
2122
+ .tome-content pre code { font-size: 12px; padding: 0.8em 1em; }
2123
+ .tome-content table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
2124
+ .tome-content blockquote { margin: 0.8em 0; }
2125
+ }
2126
+
2127
+ /* Selection style */
2128
+ ::selection { background: var(--acD); color: var(--ac); }
2129
+
2130
+ /* Scrollbar style */
2131
+ ::-webkit-scrollbar { width: 5px; height: 5px; }
2132
+ ::-webkit-scrollbar-track { background: transparent; }
2133
+ ::-webkit-scrollbar-thumb { background: var(--bd); border-radius: 10px; }
2134
+
2135
+ /* Grain overlay */
2136
+ .tome-grain::before {
2137
+ content: ""; position: fixed; inset: 0; z-index: 9999; pointer-events: none;
2138
+ opacity: .35;
2139
+ 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");
2140
+ background-repeat: repeat; background-size: 256px;
2141
+ }
2142
+
2143
+ /* \u2500\u2500 Expressive code blocks \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
2144
+
2145
+ /* Code block wrapper (for titled blocks) */
2146
+ .tome-code-block-wrapper { position: relative; margin-bottom: 1.2em; border: 1px solid var(--bd); border-radius: 2px; overflow: hidden; }
2147
+ .tome-code-block-wrapper pre { margin-bottom: 0; border: none; border-radius: 0; }
2148
+ .tome-code-title {
2149
+ font-family: var(--font-code); font-size: 12px; color: var(--tx2);
2150
+ background: var(--sf); padding: 6px 12px; border-bottom: 1px solid var(--bd);
2151
+ letter-spacing: 0.01em; font-weight: 500;
2152
+ }
2153
+
2154
+ /* Line highlighting */
2155
+ .tome-content pre .line.tome-line-highlight {
2156
+ background: rgba(139, 148, 158, 0.1);
2157
+ display: inline-block; width: 100%; margin: 0 -1.2em; padding: 0 1.2em;
2158
+ }
2159
+ html.dark .tome-content pre .line.tome-line-highlight {
2160
+ background: rgba(200, 210, 220, 0.08);
2161
+ }
2162
+
2163
+ /* Diff lines */
2164
+ .tome-content pre .line.tome-line-added {
2165
+ background: rgba(34, 197, 94, 0.12);
2166
+ display: inline-block; width: 100%; margin: 0 -1.2em; padding: 0 1.2em;
2167
+ }
2168
+ .tome-content pre .line.tome-line-removed {
2169
+ background: rgba(239, 68, 68, 0.12);
2170
+ display: inline-block; width: 100%; margin: 0 -1.2em; padding: 0 1.2em;
2171
+ }
2172
+ html.dark .tome-content pre .line.tome-line-added { background: rgba(34, 197, 94, 0.15); }
2173
+ html.dark .tome-content pre .line.tome-line-removed { background: rgba(239, 68, 68, 0.15); }
2174
+
2175
+ /* Line numbers (CSS counter) */
2176
+ .tome-content pre[data-line-numbers] code {
2177
+ counter-reset: line;
2178
+ }
2179
+ .tome-content pre[data-line-numbers] .line::before {
2180
+ counter-increment: line;
2181
+ content: counter(line);
2182
+ display: inline-block; width: 2.5em; margin-inline-end: 1em;
2183
+ text-align: end; color: var(--txM); opacity: 0.4;
2184
+ font-size: 0.85em; user-select: none;
2185
+ border-inline-end: 1px solid var(--bd); padding-inline-end: 0.8em; margin-inline-end: 0.8em;
2186
+ }
2187
+
2188
+ /* Word highlighting */
2189
+ .tome-word-highlight {
2190
+ background: rgba(139, 148, 158, 0.2); border-radius: 2px;
2191
+ padding: 1px 3px; margin: 0 -1px;
2192
+ }
2193
+ html.dark .tome-word-highlight {
2194
+ background: rgba(200, 210, 220, 0.15);
2195
+ }
2196
+
2197
+ /* Copy button */
2198
+ .tome-content pre { position: relative; }
2199
+ .tome-copy-btn {
2200
+ position: absolute; top: 8px; inset-inline-end: 8px;
2201
+ font-family: var(--font-code); font-size: 11px;
2202
+ color: var(--tx2); background: var(--sf); border: 1px solid var(--bd);
2203
+ padding: 3px 8px; border-radius: 2px; cursor: pointer;
2204
+ opacity: 0; transition: opacity 0.15s;
2205
+ z-index: 2; line-height: 1.4;
2206
+ }
2207
+ .tome-content pre:hover .tome-copy-btn,
2208
+ .tome-copy-btn:focus { opacity: 1; }
2209
+ .tome-copy-btn:hover { background: var(--sfH); }
2210
+
2211
+ /* Shiki dual-theme support */
2212
+ .shiki { background: var(--cdBg) !important; }
2213
+
2214
+ /* Dark mode: switch Shiki tokens from light-theme inline colors to --shiki-dark CSS vars */
2215
+ html.dark .shiki,
2216
+ html.dark .shiki span {
2217
+ color: var(--shiki-dark) !important;
2218
+ }
2219
+
2220
+ /* Brighten dim comment tokens (github-dark #6A737D is too low-contrast on dark backgrounds) */
2221
+ html.dark .shiki span[style*="--shiki-dark:#6A737D"] {
2222
+ --shiki-dark: #a0aab5 !important;
2223
+ }
2224
+
2225
+ /* Light mode: darken low-contrast github-light tokens for WCAG AA on --cdBg backgrounds */
2226
+ html:not(.dark) .shiki span[style*="color:#6A737D"] { color: #57606a !important; }
2227
+ html:not(.dark) .shiki span[style*="color:#E36209"] { color: #b35405 !important; }
2228
+ html:not(.dark) .shiki span[style*="color:#6F42C1"] { color: #5a32a3 !important; }
2229
+ html:not(.dark) .shiki span[style*="color:#22863A"] { color: #1a6e2e !important; }
2230
+ html:not(.dark) .shiki span[style*="color:#D73A49"] { color: #b62324 !important; }
2231
+ html:not(.dark) .shiki span[style*="color:#005CC5"] { color: #0349b4 !important; }
2232
+
2233
+ /* \u2500\u2500 Twoslash type hover tooltips \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
2234
+ .twoslash-hover {
2235
+ position: relative;
2236
+ border-bottom: 1px dotted var(--tx2);
2237
+ cursor: help;
2238
+ }
2239
+ .twoslash-popup-container {
2240
+ position: absolute;
2241
+ opacity: 0;
2242
+ display: none;
2243
+ z-index: 10;
2244
+ left: 0;
2245
+ top: 100%;
2246
+ margin-top: 4px;
2247
+ padding: 6px 10px;
2248
+ background: var(--sf);
2249
+ border: 1px solid var(--bd);
2250
+ border-radius: 6px;
2251
+ font-size: 12px;
2252
+ font-family: var(--font-code);
2253
+ color: var(--tx);
2254
+ white-space: pre-wrap;
2255
+ max-width: 500px;
2256
+ box-shadow: 0 4px 12px rgba(0,0,0,0.15);
2257
+ pointer-events: none;
2258
+ }
2259
+ .twoslash-hover:hover .twoslash-popup-container {
2260
+ opacity: 1;
2261
+ display: block;
2262
+ }
2263
+ /* Twoslash error/warning underlines */
2264
+ .twoslash-error {
2265
+ position: relative;
2266
+ background: rgba(239, 68, 68, 0.1);
2267
+ border-bottom: 2px wavy rgba(239, 68, 68, 0.6);
2268
+ }
2269
+ /* Twoslash highlighted identifiers */
2270
+ .twoslash-highlighted {
2271
+ background: rgba(139, 148, 158, 0.15);
2272
+ border-radius: 2px;
2273
+ padding: 1px 2px;
2274
+ }
2275
+ /* Twoslash type annotation line (^?) */
2276
+ .twoslash-popup-code .shiki { background: transparent !important; padding: 0; margin: 0; }
2277
+ .twoslash-popup-code .shiki code { padding: 0; font-size: 12px; }
2278
+ html.dark .twoslash-popup-container {
2279
+ background: var(--sf);
2280
+ border-color: var(--bd);
2281
+ box-shadow: 0 4px 12px rgba(0,0,0,0.3);
2282
+ }
2283
+ `;
2284
+ var basePath = (config.basePath || "/").replace(/\/$/, "");
2285
+ function pathnameToPageId2(pathname) {
2286
+ return pathnameToPageId(pathname, basePath, routes);
2287
+ }
2288
+ function pageIdToPath2(id) {
2289
+ return pageIdToPath(id, basePath, routes);
2290
+ }
2291
+ var _initialPageId = resolveInitialPageId(
2292
+ window.location.pathname,
2293
+ window.location.hash,
2294
+ routes,
2295
+ basePath,
2296
+ pathnameToPageId
2297
+ );
2298
+ var _initialPagePromise = loadPage(_initialPageId, routes, loadPageModule);
2299
+ function App() {
2300
+ const [currentPageId, setCurrentPageId] = useState3(_initialPageId);
2301
+ const [pageData, setPageData] = useState3(null);
2302
+ const [loading, setLoading] = useState3(true);
2303
+ const navCounterRef = useRef3(0);
2304
+ const navigateTo = useCallback3(async (id, opts) => {
2305
+ const navId = ++navCounterRef.current;
2306
+ setLoading(true);
2307
+ let data;
2308
+ try {
2309
+ data = await loadPage(id, routes, loadPageModule);
2310
+ } catch (err) {
2311
+ if (navCounterRef.current !== navId) return;
2312
+ console.error(`[tome] Navigation failed for page: ${id}`, err);
2313
+ data = null;
2314
+ }
2315
+ if (navCounterRef.current !== navId) return;
2316
+ const fullPath = pageIdToPath2(id);
2317
+ if (opts?.replace) {
2318
+ window.history.replaceState(null, "", fullPath);
2319
+ } else {
2320
+ window.history.pushState(null, "", fullPath);
2321
+ }
2322
+ setCurrentPageId(id);
2323
+ setPageData(data);
2324
+ setLoading(false);
2325
+ if (!opts?.skipScroll) {
2326
+ const anchor = window.location.hash.slice(1);
2327
+ if (anchor) {
2328
+ requestAnimationFrame(() => {
2329
+ const el = document.getElementById(anchor);
2330
+ if (el) el.scrollIntoView({ behavior: "smooth", block: "start" });
2331
+ });
2332
+ } else {
2333
+ window.scrollTo(0, 0);
2334
+ }
2335
+ }
2336
+ }, []);
2337
+ useEffect3(() => {
2338
+ const hash = window.location.hash.slice(1);
2339
+ if (hash && routes.some((r) => r.id === hash)) {
2340
+ const fullPath = pageIdToPath2(hash);
2341
+ window.history.replaceState(null, "", fullPath);
2342
+ navigateTo(hash, { replace: true });
2343
+ } else {
2344
+ const fullPath = pageIdToPath2(currentPageId);
2345
+ window.history.replaceState(null, "", fullPath);
2346
+ _initialPagePromise.then((data) => {
2347
+ setPageData(data);
2348
+ setLoading(false);
2349
+ });
2350
+ }
2351
+ }, []);
2352
+ useEffect3(() => {
2353
+ const onPopState = () => {
2354
+ const id = pathnameToPageId2(window.location.pathname);
2355
+ if (id && id !== currentPageId) {
2356
+ navigateTo(id, { replace: true, skipScroll: true });
2357
+ }
2358
+ };
2359
+ window.addEventListener("popstate", onPopState);
2360
+ return () => window.removeEventListener("popstate", onPopState);
2361
+ }, [currentPageId, navigateTo]);
2362
+ const mermaidModuleRef = useRef3(null);
2363
+ const [mermaidTheme, setMermaidTheme] = useState3(() => {
2364
+ if (typeof document === "undefined") return "light";
2365
+ if (document.documentElement.classList.contains("dark")) return "dark";
2366
+ const mode = config.theme?.mode || "auto";
2367
+ if (mode === "dark") return "dark";
2368
+ if (mode === "light") return "light";
2369
+ return window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light";
2370
+ });
2371
+ useEffect3(() => {
2372
+ const observer = new MutationObserver(() => {
2373
+ const isDark = document.documentElement.classList.contains("dark");
2374
+ setMermaidTheme(isDark ? "dark" : "light");
2375
+ });
2376
+ observer.observe(document.documentElement, { attributes: true, attributeFilter: ["class"] });
2377
+ return () => observer.disconnect();
2378
+ }, []);
2379
+ useEffect3(() => {
2380
+ const els = document.querySelectorAll(".tome-mermaid[data-mermaid]");
2381
+ if (els.length === 0) return;
2382
+ let cancelled = false;
2383
+ const MERMAID_CDN = "https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs";
2384
+ (async () => {
2385
+ try {
2386
+ if (!mermaidModuleRef.current) {
2387
+ mermaidModuleRef.current = (await import(
2388
+ /* @vite-ignore */
2389
+ MERMAID_CDN
2390
+ )).default;
2391
+ }
2392
+ const mermaid = mermaidModuleRef.current;
2393
+ if (cancelled) return;
2394
+ const isDark = mermaidTheme === "dark";
2395
+ const resolvedFont = getComputedStyle(document.documentElement).getPropertyValue("--font-body").trim() || "sans-serif";
2396
+ mermaid.initialize({
2397
+ startOnLoad: false,
2398
+ theme: isDark ? "dark" : "default",
2399
+ fontFamily: resolvedFont,
2400
+ flowchart: { padding: 15, nodeSpacing: 30, rankSpacing: 40 }
2401
+ });
2402
+ for (let i = 0; i < els.length; i++) {
2403
+ const el = els[i];
2404
+ const encoded = el.getAttribute("data-mermaid");
2405
+ if (!encoded) continue;
2406
+ try {
2407
+ const code = atob(encoded);
2408
+ const { svg } = await mermaid.render(`tome-mermaid-${i}-${Date.now()}`, code);
2409
+ if (!cancelled) {
2410
+ el.innerHTML = svg;
2411
+ }
2412
+ } catch (err) {
2413
+ console.warn("[tome] Mermaid render failed:", err);
2414
+ el.textContent = "Diagram rendering failed";
2415
+ el.style.cssText = "padding:16px;color:var(--txM);font-size:13px;border:1px dashed var(--bd);border-radius:2px;text-align:center;";
2416
+ }
2417
+ }
2418
+ } catch (err) {
2419
+ console.warn("[tome] Failed to load mermaid from CDN:", err);
2420
+ els.forEach((el) => {
2421
+ el.textContent = "Failed to load diagram renderer";
2422
+ el.style.cssText = "padding:16px;color:var(--txM);font-size:13px;border:1px dashed var(--bd);border-radius:2px;text-align:center;";
2423
+ });
2424
+ }
2425
+ })();
2426
+ return () => {
2427
+ cancelled = true;
2428
+ };
2429
+ }, [pageData, loading, mermaidTheme]);
2430
+ useEffect3(() => {
2431
+ if (loading) return;
2432
+ const preBlocks = document.querySelectorAll(".tome-content pre");
2433
+ const buttons = [];
2434
+ preBlocks.forEach((pre) => {
2435
+ if (pre.querySelector(".tome-copy-btn")) return;
2436
+ const btn = document.createElement("button");
2437
+ btn.className = "tome-copy-btn";
2438
+ btn.textContent = "Copy";
2439
+ btn.addEventListener("click", async () => {
2440
+ const code = pre.querySelector("code");
2441
+ if (code) {
2442
+ try {
2443
+ await navigator.clipboard.writeText(code.textContent || "");
2444
+ btn.textContent = "Copied!";
2445
+ setTimeout(() => {
2446
+ btn.textContent = "Copy";
2447
+ }, 2e3);
2448
+ } catch {
2449
+ btn.textContent = "Failed";
2450
+ setTimeout(() => {
2451
+ btn.textContent = "Copy";
2452
+ }, 2e3);
2453
+ }
2454
+ }
2455
+ });
2456
+ pre.appendChild(btn);
2457
+ buttons.push(btn);
2458
+ });
2459
+ return () => {
2460
+ buttons.forEach((btn) => btn.remove());
2461
+ };
2462
+ }, [pageData, loading]);
2463
+ const allPages = routes.map((r) => ({
2464
+ id: r.id,
2465
+ title: r.frontmatter.title,
2466
+ description: r.frontmatter.description
2467
+ }));
2468
+ const currentRoute = routes.find((r) => r.id === currentPageId);
2469
+ const currentVersion = detectCurrentVersion(currentRoute, versions);
2470
+ const editUrl = computeEditUrl(config.editLink, currentRoute?.filePath);
2471
+ const currentLocale = currentRoute?.locale || i18n?.defaultLocale || "en";
2472
+ const dir = i18n?.localeDirs?.[currentLocale] || "ltr";
2473
+ useEffect3(() => {
2474
+ const hasMathPlaceholders = document.querySelectorAll(".tome-math[data-math]").length > 0;
2475
+ if (!config.math && !hasMathPlaceholders) return;
2476
+ const id = "tome-katex-css";
2477
+ if (document.getElementById(id)) return;
2478
+ const link = document.createElement("link");
2479
+ link.id = id;
2480
+ link.rel = "stylesheet";
2481
+ link.href = "https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.css";
2482
+ link.crossOrigin = "anonymous";
2483
+ document.head.appendChild(link);
2484
+ }, [pageData, loading]);
2485
+ useEffect3(() => {
2486
+ const els = document.querySelectorAll(".tome-math[data-math]");
2487
+ if (els.length === 0) return;
2488
+ let cancelled = false;
2489
+ const KATEX_CDN = "https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.mjs";
2490
+ (async () => {
2491
+ try {
2492
+ const katex = (await import(
2493
+ /* @vite-ignore */
2494
+ KATEX_CDN
2495
+ )).default;
2496
+ if (cancelled) return;
2497
+ for (const el of els) {
2498
+ const encoded = el.getAttribute("data-math");
2499
+ if (!encoded) continue;
2500
+ try {
2501
+ const tex = atob(encoded);
2502
+ const isBlock = el.classList.contains("tome-math-block");
2503
+ katex.render(tex, el, {
2504
+ displayMode: isBlock,
2505
+ throwOnError: false
2506
+ });
2507
+ } catch (err) {
2508
+ console.warn("[tome] KaTeX render failed:", err);
2509
+ }
2510
+ }
2511
+ } catch (err) {
2512
+ console.warn("[tome] Failed to load KaTeX from CDN:", err);
2513
+ }
2514
+ })();
2515
+ return () => {
2516
+ cancelled = true;
2517
+ };
2518
+ }, [pageData, loading]);
2519
+ return /* @__PURE__ */ jsxs3(Fragment2, { children: [
2520
+ /* @__PURE__ */ jsx3("style", { children: contentStyles }),
2521
+ /* @__PURE__ */ jsx3(
2522
+ Shell,
2523
+ {
2524
+ config,
2525
+ navigation,
2526
+ currentPageId,
2527
+ pageHtml: !pageData?.isMdx ? loading ? "" : pageData?.html || "<p>Page not found</p>" : void 0,
2528
+ pageComponent: pageData?.isMdx ? pageData.component : void 0,
2529
+ mdxComponents: MDX_COMPONENTS,
2530
+ pageTitle: pageData?.frontmatter.title || (loading ? "" : "Not Found"),
2531
+ pageDescription: pageData?.frontmatter.description,
2532
+ headings: pageData?.headings || [],
2533
+ tocEnabled: pageData?.frontmatter.toc !== false,
2534
+ editUrl,
2535
+ lastUpdated: currentRoute?.lastUpdated,
2536
+ changelogEntries: !pageData?.isMdx ? pageData?.changelogEntries : void 0,
2537
+ apiManifest: !pageData?.isMdx && pageData?.isApiReference ? pageData.apiManifest : void 0,
2538
+ apiBaseUrl: config.api?.baseUrl,
2539
+ apiPlayground: config.api?.playground,
2540
+ apiAuth: config.api?.auth,
2541
+ ApiReferenceComponent: ApiReference,
2542
+ onNavigate: navigateTo,
2543
+ allPages,
2544
+ docContext,
2545
+ versioning: versions || void 0,
2546
+ currentVersion,
2547
+ basePath,
2548
+ isDraft: currentRoute?.frontmatter?.draft === true,
2549
+ dir,
2550
+ i18n: i18n || void 0,
2551
+ currentLocale,
2552
+ overrides
2553
+ }
2554
+ )
2555
+ ] });
2556
+ }
2557
+ var container = document.getElementById("tome-root");
2558
+ if (container) {
2559
+ const root = createRoot(container);
2560
+ root.render(/* @__PURE__ */ jsx3(App, {}));
2561
+ }
2562
+ var entry_default = App;
2563
+
2564
+ export {
2565
+ THEME_PRESETS,
2566
+ AiChat,
2567
+ Shell,
2568
+ entry_default
2569
+ };