import { Button } from '@mantine/core';
import { IconChevronLeft, IconMenu2, IconSearch, IconSparkles } from '@/components/icons';
import type { ReactNode } from 'react';
import { Link } from 'react-router-dom';
import { NotificationBell } from '../../notify/NotificationBell';
import { EnvBadge, envKind, useChosenEnv } from './EnvSwitcher';
import { useShell } from './prefs';
export const isMac = () => typeof navigator !== 'undefined' && /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent);
/** The toolbar of every page: sidebar toggle, back link, title and one-line caption on the left; a state chip, the page's
* actions and the search field (it opens the command palette, Ctrl K) on the right. Translucent, content scrolls under it.
* When the sidebar is folded to its icons, the practice-environment cue is repeated here so it never disappears. */
export function TopBar({ title, sub, middle, actions, titleTestId, honesty = true, back, plainTitle = false }: {
title: ReactNode; sub?: ReactNode; middle?: ReactNode; actions?: ReactNode; titleTestId?: string; honesty?: boolean; back?: { label: string; to: string };
/** The page has its own large heading: the toolbar shows the title as plain text, not a second heading. */
plainTitle?: boolean;
}) {
const { size, sidebarExpanded, openNav, openPalette } = useShell();
const { pod } = useChosenEnv();
const drawer = size === 'tablet' || size === 'phone';
const cue = honesty && drawer && !sidebarExpanded && pod && envKind(pod.kind) === 'mock'
? : null;
const phone = size === 'phone';
return (
{drawer
?
: null}
{back && {back.label}}
{plainTitle ?
{title}
:
{title}
}
{middle &&
{middle}
}
{(sub || cue) &&
{sub}{sub && cue ? · : null}{cue}
}
{actions}
{/* wide screens: notifications, search and Ask live in the top navigation */}
{drawer && }
{drawer && !phone && (
}>Ask AI
)}
{drawer && (
)}