/// Domain Entity: Blog Category
///
/// Represents a blog/news category from the Frappe CMS.
/// This entity contains category information for filtering news articles.
///
/// This is a pure domain entity with no external dependencies.
library;

/// Blog Category Entity
///
/// Contains information needed to display and filter blog categories:
/// - Display title (Vietnamese)
/// - URL-safe name/slug
///
/// Categories from the API:
/// - Tin tức (News)
/// - Chuyên môn (Professional/Technical)
/// - Dự án (Projects)
/// - Khuyến mãi (Promotions)
class BlogCategory {
  /// Display title of the category (e.g., "Tin tức", "Chuyên môn")
  final String title;

  /// URL-safe name/slug of the category (e.g., "tin-tức", "chuyên-môn")
  /// Used for API filtering and routing
  final String name;

  /// Constructor
  const BlogCategory({
    required this.title,
    required this.name,
  });

  /// Get category icon name based on the category
  String get iconName {
    switch (name) {
      case 'tin-tức':
        return 'newspaper';
      case 'chuyên-môn':
        return 'school';
      case 'dự-án':
        return 'construction';
      case 'khuyến-mãi':
        return 'local_offer';
      default:
        return 'category';
    }
  }

  /// Get category color based on the category
  String get colorHex {
    switch (name) {
      case 'tin-tức':
        return '#005B9A'; // Primary blue
      case 'chuyên-môn':
        return '#2E7D32'; // Green
      case 'dự-án':
        return '#F57C00'; // Orange
      case 'khuyến-mãi':
        return '#C62828'; // Red
      default:
        return '#757575'; // Grey
    }
  }

  /// Copy with method for immutability
  BlogCategory copyWith({
    String? title,
    String? name,
  }) {
    return BlogCategory(
      title: title ?? this.title,
      name: name ?? this.name,
    );
  }

  /// Equality operator
  @override
  bool operator ==(Object other) {
    if (identical(this, other)) return true;

    return other is BlogCategory &&
        other.title == title &&
        other.name == name;
  }

  /// Hash code
  @override
  int get hashCode {
    return Object.hash(title, name);
  }

  /// String representation
  @override
  String toString() {
    return 'BlogCategory(title: $title, name: $name)';
  }
}
