o
    e@                     @  sR  d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	 dd Z
G dd	 d	ejZG d
d dejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZG d d! d!ejZG d"d# d#ejZG d$d% d%ejZd&S )'aM  
This module defines various classes that can serve as the `input` to an interface. Each class must inherit from
`InputComponent`, and each class must define a path to its template. All of the subclasses of `InputComponent` are
automatically added to a registry, which allows them to be easily referenced in other parts of the code.
    )annotations)AnyOptional)
componentswarn_deprecationc                   C  s   t d d S )NzUsage of gradio.inputs is deprecated, and will not be supported in the future, please import your component from gradio.componentsr    r   r   =D:\Projects\ConvertPro\env\Lib\site-packages\gradio/inputs.pywarn_inputs_deprecation   s   r
   c                      s.   e Zd Z							dd fddZ  ZS )Textbox   N FtextlinesintplaceholderOptional[str]defaultstrnumericOptional[bool]typelabeloptionalboolc              	     s$   t   t j|||||||d d S )N)valuer   r   r   r   r   r   r
   super__init__)selfr   r   r   r   r   r   r   	__class__r   r	   r      s   

zTextbox.__init__)r   Nr   Fr   NF)r   r   r   r   r   r   r   r   r   r   r   r   r   r   )__name__
__module____qualname__r   __classcell__r   r   r    r	   r      s    r   c                      s*   e Zd ZdZ			dd fd
dZ  ZS )Numberz
    Component creates a field for user to enter numeric input. Provides a number as an argument to the wrapped function.
    Input type: float
    NFr   Optional[float]r   r   r   r   c                      t   t j|||d dS )z
        Parameters:
        default (float): default value.
        label (str): component name in interface.
        optional (bool): If True, the interface can be submitted with no value for this component.
        r   r   r   Nr   r   r   r   r   r    r   r	   r   3      zNumber.__init__)NNF)r   r'   r   r   r   r   r"   r#   r$   __doc__r   r%   r   r   r    r	   r&   -       r&   c                      s0   e Zd ZdZ						dd fddZ  ZS )Sliderz
    Component creates a slider that ranges from `minimum` to `maximum`. Provides number as an argument to the wrapped function.
    Input type: float
    r   d   NFminimumfloatmaximumstepr'   r   r   r   r   r   c                   s"   t   t j||||||d dS )aH  
        Parameters:
        minimum (float): minimum value for slider.
        maximum (float): maximum value for slider.
        step (float): increment between slider values.
        default (float): default value.
        label (str): component name in interface.
        optional (bool): this parameter is ignored.
        )r   r1   r3   r4   r   r   Nr   )r   r1   r3   r4   r   r   r   r    r   r	   r   I   s   
zSlider.__init__)r   r0   NNNF)r1   r2   r3   r2   r4   r'   r   r'   r   r   r   r   r,   r   r   r    r	   r/   C   s    r/   c                      s*   e Zd ZdZ			dd fd	d
Z  ZS )Checkboxz
    Component creates a checkbox that can be set to `True` or `False`. Provides a boolean as an argument to the wrapped function.
    Input type: bool
    FNr   r   r   r   r   c                   r(   )z
        Parameters:
        label (str): component name in interface.
        default (bool): if True, checked by default.
        optional (bool): this parameter is ignored.
        r)   Nr   r*   r    r   r	   r   m   r+   zCheckbox.__init__)FNF)r   r   r   r   r   r   r,   r   r   r    r	   r5   g   r.   r5   c                      s,   e Zd ZdZ				dd fddZ  ZS )CheckboxGroupz
    Component creates a set of checkboxes of which a subset can be selected. Provides a list of strings representing the selected choices as an argument to the wrapped function.
    Input type: Union[List[str], List[int]]
    Nr   Fchoices	list[str]r   list[str] | Noner   r   r   r   r   r   c                   s,   |du rg }t   t j|||||d dS )a  
        Parameters:
        choices (List[str]): list of options to select from.
        default (List[str]): default selected list of options.
        type (str): Type of value to be returned by component. "value" returns the list of strings of the choices selected, "index" returns the list of indices of the choices selected.
        label (str): component name in interface.
        optional (bool): this parameter is ignored.
        N)r   r7   r   r   r   r   )r   r7   r   r   r   r   r    r   r	   r      s   
zCheckboxGroup.__init__)Nr   NF)
r7   r8   r   r9   r   r   r   r   r   r   r,   r   r   r    r	   r6   }       r6   c                      ,   e Zd ZdZ				dd fddZ  ZS )Radioz
    Component creates a set of radio buttons of which only one can be selected. Provides string representing selected choice as an argument to the wrapped function.
    Input type: Union[str, int]
    r   NFr7   r8   r   r   r   r   r   r   r   c                       t   t j|||||d dS )a  
        Parameters:
        choices (List[str]): list of options to select from.
        type (str): Type of value to be returned by component. "value" returns the string of the choice selected, "index" returns the index of the choice selected.
        default (str): the button selected by default. If None, no button is selected by default.
        label (str): component name in interface.
        optional (bool): this parameter is ignored.
        r7   r   r   r   r   Nr   r   r7   r   r   r   r   r    r   r	   r         
