from __future__ import annotations

from collections.abc import Mapping
from typing import Any, TypeVar

from attrs import define as _attrs_define
from attrs import field as _attrs_field

from ..types import UNSET, Unset

T = TypeVar("T", bound="TimeRangeConfig")


@_attrs_define
class TimeRangeConfig:
    """Configuration for time saved ranges

    Attributes:
        action_min_hours (float | Unset): Minimum hours saved per action Default: 0.5.
        action_max_hours (float | Unset): Maximum hours saved per action Default: 2.0.
        workflow_min_hours (float | Unset): Minimum hours saved per workflow Default: 2.0.
        workflow_max_hours (float | Unset): Maximum hours saved per workflow Default: 5.0.
    """

    action_min_hours: float | Unset = 0.5
    action_max_hours: float | Unset = 2.0
    workflow_min_hours: float | Unset = 2.0
    workflow_max_hours: float | Unset = 5.0
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

    def to_dict(self) -> dict[str, Any]:
        action_min_hours = self.action_min_hours

        action_max_hours = self.action_max_hours

        workflow_min_hours = self.workflow_min_hours

        workflow_max_hours = self.workflow_max_hours

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if action_min_hours is not UNSET:
            field_dict["action_min_hours"] = action_min_hours
        if action_max_hours is not UNSET:
            field_dict["action_max_hours"] = action_max_hours
        if workflow_min_hours is not UNSET:
            field_dict["workflow_min_hours"] = workflow_min_hours
        if workflow_max_hours is not UNSET:
            field_dict["workflow_max_hours"] = workflow_max_hours

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        d = dict(src_dict)
        action_min_hours = d.pop("action_min_hours", UNSET)

        action_max_hours = d.pop("action_max_hours", UNSET)

        workflow_min_hours = d.pop("workflow_min_hours", UNSET)

        workflow_max_hours = d.pop("workflow_max_hours", UNSET)

        time_range_config = cls(
            action_min_hours=action_min_hours,
            action_max_hours=action_max_hours,
            workflow_min_hours=workflow_min_hours,
            workflow_max_hours=workflow_max_hours,
        )

        time_range_config.additional_properties = d
        return time_range_config

    @property
    def additional_keys(self) -> list[str]:
        return list(self.additional_properties.keys())

    def __getitem__(self, key: str) -> Any:
        return self.additional_properties[key]

    def __setitem__(self, key: str, value: Any) -> None:
        self.additional_properties[key] = value

    def __delitem__(self, key: str) -> None:
        del self.additional_properties[key]

    def __contains__(self, key: str) -> bool:
        return key in self.additional_properties
