
    ;g                       d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZ ddlmZ ddlmZmZmZ ddlmZ ddlZddlmZ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"d dD              xr ejF                   xr dejH                  vZ%ejL                  jO                  ejL                  jQ                  e)            Z*dZ+d Z, G d dejZ                        Z. G d de.      Z/ e0e/j(                  d      re/j(                  jc                         Z2ne/j(                  jg                         Z2 e4e2      e/_5         e/d i e2jm                         D  ci c]"  \  } }| dk7  r| |jn                  rdn e8e/|       $ c}} Z9dZ+ G d de      Z:d Z;d Z<e:j{                  e;        e0e:d      re:j}                  e<       ddgZ?yc c}} w )!z
The config module supplies the global config object and the extension
which provides convenient support for  loading and configuring panel
components.
    )annotationsN)ThreadPoolExecutor)contextmanager)TYPE_CHECKINGAnyClassVar)WeakKeyDictionary)JupyterCommManager	extension   __version__)panel_log_handlerstateDocumentc              #  ,   K   | ]  }|t         v   y wNr   ).0vs     ,lib/python3.12/site-packages/panel/config.py	<genexpr>r   #   s     4"3Q["3s   )postdirtyPANEL_DOC_BUILDTc                    | j                   ryd| _         t        | |      }	 t        | ||       	 t        | ||       d| _         y# t        $ r}|d}~ww xY w# t        | ||       d| _         w xY w)zC
    Validates parameter setting on a hidden config parameter.
    NTF)_validatinggetattrsetattr	Exception)config	parametervalueoriges        r   validate_configr'   /   sy     F69%D#	5) 		4("	   		4("s#   A 	AAAA A.c                      e Zd Z ej                  g d      Z ej                  i d      Z ej                  i d      Z ej                  g d      Z	y)_base_configz$
        External CSS files to load.defaultdoczo
        External JS files to load. Dictionary should map from exported
        name to the URL of the JS file.zz
        External JS files to load as modules. Dictionary should map from
        exported name to the URL of the JS file.z0
        List of raw CSS strings to add to load.N)
__name__
__module____qualname__paramList	css_filesDictjs_files
js_modulesraw_css     r   r)   r)   @   sd    

2 ,' (I uzz" ++ ,H B -4 5J ejj *3 4Gr8   r)   c                      e Zd ZU dZ ej
                  g ed      Z ej                  dd      Z	 ej                  dd      Z ej                  dd	      Z ej                  d
