"""
    schemas: Mission plan (un-compiled) generated by the Autonomy Engine
    sent to the respective platform's C2 to compile into a platform-specific
    mission plan.
"""

action_schema = {
    "type": "object",
    "properties": {
        "action": {
            "type": "string",
            "description": "Autonomy Engine's action from `move`, `payload`,"
            + " `dive`, `send_hits`, `scanline`, `scanpoint`.",
            "enum": [
                "move",
                "payload",
                "dive",
                "send_hits",
                "scanline",
                "scanpoint",
                "go_home",
                "surface_now",
                "stop_mission",
                "abort_now",
            ],
            "example": "move",
        },
        "activate_payload": {
            "type": "boolean",
            "description": "To activate/deactivate sensor for Autosub "
            + "Hover-1 --> `MBES` sensor and for EcoSUB --> `Sidescan`",
            "example": True,
        },
        "timeout": {
            "type": "number",
            "format": "float",
            "description": "Timeout set to perform action",
            "example": 1800.0,
        },
    },
    "oneOf": [
        {
            "type": "object",
            "properties": {
                "start": {
                    "$ref": "https://geojson.org/schema/Point.json",
                },
                "target": {
                    "$ref": "https://geojson.org/schema/Point.json",
                },
            },
            "required": [
                "target",
            ],
        },
        {
            "type": "object",
            "properties": {
                "start_point_latitude": {
                    "type": "number",
                    "format": "float",
                    "description": "Start point, y-coordinate",
                    "example": 50.37072283932642,
                },
                "start_point_longitude": {
                    "type": "number",
                    "format": "float",
                    "description": "Start point, x-coordinate",
                    "example": -4.187143188645706,
                },
                "target_waypoint_latitude": {
                    "type": "number",
                    "format": "float",
                    "description": "Target waypoint, y-coordinate",
                    "example": 50.37072283932642,
                },
                "target_waypoint_longitude": {
                    "type": "number",
                    "format": "float",
                    "description": "Target waypoint, x-coordinate",
                    "example": -4.187143188645706,
                },
                "altitude": {
                    "type": "number",
                    "format": "float",
                    "description": "Altitude of next action",
                    "example": 15.0,
                },
                "depth": {
                    "type": "number",
                    "format": "float",
                    "description": "Depth of next action",
                    "example": 15.0,
                },
            },
            "required": [
                "target_waypoint_latitude",
                "target_waypoint_longitude",
            ],
        },
    ],
}

goal_schema = {
    "type": "object",
    "properties": {
        "timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "Timestamp of last state change when autonomy model"
            + " sets this goal",
            "example": "2024-11-21T00:00:00Z",
        },
        "feature": {
            "$ref": "https://geojson.org/schema/Feature.json",
        },
    },
}
mission_plan_schema = {
    "type": "object",
    "properties": {
        "message_type": {
            "type": "string",
            "description": "Type of message",
            "example": "mission_plan",
            "enum": ["mission_plan"],
        },
        "platform_ID": {
            "type": "string",
            "description": "Unique identifier for this platform",
            "example": "reav-x-1",
        },
        "emergency": {
            "type": "boolean",
            "description": "To indicate if this is an emergency. "
            + "true = emergency and false = no emergency",
            "default": False,
            "example": False,
        },
        "partial": {
            "type": "boolean",
            "description": "To indicate if this mission plan represents a "
            + "partial (`true`) or the entire (`false`) mission plan. E.g."
            + "Partial would be `true` if a full mission plan is broken down into multiple plans.",
            "example": False,
        },
        "plan": {
            "type": "array",
            "items": action_schema,
        },
        "goal": goal_schema,
    },
    "oneOf": [
        {
            "properties": {
                "autonomy_engine_plan_ID": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",
                    "description": "Unique identifier for this plan"
                    + "generated by the Autonomy Engine",
                },
            },
        },
        {
            "properties": {
                "autonomy_engine_plan_ID": {
                    "type": "integer",
                    "description": "Unique identifier for this plan"
                    + "generated by the Autonomy Engine",
                    "example": 3,
                },
            },
        },
    ],
    "required": [
        "message_type",
        "autonomy_engine_plan_ID",
        "platform_ID",
        "plan",
    ],
}