o
    £U¤gã  ã                   @   sP   d Z dZdZdZz	dd lmZ W dS  ey'   eeƒZG dd„ de	ƒZY dS w ))ÚUtf8Validator(  é    r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   é   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   é	   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   é   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   é   r   é   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   é
   é   r	   r	   r	   r	   r	   r	   r	   r	   r	   r	   r	   é   r	   r	   é   é   r   r   é   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r	   r   r   r   r   r   r   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r	   r   r	   r   r   r   r   r   r   r   r	   r   r   r   r   r   r	   r   r	   r   r   r   r   r   r   r   r	   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   c                   @   s4   e Zd ZdZdZdd„ Zdd„ Zdd„ Zd	d
„ ZdS )r   zö
        Incremental UTF-8 validator with constant memory consumption (minimal state).

        Implements the algorithm "Flexible and Economical UTF-8 Decoder" by
        Bjoern Hoehrmann (http://bjoern.hoehrmann.de/utf-8/decoder/dfa/).
        )Ú
_codepointÚ_stateÚ_indexc                 C   s   d | _ d | _d | _|  ¡  d S )N)r   r   r   Úreset©Úself© r   úl/var/www/html/Testing_prj/Navya-Bakers/venv/lib/python3.10/site-packages/autobahn/websocket/utf8validator.pyÚ__init__V   s   zUtf8Validator.__init__c                 C   sT   t | }| jtkr|d@ | jd> B | _nd|? |@ | _t d| jd  |  | _| jS )a†  
            Eat one UTF-8 octet, and validate on the fly.

            Returns ``UTF8_ACCEPT`` when enough octets have been consumed, in which case
            ``self.codepoint`` contains the decoded Unicode code point.

            Returns ``UTF8_REJECT`` when invalid UTF-8 was encountered.

            Returns some other positive integer when more octets need to be eaten.
            é?   r   éÿ   é   é   )ÚUTF8VALIDATOR_DFA_Sr   ÚUTF8_ACCEPTr   )r   ÚbÚttr   r   r   Údecode\   s   
zUtf8Validator.decodec                 C   s   t | _d| _d| _dS )z[
            Reset validator to start new incremental UTF-8 decode/validation.
            r   N)r   r   r   r   r   r   r   r   r   o   s   
zUtf8Validator.resetc                 C   s–   t |ƒ}d}| j}||k r8td|d>  t||    }|tkr0|| _|  j|7  _dd|| jfS |d7 }||k s|| _|  j|7  _d|tk|| jfS )a‹  
            Incrementally validate a chunk of bytes provided as string.

            Will return a quad ``(valid?, endsOnCodePoint?, currentIndex, totalIndex)``.

            As soon as an octet is encountered which renders the octet sequence
            invalid, a quad with ``valid? == False`` is returned. ``currentIndex`` returns
            the index within the currently consumed chunk, and ``totalIndex`` the
            index within the total consumed sequence that was the point of bail out.
            When ``valid? == True``, currentIndex will be ``len(ba)`` and ``totalIndex`` the
            total amount of consumed bytes.
            r   r   r
   Fr   T)Úlenr   r   ÚUTF8_REJECTr   r   )r   ÚbaÚlÚiÚstater   r   r   Úvalidatew   s   ùzUtf8Validator.validateN)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   r   r   r&   r   r   r   r   r   H   s    r   N)
Ú__all__ÚUTF8VALIDATOR_DFAr   r!   Úwsaccel.utf8validatorr   ÚImportErrorÚbytesr   Úobjectr   r   r   r   Ú<module>   s   
ô