specra 0.1.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 (142) hide show
  1. package/LICENSE.MD +21 -0
  2. package/README.md +157 -0
  3. package/dist/app/api/mdx-watch/route.d.mts +12 -0
  4. package/dist/app/api/mdx-watch/route.d.ts +12 -0
  5. package/dist/app/api/mdx-watch/route.js +98 -0
  6. package/dist/app/api/mdx-watch/route.js.map +1 -0
  7. package/dist/app/api/mdx-watch/route.mjs +71 -0
  8. package/dist/app/api/mdx-watch/route.mjs.map +1 -0
  9. package/dist/app/docs-page.d.mts +32 -0
  10. package/dist/app/docs-page.d.ts +32 -0
  11. package/dist/app/docs-page.js +4072 -0
  12. package/dist/app/docs-page.js.map +1 -0
  13. package/dist/app/docs-page.mjs +14 -0
  14. package/dist/app/docs-page.mjs.map +1 -0
  15. package/dist/app/layout.css +297 -0
  16. package/dist/app/layout.css.map +1 -0
  17. package/dist/app/layout.d.mts +19 -0
  18. package/dist/app/layout.d.ts +19 -0
  19. package/dist/app/layout.js +112 -0
  20. package/dist/app/layout.js.map +1 -0
  21. package/dist/app/layout.mjs +13 -0
  22. package/dist/app/layout.mjs.map +1 -0
  23. package/dist/chunk-DR4EPLMT.mjs +1013 -0
  24. package/dist/chunk-DR4EPLMT.mjs.map +1 -0
  25. package/dist/chunk-INL2EC72.mjs +170 -0
  26. package/dist/chunk-INL2EC72.mjs.map +1 -0
  27. package/dist/chunk-IZFGEAD6.mjs +61 -0
  28. package/dist/chunk-IZFGEAD6.mjs.map +1 -0
  29. package/dist/chunk-KTRWWAGL.mjs +50 -0
  30. package/dist/chunk-KTRWWAGL.mjs.map +1 -0
  31. package/dist/chunk-MZJHJ6BV.mjs +21 -0
  32. package/dist/chunk-MZJHJ6BV.mjs.map +1 -0
  33. package/dist/chunk-NXRIAL7T.mjs +3119 -0
  34. package/dist/chunk-NXRIAL7T.mjs.map +1 -0
  35. package/dist/components/index.d.mts +822 -0
  36. package/dist/components/index.d.ts +822 -0
  37. package/dist/components/index.js +3738 -0
  38. package/dist/components/index.js.map +1 -0
  39. package/dist/components/index.mjs +3627 -0
  40. package/dist/components/index.mjs.map +1 -0
  41. package/dist/index.css +297 -0
  42. package/dist/index.css.map +1 -0
  43. package/dist/index.d.mts +545 -0
  44. package/dist/index.d.ts +545 -0
  45. package/dist/index.js +4648 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/index.mjs +347 -0
  48. package/dist/index.mjs.map +1 -0
  49. package/dist/lib/index.d.mts +798 -0
  50. package/dist/lib/index.d.ts +798 -0
  51. package/dist/lib/index.js +1301 -0
  52. package/dist/lib/index.js.map +1 -0
  53. package/dist/lib/index.mjs +89 -0
  54. package/dist/lib/index.mjs.map +1 -0
  55. package/package.json +119 -0
  56. package/src/app/api/mdx-watch/route.ts +86 -0
  57. package/src/app/docs-page.tsx +212 -0
  58. package/src/app/layout.tsx +74 -0
  59. package/src/components/docs/accordion.tsx +53 -0
  60. package/src/components/docs/api/api-endpoint.tsx +59 -0
  61. package/src/components/docs/api/api-params.tsx +43 -0
  62. package/src/components/docs/api/api-playground.tsx +233 -0
  63. package/src/components/docs/api/api-reference.tsx +291 -0
  64. package/src/components/docs/api/api-response.tsx +48 -0
  65. package/src/components/docs/api/index.ts +5 -0
  66. package/src/components/docs/badge.tsx +22 -0
  67. package/src/components/docs/breadcrumb.tsx +51 -0
  68. package/src/components/docs/callout.tsx +109 -0
  69. package/src/components/docs/card.tsx +84 -0
  70. package/src/components/docs/category-index.tsx +112 -0
  71. package/src/components/docs/code-block.tsx +129 -0
  72. package/src/components/docs/columns.tsx +45 -0
  73. package/src/components/docs/componentTextProps.ts +85 -0
  74. package/src/components/docs/dev-mode-badge.tsx +35 -0
  75. package/src/components/docs/doc-layout-wrapper.tsx +54 -0
  76. package/src/components/docs/doc-layout.tsx +111 -0
  77. package/src/components/docs/doc-loading.tsx +15 -0
  78. package/src/components/docs/doc-metadata.tsx +55 -0
  79. package/src/components/docs/doc-navigation.tsx +62 -0
  80. package/src/components/docs/doc-tags.tsx +25 -0
  81. package/src/components/docs/draft-badge.tsx +10 -0
  82. package/src/components/docs/footer.tsx +47 -0
  83. package/src/components/docs/frame.tsx +22 -0
  84. package/src/components/docs/header.tsx +122 -0
  85. package/src/components/docs/hot-reload-indicator.tsx +77 -0
  86. package/src/components/docs/icon.tsx +70 -0
  87. package/src/components/docs/image-card.tsx +95 -0
  88. package/src/components/docs/image.tsx +73 -0
  89. package/src/components/docs/index.ts +48 -0
  90. package/src/components/docs/math.tsx +46 -0
  91. package/src/components/docs/mdx-components.tsx +166 -0
  92. package/src/components/docs/mdx-hot-reload.tsx +37 -0
  93. package/src/components/docs/mermaid.tsx +77 -0
  94. package/src/components/docs/mobile-doc-layout.tsx +115 -0
  95. package/src/components/docs/not-found-content.tsx +55 -0
  96. package/src/components/docs/search-highlight.tsx +127 -0
  97. package/src/components/docs/search-modal.tsx +223 -0
  98. package/src/components/docs/sidebar-skeleton.tsx +39 -0
  99. package/src/components/docs/sidebar.tsx +323 -0
  100. package/src/components/docs/site-banner.tsx +92 -0
  101. package/src/components/docs/steps.tsx +29 -0
  102. package/src/components/docs/tab-context.tsx +28 -0
  103. package/src/components/docs/tab-groups.tsx +50 -0
  104. package/src/components/docs/table-of-contents.tsx +104 -0
  105. package/src/components/docs/tabs.tsx +63 -0
  106. package/src/components/docs/theme-toggle.tsx +39 -0
  107. package/src/components/docs/tooltip.tsx +37 -0
  108. package/src/components/docs/version-switcher.tsx +52 -0
  109. package/src/components/docs/video.tsx +80 -0
  110. package/src/components/global/index.ts +3 -0
  111. package/src/components/global/version-not-found.tsx +26 -0
  112. package/src/components/index.ts +8 -0
  113. package/src/components/theme-provider.tsx +11 -0
  114. package/src/components/ui/badge.tsx +46 -0
  115. package/src/components/ui/button.tsx +60 -0
  116. package/src/components/ui/dialog.tsx +143 -0
  117. package/src/components/ui/index.ts +6 -0
  118. package/src/components/ui/input.tsx +21 -0
  119. package/src/components/ui/textarea.tsx +18 -0
  120. package/src/index.ts +41 -0
  121. package/src/lib/api-parser.types.ts +78 -0
  122. package/src/lib/api.types.ts +202 -0
  123. package/src/lib/category.ts +71 -0
  124. package/src/lib/config.server.ts +170 -0
  125. package/src/lib/config.ts +20 -0
  126. package/src/lib/config.types.ts +295 -0
  127. package/src/lib/dev-utils.ts +75 -0
  128. package/src/lib/index.ts +27 -0
  129. package/src/lib/mdx-cache.ts +200 -0
  130. package/src/lib/mdx.ts +402 -0
  131. package/src/lib/parsers/base-parser.ts +16 -0
  132. package/src/lib/parsers/index.ts +69 -0
  133. package/src/lib/parsers/openapi-parser.ts +251 -0
  134. package/src/lib/parsers/postman-parser.ts +301 -0
  135. package/src/lib/parsers/specra-parser.ts +24 -0
  136. package/src/lib/redirects.ts +40 -0
  137. package/src/lib/remark-code-meta.ts +23 -0
  138. package/src/lib/sidebar-utils.ts +188 -0
  139. package/src/lib/toc.ts +24 -0
  140. package/src/lib/utils.ts +36 -0
  141. package/src/specra.config.json +124 -0
  142. package/src/styles/globals.css +427 -0
