var F=/^##\s+Metadata[\s\S]*?(?=^##\s|^#\s|Z)/m;function J(p){return p.replace(/^#\s+.*\n+/m,"").replace(F,"")}function D(p){return/^#{1,4}\s+/.test(p)||/^```/.test(p)||/^\s*[-*]\s+/.test(p)||/^\s*\d+\.\s+/.test(p)||/^>\s+/.test(p)}function E(p){let s=J(p).split(/\r?\n/),h=[],i=0;while(i<s.length){let u=s[i]??"";if(u.startsWith("<!-- @generated")){i+=1;continue}let t=u.trim();if(!t){i+=1;continue}if(t.startsWith("```")){let g=t.slice(3).trim(),f=[];i+=1;while(i<s.length&&!(s[i]??"").trim().startsWith("```"))f.push(s[i]??""),i+=1;i+=1,h.push({type:"code",language:g||"text",code:f.join(`
`)});continue}if(/^#{1,4}\s+/.test(t)){let g=t.match(/^#{1,4}/)?.[0].length??2;h.push({type:"heading",level:g,text:t.replace(/^#{1,4}\s+/,"")}),i+=1;continue}if(/^>\s+/.test(t)){let g=[];while(i<s.length&&/^>\s+/.test((s[i]??"").trim()))g.push((s[i]??"").trim().replace(/^>\s+/,"")),i+=1;h.push({type:"quote",text:g.join(" ")});continue}if(/^[-*]\s+/.test(t)||/^\d+\.\s+/.test(t)){let g=/^\d+\.\s+/.test(t),f=[];while(i<s.length&&D((s[i]??"").trim())){let o=(s[i]??"").trim();if(g&&/^\d+\.\s+/.test(o))f.push(o.replace(/^\d+\.\s+/,""));else if(!g&&/^[-*]\s+/.test(o))f.push(o.replace(/^[-*]\s+/,""));else break;i+=1}h.push({type:"list",ordered:g,items:f});continue}let q=[];while(i<s.length&&!D((s[i]??"").trim())){let g=(s[i]??"").trim();if(!g)break;q.push(g),i+=1}h.push({type:"paragraph",text:q.join(" ")})}return h}import{CodeBlock as K}from"@contractspec/lib.design-system";import{HStack as N,VStack as B}from"@contractspec/lib.ui-kit-web/ui/stack";import{BlockQuote as O,H2 as X,H3 as Y,H4 as _,Muted as P,P as d}from"@contractspec/lib.ui-kit-web/ui/typography";import{jsx as r,jsxs as U}from"react/jsx-runtime";var $=new Set(["typescript","tsx","javascript","jsx","bash","shell","json","yaml","graphql","sql","python","go","rust","css","scss","html","markdown","text"]);function Q(p){if(!p)return"text";let s=p.toLowerCase();return $.has(s)?s:"text"}function R(p,s){if(p<=2)return r(X,{children:s});if(p===3)return r(Y,{children:s});return r(_,{children:s})}function e({content:p}){let s=E(p);if(!s.length)return r(P,{children:"No reference content available."});return r(B,{gap:"md",children:s.map((h,i)=>{switch(h.type){case"heading":return r(B,{children:R(h.level,h.text)},i);case"paragraph":return r(d,{children:h.text},i);case"quote":return r(O,{children:h.text},i);case"code":return r(K,{language:Q(h.language),code:h.code},i);case"list":return r(B,{gap:"xs",children:h.items.map((u,t)=>U(N,{gap:"sm",align:"start",children:[r(P,{children:h.ordered?`${t+1}.`:"•"}),r(d,{className:"leading-relaxed",children:u})]},t))},i);default:return null}})})}import{ContractReferenceDataView as L}from"@contractspec/lib.contracts-spec/docs";import{DataViewRenderer as z}from"@contractspec/lib.design-system";import{VStack as G}from"@contractspec/lib.ui-kit-web/ui/stack";import{jsx as A,jsxs as n}from"react/jsx-runtime";function T(p,s){return p.match(new RegExp(`- \\*\\*${s}\\*\\*: (.+)`,"i"))?.[1]?.trim()}function I(p){if(!p)return;return p.replace(/<!--.*?-->/g,"").replace(/[ \t]+/g," ").replace(/\n{3,}/g,`

`).trim()}function Z({entry:p,content:s}){let h=I(p.summary),i=T(s,"Type"),u=T(s,"Version")??p.version,t=T(s,"Tags")?.split(",").map((W)=>W.trim()).filter(Boolean),q=T(s,"Owners")?.split(",").map((W)=>W.trim()).filter(Boolean),g=T(s,"Stability")??p.visibility,f={reference:{key:p.title??p.id,version:u,type:i,title:p.title??p.id,description:h,tags:t??p.tags,owners:q??p.owners,stability:g}},o={...L,meta:{...L.meta,title:p.title??L.meta.title,description:h??L.meta.description}};return n(G,{gap:"xl",children:[A(z,{spec:o,item:f}),A(e,{content:s})]})}import{jsx as v}from"react/jsx-runtime";function x({entry:p,content:s}){return v(Z,{entry:p,content:s})}export{x as DocsReferencePage};
