
    4i                    `    d dl mZ d dlZd dlmZ d dlmZ erd dlmZ g dZ	d
dZ
ddZdd	Zy)    )annotationsN)TYPE_CHECKING)StreamlitAPIException)Sequence))z.jpgz.jpeg)z.mpgz.mpeg)z.mp4z.mpeg4)z.tifz.tiff)z.htmz.htmlc                .   t         j                  dk(  r_d| v r[| j                  dd      \  }}t         j                  j	                  |      d   r$|t         j                  j	                  |      d   fS | t         j                  j	                  |       d   fS )z6Returns the main part of a filename and its extension.nt:   )osnamesplitpathsplitext)filenamemain_filenameads_parts      t/home/obispo/Crisostomo_bridge/mision_env/lib/python3.12/site-packages/streamlit/elements/lib/file_uploader_utils.py _get_main_filename_and_extensionr   "   s     
ww$3(?"*..a"8x77H%a( "''"2"2="A!"DDDRWW%%h/222    c                6   t        | t              r| g} | D cg c]  }|d   dk(  r|nd|  } }| D cg c]  }|j                          } }t        D ]9  \  }}|| v r|| vr| j	                  |       || v s$|| vs)| j	                  |       ; | S c c}w c c}w )Nr   .)
isinstancestrlower
TYPE_PAIRSappend)	file_typefile_type_entrytxys        r   normalize_upload_file_typer"   .   s    )S!K	  ) +1-4Ao=N:OOI 
 %..q.I.  1	>ay0Q	>ay0Q	  
 /s
   BBc                    d| v rt        d      t        |       \  }}|j                         |D cg c]  }|j                          }}t        fd|D              st        d| d|       yc c}w )a   Ensure the uploaded file's extension matches the allowed
    types set by the app developer. In theory, this should never happen, since we
    enforce file type check by extension on the frontend, but we check it on backend
    before returning file to the user to protect ourselves.
     z#Filename cannot contain null bytes.c              3  @   K   | ]  }j                  |        y w)N)endswith).0allowed_typenormalized_filenames     r   	<genexpr>z/enforce_filename_restriction.<locals>.<genexpr>U   s$       	$$\2s   zInvalid file extension: `z`. Allowed: N)r   r   r   any)r   allowed_typesr   	extensionr(   normalized_allowed_typesr)   s         @r   enforce_filename_restrictionr/   D   s     x#$IJJ?IM9'--/IVW 2 2 4WW 4  $'	{,}oN
 	
	  Xs   A2)r   r   returnztuple[str, str])r   zstr | Sequence[str]r0   Sequence[str])r   r   r,   r1   r0   None)
__future__r   r   typingr   streamlit.errorsr   collections.abcr   r   r   r"   r/    r   r   <module>r8      s/    # 	   2(
	3,
r   