d      Z ej                  dd      Z ej                  dd      Z ej                  d
d      Z ej$                  dd
d      Z ej(                  d      Z ej                  dd      Z ej
                  g d      Z ej                  d
d      Z ej2                  dddgd      Z ej                  dd      Z ej                  d
d      Z ej2                  dg dd      Z ej<                  dd       Z ej@                  d!d"      Z! ej                  d
d#      Z" ej2                  ddg d$d%&      Z# ej(                  d'      Z$ ej                  d
d(      Z% ej                  dd)      Z& ej                  d
d*      Z' ej@                  d+d,d-.      Z( ej2                  dg d/d0      Z) ej2                  dd1      Z* ej                  d
d2      Z+ ej                  d
d3      Z, ej(                  dd4      Z- ej2                  d5g d6d7      Z. ej2                  d8g d9d:      Z/ ej2                  d;dg d<d=&      Z0 ej(                  dd>      Z1 ej                  d
dd?@      Z2 ej                  d
dA      Z3 ej(                  dBdC      Z4 ej(                  ddD      Z5 ej(                  dEdF      Z6 ej2                  dGg d6dH      Z7 ej2                  dIdJdIgdK      Z8 ej@                  ddL      Z9 ej$                  de:e;fddMN      Z< ej2                  ddg dO&      Z= ej|                  dPdQdR.      Z? ej(                  ddS      Z@ ej(                  ddT      ZA ej(                  ddU      ZB ej(                  ddV      ZC ej$                  deDdWX      ZE ej                  i dY      ZG ej
                  ddZ      ZH ej                  d
d[      ZI ej                  d
d\      ZJ ej                  eKdd]@      ZL ej2                  dd8d^gdd_`      ZMh daZNdbeOdc<   g ddZP eQ       ZRdeeOdf<    fdgZS ej                  dhddi      dj        ZU ej                  dkdl      dm        ZV ej                  dndodl      dp        ZWeXdq        ZY fdrZZ ej                  dsdl      dt        Z[ ej                  dudl      dv        Z\ fdwZ]dx Z^dy Z_e`dz        Zae`d{        Zbe`d|        Zce`d}        Zde`d~        Zee`d        Zfe`d        Zge`d        Zhe`d        Zie`d        Zje`d        Zke`d        Zle`d        Zme`d        Zne`d        Zoe`d        Zpe`d        Zqe`d        Zre`d        Zse`d        Zte`d        Zue`d        Zve`d        Zwe`d        Zxe`d        Zye`d        Zze`d        Z{e`d        Z|e`d        Z} xZ~S )_configa  
    Holds global configuration options for Panel.

    The options can be set directly on the global config instance, via
    keyword arguments in the extension or via environment variables.

    For example to set the embed option the following approaches can be used:

        pn.config.embed = True

        pn.extension(embed=True)

        os.environ['PANEL_EMBED'] = 'True'

    Reference: Currently none

    :Example:

    >>> pn.config.loading_spinner = 'bar'
    z
        A list of tuples containing a title and a function that returns
        an additional panel to be rendered into the admin page.)r+   	item_typer,   Tzk
        Whether to set custom Signature which allows tab-completion
        in some IDEs and environments.r*   Na5  
        Authorization callback that is invoked when authentication
        is enabled. The callback is given the user information returned
        by the configured Auth provider and should return True or False
        depending on whether the user is authorized to access the
        application. The callback may also contain a second parameter,
        which is the requested path the user is making. If the user
        is authenticated and has explicit access to the path, then
        the callback should return True otherwise it should return
        False.z
        A jinja2 template rendered when the authorize_callback determines
        that a user in not authorized to access the application.Fz:
        Whether to autoreload server when script changes.z[
        A jinja2 template to override the default Basic Authentication
        login page.z;
        Whether to request browser info from the frontend.z5
        Whether to defer load of rendered functions.z6
        The design system to use to style components.)class_is_instancer,   zf
        The notification to display to the user when the connection
        to the server is dropped.)r,   z.
        General exception handler for events.z3
        List of raw CSS to be added to the header.zK
        Whether to add a global loading spinner for the whole application.warnerrorz
        Provide compatibility for older layout specifications. Incompatible
        specifications will trigger warnings by default but can be set to error.
        Compatibility to be set to error by default in Panel 1.1.)r+   objectsr,   z2
        Load entry points from external packages.zR
        Whether a loading indicator is shown by default while panes are updating.arc)rA   arcsbardotspetalzJ
        Loading indicator to use when component loading parameter is set.z#c3c3c3z(
        Color of the loading indicator.i  z1
        Maximum height of the loading indicator.z7
        Whether to enable notifications functionality.)pyinstrumentsnakevizmemrayz'
        The profiler engine to enable.)r+   
allow_Noner@   r,   z\
        The notification to display when the application is ready and
        fully loaded.a  
        Whether to reuse a session for the initial request to speed up
        the initial page render. Note that if the initial page differs
        between sessions, e.g. because it uses query parameters to modify
        the rendered content, then this option will result in the wrong
        content being rendered. Define a session_key_func to ensure that
        reused sessions are only reused when appropriate.z
        Used in conjunction with the reuse_sessions option, the
        session_key_func is given a tornado.httputil.HTTPServerRequest
        and should return a key that uniquely captures a session.z
        Ensure all bokeh property changes trigger events which are
        embedded. Useful when only partial updates are made in an
        app, e.g. when working with HoloViews.r   )Nz
        If set to a non-negative value this determines the maximum length
        of the pn.state.session_info dictionary, which tracks
        information about user sessions. A value of -1 indicates an
        unlimited history.)r+   boundsr,   )fixedstretch_widthstretch_heightstretch_bothscale_widthscale_height
scale_bothNz<
        Specify the default sizing mode behavior of panels.zA
        The default template to render served applications into.zJ
        If sliders and inputs should be throttled until release of mouse.z#Whether the admin panel is enabled.z#Name to use for the admin endpoint.DEBUG)rS   INFOWARNINGERRORCRITICALz#Log level of the Admin Panel loggerr+   )r+   
ipywidgetsvscodecolabz
        Whether to render output in Jupyter with the default Jupyter
        extension or use the jupyter_bokeh ipywidget model.
accumulate)r[   replacedisableFzl
        How to log errors and stdout output triggered by callbacks
        from Javascript in the notebook.z<
        Configure to enable getting/setting secure cookies.z,
        Whether plot data will be embedded.)r+   rI   r,   z6
        Whether to save embedded state to json files. z8
        Prefix for randomly generated json directories.z5
        Where to load json files for embedded state.z./z5
        Where to save json files for embedded state.rU   zLog level of Panel loggerszhttps://cdn.jsdelivr.net/npmzhttps://unpkg.comz
        The CDN to load NPM packages from if resources are served from
        CDN. Allows switching between [https://unpkg.com](https://unpkg.com) and
        [https://cdn.jsdelivr.net/npm](https://cdn.jsdelivr.net/npm) for most resources.z
        When set to a non-None value a thread pool will be started.
        Whenever an event arrives from the frontend it will be
        dispatched to the thread pool to be processed.z
        Password, dictionary with a mapping from username to password
        or filepath containing JSON to use with the basic auth
        provider.)r+   r<   rI   r,   z;
        Select between a list of authentication providers.r   )r   Nz6
        Expiry of the OAuth cookie in number of days.z7
        A client key to provide to the OAuth provider.z:
        A client secret to provide to the OAuth provider.z:
        The key in the ID JWT token to consider the user.z9
        A redirect URI to provide to the OAuth provider.zG
        A random string used to encode OAuth related user information.)r+   r<   r,   z;
        Additional parameters required for OAuth provider.zR
        List of endpoints that can be accessed as a guest without authenticating.z|
        Whether the user will be forced to go through login flow or if
        they can access all applications as a guest.zJ
        Whether to automatically refresh access tokens in the background.zx
        Whether to inline JS and CSS resources. If disabled, resources
        are loaded from CDN if one is available.darkz*
        The theme to apply to components.)r+   r@   rI   r,   >   admincommsnpm_cdnnthreads	oauth_key
