from typing import Optional, override
from flut._flut.engine import FlutImmutableObject
from flut._flut.runtime import _flut_unpack_required_field


class EdgeInsets(FlutImmutableObject):
    def __init__(
        self,
        left: float = 0.0,
        top: float = 0.0,
        right: float = 0.0,
        bottom: float = 0.0,
    ):
        super().__init__("EdgeInsets")
        self.left = left
        self.top = top
        self.right = right
        self.bottom = bottom

    @staticmethod
    def _flut_unpack(data: dict) -> "EdgeInsets":
        return EdgeInsets(
            left=_flut_unpack_required_field(data, "left"),
            top=_flut_unpack_required_field(data, "top"),
            right=_flut_unpack_required_field(data, "right"),
            bottom=_flut_unpack_required_field(data, "bottom"),
        )

    @staticmethod
    def all(value):
        return EdgeInsets(value, value, value, value)

    @staticmethod
    def symmetric(*, vertical: float = 0, horizontal: float = 0):
        return EdgeInsets(horizontal, vertical, horizontal, vertical)

    @staticmethod
    def only(
        *,
        left: float = 0,
        top: float = 0,
        right: float = 0,
        bottom: float = 0,
    ):
        return EdgeInsets(left, top, right, bottom)

    @override
    def _flut_pack(self) -> dict:
        result = self._flut_base_props()
        result["left"] = self.left
        result["top"] = self.top
        result["right"] = self.right
        result["bottom"] = self.bottom
        return result
