import { useGlobalReducer, useStytch, useConfig } from '../GlobalContextProvider.mjs';
import { AppScreens } from '../types/AppScreens.mjs';
import { useMutate } from '../utils.mjs';

const useEmlDiscoverySend = ()=>{
    const [, dispatch] = useGlobalReducer();
    const stytchClient = useStytch();
    const config = useConfig();
    return useMutate('stytch.magicLinks.email.discovery.send', (_, { arg: { email } })=>stytchClient.magicLinks.email.discovery.send({
            email_address: email,
            discovery_redirect_url: config.emailMagicLinksOptions?.discoveryRedirectURL,
            login_template_id: config.emailMagicLinksOptions?.loginTemplateId,
            locale: config.emailMagicLinksOptions?.locale
        }), {
        onSuccess: ()=>{
            dispatch({
                type: 'transition',
                screen: AppScreens.EmailConfirmation
            });
        }
    });
};

export { useEmlDiscoverySend };
//# sourceMappingURL=useEmlDiscoverySend.mjs.map
