
    j~                       d dl mZ d dlZd dlZd dlZd dlZd dlmZ ddlm	Z	 ddl
mZ dZdZd	Zd
\  ZZZZ ej&                  d      Z ej&                  d      Z eddh      Z eh d      Z eh d      Z eh d      Z eddh      Z eh d      Z eddh      Z eddh      Z eddh      Zd5dZ ed   Z! G d de"      Z# G d de#      Z$ G d de#      Z% G d d e#      Z&d6d!Z'd7d"Z(d8d#Z)d9d$Z*d:d%Z+d;d&Z,d<d=d'Z-d>d(Z.d>d)Z/d?d*Z0d@d+Z1d<dAd,Z2dBd-Z3dCd.Z4dDd/Z5dEd0Z6dFd1Z7dGdHd2Z8	 	 	 	 dI	 	 	 	 	 	 	 	 	 	 	 dJd3Z9	 	 	 	 dI	 	 	 	 	 	 	 	 	 	 	 dKd4Z:y)L    )annotationsN)Literal   )idnadata)intranges_contain	   s   xn--i   s   VMDIu   [.。．｡]z[ -,/:-@A-Z[-`{-]RAL>   r	   r
   AN>
   r	   r
   r   BNCSENESETONNSM>   r	   r
   r   r   r   r   >   Lr   r   r   r   r   r   r   r   Dc                p    t         j                  j                         D ]  \  }}t        | |      s|c S  y N)r   joining_typesitemsr   )cpjtrangess      </var/www/html/venv/lib/python3.12/site-packages/idna/core.py_joining_typer      s8    ,,224 
FR(I     )input_too_longlabel_too_longdomain_too_longempty_labelempty_domainnot_nfc
hyphen_3_4hyphen_start_endleading_combinerdisallowed_codepointcontextjcontextounknown_codepointbidi_rule_1bidi_rule_2bidi_rule_3bidi_rule_4bidi_rule_5bidi_rule_6bidi_unknown_directioninvalid_alabelnon_canonical_alabelinvalid_asciiinvalid_utf8uts46_disallowed
uts46_std3unsupported_errorsc                  p     e Zd ZU dZded<   ded<   ded<   ded<   ddddd		 	 	 	 	 	 	 	 	 	 	 d fd
Z xZS )	IDNAErrora;  Base exception for all IDNA-encoding related problems.

    ``str(err)`` is a human-readable description of the failure. The
    exception also carries machine-readable attributes so callers do not
    need to parse the message:

    * ``code`` -- a short, stable identifier for the rule that failed, such
      as ``"disallowed_codepoint"`` or ``"bidi_rule_2"``; the full list is
      documented in the README. Message wording, by contrast, may change
      between releases.
    * ``text`` -- the label (or, for UTS #46 processing, the domain) that
      was being validated;
    * ``codepoint`` -- the offending codepoint, as an ``int``;
    * ``position`` -- the 1-based index of the offending character within
      ``text``, matching the position quoted in the message.

    Each is ``None`` when it does not apply.
    
str | Nonecodetext
int | None	codepointpositionNr=   r>   r@   rA   c               V    t        |   |  || _        || _        || _        || _        y r   )super__init__r=   r>   r@   rA   )selfr=   r>   r@   rA   args	__class__s         r   rE   zIDNAError.__init__^   s.     	$		" r   )rG   objectr=   z_ErrorCode | Noner>   r<   r@   r?   rA   r?   returnNone)__name__
__module____qualname____doc____annotations__rE   __classcell__)rH   s   @r   r;   r;   E   st    & 

 #' $#!!  ! 	!
 ! ! 
