import 'package:freezed_annotation/freezed_annotation.dart';

import '../../../../../api/marianumconnect/queries/get_ticker/get_ticker_response.dart';
import '../../../../../api/marianumconnect/queries/get_ticker_nav/get_ticker_nav_response.dart';

part 'ticker_state.freezed.dart';
part 'ticker_state.g.dart';

/// Hydrated ticker module state: the current "Aktuelles" post, the filtered
/// page tree and the slug of the page the user last had open ([selectedSlug],
/// null = "Aktuelles" home). Persisting the slug lets the ticker reopen on the
/// last page instead of always falling back to home; a slug that is no longer
/// in [nav] (deleted/hidden) is discarded by the view. Page contents are loaded
/// on demand in the detail screen and are deliberately not cached here.
@freezed
abstract class TickerState with _$TickerState {
  const factory TickerState({
    TickerResponse? ticker,
    TickerNavResponse? nav,
    String? selectedSlug,
  }) = _TickerState;

  factory TickerState.fromJson(Map<String, dynamic> json) =>
      _$TickerStateFromJson(json);
}
