// SPDX-FileCopyrightText: 2026 FocusFlow contributors
// SPDX-License-Identifier: AGPL-3.0-only

part of '../../task_actions.dart';

/// Domain result for a flexible task quick action.
///
/// This result deliberately supports three outcomes: the task changed, the user
/// must choose a push destination, or the UI should start the child-task flow.
/// That keeps card code from guessing how to interpret each action.
class FlexibleTaskActionResult {
  /// Creates a `FlexibleTaskActionResult` 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.
  FlexibleTaskActionResult({
    required this.action,
    required this.task,
    this.pushDestinations = const <PushDestination>[],
    this.startsChildTaskFlow = false,
    List<TaskActivity> activities = const <TaskActivity>[],
    this.transitionOutcomeCode,
  }) : activities = List<TaskActivity>.unmodifiable(activities);

  /// Action the user selected.
  final FlexibleTaskQuickAction action;

  /// Current or updated task, depending on the action.
  final Task task;

  /// Destination choices to show after `push`; empty for direct actions.
  final List<PushDestination> pushDestinations;

  /// Whether the UI should open a child-task creation flow.
  final bool startsChildTaskFlow;

  /// Internal activities produced by direct lifecycle actions.
  final List<TaskActivity> activities;

  /// Typed transition outcome for direct lifecycle actions.
  final TaskTransitionOutcomeCode? transitionOutcomeCode;

  /// True when the action directly produced an updated [task].
  bool get changedTask => !startsChildTaskFlow && pushDestinations.isEmpty;
}
