var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
    function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
    var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
    var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
    var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
    var _, done = false;
    for (var i = decorators.length - 1; i >= 0; i--) {
        var context = {};
        for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
        for (var p in contextIn.access) context.access[p] = contextIn.access[p];
        context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
        var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
        if (kind === "accessor") {
            if (result === void 0) continue;
            if (result === null || typeof result !== "object") throw new TypeError("Object expected");
            if (_ = accept(result.get)) descriptor.get = _;
            if (_ = accept(result.set)) descriptor.set = _;
            if (_ = accept(result.init)) initializers.unshift(_);
        }
        else if (_ = accept(result)) {
            if (kind === "field") initializers.unshift(_);
            else descriptor[key] = _;
        }
    }
    if (target) Object.defineProperty(target, contextIn.name, descriptor);
    done = true;
};
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
    var useValue = arguments.length > 2;
    for (var i = 0; i < initializers.length; i++) {
        value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
    }
    return useValue ? value : void 0;
};
import * as plugins from '../../plugins.js';
import { DcRouterDb } from '../classes.dcrouter-db.js';
const getDb = () => DcRouterDb.getInstance().getDb();
/**
 * Singleton ACME configuration document. One row per dcrouter instance,
 * keyed on the fixed `configId = 'acme-config'` following the
 * `VpnServerKeysDoc` pattern.
 *
 * Managed via the OpsServer UI at **Domains > Certificates > Settings**.
 */
