text: "use strict";
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports.Metric = void 0;
  
  var _react = _interopRequireDefault(require("react"));
  
  var _propTypes = _interopRequireDefault(require("prop-types"));
  
  var _classnames = _interopRequireDefault(require("classnames"));
  
  var _metricModule = _interopRequireDefault(require("./metric.module.css"));
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  
  function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  
  // Separate value and unit
  var EXTRACT_VALUE_UNIT_PATTERN = /([\d|.|,| ]*)(\w*|%)$/;
  
  var Metric = function Metric(_ref) {
    var className = _ref.className,
        value = _ref.value,
        formatter = _ref.formatter,
        inline = _ref.inline,
        anchored = _ref.anchored,
        children = _ref.children,
        enhanced = _ref.enhanced;
    var formattedValue = formatter(value); // eslint-disable-next-line no-unused-vars
  
    var _ref2 = enhanced && formattedValue ? formattedValue.match(EXTRACT_VALUE_UNIT_PATTERN) : [null, formattedValue, null],
        _ref3 = _slicedToArray(_ref2, 3),
        matched = _ref3[0],
        displayValue = _ref3[1],
        displayUnit = _ref3[2];
  
    var rootClassName = (0, _classnames["default"])(className, _metricModule["default"].root, inline && _metricModule["default"].inline, anchored && _metricModule["default"].anchored);
    return /*#__PURE__*/_react["default"].createElement("span", {
      className: rootClassName
    }, /*#__PURE__*/_react["default"].createElement("span", {
      className: _metricModule["default"].display
    }, /*#__PURE__*/_react["default"].createElement("span", {
      className: _metricModule["default"].displayValue
    }, displayValue), displayUnit && /*#__PURE__*/_react["default"].createElement("span", {
      className: _metricModule["default"].displayUnit
    }, displayUnit)), /*#__PURE__*/_react["default"].createElement("span", {
      className: _metricModule["default"].delta
    }, children));
  };
  
  exports.Metric = Metric;
  Metric.defaultProps = {
    className: '',
    anchored: false,
    enhanced: false,
    inline: false,
    value: 0,
    children: [],
    formatter: function formatter(val) {
      return val;
    }
  };
  Metric.propTypes = {
    className: _propTypes["default"].string,
    enhanced: _propTypes["default"].bool,
    inline: _propTypes["default"].bool,
    anchored: _propTypes["default"].bool,
    value: _propTypes["default"].oneOfType([_propTypes["default"].number, _propTypes["default"].string]),
    formatter: _propTypes["default"].func,
    children: _propTypes["default"].node
  };