import { FileCardType } from '@material-hu/components/design-system/FileCard/types';

import { Position } from 'src/types/position';

export const mimes = {
  SVG: 'image/svg+xml',
};

export const GIPHY = 'GIPHY';

export type FilesExtensions =
  | 'pdf'
  | 'doc'
  | 'docx'
  | 'xls'
  | 'xlsx'
  | 'ppt'
  | 'pptx';

// for Files module use only FOLDER and FILE.
export enum FileTypes {
  VIDEO = 'VIDEO',
  IMAGE = 'IMAGE',
  FILE = 'FILE',
  AUDIO = 'AUDIO',
  FOLDER = 'FOLDER',
  DOC = 'WORD',
  PPT = 'PPT',
  EXCEL = 'EXCEL',
  PDF = 'PDF',
  GIF = 'GIF',
}

export type AttachmentsSplit = {
  videos: Attachment[];
  images: Attachment[];
  files: Attachment[];
};

export type SortableAttachment = Omit<Attachment, 'id'> & {
  id: number;
  file: File;
};

export type Attachment = {
  id?: number;
  externalReference?: {
    id: string;
    origin: string;
  };
  position?: number | null;
  videoCaptionUrl?: string;
  bytes?: number;
  attachableId?: number;
  attachableType?: string;
  type: FileTypes;
  url?: string;
  height?: number | null;
  width?: number | null;
  size?: string | null;
  name?: string;
  thumbnailUrl?: string;
  lastModified?: number;
};

export type FormFile = Partial<Position> & {
  name: string | null;
  url?: string;
  size: number | null;
  mime: string;
  fileObject: File | null;
  type: string;
  toUpload?: boolean;
  height?: number;
  width?: number;
  metadata?: {
    durationInMs?: number;
  };
};

// Data
export type UpdateAttachmentData = {
  name: string;
  extension: string;
};

export type AddAttachmentData = {
  fileCards: FileCardType[];
};

export type SortAttachmentsData = {
  attachments: SortableAttachment[];
};

// Response
export type SignedUrlResponse = {
  url: string;
};
