
    i                         d Z ddlmZ ddlmZ ddl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
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TypeVar)DEFAULT_NONEDefaultValue_VT_KT_Tc            	       P    e Zd ZU dZ e            Zeed<   	 dZd fdZ	de
deddf fd	Zde
ddf fd
Zde
ee
         z  ddfdZdee
         fdZdeee
ef                  fdZde
ddfdZdee
ef         ddfdZefde
dedef fdZd fdZdddde
dedz  defdZ x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                 n    t                                                       t                      | _        d S N)super__init__setr   self	__class__s    `/Users/shanyulin/my-agent/.venv/lib/python3.11/site-packages/telegram/ext/_utils/trackingdict.pyr   zTrackingDict.__init__7   s+    ,/EE    keyvaluec                 v    |                      |           t                                          ||           d S r   )_TrackingDict__track_writer   __setitem__)r   r   r   r   s      r   r    zTrackingDict.__setitem__;   s7    3C'''''r   c                 t    |                      |           t                                          |           d S r   )r   r   __delitem__)r   r   r   s     r   r"   zTrackingDict.__delitem__?   s5    3C     r   c                     t          |t                    r| xj        |z  c_        d S | j                            |           d S r   )
isinstancer   r   addr   r   s     r   __track_writezTrackingDict.__track_writeC   sK    c3 	-##s*#####'',,,,,r   c                 :    | j         }t                      | _         |S )zUReturns all keys that were write-accessed since the last time this method was called.)r   r   )r   outs     r   pop_accessed_keyszTrackingDict.pop_accessed_keysI   s    %"%%%
r   c                 H                                       } f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                 J    g | ]}|                     |j                  f S  )getr   ).0r   r   s     r   
<listcomp>z9TrackingDict.pop_accessed_write_items.<locals>.<listcomp>V   s.    CCCsdhhsDL112CCCr   )r*   )r   keyss   ` r   pop_accessed_write_itemsz%TrackingDict.pop_accessed_write_itemsO   s0     %%''CCCCdCCCCr   c                 :    | j                             |           dS )zUse 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&   s     r   mark_as_accessedzTrackingDict.mark_as_accessedX   s!     	##C(((((r   mappingc                 N    |                                 D ]\  }}|| j        |<   dS )z8Like ``update``, but doesn't count towards write access.N)itemsdata)r   r5   r   r   s       r   update_no_trackzTrackingDict.update_no_track`   s4    !--// 	# 	#JC"DIcNN	# 	#r   defaultc                     || v r|                      |           t          |t                    r!t                                          |          S t                                          ||          S )N)r:   )r   r$   r	   r   pop)r   r   r:   r   s      r   r<   zTrackingDict.popg   sd    
 $;;s###g|,, 	$77;;s###ww{{3{000r   c                     |                      t          t                                                                           t                                                       d S r   )r   r   r   r1   clearr   s    r   r>   zTrackingDict.clearr   s@    3uww||~~..///r   r   zTrackingDict[_KT, _T]c                 R    || v r| |         S |                      |           || |<   |S r   )r   )r   r   r:   s      r   
setdefaultzTrackingDict.setdefaultx   s7    $;;93S	r   )r   Nr   )__name__
__module____qualname____doc__objectr   r   __annotations__	__slots__r   r   r
   r    r"   r   r   r*   listtupler2   r4   r   r9   r   r<   r>   r   r@   __classcell__)r   s   @r   r   r   (   s(          VXXGU>'I2 2 2 2 2 2(s (3 (4 ( ( ( ( ( (!s !t ! ! ! ! ! !-s3x -D - - - -3s8    D$uS#X*? D D D D)C )D ) ) ) )#wsCx'8 #T # # # # $	1 	1	1 	1 
		1 	1 	1 	1 	1 	1      0 s R$Y Z\        r   r   N)rD   collectionsr   collections.abcr   typingr   r   r   telegram._utils.defaultvaluer   r	   r
   r   r   r   r-   r   r   <module>rO      s   &  !           # # # # # # * * * * * * * * * * C C C C C C C CgenngennWT]]V V V V V8WS#X. V V V V Vr   