"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Development = void 0;
var _isNil2 = _interopRequireDefault(require("ramda/src/isNil"));
var _react = _interopRequireDefault(require("react"));
var _styledComponents = _interopRequireDefault(require("styled-components"));
var _ = require("../..");
var _Number = require("../../Molecules/Number/Number");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
var getPrefix = function getPrefix(value) {
  if (!value) return '';
  return value > 0 ? '▲' : '▼';
};
var getColor = function getColor(_ref) {
  var value = _ref.value,
    theme = _ref.theme,
    _ref$positiveColor = _ref.positiveColor,
    positiveColor = _ref$positiveColor === void 0 ? function (c) {
      return c.color.positive;
    } : _ref$positiveColor,
    _ref$negativeColor = _ref.negativeColor,
    negativeColor = _ref$negativeColor === void 0 ? function (c) {
      return c.color.negative;
    } : _ref$negativeColor;
  if (!value || !Number.isFinite(value)) return theme.color.text;
  return value > 0 ? positiveColor(theme) : negativeColor(theme);
};
var StyledDevelopment = _styledComponents.default.span.withConfig({
  displayName: "Development__StyledDevelopment",
  componentId: "sc-hnn1ri-0"
})(["color:", ";"], getColor);
var Development = exports.Development = function Development(props) {
  var value = props.value,
    decimals = props.decimals,
    maximumDecimals = props.maximumDecimals,
    minimumDecimals = props.minimumDecimals,
    ticks = props.ticks,
    positiveColor = props.positiveColor,
    negativeColor = props.negativeColor,
    className = props.className,
    _props$icon = props.icon,
    icon = _props$icon === void 0 ? false : _props$icon;
  var roundedValue = !(0, _isNil2.default)(value) ? (0, _Number.getRoundedValue)(value, {
    ticks: ticks,
    decimals: decimals,
    maximumDecimals: maximumDecimals,
    minimumDecimals: minimumDecimals
  }) : value;
  return _react.default.createElement(StyledDevelopment, {
    className: className,
    value: roundedValue,
    positiveColor: positiveColor,
    negativeColor: negativeColor
  }, _react.default.createElement("span", {
    "aria-hidden": true
  }, icon && getPrefix(roundedValue)), _react.default.createElement(_.Number, _extends({
    sign: true
  }, props)));
};
Development.displayName = 'Development';