package com.example.livingai.domain.model.camera

import android.graphics.Bitmap
import android.graphics.RectF

/**
 * Represents the output of a pipeline analysis step.
 * @param message Instruction text to be displayed to the user.
 * @param animationResId Resource ID for a visual GIF/Animation explaining the instruction.
 * @param isValid True if the step passed validation, False otherwise.
 * @param result The detailed analysis result (optional).
 */
data class Instruction(
    val message: String,
    val isValid: Boolean,
    val animationResId: Int? = null,
    val result: AnalysisResult? = null
)

/**
 * Sealed interface for different types of analysis results.
 */
sealed interface AnalysisResult

data class OrientationResult(
    val currentOrientation: Int,
    val requiredOrientation: CameraOrientation
) : AnalysisResult

data class TiltResult(
    val roll: Float,
    val pitch: Float,
    val isLevel: Boolean
) : AnalysisResult

data class DetectionResult(
    val isAnimalDetected: Boolean,
    val animalBounds: RectF?,
    val referenceObjects: List<ReferenceObject>,
    val label: String? = null,
    val confidence: Float = 0f
) : AnalysisResult

data class PoseResult(
    val isCorrectPose: Boolean,
    val feedback: String
) : AnalysisResult

/**
 * Data class representing a reference object detected in the scene.
 */
data class ReferenceObject(
    val id: String,
    val label: String,
    val bounds: RectF,
    val relativeHeight: Float,
    val relativeWidth: Float,
    val distance: Float? = null
)

enum class CameraOrientation {
    PORTRAIT, LANDSCAPE
}

/**
 * Data to be saved after a successful capture.
 */
data class CaptureData(
    val image: Bitmap,
    val segmentationMask: BooleanArray, // Flattened 2D array or similar representation
    val animalMetrics: ObjectMetrics,
    val referenceObjects: List<ReferenceObject>
)

data class ObjectMetrics(
    val relativeHeight: Float,
    val relativeWidth: Float,
    val distance: Float
)
