"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.PercentFormatter = void 0;

var _react = _interopRequireDefault(require("react"));

var _styledComponents = _interopRequireDefault(require("styled-components"));

var _reactIntl = require("react-intl");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _extends() { _extends = Object.assign || 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 StyledWrapper = _styledComponents["default"].span.withConfig({
  displayName: "StyledWrapper",
  componentId: "sc-603mae-0"
})(["span{&:last-child{margin-left:0.1em;}}"]);

var PercentFormatter = function PercentFormatter(props) {
  var value = props.value;

  if (Number.isNaN(parseFloat(value))) {
    return _react["default"].createElement("span", null, "\u2212");
  } // can't use `style="percent"` due to the need to style the percent symbol


  return _react["default"].createElement(StyledWrapper, null, _react["default"].createElement(_reactIntl.FormattedNumber, _extends({
    minimumFractionDigits: 1,
    maximumFractionDigits: 1 // eslint-disable-next-line react/style-prop-object
    ,
    style: "decimal"
  }, props, {
    value: value * 100 // decimal to percent

  })), _react["default"].createElement("span", null, "%"));
};

exports.PercentFormatter = PercentFormatter;
PercentFormatter.displayName = 'PercentFormatter';