"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ProgressBar = void 0;
var _react = _interopRequireDefault(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
/** Progress indicator. By default, it uses blue progress indicator
 * [CAPITALIZATION] Use sentence case
 * [CAPITALIZATION] Step x/x: sentence case
 * @midnight-gray-supported
 * @alpine-light-supported
 */
const ProgressBar = ({
  max = 1,
  success = false,
  warning = false,
  error = false,
  value,
  className,
  ariaLabel,
  ariaLabelledBy,
  testId = 'progress-bar'
}) => {
  const adoptedValue = value <= max ? value : max;
  const ratio = Math.min(adoptedValue, max) * 100 / max;
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
    className: (0, _classnames.default)('progress', className),
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: (0, _classnames.default)('progress-bar', {
        success,
        warning,
        error
      }),
      "test-id": testId
      /* eslint-disable-next-line react/forbid-dom-props */,
      style: {
        width: `${ratio}%`
      },
      role: "progressbar",
      "aria-valuenow": adoptedValue,
      "aria-valuemin": 0,
      "aria-valuemax": max,
      "aria-label": ariaLabel,
      "aria-labelledby": ariaLabelledBy
    })
  });
};
exports.ProgressBar = ProgressBar;