# Shared stair orientation and aperture geometry for room and roof planners.
from dataclasses import dataclass
from hearth import Box, Frame


@dataclass(frozen=True)
class StairLayout:
    """Describe a six-rise flight and landing in the enclosing room's local frame."""
    width: int
    depth: int
    axis: str = 'z'

    @property
    def frame(self):
        if self.axis not in ('x', 'z'):
            raise ValueError('Stair axis must be x or z')
        return Frame() if self.axis == 'z' else Frame((0, 0, self.depth - 1), 3)

    @property
    def span(self):
        return self.width if self.axis == 'z' else self.depth

    @property
    def length(self):
        return self.depth if self.axis == 'z' else self.width

    @property
    def flight(self):
        return self.frame.compose(Frame((self.span - 4, 1, 2)))

    @property
    def slot(self):
        return self.frame.box(Box((self.span - 4, 0, 2), (self.span - 3, 0, 7)))

    @property
    def landing(self):
        return self.frame.point((self.span - 5, 1, 7))
