
    af                     n    d Z dZdZdZ	 dd lmZ dS # e$ r  ee          Z G d de	          ZY dS w xY 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                   .    e Zd ZdZdZd Zd Zd Z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                 X    d | _         d | _        d | _        |                                  d S )N)r   r   r   resetselfs    R/var/www/html/env/lib/python3.11/site-packages/autobahn/websocket/utf8validator.py__init__zUtf8Validator.__init__V   s(    "DODKDKJJLLLLL    c                     t           |         }| j        t          k    r|dz  | j        dz  z  | _        nd|z	  |z  | _        t           d| j        dz  z   |z            | _        | 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tts      r   decodezUtf8Validator.decode\   si     %Q'B{k))#$t810D"E#'2:"2-cDK"4D.Dr.IJDK;r   c                 :    t           | _        d| _        d| _        dS )z[
            Reset validator to start new incremental UTF-8 decode/validation.
            r   N)r    r   r   r   r   s    r   r   zUtf8Validator.reseto   s     &DKDODKKKr   c                 R   t          |          }d}| j        }||k     r_t          d|dz  z   t          ||                  z            }|t          k    r"|| _        | xj        |z  c_        dd|| j        fS |dz  }||k     _|| _        | xj        |z  c_        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states        r   validatezUtf8Validator.validatew   s    " BAAKEa%%+C5A:,>ATUWXYUZA[,[\K''"'DKKK1$KK %DK77Q a%%  DKKK1KK+-q$+==r   N)	__name__
__module____qualname____doc__	__slots__r   r#   r   r,    r   r   r   r   H   sa        	 	
		 	 		 	 	&	 	 		> 	> 	> 	> 	>r   r   N)
__all__UTF8VALIDATOR_DFAr    r'   wsaccel.utf8validatorr   ImportErrorbytesr   objectr2   r   r   <module>r9      s   >  " \>33333333 Y> Y> Y>  % 122M> M> M> M> M> M> M> M> M> M> M>Y>s    44