import _isNil from "ramda/src/isNil";
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); }
import React from 'react';
import styled from 'styled-components';
import { Number as NumberComponent } from '../..';
import { getRoundedValue } from '../../Molecules/Number/Number';
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 = styled.span.withConfig({
  displayName: "Development__StyledDevelopment",
  componentId: "sc-hnn1ri-0"
})(["color:", ";"], getColor);
var 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 = !_isNil(value) ? getRoundedValue(value, {
    ticks: ticks,
    decimals: decimals,
    maximumDecimals: maximumDecimals,
    minimumDecimals: minimumDecimals
  }) : value;
  return React.createElement(StyledDevelopment, {
    className: className,
    value: roundedValue,
    positiveColor: positiveColor,
    negativeColor: negativeColor
  }, React.createElement("span", {
    "aria-hidden": true
  }, icon && getPrefix(roundedValue)), React.createElement(NumberComponent, _extends({
    sign: true
  }, props)));
};
export { Development };
Development.displayName = 'Development';