var f="docs-index.manifest.json";import{readFile as u}from"node:fs/promises";import{dirname as g,join as i}from"node:path";import{fileURLToPath as D}from"node:url";var d=g(D(import.meta.url)),c=null,a=null,m=new Map;function I(n){if(!n)return"_common";if(n.includes("/")){let[t]=n.split("/");return t||"_common"}return"_common"}async function l(){if(!c)c=u(i(d,f),"utf8").then((n)=>JSON.parse(n));return c}function p(n){let t=n.contentRoot??".";return i(d,t)}async function x(n){let t=m.get(n);if(t)return t;let e=u(i(d,n),"utf8").then((r)=>JSON.parse(r));return m.set(n,e),e}async function w(){if(!a)a=(async()=>{let n=await l();return(await Promise.all(n.chunks.map((e)=>x(e.file)))).flat()})();return a}async function C(){return l()}async function _(n){let t=await l(),e=I(n),r=t.chunks.find((o)=>o.key===e);if(!r)return null;let s=(await x(r.file)).find((o)=>o.id===n);if(!s||!s.contentPath)return null;let y=i(p(t),s.contentPath);try{let o=await u(y,"utf8");return{entry:s,content:o}}catch{return null}}export{w as listGeneratedDocs,_ as getGeneratedDocById,C as getDocsIndexManifest};
