from scurrypy import (
    Addon,
    SeparatorPart, SeparatorTypes
)

class ContainerBuilder(Addon):
    """Common Container Helpers."""
    
    @staticmethod
    def small_separator(divider: bool = True):
        """Builds a separator with a small padding.

        Args:
            divider (bool, optional): Whether a visual divider should appear. Defaults to True.

        Returns:
            (SeparatorPart): the separator object
        """
        return SeparatorPart(divider, SeparatorTypes.SMALL_PADDING)
    
    @staticmethod
    def large_separator(divider: bool = True):
        """Builds a separator with a large padding.

        Args:
            divider (bool, optional): Whether a visual divider should appear. Defaults to True.

        Returns:
            (SeparatorPart): the separator object
        """
        return SeparatorPart(divider, SeparatorTypes.LARGE_PADDING)

    @staticmethod
    def accent_color(hex: str) -> int:
        """Converts a color hex to an integer.

        Args:
            hex (str): color hex (formatted as #{0-9, a-f})

        Raises:
            (ValueError): invalid hex

        Returns:
            (int): integer representation of color hex
        """
        try:
            return int(hex.removeprefix('#'), 16)
        except ValueError:
            raise ValueError("Format Error: Color must be formatted as #{0-9, a-f}.")