autoreloadoauth_expiryoauth_secretadmin_pluginscookie_secretoauth_jwt_useroauth_optionaloauth_provideroauth_extra_paramsoauth_redirect_urilayout_compatibilityoauth_encryption_keyoauth_refresh_tokensoauth_guest_endpointszClassVar[set[str]]_globals)Truetrue1Tr   z5ClassVar[WeakKeyDictionary[Document, dict[str, Any]]]_session_configc                   t        |   di | d| _        | j                  D ]:  }|j	                  d      s|dd  t
        j                  vs+t        | |dz   d        < | j                  r t        j                  | j                         y y )NF_r   r7   )super__init__r   _parameter_set
startswithr:   rs   r    	log_levelr   setLevel)selfparamsp	__class__s      r   r{   z_config.__init__O  sz    "6" $$A||C QqrU'2B2B%BaeT* % >>&&t~~6 r8   	_nthreads)watchon_initc                (   | j                   <t        j                   t        j                  j                  d       d t        _        y t        j                  rt	        d      | j                   r| j                   nd }t        |      t        _        y )NF)waitzThread pool already running)max_workers)rc   r   _thread_poolshutdownRuntimeErrorr   )r   threadss     r   _set_thread_poolz_config._set_thread_poolX  sm    == !!-""+++7!%E<==#'==$--d/GDr8   notifications)r   c                    ddl m} ddlm} | j                  r)d|j
                  vr|j
                  j                  d       t        j                  s |       t        _	        y y )Nr   )NotificationArea)ReactiveHTMLMetaclassr   )
io.notificationsr   reactiver   r   _loaded_extensionsaddr   curdoc_notification)r   r   r   s      r   _setup_notificationsz_config._setup_notificationsd  sJ    63/9N9a9a"a!4488I||"2"4E r8   disconnect_notificationready_notificationc                D    | j                   s| j                  rd| _        y y )NT)r   r   r   r   s    r   _enable_notificationsz_config._enable_notificationsm  s!    ''4+B+B!%D ,Cr8   c           
   +    K   | j                   j                         j                         D cg c]  \  }}|dk7  s||f }}}t        j                  D cg c]9  }|j                  d      r&|dd  t        j                  vr|t        | |dz         f; }}|j                         D ]  \  }}t        | ||        	 d  | j                   j                         }|D ci c]  \  }}||j                  |      us|| }}} | j                   j                  di | |D ]  \  }}t        | |dz   |        y c c}}w c c}w c c}}w # | j                   j                         }|D ci c]  \  }}||j                  |      us|| nc c}}w }}} | j                   j                  di | |D ]  \  }}t        | |dz   |        w xY ww)Nnamery   r   r7   )r0   valuesitemsr:   r|   r}   rs   r   r    getupdate)r   kwargskr   r   	overridesnewrestores           r   setz_config.setr  s    %)ZZ%6%6%8%>%>%@P%@TQAK1a&%@P/6/E/E
/E!||C QqrU'2B2B%B ae$%/E 	 
 LLNDAqD!Q #	(**##%C(.F1!3771:2Eq!tGFDJJ((!1aeQ' " Q
 G **##%C(.F1!3771:2Eq!tFGFDJJ((!1aeQ' "s_   ,GD;D;G>E'G=E G E<EAG G,F
F
AGGc                   ddl m} t        | d      rt        | j                  dd      }nt        | dd      }|r'|j                  d      r|j                  d      s|dk(  rt        | !  ||      S  t        | d| dd	       |      }|t        j                  v s<|j                  d      r|dd  t        j                  v s| j                  j                  r*t        | !  || j                  v r||       y d| |       y |j                  |t        j                  v rt        | ||       n4d| t        j                  v rt        | d| |       nt!        |d
      |j                  | j"                  vri | j"                  |j                  <   || j"                  |j                     |<   | j                  j$                  j'                  |i       j'                  dg       }|D ]  }|j)                           y d| t        j                  v r5t        | d| d      r%t        | d| |       t        | !  d| d|       y t        | !  ||       y )Nr   r   _param__privateinitializedFry   r   _hookc                    | S r   r7   )xs    r   <lambda>z%_config.__setattr__.<locals>.<lambda>  s    r8   z! is not a valid config parameter.r$   )io.stater   hasattrr   r   r}   endswithrz   __setattr__r:   rs   r0   _TRIGGERr   r|   r'   AttributeErrorrw   watchersr   fn)r   attrr$   r   initr   wr   s          r   r   z_config.__setattr__  s   # 4*+4//FD46D,s1CP]H]7&tU33;$uo{;EBG$$$$abW5E5E)Ezz""G

