"use strict";

exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _reactNative = require("react-native");
var _reactNativeJwMediaPlayer = _interopRequireDefault(require("react-native-jw-media-player"));
var _reactNativeYoutube = _interopRequireDefault(require("react-native-youtube"));
var _reactNativeVimeoIframe = require("react-native-vimeo-iframe");
var _templateContext = require("../../template/app-review/template-context");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const styleSheet = _reactNative.StyleSheet.create({
  container: {
    flex: 1,
    width: '100%'
  }
});
const VideoSwitch = ({
  media,
  autoplay
}) => {
  const {
    brandTheme
  } = (0, _templateContext.useTemplateContext)();
  switch (media.mimeType) {
    case 'application/kontiki':
    case 'application/jwplayer':
    case 'video/mp4':
      {
        if (!media.jwpOptions?.config) {
          return null;
        }
        const config = {
          ...media.jwpOptions.config,
          autostart: autoplay
        };
        return /*#__PURE__*/_react.default.createElement(_reactNativeJwMediaPlayer.default, {
          style: styleSheet.container,
          config: config
        });
      }
    case 'application/vimeo':
      return media.videoId ? /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: styleSheet.container
      }, /*#__PURE__*/_react.default.createElement(_reactNativeVimeoIframe.Vimeo, {
        videoId: media.videoId
      })) : null;
    case 'application/youtube':
      return /*#__PURE__*/_react.default.createElement(_reactNativeYoutube.default, {
        apiKey: brandTheme.youtube?.apiKey || '',
        style: styleSheet.container,
        videoId: media.videoId,
        play: autoplay
      });
    default:
      return /*#__PURE__*/_react.default.createElement(_reactNative.Text, null, `video mimeType ${media.mimeType} is not handled`);
  }
};
const Video = ({
  media,
  autoplay
}) => {
  return media ? /*#__PURE__*/_react.default.createElement(VideoSwitch, {
    media: media,
    autoplay: autoplay
  }) : null;
};
var _default = exports.default = Video;
//# sourceMappingURL=index.native.js.map