§
    Ä[6g‰0  ã                   óð   — d dl mZ 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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dS )é    )Úaliases)Úsha256)Údumps)Úsub)ÚAnyÚDictÚIteratorÚListÚOptionalÚTupleÚUnioné   )ÚRE_POSSIBLE_ENCODING_INDICATIONÚTOO_BIG_SEQUENCE)Ú	iana_nameÚis_multi_byte_encodingÚunicode_rangec                   óº  — e Zd Z	 	 d&dededededddee         d	ee         fd
„Zde	defd„Z
de	defd„Zedefd„¦   «         Zdefd„Zdefd„Zd'd„Zedefd„¦   «         Zedee         fd„¦   «         Zedefd„¦   «         Zedefd„¦   «         Zedee         fd„¦   «         Zedefd„¦   «         Zedefd„¦   «         Zedefd„¦   «         Zedefd„¦   «         Zedefd„¦   «         Zedefd„¦   «         Zeded          fd„¦   «         Zedefd„¦   «         Zedee         fd „¦   «         Zedee         fd!„¦   «         Z d(d#edefd$„Z!edefd%„¦   «         Z"dS ))ÚCharsetMatchNÚpayloadÚguessed_encodingÚmean_mess_ratioÚhas_sig_or_bomÚ	languagesÚCoherenceMatchesÚdecoded_payloadÚpreemptive_declarationc                 ó®   — || _         || _        || _        || _        || _        d | _        g | _        d| _        d | _        d | _	        || _
        || _        d S )Nç        )Ú_payloadÚ	_encodingÚ_mean_mess_ratioÚ
