a
    õ£BeS	  ã                   @  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   ú^/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/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  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   )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    ÿ-