import 'package:equatable/equatable.dart';

class SuperAdminStatsModel extends Equatable {
  // English: Overall platform stats.
  // Arabic: إحصائيات المنصة الإجمالية.
  final int totalCompanies;
  final int totalSessions;
  final int connectedSessions;

  // English: Lists of active companies, pending billing approvals, and subscription plans.
  // Arabic: قوائم بالشركات النشطة، وموافقات الفواتير المعلقة، وباقات الاشتراك المتاحة.
  final List<dynamic> companies;
  final List<dynamic> pendingApprovals;
  final List<dynamic> plans;

  const SuperAdminStatsModel({
    required this.totalCompanies,
    required this.totalSessions,
    required this.connectedSessions,
    required this.companies,
    required this.pendingApprovals,
    required this.plans,
  });

  // English: Factory constructor to parse SuperAdminStatsModel from JSON data map.
  // Arabic: منشئ المصنع لتحليل نموذج إحصائيات المشرف العام من خريطة بيانات جيسون.
  factory SuperAdminStatsModel.fromJson(Map<String, dynamic> json) {
    final stats = json['stats'] as Map<String, dynamic>? ?? {};
    return SuperAdminStatsModel(
      totalCompanies: stats['total_companies'] as int? ?? 0,
      totalSessions: stats['total_sessions'] as int? ?? 0,
      connectedSessions: stats['connected_sessions'] as int? ?? 0,
      companies: json['companies'] as List<dynamic>? ?? [],
      pendingApprovals: json['pending_approvals'] as List<dynamic>? ?? [],
      plans: json['plans'] as List<dynamic>? ?? [],
    );
  }

  // English: Convert model to JSON map.
  // Arabic: تحويل النموذج إلى خريطة جيسون.
  Map<String, dynamic> toJson() {
    return {
      'stats': {
        'total_companies': totalCompanies,
        'total_sessions': totalSessions,
        'connected_sessions': connectedSessions,
      },
      'companies': companies,
      'pending_approvals': pendingApprovals,
      'plans': plans,
    };
  }

  @override
  List<Object?> get props => [totalCompanies, totalSessions, connectedSessions, companies, pendingApprovals, plans];
}
