/// Réponse enrichie de /api/membres/mon-statut
class AuthStatusModel {
  final String statutCompte;

  /// État du workflow d'onboarding — non null si statutCompte == EN_ATTENTE_VALIDATION
  final String onboardingState;
  final String? souscriptionId;
  final String? waveSessionId;

  const AuthStatusModel({
    required this.statutCompte,
    this.onboardingState = 'NO_SUBSCRIPTION',
    this.souscriptionId,
    this.waveSessionId,
  });

  bool get isActive => statutCompte == 'ACTIF';
  bool get isPendingOnboarding => statutCompte == 'EN_ATTENTE_VALIDATION';
  bool get isBlocked =>
      statutCompte == 'SUSPENDU' || statutCompte == 'DESACTIVE';

  factory AuthStatusModel.fromJson(Map<dynamic, dynamic> json) {
    return AuthStatusModel(
      statutCompte: (json['statutCompte'] as String?) ?? 'ACTIF',
      onboardingState: (json['onboardingState'] as String?) ?? 'NO_SUBSCRIPTION',
      souscriptionId: json['souscriptionId'] as String?,
      waveSessionId: json['waveSessionId'] as String?,
    );
  }

  factory AuthStatusModel.active() =>
      const AuthStatusModel(statutCompte: 'ACTIF', onboardingState: 'VALIDATED');

  @override
  String toString() =>
      'AuthStatusModel($statutCompte, onboarding=$onboardingState, sous=$souscriptionId)';
}
