/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { Type } from "@sinclair/typebox";
/**
 * Helper for {@link Brand}.
 * This is split out into its own as thats the only way to:
 * - have doc comments for the field.
 * - make the field protected (so you don't accidentally try and read it).
 * - get nominal typing (so types produced without using this class can never be assignable to it).
 * - allow use as {@link Opaque} branded type (not assignable to `ValueType`, but captures `ValueType`).
 *
 * See {@link MakeNominal} for some more details.
 *
 * Do not use this class with `instanceof`: this will always be false at runtime,
 * but the compiler may think its true in some cases.
 *
 * @sealed
 * @alpha
 */
export class BrandedType {
    /**
     * This class should never exist at runtime, so make it un-constructable.
     */
    constructor() { }
}
/**
 * Converts a {@link Opaque} handle to the underlying branded type.
 *
 * It is assumed that only code that produces these "opaque" handles does this conversion,
 * allowing these handles to be considered opaque.
 * @alpha
 */
export function extractFromOpaque(value) {
    return value;
}
/**
 * Adds a type {@link Brand} to a value.
 *
 * Only do this when specifically allowed by the requirements of the type being converted to.
 * @alpha
 */
export function brand(value) {
    return value;
}
/**
 * Adds a type {@link Brand} to a value, returning it as a  {@link Opaque} handle.
 *
 * Only do this when specifically allowed by the requirements of the type being converted to.
 * @alpha
 */
export function brandOpaque(value) {
    return value;
}
/**
 * Create a TypeBox string schema for a branded string type.
 * This only validates that the value is a string,
 * and not that it came from the correct branded type (that information is lost when serialized).
 */
export function brandedStringType() {
    // This could use:
    // return TypeSystem.CreateType<T>(name, (options, value) => typeof value === "string")();
    // Since there isn't any useful custom validation to do and
    // TUnsafe is documented as unsupported in `typebox/compiler`,
    // opt for the compile time behavior like the above, but the runtime behavior of the built in string type.
    return Type.String();
}
export function brandedNumberType() {
    // See comments on `brandedStringType`.
    return Type.Number();
}
//# sourceMappingURL=brand.js.map