import '../models/word_model.dart';
import 'dart:math';

/// 测试数据生成器
class TestDataGenerator {
  static final Random _random = Random();
  
  /// 生成测试单词数据
  static List<Word> generateTestWords({int count = 20}) {
    final words = <Word>[];
    final testWordData = _getTestWordData();
    
    for (int i = 0; i < min(count, testWordData.length); i++) {
      final data = testWordData[i];
      words.add(_createWord(data));
    }
    
    return words;
  }
  
  /// 创建单词对象
  static Word _createWord(Map<String, dynamic> data) {
    return Word(
      id: data['id'],
      word: data['word'],
      phonetic: data['phonetic'],
      audioUrl: data['audioUrl'],
      difficulty: data['difficulty'],
      frequency: data['frequency'],
      definitions: (data['definitions'] as List).map((d) => WordDefinition(
        type: d['type'],
        definition: d['definition'],
        translation: d['translation'],
      )).toList(),
      examples: (data['examples'] as List).map((e) => WordExample(
        sentence: e['sentence'],
        translation: e['translation'],
      )).toList(),
      synonyms: List<String>.from(data['synonyms'] ?? []),
      antonyms: List<String>.from(data['antonyms'] ?? []),
      createdAt: DateTime.now(),
      updatedAt: DateTime.now(),
    );
  }
  
