'use client'
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var reactI18next = require('react-i18next');
var iconic = require('@dynamic-labs/iconic');
require('@dynamic-labs/utils');
require('../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
var error = require('../../shared/assets/error.cjs');
var ViewContext = require('../../context/ViewContext/ViewContext.cjs');
require('../../../../_virtual/_tslib.cjs');
require('@dynamic-labs/wallet-connector-core');
require('../../shared/logger.cjs');
require('@dynamic-labs/wallet-book');
require('../../utils/constants/colors.cjs');
require('../../utils/constants/values.cjs');
require('@dynamic-labs/sdk-api-core');
require('../../shared/consts/index.cjs');
require('../../components/Alert/Alert.cjs');
require('../../events/dynamicEvents.cjs');
require('../../context/DynamicContext/DynamicContext.cjs');
require('../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
require('../../store/state/authMode/authMode.cjs');
var useInternalDynamicContext = require('../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
require('../../context/CaptchaContext/CaptchaContext.cjs');
require('../../context/ErrorContext/ErrorContext.cjs');
require('@dynamic-labs/multi-wallet');
require('react-international-phone');
require('../../store/state/nonce/nonce.cjs');
var pixelToRem = require('../../utils/functions/pixelToRem/pixelToRem.cjs');
require('@dynamic-labs-sdk/client/core');
require('../../client/client.cjs');
require('@dynamic-labs-sdk/client');
require('../../config/ApiEndpoint.cjs');
require('@dynamic-labs/locale');
require('../../store/state/dynamicContextProps/dynamicContextProps.cjs');
require('../../store/state/primaryWalletId/primaryWalletId.cjs');
require('../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
var AccessDeniedContext = require('../../context/AccessDeniedContext/AccessDeniedContext.cjs');
require('../../context/AccountExistsContext/AccountExistsContext.cjs');
require('../../context/UserWalletsContext/UserWalletsContext.cjs');
var VerificationContext = require('../../context/VerificationContext/VerificationContext.cjs');
require('react-dom');
require('../../utils/functions/compareChains/compareChains.cjs');
require('../Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
require('../../context/ThemeContext/ThemeContext.cjs');
require('../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
require('bs58');
require('@dynamic-labs/types');
require('../../context/SocialRedirectContext/SocialRedirectContext.cjs');
require('../../context/LoadingContext/LoadingContext.cjs');
require('../../context/WalletContext/WalletContext.cjs');
require('../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
require('yup');
require('../../context/MockContext/MockContext.cjs');
require('../CollectUserDataView/useFields.cjs');
require('../../context/FieldsStateContext/FieldsStateContext.cjs');
require('../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
require('@dynamic-labs/rpc-providers');
require('../../store/state/walletOptions/walletOptions.cjs');
var Typography = require('../../components/Typography/Typography.cjs');
require('../../context/FooterAnimationContext/index.cjs');
require('../../components/ShadowDOM/ShadowDOM.cjs');
require('../../components/Transition/ZoomTransition/ZoomTransition.cjs');
require('../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
require('../../components/Transition/OpacityTransition/OpacityTransition.cjs');
require('../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.cjs');
require('../../context/WalletGroupContext/WalletGroupContext.cjs');
require('../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
require('react-focus-lock');
var shortenWalletAddress = require('../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.cjs');
var AuthProviderIcon = require('../../components/AuthProviderIcon/AuthProviderIcon.cjs');
require('../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
require('../../components/IconButton/IconButton.cjs');
var TypographyButton = require('../../components/TypographyButton/TypographyButton.cjs');
require('../../components/MenuList/Dropdown/Dropdown.cjs');
require('formik');
require('../../utils/hooks/useSubdomainCheck/useSubdomainCheck.cjs');
require('../../store/state/sendBalances.cjs');
require('../../components/Input/Input.cjs');
require('../../components/OverlayCard/OverlayCard.cjs');
require('../TransactionConfirmationView/TransactionConfirmationView.cjs');
require('../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
require('../../context/PasskeyContext/PasskeyContext.cjs');
require('../../widgets/DynamicWidget/components/PasskeyCard/PasskeyCard.cjs');
require('../../widgets/DynamicWidget/views/CryptoComOnramp/CryptoComOnramp.cjs');
require('../../context/OnrampContext/OnrampContext.cjs');
require('../../../index.cjs');
require('../../widgets/DynamicWidget/helpers/convertExchangeKeyAndProviderEnum.cjs');
require('qrcode');
require('../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.cjs');
var StatusDot = require('../../components/StatusDot/StatusDot.cjs');
var getSocialNetworkIcon = require('../../utils/functions/getSocialNetworkIcon/getSocialNetworkIcon.cjs');
var useNoAccessText = require('./useNoAccessText.cjs');
var IconWithStatus = require('../../components/IconWithStatus/IconWithStatus.cjs');
require('../../context/IpConfigurationContext/IpConfigurationContext.cjs');
require('../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
require('../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
require('@hcaptcha/react-hcaptcha');
require('../ExchangeWhitelistWarning/ExchangeWhitelistWarning.cjs');
require('../../context/ErrorContext/hooks/useErrorText/useErrorText.cjs');
require('../MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.cjs');
require('../../store/state/connectorsInitializing/connectorsInitializing.cjs');
require('../../store/state/tokenBalances.cjs');
require('../../store/state/multichainBalances.cjs');
require('../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
require('../../components/InlineWidget/InlineWidget.cjs');
require('../../components/IsBrowser/IsBrowser.cjs');
require('../../components/Popper/Popper/Popper.cjs');
require('../../components/Popper/PopperContext/PopperContext.cjs');

const NoAccess = () => {
    const { deniedAddress, setDeniedAddress, setDeniedOauthProvider, deniedOauthProvider, deniedOauthUsername, } = AccessDeniedContext.useAccessDeniedContext();
    const { t } = reactI18next.useTranslation();
    // deniedOauthProvider can be undefined
    const accessIcon = deniedOauthProvider
        ? iconic.findSocialIcon(deniedOauthProvider)
        : undefined;
    const { selectedWalletConnector: walletConnector, socialMediaIconUrl, notInTheListImageUrl, accessDeniedButton, } = useInternalDynamicContext.useInternalDynamicContext();
    const { displayedDestination: email } = VerificationContext.useVerification();
    const { clearStackAndPushInitialView } = ViewContext.useViewContext();
    const { _socialMediaLinkText, _socialMediaUrl, isAccessListView, isGateBlockedView, subtitle, title, buttonTitle: _buttonTitle, } = useNoAccessText.useNoAccessText();
    const handleChangeWallet = () => {
        clearStackAndPushInitialView();
        setDeniedAddress('');
        setDeniedOauthProvider(undefined);
        walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.endSession();
    };
    const SocialMediaIcon = !socialMediaIconUrl || typeof socialMediaIconUrl === 'string'
        ? null
        : getSocialNetworkIcon.getSocialNetworkIcon(Object.keys(socialMediaIconUrl)[0]);
    const Icon = React.useMemo(() => {
        if (walletConnector) {
            return jsxRuntime.jsx(AuthProviderIcon.AuthProviderIcon, {});
        }
        return (jsxRuntime.jsx(IconWithStatus.IconWithStatus, { containerClassName: 'wallet-no-access__icon--verified', Icon: accessIcon !== null && accessIcon !== void 0 ? accessIcon : iconic.SignInWithEmailIcon, iconSize: 50, InnerIcon: error.ReactComponent, variant: 'red' }));
    }, [accessIcon, walletConnector]);
    const formattedAddress = shortenWalletAddress.shortenWalletAddress(deniedAddress);
    const buttonTitle = (accessDeniedButton === null || accessDeniedButton === void 0 ? void 0 : accessDeniedButton.title) || _buttonTitle;
    const buttonAction = (accessDeniedButton === null || accessDeniedButton === void 0 ? void 0 : accessDeniedButton.action) || handleChangeWallet;
    const emailOrAddress = email !== null && email !== void 0 ? email : formattedAddress;
    const correctDisplay = deniedOauthProvider === undefined ? emailOrAddress : deniedOauthUsername;
    const showNoInTheListImage = Boolean(notInTheListImageUrl) && (isAccessListView || isGateBlockedView);
    const showSocialMediaIcon = SocialMediaIcon && (isAccessListView || isGateBlockedView);
    return (jsxRuntime.jsxs("div", { className: 'wallet-no-access__container', children: [showNoInTheListImage && (jsxRuntime.jsx("img", { src: notInTheListImageUrl, alt: t('dyn_no_access.not_in_the_list_image_alt'), className: 'wallet-no-access__image', copykey: 'dyn_no_access.not_in_the_list_image_alt' })), jsxRuntime.jsxs("div", { className: 'wallet-no-access__main', children: [jsxRuntime.jsxs("div", { className: 'wallet-no-access__user-info-container', children: [Icon, jsxRuntime.jsxs("div", { "data-testid": 'walletAddress', className: 'wallet-no-access__wallet-address-container', children: [walletConnector && (jsxRuntime.jsx(StatusDot.StatusDot, { variant: 'red', containerClassName: 'user-info__status-dot' })), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', weight: 'medium', className: 'wallet-no-access__wallet-address', children: correctDisplay })] })] }), jsxRuntime.jsxs("div", { className: 'wallet-no-access__content', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', className: 'wallet-no-access__content--primary', children: title }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'wallet-no-access__content--secondary', children: subtitle })] }), jsxRuntime.jsx(TypographyButton.TypographyButton, { onClick: buttonAction, className: 'wallet-no-access__button--primary', expanded: true, buttonPadding: 'large', children: buttonTitle }), _socialMediaUrl && _socialMediaLinkText && (jsxRuntime.jsxs("div", { className: 'wallet-no-access__social-info-container', children: [jsxRuntime.jsxs("a", { href: _socialMediaUrl, className: 'wallet-no-access__waitlist-link', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'button_primary', color: 'primary', children: _socialMediaLinkText }), showSocialMediaIcon && (jsxRuntime.jsx(SocialMediaIcon, { className: 'wallet-no-access__social-icon', style: {
                                            height: pixelToRem.pixelToRem(24),
                                            width: pixelToRem.pixelToRem(24),
                                        } }))] }), typeof socialMediaIconUrl === 'string' && (jsxRuntime.jsx("img", { alt: 'social media', src: socialMediaIconUrl, style: {
                                    height: '1.5rem',
                                    width: '1.5rem',
                                } }))] }))] })] }));
};

exports.NoAccess = NoAccess;
