� D�g1���ddlZddlZddlmZddlmZmZ ddlZn#e $rddlZYnwxYwdZ n #e $rdZ YnwxYwdZ ddee de d efd �ZGd �d ��ZGd �de��ZGd�de��ZGd�d��ZdS)�N)�Executor)�Optional�castTFi�encoding�suppress_deflate_header�returnc�b�|dkrdtjzS|r tj n tjS)N�gzip�)�zlib� MAX_WBITS)rrs �i/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/aiohttp/compression_utils.py�encoding_to_moders1���6����D�N�"�"�5� I�D�N�?�?�4�>�I�c�@�eZdZdefdedeedeefd�ZdS)�ZlibBaseHandlerN�mode�executor�max_sync_chunk_sizec�0�||_||_||_dS�N)�_mode� _executor�_max_sync_chunk_size)�selfrrrs r�__init__zZlibBaseHandler.__init__s �� �� �!���$7��!�!�!r)�__name__� __module__� __qualname__�MAX_SYNC_CHUNK_SIZE�intrrr�rrrrsZ������(,�-@� 8�8��8��8�$�8�&�c�]� 8�8�8�8�8�8rrc����eZdZddddejdefdeededee dee de dee d ee f�fd � Z d e d e fd �Z d e d e fd�Zejfde d e fd�Z�xZS)�ZLibCompressorNFrr�level�wbits�strategyrrc�,��t���|�t||��n|||���|�!tj|j|���|_n!tj|j||���|_tj��|_ dS)N�rrr)r&r')r&r'r%) �superrrr � compressobjr� _compressor�asyncio�Lock�_compress_lock) rrrr%r&r'rr� __class__s �rrzZLibCompressor.__init__*s���� ������=�!��+B�C�C�C��� 3� � � � � �=�#�/�d�j�8�T�T�T�D� � �#�/��j�8�5� � � �D� �&�l�n�n����r�datarc�6�|j�|��Sr)r,�compress�rr1s r� compress_synczZLibCompressor.compress_syncEs����(�(��.�.�.rc��rK�|j4�d{V��|j�gt|��|jkrOtj���|j|jj|���d{V��cddd���d{V��S|� |��cddd���d{V��S#1�d{V��swxYwYdS)aCCompress 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_executorrr,r3r5r4s rr3zZLibCompressor.compressHs������&� ,� ,� ,� ,� ,� ,� ,� ,� �)�5���I�I�� 9�9�9�$�5�7�7�G�G��N�D�$4�$=�t��������� ,� ,� ,� ,� ,� ,� ,� ,� ,� ,� ,� ,� ,� ,��%�%�d�+�+� ,� ,� ,� ,� ,� ,� ,� ,� ,� ,� ,� ,� ,� ,� ,� ,� ,� ,� ,� ,� ,� ,� ,� ,���� ,� ,� ,� ,� ,� ,s�AB&�?B&�& B0�3B0rc�6�|j�|��Sr)r,�flush)rrs rr;zZLibCompressor.flush_s����%�%�d�+�+�+r)rrrr �Z_DEFAULT_STRATEGYr r�str�boolr!rr�bytesr5r3�Z_FINISHr;� __classcell__�r0s@rr$r$)s'�������#'�(-�#�#��/�'+�-@�-�-��3�-�-�"&�-���}� -� ��}� -� � -��8�$�-�&�c�]�-�-�-�-�-�-�6/�%�/�E�/�/�/�/�,�5�,�U�,�,�,�,�.!%� �,�,�#�,�%�,�,�,�,�,�,�,�,rr$c ����eZdZdddefdeededeedeef�fd� Z dd e d ed e fd �Z dd e d ed e fd �Z dded e fd�Z ed efd���Zed e fd���Zed e fd���Z�xZS)�ZLibDecompressorNFrrrrc���t���t||��||���tj|j���|_dS)Nr))r&)r*rrr � decompressobjr� _decompressor)rrrrrr0s �rrzZLibDecompressor.__init__dsZ��� �����!�(�,C�D�D�� 3� � � � � "�/�d�j�A�A�A����rrr1� max_lengthrc�8�|j�||��Sr)rG� decompress�rr1rHs r�decompress_syncz ZLibDecompressor.decompress_syncrs���!�,�,�T�:�>�>�>rc���K�|j�Vt|��|jkr>tj���|j|jj||���d{V��S|�||��S)z�Decompress 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) rr7r-r8r9rrGrJrLrKs rrJzZLibDecompressor.decompressus����� � %� 1��D� � �D�5�5�5� �1�3�3�C�C���� 2� =�t�Z��������� ��#�#�D�*�5�5�5r�lengthc�t�|dkr|j�|��n|j���S)Nr)rGr;)rrNs rr;zZLibDecompressor.flush�s=����z�z� � � $� $�V� ,� ,� ,��#�)�)�+�+� rc��|jjSr)rG�eof�rs rrQzZLibDecompressor.eof�s���!�%�%rc��|jjSr)rG�unconsumed_tailrRs rrTz ZLibDecompressor.unconsumed_tail�s���!�1�1rc��|jjSr)rG� unused_datarRs rrVzZLibDecompressor.unused_data�s���!�-�-r)r)rrrr rr=r>rr!rr?rLrJr;�propertyrQrTrVrArBs@rrDrDcs��������#'�(-�'+�-@� B� B��3�-� B�"&� B��8�$� B� &�c�]� B� B� B� B� B� B�?�?�E�?�s�?�5�?�?�?�?�6�6�U�6��6�E�6�6�6�6�  � �C� �� � � � ��&�T�&�&�&��X�&��2��2�2�2��X�2��.�U�.�.�.��X�.�.�.�.�.rrDc�2�eZdZdd�Zdedefd�Zdefd�ZdS)�BrotliDecompressorrNc�b�tstd���tj��|_dS)NzIThe brotli decompression is not available. Please install `Brotli` module)� HAS_BROTLI� RuntimeError�brotli� Decompressor�_objrRs rrzBrotliDecompressor.__init__�s7��� ��1��� ��'�)�)�� � � rr1c���t|jd��r-tt|j�|����Stt|j�|����S)NrJ)�hasattrr_rr?rJ�processr4s rrLz"BrotliDecompressor.decompress_sync�sV�� �4�9�l� +� +� ;���t�y�3�3�D�9�9�:�:� :��E�4�9�,�,�T�2�2�3�3�3rc��t|jd��r,tt|j�����SdS)Nr;r)rar_rr?r;rRs rr;zBrotliDecompressor.flush�s7�� �4�9�g� &� &� 2���t�y���0�0�1�1� 1��sr)rN)rrrrr?rLr;r"rrrYrY�se������*�*�*�*�4�E�4�e�4�4�4�4� �u������rrY)NF)r-r �concurrent.futuresr�typingrr� brotlicffir]� ImportErrorr[r r=r>r!rrr$rDrYr"rr�<module>rhs������� � � � �'�'�'�'�'�'�!�!�!�!�!�!�!�!���#�#�#�#�#�� ����� � � � � ������J�J�������J�J�J�������#�$)�J�J��s�m�J�!�J� �J�J�J�J� 8� 8� 8� 8� 8� 8� 8� 8�7,�7,�7,�7,�7,�_�7,�7,�7,�t3.�3.�3.�3.�3.��3.�3.�3.�l���������s ��0� *�0�*�0�:�:
Memory