Ë
    £2ÚiiR  ã                   óÐ  — d dl Z d dlmZ d dlmZmZmZmZmZ ddl	m
Z
mZmZmZ ddl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mZ  e j@                  d
«      Z! e jD                  «       Z#e#jI                   e jJ                  d«      «       	 	 	 	 	 	 	 	 	 ddee&e'f   de(de(de)deee*      deee*      de+de+de)de+defd„Z,	 	 	 	 	 	 	 	 	 ddede(de(de)deee*      deee*      de+de+de)de+defd„Z-	 	 	 	 	 	 	 	 	 ddee*e&ef   de(de(de)deee*      deee*      de+de+de)de+defd„Z.	 	 	 	 	 	 	 	 	 ddeee*ee&f   de(de(de)deee*      deee*      de+de+de)de+de+fd„Z/y) é    N)ÚPathLike)ÚBinaryIOÚListÚOptionalÚSetÚUnioné   )Úcoherence_ratioÚencoding_languagesÚmb_encoding_languagesÚmerge_coherence_ratios)ÚIANA_SUPPORTEDÚTOO_BIG_SEQUENCEÚTOO_SMALL_SEQUENCEÚTRACE)Ú
mess_ratio)ÚCharsetMatchÚCharsetMatches)Úany_specified_encodingÚcut_sequence_chunksÚ	iana_nameÚidentify_sig_or_bomÚis_cp_similarÚis_multi_byte_encodingÚshould_strip_sig_or_bomÚcharset_normalizerz)%(asctime)s | %(levelname)s | %(message)sÚ	sequencesÚstepsÚ
chunk_sizeÚ	thresholdÚcp_isolationÚcp_exclusionÚpreemptive_behaviourÚexplainÚlanguage_thresholdÚenable_fallbackÚreturnc
                 óž  — t        | t        t        f«      s#t        dj	                  t        | «      «      «      ‚|rBt        j                  }
t        j                  t        «       t        j                  t        «       t        | «      }|dk(  rqt        j                  d«       |r@t        j                  t        «       t        j                  
xs 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        | «      t0        k\  }|r*t        j'                  t        dj	                  |«      «       n+|r)t        j'                  t        dj	                  |«      «       g }|rt3        | «      nd}|�,|j5                  |«       t        j'                  t        d|«       t7        «       }g }g }d}d}d}t#        «       }t9        | «      \  }}|�6|j5                  |«       t        j'                  t        dt        |«      |«       |j5                  d«       d|vr|j5                  d«       |t:        z   D �]§  }|r||vrŒ|r||v rŒ||v rŒ|j=                  |«       d}||k(  }|xr t?        |«      }|dv r|st        j'                  t        d|«       Œ`|dv r|st        j'                  t        d|«       Œ‚	 tA        |«      }	 |r9|du r5tG        |du r| dt-        d«       n| t        |«      t-        d«       |¬«       ntG        |du r| n| t        |«      d |¬«      }d} |D ]  }!tM        ||!«      sŒd}  n | rt        j'                  t        d|!«       �Œ"tO        |sdn
t        |«      |t-        ||z  «      «      }"|xr |duxr t        |«      |k  }#|#rt        j'                  t        d|«       t-        t        |"«      dz  «      }$tQ        |$d«      }$d}%d}&g }'g }(	 tS        | ||"||||||«	      D ]g  })|'j5                  |)«       |(j5                  tU        |)||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 jW                  |d#¬$«       |(rtY        |(«      t        |(«      z  nd}*|*|k\  s|%|$k\  rk|j5                  |«       t        j'                  t        d&||%t[        |*d'z  d(¬)«      «       |	r+|dd|fv r$|&s"t%        | ||dg |«      }+||k(  r|+}n
|dk(  r|+}n|+}�ŒÜt        j'                  t        d*|t[        |*d'z  d(¬)«      «       |st]        |«      },nt_        |«      },|,r3t        j'                  t        d+j	                  |tG        |,«      «      «       g }-|dk7  r8|'D ]3  })ta        |)||,rd,j)                  |,«      nd«      }.|-j5                  |.«       Œ5 tc        |-«      }/|/r*t        j'                  t        d-j	                  |/|«      «       |j5                  t%        | ||*||/|«      «       ||ddfv r\|*d.k  rWt        j                  d/|«       |r.t        j                  t        «       t        j                  
«       t#        ||   g«      c S ||k(  s�ŒSt        j                  d0|«       |r.t        j                  t        «       t        j                  
«       t#        ||   g«      c S  t        |«      dk(  rÆ|s|s|rt        j'                  t        d1«       |r2t        j                  d2|jd                  «       |j5                  |«       nr|r|�|r|r|jf                  |jf                  k7  s|�'t        j                  d3«       |j5                  |«       n(|r&t        j                  d4«       |j5                  |«       |r<t        j                  d5|ji                  «       jd                  t        |«      dz
  «       nt        j                  d6«       |r.t        j                  t        «       t        j                  
