"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSimpleContextFromInnerNode = exports.getSimpleNodeSchemaFromInnerNode = void 0;
const internal_1 = require("@fluidframework/core-utils/internal");
const index_js_1 = require("../../util/index.js");
const unhydratedFlexTree_js_1 = require("./unhydratedFlexTree.js");
const context_js_1 = require("./context.js");
/**
 * Gets the {@link TreeNodeSchema} for the {@link InnerNode}.
 */
function getSimpleNodeSchemaFromInnerNode(innerNode) {
    const context = getSimpleContextFromInnerNode(innerNode);
    return context.schema.get(innerNode.schema) ?? (0, index_js_1.fail)("missing schema from context");
}
exports.getSimpleNodeSchemaFromInnerNode = getSimpleNodeSchemaFromInnerNode;
/**
 * Gets the {@link Context} for the {@link InnerNode}.
 */
function getSimpleContextFromInnerNode(innerNode) {
    if (innerNode instanceof unhydratedFlexTree_js_1.UnhydratedFlexTreeNode) {
        return innerNode.simpleContext;
    }
    const context = innerNode.anchorNode.anchorSet.slots.get(context_js_1.SimpleContextSlot);
    (0, internal_1.assert)(context !== undefined, 0xa55 /* missing simple tree context */);
    return context;
}
exports.getSimpleContextFromInnerNode = getSimpleContextFromInnerNode;
//# sourceMappingURL=schemaCaching.js.map