import{REDOCLY_TEAMS_RBAC as m}from"@redocly/config";import{DEFAULT_SSO_IDP_TITLE as S,DEV_LOGIN_SLUG as u,INVITE_SLUG as T,PUBLIC_RBAC_SCOPE_ITEM as c,UI_ACCESSIBLE_CONFIG_PROPS as D,CONFIG_FILE_NAME as g}from"../../../constants/index.js";import{getTemplatePath as a}from"./get-template-path.js";import{resolveLinksFromConfig as d}from"../nav-utils.js";import{resolveLogoConfig as _}from"./resolve-logo.js";import{extractTeamNames as b}from"./extract-team-names.js";import{resolveProductsConfig as P}from"./resolve-products-config.js";import{isDevelopMode as E}from"../../utils/is-develop-mode.js";async function B(o){return{id:"Default Theme",async processContent(e){const t=v(e),r=Object.keys(e.getConfig()?.ssoDirect||{}).length>0,l=e.createTemplate("invite",a("../../../../dist/client/app/pages/Invite/Invite.js"));if(e.addRoute({duplicateInAllLocales:!0,excludeFromSidebar:!0,slug:T,[m]:c,fsPath:T,templateId:l}),o.devLogin&&r){let i={frontmatter:{},seo:{title:"Login page"},authIdps:t.filter(n=>n.title!=S),rbac:{teams:b(e.getConfig().rbac)}};const p=e.createTemplate("dev-login",a("../../../../dist/client/app/pages/DevLogin/DevLogin.js"));e.addRoute({duplicateInAllLocales:!0,excludeFromSidebar:!0,slug:u,[m]:c,fsPath:u,templateId:p,getStaticData:async(n,s)=>({props:{...i,loginUrls:s.getLoginUrls()}})})}else if(t.length>1){let i={frontmatter:{},seo:{title:"Login page"},authIdps:t};const p=e.createTemplate("login",a("../../../../dist/client/app/pages/Login/Login.js"));e.addRoute({duplicateInAllLocales:!0,excludeFromSidebar:!0,slug:u,[m]:c,fsPath:u,templateId:p,getStaticData:async(n,s)=>({props:{...i,loginUrls:s.getLoginUrls()}})})}e.createTemplate("404",a("../../../../dist/client/app/pages/404/404.js")),e.createTemplate("403",a("../../../../dist/client/app/pages/403/403.js")),e.createTemplate("403OIDC",a("../../../../dist/client/app/pages/403/403OIDC.js")),E()&&e.createTemplate("compilation-error",a("../../../../dist/client/app/pages/CompilationError/CompilationError.js"))},async afterRoutesCreated(e,t){const{contentDir:r,outdir:l}=e,i=e.getConfig(),{navbar:p,footer:n,userMenu:s,search:f,breadcrumbs:I,products:h}=i,L=Object.keys(i?.ssoDirect||{}).length>0,C={navFile:g};e.setGlobalData({...F(i),navbar:await d(p,r,e,t,C),footer:await d(n,r,e,t,C),breadcrumbs:{...I,prefixItems:await d(I?.prefixItems||[],r,e,t,{navFile:g})},userMenu:{...s,hide:s?.hide??!L,menu:await d(s?.items,r,e,t,{navFile:g})},logo:await _(i.logo,g,l,t.fs),auth:{idpsInfo:v(e),devLogin:o.devLogin&&L,loginUrls:e.getLoginUrls()},products:await P(h,e,t),search:{...f,suggestedPages:await d(f?.suggestedPages,r,e,t,{navFile:g})},headScriptTags:void 0,linkTags:void 0,postBodyScriptTags:void 0,preBodyScriptTags:void 0})}}}function v(o){const e=o.getConfig().ssoDirect;return Object.entries(e||{}).map(([r,l])=>({idpId:r,type:l.type,title:l.title}))}function F(o){const e={};for(const t of D)o[t]&&(e[t]=o[t]);return e}export{B as defaultThemePlugin,F as pickUiAccessibleConfig};
