a
    @DfE                     @  s  U d Z ddlmZ ddlZeeZddlmZm	Z	m
Z
mZmZmZmZmZ ddlmZ ddlmZmZmZmZ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! ddl"m#Z#m$Z$ ddl%m&Z&m'Z' ddl(m)Z)m*Z*m+Z+m,Z,m-Z- ddl.m/Z/ er*ddl0m1Z1 ddl2m3Z3 ddl4m5Z5 ddlm6Z6 dZ7eeef Z8de9d< eee8 e:e;e8f f Z<de9d< ede!e=e) f Z>de9d< ddddddd Z?edQd"d#d$ddd%d&d'Z@edRd"d#d(dd)d%d*d'Z@edSd+d#d$dd,d%d-d'Z@edTd+d#d(dd.d%d/d'Z@edUd0d#d$dd1d%d2d'Z@edVd0d#d(dd3d%d4d'Z@dWd6d#d#dd7d%d8d'Z@dXei dd9d9d:d;d<d=d>d?dd#d#dd@	dAdBZAG dCdD dDeZBdYd"dEddDdFdGdHZCdIddJdKdLZDdMd=ddNdOdPZEdS )Zz

    )annotationsN)TYPE_CHECKINGAnyLiteralSequence	TypedDictUnioncastoverload   )__version__)AUTOLOAD_JSAUTOLOAD_TAGFILEMACROSROOT_DIV)DEFAULT_TITLEDocument)Model)	ResourcesResourcesLike)Theme   )Scriptbundle_for_objs_and_resources)html_page_for_render_itemsscript_for_render_items)
FromCurdocOutputDocumentFor
RenderRootstandalone_docs_json%standalone_docs_json_and_render_items)wrap_in_onload)Template)	TypeAlias)ID)DocJson)autoload_static
components	file_html	json_itemr$   	ModelLikeModelLikeCollection	ThemeLikezModel | Documentr   strztuple[str, str])model	resourcesscript_pathreturnc                 C  s   t | tr| g}nt | tr$| j}ntdt|  t| g\}\}W d   n1 sZ0    Y  td|}|t	t
||g tt|j  \}}ttj||d}	tj||d}
|	|
fS )a   Return JavaScript code and a script tag that can be used to embed
    Bokeh Plots.

    The data for the plot is stored directly in the returned JavaScript code.

    Args:
        model (Model or Document) :

        resources (Resources) :

        script_path (str) :

    Returns:
        (js, tag) :
            JavaScript code to be saved at ``script_path`` and a ``<script>``
            tag to load it

    Raises:
        ValueError

    z2autoload_static expects a single Model or DocumentN)bundle	elementid)Zsrc_pathr4   )
isinstancer   r   roots
ValueErrorr   r!   r   addr   r   nextiterto_jsonitemsr"   r   renderr   )r/   r0   r1   models	docs_jsonrender_itemr3   _r4   Zjstag rC   c/nfs/NAS7/SABIOD/METHODE/ermites/ermites_venv/lib/python3.9/site-packages/bokeh/embed/standalone.pyr'   V   s     


.
r'   .r   boolzLiteral[True])r>   wrap_scriptwrap_plot_infothemer2   c                 C  s   d S NrC   r>   rF   rG   rH   rC   rC   rD   r(      s    r(   zLiteral[False]ztuple[str, RenderRoot]c                 C  s   d S rI   rC   rJ   rC   rC   rD   r(      s    zSequence[Model]ztuple[str, Sequence[str]]c                 C  s   d S rI   rC   rJ   rC   rC   rD   r(      s    z tuple[str, Sequence[RenderRoot]]c                 C  s   d S rI   rC   rJ   rC   rC   rD   r(      s    zdict[str, Model]ztuple[str, dict[str, str]]c                 C  s   d S rI   rC   rJ   rC   rC   rD   r(      s    z!tuple[str, dict[str, RenderRoot]]c                 C  s   d S rI   rC   rJ   rC   rC   rD   r(      s    Tz*Model | Sequence[Model] | dict[str, Model]ztuple[str, Any]c                   s  d}t | trd}| g} t| } d}t}t | trL| j}|  }t|  } t| |d t	| \}\}W d   n1 s|0    Y  t
dd}	|	tt||g |	j|d}
dddd	d
 |r܇ fdd|jD }n
