using AdsManagerService.Domain.SeedWork;

namespace AdsManagerService.Domain.AggregatesModel.AdSetAggregate;

/// <summary>
/// EN: Targeting settings for an Ad Set.
/// VI: Cài đặt targeting cho Ad Set.
/// </summary>
public class Targeting : ValueObject
{
    /// <summary>
    /// EN: Minimum age for targeting.
    /// VI: Tuổi tối thiểu để nhắm mục tiêu.
    /// </summary>
    public int? MinAge { get; private set; }

    /// <summary>
    /// EN: Maximum age for targeting.
    /// VI: Tuổi tối đa để nhắm mục tiêu.
    /// </summary>
    public int? MaxAge { get; private set; }

    /// <summary>
    /// EN: Target genders (male, female, all).
    /// VI: Giới tính nhắm mục tiêu (nam, nữ, tất cả).
    /// </summary>
    public string? Genders { get; private set; }

    /// <summary>
    /// EN: Target locations (comma-separated).
    /// VI: Vị trí nhắm mục tiêu (phân cách bằng dấu phẩy).
    /// </summary>
    public string? Locations { get; private set; }

    /// <summary>
    /// EN: Target interests (comma-separated).
    /// VI: Sở thích nhắm mục tiêu (phân cách bằng dấu phẩy).
    /// </summary>
    public string? Interests { get; private set; }

    /// <summary>
    /// EN: Custom audience IDs (comma-separated).
    /// VI: ID đối tượng tùy chỉnh (phân cách bằng dấu phẩy).
    /// </summary>
    public string? CustomAudienceIds { get; private set; }

    /// <summary>
    /// EN: Lookalike audience IDs (comma-separated).
    /// VI: ID đối tượng tương tự (phân cách bằng dấu phẩy).
    /// </summary>
    public string? LookalikeAudienceIds { get; private set; }

    protected Targeting() { }

    public Targeting(
        int? minAge = null,
        int? maxAge = null,
        string? genders = null,
        string? locations = null,
        string? interests = null,
        string? customAudienceIds = null,
        string? lookalikeAudienceIds = null)
    {
        MinAge = minAge;
        MaxAge = maxAge;
        Genders = genders;
        Locations = locations;
        Interests = interests;
        CustomAudienceIds = customAudienceIds;
        LookalikeAudienceIds = lookalikeAudienceIds;
    }

    /// <summary>
    /// EN: Create broad targeting (everyone).
    /// VI: Tạo targeting rộng (tất cả mọi người).
    /// </summary>
    public static Targeting Broad() => new();

    /// <summary>
    /// EN: Create demographic targeting.
    /// VI: Tạo targeting theo nhân khẩu học.
    /// </summary>
    public static Targeting Demographic(int minAge, int maxAge, string? genders = null, string? locations = null) =>
        new(minAge, maxAge, genders, locations);

    protected override IEnumerable<object> GetEqualityComponents()
    {
        yield return MinAge ?? 0;
        yield return MaxAge ?? 0;
        yield return Genders ?? "";
        yield return Locations ?? "";
        yield return Interests ?? "";
        yield return CustomAudienceIds ?? "";
        yield return LookalikeAudienceIds ?? "";
    }
}
