
    wi8                        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  e             G d
 de                      ZdS )zgr.State() component.    )annotationsN)Callable)deepcopy)Any)document)	Component)Eventsc                       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               0   |t           j        n|x| _        | _        |pd | _        	 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.
        Nc                    d S N )as    g/root/.openclaw/workspace/chatterbox_venv_py311/lib/python3.11/site-packages/gradio/components/state.py<lambda>z State.__init__.<locals>.<lambda>.   s    T     zYThe 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   	TypeErrortypesuper__init__r   )selfr   r   r   r   err	__class__s         r   r    zState.__init__   s      %,DHH,	
D-  /B>>	UOOEE 	 	 	 Plpqvlwlw  P  P  P 	 	uV444


s   9 
A)!A$$A)returnc                    dS NTr   r!   s    r   statefulzState.stateful8       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.postprocessE   s	     r   dict[str, Any]c                    i ddS )Nzany valid json)r   descriptionr   r'   s    r   api_infozState.api_infoN   s    +;<<<r   c                    d S r   r   r'   s    r   example_payloadzState.example_payloadQ       tr   c                    d S r   r   r'   s    r   example_valuezState.example_valueT   r5   r   c                    dS r&   r   r'   s    r   skip_apizState.skip_apiW   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_grouping`   s    ur   r&   )r   r   r   r   r   r   r   r   )r$   r   )r*   r   r$   r   )r   r   r$   r   )r$   r/   )r$   r   )__name__
__module____qualname__r	   changeEVENTSallow_string_shortcutr    propertyr(   r,   r.   r2   r4   r7   r9   r;   r>   __classcell__)r#   s   @r   r   r      s>       m_F " 
 ,08<       8    X      = = = =         X    
       r   r   )__doc__
__future__r   r   collections.abcr   copyr   typingr   gradio_client.documentationr   gradio.components.baser   gradio.eventsr	   r   r   r   r   <module>rO      s      " " " " " "  $ $ $ $ $ $             0 0 0 0 0 0 , , , , , ,             
Q Q Q Q QI Q Q Q Q Qr   