o
    "h                     @   s&  d Z ddlZddlmZ ddlmZmZmZm	Z	m
Z
mZ ddlmZ ddlmZ ddlmZmZ er@ddlmZ dd	lmZmZ e	d
Zdeee  deedf fddZed,ddZede
eeejf dejfddZdee
eeejf  deej fddZdee dee dee fddZe	deddZ e	ddddZ!ereG dd deZ"dee de#e  d ed! dee  fd"d#Z$dee de#e! d ed! d$e%d% dee! f
d&d'Z&dee%e  de#e  d ed! dee df fd(d)Z'dee%e  de#e! d ed! d$e%d% dee!df f
d*d+Z(dS )-a:  This module contains helper functions related to parsing arguments for classes and methods.

Warning:
    Contents of this module are intended to be used internally by the library and *not* by the
    user. Changes to this module are not considered breaking changes and may not be documented in
    the changelog.
    N)Sequence)TYPE_CHECKINGOptionalProtocolTypeVarUnionoverload)LinkPreviewOptions)TelegramObject)JSONDictODVInput)type_check_only)BotFileCredentialsTargreturn.c                 C   s   | rt | S dS )zParses an optional sequence into a tuple

    Args:
        arg (:obj:`Sequence`): The sequence to parse.

    Returns:
        :obj:`Tuple`: The sequence converted to a tuple or an empty tuple.
     )tupler   r   r   R/var/www/html/venv/lib/python3.10/site-packages/telegram/_utils/argumentparsing.pyparse_sequence_arg*   s   	r   c                 C      d S Nr   r   r   r   r   to_timedelta6   s   r   c                 C   r   r   r   r   r   r   r   r   :   s   c                 C   s*   | du rdS t | ttfrtj| dS | S )a  Parses an optional time period in seconds into a timedelta

    Args:
        arg (:obj:`int` | :class:`datetime.timedelta`, optional): The time period to parse.

    Returns:
        :obj:`timedelta`: The time period converted to a timedelta object or :obj:`None`.
    N)seconds)
isinstanceintfloatdtm	timedeltar   r   r   r   r   B   s
   	disable_web_page_previewlink_preview_optionsc                 C   s&   | r|rt d| durt| d}|S )zWrapper around warn_about_deprecated_arg_return_new_arg. Takes care of converting
    disable_web_page_preview to LinkPreviewOptions.
    zXParameters `disable_web_page_preview` and `link_preview_options` are mutually exclusive.N)is_disabled)
ValueErrorr	   )r!   r"   r   r   r   parse_lpo_and_dwppR   s   
r%   Tele_coT)bound	covariantTeleCrypto_coHasDecryptMethodc                   @   sx   e Zd ZdZedee deded de	d def
d	d
Z
edee de	e ded de	d deedf f
ddZdS )r*   r   clsdatabotr   credentialsr   r   c                 C   r   r   r   r+   r,   r-   r.   r   r   r   de_json_decryptedm      z"HasDecryptMethod.de_json_decrypted.c                 C   r   r   r   r/   r   r   r   de_list_decryptedu   r1   z"HasDecryptMethod.de_list_decryptedN)__name__
__module____qualname__	__slots__classmethodtyper)   r   r   listr0   r   r2   r   r   r   r   r*   i   s4    
r,   r+   r-   r   c                 C   s   | du rdS | | |S )z<Wrapper around TO.de_json that returns None if data is None.N)de_jsonr,   r+   r-   r   r   r   de_json_optional~      r<   r.   r   c                 C   s   | du rdS | | ||S )zFWrapper around TO.de_json_decrypted that returns None if data is None.N)r0   r,   r+   r-   r.   r   r   r   de_json_decrypted_optional      r?   c                 C   s   | du rdS | | |S )zEWrapper around TO.de_list that returns an empty list if data is None.Nr   )de_listr;   r   r   r   de_list_optional   r=   rB   c                 C   s   | du rdS | | ||S )zOWrapper around TO.de_list_decrypted that returns an empty list if data is None.Nr   )r2   r>   r   r   r   de_list_decrypted_optional   r@   rC   )r   Nr   N))__doc__datetimer   collections.abcr   typingr   r   r   r   r   r   telegram._linkpreviewoptionsr	   telegram._telegramobjectr
   telegram._utils.typesr   r   r   telegramr   r   r   r   r   r   r   r   r    boolr%   r&   r)   r*   r8   r<   r9   r?   rB   rC   r   r   r   r   <module>   s    "
(









