Ë
    ýÄ®i¿X  ã                  ó@  — d dl mZ d dl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mZmZmZ ddlmZ dd	lmZmZ dd
lmZmZmZmZmZmZ  ej<                  d«      Z ej@                  «       Z!e!jE                   ejF                  d«      «       	 	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Z$	 	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Z%	 	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Z&	 	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Z'y)é    )ÚannotationsN)ÚPathLike)ÚBinaryIOé   )Úcoherence_ratioÚencoding_languagesÚmb_encoding_languagesÚmerge_coherence_ratios)ÚIANA_SUPPORTEDÚIANA_SUPPORTED_SIMILARÚTOO_BIG_SEQUENCEÚTOO_SMALL_SEQUENCEÚTRACE)Ú
mess_ratio)ÚCharsetMatchÚCharsetMatches)Úany_specified_encodingÚcut_sequence_chunksÚ	iana_nameÚidentify_sig_or_bomÚis_multi_byte_encodingÚshould_strip_sig_or_bomÚcharset_normalizerz)%(asctime)s | %(levelname)s | %(message)sc
                ó"  — t        | t        t        f«      s#t        dj	                  t        | «      «      «      ‚|rBt        j                  }
t        j                  t        «       t        j                  t        «       t        | «      }|dk(  r_t        j                  d«       |r.t        j                  t        «       t        j                  
«       t        t!        | dddg d«      g«      S |�Dt        j#                  t        d	d
j%                  |«      «       |D �cg c]  }t'        |d«      ‘Œ }}ng }|�Dt        j#                  t        dd
j%                  |«      «       |D �cg c]  }t'        |d«      ‘Œ }}ng }|||z  k  r!t        j#                  t        d|||«       d}|}|dkD  r||z  |k  rt)        ||z  «      }t        | «      t*        k  }t        | «      t,        k\  }|r*t        j#                  t        dj	                  |«      «       n+|r)t        j#                  t        dj	                  |«      «       g }|rt/        | «      nd}|�,|j1                  |«       t        j#                  t        d|«       t3        «       }g }g }t3        «       }d}d}d}t        «       }t        «       }t5        | «      \  }}|�6|j1                  |«       t        j#                  t        dt        |«      |«       |j1                  d«       d|vr|j1                  d«       |t6        z   D �]g  }|r||vrŒ|r||v rŒ||v rŒ|j9                  |«       d}||k(  }|xr t;        |«      }|dv r|st        j#                  t        d|«       Œ`|dv r|st        j#                  t        d|«       Œ‚||v rt        j#                  t        d|«       Œ¢	 t=        |«      } 	 |r9| du r5tC        |du r| dt)        d«       n| t        |«      t)        d«       |¬«       ntC        |du r| n| t        |«      d |¬«      }tI        |sdn
t        |«      |t)        ||z  «      «      }"| xr |duxr t        |«      |k  }#|#rt        j#                  t        d|«       t)        t        |"«      dz  «      }$tK        |$d«      }$d}%d}&g }'g }(	 tM        | ||"||||| |«	      D ]g  })|'j1                  |)«       |(j1                  tO        |)||du xr dt        |«      cxk  xr dk  nc «      «       |(d    |k\  r|%dz  }%|%|$k\  s|sŒb|du sŒg n |&s$|r"| s 	 | t)        d"«      d jQ                  |d#¬$«       |(rtS        |(«      t        |(«      z  nd}*|*|k\  s|%|$k\  r�|j1                  |«       |tT        v r|jW                  tT        |   «       t        j#                  t        d&||%tY        |*d'z  d(¬)«      «       |	r/|dd|d*d+fv r&|&s$t!        | |||g ||¬,«      }+||k(  r|+}n
|dk(  r|+}n|+}�Œçt        j#                  t        d-|tY        |*d'z  d(¬)«      «       | st[        |«      },nt]        |«      },|,r3t        j#                  t        d.j	                  |tC        |,«      «      «       g }-|dk7  r8|'D ]3  })t_        |)||,rd/j%                  |,«      nd«      }.|-j1                  |.«       Œ5 ta        |-«      }/|/r*t        j#                  t        d0j	                  |/|«      «       t!        | ||*||/|du s||ddfv r|nd|¬,«      }0|j1                  |0«       ||ddfv ry|*d1k  rt|*dk(  r^t        j                  d2|0jb                  «       |r.t        j                  t        «       t        j                  
«       t        |0g«      c S |j1                  |0«       t        |«      r||�||v rvd|v rrd|v rn|je                  «       }1t        j                  d2|1jb                  «       |r.t        j                  t        «       t        j                  
«       t        |1g«      c S ||k(  s�Œt        j                  d3|«       |r.t        j                  t        «       t        j                  
«       t        ||   g«      c S  t        |«      dk(  rÆ|s|s|rt        j#                  t        d4«       |r2t        j                  d5|jb                  «       |j1                  |«       nr|r|�|r|r|jf                  |jf                  k7  s|�'t        j                  d6«       |j1                  |«       n(|r&t        j                  d7«       |j1                  |«       |r<t        j                  d8|je                  «       jb                  t        |«      dz
  «       nt        j                  d9«       |r.t        j                  t        «       t        j                  
«       |S c c}w c c}w # t>        t@        f$ r t        j#                  t        d|«       Y �Œûw xY w# tD        tF        f$ rQ}!t        |!tF        «      s%t        j#                  t        d|tC        |!«      «       |j1                  |«       Y d}!~!�ŒZd}!~!ww xY w# tD        $ r4}!t        j#                  t        d!|tC        |!«      «       |$}%d}&Y d}!~!�Œ�d}!~!ww xY w# tD        $ rA}!t        j#                  t        d%|tC        |!«      «       |j1                  |«       Y d}!~!�Œçd}!~!ww xY w):af  
    Given a raw bytes sequence, return the best possibles charset usable to render str objects.
    If there is no results, it is a strong indicator that the source is binary/not text.
    By default, the process will extract 5 blocks of 512o each to assess the mess and coherence of a given sequence.
    And will give up a particular code page after 20% of measured mess. Those criteria are customizable at will.

    The preemptive behavior DOES NOT replace the traditional detection workflow, it prioritize a particular code page
    but never take it for granted. Can improve the performance.

    You may want to focus your attention to some code page or/and not others, use cp_isolation and cp_exclusion for that
    purpose.

    This function will strip the SIG in the payload/sequence every time except on UTF-16, UTF-32.
    By default the library does not setup any handler other than the NullHandler, if you choose to set the 'explain'
    toggle to True it will alter the logger configuration to add a StreamHandler that is suitable for debugging.
    Custom logging format and handler can be set manually.
    z3Expected object of type bytes or bytearray, got: {}r   z<Encoding detection on empty bytes, assuming utf_8 intention.Úutf_8g        FÚ Nz`cp_isolation is set. use this flag for debugging purpose. limited list of encoding allowed : %s.z, zacp_exclusion is set. use this flag for debugging purpose. limited list of encoding excluded : %s.z^override steps (%i) and chunk_size (%i) as content does not fit (%i byte(s) given) parameters.r   z>Trying to detect encoding from a tiny portion of ({}) byte(s).zIUsing lazy str decoding because the payload is quite large, ({}) byte(s).z@Detected declarative mark in sequence. Priority +1 given for %s.zIDetected a SIG or BOM mark on first %i byte(s). Priority +1 given for %s.Úascii>   Úutf_16Úutf_32z\Encoding %s won't be tested as-is because it require a BOM. Will try some sub-encoder LE/BE.>   Úutf_7zREncoding %s won't be tested as-is because detection is unreliable without BOM/SIG.zY%s is deemed too similar to a code page that was already considered unsuited. Continuing!z2Encoding %s does not provide an IncrementalDecoderg    €„A)Úencodingz9Code page %s does not fit given bytes sequence at ALL. %szpCode page %s is a multi byte encoding table and it appear that at least one character was encoded using n-bytes.é   é   TéÿÿÿÿzaLazyStr Loading: After MD chunk decode, code page %s does not fit given bytes sequence at ALL. %sg     jè@Ústrict)Úerrorsz^LazyStr Loading: After final lookup, code page %s does not fit given bytes sequence at ALL. %szc%s was excluded because of initial chaos probing. Gave up %i time(s). Computed mean chaos is %f %%.éd   é   )Úndigitsr   r   )Úpreemptive_declarationz=%s passed initial chaos probing. Mean measured chaos is %f %%z&{} should target any language(s) of {}Ú,z We detected language {} using {}çš™™™™™¹?z.Encoding detection: %s is most likely the one.zoEncoding detection: %s is most likely the one as we detected a BOM or SIG within the beginning of the sequence.zONothing got out of the detection process. Using ASCII/UTF-8/Specified fallback.z7Encoding detection: %s will be used as a fallback matchz:Encoding detection: utf_8 will be used as a fallback matchz:Encoding detection: ascii will be used as a fallback matchz]Encoding detection: Found %s as plausible (best-candidate) for content. With %i alternatives.z=Encoding detection: Unable to determine any suitable charset.)4Ú
isinstanceÚ	bytearrayÚbytesÚ	TypeErrorÚformatÚtypeÚloggerÚlevelÚ
addHandlerÚexplain_handlerÚsetLevelr   ÚlenÚdebugÚremoveHandlerr   r   ÚlogÚjoinr   Úintr   r   r   ÚappendÚsetr   r   Úaddr   r   ÚModuleNotFoundErrorÚImportErrorÚstrÚUnicodeDecodeErrorÚLookupErrorÚrangeÚmaxr   r   ÚdecodeÚsumr   ÚupdateÚroundr   r	   r   r
   r!   ÚbestÚfingerprint)2Ú	sequencesÚstepsÚ
chunk_sizeÚ	thresholdÚcp_isolationÚcp_exclusionÚpreemptive_behaviourÚexplainÚlanguage_thresholdÚenable_fallbackÚprevious_logger_levelÚlengthÚcpÚis_too_small_sequenceÚis_too_large_sequenceÚprioritized_encodingsÚspecified_encodingÚtestedÚtested_but_hard_failureÚtested_but_soft_failureÚsoft_failure_skipÚfallback_asciiÚfallback_u8Úfallback_specifiedÚresultsÚearly_stop_resultsÚsig_encodingÚsig_payloadÚencoding_ianaÚdecoded_payloadÚbom_or_sig_availableÚstrip_sig_or_bomÚis_multi_byte_decoderÚeÚr_Úmulti_byte_bonusÚmax_chunk_gave_upÚearly_stop_countÚlazy_str_hard_failureÚ	md_chunksÚ	md_ratiosÚchunkÚmean_mess_ratioÚfallback_entryÚtarget_languagesÚ	cd_ratiosÚchunk_languagesÚcd_ratios_mergedÚcurrent_matchÚprobable_results2                                                     úI/var/www/html/venv/lib/python3.12/site-packages/charset_normalizer/api.pyÚ
from_bytesr�   &   sI  € ô< �i¤)¬UÐ!3Ô4ÜØA×HÑHÜ�Y“óó
ð 	
ñ Ü%+§\¡\ÐÜ×Ñœ/Ô*Ü�‰œÔä�i“.€Fà�‚{Ü�‰ÐSÔTÙÜ× Ñ ¤Ô1Ü�O‰OÐ1Ô2Üœ|¨I°wÀÀUÈBÐPRÓSÐTÓUÐUàÐÜ�
‰
Üð5à�I‰I�lÓ#ô		
ñ 8DÓD±|°œ	 " eÕ,°|ˆÑDàˆàÐÜ�
‰
Üð6à�I‰I�lÓ#ô		
ñ 8DÓD±|°œ	 " eÕ,°|ˆÑDàˆà�*˜uÑ$Ò%Ü�
‰
ÜØlØØØô	
ð ˆØˆ
àˆq‚y�V˜e‘^ jÒ0Ü˜ %™Ó(ˆ
ä"% i£.Ô3EÑ"EÐÜ"% i£.Ô4DÑ"DÐáÜ�
‰
ÜØL×SÑSØóõ	
ñ 
Ü�
‰
ÜØW×^Ñ^Øóô	
ð (*Ðñ .BÔ˜yÔ)Àtð ð Ð%Ø×$Ñ$Ð%7Ô8Ü�
‰
ÜØNØô	
ô “u€FØ)+ÐØ)+ÐÜ"%£%Ðà*.€NØ'+€KØ.2Ðä,Ó.€Gä)7Ó)9Ðä 3°IÓ >Ñ€L�+àÐØ×$Ñ$ \Ô2Ü�
‰
ÜØWÜ�ÓØô		
ð × Ñ  Ô)àÐ+Ñ+Ø×$Ñ$ WÔ-à.´Õ?ˆÙ˜M°Ñ=Øá˜M¨\Ñ9Øà˜FÑ"Øà�
‰
�=Ô!à&*ˆØ%1°]Ñ%BÐØ!5ò "
Ô:QØó;
Ðð Ð0Ñ0Ñ9MÜ�J‰JÜØnØôð
 Ø˜IÑ%Ñ.BÜ�J‰JÜØdØôð
 ð Ð-Ñ-Ü�J‰JÜØkØôð
 ð	Ü*@ÀÓ*OÐ!ð	Ù$Ð)>À%Ñ)GÜð ,¨uÑ4ð " +¤C¨£IÑ.à&¤s¨;Ó'7¼#¸d»)ÐDà*öô #&ð ,¨uÑ4ñ "à&¤s¨;Ó'7Ð'9Ð:à*ô#�ô& Ù)‰A¬s°;Ó/?ØÜ�˜‘Óó
ˆð "ò .Ø tÐ+ò.ä�OÓ$ vÑ-ð 	ñ Ü�J‰JÜð-àô	ô "%¤S¨£W¨q¡[Ó!1ÐäÐ 1°1Ó5ÐØ !ÐØ %Ðà!ˆ	Øˆ	ð'	)Ü,ØØØØØ$Ø ØØ%Øö
�ð × Ñ  Ô'à× Ñ ÜØØ!Ø 4˜ÒG¨A´°\Ó1BÖ,GÀaÔ,Góôð ˜R‘= IÒ-Ø$¨Ñ)Ð$à$Ð(9Ò9Ú(Ð-=ÀÒ-Fáð7
ñV &Ù%Ù)ð
Øœ#˜d›)˜+Ð&×-Ñ-¨mÀHÐ-ÔMñ EN¤ Y£´#°i³.Ò!@ÐSVˆØ˜iÒ'Ð+;Ð?PÒ+PØ#×*Ñ*¨=Ô9ØÔ 6Ñ6Ø!×(Ñ(Ô)?ÀÑ)NÔOÜ�J‰JÜð0àØ Ü�o¨Ñ+°QÔ7ôñ  Ø!Ø˜WÐ&8¸(ÀHÐMñNá-ä!-ØØ!ØØ(ØØ#Ø+=ô"�ð !Ð$6Ò6Ø)7Ñ&Ø" gÒ-Ø%3‘Nà"0�KÙä�
‰
ÜØKØÜ�/ CÑ'°Ô3ô		
ñ %Ü*<¸]Ó*KÑä4°]ÓCÐáÜ�J‰JÜØ8×?Ñ?Ø!¤3Ð'7Ó#8óôð ˆ	ð ˜GÒ#Û"�Ü"1ØØ&Ù2B�C—H‘HÐ-Ô.Èó#�ð × Ñ  Õ1ð #ô 2°)Ó<ÐáÜ�J‰JÜØ2×9Ñ9Ø$ móôô %ØØØØ Øð *¨UÑ2Ø$Ð);¸WÀgÐ(NÑNñ  ð
 à#5ô
ˆð" 	�‰�}Ô%ð Ð0°'¸7ÐCÑCØ #Ò%ð  #Ò%Ü—‘ØDØ!×*Ñ*ôñ Ü×(Ñ(¬Ô9Ü—O‘OÐ$9Ô:Ü% } oÓ6Ò6à×%Ñ% mÔ4ô Ð"Ô#Ø#Ð+Ð/AÀVÑ/KØ˜6Ñ!Ø˜6Ñ!à,>×,CÑ,CÓ,EˆOÜ�L‰LØ@Ø×(Ñ(ôñ Ü×$Ñ$¤_Ô5Ü—‘Ð 5Ô6ä! ?Ð"3Ó4Ò4à˜LÔ(Ü�L‰Lð1àôñ
 Ü×$Ñ$¤_Ô5Ü—‘Ð 5Ô6Ü! 7¨=Ñ#9Ð":Ó;Ò;ðw	 @ôz	 ˆ7ƒ|�qÒÙ™.Ñ,>Ü�J‰JÜØaôñ
 Ü�L‰LØIØ"×+Ñ+ôð �N‰NÐ-Õ.á˜^Ð3áÙ"Ø×+Ñ+¨~×/IÑ/IÒIàÐ'ä�L‰LÐUÔVØ�N‰N˜;Õ'ÙÜ�L‰LÐUÔVØ�N‰N˜>Ô*áÜ�‰ØkØ�L‰L‹N×#Ñ#Ü�‹L˜1Ñõ	
ô 	�‰ÐTÔUáÜ×Ñœ_Ô-Ü�‰Ð-Ô.à€NùòA Eùò Eøôx $¤[Ð1ò 	Ü�J‰JÜØDØôò
 ð	ûô6 #¤KÐ0ò 		Ü˜a¤Ô-Ü—
‘
ÜØOØ!Ü˜“Fô	ð $×*Ñ*¨=Ô9Ýûð		ûôL ò
	)ô �J‰JÜØsØÜ�A“ô	ð  1ÐØ$(Ö!ûð
	)ûô* &ò Ü—
‘
ÜØtØ!Ü˜“Fô	ð (×.Ñ.¨}Ô=Ýûðúsu   Äg&Å%g+Ïg0ÏAh!Ò2A4jÔ'jÔ,jÔ6kç0*hèhè!jè0Ai<é<jê	kê)j<ê<kë	lë6l	ì	lc
                óF   — t        | j                  «       |||||||||	«
      S )z†
    Same thing than the function from_bytes but using a file pointer that is already ready.
    Will not close the file pointer.
    )r�   Úread)
ÚfprO   rP   rQ   rR   rS   rT   rU   rV   rW   s
             r€   Úfrom_fpr…   #  s5   € ô  Ø
�‰‹	ØØØØØØØØØóð ó    c
                ón   — t        | d«      5 }
t        |
|||||||||	«
      cddd«       S # 1 sw Y   yxY w)z•
    Same thing than the function from_bytes but with one extra step. Opening and reading given file path in binary mode.
    Can raise IOError.
    ÚrbN)Úopenr…   )ÚpathrO   rP   rQ   rR   rS   rT   rU   rV   rW   r„   s              r€   Ú	from_pathr‹   A  sB   € ô  
ˆd�DÔ	˜RÜØØØØØØØ ØØØó
÷ 
×	Ò	ús   �+«4c
                óê   — t        | t        t        f«      rt        | |||||||||	¬«
      }
|
 S t        | t        t
        f«      rt        | |||||||||	¬«
      }
|
 S t        | |||||||||	¬«
      }
|
 S )a)  
    Detect if the given input (file, bytes, or path) points to a binary file. aka. not a string.
    Based on the same main heuristic algorithms and default kwargs at the sole exception that fallbacks match
    are disabled to be stricter around ASCII-compatible but unlikely to be a string.
    )	rO   rP   rQ   rR   rS   rT   rU   rV   rW   )r-   rC   r   r‹   r/   r.   r�   r…   )Úfp_or_path_or_payloadrO   rP   rQ   rR   rS   rT   rU   rV   rW   Úguessess              r€   Ú	is_binaryr�   `  sÇ   € ô" Ð'¬#¬x¨Ô9ÜØ!ØØ!ØØ%Ø%Ø!5ØØ1Ø+ô
