import { ANALYTICS_MEDIA_CHANNEL, sanitiseAnalyticsPayload } from '@atlaskit/media-common/analytics';
const componentName = 'mediaViewer';
const packageName = "@atlaskit/media-viewer";
const packageVersion = "0.0.0-development";
export { packageName, packageVersion, componentName, componentName as component };
export function getFileAttributes(fileState) {
  if (!fileState) {
    return {
      fileId: 'undefined'
    };
  }
  const {
    id: fileId
  } = fileState;
  switch (fileState.status) {
    case 'uploading':
    case 'failed-processing':
    case 'processing':
    case 'processed':
      const {
        mediaType: fileMediatype,
        mimeType: fileMimetype,
        size: fileSize
      } = fileState;
      return {
        fileId,
        fileMediatype,
        fileMimetype,
        fileSize
      };
    case 'error':
      return {
        fileId
      };
  }
}

/** This type takes FailureAttributes and redefines `failReason` to be the strong media-viewer type */

export function fireAnalytics(payload, createAnalyticsEvent) {
  if (createAnalyticsEvent) {
    const ev = createAnalyticsEvent(sanitiseAnalyticsPayload(payload));
    ev.fire(ANALYTICS_MEDIA_CHANNEL);
  }
}