
    cjh@                    `   d Z ddlmZ ddlmZmZmZmZ ddlm	Z	m
Z
mZmZmZ ddlmZmZ ddlmZmZ er*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Z# edd      Z$ G d d      Z G d de      Z G d de      Z G d de      Z% G d de      Z G d d      Z!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.
    )annotations)TYPE_CHECKINGAnyClassVarTypeVar   )ButtonStyleChannelTypeComponentTypeInputTextStyletry_enum)PartialEmoji	_EmojiTag)MISSING	get_slots)Emoji)	ActionRow)ButtonComponent)	Component)	InputText)
SelectMenu)SelectOption)r   r   Buttonr   r   r   Cr   )boundc                  V    e Zd ZU dZdZded<   ded<   ded<   dd	Zedd
       ZddZ	y)r   ai  Represents a Discord Bot UI Kit Component.

    Currently, the only components supported by Discord are:

    - :class:`ActionRow`
    - :class:`Button`
    - :class:`SelectMenu`

    This class is abstract and cannot be instantiated.

    .. versionadded:: 2.0

    Attributes
    ----------
    type: :class:`ComponentType`
        The type of component.
    typetuple[str, ...]	__slots__ClassVar[tuple[str, ...]]__repr_info__r   r   c                     dj                   fd j                  D              }d j                  j                   d| dS )N c              3  @   K   | ]  }| d t        |        yw)=N)getattr).0keyselfs     E/var/www/html/venv/lib/python3.12/site-packages/discord/components.py	<genexpr>z%Component.__repr__.<locals>.<genexpr>P   s$     WSC5'$"4!78Ws   <>)joinr"   	__class____name__)r*   attrss   ` r+   __repr__zComponent.__repr__O   s=    WDDVDVWW4>>**+1UG155    c                    | j                  |       }t        |       D ]  }	 ||   }t        |||        |S # t        $ r Y %w xY wN)__new__r   setattrKeyError)clskwargsr*   slotvalues        r+   _raw_constructzComponent._raw_constructS   sZ    ++c"cN 	+D+t dE*	+ 	  s   7	AAc                    t         r6   )NotImplementedErrorr*   s    r+   to_dictzComponent.to_dict_   s    !!r4   Nreturnstr)r:   ztype[C]rD   r   )rD   zdict[str, Any])
r1   
__module____qualname____doc__r    __annotations__r3   classmethodr>   rB    r4   r+   r   r   7   s=    $ "+I*,,
6 	 	"r4   c                  >    e Zd ZU dZdZded<   eZded<   d
dZddZy	)r   a  Represents a Discord Bot UI Kit Action Row.

    This is a component that holds up to 5 children components in a row.

    This inherits from :class:`Component`.

    .. versionadded:: 2.0

    Attributes
    ----------
    type: :class:`ComponentType`
        The type of component.
    children: List[:class:`Component`]
        The children components that this holds, if any.
    )childrenr   r    r!   r"   c                    t        t        |d         | _        |j                  dg       D cg c]  }t	        |       c}| _        y c c}w )Nr   
components)r   r   r   get_component_factoryrM   )r*   datads      r+   __init__zActionRow.__init__x   sA    #+M4<#H	+/88L"+E*
&'q!*
 *
s   Ac                    t        | j                        | j                  D cg c]  }|j                          c}dS c c}w )N)r   rO   )intr   rM   rB   )r*   childs     r+   rB   zActionRow.to_dict~   s2    		N8<Fu5==?F
 	
Fs   ?N)rR   ComponentPayload)rD   ActionRowPayload	r1   rF   rG   rH   r    rI   r"   rT   rB   rK   r4   r+   r   r   c   s(      "/I./8M,8

