
    _j[                        S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r	J
r
JrJrJr  SSKJr  SS	KJr     S         SS jjrg
)z.This is a python implementation of wcswidth().    )annotations)Optional   wcwidth)bisearch)_EMOJI_ZWJ_SET_ISC_VIRAMA_SET_CATEGORY_MC_TABLE_FITZPATRICK_RANGE_REGIONAL_INDICATOR_SET)VS16_NARROW_TO_WIDE)ISC_CONSONANTNc                D  ^ Uc5  U R                  5       (       a   U R                  5       (       a  [        U 5      $ TS:X  a  [        OU4S jnUc  [        U 5      OUnSnSnSnSn	Sn
SnXu:  Ga  X   n[	        U5      nUS:X  a'  U
(       a  US-  nOUS-   U:  a  Sn
US-  nOSn
US-  nMB  US	:X  a0  US:  a*  U[        [	        X   5      [        S
   5      -  nSnUS-  nMx  US:  a  U[        ;   a\  SnUS-
  nUS:  a<  [	        X   5      [        ;   a'  US-  nUS-  nUS:  a  [	        X   5      [        ;   a  M'  US-  S:X  a	  Un	US-  nM  O0[        S   Us=::  a  [        S   ::  a  O  OU	[        ;   a  US-  nGM  U
(       a%  [        U[        5      (       a  UnUn	Sn
SnUS-  nGM@  U" U5      nUS:  a  gUS:  a  U(       a  US-  nSnUU-  nUnUn	Sn
O0US:  a!  [        U[        5      (       a  US-  nSnSn
SnO	U[        ;   n
US-  nXu:  a  GM  U(       a  US-  nU$ )a  
Given a unicode string, return its printable length on a terminal.

See :ref:`Specification` for details of cell measurement.

This implementation differs from Markus Khun's original POSIX C implementation, in that this
``wcswidth()`` processes graphemes strings yielded by :func:`wcwidth.iter_graphemes` defined by
`Unicode Standard Annex #29`_. POSIX wcswidth(3) is not grapheme-aware and does not measure many
kinds of Emojis or complex scripts correctly.

:param pwcs: Measure width of given unicode string.
:param n: When ``n`` is None (default), return the length of the entire
    string, otherwise only the first ``n`` characters are measured.

:param unicode_version: Ignored. Retained for backwards compatibility.

    .. deprecated:: 0.3.0
       Only the latest Unicode version is now shipped.

:param ambiguous_width: Width to use for East Asian Ambiguous (A)
    characters. Default is ``1`` (narrow). Set to ``2`` for CJK contexts.
:returns: The width, in cells, needed to display the first ``n`` characters
    of the unicode string ``pwcs``.  Returns ``-1`` for C0 and C1 control
    characters!

.. _`Unicode Standard Annex #29`: https://www.unicode.org/reports/tr29/
r   c                   > [        U ST5      $ )Nautor   )cambiguous_widths    F/home/rurouni/.local/lib/python3.13/site-packages/wcwidth/_wcswidth.py<lambda>wcswidth.<locals>.<lambda>=   s    gaQ`>a    r   Fi      i  z9.0.0i  T)isasciiisprintablelenr   ordr   r   r   r   r	   r   r   r
   )pwcsnunicode_versionr   _wcwidthendtotal_widthidxlast_measured_idxlast_measured_ucslast_was_viramaconjunct_pendingcharucs	ri_beforejws      `             r   wcswidthr0      s   L 	yT\\^^(8(8(:(:4y *Q.w4aHy#d)aCK
C O
)y$i &=qq3"'q"'q &=.!38D+,#G, K !#1HC <--	!G1fTW1H!HNIFA 1fTW1H!H q=A%(+%1HC & %Q'3G2DQ2GG'>9q x];; # ##O#1HC TNq5q5q #( 1K # ##O!#6H(I(I1K "#O$!_4OqS )V qr   )Nr   r   )
r    strr!   zOptional[int]r"   r1   r   intreturnr2   )__doc__
__future__r   typingr   r#   r   r   
_constantsr	   r
   r   r   r   
table_vs16r   table_graphemer   r0    r   r   <module>r;      sl    4 "   2 2
 , )
 !	C
CC C 	C
 	Cr   