Ë
    q^ëiÞ7  ã                   óH  — d dl Z d dlZd dlZd dlZ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 d dlmZ d dlmZ d d	lmZmZ ed
„ «       Z edej.                  «      Z edej.                  «      Z edej.                  «      Z ed«      Z ed«      Zed„ «       Z G d„ de«      Zed„ «       Ze ed«      fd„«       Z ed„ «       Z!ed„ «       Z"d„ Z#ddœd„Z$ G d„ de«      Z%ddœd„Z& edejN                  «      Z(d„ Z)ed „ «       Z*ed$d!„«       Z+d"„ Z,d#„ Z- ee-e.«      Z/y)%é    N)ÚGzipFile)Úcompress)ÚBytesIO)ÚSuspiciousFileOperation)ÚSimpleLazyObjectÚkeep_lazy_textÚlazy)Ú_lazy_re_compile)Úgettext)Úgettext_lazyÚpgettextc                 ór   — | s| S t        | t        «      st        | «      } | d   j                  «       | dd z   S )z(Capitalize the first letter of a string.r   é   N)Ú
isinstanceÚstrÚupper)Úxs    úB/var/www/eb/venv/lib/python3.12/site-packages/django/utils/text.pyÚcapfirstr      s:   € ñ ØˆÜ�aœÔÜ�‹FˆØˆQ‰4�:‰:‹<˜!˜A˜B˜%ÑÐó    z<[^>]+?>|([^<>\s]+)z<[^>]+?>|(.)z<(/)?(\S+?)(?:(\s*/)|\s.*?)?>z\r\n|\rz&(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))c                 ó>   ‡ ‡— ˆ ˆfd„}dj                   |«       «      S )aC  
    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   ó¼  •K  — ‰j                  d«      D ]Ã  } t        | j                  d«      xr ‰dz   xs ‰‰«      }t        | «      |kD  r†| d |dz    j	                  d«      dz   }|dk(  r | j                  d«      dz   }|dk(  r| –— d} nGd| d |dz
   z  –— | |d  } t        | j                  d«      xr ‰dz   xs ‰‰«      }t        | «      |kD  rŒ†| sŒÀ| –— ŒÅ y ­w)NTú
