"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.RedoclyOpenAPIDocs=RedoclyOpenAPIDocs,exports.RedoclyOpenAPIDocsStandalone=RedoclyOpenAPIDocsStandalone;const jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),theme_1=require("@redocly/theme"),jotai_1=require("jotai"),Providers_1=require("./Providers"),Overlay_1=require("../Overlay"),styled_1=require("./styled"),StickySidebar_1=require("../StickySidebar"),SideMenu_1=require("../SideMenu"),Content_1=require("../Content"),hooks_1=require("../../hooks"),withRouter_1=require("../../hoc/withRouter"),withStore_1=require("../../hoc/withStore"),utils_1=require("../../utils"),useLicense_1=require("../../hooks/useLicense"),replay_1=require("../../jotai/replay"),RedoclyOpenAPIDocsComponent=(0,utils_1.compose)(withRouter_1.withRouter,withStore_1.withStore,react_1.memo)((({licenseKey:e,onLoaded:o,children:t,options:i,layout:n,collapsedSidebar:r,parser:s,withCommonStyles:l})=>{var a,d,c,u,_;const m=(0,react_1.useRef)(null),{isValid:p,licenseInfo:h}=(0,useLicense_1.useLicense)(e),y=(0,jotai_1.useSetAtom)(replay_1.allOperationsAtom),v=(0,hooks_1.useOtelTelemetry)();(0,hooks_1.useUppercase2LowercaseRedirect)();const{contentItems:j,flatItems:x}=(0,hooks_1.useContentItems)({parser:s,options:i});(0,hooks_1.usePerformanceMetrics)({sendTelemetry:e=>{const o=Object.fromEntries(Object.entries(e).map((([e,o])=>[e.toLowerCase(),o])));v.send({type:"openapi_docs.performance_metrics",payload:{cls:o.cls,lcp:o.lcp,fcp:o.fcp,ttfb:o.ttfb}})}}),(0,theme_1.useMount)((()=>{if(null==o||o(),v.send({type:"openapi_docs.viewed",payload:{layout:n}}),!i.hideReplay){const e=x.filter((e=>"operation"===e.type));y(e)}}));const{hideSidebar:S,scrollYOffset:f}=i||{},P=null===(d=null===(a=s.definition)||void 0===a?void 0:a.info)||void 0===d?void 0:d["x-logo"];return(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[l&&(0,jsx_runtime_1.jsx)(theme_1.GlobalStyle,{}),(0,jsx_runtime_1.jsxs)(styled_1.RedocWrap,{className:"redoc-wrap",ref:m,children:[!p&&(0,jsx_runtime_1.jsx)(Overlay_1.Overlay,{licenseInfo:h}),!S&&(0,jsx_runtime_1.jsxs)(StickySidebar_1.StickyResponsiveSidebar,{scrollYOffset:f,className:"menu-content",collapsedSidebar:!r,children:[(0,jsx_runtime_1.jsx)(theme_1.SidebarLogo,{imageUrl:null==P?void 0:P.url,href:(null==P?void 0:P.href)||(null===(_=null===(u=null===(c=s.definition)||void 0===c?void 0:c.info)||void 0===u?void 0:u.contact)||void 0===_?void 0:_.url),altText:null==P?void 0:P.altText,backgroundColor:null==P?void 0:P.backgroundColor}),(0,jsx_runtime_1.jsx)(SideMenu_1.SideMenu,{items:p?j:[]})]}),(0,jsx_runtime_1.jsxs)(theme_1.ThreePanelLayout,{className:"api-content",id:"api-content",layout:n===theme_1.LayoutVariant.THREE_PANEL?theme_1.LayoutVariant.THREE_PANEL:theme_1.LayoutVariant.STACKED,collapsedSidebar:r,children:[(0,jsx_runtime_1.jsx)(Content_1.Content,{items:p?j:[],routingBasePath:i.routingBasePath}),t]})]})]})}));function RedoclyOpenAPIDocs({onLoaded:e,children:o,store:t,withCommonStyles:i}){var n,r,s;return(null==t?void 0:t.definition)?(0,jsx_runtime_1.jsx)(Providers_1.StoreProvider,Object.assign({},t,{children:(0,jsx_runtime_1.jsx)(RedoclyOpenAPIDocsComponent,{onLoaded:e,basePath:null===(n=t.options)||void 0===n?void 0:n.routingBasePath,licenseKey:null===(r=t.options)||void 0===r?void 0:r.licenseKey,disableRouter:null===(s=t.options)||void 0===s?void 0:s.disableRouter,withCommonStyles:i,children:o})})):null}function RedoclyOpenAPIDocsStandalone({definition:e,definitionUrl:o,options:t={},activeItemId:i,activeSampleLanguage:n,activeDeepLink:r}){return(0,jsx_runtime_1.jsx)(Providers_1.AppProvider,{definition:e,definitionUrl:o,options:t,activeItemId:i,activeSampleLanguage:n,activeDeepLink:r,children:(0,jsx_runtime_1.jsx)(RedoclyOpenAPIDocs,{withCommonStyles:!0})})}
//# sourceMappingURL=RedoclyOpenAPIDocs.js.map