
    iL                    	   U d Z ddlmZ ddlZddl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mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z! ddl"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,Z,ddl-Z-dd	l.m/Z0m1Z2 dd
l3m4Z4 ddl5m6Z6 ddl7Z7ddl8Z8ddl9Z9ddl:Z:ddl;Z;ddlZddl<Z<ddl=Z=ddl>Z>	 ddl?Z?dZ@n# eA$ r dZ@Y nw xY wdZBdeCd<   	 ddlDmEZE dZBn$# eF$ r 	 ddlGmEZE dZBn# eF$ r ddlHZHY nw xY wY nw xY wdZIdZJdZK e8jL        d          ZMdeCd<    G d d          ZN eN            ZOdeCd<    G d d          ZPe!rYddl-mQZQ dd lRmSZSmTZTmUZU d!d"lVmWZW d!d#lXmYZY d!d$lZm[Z[ d!d%l\m]Z]  G d& d'e          Z^ eSd(          Z_ee_d)f         Z`ej        ea         Zbn	ePZQej        Zb ed*          Zc ed+d,          Zdeeec         e	ec         f         Zeeeeecf         Zfeeceec         f         Zg G d- d.eecedf                   Zh G d/ d0eed                   Zidd5Zj G d6 d7eed                   Zke dd:            Zle dd<            Zle dd?            Zldd@ZlddDZmdddGZneOeOeOeOdeOdHddUZoddXZpddYdd\ZqddbZrdddZse ddf            Zte ddg            Ztd djZtd!dlZud"dmZve d#dn            Zwe d!do            Zwd$dpZwd%drZxd&dvZyd'dxZzd'dyZ{ddzd(d|Z|d)d}Z}d*dZ~e@rd+dZe?j        Znd+dZe7j        Zddd,dZd-dZe0dd.dZd/dZd0dZd1dZe d2d            Ze d3d            Zdd4dZd5dZd6dZ G d deb          Zd7dZ G d de          Zd8dZd9dZd                    d dD                       ZdZ e8jL        de de de8j                  ZdZde dZddd:dZdddd;dÄZd<dĄZd=dȄZd>dʄZe d>d˄            Ze d=d̄            Zd?d΄Ze:j        dk    Ze:j        dk    Zd@dԄZd@dՄZdd֜dAd݄ZdBdZdCdZed         ZddDdZdEdZdFdZ G d de=j                  ZeOeOeOdddGdZ edd!dd          ddHdZ e8jL        d          Zd<dZd dddIdZeB G d d	          ZeZd
eCd<   n G d d          ZeZd
eCd<   dJdZ G d d          ZdS (K  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.
    )annotationsN)TextWrapper)AnyAsyncIterableAsyncIterator	AwaitableCallable
Collection	CoroutineDict
ForwardRefGenericIterableIteratorListLiteral
NamedTupleOptionalProtocolSetSequenceSupportsIndexTupleTypeTypeVarUnionoverloadTYPE_CHECKING)islice)	b64encode	b64decode)bisect_left)isawaitable	signature)
attrgetter)	urlencodeTFz/Literal['zstandard', 'compression.zstd'] | None_ZSTD_SOURCE)ZstdDecompressor	zstandardzcompression.zstd)	oauth_urlsnowflake_timetime_snowflakefindgetsleep_untilutcnowremove_markdownescape_markdownescape_mentionsmaybe_coroutine	as_chunks	format_dtMISSINGsetup_loggingl    0E*i   z<t:(-?\d+)(?::[tTdDfFsSR])?>zre.Pattern[str]TIMESTAMP_PATTERNc                  0    e Zd ZdZd
dZd
dZddZd Zd	S )_MissingSentinel returnboolc                    dS NFr<   )selfothers     T/home/ubuntu/.hermes/hermes-agent/venv/lib/python3.11/site-packages/discord/utils.py__eq__z_MissingSentinel.__eq__       u    c                    dS r@   r<   rA   s    rC   __bool__z_MissingSentinel.__bool__   rE   rF   intc                    dS Nr   r<   rH   s    rC   __hash__z_MissingSentinel.__hash__   s    qrF   c                    dS )Nz...r<   rH   s    rC   __repr__z_MissingSentinel.__repr__   rE   rF   Nr=   r>   r=   rJ   )__name__
__module____qualname__	__slots__rD   rI   rM   rO   r<   rF   rC   r;   r;   |   sd        I             rF   r;   r   r7   c                      e Zd ZddZd ZdS )_cached_propertyr=   Nonec                >    || _         t          |d          | _        d S N__doc__)functiongetattrr[   )rA   r\   s     rC   __init__z_cached_property.__init__   s     x33rF   c                n    || S |                      |          }t          || j         j        |           |S N)r\   setattrrR   rA   instanceownervalues       rC   __get__z_cached_property.__get__   s:    Kh''$-0%888rF   Nr=   rX   )rR   rS   rT   r^   rf   r<   rF   rC   rW   rW      s7        4 4 4 4    rF   rW   )cached_property)	ParamSpecSelf	TypeGuard   )Permissions)	SnowflakeInviteTemplatec                  "    e Zd ZU ded<   d	dZdS )
_DecompressionContextstrCOMPRESSION_TYPEdatabytesr=   
str | Nonec                   d S r`   r<   rA   rw   s     rC   
decompressz _DecompressionContext.decompress         rF   Nrw   rx   r=   ry   )rR   rS   rT   __annotations__r|   r<   rF   rC   rt   rt      s*         ??????rF   rt   PzMaybeAwaitable[T]TT_co)	covariantc                  N    e Zd ZddZedd            Zedd            ZddZdS )CachedSlotPropertynameru   r\   Callable[[T], T_co]r=   rX   c                L    || _         || _        t          |d          | _        d S rZ   )r   r\   r]   r[   )rA   r   r\   s      rC   r^   zCachedSlotProperty.__init__   s%    	 x33rF   rc   rd   Type[T]CachedSlotProperty[T, T_co]c                    d S r`   r<   rA   rc   rd   s      rC   rf   zCachedSlotProperty.__get__   s    VYVYrF   r   r   c                    d S r`   r<   r   s      rC   rf   zCachedSlotProperty.__get__   s    <?CrF   Optional[T]r   c                    || S 	 t          || j                  S # t          $ r0 |                     |          }t	          || j        |           |cY S w xY wr`   )r]   r   AttributeErrorr\   ra   rb   s       rC   rf   zCachedSlotProperty.__get__   sm    K	8TY/// 	 	 	MM(++EHdi///LLL	s    7AAN)r   ru   r\   r   r=   rX   )rc   rX   rd   r   r=   r   )rc   r   rd   r   r=   r   )rc   r   rd   r   r=   r   )rR   rS   rT   r^   r   rf   r<   rF   rC   r   r      sj        4 4 4 4
 YYY XY??? X?	 	 	 	 	 	rF   r   c                  &    e Zd ZddZddZddZdS )classpropertyfgetCallable[[Any], T_co]r=   rX   c                    || _         d S r`   r   )rA   r   s     rC   r^   zclassproperty.__init__   s    			rF   rc   Optional[Any]rd   	Type[Any]r   c                ,    |                      |          S r`   r   r   s      rC   rf   zclassproperty.__get__   s    yyrF   re   r   c                     t          d          )Nzcannot set attribute)r   )rA   rc   re   s      rC   __set__zclassproperty.__set__   s    3444rF   N)r   r   r=   rX   )rc   r   rd   r   r=   r   )rc   r   re   r   r=   rX   )rR   rS   rT   r^   rf   r   r<   rF   rC   r   r      sP                  5 5 5 5 5 5rF   r   r   ru   r=   <Callable[[Callable[[T], T_co]], CachedSlotProperty[T, T_co]]c                     d fd}|S )Nfuncr   r=   r   c                $    t          |           S r`   )r   )r   r   s    rC   	decoratorz'cached_slot_property.<locals>.decorator   s    !$---rF   )r   r   r=   r   r<   )r   r   s   ` rC   cached_slot_propertyr      s)    . . . . . . rF   c                      e Zd ZdZddd%dZed&d            Zd'dZe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 )0SequenceProxyz>A proxy of a sequence that only creates a copy when necessary.F)sortedproxiedCollection[T_co]r   r>   c               "    || _         || _        d S r`   )_SequenceProxy__proxied_SequenceProxy__sorted)rA   r   r   s      rC   r^   zSequenceProxy.__init__   s    +2$rF   r=   
