o
    h=                     @   st  d 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	m
Z
mZmZ ejdk r2ddlmZmZmZ n
ddlmZmZmZ ddlmZ ddlmZmZmZmZmZmZ g dZd	Zd
ZG dd deZG dd dZeefddddfde dee e f de
ed  de de
e! de
ee ee ee e f ge f f  de fddZ"	d3de de#de#dee fddZ$eefdddfde dee e f de de
e! de
ee ee ee e f ge f f  de fd d!Z%	"	#d4de d$ee ee ee e f ge f f de!de fd%d&Z&de de	e fd'd(Z'de de	e  fd)d*Z(d5de d+e#de)fd,d-Z*de de#fd.d/Z+de de#fd0d1Z,de de!fd2dZ-dS )6z4
emoji.core
~~~~~~~~~~

Core components for emoji.

    N)AnyCallableDictIteratorListOptionalTupleUnion)   	   )LiteralMatch	TypedDict)unicode_codes)Token
EmojiMatchEmojiMatchZWJEmojiMatchZWJNonRGItokenizefilter_tokens)emojizedemojizeanalyzeconfig
emoji_listdistinct_emoji_listemoji_countreplace_emojiis_emojipurely_emojiversionr   r   r   r   :uB   \w\-&.’”“()!#*+,/«»゙ًَُِ̧̀́̂̃̆̈̊ٓٔ・゚ٕc                   @   s&   e Zd ZU eed< eed< eed< dS )_EmojiListReturnemojimatch_start	match_endN)__name__
__module____qualname__str__annotations__int r,   r,   E/var/www/html/env_mimamsha/lib/python3.10/site-packages/emoji/core.pyr"   4   s   
 r"   c                   @   s>   e Zd ZdZdZ	 dZ	 eddeee	 e	df fddZ
dS )	r   zModule-wide configurationTFNlanguagec                 C   s6   t | tr| gn| r| ntj}|D ]}t| qdS )u  Load one or multiple languages into memory.
        If no language is specified, all languages will be loaded.

        This makes language data accessible in the :data:`EMOJI_DATA` dict.
        For example to access a French emoji name, first load French with

         ``emoji.config.load_language('fr')``

        and then access it with

         ``emoji.EMOJI_DATA['🏄']['fr']``

        Available languages are listed in :data:`LANGUAGES`N)
