
    (ph?                        S SK r S SKrS SKrS SKrS SK Jr  S SK Jr  S SKJr  S SK	J
r
  S SKJrJrJr  S SKJr  S SKJr  S S	KJrJr  \S
 5       r\" S\R.                  5      r\" S\R.                  5      r " S S5      r " S S5      r\r\" S\R.                  5      r\" S\R.                  5      r\" S5      r\" S5      r \S 5       r!S*S jr" " S S\5      r#\S 5       r$\\" S5      4S j5       r%\S 5       r&\S 5       r'S r(SS.S  jr) " S! S"\5      r*SS.S# jr+\" S$\RX                  5      r-S% r.\S& 5       r/\S+S' j5       r0S( r1S) r2\" \2\35      r4g),    N)GzipFile)compress)BytesIO)SuspiciousFileOperation)SimpleLazyObjectkeep_lazy_textlazy)_lazy_re_compile)gettext)gettext_lazypgettextc                     U (       d  U $ [        U [        5      (       d  [        U 5      n U S   R                  5       U SS -   $ )z(Capitalize the first letter of a string.r      N)
isinstancestrupper)xs    D/var/www/html/venv/lib/python3.13/site-packages/django/utils/text.pycapfirstr      s=     aFQ4::<!AB%    z
([^<>\s]+)z<|([^<>\s]+)c                   $    \ rS rSr\S 5       rSrg)
WordsRegex)   c                    [         R                  X5      nUb  US   b  U$ U R                  SUR                  S5      5      nUS:  a  [        R                  XS-   5      $ US-  n[        XR                  S5      U U5      $ )Nr   >r   )re_prtsearchfindendre_notag	FakeMatchstart)textpospartialr   s       r   r   WordsRegex.search*   s     --*?gaj4N iiW[[^,7??4q11 1HCT--"2S93??r    N)__name__
__module____qualname____firstlineno__staticmethodr   __static_attributes__r'   r   r   r   r   )   s    @ @r   r   c                   2    \ rS rSrSS/rS	S jrS rS rSrg)
r!   <   _text_endc                 4    US:X  d   S5       eU R                   $ )Nr   z'This specific object takes only group=0)r1   selfgroups     r   r   FakeMatch.end?   s    zDDDzyyr   c                 B    US:X  a  g US:X  d   S5       eU R                   $ )Nr   r   z.This specific object takes only group in {0,1})r0   r3   s     r   __getitem__FakeMatch.__getitem__C   s(    A:zKKKzzzr   c                      XsU l         U l        g N)r0   r1   )r4   r#   r   s      r   __init__FakeMatch.__init__I   s     $
DIr   )r1   r0   N)r   )	r(   r)   r*   r+   	__slots__r   r8   r<   r-   r'   r   r   r!   r!   <   s    &!I*r   r!   z<[^>]+?>|(.)z<(/)?(\S+?)(?:(\s*/)|\s.*?)?>z\r\n|\rz&(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))c                 @   ^ ^ U U4S jnSR                  U" 5       5      $ )a'  
A word-wrap function that preserves existing line breaks. Expects that
existing line breaks are posix newlines.

Preserve all white space except added line breaks consume the space on
which they break the line.

Don't wrap long words, thus the output text may have lines longer than
``width``.
c               3     >#    TR                  S5       H  n [        U R                  S5      =(       a    TS-   =(       d    TT5      n[        U 5      U:  a  U S US-    R	                  S5      S-   nUS:X  a!  U R                  S5      S-   nUS:X  a  U v   Sn ORSU S US-
   -  v   XS  n [        U R                  S5      =(       a    TS-   =(       d    TT5      n[        U 5      U:  a  M  U (       d  M  U v   M     g 7f)NT
r    r    z%s
)
splitlinesminendswithlenrfindr   )line	max_widthspacer#   widths      r   
_generatorwrap.<locals>._generatord   s     OOD)DT]]40>UQYG%%PId)i'_y1}-33C81<A: IIcNQ.Ez"
!tKeai000F|t!4!B!KeeT	 d)i' t
 *s   C%C<*C<3	C<rC   )join)r#   rL   rM   s   `` r   wraprP   W   s    " 77:<  r   c                 v    Uc  [        SS5      nSU;   a  USU 0-  $ U R                  U5      (       a  U $ U  U 3$ )Nz%String to return when truncating textu   %(truncated_text)s…z%(truncated_text)struncated_text)r   rF   )r#   truncates     r   add_truncation_textrT   x   sZ    35L
 x'+T222 }}X VH:r   c                   V   ^  \ rS rSrSrSrU 4S jrSS jrS rSS jr	S r
