
    i                    <    d Z ddlmZ ddlZ	 	 	 	 ddZ	 	 	 	 ddZy)z Timeout normalization utilities.    )annotationsNc                    | yt        | t        j                        r| S t        | t        t        z        rt        j                  t	        |             S t        dt        |              )zNormalize a timeout value to a timedelta.

    Args:
        value: Timeout value as int/float (seconds), timedelta, or None

    Returns:
        timedelta if value provided, None otherwise
    N)secondsInvalid timeout type: )
isinstancedatetime	timedeltaintfloat	TypeErrortype)values    i/Users/bowang/.openclaw/workspace/ChatDev/.venv/lib/python3.12/site-packages/fastmcp/utilities/timeout.pynormalize_timeout_to_timedeltar      s[     }%++,%u%!!%,77
,T%[M:
;;    c                    | yt        | t        j                        r| j                         }|dk(  rdS |S t        | t        t
        z        r| dk(  rdS t        |       S t        dt        |              )a  Normalize a timeout value to seconds (float).

    Args:
        value: Timeout value as int/float (seconds), timedelta, or None.
            Zero values are treated as "disabled" and return None.

    Returns:
        float seconds if value provided and non-zero, None otherwise
    Nr   r   )r   r   r	   total_secondsr
   r   r   r   )r   r   s     r   normalize_timeout_to_secondsr      su     }%++,%%'!|t00%u%zt3uU|3
,T%[M:
;;r   )r   'int | float | datetime.timedelta | Nonereturnzdatetime.timedelta | None)r   r   r   zfloat | None)__doc__
__future__r   r   r   r    r   r   <module>r      s8    & " <2<<(<2<<r   