'use strict';

var React = require('react');
var classnames = require('classnames');

var styles = {"ProgressBar":"p9AgTzIbTwY-","SteppedProgressBar":"w8NAw4ZMB6g-","wrapper":"d4oS-DGtcKA-","spinning":"f58JiDXlkHA-"};

var sizes = {"smaller":"dylWWgubHwM-","small":"z92YJQrscvI-","base":"DKfNM1to61A-","spinning":"GHfs7cB4nQQ-"};

function ProgressBarStepped({ currentStep, totalSteps, percentage, size = "base", }) {
    const steppedProgressBarClassName = classnames(styles.ProgressBar, styles.SteppedProgressBar, sizes[size]);
    const ariaLabel = `progress, ${currentStep} out of ${totalSteps}`;
    return (React.createElement("div", { role: "progressbar", className: styles.wrapper, "aria-valuenow": percentage, "aria-valuetext": ariaLabel }, Array.from({ length: totalSteps }).map((_, index) => {
        const step = index + 1;
        const value = step <= currentStep ? 100 : 0;
        return (React.createElement("progress", { key: step, className: steppedProgressBarClassName, value: value, "data-testid": "progress-step" },
            value,
            "%"));
    })));
}

function ProgressBar({ currentStep, totalSteps, size = "base", variation = "progress", }) {
    const percentage = (currentStep / totalSteps) * 100;
    const progressBarClassName = classnames(styles.ProgressBar, sizes[size]);
    if (variation === "stepped") {
        return (React.createElement(ProgressBarStepped, { currentStep: currentStep, totalSteps: totalSteps, percentage: percentage, size: size }));
    }
    return (React.createElement("progress", { className: progressBarClassName, max: totalSteps, value: currentStep },
        percentage,
        "%"));
}

exports.ProgressBar = ProgressBar;