(:ER!D6
ER\\%w---dE2TFw555$j%8$x/P%QRR||4#7#7757$$U\\27<D  .t4zz**..tR8<<WbIH Z7111gdavQK6PDAdV*e4G!D6U3Ge,r8   
_log_levelc                B    t        j                  | j                         y r   )r   r   r   r   s    r   _update_log_levelz_config._update_log_level  s    ""4??3r8   _admin_log_levelc                F    ddl m} |j                  | j                         y )Nr   )log_handler)io.adminr   r   r   )r   admin_log_handlers     r   _update_admin_log_levelz_config._update_admin_log_level  s    >""4??3r8   c                
   t         s|dv rt        | 	  |      S ddlm} t        | 	  d      }|j
                  }|r	||vri ||<   |dv r8|r6|||   vr/t        j                  t        | 	  |            }t        | ||       |t        j                  v s|dk(  rt        | 	  |      S |r||v r|||   v r||   |   S d| t        j                  v r#t        | d| d      t        | 	  d| d      S t        | 	  |      S )z
        Ensures that configuration parameters that are defined per
        session are stored in a per-session dictionary. This is to
        ensure that even on first access mutable parameters do not
        end up being modified.
        )r   rs   r|   r   r0   r   r   rw   )r6   
global_cssr2   r4   r5   themery   )_config_uninitializedrz   __getattribute__r   r   r   copyr    r:   rs   r|   r   )r   r   r   session_configr   new_objr   s         r   r   z_config.__getattribute__  s&    !D,s$s7+D11#12CDfN2%'N6"TTt>&#99ii 8 >?GD$(7###tw7+D11.0T^F=S5S!&)$//Z7111gdavQK6P6\7+avQK88w'--r8   c                    |r|S dS )Nr]   r7   r   r$   s     r   _console_output_hookz_config._console_output_hook  s    u,9,r8   c                l    t        |t              r#| j                  j                  j                  |   S |S r   )
isinstancestrr0   templatenamesr   s     r   _template_hookz_config._template_hook  s,    eS!::&&,,U33r8   c                @    t         j                  j                  d      S )Nr   )osenvironr   r   s    r   
_doc_buildz_config._doc_build  s    zz~~/00r8   c                    | j                   S r   )_adminr   s    r   r`   z_config.admin  s    {{r8   c                V    t         j                  j                  d| j                        S )NPANEL_ADMIN_ENDPOINT)r   r   r   _admin_endpointr   s    r   admin_endpointz_config.admin_endpoint      zz~~4d6J6JKKr8   c                ~    t         j                  j                  d| j                        }|r|j	                         S d S )NPANEL_ADMIN_LOG_LEVEL)r   r   r   r   upper)r   admin_log_levels     r   r   z_config.admin_log_level  s3    **..)@$BWBWX*9$$&CtCr8   c                x    | j                   ryt        j                  j                  dt        j
                        S )Nr]   PANEL_CONSOLE_OUTPUT)r   r   r   r   r:   _console_outputr   s    r   console_outputz_config.console_output  s(    ??::>>"8':Q:QRRr8   c                v    t         j                  j                  dt        j                        | j
                  v S )NPANEL_EMBED)r   r   r   r:   _embed_truthyr   s    r   embedz_config.embed  s$    zz~~mW^^<LLr8   c                V    t         j                  j                  d| j                        S )NPANEL_COMMS)r   r   r   _commsr   s    r   ra   z_config.comms  s    zz~~mT[[99r8   c                v    t         j                  j                  dt        j                        | j
                  v S )NPANEL_EMBED_JSON)r   r   r   r:   _embed_jsonr   r   s    r   
embed_jsonz_config.embed_json  s'    zz~~0'2E2EF$,,VVr8   c                ^    t         j                  j                  dt        j                        S )NPANEL_EMBED_JSON_PREFIX)r   r   r   r:   _embed_json_prefixr   s    r   embed_json_prefixz_config.embed_json_prefix  s    zz~~79S9STTr8   c                ^    t         j                  j                  dt        j                        S )NPANEL_EMBED_SAVE_PATH)r   r   r   r:   _embed_save_pathr   s    r   embed_save_pathz_config.embed_save_path      zz~~5w7O7OPPr8   c                ^    t         j                  j                  dt        j                        S )NPANEL_EMBED_LOAD_PATH)r   r   r   r:   _embed_load_pathr   s    r   embed_load_pathz_config.embed_load_path  r   r8   c                v    t         j                  j                  dt        j                        | j
                  v S )NPANEL_INLINE)r   r   r   r:   _inliner   r   s    r   inlinez_config.inline  s$    zz~~ngoo>$,,NNr8   c                ~    t         j                  j                  d| j                        }|r|j	                         S d S )NPANEL_LOG_LEVEL)r   r   r   r   r   )r   r~   s     r   r~   z_config.log_level	  s/    JJNN#4dooF	$-y 747r8   c                ^    t         j                  j                  dt        j                        S )NPANEL_NPM_CDN)r   r   r   r:   _npm_cdnr   s    r   rb   z_config.npm_cdn  s    zz~~ow/?/?@@r8   c                t    t         j                  j                  d| j                        }|d S t	        |      S )NPANEL_NUM_THREADS)r   r   r   r   int)r   rc   s     r   rc   z_config.nthreads  s/    ::>>"5t~~F't:S]:r8   c                ~    t         j                  j                  d| j                        }|r|j	                         S d S )NPANEL_BASIC_AUTHr   r   r   _oauth_providerlowerr   providers     r   
basic_authz_config.basic_auth  s1    ::>>"4d6J6JK#+x~~55r8   c                ~    t         j                  j                  d| j                        }|r|j	                         S d S )NPANEL_OAUTH_PROVIDERr  r  s     r   rl   z_config.oauth_provider  s1    ::>>"8$:N:NO#+x~~55r8   c                l    t         j                  j                  d| j                        }t	        |      S )NPANEL_OAUTH_EXPIRY)r   r   r   _oauth_expiryfloatr  s     r   rf   z_config.oauth_expiry!  s'    ::>>"68J8JKXr8   c                V    t         j                  j                  d| j                        S )NPANEL_OAUTH_KEY)r   r   r   
_oauth_keyr   s    r   rd   z_config.oauth_key&  s    zz~~/AAr8   c                    t         j                  j                  dt         j                  j                  d| j                              S )NPANEL_COOKIE_SECRETBOKEH_COOKIE_SECRET)r   r   r   _cookie_secretr   s    r   ri   z_config.cookie_secret*  s3    zz~~!JJNN0$2E2EF
 	
r8   c                V    t         j                  j                  d| j                        S )NPANEL_OAUTH_SECRET)r   r   r   _oauth_secretr   s    r   rg   z_config.oauth_secret1  s    zz~~2D4F4FGGr8   c                V    t         j                  j                  d| j                        S )NPANEL_OAUTH_REDIRECT_URI)r   r   r   _oauth_redirect_urir   s    r   rn   z_config.oauth_redirect_uri5  s    zz~~8$:R:RSSr8   c                V    t         j                  j                  d| j                        S )NPANEL_OAUTH_JWT_USER)r   r   r   _oauth_jwt_userr   s    r   rj   z_config.oauth_jwt_user9  r   r8   c                    t         j                  j                  d| j                        }t	        |t
              r|S |j                         dv S )NPANEL_OAUTH_REFRESH_TOKENSrv   ru   )r   r   r   _oauth_refresh_tokensr   boolr  )r   refreshs     r   rq   z_config.oauth_refresh_tokens=  s=    **..!=t?Y?YZgt$N}}-//r8   c                V    t         j                  j                  d| j                        S )NPANEL_OAUTH_ENCRYPTION)r   r   r   _oauth_encryption_keyr   s    r   rp   z_config.oauth_encryption_keyD  s    zz~~68R8RSSr8   c                    dt         j                  v r&t        j                  t         j                  d         S | j                  S )NPANEL_OAUTH_EXTRA_PARAMS)r   r   astliteral_eval_oauth_extra_paramsr   s    r   rm   z_config.oauth_extra_paramsH  s5    %3##BJJ/I$JKK+++r8   c                    dt         j                  v r&t        j                  t         j                  d         S | j                  S )NPANEL_OAUTH_GUEST_ENDPOINTS)r   r   r8  r9  _oauth_guest_endpointsr   s    r   rr   z_config.oauth_guest_endpointsO  s5    (BJJ6##BJJ/L$MNN...r8   c                    t         j                  j                  d| j                        }t	        |t
              r|S |j                         dv S )NPANEL_OAUTH_OPTIONALr/  )r   r   r   _oauth_optionalr   r1  r  )r   optionals     r   rk   z_config.oauth_optionalV  s>    ::>>"8$:N:NOh%O~~=00r8   c                   t         j                  }|r0d| j                  j                  |i       v r| j                  |   d   S | j                  r| j                  S t        t         j                  t              rgt         j                  rWt         j                  j                  ddg      d   j                  d      }|| j                  j                  j                  v r|S y)Nr   s   defaultr   zutf-8r+   )r   r   rw   r   _theme_r   session_argsdictdecoder0   _themer@   )r   r   r   s      r   r   z_config.theme]  s    g!5!5!9!9&"!EE''/88\\<<**D1e6H6H&&**7ZLA!DKKGTE

))111r8   )r-   r.   r/   __doc__r0   r1   tuplerh   Booleanapply_signaturesCallableauthorize_callbackPathauth_templatere   basic_auth_templatebrowser_info
defer_loadClassSelectordesignStringr   exception_handlerr   global_loading_spinnerSelectorro   load_entry_pointsloading_indicatorloading_spinnerColorloading_colorIntegerloading_max_heightr   profilerr   reuse_sessionssession_key_func
safe_embedsession_historysizing_moder   	throttledr   r   r   r   r   r#  r   r   r   r  r   r   r  r   rE  r   _basic_authr  Numberr  r  r&  r,  r)  bytesr5  r3   r:  r=  r@  r0  _LOCAL_DEV_VERSIONr  rG  rs   __annotations__r   r	   rw   r{   dependsr   r   r   r   r   r   r   r   r   r   r   propertyr   r`   r   r   r   r   ra   r   r   r   r  r  r~   rb   rc   r  rl   rf   rd   ri   rg   rn   rj   rq   rp   rm   rr   rk   r   __classcell__)r   s   @r   r:   r:   Q   s	   * EJJrU AC DM %u}}T 8* + ( 	; 	 EJJt 2D EM u 3= >J %%**T 8  !5== 4> ?L u 38 9J !U  % F9 :F +ell 0% & 't :1 2 B -6 7J +U]]5 ?N O *5>>&67BS ZE F
 &d 95 6 &e :U V %ennU =/5MNO  EKK	 8+ ,M 's 94 5 "EMM% 6: ;M u~~dt F.4*+H & +  #U]]5 7= >N &u~~d 9E F
 u 32 3J
 $emmAj G O !%.. 8;A?@K
 u~~d 1D EH e 2M NI U]]5.STF"ell45Z[O%u~~!R13 U^^#O V?@F
 %enn\d*17,-O "U\\$ 5? @N U]]5T @/ 0F  %-- 49 :K &b 7; < $u||D 78 9 $u||D 78 9  #T(*J u~~&D$&DE M\]H d 1: ;I
 &%%%dD#;SW ^ K
 %ennr 8>?O !ELL9 C9 :M d 1: ;J !ELL 4= >M #ell4 6= >O '%,,t :< = 0E//U QJ K %%**R 6> ? (UZZ ;U V $emmE 88 9O *EMM% >M N emm$64 N4 5G U^^D9f2ERV ]- .F$H   -GM^M`OJ`7 U]];dD9	E :	E U]]?$/5 05 U]],.B$O& P& ( (""-H U]]<t,4 -4 U]]%T24 34.8-
 1 1   L L D D S S M M : : W W U U Q Q Q Q O O 8 8 A A ; ; 6 6 6 6   B B 
 
 H H T T L L 0 0 T T , , / / 1 1 
 
