
    i                        d Z ddlmZ ddlmZmZmZmZmZm	Z	 ddl
mZ ddlmZ ddlmZ dd	lmZ dd
lmZmZmZ erddlmZ ddlmZ  eddd          ZdZ G d dee                   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ListLiteralOptionalTypeVarUnion   )Item   )ComponentType)MISSING)File)MediaGalleryItemMediaGalleryComponentUnfurledMediaItem)Self)
LayoutViewVr   T)bound	covariant)MediaGalleryc                  6    e Zd ZdZdZddd, fdZd-dZed.d            Zej	        d/d            Zed0d            Z
e
j	        d1d            Z
d Zd2dZeedd3dZd4d Zeedd5d#Zd4d$Zd6d%Zed7d'            Zed(             Zed8d+            Z xZS )9r   a  Represents a UI media gallery.

    Can contain up to 10 :class:`.MediaGalleryItem`\s.

    This is a top-level layout component that can only be used on :class:`LayoutView`.

    .. versionadded:: 2.6

    Parameters
    ----------
    \*items: :class:`.MediaGalleryItem`
        The initial items of this gallery.
    id: Optional[:class:`int`]
        The ID of this component. This must be unique across the view.
    itemsidN)r   r   r   r   Optional[int]returnNonec                   t                                                       t          j        t	          |          |          | _        d S )Nr   )super__init__r   _raw_constructlist_underlying)selfr   r   	__class__s      Y/usr/local/lib/hermes-agent/venv/lib/python3.11/site-packages/discord/ui/media_gallery.pyr"   zMediaGallery.__init__G   sG    
 	0?u++
 
 
    strc                V    d| j         j         dt          | j        j                   dS )N<z items=>)r'   __name__lenr%   r   r&   s    r(   __repr__zMediaGallery.__repr__S   s.    Q4>*QQ3t7G7M3N3NQQQQr)   List[MediaGalleryItem]c                >    | j         j                                        S )zSList[:class:`.MediaGalleryItem`]: Returns a read-only list of this gallery's items.)r%   r   copyr0   s    r(   r   zMediaGallery.itemsV   s     %**,,,r)   valuec                b    t          |          dk    rt          d          || j        _        d S )N
   z)media gallery only accepts up to 10 items)r/   
ValueErrorr%   r   r&   r5   s     r(   r   zMediaGallery.items[   s1    u::??HIII!&r)   c                    | j         j        S )z1Optional[:class:`int`]: The ID of this component.r%   r   r0   s    r(   r   zMediaGallery.idb   s     ""r)   c                    || j         _        d S Nr;   r9   s     r(   r   zMediaGallery.idg   s    #r)   c                4    | j                                         S r=   )r%   to_dictr0   s    r(   to_component_dictzMediaGallery.to_component_dictk   s    '')))r)   boolc                    dS )NT r0   s    r(   _is_v2zMediaGallery._is_v2n   s    tr)   descriptionspoilermedia#Union[str, File, UnfurledMediaItem]rF   Optional[str]rG   r   c                   t          | j        j                  dk    rt          d          t	          |||          }| j        j                            |           | S )ai  Adds an item to this gallery.

        This function returns the class instance to allow for fluent-style
        chaining.

        Parameters
        ----------
        media: Union[:class:`str`, :class:`discord.File`, :class:`.UnfurledMediaItem`]
            The media item data. This can be a string representing a local
            file uploaded as an attachment in the message, which can be accessed
            using the ``attachment://<filename>`` format, or an arbitrary url.
        description: Optional[:class:`str`]
            The description to show within this item. Up to 256 characters. Defaults
            to ``None``.
        spoiler: :class:`bool`
            Whether this item should be flagged as a spoiler. Defaults to ``False``.

        Raises
        ------
        ValueError
            Maximum number of items has been exceeded (10).
        r7   )maximum number of items has been exceededrE   )r/   r%   r   r8   r   append)r&   rH   rF   rG   items        r(   add_itemzMediaGallery.add_itemq   s_    < t%&&",,HIII;PPP%%d+++r)   rN   c                    t          | j        j                  dk    rt          d          t	          |t
                    st          d|j        j                  | j        j        	                    |           | S )a  Appends an item to this gallery.

        This function returns the class instance to allow for fluent-style
        chaining.

        Parameters
        ----------
        item: :class:`.MediaGalleryItem`
            The item to add to the gallery.

        Raises
        ------
        TypeError
            A :class:`.MediaGalleryItem` was not passed.
        ValueError
            Maximum number of items has been exceeded (10).
        r7   rL   zexpected MediaGalleryItem, not )
