
    AF[i$                        d Z ddlmZ ddlmZmZ ddlmZmZ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
lmZ erddlmZ  e        G d de             Zy)zgr.HTML() component.    )annotations)CallableSequence)TYPE_CHECKINGAnyLiteral)document)	Component)Button)
all_events)I18nData)set_default_buttons)Timerc                       e Zd ZdZeZ	 dddddddddddddddddddddd		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d fd
ZddZddZddZ	ddZ
ddZd fdZd Z xZS )HTMLa&  
    Creates a component with arbitrary HTML. Can include CSS and JavaScript to create highly customized and interactive components.
    Example:
        ```python
        import gradio as gr

        with gr.Blocks() as demo:
            basic_html = gr.HTML("<h2>This is a basic HTML component</h2>")

            button_set = gr.HTML(["Option 1", "Option 2", "Option 3"],
                           html_template="{{#each value}}<button class='option-btn'>{{this}}</button>{{/each}}",
                           css_template="button { margin: 5px; padding: 10px; }",
                           js_on_load="element.querySelectorAll('.option-btn').forEach(btn => { btn.addEventListener('click', () => { trigger('click', {option: btn.innerText}); }); });")
            clicked_option = gr.Textbox(label="Clicked Option")
            def on_button_click(evt: gr.EventData):
                return evt.option
            button_set.click(on_button_click, outputs=clicked_option)

        demo.launch()
        ```
    Demos: super_html
    Guides: custom_HTML
    Nz${value} zCelement.addEventListener('click', function() { trigger('click') });TFvalue)labelhtml_templatecss_template
js_on_loadapply_default_csseveryinputs
show_labelvisibleelem_idelem_classesrenderkeypreserved_by_key
min_height
max_height	containerpadding
autoscrollbuttonsc                  || _         || _        || _        || _        || _        || _        || _        || _        || _        | j                  j                  | _        t        | 5  ||||	|
|||||||       t        |d      | _        y)a  
        Parameters:
            value: The HTML content in the ${value} tag in the html_template. For example, if html_template="<p>${value}</p>" and value="Hello, world!", the component will render as `"<p>Hello, world!</p>"`.
            label: The label for this component. Is used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.
            html_template: A string representing the HTML template for this component as a JS template string and Handlebars template. The `${value}` tag will be replaced with the `value` parameter, and all other tags will be filled in with the values from `props`.
            css_template: A string representing the CSS template for this component as a JS template string and Handlebars template. The CSS will be automatically scoped to this component. The `${value}` tag will be replaced with the `value` parameter, and all other tags will be filled in with the values from `props`.
            js_on_load: A string representing the JavaScript code that will be executed when the component is loaded. The `element` variable refers to the HTML element of this component, and can be used to access children such as `element.querySelector()`. The `trigger` function can be used to trigger events, such as `trigger('click')`. The value and other props can be edited through `props`, e.g. `props.value = "new value"` which will re-render the HTML template.
            apply_default_css: If True, default Gradio CSS styles will be applied to the HTML component.
            every: Continously calls `value` to recalculate it if `value` is a function (has no effect otherwise). Can provide a Timer whose tick resets `value`, or a float that provides the regular interval for the reset Timer.
            inputs: Components that are used as inputs to calculate `value` if `value` is a function (has no effect otherwise). `value` is recalculated any time the inputs change.
            show_label: If True, the label will be displayed. If False, the label will be hidden.
            visible: If False, component will be hidden. If "hidden", component will be visually hidden and not take up space in the layout but still exist in the DOM
            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.
            render: If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.
            key: in a gr.render, Components with the same key across re-renders are treated as the same component, not a new component. Properties set in 'preserved_by_key' are not reset across a re-render.
            preserved_by_key: A list of parameters from this component's constructor. Inside a gr.render() function, if a component is re-rendered with the same key, these (and only these) parameters will be preserved in the UI (if they have been changed by the user or an event listener) instead of re-rendered based on the values provided during constructor.
            min_height: The minimum height of the component, specified in pixels if a number is passed, or in CSS units if a string is passed. If HTML content exceeds the height, the component will expand to fit the content.
            max_height: The maximum height of the component, specified in pixels if a number is passed, or in CSS units if a string is passed. If content exceeds the height, the component will scroll.
            container: If True, the HTML component will be displayed in a container. Default is False.
            padding: If True, the HTML component will have a certain padding (set by the `--block-padding` CSS variable) in all directions. Default is False.
            autoscroll: If True, will automatically scroll to the bottom of the component when the content changes, unless the user has scrolled up. If False, will not scroll to the bottom when the content changes.
            buttons: A list of gr.Button() instances to show in the top right corner of the component. Custom buttons will appear in the toolbar with their configured icon and/or label, and clicking them will trigger any .click() events registered on the button.
            props: Additional keyword arguments to pass into the HTML and CSS templates for rendering.
        )r   r   r   r   r   r   r   r   r    r!   r   r$   N)r   r   r   r   r"   r#   r%   r&   props	__class____name__component_class_namesuper__init__r   r'   )selfr   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r)   r*   s                          _/var/www/html/chatbot/moweb-chatbot/venv/lib/python3.12/site-packages/gradio/components/html.pyr.   zHTML.__init__0   s    h +($!2$$$