List[T_co]c                    | j         rt          | j                  | _        nt          | j                  | _        | j        S r`   )r   r   r   listrH   s    rC   __copiedzSequenceProxy.__copied   s8    = 	2#DN33DNN!$.11DN~rF   ru   c                    d| j         dS )NzSequenceProxy())r   rH   s    rC   rO   zSequenceProxy.__repr__   s    33333rF   idxr   r   c                    d S r`   r<   rA   r   s     rC   __getitem__zSequenceProxy.__getitem__   s    7:srF   slicec                    d S r`   r<   r   s     rC   r   zSequenceProxy.__getitem__       58SrF   Union[SupportsIndex, slice]Union[T_co, List[T_co]]c                    | j         |         S r`   _SequenceProxy__copiedr   s     rC   r   zSequenceProxy.__getitem__  s    }S!!rF   rJ   c                *    t          | j                  S r`   )lenr   rH   s    rC   __len__zSequenceProxy.__len__  s    4>"""rF   itemr   c                    || j         v S r`   r   )rA   r   s     rC   __contains__zSequenceProxy.__contains__  s    t}$$rF   Iterator[T_co]c                *    t          | j                  S r`   )iterr   rH   s    rC   __iter__zSequenceProxy.__iter__  s    DM"""rF   c                *    t          | j                  S r`   )reversedr   rH   s    rC   __reversed__zSequenceProxy.__reversed__  s    &&&rF   re   argskwargsc                .     | j         j        |g|R i |S r`   )r   index)rA   re   r   r   s       rC   r   zSequenceProxy.index  s'    "t}"5:4:::6:::rF   c                6    | j                             |          S r`   )r   countrA   re   s     rC   r   zSequenceProxy.count  s    }""5)))rF   N)r   r   r   r>   )r=   r   r=   ru   )r   r   r=   r   )r   r   r=   r   )r   r   r=   r   rQ   )r   r   r=   r>   )r=   r   )re   r   r   r   r   r   r=   rJ   )re   r   r=   rJ   )rR   rS   rT   r[   r^   rh   r   rO   r   r   r   r   r   r   r   r   r<   rF   rC   r   r      s)       HHDI % % % % % %    _4 4 4 4 ::: X:888 X8" " " "# # # #% % % %# # # #' ' ' '; ; ; ;* * * * * *rF   r   	timestamprX   c                    d S r`   r<   r   s    rC   
parse_timer     s    ),rF   datetime.datetimec                    d S r`   r<   r   s    rC   r   r     r   rF   Optional[str]Optional[datetime.datetime]c                    d S r`   r<   r   s    rC   r   r      s    ILrF   c                H    | rt           j                             |           S d S r`   )datetimefromisoformatr   s    rC   r   r   $  s&     : ..y9994rF   originalCallable[..., Any]Callable[[T], T]c                     d fd}|S )N
overriddenr   r=   c                H    j         | _         t                    | _        | S r`   )r[   
_signature__signature__)r   r   s    rC   r   zcopy_doc.<locals>.decorator+  s$    %-
#-h#7#7
 rF   )r   r   r=   r   r<   )r   r   s   ` rC   copy_docr   *  s)         
 rF   instead*Callable[[Callable[P, T]], Callable[P, T]]c                     d fd}|S )Nr   Callable[P, T]r=   c                L     t          j                   d fd            }|S )	Nr   P.argsr   P.kwargsr=   r   c                     t          j        dt                     rd}nd}t          j        |                              dt                     t          j        dt                      | i |S )Nalwaysz,{0.__name__} is deprecated, use {1} instead.z{0.__name__} is deprecated.   )
stacklevelcategorydefault)warningssimplefilterDeprecationWarningwarnformat)r   r   fmtr   r   s      rC   	decoratedz7deprecated.<locals>.actual_decorator.<locals>.decorated5  sz    !(,>??? 4D3M#**T733L^____!)-?@@@4((((rF   )r   r   r   r   r=   r   )	functoolswraps)r   r   r   s   ` rC   actual_decoratorz$deprecated.<locals>.actual_decorator4  sD    					) 		) 		) 		) 		) 		) 
			) rF   )r   r   r=   r   r<   )r   r   s   ` rC   
deprecatedr   3  s)          rF   )permissionsguildredirect_uriscopesdisable_guild_selectstate	client_idUnion[int, str]r   rm   r   rn   r   r  Optional[Iterable[str]]r  r>   r  c               4   d|  }||dd                     |pd          z   z  }|t          ur|d|j         z  }|t          ur|d|j         z  }|r|dz  }|t          ur|d	t	          d
|i          z   z  }|t          ur|dt	          d|i           z  }|S )a  A helper function that returns the OAuth2 URL for inviting the bot
    into guilds.

    .. versionchanged:: 2.0

        ``permissions``, ``guild``, ``redirect_uri``, ``scopes`` and ``state`` parameters
        are now keyword-only.

    Parameters
    -----------
    client_id: Union[:class:`int`, :class:`str`]
        The client ID for your bot.
    permissions: :class:`~discord.Permissions`
        The permissions you're requesting. If not given then you won't be requesting any
        permissions.
    guild: :class:`~discord.abc.Snowflake`
        The guild to pre-select in the authorization screen, if available.
    redirect_uri: :class:`str`
        An optional valid redirect URI.
    scopes: Iterable[:class:`str`]
        An optional valid list of scopes. Defaults to ``('bot', 'applications.commands')``.

        .. versionadded:: 1.7
    disable_guild_select: :class:`bool`
        Whether to disallow the user from changing the guild dropdown.

        .. versionadded:: 2.0
    state: :class:`str`
        The state to return after the authorization.

        .. versionadded:: 2.0

    Returns
    --------
    :class:`str`
        The OAuth2 URL for inviting the bot into guilds.
    z/https://discord.com/oauth2/authorize?client_id=Nz&scope=+)botzapplications.commandsz&permissions=z
&guild_id=z&disable_guild_select=truez&response_type=code&r   &r  )joinr7   re   idr&   )r  r   r   r   r  r  r  urls           rC   r*   r*   F  s    ^ HI
G
GCy388F$N.NOOOO'!!2{0222G&EH&&& ,++7""%	><2P(Q(QQQG09gu-..000JrF   r  rJ   c                   | dz	  t           z   dz  }t          j                            |t          j        j                  S )ab  Returns the creation time of the given snowflake.

    .. versionchanged:: 2.0
        The ``id`` parameter is now positional-only.

    Parameters
    -----------
    id: :class:`int`
        The snowflake ID.

    Returns
    --------
    :class:`datetime.datetime`
        An aware datetime in UTC representing the creation time of the snowflake.
         )tz)DISCORD_EPOCHr   fromtimestamptimezoneutc)r  r   s     rC   r+   r+     s9      (m+t3I**99J9N*OOOrF   )highdtr  c              r    t          |                                 dz  t          z
            }|dz  |rdndz   S )aW  Returns a numeric snowflake pretending to be created at the given date.

    When using as the lower end of a range, use ``time_snowflake(dt, high=False) - 1``
    to be inclusive, ``high=True`` to be exclusive.

    When using as the higher end of a range, use ``time_snowflake(dt, high=True) + 1``
    to be inclusive, ``high=False`` to be exclusive.

    .. versionchanged:: 2.0
        The ``high`` parameter is now keyword-only and the ``dt`` parameter is now
        positional-only.

    Parameters
    -----------
    dt: :class:`datetime.datetime`
        A datetime object to convert to a snowflake.
        If naive, the timezone is assumed to be local time.
    high: :class:`bool`
        Whether or not to set the lower 22 bit to high or low.

    Returns
    --------
    :class:`int`
        The snowflake representing the time given.
    r  r  i? r   )rJ   r   r  )r  r  discord_milliss      rC   r,   r,     s<    4 $.>??Nb $%=YYA>>rF   	predicateCallable[[T], Any]iterableIterable[T]r   c               >    t          t          | |          d           S r`   )nextfilterr  r  s     rC   _findr"    s    y(++T222rF   AsyncIterable[T]c               >   K   |2 3 d {V } | |          r|c S 6 d S r`   r<   )r  r  elements      rC   _afindr&    sZ      !       g9W 	NNN	 " 4s   Coro[Optional[T]]c                   d S r`   r<   r!  s     rC   r-   r-     s    ]`]`rF   c                   d S r`   r<   r!  s     rC   r-   r-     s    RURUrF   _Iter[T]%Union[Optional[T], Coro[Optional[T]]]c               b    t          |d          rt          | |          nt          | |          S )a  A helper to return the first element found in the sequence
    that meets the predicate. For example: ::

        member = discord.utils.find(lambda m: m.name == 'Mighty', channel.guild.members)

    would find the first :class:`~discord.Member` whose name is 'Mighty' and return it.
    If an entry is not found, then ``None`` is returned.

    This is different from :func:`py:filter` due to the fact it stops the moment it finds
    a valid entry.

    .. versionchanged:: 2.0

        Both parameters are now positional-only.

    .. versionchanged:: 2.0

        The ``iterable`` parameter supports :term:`asynchronous iterable`\s.

    Parameters
    -----------
    predicate
        A function that returns a boolean-like result.
    iterable: Union[:class:`collections.abc.Iterable`, :class:`collections.abc.AsyncIterable`]
        The iterable to search through. Using a :class:`collections.abc.AsyncIterable`,
        makes this function return a :term:`coroutine`.
    	__aiter__)hasattrr&  r"  r!  s     rC   r-   r-     s7    > 8[))	(y(###9h''rF   attrsc               v   t           }t          t          |          dk    rS|                                \  } |                    dd                    t          fd| D             d           S fd|                                D             }| D ] |fd|D                       rc S d S )Nrl   __.c              3  :   K   | ]} |          k    |V  d S r`   r<   ).0elempredvs     rC   	<genexpr>z_get.<locals>.<genexpr>  s/      BBd$$t**//T////BBrF   c                X    g | ]&\  }} |                     d d                    |f'S r1  r2  replacer4  attrre   attrgets      rC   
