o
    Yh	                     @  s   d Z ddlmZ ddlZddlZddlZddlmZmZm	Z	 ddl
mZ er,ddlmZ dd
dZdddZdddZG dd deeef ZdddZdS ) zA bunch of useful utilities.    )annotationsN)TYPE_CHECKINGAnyCallable)RootContainer)DeltaGeneratorfuncCallable[..., Any]returnc                   s"   g t  d fdd}|S )z2Decorator to memoize the result of a no-args func.r
   r   c                     s   s    d S )Nr   )append r   resultr   O/var/www/html/Persson_Maskin/env/lib/python3.10/site-packages/streamlit/util.pywrapped_func"   s   zmemoize.<locals>.wrapped_funcN)r
   r   )	functoolswraps)r   r   r   r   r   memoize   s   r   selfr   strc                   s|   j j}dddg t i g tr  fddtD }n fddj D }ddd |D }| d	| d
S )zA clean repr for a class, excluding both values that are likely defaults,
    and those explicitly default for dataclasses.
    N Fc                 3  sJ    | ] }|j r"t|j|jkr"t|j vr|jt|jfV  qd S N)reprgetattrnamedefault).0fdefaultsr   r   r   	<genexpr>4   s    zrepr_.<locals>.<genexpr>c                 3  s$    | ]\}}| vr||fV  qd S r   r   )r   r   v)r   r   r   r    <   s   " z, c                 s  s"    | ]\}}| d |V  qdS )=Nr   )r   fieldvaluer   r   r   r    >   s     ())		__class____name__setdataclassesis_dataclassfields__dict__itemsjoin)r   	classnamefields_valsfield_reprsr   r   r   repr_+   s   
r3   sbytes | strc                 C  s8   t jddd}t| tr| dn| }|| | S )ziReturn the md5 hash of the given string.

    This should not be used for security-related purposes.
    md5F)usedforsecurityzutf-8)hashlibnew
isinstancer   encodeupdate	hexdigest)r4   hbr   r   r   calc_md5B   s   
r@   c                   @  s$   e Zd ZdZdddZdddZdS )AttributeDictionarya  
    A dictionary subclass that supports attribute-style access.

    This class extends the functionality of a standard dictionary to allow items
    to be accessed via attribute-style dot notation in addition to the traditional
    key-based access. If a dictionary item is accessed and is itself a dictionary,
    it is automatically wrapped in another `AttributeDictionary`, enabling recursive
    attribute-style access.
    keyr   r
   r   c              
   C  s\   z|  |}t|trt|W S |W S  ty- } ztdt| j d| d|d }~ww )N'z' object has no attribute ')__getitem__r:   dictrA   KeyErrorAttributeErrortyper(   )r   rB   itemerrr   r   r   __getattr__[   s   
zAttributeDictionary.__getattr__r   r$   Nonec                 C  s   || |< d S r   r   )r   r   r$   r   r   r   __setattr__d   s   zAttributeDictionary.__setattr__N)rB   r   r
   r   )r   r   r$   r   r
   rL   )r(   
__module____qualname____doc__rK   rM   r   r   r   r   rA   P   s    

	rA   dgr   boolc                 C  s   | j jtjkS )z.Check if the DeltaGenerator is in the sidebar.)
_active_dg_root_containerr   SIDEBAR)rQ   r   r   r   
in_sidebarh   s   rV   )r   r	   r
   r	   )r   r   r
   r   )r4   r5   r
   r   )rQ   r   r
   rR   )rP   
__future__r   r*   r   r8   typingr   r   r   !streamlit.proto.RootContainer_pb2r   streamlit.delta_generatorr   r   r3   r@   rE   rA   rV   r   r   r   r   <module>   s   