$(NN$;$;!!%- 	 	
 +7D9    c                     yNz<p>Hello</p> r/   s    r0   example_payloadzHTML.example_payload       r1   c                     yr3   r4   r5   s    r0   example_valuezHTML.example_value   r7   r1   c                    |S )z
        Parameters:
            payload: string corresponding to the HTML
        Returns:
            (Rarely used) passes the HTML as a `str`.
        r4   )r/   payloads     r0   
preprocesszHTML.preprocess   s	     r1   c                    |S )z
        Parameters:
            value: Expects a `str` consisting of valid HTML.
        Returns:
            Returns the HTML string.
        r4   )r/   r   s     r0   postprocesszHTML.postprocess   s	     r1   c                
    ddiS )Ntypestringr4   r5   s    r0   api_infozHTML.api_info   s    !!r1   c                    t        |       t        ur$i t        |          t        |   t              }nt        |          }| j                  |d<   |S )Nr,   )r@   r   r-   
get_configr,   )r/   configr*   s     r0   rD   zHTML.get_config   s_    :T!'$&'$T*F
 W')F *.)B)B%&r1   c                     y)Nhtmlr4   r5   s    r0   get_block_namezHTML.get_block_name   s    r1   )N),r   zAny | Callable | Noner   zstr | I18nData | Noner   strr   rI   r   
str | Noner   boolr   zTimer | float | Noner   z7Component | Sequence[Component] | set[Component] | Noner   rK   r   zbool | Literal['hidden']r   rJ   r   list[str] | str | Noner   rK   r    z(int | str | tuple[int | str, ...] | Noner!   rL   r"   
int | Noner#   rM   r$   rK   r%   rK   r&   rK   r'   zlist[Button] | Noner)   r   )returnr   )r;   rJ   rN   rJ   )r   rJ   rN   rJ   )rN   zdict[str, Any])r+   
__module____qualname____doc__r   EVENTSr.   r6   r9   r<   r>   rB   rD   rH   __classcell__)r*   s   @r0   r   r      ss   0 F (,M: (,'V"&&*JN ,0"/38<3:!%!% '+1M:$M: %	M:
 M: M:M:  M: $M: HM: M: *M: M: -M:  !M:" 6#M:$ 1%M:& 'M:( )M:* +M:, -M:. /M:0 %1M:2 3M:^"r1   r   N)rQ   
__future__r   collections.abcr   r   typingr   r   r   gradio_client.documentationr	   gradio.components.baser
   gradio.components.buttonr   gradio.eventsr   gradio.i18nr   gradio.utilsr   gradio.componentsr   r   r4   r1   r0   <module>r^      sL     " . . . 0 , + $   ,' 
S9 S Sr1   