package com.ponzischeme89.memby.data

/**
 * What happens when an episode reaches its opening titles.
 *
 * The vocabulary lives beside the settings it is stored in rather than in the player,
 * because three things read it — the store, the settings row and the player — and the
 * gateway's own catalogue (`skipIntroMode` in `internal/api/preferences.go`) holds the
 * matching list. Keep the two in step: a value this build does not recognise is normalised
 * to the default rather than honoured, so an operator pushing a mode a television has
 * never heard of costs that set a button it already understood, never an unexplained jump
 * through somebody's episode.
 *
 * [SKIP_INTRO_PROMPT] is the default deliberately. Skipping automatically is a jump in a
 * film nobody asked for, and it must be chosen rather than arrived at.
 */

/** Offer a button. Nothing moves until somebody presses it. */
const val SKIP_INTRO_PROMPT = "prompt"

/** Jump past the titles as soon as playback reaches them, once per episode. */
const val SKIP_INTRO_AUTO = "auto"

/** Leave the titles alone. */
const val SKIP_INTRO_OFF = "off"

/** The modes a viewer may choose between, in the order the settings row offers them. */
val SKIP_INTRO_MODES: List<String> = listOf(SKIP_INTRO_PROMPT, SKIP_INTRO_AUTO, SKIP_INTRO_OFF)

const val DEFAULT_SKIP_INTRO_MODE: String = SKIP_INTRO_PROMPT

fun normalizeSkipIntroMode(mode: String?): String =
    mode?.trim()?.lowercase()?.takeIf { it in SKIP_INTRO_MODES } ?: DEFAULT_SKIP_INTRO_MODE
