---
import type { DocsSectionNav, DocsSidebarNav } from '../../lib/docs';
import MainHeader from './MainHeader.astro';
import MobileDocsNav from './MobileDocsNav.astro';
import SubNav from './SubNav.astro';
import rawThemeConfig from 'virtual:prosefly/lotus/config';
import { isPagefindSearchEnabled } from '../../lib/search';
import type { LotusThemeConfig } from '../../lib/theme';

interface Heading {
  depth: number;
  slug: string;
  text: string;
}

interface Props {
  currentPath?: string;
  headings?: Heading[];
  sectionTitle?: string;
  sections: DocsSectionNav[];
  sidebar?: DocsSidebarNav;
  sidebars?: Record<string, DocsSidebarNav>;
  title?: string;
}

const {
  currentPath,
  headings = [],
  sectionTitle,
  sections,
  sidebar,
  sidebars = {},
  title = '',
} = Astro.props;
const themeConfig = rawThemeConfig as LotusThemeConfig;
const pagefindIgnoreAttrs = isPagefindSearchEnabled(themeConfig)
  ? { 'data-pagefind-ignore': true }
  : {};
---

<div class="lotus-border-subtle sticky top-0 z-40 border-b bg-(--lotus-header-background)/95 backdrop-blur" {...pagefindIgnoreAttrs}>
  <MainHeader currentPath={currentPath} surface={false} />
  <div class="hidden lg:block">
    <SubNav sections={sections} />
  </div>
  {sidebar && (
    <MobileDocsNav
      currentPath={currentPath}
      headings={headings}
      sectionTitle={sectionTitle}
      sections={sections}
      sidebar={sidebar}
      sidebars={sidebars}
      title={title}
    />
  )}
</div>
