o
    lh1                     @   s   d dl mZ 	 g dZG dd dZzd dlmZ deeef defdd	Z	W n+ e
yR   d Zd
Zg dZdedededefddZdeeef defdd	Z	Y nw deeef defddZdedeedf fddZdedeedf fddZdS )    )Union)NoLockvalidate_utf8extract_err_messageextract_error_codec                   @   s    e Zd ZdddZdddZdS )r   returnNc                 C      d S N )selfr
   r
   d/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/websocket/_utils.py	__enter__      zNoLock.__enter__c                 C   r   r	   r
   )r   exc_type	exc_value	tracebackr
   r
   r   __exit__   r   zNoLock.__exit__)r   N)__name__
__module____qualname__r   r   r
   r
   r
   r   r      s    
r   )Utf8Validatorutfbytesr   c                 C   s   t  | d }|S Nr   )r   validate)r   resultr
   r
   r   _validate_utf8%   s   r      (l  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   	   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      r       r!   r!   r!   r!   r!   r!   r!   r!   r!   r!   r!   r!   r!   r!   r!   r!   r!   r!   r!   r!   r!   r!   r!   r!   r!   r!   r!   r!   r!   
      r#   r#   r#   r#   r#   r#   r#   r#   r#   r#   r#      r#   r#         r&   r&      r    r    r    r    r    r    r    r    r    r    r    r   r      $   <   `   T   r   r   r   0   H   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r(   r   r   r   r   r   r(   r   r(   r   r   r   r   r   r   r   r   r   r(   r   r   r   r   r   r(   r   r   r   r   r   r   r   r(   r   r   r   r   r   r   r   r   r   r)   r   r)   r   r   r   r)   r   r   r   r   r   r)   r   r)   r   r   r   r)   r   r   r   r   r   r   r   r   r   r   statecodepchc                 C   sD   t | }| tkr|d@ |d> B nd|? |@ }t d|  |  } | |fS )N?   r&         )_UTF8D_UTF8_ACCEPT)r/   r0   r1   tpr
   r
   r   _decode  s
   "r8   c                 C   s8   t }d}| D ]}t||t|\}}|tkr dS qdS )Nr   FT)r6   r8   int_UTF8_REJECT)r   r/   r0   ir
   r
   r   r     s   c                 C   s   t | S )z
    validate utf8 byte string.
    utfbytes: utf byte string to check.
    return value: if valid utf8 string, return true. Otherwise, return false.
    )r   )r   r
   r
   r   r     s   r   	exceptionNc                 C   s   | j r
| j d }|S d S r   )args)r<   exception_messager
   r
   r   r     s   
r   c                 C   s:   | j rt| j dkrt| j d tr| j d S d S d S d S )Nr   r   )r=   len
isinstancer9   )r<   r
   r
   r   r     s   r   )typingr   __all__r   wsaccel.utf8validatorr   strbytesboolr   ImportErrorr6   r:   r5   r9   tupler8   r   	Exceptionr   r   r
   r
   r
   r   <module>   s2      u
      	