§
    |Øj  ã                   ó¬   — d Z ddlZddlmZ dZdZdZdZ e e	d¦  «        ¦  «        Z
 ej        d	¦  «        Zd
edefd„Zdededz  fd„Zdeddfd„ZdS )aj  Stage 1d: UTF-8 structural validation.

Validation is decode-based: CPython's strict UTF-8 decoder enforces exactly
the rules the old hand-rolled loop checked (overlong encodings, surrogates,
codepoints above U+10FFFF) at C speed on every build flavor, where a per-byte
loop runs an order of magnitude slower even compiled.  See ADR-0006.

The input is fed to an incremental decoder in chunks so a large input never
allocates a matching ``str``; decoded output is discarded.  ``final=False``
reproduces the truncated-tail tolerance (an incomplete multi-byte sequence at
the very end is fine, the input is usually a prefix of a larger whole), the
same trick :func:`chardet._utils.decodes_without_error` uses.

Note: ``from __future__ import annotations`` is intentionally omitted because
this module is compiled with mypyc, which does not support PEP 563 string
annotations.
é    N)ÚDetectionResultgš™™™™™é?g®Gáz®ï?é   i   é€   úutf-8ÚbyteÚreturnc                 ór   — d| cxk    rdk    rn ndS d| cxk    rdk    rn ndS d| cxk    rdk    rn nd	S d
S )z”Sequence length a UTF-8 lead byte declares, or 0 for a non-lead.

    0xC0-0xC1 are overlong 2-byte encodings of ASCII, so leads start at 0xC2.
    éÂ   éß   é   éà   éï   é   éð   éô   é   r   © )r   s    úŠ/Users/tedpeters/Documents/Projects/Claude Projects/Misc Tools/notename-sheets/.venv/lib/python3.11/site-packages/chardet/pipeline/utf8.pyÚ_expected_seq_lenr   *   s~   € ð
 ˆtÐÐÒÐ�tÒÐÐÐÐØˆqØˆtÐÐÒÐ�tÒÐÐÐÐØˆqØˆtÐÐÒÐ�tÒÐÐÐÐØˆqØˆ1ó    Údatac                 ó,   — t          | ¦  «        d         S )a  Validate UTF-8 byte structure.

    Returns a result only if multi-byte sequences are found (pure ASCII
    is handled by the ASCII stage).

    :param data: The raw byte data to examine.
    :returns: A :class:`DetectionResult` for UTF-8, or ``None``.
    é   )Ú	scan_utf8)r   s    r   Údetect_utf8r   8   s   € õ �T‰?Œ?˜1ÔÐr   z#tuple[bool, DetectionResult | None]c           	      ó¦  — | sdS |                       ¦   «         rdS t          | ¦  «        }t          ¦   «         }d}d}d}|}d}||k     �rd| ||t          z   …         }|t          |¦  «        z   }	|	}|dk    r|                      ¦   «         r|	}ŒJ|t          |                     dt
          ¦  «        ¦  «        z  }	 |                     |d¬¦  «         n­# t          $ r }
d}t          t          d|dz
  ¦  «        |¦  «        D ]&}t          | |         ¦  «        }|r||z   |k    r|} nŒ'||z
  t          |
dd¦  «        z   }t          t          |d¦  «        |d	z
  ¦  «        }|dk     s||k     rY d}
~
d
S |}Y d}
~
n=d}
~
ww xY wt          |                     ¦   «         d         ¦  «        }|	}||k     �°d||z
  }||k     r5| ||…         }|t          |                     dt
          ¦  «        ¦  «        z  }|dk    rdS ||z  }t          t          z
  }t          t          t          |t          |t           z  d¦  «        z  z   ¦  «        }dt#          d|d¬¦  «        fS )a‰  Validate UTF-8 structure, separating validity from evidence.

    ``None`` from :func:`detect_utf8` is two different verdicts: the data
    is *not* UTF-8, or it is valid UTF-8 carrying no multi-byte evidence
    (pure ASCII, ASCII plus control bytes, ASCII plus a truncated tail).
    Only the first justifies ruling UTF-8 out downstream, so callers that
    act on a rejection need both halves of the answer.

    :param data: The raw byte data to examine.
    :returns: ``(window_is_valid_utf8, result_or_None)``.  The flag covers
        the whole of *data*; the result is present only when complete
        multi-byte sequences were found.
    )TNr   NF)Úfinaléÿÿÿÿr   Ústartr   )FNg      ð?Tr   )ÚencodingÚ
