package eu.geyskens.pdfscan.data

import android.graphics.PointF
import java.io.File
import java.util.UUID

/** How a page is rendered before it goes into the PDF. */
enum class ScanFilter { COLOR, GRAYSCALE, BLACK_WHITE }

/**
 * A single scanned page.
 *
 * [corners] are the four document corners in the coordinate space of the source
 * bitmap, normalized to 0..1, ordered top-left, top-right, bottom-right, bottom-left.
 * Storing them normalized keeps them valid regardless of any downscaling we do for
 * on-screen preview versus full-resolution export.
 */
data class Page(
    val id: String = UUID.randomUUID().toString(),
    val sourceFile: File,
    val corners: List<PointF>,
    val rotationDegrees: Int = 0,
    val filter: ScanFilter = ScanFilter.COLOR,
) {
    companion object {
        /** Corners covering the whole frame — the fallback when detection finds nothing. */
        fun fullFrameCorners(): List<PointF> = listOf(
            PointF(0f, 0f),
            PointF(1f, 0f),
            PointF(1f, 1f),
            PointF(0f, 1f),
        )
    }
}
