"""EX-B2-04 starter. Complete the two TODO declarations."""

from typing import Annotated, Literal

from fastapi import Cookie, FastAPI, Header

app = FastAPI(title="Correlation and preference")


@app.get("/preferencias")
def read_preferences(
    # TODO: required public header X-Correlation-ID, length 8..64
    correlation_id: Annotated[str | None, Header()] = None,
    # TODO: optional cookie named display_mode with a closed vocabulary
    display_mode: Annotated[
        Literal["compact", "comfortable"] | None,
        Cookie(),
    ] = None,
) -> dict[str, str | None]:
    return {
        "correlation_id": correlation_id,
        "display_mode": display_mode,
    }


# Check: missing header, no cookie, valid cookie, invalid cookie.