! !r   r;   c                      e Zd ZdZy)IDNABidiErrorz;Exception when bidirectional requirements are not satisfiedNrL   rM   rN   rO    r   r   rS   rS   m   s    Er   rS   c                      e Zd ZdZy)InvalidCodepointz<Exception when a disallowed or unallocated codepoint is usedNrT   rU   r   r   rW   rW   q   s    Fr   rW   c                      e Zd ZdZy)InvalidCodepointContextzCException when the codepoint is not valid in the context it is usedNrT   rU   r   r   rY   rY   u   s    Mr   rY   c                    t        j                  t        |             }|dk(  r)t        j                  t        |             st	        d      |S )Nr   z Unknown character in unicodedata)unicodedata	combiningchrname
ValueError)r   vs     r   _combining_classra   y   s?    c"g&AAvk&&s2w/;<<Hr   c                N    t        t        |       t        j                  |         S r   )r   ordr   scripts)r   scripts     r   
_is_scriptrf      s    SWh&6&6v&>??r   c                $    | j                  d      S )Npunycode)encodess    r   	_punycoderl      s    88Jr   c                    d| dS )NzU+04XrU   rj   s    r   _unotro      s    #w<r   c                    t        |       dk  S )u  Check that a label does not exceed the maximum permitted length.

    Per :rfc:`1035` (and :rfc:`5891` §4.2.4) a DNS label must not exceed
    63 octets. The argument may be either a :class:`str` (a U-label, where
    length is measured in characters) or :class:`bytes` (an A-label, where
    length is measured in octets).

    :param label: The label to check.
    :returns: ``True`` if the label is within the length limit, otherwise
        ``False``.
    ?   lenlabels    r   valid_label_lengthrv      s     u:r   c                *    t        |       |rdk  S dk  S )a  Check that a full domain name does not exceed the maximum length.

    Per :rfc:`1035`, a domain name is limited to 253 octets when no trailing
    dot is present, or 254 octets when one is included.

    :param domain: The full (possibly multi-label) domain name.
    :param trailing_dot: ``True`` if ``domain`` includes a trailing ``.``.
    :returns: ``True`` if the domain is within the length limit, otherwise
        ``False``.
          rr   )domaintrailing_dots     r   valid_string_lengthr|      s     v;,388C88r   c           
        t        |       t        kD  rt        dd      d}t        | d      D ]I  \  }}t	        j
                  |      }|dk(  rt        d| d| d	| t        |      |
      |t        v sHd}K |s|syt	        j
                  | d         }|t        v rd}n(|dk(  rd}n t        d| dd| t        | d         d
      d}d}d}	t        | d      D ]  \  }}t	        j
                  |      }|rh|t        vrt        d| dd| t        |      |
      |t        v rd}|}n	|dk7  rd}|}|t        v sa|	s|}	f|	|k7  slt        dd| t        |      |
      |t        vrt        d| dd| t        |      |
      |t        v rd}|}|dk7  sd}|} |s#t        d|rdnd| t        | |dz
           |
      y)a!  Validate the Bidi Rule from :rfc:`5893` for a single label.

    The Bidi Rule constrains how bidirectional characters (Hebrew, Arabic,
    etc.) may appear within a label. By default the check is only applied
    when the label contains at least one right-to-left character (Unicode
    bidirectional categories ``R``, ``AL``, or ``AN``); set ``check_ltr``
    to ``True`` to apply it to LTR-only labels as well.

    :param label: The label to validate, as a Unicode string.
    :param check_ltr: If ``True``, apply the rules even when the label
        contains no RTL characters.
    :returns: ``True`` if the label satisfies the Bidi Rule.
    :raises IDNABidiError: If any of Bidi Rule conditions 1-6 are violated,
        or if the directional category of a codepoint cannot be determined.
    Label too longr   r=   Fr    z Unknown directionality in label  at position r2   rB   Tr   r   zFirst codepoint in label z" must be directionality L, R or ALr,   Nz,Invalid direction for codepoint at position z in a right-to-left labelr-   r   z2Can not mix numeral types in a right-to-left labelr/   z in a left-to-right labelr0   z0Label ends with illegal codepoint directionalityr.   r1   )rs   _max_input_lengthr;   	enumerater[   bidirectionalrS   rc   _bidi_rtl_categories_bidi_rtl_first_bidi_rtl_allowed_bidi_rtl_valid_ending_bidi_rtl_numeric_bidi_ltr_allowed_bidi_ltr_valid_ending)
ru   	check_ltr
bidi_labelidxr   	directionrtlvalid_ending
ending_idxnumber_types
             r   
