"use strict";

exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _isEmpty = _interopRequireDefault(require("lodash/fp/isEmpty"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _disciplineCta = _interopRequireDefault(require("../../../molecule/discipline-cta"));
var _disciplineHeader = _interopRequireDefault(require("../../../molecule/discipline-header"));
var _disciplinePartners = _interopRequireDefault(require("../../../molecule/discipline-partners"));
var _disciplineScope = _interopRequireDefault(require("../../../molecule/discipline-scope"));
var _disciplineAssociatedSkills = _interopRequireDefault(require("../../../molecule/discipline-associated-skills"));
var _share = _interopRequireWildcard(require("../../../molecule/share"));
var _addToMyList = _interopRequireWildcard(require("../../../molecule/add-to-my-list"));
var _scopeContent = _interopRequireDefault(require("../../../molecule/scope-content"));
var _style = _interopRequireDefault(require("./style.css"));
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; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const Discipline = (props, context) => {
  const {
    selected = 0,
    level,
    levels,
    changeLevel,
    image,
    title = '',
    video,
    authors = [],
    description = '',
    content = null,
    start,
    buy,
    startLabel,
    skills = [],
    onSkillClick,
    buyLabel,
    shareWording,
    shareText,
    shareSuccessWording,
    shareErrorWording,
    addToMyListButton,
    favorite,
    onFavoriteClick,
    addToMyListText,
    removeFromMyListText,
    disableShare = false,
    disableAddToMyList = false,
    lastUpdated
  } = props;
  const authorSection = (0, _isEmpty.default)(authors) ? null : /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.partners
  }, /*#__PURE__*/_react.default.createElement(_disciplinePartners.default, {
    authors: authors
  }));
  const disciplineCTA = /*#__PURE__*/_react.default.createElement(_disciplineCta.default, {
    type: 'discipline',
    start: start,
    buy: buy,
    startLabel: startLabel,
    buyLabel: buyLabel
  });
  const disciplineContent = content || !(0, _isEmpty.default)(levels) ? /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.content
  }, content ? /*#__PURE__*/_react.default.createElement(_scopeContent.default, {
    content: content
  }) : null, !(0, _isEmpty.default)(levels) ? /*#__PURE__*/_react.default.createElement(_disciplineScope.default, {
    content: level,
    levels: levels,
    selected: selected,
    onClick: changeLevel
  }) : null) : null;
  const disciplineHeader = /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.header
  }, /*#__PURE__*/_react.default.createElement(_disciplineHeader.default, {
    image: image,
    video: video,
    title: title,
    description: description,
    lastUpdated: lastUpdated
  }));
  const discipline = /*#__PURE__*/_react.default.createElement("div", {
    "data-name": "discipline",
    className: _style.default.container,
    key: "discipline"
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.leftSection
  }, disciplineHeader, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.mobileAuthorCtaSection
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.columnReverse
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.cta
  }, disciplineCTA), disableAddToMyList ? null : /*#__PURE__*/_react.default.createElement(_addToMyList.default, {
    style: _style.default.addToMyListBtn,
    addToMyListButton: addToMyListButton,
    favorite: favorite,
    onFavoriteClick: onFavoriteClick,
    key: 'addToMyListTablet'
  }), disableShare ? null : /*#__PURE__*/_react.default.createElement(_share.default, {
    style: _style.default.shareBtn,
    wording: shareWording,
    text: shareText,
    key: 'shareTablet'
  })), /*#__PURE__*/_react.default.createElement(_disciplineAssociatedSkills.default, {
    skills: skills,
    onSkillClick: onSkillClick
  }), authorSection), disciplineContent), /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.rightSection
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.stickySection
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.cta
  }, disciplineCTA, disableShare && disableAddToMyList ? null : /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.buttons
  }, disableShare ? null : /*#__PURE__*/_react.default.createElement(_share.default, {
    style: _style.default.shareBtn,
    wording: shareWording,
    text: shareText,
    key: 'shareDesktop'
  }), disableAddToMyList ? null : /*#__PURE__*/_react.default.createElement(_addToMyList.default, {
    style: _style.default.addToMyListBtn,
    addToMyListButton: addToMyListButton,
    favorite: favorite,
    onFavoriteClick: onFavoriteClick,
    key: 'addToMyListDesktop'
  }))), /*#__PURE__*/_react.default.createElement(_disciplineAssociatedSkills.default, {
    skills: skills,
    onSkillClick: onSkillClick
  }), authorSection)));
  const shareFeedBack = disableShare ? null : /*#__PURE__*/_react.default.createElement(_share.ShareFeedback, {
    errorWording: shareErrorWording,
    successWording: shareSuccessWording,
    key: "shareFeedBack"
  });
  const addToMyListFeedback = disableAddToMyList ? null : /*#__PURE__*/_react.default.createElement(_addToMyList.AddToMyListFeedback, {
    addToMyListText: addToMyListText,
    removeFromMyListText: removeFromMyListText,
    favorite: favorite
  });
  const addToMyListProviderWrap = disableAddToMyList ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, shareFeedBack, discipline) : /*#__PURE__*/_react.default.createElement(_addToMyList.AddToMyListStatusProvider, null, shareFeedBack, addToMyListFeedback, discipline);
  const shareProviderWrap = disableShare ? addToMyListProviderWrap : /*#__PURE__*/_react.default.createElement(_share.ShareStatusProvider, null, addToMyListProviderWrap);
  return shareProviderWrap;
};
Discipline.propTypes = process.env.NODE_ENV !== "production" ? {
  image: _disciplineHeader.default.propTypes.image,
  video: _disciplineHeader.default.propTypes.video,
  title: _disciplineHeader.default.propTypes.title,
  description: _disciplineHeader.default.propTypes.description,
  start: _disciplineCta.default.propTypes.start,
  buy: _disciplineCta.default.propTypes.buy,
  startLabel: _disciplineCta.default.propTypes.startLabel,
  buyLabel: _disciplineCta.default.propTypes.buyLabel,
  authors: _disciplinePartners.default.propTypes.authors,
  level: _disciplineScope.default.propTypes.content,
  levels: _disciplineScope.default.propTypes.levels,
  selected: _disciplineScope.default.propTypes.selected,
  changeLevel: _disciplineScope.default.propTypes.onClick,
  content: _scopeContent.default.propTypes.content,
  shareWording: _share.default.propTypes.wording,
  shareText: _share.default.propTypes.text,
  shareSuccessWording: _share.ShareFeedback.propTypes.successWording,
  shareErrorWording: _share.ShareFeedback.propTypes.errorWording,
  skills: _propTypes.default.arrayOf(_propTypes.default.shape({
    ref: _propTypes.default.string,
    locale: _propTypes.default.string,
    focused: _propTypes.default.bool
  })),
  onSkillClick: _propTypes.default.func,
  addToMyListText: _addToMyList.AddToMyListFeedback.propTypes.addToMyListText,
  removeFromMyListText: _addToMyList.AddToMyListFeedback.propTypes.removeFromMyListText,
  addToMyListButton: _addToMyList.default.propTypes.addToMyListButton,
  onFavoriteClick: _addToMyList.default.propTypes.onFavoriteClick,
  favorite: _addToMyList.default.propTypes.favorite,
  disableShare: _propTypes.default.bool,
  disableAddToMyList: _propTypes.default.bool
} : {};
Discipline.contextTypes = {
  translate: _propTypes.default.func
};
var _default = exports.default = Discipline;
//# sourceMappingURL=index.js.map