'use strict';

var getIconProps = require('./get-icon-props-CwpDdQDI.js');

const DEFAULT_ICON_BACKGROUND_COLOR = 'rgba(var(--color-gray-lighter), 0.4)';
const CALENDAR_ICON_BACKGROUND_COLOR = 'rgba(var(--color-cyan-lighter), 0.4)';
const EMAIL_ICON_BACKGROUND_COLOR = 'rgba(var(--color-gray-lighter), 0.4)';
const HTML_ICON_BACKGROUND_COLOR = 'rgba(var(--color-blue-lighter), 0.4)';
const TEXT_ICON_BACKGROUND_COLOR = 'rgba(var(--color-yellow-lighter), 0.4)';
const EXCEL_ICON_BACKGROUND_COLOR = 'rgba(var(--color-green-lighter), 0.4)';
const POWERPOINT_ICON_BACKGROUND_COLOR = 'rgba(var(--color-coral-lighter), 0.4)';
const WORD_ICON_BACKGROUND_COLOR = 'rgba(var(--color-sky-lighter), 0.4)';
const IMAGE_ICON_BACKGROUND_COLOR = 'rgba(var(--color-lime-lighter), 0.4)';
const VECTOR_GRAPHIC_ICON_BACKGROUND_COLOR = 'rgba(var(--color-magenta-lighter), 0.4)';
const PRESENTATION_BACKGROUND_COLOR = 'rgba(var(--color-blue-lighter), 0.4)';
const DOCUMENT_ICON_BACKGROUND_COLOR = 'rgba(var(--color-orange-lighter), 0.4)';
const SPREADSHEET_ICON_BACKGROUND_COLOR = 'rgba(var(--color-green-lighter), 0.4)';
const AUDIO_ICON_BACKGROUND_COLOR = 'rgba(var(--color-indigo-lighter), 0.4)';
const VIDEO_ICON_BACKGROUND_COLOR = 'rgba(var(--color-red-lighter), 0.4)';
const COMPRESSED_ICON_BACKGROUND_COLOR = 'rgba(var(--color-orange-lighter), 0.4)';
const MESSAGE_ICON_BACKGROUND_COLOR = 'rgba(var(--color-yellow-lighter), 0.4)';
const PDF_ICON_BACKGROUND_COLOR = 'rgba(var(--color-red-lighter), 0.4)';
const DATA_ICON_BACKGROUND_COLOR = 'rgba(var(--color-glaucous-lighter), 0.4)';
const filetypeBackgroundColorTable = {
    // Message
    msg: MESSAGE_ICON_BACKGROUND_COLOR,
    // Calendar
    ics: CALENDAR_ICON_BACKGROUND_COLOR,
    ical: CALENDAR_ICON_BACKGROUND_COLOR,
    icalendar: CALENDAR_ICON_BACKGROUND_COLOR,
    // Email
    ifb: CALENDAR_ICON_BACKGROUND_COLOR,
    email: EMAIL_ICON_BACKGROUND_COLOR,
    eml: EMAIL_ICON_BACKGROUND_COLOR,
    oft: EMAIL_ICON_BACKGROUND_COLOR,
    ost: EMAIL_ICON_BACKGROUND_COLOR,
    emlx: EMAIL_ICON_BACKGROUND_COLOR,
    // Web
    html: HTML_ICON_BACKGROUND_COLOR,
    xml: HTML_ICON_BACKGROUND_COLOR,
    // Editable text
    txt: TEXT_ICON_BACKGROUND_COLOR,
    rtf: TEXT_ICON_BACKGROUND_COLOR,
    // Editable document
    dot: WORD_ICON_BACKGROUND_COLOR,
    doc: WORD_ICON_BACKGROUND_COLOR,
    docx: WORD_ICON_BACKGROUND_COLOR,
    dotx: WORD_ICON_BACKGROUND_COLOR,
    docm: WORD_ICON_BACKGROUND_COLOR,
    dotm: WORD_ICON_BACKGROUND_COLOR,
    odt: DOCUMENT_ICON_BACKGROUND_COLOR,
    pages: DOCUMENT_ICON_BACKGROUND_COLOR,
    // Portable document
    pdf: PDF_ICON_BACKGROUND_COLOR,
    // Presentation
    ppt: POWERPOINT_ICON_BACKGROUND_COLOR,
    pot: POWERPOINT_ICON_BACKGROUND_COLOR,
    pps: POWERPOINT_ICON_BACKGROUND_COLOR,
    pptx: POWERPOINT_ICON_BACKGROUND_COLOR,
    pptm: POWERPOINT_ICON_BACKGROUND_COLOR,
    potx: POWERPOINT_ICON_BACKGROUND_COLOR,
    potm: POWERPOINT_ICON_BACKGROUND_COLOR,
    ppam: POWERPOINT_ICON_BACKGROUND_COLOR,
    ppsx: POWERPOINT_ICON_BACKGROUND_COLOR,
    ppsm: POWERPOINT_ICON_BACKGROUND_COLOR,
    sldx: POWERPOINT_ICON_BACKGROUND_COLOR,
    sldm: POWERPOINT_ICON_BACKGROUND_COLOR,
    odp: PRESENTATION_BACKGROUND_COLOR,
    key: PRESENTATION_BACKGROUND_COLOR,
    // Spreadsheet
    xls: EXCEL_ICON_BACKGROUND_COLOR,
    xlsx: EXCEL_ICON_BACKGROUND_COLOR,
    csv: DEFAULT_ICON_BACKGROUND_COLOR,
    numbers: SPREADSHEET_ICON_BACKGROUND_COLOR,
    // Image
    bmp: IMAGE_ICON_BACKGROUND_COLOR,
    jpg: IMAGE_ICON_BACKGROUND_COLOR,
    jpeg: IMAGE_ICON_BACKGROUND_COLOR,
    heic: IMAGE_ICON_BACKGROUND_COLOR,
    png: IMAGE_ICON_BACKGROUND_COLOR,
    gif: IMAGE_ICON_BACKGROUND_COLOR,
    // Editable image
    psd: PRESENTATION_BACKGROUND_COLOR,
    ai: DOCUMENT_ICON_BACKGROUND_COLOR,
    // Vector graphic
    svg: VECTOR_GRAPHIC_ICON_BACKGROUND_COLOR,
    svgz: VECTOR_GRAPHIC_ICON_BACKGROUND_COLOR,
    ep: VECTOR_GRAPHIC_ICON_BACKGROUND_COLOR,
    eps: VECTOR_GRAPHIC_ICON_BACKGROUND_COLOR,
    sketch: VECTOR_GRAPHIC_ICON_BACKGROUND_COLOR,
    // Audio
    mp3: AUDIO_ICON_BACKGROUND_COLOR,
    wav: AUDIO_ICON_BACKGROUND_COLOR,
    wma: AUDIO_ICON_BACKGROUND_COLOR,
    ogg: AUDIO_ICON_BACKGROUND_COLOR,
    // Video
    flv: VIDEO_ICON_BACKGROUND_COLOR,
    h264: VIDEO_ICON_BACKGROUND_COLOR,
    mov: VIDEO_ICON_BACKGROUND_COLOR,
    mp4: VIDEO_ICON_BACKGROUND_COLOR,
    mwv: VIDEO_ICON_BACKGROUND_COLOR,
    // Compressed:
    zip: COMPRESSED_ICON_BACKGROUND_COLOR,
    '7z': COMPRESSED_ICON_BACKGROUND_COLOR,
    rar: COMPRESSED_ICON_BACKGROUND_COLOR,
    // Data
    json: DATA_ICON_BACKGROUND_COLOR,
    yaml: DATA_ICON_BACKGROUND_COLOR,
    sql: DATA_ICON_BACKGROUND_COLOR,
    db: DATA_ICON_BACKGROUND_COLOR,
    dbf: DATA_ICON_BACKGROUND_COLOR,
};
/**
 *
 * @param extension
 */
