package space.nstart.pcp.slots_service.model.satellite

import ballistics.types.InitialConditions
import space.nstart.pcp.pcp_types_lib.dto.ballistics.RevolutionSign
import space.nstart.pcp.pcp_types_lib.dto.requests.slots.SlotStatus
import space.nstart.pcp.pcp_types_lib.dto.requests.slots.SlotDTO
import space.nstart.pcp.slots_service.entity.BookedSlotEntity
import space.nstart.pcp.slots_service.entity.SlotEntity
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.LocalTime
import kotlin.math.sin

data class PreparedCoverageSlot(
    val sourceSlotId: Long,
    val slot: SlotDTO
)

abstract class AbstractSatellite(
    val id : Long = 0,
    var cycleRevs : Long = 243,
    var tnCalc : LocalDateTime = LocalDateTime.of(
        LocalDate.of(2025,10,27),
        LocalTime.of(0,29,23,162630000)),
    var durationCalc : Long = 16,
    var slotDuration : Long = 10,
    val maxChainLength : Int = 30,
    val maxSurveyDuration : Int = 300,
    val mmi : Long = 10,
    val angles : List<Double> = listOf(),
    val ic : InitialConditions = InitialConditions()
) {

    abstract fun prepareCoverageSlots(
        slots : List<SlotEntity>,
        bookedSlots : List<BookedSlotEntity>,
        timeStart : LocalDateTime,
        timeStop : LocalDateTime,
        sign : RevolutionSign?,
        states : List<SlotStatus>? = null
    ) : List<PreparedCoverageSlot>

    fun prepareSlots(
        slots : List<SlotEntity>,
        bookedSlots : List<BookedSlotEntity>,
        timeStart : LocalDateTime,
        timeStop : LocalDateTime,
        sign : RevolutionSign?,
        states : List<SlotStatus>? = null
    ) : List<SlotDTO> = prepareCoverageSlots(slots, bookedSlots, timeStart, timeStop, sign, states).map { it.slot }

}
