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

part of '../../child_tasks.dart';

/// Result from breaking a parent task into direct children.
class ChildTaskBreakUpResult {
  /// Creates a `ChildTaskBreakUpResult` 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.
  ChildTaskBreakUpResult({
    required List<Task> tasks,
    required this.parentTask,
    required List<Task> childTasks,
    required this.operationId,
    List<String> createdChildTaskIds = const <String>[],
    List<TaskActivity> activities = const <TaskActivity>[],
  })  : tasks = List<Task>.unmodifiable(tasks),
        childTasks = List<Task>.unmodifiable(childTasks),
        createdChildTaskIds = List<String>.unmodifiable(createdChildTaskIds),
        activities = List<TaskActivity>.unmodifiable(activities);

  /// Replacement task list including newly created children.
  final List<Task> tasks;

  /// Parent that owns the created children.
  final Task parentTask;

  /// Created children in request order.
  final List<Task> childTasks;

  /// Idempotency key for the command.
  final String operationId;

  /// Child ids created by this command.
  final List<String> createdChildTaskIds;

  /// Activity records produced by this command.
  ///
  /// V1 child creation is represented by task inserts, so this is currently
  /// empty while still giving application use cases one atomic mutation shape.
  final List<TaskActivity> activities;
}
