const require_rolldown_runtime = require('../../../../../_virtual/rolldown_runtime.js');
const require_index = require('../../../../../node_modules/.pnpm/class-transformer@0.5.1/node_modules/class-transformer/cjs/index.js');
const require_index$1 = require('../../../../../node_modules/.pnpm/class-validator@0.14.1/node_modules/class-validator/cjs/index.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');
let __credo_ts_core = require("@credo-ts/core");
__credo_ts_core = require_rolldown_runtime.__toESM(__credo_ts_core);

//#region ../didcomm/src/decorators/attachment/DidCommAttachment.ts
var import_cjs = /* @__PURE__ */ require_rolldown_runtime.__toESM(require_index.require_cjs());
var import_cjs$1 = /* @__PURE__ */ require_rolldown_runtime.__toESM(require_index$1.require_cjs());
var _ref, _ref2;
/**
* A JSON object that gives access to the actual content of the attachment
*/
var DidCommAttachmentData = class {
	constructor(options) {
		if (options) {
			this.base64 = options.base64;
			this.json = options.json;
			this.links = options.links;
			this.jws = options.jws;
			this.sha256 = options.sha256;
		}
	}
};
require_decorate.__decorate([
	(0, import_cjs$1.IsOptional)(),
	(0, import_cjs$1.IsString)(),
	require_decorateMetadata.__decorateMetadata("design:type", String)
], DidCommAttachmentData.prototype, "base64", void 0);
require_decorate.__decorate([(0, import_cjs$1.IsOptional)(), require_decorateMetadata.__decorateMetadata("design:type", Object)], DidCommAttachmentData.prototype, "json", void 0);
require_decorate.__decorate([
	(0, import_cjs$1.IsOptional)(),
	(0, import_cjs$1.IsString)({ each: true }),
	require_decorateMetadata.__decorateMetadata("design:type", Array)
], DidCommAttachmentData.prototype, "links", void 0);
require_decorate.__decorate([(0, import_cjs$1.IsOptional)(), require_decorateMetadata.__decorateMetadata("design:type", Object)], DidCommAttachmentData.prototype, "jws", void 0);
require_decorate.__decorate([
	(0, import_cjs$1.IsOptional)(),
	(0, import_cjs$1.IsHash)("sha256"),
	require_decorateMetadata.__decorateMetadata("design:type", String)
], DidCommAttachmentData.prototype, "sha256", void 0);
/**
* Represents DIDComm attachment
* https://github.com/hyperledger/aries-rfcs/blob/master/concepts/0017-attachments/README.md
*/
var DidCommAttachment = class {
	constructor(options) {
		if (options) {
			this.id = options.id ?? __credo_ts_core.utils.uuid();
			this.description = options.description;
			this.filename = options.filename;
			this.mimeType = options.mimeType;
			this.lastmodTime = options.lastmodTime;
			this.byteCount = options.byteCount;
			this.data = new DidCommAttachmentData(options.data);
		}
	}
	getDataAsJson() {
		if (typeof this.data.base64 === "string") return __credo_ts_core.JsonEncoder.fromBase64(this.data.base64);
		if (this.data.json) return this.data.json;
		throw new __credo_ts_core.CredoError("No attachment data found in `json` or `base64` data fields.");
	}
	addJws(jws) {
		const { payload,...detachedJws } = jws;
		if (!this.data.jws) this.data.jws = detachedJws;
		else if ("signatures" in this.data.jws) this.data.jws.signatures.push(detachedJws);
		else this.data.jws = { signatures: [this.data.jws, detachedJws] };
	}
};
require_decorate.__decorate([(0, import_cjs.Expose)({ name: "@id" }), require_decorateMetadata.__decorateMetadata("design:type", String)], DidCommAttachment.prototype, "id", void 0);
require_decorate.__decorate([
	(0, import_cjs$1.IsOptional)(),
	(0, import_cjs$1.IsString)(),
	require_decorateMetadata.__decorateMetadata("design:type", String)
], DidCommAttachment.prototype, "description", void 0);
require_decorate.__decorate([
	(0, import_cjs$1.IsOptional)(),
	(0, import_cjs$1.IsString)(),
	require_decorateMetadata.__decorateMetadata("design:type", String)
], DidCommAttachment.prototype, "filename", void 0);
require_decorate.__decorate([
	(0, import_cjs.Expose)({ name: "mime-type" }),
	(0, import_cjs$1.IsOptional)(),
	(0, import_cjs$1.IsMimeType)(),
	require_decorateMetadata.__decorateMetadata("design:type", String)
], DidCommAttachment.prototype, "mimeType", void 0);
require_decorate.__decorate([
	(0, import_cjs.Expose)({ name: "lastmod_time" }),
	(0, import_cjs.Type)(() => Date),
	(0, import_cjs$1.IsOptional)(),
	(0, import_cjs$1.IsDate)(),
	require_decorateMetadata.__decorateMetadata("design:type", typeof (_ref = typeof Date !== "undefined" && Date) === "function" ? _ref : Object)
], DidCommAttachment.prototype, "lastmodTime", void 0);
require_decorate.__decorate([
	(0, import_cjs.Expose)({ name: "byte_count" }),
	(0, import_cjs$1.IsOptional)(),
	(0, import_cjs$1.IsInt)(),
	require_decorateMetadata.__decorateMetadata("design:type", Number)
], DidCommAttachment.prototype, "byteCount", void 0);
require_decorate.__decorate([
	(0, import_cjs.Type)(() => DidCommAttachmentData),
	(0, import_cjs$1.ValidateNested)(),
	(0, import_cjs$1.IsInstance)(DidCommAttachmentData),
	require_decorateMetadata.__decorateMetadata("design:type", typeof (_ref2 = typeof DidCommAttachmentData !== "undefined" && DidCommAttachmentData) === "function" ? _ref2 : Object)
], DidCommAttachment.prototype, "data", void 0);

//#endregion
exports.DidCommAttachment = DidCommAttachment;
exports.DidCommAttachmentData = DidCommAttachmentData;