// @bun
var l="docs-index.manifest.json";import{readFile as u}from"fs/promises";import{dirname as D,join as i}from"path";import{fileURLToPath as g}from"url";var d=D(g(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 f(){if(!c)c=u(i(d,l),"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 h(){if(!a)a=(async()=>{let n=await f();return(await Promise.all(n.chunks.map((e)=>x(e.file)))).flat()})();return a}async function k(){return f()}async function P(n){let t=await f(),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{h as listGeneratedDocs,P as getGeneratedDocById,k as getDocsIndexManifest};
