var _=Object.defineProperty;var $=(A)=>A;function g(A,B){this[A]=$.bind(null,B)}var D=(A,B)=>{for(var J in B)_(A,J,{get:B[J],enumerable:!0,configurable:!0,set:g.bind(B,J)})};var E=(A,B)=>()=>(A&&(B=A(A=0)),B);import{DocsIndexDataView as I,DocsSearchForm as L}from"@contractspec/lib.contracts-spec/docs";import{DataViewList as Q,formRenderer as R,StatusChip as P}from"@contractspec/lib.design-system";import{HStack as H,VStack as T}from"@contractspec/lib.ui-kit-web/ui/stack";import{H1 as v,Muted as W}from"@contractspec/lib.ui-kit-web/ui/typography";import{useMemo as X,useState as w}from"react";import{jsx as K,jsxs as U}from"react/jsx-runtime";function z(A){if(!A)return;return A.replace(/<!--.*?-->/g,"").replace(/[ \t]+/g," ").replace(/\n{3,}/g,`

`).trim()}function C(A){let B=z(A.summary),J=A.kind??(A.source==="generated"?"reference":void 0),O=A.visibility??(A.source==="generated"?"public":void 0);return{...A,summary:B,kind:J,visibility:O}}function F(A,B){if(!B)return!0;return[A.title,A.summary,A.id,...A.tags??[]].filter(Boolean).join(" ").toLowerCase().includes(B.toLowerCase())}function h({entries:A}){let[B,J]=w({}),O=X(()=>A.map(C),[A]),Y=X(()=>{let G=B.query?.trim()??"";return O.filter((N)=>{if(B.kind&&N.kind!==B.kind)return!1;if(B.visibility&&N.visibility!==B.visibility)return!1;return F(N,G)})},[B,O]),Z=R.render(L,{defaultValues:{query:B.query??"",visibility:B.visibility??"",kind:B.kind??""},overrides:{onSubmitOverride:(G)=>{let N=G;J({query:N.query??"",visibility:N.visibility??"",kind:N.kind??""})}}});return U(T,{gap:"xl",children:[U(T,{gap:"sm",children:[K(v,{children:"Reference"}),K(W,{children:"Generated reference material for public contract surfaces, versions, owners, and example-backed implementations. Use this when you need the repo truth, not just the narrative docs layer."})]}),K(T,{gap:"sm",className:"max-w-2xl",children:Z}),K(Q,{spec:I,items:Y,emptyState:K(W,{children:"No reference docs match your filters."}),onSelect:(G)=>{if(G.route)window.location.assign(G.route)},renderActions:(G)=>{return U(H,{gap:"xs",justify:"end",children:[G.kind?K(P,{size:"sm",label:G.kind}):null,G.visibility?K(P,{size:"sm",label:G.visibility}):null,G.version?K(P,{size:"sm",label:`v${G.version}`}):null]})}})]})}export{h as DocsReferenceIndexClient};
