import{jsx as t,jsxs as s,Fragment as x}from"react/jsx-runtime";import{memo as C,useRef as O,useEffect as T}from"react";import{LayoutVariant as d}from"@redocly/config";import{useSetAtom as j}from"jotai";import{ThreePanelLayout as A}from"@redocly/theme/layouts/ThreePanelLayout";import{SidebarLogo as I}from"@redocly/theme/components/SidebarLogo/SidebarLogo";import{GlobalStyle as M,useMount as _}from"@redocly/theme/core/openapi";import{StoreProvider as N}from"./Providers.js";import{Overlay as v}from"../Overlay.js";import{RedocWrap as D}from"./styled.js";import{StickyResponsiveSidebar as V}from"../StickySidebar/index.js";import{SideMenu as k}from"../SideMenu/index.js";import{Content as B}from"../Content/index.js";import{useContentItems as K,useUppercase2LowercaseRedirect as F,useTelemetry as H,usePerformanceMetrics as U}from"../../hooks/index.js";import{withRouter as Y}from"../../hoc/withRouter.js";import{withStore as G}from"../../hoc/withStore.js";import{compose as W}from"../../utils/index.js";import{useLicense as q}from"../../hooks/useLicense.js";import{allOperationsAtom as z}from"../../jotai/replay.js";const J=W(Y,G,C)(({licenseKey:m,onLoaded:a,children:e,options:o,layout:i,collapsedSidebar:u,parser:c,withCommonStyles:g})=>{const R=O(null),{isValid:l,licenseInfo:S}=q(m),h=j(z),y=H();F();const{contentItems:b,flatItems:f}=K({parser:c,options:o});U({sendTelemetry:p=>{const r=Object.fromEntries(Object.entries(p).map(([E,w])=>[E.toLowerCase(),w]));y.sendPerformanceMetricsMessage([{object:"metrics",cls:r.cls,lcp:r.lcp,fcp:r.fcp,ttfb:r.ttfb}])}}),T(()=>{if(!o.hideReplay&&f.length>0){const p=f.filter(r=>r.type==="operation");h(p)}},[f,o.hideReplay,h]),_(()=>{a?.(),y.sendViewedMessage([{object:"view_stats",layout:i}])});const{hideSidebar:P,scrollYOffset:L}=o||{},n=c.definition?.info?.["x-logo"];return s(x,{children:[g&&t(M,{}),s(D,{className:"redoc-wrap",ref:R,children:[!l&&t(v,{licenseInfo:S}),!P&&s(V,{scrollYOffset:L,className:"menu-content",collapsedSidebar:!u,children:[t(I,{imageUrl:n?.url,href:n?.href||c.definition?.info?.contact?.url,altText:n?.altText,backgroundColor:n?.backgroundColor}),t(k,{items:l?b:[]})]}),s(A,{className:"api-content",id:"api-content",layout:i===d.THREE_PANEL?d.THREE_PANEL:d.STACKED,collapsedSidebar:u,children:[t(B,{items:l?b:[],routingBasePath:o.routingBasePath}),e]})]})]})});function he({onLoaded:m,children:a,store:e,withCommonStyles:o,router:i}){return e?.definition?t(N,{...e,children:t(J,{onLoaded:m,basePath:e.options?.routingBasePath,licenseKey:e.options?.licenseKey,disableRouter:e.options?.disableRouter,withCommonStyles:o,router:i,children:a})}):null}export{he as RedoclyOpenAPIDocs};
