"use client"; import { motion, useReducedMotion } from "motion/react"; import { type ComponentPropsWithRef, createContext, type ReactNode, useContext, } from "react"; import { EASE_OUT } from "@/lib/ease"; import { cn } from "@/lib/utils"; import { MessageSideContext } from "@/components/agents/message-context"; export { MessageBubble, MessageBubbleCollapsible, MessageBubbleContent, MessageBubbleGroup, } from "@/components/agents/message-bubble"; export { MessageScroller } from "@/components/agents/message-scroller"; export type { MessageScrollerProps } from "@/components/agents/message-scroller"; export type MessageFrom = "user" | "assistant"; interface MessageContextValue { from: MessageFrom; } const MessageContext = createContext({ from: "assistant", }); export interface MessageProps extends Omit, "children"> { from: MessageFrom; /** Plays a trailing-edge pop-up once when this message row mounts. */ animateIn?: boolean; children: ReactNode; } export interface MessageGroupProps extends ComponentPropsWithRef<"div"> { spacing?: "compact" | "default"; } export interface MessageAvatarProps extends ComponentPropsWithRef<"div"> { /** Keep an empty avatar slot so grouped messages remain aligned. */ placeholder?: boolean; } export type MessageContentProps = ComponentPropsWithRef<"div">; export type MessageHeaderProps = ComponentPropsWithRef<"div">; export type MessageFooterProps = ComponentPropsWithRef<"div">; export type MessageMarkerProps = ComponentPropsWithRef<"div">; export interface MessageTypingProps extends ComponentPropsWithRef<"span"> { label?: string; } // A sent row should rise from the live edge without changing measured layout. const MESSAGE_POP_UP = { type: "spring", stiffness: 480, damping: 32, mass: 0.62, } as const; export function Message({ from, animateIn = false, children, className, initial, animate, transition, exit, style, ...props }: MessageProps) { const reduce = useReducedMotion() ?? false; return ( {children} ); } export function MessageGroup({ spacing = "compact", className, ...props }: MessageGroupProps) { return (
); } export function MessageAvatar({ placeholder = false, children, className, ...props }: MessageAvatarProps) { return (
{children}
); } export function MessageContent({ className, ...props }: MessageContentProps) { const { from } = useContext(MessageContext); return (
); } export function MessageHeader({ className, ...props }: MessageHeaderProps) { const { from } = useContext(MessageContext); return (
); } export function MessageFooter({ className, ...props }: MessageFooterProps) { const { from } = useContext(MessageContext); return (
); } export function MessageMarker({ className, ...props }: MessageMarkerProps) { return (
); } export function MessageTyping({ label = "Responding", className, ...props }: MessageTypingProps) { const reduce = useReducedMotion() ?? false; return ( {label} {[0, 1, 2].map((index) => ( ); }