var h=Object.defineProperty;var g=(s)=>s;function u(s,t){this[s]=g.bind(null,t)}var f=(s,t)=>{for(var i in t)h(s,i,{get:t[i],enumerable:!0,configurable:!0,set:u.bind(t,i)})};var k=(s,t)=>()=>(s&&(t=s(s=0)),t);var d=/^##\s+Metadata[\s\S]*?(?=^##\s|^#\s|Z)/m;function m(s){return s.replace(/^#\s+.*\n+/m,"").replace(d,"")}function l(s){return/^#{1,4}\s+/.test(s)||/^```/.test(s)||/^\s*[-*]\s+/.test(s)||/^\s*\d+\.\s+/.test(s)||/^>\s+/.test(s)}function y(s){let t=m(s).split(/\r?\n/),i=[],e=0;while(e<t.length){let c=t[e]??"";if(c.startsWith("<!-- @generated")){e+=1;continue}let r=c.trim();if(!r){e+=1;continue}if(r.startsWith("```")){let n=r.slice(3).trim(),o=[];e+=1;while(e<t.length&&!(t[e]??"").trim().startsWith("```"))o.push(t[e]??""),e+=1;e+=1,i.push({type:"code",language:n||"text",code:o.join(`
`)});continue}if(/^#{1,4}\s+/.test(r)){let n=r.match(/^#{1,4}/)?.[0].length??2;i.push({type:"heading",level:n,text:r.replace(/^#{1,4}\s+/,"")}),e+=1;continue}if(/^>\s+/.test(r)){let n=[];while(e<t.length&&/^>\s+/.test((t[e]??"").trim()))n.push((t[e]??"").trim().replace(/^>\s+/,"")),e+=1;i.push({type:"quote",text:n.join(" ")});continue}if(/^[-*]\s+/.test(r)||/^\d+\.\s+/.test(r)){let n=/^\d+\.\s+/.test(r),o=[];while(e<t.length&&l((t[e]??"").trim())){let a=(t[e]??"").trim();if(n&&/^\d+\.\s+/.test(a))o.push(a.replace(/^\d+\.\s+/,""));else if(!n&&/^[-*]\s+/.test(a))o.push(a.replace(/^[-*]\s+/,""));else break;e+=1}i.push({type:"list",ordered:n,items:o});continue}let p=[];while(e<t.length&&!l((t[e]??"").trim())){let n=(t[e]??"").trim();if(!n)break;p.push(n),e+=1}i.push({type:"paragraph",text:p.join(" ")})}return i}export{y as parseDocsMarkdown};
