namespace Knot.Modules.Profiles.Domain;

public sealed class Profile : AggregateRoot<Guid>
{
    public string Username { get; private set; }
    public string DisplayName { get; private set; }
    public string? Bio { get; private set; }
    public string? Avatar { get; private set; }
    public DateTime? Birthday { get; private set; }
    public bool HideStoryViews { get; private set; }
    public string Profilename => Username;
    public string Name => DisplayName;
    public string? AvatarUrl => Avatar;
    public bool IsPrivate => false;
    public DateTime CreatedAt { get; private set; } = DateTime.UtcNow;
    public int FollowersCount => 0;
    public int FollowingCount => 0;
    public int FriendsCount => 0;

#pragma warning disable CS8618
    private Profile() : base(Guid.Empty) { }
#pragma warning restore CS8618

    private Profile(Guid id, string username, string displayName, string? bio = null)
        : base(id)
    {
        Username = username;
        DisplayName = displayName;
        Bio = bio;
    }

    public static Profile Create(Guid userId, string username, string displayName, string? bio = null)
    {
        return new Profile(userId, username, displayName, bio);
    }

    public void UpdateProfile(string displayName, string? bio, DateTime? birthday)
    {
        DisplayName = displayName;
        Bio = bio;
        Birthday = birthday;
    }

    public void UpdateAvatar(string? avatarUrl)
    {
        Avatar = avatarUrl;
    }

    public void UpdateSettings(bool hideStoryViews)
    {
        HideStoryViews = hideStoryViews;
    }
}
