import{REDOCLY_ROUTE_RBAC as D,REDOCLY_TEAMS_RBAC as d}from"@redocly/config";import{extractDocumentSearchFacets as O,setDocumentSearchFacets as T}from"./search-facets.js";import{removeMarkdownLinks as m}from"../../openapi-docs/utils.js";import{processSchema as S}from"./schema-processor.js";function q(e,t){return async(n,r)=>{const o=n.getSidebar?.(n)||[];return k({actions:e,document:t,staticData:r,route:n},o)}}function k(e,t){const n=[];for(const r of t){r.type==="group"&&n.push(...k(e,r.items||[]));const o=w(e,r);o&&n.push(o)}return n}function w(e,t){const{actions:n,document:r,staticData:o,route:s}=e,f=A(t,r);if(!f)return null;const g=t.link||"",L=t.httpVerb||"",P={slug:s.slug,fsPath:s.fsPath},R=s.metadata||{},y=O(n,R);T(n,y);const i={id:g,url:g,text:m(f.description||"")+m(f.summary||""),title:m(f.title||""),httpMethod:L,facets:y,[d]:t[d]||o[d],[D]:s[D]||P};if(t.apiItemData?.type==="channel"){const x=t.apiItemData.id,u=r.channels?.[x];if(u){const p=[];if(u.parameters)for(const[l,c]of Object.entries(u.parameters)){const a={name:l,description:m(c.description||""),place:"channel parameters",mediaType:void 0,type:"string",required:!1,example:void 0,enum:c.enum,deepLink:`#${i.url.replace(s.slug+"/","").replace(/^\//,"")}/parameters&path=${l}`};p.push(a)}if(u.messages){const l=u.messages;if(l)for(const[c,a]of Object.entries(l)){const C={name:a.title||a.name||c,description:m(a.description||"")+m(a.summary||""),place:"message",mediaType:void 0,type:"unknown",deepLink:`#${i.url.replace(s.slug+"/","").replace(/^\//,"")}/messages&m=${c.toLocaleLowerCase()}`,required:!1,example:void 0,enum:void 0};if(p.push(C),a.payload){const h=S(a.payload,"message payload",i.url.replace(s.slug+"/","").replace(/^\//,""),c);p.push(...h)}if(a.headers){const h=S(a.headers,"message headers",i.url.replace(s.slug+"/","").replace(/^\//,""),c);p.push(...h)}}}p.length>0&&(i.parameters=p)}}return i}function A(e,t){const{apiItemData:n}=e;return n?.type?E(n,t):e.type==="group"&&e.label?F(e.label,t):I(t)}function E(e,t){switch(e.type){case"channel":return t.channels?.[e.id]||null;case"operation":return t.operations?.[e.id]||null}}function F(e,t){const n=t.components?.tags?.[e];return{description:n?.description||"",title:n?.name||e,summary:""}}function I(e){return{description:e.info?.description||"",title:e.info?.title||"",summary:""}}export{q as searchResolver};
