import { useParams } from 'react-router'; import { DEFAULT_HEADSCALE_SECTION, isHeadscaleSection, type HeadscaleSectionId } from './shared'; // The URL is the source of truth for which section is open — not a panel channel. See docs/navigation-audit.md: // selection held in a channel means the id lives only in an onClick closure, so the section can't be linked to, // opened in a new tab, or reached with the back button. HeadscaleScreen redirects anything unrecognised, so the // fallback here is only for the instant before that lands. export function useHeadscaleSection(): HeadscaleSectionId { const { section } = useParams(); return isHeadscaleSection(section) ? section : DEFAULT_HEADSCALE_SECTION; }