import p from"@markdoc/markdoc";import{REDOCLY_ROUTE_RBAC as l,REDOCLY_TEAMS_RBAC as A}from"@redocly/config";import{getSearchDocuments as h}from"./get-search-documents.js";import{AstToSearchNodeTransformer as T}from"./walk-sections.js";import{setDocumentSearchFacets as R,extractDocumentSearchFacets as S}from"./search-facets.js";import{getInnerText as C}from"../markdoc/helpers/get-inner-text.js";import{MARKDOC_PARTIALS_DATA_KEY as D}from"../../../store.js";import{normalizeFrontmatterKeywords as _}from"../utils/normalize-frontmatter-keywords.js";function K(e,m,o,c){return async(t,r,a)=>{if(e?.excludeFromSearch)return[];const i=p.Ast.fromJSON(r.ast),f=new T({ast:i,getInnerContent:C,partials:a.getGlobalConfig(D)||{}}),u=t.metadata||{},n=S(u,o);R(n,o,c);const d=e?.seo?.title||m,{result:s}=_(e?.keywords);return h(f,t.slug,d,r[A],r[l],n,s||void 0)}}export{K as searchResolver};