check_bidir      sd     5z%%(/?@@JUA& R--b1	?25)=N-b'  ,,J i ))%(3IO#	c	'y0RS%(m
 	
 LJ"KUA& 0!R--b1	 11#B3%G`a&!"g   22# 
e#$ 
--""+K I-'L*""%b'!$   11#B3%G`a&!"g   22# 
e#$ 
a0!d  >"%=%
Q/0
 	
 r   c           	     |    | r:t        j                  | d         d   dk(  rt        dd| t        | d         d      y)u^  Reject labels that begin with a combining mark.

    Per :rfc:`5891` §4.2.3.2 a label must not start with a character of
    Unicode general category ``M`` (Mark).

    :param label: The label to check.
    :returns: ``True`` if the first character is not a combining mark.
    :raises IDNAError: If the label begins with a combining character.
    r   Mz0Label begins with an illegal combining characterr'   r   rB   T)r[   categoryr;   rc   rt   s    r   check_initial_combinerr     sK     %%eAh/2c9>#%(m
 	
 r   c                    | dd dk(  rt        dd      | j                  d      s| j                  d      rt        dd	      y
)u  Validate the hyphen restrictions for a label.

    Per :rfc:`5891` §4.2.3.1 a label must not start or end with a hyphen
    (``U+002D``), and must not have hyphens in both the third and fourth
    positions (the prefix reserved for A-labels).

    :param label: The label to check.
    :returns: ``True`` if the hyphen restrictions are satisfied.
    :raises IDNAError: If any of the hyphen restrictions are violated.
          z--z4Label has disallowed hyphens in 3rd and 4th positionr%   r   -z)Label must not start or end with a hyphenr&   T)r;   
startswithendswithrt   s    r   check_hyphen_okr   4  sL     QqzTNUabbs 3CJ\]]r   c                    t        |       t        kD  rt        dd      t        j                  d|       | k7  rt        dd      y)zRequire that a label is in Unicode Normalization Form C.

    :param label: The label to check.
    :raises IDNAError: If ``label`` differs from its NFC normalisation.
    r~   r   r   NFCz%Label must be in Normalization Form Cr$   N)rs   r   r;   r[   	normalizert   s    r   	check_nfcr   F  sH     5z%%(/?@@UE*e3?iPP 4r   c                2   t        |       t        kD  rt        dd      t        | |         }|dk(  r|dkD  r"t	        t        | |dz
                 t
        k(  ryd}t        |dz
  d	d	      D ],  }t        t        | |               }|d