  /// 获取测试单词数据
  static List<Map<String, dynamic>> _getTestWordData() {
    return [
      {
        'id': 'test_word_1',
        'word': 'innovation',
        'phonetic': '/ˌɪnəˈveɪʃn/',
        'audioUrl': 'https://dict.youdao.com/dictvoice?audio=innovation&type=1',
        'difficulty': WordDifficulty.intermediate,
        'frequency': 8500,
        'definitions': [
          {
            'type': WordType.noun,
            'definition': 'A new method, idea, product, etc.',
            'translation': '创新；革新；新方法',
          }
        ],
        'examples': [
          {
            'sentence': 'The company is known for its technological innovations.',
            'translation': '这家公司以其技术创新而闻名。',
          },
          {
            'sentence': 'Innovation is the key to success in business.',
            'translation': '创新是商业成功的关键。',
          }
        ],
        'synonyms': ['novelty', 'invention', 'breakthrough'],
        'antonyms': ['tradition', 'convention'],
        'tags': ['business', 'technology', 'CET6'],
      },
      {
        'id': 'test_word_2',
        'word': 'persistent',
        'phonetic': '/pərˈsɪstənt/',
        'audioUrl': 'https://dict.youdao.com/dictvoice?audio=persistent&type=1',
        'difficulty': WordDifficulty.intermediate,
        'frequency': 7200,
        'definitions': [
          {
            'type': WordType.adjective,
            'definition': 'Continuing firmly or obstinately in a course of action despite difficulty or opposition.',
            'translation': '坚持不懈的；执着的',
          }
        ],
        'examples': [
          {
            'sentence': 'She is very persistent in pursuing her goals.',
            'translation': '她在追求目标时非常执着。',
          },
          {
            'sentence': 'His persistent efforts finally paid off.',
            'translation': '他坚持不懈的努力终于得到了回报。',
          }
        ],
        'synonyms': ['determined', 'tenacious', 'steadfast'],
        'antonyms': ['inconsistent', 'wavering'],
        'tags': ['character', 'CET4'],
      },
      {
        'id': 'test_word_3',
        'word': 'enthusiasm',
        'phonetic': '/ɪnˈθuziæzəm/',
        'audioUrl': 'https://dict.youdao.com/dictvoice?audio=enthusiasm&type=1',
        'difficulty': WordDifficulty.intermediate,
        'frequency': 6800,
        'definitions': [
          {
            'type': WordType.noun,
            'definition': 'Intense and eager enjoyment, interest, or approval.',
            'translation': '热情；热忱；热心',
          }
        ],
        'examples': [
          {
            'sentence': 'She showed great enthusiasm for the project.',
            'translation': '她对这个项目表现出极大的热情。',
          },
          {
            'sentence': 'His enthusiasm is contagious.',
            'translation': '他的热情很有感染力。',
          }
        ],
        'synonyms': ['passion', 'eagerness', 'zeal'],
        'antonyms': ['apathy', 'indifference'],
        'tags': ['emotion', 'CET4'],
      },
      {
        'id': 'test_word_4',
        'word': 'collaborate',
        'phonetic': '/kəˈlæbəreɪt/',
        'audioUrl': 'https://dict.youdao.com/dictvoice?audio=collaborate&type=1',
        'difficulty': WordDifficulty.intermediate,
        'frequency': 5900,
        'definitions': [
          {
            'type': WordType.verb,
            'definition': 'Work jointly on an activity or project.',
            'translation': '合作；协作',
          }
        ],
        'examples': [
          {
            'sentence': 'The two companies collaborated on the research project.',
            'translation': '这两家公司在研究项目上进行了合作。',
          },
          {
            'sentence': 'We need to collaborate more effectively.',
            'translation': '我们需要更有效地合作。',
          }
        ],
        'synonyms': ['cooperate', 'work together', 'team up'],
        'antonyms': ['compete', 'oppose'],
        'tags': ['work', 'teamwork', 'CET6'],
      },
      {
        'id': 'test_word_5',
        'word': 'efficient',
        'phonetic': '/ɪˈfɪʃnt/',
        'audioUrl': 'https://dict.youdao.com/dictvoice?audio=efficient&type=1',
        'difficulty': WordDifficulty.intermediate,
        'frequency': 7500,
        'definitions': [
          {
            'type': WordType.adjective,
            'definition': 'Achieving maximum productivity with minimum wasted effort or expense.',
            'translation': '高效的；效率高的',
          }
        ],
        'examples': [
          {
            'sentence': 'We need to find a more efficient way to do this.',
            'translation': '我们需要找到一个更高效的方法来做这件事。',
          },
          {
            'sentence': 'She is very efficient at her job.',
            'translation': '她工作非常高效。',
          }
        ],
        'synonyms': ['effective', 'productive', 'competent'],
        'antonyms': ['inefficient', 'wasteful'],
        'tags': ['work', 'productivity', 'CET4'],
      },
      {
        'id': 'test_word_6',
        'word': 'analyze',
        'phonetic': '/ˈænəlaɪz/',
        'audioUrl': 'https://dict.youdao.com/dictvoice?audio=analyze&type=1',
        'difficulty': WordDifficulty.intermediate,
        'frequency': 8200,
        'definitions': [
          {
            'type': WordType.verb,
            'definition': 'Examine in detail the structure of something.',
            'translation': '分析；分解',
          }
        ],
        'examples': [
          {
            'sentence': 'We need to analyze the data carefully.',
            'translation': '我们需要仔细分析这些数据。',
          },
          {
            'sentence': 'The report analyzes the current market trends.',
            'translation': '这份报告分析了当前的市场趋势。',
          }
        ],
        'synonyms': ['examine', 'study', 'investigate'],
        'antonyms': ['synthesize', 'combine'],
        'tags': ['research', 'thinking', 'CET4'],
      },
      {
        'id': 'test_word_7',
        'word': 'comprehensive',
        'phonetic': '/ˌkɑːmprɪˈhensɪv/',
        'audioUrl': 'https://dict.youdao.com/dictvoice?audio=comprehensive&type=1',
        'difficulty': WordDifficulty.advanced,
        'frequency': 6500,
        'definitions': [
          {
            'type': WordType.adjective,
            'definition': 'Including or dealing with all or nearly all elements or aspects of something.',
            'translation': '综合的；全面的；详尽的',
          }
        ],
        'examples': [
          {
            'sentence': 'The book provides a comprehensive overview of the subject.',
            'translation': '这本书提供了该主题的全面概述。',
          },
          {
            'sentence': 'We need a comprehensive solution to this problem.',
            'translation': '我们需要一个全面的解决方案来解决这个问题。',
          }
        ],
        'synonyms': ['complete', 'thorough', 'extensive'],
        'antonyms': ['partial', 'incomplete'],
        'tags': ['description', 'CET6'],
      },
      {
        'id': 'test_word_8',
        'word': 'demonstrate',
        'phonetic': '/ˈdemənstreɪt/',
        'audioUrl': 'https://dict.youdao.com/dictvoice?audio=demonstrate&type=1',
        'difficulty': WordDifficulty.intermediate,
        'frequency': 7800,
        'definitions': [
          {
            'type': WordType.verb,
            'definition': 'Clearly show the existence or truth of something by giving proof or evidence.',
            'translation': '证明；展示；演示',
          }
        ],
        'examples': [
          {
            'sentence': 'The study demonstrates the effectiveness of the new method.',
            'translation': '这项研究证明了新方法的有效性。',
          },
          {
            'sentence': 'Let me demonstrate how to use this tool.',
            'translation': '让我演示一下如何使用这个工具。',
          }
        ],
        'synonyms': ['show', 'prove', 'illustrate'],
        'antonyms': ['conceal', 'hide'],
        'tags': ['action', 'proof', 'CET4'],
      },
      {
        'id': 'test_word_9',
        'word': 'significant',
        'phonetic': '/sɪɡˈnɪfɪkənt/',
        'audioUrl': 'https://dict.youdao.com/dictvoice?audio=significant&type=1',
        'difficulty': WordDifficulty.intermediate,
        'frequency': 9200,
        'definitions': [
          {
            'type': WordType.adjective,
            'definition': 'Sufficiently great or important to be worthy of attention.',
            'translation': '重要的；显著的；有意义的',
          }
        ],
        'examples': [
          {
            'sentence': 'There has been a significant improvement in sales.',
            'translation': '销售额有了显著的提高。',
          },
          {
            'sentence': 'This is a significant achievement.',
            'translation': '这是一个重大的成就。',
          }
        ],
        'synonyms': ['important', 'notable', 'considerable'],
        'antonyms': ['insignificant', 'trivial'],
        'tags': ['importance', 'CET4'],
      },
      {
        'id': 'test_word_10',
        'word': 'implement',
        'phonetic': '/ˈɪmplɪment/',
        'audioUrl': 'https://dict.youdao.com/dictvoice?audio=implement&type=1',
        'difficulty': WordDifficulty.intermediate,
        'frequency': 6700,
        'definitions': [
          {
            'type': WordType.verb,
            'definition': 'Put a decision or plan into effect.',
            'translation': '实施；执行；实现',
          }
        ],
        'examples': [
          {
            'sentence': 'The company will implement the new policy next month.',
            'translation': '公司将在下个月实施新政策。',
          },
          {
            'sentence': 'We need to implement these changes immediately.',
            'translation': '我们需要立即实施这些变更。',
          }
        ],
        'synonyms': ['execute', 'carry out', 'apply'],
        'antonyms': ['abandon', 'neglect'],
        'tags': ['action', 'business', 'CET6'],
      },
      {
        'id': 'test_word_11',
        'word': 'strategy',
        'phonetic': '/ˈstrætədʒi/',
        'audioUrl': 'https://dict.youdao.com/dictvoice?audio=strategy&type=1',
        'difficulty': WordDifficulty.intermediate,
        'frequency': 8900,
        'definitions': [
          {
            'type': WordType.noun,
            'definition': 'A plan of action designed to achieve a long-term or overall aim.',
            'translation': '策略；战略；计划',
          }
        ],
        'examples': [
          {
            'sentence': 'We need to develop a new marketing strategy.',
            'translation': '我们需要制定一个新的营销策略。',
          },
          {
            'sentence': 'The company\'s strategy is to expand into new markets.',
            'translation': '公司的战略是扩展到新市场。',
          }
        ],
        'synonyms': ['plan', 'approach', 'tactic'],
        'antonyms': [],
        'tags': ['business', 'planning', 'CET6'],
      },
      {
        'id': 'test_word_12',
        'word': 'perspective',
        'phonetic': '/pərˈspektɪv/',
        'audioUrl': 'https://dict.youdao.com/dictvoice?audio=perspective&type=1',
        'difficulty': WordDifficulty.advanced,
        'frequency': 7100,
        'definitions': [
          {
            'type': WordType.noun,
            'definition': 'A particular attitude toward or way of regarding something; a point of view.',
            'translation': '观点；视角；看法',
          }
        ],
        'examples': [
          {
            'sentence': 'We need to look at this from a different perspective.',
            'translation': '我们需要从不同的角度来看待这个问题。',
          },
          {
            'sentence': 'The book offers a fresh perspective on the issue.',
            'translation': '这本书对这个问题提供了新的视角。',
          }
        ],
        'synonyms': ['viewpoint', 'outlook', 'angle'],
        'antonyms': [],
        'tags': ['thinking', 'opinion', 'CET6'],
      },
      {
        'id': 'test_word_13',
        'word': 'enhance',
        'phonetic': '/ɪnˈhæns/',
        'audioUrl': 'https://dict.youdao.com/dictvoice?audio=enhance&type=1',
        'difficulty': WordDifficulty.intermediate,
        'frequency': 6400,
        'definitions': [
          {
            'type': WordType.verb,
            'definition': 'Intensify, increase, or further improve the quality, value, or extent of.',
            'translation': '提高；增强；改善',
          }
        ],
        'examples': [
          {
            'sentence': 'This will enhance the quality of our products.',
            'translation': '这将提高我们产品的质量。',
          },
          {
            'sentence': 'The new features enhance user experience.',
            'translation': '新功能增强了用户体验。',
          }
        ],
        'synonyms': ['improve', 'boost', 'strengthen'],
        'antonyms': ['diminish', 'reduce'],
        'tags': ['improvement', 'CET6'],
      },
      {
        'id': 'test_word_14',
        'word': 'sustainable',
        'phonetic': '/səˈsteɪnəbl/',
        'audioUrl': 'https://dict.youdao.com/dictvoice?audio=sustainable&type=1',
        'difficulty': WordDifficulty.advanced,
        'frequency': 5800,
        'definitions': [
          {
            'type': WordType.adjective,
            'definition': 'Able to be maintained at a certain rate or level.',
            'translation': '可持续的；能维持的',
          }
        ],
        'examples': [
          {
            'sentence': 'We need to develop sustainable energy sources.',
            'translation': '我们需要开发可持续的能源。',
          },
          {
            'sentence': 'The company is committed to sustainable development.',
            'translation': '公司致力于可持续发展。',
          }
        ],
        'synonyms': ['viable', 'maintainable', 'renewable'],
        'antonyms': ['unsustainable', 'temporary'],
        'tags': ['environment', 'business', 'IELTS'],
      },
      {
        'id': 'test_word_15',
        'word': 'integrate',
        'phonetic': '/ˈɪntɪɡreɪt/',
        'audioUrl': 'https://dict.youdao.com/dictvoice?audio=integrate&type=1',
        'difficulty': WordDifficulty.intermediate,
        'frequency': 6900,
        'definitions': [
          {
            'type': WordType.verb,
            'definition': 'Combine one thing with another to form a whole.',
            'translation': '整合；使结合；使一体化',
          }
        ],
        'examples': [
          {
            'sentence': 'We need to integrate the new system with the existing one.',
            'translation': '我们需要将新系统与现有系统整合。',
          },
          {
            'sentence': 'The program integrates various learning methods.',
            'translation': '该程序整合了各种学习方法。',
          }
        ],
        'synonyms': ['combine', 'merge', 'unify'],
        'antonyms': ['separate', 'divide'],
        'tags': ['combination', 'technology', 'CET6'],
      },
      {
        'id': 'test_word_16',
        'word': 'facilitate',
        'phonetic': '/fəˈsɪlɪteɪt/',
        'audioUrl': 'https://dict.youdao.com/dictvoice?audio=facilitate&type=1',
        'difficulty': WordDifficulty.advanced,
        'frequency': 5500,
        'definitions': [
          {
            'type': WordType.verb,
            'definition': 'Make an action or process easy or easier.',
            'translation': '促进；使便利；使容易',
          }
        ],
        'examples': [
          {
            'sentence': 'Technology can facilitate communication.',
            'translation': '技术可以促进沟通。',
          },
          {
            'sentence': 'The new software facilitates data analysis.',
            'translation': '新软件使数据分析变得更容易。',
          }
        ],
        'synonyms': ['enable', 'assist', 'help'],
        'antonyms': ['hinder', 'obstruct'],
        'tags': ['action', 'help', 'CET6'],
      },
      {
        'id': 'test_word_17',
        'word': 'objective',
        'phonetic': '/əbˈdʒektɪv/',
        'audioUrl': 'https://dict.youdao.com/dictvoice?audio=objective&type=1',
        'difficulty': WordDifficulty.intermediate,
        'frequency': 7600,
        'definitions': [
          {
            'type': WordType.noun,
            'definition': 'A thing aimed at or sought; a goal.',
            'translation': '目标；目的',
          },
          {
            'type': WordType.adjective,
            'definition': 'Not influenced by personal feelings or opinions.',
            'translation': '客观的；不带偏见的',
          }
        ],
        'examples': [
          {
            'sentence': 'Our main objective is to improve customer satisfaction.',
            'translation': '我们的主要目标是提高客户满意度。',
          },
          {
            'sentence': 'Try to be objective when making decisions.',
            'translation': '做决定时要尽量客观。',
          }
        ],
        'synonyms': ['goal', 'aim', 'target', 'impartial'],
        'antonyms': ['subjective', 'biased'],
        'tags': ['goal', 'thinking', 'CET4'],
      },
      {
        'id': 'test_word_18',
        'word': 'diverse',
        'phonetic': '/daɪˈvɜːrs/',
        'audioUrl': 'https://dict.youdao.com/dictvoice?audio=diverse&type=1',
        'difficulty': WordDifficulty.intermediate,
        'frequency': 6300,
        'definitions': [
          {
            'type': WordType.adjective,
            'definition': 'Showing a great deal of variety; very different.',
            'translation': '多样的；不同的；各种各样的',
          }
        ],
        'examples': [
          {
            'sentence': 'The city has a diverse population.',
            'translation': '这个城市有多样化的人口。',
          },
          {
            'sentence': 'We offer a diverse range of products.',
            'translation': '我们提供各种各样的产品。',
          }
        ],
        'synonyms': ['varied', 'different', 'assorted'],
        'antonyms': ['uniform', 'similar'],
        'tags': ['variety', 'difference', 'CET6'],
      },
      {
        'id': 'test_word_19',
        'word': 'fundamental',
        'phonetic': '/ˌfʌndəˈmentl/',
        'audioUrl': 'https://dict.youdao.com/dictvoice?audio=fundamental&type=1',
        'difficulty': WordDifficulty.advanced,
        'frequency': 7400,
        'definitions': [
          {
            'type': WordType.adjective,
            'definition': 'Forming a necessary base or core; of central importance.',
            'translation': '基本的；根本的；重要的',
          }
        ],
        'examples': [
          {
            'sentence': 'Education is fundamental to success.',
            'translation': '教育是成功的基础。',
          },
          {
            'sentence': 'There are fundamental differences between the two approaches.',
            'translation': '这两种方法之间存在根本性的差异。',
          }
        ],
        'synonyms': ['basic', 'essential', 'primary'],
        'antonyms': ['secondary', 'superficial'],
        'tags': ['importance', 'basic', 'CET6'],
      },
      {
        'id': 'test_word_20',
        'word': 'accomplish',
        'phonetic': '/əˈkɑːmplɪʃ/',
        'audioUrl': 'https://dict.youdao.com/dictvoice?audio=accomplish&type=1',
        'difficulty': WordDifficulty.intermediate,
        'frequency': 6100,
        'definitions': [
          {
            'type': WordType.verb,
            'definition': 'Achieve or complete successfully.',
            'translation': '完成；实现；达到',
          }
        ],
        'examples': [
          {
            'sentence': 'We accomplished our goal ahead of schedule.',
            'translation': '我们提前完成了目标。',
          },
          {
            'sentence': 'She has accomplished a great deal in her career.',
            'translation': '她在职业生涯中取得了很大成就。',
          }
        ],
        'synonyms': ['achieve', 'complete', 'fulfill'],
        'antonyms': ['fail', 'abandon'],
        'tags': ['achievement', 'success', 'CET4'],
      },
    ];
  }
}
