"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
var _Avatar = _interopRequireDefault(require("../components/Avatar"));
var _OxyIcon = _interopRequireDefault(require("../components/icon/OxyIcon"));
var _fonts = require("../styles/fonts");
var _sonner = require("../../lib/sonner");
var _confirmAction = require("../utils/confirmAction");
var _components = require("../components");
var _useI18n = require("../hooks/useI18n");
var _useThemeStyles = require("../hooks/useThemeStyles");
var _userUtils = require("../utils/user-utils");
var _useColorScheme = require("../hooks/use-color-scheme");
var _themeUtils = require("../utils/themeUtils");
var _OxyContext = require("../context/OxyContext");
var _useAccountQueries = require("../hooks/queries/useAccountQueries");
var _spacing = require("../constants/spacing");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
// Optional Lottie import - gracefully handle if not available
let LottieView = null;
try {
  // eslint-disable-next-line @typescript-eslint/no-require-imports
  LottieView = require('lottie-react-native').default;
} catch {
  // Lottie not available, will use fallback
}

// Import Lottie animation - will be undefined if file doesn't exist
let lottieAnimation = undefined;
try {
  // eslint-disable-next-line @typescript-eslint/no-require-imports
  lottieAnimation = require('../assets/lottie/welcomeheader_background_op1.json');
} catch {
  // Animation file not available
}

/**
 * AccountOverviewScreen - Optimized for performance
 * 
 * Performance optimizations implemented:
 * - useMemo for theme calculations (only recalculates when theme changes)
 * - useMemo for additional accounts filtering (only recalculates when dependencies change)
 * - useCallback for event handlers to prevent unnecessary re-renders
 * - React.memo wrapper to prevent re-renders when props haven't changed
 * - GroupedSection components for better organization and cleaner code
 */
