"use strict";

exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _externalContent = require("../../util/external-content");
var _style = _interopRequireDefault(require("./style.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
const FALLBACK_PATH = 'https://s3.eu-west-1.amazonaws.com/static.coorpacademy.com/assets/images/cover-fallback-external-$TYPE.png';
const PlaylistDetailCover = ({
  images
}) => {
  const [firstColumnImages, secondColumnImages] = (0, _react.useMemo)(() => {
    const imagesClone = [...images];
    return [imagesClone.splice(0, imagesClone.length / 2), imagesClone];
  }, [images]);
  const buildImageStyle = (0, _react.useCallback)(({
    type,
    image
  }) => {
    const imageUrl = image || FALLBACK_PATH.replace('$TYPE', type);
    return {
      backgroundImage: `url(${imageUrl})`,
      backgroundSize: 'cover',
      backgroundPosition: 'center'
    };
  }, []);
  return /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.container
  }, images.length === 1 ? /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.image,
    style: buildImageStyle(images[0])
  }) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.imagesWrapper
  }, firstColumnImages.map((image, index) => /*#__PURE__*/_react.default.createElement("div", {
    key: index,
    className: _style.default.image,
    style: buildImageStyle(image)
  }))), /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.imagesWrapper
  }, secondColumnImages.map((image, index) => /*#__PURE__*/_react.default.createElement("div", {
    key: index,
    className: _style.default.image,
    style: buildImageStyle(image)
  })))));
};
PlaylistDetailCover.propTypes = process.env.NODE_ENV !== "production" ? {
  images: _propTypes.default.arrayOf(_propTypes.default.shape({
    type: _propTypes.default.oneOf(_externalContent.EXTERNAL_COURSE_TYPES),
    image: _propTypes.default.string
  })).isRequired
} : {};
var _default = exports.default = PlaylistDetailCover;
//# sourceMappingURL=index.js.map