"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.mapFromNamed = exports.namedTreeSchema = void 0;
const common_utils_1 = require("@fluidframework/common-utils");
const core_1 = require("../core");
const defaultSchema_1 = require("./defaultSchema");
/**
 * Helper for building {@link NamedTreeSchema}.
 * @alpha
 */
function namedTreeSchema(data) {
    return Object.assign({ name: data.name }, (0, core_1.treeSchema)(Object.assign({ extraLocalFields: defaultSchema_1.emptyField }, data)));
}
exports.namedTreeSchema = namedTreeSchema;
/**
 * @returns a map from name of item with that name from a collection of named items.
 */
function mapFromNamed(named) {
    const map = new Map();
    for (const item of named) {
        (0, common_utils_1.assert)(!map.has(item.name), 0x4bb /* cannot build map from named items with colliding names. */);
        map.set(item.name, item);
    }
    return map;
}
exports.mapFromNamed = mapFromNamed;
//# sourceMappingURL=viewSchemaUtil.js.map