<listcomp>z_get.<locals>.<listcomp>  :    \\\{tU''$,,tS1122E:\\\rF   c              3  <   K   | ]\  }} |          |k    V  d S r`   r<   r4  r6  re   r5  s      rC   r8  z_get.<locals>.<genexpr>  4      AAeT

e#AAAAAArF   )allr%   r   popitemr<  r  items)	r  r/  _allk	convertedr?  r5  r6  r7  s	        @@@@rC   _getrK    s    DG 5zzQ}}1wqyys++,,BBBBBhBBBDIII\\\\ekkmm\\\I  4AAAAyAAAAA 	KKK	4rF   c                 K   t           }t          t          |          dk    rV|                                \  }} |                    dd                    }| 2 3 d {V  |          |k    rc S 6 d S fd|                                D             }| 2 3 d {V  |fd|D                       rc S #6 d S )Nrl   r1  r2  c                X    g | ]&\  }} |                     d d                    |f'S r:  r;  r=  s      rC   r@  z_aget.<locals>.<listcomp>  rA  rF   c              3  <   K   | ]\  }} |          |k    V  d S r`   r<   rC  s      rC   r8  z_aget.<locals>.<genexpr>  rD  rF   )rE  r%   r   rF  r<  rG  )	r  r/  rH  rI  r7  r6  rJ  r?  r5  s	          @@rC   _agetrO    s.     DG 5zzQ}}1wqyys++,," 	 	 	 	 	 	 	$tDzzQ  # t\\\\ekkmm\\\I       d4AAAAyAAAAA 	KKK	  4s   A9Cc                   d S r`   r<   r  r/  s     rC   r.   r.     s    KN3rF   c                   d S r`   r<   rQ  s     rC   r.   r.     s    @CrF   c               V    t          | d          rt          | fi |nt          | fi |S )a  A helper that returns the first element in the iterable that meets
    all the traits passed in ``attrs``. This is an alternative for
    :func:`~discord.utils.find`.

    When multiple attributes are specified, they are checked using
    logical AND, not logical OR. Meaning they have to meet every
    attribute passed in and not one of them.

    To have a nested attribute search (i.e. search by ``x.y``) then
    pass in ``x__y`` as the keyword argument.

    If nothing is found that matches the attributes passed, then
    ``None`` is returned.

    .. versionchanged:: 2.0

        The ``iterable`` parameter is now positional-only.

    .. versionchanged:: 2.0

        The ``iterable`` parameter supports :term:`asynchronous iterable`\s.

    Examples
    ---------

    Basic usage:

    .. code-block:: python3

        member = discord.utils.get(message.guild.members, name='Foo')

    Multiple attribute matching:

    .. code-block:: python3

        channel = discord.utils.get(guild.voice_channels, name='Foo', bitrate=64000)

    Nested attribute matching:

    .. code-block:: python3

        channel = discord.utils.get(client.get_all_channels(), guild__name='Cool', name='general')

    Async iterables:

    .. code-block:: python3

        msg = await discord.utils.get(channel.history(), author__name='Dave')

    Parameters
    -----------
    iterable: Union[:class:`collections.abc.Iterable`, :class:`collections.abc.AsyncIterable`]
        The iterable to search through. Using a :class:`collections.abc.AsyncIterable`,
        makes this function return a :term:`coroutine`.
    \*\*attrs
        Keyword arguments that denote attributes to search with.
    r-  )r.  rO  rK  rQ  s     rC   r.   r.     sD    z 8[))	%h  %   ($$e$$rF   List[T]c                J    d t                               |           D             S )Nc                    g | ]}|S r<   r<   r4  xs     rC   r@  z_unique.<locals>.<listcomp>b  s    ///!A///rF   )dictfromkeys)r  s    rC   _uniquer[  a  s"    //t}}X..////rF   rw   keyOptional[int]c                X    	 | |         }|ot          |          S # t          $ r Y d S w xY wr`   )rJ   KeyError)rw   r\  re   s      rC   _get_as_snowflaker`  e  sG    $S	 #U#    tts    
))rx   c                    |                      d          rdS | dd         dk    s| dd         dv rd	S |                      d
          rdS |                      d          r| dd         dk    rdS t          d          )Ns   PNG

