Ë
    >²Xj2  ã                  ó¸   — d dl mZ d dlmZ d dlmZ d dlmZmZm	Z	m
Z
 ddlmZmZ ddlmZmZmZ  G d„ d	«      Z G d
„ d«      Ze
eef   Ze	e   Z G d„ d«      Zy)é    )Úannotations)Úaliases)Úsub)ÚAnyÚIteratorÚListÚTupleé   )ÚRE_POSSIBLE_ENCODING_INDICATIONÚTOO_BIG_SEQUENCE)Ú	iana_nameÚis_multi_byte_encodingÚunicode_rangec                  ó˜  — e Zd Z	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Zdd„Zdd„Zedd„«       Zdd„Zdd„Z	dd„Z
edd	„«       Zed d
„«       Zed!d„«       Zed!d„«       Zed d„«       Zedd„«       Zedd„«       Zedd„«       Zedd„«       Zedd„«       Zed"d„«       Zed#d„«       Zed!d„«       Zed d„«       Zed d„«       Zd$d%d„Zed&d„«       Zy)'ÚCharsetMatchNc                ó¬   — || _         || _        || _        || _        || _        d | _        g | _        d| _        d | _        d | _	        || _
        || _        y )Nç        )Ú_payloadÚ	_encodingÚ_mean_mess_ratioÚ
_languagesÚ_has_sig_or_bomÚ_unicode_rangesÚ_leavesÚ_mean_coherence_ratioÚ_output_payloadÚ_output_encodingÚ_stringÚ_preemptive_declaration)ÚselfÚpayloadÚguessed_encodingÚmean_mess_ratioÚhas_sig_or_bomÚ	languagesÚdecoded_payloadÚpreemptive_declarations           ú_/var/www/html/content_generation/venv/lib/python3.12/site-packages/charset_normalizer/models.pyÚ__init__zCharsetMatch.__init__   s_   € ð ,3ˆŒà.ˆŒØ'6ˆÔØ,5ˆŒØ%3ˆÔØ15ˆÔà+-ˆŒØ,/ˆÔ"à-1ˆÔØ,0ˆÔà#2ˆŒà3IˆÕ$ó    c                óÜ   — t        |t        «      s)t        |t        «      rt        |«      | j                  k(  S y| j                  |j                  k(  xr | j
                  |j
                  k(  S )NF)Ú
