"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Step = void 0;
var _react = _interopRequireWildcard(require("react"));
var _StepActionButton = require("./StepActionButton");
var _Styles = require("./Styles");
var _Dialog = require("../Dialog");
var _IconButton = require("../IconButton");
var _Icons = require("../Icons");
var _Typography = require("../Typography");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
var Step = exports.Step = function Step(_ref) {
  var index = _ref.index,
    isLast = _ref.isLast,
    subtitle = _ref.subtitle,
    title = _ref.title,
    onNextButtonClick = _ref.onNextButtonClick,
    onPreviousButtonClick = _ref.onPreviousButtonClick,
    onClose = _ref.onClose,
    children = _ref.children,
    _ref$actionLabel = _ref.actionLabel,
    actionLabel = _ref$actionLabel === void 0 ? "Proceed" : _ref$actionLabel,
    _ref$shouldRenderNext = _ref.shouldRenderNextButton,
    shouldRenderNextButton = _ref$shouldRenderNext === void 0 ? true : _ref$shouldRenderNext,
    _ref$changingStepInPr = _ref.changingStepInProgress,
    changingStepInProgress = _ref$changingStepInPr === void 0 ? false : _ref$changingStepInPr,
    _ref$disableBackButto = _ref.disableBackButton,
    disableBackButton = _ref$disableBackButto === void 0 ? false : _ref$disableBackButto,
    customRightHeader = _ref.customRightHeader,
    _ref$skip = _ref.skip,
    skip = _ref$skip === void 0 ? false : _ref$skip;
  var onActionButtonClick = (0, _react.useCallback)(function () {
    if (isLast && onClose) {
      return onClose();
    }
    return onNextButtonClick && onNextButtonClick();
  }, [isLast, onClose, onNextButtonClick]);
  return !skip ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Styles.StyledStepHeader, null, /*#__PURE__*/_react.default.createElement(_Styles.StyledStepHeaderLeft, null, !disableBackButton && index && index > 0 ? /*#__PURE__*/_react.default.createElement(_IconButton.IconButton, {
    onClick: onPreviousButtonClick,
    variant: "text gray",
    className: "tw--ml-3 tw-mr-2",
    disabled: changingStepInProgress
  }, /*#__PURE__*/_react.default.createElement(_Icons.ArrowBackMobileIcon, null)) : null, /*#__PURE__*/_react.default.createElement(_Styles.StyledStepTitle, null, /*#__PURE__*/_react.default.createElement(_Typography.Caption2, null, title), /*#__PURE__*/_react.default.createElement(_Typography.Header3, null, subtitle))), customRightHeader ? customRightHeader : /*#__PURE__*/_react.default.createElement(_IconButton.IconButton, {
    onClick: onClose,
    variant: "text gray",
    disabled: changingStepInProgress
  }, /*#__PURE__*/_react.default.createElement(_Icons.CancelCrossIcon, null))), /*#__PURE__*/_react.default.createElement(_Dialog.Dialog.ContentDivider, null), shouldRenderNextButton ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Dialog.Dialog.Content, null, children), /*#__PURE__*/_react.default.createElement(_Dialog.Dialog.ContentDivider, null), /*#__PURE__*/_react.default.createElement(_Dialog.Dialog.Actions, null, /*#__PURE__*/_react.default.createElement(_StepActionButton.StepActionButton, {
    isLast: isLast,
    actionLabel: actionLabel,
    onNextButtonClick: onActionButtonClick
  }))) : /*#__PURE__*/_react.default.createElement(_Styles.StyledCustomStep, null, children)) : null;
};
Step.displayName = "Step";
//# sourceMappingURL=Step.js.map