
    Dh%                     |   d Z ddlZddlZddlmZ ddlmZmZmZm	Z	m
Z
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 ddlmZmZmZmZmZmZmZmZm Z m!Z!m"Z"  G d	 d
e      Z#deee      de$fdZ%deee      de$fdZ&dee   dee   fdZ'edee   defd       Z(edee   dedeeef   fd       Z(e#jR                  fdee   deee#f   deeef   fdZ(dee   dee   fdZ*dee   deedf   fdZ+dee   dee   fdZ,	 d5dee   de-deee-ef      fdZ.de	egef   dee   dee   fdZ/edddee   dee	   defd       Z0edddee   dedee	   deeef   fd       Z0dee   d edefd!Z0edddee   dee	   defd"       Z1edddee   dedee	   deeef   fd#       Z1dee   d edefd$Z1d6dee   dee   defd%Z2ed&ee   deee      fd'       Z3ed&ee   d(ee   deeeef      fd)       Z3ed&ee   d(ee   d*ee    deeeee f      fd+       Z3ed&ee   d(ee   d*ee    d,ee!   deeeee e!f      f
d-       Z3ed&ee   d(ee   d*ee    d,ee!   d.ee"   deeeee e!e"f      fd/       Z3ed&ee   d(ee   d*ee   d,ee   d.ee   d0ee   d1ee   deeedf      fd2       Z3d3ee   deeedf      fd4Z3y)7av  
Async-compatible versions of builtin functions for iterables.

These functions intentionally shadow their builtins counterparts,
enabling use with both standard iterables and async iterables, without
needing to use if/else clauses or awkward logic.  Standard iterables
get wrapped in async generators, and all functions are designed for
use with `await`, `async for`, etc.
    N)Enum)AnyAsyncIterableAsyncIteratorCallablecastIterableListOptionaloverloadSetTupleUnion   )asyncio)maybe_await	Orderable)AnyIterableAnyIteratorAnyStopMaybeAwaitableRTT1T2T3T4T5c                       e Zd ZdZ e       Zy)Sentinelz
    :meta private:
    N)__name__
__module____qualname____doc__objectMISSING     w/var/www/fastuser/data/www/generator.snapmosaic.io/flask_app/venv/lib/python3.12/site-packages/aioitertools/builtins.pyr    r    1   s     hGr(   r    itrreturnc                 n   K   t        j                  t        j                  |        d{         S 7 w)z
    Return True if all values are truthy in a mixed iterable, else False.
    The iterable will be fully consumed and any awaitables will
    automatically be awaited.

    Example::

        if await all(it):
            ...

    N)builtinsallait_asynciogather_iterr*   s    r)   r.   r.   9   (      <<k55c::;;:   (53	5c                 n   K   t        j                  t        j                  |        d{         S 7 w)z
    Return True if any value is truthy in a mixed iterable, else False.
    The iterable will be fully consumed and any awaitables will
    automatically be awaited.

    Example::

        if await any(it):
            ...

    N)r-   anyr/   r0   r1   s    r)   r5   r5   H   r2   r3   c                      t         t              r S t         t              r j                         S dt        t           f fd} |       S )a`  
    Get an async iterator from any mixed iterable.

    Async iterators will be returned directly.
    Async iterables will return an async iterator.
    Standard iterables will be wrapped in an async generator yielding
    each item in the iterable in the same order.

    Examples::

        async for value in iter(range(10)):
            ...

    r+   c                 P   K   t        t        t                 D ]  } |  	 y wN)r   r	   r   )itemr*   s    r)   genziter.<locals>.genl   s&     !c* 	DJ	s   #&)
isinstancer   r   	__aiter__r   )r*   r:   s   ` r)   iterr=   W   sD     #}%
#}%}}}Q'  5Lr(   c                    K   y wr8   r'   r1   s    r)   nextr?   s   	        defaultc                    K   y wr8   r'   r*   rB   s     r)   r?   r?   x   r@   rA   c                    K   	 t        | t              r| j                          d{   S 	 t        j                  |       S 7 # t
        $ r t        w xY w# t        $ r |t        j                  u r |cY S w xY ww)z
    Return the next item of any mixed iterator.

    Calls builtins.next() on standard iterators, and awaits itr.__anext__()
    on async iterators.

    Example::

        value = await next(it)

    N)	r;   r   	__anext__r-   r?   StopIterationStopAsyncIterationr    r&   rD   s     r)   r?   r?   }   sw     c=)((	%==%% )  	%$$	% h&&&sN   A;#A AA A;A A;A AA A85A;7A88A;c                 V   K   t        |       2 cg c3 d{   }|7 6 c}S c c}w w)z
    Consume a mixed iterable and return a list of items in order.

    Example::

        await list(range(5))
        -> [0, 1, 2, 3, 4]

    Nr=   r*   r9   s     r)   listrL      '      $(9--4D----$   )$ 
 $ $).c                 Z   K   t        j                  t        |        d{         S 7 w)z
    Consume a mixed iterable and return a tuple of items in order.

    Example::

        await tuple(range(5))
        -> (0, 1, 2, 3, 4)

    N)r-   tuplerL   r1   s    r)   rP   rP      s      >>S	/**/s   +)	+c                 V   K   t        |       2 ch c3 d{   }|7 6 c}S c c}w w)z
    Consume a mixed iterable and return a set of items.

    Example::

        await set([0, 1, 2, 3, 0, 1, 2, 3])
        -> {0, 1, 2, 3}

    NrJ   rK   s     r)   setrR      rM   rN   startc                X   K   |}t        |       2 3 d{   }||f |dz  }7 6 yw)z
    Consume a mixed iterable and yield the current index and item.

    Example::

        async for index, value in enumerate(...):
            ...

    Nr   rJ   )r*   rS   indexr9   s       r)   	enumeraterV      s;      E3i  dTk
