import { jsx as _jsx } from "react/jsx-runtime";
import { Box, Text } from "ink";
export function MessageTimestamp(props) {
    const formatted = formatMessageTimestamp(props.timestamp);
    if (!formatted)
        return null;
    return (_jsx(Box, { minWidth: formatted.length, children: _jsx(Text, { dimColor: true, children: formatted }) }));
}
export function formatMessageTimestamp(timestamp) {
    if (!timestamp)
        return null;
    const date = timestamp instanceof Date ? timestamp : new Date(timestamp);
    if (Number.isNaN(date.getTime()))
        return null;
    return date.toLocaleTimeString("en-US", {
        hour: "2-digit",
        minute: "2-digit",
        hour12: true,
    });
}
