import{withPathPrefix as f}from"@redocly/theme/core/utils";import{ASYNC_API_DOCS_TEMPLATE_ID as l,OPENAPI_DOCS_TEMPLATE_ID as p}from"../../../constants/index.js";import{removeTrailingSlash as u}from"../../../shared/utils.js";function a(t,n,r="",e){return t.map(s=>{const o=i(s,r,n,e),m=h(s,r,n,e);return{...s,items:a(s.items||[],n,r,e),active:o&&!m,hasActiveSubItem:m}}).filter(Boolean)}function i(t,n="",r,e){const s=r.pathname;if(!t.link)return!1;const[o,m]=t.link.split("#");return n&&(e===p||e===l)?decodeURIComponent(f(u(o)))===n:decodeURIComponent(u(s))===decodeURIComponent(u(f(P(s,o))))?!m||m===n:!1}function h(t,n="",r,e){return(t.items||[]).some(o=>i(o,n,r,e)||h(o,n,r,e))}function P(t,n){const r=new URL(t,"http://localhost");return new URL(n,r.href).pathname}export{a as mapItemsPropsToState};
