"""RadioBrowser API Struct Station"""

from typing import Optional, Union

from msgspec import Struct

from radiozilla.datatypes import UUID, URL


class Station(Struct):
    """RadioBrowser API Struct Station

    Attributes:
    ----------------------------------------
    ``changeuuid`` : |str, UUID|, optional
        A globally unique identifier for the change of the station information.

    ``stationuuid`` : |str, UUID|, optional
        A globally unique identifier for the station.

    ``name`` : |str|, optional
        The name of the station.

    ``url`` : |str, URL|, optional
        The stream URL provided by the user.

    ``url_resolved`` : |str, URL|, optional
        An automatically "resolved" stream URL. Things resolved are
        playlists (M3U/PLS/ASX...), HTTP redirects (Code 301/302).
        This link is especially usefull if you use this API from a
        platform that is not able to do a resolve on its own 
        (e.g. JavaScript in browser) or you just don't want to invest
        the time in decoding playlists yourself.

    ``homepage`` : |str, URL|, optional
        URL to the homepage of the stream, so you can direct
        the user to a page with more information about the stream.

    ``favicon`` : |str, URL|, optional
        URL to an icon or picture that represents the stream. (PNG, JPG)

    ``tags`` : |str|, optional
        Tags of the stream with more information about it.

    ``country`` : |str|, optional
        DEPRECATED: use countrycode instead, full name of the country.
        Currently it is autogenerated from the countrycode.

    ``countrycode`` : |str|, optional
        Official countrycodes as in ISO 3166-1 alpha-2.

    ``state`` |str|, optional
        Full name of the entity where the
        station is located inside the country.

    ``language`` |str|, optional
        Languages that are spoken in this stream.

    ``languagecodes`` |str|, optional
        Languages that are spoken in this stream by code ISO 639-2/B.

    ``votes`` |int|, optional
        Number of votes for this station. This number is by server
        and only ever increases. It will never be reset to 0.

    ``lastchangetime`` |str|, optional
        Last time when the stream information was changed in the database.

    ``lastchangetime_iso8601`` |str|, optional
        Last time when the stream information was changed in the database.

    ``codec`` |str|, optional
        The codec of this stream recorded at the last check.

    ``bitrate`` |int|, optional
        The bitrate of this stream recorded at the last check.

    ``hls`` |int|, optional
        Mark if this stream is using HLS distribution or non-HLS.

    ``lastcheckok`` |str|, optional
        The current online/offline state of this stream.
        This is a value calculated from multiple measure
        points in the internet. The test servers are located
        in different countries. It is a majority vote.

    ``lastchecktime`` |str|, optional
        The last time when any radio-browser server checked
        the online state of this stream.

    ``lastchecktime_iso8601`` |str|, optional
        The last time when any radio-browser server checke
        the online state of this stream.

    ``lastcheckoktime`` |str|, optional
        The last time when the stream was checked for the
        online status with a positive result.

    ``lastcheckoktime_iso8601`` |str|, optional
        The last time when the stream was checked for the
        online status with a positive result.

    ``lastlocalchecktime`` |str|, optional
        The last time when this server checked the online
        state and the metadata of this stream.

    ``lastlocalchecktime_iso860`` |str|, optional
        The last time when this server checked the online
        state and the metadata of this stream.

    ``clicktimestamp`` |str|, optional The time of the last click recorded for this stream

    ``clicktimestamp_iso8601`` |str|, optional
        The time of the last click recorded for this stream

    ``clickcount`` |int|, optional
        Clicks within the last 24 hours

    ``clicktrend`` |int|, optional
        The difference of the clickcounts within the last 2 days.
        Posivite values mean an increase, negative a decrease of clicks.

    ``ssl_error`` |int|, optional
        0 means no error, 1 means that there was an ssl error while connecting to the stream url.

    ``geo_lat`` |int|, optional
        Latitude on earth where the stream is located.

    ``geo_long`` |int|, optional
        Longitude on earth where the stream is located.

    ``has_extended_info`` |bool|, optional
        Is true, if the stream owner does provide extended
        information as HTTP headers which override the
        information in the database.
    """

    changeuuid: Optional[Union[str, UUID]] = None
    stationuuid: Optional[Union[str, UUID]] = None
    name: Optional[str] = None
    url: Optional[Union[str, URL]] = None
    url_resolved: Optional[Union[str, URL]] = None
    homepage: Optional[Union[str, URL]] = None
    favicon: Optional[Union[str, URL]] = None
    tags: Optional[str] = None
    country: Optional[str] = None
    countrycode: Optional[str] = None
    state: Optional[str] = None
    language: Optional[str] = None
    languagecodes: Optional[str] = None
    votes: Optional[int] = None
    lastchangetime: Optional[str] = None
    lastchangetime_iso8601: Optional[str] = None
    codec: Optional[str] = None
    bitrate: Optional[int] = None
    hls: Optional[int] = None
    lastcheckok: Optional[int] = None
    lastchecktime: Optional[str] = None
    lastchecktime_iso8601: Optional[str] = None
    lastcheckoktime: Optional[str] = None
    lastcheckoktime_iso8601: Optional[str] = None
    lastlocalchecktime: Optional[str] = None
    lastlocalchecktime_iso860: Optional[str] = None
    clicktimestamp: Optional[str] = None
    clicktimestamp_iso8601: Optional[str] = None
    clickcount: Optional[int] = None
    clicktrend: Optional[int] = None
    ssl_error: Optional[int] = None
    geo_lat: Optional[Union[int, float]] = None
    geo_long: Optional[Union[int, float]] = None
    has_extended_info: Optional[bool] = None