
    /jA3                     ^   d Z ddlZddlmZ ddlmZmZ ddlm	Z	 ddl
mZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZmZmZmZ ddlmZ ddlmZmZ erddlm Z   G d de      Z! G d de!      Z" G d de!      Z# G d de!      Z$ G d de!      Z% G d de      Z& G d de      Z'y)zCThis module contains objects that represent paid media in Telegram.    N)Sequence)TYPE_CHECKINGFinal)	constants)	LivePhoto)	PhotoSize)Video)TelegramObject)User)enum)de_json_optionalde_list_optionalparse_sequence_argto_timedelta)get_timedelta_value)JSONDict
TimePeriod)Botc                   ^    e Zd ZU dZdZej                  j                  Zee	   e
d<   	 ej                  j                  Zee	   e
d<   	 ej                  j                  Zee	   e
d<   	 ej                  j                  Zee	   e
d<   	 ddd	e	d
edz  ddf fdZeddedddd f fd       Z xZS )	PaidMediaa  Describes the paid media added to a message. Currently, it can be one of:

    * :class:`telegram.PaidMediaPreview`
    * :class:`telegram.PaidMediaPhoto`
    * :class:`telegram.PaidMediaVideo`

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`type` is equal.

    .. versionadded:: 21.4

    Args:
        type (:obj:`str`): Type of the paid media.

    Attributes:
        type (:obj:`str`): Type of the paid media.
    )typePREVIEWPHOTOVIDEO
LIVE_PHOTON
api_kwargsr   r   returnc                    t         |   |       t        j                  t        j
                  ||      | _        | j                  f| _        | j                          y Nr   )	super__init__r   
get_memberr   PaidMediaTyper   	_id_attrs_freeze)selfr   r   	__class__s      Q/var/www/html/maxservice/venv/lib/python3.12/site-packages/telegram/_paidmedia.pyr"   zPaidMedia.__init__K   sE     	J/)@)@$M	))    databot
Bot | Nonec                    | j                  |      }| j                  t        | j                  t        | j
                  t        | j                  t        i}| t        u r8|j                  d      |v r%||j                  d         j                  ||      S d|v r.|j                  d      x}rt        j                  |      nd|d<   t        | 1  ||      S )aX  Converts JSON data to the appropriate :class:`PaidMedia` object, i.e. takes
        care of selecting the correct subclass.

        Args:
            data (dict[:obj:`str`, ...]): The JSON data.
            bot (:class:`telegram.Bot`, optional): The bot associated with this object.

        Returns:
            The Telegram object.

        r   r+   r,   duration)secondsN)_parse_datar   PaidMediaPreviewr   PaidMediaPhotor   PaidMediaVideor   PaidMediaLivePhotor   getpopde_jsondtm	timedeltar!   )clsr+   r,   _class_mappingsr(   s        r)   r9   zPaidMedia.de_jsonW   s     t$ KK)II~II~NN.	6
 ) 0N B!$((6"23;;3;OOAE*AU<UA<Us}}Q7\`DwDc22r*   N)__name__
__module____qualname____doc__	__slots__r   r$   r   r   str__annotations__r   r   r   r   r"   classmethodr9   __classcell__r(   s   @r)   r   r   -   s    $ I#1199GU3Z9;!//55E5:59!//55E5:59&44??Jc
?> '+	

 tO	

 

 38 3, 3+ 3 3r*   r   c                        e Zd ZdZdZ	 	 	 ddddedz  dedz  dedz  dedz  d	df
 fd
Ze	d	ee
j                  z  dz  fd       Z xZS )r3   a  The paid media isn't available before the payment.

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`width`, :attr:`height`, and :attr:`duration`
    are equal.

    .. versionadded:: 21.4

    .. versionchanged:: v22.2
       As part of the migration to representing time periods using ``datetime.timedelta``,
       equality comparison now considers integer durations and equivalent timedeltas as equal.

    Args:
        type (:obj:`str`): Type of the paid media, always :tg-const:`telegram.PaidMedia.PREVIEW`.
        width (:obj:`int`, optional): Media width as defined by the sender.
        height (:obj:`int`, optional): Media height as defined by the sender.
        duration (:obj:`int` | :class:`datetime.timedelta`, optional): Duration of the media in
            seconds as defined by the sender.

            .. versionchanged:: v22.2
                |time-period-input|

    Attributes:
        type (:obj:`str`): Type of the paid media, always :tg-const:`telegram.PaidMedia.PREVIEW`.
        width (:obj:`int`): Optional. Media width as defined by the sender.
        height (:obj:`int`): Optional. Media height as defined by the sender.
        duration (:obj:`int` | :class:`datetime.timedelta`): Optional. Duration of the media in
            seconds as defined by the sender.

            .. deprecated:: v22.2
                |time-period-int-deprecated|
    )	_durationheightwidthNr   rM   rL   r0   r   r   c                0   t         |   t        j                  |       | j	                         5  || _        || _        t        |      | _        | j                  | j
                  | j                  | j                  f| _
        d d d        y # 1 sw Y   y xY wN)r   r   )r!   r"   r   r   	_unfrozenrM   rL   r   rK   r   r%   )r'   rM   rL   r0   r   r(   s        r)   r"   zPaidMediaPreview.__init__   sz     	i//JG^^ 	R%*DJ&,DK3?3IDN"iiT[[$..QDN	R 	R 	Rs   ABBc                 0    t        | j                  d      S )Nr0   )	attribute)r   rK   )r'   s    r)   r0   zPaidMediaPreview.duration   s    "4>>ZHHr*   )NNN)r@   rA   rB   rC   rD   intr   r   r"   propertyr:   r;   r0   rH   rI   s   @r)   r3   r3   v   s    B 1I !!&*	R '+RTzR d
