"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.treeSchema = exports.fieldSchema = exports.emptyMap = exports.emptySet = void 0;
const util_1 = require("../../util");
const schema_1 = require("./schema");
/**
 * APIs to help build schema.
 *
 * See typedSchema.ts for a wrapper for these APIs that captures the types as TypeScript types
 * in addition to runtime data.
 */
/**
 * Empty readonly set.
 */
exports.emptySet = new Set();
/**
 * Empty readonly map.
 */
exports.emptyMap = new Map();
/**
 * Helper for building {@link FieldSchema}.
 * @alpha
 */
function fieldSchema(kind, types) {
    return {
        kind,
        types: types === undefined ? undefined : new Set(types),
    };
}
exports.fieldSchema = fieldSchema;
const defaultExtraGlobalFields = false;
/**
 * Helper for building {@link TreeSchema}.
 */
function treeSchema(data) {
    var _a, _b, _c, _d;
    const localFields = new Map();
    const local = (_a = data.localFields) !== null && _a !== void 0 ? _a : {};
    // eslint-disable-next-line no-restricted-syntax
    for (const key in local) {
        if (Object.prototype.hasOwnProperty.call(local, key)) {
            localFields.set((0, util_1.brand)(key), local[key]);
        }
    }
    return {
        localFields,
        globalFields: new Set((_b = data.globalFields) !== null && _b !== void 0 ? _b : []),
        extraLocalFields: data.extraLocalFields,
        extraGlobalFields: (_c = data.extraGlobalFields) !== null && _c !== void 0 ? _c : defaultExtraGlobalFields,
        value: (_d = data.value) !== null && _d !== void 0 ? _d : schema_1.ValueSchema.Nothing,
    };
}
exports.treeSchema = treeSchema;
//# sourceMappingURL=builders.js.map