class SymptomsUserDetailsResponseModel {
  final TokenDetails? tokenDetails;
  final UserDetails? userDetails;
  final String? sessionId;

  SymptomsUserDetailsResponseModel({
    this.tokenDetails,
    this.userDetails,
    this.sessionId,
  });

  factory SymptomsUserDetailsResponseModel.fromJson(Map<String, dynamic> json) {
    return SymptomsUserDetailsResponseModel(
      tokenDetails: json['tokenDetails'] != null ? TokenDetails.fromJson(json['tokenDetails']) : null,
      userDetails: json['userDetails'] != null ? UserDetails.fromJson(json['userDetails']) : null,
      sessionId: json['sessionId'],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'tokenDetails': tokenDetails?.toJson(),
      'userDetails': userDetails?.toJson(),
      'sessionId': sessionId,
    };
  }
}

class TokenDetails {
  final String? id;
  final String? authToken;
  final int? expiresIn;

  TokenDetails({
    this.id,
    this.authToken,
    this.expiresIn,
  });

  factory TokenDetails.fromJson(Map<String, dynamic> json) {
    return TokenDetails(
      id: json['id'],
      authToken: json['auth_token'],
      expiresIn: json['expires_in'],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'auth_token': authToken,
      'expires_in': expiresIn,
    };
  }
}

class UserDetails {
  final String? fileNo;
  final String? nationalId;
  final String? email;
  final String? dateOfBirth;
  final String? dateOfBirthHijri;
  final int? age;
  final UserName? name;
  final int? maritalStatus;
  final String? maritalStatusCode;
  final String? nationality;
  final String? nationalityIsoCode;
  final String? occupation;
  final int? idType;
  final int? gender;
  final String? jwtToken;
  final String? countryDialCode;
  final String? phoneNo;

  UserDetails({
    this.fileNo,
    this.nationalId,
    this.email,
    this.dateOfBirth,
    this.dateOfBirthHijri,
    this.age,
    this.name,
    this.maritalStatus,
    this.maritalStatusCode,
    this.nationality,
    this.nationalityIsoCode,
    this.occupation,
    this.idType,
    this.gender,
    this.jwtToken,
    this.countryDialCode,
    this.phoneNo,
  });

  factory UserDetails.fromJson(Map<String, dynamic> json) {
    return UserDetails(
      fileNo: json['FileNo'],
      nationalId: json['national_id'],
      email: json['email'],
      dateOfBirth: json['date_of_birth'],
      dateOfBirthHijri: json['date_of_birth_hijri'],
      age: json['age'],
      name: json['name'] != null ? UserName.fromJson(json['name']) : null,
      maritalStatus: json['marital_status'],
      maritalStatusCode: json['marital_status_code'],
      nationality: json['nationality'],
      nationalityIsoCode: json['nationality_iso_code'],
      occupation: json['occupation'],
      idType: json['id_type'],
      gender: json['gender'],
      jwtToken: json['jwt_token'],
      countryDialCode: json['country_dial_code'],
      phoneNo: json['phone_no'],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'FileNo': fileNo,
      'national_id': nationalId,
      'email': email,
      'date_of_birth': dateOfBirth,
      'date_of_birth_hijri': dateOfBirthHijri,
      'age': age,
      'name': name?.toJson(),
      'marital_status': maritalStatus,
      'marital_status_code': maritalStatusCode,
      'nationality': nationality,
      'nationality_iso_code': nationalityIsoCode,
      'occupation': occupation,
      'id_type': idType,
      'gender': gender,
      'jwt_token': jwtToken,
      'country_dial_code': countryDialCode,
      'phone_no': phoneNo,
    };
  }

  // Helper method to get full name
  String getFullName(bool isArabic) {
    if (name == null) return '';
    if (isArabic) {
      return '${name!.firstNameAr ?? ''} ${name!.middleNameAr ?? ''} ${name!.lastNameAr ?? ''}'.trim();
    }
    return '${name!.firstName ?? ''} ${name!.middleName ?? ''} ${name!.lastName ?? ''}'.trim();
  }
}

class UserName {
  final String? firstName;
  final String? middleName;
  final String? lastName;
  final String? firstNameAr;
  final String? middleNameAr;
  final String? lastNameAr;

  UserName({
    this.firstName,
    this.middleName,
    this.lastName,
    this.firstNameAr,
    this.middleNameAr,
    this.lastNameAr,
  });

  factory UserName.fromJson(Map<String, dynamic> json) {
    return UserName(
      firstName: json['first_name'],
      middleName: json['middle_name'],
      lastName: json['last_name'],
      firstNameAr: json['first_name_ar'],
      middleNameAr: json['middle_name_ar'],
      lastNameAr: json['last_name_ar'],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'first_name': firstName,
      'middle_name': middleName,
      'last_name': lastName,
      'first_name_ar': firstNameAr,
      'middle_name_ar': middleNameAr,
      'last_name_ar': lastNameAr,
    };
  }
}