r8   r:   r@   r   Fc                  4   e Zd ZU dZdZded<   i dddddd	d
dddddddddddddddddddddd d!d"d#d$d%d&d'iZd(ed)<   d*gd
gd+gd,gd-gdgd.gd/gd0gd1gd2gd3d4gd$gd5gd&gd6Zd7ed8<   g Zd9ed:<   dZ	ded;<   d< Z
ed=        Zd> Zd? Zd@ ZdA ZyB)Cpanel_extensionaI  
    Initializes and configures Panel. You should always run `pn.extension`.
    This will

    - Initialize the `pyviz` notebook extension to enable bi-directional
    communication and for example plotting with Bokeh.
    - Load `.js` libraries (positional arguments).
    - Update the global configuration `pn.config`
    (keyword arguments).

    Parameters
    ----------
    *args : list[str]
        Positional arguments listing the extension to load. For example "plotly",
        "tabulator".
    **params : dict[str,Any]
        Keyword arguments to be set on the `pn.config` element. See
        https://panel.holoviz.org/api/config.html

    :Example:

    >>> import panel as pn
    >>> pn.extension("plotly", sizing_mode="stretch_width", template="fast")

    This will

    - Initialize the `pyviz` notebook extension.
    - Enable you to use the `Plotly` pane by loading `plotly.js`.
    - Set the default `sizing_mode` to `stretch_width` instead of `fixed`.
    - Set the global configuration `pn.config.template` to `fast`, i.e. you
    will be using the `FastListTemplate`.
    Fr1  _loadedacezpanel.models.ace
