"""
Open Meet Display types, version 1.0. Generated from meet-display-v1.schema.json and
probe-reply-v1.schema.json by `npm run sync:omd`; the schemas are the authority. Receivers ignore
keys they do not know, so a message may carry more than these types name. A message's kind-
specific parts (event, start_list, results, team_scores, announcement) are optional here; omd.kind says which
it carries.

Dedicated to the public domain under CC0 1.0.
"""

from __future__ import annotations

from typing import Any, Literal, Required, TypedDict

DateString = str
DisplayText = str | None


class EventRows(TypedDict, total=False):
    rows: Required[list[EventRow]]


class Generator(TypedDict, total=False):
    """The product that wrote this JSON, in the same shape as OMX's generator."""
    id: Required[str]
    name: Required[str]
    version: DisplayText


class Team(TypedDict, total=False):
    name: Required[str]
    short_name: DisplayText


class MessageEvent(TypedDict, total=False):
    id: DisplayText
    number: DisplayText
    name: Required[str]
    code: DisplayText
    round: DisplayText
    round_label: DisplayText
    section_name: DisplayText
    gender: DisplayText
    entry_type: DisplayText
    wind: DisplayText


class EventRow(TypedDict, total=False):
    entry_id: DisplayText
    start_assignment: DisplayText
    participant_name: Required[str]
    bib: DisplayText
    team: Team
    relay_legs: list[str] | None
    seed: DisplayText
    result: DisplayText
    status: DisplayText
    place: DisplayText
    wind: DisplayText
    points: DisplayText
    scoring_role: DisplayText
    multi_points: DisplayText


class TeamScoresRows(TypedDict, total=False):
    place: Required[str]
    team: Required[Team]
    points: Required[str]


class TeamScores(TypedDict, total=False):
    scope: Required[str]
    division_name: DisplayText
    gender: Required[DisplayText]
    rows: Required[list[TeamScoresRows]]


class Announcement(TypedDict, total=False):
    title: DisplayText
    message: Required[str]
    priority: DisplayText
    expires_at: str | None


class MessageOmd(TypedDict, total=False):
    """What this message is and who wrote it."""
    version: Required[str]
    kind: Required[str]
    generator: Required[Generator]
    sent_at: Required[str]


class MessageMeet(TypedDict, total=False):
    id: DisplayText
    name: Required[str]
    start_date: Required[DateString]
    end_date: Required[DateString]
    sport: Required[str]


class MessageDisplay(TypedDict, total=False):
    target: Required[str]
    mode: Required[str]
    connection_id: DisplayText


class Message(TypedDict, total=False):
    """One Open Meet Display message: a complete snapshot of what one display target should show. It checks every 1.x message. Receivers must ignore fields they do not recognise, so every object allows additional properties, and a kind this schema does not list is checked against the envelope only. Every value is a display string; a field with no value is left out, and a receiver treats a missing field and a null one alike."""
    omd: Required[MessageOmd]
    meet: Required[MessageMeet]
    display: Required[MessageDisplay]
    event: MessageEvent
    start_list: EventRows
    results: EventRows
    team_scores: TeamScores
    announcement: Announcement


class ProbeReplyGenerator(TypedDict, total=False):
    """The product that wrote this reply."""
    id: Required[str]
    name: Required[str]
    version: str | None


class ProbeReply(TypedDict, total=False):
    """What a receiver answers, with 200, to a GET on the URL it takes messages on: the versions it reads and who it is. The same reply an Open Meet Exchange Publisher may give, plus optional display targets. Every object allows additional properties; a later minor version only adds fields."""
    accepts: Required[list[str]]
    generator: Required[ProbeReplyGenerator]
    targets: list[str]
