

import { __decorateMetadata } from "../../../_virtual/_@oxc-project_runtime@0.95.0/helpers/decorateMetadata.mjs";
import { __decorate } from "../../../_virtual/_@oxc-project_runtime@0.95.0/helpers/decorate.mjs";
import { BaseRecord } from "../../../storage/BaseRecord.mjs";
import { parseDid } from "../domain/parse.mjs";
import { DidDocument } from "../domain/DidDocument.mjs";
import { DidDocumentRole } from "../domain/DidDocumentRole.mjs";
import "../domain/index.mjs";
import { uuid } from "../../../utils/uuid.mjs";
import { DidRecordMetadataKeys } from "./didRecordMetadataTypes.mjs";
import { Type } from "class-transformer";
import { IsEnum, ValidateNested } from "class-validator";

//#region src/modules/dids/repository/DidRecord.ts
var _ref, _ref2;
var DidRecord = class DidRecord extends BaseRecord {
	constructor(props) {
		super();
		this.type = DidRecord.type;
		if (props) {
			this.id = props.id ?? uuid();
			this.did = props.did;
			this.role = props.role;
			this.didDocument = props.didDocument;
			this.createdAt = props.createdAt ?? /* @__PURE__ */ new Date();
			this._tags = props.tags ?? {};
			this.keys = props.keys;
		}
	}
	getTags() {
		const did = parseDid(this.did);
		const legacyDid = this.metadata.get(DidRecordMetadataKeys.LegacyDid);
		return {
			...this._tags,
			role: this.role,
			method: did.method,
			legacyUnqualifiedDid: legacyDid?.unqualifiedDid,
			did: this.did,
			methodSpecificIdentifier: did.id,
			recipientKeyFingerprints: this.didDocument ? this.didDocument.recipientKeys.map((recipientKey) => recipientKey.fingerprint) : this._tags.recipientKeyFingerprints
		};
	}
};
DidRecord.type = "DidRecord";
__decorate([
	Type(() => DidDocument),
	ValidateNested(),
	__decorateMetadata("design:type", typeof (_ref = typeof DidDocument !== "undefined" && DidDocument) === "function" ? _ref : Object)
], DidRecord.prototype, "didDocument", void 0);
__decorate([IsEnum(DidDocumentRole), __decorateMetadata("design:type", typeof (_ref2 = typeof DidDocumentRole !== "undefined" && DidDocumentRole) === "function" ? _ref2 : Object)], DidRecord.prototype, "role", void 0);

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