@docubook/mdx-content 3.4.0 → 3.4.2

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 (212) hide show
  1. package/dist/adapters/next/index.d.ts +54 -5
  2. package/dist/adapters/next/index.js +420 -4
  3. package/dist/adapters/next/index.js.map +1 -1
  4. package/dist/chunk-PSDC53TU.js +1056 -0
  5. package/dist/chunk-PSDC53TU.js.map +1 -0
  6. package/dist/client.d.ts +91 -9
  7. package/dist/client.js +1191 -8
  8. package/dist/client.js.map +1 -1
  9. package/dist/index.d.ts +91 -20
  10. package/dist/index.js +1245 -19
  11. package/dist/index.js.map +1 -1
  12. package/dist/server-BObcTM97.d.ts +100 -0
  13. package/dist/server.d.ts +3 -11
  14. package/dist/server.js +40 -10
  15. package/dist/server.js.map +1 -1
  16. package/package.json +5 -4
  17. package/dist/__test__/AccordionMdx.test.d.ts +0 -2
  18. package/dist/__test__/AccordionMdx.test.d.ts.map +0 -1
  19. package/dist/__test__/AccordionMdx.test.js +0 -21
  20. package/dist/__test__/AccordionMdx.test.js.map +0 -1
  21. package/dist/__test__/AccordionsMdx.test.d.ts +0 -2
  22. package/dist/__test__/AccordionsMdx.test.d.ts.map +0 -1
  23. package/dist/__test__/AccordionsMdx.test.js +0 -22
  24. package/dist/__test__/AccordionsMdx.test.js.map +0 -1
  25. package/dist/__test__/ButtonMdx.test.d.ts +0 -2
  26. package/dist/__test__/ButtonMdx.test.d.ts.map +0 -1
  27. package/dist/__test__/ButtonMdx.test.js +0 -20
  28. package/dist/__test__/ButtonMdx.test.js.map +0 -1
  29. package/dist/__test__/CardMdx.test.d.ts +0 -2
  30. package/dist/__test__/CardMdx.test.d.ts.map +0 -1
  31. package/dist/__test__/CardMdx.test.js +0 -29
  32. package/dist/__test__/CardMdx.test.js.map +0 -1
  33. package/dist/__test__/CardsMdx.test.d.ts +0 -2
  34. package/dist/__test__/CardsMdx.test.d.ts.map +0 -1
  35. package/dist/__test__/CardsMdx.test.js +0 -33
  36. package/dist/__test__/CardsMdx.test.js.map +0 -1
  37. package/dist/__test__/CodeBlockMdx.test.d.ts +0 -2
  38. package/dist/__test__/CodeBlockMdx.test.d.ts.map +0 -1
  39. package/dist/__test__/CodeBlockMdx.test.js +0 -48
  40. package/dist/__test__/CodeBlockMdx.test.js.map +0 -1
  41. package/dist/__test__/FileTreeMdx.test.d.ts +0 -2
  42. package/dist/__test__/FileTreeMdx.test.d.ts.map +0 -1
  43. package/dist/__test__/FileTreeMdx.test.js +0 -26
  44. package/dist/__test__/FileTreeMdx.test.js.map +0 -1
  45. package/dist/__test__/ImageMdx.test.d.ts +0 -2
  46. package/dist/__test__/ImageMdx.test.d.ts.map +0 -1
  47. package/dist/__test__/ImageMdx.test.js +0 -32
  48. package/dist/__test__/ImageMdx.test.js.map +0 -1
  49. package/dist/__test__/KbdMdx.test.d.ts +0 -2
  50. package/dist/__test__/KbdMdx.test.d.ts.map +0 -1
  51. package/dist/__test__/KbdMdx.test.js +0 -27
  52. package/dist/__test__/KbdMdx.test.js.map +0 -1
  53. package/dist/__test__/LinkMdx.test.d.ts +0 -2
  54. package/dist/__test__/LinkMdx.test.d.ts.map +0 -1
  55. package/dist/__test__/LinkMdx.test.js +0 -29
  56. package/dist/__test__/LinkMdx.test.js.map +0 -1
  57. package/dist/__test__/MermaidMdx.test.d.ts +0 -2
  58. package/dist/__test__/MermaidMdx.test.d.ts.map +0 -1
  59. package/dist/__test__/MermaidMdx.test.js +0 -207
  60. package/dist/__test__/MermaidMdx.test.js.map +0 -1
  61. package/dist/__test__/NoteMdx.test.d.ts +0 -2
  62. package/dist/__test__/NoteMdx.test.d.ts.map +0 -1
  63. package/dist/__test__/NoteMdx.test.js +0 -39
  64. package/dist/__test__/NoteMdx.test.js.map +0 -1
  65. package/dist/__test__/ReleaseMdx.test.d.ts +0 -2
  66. package/dist/__test__/ReleaseMdx.test.d.ts.map +0 -1
  67. package/dist/__test__/ReleaseMdx.test.js +0 -39
  68. package/dist/__test__/ReleaseMdx.test.js.map +0 -1
  69. package/dist/__test__/StepperMdx.test.d.ts +0 -2
  70. package/dist/__test__/StepperMdx.test.d.ts.map +0 -1
  71. package/dist/__test__/StepperMdx.test.js +0 -25
  72. package/dist/__test__/StepperMdx.test.js.map +0 -1
  73. package/dist/__test__/TableMdx.test.d.ts +0 -2
  74. package/dist/__test__/TableMdx.test.d.ts.map +0 -1
  75. package/dist/__test__/TableMdx.test.js +0 -25
  76. package/dist/__test__/TableMdx.test.js.map +0 -1
  77. package/dist/__test__/TabsMdx.test.d.ts +0 -2
  78. package/dist/__test__/TabsMdx.test.d.ts.map +0 -1
  79. package/dist/__test__/TabsMdx.test.js +0 -30
  80. package/dist/__test__/TabsMdx.test.js.map +0 -1
  81. package/dist/__test__/TooltipMdx.test.d.ts +0 -2
  82. package/dist/__test__/TooltipMdx.test.d.ts.map +0 -1
  83. package/dist/__test__/TooltipMdx.test.js +0 -23
  84. package/dist/__test__/TooltipMdx.test.js.map +0 -1
  85. package/dist/__test__/YoutubeMdx.test.d.ts +0 -2
  86. package/dist/__test__/YoutubeMdx.test.d.ts.map +0 -1
  87. package/dist/__test__/YoutubeMdx.test.js +0 -25
  88. package/dist/__test__/YoutubeMdx.test.js.map +0 -1
  89. package/dist/__test__/utils/ExpandableCode.test.d.ts +0 -2
  90. package/dist/__test__/utils/ExpandableCode.test.d.ts.map +0 -1
  91. package/dist/__test__/utils/ExpandableCode.test.js +0 -62
  92. package/dist/__test__/utils/ExpandableCode.test.js.map +0 -1
  93. package/dist/__test__/utils/Icon.test.d.ts +0 -2
  94. package/dist/__test__/utils/Icon.test.d.ts.map +0 -1
  95. package/dist/__test__/utils/Icon.test.js +0 -29
  96. package/dist/__test__/utils/Icon.test.js.map +0 -1
  97. package/dist/adapters/next/ButtonMdx.d.ts +0 -4
  98. package/dist/adapters/next/ButtonMdx.d.ts.map +0 -1
  99. package/dist/adapters/next/ButtonMdx.js +0 -8
  100. package/dist/adapters/next/ButtonMdx.js.map +0 -1
  101. package/dist/adapters/next/CardMdx.d.ts +0 -4
  102. package/dist/adapters/next/CardMdx.d.ts.map +0 -1
  103. package/dist/adapters/next/CardMdx.js +0 -8
  104. package/dist/adapters/next/CardMdx.js.map +0 -1
  105. package/dist/adapters/next/ImageMdx.d.ts +0 -8
  106. package/dist/adapters/next/ImageMdx.d.ts.map +0 -1
  107. package/dist/adapters/next/ImageMdx.js +0 -8
  108. package/dist/adapters/next/ImageMdx.js.map +0 -1
  109. package/dist/adapters/next/LinkMdx.d.ts +0 -3
  110. package/dist/adapters/next/LinkMdx.d.ts.map +0 -1
  111. package/dist/adapters/next/LinkMdx.js +0 -11
  112. package/dist/adapters/next/LinkMdx.js.map +0 -1
  113. package/dist/adapters/next/index.d.ts.map +0 -1
  114. package/dist/client.d.ts.map +0 -1
  115. package/dist/components/AccordionMdx.d.ts +0 -11
  116. package/dist/components/AccordionMdx.d.ts.map +0 -1
  117. package/dist/components/AccordionMdx.js +0 -64
  118. package/dist/components/AccordionMdx.js.map +0 -1
  119. package/dist/components/AccordionsMdx.d.ts +0 -7
  120. package/dist/components/AccordionsMdx.d.ts.map +0 -1
  121. package/dist/components/AccordionsMdx.js +0 -14
  122. package/dist/components/AccordionsMdx.js.map +0 -1
  123. package/dist/components/ButtonMdx.d.ts +0 -17
  124. package/dist/components/ButtonMdx.d.ts.map +0 -1
  125. package/dist/components/ButtonMdx.js +0 -57
  126. package/dist/components/ButtonMdx.js.map +0 -1
  127. package/dist/components/CardMdx.d.ts +0 -17
  128. package/dist/components/CardMdx.d.ts.map +0 -1
  129. package/dist/components/CardMdx.js +0 -52
  130. package/dist/components/CardMdx.js.map +0 -1
  131. package/dist/components/CardsMdx.d.ts +0 -9
  132. package/dist/components/CardsMdx.d.ts.map +0 -1
  133. package/dist/components/CardsMdx.js +0 -9
  134. package/dist/components/CardsMdx.js.map +0 -1
  135. package/dist/components/CodeBlockMdx.d.ts +0 -11
  136. package/dist/components/CodeBlockMdx.d.ts.map +0 -1
  137. package/dist/components/CodeBlockMdx.js +0 -135
  138. package/dist/components/CodeBlockMdx.js.map +0 -1
  139. package/dist/components/FileTreeMdx.d.ts +0 -19
  140. package/dist/components/FileTreeMdx.d.ts.map +0 -1
  141. package/dist/components/FileTreeMdx.js +0 -99
  142. package/dist/components/FileTreeMdx.js.map +0 -1
  143. package/dist/components/ImageMdx.d.ts +0 -8
  144. package/dist/components/ImageMdx.d.ts.map +0 -1
  145. package/dist/components/ImageMdx.js +0 -111
  146. package/dist/components/ImageMdx.js.map +0 -1
  147. package/dist/components/KbdMdx.d.ts +0 -9
  148. package/dist/components/KbdMdx.d.ts.map +0 -1
  149. package/dist/components/KbdMdx.js +0 -74
  150. package/dist/components/KbdMdx.js.map +0 -1
  151. package/dist/components/LinkMdx.d.ts +0 -4
  152. package/dist/components/LinkMdx.d.ts.map +0 -1
  153. package/dist/components/LinkMdx.js +0 -10
  154. package/dist/components/LinkMdx.js.map +0 -1
  155. package/dist/components/MermaidMdx.d.ts +0 -13
  156. package/dist/components/MermaidMdx.d.ts.map +0 -1
  157. package/dist/components/MermaidMdx.js +0 -211
  158. package/dist/components/MermaidMdx.js.map +0 -1
  159. package/dist/components/NoteMdx.d.ts +0 -13
  160. package/dist/components/NoteMdx.d.ts.map +0 -1
  161. package/dist/components/NoteMdx.js +0 -79
  162. package/dist/components/NoteMdx.js.map +0 -1
  163. package/dist/components/ReleaseMdx.d.ts +0 -16
  164. package/dist/components/ReleaseMdx.d.ts.map +0 -1
  165. package/dist/components/ReleaseMdx.js +0 -44
  166. package/dist/components/ReleaseMdx.js.map +0 -1
  167. package/dist/components/StepperMdx.d.ts +0 -17
  168. package/dist/components/StepperMdx.d.ts.map +0 -1
  169. package/dist/components/StepperMdx.js +0 -74
  170. package/dist/components/StepperMdx.js.map +0 -1
  171. package/dist/components/TableMdx.d.ts +0 -9
  172. package/dist/components/TableMdx.d.ts.map +0 -1
  173. package/dist/components/TableMdx.js +0 -56
  174. package/dist/components/TableMdx.js.map +0 -1
  175. package/dist/components/TabsMdx.d.ts +0 -13
  176. package/dist/components/TabsMdx.d.ts.map +0 -1
  177. package/dist/components/TabsMdx.js +0 -67
  178. package/dist/components/TabsMdx.js.map +0 -1
  179. package/dist/components/TooltipMdx.d.ts +0 -10
  180. package/dist/components/TooltipMdx.d.ts.map +0 -1
  181. package/dist/components/TooltipMdx.js +0 -36
  182. package/dist/components/TooltipMdx.js.map +0 -1
  183. package/dist/components/YoutubeMdx.d.ts +0 -7
  184. package/dist/components/YoutubeMdx.d.ts.map +0 -1
  185. package/dist/components/YoutubeMdx.js +0 -24
  186. package/dist/components/YoutubeMdx.js.map +0 -1
  187. package/dist/components/index.d.ts +0 -19
  188. package/dist/components/index.d.ts.map +0 -1
  189. package/dist/components/index.js +0 -19
  190. package/dist/components/index.js.map +0 -1
  191. package/dist/index.d.ts.map +0 -1
  192. package/dist/registry/index.d.ts +0 -4
  193. package/dist/registry/index.d.ts.map +0 -1
  194. package/dist/registry/index.js +0 -38
  195. package/dist/registry/index.js.map +0 -1
  196. package/dist/server.d.ts.map +0 -1
  197. package/dist/utils/AccordionGroupContext.d.ts +0 -8
  198. package/dist/utils/AccordionGroupContext.d.ts.map +0 -1
  199. package/dist/utils/AccordionGroupContext.js +0 -4
  200. package/dist/utils/AccordionGroupContext.js.map +0 -1
  201. package/dist/utils/CopyButton.d.ts +0 -6
  202. package/dist/utils/CopyButton.d.ts.map +0 -1
  203. package/dist/utils/CopyButton.js +0 -39
  204. package/dist/utils/CopyButton.js.map +0 -1
  205. package/dist/utils/ExpandableCode.d.ts +0 -11
  206. package/dist/utils/ExpandableCode.d.ts.map +0 -1
  207. package/dist/utils/ExpandableCode.js +0 -78
  208. package/dist/utils/ExpandableCode.js.map +0 -1
  209. package/dist/utils/Icon.d.ts +0 -6
  210. package/dist/utils/Icon.d.ts.map +0 -1
  211. package/dist/utils/Icon.js +0 -12
  212. package/dist/utils/Icon.js.map +0 -1
