package dev.privacyllc.period.core.notifications

/**
 * What a notification button actually does.
 *
 * ## Why this exists at all
 *
 * The labels and the writes used to live apart: [NotificationCopy] returned a
 * list of strings, and `ReminderWorker` attached the first to "started" and the
 * second to "not yet" — for every kind of reminder, by position. That is fine
 * while every reminder asks the same question, and it was wrong the moment one
 * did not. The period-end check-in asks *"Is your period over?"* and offers
 * **Ended** and **Still going**; by position, "Ended" recorded a brand-new
 * period starting today, in the middle of the period it was asking about, and
 * "Still going" filed a censoring observation against a forecast that had
 * already arrived. The user did nothing wrong and had no way to see it.
 *
 * So a button is now one thing carrying both halves — see [ReminderButton] —
 * and the position of a label in a list means nothing.
 *
 * The name is the wire value: it travels in the PendingIntent that the tap
 * delivers, and it is read back on the other side. Renaming a constant here
 * changes what a notification already sitting in somebody's shade will say when
 * they tap it, which is why the reader treats an unrecognised value as "do
 * nothing" rather than guessing.
 */
enum class ReminderAction {
    /** The period began. Confirms a start. */
    STARTED,

    /** It has not begun yet. Censors the forecast — §13. */
    NOT_YET,

    /** The period is over. Closes the open record; never opens a new one. */
    ENDED,

    /** The period is still going. Answered, and deliberately writes nothing. */
    STILL_GOING,
    ;

    companion object {
        /** Null for anything unrecognised — including the pre-2026-08 action strings. */
        fun fromWireName(name: String?): ReminderAction? = entries.firstOrNull { it.name == name }
    }
}

/**
 * A button on a reminder: what it says, and what it does.
 *
 * The two are produced together by [NotificationCopy.buttons] precisely so that
 * nothing downstream has to pair them up again.
 */
data class ReminderButton(val action: ReminderAction, val label: String)
