

const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.js');
const require_decorateMetadata = require('../../../../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorateMetadata.js');
const require_decorate = require('../../../../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorate.js');
const require_JsonTransformer = require('../../../../utils/JsonTransformer.js');
const require_array = require('../../../../utils/array.js');
const require_validators = require('../../../../utils/validators.js');
require('../../../../utils/index.js');
const require_constants = require('../../constants.js');
const require_validators$1 = require('../../validators.js');
const require_W3cV2CredentialSchema = require('./W3cV2CredentialSchema.js');
const require_W3cV2CredentialStatus = require('./W3cV2CredentialStatus.js');
const require_W3cV2CredentialSubject = require('./W3cV2CredentialSubject.js');
const require_W3cV2Evidence = require('./W3cV2Evidence.js');
const require_W3cV2Issuer = require('./W3cV2Issuer.js');
const require_W3cV2LocalizedValue = require('./W3cV2LocalizedValue.js');
const require_W3cV2RefreshService = require('./W3cV2RefreshService.js');
const require_W3cV2TermsOfUse = require('./W3cV2TermsOfUse.js');
let class_transformer = require("class-transformer");
class_transformer = require_rolldown_runtime.__toESM(class_transformer);
let class_validator = require("class-validator");
class_validator = require_rolldown_runtime.__toESM(class_validator);

