package app.closer.domain.model

data class ConnectionChallenge(
    val id: String,
    val title: String,
    val description: String,
    val emoji: String,
    val category: String,
    val durationDays: Int = 7,
    val days: List<ChallengeDayPrompt>,
    val isPremium: Boolean = false
)

data class ChallengeDayPrompt(
    val day: Int,
    val prompt: String,
    val hint: String = ""
)

data class ChallengeProgressState(
    val challengeId: String = "",
    val startedAt: Long = 0L,
    val status: String = "active",
    val myCompletedDays: List<Int> = emptyList(),
    val partnerCompletedDays: List<Int> = emptyList()
) {
    // Days where both partners have checked in.
    val jointCompletedDays: List<Int>
        get() = myCompletedDays.filter { it in partnerCompletedDays }

    // Next day the current user should complete (regardless of partner).
    val myNextDay: Int
        get() = (myCompletedDays.maxOrNull() ?: 0) + 1

    // Consecutive joint days from day 1.
    val jointStreak: Int
        get() {
            var streak = 0
            for (d in 1..7) {
                if (d in jointCompletedDays) streak++ else break
            }
            return streak
        }

    val isComplete: Boolean get() = status == "completed"
}