is   *(&(*(*fnc                x   K   t        |      2 3 d{   }t         | |             d{    &7 !7 
6 yw)z
    Modify item of a mixed iterable using the given function or coroutine.

    Example::

        async for response in map(func, data):
            ...

    N)r=   r   )rW   r*   r9   s      r)   maprY      s<      3i * *d4)))*)  s(   :848:6:8::)keyrZ   c                   K   y wr8   r'   r*   rZ   s     r)   maxr]            	rA   c                   K   y wr8   r'   r*   rB   rZ   s      r)   r]   r]      r^   rA   kwargsc                 z  K   |D ]  }|dvst        d| d       |j                  dd      }t        |       }	 t        |       d{   }|r ||      }|r|2 3 d{   } ||      }|kD  s|}|}|2 3 d{   }||kD  s|}7 B# t        $ r d|v r|d   cY S t        d      w xY w7 P6 |S 7 76 |S w)z
    Return the largest item in an iterable or the largest of two or more arguments.

    Example::

        await max(range(5))
        -> 4

    rZ   rB   kwarg  not supportedrZ   NrB   ,iterable is empty and no default value given
ValueErrorgetr=   r?   rH   	r*   ra   kkeyfuncitvaluevkeyr9   ikeys	            r)   r]   r]            9&&vaS7889 jj%G	cBI2h5>D  	 	$4=Dd{  	 	$e|'   I)$$GHHI	" L		" L   
B;-B;B 	B
B B;B3 B1!B3$B;3B;:B8>B6?B8B;	B;B B. B;"B..B;1B33B;6B88B;c                   K   y wr8   r'   r\   s     r)   minrt     r^   rA   c                   K   y wr8   r'   r`   s      r)   rt   rt   $  r^   rA   c                 z  K   |D ]  }|dvst        d| d       |j                  dd      }t        |       }	 t        |       d{   }|r ||      }|r|2 3 d{   } ||      }|k  s|}|}|2 3 d{   }||k  s|}7 B# t        $ r d|v r|d   cY S t        d      w xY w7 P6 |S 7 76 |S w)z
    Return the smallest item in an iterable or the smallest of two or more arguments.

    Example::

        await min(range(5))
        -> 0

    rc   rd   re   rZ   NrB   rf   rg   rj   s	            r)   rt   rt   +  rq   rr   c                 r   K   |t        t        d      }n|}t        |       2 3 d{   }||z  }7 
6 |S w)z
    Compute the sum of a mixed iterable, adding each value with the start value.

    Example::

        await sum(generator())
        -> 1024

    Nr   )r   r   r=   )r*   rS   rn   r9   s       r)   sumrx   X  sH      }Q
3i  di Ls   !7424747__iter1c                      y r8   r'   )ry   s    r)   zipr{   n  s    r(   __iter2c                      y r8   r'   )ry   r|   s     r)   r{   r{   s       	r(   __iter3c                      y r8   r'   )ry   r|   r   s      r)   r{   r{   z  r~   r(   __iter4c                      y r8   r'   )ry   r|   r   r   s       r)   r{   r{     s     	r(   __iter5c                      y r8   r'   )ry   r|   r   r   r   s        r)   r{   r{     s     	r(   __iter6__iterablesc                      y r8   r'   )ry   r|   r   r   r   r   r   s          r)   r{   r{     s     	r(   itrsc                 2  K   | D cg c]  }t        |       }}	 t        j                  |D cg c]  }|j                          c}ddi d{   }t	        j
                  d |D              ryt	        j                  |       oc c}w c c}w 7 Dw)z
    Yield a tuple of items from mixed iterables until the shortest is consumed.

    Example::

        async for a, b, c in zip(i, j, k):
            ...

    Treturn_exceptionsNc              3   <   K   | ]  }t        |t                y wr8   )r;   r   ).0vs     r)   	<genexpr>zzip.<locals>.<genexpr>  s     ?1
1g.?s   )r=   r   gatherrF   r-   r5   rP   )r   r*   itsrm   valuess        r)   r{   r{     s      ;?$?3T#Y$?C$?
~~'*+blln+
?C
 
 <<???nnV$$  %@ ,
s'   BBBB
BBAB)r   r8   )4r$   r   r-   enumr   typingr   r   r   r   r   r	   r
   r   r   r   r   r    r/   helpersr   r   typesr   r   r   r   r   r   r   r   r   r   r   r    boolr.   r5   r=   r?   r&   rL   rP   rR   intrV   rY   r]   rt   rx   r{   r'   r(   r)   <module>r      s         % +   t <;~c23 < <<;~c23 < <k!n q!1 8 
KN q  
 
KO b U2r6]  

 :B9I9I	R#(X#6
2r6]8
.KN 
.tAw 
.+[^ +af +
.;q> 
.c!f 
. '(	Q #5a=!$*(A36" *Q *M!<L * 
>B		Y		)1();		 
	 
JN		Y		-.	5=h5G	
9a<	 
	*;y) *S *S *Z 
>B		Y		)1();		 
	 
JN		Y		-.	5=h5G	
9a<	 
	*;y) *S *S *Z;q> (1+  , 
	R 	]59%= 	 
	 
	_	'22	5R=!	 
	 
	_	'22	ALR	5R$%	 
	 
	_	_	 _	 _		
 5RR()	 
	 
	_	_	 _	 _		
 _	 5RR+,-	 
	 
						 		 			
 		 		 c"		 5c?#		 
		%[% %-c3h*H %r(   