

import { _classPrivateFieldInitSpec } from "../../_virtual/_@oxc-project_runtime@0.94.0/helpers/classPrivateFieldInitSpec.mjs";
import { _classPrivateFieldSet2 } from "../../_virtual/_@oxc-project_runtime@0.94.0/helpers/classPrivateFieldSet2.mjs";
import { _classPrivateFieldGet2 } from "../../_virtual/_@oxc-project_runtime@0.94.0/helpers/classPrivateFieldGet2.mjs";
import { X509Certificate } from "./X509Certificate.mjs";

//#region src/modules/x509/X509ModuleConfig.ts
var _trustedCertificates = /* @__PURE__ */ new WeakMap();
var _getTrustedCertificatesForVerification = /* @__PURE__ */ new WeakMap();
var X509ModuleConfig = class {
	constructor(options) {
		_classPrivateFieldInitSpec(this, _trustedCertificates, void 0);
		_classPrivateFieldInitSpec(this, _getTrustedCertificatesForVerification, void 0);
		this.setTrustedCertificates(options?.trustedCertificates);
		if (options?.getTrustedCertificatesForVerification) this.setTrustedCertificatesForVerification(options.getTrustedCertificatesForVerification);
	}
	get trustedCertificates() {
		return _classPrivateFieldGet2(_trustedCertificates, this)?.map((cert) => cert.toString("pem"));
	}
	get getTrustedCertificatesForVerification() {
		return _classPrivateFieldGet2(_getTrustedCertificatesForVerification, this);
	}
	setTrustedCertificatesForVerification(fn) {
		_classPrivateFieldSet2(_getTrustedCertificatesForVerification, this, fn);
	}
	setTrustedCertificates(trustedCertificates) {
		const certificateInstances = trustedCertificates?.map((trustedCertificate) => typeof trustedCertificate === "string" ? X509Certificate.fromEncodedCertificate(trustedCertificate) : trustedCertificate);
		_classPrivateFieldSet2(_trustedCertificates, this, trustedCertificates?.length ? certificateInstances : void 0);
	}
	addTrustedCertificate(trustedCertificate) {
		const certificateInstance = typeof trustedCertificate === "string" ? X509Certificate.fromEncodedCertificate(trustedCertificate) : trustedCertificate;
		if (!_classPrivateFieldGet2(_trustedCertificates, this)) _classPrivateFieldSet2(_trustedCertificates, this, []);
		_classPrivateFieldGet2(_trustedCertificates, this).push(certificateInstance);
	}
};

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