
    i                         d Z ddlmZ ddlmZ ddlmZ dededefdZ	 dded
ee         dee         d	z  de	eef         f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.
    )Sequence)MessageEntity)TextEncodingtextentityreturnc                     |                      t          j                  }||j        dz  |j        |j        z   dz           }|                    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_texts      X/Users/shanyulin/my-agent/.venv/lib/python3.11/site-packages/telegram/_utils/entities.pyparse_message_entityr   !   sT     ++l455Kfma/6=6=3PTU2UUVKl4555    Nentitiestypesc                 @     t           j         f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                 D    i | ]}|j         v |t          |          S  )typer   ).0r   r   r   s     r   
<dictcomp>z*parse_message_entities.<locals>.<dictcomp>G   s:       7=V[\aMaMa$T622MaMaMar   )r   	ALL_TYPES)r   r   r   s   ` `r   parse_message_entitiesr   1   sC    & }'    AI   r   )N)__doc__collections.abcr   telegram._messageentityr   telegram._utils.stringsr   strr   dictr   r   r   r   <module>r$      s   &  % $ $ $ $ $ 1 1 1 1 1 1 0 0 0 0 0 06s 6M 6c 6 6 6 6" QU 
!-09A#9M	-
     r   