/// 认证信息 - POST uc/approve/security/setting
class AccountAuth {
  final String id;
  final String username;
  final String mobilePhone;
  final String email;
  final String realVerified;
  final String emailVerified;
  final String loginVerified;
  final String fundsVerified;
  final String googleStatus;

  const AccountAuth({
    this.id = '',
    this.username = '',
    this.mobilePhone = '',
    this.email = '',
    this.realVerified = '0',
    this.emailVerified = '0',
    this.loginVerified = '0',
    this.fundsVerified = '0',
    this.googleStatus = '0',
  });

  bool get isGoogleVerified => googleStatus == '1';
  bool get isFundsVerified => fundsVerified == '1';
  bool get isEmailVerified => emailVerified == '1';
  bool get isLoginVerified => loginVerified == '1';

  /// 邮箱脱敏：user@gmail.com → u**@gmail.com
  String get maskedEmail {
    if (email.isEmpty) return '';
    final parts = email.split('@');
    if (parts.length != 2) return email;
    final name = parts[0];
    if (name.length <= 1) return '$name**@${parts[1]}';
    return '${name[0]}**@${parts[1]}';
  }

  factory AccountAuth.fromJson(Map<String, dynamic> json) {
    return AccountAuth(
      id: json['id']?.toString() ?? '',
      username: json['username']?.toString() ?? '',
      mobilePhone: json['mobilePhone']?.toString() ?? '',
      email: json['email']?.toString() ?? '',
      realVerified: json['realVerified']?.toString() ?? '0',
      emailVerified: json['emailVerified']?.toString() ?? '0',
      loginVerified: json['loginVerified']?.toString() ?? '0',
      fundsVerified: json['fundsVerified']?.toString() ?? '0',
      googleStatus: json['googleStatus']?.toString() ?? '0',
    );
  }
}
