
    -ec                        U d Z ddlmZ ddlZ ej        e          ZddlZddlm	Z	 ddl
mZmZmZ ddlmZ ed         Zed	         Zdd
ddZded<   dZ G d de          Z G d d          Zd d!dZd"d#dZdS )$zD Utility functions for helping with operations involving browsers.

    )annotationsN)abspath)LiteralProtocolcast   )settings)samewindowtab)r      r   r   zdict[BrowserTarget, TargetCode]	NEW_PARAM)DummyWebBrowserget_browser_controllerviewc                      e Zd ZdZddd
ZdS )BrowserLikez* Interface for browser-like objects.

    .urlstrnew
TargetCode	autoraiseboolreturnc                    d S N selfr   r   r   s       2lib/python3.11/site-packages/bokeh/util/browser.pyopenzBrowserLike.open6   s        N)..r   r   r   r   r   r   r   r   __name__
__module____qualname____doc__r!   r   r"   r    r   r   2   s7               r"   r   c                      e Zd ZdZdddZdS )r   z( A "no-op" web-browser controller.

    r   Tr   r   r   r   r   r   r   c                    dS )z0 Receive standard arguments and take no action. Tr   r   s       r    r!   zDummyWebBrowser.open=   s    tr"   N)r   Tr#   r$   r   r"   r    r   r   9   s7               r"   r   browser
str | Noner   c                    t          j        |           } | t          t          t                    }n)| dk    rt                      }nt	          j        |           }|S )a   Return a browser controller.

    Args:
        browser (str or None) : browser name, or ``None`` (default: ``None``)
            If passed the string ``'none'``, a dummy web browser controller
            is returned.

            Otherwise, use the value to select an appropriate controller using
            the :doc:`webbrowser <python:library/webbrowser>` standard library
            module. If the value is ``None``, a system default is used.

    Returns:
        controller : a web browser controller

    Nnone)r	   r+   r   r   
webbrowserr   get)r+   
controllers     r    r   r   A   sW      w''G+z22

	F		$&&

^G,,
r"   r
   Tlocationr   r   BrowserTargetr   r   Nonec                ,   	 t           |         }n!# t          $ r t          d|d          w xY w|                     d          r| }ndt	          |           z   }	 t          |          }|                    |||           dS # t          $ r Y dS w xY w)a   Open a browser to view the specified location.

    Args:
        location (str) : Location to open
            If location does not begin with "http:" it is assumed
            to be a file path on the local filesystem.
        browser (str or None) : what browser to use (default: None)
            If ``None``, use the system default browser.
        new (str) : How to open the location. Valid values are:

            ``'same'`` - open in the current tab

            ``'tab'`` - open a new tab in the current window

            ``'window'`` - open in a new window
        autoraise (bool) : Whether to automatically raise the location
            in a new browser window (default: True)

    Returns:
        None

    z$invalid 'new' value passed to view: z., valid values are: 'same', 'window', or 'tab'httpzfile://)r   r   N)r   KeyErrorRuntimeError
startswithr   r   r!   	Exception)r2   r+   r   r   new_idr   r1   s          r    r   r   \   s    .y3 y y yw#wwwxxxy 6"" ,'(++++G44
9=====   s    .'B 
BBr   )r+   r,   r   r   )Nr
   T)
r2   r   r+   r,   r   r3   r   r   r   r4   )r(   
__future__r   logging	getLoggerr%   logr/   os.pathr   typingr   r   r   r	   r3   r   r   __annotations____all__r   r   r   r   r   r"   r    <module>rD      s\     # " " " " " g!!           * * * * * * * * * *        /0W
671Q-O-O	 O O O O    (              6% % % % % % %r"   