
    i2                        d Z ddlmZ ddlmZ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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  dZ! G d de
          Z" G d d          Z#dS )a:  
The MIT License (MIT)

Copyright (c) 2015-present Rapptz

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DictIterableIteratorList
NamedTupleTuple   )Member)Object)Role)Message
Attachment)PartialMessageable)AppCommandOptionType   )AppCommandChannelAppCommandThread)Interaction)ResolvedData'ApplicationCommandInteractionDataOption)	Namespacec                  L    e Zd ZU ded<   ded<   edd            Zdd
ZddZdS )
ResolveKeystridinttypereturnc                $    t          |d          S )Nr   r    )r   )clsr   s     _/usr/local/lib/hermes-agent/venv/lib/python3.11/site-packages/discord/app_commands/namespace.pyany_withzResolveKey.any_with1   s    Rb))))    oobjectboolc                    t          |t                    st          S | j        dk    s|j        dk    r| j        |j        k    S | j        | j        f|j        |j        fk    S )Nr#   )
isinstancer   NotImplementedr    r   )selfr)   s     r&   __eq__zResolveKey.__eq__5   sY    !Z(( 	"!!9??afll7ad?"#af~55r(   c                *    t          | j                  S N)hashr   r/   s    r&   __hash__zResolveKey.__hash__<   s     DG}}r(   N)r   r   r!   r   )r)   r*   r!   r+   )r!   r   )__name__
__module____qualname____annotations__classmethodr'   r0   r5    r(   r&   r   r   +   sp         GGG III* * * [*6 6 6 6     r(   r   c                  j    e Zd ZdZddZed d            Zd!dZd"dZd#dZ	d#dZ
d$dZd%dZd&dZdS )'r   a  An object that holds the parameters being passed to a command in a mostly raw state.

    This class is deliberately simple and just holds the option name and resolved value as a simple
    key-pair mapping. These attributes can be accessed using dot notation. For example, an option
    with the name of ``example`` can be accessed using ``ns.example``. If an attribute is not found,
    then ``None`` is returned rather than an attribute error.

    .. warning::

        The key names come from the raw Discord data, which means that if a parameter was renamed then the
        renamed key is used instead of the function parameter name.

    .. versionadded:: 2.0

    .. container:: operations

        .. describe:: x == y

            Checks if two namespaces are equal by checking if all attributes are equal.
        .. describe:: x != y

            Checks if two namespaces are not equal.
        .. describe:: x[key]

            Returns an attribute if it is found, otherwise raises
            a :exc:`KeyError`.
        .. describe:: key in x

            Checks if the attribute is in the namespace.
        .. describe:: iter(x)

           Returns an iterator of ``(name, value)`` pairs. This allows it
           to be, for example, constructed as a dict or a list of pairs.

    This namespace object converts resolved objects into their appropriate form depending on their
    type. Consult the table below for conversion information.

    +-------------------------------------------+-------------------------------------------------------------------------------+
    |                Option Type                |                                 Resolved Type                                 |
    +===========================================+===============================================================================+
    | :attr:`.AppCommandOptionType.string`      | :class:`str`                                                                  |
    +-------------------------------------------+-------------------------------------------------------------------------------+
    | :attr:`.AppCommandOptionType.integer`     | :class:`int`                                                                  |
    +-------------------------------------------+-------------------------------------------------------------------------------+
    | :attr:`.AppCommandOptionType.boolean`     | :class:`bool`                                                                 |
    +-------------------------------------------+-------------------------------------------------------------------------------+
    | :attr:`.AppCommandOptionType.number`      | :class:`float`                                                                |
    +-------------------------------------------+-------------------------------------------------------------------------------+
    | :attr:`.AppCommandOptionType.user`        | :class:`~discord.User` or :class:`~discord.Member`                            |
    +-------------------------------------------+-------------------------------------------------------------------------------+
    | :attr:`.AppCommandOptionType.channel`     | :class:`.AppCommandChannel` or :class:`.AppCommandThread`                     |
    +-------------------------------------------+-------------------------------------------------------------------------------+
    | :attr:`.AppCommandOptionType.role`        | :class:`~discord.Role`                                                        |
    +-------------------------------------------+-------------------------------------------------------------------------------+
    | :attr:`.AppCommandOptionType.mentionable` | :class:`~discord.User` or :class:`~discord.Member`, or :class:`~discord.Role` |
    +-------------------------------------------+-------------------------------------------------------------------------------+
    | :attr:`.AppCommandOptionType.attachment`  | :class:`~discord.Attachment`                                                  |
    +-------------------------------------------+-------------------------------------------------------------------------------+

    .. note::

        In autocomplete interactions, the namespace might not be validated or filled in. Discord does not
        send the resolved data as well, so this means that certain fields end up just as IDs rather than
        the resolved data. In these cases, a :class:`discord.Object` is returned instead.

        This is a Discord limitation.
    interactionr   resolvedr   options-List[ApplicationCommandInteractionDataOption]c                T   |                      ||          }|D ]}|d         }|d         }|                    dd          }|dv r|d         }	|	| j        |<   @|dk    rM|d         }	|	|	dk    rt          d	          | j        |<   n|st          |	          | j        |<   |	| j        |<   |d
v rv|d         }
|dk    rt                              |
          }nt	          |
