import { __decorateMetadata } from "../../../../../../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorateMetadata.mjs";
import { __decorate } from "../../../../../../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorate.mjs";
import "../models/index.mjs";
import { DidCommConnectionRecord } from "./DidCommConnectionRecord.mjs";
import { __decorateParam } from "../../../../../../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorateParam.mjs";
import { EventEmitter, InjectionSymbols, Repository, inject, injectable } from "@credo-ts/core";

//#region ../didcomm/src/modules/connections/repository/DidCommConnectionRepository.ts
var _ref;
let DidCommConnectionRepository = class DidCommConnectionRepository$1 extends Repository {
	constructor(storageService, eventEmitter) {
		super(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 = __decorate([
	injectable(),
	__decorateParam(0, inject(InjectionSymbols.StorageService)),
	__decorateMetadata("design:paramtypes", [Object, typeof (_ref = typeof EventEmitter !== "undefined" && EventEmitter) === "function" ? _ref : Object])
], DidCommConnectionRepository);

//#endregion
export { DidCommConnectionRepository };
//# sourceMappingURL=DidCommConnectionRepository.mjs.map