@@ -0,0 +1,4072 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/app/docs-page.tsx
31
+ var docs_page_exports = {};
32
+ __export(docs_page_exports, {
33
+ default: () => DocPage,
34
+ generateMetadata: () => generateMetadata,
35
+ generateStaticParams: () => generateStaticParams
36
+ });
37
+ module.exports = __toCommonJS(docs_page_exports);
38
+
39
+ // src/lib/mdx.ts
40
+ var import_fs2 = __toESM(require("fs"));
41
+ var import_path2 = __toESM(require("path"));
42
+ var import_gray_matter = __toESM(require("gray-matter"));
43
+
44
+ // src/lib/category.ts
45
+ var import_fs = __toESM(require("fs"));
46
+ var import_path = __toESM(require("path"));
47
+ var DOCS_DIR = import_path.default.join(process.cwd(), "docs");
48
+ function getCategoryConfig(folderPath) {
49
+ try {
50
+ const categoryPath = import_path.default.join(folderPath, "_category_.json");
51
+ if (!import_fs.default.existsSync(categoryPath)) {
52
+ return null;
53
+ }
54
+ const content = import_fs.default.readFileSync(categoryPath, "utf8");
55
+ return JSON.parse(content);
56
+ } catch (error) {
57
+ console.error(`Error reading category config from ${folderPath}:`, error);
58
+ return null;
59
+ }
60
+ }
61
+ function getAllCategoryConfigs(version) {
62
+ const configs = /* @__PURE__ */ new Map();
63
+ const versionDir = import_path.default.join(DOCS_DIR, version);
64
+ if (!import_fs.default.existsSync(versionDir)) {
65
+ return configs;
66
+ }
67
+ function scanDirectory(dir, relativePath = "") {
68
+ const entries = import_fs.default.readdirSync(dir, { withFileTypes: true });
69
+ for (const entry of entries) {
70
+ if (entry.isDirectory()) {
71
+ const fullPath = import_path.default.join(dir, entry.name);
72
+ const relPath = relativePath ? `${relativePath}/${entry.name}` : entry.name;
73
+ const config = getCategoryConfig(fullPath);
74
+ if (config) {
75
+ configs.set(relPath, config);
76
+ }
77
+ scanDirectory(fullPath, relPath);
78
+ }
79
+ }
80
+ }
81
+ scanDirectory(versionDir);
82
+ return configs;
83
+ }
84
+
85
+ // src/lib/sidebar-utils.ts
86
+ function sortSidebarItems(items) {
87
+ return [...items].sort((a, b) => {
88
+ const posA = a.sidebar_position ?? a.meta?.sidebar_position ?? a.meta?.order ?? 999;
89
+ const posB = b.sidebar_position ?? b.meta?.sidebar_position ?? b.meta?.order ?? 999;
90
+ return posA - posB;
91
+ });
92
+ }
93
+ function sortSidebarGroups(groups) {
94
+ return Object.entries(groups).sort(([, a], [, b]) => {
95
+ const posA = a.position ?? 999;
96
+ const posB = b.position ?? 999;
97
+ return posA - posB;
98
+ });
99
+ }
100
+ function buildSidebarStructure(docs) {
101
+ const rootGroups = {};
102
+ const standalone = [];
103
+ const categoryMetadata = /* @__PURE__ */ new Map();
104
+ docs.forEach((doc) => {
105
+ const pathParts = doc.filePath.split("/");
106
+ const folderPath = pathParts.length > 1 ? pathParts.slice(0, -1).join("/") : "";
107
+ if (folderPath && doc.categoryLabel) {
108
+ categoryMetadata.set(folderPath, {
109
+ label: doc.categoryLabel,
110
+ position: doc.categoryPosition,
111
+ icon: doc.categoryIcon,
112
+ collapsible: doc.categoryCollapsible,
113
+ collapsed: doc.categoryCollapsed
114
+ });
115
+ }
116
+ });
117
+ docs.forEach((doc) => {
118
+ const pathParts = doc.filePath.split("/");
119
+ const isIndexFile = doc.filePath.endsWith("/index") || doc.filePath === "index" || pathParts.length > 1 && doc.slug === pathParts.slice(0, -1).join("/");
120
+ const customGroup = doc.meta.sidebar || doc.meta.group;
121
+ if (customGroup) {
122
+ const groupName = customGroup.charAt(0).toUpperCase() + customGroup.slice(1);
123
+ if (!rootGroups[groupName]) {
124
+ rootGroups[groupName] = {
125
+ label: groupName,
126
+ path: customGroup,
127
+ items: [],
128
+ position: 999,
129
+ collapsible: doc.categoryCollapsible ?? true,
130
+ defaultCollapsed: doc.categoryCollapsed ?? false,
131
+ children: {}
132
+ };
133
+ }
134
+ if (isIndexFile) {
135
+ rootGroups[groupName].position = doc.categoryPosition ?? doc.meta.sidebar_position ?? 999;
136
+ rootGroups[groupName].icon = doc.categoryIcon;
137
+ } else {
138
+ rootGroups[groupName].items.push(doc);
139
+ }
140
+ return;
141
+ }
142
+ if (pathParts.length > 1) {
143
+ const folderParts = pathParts.slice(0, -1);
144
+ let currentLevel = rootGroups;
145
+ let currentPath = "";
146
+ for (let i = 0; i < folderParts.length; i++) {
147
+ const folder = folderParts[i];
148
+ currentPath = currentPath ? `${currentPath}/${folder}` : folder;
149
+ const folderLabel = folder.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
150
+ const metadata = categoryMetadata.get(currentPath);
151
+ if (!currentLevel[folder]) {
152
+ currentLevel[folder] = {
153
+ label: metadata?.label ?? folderLabel,
154
+ path: currentPath,
155
+ icon: metadata?.icon,
156
+ items: [],
157
+ position: metadata?.position ?? 999,
158
+ collapsible: metadata?.collapsible ?? true,
159
+ defaultCollapsed: metadata?.collapsed ?? false,
160
+ children: {}
161
+ };
162
+ }
163
+ if (i === folderParts.length - 1) {
164
+ if (isIndexFile) {
165
+ currentLevel[folder].position = doc.categoryPosition ?? doc.meta.sidebar_position ?? currentLevel[folder].position;
166
+ if (doc.categoryLabel) {
167
+ currentLevel[folder].label = doc.categoryLabel;
168
+ }
169
+ if (doc.categoryIcon) {
170
+ currentLevel[folder].icon = doc.categoryIcon;
171
+ }
172
+ if (doc.categoryCollapsible !== void 0) {
173
+ currentLevel[folder].collapsible = doc.categoryCollapsible;
174
+ }
175
+ if (doc.categoryCollapsed !== void 0) {
176
+ currentLevel[folder].defaultCollapsed = doc.categoryCollapsed;
177
+ }
178
+ } else {
179
+ currentLevel[folder].items.push(doc);
180
+ }
181
+ }
182
+ currentLevel = currentLevel[folder].children;
183
+ }
184
+ } else {
185
+ if (!isIndexFile) {
186
+ standalone.push(doc);
187
+ }
188
+ }
189
+ });
190
+ return { rootGroups, standalone };
191
+ }
192
+
193
+ // src/lib/mdx.ts
194
+ var DOCS_DIR2 = import_path2.default.join(process.cwd(), "docs");
195
+ function calculateReadingTime(content) {
196
+ const words = content.trim().split(/\s+/).length;
197
+ const minutes = Math.ceil(words / 200);
198
+ return { minutes, words };
199
+ }
200
+ function getVersions() {
201
+ try {
202
+ const versions = import_fs2.default.readdirSync(DOCS_DIR2);
203
+ return versions.filter((v) => import_fs2.default.statSync(import_path2.default.join(DOCS_DIR2, v)).isDirectory());
204
+ } catch (error) {
205
+ return ["v1.0.0"];
206
+ }
207
+ }
208
+ function findMdxFiles(dir, baseDir = dir) {
209
+ const files = [];
210
+ try {
211
+ const entries = import_fs2.default.readdirSync(dir, { withFileTypes: true });
212
+ for (const entry of entries) {
213
+ const fullPath = import_path2.default.join(dir, entry.name);
214
+ if (entry.isDirectory()) {
215
+ files.push(...findMdxFiles(fullPath, baseDir));
216
+ } else if (entry.isFile() && entry.name.endsWith(".mdx")) {
217
+ const relativePath = import_path2.default.relative(baseDir, fullPath).replace(/\\/g, "/");
218
+ files.push(relativePath);
219
+ }
220
+ }
221
+ } catch (error) {
222
+ console.error(`Error reading directory ${dir}:`, error);
223
+ }
224
+ return files;
225
+ }
226
+ function readDocFromFile(filePath, originalSlug) {
227
+ try {
228
+ if (!import_fs2.default.existsSync(filePath)) {
229
+ return null;
230
+ }
231
+ const fileContents = import_fs2.default.readFileSync(filePath, "utf8");
232
+ const { data, content } = (0, import_gray_matter.default)(fileContents);
233
+ const { minutes, words } = calculateReadingTime(content);
234
+ let finalSlug = originalSlug;
235
+ if (data.slug) {
236
+ const customSlug = data.slug.replace(/^\//, "");
237
+ const parts = originalSlug.split("/");
238
+ if (parts.length > 1) {
239
+ parts[parts.length - 1] = customSlug;
240
+ finalSlug = parts.join("/");
241
+ } else {
242
+ finalSlug = customSlug;
243
+ }
244
+ }
245
+ return {
246
+ slug: finalSlug,
247
+ filePath: originalSlug,
248
+ // Keep original file path for sidebar
249
+ title: data.title || originalSlug,
250
+ meta: {
251
+ ...data,
252
+ content,
253
+ reading_time: minutes,
254
+ word_count: words
255
+ },
256
+ content
257
+ };
258
+ } catch (error) {
259
+ console.error(`Error reading file ${filePath}:`, error);
260
+ return null;
261
+ }
262
+ }
263
+ async function getDocBySlug(slug, version = "v1.0.0") {
264
+ try {
265
+ let filePath = import_path2.default.join(DOCS_DIR2, version, `${slug}.mdx`);
266
+ let doc = readDocFromFile(filePath, slug);
267
+ if (doc) return doc;
268
+ filePath = import_path2.default.join(DOCS_DIR2, version, slug, "index.mdx");
269
+ doc = readDocFromFile(filePath, slug);
270
+ if (doc) return doc;
271
+ const versionDir = import_path2.default.join(DOCS_DIR2, version);
272
+ if (!import_fs2.default.existsSync(versionDir)) {
273
+ return null;
274
+ }
275
+ const mdxFiles = findMdxFiles(versionDir);
276
+ for (const file of mdxFiles) {
277
+ const fileSlug = file.replace(/\.mdx$/, "");
278
+ const testPath = import_path2.default.join(versionDir, file.endsWith("index.mdx") ? file : `${fileSlug}.mdx`);
279
+ const testDoc = readDocFromFile(testPath, fileSlug);
280
+ if (testDoc && testDoc.slug === slug) {
281
+ return testDoc;
282
+ }
283
+ }
284
+ return null;
285
+ } catch (error) {
286
+ console.error(`Error reading doc ${slug}:`, error);
287
+ return null;
288
+ }
289
+ }
290
+ async function getAllDocs(version = "v1.0.0") {
291
+ try {
292
+ const versionDir = import_path2.default.join(DOCS_DIR2, version);
293
+ if (!import_fs2.default.existsSync(versionDir)) {
294
+ return [];
295
+ }
296
+ const mdxFiles = findMdxFiles(versionDir);
297
+ const categoryConfigs = getAllCategoryConfigs(version);
298
+ const docs = await Promise.all(
299
+ mdxFiles.map(async (file) => {
300
+ const originalFilePath = file.replace(/\.mdx$/, "");
301
+ let slug = originalFilePath;
302
+ if (file.endsWith("/index.mdx") || file === "index.mdx") {
303
+ slug = import_path2.default.dirname(file).replace(/\\/g, "/");
304
+ if (slug === ".") slug = "";
305
+ }
306
+ const doc = await getDocBySlug(slug, version);
307
+ if (doc) {
308
+ doc.filePath = originalFilePath;
309
+ const folderPath = import_path2.default.dirname(originalFilePath).replace(/\\/g, "/");
310
+ if (folderPath !== ".") {
311
+ const categoryConfig = categoryConfigs.get(folderPath);
312
+ if (categoryConfig) {
313
+ doc.categoryLabel = categoryConfig.label;
314
+ doc.categoryPosition = categoryConfig.position ?? categoryConfig.sidebar_position;
315
+ doc.categoryCollapsible = categoryConfig.collapsible;
316
+ doc.categoryCollapsed = categoryConfig.collapsed;
317
+ doc.categoryIcon = categoryConfig.icon;
318
+ doc.categoryTabGroup = categoryConfig.tab_group;
319
+ }
320
+ }
321
+ }
322
+ return doc;
323
+ })
324
+ );
325
+ const isDevelopment3 = process.env.NODE_ENV === "development";
326
+ const uniqueDocs = /* @__PURE__ */ new Map();
327
+ docs.filter((doc) => doc !== null).filter((doc) => isDevelopment3 || !doc.meta.draft).forEach((doc) => {
328
+ uniqueDocs.set(doc.slug, doc);
329
+ });
330
+ return Array.from(uniqueDocs.values()).sort((a, b) => {
331
+ const orderA = a.meta.sidebar_position ?? a.meta.order ?? 999;
332
+ const orderB = b.meta.sidebar_position ?? b.meta.order ?? 999;
333
+ return orderA - orderB;
334
+ });
335
+ } catch (error) {
336
+ console.error(`Error getting all docs for version ${version}:`, error);
337
+ return [];
338
+ }
339
+ }
340
+ function flattenSidebarOrder(rootGroups, standalone) {
341
+ const flatDocs = [];
342
+ const flattenGroup = (group) => {
343
+ const sortedChildren = sortSidebarGroups(group.children);
344
+ const sortedItems = sortSidebarItems(group.items);
345
+ const merged = [
346
+ ...sortedChildren.map(([, childGroup]) => ({
347
+ type: "group",
348
+ group: childGroup,
349
+ position: childGroup.position
350
+ })),
351
+ ...sortedItems.map((doc) => ({
352
+ type: "item",
353
+ doc,
354
+ position: doc.meta.sidebar_position ?? doc.meta.order ?? 999
355
+ }))
356
+ ];
357
+ merged.sort((a, b) => a.position - b.position);
358
+ merged.forEach((item) => {
359
+ if (item.type === "group") {
360
+ flattenGroup(item.group);
361
+ } else {
362
+ flatDocs.push(item.doc);
363
+ }
364
+ });
365
+ };
366
+ sortSidebarItems(standalone).forEach((doc) => {
367
+ flatDocs.push(doc);
368
+ });
369
+ const sortedRootGroups = sortSidebarGroups(rootGroups);
370
+ sortedRootGroups.forEach(([, group]) => {
371
+ flattenGroup(group);
372
+ });
373
+ return flatDocs;
374
+ }
375
+ function getAdjacentDocs(currentSlug, allDocs) {
376
+ const { rootGroups, standalone } = buildSidebarStructure(allDocs);
377
+ const orderedDocs = flattenSidebarOrder(rootGroups, standalone);
378
+ const currentIndex = orderedDocs.findIndex((doc) => doc.slug === currentSlug);
379
+ if (currentIndex === -1) {
380
+ return {};
381
+ }
382
+ const currentDoc = orderedDocs[currentIndex];
383
+ const currentTabGroup = currentDoc.meta?.tab_group || currentDoc.categoryTabGroup;
384
+ const filteredDocs = orderedDocs.filter((doc) => {
385
+ const docTabGroup = doc.meta?.tab_group || doc.categoryTabGroup;
386
+ if (currentTabGroup) {
387
+ return docTabGroup === currentTabGroup;
388
+ }
389
+ return !docTabGroup;
390
+ });
391
+ const filteredIndex = filteredDocs.findIndex((doc) => doc.slug === currentSlug);
392
+ if (filteredIndex === -1) {
393
+ return {};
394
+ }
395
+ return {
396
+ previous: filteredIndex > 0 ? filteredDocs[filteredIndex - 1] : void 0,
397
+ next: filteredIndex < filteredDocs.length - 1 ? filteredDocs[filteredIndex + 1] : void 0
398
+ };
399
+ }
400
+ function extractTableOfContents(content) {
401
+ const headingRegex = /^(#{2,3})\s+(.+)$/gm;
402
+ const toc = [];
403
+ let match;
404
+ while ((match = headingRegex.exec(content)) !== null) {
405
+ const level = match[1].length;
406
+ const text = match[2];
407
+ const id = text.toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "").replace(/^-|-$/g, "");
408
+ toc.push({ id, title: text, level });
409
+ }
410
+ return toc;
411
+ }
412
+ function isCategoryPage(slug, allDocs) {
413
+ return allDocs.some((doc) => {
414
+ const parts = doc.slug.split("/");
415
+ const docParent = parts.slice(0, -1).join("/");
416
+ return docParent === slug && doc.slug !== slug;
417
+ });
418
+ }
419
+
420
+ // src/lib/mdx-cache.ts
421
+ var import_fs3 = require("fs");
422
+ var import_path3 = require("path");
423
+
424
+ // src/lib/dev-utils.ts
425
+ var isDevelopment = process.env.NODE_ENV === "development";
426
+ var PerfTimer = class {
427
+ constructor(label) {
428
+ this.label = label;
429
+ this.startTime = isDevelopment ? performance.now() : 0;
430
+ }
431
+ end() {
432
+ if (!isDevelopment) return;
433
+ const duration = performance.now() - this.startTime;
434
+ const color = duration > 1e3 ? "\x1B[31m" : duration > 500 ? "\x1B[33m" : "\x1B[32m";
435
+ const reset = "\x1B[0m";
436
+ console.log(`${color}\u23F1\uFE0F ${this.label}: ${duration.toFixed(2)}ms${reset}`);
437
+ }
438
+ };
439
+ function logCacheOperation(operation, key) {
440
+ if (!isDevelopment) return;
441
+ const emoji = operation === "hit" ? "\u2705" : operation === "miss" ? "\u274C" : "\u{1F504}";
442
+ console.log(`${emoji} [Cache] ${operation}: ${key}`);
443
+ }
444
+
445
+ // src/lib/mdx-cache.ts
446
+ var isDevelopment2 = process.env.NODE_ENV === "development";
447
+ var versionsCache = {
448
+ data: null,
449
+ timestamp: 0
450
+ };
451
+ var allDocsCache = /* @__PURE__ */ new Map();
452
+ var docBySlugCache = /* @__PURE__ */ new Map();
453
+ var CACHE_TTL = isDevelopment2 ? 5e3 : 6e4;
454
+ var watchersInitialized = false;
455
+ function initializeWatchers() {
456
+ if (!isDevelopment2 || watchersInitialized) return;
457
+ watchersInitialized = true;
458
+ const docsPath = (0, import_path3.join)(process.cwd(), "docs");
459
+ try {
460
+ (0, import_fs3.watch)(docsPath, { recursive: true }, (eventType, filename) => {
461
+ if (!filename) return;
462
+ if (filename.endsWith(".mdx") || filename.endsWith(".json")) {
463
+ const parts = filename.split(/[/\\]/);
464
+ const version = parts[0];
465
+ allDocsCache.delete(version);
466
+ const cacheKeysToDelete = [];
467
+ docBySlugCache.forEach((_, key) => {
468
+ if (key.startsWith(`${version}:`)) {
469
+ cacheKeysToDelete.push(key);
470
+ }
471
+ });
472
+ cacheKeysToDelete.forEach((key) => docBySlugCache.delete(key));
473
+ if (eventType === "rename") {
474
+ versionsCache.data = null;
475
+ }
476
+ console.log(`[MDX Cache] Invalidated cache for: ${filename}`);
477
+ }
478
+ });
479
+ console.log("[MDX Cache] File watchers initialized");
480
+ } catch (error) {
481
+ console.error("[MDX Cache] Failed to initialize watchers:", error);
482
+ }
483
+ }
484
+ function isCacheValid(timestamp) {
485
+ return Date.now() - timestamp < CACHE_TTL;
486
+ }
487
+ function getCachedVersions() {
488
+ initializeWatchers();
489
+ if (versionsCache.data && isCacheValid(versionsCache.timestamp)) {
490
+ logCacheOperation("hit", "versions");
491
+ return versionsCache.data;
492
+ }
493
+ logCacheOperation("miss", "versions");
494
+ const timer = new PerfTimer("getVersions");
495
+ const versions = getVersions();
496
+ timer.end();
497
+ versionsCache.data = versions;
498
+ versionsCache.timestamp = Date.now();
499
+ return versions;
500
+ }
501
+ async function getCachedAllDocs(version = "v1.0.0") {
502
+ initializeWatchers();
503
+ const cached = allDocsCache.get(version);
504
+ if (cached && isCacheValid(cached.timestamp)) {
505
+ logCacheOperation("hit", `getAllDocs:${version}`);
506
+ return cached.data;
507
+ }
508
+ logCacheOperation("miss", `getAllDocs:${version}`);
509
+ const timer = new PerfTimer(`getAllDocs(${version})`);
510
+ const docs = await getAllDocs(version);
511
+ timer.end();
512
+ allDocsCache.set(version, {
513
+ data: docs,
514
+ timestamp: Date.now()
515
+ });
516
+ return docs;
517
+ }
518
+ async function getCachedDocBySlug(slug, version = "v1.0.0") {
519
+ initializeWatchers();
520
+ const cacheKey = `${version}:${slug}`;
521
+ const cached = docBySlugCache.get(cacheKey);
522
+ if (cached && isCacheValid(cached.timestamp)) {
523
+ logCacheOperation("hit", `getDocBySlug:${cacheKey}`);
524
+ return cached.data;
525
+ }
526
+ logCacheOperation("miss", `getDocBySlug:${cacheKey}`);
527
+ const timer = new PerfTimer(`getDocBySlug(${slug})`);
528
+ const doc = await getDocBySlug(slug, version);
529
+ timer.end();
530
+ docBySlugCache.set(cacheKey, {
531
+ data: doc,
532
+ timestamp: Date.now()
533
+ });
534
+ return doc;
535
+ }
536
+
537
+ // src/components/docs/doc-layout.tsx
538
+ var import_lucide_react14 = require("lucide-react");
539
+ var import_rsc = require("next-mdx-remote/rsc");
540
+ var import_remark_gfm = __toESM(require("remark-gfm"));
541
+ var import_rehype_slug = __toESM(require("rehype-slug"));
542
+
543
+ // src/lib/remark-code-meta.ts
544
+ function remarkCodeMeta() {
545
+ return (tree) => {
546
+ const visit = (node) => {
547
+ if (node.type === "code" && node.meta) {
548
+ node.data = node.data || {};
549
+ node.data.hProperties = node.data.hProperties || {};
550
+ node.data.hProperties.meta = node.meta;
551
+ }
552
+ if (node.children) {
553
+ node.children.forEach(visit);
554
+ }
555
+ };
556
+ visit(tree);
557
+ };
558
+ }
559
+
560
+ // src/components/docs/code-block.tsx
561
+ var import_react = require("react");
562
+ var import_lucide_react = require("lucide-react");
563
+ var import_jsx_runtime = require("react/jsx-runtime");
564
+ function CodeBlock({ code, language, filename }) {
565
+ const [copied, setCopied] = (0, import_react.useState)(false);
566
+ const handleCopy = async () => {
567
+ await navigator.clipboard.writeText(code);
568
+ setCopied(true);
569
+ setTimeout(() => setCopied(false), 2e3);
570
+ };
571
+ const highlightCode = (code2, lang) => {
572
+ const lines = code2.split("\n");
573
+ return lines.map((line, i) => {
574
+ const tokens = [];
575
+ let currentPos = 0;
576
+ const patterns = [
577
+ { type: "comment", regex: /(\/\/.*$|\/\*[\s\S]*?\*\/|#.*$)/ },
578
+ { type: "string", regex: /("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`(?:[^`\\]|\\.)*`)/ },
579
+ {
580
+ type: "keyword",
581
+ regex: /\b(const|let|var|function|return|if|else|for|while|do|break|continue|switch|case|default|import|export|from|as|class|extends|implements|interface|type|enum|namespace|async|await|try|catch|finally|throw|new|this|super|static|public|private|protected|readonly|abstract|void|null|undefined|true|false|typeof|instanceof|delete|in|of)\b/
582
+ },
583
+ { type: "operator", regex: /([+\-*/%=<>!&|^~?:]+)/ },
584
+ { type: "number", regex: /\b(0x[a-fA-F0-9]+|0b[01]+|\d+\.?\d*(?:e[+-]?\d+)?)\b/ },
585
+ { type: "function", regex: /\b([a-zA-Z_$][\w$]*)\s*(?=\()/ },
586
+ { type: "property", regex: /\.([a-zA-Z_$][\w$]*)/ },
587
+ { type: "punctuation", regex: /([{}[\]();,])/ }
588
+ ];
589
+ while (currentPos < line.length) {
590
+ let matched = false;
591
+ for (const { type, regex } of patterns) {
592
+ const match = line.slice(currentPos).match(regex);
593
+ if (match && match.index === 0) {
594
+ tokens.push({ type, value: match[0] });
595
+ currentPos += match[0].length;
596
+ matched = true;
597
+ break;
598
+ }
599
+ }
600
+ if (!matched) {
601
+ const nextSpecialChar = line.slice(currentPos).search(/["'`/\w.+\-*/%=<>!&|^~?:;,()[\]{}#]/);
602
+ if (nextSpecialChar === -1) {
603
+ tokens.push({ type: "text", value: line.slice(currentPos) });
604
+ break;
605
+ } else if (nextSpecialChar > 0) {
606
+ tokens.push({ type: "text", value: line.slice(currentPos, currentPos + nextSpecialChar) });
607
+ currentPos += nextSpecialChar;
608
+ } else {
609
+ tokens.push({ type: "text", value: line[currentPos] });
610
+ currentPos++;
611
+ }
612
+ }
613
+ }
614
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "table-row", children: [
615
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "table-cell pr-4 text-right select-none text-muted-foreground/40 w-8 align-top", children: i + 1 }),
616
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "table-cell align-top", children: tokens.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\xA0" }) : tokens.map((token, j) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: `token-${token.type}`, children: token.value }, j)) })
617
+ ] }, i);
618
+ });
619
+ };
620
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "relative group my-2", children: [
621
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "bg-muted/50 dark:bg-muted/30 px-4 py-2 rounded-t-xl border border-b-0 border-border/50 flex items-center justify-between", children: [
622
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-3", children: [
623
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-1.5", children: [
624
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "w-3 h-3 rounded-full bg-red-500/80 dark:bg-red-500/60" }),
625
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "w-3 h-3 rounded-full bg-yellow-500/80 dark:bg-yellow-500/60" }),
626
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "w-3 h-3 rounded-full bg-green-500/80 dark:bg-green-500/60" })
627
+ ] }),
628
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-xs font-mono text-foreground", children: filename || "Code" })
629
+ ] }),
630
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2", children: [
631
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-xs text-muted-foreground/60 font-mono uppercase tracking-wide", children: language }),
632
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
633
+ "button",
634
+ {
635
+ onClick: handleCopy,
636
+ className: "p-1.5 rounded-md hover:bg-muted/50 transition-colors",
637
+ "aria-label": "Copy code",
638
+ children: copied ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Check, { className: "h-4 w-4 text-green-400" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Copy, { className: "h-4 w-4 text-muted-foreground" })
639
+ }
640
+ )
641
+ ] })
642
+ ] }),
643
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "bg-gray-200/50 dark:bg-[#0d1117] rounded-b-xl overflow-x-auto border border-border/50", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "p-2 text-[13px] font-mono leading-relaxed text-gray-800 dark:text-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { className: "table w-full", children: highlightCode(code, language) }) }) })
644
+ ] });
645
+ }
646
+
647
+ // src/components/docs/callout.tsx
648
+ var import_lucide_react2 = require("lucide-react");
649
+ var import_jsx_runtime2 = require("react/jsx-runtime");
650
+ function Callout({ children, type = "info", title }) {
651
+ const configs = {
652
+ info: {
653
+ icon: import_lucide_react2.Info,
654
+ className: "bg-blue-500/10 border-blue-500/30 text-blue-900 dark:bg-blue-400/5 dark:border-blue-500/20 dark:text-blue-400",
655
+ iconClassName: "text-blue-600 dark:text-blue-400",
656
+ titleClassName: "text-blue-700 dark:text-blue-300",
657
+ defaultTitle: "Info"
658
+ },
659
+ note: {
660
+ icon: import_lucide_react2.Info,
661
+ className: "bg-blue-500/10 border-blue-500/30 text-blue-900 dark:bg-blue-400/5 dark:border-blue-500/20 dark:text-blue-400",
662
+ iconClassName: "text-blue-600 dark:text-blue-400",
663
+ titleClassName: "text-blue-700 dark:text-blue-300",
664
+ defaultTitle: "Note"
665
+ },
666
+ warning: {
667
+ icon: import_lucide_react2.AlertTriangle,
668
+ className: "bg-yellow-500/10 border-yellow-500/30 text-yellow-900 dark:bg-yellow-400/5 dark:border-yellow-500/20 dark:text-yellow-400",
669
+ iconClassName: "text-yellow-600 dark:text-yellow-400",
670
+ titleClassName: "text-yellow-700 dark:text-yellow-300",
671
+ defaultTitle: "Warning"
672
+ },
673
+ success: {
674
+ icon: import_lucide_react2.CheckCircle2,
675
+ className: "bg-green-500/10 border-green-500/30 text-green-900 dark:bg-green-400/5 dark:border-green-500/20 dark:text-green-400",
676
+ iconClassName: "text-green-600 dark:text-green-400",
677
+ titleClassName: "text-green-700 dark:text-green-300",
678
+ defaultTitle: "Success"
679
+ },
680
+ error: {
681
+ icon: import_lucide_react2.XCircle,
682
+ className: "bg-red-500/10 border-red-500/30 text-red-900 dark:bg-red-400/5 dark:border-red-500/20 dark:text-red-400",
683
+ iconClassName: "text-red-600 dark:text-red-400",
684
+ titleClassName: "text-red-700 dark:text-red-300",
685
+ defaultTitle: "Error"
686
+ },
687
+ danger: {
688
+ icon: import_lucide_react2.XCircle,
689
+ className: "bg-red-500/10 border-red-500/30 text-red-900 dark:bg-red-400/5 dark:border-red-500/20 dark:text-red-400",
690
+ iconClassName: "text-red-600 dark:text-red-400",
691
+ titleClassName: "text-red-700 dark:text-red-300",
692
+ defaultTitle: "Danger"
693
+ },
694
+ tip: {
695
+ icon: import_lucide_react2.Lightbulb,
696
+ className: "bg-purple-500/10 border-purple-500/30 text-purple-900 dark:bg-purple-400/5 dark:border-purple-500/20 dark:text-purple-400",
697
+ iconClassName: "text-purple-600 dark:text-purple-400",
698
+ titleClassName: "text-purple-700 dark:text-purple-300",
699
+ defaultTitle: "Tip"
700
+ }
701
+ };
702
+ const config = configs[type];
703
+ const Icon2 = config.icon;
704
+ let _title = title || config.defaultTitle;
705
+ let content = children;
706
+ if (!title && children && typeof children === "object") {
707
+ const childArray = Array.isArray(children) ? children : [children];
708
+ const firstElement = childArray[0];
709
+ if (firstElement && typeof firstElement === "object" && "props" in firstElement) {
710
+ const props = firstElement.props;
711
+ if (props.children && Array.isArray(props.children)) {
712
+ const strongChild = props.children.find(
713
+ (child) => child && typeof child === "object" && child.type === "strong"
714
+ );
715
+ if (strongChild) {
716
+ _title = strongChild.props.children;
717
+ content = childArray.map((child, idx) => {
718
+ if (idx === 0 && typeof child === "object" && "props" in child) {
719
+ const newChildren = child.props.children.filter((c) => c !== strongChild);
720
+ return { ...child, props: { ...child.props, children: newChildren } };
721
+ }
722
+ return child;
723
+ });
724
+ }
725
+ }
726
+ }
727
+ }
728
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: `flex gap-3 p-4 rounded-xl border my-2 ${config.className}`, children: [
729
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex-shrink-0 mt-0.5", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon2, { className: `h-5 w-5 ${config.iconClassName}` }) }),
730
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex-1 space-y-0", children: [
731
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: `font-semibold text-sm ${config.titleClassName}`, children: _title }),
732
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "text-sm leading-relaxed [&>p]:mb-0 [&>p]:text-current", children: content })
733
+ ] })
734
+ ] });
735
+ }
736
+
737
+ // src/components/docs/accordion.tsx
738
+ var import_lucide_react3 = require("lucide-react");
739
+ var import_react2 = require("react");
740
+ var import_jsx_runtime3 = require("react/jsx-runtime");
741
+ function AccordionItem({ title, children, defaultOpen = false }) {
742
+ const [isOpen, setIsOpen] = (0, import_react2.useState)(defaultOpen);
743
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "border border-border rounded-xl overflow-hidden mb-2", children: [
744
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
745
+ "button",
746
+ {
747
+ onClick: () => setIsOpen(!isOpen),
748
+ className: "w-full flex items-center justify-between p-4 text-left bg-muted/30 hover:bg-muted/50 transition-colors",
749
+ children: [
750
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "font-medium text-foreground", children: title }),
751
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
752
+ import_lucide_react3.ChevronDown,
753
+ {
754
+ className: `h-5 w-5 text-muted-foreground transition-transform ${isOpen ? "rotate-180" : ""}`
755
+ }
756
+ )
757
+ ]
758
+ }
759
+ ),
760
+ isOpen && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "p-4 border-t border-border bg-background", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "prose prose-sm dark:prose-invert max-w-none [&>*:last-child]:mb-0", children }) })
761
+ ] });
762
+ }
763
+ function Accordion({ children, type = "multiple", className }) {
764
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: className || "my-6 space-y-2", children });
765
+ }
766
+
767
+ // src/components/docs/tabs.tsx
768
+ var import_react3 = require("react");
769
+ var import_jsx_runtime4 = require("react/jsx-runtime");
770
+ function Tab({ children }) {
771
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children });
772
+ }
773
+ function Tabs({ children, defaultValue }) {
774
+ const tabs = import_react3.Children.toArray(children).filter(import_react3.isValidElement);
775
+ const firstTabLabel = tabs[0]?.props.label || "";
776
+ const [activeTab, setActiveTab] = (0, import_react3.useState)(defaultValue || firstTabLabel);
777
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "my-6", children: [
778
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "flex items-center gap-1 border-b border-border mb-4", children: tabs.map((tab) => {
779
+ const label = tab.props.label;
780
+ const isActive = activeTab === label;
781
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
782
+ "button",
783
+ {
784
+ onClick: () => setActiveTab(label),
785
+ className: `px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${isActive ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
786
+ children: label
787
+ },
788
+ label
789
+ );
790
+ }) }),
791
+ tabs.map((tab) => {
792
+ const label = tab.props.label;
793
+ if (activeTab !== label) return null;
794
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "prose prose-slate dark:prose-invert max-w-none [&>*:first-child]:mt-0", children: tab.props.children }, label);
795
+ })
796
+ ] });
797
+ }
798
+
799
+ // src/components/docs/image.tsx
800
+ var import_image = __toESM(require("next/image"));
801
+ var import_react4 = require("react");
802
+ var import_lucide_react4 = require("lucide-react");
803
+ var import_jsx_runtime5 = require("react/jsx-runtime");
804
+ function Image({ src, alt, caption, width, height, zoom = true }) {
805
+ const [isZoomed, setIsZoomed] = (0, import_react4.useState)(false);
806
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
807
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("figure", { className: "my-6", children: [
808
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "relative group rounded-xl border border-border overflow-hidden bg-muted/30", children: [
809
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
810
+ import_image.default,
811
+ {
812
+ src,
813
+ alt,
814
+ width: width || 1200,
815
+ height: height || 675,
816
+ className: "w-full h-auto"
817
+ }
818
+ ),
819
+ zoom && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
820
+ "button",
821
+ {
822
+ onClick: () => setIsZoomed(true),
823
+ className: "absolute top-3 right-3 p-2 rounded-md bg-background/80 backdrop-blur-sm border border-border opacity-0 group-hover:opacity-100 transition-opacity hover:bg-background",
824
+ "aria-label": "Zoom image",
825
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react4.ZoomIn, { className: "h-4 w-4 text-foreground" })
826
+ }
827
+ )
828
+ ] }),
829
+ caption && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("figcaption", { className: "mt-2 text-center text-sm text-muted-foreground italic", children: caption })
830
+ ] }),
831
+ isZoomed && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
832
+ "div",
833
+ {
834
+ className: "fixed inset-0 z-50 bg-background/95 backdrop-blur-sm flex items-center justify-center p-4",
835
+ onClick: () => setIsZoomed(false),
836
+ children: [
837
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
838
+ "button",
839
+ {
840
+ onClick: () => setIsZoomed(false),
841
+ className: "absolute top-4 right-4 p-2 rounded-md bg-muted hover:bg-muted/80 transition-colors",
842
+ "aria-label": "Close",
843
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react4.X, { className: "h-5 w-5 text-foreground" })
844
+ }
845
+ ),
846
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "max-w-7xl max-h-[90vh] overflow-auto", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
847
+ import_image.default,
848
+ {
849
+ src,
850
+ alt,
851
+ width: width || 1920,
852
+ height: height || 1080,
853
+ className: "w-full h-auto"
854
+ }
855
+ ) })
856
+ ]
857
+ }
858
+ )
859
+ ] });
860
+ }
861
+
862
+ // src/components/docs/video.tsx
863
+ var import_jsx_runtime6 = require("react/jsx-runtime");
864
+ function Video({
865
+ src,
866
+ caption,
867
+ autoplay = false,
868
+ loop = false,
869
+ muted = false,
870
+ controls = true,
871
+ poster
872
+ }) {
873
+ const isYouTube = src.includes("youtube.com") || src.includes("youtu.be");
874
+ const isVimeo = src.includes("vimeo.com");
875
+ const getYouTubeId = (url) => {
876
+ const match = url.match(/(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/\s]{11})/);
877
+ return match ? match[1] : null;
878
+ };
879
+ const getVimeoId = (url) => {
880
+ const match = url.match(/vimeo\.com\/(\d+)/);
881
+ return match ? match[1] : null;
882
+ };
883
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("figure", { className: "my-6", children: [
884
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "relative rounded-xl border border-border overflow-hidden bg-muted/30", children: isYouTube ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "relative w-full", style: { paddingBottom: "56.25%" }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
885
+ "iframe",
886
+ {
887
+ className: "absolute top-0 left-0 w-full h-full",
888
+ src: `https://www.youtube.com/embed/${getYouTubeId(src)}${autoplay ? "?autoplay=1" : ""}`,
889
+ title: "YouTube video",
890
+ allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",
891
+ allowFullScreen: true
892
+ }
893
+ ) }) : isVimeo ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "relative w-full", style: { paddingBottom: "56.25%" }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
894
+ "iframe",
895
+ {
896
+ className: "absolute top-0 left-0 w-full h-full",
897
+ src: `https://player.vimeo.com/video/${getVimeoId(src)}${autoplay ? "?autoplay=1" : ""}`,
898
+ title: "Vimeo video",
899
+ allow: "autoplay; fullscreen; picture-in-picture",
900
+ allowFullScreen: true
901
+ }
902
+ ) }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
903
+ "video",
904
+ {
905
+ src,
906
+ controls,
907
+ autoPlay: autoplay,
908
+ loop,
909
+ muted,
910
+ poster,
911
+ className: "w-full h-auto",
912
+ children: "Your browser does not support the video tag."
913
+ }
914
+ ) }),
915
+ caption && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("figcaption", { className: "mt-2 text-center text-sm text-muted-foreground italic", children: caption })
916
+ ] });
917
+ }
918
+
919
+ // src/components/docs/card.tsx
920
+ var import_lucide_react5 = require("lucide-react");
921
+ var import_link = __toESM(require("next/link"));
922
+
923
+ // src/components/docs/icon.tsx
924
+ var LucideIcons = __toESM(require("lucide-react"));
925
+ var import_jsx_runtime7 = require("react/jsx-runtime");
926
+ function Icon({ icon, iconType = "regular", color, size = 20, className = "" }) {
927
+ if (typeof icon !== "string") {
928
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: `inline-flex items-center ${className}`, style: { color }, children: icon });
929
+ }
930
+ if (icon.startsWith("http") || icon.startsWith("/")) {
931
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
932
+ "img",
933
+ {
934
+ src: icon,
935
+ alt: "",
936
+ width: size,
937
+ height: size,
938
+ className: `inline-block ${className}`,
939
+ style: { color }
940
+ }
941
+ );
942
+ }
943
+ if (icon.startsWith("fa-")) {
944
+ const faClass = `fa-${iconType} ${icon}`;
945
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
946
+ "i",
947
+ {
948
+ className: `${faClass} ${className}`,
949
+ style: { fontSize: size, color },
950
+ "aria-hidden": "true"
951
+ }
952
+ );
953
+ }
954
+ const iconName = icon.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
955
+ const LucideIcon = LucideIcons[iconName];
956
+ if (LucideIcon) {
957
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
958
+ LucideIcon,
959
+ {
960
+ size,
961
+ className: `inline-block ${className}`,
962
+ style: { color },
963
+ "aria-hidden": "true"
964
+ }
965
+ );
966
+ }
967
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: `inline-flex items-center font-mono text-xs ${className}`, style: { color }, children: [
968
+ "[",
969
+ icon,
970
+ "]"
971
+ ] });
972
+ }
973
+
974
+ // src/components/docs/card.tsx
975
+ var import_jsx_runtime8 = require("react/jsx-runtime");
976
+ function Card({ title, description, href, icon, children, external = false }) {
977
+ const content = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex items-center gap-3", children: [
978
+ icon && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "shrink-0 w-10 h-10 rounded-xl bg-primary/10 flex items-center justify-center text-primary", children: typeof icon === "string" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { icon, size: 20 }) : icon }),
979
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex-1 min-w-0", children: [
980
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h3", { className: `font-semibold text-foreground mb-1 no-underline ${href ? "group-hover:text-primary transition-colors" : ""}`, children: title }),
981
+ description && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "text-sm text-muted-foreground line-clamp-2 no-underline", children: description }),
982
+ children && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "mt-2 text-sm text-muted-foreground no-underline", children })
983
+ ] }),
984
+ href && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "shrink-0 self-start mt-1", children: external ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react5.ExternalLink, { className: "h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors" }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react5.ArrowRight, { className: "h-4 w-4 text-muted-foreground group-hover:text-primary group-hover:translate-x-1 transition-all" }) })
985
+ ] }) });
986
+ if (href) {
987
+ const Component = external ? "a" : import_link.default;
988
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
989
+ Component,
990
+ {
991
+ href,
992
+ className: "card-link group block p-4 rounded-xl border border-border hover:border-primary/50 hover:bg-muted/50 transition-all",
993
+ ...external ? { target: "_blank", rel: "noopener noreferrer" } : {},
994
+ children: content
995
+ }
996
+ );
997
+ }
998
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "p-4 rounded-xl border border-border bg-muted/30 no-underline", children: content });
999
+ }
1000
+ function CardGrid({ children, cols = 2 }) {
1001
+ const gridCols = {
1002
+ 1: "grid-cols-1",
1003
+ 2: "grid-cols-1 md:grid-cols-2",
1004
+ 3: "grid-cols-1 md:grid-cols-2 lg:grid-cols-3"
1005
+ };
1006
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `grid ${gridCols[cols]} gap-4 my-6`, children });
1007
+ }
1008
+
1009
+ // src/components/docs/image-card.tsx
1010
+ var import_image2 = __toESM(require("next/image"));
1011
+ var import_link2 = __toESM(require("next/link"));
1012
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1013
+ function ImageCard({
1014
+ src,
1015
+ alt,
1016
+ title,
1017
+ description,
1018
+ href,
1019
+ external = false,
1020
+ aspectRatio = "video"
1021
+ }) {
1022
+ const aspectRatios = {
1023
+ square: "aspect-square",
1024
+ video: "aspect-video",
1025
+ portrait: "aspect-[3/4]"
1026
+ };
1027
+ const content = /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex flex-col gap-0 p-0", children: [
1028
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: `w-full ${aspectRatios[aspectRatio]} overflow-hidden ${title || description ? "rounded-t-xl" : "rounded-xl"} bg-muted relative`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1029
+ import_image2.default,
1030
+ {
1031
+ src,
1032
+ alt,
1033
+ fill: true,
1034
+ sizes: "(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw",
1035
+ className: "object-cover transition-transform duration-300 group-hover:scale-105"
1036
+ }
1037
+ ) }),
1038
+ (title || description) && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "p-3 flex flex-col gap-1", children: [
1039
+ title && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h3", { className: `font-semibold text-foreground mb-0 no-underline ${href ? "group-hover:text-primary transition-colors" : ""}`, children: title }),
1040
+ description && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-sm text-muted-foreground line-clamp-2 no-underline mb-0", children: description })
1041
+ ] })
1042
+ ] });
1043
+ if (href) {
1044
+ const Component = external ? "a" : import_link2.default;
1045
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1046
+ Component,
1047
+ {
1048
+ href,
1049
+ className: "image-card-link group block rounded-xl border border-border hover:border-primary/50 hover:shadow-lg transition-all overflow-hidden p-0",
1050
+ ...external ? { target: "_blank", rel: "noopener noreferrer" } : {},
1051
+ children: content
1052
+ }
1053
+ );
1054
+ }
1055
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "block rounded-xl border border-border overflow-hidden bg-card p-0", children: content });
1056
+ }
1057
+ function ImageCardGrid({ children, cols = 3 }) {
1058
+ const gridCols = {
1059
+ 1: "grid-cols-1",
1060
+ 2: "grid-cols-1 md:grid-cols-2",
1061
+ 3: "grid-cols-1 md:grid-cols-2 lg:grid-cols-3",
1062
+ 4: "grid-cols-1 md:grid-cols-2 lg:grid-cols-4"
1063
+ };
1064
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: `grid ${gridCols[cols]} gap-4 my-6`, children });
1065
+ }
1066
+
1067
+ // src/components/docs/steps.tsx
1068
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1069
+ function Steps({ children }) {
1070
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "my-6 ml-4 space-y-6 [counter-reset:step]", children });
1071
+ }
1072
+ function Step({ title, children }) {
1073
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "relative pl-8 pb-6 border-l-2 border-border last:border-l-0 last:pb-0 [counter-increment:step] before:content-[counter(step)] before:absolute before:left-0 before:-translate-x-1/2 before:w-8 before:h-8 before:rounded-full before:bg-primary before:text-primary-foreground before:flex before:items-center before:justify-center before:text-sm before:font-semibold before:z-10", children: [
1074
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "mb-2", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h3", { className: "text-lg font-semibold text-foreground", children: title }) }),
1075
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "prose prose-sm dark:prose-invert max-w-none [&>*:last-child]:mb-0", children })
1076
+ ] });
1077
+ }
1078
+
1079
+ // src/components/docs/mermaid.tsx
1080
+ var import_react5 = require("react");
1081
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1082
+ function Mermaid({ chart, caption }) {
1083
+ const containerRef = (0, import_react5.useRef)(null);
1084
+ const [error, setError] = (0, import_react5.useState)(null);
1085
+ (0, import_react5.useEffect)(() => {
1086
+ const renderChart = async () => {
1087
+ try {
1088
+ const mermaid = (await import("mermaid")).default;
1089
+ mermaid.initialize({
1090
+ startOnLoad: false,
1091
+ theme: document.documentElement.classList.contains("dark") ? "dark" : "default",
1092
+ securityLevel: "loose",
1093
+ fontFamily: "inherit"
1094
+ });
1095
+ if (containerRef.current) {
1096
+ const id = `mermaid-${Math.random().toString(36).substr(2, 9)}`;
1097
+ const { svg } = await mermaid.render(id, chart);
1098
+ containerRef.current.innerHTML = svg;
1099
+ }
1100
+ } catch (err) {
1101
+ console.error("Mermaid rendering error:", err);
1102
+ setError(err instanceof Error ? err.message : "Failed to render diagram");
1103
+ }
1104
+ };
1105
+ renderChart();
1106
+ const observer = new MutationObserver((mutations) => {
1107
+ mutations.forEach((mutation) => {
1108
+ if (mutation.attributeName === "class") {
1109
+ renderChart();
1110
+ }
1111
+ });
1112
+ });
1113
+ observer.observe(document.documentElement, { attributes: true });
1114
+ return () => observer.disconnect();
1115
+ }, [chart]);
1116
+ if (error) {
1117
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "my-6 p-4 rounded-xl border border-red-500/50 bg-red-500/10", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("p", { className: "text-sm text-red-600 dark:text-red-400 font-mono", children: [
1118
+ "Mermaid Error: ",
1119
+ error
1120
+ ] }) });
1121
+ }
1122
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("figure", { className: "my-6", children: [
1123
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1124
+ "div",
1125
+ {
1126
+ ref: containerRef,
1127
+ className: "flex justify-center items-center p-6 rounded-xl border border-border bg-muted/30 overflow-x-auto"
1128
+ }
1129
+ ),
1130
+ caption && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("figcaption", { className: "mt-2 text-center text-sm text-muted-foreground italic", children: caption })
1131
+ ] });
1132
+ }
1133
+
1134
+ // src/components/docs/math.tsx
1135
+ var import_react6 = require("react");
1136
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1137
+ function Math2({ children, block = false }) {
1138
+ const containerRef = (0, import_react6.useRef)(null);
1139
+ (0, import_react6.useEffect)(() => {
1140
+ const renderMath = async () => {
1141
+ try {
1142
+ const katex = (await import("katex")).default;
1143
+ if (containerRef.current) {
1144
+ katex.render(children, containerRef.current, {
1145
+ throwOnError: false,
1146
+ displayMode: block
1147
+ });
1148
+ }
1149
+ } catch (err) {
1150
+ console.error("KaTeX rendering error:", err);
1151
+ if (containerRef.current) {
1152
+ containerRef.current.textContent = children;
1153
+ }
1154
+ }
1155
+ };
1156
+ renderMath();
1157
+ }, [children, block]);
1158
+ if (block) {
1159
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1160
+ "div",
1161
+ {
1162
+ ref: containerRef,
1163
+ className: "my-6 overflow-x-auto text-center"
1164
+ }
1165
+ );
1166
+ }
1167
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { ref: containerRef, className: "inline-block" });
1168
+ }
1169
+
1170
+ // src/components/docs/columns.tsx
1171
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1172
+ function Columns({ children, cols = { sm: 1, md: 2, lg: 3 } }) {
1173
+ const colClasses = {
1174
+ 1: "grid-cols-1",
1175
+ 2: "grid-cols-2",
1176
+ 3: "grid-cols-3",
1177
+ 4: "grid-cols-4"
1178
+ };
1179
+ const smClass = cols.sm ? colClasses[cols.sm] : "grid-cols-1";
1180
+ const mdClass = cols.md ? `md:${colClasses[cols.md]}` : "";
1181
+ const lgClass = cols.lg ? `lg:${colClasses[cols.lg]}` : "";
1182
+ const xlClass = cols.xl ? `xl:${colClasses[cols.xl]}` : "";
1183
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: `grid ${smClass} ${mdClass} ${lgClass} ${xlClass} gap-4 my-6`, children });
1184
+ }
1185
+ function Column({ children, span = 1 }) {
1186
+ const spanClass = {
1187
+ 1: "col-span-1",
1188
+ 2: "col-span-2",
1189
+ 3: "col-span-3",
1190
+ 4: "col-span-4"
1191
+ };
1192
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: spanClass[span], children });
1193
+ }
1194
+
1195
+ // src/components/docs/badge.tsx
1196
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1197
+ function Badge({ children, variant = "default" }) {
1198
+ const variants = {
1199
+ default: "bg-muted text-foreground border-border",
1200
+ success: "bg-green-500/10 text-green-600 dark:text-green-400 border-green-500/20",
1201
+ warning: "bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 border-yellow-500/20",
1202
+ error: "bg-red-500/10 text-red-600 dark:text-red-400 border-red-500/20",
1203
+ info: "bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20"
1204
+ };
1205
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1206
+ "span",
1207
+ {
1208
+ className: `inline-flex items-center px-2 py-0.5 rounded-md text-xs font-medium border ${variants[variant]}`,
1209
+ children
1210
+ }
1211
+ );
1212
+ }
1213
+
1214
+ // src/components/docs/tooltip.tsx
1215
+ var import_react7 = require("react");
1216
+ var import_jsx_runtime15 = require("react/jsx-runtime");
1217
+ function Tooltip({ children, content, position = "top" }) {
1218
+ const [isVisible, setIsVisible] = (0, import_react7.useState)(false);
1219
+ const positions = {
1220
+ top: "bottom-full left-1/2 -translate-x-1/2 mb-2",
1221
+ bottom: "top-full left-1/2 -translate-x-1/2 mt-2",
1222
+ left: "right-full top-1/2 -translate-y-1/2 mr-2",
1223
+ right: "left-full top-1/2 -translate-y-1/2 ml-2"
1224
+ };
1225
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
1226
+ "span",
1227
+ {
1228
+ className: "relative inline-flex underline decoration-dotted cursor-help",
1229
+ onMouseEnter: () => setIsVisible(true),
1230
+ onMouseLeave: () => setIsVisible(false),
1231
+ children: [
1232
+ children,
1233
+ isVisible && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1234
+ "span",
1235
+ {
1236
+ className: `absolute ${positions[position]} z-50 px-2 py-1 text-xs text-white bg-gray-900 dark:bg-gray-700 rounded whitespace-nowrap pointer-events-none`,
1237
+ children: content
1238
+ }
1239
+ )
1240
+ ]
1241
+ }
1242
+ );
1243
+ }
1244
+
1245
+ // src/components/docs/frame.tsx
1246
+ var import_jsx_runtime16 = require("react/jsx-runtime");
1247
+ function Frame({ src, title = "Embedded content", height = 500, width = "100%" }) {
1248
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "my-6 rounded-xl border border-border overflow-hidden bg-muted/30", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1249
+ "iframe",
1250
+ {
1251
+ src,
1252
+ title,
1253
+ width,
1254
+ height,
1255
+ className: "w-full",
1256
+ loading: "lazy",
1257
+ sandbox: "allow-scripts allow-same-origin allow-forms allow-popups"
1258
+ }
1259
+ ) });
1260
+ }
1261
+
1262
+ // src/components/docs/api/api-endpoint.tsx
1263
+ var import_react8 = require("react");
1264
+ var import_lucide_react6 = require("lucide-react");
1265
+
1266
+ // src/lib/utils.ts
1267
+ var import_clsx = require("clsx");
1268
+ var import_tailwind_merge = require("tailwind-merge");
1269
+ function cn(...inputs) {
1270
+ return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
1271
+ }
1272
+ function getAssetPath(path3) {
1273
+ const basePath = process.env.NEXT_PUBLIC_BASE_PATH || process.env.__NEXT_ROUTER_BASEPATH || "";
1274
+ const normalizedPath = path3.startsWith("/") ? path3 : `/${path3}`;
1275
+ if (basePath) {
1276
+ const normalizedBase = basePath.startsWith("/") ? basePath : `/${basePath}`;
1277
+ const cleanBase = normalizedBase.replace(/\/$/, "");
1278
+ return `${cleanBase}${normalizedPath}`;
1279
+ }
1280
+ return normalizedPath;
1281
+ }
1282
+
1283
+ // src/components/docs/api/api-endpoint.tsx
1284
+ var import_jsx_runtime17 = require("react/jsx-runtime");
1285
+ var methodColors = {
1286
+ GET: "bg-blue-500/10 text-blue-600 dark:text-blue-400",
1287
+ POST: "bg-green-500/10 text-green-600 dark:text-green-400",
1288
+ PUT: "bg-orange-500/10 text-orange-600 dark:text-orange-400",
1289
+ PATCH: "bg-purple-500/10 text-purple-600 dark:text-purple-400",
1290
+ DELETE: "bg-red-500/10 text-red-600 dark:text-red-400"
1291
+ };
1292
+ function ApiEndpoint({ method, path: path3, summary, children, defaultOpen = false }) {
1293
+ const [isOpen, setIsOpen] = (0, import_react8.useState)(defaultOpen);
1294
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "not-prose mb-4 rounded-xl border border-border overflow-hidden", children: [
1295
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
1296
+ "button",
1297
+ {
1298
+ onClick: () => setIsOpen(!isOpen),
1299
+ className: "w-full flex items-center gap-3 px-4 py-3 text-left bg-muted/30 hover:bg-muted/50 transition-colors",
1300
+ children: [
1301
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1302
+ "span",
1303
+ {
1304
+ className: cn(
1305
+ "text-xs font-semibold px-2 py-0.5 rounded",
1306
+ methodColors[method]
1307
+ ),
1308
+ children: method
1309
+ }
1310
+ ),
1311
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("code", { className: "text-sm font-mono", children: path3 }),
1312
+ summary && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-sm text-muted-foreground ml-auto mr-2", children: summary }),
1313
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1314
+ import_lucide_react6.ChevronDown,
1315
+ {
1316
+ className: cn(
1317
+ "h-5 w-5 text-muted-foreground transition-transform flex-shrink-0",
1318
+ isOpen ? "rotate-180" : ""
1319
+ )
1320
+ }
1321
+ )
1322
+ ]
1323
+ }
1324
+ ),
1325
+ isOpen && children && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "border-t border-border bg-background", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "px-4 py-4 space-y-6", children }) })
1326
+ ] });
1327
+ }
1328
+
1329
+ // src/components/docs/api/api-params.tsx
1330
+ var import_jsx_runtime18 = require("react/jsx-runtime");
1331
+ function ApiParams({ title = "Parameters", params }) {
1332
+ if (!params || params.length === 0) return null;
1333
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "mb-6", children: [
1334
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("h4", { className: "text-sm font-semibold text-foreground mb-3", children: title }),
1335
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "space-y-3", children: params.map((param) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-1", children: [
1336
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-2", children: [
1337
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("code", { className: "text-sm font-mono text-foreground", children: param.name }),
1338
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-xs text-muted-foreground", children: param.type }),
1339
+ param.required && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-xs text-red-600 dark:text-red-400", children: "required" }),
1340
+ param.default && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { className: "text-xs text-muted-foreground", children: [
1341
+ "default: ",
1342
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("code", { className: "text-xs", children: param.default })
1343
+ ] })
1344
+ ] }),
1345
+ param.description && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { className: "text-sm text-muted-foreground", children: param.description })
1346
+ ] }, param.name)) })
1347
+ ] });
1348
+ }
1349
+
1350
+ // src/components/docs/api/api-response.tsx
1351
+ var import_jsx_runtime19 = require("react/jsx-runtime");
1352
+ var statusColors = {
1353
+ "2": "text-green-600 dark:text-green-400",
1354
+ "3": "text-blue-600 dark:text-blue-400",
1355
+ "4": "text-orange-600 dark:text-orange-400",
1356
+ "5": "text-red-600 dark:text-red-400"
1357
+ };
1358
+ function ApiResponse({ status, description, example, schema }) {
1359
+ const statusClass = statusColors[String(status)[0]] || "text-muted-foreground";
1360
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "mb-4", children: [
1361
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-2 mb-2", children: [
1362
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: `text-sm font-semibold ${statusClass}`, children: status }),
1363
+ description && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "text-sm text-muted-foreground", children: description })
1364
+ ] }),
1365
+ example && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "mb-3", children: [
1366
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "text-xs font-semibold text-muted-foreground mb-2", children: "Example Response" }),
1367
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1368
+ CodeBlock,
1369
+ {
1370
+ code: typeof example === "string" ? example : JSON.stringify(example, null, 2),
1371
+ language: "json"
1372
+ }
1373
+ )
1374
+ ] }),
1375
+ schema && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { children: [
1376
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "text-xs font-semibold text-muted-foreground mb-2", children: "Schema" }),
1377
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1378
+ CodeBlock,
1379
+ {
1380
+ code: typeof schema === "string" ? schema : JSON.stringify(schema, null, 2),
1381
+ language: "json"
1382
+ }
1383
+ )
1384
+ ] })
1385
+ ] });
1386
+ }
1387
+
1388
+ // src/components/docs/api/api-playground.tsx
1389
+ var import_react9 = require("react");
1390
+
1391
+ // src/components/ui/button.tsx
1392
+ var import_react_slot = require("@radix-ui/react-slot");
1393
+ var import_class_variance_authority = require("class-variance-authority");
1394
+ var import_jsx_runtime20 = require("react/jsx-runtime");
1395
+ var buttonVariants = (0, import_class_variance_authority.cva)(
1396
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
1397
+ {
1398
+ variants: {
1399
+ variant: {
1400
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
1401
+ destructive: "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
1402
+ outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
1403
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
1404
+ ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
1405
+ link: "text-primary underline-offset-4 hover:underline"
1406
+ },
1407
+ size: {
1408
+ default: "h-9 px-4 py-2 has-[>svg]:px-3",
1409
+ sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
1410
+ lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
1411
+ icon: "size-9",
1412
+ "icon-sm": "size-8",
1413
+ "icon-lg": "size-10"
1414
+ }
1415
+ },
1416
+ defaultVariants: {
1417
+ variant: "default",
1418
+ size: "default"
1419
+ }
1420
+ }
1421
+ );
1422
+ function Button({
1423
+ className,
1424
+ variant,
1425
+ size,
1426
+ asChild = false,
1427
+ ...props
1428
+ }) {
1429
+ const Comp = asChild ? import_react_slot.Slot : "button";
1430
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
1431
+ Comp,
1432
+ {
1433
+ "data-slot": "button",
1434
+ className: cn(buttonVariants({ variant, size, className })),
1435
+ ...props
1436
+ }
1437
+ );
1438
+ }
1439
+
1440
+ // src/components/ui/input.tsx
1441
+ var import_jsx_runtime21 = require("react/jsx-runtime");
1442
+ function Input({ className, type, ...props }) {
1443
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1444
+ "input",
1445
+ {
1446
+ type,
1447
+ "data-slot": "input",
1448
+ className: cn(
1449
+ "file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
1450
+ "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
1451
+ "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
1452
+ className
1453
+ ),
1454
+ ...props
1455
+ }
1456
+ );
1457
+ }
1458
+
1459
+ // src/components/ui/textarea.tsx
1460
+ var import_jsx_runtime22 = require("react/jsx-runtime");
1461
+ function Textarea({ className, ...props }) {
1462
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
1463
+ "textarea",
1464
+ {
1465
+ "data-slot": "textarea",
1466
+ className: cn(
1467
+ "border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
1468
+ className
1469
+ ),
1470
+ ...props
1471
+ }
1472
+ );
1473
+ }
1474
+
1475
+ // src/components/ui/badge.tsx
1476
+ var import_react_slot2 = require("@radix-ui/react-slot");
1477
+ var import_class_variance_authority2 = require("class-variance-authority");
1478
+ var import_jsx_runtime23 = require("react/jsx-runtime");
1479
+ var badgeVariants = (0, import_class_variance_authority2.cva)(
1480
+ "inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",
1481
+ {
1482
+ variants: {
1483
+ variant: {
1484
+ default: "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
1485
+ secondary: "border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
1486
+ destructive: "border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
1487
+ outline: "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"
1488
+ }
1489
+ },
1490
+ defaultVariants: {
1491
+ variant: "default"
1492
+ }
1493
+ }
1494
+ );
1495
+ function Badge2({
1496
+ className,
1497
+ variant,
1498
+ asChild = false,
1499
+ ...props
1500
+ }) {
1501
+ const Comp = asChild ? import_react_slot2.Slot : "span";
1502
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
1503
+ Comp,
1504
+ {
1505
+ "data-slot": "badge",
1506
+ className: cn(badgeVariants({ variant }), className),
1507
+ ...props
1508
+ }
1509
+ );
1510
+ }
1511
+
1512
+ // src/components/docs/api/api-playground.tsx
1513
+ var import_lucide_react7 = require("lucide-react");
1514
+ var import_jsx_runtime24 = require("react/jsx-runtime");
1515
+ function ApiPlayground({
1516
+ method,
1517
+ path: path3,
1518
+ baseUrl = "",
1519
+ headers = {},
1520
+ defaultBody,
1521
+ pathParams = []
1522
+ }) {
1523
+ const [loading, setLoading] = (0, import_react9.useState)(false);
1524
+ const [response, setResponse] = (0, import_react9.useState)(null);
1525
+ const [error, setError] = (0, import_react9.useState)(null);
1526
+ const [requestBody, setRequestBody] = (0, import_react9.useState)(defaultBody || "");
1527
+ const initialHeaders = (0, import_react9.useMemo)(() => {
1528
+ const cleanHeaders = {};
1529
+ Object.entries(headers).forEach(([key, value]) => {
1530
+ cleanHeaders[key] = value || "";
1531
+ });
1532
+ return cleanHeaders;
1533
+ }, [headers]);
1534
+ const [requestHeaders, setRequestHeaders] = (0, import_react9.useState)(JSON.stringify(initialHeaders, null, 2));
1535
+ const extractedParams = (0, import_react9.useMemo)(() => {
1536
+ const params = {};
1537
+ const pathParamPattern = /:(\w+)/g;
1538
+ let match;
1539
+ while ((match = pathParamPattern.exec(path3)) !== null) {
1540
+ const paramName = match[1];
1541
+ const paramConfig = pathParams.find((p) => p.name === paramName);
1542
+ if (paramConfig?.example !== void 0) {
1543
+ params[paramName] = String(paramConfig.example);
1544
+ } else if (paramConfig?.type === "number") {
1545
+ params[paramName] = "1";
1546
+ } else {
1547
+ params[paramName] = "";
1548
+ }
1549
+ }
1550
+ return params;
1551
+ }, [path3, pathParams]);
1552
+ const [pathParamValues, setPathParamValues] = (0, import_react9.useState)(extractedParams);
1553
+ const buildUrl = () => {
1554
+ let finalPath = path3;
1555
+ Object.entries(pathParamValues).forEach(([key, value]) => {
1556
+ finalPath = finalPath.replace(`:${key}`, value);
1557
+ });
1558
+ return `${baseUrl}${finalPath}`;
1559
+ };
1560
+ const handleSend = async () => {
1561
+ setLoading(true);
1562
+ setError(null);
1563
+ setResponse(null);
1564
+ try {
1565
+ const url = buildUrl();
1566
+ const parsedHeaders = JSON.parse(requestHeaders);
1567
+ const options = {
1568
+ method,
1569
+ headers: {
1570
+ "Content-Type": "application/json",
1571
+ ...parsedHeaders
1572
+ }
1573
+ };
1574
+ if (method !== "GET" && method !== "DELETE" && requestBody) {
1575
+ options.body = requestBody;
1576
+ }
1577
+ const res = await fetch(url, options);
1578
+ const data = await res.json();
1579
+ setResponse({
1580
+ status: res.status,
1581
+ statusText: res.statusText,
1582
+ headers: Object.fromEntries(res.headers.entries()),
1583
+ body: data
1584
+ });
1585
+ } catch (err) {
1586
+ setError(err instanceof Error ? err.message : "An error occurred");
1587
+ } finally {
1588
+ setLoading(false);
1589
+ }
1590
+ };
1591
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "not-prose border border-border rounded-lg overflow-hidden bg-card/30", children: [
1592
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "bg-muted/50 px-4 py-2 border-b border-border", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("h4", { className: "text-sm font-semibold text-foreground", children: "API Playground" }) }),
1593
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "p-4 space-y-4", children: [
1594
+ Object.keys(pathParamValues).length > 0 && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { children: [
1595
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("label", { className: "text-xs font-semibold text-muted-foreground mb-2 block", children: "Path Parameters" }),
1596
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "space-y-2", children: Object.entries(pathParamValues).map(([paramName, paramValue]) => {
1597
+ const paramConfig = pathParams.find((p) => p.name === paramName);
1598
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex items-center gap-2", children: [
1599
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("span", { className: "text-xs text-muted-foreground min-w-[80px]", children: [
1600
+ ":",
1601
+ paramName
1602
+ ] }),
1603
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
1604
+ Input,
1605
+ {
1606
+ value: paramValue,
1607
+ onChange: (e) => setPathParamValues((prev) => ({ ...prev, [paramName]: e.target.value })),
1608
+ placeholder: paramConfig?.example || paramConfig?.type || "value",
1609
+ className: "font-mono text-sm"
1610
+ }
1611
+ )
1612
+ ] }, paramName);
1613
+ }) })
1614
+ ] }),
1615
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { children: [
1616
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("label", { className: "text-xs font-semibold text-muted-foreground mb-2 block", children: "Request URL" }),
1617
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex items-center gap-2", children: [
1618
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Badge2, { variant: "outline", className: "font-mono", children: method }),
1619
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Input, { value: buildUrl(), readOnly: true, className: "font-mono text-sm" })
1620
+ ] })
1621
+ ] }),
1622
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { children: [
1623
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("label", { className: "text-xs font-semibold text-muted-foreground mb-2 block", children: "Headers (JSON)" }),
1624
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
1625
+ Textarea,
1626
+ {
1627
+ value: requestHeaders,
1628
+ onChange: (e) => setRequestHeaders(e.target.value),
1629
+ className: "font-mono text-sm",
1630
+ rows: 4
1631
+ }
1632
+ )
1633
+ ] }),
1634
+ method !== "GET" && method !== "DELETE" && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { children: [
1635
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("label", { className: "text-xs font-semibold text-muted-foreground mb-2 block", children: "Request Body (JSON)" }),
1636
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
1637
+ Textarea,
1638
+ {
1639
+ value: requestBody,
1640
+ onChange: (e) => setRequestBody(e.target.value),
1641
+ className: "font-mono text-sm",
1642
+ rows: 6,
1643
+ placeholder: '{\\n "key": "value"\\n}'
1644
+ }
1645
+ )
1646
+ ] }),
1647
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Button, { onClick: handleSend, disabled: loading, className: "w-full", children: loading ? /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
1648
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react7.Loader2, { className: "mr-2 h-4 w-4 animate-spin" }),
1649
+ "Sending..."
1650
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
1651
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react7.Play, { className: "mr-2 h-4 w-4" }),
1652
+ "Send Request"
1653
+ ] }) }),
1654
+ response && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "mt-4", children: [
1655
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("label", { className: "text-xs font-semibold text-muted-foreground mb-2 block", children: [
1656
+ "Response (",
1657
+ response.status,
1658
+ " ",
1659
+ response.statusText,
1660
+ ")"
1661
+ ] }),
1662
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(CodeBlock, { code: JSON.stringify(response.body, null, 2), language: "json" })
1663
+ ] }),
1664
+ error && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "mt-4 p-3 bg-red-500/10 border border-red-500/20 rounded-md", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "text-sm text-red-600 dark:text-red-400", children: error }) })
1665
+ ] })
1666
+ ] });
1667
+ }
1668
+
1669
+ // src/components/docs/api/api-reference.tsx
1670
+ var import_react10 = require("react");
1671
+
1672
+ // src/lib/parsers/specra-parser.ts
1673
+ var SpecraParser = class {
1674
+ validate(input) {
1675
+ return typeof input === "object" && input !== null && "endpoints" in input && Array.isArray(input.endpoints);
1676
+ }
1677
+ parse(input) {
1678
+ if (!this.validate(input)) {
1679
+ throw new Error("Invalid Specra API spec format");
1680
+ }
1681
+ return input;
1682
+ }
1683
+ };
1684
+
1685
+ // src/lib/parsers/openapi-parser.ts
1686
+ var OpenApiParser = class {
1687
+ validate(input) {
1688
+ return typeof input === "object" && input !== null && ("openapi" in input || "swagger" in input) && "paths" in input;
1689
+ }
1690
+ parse(input) {
1691
+ if (!this.validate(input)) {
1692
+ throw new Error("Invalid OpenAPI spec format");
1693
+ }
1694
+ const baseUrl = this.extractBaseUrl(input);
1695
+ const endpoints = [];
1696
+ for (const [path3, pathItem] of Object.entries(input.paths || {})) {
1697
+ const methods = ["get", "post", "put", "patch", "delete"];
1698
+ for (const method of methods) {
1699
+ const operation = pathItem[method];
1700
+ if (!operation) continue;
1701
+ const endpoint = this.parseOperation(path3, method.toUpperCase(), operation, input);
1702
+ endpoints.push(endpoint);
1703
+ }
1704
+ }
1705
+ return {
1706
+ version: input.info?.version,
1707
+ title: input.info?.title,
1708
+ description: input.info?.description,
1709
+ baseUrl,
1710
+ auth: this.extractAuth(input),
1711
+ endpoints
1712
+ };
1713
+ }
1714
+ extractBaseUrl(spec) {
1715
+ if (spec.servers && spec.servers.length > 0) {
1716
+ return spec.servers[0].url;
1717
+ }
1718
+ if (spec.host) {
1719
+ const scheme = spec.schemes?.[0] || "https";
1720
+ const basePath = spec.basePath || "";
1721
+ return `${scheme}://${spec.host}${basePath}`;
1722
+ }
1723
+ return "";
1724
+ }
1725
+ extractAuth(spec) {
1726
+ const securitySchemes = spec.components?.securitySchemes || spec.securityDefinitions;
1727
+ if (!securitySchemes) return void 0;
1728
+ const firstScheme = Object.values(securitySchemes)[0];
1729
+ if (!firstScheme) return void 0;
1730
+ if (firstScheme.type === "http" && firstScheme.scheme === "bearer") {
1731
+ return {
1732
+ type: "bearer",
1733
+ description: firstScheme.description,
1734
+ tokenPrefix: "Bearer"
1735
+ };
1736
+ }
1737
+ if (firstScheme.type === "apiKey") {
1738
+ return {
1739
+ type: "apiKey",
1740
+ description: firstScheme.description,
1741
+ headerName: firstScheme.name || "X-API-Key"
1742
+ };
1743
+ }
1744
+ if (firstScheme.type === "http" && firstScheme.scheme === "basic") {
1745
+ return {
1746
+ type: "basic",
1747
+ description: firstScheme.description
1748
+ };
1749
+ }
1750
+ return void 0;
1751
+ }
1752
+ parseOperation(path3, method, operation, spec) {
1753
+ const endpoint = {
1754
+ title: operation.summary || operation.operationId || `${method} ${path3}`,
1755
+ method,
1756
+ path: this.convertPathParams(path3),
1757
+ description: operation.description
1758
+ };
1759
+ const params = this.parseParameters(operation.parameters || [], spec);
1760
+ if (params.path.length > 0) endpoint.pathParams = params.path;
1761
+ if (params.query.length > 0) endpoint.queryParams = params.query;
1762
+ if (params.header.length > 0) {
1763
+ endpoint.headers = params.header.map((p) => ({
1764
+ name: p.name,
1765
+ value: p.example || "",
1766
+ description: p.description
1767
+ }));
1768
+ }
1769
+ if (operation.requestBody) {
1770
+ endpoint.body = this.parseRequestBody(operation.requestBody, spec);
1771
+ }
1772
+ const responses = this.parseResponses(operation.responses || {}, spec);
1773
+ if (responses.success) endpoint.successResponse = responses.success;
1774
+ if (responses.errors.length > 0) endpoint.errorResponses = responses.errors;
1775
+ return endpoint;
1776
+ }
1777
+ convertPathParams(path3) {
1778
+ return path3.replace(/\{([^}]+)\}/g, ":$1");
1779
+ }
1780
+ parseParameters(parameters, spec) {
1781
+ const result = { path: [], query: [], header: [] };
1782
+ for (const param of parameters) {
1783
+ const resolved = param.$ref ? this.resolveRef(param.$ref, spec) : param;
1784
+ const apiParam = {
1785
+ name: resolved.name,
1786
+ type: resolved.schema?.type || resolved.type || "string",
1787
+ required: resolved.required,
1788
+ description: resolved.description,
1789
+ example: resolved.example || resolved.schema?.example
1790
+ };
1791
+ if (resolved.in === "path") result.path.push(apiParam);
1792
+ else if (resolved.in === "query") result.query.push(apiParam);
1793
+ else if (resolved.in === "header") result.header.push(apiParam);
1794
+ }
1795
+ return result;
1796
+ }
1797
+ parseRequestBody(requestBody, spec) {
1798
+ const content = requestBody.content?.["application/json"];
1799
+ if (!content) return void 0;
1800
+ return {
1801
+ description: requestBody.description,
1802
+ example: content.example || this.generateExample(content.schema, spec),
1803
+ schema: content.schema
1804
+ };
1805
+ }
1806
+ parseResponses(responses, spec) {
1807
+ const result = { errors: [] };
1808
+ for (const [statusCode, response] of Object.entries(responses)) {
1809
+ const status = parseInt(statusCode);
1810
+ if (isNaN(status)) continue;
1811
+ const resolved = response.$ref ? this.resolveRef(response.$ref, spec) : response;
1812
+ const content = resolved.content?.["application/json"];
1813
+ const apiResponse = {
1814
+ status,
1815
+ description: resolved.description,
1816
+ example: content?.example || this.generateExample(content?.schema, spec),
1817
+ schema: content?.schema
1818
+ };
1819
+ if (status >= 200 && status < 300) {
1820
+ result.success = apiResponse;
1821
+ } else {
1822
+ result.errors.push(apiResponse);
1823
+ }
1824
+ }
1825
+ return result;
1826
+ }
1827
+ generateExample(schema, spec) {
1828
+ if (!schema) return void 0;
1829
+ if (schema.$ref) schema = this.resolveRef(schema.$ref, spec);
1830
+ if (schema.example) return schema.example;
1831
+ if (schema.type === "object" && schema.properties) {
1832
+ const example = {};
1833
+ for (const [key, prop] of Object.entries(schema.properties)) {
1834
+ example[key] = this.generateExample(prop, spec);
1835
+ }
1836
+ return example;
1837
+ }
1838
+ if (schema.type === "array" && schema.items) {
1839
+ return [this.generateExample(schema.items, spec)];
1840
+ }
1841
+ const defaults = {
1842
+ string: "string",
1843
+ number: 0,
1844
+ integer: 0,
1845
+ boolean: false,
1846
+ object: {},
1847
+ array: []
1848
+ };
1849
+ return defaults[schema.type] || null;
1850
+ }
1851
+ resolveRef(ref, spec) {
1852
+ const path3 = ref.replace(/^#\//, "").split("/");
1853
+ let current = spec;
1854
+ for (const segment of path3) {
1855
+ current = current[segment];
1856
+ if (!current) return {};
1857
+ }
1858
+ return current;
1859
+ }
1860
+ };
1861
+
1862
+ // src/lib/parsers/postman-parser.ts
1863
+ var PostmanParser = class {
1864
+ validate(input) {
1865
+ return typeof input === "object" && input !== null && "info" in input && input.info?.schema?.includes("v2");
1866
+ }
1867
+ parse(input) {
1868
+ if (!this.validate(input)) {
1869
+ throw new Error("Invalid Postman Collection format (requires v2.0 or v2.1)");
1870
+ }
1871
+ const baseUrl = this.extractBaseUrl(input);
1872
+ const endpoints = [];
1873
+ this.parseItems(input.item || [], endpoints, baseUrl, input);
1874
+ return {
1875
+ version: input.info?.version,
1876
+ title: input.info?.name,
1877
+ description: input.info?.description,
1878
+ baseUrl,
1879
+ auth: this.extractAuth(input.auth),
1880
+ globalHeaders: this.extractGlobalHeaders(input),
1881
+ endpoints
1882
+ };
1883
+ }
1884
+ extractBaseUrl(collection) {
1885
+ const baseUrlVar = collection.variable?.find(
1886
+ (v) => v.key === "baseUrl" || v.key === "base_url" || v.key === "url"
1887
+ );
1888
+ if (baseUrlVar) return baseUrlVar.value;
1889
+ if (collection.item && collection.item.length > 0) {
1890
+ const firstRequest = this.findFirstRequest(collection.item);
1891
+ if (firstRequest?.request?.url) {
1892
+ const url = this.parseUrl(firstRequest.request.url);
1893
+ if (url.host) {
1894
+ return `${url.protocol}://${url.host.join(".")}`;
1895
+ }
1896
+ }
1897
+ }
1898
+ return "";
1899
+ }
1900
+ findFirstRequest(items) {
1901
+ for (const item of items) {
1902
+ if (item.request) return item;
1903
+ if (item.item) {
1904
+ const found = this.findFirstRequest(item.item);
1905
+ if (found) return found;
1906
+ }
1907
+ }
1908
+ return null;
1909
+ }
1910
+ extractAuth(auth) {
1911
+ if (!auth) return void 0;
1912
+ if (auth.type === "bearer") {
1913
+ return {
1914
+ type: "bearer",
1915
+ tokenPrefix: "Bearer"
1916
+ };
1917
+ }
1918
+ if (auth.type === "apikey") {
1919
+ const keyData = auth.apikey?.find((a) => a.key === "key");
1920
+ const keyName = keyData?.value || "X-API-Key";
1921
+ return {
1922
+ type: "apiKey",
1923
+ headerName: keyName
1924
+ };
1925
+ }
1926
+ if (auth.type === "basic") {
1927
+ return {
1928
+ type: "basic"
1929
+ };
1930
+ }
1931
+ return void 0;
1932
+ }
1933
+ extractGlobalHeaders(collection) {
1934
+ return [];
1935
+ }
1936
+ parseItems(items, endpoints, baseUrl, collection) {
1937
+ for (const item of items) {
1938
+ if (item.item && Array.isArray(item.item)) {
1939
+ this.parseItems(item.item, endpoints, baseUrl, collection);
1940
+ } else if (item.request) {
1941
+ const endpoint = this.parseRequest(item, baseUrl, collection);
1942
+ endpoints.push(endpoint);
1943
+ }
1944
+ }
1945
+ }
1946
+ parseRequest(item, baseUrl, collection) {
1947
+ const request = item.request;
1948
+ const url = this.parseUrl(request.url);
1949
+ const endpoint = {
1950
+ title: item.name,
1951
+ method: request.method.toUpperCase(),
1952
+ path: this.buildPath(url, baseUrl),
1953
+ description: item.request.description || item.description
1954
+ };
1955
+ const params = this.parseUrlParams(url);
1956
+ if (params.path.length > 0) endpoint.pathParams = params.path;
1957
+ if (params.query.length > 0) endpoint.queryParams = params.query;
1958
+ if (request.header && request.header.length > 0) {
1959
+ endpoint.headers = request.header.filter((h) => !h.disabled).map((h) => ({
1960
+ name: h.key,
1961
+ value: h.value || "",
1962
+ description: h.description
1963
+ }));
1964
+ }
1965
+ if (request.body) {
1966
+ endpoint.body = this.parseBody(request.body);
1967
+ }
1968
+ const responses = this.parseResponses(item.response || []);
1969
+ if (responses.success) endpoint.successResponse = responses.success;
1970
+ if (responses.errors.length > 0) endpoint.errorResponses = responses.errors;
1971
+ return endpoint;
1972
+ }
1973
+ parseUrl(url) {
1974
+ if (typeof url === "string") {
1975
+ const urlObj = new URL(url);
1976
+ return {
1977
+ protocol: urlObj.protocol.replace(":", ""),
1978
+ host: urlObj.hostname.split("."),
1979
+ path: urlObj.pathname.split("/").filter(Boolean),
1980
+ query: [],
1981
+ variable: []
1982
+ };
1983
+ }
1984
+ return {
1985
+ protocol: url.protocol || "https",
1986
+ host: url.host || [],
1987
+ path: url.path || [],
1988
+ query: url.query || [],
1989
+ variable: url.variable || []
1990
+ };
1991
+ }
1992
+ buildPath(url, baseUrl) {
1993
+ let path3 = "/";
1994
+ if (url.path && url.path.length > 0) {
1995
+ path3 += url.path.join("/");
1996
+ }
1997
+ path3 = path3.replace(/\{\{([^}]+)\}\}/g, ":$1");
1998
+ return path3;
1999
+ }
2000
+ parseUrlParams(url) {
2001
+ const result = { path: [], query: [] };
2002
+ if (url.variable && url.variable.length > 0) {
2003
+ for (const v of url.variable) {
2004
+ result.path.push({
2005
+ name: v.key,
2006
+ type: v.type || "string",
2007
+ description: v.description,
2008
+ example: v.value
2009
+ });
2010
+ }
2011
+ }
2012
+ if (url.path && url.path.length > 0) {
2013
+ for (const segment of url.path) {
2014
+ if (segment.startsWith(":")) {
2015
+ const paramName = segment.slice(1);
2016
+ if (!result.path.find((p) => p.name === paramName)) {
2017
+ result.path.push({
2018
+ name: paramName,
2019
+ type: "string"
2020
+ });
2021
+ }
2022
+ }
2023
+ }
2024
+ }
2025
+ if (url.query && url.query.length > 0) {
2026
+ for (const q of url.query) {
2027
+ if (q.disabled) continue;
2028
+ result.query.push({
2029
+ name: q.key,
2030
+ type: "string",
2031
+ description: q.description,
2032
+ example: q.value
2033
+ });
2034
+ }
2035
+ }
2036
+ return result;
2037
+ }
2038
+ parseBody(body) {
2039
+ if (!body) return void 0;
2040
+ let example;
2041
+ let description = body.description;
2042
+ if (body.mode === "raw") {
2043
+ try {
2044
+ example = JSON.parse(body.raw);
2045
+ } catch {
2046
+ example = body.raw;
2047
+ }
2048
+ } else if (body.mode === "formdata" || body.mode === "urlencoded") {
2049
+ example = {};
2050
+ for (const item of body[body.mode] || []) {
2051
+ if (!item.disabled) {
2052
+ example[item.key] = item.value;
2053
+ }
2054
+ }
2055
+ }
2056
+ return {
2057
+ description,
2058
+ example
2059
+ };
2060
+ }
2061
+ parseResponses(responses) {
2062
+ const result = { errors: [] };
2063
+ for (const response of responses) {
2064
+ let example;
2065
+ try {
2066
+ example = JSON.parse(response.body);
2067
+ } catch {
2068
+ example = response.body;
2069
+ }
2070
+ const apiResponse = {
2071
+ status: response.code || 200,
2072
+ description: response.name,
2073
+ example
2074
+ };
2075
+ if (apiResponse.status >= 200 && apiResponse.status < 300) {
2076
+ if (!result.success) result.success = apiResponse;
2077
+ } else {
2078
+ result.errors.push(apiResponse);
2079
+ }
2080
+ }
2081
+ return result;
2082
+ }
2083
+ };
2084
+
2085
+ // src/lib/parsers/index.ts
2086
+ var parsers = /* @__PURE__ */ new Map([
2087
+ ["specra", new SpecraParser()],
2088
+ ["openapi", new OpenApiParser()],
2089
+ ["postman", new PostmanParser()]
2090
+ ]);
2091
+ function detectParserType(input) {
2092
+ if (!input || typeof input !== "object") {
2093
+ throw new Error("Invalid API spec: input must be an object");
2094
+ }
2095
+ if (input.info?.schema?.includes("v2")) {
2096
+ return "postman";
2097
+ }
2098
+ if (input.openapi || input.swagger) {
2099
+ return "openapi";
2100
+ }
2101
+ if (input.endpoints && Array.isArray(input.endpoints)) {
2102
+ return "specra";
2103
+ }
2104
+ throw new Error(
2105
+ "Unable to auto-detect API spec format. Supported formats: Specra, OpenAPI 3.x, Postman Collection v2.x"
2106
+ );
2107
+ }
2108
+ function parseApiSpec(input, parserType = "auto") {
2109
+ const actualType = parserType === "auto" ? detectParserType(input) : parserType;
2110
+ const parser = parsers.get(actualType);
2111
+ if (!parser) {
2112
+ throw new Error(`Unknown parser type: ${actualType}`);
2113
+ }
2114
+ if (!parser.validate(input)) {
2115
+ throw new Error(`Input does not match ${actualType} format`);
2116
+ }
2117
+ return parser.parse(input);
2118
+ }
2119
+
2120
+ // src/components/docs/api/api-reference.tsx
2121
+ var import_lucide_react8 = require("lucide-react");
2122
+ var import_jsx_runtime25 = require("react/jsx-runtime");
2123
+ function ApiReference({ spec, parser = "auto", showPlayground = true }) {
2124
+ const [apiSpec, setApiSpec] = (0, import_react10.useState)(null);
2125
+ const [loading, setLoading] = (0, import_react10.useState)(true);
2126
+ const [error, setError] = (0, import_react10.useState)(null);
2127
+ (0, import_react10.useEffect)(() => {
2128
+ async function loadSpec() {
2129
+ try {
2130
+ const response = await fetch(spec);
2131
+ if (!response.ok) {
2132
+ throw new Error(`Failed to load API spec: ${response.statusText}`);
2133
+ }
2134
+ const data = await response.json();
2135
+ const parsedSpec = parseApiSpec(data, parser);
2136
+ setApiSpec(parsedSpec);
2137
+ } catch (err) {
2138
+ setError(err instanceof Error ? err.message : "Failed to load API spec");
2139
+ } finally {
2140
+ setLoading(false);
2141
+ }
2142
+ }
2143
+ loadSpec();
2144
+ }, [spec, parser]);
2145
+ const interpolateEnv = (text, env) => {
2146
+ if (!env) return text;
2147
+ return text.replace(/\{(\w+)\}/g, (match, key) => {
2148
+ return env[key] || match;
2149
+ });
2150
+ };
2151
+ if (loading) {
2152
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center justify-center py-12", children: [
2153
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_lucide_react8.Loader2, { className: "h-6 w-6 animate-spin text-muted-foreground" }),
2154
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "ml-2 text-muted-foreground", children: "Loading API specification..." })
2155
+ ] });
2156
+ }
2157
+ if (error) {
2158
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "rounded-lg border border-red-500/20 bg-red-500/10 p-4", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("p", { className: "text-sm text-red-600 dark:text-red-400", children: [
2159
+ "Error: ",
2160
+ error
2161
+ ] }) });
2162
+ }
2163
+ if (!apiSpec) {
2164
+ return null;
2165
+ }
2166
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "space-y-6", children: [
2167
+ (apiSpec.title || apiSpec.description) && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "mb-8", children: [
2168
+ apiSpec.title && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("h2", { className: "text-2xl font-semibold mb-2 text-foreground", children: apiSpec.title }),
2169
+ apiSpec.description && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-muted-foreground", children: apiSpec.description }),
2170
+ apiSpec.baseUrl && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "mt-4", children: [
2171
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-sm font-semibold text-muted-foreground mb-1", children: "Base URL" }),
2172
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("code", { className: "text-sm px-2 py-1 bg-muted rounded", children: apiSpec.baseUrl })
2173
+ ] })
2174
+ ] }),
2175
+ apiSpec.auth && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "rounded-lg border border-border bg-card/30 p-4 mb-6", children: [
2176
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("h3", { className: "text-lg font-semibold mb-2 text-foreground", children: "Authentication" }),
2177
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-sm text-muted-foreground mb-2", children: apiSpec.auth.description || `This API uses ${apiSpec.auth.type} authentication.` }),
2178
+ apiSpec.auth.type === "bearer" && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2179
+ CodeBlock,
2180
+ {
2181
+ code: `Authorization: ${apiSpec.auth.tokenPrefix || "Bearer"} {YOUR_TOKEN}`,
2182
+ language: "bash"
2183
+ }
2184
+ ),
2185
+ apiSpec.auth.type === "apiKey" && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2186
+ CodeBlock,
2187
+ {
2188
+ code: `${apiSpec.auth.headerName || "X-API-Key"}: {YOUR_API_KEY}`,
2189
+ language: "bash"
2190
+ }
2191
+ )
2192
+ ] }),
2193
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Accordion, { type: "single", collapsible: true, className: "space-y-4", children: apiSpec.endpoints.map((endpoint, index) => {
2194
+ const allHeaders = [
2195
+ ...apiSpec.globalHeaders || [],
2196
+ ...endpoint.headers || []
2197
+ ].map((header) => ({
2198
+ ...header,
2199
+ value: interpolateEnv(header.value, apiSpec.env)
2200
+ }));
2201
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2202
+ AccordionItem,
2203
+ {
2204
+ value: `endpoint-${index}`,
2205
+ title: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center gap-3", children: [
2206
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2207
+ "span",
2208
+ {
2209
+ className: `text-xs font-semibold px-2 py-0.5 rounded ${endpoint.method === "GET" ? "bg-blue-500/10 text-blue-600 dark:text-blue-400" : endpoint.method === "POST" ? "bg-green-500/10 text-green-600 dark:text-green-400" : endpoint.method === "PUT" ? "bg-orange-500/10 text-orange-600 dark:text-orange-400" : endpoint.method === "PATCH" ? "bg-purple-500/10 text-purple-600 dark:text-purple-400" : "bg-red-500/10 text-red-600 dark:text-red-400"}`,
2210
+ children: endpoint.method
2211
+ }
2212
+ ),
2213
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("code", { className: "text-sm font-mono", children: endpoint.path }),
2214
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "text-sm text-muted-foreground ml-auto", children: endpoint.title })
2215
+ ] }),
2216
+ children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "space-y-6 pt-4", children: [
2217
+ endpoint.description && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-sm text-muted-foreground", children: endpoint.description }),
2218
+ endpoint.pathParams && endpoint.pathParams.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ApiParams, { title: "Path Parameters", params: endpoint.pathParams }),
2219
+ endpoint.queryParams && endpoint.queryParams.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ApiParams, { title: "Query Parameters", params: endpoint.queryParams }),
2220
+ allHeaders.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { children: [
2221
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("h4", { className: "text-sm font-semibold text-foreground mb-3", children: "Headers" }),
2222
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "space-y-2", children: allHeaders.map((header, idx) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-col gap-1", children: [
2223
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center gap-2", children: [
2224
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("code", { className: "text-sm font-mono text-foreground", children: header.name }),
2225
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "text-xs text-muted-foreground", children: header.value })
2226
+ ] }),
2227
+ header.description && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-sm text-muted-foreground", children: header.description })
2228
+ ] }, idx)) })
2229
+ ] }),
2230
+ endpoint.body && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { children: [
2231
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("h4", { className: "text-sm font-semibold text-foreground mb-3", children: "Request Body" }),
2232
+ endpoint.body.description && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-sm text-muted-foreground mb-2", children: endpoint.body.description }),
2233
+ endpoint.body.example && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2234
+ CodeBlock,
2235
+ {
2236
+ code: typeof endpoint.body.example === "string" ? endpoint.body.example : JSON.stringify(endpoint.body.example, null, 2),
2237
+ language: "json"
2238
+ }
2239
+ )
2240
+ ] }),
2241
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { children: [
2242
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("h4", { className: "text-sm font-semibold text-foreground mb-3", children: "Responses" }),
2243
+ endpoint.successResponse && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2244
+ ApiResponse,
2245
+ {
2246
+ status: endpoint.successResponse.status,
2247
+ description: endpoint.successResponse.description,
2248
+ example: endpoint.successResponse.example,
2249
+ schema: endpoint.successResponse.schema
2250
+ }
2251
+ ),
2252
+ endpoint.errorResponses?.map((response, idx) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2253
+ ApiResponse,
2254
+ {
2255
+ status: response.status,
2256
+ description: response.description,
2257
+ example: response.example,
2258
+ schema: response.schema
2259
+ },
2260
+ idx
2261
+ ))
2262
+ ] }),
2263
+ endpoint.examples && endpoint.examples.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { children: [
2264
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("h4", { className: "text-sm font-semibold text-foreground mb-3", children: "Examples" }),
2265
+ endpoint.examples.map((example, idx) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "mb-3", children: [
2266
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-xs font-semibold text-muted-foreground mb-2", children: example.title }),
2267
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(CodeBlock, { code: example.code, language: example.language })
2268
+ ] }, idx))
2269
+ ] }),
2270
+ showPlayground && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2271
+ ApiPlayground,
2272
+ {
2273
+ method: endpoint.method,
2274
+ path: endpoint.path,
2275
+ baseUrl: apiSpec.baseUrl,
2276
+ headers: Object.fromEntries(allHeaders.map((h) => [h.name, h.value])),
2277
+ pathParams: endpoint.pathParams,
2278
+ defaultBody: endpoint.body?.example ? typeof endpoint.body.example === "string" ? endpoint.body.example : JSON.stringify(endpoint.body.example, null, 2) : void 0
2279
+ }
2280
+ )
2281
+ ] })
2282
+ },
2283
+ index
2284
+ );
2285
+ }) })
2286
+ ] });
2287
+ }
2288
+
2289
+ // src/components/docs/mdx-components.tsx
2290
+ var import_jsx_runtime26 = require("react/jsx-runtime");
2291
+ var mdxComponents = {
2292
+ h1: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("h1", { className: "text-3xl font-semibold tracking-tight mb-6 text-foreground", children }),
2293
+ h2: ({ children, id }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("h2", { id, className: "text-2xl font-semibold tracking-tight mt-10 mb-4 text-foreground scroll-mt-24", children }),
2294
+ h3: ({ children, id }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("h3", { id, className: "text-xl font-medium tracking-tight mt-8 mb-3 text-foreground scroll-mt-24", children }),
2295
+ p: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "text-base leading-7 text-muted-foreground mb-4", children }),
2296
+ code: ({ children, className, meta, ...props }) => {
2297
+ const isInline = !className;
2298
+ if (isInline) {
2299
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("code", { className: "px-1.5 py-0.5 rounded-md bg-muted/50 text-primary font-mono text-[13px] border border-border/50", children });
2300
+ }
2301
+ const language = className?.replace("language-", "") || "text";
2302
+ const filename = meta || void 0;
2303
+ const code = String(children).replace(/\n$/, "");
2304
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CodeBlock, { code, language, filename });
2305
+ },
2306
+ pre: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children }),
2307
+ ul: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("ul", { className: "list-disc list-outside pl-5 space-y-2 mb-4 text-muted-foreground [&_p]:mb-0 [&_p]:inline [&_ul]:ml-6 [&_ol]:ml-6", children }),
2308
+ ol: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("ol", { className: "list-decimal list-outside pl-5 space-y-2 mb-4 text-muted-foreground [&_p]:mb-0 [&_p]:inline [&_ul]:ml-6 [&_ol]:ml-6", children }),
2309
+ li: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("li", { className: "leading-7 [&>p]:mb-0 [&>p]:inline", children }),
2310
+ a: ({ children, href }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2311
+ "a",
2312
+ {
2313
+ href,
2314
+ className: "text-primary hover:underline font-medium",
2315
+ target: href?.startsWith("http") ? "_blank" : void 0,
2316
+ rel: href?.startsWith("http") ? "noopener noreferrer" : void 0,
2317
+ children
2318
+ }
2319
+ ),
2320
+ blockquote: ({ children }) => {
2321
+ const childrenArray = Array.isArray(children) ? children : [children];
2322
+ const firstChild = childrenArray[0];
2323
+ let textContent = "";
2324
+ if (firstChild && typeof firstChild === "object" && "props" in firstChild) {
2325
+ const props = firstChild.props;
2326
+ if (props.children) {
2327
+ const text = Array.isArray(props.children) ? props.children.join("") : String(props.children);
2328
+ textContent = text;
2329
+ }
2330
+ }
2331
+ const alertMatch = textContent.match(/^\[!(INFO|TIP|WARNING|SUCCESS|ERROR)\]/);
2332
+ if (alertMatch) {
2333
+ const type = alertMatch[1].toLowerCase();
2334
+ const processChildren = (node) => {
2335
+ if (typeof node === "string") {
2336
+ return node.replace(/^\[!(INFO|TIP|WARNING|SUCCESS|ERROR)\]\s*\n?/, "");
2337
+ }
2338
+ if (node && typeof node === "object" && "props" in node) {
2339
+ return {
2340
+ ...node,
2341
+ props: {
2342
+ ...node.props,
2343
+ children: Array.isArray(node.props.children) ? node.props.children.map(processChildren) : processChildren(node.props.children)
2344
+ }
2345
+ };
2346
+ }
2347
+ return node;
2348
+ };
2349
+ const cleanedChildren = Array.isArray(children) ? children.map(processChildren) : processChildren(children);
2350
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Callout, { type, children: cleanedChildren });
2351
+ }
2352
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("blockquote", { className: "border-l-4 border-primary/50 bg-muted/30 pl-4 pr-4 py-3 my-6 rounded-r-lg", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "text-muted-foreground italic [&>p]:mb-0", children }) });
2353
+ },
2354
+ table: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "overflow-x-auto mb-6 rounded-xl border border-border", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("table", { className: "min-w-full border-collapse", children }) }),
2355
+ th: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("th", { className: "border-b border-r border-border bg-muted px-4 py-2 text-left font-semibold text-foreground last:border-r-0", children }),
2356
+ td: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("td", { className: "border-b border-r border-border px-4 py-2 text-muted-foreground last:border-r-0", children }),
2357
+ // Custom components
2358
+ Callout,
2359
+ Accordion,
2360
+ AccordionItem,
2361
+ Tabs,
2362
+ Tab,
2363
+ Image,
2364
+ Video,
2365
+ Card,
2366
+ CardGrid,
2367
+ ImageCard,
2368
+ ImageCardGrid,
2369
+ Steps,
2370
+ Step,
2371
+ Icon,
2372
+ Mermaid,
2373
+ Math: Math2,
2374
+ Columns,
2375
+ Column,
2376
+ Badge,
2377
+ Tooltip,
2378
+ Frame,
2379
+ // API Documentation components
2380
+ ApiEndpoint,
2381
+ ApiParams,
2382
+ ApiResponse,
2383
+ ApiPlayground,
2384
+ ApiReference
2385
+ };
2386
+
2387
+ // src/components/docs/doc-navigation.tsx
2388
+ var import_link3 = __toESM(require("next/link"));
2389
+ var import_lucide_react9 = require("lucide-react");
2390
+ var import_jsx_runtime27 = require("react/jsx-runtime");
2391
+ function DocNavigation({ previousDoc, nextDoc, version }) {
2392
+ if (!previousDoc && !nextDoc) return null;
2393
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "mt-12 pt-8 border-t border-border grid grid-cols-2 gap-4", children: [
2394
+ previousDoc ? /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
2395
+ import_link3.default,
2396
+ {
2397
+ href: `/docs/${version}/${previousDoc.slug}`,
2398
+ className: "group flex flex-col gap-2 p-4 rounded-xl border border-border hover:border-primary/50 hover:bg-muted/50 transition-all",
2399
+ style: {
2400
+ textDecoration: "none !important"
2401
+ },
2402
+ children: [
2403
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [
2404
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_lucide_react9.ChevronLeft, { className: "h-4 w-4" }),
2405
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { children: "Previous" })
2406
+ ] }),
2407
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "text-base font-medium text-foreground group-hover:text-primary transition-colors", children: previousDoc.title })
2408
+ ]
2409
+ }
2410
+ ) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", {}),
2411
+ nextDoc ? /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
2412
+ import_link3.default,
2413
+ {
2414
+ href: `/docs/${version}/${nextDoc.slug}`,
2415
+ className: "group flex flex-col gap-2 p-4 rounded-xl border border-border hover:border-primary/50 hover:bg-muted/50 transition-all text-right",
2416
+ style: {
2417
+ textDecoration: "none !important"
2418
+ },
2419
+ children: [
2420
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex items-center justify-end gap-2 text-sm text-muted-foreground", children: [
2421
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { children: "Next" }),
2422
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_lucide_react9.ChevronRight, { className: "h-4 w-4" })
2423
+ ] }),
2424
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "text-base font-medium text-foreground group-hover:text-primary transition-colors", children: nextDoc.title })
2425
+ ]
2426
+ }
2427
+ ) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", {})
2428
+ ] });
2429
+ }
2430
+
2431
+ // src/components/docs/breadcrumb.tsx
2432
+ var import_link4 = __toESM(require("next/link"));
2433
+ var import_lucide_react10 = require("lucide-react");
2434
+ var import_jsx_runtime28 = require("react/jsx-runtime");
2435
+ function Breadcrumb({ version, slug, title }) {
2436
+ const parts = slug.split("/");
2437
+ const breadcrumbs = [
2438
+ { label: "Docs", href: `/docs/${version}` }
2439
+ ];
2440
+ let currentPath = "";
2441
+ for (let i = 0; i < parts.length - 1; i++) {
2442
+ currentPath += (currentPath ? "/" : "") + parts[i];
2443
+ breadcrumbs.push({
2444
+ label: parts[i].replace(/-/g, " ").replace(/\b\w/g, (l) => l.toUpperCase()),
2445
+ href: `/docs/${version}/${currentPath}`
2446
+ });
2447
+ }
2448
+ breadcrumbs.push({
2449
+ label: title,
2450
+ href: `/docs/${version}/${slug}`
2451
+ });
2452
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("nav", { className: "flex items-center gap-2 text-sm text-muted-foreground mb-4", "aria-label": "Breadcrumb", children: breadcrumbs.map((crumb, index) => /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex items-center gap-2", children: [
2453
+ index > 0 && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_lucide_react10.ChevronRight, { className: "h-4 w-4" }),
2454
+ index === breadcrumbs.length - 1 ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "text-foreground font-medium", children: crumb.label }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2455
+ import_link4.default,
2456
+ {
2457
+ href: crumb.href,
2458
+ className: "hover:text-foreground transition-colors",
2459
+ children: crumb.label
2460
+ }
2461
+ )
2462
+ ] }, crumb.href)) });
2463
+ }
2464
+
2465
+ // src/components/docs/doc-metadata.tsx
2466
+ var import_lucide_react11 = require("lucide-react");
2467
+ var import_jsx_runtime29 = require("react/jsx-runtime");
2468
+ function DocMetadata({ meta, config }) {
2469
+ const showReadingTime = config.features?.showReadingTime && meta.reading_time;
2470
+ const showLastUpdated = config.features?.showLastUpdated && meta.last_updated;
2471
+ const showAuthors = config.features?.showAuthors && meta.authors?.length;
2472
+ const hasMetadata = showReadingTime || showLastUpdated || showAuthors;
2473
+ if (!hasMetadata) {
2474
+ return null;
2475
+ }
2476
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex flex-wrap items-center gap-4 text-sm text-muted-foreground border-b border-border pb-4 mb-6", children: [
2477
+ showReadingTime && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex items-center gap-1.5", children: [
2478
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react11.Clock, { className: "h-4 w-4" }),
2479
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("span", { children: [
2480
+ meta.reading_time,
2481
+ " min read"
2482
+ ] })
2483
+ ] }),
2484
+ showLastUpdated && meta.last_updated && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex items-center gap-1.5", children: [
2485
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react11.Calendar, { className: "h-4 w-4" }),
2486
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("span", { children: [
2487
+ "Updated ",
2488
+ new Date(meta.last_updated).toLocaleDateString()
2489
+ ] })
2490
+ ] }),
2491
+ showAuthors && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex items-center gap-1.5", children: [
2492
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react11.User, { className: "h-4 w-4" }),
2493
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { children: meta.authors.map((author, idx) => /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("span", { children: [
2494
+ author.name || author.id,
2495
+ idx < meta.authors.length - 1 && ", "
2496
+ ] }, author.id)) })
2497
+ ] })
2498
+ ] });
2499
+ }
2500
+
2501
+ // src/components/docs/draft-badge.tsx
2502
+ var import_lucide_react12 = require("lucide-react");
2503
+ var import_jsx_runtime30 = require("react/jsx-runtime");
2504
+ function DraftBadge() {
2505
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "inline-flex items-center gap-2 px-3 py-1.5 rounded-md bg-yellow-500/10 border border-yellow-500/20 text-yellow-600 dark:text-yellow-400 text-sm font-medium mb-4", children: [
2506
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_lucide_react12.FileWarning, { className: "h-4 w-4" }),
2507
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { children: "Draft - Not visible in production" })
2508
+ ] });
2509
+ }
2510
+
2511
+ // src/components/docs/doc-tags.tsx
2512
+ var import_lucide_react13 = require("lucide-react");
2513
+ var import_jsx_runtime31 = require("react/jsx-runtime");
2514
+ function DocTags({ tags }) {
2515
+ if (!tags || tags.length === 0) {
2516
+ return null;
2517
+ }
2518
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex flex-wrap items-center gap-2 mt-6 pt-6 border-t border-border", children: [
2519
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react13.Tag, { className: "h-4 w-4 text-muted-foreground" }),
2520
+ tags.map((tag) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2521
+ "span",
2522
+ {
2523
+ className: "inline-flex items-center px-2.5 py-0.5 rounded-md text-xs font-medium bg-primary/10 text-primary border border-primary/20",
2524
+ children: tag
2525
+ },
2526
+ tag
2527
+ ))
2528
+ ] });
2529
+ }
2530
+
2531
+ // src/components/docs/search-highlight.tsx
2532
+ var import_react11 = require("react");
2533
+ var import_navigation = require("next/navigation");
2534
+ function SearchHighlight() {
2535
+ const searchParams = (0, import_navigation.useSearchParams)();
2536
+ const query = searchParams.get("q");
2537
+ (0, import_react11.useEffect)(() => {
2538
+ if (!query) {
2539
+ document.querySelectorAll("mark.search-highlight").forEach((mark) => {
2540
+ const parent = mark.parentNode;
2541
+ if (parent) {
2542
+ parent.replaceChild(document.createTextNode(mark.textContent || ""), mark);
2543
+ parent.normalize();
2544
+ }
2545
+ });
2546
+ return;
2547
+ }
2548
+ const timeout = setTimeout(() => {
2549
+ highlightSearchTerm(query);
2550
+ }, 100);
2551
+ return () => {
2552
+ clearTimeout(timeout);
2553
+ document.querySelectorAll("mark.search-highlight").forEach((mark) => {
2554
+ const parent = mark.parentNode;
2555
+ if (parent) {
2556
+ parent.replaceChild(document.createTextNode(mark.textContent || ""), mark);
2557
+ parent.normalize();
2558
+ }
2559
+ });
2560
+ };
2561
+ }, [query]);
2562
+ return null;
2563
+ }
2564
+ function highlightSearchTerm(searchTerm) {
2565
+ document.querySelectorAll("mark.search-highlight").forEach((mark) => {
2566
+ const parent = mark.parentNode;
2567
+ if (parent) {
2568
+ parent.replaceChild(document.createTextNode(mark.textContent || ""), mark);
2569
+ parent.normalize();
2570
+ }
2571
+ });
2572
+ const contentArea = document.querySelector("main") || document.body;
2573
+ const walker = document.createTreeWalker(
2574
+ contentArea,
2575
+ NodeFilter.SHOW_TEXT,
2576
+ {
2577
+ acceptNode: (node) => {
2578
+ const parent = node.parentElement;
2579
+ if (!parent) return NodeFilter.FILTER_REJECT;
2580
+ const tagName = parent.tagName.toLowerCase();
2581
+ if (["mark", "script", "style", "code", "pre"].includes(tagName)) {
2582
+ return NodeFilter.FILTER_REJECT;
2583
+ }
2584
+ if (node.textContent && node.textContent.toLowerCase().includes(searchTerm.toLowerCase())) {
2585
+ return NodeFilter.FILTER_ACCEPT;
2586
+ }
2587
+ return NodeFilter.FILTER_REJECT;
2588
+ }
2589
+ }
2590
+ );
2591
+ const nodesToHighlight = [];
2592
+ let currentNode;
2593
+ while (currentNode = walker.nextNode()) {
2594
+ if (currentNode.textContent) {
2595
+ nodesToHighlight.push({
2596
+ node: currentNode,
2597
+ text: currentNode.textContent
2598
+ });
2599
+ }
2600
+ }
2601
+ nodesToHighlight.forEach(({ node, text }) => {
2602
+ const regex = new RegExp(`(${escapeRegex(searchTerm)})`, "gi");
2603
+ const parts = text.split(regex);
2604
+ if (parts.length > 1) {
2605
+ const fragment = document.createDocumentFragment();
2606
+ parts.forEach((part) => {
2607
+ if (part.toLowerCase() === searchTerm.toLowerCase()) {
2608
+ const mark = document.createElement("mark");
2609
+ mark.className = "search-highlight bg-yellow-200 dark:bg-yellow-900/50 text-foreground px-1 rounded";
2610
+ mark.textContent = part;
2611
+ fragment.appendChild(mark);
2612
+ } else if (part) {
2613
+ fragment.appendChild(document.createTextNode(part));
2614
+ }
2615
+ });
2616
+ node.parentNode?.replaceChild(fragment, node);
2617
+ }
2618
+ });
2619
+ const firstHighlight = document.querySelector("mark.search-highlight");
2620
+ if (firstHighlight) {
2621
+ setTimeout(() => {
2622
+ firstHighlight.scrollIntoView({ behavior: "smooth", block: "center" });
2623
+ }, 200);
2624
+ }
2625
+ }
2626
+ function escapeRegex(string) {
2627
+ return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2628
+ }
2629
+
2630
+ // src/lib/config.types.ts
2631
+ var defaultConfig = {
2632
+ site: {
2633
+ title: "Documentation",
2634
+ description: "Project documentation",
2635
+ baseUrl: "/",
2636
+ language: "en"
2637
+ },
2638
+ theme: {
2639
+ defaultMode: "system",
2640
+ respectPrefersColorScheme: true
2641
+ },
2642
+ navigation: {
2643
+ showSidebar: true,
2644
+ collapsibleSidebar: true,
2645
+ showBreadcrumbs: true,
2646
+ showTableOfContents: true,
2647
+ tocPosition: "right",
2648
+ tocMaxDepth: 3
2649
+ },
2650
+ search: {
2651
+ enabled: true,
2652
+ provider: "local",
2653
+ placeholder: "Search documentation..."
2654
+ },
2655
+ features: {
2656
+ showLastUpdated: true,
2657
+ showReadingTime: true,
2658
+ showAuthors: false,
2659
+ showTags: true,
2660
+ versioning: true,
2661
+ i18n: false
2662
+ }
2663
+ };
2664
+
2665
+ // src/lib/config.server.ts
2666
+ function deepMerge(target, source) {
2667
+ const result = { ...target };
2668
+ for (const key in source) {
2669
+ const sourceValue = source[key];
2670
+ const targetValue = result[key];
2671
+ if (sourceValue && typeof sourceValue === "object" && !Array.isArray(sourceValue)) {
2672
+ result[key] = deepMerge(
2673
+ targetValue && typeof targetValue === "object" ? targetValue : {},
2674
+ sourceValue
2675
+ );
2676
+ } else if (sourceValue !== void 0) {
2677
+ result[key] = sourceValue;
2678
+ }
2679
+ }
2680
+ return result;
2681
+ }
2682
+ function loadConfig(userConfig) {
2683
+ try {
2684
+ const config = deepMerge(defaultConfig, userConfig);
2685
+ return config;
2686
+ } catch (error) {
2687
+ console.error(`\u274C Error loading configuration:`, error);
2688
+ console.warn("Using default configuration.");
2689
+ return defaultConfig;
2690
+ }
2691
+ }
2692
+ function replaceEnvVariables(text, config) {
2693
+ const cfg = config || loadConfig({});
2694
+ const envVars = cfg.env || {};
2695
+ let result = text;
2696
+ result = result.replace(/\$\{([^}]+)\}/g, (match, varName) => {
2697
+ return envVars[varName] || match;
2698
+ });
2699
+ result = result.replace(/\{\{([^}]+)\}\}/g, (match, varName) => {
2700
+ return envVars[varName] || match;
2701
+ });
2702
+ return result;
2703
+ }
2704
+ function processContentWithEnv(content, config) {
2705
+ return replaceEnvVariables(content, config);
2706
+ }
2707
+ var configInstance = null;
2708
+ function getConfig() {
2709
+ if (!configInstance) {
2710
+ throw new Error("Specra config has not been initialized");
2711
+ }
2712
+ return configInstance;
2713
+ }
2714
+
2715
+ // src/components/docs/doc-layout.tsx
2716
+ var import_jsx_runtime32 = require("react/jsx-runtime");
2717
+ async function DocLayout({ content, meta, previousDoc, nextDoc, version, slug, config }) {
2718
+ const isDevelopment3 = process.env.NODE_ENV === "development";
2719
+ const processedContent = processContentWithEnv(content, config);
2720
+ const editUrl = config.features?.editUrl && typeof config.features.editUrl === "string" ? `${config.features.editUrl}/${version}/${slug}.mdx` : null;
2721
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("article", { className: "flex-1 min-w-0", children: [
2722
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(SearchHighlight, {}),
2723
+ config.navigation?.showBreadcrumbs && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Breadcrumb, { version, slug, title: meta.title }),
2724
+ isDevelopment3 && meta.draft && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DraftBadge, {}),
2725
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "mb-8", children: [
2726
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("h1", { className: "text-4xl font-bold tracking-tight mb-3 text-foreground", children: meta.title }),
2727
+ meta.description && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("p", { className: "text-lg text-muted-foreground leading-relaxed", children: meta.description })
2728
+ ] }),
2729
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DocMetadata, { meta, config }),
2730
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "prose prose-slate dark:prose-invert max-w-none prose-headings:scroll-mt-24 prose-headings:font-semibold prose-h1:text-4xl prose-h2:text-3xl prose-h2:mt-12 prose-h2:mb-4 prose-h3:text-2xl prose-h3:mt-8 prose-h3:mb-3 prose-p:text-base prose-p:leading-7 prose-p:text-muted-foreground prose-p:mb-4 prose-a:font-normal prose-a:transition-all prose-code:text-primary prose-code:bg-muted/50 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded-md prose-code:text-[13px] prose-code:font-mono prose-code:border prose-code:border-border/50 prose-code:before:content-none prose-code:after:content-none prose-pre:bg-transparent prose-pre:p-0 prose-ul:list-disc prose-ul:list-inside prose-ul:space-y-2 prose-ul:mb-4 prose-ol:list-decimal prose-ol:list-inside prose-ol:space-y-2 prose-ol:mb-4 prose-li:leading-7 prose-li:text-muted-foreground prose-strong:text-foreground prose-strong:font-semibold", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
2731
+ import_rsc.MDXRemote,
2732
+ {
2733
+ source: processedContent,
2734
+ options: {
2735
+ parseFrontmatter: false,
2736
+ mdxOptions: {
2737
+ remarkPlugins: [import_remark_gfm.default, remarkCodeMeta],
2738
+ rehypePlugins: [import_rehype_slug.default],
2739
+ development: false
2740
+ }
2741
+ },
2742
+ components: mdxComponents
2743
+ }
2744
+ ) }),
2745
+ config.features?.showTags && meta.tags && meta.tags.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DocTags, { tags: meta.tags }),
2746
+ (editUrl || config.social?.github) && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "mt-12 pt-6 border-t border-border flex items-center justify-between", children: [
2747
+ editUrl ? /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
2748
+ "a",
2749
+ {
2750
+ href: editUrl,
2751
+ target: "_blank",
2752
+ rel: "noopener noreferrer",
2753
+ className: "flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",
2754
+ children: [
2755
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_lucide_react14.FileEdit, { className: "h-4 w-4" }),
2756
+ "Edit this page"
2757
+ ]
2758
+ }
2759
+ ) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", {}),
2760
+ config.social?.github && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
2761
+ "a",
2762
+ {
2763
+ href: `${config.social.github}/issues/new`,
2764
+ target: "_blank",
2765
+ rel: "noopener noreferrer",
2766
+ className: "flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",
2767
+ children: [
2768
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_lucide_react14.ExternalLink, { className: "h-4 w-4" }),
2769
+ "Report an issue"
2770
+ ]
2771
+ }
2772
+ )
2773
+ ] }),
2774
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DocNavigation, { previousDoc, nextDoc, version })
2775
+ ] });
2776
+ }
2777
+
2778
+ // src/components/docs/table-of-contents.tsx
2779
+ var import_react12 = require("react");
2780
+ var import_jsx_runtime33 = require("react/jsx-runtime");
2781
+ function TableOfContents({ items, config }) {
2782
+ const [activeId, setActiveId] = (0, import_react12.useState)("");
2783
+ if (!config.navigation?.showTableOfContents) {
2784
+ return null;
2785
+ }
2786
+ const maxDepth = config.navigation?.tocMaxDepth || 3;
2787
+ const filteredItems = items.filter((item) => item.level <= maxDepth);
2788
+ const hasTabGroups = config.navigation?.tabGroups && config.navigation.tabGroups.length > 0;
2789
+ (0, import_react12.useEffect)(() => {
2790
+ const observer = new IntersectionObserver(
2791
+ (entries) => {
2792
+ entries.forEach((entry) => {
2793
+ if (entry.isIntersecting) {
2794
+ setActiveId(entry.target.id);
2795
+ }
2796
+ });
2797
+ },
2798
+ { rootMargin: "-80px 0px -80% 0px" }
2799
+ );
2800
+ filteredItems.forEach((item) => {
2801
+ const element = document.getElementById(item.id);
2802
+ if (element) {
2803
+ observer.observe(element);
2804
+ }
2805
+ });
2806
+ return () => observer.disconnect();
2807
+ }, [filteredItems]);
2808
+ const handleClick = (e, id) => {
2809
+ e.preventDefault();
2810
+ const element = document.getElementById(id);
2811
+ if (element) {
2812
+ const offset = 100;
2813
+ const elementPosition = element.getBoundingClientRect().top;
2814
+ const offsetPosition = elementPosition + window.scrollY - offset;
2815
+ window.scrollTo({
2816
+ top: offsetPosition,
2817
+ behavior: "smooth"
2818
+ });
2819
+ window.history.replaceState(null, "", `#${id}`);
2820
+ setActiveId(id);
2821
+ }
2822
+ };
2823
+ const stickyTop = hasTabGroups ? "top-[7.5rem]" : "top-24";
2824
+ const maxHeight = hasTabGroups ? "max-h-[calc(100vh-10rem)]" : "max-h-[calc(100vh-7rem)]";
2825
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("aside", { className: `w-64 hidden xl:block shrink-0 sticky ${stickyTop} self-start`, children: filteredItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: `${maxHeight} overflow-y-auto bg-muted/30 dark:bg-muted/10 rounded-2xl p-4 border border-border/50`, children: [
2826
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("h3", { className: "text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-4 px-2", children: "On this page" }),
2827
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("nav", { className: "space-y-1", children: filteredItems.map((item) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2828
+ "a",
2829
+ {
2830
+ href: `#${item.id}`,
2831
+ onClick: (e) => handleClick(e, item.id),
2832
+ className: `block text-sm transition-all cursor-pointer rounded-xl px-3 py-2 ${item.level === 3 ? "ml-3" : ""} ${activeId === item.id ? "text-primary font-medium" : "text-foreground hover:bg-accent/50"}`,
2833
+ children: item.title
2834
+ },
2835
+ item.id
2836
+ )) })
2837
+ ] }) });
2838
+ }
2839
+
2840
+ // src/components/docs/header.tsx
2841
+ var import_link5 = __toESM(require("next/link"));
2842
+ var import_lucide_react19 = require("lucide-react");
2843
+
2844
+ // src/components/docs/version-switcher.tsx
2845
+ var import_react13 = require("react");
2846
+ var import_lucide_react15 = require("lucide-react");
2847
+ var import_navigation2 = require("next/navigation");
2848
+ var import_jsx_runtime34 = require("react/jsx-runtime");
2849
+ function VersionSwitcher({ currentVersion, versions }) {
2850
+ const [open, setOpen] = (0, import_react13.useState)(false);
2851
+ const router = (0, import_navigation2.useRouter)();
2852
+ const handleVersionChange = (version) => {
2853
+ router.push(`/docs/${version}`);
2854
+ setOpen(false);
2855
+ };
2856
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "relative", children: [
2857
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
2858
+ "button",
2859
+ {
2860
+ onClick: () => setOpen(!open),
2861
+ className: "flex items-center gap-2 px-3 py-2 text-sm text-foreground bg-muted rounded-md hover:bg-muted/80 transition-colors",
2862
+ children: [
2863
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: "font-medium", children: currentVersion }),
2864
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_lucide_react15.ChevronDown, { className: "h-4 w-4" })
2865
+ ]
2866
+ }
2867
+ ),
2868
+ open && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
2869
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "fixed inset-0 z-40", onClick: () => setOpen(false) }),
2870
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "absolute right-0 mt-2 w-48 bg-background border border-border rounded-md shadow-lg z-50", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "p-2", children: versions.map((version) => /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
2871
+ "button",
2872
+ {
2873
+ onClick: () => handleVersionChange(version),
2874
+ className: "flex items-center justify-between w-full px-3 py-2 text-sm text-foreground hover:bg-muted rounded-md transition-colors",
2875
+ children: [
2876
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { children: version }),
2877
+ version === currentVersion && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_lucide_react15.Check, { className: "h-4 w-4 text-primary" })
2878
+ ]
2879
+ },
2880
+ version
2881
+ )) }) })
2882
+ ] })
2883
+ ] });
2884
+ }
2885
+
2886
+ // src/components/docs/theme-toggle.tsx
2887
+ var import_lucide_react16 = require("lucide-react");
2888
+ var import_react14 = require("react");
2889
+ var import_jsx_runtime35 = require("react/jsx-runtime");
2890
+ function ThemeToggle() {
2891
+ const [theme, setTheme] = (0, import_react14.useState)("dark");
2892
+ (0, import_react14.useEffect)(() => {
2893
+ const savedTheme = localStorage.getItem("theme");
2894
+ const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
2895
+ const initialTheme = savedTheme || (prefersDark ? "dark" : "light");
2896
+ setTheme(initialTheme);
2897
+ document.documentElement.classList.toggle("dark", initialTheme === "dark");
2898
+ }, []);
2899
+ const toggleTheme = () => {
2900
+ const newTheme = theme === "dark" ? "light" : "dark";
2901
+ setTheme(newTheme);
2902
+ localStorage.setItem("theme", newTheme);
2903
+ document.documentElement.classList.toggle("dark", newTheme === "dark");
2904
+ };
2905
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
2906
+ "button",
2907
+ {
2908
+ onClick: toggleTheme,
2909
+ className: "flex items-center justify-center w-9 h-9 rounded-md border border-border bg-background hover:bg-accent transition-colors",
2910
+ "aria-label": "Toggle theme",
2911
+ children: theme === "dark" ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react16.Sun, { className: "h-4 w-4 text-foreground" }) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react16.Moon, { className: "h-4 w-4 text-foreground" })
2912
+ }
2913
+ );
2914
+ }
2915
+
2916
+ // src/components/docs/search-modal.tsx
2917
+ var import_react15 = require("react");
2918
+ var import_lucide_react18 = require("lucide-react");
2919
+ var import_navigation3 = require("next/navigation");
2920
+
2921
+ // src/components/ui/dialog.tsx
2922
+ var DialogPrimitive = __toESM(require("@radix-ui/react-dialog"));
2923
+ var import_lucide_react17 = require("lucide-react");
2924
+ var import_jsx_runtime36 = require("react/jsx-runtime");
2925
+ function Dialog({
2926
+ ...props
2927
+ }) {
2928
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
2929
+ }
2930
+ function DialogPortal({
2931
+ ...props
2932
+ }) {
2933
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(DialogPrimitive.Portal, { "data-slot": "dialog-portal", ...props });
2934
+ }
2935
+ function DialogOverlay({
2936
+ className,
2937
+ ...props
2938
+ }) {
2939
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
2940
+ DialogPrimitive.Overlay,
2941
+ {
2942
+ "data-slot": "dialog-overlay",
2943
+ className: cn(
2944
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50 dark:bg-black/70 backdrop-blur-md",
2945
+ className
2946
+ ),
2947
+ ...props
2948
+ }
2949
+ );
2950
+ }
2951
+ function DialogContent({
2952
+ className,
2953
+ children,
2954
+ showCloseButton = true,
2955
+ ...props
2956
+ }) {
2957
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(DialogPortal, { "data-slot": "dialog-portal", children: [
2958
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(DialogOverlay, {}),
2959
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
2960
+ DialogPrimitive.Content,
2961
+ {
2962
+ "data-slot": "dialog-content",
2963
+ className: cn(
2964
+ "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 outline-none sm:max-w-lg",
2965
+ className
2966
+ ),
2967
+ ...props,
2968
+ children: [
2969
+ children,
2970
+ showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
2971
+ DialogPrimitive.Close,
2972
+ {
2973
+ "data-slot": "dialog-close",
2974
+ className: "ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
2975
+ children: [
2976
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_lucide_react17.XIcon, {}),
2977
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "sr-only", children: "Close" })
2978
+ ]
2979
+ }
2980
+ )
2981
+ ]
2982
+ }
2983
+ )
2984
+ ] });
2985
+ }
2986
+
2987
+ // src/components/docs/search-modal.tsx
2988
+ var import_jsx_runtime37 = require("react/jsx-runtime");
2989
+ function SearchModal({ isOpen, onClose, config }) {
2990
+ const [query, setQuery] = (0, import_react15.useState)("");
2991
+ const [results, setResults] = (0, import_react15.useState)([]);
2992
+ const [isLoading, setIsLoading] = (0, import_react15.useState)(false);
2993
+ const [selectedIndex, setSelectedIndex] = (0, import_react15.useState)(0);
2994
+ const router = (0, import_navigation3.useRouter)();
2995
+ const searchConfig = config.search;
2996
+ const performSearch = (0, import_react15.useCallback)(async (searchQuery) => {
2997
+ if (!searchQuery.trim() || !searchConfig?.enabled) {
2998
+ setResults([]);
2999
+ return;
3000
+ }
3001
+ setIsLoading(true);
3002
+ try {
3003
+ const response = await fetch("/api/search", {
3004
+ method: "POST",
3005
+ headers: { "Content-Type": "application/json" },
3006
+ body: JSON.stringify({
3007
+ query: searchQuery,
3008
+ // filter: 'version = "v1.0.0"',
3009
+ distinct: "version",
3010
+ limit: 2
3011
+ })
3012
+ });
3013
+ if (response.ok) {
3014
+ const data = await response.json();
3015
+ console.log("Search response:", data);
3016
+ setResults(data.hits || []);
3017
+ } else {
3018
+ console.error("Search failed:", response.status, await response.text());
3019
+ }
3020
+ } catch (error) {
3021
+ console.error("Search error:", error);
3022
+ setResults([]);
3023
+ } finally {
3024
+ setIsLoading(false);
3025
+ }
3026
+ }, [searchConfig]);
3027
+ (0, import_react15.useEffect)(() => {
3028
+ const timer = setTimeout(() => {
3029
+ performSearch(query);
3030
+ }, 300);
3031
+ return () => clearTimeout(timer);
3032
+ }, [query, performSearch]);
3033
+ (0, import_react15.useEffect)(() => {
3034
+ const handleKeyDown = (e) => {
3035
+ if (!isOpen) return;
3036
+ switch (e.key) {
3037
+ case "Escape":
3038
+ onClose();
3039
+ break;
3040
+ case "ArrowDown":
3041
+ e.preventDefault();
3042
+ setSelectedIndex((prev) => Math.min(prev + 1, results.length - 1));
3043
+ break;
3044
+ case "ArrowUp":
3045
+ e.preventDefault();
3046
+ setSelectedIndex((prev) => Math.max(prev - 1, 0));
3047
+ break;
3048
+ case "Enter":
3049
+ e.preventDefault();
3050
+ if (results[selectedIndex]) {
3051
+ handleResultClick(results[selectedIndex]);
3052
+ }
3053
+ break;
3054
+ }
3055
+ };
3056
+ window.addEventListener("keydown", handleKeyDown);
3057
+ return () => window.removeEventListener("keydown", handleKeyDown);
3058
+ }, [isOpen, results, selectedIndex, onClose]);
3059
+ (0, import_react15.useEffect)(() => {
3060
+ if (isOpen) {
3061
+ setQuery("");
3062
+ setResults([]);
3063
+ setSelectedIndex(0);
3064
+ }
3065
+ }, [isOpen]);
3066
+ const handleResultClick = (result) => {
3067
+ const url = `/docs/${result.version}/${result.slug}?q=${encodeURIComponent(query)}`;
3068
+ router.push(url);
3069
+ onClose();
3070
+ };
3071
+ const highlightText = (text, query2) => {
3072
+ if (!query2.trim()) return text;
3073
+ const parts = text.split(new RegExp(`(${query2})`, "gi"));
3074
+ return parts.map(
3075
+ (part, i) => part.toLowerCase() === query2.toLowerCase() ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("mark", { className: "bg-yellow-200 dark:bg-yellow-900/50 text-foreground", children: part }, i) : part
3076
+ );
3077
+ };
3078
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Dialog, { open: isOpen, onOpenChange: onClose, modal: true, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
3079
+ DialogContent,
3080
+ {
3081
+ className: "max-w-2xl p-0 gap-0 top-[10vh] translate-y-0",
3082
+ showCloseButton: false,
3083
+ onOpenAutoFocus: (e) => e.preventDefault(),
3084
+ children: [
3085
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex items-center gap-3 px-4 py-3 border-b border-border", children: [
3086
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_lucide_react18.Search, { className: "h-5 w-5 text-muted-foreground shrink-0" }),
3087
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3088
+ "input",
3089
+ {
3090
+ type: "text",
3091
+ value: query,
3092
+ onChange: (e) => setQuery(e.target.value),
3093
+ placeholder: searchConfig?.placeholder || "Search documentation...",
3094
+ className: "flex-1 bg-transparent border-none outline-none text-foreground placeholder:text-muted-foreground",
3095
+ autoFocus: true
3096
+ }
3097
+ ),
3098
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_lucide_react18.Loader2, { className: "h-5 w-5 text-muted-foreground animate-spin" })
3099
+ ] }),
3100
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "max-h-[60vh] overflow-y-auto", children: [
3101
+ query.trim() && results.length === 0 && !isLoading && /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "px-4 py-8 text-center text-muted-foreground", children: [
3102
+ 'No results found for "',
3103
+ query,
3104
+ '"'
3105
+ ] }),
3106
+ results.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "py-2", children: results.map((result, index) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3107
+ "button",
3108
+ {
3109
+ onClick: () => handleResultClick(result),
3110
+ className: `w-full px-4 py-3 text-left hover:bg-muted/50 transition-colors border-l-2 ${index === selectedIndex ? "bg-muted/50 border-primary" : "border-transparent"}`,
3111
+ onMouseEnter: () => setSelectedIndex(index),
3112
+ children: /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex items-start gap-3", children: [
3113
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_lucide_react18.FileText, { className: "h-5 w-5 text-muted-foreground shrink-0 mt-0.5" }),
3114
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex-1 min-w-0", children: [
3115
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "font-medium text-foreground mb-1", children: highlightText(result.title, query) }),
3116
+ result.content && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "text-sm text-muted-foreground line-clamp-2", children: highlightText(result.content, query) }),
3117
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex items-center gap-2 mt-1 text-xs text-muted-foreground", children: [
3118
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { children: result.version }),
3119
+ result.category && /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { children: [
3120
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { children: "\u2022" }),
3121
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { children: result.category })
3122
+ ] })
3123
+ ] })
3124
+ ] })
3125
+ ] })
3126
+ },
3127
+ result.id
3128
+ )) }),
3129
+ !query.trim() && /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "px-4 py-8 text-center text-muted-foreground text-sm", children: [
3130
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("p", { children: "Start typing to search documentation..." }),
3131
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "mt-4 flex items-center justify-center gap-4 text-xs", children: [
3132
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("kbd", { className: "px-2 py-1 bg-muted rounded border border-border", children: "\u2191\u2193" }),
3133
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { children: "Navigate" }),
3134
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("kbd", { className: "px-2 py-1 bg-muted rounded border border-border", children: "Enter" }),
3135
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { children: "Select" }),
3136
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("kbd", { className: "px-2 py-1 bg-muted rounded border border-border", children: "Esc" }),
3137
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { children: "Close" })
3138
+ ] })
3139
+ ] })
3140
+ ] })
3141
+ ]
3142
+ }
3143
+ ) });
3144
+ }
3145
+
3146
+ // src/components/docs/header.tsx
3147
+ var import_react16 = require("react");
3148
+ var import_jsx_runtime38 = require("react/jsx-runtime");
3149
+ function Header({ currentVersion, versions, onMenuClick, config }) {
3150
+ const [searchOpen, setSearchOpen] = (0, import_react16.useState)(false);
3151
+ (0, import_react16.useEffect)(() => {
3152
+ const handleKeyDown = (e) => {
3153
+ if ((e.metaKey || e.ctrlKey) && e.key === "k") {
3154
+ e.preventDefault();
3155
+ setSearchOpen(true);
3156
+ }
3157
+ };
3158
+ window.addEventListener("keydown", handleKeyDown);
3159
+ return () => window.removeEventListener("keydown", handleKeyDown);
3160
+ }, []);
3161
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("header", { className: "sticky top-0 z-50 w-full border-b border-border bg-background/95 backdrop-blur supports-backdrop-filter:bg-background/60", children: [
3162
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "container flex h-16 items-center justify-between px-6 mx-auto", children: [
3163
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex items-center gap-2", children: [
3164
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
3165
+ "button",
3166
+ {
3167
+ onClick: onMenuClick,
3168
+ className: "lg:hidden hover:bg-muted p-2 rounded-md transition-colors",
3169
+ "aria-label": "Toggle menu",
3170
+ children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_lucide_react19.Menu, { className: "h-5 w-5" })
3171
+ }
3172
+ ),
3173
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_link5.default, { href: "/", className: "flex items-center gap-2", children: [
3174
+ config.site.logo ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("img", { src: getAssetPath(config.site.logo), alt: config.site.title, className: "h-8 w-auto" }) : /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "h-8 w-8 rounded-xl bg-primary flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "text-primary-foreground font-bold text-lg", children: config.site.title.charAt(0).toUpperCase() }) }),
3175
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "font-semibold text-lg text-foreground", children: "Specra" })
3176
+ ] })
3177
+ ] }),
3178
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex items-center gap-2", children: [
3179
+ config.search?.enabled && /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
3180
+ "button",
3181
+ {
3182
+ onClick: () => setSearchOpen(true),
3183
+ className: "flex items-center gap-2 px-3 py-2 text-sm text-muted-foreground hover:text-foreground bg-muted rounded-md transition-colors",
3184
+ children: [
3185
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_lucide_react19.Search, { className: "h-4 w-4" }),
3186
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "hidden sm:inline", children: config.search.placeholder || "Search" }),
3187
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("kbd", { className: "hidden sm:inline-flex h-5 select-none items-center gap-1 rounded border border-border bg-background px-1.5 font-mono text-xs font-medium", children: "\u2318K" })
3188
+ ]
3189
+ }
3190
+ ),
3191
+ config.features?.versioning && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(VersionSwitcher, { currentVersion, versions }),
3192
+ config.social?.github && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
3193
+ "a",
3194
+ {
3195
+ href: config.social.github,
3196
+ target: "_blank",
3197
+ rel: "noopener noreferrer",
3198
+ className: "hidden md:flex items-center justify-center h-9 w-9 rounded-md hover:bg-muted transition-colors",
3199
+ "aria-label": "GitHub",
3200
+ children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_lucide_react19.Github, { className: "h-4 w-4" })
3201
+ }
3202
+ ),
3203
+ config.social?.twitter && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
3204
+ "a",
3205
+ {
3206
+ href: config.social.twitter,
3207
+ target: "_blank",
3208
+ rel: "noopener noreferrer",
3209
+ className: "hidden md:flex items-center justify-center h-9 w-9 rounded-md hover:bg-muted transition-colors",
3210
+ "aria-label": "Twitter",
3211
+ children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_lucide_react19.Twitter, { className: "h-4 w-4" })
3212
+ }
3213
+ ),
3214
+ config.social?.discord && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
3215
+ "a",
3216
+ {
3217
+ href: config.social.discord,
3218
+ target: "_blank",
3219
+ rel: "noopener noreferrer",
3220
+ className: "hidden md:flex items-center justify-center h-9 w-9 rounded-md hover:bg-muted transition-colors",
3221
+ "aria-label": "Discord",
3222
+ children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_lucide_react19.MessageCircle, { className: "h-4 w-4" })
3223
+ }
3224
+ ),
3225
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ThemeToggle, {})
3226
+ ] })
3227
+ ] }),
3228
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(SearchModal, { isOpen: searchOpen, onClose: () => setSearchOpen(false), config })
3229
+ ] });
3230
+ }
3231
+
3232
+ // src/components/docs/doc-layout-wrapper.tsx
3233
+ var import_react21 = require("react");
3234
+
3235
+ // src/components/docs/mobile-doc-layout.tsx
3236
+ var import_react19 = require("react");
3237
+
3238
+ // src/components/docs/footer.tsx
3239
+ var import_link6 = __toESM(require("next/link"));
3240
+ var import_jsx_runtime39 = require("react/jsx-runtime");
3241
+ function Footer({ config }) {
3242
+ if (!config.footer) {
3243
+ return null;
3244
+ }
3245
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("footer", { className: "bg-muted/30 dark:bg-muted/10 rounded-2xl mt-24", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "px-6 py-12", children: [
3246
+ config.footer.links && config.footer.links.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "grid grid-cols-2 md:grid-cols-4 gap-8 mb-8", children: config.footer.links.map((column, idx) => /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { children: [
3247
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("h3", { className: "font-semibold text-foreground mb-4", children: column.title }),
3248
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("ul", { className: "space-y-2", children: column.items.map((item, itemIdx) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3249
+ import_link6.default,
3250
+ {
3251
+ href: item.href,
3252
+ className: "text-sm text-muted-foreground hover:text-foreground transition-colors",
3253
+ children: item.label
3254
+ }
3255
+ ) }, itemIdx)) })
3256
+ ] }, idx)) }),
3257
+ config.footer.copyright && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "pt-8", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "text-sm text-muted-foreground text-center", children: config.footer.copyright }) })
3258
+ ] }) });
3259
+ }
3260
+
3261
+ // src/components/docs/site-banner.tsx
3262
+ var import_lucide_react20 = require("lucide-react");
3263
+ var import_react17 = require("react");
3264
+ var import_jsx_runtime40 = require("react/jsx-runtime");
3265
+ function SiteBanner({ config }) {
3266
+ const [dismissed, setDismissed] = (0, import_react17.useState)(false);
3267
+ const [mounted, setMounted] = (0, import_react17.useState)(false);
3268
+ const banner = config.banner;
3269
+ const storageKey = "site-banner-dismissed";
3270
+ (0, import_react17.useEffect)(() => {
3271
+ setMounted(true);
3272
+ const isDismissed = localStorage.getItem(storageKey) === "true";
3273
+ setDismissed(isDismissed);
3274
+ }, []);
3275
+ const handleDismiss = () => {
3276
+ setDismissed(true);
3277
+ localStorage.setItem(storageKey, "true");
3278
+ };
3279
+ if (!mounted || !banner || !banner.enabled || dismissed) {
3280
+ return null;
3281
+ }
3282
+ const typeConfig = {
3283
+ info: {
3284
+ icon: import_lucide_react20.Info,
3285
+ bg: "bg-blue-500/10 dark:bg-blue-400/5",
3286
+ border: "border-blue-500/30 dark:border-blue-500/20",
3287
+ iconColor: "text-blue-600 dark:text-blue-400",
3288
+ textColor: "text-blue-900 dark:text-blue-300"
3289
+ },
3290
+ success: {
3291
+ icon: import_lucide_react20.CheckCircle,
3292
+ bg: "bg-green-500/10 dark:bg-green-400/5",
3293
+ border: "border-green-500/30 dark:border-green-500/20",
3294
+ iconColor: "text-green-600 dark:text-green-400",
3295
+ textColor: "text-green-900 dark:text-green-300"
3296
+ },
3297
+ warning: {
3298
+ icon: import_lucide_react20.AlertCircle,
3299
+ bg: "bg-yellow-500/10 dark:bg-yellow-400/5",
3300
+ border: "border-yellow-500/30 dark:border-yellow-500/20",
3301
+ iconColor: "text-yellow-600 dark:text-yellow-400",
3302
+ textColor: "text-yellow-900 dark:text-yellow-300"
3303
+ },
3304
+ error: {
3305
+ icon: import_lucide_react20.XCircle,
3306
+ bg: "bg-red-500/10 dark:bg-red-400/5",
3307
+ border: "border-red-500/30 dark:border-red-500/20",
3308
+ iconColor: "text-red-600 dark:text-red-400",
3309
+ textColor: "text-red-900 dark:text-red-300"
3310
+ }
3311
+ };
3312
+ const type = banner.type || "info";
3313
+ const { icon: IconComponent, bg, border, iconColor, textColor } = typeConfig[type];
3314
+ return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: `w-full border-b ${border} ${bg}`, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "container mx-auto px-6 py-3", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "flex items-center gap-3", children: [
3315
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(IconComponent, { className: `h-5 w-5 shrink-0 ${iconColor}` }),
3316
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "flex-1 min-w-0", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { className: `text-sm font-medium ${textColor}`, children: banner.message }) }),
3317
+ banner.dismissible && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
3318
+ "button",
3319
+ {
3320
+ onClick: handleDismiss,
3321
+ className: `shrink-0 p-1 rounded-md hover:bg-black/5 dark:hover:bg-white/5 transition-colors ${iconColor}`,
3322
+ "aria-label": "Dismiss banner",
3323
+ children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_lucide_react20.X, { className: "h-4 w-4" })
3324
+ }
3325
+ )
3326
+ ] }) }) });
3327
+ }
3328
+
3329
+ // src/components/docs/tab-groups.tsx
3330
+ var import_jsx_runtime41 = require("react/jsx-runtime");
3331
+ function TabGroups({ tabGroups, activeTabId, onTabChange }) {
3332
+ const activeTab = activeTabId || tabGroups[0]?.id || "";
3333
+ const handleTabChange = (tabId) => {
3334
+ onTabChange?.(tabId);
3335
+ };
3336
+ if (!tabGroups || tabGroups.length === 0) {
3337
+ return null;
3338
+ }
3339
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "sticky top-16 z-30 border-b border-border bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "container mx-auto px-6", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("nav", { className: "flex gap-1 overflow-x-auto no-scrollbar", "aria-label": "Documentation tabs", children: tabGroups.map((tab) => {
3340
+ const isActive = tab.id === activeTab;
3341
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
3342
+ "button",
3343
+ {
3344
+ onClick: () => handleTabChange(tab.id),
3345
+ className: `flex items-center gap-2 px-4 py-3 text-sm font-medium whitespace-nowrap transition-all border-b-2 ${isActive ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
3346
+ "aria-current": isActive ? "page" : void 0,
3347
+ children: [
3348
+ tab.icon && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Icon, { icon: tab.icon, size: 16, className: "shrink-0" }),
3349
+ tab.label
3350
+ ]
3351
+ },
3352
+ tab.id
3353
+ );
3354
+ }) }) }) });
3355
+ }
3356
+
3357
+ // src/components/docs/sidebar.tsx
3358
+ var import_link7 = __toESM(require("next/link"));
3359
+ var import_navigation4 = require("next/navigation");
3360
+ var import_lucide_react21 = require("lucide-react");
3361
+ var import_react18 = require("react");
3362
+ var import_jsx_runtime42 = require("react/jsx-runtime");
3363
+ function Sidebar({ docs, version, onLinkClick, config, activeTabGroup }) {
3364
+ const pathname = (0, import_navigation4.usePathname)();
3365
+ const [collapsed, setCollapsed] = (0, import_react18.useState)(() => {
3366
+ const initial = {};
3367
+ return initial;
3368
+ });
3369
+ if (!config.navigation?.showSidebar) {
3370
+ return null;
3371
+ }
3372
+ const hasTabGroups = config.navigation?.tabGroups && config.navigation.tabGroups.length > 0;
3373
+ const filteredDocs = hasTabGroups && activeTabGroup ? docs.filter((doc) => {
3374
+ const docTabGroup = doc.meta?.tab_group || doc.categoryTabGroup;
3375
+ if (!docTabGroup) {
3376
+ return activeTabGroup === config.navigation?.tabGroups?.[0]?.id;
3377
+ }
3378
+ return docTabGroup === activeTabGroup;
3379
+ }) : docs;
3380
+ const rootGroups = {};
3381
+ const standalone = [];
3382
+ filteredDocs.forEach((doc) => {
3383
+ const pathParts = doc.filePath.split("/");
3384
+ const isIndexFile = doc.filePath.endsWith("/index") || doc.filePath === "index" || pathParts.length > 1 && doc.slug === pathParts.slice(0, -1).join("/");
3385
+ const customGroup = doc.sidebar || doc.group;
3386
+ if (customGroup) {
3387
+ const groupName = customGroup.charAt(0).toUpperCase() + customGroup.slice(1);
3388
+ if (!rootGroups[groupName]) {
3389
+ rootGroups[groupName] = {
3390
+ label: groupName,
3391
+ path: customGroup,
3392
+ items: [],
3393
+ position: 999,
3394
+ collapsible: doc.categoryCollapsible ?? true,
3395
+ defaultCollapsed: doc.categoryCollapsed ?? false,
3396
+ children: {}
3397
+ };
3398
+ }
3399
+ if (isIndexFile) {
3400
+ rootGroups[groupName].position = doc.sidebar_position ?? 999;
3401
+ rootGroups[groupName].icon = doc.categoryIcon;
3402
+ } else {
3403
+ rootGroups[groupName].items.push(doc);
3404
+ }
3405
+ return;
3406
+ }
3407
+ if (pathParts.length > 1) {
3408
+ const folderParts = pathParts.slice(0, -1);
3409
+ let currentLevel = rootGroups;
3410
+ let currentPath = "";
3411
+ for (let i = 0; i < folderParts.length; i++) {
3412
+ const folder = folderParts[i];
3413
+ currentPath = currentPath ? `${currentPath}/${folder}` : folder;
3414
+ const folderLabel = folder.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
3415
+ if (!currentLevel[folder]) {
3416
+ currentLevel[folder] = {
3417
+ label: doc.categoryLabel && i === folderParts.length - 1 ? doc.categoryLabel : folderLabel,
3418
+ path: currentPath,
3419
+ icon: doc.categoryIcon,
3420
+ items: [],
3421
+ position: doc.categoryPosition ?? 999,
3422
+ collapsible: doc.categoryCollapsible ?? true,
3423
+ defaultCollapsed: doc.categoryCollapsed ?? false,
3424
+ children: {}
3425
+ };
3426
+ }
3427
+ if (i === folderParts.length - 1) {
3428
+ if (isIndexFile) {
3429
+ currentLevel[folder].position = doc.categoryPosition ?? doc.sidebar_position ?? 999;
3430
+ if (doc.categoryLabel) {
3431
+ currentLevel[folder].label = doc.categoryLabel;
3432
+ }
3433
+ if (doc.categoryIcon) {
3434
+ currentLevel[folder].icon = doc.categoryIcon;
3435
+ }
3436
+ } else {
3437
+ currentLevel[folder].items.push(doc);
3438
+ }
3439
+ }
3440
+ currentLevel = currentLevel[folder].children;
3441
+ }
3442
+ } else {
3443
+ if (!isIndexFile) {
3444
+ standalone.push(doc);
3445
+ }
3446
+ }
3447
+ });
3448
+ const toggleSection = (section) => {
3449
+ setCollapsed((prev) => ({ ...prev, [section]: !prev[section] }));
3450
+ };
3451
+ const renderGroup = (groupKey, group, depth = 0) => {
3452
+ const sortedItems = sortSidebarItems(group.items);
3453
+ const sortedChildren = sortSidebarGroups(group.children);
3454
+ const hasChildren = sortedChildren.length > 0;
3455
+ const hasItems = sortedItems.length > 0;
3456
+ const hasContent = hasChildren || hasItems;
3457
+ const isActiveInGroup = (g) => {
3458
+ const hasActiveItem2 = g.items.some((doc) => pathname === `/docs/${version}/${doc.slug}`);
3459
+ if (hasActiveItem2) return true;
3460
+ return Object.values(g.children).some((child) => isActiveInGroup(child));
3461
+ };
3462
+ const hasActiveItem = isActiveInGroup(group);
3463
+ const isGroupActive = pathname === `/docs/${version}/${group.path}`;
3464
+ const isCollapsed = hasActiveItem || isGroupActive ? false : collapsed[groupKey] ?? group.defaultCollapsed;
3465
+ const marginLeft = depth > 0 ? "ml-4" : "";
3466
+ const groupHref = `/docs/${version}/${group.path}`;
3467
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: `space-y-1 ${marginLeft}`, children: [
3468
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "flex items-center group", children: [
3469
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
3470
+ import_link7.default,
3471
+ {
3472
+ href: groupHref,
3473
+ onClick: onLinkClick,
3474
+ className: `flex items-center gap-2 flex-1 px-3 py-2 text-sm font-semibold rounded-l-xl transition-all ${isGroupActive ? "bg-primary/10 text-primary" : "text-foreground hover:bg-accent/50"}`,
3475
+ children: [
3476
+ group.icon ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Icon, { icon: group.icon, size: 16, className: "shrink-0" }) : /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_lucide_react21.FolderOpen, { size: 16, className: "shrink-0" }),
3477
+ group.label
3478
+ ]
3479
+ }
3480
+ ),
3481
+ hasContent && group.collapsible && config.navigation?.collapsibleSidebar && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
3482
+ "button",
3483
+ {
3484
+ onClick: (e) => {
3485
+ e.preventDefault();
3486
+ e.stopPropagation();
3487
+ toggleSection(groupKey);
3488
+ },
3489
+ className: `p-2 rounded-r-xl transition-all ${isGroupActive ? "hover:bg-primary/20" : "hover:bg-accent/50"}`,
3490
+ "aria-label": isCollapsed ? "Expand section" : "Collapse section",
3491
+ children: isCollapsed ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_lucide_react21.ChevronRight, { className: `h-4 w-4 ${isGroupActive ? "text-primary" : "text-muted-foreground"}` }) : /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_lucide_react21.ChevronDown, { className: `h-4 w-4 ${isGroupActive ? "text-primary" : "text-muted-foreground"}` })
3492
+ }
3493
+ )
3494
+ ] }),
3495
+ !isCollapsed && hasContent && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "ml-4 space-y-1", children: (() => {
3496
+ const merged = [
3497
+ ...sortedChildren.map(([childKey, childGroup]) => ({
3498
+ type: "group",
3499
+ key: childKey,
3500
+ group: childGroup,
3501
+ position: childGroup.position
3502
+ })),
3503
+ ...sortedItems.map((doc) => ({
3504
+ type: "item",
3505
+ doc,
3506
+ position: doc.sidebar_position ?? doc.meta?.sidebar_position ?? doc.meta?.order ?? 999
3507
+ }))
3508
+ ];
3509
+ merged.sort((a, b) => a.position - b.position);
3510
+ return merged.map((item) => {
3511
+ if (item.type === "group") {
3512
+ return renderGroup(`${groupKey}/${item.key}`, item.group, depth + 1);
3513
+ } else {
3514
+ const href = `/docs/${version}/${item.doc.slug}`;
3515
+ const isActive = pathname === href;
3516
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
3517
+ import_link7.default,
3518
+ {
3519
+ href,
3520
+ onClick: onLinkClick,
3521
+ className: `flex items-center gap-2 px-3 py-2 text-sm rounded-xl transition-all ${isActive ? "bg-primary/10 text-primary font-medium" : "text-foreground hover:text-foreground hover:bg-accent/50"}`,
3522
+ children: [
3523
+ item.doc.meta?.icon && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Icon, { icon: item.doc.meta.icon, size: 16, className: "shrink-0" }),
3524
+ item.doc.title
3525
+ ]
3526
+ },
3527
+ `grouped-${item.doc.slug}`
3528
+ );
3529
+ }
3530
+ });
3531
+ })() })
3532
+ ] }, `group-${groupKey}`);
3533
+ };
3534
+ const sortedRootGroups = sortSidebarGroups(rootGroups);
3535
+ const sortedStandalone = sortSidebarItems(standalone);
3536
+ const stickyTop = hasTabGroups ? "top-[7.5rem]" : "top-24";
3537
+ const maxHeight = hasTabGroups ? "max-h-[calc(100vh-10rem)]" : "max-h-[calc(100vh-7rem)]";
3538
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("aside", { className: `w-64 shrink-0 sticky ${stickyTop} self-start`, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: `${maxHeight} overflow-y-auto bg-muted/30 dark:bg-muted/10 rounded-2xl p-4 border border-border/50`, children: [
3539
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("h2", { className: "text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-4 px-2", children: "Documentation" }),
3540
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("nav", { className: "space-y-1", children: [
3541
+ sortedStandalone.length > 0 && sortedStandalone.map((doc) => {
3542
+ const href = `/docs/${version}/${doc.slug}`;
3543
+ const isActive = pathname === href;
3544
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
3545
+ import_link7.default,
3546
+ {
3547
+ href,
3548
+ onClick: onLinkClick,
3549
+ className: `flex items-center gap-2 px-3 py-2 text-sm rounded-xl transition-all ${isActive ? "bg-primary/10 text-primary font-medium" : "text-foreground hover:text-foreground hover:bg-accent/50"}`,
3550
+ children: [
3551
+ doc.meta?.icon && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Icon, { icon: doc.meta.icon, size: 16, className: "shrink-0" }),
3552
+ doc.title
3553
+ ]
3554
+ },
3555
+ `standalone-${doc.slug}`
3556
+ );
3557
+ }),
3558
+ sortedRootGroups.map(([groupKey, group]) => renderGroup(groupKey, group, 0))
3559
+ ] })
3560
+ ] }) });
3561
+ }
3562
+
3563
+ // src/components/docs/mobile-doc-layout.tsx
3564
+ var import_jsx_runtime43 = require("react/jsx-runtime");
3565
+ function MobileDocLayout({ header, docs, version, content, toc, config, activeTabGroup, onTabChange }) {
3566
+ const [sidebarOpen, setSidebarOpen] = (0, import_react19.useState)(false);
3567
+ const handleTabChange = (tabId) => {
3568
+ onTabChange?.(tabId);
3569
+ };
3570
+ const closeSidebar = () => setSidebarOpen(false);
3571
+ const toggleSidebar = () => setSidebarOpen(!sidebarOpen);
3572
+ const headerWithProps = (0, import_react19.isValidElement)(header) ? (0, import_react19.cloneElement)(header, {
3573
+ onMenuClick: toggleSidebar
3574
+ }) : header;
3575
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "min-h-screen bg-background", children: [
3576
+ headerWithProps,
3577
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(SiteBanner, { config }),
3578
+ config.navigation?.tabGroups && config.navigation.tabGroups.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
3579
+ TabGroups,
3580
+ {
3581
+ tabGroups: config.navigation.tabGroups,
3582
+ activeTabId: activeTabGroup,
3583
+ onTabChange: handleTabChange
3584
+ }
3585
+ ),
3586
+ sidebarOpen && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
3587
+ "div",
3588
+ {
3589
+ className: "lg:hidden fixed inset-0 bg-background/80 backdrop-blur-sm z-40",
3590
+ onClick: () => setSidebarOpen(false)
3591
+ }
3592
+ ),
3593
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
3594
+ "div",
3595
+ {
3596
+ className: `lg:hidden fixed top-0 left-0 h-full w-64 bg-background border-r border-border z-40 transform transition-transform duration-300 ease-in-out overflow-y-auto ${sidebarOpen ? "translate-x-0" : "-translate-x-full"}`,
3597
+ children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "pt-20 px-4", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
3598
+ Sidebar,
3599
+ {
3600
+ docs,
3601
+ version,
3602
+ config,
3603
+ onLinkClick: closeSidebar,
3604
+ activeTabGroup
3605
+ }
3606
+ ) })
3607
+ }
3608
+ ),
3609
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("main", { className: "container mx-auto px-6 py-8", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "flex", children: [
3610
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "hidden lg:block", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
3611
+ Sidebar,
3612
+ {
3613
+ docs,
3614
+ version,
3615
+ config,
3616
+ activeTabGroup
3617
+ }
3618
+ ) }),
3619
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "flex-1 min-w-0", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "flex flex-col gap-2 px-2 md:px-8", children: [
3620
+ content,
3621
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Footer, { config })
3622
+ ] }) }),
3623
+ toc
3624
+ ] }) })
3625
+ ] });
3626
+ }
3627
+
3628
+ // src/components/docs/tab-context.tsx
3629
+ var import_react20 = require("react");
3630
+ var import_jsx_runtime44 = require("react/jsx-runtime");
3631
+ var TabContext = (0, import_react20.createContext)(void 0);
3632
+ function useTabContext() {
3633
+ const context = (0, import_react20.useContext)(TabContext);
3634
+ if (!context) {
3635
+ throw new Error("useTabContext must be used within TabProvider");
3636
+ }
3637
+ return context;
3638
+ }
3639
+
3640
+ // src/components/docs/doc-layout-wrapper.tsx
3641
+ var import_jsx_runtime45 = require("react/jsx-runtime");
3642
+ function DocLayoutWrapper({ header, docs, version, content, toc, config, currentPageTabGroup }) {
3643
+ const { activeTabGroup, setActiveTabGroup } = useTabContext();
3644
+ const lastPageTabGroupRef = (0, import_react21.useRef)(void 0);
3645
+ const isInitialMount = (0, import_react21.useRef)(true);
3646
+ (0, import_react21.useEffect)(() => {
3647
+ if (isInitialMount.current && currentPageTabGroup) {
3648
+ setActiveTabGroup(currentPageTabGroup);
3649
+ lastPageTabGroupRef.current = currentPageTabGroup;
3650
+ isInitialMount.current = false;
3651
+ return;
3652
+ }
3653
+ if (currentPageTabGroup && lastPageTabGroupRef.current !== currentPageTabGroup) {
3654
+ setActiveTabGroup(currentPageTabGroup);
3655
+ lastPageTabGroupRef.current = currentPageTabGroup;
3656
+ }
3657
+ }, [currentPageTabGroup, setActiveTabGroup]);
3658
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
3659
+ MobileDocLayout,
3660
+ {
3661
+ header,
3662
+ docs,
3663
+ version,
3664
+ content,
3665
+ toc,
3666
+ config,
3667
+ activeTabGroup,
3668
+ onTabChange: setActiveTabGroup
3669
+ }
3670
+ );
3671
+ }
3672
+
3673
+ // src/components/docs/hot-reload-indicator.tsx
3674
+ var import_react22 = require("react");
3675
+ var import_navigation5 = require("next/navigation");
3676
+ var import_lucide_react22 = require("lucide-react");
3677
+ var import_jsx_runtime46 = require("react/jsx-runtime");
3678
+ function HotReloadIndicator() {
3679
+ const [isReloading, setIsReloading] = (0, import_react22.useState)(false);
3680
+ const [lastReload, setLastReload] = (0, import_react22.useState)(null);
3681
+ const pathname = (0, import_navigation5.usePathname)();
3682
+ (0, import_react22.useEffect)(() => {
3683
+ if (process.env.NODE_ENV !== "development") return;
3684
+ setIsReloading(true);
3685
+ const timer = setTimeout(() => {
3686
+ setIsReloading(false);
3687
+ setLastReload(/* @__PURE__ */ new Date());
3688
+ setTimeout(() => {
3689
+ setLastReload(null);
3690
+ }, 3e3);
3691
+ }, 500);
3692
+ return () => clearTimeout(timer);
3693
+ }, [pathname]);
3694
+ (0, import_react22.useEffect)(() => {
3695
+ if (process.env.NODE_ENV !== "development") return;
3696
+ const handleBeforeRefresh = () => {
3697
+ setIsReloading(true);
3698
+ };
3699
+ const handleAfterRefresh = () => {
3700
+ setIsReloading(false);
3701
+ setLastReload(/* @__PURE__ */ new Date());
3702
+ setTimeout(() => setLastReload(null), 3e3);
3703
+ };
3704
+ if (typeof window !== "undefined" && window.__NEXT_DATA__) {
3705
+ window.addEventListener("beforeunload", handleBeforeRefresh);
3706
+ }
3707
+ return () => {
3708
+ window.removeEventListener("beforeunload", handleBeforeRefresh);
3709
+ };
3710
+ }, []);
3711
+ if (process.env.NODE_ENV !== "development") return null;
3712
+ return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_jsx_runtime46.Fragment, { children: [
3713
+ isReloading && /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "fixed bottom-4 right-4 z-50 flex items-center gap-2 px-4 py-2 bg-primary text-primary-foreground rounded-xl shadow-lg animate-in slide-in-from-bottom-2", children: [
3714
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_lucide_react22.RefreshCw, { className: "h-4 w-4 animate-spin" }),
3715
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: "text-sm font-medium", children: "Reloading..." })
3716
+ ] }),
3717
+ lastReload && !isReloading && /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "fixed bottom-4 right-4 z-50 flex items-center gap-2 px-4 py-2 bg-green-500 text-white rounded-xl shadow-lg animate-in slide-in-from-bottom-2", children: [
3718
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_lucide_react22.RefreshCw, { className: "h-4 w-4" }),
3719
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("span", { className: "text-sm font-medium", children: [
3720
+ "Updated at ",
3721
+ lastReload.toLocaleTimeString()
3722
+ ] })
3723
+ ] })
3724
+ ] });
3725
+ }
3726
+
3727
+ // src/components/docs/dev-mode-badge.tsx
3728
+ var import_react23 = require("react");
3729
+ var import_lucide_react23 = require("lucide-react");
3730
+ var import_jsx_runtime47 = require("react/jsx-runtime");
3731
+ function DevModeBadge() {
3732
+ const [isConnected, setIsConnected] = (0, import_react23.useState)(true);
3733
+ (0, import_react23.useEffect)(() => {
3734
+ if (process.env.NODE_ENV !== "development") return;
3735
+ const checkConnection = () => {
3736
+ setIsConnected(navigator.onLine);
3737
+ };
3738
+ window.addEventListener("online", checkConnection);
3739
+ window.addEventListener("offline", checkConnection);
3740
+ return () => {
3741
+ window.removeEventListener("online", checkConnection);
3742
+ window.removeEventListener("offline", checkConnection);
3743
+ };
3744
+ }, []);
3745
+ if (process.env.NODE_ENV !== "development") return null;
3746
+ return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "fixed top-20 left-4 z-40 flex items-center gap-2 px-3 py-1.5 bg-orange-500/10 text-orange-600 dark:text-orange-400 border border-orange-500/20 rounded-full text-xs font-medium", children: [
3747
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_lucide_react23.Code2, { className: "h-3 w-3" }),
3748
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { children: "Dev Mode" }),
3749
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: `h-2 w-2 rounded-full ${isConnected ? "bg-green-500" : "bg-red-500"} animate-pulse` })
3750
+ ] });
3751
+ }
3752
+
3753
+ // src/components/docs/mdx-hot-reload.tsx
3754
+ var import_react24 = require("react");
3755
+ var import_navigation6 = require("next/navigation");
3756
+ function MdxHotReload() {
3757
+ const router = (0, import_navigation6.useRouter)();
3758
+ (0, import_react24.useEffect)(() => {
3759
+ if (process.env.NODE_ENV !== "development") return;
3760
+ const eventSource = new EventSource("/api/mdx-watch");
3761
+ eventSource.onmessage = (event) => {
3762
+ const data = JSON.parse(event.data);
3763
+ if (data.type === "change") {
3764
+ console.log("[MDX Hot Reload] File changed:", data.file);
3765
+ router.refresh();
3766
+ } else if (data.type === "connected") {
3767
+ console.log("[MDX Hot Reload] Watching for changes...");
3768
+ }
3769
+ };
3770
+ eventSource.onerror = (error) => {
3771
+ console.error("[MDX Hot Reload] Connection error:", error);
3772
+ eventSource.close();
3773
+ };
3774
+ return () => {
3775
+ eventSource.close();
3776
+ };
3777
+ }, [router]);
3778
+ return null;
3779
+ }
3780
+
3781
+ // src/components/docs/category-index.tsx
3782
+ var import_link8 = __toESM(require("next/link"));
3783
+ var import_lucide_react24 = require("lucide-react");
3784
+ var import_rsc2 = require("next-mdx-remote/rsc");
3785
+ var import_remark_gfm2 = __toESM(require("remark-gfm"));
3786
+ var import_rehype_slug2 = __toESM(require("rehype-slug"));
3787
+ var import_jsx_runtime48 = require("react/jsx-runtime");
3788
+ function CategoryIndex({ categoryPath, version, allDocs, title, description, content, config }) {
3789
+ const childDocs = allDocs.filter((doc) => {
3790
+ const parts = doc.slug.split("/");
3791
+ const docParent = parts.slice(0, -1).join("/");
3792
+ return docParent === categoryPath && doc.slug !== categoryPath;
3793
+ });
3794
+ const processedContent = () => {
3795
+ if (content) {
3796
+ return processContentWithEnv(content, config);
3797
+ }
3798
+ return "";
3799
+ };
3800
+ const sortedDocs = sortSidebarItems(childDocs);
3801
+ return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex-1 min-w-0", children: [
3802
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "mb-8", children: [
3803
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("h1", { className: "text-4xl font-bold tracking-tight mb-3 text-foreground", children: title }),
3804
+ description && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { className: "text-lg text-muted-foreground leading-relaxed", children: description }),
3805
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "prose prose-slate dark:prose-invert max-w-none prose-headings:scroll-mt-24 prose-headings:font-semibold prose-h1:text-4xl prose-h2:text-3xl prose-h2:mt-12 prose-h2:mb-4 prose-h3:text-2xl prose-h3:mt-8 prose-h3:mb-3 prose-p:text-base prose-p:leading-7 prose-p:text-muted-foreground prose-p:mb-4 prose-a:font-normal prose-a:transition-all prose-code:text-primary prose-code:bg-muted/50 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded-md prose-code:text-[13px] prose-code:font-mono prose-code:border prose-code:border-border/50 prose-code:before:content-none prose-code:after:content-none prose-pre:bg-transparent prose-pre:p-0 prose-ul:list-disc prose-ul:list-inside prose-ul:space-y-2 prose-ul:mb-4 prose-ol:list-decimal prose-ol:list-inside prose-ol:space-y-2 prose-ol:mb-4 prose-li:leading-7 prose-li:text-muted-foreground prose-strong:text-foreground prose-strong:font-semibold", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
3806
+ import_rsc2.MDXRemote,
3807
+ {
3808
+ source: processedContent(),
3809
+ options: {
3810
+ parseFrontmatter: false,
3811
+ mdxOptions: {
3812
+ remarkPlugins: [import_remark_gfm2.default, remarkCodeMeta],
3813
+ rehypePlugins: [import_rehype_slug2.default],
3814
+ development: false
3815
+ }
3816
+ },
3817
+ components: mdxComponents
3818
+ }
3819
+ ) })
3820
+ ] }),
3821
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "grid grid-cols-1 sm:grid-cols-2 md:grid-cols-2 lg:grid-cols-3 gap-4", children: sortedDocs.map((doc) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
3822
+ import_link8.default,
3823
+ {
3824
+ href: `/docs/${version}/${doc.slug}`,
3825
+ className: "group block p-5 rounded-xl border border-border bg-card hover:bg-accent hover:border-primary/50 transition-all duration-200",
3826
+ style: {
3827
+ textDecoration: "none !important"
3828
+ },
3829
+ children: /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex items-start justify-between gap-4", children: [
3830
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex-1 min-w-0", children: [
3831
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex items-center gap-2 mb-2", children: [
3832
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_lucide_react24.FileText, { className: "h-6 w-6 text-primary shrink-0" }),
3833
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("h3", { className: "text-lg font-semibold text-foreground group-hover:text-primary transition-colors", children: doc.meta.title || doc.title })
3834
+ ] }),
3835
+ doc.meta.description && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { className: "text-sm text-muted-foreground line-clamp-2", children: doc.meta.description }),
3836
+ doc.meta.reading_time && /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("p", { className: "text-xs text-muted-foreground mt-2", children: [
3837
+ doc.meta.reading_time,
3838
+ " min read"
3839
+ ] })
3840
+ ] }),
3841
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_lucide_react24.ChevronRight, { className: "h-5 w-5 text-muted-foreground group-hover:text-primary group-hover:translate-x-1 transition-all flex-shrink-0 mt-1" })
3842
+ ] })
3843
+ },
3844
+ doc.slug
3845
+ )) }),
3846
+ sortedDocs.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "text-center py-12 text-muted-foreground", children: [
3847
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_lucide_react24.FileText, { className: "h-12 w-12 mx-auto mb-3 opacity-50" }),
3848
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { children: "No documents found in this category." })
3849
+ ] })
3850
+ ] });
3851
+ }
3852
+
3853
+ // src/components/docs/not-found-content.tsx
3854
+ var import_link9 = __toESM(require("next/link"));
3855
+ var import_lucide_react25 = require("lucide-react");
3856
+ var import_jsx_runtime49 = require("react/jsx-runtime");
3857
+ function NotFoundContent({ version }) {
3858
+ return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: "flex min-h-[calc(100vh-12rem)] items-center justify-center px-4 py-12", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: "w-full max-w-2xl text-center", children: [
3859
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: "mb-6 flex justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: "rounded-full bg-yellow-500/10 p-4", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_lucide_react25.AlertTriangle, { className: "h-16 w-16 text-yellow-500" }) }) }),
3860
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("h1", { className: "mb-3 text-5xl font-bold tracking-tight", children: "404" }),
3861
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("h2", { className: "mb-4 text-2xl font-semibold", children: "Page Not Found" }),
3862
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("p", { className: "mb-8 text-base text-muted-foreground", children: [
3863
+ "The documentation page you're looking for doesn't exist or may have been moved.",
3864
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("br", {}),
3865
+ "Try using the sidebar to find what you're looking for, or return to the documentation home."
3866
+ ] }),
3867
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: "flex flex-col items-center justify-center gap-3 sm:flex-row", children: [
3868
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
3869
+ import_link9.default,
3870
+ {
3871
+ href: `/docs/${version}`,
3872
+ className: "inline-flex items-center gap-2 rounded-lg bg-primary px-6 py-3 text-sm font-medium text-primary-foreground hover:bg-primary/90 transition-colors",
3873
+ children: [
3874
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_lucide_react25.ArrowLeft, { className: "h-4 w-4" }),
3875
+ "Back to Documentation"
3876
+ ]
3877
+ }
3878
+ ),
3879
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
3880
+ import_link9.default,
3881
+ {
3882
+ href: "/",
3883
+ className: "inline-flex items-center gap-2 rounded-lg border border-border bg-background px-6 py-3 text-sm font-medium hover:bg-muted transition-colors",
3884
+ children: [
3885
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_lucide_react25.Home, { className: "h-4 w-4" }),
3886
+ "Go to Homepage"
3887
+ ]
3888
+ }
3889
+ )
3890
+ ] }),
3891
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: "mt-12 rounded-lg border border-border bg-muted/30 p-6", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("p", { className: "text-sm text-muted-foreground", children: [
3892
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("strong", { className: "font-medium text-foreground", children: "Tip:" }),
3893
+ " Use the sidebar navigation on the left to browse all available documentation pages."
3894
+ ] }) })
3895
+ ] }) });
3896
+ }
3897
+
3898
+ // src/app/docs-page.tsx
3899
+ var import_react25 = require("react");
3900
+
3901
+ // src/components/docs/doc-loading.tsx
3902
+ var import_jsx_runtime50 = require("react/jsx-runtime");
3903
+ function DocLoading() {
3904
+ return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "max-w-4xl mx-auto px-6 py-8", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "animate-pulse space-y-4", children: [
3905
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "h-8 bg-gray-200 rounded w-3/4" }),
3906
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "h-4 bg-gray-200 rounded w-1/2" }),
3907
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "space-y-3 mt-8", children: [
3908
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "h-4 bg-gray-200 rounded" }),
3909
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "h-4 bg-gray-200 rounded w-5/6" }),
3910
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "h-4 bg-gray-200 rounded w-4/6" })
3911
+ ] })
3912
+ ] }) });
3913
+ }
3914
+
3915
+ // src/app/docs-page.tsx
3916
+ var import_jsx_runtime51 = require("react/jsx-runtime");
3917
+ async function generateMetadata({ params }) {
3918
+ const { version, slug: slugArray } = await params;
3919
+ const slug = slugArray.join("/");
3920
+ const doc = await getCachedDocBySlug(slug, version);
3921
+ if (!doc) {
3922
+ return {
3923
+ title: "Page Not Found",
3924
+ description: "The requested documentation page could not be found."
3925
+ };
3926
+ }
3927
+ const title = doc.meta.title || doc.title;
3928
+ const description = doc.meta.description || `Documentation for ${title}`;
3929
+ const url = `/docs/${version}/${slug}`;
3930
+ return {
3931
+ title: `${title}`,
3932
+ description,
3933
+ openGraph: {
3934
+ title,
3935
+ description,
3936
+ url,
3937
+ siteName: "Documentation Platform",
3938
+ type: "article",
3939
+ locale: "en_US"
3940
+ },
3941
+ twitter: {
3942
+ card: "summary_large_image",
3943
+ title,
3944
+ description
3945
+ },
3946
+ alternates: {
3947
+ canonical: url
3948
+ }
3949
+ };
3950
+ }
3951
+ async function generateStaticParams() {
3952
+ const versions = getCachedVersions();
3953
+ const params = [];
3954
+ for (const version of versions) {
3955
+ const docs = await getCachedAllDocs(version);
3956
+ for (const doc of docs) {
3957
+ params.push({
3958
+ version,
3959
+ slug: doc.slug.split("/").filter(Boolean)
3960
+ });
3961
+ }
3962
+ }
3963
+ return params;
3964
+ }
3965
+ async function DocPage({ params }) {
3966
+ const { version, slug: slugArray } = await params;
3967
+ const slug = slugArray.join("/");
3968
+ const allDocs = await getCachedAllDocs(version);
3969
+ const versions = getCachedVersions();
3970
+ const config = getConfig();
3971
+ const isCategory = isCategoryPage(slug, allDocs);
3972
+ const doc = await getCachedDocBySlug(slug, version);
3973
+ if (!doc && isCategory) {
3974
+ const categoryDoc = allDocs.find((d) => d.slug.startsWith(slug + "/"));
3975
+ const categoryTabGroup = categoryDoc?.meta?.tab_group || categoryDoc?.categoryTabGroup;
3976
+ return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_jsx_runtime51.Fragment, { children: [
3977
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
3978
+ DocLayoutWrapper,
3979
+ {
3980
+ header: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Header, { currentVersion: version, versions, config }),
3981
+ docs: allDocs,
3982
+ version,
3983
+ content: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
3984
+ CategoryIndex,
3985
+ {
3986
+ categoryPath: slug,
3987
+ version,
3988
+ allDocs,
3989
+ title: slug.split("/").pop()?.replace(/-/g, " ").replace(/\b\w/g, (l) => l.toUpperCase()) || "Category",
3990
+ description: "Browse the documentation in this section.",
3991
+ config
3992
+ }
3993
+ ),
3994
+ toc: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", {}),
3995
+ config,
3996
+ currentPageTabGroup: categoryTabGroup
3997
+ }
3998
+ ),
3999
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(MdxHotReload, {}),
4000
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(HotReloadIndicator, {}),
4001
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(DevModeBadge, {})
4002
+ ] });
4003
+ }
4004
+ if (!doc) {
4005
+ return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_jsx_runtime51.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_react25.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(DocLoading, {}), children: [
4006
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
4007
+ DocLayoutWrapper,
4008
+ {
4009
+ header: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Header, { currentVersion: version, versions, config }),
4010
+ docs: allDocs,
4011
+ version,
4012
+ content: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(NotFoundContent, { version }),
4013
+ toc: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", {}),
4014
+ config,
4015
+ currentPageTabGroup: void 0
4016
+ }
4017
+ ),
4018
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(MdxHotReload, {}),
4019
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(HotReloadIndicator, {}),
4020
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(DevModeBadge, {})
4021
+ ] }) });
4022
+ }
4023
+ const toc = extractTableOfContents(doc.content);
4024
+ const { previous, next } = getAdjacentDocs(slug, allDocs);
4025
+ const showCategoryIndex = isCategory && doc;
4026
+ const currentPageTabGroup = doc.meta?.tab_group || doc.categoryTabGroup;
4027
+ return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_jsx_runtime51.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_react25.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(DocLoading, {}), children: [
4028
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
4029
+ DocLayoutWrapper,
4030
+ {
4031
+ header: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Header, { currentVersion: version, versions, config }),
4032
+ docs: allDocs,
4033
+ version,
4034
+ content: showCategoryIndex ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
4035
+ CategoryIndex,
4036
+ {
4037
+ categoryPath: slug,
4038
+ version,
4039
+ allDocs,
4040
+ title: doc.meta.title,
4041
+ description: doc.meta.description,
4042
+ content: doc.content,
4043
+ config
4044
+ }
4045
+ ) : /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
4046
+ DocLayout,
4047
+ {
4048
+ meta: doc.meta,
4049
+ content: doc.content,
4050
+ previousDoc: previous ? { title: previous.meta.title, slug: previous.slug } : void 0,
4051
+ nextDoc: next ? { title: next.meta.title, slug: next.slug } : void 0,
4052
+ version,
4053
+ slug,
4054
+ config
4055
+ }
4056
+ ),
4057
+ toc: showCategoryIndex ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", {}) : /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(TableOfContents, { items: toc, config }),
4058
+ config,
4059
+ currentPageTabGroup
4060
+ }
4061
+ ),
4062
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(MdxHotReload, {}),
4063
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(HotReloadIndicator, {}),
4064
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(DevModeBadge, {})
4065
+ ] }) });
4066
+ }
4067
+ // Annotate the CommonJS export names for ESM import in node:
4068
+ 0 && (module.exports = {
4069
+ generateMetadata,
4070
+ generateStaticParams
4071
+ });
4072
+ //# sourceMappingURL=docs-page.js.map