"""Display abstraction for cheatly - simple view container."""

from dataclasses import dataclass, field
from typing import Any


@dataclass
class View:
    """A view to be rendered - just data, no behavior.

    Contains the content to display and optional header/footer.
    Used as a data transfer object between pipeline and display modules.
    """

    content: list[Any] = field(default_factory=list)
    header: Any | None = None
    footer: Any | None = None
    is_empty: bool = False

    def __bool__(self) -> bool:
        """Check if view has displayable content.

        A View is considered truthy when it has actual content to display or when
        it's not explicitly marked as empty. This allows the display pipeline to
        determine whether a view should be rendered or skipped.

        Returns:
            bool: True if the view has displayable content (non-empty content list)
                 or if the view is not marked with is_empty=True. False if both
                 the content list is empty and is_empty is True.
        """
        return bool(self.content) or not self.is_empty
