// @bun
import{defaultDocRegistry as O}from"@contractspec/lib.contracts-spec/docs";import{useMemo as L}from"react";function Z(F,Q){return L(()=>{try{return O.list().filter(({block:I})=>{let A=I.id.toLowerCase().includes(F.toLowerCase())||I.title.toLowerCase().includes(F.toLowerCase()),T=Q?.some((G)=>I.tags?.some((M)=>M.toLowerCase().includes(G.toLowerCase())));return A||T}).map(({block:I,route:A})=>({id:I.id,title:I.title,summary:I.summary,route:A}))}catch(q){return console.error("Failed to fetch related docs:",q),[]}},[F,Q])}import{Breadcrumbs as _,CodeBlock as $,EmptyState as N,PageHeaderResponsive as v,StatusChip as U}from"@contractspec/lib.design-system";import{Card as X}from"@contractspec/lib.ui-kit-web/ui/card";import{Box as i,HStack as W,VStack as J}from"@contractspec/lib.ui-kit-web/ui/stack";import{cn as w}from"@contractspec/lib.ui-kit-web/ui/utils";import{BookOpen as m,Code as B,Database as K,Layout as E}from"lucide-react";import g from"next/link";import{jsx as z,jsxs as P}from"react/jsx-runtime";function l({feature:F,presentationKey:Q,presentation:Y,spec:q,className:I}){let A=Y??F.presentations?.find((G)=>G.key===Q),T=Z(A?.key||"",q?.meta?.tags);if(!A)return P(J,{gap:"lg",className:w("mx-auto w-full max-w-5xl p-6",I),children:[z(v,{title:"Presentation Not Found",subtitle:`Presentation ${Q} not found in feature ${F.meta.key}`,breadcrumb:z(_,{items:[{label:"Features",href:"/features"},{label:F.meta.title||F.meta.key,href:`/features/${F.meta.key}`},{label:"Presentations",href:`/features/${F.meta.key}/presentation`}]})}),z(N,{title:"Presentation not found",description:`The presentation '${Q}' could not be found in this feature.`,icon:z(E,{className:"h-12 w-12 text-muted-foreground"})})]});return P(J,{gap:"lg",className:w("mx-auto w-full max-w-5xl p-6",I),children:[z(v,{title:A.key,subtitle:`Presentation defined in ${F.meta.title??F.meta.key}`,breadcrumb:z(_,{items:[{label:"Features",href:"/features"},{label:F.meta.title||F.meta.key,href:`/features/${F.meta.key}`},{label:"Presentations",href:`/features/${F.meta.key}#presentations`},{label:A.key}]})}),P(W,{gap:"sm",children:[z(U,{tone:"neutral",label:A.key,size:"sm",icon:z(E,{className:"h-3 w-3"})}),z(U,{tone:"neutral",label:`v${A.version}`,size:"sm"}),q?.meta?.stability?z(U,{tone:q.meta.stability==="stable"?"success":"warning",label:q.meta.stability,size:"sm"}):null]}),P("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-3",children:[z("div",{className:"space-y-6 lg:col-span-2",children:z(X,{className:"p-6",children:P(J,{gap:"md",children:[P(W,{className:"items-center gap-2 border-b pb-2",children:[z(B,{className:"h-5 w-5 text-muted-foreground"}),z("h3",{className:"font-semibold text-lg",children:"Component Definition"})]}),q?P(J,{gap:"lg",children:[q.meta.description&&z("p",{className:"text-muted-foreground",children:q.meta.description}),P(i,{className:"flex-col gap-2",children:[z("span",{className:"font-medium text-muted-foreground text-sm uppercase tracking-wider",children:"Spec Details"}),z($,{code:JSON.stringify(q,null,2),language:"json"})]})]}):P(J,{gap:"md",children:[z("p",{className:"text-muted-foreground",children:"Full component details are not available for this presentation reference."}),z($,{code:JSON.stringify(A,null,2),language:"json"})]})]})})}),z("div",{className:"space-y-6",children:z(X,{className:"p-6",children:P(J,{gap:"md",children:[P(W,{className:"items-center gap-2 border-b pb-2",children:[z(K,{className:"h-5 w-5 text-muted-foreground"}),z("h3",{className:"font-semibold text-lg",children:"Metadata"})]}),P("dl",{className:"grid grid-cols-1 gap-4 text-sm",children:[P("div",{children:[z("dt",{className:"text-muted-foreground",children:"Key"}),z("dd",{className:"truncate font-medium",children:A.key})]}),P("div",{children:[z("dt",{className:"text-muted-foreground",children:"Version"}),z("dd",{className:"font-medium",children:A.version})]}),q?.meta?.owners&&P("div",{children:[z("dt",{className:"text-muted-foreground",children:"Owners"}),z("dd",{className:"flex flex-wrap gap-1 font-medium",children:q.meta.owners.map((G)=>z(U,{label:G,size:"sm",tone:"neutral"},G))})]})]})]})})}),T?.length?z("div",{className:"lg:col-span-3",children:z(X,{className:"p-6",children:P(J,{gap:"md",children:[P(W,{className:"items-center gap-2 border-b pb-2",children:[z(m,{className:"h-5 w-5 text-muted-foreground"}),z("h3",{className:"font-semibold text-lg",children:"Related Documentation"})]}),z("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3",children:T.map((G)=>z(g,{href:G.route||`/docs/${G.id}`,className:"group block",children:P("div",{className:"h-full rounded-lg border p-4 transition-colors hover:border-primary",children:[z("h4",{className:"mb-1 font-semibold group-hover:text-primary",children:G.title}),G.summary&&z("p",{className:"line-clamp-2 text-muted-foreground text-sm",children:G.summary})]})},G.id))})]})})}):null]})]})}export{l as FeaturePresentationDetailTemplate};
