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();
let AcmeCertDoc = (() => {
    let _classDecorators = [plugins.smartdata.Collection(() => getDb())];
    let _classDescriptor;
    let _classExtraInitializers = [];
    let _classThis;
    let _classSuper = plugins.smartdata.SmartDataDbDoc;
    let _domainName_decorators;
    let _domainName_initializers = [];
    let _domainName_extraInitializers = [];
    let _id_decorators;
    let _id_initializers = [];
    let _id_extraInitializers = [];
    let _created_decorators;
    let _created_initializers = [];
    let _created_extraInitializers = [];
    let _privateKey_decorators;
    let _privateKey_initializers = [];
    let _privateKey_extraInitializers = [];
    let _publicKey_decorators;
    let _publicKey_initializers = [];
    let _publicKey_extraInitializers = [];
    let _csr_decorators;
    let _csr_initializers = [];
    let _csr_extraInitializers = [];
    let _validUntil_decorators;
    let _validUntil_initializers = [];
    let _validUntil_extraInitializers = [];
    var AcmeCertDoc = class extends _classSuper {
        static { _classThis = this; }
        static {
            const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
            _domainName_decorators = [plugins.smartdata.unI(), plugins.smartdata.svDb()];
            _id_decorators = [plugins.smartdata.svDb()];
            _created_decorators = [plugins.smartdata.svDb()];
            _privateKey_decorators = [plugins.smartdata.svDb()];
            _publicKey_decorators = [plugins.smartdata.svDb()];
            _csr_decorators = [plugins.smartdata.svDb()];
            _validUntil_decorators = [plugins.smartdata.svDb()];
            __esDecorate(null, null, _domainName_decorators, { kind: "field", name: "domainName", static: false, private: false, access: { has: obj => "domainName" in obj, get: obj => obj.domainName, set: (obj, value) => { obj.domainName = value; } }, metadata: _metadata }, _domainName_initializers, _domainName_extraInitializers);
            __esDecorate(null, null, _id_decorators, { kind: "field", name: "id", static: false, private: false, access: { has: obj => "id" in obj, get: obj => obj.id, set: (obj, value) => { obj.id = value; } }, metadata: _metadata }, _id_initializers, _id_extraInitializers);
            __esDecorate(null, null, _created_decorators, { kind: "field", name: "created", static: false, private: false, access: { has: obj => "created" in obj, get: obj => obj.created, set: (obj, value) => { obj.created = value; } }, metadata: _metadata }, _created_initializers, _created_extraInitializers);
            __esDecorate(null, null, _privateKey_decorators, { kind: "field", name: "privateKey", static: false, private: false, access: { has: obj => "privateKey" in obj, get: obj => obj.privateKey, set: (obj, value) => { obj.privateKey = value; } }, metadata: _metadata }, _privateKey_initializers, _privateKey_extraInitializers);
            __esDecorate(null, null, _publicKey_decorators, { kind: "field", name: "publicKey", static: false, private: false, access: { has: obj => "publicKey" in obj, get: obj => obj.publicKey, set: (obj, value) => { obj.publicKey = value; } }, metadata: _metadata }, _publicKey_initializers, _publicKey_extraInitializers);
            __esDecorate(null, null, _csr_decorators, { kind: "field", name: "csr", static: false, private: false, access: { has: obj => "csr" in obj, get: obj => obj.csr, set: (obj, value) => { obj.csr = value; } }, metadata: _metadata }, _csr_initializers, _csr_extraInitializers);
            __esDecorate(null, null, _validUntil_decorators, { kind: "field", name: "validUntil", static: false, private: false, access: { has: obj => "validUntil" in obj, get: obj => obj.validUntil, set: (obj, value) => { obj.validUntil = value; } }, metadata: _metadata }, _validUntil_initializers, _validUntil_extraInitializers);
            __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
            AcmeCertDoc = _classThis = _classDescriptor.value;
            if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
            __runInitializers(_classThis, _classExtraInitializers);
        }
        domainName = __runInitializers(this, _domainName_initializers, void 0);
        id = (__runInitializers(this, _domainName_extraInitializers), __runInitializers(this, _id_initializers, void 0));
        created = (__runInitializers(this, _id_extraInitializers), __runInitializers(this, _created_initializers, void 0));
        privateKey = (__runInitializers(this, _created_extraInitializers), __runInitializers(this, _privateKey_initializers, void 0));
        publicKey = (__runInitializers(this, _privateKey_extraInitializers), __runInitializers(this, _publicKey_initializers, void 0));
        csr = (__runInitializers(this, _publicKey_extraInitializers), __runInitializers(this, _csr_initializers, void 0));
        validUntil = (__runInitializers(this, _csr_extraInitializers), __runInitializers(this, _validUntil_initializers, void 0));
        constructor() {
            super();
            __runInitializers(this, _validUntil_extraInitializers);
        }
        static async findByDomain(domainName) {
            return await AcmeCertDoc.getInstance({ domainName });
        }
        static async findAll() {
            return await AcmeCertDoc.getInstances({});
        }
    };
    return Acm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