
    vKg                        S SK Jr  S SKrS SKJrJr  S SKJrJrJ	r	  SSK
JrJr  SSKJrJr  SSKJr  SS	KJr   SS
KJr   " S S\	5      rSS jrSS jr\rSSKJr  SS jrSS jrg! \ a	    SS
KJr   N6f = f)    )annotationsN)	AwaitableSequence)AnyCallable
NamedTuple   )
extensionsframes)PayloadTooBigProtocolError)	BytesLike)Data)
apply_maskc                      \ rS rSr% S\S'   S\S'   S\S'   SrS\S	'   SrS\S
'   SrS\S'   \SS j5       r	SS jr
SS jr\SSS.         SS jj5       rSS.       SS jjrSrg)Frame   boolfinzframes.OpcodeopcodebytesdataFrsv1rsv2rsv3c                    [         R                  " U R                  U R                  U R                  U R
                  U R                  U R                  5      $ N)r   r   r   r   r   r   r   r   selfs    Y/var/www/highfloat_scraper/venv/lib/python3.13/site-packages/websockets/legacy/framing.py	new_frameFrame.new_frame   s=    ||KKIIHHIIIIII
 	
    c                ,    [        U R                  5      $ r   )strr!   r   s    r    __str__Frame.__str__&   s    4>>""r#   c                6    U R                   R                  5       $ r   )r!   checkr   s    r    r)   Frame.check)   s    ~~##%%r#   N)max_sizer
   c               "  #    U" S5      I Sh  vN n[         R                  " SU5      u  pgUS-  (       a  SOSnUS-  (       a  SOSn	US-  (       a  SOSn
US	-  (       a  SOSn [        R                  " US
-  5      nUS-  (       a  SOSU:w  a  [        S5      eUS-  nUS:X  a*  U" S5      I Sh  vN n[         R                  " SU5      u  nO/US:X  a)  U" S5      I Sh  vN n[         R                  " SU5      u  nUb  X:  a  [        X5      eU(       a  U" S5      I Sh  vN nU" U5      I Sh  vN nU(       a  [        UW5      n[        R                  " XXX5      nUc  / n[        U5       H  nUR                  UUS9nM     UR                  5         U " UR                  UR                  UR                  UR                  UR                   UR"                  5      $  GN! [         a  n[        S5      UeSnAff = f GNT GN' N N7f)a  
Read a WebSocket frame.

Args:
    reader: Coroutine that reads exactly the requested number of
        bytes, unless the end of file is reached.
    mask: Whether the frame should be masked i.e. whether the read
        happens on the server side.
    max_size: Maximum payload size in bytes.
    extensions: List of extensions, applied in reverse order.

Raises:
    PayloadTooBig: If the frame exceeds ``max_size``.
    ProtocolError: If the frame contains incorrect values.

r	   Nz!BB   TF@             zinvalid opcodezincorrect masking   ~   z!H   z!Q   )r+   )structunpackr   Opcode
ValueErrorr   r   r   r   reverseddecoder)   r   r   r   r   r   r   )clsreadermaskr+   r
   r   head1head2r   r   r   r   r   exclength	mask_bitsr!   	extensions                     r    read
Frame.read,   s    6 AY}}UD1 j(dez)tuz)tuz)tu	;]]5:#56F J&DEd: 344#S=?DdD1IVs]?DdD1IVF$511$QiI F^#dI.DLLs$E	J!*-I!((X(FI . 	MMNNNNNNNN
 	
W   	; 01s:	; # #
 ( $sx   HG$AH%G' >3H1H2/H!H"AH$H%H4H5B0H'
H1G==HHHHH)r
   c               B    U" U R                   R                  X#S95        g)aF  
Write a WebSocket frame.

Args:
    frame: Frame to write.
    write: Function that writes bytes.
    mask: Whether the frame should be masked i.e. whether the write
        happens on the client side.
    extensions: List of extensions, applied in order.

Raises:
    ProtocolError: If the frame contains incorrect values.

)r>   r
   N)r!   	serialize)r   writer>   r
   s       r    rI   Frame.write{   s    0 	dnn&&D&HIr#    )returnzframes.Frame)rL   r%   )rL   None)
r=   z!Callable[[int], Awaitable[bytes]]r>   r   r+   z
int | Noner
   %Sequence[extensions.Extension] | NonerL   r   )rI   zCallable[[bytes], Any]r>   r   r
   rN   rL   rM   )__name__
__module____qualname____firstlineno____annotations__r   r   r   propertyr!   r&   r)   classmethodrE   rI   __static_attributes__rK   r#   r    r   r      s    	I
KD$D$D$
 
#&   $<@L
1L
 	L

 L
 :L
 
L
 L
f =AJ%J 	J
 :J 
J Jr#   r   c                    [        U [        5      (       a*  [        R                  R                  U R                  5       4$ [        U [        5      (       a  [        R                  R                  U 4$ [        S5      e)az  
Convert a string or byte-like object to an opcode and a bytes-like object.

This function is designed for data frames.

If ``data`` is a :class:`str`, return ``OP_TEXT`` and a :class:`bytes`
object encoding ``data`` in UTF-8.

If ``data`` is a bytes-like object, return ``OP_BINARY`` and a bytes-like
object.

Raises:
    TypeError: If ``data`` doesn't have a supported type.

data must be str or bytes-like)	
isinstancer%   r   r8   TEXTencoder   BINARY	TypeErrorr   s    r    prepare_datar_      sZ      $}}!!4;;=00	D)	$	$}}##T))899r#   c                    [        U [        5      (       a  U R                  5       $ [        U [        5      (       a  [	        U 5      $ [        S5      e)aI  
Convert a string or byte-like object to bytes.

This function is designed for ping and pong frames.

If ``data`` is a :class:`str`, return a :class:`bytes` object encoding
``data`` in UTF-8.

If ``data`` is a bytes-like object, return a :class:`bytes` object.

Raises:
    TypeError: If ``data`` doesn't have a supported type.

rX   )rY   r%   r[   r   r   r]   r^   s    r    prepare_ctrlra      s@     ${{}	D)	$	$T{899r#   )Closec                ^    [         R                  " U 5      nUR                  UR                  4$ )z
Parse the payload from a close frame.

Returns:
    Close code and reason.

Raises:
    ProtocolError: If data is ill-formed.
    UnicodeDecodeError: If the reason isn't valid UTF-8.

)rb   parsecodereason)r   closes     r    parse_closerh      s%     KKE::u||##r#   c                4    [        X5      R                  5       $ )z+
Serialize the payload for a close frame.

)rb   rH   )re   rf   s     r    serialize_closerj      s    
 ((**r#   )r   r   rL   ztuple[int, bytes])r   r   rL   r   )r   r   rL   ztuple[int, str])re   intrf   r%   rL   r   )
__future__r   r6   collections.abcr   r   typingr   r   r    r
   r   
exceptionsr   r   r   r   speedupsr   ImportErrorutilsr   r_   ra   encode_datarb   rh   rj   rK   r#   r    <module>ru      sn    "  / , , ! 5  #%
@JJ @JF:0:0  $ +[  #"#s   A( (A76A7