
    vKgQ                        S SK r S SKrS SKrS SKJrJrJr  \S#S j5       r\S\\\	4   S\	4S j5       rS\S\\	4   S\S\	4   4S jr\S#S j5       r
\S\\\	4   S\4S	 j5       r
S\S\\	4   S\S\4   4S
 jr
\" S5       V s0 sH  n U \" S5      _M     sn r\" S5      \S'   \R                  5       rS H  r\\" \5      	 M     \R#                  \5      r\R#                  \5      rS$S\S\4S jjrS%S jrS rS\	S\4S jrS\	S\4S jrS rS rS rS rSrSrSrSrS\S\\   4S  jr S\S\\   4S! jr!S\4S" jr"gs  sn f )&    N)IterableUnionoverloadstr_or_bytesreturnc                     g N r   encode_argss     p/var/www/highfloat_scraper/venv/lib/python3.13/site-packages/seleniumwire/thirdparty/mitmproxy/utils/strutils.pyalways_bytesr              c                     g r	   r
   r   s     r   r   r      r   r   c                     U b  [        U [        5      (       a  U $ [        U [        5      (       a  U R                  " U6 $ [	        SR                  [        U 5      R                  5      5      e)N"Expected str or bytes, but got {}.)
isinstancebytesstrencode	TypeErrorformattype__name__r   s     r   r   r      sZ    z,>>	L#	&	&""K00<CCDDVD_D_`aar   c                     g r	   r
   r   s     r   
always_strr      r   r   c                     g r	   r
   r   s     r   r   r       r   r   c                     U b  [        U [        5      (       a  U $ [        U [        5      (       a  U R                  " U6 $ [	        SR                  [        U 5      R                  5      5      e)z*
Returns,
    str_or_bytes unmodified, if
r   )r   r   r   decoder   r   r   r   )r   decode_argss     r   r   r   %   s\    
 z,<<	L%	(	(""K00<CCDDVD_D_`aar       .   )
	textc                     [        U [        5      (       d-  [        SR                  [	        U 5      R
                  5      5      eU(       a  [        O[        nU R                  U5      $ )z
Replace all unicode C1 control characters from the given text with a single "."

Args:
    keep_spacing: If True, tabs and newlines will not be replaced.
z#text type must be unicode but is {})	r   r   
ValueErrorr   r   r   _control_char_trans_newline_control_char_trans	translate)r(   keep_spacingtranss      r   escape_control_charactersr0   C   sL     dC  >EEd4jFYFYZ[[+7'=PE>>%  r   c                 L   [        U [        5      (       d.  [        SR                  U R                  R
                  5      5      e[        SU -   5      R                  S5      SS nU(       d  [        R                  " SS U5      nU(       a  [        R                  " SS	 U5      nU$ )
a  
Take bytes and return a safe string that can be displayed to the user.

Single quotes are always escaped, double quotes are never escaped:
    "'" + bytes_to_escaped_str(...) + "'"
gives a valid Python string.

Args:
    keep_spacing: If True, tabs and newlines will not be escaped.
zdata must be bytes, but is {}   "b   z(?<!\\)(\\\\)*\\'c                 <    U R                  S5      =(       d    SS-   $ )N    ')groupms    r   <lambda>&bytes_to_escaped_str.<locals>.<lambda>c   s    aggaj6FB#5Mr   z(?<!\\)(\\\\)*\\([nrt])c                 r    U R                  S5      =(       d    S[        SSSS9U R                  S5         -   $ )Nr7   r8   r&   r%   r'   )nrtr4   )r:   dictr;   s    r   r=   r>   g   s-    qwwqz'R4$$$+GPQ
+SSr   )
r   r   r*   r   	__class__r   reprlstripresub)datar.   escape_single_quotesrets       r   bytes_to_escaped_strrL   Q   s     dE""8??@W@WXYY td{

"
"3
'"
-Cff)+MsSff&S

 Jr   c                     [        U [        5      (       d.  [        SR                  U R                  R
                  5      5      e[        R                  " U 5      S   $ )z
Take an escaped string and return the unescaped bytes equivalent.

Raises:
    ValueError, if the escape sequence is invalid.
zdata must be str, but is {}r   )r   r   r*   r   rD   r   codecsescape_decoderI   s    r   escaped_str_to_bytesrQ   m   sJ     dC  6==dnn>U>UVWW %a((r   sc                 ~    U (       a  [        U 5      S:X  a  g[        S U S S  5       5      [        U S S 5      -  S:  $ )Nr   Fc              3   z   #    U H2  nUS :  =(       d!    SUs=:  =(       a    S:  Os  =(       d    SU:  v   M4     g7f)	      r"   ~   Nr
   .0is     r   	<genexpr> is_mostly_bin.<locals>.<genexpr>   s6      A 	
A'a"'a's   9;d   g333333?)lensumrR   s    r   is_mostly_binra   |   sP    A! 4C  	AdsG  r   c                 @    U R                  5       R                  S5      $ )N   <)strip
startswithr`   s    r   is_xmlrf      s    779%%r   c                 0    U (       a  U S   S:X  a  U SS $ U $ )z
Many editors will silently add a newline to the final line of a
document (I'm looking at you, Vim). This function fixes this common
problem at the risk of removing a hanging newline in the rare cases
where the user actually intends it.
r5   r&   Nr
   )rB   s    r   clean_hanging_newlinerh      s!     	QrUd]"vHr   c           	   #   >  #    [        S[        U 5      S5       H  nSR                  U5      nXUS-    nSR                  S U 5       5      nUR	                  S5      n[        [        UR                  SS5      R                  S	S
5      S5      5      nX$U4v   M     g7f)z7
Returns:
    A generator of (offset, hex, str) tuples
r      z{:0=10x} c              3   B   #    U H  nS R                  U5      v   M     g7f)z{:0=2x}N)r   rX   s     r   r[   hexdump.<locals>.<genexpr>   s     7$QY%%a(($s   /   asciireplaceu   �r#   FN)	ranger^   r   joinljustr   r0   r    rp   )rR   rZ   offsetpartx	part_reprs         r   hexdumprx      s     
 1c!fb!""1%1r6{HH7$77GGBK8KK+33ItD 
 	 )$$ "s   BBc                 N    [        [        U R                  S5      5      S-   5      $ Nr   i   chrordr:   matchobjs    r   _move_to_private_code_planer           s8>>!$%.//r   c                 N    [        [        U R                  S5      5      S-
  5      $ rz   r{   r~   s    r    _restore_from_private_code_planer      r   r   z(?<!\\)(?:\\\\)*z[\s\S]*?z.*?z(?:.|(?<=\\)\n)*?rI   area_delimiterc                     [         R                  " SR                  SR                  U5      5      U [         R                  S9$ )aN  
Split a string of code into a [code, special area, code, special area, ..., code] list.

For example,

>>> split_special_areas(
>>>     "test /* don't modify me */ foo",
>>>     [r"/\*[\s\S]*?\*/"])  # (regex matching comments)
["test ", "/* don't modify me */", " foo"]

"".join(split_special_areas(x, ...)) == x always holds true.
z({})|)flags)rG   splitr   rr   	MULTILINE)rI   r   s     r   split_special_areasr      s4      88chh~./ll r   c                 6   [         R                  " 5       n[        X5      n[        R                  " SR                  U5      5      n[        U5       H6  u  pgUS-  (       a  UR                  [        U5      nUR                  U5        M8     UR                  5       $ )uL  
Escape all control characters present in special areas with UTF8 symbols
in the private use plane (U+E000 t+ ord(char)).
This is useful so that one can then use regex replacements on the resulting string without
interfering with special areas.

control_characters must be 0 < ord(x) < 256.

Example:

>>> print(x)
if (true) { console.log('{}'); }
>>> x = escape_special_areas(x, "{", ["'" + SINGLELINE_CONTENT + "'"])
>>> print(x)
if (true) { console.log('�}'); }
>>> x = re.sub(r"\s*{\s*", " {
", x)
>>> x = unescape_special_areas(x)
>>> print(x)
if (true) {
    console.log('{}'); }
z[{}]r4   )ioStringIOr   rG   compiler   	enumeraterH   r   writegetvalue)rI   r   control_charactersbufpartsrexrZ   rv   s           r   escape_special_areasr      ss    4 ++-C5E
**W^^$67
8C% q53Q7A		! ! <<>r   c                 :    [         R                  " S[        U 5      $ )zg
Invert escape_special_areas.

x == unescape_special_areas(escape_special_areas(x)) always holds true.
z[\ue000-\ue0ff])rG   rH   r   rP   s    r   unescape_special_areasr      s     66$&FMMr   )r   Nr   N)T)FF)#rN   r   rG   typingr   r   r   r   r   r   r   rq   r}   r,   copyr+   rv   	maketransr0   rL   rQ   boolra   rf   rh   rx   r   r   	NO_ESCAPEMULTILINE_CONTENTSINGLELINE_CONTENT#MULTILINE_CONTENT_LINE_CONTINUATIONr   r   r   )rv   s   0r   <module>r      s%    	 	 , , 
 
 
uS%Z0 5  
buT3%56 btUZ{I[ b 
 
 
U3:.   

bU4e#34 
buTSVYGW 
b& 2Y s3xK  s8 C 1668 	A#CF+ 
 mm$78 !mm,GH !C !s !8)U t &e & &	%"00  	  &: # .!! !HN Nus   E 