

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 { IsUri, isUri } from "../../../../utils/validators.mjs";
import { Transform, TransformationType, instanceToPlain, plainToInstance } from "class-transformer";
import { ValidateBy, buildMessage, isInstance, isString } from "class-validator";

//#region src/modules/vc/models/presentation/W3cHolder.ts
var W3cHolder = class {
	constructor(options) {
		if (options) this.id = options.id;
	}
};
__decorate([IsUri(), __decorateMetadata("design:type", String)], W3cHolder.prototype, "id", void 0);
function W3cHolderTransformer() {
	return Transform(({ value, type }) => {
		if (type === TransformationType.PLAIN_TO_CLASS) {
			if (isString(value)) return value;
			return plainToInstance(W3cHolder, value);
		}
		if (type === TransformationType.CLASS_TO_PLAIN) {
			if (isString(value)) return value;
			return instanceToPlain(value);
		}
		return value;
	});
}
function IsW3cHolder(validationOptions) {
	return ValidateBy({
		name: "IsW3cHolder",
		validator: {
			validate: (value) => {
				if (typeof value === "string") return isUri(value);
				if (isInstance(value, W3cHolder)) return isUri(value.id);
				return false;
			},
			defaultMessage: buildMessage((eachPrefix) => `${eachPrefix}$property must be an URI or an object with an id property which is an URI`, validationOptions)
		}
	}, validationOptions);
}

//#endregion
export { IsW3cHolder, W3cHolder, W3cHolderTransformer };
//# sourceMappingURL=W3cHolder.mjs.map