/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { brand } from "../../util";
/**
 * 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.
 */
export const emptySet = new Set();
/**
 * Empty readonly map.
 */
export const emptyMap = new Map();
/**
 * Helper for building {@link TreeFieldStoredSchema}.
 * @alpha
 */
export function fieldSchema(kind, types) {
    return {
        kind,
        types: types === undefined ? undefined : new Set(types),
    };
}
/**
 * Helper for building {@link TreeNodeStoredSchema}.
 */
export function treeSchema(data) {
    const objectNodeFields = new Map();
    const fields = data.objectNodeFields ?? {};
    // eslint-disable-next-line no-restricted-syntax
    for (const key in fields) {
        if (Object.prototype.hasOwnProperty.call(fields, key)) {
            objectNodeFields.set(brand(key), fields[key]);
        }
    }
    return {
        objectNodeFields,
        mapFields: data.mapFields,
        leafValue: data.leafValue,
    };
}
//# sourceMappingURL=builders.js.map