// SPDX-FileCopyrightText: 2026 FocusFlow contributors // SPDX-License-Identifier: AGPL-3.0-only part of '../../persistence.dart'; /// Minimal Either type for expected repository success/failure paths. sealed class Either { /// Creates a `Either` instance with the values required by its invariants. /// Callers should pass already-normalized scheduler data because validation and defaulting belong at the model or service boundary, not in arbitrary UI code. const Either(); /// Whether this value is a left/failure value. bool get isLeft => this is Left; /// Whether this value is a right/success value. bool get isRight => this is Right; /// Return the left value or throw when this is right. L get left => switch (this) { Left(:final value) => value, Right() => throw StateError('Either does not contain left.'), }; /// Return the right value or throw when this is left. R get right => switch (this) { Left() => throw StateError('Either does not contain right.'), Right(:final value) => value, }; }