import mimeTypes from './mimeTypes.json';
/**
 * Returns approximately correct mime type for given file based upon the extension. Only few extensions are recognized.
 * @param fileName file name or url to discover the mime type from.
 * @returns mime type associated to the file.
 */
export const getMimeTypeFromFile = (fileName) => {
    const fileExt = fileName.split('.').pop() ?? fileName;
    return mimeTypes[fileExt.toLowerCase()];
};
export const getKindFromMimeType = (mimeType) => {
    let type = 'generic';
    if (mimeType.startsWith('video/'))
        type = 'video';
    if (mimeType.startsWith('audio/'))
        type = 'audio';
    if (mimeType.startsWith('image/'))
        type = 'image';
    if (mimeType.startsWith('text/'))
        type = 'text';
    if (mimeType.startsWith('message/'))
        type = 'message';
    if (mimeType.endsWith('/pdf'))
        type = 'pdf';
    if (mimeType.match(/powerpoint|presentation|impress/))
        type = 'presentation';
    if (mimeType.match(/excel|spreadsheet|calc|csv/))
        type = 'spreadsheet';
    if (mimeType.match(/word|writer/))
        type = 'document';
    if (mimeType.match(/access|database/))
        type = 'database';
    if (mimeType.match(/zip|rar|7z/))
        type = 'archive';
    return type;
};
//# sourceMappingURL=utils.js.map