o �J�h /� @s�dZddlmZddlZddlZddlZddlZddlmZzddl Z Wne y?zddl Z Wn e y<dZ YnwYnwzddl Z Wn e yQdZ YnwGdd�d�Z Gdd �d e �ZGd d �d e �ZGd d �d e �ZGdd�de �ZGdd�de �ZGdd�de �ZGdd�d�ZGdd�d�ZGdd�d�ZGdd�d�Zeeeeed�Ze dur�e�d�e dur�e�d�dSdS)zq Handlers for Content-Encoding. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding �)� annotationsN�)� DecodingErrorc@s eZdZd dd�Zd dd�ZdS) �ContentDecoder�data�bytes�returncC�t���N��NotImplementedError��selfr�r�MC:\pinokio\api\whisper-webui.git\app\env\lib\site-packages\httpx\_decoders.py�decode%�zContentDecoder.decodecCr r r �rrrr�flush(rzContentDecoder.flushN�rrrr�rr)�__name__� __module__� __qualname__rrrrrrr$s rc@s$eZdZdZd dd�Zd dd�Zd S) �IdentityDecoderz Handle unencoded data. rrrcCs|Sr rr rrrr1�zIdentityDecoder.decodecCsdS�N�rrrrrr4rzIdentityDecoder.flushNrr)rrr�__doc__rrrrrrr,s rc@�.eZdZdZd dd�Zddd �Zdd d �Zd S)�DeflateDecoderzZ Handle 'deflate' decoding. See: https://stackoverflow.com/questions/1838699 r�NonecCsd|_t��|_dS�NT)� first_attempt�zlib� decompressobj� decompressorrrrr�__init__?szDeflateDecoder.__init__rrc Csn|j}d|_z|j�|�WStjy6}z|r+t�tj �|_|�|�WYd}~Stt |��|�d}~ww�NF) r#r&� decompressr$�errorr%� MAX_WBITSrr�str)rrZwas_first_attempt�excrrrrCs��zDeflateDecoder.decodec C�6z|j��WStjy}ztt|��|�d}~wwr �r&rr$r*rr,�rr-rrrrN�  ��zDeflateDecoder.flushN�rr!rr�rrrrr'rrrrrrr 8s    r c@r)� GZipDecoderzW Handle 'gzip' decoding. See: https://stackoverflow.com/questions/1838699 rr!cCst�tjdB�|_dS)N�)r$r%r+r&rrrrr'\�zGZipDecoder.__init__rrc Cs8z|j�|�WStjy}ztt|��|�d}~wwr )r&r)r$r*rr,�rrr-rrrr_s ��zGZipDecoder.decodec Cr.r r/r0rrrrer1zGZipDecoder.flushNr2rrr3rrrrr4Us   r4c@r)� BrotliDecoderaT Handle 'brotli' decoding. Requires `pip install brotlipy`. See: https://brotlipy.readthedocs.io/ or `pip install brotli`. See https://github.com/google/brotli Supports both 'brotlipy' and 'Brotli' packages since they share an import name. The top branches are for 'brotlipy' and bottom branches for 'Brotli' rr!cCsNtdur td�d�t��|_d|_|t|jd�r |jj|_dS|jj|_dS)Nz�Using 'BrotliDecoder', but neither of the 'brotlicffi' or 'brotli' packages have been installed. Make sure to install httpx using `pip install httpx[brotli]`.Fr)) �brotli� ImportErrorZ Decompressorr&� seen_data�hasattrr)� _decompress�processrrrrr'vs��  zBrotliDecoder.__init__rrc CsD|sdSd|_z|�|�WStjy!}ztt|��|�d}~ww�NrT)r;r=r9r*rr,r7rrrr�s ��zBrotliDecoder.decodec CsP|jsdSzt|jd�r|j��WdStjy'}ztt|��|�d}~ww)Nr�finish)r;r<r&r@r9r*rr,r0rrrr�s  ��zBrotliDecoder.flushNr2rrr3rrrrr8ls   r8c@r)�ZStandardDecoderz� Handle 'zstd' RFC 8878 decoding. Requires `pip install zstandard`. Can be installed as a dependency of httpx using `pip install httpx[zstd]`. rr!cCs*tdur td�d�t����|_d|_dS)NzXUsing 'ZStandardDecoder', ...Make sure to install httpx using `pip install httpx[zstd]`.F)� zstandardr:�ZstdDecompressorr%r&r;rrrrr'�s�� zZStandardDecoder.__init__rrc Cs�tdusJ�d|_t��}zA|�|j�|��|jjr@|jjrJ|jj}t� �� �|_|�|j�|��|jjrE|jjsW|��SW|��SW|��SW|��Stj yb}zt t |��|�d}~wwr")rBr;�io�BytesIO�writer&r)�eof� unused_datarCr%Z ZstdErrorrr,�getvalue)rr�outputrHr-rrrr�s* �������zZStandardDecoder.decodecCs,|jsdS|j��}|jjstd��t|�S)NrzZstandard data is incomplete)r;r&rrGrr)r�retrrrr�s  zZStandardDecoder.flushNr2rrr3rrrrrA�s   rAc@s.eZdZdZddd�Zdd d �Zdd d �ZdS)� MultiDecoderzE Handle the case where multiple encodings have been applied. �children�typing.Sequence[ContentDecoder]rr!cCstt|��|_dS)zm 'children' should be a sequence of decoders in the order in which each was applied. N)�list�reversedrM)rrMrrrr'�szMultiDecoder.__init__rrcCs|jD]}|�|�}q|Sr )rMr�rr�childrrrr�s  zMultiDecoder.decodecCs&d}|jD] }|�|�|��}q|Sr)rMrrrQrrrr�s zMultiDecoder.flushN)rMrNrr!rrr3rrrrrL�s   rLc@�0eZdZdZdddd�Zdd d �Zddd�ZdS)� ByteChunkerz> Handles returning byte content in fixed-size chunks. N� chunk_size� int | Nonerr!cC�t��|_||_dSr )rDrE�_buffer� _chunk_size�rrUrrrr'��  zByteChunker.__init__�contentr� list[bytes]c���jdur |r |gSgS�j�|��j���jkr_�j�����fdd�tdt���j�D�}t|d��jkrF�j�d��j��|S�j�d��j�|d��j��|dd�SgS)Nc�g|] }�||�j��qSr�rY��.0�i�r�valuerr� <listcomp>����z&ByteChunker.decode.<locals>.<listcomp>r������ rYrXrF�tellrI�range�len�seek�truncate�rr\�chunksrrdrr��"    �     zByteChunker.decodecC�.|j��}|j�d�|j��|r|gSgS�Nr�rXrIrmrnrdrrrr�   zByteChunker.flushr �rUrVrr!)r\rrr])rr]r3rrrrrT��   rTc@rS)� TextChunkerz> Handles returning text content in fixed-size chunks. NrUrVrr!cCrWr )rD�StringIOrXrYrZrrrr'r[zTextChunker.__init__r\r,� list[str]cr^)Ncr_rr`rardrrrfrgz&TextChunker.decode.<locals>.<listcomp>rrhrirorrdrrrqzTextChunker.decodecCrrrsrtrdrrrr+ruzTextChunker.flushr rv)r\r,rrz�rrzr3rrrrrx rwrxc@s0eZdZdZdddd�Zdd d �Zdd d�ZdS)� TextDecoderz8 Handles incrementally decoding bytes into text �utf-8�encodingr,rr!cCst�|�dd�|_dS)N�replace)�errors)�codecs�getincrementaldecoder�decoder)rr~rrrr'7r6zTextDecoder.__init__rrcCs |j�|�Sr �r�rr rrrr:s zTextDecoder.decodecCs|j�dd�Sr?r�rrrrr=szTextDecoder.flushN)r})r~r,rr!)rrrr,)rr,r3rrrrr|2s   r|c@s.eZdZdZddd�Zdd d �Zdd d �Zd S)� LineDecoderz� Handles incrementally reading lines from text. Has the same behaviour as the stdllib splitlines, but handling the input iteratively. rr!cCsg|_d|_dSr()�buffer� trailing_crrrrrr'Is zLineDecoder.__init__�textr,rzcCs�d}|jr d|}d|_|�d�rd|_|dd�}|sgS|d|v}|��}t|�dkr:|s:|j�|d�gS|jrQd�|j�|dg|dd�}g|_|sY|��g|_|S) Nu …

� FTrhrr�)r��endswith� splitlinesrlr��append�join�pop)rr�Z NEWLINE_CHARSZtrailing_newline�linesrrrrMs(   " zLineDecoder.decodecCs.|js|jsgSd�|j�g}g|_d|_|S)Nr�F)r�r�r�)rr�rrrrss zLineDecoder.flushNr2)r�r,rrzr{r3rrrrr�As   &r�)�identity�gzipZdeflate�br�zstdr�r�)r� __future__rr�rD�typingr$� _exceptionsrr9r:Z brotlicffirBrrr r4r8rArLrTrxr|r��SUPPORTED_DECODERSr�rrrr�<module>sX      ���  � 5*''=� �
Memory