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 { CredoError, DidDocumentService, DidKey, IsUri, Kms, isDid } from "@credo-ts/core";
import { ArrayNotEmpty, IsOptional, IsString, ValidateBy, buildMessage, isString } from "class-validator";

//#region ../didcomm/src/modules/oob/domain/OutOfBandDidCommService.ts
var OutOfBandDidCommService = class OutOfBandDidCommService extends DidDocumentService {
	constructor(options) {
		super({
			...options,
			type: OutOfBandDidCommService.type
		});
		if (options) {
			this.recipientKeys = options.recipientKeys;
			this.routingKeys = options.routingKeys;
			this.accept = options.accept;
		}
	}
	get resolvedDidCommService() {
		return {
			id: this.id,
			recipientKeys: this.recipientKeys.map((didKey) => {
				const publicJwk = DidKey.fromDid(didKey).publicJwk;
				if (!publicJwk.is(Kms.Ed25519PublicJwk)) throw new CredoError("Expected recipient key for didcomm service to be of type Ed25519");
				return publicJwk;
			}),
			routingKeys: this.routingKeys?.map((didKey) => {
				const publicJwk = DidKey.fromDid(didKey).publicJwk;
				if (!publicJwk.is(Kms.Ed25519PublicJwk)) throw new CredoError("Expected recipient key for didcomm service to be of type Ed25519");
				return publicJwk;
			}) ?? [],
			serviceEndpoint: this.serviceEndpoint
		};
	}
	static fromResolvedDidCommService(service) {
		return new OutOfBandDidCommService({
			id: service.id,
			recipientKeys: service.recipientKeys.map((key) => new DidKey(key).did),
			routingKeys: service.routingKeys.map((key) => new DidKey(key).did),
			serviceEndpoint: service.serviceEndpoint
		});
	}
};
OutOfBandDidCommService.type = "did-communication";
__decorate([
	IsString(),
	IsUri(),
	__decorateMetadata("design:type", String)
], OutOfBandDidCommService.prototype, "serviceEndpoint", void 0);
__decorate([
	ArrayNotEmpty(),
	IsDidKeyString({ each: true }),
	__decorateMetadata("design:type", Array)
], OutOfBandDidCommService.prototype, "recipientKeys", void 0);
__decorate([
	IsDidKeyString({ each: true }),
	IsOptional(),
	__decorateMetadata("design:type", Array)
], OutOfBandDidCommService.prototype, "routingKeys", void 0);
__decorate([
	IsString({ each: true }),
	IsOptional(),
	__decorateMetadata("design:type", Array)
], OutOfBandDidCommService.prototype, "accept", void 0);
/**
* Checks if a given value is a did:key did string
*/
function IsDidKeyString(validationOptions) {
	return ValidateBy({
		name: "isDidKeyString",
		validator: {
			validate: (value) => isString(value) && isDid(value, "key"),
			defaultMessage: buildMessage((eachPrefix) => `${eachPrefix}$property must be a did:key string`, validationOptions)
		}
	}, validationOptions);
}

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