U
    oufS	                     @  s   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
 erHd dlmZ dgZede
dZG dd	 d	ee Zd
ddddZdS )    )annotations)TYPE_CHECKINGIterableListTypeVarcastoverload)OneStyleAndTextTuple)SupportsIndexexplode_text_fragments_T)boundc                      s   e Zd ZdZdZdddddZddd	 fd
dZddddddZeddddddZ	eddddddZ	ddd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.
    Tr   None)itemreturnc                 C  s   |  |g d S N)extend)selfr    r   ?/tmp/pip-unpacked-wheel-8milen2s/prompt_toolkit/layout/utils.pyappend   s    z_ExplodedList.appendIterable[_T])lstr   c                   s   t  t| d S r   )superr   r   )r   r   	__class__r   r   r      s    z_ExplodedList.extendr
   )indexr   r   c                 C  s   t d S r   )NotImplementedError)r   r   r   r   r   r   insert!   s    z_ExplodedList.insert)r   valuer   c                 C  s   d S r   r   r   r   r    r   r   r   __setitem__&   s    z_ExplodedList.__setitem__slicec                 C  s   d S r   r   r!   r   r   r   r"   *   s    zSupportsIndex | slicez_T | Iterable[_T]c                   sL   t |ts | }t||d }t |tr6td|g}t |t| dS )zl
        Ensure that when `(style_str, 'long string')` is set, the string will be
        exploded.
           zList[_T]N)
isinstancer#   	__index__tupler   r   r"   r   )r   r   r    Z	int_indexr   r   r   r"   .   s    

)__name__
__module____qualname____doc__explodedr   r   r   r   r"   __classcell__r   r   r   r   r      s   r   r   z_ExplodedList[_T])	fragmentsr   c                 C  sF   t | tr| S g }| D ]&^}}}|D ]}|||f| 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   )r.   resultstylestringrestcr   r   r   r   >   s    
N)
__future__r   typingr   r   r   r   r   r   Z"prompt_toolkit.formatted_text.baser	   Ztyping_extensionsr
   __all__r   r   r   r   r   r   r   <module>   s    -