"use strict";

exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _startsWith = _interopRequireDefault(require("lodash/fp/startsWith"));
var _includes = _interopRequireDefault(require("lodash/fp/includes"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _style = _interopRequireDefault(require("./style.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const podcastWrapperStyle = {
  default: _style.default.podcastWrapper,
  cockpit: _style.default.podcastWrapperCockpit,
  mobile: _style.default.podcastWrapper
};
const iframeStyle = {
  default: _style.default.iframe,
  cockpit: _style.default.iframeCockpit,
  mobile: _style.default.iframe
};
function ExternalContentViewer(props) {
  const {
    url,
    backgroundImageUrl,
    contentType,
    mode = 'default'
  } = props;
  const isPdf = (0, _includes.default)('.pdf', url);
  const googleViewer = `https://docs.google.com/viewerng/viewer?embedded=true&url=${url}`;
  return (0, _startsWith.default)('audio', contentType) ? /*#__PURE__*/_react.default.createElement("div", {
    className: podcastWrapperStyle[mode]
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.bgPodcast,
    style: {
      backgroundImage: backgroundImageUrl && `url(${backgroundImageUrl})`
    }
  }), /*#__PURE__*/_react.default.createElement("audio", {
    className: _style.default.podcast,
    controls: true,
    controlsList: "nodownload",
    autoPlay: "",
    name: "media",
    "data-name": "external-content-podcast",
    preload: "auto"
  }, /*#__PURE__*/_react.default.createElement("source", {
    src: url,
    type: contentType
  }))) : /*#__PURE__*/_react.default.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.default.string.isRequired,
  backgroundImageUrl: _propTypes.default.string,
  contentType: _propTypes.default.string,
  mode: _propTypes.default.string
} : {};
var _default = exports.default = ExternalContentViewer;
//# sourceMappingURL=index.js.map