
    Pi                        d Z ddlm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 dd	lmZ ddZ e             G d de                      ZdS )zgr.State() component.    )annotationsN)Callable)deepcopy)Any)document)	Component)Eventsxr   returnNonec                    d S N )r
   s    k/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/gradio/components/state.pydefault_delete_callbackr      s    D    c                       e Zd Zej        gZ	 dZ	 	 ddddd fdZedd            Z	ddZ
ddZddZd dZd dZed             Z fdZddZ xZS )!StateFNT)time_to_livedelete_callbackvaluer   renderboolr   int | float | Noner   Callable[[Any], None] | Nonec               8   |t           j        n|x| _        | _        |pt          | _        	 t          |          }n3# t          $ r&}t          dt          |           d          |d}~ww xY wt                      	                    ||           || _
        dS )a:  
        Parameters:
            value: the initial value (of arbitrary type) of the state. The provided argument is deepcopied. If a callable is provided, the function will be called whenever the app loads to set the initial value of the state.
            render: should always be True, is included for consistency with other components.
            time_to_live: the number of seconds the state should be stored for after it is created or updated. If None, the state will be stored indefinitely. Gradio automatically deletes state variables after a user closes the browser tab or refreshes the page, so this is useful for clearing state for potentially long running sessions.
            delete_callback: a function that is called when the state is deleted. The function should take the state value as an argument.
        NzYThe initial value of `gr.State` must be able to be deepcopied. The initial value of type z cannot be deepcopied.)r   r   )mathinfr   r   r   r   	TypeErrortypesuper__init__r   )selfr   r   r   r   err	__class__s         r   r"   zState.__init__    s      %,DHH,	
D-  /I2I	UOOEE 	 	 	 Plpqvlwlw  P  P  P 	 	uV444


s   = 
A-!A((A-r   c                    dS NTr   r#   s    r   statefulzState.stateful<       tr   payloadc                    |S )z
        Parameters:
            payload: Value
        Returns:
            Passes a value of arbitrary type through.
        r   )r#   r+   s     r   
preprocesszState.preprocess@   s	     r   c                    |S )z
        Parameters:
            value: Expects a value of arbitrary type, as long as it can be deepcopied.
        Returns:
            Passes a value of arbitrary type through.
        r   )r#   r   s     r   postprocesszState.postprocessI   s	     r   dict[str, Any]c                    i ddS )Nzany valid json)r    descriptionr   r(   s    r   api_infozState.api_infoR   s    +;<<<r   c                    d S r   r   r(   s    r   example_payloadzState.example_payloadU       tr   c                    d S r   r   r(   s    r   example_valuezState.example_valueX   r6   r   c                    dS r'   r   r(   s    r   skip_apizState.skip_api[   r*   r   c                N    t                                                      }|d= |S )Nr   )r!   
get_config)r#   configr%   s     r   r<   zState.get_config_   s$    ##%%7Or   c                    dS )z:State components should not break wrapper grouping chains.Fr   r(   s    r   breaks_groupingzState.breaks_groupingd   s    ur   r'   )r   r   r   r   r   r   r   r   )r   r   )r+   r   r   r   )r   r   r   r   )r   r0   )r   r   )__name__
__module____qualname__r	   changeEVENTSallow_string_shortcutr"   propertyr)   r-   r/   r3   r5   r8   r:   r<   r?   __classcell__)r%   s   @r   r   r      s>       m_F " 
 ,08<       8    X      = = = =         X    
       r   r   )r
   r   r   r   )__doc__
__future__r   r   collections.abcr   copyr   typingr   gradio_client.documentationr   gradio.components.baser   gradio.eventsr	   r   r   r   r   r   <module>rP      s      " " " " " "  $ $ $ $ $ $             0 0 0 0 0 0 , , , , , ,            	 	 	 	 
Q Q Q Q QI Q Q Q Q Qr   