r   ú r   Ú z%s
)Ú
splitlinesÚminÚendswithÚlenÚrfindÚfind)ÚlineÚ	max_widthÚspaceÚtextÚwidths      €€r   Ú
_generatorzwrap.<locals>._generator/   s÷   øè ø€ Ø—O‘O DÓ)ò 	ˆDÜ˜TŸ]™]¨4Ó0Ò>°U¸Q±YÒGÀ%È%ÓPˆIÜ�d“)˜iÒ'Ø˜_˜y¨1™}Ð-×3Ñ3°CÓ8¸1Ñ<�Ø˜A’:Ø ŸI™I c›N¨QÑ.�EØ ’zØ"š
Ø!˜ØØ˜t K e¨a¡iÐ0Ñ0Ò0Ø˜E˜F�|�Ü §¡¨tÓ!4Ò!B¸À¹Ò!KÀeÈeÓT�	ô �d“)˜iÓ'ò Ø“
ñ	ùs   ƒCCÃCÃCr   )Újoin)r%   r&   r'   s   `` r   Úwrapr)   "   s   ù€ õð" �7‰7‘:“<Ó Ð r   c                   óL   ‡ — e Zd ZdZˆ fd„Zd	d„Zd
d„Zd„ Zd
d„Zd„ Z	d„ Z
ˆ xZS )Ú	TruncatorzI
    An object used to truncate text, either by characters or words.
    c                 ó,   •‡— t         ‰| �  ˆfd„«       y )Nc                  ó   •— t        ‰ «      S ©N©r   ©r%   s   €r   ú<lambda>z$Truncator.__init__.<locals>.<lambda>I   s   ø€ ¤ T£€ r   )ÚsuperÚ__init__)Úselfr%   Ú	__class__s    `€r   r3   zTruncator.__init__H   s   ù€ Ü‰ÑÓ*Õ+r   c                 óf   — |€t        dd«      }d|v r|d|iz  S |j                  |«      r|S |›|›�S )Nz%String to return when truncating textu   %(truncated_text)sâ€¦z%(truncated_text)sÚtruncated_text)r   r   )r4   r%   Útruncates      r   Úadd_truncation_textzTruncator.add_truncation_textK   sS   € ØÐÜØ7Ð9PóˆHð   8Ñ+ØÐ/°Ð6Ñ6Ð6ð �=‰=˜Ô"ð ˆKÙ™xÐ(Ð(r   c                 óD  — | j                  «        t        |«      }t        j                  d| j                  «      }|}| j                  d|«      D ]$  }t        j                  |«      rŒ|dz  }|dk(  sŒ$ n |r| j                  ||||d«      S | j                  ||||«      S )a  
        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.
        ÚNFCr   r   r   F)	Ú_setupÚintÚunicodedataÚ	normalizeÚ_wrappedr9   Ú	combiningÚ_truncate_htmlÚ_text_chars)r4   Únumr8   ÚhtmlÚlengthr%   Útruncate_lenÚchars           r   ÚcharszTruncator.charsZ   s§   € ð 	�‰ŒÜ�S“ˆÜ×$Ñ$ U¨D¯M©MÓ:ˆð ˆØ×,Ñ,¨R°Ó:ò 	ˆDÜ×(Ñ(¨Õ.Ø Ñ!�Ø 1Ó$Ùð		ñ
 Ø×&Ñ& v¨x¸¸|ÈUÓSÐSØ×Ñ ¨°$¸ÓEÐEr   c                 ó¼   — d}d}t        |«      D ]I  \  }}t        j                  |«      rŒ|dz  }|€||kD  r|}||kD  sŒ0| j                  |d|xs d |«      c S  |S )z2Truncate a string after a certain number of chars.r   Nr   )Ú	enumerater>   rA   r9   )	r4   rF   r8   r%   rG   Ús_lenÚ	end_indexÚirH   s	            r   rC   zTruncator._text_charsq   s€   € àˆØˆ	Ü  “ò 
	R‰GˆAˆtÜ×$Ñ$ TÔ*ð Ø�Q‰JˆEØÐ  U¨\Ò%9Ø�	Ø�v‹~à×/Ñ/°Ð5E°y²~ÀAÐ0FÈÓQÒQð
	Rð ˆr   c                 óž   — | j                  «        t        |«      }|r| j                  ||| j                  |d«      S | j	                  ||«      S )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)r<   r=   rB   r@   Ú_text_words)r4   rD   r8   rE   rF   s        r   ÚwordszTruncator.words„   sJ   € ð 	�‰ŒÜ�S“ˆÙØ×&Ñ& v¨x¸¿¹ÈÐPTÓUÐUØ×Ñ ¨Ó1Ð1r   c                 óÀ   — | j                   j                  «       }t        |«      |kD  r&|d| }| j                  dj	                  |«      |«      S dj	                  |«      S )zk
        Truncate a string after a certain number of words.

        Strip newlines in the string.
        Nr   )r@   Úsplitr   r9   r(   )r4   rF   r8   rQ   s       r   rP   zTruncator._text_words�   sV   € ð —‘×#Ñ#Ó%ˆÜˆu‹:˜ÒØ˜'˜6�NˆEØ×+Ñ+¨C¯H©H°U«O¸XÓFÐFØ�x‰x˜‹Ðr   c                 óF  — |r|dk  ryd}d}d}d}	g }
|rt         nt        }|	|k  r¸|j                  ||«      }|sn£|j                  d«      }|d   r|	dz  }	|	|k(  r|}Œ=t        j                  |d   «      }|r|	|k\  rŒ]|j                  «       \  }}}|j                  «       }|s||v rn/|r	 |
j                  |«      }|
|dz   d }
n|
j                  d|«       |	|k  rŒ¸|	|k  r|S |d| }| j                  d|«      }|r||z  }|
D ]
  }|d|z  z  }Œ |S # t        $ r Y ŒGw xY w)a  
        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   r   )	ÚbrÚcolÚlinkÚbaseÚimgÚparamÚareaÚhrÚinputr   Nz</%s>)Úre_wordsÚre_charsÚsearchÚendÚre_tagÚmatchÚgroupsÚlowerÚindexÚ
ValueErrorÚinsertr9   )r4   rF   r8   r%   rG   rQ   Úhtml4_singletsÚposÚend_text_posÚcurrent_lenÚ	open_tagsÚregexÚmÚtagÚclosing_tagÚtagnameÚself_closingrN   ÚoutÚtruncate_texts                       r   rB   zTruncator._truncate_htmlœ   sƒ  € ñ �V˜q’[Øð

ˆð ˆØˆØˆØˆ	á!•¤xˆà˜VÒ#Ø—‘˜T 3Ó'ˆAÙàØ—%‘%˜“(ˆCØ�Štà˜qÑ �Ø ,Ò.Ø#&�LØä—,‘,˜q ™tÓ$ˆCÙ˜+¨Ò5àØ14·±³Ñ.ˆK˜ ,à—m‘m“oˆGÙ˜w¨.Ñ8ØÙð3Ø!Ÿ™¨Ó0�Að !*¨!¨a©%¨'Ð 2‘Ið × Ñ   GÔ,ðE ˜VÓ#ðH ˜&Ò ØˆKØ�=�LÐ!ˆØ×0Ñ0°°XÓ>ˆÙØ�=Ñ ˆCàò 	!ˆCØ�7˜S‘=Ñ ‰Cð	!ð ˆ
øô) "ò Ùðús   Â,D Ä	D ÄD r.   )NF)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r3   r9   rI   rC   rQ   rP   rB   Ú__classcell__)r5   s   @r   r+   r+   C   s-   ø„ ñô,ó)óFò.ó&
2ò
öMr   r+   c                 óª   — t        | «      j                  «       j                  dd«      }t        j                  dd|«      }|dv rt        d| z  «      ‚|S )aY  
    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'
    r   Ú_z(?u)[^-\w.]r   >   ú..r   ú.z$Could not derive file name from '%s')r   ÚstripÚreplaceÚreÚsubr   )ÚnameÚss     r   Úget_valid_filenamer…   ì   sQ   € ô 	ˆD‹	�‰Ó×!Ñ! # sÓ+€AÜ
�‰ˆ~˜r 1Ó%€AØˆOÑÜ%Ð&LÈtÑ&SÓTÐTØ€Hr   Úorc                 óÂ   — | syt        | «      dk(  rt        | d   «      S t        d«      j                  d„ | dd D «       «      ›dt        |«      ›dt        | d   «      ›�S )	a   
    >>> 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([])
    ''
    r   r   r   z, c              3   ó2   K  — | ]  }t        |«      –— Œ y ­wr.   r/   )Ú.0rN   s     r   ú	<genexpr>z get_text_list.<locals>.<genexpr>  s   è ø€ Ò0 ”S˜—VÑ0ùs   ‚Néÿÿÿÿr   )r   r   r|   r(   )Úlist_Ú	last_words     r   Úget_text_listrŽ   ý   s]   € ñ ØÜ
ˆ5ƒz�Q‚Ü�5˜‘8‹}Ðô 	
ˆ$‹�‰Ñ0 U¨3¨B ZÔ0Õ0ÜˆI�ÜˆE�"‰IŒð	ð r   c                 ó@   — t         j                  dt        | «      «      S )z*Normalize CRLF and CR newlines to just LF.r   )Úre_newlinesr‚   r   r0   s    r   Únormalize_newlinesr‘     s   € ô �?‰?˜4¤ T£Ó+Ð+r   c                 óÖ   ‡— i dd“dd“dd“dd“dd“dd“d	d
“dd
“dd
“dd“dd“dd“dd“dd“dd“dd“dd“ddddddddddœ	¥Šdj                  ˆfd„| j                  «       D «       «      S )z@Convert a phone number with letters into its numeric equivalent.ÚaÚ2ÚbÚcÚdÚ3ÚeÚfÚgÚ4ÚhrN   ÚjÚ5ÚkÚlro   Ú6ÚnÚoÚpÚ7ÚqÚ8Ú9)	Úrr„   ÚtÚuÚvÚwr   ÚyÚzr   c              3   óB   •K  — | ]  }‰j                  ||«      –— Œ y ­wr.   )Úget)r‰   r–   Úchar2numbers     €r   rŠ   z phone2numeric.<locals>.<genexpr><  s   øè ø€ Ò@¨Q�;—?‘? 1 a×(Ñ@ùs   ƒ)r(   re   )Úphoner³   s    @r   Úphone2numericrµ     s  ø€ ðØˆSðàˆSðð 	ˆSðð 	ˆSð	ð
 	ˆSðð 	ˆSðð 	ˆSðð 	ˆSðð 	ˆSðð 	ˆSðð 	ˆSðð 	ˆSðð 	ˆSðð 	ˆSðð 	ˆSðð  	ˆSð!ð" 	ˆSð#ð$ ØØØØØØØØò5€Kð8 �7‰7Ó@°%·+±+³-Ô@Ó@Ð@r   c                 ó2   — dt        j                  | «      z  S )Nó   a)ÚsecretsÚ	randbelow©Úmax_random_bytess    r   Ú_get_random_filenamer¼   ?  s   € Ø”'×#Ñ#Ð$4Ó5Ñ5Ð5r   rº   c                óÂ   — t        | dd¬«      }|s|S t        |«      }t        |d d «      }t        j                  |d<   t        |«      dz   }t        |«      |z   |dd  z   S )Né   r   )ÚcompresslevelÚmtimeé
   é   ó    )Úgzip_compressÚ
memoryviewÚ	bytearrayÚgzipÚFNAMEr¼   Úbytes)r„   r»   Úcompressed_dataÚcompressed_viewÚheaderÚfilenames         r   Úcompress_stringrÎ   C  sl   € Ü# A°Q¸aÔ@€OáØÐä  Ó1€OÜ� s¨Ð+Ó,€FÜ—
‘
€Fˆ1�Iä#Ð$4Ó5¸Ñ?€Hä�‹=˜8Ñ# o°b°cÐ&:Ñ:Ð:r   c                   ó   — e Zd Zd„ Zy)ÚStreamingBufferc                 óh   — | j                  «       }| j                  d«       | j                  «        |S )Nr   )ÚgetvalueÚseekr8   )r4   Úrets     r   ÚreadzStreamingBuffer.readS  s&   € Ø�m‰m‹oˆØ�	‰	�!ŒØ�‰ŒØˆ
r   N)rv   rw   rx   rÕ   © r   r   rÐ   rÐ   R  s   „ ór   rÐ   c             #   ó0  K  — t        «       }|rt        |«      nd }t        |dd|d¬«      5 }|j                  «       –— | D ]*  }|j	                  |«       |j                  «       }|sŒ'|–— Œ, 	 d d d «       |j                  «       –— y # 1 sw Y   ŒxY w­w)NÚwbr¾   r   )rÍ   Úmoder¿   ÚfileobjrÀ   )rÐ   r¼   r   rÕ   Úwrite)Úsequencer»   ÚbufrÍ   ÚzfileÚitemÚdatas          r   Úcompress_sequencerá   [  s�   è ø€ Ü
Ó
€CÙ9IÔ#Ð$4Ô5Èt€HÜ	Ø °A¸sÈ!ô
ð 	à	à�h‰h‹jÒØò 	ˆDØ�K‰K˜ÔØ—8‘8“:ˆDÚØ“
ñ		÷	ð �(‰(‹*Ó÷	ð 	üs"   ‚*B¬;B
Á(B
Á/BÂ
BÂBzŠ
    ((?:
        [^\s'"]*
        (?:
            (?:"(?:[^"\\]|\\.)*" | '(?:[^'\\]|\\.)*')
            [^\s'"]*
        )+
    ) | \S+)
c              #   ó`   K  — t         j                  t        | «      «      D ]	  }|d   –— Œ y­w)a£  
    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/   è ø€ ô ×&Ñ&¤s¨4£yÓ1ò ˆØ�!‰f‹ñùs   ‚,.c                 ó    — | r| d   dvs| d   | d   k7  rt        d| z  «      ‚| d   }| dd j                  d|z  |«      j                  dd«      S )	al  
    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\\ú\)rg   r€   )r„   Úquotes     r   Úunescape_string_literalrê   Ž  sb   € ñ ��!‘˜EÑ! Q r¡U¨a°©d¢]ÜÐ3°aÑ7Ó8Ð8Øˆa‰D€EØˆQˆrˆ7�?‰?˜6 E™>¨5Ó1×9Ñ9¸%ÀÓFÐFr   c                 óJ  — t        | «      } |rt        j                  d| «      } n5t        j                  d| «      j                  dd«      j	                  d«      } t        j                  dd| j                  «       «      } t        j                  dd| «      j                  d	«      S )
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-]r   z[-\s]+ú-z-_)	r   r>   r?   ÚencodeÚdecoder�   r‚   re   r   )ÚvalueÚallow_unicodes     r   Úslugifyrõ   £  s†   € ô �‹J€EÙÜ×%Ñ% f¨eÓ4‰ô ×!Ñ! &¨%Ó0ß‰V�G˜XÓ&ß‰V�G‹_ð 	ô
 �F‰F�;  E§K¡K£MÓ2€EÜ�6‰6�)˜S %Ó(×.Ñ.¨tÓ4Ð4r   c                 óf   — t         j                  d| «      j                  «       j                  «       S )zQ
    Split CamelCase and convert to lowercase. Strip surrounding whitespace.
    z \1)Úre_camel_caser‚   r   re   )ró   s    r   Úcamel_case_to_spacesrø   ¸  s)   € ô ×Ñ˜V UÓ+×1Ñ1Ó3×9Ñ9Ó;Ð;r   c                 ó&   —  | j                   |i |¤ŽS )zk
    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   )F)0rÇ   r�   r¸   r>   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_   rb   r�   r÷   r)   r+   r…   rŽ   r‘   rµ   r¼   rÎ   rÐ   rá   ÚVERBOSErã   ræ   rê   rõ   rø   rþ   r   Úformat_lazyrÖ   r   r   ú<module>r     s�  ðÛ Û 	Û Û Ý Ý *Ý å :ß JÑ JÝ 6Ý 1ß ;ð ñ ó ð ñ Ð2°B·D±DÓ9€Ù˜O¨R¯T©TÓ2€Ù	Ð:¸B¿D¹DÓ	A€Ù˜zÓ*€Ù Ð!JÓK€ð ñ!ó ð!ô@fÐ ô fðR ñó ðð  Ù#/°Ó#5ò ó ðð2 ñ,ó ð,ð
 ñAó ðAòB6ð ,0ô ;ô�gô ð 59ô ñ$ "ðð ‡J�Jó€òð& ñGó ðGð( ò5ó ð5ò(<ò1ñ �< Ó%�r   