Ë
    3ýj“  ã                   óp  — d dl mZmZ ddlmZmZmZmZ dedefd„Z	 G d„ de«      Z
 G d	„ d
e«      Z G d„ de
«      Z G d„ de
«      Z G d„ de
«      Z G d„ de
«      Z G d„ de
«      Z G d„ de
«      Z G d„ de
«      Z G d„ de«      Z G d„ de
«      Z G d„ de«      Z G d„ d e«      Z G d!„ d"e«      Zy#)$é    )ÚIterableÚUnioné   )ÚAscÚDescÚReducerÚSortDirectionÚnameÚreturnc                 ó2   — | j                  d«      r| S d| z   S )z3Return ``name`` with a single leading ``@`` prefix.ú@)Ú
startswith)r
   s    úX/root/telegram-saas/.venv/lib/python3.12/site-packages/redis/commands/search/reducers.pyÚ_ensure_at_prefixr      s   € à—?‘? 3Ô'ˆ4Ð7¨S°4©ZÐ7ó    c                   ó,   ‡ — e Zd ZdZdeddfˆ fd„Zˆ xZS )ÚFieldOnlyReducerzHSee https://redis.io/docs/interact/search-and-query/search/aggregations/Úfieldr   Nc                 ó2   •— t         ‰| �  |«       || _        y ©N)ÚsuperÚ__init__Ú_field©Úselfr   Ú	__class__s     €r   r   zFieldOnlyReducer.__init__   s   ø€ Ü‰Ñ˜ÔØˆ�r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ústrr   Ú__classcell__©r   s   @r   r   r      s   ø„ ÙRð˜cð  d÷ ñ r   r   c                   ó(   ‡ — e Zd ZdZdZdˆ fd„Zˆ xZS )Úcountz3
    Counts the number of results in the group
    ÚCOUNTc                 ó"   •— t         ‰| �  «        y r   ©r   r   )r   r   s    €r   r   zcount.__init__   s   ø€ Ü‰ÑÕr   )r   N)r   r   r   r    ÚNAMEr   r"   r#   s   @r   r%   r%      s   ø„ ñð €D÷ñ r   r%   c                   ó0   ‡ — e Zd ZdZdZdeddfˆ fd„Zˆ xZS )ÚsumzS
    Calculates the sum of all the values in the given fields within the group
    ÚSUMr   r   Nc                 ó$   •— t         ‰| �  |«       y r   r(   r   s     €r   r   zsum.__init__%   ó   ø€ Ü‰Ñ˜Õr   ©r   r   r   r    r)   r!   r   r"   r#   s   @r   r+   r+      ó'   ø„ ñð €Dð ˜cð   d÷  ñ  r   r+   c                   ó0   ‡ — e Zd ZdZdZdeddfˆ fd„Zˆ xZS )ÚminzK
    Calculates the smallest value in the given field within the group
    ÚMINr   r   Nc                 ó$   •— t         ‰| �  |«       y r   r(   r   s     €r   r   zmin.__init__0   r.   r   r/   r#   s   @r   r2   r2   )   r0   r   r2   c                   ó0   ‡ — e Zd ZdZdZdeddfˆ fd„Zˆ xZS )ÚmaxzJ
    Calculates the largest value in the given field within the group
    ÚMAXr   r   Nc                 ó$   •— t         ‰| �  |«       y r   r(   r   s     €r   r   zmax.__init__;   r.   r   r/   r#   s   @r   r6   r6   4   r0   r   r6   c                   ó0   ‡ — e Zd ZdZdZdeddfˆ fd„Zˆ xZS )ÚavgzG
    Calculates the mean value in the given field within the group
    ÚAVGr   r   Nc                 ó$   •— t         ‰| �  |«       y r   r(   r   s     €r   r   zavg.__init__F   r.   r   r/   r#   s   @r   r:   r:   ?   r0   r   r:   c                   ó0   ‡ — e Zd ZdZdZdeddfˆ fd„Zˆ xZS )Útolistz6
    Returns all the matched properties in a list
    ÚTOLISTr   r   Nc                 ó$   •— t         ‰| �  |«       y r   r(   r   s     €r   r   ztolist.__init__Q   r.   r   r/   r#   s   @r   r>   r>   J   ó'   ø„ ñð €Dð ˜cð   d÷  ñ  r   r>   c                   ó0   ‡ — e Zd ZdZdZdeddfˆ fd„Zˆ xZS )Úcount_distinctzs
    Calculate the number of distinct values contained in all the results in
    the group for the given field
    ÚCOUNT_DISTINCTr   r   Nc                 ó$   •— t         ‰| �  |«       y r   r(   r   s     €r   r   zcount_distinct.__init__]   r.   r   r/   r#   s   @r   rC   rC   U   s'   ø„ ñð
 €Dð ˜cð   d÷  ñ  r   rC   c                   ó   — e Zd ZdZdZy)Úcount_distinctishzÀ
    Calculate the number of distinct values contained in all the results in the
    group for the given field. This uses a faster algorithm than
    `count_distinct` but is less accurate
    ÚCOUNT_DISTINCTISHN)r   r   r   r    r)   © r   r   rG   rG   a   s   „ ñð �Dr   rG   c                   ó4   ‡ — e Zd ZdZdZdededdfˆ fd„Zˆ xZS )Úquantilezp
    Return the value for the nth percentile within the range of values for the
    field within the group.
    ÚQUANTILEr   Úpctr   Nc                 óF   •— t         ‰| �  |t        |«      «       || _        y r   )r   r   r!   r   )r   r   rM   r   s      €r   r   zquantile.__init__s   s   ø€ Ü‰Ñ˜¤ C£Ô)Øˆ�r   )	r   r   r   r    r)   r!   Úfloatr   r"   r#   s   @r   rK   rK   k   s.   ø„ ñð
 €Dð˜cð ¨ð °$÷ ñ r   rK   c                   ó0   ‡ — e Zd ZdZdZdeddfˆ fd„Zˆ xZS )ÚstddevzG
    Return the standard deviation for the values within the group
    ÚSTDDEVr   r   Nc                 ó$   •— t         ‰| �  |«       y r   r(   r   s     €r   r   zstddev.__init__   r.   r   r/   r#   s   @r   rQ   rQ   x   rA   r   rQ   c                   ó>   ‡ — e Zd ZdZdZdedeeef   ddfˆ fd„Z	ˆ xZ
S )Úfirst_valuezR
    Selects the first value within the group according to sorting parameters
    ÚFIRST_VALUEr   Úbyfieldsr   Nc                 ó  •— g }t        |«      dk(  r2t        |d   t        «      rt        |d   t        «      r |d   |«      g}|D ]  }||j
                  |j                  gz  }Œ |g}|r	|dg|z   z  }t        ‰| �   |Ž  || _	        y)aô  
        Selects the first value of the given field within the group.

        ### Parameter

        - **field**: Source field used for the value
        - **byfields**: How to sort the results. This can be either the
            *class* of `aggregation.Asc` or `aggregation.Desc` in which
            case the field `field` is also used as the sort input.

            `byfields` can also be one or more *instances* of `Asc` or `Desc`
            indicating the sort order for these fields
        r   r   ÚBYN)
