
    -e!                       d Z ddlmZ ddlZ ej        e          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mZ dd
lmZ ddlmZ er&ddlm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  dZ!dddefd-d#Z"d$Z#d.d+Z$	 d/d0d,Z%dS )1z

    )annotationsN)TYPE_CHECKINGAny   )	UIElement)	NEW_PARAMget_browser_controller   )DEFAULT_JUPYTER_URLProxyUrlFuncrun_notebook_hook)save)curstate)	TypeGuard)Application)	ModifyDoc)BrowserLikeBrowserTarget)CommsHandle)State)showtabFobj#UIElement | Application | ModifyDocbrowser
str | Nonenewr   notebook_handleboolnotebook_urlstr | ProxyUrlFunckwargsr   returnCommsHandle | Nonec                   t                      }t          | t                    rt          | ||||          S d	d} ||           st	          |           r|j        J t          |j        d| ||fi |S t          t                    )
a  Immediately display a Bokeh object or application.

    :func:`show` may be called multiple times in a single Jupyter notebook
    cell to display multiple objects. The objects are displayed in order.

    Args:
        obj (UIElement or Application or callable) :
            A Bokeh object to display.

            Bokeh plots, widgets, layouts (i.e. rows and columns) may be
            passed to ``show`` in order to display them. If |output_file|
            has been called, the output will be saved to an HTML file, which is also
            opened in a new browser window or tab. If |output_notebook|
            has been called in a Jupyter notebook, the output will be inline
            in the associated notebook output cell.

            In a Jupyter notebook, a Bokeh application or callable may also
            be passed. A callable will be turned into an Application using a
            ``FunctionHandler``. The application will be run and displayed
            inline in the associated notebook output cell.

        browser (str, optional) :
            Specify the browser to use to open output files(default: None)

            For file output, the **browser** argument allows for specifying
            which browser to display in, e.g. "safari", "firefox", "opera",
            "windows-default". Not all platforms may support this option, see
            the documentation for the standard library
            :doc:`webbrowser <python:library/webbrowser>` module for
            more information

        new (str, optional) :
            Specify the browser mode to use for output files (default: "tab")

            For file output, opens or raises the browser window showing the
            current output file.  If **new** is 'tab', then opens a new tab.
            If **new** is 'window', then opens a new window.

        notebook_handle (bool, optional) :
            Whether to create a notebook interaction handle (default: False)

            For notebook output, toggles whether a handle which can be used
            with ``push_notebook`` is returned. Note that notebook handles
            only apply to standalone plots, layouts, etc. They do not apply
            when showing Applications in the notebook.

        notebook_url (URL, optional) :
            Location of the Jupyter notebook page (default: "localhost:8888")

            When showing Bokeh applications, the Bokeh server must be
            explicitly configured to allow connections originating from
            different URLs. This parameter defaults to the standard notebook
            host and port. If you are running on a different location, you
            will need to supply this value for the application to display
            properly. If no protocol is supplied in the URL, e.g. if it is
            of the form "localhost:8888", then "http" will be used.

            ``notebook_url`` can also be a function that takes one int for the
            bound server port.  If the port is provided, the function needs
            to generate the full public URL to the bokeh server.  If None
            is passed, the function is to generate the origin URL.

            If the environment variable JUPYTER_BOKEH_EXTERNAL_URL is set
            to the external URL of a JupyterHub, notebook_url is overridden
            with a callable which enables Bokeh to traverse the JupyterHub
            proxy without specifying this parameter.

    Some parameters are only useful when certain output modes are active:

    * The ``browser`` and ``new`` parameters only apply when |output_file|
      is active.

    * The ``notebook_handle`` parameter only applies when |output_notebook|
      is active, and non-Application objects are being shown. It is only
      supported in Jupyter notebook and raises an exception for other notebook
      types when it is True.

    * The ``notebook_url`` parameter only applies when showing Bokeh
      Applications in a Jupyter notebook.

    * Any additional keyword arguments are passed to :class:`~bokeh.server.Server` when
      showing a Bokeh app (added in version 1.1)

    Returns:
        When in a Jupyter notebook (with |output_notebook| enabled)
        and ``notebook_handle=True``, returns a handle that can be used by
        ``push_notebook``, None otherwise.

    )r   r   r   r#   TypeGuard[Application]c                $    t          | dd          S )N_is_a_bokeh_application_classF)getattr)r   s    0lib/python3.11/site-packages/bokeh/io/showing.pyis_applicationzshow.<locals>.is_application   s    s;UCCC    Napp)r   r   r#   r&   )	r   
isinstancer   _show_with_statecallablenotebook_typer   
ValueError_BAD_SHOW_MSG)r   r   r   r   r    r"   stater+   s           r*   r   r   6   s    x JJE#y!! [UGS/ZZZZD D D D ~c ahsmm a "... !4eS%``Y_```
]
#
##r,   zInvalid object to show. The object to passed to show must be one of:

* a UIElement (e.g. a plot, figure, widget or layout)
* a Bokeh Application
* a callable suitable to an application FunctionHandler
r   r4   r   
controllerr   Nonec                r    t          | |          }|                    d|z   t          |                    dS )

    )r4   zfile://)r   N)r   openr   )r   r4   r   r5   filenames        r*   _show_file_with_stater;      s;     Cu%%%HOOI(inO=====r,   c                    t          |          }d}d}|j        r#|j        J t          |j        d| ||          }d}|j        s|st          | |||           |S )r8   )r   NFdocT)r	   notebookr1   r   filer;   )r   r4   r   r   r   r5   comms_handleshowns           r*   r/   r/      s    
 (888JLE~ "...()<eS%Q`aaz ; ;c5#z:::r,   )r   r   r   r   r   r   r   r   r    r!   r"   r   r#   r$   )
r   r   r4   r   r   r   r5   r   r#   r6   )F)r   r   r4   r   r   r   r   r   r   r   r#   r$   )&__doc__
__future__r   logging	getLogger__name__logtypingr   r   	models.uir   util.browserr   r	   r>   r   r   r   savingr   r4   r   typing_extensionsr   application.applicationr   application.handlers.functionr   r   r   r   r   __all__r   r3   r;   r/    r,   r*   <module>rQ      s    # " " " " " g!! & % % % % % % % " ! ! ! ! ! < < < < < < < < J J J J J J J J J J             ++++++55555599999999999999%%%%%% JNdi!&K^j$ j$ j$ j$ j$h> > > > 5:      r,   