'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
var React = require('react');
var Progress_styles = require('./Progress.styles.js');
var base = require('./variations/_view/base.js');
var base$1 = require('./variations/_size/base.js');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var React__default = /*#__PURE__*/_interopDefault(React);

var _excluded = ["view", "status", "value", "displayValue"];
var progressRoot = function progressRoot(Root) {
  return /*#__PURE__*/React.forwardRef(function (_ref, ref) {
    var view = _ref.view,
      status = _ref.status,
      value = _ref.value,
      _ref$displayValue = _ref.displayValue,
      displayValue = _ref$displayValue === void 0 ? true : _ref$displayValue,
      rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
    var min = 0;
    var max = 100;
    var normalizedValue = Math.max(Math.min(value, max), min);
    return /*#__PURE__*/React__default.default.createElement(Root, _rollupPluginBabelHelpers.extends({
      ref: ref,
      view: status || view,
      value: normalizedValue
    }, rest), /*#__PURE__*/React__default.default.createElement(Progress_styles.StyledTrack, null, /*#__PURE__*/React__default.default.createElement(Progress_styles.StyledProgress, {
      value: normalizedValue
    })), displayValue && /*#__PURE__*/React__default.default.createElement(Progress_styles.StyledValue, null, normalizedValue, "%"));
  });
};
var progressConfig = {
  name: 'Progress',
  tag: 'div',
  layout: progressRoot,
  base: Progress_styles.base,
  variations: {
    view: {
      css: base.base
    },
    size: {
      css: base$1.base
    }
  },
  defaults: {
    view: 'default',
    size: 'm'
  }
};

exports.progressConfig = progressConfig;
exports.progressRoot = progressRoot;
//# sourceMappingURL=Progress.js.map
