
    cjh.                        d Z ddlmZ ddlZddlZddlmZmZmZ ddl	m
Z ddlmZmZ ddlmZmZ d	d
lmZmZ dZerddlmZ d	dlmZ  edd      Z eddd      Z G d dee         Z
dddej8                  ddd	 	 	 	 	 	 	 	 	 	 	 	 	 ddZy)ae  
The MIT License (MIT)

Copyright (c) 2015-2021 Rapptz
Copyright (c) 2021-present Pycord Development

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
    )annotationsN)TYPE_CHECKINGCallableTypeVar   )Button)ButtonStyleComponentType)PartialEmoji	_EmojiTag   )ItemItemCallbackType)r   button)Emoji)ViewBr   )boundVr   T)r   	covariantc            	      H    e Zd ZU dZdZded<   ej                  dddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d fdZe	dd	       Z
e
j                  dd
       Z
e	d d       Zej                  d!d       Ze	d d       Zej                  d!d       Ze	d"d       Zej                  d#d       Ze	d d       Zej                  d!d       Ze	d$d       Zej                  d%d       Ze	d&d       Zej                  d'd       Zed(d       Ze	d)d       Zd Zd"dZd" fdZd*dZ xZS )+r   a  Represents a UI button.

    .. versionadded:: 2.0

    Parameters
    ----------
    style: :class:`discord.ButtonStyle`
        The style of the button.
    custom_id: Optional[:class:`str`]
        The ID of the button that gets received during an interaction.
        If this button is for a URL, it does not have a custom ID.
    url: Optional[:class:`str`]
        The URL this button sends you to.
    disabled: :class:`bool`
        Whether the button is disabled or not.
    label: Optional[:class:`str`]
        The label of the button, if any. Maximum of 80 chars.
    emoji: Optional[Union[:class:`.PartialEmoji`, :class:`.Emoji`, :class:`str`]]
        The emoji of the button, if available.
    sku_id: Optional[Union[:class:`int`]]
        The ID of the SKU this button refers to.
    row: Optional[:class:`int`]
        The relative row this button belongs to. A Discord component can only have 5
        rows. By default, items are arranged automatically into those 5 rows. If you'd
        like to control the relative positioning of the row then passing an index is advised.
        For example, row=1 will show up before row=2. Defaults to ``None``, which is automatic
        ordering. The row number must be between 0 and 4 (i.e. zero indexed).
    )styleurldisabledlabelemojisku_idrowztuple[str, ...]__item_repr_attributes__NFr   r   r   	custom_idr   r   r   r   c          
     P   t         	|           |r"t        t        |            dkD  rt	        d      |"t        t        |            dkD  rt	        d      ||t        d      ||t        d      ||t        d      t        |t              s$|"t        d|j                  j                         |d u| _	        |'|%|#t        j                  d	      j                         }|t        j                  }|t        j                  }|_t        |t              rt!        j"                  |      }n9t        |t$              r|j'                         }nt        d
|j                         t)        j*                  t,        j.                  |||||||      | _        || _        y )NP   $label must be 80 characters or fewerd   )custom_id must be 100 characters or fewerz-cannot mix both url and custom_id with Buttonz*cannot mix both url and sku_id with Buttonz0cannot mix both sku_id and custom_id with Buttonz"expected custom_id to be str, not    z5expected emoji to be str, Emoji, or PartialEmoji not )typer!   r   r   r   r   r   r   )super__init__lenstr
ValueError	TypeError
isinstance	__class____name___provided_custom_idosurandomhexr	   linkpremiumr   from_strr   _to_partialButtonComponent_raw_constructr
   r   _underlyingr   )
selfr   r   r   r!   r   r   r   r   r0   s
            D/var/www/html/venv/lib/python3.12/site-packages/discord/ui/button.pyr*   zButton.__init__Z   s    	SU_r)CDD SY%83%>HII S_KLL#/HII V%7NOO)S)i.C4Y5H5H5Q5Q4RS  $-D#8 ;9,

2**,I?$$E''E%%$--e4E9-))+(* 
 +99%%	
     c                .    | j                   j                  S )zThe style of the button.r<   r   r=   s    r>   r   zButton.style        %%%r?   c                &    || j                   _        y NrA   r=   values     r>   r   zButton.style   s    !&r?   c                .    | j                   j                  S )zThe ID of the button that gets received during an interaction.

        If this button is for a URL, it does not have a custom ID.
        )r<   r!   rB   s    r>   r!   zButton.custom_id   s     )))r?   c                    |t        |t              st        d      |rt        |      dkD  rt	        d      || j
                  _        y )Nzcustom_id must be None or strr%   r&   )r/   r,   r.   r+   r-   r<   r!   rF   s     r>   r!   zButton.custom_id   sE    Zs%;;<<SZ#%HII%*"r?   c                .    | j                   j                  S )z!The URL this button sends you to.)r<   r   rB   s    r>   r   z
Button.url   s     ###r?   c                `    |t        |t              st        d      || j                  _        y )Nzurl must be None or str)r/   r,   r.   r<   r   rF   s     r>   r   z
Button.url   s+    Zs%;566$r?   c                .    | j                   j                  S )z&Whether the button is disabled or not.)r<   r   rB   s    r>   r   zButton.disabled   s     (((r?   c                8    t        |      | j                  _        y rE   )boolr<   r   rF   s     r>   r   zButton.disabled   s    $(K!r?   c                .    | j                   j                  S )z&The label of the button, if available.)r<   r   rB   s    r>   r   zButton.label   rC   r?   c                    |r"t        t        |            dkD  rt        d      |t        |      | j                  _        y || j                  _        y )Nr#   r$   )r+   r,   r-   r<   r   rF   s     r>   r   zButton.label   sD    SU_r)CDD/4/@Uer?   c                .    | j                   j                  S )z&The emoji of the button, if available.)r<   r   rB   s    r>   r   zButton.emoji   rC   r?   c                &   |d | j                   _        y t        |t              r%t	        j
                  |      | j                   _        y t        |t              r |j                         | j                   _        y t        d|j                   d      )Nz/expected str, Emoji, or PartialEmoji, received  instead)
