class AyatTangheemTypeMapped {
  int totalItemsCount;
  int statusCode;
  String message;
  List<AyatTangheemTypeMappedData> data;

  AyatTangheemTypeMapped({this.totalItemsCount, this.statusCode, this.message, this.data});

  AyatTangheemTypeMapped.fromJson(Map<String, dynamic> json) {
    totalItemsCount = json['totalItemsCount'];
    statusCode = json['statusCode'];
    message = json['message'];
    if (json['data'] != null) {
      data = [];
      json['data'].forEach((v) {
        data.add(new AyatTangheemTypeMappedData.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['totalItemsCount'] = this.totalItemsCount;
    data['statusCode'] = this.statusCode;
    data['message'] = this.message;
    if (this.data != null) {
      data['data'] = this.data.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class AyatTangheemTypeMappedData {
  String tangheemTypeId;
  String tangheemTypeName;
  String tangheemTypeDescription;
  String ayaTangheemTypeId;
  int surahNo;
  String surahNameEn;
  String surahNameAr;
  int ayahNo;
  String ayahText;
  int ayatNumberInSurah;
  String highlightText;
  String userId;
  String ayahTextBase;
  String ayahNos;
  String ayatNumberInSurahs;
  int startIndex;
  int endIndex;
  String created;
  String highlightAyaNos;
  List<AyahTextList > ayahTextList;
  List<TangheemProperty> property;
  List<VoiceNote> voiceNote;

  AyatTangheemTypeMappedData(
      {this.tangheemTypeId,
      this.tangheemTypeName,
      this.tangheemTypeDescription,
      this.ayaTangheemTypeId,
      this.surahNo,
      this.surahNameEn,
      this.surahNameAr,
      this.ayahNo,
      this.ayahText,
      this.ayatNumberInSurah,
      this.highlightText,
      this.userId,
      this.ayahTextBase,
      this.ayahNos,
      this.ayatNumberInSurahs,
      this.startIndex,
      this.endIndex,
      this.created,
      this.highlightAyaNos,
      this.ayahTextList,
      this.property,
      this.voiceNote});

  AyatTangheemTypeMappedData.fromJson(Map<String, dynamic> json) {
    tangheemTypeId = json['tangheemTypeId'];
    tangheemTypeName = json['tangheemTypeName'];
    tangheemTypeDescription = json['tangheemTypeDescription'];
    ayaTangheemTypeId = json['ayaTangheemTypeId'];
    surahNo = json['surahNo'];
    surahNameEn = json['surahNameEn'];
    surahNameAr = json['surahNameAr'];
    ayahNo = json['ayahNo'];
    ayahText = json['ayahText'];
    ayatNumberInSurah = json['ayatNumberInSurah'];
    highlightText = json['highlightText'];
    userId = json['userId'];
    ayahTextBase = json['ayahTextBase'];
    ayahNos = json['ayahNos'];
    ayatNumberInSurahs = json['ayatNumberInSurahs'];
    startIndex = json['startIndex'];
    endIndex = json['endIndex'];
    created = json['created'];
    highlightAyaNos = json['highlightAyaNos'];
    if (json['ayahTextList'] != null) {
      ayahTextList = <AyahTextList>[];
      json['ayahTextList'].forEach((v) {
        ayahTextList.add(new AyahTextList.fromJson(v));
      });
    }
    if (json['property'] != null) {
      property = [];
      json['property'].forEach((v) {
        property.add(new TangheemProperty.fromJson(v));
      });
    }
    if (json['voiceNote'] != null) {
      voiceNote = [];
      json['voiceNote'].forEach((v) {
        voiceNote.add(new VoiceNote.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['tangheemTypeId'] = this.tangheemTypeId;
    data['tangheemTypeName'] = this.tangheemTypeName;
    data['tangheemTypeDescription'] = this.tangheemTypeDescription;
    data['ayaTangheemTypeId'] = this.ayaTangheemTypeId;
    data['surahNo'] = this.surahNo;
    data['surahNameEn'] = this.surahNameEn;
    data['surahNameAr'] = this.surahNameAr;
    data['ayahNo'] = this.ayahNo;
    data['ayahText'] = this.ayahText;
    data['ayatNumberInSurah'] = this.ayatNumberInSurah;
    data['highlightText'] = this.highlightText;
    data['userId'] = this.userId;
    data['ayahTextBase'] = this.ayahTextBase;
    data['ayahNos'] = this.ayahNos;
    data['ayatNumberInSurahs'] = this.ayatNumberInSurahs;
    data['startIndex'] = this.startIndex;
    data['endIndex'] = this.endIndex;
    data['created'] = this.created;
    data['highlightAyaNos'] = this.highlightAyaNos;
    data['ayahTextList'] = this.ayahTextList;
    if (this.ayahTextList != null) {
      data['ayahTextList'] = this.ayahTextList.map((v) => v.toJson()).toList();
    }
    if (this.property != null) {
      data['property'] = this.property.map((v) => v.toJson()).toList();
    }
    if (this.voiceNote != null) {
      data['voiceNote'] = this.voiceNote.map((v) => v.toJson()).toList();
    }
    return data;
  }

  String reverseAyatNumber() {
    // print("total:${ayahText.length}");
    List<String> ayaNoList = ayatNumberInSurahs.split(",").reversed.toList();
    String text = "";
    for (int i = 0; i < ayahTextList.length; i++) {
      text = text + _reverseAyatNumber(ayahTextList[i].ayahText, ayaNoList[i]);
    }
    return text;
  }

  String _reverseAyatNumber(String ayaText, String ayaLength) {
    String _ayaTemp = ayaText.substring(0, ayaText.length - ayaLength.toString().length);
    String _ayaNum = ayaText.substring(ayaText.length - ayaLength.toString().length, ayaText.length);
    //_ayaNum = _ayaNum.split('').reversed.join(''); // commenting this line for temperating purpose
    return "$_ayaTemp $_ayaNum";
  }
}

class TangheemProperty {
  String tangheemTypePropertyId;
  String propertyText;
  bool isInsideTable;
  String textColor;
  int orderNo;
  String ayaTangheemTypePropertyId;
  String propertyValue;

  TangheemProperty({this.tangheemTypePropertyId, this.propertyText, this.isInsideTable, this.textColor, this.orderNo, this.ayaTangheemTypePropertyId, this.propertyValue});

  TangheemProperty.fromJson(Map<String, dynamic> json) {
    tangheemTypePropertyId = json['tangheemTypePropertyId'];
    propertyText = json['propertyText'];
    isInsideTable = json['isInsideTable'];
    textColor = json['textColor'];
    orderNo = json['orderNo'];
    ayaTangheemTypePropertyId = json['ayaTangheemTypePropertyId'];
    propertyValue = json['propertyValue'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['tangheemTypePropertyId'] = this.tangheemTypePropertyId;
    data['propertyText'] = this.propertyText;
    data['isInsideTable'] = this.isInsideTable;
    data['textColor'] = this.textColor;
    data['orderNo'] = this.orderNo;
    data['ayaTangheemTypePropertyId'] = this.ayaTangheemTypePropertyId;
    data['propertyValue'] = this.propertyValue;
    return data;
  }
}

class VoiceNote {
  String voiceNoteId;
  String voiceNotePath;
  String exposeFilePath;
  String filePath;
  String voiceNoteAuthorId;
  String userName;
  String fileName;
  String fileType;
  String ayaTangheemTypeId;
  String profilePicture;

  VoiceNote(
      {this.voiceNoteId, this.voiceNotePath, this.exposeFilePath, this.filePath, this.voiceNoteAuthorId, this.userName, this.fileName, this.fileType, this.ayaTangheemTypeId, this.profilePicture});

  VoiceNote.fromJson(Map<String, dynamic> json) {
    voiceNoteId = json['voiceNoteId'];
    voiceNotePath = json['voiceNotePath'];
    exposeFilePath = json['exposeFilePath'];
    filePath = json['filePath'];
    voiceNoteAuthorId = json['voiceNoteAuthorId'];
    userName = json['userName'];
    fileName = json['fileName'];
    fileType = json['fileType'];
    ayaTangheemTypeId = json['ayaTangheemTypeId'];
    profilePicture = json['profilePicture'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['voiceNoteId'] = this.voiceNoteId;
    data['voiceNotePath'] = this.voiceNotePath;
    data['exposeFilePath'] = this.exposeFilePath;
    data['filePath'] = this.filePath;
    data['voiceNoteAuthorId'] = this.voiceNoteAuthorId;
    data['userName'] = this.userName;
    data['fileName'] = this.fileName;
    data['fileType'] = this.fileType;
    data['ayaTangheemTypeId'] = this.ayaTangheemTypeId;
    data['profilePicture'] = this.profilePicture;
    return data;
  }
}

class AyahTextList {
  int ayahNo;
  String ayahText;

  AyahTextList({this.ayahNo, this.ayahText});

  AyahTextList.fromJson(Map<String, dynamic> json) {
    ayahNo = json['ayahNo'];
    ayahText = json['ayahText'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['ayahNo'] = this.ayahNo;
    data['ayahText'] = this.ayahText;
    return data;
  }
}