"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.applySpecRegistryAddSafety = applySpecRegistryAddSafety;
const document_io_1 = require("./document-io");
function applySpecRegistryAddSafety(input) {
    if (!input.validationResult.ok) {
        return {
            ok: false,
            findings: input.validationResult.findings
        };
    }
    return {
        ok: true,
        entry: input.validationResult.entry,
        document: buildNonDestructiveUpdatedDocument(input.currentDocument, input.validationResult.entry)
    };
}
function buildNonDestructiveUpdatedDocument(currentDocument, entry) {
    return (0, document_io_1.buildSpecIndexDocumentWithEntries)(currentDocument, [...currentDocument.entries, entry]);
}
