/**
 * Renders a user message in a styled box with optional annotation and file attachments.
 */
import { Box, Container, Markdown, Spacer, Text } from '../../../tui/index.js';
import { formatAttachmentLabels } from '../../input/file-attachments.js';
import { CONTENT_PAD_X, CONTENT_PAD_Y } from '../../layout.js';
import { theme } from '../../theme/runtime.js';
import { getMarkdownTheme } from '../../theme/theme.js';
/**
 * Component that renders a user message with an optional right-aligned annotation
 * and file attachment labels.
 */
export class UserMessageComponent extends Container {
    _annotation;
    _attachments;
    box;
    constructor(text, markdownTheme = getMarkdownTheme()) {
        super();
        this.addChild(new Spacer(1));
        this.box = new Box(CONTENT_PAD_X, CONTENT_PAD_Y, (t) => theme.bg('userMessageBg', t));
        this.box.addChild(new Markdown(text, 0, 0, markdownTheme, {
            color: (text) => theme.fg('userMessageText', text)
        }));
        this.addChild(this.box);
    }
    /** Set a dim annotation shown above the message (e.g. workbook names). */
    setAnnotation(text) {
        if (!this._annotation) {
            this._annotation = new Text(theme.fg('dim', text), 0, 0);
            // Insert between Spacer and Box
            this.children.splice(1, 0, this._annotation);
        }
        else {
            this._annotation.setText(theme.fg('dim', text));
        }
    }
    /** Set file attachment labels shown below the message with ⎿ glyph. */
    setAttachments(filePaths) {
        if (filePaths.length === 0)
            return;
        const labels = formatAttachmentLabels(filePaths);
        if (!this._attachments) {
            this._attachments = new Text(labels, 0, 0);
            this.box.addChild(this._attachments);
        }
        else {
            this._attachments.setText(labels);
        }
    }
}
//# sourceMappingURL=user-message.js.map