Ë
    ±Œj1  ã                  óæ   — d dl mZ d dlZd dlmZmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZmZmZmZmZmZ d dlmZ 	 	 	 	 dd	„Z ed
¬«       G d„ dee¬«      «       Z G d„ de«      Z G d„ de«      Zy)é    )ÚannotationsN)ÚABCÚabstractmethod)Úversionadded)Úerrors)ÚStorageRegistry)ÚAnyÚ	AwaitableÚCallableÚPÚRÚcast)ÚLazyDependencyc                óD   ‡ — t        j                  ‰ «      dˆ fd„«       }|S )Nc               Ÿ  óÌ   •K  — t        t        | d   «      }	  ‰| i |¤Žƒ d {  –—† S 7 Œ# |j                  $ r(}|j                  rt	        j
                  |«      |‚‚ d }~ww xY w­w)Nr   )r   ÚStorageÚbase_exceptionsÚwrap_exceptionsr   ÚStorageError)ÚargsÚkwargsÚinstanceÚexcÚfns       €úa/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/limits/aio/storage/base.pyÚinnerz_wrap_errors.<locals>.inner   sf   øè ø€ äœ  a¡Ó)ˆð	Ù˜TÐ, VÑ,×,Ð,Ð,ùØ×'Ñ'ò 	Ø×'Ò'Ü×)Ñ)¨#Ó.°CÐ7Øûð	üs0   ƒA$˜* £(¤* §A$¨* ªA!¹#AÁA!Á!A$)r   zP.argsr   zP.kwargsÚreturnr   )Ú	functoolsÚwraps)r   r   s   ` r   Ú_wrap_errorsr       s'   ø€ ô ‡_�_�RÓôó ðð €Ló    z2.1)Úversionc                  óÜ   ‡ — e Zd ZU dZded<   	 dˆ fd„Z	 	 d	 	 	 	 	 	 	 dˆ fd„Zeedd„«       «       Z	eddd„«       Z
edd„«       Zedd	„«       Zedd
„«       Zedd„«       Zedd„«       Zˆ xZS )r   zJ
    Base class to extend when implementing an async storage backend.
    zlist[str] | NoneÚSTORAGE_SCHEMEc                ó�   •— t        ‰| �  di |¤Ž dD ]"  }t        | |t        t	        | |«      «      «       Œ$ t        ‰| �  di |¤Ž y )N>   ÚgetÚincrÚcheckÚclearÚresetÚ
get_expiry© )ÚsuperÚ__init_subclass__Úsetattrr    Úgetattr©Úclsr   ÚmethodÚ	__class__s      €r   r.   zStorage.__init_subclass__.   sK   ø€ Ü‰Ñ!Ñ+ FÒ+ó
ˆFô �C˜¤¬g°c¸6Ó.BÓ!CÕDð
ô 	‰Ñ!Ñ+ FÓ+r!   c                ó0   •— t         ‰| �  «        || _        y)z�
        :param wrap_exceptions: Whether to wrap storage exceptions in
         :exc:`limits.errors.StorageError` before raising it.
        N)r-   Ú__init__r   )ÚselfÚurir   Úoptionsr4   s       €r   r6   zStorage.__init__;   s   ø€ ô 	‰ÑÔØ.ˆÕr!   c                ó   — t         ‚)N©ÚNotImplementedError©r7   s    r   r   zStorage.base_exceptionsH   s
   € ô "Ð!r!   c              ƒ  ó   K  — t         ‚­w)zá
        increments the counter for a given rate limit key

        :param key: the key to increment
        :param expiry: amount in seconds for the key to expire in
        :param amount: the number to increment by
        r;   )r7   ÚkeyÚexpiryÚamounts       r   r'   zStorage.incrM   s   è ø€ ô "Ð!ùó   ‚	c              ƒ  ó   K  — t         ‚­w)zB
        :param key: the key to get the counter value for
        r;   ©r7   r?   s     r   r&   zStorage.getX   ó   è ø€ ô
 "Ð!ùrB   c              ƒ  ó   K  — t         ‚­w)z;
        :param key: the key to get the expiry for
        r;   rD   s     r   r+   zStorage.get_expiry_   rE   rB   c              ƒ  ó   K  — t         ‚­w)z-
        check if storage is healthy
        r;   r=   s    r   r(   zStorage.checkf   rE   rB   c              ƒ  ó   K  — t         ‚­w)z/
        reset storage to clear limits
        r;   r=   s    r   r*   zStorage.resetm   rE   rB   c              ƒ  ó   K  — t         ‚­w)za
        resets the rate limit key

        :param key: the key to clear rate limits for
        r;   rD   s     r   r)   zStorage.cleart   s   è ø€ ô "Ð!ùrB   ©r   r	   r   ÚNone)NF)r8   z
str | Noner   Úboolr9   zfloat | str | boolr   rK   )r   z-type[Exception] | tuple[type[Exception], ...]©é   )r?   Ústrr@   ÚintrA   rP   r   rP   )r?   rO   r   rP   )r?   rO   r   Úfloat)r   rL   )r   z
int | None)r?   rO   r   rK   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r.   r6   Úpropertyr   r   r'   r&   r+   r(   r*   r)   Ú__classcell__©r4   s   @r   r   r   %   sß   ø… ñð %Ó$ØEõ,ð Ø %ð/àð/ð ð/ð &ð	/ð
 
