import type { ComponentPropsWithoutRef } from "react"; import { Facepile, type FacepileAvatar } from "../facepile/facepile"; import { TypingDots } from "../typing-dots/typing-dots"; import { cn } from "../../lib/utils"; const DISCLAIMER = "Ace is AI and can make mistakes. Please double-check responses."; const SHORT = "Ace is AI and can make mistakes."; const NAMES: readonly string[] = []; const AVATARS: FacepileAvatar[] = []; type ChatStatusProps = ComponentPropsWithoutRef<"div"> & { typing?: readonly string[]; avatars?: FacepileAvatar[]; disclaimer?: string; onDisclaimerClose?: () => void; }; function label(names: readonly string[]) { if (names.length === 0) return ""; if (names.length === 1) return `${names[0]} is typing`; if (names.length === 2) return `${names[0]} and ${names[1]} are typing`; if (names.length === 3) return `${names[0]}, ${names[1]}, and ${names[2]} are typing`; return `${names[0]}, ${names[1]}, and ${names.length - 2} others are typing`; } function ChatStatus( { typing = NAMES, avatars = AVATARS, disclaimer = DISCLAIMER, onDisclaimerClose, className, ...props }: ChatStatusProps, ) { let text = typing.length > 0 && typing.length <= 3 ? label(typing) : ""; let note = typing.length > 0 ? label(typing) : ""; return (
{note && {note}} {avatars.length > 0 && (
{disclaimer && (

{disclaimer === DISCLAIMER ? ( <> ) : disclaimer} {onDisclaimerClose && ( <> {" "} )}

)}
); } export { ChatStatus, type ChatStatusProps };