o
    GC™hõ  ã                   @   s~   d Z ddlmZ ddlmZ ddlmZmZmZm	Z	m
Z
 ddlmZmZ e	dƒZe	dƒZe	dƒZG d	d
„ d
eeeef ƒZdS )aO  This module contains a mutable mapping that keeps track of the keys that where accessed.

.. versionadded:: 20.0

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.
é    )ÚUserDict)ÚMapping)ÚFinalÚGenericÚOptionalÚTypeVarÚUnion)ÚDEFAULT_NONEÚDefaultValueÚ_VTÚ_KTÚ_Tc                	       s*  e Zd ZU dZeƒ Zeed< 	 dZd"‡ fdd„Z	de
d	eddf‡ fd
d„Zde
ddf‡ fdd„Zdee
ee
 f ddfdd„Zdee
 fdd„Zdeee
ef  fdd„Zde
ddfdd„Zdee
ef ddfdd„Zefde
dedef‡ fdd„Zd"‡ fdd„Zd#ddde
dee defd d!„Z‡  ZS )$ÚTrackingDicta'  Mutable mapping that keeps track of which keys where accessed with write access.
    Read-access is not tracked.

    Note:
        * ``setdefault()`` and ``pop`` are considered writing only depending on whether the
            key is present
        * deleting values is considered writing
    ÚDELETED)Ú_write_access_keysÚreturnNc                    s   t ƒ  ¡  tƒ | _d S ©N)ÚsuperÚ__init__Úsetr   ©Úself©Ú	__class__© úY/var/www/html/govbot/env/lib/python3.10/site-packages/telegram/ext/_utils/trackingdict.pyr   6   s   
zTrackingDict.__init__ÚkeyÚvaluec                    s   |   |¡ tƒ  ||¡ d S r   )Ú_TrackingDict__track_writer   Ú__setitem__)r   r   r   r   r   r   r   :   s   
zTrackingDict.__setitem__c                    s   |   |¡ tƒ  |¡ d S r   )r   r   Ú__delitem__©r   r   r   r   r   r    >   s   
zTrackingDict.__delitem__c                 C   s,   t |tƒr|  j|O  _d S | j |¡ d S r   )Ú
isinstancer   r   Úaddr!   r   r   r   Ú__track_writeB   s   
zTrackingDict.__track_writec                 C   s   | j }tƒ | _ |S )zUReturns all keys that were write-accessed since the last time this method was called.)r   r   )r   Úoutr   r   r   Úpop_accessed_keysH   s   zTrackingDict.pop_accessed_keysc                    s   ˆ   ¡ }‡ fdd„|D ƒS )zØ
        Returns all keys & corresponding values as set of tuples that were write-accessed since
        the last time this method was called. If a key was deleted, the value will be
        :attr:`DELETED`.
        c                    s   g | ]}|ˆ   |ˆ j¡f‘qS r   )Úgetr   )Ú.0r   r   r   r   Ú
<listcomp>U   s    z9TrackingDict.pop_accessed_write_items.<locals>.<listcomp>)r&   )r   Úkeysr   r   r   Úpop_accessed_write_itemsN   s   z%TrackingDict.pop_accessed_write_itemsc                 C   s   | j  |¡ dS )zŽUse this method have the key returned again in the next call to
        :meth:`pop_accessed_write_items` or :meth:`pop_accessed_keys`
        N)r   r#   r!   r   r   r   Úmark_as_accessedW   s   zTrackingDict.mark_as_accessedÚmappingc                 C   s    |  ¡ D ]	\}}|| j|< qdS )z8Like ``update``, but doesn't count towards write access.N)ÚitemsÚdata)r   r-   r   r   r   r   r   Úupdate_no_track_   s   ÿzTrackingDict.update_no_trackÚdefaultc                    s8   || v r	|   |¡ t|tƒrtƒ  |¡S tƒ j||dS )N)r1   )r   r"   r
   r   Úpop©r   r   r1   r   r   r   r2   f   s
   

zTrackingDict.popc                    s"   |   ttƒ  ¡ ƒ¡ tƒ  ¡  d S r   )r   r   r   r*   Úclearr   r   r   r   r4   q   s   zTrackingDict.clearr   zTrackingDict[_KT, _T]c                 C   s&   || v r| | S |   |¡ || |< |S r   )r   r3   r   r   r   Ú
setdefaultw   s
   
zTrackingDict.setdefault)r   Nr   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úobjectr   r   Ú__annotations__Ú	__slots__r   r   r   r   r    r   r   r   r&   ÚlistÚtupler+   r,   r   r0   r	   r2   r4   r   r   r5   Ú__classcell__r   r   r   r   r   '   s.   
 		
ýþýü(r   N)r9   Úcollectionsr   Úcollections.abcr   Útypingr   r   r   r   r   Útelegram._utils.defaultvaluer	   r
   r   r   r   r   r   r   r   r   Ú<module>   s   	