function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

/*
Copyright (c) 2018-2019 Uber Technologies, Inc.

This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
import * as React from 'react';
import { getOverrides } from '../helpers/overrides.js';
import { StyledProgressSteps } from './styled-components.js';

function ProgressSteps({
  overrides = {},
  current,
  children
}) {
  const [Root, rootProps] = getOverrides(overrides.Root, StyledProgressSteps);
  const numChildren = React.Children.count(children);
  const modifiedChildren = React.Children.map(children, (child, index) => {
    if (!child) return;
    return React.cloneElement(child, {
      isLast: index === numChildren - 1,
      isCompleted: index < current,
      isActive: index === current,
      step: index + 1,
      overrides: { ...overrides,
        Root: overrides.StepRoot
      }
    });
  });
  return React.createElement(Root, _extends({
    "data-baseweb": "progress-steps"
  }, rootProps), modifiedChildren);
}

ProgressSteps.defaultProps = {
  current: 0
};
export default ProgressSteps;