
    D6i                     b    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	 d Z
d Zd Zd	 Zd
 Zy)    )DOTALL)compile)sub)maxsize)xxh32xxh64c                 B    t        dd| xs d      j                          S )zCheck if the content is truly empty.

    Paramaters
    ----------
        content: str
            content to check if it's truly empty.

    Returns
    -------
        Boolean True if empty False if not.
    z	[ |\n|\t] )r   strip)contents    U/home/azureuser/techstart-app/venv/lib/python3.12/site-packages/flask_minify/utils.pyis_emptyr   	   s#     <W]399;;;    c                 *   t        |      ry| dk(  r|t        |      rq|j                  dd      j                  dd      j                         d|v rdvry|D ch c]  }|dk7  rdj	                  |       }}t        fd	|D              syyc c}w )
a  Check if the content is valid for its tag type and definition.

    Paramaters
    ----------
        tag: str
            the tag type to validate.
        opening_tag_html: str
            the html of the opening tag, including any attributes.
        content: str
            content to check if it's empty.
        script_types: list
            list of script types to limit js minification to.

    Returns
    -------
        Boolean True if valid, False if not.
    Fscript"r
   'ztype=Tztype={}c              3   &   K   | ]  }|v  
 y w)N ).0
valid_typetag_no_quotess     r   	<genexpr>z'is_valid_tag_content.<locals>.<genexpr>:   s     M::.Ms   )r   lenreplacelowerformatany)tagopening_tag_htmlr   script_typesscript_typevalid_typesr   s         @r   is_valid_tag_contentr$      s    $ 
h3|,(00b9AA#rJPPRm+  ,
b  [)
 
 MMM
s   Bc                 z    t        dj                        t              }fd|j                  |       D        S )ah  Get list of html tag contents.

    Parameters
    ----------
        html: string
            html flask response content.
        tag: string
            tag to retrieve its specific content.
        script_types: list
            list of script types to limit js minification to.

    Returns
    -------
        String of specific tag's inner content.
    z(<{0}[^>]*>)(.*?)</{0}>c              3      K   | ]B  }t        |j                  d       |j                  d            r|j                  d       D yw)      )r    r   r!   N)r$   group)r   r   r!   r   s     r   r   z#get_tag_contents.<locals>.<genexpr>R   sH      	$]]1-MM!$%	
 	a	s   AA)
compile_rer   r   finditer)htmlr   r!   regexs    `` r   get_tag_contentsr.   @   s8      188=vFE	~~d+	 	r   c                 f    t        | dd      j                         }d|v }d|v xs d|v }d|v }|||fS )zCheck if Flask response of content-type match HTML, CSS\LESS or JS.

    Parameters
    ----------
        response: Flask response

    Returns
    -------
        (bool, bool, bool)
            html, cssless, js if content type match.
    content_typer
   z	text/htmlcssless
javascript)getattrr   )responser0   r,   csslessjss        r   does_content_type_matchr8   ^   sP     8^R8>>@L,&D|#=v'=G		%B"r   c                  ,    t         dkD  rt        S t        S )z7Gets optimized hashing module based on cpu architecturel        )r   r   r   r   r   r   get_optimized_hashingr:   r   s    eO5..r   N)rer   r   r*   r   sysr   xxhashr   r   r   r$   r.   r8   r:   r   r   r   <module>r>      s.     $   <%P<(/r   