from enum import IntEnum


class InverterTypeSMA(IntEnum):
    MODEL_12KW = 4
    MODEL_15KW = 5
    MODEL_20KW = 6
    MODEL_24KW = 8

    @property
    def get_type(self):
        return "SMA"

    @property
    def default_string(self):
        return {
            self.MODEL_12KW: 4,
            self.MODEL_15KW: 5,
            self.MODEL_20KW: 6,
            self.MODEL_24KW: 8,
        }[self]

    @property
    def label(self):
        return {
            self.MODEL_12KW: '12kW SMA Tripower - 514686',
            self.MODEL_15KW: '15kW SMA Tripower - 514687',
            self.MODEL_20KW: '20kW SMA Tripower - 512676',
            self.MODEL_24KW: '24kW SMA Tripower - 514685',
        }[self]

    @property
    def valid_string_ranges(self):
        return {
            self.MODEL_12KW: range(2, 9),
            self.MODEL_15KW: range(2, 9),
            self.MODEL_20KW: range(2, 9),
            self.MODEL_24KW: range(2, 9),
        }[self]

    @classmethod
    def default_value(cls):
        return cls.MODEL_24KW.value

    @classmethod
    def all(cls):
        return [cls.MODEL_12KW, cls.MODEL_15KW, cls.MODEL_20KW, cls.MODEL_24KW]


class InverterTypeDelta(IntEnum):
    MODEL_36KW = 9
    MODEL_42KW = 10
    MODEL_60KW = 11
    MODEL_80KW = 12

    @property
    def get_type(self):
        return "Delta"

    @property
    def label(self):
        return {
            self.MODEL_36KW: '36kW Delta - 524952',
            self.MODEL_42KW: '42kW Delta - 524969',
            self.MODEL_60KW: '60kW Delta - 524954',
            self.MODEL_80KW: '80kW Delta - 524955',
        }[self]

    @property
    def default_string(self):
        return {
            self.MODEL_36KW: None,
            self.MODEL_42KW: None,
            self.MODEL_60KW: None,
            self.MODEL_80KW: 14,
        }[self]

    @property
    def valid_string_ranges(self):
        return {
            self.MODEL_36KW: None,
            self.MODEL_42KW: None,
            self.MODEL_60KW: None,
            self.MODEL_80KW: range(14, 25),
        }[self]

    @classmethod
    def default_value(cls):
        return cls.MODEL_60KW.value

    @classmethod
    def all(cls):
        return [cls.MODEL_36KW, cls.MODEL_42KW, cls.MODEL_60KW, cls.MODEL_80KW]


class InverterType:
    SMA = InverterTypeSMA
    DELTA = InverterTypeDelta

    @classmethod
    def all(cls):
        return cls.SMA.all() + cls.DELTA.all()
