import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../../../core/domain/usecases/series_resume_target.dart';


class EpisodeAutoSelectArgs {

  final bool autoSelectFirstEpisode;


  final String? autoSelectEpisodeId;


  final String? autoSelectSeasonId;

  const EpisodeAutoSelectArgs({
    required this.autoSelectFirstEpisode,
    required this.autoSelectEpisodeId,
    required this.autoSelectSeasonId,
  });


  factory EpisodeAutoSelectArgs.fromResume(
    AsyncValue<SeriesResumeTarget?>? resumeAsync,
  ) {
    final loading = resumeAsync?.isLoading ?? false;
    final target = resumeAsync?.value;
    return EpisodeAutoSelectArgs(
      autoSelectFirstEpisode: !loading,
      autoSelectEpisodeId: target?.episodeId,
      autoSelectSeasonId: target?.seasonId,
    );
  }
}
