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); }
import { createStackNavigator } from '@react-navigation/stack';
import React, { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { DeviceEventEmitter } from 'react-native';
import { EventTypes } from '../constants';
import { useConfiguration } from '../contexts/configuration';
import { useTheme } from '../contexts/theme';
import DataRetention from '../screens/DataRetention';
import Language from '../screens/Language';
import NameWallet from '../screens/NameWallet';
import Onboarding from '../screens/Onboarding';
import { createCarouselStyle } from '../screens/OnboardingPages';
import PINCreate from '../screens/PINCreate';
import Settings from '../screens/Settings';
import Tours from '../screens/Tours';
import UseBiometry from '../screens/UseBiometry';
import { Screens } from '../types/navigators';
import { testIdWithKey } from '../utils/testable';
import { createDefaultStackOptions } from './defaultStackOptions';
const SettingStack = () => {
  const Stack = createStackNavigator();
  const theme = useTheme();
  const [biometryUpdatePending, setBiometryUpdatePending] = useState(false);
  const {
    t
  } = useTranslation();
  const {
    pages,
    terms,
    developer
  } = useConfiguration();
  const defaultStackOptions = createDefaultStackOptions(theme);
  const OnboardingTheme = theme.OnboardingTheme;
  const carousel = createCarouselStyle(OnboardingTheme);
  useEffect(() => {
    const handleBiometry = DeviceEventEmitter.addListener(EventTypes.BIOMETRY_UPDATE, value => {
      setBiometryUpdatePending(value);
    });
    return () => {
      handleBiometry.remove();
    };
  }, []);
  return /*#__PURE__*/React.createElement(Stack.Navigator, {
    screenOptions: {
      ...defaultStackOptions
    }
  }, /*#__PURE__*/React.createElement(Stack.Screen, {
    name: Screens.Settings,
    component: Settings,
    options: {
      title: t('Screens.Settings'),
      headerBackTestID: testIdWithKey('Back')
    }
  }), /*#__PURE__*/React.createElement(Stack.Screen, {
    name: Screens.NameWallet,
    component: NameWallet,
    options: {
      title: t('Screens.NameWallet'),
      headerBackTestID: testIdWithKey('Back')
    }
  }), /*#__PURE__*/React.createElement(Stack.Screen, {
    name: Screens.Language,
    component: Language,
    options: {
      title: t('Screens.Language'),
      headerBackTestID: testIdWithKey('Back')
    }
  }), /*#__PURE__*/React.createElement(Stack.Screen, {
    name: Screens.DataRetention,
    component: DataRetention,
    options: {
      title: t('Screens.DataRetention'),
      headerBackTestID: testIdWithKey('Back')
    }
  }), /*#__PURE__*/React.createElement(Stack.Screen, {
    name: Screens.Tours,
    component: Tours,
    options: {
      title: t('Screens.Tours'),
      headerBackTestID: testIdWithKey('Back')
    }
  }), /*#__PURE__*/React.createElement(Stack.Screen, {
    name: Screens.UseBiometry,
    component: UseBiometry,
    options: {
      title: t('Screens.Biometry'),
      headerLeft: biometryUpdatePending ? () => null : undefined,
      headerBackTestID: testIdWithKey('Back')
    }
  }), /*#__PURE__*/React.createElement(Stack.Screen, {
    name: Screens.CreatePIN,
    component: PINCreate,
    options: {
      title: t('Screens.ChangePIN'),
      headerBackTestID: testIdWithKey('Back')
    }
  }), /*#__PURE__*/React.createElement(Stack.Screen, {
    name: Screens.Terms,
    component: terms,
    options: {
      title: t('Screens.Terms'),
      headerBackTestID: testIdWithKey('Back')
    }
  }), /*#__PURE__*/React.createElement(Stack.Screen, {
    name: Screens.Developer,
    component: developer,
    options: {
      title: t('Screens.Developer'),
      headerBackTestID: testIdWithKey('Back')
    }
  }), /*#__PURE__*/React.createElement(Stack.Screen, {
    name: Screens.Onboarding,
    options: {
      title: t('Screens.Onboarding')
    }
  }, props => /*#__PURE__*/React.createElement(Onboarding, _extends({}, props, {
    nextButtonText: t('Global.Next'),
    previousButtonText: t('Global.Back'),
    pages: pages(() => null, OnboardingTheme),
    style: carousel,
    disableSkip: true
  }))));
};
export default SettingStack;
//# sourceMappingURL=SettingStack.js.map