
    h1                        d dl Z d dlZd dlmZ d dlmZmZ 	 	 d dlZn# e	$ r d dlZY nw xY wdZ
n# e	$ r dZ
Y nw xY wdZ	 	 ddee         ded	efd
Z G d d          Z G d de          Z G d de          Z G d d          ZdS )    N)Executor)OptionalcastTFi   encodingsuppress_deflate_headerreturnc                 b    | dk    rdt           j        z   S |rt           j         nt           j        S )Ngzip   )zlib	MAX_WBITS)r   r   s     [/var/www/html/prod/cognitive/venv/lib/python3.11/site-packages/aiohttp/compression_utils.pyencoding_to_moder      s1     6DN""5IDN??4>I    c                   @    e Zd Zdefdedee         dee         fdZdS )ZlibBaseHandlerNmodeexecutormax_sync_chunk_sizec                 0    || _         || _        || _        d S N)_mode	_executor_max_sync_chunk_size)selfr   r   r   s       r   __init__zZlibBaseHandler.__init__   s      
!$7!!!r   )__name__
__module____qualname__MAX_SYNC_CHUNK_SIZEintr   r   r    r   r   r   r      sZ         (,-@	8 88 8$8 &c]	8 8 8 8 8 8r   r   c                        e Zd Zddddej        defdee         dedee	         dee	         de	dee
         d	ee	         f fd
ZdedefdZdedefdZej        fde	defdZ xZS )ZLibCompressorNFr   r   levelwbitsstrategyr   r   c                 ,   t                                          |t          ||          n|||           |!t          j        | j        |          | _        n!t          j        | j        ||          | _        t          j                    | _	        d S )Nr   r   r   )r&   r'   )r&   r'   r%   )
superr   r   r   compressobjr   _compressorasyncioLock_compress_lock)	r   r   r   r%   r&   r'   r   r   	__class__s	           r   r   zZLibCompressor.__init__*   s     	 = !+BCCC 3 	 	
 	
 	
 =#/dj8TTTD#/j85     D &lnnr   datar   c                 6    | j                             |          S r   )r,   compressr   r1   s     r   compress_synczZLibCompressor.compress_syncE   s    ((...r   c                 r  K   | j         4 d{V  | j        gt          |          | j        k    rOt          j                                        | j        | j        j        |           d{V cddd          d{V  S | 	                    |          cddd          d{V  S # 1 d{V swxY w Y   dS )aC  Compress the data and returned the compressed bytes.

        Note that flush() must be called after the last call to compress()

        If the data size is large than the max_sync_chunk_size, the compression
        will be done in the executor. Otherwise, the compression will be done
        in the event loop.
        N)
r/   r   lenr-   get_running_looprun_in_executorr   r,   r3   r5   r4   s     r   r3   zZLibCompressor.compressH   s      & 	, 	, 	, 	, 	, 	, 	, 	, )5II 999$577GGND$4$=t       	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, %%d++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,s   AB&?B&&
B03B0r   c                 6    | j                             |          S r   )r,   flush)r   r   s     r   r;   zZLibCompressor.flush_   s    %%d+++r   )r   r   r   r   Z_DEFAULT_STRATEGYr    r   strboolr!   r   r   bytesr5   r3   Z_FINISHr;   __classcell__r0   s   @r   r$   r$   )   s'        #'(-##/'+-@- -3-- "&- }	-
 }- - 8$- &c]- - - - - -6/% /E / / / /,5 ,U , , , ,. !% , ,# ,% , , , , , , , ,r   r$   c            
            e Zd Zdddefdee         dedee         dee         f fdZ	dd	e
d
ede
fdZdd	e
d
ede
fdZddede
fdZedefd            Zede
fd            Zede
fd            Z xZS )ZLibDecompressorNFr   r   r   r   c                     t                                          t          ||          ||           t          j        | j                  | _        d S )Nr)   )r&   )r*   r   r   r   decompressobjr   _decompressor)r   r   r   r   r   r0   s        r   r   zZLibDecompressor.__init__d   sZ     	!(,CDD 3 	 	
 	
 	

 "/djAAAr   r   r1   
max_lengthr   c                 8    | j                             ||          S r   )rG   
decompressr   r1   rH   s      r   decompress_syncz ZLibDecompressor.decompress_syncr   s    !,,T:>>>r   c                    K   | j         Vt          |          | j         k    r>t          j                                        | j        | j        j        ||           d{V S |                     ||          S )zDecompress the data and return the decompressed bytes.

        If the data size is large than the max_sync_chunk_size, the decompression
        will be done in the executor. Otherwise, the decompression will be done
        in the event loop.
        N)	r   r7   r-   r8   r9   r   rG   rJ   rL   rK   s      r   rJ   zZLibDecompressor.decompressu   s       %1D		D555 133CC 2 =tZ         ##D*555r   lengthc                 t    |dk    r| j                             |          n| j                                         S )Nr   )rG   r;   )r   rN   s     r   r;   zZLibDecompressor.flush   s=     zz $$V,,,#))++	
r   c                     | j         j        S r   )rG   eofr   s    r   rQ   zZLibDecompressor.eof   s    !%%r   c                     | j         j        S r   )rG   unconsumed_tailrR   s    r   rT   z ZLibDecompressor.unconsumed_tail   s    !11r   c                     | j         j        S r   )rG   unused_datarR   s    r   rV   zZLibDecompressor.unused_data   s    !--r   )r   )r   r   r   r    r   r=   r>   r   r!   r   r?   rL   rJ   r;   propertyrQ   rT   rV   rA   rB   s   @r   rD   rD   c   s        #'(-'+-@B B3-B "&B 8$	B
 &c]B B B B B B? ?E ?s ?5 ? ? ? ?6 6U 6 6E 6 6 6 6 
 
C 
 
 
 
 
 &T & & & X& 2 2 2 2 X2 .U . . . X. . . . .r   rD   c                   2    e Zd ZddZdedefdZdefdZdS )BrotliDecompressorr   Nc                 b    t           st          d          t          j                    | _        d S )NzIThe brotli decompression is not available. Please install `Brotli` module)
HAS_BROTLIRuntimeErrorbrotliDecompressor_objrR   s    r   r   zBrotliDecompressor.__init__   s7     	1   '))			r   r1   c                     t          | j        d          r-t          t          | j                            |                    S t          t          | j                            |                    S )NrJ   )hasattrr_   r   r?   rJ   processr4   s     r   rL   z"BrotliDecompressor.decompress_sync   sV    49l++ 	;ty33D99:::E49,,T22333r   c                     t          | j        d          r,t          t          | j                                                  S dS )Nr;   r   )ra   r_   r   r?   r;   rR   s    r   r;   zBrotliDecompressor.flush   s7    49g&& 	2ty00111sr   )r   N)r   r   r   r   r?   rL   r;   r"   r   r   rY   rY      se        * * * *4E 4e 4 4 4 4
u      r   rY   )NF)r-   r   concurrent.futuresr   typingr   r   
brotlicffir]   ImportErrorr[   r    r=   r>   r!   r   r   r$   rD   rY   r"   r   r   <module>rh      s     ' ' ' ' ' ' ! ! ! ! ! ! ! !#####    JJ   JJJ   #$)J JsmJ!J 	J J J J	8 	8 	8 	8 	8 	8 	8 	87, 7, 7, 7, 7,_ 7, 7, 7,t3. 3. 3. 3. 3. 3. 3. 3.l         s     0 	*0 *0 ::