import Link from "next/link";
import type { Locale } from "@/i18n/config";
import type { Dictionary } from "@/i18n/get-dictionary";
import { type NavKey, navLinks, routes, sectionIds } from "@/lib/routes";
import { LogoHorizontal } from "../logo";
import { DesktopNav } from "./desktop-nav";
import { HeaderActions } from "./header-actions";
import { HeaderShell } from "./header-shell";
import { MobileNav } from "./mobile-nav";

type HeaderProps = { locale: Locale; nav: Dictionary["nav"]; /** Highlighted nav item (the current page). */ activeKey?: NavKey };

export function Header({ locale, nav, activeKey }: HeaderProps) {
  // Figma's header has no "Contact" (the footer keeps it); "Get Started" goes to the contact section instead.
  const links = navLinks(locale)
    .filter((l) => l.key !== "contact")
    .map((l) => ({ ...l, label: nav[l.key] }));
  const getStartedHref = routes.section(locale, sectionIds.contact);

  return (
    <HeaderShell>
      <Link href={routes.home(locale)} aria-label={nav.home} className="shrink-0">
        <LogoHorizontal />
      </Link>

      <DesktopNav links={links} activeKey={activeKey} label={nav.mainNav} portfolioLabel={nav.portfolio} className="hidden xl:block" />

      <HeaderActions
        locale={locale}
        switchLanguageLabel={nav.switchLanguage}
        getStartedLabel={nav.getStarted}
        getStartedHref={getStartedHref}
        className="hidden xl:flex"
      />

      <MobileNav
        locale={locale}
        links={links}
        activeKey={activeKey}
        nav={nav}
        getStartedHref={getStartedHref}
        className="xl:hidden"
      />
    </HeaderShell>
  );
}