«       |S c c}w c c}w # tB        tD        f$ r t        j'                  t        d|«       Y �Œ;w xY w# tH        tJ        f$ rQ}t        |tJ        «      s%t        j'                  t        d|tG        |«      «       |j5                  |«       Y d}~�Œšd}~ww xY w# tH        $ r4}t        j'                  t        d!|tG        |«      «       |$}%d}&Y d}~�Œ´d}~ww xY w# tH        $ rA}t        j'                  t        d%|tG        |«      «       |j5                  |«       Y d}~�Œ'd}~ww xY w)7af  
    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.
    z4Expected object of type bytes or bytearray, got: {0}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.z2Encoding %s does not provide an IncrementalDecoderg    €„A)Úencodingz9Code page %s does not fit given bytes sequence at ALL. %sTzW%s is deemed too similar to code page %s and was consider unsuited already. Continuing!zpCode page %s is a multi byte encoding table and it appear that at least one character was encoded using n-bytes.é   é   éÿÿÿÿ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   é   )Úndigitsz=%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.)5Ú
isinstanceÚ	bytearrayÚbytesÚ	TypeErrorÚformatÚtypeÚloggerÚlevelÚ
addHandlerÚexplain_handlerÚsetLevelr   ÚlenÚdebugÚremoveHandlerÚloggingÚWARNINGr   r   ÚlogÚjoinr   Úintr   r   r   ÚappendÚsetr   r   Úaddr   r   ÚModuleNotFoundErrorÚImportErrorÚstrÚUnicodeDecodeErrorÚLookupErrorr   ÚrangeÚmaxr   r   ÚdecodeÚsumÚroundr   r   r
   r   r/   ÚfingerprintÚbest)0r   r   r   r    r!   r"   r#   r$   r%   r&   Ú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Úfallback_asciiÚfallback_u8Úfallback_specifiedÚresultsÚsig_encodingÚsig_payloadÚencoding_ianaÚdecoded_payloadÚbom_or_sig_availableÚstrip_sig_or_bomÚis_multi_byte_decoderÚeÚsimilar_soft_failure_testÚencoding_soft_failedÚ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_mergeds0                                                   úM/var/www/html/acx/venv/lib/python3.12/site-packages/charset_normalizer/api.pyÚ
from_bytesrƒ   !   s‡
  € ô< �i¤)¬UÐ!3Ô4ÜØB×IÑIÜ�Y“óó
ð 	
ñ Ü%+§\¡\ÐÜ×Ñœ/Ô*Ü�‰œÔä�i“.€Fà�‚{Ü�‰ÐSÔTÙÜ× Ñ ¤Ô1Ü�O‰OÐ1ÒD´W·_±_ÔEÜœ|¨I°wÀÀUÈBÐPRÓSÐTÓUÐUàÐÜ�
‰
Üð5à�I‰I�lÓ#ô		
ð 8DÖD°œ	 " eÕ,ÐDˆÑDàˆàÐÜ�
‰
Üð6à�I‰I�lÓ#ô		
ð 8DÖD°œ	 " eÕ,ÐDˆÑ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Ø)+ÐØ)+Ðà-1€NØ*.€KØ15Ðä,Ó.€Gä 3°IÓ >Ñ€L�+àÐØ×$Ñ$ \Ô2Ü�
‰
ÜØWÜ�ÓØô		
ð × Ñ  Ô)àÐ+Ñ+Ø×$Ñ$ WÔ-à.´Ñ?ó V<ˆÙ˜M°Ñ=Øá˜M¨\Ñ9Øà˜FÑ"Øà�
‰
�=Ô!à)-ˆØ%1°]Ñ%BÐØ!5ò "
Ô:QØó;
Ðð Ð0Ñ0Ñ9MÜ�J‰JÜØnØôð
 Ø˜IÑ%Ñ.BÜ�J‰JÜØdØôð
 ð	Ü*@ÀÓ*OÐ!ð	Ù$Ð)>À%Ñ)GÜà'¨5Ñ0ð ˜k¤ D£	Ñ*à"¤3 {Ó#3´c¸$³iÐ@Ø*ö	ô #&à'¨5Ñ0ñ à"¤3 {Ó#3Ð#5Ð6Ø*ô	#�ð" +0Ð!à$;ò 	Ð Ü˜]Ð,@ÕAØ,0Ð)Ùð	ñ
 %Ü�J‰JÜØiØØ$ô	ñ äÙ)‰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Ü�J‰JÜð0àØ Ü�o¨Ñ+°QÔ7ôñ  Ø! g¨wÐ8JÐ%KÑKÙ-ä!-Ø˜}¨i¸ÀÀOó"�ð !Ð$6Ò6Ø)7Ñ&Ø" gÒ-Ø%3‘Nà"0�KÙä�
