
    pj~                       S SK Jr  S SKrS SKrS SKrS SKrS SKJr  SSKJ	r	  SSK
Jr  SrSrS	rS
u  rrrr\R&                  " S5      r\R&                  " S5      r\" SS15      r\" 1 Sk5      r\" 1 Sk5      r\" 1 Sk5      r\" SS15      r\" 1 Sk5      r\" SS15      r\" SS15      r\" SS15      rS5S jr \S   r! " S S\"5      r# " S S\#5      r$ " S S\#5      r% " S S \#5      r&S6S! jr'S7S" jr(S8S# jr)S9S$ jr*S:S% jr+S;S& jr,S<S=S' jjr-S>S( jr.S>S) jr/S?S* jr0S@S+ jr1S<SAS, jjr2SBS- jr3SCS. jr4SDS/ jr5SES0 jr6SFS1 jr7SGSHS2 jjr8    SI           SJS3 jjr9    SI           SKS4 jjr:g)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                z    [         R                  R                  5        H  u  p[        X5      (       d  M  Us  $    g N)r   joining_typesitemsr   )cpjtrangess      E/var/www/html/pdf-tiff/venv/lib/python3.13/site-packages/idna/core.py_joining_typer      s2    ,,224
R((I 5     )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                  ~   ^  \ rS rSr% SrS\S'   S\S'   S\S'   S\S'   S	S	S	S	S
.           SU 4S jjjrSrU =r$ )	IDNAErrorE   a  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?   rA   rB   c               P   > [         TU ]  " U6   Xl        X l        X0l        X@l        g r   )super__init__r>   r?   rA   rB   )selfr>   r?   rA   rB   args	__class__s         r   rF   IDNAError.__init__^   s&     	$		" r   )r>   rA   rB   r?   )rH   objectr>   z_ErrorCode | Noner?   r=   rA   r@   rB   r@   returnNone)	__name__
__module____qualname____firstlineno____doc____annotations__rF   __static_attributes____classcell__)rI   s   @r   r;   r;   E   st    & 

 #' $#!!  ! 	!
 ! ! 