r4   r   c                  >    e Zd ZU dZdZded<   eZded<   d
dZddZy	)r   a  Represents an Input Text field from the Discord Bot UI Kit.
    This inherits from :class:`Component`.

    Attributes
    ----------
    style: :class:`.InputTextStyle`
        The style of the input text field.
    custom_id: Optional[:class:`str`]
        The ID of the input text field that gets received during an interaction.
    label: :class:`str`
        The label for the input text field.
    placeholder: Optional[:class:`str`]
        The placeholder text that is shown if nothing is selected, if any.
    min_length: Optional[:class:`int`]
        The minimum number of characters that must be entered
        Defaults to 0
    max_length: Optional[:class:`int`]
        The maximum number of characters that can be entered
    required: Optional[:class:`bool`]
        Whether the input text field is required or not. Defaults to `True`.
    value: Optional[:class:`str`]
        The value that has been entered in the input text field.
    )	r   style	custom_idlabelplaceholder
min_length
max_lengthrequiredr=   r   r    r!   r"   c                   t         j                  | _        t        t        |d         | _        |d   | _        |j                  dd       | _        |j                  dd       | _	        |j                  dd       | _
        |j                  dd       | _        |j                  dd      | _        |j                  d	d       | _        y )
Nr\   r]   r^   r_   r`   ra   rb   Tr=   )r   
input_textr   r   r   r\   r]   rP   r^   r_   r`   ra   rb   r=   r*   rR   s     r+   rT   zInputText.__init__   s    !,,	%-nd7m%L
k*((7D1
'+xxt'D&*hh|T&B&*hh|T&B"hhz48!%'4!8
r4   c                   d| j                   j                  | j                  d}| j                  r| j                  |d<   | j                  r| j                  |d<   | j
                  r| j
                  |d<   | j                  r| j                  |d<   | j                  s| j                  |d<   | j                  r| j                  |d<   |S )	N   )r   r\   r^   r]   r_   r`   ra   rb   r=   )r\   r=   r^   r]   r_   r`   ra   rb   r*   payloads     r+   rB   zInputText.to_dict   s    ZZ%%ZZ

 >>#'>>GK %)%5%5GM"??$(OOGL!??$(OOGL!}}"&--GJ::#zzGGr4   N)rR   InputTextComponentPayload)rD   rj   rZ   rK   r4   r+   r   r      s,    0
"I 
 09M,8	9r4   r   c                  >    e Zd ZU dZdZded<   eZded<   d