k(  r |t        v rd} n n |syd}t        |dz   t        |             D ].  }t        t        | |               }|d
k(  r |t        v rd} |S  |S  |S |dk(  r(|dkD  xr! t	        t        | |dz
                 t
        k(  S y)a  Validate the CONTEXTJ rules from :rfc:`5892` Appendix A.

    These rules govern the contextual use of the joiner codepoints
    ``U+200C`` (ZERO WIDTH NON-JOINER, Appendix A.1) and ``U+200D``
    (ZERO WIDTH JOINER, Appendix A.2) within a label.

    :param label: The label containing the codepoint.
    :param pos: Index of the joiner codepoint within ``label``.
    :returns: ``True`` if the codepoint at ``pos`` satisfies its CONTEXTJ
        rule, ``False`` otherwise (including when the codepoint at
        ``pos`` is not a recognised joiner).
    :raises ValueError: If an adjacent codepoint has no Unicode name when
        determining its combining class.
    :raises IDNAError: If ``label`` exceeds the defensive input length limit.
    r~   r   r   i   r   r   TFTi   )
rs   r   r;   rc   ra   _virama_combining_classranger   _bidi_joiner_l_or_d_bidi_joiner_r_or_d)ru   poscp_valueokijoining_types         r   valid_contextjr   R  sN     5z%%(/?@@5:H67'E#'N(;<@WWsQwB' 	A(U1X7Ls"22	 sQwE
+ 	A(U1X7Ls"22	 		 	6Qw[+CcAg,?@D[[[r   c                   t        |       t        kD  rt        dd      t        | |         }|dk(  rHd|cxk  xr t        |       dz
  k  nc xr* t        | |dz
           dk(  xr t        | |dz            dk(  S |dk(  r2|t        |       dz
  k  r t        |       dkD  rt	        | |dz      d	      S y
|dv r|dkD  rt	        | |dz
     d      S y
|dk(  r4| D ].  }|dk(  r	t	        |d      st	        |d      st	        |d      s. y y
d|cxk  rdk  rn nt        d | D               S d|cxk  rdk  rn y
t        d | D               S y
)a  Validate the CONTEXTO rules from :rfc:`5892` Appendix A.

    Covers the contextual rules for codepoints such as MIDDLE DOT
    (``U+00B7``), Greek lower numeral sign, Hebrew punctuation, Katakana
    middle dot, and the Arabic-Indic / Extended Arabic-Indic digit ranges.

    :param label: The label containing the codepoint.
    :param pos: Index of the codepoint within ``label``.
    :param exception: Reserved for forward compatibility; currently unused.
    :returns: ``True`` if the codepoint at ``pos`` satisfies its CONTEXTO
        rule, ``False`` otherwise (including when the codepoint is not a
        recognised CONTEXTO codepoint).
    :raises IDNAError: If ``label`` exceeds the defensive input length limit.
    r~   r   r      r   r   l   iu  GreekF>       Hebrewi0  u   ・HiraganaKatakanaHanT`  i  c              3  N   K   | ]  }d t        |      cxk  xr dk  nc   yw)    Nrc   .0r   s     r   	<genexpr>z!valid_contexto.<locals>.<genexpr>  !     BbuB1611B   #%r   r   c              3  N   K   | ]  }d t        |      cxk  xr dk  nc   yw)r   r   Nr   r   s     r   r   z!valid_contexto.<locals>.<genexpr>  r   r   )rs   r   r;   rc   rf   any)ru   r   	exceptionr   r   s        r   valid_contextor     sv    5z%%(/?@@5:H63'Ua'kCcAg,?6,IkcRWX[^_X_R`NaekNkk6UaCJNeC!Gng66##7eC!Gnh776 	BX~"j)ZJ-G:VXZ_K`		
 !E!BEBBBB!E!  BEBBBBr   c           
        t        |       t        kD  rt        dd      t        | t        t
        f      r	 | j                  d      } t        |       dk(  rt        d	d
      t        | d      st        dd      t        |        t        |        t        |        t        |       D ]  \  }}t        |      }t        |t        j                   d         r/t        |t        j                   d         r8	 t#        | |      }|r\t)        dt'        |       d|dz    d| d| ||dz         t        |t        j                   d         r5t+        | |      rt)        dt'        |       d|dz    d| d| ||dz         t-        dt'        |       d|dz    d| dd| ||dz          t/        |        y# t        $ r}t        dd      |d}~ww xY w# t$        $ r.}t        dt'        |       d|dz    d| d| ||dz         |d}~ww xY w)a8  Run the full set of IDNA 2008 validity checks on a single label.

    Applies, in order: NFC normalisation (:func:`check_nfc`), hyphen
    restrictions (:func:`check_hyphen_ok`), the no-leading-combiner rule
    (:func:`check_initial_combiner`), per-codepoint validity (PVALID,
    CONTEXTJ, CONTEXTO classes from :rfc:`5892`), and the Bidi Rule
    (:func:`check_bidi`).

    :param label: The label to validate. ``bytes`` or ``bytearray`` input
        is decoded as UTF-8 first.
    :raises IDNAError: If the label is empty or fails a structural rule.
    :raises InvalidCodepoint: If the label contains a DISALLOWED or
        UNASSIGNED codepoint.
    :raises InvalidCodepointContext: If a CONTEXTJ or CONTEXTO codepoint
        is not valid in its context.
    :raises IDNABidiError: If the Bidi Rule is violated.
    r~   r   r   zutf-8zInvalid UTF-8 in labelr6   Nr   zEmpty Labelr"   Tr{   r    PVALIDCONTEXTJz%Unknown codepoint adjacent to joiner r   r    in r+   rB   zJoiner  not allowed at position r)   CONTEXTO
Codepoint r*   z of z not allowedr(   )rs   r   r;   
isinstancebytes	bytearraydecodeUnicodeDecodeErrorr|   r   r   r   r   rc   r   r   codepoint_classesr   r_   ro   rY   r   rW   r   )ru   errr   r   r   contextj_oks         r   check_labelr     sb   $ 5z%%(/?@@%%+,	TLL)E 5zQM::
 u48(/?@@eE5!U# 'Rr7Xx'A'A('KLXx'A'A*'MN	,UC8 -eHo..GayPTUZT]^#& 1W  x)C)CJ)OP!%-- x 11J3QR7)SWX]W`a#& 1W  #U8_-]37)4yP\]+"q C'R uq " 	T4>JPSS	T,  ;E(O;LMZ]`aZaYbbfglfop,& 1W s/   F5 6G5	G>GG	H)HHc                :   t        |       t        kD  rt        dd      	 | j                  d      }t	        |       t        |      st        dd      |S # t        $ r Y nw xY wt        |        t        t        |       z   }t        |      st        dd      |S )u  Convert a single U-label into its A-label form.

    The result is the ASCII-Compatible Encoding (ACE) form per :rfc:`5891`
    §4: the label is validated, Punycode-encoded, and prefixed with
    ``xn--``. Pure ASCII labels that are already valid IDNA labels are
    returned unchanged (as :class:`bytes`).

    :param label: The label to convert, as a Unicode string.
    :returns: The A-label as ASCII-encoded :class:`bytes`.
    :raises IDNAError: If the label is invalid or the resulting A-label
        exceeds 63 octets.
    r~   r   r   asciir    )