S	 rS
rU =r$ )	Truncator   z
An object used to truncate text, either by characters or words.

When truncating HTML text (either chars or words), input will be limited to
at most `MAX_LENGTH_HTML` characters.
i@KL c                 .   >^ [         TU ]  U4S j5        g )Nc                     > [        T 5      $ r;   r   r#   s   r   <lambda>$Truncator.__init__.<locals>.<lambda>   s	    Tr   )superr<   )r4   r#   	__class__s    `r   r<   Truncator.__init__   s    *+r   c                 P   U R                  5         [        U5      n[        R                  " SU R                  5      nUn[        SU5       H-  n[        R                  " U5      (       a  M   US-  nUS:X  d  M-    O   U(       a  U R                  XBXVS5      $ U R                  XBXV5      $ )z
Return the text truncated to be no longer than the specified number
of characters.

`truncate` specifies what should be used to notify that the string has
been truncated, defaulting to a translatable string of an ellipsis.
NFCrC   r   r   F)	_setupintunicodedata	normalize_wrappedrT   	combining_truncate_html_text_chars)r4   numrS   htmllengthr#   truncate_lenchars           r   charsTruncator.chars   s     	S$$UDMM: 'H5D((..!1$	 6
 &&vUSS$EEr   c                     SnSn[        U5       HP  u  px[        R                  " U5      (       a  M"  US-  nUc  XT:  a  UnXQ:  d  M8  [        USU=(       d    S U5      s  $    U$ )z2Truncate a string after a certain number of chars.r   Nr   )	enumeratere   rh   rT   )	r4   rm   rS   r#   rn   s_len	end_indexiro   s	            r   rj   Truncator._text_chars   sp    	 GA$$T** QJE U%9	~*40@).q+A8LL ' r   c                     U R                  5         [        U5      nU(       a  U R                  XBU R                  US5      $ U R	                  XB5      $ )z
Truncate a string after a certain number of words. `truncate` specifies
what should be used to notify that the string has been truncated,
defaulting to ellipsis.
T)rc   rd   ri   rg   _text_words)r4   rk   rS   rl   rm   s        r   wordsTruncator.words   sF     	S&&vPTUU11r   c                     U R                   R                  5       n[        U5      U:  a   USU n[        SR	                  U5      U5      $ SR	                  U5      $ )zS
Truncate a string after a certain number of words.

Strip newlines in the string.
NrB   )rg   splitrG   rT   rO   )r4   rm   rS   rz   s       r   ry   Truncator._text_words   sP     ##%u:'6NE&sxxAAxxr   c                    U(       a  US::  a  gSn[        U5      U R                  :  a  USU R                   nSnSnSnSn	Sn
/ nU(       a  [        O[        nX::  a  UR	                  X85      nU(       d  OUR                  S5      nUS   (       a  U
S-  n
X:X  a  Un	MG  [        R                  US   5      nU(       a  X:  a  Mm  UR                  5       u  nnnUR                  5       nU(       d  UU;   a  O4U(       a   UR                  U5      nUUS-   S nOUR                  SU5        X::  a  M  [        SU5      nX::  a  U(       a  U(       a  UU-  nU$ USU	 nU(       a  UU-  nU H  nUSU-  -  nM     U$ ! [         a     N]f = f)	z
Truncate HTML to a certain number of chars (not counting tags and
comments), or, if words is True, then to a certain number of words.
Close opened tags if they were correctly closed in the given HTML.

Preserve newlines in the HTML.
r   rC   FNT)	brcollinkbaseimgparamareahrinputr   z</%s>)rG   MAX_LENGTH_HTMLre_wordsre_charsr   r   re_tagmatchgroupslowerindex
ValueErrorinsertrT   )r4   rm   rS   r#   rn   rz   size_limitedhtml4_singletsr$   end_text_poscurrent_len	open_tagsregexmtagclosing_tagtagnameself_closingrv   truncate_textouts                        r   ri   Truncator._truncate_html   s    Vq[t9t+++.$../DL

 	!x#T'A%%(Ctq .#&L,,qt$C+514.K,mmoGw.83!0A !*!a%' 2I   G,E #H ,B9 %K=L!= CC7S= C  
1 " s   ?E< <
F	F	r'   )NF)r(   r)   r*   r+   __doc__r   r<   rp   rj   rz   ry   ri   r-   __classcell__)r_   s   @r   rV   rV      s5      O,F.&
2
V Vr   rV   c                     [        U 5      R                  5       R                  SS5      n[        R                  " SSU5      nUS;   a  [        SU -  5      eU$ )a=  
Return the given string converted to a string that can be used for a clean
filename. Remove leading and trailing spaces; convert other spaces to
underscores; and remove anything that is not an alphanumeric, dash,
underscore, or dot.
>>> get_valid_filename("john's portrait in 2004.jpg")
'johns_portrait_in_2004.jpg'
rB   _z(?u)[^-\w.]rC   >   rC   ...z$Could not derive file name from '%s')r   stripreplaceresubr   )namess     r   get_valid_filenamer   1  sQ     	D	!!#s+A
~r1%AO%&Lt&STTHr   orc                     U (       d  g[        U 5      S:X  a  [        U S   5      $ [        S5      R                  S U SS  5       5      < S[        U5      < S[        U S   5      < 3$ )	z
>>> get_text_list(['a', 'b', 'c', 'd'])
'a, b, c or d'
>>> get_text_list(['a', 'b', 'c'], 'and')
'a, b and c'
>>> get_text_list(['a', 'b'], 'and')
'a and b'
>>> get_text_list(['a'])
'a'
>>> get_text_list([])
''
rC   r   r   z, c              3   8   #    U  H  n[        U5      v   M     g 7fr;   rZ   ).0rv   s     r   	<genexpr> get_text_list.<locals>.<genexpr>V  s     0ZSVVZs   NrB   )rG   r   r   rO   )list_	last_words     r   get_text_listr   B  s]     
5zQ58} 	
$0U3BZ00IE"I	 r   c                 @    [         R                  S[        U 5      5      $ )z*Normalize CRLF and CR newlines to just LF.rA   )re_newlinesr   r   r[   s    r   normalize_newlinesr   \  s     ??4T++r   c                    ^ 0 SS_SS_SS_SS_SS_SS_S	S
_SS
_SS
_SS_SS_SS_SS_SS_SS_SS_SS_SSSSSSSSSS.	EmSR                  U4S jU R                  5        5       5      $ )z@Convert a phone number with letters into its numeric equivalent.a2bcd3efg4hrv   j5klr   6nop7q89)	rr   tuvwr   yzrC   c              3   F   >#    U  H  nTR                  X5      v   M     g 7fr;   )get)r   r   char2numbers     r   r    phone2numeric.<locals>.<genexpr>  s     @-Q;??1((-s   !)rO   r   )phoner   s    @r   phone2numericr   b  s   SS 	S 	S	
 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S  	S!" 	S#$ 5K8 77@%++-@@@r   c                 4    S[         R                  " U 5      -  $ )N   a)secrets	randbelowmax_random_bytess    r   _get_random_filenamer     s    '##$4555r   r   c                    [        U SSS9nU(       d  U$ [        U5      n[        US S 5      n[        R                  US'   [        U5      S-   n[        U5      U-   USS  -   $ )N   r   )compresslevelmtime
          )gzip_compress
memoryview	bytearraygzipFNAMEr   bytes)r   r   compressed_datacompressed_viewheaderfilenames         r   compress_stringr     sl    #AQa@O 1Os+,F

F1I#$45?H=8#obc&:::r   c                       \ rS rSrS rSrg)StreamingBufferi  c                 h    U R                  5       nU R                  S5        U R                  5         U$ )Nr   )getvalueseekrS   )r4   rets     r   readStreamingBuffer.read  s&    mmo		!
r   r'   N)r(   r)   r*   r+   r   r-   r'   r   r   r   r     s    r   r   c             #   L  #    [        5       nU(       a  [        U5      OS n[        USSUSS9 nUR                  5       v   U  H1  nUR	                  U5        UR                  5       nU(       d  M-  Uv   M3     S S S 5        UR                  5       v   g ! , (       d  f       N!= f7f)Nwbr   r   )r   moder   fileobjr   )r   r   r   r   write)sequencer   bufr   zfileitemdatas          r   compress_sequencer    s     

C9I#$45tH	As!
	hhjDKK88:Dt
	 
 ((*
 
s"   ,B$>B0B8B$
B!B$z
    ((?:
        [^\s'"]*
        (?:
            (?:"(?:[^"\\]|\\.)*" | '(?:[^'\\]|\\.)*')
            [^\s'"]*
        )+
    ) | \S+)
c              #   d   #    [         R                  [        U 5      5       H
  nUS   v   M     g7f)as  
Generator that splits a string by spaces, leaving quoted phrases together.
Supports both single and double quotes, and supports escaping quotes with
backslashes. In the output, strings will keep their initial and trailing
quote marks and escaped quotes will remain escaped (the results can then
be further processed with unescape_string_literal()).

>>> list(smart_split(r'This is "a person\'s" test.'))
['This', 'is', '"a person\\\'s"', 'test.']
>>> list(smart_split(r"Another 'person\'s' test."))
['Another', "'person\\'s'", 'test.']
>>> list(smart_split(r'A "\"funky\" style" test.'))
['A', '"\\"funky\\" style"', 'test.']
r   N)smart_split_refinditerr   )r#   bits     r   smart_splitr    s)      &&s4y1!f 2s   .0c                     U (       a  U S   S;  d  U S   U S   :w  a  [        SU -  5      eU S   nU SS R                  SU-  U5      R                  SS5      $ )	a@  
Convert quoted string literals to unquoted strings with escaped quotes and
backslashes unquoted::

    >>> unescape_string_literal('"abc"')
    'abc'
    >>> unescape_string_literal("'abc'")
    'abc'
    >>> unescape_string_literal('"a \"bc\""')
    'a "bc"'
    >>> unescape_string_literal("'\'ab\' c'")
    "'ab' c"
r   z"'r   zNot a string literal: %rr   z\%sz\\\)r   r   )r   quotes     r   unescape_string_literalr    sb     !E!QrUad]3a788aDEQr7??6E>5199%FFr   c                 \   [        U 5      n U(       a  [        R                  " SU 5      n O6[        R                  " SU 5      R                  SS5      R	                  S5      n [
        R                  " SSU R                  5       5      n [
        R                  " SSU 5      R                  S	5      $ )
a  
Convert to ASCII if 'allow_unicode' is False. Convert spaces or repeated
dashes to single dashes. Remove characters that aren't alphanumerics,
underscores, or hyphens. Convert to lowercase. Also strip leading and
trailing whitespace, dashes, and underscores.
NFKCNFKDasciiignorez[^\w\s-]rC   z[-\s]+-z-_)	r   re   rf   encodedecoder   r   r   r   )valueallow_unicodes     r   slugifyr    s     JE%%fe4 !!&%0VGX&VG_ 	
 FF;EKKM2E66)S%(..t44r   c                 f    [         R                  SU 5      R                  5       R                  5       $ )zI
Split CamelCase and convert to lowercase. Strip surrounding whitespace.
z \1)re_camel_caser   r   r   )r  s    r   camel_case_to_spacesr"    s)     VU+11399;;r   c                 &    U R                   " U0 UD6$ )z_
Apply str.format() on 'format_string' where format_string, args,
and/or kwargs might be lazy.
)format)format_stringargskwargss      r   _format_lazyr(    s    
 000r   r;   )F)5r   r   r   re   r   r   r   ior   django.core.exceptionsr   django.utils.functionalr   r   r	   django.utils.regex_helperr
   django.utils.translationr   r   r   r   r   Sr    r   r   r!   r   r   r   r   r!  rP   rT   rV   r   r   r   r   r   r   r   r  VERBOSEr  r  r  r  r"  r(  r   format_lazyr'   r   r   <module>r1     s    	    *  : J J 6 1 ;    ( M2440	/244	0@ @&* *( ORTT2	:BDD	Az* !JK ! !@ f  fR    #/#5  2 , ,
 A AB6 ,0 ;g  59 $ " JJ& G G( 5 5(<1 <%r   