import*as o from"react";import{useEffect as l}from"react";import{Outlet as f,useLocation as g,useNavigate as d}from"react-router-dom";import{components as P}from"@redocly-markdoc/components";import h from"@markdoc/markdoc/dist/react";import{InternalServerErrorLayout as D}from"@redocly/theme/layouts/InternalServerErrorLayout";import{withPathPrefix as T}from"@redocly/theme/core/utils";import{RootLayout as S}from"@redocly/theme/layouts/RootLayout";import{PageLayout as _}from"@redocly/theme/layouts/PageLayout";import{components as i}from"@redocly/theme/markdoc/default";import{Sidebar as L}from"./app/Sidebar/Sidebar";import{loadAndNavigate as C}from"./app/utils/loadAndNavigate";import{useActions as v}from"./app/Sidebar/useActions";import{useScrollTracker as A}from"./app/hooks/useScrollTracker";import{useAutoScroll as N}from"./app/hooks/useAutoScroll";import{OPENAPI_DOCS_TEMPLATE_ID as O,ASYNC_API_DOCS_TEMPLATE_ID as y,GRAPHQL_TEMPLATE_ID as R}from"../constants/common";import{removeTrailingSlash as I}from"../utils/url/remove-trailing-slash";import*as b from"../server/plugins/markdown/markdoc/custom-components/index";import{ErrorBubble as k}from"./app/ErrorBubble";import{DefaultStyles as x}from"./styling/default-styles";import{ThemeDataProvider as M}from"./providers/theme/ThemeDataProvider";import{PageDataContext as V}from"./providers/page-data/PageDataContext";import{SeoTags as B}from"./app/seo/SeoTags";import{useRouterForLocalLinks as G,useRunningEnvironmentCheck as $}from"./providers/hooks";import{usePageData as w,usePageDataLoader as F}from"./providers/page-data/hooks";import{ErrorBoundary as H}from"./ErrorBoundary";import{ErrorDetails as c,Loader as Q}from"./server-entry";import"@styles";import{useRouteChangeTracker as U}from"./app/hooks/useRouteChangeTracker";import{isInIframe as Y}from"./utils";import{useL10n as j}from"./app/l10n";import{PostMessageProvider as q}from"./providers/post-message/PostMessageProvider";import{ScriptLoader as z}from"./ScriptLoader";import{clientRoutes as J}from"./runtime/generated/routes.js";import{PageCounter as K}from"./app/PageCounter";globalThis.__LOADER.markdocComponents={...b,...i};function Ie(){const e=F(),[t,a]=o.useState(e),r=g(),m=d();j(),l(()=>{e?a(e):C({navigate:m,to:r.pathname+r.search+r.hash}).then(()=>a(Q.loadSync(r.pathname)))},[r,m]),G();const n=$();return n?(console.log(n),o.createElement(c,{error:{message:n,name:""}})):t?o.createElement(H,null,o.createElement(x,null),o.createElement(V.Provider,{value:e||t},o.createElement(M,null,o.createElement(q,{enabled:process.env.NODE_ENV==="development"||Y()},o.createElement(f,null))))):null}function u(){U(),A(),N();const e=w(),t=v(),{layout:a}=t,r={layout:a},m=process.env.NODE_ENV!=="production",n=globalThis.SSR_OMIT_SUSPENSE,s=e?.props.ast&&e.props.ast.$$mdtype==="Tag"?h(e.props.ast,o,{components:{...globalThis.__LOADER.markdocComponents,...i,...P}}):null,E=I(e?.slug||"");if(l(()=>{document.documentElement.classList.add("ready")},[]),e?.props.pagePropGetterError?.message)return m?o.createElement(c,{error:{...e?.props?.pagePropGetterError}}):o.createElement(D,null);if(!!e?.props?.compilationErrors?.length)return e?.Template?o.createElement(e.Template,{pageProps:e?.props,children:s}):null;const p=()=>o.createElement(S,null,o.createElement(_,{sidebar:o.createElement(L,{layoutControls:t})},o.createElement(B,{seo:e?.props.seo,slug:E}),e?.Template?o.createElement(e.Template,{pageProps:[O,y,R].includes(e.templateId)?{...e.props,apiOptions:r}:e?.props,children:s}):null),process.env.NODE_ENV!=="production"&&o.createElement(k,null),process.env.NODE_ENV!=="production"&&o.createElement(K,null),o.createElement(z,null));return n?p():o.createElement(o.Suspense,null,p())}const be=[...J.map(e=>({Component:u,path:T(e).substring(1)+"/*"})),{Component:u,path:"*"}];export{Ie as App,u as Page,be as routes};
