'use client'; import { Fragment } from 'react'; import { useChatContext } from '../../context'; import type { UseChatDockPrefsReturn } from '../../hooks/useChatDockPrefs'; import { ChatHeaderAudioToggle } from './ChatHeaderAudioToggle'; import { ChatHeaderLanguageButton } from './ChatHeaderLanguageButton'; import { ChatHeaderModeToggle } from './ChatHeaderModeToggle'; import { ChatHeaderResetButton } from './ChatHeaderResetButton'; import type { ResolvedChatHeaderSlots } from '../types'; export interface HeaderSlotsRendererProps { slots: ResolvedChatHeaderSlots; /** * Shared dock-prefs instance owned by ``. The mode * toggle MUST use the same instance the dock reads from — a separate * `useChatDockPrefs` call would hold isolated state and the toggle * would no-op. */ dockPrefs: UseChatDockPrefsReturn; } /** * Renders the declarative `headerSlots` config inside the * `` mounted by ``. * * Order (left → right, before the close icon): * custom · languagePicker · modeToggle · audio · reset */ export function HeaderSlotsRenderer({ slots, dockPrefs }: HeaderSlotsRendererProps) { const ctx = useChatContext(); return ( <> {slots.custom ? {slots.custom(ctx)} : null} {slots.languagePicker ? ( ) : null} {slots.modeToggle ? ( ) : null} {slots.audio && !ctx.audio.isSilent ? ( ) : null} {slots.reset && ctx.sessionId ? : null} ); } function ModeToggleSlot({ slot, dockPrefs, }: { slot: NonNullable; dockPrefs: UseChatDockPrefsReturn; }) { return ( ); } function ResetSlot({ slot, }: { slot: NonNullable; }) { const ctx = useChatContext(); const handleSuccess = () => { if (slot.onSuccess) { slot.onSuccess(ctx); return; } ctx.clearMessages(); }; return ( ); }