import { validateInDev } from '../../utils/dev.mjs';

class HeadlessB2BImpersonationClient {
    _networkClient;
    _subscriptionService;
    dfpProtectedAuth;
    authenticate;
    constructor(_networkClient, _subscriptionService, dfpProtectedAuth){
        this._networkClient = _networkClient;
        this._subscriptionService = _subscriptionService;
        this.dfpProtectedAuth = dfpProtectedAuth;
        this.authenticate = this._subscriptionService.withUpdateSession(async (data)=>{
            validateInDev('stytch.impersonation.authenticate', data, {
                impersonation_token: 'string'
            });
            const { dfp_telemetry_id, captcha_token } = await this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
            return this._networkClient.retriableFetchSDK({
                url: '/b2b/impersonation/authenticate',
                body: {
                    ...data,
                    dfp_telemetry_id,
                    captcha_token
                },
                method: 'POST',
                retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
            });
        });
    }
}

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