package com.example.elva.data.remote.model.emergency

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

// ==================== REST API MODELS ====================

@Serializable
data class CreateAlertRequest(
    val latitude: Double,
    val longitude: Double,
    @SerialName("alert_type")
    val alertType: String,
    val message: String? = null,
    val address: String? = null,
    @SerialName("contact_emergency_services")
    val contactEmergencyServices: Boolean = false,
    @SerialName("notify_emergency_contacts")
    val notifyEmergencyContacts: Boolean = true
)

@Serializable
data class AlertResponse(
    val id: Int,
    @SerialName("user_id")
    val userId: Int,
    val latitude: Double,
    val longitude: Double,
    @SerialName("alert_type")
    val alertType: String,
    val message: String? = null,
    val address: String? = null,
    val status: String,
    @SerialName("created_at")
    val createdAt: String,
    @SerialName("updated_at")
    val updatedAt: String? = null,
    @SerialName("resolved_at")
    val resolvedAt: String? = null
)

@Serializable
data class RespondToAlertRequest(
    @SerialName("response_type")
    val responseType: String,
    val message: String? = null,
    @SerialName("eta_minutes")
    val etaMinutes: Int? = null,
    @SerialName("location_sharing")
    val locationSharing: Boolean = false
)

@Serializable
data class AlertResponseItem(
    val id: Int,
    @SerialName("alert_id")
    val alertId: Int,
    @SerialName("responder_id")
    val responderId: Int,
    @SerialName("response_type")
    val responseType: String,
    val message: String? = null,
    @SerialName("eta_minutes")
    val etaMinutes: Int? = null,
    @SerialName("created_at")
    val createdAt: String
)

@Serializable
data class NearbyAlertsResponse(
    val alerts: List<AlertResponse>,
    val count: Int
)

// ==================== WEBSOCKET MODELS ====================

@Serializable
data class WebSocketMessage(
    val type: String,
    @SerialName("user_id")
    val userId: Int? = null,
    val message: String? = null,
    val timestamp: String? = null
)

@Serializable
data class EmergencyAlertWS(
    val type: String,
    @SerialName("alert_id")
    val alertId: Int,
    @SerialName("alert_type")
    val alertType: String,
    val latitude: Double,
    val longitude: Double,
    val address: String? = null,
    val message: String? = null,
    @SerialName("user_name")
    val userName: String? = null,
    @SerialName("user_phone")
    val userPhone: String? = null,
    @SerialName("created_at")
    val createdAt: String,
    @SerialName("distance_km")
    val distanceKm: Double? = null
)

@Serializable
data class AlertUpdateWS(
    val type: String,
    @SerialName("alert_id")
    val alertId: Int,
    val status: String,
    @SerialName("responded_users_count")
    val respondedUsersCount: Int,
    @SerialName("updated_at")
    val updatedAt: String
)

@Serializable
data class AlertResponseWS(
    val type: String,
    @SerialName("alert_id")
    val alertId: Int,
    @SerialName("responder_id")
    val responderId: Int,
    @SerialName("responder_name")
    val responderName: String? = null,
    @SerialName("response_type")
    val responseType: String,
    val message: String? = null,
    @SerialName("eta_minutes")
    val etaMinutes: Int? = null,
    @SerialName("created_at")
    val createdAt: String
)

// ==================== ENUMS ====================

object AlertTypes {
    const val GENERAL = "general"
    const val MEDICAL = "medical"
    const val VIOLENCE = "violence"
    const val HARASSMENT = "harassment"
    const val UNSAFE_AREA = "unsafe_area"
    const val ACCIDENT = "accident"
    const val FIRE = "fire"
    const val NATURAL_DISASTER = "natural_disaster"
}

object ResponseTypes {
    const val HELP_ON_WAY = "help_on_way"
    const val CONTACTED_AUTHORITIES = "contacted_authorities"
    const val SAFE_NOW = "safe_now"
    const val FALSE_ALARM = "false_alarm"
    const val INVESTIGATING = "investigating"
    const val RESOLVED = "resolved"
}

object AlertStatuses {
    const val ACTIVE = "active"
    const val PENDING = "pending"
    const val RESOLVED = "resolved"
    const val CANCELLED = "cancelled"
}