ˆðZ ˆ;ÐôC 
ØäÜð	
ô
ô Ø!ØØ!ØØ%Ø%Ø!5ØØ1Ø+ô
ˆð4 ˆ;Ðô Ø!ØØ!ØØ%Ø%Ø!5ØØ1Ø+ô
ˆð ˆ;Ðr†   )	é   é   çš™™™™™É?NNTFr,   T)rN   zbytes | bytearrayrO   r=   rP   r=   rQ   ÚfloatrR   úlist[str] | NonerS   r”   rT   ÚboolrU   r•   rV   r“   rW   r•   Úreturnr   )r„   r   rO   r=   rP   r=   rQ   r“   rR   r”   rS   r”   rT   r•   rU   r•   rV   r“   rW   r•   r–   r   )rŠ   zstr | bytes | PathLikerO   r=   rP   r=   rQ   r“   rR   r”   rS   r”   rT   r•   rU   r•   rV   r“   rW   r•   r–   r   )	r�   r‘   r’   NNTFr,   F)r�   z!PathLike | str | BinaryIO | bytesrO   r=   rP   r=   rQ   r“   rR   r”   rS   r”   rT   r•   rU   r•   rV   r“   rW   r•   r–   r•   )(Ú
__future__r   ÚloggingÚosr   Útypingr   Úcdr   r   r	   r
   Úconstantr   r   r   r   r   Úmdr   Úmodelsr   r   Úutilsr   r   r   r   r   r   Ú	getLoggerr3   ÚStreamHandlerr6   ÚsetFormatterÚ	Formatterr�   r…   r‹   r�   © r†   r€   Ú<module>r¥      sº  ðÝ "ã Ý Ý ÷ó ÷õ õ ß 0÷÷ ð 
ˆ×	Ñ	Ð/Ó	0€Ø'�'×'Ñ'Ó)€Ø × Ñ Ø€G×ÑÐAÓBôð ØØØ%)Ø%)Ø!%ØØ #Ø ðzØ ðzàðzð ðzð ð	zð
 #ðzð #ðzð ðzð ðzð ðzð ðzð ózð~ ØØØ%)Ø%)Ø!%ØØ #Ø ðØðàðð ðð ð	ð
 #ðð #ðð ðð ðð ðð ðð óð@ ØØØ%)Ø%)Ø!%ØØ #Ø ð
Ø
 ð
àð
ð ð
ð ð	
ð
 #ð
ð #ð
ð ð
ð ð
ð ð
ð ð
ð ó
ðB ØØØ%)Ø%)Ø!%ØØ #Ø!ð?Ø<ð?àð?ð ð?ð ð	?ð
 #ð?ð #ð?ð ð?ð ð?ð ð?ð ð?ð 
ô?r†   