/**
 * Utility functions for the FileTextbox component.
 */
import { HiDocument, HiDocumentText, HiPhotograph } from 'react-icons/hi';
export const TAG_COLORS = [
    'bg-gray-100 text-gray-600',
];
export function get_tag_color(tag) {
    let hash = 0;
    for (let i = 0; i < tag.length; i++)
        hash = ((hash << 5) - hash + tag.charCodeAt(i)) | 0;
    return TAG_COLORS[Math.abs(hash) % TAG_COLORS.length];
}
export function format_file_size(bytes) {
    if (bytes < 1024)
        return `${bytes} B`;
    if (bytes < 1024 * 1024)
        return `${(bytes / 1024).toFixed(1)} KB`;
    return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
}
export function get_file_icon(mime_type) {
    if (mime_type.startsWith('image/'))
        return HiPhotograph;
    if (mime_type === 'application/pdf' || mime_type.startsWith('text/'))
        return HiDocumentText;
    return HiDocument;
}
export function merge_adjacent_text_blocks(blocks) {
    const result = [];
    for (const block of blocks) {
        if (block.type === 'text' && result.length > 0 && result[result.length - 1].type === 'text') {
            const prev = result[result.length - 1];
            prev.content += '\n' + block.content;
            if (block.tags?.length)
                prev.tags = [...(prev.tags || []), ...block.tags];
        }
        else {
            result.push({ ...block });
        }
    }
    return result.length ? result : [{ type: 'text', content: '' }];
}
export function count_files(blocks) {
    return blocks.filter((b) => b.type === 'file').length;
}
/** Map a response_choice value to a short display label for the file tag */
export const RESPONSE_LABELS = {
    ignore: 'File Removed',
    submit_for_review: 'Send to Agent',
    replace_document: 'Replaced',
    provide_new_keep_existing: 'Additional docs provided',
    additional_documents: 'Additional docs provided',
    no_further_files: 'No further files',
};
export function get_response_label(choice) {
    return RESPONSE_LABELS[choice] ?? choice;
}
//# sourceMappingURL=utils.js.map