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

part of '../demo_scheduler_composition.dart';

/// Top-level helper that performs the `_todaySeedTasks` operation for this file.
/// Keeping the helper private makes the surrounding flow easier to read while preventing unrelated libraries from depending on implementation detail.
List<Task> _todaySeedTasks(CivilDate date, DateTime createdAt) {
  return [
    _seedTask(
      id: 'clean-coffee-maker',
      title: 'Clean coffee maker',
      type: TaskType.flexible,
      status: TaskStatus.planned,
      date: date,
      startHour: 16,
      startMinute: 15,
      endHour: 16,
      endMinute: 30,
      reward: RewardLevel.medium,
      difficulty: DifficultyLevel.easy,
      createdAt: createdAt,
    ),
    _seedTask(
      id: 'cleaned-kitchen-counter',
      title: 'Cleaned kitchen counter',
      type: TaskType.flexible,
      status: TaskStatus.completed,
      date: date,
      startHour: 8,
      startMinute: 15,
      endHour: 8,
      endMinute: 30,
      reward: RewardLevel.medium,
      difficulty: DifficultyLevel.medium,
      completedAt: _instant(date, 8, 5),
      createdAt: createdAt,
    ),
    _seedTask(
      id: 'sort-mail',
      title: 'Sort mail',
      type: TaskType.flexible,
      status: TaskStatus.planned,
      date: date,
      startHour: 14,
      startMinute: 40,
      endHour: 15,
      endMinute: 20,
      reward: RewardLevel.low,
      difficulty: DifficultyLevel.easy,
      createdAt: createdAt,
    ),
    _seedTask(
      id: 'start-laundry',
      title: 'Start laundry',
      type: TaskType.flexible,
      status: TaskStatus.planned,
      date: date,
      startHour: 15,
      startMinute: 0,
      endHour: 15,
      endMinute: 40,
      reward: RewardLevel.medium,
      difficulty: DifficultyLevel.medium,
      createdAt: createdAt,
    ),
    _seedTask(
      id: 'water-plants',
      title: 'Water plants',
      type: TaskType.flexible,
      status: TaskStatus.planned,
      date: date,
      startHour: 15,
      startMinute: 20,
      endHour: 16,
      endMinute: 0,
      reward: RewardLevel.medium,
      difficulty: DifficultyLevel.medium,
      createdAt: createdAt,
    ),
    _seedTask(
      id: 'pay-bill',
      title: 'Pay bill',
      type: TaskType.critical,
      status: TaskStatus.planned,
      date: date,
      startHour: 18,
      startMinute: 0,
      endHour: 18,
      endMinute: 10,
      reward: RewardLevel.low,
      difficulty: DifficultyLevel.medium,
      createdAt: createdAt,
    ),
    _seedTask(
      id: 'doctor-appointment',
      title: 'Doctor appointment',
      type: TaskType.inflexible,
      status: TaskStatus.planned,
      date: date,
      startHour: 18,
      startMinute: 30,
      endHour: 19,
      endMinute: 15,
      reward: RewardLevel.medium,
      difficulty: DifficultyLevel.hard,
      createdAt: createdAt,
    ),
    _seedTask(
      id: 'free-slot',
      title: 'Free Slot',
      type: TaskType.freeSlot,
      status: TaskStatus.planned,
      date: date,
      startHour: 19,
      startMinute: 15,
      endHour: 20,
      endMinute: 15,
      reward: RewardLevel.notSet,
      difficulty: DifficultyLevel.notSet,
      createdAt: createdAt,
    ),
  ];
}

/// Top-level helper that performs the `_seedTask` operation for this file.
/// Keeping the helper private makes the surrounding flow easier to read while preventing unrelated libraries from depending on implementation detail.
Task _seedTask({
  required String id,
  required String title,
  required TaskType type,
  required TaskStatus status,
  required CivilDate date,
  required int startHour,
  required int startMinute,
  required int endHour,
  required int endMinute,
  required RewardLevel reward,
  required DifficultyLevel difficulty,
  required DateTime createdAt,
  DateTime? completedAt,
}) {
  final start = _instant(date, startHour, startMinute);
  final end = _instant(date, endHour, endMinute);
  return Task(
    id: id,
    title: title,
    projectId: DemoSchedulerComposition.projectId,
    type: type,
    status: status,
    priority: PriorityLevel.medium,
    reward: reward,
    difficulty: difficulty,
    durationMinutes: end.difference(start).inMinutes,
    scheduledStart: start,
    scheduledEnd: end,
    actualStart: status == TaskStatus.completed ? start : null,
    actualEnd: status == TaskStatus.completed ? end : null,
    completedAt: completedAt,
    createdAt: createdAt,
    updatedAt: completedAt ?? createdAt,
  );
}
