import { BaseRecord, CredoError, Kms, TypedArrayEncoder, utils } from "@credo-ts/core";

//#region ../didcomm/src/modules/routing/repository/DidCommMediatorRoutingRecord.ts
var DidCommMediatorRoutingRecord = class DidCommMediatorRoutingRecord extends BaseRecord {
	constructor(props) {
		super();
		this.type = DidCommMediatorRoutingRecord.type;
		this.allowCache = true;
		if (props) {
			this.id = props.id ?? utils.uuid();
			this.createdAt = props.createdAt ?? /* @__PURE__ */ new Date();
			this.routingKeys = props.routingKeys || [];
		}
	}
	get routingKeysWithKeyId() {
		return this.routingKeys.map((routingKey) => {
			if (typeof routingKey === "string") {
				const publicJwk$1 = Kms.PublicJwk.fromPublicKey({
					kty: "OKP",
					crv: "Ed25519",
					publicKey: TypedArrayEncoder.fromBase58(routingKey)
				});
				publicJwk$1.keyId = publicJwk$1.legacyKeyId;
				return publicJwk$1;
			}
			const publicJwk = Kms.PublicJwk.fromFingerprint(routingKey.routingKeyFingerprint);
			publicJwk.keyId = routingKey.kmsKeyId;
			if (!publicJwk.is(Kms.Ed25519PublicJwk)) throw new CredoError("Expected mediator routing record key to be of type Ed25519.");
			return publicJwk;
		});
	}
	getTags() {
		return {
			...this._tags,
			routingKeyFingerprints: this.routingKeys.map((routingKey) => typeof routingKey === "string" ? Kms.PublicJwk.fromPublicKey({
				kty: "OKP",
				crv: "Ed25519",
				publicKey: TypedArrayEncoder.fromBase58(routingKey)
			}).fingerprint : routingKey.routingKeyFingerprint)
		};
	}
};
DidCommMediatorRoutingRecord.type = "MediatorRoutingRecord";
DidCommMediatorRoutingRecord.allowCache = true;

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