import EventEmitter from "node:events";
import { EventDirection } from "../events.js";
export { ReqRespBridgeEvent };
var ReqRespBridgeEvent;
(function (ReqRespBridgeEvent) {
    ReqRespBridgeEvent["outgoingRequest"] = "reqresp.outgoingRequest";
    ReqRespBridgeEvent["outgoingResponse"] = "reqresp.outgoingResponse";
    ReqRespBridgeEvent["incomingRequest"] = "reqresp.incomingRequest";
    ReqRespBridgeEvent["incomingResponse"] = "reqresp.incomingResponse";
})(ReqRespBridgeEvent || (ReqRespBridgeEvent = {}));
export class ReqRespBridgeEventBus extends EventEmitter {
}
// NOTE: If the same event is on this two arrays it can create an infinite cycle
export const reqRespBridgeEventDirection = {
    [ReqRespBridgeEvent.outgoingRequest]: EventDirection.mainToWorker,
    [ReqRespBridgeEvent.outgoingResponse]: EventDirection.mainToWorker,
    [ReqRespBridgeEvent.incomingRequest]: EventDirection.workerToMain,
    [ReqRespBridgeEvent.incomingResponse]: EventDirection.workerToMain,
};
export function getReqRespBridgeReqEvents(events) {
    return {
        emitRequest: (data) => events.emit(ReqRespBridgeEvent.outgoingRequest, data),
        emitResponse: (data) => events.emit(ReqRespBridgeEvent.incomingResponse, data),
        onRequest: (cb) => events.on(ReqRespBridgeEvent.outgoingRequest, cb),
        onResponse: (cb) => events.on(ReqRespBridgeEvent.incomingResponse, cb),
    };
}
export function getReqRespBridgeRespEvents(events) {
    return {
        emitRequest: (data) => events.emit(ReqRespBridgeEvent.incomingRequest, data),
        emitResponse: (data) => events.emit(ReqRespBridgeEvent.outgoingResponse, data),
        onRequest: (cb) => events.on(ReqRespBridgeEvent.incomingRequest, cb),
        onResponse: (cb) => events.on(ReqRespBridgeEvent.outgoingResponse, cb),
    };
}
export { NetworkWorkerThreadEventType };
var NetworkWorkerThreadEventType;
(function (NetworkWorkerThreadEventType) {
    NetworkWorkerThreadEventType["networkEvent"] = "networkEvent";
    NetworkWorkerThreadEventType["reqRespBridgeEvents"] = "reqRespBridgeEvents";
})(NetworkWorkerThreadEventType || (NetworkWorkerThreadEventType = {}));
//# sourceMappingURL=events.js.map