'use client'
import '@dynamic-labs/iconic';
import '@dynamic-labs/wallet-connector-core';
import 'react';
import 'react/jsx-runtime';
import '../../../ViewContext/ViewContext.js';
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 { useInternalDynamicEvents } from '../../../../utils/hooks/events/useDynamicEvents/useDynamicEvents.js';
import '../../../../../../_virtual/_tslib.js';
import '../../DynamicContext.js';
import '../../../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
import '../../../../store/state/authMode/authMode.js';
import '../../../CaptchaContext/CaptchaContext.js';
import '../../../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 '../../../../events/dynamicEvents.js';
import '@dynamic-labs/locale';
import '../../../../store/state/dynamicContextProps/dynamicContextProps.js';
import '../../../../store/state/primaryWalletId/primaryWalletId.js';
import '../../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
import '../../../AccessDeniedContext/AccessDeniedContext.js';
import '../../../AccountExistsContext/AccountExistsContext.js';
import '../../../UserWalletsContext/UserWalletsContext.js';
import '../../../VerificationContext/VerificationContext.js';
import 'react-dom';
import '../../../../utils/functions/compareChains/compareChains.js';
import '../../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
import '../../../ThemeContext/ThemeContext.js';
import '../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
import 'bs58';
import '@dynamic-labs/types';
import '../../../SocialRedirectContext/SocialRedirectContext.js';
import '../../../LoadingContext/LoadingContext.js';
import '../../../WalletContext/WalletContext.js';
import '../../../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
import 'yup';
import '../../../MockContext/MockContext.js';
import '../../../../views/CollectUserDataView/useFields.js';
import '../../../FieldsStateContext/FieldsStateContext.js';
import '../../../UserFieldEditorContext/UserFieldEditorContext.js';
import '@dynamic-labs/rpc-providers';
import '../../../../store/state/walletOptions/walletOptions.js';
import 'react-i18next';
import '../../../../components/Accordion/components/AccordionItem/AccordionItem.js';
import '../../../../components/Alert/Alert.js';
import '../../../../components/ShadowDOM/ShadowDOM.js';
import '../../../../components/IconButton/IconButton.js';
import '../../../../components/InlineWidget/InlineWidget.js';
import '../../../../components/Input/Input.js';
import '../../../../components/IsBrowser/IsBrowser.js';
import '../../../../components/MenuList/Dropdown/Dropdown.js';
import '../../../../components/OverlayCard/OverlayCard.js';
import '../../../../components/Transition/ZoomTransition/ZoomTransition.js';
import '../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
import '../../../../components/Transition/OpacityTransition/OpacityTransition.js';
import '../../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
import '../../../../components/Popper/Popper/Popper.js';
import '../../../../components/Popper/PopperContext/PopperContext.js';
import 'react-focus-lock';
import 'qrcode';
import 'formik';
import '../../../../utils/hooks/useSubdomainCheck/useSubdomainCheck.js';
import '../../../WalletGroupContext/WalletGroupContext.js';
import '../../../IpConfigurationContext/IpConfigurationContext.js';
import '../../../ConnectWithOtpContext/ConnectWithOtpContext.js';
import '../../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
import '@hcaptcha/react-hcaptcha';
import '../../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
import '../../../../widgets/DynamicWidget/helpers/convertExchangeKeyAndProviderEnum.js';
import '../../../../views/ExchangeWhitelistWarning/ExchangeWhitelistWarning.js';
import '../../../ErrorContext/hooks/useErrorText/useErrorText.js';
import '../../../FooterAnimationContext/index.js';
import '../../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.js';
import '../../../PasskeyContext/PasskeyContext.js';
import '../../../OnrampContext/OnrampContext.js';
import '../../../../store/state/sendBalances.js';
import '../../../../store/state/connectorsInitializing/connectorsInitializing.js';
import '../../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.js';
import '../../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
import '../../../../views/TransactionConfirmationView/TransactionConfirmationView.js';
import '../../../../widgets/DynamicWidget/components/PasskeyCard/PasskeyCard.js';
import '../../../../widgets/DynamicWidget/views/CryptoComOnramp/CryptoComOnramp.js';
import '../../../../../index.js';
import '../../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.js';
import '../../../../store/state/tokenBalances.js';
import '../../../../store/state/multichainBalances.js';
import '../../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';

/** Ties the customer callbacks to our events, such that our events will also trigger the callbacks */
const useTieCallbacksToEvents = ({ clientCallbacks, user, }) => {
    useInternalDynamicEvents('emailVerificationResult', (result, email) => {
        var _a;
        return (_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onOtpVerificationResult) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, result, {
            type: 'email',
            value: email,
        });
    });
    useInternalDynamicEvents('smsVerificationResult', (result, phoneData) => {
        var _a;
        return (_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onOtpVerificationResult) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, result, {
            type: 'sms',
            value: phoneData,
        });
    });
    useInternalDynamicEvents('authFlowCancelled', () => { var _a; return (_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onAuthFlowCancel) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks); });
    useInternalDynamicEvents('authFlowOpen', () => {
        var _a;
        (_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onAuthFlowOpen) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks);
    });
    useInternalDynamicEvents('authFlowClose', () => {
        var _a;
        (_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onAuthFlowClose) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks);
    });
    useInternalDynamicEvents('walletAdded', (wallet, userWallets) => {
        var _a;
        logger.debug('[walletAdded]', { userWallets, wallet });
        (_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onWalletAdded) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, { userWallets, wallet });
    });
    useInternalDynamicEvents('walletRemoved', (wallet, userWallets) => {
        var _a;
        logger.debug('[walletRemoved]', { userWallets, wallet });
        (_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onWalletRemoved) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, { userWallets, wallet });
    });
    useInternalDynamicEvents('embeddedWalletCreated', (_wallet, jwtVerifiedCredential, user) => {
        var _a;
        logger.debug('[embeddedWalletCreated]', {
            _wallet,
            jwtVerifiedCredential,
            user,
        });
        (_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onEmbeddedWalletCreated) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, jwtVerifiedCredential, user);
    });
    useInternalDynamicEvents('logout', () => {
        var _a;
        (_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onLogout) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, user);
    });
    useInternalDynamicEvents('authFailure', (data, reason) => {
        var _a;
        logger.debug('[authFailure]', { data, reason });
        (_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onAuthFailure) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, data, reason);
    });
    useInternalDynamicEvents('authInit', (data) => {
        var _a;
        logger.debug('[authInit]', { data });
        (_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onAuthInit) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, data);
    });
    useInternalDynamicEvents('userProfileUpdated', (user) => {
        var _a;
        (_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onUserProfileUpdate) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, user);
    });
    useInternalDynamicEvents('walletTabSelected', (props) => {
        var _a;
        (_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onWalletTabSelected) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, props);
    });
    useInternalDynamicEvents('walletConnectionFailed', (walletConnector, error) => {
        var _a;
        (_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onWalletConnectionFailed) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, walletConnector, error);
    });
};

export { useTieCallbacksToEvents };