r/   r%   r   r8   
isinstancer   	TypeErrorr'   r.   rM   r&   rN   s     r(   append_itemzMediaGallery.append_item   s{    & t%&&",,HIII$ 011 	[Ydn>UYYZZZ%%d+++r)   indexintc                   t          | j        j                  dk    rt          d          t	          |||          }| j        j                            ||           | S )a  Inserts an item before a specified index to the media gallery.

        This function returns the class instance to allow for fluent-style
        chaining.

        Parameters
        ----------
        index: :class:`int`
            The index of where to insert the field.
        media: Union[:class:`str`, :class:`discord.File`, :class:`.UnfurledMediaItem`]
            The media item data. This can be a string representing a local
            file uploaded as an attachment in the message, which can be accessed
            using the ``attachment://<filename>`` format, or an arbitrary url.
        description: Optional[:class:`str`]
            The description to show within this item. Up to 256 characters. Defaults
            to ``None``.
        spoiler: :class:`bool`
            Whether this item should be flagged as a spoiler. Defaults to ``False``.

        Raises
        ------
        ValueError
            Maximum number of items has been exceeded (10).
        r7   rL   rE   )r/   r%   r   r8   r   insert)r&   rU   rH   rF   rG   rN   s         r(   insert_item_atzMediaGallery.insert_item_at   sm    B t%&&",,HIII#
 
 

 	%%eT222r)   c                h    	 | j         j                            |           n# t          $ r Y nw xY w| S )a	  Removes an item from the gallery.

        This function returns the class instance to allow for fluent-style
        chaining.

        Parameters
        ----------
        item: :class:`.MediaGalleryItem`
            The item to remove from the gallery.
        )r%   r   remover8   rS   s     r(   remove_itemzMediaGallery.remove_item   sI    	"))$//// 	 	 	D	s   " 
//c                B    | j         j                                         | S )zRemoves all items from the gallery.

        This function returns the class instance to allow for fluent-style
        chaining.
        )r%   r   clearr0   s    r(   clear_itemszMediaGallery.clear_items   s!     	$$&&&r)   $Literal[ComponentType.media_gallery]c                    | j         j        S r=   )r%   typer0   s    r(   rb   zMediaGallery.type   s    $$r)   c                    dS )N   rC   r0   s    r(   widthzMediaGallery.width   s    qr)   	componentr   c                &     | |j         d|j        iS )Nr   r   )clsrf   s     r(   from_componentzMediaGallery.from_component  s%    s_
|
 
 	
r)   )r   r   r   r   r   r   )r   r*   )r   r2   )r5   r2   r   r   )r   r   )r5   r   r   r   )r   rA   )rH   rI   rF   rJ   rG   rA   r   r   )rN   r   r   r   )
rU   rV   rH   rI   rF   rJ   rG   rA   r   r   )r   r   )r   r`   )rf   r   r   r   )r.   
__module____qualname____doc____item_repr_attributes__r"   r1   propertyr   setterr   r@   rD   r   rO   rT   rY   r\   r_   rb   re   classmethodri   __classcell__)r'   s   @r(   r   r   1   s           !

 

 

 

 

 

 

 

R R R R - - - X- \' ' ' \' # # # X# Y$ $ $ Y$* * *    &-# # # # # #J   B &-* * * * * *X   $    % % % X%   X 
 
 
 [
 
 
 
 
r)   r   N)rl   
__future__r   typingr   r   r   r   r   r	   rN   r   enumsr   utilsr   filer   
componentsr   r   r   typing_extensionsr   viewr   r   __all__r   rC   r)   r(   <module>r{      sX   0 # " " " " " I I I I I I I I I I I I I I I I       ! ! ! ! ! !                       !&&&&&&      GC|t444
V
 V
 V
 V
 V
47 V
 V
 V
 V
 V
r)   