U
    gL                     @   s$  d Z ddlmZ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 ddlmZ ddlmZ ddlmZ erdd	l	mZ G d
d deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZdS )z9This module contains objects related to chat backgrounds.    )TYPE_CHECKINGDictFinalOptionalSequenceTupleType)	constants)Document)TelegramObject)enum)parse_sequence_arg)JSONDict)Botc                       s   e Zd ZU dZdZejjZeej e	d< ejj
Z
eej e	d< ejjZeej e	d< ddeee d fd	d
Zedee ed ed  d fddZ  ZS )BackgroundFillau  Base class for Telegram BackgroundFill Objects. It can be one of:

    * :class:`telegram.BackgroundFillSolid`
    * :class:`telegram.BackgroundFillGradient`
    * :class:`telegram.BackgroundFillFreeformGradient`

    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.2

    Args:
        type (:obj:`str`): Type of the background fill. Can be one of:
            :attr:`~telegram.BackgroundFill.SOLID`, :attr:`~telegram.BackgroundFill.GRADIENT`
            or :attr:`~telegram.BackgroundFill.FREEFORM_GRADIENT`.

    Attributes:
        type (:obj:`str`): Type of the background fill. Can be one of:
            :attr:`~telegram.BackgroundFill.SOLID`, :attr:`~telegram.BackgroundFill.GRADIENT`
            or :attr:`~telegram.BackgroundFill.FREEFORM_GRADIENT`.
    typeSOLIDGRADIENTFREEFORM_GRADIENTN
api_kwargsr   r   c                   s6   t  j|d ttj||| _| jf| _|   d S Nr   )	super__init__r   
get_memberr	   BackgroundFillTyper   	_id_attrs_freezeselfr   r   	__class__ </tmp/pip-unpacked-wheel-swnnwir2/telegram/_chatbackground.pyr   C   s    
zBackgroundFill.__init__r   databotreturnc                    sf   |  |}|sdS | jt| jt| jti}| tkrV|d|krV||	d j
||dS t j
||dS ,See :meth:`telegram.TelegramObject.de_json`.Nr   r'   r(   )_parse_datar   BackgroundFillSolidr   BackgroundFillGradientr   BackgroundFillFreeformGradientr   getpopde_jsonr   clsr'   r(   Z_class_mappingr"   r$   r%   r3   P   s    
   zBackgroundFill.de_json)N)__name__
__module____qualname____doc__	__slots__r	   r   r   r   __annotations__r   r   strr   r   r   classmethodr3   __classcell__r$   r$   r"   r%   r   !   s$   
	  r   c                       s6   e Zd ZdZdZddeee d fddZ  Z	S )r.   a$  
    The background is filled using the selected color.

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

    .. versionadded:: 21.2

    Args:
        color (:obj:`int`): The color of the background fill in the `RGB24` format.

    Attributes:
        type (:obj:`str`): Type of the background fill. Always
            :attr:`~telegram.BackgroundFill.SOLID`.
        color (:obj:`int`): The color of the background fill in the `RGB24` format.
    )colorNr   )r?   r   c             	      s:   t  j| j|d |   || _| jf| _W 5 Q R X d S Nr   )r   r   r   	_unfrozenr?   r   )r!   r?   r   r"   r$   r%   r   z   s    
