// GENERATED CODE - DO NOT MODIFY BY HAND

part of 'word_model.dart';

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

Word _$WordFromJson(Map<String, dynamic> json) => Word(
      id: Word._idFromJson(json['id']),
      word: json['word'] as String,
      phonetic: json['phonetic'] as String?,
      audioUrl: json['audio_url'] as String?,
      definitions: (json['definitions'] as List<dynamic>?)
              ?.map((e) => WordDefinition.fromJson(e as Map<String, dynamic>))
              .toList() ??
          [],
      examples: (json['examples'] as List<dynamic>?)
              ?.map((e) => WordExample.fromJson(e as Map<String, dynamic>))
              .toList() ??
          [],
      synonyms: (json['synonyms'] as List<dynamic>?)
              ?.map((e) => e as String)
              .toList() ??
          [],
      antonyms: (json['antonyms'] as List<dynamic>?)
              ?.map((e) => e as String)
              .toList() ??
          [],
      etymology: json['etymology'] == null
          ? null
          : WordEtymology.fromJson(json['etymology'] as Map<String, dynamic>),
      difficulty: Word._difficultyFromJson(json['difficulty']),
      frequency: (json['frequency'] as num?)?.toInt() ?? 0,
      imageUrl: json['image_url'] as String?,
      memoryTip: json['memory_tip'] as String?,
      createdAt: DateTime.parse(json['created_at'] as String),
      updatedAt: DateTime.parse(json['updated_at'] as String),
    );

Map<String, dynamic> _$WordToJson(Word instance) => <String, dynamic>{
      'id': instance.id,
      'word': instance.word,
      'phonetic': instance.phonetic,
      'audio_url': instance.audioUrl,
      'definitions': instance.definitions,
      'examples': instance.examples,
      'synonyms': instance.synonyms,
      'antonyms': instance.antonyms,
      'etymology': instance.etymology,
      'difficulty': _$WordDifficultyEnumMap[instance.difficulty]!,
      'frequency': instance.frequency,
      'image_url': instance.imageUrl,
      'memory_tip': instance.memoryTip,
      'created_at': instance.createdAt.toIso8601String(),
      'updated_at': instance.updatedAt.toIso8601String(),
    };

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

WordDefinition _$WordDefinitionFromJson(Map<String, dynamic> json) =>
    WordDefinition(
      type: WordDefinition._typeFromJson(json['type']),
      definition: json['definition'] as String,
      translation: WordDefinition._translationFromJson(json['translation']),
      frequency: (json['frequency'] as num?)?.toInt() ?? 3,
    );

Map<String, dynamic> _$WordDefinitionToJson(WordDefinition instance) =>
    <String, dynamic>{
      'type': _$WordTypeEnumMap[instance.type]!,
      'definition': instance.definition,
      'translation': instance.translation,
      'frequency': instance.frequency,
    };

const _$WordTypeEnumMap = {
  WordType.noun: 'noun',
  WordType.verb: 'verb',
  WordType.adjective: 'adjective',
  WordType.adverb: 'adverb',
  WordType.preposition: 'preposition',
  WordType.conjunction: 'conjunction',
  WordType.interjection: 'interjection',
  WordType.pronoun: 'pronoun',
  WordType.article: 'article',
  WordType.phrase: 'phrase',
};

WordExample _$WordExampleFromJson(Map<String, dynamic> json) => WordExample(
      sentence: WordExample._sentenceFromJson(json['example']),
      translation: WordExample._exampleTranslationFromJson(json['translation']),
      audioUrl: json['audio_url'] as String?,
      source: json['source'] as String?,
    );

Map<String, dynamic> _$WordExampleToJson(WordExample instance) =>
    <String, dynamic>{
      'example': instance.sentence,
      'translation': instance.translation,
      'audio_url': instance.audioUrl,
      'source': instance.source,
    };

WordEtymology _$WordEtymologyFromJson(Map<String, dynamic> json) =>
    WordEtymology(
      roots:
          (json['roots'] as List<dynamic>?)?.map((e) => e as String).toList() ??
              const [],
      prefixes: (json['prefixes'] as List<dynamic>?)
              ?.map((e) => e as String)
              .toList() ??
          const [],
      suffixes: (json['suffixes'] as List<dynamic>?)
              ?.map((e) => e as String)
              .toList() ??
          const [],
      origin: json['origin'] as String?,
    );

Map<String, dynamic> _$WordEtymologyToJson(WordEtymology instance) =>
    <String, dynamic>{
      'roots': instance.roots,
      'prefixes': instance.prefixes,
      'suffixes': instance.suffixes,
      'origin': instance.origin,
    };

UserWordProgress _$UserWordProgressFromJson(Map<String, dynamic> json) =>
    UserWordProgress(
      id: UserWordProgress._idFromJson(json['id']),
      userId: UserWordProgress._userIdFromJson(json['user_id']),
      wordId: UserWordProgress._wordIdFromJson(json['vocabulary_id']),
      status: $enumDecode(_$LearningStatusEnumMap, json['status']),
      studyCount: (json['study_count'] as num?)?.toInt() ?? 0,
      correctCount: (json['correct_count'] as num?)?.toInt() ?? 0,
      wrongCount: (json['wrong_count'] as num?)?.toInt() ?? 0,
      proficiency: (json['proficiency'] as num?)?.toInt() ?? 0,
      nextReviewAt: json['next_review_at'] == null
          ? null
          : DateTime.parse(json['next_review_at'] as String),
      reviewInterval: (json['review_interval'] as num?)?.toInt() ?? 1,
      firstStudiedAt: DateTime.parse(json['first_studied_at'] as String),
      lastStudiedAt: DateTime.parse(json['last_studied_at'] as String),
      masteredAt: json['mastered_at'] == null
          ? null
          : DateTime.parse(json['mastered_at'] as String),
    );

Map<String, dynamic> _$UserWordProgressToJson(UserWordProgress instance) =>
    <String, dynamic>{
      'id': instance.id,
      'user_id': instance.userId,
      'vocabulary_id': instance.wordId,
      'status': _$LearningStatusEnumMap[instance.status]!,
      'study_count': instance.studyCount,
      'correct_count': instance.correctCount,
      'wrong_count': instance.wrongCount,
      'proficiency': instance.proficiency,
      'next_review_at': instance.nextReviewAt?.toIso8601String(),
      'review_interval': instance.reviewInterval,
      'first_studied_at': instance.firstStudiedAt.toIso8601String(),
      'last_studied_at': instance.lastStudiedAt.toIso8601String(),
      'mastered_at': instance.masteredAt?.toIso8601String(),
    };

const _$LearningStatusEnumMap = {
  LearningStatus.newWord: 'new',
  LearningStatus.learning: 'learning',
  LearningStatus.reviewing: 'reviewing',
  LearningStatus.mastered: 'mastered',
  LearningStatus.forgotten: 'forgotten',
};
