

const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
const require_Metadata = require('../storage/Metadata.js');
let class_transformer = require("class-transformer");
let class_validator = require("class-validator");

//#region src/utils/transformers.ts
function MetadataTransformer() {
	return (0, class_transformer.Transform)(({ value, type }) => {
		if (type === class_transformer.TransformationType.CLASS_TO_PLAIN) return { ...value.data };
		if (type === class_transformer.TransformationType.PLAIN_TO_CLASS) return new require_Metadata.Metadata(value);
		if (type === class_transformer.TransformationType.CLASS_TO_CLASS) return new require_Metadata.Metadata({ ...value.data });
	});
}
/**
* Decorator that transforms to and from a date instance.
*/
function DateTransformer() {
	return (0, class_transformer.Transform)(({ value, type }) => {
		if (value === void 0) return void 0;
		if (type === class_transformer.TransformationType.CLASS_TO_PLAIN) return value.toISOString();
		if (type === class_transformer.TransformationType.PLAIN_TO_CLASS) return new Date(value);
		if (type === class_transformer.TransformationType.CLASS_TO_CLASS) return new Date(value.getTime());
	});
}
/**
* Checks if a given value is a string or string array.
*/
function IsStringOrStringArray(validationOptions) {
	return (0, class_validator.ValidateBy)({
		name: "isStringOrStringArray",
		validator: {
			validate: (value) => (0, class_validator.isString)(value) || Array.isArray(value) && value.every((v) => (0, class_validator.isString)(v)),
			defaultMessage: (0, class_validator.buildMessage)((eachPrefix) => `${eachPrefix}$property must be a string or string array`, validationOptions)
		}
	}, validationOptions);
}

//#endregion
exports.DateTransformer = DateTransformer;
exports.IsStringOrStringArray = IsStringOrStringArray;
exports.MetadataTransformer = MetadataTransformer;