# -*- coding: utf-8 -*-
"""skin.milionar has no Kodi library: places that offered "Přidat do knihovny Kodi" drop that offer (080 §3)."""
from wcs.skin import family

LIBRARY_MARK = 'knihovny Kodi'


def is_milionar_skin():
    try:
        return family.active()
    except Exception:
        return False


def select_action(dialog, heading, options):
    """`dialog.select` that, with skin.milionar, hides the library option; returns the index in the original list."""
    if not is_milionar_skin():
        return dialog.select(heading, options)
    shown = [o for o in options if LIBRARY_MARK not in o]
    choice = dialog.select(heading, shown)
    return options.index(shown[choice]) if choice >= 0 else choice


def drop_library_button(keys):
    """Button keys of the AI chat without the library button (skin.milionar)."""
    return [k for k in keys if k != 'add_library'] if is_milionar_skin() else list(keys)
