"use strict";

exports.__esModule = true;
exports.default = void 0;
var _keys2 = _interopRequireDefault(require("lodash/fp/keys"));
var _get2 = _interopRequireDefault(require("lodash/fp/get"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _novaIcons = require("@coorpacademy/nova-icons");
var _classnames = _interopRequireDefault(require("classnames"));
var _provider = _interopRequireDefault(require("../provider"));
var _style = _interopRequireDefault(require("./style.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const TYPES = {
  pdf: {
    style: _style.default.pdf,
    icon: _novaIcons.NovaLineFilesOfficeFileOfficePdf
  },
  audio: {
    style: _style.default.audio,
    icon: _novaIcons.NovaCompositionCoorpacademyMicrophone
  },
  video: {
    style: _style.default.video,
    icon: _novaIcons.NovaSolidAudioAudioControlPlay
  }
};
const ResourceMiniature = (props, context) => {
  const {
    skin
  } = context;
  const {
    type,
    description,
    poster,
    onClick: handleOnClick,
    selected = false
  } = props;
  const descriptionClassName = selected ? _style.default.selectedDescription : _style.default.description;
  const white = (0, _get2.default)('common.white', skin);
  const primary = (0, _get2.default)('common.primary', skin);
  const posterOutlineColor = selected ? primary : white;
  const Icon = TYPES[type].icon;
  return /*#__PURE__*/_react.default.createElement("div", {
    className: TYPES[type].style,
    onClick: handleOnClick,
    "data-type": type
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.posterWrapper,
    style: {
      borderColor: posterOutlineColor
    }
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.poster,
    style: {
      backgroundImage: `url(${poster})`
    }
  }), !selected ? /*#__PURE__*/_react.default.createElement(Icon, {
    style: {
      color: white
    },
    className: _style.default.icon
  }) : null), /*#__PURE__*/_react.default.createElement("div", {
    className: (0, _classnames.default)(descriptionClassName, _style.default.innerHTML)
    // eslint-disable-next-line react/no-danger
    ,
    dangerouslySetInnerHTML: {
      __html: description
    }
  }));
};
ResourceMiniature.propTypes = process.env.NODE_ENV !== "production" ? {
  type: _propTypes.default.oneOf((0, _keys2.default)(TYPES)),
  selected: _propTypes.default.bool,
  description: _propTypes.default.string,
  poster: _propTypes.default.string,
  onClick: _propTypes.default.func
} : {};
ResourceMiniature.contextTypes = {
  skin: _provider.default.childContextTypes.skin
};
var _default = exports.default = ResourceMiniature;
//# sourceMappingURL=index.js.map