confidenceÚlanguage)ÚisasciiÚlenÚ_utf8_decoderÚ_CHUNK_SIZEÚ	translateÚ_ASCII_DELETEÚdecodeÚUnicodeErrorÚrangeÚmaxr   ÚgetattrÚminÚgetstateÚ_MAX_CONFIDENCEÚ_BASE_CONFIDENCEÚ_MB_RATIO_SCALEr   )r   ÚlengthÚdecoderÚmultibyte_bytesÚpending_lenÚposÚ
tail_startÚcounted_endÚchunkÚ	chunk_endÚexcÚ	tail_leadÚkÚseq_lenÚ	err_startÚtailÚmb_ratioÚconfidence_ranger!   s                      r   r   r   D   sÆ  € ð ð Øˆ|ð ‡|‚|�~„~ð Øˆ|å�‰YŒY€FÝ‰oŒo€GØ€OØ€KØ
€Cð €JØ€KØ
�Š,‰,Ø�S˜3¥Ñ,Ð,Ô-ˆØ�#˜e™*œ*Ñ$ˆ	ØˆØ˜!ÒÐ §¢¡¤Ðð ˆCØØ�3˜uŸš¨tµ]ÑCÔCÑDÔDÑDˆð	Ø�NŠN˜5¨ˆNÑ.Ô.Ð.Ð.øÝð 	ð 	ð 	ð ˆIÝ�3˜q &¨1¡*Ñ-Ô-¨vÑ6Ô6ð ð �Ý+¨D°¬GÑ4Ô4�Øð ˜q 7™{¨VÒ3Ð3Ø !�IØ�EøØ˜kÑ)­G°C¸À!Ñ,DÔ,DÑDˆIÝ�C 	¨1Ñ-Ô-¨v¸©zÑ:Ô:ˆIØ˜1Š}ˆ} 	¨IÒ 5Ð 5à$�}�}�}�}�}ð #ˆJØˆEˆEˆEˆEøøøøð1	øøøõ2 ˜'×*Ò*Ñ,Ô,¨QÔ/Ñ0Ô0ˆØˆðM �Š,‰,ðT ˜kÑ)ˆ
ð �KÒÐØ�J˜{Ð*Ô+ˆØ�3˜tŸ~š~¨dµMÑBÔBÑCÔCÑCˆð ˜!ÒÐØˆ|ð  Ñ'€HÝ&Õ)9Ñ9ÐÝÝÝÐ+­c°(½_Ñ2LÈcÑ.RÔ.RÑRÑRñô €Jð
 	Ý °ZÈ$ÐOÑOÔOðð s   Â8C Ã
E:ÃBE5Å.E5Å5E:)Ú__doc__ÚcodecsÚchardet.pipeliner   r1   r0   r2   r&   Úbytesr+   r(   Úgetincrementaldecoderr%   Úintr   r   r   r   r   r   ú<module>rJ      sð   ððð ð$ €€€à ,Ð ,Ð ,Ð ,Ð ,Ð ,ð Ð Ø€ð €ð €ð ��e�e˜D‘k”kÑ"Ô"€à,�Ô,¨WÑ5Ô5€ð˜Cð  Cð ð ð ð ð	�eð 	 °$Ñ 6ð 	ð 	ð 	ð 	ðh�Eð hÐCð hð hð hð hð hð hr   