o
    ip	                     @  s   d dl mZ d dlmZmZmZmZmZmZm	Z	 d dl
mZ er&d dlmZ dgZededZG dd	 d	ee ZdddZdS )    )annotations)TYPE_CHECKINGIterableListTypeVarUnioncastoverload)OneStyleAndTextTuple)SupportsIndexexplode_text_fragments_T)boundc                      sd   e Zd ZdZdZdddZd fddZdddZedddZ	edddZ	d fddZ	  Z
S )_ExplodedListz
    Wrapper around a list, that marks it as 'exploded'.

    As soon as items are added or the list is extended, the new items are
    automatically exploded as well.
    Titemr   returnNonec                 C  s   |  |g d S N)extend)selfr    r   V/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/prompt_toolkit/layout/utils.pyappend   s   z_ExplodedList.appendlstIterable[_T]c                   s   t  t| d S r   )superr   r   )r   r   	__class__r   r   r      s   z_ExplodedList.extendindexr   c                 C  s   t r   )NotImplementedError)r   r   r   r   r   r   insert!   s   z_ExplodedList.insertvaluec                 C     d S r   r   r   r   r!   r   r   r   __setitem__&      z_ExplodedList.__setitem__slicec                 C  r"   r   r   r#   r   r   r   r$   *   r%   SupportsIndex | slice_T | Iterable[_T]c                   sR   t |ts| }t||d }t |trtd|g}t |ttd| dS )zl
        Ensure that when `(style_str, 'long string')` is set, the string will be
        exploded.
           zList[_T]r   N)
isinstancer&   	__index__tupler   r   r$   r   )r   r   r!   	int_indexr   r   r   r$   .   s   

)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   )__name__
__module____qualname____doc__explodedr   r   r    r	   r$   __classcell__r   r   r   r   r      s    

r   	fragmentsr   r   _ExplodedList[_T]c                 C  sH   t | tr| S g }| D ]^}}}|D ]}|||g|R  qqt|S )a.  
    Turn a list of (style_str, text) tuples into another list where each string is
    exactly one character.

    It should be fine to call this function several times. Calling this on a
    list that is already exploded, is a null operation.

    :param fragments: List of (style, text) tuples.
    )r*   r   r   )r4   resultstylestringrestcr   r   r   r   >   s   
N)r4   r   r   r5   )
__future__r   typingr   r   r   r   r   r   r	   "prompt_toolkit.formatted_text.baser
   typing_extensionsr   __all__r   r   r   r   r   r   r   <module>   s    $-