import{safeSlugify as f}from"@redocly/openapi-docs/lib/utils/string.js";function V({asyncApiDoc:i,channelToOperations:g={},protocol:k}){const c={},h=[],y=i.channels||{},u=i.operations||{};for(const[e,s]of Object.entries(g)){const n=y[e],d=n.tags||[],l=s.length>0,o=x(k,n.bindings),r=`${o.channel}s`;for(const a of d){const t=a.name,m=f(t).toLowerCase();c[t]||(c[t]=[]),c[t].push({label:n.title||n.address||e,type:l?"group":"link",link:m+"/"+r+"/"+e,badges:n?.["x-badges"]||[],httpVerb:o.channel,apiItemData:{type:"channel",id:e},...l?{items:s.map(p=>{const b=u[p];return{label:b.title||p,type:"link",link:m+"/"+r+"/"+e+"/operations/"+p,httpVerb:o[b.action]||"",action:b.action,badges:b?.["x-badges"]||[],apiItemData:{type:"operation",id:p}}})}:{}})}d.length||h.push({label:n.title||n.address||e,type:l?"group":"link",link:r+"/"+e,httpVerb:o.channel,badges:n?.["x-badges"]||[],apiItemData:{type:"channel",id:e},...l?{items:s.map(a=>{const t=u[a];return{label:t.title||a,type:"link",link:r+"/"+e+"/operations/"+a,httpVerb:o[t.action]||"",badges:t?.["x-badges"]||[],action:t.action,apiItemData:{type:"operation",id:a}}})}:{}})}return[...Object.entries(c).map(([e,s])=>({label:e,type:"group",link:f(e).toLowerCase(),items:s})),...h]}const x=(i,g)=>{switch(i){case"kafka":return{channel:"topic",send:"pub",receive:"sub"};case"amqp":return{channel:g?.amqp?.is==="routingKey"?"exch":"queue",send:"pub",receive:"cons"};default:return{channel:"channel",send:"send",receive:"receive"}}};export{V as documentToNavItems};
