/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
/**
 * Defines a side relative to a character in a sequence.
 *
 * @remarks See {@link SequencePlace} for additional context on usage.
 * @legacy @beta
 */
export var Side;
(function (Side) {
    Side[Side["Before"] = 0] = "Before";
    Side[Side["After"] = 1] = "After";
})(Side || (Side = {}));
/**
 * Returns the position and side of the start and end of a sequence.
 *
 * @legacy @beta
 */
export function endpointPosAndSide(start, end) {
    const startIsPlainEndpoint = typeof start === "number" || start === "start" || start === "end";
    const endIsPlainEndpoint = typeof end === "number" || end === "start" || end === "end";
    const startSide = startIsPlainEndpoint ? Side.Before : start?.side;
    const endSide = endIsPlainEndpoint ? Side.Before : end?.side;
    const startPos = startIsPlainEndpoint ? start : start?.pos;
    const endPos = endIsPlainEndpoint ? end : end?.pos;
    return {
        startSide,
        endSide,
        startPos,
        endPos,
    };
}
/**
 * Returns the given place in InteriorSequencePlace form.
 */
export function normalizePlace(place) {
    if (typeof place === "number") {
        return { pos: place, side: Side.Before };
    }
    if (place === "start") {
        return { pos: -1, side: Side.After };
    }
    if (place === "end") {
        return { pos: -1, side: Side.Before };
    }
    return place;
}
//# sourceMappingURL=sequencePlace.js.map