zBackgroundFillSolid.__init__
r6   r7   r8   r9   r:   intr   r   r   r>   r$   r$   r"   r%   r.   f   s   r.   c                       s:   e Zd ZdZdZddeeeee d fddZ  Z	S )r/   a~  
    The background is a gradient fill.

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

    .. versionadded:: 21.2

    Args:
        top_color (:obj:`int`): Top color of the gradient in the `RGB24` format.
        bottom_color (:obj:`int`): Bottom color of the gradient in the `RGB24` format.
        rotation_angle (:obj:`int`): Clockwise rotation angle of the background
            fill in degrees;
            0-:tg-const:`telegram.constants.BackgroundFillLimit.MAX_ROTATION_ANGLE`.


    Attributes:
        type (:obj:`str`): Type of the background fill. Always
            :attr:`~telegram.BackgroundFill.GRADIENT`.
        top_color (:obj:`int`): Top color of the gradient in the `RGB24` format.
        bottom_color (:obj:`int`): Bottom color of the gradient in the `RGB24` format.
        rotation_angle (:obj:`int`): Clockwise rotation angle of the background
            fill in degrees;
            0-:tg-const:`telegram.constants.BackgroundFillLimit.MAX_ROTATION_ANGLE`.
    )bottom_colorrotation_angle	top_colorNr   )rF   rD   rE   r   c             	      sN   t  j| j|d |  * || _|| _|| _| j| j| jf| _W 5 Q R X d S r@   )r   r   r   rA   rF   rD   rE   r   )r!   rF   rD   rE   r   r"   r$   r%   r      s    
zBackgroundFillGradient.__init__rB   r$   r$   r"   r%   r/      s   r/   c                       s:   e Zd ZdZdZddee ee d fddZ	  Z
S )r0   a  
    The background is a freeform gradient that rotates after every message in the chat.

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

    .. versionadded:: 21.2

    Args:
        colors (Sequence[:obj:`int`]): A list of the 3 or 4 base colors that are used to
            generate the freeform gradient in the `RGB24` format

    Attributes:
        type (:obj:`str`): Type of the background fill. Always
            :attr:`~telegram.BackgroundFill.FREEFORM_GRADIENT`.
        colors (Sequence[:obj:`int`]): A list of the 3 or 4 base colors that are used to
            generate the freeform gradient in the `RGB24` format
    )colorsNr   )rG   r   c             	      s>   t  j| j|d |   t|| _| jf| _W 5 Q R X d S r@   )r   r   r   rA   r   rG   r   )r!   rG   r   r"   r$   r%   r      s    

z'BackgroundFillFreeformGradient.__init__)r6   r7   r8   r9   r:   r   rC   r   r   r   r>   r$   r$   r"   r%   r0      s   r0   c                       s   e Zd ZU dZdZejjZeej e	d< ejj
Z
eej e	d< ejjZeej e	d< ejjZeej e	d< ddeee d	 fd
dZedee ed ed  d fddZ  ZS )BackgroundTypea  Base class for Telegram BackgroundType Objects. It can be one of:

    * :class:`telegram.BackgroundTypeFill`
    * :class:`telegram.BackgroundTypeWallpaper`
    * :class:`telegram.BackgroundTypePattern`
    * :class:`telegram.BackgroundTypeChatTheme`.

    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.2

    Args:
        type (:obj:`str`): Type of the background. Can be one of:
            :attr:`~telegram.BackgroundType.FILL`, :attr:`~telegram.BackgroundType.WALLPAPER`
            :attr:`~telegram.BackgroundType.PATTERN` or
            :attr:`~telegram.BackgroundType.CHAT_THEME`.

    Attributes:
        type (:obj:`str`): Type of the background. Can be one of:
            :attr:`~telegram.BackgroundType.FILL`, :attr:`~telegram.BackgroundType.WALLPAPER`
            :attr:`~telegram.BackgroundType.PATTERN` or
            :attr:`~telegram.BackgroundType.CHAT_THEME`.

    r   FILL	WALLPAPERPATTERN
CHAT_THEMENr   r   c                   s6   t  j|d ttj||| _| jf| _|   d S r   )	r   r   r   r   r	   BackgroundTypeTyper   r   r   r    r"   r$   r%   r     s    
zBackgroundType.__init__r   r&   c                    s   |  |}|sdS | jt| jt| jt| jti}| t	kr\|
d|kr\||d j||dS d|krzt|
d||d< d|krt|
d||d< t j||dS )r+   Nr   r,   filldocument)r-   rI   BackgroundTypeFillrJ   BackgroundTypeWallpaperrK   BackgroundTypePatternrL   BackgroundTypeChatThemerH   r1   r2   r3   r   r
   r   r4   r"   r$   r%   r3     s&    
    zBackgroundType.de_json)N)r6   r7   r8   r9   r:   r	   rM   rI   r   r;   rJ   rK   rL   r<   r   r   r   r=   r3   r>   r$   r$   r"   r%   rH      s$   
  rH   c                       s8   e Zd ZdZdZddeeee d fddZ	  Z
