"use strict";

exports.__esModule = true;
exports["default"] = void 0;
var _react = _interopRequireWildcard(require("react"));
var _box = _interopRequireDefault(require("../templates/box"));
var _flex = _interopRequireDefault(require("../templates/flex"));
var _excluded = ["background", "className", "color", "containerWidth", "height", "value", "width"];
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
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 && {}.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; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
var ProgressBar = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
  var _ref$background = _ref.background,
    background = _ref$background === void 0 ? "nodeBadgeBackground" : _ref$background,
    className = _ref.className,
    _ref$color = _ref.color,
    color = _ref$color === void 0 ? "text" : _ref$color,
    _ref$containerWidth = _ref.containerWidth,
    containerWidth = _ref$containerWidth === void 0 ? "100%" : _ref$containerWidth,
    _ref$height = _ref.height,
    height = _ref$height === void 0 ? 2 : _ref$height,
    value = _ref.value,
    width = _ref.width,
    rest = _objectWithoutPropertiesLoose(_ref, _excluded);
  value = Array.isArray(value) ? value : [value || {
    width: width,
    color: color
  }];
  return /*#__PURE__*/_react["default"].createElement(_flex["default"], _extends({
    background: background,
    border: {
      side: "all",
      color: background
    },
    className: className,
    "data-testid": "progressBar",
    height: height,
    ref: ref,
    round: "2px",
    width: containerWidth
  }, rest), value.map(function (_ref2, index, arr) {
    var color = _ref2.color,
      width = _ref2.width;
    return width === "0%" ? null : /*#__PURE__*/_react["default"].createElement(_box["default"], {
      background: color,
      border: {
        side: "all",
        color: color
      },
      "data-testid": "progressBar-progress" + width,
      height: "100%",
      key: width + "-" + index,
      position: "relative",
      round: !index ? "2px 0 0 2px" : arr.length - 1 === index ? "0 2px 2px 0" : "0",
      width: width,
      zIndex: index
    });
  }));
});
var _default = exports["default"] = ProgressBar;