rs   r   r;   ri   ulabelrv   UnicodeEncodeErrorr   _alabel_prefixrl   )ru   label_bytess     r   alabelr     s     5z%%(/?@@ll7+ 	{!+.,3CDD    9U#33Kk*(/?@@s   A 	A#"A#c                   t        |       t        kD  rt        dd      t        | t        t
        f      s	 | j                  d      }n(t	        |       }|j                         st        dd      |j                         }|j                  t              r?|t        t              d }|st        dd	      |j                  d
      r)t        dd	      t        |       |j                  d      S 	 |j                  d      } t!        |       |k7  rt        dd      t        |        | S # t        $ r t        |        | cY S w xY w# t        $ r}t        dd	      |d}~ww xY w)uc  Convert a single A-label into its U-label form.

    Performs the inverse of :func:`alabel`: an ``xn--``-prefixed label is
    Punycode-decoded and validated, and is rejected unless it is the
    canonical A-label for the decoded U-label (:rfc:`5891` §5.3). Labels
    that are already Unicode (or plain ASCII without the ACE prefix) are
    validated and returned as a Unicode string.

    :param label: The label to convert. ``bytes`` or ``bytearray`` input
        is treated as ASCII.
    :returns: The U-label as a Unicode string.
    :raises IDNAError: If the label is malformed or fails validation.
    r~   r   r   r   Invalid ASCII in A-labelr5   Nz5Malformed A-label, no Punycode eligible content foundr3      -z"A-label must not end with a hyphenrh   zInvalid A-labelz=A-label is not the canonical Punycode encoding of its U-labelr4   )rs   r   r;   r   r   r   ri   r   r   isasciilowerr   r   r   r   UnicodeErrorrl   )ru   r   r   s      r   r   r   -  s`    5z%%(/?@@eeY/0	,,w/K
 El""$6_MM##%Kn-!#n"5"78SZjkk%@GWXXK !!'**K"":. ;&W^tuuL? " 	L	*  K)0@AsJKs)   D+ 2E +EE	E#EE#c                    t         j                  |       }|rQt        |j                               }||j	                         z   dz   }t        dt        |       d| d|d|||      y)zRaise if ``text``, a slice of ``domain`` starting at ``offset`` that
    UTS #46 mapping left unchanged, contains an ASCII character disallowed
    under ``UseSTD3ASCIIRules``.r   r   r   r   r8   rB   N)_std3_disallowed_researchrc   groupstartrW   ro   )r>   rz   offsetmatchr@   rA   s         r   _check_std3r   b  sy      &&t,E&	EKKM)A-y)**CH:TRXQ[\
 	
 r   c                 <    t        j                  dt        d       y )NzTransitional processing is deprecated in UTS #46 and has no effect. The transitional argument will be removed in a future version.   )