ÚlenÚ
isinstanceÚtypeÚ
issubclassr	   r   Ú	DIRSTRINGr   r   r   )r   r   rW   Ú	fieldstrsÚfÚargsr   s         €r   r   zfirst_value.__init__Š   sœ   ø€ ð ˆ	ä�‹M˜QÒÜ˜8 A™;¬Ô-Ü˜8 A™;¬Ô6à#˜ ™ EÓ*Ð+ˆHàò 	0ˆAØ˜!Ÿ'™' 1§;¡;Ð/Ñ/‰Ið	0ð ˆwˆÙØ�T�F˜YÑ&Ñ&ˆDÜ‰Ñ˜$ÑØˆ�r   )r   r   r   r    r)   r!   r   r   r   r   r"   r#   s   @r   rU   rU   ƒ   s7   ø„ ñð €Dð˜cð ¨e°C¸°IÑ.>ð À4÷ ñ r   rU   c                   ó4   ‡ — e Zd ZdZdZdededdfˆ fd„Zˆ xZS )Úrandom_samplezT
    Returns a random sample of items from the dataset, from the given property
    ÚRANDOM_SAMPLEr   Úsizer   Nc                 óF   •— |t        |«      g}t        ‰| �  |Ž  || _        y)z
        ### Parameter

        **field**: Field to sample from
        **size**: Return this many items (can be less)
        N)r!   r   r   r   )r   r   re   ra   r   s       €r   r   zrandom_sample.__init__²   s'   ø€ ð ”s˜4“yÐ!ˆÜ‰Ñ˜$ÑØˆ�r   )	r   r   r   r    r)   r!   Úintr   r"   r#   s   @r   rc   rc   «   s.   ø„ ñð €Dð	˜cð 	¨ð 	°÷ 	ñ 	r   rc   c                   ó€   ‡ — e Zd ZdZdZ	 	 	 	 d
