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

part of '../../../application_management.dart';

/// Card-level read model for one Backlog board task.
class BacklogBoardItemReadModel {
  /// Creates a Backlog board item from display-ready task metadata.
  BacklogBoardItemReadModel({
    required this.taskId,
    required this.title,
    required this.projectId,
    required this.projectName,
    required this.projectColorToken,
    required this.reward,
    required this.difficulty,
    required this.bucket,
    required this.bucketReason,
    required this.createdAt,
    required this.updatedAt,
    required List<BacklogChildPreviewReadModel> childPreview,
    required List<String> tags,
    this.subtitle,
    this.durationMinutes,
    this.priority,
    bool? hasChildren,
  })  : childPreview =
            List<BacklogChildPreviewReadModel>.unmodifiable(childPreview),
        tags = List<String>.unmodifiable(tags),
        hasChildren = hasChildren ?? childPreview.isNotEmpty;

  /// Stable task id used for selection and commands.
  final String taskId;

  /// User-facing task title.
  final String title;

  /// Optional subtitle or notes preview for card display.
  final String? subtitle;

  /// Owning project id.
  final String projectId;

  /// Display name for the owning project.
  final String projectName;

  /// UI color token for the owning project.
  final String projectColorToken;

  /// Estimated task duration in minutes, if captured.
  final int? durationMinutes;

  /// Optional task priority.
  final PriorityLevel? priority;

  /// Expected reward or payoff.
  final RewardLevel reward;

  /// Expected activation difficulty.
  final DifficultyLevel difficulty;

  /// Board bucket selected by scheduler policy.
  final BacklogBoardBucket bucket;

  /// User-facing reason for [bucket].
  final String bucketReason;

  /// Original task creation timestamp.
  final DateTime createdAt;

  /// Last task update timestamp.
  final DateTime updatedAt;

  /// Whether the task has child task metadata.
  final bool hasChildren;

  /// Preview rows for direct child tasks.
  final List<BacklogChildPreviewReadModel> childPreview;

  /// Display-ready task-local tag labels.
  final List<String> tags;
}
