package cn.learningpad.oraltrainer.sdk

import android.net.Uri
import androidx.media3.common.MimeTypes

data class SentenceBoundary @JvmOverloads constructor(
    val index: Int,
    val startMs: Long,
    val endMs: Long,
    val text: String? = null,
    val language: String? = null,
    val referenceSpeechDurationMs: Long? = null,
) {
    init {
        require(index >= 0) { "Sentence index must be non-negative." }
        require(startMs >= 0) { "Sentence startMs must be non-negative." }
        require(endMs > startMs) { "Sentence endMs must be greater than startMs." }
        require(referenceSpeechDurationMs == null || referenceSpeechDurationMs > 0) {
            "Sentence referenceSpeechDurationMs must be positive when present."
        }
    }
}

data class TrainingMediaItem @JvmOverloads constructor(
    val id: String,
    val title: String,
    val uri: Uri,
    val sentences: List<SentenceBoundary> = emptyList(),
    val subtitleUri: Uri? = null,
    val subtitleMimeType: String = MimeTypes.APPLICATION_SUBRIP,
    val subtitleLanguage: String? = null,
    val mimeType: String? = null,
    val customCacheKey: String? = null,
)

data class TrainingCourse(
    val id: String,
    val title: String,
    val items: List<TrainingMediaItem>,
)
