
    d                     &   d Z ddlZd Zd Zd Zd Zd ZdZd	 Zd
 Z	d Z
d Zd Zd Zd Z G d dej                  Z G d dej                  Z G d dej                  Z G d deej                  Z G d deej                  Zd ZdS )uY    Codec for the Punicode encoding, as specified in RFC 3492

Written by Martin v. Löwis.
    Nc                    t                      }t                      }| D ]M}t          |          dk     r#|                    t          |                     8|                    |           Nt          |          }t          |          |fS )z 3.1 Basic code point segregation   )	bytearraysetordappendaddsortedbytes)strbaseextendedcs       $  /croot/python-split_1694437901252/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/lib/python3.11/encodings/punycode.py	segregater   
   s|    ;;DuuH  q66C<<KKALLOOOOhH;;      c                 D    d}| D ]}t          |          |k     r|dz  }|S )z@Return the length of str, considering only characters below max.r      )r   )r   maxresr   s       r   selective_lenr      s4    
C  q66C<<1HCJr   c                 ~    t          |           }	 |dz  }||k    rdS | |         }||k    r|dz   |fS ||k     r|dz  }.)a  Return a pair (index, pos), indicating the next occurrence of
    char in str. index is the position of the character considering
    only ordinals up to and including char, and pos is the position in
    the full string. index/pos is the starting position in the full
    string.r   )r   )len)r   charindexposlr   s         r   selective_findr      sb     	CAq!888H997C<XXQJEr   c                     d}g }d}|D ]t}dx}}t          |          }t          | |          }	|	dz   ||z
  z  }
	 t          | |||          \  }}|dk    rn%|
||z
  z  }
|                    |
dz
             |}d}