S )rP   a  
    The background is automatically filled based on the selected colors.

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

    .. versionadded:: 21.2

    Args:
        fill (:class:`telegram.BackgroundFill`): The background fill.
        dark_theme_dimming (:obj:`int`): Dimming of the background in dark themes, as a
            percentage;
            0-:tg-const:`telegram.constants.BackgroundTypeLimit.MAX_DIMMING`.

    Attributes:
        type (:obj:`str`): Type of the background. Always
            :attr:`~telegram.BackgroundType.FILL`.
        fill (:class:`telegram.BackgroundFill`): The background fill.
        dark_theme_dimming (:obj:`int`): Dimming of the background in dark themes, as a
            percentage;
            0-:tg-const:`telegram.constants.BackgroundTypeLimit.MAX_DIMMING`.
    )dark_theme_dimmingrN   Nr   )rN   rT   r   c             	      sD   t  j| j|d |    || _|| _| j| jf| _W 5 Q R X d S r@   )r   r   rI   rA   rN   rT   r   )r!   rN   rT   r   r"   r$   r%   r   F  s
    
zBackgroundTypeFill.__init__)r6   r7   r8   r9   r:   r   rC   r   r   r   r>   r$   r$   r"   r%   rP   ,  s   rP   c                       sF   e Zd ZdZdZdddeeee ee ee	 d fddZ
  ZS )	rQ   a  
    The background is a wallpaper in the `JPEG` format.

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

    .. versionadded:: 21.2

    Args:
        document (:class:`telegram.Document`): Document with the wallpaper
        dark_theme_dimming (:obj:`int`): Dimming of the background in dark themes, as a
            percentage;
            0-:tg-const:`telegram.constants.BackgroundTypeLimit.MAX_DIMMING`.
        is_blurred (:obj:`bool`, optional): :obj:`True`, if the wallpaper is downscaled to fit
            in a 450x450 square and then box-blurred with radius 12
        is_moving (:obj:`bool`, optional): :obj:`True`, if the background moves slightly
            when the device is tilted

    Attributes:
        type (:obj:`str`): Type of the background. Always
            :attr:`~telegram.BackgroundType.WALLPAPER`.
        document (:class:`telegram.Document`): Document with the wallpaper
        dark_theme_dimming (:obj:`int`): Dimming of the background in dark themes, as a
            percentage;
            0-:tg-const:`telegram.constants.BackgroundTypeLimit.MAX_DIMMING`.
        is_blurred (:obj:`bool`): Optional. :obj:`True`, if the wallpaper is downscaled to fit
            in a 450x450 square and then box-blurred with radius 12
        is_moving (:obj:`bool`): Optional. :obj:`True`, if the background moves slightly
            when the device is tilted
    )rT   rO   