deee   z  dedee	z  eee	z     z  dz  de
eef   dz  ddf
ˆ fd	„Zˆ xZS )Úcollecta„  
    Gathers the rows of each ``GROUPBY`` group, projects a chosen set of
    fields from every row, optionally deduplicates, sorts, and limits them,
    and returns them as an array of per-entry maps under the reducer alias.

    ``COLLECT`` is a preview feature gated behind
    ``search-enable-unstable-features``. See
    `FT.AGGREGATE <https://redis.io/commands/ft.aggregate>`_.
    ÚCOLLECTNÚfieldsÚdistinctÚsort_byÚlimitr   c                 ó`  •— g }|dk(  r|ddgz  }nqt        |t        «      r|gn
t        |«      }|rt        d„ |D «       «      rt	        d«      ‚|D �cg c]  }t        |«      ‘Œ }}|dt        t        |«      «      g|z   z  }|r|dgz  }|�qt        |t        t        f«      r|gn|}g }	|D ]&  }
|	t        |
j                  «      |
j                  gz  }	Œ( |	st	        d«      ‚|dt        t        |	«      «      g|	z   z  }|�|\  }}|d	t        |«      t        |«      gz  }t        ‰| �0  |Ž  yc c}w )
aÔ  
        ### Parameters

        - **fields**: The fields to project from each collected row. Either the
            literal ``"*"`` (project every field present in the pipeline at this
            stage) or a field name / iterable of field names. Names are
            normalized to a single leading ``@`` on the wire; output map keys
            are the bare names.
        - **distinct**: When ``True``, emit ``DISTINCT`` to deduplicate entries
            with identical projected fields. Forward-compatible: this option is
            not yet implemented by the server and currently produces a server
            error when sent.
        - **sort_by**: An ``Asc``/``Desc`` instance or an iterable of them, used
            to order the collected entries within each group.
        - **limit**: An ``(offset, count)`` pair. Returns at most ``count``
            entries per group after skipping ``offset``. With ``sort_by`` this
            acts as a top-N selection.
        Ú*ÚFIELDSc              3   ó>   K  — | ]  }|j                  «        –— Œ y ­wr   )Ústrip)Ú.0Úns     r   ú	<genexpr>z#collect.__init__.<locals>.<genexpr>ë   s   è ø€ Ò=°! A§G¡G£I¤Ñ=ùs   ‚z7collect fields must be '*' or a non-empty list of namesÚDISTINCTNz/collect sort_by must contain at least one fieldÚSORTBYÚLIMIT)r[   r!   ÚlistÚanyÚ
ValueErrorr   rZ   r   r   r   r^   r   r   )r   rk   rl   rm   rn   ra   Únamesru   Úsort_fieldsÚ	sort_argsr`   Úoffsetr%   r   s                €r   r   zcollect.__init__Ë   sX  ø€ ð2 ˆð �SŠ=Ø�X˜s�OÑ#‰Dä *¨6´3Ô 7�V‘H¼TÀ&»\ˆEÙœCÑ=°uÔ=Ô=Ü ØMóð ð 49Ö9¨aÔ& qÕ)Ð9ˆEÐ9Ø�Xœs¤3 u£:›Ð/°%Ñ7Ñ7ˆDñ Ø�Z�LÑ ˆDð ÐÜ'1°'¼CÄ¸;Ô'G˜7™)ÈWˆKØ#%ˆIØ ò G�ØÔ/°·±Ó8¸!¿+¹+ÐFÑF‘	ðGáÜ Ð!RÓSÐSØ�Xœs¤3 y£>Ó2Ð3°iÑ?Ñ?ˆDð ÐØ!‰MˆF�EØ�Wœc &›k¬3¨u«:Ð6Ñ6ˆDä‰Ñ˜$Òùò- :s   ÁD+)rp   FNN)r   r   r   r    r)   r!   r   Úboolr   r   Útuplerg   r   r"   r#   s   @r   ri   ri   ¾   s„   ø„ ñð €Dð '*ØØ<@Ø(,ñ: à�h˜s‘mÑ#ð: ð ð: ð �t‘˜h s¨T¡zÑ2Ñ2°TÑ9ð	: ð
 �S˜#�X‰ Ñ%ð: ð 
÷: ñ : r   ri   N)Útypingr   r   Úaggregationr   r   r   r	   r!   r   r   r%   r+   r2   r6   r:   r>   rC   rG   rK   rQ   rU   rc   ri   rI   r   r   ú<module>r…      sÔ   ðß "ç :Ó :ð8˜Cð 8 Có 8ô
�wô ôˆGô ô Ð
ô  ô Ð
ô  ô Ð
ô  ô Ð
ô  ô Ðô  ô	 Ð%ô 	 ôÐ(ô ô
ˆwô 
ô Ðô  ô%�'ô %ôP�Gô ô&G ˆgõ G r   