

const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
const require_constants = require('../constants.js');
require('../plugins/index.js');
const require_decorateMetadata = require('../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorateMetadata.js');
const require_decorate = require('../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorate.js');
const require_decorateParam = require('../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorateParam.js');
let rxjs = require("rxjs");
rxjs = require_rolldown_runtime.__toESM(rxjs);
let rxjs_operators = require("rxjs/operators");
rxjs_operators = require_rolldown_runtime.__toESM(rxjs_operators);
let tsyringe = require("tsyringe");
tsyringe = require_rolldown_runtime.__toESM(tsyringe);

//#region src/agent/EventEmitter.ts
var _ref;
let EventEmitter = class EventEmitter$1 {
	constructor(agentDependencies, stop$) {
		this.eventEmitter = new agentDependencies.EventEmitterClass();
		this.stop$ = stop$;
	}
	emit(agentContext, data) {
		this.eventEmitter.emit(data.type, {
			...data,
			metadata: { contextCorrelationId: agentContext.contextCorrelationId }
		});
	}
	on(event, listener) {
		this.eventEmitter.on(event, listener);
	}
	off(event, listener) {
		this.eventEmitter.off(event, listener);
	}
	observable(event) {
		return (0, rxjs.fromEventPattern)((handler) => this.on(event, handler), (handler) => this.off(event, handler)).pipe((0, rxjs_operators.takeUntil)(this.stop$));
	}
};
EventEmitter = require_decorate.__decorate([
	(0, tsyringe.injectable)(),
	require_decorateParam.__decorateParam(0, (0, tsyringe.inject)(require_constants.InjectionSymbols.AgentDependencies)),
	require_decorateParam.__decorateParam(1, (0, tsyringe.inject)(require_constants.InjectionSymbols.Stop$)),
	require_decorateMetadata.__decorateMetadata("design:paramtypes", [Object, typeof (_ref = typeof rxjs.Subject !== "undefined" && rxjs.Subject) === "function" ? _ref : Object])
], EventEmitter);

//#endregion
Object.defineProperty(exports, 'EventEmitter', {
  enumerable: true,
  get: function () {
    return EventEmitter;
  }
});