_languagesÚ_has_sig_or_bomÚ_unicode_rangesÚ_leavesÚ_mean_coherence_ratioÚ_output_payloadÚ_output_encodingÚ_stringÚ_preemptive_declaration)Úselfr   r   r   r   r   r   r   s           úX/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/charset_normalizer/models.pyÚ__init__zCharsetMatch.__init__   se   € ð  'ˆŒà.ˆŒØ'6ˆÔØ,5ˆŒØ%3ˆÔØ48ˆÔà+-ˆŒØ,/ˆÔ"à04ˆÔØ/3ˆÔà&5ˆŒà6LˆÔ$Ð$Ð$ó    ÚotherÚreturnc                 óÊ   — t          |t          ¦  «        s/t          |t          ¦  «        rt          |¦  «        | j        k    S dS | j        |j        k    o| j        |j        k    S )NF)Ú
isinstancer   Ústrr   ÚencodingÚfingerprint©r,   r0   s     r-   Ú__eq__zCharsetMatch.__eq__(   s_   € Ý˜%¥Ñ.Ô.ð 	Ý˜%¥Ñ%Ô%ð 9Ý  Ñ'Ô'¨4¬=Ò8Ð8Ø�5ØŒ} ¤Ò.ÐX°4Ô3CÀuÔGXÒ3XÐXr/   c                 ó”  — t          |t          ¦  «        st          ‚t          | j        |j        z
  ¦  «        }t          | j        |j        z
  ¦  «        }|dk     r|dk    r| j        |j        k    S |dk     rC|dk    r=t          | j        ¦  «        t          k    r| j        |j        k     S | j	        |j	        k    S | j        |j        k     S )zQ
        Implemented to make sorted available upon CharsetMatches items.
        g{®Gáz„?g{®Gáz”?)
r3   r   Ú
ValueErrorÚabsÚchaosÚ	coherenceÚlenr    r   Úmulti_byte_usage)r,   r0   Úchaos_differenceÚcoherence_differences       r-   Ú__lt__zCharsetMatch.__lt__/   sÎ   € õ ˜%¥Ñ.Ô.ð 	ÝÐå"% d¤j°5´;Ñ&>Ñ"?Ô"?ÐÝ&)¨$¬.¸5¼?Ñ*JÑ&KÔ&KÐð ˜dÒ"Ð"Ð';¸dÒ'BÐ'BØ”> E¤OÒ3Ð3Ø Ò$Ð$Ð)=ÀÒ)EÐ)Eõ �4”=Ñ!Ô!Õ%5Ò5Ð5Ø”z E¤KÒ/Ð/ØÔ(¨5Ô+AÒAÐAàŒz˜EœKÒ'Ð'r/   c                 ój   — dt          t          | ¦  «        ¦  «        t          | j        ¦  «        z  z
  S )Ng      ð?)r>   r4   Úraw©r,   s    r-   r?   zCharsetMatch.multi_byte_usageE   s&   € à•c�#˜d™)œ)‘n”n¥s¨4¬8¡}¤}Ñ4Ñ5Ð5r/   c                 ó^   — | j         € t          | j        | j        d¦  «        | _         | j         S )NÚstrict)r*   r4   r    r!   rE   s    r-   Ú__str__zCharsetMatch.__str__I   s)   € àŒ<ÐÝ˜tœ}¨d¬n¸hÑGÔGˆDŒLØŒ|Ðr/   c                 óB   — d                      | j        | j        ¦  «        S )Nz<CharsetMatch '{}' bytes({})>)Úformatr5   r6   rE   s    r-   Ú__repr__zCharsetMatch.__repr__O   s   € Ø.×5Ò5°d´mÀTÔEUÑVÔVÐVr/   c                 óÌ   — t          |t          ¦  «        r|| k    r't          d                     |j        ¦  «        ¦  «        ‚d |_        | j                             |¦  «         d S )Nz;Unable to add instance <{}> as a submatch of a CharsetMatch)r3   r   r:   rJ   Ú	__class__r*   r&   Úappendr7   s     r-   Úadd_submatchzCharsetMatch.add_submatchR   sk   € Ý˜%¥Ñ.Ô.ð 	°%¸4²-°-ÝØM×TÒTØ”Oñô ñô ð ð ˆŒØŒ×Ò˜EÑ"Ô"Ð"Ð"Ð"r/   c                 ó   — | j         S ©N)r!   rE   s    r-   r5   zCharsetMatch.encoding]   s
   € àŒ~Ðr/   c                 ó¾   — g }t          j        ¦   «         D ]F\  }}| j        |k    r|                     |¦  «         Œ&| j        |k    r|                     |¦  «         ŒG|S )z‚
        Encoding name are known by many name, using this could help when searching for IBM855 when it's listed as CP855.
        )r   Úitemsr5   rN   )r,   Úalso_known_asÚuÚps       r-   Úencoding_aliaseszCharsetMatch.encoding_aliasesa   sn   € ð
 $&ˆÝ”M‘O”Oð 	(ð 	(‰DˆAˆqØŒ} Ò!Ð!Ø×$Ò$ QÑ'Ô'Ð'Ð'Ø” !Ò#Ð#Ø×$Ò$ QÑ'Ô'Ð'øØÐr/   c                 ó   — | j         S rQ   ©r$   rE   s    r-   ÚbomzCharsetMatch.bomn   ó   € àÔ#Ð#r/   c                 ó   — | j         S rQ   rY   rE   s    r-   Úbyte_order_markzCharsetMatch.byte_order_markr   r[   r/   c                 ó$   — d„ | j         D ¦   «         S )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'.
        c                 ó   — g | ]
}|d          ‘ŒS )r   © )Ú.0Úes     r-   ú
<listcomp>z*CharsetMatch.languages.<locals>.<listcomp>|   s   € Ð.Ð.Ð.˜��!”Ð.Ð.Ð.r/   ©r#   rE   s    r-   r   zCharsetMatch.languagesv   s   € ð /Ð.˜dœoÐ.Ñ.Ô.Ð.r/   c                 ó  — | j         shd| j        v rdS ddlm}m} t          | j        ¦  «        r || j        ¦  «        n || j        ¦  «        }t          |¦  «        dk    sd|v rdS |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.cdrh   ri   r   r5   r>   )r,   rh   ri   r   s       r-   ÚlanguagezCharsetMatch.language~   s¸   € ð Œð 	 ð ˜$Ô4Ð4Ð4Ø �yð XÐWÐWÐWÐWÐWÐWÐWõ *¨$¬-Ñ8Ô8ð7Ð%Ð% d¤mÑ4Ô4Ð4à'Ð'¨¬Ñ6Ô6ð õ �9‰~Œ~ Ò"Ð" m°yÐ&@Ð&@Ø �yà˜Q”<ÐàŒ˜qÔ! !Ô$Ð$r/   c                 ó   — | j         S rQ   )r"   rE   s    r-   r<   zCharsetMatch.chaosš   s   € àÔ$Ð$r/   c                 ó:   — | j         sdS | j         d         d         S )Nr   r   r   rd   rE   s    r-   r=   zCharsetMatch.coherencež   s#   € àŒð 	Ø�3ØŒ˜qÔ! !Ô$Ð$r/   c                 ó4   — t          | j        dz  d¬¦  «        S ©Néd   é   )Úndigits)Úroundr<   rE   s    r-   Úpercent_chaoszCharsetMatch.percent_chaos¤   s   € å�T”Z #Ñ%¨qÐ1Ñ1Ô1Ð1r/   c                 ó4   — t          | j        dz  d¬¦  «        S rq   )ru   r=   rE   s    r-   Úpercent_coherencezCharsetMatch.percent_coherence¨   s   € å�T”^ cÑ)°1Ð5Ñ5Ô5Ð5r/   c                 ó   — | j         S )z+
        Original untouched bytes.
        )r    rE   s    r-   rD   zCharsetMatch.raw¬   s   € ð
 Œ}Ðr/   c                 ó   — | j         S rQ   )r&   rE   s    r-   ÚsubmatchzCharsetMatch.submatch³   s
   € àŒ|Ðr/   c                 ó2   — t          | j        ¦  «        dk    S ©Nr   )r>   r&   rE   s    r-   Úhas_submatchzCharsetMatch.has_submatch·   s   € å�4”<Ñ Ô  1Ò$Ð$r/   c                 ó´   — | j         �| j         S d„ t          | ¦  «        D ¦   «         }t          t          d„ |D ¦   «         ¦  «        ¦  «        | _         | j         S )Nc                 ó,   — g | ]}t          |¦  «        ‘ŒS r`   )r   )ra   Úchars     r-   rc   z*CharsetMatch.alphabets.<locals>.<listcomp>À   s-   € ð 0
ð 0
ð 0
Ø$(�M˜$ÑÔð0
ð 0
ð 0
r/   c                 ó   — h | ]}|¯|’ŒS r`   r`   )ra   Úrs     r-   ú	<setcomp>z)CharsetMatch.alphabets.<locals>.<setcomp>Ä   s   € Ð+LÐ+LÐ+L°!È!Ð+L¨AÐ+LÐ+LÐ+Lr/   )r%   r4   ÚsortedÚlist)r,   Údetected_rangess     r-   Ú	alphabetszCharsetMatch.alphabets»   sj   € àÔÐ+ØÔ'Ð'ð0
ð 0
Ý,/°©I¬Ið0
ñ 0
ô 0
ˆõ  &¥dÐ+LÐ+L°Ð+LÑ+LÔ+LÑ&MÔ&MÑNÔNˆÔØÔ#Ð#r/   c                 ó6   — | j         gd„ | j        D ¦   «         z   S )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'.
        c                 ó   — g | ]	}|j         ‘Œ
S r`   )r5   )ra   Úms     r-   rc   z6CharsetMatch.could_be_from_charset.<locals>.<listcomp>Î   s   € Ð"DÐ"DÐ"D°! 1¤:Ð"DÐ"DÐ"Dr/   )r!   r&   rE   s    r-   rk   z"CharsetMatch.could_be_from_charsetÇ   s%   € ð ”ÐÐ"DÐ"D°t´|Ð"DÑ"DÔ"DÑDÐDr/   Úutf_8r5   c                 ó:  ‡ — ‰ j         �‰ j         |k    r‚|‰ _         t          ‰ ¦  «        }‰ j        �J‰ j                             ¦   «         dvr/t	          t
          ˆ fd„|dd…         d¦  «        }||dd…         z   }|                     |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Úutf8rŒ   c                 óþ   •— | j         |                      ¦   «         d         |                      ¦   «         d         …                              |                      ¦   «         d         t	          ‰j        ¦  «        ¦  «        S )Nr   r   )ÚstringÚspanÚreplaceÚgroupsr   r)   )r‹   r,   s    €r-   ú<lambda>z%CharsetMatch.output.<locals>.<lambda>ß   sW   ø€ ˜aœh q§v¢v¡x¤x°¤{°Q·V²V±X´X¸a´[Ð'@ÔA×IÒIØŸš™
œ
 1œ¥y°Ô1FÑ'GÔ'Gñô € r/   i    r   r’   )r)   r4   r+   Úlowerr   r   Úencoder(   )r,   r5   Údecoded_stringÚpatched_headers   `   r-   ÚoutputzCharsetMatch.outputÐ   sÅ   ø€ ð
 Ô Ð(¨DÔ,AÀXÒ,MÐ,MØ$,ˆDÔ!Ý  ™YœYˆNàÔ,Ð8ØÔ0×6Ò6Ñ8Ô8Ø1ð2ð 2õ "%Ý3ðð ð ð ð # 5 D 5Ô)Øñ"ô "�ð "0°.ÀÀÀÔ2GÑ!G�à#1×#8Ò#8¸À9Ñ#MÔ#MˆDÔ àÔ#Ð#r/   c                 óh   — t          |                      ¦   «         ¦  «                             ¦   «         S )zw
        Retrieve the unique SHA256 computed using the transformed (re-encoded) payload. Not the original one.
        )r   r™   Ú	hexdigestrE   s    r-   r6   zCharsetMatch.fingerprintì   s&   € õ
 �d—k’k‘m”mÑ$Ô$×.Ò.Ñ0Ô0Ð0r/   )NN)r0   r   r1   N)rŒ   )#Ú__name__Ú
__module__Ú__qualname__Úbytesr4   ÚfloatÚboolr   r.   Úobjectr8   rB   Úpropertyr?   rH   rK   rO   r5   r
   rW   rZ   r]   r   rm   r<   r=   rv   rx   rD   r{   r~   rˆ   rk   r™   r6   r`   r/   r-   r   r      sþ  € € € € € ð *.Ø04ðMð MàðMð ðMð ð	Mð
 ðMð &ðMð " #œðMð !)¨¤ðMð Mð Mð Mð8Y˜Fð Y tð Yð Yð Yð Yð(˜Fð ( tð (ð (ð (ð (ð, ð6 %ð 6ð 6ð 6ñ „Xð6ð˜ð ð ð ð ðW˜#ð Wð Wð Wð Wð	#ð 	#ð 	#ð 	#ð ð˜#ð ð ð ñ „Xðð ð
 $ s¤)ð 
