import React from "react";
import ProgressButtonItem from "./ProgressButtonItem";
const ProgressButtons = (props) => {
    const isStepCompleted = (stepId) => {
        // if the step is on or before the completed step, return true
        return Boolean(props.completedStepId &&
            props.progressButtonItems.findIndex((progressButtonItem) => {
                return progressButtonItem.id === stepId;
            }) <=
                props.progressButtonItems.findIndex((progressButtonItem) => {
                    return progressButtonItem.id === props.completedStepId;
                }));
    };
    const isCurrentStep = (stepId) => {
        // if this is one step ahead of the completed step, return true
        return Boolean(props.completedStepId &&
            props.progressButtonItems.findIndex((progressButtonItem) => {
                return progressButtonItem.id === stepId;
            }) ===
                props.progressButtonItems.findIndex((progressButtonItem) => {
                    return progressButtonItem.id === props.completedStepId;
                }) +
                    1);
    };
    return (React.createElement("nav", { "aria-label": "Progress", id: props.id, className: "ml-3" },
        React.createElement("ol", { role: "list", className: "bg-white shadow divide-y divide-gray-300 rounded-md md:flex md:divide-y-0" }, props.progressButtonItems.map((progressButtonItem, index) => {
            return (React.createElement(ProgressButtonItem, Object.assign({ key: progressButtonItem.id }, progressButtonItem, { stepCount: index + 1, isLastStep: progressButtonItem.id ===
                    props.progressButtonItems[props.progressButtonItems.length - 1].id, isCurrentStep: isCurrentStep(progressButtonItem.id), isCompletedStep: isStepCompleted(progressButtonItem.id), onClick: () => {
                    return props.onStepClick
                        ? props.onStepClick(progressButtonItem.id)
                        : undefined;
                } })));
        }))));
};
export default ProgressButtons;
//# sourceMappingURL=ProgressButtons.js.map