//#region src/modules/vc/models/credential/W3cV2Credential.ts
var _ref;
var W3cV2Credential = class {
	constructor(options) {
		if (options) {
			const { context, id, type, name, description, issuer, credentialSubject, validFrom, validUntil, status, credentialSchema, refreshService, termsOfUse, evidence,...rest } = options;
			(0, class_transformer.plainToClassFromExist)(this, rest);
			this.context = context ?? [require_constants.CREDENTIALS_CONTEXT_V2_URL];
			this.id = id;
			this.type = type || ["VerifiableCredential"];
			if (name) this.name = typeof name === "string" ? name : require_array.mapSingleOrArray(name, (n) => n instanceof require_W3cV2LocalizedValue.W3cV2LocalizedValue ? n : new require_W3cV2LocalizedValue.W3cV2LocalizedValue(n));
			if (description) this.description = typeof description === "string" ? description : require_array.mapSingleOrArray(description, (n) => n instanceof require_W3cV2LocalizedValue.W3cV2LocalizedValue ? n : new require_W3cV2LocalizedValue.W3cV2LocalizedValue(n));
			this.issuer = typeof issuer === "string" || issuer instanceof require_W3cV2Issuer.W3cV2Issuer ? issuer : new require_W3cV2Issuer.W3cV2Issuer(issuer);
			this.credentialSubject = require_array.mapSingleOrArray(credentialSubject, (subject) => subject instanceof require_W3cV2CredentialSubject.W3cV2CredentialSubject ? subject : new require_W3cV2CredentialSubject.W3cV2CredentialSubject(subject));
			this.validFrom = validFrom;
			this.validUntil = validUntil;
			if (status) this.status = require_array.mapSingleOrArray(status, (status$1) => status$1 instanceof require_W3cV2CredentialStatus.W3cV2CredentialStatus ? status$1 : new require_W3cV2CredentialStatus.W3cV2CredentialStatus(status$1));
			if (credentialSchema) this.credentialSchema = require_array.mapSingleOrArray(credentialSchema, (schema) => schema instanceof require_W3cV2CredentialSchema.W3cV2CredentialSchema ? schema : new require_W3cV2CredentialSchema.W3cV2CredentialSchema(schema));
			if (refreshService) this.refreshService = require_array.mapSingleOrArray(refreshService, (service) => service instanceof require_W3cV2RefreshService.W3cV2RefreshService ? service : new require_W3cV2RefreshService.W3cV2RefreshService(service));
			if (termsOfUse) this.termsOfUse = require_array.mapSingleOrArray(termsOfUse, (tos) => tos instanceof require_W3cV2TermsOfUse.W3cV2TermsOfUse ? tos : new require_W3cV2TermsOfUse.W3cV2TermsOfUse(tos));
			if (evidence) this.evidence = require_array.mapSingleOrArray(evidence, (evidence$1) => evidence$1 instanceof require_W3cV2Evidence.W3cV2Evidence ? evidence$1 : new require_W3cV2Evidence.W3cV2Evidence(evidence$1));
		}
	}
	get issuerId() {
		return this.issuer instanceof require_W3cV2Issuer.W3cV2Issuer ? this.issuer.id : this.issuer;
	}
	get credentialSchemaIds() {
		if (!this.credentialSchema) return [];
		if (Array.isArray(this.credentialSchema)) return this.credentialSchema.map((credentialSchema) => credentialSchema.id);
		return [this.credentialSchema.id];
	}
	get credentialSubjectIds() {
		if (Array.isArray(this.credentialSubject)) return this.credentialSubject.map((credentialSubject) => credentialSubject.id).filter((v) => v !== void 0);
		return this.credentialSubject.id ? [this.credentialSubject.id] : [];
	}
	get contexts() {
		return require_array.asArray(this.context);
	}
	toJSON() {
		return require_JsonTransformer.JsonTransformer.toJSON(this);
	}
};
require_decorate.__decorate([
	(0, class_transformer.Expose)({ name: "@context" }),
	require_validators$1.IsCredentialJsonLdContext({ credentialContext: require_constants.CREDENTIALS_CONTEXT_V2_URL }),
	require_decorateMetadata.__decorateMetadata("design:type", typeof (_ref = typeof Array !== "undefined" && Array) === "function" ? _ref : Object)
], W3cV2Credential.prototype, "context", void 0);
require_decorate.__decorate([
	(0, class_validator.IsOptional)(),
	require_validators.IsUri(),
	require_decorateMetadata.__decorateMetadata("design:type", String)
], W3cV2Credential.prototype, "id", void 0);
require_decorate.__decorate([require_validators$1.IsCredentialType(), require_decorateMetadata.__decorateMetadata("design:type", Object)], W3cV2Credential.prototype, "type", void 0);
require_decorate.__decorate([
	(0, class_validator.IsOptional)(),
	require_validators.IsStringOrInstanceOrArrayOfInstances({
		classType: require_W3cV2LocalizedValue.W3cV2LocalizedValue,
		allowEmptyArray: true
	}),
	require_W3cV2LocalizedValue.W3cV2LocalizedValueTransformer(),
	require_decorateMetadata.__decorateMetadata("design:type", Object)
], W3cV2Credential.prototype, "name", void 0);
require_decorate.__decorate([
	(0, class_validator.IsOptional)(),
	require_validators.IsStringOrInstanceOrArrayOfInstances({
		classType: require_W3cV2LocalizedValue.W3cV2LocalizedValue,
		allowEmptyArray: true
	}),
	require_W3cV2LocalizedValue.W3cV2LocalizedValueTransformer(),
	require_decorateMetadata.__decorateMetadata("design:type", Object)
], W3cV2Credential.prototype, "description", void 0);
require_decorate.__decorate([
	require_W3cV2Issuer.IsW3cV2Issuer(),
	require_W3cV2Issuer.W3cV2IssuerTransformer(),
	require_decorateMetadata.__decorateMetadata("design:type", Object)
], W3cV2Credential.prototype, "issuer", void 0);
require_decorate.__decorate([
	(0, class_transformer.Type)(() => require_W3cV2CredentialSubject.W3cV2CredentialSubject),
	(0, class_validator.ValidateNested)({ each: true }),
	require_validators.IsInstanceOrArrayOfInstances({ classType: require_W3cV2CredentialSubject.W3cV2CredentialSubject }),
	require_decorateMetadata.__decorateMetadata("design:type", Object)
], W3cV2Credential.prototype, "credentialSubject", void 0);
require_decorate.__decorate([
	(0, class_validator.IsRFC3339)(),
	(0, class_validator.IsOptional)(),
	require_decorateMetadata.__decorateMetadata("design:type", String)
], W3cV2Credential.prototype, "validFrom", void 0);
require_decorate.__decorate([
	(0, class_validator.IsRFC3339)(),
	(0, class_validator.IsOptional)(),
	require_decorateMetadata.__decorateMetadata("design:type", String)
], W3cV2Credential.prototype, "validUntil", void 0);
require_decorate.__decorate([
	(0, class_validator.IsOptional)(),
	(0, class_transformer.Type)(() => require_W3cV2CredentialStatus.W3cV2CredentialStatus),
	(0, class_validator.ValidateNested)({ each: true }),
	require_validators.IsInstanceOrArrayOfInstances({
		classType: require_W3cV2CredentialStatus.W3cV2CredentialStatus,
		allowEmptyArray: true
	}),
	require_decorateMetadata.__decorateMetadata("design:type", Object)
], W3cV2Credential.prototype, "status", void 0);
require_decorate.__decorate([
	(0, class_validator.IsOptional)(),
	(0, class_transformer.Type)(() => require_W3cV2CredentialSchema.W3cV2CredentialSchema),
	(0, class_validator.ValidateNested)({ each: true }),
	require_validators.IsInstanceOrArrayOfInstances({
		classType: require_W3cV2CredentialSchema.W3cV2CredentialSchema,
		allowEmptyArray: true
	}),
	require_decorateMetadata.__decorateMetadata("design:type", Object)
], W3cV2Credential.prototype, "credentialSchema", void 0);
require_decorate.__decorate([
	(0, class_validator.IsOptional)(),
	(0, class_transformer.Type)(() => require_W3cV2RefreshService.W3cV2RefreshService),
	(0, class_validator.ValidateNested)({ each: true }),
	require_validators.IsInstanceOrArrayOfInstances({
		classType: require_W3cV2RefreshService.W3cV2RefreshService,
		allowEmptyArray: true
	}),
	require_decorateMetadata.__decorateMetadata("design:type", Object)
], W3cV2Credential.prototype, "refreshService", void 0);
require_decorate.__decorate([
	(0, class_validator.IsOptional)(),
	(0, class_transformer.Type)(() => require_W3cV2Evidence.W3cV2Evidence),
	(0, class_validator.ValidateNested)({ each: true }),
	require_validators.IsInstanceOrArrayOfInstances({
		classType: require_W3cV2Evidence.W3cV2Evidence,
		allowEmptyArray: true
	}),
	require_decorateMetadata.__decorateMetadata("design:type", Object)
], W3cV2Credential.prototype, "evidence", void 0);
require_decorate.__decorate([
	(0, class_validator.IsOptional)(),
	(0, class_transformer.Type)(() => require_W3cV2TermsOfUse.W3cV2TermsOfUse),
	(0, class_validator.ValidateNested)({ each: true }),
	require_validators.IsInstanceOrArrayOfInstances({
		classType: require_W3cV2TermsOfUse.W3cV2TermsOfUse,
		allowEmptyArray: true
	}),
	require_decorateMetadata.__decorateMetadata("design:type", Object)
], W3cV2Credential.prototype, "termsOfUse", void 0);
require_decorate.__decorate([require_validators.IsNever(), require_decorateMetadata.__decorateMetadata("design:type", void 0)], W3cV2Credential.prototype, "vc", void 0);
require_decorate.__decorate([require_validators.IsNever(), require_decorateMetadata.__decorateMetadata("design:type", void 0)], W3cV2Credential.prototype, "vp", void 0);

//#endregion
exports.W3cV2Credential = W3cV2Credential;