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');
require('../models/index.js');
const require_DidCommConnectionRecord = require('./DidCommConnectionRecord.js');
const require_decorateParam = require('../../../../../../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorateParam.js');
let __credo_ts_core = require("@credo-ts/core");
__credo_ts_core = require_rolldown_runtime.__toESM(__credo_ts_core);

//#region ../didcomm/src/modules/connections/repository/DidCommConnectionRepository.ts
var _ref;
let DidCommConnectionRepository = class DidCommConnectionRepository$1 extends __credo_ts_core.Repository {
	constructor(storageService, eventEmitter) {
		super(require_DidCommConnectionRecord.DidCommConnectionRecord, storageService, eventEmitter);
	}
	async findByDids(agentContext, { ourDid, theirDid }) {
		return this.findSingleByQuery(agentContext, { $or: [
			{
				did: ourDid,
				theirDid
			},
			{
				did: ourDid,
				previousTheirDids: [theirDid]
			},
			{
				previousDids: [ourDid],
				theirDid
			}
		] }, { cacheKey: `ourDid${ourDid}theirDid${theirDid}` });
	}
	getByThreadId(agentContext, threadId) {
		return this.getSingleByQuery(agentContext, { threadId });
	}
	getByRoleAndThreadId(agentContext, role, threadId) {
		return this.getSingleByQuery(agentContext, {
			threadId,
			role
		});
	}
};
DidCommConnectionRepository = require_decorate.__decorate([
	(0, __credo_ts_core.injectable)(),
	require_decorateParam.__decorateParam(0, (0, __credo_ts_core.inject)(__credo_ts_core.InjectionSymbols.StorageService)),
	require_decorateMetadata.__decorateMetadata("design:paramtypes", [Object, typeof (_ref = typeof __credo_ts_core.EventEmitter !== "undefined" && __credo_ts_core.EventEmitter) === "function" ? _ref : Object])
], DidCommConnectionRepository);

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