R t#	R tOR 
R" I#-4 I Ir*   r3   c                   j     e Zd ZdZdZddded   dedz  ddf fd	Zedd
edddd f fd       Z	 xZ
S )r4   a3  
    The paid media is a photo.

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`photo` are equal.

    .. versionadded:: 21.4

    Args:
        type (:obj:`str`): Type of the paid media, always :tg-const:`telegram.PaidMedia.PHOTO`.
        photo (Sequence[:class:`telegram.PhotoSize`]): The photo.

    Attributes:
        type (:obj:`str`): Type of the paid media, always :tg-const:`telegram.PaidMedia.PHOTO`.
        photo (tuple[:class:`telegram.PhotoSize`]): The photo.
    )photoNr   rV   r   r   r   c                    t         |   t        j                  |       | j	                         5  t        |      | _        | j                  | j                  f| _        d d d        y # 1 sw Y   y xY wrO   )	r!   r"   r   r   rP   r   rV   r   r%   )r'   rV   r   r(   s      r)   r"   zPaidMediaPhoto.__init__   sZ     	ioo*E^^ 	50B50IDJ"ii4DN	5 	5 	5s   .A((A1r+   r,   r-   c                     | j                  |      }t        |j                  d      t        |      |d<   t        |   ||      S )NrV   r/   )r2   r   r7   r   r!   r9   r<   r+   r,   r(   s      r)   r9   zPaidMediaPhoto.de_json   s?    t$('):IsKWwDc22r*   r?   )r@   rA   rB   rC   rD   r   r   r"   rG   r9   rH   rI   s   @r)   r4   r4      sh    " I '+	5$5 tO	5
 
5 38 3, 3BR 3 3r*   r4   c                   d     e Zd ZdZdZdddededz  ddf fdZedd	ed
ddd f fd       Z	 xZ
S )r5   a  
    The paid media is a video.

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`video` are equal.

    .. versionadded:: 21.4

    Args:
        type (:obj:`str`): Type of the paid media, always :tg-const:`telegram.PaidMedia.VIDEO`.
        video (:class:`telegram.Video`): The video.

    Attributes:
        type (:obj:`str`): Type of the paid media, always :tg-const:`telegram.PaidMedia.VIDEO`.
        video (:class:`telegram.Video`): The video.
    )videoNr   r[   r   r   c                    t         |   t        j                  |       | j	                         5  || _        | j                  | j
                  f| _        d d d        y # 1 sw Y   y xY wrO   )r!   r"   r   r   rP   r[   r   r%   )r'   r[   r   r(   s      r)   r"   zPaidMediaVideo.__init__   sU     	ioo*E^^ 	5 %DJ"ii4DN	5 	5 	5   %AA(r+   r,   r-   c                     | j                  |      }t        |j                  d      t        |      |d<   t        |   ||      S )Nr[   r/   )r2   r   r7   r	   r!   r9   rY   s      r)   r9   zPaidMediaVideo.de_json   s?    t$('):E3GWwDc22r*   r?   )r@   rA   rB   rC   rD   r	   r   r"   rG   r9   rH   rI   s   @r)   r5   r5      sc    " I '+	55 tO	5
 
5 38 3, 3BR 3 3r*   r5   c                   d     e Zd ZdZdZdddededz  ddf fdZedd	ed
ddd f fd       Z	 xZ
S )r6   a?  
    The paid media is a live photo.

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`live_photo` are equal.

    .. versionadded:: 22.8

    Args:
        type (:obj:`str`): Type of the paid media, always :tg-const:`telegram.PaidMedia.LIVE_PHOTO`
        live_photo (:class:`telegram.LivePhoto`): The photo.

    Attributes:
        type (:obj:`str`): Type of the paid media, always :tg-const:`telegram.PaidMedia.LIVE_PHOTO`
        live_photo (:class:`telegram.LivePhoto`): The photo.

    )
