import _extends from "@babel/runtime/helpers/extends";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _inherits from "@babel/runtime/helpers/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import theme from './theme.css';
import Box from '../box';
import ProgressStep from './ProgressStep';
/** @type {React.ComponentType<any>} */

var ProgressTracker = /*#__PURE__*/function (_PureComponent) {
  _inherits(ProgressTracker, _PureComponent);

  var _super = _createSuper(ProgressTracker);

  function ProgressTracker() {
    _classCallCheck(this, ProgressTracker);

    return _super.apply(this, arguments);
  }

  _createClass(ProgressTracker, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
          color = _this$props.color,
          children = _this$props.children,
          currentStep = _this$props.currentStep,
          done = _this$props.done,
          labelPosition = _this$props.labelPosition;
      var classNames = cx(theme['tracker'], theme[color], theme["tracker-".concat(labelPosition)]);
      return /*#__PURE__*/React.createElement(Box, {
        className: classNames
      }, React.Children.map(children, function (child, index) {
        var activeStep = Math.max(0, currentStep);
        return /*#__PURE__*/React.createElement(ProgressStep, _extends({}, child.props, {
          active: done ? false : index === activeStep,
          completed: done || index < activeStep
        }));
      }));
    }
  }]);

  return ProgressTracker;
}(PureComponent);

ProgressTracker.defaultProps = {
  currentStep: 0,
  color: 'mint',
  labelPosition: 'top'
};
ProgressTracker.ProgressStep = ProgressStep;
ProgressTracker.ProgressStep.displayName = 'ProgressTracker.ProgressStep';
export default ProgressTracker;