{"version":3,"file":"useEmailOtpDiscoverySend.mjs","sources":["../../../../../../../../../web/src/ui/b2b/hooks/useEmailOtpDiscoverySend.ts"],"sourcesContent":["import { ResponseCommon, StytchAPIError } from '@stytch/core/public';\n\nimport { getOtpCodeExpiration } from '../getOtpCodeExpiration';\nimport { useConfig, useGlobalReducer, useStytch } from '../GlobalContextProvider';\nimport { StytchMutationKey, useMutate } from '../utils';\n\nexport const useEmailOtpDiscoverySend = ({ throwOnError }: { throwOnError?: boolean } = {}) => {\n  const [, dispatch] = useGlobalReducer();\n  const stytchClient = useStytch();\n  const config = useConfig();\n\n  return useMutate<ResponseCommon, StytchAPIError, StytchMutationKey, { email: string }>(\n    'stytch.otps.email.discovery.send',\n    (_key: string, { arg: { email } }: { arg: { email: string } }) =>\n      stytchClient.otps.email.discovery.send({\n        email_address: email,\n        login_template_id: config.emailOtpOptions?.loginTemplateId,\n        locale: config.emailOtpOptions?.locale,\n      }),\n    {\n      onSuccess: () => {\n        dispatch({ type: 'send_email_otp', codeExpiration: getOtpCodeExpiration() });\n      },\n      throwOnError,\n    },\n  );\n};\n"],"names":["useEmailOtpDiscoverySend","throwOnError","dispatch","useGlobalReducer","stytchClient","useStytch","config","useConfig","useMutate","_key","arg","email","otps","discovery","send","email_address","login_template_id","emailOtpOptions","loginTemplateId","locale","onSuccess","type","codeExpiration","getOtpCodeExpiration"],"mappings":";;;;AAMO,MAAMA,2BAA2B,CAAC,EAAEC,YAAY,EAA8B,GAAG,EAAE,GAAA;IACxF,MAAM,GAAGC,SAAS,GAAGC,gBAAAA,EAAAA;AACrB,IAAA,MAAMC,YAAAA,GAAeC,SAAAA,EAAAA;AACrB,IAAA,MAAMC,MAAAA,GAASC,SAAAA,EAAAA;AAEf,IAAA,OAAOC,UACL,kCAAA,EACA,CAACC,MAAc,EAAEC,GAAAA,EAAK,EAAEC,KAAK,EAAE,EAA8B,GAC3DP,YAAAA,CAAaQ,IAAI,CAACD,KAAK,CAACE,SAAS,CAACC,IAAI,CAAC;YACrCC,aAAAA,EAAeJ,KAAAA;YACfK,iBAAAA,EAAmBV,MAAAA,CAAOW,eAAe,EAAEC,eAAAA;YAC3CC,MAAAA,EAAQb,MAAAA,CAAOW,eAAe,EAAEE;SAClC,CAAA,EACF;QACEC,SAAAA,EAAW,IAAA;YACTlB,QAAAA,CAAS;gBAAEmB,IAAAA,EAAM,gBAAA;gBAAkBC,cAAAA,EAAgBC,oBAAAA;AAAuB,aAAA,CAAA;AAC5E,QAAA,CAAA;AACAtB,QAAAA;AACF,KAAA,CAAA;AAEJ;;;;"}