import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import JWPlayer from 'react-native-jw-media-player';
import Youtube from 'react-native-youtube';
import { Vimeo } from 'react-native-vimeo-iframe';
import { useTemplateContext } from '../../template/app-review/template-context';
const styleSheet = StyleSheet.create({
  container: {
    flex: 1,
    width: '100%'
  }
});
const VideoSwitch = ({
  media,
  autoplay
}) => {
  const {
    brandTheme
  } = 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.createElement(JWPlayer, {
          style: styleSheet.container,
          config: config
        });
      }
    case 'application/vimeo':
      return media.videoId ? /*#__PURE__*/React.createElement(View, {
        style: styleSheet.container
      }, /*#__PURE__*/React.createElement(Vimeo, {
        videoId: media.videoId
      })) : null;
    case 'application/youtube':
      return /*#__PURE__*/React.createElement(Youtube, {
        apiKey: brandTheme.youtube?.apiKey || '',
        style: styleSheet.container,
        videoId: media.videoId,
        play: autoplay
      });
    default:
      return /*#__PURE__*/React.createElement(Text, null, `video mimeType ${media.mimeType} is not handled`);
  }
};
const Video = ({
  media,
  autoplay
}) => {
  return media ? /*#__PURE__*/React.createElement(VideoSwitch, {
    media: media,
    autoplay: autoplay
  }) : null;
};
export default Video;
//# sourceMappingURL=index.native.js.map