function getIconBackgroundColorForFile(extension) {
    return (filetypeBackgroundColorTable[extension.toLowerCase()] ||
        DEFAULT_ICON_BACKGROUND_COLOR);
}

const DEFAULT_ICON_FILL_COLOR = 'rgb(var(--color-gray-dark))';
const CALENDAR_ICON_FILL_COLOR = 'rgb(var(--color-cyan-dark))';
const EMAIL_ICON_FILL_COLOR = 'rgb(var(--color-gray-dark))';
const HTML_ICON_FILL_COLOR = 'rgb(var(--color-blue-dark))';
const TEXT_ICON_FILL_COLOR = 'rgb(var(--color-yellow-darker))';
const EXCEL_ICON_FILL_COLOR = 'rgb(var(--color-green-dark))';
const POWERPOINT_ICON_FILL_COLOR = 'rgb(var(--color-coral-dark))';
const WORD_ICON_FILL_COLOR = 'rgb(var(--color-sky-dark))';
const IMAGE_ICON_FILL_COLOR = 'rgb(var(--color-lime-dark))';
const VECTOR_GRAPHIC_FILL_COLOR = 'rgb(var(--color-magenta-dark))';
const PRESENTATION_ICON_FILL_COLOR = 'rgb(var(--color-blue-dark))';
const DOCUMENT_ICON_FILL_COLOR = 'rgb(var(--color-orange-dark))';
const SPREADSHEET_ICON_FILL_COLOR = 'rgb(var(--color-green-dark))';
const AUDIO_ICON_FILL_COLOR = 'rgb(var(--color-indigo-dark))';
const VIDEO_ICON_FILL_COLOR = 'rgb(var(--color-red-dark))';
const COMPRESSED_ICON_FILL_COLOR = 'rgb(var(--color-brown-default))';
const MESSAGE_ICON_FILL_COLOR = 'rgb(var(--color-yellow-dark))';
const PDF_ICON_FILL_COLOR = 'rgb(var(--color-red-dark))';
const DATA_ICON_FILL_COLOR = 'rgb(var(--color-glaucous-dark))';
const filetypeFillColorTable = {
    // Message
    msg: MESSAGE_ICON_FILL_COLOR,
    // Calendar
    ics: CALENDAR_ICON_FILL_COLOR,
    ical: CALENDAR_ICON_FILL_COLOR,
    icalendar: CALENDAR_ICON_FILL_COLOR,
    ifb: CALENDAR_ICON_FILL_COLOR,
    // Email
    email: EMAIL_ICON_FILL_COLOR,
    eml: EMAIL_ICON_FILL_COLOR,
    oft: EMAIL_ICON_FILL_COLOR,
    ost: EMAIL_ICON_FILL_COLOR,
    emlx: EMAIL_ICON_FILL_COLOR,
    // Web
    html: HTML_ICON_FILL_COLOR,
    xml: HTML_ICON_FILL_COLOR,
    // Editable text
    txt: TEXT_ICON_FILL_COLOR,
    rtf: TEXT_ICON_FILL_COLOR,
    // Editable document
    dot: WORD_ICON_FILL_COLOR,
    doc: WORD_ICON_FILL_COLOR,
    docx: WORD_ICON_FILL_COLOR,
    dotx: WORD_ICON_FILL_COLOR,
    docm: WORD_ICON_FILL_COLOR,
    dotm: WORD_ICON_FILL_COLOR,
    odt: DOCUMENT_ICON_FILL_COLOR,
    pages: DOCUMENT_ICON_FILL_COLOR,
    // Portable document
    pdf: PDF_ICON_FILL_COLOR,
    // Presentation
    ppt: POWERPOINT_ICON_FILL_COLOR,
    pot: POWERPOINT_ICON_FILL_COLOR,
    pps: POWERPOINT_ICON_FILL_COLOR,
    pptx: POWERPOINT_ICON_FILL_COLOR,
    pptm: POWERPOINT_ICON_FILL_COLOR,
    potx: POWERPOINT_ICON_FILL_COLOR,
    potm: POWERPOINT_ICON_FILL_COLOR,
    ppam: POWERPOINT_ICON_FILL_COLOR,
    ppsx: POWERPOINT_ICON_FILL_COLOR,
    ppsm: POWERPOINT_ICON_FILL_COLOR,
    sldx: POWERPOINT_ICON_FILL_COLOR,
    sldm: POWERPOINT_ICON_FILL_COLOR,
    odp: PRESENTATION_ICON_FILL_COLOR,
    key: PRESENTATION_ICON_FILL_COLOR,
    // Spreadsheet
    xls: EXCEL_ICON_FILL_COLOR,
    xlsx: EXCEL_ICON_FILL_COLOR,
    csv: DEFAULT_ICON_FILL_COLOR,
    numbers: SPREADSHEET_ICON_FILL_COLOR,
    // Image
    bmp: IMAGE_ICON_FILL_COLOR,
    jpg: IMAGE_ICON_FILL_COLOR,
    jpeg: IMAGE_ICON_FILL_COLOR,
    heic: IMAGE_ICON_FILL_COLOR,
    png: IMAGE_ICON_FILL_COLOR,
    gif: IMAGE_ICON_FILL_COLOR,
    // Editable image
    psd: PRESENTATION_ICON_FILL_COLOR,
    ai: DOCUMENT_ICON_FILL_COLOR,
    // Vector graphic
    svg: VECTOR_GRAPHIC_FILL_COLOR,
    svgz: VECTOR_GRAPHIC_FILL_COLOR,
    ep: VECTOR_GRAPHIC_FILL_COLOR,
    eps: VECTOR_GRAPHIC_FILL_COLOR,
    sketch: VECTOR_GRAPHIC_FILL_COLOR,
    // Audio
    mp3: AUDIO_ICON_FILL_COLOR,
    wav: AUDIO_ICON_FILL_COLOR,
    wma: AUDIO_ICON_FILL_COLOR,
    ogg: AUDIO_ICON_FILL_COLOR,
    // Video
    flv: VIDEO_ICON_FILL_COLOR,
    h264: VIDEO_ICON_FILL_COLOR,
    mov: VIDEO_ICON_FILL_COLOR,
    mp4: VIDEO_ICON_FILL_COLOR,
    mwv: VIDEO_ICON_FILL_COLOR,
    // Compressed
    zip: COMPRESSED_ICON_FILL_COLOR,
    '7z': COMPRESSED_ICON_FILL_COLOR,
    rar: COMPRESSED_ICON_FILL_COLOR,
    // Data
    json: DATA_ICON_FILL_COLOR,
    yaml: DATA_ICON_FILL_COLOR,
    sql: DATA_ICON_FILL_COLOR,
    db: DATA_ICON_FILL_COLOR,
    dbf: DATA_ICON_FILL_COLOR,
};
/**
 *
 * @param extension
 */
