
    d#                     ,   d dl Z d dlZd dlZd dlmZ  ej        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 )    N)	ucd_3_2_0u   [.。．｡]s   xn--zxn--c                 :   g }| D ]>}t          j        |          r|                    t          j        |                     ?d                    |          } t          j        d|           } | D ]}t          j        |          st          j        |          st          j	        |          sxt          j
        |          sdt          j        |          sPt          j        |          s<t          j        |          s(t          j        |          st          j        |          rt!          d|z            d | D             }t#          |          rGt#          d | D                       rt!          d          |d         r|d         st!          d	          | S )
N NFKCzInvalid character %rc                 6    g | ]}t          j        |          S  )
stringprepin_table_d1.0xs      lib/python3.11/encodings/idna.py
<listcomp>znameprep.<locals>.<listcomp>)   s#    777Aj$Q''777    c              3   >   K   | ]}t          j        |          V  d S )N)r	   in_table_d2r   s     r   	<genexpr>znameprep.<locals>.<genexpr>1   s-      88Qz%a((888888r   zViolation of BIDI requirement 2r   zViolation of BIDI requirement 3)r	   in_table_b1appendmap_table_b2joinunicodedata	normalizein_table_c12in_table_c22in_table_c3in_table_c4in_table_c5in_table_c6in_table_c7in_table_c8in_table_c9UnicodeErrorany)labelnewlabelcRandALs       r   nameprepr*      s   H 4 4!!$$ 	
/223333GGHE !&%00E  
; 
;"1%% 		;"1%%		;!!$$		; !!$$		; !!$$			;
 !!$$		; !!$$		; !!$$		; !!$$		; 59:::		; 87777F
6{{ B 88%88888 	B@AAA
 ay 	Br
 	B@AAALr   c                 \   	 |                      d          } dt          |           cxk     rdk     rn n| S t          d          # t          $ r Y nw xY wt          |           } 	 |                      d          } dt          |           cxk     rdk     rn n| S t          d          # t          $ r Y nw xY w|                     t
                    rt          d          |                      d          } t          | z   } dt          |           cxk     rdk     rn n| S t          d          )Nasciir   @   label empty or too longzLabel starts with ACE prefixpunycode)encodelenr$   r*   
startswithsace_prefix
ace_prefix)r&   s    r   ToASCIIr5   <   s   
6W%% s5zzBL4555     UOOE6W%%
 s5zzBL4555     $$ ;9::: LL$$E E 	3u::
0
1
11s#   A 
AA%B( (
B54B5c                 t   t          | t                    rd}n+	 |                     d          } d}n# t          $ r d}Y nw xY w|sCt	          |           } 	 |                     d          } n# t          $ r t          d          w xY w|                     t                    st          | d          S | t          t                    d          }|	                    d          }t          |          }t          | d                                          t          |d          k    rt          d| |          |S )NTr,   FzInvalid character in IDN labelr/   zIDNA does not round-trip)
isinstancebytesr0   r$   r*   r2   r4   strr1   decoder5   lower)r&   
pure_asciilabel1resultlabel2s        r   	ToUnicoder@   g   s^   % 

	LL))EJJ 	 	 	JJJ	 A	ALL))EE 	A 	A 	A?@@@	A J'' #5'""" 3z??##$F ]]:&&F V__F 5'  ""c&'&:&:::5ufEEE Ms   2 A AA, ,Bc                       e Zd ZddZddZdS )Codecstrictc                    |dk    rt          d|z             |sdS 	 |                    d          }|                    d          }|d d         D ]-}dt          |          cxk     rdk     sn t          d	          .t          |d                   dk    rt          d
          |t          |          fS # t          $ r Y nw xY wt                      }t                              |          }|r|d         sd}|d= nd}|D ];}|r|                    d           |                    t          |                     <t          ||z             t          |          fS )NrC   unsupported error handling r   r   r,      .r   r   r-   r.   zlabel too longr   )
r$   r0   splitr1   UnicodeEncodeError	bytearraydotsextendr5   r8   )selfinputerrorsr>   labelsr&   trailing_dots          r   r0   zCodec.encode   s   X<VCDDD 	6	&\\'**F
 \\$''F B BCJJ++++++++&'@AAA ,6":"$$"#34443u::%% " 	 	 	D	 E"" 	&* 	Lr

