import WarpError from "../errors/WarpError.js";
const AVAILABLE_ACCESS = 'available';
const REDACTED_ACCESS = 'redacted';
const CREDENTIAL_REQUIRED_ACCESS = 'credential-required';
const DENIED_ACCESS = 'denied';
export const CONTINUUM_EVIDENCE_ACCESSES = Object.freeze([
    AVAILABLE_ACCESS,
    REDACTED_ACCESS,
    CREDENTIAL_REQUIRED_ACCESS,
    DENIED_ACCESS,
]);
/** Access coordinate for a Continuum evidence posture. */
export default class ContinuumEvidenceAccess {
    value;
    constructor(value) {
        this.value = requireContinuumEvidenceAccessValue(value);
        Object.freeze(this);
    }
    static available() {
        return new ContinuumEvidenceAccess(AVAILABLE_ACCESS);
    }
    static redacted() {
        return new ContinuumEvidenceAccess(REDACTED_ACCESS);
    }
    static credentialRequired() {
        return new ContinuumEvidenceAccess(CREDENTIAL_REQUIRED_ACCESS);
    }
    static denied() {
        return new ContinuumEvidenceAccess(DENIED_ACCESS);
    }
    isAvailable() {
        return this.value === AVAILABLE_ACCESS;
    }
    requiresCredential() {
        return this.value === CREDENTIAL_REQUIRED_ACCESS;
    }
    equals(other) {
        return this.value === other.value;
    }
    toString() {
        return this.value;
    }
}
export function requireContinuumEvidenceAccessValue(value) {
    if (typeof value !== 'string') {
        throw new WarpError(`Continuum evidence access must be one of: ${CONTINUUM_EVIDENCE_ACCESSES.join(', ')}`, 'E_VALIDATION');
    }
    const valid = CONTINUUM_EVIDENCE_ACCESSES.find((candidate) => candidate === value);
    if (valid === undefined) {
        throw new WarpError(`Continuum evidence access must be one of: ${CONTINUUM_EVIDENCE_ACCESSES.join(', ')}`, 'E_VALIDATION');
    }
    return valid;
}
