import QueryError from "../../errors/QueryError.js";
const LIVE_ONE_OFF_COORDINATE_POSTURE = 'live-one-off';
const CAPTURED_COORDINATE_POSTURE = 'captured-coordinate';
export const OPTIC_COORDINATE_POSTURES = Object.freeze([
    LIVE_ONE_OFF_COORDINATE_POSTURE,
    CAPTURED_COORDINATE_POSTURE,
]);
export default class OpticCoordinatePosture {
    value;
    constructor(value) {
        this.value = requireOpticCoordinatePostureValue(value);
        Object.freeze(this);
    }
    static liveOneOff() {
        return new OpticCoordinatePosture(LIVE_ONE_OFF_COORDINATE_POSTURE);
    }
    static capturedCoordinate() {
        return new OpticCoordinatePosture(CAPTURED_COORDINATE_POSTURE);
    }
    isCapturedCoordinate() {
        return this.value === CAPTURED_COORDINATE_POSTURE;
    }
    equals(other) {
        return this.value === other.value;
    }
    toString() {
        return this.value;
    }
}
export function requireOpticCoordinatePostureValue(value) {
    if (typeof value !== 'string') {
        throwOpticCoordinatePostureError();
    }
    const valid = OPTIC_COORDINATE_POSTURES.find((candidate) => candidate === value);
    if (valid === undefined) {
        throwOpticCoordinatePostureError();
    }
    return valid;
}
function throwOpticCoordinatePostureError() {
    throw new QueryError('Optic coordinate posture is invalid.', {
        code: 'E_OPTIC_SCHEMA',
        context: { field: 'coordinatePosture' },
    });
}
