o
    @j4
                     @   s   d dl mZ d dlmZ d dlmZ d dlmZ d dlmZm	Z	 d dl
mZmZmZmZmZmZmZ d dlmZ d dlmZmZmZmZ eG d	d
 d
ZG dd deZG dd deZG dd deZdS )    )Lock)defaultdict)asynccontextmanager)copy)	dataclassfield)AnyAsyncGeneratorDefaultDictDictHashableOptionaloverload)State)BaseEventIsolationBaseStorage	StateType
StorageKeyc                   @   s8   e Zd ZU eedZeeef e	d< dZ
ee e	d< dS )MemoryStorageRecord)default_factorydataNstate)__name__
__module____qualname__r   dictr   r   strr   __annotations__r   r    r   r   i/var/www/www-root/data/www/ai-bot.pdev.uz/venv/lib/python3.10/site-packages/aiogram/fsm/storage/memory.pyr      s   
 r   c                
   @   s   e Zd ZdZdddZdddZdded	eddfd
dZdede	e
 fddZdedee
ef ddfddZdedee
ef fddZedede
de	e fddZedede
dedefddZ	ddede
de	e de	e fddZdS )MemoryStoragez
    Default FSM storage, stores all data in :class:`dict` and loss everything on shutdown

    .. warning::

        Is not recommended using in production in due to you will lose all data
        when your bot restarts
    returnNc                 C      t t| _d S N)r   r   storageselfr   r   r   __init__!   s   
zMemoryStorage.__init__c                       d S r#   r   r%   r   r   r   close&      zMemoryStorage.closekeyr   c                    s"   t |tr	|jn|| j| _d S r#   )
isinstancer   r   r$   )r&   r+   r   r   r   r   	set_state)   s    zMemoryStorage.set_statec                    s   | j | jS r#   )r$   r   r&   r+   r   r   r   	get_state,   s   zMemoryStorage.get_stater   c                    s   |  | j| _d S r#   )r   r$   r   )r&   r+   r   r   r   r   set_data/   s   zMemoryStorage.set_datac                    s   | j | j S r#   )r$   r   r   r.   r   r   r   get_data2   s   zMemoryStorage.get_datastorage_keydict_keyc                    r(   r#   r   )r&   r2   r3   r   r   r   	get_value5   r*   zMemoryStorage.get_valuedefaultc                    r(   r#   r   )r&   r2   r3   r5   r   r   r   r4   8   r*   c                    s   | j | j}t|||S r#   )r$   r   r   get)r&   r2   r3   r5   r   r   r   r   r4   ;   s   r!   Nr#   )r   r   r   __doc__r'   r)   r   r   r-   r   r   r/   r   r   r0   r1   r   r4   r   r   r   r   r       s,    
	
r    c                   @   s0   e Zd Zededed fddZd	ddZdS )
DisabledEventIsolationr+   r!   NNc                 C  s   d V  d S r#   r   r.   r   r   r   lockC   s   
zDisabledEventIsolation.lockNc                    r(   r#   r   r%   r   r   r   r)   G   r*   zDisabledEventIsolation.closer7   )r   r   r   r   r   r	   r;   r)   r   r   r   r   r9   B   s    r9   c                   @   s:   e Zd ZdddZededed fddZdd	d
ZdS )SimpleEventIsolationr!   Nc                 C   r"   r#   )r   r   _locksr%   r   r   r   r'   L   s   zSimpleEventIsolation.__init__r+   r:   c              	   C  sP   | j | }|4 I d H  d V  W d   I d H  d S 1 I d H s!w   Y  d S r#   )r=   )r&   r+   r;   r   r   r   r;   P   s
   
.zSimpleEventIsolation.lockc                    s   | j   d S r#   )r=   clearr%   r   r   r   r)   V   s   zSimpleEventIsolation.closer7   )	r   r   r   r'   r   r   r	   r;   r)   r   r   r   r   r<   K   s
    
r<   N)asyncior   collectionsr   
contextlibr   r   dataclassesr   r   typingr   r	   r
   r   r   r   r   aiogram.fsm.stater   aiogram.fsm.storage.baser   r   r   r   r   r    r9   r<   r   r   r   r   <module>   s    $+	