package/dist/client.js CHANGED
@@ -1,9 +1,1192 @@
1
- export { AccordionMdx } from "./components/AccordionMdx";
2
- export { AccordionsMdx } from "./components/AccordionsMdx";
3
- export { TabMdx, TabsMdx } from "./components/TabsMdx";
4
- export { TooltipMdx } from "./components/TooltipMdx";
5
- export { ImageMdx } from "./components/ImageMdx";
6
- export { CardMdx } from "./components/CardMdx";
7
- export { FileMdx, FilesMdx, FolderMdx } from "./components/FileTreeMdx";
8
- export { MermaidMdx } from "./components/MermaidMdx";
1
+ "use client";
2
+
3
+ // src/components/AccordionMdx.tsx
4
+ import { useContext, useId, useState } from "react";
5
+
6
+ // src/utils/AccordionGroupContext.tsx
7
+ import { createContext } from "react";
8
+ var AccordionGroupContext = createContext(null);
9
+
10
+ // src/utils/Icon.tsx
11
+ import * as LucideIcons from "lucide-react";
12
+ import { jsx } from "react/jsx-runtime";
13
+ var DEFAULT_ICON_SIZE = 20;
14
+ function resolveLucideIcon(icon) {
15
+ const normalized = typeof icon === "string" ? icon.trim() : icon;
16
+ if (!normalized || !Object.hasOwn(LucideIcons, normalized)) {
17
+ return void 0;
18
+ }
19
+ const IconComponent = LucideIcons[normalized];
20
+ return /* @__PURE__ */ jsx(IconComponent, { size: DEFAULT_ICON_SIZE });
21
+ }
22
+
23
+ // src/components/AccordionMdx.tsx
24
+ import { ChevronRight } from "lucide-react";
25
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
26
+ function AccordionMdx({ title, icon, className, children }) {
27
+ const groupContext = useContext(AccordionGroupContext);
28
+ const [localOpen, setLocalOpen] = useState(false);
29
+ const panelId = useId();
30
+ const triggerId = `${panelId}-trigger`;
31
+ const isGroup = groupContext?.inGroup === true;
32
+ const isOpen = isGroup ? groupContext?.openTitle === title : localOpen;
33
+ const resolvedIcon = resolveLucideIcon(icon);
34
+ function onToggle() {
35
+ if (isGroup && groupContext) {
36
+ groupContext.setOpenTitle(groupContext.openTitle === title ? null : title);
37
+ return;
38
+ }
39
+ setLocalOpen((prev) => !prev);
40
+ }
41
+ return /* @__PURE__ */ jsxs(
42
+ "div",
43
+ {
44
+ className: `mdx-accordion ${isGroup ? "mdx-accordion-group-item" : ""} ${className ?? ""}`,
45
+ style: {
46
+ border: "1px solid hsl(var(--border-color, 210 20% 85%))",
47
+ borderRadius: 10,
48
+ overflow: "hidden",
49
+ background: "hsl(var(--card, 0 0% 100%))"
50
+ },
51
+ children: [
52
+ /* @__PURE__ */ jsxs(
53
+ "button",
54
+ {
55
+ className: "mdx-accordion-header",
56
+ type: "button",
57
+ onClick: onToggle,
58
+ "aria-expanded": isOpen,
59
+ "aria-controls": panelId,
60
+ id: triggerId,
61
+ onKeyDown: (event) => {
62
+ if (event.key === "Enter" || event.key === " ") {
63
+ event.preventDefault();
64
+ onToggle();
65
+ }
66
+ },
67
+ style: {
68
+ width: "100%",
69
+ display: "flex",
70
+ alignItems: "center",
71
+ justifyContent: "flex-start",
72
+ gap: "0.5rem",
73
+ textAlign: "left",
74
+ border: 0,
75
+ cursor: "pointer",
76
+ background: "hsl(var(--muted, 210 20% 92%))",
77
+ color: "hsl(var(--foreground, 220 30% 15%))",
78
+ fontWeight: 600,
79
+ padding: "0.95rem 1rem"
80
+ },
81
+ children: [
82
+ /* @__PURE__ */ jsx2(
83
+ ChevronRight,
84
+ {
85
+ className: "mdx-accordion-chevron",
86
+ "aria-hidden": "true",
87
+ size: 16,
88
+ style: {
89
+ transform: isOpen ? "rotate(90deg)" : "rotate(0deg)",
90
+ transition: "transform 0.2s ease",
91
+ flexShrink: 0,
92
+ color: "hsl(var(--foreground, 220 30% 15%) / 0.74)",
93
+ marginRight: "0.4rem"
94
+ }
95
+ }
96
+ ),
97
+ /* @__PURE__ */ jsxs("span", { style: { display: "inline-flex", alignItems: "center", gap: "0.5rem", flex: 1 }, children: [
98
+ resolvedIcon ? /* @__PURE__ */ jsx2(
99
+ "span",
100
+ {
101
+ "aria-hidden": "true",
102
+ style: {
103
+ display: "inline-flex",
104
+ alignItems: "center",
105
+ justifyContent: "center",
106
+ minWidth: "1.45rem",
107
+ height: "1.45rem",
108
+ color: "hsl(var(--foreground, 220 30% 15%))"
109
+ },
110
+ children: resolvedIcon
111
+ }
112
+ ) : null,
113
+ /* @__PURE__ */ jsx2("span", { children: title })
114
+ ] })
115
+ ]
116
+ }
117
+ ),
118
+ /* @__PURE__ */ jsx2(
119
+ "div",
120
+ {
121
+ id: panelId,
122
+ role: "region",
123
+ "aria-labelledby": triggerId,
124
+ hidden: !isOpen,
125
+ className: "mdx-accordion-content",
126
+ style: {
127
+ padding: "0.75rem 0.8rem",
128
+ background: "hsl(var(--card, 0 0% 100%))",
129
+ color: "hsl(var(--card-foreground, 220 30% 15%))"
130
+ },
131
+ children
132
+ }
133
+ )
134
+ ]
135
+ }
136
+ );
137
+ }
138
+
139
+ // src/components/AccordionsMdx.tsx
140
+ import { useMemo, useState as useState2 } from "react";
141
+ import { jsx as jsx3 } from "react/jsx-runtime";
142
+ function AccordionsMdx({ children }) {
143
+ const [openTitle, setOpenTitle] = useState2(null);
144
+ const value = useMemo(() => ({ inGroup: true, openTitle, setOpenTitle }), [openTitle]);
145
+ return /* @__PURE__ */ jsx3(AccordionGroupContext.Provider, { value, children: /* @__PURE__ */ jsx3(
146
+ "div",
147
+ {
148
+ className: "mdx-accordion-group",
149
+ style: {
150
+ margin: "1rem 0",
151
+ display: "grid",
152
+ gap: "0.85rem"
153
+ },
154
+ children
155
+ }
156
+ ) });
157
+ }
158
+
159
+ // src/components/TabsMdx.tsx
160
+ import {
161
+ Children,
162
+ isValidElement,
163
+ useId as useId2,
164
+ useState as useState3
165
+ } from "react";
166
+ import { Fragment, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
167
+ function TabMdx({ children }) {
168
+ return /* @__PURE__ */ jsx4(Fragment, { children });
169
+ }
170
+ function titleToValue(title) {
171
+ return title.trim().toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9-_]/g, "");
172
+ }
173
+ function TabsMdx({ className, children }) {
174
+ const id = useId2();
175
+ const childArray = Children.toArray(children);
176
+ const tabItems = childArray.filter(
177
+ (child) => isValidElement(child) && typeof child.props.title === "string"
178
+ ).map((child, index) => {
179
+ const title = child.props.title;
180
+ const fallback = `tab-${index + 1}`;
181
+ const slug = titleToValue(title) || fallback;
182
+ return {
183
+ value: `${slug}-${index + 1}`,
184
+ title,
185
+ children: child.props.children
186
+ };
187
+ });
188
+ const [activeValue, setActiveValue] = useState3(tabItems[0]?.value ?? "");
189
+ const activeItem = tabItems.find((item) => item.value === activeValue) ?? tabItems[0];
190
+ return /* @__PURE__ */ jsxs2("div", { className, style: { margin: "1rem 0" }, children: [
191
+ /* @__PURE__ */ jsx4(
192
+ "div",
193
+ {
194
+ role: "tablist",
195
+ "aria-orientation": "horizontal",
196
+ style: {
197
+ display: "flex",
198
+ flexWrap: "nowrap",
199
+ gap: "0.75rem",
200
+ alignItems: "center",
201
+ overflowX: "auto",
202
+ borderBottom: "1px solid hsl(var(--border-color, 210 20% 85%))"
203
+ },
204
+ children: tabItems.map((item) => {
205
+ const active = item.value === activeItem?.value;
206
+ const triggerId = `${id}-tab-${item.value}`;
207
+ const panelId = `${id}-panel-${item.value}`;
208
+ return /* @__PURE__ */ jsx4(
209
+ "button",
210
+ {
211
+ id: triggerId,
212
+ type: "button",
213
+ role: "tab",
214
+ "aria-selected": active,
215
+ "aria-controls": panelId,
216
+ tabIndex: active ? 0 : -1,
217
+ onClick: () => setActiveValue(item.value),
218
+ style: {
219
+ border: "none",
220
+ borderBottom: active ? "2px solid hsl(var(--primary, 210 81% 56%))" : "2px solid transparent",
221
+ background: "transparent",
222
+ color: active ? "hsl(var(--primary, 210 81% 56%))" : "hsl(var(--foreground, 220 30% 15%))",
223
+ fontSize: "0.875rem",
224
+ fontWeight: 600,
225
+ lineHeight: 1.2,
226
+ padding: "0.7rem 0.15rem",
227
+ cursor: "pointer",
228
+ whiteSpace: "nowrap"
229
+ },
230
+ children: item.title
231
+ },
232
+ item.value
233
+ );
234
+ })
235
+ }
236
+ ),
237
+ tabItems.map((item) => {
238
+ const active = item.value === activeItem?.value;
239
+ const triggerId = `${id}-tab-${item.value}`;
240
+ const panelId = `${id}-panel-${item.value}`;
241
+ return /* @__PURE__ */ jsx4(
242
+ "div",
243
+ {
244
+ role: "tabpanel",
245
+ id: panelId,
246
+ "aria-labelledby": triggerId,
247
+ hidden: !active,
248
+ tabIndex: 0,
249
+ style: {
250
+ marginTop: "1rem"
251
+ },
252
+ children: item.children
253
+ },
254
+ item.value
255
+ );
256
+ })
257
+ ] });
258
+ }
259
+
260
+ // src/components/TooltipMdx.tsx
261
+ import { useId as useId3, useState as useState4 } from "react";
262
+ import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
263
+ function TooltipMdx({
264
+ text,
265
+ tip,
266
+ side = "top",
267
+ style,
268
+ className,
269
+ ...props
270
+ }) {
271
+ const [open, setOpen] = useState4(false);
272
+ const id = useId3();
273
+ const tooltipContent = tip ?? "";
274
+ const triggerContent = text ?? "?";
275
+ const floatingPosition = side === "bottom" ? { top: "calc(100% + 8px)" } : { bottom: "calc(100% + 8px)" };
276
+ return /* @__PURE__ */ jsxs3(
277
+ "span",
278
+ {
279
+ className,
280
+ ...props,
281
+ "data-tooltip": typeof tooltipContent === "string" ? tooltipContent : "",
282
+ "data-tooltip-side": side,
283
+ style: { position: "relative", display: "inline-block", ...style },
284
+ onMouseEnter: () => setOpen(true),
285
+ onMouseLeave: () => setOpen(false),
286
+ onFocus: () => setOpen(true),
287
+ onBlur: () => setOpen(false),
288
+ children: [
289
+ /* @__PURE__ */ jsx5(
290
+ "span",
291
+ {
292
+ tabIndex: 0,
293
+ "aria-describedby": id,
294
+ style: {
295
+ cursor: "help",
296
+ color: "hsl(var(--primary, 210 81% 56%))",
297
+ textDecorationLine: "underline",
298
+ textDecorationStyle: "dotted",
299
+ textDecorationColor: "hsl(var(--primary, 210 81% 56%))",
300
+ textUnderlineOffset: "0.18em"
301
+ },
302
+ onKeyDown: (event) => {
303
+ if (event.key === "Escape") {
304
+ setOpen(false);
305
+ }
306
+ },
307
+ children: triggerContent
308
+ }
309
+ ),
310
+ open && tooltipContent ? /* @__PURE__ */ jsx5(
311
+ "span",
312
+ {
313
+ id,
314
+ role: "tooltip",
315
+ style: {
316
+ position: "absolute",
317
+ left: "50%",
318
+ transform: "translateX(-50%)",
319
+ ...floatingPosition,
320
+ border: "1px solid hsl(var(--border-color, 210 20% 85%))",
321
+ background: "hsl(var(--card, 0 0% 100%))",
322
+ color: "hsl(var(--foreground, 220 30% 15%))",
323
+ borderRadius: 8,
324
+ padding: "0.35rem 0.5rem",
325
+ fontSize: "0.78rem",
326
+ whiteSpace: "nowrap",
327
+ zIndex: 20
328
+ },
329
+ children: tooltipContent
330
+ }
331
+ ) : null
332
+ ]
333
+ }
334
+ );
335
+ }
336
+
337
+ // src/components/ImageMdx.tsx
338
+ import { createPortal } from "react-dom";
339
+ import { useEffect, useId as useId4, useRef, useState as useState5 } from "react";
340
+ import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
341
+ function ImageMdx({
342
+ src,
343
+ alt = "image",
344
+ width = 800,
345
+ height = 350,
346
+ zoom = true,
347
+ style,
348
+ ImageComponent,
349
+ ...props
350
+ }) {
351
+ const Image = ImageComponent ?? "img";
352
+ const [isOpen, setIsOpen] = useState5(false);
353
+ const scrollYRef = useRef(0);
354
+ const closeButtonRef = useRef(null);
355
+ const dialogId = useId4();
356
+ useEffect(() => {
357
+ if (!isOpen) return;
358
+ scrollYRef.current = window.scrollY;
359
+ document.body.style.position = "fixed";
360
+ document.body.style.top = `-${scrollYRef.current}px`;
361
+ document.body.style.width = "100%";
362
+ closeButtonRef.current?.focus();
363
+ const onEsc = (e) => {
364
+ if (e.key === "Escape") setIsOpen(false);
365
+ };
366
+ const onFocusTrap = (e) => {
367
+ if (e.key !== "Tab") return;
368
+ const dialog = document.getElementById(dialogId);
369
+ const focusable = dialog?.querySelectorAll(
370
+ 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
371
+ );
372
+ if (!focusable || focusable.length === 0) return;
373
+ const first = focusable[0];
374
+ const last = focusable[focusable.length - 1];
375
+ if (!e.shiftKey && document.activeElement === last) {
376
+ e.preventDefault();
377
+ first.focus();
378
+ }
379
+ if (e.shiftKey && document.activeElement === first) {
380
+ e.preventDefault();
381
+ last.focus();
382
+ }
383
+ };
384
+ window.addEventListener("keydown", onEsc);
385
+ window.addEventListener("keydown", onFocusTrap);
386
+ return () => {
387
+ document.body.style.position = "";
388
+ document.body.style.top = "";
389
+ document.body.style.width = "";
390
+ window.scrollTo(0, scrollYRef.current);
391
+ window.removeEventListener("keydown", onEsc);
392
+ window.removeEventListener("keydown", onFocusTrap);
393
+ };
394
+ }, [dialogId, isOpen]);
395
+ if (!src) return null;
396
+ const canZoom = zoom;
397
+ return /* @__PURE__ */ jsxs4(Fragment2, { children: [
398
+ /* @__PURE__ */ jsx6(
399
+ "button",
400
+ {
401
+ type: "button",
402
+ onClick: () => canZoom && setIsOpen(true),
403
+ "aria-label": canZoom ? "Zoom image" : "Image",
404
+ style: {
405
+ position: "relative",
406
+ width: "100%",
407
+ border: "none",
408
+ background: "transparent",
409
+ padding: 0,
410
+ margin: "1rem 0",
411
+ cursor: canZoom ? "zoom-in" : "default"
412
+ },
413
+ children: /* @__PURE__ */ jsx6(
414
+ Image,
415
+ {
416
+ src,
417
+ alt,
418
+ width: typeof width === "number" ? width : parseInt(width, 10),
419
+ height: typeof height === "number" ? height : parseInt(height, 10),
420
+ style: {
421
+ width: "100%",
422
+ height: "auto",
423
+ borderRadius: 10,
424
+ objectFit: "contain",
425
+ ...style
426
+ },
427
+ ...props
428
+ }
429
+ )
430
+ }
431
+ ),
432
+ canZoom && isOpen ? /* @__PURE__ */ jsx6(Portal, { children: /* @__PURE__ */ jsxs4(
433
+ "div",
434
+ {
435
+ id: dialogId,
436
+ role: "dialog",
437
+ "aria-modal": "true",
438
+ "aria-label": "Image preview",
439
+ onClick: () => setIsOpen(false),
440
+ style: {
441
+ position: "fixed",
442
+ inset: 0,
443
+ zIndex: 99999,
444
+ background: "rgba(0,0,0,0.88)",
445
+ display: "flex",
446
+ alignItems: "center",
447
+ justifyContent: "center",
448
+ padding: "1rem"
449
+ },
450
+ children: [
451
+ /* @__PURE__ */ jsx6(
452
+ "button",
453
+ {
454
+ ref: closeButtonRef,
455
+ type: "button",
456
+ "aria-label": "Close image preview",
457
+ onClick: (e) => {
458
+ e.stopPropagation();
459
+ setIsOpen(false);
460
+ },
461
+ style: {
462
+ position: "absolute",
463
+ top: 16,
464
+ right: 16,
465
+ border: "1px solid rgba(255,255,255,0.24)",
466
+ borderRadius: 8,
467
+ background: "rgba(0,0,0,0.45)",
468
+ color: "#fff",
469
+ padding: "0.4rem 0.55rem",
470
+ cursor: "pointer"
471
+ },
472
+ children: "Close"
473
+ }
474
+ ),
475
+ /* @__PURE__ */ jsx6(
476
+ "div",
477
+ {
478
+ onClick: (e) => e.stopPropagation(),
479
+ style: {
480
+ maxWidth: "92vw",
481
+ maxHeight: "90vh",
482
+ display: "flex",
483
+ alignItems: "center",
484
+ justifyContent: "center"
485
+ },
486
+ children: /* @__PURE__ */ jsx6(
487
+ Image,
488
+ {
489
+ src,
490
+ alt,
491
+ width: 1920,
492
+ height: 1080,
493
+ style: {
494
+ width: "auto",
495
+ height: "auto",
496
+ maxWidth: "92vw",
497
+ maxHeight: "90vh",
498
+ objectFit: "contain",
499
+ borderRadius: 10
500
+ }
501
+ }
502
+ )
503
+ }
504
+ )
505
+ ]
506
+ }
507
+ ) }) : null
508
+ ] });
509
+ }
510
+ function Portal({ children }) {
511
+ if (typeof window === "undefined") return null;
512
+ return createPortal(children, document.body);
513
+ }
514
+
515
+ // src/components/LinkMdx.tsx
516
+ import { jsx as jsx7 } from "react/jsx-runtime";
517
+ function LinkMdx({ href, rel, target, ...props }) {
518
+ if (!href) return null;
519
+ const external = /^https?:\/\//.test(href);
520
+ const computedTarget = target ?? (external ? "_blank" : void 0);
521
+ const computedRel = rel ?? (external ? "noopener noreferrer" : void 0);
522
+ return /* @__PURE__ */ jsx7("a", { href, target: computedTarget, rel: computedRel, ...props });
523
+ }
524
+
525
+ // src/components/CardMdx.tsx
526
+ import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
527
+ var baseStyle = {
528
+ display: "block",
529
+ border: "1px solid hsl(var(--border-color, 210 20% 85%))",
530
+ borderRadius: 14,
531
+ background: "hsl(var(--card, 0 0% 100%))",
532
+ color: "hsl(var(--foreground, 220 30% 15%))",
533
+ textDecoration: "none",
534
+ padding: "1rem",
535
+ minHeight: 120,
536
+ boxShadow: "0 0 0 rgba(0,0,0,0)",
537
+ transition: "border-color 0.2s ease, box-shadow 0.24s ease, transform 0.24s ease, color 0.2s ease",
538
+ overflow: "hidden"
539
+ };
540
+ function CardMdx({
541
+ title,
542
+ icon,
543
+ href,
544
+ horizontal,
545
+ children,
546
+ style,
547
+ className,
548
+ __LinkComponent,
549
+ ...props
550
+ }) {
551
+ const resolvedIcon = resolveLucideIcon(icon);
552
+ const LinkComponent = __LinkComponent ?? LinkMdx;
553
+ const content = /* @__PURE__ */ jsxs5(
554
+ "div",
555
+ {
556
+ style: {
557
+ display: "grid",
558
+ gridTemplateColumns: horizontal ? "auto 1fr" : "1fr",
559
+ gap: horizontal ? "0.75rem" : "0.4rem",
560
+ alignItems: horizontal ? "flex-start" : "flex-start"
561
+ },
562
+ children: [
563
+ resolvedIcon ? /* @__PURE__ */ jsx8(
564
+ "span",
565
+ {
566
+ "aria-hidden": "true",
567
+ "data-card-icon": "",
568
+ style: {
569
+ display: "block",
570
+ alignItems: "center",
571
+ justifyContent: "center",
572
+ width: "1rem",
573
+ height: "1rem",
574
+ color: "hsl(var(--primary, 210 81% 56%))",
575
+ fontSize: "2rem",
576
+ transition: "transform 0.2s ease, color 0.2s ease"
577
+ },
578
+ children: resolvedIcon
579
+ }
580
+ ) : null,
581
+ /* @__PURE__ */ jsxs5("div", { style: { display: "grid", gridAutoRows: "min-content", gap: 0 }, children: [
582
+ /* @__PURE__ */ jsx8(
583
+ "div",
584
+ {
585
+ style: {
586
+ fontWeight: 700,
587
+ fontSize: "1.22rem",
588
+ lineHeight: 1.3,
589
+ color: "hsl(var(--foreground, 220 30% 15%))"
590
+ },
591
+ children: title
592
+ }
593
+ ),
594
+ children ? /* @__PURE__ */ jsx8(
595
+ "div",
596
+ {
597
+ style: {
598
+ color: "hsl(var(--muted-foreground, 220 15% 50%))",
599
+ fontSize: "0.96rem",
600
+ lineHeight: 1.42,
601
+ marginTop: "-0.5rem"
602
+ },
603
+ children
604
+ }
605
+ ) : null
606
+ ] })
607
+ ]
608
+ }
609
+ );
610
+ const combinedStyle = { ...baseStyle, ...style };
611
+ if (href) {
612
+ return /* @__PURE__ */ jsx8(
613
+ LinkComponent,
614
+ {
615
+ href,
616
+ "data-card-hover": "",
617
+ "data-card-link": "",
618
+ style: combinedStyle,
619
+ ...className ? { className } : {},
620
+ ...props,
621
+ children: content
622
+ }
623
+ );
624
+ }
625
+ return /* @__PURE__ */ jsx8("div", { style: combinedStyle, ...className ? { className } : {}, ...props, children: content });
626
+ }
627
+
628
+ // src/components/FileTreeMdx.tsx
629
+ import React, {
630
+ useId as useId5,
631
+ useState as useState6
632
+ } from "react";
633
+ import { ChevronRight as ChevronRight2, File as FileIcon, Folder as FolderIcon, FolderOpen } from "lucide-react";
634
+ import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
635
+ function FilesMdx({ children, style, className, ...props }) {
636
+ return /* @__PURE__ */ jsx9(
637
+ "div",
638
+ {
639
+ className,
640
+ ...props,
641
+ role: "tree",
642
+ "aria-label": props["aria-label"] ?? "File tree",
643
+ style: {
644
+ border: "1px solid hsl(var(--border-color, 210 20% 85%))",
645
+ borderRadius: 12,
646
+ padding: "0.5rem",
647
+ margin: "1rem 0",
648
+ background: "hsla(var(--card, 0 0% 100%) / 0.9)",
649
+ backdropFilter: "blur(8px)",
650
+ boxShadow: "0 10px 20px rgba(0,0,0,0.05)",
651
+ ...style
652
+ },
653
+ children
654
+ }
655
+ );
656
+ }
657
+ function FolderMdx({ name, children, style, className, ...props }) {
658
+ const [isOpen, setIsOpen] = useState6(true);
659
+ const [isHovered, setIsHovered] = useState6(false);
660
+ const [isFocused, setIsFocused] = useState6(false);
661
+ const hasChildren = React.Children.count(children) > 0;
662
+ const groupId = useId5();
663
+ const handleKeyDown = (event) => {
664
+ if (!hasChildren) {
665
+ return;
666
+ }
667
+ if (event.key === "ArrowRight") {
668
+ event.preventDefault();
669
+ setIsOpen(true);
670
+ return;
671
+ }
672
+ if (event.key === "ArrowLeft") {
673
+ event.preventDefault();
674
+ setIsOpen(false);
675
+ return;
676
+ }
677
+ if (event.key === "Enter" || event.key === " ") {
678
+ event.preventDefault();
679
+ setIsOpen((prev) => !prev);
680
+ }
681
+ };
682
+ return /* @__PURE__ */ jsxs6(
683
+ "div",
684
+ {
685
+ className,
686
+ ...props,
687
+ role: "treeitem",
688
+ "aria-expanded": hasChildren ? isOpen : void 0,
689
+ style: { marginLeft: "0.35rem", ...style },
690
+ children: [
691
+ /* @__PURE__ */ jsxs6(
692
+ "button",
693
+ {
694
+ type: "button",
695
+ className: "flex items-center gap-2 rounded-md px-2 py-1.5 transition-colors duration-150",
696
+ onClick: () => hasChildren && setIsOpen((prev) => !prev),
697
+ onMouseEnter: () => setIsHovered(true),
698
+ onMouseLeave: () => setIsHovered(false),
699
+ onFocus: () => setIsFocused(true),
700
+ onBlur: () => setIsFocused(false),
701
+ onKeyDown: handleKeyDown,
702
+ "aria-label": `${isOpen ? "Collapse" : "Expand"} folder ${name}`,
703
+ "aria-expanded": hasChildren ? isOpen : void 0,
704
+ "aria-controls": hasChildren ? groupId : void 0,
705
+ style: {
706
+ cursor: hasChildren ? "pointer" : "default",
707
+ width: "100%",
708
+ border: "none",
709
+ textAlign: "left",
710
+ background: isHovered || isFocused ? "hsla(var(--muted, 210 20% 92%) / 0.45)" : "transparent"
711
+ },
712
+ children: [
713
+ hasChildren ? /* @__PURE__ */ jsx9(
714
+ ChevronRight2,
715
+ {
716
+ className: "h-3.5 w-3.5 transition-transform duration-200",
717
+ style: {
718
+ transform: isOpen ? "rotate(90deg)" : "rotate(0deg)",
719
+ color: isHovered || isFocused ? "hsl(var(--primary, 210 81% 56%))" : "hsl(var(--muted-foreground, 220 15% 50%))"
720
+ }
721
+ }
722
+ ) : /* @__PURE__ */ jsx9("div", { className: "w-3.5" }),
723
+ isOpen ? /* @__PURE__ */ jsx9(
724
+ FolderOpen,
725
+ {
726
+ className: "h-4 w-4",
727
+ style: {
728
+ color: isHovered || isFocused ? "hsl(var(--primary, 210 81% 56%))" : "hsl(var(--muted-foreground, 220 15% 50%))"
729
+ }
730
+ }
731
+ ) : /* @__PURE__ */ jsx9(
732
+ FolderIcon,
733
+ {
734
+ className: "h-4 w-4",
735
+ style: {
736
+ color: isHovered || isFocused ? "hsl(var(--primary, 210 81% 56%))" : "hsl(var(--muted-foreground, 220 15% 50%))"
737
+ }
738
+ }
739
+ ),
740
+ /* @__PURE__ */ jsx9(
741
+ "span",
742
+ {
743
+ style: {
744
+ fontWeight: 600,
745
+ color: isHovered || isFocused ? "hsl(var(--primary, 210 81% 56%))" : "hsl(var(--foreground, 220 30% 15%))"
746
+ },
747
+ children: name
748
+ }
749
+ )
750
+ ]
751
+ }
752
+ ),
753
+ isOpen && hasChildren && /* @__PURE__ */ jsx9(
754
+ "div",
755
+ {
756
+ id: groupId,
757
+ role: "group",
758
+ style: {
759
+ marginLeft: "1rem",
760
+ borderLeft: "2px solid hsl(var(--border-color, 210 20% 85%))",
761
+ paddingLeft: "0.6rem"
762
+ },
763
+ children
764
+ }
765
+ )
766
+ ]
767
+ }
768
+ );
769
+ }
770
+ function FileMdx({ name, style, className, ...props }) {
771
+ const [isHovered, setIsHovered] = useState6(false);
772
+ const [isFocused, setIsFocused] = useState6(false);
773
+ const fileExtension = name.split(".").pop()?.toUpperCase();
774
+ return /* @__PURE__ */ jsxs6(
775
+ "div",
776
+ {
777
+ className,
778
+ ...props,
779
+ role: "treeitem",
780
+ tabIndex: 0,
781
+ style: {
782
+ display: "flex",
783
+ alignItems: "center",
784
+ gap: "0.5rem",
785
+ padding: "0.33rem 0.5rem",
786
+ borderRadius: "0.45rem",
787
+ userSelect: "none",
788
+ background: isHovered || isFocused ? "hsla(var(--muted, 210 20% 92%) / 0.35)" : "transparent",
789
+ ...style
790
+ },
791
+ onMouseEnter: () => setIsHovered(true),
792
+ onMouseLeave: () => setIsHovered(false),
793
+ onFocus: () => setIsFocused(true),
794
+ onBlur: () => setIsFocused(false),
795
+ children: [
796
+ /* @__PURE__ */ jsx9(
797
+ FileIcon,
798
+ {
799
+ className: "h-3.5 w-3.5",
800
+ style: {
801
+ color: isHovered || isFocused ? "hsl(var(--primary, 210 81% 56%))" : "hsl(var(--muted-foreground, 220 15% 50%))"
802
+ }
803
+ }
804
+ ),
805
+ /* @__PURE__ */ jsx9(
806
+ "span",
807
+ {
808
+ style: {
809
+ fontFamily: "SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace",
810
+ fontSize: "0.9rem",
811
+ color: "hsl(var(--foreground, 220 30% 15%))"
812
+ },
813
+ children: name
814
+ }
815
+ ),
816
+ (isHovered || isFocused) && fileExtension && /* @__PURE__ */ jsx9(
817
+ "span",
818
+ {
819
+ style: {
820
+ marginLeft: "auto",
821
+ fontSize: "0.7rem",
822
+ color: "hsl(var(--muted-foreground, 220 15% 50%))"
823
+ },
824
+ children: fileExtension
825
+ }
826
+ )
827
+ ]
828
+ }
829
+ );
830
+ }
831
+
832
+ // src/components/MermaidMdx.tsx
833
+ import {
834
+ useId as useId6,
835
+ useRef as useRef2,
836
+ useEffect as useEffect2,
837
+ useState as useState7
838
+ } from "react";
839
+ import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
840
+ var mermaidPromise = null;
841
+ function getTheme() {
842
+ return document.documentElement.classList.contains("dark") ? "dark" : "default";
843
+ }
844
+ var PAN_STEP = 50;
845
+ var ZOOM_STEP = 1.2;
846
+ var MIN_SCALE = 0.4;
847
+ var MAX_SCALE = 4;
848
+ var clampScale = (scale) => Math.min(MAX_SCALE, Math.max(MIN_SCALE, scale));
849
+ var controlButtonStyle = {
850
+ display: "flex",
851
+ alignItems: "center",
852
+ justifyContent: "center",
853
+ width: 28,
854
+ height: 28,
855
+ padding: 0,
856
+ border: "1px solid rgba(127,127,127,0.35)",
857
+ borderRadius: 6,
858
+ background: "rgba(127,127,127,0.12)",
859
+ color: "currentcolor",
860
+ cursor: "pointer"
861
+ };
862
+ function ControlButton({
863
+ label,
864
+ onClick,
865
+ cell,
866
+ children
867
+ }) {
868
+ return /* @__PURE__ */ jsx10(
869
+ "button",
870
+ {
871
+ type: "button",
872
+ "aria-label": label,
873
+ title: label,
874
+ onClick,
875
+ style: { ...controlButtonStyle, gridColumn: cell.col, gridRow: cell.row },
876
+ children: /* @__PURE__ */ jsx10(
877
+ "svg",
878
+ {
879
+ width: "14",
880
+ height: "14",
881
+ viewBox: "0 0 24 24",
882
+ fill: "none",
883
+ stroke: "currentColor",
884
+ strokeWidth: "2",
885
+ strokeLinecap: "round",
886
+ strokeLinejoin: "round",
887
+ "aria-hidden": "true",
888
+ children
889
+ }
890
+ )
891
+ }
892
+ );
893
+ }
894
+ function MermaidMdx({ chart, id, className, panZoom = true }) {
895
+ const generatedId = useId6();
896
+ const domId = id ?? `mermaid-${generatedId.replace(/[:.]/g, "-")}`;
897
+ const ref = useRef2(null);
898
+ const chartRef = useRef2(chart);
899
+ const mermaidRef = useRef2(null);
900
+ const [error, setError] = useState7(null);
901
+ const [rendered, setRendered] = useState7(false);
902
+ const [view, setView] = useState7({ x: 0, y: 0, scale: 1 });
903
+ const [fullscreen, setFullscreen] = useState7(false);
904
+ chartRef.current = chart;
905
+ useEffect2(() => {
906
+ if (typeof window === "undefined") return;
907
+ if (!chart) return;
908
+ let cancelled = false;
909
+ let lazyObserver = null;
910
+ let syncObserver = null;
911
+ let themeTimer = null;
912
+ let lastTheme = getTheme();
913
+ let runChain = Promise.resolve();
914
+ function enqueueRun(run) {
915
+ const next = runChain.then(() => {
916
+ if (cancelled || !ref.current?.isConnected) return;
917
+ return run();
918
+ });
919
+ runChain = next.catch(() => {
920
+ });
921
+ return next;
922
+ }
923
+ async function init() {
924
+ try {
925
+ if (!mermaidPromise) {
926
+ mermaidPromise = import("mermaid");
927
+ }
928
+ const mod = await mermaidPromise;
929
+ const mermaid = mermaidRef.current = mod.default;
930
+ mermaid.initialize({ startOnLoad: false, theme: getTheme() });
931
+ try {
932
+ await mermaid.parse(chart);
933
+ } catch {
934
+ if (!cancelled) setError("Invalid Mermaid syntax");
935
+ return;
936
+ }
937
+ if (cancelled || !ref.current) return;
938
+ lazyObserver = new IntersectionObserver(
939
+ ([entry]) => {
940
+ if (!entry.isIntersecting || cancelled || !ref.current) return;
941
+ enqueueRun(() => {
942
+ const node = ref.current;
943
+ if (!node) return Promise.resolve();
944
+ return mermaid.run({ nodes: [node] });
945
+ }).then(() => {
946
+ if (!cancelled) setRendered(true);
947
+ }).catch(() => {
948
+ if (!cancelled) setError("Failed to render diagram");
949
+ });
950
+ lazyObserver?.disconnect();
951
+ },
952
+ { rootMargin: "200px" }
953
+ );
954
+ lazyObserver.observe(ref.current);
955
+ } catch {
956
+ if (!cancelled) setError("Failed to load Mermaid renderer");
957
+ }
958
+ }
959
+ init();
960
+ syncObserver = new MutationObserver(() => {
961
+ if (themeTimer) clearTimeout(themeTimer);
962
+ themeTimer = setTimeout(() => {
963
+ if (cancelled || !mermaidRef.current || !ref.current) return;
964
+ if (getTheme() === lastTheme) return;
965
+ enqueueRun(() => {
966
+ const mermaid = mermaidRef.current;
967
+ const node = ref.current;
968
+ if (!mermaid || !node) return Promise.resolve();
969
+ lastTheme = getTheme();
970
+ node.textContent = chartRef.current;
971
+ node.removeAttribute("data-processed");
972
+ mermaid.initialize({ startOnLoad: false, theme: lastTheme });
973
+ return mermaid.run({ nodes: [node] });
974
+ }).catch((e) => {
975
+ console.warn("[mermaid] diagram render error:", e);
976
+ });
977
+ }, 200);
978
+ });
979
+ syncObserver.observe(document.documentElement, {
980
+ attributes: true,
981
+ attributeFilter: ["class"]
982
+ });
983
+ return () => {
984
+ cancelled = true;
985
+ if (themeTimer) clearTimeout(themeTimer);
986
+ lazyObserver?.disconnect();
987
+ syncObserver?.disconnect();
988
+ };
989
+ }, []);
990
+ useEffect2(() => {
991
+ if (!fullscreen) return;
992
+ const previous = document.body.style.overflow;
993
+ document.body.style.overflow = "hidden";
994
+ return () => {
995
+ document.body.style.overflow = previous;
996
+ };
997
+ }, [fullscreen]);
998
+ if (!chart) return null;
999
+ const pan = (dx, dy) => setView((v) => ({ ...v, x: v.x + dx, y: v.y + dy }));
1000
+ const zoom = (factor) => setView((v) => ({ ...v, scale: clampScale(v.scale * factor) }));
1001
+ const resetView = () => setView({ x: 0, y: 0, scale: 1 });
1002
+ const controlsActive = panZoom && rendered;
1003
+ const handleKeyDown = (e) => {
1004
+ if (!controlsActive || e.ctrlKey || e.metaKey || e.altKey) return;
1005
+ const actions = {
1006
+ ArrowUp: () => pan(0, -PAN_STEP),
1007
+ ArrowDown: () => pan(0, PAN_STEP),
1008
+ ArrowLeft: () => pan(-PAN_STEP, 0),
1009
+ ArrowRight: () => pan(PAN_STEP, 0),
1010
+ "+": () => zoom(ZOOM_STEP),
1011
+ "=": () => zoom(ZOOM_STEP),
1012
+ "-": () => zoom(1 / ZOOM_STEP),
1013
+ "0": resetView,
1014
+ ...fullscreen ? { Escape: () => setFullscreen(false) } : {}
1015
+ };
1016
+ const action = actions[e.key];
1017
+ if (!action) return;
1018
+ e.preventDefault();
1019
+ action();
1020
+ };
1021
+ if (error) {
1022
+ return /* @__PURE__ */ jsxs7(
1023
+ "div",
1024
+ {
1025
+ className,
1026
+ style: {
1027
+ border: "1px solid hsl(var(--destructive, 0 85% 60%))",
1028
+ borderRadius: 8,
1029
+ padding: "0.75rem 1rem",
1030
+ margin: "1em 0"
1031
+ },
1032
+ children: [
1033
+ /* @__PURE__ */ jsx10(
1034
+ "p",
1035
+ {
1036
+ style: {
1037
+ color: "hsl(var(--destructive, 0 85% 60%))",
1038
+ fontWeight: 600,
1039
+ marginBottom: 8,
1040
+ fontSize: "0.875rem"
1041
+ },
1042
+ children: "\u26A0\uFE0F Diagram rendering error"
1043
+ }
1044
+ ),
1045
+ /* @__PURE__ */ jsx10(
1046
+ "pre",
1047
+ {
1048
+ style: {
1049
+ fontSize: "0.875rem",
1050
+ whiteSpace: "pre-wrap",
1051
+ margin: 0
1052
+ },
1053
+ children: chart
1054
+ }
1055
+ )
1056
+ ]
1057
+ }
1058
+ );
1059
+ }
1060
+ return /* @__PURE__ */ jsxs7(
1061
+ "div",
1062
+ {
1063
+ className: "max-w-full",
1064
+ tabIndex: controlsActive ? 0 : void 0,
1065
+ role: controlsActive ? "group" : void 0,
1066
+ "aria-label": controlsActive ? "Mermaid diagram. Use arrow keys to pan, + and - to zoom, 0 to reset." : void 0,
1067
+ onKeyDown: handleKeyDown,
1068
+ style: {
1069
+ ...fullscreen ? {
1070
+ position: "fixed",
1071
+ inset: 0,
1072
+ zIndex: 50,
1073
+ background: "hsl(var(--background, 0 0% 100%))",
1074
+ display: "flex",
1075
+ alignItems: "center",
1076
+ justifyContent: "center"
1077
+ } : { position: "relative" },
1078
+ ...controlsActive ? { overflow: "hidden" } : { overflowX: "auto" }
1079
+ },
1080
+ children: [
1081
+ /* @__PURE__ */ jsx10(
1082
+ "div",
1083
+ {
1084
+ style: controlsActive ? {
1085
+ transform: `translate(${view.x}px, ${view.y}px) scale(${view.scale})`,
1086
+ transformOrigin: "center center",
1087
+ transition: "transform 150ms ease"
1088
+ } : void 0,
1089
+ children: /* @__PURE__ */ jsx10(
1090
+ "pre",
1091
+ {
1092
+ ref,
1093
+ id: domId,
1094
+ className: `mermaid not-prose${className ? ` ${className}` : ""}`,
1095
+ style: { margin: "1em auto", width: "fit-content", maxWidth: "100%" },
1096
+ children: chart
1097
+ }
1098
+ )
1099
+ }
1100
+ ),
1101
+ controlsActive ? /* @__PURE__ */ jsxs7(
1102
+ "div",
1103
+ {
1104
+ role: "group",
1105
+ "aria-label": "Pan and zoom controls",
1106
+ style: {
1107
+ position: "absolute",
1108
+ bottom: 8,
1109
+ right: 8,
1110
+ display: "grid",
1111
+ gridTemplateColumns: "repeat(3, 28px)",
1112
+ gap: 4
1113
+ },
1114
+ children: [
1115
+ /* @__PURE__ */ jsx10(
1116
+ ControlButton,
1117
+ {
1118
+ label: fullscreen ? "Exit full screen" : "Enter full screen",
1119
+ onClick: () => setFullscreen((f) => !f),
1120
+ cell: { col: 1, row: 1 },
1121
+ children: fullscreen ? /* @__PURE__ */ jsx10("path", { d: "M8 3v3a2 2 0 0 1-2 2H3M21 8h-3a2 2 0 0 1-2-2V3M3 16h3a2 2 0 0 1 2 2v3M16 21v-3a2 2 0 0 1 2-2h3" }) : /* @__PURE__ */ jsx10("path", { d: "M8 3H5a2 2 0 0 0-2 2v3M21 8V5a2 2 0 0 0-2-2h-3M3 16v3a2 2 0 0 0 2 2h3M16 21h3a2 2 0 0 0 2-2v-3" })
1122
+ }
1123
+ ),
1124
+ /* @__PURE__ */ jsx10(ControlButton, { label: "Pan up", onClick: () => pan(0, -PAN_STEP), cell: { col: 2, row: 1 }, children: /* @__PURE__ */ jsx10("path", { d: "m18 15-6-6-6 6" }) }),
1125
+ /* @__PURE__ */ jsxs7(ControlButton, { label: "Zoom in", onClick: () => zoom(ZOOM_STEP), cell: { col: 3, row: 1 }, children: [
1126
+ /* @__PURE__ */ jsx10("circle", { cx: "11", cy: "11", r: "7" }),
1127
+ /* @__PURE__ */ jsx10("path", { d: "m21 21-4-4M8 11h6M11 8v6" })
1128
+ ] }),
1129
+ /* @__PURE__ */ jsx10(
1130
+ ControlButton,
1131
+ {
1132
+ label: "Pan left",
1133
+ onClick: () => pan(-PAN_STEP, 0),
1134
+ cell: { col: 1, row: 2 },
1135
+ children: /* @__PURE__ */ jsx10("path", { d: "m15 18-6-6 6-6" })
1136
+ }
1137
+ ),
1138
+ /* @__PURE__ */ jsxs7(ControlButton, { label: "Reset view", onClick: resetView, cell: { col: 2, row: 2 }, children: [
1139
+ /* @__PURE__ */ jsx10("path", { d: "M3 12a9 9 0 1 0 2.6-6.3L3 8" }),
1140
+ /* @__PURE__ */ jsx10("path", { d: "M3 3v5h5" })
1141
+ ] }),
1142
+ /* @__PURE__ */ jsx10(
1143
+ ControlButton,
1144
+ {
1145
+ label: "Pan right",
1146
+ onClick: () => pan(PAN_STEP, 0),
1147
+ cell: { col: 3, row: 2 },
1148
+ children: /* @__PURE__ */ jsx10("path", { d: "m9 18 6-6-6-6" })
1149
+ }
1150
+ ),
1151
+ /* @__PURE__ */ jsx10(
1152
+ ControlButton,
1153
+ {
1154
+ label: "Pan down",
1155
+ onClick: () => pan(0, PAN_STEP),
1156
+ cell: { col: 2, row: 3 },
1157
+ children: /* @__PURE__ */ jsx10("path", { d: "m6 9 6 6 6-6" })
1158
+ }
1159
+ ),
1160
+ /* @__PURE__ */ jsxs7(
1161
+ ControlButton,
1162
+ {
1163
+ label: "Zoom out",
1164
+ onClick: () => zoom(1 / ZOOM_STEP),
1165
+ cell: { col: 3, row: 3 },
1166
+ children: [
1167
+ /* @__PURE__ */ jsx10("circle", { cx: "11", cy: "11", r: "7" }),
1168
+ /* @__PURE__ */ jsx10("path", { d: "m21 21-4-4M8 11h6" })
1169
+ ]
1170
+ }
1171
+ )
1172
+ ]
1173
+ }
1174
+ ) : null
1175
+ ]
1176
+ }
1177
+ );
1178
+ }
1179
+ export {
1180
+ AccordionMdx,
1181
+ AccordionsMdx,
1182
+ CardMdx,
1183
+ FileMdx,
1184
+ FilesMdx,
1185
+ FolderMdx,
1186
+ ImageMdx,
1187
+ MermaidMdx,
1188
+ TabMdx,
1189
+ TabsMdx,
1190
+ TooltipMdx
1191
+ };
9
1192
  //# sourceMappingURL=client.js.map