let AcmeConfigDoc = (() => {
    let _classDecorators = [plugins.smartdata.Collection(() => getDb())];
    let _classDescriptor;
    let _classExtraInitializers = [];
    let _classThis;
    let _classSuper = plugins.smartdata.SmartDataDbDoc;
    let _configId_decorators;
    let _configId_initializers = [];
    let _configId_extraInitializers = [];
    let _accountEmail_decorators;
    let _accountEmail_initializers = [];
    let _accountEmail_extraInitializers = [];
    let _enabled_decorators;
    let _enabled_initializers = [];
    let _enabled_extraInitializers = [];
    let _useProduction_decorators;
    let _useProduction_initializers = [];
    let _useProduction_extraInitializers = [];
    let _autoRenew_decorators;
    let _autoRenew_initializers = [];
    let _autoRenew_extraInitializers = [];
    let _renewThresholdDays_decorators;
    let _renewThresholdDays_initializers = [];
    let _renewThresholdDays_extraInitializers = [];
    let _updatedAt_decorators;
    let _updatedAt_initializers = [];
    let _updatedAt_extraInitializers = [];
    let _updatedBy_decorators;
    let _updatedBy_initializers = [];
    let _updatedBy_extraInitializers = [];
    var AcmeConfigDoc = class extends _classSuper {
        static { _classThis = this; }
        static {
            const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
            _configId_decorators = [plugins.smartdata.unI(), plugins.smartdata.svDb()];
            _accountEmail_decorators = [plugins.smartdata.svDb()];
            _enabled_decorators = [plugins.smartdata.svDb()];
            _useProduction_decorators = [plugins.smartdata.svDb()];
            _autoRenew_decorators = [plugins.smartdata.svDb()];
            _renewThresholdDays_decorators = [plugins.smartdata.svDb()];
            _updatedAt_decorators = [plugins.smartdata.svDb()];
            _updatedBy_decorators = [plugins.smartdata.svDb()];
            __esDecorate(null, null, _configId_decorators, { kind: "field", name: "configId", static: false, private: false, access: { has: obj => "configId" in obj, get: obj => obj.configId, set: (obj, value) => { obj.configId = value; } }, metadata: _metadata }, _configId_initializers, _configId_extraInitializers);
            __esDecorate(null, null, _accountEmail_decorators, { kind: "field", name: "accountEmail", static: false, private: false, access: { has: obj => "accountEmail" in obj, get: obj => obj.accountEmail, set: (obj, value) => { obj.accountEmail = value; } }, metadata: _metadata }, _accountEmail_initializers, _accountEmail_extraInitializers);
            __esDecorate(null, null, _enabled_decorators, { kind: "field", name: "enabled", static: false, private: false, access: { has: obj => "enabled" in obj, get: obj => obj.enabled, set: (obj, value) => { obj.enabled = value; } }, metadata: _metadata }, _enabled_initializers, _enabled_extraInitializers);
            __esDecorate(null, null, _useProduction_decorators, { kind: "field", name: "useProduction", static: false, private: false, access: { has: obj => "useProduction" in obj, get: obj => obj.useProduction, set: (obj, value) => { obj.useProduction = value; } }, metadata: _metadata }, _useProduction_initializers, _useProduction_extraInitializers);
            __esDecorate(null, null, _autoRenew_decorators, { kind: "field", name: "autoRenew", static: false, private: false, access: { has: obj => "autoRenew" in obj, get: obj => obj.autoRenew, set: (obj, value) => { obj.autoRenew = value; } }, metadata: _metadata }, _autoRenew_initializers, _autoRenew_extraInitializers);
            __esDecorate(null, null, _renewThresholdDays_decorators, { kind: "field", name: "renewThresholdDays", static: false, private: false, access: { has: obj => "renewThresholdDays" in obj, get: obj => obj.renewThresholdDays, set: (obj, value) => { obj.renewThresholdDays = value; } }, metadata: _metadata }, _renewThresholdDays_initializers, _renewThresholdDays_extraInitializers);
            __esDecorate(null, null, _updatedAt_decorators, { kind: "field", name: "updatedAt", static: false, private: false, access: { has: obj => "updatedAt" in obj, get: obj => obj.updatedAt, set: (obj, value) => { obj.updatedAt = value; } }, metadata: _metadata }, _updatedAt_initializers, _updatedAt_extraInitializers);
            __esDecorate(null, null, _updatedBy_decorators, { kind: "field", name: "updatedBy", static: false, private: false, access: { has: obj => "updatedBy" in obj, get: obj => obj.updatedBy, set: (obj, value) => { obj.updatedBy = value; } }, metadata: _metadata }, _updatedBy_initializers, _updatedBy_extraInitializers);
            __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
            AcmeConfigDoc = _classThis = _classDescriptor.value;
            if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
            __runInitializers(_classThis, _classExtraInitializers);
        }
        configId = __runInitializers(this, _configId_initializers, 'acme-config');
        accountEmail = (__runInitializers(this, _configId_extraInitializers), __runInitializers(this, _accountEmail_initializers, ''));
        enabled = (__runInitializers(this, _accountEmail_extraInitializers), __runInitializers(this, _enabled_initializers, true));
        useProduction = (__runInitializers(this, _enabled_extraInitializers), __runInitializers(this, _useProduction_initializers, true));
        autoRenew = (__runInitializers(this, _useProduction_extraInitializers), __runInitializers(this, _autoRenew_initializers, true));
        renewThresholdDays = (__runInitializers(this, _autoRenew_extraInitializers), __runInitializers(this, _renewThresholdDays_initializers, 30));
        updatedAt = (__runInitializers(this, _renewThresholdDays_extraInitializers), __runInitializers(this, _updatedAt_initializers, 0));
        updatedBy = (__runInitializers(this, _updatedAt_extraInitializers), __runInitializers(this, _updatedBy_initializers, ''));
        constructor() {
            super();
            __runInitializers(this, _updatedBy_extraInitializers);
        }
        static async load() {
            return await AcmeConfigDoc.getInstance({ configId: 'acme-config' });
        }
    };
    return AcmeConfigDoc = _classThis;
})();
export { AcmeConfigDoc };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xhc3Nlcy5hY21lLWNvbmZpZy5kb2MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi90cy9kYi9kb2N1bWVudHMvY2xhc3Nlcy5hY21lLWNvbmZpZy5kb2MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLE9BQU8sS0FBSyxPQUFPLE1BQU0sa0JBQWtCLENBQUM7QUFDNUMsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBRXZELE1BQU0sS0FBSyxHQUFHLEdBQUcsRUFBRSxDQUFDLFVBQVUsQ0FBQyxXQUFXLEVBQUUsQ0FBQyxL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