'use client'
'use strict';

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

var _tslib = require('../../../../../_virtual/_tslib.cjs');
var React = require('react');
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
require('@dynamic-labs-sdk/client/core');
require('../../../client/client.cjs');
require('@dynamic-labs-sdk/client');
require('../../../config/ApiEndpoint.cjs');
require('@dynamic-labs/iconic');
require('@dynamic-labs/wallet-connector-core');
require('react/jsx-runtime');
require('../../../context/ViewContext/ViewContext.cjs');
require('../../../shared/logger.cjs');
require('@dynamic-labs/wallet-book');
require('@dynamic-labs/utils');
require('../../../utils/constants/colors.cjs');
require('../../../utils/constants/values.cjs');
require('../../../shared/consts/index.cjs');
require('@dynamic-labs/multi-wallet');
require('react-international-phone');
require('../../../store/state/nonce/nonce.cjs');
require('@dynamic-labs/locale');
require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
require('../../../events/dynamicEvents.cjs');
var getUserProfile = require('../../../client/extension/user/getUserProfile/getUserProfile.cjs');
var isMfaMethodEnabled = require('../../../utils/functions/isMfaMethodEnabled/isMfaMethodEnabled.cjs');
var useGetUserMfaMethods = require('../../../utils/hooks/useGetUserMfaMethods/useGetUserMfaMethods.cjs');

const PASSKEY_OPTION = {
    Icon: undefined,
    descriptionKey: 'dyn_mfa.choose_device_view.passkey_description',
    labelKey: 'dyn_mfa.choose_device_view.passkey',
    type: sdkApiCore.MFADeviceType.Passkey,
};
const TOTP_OPTION = {
    Icon: undefined,
    descriptionKey: 'dyn_mfa.choose_device_view.authenticator_app_description',
    labelKey: 'dyn_mfa.choose_device_view.authenticator_app',
    type: sdkApiCore.MFADeviceType.Totp,
};
const BACKUP_CODE_OPTION = {
    Icon: undefined,
    descriptionKey: 'dyn_mfa.choose_device_view.backup_code_description',
    labelKey: 'dyn_mfa.choose_device_view.backup_code',
    type: 'backupCode',
};
const useGetMfaOptions = (isInitialSetup) => {
    const getUserMfaMethods = useGetUserMfaMethods.useGetUserMfaMethods();
    return React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
        const registeredMfaMethods = yield getUserMfaMethods();
        const showTotpOption = isInitialSetup
            ? isMfaMethodEnabled.isMfaMethodEnabled(sdkApiCore.MFADeviceType.Totp)
            : registeredMfaMethods.devices.length > 0;
        const showPasskeyOption = isInitialSetup
            ? isMfaMethodEnabled.isMfaMethodEnabled(sdkApiCore.MFADeviceType.Passkey)
            : registeredMfaMethods.passkeys.length > 0;
        if (!showTotpOption && !showPasskeyOption) {
            return [];
        }
        const mfaOptions = [];
        if (showPasskeyOption) {
            mfaOptions.push(PASSKEY_OPTION);
        }
        if (showTotpOption) {
            mfaOptions.push(TOTP_OPTION);
        }
        const user = getUserProfile.getUserProfile();
        const shouldShowBackupCodeOption = !isInitialSetup &&
            (user === null || user === void 0 ? void 0 : user.mfaBackupCodeAcknowledgement) ===
                sdkApiCore.MfaBackupCodeAcknowledgement.Complete;
        if (shouldShowBackupCodeOption) {
            mfaOptions.push(BACKUP_CODE_OPTION);
        }
        return mfaOptions;
    }), [getUserMfaMethods, isInitialSetup]);
};

exports.BACKUP_CODE_OPTION = BACKUP_CODE_OPTION;
exports.PASSKEY_OPTION = PASSKEY_OPTION;
exports.TOTP_OPTION = TOTP_OPTION;
exports.useGetMfaOptions = useGetMfaOptions;