function getIconFillColorForFile(extension) {
    return (filetypeFillColorTable[extension.toLowerCase()] ||
        DEFAULT_ICON_FILL_COLOR);
}

const DEFAULT_ICON = 'file';
const CALENDAR_ICON = 'tear_off_calendar';
const EMAIL_ICON = 'email';
const HTML_ICON = 'internet';
const TEXT_ICON = 'text_box';
const EXCEL_ICON = 'ms_excel_copyrighted';
const WORD_ICON = 'ms_word_copyrighted';
const POWERPOINT_ICON = 'ms_powerpoint_copyrighted';
const IMAGE_ICON = 'picture';
const PHOTO_ICON = 'camera';
const VECTOR_GRAPHIC_ICON = 'vector';
const PRESENTATION_ICON = 'presentation_filled';
const DOCUMENT_ICON = 'overview_pages_2';
const SPREADSHEET_ICON = 'data_sheet';
const AUDIO_ICON = 'audio_wave';
const VIDEO_ICON = 'video_file';
const COMPRESSED_ICON = 'condom_package';
const MESSAGE_ICON = 'ms_outlook_copyrighted';
const DATA_ICON = 'database';
const filetypeIconTable = {
    // Message
    msg: MESSAGE_ICON,
    // Calendar
    ics: CALENDAR_ICON,
    ical: CALENDAR_ICON,
    icalendar: CALENDAR_ICON,
    ifb: CALENDAR_ICON,
    // Email
    email: EMAIL_ICON,
    eml: EMAIL_ICON,
    oft: EMAIL_ICON,
    ost: EMAIL_ICON,
    emlx: EMAIL_ICON,
    // Web
    html: HTML_ICON,
    xml: HTML_ICON,
    // Editable text
    txt: TEXT_ICON,
    rtf: TEXT_ICON,
    // Editable document
    dot: WORD_ICON,
    doc: WORD_ICON,
    docx: WORD_ICON,
    dotx: WORD_ICON,
    docm: WORD_ICON,
    dotm: WORD_ICON,
    odt: DOCUMENT_ICON,
    pages: DOCUMENT_ICON,
    // Portable document
    pdf: 'PDF_2',
    // Presentation
    ppt: POWERPOINT_ICON,
    pot: POWERPOINT_ICON,
    pps: POWERPOINT_ICON,
    pptx: POWERPOINT_ICON,
    pptm: POWERPOINT_ICON,
    potx: POWERPOINT_ICON,
    potm: POWERPOINT_ICON,
    ppam: POWERPOINT_ICON,
    ppsx: POWERPOINT_ICON,
    ppsm: POWERPOINT_ICON,
    sldx: POWERPOINT_ICON,
    sldm: POWERPOINT_ICON,
    odp: PRESENTATION_ICON,
    key: PRESENTATION_ICON,
    // Spreadsheet
    xls: EXCEL_ICON,
    xlsx: EXCEL_ICON,
    csv: SPREADSHEET_ICON,
    numbers: SPREADSHEET_ICON,
    // Image
    jpg: PHOTO_ICON,
    jpeg: PHOTO_ICON,
    heic: PHOTO_ICON,
    bmp: IMAGE_ICON,
    png: IMAGE_ICON,
    gif: IMAGE_ICON,
    // Editable image
    psd: 'adobe_photoshop_copyrighted',
    ai: 'adobe_illustrator_copyrighted',
    // Vector graphic
    svg: VECTOR_GRAPHIC_ICON,
    svgz: VECTOR_GRAPHIC_ICON,
    ep: VECTOR_GRAPHIC_ICON,
    eps: VECTOR_GRAPHIC_ICON,
    sketch: VECTOR_GRAPHIC_ICON,
    // Audio
    mp3: AUDIO_ICON,
    wav: AUDIO_ICON,
    wma: AUDIO_ICON,
    ogg: AUDIO_ICON,
    // Video
    avi: VIDEO_ICON,
    flv: VIDEO_ICON,
    h264: VIDEO_ICON,
    mov: VIDEO_ICON,
    mp4: VIDEO_ICON,
    mwv: VIDEO_ICON,
    // Compressed
    zip: COMPRESSED_ICON,
    '7z': COMPRESSED_ICON,
    rar: COMPRESSED_ICON,
    // Data
    json: 'json',
    yaml: DATA_ICON,
    sql: DATA_ICON,
    db: DATA_ICON,
    dbf: DATA_ICON,
};
/**
 *
 * @param extension
 */
