o
    ú§Ýj
  ã                   @  s  U d dl mZ d dlmZ d dlmZ ddlmZ g d¢Zde	d< e
d	d
„ eD ƒƒZejZde	d< edƒd,dd„ƒZefd-dd„Zedd�d.dd„ƒZd/dd„Zd0d!d"„Zed#krƒeed$ƒƒ ed%d&ƒD ]Zeeƒ qded'dd(ƒD ]Zeed%eƒd) ƒ ed*e ƒ qqd+S d+S )1é    )Úannotations)Ú	lru_cache)ÚCallableé   )ÚCELL_WIDTHS))é    é~   )é    é¬   )é®   iÿ  )ip  i‚  )i %  iü%  )i (  iÿ(  zlist[tuple[int, int]]Ú_SINGLE_CELL_UNICODE_RANGESc                 C  s.   g | ]\}}t tt||d  ƒƒD ]}|‘qqS )r   )ÚmapÚchrÚrange)Ú.0Z_startZ_endÚ	character© r   úQ/var/www/html/chatgpt/venv/lib/python3.10/site-packages/pip/_vendor/rich/cells.pyÚ
<listcomp>   s    ýþÿr   zCallable[[str], bool]Ú_is_single_cell_widthsi   ÚtextÚstrÚreturnÚintc                 C  s   t | ƒrt| ƒS ttt| ƒƒS )a/  Get the number of cells required to display text.

    This method always caches, which may use up a lot of memory. It is recommended to use
    `cell_len` over this method.

    Args:
        text (str): Text to display.

    Returns:
        int: Get the number of cells required to display text.
    )r   ÚlenÚsumr   Úget_character_cell_size)r   r   r   r   Úcached_cell_len!   s   r   Ú	_cell_lenúCallable[[str], int]c                 C  s2   t | ƒdk r
|| ƒS t| ƒrt | ƒS ttt| ƒƒS )z³Get the number of cells required to display text.

    Args:
        text (str): Text to display.

    Returns:
        int: Get the number of cells required to display text.
    i   )r   r   r   r   r   )r   r   r   r   r   Úcell_len3   s
   	r    )Úmaxsizer   c           	      C  sˆ   t | ƒ}t}d}t|ƒd }|| d }	 || \}}}||k r%|d }n||kr.|d }n|dkr4dS |S ||k r=	 dS || d }q)z±Get the cell size of a character.

    Args:
        character (str): A single character.

    Returns:
        int: Number of cells (0, 1 or 2) occupied by that character.
    r   r   é   Téÿÿÿÿ)Úordr   r   )	r   Z	codepointZ_tableZlower_boundZupper_boundÚindexÚstartÚendÚwidthr   r   r   r   C   s"   


ÿör   Útotalc           	      C  sê   t | ƒrt| ƒ}||k r| d||   S | d|… S |dkr dS t| ƒ}||kr*| S ||k r6| d||   S d}t| ƒ}	 || d }| d|d … }t|ƒ}||d kret|d ƒdkre|dd… d S ||krk|S ||krr|}n|}q=)	z?Set the length of a string to fit within given number of cells.ú Nr   Ú Tr"   r   r#   )r   r   r    )	r   r)   ÚsizeÚ	cell_sizer&   r'   ÚposÚbeforeZ
before_lenr   r   r   Úset_cell_size`   s4   õr0   r(   ú	list[str]c           
      C  sx   t }g g}|j}|d j}d}| D ]#}||ƒ}|| |k}	|	r,||gƒ |d j}|}q||ƒ ||7 }qdd„ |D ƒS )ah  Split text into lines such that each line fits within the available (cell) width.

    Args:
        text: The text to fold such that it fits in the given width.
        width: The width available (number of cells).

    Returns:
        A list of strings such that each string in the list has cell width
        less than or equal to the available width.
    r#   r   c                 S  s   g | ]}d   |¡‘qS )r+   )Újoin)r   Úliner   r   r   r   ¥   s    zchop_cells.<locals>.<listcomp>)r   Úappend)
r   r(   Z_get_character_cell_sizeÚlinesZappend_new_lineZappend_to_last_lineZtotal_widthr   Z
cell_widthZchar_doesnt_fitr   r   r   Ú
chop_cellsƒ   s   



r6   Ú__main__u   ðŸ˜½u]   è¿™æ˜¯å¯¹äºšæ´²è¯­è¨€æ”¯æŒ�çš„æµ‹è¯•ã€‚é�¢å¯¹æ¨¡æ£±ä¸¤å�¯çš„æƒ³æ³•ï¼Œæ‹’ç»�çŒœæµ‹çš„è¯±æƒ‘ã€‚é   éP   r#   ú|ÚxN)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   r1   )Ú
__future__r   Ú	functoolsr   Útypingr   Z_cell_widthsr   r   Ú__annotations__Ú	frozensetZ_SINGLE_CELLSÚ
issupersetr   r   r    r   r0   r6   Ú__name__Úprintr3   r   Únr   r   r   r   Ú<module>   s6    
þÿ


#%
ú