o
    ,&]i                  	   @  sz  U d dl mZ d dlZd dlZd dlZd dlZd dlZd dlmZm	Z	m
Z
mZmZ d dlmZ er;d dlZd dlmZ edZded< dCddZdDddZdDddZdEddZdFddZdGddZdHdd ZdId"d#ZdJd'd(Zeh d)e e!d*d+d,h B Z"ded-< dKd0d1Z#dLd3d4Z$ed5Z%ded6< dMd7d8Z&dNd:d;Z'ed<d=e(e)ej*ej+ej,ej-f Z.d>ed?< dOdAdBZ/dS )P    )annotationsN)TYPE_CHECKINGAnyFinal	TypeAliasUnion)StreamlitAPIException)SupportsStrz^[a-zA-Z0-9_&\-\. ]+$r   _ALPHANUMERIC_CHAR_REGEXtextr	   returnstrc                 C  s   t t|  S )z;Convert an object to text, dedent it, and strip whitespace.)textwrapdedentr   stripr    r   S/var/www/html/IGF-ODF-V3/venv/lib/python3.10/site-packages/streamlit/string_util.py
clean_text"   s   r   boolc                 C  s   | r
t t| du S dS )zCheck if a string contains any special chars.

    Special chars in that case are all chars that are not
    alphanumeric, underscore, hyphen or whitespace.
    NF)rematchr
   r   r   r   r   _contains_special_chars'   s   r   c                 C  s(   t | sdS ddlm} | dd|v S )z'Check if input string is a valid emoji.Fr   )
ALL_EMOJISu   ️ )r   streamlit.emojisr   replace)r   r   r   r   r   is_emoji0   s   r   
maybe_iconc                 C  s   ddl m} | |v S )z/Check if input string is a valid Material icon.r   )ALL_MATERIAL_ICONS)streamlit.material_icon_namesr   )r   r   r   r   r   is_material_icon:   s   r!   icon
str | Nonec                 C  s2   | du rdS | dkrdS |  drt| S t| S )zFValidate an icon or emoji and return it in normalized format if valid.Nr   spinnerz	:material)
startswithvalidate_material_iconvalidate_emoji)r"   r   r   r   validate_icon_or_emojiA   s   
r(   maybe_emojic                 C  s(   | d u rdS t | r| S td|  d)Nr   zThe value "zZ" is not a valid emoji. Shortcodes are not allowed, please use a single character instead.)r   r   )r)   r   r   r   r'   O   s   
r'   maybe_material_iconc                 C  s   dg}| du r	dS d}t || }d}|s&td| d|d  d| d	| \}}||vs6|r6t|sGtd| d|d  d| d
d| d| dS )z^Validate a Material icon shortcode and return the icon in
    normalized format if valid.
    materialNr   z^\s*:(.+)\/(.+):\s*$u   ​zThe value `"/zW"` is not a valid Material icon. Please use a Material icon shortcode like **`:materialz/thumb_up:`**z/thumb_up:`**.:)r   r   r   r   groupsr!   )r*   supported_icon_packs
icon_regex
icon_matchinvisible_white_space	pack_name	icon_namer   r   r   r&   [   s2   r&   tuple[str, str]c                 C  sL   t | sd| fS ddlm} t|| }|du rd| fS |d|dfS )zReturn a tuple containing the first emoji found in the given string and
    the rest of the string (minus an optional separator between the two).
    r   r   )EMOJI_EXTRACTION_REGEXN      )r   r   r6   r   searchgroup)r   r6   re_matchr   r   r   extract_leading_emoji   s   r<   stringcharintc                 C  s6   d}d}| D ]}||kr|d7 }t ||}qd}q|S )zBReturns the count of the max sequence of a given char in a string.r   r7   )max)r=   r>   max_sequencecurrent_sequencecr   r   r   max_char_sequence   s   rD   >         	   
                      	TEXTCHARSinpbytesc                 C  s   t | dtS )z8Guess if an input bytesarray can be encoded as a string.N)r   	translaterO   )rP   r   r   r   is_binary_string   s   rS   numc                 C  s\   t | d}d}t|dkr|d7 }|d }t|dksd|ddd	g d
| S )z:Simplifies number into Human readable format, returns str.z.2gr   i  r7   g     @@z{}{}f0.)r   kmbt)floatabsformatrstrip)rT   num_converted	magnituder   r   r   simplify_number   s   
rb   z0^\<[a-zA-Z_]+[a-zA-Z0-9<>._ ]* at 0x[0-9a-f]+\>$_OBJ_MEM_ADDRESSc                 C  s   t t| S )zAReturns True if the string looks like <foo blarg at 0x15ee6f9a0>.)r   rc   r   )r=   r   r   r   is_mem_address_str   s   rd   camel_case_strc                 C  s    t dd| }t dd| S )zConverts UpperCamelCase and lowerCamelCase to snake_case.

    Examples
    --------
        fooBar -> foo_bar
        BazBang -> baz_bang

    z(.)([A-Z][a-z]+)z\1_\2z([a-z0-9])([A-Z]))r   sublower)re   s1r   r   r   to_snake_case   s   	ri   znp.integer[Any]znp.floating[Any]r   	AnyNumbervaluec                 C  sp   t | tjr
t| S t| dr+zt |  ttfr t|  W S W n	 ty*   Y nw t	d|  dt
|  d)a  Render a real numeric type as a string for display.

    Parameters
    ----------
    value : AnyNumber
        The numeric value to convert to a string. Can be an ``int``, ``float``,
        any ``numbers.Number`` (e.g., ``decimal.Decimal``), or a NumPy numeric type
        with an ``item()`` method.

    Returns
    -------
    str
        String representation of the numeric value.

    Raises
    ------
    TypeError
        If the value is not of an accepted numeric type.
    item'z' is of type zU, which is not an accepted type. Please convert the value to an accepted number type.)
isinstancenumbersNumberr   hasattrrl   r\   r?   	Exception	TypeErrortype)rk   r   r   r   from_number   s   
ru   )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   r   r   r5   )r=   r   r>   r   r   r?   )rP   rQ   r   r   )rT   r?   r   r   )r=   r   r   r   )re   r   r   r   )rk   rj   r   r   )0
__future__r   decimal	fractionsro   r   r   typingr   r   r   r   r   streamlit.errorsr   numpynpstreamlit.type_utilr	   compiler
   __annotations__r   r   r   r!   r(   r'   r&   r<   rD   	bytearraysetrangerO   rS   rb   rc   rd   ri   r?   r\   DecimalFractionRealrp   rj   ru   r   r   r   r   <module>   sV   


	





*