isinstancer   Ústrr   ÚencodingÚfingerprint©r    Úothers     r(   Ú__eq__zCharsetMatch.__eq__(   sV   € Ü˜%¤Ô.Ü˜%¤Ô%Ü  Ó'¨4¯=©=Ñ8Ð8ØØ�}‰} §¡Ñ.ÒX°4×3CÑ3CÀu×GXÑGXÑ3XÐXr*   c                óÞ  — t        |t        «      st        ‚t        | j                  |j                  z
  «      }t        | j
                  |j
                  z
  «      }|dk  r|dkD  r| j
                  |j
                  kD  S |dk  rS|dk  rNt        | j                  «      t        k\  r| j                  |j                  k  S | j                  |j                  kD  S | j                  |j                  k  S )zQ
        Implemented to make sorted available upon CharsetMatches items.
        g{®Gázt?g{®Gáz”?)
r,   r   Ú
ValueErrorÚabsÚchaosÚ	coherenceÚlenr   r   Úmulti_byte_usage)r    r1   Úchaos_differenceÚcoherence_differences       r(   Ú__lt__zCharsetMatch.__lt__/   sÊ   € ô ˜%¤Ô.ÜÐä"% d§j¡j°5·;±;Ñ&>Ó"?ÐÜ&)¨$¯.©.¸5¿?¹?Ñ*JÓ&KÐð ˜eÒ#Ð(<¸tÒ(CØ—>‘> E§O¡OÑ3Ð3Ø Ò%Ð*>À$Ò*Fô �4—=‘=Ó!Ô%5Ò5Ø—z‘z E§K¡KÑ/Ð/Ø×(Ñ(¨5×+AÑ+AÑAÐAà�z‰z˜EŸK™KÑ'Ð'r*   c                ó\   — dt        t        | «      «      t        | j                  «      z  z
  S )Ng      ð?)r8   r-   Úraw©r    s    r(   r9   zCharsetMatch.multi_byte_usageE   s"   € à”cœ#˜d›)“n¤s¨4¯8©8£}Ñ4Ñ5Ð5r*   c                ó  — | j                   €st        | j                  | j                  d«      | _         | j                  rA| j                  dk(  r2| j                   r&| j                   d   dk(  r| j                   dd  | _         | j                   S )NÚstrictÚutf_7r   u   ï»¿r
   )r   r-   r   r   r   r?   s    r(   Ú__str__zCharsetMatch.__str__I   sn   € à�<‰<ÐÜ˜tŸ}™}¨d¯n©n¸hÓGˆDŒLð
 ×$Ò$Ø—N‘N gÒ-Ø—L’LØ—L‘L ‘O xÒ/à#Ÿ|™|¨A¨BÐ/�”Ø�|‰|Ðr*   c                ó<   — d| j                   › d| j                  › d�S )Nz<CharsetMatch 'z' fp(z)>)r.   r/   r?   s    r(   Ú__repr__zCharsetMatch.__repr__Y   s"   € Ø  §¡ ¨u°T×5EÑ5EÐ4FÀbÐIÐIr*   c                óº   — t        |t        «      r|| k(  r$t        dj                  |j                  «      «      ‚d |_        | j                  j                  |«       y )Nz;Unable to add instance <{}> as a submatch of a CharsetMatch)r,   r   r4   ÚformatÚ	__class__r   r   Úappendr0   s     r(   Úadd_submatchzCharsetMatch.add_submatch\   sO   € Ü˜%¤Ô.°%¸4²-ÜØM×TÑTØ—O‘Oóóð ð ˆŒØ�‰×Ñ˜EÕ"r*   c                ó   — | j                   S ©N)r   r?   s    r(   r.   zCharsetMatch.encodingg   s   € à�~‰~Ðr*   c                óÆ   — g }t        j                  «       D ]G  \  }}| j                  |k(  r|j                  |«       Œ'| j                  |k(  sŒ7|j                  |«       ŒI |S )z‚
        Encoding name are known by many name, using this could help when searching for IBM855 when it's listed as CP855.
        )r   Úitemsr.   rI   )r    Úalso_known_asÚuÚps       r(   Úencoding_aliaseszCharsetMatch.encoding_aliasesk   sY   € ð
 $&ˆÜ—M‘M–O‰DˆAˆqØ�}‰} Ò!Ø×$Ñ$ QÕ'Ø—‘ !Ó#Ø×$Ñ$ QÕ'ð	 $ð
 Ðr*   c                ó   — | j                   S rL   ©r   r?   s    r(   ÚbomzCharsetMatch.bomx   ó   € à×#Ñ#Ð#r*   c                ó   — | j                   S rL   rT   r?   s    r(   Úbyte_order_markzCharsetMatch.byte_order_mark|   rV   r*   c                óF   — | j                   D �cg c]  }|d   ‘Œ	 c}S c c}w )zÔ
        Return the complete list of possible languages found in decoded sequence.
        Usually not really useful. Returned list may be empty even if 'language' property return something != 'Unknown'.
        r   ©r   )r    Úes     r(   r%   zCharsetMatch.languages€   s$   € ð #ŸošoÓ.™o˜��!“˜oÑ.Ð.ùÒ.s   �c                ó  — | j                   shd| j                  v ryddlm}m} t        | j                  «      r || j                  «      n || j                  «      }t        |«      dk(  sd|v ry|d   S | j                   d   d   S )z’
        Most probable language found in decoded sequence. If none were detected or inferred, the property will return
        "Unknown".
        ÚasciiÚEnglishr   )Úencoding_languagesÚmb_encoding_languageszLatin BasedÚUnknown)r   Úcould_be_from_charsetÚcharset_normalizer.cdr_   r`   r   r.   r8   )r    r_   r`   r%   s       r(   ÚlanguagezCharsetMatch.languageˆ   s‡   € ð �Šð ˜$×4Ñ4Ñ4Ø ÷ Xô *¨$¯-©-Ô8ñ & d§m¡mÔ4á'¨¯©Ó6ð ô �9‹~ Ò" m°yÑ&@Ø à˜Q‘<Ðà�‰˜qÑ! !Ñ$Ð$r*   c                ó   — | j                   S rL   )r   r?   s    r(   r6   zCharsetMatch.chaos¤   s   € à×$Ñ$Ð$r*   c                ó@   — | j                   sy| j                   d   d   S )Nr   r   r
   rZ   r?   s    r(   r7   zCharsetMatch.coherence¨   s    € à�ŠØØ�‰˜qÑ! !Ñ$Ð$r*   c                ó6   — t        | j                  dz  d¬«      S ©Néd   é   )Úndigits)Úroundr6   r?   s    r(   Úpercent_chaoszCharsetMatch.percent_chaos®   s   € ä�T—Z‘Z #Ñ%¨qÔ1Ð1r*   c                ó6   — t        | j                  dz  d¬«      S rh   )rl   r7   r?   s    r(   Úpercent_coherencezCharsetMatch.percent_coherence²   s   € ä�T—^‘^ cÑ)°1Ô5Ð5r*   c                ó   — | j                   S )z+
        Original untouched bytes.
        )r   r?   s    r(   r>   zCharsetMatch.raw¶   s   € ð
 �}‰}Ðr*   c                ó   — | j                   S rL   )r   r?   s    r(   ÚsubmatchzCharsetMatch.submatch½   s   € à�|‰|Ðr*   c                ó2   — t        | j                  «      dkD  S ©Nr   )r8   r   r?   s    r(   Úhas_submatchzCharsetMatch.has_submatchÁ   s   € ä�4—<‘<Ó  1Ñ$Ð$r*   c                óô   — | j                   �| j                   S t        | «      D �cg c]  }t        |«      ‘Œ }}t        t	        |D �ch c]  }|sŒ|’Œ	 c}«      «      | _         | j                   S c c}w c c}w rL   )r   r-   r   ÚsortedÚlist)r    ÚcharÚdetected_rangesÚrs       r(   Ú	alphabetszCharsetMatch.alphabetsÅ   sp   € à×ÑÐ+Ø×'Ñ'Ð'äMPÐQUÌYÓ,WÉYÀT¬]¸4Õ-@ÈYˆÐ,Wä%¤d±Ó+L±°!Ê!ªA°Ñ+LÓ&MÓNˆÔØ×#Ñ#Ð#ùò -Xùâ+Ls   ¦A0ÁA5ÁA5c                óp   — | j                   g| j                  D �cg c]  }|j                  ‘Œ c}z   S c c}w )zÜ
        The complete list of encoding that output the exact SAME str result and therefore could be the originating
        encoding.
        This list does include the encoding available in property 'encoding'.
        )r   r   r.   )r    Úms     r(   rb   z"CharsetMatch.could_be_from_charsetÏ   s0   € ð —‘Ð°t·|²|Ó"D±|°! 1§:£:°|Ñ"DÑDÐDùÒ"Ds   ›3c                ó6  ‡ — ‰ j                   �‰ j                   |k7  rr|‰ _         t        ‰ «      }‰ j                  �=‰ j                  j                  «       dvr!t	        t
        ˆ fd„|dd d¬«      }||dd z   }|j                  |d«      ‰ _        ‰ j                  S )z®
        Method to get re-encoded bytes payload using given target encoding. Default to UTF-8.
        Any errors will be simply ignored by the encoder NOT replaced.
        N)zutf-8Úutf8Úutf_8c                óî   •— | j                   | j                  «       d   | j                  «       d    j                  | j                  «       d   t	        ‰j
                  «      j                  dd«      «      S )Nr   r
   Ú_Ú-)ÚstringÚspanÚreplaceÚgroupsr   r   )r~   r    s    €r(   Ú<lambda>z%CharsetMatch.output.<locals>.<lambda>ç   sW   ø€ ˜aŸh™h q§v¡v£x°¡{°Q·V±V³X¸a±[ÐA×IÑIØŸ™›
 1™Ü! $×"7Ñ"7Ó8×@Ñ@ÀÀcÓJôr*   i    r
   )Úcountr‡   )r   r-   r   Úlowerr   r   Úencoder   )r    r.   Údecoded_stringÚpatched_headers   `   r(   ÚoutputzCharsetMatch.outputØ   s¬   ø€ ð
 × Ñ Ð(¨D×,AÑ,AÀXÒ,MØ$,ˆDÔ!Ü  ›YˆNà×,Ñ,Ð8Ø×0Ñ0×6Ñ6Ó8Ø1ñ2ô "%Ü3óð # 5 DÐ)Øô"�ð "0°.ÀÀÐ2GÑ!G�à#1×#8Ñ#8¸À9Ó#MˆDÔ à×#Ñ#Ð#r*   c                ó*   — t        t        | «      «      S )z]
        Retrieve a hash fingerprint of the decoded payload, used for deduplication.
        )Úhashr-   r?   s    r(   r/   zCharsetMatch.fingerprintõ   s   € ô
 ”C˜“I‹Ðr*   )NN)r!   úbytes | bytearrayr"   r-   r#   Úfloatr$   Úboolr%   ÚCoherenceMatchesr&   ú
str | Noner'   r–   )r1   ÚobjectÚreturnr”   )r˜   r“   ©r˜   r-   )r1   r   r˜   ÚNone)r˜   ú	list[str]©r˜   r”   )r˜   r’   )r˜   zlist[CharsetMatch])r�   )r.   r-   r˜   Úbytes©r˜   Úint)Ú__name__Ú
__module__Ú__qualname__r)   r2   r<   Úpropertyr9   rC   rE   rJ   r.   rR   rU   rX   r%   rd   r6   r7   rm   ro   r>   rr   ru   r|   rb   r�   r/   © r*   r(   r   r      sÑ  „ ð '+Ø-1ðJà"ðJð ðJð ð	Jð
 ðJð $ðJð $ðJð !+óJó8Yó(ð, ò6ó ð6óó Jó	#ð òó ðð ò
ó ð
ð ò$ó ð$ð ò$ó ð$ð ò/ó ð/ð ò%ó ð%ð6 ò%ó ð%ð ò%ó ð%ð
 ò2ó ð2ð ò6ó ð6ð òó ðð òó ðð ò%ó ð%ð ò$ó ð$ð òEó ðEô$ð: òó ñr*   r   c                  óR   — e Zd ZdZddd„Zdd„Zdd„Zdd„Zdd„Zdd„Z	dd	„Z
dd
„Zy)ÚCharsetMatchesz³
    Container with every CharsetMatch items ordered by default from most probable to the less one.
    Act like a list(iterable) but does not implements all related methods.
    Nc                ó8   — |rt        |«      | _        y g | _        y rL   )rw   Ú_results)r    Úresultss     r(   r)   zCharsetMatches.__init__  s   € Ù?F¬F°7«Oˆ�ÈBˆ�r*   c              #  ó8   K  — | j                   E d {  –—†  y 7 Œ­wrL   ©r¨   r?   s    r(   Ú__iter__zCharsetMatches.__iter__  s   è ø€ Ø—=‘=× Ò ús   ‚’“c                óÊ   — t        |t        «      r| j                  |   S t        |t        «      r/t	        |d«      }| j                  D ]  }||j
                  v sŒ|c S  t        ‚)z¸
        Retrieve a single item either by its position or encoding name (alias may be used here).
        Raise KeyError upon invalid index or encoding not present in results.
        F)r,   rŸ   r¨   r-   r   rb   ÚKeyError)r    ÚitemÚresults      r(   Ú__getitem__zCharsetMatches.__getitem__	  s[   € ô
 �dœCÔ Ø—=‘= Ñ&Ð&Ü�dœCÔ Ü˜T 5Ó)ˆDØŸ-œ-�Ø˜6×7Ñ7Ò7Ø!’Mð (ô ˆr*   c                ó,   — t        | j                  «      S rL   ©r8   r¨   r?   s    r(   Ú__len__zCharsetMatches.__len__  s   € Ü�4—=‘=Ó!Ð!r*   c                ó2   — t        | j                  «      dkD  S rt   r³   r?   s    r(   Ú__bool__zCharsetMatches.__bool__  s   € Ü�4—=‘=Ó! AÑ%Ð%r*   c                óÎ  — t        |t        «      s-t        dj                  t	        |j
                  «      «      «      ‚t        |j                  «      t        k  rW| j                  D ]H  }|j                  |j                  k(  sŒ|j                  |j                  k(  sŒ7|j                  |«        y | j                  j                  |«       t        | j                  «      | _	        y)z~
        Insert a single match. Will be inserted accordingly to preserve sort.
        Can be inserted as a submatch.
        z-Cannot append instance '{}' to CharsetMatchesN)r,   r   r4   rG   r-   rH   r8   r>   r   r¨   r/   r6   rJ   rI   rw   )r    r¯   Úmatchs      r(   rI   zCharsetMatches.append  s®   € ô
 ˜$¤Ô-ÜØ?×FÑFÜ˜Ÿ™Ó'óóð ô ˆt�x‰x‹=Ô+Ò+ØŸœ�Ø×$Ñ$¨×(8Ñ(8Ó8¸U¿[¹[ÈDÏJÉJÓ=VØ×&Ñ& tÔ,Ùð 'ð 	�‰×Ñ˜TÔ"Ü˜tŸ}™}Ó-ˆ�r*   c                ó:   — | j                   sy| j                   d   S )zQ
        Simply return the first match. Strict equivalent to matches[0].
        Nr   r«   r?   s    r(   ÚbestzCharsetMatches.best1  s   € ð �}Š}ØØ�}‰}˜QÑÐr*   c                ó"   — | j                  «       S )zP
        Redundant method, call the method best(). Kept for BC reasons.
        )rº   r?   s    r(   ÚfirstzCharsetMatches.first9  s   € ð �y‰y‹{Ðr*   rL   )r©   zlist[CharsetMatch] | None)r˜   zIterator[CharsetMatch])r¯   z	int | strr˜   r   rž   rœ   )r¯   r   r˜   rš   )r˜   zCharsetMatch | None)r    r¡   r¢   Ú__doc__r)   r¬   r±   r´   r¶   rI   rº   r¼   r¤   r*   r(   r¦   r¦   ý   s0   „ ñô
Oó!óó"ó&ó.ó( ôr*   r¦   c                  óZ   — e Zd Z	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Zedd„«       Zdd„Zy)ÚCliDetectionResultc                óž   — || _         |
| _        || _        || _        || _        || _        || _        || _        || _        |	| _	        || _
        y rL   )ÚpathÚunicode_pathr.   rR   Úalternative_encodingsrd   r|   r$   r6   r7   Úis_preferred)r    rÁ   r.   rR   rÃ   rd   r|   r$   r6   r7   rÂ   rÄ   s               r(   r)   zCliDetectionResult.__init__E  sV   € ð ˆŒ	Ø(4ˆÔØ$,ˆŒØ+;ˆÔØ0EˆÔ"Ø%ˆŒØ$-ˆŒØ$2ˆÔØ!ˆŒ
Ø )ˆŒØ".ˆÕr*   c                óú   — | j                   | j                  | j                  | j                  | j                  | j
                  | j                  | j                  | j                  | j                  | j                  dœS )N©rÁ   r.   rR   rÃ   rd   r|   r$   r6   r7   rÂ   rÄ   rÆ   r?   s    r(   Ú__dict__zCliDetectionResult.__dict___  se   € ð —I‘IØŸ™Ø $× 5Ñ 5Ø%)×%?Ñ%?ØŸ™ØŸ™Ø"×1Ñ1Ø—Z‘ZØŸ™Ø ×-Ñ-Ø ×-Ñ-ñ
ð 	
r*   c                ó8   — ddl m}  || j                  dd¬«      S )Nr   )ÚdumpsTé   )Úensure_asciiÚindent)ÚjsonrÉ   rÇ   )r    rÉ   s     r(   Úto_jsonzCliDetectionResult.to_jsono  s   € Ýá�T—]‘]°¸aÔ@Ð@r*   N)rÁ   r-   r.   r–   rR   r›   rÃ   r›   rd   r-   r|   r›   r$   r”   r6   r“   r7   r“   rÂ   r–   rÄ   r”   )r˜   zdict[str, Any]r™   )r    r¡   r¢   r)   r£   rÇ   rÎ   r¤   r*   r(   r¿   r¿   D  s�   „ ð/àð/ð ð/ð $ð	/ð
  )ð/ð ð/ð ð/ð ð/ð ð/ð ð/ð !ð/ð ó/ð4 ò
ó ð
ôAr*   r¿   N)Ú
__future__r   Úencodings.aliasesr   Úrer   Útypingr   r   r   r	   Úconstantr   r   Úutilsr   r   r   r   r¦   r-   r“   ÚCoherenceMatchr•   r¿   r¤   r*   r(   Ú<module>rÖ      s^   ðÝ "å %Ý ß -Ó -ç Gß CÑ C÷oñ o÷d@ñ @ðF �s˜E�zÑ"€Ø˜Ñ'Ð ÷.Aò .Ar*   