zRadio.__init__r   NNF
r7   r8   r   r   r   r   r   r   r   r   r,   r   r   r    r	   r<      r:   r<   c                      r;   )Dropdownz
    Component creates a dropdown of which only one can be selected. Provides string representing selected choice as an argument to the wrapped function.
    Input type: Union[str, int]
    r   NFr7   r8   r   r   r   r   r   r   r   c                   r=   )a  
        Parameters:
        choices (List[str]): list of options to select from.
        type (str): Type of value to be returned by component. "value" returns the string of the choice selected, "index" returns the index of the choice selected.
        default (str): default value selected in dropdown. If None, no value is selected by default.
        label (str): component name in interface.
        optional (bool): this parameter is ignored.
        r>   Nr   r?   r    r   r	   r      r@   zDropdown.__init__rA   rB   r,   r   r   r    r	   rC      r:   rC   c                      s4   e Zd ZdZ								dd fddZ  ZS )Imagez
    Component creates an image upload box with editing capabilities.
    Input type: Union[numpy.array, PIL.Image, file-object]
    NRGBFuploadeditornumpyshapetuple[int, int]
image_moder   invert_colorsr   sourcetoolr   r   r   c	           	   
     s&   t   t j||||||||d dS )a  
        Parameters:
        shape (Tuple[int, int]): (width, height) shape to crop and resize image to; if None, matches input image size.
        image_mode (str): How to process the uploaded image. Accepts any of the PIL image modes, e.g. "RGB" for color images, "RGBA" to include the transparency mask, "L" for black-and-white images.
        invert_colors (bool): whether to invert the image as a preprocessing step.
        source (str): Source of image. "upload" creates a box where user can drop an image file, "webcam" allows user to take snapshot from their webcam, "canvas" defaults to a white image that can be edited and drawn upon with tools.
        tool (str): Tools used for editing. "editor" allows a full screen editor, "select" provides a cropping and zoom tool.
        type (str): Type of value to be returned by component. "numpy" returns a numpy array with shape (height, width, 3) and values from 0 to 255, "pil" returns a PIL image object, "file" returns a temporary file object whose path can be retrieved by file_obj.name, "filepath" returns the path directly.
        label (str): component name in interface.
        optional (bool): If True, the interface can be submitted with no uploaded image, in which case the input value is None.
        )rI   rK   rL   rM   rN   r   r   r   Nr   )	r   rI   rK   rL   rM   rN   r   r   r   r    r   r	   r      s   
zImage.__init__)NrE   FrF   rG   rH   NF)rI   rJ   rK   r   rL   r   rM   r   rN   r   r   r   r   r   r   r   r,   r   r   r    r	   rD      s    rD   c                      s,   e Zd ZdZ				dd fddZ  ZS )Videozk
    Component creates a video file upload that is converted to a file path.

    Input type: filepath
    NrF   Fr   r   rM   r   r   r   r   c                      t   t j||||d dS )a  
        Parameters:
        type (str): Type of video format to be returned by component, such as 'avi' or 'mp4'. If set to None, video will keep uploaded format.
        source (str): Source of video. "upload" creates a box where user can drop an video file, "webcam" allows user to record a video from their webcam.
        label (str): component name in interface.
        optional (bool): If True, the interface can be submitted with no uploaded video, in which case the input value is None.
        )formatrM   r   r   Nr   )r   r   rM   r   r   r    r   r	   r        zVideo.__init__)NrF   NF)r   r   rM   r   r   r   r   r   r,   r   r   r    r	   rO     s    rO   c                      s,   e Zd ZdZ				dd fddZ  ZS )Audiozw
    Component accepts audio input files.
    Input type: Union[Tuple[int, numpy.array], file-object, numpy.array]
    rF   rH   NFrM   r   r   r   r   r   c                   rP   )a}  
        Parameters:
        source (str): Source of audio. "upload" creates a box where user can drop an audio file, "microphone" creates a microphone input.
        type (str): Type of value to be returned by component. "numpy" returns a 2-set tuple with an integer sample_rate and the data numpy.array of shape (samples, 2), "file" returns a temporary file object whose path can be retrieved by file_obj.name, "filepath" returns the path directly.
        label (str): component name in interface.
        optional (bool): If True, the interface can be submitted with no uploaded audio, in which case the input value is None.
        )rM   r   r   r   Nr   )r   rM   r   r   r   r    r   r	   r   '  rR   zAudio.__init__)rF   rH   NF)rM   r   r   r   r   r   r   r   r,   r   r   r    r	   rS   !      rS   c                      s.   e Zd ZdZ					dd fddZ  ZS )Filez|
    Component accepts generic file uploads.
    Input type: Union[file-object, bytes, List[Union[file-object, bytes]]]
    singlefileNTF
