"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.getUnhydratedContext = void 0;
const index_js_1 = require("../feature-libraries/index.js");
const index_js_2 = require("../util/index.js");
const index_js_3 = require("./core/index.js");
const schemaTypes_js_1 = require("./schemaTypes.js");
const toStoredSchema_js_1 = require("./toStoredSchema.js");
const contextCache = new WeakMap();
/**
 * Utility for creating {@link Context}s for unhydrated nodes.
 */
function getUnhydratedContext(schema) {
    return (0, index_js_2.getOrCreate)(contextCache, schema, (s) => {
        const normalized = (0, schemaTypes_js_1.normalizeFieldSchema)(schema);
        const flexContext = new index_js_3.UnhydratedContext(index_js_1.defaultSchemaPolicy, (0, toStoredSchema_js_1.toStoredSchema)(schema));
        return new index_js_3.Context(normalized.allowedTypeSet, flexContext);
    });
}
exports.getUnhydratedContext = getUnhydratedContext;
//# sourceMappingURL=createContext.js.map