õ/ð Øò"ó ó ð"ð ó"ó ð"ð ò"ó ð"ð ò"ó ð"ð ò"ó ð"ð ò"ó ð"ð ò"ó ô"r!   r   )Ú	metaclassc                  ón   ‡ — e Zd ZdZdˆ fd„Ze	 d	 	 	 	 	 	 	 	 	 dd„«       Ze	 	 	 	 	 	 	 	 dd„«       Zˆ xZS )	ÚMovingWindowSupportzn
    Abstract base class for async storages that support
    the :ref:`strategies:moving window` strategy
    c                ór   •— dD ]"  }t        | |t        t        | |«      «      «       Œ$ t        ‰| �  di |¤Ž y )N>   Úacquire_entryÚget_moving_windowr,   ©r/   r    r0   r-   r.   r1   s      €r   r.   z%MovingWindowSupport.__init_subclass__„   s@   ø€ ó
ˆFô ØØÜœW S¨&Ó1Ó2õð	
ô 	‰Ñ!Ñ+ FÓ+r!   c              ƒ  ó   K  — t         ‚­w)zÖ
        :param key: rate limit key to acquire an entry in
        :param limit: amount of entries allowed
        :param expiry: expiry of the entry
        :param amount: the number of entries to acquire
        r;   ©r7   r?   Úlimitr@   rA   s        r   r^   z!MovingWindowSupport.acquire_entry�   s   è ø€ ô "Ð!ùrB   c              ƒ  ó   K  — t         ‚­w)zí
        returns the starting point and the number of entries in the moving
        window

        :param key: rate limit key
        :param expiry: expiry of entry
        :return: (start of window, number of acquired entries)
        r;   )r7   r?   rc   r@   s       r   r_   z%MovingWindowSupport.get_moving_windowœ   s   è ø€ ô "Ð!ùrB   rJ   rM   ©
r?   rO   rc   rP   r@   rP   rA   rP   r   rL   )r?   rO   rc   rP   r@   rP   r   ztuple[float, int])	rR   rS   rT   rU   r.   r   r^   r_   rX   rY   s   @r   r\   r\   ~   s€   ø„ ñõ

,ð à?@ð	"Øð	"Ø"ð	"Ø,/ð	"Ø9<ð	"à	ò	"ó ð	"ð ð"Øð"Ø"ð"Ø,/ð"à	ò"ó ô"r!   r\   c                  ó|   ‡ — e Zd ZdZdˆ fd„Ze	 d	 	 	 	 	 	 	 	 	 dd„«       Ze	 	 	 	 	 	 d	d„«       Zed
d„«       Zˆ xZ	S )ÚSlidingWindowCounterSupportzw
    Abstract base class for async storages that support
    the :ref:`strategies:sliding window counter` strategy
    c                ór   •— dD ]"  }t        | |t        t        | |«      «      «       Œ$ t        ‰| �  di |¤Ž y )N>   Úget_sliding_windowÚclear_sliding_windowÚacquire_sliding_window_entryr,   r`   r1   s      €r   r.   z-SlidingWindowCounterSupport.__init_subclass__±   s@   ø€ ó
ˆFô
 ØØÜœW S¨&Ó1Ó2õð
ô 	‰Ñ!Ñ+ FÓ+r!   c              ƒ  ó   K  — t         ‚­w)aU  
        Acquire an entry if the weighted count of the current and previous
        windows is less than or equal to the limit

        :param key: rate limit key to acquire an entry in
        :param limit: amount of entries allowed
        :param expiry: expiry of the entry
        :param amount: the number of entries to acquire
        r;   rb   s        r   rk   z8SlidingWindowCounterSupport.acquire_sliding_window_entry¾   s   è ø€ ô" "Ð!ùrB   c              ƒ  ó   K  — t         ‚­w)a¨  
        Return the previous and current window information.

        :param key: the rate limit key
        :param expiry: the rate limit expiry, needed to compute the key in some implementations
        :return: a tuple of (int, float, int, float) with the following information:
          - previous window counter
          - previous window TTL
          - current window counter
          - current window TTL
        r;   ©r7   r?   r@   s      r   ri   z.SlidingWindowCounterSupport.get_sliding_windowÑ   s   è ø€ ô "Ð!ùrB   c              ƒ  ó   K  — y­w)zÚ
        Resets the rate limit key(s) for the sliding window

        :param key: the key to clear rate limits for
        :param expiry: the rate limit expiry, needed to compute the key in some implemenations
        Nr,   rn   s      r   rj   z0SlidingWindowCounterSupport.clear_sliding_windowâ   s   è ø€ ð 	ùs   ‚rJ   rM   re   )r?   rO   r@   rP   r   ztuple[int, float, int, float])r?   rO   r@   rP   r   rK   )
rR   rS   rT   rU   r.   r   rk   ri   rj   rX   rY   s   @r   rg   rg   «   s–   ø„ ñõ
,ð ð ð"àð"ð ð"ð ð	"ð
 ð"ð 
ò"ó ð"ð$ ð"Øð"Ø #ð"à	&ò"ó ð"ð  òó ôr!   rg   )r   úCallable[P, Awaitable[R]]r   rp   )Ú
__future__r   r   Úabcr   r   Údeprecated.sphinxr   Úlimitsr   Úlimits._storage_schemer   Úlimits.typingr	   r
   r   r   r   r   Úlimits.utilr   r    r   r\   rg   r,   r!   r   Ú<module>rx      sz   ðÝ "ã ß #å *å Ý 2÷÷ õ 'ðØ!ðàóñ  �eÔôU"ˆn¨ô U"ó ðU"ôp*"˜#ô *"ôZ? #õ ?r!   