L 	* 	*E $d###MM'%..))))VL())3u::55s   B9 9
CCc                    |dk    rt          d|z             |sdS t          |t                    st          |          }t          |vr5	 |                    d          t          |          fS # t          $ r Y nw xY w|                    d          }|rt          |d                   dk    rd}|d= nd	}g }|D ]$}|                    t          |                     %d
                    |          |z   t          |          fS )
NrC   Unsupported error handling r   r   r,   rG   r   r   .r   )r$   r7   r8   r4   r:   r1   UnicodeDecodeErrorrH   r   r@   r   )rM   rN   rO   rP   rQ   r>   r&   s          r   r:   zCodec.decode   s/   X<VCDDD 	5 %'' 	!%LLEU""||G,,c%jj88%    T"" 	c&*oo**Lr

L 	, 	,EMM)E**++++xx,c%jj88s   #A/ /
A<;A<N)rC   )__name__
__module____qualname__r0   r:   r   r   r   rB   rB      s=        #6 #6 #6 #6J 9  9  9  9  9  9r   rB   c                       e Zd Zd ZdS )IncrementalEncoderc                    |dk    rt          d|z             |sdS t                              |          }d}|r|d         sd}|d= n	|s|d= |rd}t                      }d}|D ]R}|r|                    d           |dz  }|                    t          |                     |t          |          z  }S||z  }|t          |          z  }t          |          |fS )	NrC   rE   rF   r   r   rG   r      )r$   rK   rH   rJ   rL   r5   r1   r8   	rM   rN   rO   finalrP   rQ   r>   sizer&   s	            r   _buffer_encodez!IncrementalEncoder._buffer_encode   s   X<VCDDD 	8E"" 	(": (#2JJ (2J (#'L 	 	E d###	MM'%..)))CJJDD,L!!!ft$$r   N)rW   rX   rY   ra   r   r   r   r[   r[      s#         %  %  %  %  %r   r[   c                       e Zd Zd ZdS )IncrementalDecoderc                    |dk    rt          d|z             |sdS t          |t                    rt                              |          }n%t          |d          }|                    d          }d}|r|d         sd}|d= n	|s|d= |rd}g }d}|D ]=}|                    t          |                     |r|d	z  }|t          |          z  }>d                    |          |z   }|t          |          z  }||fS )
NrC   rS   rT   r,   rU   r   r   r   r]   )	r$   r7   r9   rK   rH   r   r@   r1   r   r^   s	            r   _buffer_decodez!IncrementalDecoder._buffer_decode   sB   X<VCDDD 	7 eS!! 	&ZZ&&FF w''E[[%%F 	'": '"2JJ '2J '#&L 	 	EMM)E**+++ 	CJJDD&!!L0L!!!~r   N)rW   rX   rY   re   r   r   r   rc   rc      s#        $ $ $ $ $r   rc   c                       e Zd ZdS )StreamWriterNrW   rX   rY   r   r   r   rg   rg   "          Dr   rg   c                       e Zd ZdS )StreamReaderNrh   r   r   r   rk   rk   %  ri   r   rk   c            	          t          j        dt                      j        t                      j        t
          t          t          t                    S )Nidna)namer0   r:   incrementalencoderincrementaldecoderstreamwriterstreamreader)	codecs	CodecInforB   r0   r:   r[   rc   rg   rk   r   r   r   getregentryru   *  s=    ww~ww~--!!   r   )r	   rers   r   r   compilerK   r4   r3   r*   r5   r@   rB   BufferedIncrementalEncoderr[   BufferedIncrementalDecoderrc   rg   rk   ru   r   r   r   <module>rz      s               0 0 0 0 0 0 rz.// 
, , ,\)2 )2 )2V% % %RF9 F9 F9 F9 F9FL F9 F9 F9P!% !% !% !% !%: !% !% !%F% % % % %: % % %N	 	 	 	 	5, 	 	 		 	 	 	 	5, 	 	 	
	 	 	 	 	r   