/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { ValueSchema } from "../schema-stored";
import { brand, extractFromOpaque } from "../../util";
/**
 * The empty key ("") is used for unnamed relationships, such as the indexer
 * of an explicit array node.
 *
 * This key is a hint that this field is the primary function of the node,
 * and in some abstractions the APIs for this field should be inlined onto the node.
 *
 * TODO:
 * This has to be a FieldKey since different nodes will have different FieldStoredSchema for it.
 * This makes it prone to collisions and suggests
 * that this intention may be better conveyed by metadata on the ITreeSchema.
 * @alpha
 */
export const EmptyKey = brand("");
/**
 * FieldKey to use for the root of documents in places that need to refer to detached sequences or the root.
 * TODO: if we do want to standardize on a single value for this,
 * it likely should be namespaced or a UUID to avoid risk of collisions.
 * @alpha
 */
export const rootFieldKey = brand("rootFieldKey");
/**
 * @alpha
 */
export const rootField = keyAsDetachedField(rootFieldKey);
/**
 * Some code abstracts the root as a node with detached fields as its fields.
 * This maps detached field to field keys for thus use.
 *
 * @returns `field` as a {@link FieldKey} usable on a special root node serving as a parent of detached fields.
 * @alpha
 */
export function detachedFieldAsKey(field) {
    return brand(extractFromOpaque(field));
}
/**
 * The inverse of {@link detachedFieldAsKey}.
 * Thus must only be used on {@link FieldKey}s which were produced via {@link detachedFieldAsKey},
 * and with the same scope (ex: forest) as the detachedFieldAsKey was originally from.
 * @alpha
 */
export function keyAsDetachedField(key) {
    return brand(key);
}
//# sourceMappingURL=types.js.map