file_countr   r   r   r   keep_filenamer   r   c                   r=   )a  
        Parameters:
        file_count (str): if single, allows user to upload one file. If "multiple", user uploads multiple files. If "directory", user uploads all files in selected directory. Return type will be list for each file in case of "multiple" or "directory".
        type (str): Type of value to be returned by component. "file" returns a temporary file object whose path can be retrieved by file_obj.name, "binary" returns an bytes object.
        label (str): component name in interface.
        keep_filename (bool): DEPRECATED. Original filename always kept.
        optional (bool): If True, the interface can be submitted with no uploaded image, in which case the input value is None.
        )rX   r   r   rY   r   Nr   )r   rX   r   r   rY   r   r    r   r	   r   ?  r@   zFile.__init__)rV   rW   NTF)
rX   r   r   r   r   r   rY   r   r   r   r,   r   r   r    r	   rU   9  s    rU   c                      s6   e Zd ZdZ									dd fddZ  ZS )	Dataframez
    Component accepts 2D input through a spreadsheet interface.
    Input type: Union[pandas.DataFrame, numpy.array, List[Union[str, float]], List[List[Union[str, float]]]]
    N   r   pandasFheadersOptional[list[str]]	row_countr   	col_countOptional[int]datatypestr | list[str]	col_widthint | list[int]r   Optional[list[list[Any]]]r   r   r   r   r   c
           
        s(   t   t j|||||||||	d	 dS )a  
        Parameters:
        headers (List[str]): Header names to dataframe. If None, no headers are shown.
        row_count (int): Limit number of rows for input.
        col_count (int): Limit number of columns for input. If equal to 1, return data will be one-dimensional. Ignored if `headers` is provided.
        datatype (Union[str, List[str]]): Datatype of values in sheet. Can be provided per column as a list of strings, or for the entire sheet as a single string. Valid datatypes are "str", "number", "bool", and "date".
        col_width (Union[int, List[int]]): Width of columns in pixels. Can be provided as single value or list of values per column.
        default (List[List[Any]]): Default value
        type (str): Type of value to be returned by component. "pandas" for pandas dataframe, "numpy" for numpy array, or "array" for a Python array.
        label (str): component name in interface.
        optional (bool): this parameter is ignored.
        )	r   r]   r_   r`   rb   rd   r   r   r   Nr   )
r   r]   r_   r`   rb   rd   r   r   r   r   r    r   r	   r   _  s   
zDataframe.__init__)	Nr[   r[   r   NNr\   NF)r]   r^   r_   r   r`   ra   rb   rc   rd   re   r   rf   r   r   r   r   r   r   r,   r   r   r    r	   rZ   Y  s    rZ   c                      s,   e Zd ZdZ				dd fddZ  ZS )
Timeserieszp
    Component accepts pandas.DataFrame uploaded as a timeseries csv file.
    Input type: pandas.DataFrame
    NFxr   yrc   r   r   r   c                   rP   )a  
        Parameters:
        x (str): Column name of x (time) series. None if csv has no headers, in which case first column is x series.
        y (Union[str, List[str]]): Column name of y series, or list of column names if multiple series. None if csv has no headers, in which case every column after first is a y series.
        label (str): component name in interface.
        optional (bool): If True, the interface can be submitted with no uploaded csv file, in which case the input value is None.
        )rh   ri   r   r   Nr   )r   rh   ri   r   r   r    r   r	   r     rR   zTimeseries.__init__)NNNF)rh   r   ri   rc   r   r   r   r   r,   r   r   r    r	   rg     rT   rg   c                      s(   e Zd ZdZ		d	d
 fddZ  ZS )Statezf
    Special hidden component that stores state across runs of the interface.
    Input type: Any
    Nr   r   r   r   c                   s   t   t j||d dS )z
        Parameters:
        label (str): component name in interface (not used).
        default (Any): the initial value of the state.
        optional (bool): this parameter is ignored.
        )r   r   Nr   )r   r   r   r    r   r	   r     s   zState.__init__)NN)r   r   r   r   r,   r   r   r    r	   rj     
    rj   c                      s(   e Zd ZdZ		d
d fdd	Z  ZS )Image3Dzc
    Used for 3D image model output.
    Input type: File object of type (.obj, glb, or .gltf)
    NFr   r   r   r   c                   s   t   t j||d dS )z
        Parameters:
        label (str): component name in interface.
        optional (bool): If True, the interface can be submitted with no uploaded image, in which case the input value is None.
        )r   r   Nr   )r   r   r   r    r   r	   r     s   
zImage3D.__init__)NF)r   r   r   r   r,   r   r   r    r	   rl     rk   rl   N)r-   
__future__r   typingr   r   Zgradior   Zgradio.deprecationr   r
   r   r&   r/   r5   r6   r<   rC   rD   rO   rS   rU   rZ   rg   rj   ZModel3Drl   r   r   r   r	   <module>   s*   $"  ) ,