a
    dD                     @  s   d Z ddlmZ ddlmZ ddlmZmZ ddlm	Z	 ddl
mZmZ ddlmZmZ ed e G d	d
 d
eeee	ZdS )zgr.Code() component    )annotations)Literal)documentset_documentation_group)StringSerializable)IOComponent	_Keywords)
Changeable	Inputable	componentc                   @  s   e Zd ZdZg dZdddddddddddd
dd	d
dddddd
ddddddZdd Zdd Zee	j
ddddddddf	dddddddd	dd	ddZdS )Codez
    Creates a Code editor for entering, editing or viewing code.
    Preprocessing: passes a {str} of code into the function.
    Postprocessing: expects the function to return a {str} of code or a single-elment {tuple}: (string filepath,)
    )pythonZmarkdownjsonhtmlcssZ
javascriptZ
typescriptZyamlZ
dockerfileshellrNN   T   )
lineslabelinteractive
show_label	containerscale	min_widthvisibleelem_idelem_classeszstr | tuple[str] | Nonez{Literal['python', 'markdown', 'json', 'html', 'css', 'javascript', 'typescript', 'yaml', 'dockerfile', 'shell', 'r'] | Noneintz
str | Nonezbool | Noneboolz
int | Nonezlist[str] | str | None)valuelanguager   r   r   r   r   r   r   r   r   r   c       
         K  sR   |t jv sJ d| d|| _|| _tj| f||||||	|
|||d
| dS )a  
        Parameters:
            value: Default value to show in the code editor. If callable, the function will be called whenever the app loads to set the initial value of the component.
            language: The language to display the code as. Supported languages listed in `gr.Code.languages`.
            label: component name in interface.
            interactive: Whether user should be able to enter code or only view it.
            show_label: if True, will display label.
            container: If True, will place the component in a container - providing some extra padding around the border.
            scale: relative width compared to adjacent Components in a Row. For example, if Component A has scale=2, and Component B has scale=1, A will be twice as wide as B. Should be an integer.
            min_width: minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.
            visible: If False, component will be hidden.
            elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
            elem_classes: An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.
        z	Language z not supported.)
r   r   r   r   r   r   r   r   r   r!   N)r   	languagesr"   r   r   __init__)selfr!   r"   r   r   r   r   r   r   r   r   r   r   kwargs r'   _/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/gradio/components/code.pyr$   '   s&    ,zCode.__init__c                 C  s   | j | j| jdt| S )N)r!   r"   r   )r!   r"   r   r   
get_config)r%   r'   r'   r(   r)   e   s    zCode.get_configc                 C  sX   |d u rd S t |trLt|d }| W  d    S 1 s@0    Y  n| S d S )Nr   )
isinstancetupleopenreadstrip)r%   yZ	file_datar'   r'   r(   postprocessm   s    
(zCode.postprocessz5str | tuple[str] | None | Literal[_Keywords.NO_VALUE]	r!   r   r   r   r   r   r   r"   r   c	           	      C  s   ||||||| ||dd
S )Nupdate)
r   r   r   r   r   r   r!   r"   r   Z__type__r'   r1   r'   r'   r(   r2   v   s    zCode.update)NN)__name__
__module____qualname____doc__r#   r$   r)   r0   staticmethodr   ZNO_VALUEr2   r'   r'   r'   r(   r      s:     (>	r   N)r6   
__future__r   typingr   Zgradio_client.documentationr   r   Zgradio_client.serializingr   Zgradio.components.baser   r   Zgradio.eventsr	   r
   r   r'   r'   r'   r(   <module>   s   