boltdocs 3.0.2 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/README.md +2 -18
  2. package/dist/{adapters-C5AWWGfb.cjs → adapters-uGz-UKQa.cjs} +1 -1
  3. package/dist/{banner-DNSkgUsO.d.cts → banner-DdSgCs4G.d.cts} +1 -1
  4. package/dist/{banner-CfdalYLL.d.ts → banner-DjujkctF.d.ts} +1 -1
  5. package/dist/cache-B0C2i0yP.mjs +6 -0
  6. package/dist/cache-CfRTUzWC.cjs +6 -0
  7. package/dist/chunk-hT5z_Zn9-DsJawvsz.mjs +6 -0
  8. package/dist/chunk-hT5z_Zn9-SKz6VFXu.cjs +6 -0
  9. package/dist/client/index.cjs +227 -113
  10. package/dist/client/index.d.cts +57 -12
  11. package/dist/client/index.d.ts +57 -12
  12. package/dist/client/index.js +227 -114
  13. package/dist/client/mdx.cjs +1 -1
  14. package/dist/client/mdx.js +1 -1
  15. package/dist/client/primitives.cjs +4 -4
  16. package/dist/client/primitives.d.cts +1 -1
  17. package/dist/client/primitives.d.ts +1 -1
  18. package/dist/client/primitives.js +4 -4
  19. package/dist/client/theme/neutral.css +1 -3
  20. package/dist/{config-JGkMJoJQ.cjs → config-BxsogK5A.cjs} +1 -1
  21. package/dist/config-DAgpZyh6.mjs +7 -0
  22. package/dist/config-DrRQYDCI.cjs +7 -0
  23. package/dist/{docs-layout-3TpAt6MB.cjs → docs-layout-D1buSdua.cjs} +1 -1
  24. package/dist/{docs-layout-6FQ8__ok.js → docs-layout-DyLDBwS6.js} +1 -1
  25. package/dist/{doctor-DQxLM202.cjs → doctor-BadGEhXv.cjs} +1 -1
  26. package/dist/{doctor-BR1B2Mkz.cjs → doctor-DPDcRKM1.cjs} +1 -1
  27. package/dist/{doctor-3MheVMwd.mjs → doctor-vDsUDgqp.mjs} +1 -1
  28. package/dist/escape-string-regexp-AG8q1e25-9Un9V90q.mjs +6 -0
  29. package/dist/escape-string-regexp-AG8q1e25-bJ9Ixe7c.cjs +6 -0
  30. package/dist/esm-shims-DSep1HcR.mjs +6 -0
  31. package/dist/{icons-dev-kJyGWNeg.js → icons-dev-CHZOwhQA.js} +8 -3
  32. package/dist/{icons-dev-BryEFkJu.cjs → icons-dev-YtDoLUsb.cjs} +8 -3
  33. package/dist/{image-C9md50h2.js → image-5WsgWYTh.js} +2 -2
  34. package/dist/{image-CR6UlaI5.cjs → image-Hb105Gu6.cjs} +2 -2
  35. package/dist/lib-BR0SoanK-CLswltLI.cjs +6 -0
  36. package/dist/lib-BR0SoanK-DcYeDrE6.mjs +6 -0
  37. package/dist/lib-DPoCz1YB-CLYXwKST.cjs +6 -0
  38. package/dist/lib-DPoCz1YB-CyGOqgSO.mjs +6 -0
  39. package/dist/{mdx-DhyMkc35.js → mdx-Bv-pS6-O.js} +6 -2
  40. package/dist/{mdx-DJBg5DuL.cjs → mdx-CDUcJmye.cjs} +6 -2
  41. package/dist/micromark-util-character-5KqJafVT-C6gnc770.cjs +6 -0
  42. package/dist/micromark-util-character-5KqJafVT-DkPKsbgn.mjs +6 -0
  43. package/dist/node/cache.cjs +6 -0
  44. package/dist/node/cache.d.cts +83 -0
  45. package/dist/node/cache.d.mts +83 -0
  46. package/dist/node/cache.mjs +6 -0
  47. package/dist/node/cli-entry.cjs +3 -3
  48. package/dist/node/cli-entry.mjs +3 -3
  49. package/dist/node/index.cjs +1 -1
  50. package/dist/node/index.d.cts +10 -467
  51. package/dist/node/index.d.mts +12 -468
  52. package/dist/node/index.mjs +1 -1
  53. package/dist/node/mdx/shiki-adapter.cjs +6 -0
  54. package/dist/node/mdx/shiki-adapter.d.cts +3 -0
  55. package/dist/node/mdx/shiki-adapter.d.mts +3 -0
  56. package/dist/node/mdx/shiki-adapter.mjs +6 -0
  57. package/dist/node-BDBv8CT6.mjs +104 -0
  58. package/dist/node-DFV_FV0y.mjs +6 -0
  59. package/dist/node-DqsP7kXz.cjs +6 -0
  60. package/dist/node-yFmAavND.cjs +104 -0
  61. package/dist/{package-_dCCKVvG.mjs → package-CoHWTf0N.mjs} +1 -1
  62. package/dist/{package-CEDhVAfO.cjs → package-_-Oa8-qN.cjs} +1 -1
  63. package/dist/{parser-D0QHIQsi.mjs → parser-BZJgAa9E.mjs} +1 -1
  64. package/dist/{parser-CNIPHx4s.cjs → parser-DlanzESE.cjs} +1 -1
  65. package/dist/plugin-BVuwx5D9.cjs +73 -0
  66. package/dist/plugin-BoxD91Yh.mjs +73 -0
  67. package/dist/rehype-slug--ZOxZ-_K-BNeYC4aT.cjs +6 -0
  68. package/dist/rehype-slug--ZOxZ-_K-CjIQEJCs.mjs +6 -0
  69. package/dist/remark-frontmatter-wFYRLcCt-CutW0gA3.mjs +8 -0
  70. package/dist/remark-frontmatter-wFYRLcCt-ENB5qG3y.cjs +8 -0
  71. package/dist/remark-gfm-B8TMkQbX-CjUJo8Rd.cjs +21 -0
  72. package/dist/remark-gfm-B8TMkQbX-Ctu0VV1_.mjs +21 -0
  73. package/dist/rollup-DMqoG11U-CKcJ37u_.mjs +59 -0
  74. package/dist/rollup-DMqoG11U-DKdxvZIj.cjs +59 -0
  75. package/dist/routes-BN2XbGcT.mjs +6 -0
  76. package/dist/routes-Cnq8xTCv.cjs +6 -0
  77. package/dist/{routes-BajCwrvX.cjs → routes-D_S9kjkS.cjs} +1 -1
  78. package/dist/{search-dialog-CW1f6dn6.cjs → search-dialog-BIuxGQsg.cjs} +1 -1
  79. package/dist/{search-dialog-Cx7aGW3U.cjs → search-dialog-BbtxA1uT.cjs} +2 -2
  80. package/dist/{search-dialog-D4rplZMv.cjs → search-dialog-BpNULmrl.cjs} +1 -1
  81. package/dist/{search-dialog-DDopgbKM.js → search-dialog-DC7oXU-5.js} +2 -2
  82. package/dist/{search-dialog-DaeSPvEo.js → search-dialog-PJrFRU5G.js} +1 -1
  83. package/dist/{search-dialog-BNdRV60O.js → search-dialog-gp9lrJXm.js} +1 -1
  84. package/dist/server/index.cjs +1 -1
  85. package/dist/server/index.d.mts +1 -1
  86. package/dist/shiki-adapter-CK3llqw2.mjs +6 -0
  87. package/dist/shiki-adapter-fS94vy-z.d.mts +534 -0
  88. package/dist/shiki-adapter-l2kEP5rn.d.cts +534 -0
  89. package/dist/{sidebar-BAKgJ-Er.d.ts → sidebar-DH2iPKXM.d.cts} +187 -10
  90. package/dist/{sidebar-7gIifpBX.d.cts → sidebar-DknLUI1R.d.ts} +187 -10
  91. package/package.json +16 -5
  92. package/src/shared/types.ts +177 -10
  93. package/dist/cache-DETwlACe.cjs +0 -6
  94. package/dist/cache-SF59enb3.mjs +0 -6
  95. package/dist/config-B5uVv5q4.cjs +0 -7
  96. package/dist/config-D3_zDkHh.mjs +0 -7
  97. package/dist/node-B9JSyEIU.mjs +0 -105
  98. package/dist/node-Cedquois.cjs +0 -105
  99. package/dist/plugin-WYNORxp1.cjs +0 -68
  100. package/dist/plugin-YWNVRpws.mjs +0 -68
  101. package/dist/routes-CyrnmVuG.mjs +0 -6
  102. package/dist/routes-D6Tuu7Fs.cjs +0 -6
  103. package/dist/shiki-adapter-CXEGRnjr.mjs +0 -6
  104. package/dist/shiki-adapter-Mr8_oT_9.cjs +0 -6
  105. /package/dist/{csp-CBysWlAf.cjs → csp-BX06rvdg.cjs} +0 -0
  106. /package/dist/{csp-gaZ51xzq.mjs → csp-z2D0FuRW.mjs} +0 -0
  107. /package/dist/{generator-DtUU3Cfk.cjs → generator-BN75lJOv.cjs} +0 -0
  108. /package/dist/{handler-Dzf4dSnV.cjs → handler-1LRMYeI4.cjs} +0 -0
  109. /package/dist/{headers-CXyf0auY.mjs → headers-CL0pMcwm.mjs} +0 -0
  110. /package/dist/{headers-BXKxiPUv.cjs → headers-YpD10rDb.cjs} +0 -0
  111. /package/dist/{index-CdJv4ocW.d.mts → index-DJYJzs-Z.d.mts} +0 -0
  112. /package/dist/{meta-loader-C4Hu9RN9.mjs → meta-loader-Bq-MjTXB.mjs} +0 -0
  113. /package/dist/{meta-loader-C9MKjAs0.cjs → meta-loader-CTB62-Mo.cjs} +0 -0
