
    h                     ^    d Z dZdZdZ	 dd lmZ y# e$ r  ee      Z G d de	      ZY y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y)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                 N    d | _         d | _        d | _        | j                          y )N)r   r   r   resetselfs    \/var/www/Befach/backend/env/lib/python3.12/site-packages/autobahn/websocket/utf8validator.py__init__zUtf8Validator.__init__V   s     "DODKDKJJL    c                     t         |   }| j                  t        k7  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\   sl     %Q'B{{k)#$t810D"E#'2:"2-cDKK"4D.Dr.IJDK;;r   c                 6    t         | _        d| _        d| _        y)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DKr   c                 \   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  r\|| _        | 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KKEa%+C5A:,>ATUWXYUZA[,[\K'"'DKKK1$K %DKK77Q a%  DKKK1K+-q$++==r   N)	__name__
__module____qualname____doc__	__slots__r   r#   r   r,    r   r   r   r   H   s"    	
			&		>r   r   N)
__all__UTF8VALIDATOR_DFAr    r'   wsaccel.utf8validatorr   ImportErrorbytesr   objectr2   r   r   <module>r9      sV   >  " \>3 Y>   12M> M>Y>s    ,,