import { getLanguageFromFilename, wrapContentInCodeBlock } from "../../utils/codeLanguageUtils";
var HTML_MIME_TYPE = 'text/html';
var HTML_EXTENSIONS = [
    '.html',
    '.htm'
];
/**
 * 判断是否为 HTML 文件：扩展名或 MIME 任一命中
 */ export var isHtmlFile = function isHtmlFile(fileName, mimeType) {
    var name = (fileName === null || fileName === void 0 ? void 0 : fileName.toLowerCase()) || '';
    var byExtension = HTML_EXTENSIONS.some(function(ext) {
        return name.endsWith(ext);
    });
    var byMimeType = mimeType === HTML_MIME_TYPE;
    return byExtension || byMimeType;
};
/**
 * 将 ContentState 收敛到三态展示标识
 */ export var getContentStatus = function getContentStatus(state) {
    if ('error' in state) return 'error';
    return state.status === 'loading' ? 'loading' : 'done';
};
/**
 * 将原始文本按文件类别构造为 MarkdownEditor 可接收的内容
 *
 * - 代码类（category === 'code'）：用 ``` 围栏 + 推断语言包裹
 * - 其他类型：原文返回
 */ export var buildMarkdownContent = function buildMarkdownContent(raw, category, fileName) {
    if (category === 'code') {
        var language = getLanguageFromFilename(fileName);
        return wrapContentInCodeBlock(raw, language);
    }
    return raw;
};