‰
ÜØKØÜ�/ CÑ'°Ô3ô		
ñ %Ü*<¸]Ó*KÑä4°]ÓCÐáÜ�J‰JÜØ8×?Ñ?Ø!¤3Ð'7Ó#8óôð ˆ	ð ˜GÒ#Ø"ò 2�Ü"1ØØ&Ù2B�C—H‘HÐ-Ô.Èó#�ð × Ñ  Õ1ð2ô 2°)Ó<ÐáÜ�J‰JÜØ2×9Ñ9Ø$ móôð 	�‰ÜØØØØ$Ø Øóô		
ð Ð0°'¸7ÐCÑCØ #Ò%ä�L‰LØ@À-ôñ Ü×$Ñ$¤_Ô5Ü—‘Ð 5Ô6Ü! 7¨=Ñ#9Ð":Ó;Ò;à˜LÔ(Ü�L‰Lð1àôñ
 Ü×$Ñ$¤_Ô5Ü—‘Ð 5Ô6Ü! 7¨=Ñ#9Ð":Ó;Ò;ðmV<ôp ˆ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ùòq Eùò Eøô^ $¤[Ð1ò 	Ü�J‰JÜØDØôò
 ð	ûô. #¤KÐ0ò 		Ü˜a¤Ô-Ü—
‘
ÜØOØ!Ü˜“Fô	ð $×*Ñ*¨=Ô9Ýûð		ûôl ò
	)ô �J‰JÜØsØÜ�A“ô	ð  1ÐØ$(Ö!ûð
	)ûô* &ò Ü—
‘
ÜØtØ!Ü˜“Fô	ð (×.Ñ.¨}Ô=Ýûðúsu   Ä/d$Å7d)Î#d.Î/AeÓ	A4gÔ>gÕgÕhä.*eåeåf?å.Af:æ:f?ç	g?ç)g:ç:g?è	iè6iéiÚfpc
                 ó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)
r„   r   r   r    r!   r"   r#   r$   r%   r&   s
             r‚   Úfrom_fpr‡   ö  s5   € ô  Ø
�‰‹	ØØØØØØØØØóð ó    Úpathc
                 ó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‡   )r‰   r   r   r    r!   r"   r#   r$   r%   r&   r„   s              r‚   Ú	from_pathr�     sK   € ô  
ˆd�DÓ	ð 
˜RÜØØØØØØØ ØØØó
÷
÷ 
ò 
ús   �+«4Úfp_or_path_or_payloadc
                 óê   — 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.
    )	r   r   r    r!   r"   r#   r$   r%   r&   )r:   rR   r   r�   r<   r;   rƒ   r‡   )rŽ   r   r   r    r!   r"   r#   r$   r%   r&   Úguessess              r‚   Ú	is_binaryr‘   3  sÇ   € ô" Ð'¬#¬x¨Ô9ÜØ!ØØ!ØØ%Ø%Ø!5ØØ1Ø+ô
ˆðZ ˆ;ÐôC 
ØäÜð	
ô
ô Ø!ØØ!ØØ%Ø%Ø!5ØØ1Ø+ô
ˆð4 ˆ;Ðô Ø!ØØ!ØØ%Ø%Ø!5ØØ1Ø+ô
ˆð ˆ;Ðrˆ   )	é   é   çš™™™™™É?NNTFr9   T)	r’   r“   r”   NNTFr9   F)0rH   Úosr   Útypingr   r   r   r   r   Úcdr
   r   r   r   Úconstantr   r   r   r   Úmdr   Úmodelsr   r   Úutilsr   r   r   r   r   r   r   Ú	getLoggerr@   ÚStreamHandlerrC   ÚsetFormatterÚ	Formatterr<   r;   rL   ÚfloatrR   Úboolrƒ   r‡   r�   r‘   © rˆ   r‚   ú<module>r£      s(  ðÛ Ý ß 7Õ 7÷ó ÷ RÓ QÝ ß 0÷÷ ñ ð 
ˆ×	Ñ	Ð/Ó	0€Ø'�'×'Ñ'Ó)€Ø × Ñ Ø€G×ÑÐAÓBôð ØØØ(,Ø(,Ø!%ØØ #Ø ñRØ�U˜IÐ%Ñ&ðRàðRð ðRð ð	Rð
 ˜4 ™9Ñ%ðRð ˜4 ™9Ñ%ðRð ðRð ðRð ðRð ðRð óRðn ØØØ(,Ø(,Ø!%ØØ #Ø ñØðàðð ðð ð	ð
 ˜4 ™9Ñ%ðð ˜4 ™9Ñ%ðð ðð ðð ðð ðð óð@ ØØØ(,Ø(,Ø!%ØØ #Ø ñ
Ø
��U˜HÐ$Ñ
%ð
àð
ð ð
ð ð	
ð
 ˜4 ™9Ñ%ð
ð ˜4 ™9Ñ%ð
ð ð
ð ð
ð ð
ð ð
ð ó
ðB ØØØ(,Ø(,Ø!%ØØ #Ø!ñ?Ø  ¨3°¸%Ð!?Ñ@ð?àð?ð ð?ð ð	?ð
 ˜4 ™9Ñ%ð?ð ˜4 ™9Ñ%ð?ð ð?ð ð?ð ð?ð ð?ð 
ô?rˆ   