import "../../i18n";
import React, { useMemo } from "react";
import TextClassification from "../TextClassification";
import TextEntityRecognition from "../TextEntityRecognition";
import TextEntityRelations from "../TextEntityRelations";
import ImageSegmentation from "../ImageSegmentation";
import ImageClassification from "../ImageClassification";
import VideoSegmentation from "../VideoSegmentation";
import AudioTranscription from "../AudioTranscription";
import ImageLandmarkAnnotation from "../ImageLandmarkAnnotation";
import TimeSeries from "../TimeSeries";
import DataEntry from "../DataEntry";
import EmptySampleContainer from "../EmptySampleContainer";
import Composite from "../Composite";
import BadDataset from "../BadDataset";
import Button from "@material-ui/core/Button";
import { useTranslation } from "react-i18next";
export var UniversalSampleViewer = function UniversalSampleViewer(_ref) {
  var iface = _ref.interface,
      sample = _ref.sample,
      onExit = _ref.onExit,
      loading = _ref.loading,
      onRemoveSample = _ref.onRemoveSample,
      hideHeader = _ref.hideHeader,
      hideDescription = _ref.hideDescription,
      _ref$disableHotkeys = _ref.disableHotkeys,
      disableHotkeys = _ref$disableHotkeys === void 0 ? false : _ref$disableHotkeys,
      title = _ref.title,
      sampleIndex = _ref.sampleIndex,
      onModifySample = _ref.onModifySample,
      height = _ref.height,
      onClickSetup = _ref.onClickSetup;

  // TODO type check w/ superstruct against dataset
  var _useTranslation = useTranslation(),
      t = _useTranslation.t;

  var containerProps = useMemo(function () {
    return {
      hideHeader: hideHeader,
      hideDescription: hideDescription,
      title: title,
      onExit: onExit,
      onRemoveSample: onRemoveSample,
      height: height,
      disableHotkeys: disableHotkeys,
      globalSampleIndex: sampleIndex
    };
  }, [hideHeader, hideDescription, title, height, onExit, disableHotkeys, onRemoveSample, sampleIndex]);

  if (loading) {
    return /*#__PURE__*/React.createElement(BadDataset, {
      title: "Loading Sample...",
      description: ""
    });
  }

  if (!(iface === null || iface === void 0 ? void 0 : iface.type)) {
    return /*#__PURE__*/React.createElement(BadDataset, {
      title: "Set up your project to begin labeling",
      description: /*#__PURE__*/React.createElement("p", null, t("universal-data-viewer-interface-warning"), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement(Button, {
        color: "primary",
        variant: "contained",
        onClick: onClickSetup
      }, t("setup-project")))
    });
  }

  if (!sample) {
    return /*#__PURE__*/React.createElement(EmptySampleContainer, null);
  }

  switch (iface === null || iface === void 0 ? void 0 : iface.type) {
    case "data_entry":
      return /*#__PURE__*/React.createElement(DataEntry, {
        containerProps: containerProps,
        sampleIndex: sampleIndex,
        interface: iface,
        sample: sample,
        onModifySample: onModifySample,
        onExit: onExit
      });

    case "text_classification":
      return /*#__PURE__*/React.createElement(TextClassification, {
        containerProps: containerProps,
        sampleIndex: sampleIndex,
        interface: iface,
        sample: sample,
        onModifySample: onModifySample,
        onExit: onExit
      });

    case "text_entity_recognition":
      return /*#__PURE__*/React.createElement(TextEntityRecognition, {
        containerProps: containerProps,
        sampleIndex: sampleIndex,
        interface: iface,
        sample: sample,
        onModifySample: onModifySample,
        onExit: onExit
      });

    case "text_entity_relations":
      return /*#__PURE__*/React.createElement(TextEntityRelations, {
        containerProps: containerProps,
        sampleIndex: sampleIndex,
        interface: iface,
        sample: sample,
        onModifySample: onModifySample,
        onExit: onExit
      });

    case "image_segmentation":
    case "image_pixel_segmentation":
      return /*#__PURE__*/React.createElement(ImageSegmentation, {
        containerProps: containerProps,
        sampleIndex: sampleIndex,
        interface: iface,
        sample: sample,
        onExit: onExit,
        onModifySample: onModifySample
      });

    case "image_classification":
      return /*#__PURE__*/React.createElement(ImageClassification, {
        containerProps: containerProps,
        sampleIndex: sampleIndex,
        interface: iface,
        sample: sample,
        onExit: onExit,
        onModifySample: onModifySample
      });

    case "video_segmentation":
      return /*#__PURE__*/React.createElement(VideoSegmentation, {
        containerProps: containerProps,
        sampleIndex: sampleIndex,
        interface: iface,
        sample: sample,
        onExit: onExit,
        onModifySample: onModifySample
      });

    case "composite":
      return /*#__PURE__*/React.createElement(Composite, {
        containerProps: containerProps,
        sampleIndex: sampleIndex,
        interface: iface,
        sample: sample,
        onModifySample: onModifySample,
        onExit: onExit
      });

    case "audio_transcription":
      return /*#__PURE__*/React.createElement(AudioTranscription, {
        containerProps: containerProps,
        sampleIndex: sampleIndex,
        interface: iface,
        sample: sample,
        onModifySample: onModifySample,
        onExit: onExit
      });

    case "image_landmark_annotation":
      return /*#__PURE__*/React.createElement(ImageLandmarkAnnotation, {
        containerProps: containerProps,
        sampleIndex: sampleIndex,
        interface: iface,
        sample: sample,
        onModifySample: onModifySample,
        onExit: onExit
      });

    case "time_series":
      return /*#__PURE__*/React.createElement(TimeSeries, {
        containerProps: containerProps,
        sampleIndex: sampleIndex,
        interface: iface,
        sample: sample,
        onModifySample: onModifySample,
        onExit: onExit
      });

    default:
      return "\"".concat(iface === null || iface === void 0 ? void 0 : iface.type, "\" not supported");
  }
};
export default UniversalSampleViewer;