boltdocs 2.8.2 → 2.8.4

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 (51) hide show
  1. package/dist/{banner-3N4Jd_L9.d.ts → banner-BLTQUA2O.d.ts} +1 -1
  2. package/dist/{banner-MynZD_Ox.d.cts → banner-DFACg5Dy.d.cts} +1 -1
  3. package/dist/client/index.cjs +39 -19
  4. package/dist/client/index.d.cts +2 -2
  5. package/dist/client/index.d.ts +2 -2
  6. package/dist/client/index.js +39 -19
  7. package/dist/client/mdx.cjs +1 -1
  8. package/dist/client/mdx.js +1 -1
  9. package/dist/client/primitives.cjs +4 -4
  10. package/dist/client/primitives.d.cts +1 -1
  11. package/dist/client/primitives.d.ts +1 -1
  12. package/dist/client/primitives.js +4 -4
  13. package/dist/{docs-layout-Dn6S5g59.js → docs-layout-BBv6wILp.js} +82 -92
  14. package/dist/{docs-layout-CwCq42Zt.cjs → docs-layout-CVCf3xkZ.cjs} +82 -92
  15. package/dist/{doctor-aN_leTbh.mjs → doctor-BGPdO1Ah.mjs} +1 -1
  16. package/dist/{doctor-DyNUVe96.cjs → doctor-DT4jh07O.cjs} +1 -1
  17. package/dist/doctor-Dnv77Lfx.mjs +28 -0
  18. package/dist/doctor-VBPlQf7d.cjs +28 -0
  19. package/dist/{icons-dev-DvJ-hh9x.cjs → icons-dev-C8sFxeBk.cjs} +6 -3
  20. package/dist/{icons-dev-Oju24Wjp.js → icons-dev-CFcv5Nb8.js} +6 -3
  21. package/dist/{image-Ch4-GxdO.cjs → image-DCMxxidi.cjs} +9 -3
  22. package/dist/{image-Do8V9PCW.js → image-DufDOid8.js} +9 -3
  23. package/dist/{mdx-BGM7LjW5.cjs → mdx-BH9kHiF9.cjs} +2 -2
  24. package/dist/{mdx-5oeCOFhH.js → mdx-Bto8CvGl.js} +2 -2
  25. package/dist/node/cli-entry.cjs +2 -2
  26. package/dist/node/cli-entry.mjs +3 -3
  27. package/dist/node/index.cjs +1 -1
  28. package/dist/node/index.mjs +1 -1
  29. package/dist/node/routes/worker.mjs +1 -1
  30. package/dist/{node-BfGSXyUz.cjs → node-JM9bx0mO.cjs} +5 -4
  31. package/dist/{node-NZrBn5jg.mjs → node-q-Y2mdLX.mjs} +5 -4
  32. package/dist/{package-DBz4CSnw.cjs → package-CwNjt3Sd.cjs} +1 -1
  33. package/dist/{package-C1qrHXzn.mjs → package-DlgexgpQ.mjs} +1 -1
  34. package/dist/{parser-BrkFi6YE.mjs → parser-9LqyiEnB.mjs} +1 -1
  35. package/dist/{routes-DJNJ-rTt.cjs → routes-3sAccArX.cjs} +1 -1
  36. package/dist/{routes-f9J1MQRr.mjs → routes-DZpXqq1p.mjs} +1 -1
  37. package/dist/{routes-CtQzxiZg.mjs → routes-DjoxNeef.mjs} +1 -1
  38. package/dist/{routes-DiYC4nD2.cjs → routes-DpJnb2VS.cjs} +1 -1
  39. package/dist/{search-dialog-BYhOov4S.cjs → search-dialog-CmHYOt18.cjs} +2 -2
  40. package/dist/{search-dialog-CUeAfy-8.cjs → search-dialog-Cr7SC8Xt.cjs} +1 -1
  41. package/dist/{search-dialog-BXVoecTx.cjs → search-dialog-Cvux-qSk.cjs} +1 -1
  42. package/dist/{search-dialog-DHc_8FFX.js → search-dialog-DBNaG5At.js} +1 -1
  43. package/dist/{search-dialog-D8gLkhUV.js → search-dialog-e86WPpck.js} +1 -1
  44. package/dist/{search-dialog-C09riYmx.js → search-dialog-jHZ21G4i.js} +2 -2
  45. package/dist/{sidebar-Dlkgbxs6.d.cts → sidebar---RgTmZD.d.cts} +2 -0
  46. package/dist/{sidebar-DNq4_ZAa.d.ts → sidebar-kQBonN82.d.ts} +2 -0
  47. package/dist/{worker-pool-CtqklOXq.cjs → worker-pool-DXLyeHJg.cjs} +1 -1
  48. package/dist/{worker-pool-k0DY6k8T.mjs → worker-pool-Kn4F9gDq.mjs} +1 -1
  49. package/package.json +2 -1
  50. package/dist/doctor-BArviV8X.cjs +0 -28
  51. package/dist/doctor-CgLA7_Uv.mjs +0 -28
@@ -3,7 +3,7 @@
3
3
  * Copyright (c) 2026 Jesus Alcala
4
4
  * Licensed under the MIT License.
5
5
  */
6
- const require_icons_dev = require('./icons-dev-DvJ-hh9x.cjs');
6
+ const require_icons_dev = require('./icons-dev-C8sFxeBk.cjs');
7
7
  let react = require("react");
8
8
  let react_router_dom = require("react-router-dom");
9
9
  let react_jsx_runtime = require("react/jsx-runtime");
@@ -621,112 +621,102 @@ PageNav.Icon = PageNavIcon;
621
621
 
622
622
  //#endregion
623
623
  //#region src/client/hooks/use-sidebar.ts
