// GENERATED CODE - DO NOT MODIFY BY HAND

part of 'vocabulary_book_model.dart';

// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************

VocabularyBook _$VocabularyBookFromJson(Map<String, dynamic> json) =>
    VocabularyBook(
      id: json['id'] as String,
      name: json['name'] as String,
      description: json['description'] as String?,
      type: $enumDecodeNullable(_$VocabularyBookTypeEnumMap, json['type']) ??
          VocabularyBookType.system,
      difficulty: $enumDecode(_$VocabularyBookDifficultyEnumMap, json['level']),
      coverImageUrl: json['cover_image'] as String?,
      totalWords: (json['total_words'] as num).toInt(),
      creatorId: json['creator_id'] as String?,
      creatorName: json['creator_name'] as String?,
      isPublic: json['is_public'] as bool? ?? false,
      tags:
          (json['tags'] as List<dynamic>?)?.map((e) => e as String).toList() ??
              [],
      category: json['category'] as String?,
      mainCategory: $enumDecodeNullable(
          _$VocabularyBookMainCategoryEnumMap, json['main_category']),
      subCategory: json['sub_category'] as String?,
      targetLevels: (json['target_levels'] as List<dynamic>?)
              ?.map((e) => e as String)
              .toList() ??
          [],
      estimatedDays: (json['estimated_days'] as num?)?.toInt() ?? 30,
      dailyWordCount: (json['daily_word_count'] as num?)?.toInt() ?? 20,
      downloadCount: (json['download_count'] as num?)?.toInt() ?? 0,
      rating: (json['rating'] as num?)?.toDouble() ?? 0.0,
      reviewCount: (json['review_count'] as num?)?.toInt() ?? 0,
      createdAt: DateTime.parse(json['created_at'] as String),
      updatedAt: DateTime.parse(json['updated_at'] as String),
    );

Map<String, dynamic> _$VocabularyBookToJson(VocabularyBook instance) =>
    <String, dynamic>{
      'id': instance.id,
      'name': instance.name,
      'description': instance.description,
      'type': _$VocabularyBookTypeEnumMap[instance.type]!,
      'level': _$VocabularyBookDifficultyEnumMap[instance.difficulty]!,
      'cover_image': instance.coverImageUrl,
      'total_words': instance.totalWords,
      'creator_id': instance.creatorId,
      'creator_name': instance.creatorName,
      'is_public': instance.isPublic,
      'tags': instance.tags,
      'category': instance.category,
      'main_category':
          _$VocabularyBookMainCategoryEnumMap[instance.mainCategory],
      'sub_category': instance.subCategory,
      'target_levels': instance.targetLevels,
      'estimated_days': instance.estimatedDays,
      'daily_word_count': instance.dailyWordCount,
      'download_count': instance.downloadCount,
      'rating': instance.rating,
      'review_count': instance.reviewCount,
      'created_at': instance.createdAt.toIso8601String(),
      'updated_at': instance.updatedAt.toIso8601String(),
    };

const _$VocabularyBookTypeEnumMap = {
  VocabularyBookType.system: 'system',
  VocabularyBookType.custom: 'custom',
  VocabularyBookType.shared: 'shared',
};

const _$VocabularyBookDifficultyEnumMap = {
  VocabularyBookDifficulty.beginner: 'beginner',
  VocabularyBookDifficulty.elementary: 'elementary',
  VocabularyBookDifficulty.intermediate: 'intermediate',
  VocabularyBookDifficulty.advanced: 'advanced',
  VocabularyBookDifficulty.expert: 'expert',
};

const _$VocabularyBookMainCategoryEnumMap = {
  VocabularyBookMainCategory.academicStage: 'academic_stage',
  VocabularyBookMainCategory.domesticTest: 'domestic_test',
  VocabularyBookMainCategory.internationalTest: 'international_test',
  VocabularyBookMainCategory.professional: 'professional',
  VocabularyBookMainCategory.functional: 'functional',
};

UserVocabularyBookProgress _$UserVocabularyBookProgressFromJson(
        Map<String, dynamic> json) =>
    UserVocabularyBookProgress(
      id: UserVocabularyBookProgress._idFromJson(json['id']),
      userId: UserVocabularyBookProgress._userIdFromJson(json['user_id']),
      vocabularyBookId: json['book_id'] as String,
      learnedWords: (json['learned_words'] as num?)?.toInt() ?? 0,
      masteredWords: (json['mastered_words'] as num?)?.toInt() ?? 0,
      progressPercentage:
          (json['progress_percentage'] as num?)?.toDouble() ?? 0.0,
      streakDays: (json['streak_days'] as num?)?.toInt() ?? 0,
      totalStudyDays: (json['total_study_days'] as num?)?.toInt() ?? 0,
      averageDailyWords:
          (json['average_daily_words'] as num?)?.toDouble() ?? 0.0,
      estimatedCompletionDate: json['estimated_completion_date'] == null
          ? null
          : DateTime.parse(json['estimated_completion_date'] as String),
      isCompleted: json['is_completed'] as bool? ?? false,
      completedAt: json['completed_at'] == null
          ? null
          : DateTime.parse(json['completed_at'] as String),
      startedAt: DateTime.parse(json['started_at'] as String),
      lastStudiedAt: json['last_studied_at'] == null
          ? null
          : DateTime.parse(json['last_studied_at'] as String),
    );

Map<String, dynamic> _$UserVocabularyBookProgressToJson(
        UserVocabularyBookProgress instance) =>
    <String, dynamic>{
      'id': instance.id,
      'user_id': instance.userId,
      'book_id': instance.vocabularyBookId,
      'learned_words': instance.learnedWords,
      'mastered_words': instance.masteredWords,
      'progress_percentage': instance.progressPercentage,
      'streak_days': instance.streakDays,
      'total_study_days': instance.totalStudyDays,
      'average_daily_words': instance.averageDailyWords,
      'estimated_completion_date':
          instance.estimatedCompletionDate?.toIso8601String(),
      'is_completed': instance.isCompleted,
      'completed_at': instance.completedAt?.toIso8601String(),
      'started_at': instance.startedAt.toIso8601String(),
      'last_studied_at': instance.lastStudiedAt?.toIso8601String(),
    };

VocabularyBookWord _$VocabularyBookWordFromJson(Map<String, dynamic> json) =>
    VocabularyBookWord(
      id: VocabularyBookWord._idFromJson(json['id']),
      vocabularyBookId: json['book_id'] as String,
      wordId: json['vocabulary_id'] as String,
      order: (json['sort_order'] as num?)?.toInt() ?? 0,
      word: json['word'] == null
          ? null
          : Word.fromJson(json['word'] as Map<String, dynamic>),
      addedAt: DateTime.parse(json['created_at'] as String),
    );

Map<String, dynamic> _$VocabularyBookWordToJson(VocabularyBookWord instance) =>
    <String, dynamic>{
      'id': instance.id,
      'book_id': instance.vocabularyBookId,
      'vocabulary_id': instance.wordId,
      'sort_order': instance.order,
      'word': instance.word,
      'created_at': instance.addedAt.toIso8601String(),
    };
