import { z } from 'zod';
export const ReviewRequestStateSchema = z.enum([
    'pending-review',
    'pending-fix',
    'pending-approval',
    'approved',
    'merged',
    'closed',
]);
const VALID_TRANSITIONS = {
    'pending-review': ['pending-fix', 'pending-approval', 'closed'],
    'pending-fix': ['pending-review', 'pending-approval', 'merged', 'closed'],
    'pending-approval': ['approved', 'pending-fix', 'closed'],
    'approved': ['merged', 'closed'],
    'merged': [],
    'closed': [],
};
export class ReviewRequestState {
    value;
    constructor(value) {
        this.value = value;
    }
    static create(value) {
        const parsed = ReviewRequestStateSchema.parse(value);
        return new ReviewRequestState(parsed);
    }
    static pendingReview() {
        return new ReviewRequestState('pending-review');
    }
    static pendingFix() {
        return new ReviewRequestState('pending-fix');
    }
    static pendingApproval() {
        return new ReviewRequestState('pending-approval');
    }
    get current() {
        return this.value;
    }
    canTransitionTo(target) {
        return VALID_TRANSITIONS[this.value].includes(target);
    }
    transitionTo(target) {
        if (!this.canTransitionTo(target)) {
            throw new Error(`Invalid state transition: ${this.value} → ${target}`);
        }
        return new ReviewRequestState(target);
    }
    get isTerminal() {
        return this.value === 'merged' || this.value === 'closed';
    }
    get needsAction() {
        return this.value === 'pending-fix' || this.value === 'pending-review';
    }
    equals(other) {
        return this.value === other.value;
    }
    toString() {
        return this.value;
    }
}
//# sourceMappingURL=reviewRequestState.valueObject.js.map