t|j}|r|d }n"|dur|t||}nt|}|
|fS )aN   Return HTML components to embed a Bokeh plot. The data for the plot is
    stored directly in the returned HTML.

    An example can be found in examples/embed/embed_multiple.py

    The returned components assume that BokehJS resources are **already loaded**.
    The HTML document or template in which they will be embedded needs to
    include scripts tags, either from a local URL or Bokeh's CDN (replacing
    ``x.y.z`` with the version of Bokeh you are using):

    .. code-block:: html

        <script src="https://cdn.bokeh.org/bokeh/release/bokeh-x.y.z.min.js"></script>
        <script src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-x.y.z.min.js"></script>
        <script src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-x.y.z.min.js"></script>
        <script src="https://cdn.bokeh.org/bokeh/release/bokeh-gl-x.y.z.min.js"></script>
        <script src="https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-x.y.z.min.js"></script>

    Only the Bokeh core library ``bokeh-x.y.z.min.js`` is always required. The
    other scripts are optional and only need to be included if you want to use
    corresponding features:

    * The ``"bokeh-widgets"`` files are only necessary if you are using any of the
      :ref:`Bokeh widgets <ug_interaction_widgets>`.
    * The ``"bokeh-tables"`` files are only necessary if you are using Bokeh's
      :ref:`data tables <ug_interaction_widgets_examples_datatable>`.
    * The ``"bokeh-api"`` files are required to use the
      :ref:`BokehJS API <ug_advanced_bokehjs>` and must be loaded *after* the
      core BokehJS library.
    * The ``"bokeh-gl"`` files are required to enable
      :ref:`WebGL support <ug_output_webgl>`.
    * the ``"bokeh-mathjax"`` files are required to enable
      :ref:`MathJax support <ug_styling_mathtext>`.

    Args:
        models (Model|list|dict|tuple) :
            A single Model, a list/tuple of Models, or a dictionary of keys
            and Models.

        wrap_script (boolean, optional) :
            If True, the returned javascript is wrapped in a script tag.
            (default: True)

        wrap_plot_info (boolean, optional) :
            If True, returns ``<div>`` strings. Otherwise, return
            :class:`~bokeh.embed.RenderRoot` objects that can be used to build
            your own divs. (default: True)

        theme (Theme, optional) :
            Applies the specified theme when creating the components. If None,
            or not specified, and the supplied models constitute the full set
            of roots of a document, applies the theme of that document to the
            components. Otherwise applies the default theme.

    Returns:
        UTF-8 encoded *(script, div[s])* or *(raw_script, plot_info[s])*

    Examples:

        With default wrapping parameter values:

        .. code-block:: python

            components(plot)
            # => (script, plot_div)

            components((plot1, plot2))
            # => (script, (plot1_div, plot2_div))

            components({"Plot 1": plot1, "Plot 2": plot2})
            # => (script, {"Plot 1": plot1_div, "Plot 2": plot2_div})

    Examples:

        With wrapping parameters set to ``False``:

        .. code-block:: python

            components(plot, wrap_script=False, wrap_plot_info=False)
            # => (javascript, plot_root)

            components((plot1, plot2), wrap_script=False, wrap_plot_info=False)
            # => (javascript, (plot1_root, plot2_root))

            components({"Plot 1": plot1, "Plot 2": plot2}, wrap_script=False, wrap_plot_info=False)
            # => (javascript, {"Plot 1": plot1_root, "Plot 2": plot2_root})

    FTNapply_theme)rB   r   r.   )rootr2   c                 S  s   t j| tdS )N)rM   macros)r   r=   r   )rM   rC   rC   rD   div_for_root  s    z components.<locals>.div_for_rootc                   s   g | ]} |qS rC   rC   ).0rM   rO   rC   rD   
<listcomp>      zcomponents.<locals>.<listcomp>r   )r5   r   _check_models_or_docsdict	__class__keyslistvaluesr   r!   r   r8   r   r   scriptsr6   ziptuple)r>   rF   rG   rH   Zwas_single_objectZ
model_keys	dict_typer?   r@   r3   scriptresultsresultrC   rQ   rD   r(      s4    \

,



F)templatetemplate_variablesrH   suppress_callback_warning_always_newz"Model | Document | Sequence[Model]zResourcesLike | Nonez
str | NonezTemplate | strzdict[str, Any])	r>   r0   titlera   rb   rH   rc   rd   r2   c             	   C  s   g }t | tr| g}n,t | tr>t| jdkr6td| j}n| }t|}t|||dJ}	t	||d\}
}t
||}t|	g|}t||
||||dW  d   S 1 s0    Y  dS )a*   Return an HTML document that embeds Bokeh Model or Document objects.

    The data for the plot is stored directly in the returned HTML, with
    support for customizing the JS/CSS resources independently and
    customizing the jinja2 template.

    Args:
        models (Model or Document or seq[Model]) : Bokeh object or objects to render
            typically a Model or Document

        resources (ResourcesLike) :
            A resources configuration for Bokeh JS & CSS assets.

        title (str, optional) :
            A title for the HTML document ``<title>`` tags or None. (default: None)

            If None, attempt to automatically find the Document title from the given
            plot objects.

        template (Template, optional) : HTML document template (default: FILE)
            A Jinja2 Template, see bokeh.core.templates.FILE for the required
            template parameters

        template_variables (dict, optional) : variables to be used in the Jinja2
            template. If used, the following variable names will be overwritten:
            title, bokeh_js, bokeh_css, plot_script, plot_div

        theme (Theme, optional) :
            Applies the specified theme to the created html. If ``None``, or
            not specified, and the function is passed a document or the full set
            of roots of a document, applies the theme of that document.  Otherwise
            applies the default theme.

        suppress_callback_warning (bool, optional) :
            Normally generating standalone HTML from a Bokeh Document that has
            Python callbacks will result in a warning stating that the callbacks
            cannot function. However, this warning can be suppressed by setting
            this value to True (default: False)

    Returns:
        UTF-8 encoded HTML

    r   zDocument has no root Models)rL   Z