codeeditordeckglzpanel.models.deckglechartszpanel.models.echartsfiledropperzpanel.models.file_dropperrX   zpanel.io.ipywidget
jsoneditorzpanel.models.jsoneditorkatexzpanel.models.katexmathjaxzpanel.models.mathjaxmodalzpanel.models.modalperspectivezpanel.models.perspectiveplotlyzpanel.models.plotly	tabulatorzpanel.models.tabulatorterminalzpanel.models.terminal
texteditorzpanel.models.quillvizzuzpanel.models.vizzuvegazpanel.models.vegavtkzpanel.models.vtkzClassVar[dict[str, str]]_importsdeckFilePondjsPanel	GridStackMathJax
A11yDialogz(customElements.get('perspective-viewer')Plotly	TabulatorTerminalxtermjsVizzu)rt  ru  rv  
floatpanel	gridstackrx  ry  rz  r{  r|  r}  r~  r  r  r  zClassVar[dict[str, list[str]]]rs   z	list[str]r   _comms_detected_beforec           	     *   ddl m} ddlm} ddlm} ddlm}m} t        j                  |      j                         D 	ci c]  \  }}	|	j                  |	 }
}}	|D cg c]  }|t        j                  vs| }}t        j                   rAt        j                   t        j"                  vr!g t        j"                  t        j                   <   |j%                  d      s|j%                  d      rd	|d
<   |j%                  d
t&        j(                        r	d
|vr|dz  }|D ]  }|d
k(  r	d
|vrd	|d
<   |dk(  r"ddlm} |j%                  dg       |d   gz   |d<   || j.                  v r-	 |dk(  rt1               rdt2        j4                  vrk| j.                  |   }|t8        j:                  v rt8        j:                  |   j<                  j?                         D ]P  }tA        |tB              stE        ||      s!tG        |dd       }|s1||jH                  vs@|jK                  |       R ntM        |       | j                  jO                  |       t        j                   sCt        j"                  t        j                      jO                  |       u||
v rLt        j                   rt        jP                  jO                  |       |j                  jK                  |       | j                  jS                  | d        |j                         D ]a  \  }}	|dk(  rtA        |	tT              rddl+m,} 	 t[        j\                  d| j^                          t        j                  |      j                         D ci c]  \  }}|ja                         | }}}|	|vrtc        d|	dte        |       d      tg        t&        |||	          |dv rjtA        |	td              s$tc        | dtC        |	      jh                   d      tG        t&        |      }|jk                  |	D cg c]	  }||vs| c}       +|dk(  r!tG        t&        |      jm                  |	       Qtg        t&        ||	       d t&        jn                  r| jq                          | jr                  }d	t        _9        |r]|dk(  rXd| j                  v rJtu        jv                         }tu        jx                  |d      }t{        |      d k\  rd!|d   j|                  v ry d"t8        j:                  v rdd l?}dd l@}|xs tG        |j                  d#d$      }|j                  j                  |j                  j                  v r|j                  j                  }nd%}|r1|rK||j                  j                  k7  r2t        |j                  d&      r|j                  j                  |       n||j                  _C        |s t&        j                  r| j                          	 |j                  d'd       xs
 t1               }dd(lJmK} | j                  |       t        xj                  |z  c_        t        |d)      rA|s?t&        j                  s/t        j                  | j                  d*       t        t        _Q        dt8        j:                  v r(t&        j                  rtM        | j.                  d          tG        | d+d$      x}} d"t8        j:                  v rmtG        j                  d#d$      rd	}nSt        j                  d,      5  |j                  j                  j                  t&        j                         d	}d d d        |j                  j                  d$       t        |d)      r |t&        j                  |-       | s| j                          y y c c}	}w c c}w # t6        $ r Y Pw xY w# t6        $ r Y w xY wc c}}w c c}w # t6        $ r Y y w xY w# 1 sw Y   xY w).Nr   )_default_resolver)Model)settingsr   )ReactiveHTMLr   r   r   Tr   )r   rX   )CSS_URLSr2   zfont-awesomePANEL_IPYWIDGET__qualified_model__z. extension not recognized and will be skipped.rT  )Designzpanel.theme.zDesign z7 was not recognized, available design systems include: .)r2   r6   r   z( should be supplied as a list, not as a z type.r4   )r  r        pyvista	holoviewsrq  Fbokehset_current_backendip)load_notebookkernelzhv-extension-comm_repeat_execution_in_cellrV   )	reloading)[bokeh.core.has_propsr  bokeh.modelr  bokeh.settingsr  r   r  r   r0   concrete_descendentsr   _extension_namerp  r   r   r   _extensions_r   r"   r   io.resourcesr  r  get_ipythonr   r   r!   sysmodules__dict__r   r   type
