import 'package:fladder/jellyfin/jellyfin_open_api.swagger.dart';
import 'package:fladder/models/item_base_model.dart';
import 'package:fladder/models/items/images_models.dart';
import 'package:fladder/models/items/item_shared_models.dart';
import 'package:fladder/models/items/overview_model.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

import 'package:dart_mappable/dart_mappable.dart';

part 'boxset_model.mapper.dart';

@MappableClass()
class BoxSetModel extends ItemBaseModel with BoxSetModelMappable {
  final List<ItemBaseModel> items;
  const BoxSetModel({
    this.items = const [],
    required super.name,
    required super.id,
    required super.overview,
    required super.parentId,
    required super.playlistId,
    required super.images,
    required super.childCount,
    required super.primaryRatio,
    required super.userData,
    required super.canDelete,
    required super.canDownload,
    super.jellyType,
  });

  factory BoxSetModel.fromBaseDto(BaseItemDto item, Ref ref) {
    return BoxSetModel(
      name: item.name ?? "",
      id: item.id ?? "",
      childCount: item.childCount,
      overview: OverviewModel.fromBaseItemDto(item, ref),
      userData: UserData.fromDto(item.userData),
      parentId: item.parentId,
      playlistId: item.playlistItemId,
      images: ImagesData.fromBaseItem(item, ref),
      primaryRatio: item.primaryImageAspectRatio,
      canDelete: item.canDelete,
      canDownload: item.canDownload,
      jellyType: item.type,
    );
  }
}
