"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 _classnames = _interopRequireDefault(require("classnames"));
var _novaIcons = require("@coorpacademy/nova-icons");
var _provider = _interopRequireDefault(require("../provider"));
var _style = _interopRequireDefault(require("./style.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const MODES = {
  default: _style.default.defaultStyle,
  small: _style.default.small
};
const BOUNCES = {
  bounce: _style.default.bounce,
  bounceTwice: _style.default.bounceTwice,
  bounceAndPause: _style.default.bounceAndPause
};
const Life = (props, context) => {
  const {
    skin
  } = context;
  const {
    bounce = null,
    heartOnRight = false,
    animated = false,
    count = 3,
    failed = false,
    mode = 'default',
    operator = 'x',
    revival,
    className,
    style: customStyle
  } = props;
  const negativeColor = (0, _get2.default)('common.negative', skin);
  const white = (0, _get2.default)('common.white', skin);
  if (count === null) {
    return null;
  }
  const pickStyle = (successStyle, failedStyle, animatedFailedStyle, revivalStyle) => {
    if (revival) return revivalStyle;
    if (failed && animated) return animatedFailedStyle;
    if (failed) return failedStyle;
    return successStyle;
  };
  const heartWrapper = failed && animated ? _style.default.heartWrapperFailed : _style.default.heartWrapperDefault;
  const bounceClass = bounce ? BOUNCES[bounce.type] : null;
  const heartCustomStyle = {
    animationDelay: bounce && bounce.delay,
    animationDuration: bounce && bounce.duration,
    left: heartOnRight && '70px'
  };
  const countStyle = failed ? _style.default.livesCounterFailed : _style.default.livesCounterDefault;
  return /*#__PURE__*/_react.default.createElement("div", {
    "data-name": "life",
    className: (0, _classnames.default)(MODES[mode], className),
    style: customStyle
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.livesCounterWrapper
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: pickStyle(_style.default.previousLivesCounterDefault, _style.default.previousLivesCounterDefault, _style.default.previousLivesCounterFailed, _style.default.previousLivesRevival)
  }, count + 1), /*#__PURE__*/_react.default.createElement("div", {
    "data-name": "counter",
    className: countStyle
  }, count)), /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.operatorWrapper
  }, /*#__PURE__*/_react.default.createElement("span", {
    className: _style.default.operator
  }, operator)), /*#__PURE__*/_react.default.createElement("div", {
    className: (0, _classnames.default)(heartWrapper, bounceClass),
    style: heartCustomStyle
  }, /*#__PURE__*/_react.default.createElement(_novaIcons.NovaCompositionCoorpacademyVoteHeartOutline, {
    className: _style.default.heartOutline,
    style: {
      color: white
    }
  }), /*#__PURE__*/_react.default.createElement(_novaIcons.NovaSolidVoteRewardsVoteHeart, {
    className: pickStyle(_style.default.heartNormalDefault, _style.default.heartNormalFailed, _style.default.heartNormalAnimatedFailed, _style.default.heartNormalRevival),
    style: {
      color: negativeColor
    }
  }), /*#__PURE__*/_react.default.createElement(_novaIcons.NovaCompositionCoorpacademyBrokenHeart, {
    className: pickStyle(_style.default.heartBrokenDefault, _style.default.heartBrokenFailed, _style.default.heartBrokenAnimatedFailed, _style.default.heartBrokenRevival),
    style: {
      color: negativeColor
    }
  })));
};
Life.contextTypes = {
  skin: _provider.default.childContextTypes.skin
};
Life.propTypes = process.env.NODE_ENV !== "production" ? {
  revival: _propTypes.default.bool,
  animated: _propTypes.default.bool,
  bounce: _propTypes.default.shape({
    type: _propTypes.default.oneOf(['bounce', 'bounceTwice', 'bounceAndPause']),
    delay: _propTypes.default.string
  }),
  heartOnRight: _propTypes.default.bool,
  mode: _propTypes.default.oneOf((0, _keys2.default)(MODES)),
  count: _propTypes.default.number,
  failed: _propTypes.default.bool,
  className: _propTypes.default.string,
  operator: _propTypes.default.string,
  style: _propTypes.default.shape({})
} : {};
var _default = exports.default = Life;
//# sourceMappingURL=index.js.map