package solutions.tretter.githugandroid


enum class PlayMode(val label: String) {
    CLI_ONLY("CLI ONLY"),
    VISUAL("VISUAL"),
}

data class GitFile(
    val name: String,
    val content: String = "",
    val staged: Boolean = false,
    val tracked: Boolean = false,
    val deleted: Boolean = false,
)

data class CommitNode(
    val id: String,
    val message: String,
    val authorTimestampSeconds: Long? = null,
    val parentCount: Int = 0,
)

data class InteractiveAddSession(
    val target: String? = null,
    val awaitingUpdateSelection: Boolean = false,
    val selectionPrompt: String = "Update>>",
    val selectionAction: String = "update",
)

data class RepoState(
    val initialized: Boolean = false,
    val files: List<GitFile> = emptyList(),
    val commits: List<CommitNode> = emptyList(),
    val headBranch: String = "master",
    val branches: Map<String, Int> = emptyMap(),
    val currentDir: String = ".",
    val tags: List<String> = emptyList(),
    val remotes: Map<String, String> = emptyMap(),
    val config: Map<String, String> = emptyMap(),
    val stashes: List<String> = emptyList(),
    val fetchedBranches: Set<String> = emptySet(),
    val fetchHeadCount: Int = 0,
    val pushedBranches: Set<String> = emptySet(),
    val pushedTags: Set<String> = emptySet(),
    val submodules: Map<String, String> = emptyMap(),
    val maintenanceActions: Set<String> = emptySet(),
    val interactiveAddSession: InteractiveAddSession? = null,
)

data class Level(
    val id: String,
    val title: String,
    val description: String,
    val hints: List<String>,
    val commandSuggestions: List<String>,
    val validator: (RepoState, String) -> Boolean,
    val setup: () -> RepoState,
    val nativeSetup: (NativeLevelSetup.() -> Boolean)? = null,
    val testCases: List<LevelTestCase> = emptyList(),
    val negativeTestCases: List<LevelTestCase> = emptyList(),
    val setupChecks: List<LevelSetupCheck> = emptyList(),
)

data class LevelTestCase(
    val name: String,
    val commands: List<String>,
)

data class LevelSetupCheck(
    val name: String,
    val failureMessage: String,
    val predicate: (RepoState) -> Boolean,
)

fun sampleLevels(): List<Level> = allGithugLevels()
