"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _reactNative = require("react-native");
var _vectorIcons = require("@expo/vector-icons");
var _GroupedPillButtons = _interopRequireDefault(require("../../components/internal/GroupedPillButtons"));
var _PinInput = _interopRequireDefault(require("../../components/internal/PinInput"));
var _useI18n = require("../../hooks/useI18n");
var _spacing = require("../../styles/spacing");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const RecoverVerifyStep = ({
  colors,
  styles,
  nextStep,
  prevStep,
  verificationCode,
  setVerificationCode,
  errorMessage,
  setErrorMessage,
  successMessage,
  setSuccessMessage,
  isLoading,
  setIsLoading,
  identifier
}) => {
  const {
    t
  } = (0, _useI18n.useI18n)();
  const baseStyles = _spacing.stepStyles;
  const handleVerifyCode = async () => {
    setErrorMessage('');
    setSuccessMessage('');
    if (verificationCode.length !== 6) {
      setErrorMessage(t('recover.enterCode'));
      return;
    }
    // For recovery via TOTP, proceed to reset step; server will validate during reset
    nextStep();
  };
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
    children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
      style: [baseStyles.container, baseStyles.sectionSpacing, baseStyles.header],
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
        style: [styles.modernTitle, baseStyles.title, {
          color: colors.text,
          marginBottom: 0,
          marginTop: 0
        }],
        children: t('recover.verify.title')
      }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
        style: [styles.modernSubtitle, baseStyles.subtitle, {
          color: colors.secondaryText,
          marginBottom: 0,
          marginTop: 0
        }],
        children: t('recover.enterCode')
      })]
    }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
      style: [baseStyles.container, baseStyles.sectionSpacing],
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
        style: stylesheet.pinInputWrapper,
        children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PinInput.default, {
          value: verificationCode,
          onChange: setVerificationCode,
          length: 6,
          disabled: isLoading,
          autoFocus: true,
          colors: colors
        })
      }), successMessage && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
        style: [stylesheet.messageContainer, {
          backgroundColor: colors.success + '10',
          borderColor: colors.success + '30'
        }],
        children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_vectorIcons.Ionicons, {
          name: "checkmark-circle",
          size: 20,
          color: colors.success
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
          style: [styles.footerText, {
            color: colors.success,
            fontSize: 14
          }],
          children: successMessage
        })]
      }), errorMessage && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
        style: [stylesheet.messageContainer, {
          backgroundColor: colors.error + '10',
          borderColor: colors.error + '30'
        }],
        children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_vectorIcons.Ionicons, {
          name: "alert-circle",
          size: 20,
          color: colors.error
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
          style: [styles.footerText, {
            color: colors.error,
            fontSize: 14
          }],
          children: errorMessage
        })]
      })]
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
      style: [baseStyles.container, baseStyles.sectionSpacing, baseStyles.buttonContainer],
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_GroupedPillButtons.default, {
        buttons: [{
          text: t('common.actions.back'),
          onPress: prevStep,
          icon: 'arrow-back',
          variant: 'transparent'
        }, {
          text: t('recover.verify.action'),
          onPress: handleVerifyCode,
          icon: 'checkmark-circle-outline',
          variant: 'primary',
          loading: isLoading,
          disabled: isLoading || verificationCode.length !== 6
        }],
        colors: colors
      })
    })]
  });
};
var _default = exports.default = RecoverVerifyStep;
const stylesheet = _reactNative.StyleSheet.create({
  pinInputWrapper: {
    marginBottom: 0,
    marginTop: 0
  },
  messageContainer: {
    flexDirection: 'row',
    alignItems: 'center',
    marginTop: _spacing.STEP_INNER_GAP,
    padding: _spacing.STEP_INNER_GAP,
    borderRadius: 8,
    borderWidth: 1,
    gap: _spacing.STEP_INNER_GAP
  }
});
//# sourceMappingURL=RecoverVerifyStep.js.map