const require_rolldown_runtime = require('../../../../../../_virtual/rolldown_runtime.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_DidCommModuleConfig = require('../../../DidCommModuleConfig.js');
const require_DidCommRoutingEvents = require('../DidCommRoutingEvents.js');
const require_DidCommMediationRecipientService = require('./DidCommMediationRecipientService.js');
let __credo_ts_core = require("@credo-ts/core");
__credo_ts_core = require_rolldown_runtime.__toESM(__credo_ts_core);

//#region ../didcomm/src/modules/routing/services/DidCommRoutingService.ts
var _ref, _ref2;
let DidCommRoutingService = class DidCommRoutingService$1 {
	constructor(mediationRecipientService, eventEmitter) {
		this.mediationRecipientService = mediationRecipientService;
		this.eventEmitter = eventEmitter;
	}
	async getRouting(agentContext, { mediatorId, useDefaultMediator = true } = {}) {
		const kms = agentContext.resolve(__credo_ts_core.Kms.KeyManagementApi);
		const didcommConfig = agentContext.resolve(require_DidCommModuleConfig.DidCommModuleConfig);
		const recipientKey = await kms.createKey({ type: {
			kty: "OKP",
			crv: "Ed25519"
		} });
		let routing = {
			endpoints: didcommConfig.endpoints,
			routingKeys: [],
			recipientKey: __credo_ts_core.Kms.PublicJwk.fromPublicJwk(recipientKey.publicJwk)
		};
		routing = await this.mediationRecipientService.addMediationRouting(agentContext, routing, {
			mediatorId,
			useDefaultMediator
		});
		this.eventEmitter.emit(agentContext, {
			type: require_DidCommRoutingEvents.DidCommRoutingEventTypes.RoutingCreatedEvent,
			payload: { routing }
		});
		return routing;
	}
	async removeRouting(agentContext, options) {
		await this.mediationRecipientService.removeMediationRouting(agentContext, options);
	}
};
DidCommRoutingService = require_decorate.__decorate([(0, __credo_ts_core.injectable)(), require_decorateMetadata.__decorateMetadata("design:paramtypes", [typeof (_ref = typeof require_DidCommMediationRecipientService.DidCommMediationRecipientService !== "undefined" && require_DidCommMediationRecipientService.DidCommMediationRecipientService) === "function" ? _ref : Object, typeof (_ref2 = typeof __credo_ts_core.EventEmitter !== "undefined" && __credo_ts_core.EventEmitter) === "function" ? _ref2 : Object])], DidCommRoutingService);

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