// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import * as WS from 'ws';
import { NodeWebSocket } from "../../internal/ws-adapter-node.mjs";
import { ResponsesWSBase } from "./ws-base.mjs";
export class ResponsesWS extends ResponsesWSBase {
    constructor(client, options) {
        if (!WS?.WebSocket) {
            throw new Error('ResponsesWS from "openai/resources/responses/ws" requires the "ws" package but it could not be loaded.');
        }
        const { reconnect, maxQueueSize, ...wsOptions } = options ?? {};
        super(client, { reconnect, maxQueueSize });
        this._wsOptions = wsOptions;
        this._connectInitial();
    }
    _createSocket(url, authHeaders) {
        const ws = new WS.WebSocket(url, {
            ...this._wsOptions,
            headers: {
                ...authHeaders,
                ...this._wsOptions?.headers,
            },
        });
        return new NodeWebSocket(ws);
    }
}
//# sourceMappingURL=ws.mjs.map