isinstancer)   r   	LANGUAGESload_from_json)r.   	languageslangr,   r,   r-   load_language^   s   zconfig.load_languageN)r&   r'   r(   __doc__demojize_keep_zwjreplace_emoji_keep_zwjstaticmethodr	   r   r)   r4   r,   r,   r,   r-   r   :   s    $r   enstring
delimitersvariant)	text_type
emoji_typer.   r    handle_versionreturnc              	      s`   t  tdt d tt d f }dtt dtf fdd}||| S )u/  
    Replace emoji names in a string with Unicode codes.
        >>> import emoji
        >>> print(emoji.emojize("Python is fun :thumbsup:", language='alias'))
        Python is fun 👍
        >>> print(emoji.emojize("Python is fun :thumbs_up:"))
        Python is fun 👍
        >>> print(emoji.emojize("Python is fun {thumbs_up}", delimiters = ("{", "}")))
        Python is fun 👍
        >>> print(emoji.emojize("Python is fun :red_heart:", variant="text_type"))
        Python is fun ❤
        >>> print(emoji.emojize("Python is fun :red_heart:", variant="emoji_type"))
        Python is fun ❤️ # red heart, not black heart

    :param string: String contains emoji names.
    :param delimiters: (optional) Use delimiters other than _DEFAULT_DELIMITER. Each delimiter
        should contain at least one character that is not part of a-zA-Z0-9 and ``_-&.()!?#*+,``.
        See ``emoji.core._EMOJI_NAME_PATTERN`` for the regular expression of unsafe characters.
    :param variant: (optional) Choose variation selector between "base"(None), VS-15 ("text_type") and VS-16 ("emoji_type")
    :param language: Choose language of emoji name: language code 'es', 'de', etc. or 'alias'
        to use English aliases
    :param version: (optional) Max version. If set to an Emoji Version,
        all emoji above this version will be ignored.
    :param handle_version: (optional) Replace the emoji above ``version``
        instead of ignoring it. handle_version can be either a string or a
        callable; If it is a callable, it's passed the Unicode emoji and the
        data dict from :data:`EMOJI_DATA` and must return a replacement string
        to be used::

            handle_version('\U0001F6EB', {
                'en' : ':airplane_departure:',
                'status' : fully_qualified,
                'E' : 1,
                'alias' : [':flight_departure:'],
                'de': ':abflug:',
                'es': ':avión_despegando:',
                ...
            })

    :raises ValueError: if ``variant`` is neither None, 'text_type' or 'emoji_type'

    z(%s[%s]+%s)r      matchrA   c                    s  |  dt d t d   }tttd| t }|d u r)|  dS d ur\tj| d kr\trRtj| 	 }| 
 |d< |  |d< ||S d urZtS dS d u sgdtj| vri|S |d	 d
ksu|d	 dkr{|dd	 }dkr|d
 S dkr|d S td)NrB   r   NFKCEr$   r%    r=   u   ︎u   ️r>   r?   zDParameter 'variant' must be either None, 'text_type' or 'emoji_type')grouplenr   get_emoji_by_name_DEFAULT_DELIMITERunicodedata	normalize
EMOJI_DATAcallablecopystartendr)   
ValueError)rC   nameemjemj_datar<   r@   r.   r=   r    r,   r-   replace   s>   $


zemojize.<locals>.replace)	r   r1   recompileescape_EMOJI_NAME_PATTERNr   r)   sub)r;   r<   r=   r.   r    r@   patternrX   r,   rW   r-   r   z   s   
3"'r   FT	non_emoji
join_emojic                 C   s   t t| dd| |dS )a  
    Find unicode emoji in a string. Yield each emoji as a named tuple
    :class:`Token` ``(chars, EmojiMatch)`` or :class:`Token` ``(chars, EmojiMatchZWJNonRGI)``.
    If ``non_emoji`` is True, also yield all other characters as
    :class:`Token` ``(char, char)`` .

    :param string: String to analyze
    :param non_emoji: If True also yield all non-emoji characters as Token(char, char)
    :param join_emoji: If True, multiple EmojiMatch are merged into a single
        EmojiMatchZWJNonRGI if they are separated only by a ZWJ.
    Tkeep_zwj
emoji_onlyr`   )r   r   )r;   r_   r`   r,   r,   r-   r      s   r   c                    sd   dkr	dd nd t  dtdtf fddt| tjd	}d
fdd|D S )u  
    Replace Unicode emoji in a string with emoji shortcodes. Useful for storage.
        >>> import emoji
        >>> print(emoji.emojize("Python is fun :thumbs_up:"))
        Python is fun 👍
        >>> print(emoji.demojize("Python is fun 👍"))
        Python is fun :thumbs_up:
        >>> print(emoji.demojize("icode is tricky 😯", delimiters=("__", "__")))
        Unicode is tricky __hushed_face__

    :param string: String contains Unicode characters. MUST BE UNICODE.
    :param delimiters: (optional) User delimiters other than ``_DEFAULT_DELIMITER``
    :param language: Choose language of emoji name: language code 'es', 'de', etc. or 'alias'
        to use English aliases
    :param version: (optional) Max version. If set to an Emoji Version,
        all emoji above this version will be removed.
    :param handle_version: (optional) Replace the emoji above ``version``
        instead of removing it. handle_version can be either a string or a
        callable ``handle_version(emj: str, data: dict) -> str``; If it is
        a callable, it's passed the Unicode emoji and the data dict from
        :data:`EMOJI_DATA` and must return a replacement string  to be used.
        The passed data is in the form of::

            handle_version('\U0001F6EB', {
                'en' : ':airplane_departure:',
                'status' : fully_qualified,
                'E' : 1,
                'alias' : [':flight_departure:'],
                'de': ':abflug:',
                'es': ':avión_despegando:',
                ...
            })

    aliasr:   TFemoji_matchrA   c                    s   | j d usJ d ur&| j d kr&tr| j|  S d ur$S dS | j v rV rEd| j v rEd | j d d dd  d  S d | j  dd  d  S | jS )NrE   rF   re   r   rB   rG   )datarO   r#   	data_copyrf   )_use_aliasesr<   r@   r.   r    r,   r-   handle$  s   
$"zdemojize.<locals>.handlera   rF   c                 3   0    | ]}t |jtrt |jn|jV  qd S r5   r/   valuer   r)   ).0tokenrk   r,   r-   	<genexpr>9  
    
zdemojize.<locals>.<genexpr>)r   r1   r   r)   r   r   r7   join)r;   r<   r.   r    r@   matchesr,   )rj   r<   rk   r@   r.   r    r-   r      s   *
r   rF   rG   rX   c                    sR   dt dtffdd t| tjd}tjrt|ddd}d	 fd
d|D S )a  
    Replace Unicode emoji in a customizable string.

    :param string: String contains Unicode characters. MUST BE UNICODE.
    :param replace: (optional) replace can be either a string or a callable;
        If it is a callable, it's passed the Unicode emoji and the data dict from
        :data:`EMOJI_DATA` and must return a replacement string to be used.
        replace(str, dict) -> str
    :param version: (optional) Max version. If set to an Emoji Version,
        only emoji above this version will be replaced.
    rf   rA   c                    st   dkr%| j d usJ | j d kr"t r | j|  S t S | jS t r1 | j|  S  d ur7 S | jS )NrG   rE   )rg   rO   r#   rh   r)   ri   rX   r    r,   r-   rk   P  s   zreplace_emoji.<locals>.handlera   FTrc   rF   c                 3   rl   r5   rm   ro   mrq   r,   r-   rr   a  rs   z replace_emoji.<locals>.<genexpr>)r   r)   r   r   r8   r   rt   )r;   rX   r    ru   r,   )rk   rX   r    r-   r   ?  s   r   c                 C   s   dd t | ddD S )u   
    Returns the location and emoji in list of dict format.
        >>> emoji.emoji_list("Hi, I am fine. 😁")
        [{'match_start': 15, 'match_end': 16, 'emoji': '😁'}]
    c                 S   s0   g | ]}t |jtr|jj|jj|jjd qS ))r$   r%   r#   )r/   rn   r   rQ   rR   r#   rw   r,   r,   r-   
<listcomp>n  s    
zemoji_list.<locals>.<listcomp>Fra   )r   r;   r,   r,   r-   r   g  s   
r   c                 C   s   t dd t| D }|S )z0Returns distinct list of emojis from the string.c                 S   s   h | ]}|d  qS )r#   r,   )ro   er,   r,   r-   	<setcomp>{  s    z&distinct_emoji_list.<locals>.<setcomp>)listr   )r;   distinct_listr,   r,   r-   r   y  s   r   uniquec                 C   s   |rt t| S t t| S )zr
    Returns the count of emojis in a string.

    :param unique: (optional) True if count only unique emojis
    )rI   r   r   )r;   r   r,   r,   r-   r     s   r   c                 C   s
   | t jv S )z{
    Returns True if the string is a single emoji, and it is "recommended for
    general interchange" by Unicode.org.
    )r   rN   rz   r,   r,   r-   r     s   
r   c                 C   s   t dd t| ddD S )z
    Returns True if the string contains only emojis.
    This might not imply that `is_emoji` for all the characters, for example,
    if the string contains variation selectors.
    c                 s   s    | ]	}t |jtV  qd S r5   )r/   rn   r   rw   r,   r,   r-   rr     s    zpurely_emoji.<locals>.<genexpr>T)r_   )allr   rz   r,   r,   r-   r     s   r   c                    s   | t jv rt j|  d S t | d}|r |t jv r t j| d S g  dtdtttf dtf fdd}t| |dd	  r@ d
 S t| dd|d  rN d
 S t jD ]}t| |d|d  rc d
   S qQt	d)u]  
    Returns the Emoji Version of the emoji.

    See https://www.unicode.org/reports/tr51/#Versioning for more information.
        >>> emoji.version("😁")
        0.6
        >>> emoji.version(":butterfly:")
        3

    :param string: An emoji or a text containing an emoji
    :raises ValueError: if ``string`` does not contain an emoji
    rE   r:   r{   
emoji_datarA   c                    s     |d  dS )NrE   rF   )append)r{   r   r    r,   r-   f  s   zversion.<locals>.frG   rv   r   re   )r.   r    r@   zNo emoji found in string)
r   rN   rJ   r)   r   r   r   r   r0   rS   )r;   emj_coder   	lang_coder,   r   r-   r      s&   
"
)FT)rF   rG   )F).r6   rY   rL   systypingr   r   r   r   r   r   r   r	   version_infotyping_extensionsr   r   r   r#   r   emoji.tokenizerr   r   r   r   r   r   __all__rK   r\   r"   r   r)   floatr   boolr   r   r   r   r   r+   r   r   r   r    r,   r,   r,   r-   <module>   s    (
 	B

"
e

"
O
(	