function getIconForFile(extension) {
    return filetypeIconTable[extension.toLowerCase()] || DEFAULT_ICON;
}

/**
 *
 * @param file
 */
function getFileIcon(file) {
    const name = getIconProps.getIconName(file.icon);
    if (name) {
        return name;
    }
    const extension = getExtension(file);
    if (!extension) {
        return;
    }
    return getIconForFile(extension);
}
/**
 *
 * @param file
 */
function getFileColor(file) {
    const color = getIconProps.getIconColor(file.icon, file.iconColor);
    if (color) {
        return color;
    }
    const extension = getExtension(file);
    if (!extension) {
        return;
    }
    return getIconFillColorForFile(extension);
}
/**
 *
 * @param file
 */
function getFileBackgroundColor(file) {
    const backgroundColor = getIconProps.getIconBackgroundColor(file.icon, file.iconBackgroundColor);
    if (backgroundColor) {
        return backgroundColor;
    }
    const extension = getExtension(file);
    if (!extension) {
        return;
    }
    return getIconBackgroundColorForFile(extension);
}
/**
 *
 * @param file
 */
function getFileExtensionTitle(file) {
    const name = getIconProps.getIconName(file.icon);
    if (name) {
        return name;
    }
    return getExtension(file);
}
/**
 *
 * @param file
 */
function getExtension(file) {
    if (!file) {
        return;
    }
    return file.filename.split('.').pop();
}

exports.getFileBackgroundColor = getFileBackgroundColor;
exports.getFileColor = getFileColor;
exports.getFileExtensionTitle = getFileExtensionTitle;
exports.getFileIcon = getFileIcon;
