a
    lc^	                     @   s   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ee ee d	d
dZdS )    )TYPE_CHECKINGIterableListTypeVarUnioncastoverload)OneStyleAndTextTuple)SupportsIndexexplode_text_fragments_T)boundc                       s   e Zd ZdZdZeddddZee dd fdd	Zd
eddddZ	e
d
eddddZe
eee ddddZed
ef eeee f 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.
    TN)itemreturnc                 C   s   |  |g d S N)extend)selfr    r   W/var/www/html/django/DPS/env/lib/python3.9/site-packages/prompt_toolkit/layout/utils.pyappend   s    z_ExplodedList.append)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__c                 C   s   d S r   r   r   r   r   r   r    (   s    c                    sR   t |ts | }t||d }t |tr6t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]zIterable[_T]N)
isinstanceslice	__index__tupler   r   r    r   )r   r   r   Z	int_indexr   r   r   r    ,   s    

)__name__
__module____qualname____doc__explodedr   r   r   r   r   r   r    r#   r   __classcell__r   r   r   r   r      s   r   )	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)typingr   r   r   r   r   r   r   Z"prompt_toolkit.formatted_text.baser	   Ztyping_extensionsr
   __all__r   r   r   r   r   r   r   <module>   s   $-