using WishNinja.Data.Entities;

namespace WishNinja.Services;

/// <summary>
/// A wishlist prepared for a specific viewer. When <see cref="IsViewerOwner"/> is true, every
/// item's claim fields are blanked — the owner can never learn what has been claimed.
/// </summary>
public record WishlistDetailView(
    Wishlist Wishlist,
    bool IsViewerOwner,
    IReadOnlyList<WishlistItemView> Items);

public record WishlistItemView(
    WishlistItem Item,
    bool IsViewerOwner,
    int ClaimedQuantity,
    bool ClaimedByViewer,
    int ViewerClaimId,
    IReadOnlyList<ClaimInfo> OtherClaims)
{
    /// <summary>Remaining unclaimed quantity. Always equals full quantity for the owner (claims hidden).</summary>
    public int RemainingQuantity => Math.Max(0, Item.Quantity - ClaimedQuantity);

    public bool IsFullyClaimed => !IsViewerOwner && RemainingQuantity == 0;
}

/// <summary>A single claim as shown to non-owner viewers.</summary>
public record ClaimInfo(int ClaimId, string ClaimedByUserId, string ClaimedByDisplayName, int Quantity, string? Note);
