
    Rj#X                        S SK r S SKrS SKrS SKrS SKJrJr  SSKJr  SSK	J
r
  SrSr\R                  " S5      r " S	 S
\5      r " S S\5      r " S S\5      r " S S\5      rS\S\4S jrS\S\S\4S jrS\S\4S jrS\S\4S jrS\\\4   S\4S jrS\\\4   S\S\4S jrS1S\S\S\4S jjrS\S\4S jrS\S\4S  jr S\SS4S! jr!S\S"\S\4S# jr"S1S\S"\S$\S\4S% jjr#S\\\\$4   SS4S& jr%S\S\4S' jr&S\\\\$4   S\4S( jr'S2S)\S*\S+\S\4S, jjr(    S3S\\\\$4   S-\S.\S*\S+\S\4S/ jjr)   S4S\\\\$4   S-\S.\S*\S\4
S0 jjr*g)5    N)OptionalUnion   )idnadata)intranges_contain	   s   xn--u   [.。．｡]c                       \ rS rSrSrSrg)	IDNAError   z5Base exception for all IDNA-encoding related problems N__name__
__module____qualname____firstlineno____doc____static_attributes__r       L/var/www/html/Sattelite-Image/venv/lib/python3.13/site-packages/idna/core.pyr
   r
      s    ?r   r
   c                       \ rS rSrSrSrg)IDNABidiError   z;Exception when bidirectional requirements are not satisfiedr   Nr   r   r   r   r   r      s    Er   r   c                       \ rS rSrSrSrg)InvalidCodepoint   z<Exception when a disallowed or unallocated codepoint is usedr   Nr   r   r   r   r   r      s    Fr   r   c                       \ rS rSrSrSrg)InvalidCodepointContext!   zCException when the codepoint is not valid in the context it is usedr   Nr   r   r   r   r   r   !   s    Mr   r   cpreturnc                     [         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_classr(   '   sC    c"g&AAvB((?@@Hr   scriptc                 N    [        [        U 5      [        R                  U   5      $ )N)r   ordr   scripts)r   r)   s     r   
_is_scriptr-   /   s    SWh&6&6v&>??r   sc                 $    U R                  S5      $ )Npunycode)encoder.   s    r   	_punycoder3   3   s    88Jr   c                 $    SR                  U 5      $ )NzU+{:04X})formatr2   s    r   _unotr6   7   s    Qr   labelc                 $    [        U 5      S:  a  gg)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``.
?   FTlenr7   s    r   valid_label_lengthr=   ;   s     5zBr   trailing_dotc                 6    [        U 5      U(       a  SOS:  a  gg)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 label: The full (possibly multi-label) domain name.
:param trailing_dot: ``True`` if ``label`` includes a trailing ``.``.
:returns: ``True`` if the domain is within the length limit, otherwise
    ``False``.
      FTr:   )r7   r>   s     r   valid_string_lengthrB   L   s     5zLSc2r   	check_ltrc                 $   Sn[        U S5       HO  u  p4[        R                  " U5      nUS:X  a$  [        SR	                  [        U 5      U5      5      eUS;   d  MM  SnMQ     U(       d  U(       d  g[        R                  " U S   5      nUS;   a  SnO,US	:X  a  SnO#[        S
R	                  [        U 5      5      5      eSnSn[        U S5       H  u  p4[        R                  " U5      nU(       aV  US;  a  [        SR	                  U5      5      eUS;   a  SnOUS:w  a  SnUS;   a  U(       d  UnMd  X:w  a  [        S5      eMv  Mx  US;  a  [        SR	                  U5      5      eUS;   a  SnM  US:w  d  M  SnM     U(       d  [        S5      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.
Fr    z1Unknown directionality in label {} at position {})RALANTr   )rF   rG   Lz=First codepoint in label {} must be directionality L, R or ALN)
rF   rG   rH   ENESCSETONBNNSMzGInvalid direction for codepoint at position {} in a right-to-left label)rF   rG   rJ   rH   rP   )rH   rJ   z2Can not mix numeral types in a right-to-left label)rI   rJ   rK   rL   rM   rN   rO   rP   zGInvalid direction for codepoint at position {} in a left-to-right label)rI   rJ   z0Label ends with illegal codepoint directionality)	enumerater"   bidirectionalr   r5   repr)	r7   rC   
bidi_labelidxr   	directionrtlvalid_endingnumber_types	            r   
check_bidirZ   \   s   " JUA&--b1	? S Z Z[_`e[fhk lmm))J ' i ))%(3IK	c	[bbcghmcnoppL!%KUA&--b1	 !  $$m$t$tux$yzz33#e#$L(""+K"/+,`aa 0	 )  PP#$m$t$tux$yzzK'#e#$M 'P NOOr   c                 Z    [         R                  " U S   5      S   S:X  a  [        S5      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 characterT)r"   categoryr
   r<   s    r   check_initial_combinerr^      s/     E!H%a(C/JKKr   c                 f    U SS S:X  a  [        S5      eU S   S:X  d	  U S   S:X  a  [        S5      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   -z)Label must not start or end with a hyphenT)r
   r<   s    r   check_hyphen_okrd      sC     QqzTNOOQx3%)s*CDDr   c                 P    [         R                  " SU 5      U :w  a  [        S5      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.
NFCz%Label must be in Normalization Form CN)r"   	normalizer
   r<   s    r   	check_nfcrh      s*     UE*e3?@@ 4r   posc                    [        X   5      nUS:X  Ga*  US:  a"  [        [        XS-
     5      5      [        :X  a  gSn[        US-
  SS5       Ha  n[        R
                  " 5       R                  [        X   5      5      nU[        S5      :X  a  MC  U[        S5      [        S	5      4;   a  Sn  O  O   U(       d  gSn[        US-   [        U 5      5       Hc  n[        R
                  " 5       R                  [        X   5      5      nU[        S5      :X  a  MC  U[        S
5      [        S	5      4;   a  Sn  U$   U$    U$ US:X  a)  US:  a"  [        [        XS-
     5      5      [        :X  a  ggg)as  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.
i   r   r   TFrc   TrI   DrF   i   )r+   r(   _virama_combining_classranger   joining_typesgetr;   )r7   ri   cp_valueokijoining_types         r   valid_contextjru      s`    5:H67E'N 348OOsQwB'A#11377EHFLs3x'#c(CH!55 ( sQwE
+A#11377EHFLs3x'#c(CH!55 	 	 , 	67E'N 348OO r   	exceptionc                    [        X   5      nUS:X  aF  SUs=:  a  [        U 5      S-
  :  a,  O  g[        XS-
     5      S:X  a  [        XS-      5      S:X  a  ggUS:X  a3  U[        U 5      S-
  :  a   [        U 5      S:  a  [        XS-      S5      $ gUS	:X  d  US
:X  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&U  H  nS[        U5      s=::  a
  S::  d  M     g  M!     gSUs=::  a  S::  a)  O  gU  H  nS[        U5      s=::  a
  S::  d  M     g  M!     gg)ac  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).
   r   r   l   TFiu  Greeki  i  Hebrewi0  u   ・HiraganaKatakanaHani`  ii  i  i  )r+   r;   r-   )r7   ri   rv   rq   r   s        r   valid_contextor     s    5:H6s#SZ!^#  5q>"f,U7^1D1N	V	UaCJNe!Gng66	V	x617e!Gnh77	V	BX~"j))ZJ-G-G:VXZ_K`K`	 
 	(	#e	#BB)6) *  	(	#e	#  BB)6) *  r   c                    [        U [        [        45      (       a  U R                  S5      n [	        U 5      S:X  a  [        S5      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      (       aD   [        X5      (       d1  [        SR!                  [#        U5      US-   [%        U 5      5      5      eM  [        U[        R                  S	   5      (       aD  [)        X5      (       d1  [        S
R!                  [#        U5      US-   [%        U 5      5      5      eGM  [+        SR!                  [#        U5      US-   [%        U 5      5      5      e   [-        U 5        g! [&         a2    [        SR!                  [#        U5      US-   [%        U 5      5      5      e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.
zutf-8r   zEmpty LabelPVALIDCONTEXTJz*Joiner {} not allowed at position {} in {}r   z<Unknown codepoint adjacent to joiner {} at position {} in {}CONTEXTO-Codepoint {} not allowed at position {} in {}z-Codepoint {} at position {} of {} not allowedN)
isinstancebytes	bytearraydecoder;   r
   rh   rd   r^   rQ   r+   r   r   codepoint_classesru   r   r5   r6   rS   r&   r   r   rZ   )r7   ri   r   rq   s       r   check_labelr   M  s   $ %%+,,W%
5zQ&&eE5!U#r7Xx'A'A('KLLx)C)CJ)OPP
%e111DKKERZO]`cd]dfjkpfqr  2 x)C)CJ)OPP!%---CJJ5QY?\_bc\ceijoepq  .
 #?FFuXX[^_X_aefkalm - $4 u!  RYYhq$u+ s   AF33<G/c                 
    U R                  S5      n[        U5        [        U5      (       d  [        S5      eU$ ! [         a     Of = f[        U 5        [        [        U 5      -   n[        U5      (       d  [        S5      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.
asciizLabel too long)r1   ulabelr=   r
   UnicodeEncodeErrorr   _alabel_prefixr3   r7   label_bytess     r   alabelr     s    ll7+{!+..,--   9U#33Kk**())s   8; 
AAc                 :   [        U [        [        45      (       d   U R                  S5      nO[        U 5      nUR                  5       nUR                  [        5      (       aH  U[        [        5      S nU(       d  [        S5      eUR                  S5      S   S:X  a  [        S5      eO[        U5        UR                  S5      $  UR                  S5      n [        U 5        U $ ! [         a    [        U 5        U s $ f = f! [         a    [        S5      ef = f)	a  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. 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   Nz5Malformed A-label, no Punycode eligible content foundrc   rb   z"A-label must not end with a hyphenr0   zInvalid A-label)r   r   r   r1   r   r   lower
startswithr   r;   r
   r   UnicodeErrorr   s     r   r   r     s    eeY/00	,,w/K
 El##%Kn--!#n"5"78STTg&r*c1@AA 2 	K !!'**+"":. L- " 	L	&  +)**+s   C' 	D 'D DDdomain
std3_rulestransitionalc           
         SSK J n  Sn[        U 5       H  u  pV[        U5      nX7S:  a  UO[        R                  " X7S45      S-
     nUS   n	Sn
[        U5      S:X  a  US   n
U	S	:X  d  U	S
:X  a  U(       a  U	S:X  a  U(       d	  U
c  XF-  nMy  U
b&  U	S:X  d  U	S:X  a  U(       a  U	S
:X  a  U(       a  XJ-  nM  U	S:X  a  M  [        SR                  [        U5      US-   [        U 5      5      5      e   [        R                  " SU5      $ )ur  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``, ``3``,
``I``). The result is returned in Normalisation Form C.

:param domain: The full domain name to remap.
:param std3_rules: If ``True``, apply the stricter STD3 ASCII rules
    (status ``3`` codepoints raise instead of being kept or mapped).
:param transitional: If ``True``, use transitional processing (status
    ``D`` codepoints are mapped instead of kept). Transitional
    processing has been removed from UTS #46 and this option is
    retained only for backwards compatibility.
:returns: The remapped domain, in Normalisation Form C.
:raises InvalidCodepoint: If the domain contains a disallowed
    codepoint under the chosen rules.
r   )	uts46datarE      ZN   r`   Vrl   3r\   Ir   rf   )r   rQ   r+   bisectbisect_leftr;   r   r5   r6   rS   r"   rg   )r   r   r   r   outputri   char
code_pointuts46rowstatusreplacements              r   uts46_remapr     s   & %Fv&	Y
+;ZASAST]lo_pAqtuAuv!%)x=A"1+KS=Vs]<Vs][ejuj}NF$cMfmJFcMVb!Fs]"?FFuZGXZ]`aZacghncop ! '(   //r   strictuts46c                    U(       a  [         R                  " S[        SS9  [        U [        5      (       d   [	        U S5      n U(       a  [        XU5      n [        U SS9(       d  [        S5      eS	n/ nU(       a  U R                  S
5      nO[        R                  U 5      nU(       a  US/:X  a  [        S5      eUS   S:X  a  US	 SnU H1  n[        U5      n U (       a  UR                  U 5        M(  [        S5      e   U(       a  UR                  S5        SR                  U5      n [        X5      (       d  [        S5      eU $ ! [
        [        4 a    [        S5      e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: Forwarded to :func:`uts46_remap` when ``uts46``
    is ``True``. Deprecated: 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.
zuTransitional processing has been removed from UTS #46. The transitional argument will be removed in a future version.r`   )
stacklevelr   zGshould pass a unicode string to the function rather than a byte string.Tr>   Domain too longF.rE   Empty domainrc   Empty labelr      .)warningswarnDeprecationWarningr   strUnicodeDecodeError	TypeErrorr
   r   rB   split_unicode_dots_rer   appendjoin)	r.   r   r   r   r   r>   resultlabelsr7   s	            r   r1   r1     sM   8 M		
 a	gAwA |4 qt4)**LF!''*Vt^''bzR2J5MMM!M**  c		&Aq//)**HA #I. 	geff	gs   E E#c                 R   [        U [        5      (       d   [        U S5      n U(       a  [        XS5      n [        U SS9(       d  [	        S5      eSn/ nU(       d  [        R                  U 5      nOU R                  S5      nU(       a  US/:X  a  [	        S	5      eUS
   (       d  US
	 SnU H1  n[        U5      n U (       a  UR                  U 5        M(  [	        S5      e   U(       a  UR                  S5        SR                  U5      $ ! [        [        4 a    [	        S5      ef = f)a  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``.
: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   zInvalid ASCII in A-labelFTr   r   r   rE   r   rc   r   )r   r   r   r   r
   r   rB   r   r   r   r   r   )r.   r   r   r   r>   r   r   r7   s           r   r   r   D  s   . a	8AwA u- qt4)**LF!''*Vt^''":2J5MMM!M**  b88F7 #I. 	8677	8s   D
 
D&)F)TF)FFFF)FFF)+r   rer"   r   typingr   r   rE   r   	intrangesr   rm   r   compiler   r   r
   r   r   r   intr(   r   boolr-   r   r3   r6   r=   rB   rZ   r^   rd   rh   ru   r   r   r   r   r   r   r1   r   r   r   r   <module>r      s    	   "  ( :::; 	 		I 		y 		i 	  @3 @ @ @      S  S  eE3J/ D "uUCZ0    Rc Rd Rt Rj# $ 3 4 $AS AT A7# 7C 7D 7t4# 4C 4D 4T 4n5uS%23 5 5p# % >&%UI-. &3 &R+0 +0 +0D +0UX +0` FS%"#FF F 	F
 F FV 	5S%"#55 5 	5
 	5r   