package com.social.media.domain.socialaccount.valueobject;

/**
 * Value Object representing social account metrics
 */
public record AccountMetrics(
    int followersCount,
    int followingCount,
    int postsCount,
    double averageEngagement
) {
    
    public AccountMetrics {
        if (followersCount < 0) {
            throw new IllegalArgumentException("Followers count cannot be negative");
        }
        if (followingCount < 0) {
            throw new IllegalArgumentException("Following count cannot be negative");
        }
        if (postsCount < 0) {
            throw new IllegalArgumentException("Posts count cannot be negative");
        }
        if (averageEngagement < 0) {
            throw new IllegalArgumentException("Average engagement cannot be negative");
        }
    }
    
    public static AccountMetrics empty() {
        return new AccountMetrics(0, 0, 0, 0.0);
    }
    
    public double getEngagementRate() {
        return followersCount > 0 ? (averageEngagement / followersCount) * 100 : 0.0;
    }
    
    public boolean hasGoodEngagement() {
        return getEngagementRate() >= 2.0; // 2% or higher is considered good
    }
    
    public boolean isInfluencer() {
        return followersCount >= 10000; // 10k+ followers
    }
    
    public boolean isMicroInfluencer() {
        return followersCount >= 1000 && followersCount < 100000; // 1k to 100k
    }
    
    public boolean isMacroInfluencer() {
        return followersCount >= 100000; // 100k+
    }
}
