@qualcomm-ui/mdx-vite 3.8.1 → 3.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qualcomm-ui/mdx-vite",
3
- "version": "3.8.1",
3
+ "version": "3.8.2",
4
4
  "description": "Vite documentation plugin for applications that use MDX",
5
5
  "author": "Ryan Bower",
6
6
  "license": "BSD-3-Clause-Clear",
@@ -1,14 +0,0 @@
1
- import{createRequire as e}from"node:module";e(import.meta.url);import{execSync as t}from"node:child_process";import{dirname as n,join as r,posix as i,resolve as a}from"node:path";import{readFileSync as o}from"node:fs";import{access as s}from"node:fs/promises";import{cosmiconfigSync as c}from"cosmiconfig";import{z as l}from"zod";import u from"chalk";import{defined as d}from"@qualcomm-ui/utils/guard";import f from"remark-mdx";import p from"remark-parse";import m from"remark-stringify";import{unified as h}from"unified";import{EXIT as g,SKIP as _,visit as v}from"unist-util-visit";import{UniqueIdService as y,isNavBadge as b}from"@qualcomm-ui/mdx-common";import{createHash as x}from"node:crypto";import S from"remark-frontmatter";import C from"remark-parse-frontmatter";import w from"remark-gfm";import{remove as T}from"unist-util-remove";import{toString as E}from"mdast-util-to-string";import D from"typescript";import{sortBy as O}from"lodash-es";import{v4 as k}from"uuid";import{capitalCase as A}from"@qualcomm-ui/utils/change-case";function fixPath(e){return e.replaceAll(`\\`,`/`)}function removeTrailingSlash(e){return e.endsWith(`/`)?e.substring(0,e.length-1):e}function implement(){return{with:e=>l.object(e)}}var j=implement().with({id:l.never().optional(),sectionTitle:l.string().optional(),separator:l.boolean().optional()}),M=implement().with({children:l.array(l.lazy(()=>M)).optional(),expanded:l.boolean().optional(),group:l.string().optional(),groupOrder:l.string().array().optional(),hidden:l.boolean().optional(),hideBreadcrumbs:l.boolean().optional(),hideFromSearch:l.boolean().optional(),hidePageLinks:l.boolean().optional(),hideSideNav:l.boolean().optional(),hideToc:l.boolean().optional(),id:l.string(),ignoreRouteMetaOrder:l.boolean().optional(),restricted:l.boolean().optional(),sectionTitle:l.never().optional(),separator:l.never().optional(),sideNavTitle:l.string().optional(),title:l.string().optional()}),N=implement().with({includeInSearchIndex:l.boolean().optional()}),ee=implement().with({contents:l.string(),id:l.string(),processAsMdx:l.boolean().optional(),title:l.string().optional()}),P=l.object({exclude:l.array(l.string()).optional(),include:l.array(l.string()).optional()}).optional(),F=implement().with({outputPath:l.string().optional()}),I=implement().with({depths:l.array(l.number()).optional(),minContentLength:l.number().optional(),outputPath:l.string().optional()}),L=implement().with({envFile:l.string().optional(),id:l.string()}),R=implement().with({baseUrl:l.string().optional(),exclude:l.array(l.string()).optional(),extraFiles:l.array(ee).optional(),frontmatter:P,integrations:l.object({openWebUi:l.array(L).optional()}).optional(),outputPath:l.string().optional(),pageIdPrefix:l.string().optional(),pages:F.optional(),sections:I.optional()}),z=implement().with({appDirectory:l.string().optional(),disableCache:l.boolean().optional(),headings:l.array(l.union([l.literal(`h1`),l.literal(`h2`),l.literal(`h3`),l.literal(`h4`),l.literal(`h5`),l.literal(`h6`)])).optional(),hotUpdateIgnore:l.instanceof(RegExp).optional(),knowledge:R.optional(),navConfig:l.array(l.union([M,j])).optional(),pageDirectory:l.string().optional(),pageTimestampMetadata:l.union([l.literal(`off`),l.literal(`timestamp`),l.literal(`user-and-timestamp`)]).optional(),routingStrategy:l.union([l.literal(`vite-generouted`),l.literal(`react-router-directory-groups`),l.any()]).optional(),throwOnError:l.boolean().optional(),typeDocProps:l.string().optional(),typeDocPropsOptions:N.optional(),validatePageLinks:l.boolean().optional()}),ConfigLoader=class{constructor(e){return this.options=e,this}getCosmiconfig(){let e=c(`qui-docs`),t=this.options.configFile?e.load(this.options.configFile):e.search();if(!t)throw Error(`Config file not found. Please consult the docs at https://docs.qui.qualcomm.com/guide/page-setup#config`);return t}resolveConfigFromCosmiconfig(e){let t=z.safeParse(e.config);if(!t.success)throw console.dir(t.error.issues,{depth:10}),Error(`Failed to parse config file.`);let n=t.data;return{...n,appDirectory:n.appDirectory||`app`,filePath:e.filepath,pageDirectory:n.pageDirectory?removeTrailingSlash(n.pageDirectory):`routes`,validatePageLinks:n.validatePageLinks??!0}}loadConfig(){let e=this.getCosmiconfig();return this.resolveConfigFromCosmiconfig(e)}};function slugify(e){let t=e.replace(/[<>]/g,``).replace(/[^\w\s-]/g,``).trim();return t.includes(` `)?t.toLowerCase().replace(/\s+/g,`-`).replace(/^-+|-+$/g,``):(t.match(/[A-Z]/g)||[]).length>=2?t.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).replace(/([A-Z]+)([A-Z][a-z])/g,`$1-$2`).toLowerCase():t.toLowerCase()}var SlugGenerator=class{constructor(){this.seenIds=new Map}reset(){this.seenIds.clear()}createSlug(e){let t=slugify(e),n=this.seenIds.get(t)||0;return this.seenIds.set(t,n+1),n>0?`${t}-${n}`:t}},B=implement().with({categories:l.string().array().optional(),description:l.string().optional(),group:l.string().optional(),hidden:l.boolean().optional(),hideBreadcrumbs:l.boolean().optional(),hideFromSearch:l.boolean().optional(),hidePageLinks:l.boolean().optional(),hideSideNav:l.boolean().optional(),hideToc:l.boolean().optional(),id:l.string().optional(),restricted:l.boolean().optional(),sideNavTitle:l.string().optional(),title:l.string(),updatedBy:l.string().optional(),updatedOn:l.string().optional()});function buildGitMetadataMap(e,n){let r=new Map;if(n===`off`)return r;try{let i=t(`git rev-parse --show-toplevel`,{encoding:`utf-8`}).trim(),o=t(`git log --format="COMMIT%x09${n===`user-and-timestamp`?`%cI%x09%aN`:`%cI`}" --name-only -- "${e}/**/*.mdx"`,{encoding:`utf-8`,stdio:[`pipe`,`pipe`,`pipe`]}),s={};for(let e of o.split(`
2
- `))if(e.startsWith(`COMMIT `)){let t=e.split(` `);s=n===`user-and-timestamp`?{updatedBy:t[2],updatedOn:t[1]}:{updatedOn:t[1]}}else if(e.trim()){let t=a(i,e.trim());r.has(t)||r.set(t,s)}}catch{}return r}var MdxFileReader=class{constructor(e,t=`off`){this.enabled=e,this.pageTimestampMetadata=t,this.cachedFileCount=0,this.gitMetadataMap=new Map,this.logWarnings=!0,this.mdxCache={}}hash(e){return x(`md5`).update(e).digest(`hex`)}reset(){this.cachedFileCount=0}readCache(e){return this.mdxCache[e]||null}checkCache(e,t){if(!this.enabled)return;let n=this.hash(t),r=this.mdxCache[e];if(r?.md5===n)return this.cachedFileCount++,{collectedLinks:r.collectedLinks,frontmatter:r.frontmatter,page:r.page,pageDocProps:r.pageDocProps,pageDocPropSections:r.pageDocPropSections}}parseFrontmatter(e,t,n){let r;if(n)r={data:{frontmatter:n}};else{let e=t.substring(0,t.indexOf(`
3
- ---`)+4);r=h().use(p).use(S,[`yaml`]).use(C).use(m).processSync(e)}let i=r.data.frontmatter??{title:``};if(!i.title){let e=t.split(`
4
- `).find(e=>e.startsWith(`# `));e&&(i.title=e.substring(2).trim())}!i.title&&this.logWarnings&&console.debug(u.red.bold(`Missing title:`),e);let a=B.safeParse(i);return a.success||(console.debug(`${u.redBright.bold(`Invalid frontmatter detected for file`)}: ${e}\n`),console.debug(u.redBright.bold(`Please check the following fields:`)),a.error.issues.map(e=>{console.debug(`- ${e.path.join(`.`)}`)})),i}enrichWithGitMetadata(e,t,n){let r=this.mdxCache[e];if(!this.enabled||!r){let n=this.gitMetadataMap.get(e)??{};!t.updatedOn&&n.updatedOn&&(t.updatedOn=n.updatedOn),!t.updatedBy&&n.updatedBy&&(t.updatedBy=n.updatedBy)}else !n&&r&&(!t.updatedOn&&r.frontmatter.updatedOn&&(t.updatedOn=r.frontmatter.updatedOn),!t.updatedBy&&r.frontmatter.updatedBy&&(t.updatedBy=r.frontmatter.updatedBy))}readFileSync(e){let t=o(e,`utf-8`),n=this.checkCache(e,t),r=this.parseFrontmatter(e,t,n?.frontmatter);return this.enrichWithGitMetadata(e,r,n),{cached:n,fileContents:t,frontmatter:r}}updateCache(e,t,n){this.enabled&&(this.mdxCache[e]={...n,md5:this.hash(t)})}};function extractNamesFromAttribute(e){if(!e.value)return[];if(typeof e.value==`string`)return[e.value];if(e.value.type===`mdxJsxAttributeValueExpression`){let t=e.value.data?.estree;if(!t?.body?.[0]||t.body[0].type!==`ExpressionStatement`)return[];let n=t.body[0].expression;if(n.type===`ArrayExpression`){let e=[];for(let t of n.elements)t?.type===`Literal`&&typeof t.value==`string`&&e.push(t.value);return e}if(n.type===`Literal`&&typeof n.value==`string`)return[n.value]}return[]}var V=/^\[!(NOTE|TIP|SUCCESS|WARNING|CAUTION)(\/.*)?\]/i,remarkAlerts=()=>e=>{v(e,`blockquote`,e=>{let t=``,n=``,r=!0,i=e.children.map(e=>{if(r&&e.type===`paragraph`){let i=e.children[0],a=i.type===`text`?i.value:``,o=V,s=a.match(o);if(s&&(r=!1,t=s[1].toLocaleLowerCase(),n=s[2]||t.toLocaleUpperCase(),a.includes(`
5
- `)&&(e.children[0]={type:`text`,value:a.replace(o,``).replace(/^\n+/,``)}),!a.includes(`
6
- `))){let t=[];e.children.forEach((e,n)=>{n!==0&&(n===1&&e.type===`break`||t.push(e))}),e.children=[...t]}}return e});n=n.replace(/^\//,``),t&&(e.data={hName:`div`,hProperties:{class:`qui-notification__root`,"data-emphasis":U[t]||`neutral`,"data-orientation":`vertical`,dir:`auto`}},e.children=[{children:[getAlertIcon(t)],data:{hProperties:{class:`qui-notification__icon`,"data-inline-notification-part":`status-icon`}},type:`paragraph`},{children:[{type:`text`,value:n}],data:{hProperties:{class:`qui-notification__label`,dir:`auto`}},type:`paragraph`},{children:i,data:{hName:`div`,hProperties:{class:`qui-notification__description`,dir:`auto`}},type:`blockquote`}])})};function getAlertIcon(e){return{children:H[e]??[],data:{hName:`svg`,hProperties:{ariaHidden:`true`,class:`lucide`,fill:`transparent`,height:`20`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,viewBox:`0 0 24 24`,width:`20`}},type:`emphasis`}}var H={caution:[{children:[],data:{hName:`polygon`,hProperties:{points:`7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86 7.86 2`}},type:`emphasis`},{children:[],data:{hName:`line`,hProperties:{x1:`12`,x2:`12`,y1:`8`,y2:`12`}},type:`emphasis`},{children:[],data:{hName:`line`,hProperties:{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`}},type:`emphasis`}],note:[{children:[],data:{hName:`circle`,hProperties:{cx:`12`,cy:`12`,r:`10`}},type:`emphasis`},{children:[],data:{hName:`path`,hProperties:{d:`M12 16v-4`}},type:`emphasis`},{children:[],data:{hName:`path`,hProperties:{d:`M12 8h.01`}},type:`emphasis`}],success:[{children:[],data:{hName:`path`,hProperties:{d:`M20 6 9 17l-5-5`}},type:`emphasis`}],tip:[{children:[],data:{hName:`path`,hProperties:{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`}},type:`emphasis`},{children:[],data:{hName:`path`,hProperties:{d:`M9 18h6`}},type:`emphasis`},{children:[],data:{hName:`path`,hProperties:{d:`M10 22h4`}},type:`emphasis`}],warning:[{children:[],data:{hName:`path`,hProperties:{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`}},type:`emphasis`},{children:[],data:{hName:`path`,hProperties:{d:`M12 9v4`}},type:`emphasis`},{children:[],data:{hName:`path`,hProperties:{d:`M12 17h.01`}},type:`emphasis`}]},U={caution:`danger`,note:`neutral`,success:`success`,tip:`info`,warning:`warning`};function parseTabAttributes(e){if(!e)return{label:null,remainingMeta:``,tabsGroup:null};let t=e.match(/tabs=["']([^"']+)["']|tabs=(\S+)/),n=e.match(/label=["']([^"']+)["']|label=(\S+)/),r=t?t[1]||t[2]:null;return{label:n?n[1]||n[2]:null,remainingMeta:e.replace(/\s*tabs=["']([^"']+)["']/g,``).replace(/\s*tabs=(\S+)/g,``).replace(/\s*label=["']([^"']+)["']/g,``).replace(/\s*label=(\S+)/g,``).trim(),tabsGroup:r}}function findConsecutiveTabs(e,t,n){let r=[],i=e;for(;i<t.children.length;){let e=t.children[i];if(!e||e.type!==`code`)break;let a=e;if(!a.meta)break;let{label:o,remainingMeta:s,tabsGroup:c}=parseTabAttributes(a.meta);if(!c||!o||c!==n||(a.meta=s||void 0,r.push({index:i,label:o,meta:s||void 0,tabsGroup:c}),s&&s.includes(`end`)))break;i++}return r}function renderTabs(e,t){let n={attributes:[],children:[],name:`CodeTabs`,type:`mdxJsxFlowElement`};return e.forEach(e=>{let r=t.children[e.index],i=[{name:`label`,type:`mdxJsxAttribute`,value:e.label}];e.meta&&i.push({name:`meta`,type:`mdxJsxAttribute`,value:e.meta});let a={attributes:i,children:[{lang:r.lang,meta:r.meta,type:`code`,value:r.value}],name:`CodeTab`,type:`mdxJsxFlowElement`};n.children.push(a)}),[n]}var remarkCodeTabs=()=>e=>{let t=[];v(e,`code`,(e,n,r)=>{if(!e.meta||!r||n===void 0)return;let{label:i,tabsGroup:a}=parseTabAttributes(e.meta);if(!a||!i||t.some(e=>e.parent===r&&n>=e.startIndex&&n<e.endIndex))return;let o=findConsecutiveTabs(n,r,a);if(o.length>1){let e=o[0].index,n=o[o.length-1].index+1,i=renderTabs(o,r);t.push({endIndex:n,parent:r,replacement:i,startIndex:e})}}),t.sort((e,t)=>t.startIndex-e.startIndex).forEach(e=>{e.parent.children.splice(e.startIndex,e.endIndex-e.startIndex,...e.replacement)})};function parseValue(e){let t=e.trim();return t.startsWith(`[`)&&t.endsWith(`]`)?t.slice(1,-1).split(`,`).map(e=>e.trim()).filter(Boolean):t}function parseMetaContent(e){let t={},n=e.split(`
7
- `);for(let e of n){let n=e.trim();if(!n||n===`:::`)continue;let r=n.indexOf(`:`);if(r===-1)continue;let i=n.slice(0,r).trim(),a=n.slice(r+1).trim();i&&a&&(t[i]=parseValue(a))}return t}function parseTermsContent(e){return e.split(`
8
- `).map(e=>e.trim()).filter(e=>e&&e!==`:::`)}var remarkExtractMeta=(e={})=>t=>{let n=[];v(t,`paragraph`,(t,r,i)=>{if(!i||r===void 0)return;let a=t.children[0];if(a?.type!==`text`)return;let o=a.value,s=o.match(/^:::\s*meta\s*/),c=o.match(/^:::\s*terms\s*/);if(!s&&!c)return;let l=s||c,u=!!c;if(o.includes(`:::`)&&o.lastIndexOf(`:::`)>l[0].length){let t=o.slice(l[0].length),a=t.lastIndexOf(`:::`),s=t.slice(0,a);if(u){let t=parseTermsContent(s);if(t.length>0){let n=e.terms;e.terms=Array.isArray(n)?[...n,...t]:t}}else{let t=parseMetaContent(s);Object.assign(e,t)}return n.push({index:r,parent:i}),_}let d=o;for(let e=1;e<t.children.length;e++){let n=t.children[e];n.type===`text`&&(d+=n.value)}let f=d.slice(l[0].length),p=f.lastIndexOf(`:::`);if(p!==-1){let t=f.slice(0,p);if(u){let n=parseTermsContent(t);if(n.length>0){let t=e.terms;e.terms=Array.isArray(t)?[...t,...n]:n}}else{let n=parseMetaContent(t);Object.assign(e,n)}return n.push({index:r,parent:i}),_}});for(let e=n.length-1;e>=0;e--){let{index:t,parent:r}=n[e];r.children.splice(t,1)}},remarkFrontmatterDescription=()=>e=>{v(e,`mdxFlowExpression`,(e,t,n)=>{if(e.value.trim()!==`frontmatter.description`||t===void 0||!n)return;let r={attributes:[{name:`className`,type:`mdxJsxAttribute`,value:`mdx qui-docs__page-description`}],children:[e],name:`p`,type:`mdxJsxFlowElement`};n.children[t]=r})},W=/^\s*frontmatter\.(\w+)\s*$/;function isMdxExpression(e){let t=e;return(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)&&typeof t.value==`string`}var remarkFrontmatterInterpolation=e=>t=>{v(t,(t,n,r)=>{if(!isMdxExpression(t)||n===void 0||!r)return;let i=t.value.match(W);if(!i)return;let a=e[i[1]];if(typeof a==`string`||typeof a==`number`){let e={type:`text`,value:String(a)};r.children[n]=e}})},remarkFrontmatterTitle=()=>e=>{v(e,`heading`,(e,t,n)=>{if(t===void 0||!n||e.depth!==1)return;let r={attributes:[],children:e.children,name:`PageHeader`,type:`mdxJsxFlowElement`};return n.children[t]=r,g})},remarkRemoveMermaidCodeBlocks=()=>(e,t,n)=>{T(e,e=>e.type===`code`&&e.lang===`mermaid`),n()},remarkRemoveJsx=()=>(e,t,n)=>{T(e,`mdxjsEsm`),T(e,`mdxJsxFlowElement`),T(e,`mdxJsxTextElement`),n()},G={};function remarkSelfLinkHeadings(e=``,t){return e?()=>{let n=t||G,r=n.prefix||``,i=new Set(n.allowedLevels||[2,3,4]),a=new Map;function createSlug(e){let t=e.replace(/[<>]/g,``).replace(/[^\w\s-]/g,``).trim(),n;n=t.includes(` `)?t.toLowerCase().replace(/\s+/g,`-`).replace(/^-+|-+$/g,``):(t.match(/[A-Z]/g)||[]).length>=2?t.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).replace(/([A-Z]+)([A-Z][a-z])/g,`$1-$2`).toLowerCase():t.toLowerCase();let r=a.get(n)||0;return a.set(n,r+1),r>0?`${n}-${r}`:n}return t=>{a.clear(),v(t,`heading`,t=>{if(i.has(t.depth)){let n=r+createSlug(E(t));t.children=[{children:t.children,type:`link`,url:`${e}#${n}`}]}})}}:()=>{}}function getSerializeJsxStartMatch(e){return e.match(/^:::\s*serialize-jsx\s*$/)}function getSerializeJsxEndMatch(e){return e.trim()===`:::`}function isSerializeJsxBlock(e){return!!getSerializeJsxStartMatch(e)||!!getSerializeJsxEndMatch(e)}var isJsxNode=e=>e.type===`mdxJsxFlowElement`||e.type===`mdxJsxTextElement`;function createSerializeJsxPlugin(e){return()=>t=>{v(t,`paragraph`,(t,n,r)=>{if(!r||n===void 0)return;let i=t.children[0];if(i?.type!==`text`||!getSerializeJsxStartMatch(i.value))return;let a=n+1,o=[];for(;a<r.children.length;){let e=r.children[a];if(e.type===`paragraph`){let t=e.children[0];if(t?.type===`text`&&getSerializeJsxEndMatch(t.value))break}o.push(e),a++}a>=r.children.length||r.children.splice(n,a-n+1,...o.filter(e))})}}var K=createSerializeJsxPlugin(isJsxNode),q=createSerializeJsxPlugin(e=>!isJsxNode(e));function getSpoilerStartMatch(e){return e.match(/^:::\s*spoiler\s*(.*)$/)}function getSpoilerEndMatch(e){return e.trim()===`:::`}function isSpoilerBlock(e){return!!getSpoilerStartMatch(e)||getSpoilerEndMatch(e)}var remarkSpoilers=(e={})=>{let{defaultSummary:t=`Open spoiler`,detailsClassName:n=[],summaryClassName:r=[]}=e;return e=>{v(e,`paragraph`,(e,i,a)=>{if(!a||i===void 0)return;let o=e.children[0];if(o?.type!==`text`)return;let s=getSpoilerStartMatch(o.value);if(!s)return;let c=s[1].trim()||t,l=i+1,u=[];for(;l<a.children.length;){let e=a.children[l];if(e.type===`paragraph`){let t=e.children[0];if(t?.type===`text`&&getSpoilerEndMatch(t.value.trim()))break}u.push(e),l++}if(l>=a.children.length)return;let d={attributes:r.length?[{name:`className`,type:`mdxJsxAttribute`,value:r.join(` `)}]:[],children:[{children:[{type:`text`,value:c}],type:`paragraph`}],name:`SpoilerSummary`,type:`mdxJsxFlowElement`},f={attributes:[],children:u,name:`SpoilerContent`,type:`mdxJsxFlowElement`},p={attributes:n.length?[{name:`className`,type:`mdxJsxAttribute`,value:n.join(` `)}]:[],children:[d,f],name:`SpoilerRoot`,type:`mdxJsxFlowElement`};a.children.splice(i,l-i+1,p)})}},J=new Set([2,3,4]);function parseHeadingRange(e){let t=e.match(/^h([1-6])(?:-h([1-6]))?$/);if(!t)return;let n=Number(t[1]),r=t[2]?Number(t[2]):n;if(n>r)return;let i=new Set;for(let e=n;e<=r;e++)i.add(e);return i}function isHeading(e){return e.type===`heading`}function getStepStartMatch(e){return e.match(/^:::\s*steps(?:\s+(h[1-6](?:-h[1-6])?))?\s*$/)}function getStepEndMatch(e){return e.match(/^:::\s*\/steps\s*$/)}function isStepBlock(e){return!!(getStepStartMatch(e)||getStepEndMatch(e))}var remarkSteps=()=>e=>{v(e,`paragraph`,(e,t,n)=>{if(!n||t===void 0)return;let r=e.children[0];if(r?.type!==`text`)return;let i=getStepStartMatch(r.value);if(!i)return;let a=i[1]?parseHeadingRange(i[1])??J:J,o=t+1,s=[];for(;o<n.children.length;){let e=n.children[o];if(e.type===`paragraph`){let t=e.children[0];if(t?.type===`text`&&getStepEndMatch(t.value))break}isHeading(e)&&a.has(e.depth)&&(e.data={...e.data,hProperties:{...e.data?.hProperties,"data-step":``}}),s.push(e),o++}if(o>=n.children.length)return;let c={attributes:[],children:s,name:`HeadingSteps`,type:`mdxJsxFlowElement`};n.children.splice(t,o-t+1,c)})};function createRemarkProcessor(e={}){let t=h().use(p);if(e.mdx&&t.use(f),e.frontmatter&&t.use(S,[`yaml`]),e.removeJsx&&t.use(remarkRemoveJsx),e.removeMermaidCodeBlocks&&t.use(remarkRemoveMermaidCodeBlocks),e.gfm&&t.use(w),e.alerts&&t.use(remarkAlerts),e.interpolateFrontmatter&&t.use(remarkFrontmatterInterpolation,e.interpolateFrontmatter),e.extractMeta&&t.use(remarkExtractMeta,e.extractMeta),e.plugins)for(let n of e.plugins)Array.isArray(n)?t.use(...n):t.use(n);return e.output===`md`&&t.use(m),t}function extractPickPropsRecord(e){if(e.name!==`unionWithPick`||!e.value||typeof e.value==`string`)return null;let t=e.value.data?.estree;if(!t?.body?.[0]||t.body[0].type!==`ExpressionStatement`)return null;let n=t.body[0].expression;if(n.type!==`ObjectExpression`)return null;let r={};for(let e of n.properties){if(e.type!==`Property`||e.key.type!==`Identifier`||e.value.type!==`ArrayExpression`)continue;let t=e.key.name,n=[];for(let t of e.value.elements)t?.type===`Literal`&&typeof t.value==`string`&&n.push(t.value);r[t]=n}return r}var Y=[`TypeDocProps`,`TypeDocAttributes`,`TypeDocAngularAttributes`,`TypeDocFunction`],DocPropsIndexer=class{constructor(e){this.docPropsEntries=[],this.idService=new y,this.pageDocProps={},this.getTypeDocPropsNodes=()=>(e,t,n)=>{v(e,`mdxJsxFlowElement`,e=>{if(e&&`name`in e&&Y.includes(e.name)){let t=e.attributes?.find(e=>e.name===`name`),n=e.attributes?.find(e=>e.name===`omitFrom`),r=n?extractNamesFromAttribute(n):void 0;if(t){let e=extractNamesFromAttribute(t);for(let t of e)this.docPropsEntries.push({name:t,omitFrom:r}),t.endsWith(`Props`)&&this.docPropsEntries.push({name:t.slice(0,-5),omitFrom:r})}let i=e.attributes?.find(e=>e.name===`unionWithPick`);if(i)try{let e=extractPickPropsRecord(i);e&&this.docPropsEntries.push(...Object.keys(e).map(e=>({name:e,omitFrom:r})))}catch{}}}),n()},this.props=e}reset(){this.idService.reset(),this.docPropsEntries=[]}build(e,t){if(h().use(f).use(this.getTypeDocPropsNodes).use(p).use(m).processSync(e),!this.docPropsEntries.length)return null;for(let e of t)this.idService.add(e.id);return this.docPropsEntries.map(e=>{let t=this.props[e.name];if(!t)return[];let n=new Set((e.omitFrom??[]).map(e=>{let t=this.props[e];return t?[t.props,t.input,t.output,t.publicMethods].reduce((e,t)=>(t&&e.push(...t.map(e=>e.name)),e),[]):[]}).flat(1).filter(Boolean)),r=[],assembleProps=e=>{if(!e)return;let t=[];for(let i of e){if(n.has(i.name))continue;let e=this.idService.add(i.name);t.push({...i,id:e}),r.push(this.assembleProp(i,e))}return t},i=t.resolvedType,a=i?.type===`signature`&&i.functionParameters?.length?this.assembleFunctionParams(i.functionParameters,r):void 0;return this.pageDocProps[e.name]={...this.props[e.name],input:assembleProps(t.input),output:assembleProps(t.output),props:assembleProps(t.props),publicMethods:assembleProps(t.publicMethods),resolvedType:a?{...i,functionParameters:a}:i},r}).flat()}getDocProps(){return this.docPropsEntries.reduce((e,t)=>{let n=this.pageDocProps[t.name];return n&&(e[t.name]=n),e},{})}assembleFunctionParams(e,t){return e.map(e=>{let n=this.idService.add(e.name);t.push(this.assembleProp(e,n));let r=e.args?.length?this.assembleFunctionParams(e.args,t):void 0;return{...e,args:r,id:n}})}assembleProp(e,t){let n={headingLevel:4,id:t,tagName:`a`,textContent:e.name},r=e.comment;return r?{content:[{tagName:`p`,text:[r.summary.map(e=>e.text.replaceAll(`
9
- `,` `)).join(``)]}],heading:n}:{content:[],heading:n}}},X=[`https://`,`http://`,`mailto:`,`tel:`];function isExternal(e){return X.some(t=>e.startsWith(t))}function resolveLink(e,t){if(isExternal(e))return null;let[n,r]=e.split(`#`,2),a;if(!n||n===`./`||n===`.`)a=t;else if(n.startsWith(`/`))a=n;else{let e=t.endsWith(`/`)?t:i.dirname(t);a=i.resolve(e,n)}return a!==`/`&&a.endsWith(`/`)&&(a=a.slice(0,-1)),{fragment:r||void 0,pathname:a}}function collectLinks(e,t,n){let r=[];return v(e,`link`,e=>{let i=resolveLink(e.url,n);i&&r.push({fragment:i.fragment,sourceFile:t,sourcePathname:n,targetPathname:i.pathname,url:e.url})}),r}function getLiteralAttributeValue(e,t){let n=e.attributes.find(e=>e.type===`mdxJsxAttribute`&&e.name===t);return typeof n?.value==`string`?n.value:void 0}function collectAnchorIds(e){let t=new Set,collectAnchorId=e=>{if(e.name!==`a`)return;let n=getLiteralAttributeValue(e,`id`);n&&t.add(n)};return v(e,`mdxJsxFlowElement`,collectAnchorId),v(e,`mdxJsxTextElement`,collectAnchorId),t}function validateLinks(e,t,n,r){let i=[];for(let a of e){let e=t[a.targetPathname];if(!e){i.push({...a,reason:`page-not-found`});continue}if(a.fragment){let t=e.toc?.some(e=>e.id===a.fragment),o=n?.[a.targetPathname]?.has(a.fragment),s=r?.[a.targetPathname]?.has(a.fragment);!t&&!o&&!s&&i.push({...a,reason:`fragment-not-found`})}}return i}function reportInvalidLinks(e){if(e.length===0)return;let t=new Map;for(let n of e){let e=t.get(n.sourcePathname)??[];e.push(n),t.set(n.sourcePathname,e)}console.debug(`\n${u.yellowBright.bold(`Found ${e.length} broken link${e.length===1?``:`s`}:`)}`);for(let[e,n]of t){console.debug(`\n ${u.blueBright.bold(e)}`);for(let e of n){let t=e.reason===`page-not-found`?`page not found`:`fragment "#${e.fragment}" not found`;console.debug(` ${u.red(`x`)} ${e.url} — ${t}`)}}console.debug(``)}async function exists(e){return s(e).then(()=>!0).catch(()=>!1)}function computeMd5(e){return x(`md5`).update(e).digest(`hex`)}function isPreviewLine(e){return e===`// preview`||/^\{\s*\/\*\s*preview\s*\*\/\s*\}$/.test(e)||/^<!--\s*preview\s*-->$/.test(e)}function removePreviewLines(e){return e.split(`
10
- `).filter(e=>!isPreviewLine(e.trim())).join(`
11
- `)}function extractRelativeImports(e){let t=D.createSourceFile(`temp.ts`,e,D.ScriptTarget.Latest,!1,D.ScriptKind.TSX),n=[];for(let e of t.statements)if(D.isImportDeclaration(e)&&D.isStringLiteral(e.moduleSpecifier)){let t=e.moduleSpecifier.text;t.startsWith(`.`)&&n.push(t)}return n}async function resolveModulePath(e,t){let i=a(n(t),e);for(let e of[`.ts`,`.tsx`,`.js`,`.jsx`,``]){let t=i+e;if(await exists(t))return t}if(await exists(i)){let e=r(i,`index.ts`);if(await exists(e))return e}return null}function transformLinks(){return()=>e=>{v(e,`link`,e=>{let t=``;v(e,`text`,e=>{t+=e.value}),Object.assign(e,{children:void 0,type:`inlineCode`,url:void 0,value:t})})}}var Z=h().use(w).use(m),Q=h().use(w).use(transformLinks()).use(m),SectionExtractor=class{constructor(e){this.depths=new Set(e?.depths??[1,2,3,4]),this.minContentLength=e?.minContentLength??0,this.pageIdPrefix=e?.pageIdPrefix??``}extract(e,t){let n=[],r=[],i=[{depth:1,text:t.title}],a=new SlugGenerator,o=null,finalizeSection=()=>{if(!o||o.nodes.length===0)return;let e=this.buildSectionEntry(o,t);e&&e.content.length>=this.minContentLength&&n.push(e)};for(let t=0;t<e.children.length;t++){let n=e.children[t];if(n.type!==`yaml`)if(n.type===`heading`){let e=n;if(!this.depths.has(e.depth)){o?o.nodes.push(n):o={headerPath:i.map(e=>e.text),headingLevel:i[i.length-1]?.depth??1,nodes:[],startIndex:t};continue}for(finalizeSection();i.length>0&&i[i.length-1].depth>=e.depth;)i.pop();let s=E(e);i.push({depth:e.depth,text:s});let c;e.depth>1&&(c=a.createSlug(s),r.push({headingLevel:e.depth,id:c,tagName:`h${e.depth}`,textContent:s})),o={anchorId:c,headerPath:i.map(e=>e.text),headingLevel:e.depth,nodes:[],startIndex:t}}else o?o.nodes.push(n):o={headerPath:i.map(e=>e.text),headingLevel:i[i.length-1]?.depth??1,nodes:[n],startIndex:t}}return finalizeSection(),{sections:n,toc:r}}extractPage(e,t){let n=e.children.filter(e=>e.type!==`yaml`);if(n.length===0)return null;let r=this.nodesToRawContent(n).trim();if(!r)return null;let i={content:r,pageId:`${this.pageIdPrefix}${t.id}`,pathname:t.pathname};return{content:r,hash:computeMd5(JSON.stringify(i)),pageId:`${this.pageIdPrefix}${t.id}`,pathname:t.pathname,title:t.title}}buildSectionEntry(e,t){let{nodes:n,terms:r}=this.extractTerms(e.nodes),i=[],a=[],o=[];for(let e of n)if(e.type===`code`){let t=e;if(t.data?.typeDocProps){let{name:e,props:n,since:r}=t.data.typeDocProps;o.push({props:n,since:r,type:e})}a.push({code:t.value,language:t.lang??``})}else e.type===`text`&&(isStepBlock(e.value.trim())||isSpoilerBlock(e.value.trim()))||i.push(e);let s=this.nodesToRawContent(n),c=this.nodesToContent(i),l=this.generateSectionId(e.headerPath),u=t.url&&e.anchorId?`${t.url}#${e.anchorId}`:void 0,d={headerPath:e.headerPath,pageFrontmatter:Object.keys(t.frontmatter).length?t.frontmatter:void 0,pageId:`${this.pageIdPrefix}${t.id}`,rawContent:s.trim(),terms:r.length?r:void 0,types:o.length?o:void 0,url:u},f=computeMd5(JSON.stringify(d));return{...d,codeExamples:a.length?a:void 0,content:c.trim(),hash:f,headingLevel:e.headingLevel,sectionId:l}}extractTerms(e){let t=[],n=[];for(let r of e){if(r.type===`paragraph`){let e=r.children??[],t=e[0];if(t?.type===`text`){let r=t.value;if(r.match(/^:::\s*terms\s*/)){let t=r;for(let n=1;n<e.length;n++){let r=e[n];r.type===`text`?t+=r.value:r.type===`softBreak`&&(t+=`
12
- `)}let i=this.parseTermsBlock(t);n.push(...i);continue}}}t.push(r)}return{nodes:t,terms:n}}parseTermsBlock(e){let t=e.replace(/^:::\s*terms\s*/,``),n=t.lastIndexOf(`:::`);return(n===-1?t:t.slice(0,n)).split(`
13
- `).map(e=>e.trim()).filter(e=>e&&e!==`:::`)}nodesToRawContent(e){let t={children:e,type:`root`};return Z.stringify(t)}nodesToContent(e){let t={children:structuredClone(e),type:`root`},n=Q.runSync(t);return Q.stringify(n)}generateSectionId(e){return e.map(e=>slugify(e)).join(`-`)}};function getRouteMeta(e,t){let n=t[e[0]];if(n)return e.length===1?n:e.slice(1).reduce((e,t)=>e?.children?.[t],n)}var NavBuilder=class{get navItems(){return this._navItems}constructor(e,t){this.initialRoutes=[],this.flatNavItems=[],this._navItems=[],this.navMeta=t,this.metaJson=e}add(e,t,n){this.initialRoutes.push({pageFrontmatter:t,pageSection:e,routeMeta:n})}reset(){this.initialRoutes=[],this.flatNavItems=[],this._navItems=[]}navItemSort(e,t,n){if(e.depth!==t.depth)return e.depth-t.depth;if(e.order&&!t.order)return-1;if(!e.order&&t.order)return 1;if(e.order&&t.order&&e.order!==t.order)return e.order-t.order;if(n&&e.group&&t.group){let r=e.group?n.indexOf(e.group):-1,i=t.group?n.indexOf(t.group):-1;if(r!==i){if(r!==-1&&i!==-1)return r-i;if(r!==-1)return-1;if(i!==-1)return 1}}if(e.group!==t.group){if(!e.group&&t.group)return-1;if(e.group&&!t.group)return 1;if(e.group&&t.group)return e.group.localeCompare(t.group)}return e.title.localeCompare(t.title)}resolveSideNavTitle(e,t,n){return(d(t.sideNavTitle)?t.sideNavTitle||``:e.sideNavTitle||``)||n}buildNavItem({pageFrontmatter:e,pageSection:{pathname:t,pathSegments:n,title:r},routeMeta:i}){let a=e?.id||``;if(!n.length&&t===`/`){let n=i||getRouteMeta(a?[a]:[],this.metaJson);if(!n)return;this.flatNavItems.push({depth:1,expanded:n?.expanded||!1,id:`/`,order:n?.order,pathname:t,pathSegments:[],title:this.resolveSideNavTitle(e,n,n?.title||r)})}n.forEach((i,a)=>{let o=a+1;if(!this.flatNavItems.find(e=>n.slice(0,o).every((t,n)=>t===e.pathSegments[n]))){let s=a===n.length-1,c=n.slice(0,o),l=getRouteMeta(s?n:c,this.metaJson)??{};this.flatNavItems.push({badges:s?this.extractBadges(e):void 0,depth:o,expanded:l?.expanded||!1,group:s?l.group||e.group:l.group,id:`/${c.join(`/`)}`,items:[],order:l?.order,pathname:s?t:void 0,pathSegments:c,title:this.resolveSideNavTitle(s?e:{},l,l?.title?l.title:s?r:A(i))})}})}ensureParent(e){let t=e.pathSegments,n=this.navItems,r,i;for(let e=0;e<t.length-1;e++){let a=t[e];if(r=n?.find(t=>t.pathSegments[e]===a),r){n=r.items??[],i=r;continue}if(i){let r=t.slice(0,e+1),o=getRouteMeta(r,this.metaJson);n=[];let s={depth:r.length,id:`/routes/${r.join(`/`)}`,items:n,pathSegments:r,title:a},c=o?{...s,expanded:o.expanded,order:o.order,restricted:o.restricted,title:o.title??a}:s;i.items=i.items?[...i.items,c]:[c]}i=r}}nestedInsert(e,t,n){let r=t[0],i=n.find(e=>e.pathSegments[e.pathSegments.length-1]===r);i?this.nestedInsert(e,t.slice(1),i.items??[]):t.length===1&&n.push(e)}buildNestedNavItems(){for(let e=0;e<this.flatNavItems.length;e++){let t=this.flatNavItems[e];if(t.depth===1){this.navItems.push(t);continue}this.ensureParent(t),this.nestedInsert(t,t.pathSegments,this.navItems)}}sortNestedNavItems(e,t){e.sort((e,n)=>this.navItemSort(e,n,t)),e.forEach(e=>{if(e.items?.length){let t=getRouteMeta(e.pathSegments,this.metaJson);this.sortNestedNavItems(e.items,t?.groupOrder)}})}build(){O(this.initialRoutes,e=>e.pageSection.pathSegments.length).map(e=>this.buildNavItem(e)),this.buildNestedNavItems();let e=getRouteMeta([],this.metaJson);return this.sortNestedNavItems(this.navItems,e?.groupOrder),this.navMeta&&Object.entries(this.navMeta).forEach(([e,t])=>{this._navItems.splice(parseInt(e),0,{depth:1,id:k(),pathSegments:[],sectionTitle:t.sectionTitle,separator:t.separator,title:``})}),this._navItems=this.groupNavItems(this.navItems),this._navItems=this.buildSearchMeta(this.navItems,[]),this.navItems}groupNavItems(e){let t=[],n=new Set;for(let r of e)r.group&&!n.has(r.group)&&(n.add(r.group),t.push({depth:r.depth,group:r.group,id:k(),pathSegments:[],sectionTitle:r.group,title:``})),t.push({...r,items:r.items?this.groupNavItems(r.items):void 0});return t}buildSearchMeta(e,t){let n=``,r=[];for(let i of e){let e={...i};if(e.sectionTitle?n=e.sectionTitle:e.separator&&(n=``),!e.separator){let r=n?[...t,n]:[...t],i=[...e.searchMeta||[],...r];i.length&&(e.searchMeta=[...i]),e.items&&=this.buildSearchMeta(e.items,r)}r.push(e)}return r}extractBadges(e){let t=e.badges;if(t&&typeof t==`object`&&Array.isArray(t))return t.filter(e=>b(e)&&!e.hideFromNav)}};function getPathnameFromPathSegments(e){return`/${e.join(`/`)}`}function getCategoriesFromPathSegments(e,t,n){return e.reduce((r,i,a)=>{let o=e.slice(0,a+1);if(a===e.length-1)return r.push(n),r;let s=getRouteMeta(o,t);return s?.title?r.push(s.title):r.push(pathSegmentToCategory(i)),r},[])}function pathSegmentToCategory(e){return e.split(`-`).map(e=>/\b(a|an|and|but|or|in|on|at)\b/.test(e)?e:A(e)).join(` `)}function getGeneroutedPathSegments(e){let t=e.endsWith(`mdx`)?`mdx`:`tsx`,n=e.substring(0,e.lastIndexOf(`.${t}`)).split(`/`);return n[n.length-1]===`index`?n.slice(0,n.length-1):n}var te=/[\/\\.]/;function isPathSeparator(e){return te.test(e)}var $=/((^|[.]|[+]\/)(index|_index))(\/[^\/]+)?$|(\/_?index\/)/;function getRemixFlatRoutesSegments(e,t,n=`$`){let r=typeof n==`string`?{paramPrefixChar:n}:n,i=r.paramPrefixChar??`$`,a=r.directoryMode??!1,o=[],s=0,c=``,l=`START`,u=`NORMAL`,d=!1;if(e.endsWith(`_layout`))return[];if(/\+\/_\./.test(e)&&(e=e.replace(/\+\/_\./g,`_+/`)),/\+\//.test(e)&&(e=e.replace(/\+\//g,`.`),d=!0),a&&/\//.test(e)){if(e.endsWith(`.route`)){let t=e.lastIndexOf(`/`);t>=0&&(e=`${e.substring(0,t).replace(/\//g,`.`)}/${e.substring(t+1)}`)}else e=e.replace(/\//g,`.`);d=!0}let f=/\//.test(e);if((d&&f||!d)&&!(e.endsWith(`.route`)||e.endsWith(`.index`))){let t=e.lastIndexOf(`/`);t>=0&&(e=e.substring(0,t))}let pushRouteSegment=e=>{e&&o.push(e)};for(;s<e.length;){let t=e[s];switch(l){case`START`:if(c.includes(i)&&!(c.startsWith(i)||c.startsWith(`(${i}`)))throw Error(`Route params must start with prefix char ${i}: ${c}`);if(c.includes(`(`)&&!c.startsWith(`(`)&&!c.endsWith(`)`))throw Error(`Optional routes must start and end with parentheses: ${c}`);pushRouteSegment(c),c=``,l=`PATH`;continue;case`PATH`:if(isPathSeparator(t)&&u===`NORMAL`){l=`START`;break}else if(t===`[`){u=`ESCAPE`;break}else if(t===`]`){u=`NORMAL`;break}c+=t;break}s++}return pushRouteSegment(c),(o.at(-1)===`route`||o.at(-1)===`index`||o.at(-1)===`_index`||o.at(-1)===`_route`)&&(o=o.slice(0,-1)),!t&&d&&o.at(-1)?.startsWith(`_`)&&(o=o.slice(0,-1)),o}function getRemixHybridRoutesPathSegments(e){let t=e.substring(0,e.lastIndexOf(`.`));return getRemixFlatRoutesSegments(t,$.test(t))}function getRemixHybridDirectoryRoutesPathSegments(e){let t=e.substring(0,e.lastIndexOf(`.`));return hasPrivateFolderSegment(t)?[]:getRemixFlatRoutesSegments(t,$.test(t),{directoryMode:!0})}function hasPrivateFolderSegment(e){let t=e.split(`/`);for(let e=0;e<t.length-1;e++){let n=t[e];if(n.startsWith(`_`)&&!n.includes(`+`))return!0}return!1}function getPathSegmentsFromFileName(e,t,n){let r=e.substring(e.indexOf(t)+t.length+1);if(typeof n==`function`)return n(r);switch(n){case`vite-generouted`:return getGeneroutedPathSegments(r);case`react-router-directory-groups`:return getRemixHybridDirectoryRoutesPathSegments(r);default:return getRemixHybridRoutesPathSegments(r)}}function filterFileGlob(e,t,n,i){if(typeof i==`string`&&i===`vite-generouted`){let i=/(\(.*\))|(\[.*\])/;return e.map(e=>e.replace(n,``)).filter(e=>e.endsWith(`.${t}`)&&!e.includes(`/_`)&&!e.includes(`/+`)).map(e=>e.split(`/`).filter(e=>!i.test(e)).join(`/`)).map(e=>r(n,e))}return typeof i==`string`&&i===`react-router-directory-groups`?e.filter(e=>e.endsWith(t)&&!e.includes(`$`)&&!hasPrivateFolderInRelativePath(e,n)):e.filter(e=>e.endsWith(t)&&!e.includes(`$`))}function hasPrivateFolderInRelativePath(e,t){let n=(e.startsWith(t)?e.slice(t.length):e).split(`/`).filter(Boolean);for(let e=0;e<n.length-1;e++){let t=n[e];if(t.startsWith(`_`)&&!t.includes(`+`))return!0}return!1}function transformRouteMetaArray(e,t){let n=0;return e.reduce((e,r,i)=>{if(!(`id`in r))return(`separator`in r||`sectionTitle`in r)&&(t[i-n]=r),e;let a=r;return(a.ignoreRouteMetaOrder||a.hidden)&&n++,e[a.id]={children:a.children?transformRouteMetaArray(a.children,t):void 0,expanded:a.expanded,group:a.group,groupOrder:a.groupOrder,hidden:a.hidden,hideBreadcrumbs:a.hideBreadcrumbs,hideFromSearch:a.hideFromSearch,hidePageLinks:a.hidePageLinks,hideSideNav:a.hideSideNav,hideToc:a.hideToc,order:a.ignoreRouteMetaOrder?void 0:i+1,restricted:a.restricted,title:a.title},e},{})}var SearchIndexer=class{get cachedFileCount(){return this.mdxFileReader.cachedFileCount}get pageDocProps(){return this._pageDocProps}get mdxFileCount(){return this._mdxFileCount}get navItems(){return this.navBuilder.navItems}get pageMap(){return this._pageMap}get searchIndex(){return this._searchIndex}reset(){this.mdxFileReader.reset(),this._collectedLinks=[],this._anchorIds={},this._docPropIds={},this._pageMap={},this._searchIndex=[]}constructor(e,t=!0,n={}){this._collectedLinks=[],this._anchorIds={},this._docPropIds={},this.routeMetaNav={},this._pageDocProps={},this._mdxFileCount=0,this._pageMap={},this._searchIndex=[],this.config=e,this.logWarnings=t,this.allowedHeadings=new Set(Array.from(e?.headings||[`h2`,`h3`,`h4`])),this.metaJson=transformRouteMetaArray(this.config.navConfig??[],this.routeMetaNav);let r=Array.from(this.allowedHeadings).map(e=>parseInt(e.charAt(1)));this.sectionExtractor=n.sectionExtractor||new SectionExtractor({depths:[1,...r]}),this.navBuilder=n.navBuilder||new NavBuilder(this.metaJson,this.routeMetaNav),this.docPropsIndexer=n.docPropsIndexer||new DocPropsIndexer(this.config.typeDocProps??{}),this.mdxFileReader=n.mdxFileReader||new MdxFileReader(process.env.NODE_ENV===`development`&&!this.config.disableCache,this.config.pageTimestampMetadata)}getPageEntry(e,t){let n=e.replace(this.config.srcDir,``),r=getPathSegmentsFromFileName(n,this.config.pageDirectory,this.config.routingStrategy),i=getPathnameFromPathSegments(r),a=getRouteMeta(r.length===0?t.id?[t.id]:[`_index`]:r,this.metaJson)??{};return{categories:t.categories??getCategoriesFromPathSegments(r,this.metaJson,a?.title||t.title||``),data:t,description:t.description,hidden:d(a.hidden)?a.hidden:t.hidden,hideBreadcrumbs:d(a.hideBreadcrumbs)?a.hideBreadcrumbs:t.hideBreadcrumbs,hideFromSearch:d(a.hideFromSearch)?a.hideFromSearch:t.hideFromSearch,hidePageLinks:d(a.hidePageLinks)?a.hidePageLinks:t.hidePageLinks,hideSideNav:d(a.hideSideNav)?a.hideSideNav:t.hideSideNav,hideToc:d(a.hideToc)?a.hideToc:t.hideToc,id:n,pathname:i,pathSegments:r,restricted:d(a.restricted)?a.restricted:t.restricted,title:d(a.title)?a.title||``:t.title||``,updatedBy:t.updatedBy,updatedOn:t.updatedOn}}compileMdxFile(e){let{cached:t,fileContents:n,frontmatter:r}=this.mdxFileReader.readFileSync(e),i={changed:{},filePath:e},a;if(!t){let t=this.mdxFileReader.readCache(e);if(t){let e=JSON.stringify(t.frontmatter),n=JSON.stringify(r);a=t.page,e!==n&&(i.changed.frontmatter=!0)}}this.docPropsIndexer.reset();let o=this.getPageEntry(e,r);!o.categories.length&&o.title&&(o.categories=[o.title]),o.hidden||this.navBuilder.add(o,r),this._pageMap[o.pathname]=o;let s,c=[];try{if(this.config.validatePageLinks){let e=collectAnchorIds(createRemarkProcessor({frontmatter:!0,mdx:!0}).parse(n));e.size&&(this._anchorIds[o.pathname]=e)}if(t?.page)s=t.page,c=t.collectedLinks,this._collectedLinks.push(...c);else{let t=createRemarkProcessor({alerts:!0,extractMeta:{},frontmatter:!0,gfm:!0,interpolateFrontmatter:r,mdx:!0,plugins:[q],removeJsx:!0,removeMermaidCodeBlocks:!0}),i=t.runSync(t.parse(n));this.config.validatePageLinks&&(c=collectLinks(i,e,o.pathname),this._collectedLinks.push(...c));let a={frontmatter:r,id:o.id,pathname:o.pathname,title:o.title,url:o.pathname},{sections:l,toc:u}=this.sectionExtractor.extract(i,a);s={sections:l,toc:u}}}catch(t){if(console.debug(`${u.yellowBright.bold(`Failed to parse mdx page content.`)} ${u.blueBright.bold(e)}`),this.config.throwOnError)throw Error(t);return{metadata:i,pageSections:[o]}}let{sections:l,toc:d}=s;if(a)for(let e=0;e<d.length;e++){let t=a.toc[e],n=d[e];if(t?.id!==n.id){i.changed.toc=!0;break}}d.length&&(this._pageMap[o.pathname].toc=d);let f=[],p={};if(this.config.typeDocProps&&(f=t?.pageDocPropSections||(this.docPropsIndexer.build(n,d)??[]),p=t?.pageDocProps||this.docPropsIndexer.getDocProps()),(f.length||Object.keys(p).length)&&(this._pageDocProps[o.pathname]=p,this.config.validatePageLinks)){let e=new Set;for(let t of f)t.heading?.id&&e.add(t.heading.id);e.size&&(this._docPropIds[o.pathname]=e)}if(t||this.mdxFileReader.updateCache(e,n,{collectedLinks:c,frontmatter:r,page:s,pageDocProps:p,pageDocPropSections:f}),r.hideFromSearch||!l.length&&!f.length)return{metadata:i,pageSections:[o]};let m=[...this.formatContentSections(l,o)];return this.config.typeDocPropsOptions?.includeInSearchIndex&&m.push(...this.formatDocPropSections(f,o)),{metadata:i,pageSections:m}}formatContentSections(e,{toc:t,...n}){return e.map((e,t)=>{let r=e.headerPath.at(-1)??n.title;return{...n,content:e.content||void 0,heading:r,headingLevel:e.headingLevel,href:e.url??n.pathname,id:`${n.id}-${t}`}})}formatDocPropSections(e,{toc:t,...n}){return e.map((e,t)=>{let r=e.content.map(e=>e.text.join(` `)).join(` `);return{...n,content:r||void 0,heading:e.heading?.textContent??n.title,headingLevel:e.heading?.headingLevel,href:e.heading?`${n.pathname}#${e.heading.id}`:n.pathname,id:`${n.id}-${t}-prop`,isDocProp:!0}})}compileTsxFile(e){let t=this.getPageEntry(e,{}),n=getRouteMeta(t.pathSegments.length===0?[`_index`]:t.pathSegments,this.metaJson);return n?(t.hidden||this.navBuilder.add(t,{},n),this._pageMap[t.pathname]=t,t):null}buildIndex(e,t=!0){this.logWarnings=t,this.mdxFileReader.logWarnings=t;let n=e.map(fixPath);this.navBuilder.reset(),this.reset();let r=filterFileGlob(n,`mdx`,this.config.srcDir,this.config.routingStrategy);this._mdxFileCount=r.length,(!this.mdxFileReader.enabled||this.mdxFileReader.gitMetadataMap.size===0)&&(this.mdxFileReader.gitMetadataMap=buildGitMetadataMap(this.config.srcDir,this.mdxFileReader.pageTimestampMetadata));let i=r.map(e=>this.compileMdxFile(e)),a=i.map(e=>e.pageSections).flat();return filterFileGlob(n,`tsx`,this.config.srcDir,this.config.routingStrategy).map(e=>this.compileTsxFile(e)),this._searchIndex.push(...a.filter(e=>!e.hideFromSearch)),this.navBuilder.build(),this.config.validatePageLinks&&reportInvalidLinks(validateLinks(this._collectedLinks,this._pageMap,this._docPropIds,this._anchorIds)),i}};export{MdxFileReader as A,remarkFrontmatterInterpolation as C,getAlertIcon as D,remarkCodeTabs as E,M as F,fixPath as I,ConfigLoader as M,z as N,remarkAlerts as O,j as P,remarkFrontmatterTitle as S,remarkExtractMeta as T,q as _,computeMd5 as a,remarkRemoveJsx as b,removePreviewLines as c,createRemarkProcessor as d,isStepBlock as f,isSerializeJsxBlock as g,remarkSpoilers as h,SectionExtractor as i,SlugGenerator as j,extractNamesFromAttribute as k,resolveModulePath as l,isSpoilerBlock as m,getPathSegmentsFromFileName as n,exists as o,remarkSteps as p,getPathnameFromPathSegments as r,extractRelativeImports as s,SearchIndexer as t,Y as u,K as v,remarkFrontmatterDescription as w,remarkRemoveMermaidCodeBlocks as x,remarkSelfLinkHeadings as y};
14
- //# sourceMappingURL=search-indexer-D3Y9DkgK.js.map