import QueryError from "../../errors/QueryError.js";
const DEFAULT_FULL_READ_APERTURE_POSTURE = 'default-full-read';
const OBSERVER_OWNED_APERTURE_POSTURE = 'observer-owned-aperture';
export const OPTIC_APERTURE_POSTURES = Object.freeze([
    DEFAULT_FULL_READ_APERTURE_POSTURE,
    OBSERVER_OWNED_APERTURE_POSTURE,
]);
export default class OpticAperturePosture {
    value;
    constructor(value) {
        this.value = requireOpticAperturePostureValue(value);
        Object.freeze(this);
    }
    static defaultFullRead() {
        return new OpticAperturePosture(DEFAULT_FULL_READ_APERTURE_POSTURE);
    }
    static observerOwnedAperture() {
        return new OpticAperturePosture(OBSERVER_OWNED_APERTURE_POSTURE);
    }
    equals(other) {
        return this.value === other.value;
    }
    toString() {
        return this.value;
    }
}
export function requireOpticAperturePostureValue(value) {
    if (typeof value !== 'string') {
        throwOpticAperturePostureError();
    }
    const valid = OPTIC_APERTURE_POSTURES.find((candidate) => candidate === value);
    if (valid === undefined) {
        throwOpticAperturePostureError();
    }
    return valid;
}
function throwOpticAperturePostureError() {
    throw new QueryError('Optic aperture posture is invalid.', {
        code: 'E_OPTIC_SCHEMA',
        context: { field: 'aperturePosture' },
    });
}
