'use client'
import { jsxs, jsx } from 'react/jsx-runtime';
import { useRef, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { classNames } from '../../utils/functions/classNames/classNames.js';
import '../../components/Accordion/components/AccordionItem/AccordionItem.js';
import { ReactComponent as SvgExclamation } from '../../shared/assets/exclamation.js';
import '@dynamic-labs/iconic';
import '../../context/ViewContext/ViewContext.js';
import { ReactComponent as SvgWarningRed } from '../../shared/assets/warning-red.js';
import { ReactComponent as SvgBackup } from '../../shared/assets/backup.js';
import '../../../../_virtual/_tslib.js';
import '@dynamic-labs/wallet-connector-core';
import { logger } from '../../shared/logger.js';
import '@dynamic-labs/wallet-book';
import '@dynamic-labs/utils';
import '../../utils/constants/colors.js';
import '../../utils/constants/values.js';
import '@dynamic-labs/sdk-api-core';
import '../../shared/consts/index.js';
import '../../components/Alert/Alert.js';
import '../../events/dynamicEvents.js';
import { useDynamicContext } from '../../context/DynamicContext/useDynamicContext/useDynamicContext.js';
import '../../context/DynamicContext/DynamicContext.js';
import '../../context/CaptchaContext/CaptchaContext.js';
import '../../context/ErrorContext/ErrorContext.js';
import '@dynamic-labs/multi-wallet';
import 'react-international-phone';
import '../../store/state/nonce/nonce.js';
import '@dynamic-labs-sdk/client/core';
import '../../client/client.js';
import '@dynamic-labs-sdk/client';
import '../../config/ApiEndpoint.js';
import { useProjectSettings } from '../../client/extension/projectSettings/useProjectSettings/useProjectSettings.js';
import '@dynamic-labs/locale';
import '../../store/state/dynamicContextProps/dynamicContextProps.js';
import '../../store/state/primaryWalletId/primaryWalletId.js';
import '../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
import '../../context/AccessDeniedContext/AccessDeniedContext.js';
import '../../context/AccountExistsContext/AccountExistsContext.js';
import '../../context/UserWalletsContext/UserWalletsContext.js';
import '../../store/state/authMode/authMode.js';
import '../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
import '../../context/VerificationContext/VerificationContext.js';
import 'react-dom';
import '../../utils/functions/compareChains/compareChains.js';
import '../Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
import '../../context/ThemeContext/ThemeContext.js';
import '../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
import 'bs58';
import '@dynamic-labs/types';
import '../../context/SocialRedirectContext/SocialRedirectContext.js';
import '../../context/LoadingContext/LoadingContext.js';
import '../../context/WalletContext/WalletContext.js';
import '../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
import 'yup';
import '../../context/MockContext/MockContext.js';
import '../CollectUserDataView/useFields.js';
import '../../context/FieldsStateContext/FieldsStateContext.js';
import '../../context/UserFieldEditorContext/UserFieldEditorContext.js';
import '@dynamic-labs/rpc-providers';
import '../../store/state/walletOptions/walletOptions.js';
import { PoweredByDynamic } from '../../components/PoweredByDynamic/PoweredByDynamic.js';
import '../../context/FooterAnimationContext/index.js';
import '../../components/ShadowDOM/ShadowDOM.js';
import '../../components/Transition/ZoomTransition/ZoomTransition.js';
import '../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
import '../../components/Transition/OpacityTransition/OpacityTransition.js';
import '../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.js';
import '../../context/WalletGroupContext/WalletGroupContext.js';
import '../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
import 'react-focus-lock';
import { Icon } from '../../components/Icon/Icon.js';
import { Typography } from '../../components/Typography/Typography.js';
import '../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
import '../../components/IconButton/IconButton.js';
import { TypographyButton } from '../../components/TypographyButton/TypographyButton.js';
import '../../components/MenuList/Dropdown/Dropdown.js';
import 'formik';
import '../../utils/hooks/useSubdomainCheck/useSubdomainCheck.js';
import '../../store/state/sendBalances.js';
import '../../components/Input/Input.js';
import '../../components/OverlayCard/OverlayCard.js';
import '../TransactionConfirmationView/TransactionConfirmationView.js';
import '../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
import '../../context/PasskeyContext/PasskeyContext.js';
import '../../widgets/DynamicWidget/components/PasskeyCard/PasskeyCard.js';
import '../../widgets/DynamicWidget/views/CryptoComOnramp/CryptoComOnramp.js';
import '../../context/OnrampContext/OnrampContext.js';
import '../../../index.js';
import '../../widgets/DynamicWidget/helpers/convertExchangeKeyAndProviderEnum.js';
import 'qrcode';
import '../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.js';
import { NeedHelpSection } from '../../components/NeedHelpSection/NeedHelpSection.js';
import '../../context/IpConfigurationContext/IpConfigurationContext.js';
import '../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
import '../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
import '@hcaptcha/react-hcaptcha';
import '../ExchangeWhitelistWarning/ExchangeWhitelistWarning.js';
import '../../context/ErrorContext/hooks/useErrorText/useErrorText.js';
import '../MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.js';
import '../../store/state/connectorsInitializing/connectorsInitializing.js';
import '../../store/state/tokenBalances.js';
import '../../store/state/multichainBalances.js';
import '../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
import '../../components/InlineWidget/InlineWidget.js';
import '../../components/IsBrowser/IsBrowser.js';
import '../../components/Popper/Popper/Popper.js';
import '../../components/Popper/PopperContext/PopperContext.js';

const BackupUnsuccessfulView = () => {
    var _a, _b;
    const { t } = useTranslation();
    const projectSettings = useProjectSettings();
    const isProperlyMounted = useRef(false);
    const supportEmail = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.general) === null || _a === void 0 ? void 0 : _a.supportEmail;
    const supportUrls = (_b = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.general) === null || _b === void 0 ? void 0 : _b.supportUrls;
    const hasContactInfo = Boolean(supportEmail || Object.keys(supportUrls || {}).length > 0);
    const { handleLogOut } = useDynamicContext();
    const refreshPage = () => {
        window.location.reload();
    };
    // force refresh on component unmount
    useEffect(() => {
        const timer = setTimeout(() => {
            isProperlyMounted.current = true;
        }, 100);
        return () => {
            clearTimeout(timer);
            // Only refresh if component was properly mounted and is now being unmounted
            if (isProperlyMounted.current) {
                setTimeout(() => {
                    refreshPage();
                }, 0);
            }
        };
    }, []);
    return (jsxs("div", { className: 'backup-unsuccessful-view', children: [jsxs("div", { className: 'backup-unsuccessful-view__content', children: [jsxs("div", { className: 'backup-icon-container', children: [jsx(Icon, { color: 'brand-primary', children: jsx(SvgBackup, { className: 'backup-icon', width: 64, height: 64 }) }), jsxs("div", { className: 'warning-icon-container', children: [jsx(SvgWarningRed, { className: 'combined-icon', width: 40, height: 40 }), jsx(SvgExclamation, { className: 'exclamation-icon', width: 20, height: 20, style: {
                                            left: '50%',
                                            position: 'absolute',
                                            top: '50%',
                                            transform: 'translate(-50%, -50%)',
                                        } })] })] }), jsx(Typography, { variant: 'body_normal', className: 'backup-message', color: 'primary', copykey: 'dyn_waas.backup_unsuccessful.description', children: t('dyn_waas.backup_unsuccessful.description') }), jsx("div", { className: classNames('button-group', {
                            'button-group--with-help-section': hasContactInfo,
                        }), children: jsx(TypographyButton, { buttonClassName: 'retry-button', buttonVariant: 'brand-primary', type: 'submit', onClick: () => refreshPage(), copykey: 'dyn_waas.backup_unsuccessful.try_again', typographyProps: {
                                color: 'inherit',
                            }, children: t('dyn_waas.backup_unsuccessful.try_again') }) }), jsx("div", { className: classNames('button-group', 'logout-group', {
                            'button-group--with-help-section': hasContactInfo,
                        }), children: jsx(TypographyButton, { buttonClassName: 'logout-button', buttonVariant: 'tertiary', type: 'submit', onClick: () => {
                                logger.error('BackupUnsuccessfulView: Could not backup wallet, logging out');
                                handleLogOut();
                            }, copykey: 'dyn_waas.backup_unsuccessful.log_out', typographyProps: {
                                color: 'inherit',
                                weight: 'medium',
                            }, children: t('dyn_waas.backup_unsuccessful.log_out') }) }), jsx("div", { className: 'need-help-section', children: jsx(NeedHelpSection, {}) })] }), jsx(PoweredByDynamic, { asFooter: true })] }));
};

export { BackupUnsuccessfulView, BackupUnsuccessfulView as default };