ð 
ð 
ñ „Xð
ð ð$�Tð $ð $ð $ñ „Xð$ð ð$ ð $ð $ð $ñ „Xð$ð ð/˜4 œ9ð /ð /ð /ñ „Xð/ð ð%˜#ð %ð %ð %ñ „Xð%ð6 ð%�uð %ð %ð %ñ „Xð%ð ð%˜5ð %ð %ð %ñ „Xð%ð
 ð2˜uð 2ð 2ð 2ñ „Xð2ð ð6 5ð 6ð 6ð 6ñ „Xð6ð ð�Uð ð ð ñ „Xðð ð˜$˜~Ô.ð ð ð ñ „Xðð ð%˜dð %ð %ð %ñ „Xð%ð ð	$˜4 œ9ð 	$ð 	$ð 	$ñ „Xð	$ð ðE t¨C¤yð Eð Eð Eñ „XðEð$ð $˜sð $°ð $ð $ð $ð $ð8 ð1˜Sð 1ð 1ð 1ñ „Xð1ð 1ð 1r/   r   c                   óÈ   — e Zd ZdZddeee                  fd„Zdee         fd„Z	de
eef         defd„Zdefd	„Zdefd
„Zdeddfd„Zded         fd„Zded         fd„ZdS )Ú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.
    NÚresultsc                 ó6   — |rt          |¦  «        ng | _        d S rQ   )r…   Ú_results)r,   r¦   s     r-   r.   zCharsetMatches.__init__ú   s   € Ø?FÐ,N­F°7©O¬O¨OÈBˆŒˆˆr/   r1   c              #   ó$   K  — | j         E d {V —† d S rQ   ©r¨   rE   s    r-   Ú__iter__zCharsetMatches.__iter__ý   s&   è è € Ø”=Ð Ð Ð Ð Ð Ð Ð Ð Ð r/   Úitemc                 óÌ   — t          |t          ¦  «        r| j        |         S t          |t          ¦  «        r't	          |d¦  «        }| j        D ]}||j        v r|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)r3   Úintr¨   r4   r   rk   ÚKeyError)r,   r¬   Úresults      r-   Ú__getitem__zCharsetMatches.__getitem__   sv   € õ
 �d�CÑ Ô ð 	'Ø”= Ô&Ð&Ý�d�CÑ Ô ð 	"Ý˜T 5Ñ)Ô)ˆDØœ-ð "ð "�Ø˜6Ô7Ð7Ð7Ø!�M�M�Mð 8åˆr/   c                 ó*   — t          | j        ¦  «        S rQ   ©r>   r¨   rE   s    r-   Ú__len__zCharsetMatches.__len__  s   € Ý�4”=Ñ!Ô!Ð!r/   c                 ó2   — t          | j        ¦  «        dk    S r}   r³   rE   s    r-   Ú__bool__zCharsetMatches.__bool__  s   € Ý�4”=Ñ!Ô! AÒ%Ð%r/   c                 ó¼  — t          |t          ¦  «        s4t          d                     t	          |j        ¦  «        ¦  «        ¦  «        ‚t          |j        ¦  «        t          k     rB| j	        D ]:}|j
        |j
        k    r(|j        |j        k    r|                     |¦  «          dS Œ;| j	                             |¦  «         t          | j	        ¦  «        | _	        dS )z~
        Insert a single match. Will be inserted accordingly to preserve sort.
        Can be inserted as a submatch.
        z-Cannot append instance '{}' to CharsetMatchesN)r3   r   r:   rJ   r4   rM   r>   rD   r   r¨   r6   r<   rO   rN   r…   )r,   r¬   Úmatchs      r-   rN   zCharsetMatches.append  sÕ   € õ
 ˜$¥Ñ-Ô-ð 	ÝØ?×FÒFÝ˜œÑ'Ô'ñô ñô ð õ ˆtŒx‰=Œ=Õ+Ò+Ð+Øœð ð �ØÔ$¨Ô(8Ò8Ð8¸U¼[ÈDÌJÒ=VÐ=VØ×&Ò& tÑ,Ô,Ð,Ø�F�FøØŒ×Ò˜TÑ"Ô"Ð"Ý˜tœ}Ñ-Ô-ˆŒˆˆr/   r   c                 ó.   — | j         sdS | j         d         S )zQ
        Simply return the first match. Strict equivalent to matches[0].
        Nr   rª   rE   s    r-   ÚbestzCharsetMatches.best(  s    € ð Œ}ð 	Ø�4ØŒ}˜QÔÐr/   c                 ó*   — |                       ¦   «         S )zP
        Redundant method, call the method best(). Kept for BC reasons.
        )rº   rE   s    r-   ÚfirstzCharsetMatches.first0  s   € ð �yŠy‰{Œ{Ðr/   rQ   )rœ   r�   rž   Ú__doc__r   r
   r   r.   r	   r«   r   r®   r4   r±   r´   r¡   r¶   rN   rº   r¼   r`   r/   r-   r¥   r¥   ô   s0  € € € € € ðð ð
Oð O ¨¨lÔ);Ô <ð Oð Oð Oð Oð!˜( <Ô0ð !ð !ð !ð !ð  c¨3 h¤ð °Lð ð ð ð ð"˜ð "ð "ð "ð "ð&˜$ð &ð &ð &ð &ð.˜<ð .¨Dð .ð .ð .ð .ð( �h˜~Ô.ð  ð  ð  ð  ð�x Ô/ð ð ð ð ð ð r/   r¥   c                   ó¶   — e Zd Zdedee         dee         dee         dedee         deded	ed
ee         defd„Ze	de
eef         fd„¦   «         Zdefd„ZdS )ÚCliDetectionResultÚpathr5   rW   Úalternative_encodingsrm   rˆ   r   r<   r=   Úunicode_pathÚis_preferredc                 ó    — || _         |
| _        || _        || _        || _        || _        || _        || _        || _        |	| _	        || _
        d S rQ   )rÀ   rÂ   r5   rW   rÁ   rm   rˆ   r   r<   r=   rÃ   )r,   rÀ   r5   rW   rÁ   rm   rˆ   r   r<   r=   rÂ   rÃ   s               r-   r.   zCliDetectionResult.__init__<  s\   € ð ˆŒ	Ø+7ˆÔØ'/ˆŒØ+;ˆÔØ0EˆÔ"Ø%ˆŒØ$-ˆŒØ$2ˆÔØ!ˆŒ
Ø )ˆŒØ".ˆÔÐÐr/   r1   c                 óŒ   — | j         | j        | j        | j        | j        | j        | j        | j        | j        | j	        | j
        dœS )N©rÀ   r5   rW   rÁ   rm   rˆ   r   r<   r=   rÂ   rÃ   rÆ   rE   s    r-   Ú__dict__zCliDetectionResult.__dict__V  sO   € ð ”IØœØ $Ô 5Ø%)Ô%?ØœØœØ"Ô1Ø”ZØœØ Ô-Ø Ô-ð
ð 
ð 	
r/   c                 ó0   — t          | j        dd¬¦  «        S )NTé   )Úensure_asciiÚindent)r   rÇ   rE   s    r-   Úto_jsonzCliDetectionResult.to_jsonf  s   € Ý�T”]°¸aÐ@Ñ@Ô@Ð@r/   N)rœ   r�   rž   r4   r   r
   r¡   r    r.   r£   r   r   rÇ   rÌ   r`   r/   r-   r¿   r¿   ;  sù   € € € € € ð/àð/ð ˜3”-ð/ð ˜sœ)ð	/ð
  $ Cœyð/ð ð/ð ˜”9ð/ð ð/ð ð/ð ð/ð ˜s”mð/ð ð/ð /ð /ð /ð4 ð
˜$˜s C˜xœ.ð 
ð 
ð 
ñ „Xð
ðA˜ð Að Að Að Að Að Ar/   r¿   N)Úencodings.aliasesr   Úhashlibr   Újsonr   Úrer   Útypingr   r   r	   r
   r   r   r   Úconstantr   r   Úutilsr   r   r   r   r¥   r4   r    ÚCoherenceMatchr   r¿   r`   r/   r-   ú<module>rÕ      sr  ðØ %Ð %Ð %Ð %Ð %Ð %Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ Dà GÐ GÐ GÐ GÐ GÐ GÐ GÐ GØ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ Cðf1ð f1ð f1ð f1ð f1ñ f1ô f1ð f1ðR@ð @ð @ð @ð @ñ @ô @ð @ðF �s˜E�zÔ"€Ø˜Ô'Ð ð,Að ,Að ,Að ,Að ,Añ ,Aô ,Að ,Að ,Að ,Ar/   