624
+ const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1).replace(/-/g, " ");
625
+ const getCleanDirectoryMeta = (directoryMeta) => {
626
+ const meta = {};
627
+ if (!directoryMeta) return meta;
628
+ for (const [key, value] of Object.entries(directoryMeta)) {
629
+ const cleanKey = key.split("/").filter((part) => !part.startsWith("(") || !part.endsWith(")")).map((part) => part.replace(/^\d+-/, "")).join("/");
630
+ meta[cleanKey === "" ? "." : cleanKey] = value;
631
+ }
632
+ return meta;
633
+ };
634
+ const getOrCreateNode = (parts, rootMap, directoryMeta) => {
635
+ let currentMap = rootMap;
636
+ let parentPath = "";
637
+ let lastNode;
638
+ for (const segment of parts) {
639
+ const currentRelPath = parentPath ? `${parentPath}/${segment}` : segment;
640
+ if (!currentMap.has(segment)) {
641
+ const meta = directoryMeta[currentRelPath] || {};
642
+ const newNode = {
643
+ path: "#",
644
+ title: meta.title || capitalize(segment),
645
+ componentPath: "",
646
+ filePath: "",
647
+ icon: meta.icon,
648
+ groupPosition: typeof meta.order === "number" ? meta.order : 999,
649
+ subRoutes: [],
650
+ childrenMap: /* @__PURE__ */ new Map()
651
+ };
652
+ currentMap.set(segment, newNode);
653
+ }
654
+ lastNode = currentMap.get(segment);
655
+ currentMap = lastNode.childrenMap;
656
+ parentPath = currentRelPath;
657
+ }
658
+ return lastNode;
659
+ };
660
+ const getRoutePosition = (r) => r.sidebarPosition ?? r.order ?? 999;
661
+ const getNodePosition = (n) => n.sidebarPosition ?? n.groupPosition ?? 999;
662
+ const finalizeTree = (nodes) => {
663
+ return nodes.map((node) => {
664
+ if (node.childrenMap && node.childrenMap.size > 0) {
665
+ const childDirs = Array.from(node.childrenMap.values());
666
+ node.subRoutes = [...node.subRoutes || [], ...childDirs];
667
+ }
668
+ const { childrenMap, ...restNode } = node;
669
+ if (restNode.subRoutes && restNode.subRoutes.length > 0) restNode.subRoutes = finalizeTree(restNode.subRoutes);
670
+ return restNode;
671
+ }).sort((a, b) => {
672
+ const posA = getNodePosition(a);
673
+ const posB = getNodePosition(b);
674
+ return posA !== posB ? posA - posB : a.title.localeCompare(b.title);
675
+ });
676
+ };
624
677
  function useSidebar(routes) {
625
678
  const config = require_icons_dev.useConfig();
626
- const currentPath = require_icons_dev.normalizePath((0, react_router_dom.useLocation)().pathname);
679
+ const { pathname } = (0, react_router_dom.useLocation)();
627
680
  return (0, react.useMemo)(() => {
681
+ const currentPath = require_icons_dev.normalizePath(pathname);
628
682
  const activeRoute = routes.find((r) => require_icons_dev.normalizePath(r.path) === currentPath);
629
683
  const activeTabId = activeRoute?.tab?.toLowerCase();
630
- const noCollection = routes.filter((r) => !r.collection);
631
- const filteredRoutes = activeTabId ? noCollection.filter((r) => !r.tab || r.tab.toLowerCase() === activeTabId) : noCollection;
632
- const directoryMeta = {};
633
- if (config.directoryMeta) for (const [key, value] of Object.entries(config.directoryMeta)) {
634
- const cleanKey = key.split("/").filter((part) => !part.startsWith("(") || !part.endsWith(")")).map((part) => part.replace(/^\d+-/, "")).join("/");
635
- directoryMeta[cleanKey === "" ? "." : cleanKey] = value;
636
- }
637
- const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1).replace(/-/g, " ");
684
+ const filteredRoutes = routes.filter((r) => !r.collection && !r.sidebarHidden && !r.fallback).filter((r) => !activeTabId || r.tab?.toLowerCase() === activeTabId).sort((a, b) => getRoutePosition(a) - getRoutePosition(b));
685
+ const directoryMeta = getCleanDirectoryMeta(config.directoryMeta);
638
686
  const rootNodesMap = /* @__PURE__ */ new Map();
639
687
  const ungrouped = [];
640
- const getOrCreateNode = (parts, rootStore) => {
641
- let currentMap = rootStore;
642
- let parentPath = "";
643
- let lastNode = null;
644
- for (let i = 0; i < parts.length; i++) {
645
- const segment = parts[i];
646
- const currentRelPath = parentPath ? `${parentPath}/${segment}` : segment;
647
- if (!currentMap.has(segment)) {
648
- const meta = directoryMeta[currentRelPath] || {};
649
- const newNode = {
650
- path: "#",
651
- title: meta.title || capitalize(segment),
652
- componentPath: "",
653
- filePath: "",
654
- icon: meta.icon,
655
- groupPosition: typeof meta.order === "number" ? meta.order : 999,
656
- subRoutes: []
657
- };
658
- currentMap.set(segment, newNode);
659
- }
660
- lastNode = currentMap.get(segment);
661
- if (!lastNode._subMap) lastNode._subMap = /* @__PURE__ */ new Map();
662
- currentMap = lastNode._subMap;
663
- parentPath = currentRelPath;
664
- }
665
- return lastNode;
666
- };
667
- const sortedRoutes = [...filteredRoutes].sort((a, b) => {
668
- return (a.sidebarPosition ?? a.order ?? 999) - (b.sidebarPosition ?? b.order ?? 999);
669
- });
670
- for (const route of sortedRoutes) {
671
- if (route.sidebarHidden) continue;
688
+ for (const route of filteredRoutes) {
672
689
  const parts = route.slugParts || [];
673
- const fileName = route.filePath.split("/").pop() || "";
674
- const isIndex = /^index\.mdx?$/.test(fileName);
690
+ const isIndex = /^index\.mdx?$/.test(route.filePath.split("/").pop() || "");
675
691
  if (parts.length === 0) {
676
692
  if (route.filePath) ungrouped.push(route);
677
693
  continue;
678
694
  }
679
- if (isIndex) {
680
- const containerNode = getOrCreateNode(parts, rootNodesMap);
681
- if (containerNode) {
682
- containerNode.path = route.path;
683
- containerNode.title = route.title || containerNode.title;
684
- containerNode.icon = route.icon || containerNode.icon;
685
- containerNode.badge = route.badge;
686
- containerNode.sidebarPosition = route.sidebarPosition;
687
- containerNode.frontmatter = route.frontmatter;
688
- }
689
- } else {
690
- const parentNode = getOrCreateNode(parts, rootNodesMap);
691
- if (parentNode) parentNode.subRoutes.push(route);
692
- }
693
- }
694
- const finalizeTree = (nodes, currentPathPrefix = "") => {
695
- nodes.forEach((node) => {
696
- if (node._subMap) {
697
- const childDirs = Array.from(node._subMap.values());
698
- node.subRoutes = [...node.subRoutes || [], ...childDirs];
699
- delete node._subMap;
700
- }
701
- if (node.subRoutes && node.subRoutes.length > 0) node.subRoutes = finalizeTree(node.subRoutes);
695
+ const containerNode = getOrCreateNode(parts, rootNodesMap, directoryMeta);
696
+ if (isIndex) Object.assign(containerNode, {
697
+ path: route.path,
698
+ title: route.title || containerNode.title,
699
+ icon: route.icon || containerNode.icon,
700
+ badge: route.badge,
701
+ sidebarPosition: route.sidebarPosition,
702
+ frontmatter: route.frontmatter,
703
+ filePath: route.filePath
702
704
  });
703
- return nodes.sort((a, b) => {
704
- const posA = a.sidebarPosition ?? a.groupPosition ?? 999;
705
- const posB = b.sidebarPosition ?? b.groupPosition ?? 999;
706
- if (posA !== posB) return posA - posB;
707
- return a.title.localeCompare(b.title);
708
- });
709
- };
705
+ else containerNode.subRoutes.push(route);
706
+ }
710
707
  const finalizedTopNodes = finalizeTree(Array.from(rootNodesMap.values()));
711
- finalizedTopNodes.map((node) => {
712
- return {
713
- slug: node.title.toLowerCase().replace(/\s+/g, "-"),
714
- title: node.title,
715
- icon: node.icon,
716
- routes: [node]
717
- };
708
+ const groups = [];
709
+ for (const node of finalizedTopNodes) if (node.subRoutes && node.subRoutes.length > 0) groups.push({
710
+ slug: node.title.toLowerCase().replace(/\s+/g, "-"),
711
+ title: node.title,
712
+ icon: node.icon,
713
+ path: node.path,
714
+ filePath: node.filePath,
715
+ routes: node.subRoutes
718
716
  });
717
+ else ungrouped.push(node);
719
718
  return {
720
- groups: finalizedTopNodes.map((node) => {
721
- if (node.subRoutes && node.subRoutes.length > 0) return {
722
- slug: node.title.toLowerCase().replace(/\s+/g, "-"),
723
- title: node.title,
724
- icon: node.icon,
725
- routes: node.subRoutes
726
- };
727
- ungrouped.push(node);
728
- return null;
729
- }).filter(Boolean),
719
+ groups,
730
720
  ungrouped: finalizeTree(ungrouped),
731
721
  activeRoute,
732
722
  activePath: currentPath,
@@ -735,7 +725,7 @@ function useSidebar(routes) {
735
725
  }, [
736
726
  routes,
737
727
  config,
738
- currentPath
728
+ pathname
739
729
  ]);
740
730
  }
741
731
 
@@ -3,4 +3,4 @@
3
3
  * Copyright (c) 2026 Jesus Alcala
4
4
  * Licensed under the MIT License.
5
5
  */
6
- import{t as e}from"./doctor-CgLA7_Uv.mjs";export{e as doctorAction};
6
+ import{t as e}from"./doctor-Dnv77Lfx.mjs";export{e as doctorAction};
@@ -3,4 +3,4 @@
3
3
  * Copyright (c) 2026 Jesus Alcala
4
4
  * Licensed under the MIT License.
5
5
  */
6
- const e=require(`./doctor-BArviV8X.cjs`);exports.doctorAction=e.t;
6
+ const e=require(`./doctor-VBPlQf7d.cjs`);exports.doctorAction=e.t;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Boltdocs - https://boltdocs.vercel.app
3
+ * Copyright (c) 2026 Jesus Alcala
4
+ * Licensed under the MIT License.
5
+ */
6
+ import{a as e,d as t,u as n,v as r,y as i}from"./utils-BYITg7T5.mjs";import{createRequire as a}from"node:module";import{loadConfigFromFile as o}from"vite";import s from"node:path";import{fdir as c}from"fdir";import l from"node:fs";import{z as u}from"zod";import*as d from"@bdocs/dui";import{bullet as f,colors as p,confirm as m,dividerLog as h,double as g,error as _,info as v,round as ee,single as te,success as y,tasks as ne,warn as b}from"@bdocs/dui";import{fileURLToPath as x}from"node:url";import re from"picomatch";import S from"node:os";import{distance as C}from"fastest-levenshtein";const w=u.object({icon:u.string().max(50),link:u.string().url()});u.object({text:u.string().max(2e3).optional()});const T=u.object({name:u.string(),enforce:u.enum([`pre`,`post`]).optional(),version:u.string().optional(),boltdocsVersion:u.string().optional(),remarkPlugins:u.array(u.unknown()).optional(),rehypePlugins:u.array(u.unknown()).optional(),vitePlugins:u.array(u.unknown()).optional(),components:u.record(u.string(),u.string()).optional(),hooks:u.record(u.string(),u.unknown()).optional()}),E=u.object({title:u.union([u.string(),u.record(u.string(),u.string())]).optional(),description:u.union([u.string(),u.record(u.string(),u.string())]).optional(),logo:u.union([u.string(),u.object({dark:u.string(),light:u.string(),alt:u.string().optional(),width:u.number().optional(),height:u.number().optional()})]).optional(),navbar:u.array(u.object({label:u.union([u.string(),u.record(u.string(),u.string())]),href:u.string(),items:u.array(u.object({label:u.union([u.string(),u.record(u.string(),u.string())]),href:u.string()})).optional()})).optional(),sidebar:u.record(u.string(),u.array(u.object({text:u.string(),link:u.string()}))).optional(),sidebarGroups:u.record(u.string(),u.object({title:u.union([u.string(),u.record(u.string(),u.string())]).optional(),icon:u.string().optional()})).optional(),socialLinks:u.array(w).optional(),editLink:u.string().refine(e=>!e||e.includes(`:path`),{message:`editLink must contain ':path' placeholder if specified`}).optional(),communityHelp:u.string().url().optional(),version:u.string().max(50).optional(),githubRepo:u.string().max(100).optional(),favicon:u.string().optional(),tabs:u.array(u.object({id:u.string(),text:u.union([u.string(),u.record(u.string(),u.string())]),icon:u.string().optional()})).optional(),codeTheme:u.union([u.string(),u.object({light:u.string(),dark:u.string()})]).optional()}),D=u.union([u.string(),u.object({rules:u.array(u.object({userAgent:u.string(),allow:u.union([u.string(),u.array(u.string())]).optional(),disallow:u.union([u.string(),u.array(u.string())]).optional()})).optional(),sitemaps:u.array(u.string().url()).optional()})]),O=u.object({defaultLocale:u.string(),locales:u.union([u.record(u.string(),u.string()),u.array(u.string())]).transform(e=>Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e),localeConfigs:u.record(u.string(),u.object({label:u.string().optional(),direction:u.enum([`ltr`,`rtl`]).optional(),htmlLang:u.string().optional(),calendar:u.string().optional()})).optional()}),k=u.object({defaultVersion:u.string(),prefix:u.string().optional(),versions:u.array(u.object({label:u.string(),path:u.string()}))}),A=u.object({headers:u.record(u.string(),u.string()).optional(),enableCSP:u.boolean().optional(),customHeaders:u.record(u.string(),u.string()).optional()}),j=u.object({metatags:u.record(u.string(),u.string()).optional(),indexing:u.enum([`all`,`public`]).optional(),thumbnails:u.object({background:u.string().optional()}).optional()}),M=u.object({measurementId:u.string().min(1,`Measurement ID is required for GA4`),debug:u.boolean().optional(),anonymizeIp:u.boolean().optional(),sendPageView:u.boolean().optional(),cookieFlags:u.string().optional(),autoTrack:u.object({pageViews:u.boolean().optional(),downloads:u.boolean().optional(),externalLinks:u.boolean().optional(),search:u.boolean().optional()}).optional()}),N=u.object({tagId:u.string().min(1,`Tag ID is required for GTM`),dataLayerName:u.string().optional(),preview:u.string().optional()}),P=u.object({appId:u.string().min(1,`Algolia App ID is required`),apiKey:u.string().min(1,`Algolia API Key is required`),indexName:u.string().min(1,`Algolia Index Name is required`)}),F=u.object({ga4:M.optional(),gtm:N.optional(),algolia:P.optional()}),I=u.object({siteUrl:u.string().url().optional(),docsDir:u.string().optional(),base:u.string().optional(),theme:E.optional(),i18n:O.optional(),versions:k.optional(),plugins:u.array(T).optional(),robots:D.optional(),security:A.optional(),seo:j.optional(),integrations:F.optional(),vite:u.record(u.string(),u.unknown()).optional()});function L(e,t,n=process.cwd(),r){let i=s.resolve(n,`.boltdocs`,`generated`);l.existsSync(i)||l.mkdirSync(i,{recursive:!0});let a=e.i18n?Object.keys(e.i18n.locales):[],o=e.versions?e.versions.versions.map(e=>e.path):[],c=a.length>0?a.map(e=>`'${e}'`).join(` | `):`string`,u=o.length>0?o.map(e=>`'${e}'`).join(` | `):`string`,d=[`tsx`,`ts`,`jsx`,`js`],f=``,p=``;for(let e of d){let r=s.resolve(n,t,`mdx-components.${e}`);if(l.existsSync(r)){let e=s.join(n,t,`mdx-components`),r=s.relative(i,e).replace(/\\/g,`/`);f=`import type * as MdxComponentsModule from '${r.startsWith(`.`)?r:`./${r}`}'\n`,p=` MdxComponents: typeof MdxComponentsModule`;break}}let m=r&&r.length>0?`\ndeclare global {
7
+ namespace Boltdocs {
8
+ interface RoutePaths {
9
+ ${r.map(e=>` '${e}': void`).join(`
10
+ `)}
11
+ }
12
+ }
13
+ }`:``,h=`// This file is automatically generated by Boltdocs.
14
+ // Do not edit this file manually.
15
+
16
+ ${f}declare global {
17
+ namespace Boltdocs {
18
+ interface Types {
19
+ Locale: ${c}
20
+ Version: ${u}${p?`\n${p}`:``}
21
+ }
22
+ }
23
+ }${m}
24
+
25
+ export {}
26
+ `;l.writeFileSync(s.resolve(i,`types.d.ts`),h)}function ie(e,t=process.cwd()){let n=s.resolve(t,`.boltdocs`,`generated`);l.existsSync(n)||l.mkdirSync(n,{recursive:!0});let r={routes:Array.from(new Set(e)).sort(),timestamp:Date.now()};l.writeFileSync(s.resolve(n,`link-tree.json`),JSON.stringify(r,null,2))}function ae(e){return e}const R=[`boltdocs.config.js`,`boltdocs.config.mjs`,`boltdocs.config.ts`];async function z(e,t=process.cwd()){let n=t,i={docsDir:s.resolve(e),theme:{title:`Boltdocs`,description:`A Vite documentation framework`,navbar:[{label:`Home`,href:`/`},{label:`Documentation`,href:`/docs`}],codeTheme:{light:`github-light`,dark:`github-dark`}}},a={};for(let e of R){let t=s.resolve(n,e);if(l.existsSync(t))try{let e=await o({command:`serve`,mode:`development`},t,n);if(e){a=e.config;break}}catch(t){b(`Failed to load config from ${e}:`,t)}}let c={title:a.title,description:a.description,logo:a.logo,favicon:a.favicon,navbar:a.navbar,sidebar:a.sidebar,sidebarGroups:a.theme?.sidebarGroups,socialLinks:a.socialLinks,githubRepo:a.githubRepo,tabs:a.tabs,codeTheme:a.codeTheme,communityHelp:a.communityHelp,version:a.version,editLink:a.editLink,...a.theme||{}},u=Object.fromEntries(Object.entries(c).filter(([e,t])=>t!==void 0));u.navbar&&=u.navbar.map(e=>({label:e.label||e.text||``,href:e.href||e.link||e.to||``,items:e.items}));let d={docsDir:s.resolve(e),theme:{...i.theme,...u},i18n:a.i18n?{...a.i18n,locales:Array.isArray(a.i18n.locales)?Object.fromEntries(a.i18n.locales.map(e=>[e,e])):a.i18n.locales}:void 0,versions:a.versions,siteUrl:a.siteUrl,base:a.base,seo:a.seo,plugins:a.plugins||[],robots:a.robots,security:a.security,integrations:a.integrations,vite:a.vite},f=I.safeParse(d);if(!f.success)throw new r(`Invalid Boltdocs configuration:\n${f.error.issues.map(e=>` - ${e.path.join(`.`)}: ${e.message}`).join(`
27
+ `)}`);return f.data}const oe=a(import.meta.url);function se(e,t){let n=e.split(`-`)[0].split(`.`).map(Number),r=t.split(`-`)[0].split(`.`).map(Number);for(let e=0;e<Math.max(n.length,r.length);e++){let t=n[e]??0,i=r[e]??0;if(Number.isNaN(t)||Number.isNaN(i))return!1;if(t!==i)return t>i}return!1}async function ce(){try{let e=new AbortController,t=setTimeout(()=>e.abort(),2e3),n=await fetch(`https://registry.npmjs.org/boltdocs/latest`,{signal:e.signal,headers:{Accept:`application/vnd.npm.install-v1+json`}});return clearTimeout(t),n.ok?(await n.json()).version??null:null}catch{return null}}async function le(){try{let e=x(import.meta.url),t=s.dirname(e);for(let e=0;e<5;e++){let e=s.join(t,`package.json`);if(l.existsSync(e)){let t=JSON.parse(l.readFileSync(e,`utf-8`));if(t.name===`boltdocs`)return t.version}t=s.dirname(t)}}catch{}try{return oe(`boltdocs/package.json`).version}catch{return`0.0.0`}}async function B(){let e=``;try{e=s.join(S.homedir(),`.boltdocs`,`update-check.json`)}catch{return}let t=0;try{if(l.existsSync(e)){let n=JSON.parse(l.readFileSync(e,`utf-8`));t=Number(n.lastCheck)||0}}catch{}let n=Date.now();if(n-t<864e5)return;try{l.mkdirSync(s.dirname(e),{recursive:!0}),l.writeFileSync(e,JSON.stringify({lastCheck:n}),`utf-8`)}catch{}let r=await le();if(r===`0.0.0`)return;let i=await ce();i&&se(i,r)&&console.log(d.updateAvailable(r,i))}const V={$schema:`https://boltdocs.vercel.app/schemas/doctor-config.schema.json`,checks:{metadata:{enabled:!0,titleMin:10,titleMax:60,descriptionMin:50,required:[`title`,`description`],optional:[],validateDates:!1},links:{internal:!0,external:!1,timeout:1e4,concurrency:10,ignore:[]},i18n:{enabled:!0},performance:{enabled:!0,budgets:{maxJSBundleSize:`200kb`,maxCSSBundleSize:`30kb`,maxPageHTMLSize:`80kb`,maxImagesKB:500,maxBuildTime:3e4,maxFontCount:3}}},fix:{confirmChanges:!1,backupFiles:!1,backupPath:`.boltdocs/backups`},reporting:{format:`pretty`,outputFile:`.boltdocs/reports/doctor.json`,failOnError:!1,maxWarnings:-1},severity:{missingTranslation:`warning`,brokenLink:`high`,brokenAnchor:`warning`,largeFile:`warning`,orphanedPage:`low`,duplicateTitle:`low`,shortMetadata:`low`,missingMetadata:`warning`,malformedFrontmatter:`high`,invalidFrontmatter:`high`,budgetExceeded:`warning`},exclude:[]};function H(e,t){if(e==null)return t;if(typeof e==`number`)return e;let n=e.toLowerCase().match(/^(\d+(?:\.\d+)?)\s*(b|kb|mb|gb)?$/);if(!n)return t;let r=Number.parseFloat(n[1]),i=n[2]||`b`;return Math.round(r*({b:1,kb:1024,mb:1024*1024,gb:1024*1024*1024}[i]||1))}function U(e,t,n){return e.doctorConfig.severity[t]||n}async function ue(e,t){l.existsSync(t)||l.mkdirSync(t,{recursive:!0});let n=s.basename(e),r=new Date().toISOString().replace(/[:.]/g,`-`),i=s.join(t,`${n}.${r}.bak`);l.copyFileSync(e,i)}const W=new Map;function G(e){let n=W.get(e);if(n)return n;let r=(async()=>{let n=await t(e,!1);return{raw:n.raw,data:n.data,content:n.content}})();return W.set(e,r),r}const K=new Map;function q(e){if(K.has(e))return K.get(e);let t=!1;try{t=l.existsSync(e)&&l.statSync(e).isFile()}catch{t=!1}return K.set(e,t),t}async function J(e){let t=s.resolve(e,`doctor.json`);if(l.existsSync(t))try{let e=JSON.parse(l.readFileSync(t,`utf-8`));return{...V,...e,checks:{...V.checks,...e.checks,metadata:{...V.checks.metadata,...e.checks?.metadata},links:{...V.checks.links,...e.checks?.links},i18n:{...V.checks.i18n,...e.checks?.i18n},performance:{...V.checks.performance,...e.checks?.performance,budgets:{...V.checks.performance?.budgets,...e.checks?.performance?.budgets}}},fix:{...V.fix,...e.fix},reporting:{...V.reporting,...e.reporting},severity:{...V.severity,...e.severity},exclude:[...V.exclude,...e.exclude||[]]}}catch(e){b(`Failed to parse doctor.json: ${e}`)}return V}async function Y(t,n=process.cwd(),r,i){let a=s.resolve(n,`.boltdocs`,`generated`);l.existsSync(a)||l.mkdirSync(a,{recursive:!0});let o=i;o||=await new c().withFullPaths().filter(e=>e.endsWith(`.md`)||e.endsWith(`.mdx`)).crawl(t).withPromise();let u=r?.base||`/docs`,d=[];for(let n=0;n<o.length;n+=100){let r=o.slice(n,n+100),i=await Promise.all(r.map(async n=>{let r=s.isAbsolute(n)?n:s.resolve(t,n),i=s.relative(t,r),{data:a}=await G(r),o;return o=a.permalink?a.permalink.startsWith(`/`)?a.permalink:`/${a.permalink}`:e(i),u===`/`?o:(u.endsWith(`/`)?u:u+`/`)+(o.startsWith(`/`)?o.substring(1):o)}));d.push(...i)}d.includes(u)||d.push(u);let f={routes:Array.from(new Set(d)).sort(),timestamp:Date.now()};return l.writeFileSync(s.resolve(a,`link-tree.json`),JSON.stringify(f,null,2)),f}function de(e,t){if(e===t)return 1;if(!e||!t)return 0;let n=e.split(`/`).filter(Boolean),r=t.split(`/`).filter(Boolean),i=n[n.length-1]||``,a=r[r.length-1]||``;if(i===a){let e=0;for(let t of n)r.includes(t)&&e++;return e>=2?.99:.9}if(i.length>3&&a.length>3&&(a.startsWith(i)||i.startsWith(a))&&Math.min(i.length,a.length)/Math.max(i.length,a.length)>.5)return .88;let o=1-C(i,a)/Math.max(i.length,a.length);return o>.8?o*.95:1-C(e,t)/Math.max(e.length,t.length)}const X=new Map;function Z(e,t){if(X.has(e))return X.get(e);let n=e.length,r=``,i=0;for(let a of t){if(a===e)continue;let t=a.length,o=Math.max(n,t);if(o===0)continue;let s=1-Math.abs(n-t)/o;if(s<=.8&&s<=i)continue;let c=de(e,a);c>i&&(i=c,r=a)}let a={bestMatch:r,similarity:i};return X.set(e,a),a}async function Q(e){let t=[];if(!e.doctorConfig.checks.metadata.enabled)return t;let{titleMin:r,titleMax:a,descriptionMin:o}=e.doctorConfig.checks.metadata,c=new Map;for(let l of e.files){let u=n(s.relative(e.docsDir,l));try{let{raw:n,data:s}=await G(l);if(n.trim().startsWith(`---`)&&n.split(`---`).length>=3&&Object.keys(s).length===0){let n=U(e,`malformedFrontmatter`,`high`);n!==`off`&&t.push({file:u,level:n,message:`Malformed frontmatter (YAML parsing failed).`,suggestion:`Check your YAML syntax for indentation or unquoted special characters.`})}let d=i.safeParse(s);if(!d.success){let n=U(e,`invalidFrontmatter`,`high`);if(n!==`off`)for(let e of d.error.issues)t.push({file:u,level:n,message:`Invalid frontmatter field "${e.path.join(`.`)}": ${e.message}`,suggestion:`Ensure the field follows the correct type.`})}let f=Array.from(new Set([`title`,...e.doctorConfig.checks.metadata.required]));for(let n of f)if(s[n]===void 0){let r=U(e,`missingMetadata`,`warning`);r!==`off`&&t.push({file:u,level:r,message:`Missing required frontmatter field: "${n}".`,suggestion:`Add the "${n}" field to your frontmatter.`})}if(e.doctorConfig.checks.metadata.validateDates){let n=[`date`,`lastUpdated`,...e.doctorConfig.checks.metadata.optional.filter(e=>e.toLowerCase().includes(`date`))];for(let r of n)if(s[r]&&Number.isNaN(Date.parse(String(s[r])))){let n=U(e,`invalidFrontmatter`,`high`);n!==`off`&&t.push({file:u,level:n,message:`Invalid date format in field "${r}": "${s[r]}".`,suggestion:`Use a valid ISO date format (e.g., YYYY-MM-DD).`})}}if(s.title){let n=String(s.title);if(n.length<r){let i=U(e,`shortMetadata`,`low`);i!==`off`&&t.push({file:u,level:i,message:`Title is too short (${n.length} chars).`,suggestion:`Titles should be at least ${r} characters for better SEO.`})}else if(n.length>a){let r=U(e,`shortMetadata`,`low`);r!==`off`&&t.push({file:u,level:r,message:`Title is too long (${n.length} chars).`,suggestion:`Titles should be under ${a} characters.`})}let i=c.get(n)||[];i.push(u),c.set(n,i)}if(s.description&&String(s.description).length<o){let n=U(e,`shortMetadata`,`low`);n!==`off`&&t.push({file:u,level:n,message:`Description is very short.`,suggestion:`Descriptions should ideally be at least ${o} characters.`})}}catch(n){if(n instanceof Error){let r=U(e,`malformedFrontmatter`,`high`);r!==`off`&&t.push({file:u,level:r,message:`Malformed frontmatter (YAML error): ${n.message}`,suggestion:`Check your YAML syntax for indentation or unquoted special characters.`})}}}for(let[n,r]of c.entries())if(r.length>1){let i=U(e,`duplicateTitle`,`low`);if(i!==`off`)for(let e of r)t.push({file:e,level:i,message:`Duplicate title found: "${n}"`,suggestion:`Ensure each page has a unique title. Also used in: ${r.filter(t=>t!==e).join(`, `)}`})}return t}async function $(e){let t=[],{internal:r,external:i,ignore:a,timeout:o,concurrency:c}=e.doctorConfig.checks.links;if(!r&&!i&&!e.options.checkExternal)return t;let u=/(?:\[.*?\]\((.*?)\))|(?:href=["']([^"']+)["'])/g,d=new Set,f=5e5;for(let o of e.files){let c=n(s.relative(e.docsDir,o)),{content:p}=await G(o),m=[...(p.length>f?p.slice(0,f):p).replace(/```[\s\S]*?```/g,``).replace(/`[^`\n]*`/g,``).matchAll(u)];for(let n of m){let u=n[1]||n[2],f=!!n[1];if(!u||a.some(e=>u.includes(e)))continue;if(/^https?:\/\//i.test(u)){(i||e.options.checkExternal)&&d.add({url:u,file:o});continue}if(!r||/^(mailto|tel|#)/i.test(u))continue;let p;try{p=decodeURIComponent(u.split(`#`)[0].split(`?`)[0])}catch{p=u.split(`#`)[0].split(`?`)[0]}if(!p)continue;let m=!1,h=``;if(p.startsWith(`/`))if(e.routeIndex.has(p)||e.routeIndexWithSlash.has(p)||e.routeIndexWithoutSlash.has(p))m=!0;else{let t=e.basePrefix+(p.startsWith(`/`)?p:`/`+p);if(e.routeIndex.has(t)||e.routeIndexWithSlash.has(t))m=!1,h=t;else{let t=e.config.base!==`/`&&p.startsWith(e.config.base||`/`)?p.substring((e.config.base||`/`).length):p,n=t.startsWith(`/`)?t.substring(1):t;h=s.join(e.docsDir,n),m=[``,`.md`,`.mdx`,`/index.md`,`/index.mdx`].some(e=>q(h+e))}}else h=s.resolve(s.dirname(o),p),m=[``,`.md`,`.mdx`,`/index.md`,`/index.mdx`].some(e=>q(h+e));if(!m){let{bestMatch:n,similarity:r}=Z(p,e.linkTree.routes),i=!1,a=e.basePrefix+(p.startsWith(`/`)?p:`/`+p);(e.routeIndex.has(a)||e.routeIndexWithSlash.has(a))&&(n=a,r=1,i=!0);let s=r>.6||i,d=r>.75&&n!==p||i,m=U(e,`brokenLink`,`high`);m!==`off`&&t.push({file:c,level:m,message:`Broken internal link: "${u}"`,suggestion:s?`Did you mean "${n}"?`:`Ensure the target exists or check for typos.`,fix:d?async()=>{let e=u.includes(`#`)?`#`+u.split(`#`)[1]:``,t=f?`(${u})`:`href="${u}"`,r=f?`(${n}${e})`:`href="${n}${e}"`,i=l.readFileSync(o,`utf-8`).replace(t,r);l.writeFileSync(o,i),W.delete(o)}:void 0})}}}if(d.size>0){v(p.gray(`Verifying ${d.size} external links...`));let r=new Map;for(let e of d)r.has(e.url)||r.set(e.url,[]),r.get(e.url).push(e.file);let i=async e=>{try{let t=new AbortController,n=setTimeout(()=>t.abort(),o),r=await fetch(e,{method:`HEAD`,signal:t.signal,headers:{"User-Agent":`boltdocs-doctor/1.0`}});return clearTimeout(n),!r.ok&&r.status!==404?{url:e,ok:(await fetch(e,{method:`GET`,signal:t.signal,headers:{"User-Agent":`boltdocs-doctor/1.0`}})).ok}:{url:e,ok:r.ok}}catch(t){return{url:e,ok:!1,error:t.message}}},a=Array.from(r.keys()),l=[];for(let e=0;e<a.length;e+=c){let t=a.slice(e,e+c),n=await Promise.allSettled(t.map(i));l.push(...n.map(e=>e.status===`fulfilled`?e.value:{url:`unknown`,ok:!1,error:e.reason}))}for(let i of l)if(!i.ok){let a=U(e,`brokenLink`,`warning`);if(a!==`off`){let o=r.get(i.url)||[];for(let r of o)t.push({file:n(s.relative(e.docsDir,r)),level:a,message:`Broken external link: "${i.url}"`,suggestion:`Verify the URL or update it if it's permanently down. Error: ${i.error||`Status >= 400`}`})}}}return t}async function fe(e){let t=[];if(!e.doctorConfig.checks.i18n.enabled||!e.config.i18n)return t;let{defaultLocale:r,locales:i}=e.config.i18n,a=Object.keys(i),o=a.filter(e=>e!==r);for(let i of e.files){let c=n(s.relative(e.docsDir,i)),u=c.split(`/`),d=u[0];if(d===r){let n=u.slice(1).join(`/`);for(let r of o){let a=s.join(e.docsDir,r,n);if(!q(a)){let o=U(e,`missingTranslation`,`warning`);o!==`off`&&t.push({file:c,level:o,message:`Missing translation for locale "${r}"`,suggestion:`Create a version at "${r}/${n}".`,fix:async()=>{let e=s.dirname(a);l.existsSync(e)||l.mkdirSync(e,{recursive:!0}),l.copyFileSync(i,a)}})}}}else if(a.includes(d)){let n=u.slice(1).join(`/`);if(!q(s.join(e.docsDir,r,n))){let a=U(e,`missingTranslation`,`low`);a!==`off`&&t.push({file:c,level:a,message:`Orphaned translation (source missing in "${r}")`,suggestion:`Remove this file or create the source at "${r}/${n}".`,fix:async()=>{l.unlinkSync(i)}})}}}return t}async function pe(e){let t=[];if(!e.config.theme.sidebar)return t;let n=new Set,r=e.config.theme.sidebar;for(let[i,a]of Object.entries(r))for(let r of a){if(!r.text){let n=U(e,`invalidFrontmatter`,`warning`);n!==`off`&&t.push({file:`boltdocs.config.ts`,level:n,message:`Sidebar item in group "${i}" is missing a label.`,suggestion:`Add a "text" property to the sidebar item.`})}if(r.link&&(n.add(r.link),!e.routeIndex.has(r.link))){let{bestMatch:n,similarity:i}=Z(r.link,e.linkTree.routes),a=i>.6,o=U(e,`brokenLink`,`high`);o!==`off`&&t.push({file:`boltdocs.config.ts`,level:o,message:`Broken sidebar link: "${r.link}"`,suggestion:a?`Did you mean "${n}"?`:`Ensure the route exists and is correctly formatted.`})}}for(let r of e.linkTree.routes)if(!(r===`/`||r===``)&&!n.has(r)){let n=U(e,`orphanedPage`,`low`);n!==`off`&&t.push({file:`Sidebar`,level:n,message:`Orphaned page found: "${r}" is not linked in the sidebar.`,suggestion:`Consider adding it to the sidebar for better discoverability.`})}return t}async function me(e){let t=[],n=e.doctorConfig.checks.performance;if(!n?.enabled)return t;let r=s.resolve(e.root,`.boltdocs`,`reports`,`performance.json`);if(!l.existsSync(r))return t.push({file:`(build)`,level:U(e,`budgetExceeded`,`warning`),message:"Performance metrics not found. Run `boltdocs build` first."}),t;let i;try{i=JSON.parse(l.readFileSync(r,`utf-8`))}catch{return t.push({file:`(build)`,level:U(e,`budgetExceeded`,`warning`),message:`Failed to parse performance metrics file.`}),t}let a=n.budgets,o=U(e,`budgetExceeded`,`warning`),c=H(a?.maxJSBundleSize,1/0),u=H(a?.maxCSSBundleSize,1/0),d=H(a?.maxPageHTMLSize,1/0),f=a?.maxImagesKB??1/0,p=a?.maxBuildTime??1/0,m=a?.maxFontCount??1/0;if(c!==1/0&&i.totalJSBundleSize>c){let e=(i.totalJSBundleSize/1024).toFixed(0),n=(c/1024).toFixed(0);t.push({file:`(build)`,level:o,message:`JS bundle size exceeds budget: ${e}kb > ${n}kb`,suggestion:`Code-split large dependencies or lazy-load route components.`})}if(u!==1/0&&i.totalCSSBundleSize>u){let e=(i.totalCSSBundleSize/1024).toFixed(0),n=(u/1024).toFixed(0);t.push({file:`(build)`,level:o,message:`CSS bundle size exceeds budget: ${e}kb > ${n}kb`,suggestion:`Remove unused styles or split CSS by route.`})}if(d!==1/0){for(let e of i.pages)if(e.htmlSize>d){let n=(e.htmlSize/1024).toFixed(0),r=(d/1024).toFixed(0);t.push({file:e.route,level:o,message:`Page HTML size exceeds budget: ${n}kb > ${r}kb`,suggestion:`Reduce the amount of inline content or split into sub-pages.`})}}let h=f*1024;if(f!==1/0&&i.totalImagesSize>h){let e=(i.totalImagesSize/1024).toFixed(0);t.push({file:`(build)`,level:o,message:`Image assets exceed budget: ${e}kb > ${f}kb`,suggestion:`Optimize images with lossy compression or use next-gen formats (webp/avif).`})}if(p!==1/0&&i.buildTime>p){let e=(i.buildTime/1e3).toFixed(1),n=(p/1e3).toFixed(1);t.push({file:`(build)`,level:o,message:`Build time exceeds budget: ${e}s > ${n}s`,suggestion:"Check for large unoptimized assets or increase `concurrency` in SSG options."})}return m!==1/0&&i.fontCount>m&&t.push({file:`(build)`,level:o,message:`Font files exceed budget: ${i.fontCount} > ${m}`,suggestion:`Reduce the number of font families or use variable fonts.`}),t}async function he(e){let t=s.resolve(e,`doctor.json`);if(l.existsSync(t)){b(`"doctor.json" already exists at ${e}.`);return}try{l.writeFileSync(t,JSON.stringify(V,null,2)),y(`Created "doctor.json" with default configuration.`)}catch(e){_(`Failed to create "doctor.json": ${e}`)}}async function ge(e=process.cwd(),t={}){if(t.init){await he(e);return}B();try{let n=await J(e),{format:r}=n.reporting,i=performance.now(),a=await z(`docs`,e),o=s.resolve(e,`docs`);l.existsSync(o)||(r===`pretty`&&_(`Docs dir not found at ${o}`),process.exit(1)),r===`pretty`&&console.log(g(`✦ DOCTOR — Documentation Health Check`,[` ${p.dim(`Docs dir:`)} ${o}`,` ${p.dim(`Reports:`)} ${e}/.boltdocs/reports/`])),r===`pretty`&&v(p.dim(`🔍 Discovering files and routes...`));let u=re(n.exclude||[]),d=await new c().withFullPaths().filter(e=>{if(!(e.endsWith(`.md`)||e.endsWith(`.mdx`)))return!1;let t=s.relative(o,e).replace(/\\/g,`/`),n=t.split(`/`).some(e=>e.startsWith(`_`)&&e!==`_index.md`&&e!==`_index.mdx`);return!u(t)&&!n}).crawl(o).withPromise();for(let e of d)K.set(e,!0);let b=await Y(o,e,a,d),x=a.base||`/`,S=x===`/`?``:x.endsWith(`/`)?x.slice(0,-1):x,C={root:e,docsDir:o,config:a,doctorConfig:n,linkTree:b,files:d,options:t,routeIndex:new Set(b.routes),routeIndexWithSlash:new Set(b.routes.map(e=>e.endsWith(`/`)?e:e+`/`)),routeIndexWithoutSlash:new Set(b.routes.map(e=>e.endsWith(`/`)?e.slice(0,-1):e)),basePrefix:S};r===`pretty`&&v(p.dim(`🧪 Running diagnostic checks in parallel...`));let w=[Q(C),$(C),fe(C),pe(C)];t.budget&&w.push(me(C));let[T,E,D,O,...k]=await Promise.all(w),A=t.budget?k[0]:[],j=[...T,...E,...D,...O,...A];if(r===`pretty`){let e=[{label:`Metadata checks ${T.length>0?`— ${T.length} issue${T.length===1?``:`s`}`:`— OK`}`,done:T.length===0},{label:`Link checks ${E.length>0?`— ${E.length} issue${E.length===1?``:`s`}`:`— OK`}`,done:E.length===0},{label:`i18n checks ${D.length>0?`— ${D.length} issue${D.length===1?``:`s`}`:`— OK`}`,done:D.length===0},{label:`Sidebar checks ${O.length>0?`— ${O.length} issue${O.length===1?``:`s`}`:`— OK`}`,done:O.length===0}];t.budget&&e.push({label:`Performance budget ${A.length>0?`— ${A.length} issue${A.length===1?``:`s`}`:`— OK`}`,done:A.length===0}),console.log(`\n${ne(e)}`)}let M=0;if(t.fix){for(let e of j)if(e.fix){if(C.doctorConfig.fix.confirmChanges&&!await m(`Fix issue in "${e.file}": ${e.message}?`))continue;if(C.doctorConfig.fix.backupFiles){let t=s.resolve(C.docsDir,e.file);l.existsSync(t)&&await ue(t,s.resolve(C.root,C.doctorConfig.fix.backupPath))}await e.fix(),M++}}let N=((performance.now()-i)/1e3).toFixed(2),P=j.filter(e=>e.level===`high`).length,F=j.filter(e=>e.level===`warning`).length,I=j.filter(e=>e.level===`low`).length,L={summary:{total:j.length,high:P,warning:F,low:I,fixed:M,duration:N},issues:j.map(e=>({...e,fix:void 0}))};if(n.reporting.outputFile){let t=s.resolve(e,n.reporting.outputFile);l.existsSync(s.dirname(t))||l.mkdirSync(s.dirname(t),{recursive:!0}),l.writeFileSync(t,JSON.stringify(L,null,2))}if(r===`json`)console.log(JSON.stringify(L,null,2));else if(r===`pretty`){let e=j.reduce((e,t)=>(e[t.file]||(e[t.file]=[]),e[t.file].push(t),e),{});if(j.length>0){h();for(let[n,r]of Object.entries(e)){let e=[];for(let n of r){let r=n.level===`high`?`❌`:n.level===`warning`?`⚠️`:`ℹ️`,i=n.level===`high`?p.red:n.level===`warning`?p.yellow:p.blue;e.push(`${r} ${i(n.level.toUpperCase())}: ${n.message}`),n.suggestion&&e.push(` ${p.dim(`💡 ${n.suggestion}`)}`),t.fix&&n.fix&&e.push(` ${p.green(`✅ Fixed automatically`)}`)}console.log(`\n${te(`📄 ${n}`,e)}`)}h()}if(j.length===0)console.log(ee(`✨ Documentation Health Check`,[` Everything looks perfect!`,` Your documentation is in great shape.`,``,` ${p.dim(`Scanned ${d.length} file${d.length===1?``:`s`} in ${N}s`)}`]));else{let e=[];P>0&&e.push(p.red(`${P} Critical Error${P===1?``:`s`}`)),F>0&&e.push(p.yellow(`${F} Warning${F===1?``:`s`}`)),I>0&&e.push(p.blue(`${I} Improvement${I===1?``:`s`}`));let t=[...f(e).split(`
28
+ `).map(e=>e.trimStart()),``,p.dim(`Scanned ${d.length} file${d.length===1?``:`s`} in ${N}s`)];console.log(`\n${g(`Diagnosis Results`,t)}\n`),M>0&&y(`Successfully fixed ${M} issues automatically!`),P>0?_(`Please fix the critical errors before building for production.`):y(`No critical issues found. You are ready to go!`)}}n.reporting.failOnError&&P>0&&process.exit(1),n.reporting.maxWarnings!==-1&&F>n.reporting.maxWarnings&&(r===`pretty`&&_(`Failed: Too many warnings (${F} > ${n.reporting.maxWarnings})`),process.exit(1))}catch(e){_(`Doctor failed: ${e}`),process.exit(1)}}export{T as _,Q as a,Y as c,B as d,R as f,ie as g,L as h,$ as i,J as l,ae as m,he as n,me as o,z as p,fe as r,pe as s,ge as t,V as u};
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Boltdocs - https://boltdocs.vercel.app
3
+ * Copyright (c) 2026 Jesus Alcala
4
+ * Licensed under the MIT License.
5
+ */
6
+ const e=require(`./chunk-CU-zTemE.cjs`),t=require(`./utils-Cjmx1hhk.cjs`);let n=require(`vite`),r=require(`node:path`);r=e.t(r);let i=require(`fdir`),a=require(`node:fs`);a=e.t(a);let o=require(`zod`),s=require(`@bdocs/dui`);s=e.t(s);let c=require(`node:module`),l=require(`picomatch`);l=e.t(l);let u=require(`node:os`);u=e.t(u);let d=require(`node:url`),f=require(`fastest-levenshtein`);const p=o.z.object({icon:o.z.string().max(50),link:o.z.string().url()});o.z.object({text:o.z.string().max(2e3).optional()});const m=o.z.object({name:o.z.string(),enforce:o.z.enum([`pre`,`post`]).optional(),version:o.z.string().optional(),boltdocsVersion:o.z.string().optional(),remarkPlugins:o.z.array(o.z.unknown()).optional(),rehypePlugins:o.z.array(o.z.unknown()).optional(),vitePlugins:o.z.array(o.z.unknown()).optional(),components:o.z.record(o.z.string(),o.z.string()).optional(),hooks:o.z.record(o.z.string(),o.z.unknown()).optional()}),h=o.z.object({title:o.z.union([o.z.string(),o.z.record(o.z.string(),o.z.string())]).optional(),description:o.z.union([o.z.string(),o.z.record(o.z.string(),o.z.string())]).optional(),logo:o.z.union([o.z.string(),o.z.object({dark:o.z.string(),light:o.z.string(),alt:o.z.string().optional(),width:o.z.number().optional(),height:o.z.number().optional()})]).optional(),navbar:o.z.array(o.z.object({label:o.z.union([o.z.string(),o.z.record(o.z.string(),o.z.string())]),href:o.z.string(),items:o.z.array(o.z.object({label:o.z.union([o.z.string(),o.z.record(o.z.string(),o.z.string())]),href:o.z.string()})).optional()})).optional(),sidebar:o.z.record(o.z.string(),o.z.array(o.z.object({text:o.z.string(),link:o.z.string()}))).optional(),sidebarGroups:o.z.record(o.z.string(),o.z.object({title:o.z.union([o.z.string(),o.z.record(o.z.string(),o.z.string())]).optional(),icon:o.z.string().optional()})).optional(),socialLinks:o.z.array(p).optional(),editLink:o.z.string().refine(e=>!e||e.includes(`:path`),{message:`editLink must contain ':path' placeholder if specified`}).optional(),communityHelp:o.z.string().url().optional(),version:o.z.string().max(50).optional(),githubRepo:o.z.string().max(100).optional(),favicon:o.z.string().optional(),tabs:o.z.array(o.z.object({id:o.z.string(),text:o.z.union([o.z.string(),o.z.record(o.z.string(),o.z.string())]),icon:o.z.string().optional()})).optional(),codeTheme:o.z.union([o.z.string(),o.z.object({light:o.z.string(),dark:o.z.string()})]).optional()}),g=o.z.union([o.z.string(),o.z.object({rules:o.z.array(o.z.object({userAgent:o.z.string(),allow:o.z.union([o.z.string(),o.z.array(o.z.string())]).optional(),disallow:o.z.union([o.z.string(),o.z.array(o.z.string())]).optional()})).optional(),sitemaps:o.z.array(o.z.string().url()).optional()})]),_=o.z.object({defaultLocale:o.z.string(),locales:o.z.union([o.z.record(o.z.string(),o.z.string()),o.z.array(o.z.string())]).transform(e=>Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e),localeConfigs:o.z.record(o.z.string(),o.z.object({label:o.z.string().optional(),direction:o.z.enum([`ltr`,`rtl`]).optional(),htmlLang:o.z.string().optional(),calendar:o.z.string().optional()})).optional()}),v=o.z.object({defaultVersion:o.z.string(),prefix:o.z.string().optional(),versions:o.z.array(o.z.object({label:o.z.string(),path:o.z.string()}))}),y=o.z.object({headers:o.z.record(o.z.string(),o.z.string()).optional(),enableCSP:o.z.boolean().optional(),customHeaders:o.z.record(o.z.string(),o.z.string()).optional()}),b=o.z.object({metatags:o.z.record(o.z.string(),o.z.string()).optional(),indexing:o.z.enum([`all`,`public`]).optional(),thumbnails:o.z.object({background:o.z.string().optional()}).optional()}),x=o.z.object({measurementId:o.z.string().min(1,`Measurement ID is required for GA4`),debug:o.z.boolean().optional(),anonymizeIp:o.z.boolean().optional(),sendPageView:o.z.boolean().optional(),cookieFlags:o.z.string().optional(),autoTrack:o.z.object({pageViews:o.z.boolean().optional(),downloads:o.z.boolean().optional(),externalLinks:o.z.boolean().optional(),search:o.z.boolean().optional()}).optional()}),S=o.z.object({tagId:o.z.string().min(1,`Tag ID is required for GTM`),dataLayerName:o.z.string().optional(),preview:o.z.string().optional()}),C=o.z.object({appId:o.z.string().min(1,`Algolia App ID is required`),apiKey:o.z.string().min(1,`Algolia API Key is required`),indexName:o.z.string().min(1,`Algolia Index Name is required`)}),w=o.z.object({ga4:x.optional(),gtm:S.optional(),algolia:C.optional()}),T=o.z.object({siteUrl:o.z.string().url().optional(),docsDir:o.z.string().optional(),base:o.z.string().optional(),theme:h.optional(),i18n:_.optional(),versions:v.optional(),plugins:o.z.array(m).optional(),robots:g.optional(),security:y.optional(),seo:b.optional(),integrations:w.optional(),vite:o.z.record(o.z.string(),o.z.unknown()).optional()});function E(e,t,n=process.cwd(),i){let o=r.default.resolve(n,`.boltdocs`,`generated`);a.default.existsSync(o)||a.default.mkdirSync(o,{recursive:!0});let s=e.i18n?Object.keys(e.i18n.locales):[],c=e.versions?e.versions.versions.map(e=>e.path):[],l=s.length>0?s.map(e=>`'${e}'`).join(` | `):`string`,u=c.length>0?c.map(e=>`'${e}'`).join(` | `):`string`,d=[`tsx`,`ts`,`jsx`,`js`],f=``,p=``;for(let e of d){let i=r.default.resolve(n,t,`mdx-components.${e}`);if(a.default.existsSync(i)){let e=r.default.join(n,t,`mdx-components`),i=r.default.relative(o,e).replace(/\\/g,`/`);f=`import type * as MdxComponentsModule from '${i.startsWith(`.`)?i:`./${i}`}'\n`,p=` MdxComponents: typeof MdxComponentsModule`;break}}let m=i&&i.length>0?`\ndeclare global {
7
+ namespace Boltdocs {
8
+ interface RoutePaths {
9
+ ${i.map(e=>` '${e}': void`).join(`
10
+ `)}
11
+ }
12
+ }
13
+ }`:``,h=`// This file is automatically generated by Boltdocs.
14
+ // Do not edit this file manually.
15
+
16
+ ${f}declare global {
17
+ namespace Boltdocs {
18
+ interface Types {
19
+ Locale: ${l}
20
+ Version: ${u}${p?`\n${p}`:``}
21
+ }
22
+ }
23
+ }${m}
24
+
25
+ export {}
26
+ `;a.default.writeFileSync(r.default.resolve(o,`types.d.ts`),h)}function D(e,t=process.cwd()){let n=r.default.resolve(t,`.boltdocs`,`generated`);a.default.existsSync(n)||a.default.mkdirSync(n,{recursive:!0});let i={routes:Array.from(new Set(e)).sort(),timestamp:Date.now()};a.default.writeFileSync(r.default.resolve(n,`link-tree.json`),JSON.stringify(i,null,2))}function O(e){return e}const k=[`boltdocs.config.js`,`boltdocs.config.mjs`,`boltdocs.config.ts`];async function A(e,i=process.cwd()){let o=i,c={docsDir:r.default.resolve(e),theme:{title:`Boltdocs`,description:`A Vite documentation framework`,navbar:[{label:`Home`,href:`/`},{label:`Documentation`,href:`/docs`}],codeTheme:{light:`github-light`,dark:`github-dark`}}},l={};for(let e of k){let t=r.default.resolve(o,e);if(a.default.existsSync(t))try{let e=await(0,n.loadConfigFromFile)({command:`serve`,mode:`development`},t,o);if(e){l=e.config;break}}catch(t){(0,s.warn)(`Failed to load config from ${e}:`,t)}}let u={title:l.title,description:l.description,logo:l.logo,favicon:l.favicon,navbar:l.navbar,sidebar:l.sidebar,sidebarGroups:l.theme?.sidebarGroups,socialLinks:l.socialLinks,githubRepo:l.githubRepo,tabs:l.tabs,codeTheme:l.codeTheme,communityHelp:l.communityHelp,version:l.version,editLink:l.editLink,...l.theme||{}},d=Object.fromEntries(Object.entries(u).filter(([e,t])=>t!==void 0));d.navbar&&=d.navbar.map(e=>({label:e.label||e.text||``,href:e.href||e.link||e.to||``,items:e.items}));let f={docsDir:r.default.resolve(e),theme:{...c.theme,...d},i18n:l.i18n?{...l.i18n,locales:Array.isArray(l.i18n.locales)?Object.fromEntries(l.i18n.locales.map(e=>[e,e])):l.i18n.locales}:void 0,versions:l.versions,siteUrl:l.siteUrl,base:l.base,seo:l.seo,plugins:l.plugins||[],robots:l.robots,security:l.security,integrations:l.integrations,vite:l.vite},p=T.safeParse(f);if(!p.success)throw new t.v(`Invalid Boltdocs configuration:\n${p.error.issues.map(e=>` - ${e.path.join(`.`)}: ${e.message}`).join(`
27
+ `)}`);return p.data}const j=(0,c.createRequire)(require(`url`).pathToFileURL(__filename).href);function M(e,t){let n=e.split(`-`)[0].split(`.`).map(Number),r=t.split(`-`)[0].split(`.`).map(Number);for(let e=0;e<Math.max(n.length,r.length);e++){let t=n[e]??0,i=r[e]??0;if(Number.isNaN(t)||Number.isNaN(i))return!1;if(t!==i)return t>i}return!1}async function ee(){try{let e=new AbortController,t=setTimeout(()=>e.abort(),2e3),n=await fetch(`https://registry.npmjs.org/boltdocs/latest`,{signal:e.signal,headers:{Accept:`application/vnd.npm.install-v1+json`}});return clearTimeout(t),n.ok?(await n.json()).version??null:null}catch{return null}}async function N(){try{let e=(0,d.fileURLToPath)(require(`url`).pathToFileURL(__filename).href),t=r.default.dirname(e);for(let e=0;e<5;e++){let e=r.default.join(t,`package.json`);if(a.default.existsSync(e)){let t=JSON.parse(a.default.readFileSync(e,`utf-8`));if(t.name===`boltdocs`)return t.version}t=r.default.dirname(t)}}catch{}try{return j(`boltdocs/package.json`).version}catch{return`0.0.0`}}async function P(){let e=``;try{e=r.default.join(u.default.homedir(),`.boltdocs`,`update-check.json`)}catch{return}let t=0;try{if(a.default.existsSync(e)){let n=JSON.parse(a.default.readFileSync(e,`utf-8`));t=Number(n.lastCheck)||0}}catch{}let n=Date.now();if(n-t<864e5)return;try{a.default.mkdirSync(r.default.dirname(e),{recursive:!0}),a.default.writeFileSync(e,JSON.stringify({lastCheck:n}),`utf-8`)}catch{}let i=await N();if(i===`0.0.0`)return;let o=await ee();o&&M(o,i)&&console.log(s.updateAvailable(i,o))}const F={$schema:`https://boltdocs.vercel.app/schemas/doctor-config.schema.json`,checks:{metadata:{enabled:!0,titleMin:10,titleMax:60,descriptionMin:50,required:[`title`,`description`],optional:[],validateDates:!1},links:{internal:!0,external:!1,timeout:1e4,concurrency:10,ignore:[]},i18n:{enabled:!0},performance:{enabled:!0,budgets:{maxJSBundleSize:`200kb`,maxCSSBundleSize:`30kb`,maxPageHTMLSize:`80kb`,maxImagesKB:500,maxBuildTime:3e4,maxFontCount:3}}},fix:{confirmChanges:!1,backupFiles:!1,backupPath:`.boltdocs/backups`},reporting:{format:`pretty`,outputFile:`.boltdocs/reports/doctor.json`,failOnError:!1,maxWarnings:-1},severity:{missingTranslation:`warning`,brokenLink:`high`,brokenAnchor:`warning`,largeFile:`warning`,orphanedPage:`low`,duplicateTitle:`low`,shortMetadata:`low`,missingMetadata:`warning`,malformedFrontmatter:`high`,invalidFrontmatter:`high`,budgetExceeded:`warning`},exclude:[]};function I(e,t){if(e==null)return t;if(typeof e==`number`)return e;let n=e.toLowerCase().match(/^(\d+(?:\.\d+)?)\s*(b|kb|mb|gb)?$/);if(!n)return t;let r=Number.parseFloat(n[1]),i=n[2]||`b`;return Math.round(r*({b:1,kb:1024,mb:1024*1024,gb:1024*1024*1024}[i]||1))}function L(e,t,n){return e.doctorConfig.severity[t]||n}async function R(e,t){a.default.existsSync(t)||a.default.mkdirSync(t,{recursive:!0});let n=r.default.basename(e),i=new Date().toISOString().replace(/[:.]/g,`-`),o=r.default.join(t,`${n}.${i}.bak`);a.default.copyFileSync(e,o)}const z=new Map;function B(e){let n=z.get(e);if(n)return n;let r=(async()=>{let n=await t.d(e,!1);return{raw:n.raw,data:n.data,content:n.content}})();return z.set(e,r),r}const V=new Map;function H(e){if(V.has(e))return V.get(e);let t=!1;try{t=a.default.existsSync(e)&&a.default.statSync(e).isFile()}catch{t=!1}return V.set(e,t),t}async function U(e){let t=r.default.resolve(e,`doctor.json`);if(a.default.existsSync(t))try{let e=JSON.parse(a.default.readFileSync(t,`utf-8`));return{...F,...e,checks:{...F.checks,...e.checks,metadata:{...F.checks.metadata,...e.checks?.metadata},links:{...F.checks.links,...e.checks?.links},i18n:{...F.checks.i18n,...e.checks?.i18n},performance:{...F.checks.performance,...e.checks?.performance,budgets:{...F.checks.performance?.budgets,...e.checks?.performance?.budgets}}},fix:{...F.fix,...e.fix},reporting:{...F.reporting,...e.reporting},severity:{...F.severity,...e.severity},exclude:[...F.exclude,...e.exclude||[]]}}catch(e){(0,s.warn)(`Failed to parse doctor.json: ${e}`)}return F}async function W(e,n=process.cwd(),o,s){let c=r.default.resolve(n,`.boltdocs`,`generated`);a.default.existsSync(c)||a.default.mkdirSync(c,{recursive:!0});let l=s;l||=await new i.fdir().withFullPaths().filter(e=>e.endsWith(`.md`)||e.endsWith(`.mdx`)).crawl(e).withPromise();let u=o?.base||`/docs`,d=[];for(let n=0;n<l.length;n+=100){let i=l.slice(n,n+100),a=await Promise.all(i.map(async n=>{let i=r.default.isAbsolute(n)?n:r.default.resolve(e,n),a=r.default.relative(e,i),{data:o}=await B(i),s;return s=o.permalink?o.permalink.startsWith(`/`)?o.permalink:`/${o.permalink}`:t.a(a),u===`/`?s:(u.endsWith(`/`)?u:u+`/`)+(s.startsWith(`/`)?s.substring(1):s)}));d.push(...a)}d.includes(u)||d.push(u);let f={routes:Array.from(new Set(d)).sort(),timestamp:Date.now()};return a.default.writeFileSync(r.default.resolve(c,`link-tree.json`),JSON.stringify(f,null,2)),f}function G(e,t){if(e===t)return 1;if(!e||!t)return 0;let n=e.split(`/`).filter(Boolean),r=t.split(`/`).filter(Boolean),i=n[n.length-1]||``,a=r[r.length-1]||``;if(i===a){let e=0;for(let t of n)r.includes(t)&&e++;return e>=2?.99:.9}if(i.length>3&&a.length>3&&(a.startsWith(i)||i.startsWith(a))&&Math.min(i.length,a.length)/Math.max(i.length,a.length)>.5)return .88;let o=1-(0,f.distance)(i,a)/Math.max(i.length,a.length);return o>.8?o*.95:1-(0,f.distance)(e,t)/Math.max(e.length,t.length)}const K=new Map;function q(e,t){if(K.has(e))return K.get(e);let n=e.length,r=``,i=0;for(let a of t){if(a===e)continue;let t=a.length,o=Math.max(n,t);if(o===0)continue;let s=1-Math.abs(n-t)/o;if(s<=.8&&s<=i)continue;let c=G(e,a);c>i&&(i=c,r=a)}let a={bestMatch:r,similarity:i};return K.set(e,a),a}async function J(e){let n=[];if(!e.doctorConfig.checks.metadata.enabled)return n;let{titleMin:i,titleMax:a,descriptionMin:o}=e.doctorConfig.checks.metadata,s=new Map;for(let c of e.files){let l=t.u(r.default.relative(e.docsDir,c));try{let{raw:r,data:u}=await B(c);if(r.trim().startsWith(`---`)&&r.split(`---`).length>=3&&Object.keys(u).length===0){let t=L(e,`malformedFrontmatter`,`high`);t!==`off`&&n.push({file:l,level:t,message:`Malformed frontmatter (YAML parsing failed).`,suggestion:`Check your YAML syntax for indentation or unquoted special characters.`})}let d=t.y.safeParse(u);if(!d.success){let t=L(e,`invalidFrontmatter`,`high`);if(t!==`off`)for(let e of d.error.issues)n.push({file:l,level:t,message:`Invalid frontmatter field "${e.path.join(`.`)}": ${e.message}`,suggestion:`Ensure the field follows the correct type.`})}let f=Array.from(new Set([`title`,...e.doctorConfig.checks.metadata.required]));for(let t of f)if(u[t]===void 0){let r=L(e,`missingMetadata`,`warning`);r!==`off`&&n.push({file:l,level:r,message:`Missing required frontmatter field: "${t}".`,suggestion:`Add the "${t}" field to your frontmatter.`})}if(e.doctorConfig.checks.metadata.validateDates){let t=[`date`,`lastUpdated`,...e.doctorConfig.checks.metadata.optional.filter(e=>e.toLowerCase().includes(`date`))];for(let r of t)if(u[r]&&Number.isNaN(Date.parse(String(u[r])))){let t=L(e,`invalidFrontmatter`,`high`);t!==`off`&&n.push({file:l,level:t,message:`Invalid date format in field "${r}": "${u[r]}".`,suggestion:`Use a valid ISO date format (e.g., YYYY-MM-DD).`})}}if(u.title){let t=String(u.title);if(t.length<i){let r=L(e,`shortMetadata`,`low`);r!==`off`&&n.push({file:l,level:r,message:`Title is too short (${t.length} chars).`,suggestion:`Titles should be at least ${i} characters for better SEO.`})}else if(t.length>a){let r=L(e,`shortMetadata`,`low`);r!==`off`&&n.push({file:l,level:r,message:`Title is too long (${t.length} chars).`,suggestion:`Titles should be under ${a} characters.`})}let r=s.get(t)||[];r.push(l),s.set(t,r)}if(u.description&&String(u.description).length<o){let t=L(e,`shortMetadata`,`low`);t!==`off`&&n.push({file:l,level:t,message:`Description is very short.`,suggestion:`Descriptions should ideally be at least ${o} characters.`})}}catch(t){if(t instanceof Error){let r=L(e,`malformedFrontmatter`,`high`);r!==`off`&&n.push({file:l,level:r,message:`Malformed frontmatter (YAML error): ${t.message}`,suggestion:`Check your YAML syntax for indentation or unquoted special characters.`})}}}for(let[t,r]of s.entries())if(r.length>1){let i=L(e,`duplicateTitle`,`low`);if(i!==`off`)for(let e of r)n.push({file:e,level:i,message:`Duplicate title found: "${t}"`,suggestion:`Ensure each page has a unique title. Also used in: ${r.filter(t=>t!==e).join(`, `)}`})}return n}async function Y(e){let n=[],{internal:i,external:o,ignore:c,timeout:l,concurrency:u}=e.doctorConfig.checks.links;if(!i&&!o&&!e.options.checkExternal)return n;let d=/(?:\[.*?\]\((.*?)\))|(?:href=["']([^"']+)["'])/g,f=new Set,p=5e5;for(let s of e.files){let l=t.u(r.default.relative(e.docsDir,s)),{content:u}=await B(s),m=[...(u.length>p?u.slice(0,p):u).replace(/```[\s\S]*?```/g,``).replace(/`[^`\n]*`/g,``).matchAll(d)];for(let t of m){let u=t[1]||t[2],d=!!t[1];if(!u||c.some(e=>u.includes(e)))continue;if(/^https?:\/\//i.test(u)){(o||e.options.checkExternal)&&f.add({url:u,file:s});continue}if(!i||/^(mailto|tel|#)/i.test(u))continue;let p;try{p=decodeURIComponent(u.split(`#`)[0].split(`?`)[0])}catch{p=u.split(`#`)[0].split(`?`)[0]}if(!p)continue;let m=!1,h=``;if(p.startsWith(`/`))if(e.routeIndex.has(p)||e.routeIndexWithSlash.has(p)||e.routeIndexWithoutSlash.has(p))m=!0;else{let t=e.basePrefix+(p.startsWith(`/`)?p:`/`+p);if(e.routeIndex.has(t)||e.routeIndexWithSlash.has(t))m=!1,h=t;else{let t=e.config.base!==`/`&&p.startsWith(e.config.base||`/`)?p.substring((e.config.base||`/`).length):p,n=t.startsWith(`/`)?t.substring(1):t;h=r.default.join(e.docsDir,n),m=[``,`.md`,`.mdx`,`/index.md`,`/index.mdx`].some(e=>H(h+e))}}else h=r.default.resolve(r.default.dirname(s),p),m=[``,`.md`,`.mdx`,`/index.md`,`/index.mdx`].some(e=>H(h+e));if(!m){let{bestMatch:t,similarity:r}=q(p,e.linkTree.routes),i=!1,o=e.basePrefix+(p.startsWith(`/`)?p:`/`+p);(e.routeIndex.has(o)||e.routeIndexWithSlash.has(o))&&(t=o,r=1,i=!0);let c=r>.6||i,f=r>.75&&t!==p||i,m=L(e,`brokenLink`,`high`);m!==`off`&&n.push({file:l,level:m,message:`Broken internal link: "${u}"`,suggestion:c?`Did you mean "${t}"?`:`Ensure the target exists or check for typos.`,fix:f?async()=>{let e=u.includes(`#`)?`#`+u.split(`#`)[1]:``,n=d?`(${u})`:`href="${u}"`,r=d?`(${t}${e})`:`href="${t}${e}"`,i=a.default.readFileSync(s,`utf-8`).replace(n,r);a.default.writeFileSync(s,i),z.delete(s)}:void 0})}}}if(f.size>0){(0,s.info)(s.colors.gray(`Verifying ${f.size} external links...`));let i=new Map;for(let e of f)i.has(e.url)||i.set(e.url,[]),i.get(e.url).push(e.file);let a=async e=>{try{let t=new AbortController,n=setTimeout(()=>t.abort(),l),r=await fetch(e,{method:`HEAD`,signal:t.signal,headers:{"User-Agent":`boltdocs-doctor/1.0`}});return clearTimeout(n),!r.ok&&r.status!==404?{url:e,ok:(await fetch(e,{method:`GET`,signal:t.signal,headers:{"User-Agent":`boltdocs-doctor/1.0`}})).ok}:{url:e,ok:r.ok}}catch(t){return{url:e,ok:!1,error:t.message}}},o=Array.from(i.keys()),c=[];for(let e=0;e<o.length;e+=u){let t=o.slice(e,e+u),n=await Promise.allSettled(t.map(a));c.push(...n.map(e=>e.status===`fulfilled`?e.value:{url:`unknown`,ok:!1,error:e.reason}))}for(let a of c)if(!a.ok){let o=L(e,`brokenLink`,`warning`);if(o!==`off`){let s=i.get(a.url)||[];for(let i of s)n.push({file:t.u(r.default.relative(e.docsDir,i)),level:o,message:`Broken external link: "${a.url}"`,suggestion:`Verify the URL or update it if it's permanently down. Error: ${a.error||`Status >= 400`}`})}}}return n}async function X(e){let n=[];if(!e.doctorConfig.checks.i18n.enabled||!e.config.i18n)return n;let{defaultLocale:i,locales:o}=e.config.i18n,s=Object.keys(o),c=s.filter(e=>e!==i);for(let o of e.files){let l=t.u(r.default.relative(e.docsDir,o)),u=l.split(`/`),d=u[0];if(d===i){let t=u.slice(1).join(`/`);for(let i of c){let s=r.default.join(e.docsDir,i,t);if(!H(s)){let c=L(e,`missingTranslation`,`warning`);c!==`off`&&n.push({file:l,level:c,message:`Missing translation for locale "${i}"`,suggestion:`Create a version at "${i}/${t}".`,fix:async()=>{let e=r.default.dirname(s);a.default.existsSync(e)||a.default.mkdirSync(e,{recursive:!0}),a.default.copyFileSync(o,s)}})}}}else if(s.includes(d)){let t=u.slice(1).join(`/`);if(!H(r.default.join(e.docsDir,i,t))){let r=L(e,`missingTranslation`,`low`);r!==`off`&&n.push({file:l,level:r,message:`Orphaned translation (source missing in "${i}")`,suggestion:`Remove this file or create the source at "${i}/${t}".`,fix:async()=>{a.default.unlinkSync(o)}})}}}return n}async function Z(e){let t=[];if(!e.config.theme.sidebar)return t;let n=new Set,r=e.config.theme.sidebar;for(let[i,a]of Object.entries(r))for(let r of a){if(!r.text){let n=L(e,`invalidFrontmatter`,`warning`);n!==`off`&&t.push({file:`boltdocs.config.ts`,level:n,message:`Sidebar item in group "${i}" is missing a label.`,suggestion:`Add a "text" property to the sidebar item.`})}if(r.link&&(n.add(r.link),!e.routeIndex.has(r.link))){let{bestMatch:n,similarity:i}=q(r.link,e.linkTree.routes),a=i>.6,o=L(e,`brokenLink`,`high`);o!==`off`&&t.push({file:`boltdocs.config.ts`,level:o,message:`Broken sidebar link: "${r.link}"`,suggestion:a?`Did you mean "${n}"?`:`Ensure the route exists and is correctly formatted.`})}}for(let r of e.linkTree.routes)if(!(r===`/`||r===``)&&!n.has(r)){let n=L(e,`orphanedPage`,`low`);n!==`off`&&t.push({file:`Sidebar`,level:n,message:`Orphaned page found: "${r}" is not linked in the sidebar.`,suggestion:`Consider adding it to the sidebar for better discoverability.`})}return t}async function Q(e){let t=[],n=e.doctorConfig.checks.performance;if(!n?.enabled)return t;let i=r.default.resolve(e.root,`.boltdocs`,`reports`,`performance.json`);if(!a.default.existsSync(i))return t.push({file:`(build)`,level:L(e,`budgetExceeded`,`warning`),message:"Performance metrics not found. Run `boltdocs build` first."}),t;let o;try{o=JSON.parse(a.default.readFileSync(i,`utf-8`))}catch{return t.push({file:`(build)`,level:L(e,`budgetExceeded`,`warning`),message:`Failed to parse performance metrics file.`}),t}let s=n.budgets,c=L(e,`budgetExceeded`,`warning`),l=I(s?.maxJSBundleSize,1/0),u=I(s?.maxCSSBundleSize,1/0),d=I(s?.maxPageHTMLSize,1/0),f=s?.maxImagesKB??1/0,p=s?.maxBuildTime??1/0,m=s?.maxFontCount??1/0;if(l!==1/0&&o.totalJSBundleSize>l){let e=(o.totalJSBundleSize/1024).toFixed(0),n=(l/1024).toFixed(0);t.push({file:`(build)`,level:c,message:`JS bundle size exceeds budget: ${e}kb > ${n}kb`,suggestion:`Code-split large dependencies or lazy-load route components.`})}if(u!==1/0&&o.totalCSSBundleSize>u){let e=(o.totalCSSBundleSize/1024).toFixed(0),n=(u/1024).toFixed(0);t.push({file:`(build)`,level:c,message:`CSS bundle size exceeds budget: ${e}kb > ${n}kb`,suggestion:`Remove unused styles or split CSS by route.`})}if(d!==1/0){for(let e of o.pages)if(e.htmlSize>d){let n=(e.htmlSize/1024).toFixed(0),r=(d/1024).toFixed(0);t.push({file:e.route,level:c,message:`Page HTML size exceeds budget: ${n}kb > ${r}kb`,suggestion:`Reduce the amount of inline content or split into sub-pages.`})}}let h=f*1024;if(f!==1/0&&o.totalImagesSize>h){let e=(o.totalImagesSize/1024).toFixed(0);t.push({file:`(build)`,level:c,message:`Image assets exceed budget: ${e}kb > ${f}kb`,suggestion:`Optimize images with lossy compression or use next-gen formats (webp/avif).`})}if(p!==1/0&&o.buildTime>p){let e=(o.buildTime/1e3).toFixed(1),n=(p/1e3).toFixed(1);t.push({file:`(build)`,level:c,message:`Build time exceeds budget: ${e}s > ${n}s`,suggestion:"Check for large unoptimized assets or increase `concurrency` in SSG options."})}return m!==1/0&&o.fontCount>m&&t.push({file:`(build)`,level:c,message:`Font files exceed budget: ${o.fontCount} > ${m}`,suggestion:`Reduce the number of font families or use variable fonts.`}),t}async function $(e){let t=r.default.resolve(e,`doctor.json`);if(a.default.existsSync(t)){(0,s.warn)(`"doctor.json" already exists at ${e}.`);return}try{a.default.writeFileSync(t,JSON.stringify(F,null,2)),(0,s.success)(`Created "doctor.json" with default configuration.`)}catch(e){(0,s.error)(`Failed to create "doctor.json": ${e}`)}}async function te(e=process.cwd(),t={}){if(t.init){await $(e);return}P();try{let n=await U(e),{format:o}=n.reporting,c=performance.now(),u=await A(`docs`,e),d=r.default.resolve(e,`docs`);a.default.existsSync(d)||(o===`pretty`&&(0,s.error)(`Docs dir not found at ${d}`),process.exit(1)),o===`pretty`&&console.log((0,s.double)(`✦ DOCTOR — Documentation Health Check`,[` ${s.colors.dim(`Docs dir:`)} ${d}`,` ${s.colors.dim(`Reports:`)} ${e}/.boltdocs/reports/`])),o===`pretty`&&(0,s.info)(s.colors.dim(`🔍 Discovering files and routes...`));let f=(0,l.default)(n.exclude||[]),p=await new i.fdir().withFullPaths().filter(e=>{if(!(e.endsWith(`.md`)||e.endsWith(`.mdx`)))return!1;let t=r.default.relative(d,e).replace(/\\/g,`/`),n=t.split(`/`).some(e=>e.startsWith(`_`)&&e!==`_index.md`&&e!==`_index.mdx`);return!f(t)&&!n}).crawl(d).withPromise();for(let e of p)V.set(e,!0);let m=await W(d,e,u,p),h=u.base||`/`,g=h===`/`?``:h.endsWith(`/`)?h.slice(0,-1):h,_={root:e,docsDir:d,config:u,doctorConfig:n,linkTree:m,files:p,options:t,routeIndex:new Set(m.routes),routeIndexWithSlash:new Set(m.routes.map(e=>e.endsWith(`/`)?e:e+`/`)),routeIndexWithoutSlash:new Set(m.routes.map(e=>e.endsWith(`/`)?e.slice(0,-1):e)),basePrefix:g};o===`pretty`&&(0,s.info)(s.colors.dim(`🧪 Running diagnostic checks in parallel...`));let v=[J(_),Y(_),X(_),Z(_)];t.budget&&v.push(Q(_));let[y,b,x,S,...C]=await Promise.all(v),w=t.budget?C[0]:[],T=[...y,...b,...x,...S,...w];if(o===`pretty`){let e=[{label:`Metadata checks ${y.length>0?`— ${y.length} issue${y.length===1?``:`s`}`:`— OK`}`,done:y.length===0},{label:`Link checks ${b.length>0?`— ${b.length} issue${b.length===1?``:`s`}`:`— OK`}`,done:b.length===0},{label:`i18n checks ${x.length>0?`— ${x.length} issue${x.length===1?``:`s`}`:`— OK`}`,done:x.length===0},{label:`Sidebar checks ${S.length>0?`— ${S.length} issue${S.length===1?``:`s`}`:`— OK`}`,done:S.length===0}];t.budget&&e.push({label:`Performance budget ${w.length>0?`— ${w.length} issue${w.length===1?``:`s`}`:`— OK`}`,done:w.length===0}),console.log(`\n${(0,s.tasks)(e)}`)}let E=0;if(t.fix){for(let e of T)if(e.fix){if(_.doctorConfig.fix.confirmChanges&&!await(0,s.confirm)(`Fix issue in "${e.file}": ${e.message}?`))continue;if(_.doctorConfig.fix.backupFiles){let t=r.default.resolve(_.docsDir,e.file);a.default.existsSync(t)&&await R(t,r.default.resolve(_.root,_.doctorConfig.fix.backupPath))}await e.fix(),E++}}let D=((performance.now()-c)/1e3).toFixed(2),O=T.filter(e=>e.level===`high`).length,k=T.filter(e=>e.level===`warning`).length,j=T.filter(e=>e.level===`low`).length,M={summary:{total:T.length,high:O,warning:k,low:j,fixed:E,duration:D},issues:T.map(e=>({...e,fix:void 0}))};if(n.reporting.outputFile){let t=r.default.resolve(e,n.reporting.outputFile);a.default.existsSync(r.default.dirname(t))||a.default.mkdirSync(r.default.dirname(t),{recursive:!0}),a.default.writeFileSync(t,JSON.stringify(M,null,2))}if(o===`json`)console.log(JSON.stringify(M,null,2));else if(o===`pretty`){let e=T.reduce((e,t)=>(e[t.file]||(e[t.file]=[]),e[t.file].push(t),e),{});if(T.length>0){(0,s.dividerLog)();for(let[n,r]of Object.entries(e)){let e=[];for(let n of r){let r=n.level===`high`?`❌`:n.level===`warning`?`⚠️`:`ℹ️`,i=n.level===`high`?s.colors.red:n.level===`warning`?s.colors.yellow:s.colors.blue;e.push(`${r} ${i(n.level.toUpperCase())}: ${n.message}`),n.suggestion&&e.push(` ${s.colors.dim(`💡 ${n.suggestion}`)}`),t.fix&&n.fix&&e.push(` ${s.colors.green(`✅ Fixed automatically`)}`)}console.log(`\n${(0,s.single)(`📄 ${n}`,e)}`)}(0,s.dividerLog)()}if(T.length===0)console.log((0,s.round)(`✨ Documentation Health Check`,[` Everything looks perfect!`,` Your documentation is in great shape.`,``,` ${s.colors.dim(`Scanned ${p.length} file${p.length===1?``:`s`} in ${D}s`)}`]));else{let e=[];O>0&&e.push(s.colors.red(`${O} Critical Error${O===1?``:`s`}`)),k>0&&e.push(s.colors.yellow(`${k} Warning${k===1?``:`s`}`)),j>0&&e.push(s.colors.blue(`${j} Improvement${j===1?``:`s`}`));let t=[...(0,s.bullet)(e).split(`
28
+ `).map(e=>e.trimStart()),``,s.colors.dim(`Scanned ${p.length} file${p.length===1?``:`s`} in ${D}s`)];console.log(`\n${(0,s.double)(`Diagnosis Results`,t)}\n`),E>0&&(0,s.success)(`Successfully fixed ${E} issues automatically!`),O>0?(0,s.error)(`Please fix the critical errors before building for production.`):(0,s.success)(`No critical issues found. You are ready to go!`)}}n.reporting.failOnError&&O>0&&process.exit(1),n.reporting.maxWarnings!==-1&&k>n.reporting.maxWarnings&&(o===`pretty`&&(0,s.error)(`Failed: Too many warnings (${k} > ${n.reporting.maxWarnings})`),process.exit(1))}catch(e){(0,s.error)(`Doctor failed: ${e}`),process.exit(1)}}Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return te}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return F}});
@@ -487,8 +487,9 @@ function useRoutes() {
487
487
  const localeMatch = config.i18n ? (r.locale || config.i18n.defaultLocale) === currentLocale : true;
488
488
  const versionMatch = config.versions ? (r.version || config.versions.defaultVersion) === currentVersion : true;
489
489
  if (!(localeMatch && versionMatch)) return false;
490
- const isCurrentLocalePrefixed = !!currentRoute?.locale;
491
- const isCurrentVersionPrefixed = !!currentRoute?.version;
490
+ const pathParts = location.pathname.split("/").filter(Boolean);
491
+ const isCurrentLocalePrefixed = !!(config.i18n && pathParts.includes(currentLocaleStore || config.i18n.defaultLocale));
492
+ const isCurrentVersionPrefixed = !!(config.versions && pathParts.includes(currentVersionStore || config.versions.defaultVersion));
492
493
  const isRouteLocalePrefixed = !!r.locale;
493
494
  const isRouteVersionPrefixed = !!r.version;
494
495
  const locale = r.locale || defaultLocale;
@@ -506,7 +507,9 @@ function useRoutes() {
506
507
  config,
507
508
  currentLocale,
508
509
  currentVersion,
509
- currentRoute
510
+ location.pathname,
511
+ currentLocaleStore,
512
+ currentVersionStore
510
513
  ]);
511
514
  const collections = (0, react.useMemo)(() => {
512
515
  return new Set((allRoutes || []).map((r) => r.collection).filter(Boolean));
@@ -464,8 +464,9 @@ function useRoutes() {
464
464
  const localeMatch = config.i18n ? (r.locale || config.i18n.defaultLocale) === currentLocale : true;
465
465
  const versionMatch = config.versions ? (r.version || config.versions.defaultVersion) === currentVersion : true;
466
466
  if (!(localeMatch && versionMatch)) return false;
467
- const isCurrentLocalePrefixed = !!currentRoute?.locale;
468
- const isCurrentVersionPrefixed = !!currentRoute?.version;
467
+ const pathParts = location.pathname.split("/").filter(Boolean);
468
+ const isCurrentLocalePrefixed = !!(config.i18n && pathParts.includes(currentLocaleStore || config.i18n.defaultLocale));
469
+ const isCurrentVersionPrefixed = !!(config.versions && pathParts.includes(currentVersionStore || config.versions.defaultVersion));
469
470
  const isRouteLocalePrefixed = !!r.locale;
470
471
  const isRouteVersionPrefixed = !!r.version;
471
472
  const locale = r.locale || defaultLocale;
@@ -483,7 +484,9 @@ function useRoutes() {
483
484
  config,
484
485
  currentLocale,
485
486
  currentVersion,
486
- currentRoute
487
+ location.pathname,
488
+ currentLocaleStore,
489
+ currentVersionStore
487
490
  ]);
488
491
  const collections = useMemo(() => {
489
492
  return new Set((allRoutes || []).map((r) => r.collection).filter(Boolean));
@@ -3,7 +3,7 @@
3
3
  * Copyright (c) 2026 Jesus Alcala
4
4
  * Licensed under the MIT License.
5
5
  */
6
- const require_icons_dev = require('./icons-dev-DvJ-hh9x.cjs');
6
+ const require_icons_dev = require('./icons-dev-C8sFxeBk.cjs');
7
7
  let react = require("react");
8
8
  react = require_icons_dev.__toESM(react);
9
9
  let react_jsx_runtime = require("react/jsx-runtime");
@@ -16,8 +16,14 @@ const THEME_INSTANCE_SYMBOL = Symbol.for("__BDOCS_THEME_INSTANCE__");
16
16
  const THEME_EVENT = "boltdocs-theme-change";
17
17
  const ThemeContext = globalThis[THEME_CONTEXT_SYMBOL] || (globalThis[THEME_CONTEXT_SYMBOL] = (0, react.createContext)(void 0));
18
18
  function ThemeProvider({ children }) {
19
- const [theme, setThemeState] = (0, react.useState)("system");
20
- const [resolvedTheme, setResolvedTheme] = (0, react.useState)("dark");
19
+ const [theme, setThemeState] = (0, react.useState)(() => {
20
+ if (typeof window !== "undefined" && typeof localStorage !== "undefined") return localStorage.getItem("boltdocs-theme") || "system";
21
+ return "system";
22
+ });
23
+ const [resolvedTheme, setResolvedTheme] = (0, react.useState)(() => {
24
+ if (typeof window !== "undefined" && typeof document !== "undefined" && document.documentElement) return document.documentElement.classList.contains("dark") ? "dark" : "light";
25
+ return "light";
26
+ });
21
27
  const applyTheme = (targetTheme) => {
22
28
  const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
23
29
  const isDark = targetTheme === "dark" || targetTheme === "system" && mediaQuery.matches;
@@ -3,7 +3,7 @@
3
3
  * Copyright (c) 2026 Jesus Alcala
4
4
  * Licensed under the MIT License.
5
5
  */
6
- import { H as Link, _ as Link$1, y as cn } from "./icons-dev-Oju24Wjp.js";
6
+ import { H as Link, _ as Link$1, y as cn } from "./icons-dev-CFcv5Nb8.js";
7
7
  import * as React$1 from "react";
8
8
  import { createContext, use, useEffect, useState } from "react";
9
9
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -15,8 +15,14 @@ const THEME_INSTANCE_SYMBOL = Symbol.for("__BDOCS_THEME_INSTANCE__");
15
15
  const THEME_EVENT = "boltdocs-theme-change";
16
16
  const ThemeContext = globalThis[THEME_CONTEXT_SYMBOL] || (globalThis[THEME_CONTEXT_SYMBOL] = createContext(void 0));
17
17
  function ThemeProvider({ children }) {
18
- const [theme, setThemeState] = useState("system");
19
- const [resolvedTheme, setResolvedTheme] = useState("dark");
18
+ const [theme, setThemeState] = useState(() => {
19
+ if (typeof window !== "undefined" && typeof localStorage !== "undefined") return localStorage.getItem("boltdocs-theme") || "system";
20
+ return "system";
21
+ });
22
+ const [resolvedTheme, setResolvedTheme] = useState(() => {
23
+ if (typeof window !== "undefined" && typeof document !== "undefined" && document.documentElement) return document.documentElement.classList.contains("dark") ? "dark" : "light";
24
+ return "light";
25
+ });
20
26
  const applyTheme = (targetTheme) => {
21
27
  const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
22
28
  const isDark = targetTheme === "dark" || targetTheme === "system" && mediaQuery.matches;
@@ -3,8 +3,8 @@
3
3
  * Copyright (c) 2026 Jesus Alcala
4
4
  * Licensed under the MIT License.
5
5
  */
6
- const require_icons_dev = require('./icons-dev-DvJ-hh9x.cjs');
7
- const require_image = require('./image-Ch4-GxdO.cjs');
6
+ const require_icons_dev = require('./icons-dev-C8sFxeBk.cjs');
7
+ const require_image = require('./image-DCMxxidi.cjs');
8
8
  let react = require("react");
9
9
  let react_jsx_runtime = require("react/jsx-runtime");
10
10
  let react_aria_components = require("react-aria-components");
@@ -3,8 +3,8 @@
3
3
  * Copyright (c) 2026 Jesus Alcala
4
4
  * Licensed under the MIT License.
5
5
  */
6
- import { D as Check, F as File, M as Copy, T as AlertTriangle, V as Lightbulb, _ as Link, a as Csv, c as JavaScript, d as React$1, f as Rust, g as Yaml, i as Css, l as Json, m as TypeScript, n as BracketsOrange, p as Shell, r as BracketsRed, u as Markdown, w as AlertCircle, y as cn, z as Info } from "./icons-dev-Oju24Wjp.js";
7
- import { a as CodeBlockGroup, i as CodeBlockContent, l as useTheme, n as Tooltip, o as CodeBlockHeader, r as CodeBlock$1, s as Heading$1, t as Image$1 } from "./image-Do8V9PCW.js";
6
+ import { D as Check, F as File, M as Copy, T as AlertTriangle, V as Lightbulb, _ as Link, a as Csv, c as JavaScript, d as React$1, f as Rust, g as Yaml, i as Css, l as Json, m as TypeScript, n as BracketsOrange, p as Shell, r as BracketsRed, u as Markdown, w as AlertCircle, y as cn, z as Info } from "./icons-dev-CFcv5Nb8.js";
7
+ import { a as CodeBlockGroup, i as CodeBlockContent, l as useTheme, n as Tooltip, o as CodeBlockHeader, r as CodeBlock$1, s as Heading$1, t as Image$1 } from "./image-DufDOid8.js";
8
8
  import { useCallback, useEffect, useRef, useState } from "react";
9
9
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
10
  import { Button } from "react-aria-components";
@@ -4,6 +4,6 @@
4
4
  * Copyright (c) 2026 Jesus Alcala
5
5
  * Licensed under the MIT License.
6
6
  */
7
- const e=require(`../chunk-CU-zTemE.cjs`),t=require(`../doctor-BArviV8X.cjs`),n=require(`../node-BfGSXyUz.cjs`);let r=require(`vite`),i=require(`node:path`);i=e.t(i);let a=require(`node:fs`);a=e.t(a);let o=require(`@bdocs/dui`),s=require(`node:fs/promises`);s=e.t(s);let c=require(`@bdocs/ssg/node`),l=require(`cac`);l=e.t(l);function u(e){let t=e;for(;t&&t!==i.default.dirname(t);){if(a.default.existsSync(i.default.join(t,`.git`))||a.default.existsSync(i.default.join(t,`pnpm-workspace.yaml`)))return t;t=i.default.dirname(t)}t=e;let n=e;for(;t&&t!==i.default.dirname(t);)a.default.existsSync(i.default.join(t,`package.json`))&&(n=t),t=i.default.dirname(t);return n}let d=u(process.cwd());function f(e){if(!e)return;let t;if(typeof e==`string`)t=e;else if(e instanceof URL){if(e.protocol!==`file:`)return;t=e.pathname}else if(Buffer.isBuffer(e))t=e.toString();else return;let n=i.default.resolve(d,t),r=i.default.relative(d,n),a=r.startsWith(`..`)||i.default.isAbsolute(r),o=n.split(i.default.sep),s=o.some(e=>e.startsWith(`.env`)),c=o.some((e,t)=>{if(e===`node_modules`){let e=o[t+1];return!e||!e.startsWith(`.`)}return!1});if(a||s||c)throw Error(`[Boltdocs Security] Write/delete operation blocked on path: "${n}". Modifications are restricted to the project root, and cannot access .env or non-cache node_modules folders.`)}function p(e){return e==null?!1:typeof e==`number`?e!==0:typeof e==`string`?e.includes(`w`)||e.includes(`a`)||e.includes(`+`):!0}function m(){let e=a.default.writeFile;a.default.writeFile=function(t,...n){try{f(t)}catch(e){let t=n[n.length-1];if(typeof t==`function`){process.nextTick(()=>t(e));return}throw e}return e.call(a.default,t,...n)};let t=a.default.writeFileSync;a.default.writeFileSync=function(e,...n){return f(e),t.call(a.default,e,...n)};let n=a.default.rm;a.default.rm=function(e,...t){try{f(e)}catch(e){let n=t[t.length-1];if(typeof n==`function`){process.nextTick(()=>n(e));return}throw e}return n.call(a.default,e,...t)};let r=a.default.rmSync;a.default.rmSync=function(e,...t){return f(e),r.call(a.default,e,...t)};let i=a.default.unlink;a.default.unlink=function(e,...t){try{f(e)}catch(e){let n=t[t.length-1];if(typeof n==`function`){process.nextTick(()=>n(e));return}throw e}return i.call(a.default,e,...t)};let o=a.default.unlinkSync;a.default.unlinkSync=function(e,...t){return f(e),o.call(a.default,e,...t)};let c=a.default.mkdir;a.default.mkdir=function(e,...t){try{f(e)}catch(e){let n=t[t.length-1];if(typeof n==`function`){process.nextTick(()=>n(e));return}throw e}return c.call(a.default,e,...t)};let l=a.default.mkdirSync;a.default.mkdirSync=function(e,...t){return f(e),l.call(a.default,e,...t)};let u=a.default.rmdir;a.default.rmdir=function(e,...t){try{f(e)}catch(e){let n=t[t.length-1];if(typeof n==`function`){process.nextTick(()=>n(e));return}throw e}return u.call(a.default,e,...t)};let d=a.default.rmdirSync;a.default.rmdirSync=function(e,...t){return f(e),d.call(a.default,e,...t)};let m=a.default.appendFile;a.default.appendFile=function(e,...t){try{f(e)}catch(e){let n=t[t.length-1];if(typeof n==`function`){process.nextTick(()=>n(e));return}throw e}return m.call(a.default,e,...t)};let h=a.default.appendFileSync;a.default.appendFileSync=function(e,...t){return f(e),h.call(a.default,e,...t)};let g=a.default.copyFile;a.default.copyFile=function(e,t,...n){try{f(e),f(t)}catch(e){let t=n[n.length-1];if(typeof t==`function`){process.nextTick(()=>t(e));return}throw e}return g.call(a.default,e,t,...n)};let _=a.default.copyFileSync;a.default.copyFileSync=function(e,t,...n){return f(e),f(t),_.call(a.default,e,t,...n)};let v=a.default.rename;a.default.rename=function(e,t,...n){try{f(e),f(t)}catch(e){let t=n[n.length-1];if(typeof t==`function`){process.nextTick(()=>t(e));return}throw e}return v.call(a.default,e,t,...n)};let y=a.default.renameSync;a.default.renameSync=function(e,t,...n){return f(e),f(t),y.call(a.default,e,t,...n)};let b=a.default.createWriteStream;a.default.createWriteStream=function(e,...t){return f(e),b.call(a.default,e,...t)};let x=a.default.open;a.default.open=function(e,t,...n){if(p(typeof t==`function`?void 0:t))try{f(e)}catch(e){let r=n[n.length-1],i=typeof t==`function`?t:typeof r==`function`?r:void 0;if(i){process.nextTick(()=>i(e));return}throw e}return x.call(a.default,e,t,...n)};let S=a.default.openSync;a.default.openSync=function(e,t,...n){return p(t)&&f(e),S.call(a.default,e,t,...n)};let C=e=>{if(!e)return;let t=e.writeFile;t&&(e.writeFile=async function(n,...r){return f(n),t.call(e,n,...r)});let n=e.rm;n&&(e.rm=async function(t,...r){return f(t),n.call(e,t,...r)});let r=e.mkdir;r&&(e.mkdir=async function(t,...n){return f(t),r.call(e,t,...n)});let i=e.rmdir;i&&(e.rmdir=async function(t,...n){return f(t),i.call(e,t,...n)});let a=e.unlink;a&&(e.unlink=async function(t,...n){return f(t),a.call(e,t,...n)});let o=e.appendFile;o&&(e.appendFile=async function(t,...n){return f(t),o.call(e,t,...n)});let s=e.copyFile;s&&(e.copyFile=async function(t,n,...r){return f(t),f(n),s.call(e,t,n,...r)});let c=e.rename;c&&(e.rename=async function(t,n,...r){return f(t),f(n),c.call(e,t,n,...r)});let l=e.open;l&&(e.open=async function(t,n,...r){return p(n)&&f(t),l.call(e,t,n,...r)})};C(a.default.promises),C(s.default)}let h=!1;async function g(e=process.cwd()){if(!h){h=!0,t.d();try{n.S(await t.p(i.default.resolve(e,`docs`),e),e)}catch{}try{let t=await n.n(e,`development`);t.logLevel=`warn`,t.clearScreen=!1;let r=await(0,c.createServer)(t);await r.listen();let i=r.resolvedUrls;console.log((0,o.devServer)(i?.local?.[0]??`http://localhost:5173`,i?.network?.[0]??null)),r.bindCLIShortcuts({print:!1})}catch(e){(0,o.error)(`Failed to start dev server:`,e),process.exit(1)}}}async function _(e=process.cwd()){t.d();try{let t=await n.x().run({root:e,timing:{}});t.success||((0,o.error)(`Build failed at step "${t.failedStep}":`,t.error),process.exit(1)),(0,o.success)(`SSG build completed successfully in ${Math.round(t.timing.total)}ms!`),process.exit(0)}catch(e){(0,o.error)(`Build failed:`,e),process.exit(1)}}async function v(e=process.cwd()){try{let t=await createViteConfig(e,`production`);t.logLevel=`warn`,t.clearScreen=!1;let n=await(0,r.preview)(t),i=n.resolvedUrls;console.log(n(i?.local?.[0]??`http://localhost:4173`,i?.network?.[0]??null))}catch(e){(0,o.error)(`Failed to start preview server:`,e),process.exit(1)}}function y(e){let t=[];if(!a.default.existsSync(e))return t;try{let n=a.default.readdirSync(e);for(let r of n){let n=i.default.join(e,r);a.default.statSync(n).isDirectory()?r!==`node_modules`&&r!==`.git`&&r!==`dist`&&r!==`coverage`&&t.push(...y(n)):/\.(js|mjs|cjs|ts|tsx|jsx)$/.test(r)&&t.push(n)}}catch{}return t}async function b(e=process.cwd()){(0,o.info)(`Starting static security audit of Boltdocs plugins...`);let n;try{n=await t.p(i.default.resolve(e,`docs`),e)}catch(e){(0,o.error)(`Failed to load Boltdocs configuration for audit:`,e),process.exit(1)}let r=n.plugins||[];if(r.length===0){(0,o.success)(`No plugins configured. Nothing to audit.`);return}let s=[];for(let t of r){if(!t.name)continue;let n=null;try{let{createRequire:r}=await import(`node:module`),a=r(i.default.resolve(e,`package.json`)).resolve(`${t.name}/package.json`);n=i.default.dirname(a)}catch{let r=i.default.resolve(e,`node_modules`,t.name);a.default.existsSync(r)&&(n=r)}if(!n){s.push({name:o.colors.cyan(t.name),status:o.colors.red(`❓ Unresolved`),details:`Could not locate plugin files in node_modules.`});continue}let r=y(n),c=[];for(let e of r)try{let t=a.default.readFileSync(e,`utf-8`);t.includes(`fetch(`)&&c.push(`fetch`),t.includes(`axios`)&&c.push(`axios`),t.includes(`http.request`)&&c.push(`http.request`),t.includes(`https.request`)&&c.push(`https.request`),t.includes(`process.env`)&&c.push(`process.env`)}catch{}let l=Array.from(new Set(c));l.length>0?s.push({name:o.colors.cyan(t.name),status:o.colors.yellow(`⚠️ Warning`),details:`Contains network/env accesses: ${o.colors.bold(l.join(`, `))}. Ensure you trust the author.`}):s.push({name:o.colors.cyan(t.name),status:o.colors.green(`✅ Clean`),details:`No external network calls or env accesses detected.`})}let c=[`Plugin`,`Status`,`Audit Notes`],l=s.map(e=>[e.name,e.status,e.details]);console.log(`
7
+ const e=require(`../chunk-CU-zTemE.cjs`),t=require(`../doctor-VBPlQf7d.cjs`),n=require(`../node-JM9bx0mO.cjs`);let r=require(`vite`),i=require(`node:path`);i=e.t(i);let a=require(`node:fs`);a=e.t(a);let o=require(`@bdocs/dui`),s=require(`node:fs/promises`);s=e.t(s);let c=require(`@bdocs/ssg/node`),l=require(`cac`);l=e.t(l);function u(e){let t=e;for(;t&&t!==i.default.dirname(t);){if(a.default.existsSync(i.default.join(t,`.git`))||a.default.existsSync(i.default.join(t,`pnpm-workspace.yaml`)))return t;t=i.default.dirname(t)}t=e;let n=e;for(;t&&t!==i.default.dirname(t);)a.default.existsSync(i.default.join(t,`package.json`))&&(n=t),t=i.default.dirname(t);return n}let d=u(process.cwd());function f(e){if(!e)return;let t;if(typeof e==`string`)t=e;else if(e instanceof URL){if(e.protocol!==`file:`)return;t=e.pathname}else if(Buffer.isBuffer(e))t=e.toString();else return;let n=i.default.resolve(d,t),r=i.default.relative(d,n),a=r.startsWith(`..`)||i.default.isAbsolute(r),o=n.split(i.default.sep),s=o.some(e=>e.startsWith(`.env`)),c=o.some((e,t)=>{if(e===`node_modules`){let e=o[t+1];return!e||!e.startsWith(`.`)}return!1});if(a||s||c)throw Error(`[Boltdocs Security] Write/delete operation blocked on path: "${n}". Modifications are restricted to the project root, and cannot access .env or non-cache node_modules folders.`)}function p(e){return e==null?!1:typeof e==`number`?e!==0:typeof e==`string`?e.includes(`w`)||e.includes(`a`)||e.includes(`+`):!0}function m(){let e=a.default.writeFile;a.default.writeFile=function(t,...n){try{f(t)}catch(e){let t=n[n.length-1];if(typeof t==`function`){process.nextTick(()=>t(e));return}throw e}return e.call(a.default,t,...n)};let t=a.default.writeFileSync;a.default.writeFileSync=function(e,...n){return f(e),t.call(a.default,e,...n)};let n=a.default.rm;a.default.rm=function(e,...t){try{f(e)}catch(e){let n=t[t.length-1];if(typeof n==`function`){process.nextTick(()=>n(e));return}throw e}return n.call(a.default,e,...t)};let r=a.default.rmSync;a.default.rmSync=function(e,...t){return f(e),r.call(a.default,e,...t)};let i=a.default.unlink;a.default.unlink=function(e,...t){try{f(e)}catch(e){let n=t[t.length-1];if(typeof n==`function`){process.nextTick(()=>n(e));return}throw e}return i.call(a.default,e,...t)};let o=a.default.unlinkSync;a.default.unlinkSync=function(e,...t){return f(e),o.call(a.default,e,...t)};let c=a.default.mkdir;a.default.mkdir=function(e,...t){try{f(e)}catch(e){let n=t[t.length-1];if(typeof n==`function`){process.nextTick(()=>n(e));return}throw e}return c.call(a.default,e,...t)};let l=a.default.mkdirSync;a.default.mkdirSync=function(e,...t){return f(e),l.call(a.default,e,...t)};let u=a.default.rmdir;a.default.rmdir=function(e,...t){try{f(e)}catch(e){let n=t[t.length-1];if(typeof n==`function`){process.nextTick(()=>n(e));return}throw e}return u.call(a.default,e,...t)};let d=a.default.rmdirSync;a.default.rmdirSync=function(e,...t){return f(e),d.call(a.default,e,...t)};let m=a.default.appendFile;a.default.appendFile=function(e,...t){try{f(e)}catch(e){let n=t[t.length-1];if(typeof n==`function`){process.nextTick(()=>n(e));return}throw e}return m.call(a.default,e,...t)};let h=a.default.appendFileSync;a.default.appendFileSync=function(e,...t){return f(e),h.call(a.default,e,...t)};let g=a.default.copyFile;a.default.copyFile=function(e,t,...n){try{f(e),f(t)}catch(e){let t=n[n.length-1];if(typeof t==`function`){process.nextTick(()=>t(e));return}throw e}return g.call(a.default,e,t,...n)};let _=a.default.copyFileSync;a.default.copyFileSync=function(e,t,...n){return f(e),f(t),_.call(a.default,e,t,...n)};let v=a.default.rename;a.default.rename=function(e,t,...n){try{f(e),f(t)}catch(e){let t=n[n.length-1];if(typeof t==`function`){process.nextTick(()=>t(e));return}throw e}return v.call(a.default,e,t,...n)};let y=a.default.renameSync;a.default.renameSync=function(e,t,...n){return f(e),f(t),y.call(a.default,e,t,...n)};let b=a.default.createWriteStream;a.default.createWriteStream=function(e,...t){return f(e),b.call(a.default,e,...t)};let x=a.default.open;a.default.open=function(e,t,...n){if(p(typeof t==`function`?void 0:t))try{f(e)}catch(e){let r=n[n.length-1],i=typeof t==`function`?t:typeof r==`function`?r:void 0;if(i){process.nextTick(()=>i(e));return}throw e}return x.call(a.default,e,t,...n)};let S=a.default.openSync;a.default.openSync=function(e,t,...n){return p(t)&&f(e),S.call(a.default,e,t,...n)};let C=e=>{if(!e)return;let t=e.writeFile;t&&(e.writeFile=async function(n,...r){return f(n),t.call(e,n,...r)});let n=e.rm;n&&(e.rm=async function(t,...r){return f(t),n.call(e,t,...r)});let r=e.mkdir;r&&(e.mkdir=async function(t,...n){return f(t),r.call(e,t,...n)});let i=e.rmdir;i&&(e.rmdir=async function(t,...n){return f(t),i.call(e,t,...n)});let a=e.unlink;a&&(e.unlink=async function(t,...n){return f(t),a.call(e,t,...n)});let o=e.appendFile;o&&(e.appendFile=async function(t,...n){return f(t),o.call(e,t,...n)});let s=e.copyFile;s&&(e.copyFile=async function(t,n,...r){return f(t),f(n),s.call(e,t,n,...r)});let c=e.rename;c&&(e.rename=async function(t,n,...r){return f(t),f(n),c.call(e,t,n,...r)});let l=e.open;l&&(e.open=async function(t,n,...r){return p(n)&&f(t),l.call(e,t,n,...r)})};C(a.default.promises),C(s.default)}let h=!1;async function g(e=process.cwd(),r={}){if(!h){h=!0,t.d();try{n.S(await t.p(i.default.resolve(e,`docs`),e),e)}catch{}try{let t=await n.n(e,`development`);t.logLevel=`warn`,t.clearScreen=!1,r.port!==void 0&&(t.server=t.server||{},t.server.port=Number(r.port)),r.host!==void 0&&(t.server=t.server||{},t.server.host=r.host);let i=await(0,c.createServer)(t);await i.listen();let a=i.resolvedUrls;console.log((0,o.devServer)(a?.local?.[0]??`http://localhost:${r.port??5173}`,a?.network?.[0]??null)),i.bindCLIShortcuts({print:!1})}catch(e){(0,o.error)(`Failed to start dev server:`,e),process.exit(1)}}}async function _(e=process.cwd()){t.d();try{let t=await n.x().run({root:e,timing:{}});t.success||((0,o.error)(`Build failed at step "${t.failedStep}":`,t.error),process.exit(1)),(0,o.success)(`SSG build completed successfully in ${Math.round(t.timing.total)}ms!`),process.exit(0)}catch(e){(0,o.error)(`Build failed:`,e),process.exit(1)}}async function v(e=process.cwd(),t={}){try{let i=await n.n(e,`production`);i.logLevel=`warn`,i.clearScreen=!1,t.port!==void 0&&(i.preview=i.preview||{},i.preview.port=Number(t.port)),t.host!==void 0&&(i.preview=i.preview||{},i.preview.host=t.host);let a=(await(0,r.preview)(i)).resolvedUrls;console.log((0,o.previewServer)(a?.local?.[0]??`http://localhost:${t.port??4173}`,a?.network?.[0]??null))}catch(e){(0,o.error)(`Failed to start preview server:`,e),process.exit(1)}}function y(e){let t=[];if(!a.default.existsSync(e))return t;try{let n=a.default.readdirSync(e);for(let r of n){let n=i.default.join(e,r);a.default.statSync(n).isDirectory()?r!==`node_modules`&&r!==`.git`&&r!==`dist`&&r!==`coverage`&&t.push(...y(n)):/\.(js|mjs|cjs|ts|tsx|jsx)$/.test(r)&&t.push(n)}}catch{}return t}async function b(e=process.cwd()){(0,o.info)(`Starting static security audit of Boltdocs plugins...`);let n;try{n=await t.p(i.default.resolve(e,`docs`),e)}catch(e){(0,o.error)(`Failed to load Boltdocs configuration for audit:`,e),process.exit(1)}let r=n.plugins||[];if(r.length===0){(0,o.success)(`No plugins configured. Nothing to audit.`);return}let s=[];for(let t of r){if(!t.name)continue;let n=null;try{let{createRequire:r}=await import(`node:module`),a=r(i.default.resolve(e,`package.json`)).resolve(`${t.name}/package.json`);n=i.default.dirname(a)}catch{let r=i.default.resolve(e,`node_modules`,t.name);a.default.existsSync(r)&&(n=r)}if(!n){s.push({name:o.colors.cyan(t.name),status:o.colors.red(`❓ Unresolved`),details:`Could not locate plugin files in node_modules.`});continue}let r=y(n),c=[];for(let e of r)try{let t=a.default.readFileSync(e,`utf-8`);t.includes(`fetch(`)&&c.push(`fetch`),t.includes(`axios`)&&c.push(`axios`),t.includes(`http.request`)&&c.push(`http.request`),t.includes(`https.request`)&&c.push(`https.request`),t.includes(`process.env`)&&c.push(`process.env`)}catch{}let l=Array.from(new Set(c));l.length>0?s.push({name:o.colors.cyan(t.name),status:o.colors.yellow(`⚠️ Warning`),details:`Contains network/env accesses: ${o.colors.bold(l.join(`, `))}. Ensure you trust the author.`}):s.push({name:o.colors.cyan(t.name),status:o.colors.green(`✅ Clean`),details:`No external network calls or env accesses detected.`})}let c=[`Plugin`,`Status`,`Audit Notes`],l=s.map(e=>[e.name,e.status,e.details]);console.log(`
8
8
  `+(0,o.table)(c,l)+`
9
- `),s.some(e=>e.status.includes(`Warning`))?(0,o.warn)(`⚠️ One or more plugins have security warnings. Review the flags above.`):(0,o.success)(`✓ All plugins passed the static security check!`)}process.noDeprecation=!0,m(),(0,o.configure)({prefix:`boltdocs`,devServerTitle:`boltdocs dev server`,previewServerTitle:`boltdocs preview server`,updateCommand:`pnpm add boltdocs@latest`});const x=(0,l.default)(`boltdocs`);x.command(`dev [root]`,`Start development server`).action(g),x.command(`[root]`,`Start development server`).action(g),x.command(`build [root]`,`Build for production`).action(_),x.command(`preview [root]`,`Preview production build`).action(v),x.command(`audit [root]`,`Audit configured plugins for security warnings`).action(b),x.command(`doctor [root]`,`Check the health of your documentation`).option(`--fix`,`Automatically fix broken internal links and sync translations`).option(`--check-external`,`Verify external links (slower)`).option(`--init`,`Initialize doctor.json with default configuration`).option(`--budget`,`Check build performance against configured budgets`).action(async(e,t)=>{let{doctorAction:n}=await Promise.resolve().then(()=>require(`../doctor-DyNUVe96.cjs`));await n(e,t)}),x.command(`generate-changelog <file>`,`Generate changelog documentation from CHANGELOG.md`).option(`-o, --output <path>`,`Output folder (default: docs/changelog)`,{default:`docs/changelog`}).option(`-t, --title <text>`,`Title for changelog pages`,{default:`Changelog`}).option(`--infer-tab`,`Infer tab from folder name (default: true)`,{default:!0}).option(`-l, --limit <number>`,`Limit number of versions to generate`).action(async(e,t)=>{let{generateChangelog:n}=await Promise.resolve().then(()=>require(`../generator-CC2yHzhZ.cjs`));await n(e,{output:t.output,title:t.title,inferTab:t.inferTab,limit:t.limit?parseInt(String(t.limit),10):void 0})}),x.help(),x.version(`2.0.0`),x.parse();
9
+ `),s.some(e=>e.status.includes(`Warning`))?(0,o.warn)(`⚠️ One or more plugins have security warnings. Review the flags above.`):(0,o.success)(`✓ All plugins passed the static security check!`)}process.noDeprecation=!0,m(),(0,o.configure)({prefix:`boltdocs`,devServerTitle:`boltdocs dev server`,previewServerTitle:`boltdocs preview server`,updateCommand:`pnpm add boltdocs@latest`});const x=(0,l.default)(`boltdocs`);x.command(`dev [root]`,`Start development server`).option(`--port <port>`,`Port to listen on`).option(`--host [host]`,`Host to bind to`).action(g),x.command(`[root]`,`Start development server`).option(`--port <port>`,`Port to listen on`).option(`--host [host]`,`Host to bind to`).action(g),x.command(`build [root]`,`Build for production`).action(_),x.command(`preview [root]`,`Preview production build`).option(`--port <port>`,`Port to listen on`).option(`--host [host]`,`Host to bind to`).action(v),x.command(`audit [root]`,`Audit configured plugins for security warnings`).action(b),x.command(`doctor [root]`,`Check the health of your documentation`).option(`--fix`,`Automatically fix broken internal links and sync translations`).option(`--check-external`,`Verify external links (slower)`).option(`--init`,`Initialize doctor.json with default configuration`).option(`--budget`,`Check build performance against configured budgets`).action(async(e,t)=>{let{doctorAction:n}=await Promise.resolve().then(()=>require(`../doctor-DT4jh07O.cjs`));await n(e,t)}),x.command(`generate-changelog <file>`,`Generate changelog documentation from CHANGELOG.md`).option(`-o, --output <path>`,`Output folder (default: docs/changelog)`,{default:`docs/changelog`}).option(`-t, --title <text>`,`Title for changelog pages`,{default:`Changelog`}).option(`--infer-tab`,`Infer tab from folder name (default: true)`,{default:!0}).option(`-l, --limit <number>`,`Limit number of versions to generate`).action(async(e,t)=>{let{generateChangelog:n}=await Promise.resolve().then(()=>require(`../generator-CC2yHzhZ.cjs`));await n(e,{output:t.output,title:t.title,inferTab:t.inferTab,limit:t.limit?parseInt(String(t.limit),10):void 0})}),x.help(),x.version(`2.0.0`),x.parse();