issubclassr   known_modelsr   
__import__append_extensionswarningr   r   r  	importlibimport_module_designr  
ValueErrorlistr    r-   extendr   rK  _apply_signaturesrq  inspectcurrentframegetouterframeslenfilenamer  holoviews.plotting.bokehr   Storecurrent_backend	renderersr   r  rY  _load_entry_pointspopio.notebookr  _detect_commsr   _JupyterCommManagerget_client_comm_process_comm_msg_comm_managerr   logging_levelplottingRendererload_nbr  
simple_ids	set_value_display_globals)!r   argsr   r  r  bk_settingsr  r   r   r   reactive_extsargnewly_loadedr  modulemodelqualr  r   tdesignsexistingr   loadedcurframecalframehvr  backendr  r  	nb_loaded	publisheds!                                    r   __call__zpanel_extension.__call__  s   :%:A-2-G-G-U-[-[-]
-]TQAq -] 	 
 (,]ts/:\:\/\t]<<ELL0B0BB/1Eu||,::*+vzz:S/T&*F?#::ov';';<X\A\&&DCo%/*G*.'l"2&,jjb&AXnE]D^&^{#dmm#|+); 
 s+S[[(!$V!4!=!=!D!D!F%eT2z%7O#*52G#ND#4E4R4R(R 1 5 5e <	 "G v&''..s3<<&&u||4;;C@%<<%%,,S1%88<<SA

""cU +6 $6 7E J LLNDAqH}As!3)++l4<<.,IJ .3-G-G-O-U-U-W-WTQAGGIqL-W   G#$!! ',,0M?!=  71:.<<!!T*$s +115a1A1A0B&&J K K"61- IS5H IJj"))!,1%3 #6 """"$"& dh&5D4K4K+K++-H--h:H8}!i8A;3G3G&G#++%"+Fwr||YFFxx''288+=+==((22!fBHH4L4L)LRYZ\ZbZbdyRz,,W5+2(&22##%	D$'8;=B 	/6"**l:*2x 8I8I  //0F0F0CE"5E3;;&6<<t}}\23 '.I5 QQ	I#++%r||Y6 	((1KK((00? $I 2
 	((/2x  !!# a
 ^$ ! > !  !JN  		2 21sf   __
7_
)!_9"__/*	_5
4_5
_: 36`		__	_,+_,:	``	`c                    t         j                  rt        j                  r}ddlm}   |        }t        j
                  j                         }t        j                  j                  ||      }t        j                  j                  |||      \  }}t        ||d       t         j                  rt        t        j                         y y )Nr   r   T)metadataraw)r"   rQ  r   bokeh.documentr   r  get_server_comm_render_model_render_mimebundledisplayr   )r   r,   commr  bundlemetas         r   r  z panel_extension._display_globals_  s    5#5#5/*C&&668D&&44S$?E --@@TRLFDFTt4E''(  r8   c                   | j                   }d| _         d|v r|j                  d      t        _        y |ry dt        j
                  v r	 dd l}dt        _        y d	t        j                  v sd
t        j                  v r!	 dd l}dt        _        | j                          y y # t        $ r t        j                  dd       Y y w xY w# t        $ r t        j                  dd       Y Zw xY w)NTra   zgoogle.colabr   rZ   zUsing Panel interactively in Colab notebooks requires the jupyter_bokeh package to be installed. Install it with:

    !pip install jupyter_bokeh

