'use client'
import { __awaiter } from '../../../../../_virtual/_tslib.js';
import { createEmailVerification } from '../../../data/api/email/email.js';
import '@dynamic-labs/sdk-api-core';
import '@dynamic-labs/utils';
import '@dynamic-labs/iconic';
import '@dynamic-labs/wallet-connector-core';
import 'react';
import 'react/jsx-runtime';
import '../../ViewContext/ViewContext.js';
import '../../../shared/logger.js';
import '@dynamic-labs/wallet-book';
import '../../../utils/constants/colors.js';
import '../../../utils/constants/values.js';
import '../../../shared/consts/index.js';
import '@dynamic-labs-sdk/client/core';
import 'eventemitter3';
import '@dynamic-labs-sdk/client';
import '../../../config/ApiEndpoint.js';
import '@dynamic-labs/multi-wallet';
import 'react-international-phone';
import '../../../store/state/nonce/nonce.js';
import '@dynamic-labs-wallet/browser-wallet-client';
import '../../../store/state/dynamicContextProps/dynamicContextProps.js';
import '../../../store/state/primaryWalletId/primaryWalletId.js';
import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
import '../../../utils/functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
import '../../../events/dynamicEvents.js';
import '@dynamic-labs/locale';
import { buildEmailOtpHandler } from './buildEmailOtpHandler/buildEmailOtpHandler.js';
import { persistOtpVerificationState } from './otpVerificationStorage/otpVerificationStorage.js';

const createEmailHandler = (environmentId, embeddedWalletSessionKeys) => (email, captchaToken) => __awaiter(void 0, void 0, void 0, function* () {
    const createEmailVerificationResponse = yield createEmailVerification({
        captchaToken,
        email,
        environmentId,
    });
    const { verificationUUID } = createEmailVerificationResponse;
    persistOtpVerificationState({
        captchaToken,
        destination: email,
        type: 'email',
        verificationUUID,
    });
    return buildEmailOtpHandler({
        captchaToken,
        email,
        embeddedWalletSessionKeys,
        environmentId,
        initialVerificationUUID: verificationUUID,
    });
});

export { createEmailHandler };
