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

part of '../../today_state.dart';

/// Complete V1 Today state for one owner-local date.
class TodayState {
  /// Creates a `TodayState` 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.
  TodayState({
    required this.date,
    required this.ownerId,
    required this.timeZoneId,
    required this.readAt,
    required this.dayStart,
    required this.dayEnd,
    required this.ownerSettings,
    required List<TodayTimelineItem> timelineItems,
    required this.compactState,
    required List<TodayPendingNotice> pendingNotices,
    this.currentItem,
    this.nextRequiredItem,
    this.nextFlexibleItem,
  })  : timelineItems = List<TodayTimelineItem>.unmodifiable(timelineItems),
        pendingNotices = List<TodayPendingNotice>.unmodifiable(pendingNotices);

  /// Owner-local date represented by this state.
  final CivilDate date;

  /// Authorization-neutral owner scope.
  final String ownerId;

  /// Time-zone id used for local-day expansion.
  final String timeZoneId;

  /// Read instant from the request context.
  final DateTime readAt;

  /// Resolved start instant for [date].
  final DateTime dayStart;

  /// Resolved end instant for [date].
  final DateTime dayEnd;

  /// Effective owner settings used by the query.
  final OwnerSettings ownerSettings;

  /// Full sorted UI-independent timeline projection.
  final List<TodayTimelineItem> timelineItems;

  /// Current item, if one occupies [readAt].
  final TodayTimelineItem? currentItem;

  /// Next required item after [readAt].
  final TodayTimelineItem? nextRequiredItem;

  /// Optional next flexible item after [readAt].
  final TodayTimelineItem? nextFlexibleItem;

  /// Compact-mode projection from [timelineItems].
  final TodayCompactState compactState;

  /// Pending scheduling notices stored for the day.
  final List<TodayPendingNotice> pendingNotices;
}