and try again.   )
stacklevel
VSCODE_CWD
VSCODE_PIDrY   zUsing Panel interactively in VSCode notebooks requires the jupyter_bokeh package to be installed. You can install it with:

   pip install jupyter_bokeh

or:
    conda install jupyter_bokeh

and try again.)r  r  r"   ra   r  r  jupyter_bokehr!   warningsr>   r   r   _ignore_bokeh_warnings)r   r   called_beforer  s       r   r  zpanel_extension._detect_commsk  s    33&*#f!::g.FL S[[(	$& 2::%)C
$' '') *D  ) 67	   Q  !s$   	B >C  CC C('C(c                   ddl m}m} ddlm} t        j                  |      }t        t        |j                                     D ]  }|j                  nZ|j                  j                  d      r?|j                  j                  d      d   }|j                  j                  |d      |_
        t        j                  |j                        }t        |j                   j                               }|r|d    |d|j"                        k7  r|d d }	t%               g }}
t        |j'                               D ]  }g }t)        |j*                  j-                               D ]T  \  }}t/        |t
        j                        s!||
vs&|j0                  r3|j3                  |       |
j5                  |       V |j3                  |        |	t        |      D cg c]*  }|D ]#  }||j                   vr |||j6                        % , c}}z  }	d	|
v rd
nd	}|	j3                   |||j"                                ||	|j8                        |j                  _         y c c}}w )Nr   )	Parameter	Signaturer   )Viewabler   
r^   rJ   r   _kwargs)return_annotation)r  r   r  viewabler  r0   r  reversedr  r   rH  r}   splitr\   	signaturer{   
parametersVAR_KEYWORDr   mrosortedr  r   r   readonlyr  r   KEYWORD_ONLYr  __signature__)r   r   r  r  descendantsclsprefixsig
sig_paramsr
  processed_kwskeyword_groupssclskeyword_groupr   r   kwsr   
kwarg_names                      r   r  z!panel_extension._apply_signatures  s   0&00:D!3!3!567C{{"''1**403!kk11&"=##CLL1Ccnn3356JB9XyG\G\3]!]#CRJ,/E2>M + "$T]]%8%8%:;FQ"1eoo61M;Q !

%,,Q/%))!,	 <
 %%m4 , #N33Cs~~- $	 6 67@C 83 J
 '/-&?XJi
I4I4IJK)2c.C.C*CLL&; 8,s   /I 
c                     ddl m}  |d       y)a  
        Load entry points from external packages.
        Import is performed here, so any importlib
        can be easily bypassed by switching off the configuration flag.
        Also, there is no reason to waste time importing this module
        if it won't be used.
        r   )rY  zpanel.extensionN)entry_pointsrY  )r   rY  s     r   r  z"panel_extension._load_entry_points  s     	4+,r8   c                @    ddl m} t        j                  d|d       y )Nr   )BokehUserWarningignorezreference already known)categorymessage)bokeh.util.warningsr  r  filterwarnings)r   r  s     r   r  z&panel_extension._ignore_bokeh_warnings  s    83CMfgr8   N)r-   r.   r/   rH  rq  rk  r  rs   r   r  r  staticmethodr  r  r  r  r  r7   r8   r   rp  rp  t  s   B GT*!*(* 	'* 	)	*
 	2* 	** 	/* 	%* 	)* 	%* 	1* 	'* 	-* 	+* 	**  	%!*" 	##*$ 	!%*H& 2 (;"| k!];BC*!]+w0H, $ %'	&#(D(W$r 	) 	)&P%N	-hr8   rp  c                    | t         j                  vryt         j                  j                  |       \  }}}}|j                  |       y)zQ
    A cleanup action which is called when a plot is deleted in the notebook
    N)r   _viewsr  _cleanup)msg_idr  r  ry   s       r   _cleanup_panelr*    s>     U\\!!LL,,V4HeQer8   c                   | t         j                  vryt         j                  j                  |       \  }}}|j                          |D ]@  }|j                  D ]/  }|j
                  d   |j                  v s|j                  |       1 B y)zS
    A cleanup action which is called when a server is deleted in the notebook
    Nid)r   _serversr  stoprootsref_modelsr(  )	server_idserverr  docsr,   roots         r   _cleanup_serverr6    ss     &"^^//	:FHd
KKMIIDxx~!1!11!!$'  r8   add_server_delete_actionr"   r7   )@rH  
__future__r   r8  r   r  r  r   r  r  concurrent.futuresr   
contextlibr   typingr   r   r   weakrefr	   r0   pyviz_commsr
   r  r   _pyviz_extension	__versionr   
io.loggingr   r   r   r  r   any_is_pyodider   rj  pathabspathdirname__file___PATHr   r'   Parameterizedr)   r:   r   r@   _paramsr   r   r|   r   rI   r   r"   rp  r*  r6  add_delete_actionr7  __all__)r   r   s   00r   <module>rL     s  
 # 
    	 
  1 % / / %  # ) ' 4"344 ,,+  	12 #"45&& 4"Wl Wt 7==)$mm##%Gmm""$GW 	 
A '@ /11; q||t!1DD /@ 
A Sh& Sht
(  ! !. 1
?67,,_=&
'u@s   'G
