# -*- coding: utf-8 -*-
"""Genre page contract shared by the addon and its XML generator (scripts/skin_harness/gen_genre.py). No Kodi imports."""
SEC = 'genre'                      # the widget manager section of the genre page's rows (wcs/skin/slots.py)
PREFIX = 'milionar.genre.'         # Window(Home) properties of the open genre page
BASE = 43000                       # group of the page; slot n's row is BASE + n * 100
ROWS = 43001                       # the rows' group list
PAGE = 43009
BUTTON_GROUP = 43905
ANCHOR = 43907                     # where the buttons' menus open (wcs/skin/menu_anchor.py)
# the hero buttons, in their order: the filters, then Zpět
BUTTONS = (('media', 43901), ('year', 43902), ('country', 43903), ('sort', 43904), ('origin', 43906), ('back', 43908))
BUTTON_IDS = tuple(control for _name, control in BUTTONS)
FILTERS = ('media', 'year', 'country', 'sort', 'origin')
# the rows a slot of the genre page may show; Nejlepší z desetiletí is one row per decade
DECADES = ('2020', '2010', '2000', '1990', '1980', '1970', '1960', '1950', 'older')
LIST, FORYOU, POPULAR, TOP, GEMS = 'gn_list', 'gn_foryou', 'gn_popular', 'gn_top', 'gn_gems'
SERVICES = 'gn_services'           # Teď na službách v ČR (docs/plan/genre-browser/070)
DECADE_ROWS = tuple('gn_decade_' + d for d in DECADES)
ROW_TYPES = (LIST, FORYOU, SERVICES, POPULAR, TOP, GEMS) + DECADE_ROWS
# the Pro tebe row of genre cards
FY_ROW = 'fy_genres'


def list_id(n):
    from wcs.skin.hero_contract import list_id as section_list_id
    return section_list_id(BASE, n)


def decade_years(row):
    """(first, last) year of a gn_decade_<d> row; 'older' = everything before 1950."""
    name = row[len('gn_decade_'):]
    if name == 'older':
        return 1870, 1949
    first = int(name)
    return first, first + 9
