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_DidCommOutboundMessageContext = require('../../models/DidCommOutboundMessageContext.js');
require('../../models/index.js');
const require_DidCommConnectionService = require('../connections/services/DidCommConnectionService.js');
const require_DidCommMessageSender = require('../../DidCommMessageSender.js');
require('../connections/index.js');
const require_DidCommMediatorModuleConfig = require('./DidCommMediatorModuleConfig.js');
const require_DidCommMediatorService = require('./services/DidCommMediatorService.js');
let __credo_ts_core = require("@credo-ts/core");
__credo_ts_core = require_rolldown_runtime.__toESM(__credo_ts_core);

//#region ../didcomm/src/modules/routing/DidCommMediatorApi.ts
var _ref, _ref2, _ref3, _ref4, _ref5;
let DidCommMediatorApi = class DidCommMediatorApi$1 {
	constructor(mediationService, messageSender, agentContext, connectionService, config) {
		this.mediatorService = mediationService;
		this.messageSender = messageSender;
		this.connectionService = connectionService;
		this.agentContext = agentContext;
		this.config = config;
	}
	async grantRequestedMediation(mediationRecordId) {
		const record = await this.mediatorService.getById(this.agentContext, mediationRecordId);
		const connectionRecord = await this.connectionService.getById(this.agentContext, record.connectionId);
		const { message, mediationRecord } = await this.mediatorService.createGrantMediationMessage(this.agentContext, record);
		const outboundMessageContext = new require_DidCommOutboundMessageContext.DidCommOutboundMessageContext(message, {
			agentContext: this.agentContext,
			connection: connectionRecord,
			associatedRecord: mediationRecord
		});
		await this.messageSender.sendMessage(outboundMessageContext);
		return mediationRecord;
	}
};
DidCommMediatorApi = require_decorate.__decorate([(0, __credo_ts_core.injectable)(), require_decorateMetadata.__decorateMetadata("design:paramtypes", [
	typeof (_ref = typeof require_DidCommMediatorService.DidCommMediatorService !== "undefined" && require_DidCommMediatorService.DidCommMediatorService) === "function" ? _ref : Object,
	typeof (_ref2 = typeof require_DidCommMessageSender.DidCommMessageSender !== "undefined" && require_DidCommMessageSender.DidCommMessageSender) === "function" ? _ref2 : Object,
	typeof (_ref3 = typeof __credo_ts_core.AgentContext !== "undefined" && __credo_ts_core.AgentContext) === "function" ? _ref3 : Object,
	typeof (_ref4 = typeof require_DidCommConnectionService.DidCommConnectionService !== "undefined" && require_DidCommConnectionService.DidCommConnectionService) === "function" ? _ref4 : Object,
	typeof (_ref5 = typeof require_DidCommMediatorModuleConfig.DidCommMediatorModuleConfig !== "undefined" && require_DidCommMediatorModuleConfig.DidCommMediatorModuleConfig) === "function" ? _ref5 : Object
])], DidCommMediatorApi);

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