z	image/pngr      s      
   )s   JFIFs   Exifz
image/jpeg)s   GIF87as   GIF89az	image/gifs   RIFF      s   WEBPz
image/webpzUnsupported image type given
startswith
ValueErrorrw   s    rC   _get_mime_type_for_imagerk  n  s    :;; 	9{	aco	%	%ad7I)I)I|	S	T	T 9{		!	! 9d1R4jG&;&;|7888rF   c                x    |                      d          s|                      d          rdS t          d          )Ns   ID3s   z
audio/mpegzUnsupported audio type givenrg  rj  s    rC   _get_mime_type_for_audiorm  {  s=    '' 94??;+G+G 9|7888rF   )audiorn  c                   d}|rt          |           }nt          |           }t          |                               d          }|                    ||          S )Nzdata:{mime};base64,{data}ascii)mimerw   )rm  rk  r    decoder   )rw   rn  r   rq  b64s        rC   _bytes_to_base64_datart    sZ    
%C .'--'--
D//
 
 
)
)C::4c:***rF   c                F    t          |                     d                    S )Nrp  )r!   encoderj  s    rC   _base64_to_bytesrw    s    T[[))***rF   parentchildc                >    | |k    p|                     | dz             S )Nr2  )rh  )rx  ry  s     rC   _is_submoduler{    s#    U?<e..v|<<<rF   objc                P    t          j        |                               d          S Nutf-8)orjsondumpsrr  r|  s    rC   _to_jsonr    s     |C  ''000rF   c                0    t          j        | dd          S )N),:T)
separatorsensure_ascii)jsonr  r  s    rC   r  r    s    z#*4HHHHrF   )	use_clockrequestr  floatc               Z   | j                             d          }|s|st          j        j        }t          j                            |          }t          j                            t          | j         d                   |          }||z
                                  S t          |          S )NzX-Ratelimit-Reset-AfterzX-Ratelimit-Reset)	headersr.   r   r  r  nowr  r  total_seconds)r  r  reset_afterr  r  resets         rC   _parse_ratelimit_headerr    s    !(!4!45N!O!OK " "###C((!//goFY6Z0[0[]`aa**,,,[!!!rF   fMaybeAwaitableFunc[P, T]r   r   r   r   c                H   K    | |i |}t          |          r| d{V S |S )a  |coro|

    A helper function that will await the result of a function if it's a coroutine
    or return the result if it's not.

    This is useful for functions that may or may not be coroutines.

    .. versionadded:: 2.2

    Parameters
    -----------
    f: Callable[..., Any]
        The function or coroutine to call.
    \*args
        The arguments to pass to the function.
    \*\*kwargs
        The keyword arguments to pass to the function.

    Returns
    --------
    Any
        The result of the function or coroutine.
    N)_isawaitable)r  r   r   re   s       rC   r4   r4     sC      2 AtvEE {{{{{{rF   )checkgen Iterable[Union[T, Awaitable[T]]]r  ;Callable[[Union[T, Awaitable[T]]], TypeGuard[Awaitable[T]]]c               D   K   | D ]} ||          r| d {V }|s dS dS )NFTr<   )r  r  r5  s      rC   	async_allr    sQ      
   5;; 	::::::D 	55	4rF   futuresIterable[Awaitable[T]]timeoutOptional[float]Set[asyncio.Task[T]]c                  K   d | D             }t          j        ||t           j                   d {V \  }}t          |          dk    rt          j                    |S )Nc                6    g | ]}t          j        |          S r<   )asyncioensure_future)r4  futs     rC   r@  z!sane_wait_for.<locals>.<listcomp>  s#    ===cw$S))===rF   )r  return_whenr   )r  waitALL_COMPLETEDr   TimeoutError)r  r  ensureddonependings        rC   sane_wait_forr    sm      ==W===G!,wWMbcccccccccMD'
7||q"$$$KrF   clsr   Iterator[str]c              #  t   K   t          | j                  D ] }	 |j        E d {V  # t          $ r Y w xY wd S r`   )r   __mro__rU   r   )r  mros     rC   	get_slotsr    sk      $$  	}$$$$$$$$ 	 	 	H	 s   (
55c                    | j         |                                 } t          j                            t          j        j                  }t          | |z
                                  d          S rL   )tzinfo
astimezoner   r  r  r  maxr  )r  r  s     rC   compute_timedeltar    sS    	y]]__



 1 5
6
6CS''))1---rF   whenresultc                
   K   d S r`   r<   )r  r  s     rC   r/   r/     s      @CrF   c                
   K   d S r`   r<   )r  s    rC   r/   r/     s      8;rF   c                Z   K   t          |           }t          j        ||           d{V S )a  |coro|

    Sleep until a specified time.

    If the time supplied is in the past this function will yield instantly.

    .. versionadded:: 1.3

    Parameters
    -----------
    when: :class:`datetime.datetime`
        The timestamp in which to sleep until. If the datetime is naive then
        it is assumed to be local time.
    result: Any
        If provided is returned to the caller when the coroutine completes.
    N)r  r  sleep)r  r  deltas      rC   r/   r/     s9      " d##Euf---------rF   c                 ^    t           j                             t           j        j                  S )aq  A helper function to return an aware UTC datetime representing the current time.

    This should be preferred to :meth:`datetime.datetime.utcnow` since it is an aware
    datetime, compared to the naive datetime in the standard library.

    .. versionadded:: 2.0

    Returns
    --------
    :class:`datetime.datetime`
        The current aware datetime in UTC.
    )r   r  r  r  r<   rF   rC   r0   r0     s!       !2!6777rF   sizec                4    | | dz
  z   od| cxk    odk    nc S )z+Icons must be power of 2 within [16, 4096].rl   i      r<   )r  s    rC   valid_icon_sizer  !  s5    tax  7TT%7%7%7%7R%7%7%7%77rF   c                  N    e Zd ZdZdZerdddd	ZddddZddZddZ	ddZ
