/// Mirrors web/src/lib/api/types.ts LidarrSearchResult — one row in
/// `/api/lidarr/search` results. `in_library` and `requested` let the
/// UI gray out rows the user can't act on (already imported / already
/// awaiting review).
class LidarrSearchResult {
  const LidarrSearchResult({
    required this.mbid,
    required this.name,
    required this.secondaryText,
    required this.imageUrl,
    required this.artistMbid,
    required this.albumMbid,
    required this.inLibrary,
    required this.requested,
  });

  final String mbid;
  final String name;
  final String secondaryText;
  final String imageUrl;
  final String artistMbid;
  final String albumMbid;
  final bool inLibrary;
  final bool requested;

  factory LidarrSearchResult.fromJson(Map<String, dynamic> j) =>
      LidarrSearchResult(
        mbid: j['mbid'] as String? ?? '',
        name: j['name'] as String? ?? '',
        secondaryText: j['secondary_text'] as String? ?? '',
        imageUrl: j['image_url'] as String? ?? '',
        artistMbid: j['artist_mbid'] as String? ?? '',
        albumMbid: j['album_mbid'] as String? ?? '',
        inLibrary: j['in_library'] as bool? ?? false,
        requested: j['requested'] as bool? ?? false,
      );
}

enum LidarrRequestKind { artist, album, track }

extension LidarrRequestKindStr on LidarrRequestKind {
  String get wire => switch (this) {
        LidarrRequestKind.artist => 'artist',
        LidarrRequestKind.album => 'album',
        LidarrRequestKind.track => 'track',
      };
}
