
    Yi                         S r SSKJr  SSKJr  SSKJr  SSKJr  S\	S\S\	4S	 jr
 SS\	S\\   S\\\	      S\\\	4   4S jjrg
)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)Optional)MessageEntity)TextEncodingtextentityreturnc                     U R                  [        R                  5      nX!R                  S-  UR                  UR                  -   S-   nUR                  [        R                  5      $ )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      C/app/.venv/lib/python3.13/site-packages/telegram/_utils/entities.pyparse_message_entityr   !   sU     ++l445Kmma/6==6==3PTU2UVKl4455    Nentitiestypesc                     Uc  [         R                  nU Vs0 s H   o3R                  U;   d  M  U[        X5      _M"     sn$ s  snf )a  
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.
)r   	ALL_TYPEStyper   )r   r   r   r   s       r   parse_message_entitiesr   1   sQ    & }'' BJAIv[[\aMa2$T22  s
   AA)N)__doc__collections.abcr   typingr   telegram._messageentityr   telegram._utils.stringsr   strr   dictr    r   r   <module>r#      sv   & %  1 06s 6M 6c 6" TX
!-09A(3-9P	-
r   