
    &g                       S SK Jr  S SKrS SKJr  S SKJr  SSKJr  \R                  " S5      R                  r\" S5      SS	 j5       r\4SS
 jjr\" SS9SS j5       r\" SS9SS j5       rSS jr      SS jr\S:X  aU  \" \" S5      5        \" SS5       H  r\" \5        M     \" SSS5       H   r\" \" S\5      S-   5        \" S\-  5        M"     gg)    )annotationsN)	lru_cache)Callable   )CELL_WIDTHSu   ^[ -o ˿Ͱ-҂]*$i   c                >   ^ [         m[        U4S jU  5       5      nU$ )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.
c              3  4   >#    U  H  nT" U5      v   M     g 7fN .0	character	_get_sizes     O/home/matz/Project1/venv/lib/python3.13/site-packages/pip/_vendor/rich/cells.py	<genexpr>"cached_cell_len.<locals>.<genexpr>        @4iYy))4   )get_character_cell_sizesum)text
total_sizer   s     @r   cached_cell_lenr      s      (I@4@@J    c                l   ^ [        U 5      S:  a  U" U 5      $ [        m[        U4S jU  5       5      nU$ )zGet 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   c              3  4   >#    U  H  nT" U5      v   M     g 7fr
   r   r   s     r   r   cell_len.<locals>.<genexpr>+   r   r   )lenr   r   )r   	_cell_lenr   r   s      @r   cell_lenr       s5     4y3'I@4@@Jr   )maxsizec                *    [        [        U 5      5      $ )zGet 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.
)_get_codepoint_cell_sizeord)r   s    r   r   r   /   s     $C	N33r   c                    [         nSn[        U5      S-
  nX#-   S-  n X   u  pVnX:  a  US-
  nOX:  a  US-   nO
US:X  a  S$ U$ X2:  a   gX#-   S-  nM7  )zGet the cell size of a character.

Args:
    codepoint (int): Codepoint of a character.

Returns:
    int: Number of cells (0, 1 or 2) occupied by that character.
r   r      )r   r   )	codepoint_tablelower_boundupper_boundindexstartendwidths           r   r#   r#   <   s     FKf+/K&1,E
"ME!)K_!)K1..$ *q0 r   c                j   [        U 5      (       a  [        U 5      nX!:  a
  U SX-
  -  -   $ U SU $ US::  a  g[        U 5      nX1:X  a  U $ X1:  a
  U SX-
  -  -   $ Sn[        U 5      n XE-   S-  nU SUS-    n[        U5      nXS-   :X  a  [        US   5      S:X  a  USS S-   $ X:X  a  U$ X:  a  UnOUnMO  )z?Set the length of a string to fit within given number of cells. Nr    r&   r   r'   )_is_single_cell_widthsr   r    )	r   totalsize	cell_sizer-   r.   posbefore
before_lens	            r   set_cell_sizer:   Y   s     d##4y<#...FU|zIcU.///E
d)C {q iaf%
"xr
';q'@#2;$$MCE r   c                *   [         n/ /nUR                  nUS   R                  nSnU  HA  nU" U5      nXh-   U:  n	U	(       a  U" U/5        US   R                  nUnM5  U" U5        Xh-  nMC     U V
s/ s H  n
SR                  U
5      PM     sn
$ s  sn
f )aL  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   r2   )r   appendjoin)r   r/   _get_character_cell_sizelinesappend_new_lineappend_to_last_linetotal_widthr   
cell_widthchar_doesnt_fitlines              r   
chop_cellsrF   |   s      7 TEllO)**K	-i8
%2U:YK("')"2"2$K	*%K  ',,edBGGDMe,,,s   2B__main__u   😽u]   这是对亚洲语言支持的测试。面对模棱两可的想法，拒绝猜测的诱惑。   P   r'   |x)r   strreturnint)r   rL   r   zCallable[[str], int]rM   rN   )r   rL   rM   rN   )r(   rN   rM   rN   )r   rL   r4   rN   rM   rL   )r   rL   r/   rN   rM   z	list[str])
__future__r   re	functoolsr   typingr   _cell_widthsr   compilematchr3   r   r    r   r#   r:   rF   __name__printrE   rangenr   r   r   <module>rZ      s,   " 	   % $QRXX  4 " ;J   4	4 	4 4 8 F"-
"-"- "-J z	
!&
)*~  AB  Cd C2q"m  BC  D  GJ  J  	KcAg 	 r   