dS )SnowflakeLista'  Internal data storage class to efficiently store a list of snowflakes.

    This should have the following characteristics:

    - Low memory usage
    - O(n) iteration (obviously)
    - O(n log n) initial creation if data is unsorted
    - O(log n) search and indexing
    - O(n) insertion
    r<   F)	is_sortedrw   Iterable[int]r  r>   c                   d S r`   r<   )rA   rw   r  s      rC   r^   zSnowflakeList.__init__6  r}   rF   r=   rj   c               f    t           j                             | d|r|nt          |                    S )NQ)array__new__r   )r  rw   r  s      rC   r  zSnowflakeList.__new__8  s+    {""3Y-PTTF4LLQQQrF   r%  rJ   rX   c                R    t          | |          }|                     ||           d S r`   )r"   insertrA   r%  is      rC   addzSnowflakeList.add;  s+    g&&AwrF   r]  c                t    t          | |          }|t          |           k    r| |         |k    r| |         nd S r`   r"   r   r  s      rC   r.   zSnowflakeList.get?  s;    g&&s4yy..T!W-?-?tAwwTIrF   c                `    t          | |          }|t          |           k    o| |         |k    S r`   r  r  s      rC   haszSnowflakeList.hasC  s/    g&&CII~4$q'W"44rF   N)rw   r  r  r>   )rw   r  r  r>   r=   rj   )r%  rJ   r=   rX   )r%  rJ   r=   r]  )r%  rJ   r=   r>   )rR   rS   rT   r[   rU   r   r^   r  r  r.   r  r<   rF   rC   r  r  &  s        	 	 I QEJPPPPPP?D R R R R R R       J J J J5 5 5 5 5 5rF   r  stringc                    |                                  rt          |           S dt          j        t	          fd| D                       S )zReturns string's width.WFAc              3  :   K   | ]} |          v rd ndV  dS )r   rl   Nr<   )r4  charUNICODE_WIDE_CHAR_TYPEr   s     rC   r8  z _string_width.<locals>.<genexpr>O  s:      SSDDDJJ"888qqaSSSSSSrF   )isasciir   unicodedataeast_asian_widthsum)r  r  r   s    @@rC   _string_widthr  H  sV    ~~ 6{{"'DSSSSSFSSSSSSrF   c                  $    e Zd ZU ded<   ded<   dS )ResolvedInviteru   coder]  eventN)rR   rS   rT   r   r<   rF   rC   r  r  R  s'         IIIrF   r  inviteUnion[Invite, str]c                   ddl m} t          | |          rt          | j        | j                  S d}t          j        ||           }|r\t          j	        |           }|j
        d         }|j                            d          }t          ||rt          |          nd          S d}t          j        ||           st          d          t          | d          S )	a;  Resolves an invite from a :class:`~discord.Invite`, URL or code.

    .. versionchanged:: 2.0
        Now returns a :class:`.ResolvedInvite` instead of a
        :class:`str`.

    Parameters
    -----------
    invite: Union[:class:`~discord.Invite`, :class:`str`]
        The invite.

    Raises
    -------
    ValueError
        The invite is not a valid Discord invite, e.g. is not a URL
        or does not contain alphanumeric characters.

    Returns
    --------
    :class:`.ResolvedInvite`
        A data class containing the invite code and the event ID.
    rl   ro   z=(?:https?\:\/\/)?discord(?:\.gg|(?:app)?\.com\/invite)\/[^/]+r  Nz[a-zA-Z0-9\-_]+z/Invite contains characters that are not allowed)r  rp   
isinstancer  r  scheduled_event_idrematchyarlURLpartsqueryr.   rJ   	fullmatchri  )r  rp   rxmr  r  event_idallowed_characterss           rC   resolve_inviter  W  s    . &&!! ,fk6+DEEEMHR   	M(6""C9R=Dy}}W--H!$(KHtLLL/|.77 	PNOOOfd+++rF   r  Union[Template, str]c                    ddl m} t          | |          r| j        S d}t	          j        ||           }|r|                    d          S | S )a  
    Resolves a template code from a :class:`~discord.Template`, URL or code.

    .. versionadded:: 1.4

    Parameters
    -----------
    code: Union[:class:`~discord.Template`, :class:`str`]
        The code.

    Returns
    --------
    :class:`str`
        The template code.
    rl   rq   z?(?:https?\:\/\/)?discord(?:\.new|(?:app)?\.com\/template)\/(.+))templaterr   r  r  r  r  group)r  rr   r  r  s       rC   resolve_templater    sc      #"""""$!! yOHR 	771::KrF   |c              #  @   K   | ]}d                      |          V  dS )z \{0}(?=([\s\S]*((?<!\{0})\{0})))N)r   )r4  cs     rC   r8  r8    s3      $v$vWX%H%O%OPQ%R%R$v$v$v$v$v$vrF   )*`_~r  z&^>(?:>>)?\s|\[.+\]\(.+\)|^#{1,3}|^\s*-z(?P<markdown>r   zH(?P<url><[^: >]+:\/[^ >]+>|(?:https?|steam):\/\/[^\s<]+[^<.,:;\"\'\]\s])z(?P<markdown>[_\\~|\*`]|)ignore_linkstextr  c               |    d
