load static method

Implementation

static Future<QpcHafsWordByWordStore> load() async {
  const jsonService = GzipJsonAssetService();
  final decoded = await jsonService.loadJsonDynamic(_wbwGzPath);
  if (decoded is! Map) {
    throw const FormatException(
        'qpc-hafs-word-by-word.json must be a JSON Map');
  }

  final map = <int, String>{};
  for (final value in decoded.values) {
    if (value is! Map) continue;
    final v = Map<String, dynamic>.from(value);
    final surah = int.tryParse(v['surah']?.toString() ?? '');
    final ayah = int.tryParse(v['ayah']?.toString() ?? '');
    final word = int.tryParse(v['word']?.toString() ?? '');
    final text = (v['text'] ?? '').toString();
    if (surah == null || ayah == null || word == null) continue;
    if (text.isEmpty) continue;
    map[QpcHafsWordByWordStore.key(surah: surah, ayah: ayah, word: word)] =
        text;
  }

  return QpcHafsWordByWordStore(textByKey: map);
}