
    pj                    H   S SK Jr  S SKrS SKJr  SSKJrJrJrJ	r	J
r
Jr   " S S\R                  5      r " S S	\R                  5      r " S
 S\R                  5      r " S S\\R"                  5      r " S S\\R$                  5      rSS jr\R(                  " \5        g)    )annotationsN)Any   )	IDNAError_unicode_dots_realabeldecodeencodeulabelc                  4    \ rS rSrSrSSS jjrSS	S jjrSrg)
Codec	   aN  Stateless IDNA 2008 codec.

Implements the :class:`codecs.Codec` protocol so that the whole-domain
encoder (:func:`idna.encode`) and decoder (:func:`idna.decode`) are
accessible through the standard codec machinery as ``"idna2008"``.

Only the ``"strict"`` error handler is supported; any other handler
raises :exc:`~idna.IDNAError`.
c                f    US:w  a  [        SU S3SS9eU(       d  g[        U5      [        U5      4$ )NstrictUnsupported error handling ""unsupported_errorscode    r   )r   r
   lenselfdataerrorss      F/var/www/html/pdf-tiff/venv/lib/python3.13/site-packages/idna/codec.pyr
   Codec.encode   s;    X:6(!DK_``d|SY&&r   c                f    US:w  a  [        SU S3SS9eU(       d  g[        U5      [        U5      4$ )Nr   r   r   r   r    r   )r   r	   r   r   s      r   r	   Codec.decode   s;    X:6(!DK_``d|SY&&r    N)r   )r   strr   r$   returntuple[bytes, int])r   bytesr   r$   r%   tuple[str, int])__name__
__module____qualname____firstlineno____doc__r
   r	   __static_attributes__r#   r   r   r   r   	   s    '' 'r   r   c                  "    \ rS rSrSrSS jrSrg)IncrementalEncoder'   a  Incremental IDNA 2008 encoder.

Buffers a partial trailing label across calls until either the next
label separator is seen or ``final=True``, so that streamed input is
encoded one whole label at a time. Any of the four Unicode label
separators (``U+002E``, ``U+3002``, ``U+FF0E``, ``U+FF61``) ends a
label; the result always uses ``U+002E`` as the separator.

Only the ``"strict"`` error handler is supported.
c                   US:w  a  [        SU S3SS9eU(       d  g[        R                  " U5      nSnU(       a#  US   (       d  S	nUS	 OU(       d  US	 U(       a  S	n/ nS
nU H7  nUR                  [	        U5      5        U(       a  US-  nU[        U5      -  nM9     S	R                  U5      U-   n	U[        U5      -  nX4$ )Nr   r   r   r   r   r   r      .r   r   )r   r   splitappendr   r   join)
r   r   r   finallabelstrailing_dotresultsizelabelresult_bytess
             r   _buffer_encode!IncrementalEncoder._buffer_encode3   s    X:6(!DK_``!''-":#2J2J#'LEMM&-(	CJD	  yy(<7L!!!!r   r#   N)r   r$   r   r$   r8   boolr%   r&   )r)   r*   r+   r,   r-   r?   r.   r#   r   r   r0   r0   '   s    	"r   r0   c                  "    \ rS rSrSrSS jrSrg)IncrementalDecoderS   zIncremental IDNA 2008 decoder.

Buffers a partial trailing label across calls until either the next
label separator is seen or ``final=True``, so that streamed input is
decoded one whole label at a time.

Only the ``"strict"`` error handler is supported.
c                   US:w  a  [        SU S3SS9eU(       d  g[        U[        5      (       d   [        US5      n[        R
                  " U5      nS
nU(       a#  US   (       d  SnUS	 OU(       d  US	 U(       a  Sn/ nSnU H7  n	UR                  [        U	5      5        U(       a  US-  nU[        U	5      -  nM9     SR                  U5      U-   n
U[        U5      -  nX4$ ! [         a  n[        SS	S9UeS nAff = f)Nr   r   r   r   r   r    asciizInvalid ASCII in A-labelinvalid_asciir!   r3   .r   r   )
r   
isinstancer$   UnicodeDecodeErrorr   r5   r6   r   r   r7   )r   r   r   r8   errr9   r:   r;   r<   r=   
result_strs              r   _buffer_decode!IncrementalDecoder._buffer_decode]   s   X:6(!DK_``$$$[4) "''-":"2J2J#&LEMM&-(	CJD	  XXf%4
L!!!!3 & [ :QWZZ[s   C' '
D1C<<Dr#   N)r   r   r   r$   r8   rA   r%   r(   )r)   r*   r+   r,   r-   rM   r.   r#   r   r   rC   rC   S   s    #"r   rC   c                      \ rS rSrSrg)StreamWriter   r#   Nr)   r*   r+   r,   r.   r#   r   r   rP   rP          r   rP   c                      \ rS rSrSrg)StreamReader   r#   NrR   r#   r   r   rU   rU      rS   r   rU   c           
         U S:w  a  g[         R                  " U [        5       R                  [        5       R                  [
        [        [        [        S9$ )a  Codec search function registered with :mod:`codecs`.

Returns a :class:`codecs.CodecInfo` for the ``"idna2008"`` codec name
so that ``str.encode("idna2008")`` and ``bytes.decode("idna2008")``
invoke the IDNA 2008 codec defined in this module.

:param name: The codec name being looked up.
:returns: A :class:`codecs.CodecInfo` instance if ``name`` is
    ``"idna2008"``, otherwise ``None``.
idna2008N)namer
   r	   incrementalencoderincrementaldecoderstreamwriterstreamreader)	codecs	CodecInfor   r
   r	   r0   rC   rP   rU   )rY   s    r   search_functionr`      sC     zw~~w~~--!! r   )rY   r$   r%   zcodecs.CodecInfo | None)
__future__r   r^   typingr   corer   r   r   r	   r
   r   r   BufferedIncrementalEncoderr0   BufferedIncrementalDecoderrC   rP   rU   r`   registerr#   r   r   <module>rg      s    "   M M'FLL '<)":: )"X-":: -"`	5&-- 		5&-- 	0   r   