"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
var _constants = require("../../../constants");
var extractFileFormatIcon = function extractFileFormatIcon(fileFormat) {
  var getIconDescriptor = function getIconDescriptor(icon, label) {
    return (0, _platformFeatureFlags.fg)('platform_navx_smart_link_icon_label_a11y') ? {
      icon: icon,
      label: label
    } : {
      icon: icon
    };
  };
  switch (fileFormat) {
    // Generic documents
    case 'folder':
      return getIconDescriptor(_constants.IconType.Folder, 'folder');
    case 'text/plain':
    case 'application/vnd.oasis.opendocument.text':
    case 'application/vnd.apple.pages':
      return getIconDescriptor(_constants.IconType.Document, 'document');
    case 'application/pdf':
      return getIconDescriptor(_constants.IconType.PDF, 'pdf');
    case 'application/vnd.oasis.opendocument.presentation':
    case 'application/vnd.apple.keynote':
      return getIconDescriptor(_constants.IconType.Presentation, 'presentation');
    case 'application/vnd.oasis.opendocument.spreadsheet':
    case 'application/vnd.apple.numbers':
      return getIconDescriptor(_constants.IconType.Spreadsheet, 'spreadsheet');
    // Google Drive
    case 'application/vnd.google-apps.document':
      return getIconDescriptor(_constants.IconType.GoogleDocs, 'google document');
    case 'application/vnd.google-apps.form':
      return getIconDescriptor(_constants.IconType.GoogleForms, 'google form');
    case 'application/vnd.google-apps.spreadsheet':
      return getIconDescriptor(_constants.IconType.GoogleSheets, 'google sheet');
    case 'application/vnd.google-apps.presentation':
      return getIconDescriptor(_constants.IconType.GoogleSlides, 'google slide');
    // Microsoft
    case 'application/vnd.ms-excel':
    case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
      return getIconDescriptor(_constants.IconType.MSExcel, 'excel spreadsheet');
    case 'application/vnd.ms-powerpoint':
    case 'application/vnd.openxmlformats-officedocument.presentationml.presentation':
      return getIconDescriptor(_constants.IconType.MSPowerpoint, 'powerpoint');
    case 'application/msword':
    case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
      return getIconDescriptor(_constants.IconType.MSWord, 'word document');
    case 'image/png':
    case 'image/jpeg':
    case 'image/bmp':
    case 'image/webp':
    case 'image/svg+xml':
      return getIconDescriptor(_constants.IconType.Image, 'image');
    case 'image/gif':
      return getIconDescriptor(_constants.IconType.GIF, 'gif');
    case 'audio/midi':
    case 'audio/mpeg':
    case 'audio/webm':
    case 'audio/ogg':
    case 'audio/wav':
      return getIconDescriptor(_constants.IconType.Audio, 'audio');
    case 'video/mp4':
    case 'video/quicktime':
    case 'video/mov':
    case 'video/webm':
    case 'video/ogg':
    case 'video/x-ms-wmv':
    case 'video/x-msvideo':
      return getIconDescriptor(_constants.IconType.Video, 'video');
    // Others
    case 'text/css':
    case 'text/html':
    case 'application/javascript':
      return getIconDescriptor(_constants.IconType.Code, 'code');
    case 'application/zip':
    case 'application/x-tar':
    case 'application/x-gtar':
    case 'application/x-7z-compressed':
    case 'application/x-apple-diskimage':
    case 'application/vnd.rar':
      return getIconDescriptor(_constants.IconType.Archive, 'archive');
    case 'application/dmg':
      return getIconDescriptor(_constants.IconType.Executable, 'disk image');
    case 'application/sketch':
      return getIconDescriptor(_constants.IconType.Sketch, 'sketch');
    case 'application/octet-stream':
      return getIconDescriptor(_constants.IconType.Generic, 'file');
    case 'application/invision.prototype':
      return getIconDescriptor(_constants.IconType.Generic, 'file');
    default:
      return undefined;
  }
};
var _default = exports.default = extractFileFormatIcon;