r<   r   r/   r,   r   r8   r   r9   r.   r0   rF   s     r>   r   zButton.emoji   s|    =%)D"s#%1%:%:5%AD"y)%*%6%6%8D"OO$H. r?   c                .    | j                   j                  S )z(The ID of the SKU this button refers to.)r<   r   rB   s    r>   r   zButton.sku_id   s     &&&r?   c                    |d | j                   _        y t        |t              r|| j                   _        y t	        d|j
                   d      )Nzexpected int or None, received rS   )r<   r   r/   intr.   r0   rF   s     r>   r   zButton.sku_id   sG    =&*D#s#&+D#=eoo=NhWXXr?   c           
          | |j                   |j                  |j                  |j                  |j                  |j
                  |j                  d       S )Nr    )r   r   r   r!   r   r   r   )clsr   s     r>   from_componentzButton.from_component   sE    ,,,,__&&

,,==	
 		
r?   c                .    | j                   j                  S rE   )r<   r(   rB   s    r>   r(   zButton.type   s    $$$r?   c                6    | j                   j                         S rE   )r<   to_dictrB   s    r>   to_component_dictzButton.to_component_dict  s    ''))r?   c                    | j                   d uS rE   )r!   rB   s    r>   is_dispatchablezButton.is_dispatchable  s    ~~T))r?   c                t    | j                   t        j                  u r| j                  d uS t        |          S rE   )r   r	   r6   r   r)   is_persistent)r=   r0   s    r>   ra   zButton.is_persistent  s2    ::)))884''w$&&r?   c                    || _         y rE   )r<   )r=   r   s     r>   refresh_componentzButton.refresh_component  s
    !r?   )r   r	   r   
str | Noner   rN   r!   rd   r   rd   r   !str | Emoji | PartialEmoji | Noner   
int | Noner   rf   )returnr	   )rG   r	   )rg   rd   )rG   rd   )rg   rN   )rG   rN   )rg   zPartialEmoji | None)rG   re   )rg   rf   )rG   rf   )rX   ztype[B]r   r:   rg   r   )rg   r
   )r   r:   rg   None)r1   
__module____qualname____doc__r   __annotations__r	   	secondaryr*   propertyr   setterr!   r   r   r   r   r   classmethodrY   r(   r]   r_   ra   rc   __classcell__)r0   s   @r>   r   r   2   s   :1o  )22  $37!; ; 	;
 ; ; ; 1; ; ;z & & \\' ' * * + + $ $ 	ZZ% %
 ) ) __0 0 & & \\L L
 & & \\  ' ' ]]Y Y 

 

 % %**'
"r?   F)r   r!   r   r   r   r   c                (     d fd}|S )a  A decorator that attaches a button to a component.

    The function being decorated should have three parameters, ``self`` representing
    the :class:`discord.ui.View`, the :class:`discord.ui.Button` being pressed and
    the :class:`discord.Interaction` you receive.

    .. note::

        Premium and link buttons cannot be created with this decorator. Consider
        creating a :class:`Button` object manually instead. These types of
        buttons do not have a callback associated since Discord doesn't handle
        them when clicked.

    Parameters
    ----------
    label: Optional[:class:`str`]
        The label of the button, if any.
    custom_id: Optional[:class:`str`]
        The ID of the button that gets received during an interaction.
        It is recommended not to set this parameter to prevent conflicts.
    style: :class:`.ButtonStyle`
        The style of the button. Defaults to :attr:`.ButtonStyle.grey`.
    disabled: :class:`bool`
        Whether the button is disabled or not. Defaults to ``False``.
    emoji: Optional[Union[:class:`str`, :class:`.Emoji`, :class:`.PartialEmoji`]]
        The emoji of the button. This can be in string form or a :class:`.PartialEmoji`
        or a full :class:`.Emoji`.
    row: Optional[:class:`int`]
        The relative row this button belongs to. A Discord component can only have 5
        rows. By default, items are arranged automatically into those 5 rows. If you'd
        like to control the relative positioning of the row then passing an index is advised.
        For example, row=1 will show up before row=2. Defaults to ``None``, which is automatic
        ordering. The row number must be between 0 and 4 (i.e. zero indexed).
    c                |    t        j                  |       st        d      t        | _        d d| _        | S )Nz,button function must be a coroutine function)r   r!   r   r   r   r   r   )inspectiscoroutinefunctionr.   r   __discord_ui_model_type____discord_ui_model_kwargs__)funcr!   r   r   r   r   r   s    r>   	decoratorzbutton.<locals>.decorator<  sK    **40JKK)/&" ,
( r?   )rx   r   rg   r    )r   r!   r   r   r   r   ry   s   `````` r>   r   r     s    X   r?   )r   rd   r!   rd   r   rN   r   r	   r   re   r   rf   rg   z.Callable[[ItemCallbackType], ItemCallbackType])rk   
__future__r   rt   r3   typingr   r   r   
componentsr   r:   enumsr	   r
   partial_emojir   r   itemr   r   __all__r   r   viewr   r   r   rm   r   rz   r?   r>   <module>r      s   2 #  	 3 3 2 . 3 (
 Cx Cv.["T!W ["@  $../3<< < 	<
 < -< 
< 4<r?   