stacklevel)warningswarnDeprecationWarningrU   r   r   _warn_transitionalr   s  s    MM	I	r   c           	        |r
t                t        |       t        kD  rt        dd      | j	                         r!| j                         }|rt        || d       |S ddlm}m	}m
} g }d}t        |       D ]  \  }	}
t        |
      }|dk  r|nt        j                  ||      dz
  }||   }|t        k(  rA|t         k(  r||   }n>|t"        k(  rZ|t$        k(  rd}n(t'        d	t)        |       d
|	dz    d| d| ||	dz         ||	k  r%| ||	 }|rt        || |       |j+                  |       |rP|r=t,        j/                  |      r(t'        d	t)        |       d
|	dz    d| d| ||	dz         |j+                  |       |	dz   } |dk(  r%|rt        | | d       t1        j2                  d|       S | |d }|rt        || |       |j+                  |       t1        j2                  ddj5                  |            S )u3  Apply the UTS #46 character mapping to a domain string.

    Implements the mapping table from `UTS #46 §4
    <https://www.unicode.org/reports/tr46/>`_: each character is kept,
    replaced, or rejected based on its status (``V``, ``M``, ``D``,
    ``I``, ``X``). The result is returned in Normalisation Form C.

    :param domain: The full domain name to remap.
    :param std3_rules: If ``True``, apply UTS #46's ``UseSTD3ASCIIRules``:
        after mapping, any ASCII character other than a lowercase letter,
        digit, hyphen or the label separator ``.`` is rejected, whether it
        appeared in the input or was produced by a mapping (e.g. U+FF01
        FULLWIDTH EXCLAMATION MARK maps to ``!``). If ``False``, such
        characters are passed through.
    :param transitional: Deprecated and ignored. UTS #46 deprecated
        transitional processing in Unicode 15.1 and deviation (status
        ``D``) codepoints are now always kept, so this has no effect
        beyond emitting a :class:`DeprecationWarning`. It will be removed
        in a future version.
    :returns: The remapped domain, in Normalisation Form C.
    :raises InvalidCodepoint: If the domain contains a disallowed
        codepoint under the chosen rules.
    :raises IDNAError: If ``domain`` exceeds the defensive input length limit.
    Domain too longr   r   r   r   )uts46_replacementsuts46_startsuts46_statuses   Nr   r   r   r7   rB   r8   r   r   )r   rs   r   r;   r   r   r   	uts46datar   r   r   r   rc   bisectbisect_right_STATUS_VALID_STATUS_MAPPED_STATUS_DEVIATION_STATUS_IGNOREDrW   ro   appendr   r   r[   r   join)rz   
std3_rulestransitionalresultr   r   r   outputr   r   char
code_pointr   statusreplacementruntails                    r   uts46_remapr  |  s7   2 
6{&&)0@AA~~ *KK FEv& %	TY
$s*J0C0CLR\0]`a0a" ]"^#,Q/K((&K"U:.//Hq	QUV\U_`'$q  3;s#CC/MM#188E& z!2 33LSSTWIUYZ`Ycd%( 1W  MM+&aK%N z*$$UF33%&>DD&%(
MM$  88r   c                   |r
t                t        | t              s	 t        | d      } t        |       t        kD  rt        dd      |rt        | |      } t        | d	      st        dd
      d}g }|r| j                  d      nt        j                  |       }|r|dgk(  rt        dd      |d   dk(  r|d= d}|D ]-  }	t        |	      } | r|j                  |        "t        dd       |r|j                  d       dj                  |      } t        | |      st        dd
      | S # t        t        f$ r}t        dd      |d}~ww xY w)a*  Encode a Unicode domain name into its ASCII (A-label) form.

    Splits the input on label separators (only ``U+002E`` if ``strict`` is
    set; otherwise also IDEOGRAPHIC FULL STOP ``U+3002``, FULLWIDTH FULL
    STOP ``U+FF0E``, and HALFWIDTH IDEOGRAPHIC FULL STOP ``U+FF61``),
    encodes each label with :func:`alabel`, and rejoins them with ``.``.
    Optionally pre-processes the input through :func:`uts46_remap`.

    :param s: The domain name to encode.
    :param strict: If ``True``, only ``U+002E`` is recognised as a label
        separator.
    :param uts46: If ``True``, apply UTS #46 mapping before encoding.
    :param std3_rules: Forwarded to :func:`uts46_remap` when ``uts46`` is
        ``True``.
    :param transitional: Deprecated and ignored (see :func:`uts46_remap`):
        emits a :class:`DeprecationWarning` and will be removed in a
        future version.
    :returns: The encoded domain as ASCII :class:`bytes`.
    :raises IDNAError: If the domain is empty, contains an invalid label,
        or exceeds the maximum domain length.
    r   zGshould pass a unicode string to the function rather than a byte string.r5   r   Nr   r   Tr   r!   F.r   Empty domainr#   r   Empty labelr"   r      .)r   r   strr   	TypeErrorr;   rs   r   r  r|   split_unicode_dots_rer   r  r  )
