import { jsx } from 'react/jsx-runtime';
import React__default from 'react';
import { cn } from '../../../utils/cn.js';
import { useMessageContext } from './MessageContext.js';
import { messageTheme } from './Message.theme.js';
import { TypeWriter } from './TypeWriter.js';

const MessageBody = React__default.forwardRef(({ children, className, ...props }, ref) => {
    const { variant, role, isStreaming, typingSpeed } = useMessageContext();
    // Get variant-specific theme
    const variantTheme = messageTheme.variants[variant];
    // Build bubble style using theme structure
    const bubbleStyle = cn(messageTheme.bubbleBaseStyle, variantTheme.bubbleStyle, className);
    // Use TypeWriter for streaming assistant/receiver messages with string content
    const shouldAnimate = (role === 'assistant' || variant === 'receiver') &&
        isStreaming &&
        typeof children === 'string';
    return (jsx("div", { ref: ref, className: bubbleStyle, ...props, children: shouldAnimate ? (jsx(TypeWriter, { text: children, speed: typingSpeed, enabled: true, className: "break-words" })) : typeof children === 'string' ? (jsx("p", { className: "break-words", children: children })) : (children) }));
});
MessageBody.displayName = 'Message.Body';

export { MessageBody };