dZddZy	)r   a  Represents a button from the Discord Bot UI Kit.

    This inherits from :class:`Component`.

    .. note::

        The user constructible and usable type to create a button is :class:`discord.ui.Button`
        not this one.

    .. versionadded:: 2.0

    Attributes
    ----------
    style: :class:`.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.
    emoji: Optional[:class:`PartialEmoji`]
        The emoji of the button, if available.
    sku_id: Optional[:class:`int`]
        The ID of the SKU this button refers to.
    )r\   r]   urldisabledr^   emojisku_idr   r    r!   r"   c                   t        t        |d         | _        t        t        |d         | _        |j                  d      | _        |j                  d      | _        |j                  dd      | _        |j                  d      | _	        |  	 t        j                  |d         | _        |j                  d	      | _        y # t        $ r
 d | _        Y )w xY w)
Nr   r\   r]   rl   rm   Fr^   rn   ro   )r   r   r   r	   r\   rP   r]   rl   rm   r^   r   	from_dictrn   r9   ro   re   s     r+   rT   zButton.__init__   s    #+M4<#H	"*;W"F
%)XXk%:#xx"hhz59!%'!2
	%//W>DJ #'((8"4  	DJ	s   C CCc                V   dt        | j                        | j                  | j                  d}| j                  r| j                  |d<   | j
                  r| j
                  |d<   | j                  r| j                  j                         |d<   | j                  r| j                  |d<   |S )N   )r   r\   r^   rm   r]   rl   rn   ro   )	rV   r\   r^   rm   r]   rl   rn   rB   ro   rh   s     r+   rB   zButton.to_dict  s    _ZZ	
 >>#'>>GK 88!XXGEN::#zz113GG;; $GHr4   N)rR   ButtonComponentPayload)rD   rt   rZ   rK   r4   r+   r   r      s,    <"I  09M,85r4   r   c                  >    e Zd ZU dZdZded<   eZded<   d
dZddZy	)r   a  Represents a select menu from the Discord Bot UI Kit.

    A select menu is functionally the same as a dropdown, however
    on mobile it renders a bit differently.

    .. note::

        The user constructible and usable type to create a select menu is
        :class:`discord.ui.Select` not this one.

    .. versionadded:: 2.0

    .. versionchanged:: 2.3

        Added support for :attr:`ComponentType.user_select`, :attr:`ComponentType.role_select`,
        :attr:`ComponentType.mentionable_select`, and :attr:`ComponentType.channel_select`.

    Attributes
    ----------
    type: :class:`ComponentType`
        The select menu's type.
    custom_id: Optional[:class:`str`]
        The ID of the select menu that gets received during an interaction.
    placeholder: Optional[:class:`str`]
        The placeholder text that is shown if nothing is selected, if any.
    min_values: :class:`int`
        The minimum number of items that must be chosen for this select menu.
        Defaults to 1 and must be between 0 and 25.
    max_values: :class:`int`
        The maximum number of items that must be chosen for this select menu.
        Defaults to 1 and must be between 1 and 25.
    options: List[:class:`SelectOption`]
        A list of options that can be selected in this menu.
        Will be an empty list for all component types
        except for :attr:`ComponentType.string_select`.
    channel_types: List[:class:`ChannelType`]
        A list of channel types that can be selected.
        Will be an empty list for all component types
        except for :attr:`ComponentType.channel_select`.
    disabled: :class:`bool`
        Whether the select is disabled or not.
    )r]   r_   
min_values
max_valuesoptionschannel_typesrm   r   r    r!   r"   c                   t        t        |d         | _        |d   | _        |j	                  d      | _        |j	                  dd      | _        |j	                  dd      | _        |j	                  dd      | _        |j	                  d	g       D cg c]  }t        j                  |       c}| _        |j	                  d
g       D cg c]  }t        t        |       c}| _        y c c}w c c}w )Nr   r]   r_   rv   r   rw   rm   Frx   ry   )r   r   r   r]   rP   r_   rv   rw   rm   r   rq   rx   r
   ry   )r*   rR   optioncts       r+   rT   zSelectMenu.__init__Y  s    ]DL9	";/'+xx'>#xxa8#xxa8"hhz599=)R9P,
/5L""6*,
 15"0M1
*,H["%1
,
1
s   C*
C/c                   | j                   j                  | j                  | j                  | j                  | j
                  d}| j                   t        j                  u r+| j                  D cg c]  }|j                          c}|d<   | j                   t        j                  u r3| j                  r'| j                  D cg c]  }|j                   c}|d<   | j                  r| j                  |d<   |S c c}w c c}w )N)r   r]   rv   rw   rm   rx   ry   r_   )r   r=   r]   rv   rw   rm   r   string_selectrx   rB   channel_selectry   r_   )r*   ri   opr|   s       r+   rB   zSelectMenu.to_dictg  s    IIOO////&
 993339=!F2"**,!FGI994449K9K;?;M;M'NR'NGO$%)%5%5GM" "G'Ns   /C8C=N)rR   SelectMenuPayload)rD   r   rZ   rK   r4   r+   r   r   !  s-    )V"I  09M,8
r4   r   c                      e Zd ZU dZdZded<   edddd	 	 	 	 	 	 	 	 	 	 	 ddZdd	Zdd
Z	e
dd       Zej                  dd       Zedd       ZddZy)r   a  Represents a :class:`discord.SelectMenu`'s option.

    These can be created by users.

    .. versionadded:: 2.0

    Attributes
    ----------
    label: :class:`str`
        The label of the option. This is displayed to users.
        Can only be up to 100 characters.
    value: :class:`str`
        The value of the option. This is not displayed to users.
        If not provided when constructed then it defaults to the
        label. Can only be up to 100 characters.
    description: Optional[:class:`str`]
        An additional description of the option, if any.
        Can only be up to 100 characters.
    default: :class:`bool`
        Whether this option is selected by default.
    )r^   r=   description_emojidefaultr   r    NF)r=   r   rn   r   c                  t        |      dkD  rt        d      |t        urt        |      dkD  rt        d      |t        |      dkD  rt        d      || _        |t        u r|n|| _        || _        || _        || _        y )Nd   z%label must be 100 characters or fewerz%value must be 100 characters or fewerz+description must be 100 characters or fewer)len
ValueErrorr   r^   r=   r   rn   r   )r*   r^   r=   r   rn   r   s         r+   rT   zSelectOption.__init__  s     u:DEECJ$4DEE"s;'7#'=JKK
#w.UE
&
r4   c                    d| j                   d| j                  d| j                  d| j                  d| j                  dS )Nz<SelectOption label=z value=z description=z emoji=z	 default=r.   r^   r=   r   rn   r   rA   s    r+   r3   zSelectOption.__repr__  sM    jj^74::.dFVFVEY ZZZN)DLL+;1>	
r4   c                    | j                   r| j                    d| j                   n| j                  }| j                  r| d| j                   S |S )Nr$   
)rn   r^   r   )r*   bases     r+   __str__zSelectOption.__str__  sL    /3zz$**Qtzzl+tzzV2d../00r4   c                    | j                   S )z&The emoji of the option, if available.)r   rA   s    r+   rn   zSelectOption.emoji  s     {{r4   c                    |mt        |t              rt        j                  |      }|| _        y t        |t              r|j                         }|| _        y t        d|j                         || _        y )Nz5expected emoji to be str, Emoji, or PartialEmoji not )	
isinstancerE   r   from_strr   _to_partial	TypeErrorr0   r   )r*   r=   s     r+   rn   zSelectOption.emoji  sz    %%$--e4  E9-))+   (* 
 r4   c           
         	 t        j                  |d         } | |d   |d   |j                  d      ||j                  dd            S # t        $ r d }Y ?w xY w)Nrn   r^   r=   r   r   Fr   )r   rq   r9   rP   )r:   rR   rn   s      r+   rq   zSelectOption.from_dict  sk    	 **4=9E w-w-/HHY.
 	
  	E	s   A AAc                    | j                   | j                  | j                  d}| j                  r| j                  j	                         |d<   | j
                  r| j
                  |d<   |S )N)r^   r=   r   rn   r   )r^   r=   r   rn   rB   r   rh   s     r+   rB   zSelectOption.to_dict  s\    ZZZZ||(
 ::#zz113GG%)%5%5GM"r4   )r^   rE   r=   rE   r   z
str | Nonern   !str | Emoji | PartialEmoji | Noner   boolrD   NonerC   )rD   r   )rD   r   )rR   SelectOptionPayloadrD   r   )rD   r   )r1   rF   rG   rH   r    rI   r   rT   r3   r   propertyrn   setterrJ   rq   rB   rK   r4   r+   r   r   z  s    ,"I  "&37  	
   1  
0
   \\  
 
r4   r   c                    | d   }|dk(  rt        |       S |dk(  rt        |       S |dk(  rt        |       S |dv rt        |       S t	        t
        |      }t        j                  |      S )Nr   r   rs   rg   )               r   )r   r   r   r   r   r   r   r>   )rR   component_typeas_enums      r+   rQ   rQ     st    &\N	1	d|	1		?	*$=.9''W'55r4   N)rR   rX   rD   r   )'rH   
__future__r   typingr   r   r   r   enumsr	   r
   r   r   r   partial_emojir   r   utilsr   r   rn   r   types.componentsr   rY   r   rt   r   rX   r   rj   r   r   r   r   __all__r   r   rQ   rK   r4   r+   <module>r      s   2 # 8 8 T T 2 %?K?HAE C{#)" )"X
	 
DJ	 JZLY L^V Vrt tn6r4   