A|}u|S )3.2 Insertion unsort codingr   r   r   r   )r   r   r   r   )r   r   oldcharresultoldindexr   r   r   r   curlendeltas              r   insertion_unsortr'   0   s    GFH  1vvsD))dWn-	&s1U377IE#{{UX%%EMM%'"""HE	 Mr   c                 <    d| dz   z  |z
  }|dk     rdS |dk    rdS |S )N$   r       )jbiasr   s      r   Tr.   F   s3    
A,
C
Qwwqq
RxxJr   s$   abcdefghijklmnopqrstuvwxyz0123456789c                 (   t                      }d}	 t          ||          }| |k     r/|                    t          |                     t	          |          S |                    t          || |z
  d|z
  z  z                       | |z
  d|z
  z  } |dz  })(3.3 Generalized variable-length integersr   r   r)   )r   r.   r   digitsr   )Nr-   r#   r,   ts        r   generate_generalized_integerr4   N   s    [[F	AaJJq55MM&)$$$== fQ1q5R!V"456777UQ	Qr   c                 |    |r| dz  } n| dz  } | | |z  z  } d}| dk    r| dz  } |dz  }| dk    |d| z  | dz   z  z   }|S )Ni     r   i  #   r)   &   r+   )r&   firstnumchars	divisionsr-   s        r   adaptr<   [   sv     #!	UhEI
#++R	 #++ U
urz23DKr   c                     t                      }d}t          |          D ]E\  }}t          ||          }|                    |           t	          ||dk    | |z   dz             }Ft          |          S )z3.4 Bias adaptationH   r   r   )r   	enumerater4   extendr<   r   )baselendeltasr#   r-   pointsr&   ss          r   generate_integersrE   j   sz     [[FD"6** 9 9(55aUFAIwv~a'788==r   c                     t          |           \  }}t          | |          }t          t          |          |          }|r|dz   |z   S |S )N   -)r   r'   rE   r   )textr   r   rB   s       r   punycode_encoderI   u   sQ    t__ND(dH--F TF33H &d{X%%Or   c                    d}d}d}	 	 t          | |                   }n,# t          $ r |dk    rt          d          |dz   dfcY S w xY w|dz  }d|cxk    rdk    r	n n|dz
  }n;d|cxk    rd	k    r	n n|d
z
  }n%|dk    rt          d| |dz
           z            |dfS t          ||          }	|||z  z  }||	k     r||fS |d|	z
  z  }|dz  })r0   r   r   strictzincomplete punicode stringNA   Z   0   9      z Invalid extended code point '%s'r)   )r   
IndexErrorUnicodeErrorr.   )
r   extposr-   errorsr#   wr,   r   digitr3   s
             r   decode_generalized_numberrW      sd   F	A	A	$x'((DD 	$ 	$ 	$!!"#?@@@A:t####	$ 	!444KEET!!!!T!!!!!2IEExA!)&(!3 4 5 5 5 4<aJJ%!)1996>!aL	Q-s    &AAc                    d}d}d}d}|t          |          k     rt          ||||          \  }}|| S ||dz   z  }||t          |           dz   z  z  }|dk    r'|dk    rt          d	|z            t          d
          }|t          |           dz   z  }| d|         t	          |          z   | |d         z   } t          ||dk    t          |                     }|}|t          |          k     | S )r!   r   r   r>   r   Nr   i rK   zInvalid character U+%x?)r   rW   rR   r   chrr<   )	r   r   rT   r   r   r-   rS   newposr&   s	            r   insertion_sortr\      s   D
CDF
3x==
 
 1(F26@ @= KuQwD		A&&(??!!"#;d#BCCCs88DSYY]#DSDzCII%STT
2UVq[3t9955! 3x==
 
 " Kr   c                    t          | t                    r|                     d          } t          | t                    rt	          |           } |                     d          }|dk    r%d}t          | d                                          }nFt          | d |         d|          }t          | |dz   d          d                                          }t          |||          S )NasciirG   r    r   )
isinstancer   encode
memoryviewr   rfindupperr\   )rH   rT   r   r   r   s        r   punycode_decodere      s    $ ${{7##$
## T{{
**T

C
byytW%%++--4:w//tCEFF|W--3355$&111r   c                       e Zd ZddZddZdS )CodecrK   c                 B    t          |          }|t          |          fS N)rI   r   selfinputrT   r   s       r   ra   zCodec.encode   s    e$$CJJr   c                 p    |dvrt          d|z             t          ||          }|t          |          fS N)rK   replaceignorezUnsupported error handling )rR   re   r   rj   s       r   decodezCodec.decode   sA    888<VCDDDeV,,CJJr   N)rK   )__name__
__module____qualname__ra   rq   r+   r   r   rg   rg      s<                r   rg   c                       e Zd ZddZdS )IncrementalEncoderFc                      t          |          S ri   )rI   rk   rl   finals      r   ra   zIncrementalEncoder.encode   s    u%%%r   NF)rr   rs   rt   ra   r+   r   r   rv   rv      s(        & & & & & &r   rv   c                       e Zd ZddZdS )IncrementalDecoderFc                 l    | j         dvrt          d| j         z             t          || j                   S rn   )rT   rR   re   rx   s      r   rq   zIncrementalDecoder.decode   s8    ;===<T[HIIIudk222r   Nrz   )rr   rs   rt   rq   r+   r   r   r|   r|      s(        3 3 3 3 3 3r   r|   c                       e Zd ZdS )StreamWriterNrr   rs   rt   r+   r   r   r   r              Dr   r   c                       e Zd ZdS )StreamReaderNr   r+   r   r   r   r      r   r   r   c            	          t          j        dt                      j        t                      j        t
          t          t          t                    S )Npunycode)namera   rq   incrementalencoderincrementaldecoderstreamwriterstreamreader)	codecs	CodecInforg   ra   rq   rv   r|   r   r   r+   r   r   getregentryr      s=    ww~ww~--!!   r   )__doc__r   r   r   r   r'   r.   r1   r4   r<   rE   rI   rW   r\   re   rg   rv   r|   r   r   r   r+   r   r   <module>r      s   
 
! 
! 
!    $  ,   
1    	 	 	    <  22 2 2 
 
 
 
 
FL 
 
 
& & & & &2 & & &3 3 3 3 32 3 3 3	 	 	 	 	5, 	 	 		 	 	 	 	5, 	 	 	
	 	 	 	 	r   