rk   strictuts46r  r  r   r{   r  labelsru   s
             r   ri   ri     sb   8 a	AwA
 1v!!)0@AA:&qt4)0ABBLF#QWWS\)9)?)?)BFVt^^<<bzR2J ?5MMM!M>>? c		&Aq,/)0ABBH? #I. 	Y`o	s   D0 0E?EEc                   t        | t              s	 t        | d      } t        |       t        kD  rt	        dd      |rt        | |d      } t        | d	
      st	        dd      d}g }|r| j                  d      nt        j                  |       }|r|dgk(  rt	        dd      |d   s|d= d	}|D ].  }		 t        |	      }
|
r|j                  |
       #t	        dd       |r|j                  d       dj                  |      S # t        t        f$ r}t	        dd      |d}~ww xY w# t        $ r- |r'|	dd j                         dk(  r|	j                         }
n Y w xY w)u  Decode an A-label-encoded domain name back to Unicode.

    Splits the input on label separators (see :func:`encode` for the
    rules), decodes each label with :func:`ulabel`, and rejoins them
    with ``.``. Optionally pre-processes the input through
    :func:`uts46_remap`.

    :param s: The domain name to decode.
    :param strict: If ``True``, only ``U+002E`` is recognised as a label
        separator.
    :param uts46: If ``True``, apply UTS #46 mapping before decoding.
    :param std3_rules: Forwarded to :func:`uts46_remap` when ``uts46`` is
        ``True``.
    :param display: If ``True``, any ``xn--`` label that fails IDNA
        validation is passed through unchanged (lowercased) rather than
        aborting the whole call. Intended for "decode for display"
        consumers (e.g. URL libraries, HTTP clients) that want to show
        the user the label as it appears on the wire when it cannot be
        rendered as Unicode. Matches the per-label recovery prescribed
        by UTS #46 §4 and the WHATWG URL "domain to Unicode" algorithm.
    :returns: The decoded domain as a Unicode string.
    :raises IDNAError: If the input is not valid ASCII, contains an
        invalid label, or is empty.
    r   r   r5   r   Nr   r   FTr   r!   r  r   r  r#   r   r   zxn--r  r"   )r   r  r   r  r;   rs   r   r  r|   r  r  r   r   r  r  )rk   r  r  r  displayr   r{   r  r  ru   us              r   r   r     sx   > a	WAwA 1v!!)0@AA:u-qt4)0ABBLF#QWWS\)9)?)?)BFVt^^<<":2J ?	uA MM!M>>? b88F= #I. 	W6_MSVV	W&  	5!9??,6KKM 	s)   D 7D-D*D%%D*-3E#"E#)r   intrJ   r<   )r   r   rJ   r   )r   r  re   r  rJ   bool)rk   r  rJ   r   )rk   r   rJ   r  )ru   bytes | strrJ   r!  )rz   r"  r{   r!  rJ   r!  )F)ru   r  r   r!  rJ   r!  )ru   r  rJ   r!  )ru   r  rJ   rK   )ru   r  r   r   rJ   r!  )ru   r  r   r   r   r!  rJ   r!  )ru   str | bytes | bytearrayrJ   rK   )ru   r  rJ   r   )ru   r#  rJ   r  )r>   r  rz   r  r   r   rJ   rK   )rJ   rK   )TF)rz   r  r  r!  r  r!  rJ   r  )FFFF)rk   r#  r  r!  r  r!  r  r!  r  r!  rJ   r   )rk   r#  r  r!  r  r!  r  r!  r  r!  rJ   r  );
__future__r   r   rer[   r   typingr   r   r   	intrangesr   r   r   r   r   r  r  r  compiler  r   	frozensetr   r   r   r   r   r   r   r   r   r   
_ErrorCoder   r;   rS   rW   rY   ra   rf   rl   ro   rv   r|   r   r   r   r   r   r   r   r   r   r   r   r  ri   r   rU   r   r   <module>r+     s3   "  	     (  DK A~0/2:::;  bjj!PQ S$K( !23 Z[ "#:; tTl+ NO "C;/ c
+ c
+  
>%! %!PFI FGy GNi N@ 9sl*$	Q3l.bOdD2j
"\9B @@@ @ 	@
 @ @J @@@ @ 	@
 @ 	@r   