import { EventType } from '../../types/event.type';

import { FileEventJson, decodeFileEventJson } from './file.event-json';
import {
  MassTextEventJson,
  decodeMassTextEventJson
} from './mass-text.event-json';
import { StickerEventJson, decodeStickerEventJson } from './sticker.event-json';
import { PlanEventJson, decodePlanEventJson } from './plan.event-json';
import {
  VideoConferenceEventJson,
  decodeVideoConferenceEventJson
} from './video-conference.event-json';
import {
  RenameRoomEventJson,
  decodeRenameRoomEventJson
} from './rename-room.event-json';
import {
  TranslationEventJson,
  decodeTranslationEventJson
} from './translation.event-json';
import {
  MassTranslationEventJson,
  decodeMassTranslationEventJson
} from './mass-translation.event-json';
import {
  GuideForRoomTimerChangedEventJson,
  decodeGuideForRoomTimerChangedEventJson
} from './guide-for-room-timer-changed.event-json';
import { JoinEventJson, decodeJoinEventJson } from './join.event-json';
import {
  CharacterEventJson,
  decodeCharacterEventJson
} from './character.event-json';
import { ExitEventJson, decodeExitEventJson } from './exit.event-json';
import { LinkEventJson, decodeLinkEventJson } from './link.event-json';
import {
  RecalledMessageEventJson,
  decodeRecalledMessageEventJson
} from './recalled-message.event-json';
import {
  VideoStreammingEventJson,
  decodeVideoStreammingEventJson
} from './video-streamming.event-json';
import {
  NotificationForTimerRoomEventJson,
  decodeNotificationForTimerRoomEventJson
} from './notification-for-timer-room.event-json';
import { decodeAllimEventJson, AllimEventJson } from './allim.event-json';
import {
  NotificationForIOSCaptureEventJson,
  decodeNotificationForIOSCaptureEventJson
} from './notification-for-ios-capture.event-json';

export type EventJson =
  | string
  | string[]
  | JoinEventJson
  | CharacterEventJson
  | ExitEventJson
  | FileEventJson
  | LinkEventJson
  | MassTextEventJson
  | RecalledMessageEventJson
  | StickerEventJson
  | PlanEventJson
  | VideoConferenceEventJson
  | RenameRoomEventJson
  | NotificationForIOSCaptureEventJson
  | NotificationForTimerRoomEventJson
  | TranslationEventJson
  | MassTranslationEventJson
  | VideoStreammingEventJson
  | GuideForRoomTimerChangedEventJson
  | AllimEventJson;

export const decodeEventJson = (
  eventType: EventType,
  message: string
): EventJson => {
  switch (eventType) {
    case EventType.Join:
      return decodeJoinEventJson(message);
    case EventType.Character:
      return decodeCharacterEventJson(message);
    case EventType.File:
      return decodeFileEventJson(message);
    case EventType.Sticker:
      return decodeStickerEventJson(message);
    case EventType.MassText:
      return decodeMassTextEventJson(message);
    case EventType.Exit:
      return decodeExitEventJson(message);
    case EventType.Plan:
      return decodePlanEventJson(message);
    case EventType.VideoConference:
      return decodeVideoConferenceEventJson(message);
    case EventType.Link:
      return decodeLinkEventJson(message);
    case EventType.RenameRoom:
      return decodeRenameRoomEventJson(message);
    case EventType.Translation:
      return decodeTranslationEventJson(message);
    case EventType.MassTranslation:
      return decodeMassTranslationEventJson(message);
    case EventType.RecalledMessage:
      return decodeRecalledMessageEventJson(message);
    case EventType.GuideForRoomTimerChanged:
      return decodeGuideForRoomTimerChangedEventJson(message);
    case EventType.NotificationForiOSCapture:
      return decodeNotificationForIOSCaptureEventJson(message);
    case EventType.NotificationForTimerRoom:
      return decodeNotificationForTimerRoomEventJson(message);
    case EventType.Before2MonthsAgo:
      return message;
    case EventType.ForcedExit:
      return decodeCharacterEventJson(message);
    case EventType.ChatbotStart:
      return message;
    case EventType.ChatbotEnd:
      return message;
    case EventType.ChatbotSend:
      return message;
    case EventType.ChatbotSendMass:
      return message;
    case EventType.VideoStreamming:
      return decodeVideoStreammingEventJson(message);

    case EventType.AllimElephant:
    case EventType.AllimTms:
      return decodeAllimEventJson(message);
    default:
      return message;
  }
};