@@ -0,0 +1,7 @@
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-Ds5LZdWN.cjs`),t=require(`./errors-Dx6JHoKE.cjs`),n=require(`./types-generator-CYcHkDzZ.cjs`);let r=require(`node:path`);r=e.n(r);let i=require(`node:fs`);i=e.n(i);let a=require(`zod`),o=require(`@bdocs/dui`);function s(e){return e}const c=a.z.object({icon:a.z.string().max(50),link:a.z.string().url()});a.z.object({text:a.z.string().max(2e3).optional()});const l=a.z.object({processor:a.z.enum([`unified`,`satteri`]).optional()}),u=a.z.object({name:a.z.string(),enforce:a.z.enum([`pre`,`post`]).optional(),version:a.z.string().optional(),boltdocsVersion:a.z.string().optional(),remarkPlugins:a.z.array(a.z.unknown()).optional(),rehypePlugins:a.z.array(a.z.unknown()).optional(),vitePlugins:a.z.array(a.z.unknown()).optional(),components:a.z.record(a.z.string(),a.z.string()).optional(),hooks:a.z.record(a.z.string(),a.z.unknown()).optional()}),d=a.z.object({title:a.z.union([a.z.string(),a.z.record(a.z.string(),a.z.string())]).optional(),description:a.z.union([a.z.string(),a.z.record(a.z.string(),a.z.string())]).optional(),logo:a.z.union([a.z.string(),a.z.object({dark:a.z.string(),light:a.z.string(),alt:a.z.string().optional(),width:a.z.number().optional(),height:a.z.number().optional()})]).optional(),navbar:a.z.array(a.z.object({label:a.z.union([a.z.string(),a.z.record(a.z.string(),a.z.string())]),href:a.z.string(),items:a.z.array(a.z.object({label:a.z.union([a.z.string(),a.z.record(a.z.string(),a.z.string())]),href:a.z.string()})).optional()})).optional(),sidebar:a.z.record(a.z.string(),a.z.array(a.z.object({text:a.z.string(),link:a.z.string()}))).optional(),sidebarGroups:a.z.record(a.z.string(),a.z.object({title:a.z.union([a.z.string(),a.z.record(a.z.string(),a.z.string())]).optional(),icon:a.z.string().optional()})).optional(),socialLinks:a.z.array(c).optional(),editLink:a.z.string().refine(e=>!e||e.includes(`:path`),{message:`editLink must contain ':path' placeholder if specified`}).optional(),communityHelp:a.z.string().url().optional(),version:a.z.string().max(50).optional(),githubRepo:a.z.string().max(100).optional(),favicon:a.z.string().optional(),tabs:a.z.array(a.z.object({id:a.z.string(),text:a.z.union([a.z.string(),a.z.record(a.z.string(),a.z.string())]),icon:a.z.string().optional()})).optional(),codeTheme:a.z.union([a.z.string(),a.z.object({light:a.z.string(),dark:a.z.string()})]).optional()}),f=a.z.union([a.z.string(),a.z.object({rules:a.z.array(a.z.object({userAgent:a.z.string(),allow:a.z.union([a.z.string(),a.z.array(a.z.string())]).optional(),disallow:a.z.union([a.z.string(),a.z.array(a.z.string())]).optional()})).optional(),sitemaps:a.z.array(a.z.string().url()).optional()})]),p=a.z.object({defaultLocale:a.z.string(),locales:a.z.union([a.z.record(a.z.string(),a.z.string()),a.z.array(a.z.string())]).transform(e=>Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e),localeConfigs:a.z.record(a.z.string(),a.z.object({label:a.z.string().optional(),direction:a.z.enum([`ltr`,`rtl`]).optional(),htmlLang:a.z.string().optional(),calendar:a.z.string().optional()})).optional()}),m=a.z.object({defaultVersion:a.z.string(),prefix:a.z.string().optional(),versions:a.z.array(a.z.object({label:a.z.string(),path:a.z.string()}))}),h=a.z.object({headers:a.z.record(a.z.string(),a.z.string()).optional(),enableCSP:a.z.boolean().optional(),customHeaders:a.z.record(a.z.string(),a.z.string()).optional()}),g=a.z.object({google:a.z.string().optional(),bing:a.z.string().optional(),yandex:a.z.string().optional(),pinterest:a.z.string().optional(),facebook:a.z.string().optional()}),_=a.z.object({metatags:a.z.record(a.z.string(),a.z.string()).optional(),indexing:a.z.enum([`all`,`public`]).optional(),thumbnails:a.z.object({background:a.z.string().optional()}).optional(),verification:g.optional()}),v=a.z.object({measurementId:a.z.string().min(1,`Measurement ID is required for GA4`),debug:a.z.boolean().optional(),anonymizeIp:a.z.boolean().optional(),sendPageView:a.z.boolean().optional(),cookieFlags:a.z.string().optional(),autoTrack:a.z.object({pageViews:a.z.boolean().optional(),downloads:a.z.boolean().optional(),externalLinks:a.z.boolean().optional(),search:a.z.boolean().optional()}).optional()}),y=a.z.object({tagId:a.z.string().min(1,`Tag ID is required for GTM`),dataLayerName:a.z.string().optional(),preview:a.z.string().optional()}),b=a.z.object({appId:a.z.string().min(1,`Algolia App ID is required`),apiKey:a.z.string().min(1,`Algolia API Key is required`),indexName:a.z.string().min(1,`Algolia Index Name is required`)}),x=a.z.object({repo:a.z.string().min(1,`Giscus repository is required`),repoId:a.z.string().min(1,`Giscus repository ID is required`),category:a.z.string().optional(),categoryId:a.z.string().optional(),mapping:a.z.enum([`pathname`,`url`,`title`,`og:title`,`specific`,`number`]).optional(),strict:a.z.union([a.z.enum([`0`,`1`]),a.z.boolean()]).optional(),reactionsEnabled:a.z.union([a.z.enum([`0`,`1`]),a.z.boolean()]).optional(),emitMetadata:a.z.union([a.z.enum([`0`,`1`]),a.z.boolean()]).optional(),inputPosition:a.z.enum([`top`,`bottom`]).optional(),theme:a.z.string().optional(),darkTheme:a.z.string().optional(),lang:a.z.string().optional(),loading:a.z.enum([`lazy`,`eager`]).optional()}),S=a.z.object({enabled:a.z.boolean(),owner:a.z.string().min(1,`GitHub owner is required`),repo:a.z.string().min(1,`GitHub repository name is required`),categorySlug:a.z.string().optional(),endpoint:a.z.string().optional()}),C=a.z.object({analytics:a.z.boolean().optional(),speedInsights:a.z.boolean().optional()}),w=a.z.object({apiKey:a.z.string().min(1,`API key is required for PostHog`),host:a.z.string().url().optional(),capturePageview:a.z.boolean().optional(),capturePageleave:a.z.boolean().optional(),sessionRecording:a.z.boolean().optional(),autocapture:a.z.boolean().optional()}),T=a.z.object({ga4:v.optional(),gtm:y.optional(),vercel:C.optional(),posthog:w.optional()}),E=a.z.object({algolia:b.optional()}),D=a.z.object({giscus:x.optional(),custom:S.optional()}),O=a.z.object({analytics:T.optional(),search:E.optional(),feedback:D.optional()}),k=a.z.object({visible:a.z.boolean().optional(),environments:a.z.array(a.z.string()).optional()}),A=a.z.object({siteUrl:a.z.string().url().optional(),docsDir:a.z.string().optional(),base:a.z.string().optional(),theme:d.optional(),i18n:p.optional(),versions:m.optional(),mdx:l.optional(),plugins:a.z.array(u).optional(),robots:f.optional(),security:h.optional(),seo:_.optional(),integrations:O.optional(),drafts:k.optional(),featureFlags:a.z.record(a.z.string(),a.z.union([a.z.boolean(),a.z.string()])).optional(),vite:a.z.record(a.z.string(),a.z.unknown()).optional()}),j=[`boltdocs.config.js`,`boltdocs.config.mjs`,`boltdocs.config.ts`];async function M(e,n=process.cwd()){let a=n,s={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`}}},c={};for(let e of j){let t=r.default.resolve(a,e);if(i.default.existsSync(t))try{let{loadConfigFromFile:e}=await import(`vite`),n=await e({command:`serve`,mode:`development`},t,a);if(n){c=n.config;break}}catch(t){t instanceof Error&&(0,o.warn)(`Failed to load config from ${e}: ${t}`)}}let l={title:c.title,description:c.description,logo:c.logo,favicon:c.favicon,navbar:c.navbar,sidebar:c.sidebar,sidebarGroups:c.theme?.sidebarGroups,socialLinks:c.socialLinks,githubRepo:c.githubRepo,tabs:c.tabs,codeTheme:c.codeTheme,communityHelp:c.communityHelp,version:c.version,editLink:c.editLink,...c.theme||{}},u=Object.fromEntries(Object.entries(l).filter(([e,t])=>t!==void 0));u.navbar&&=u.navbar.map(e=>({label:e.label||``,href:e.href||``,items:e.items}));let d={docsDir:r.default.resolve(e),theme:{...s.theme,...u},i18n:c.i18n?{...c.i18n,locales:Array.isArray(c.i18n.locales)?Object.fromEntries(c.i18n.locales.map(e=>[e,e])):c.i18n.locales}:void 0,versions:c.versions,siteUrl:c.siteUrl,base:c.base,seo:c.seo,plugins:c.plugins||[],robots:c.robots,security:c.security,integrations:c.integrations,vite:c.vite},f=A.safeParse(d);if(!f.success)throw new t.r(`Invalid Boltdocs configuration:\n${f.error.issues.map(e=>` - ${e.path.join(`.`)}: ${e.message}`).join(`
7
+ `)}`);return f.data}async function N(e,t=process.cwd()){let r=await M(e,t);return n.t(r,e,t),r}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return j}});
@@ -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-BryEFkJu.cjs');
6
+ const require_icons_dev = require('./icons-dev-YtDoLUsb.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");
@@ -3,7 +3,7 @@
3
3
  * Copyright (c) 2026 Jesus Alcala
4
4
  * Licensed under the MIT License.
5
5
  */
6
- import { A as ChevronRight, D as Check, S as normalizePath, _ as Link$1, b as useLocalizedTo, k as ChevronLeft, rt as useConfig, tt as icons_exports, y as cn } from "./icons-dev-kJyGWNeg.js";
6
+ import { A as ChevronRight, D as Check, S as normalizePath, _ as Link$1, b as useLocalizedTo, k as ChevronLeft, rt as useConfig, tt as icons_exports, y as cn } from "./icons-dev-CHZOwhQA.js";
7
7
  import { Children, createContext, use, useContext, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
8
8
  import { useLocation } from "react-router-dom";
9
9
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -3,5 +3,5 @@
3
3
  * Copyright (c) 2026 Jesus Alcala
4
4
  * Licensed under the MIT License.
5
5
  */
6
- const e=require(`./chunk-Ds5LZdWN.cjs`),t=require(`./utils-Bz1tG9Dg.cjs`),n=require(`./pages-external-CX2uyW95.cjs`),r=require(`./config-B5uVv5q4.cjs`),i=require(`./node/cli-entry.cjs`);let a=require(`node:path`);a=e.n(a);let o=require(`node:fs`);o=e.n(o);let s=require(`@bdocs/dui`),c=require(`fdir`),l=require(`picomatch`);l=e.n(l);let u=require(`fastest-levenshtein`);const d={$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 f(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 p(e,t,n){return e.doctorConfig.severity[t]||n}async function m(e,t){o.default.existsSync(t)||o.default.mkdirSync(t,{recursive:!0});let n=a.default.basename(e),r=new Date().toISOString().replace(/[:.]/g,`-`),i=a.default.join(t,`${n}.${r}.bak`);o.default.copyFileSync(e,i)}const h=new Map;function g(e){let n=h.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 h.set(e,r),r}const _=new Map;function v(e){if(_.has(e))return _.get(e);let t=!1;try{t=o.default.existsSync(e)&&o.default.statSync(e).isFile()}catch{t=!1}return _.set(e,t),t}async function y(e){let t=a.default.resolve(e,`doctor.json`);if(o.default.existsSync(t))try{let e=JSON.parse(o.default.readFileSync(t,`utf-8`));return{...d,...e,checks:{...d.checks,...e.checks,metadata:{...d.checks.metadata,...e.checks?.metadata},links:{...d.checks.links,...e.checks?.links},i18n:{...d.checks.i18n,...e.checks?.i18n},performance:{...d.checks.performance,...e.checks?.performance,budgets:{...d.checks.performance?.budgets,...e.checks?.performance?.budgets}}},fix:{...d.fix,...e.fix},reporting:{...d.reporting,...e.reporting},severity:{...d.severity,...e.severity},exclude:[...d.exclude,...e.exclude||[]]}}catch(e){(0,s.warn)(`Failed to parse doctor.json: ${e}`)}return d}async function b(e,r=process.cwd(),i,s){let l=a.default.resolve(r,`.boltdocs`,`generated`);o.default.existsSync(l)||o.default.mkdirSync(l,{recursive:!0});let u=s;u||=await new c.fdir().withFullPaths().filter(e=>e.endsWith(`.md`)||e.endsWith(`.mdx`)).crawl(e).withPromise();let d=i?.base||`/docs`,f=[];for(let n=0;n<u.length;n+=100){let r=u.slice(n,n+100),i=await Promise.all(r.map(async n=>{let r=a.default.isAbsolute(n)?n:a.default.resolve(e,n),i=a.default.relative(e,r),{data:o}=await g(r),s;return s=o.permalink?o.permalink.startsWith(`/`)?o.permalink:`/${o.permalink}`:t.a(i),d===`/`?s:(d.endsWith(`/`)?d:d+`/`)+(s.startsWith(`/`)?s.substring(1):s)}));f.push(...i)}f.includes(d)||f.push(d);let p=n.t(e,i);for(let e of p)f.includes(e)||f.push(e);let m={routes:Array.from(new Set(f)).sort(),timestamp:Date.now()};return o.default.writeFileSync(a.default.resolve(l,`link-tree.json`),JSON.stringify(m,null,2)),m}function x(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,u.distance)(i,a)/Math.max(i.length,a.length);return o>.8?o*.95:1-(0,u.distance)(e,t)/Math.max(e.length,t.length)}const S=new Map;function C(e,t){if(S.has(e))return S.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=x(e,a);c>i&&(i=c,r=a)}let a={bestMatch:r,similarity:i};return S.set(e,a),a}async function w(e){let n=[];if(!e.doctorConfig.checks.metadata.enabled)return n;let{titleMin:r,titleMax:i,descriptionMin:o}=e.doctorConfig.checks.metadata,s=new Map;for(let c of e.files){let l=t.u(a.default.relative(e.docsDir,c));try{let{raw:a,data:u}=await g(c);if(a.trim().startsWith(`---`)&&a.split(`---`).length>=3&&Object.keys(u).length===0){let t=p(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._.safeParse(u);if(!d.success){let t=p(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=p(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=p(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<r){let i=p(e,`shortMetadata`,`low`);i!==`off`&&n.push({file:l,level:i,message:`Title is too short (${t.length} chars).`,suggestion:`Titles should be at least ${r} characters for better SEO.`})}else if(t.length>i){let r=p(e,`shortMetadata`,`low`);r!==`off`&&n.push({file:l,level:r,message:`Title is too long (${t.length} chars).`,suggestion:`Titles should be under ${i} characters.`})}let a=s.get(t)||[];a.push(l),s.set(t,a)}if(u.description&&String(u.description).length<o){let t=p(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=p(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=p(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 T(e){let n=[],{internal:r,external:i,ignore:c,timeout:l,concurrency:u}=e.doctorConfig.checks.links;if(!r&&!i&&!e.options.checkExternal)return n;let d=/(?:\[.*?\]\((.*?)\))|(?:href=["']([^"']+)["'])/g,f=new Set,m=5e5;for(let s of e.files){let l=t.u(a.default.relative(e.docsDir,s)),{content:u}=await g(s),_=[...(u.length>m?u.slice(0,m):u).replace(/```[\s\S]*?```/g,``).replace(/`[^`\n]*`/g,``).matchAll(d)];for(let t of _){let u=t[1]||t[2],d=!!t[1];if(!u||c.some(e=>u.includes(e)))continue;if(/^https?:\/\//i.test(u)){(i||e.options.checkExternal)&&f.add({url:u,file:s});continue}if(!r||/^(mailto|tel|#)/i.test(u))continue;let m;try{m=decodeURIComponent(u.split(`#`)[0].split(`?`)[0])}catch{m=u.split(`#`)[0].split(`?`)[0]}if(!m)continue;let g=!1,_=``;if(m.startsWith(`/`))if(e.routeIndex.has(m)||e.routeIndexWithSlash.has(m)||e.routeIndexWithoutSlash.has(m))g=!0;else{let t=e.basePrefix+(m.startsWith(`/`)?m:`/`+m);if(e.routeIndex.has(t)||e.routeIndexWithSlash.has(t))g=!1,_=t;else{let t=e.config.base!==`/`&&m.startsWith(e.config.base||`/`)?m.substring((e.config.base||`/`).length):m,n=t.startsWith(`/`)?t.substring(1):t;_=a.default.join(e.docsDir,n),g=[``,`.md`,`.mdx`,`/index.md`,`/index.mdx`].some(e=>v(_+e))}}else _=a.default.resolve(a.default.dirname(s),m),g=[``,`.md`,`.mdx`,`/index.md`,`/index.mdx`].some(e=>v(_+e));if(!g){let{bestMatch:t,similarity:r}=C(m,e.linkTree.routes),i=!1,a=e.basePrefix+(m.startsWith(`/`)?m:`/`+m);(e.routeIndex.has(a)||e.routeIndexWithSlash.has(a))&&(t=a,r=1,i=!0);let c=r>.6||i,f=r>.75&&t!==m||i,g=p(e,`brokenLink`,`high`);g!==`off`&&n.push({file:l,level:g,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=o.default.readFileSync(s,`utf-8`).replace(n,r);o.default.writeFileSync(s,i),h.delete(s)}:void 0})}}}if(f.size>0){(0,s.info)(s.colors.gray(`Verifying ${f.size} external links...`));let r=new Map;for(let e of f)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(),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(r.keys()),c=[];for(let e=0;e<o.length;e+=u){let t=o.slice(e,e+u),n=await Promise.allSettled(t.map(i));c.push(...n.map(e=>e.status===`fulfilled`?e.value:{url:`unknown`,ok:!1,error:e.reason}))}for(let i of c)if(!i.ok){let o=p(e,`brokenLink`,`warning`);if(o!==`off`){let s=r.get(i.url)||[];for(let r of s)n.push({file:t.u(a.default.relative(e.docsDir,r)),level:o,message:`Broken external link: "${i.url}"`,suggestion:`Verify the URL or update it if it's permanently down. Error: ${i.error||`Status >= 400`}`})}}}return n}async function E(e){let n=[];if(!e.doctorConfig.checks.i18n.enabled||!e.config.i18n)return n;let{defaultLocale:r,locales:i}=e.config.i18n,s=Object.keys(i),c=s.filter(e=>e!==r);for(let i of e.files){let l=t.u(a.default.relative(e.docsDir,i)),u=l.split(`/`),d=u[0];if(d===r){let t=u.slice(1).join(`/`);for(let r of c){let s=a.default.join(e.docsDir,r,t);if(!v(s)){let c=p(e,`missingTranslation`,`warning`);c!==`off`&&n.push({file:l,level:c,message:`Missing translation for locale "${r}"`,suggestion:`Create a version at "${r}/${t}".`,fix:async()=>{let e=a.default.dirname(s);o.default.existsSync(e)||o.default.mkdirSync(e,{recursive:!0}),o.default.copyFileSync(i,s)}})}}}else if(s.includes(d)){let t=u.slice(1).join(`/`);if(!v(a.default.join(e.docsDir,r,t))){let a=p(e,`missingTranslation`,`low`);a!==`off`&&n.push({file:l,level:a,message:`Orphaned translation (source missing in "${r}")`,suggestion:`Remove this file or create the source at "${r}/${t}".`,fix:async()=>{o.default.unlinkSync(i)}})}}}return n}async function D(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=p(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}=C(r.link,e.linkTree.routes),a=i>.6,o=p(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=p(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 O(e){let t=[],n=e.doctorConfig.checks.performance;if(!n?.enabled)return t;let r=a.default.resolve(e.root,`.boltdocs`,`reports`,`performance.json`);if(!o.default.existsSync(r))return t.push({file:`(build)`,level:p(e,`budgetExceeded`,`warning`),message:"Performance metrics not found. Run `boltdocs build` first."}),t;let i;try{i=JSON.parse(o.default.readFileSync(r,`utf-8`))}catch{return t.push({file:`(build)`,level:p(e,`budgetExceeded`,`warning`),message:`Failed to parse performance metrics file.`}),t}let s=n.budgets,c=p(e,`budgetExceeded`,`warning`),l=f(s?.maxJSBundleSize,1/0),u=f(s?.maxCSSBundleSize,1/0),d=f(s?.maxPageHTMLSize,1/0),m=s?.maxImagesKB??1/0,h=s?.maxBuildTime??1/0,g=s?.maxFontCount??1/0;if(l!==1/0&&i.totalJSBundleSize>l){let e=(i.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&&i.totalCSSBundleSize>u){let e=(i.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 i.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 _=m*1024;if(m!==1/0&&i.totalImagesSize>_){let e=(i.totalImagesSize/1024).toFixed(0);t.push({file:`(build)`,level:c,message:`Image assets exceed budget: ${e}kb > ${m}kb`,suggestion:`Optimize images with lossy compression or use next-gen formats (webp/avif).`})}if(h!==1/0&&i.buildTime>h){let e=(i.buildTime/1e3).toFixed(1),n=(h/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 g!==1/0&&i.fontCount>g&&t.push({file:`(build)`,level:c,message:`Font files exceed budget: ${i.fontCount} > ${g}`,suggestion:`Reduce the number of font families or use variable fonts.`}),t}async function k(e){let t=a.default.resolve(e,`doctor.json`);if(o.default.existsSync(t)){(0,s.warn)(`"doctor.json" already exists at ${e}.`);return}try{o.default.writeFileSync(t,JSON.stringify(d,null,2)),(0,s.success)(`Created "doctor.json" with default configuration.`)}catch(e){(0,s.error)(`Failed to create "doctor.json": ${e}`)}}async function A(e=process.cwd(),t={}){if(t.init){await k(e);return}i.t();try{let n=await y(e),{format:i}=n.reporting,u=performance.now(),d=await r.n(`docs`,e),f=a.default.resolve(e,`docs`);o.default.existsSync(f)||(i===`pretty`&&(0,s.error)(`Docs dir not found at ${f}`),process.exit(1)),i===`pretty`&&console.log((0,s.double)([` ${s.colors.dim(`Docs dir:`)} ${f}`,` ${s.colors.dim(`Reports:`)} ${e}/.boltdocs/reports/`],{title:`✦ DOCTOR — Documentation Health Check`})),i===`pretty`&&(0,s.info)(s.colors.dim(`🔍 Discovering files and routes...`));let p=(0,l.default)(n.exclude||[]),h=await new c.fdir().withFullPaths().filter(e=>{if(!(e.endsWith(`.md`)||e.endsWith(`.mdx`)))return!1;let t=a.default.relative(f,e).replace(/\\/g,`/`),n=t.split(`/`).some(e=>e.startsWith(`_`)&&e!==`_index.md`&&e!==`_index.mdx`);return!p(t)&&!n}).crawl(f).withPromise();for(let e of h)_.set(e,!0);let g=await b(f,e,d,h),v=d.base||`/`,x=v===`/`?``:v.endsWith(`/`)?v.slice(0,-1):v,S={root:e,docsDir:f,config:d,doctorConfig:n,linkTree:g,files:h,options:t,routeIndex:new Set(g.routes),routeIndexWithSlash:new Set(g.routes.map(e=>e.endsWith(`/`)?e:e+`/`)),routeIndexWithoutSlash:new Set(g.routes.map(e=>e.endsWith(`/`)?e.slice(0,-1):e)),basePrefix:x};i===`pretty`&&(0,s.info)(s.colors.dim(`🧪 Running diagnostic checks in parallel...`));let C=[w(S),T(S),E(S),D(S)];t.budget&&C.push(O(S));let[k,A,j,M,...N]=await Promise.all(C),P=t.budget?N[0]:[],F=[...k,...A,...j,...M,...P];if(i===`pretty`){let e=[{label:`Metadata checks ${k.length>0?`— ${k.length} issue${k.length===1?``:`s`}`:`— OK`}`,done:k.length===0},{label:`Link checks ${A.length>0?`— ${A.length} issue${A.length===1?``:`s`}`:`— OK`}`,done:A.length===0},{label:`i18n checks ${j.length>0?`— ${j.length} issue${j.length===1?``:`s`}`:`— OK`}`,done:j.length===0},{label:`Sidebar checks ${M.length>0?`— ${M.length} issue${M.length===1?``:`s`}`:`— OK`}`,done:M.length===0}];t.budget&&e.push({label:`Performance budget ${P.length>0?`— ${P.length} issue${P.length===1?``:`s`}`:`— OK`}`,done:P.length===0}),console.log(`\n${(0,s.tasks)(e)}`)}let I=0;if(t.fix){for(let e of F)if(e.fix){if(S.doctorConfig.fix.confirmChanges&&!await(0,s.confirm)(`Fix issue in "${e.file}": ${e.message}?`))continue;if(S.doctorConfig.fix.backupFiles){let t=a.default.resolve(S.docsDir,e.file);o.default.existsSync(t)&&await m(t,a.default.resolve(S.root,S.doctorConfig.fix.backupPath))}await e.fix(),I++}}let L=((performance.now()-u)/1e3).toFixed(2),R=F.filter(e=>e.level===`high`).length,z=F.filter(e=>e.level===`warning`).length,B=F.filter(e=>e.level===`low`).length,V={summary:{total:F.length,high:R,warning:z,low:B,fixed:I,duration:L},issues:F.map(e=>({...e,fix:void 0}))};if(n.reporting.outputFile){let t=a.default.resolve(e,n.reporting.outputFile);o.default.existsSync(a.default.dirname(t))||o.default.mkdirSync(a.default.dirname(t),{recursive:!0}),o.default.writeFileSync(t,JSON.stringify(V,null,2))}if(i===`json`)console.log(JSON.stringify(V,null,2));else if(i===`pretty`){let e=F.reduce((e,t)=>(e[t.file]||(e[t.file]=[]),e[t.file].push(t),e),{});if(F.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)(e,{title:`📄 ${n}`})}`)}(0,s.dividerLog)()}if(F.length===0)console.log((0,s.round)([` Everything looks perfect!`,` Your documentation is in great shape.`,``,` ${s.colors.dim(`Scanned ${h.length} file${h.length===1?``:`s`} in ${L}s`)}`],{title:`✨ Documentation Health Check`}));else{let e=[];R>0&&e.push(s.colors.red(`${R} Critical Error${R===1?``:`s`}`)),z>0&&e.push(s.colors.yellow(`${z} Warning${z===1?``:`s`}`)),B>0&&e.push(s.colors.blue(`${B} Improvement${B===1?``:`s`}`));let t=[...(0,s.bullet)(e).split(`
6
+ const e=require(`./chunk-Ds5LZdWN.cjs`),t=require(`./utils-Bz1tG9Dg.cjs`),n=require(`./pages-external-CX2uyW95.cjs`),r=require(`./config-DrRQYDCI.cjs`),i=require(`./node/cli-entry.cjs`);let a=require(`node:path`);a=e.n(a);let o=require(`node:fs`);o=e.n(o);let s=require(`@bdocs/dui`),c=require(`fdir`),l=require(`picomatch`);l=e.n(l);let u=require(`fastest-levenshtein`);const d={$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 f(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 p(e,t,n){return e.doctorConfig.severity[t]||n}async function m(e,t){o.default.existsSync(t)||o.default.mkdirSync(t,{recursive:!0});let n=a.default.basename(e),r=new Date().toISOString().replace(/[:.]/g,`-`),i=a.default.join(t,`${n}.${r}.bak`);o.default.copyFileSync(e,i)}const h=new Map;function g(e){let n=h.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 h.set(e,r),r}const _=new Map;function v(e){if(_.has(e))return _.get(e);let t=!1;try{t=o.default.existsSync(e)&&o.default.statSync(e).isFile()}catch{t=!1}return _.set(e,t),t}async function y(e){let t=a.default.resolve(e,`doctor.json`);if(o.default.existsSync(t))try{let e=JSON.parse(o.default.readFileSync(t,`utf-8`));return{...d,...e,checks:{...d.checks,...e.checks,metadata:{...d.checks.metadata,...e.checks?.metadata},links:{...d.checks.links,...e.checks?.links},i18n:{...d.checks.i18n,...e.checks?.i18n},performance:{...d.checks.performance,...e.checks?.performance,budgets:{...d.checks.performance?.budgets,...e.checks?.performance?.budgets}}},fix:{...d.fix,...e.fix},reporting:{...d.reporting,...e.reporting},severity:{...d.severity,...e.severity},exclude:[...d.exclude,...e.exclude||[]]}}catch(e){(0,s.warn)(`Failed to parse doctor.json: ${e}`)}return d}async function b(e,r=process.cwd(),i,s){let l=a.default.resolve(r,`.boltdocs`,`generated`);o.default.existsSync(l)||o.default.mkdirSync(l,{recursive:!0});let u=s;u||=await new c.fdir().withFullPaths().filter(e=>e.endsWith(`.md`)||e.endsWith(`.mdx`)).crawl(e).withPromise();let d=i?.base||`/docs`,f=[];for(let n=0;n<u.length;n+=100){let r=u.slice(n,n+100),i=await Promise.all(r.map(async n=>{let r=a.default.isAbsolute(n)?n:a.default.resolve(e,n),i=a.default.relative(e,r),{data:o}=await g(r),s;return s=o.permalink?o.permalink.startsWith(`/`)?o.permalink:`/${o.permalink}`:t.a(i),d===`/`?s:(d.endsWith(`/`)?d:d+`/`)+(s.startsWith(`/`)?s.substring(1):s)}));f.push(...i)}f.includes(d)||f.push(d);let p=n.t(e,i);for(let e of p)f.includes(e)||f.push(e);let m={routes:Array.from(new Set(f)).sort(),timestamp:Date.now()};return o.default.writeFileSync(a.default.resolve(l,`link-tree.json`),JSON.stringify(m,null,2)),m}function x(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,u.distance)(i,a)/Math.max(i.length,a.length);return o>.8?o*.95:1-(0,u.distance)(e,t)/Math.max(e.length,t.length)}const S=new Map;function C(e,t){if(S.has(e))return S.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=x(e,a);c>i&&(i=c,r=a)}let a={bestMatch:r,similarity:i};return S.set(e,a),a}async function w(e){let n=[];if(!e.doctorConfig.checks.metadata.enabled)return n;let{titleMin:r,titleMax:i,descriptionMin:o}=e.doctorConfig.checks.metadata,s=new Map;for(let c of e.files){let l=t.u(a.default.relative(e.docsDir,c));try{let{raw:a,data:u}=await g(c);if(a.trim().startsWith(`---`)&&a.split(`---`).length>=3&&Object.keys(u).length===0){let t=p(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._.safeParse(u);if(!d.success){let t=p(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=p(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=p(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<r){let i=p(e,`shortMetadata`,`low`);i!==`off`&&n.push({file:l,level:i,message:`Title is too short (${t.length} chars).`,suggestion:`Titles should be at least ${r} characters for better SEO.`})}else if(t.length>i){let r=p(e,`shortMetadata`,`low`);r!==`off`&&n.push({file:l,level:r,message:`Title is too long (${t.length} chars).`,suggestion:`Titles should be under ${i} characters.`})}let a=s.get(t)||[];a.push(l),s.set(t,a)}if(u.description&&String(u.description).length<o){let t=p(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=p(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=p(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 T(e){let n=[],{internal:r,external:i,ignore:c,timeout:l,concurrency:u}=e.doctorConfig.checks.links;if(!r&&!i&&!e.options.checkExternal)return n;let d=/(?:\[.*?\]\((.*?)\))|(?:href=["']([^"']+)["'])/g,f=new Set,m=5e5;for(let s of e.files){let l=t.u(a.default.relative(e.docsDir,s)),{content:u}=await g(s),_=[...(u.length>m?u.slice(0,m):u).replace(/```[\s\S]*?```/g,``).replace(/`[^`\n]*`/g,``).matchAll(d)];for(let t of _){let u=t[1]||t[2],d=!!t[1];if(!u||c.some(e=>u.includes(e)))continue;if(/^https?:\/\//i.test(u)){(i||e.options.checkExternal)&&f.add({url:u,file:s});continue}if(!r||/^(mailto|tel|#)/i.test(u))continue;let m;try{m=decodeURIComponent(u.split(`#`)[0].split(`?`)[0])}catch{m=u.split(`#`)[0].split(`?`)[0]}if(!m)continue;let g=!1,_=``;if(m.startsWith(`/`))if(e.routeIndex.has(m)||e.routeIndexWithSlash.has(m)||e.routeIndexWithoutSlash.has(m))g=!0;else{let t=e.basePrefix+(m.startsWith(`/`)?m:`/`+m);if(e.routeIndex.has(t)||e.routeIndexWithSlash.has(t))g=!1,_=t;else{let t=e.config.base!==`/`&&m.startsWith(e.config.base||`/`)?m.substring((e.config.base||`/`).length):m,n=t.startsWith(`/`)?t.substring(1):t;_=a.default.join(e.docsDir,n),g=[``,`.md`,`.mdx`,`/index.md`,`/index.mdx`].some(e=>v(_+e))}}else _=a.default.resolve(a.default.dirname(s),m),g=[``,`.md`,`.mdx`,`/index.md`,`/index.mdx`].some(e=>v(_+e));if(!g){let{bestMatch:t,similarity:r}=C(m,e.linkTree.routes),i=!1,a=e.basePrefix+(m.startsWith(`/`)?m:`/`+m);(e.routeIndex.has(a)||e.routeIndexWithSlash.has(a))&&(t=a,r=1,i=!0);let c=r>.6||i,f=r>.75&&t!==m||i,g=p(e,`brokenLink`,`high`);g!==`off`&&n.push({file:l,level:g,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=o.default.readFileSync(s,`utf-8`).replace(n,r);o.default.writeFileSync(s,i),h.delete(s)}:void 0})}}}if(f.size>0){(0,s.info)(s.colors.gray(`Verifying ${f.size} external links...`));let r=new Map;for(let e of f)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(),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(r.keys()),c=[];for(let e=0;e<o.length;e+=u){let t=o.slice(e,e+u),n=await Promise.allSettled(t.map(i));c.push(...n.map(e=>e.status===`fulfilled`?e.value:{url:`unknown`,ok:!1,error:e.reason}))}for(let i of c)if(!i.ok){let o=p(e,`brokenLink`,`warning`);if(o!==`off`){let s=r.get(i.url)||[];for(let r of s)n.push({file:t.u(a.default.relative(e.docsDir,r)),level:o,message:`Broken external link: "${i.url}"`,suggestion:`Verify the URL or update it if it's permanently down. Error: ${i.error||`Status >= 400`}`})}}}return n}async function E(e){let n=[];if(!e.doctorConfig.checks.i18n.enabled||!e.config.i18n)return n;let{defaultLocale:r,locales:i}=e.config.i18n,s=Object.keys(i),c=s.filter(e=>e!==r);for(let i of e.files){let l=t.u(a.default.relative(e.docsDir,i)),u=l.split(`/`),d=u[0];if(d===r){let t=u.slice(1).join(`/`);for(let r of c){let s=a.default.join(e.docsDir,r,t);if(!v(s)){let c=p(e,`missingTranslation`,`warning`);c!==`off`&&n.push({file:l,level:c,message:`Missing translation for locale "${r}"`,suggestion:`Create a version at "${r}/${t}".`,fix:async()=>{let e=a.default.dirname(s);o.default.existsSync(e)||o.default.mkdirSync(e,{recursive:!0}),o.default.copyFileSync(i,s)}})}}}else if(s.includes(d)){let t=u.slice(1).join(`/`);if(!v(a.default.join(e.docsDir,r,t))){let a=p(e,`missingTranslation`,`low`);a!==`off`&&n.push({file:l,level:a,message:`Orphaned translation (source missing in "${r}")`,suggestion:`Remove this file or create the source at "${r}/${t}".`,fix:async()=>{o.default.unlinkSync(i)}})}}}return n}async function D(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=p(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}=C(r.link,e.linkTree.routes),a=i>.6,o=p(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=p(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 O(e){let t=[],n=e.doctorConfig.checks.performance;if(!n?.enabled)return t;let r=a.default.resolve(e.root,`.boltdocs`,`reports`,`performance.json`);if(!o.default.existsSync(r))return t.push({file:`(build)`,level:p(e,`budgetExceeded`,`warning`),message:"Performance metrics not found. Run `boltdocs build` first."}),t;let i;try{i=JSON.parse(o.default.readFileSync(r,`utf-8`))}catch{return t.push({file:`(build)`,level:p(e,`budgetExceeded`,`warning`),message:`Failed to parse performance metrics file.`}),t}let s=n.budgets,c=p(e,`budgetExceeded`,`warning`),l=f(s?.maxJSBundleSize,1/0),u=f(s?.maxCSSBundleSize,1/0),d=f(s?.maxPageHTMLSize,1/0),m=s?.maxImagesKB??1/0,h=s?.maxBuildTime??1/0,g=s?.maxFontCount??1/0;if(l!==1/0&&i.totalJSBundleSize>l){let e=(i.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&&i.totalCSSBundleSize>u){let e=(i.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 i.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 _=m*1024;if(m!==1/0&&i.totalImagesSize>_){let e=(i.totalImagesSize/1024).toFixed(0);t.push({file:`(build)`,level:c,message:`Image assets exceed budget: ${e}kb > ${m}kb`,suggestion:`Optimize images with lossy compression or use next-gen formats (webp/avif).`})}if(h!==1/0&&i.buildTime>h){let e=(i.buildTime/1e3).toFixed(1),n=(h/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 g!==1/0&&i.fontCount>g&&t.push({file:`(build)`,level:c,message:`Font files exceed budget: ${i.fontCount} > ${g}`,suggestion:`Reduce the number of font families or use variable fonts.`}),t}async function k(e){let t=a.default.resolve(e,`doctor.json`);if(o.default.existsSync(t)){(0,s.warn)(`"doctor.json" already exists at ${e}.`);return}try{o.default.writeFileSync(t,JSON.stringify(d,null,2)),(0,s.success)(`Created "doctor.json" with default configuration.`)}catch(e){(0,s.error)(`Failed to create "doctor.json": ${e}`)}}async function A(e=process.cwd(),t={}){if(t.init){await k(e);return}i.t();try{let n=await y(e),{format:i}=n.reporting,u=performance.now(),d=await r.n(`docs`,e),f=a.default.resolve(e,`docs`);o.default.existsSync(f)||(i===`pretty`&&(0,s.error)(`Docs dir not found at ${f}`),process.exit(1)),i===`pretty`&&console.log((0,s.double)([` ${s.colors.dim(`Docs dir:`)} ${f}`,` ${s.colors.dim(`Reports:`)} ${e}/.boltdocs/reports/`],{title:`✦ DOCTOR — Documentation Health Check`})),i===`pretty`&&(0,s.info)(s.colors.dim(`🔍 Discovering files and routes...`));let p=(0,l.default)(n.exclude||[]),h=await new c.fdir().withFullPaths().filter(e=>{if(!(e.endsWith(`.md`)||e.endsWith(`.mdx`)))return!1;let t=a.default.relative(f,e).replace(/\\/g,`/`),n=t.split(`/`).some(e=>e.startsWith(`_`)&&e!==`_index.md`&&e!==`_index.mdx`);return!p(t)&&!n}).crawl(f).withPromise();for(let e of h)_.set(e,!0);let g=await b(f,e,d,h),v=d.base||`/`,x=v===`/`?``:v.endsWith(`/`)?v.slice(0,-1):v,S={root:e,docsDir:f,config:d,doctorConfig:n,linkTree:g,files:h,options:t,routeIndex:new Set(g.routes),routeIndexWithSlash:new Set(g.routes.map(e=>e.endsWith(`/`)?e:e+`/`)),routeIndexWithoutSlash:new Set(g.routes.map(e=>e.endsWith(`/`)?e.slice(0,-1):e)),basePrefix:x};i===`pretty`&&(0,s.info)(s.colors.dim(`🧪 Running diagnostic checks in parallel...`));let C=[w(S),T(S),E(S),D(S)];t.budget&&C.push(O(S));let[k,A,j,M,...N]=await Promise.all(C),P=t.budget?N[0]:[],F=[...k,...A,...j,...M,...P];if(i===`pretty`){let e=[{label:`Metadata checks ${k.length>0?`— ${k.length} issue${k.length===1?``:`s`}`:`— OK`}`,done:k.length===0},{label:`Link checks ${A.length>0?`— ${A.length} issue${A.length===1?``:`s`}`:`— OK`}`,done:A.length===0},{label:`i18n checks ${j.length>0?`— ${j.length} issue${j.length===1?``:`s`}`:`— OK`}`,done:j.length===0},{label:`Sidebar checks ${M.length>0?`— ${M.length} issue${M.length===1?``:`s`}`:`— OK`}`,done:M.length===0}];t.budget&&e.push({label:`Performance budget ${P.length>0?`— ${P.length} issue${P.length===1?``:`s`}`:`— OK`}`,done:P.length===0}),console.log(`\n${(0,s.tasks)(e)}`)}let I=0;if(t.fix){for(let e of F)if(e.fix){if(S.doctorConfig.fix.confirmChanges&&!await(0,s.confirm)(`Fix issue in "${e.file}": ${e.message}?`))continue;if(S.doctorConfig.fix.backupFiles){let t=a.default.resolve(S.docsDir,e.file);o.default.existsSync(t)&&await m(t,a.default.resolve(S.root,S.doctorConfig.fix.backupPath))}await e.fix(),I++}}let L=((performance.now()-u)/1e3).toFixed(2),R=F.filter(e=>e.level===`high`).length,z=F.filter(e=>e.level===`warning`).length,B=F.filter(e=>e.level===`low`).length,V={summary:{total:F.length,high:R,warning:z,low:B,fixed:I,duration:L},issues:F.map(e=>({...e,fix:void 0}))};if(n.reporting.outputFile){let t=a.default.resolve(e,n.reporting.outputFile);o.default.existsSync(a.default.dirname(t))||o.default.mkdirSync(a.default.dirname(t),{recursive:!0}),o.default.writeFileSync(t,JSON.stringify(V,null,2))}if(i===`json`)console.log(JSON.stringify(V,null,2));else if(i===`pretty`){let e=F.reduce((e,t)=>(e[t.file]||(e[t.file]=[]),e[t.file].push(t),e),{});if(F.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)(e,{title:`📄 ${n}`})}`)}(0,s.dividerLog)()}if(F.length===0)console.log((0,s.round)([` Everything looks perfect!`,` Your documentation is in great shape.`,``,` ${s.colors.dim(`Scanned ${h.length} file${h.length===1?``:`s`} in ${L}s`)}`],{title:`✨ Documentation Health Check`}));else{let e=[];R>0&&e.push(s.colors.red(`${R} Critical Error${R===1?``:`s`}`)),z>0&&e.push(s.colors.yellow(`${z} Warning${z===1?``:`s`}`)),B>0&&e.push(s.colors.blue(`${B} Improvement${B===1?``:`s`}`));let t=[...(0,s.bullet)(e).split(`
7
7
  `).map(e=>e.trimStart()),``,s.colors.dim(`Scanned ${h.length} file${h.length===1?``:`s`} in ${L}s`)];console.log(`\n${(0,s.double)(t,{title:`Diagnosis Results`})}\n`),I>0&&(0,s.success)(`Successfully fixed ${I} issues automatically!`),R>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&&R>0&&process.exit(1),n.reporting.maxWarnings!==-1&&z>n.reporting.maxWarnings&&(i===`pretty`&&(0,s.error)(`Failed: Too many warnings (${z} > ${n.reporting.maxWarnings})`),process.exit(1))}catch(e){(0,s.error)(`Doctor failed: ${e}`),process.exit(1)}}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return d}});
@@ -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-DQxLM202.cjs`);exports.doctorAction=e.t;
6
+ const e=require(`./doctor-BadGEhXv.cjs`);exports.doctorAction=e.t;
@@ -3,5 +3,5 @@
3
3
  * Copyright (c) 2026 Jesus Alcala
4
4
  * Licensed under the MIT License.
5
5
  */
6
- import{t as e}from"./rolldown-runtime-fkIsjY3S.mjs";import{_ as t,a as n,d as r,u as i}from"./utils-B3xYMrpK.mjs";import{t as a}from"./pages-external-BYa4JSda.mjs";import{r as o}from"./config-D3_zDkHh.mjs";import{t as s}from"./node/cli-entry.mjs";import c from"node:path";import l from"node:fs";import{bullet as u,colors as d,confirm as f,dividerLog as p,double as m,error as h,info as g,round as _,single as v,success as y,tasks as b,warn as x}from"@bdocs/dui";import{fdir as S}from"fdir";import C from"picomatch";import{distance as w}from"fastest-levenshtein";const T={$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 E(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 D(e,t,n){return e.doctorConfig.severity[t]||n}async function O(e,t){l.existsSync(t)||l.mkdirSync(t,{recursive:!0});let n=c.basename(e),r=new Date().toISOString().replace(/[:.]/g,`-`),i=c.join(t,`${n}.${r}.bak`);l.copyFileSync(e,i)}const k=new Map;function A(e){let t=k.get(e);if(t)return t;let n=(async()=>{let t=await r(e,!1);return{raw:t.raw,data:t.data,content:t.content}})();return k.set(e,n),n}const j=new Map;function M(e){if(j.has(e))return j.get(e);let t=!1;try{t=l.existsSync(e)&&l.statSync(e).isFile()}catch{t=!1}return j.set(e,t),t}async function N(e){let t=c.resolve(e,`doctor.json`);if(l.existsSync(t))try{let e=JSON.parse(l.readFileSync(t,`utf-8`));return{...T,...e,checks:{...T.checks,...e.checks,metadata:{...T.checks.metadata,...e.checks?.metadata},links:{...T.checks.links,...e.checks?.links},i18n:{...T.checks.i18n,...e.checks?.i18n},performance:{...T.checks.performance,...e.checks?.performance,budgets:{...T.checks.performance?.budgets,...e.checks?.performance?.budgets}}},fix:{...T.fix,...e.fix},reporting:{...T.reporting,...e.reporting},severity:{...T.severity,...e.severity},exclude:[...T.exclude,...e.exclude||[]]}}catch(e){x(`Failed to parse doctor.json: ${e}`)}return T}async function P(e,t=process.cwd(),r,i){let o=c.resolve(t,`.boltdocs`,`generated`);l.existsSync(o)||l.mkdirSync(o,{recursive:!0});let s=i;s||=await new S().withFullPaths().filter(e=>e.endsWith(`.md`)||e.endsWith(`.mdx`)).crawl(e).withPromise();let u=r?.base||`/docs`,d=[];for(let t=0;t<s.length;t+=100){let r=s.slice(t,t+100),i=await Promise.all(r.map(async t=>{let r=c.isAbsolute(t)?t:c.resolve(e,t),i=c.relative(e,r),{data:a}=await A(r),o;return o=a.permalink?a.permalink.startsWith(`/`)?a.permalink:`/${a.permalink}`:n(i),u===`/`?o:(u.endsWith(`/`)?u:u+`/`)+(o.startsWith(`/`)?o.substring(1):o)}));d.push(...i)}d.includes(u)||d.push(u);let f=a(e,r);for(let e of f)d.includes(e)||d.push(e);let p={routes:Array.from(new Set(d)).sort(),timestamp:Date.now()};return l.writeFileSync(c.resolve(o,`link-tree.json`),JSON.stringify(p,null,2)),p}function F(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-w(i,a)/Math.max(i.length,a.length);return o>.8?o*.95:1-w(e,t)/Math.max(e.length,t.length)}const I=new Map;function L(e,t){if(I.has(e))return I.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=F(e,a);c>i&&(i=c,r=a)}let a={bestMatch:r,similarity:i};return I.set(e,a),a}async function R(e){let n=[];if(!e.doctorConfig.checks.metadata.enabled)return n;let{titleMin:r,titleMax:a,descriptionMin:o}=e.doctorConfig.checks.metadata,s=new Map;for(let l of e.files){let u=i(c.relative(e.docsDir,l));try{let{raw:i,data:c}=await A(l);if(i.trim().startsWith(`---`)&&i.split(`---`).length>=3&&Object.keys(c).length===0){let t=D(e,`malformedFrontmatter`,`high`);t!==`off`&&n.push({file:u,level:t,message:`Malformed frontmatter (YAML parsing failed).`,suggestion:`Check your YAML syntax for indentation or unquoted special characters.`})}let d=t.safeParse(c);if(!d.success){let t=D(e,`invalidFrontmatter`,`high`);if(t!==`off`)for(let e of d.error.issues)n.push({file:u,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(c[t]===void 0){let r=D(e,`missingMetadata`,`warning`);r!==`off`&&n.push({file:u,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(c[r]&&Number.isNaN(Date.parse(String(c[r])))){let t=D(e,`invalidFrontmatter`,`high`);t!==`off`&&n.push({file:u,level:t,message:`Invalid date format in field "${r}": "${c[r]}".`,suggestion:`Use a valid ISO date format (e.g., YYYY-MM-DD).`})}}if(c.title){let t=String(c.title);if(t.length<r){let i=D(e,`shortMetadata`,`low`);i!==`off`&&n.push({file:u,level:i,message:`Title is too short (${t.length} chars).`,suggestion:`Titles should be at least ${r} characters for better SEO.`})}else if(t.length>a){let r=D(e,`shortMetadata`,`low`);r!==`off`&&n.push({file:u,level:r,message:`Title is too long (${t.length} chars).`,suggestion:`Titles should be under ${a} characters.`})}let i=s.get(t)||[];i.push(u),s.set(t,i)}if(c.description&&String(c.description).length<o){let t=D(e,`shortMetadata`,`low`);t!==`off`&&n.push({file:u,level:t,message:`Description is very short.`,suggestion:`Descriptions should ideally be at least ${o} characters.`})}}catch(t){if(t instanceof Error){let r=D(e,`malformedFrontmatter`,`high`);r!==`off`&&n.push({file:u,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=D(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 z(e){let t=[],{internal:n,external:r,ignore:a,timeout:o,concurrency:s}=e.doctorConfig.checks.links;if(!n&&!r&&!e.options.checkExternal)return t;let u=/(?:\[.*?\]\((.*?)\))|(?:href=["']([^"']+)["'])/g,f=new Set,p=5e5;for(let o of e.files){let s=i(c.relative(e.docsDir,o)),{content:d}=await A(o),m=[...(d.length>p?d.slice(0,p):d).replace(/```[\s\S]*?```/g,``).replace(/`[^`\n]*`/g,``).matchAll(u)];for(let i of m){let u=i[1]||i[2],d=!!i[1];if(!u||a.some(e=>u.includes(e)))continue;if(/^https?:\/\//i.test(u)){(r||e.options.checkExternal)&&f.add({url:u,file:o});continue}if(!n||/^(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=c.join(e.docsDir,n),m=[``,`.md`,`.mdx`,`/index.md`,`/index.mdx`].some(e=>M(h+e))}}else h=c.resolve(c.dirname(o),p),m=[``,`.md`,`.mdx`,`/index.md`,`/index.mdx`].some(e=>M(h+e));if(!m){let{bestMatch:n,similarity:r}=L(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 c=r>.6||i,f=r>.75&&n!==p||i,m=D(e,`brokenLink`,`high`);m!==`off`&&t.push({file:s,level:m,message:`Broken internal link: "${u}"`,suggestion:c?`Did you mean "${n}"?`:`Ensure the target exists or check for typos.`,fix:f?async()=>{let e=u.includes(`#`)?`#`+u.split(`#`)[1]:``,t=d?`(${u})`:`href="${u}"`,r=d?`(${n}${e})`:`href="${n}${e}"`,i=l.readFileSync(o,`utf-8`).replace(t,r);l.writeFileSync(o,i),k.delete(o)}:void 0})}}}if(f.size>0){g(d.gray(`Verifying ${f.size} external links...`));let n=new Map;for(let e of f)n.has(e.url)||n.set(e.url,[]),n.get(e.url).push(e.file);let r=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(n.keys()),l=[];for(let e=0;e<a.length;e+=s){let t=a.slice(e,e+s),n=await Promise.allSettled(t.map(r));l.push(...n.map(e=>e.status===`fulfilled`?e.value:{url:`unknown`,ok:!1,error:e.reason}))}for(let r of l)if(!r.ok){let a=D(e,`brokenLink`,`warning`);if(a!==`off`){let o=n.get(r.url)||[];for(let n of o)t.push({file:i(c.relative(e.docsDir,n)),level:a,message:`Broken external link: "${r.url}"`,suggestion:`Verify the URL or update it if it's permanently down. Error: ${r.error||`Status >= 400`}`})}}}return t}async function B(e){let t=[];if(!e.doctorConfig.checks.i18n.enabled||!e.config.i18n)return t;let{defaultLocale:n,locales:r}=e.config.i18n,a=Object.keys(r),o=a.filter(e=>e!==n);for(let r of e.files){let s=i(c.relative(e.docsDir,r)),u=s.split(`/`),d=u[0];if(d===n){let n=u.slice(1).join(`/`);for(let i of o){let a=c.join(e.docsDir,i,n);if(!M(a)){let o=D(e,`missingTranslation`,`warning`);o!==`off`&&t.push({file:s,level:o,message:`Missing translation for locale "${i}"`,suggestion:`Create a version at "${i}/${n}".`,fix:async()=>{let e=c.dirname(a);l.existsSync(e)||l.mkdirSync(e,{recursive:!0}),l.copyFileSync(r,a)}})}}}else if(a.includes(d)){let i=u.slice(1).join(`/`);if(!M(c.join(e.docsDir,n,i))){let a=D(e,`missingTranslation`,`low`);a!==`off`&&t.push({file:s,level:a,message:`Orphaned translation (source missing in "${n}")`,suggestion:`Remove this file or create the source at "${n}/${i}".`,fix:async()=>{l.unlinkSync(r)}})}}}return t}async function V(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=D(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}=L(r.link,e.linkTree.routes),a=i>.6,o=D(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=D(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 H(e){let t=[],n=e.doctorConfig.checks.performance;if(!n?.enabled)return t;let r=c.resolve(e.root,`.boltdocs`,`reports`,`performance.json`);if(!l.existsSync(r))return t.push({file:`(build)`,level:D(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:D(e,`budgetExceeded`,`warning`),message:`Failed to parse performance metrics file.`}),t}let a=n.budgets,o=D(e,`budgetExceeded`,`warning`),s=E(a?.maxJSBundleSize,1/0),u=E(a?.maxCSSBundleSize,1/0),d=E(a?.maxPageHTMLSize,1/0),f=a?.maxImagesKB??1/0,p=a?.maxBuildTime??1/0,m=a?.maxFontCount??1/0;if(s!==1/0&&i.totalJSBundleSize>s){let e=(i.totalJSBundleSize/1024).toFixed(0),n=(s/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}var U=e({DEFAULT_DOCTOR_CONFIG:()=>T,checkI18n:()=>B,checkLinks:()=>z,checkMetadata:()=>R,checkPerformance:()=>H,checkSidebar:()=>V,doctorAction:()=>G,doctorInit:()=>W,generateLinkTree:()=>P,loadDoctorConfig:()=>N});async function W(e){let t=c.resolve(e,`doctor.json`);if(l.existsSync(t)){x(`"doctor.json" already exists at ${e}.`);return}try{l.writeFileSync(t,JSON.stringify(T,null,2)),y(`Created "doctor.json" with default configuration.`)}catch(e){h(`Failed to create "doctor.json": ${e}`)}}async function G(e=process.cwd(),t={}){if(t.init){await W(e);return}s();try{let n=await N(e),{format:r}=n.reporting,i=performance.now(),a=await o(`docs`,e),s=c.resolve(e,`docs`);l.existsSync(s)||(r===`pretty`&&h(`Docs dir not found at ${s}`),process.exit(1)),r===`pretty`&&console.log(m([` ${d.dim(`Docs dir:`)} ${s}`,` ${d.dim(`Reports:`)} ${e}/.boltdocs/reports/`],{title:`✦ DOCTOR — Documentation Health Check`})),r===`pretty`&&g(d.dim(`🔍 Discovering files and routes...`));let x=C(n.exclude||[]),w=await new S().withFullPaths().filter(e=>{if(!(e.endsWith(`.md`)||e.endsWith(`.mdx`)))return!1;let t=c.relative(s,e).replace(/\\/g,`/`),n=t.split(`/`).some(e=>e.startsWith(`_`)&&e!==`_index.md`&&e!==`_index.mdx`);return!x(t)&&!n}).crawl(s).withPromise();for(let e of w)j.set(e,!0);let T=await P(s,e,a,w),E=a.base||`/`,D=E===`/`?``:E.endsWith(`/`)?E.slice(0,-1):E,k={root:e,docsDir:s,config:a,doctorConfig:n,linkTree:T,files:w,options:t,routeIndex:new Set(T.routes),routeIndexWithSlash:new Set(T.routes.map(e=>e.endsWith(`/`)?e:e+`/`)),routeIndexWithoutSlash:new Set(T.routes.map(e=>e.endsWith(`/`)?e.slice(0,-1):e)),basePrefix:D};r===`pretty`&&g(d.dim(`🧪 Running diagnostic checks in parallel...`));let A=[R(k),z(k),B(k),V(k)];t.budget&&A.push(H(k));let[M,F,I,L,...U]=await Promise.all(A),W=t.budget?U[0]:[],G=[...M,...F,...I,...L,...W];if(r===`pretty`){let e=[{label:`Metadata checks ${M.length>0?`— ${M.length} issue${M.length===1?``:`s`}`:`— OK`}`,done:M.length===0},{label:`Link checks ${F.length>0?`— ${F.length} issue${F.length===1?``:`s`}`:`— OK`}`,done:F.length===0},{label:`i18n checks ${I.length>0?`— ${I.length} issue${I.length===1?``:`s`}`:`— OK`}`,done:I.length===0},{label:`Sidebar checks ${L.length>0?`— ${L.length} issue${L.length===1?``:`s`}`:`— OK`}`,done:L.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${b(e)}`)}let K=0;if(t.fix){for(let e of G)if(e.fix){if(k.doctorConfig.fix.confirmChanges&&!await f(`Fix issue in "${e.file}": ${e.message}?`))continue;if(k.doctorConfig.fix.backupFiles){let t=c.resolve(k.docsDir,e.file);l.existsSync(t)&&await O(t,c.resolve(k.root,k.doctorConfig.fix.backupPath))}await e.fix(),K++}}let q=((performance.now()-i)/1e3).toFixed(2),J=G.filter(e=>e.level===`high`).length,Y=G.filter(e=>e.level===`warning`).length,X=G.filter(e=>e.level===`low`).length,Z={summary:{total:G.length,high:J,warning:Y,low:X,fixed:K,duration:q},issues:G.map(e=>({...e,fix:void 0}))};if(n.reporting.outputFile){let t=c.resolve(e,n.reporting.outputFile);l.existsSync(c.dirname(t))||l.mkdirSync(c.dirname(t),{recursive:!0}),l.writeFileSync(t,JSON.stringify(Z,null,2))}if(r===`json`)console.log(JSON.stringify(Z,null,2));else if(r===`pretty`){let e=G.reduce((e,t)=>(e[t.file]||(e[t.file]=[]),e[t.file].push(t),e),{});if(G.length>0){p();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`?d.red:n.level===`warning`?d.yellow:d.blue;e.push(`${r} ${i(n.level.toUpperCase())}: ${n.message}`),n.suggestion&&e.push(` ${d.dim(`💡 ${n.suggestion}`)}`),t.fix&&n.fix&&e.push(` ${d.green(`✅ Fixed automatically`)}`)}console.log(`\n${v(e,{title:`📄 ${n}`})}`)}p()}if(G.length===0)console.log(_([` Everything looks perfect!`,` Your documentation is in great shape.`,``,` ${d.dim(`Scanned ${w.length} file${w.length===1?``:`s`} in ${q}s`)}`],{title:`✨ Documentation Health Check`}));else{let e=[];J>0&&e.push(d.red(`${J} Critical Error${J===1?``:`s`}`)),Y>0&&e.push(d.yellow(`${Y} Warning${Y===1?``:`s`}`)),X>0&&e.push(d.blue(`${X} Improvement${X===1?``:`s`}`));let t=[...u(e).split(`
6
+ import{t as e}from"./rolldown-runtime-fkIsjY3S.mjs";import{_ as t,a as n,d as r,u as i}from"./utils-B3xYMrpK.mjs";import{t as a}from"./pages-external-BYa4JSda.mjs";import{r as o}from"./config-DAgpZyh6.mjs";import{t as s}from"./node/cli-entry.mjs";import c from"node:path";import l from"node:fs";import{bullet as u,colors as d,confirm as f,dividerLog as p,double as m,error as h,info as g,round as _,single as v,success as y,tasks as b,warn as x}from"@bdocs/dui";import{fdir as S}from"fdir";import C from"picomatch";import{distance as w}from"fastest-levenshtein";const T={$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 E(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 D(e,t,n){return e.doctorConfig.severity[t]||n}async function O(e,t){l.existsSync(t)||l.mkdirSync(t,{recursive:!0});let n=c.basename(e),r=new Date().toISOString().replace(/[:.]/g,`-`),i=c.join(t,`${n}.${r}.bak`);l.copyFileSync(e,i)}const k=new Map;function A(e){let t=k.get(e);if(t)return t;let n=(async()=>{let t=await r(e,!1);return{raw:t.raw,data:t.data,content:t.content}})();return k.set(e,n),n}const j=new Map;function M(e){if(j.has(e))return j.get(e);let t=!1;try{t=l.existsSync(e)&&l.statSync(e).isFile()}catch{t=!1}return j.set(e,t),t}async function N(e){let t=c.resolve(e,`doctor.json`);if(l.existsSync(t))try{let e=JSON.parse(l.readFileSync(t,`utf-8`));return{...T,...e,checks:{...T.checks,...e.checks,metadata:{...T.checks.metadata,...e.checks?.metadata},links:{...T.checks.links,...e.checks?.links},i18n:{...T.checks.i18n,...e.checks?.i18n},performance:{...T.checks.performance,...e.checks?.performance,budgets:{...T.checks.performance?.budgets,...e.checks?.performance?.budgets}}},fix:{...T.fix,...e.fix},reporting:{...T.reporting,...e.reporting},severity:{...T.severity,...e.severity},exclude:[...T.exclude,...e.exclude||[]]}}catch(e){x(`Failed to parse doctor.json: ${e}`)}return T}async function P(e,t=process.cwd(),r,i){let o=c.resolve(t,`.boltdocs`,`generated`);l.existsSync(o)||l.mkdirSync(o,{recursive:!0});let s=i;s||=await new S().withFullPaths().filter(e=>e.endsWith(`.md`)||e.endsWith(`.mdx`)).crawl(e).withPromise();let u=r?.base||`/docs`,d=[];for(let t=0;t<s.length;t+=100){let r=s.slice(t,t+100),i=await Promise.all(r.map(async t=>{let r=c.isAbsolute(t)?t:c.resolve(e,t),i=c.relative(e,r),{data:a}=await A(r),o;return o=a.permalink?a.permalink.startsWith(`/`)?a.permalink:`/${a.permalink}`:n(i),u===`/`?o:(u.endsWith(`/`)?u:u+`/`)+(o.startsWith(`/`)?o.substring(1):o)}));d.push(...i)}d.includes(u)||d.push(u);let f=a(e,r);for(let e of f)d.includes(e)||d.push(e);let p={routes:Array.from(new Set(d)).sort(),timestamp:Date.now()};return l.writeFileSync(c.resolve(o,`link-tree.json`),JSON.stringify(p,null,2)),p}function F(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-w(i,a)/Math.max(i.length,a.length);return o>.8?o*.95:1-w(e,t)/Math.max(e.length,t.length)}const I=new Map;function L(e,t){if(I.has(e))return I.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=F(e,a);c>i&&(i=c,r=a)}let a={bestMatch:r,similarity:i};return I.set(e,a),a}async function R(e){let n=[];if(!e.doctorConfig.checks.metadata.enabled)return n;let{titleMin:r,titleMax:a,descriptionMin:o}=e.doctorConfig.checks.metadata,s=new Map;for(let l of e.files){let u=i(c.relative(e.docsDir,l));try{let{raw:i,data:c}=await A(l);if(i.trim().startsWith(`---`)&&i.split(`---`).length>=3&&Object.keys(c).length===0){let t=D(e,`malformedFrontmatter`,`high`);t!==`off`&&n.push({file:u,level:t,message:`Malformed frontmatter (YAML parsing failed).`,suggestion:`Check your YAML syntax for indentation or unquoted special characters.`})}let d=t.safeParse(c);if(!d.success){let t=D(e,`invalidFrontmatter`,`high`);if(t!==`off`)for(let e of d.error.issues)n.push({file:u,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(c[t]===void 0){let r=D(e,`missingMetadata`,`warning`);r!==`off`&&n.push({file:u,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(c[r]&&Number.isNaN(Date.parse(String(c[r])))){let t=D(e,`invalidFrontmatter`,`high`);t!==`off`&&n.push({file:u,level:t,message:`Invalid date format in field "${r}": "${c[r]}".`,suggestion:`Use a valid ISO date format (e.g., YYYY-MM-DD).`})}}if(c.title){let t=String(c.title);if(t.length<r){let i=D(e,`shortMetadata`,`low`);i!==`off`&&n.push({file:u,level:i,message:`Title is too short (${t.length} chars).`,suggestion:`Titles should be at least ${r} characters for better SEO.`})}else if(t.length>a){let r=D(e,`shortMetadata`,`low`);r!==`off`&&n.push({file:u,level:r,message:`Title is too long (${t.length} chars).`,suggestion:`Titles should be under ${a} characters.`})}let i=s.get(t)||[];i.push(u),s.set(t,i)}if(c.description&&String(c.description).length<o){let t=D(e,`shortMetadata`,`low`);t!==`off`&&n.push({file:u,level:t,message:`Description is very short.`,suggestion:`Descriptions should ideally be at least ${o} characters.`})}}catch(t){if(t instanceof Error){let r=D(e,`malformedFrontmatter`,`high`);r!==`off`&&n.push({file:u,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=D(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 z(e){let t=[],{internal:n,external:r,ignore:a,timeout:o,concurrency:s}=e.doctorConfig.checks.links;if(!n&&!r&&!e.options.checkExternal)return t;let u=/(?:\[.*?\]\((.*?)\))|(?:href=["']([^"']+)["'])/g,f=new Set,p=5e5;for(let o of e.files){let s=i(c.relative(e.docsDir,o)),{content:d}=await A(o),m=[...(d.length>p?d.slice(0,p):d).replace(/```[\s\S]*?```/g,``).replace(/`[^`\n]*`/g,``).matchAll(u)];for(let i of m){let u=i[1]||i[2],d=!!i[1];if(!u||a.some(e=>u.includes(e)))continue;if(/^https?:\/\//i.test(u)){(r||e.options.checkExternal)&&f.add({url:u,file:o});continue}if(!n||/^(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=c.join(e.docsDir,n),m=[``,`.md`,`.mdx`,`/index.md`,`/index.mdx`].some(e=>M(h+e))}}else h=c.resolve(c.dirname(o),p),m=[``,`.md`,`.mdx`,`/index.md`,`/index.mdx`].some(e=>M(h+e));if(!m){let{bestMatch:n,similarity:r}=L(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 c=r>.6||i,f=r>.75&&n!==p||i,m=D(e,`brokenLink`,`high`);m!==`off`&&t.push({file:s,level:m,message:`Broken internal link: "${u}"`,suggestion:c?`Did you mean "${n}"?`:`Ensure the target exists or check for typos.`,fix:f?async()=>{let e=u.includes(`#`)?`#`+u.split(`#`)[1]:``,t=d?`(${u})`:`href="${u}"`,r=d?`(${n}${e})`:`href="${n}${e}"`,i=l.readFileSync(o,`utf-8`).replace(t,r);l.writeFileSync(o,i),k.delete(o)}:void 0})}}}if(f.size>0){g(d.gray(`Verifying ${f.size} external links...`));let n=new Map;for(let e of f)n.has(e.url)||n.set(e.url,[]),n.get(e.url).push(e.file);let r=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(n.keys()),l=[];for(let e=0;e<a.length;e+=s){let t=a.slice(e,e+s),n=await Promise.allSettled(t.map(r));l.push(...n.map(e=>e.status===`fulfilled`?e.value:{url:`unknown`,ok:!1,error:e.reason}))}for(let r of l)if(!r.ok){let a=D(e,`brokenLink`,`warning`);if(a!==`off`){let o=n.get(r.url)||[];for(let n of o)t.push({file:i(c.relative(e.docsDir,n)),level:a,message:`Broken external link: "${r.url}"`,suggestion:`Verify the URL or update it if it's permanently down. Error: ${r.error||`Status >= 400`}`})}}}return t}async function B(e){let t=[];if(!e.doctorConfig.checks.i18n.enabled||!e.config.i18n)return t;let{defaultLocale:n,locales:r}=e.config.i18n,a=Object.keys(r),o=a.filter(e=>e!==n);for(let r of e.files){let s=i(c.relative(e.docsDir,r)),u=s.split(`/`),d=u[0];if(d===n){let n=u.slice(1).join(`/`);for(let i of o){let a=c.join(e.docsDir,i,n);if(!M(a)){let o=D(e,`missingTranslation`,`warning`);o!==`off`&&t.push({file:s,level:o,message:`Missing translation for locale "${i}"`,suggestion:`Create a version at "${i}/${n}".`,fix:async()=>{let e=c.dirname(a);l.existsSync(e)||l.mkdirSync(e,{recursive:!0}),l.copyFileSync(r,a)}})}}}else if(a.includes(d)){let i=u.slice(1).join(`/`);if(!M(c.join(e.docsDir,n,i))){let a=D(e,`missingTranslation`,`low`);a!==`off`&&t.push({file:s,level:a,message:`Orphaned translation (source missing in "${n}")`,suggestion:`Remove this file or create the source at "${n}/${i}".`,fix:async()=>{l.unlinkSync(r)}})}}}return t}async function V(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=D(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}=L(r.link,e.linkTree.routes),a=i>.6,o=D(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=D(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 H(e){let t=[],n=e.doctorConfig.checks.performance;if(!n?.enabled)return t;let r=c.resolve(e.root,`.boltdocs`,`reports`,`performance.json`);if(!l.existsSync(r))return t.push({file:`(build)`,level:D(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:D(e,`budgetExceeded`,`warning`),message:`Failed to parse performance metrics file.`}),t}let a=n.budgets,o=D(e,`budgetExceeded`,`warning`),s=E(a?.maxJSBundleSize,1/0),u=E(a?.maxCSSBundleSize,1/0),d=E(a?.maxPageHTMLSize,1/0),f=a?.maxImagesKB??1/0,p=a?.maxBuildTime??1/0,m=a?.maxFontCount??1/0;if(s!==1/0&&i.totalJSBundleSize>s){let e=(i.totalJSBundleSize/1024).toFixed(0),n=(s/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}var U=e({DEFAULT_DOCTOR_CONFIG:()=>T,checkI18n:()=>B,checkLinks:()=>z,checkMetadata:()=>R,checkPerformance:()=>H,checkSidebar:()=>V,doctorAction:()=>G,doctorInit:()=>W,generateLinkTree:()=>P,loadDoctorConfig:()=>N});async function W(e){let t=c.resolve(e,`doctor.json`);if(l.existsSync(t)){x(`"doctor.json" already exists at ${e}.`);return}try{l.writeFileSync(t,JSON.stringify(T,null,2)),y(`Created "doctor.json" with default configuration.`)}catch(e){h(`Failed to create "doctor.json": ${e}`)}}async function G(e=process.cwd(),t={}){if(t.init){await W(e);return}s();try{let n=await N(e),{format:r}=n.reporting,i=performance.now(),a=await o(`docs`,e),s=c.resolve(e,`docs`);l.existsSync(s)||(r===`pretty`&&h(`Docs dir not found at ${s}`),process.exit(1)),r===`pretty`&&console.log(m([` ${d.dim(`Docs dir:`)} ${s}`,` ${d.dim(`Reports:`)} ${e}/.boltdocs/reports/`],{title:`✦ DOCTOR — Documentation Health Check`})),r===`pretty`&&g(d.dim(`🔍 Discovering files and routes...`));let x=C(n.exclude||[]),w=await new S().withFullPaths().filter(e=>{if(!(e.endsWith(`.md`)||e.endsWith(`.mdx`)))return!1;let t=c.relative(s,e).replace(/\\/g,`/`),n=t.split(`/`).some(e=>e.startsWith(`_`)&&e!==`_index.md`&&e!==`_index.mdx`);return!x(t)&&!n}).crawl(s).withPromise();for(let e of w)j.set(e,!0);let T=await P(s,e,a,w),E=a.base||`/`,D=E===`/`?``:E.endsWith(`/`)?E.slice(0,-1):E,k={root:e,docsDir:s,config:a,doctorConfig:n,linkTree:T,files:w,options:t,routeIndex:new Set(T.routes),routeIndexWithSlash:new Set(T.routes.map(e=>e.endsWith(`/`)?e:e+`/`)),routeIndexWithoutSlash:new Set(T.routes.map(e=>e.endsWith(`/`)?e.slice(0,-1):e)),basePrefix:D};r===`pretty`&&g(d.dim(`🧪 Running diagnostic checks in parallel...`));let A=[R(k),z(k),B(k),V(k)];t.budget&&A.push(H(k));let[M,F,I,L,...U]=await Promise.all(A),W=t.budget?U[0]:[],G=[...M,...F,...I,...L,...W];if(r===`pretty`){let e=[{label:`Metadata checks ${M.length>0?`— ${M.length} issue${M.length===1?``:`s`}`:`— OK`}`,done:M.length===0},{label:`Link checks ${F.length>0?`— ${F.length} issue${F.length===1?``:`s`}`:`— OK`}`,done:F.length===0},{label:`i18n checks ${I.length>0?`— ${I.length} issue${I.length===1?``:`s`}`:`— OK`}`,done:I.length===0},{label:`Sidebar checks ${L.length>0?`— ${L.length} issue${L.length===1?``:`s`}`:`— OK`}`,done:L.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${b(e)}`)}let K=0;if(t.fix){for(let e of G)if(e.fix){if(k.doctorConfig.fix.confirmChanges&&!await f(`Fix issue in "${e.file}": ${e.message}?`))continue;if(k.doctorConfig.fix.backupFiles){let t=c.resolve(k.docsDir,e.file);l.existsSync(t)&&await O(t,c.resolve(k.root,k.doctorConfig.fix.backupPath))}await e.fix(),K++}}let q=((performance.now()-i)/1e3).toFixed(2),J=G.filter(e=>e.level===`high`).length,Y=G.filter(e=>e.level===`warning`).length,X=G.filter(e=>e.level===`low`).length,Z={summary:{total:G.length,high:J,warning:Y,low:X,fixed:K,duration:q},issues:G.map(e=>({...e,fix:void 0}))};if(n.reporting.outputFile){let t=c.resolve(e,n.reporting.outputFile);l.existsSync(c.dirname(t))||l.mkdirSync(c.dirname(t),{recursive:!0}),l.writeFileSync(t,JSON.stringify(Z,null,2))}if(r===`json`)console.log(JSON.stringify(Z,null,2));else if(r===`pretty`){let e=G.reduce((e,t)=>(e[t.file]||(e[t.file]=[]),e[t.file].push(t),e),{});if(G.length>0){p();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`?d.red:n.level===`warning`?d.yellow:d.blue;e.push(`${r} ${i(n.level.toUpperCase())}: ${n.message}`),n.suggestion&&e.push(` ${d.dim(`💡 ${n.suggestion}`)}`),t.fix&&n.fix&&e.push(` ${d.green(`✅ Fixed automatically`)}`)}console.log(`\n${v(e,{title:`📄 ${n}`})}`)}p()}if(G.length===0)console.log(_([` Everything looks perfect!`,` Your documentation is in great shape.`,``,` ${d.dim(`Scanned ${w.length} file${w.length===1?``:`s`} in ${q}s`)}`],{title:`✨ Documentation Health Check`}));else{let e=[];J>0&&e.push(d.red(`${J} Critical Error${J===1?``:`s`}`)),Y>0&&e.push(d.yellow(`${Y} Warning${Y===1?``:`s`}`)),X>0&&e.push(d.blue(`${X} Improvement${X===1?``:`s`}`));let t=[...u(e).split(`
7
7
  `).map(e=>e.trimStart()),``,d.dim(`Scanned ${w.length} file${w.length===1?``:`s`} in ${q}s`)];console.log(`\n${m(t,{title:`Diagnosis Results`})}\n`),K>0&&y(`Successfully fixed ${K} issues automatically!`),J>0?h(`Please fix the critical errors before building for production.`):y(`No critical issues found. You are ready to go!`)}}n.reporting.failOnError&&J>0&&process.exit(1),n.reporting.maxWarnings!==-1&&Y>n.reporting.maxWarnings&&(r===`pretty`&&h(`Failed: Too many warnings (${Y} > ${n.reporting.maxWarnings})`),process.exit(1))}catch(e){h(`Doctor failed: ${e}`),process.exit(1)}}export{P as n,U as t};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Boltdocs - https://boltdocs.vercel.app
3
+ * Copyright (c) 2026 Jesus Alcala
4
+ * Licensed under the MIT License.
5
+ */
6
+ function e(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}export{e as t};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Boltdocs - https://boltdocs.vercel.app
3
+ * Copyright (c) 2026 Jesus Alcala
4
+ * Licensed under the MIT License.
5
+ */
6
+ function e(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Boltdocs - https://boltdocs.vercel.app
3
+ * Copyright (c) 2026 Jesus Alcala
4
+ * Licensed under the MIT License.
5
+ */
6
+ import e from"node:path";import{fileURLToPath as t}from"node:url";const n=e.dirname(t(import.meta.url));export{n as t};
@@ -576,7 +576,12 @@ function useLocalizedTo(to) {
576
576
  const config = useConfig();
577
577
  const { currentLocale: activeLocale, currentVersion: activeVersion, allRoutes } = useRoutes();
578
578
  if (!config || typeof to !== "string") return to;
579
- if (to.startsWith("http") || to.startsWith("//") || to.startsWith("#") || to.startsWith("site:")) return to.replace("site:", "");
579
+ if (to.startsWith("http") || to.startsWith("//") || to.startsWith("#")) return to;
580
+ if (to.startsWith("site:")) {
581
+ to = to.replace("site:", "");
582
+ if (to === "" || to === "/") return config.i18n && activeLocale && activeLocale !== config.i18n.defaultLocale ? `/${activeLocale}` : "/";
583
+ return to;
584
+ }
580
585
  const [pathOnly, hashAndQuery] = to.split(/([?#].*)/s);
581
586
  const normalizedTo = pathOnly.endsWith("/") && pathOnly.length > 1 ? pathOnly.slice(0, -1) : pathOnly;
582
587
  const isKnownRoute = allRoutes?.some((r) => {
@@ -600,8 +605,8 @@ function useLocalizedTo(to) {
600
605
  if (isDocsPath) {
601
606
  if (baseSegment) resultParts.push(baseSegment);
602
607
  if (versions && activeVersion) resultParts.push(activeVersion);
603
- if (i18n && activeLocale) resultParts.push(activeLocale);
604
- } else if (i18n && activeLocale) resultParts.push(activeLocale);
608
+ if (i18n && activeLocale && activeLocale !== i18n.defaultLocale) resultParts.push(activeLocale);
609
+ } else if (i18n && activeLocale && activeLocale !== i18n.defaultLocale) resultParts.push(activeLocale);
605
610
  resultParts.push(...routeContent);
606
611
  let finalPath = `/${resultParts.join("/")}`;
607
612
  if (pathOnly.endsWith("/") && pathOnly.length > 1 && !finalPath.endsWith("/")) finalPath += "/";
@@ -599,7 +599,12 @@ function useLocalizedTo(to) {
599
599
  const config = useConfig();
600
600
  const { currentLocale: activeLocale, currentVersion: activeVersion, allRoutes } = useRoutes();
601
601
  if (!config || typeof to !== "string") return to;
602
- if (to.startsWith("http") || to.startsWith("//") || to.startsWith("#") || to.startsWith("site:")) return to.replace("site:", "");
602
+ if (to.startsWith("http") || to.startsWith("//") || to.startsWith("#")) return to;
603
+ if (to.startsWith("site:")) {
604
+ to = to.replace("site:", "");
605
+ if (to === "" || to === "/") return config.i18n && activeLocale && activeLocale !== config.i18n.defaultLocale ? `/${activeLocale}` : "/";
606
+ return to;
607
+ }
603
608
  const [pathOnly, hashAndQuery] = to.split(/([?#].*)/s);
604
609
  const normalizedTo = pathOnly.endsWith("/") && pathOnly.length > 1 ? pathOnly.slice(0, -1) : pathOnly;
605
610
  const isKnownRoute = allRoutes?.some((r) => {
@@ -623,8 +628,8 @@ function useLocalizedTo(to) {
623
628
  if (isDocsPath) {
624
629
  if (baseSegment) resultParts.push(baseSegment);
625
630
  if (versions && activeVersion) resultParts.push(activeVersion);
626
- if (i18n && activeLocale) resultParts.push(activeLocale);
627
- } else if (i18n && activeLocale) resultParts.push(activeLocale);
631
+ if (i18n && activeLocale && activeLocale !== i18n.defaultLocale) resultParts.push(activeLocale);
632
+ } else if (i18n && activeLocale && activeLocale !== i18n.defaultLocale) resultParts.push(activeLocale);
628
633
  resultParts.push(...routeContent);
629
634
  let finalPath = `/${resultParts.join("/")}`;
630
635
  if (pathOnly.endsWith("/") && pathOnly.length > 1 && !finalPath.endsWith("/")) finalPath += "/";
@@ -3,7 +3,7 @@
3
3
  * Copyright (c) 2026 Jesus Alcala
4
4
  * Licensed under the MIT License.
5
5
  */
6
- import { G as Link, _ as Link$1, y as cn } from "./icons-dev-kJyGWNeg.js";
6
+ import { G as Link, _ as Link$1, y as cn } from "./icons-dev-CHZOwhQA.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";
@@ -125,7 +125,7 @@ const Heading = React$1.forwardRef(({ level, id, children, className, showAnchor
125
125
  return /* @__PURE__ */ jsx(Tag, {
126
126
  ref,
127
127
  id,
128
- className: cn("boltdocs-heading relative group flex items-center scroll-mt-24", className),
128
+ className: cn("boltdocs-heading relative group flex items-center gap-4 scroll-mt-24", className),
129
129
  ...props,
130
130
  children: renderContent()
131
131
  });
@@ -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-BryEFkJu.cjs');
6
+ const require_icons_dev = require('./icons-dev-YtDoLUsb.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");
@@ -126,7 +126,7 @@ const Heading = react.forwardRef(({ level, id, children, className, showAnchor =
126
126
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Tag, {
127
127
  ref,
128
128
  id,
129
- className: require_icons_dev.cn("boltdocs-heading relative group flex items-center scroll-mt-24", className),
129
+ className: require_icons_dev.cn("boltdocs-heading relative group flex items-center gap-4 scroll-mt-24", className),
130
130
  ...props,
131
131
  children: renderContent()
132
132
  });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Boltdocs - https://boltdocs.vercel.app
3
+ * Copyright (c) 2026 Jesus Alcala
4
+ * Licensed under the MIT License.
5
+ */
6
+ const e=require(`./micromark-util-character-5KqJafVT-C6gnc770.cjs`);function t(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function n(t,n,r,i){let a=i?i-1:1/0,o=0;return s;function s(i){return e.u(i)?(t.enter(r),c(i)):n(i)}function c(i){return e.u(i)&&o++<a?(t.consume(i),c):(t.exit(r),n(i))}}function r(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function i(e,t){return e.length>0?(r(e,e.length,0,t),e):t}function a(t){if(t===null||e.l(t)||e.f(t))return 1;if(e.d(t))return 2}function o(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}const s={partial:!0,tokenize:c};function c(t,r,i){return a;function a(r){return e.u(r)?n(t,o,`linePrefix`)(r):o(r)}function o(t){return t===null||e.c(t)?r(t):i(t)}}function l(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}const u={}.hasOwnProperty;function d(e){let t={},n=-1;for(;++n<e.length;)f(t,e[n]);return t}function f(e,t){let n;for(n in t){let r=(u.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){u.call(r,a)||(r[a]=[]);let e=i[a];p(r[a],Array.isArray(e)?e:e?[e]:[])}}}function p(e,t){let n=-1,i=[];for(;++n<t.length;)(t[n].add===`after`?e:i).push(t[n]);r(e,0,0,i)}const m={};function h(e,t){let n=t||m;return g(e,typeof n.includeImageAlt==`boolean`?n.includeImageAlt:!0,typeof n.includeHtml==`boolean`?n.includeHtml:!0)}function g(e,t,n){if(v(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return _(e.children,t,n)}return Array.isArray(e)?_(e,t,n):``}function _(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=g(e[i],t,n);return r.join(``)}function v(e){return!!(e&&typeof e==`object`)}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return h}});
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Boltdocs - https://boltdocs.vercel.app
3
+ * Copyright (c) 2026 Jesus Alcala
4
+ * Licensed under the MIT License.
5
+ */
6
+ import{c as e,d as t,f as n,l as r,u as i}from"./micromark-util-character-5KqJafVT-DkPKsbgn.mjs";function a(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function o(e,t,n,r){let a=r?r-1:1/0,o=0;return s;function s(r){return i(r)?(e.enter(n),c(r)):t(r)}function c(r){return i(r)&&o++<a?(e.consume(r),c):(e.exit(n),t(r))}}function s(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function c(e,t){return e.length>0?(s(e,e.length,0,t),e):t}function l(e){if(e===null||r(e)||n(e))return 1;if(t(e))return 2}function u(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}const d={partial:!0,tokenize:f};function f(t,n,r){return a;function a(e){return i(e)?o(t,s,`linePrefix`)(e):s(e)}function s(t){return t===null||e(t)?n(t):r(t)}}function p(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}const m={}.hasOwnProperty;function h(e){let t={},n=-1;for(;++n<e.length;)g(t,e[n]);return t}function g(e,t){let n;for(n in t){let r=(m.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){m.call(r,a)||(r[a]=[]);let e=i[a];_(r[a],Array.isArray(e)?e:e?[e]:[])}}}function _(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);s(e,0,0,r)}const v={};function y(e,t){let n=t||v;return b(e,typeof n.includeImageAlt==`boolean`?n.includeImageAlt:!0,typeof n.includeHtml==`boolean`?n.includeHtml:!0)}function b(e,t,n){if(S(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return x(e.children,t,n)}return Array.isArray(e)?x(e,t,n):``}function x(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=b(e[i],t,n);return r.join(``)}function S(e){return!!(e&&typeof e==`object`)}export{o as a,u as c,h as i,s as l,a as n,p as o,l as r,c as s,d as t,y as u};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Boltdocs - https://boltdocs.vercel.app
3
+ * Copyright (c) 2026 Jesus Alcala
4
+ * Licensed under the MIT License.
5
+ */
6
+ const e=(function(e){if(e==null)return a;if(typeof e==`function`)return i(e);if(typeof e==`object`)return Array.isArray(e)?t(e):n(e);if(typeof e==`string`)return r(e);throw Error(`Expected function, string, or object as test`)});function t(t){let n=[],r=-1;for(;++r<t.length;)n[r]=e(t[r]);return i(a);function a(...e){let t=-1;for(;++t<n.length;)if(n[t].apply(this,e))return!0;return!1}}function n(e){let t=e;return i(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function r(e){return i(t);function t(t){return t&&t.type===e}}function i(e){return t;function t(t,n,r){return!!(o(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function a(){return!0}function o(e){return typeof e==`object`&&!!e&&`type`in e}function s(e){return`\x1B[33m`+e+`\x1B[39m`}const c=[];function l(t,n,r,i){let a;typeof n==`function`&&typeof r!=`function`?(i=r,r=n):a=n;let o=e(a),l=i?-1:1;d(t,void 0,[])();function d(e,t,a){let f=e&&typeof e==`object`?e:{};if(typeof f.type==`string`){let t=typeof f.tagName==`string`?f.tagName:typeof f.name==`string`?f.name:void 0;Object.defineProperty(p,`name`,{value:`node (`+s(e.type+(t?`<`+t+`>`:``))+`)`})}return p;function p(){let s=c,f,p,m;if((!n||o(e,t,a[a.length-1]||void 0))&&(s=u(r(e,a)),s[0]===!1))return s;if(`children`in e&&e.children){let t=e;if(t.children&&s[0]!==`skip`)for(p=(i?t.children.length:-1)+l,m=a.concat(t);p>-1&&p<t.children.length;){let e=t.children[p];if(f=d(e,p,m)(),f[0]===!1)return f;p=typeof f[1]==`number`?f[1]:p+l}}return s}}}function u(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?c:[e]}function d(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),l(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Boltdocs - https://boltdocs.vercel.app
3
+ * Copyright (c) 2026 Jesus Alcala
4
+ * Licensed under the MIT License.
5
+ */
6
+ const e=(function(e){if(e==null)return a;if(typeof e==`function`)return i(e);if(typeof e==`object`)return Array.isArray(e)?t(e):n(e);if(typeof e==`string`)return r(e);throw Error(`Expected function, string, or object as test`)});function t(t){let n=[],r=-1;for(;++r<t.length;)n[r]=e(t[r]);return i(a);function a(...e){let t=-1;for(;++t<n.length;)if(n[t].apply(this,e))return!0;return!1}}function n(e){let t=e;return i(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function r(e){return i(t);function t(t){return t&&t.type===e}}function i(e){return t;function t(t,n,r){return!!(o(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function a(){return!0}function o(e){return typeof e==`object`&&!!e&&`type`in e}function s(e){return`\x1B[33m`+e+`\x1B[39m`}const c=[];function l(t,n,r,i){let a;typeof n==`function`&&typeof r!=`function`?(i=r,r=n):a=n;let o=e(a),l=i?-1:1;d(t,void 0,[])();function d(e,t,a){let f=e&&typeof e==`object`?e:{};if(typeof f.type==`string`){let t=typeof f.tagName==`string`?f.tagName:typeof f.name==`string`?f.name:void 0;Object.defineProperty(p,`name`,{value:`node (`+s(e.type+(t?`<`+t+`>`:``))+`)`})}return p;function p(){let s=c,f,p,m;if((!n||o(e,t,a[a.length-1]||void 0))&&(s=u(r(e,a)),s[0]===!1))return s;if(`children`in e&&e.children){let t=e;if(t.children&&s[0]!==`skip`)for(p=(i?t.children.length:-1)+l,m=a.concat(t);p>-1&&p<t.children.length;){let e=t.children[p];if(f=d(e,p,m)(),f[0]===!1)return f;p=typeof f[1]==`number`?f[1]:p+l}}return s}}}function u(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?c:[e]}function d(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),l(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}export{d as n,l as r,e as t};
@@ -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, H as Info, M as Copy, R as File, T as AlertTriangle, W 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, rt as useConfig, u as Markdown, w as AlertCircle, y as cn } from "./icons-dev-kJyGWNeg.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-C9md50h2.js";
6
+ import { D as Check, H as Info, M as Copy, R as File, T as AlertTriangle, W 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, rt as useConfig, u as Markdown, w as AlertCircle, y as cn } from "./icons-dev-CHZOwhQA.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-5WsgWYTh.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";
@@ -104,6 +104,10 @@ const Typographics = {
104
104
  className: cn("bg-primary-500/10 text-primary-500 font-semibold px-1.5 py-0.5 rounded-md", className),
105
105
  ...props
106
106
  }),
107
+ code: ({ className, ...props }) => /* @__PURE__ */ jsx("code", {
108
+ className: cn("bg-code-bg text-code-text rounded-md px-1.5 py-0.5 text-[0.875em] font-mono font-medium", className),
109
+ ...props
110
+ }),
107
111
  blockquote: ({ className, ...props }) => /* @__PURE__ */ jsx("blockquote", {
108
112
  className: cn("border-l-4 border-primary-500 bg-soft/30 pl-4 py-2 my-6 italic text-muted rounded-r-lg", className),
109
113
  ...props
@@ -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-BryEFkJu.cjs');
7
- const require_image = require('./image-CR6UlaI5.cjs');
6
+ const require_icons_dev = require('./icons-dev-YtDoLUsb.cjs');
7
+ const require_image = require('./image-Hb105Gu6.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");
@@ -104,6 +104,10 @@ const Typographics = {
104
104
  className: require_icons_dev.cn("bg-primary-500/10 text-primary-500 font-semibold px-1.5 py-0.5 rounded-md", className),
105
105
  ...props
106
106
  }),
107
+ code: ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
108
+ className: require_icons_dev.cn("bg-code-bg text-code-text rounded-md px-1.5 py-0.5 text-[0.875em] font-mono font-medium", className),
109
+ ...props
110
+ }),
107
111
  blockquote: ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("blockquote", {
108
112
  className: require_icons_dev.cn("border-l-4 border-primary-500 bg-soft/30 pl-4 py-2 my-6 italic text-muted rounded-r-lg", className),
109
113
  ...props
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Boltdocs - https://boltdocs.vercel.app
3
+ * Copyright (c) 2026 Jesus Alcala
4
+ * Licensed under the MIT License.
5
+ */
6
+ const e=f(/[A-Za-z]/),t=f(/[\dA-Za-z]/),n=f(/[#-'*+\--9=?A-Z^-~]/);function r(e){return e!==null&&(e<32||e===127)}const i=f(/\d/),a=f(/[\dA-Fa-f]/),o=f(/[!-/:-@[-`{-~]/);function s(e){return e!==null&&e<-2}function c(e){return e!==null&&(e<0||e===32)}function l(e){return e===-2||e===-1||e===32}const u=f(/\p{P}|\p{S}/u),d=f(/\s/);function f(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return l}});
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Boltdocs - https://boltdocs.vercel.app
3
+ * Copyright (c) 2026 Jesus Alcala
4
+ * Licensed under the MIT License.
5
+ */
6
+ const e=f(/[A-Za-z]/),t=f(/[\dA-Za-z]/),n=f(/[#-'*+\--9=?A-Z^-~]/);function r(e){return e!==null&&(e<32||e===127)}const i=f(/\d/),a=f(/[\dA-Fa-f]/),o=f(/[!-/:-@[-`{-~]/);function s(e){return e!==null&&e<-2}function c(e){return e!==null&&(e<0||e===32)}function l(e){return e===-2||e===-1||e===32}const u=f(/\p{P}|\p{S}/u),d=f(/\s/);function f(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}export{i as a,s as c,u as d,d as f,r as i,c as l,t as n,a as o,n as r,o as s,e as t,l as u};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Boltdocs - https://boltdocs.vercel.app
3
+ * Copyright (c) 2026 Jesus Alcala
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../chunk-Ds5LZdWN.cjs`),t=require(`../utils-Bz1tG9Dg.cjs`);let n=require(`node:path`);n=e.n(n);let r=require(`node:fs/promises`);r=e.n(r);let i=require(`node:crypto`);i=e.n(i);let a=require(`node:zlib`);a=e.n(a);let o=require(`node:util`),s=require(`lru-cache`);const c=r.default.writeFile,l=r.default.readFile,u=r.default.mkdir,d=r.default.rename,f=(0,o.promisify)(a.default.gzip),p=(0,o.promisify)(a.default.gunzip),m=new class{activeTasks=new Set;add(e){let t=Promise.resolve().then(e).catch(()=>{}).finally(()=>{this.activeTasks.delete(t)});this.activeTasks.add(t)}async flush(){await Promise.all(Array.from(this.activeTasks))}get pending(){return this.activeTasks.size}};var h=class{entries=new Map;cachePath=null;compress;constructor(e={}){let r=t.o();if(this.compress=e.compress===void 0?r.compress:e.compress,e.name){let t=e.root||process.cwd(),i=this.compress?`json.gz`:`json`;this.cachePath=n.default.resolve(t,r.dir,`${e.name}.${i}`)}}async load(){if(!t.o().noCache&&this.cachePath)try{let e=await l(this.cachePath);this.cachePath.endsWith(`.gz`)&&(e=await p(e));let t=JSON.parse(e.toString(`utf-8`));this.entries=new Map(Object.entries(t))}catch(e){if(e.code===`ENOENT`)return}}save(){if(t.o().noCache||!this.cachePath)return;let e=Object.fromEntries(this.entries),r=JSON.stringify(e),a=this.cachePath,o=this.compress;m.add(async()=>{try{await u(n.default.dirname(a),{recursive:!0});let e=Buffer.from(r);o&&(e=await f(e));let t=`${a}.${i.default.randomBytes(4).toString(`hex`)}.tmp`;await c(t,e),await d(t,a)}catch{}})}get(e){let n=this.entries.get(e);return!n||t.s(e)!==n.mtime?null:n.data}getStale(e){let t=this.entries.get(e);return t?t.data:null}set(e,n){this.entries.set(e,{data:n,mtime:t.s(e)})}isValid(e){let n=this.entries.get(e);return n?t.s(e)===n.mtime:!1}invalidate(e){this.entries.delete(e)}invalidateAll(){this.entries.clear()}pruneStale(e){for(let t of this.entries.keys())e.has(t)||this.entries.delete(t)}get size(){return this.entries.size}async flush(){await m.flush()}},g=class{index=new Map;memoryCache;baseDir;shardsDir;indexPath;saveTimeout=null;constructor(e,r=process.cwd()){let i=t.o();this.baseDir=n.default.resolve(r,i.dir,`transform-${e}`),this.shardsDir=n.default.resolve(this.baseDir,`shards`),this.indexPath=n.default.resolve(this.baseDir,`index.json`),this.memoryCache=new s.LRUCache({max:i.lruLimit,ttl:i.lruTTL,updateAgeOnGet:!0})}async load(){if(!t.o().noCache)try{let e=await l(this.indexPath,`utf-8`);this.index=new Map(Object.entries(JSON.parse(e)))}catch(e){if(e.code===`ENOENT`)return}}save(){if(t.o().noCache)return;let e=JSON.stringify(Object.fromEntries(this.index)),r=this.indexPath;m.add(async()=>{try{await u(n.default.dirname(r),{recursive:!0}),await c(r,e)}catch{}})}async getMany(e){let t=new Map,r=[];for(let n of e){let e=this.memoryCache.get(n);e?t.set(n,e):this.index.has(n)&&r.push(n)}if(r.length>0){let e=await Promise.all(r.map(async e=>{let t=this.index.get(e),r=n.default.resolve(this.shardsDir,`${t}.gz`);try{let t=(await p(await l(r))).toString(`utf-8`);return this.memoryCache.set(e,t),{key:e,val:t}}catch{return null}}));for(let n of e)n&&t.set(n.key,n.val)}return t}async getAsync(e){let t=this.memoryCache.get(e);if(t)return t;let r=this.index.get(e);if(!r)return null;let i=n.default.resolve(this.shardsDir,`${r}.gz`);try{let t=(await p(await l(i))).toString(`utf-8`);return this.memoryCache.set(e,t),t}catch(e){return e.code,null}}set(e,t){let a=i.default.createHash(`md5`).update(t).digest(`hex`);this.index.set(e,a),this.memoryCache.set(e,t);let o=n.default.resolve(this.shardsDir,`${a}.gz`);m.add(async()=>{try{try{await r.default.access(o);return}catch{}await u(this.shardsDir,{recursive:!0});let e=await f(Buffer.from(t)),n=`${o}.${i.default.randomBytes(4).toString(`hex`)}.tmp`;await c(n,e),await d(n,o)}catch{}}),this.saveTimeout&&clearTimeout(this.saveTimeout),this.saveTimeout=setTimeout(()=>{this.save()},500),typeof this.saveTimeout.unref==`function`&&this.saveTimeout.unref()}get size(){return this.index.size}async flush(){await m.flush()}};async function _(){await m.flush()}exports.FileCache=h,exports.TransformCache=g,exports.flushCache=_,exports.globalBackgroundQueue=m;
@@ -0,0 +1,83 @@
1
+
2
+ //#region src/node/cache.d.ts
3
+ /**
4
+ * Simple background task queue to prevent blocking the main thread during IO.
5
+ */
6
+ declare class BackgroundQueue {
7
+ private activeTasks;
8
+ add(task: () => Promise<any>): void;
9
+ flush(): Promise<void>;
10
+ get pending(): number;
11
+ }
12
+ declare const globalBackgroundQueue: BackgroundQueue;
13
+ /**
14
+ * Generic file-based cache with per-file granularity and asynchronous persistence.
15
+ */
16
+ declare class FileCache<T> {
17
+ private entries;
18
+ private readonly cachePath;
19
+ private readonly compress;
20
+ constructor(options?: {
21
+ name?: string;
22
+ root?: string;
23
+ compress?: boolean;
24
+ });
25
+ /**
26
+ * Loads the cache.
27
+ */
28
+ load(): Promise<void>;
29
+ /**
30
+ * Saves the cache in the background.
31
+ */
32
+ save(): void;
33
+ get(filePath: string): T | null;
34
+ getStale(filePath: string): T | null;
35
+ set(filePath: string, data: T): void;
36
+ isValid(filePath: string): boolean;
37
+ invalidate(filePath: string): void;
38
+ invalidateAll(): void;
39
+ pruneStale(currentFiles: Set<string>): void;
40
+ get size(): number;
41
+ flush(): Promise<void>;
42
+ }
43
+ /**
44
+ * Sharded Cache: Optimized for large-scale data (like MDX transformations).
45
+ * Uses a memory index and individual files for each entry to avoid massive JSON parsing.
46
+ */
47
+ declare class TransformCache {
48
+ private index;
49
+ private memoryCache;
50
+ private readonly baseDir;
51
+ private readonly shardsDir;
52
+ private readonly indexPath;
53
+ private saveTimeout;
54
+ constructor(name: string, root?: string);
55
+ /**
56
+ * Loads the index into memory.
57
+ */
58
+ load(): Promise<void>;
59
+ /**
60
+ * Persists the index in background.
61
+ */
62
+ save(): void;
63
+ /**
64
+ * Batch Read: Retrieves multiple transformation results concurrently.
65
+ */
66
+ getMany(keys: string[]): Promise<Map<string, string>>;
67
+ /**
68
+ * Retrieves a cached transformation asynchronously. Fast lookup via index, lazy loading from disk.
69
+ */
70
+ getAsync(key: string): Promise<string | null>;
71
+ /**
72
+ * Stores a transformation result.
73
+ */
74
+ set(key: string, result: string): void;
75
+ get size(): number;
76
+ flush(): Promise<void>;
77
+ }
78
+ /**
79
+ * Flushes all pending background cache operations.
80
+ */
81
+ declare function flushCache(): Promise<void>;
82
+ //#endregion
83
+ export { FileCache, TransformCache, flushCache, globalBackgroundQueue };