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

part of '../demo_scheduler_composition.dart';

/// Top-level helper that performs the `_demoProjects` 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<ProjectProfile> _demoProjects() {
  return [
    ProjectProfile(id: 'home', name: 'Home', colorKey: 'project-home'),
    ProjectProfile(id: 'work', name: 'Work', colorKey: 'project-work'),
    ProjectProfile(
      id: 'personal',
      name: 'Personal',
      colorKey: 'project-personal',
    ),
    ProjectProfile(
      id: 'learning',
      name: 'Learning',
      colorKey: 'project-learning',
    ),
    ProjectProfile(
      id: 'side-project',
      name: 'Side Project',
      colorKey: 'project-side-project',
    ),
  ];
}

/// 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 `_backlogSeedTasks` 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> _backlogSeedTasks(CivilDate date, DateTime createdAt) {
  return [
    _backlogSeedTask(
      id: 'reply-to-3-emails',
      title: 'Reply to 3 emails',
      projectId: 'home',
      order: 1,
      priority: PriorityLevel.medium,
      reward: RewardLevel.low,
      difficulty: DifficultyLevel.easy,
      durationMinutes: 10,
      createdAt: createdAt,
    ),
    _backlogSeedTask(
      id: 'update-project-status',
      title: 'Update project status',
      projectId: 'work',
      order: 2,
      priority: PriorityLevel.medium,
      reward: RewardLevel.low,
      difficulty: DifficultyLevel.easy,
      durationMinutes: 15,
      createdAt: createdAt,
    ),
    _backlogSeedTask(
      id: 'schedule-dentist-appt',
      title: 'Schedule dentist appt',
      projectId: 'personal',
      order: 3,
      priority: PriorityLevel.medium,
      reward: RewardLevel.low,
      difficulty: DifficultyLevel.easy,
      durationMinutes: 10,
      createdAt: createdAt,
    ),
    _backlogSeedTask(
      id: 'clean-up-downloads-folder',
      title: 'Clean up downloads folder',
      projectId: 'home',
      order: 4,
      priority: PriorityLevel.medium,
      reward: RewardLevel.low,
      difficulty: DifficultyLevel.easy,
      durationMinutes: 10,
      createdAt: createdAt,
    ),
    _backlogSeedTask(
      id: 'plan-tomorrow',
      title: 'Plan tomorrow',
      projectId: 'work',
      order: 5,
      priority: PriorityLevel.medium,
      reward: RewardLevel.low,
      difficulty: DifficultyLevel.easy,
      durationMinutes: 10,
      createdAt: createdAt,
    ),
    _backlogSeedTask(
      id: 'review-q3-budget',
      title: 'Review Q3 budget',
      projectId: 'work',
      order: 6,
      priority: PriorityLevel.high,
      reward: RewardLevel.medium,
      difficulty: DifficultyLevel.easy,
      durationMinutes: 60,
      createdAt: createdAt,
    ),
    _backlogSeedTask(
      id: 'plan-next-week',
      title: 'Plan next week',
      projectId: 'work',
      order: 7,
      priority: PriorityLevel.high,
      reward: RewardLevel.high,
      difficulty: DifficultyLevel.medium,
      durationMinutes: 30,
      createdAt: createdAt,
    ),
    _backlogSeedTask(
      id: 'define-weekly-goals',
      title: 'Define weekly goals',
      projectId: 'work',
      order: 8,
      priority: PriorityLevel.high,
      reward: RewardLevel.medium,
      difficulty: DifficultyLevel.medium,
      durationMinutes: 15,
      createdAt: createdAt,
    ),
    _backlogSeedTask(
      id: 'time-block-schedule',
      title: 'Time block schedule',
      projectId: 'work',
      order: 9,
      priority: PriorityLevel.high,
      reward: RewardLevel.medium,
      difficulty: DifficultyLevel.medium,
      durationMinutes: 15,
      createdAt: createdAt,
    ),
    _backlogSeedTask(
      id: 'organize-kitchen-drawers',
      title: 'Organize kitchen drawers',
      projectId: 'home',
      order: 10,
      priority: PriorityLevel.low,
      reward: RewardLevel.low,
      difficulty: DifficultyLevel.medium,
      durationMinutes: 45,
      createdAt: createdAt,
    ),
    _backlogSeedTask(
      id: 'renew-car-registration',
      title: 'Renew car registration',
      projectId: 'home',
      order: 11,
      priority: PriorityLevel.high,
      reward: RewardLevel.low,
      difficulty: DifficultyLevel.medium,
      durationMinutes: 25,
      createdAt: createdAt,
    ),
    _backlogSeedTask(
      id: 'build-analytics-dashboard',
      title: 'Build analytics dashboard',
      projectId: 'work',
      order: 12,
      priority: PriorityLevel.high,
      reward: RewardLevel.high,
      difficulty: DifficultyLevel.hard,
      durationMinutes: 120,
      createdAt: createdAt,
    ),
    _backlogSeedTask(
      id: 'write-marketing-strategy',
      title: 'Write marketing strategy',
      projectId: 'work',
      order: 13,
      priority: PriorityLevel.high,
      reward: RewardLevel.high,
      difficulty: DifficultyLevel.medium,
      durationMinutes: 90,
      createdAt: createdAt,
    ),
    _backlogSeedTask(
      id: 'complete-online-course',
      title: 'Complete online course',
      projectId: 'learning',
      order: 14,
      priority: PriorityLevel.medium,
      reward: RewardLevel.high,
      difficulty: DifficultyLevel.medium,
      durationMinutes: 90,
      createdAt: createdAt,
    ),
    _backlogSeedTask(
      id: 'module-1-foundations',
      title: 'Module 1: Foundations',
      projectId: 'learning',
      order: 15,
      priority: PriorityLevel.medium,
      reward: RewardLevel.medium,
      difficulty: DifficultyLevel.hard,
      durationMinutes: 15,
      createdAt: createdAt,
    ),
    _backlogSeedTask(
      id: 'module-2-deep-dive',
      title: 'Module 2: Deep Dive',
      projectId: 'learning',
      order: 16,
      priority: PriorityLevel.low,
      reward: RewardLevel.medium,
      difficulty: DifficultyLevel.hard,
      durationMinutes: 15,
      createdAt: createdAt,
    ),
    _backlogSeedTask(
      id: 'module-3-practice',
      title: 'Module 3: Practice',
      projectId: 'learning',
      order: 17,
      priority: PriorityLevel.low,
      reward: RewardLevel.medium,
      difficulty: DifficultyLevel.hard,
      durationMinutes: 15,
      createdAt: createdAt,
    ),
    _backlogSeedTask(
      id: 'learn-guitar',
      title: 'Learn guitar',
      projectId: 'personal',
      order: 18,
      priority: PriorityLevel.low,
      reward: RewardLevel.low,
      difficulty: DifficultyLevel.medium,
      durationMinutes: 30,
      backlogTags: const {BacklogTag.wishlist},
      createdAt: createdAt,
    ),
    _backlogSeedTask(
      id: 'start-youtube-channel',
      title: 'Start YouTube channel',
      projectId: 'side-project',
      order: 19,
      priority: PriorityLevel.low,
      reward: RewardLevel.low,
      difficulty: DifficultyLevel.medium,
      durationMinutes: 20,
      backlogTags: const {BacklogTag.wishlist},
      createdAt: createdAt,
    ),
    _backlogSeedTask(
      id: 'travel-to-japan',
      title: 'Travel to Japan',
      projectId: 'personal',
      order: 20,
      priority: PriorityLevel.medium,
      reward: RewardLevel.medium,
      difficulty: DifficultyLevel.medium,
      durationMinutes: 30,
      backlogTags: const {BacklogTag.wishlist},
      createdAt: createdAt,
    ),
    _backlogSeedTask(
      id: 'home-office-upgrade',
      title: 'Home office upgrade',
      projectId: 'home',
      order: 21,
      priority: PriorityLevel.low,
      reward: RewardLevel.low,
      difficulty: DifficultyLevel.medium,
      durationMinutes: 20,
      backlogTags: const {BacklogTag.wishlist},
      createdAt: createdAt,
    ),
    _backlogSeedTask(
      id: 'read-2-books',
      title: 'Read 2 books',
      projectId: 'personal',
      order: 22,
      priority: PriorityLevel.low,
      reward: RewardLevel.low,
      difficulty: DifficultyLevel.medium,
      durationMinutes: 15,
      backlogTags: const {BacklogTag.wishlist},
      createdAt: createdAt,
    ),
    _backlogSeedTask(
      id: 'sketch-app-icon-ideas',
      title: 'Sketch app icon ideas',
      projectId: 'side-project',
      order: 23,
      priority: PriorityLevel.medium,
      reward: RewardLevel.medium,
      difficulty: DifficultyLevel.easy,
      durationMinutes: 15,
      backlogTags: const {BacklogTag.wishlist},
      createdAt: createdAt,
    ),
    _backlogSeedTask(
      id: 'archive-photo-backlog',
      title: 'Archive photo backlog',
      projectId: 'personal',
      order: 24,
      priority: PriorityLevel.low,
      reward: RewardLevel.low,
      difficulty: DifficultyLevel.medium,
      durationMinutes: 15,
      backlogTags: const {BacklogTag.wishlist},
      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,
  );
}

/// Top-level helper that performs the `_backlogSeedTask` 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 _backlogSeedTask({
  required String id,
  required String title,
  required String projectId,
  required int order,
  required PriorityLevel priority,
  required RewardLevel reward,
  required DifficultyLevel difficulty,
  required int durationMinutes,
  required DateTime createdAt,
  Set<BacklogTag> backlogTags = const <BacklogTag>{},
}) {
  final orderedCreatedAt = createdAt.add(Duration(minutes: order));
  return Task(
    id: id,
    title: title,
    projectId: projectId,
    type: TaskType.flexible,
    status: TaskStatus.backlog,
    priority: priority,
    reward: reward,
    difficulty: difficulty,
    durationMinutes: durationMinutes,
    backlogTags: backlogTags,
    createdAt: orderedCreatedAt,
    updatedAt: orderedCreatedAt,
  );
}