is_blurred	is_movingNr   )rO   rT   rU   rV   r   c             	      sP   t  j| j|d |  , || _|| _|| _|| _| j| jf| _W 5 Q R X d S r@   )	r   r   rJ   rA   rO   rT   rU   rV   r   )r!   rO   rT   rU   rV   r   r"   r$   r%   r   x  s    	
z BackgroundTypeWallpaper.__init__)NN)r6   r7   r8   r9   r:   r
   rC   r   boolr   r   r>   r$   r$   r"   r%   rQ   V  s     rQ   c                	       sH   e Zd ZdZdZdddeeeee	 ee	 ee
 d fddZ  ZS )	rR   a  
    The background is a `PNG` or `TGV` (gzipped subset of `SVG` with `MIME` type
    `"application/x-tgwallpattern"`) pattern to be combined with the background fill
    chosen by the user.

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

    .. versionadded:: 21.2

    Args:
        document (:class:`telegram.Document`): Document with the pattern.
        fill (:class:`telegram.BackgroundFill`): The background fill that is combined with
            the pattern.
        intensity (:obj:`int`): Intensity of the pattern when it is shown above the filled
            background;
            0-:tg-const:`telegram.constants.BackgroundTypeLimit.MAX_INTENSITY`.
        is_inverted (:obj:`int`, optional): :obj:`True`, if the background fill must be applied
            only to the pattern itself. All other pixels are black in this case. For dark
            themes only.
        is_moving (:obj:`bool`, optional): :obj:`True`, if the background moves slightly
            when the device is tilted.

    Attributes:
        type (:obj:`str`): Type of the background. Always
            :attr:`~telegram.BackgroundType.PATTERN`.
        document (:class:`telegram.Document`): Document with the pattern.
        fill (:class:`telegram.BackgroundFill`): The background fill that is combined with
            the pattern.
        intensity (:obj:`int`): Intensity of the pattern when it is shown above the filled
            background;
            0-:tg-const:`telegram.constants.BackgroundTypeLimit.MAX_INTENSITY`.
        is_inverted (:obj:`int`): Optional. :obj:`True`, if the background fill must be applied
            only to the pattern itself. All other pixels are black in this case. For dark
            themes only.
        is_moving (:obj:`bool`): Optional. :obj:`True`, if the background moves slightly
            when the device is tilted.
    )rO   rN   	intensityis_invertedrV   Nr   )rO   rN   rX   rY   rV   r   c             	      sZ   t  j| j|d |  6 || _|| _|| _|| _|| _| j| j| jf| _	W 5 Q R X d S r@   )
r   r   rK   rA   rO   rN   rX   rY   rV   r   )r!   rO   rN   rX   rY   rV   r   r"   r$   r%   r     s    

zBackgroundTypePattern.__init__)NN)r6   r7   r8   r9   r:   r
   r   rC   r   rW   r   r   r>   r$   r$   r"   r%   rR     s   '  rR   c                       s6   e Zd ZdZdZddeee d fddZ  Z	S )rS   a3  
    The background is taken directly from a built-in chat theme.

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

    .. versionadded:: 21.2

    Args:
        theme_name (:obj:`str`): Name of the chat theme, which is usually an emoji.

    Attributes:
        type (:obj:`str`): Type of the background. Always
            :attr:`~telegram.BackgroundType.CHAT_THEME`.
        theme_name (:obj:`str`): Name of the chat theme, which is usually an emoji.
    )
theme_nameNr   )rZ   r   c             	      s:   t  j| j|d |   || _| jf| _W 5 Q R X d S r@   )r   r   rL   rA   rZ   r   )r!   rZ   r   r"   r$   r%   r     s    
z BackgroundTypeChatTheme.__init__)
r6   r7   r8   r9   r:   r<   r   r   r   r>   r$   r$   r"   r%   rS     s   rS   c                       s^   e Zd ZdZdZddeee d fddZe	dee ed ed  d	 fd
dZ
  ZS )ChatBackgrounda  
    This object represents a chat background.

    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.2

    Args:
        type (:class:`telegram.BackgroundType`): Type of the background.

    Attributes:
        type (:class:`telegram.BackgroundType`): Type of the background.
    r   Nr   r   c                   s*   t  j|d || _| jf| _|   d S r   )r   r   r   r   r   r    r"   r$   r%   r   
  s    
zChatBackground.__init__r   r&   c                    s8   |  |}|sdS t|d||d< t j||dS r*   )r-   rH   r3   r1   r   )r5   r'   r(   r"   r$   r%   r3     s
    
zChatBackground.de_json)N)r6   r7   r8   r9   r:   rH   r   r   r   r=   r3   r>   r$   r$   r"   r%   r[     s     r[   N) r9   typingr   r   r   r   r   r   r   Ztelegramr	   Ztelegram._files.documentr
   Ztelegram._telegramobjectr   Ztelegram._utilsr   Ztelegram._utils.argumentparsingr   Ztelegram._utils.typesr   r   r   r.   r/   r0   rH   rP   rQ   rR   rS   r[   r$   r$   r$   r%   <module>   s&   $E"0$P*8H"