"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _stack = require("@react-navigation/stack");
var _react = _interopRequireWildcard(require("react"));
var _reactI18next = require("react-i18next");
var _reactNative = require("react-native");
var _constants = require("../constants");
var _configuration = require("../contexts/configuration");
var _theme = require("../contexts/theme");
var _DataRetention = _interopRequireDefault(require("../screens/DataRetention"));
var _Language = _interopRequireDefault(require("../screens/Language"));
var _NameWallet = _interopRequireDefault(require("../screens/NameWallet"));
var _Onboarding = _interopRequireDefault(require("../screens/Onboarding"));
var _OnboardingPages = require("../screens/OnboardingPages");
var _PINCreate = _interopRequireDefault(require("../screens/PINCreate"));
var _Settings = _interopRequireDefault(require("../screens/Settings"));
var _Tours = _interopRequireDefault(require("../screens/Tours"));
var _UseBiometry = _interopRequireDefault(require("../screens/UseBiometry"));
var _navigators = require("../types/navigators");
var _testable = require("../utils/testable");
var _defaultStackOptions = require("./defaultStackOptions");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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 _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
const SettingStack = () => {
  const Stack = (0, _stack.createStackNavigator)();
  const theme = (0, _theme.useTheme)();
  const [biometryUpdatePending, setBiometryUpdatePending] = (0, _react.useState)(false);
  const {
    t
  } = (0, _reactI18next.useTranslation)();
  const {
    pages,
    terms,
    developer
  } = (0, _configuration.useConfiguration)();
  const defaultStackOptions = (0, _defaultStackOptions.createDefaultStackOptions)(theme);
  const OnboardingTheme = theme.OnboardingTheme;
  const carousel = (0, _OnboardingPages.createCarouselStyle)(OnboardingTheme);
  (0, _react.useEffect)(() => {
    const handleBiometry = _reactNative.DeviceEventEmitter.addListener(_constants.EventTypes.BIOMETRY_UPDATE, value => {
      setBiometryUpdatePending(value);
    });
    return () => {
      handleBiometry.remove();
    };
  }, []);
  return /*#__PURE__*/_react.default.createElement(Stack.Navigator, {
    screenOptions: {
      ...defaultStackOptions
    }
  }, /*#__PURE__*/_react.default.createElement(Stack.Screen, {
    name: _navigators.Screens.Settings,
    component: _Settings.default,
    options: {
      title: t('Screens.Settings'),
      headerBackTestID: (0, _testable.testIdWithKey)('Back')
    }
  }), /*#__PURE__*/_react.default.createElement(Stack.Screen, {
    name: _navigators.Screens.NameWallet,
    component: _NameWallet.default,
    options: {
      title: t('Screens.NameWallet'),
      headerBackTestID: (0, _testable.testIdWithKey)('Back')
    }
  }), /*#__PURE__*/_react.default.createElement(Stack.Screen, {
    name: _navigators.Screens.Language,
    component: _Language.default,
    options: {
      title: t('Screens.Language'),
      headerBackTestID: (0, _testable.testIdWithKey)('Back')
    }
  }), /*#__PURE__*/_react.default.createElement(Stack.Screen, {
    name: _navigators.Screens.DataRetention,
    component: _DataRetention.default,
    options: {
      title: t('Screens.DataRetention'),
      headerBackTestID: (0, _testable.testIdWithKey)('Back')
    }
  }), /*#__PURE__*/_react.default.createElement(Stack.Screen, {
    name: _navigators.Screens.Tours,
    component: _Tours.default,
    options: {
      title: t('Screens.Tours'),
      headerBackTestID: (0, _testable.testIdWithKey)('Back')
    }
  }), /*#__PURE__*/_react.default.createElement(Stack.Screen, {
    name: _navigators.Screens.UseBiometry,
    component: _UseBiometry.default,
    options: {
      title: t('Screens.Biometry'),
      headerLeft: biometryUpdatePending ? () => null : undefined,
      headerBackTestID: (0, _testable.testIdWithKey)('Back')
    }
  }), /*#__PURE__*/_react.default.createElement(Stack.Screen, {
    name: _navigators.Screens.CreatePIN,
    component: _PINCreate.default,
    options: {
      title: t('Screens.ChangePIN'),
      headerBackTestID: (0, _testable.testIdWithKey)('Back')
    }
  }), /*#__PURE__*/_react.default.createElement(Stack.Screen, {
    name: _navigators.Screens.Terms,
    component: terms,
    options: {
      title: t('Screens.Terms'),
      headerBackTestID: (0, _testable.testIdWithKey)('Back')
    }
  }), /*#__PURE__*/_react.default.createElement(Stack.Screen, {
    name: _navigators.Screens.Developer,
    component: developer,
    options: {
      title: t('Screens.Developer'),
      headerBackTestID: (0, _testable.testIdWithKey)('Back')
    }
  }), /*#__PURE__*/_react.default.createElement(Stack.Screen, {
    name: _navigators.Screens.Onboarding,
    options: {
      title: t('Screens.Onboarding')
    }
  }, props => /*#__PURE__*/_react.default.createElement(_Onboarding.default, _extends({}, props, {
    nextButtonText: t('Global.Next'),
    previousButtonText: t('Global.Back'),
    pages: pages(() => null, OnboardingTheme),
    style: carousel,
    disableSkip: true
  }))));
};
var _default = SettingStack;
exports.default = _default;
//# sourceMappingURL=SettingStack.js.map