import React from 'react';
import startsWith from 'lodash/fp/startsWith';
import includes from 'lodash/fp/includes';
import PropTypes from 'prop-types';
import style from './style.css';
const podcastWrapperStyle = {
  default: style.podcastWrapper,
  cockpit: style.podcastWrapperCockpit,
  mobile: style.podcastWrapper
};
const iframeStyle = {
  default: style.iframe,
  cockpit: style.iframeCockpit,
  mobile: style.iframe
};
function ExternalContentViewer(props) {
  const {
    url,
    backgroundImageUrl,
    contentType,
    mode = 'default'
  } = props;
  const isPdf = includes('.pdf', url);
  const googleViewer = `https://docs.google.com/viewerng/viewer?embedded=true&url=${url}`;
  return startsWith('audio', contentType) ? /*#__PURE__*/React.createElement("div", {
    className: podcastWrapperStyle[mode]
  }, /*#__PURE__*/React.createElement("div", {
    className: style.bgPodcast,
    style: {
      backgroundImage: backgroundImageUrl && `url(${backgroundImageUrl})`
    }
  }), /*#__PURE__*/React.createElement("audio", {
    className: style.podcast,
    controls: true,
    controlsList: "nodownload",
    autoPlay: "",
    name: "media",
    "data-name": "external-content-podcast",
    preload: "auto"
  }, /*#__PURE__*/React.createElement("source", {
    src: url,
    type: contentType
  }))) : /*#__PURE__*/React.createElement("iframe", {
    src: isPdf && mode === 'mobile' ? googleViewer : url,
    frameBorder: 0,
    className: iframeStyle[mode],
    allowFullScreen: true,
    "data-name": "external-content-iframe"
  });
}
ExternalContentViewer.propTypes = process.env.NODE_ENV !== "production" ? {
  url: PropTypes.string.isRequired,
  backgroundImageUrl: PropTypes.string,
  contentType: PropTypes.string,
  mode: PropTypes.string
} : {};
export default ExternalContentViewer;
//# sourceMappingURL=index.js.map