const AccountOverviewScreen = ({
  onClose,
  theme,
  navigate
}) => {
  // Use useOxy() hook for OxyContext values
  const {
    user,
    logout,
    isLoading,
    sessions,
    activeSessionId,
    oxyServices,
    isAuthenticated,
    openAvatarPicker
  } = (0, _OxyContext.useOxy)();
  const {
    t
  } = (0, _useI18n.useI18n)();
  const [showMoreAccounts, setShowMoreAccounts] = (0, _react.useState)(false);
  const [additionalAccountsData, setAdditionalAccountsData] = (0, _react.useState)([]);
  const [loadingAdditionalAccounts, setLoadingAdditionalAccounts] = (0, _react.useState)(false);
  const lottieRef = (0, _react.useRef)(null);
  const hasPlayedRef = (0, _react.useRef)(false);
  const insets = (0, _reactNativeSafeAreaContext.useSafeAreaInsets)();

  // Use centralized theme styles hook for consistency
  const colorScheme = (0, _useColorScheme.useColorScheme)();
  const normalizedTheme = (0, _themeUtils.normalizeTheme)(theme);
  const baseThemeStyles = (0, _useThemeStyles.useThemeStyles)(normalizedTheme, colorScheme);
  const themeStyles = (0, _react.useMemo)(() => ({
    ...baseThemeStyles,
    // AccountOverviewScreen uses a custom primary color (purple) instead of the default blue
    primaryColor: '#d169e5',
    // Keep custom icon color for this screen
    iconColor: baseThemeStyles.isDarkTheme ? '#BBBBBB' : '#666666'
  }), [baseThemeStyles]);

  // Compute user data for display
  const displayName = (0, _react.useMemo)(() => (0, _userUtils.getDisplayName)(user), [user]);
  const shortDisplayName = (0, _react.useMemo)(() => (0, _userUtils.getShortDisplayName)(user), [user]);
  const avatarUrl = (0, _react.useMemo)(() => {
    if (user?.avatar && oxyServices) {
      return oxyServices.getFileDownloadUrl(user.avatar, 'thumb');
    }
    return undefined;
  }, [user?.avatar, oxyServices]);

  // Handle avatar press - use openAvatarPicker from context
  const handleAvatarPress = (0, _react.useCallback)(() => {
    openAvatarPicker();
  }, [openAvatarPicker]);

  // Play Lottie animation once when component mounts
  (0, _react.useEffect)(() => {
    if (hasPlayedRef.current || !LottieView || !lottieRef.current || !lottieAnimation) return;
    const timer = setTimeout(() => {
      if (lottieRef.current && !hasPlayedRef.current) {
        lottieRef.current.play();
        hasPlayedRef.current = true;
      }
    }, 100);
    return () => clearTimeout(timer);
  }, []);

  // Memoize additional accounts filtering to prevent recalculation on every render
  const additionalAccounts = (0, _react.useMemo)(() => (sessions || []).filter(session => session.sessionId !== activeSessionId && session.userId !== user?.id), [sessions, activeSessionId, user?.id]);

  // Load user profiles for additional accounts using TanStack Query
  const sessionIds = additionalAccounts.map(s => s.sessionId);
  const {
    data: usersData,
    isLoading: isLoadingUsers
  } = (0, _useAccountQueries.useUsersBySessions)(sessionIds, {
    enabled: additionalAccounts.length > 0
  });
  _react.default.useEffect(() => {
    if (usersData && usersData.length > 0) {
      const accountsData = usersData.map(({
        sessionId,
        user: userProfile
      }) => {
        if (!userProfile) {
          return {
            id: sessionId,
            sessionId,
            username: 'Unknown User',
            email: 'No email available',
            avatar: null,
            userProfile: null
          };
        }
        return {
          id: sessionId,
          sessionId,
          username: userProfile.username,
          email: userProfile.email,
          name: userProfile.name,
          avatar: userProfile.avatar,
          userProfile
        };
      });
      setAdditionalAccountsData(accountsData);
      setLoadingAdditionalAccounts(false);
    } else if (additionalAccounts.length === 0) {
      setAdditionalAccountsData([]);
      setLoadingAdditionalAccounts(false);
    } else if (!isLoadingUsers) {
      setLoadingAdditionalAccounts(false);
    }
  }, [usersData, additionalAccounts.length, isLoadingUsers]);

  // Feature settings (with mock values)
  const features = {
    safeSearch: false,
    language: 'English'
  };

  // Memoize event handlers to prevent recreation on every render
  const handleLogout = (0, _react.useCallback)(async () => {
    try {
      await logout();
      if (onClose) {
        onClose();
      }
    } catch (error) {
      console.error('Logout failed:', error);
      _sonner.toast.error(t('common.errors.signOutFailed'));
    }
  }, [logout, onClose]);
  const confirmLogout = (0, _react.useCallback)(() => {
    (0, _confirmAction.confirmAction)(t('common.confirms.signOut'), handleLogout);
  }, [handleLogout]);
  const handleAddAccount = (0, _react.useCallback)(() => {
    _sonner.toast.info(t('accountOverview.addAccountComing'));
  }, [t]);
  const handleSignOutAll = (0, _react.useCallback)(() => {
    (0, _confirmAction.confirmAction)(t('common.confirms.signOutAll'), handleLogout);
  }, [handleLogout]);
  const handleDownloadData = (0, _react.useCallback)(async () => {
    if (!oxyServices || !user) {
      _sonner.toast.error(t('accountOverview.items.downloadData.error') || 'Service not available');
      return;
    }
    try {
      _reactNative.Alert.alert(t('accountOverview.items.downloadData.confirmTitle') || 'Download Account Data', t('accountOverview.items.downloadData.confirmMessage') || 'Choose the format for your account data export:', [{
        text: t('common.cancel') || 'Cancel',
        style: 'cancel'
      }, {
        text: 'JSON',
        onPress: async () => {
          try {
            _sonner.toast.loading(t('accountOverview.items.downloadData.downloading') || 'Preparing download...');
            const blob = await oxyServices.downloadAccountData('json');

            // Create download link for web
            if (_reactNative.Platform.OS === 'web') {
              const url = URL.createObjectURL(blob);
              const link = document.createElement('a');
              link.href = url;
              link.download = `account-data-${Date.now()}.json`;
              document.body.appendChild(link);
              link.click();
              document.body.removeChild(link);
              URL.revokeObjectURL(url);
              _sonner.toast.success(t('accountOverview.items.downloadData.success') || 'Data downloaded successfully');
            } else {
              // For React Native, you'd need to use a library like expo-file-system
              _sonner.toast.success(t('accountOverview.items.downloadData.success') || 'Data downloaded successfully');
            }
          } catch (error) {
            console.error('Failed to download data:', error);
            _sonner.toast.error(error?.message || t('accountOverview.items.downloadData.error') || 'Failed to download data');
          }
        }
      }, {
        text: 'CSV',
        onPress: async () => {
          try {
            _sonner.toast.loading(t('accountOverview.items.downloadData.downloading') || 'Preparing download...');
            const blob = await oxyServices.downloadAccountData('csv');

            // Create download link for web
            if (_reactNative.Platform.OS === 'web') {
              const url = URL.createObjectURL(blob);
              const link = document.createElement('a');
              link.href = url;
              link.download = `account-data-${Date.now()}.csv`;
              document.body.appendChild(link);
              link.click();
              document.body.removeChild(link);
              URL.revokeObjectURL(url);
              _sonner.toast.success(t('accountOverview.items.downloadData.success') || 'Data downloaded successfully');
            } else {
              // For React Native, you'd need to use a library like expo-file-system
              _sonner.toast.success(t('accountOverview.items.downloadData.success') || 'Data downloaded successfully');
            }
          } catch (error) {
            console.error('Failed to download data:', error);
            _sonner.toast.error(error?.message || t('accountOverview.items.downloadData.error') || 'Failed to download data');
          }
        }
      }]);
    } catch (error) {
      console.error('Failed to initiate download:', error);
      _sonner.toast.error(error?.message || t('accountOverview.items.downloadData.error') || 'Failed to download data');
    }
  }, [oxyServices, user, t]);
  const handleDeleteAccount = (0, _react.useCallback)(() => {
    if (!user) {
      _sonner.toast.error(t('accountOverview.items.deleteAccount.error') || 'User not available');
      return;
    }
    (0, _confirmAction.confirmAction)(t('accountOverview.items.deleteAccount.confirmMessage') || `This action cannot be undone. This will permanently delete your account and all associated data.\n\nAre you sure you want to delete your account?`, async () => {
      // For React Native, we'd need a separate modal for password/confirmation input
      // For now, we'll use a simplified confirmation
      // In production, you'd want to create a modal with password and username confirmation fields
      if (!oxyServices) {
        _sonner.toast.error(t('accountOverview.items.deleteAccount.error') || 'Service not available');
        return;
      }
      _reactNative.Alert.alert(t('accountOverview.items.deleteAccount.confirmTitle') || 'Delete Account', t('accountOverview.items.deleteAccount.finalConfirm') || `This is your final warning. Your account will be permanently deleted and cannot be recovered. Type "${user.username}" to confirm.`, [{
        text: t('common.cancel') || 'Cancel',
        style: 'cancel'
      }, {
        text: t('accountOverview.items.deleteAccount.confirm') || 'Delete Forever',
        style: 'destructive',
        onPress: async () => {
          try {
            // Note: In a production app, you'd want to show a modal with password and username confirmation fields
            // For now, we'll require the user to enter these via a custom modal or prompt
            _sonner.toast.error(t('accountOverview.items.deleteAccount.passwordRequired') || 'Password confirmation required. This feature needs a modal with password input.');
          } catch (error) {
            console.error('Failed to delete account:', error);
            _sonner.toast.error(error?.message || t('accountOverview.items.deleteAccount.error') || 'Failed to delete account');
          }
        }
      }]);
    });
  }, [user, oxyServices, logout, onClose, t]);
  if (!isAuthenticated) {
    return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
      style: [styles.container, {
        backgroundColor: themeStyles.backgroundColor
      }],
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
        style: [styles.message, {
          color: themeStyles.textColor
        }],
        children: t('common.status.notSignedIn')
      })
    });
  }
  if (isLoading) {
    return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
      style: [styles.container, {
        backgroundColor: themeStyles.backgroundColor,
        justifyContent: 'center'
      }],
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
        size: "large",
        color: themeStyles.primaryColor
      })
    });
  }
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
    style: [styles.container, {
      backgroundColor: themeStyles.backgroundColor
    }],
    children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.ScrollView, {
      style: styles.content,
      contentContainerStyle: styles.scrollContent,
      showsVerticalScrollIndicator: false,
      children: [user && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
        style: styles.headerSection,
        children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
          style: styles.avatarSectionWrapper,
          children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
            style: styles.avatarContainer,
            children: [LottieView && lottieAnimation && /*#__PURE__*/(0, _jsxRuntime.jsx)(LottieView, {
              ref: lottieRef,
              source: lottieAnimation,
              style: styles.lottieBackground,
              loop: false,
              autoPlay: false
            }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
              style: styles.avatarWrapper,
              onPress: handleAvatarPress,
              activeOpacity: 0.8,
              children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Avatar.default, {
                uri: avatarUrl,
                name: displayName,
                size: 100,
                theme: normalizedTheme
              })
            })]
          }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
            style: styles.nameWrapper,
            children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
              style: [styles.welcomeText, {
                color: themeStyles.textColor
              }],
              children: displayName
            }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
              style: [styles.welcomeSubtext, {
                color: themeStyles.isDarkTheme ? '#BBBBBB' : '#666666'
              }],
              children: "Manage your Oxy account."
            })]
          })]
        })
      }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Section, {
        title: t('accountOverview.sections.profile'),
        isFirst: true,
        children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.GroupedSection, {
          items: [{
            id: 'profile-info',
            icon: 'person',
            iconColor: baseThemeStyles.colors.iconSecurity,
            title: displayName,
            subtitle: user ? user.email || user.username : t('common.status.loading') || 'Loading...',
            onPress: () => navigate?.('EditProfile', {
              activeTab: 'profile'
            })
          }]
        })
      }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Section, {
        title: t('accountOverview.sections.accountSettings'),
        children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.GroupedSection, {
          items: [{
            id: 'edit-profile',
            icon: 'person-circle',
            iconColor: baseThemeStyles.colors.iconPersonalInfo,
            title: t('accountOverview.items.editProfile.title'),
            subtitle: t('accountOverview.items.editProfile.subtitle'),
            onPress: () => navigate?.('EditProfile', {
              activeTab: 'profile'
            })
          }, {
            id: 'security-privacy',
            icon: 'shield-checkmark',
            iconColor: baseThemeStyles.colors.iconSecurity,
            title: t('accountOverview.items.security.title'),
            subtitle: t('accountOverview.items.security.subtitle'),
            onPress: () => navigate?.('EditProfile', {
              activeTab: 'password'
            })
          }, {
            id: 'notifications',
            icon: 'notifications',
            iconColor: baseThemeStyles.colors.iconStorage,
            title: t('accountOverview.items.notifications.title'),
            subtitle: t('accountOverview.items.notifications.subtitle'),
            onPress: () => navigate?.('EditProfile', {
              activeTab: 'notifications'
            })
          }, {
            id: 'premium-subscription',
            icon: 'star',
            iconColor: baseThemeStyles.colors.iconPayments,
            title: t('accountOverview.items.premium.title'),
            subtitle: user?.isPremium ? t('accountOverview.items.premium.manage') : t('accountOverview.items.premium.upgrade'),
            onPress: () => navigate?.('PremiumSubscription')
          }, ...(user?.isPremium ? [{
            id: 'billing-management',
            icon: 'card',
            iconColor: baseThemeStyles.colors.iconPersonalInfo,
            title: t('accountOverview.items.billing.title'),
            subtitle: t('accountOverview.items.billing.subtitle'),
            onPress: () => _sonner.toast.info(t('accountOverview.items.billing.coming'))
          }] : [])]
        })
      }), showMoreAccounts && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Section, {
        title: `${t('accountOverview.sections.additionalAccounts') || 'Additional Accounts'}${additionalAccountsData.length > 0 ? ` (${additionalAccountsData.length})` : ''}`,
        children: loadingAdditionalAccounts ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.GroupedSection, {
          items: [{
            id: 'loading-accounts',
            icon: 'sync',
            iconColor: baseThemeStyles.colors.iconSecurity,
            title: t('accountOverview.loadingAdditional.title') || 'Loading accounts...',
            subtitle: t('accountOverview.loadingAdditional.subtitle') || 'Please wait while we load your additional accounts',
            customContent: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
              style: styles.loadingContainer,
              children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
                size: "small",
                color: baseThemeStyles.colors.iconSecurity
              }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
                style: styles.loadingText,
                children: t('accountOverview.loadingAdditional.title') || 'Loading accounts...'
              })]
            })
          }]
        }) : additionalAccountsData.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.GroupedSection, {
          items: additionalAccountsData.map((account, index) => ({
            id: `account-${account.id}`,
            icon: 'person',
            iconColor: baseThemeStyles.colors.iconData,
            title: typeof account.name === 'object' ? account.name?.full || account.name?.first || account.username : account.name || account.username,
            subtitle: account.email || account.username,
            onPress: () => {
              _sonner.toast.info(t('accountOverview.items.accountSwitcher.switchPrompt', {
                username: account.username
              }) || `Switch to ${account.username}?`);
            },
            customContent: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
              children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
                style: styles.userIcon,
                children: account.avatar ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
                  source: {
                    uri: oxyServices.getFileDownloadUrl(account.avatar, 'thumb')
                  },
                  style: styles.accountAvatarImage
                }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
                  style: styles.accountAvatarFallback,
                  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
                    style: styles.accountAvatarText,
                    children: account.username?.charAt(0).toUpperCase() || '?'
                  })
                })
              }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_OxyIcon.default, {
                name: "chevron-forward",
                size: 16,
                color: "#ccc"
              })]
            })
          }))
        }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.GroupedSection, {
          items: [{
            id: 'no-accounts',
            icon: 'person-outline',
            iconColor: '#ccc',
            title: t('accountOverview.additional.noAccounts.title') || 'No other accounts',
            subtitle: t('accountOverview.additional.noAccounts.subtitle') || 'Add another account to switch between them'
          }]
        })
      }), showMoreAccounts && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Section, {
        title: t('accountOverview.sections.accountManagement') || 'Account Management',
        children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.GroupedSection, {
          items: [{
            id: 'add-account',
            icon: 'add',
            iconColor: baseThemeStyles.colors.iconSecurity,
            title: t('accountOverview.items.addAccount.title') || 'Add Another Account',
            subtitle: t('accountOverview.items.addAccount.subtitle') || 'Sign in with a different account',
            onPress: handleAddAccount
          }, {
            id: 'sign-out-all',
            icon: 'log-out',
            iconColor: baseThemeStyles.colors.iconSharing,
            title: t('accountOverview.items.signOutAll.title') || 'Sign out of all accounts',
            subtitle: t('accountOverview.items.signOutAll.subtitle') || 'Remove all accounts from this device',
            onPress: handleSignOutAll
          }]
        })
      }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Section, {
        title: t('accountOverview.sections.quickActions'),
        children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.GroupedSection, {
          items: [{
            id: 'account-switcher',
            icon: 'people',
            iconColor: baseThemeStyles.colors.iconData,
            title: showMoreAccounts ? t('accountOverview.items.accountSwitcher.titleHide') : t('accountOverview.items.accountSwitcher.titleShow'),
            subtitle: showMoreAccounts ? t('accountOverview.items.accountSwitcher.subtitleHide') : additionalAccountsData.length > 0 ? t('accountOverview.items.accountSwitcher.subtitleSwitchBetween', {
              count: String(additionalAccountsData.length + 1)
            }) : loadingAdditionalAccounts ? t('accountOverview.items.accountSwitcher.subtitleLoading') : t('accountOverview.items.accountSwitcher.subtitleManageMultiple'),
            onPress: () => setShowMoreAccounts(!showMoreAccounts)
          }, {
            id: 'history-view',
            icon: 'time',
            iconColor: baseThemeStyles.colors.iconSecurity,
            title: t('accountOverview.items.history.title') || 'History',
            subtitle: t('accountOverview.items.history.subtitle') || 'View and manage your search history',
            onPress: () => navigate?.('HistoryView')
          }, {
            id: 'saves-collections',
            icon: 'bookmark',
            iconColor: baseThemeStyles.colors.iconStorage,
            title: t('accountOverview.items.saves.title') || 'Saves & Collections',
            subtitle: t('accountOverview.items.saves.subtitle') || 'View your saved items and collections',
            onPress: () => navigate?.('SavesCollections')
          }, {
            id: 'download-data',
            icon: 'download',
            iconColor: baseThemeStyles.colors.iconPersonalInfo,
            title: t('accountOverview.items.downloadData.title'),
            subtitle: t('accountOverview.items.downloadData.subtitle'),
            onPress: handleDownloadData
          }, {
            id: 'delete-account',
            icon: 'trash',
            iconColor: baseThemeStyles.colors.iconSharing,
            title: t('accountOverview.items.deleteAccount.title'),
            subtitle: t('accountOverview.items.deleteAccount.subtitle'),
            onPress: handleDeleteAccount
          }]
        })
      }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Section, {
        title: t('accountOverview.sections.support'),
        children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.GroupedSection, {
          items: [{
            id: 'search-settings',
            icon: 'search',
            iconColor: baseThemeStyles.colors.iconSecurity,
            title: t('accountOverview.items.searchSettings.title') || 'Search Settings',
            subtitle: t('accountOverview.items.searchSettings.subtitle') || 'SafeSearch and personalization',
            onPress: () => navigate?.('SearchSettings')
          }, {
            id: 'language-settings',
            icon: 'language',
            iconColor: baseThemeStyles.colors.iconPersonalInfo,
            title: t('accountOverview.items.language.title') || 'Language',
            subtitle: t('accountOverview.items.language.subtitle') || 'Choose your preferred language',
            onPress: () => navigate?.('LanguageSelector')
          }, {
            id: 'account-preferences',
            icon: 'settings',
            iconColor: '#8E8E93',
            title: t('accountOverview.items.preferences.title'),
            subtitle: t('accountOverview.items.preferences.subtitle'),
            onPress: () => _sonner.toast.info(t('accountOverview.items.preferences.coming'))
          }, {
            id: 'help-support',
            icon: 'help-circle',
            iconColor: baseThemeStyles.colors.iconSecurity,
            title: t('accountOverview.items.help.title'),
            subtitle: t('accountOverview.items.help.subtitle'),
            onPress: () => navigate?.('HelpSupport')
          }, {
            id: 'privacy-policy',
            icon: 'shield-checkmark',
            iconColor: baseThemeStyles.colors.iconPersonalInfo,
            title: t('accountOverview.items.privacyPolicy.title') || 'Privacy Policy',
            subtitle: t('accountOverview.items.privacyPolicy.subtitle') || 'How we handle your data',
            onPress: () => navigate?.('LegalDocuments', {
              initialStep: 1
            })
          }, {
            id: 'terms-of-service',
            icon: 'document-text',
            iconColor: baseThemeStyles.colors.iconSecurity,
            title: t('accountOverview.items.termsOfService.title') || 'Terms of Service',
            subtitle: t('accountOverview.items.termsOfService.subtitle') || 'Terms and conditions of use',
            onPress: () => navigate?.('LegalDocuments', {
              initialStep: 2
            })
          }, {
            id: 'connected-apps',
            icon: 'link',
            iconColor: baseThemeStyles.colors.iconPersonalInfo,
            title: t('accountOverview.items.connectedApps.title'),
            subtitle: t('accountOverview.items.connectedApps.subtitle'),
            onPress: () => _sonner.toast.info(t('accountOverview.items.connectedApps.coming'))
          }, {
            id: 'about',
            icon: 'information-circle',
            iconColor: '#8E8E93',
            title: t('accountOverview.items.about.title'),
            subtitle: t('accountOverview.items.about.subtitle'),
            onPress: () => navigate?.('AppInfo')
          }]
        })
      }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Section, {
        title: t('accountOverview.sections.actions'),
        children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.GroupedItem, {
          icon: "log-out",
          iconColor: "#FF3B30",
          title: t('accountOverview.items.signOut.title'),
          subtitle: t('accountOverview.items.signOut.subtitle'),
          onPress: confirmLogout,
          isFirst: true,
          isLast: true,
          showChevron: false
        })
      })]
    })
  });
};
const styles = _reactNative.StyleSheet.create({
  container: {
    flex: 1
  },
  content: {
    flex: 1
  },
  scrollContent: (0, _spacing.createScreenContentStyle)(_spacing.HEADER_PADDING_TOP_OVERVIEW),
  headerSection: {
    alignItems: 'center',
    marginBottom: _spacing.SECTION_GAP,
    paddingTop: _spacing.HEADER_PADDING_TOP_OVERVIEW
  },
  avatarSectionWrapper: {
    alignItems: 'center',
    justifyContent: 'center',
    width: '100%'
  },
  avatarContainer: {
    position: 'relative',
    alignItems: 'center',
    justifyContent: 'center',
    width: '100%',
    maxWidth: 600,
    minHeight: 100,
    overflow: 'hidden',
    alignSelf: 'center',
    aspectRatio: 6
  },
  lottieBackground: {
    position: 'absolute',
    width: '100%',
    maxWidth: 600,
    minHeight: 100,
    top: 0,
    left: 0,
    right: 0,
    bottom: 0,
    zIndex: 0,
    aspectRatio: 6
  },
  avatarWrapper: {
    zIndex: 1,
    position: 'absolute',
    alignItems: 'center',
    justifyContent: 'center',
    width: 100,
    height: 100,
    left: '50%',
    marginLeft: -50,
    top: 0
  },
  nameWrapper: {
    marginTop: 12,
    alignItems: 'center',
    justifyContent: 'center'
  },
  welcomeText: {
    fontSize: 28,
    fontWeight: '600',
    marginBottom: 8,
    fontFamily: _fonts.fontFamilies.phuduBold,
    maxWidth: '90%'
  },
  welcomeSubtext: {
    fontSize: 16,
    fontWeight: '400',
    opacity: 0.6
  },
  userIcon: {
    marginRight: 12
  },
  manageButton: {
    paddingHorizontal: 16,
    paddingVertical: 8,
    borderRadius: 16
    // backgroundColor should be applied inline using colors.iconSecurity
  },
  manageButtonText: {
    color: '#fff',
    fontSize: 14,
    fontWeight: '500'
  },
  accountAvatarImage: {
    width: 40,
    height: 40,
    borderRadius: 20
  },
  accountAvatarFallback: {
    width: 40,
    height: 40,
    borderRadius: 20,
    backgroundColor: '#d169e5',
    alignItems: 'center',
    justifyContent: 'center'
  },
  accountAvatarText: {
    color: 'white',
    fontSize: 18,
    fontWeight: 'bold'
  },
  message: {
    fontSize: 16,
    textAlign: 'center',
    marginTop: 24,
    color: '#333'
  },
  loadingContainer: {
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'center',
    paddingVertical: 20,
    gap: 12
  },
  loadingText: {
    fontSize: 16,
    color: '#666'
  }
});
var _default = exports.default = /*#__PURE__*/_react.default.memo(AccountOverviewScreen);
//# sourceMappingURL=AccountOverviewScreen.js.map