always_new)rc   )re   ra   rb   N)r5   r   r   lenr6   r7   r   buildr   r!   _title_from_modelsr   r   )r>   r0   re   ra   rb   rH   rc   rd   Z
models_seqdocr?   Zrender_itemsr3   rC   rC   rD   r)   &  s     4




r)   c                   @  s.   e Zd ZU ded< ded< ded< ded< d	S )
StandaloneEmbedJson	ID | None	target_idr%   root_idr&   ri   r.   versionN)__name__
__module____qualname____annotations__rC   rC   rC   rD   rj   m  s   
rj   rk   )r/   targetrH   r2   c                 C  sd   t | g|d&}d|_t| g \}W d   n1 s:0    Y  |d d d }t|||tdS )a   Return a JSON block that can be used to embed standalone Bokeh content.

    Args:
        model (Model) :
            The Bokeh object to embed

        target (string, optional)
            A div id to embed the model into. If None, the target id must
            be supplied in the JavaScript call.

        theme (Theme, optional) :
            Applies the specified theme to the created html. If ``None``, or
            not specified, and the function is passed a document or the full set
            of roots of a document, applies the theme of that document.  Otherwise
            applies the default theme.

    Returns:
        JSON-like

    This function returns a JSON block that can be consumed by the BokehJS
    function ``Bokeh.embed.embed_item``. As an example, a Flask endpoint for
    ``/plot`` might return the following content to embed a Bokeh plot into
    a div with id *"myplot"*:

    .. code-block:: python

        @app.route('/plot')
        def plot():
            p = make_plot('petal_width', 'petal_length')
            return json.dumps(json_item(p, "myplot"))

    Then a web page can retrieve this JSON and embed the plot by calling
    ``Bokeh.embed.embed_item``:

    .. code-block:: html

        <script>
        fetch('/plot')
            .then(function(response) { return response.json(); })
            .then(function(item) { Bokeh.embed.embed_item(item); })
        </script>

    Alternatively, if is more convenient to supply the target div id directly
    in the page source, that is also possible. If `target_id` is omitted in the
    call to this function:

    .. code-block:: python

        return json.dumps(json_item(p))

    Then the value passed to ``embed_item`` is used:

    .. code-block:: javascript

        Bokeh.embed.embed_item(item, "myplot");

    rK    Nr6   r   id)rl   rm   ri   rn   )r   re   r    rY   rj   r   )r/   rs   rH   ri   Zdoc_jsonrm   rC   rC   rD   r*   s  s    :.r*   zModelLike | ModelLikeCollection)r>   r2   c                 C  s   d}t | ttfr| g} t | tr8tdd | D r8d}t | trrtdd |  D rrtdd |  D rrd}|s~td| S )z

    Fc                 s  s   | ]}t |ttfV  qd S rI   r5   r   r   rP   xrC   rC   rD   	<genexpr>  rS   z(_check_models_or_docs.<locals>.<genexpr>Tc                 s  s   | ]}t |tV  qd S rI   )r5   r.   rw   rC   rC   rD   ry     rS   c                 s  s   | ]}t |ttfV  qd S rI   rv   rw   rC   rC   rD   ry     rS   zwInput must be a Model, a Document, a Sequence of Models and Document, or a dictionary from string to Model and Document)	r5   r   r   r   allrU   rW   rY   r7   )r>   Zinput_type_validrC   rC   rD   rT     s     
rT   zSequence[Model | Document])r>   re   r2   c                 C  sX   |d ur|S | D ]}t |tr|j  S qttt | D ]}|jd ur8|jj  S q8tS rI   )r5   r   re   r	   r   r   documentr   )r>   re   prC   rC   rD   rh     s    

rh   )...)...)...)...)...)...)TTN)NN)NN)F__doc__
__future__r   logging	getLoggerro   logtypingr   r   r   r   r   r   r	   r
   rt   r   Zcore.templatesr   r   r   r   r   Zdocument.documentr   r   r/   r   r0   r   r   Zthemesr   r3   r   r   elementsr   r   utilr   r   r   r    r!   wrappersr"   Zjinja2r#   Ztyping_extensionsr$   Z
core.typesr%   r&   __all__r+   rr   rU   r.   r,   typer-   r'   r(   r)   rj   r*   rT   rh   rC   rC   rC   rD   <module>   s   
( 2                 "GO