o
    j[                     @  s~   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	m
Z
mZmZmZ ddlmZ dd	lmZ 	
		ddddZd
S )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_CONSONANTNautopwcsstrnOptional[int]unicode_versionambiguous_widthintreturnc                   s`  |du r|   r|  rt| S  dkrtn fdd}|du r$t| n|}d}d}d}d}	d}
d}||k r'| | }t|}|d	kr^|
rJ|d7 }n|d |k rWd}
|d
7 }nd}
|d7 }q2|dkrz|dkrz|tt| | td 7 }d}|d7 }q2|dkr|tv rd}|d }|dkrt| | tv r|d7 }|d8 }|dkrt| | tv s|d
 dkr|}	|d7 }q2ntd |  krtd krn n	|	t	v r|d7 }q2|
rt|t
r|}|}	d}
d}|d7 }q2||}|dk rdS |dkr|r|d7 }d}||7 }|}|}	d}
n|dkrt|tr|d7 }d}d}
d}n|tv }
|d7 }||k s7|r.|d7 }|S )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/
    Nr   c                   s   t | d S )Nr   r   )cr    R/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/wcwidth/_wcswidth.py<lambda>=   s    zwcswidth.<locals>.<lambda>r   Fi      i  z9.0.0i  T)isasciiisprintablelenr   ordr   r   r   r   r   r   r
   r	   )r   r   r   r   _wcwidthendtotal_widthidxZlast_measured_idxZlast_measured_ucsZlast_was_viramaZconjunct_pendingcharZucsZ	ri_beforejwr   r   r   wcswidth   s   &



 
Kr+   )Nr   r   )
r   r   r   r   r   r   r   r   r   r   )__doc__
__future__r   typingr   r$   r   r   
_constantsr   r	   r
   r   r   Z
table_vs16r   Ztable_graphemer   r+   r   r   r   r   <module>   s    