o
    / hÎ  ã                   @   s|   d Z ddlmZmZmZ ddlmZ ddlmZ de	dede	fdd	„Z
	
dde	dee deee	  deee	f fdd„Zd
S )a.  This module contains auxiliary functionality for parsing MessageEntity objects.

Warning:
    Contents of this module are intended to be used internally by the library and *not* by the
    user. Changes to this module are not considered breaking changes and may not be documented in
    the changelog.
é    )ÚDictÚOptionalÚSequence)ÚMessageEntity)ÚTextEncodingÚtextÚentityÚreturnc                 C   s6   |   tj¡}||jd |j|j d … }| tj¡S )a%  Returns the text from a given :class:`telegram.MessageEntity`.

    Args:
        text (:obj:`str`): The text to extract the entity from.
        entity (:class:`telegram.MessageEntity`): The entity to extract the text from.

    Returns:
        :obj:`str`: The text of the given entity.
    é   )Úencoder   Ú	UTF_16_LEÚoffsetÚlengthÚdecode)r   r   Úentity_text© r   úQ/var/www/html/govbot/env/lib/python3.10/site-packages/telegram/_utils/entities.pyÚparse_message_entity    s   
r   NÚentitiesÚtypesc                    s"   ˆdu rt j‰‡ ‡fdd„|D ƒS )aS  
    Returns a :obj:`dict` that maps :class:`telegram.MessageEntity` to :obj:`str`.
    It contains entities filtered by their ``type`` attribute as
    the key, and the text that each entity belongs to as the value of the :obj:`dict`.

    Args:
        text (:obj:`str`): The text to extract the entity from.
        entities (List[:class:`telegram.MessageEntity`]): The entities to extract the text from.
        types (List[:obj:`str`], optional): List of ``MessageEntity`` types as strings. If the
            ``type`` attribute of an entity is contained in this list, it will be returned.
            Defaults to :attr:`telegram.MessageEntity.ALL_TYPES`.

    Returns:
        Dict[:class:`telegram.MessageEntity`, :obj:`str`]: A dictionary of entities mapped to
        the text that belongs to them, calculated based on UTF-16 codepoints.
    Nc                    s"   i | ]}|j ˆv r|tˆ |ƒ“qS r   )Útyper   )Ú.0r   ©r   r   r   r   Ú
<dictcomp>F   s    z*parse_message_entities.<locals>.<dictcomp>)r   Ú	ALL_TYPES)r   r   r   r   r   r   Úparse_message_entities0   s
   ÿr   )N)Ú__doc__Útypingr   r   r   Útelegram._messageentityr   Útelegram._utils.stringsr   Ústrr   r   r   r   r   r   Ú<module>   s   ÿÿÿ
ÿ
þ