live_photoNr   r`   r   r   c                    t         |   t        j                  |       | j	                         5  || _        | j                  | j
                  f| _        d d d        y # 1 sw Y   y xY wrO   )r!   r"   r   r   rP   r`   r   r%   )r'   r`   r   r(   s      r)   r"   zPaidMediaLivePhoto.__init__  sW     	i22zJ^^ 	:)3DO"ii9DN	: 	: 	:r]   r+   r,   r-   c                     | j                  |      }t        |j                  d      t        |      |d<   t        |   ||      S )Nr`   r/   )r2   r   r7   r   r!   r9   rY   s      r)   r9   zPaidMediaLivePhoto.de_json#  A    t$-dhh|.DiQTU\wDc22r*   r?   )r@   rA   rB   rC   rD   r   r   r"   rG   r9   rH   rI   s   @r)   r6   r6     sc    $  I '+	
:
: tO	
:
 

: 38 3, 3BV 3 3r*   r6   c            	       n     e Zd ZdZdZdddedee   dedz  ddf fd	Z	e
dd
edddd f fd       Z xZS )PaidMediaInfoa  
    Describes the paid media added to a message.

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`star_count` and :attr:`paid_media` are equal.

    .. versionadded:: 21.4

    Args:
        star_count (:obj:`int`): The number of Telegram Stars that must be paid to buy access to
            the media.
        paid_media (Sequence[:class:`telegram.PaidMedia`]): Information about the paid media.

    Attributes:
        star_count (:obj:`int`): The number of Telegram Stars that must be paid to buy access to
            the media.
        paid_media (tuple[:class:`telegram.PaidMedia`]): Information about the paid media.
    )
paid_media
star_countNr   rg   rf   r   r   c                    t         |   |       || _        t        |      | _        | j                  | j                  f| _        | j                          y r    )r!   r"   rg   r   rf   r%   r&   )r'   rg   rf   r   r(   s       r)   r"   zPaidMediaInfo.__init__A  sE     	J/)1CJ1O//4??;r*   r+   r,   r-   c                     | j                  |      }t        |j                  d      t        |      |d<   t        |   ||      S )Nrf   r/   )r2   r   r7   r   r!   r9   rY   s      r)   r9   zPaidMediaInfo.de_jsonO  rc   r*   r?   )r@   rA   rB   rC   rD   rS   r   r   r   r"   rG   r9   rH   rI   s   @r)   re   re   +  sq    & -I '+ Y'
 tO 
 38 3, 3/ 3 3r*   re   c            	       h     e Zd ZdZdZdddddededz  d	df fd
Zeddeddd	d f fd       Z	 xZ
S )PaidMediaPurchaseda  This object contains information about a paid media purchase.

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`from_user` and :attr:`paid_media_payload` are equal.

    Note:
        In Python :keyword:`from` is a reserved word. Use :paramref:`from_user` instead.

    .. versionadded:: 21.6

    Args:
        from_user (:class:`telegram.User`): User who purchased the media.
        paid_media_payload (:obj:`str`): Bot-specified paid media payload.

    Attributes:
        from_user (:class:`telegram.User`): User who purchased the media.
        paid_media_payload (:obj:`str`): Bot-specified paid media payload.
    )	from_userpaid_media_payloadNr   rl   r   rm   r   r   c                    t         |   |       || _        || _        | j                  | j                  f| _        | j                          y r    )r!   r"   rl   rm   r%   r&   )r'   rl   rm   r   r(   s       r)   r"   zPaidMediaPurchased.__init__m  sC     	J/('9..$*A*ABr*   r+   r,   r-   c                     | j                  |      }t        j                  |j                  d      |      |d<   t        | 	  ||      S )Nfromr/   rl   )r2   r   r9   r8   r!   rY   s      r)   r9   zPaidMediaPurchased.de_json{  sB    t$ LLdhhv.>CH[wDc22r*   r?   )r@   rA   rB   rC   rD   rE   r   r"   rG   r9   rH   rI   s   @r)   rk   rk   W  sm    & 4I '+  
 tO 
 38 3, 3BV 3 3r*   rk   )(rC   datetimer:   collections.abcr   typingr   r   telegramr   telegram._files.livephotor   telegram._files.photosizer   telegram._files.videor	   telegram._telegramobjectr
   telegram._userr   telegram._utilsr   telegram._utils.argumentparsingr   r   r   r   telegram._utils.datetimer   telegram._utils.typesr   r   r   r   r3   r4   r5   r6   re   rk    r*   r)   <module>r      s   & J  $ '  / / ' 3     9 6F3 F3R7Iy 7It&3Y &3R&3Y &3R&3 &3R)3N )3X)3 )3r*   