d}t           }|rdt           d| d}t          j        ||| d	t          j                  S )a  A helper function that removes markdown characters.

    .. versionadded:: 1.7

    .. note::
            This function is not markdown aware and may remove meaning from the original text. For example,
            if the input contains ``10 * 5`` then it will be converted into ``10  5``.

    Parameters
    -----------
    text: :class:`str`
        The text to remove markdown from.
    ignore_links: :class:`bool`
        Whether to leave links alone when removing markdown. For example,
        if a URL in the text contains characters such as ``_`` then it will
        be left alone. Defaults to ``True``.

    Returns
    --------
    :class:`str`
        The text with the markdown special characters removed.
    r  re.Match[str]r=   ru   c                V    |                                  }|                    dd          S )Nr   	groupdictr.   )r  r  s     rC   replacementz$remove_markdown.<locals>.replacement  s%    OO%%	}}UB'''rF   (?:r  r   r   )r  r	  r=   ru   )_MARKDOWN_STOCK_REGEX
_URL_REGEXr  sub	MULTILINE)r  r  r  regexs       rC   r1   r1     sW    0( ( ( ( "E ,+j++5+++6%dAr|<<<rF   )	as_neededr  r  c                   |s<d }t           }|rdt           d| d}t          j        ||| dt          j                  S t          j        dd|           } t
                              d|           S )	a  A helper function that escapes Discord's markdown.

    Parameters
    -----------
    text: :class:`str`
        The text to escape markdown from.
    as_needed: :class:`bool`
        Whether to escape the markdown characters as needed. This
        means that it does not escape extraneous characters if it's
        not necessary, e.g. ``**hello**`` is escaped into ``\*\*hello**``
        instead of ``\*\*hello\*\*``. Note however that this can open
        you up to some clever syntax abuse. Defaults to ``False``.
    ignore_links: :class:`bool`
        Whether to leave links alone when escaping markdown. For example,
        if a URL in the text contains characters such as ``_`` then it will
        be left alone. This option is not supported with ``as_needed``.
        Defaults to ``True``.

    Returns
    --------
    :class:`str`
        The text with the markdown special characters escaped with a slash.
    c                r    |                                  }|                    d          }|r|S d|d         z   S )Nr  \markdownr  )r  r  is_urls      rC   r  z$escape_markdown.<locals>.replacement  s?    ))I]]5))F )J///rF   r  r  r   r   z\\z\\\\z\\\1)r  r  r  r  r  _MARKDOWN_ESCAPE_REGEX)r  r  r  r  r  s        rC   r2   r2     s    2  9	0 	0 	0 & 	0/*//u///Eve[$2<@@@veWd++%))'4888rF   c                .    t          j        dd|           S )a  A helper function that escapes everyone, here, role, and user mentions.

    .. note::

        This does not include channel mentions.

    .. note::

        For more granular control over what mentions should be escaped
        within messages, refer to the :class:`~discord.AllowedMentions`
        class.

    Parameters
    -----------
    text: :class:`str`
        The text to escape mentions from.

    Returns
    --------
    :class:`str`
        The text with the mentions removed.
    z"@(everyone|here|[!&]?[0-9]{17,20})u   @​\1)r  r  r  s    rC   r3   r3     s    . 67tLLLrF   iteratormax_sizeIterator[List[T]]c              #  .  K   t          | t          j        j                  r?t	          dt          |           |          D ]}t          | |||z                      V  d S t          |           } 	 t          t          | |                    }|sd S |V  &rL   )	r  collectionsabcr   ranger   r   r   r   )r  r  r  batchs       rC   _chunkr&    s      (KO455 
q#h--22 	3 	3AxAL 01222222	3 	3 >>	(3344E KKK		rF   AsyncIterator[List[T]]c                  K   g }d}| 2 3 d {V }|                     |           |dz  }||k    r	|W V  g }d}16 |r|W V  d S d S )Nr   rl   )append)r  r  retnr   s        rC   _achunkr,  !  s      
C	A       d

4	Q==IIIICA   						 s   :c                    d S r`   r<   r  r  s     rC   r5   r5   /  s    TWTWrF   c                    d S r`   r<   r.  s     rC   r5   r5   3  s    JM#rF   _Iter[List[T]]c                    |dk    rt          d          t          | t                    rt          | |          S t	          | |          S )a;  A helper function that collects an iterator into chunks of a given size.

    .. versionadded:: 2.0

    Parameters
    ----------
    iterator: Union[:class:`collections.abc.Iterable`, :class:`collections.abc.AsyncIterable`]
        The iterator to chunk, can be sync or async.
    max_size: :class:`int`
        The maximum chunk size.


    .. warning::

        The last chunk collected may not be as large as ``max_size``.

    Returns
    --------
    Union[:class:`Iterator`, :class:`AsyncIterator`]
        A new iterator which yields chunks of a given size.
    r   z#Chunk sizes must be greater than 0.)ri  r  r   r,  r&  r.  s     rC   r5   r5   7  sN    , 1}}>???(M** +x***(H%%%rF   )rb  rd  )rb  rf  
parametersIterable[Any]Tuple[Any, ...]c                    g }t          t          d                   }| D ]B}t          ||          r|                    |j                   -|                    |           Ct          |          S rL   )typer   r  extend__args__r)  tuple)r2  paramsliteral_clsps       rC   flatten_literal_paramsr=  Y  sq    Fwqz""K  a%% 	MM!*%%%%MM!==rF   c                `    t          d           t          fd| D                       fz   S )Nc              3  $   K   | ]
}|u|V  d S r`   r<   )r4  r<  none_clss     rC   r8  z,normalise_optional_params.<locals>.<genexpr>f  s-      <<q!8*;*;*;*;*;*;<<rF   )r6  r9  )r2  r@  s    @rC   normalise_optional_paramsrA  d  s8    DzzH<<<<J<<<<<{JJrF   implicit_strtpglobalsDict[str, Any]localscacherC  c                  t          | t                    r	| j        } drIt          | t                    r4| v r|          S t	          t          |                     }|| <   |S t          rt          | j        dd           t          j
        u ret          di d | j        D             }t	          | j        |                                          }t          | d          r|| j                 }|S t          | d          rt	          | j                  S t          | d          r| j        d         }t	          |          S t          | d          rhdd}	| j        }
t          | d	          s;t&          r2| j        t*          j        u rt.          |
         }t	          |          S | S | j        t.          u r\	 |
                    t5          d                     t7          |
          d
z
  k    rt9          | j                  }
n# t:          $ r Y nw xY w| j        t<          u rt&          st?          | j                  }
dd}	tA          fd|
D                       }|	r(tC          d |D                       stE          d          	 | #                    |          S # tH          $ r | j        |         cY S w xY w| S )NT__objclass__c                    i | ]
}|j         |S r<   )rR   )r4  ts     rC   
<dictcomp>z'evaluate_annotation.<locals>.<dictcomp>~  s    'R'R'R!
A'R'R'RrF   r8  __supertype____metadata__r   F
__origin__rl   c              3  @   K   | ]}t          |           V  dS )rB  N)evaluate_annotation)r4  argrH  rE  rC  rG  s     rC   r8  z&evaluate_annotation.<locals>.<genexpr>  s9      {{or23]ijjj{{{{{{rF   c           
   3  v   K   | ]4}t          |t          t          t          t	          d           f          V  5d S r`   )r  ru   rJ   r>   r6  rW  s     rC   r8  z&evaluate_annotation.<locals>.<genexpr>  s<      !f!fRS*Qc4d0L"M"M!f!f!f!f!f!frF   z>Literal arguments must be of type str, int, bool, or NoneType.r<   )%r  r   __forward_arg__ru   rR  evalPY_312r]   rO   typingTypeAliasTyperY  __type_params__	__value__copyr.  r8  rN  rO  PY_310	__class__types	UnionTyper   rP  r   r6  r   rA  ri  r   r=  r9  rE  	TypeError	copy_withr   )rD  rE  rG  rH  rC  	evaluatedtemp_locals
annotationmetadata
is_literalr   rJ  evaluated_argss    ````        rC   rR  rR  i  s"    "j!!  
2s++ ;;9'R&(A(A7FTYZZ	b	 '"+~t<<@TTTSSVS'R'Rr?Q'R'R'RSS(wUZZ\\ZZ
2z"" 	1#BK0Jr?## M"2#3WfeLLLr>"" E?1%"8WfeDDDr: 1
{r<(( 	 N",%/99!$K	*9gvuMMMI=E!!::d4jj))SYY]::4R[AAD   =G## ;-bk:: LJ{{{{{{{vz{{{{{ 	^c!f!fWe!f!f!fff 	^\]]]	1<</// 	1 	1 	1=0000	1 Is%   A
H 
H H J. .KKre  globalnslocalnsOptional[Dict[str, Any]]c                    | t          d           S t          | t                    rt          |           } ||n|}|i }t	          | |||          S r`   )r6  r  ru   r   rR  )re  ri  rj  rH  rG  s        rC   resolve_annotationrm    s`     Dzz*c"" ,
++
 XXgF}z8VUCCCrF   r   c                    | j         | j        k    rdS | j                             d          \  }}}|                    d           S )NFr2  z<locals>)rT   rR   
rpartitionendswith)r   	remainingr  s      rC   is_inside_classrr    sM     DM))u)44S99Y1!!*----rF   )	r  FdDrL  r   sSRstyleOptional[TimestampStyle]c                   |%dt          |                                            dS dt          |                                            d| dS )a  A helper function to format a :class:`datetime.datetime` for presentation within Discord.

    This allows for a locale-independent way of presenting data using Discord specific Markdown.

    +-------------+--------------------------------+-------------------------+
    |    Style    |        Example Output          |       Description       |
    +=============+================================+=========================+
    | t           | 22:57                          | Short Time              |
    +-------------+--------------------------------+-------------------------+
    | T           | 22:57:58                       | Medium Time             |
    +-------------+--------------------------------+-------------------------+
    | d           | 17/05/2016                     | Short Date              |
    +-------------+--------------------------------+-------------------------+
    | D           | May 17, 2016                   | Long Date               |
    +-------------+--------------------------------+-------------------------+
    | f (default) | May 17, 2016 at 22:57          | Long Date, Short Time   |
    +-------------+--------------------------------+-------------------------+
    | F           | Tuesday, May 17, 2016 at 22:57 | Full Date, Short Time   |
    +-------------+--------------------------------+-------------------------+
    | s           | 17/05/2016, 22:57              | Short Date, Short Time  |
    +-------------+--------------------------------+-------------------------+
    | S           | 17/05/2016, 22:57:58           | Short Date, Medium Time |
    +-------------+--------------------------------+-------------------------+
    | R           | 5 years ago                    | Relative Time           |
    +-------------+--------------------------------+-------------------------+

    Note that the exact output depends on the user's locale setting in the client. The example output
    presented is using the ``en-GB`` locale.

    .. versionadded:: 2.0

    Parameters
    -----------
    dt: :class:`datetime.datetime`
        The datetime to format.
    style: :class:`str`
        The style to format the datetime with.

    Returns
    --------
    :class:`str`
        The formatted string.
    Nz<t:>r  )rJ   r   )r  ry  s     rC   r6   r6     sT    X }+S((++++/R\\^^$$//u////rF   c                     d} t           j                            d          pDt           j                            |           o%t	          d t          |           D                       S )Nz/proc/self/cgroupz/.dockerenvc              3     K   | ]}d |v V  	dS )dockerNr<   )r4  lines     rC   r8  zis_docker.<locals>.<genexpr>  s)      IrIr_c(VZJZIrIrIrIrIrIrrF   )ospathexistsisfileanyopen)r  s    rC   	is_dockerr    sT    D7>>-((sRW^^D-A-A-rcIrIrgklpgqgqIrIrIrFrFrsrF   streamc                ,   t          | d          o|                                 }dt          j        v s#t          j                            d          dk    r|S t
          j        dk    r|pt                      S |odt          j        v pdt          j        v S )NisattyPYCHARM_HOSTEDTERM_PROGRAMvscodewin32ANSICON
WT_SESSION)r.  r  r  environr.   sysplatformr  )r  is_a_ttys     rC   stream_supports_colourr    s    vx((<V]]__H 2:%%)G)G8)S)S
|w&9;;& Obj0NLBJ4NOrF   c                      e Zd Zej        dfej        dfej        dfej        dfej        dfgZ	d e	D             Z
d ZdS )	_ColourFormatterz[40;1mz[34;1mz[33;1m[31mz[41mc                H    i | ]\  }}|t          j        d | dd           S )z[30;1m%(asctime)s[0m z1%(levelname)-8s[0m [35m%(name)s[0m %(message)s%Y-%m-%d %H:%M:%S)logging	Formatter)r4  levelcolours      rC   rM  z_ColourFormatter.<dictcomp>*  sN       
 E6	 	w nFnnn
 
  rF   c                   | j                             |j                  }|| j         t          j                 }|j        r%|                    |j                  }d| d|_        |                    |          }d |_        |S )Nr  z[0m)	FORMATSr.   levelnor  DEBUGexc_infoformatExceptionexc_textr   )rA   record	formatterr  outputs        rC   r   z_ColourFormatter.format2  s    L$$V^44	W]3I ? 	7,,V_==D6666FO!!&)) rF   N)rR   rS   rT   r  r  INFOWARNINGERRORCRITICALLEVEL_COLOURSr  r   r<   rF   rC   r  r    s         
%	|$	,'	
#		:&M 
 +  G    rF   r  )handlerr  r  rootr  logging.Handlerr  logging.Formatterr  r  c                4   |t           u rt          j        }| t           u rt          j                    } |t           u rVt	          | t          j                  r#t          | j                  rt                      }nd}t          j        d|d          }|rt          j	                    }n2t                              d          \  }}}t          j	        |          }|                     |           |                    |           |                    |            dS )aU  A helper function to setup logging.

    This is superficially similar to :func:`logging.basicConfig` but
    uses different defaults and a colour formatter if the stream can
    display colour.

    This is used by the :class:`~discord.Client` to set up logging
    if ``log_handler`` is not ``None``.

    .. versionadded:: 2.0

    Parameters
    -----------
    handler: :class:`logging.Handler`
        The log handler to use for the library's logger.

        The default log handler if not provided is :class:`logging.StreamHandler`.
    formatter: :class:`logging.Formatter`
        The formatter to use with the given log handler. If not provided then it
        defaults to a colour based logging formatter (if available). If colour
        is not available then a simple logging formatter is provided.
    level: :class:`int`
        The default log level for the library's logger. Defaults to ``logging.INFO``.
    root: :class:`bool`
        Whether to set up the root logger rather than the library logger.
        Unlike the default for :class:`~discord.Client`, this defaults to ``True``.
    r  z.[{asctime}] [{levelname:<8}] {name}: {message}{)ry  r2  N)r7   r  r  StreamHandlerr  r  r  r  r  	getLoggerrR   	partitionsetFormattersetLevel
addHandler)r  r  r  r  dt_fmtloggerlibraryr  s           rC   r8   r8   C  s   F ''))Ggw455 	o:PQXQ_:`:` 	o(**II(F)*Z\bjmnnnI ,"$$ **3//A"7++###
OOE
grF   d   u   …)width	max_linesreplace_whitespaceplaceholder)_wrapperinputr  r   c                   	 t          j        d| d          \  } }n# t          $ r Y nw xY w|                    d                    |                                                                                     S )Nz\n\s*\nrl   )maxsplit )r  splitri  fillr  strip)r  r  r  s      rC   _shortenr  ~  su    
8J:::qq   ==%++--"5"5"7"788999s    
**z(?<!^)(?=[A-Z])c                \    t                               d|                                           S )N-)CAMEL_CASE_REGEXr  lowerr  s    rC   _to_kebab_caser    s$    T**00222rF   z, or)	delimiterfinalseqSequence[str]r  r  c                  t          |           }|dk    rdS |dk    r| d         S |dk    r| d          d| d| d          S |                    | d d                   d| d| d          z   S )Nr   r  rl   r   r  r  )r   r  )r  r  r  r  s       rC   _human_joinr    s    s88Dqyyrqyy1vqyya&++5++3q6+++>>#crc(##&;%&;&;#b'&;&;;;rF   c                  2    e Zd ZU dZdZded<   ddZddZdS )_ZstdDecompressionContext)decompressorzzstd-streamru   rv   r=   rX   c                    t                      | _        t          dk    r | j                                        | _        d S d S )Nr)   )r(   r  r'   decompressobjrH   s    rC   r^   z"_ZstdDecompressionContext.__init__  sB     0 2 2D{**
 %)$5$C$C$E$E!!! +*rF   rw   rx   ry   c               \    | j                             |                              d          S r~  )r  r|   rr  r{   s     rC   r|   z$_ZstdDecompressionContext.decompress  s'    $//55<<WEEErF   Nrg   r~   rR   rS   rT   rU   rv   r   r^   r|   r<   rF   rC   r  r    s_         %	 -----	F 	F 	F 	F	F 	F 	F 	F 	F 	FrF   r  zType[_DecompressionContext]_ActiveDecompressionContextc                  2    e Zd ZU dZdZded<   ddZddZdS )_ZlibDecompressionContext)contextbufferzzlib-streamru   rv   r=   rX   c                \    t                      | _        t          j                    | _        d S r`   )	bytearrayr  zlibr  r  rH   s    rC   r^   z"_ZlibDecompressionContext.__init__  s!    %.[[DK-//DLLLrF   rw   rx   ry   c               
   | j                             |           t          |          dk     s|dd          dk    rd S | j                            | j                   }t                      | _         |                    d          S )N   s     r  )r  r7  r   r  r|   r  rr  )rA   rw   msgs      rC   r|   z$_ZlibDecompressionContext.decompress  su    Kt$$$ 4yy1}}RSS	-@ @ @,))$+66C#++DK::g&&&rF   Nrg   r~   r  r<   rF   rC   r  r    sU         )	 -----	0 	0 	0 	0
	' 
	' 
	' 
	' 
	' 
	'rF   r  durationdatetime.timedeltac                   |                                  }d}|dz  }|dz  }|dz  }|dz  }d}d}d}	d}
d}||k     rd	}n|||z  k     r!t          ||z            }|d
k    rd}n| d}n||	|z  k     r!t          ||z            }|d
k    rd}nz| d}nt||
|z  k     r!t          ||z            }|d
k    rd}nP| d}nJ|||z  k     r!t          ||z            }|d
k    rd}n&| d}n t          ||z            }|d
k    rd}n| d}|S )N<      g     p>@rf  -   g     5@g     9@g      %@za few secondsrl   za minutez minuteszan hourz hoursza dayz daysza monthz monthsza yearz years)r  round)r  seconds	minutes_shours_sdays_smonths_syears_sthreshold_sthreshold_mthreshold_hthreshold_dthreshold_M	formattedminuteshoursdaysmonthsyearss                     rC   _format_call_durationr    s   $$&&GI"nGr\FHmGKKKKK#			K)+	,	,)+,,a<<"II",,,II	K')	*	*g'((A::!II (((II	K&(	)	)Wv%&&199IIII	K(*	+	+w)**Q;;!II!***IIg'((A:: II (((IrF   c                  &    e Zd ZU dZded<   ddZdS )	_RawReprMixinr<   zTuple[str, ...]rU   r=   ru   c                v     d                      fd j        D                       }d j        j         d| dS )Nr  c              3  B   K   | ]}| d t          |          V  dS )=N)r]   )r4  r>  rA   s     rC   r8  z)_RawReprMixin.__repr__.<locals>.<genexpr>  s;      VVtD::74#6#6::VVVVVVrF   <r|  )r  rU   r^  rR   r   s   ` rC   rO   z_RawReprMixin.__repr__  sI    VVVVt~VVVVV54>*55U5555rF   Nr   )rR   rS   rT   rU   r   rO   r<   rF   rC   r  r    s;         !#I####6 6 6 6 6 6rF   r  )r   ru   r=   r   )r   rX   r=   rX   )r   ru   r=   r   )r   r   r=   r   )r   r   r=   r   r`   )r   r   r=   r   )r  r  r   rm   r   rn   r   ru   r  r  r  r>   r  ru   r=   ru   )r  rJ   r=   r   )r  r   r  r>   r=   rJ   )r  r  r  r  r=   r   )r  r  r  r#  r=   r   )r  r  r  r#  r=   r'  )r  r  r  r*  r=   r+  )r  r  r/  r   r=   r   )r  r#  r/  r   r=   r   )r  r#  r/  r   r=   r'  )r  r*  r/  r   r=   r+  )r  r  r=   rT  )rw   r   r\  ru   r=   r]  )rw   rx   )rw   rx   rn  r>   r=   ru   )rw   ru   r=   rx   )rx  ru   ry  ru   r=   r>   )r|  r   r=   ru   )r  r   r  r>   r=   r  )r  r  r   r   r   r   r=   r   )r  r  r  r  r=   r>   )r  r  r  r  r=   r  )r  r   r=   r  )r  r   r=   r  )r  r   r  r   r=   r   )r  r   r=   rX   )r  r   r  r   r=   r   )r=   r   )r  rJ   r=   r>   )r  ru   r=   rJ   )r  r  r=   r  )r  r  r=   ru   )r  ru   r  r>   r=   ru   )r  ru   r  r>   r  r>   r=   ru   )r  ru   r=   ru   )r  r  r  rJ   r=   r   )r  r#  r  rJ   r=   r'  )r  r*  r  rJ   r=   r0  )r2  r3  r=   r4  )rD  r   rE  rF  rG  rF  rH  rF  rC  r>   r=   r   )
re  r   ri  rF  rj  rk  rH  rk  r=   r   )r   r   r=   r>   )ry  rz  r  r   r=   ru   rP   )r  r   r=   r>   )
r  r  r  r  r  rJ   r  r>   r=   rX   )r  ru   r  r   r=   ru   )r  r  r  ru   r  ru   r=   ru   )r  r  r=   ru   )r[   
__future__r   r  r  textwrapr   rX  r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  collections.abcr"  	itertoolsr   base64r    r!   bisectr"   r   r   inspectr#   r  r$   r   operatorr%   urllib.parser&   r  r  r  r  r_  r   r  r  r  
HAS_ORJSONModuleNotFoundErrorr'   r   r)   r(   ImportErrorcompression.zstdr  __all__r  DEFAULT_FILE_SIZE_LIMIT_BYTEScompiler9   r;   r7   rW   rh   typing_extensionsri   rj   rk   r   rm   r#  rn   r  rp   r  rr   rt   r   MaybeAwaitableFuncrJ   _SnowflakeListBaser   r   _IterCoroMaybeAwaitabler   r   r   r   r   r   r   r*   r+   r,   r"  r&  r-   rK  rO  r.   r[  r`  rk  rm  rt  rw  r{  r  loads
_from_jsonr  r4   r  r  r  r  r/   r0   r  r  r  r  r  r  r  _MARKDOWN_ESCAPE_SUBREGEX_MARKDOWN_ESCAPE_COMMONr  r  r  r  r1   r2   r3   r&  r,  r5   version_infor]  rW  r=  rA  rR  rm  rr  TimestampStyler6   r  r  r  r  r8   r  r  r  r  r  r  r  r  r  r<   rF   rC   <module>r%     s    0 # " " " " "                                                                     8               ' ' ' ' ' ' ' '            H H H H H H H H       " " " " " "  				 				 



     MMM JJ    JJJ
 AE D D D D
******LL   555555)   $  ( %/RZ0O%P%P  P P P P          !! ! ! ! !         %<<<<<<<<<<<<<<<<((((((""""""@ @ @ @ @ @ @ @
 		#A!!%8"89S) 'O GCLLwv&&&hqk=++,c1q)A,'    D)   05 5 5 5 5GDM 5 5 5   ,* ,* ,* ,* ,*HTN ,* ,* ,*^ 
 , , , 
 , 
 8 8 8 
 8 
 L L L 
 L          ,  '&-!&< < < < < <~P P P P( >C ? ? ? ? ? ?<3 3 3 3    
 ` ` ` 
 ` 
 U U U 
 U! ! ! !H   $   , 
 N N N 
 N 
 C C C 
 C? ? ? ?D0 0 0 0$ $ $ $
9 
9 
9 
99 9 9 9 9> + + + + + ++ + + += = = =  1 1 1 1 JJI I I I J @E " " " " " "   F JV
 
 
 
 
 
      . . . . 
 C C C 
 C 
 ; ; ; 
 ;. . . . .*8 8 8 8 8 8 8 8
5 5 5 5 5& 5 5 5DT T T T    Z   
*, *, *, *,Z   8  HH$v$v\u$v$v$vvv C #$k5N$k$kQh$k$k$kmomyzz X
N4KNNN  8< = = = = = =D 5:PT (9 (9 (9 (9 (9 (9VM M M M4       
 W W W 
 W 
 M M M 
 M& & & &< 
	W	$		W	$   K K K K C C C C C CLD D D D". . . . DE.0 .0 .0 .0 .0bt t t t
P P P P ( ( ( ( (w( ( ( (Z  '#*8 8 8 8 8 8| (KcQSWejkkk
: 
: 
: 
: 
: 
: 2:011 3 3 3 3 <@d < < < < < < F F F F F F F F$ @YXXXXX' ' ' ' ' ' ' '* @YXXXX1 1 1 1h6 6 6 6 6 6 6 6 6 6sH   -B4 4B>=B>	C C3C! C3!	C-*C3,C--C32C3