"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ProgressBar = void 0;
var _react = _interopRequireWildcard(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _Styles = require("./Styles");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
var ProgressBar = exports.ProgressBar = function ProgressBar(_ref) {
  var _ref$progress = _ref.progress,
    progress = _ref$progress === void 0 ? 0 : _ref$progress,
    backgroundColor = _ref.backgroundColor,
    progressColor = _ref.progressColor,
    _ref$stroke = _ref.stroke,
    stroke = _ref$stroke === void 0 ? 3 : _ref$stroke,
    _ref$width = _ref.width,
    width = _ref$width === void 0 ? 100 : _ref$width,
    className = _ref.className;
  var progressNumber = (0, _react.useMemo)(function () {
    var width = progress;
    if (progress > 100) {
      width = 100;
    }
    if (progress < 0) {
      width = 0;
    }
    return width;
  }, [progress]);
  var widthPercent = (0, _react.useMemo)(function () {
    var width_percent = width;
    if (width > 100) {
      width_percent = 100;
    }
    if (width <= 0) {
      width_percent = 100;
    }
    return width_percent;
  }, [width]);
  var height = (0, _react.useMemo)(function () {
    var stroke_min = stroke;
    if (stroke <= 0) {
      stroke_min = 3;
    }
    return stroke_min;
  }, [stroke]);
  return /*#__PURE__*/_react.default.createElement(_Styles.StyledProgressBar, {
    className: (0, _classnames.default)("c-progress-bar", className),
    $color: backgroundColor,
    $width: widthPercent
  }, /*#__PURE__*/_react.default.createElement(_Styles.StyledProgressBarProgress, {
    className: "c-progress-bar__progress",
    style: {
      width: "".concat(progressNumber, "%")
    },
    $height: height,
    $color: progressColor
  }));
};
ProgressBar.displayName = "ProgressBar";
//# sourceMappingURL=ProgressBar.js.map