'use strict';

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

var _extends = require('@babel/runtime/helpers/extends');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
var React = require('react');
var classNames = require('clsx');

function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }

function _interopNamespaceCompat(e) {
    if (e && typeof e === 'object' && 'default' in e) return e;
    var n = Object.create(null);
    if (e) {
        Object.keys(e).forEach(function (k) {
            if (k !== 'default') {
                var d = Object.getOwnPropertyDescriptor(e, k);
                Object.defineProperty(n, k, d.get ? d : {
                    enumerable: true,
                    get: function () { return e[k]; }
                });
            }
        });
    }
    n.default = e;
    return Object.freeze(n);
}

var _extends__default = /*#__PURE__*/_interopDefaultCompat(_extends);
var _defineProperty__default = /*#__PURE__*/_interopDefaultCompat(_defineProperty);
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultCompat(_objectWithoutProperties);
var React__namespace = /*#__PURE__*/_interopNamespaceCompat(React);
var classNames__default = /*#__PURE__*/_interopDefaultCompat(classNames);

var css = {"root":"Progress__root___Qt61w","root_theme_yellow-500":"Progress__root_theme_yellow-500___Q--6y","root_theme_violet-500":"Progress__root_theme_violet-500___ZJtv2","root_theme_green-700":"Progress__root_theme_green-700___qpHWh"};

var _excluded = ["value", "min", "max", "theme", "style", "className"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty__default.default(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
/**
 * Элемент индикатора выполнения
 */
var Progress = /*#__PURE__*/React__namespace.forwardRef(function (_ref, ref) {
  var _ref$value = _ref.value,
    value = _ref$value === void 0 ? 0 : _ref$value,
    _ref$min = _ref.min,
    min = _ref$min === void 0 ? 0 : _ref$min,
    _ref$max = _ref.max,
    max = _ref$max === void 0 ? 100 : _ref$max,
    _ref$theme = _ref.theme,
    theme = _ref$theme === void 0 ? 'yellow-500' : _ref$theme,
    style = _ref.style,
    className = _ref.className,
    props = _objectWithoutProperties__default.default(_ref, _excluded);
  var progressWidth = 100 - Math.min(Math.max((value - min) / (max - min) * 100, 0), 100);
  return /*#__PURE__*/React__namespace.createElement("div", _extends__default.default({
    ref: ref,
    className: classNames__default.default(css.root, css["root_theme_".concat(theme)], className),
    role: "progressbar",
    "aria-valuenow": value,
    "aria-valuemin": min,
    "aria-valuemax": max,
    "data-testid": "progress",
    "data-qaid": "progress",
    style: _objectSpread(_objectSpread({}, style), {}, {
      '--pds-progress-width': "-".concat(progressWidth, "%")
    })
  }, props));
});
Progress.displayName = 'Progress';

exports.Progress = Progress;

require('./style.development.v2.css');
