package com.fabledsword.minstrel.models

/**
 * One user's quarantine report under an aggregated row.
 */
data class AdminQuarantineReportRef(
    val userId: String,
    val username: String,
    val reason: String,
    val notes: String? = null,
    val createdAt: String = "",
)

/**
 * Aggregated quarantine row in the admin queue — all reports against a
 * single track collapsed into per-reason counts plus the underlying
 * per-user reports. Mirrors Flutter's `AdminQuarantineItem`.
 *
 * `topReasonSummary` returns the most-cited reason, with a "(+N more)"
 * suffix when other distinct reasons exist.
 */
data class AdminQuarantineItemRef(
    val trackId: String,
    val trackTitle: String,
    val artistName: String,
    val albumTitle: String,
    val albumId: String,
    val lidarrAlbumMbid: String? = null,
    val reportCount: Int = 0,
    val latestAt: String = "",
    val reasonCounts: Map<String, Int> = emptyMap(),
    val reports: List<AdminQuarantineReportRef> = emptyList(),
) {
    val topReasonSummary: String
        get() {
            if (reasonCounts.isEmpty()) return ""
            val sorted = reasonCounts.entries.sortedByDescending { it.value }
            val top = sorted.first().key
            return if (sorted.size > 1) "$top (+${sorted.size - 1} more)" else top
        }
}
