class HeadlessB2BOTPsClient {
    _networkClient;
    _subscriptionService;
    dfpProtectedAuth;
    sms;
    email;
    constructor(_networkClient, _subscriptionService, dfpProtectedAuth){
        this._networkClient = _networkClient;
        this._subscriptionService = _subscriptionService;
        this.dfpProtectedAuth = dfpProtectedAuth;
        this.sms = {
            send: async (data)=>{
                const { dfp_telemetry_id, captcha_token } = await this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
                return this._networkClient.retriableFetchSDK({
                    url: '/b2b/otps/sms/send',
                    body: {
                        ...data,
                        dfp_telemetry_id,
                        captcha_token,
                        intermediate_session_token: this._subscriptionService.getIntermediateSessionToken() || undefined
                    },
                    method: 'POST',
                    retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
                });
            },
            authenticate: this._subscriptionService.withUpdateSession(async (data)=>{
                const { dfp_telemetry_id, captcha_token } = await this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
                const requestBody = {
                    ...data,
                    dfp_telemetry_id,
                    captcha_token,
                    intermediate_session_token: this._subscriptionService.getIntermediateSessionToken() || undefined
                };
                return this._networkClient.retriableFetchSDK({
                    url: '/b2b/otps/sms/authenticate',
                    body: requestBody,
                    method: 'POST',
                    retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
                });
            })
        };
        this.email = {
            loginOrSignup: async (data)=>{
                const { dfp_telemetry_id, captcha_token } = await this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
                return this._networkClient.retriableFetchSDK({
                    url: '/b2b/otps/email/login_or_signup',
                    body: {
                        ...data,
                        dfp_telemetry_id,
                        captcha_token
                    },
                    method: 'POST',
                    retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
                });
            },
            authenticate: this._subscriptionService.withUpdateSession(async (data)=>{
                const { dfp_telemetry_id, captcha_token } = await this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
                return this._networkClient.retriableFetchSDK({
                    url: '/b2b/otps/email/authenticate',
                    body: {
                        ...data,
                        intermediate_session_token: this._subscriptionService.getIntermediateSessionToken() || undefined,
                        dfp_telemetry_id,
                        captcha_token
                    },
                    method: 'POST',
                    retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
                });
            }),
            discovery: {
                send: async (data)=>{
                    const { dfp_telemetry_id, captcha_token } = await this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
                    const requestBody = {
                        ...data,
                        dfp_telemetry_id,
                        captcha_token
                    };
                    return this._networkClient.retriableFetchSDK({
                        url: '/b2b/otps/email/discovery/send',
                        body: requestBody,
                        method: 'POST',
                        retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
                    });
                },
                authenticate: this._subscriptionService.withUpdateSession(async (data)=>{
                    const { dfp_telemetry_id, captcha_token } = await this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
                    const requestBody = {
                        dfp_telemetry_id,
                        captcha_token,
                        ...data
                    };
                    return this._networkClient.retriableFetchSDK({
                        url: '/b2b/otps/email/discovery/authenticate',
                        body: requestBody,
                        method: 'POST',
                        retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
                    });
                })
            }
        };
    }
}

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