

const require_classPrivateFieldInitSpec = require('../../_virtual/_@oxc-project_runtime@0.94.0/helpers/classPrivateFieldInitSpec.js');
const require_classPrivateFieldSet2 = require('../../_virtual/_@oxc-project_runtime@0.94.0/helpers/classPrivateFieldSet2.js');
const require_classPrivateFieldGet2 = require('../../_virtual/_@oxc-project_runtime@0.94.0/helpers/classPrivateFieldGet2.js');
const require_X509Certificate = require('./X509Certificate.js');

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

//#endregion
exports.X509ModuleConfig = X509ModuleConfig;