text: "use strict";
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports.ProgressStep = ProgressStep;
  exports.ProgressIndicator = void 0;
  
  var _propTypes = _interopRequireDefault(require("prop-types"));
  
  var _react = _interopRequireWildcard(require("react"));
  
  var _classnames4 = _interopRequireDefault(require("classnames"));
  
  var _carbonComponents = require("carbon-components");
  
  var _iconsReact = require("@carbon/icons-react");
  
  var _keyboard = require("../../internal/keyboard");
  
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  
  function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  
  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 _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  
  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); }
  
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
  
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
  
  var prefix = _carbonComponents.settings.prefix;
  
  var defaultRenderLabel = function defaultRenderLabel(props) {
    return /*#__PURE__*/_react.default.createElement("p", props);
  };
  
  var defaultTranslations = {
    'carbon.progress-step.complete': 'Complete',
    'carbon.progress-step.incomplete': 'Incomplete',
    'carbon.progress-step.current': 'Current',
    'carbon.progress-step.invalid': 'Invalid'
  };
  
  function translateWithId(messageId) {
    return defaultTranslations[messageId];
  }
  
  function ProgressStep(_ref) {
    var _classnames;
  
    var label = _ref.label,
        description = _ref.description,
        className = _ref.className,
        current = _ref.current,
        complete = _ref.complete,
        invalid = _ref.invalid,
        secondaryLabel = _ref.secondaryLabel,
        disabled = _ref.disabled,
        onClick = _ref.onClick,
        ProgressStepLabel = _ref.renderLabel,
        t = _ref.translateWithId,
        rest = _objectWithoutProperties(_ref, ["label", "description", "className", "current", "complete", "invalid", "secondaryLabel", "disabled", "onClick", "renderLabel", "translateWithId"]);
  
    var classes = (0, _classnames4.default)((_classnames = {}, _defineProperty(_classnames, "".concat(prefix, "--progress-step"), true), _defineProperty(_classnames, "".concat(prefix, "--progress-step--current"), current), _defineProperty(_classnames, "".concat(prefix, "--progress-step--complete"), complete), _defineProperty(_classnames, "".concat(prefix, "--progress-step--incomplete"), !complete && !current), _defineProperty(_classnames, "".concat(prefix, "--progress-step--disabled"), disabled), _defineProperty(_classnames, className, className), _classnames));
  
    var handleKeyDown = function handleKeyDown(e) {
      if ((0, _keyboard.matches)(e, [_keyboard.keys.Enter, _keyboard.keys.Space])) {
        onClick();
      }
    }; // eslint-disable-next-line react/prop-types
  
  
    var SVGIcon = function SVGIcon(_ref2) {
      var complete = _ref2.complete,
          current = _ref2.current,
          description = _ref2.description,
          invalid = _ref2.invalid,
          prefix = _ref2.prefix;
  
      if (invalid) {
        return /*#__PURE__*/_react.default.createElement(_iconsReact.Warning16, {
          className: "".concat(prefix, "--progress__warning")
        });
      }
  
      if (current) {
        return /*#__PURE__*/_react.default.createElement(_iconsReact.CircleFilled16, null, /*#__PURE__*/_react.default.createElement("title", null, description));
      }
  
      if (complete) {
        return /*#__PURE__*/_react.default.createElement(_iconsReact.CheckmarkOutline16, null, /*#__PURE__*/_react.default.createElement("title", null, description));
      }
  
      return /*#__PURE__*/_react.default.createElement(_iconsReact.RadioButton16, null, /*#__PURE__*/_react.default.createElement("title", null, description));
    };
  
    var message = t('carbon.progress-step.incomplete');
  
    if (current) {
      message = t('carbon.progress-step.current');
    }
  
    if (complete) {
      message = t('carbon.progress-step.complete');
    }
  
    if (invalid) {
      message = t('carbon.progress-step.invalid');
    }
  
    return /*#__PURE__*/_react.default.createElement("li", {
      className: classes
    }, /*#__PURE__*/_react.default.createElement("button", _extends({
      type: "button",
      className: (0, _classnames4.default)("".concat(prefix, "--progress-step-button"), _defineProperty({}, "".concat(prefix, "--progress-step-button--unclickable"), !onClick || current)),
      disabled: disabled,
      "aria-disabled": disabled,
      tabIndex: !current && onClick && !disabled ? 0 : -1,
      onClick: !current ? onClick : undefined,
      onKeyDown: handleKeyDown,
      title: label
    }, rest), /*#__PURE__*/_react.default.createElement("span", {
      className: "".concat(prefix, "--assistive-text")
    }, message), /*#__PURE__*/_react.default.createElement(SVGIcon, {
      complete: complete,
      current: current,
      description: description,
      invalid: invalid,
      prefix: prefix
    }), /*#__PURE__*/_react.default.createElement(ProgressStepLabel, {
      className: "".concat(prefix, "--progress-label")
    }, label), secondaryLabel !== null && secondaryLabel !== undefined ? /*#__PURE__*/_react.default.createElement("p", {
      className: "".concat(prefix, "--progress-optional")
    }, secondaryLabel) : null, /*#__PURE__*/_react.default.createElement("span", {
      className: "".concat(prefix, "--progress-line")
    })));
  }
  
  ProgressStep.propTypes = {
    /**
     * Provide an optional className to be applied to the containing `<li>` node
     */
    className: _propTypes.default.string,
  
    /**
     * Specify whether the step has been completed
     */
    complete: _propTypes.default.bool,
  
    /**
     * Specify whether the step is the current step
     */
    current: _propTypes.default.bool,
  
    /**
     * Provide a description for the <ProgressStep>
     */
    description: _propTypes.default.string,
  
    /**
     * Specify whether the step is disabled
     */
    disabled: _propTypes.default.bool,
  
    /**
     * Index of the current step within the ProgressIndicator
     */
    index: _propTypes.default.number,
  
    /**
     * Specify whether the step is invalid
     */
    invalid: _propTypes.default.bool,
  
    /**
     * Provide the label for the <ProgressStep>
     */
    label: _propTypes.default.node.isRequired,
  
    /**
     * A callback called if the step is clicked or the enter key is pressed
     */
    onClick: _propTypes.default.func,
  
    /**
     * Provide the props that describe a progress step tooltip
     */
    overflowTooltipProps: _propTypes.default.object,
  
    /*
     * An optional parameter to allow for overflow content to be rendered in a
     * tooltip.
     */
    renderLabel: _propTypes.default.func,
  
    /**
     * Provide an optional secondary label
     */
    secondaryLabel: _propTypes.default.string,
  
    /**
     * The ID of the tooltip content.
     */
    tooltipId: _propTypes.default.string,
  
    /**
     * Optional method that takes in a message id and returns an
     * internationalized string.
     */
    translateWithId: _propTypes.default.func
  };
  ProgressStep.defaultProps = {
    renderLabel: defaultRenderLabel,
    translateWithId: translateWithId
  };
  
  var ProgressIndicator = /*#__PURE__*/function (_Component) {
    _inherits(ProgressIndicator, _Component);
  
    var _super = _createSuper(ProgressIndicator);
  
    function ProgressIndicator() {
      var _this;
  
      _classCallCheck(this, ProgressIndicator);
  
      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
        args[_key] = arguments[_key];
      }
  
      _this = _super.call.apply(_super, [this].concat(args));
  
      _defineProperty(_assertThisInitialized(_this), "state", {});
  
      _defineProperty(_assertThisInitialized(_this), "renderSteps", function () {
        var onChange = _this.props.onChange;
        return _react.default.Children.map(_this.props.children, function (child, index) {
          // only setup click handlers if onChange event is passed
          var onClick = onChange ? function () {
            return onChange(index);
          } : undefined;
  
          if (index === _this.state.currentIndex) {
            return /*#__PURE__*/_react.default.cloneElement(child, {
              current: true,
              index: index,
              onClick: onClick
            });
          }
  
          if (index < _this.state.currentIndex) {
            return /*#__PURE__*/_react.default.cloneElement(child, {
              complete: true,
              index: index,
              onClick: onClick
            });
          }
  
          if (index > _this.state.currentIndex) {
            return /*#__PURE__*/_react.default.cloneElement(child, {
              complete: child.props.complete || false,
              index: index,
              onClick: onClick
            });
          }
  
          return null;
        });
      });
  
      return _this;
    }
  
    _createClass(ProgressIndicator, [{
      key: "render",
      value: function render() {
        var _classnames3;
  
        var _this$props = this.props,
            className = _this$props.className,
            currentIndex = _this$props.currentIndex,
            vertical = _this$props.vertical,
            spaceEqually = _this$props.spaceEqually,
            other = _objectWithoutProperties(_this$props, ["className", "currentIndex", "vertical", "spaceEqually"]);
  
        var classes = (0, _classnames4.default)((_classnames3 = {}, _defineProperty(_classnames3, "".concat(prefix, "--progress"), true), _defineProperty(_classnames3, "".concat(prefix, "--progress--vertical"), vertical), _defineProperty(_classnames3, "".concat(prefix, "--progress--space-equal"), spaceEqually && !vertical), _defineProperty(_classnames3, className, className), _classnames3));
        return /*#__PURE__*/_react.default.createElement("ul", _extends({
          className: classes
        }, other), this.renderSteps());
      }
    }], [{
      key: "getDerivedStateFromProps",
      value: function getDerivedStateFromProps(_ref3, state) {
        var currentIndex = _ref3.currentIndex;
        var prevCurrentIndex = state.prevCurrentIndex;
        return prevCurrentIndex === currentIndex ? null : {
          currentIndex: currentIndex,
          prevCurrentIndex: currentIndex
        };
      }
    }]);
  
    return ProgressIndicator;
  }(_react.Component);
  
  exports.ProgressIndicator = ProgressIndicator;
  
  _defineProperty(ProgressIndicator, "propTypes", {
    /**
     * Provide <ProgressStep> components to be rendered in the
     * <ProgressIndicator>
     */
    children: _propTypes.default.node,
  
    /**
     * Provide an optional className to be applied to the containing node
     */
    className: _propTypes.default.string,
  
    /**
     * Optionally specify the current step array index
     */
    currentIndex: _propTypes.default.number,
  
    /**
     * Optional callback called if a ProgressStep is clicked on.  Returns the index of the step.
     */
    onChange: _propTypes.default.func,
  
    /**
     * Specify whether the progress steps should be split equally in size in the div
     */
    spaceEqually: _propTypes.default.bool,
  
    /**
     * Determines whether or not the ProgressIndicator should be rendered vertically.
     */
    vertical: _propTypes.default.bool
  });
  
  _defineProperty(ProgressIndicator, "defaultProps", {
    currentIndex: 0
  });