"use strict";

exports.__esModule = true;
exports.default = void 0;
var _uniqueId2 = _interopRequireDefault(require("lodash/fp/uniqueId"));
var _map2 = _interopRequireDefault(require("lodash/fp/map"));
var _isEmpty2 = _interopRequireDefault(require("lodash/fp/isEmpty"));
var _getOr2 = _interopRequireDefault(require("lodash/fp/getOr"));
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 _socialLink = _interopRequireDefault(require("../../atom/social-link"));
var _provider = _interopRequireDefault(require("../../atom/provider"));
var _catalogSection = _interopRequireDefault(require("../../atom/catalog-section"));
var _picture = _interopRequireDefault(require("../../atom/picture"));
var _style = _interopRequireDefault(require("./style.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const DisciplinePartners = (props, context) => {
  const {
    translate,
    skin
  } = context;
  const {
    authorTitle,
    authors = []
  } = props;
  const authorLabel = authorTitle || translate('author');
  const defaultColor = (0, _get2.default)('common.primary', skin);
  const authorsView = _map2.default.convert({
    cap: false
  })((author, index) => {
    const socialLinks = (0, _getOr2.default)([], 'socialLinks', author);
    const authorLogo = (0, _get2.default)('logo', author);
    const authorHref = (0, _get2.default)('href', author);
    const moreDetails = (0, _get2.default)('more', author);
    const autName = (0, _get2.default)('name', author);
    const authorToggleId = (0, _uniqueId2.default)('author-toggle-');
    const linkView = /*#__PURE__*/_react.default.createElement("div", {
      className: _style.default.authorLink
    }, /*#__PURE__*/_react.default.createElement("a", {
      target: "_blank",
      rel: "noopener noreferrer",
      style: {
        color: defaultColor
      },
      href: authorHref
    }, authorHref));
    const moreInfoView = /*#__PURE__*/_react.default.createElement("div", {
      className: _style.default.authorLink
    }, /*#__PURE__*/_react.default.createElement("a", {
      href: authorHref,
      style: {
        color: defaultColor
      }
    }, moreDetails, /*#__PURE__*/_react.default.createElement(_novaIcons.NovaCompositionNavigationArrowRight, {
      style: {
        color: defaultColor
      },
      className: _style.default.linkicon
    })));
    const socialView = socialLinks.map((social, i) => /*#__PURE__*/_react.default.createElement("div", {
      key: i,
      className: _style.default.link
    }, /*#__PURE__*/_react.default.createElement(_socialLink.default, social)));
    const aNameView = autName ? /*#__PURE__*/_react.default.createElement("div", {
      "data-name": "authorName",
      className: _style.default.authorName
    }, autName) : null;
    const logoView = authorLogo ? /*#__PURE__*/_react.default.createElement("div", {
      className: _style.default.logoContainer
    }, /*#__PURE__*/_react.default.createElement(_picture.default, {
      className: _style.default.logo,
      src: authorLogo.src,
      alt: authorLogo.alt
    }), /*#__PURE__*/_react.default.createElement("div", {
      className: _style.default.arrowWrapper
    }, /*#__PURE__*/_react.default.createElement(_novaIcons.NovaCompositionNavigationArrowDown, {
      className: _style.default.arrow,
      height: 14,
      whidth: 14
    }))) : null;
    const authorContent = authorHref || aNameView || socialView ? /*#__PURE__*/_react.default.createElement("div", {
      className: _style.default.authorContent
    }, autName ? aNameView : null, moreDetails ? moreInfoView : null, !moreDetails && authorHref ? linkView : null, /*#__PURE__*/_react.default.createElement("div", {
      className: _style.default.links
    }, socialView)) : null;
    return /*#__PURE__*/_react.default.createElement("div", {
      key: index,
      className: _style.default.authorWrapper
    }, /*#__PURE__*/_react.default.createElement("input", {
      type: "checkbox",
      id: authorToggleId,
      className: _style.default.toggle,
      defaultChecked: true
    }), /*#__PURE__*/_react.default.createElement("label", {
      htmlFor: authorToggleId
    }, logoView), authorContent);
  }, authors);
  return !(0, _isEmpty2.default)(authors) ? /*#__PURE__*/_react.default.createElement("div", {
    "data-name": "disciplinePartner",
    className: _style.default.colDetails
  }, /*#__PURE__*/_react.default.createElement(_catalogSection.default, {
    title: authorLabel
  }, authorsView)) : null;
};
DisciplinePartners.contextTypes = {
  translate: _provider.default.childContextTypes.translate,
  skin: _provider.default.childContextTypes.skin
};
DisciplinePartners.propTypes = process.env.NODE_ENV !== "production" ? {
  authors: _propTypes.default.arrayOf(_propTypes.default.shape({
    name: _propTypes.default.string,
    href: _propTypes.default.string,
    logo: _propTypes.default.shape({
      src: _propTypes.default.string,
      href: _propTypes.default.string,
      alt: _propTypes.default.string
    }),
    socialLinks: _propTypes.default.arrayOf(_propTypes.default.shape(_socialLink.default.propTypes))
  })),
  authorTitle: _propTypes.default.string
} : {};
var _default = exports.default = DisciplinePartners;
//# sourceMappingURL=index.js.map