! !r   r;   c                      \ rS rSrSrSrg)IDNABidiErrorm   z;Exception when bidirectional requirements are not satisfied NrN   rO   rP   rQ   rR   rT   rY   r   r   rW   rW   m   s    Er   rW   c                      \ rS rSrSrSrg)InvalidCodepointq   z<Exception when a disallowed or unallocated codepoint is usedrY   NrZ   rY   r   r   r\   r\   q   s    Fr   r\   c                      \ rS rSrSrSrg)InvalidCodepointContextu   zCException when the codepoint is not valid in the context it is usedrY   NrZ   rY   r   r   r_   r_   u   s    Mr   r_   c                    [         R                  " [        U 5      5      nUS:X  a/  [         R                  " [        U 5      5      (       d  [	        S5      eU$ )Nr   z Unknown character in unicodedata)unicodedata	combiningchrname
ValueError)r   vs     r   _combining_classrh   y   sB    c"g&AAvk&&s2w//;<<Hr   c                N    [        [        U 5      [        R                  U   5      $ r   )r   ordr   scripts)r   scripts     r   
_is_scriptrm      s    SWh&6&6v&>??r   c                $    U R                  S5      $ )Npunycode)encodess    r   	_punycoders      s    88Jr   c                    SU S 3$ )NzU+04XrY   rq   s    r   _unotrv      s    #w<r   c                    [        U 5      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_lengthr}      s     u:r   c                4    [        U 5      U(       a  S:*  $ 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``.
      ry   )domaintrailing_dots     r   valid_string_lengthr      s     v;,388C88r   c           
        [        U 5      [        :  a
  [        SSS9eSn[        U S5       HL  u  p4[        R
                  " U5      nUS:X  a  [        SU < SU 3S	U [        U5      US
9eU[        ;   d  MJ  SnMN     U(       d  U(       d  g[        R
                  " U S   5      nU[        ;   a  SnO'US:X  a  SnO[        SU < S3SU [        U S   5      SS
9eSnSnSn	[        U S5       H  u  p4[        R
                  " U5      nU(       aq  U[        ;  a  [        SU S3SU [        U5      US
9eU[        ;   a  SnUnO
US:w  a  SnUnU[        ;   a(  U	(       d  Un	Mt  X:w  a  [        SSU [        U5      US
9eM  M  U[        ;  a  [        SU S3SU [        U5      US
9eU[        ;   a  SnUnM  US:w  d  M  SnUnM     U(       d$  [        SU(       a  SOSU [        XS-
     5      US
9eg)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   rC   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   )rz   _max_input_lengthr;   	enumeraterb   bidirectionalrW   rj   _bidi_rtl_categories_bidi_rtl_first_bidi_rtl_allowed_bidi_rtl_valid_ending_bidi_rtl_numeric_bidi_ltr_allowed_bidi_ltr_valid_ending)
r|   	check_ltr
bidi_labelidxr   	directionrtlvalid_ending
ending_idxnumber_types
             r   
check_bidir      s\     5z%%(/?@@JUA&--b1	?25)=N-b'  ,,J ' i ))%(3IO#	c	'y0RS%(m
 	
 LJ"KUA&--b1	 11#B3%G`a&!"g   22# 
e#$ 
--""+K -'L*""%b'!$  . .  11#B3%G`a&!"g   22# 
e#$ 
a 'd  >"%=%Q/0
 	
 r   c           	         U (       a9  [         R                  " U S   5      S   S:X  a  [        SSU [        U S   5      SS9eg)uF  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   rC   T)rb   categoryr;   rj   r{   s    r   check_initial_combinerr     sK     %%eAh/2c9>#%(m
 	
 r   c                    U SS S:X  a
  [        SSS9eU R                  S5      (       d  U R                  S5      (       a
  [        SS	S9eg
)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endswithr{   s    r   check_hyphen_okr   4  sR     QqzTNUabbs 3 3CJ\]]r   c                    [        U 5      [        :  a
  [        SSS9e[        R                  " SU 5      U :w  a
  [        SSS9eg)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)rz   r   r;   rb   	normalizer{   s    r   	check_nfcr   F  sH     5z%%(/?@@UE*e3?iPP 4r   c                T   [        U 5      [        :  a
  [        SSS9e[        X   5      nUS:X  a  US:  a"  [	        [        XS-
     5      5      [
        :X  a  gSn[        US-
  S	S	5       H/  n[        [        X   5      5      nUS
:X  a  M!  U[        ;   a  Sn  O  O   U(       d  gSn[        US-   [        U 5      5       H1  n[        [        X   5      5      nUS
:X  a  M!  U[        ;   a  Sn  U$   U$    U$ US:X  a,  US:  =(       a     [	        [        XS-
     5      5      [
        :H  $ g)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   )
rz   r   r;   rj   rh   _virama_combining_classranger   _bidi_joiner_l_or_d_bidi_joiner_r_or_d)r|   poscp_valueokijoining_types         r   valid_contextjr   R  s:     5z%%(/?@@5:H67'E'N(;<@WWsQwB'A(UX7Ls"22 ( sQwE
+A(UX7Ls"22	 	 , 	6Qw[+CAg,?@D[[[r   c                   [        U 5      [        :  a
  [        SSS9e[        X   5      nUS:X  aU  SUs=:  =(       a    [        U 5      S-
  :  Os  =(       a-    [        XS-
     5      S:H  =(       a    [        XS-      5      S:H  $ US:X  a3  U[        U 5      S-
  :  a   [        U 5      S:  a  [	        XS-      S	5      $ g
US;   a  US:  a  [	        XS-
     S5      $ g
US:X  aG  U  H@  nUS:X  a  M  [	        US5      (       d$  [	        US5      (       d  [	        US5      (       d  M@    g   g
SUs=::  a  S::  a  O  O[        S U  5       5      (       + $ SUs=::  a  S::  a  O  g
[        S U  5       5      (       + $ g
)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  ^   #    U  H#  nS [        U5      s=:*  =(       a    S:*  Os  v   M%     g7f)    Nrj   .0r   s     r   	<genexpr>!valid_contexto.<locals>.<genexpr>  $     BEbuB11611E   +-r   r   c              3  ^   #    U  H#  nS [        U5      s=:*  =(       a    S:*  Os  v   M%     g7f)r   r   Nr   r   s     r   r   r     r   r   )rz   r   r;   rj   rm   any)r|   r   	exceptionr   r   s        r   valid_contextor     sr    5z%%(/?@@5:H63''Ua'kCAg,?6,IkcRW^_X_R`NaekNkk6UaCJNe!Gng66##7e!Gnh776BX~"j))ZJ-G-G:VXZ_K`K`	 
 !E!BEBBBB!E!  BEBBBBr   c           
     @   [        U 5      [        :  a
  [        SSS9e[        U [        [
        45      (       a   U R                  S5      n [        U 5      S:X  a
  [        S	S
S9e[        U SS9(       d
  [        SSS9e[        U 5        [        U 5        [        U 5        [        U 5       GH  u  p#[        U5      n[        U[        R                   S   5      (       a  M5  [        U[        R                   S   5      (       a;   [#        X5      nU(       d&  [)        S['        U5       SUS-    SU < 3SU UUS-   S9eM  [        U[        R                   S   5      (       a8  [+        X5      (       d&  [)        S['        U5       SUS-    SU < 3SU UUS-   S9eM  [-        S['        U5       SUS-    SU < S3SU UUS-   S9e   [/        U 5        g! [         a  n[        SSS9UeSnAff = f! [$         a,  n[        S['        U5       SUS-    SU < 3SU UUS-   S9UeSnAff = f)a   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+   rC   zJoiner  not allowed at position r)   CONTEXTO
Codepoint r*   z of z not allowedr(   )rz   r   r;   
isinstancebytes	bytearraydecodeUnicodeDecodeErrorr   r   r   r   r   rj   r   r   codepoint_classesr   rf   rv   r_   r   r\   r   )r|   errr   r   r   contextj_oks         r   check_labelr     sp   $ 5z%%(/?@@%%+,,	TLL)E 5zQM::
 u48(/?@@eE5!U#r7Xx'A'A('KLLXx'A'A*'MNN	,U8 -eHo..GayPTUZT]^#& 1W   x)C)CJ)OP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/   G
 G'

G$GG$'
H1'HHc                @   [        U 5      [        :  a
  [        SSS9e U R                  S5      n[	        U5        [        U5      (       d
  [        SSS9eU$ ! [         a     Of = f[        U 5        [        [        U 5      -   n[        U5      (       d
  [        SSS9eU$ )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    )
rz   r   r;   rp   ulabelr}   UnicodeEncodeErrorr   _alabel_prefixrs   )r|   label_bytess     r   alabelr     s     5z%%(/?@@ll7+ 	{!+..,3CDD    9U#33Kk**(/?@@s   A 
A$#A$c                   [        U 5      [        :  a
  [        SSS9e[        U [        [
        45      (       d   U R                  S5      nO*[	        U 5      nUR                  5       (       d
  [        SSS9eUR                  5       nUR                  [        5      (       aD  U[        [        5      S nU(       d
  [        SS	S9eUR                  S
5      (       a
  [        SS	S9eO[        U5        UR                  S5      $  UR                  S5      n [!        U 5      U:w  a
  [        SSS9e[        U 5        U $ ! [         a    [        U 5        U s $ f = f! [         a  n[        SS	S9UeSnAff = f)u;  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 hyphenro   zInvalid A-labelz=A-label is not the canonical Punycode encoding of its U-labelr4   )rz   r   r;   r   r   r   rp   r   r   isasciilowerr   r   r   r   UnicodeErrorrs   )r|   r   r   s      r   r   r   -  ss    5z%%(/?@@eeY/0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)   D8 E 8EE
E/E**E/c                    [         R                  U 5      nU(       aN  [        UR                  5       5      nX#R	                  5       -   S-   n[        S[        U5       SU SU< 3SUUUS9eg)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   rC   N)_std3_disallowed_researchrj   groupstartr\   rv   )r?   r   offsetmatchrA   rB   s         r   _check_std3r   b  sw      &&t,E&	KKM)A-y)**CH:TRXQ[\
 	
 r   c                 8    [         R                  " S[        SS9  g )NzTransitional processing is deprecated in UTS #46 and has no effect. The transitional argument will be removed in a future version.   )
stacklevel)warningswarnDeprecationWarningrY   r   r   _warn_transitionalr   s  s    MM	I	r   c           	     L   U(       a
  [        5         [        U 5      [        :  a
  [        SSS9eU R	                  5       (       a%  U R                  5       nU(       a  [        X0S5        U$ SSKJnJ	nJ
n  / nSn[        U 5       GH!  u  p[        U
5      nUS:  a  UO[        R                  " X[5      S-
  nXl   nU[        :X  a  MB  U[         :X  a  XL   nO?U["        :X  a  M]  U[$        :X  a  SnO&['        S	[)        U5       S
U	S-    SU < 3SU UU	S-   S9eX:  a(  XU	 nU(       a  [        XU5        UR+                  U5        U(       aX  U(       a@  [,        R/                  U5      (       a&  ['        S	[)        U5       S
U	S-    SU < 3SU UU	S-   S9eUR+                  U5        U	S-   nGM$     US:X  a*  U(       a  [        X S5        [0        R2                  " SU 5      $ XS nU(       a  [        UX5        UR+                  U5        [0        R2                  " SSR5                  U5      5      $ )u  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   rC   r8   r   r   )r   rz   r   r;   r   r   r   	uts46datar  r  r  r   rj   bisectbisect_right_STATUS_VALID_STATUS_MAPPED_STATUS_DEVIATION_STATUS_IGNOREDr\   rv   appendr   r   rb   r   join)r   
std3_rulestransitionalresultr  r  r  outputr   r   char
code_pointr   statusreplacementruntails                    r   uts46_remapr  |  s!   2 
6{&&)0@AA~~ *KK FEv&	Y
$s*J0C0CL0]`a0a" ]"^#,/K((&K"U:.//Hq	QUV\U_`'$q  ;s#CC/MM#188EE& z!2 33LSSTWIUYZ`Ycd%( 1W  MM+&aK 'N z*$$UF33&>DD&(
MM$  88r   c                   U(       a
  [        5         [        U [        5      (       d   [        U S5      n [        U 5      [        :  a
  [        SSS9eU(       a  [        X5      n [        U SS	9(       d
  [        SS
S9eSn/ nU(       a  U R                  S5      O[        R                  U 5      nU(       a  US/:X  a
  [        SSS9eUS   S:X  a  US	 SnU H0  n	[        U	5      n U (       a  UR                  U 5        M(  [        SSS9e   U(       a  UR                  S5        SR                  U5      n [        X5      (       d
  [        SS
S9eU $ ! [        [        4 a  n[        SSS9UeSnAff = f)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;   rz   r   r  r   split_unicode_dots_rer   r  r  )
rr   strictuts46r  r  r   r   r  labelsr|   s
             r   rp   rp     s_   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   E E.E))E.c                   [        U [        5      (       d   [        U S5      n [        U 5      [        :  a
  [	        SSS9eU(       a  [        XS5      n [        U S	S
9(       d
  [	        SSS9eSn/ nU(       a  U R                  S5      O[        R                  U 5      nU(       a  US/:X  a
  [	        SSS9eUS   (       d  US	 S	nU H1  n	 [        U	5      n
U
(       a  UR                  U
5        M)  [	        SSS9e   U(       a  UR                  S5        SR                  U5      $ ! [        [        4 a  n[	        SSS9UeSnAff = f! [         a2    U(       a)  U	SS R                  5       S:X  a  U	R                  5       n
 Ne f = f)uy  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;   rz   r   r  r   r   r!  r   r   r  r  )rr   r"  r#  r  displayr   r   r  r$  r|   us              r   r   r     so   > 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$ 
E$E4D??E8FF)r   intrL   r=   )r   r(  rL   r(  )r   r  rl   r  rL   bool)rr   r  rL   r   )rr   r(  rL   r  )r|   bytes | strrL   r)  )r   r*  r   r)  rL   r)  )F)r|   r  r   r)  rL   r)  )r|   r  rL   r)  )r|   r  rL   rM   )r|   r  r   r(  rL   r)  )r|   r  r   r(  r   r)  rL   r)  )r|   str | bytes | bytearrayrL   rM   )r|   r  rL   r   )r|   r+  rL   r  )r?   r  r   r  r   r(  rL   rM   )rL   rM   )TF)r   r  r  r)  r  r)  rL   r  )FFFF)rr   r+  r"  r)  r#  r)  r  r)  r  r)  rL   r   )rr   r+  r"  r)  r#  r)  r  r)  r&  r)  rL   r  );
__future__r   r  rerb   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;   rW   r\   r_   rh   rm   rs   rv   r}   r   r   r   r   r   r   r   r   r   r   r   r   r  rp   r   rY   r   r   <module>r3     s/   "  	     (  DK A~0/:::; jj!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   