|          }|                    |          pt          t          |
                    }	|	| j        |<   d S )Nr    namefocusedF)         value
    nan)         	      rN   r$   )r   )_get_resolved_itemsget__dict__floatr   r'   r   r   )r/   r=   r>   r?   	completedoptionopt_typerB   rC   rG   	snowflakekeys               r&   __init__zNamespace.__init__   sX    ,,[(CC	  	,  	,Ff~H&>DjjE22G9$$w&+d##Rw=ERKK*/,,DM$''" 4.3Elld++ /4d++---!'	q==$--i88CC %	AAAC!c**GfI.G.G.G&+d#A 	,  	,r(   r!   Dict[ResolveKey, Any]c                   i }|j         |                    di           }|j        }|j        t          j        j        |                    di                                           D ]p\  }}	 ||         }||d<   t          |          }	|	|t          |          <   :# t          $ r*                     |          |t          |          <   Y mw xY wt          j        j        |                    fd|                    di                                           D                        t          j        j        |                    di                                           D ]K\  }
}t          |
          }|d	         d
v rt          ||          ||<   6t!          ||          ||<   Lt          j        j        |                    fd|                    di                                           D                        |                    di                                           D ]\  }}t%          |d                   }
t'          ||
          }n'                    |
          pt'          ||
          }t+          ||          }|_        t          |d          }|||<   |S )Nmembersusersuser)stateguilddatar$   c                Z    i | ]'\  }}t          |           t          |          (S )r$   )r`   r_   ra   )r   r   ).0role_id	role_datar`   r_   r    s      r&   
<dictcomp>z1Namespace._get_resolved_items.<locals>.<dictcomp>   sN        'GY gD1114e5W`3a3a3a  r(   roleschannelsr    )rH   rO      )r_   ra   guild_idc                X    i | ]&\  }}t          |           t          |          'S )r$   )ra   r_   )r   r   )rc   attachment_idattachment_datar_   r    s      r&   rf   z1Namespace._get_resolved_items.<locals>.<dictcomp>   sJ       2M? m$777`e9f9f9f  r(   attachmentsmessages
channel_id)r_   rj   r   )r_   channelra   r#   )_staterQ   rj   r`   r   r^   rG   itemsr   r   KeyErrorcreate_userroleupdaterq   r   r   
attachmentr   r   get_channel_or_threadr   )r%   r=   r>   rT   r\   rj   user_id	user_datamember_datamemberrp   channel_datarX   
message_idmessage_datarq   messager`   r_   r    s                    @@@r&   rP   zNamespace._get_resolved_items   sL   +-	",,y"--'!#(."*,,w";";"A"A"C"C 
	F 
	FGY	F%g. '0F#  e5{KKK?E	*d;;;<<  \ \ \?D?P?PQZ?[?[	*d;;;<<<\ $(.      +3,,w*C*C*I*I*K*K  	
 	
 	
 $+1(0Z(D(D(J(J(L(L 	f 	f$J
666CF#|33!1L[c!d!d!d	# "3\\d!e!e!e	##.4    6>ll=RT6U6U6[6[6]6]  	
 	
 	
 )1Z(D(D(J(J(L(L 	% 	%$J\,788J},58PZ[[[55jAA EW(zF F F
 E7NNNG!GM
444C$IcNNs   0B$$1CCr   c                    d | j                                         D             }d                    | j        j        d                    |                    S )Nc              3  *   K   | ]\  }}| d |V  dS )=Nr;   )rc   kvs      r&   	<genexpr>z%Namespace.__repr__.<locals>.<genexpr>   s0      @@$!QA@@@@@@r(   z<{} {}> )rR   rs   format	__class__r6   join)r/   rs   s     r&   __repr__zNamespace.__repr__   sH    @@$-*=*=*?*?@@@ 7%IIIr(   otherr*   r+   c                    t          | t                    r%t          |t                    r| j        |j        k    S t          S r2   )r-   r   rR   r.   )r/   r   s     r&   r0   zNamespace.__eq__   s:    dI&& 	3:eY+G+G 	3=EN22r(   rX   r   c                    | j         |         S r2   rR   r/   rX   s     r&   __getitem__zNamespace.__getitem__   s    }S!!r(   c                    || j         v S r2   r   r   s     r&   __contains__zNamespace.__contains__   s    dm##r(   attrc                    d S r2   r;   )r/   r   s     r&   __getattr__zNamespace.__getattr__   s    tr(   Iterator[Tuple[str, Any]]c              #  H   K   | j                                         E d {V  d S r2   )rR   rs   r4   s    r&   __iter__zNamespace.__iter__  s2      =&&(((((((((((r(   defaultsIterable[Tuple[str, Any]]Nonec                L    |D ] \  }}| j                             ||           !d S r2   )rR   
setdefault)r/   r   rX   rG   s       r&   _update_with_defaultszNamespace._update_with_defaults  s:    " 	1 	1JCM$$S%0000	1 	1r(   N)r=   r   r>   r   r?   r@   )r=   r   r>   r   r!   rZ   )r!   r   )r   r*   r!   r+   )rX   r   r!   r   )r   r   r!   r   )r!   r   )r   r   r!   r   )r6   r7   r8   __doc__rY   r:   rP   r   r0   r   r   r   r   r   r;   r(   r&   r   r   B   s        B BH', ', ', ',R = = = [=~J J J J   
" " " "$ $ $ $   ) ) ) )1 1 1 1 1 1r(   r   N)$r   
__future__r   typingr   r   r   r   r   r	   r
   r   r}   r   r*   r   rv   r   r   r   r   rq   r   enumsr   modelsr   r   interactionsr   types.interactionsr   r   __all__r   r   r;   r(   r&   <module>r      s   0 # " " " " " X X X X X X X X X X X X X X X X X X X X                   ) ) ) ) ) ) ) ) ( ( ( ( ( ( ( ( ( ( ( ( 7 7 7 7 7 7 7 7 [******ZZZZZZZZ
       .E1 E1 E1 E1 E1 E1 E1 E1 E1 E1r(   