
    Ben                       d Z ddlmZ ddlmZ ddlmZmZmZm	Z	m
Z
mZmZmZmZmZmZ ddlZddlZddl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"m#Z# ddl$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/ ddl0m1Z2 ddl3m4Z4 ddl5m6Z6m7Z7 ddl8m9Z9m:Z: ddl;m<Z<m=Z=m>Z>m?Z? erddl@mAZA ddlBmCZC ddlDmEZE d'dZF G d deG          ZH edd !          ZI G d" d e4          ZJ G d# d$eJ          ZK G d% d&eJ          ZLdS )(z
Defines base classes for Pane components which allow wrapping a Python
object transforming it into a Bokeh model that can be rendered.
    )annotations)partial)TYPE_CHECKINGAnyCallableClassVarDictListMappingOptionalTupleTypeTypeVarNImportedStyleSheet)GridBoxTabPanelTabs   )Margin)_generate_hash)create_doc_if_none_existsunlocked)pushstate)Column	ListPanelNamedListPanelPanelRow)Link)ReactiveHTML)Reactive)param_reprsparam_watchers)is_dataframe	is_series)
LayoutableServableMixinViewableViewer)Document)Model)Commobjr   returnr+   c                   t          | t          t          f          r| S t          | d          rt          | t                    r|                                 S t          | t                    r>t          | t                    r)t           |             	                                          S t          | 	                                          S |
                    dd          |                    d            t          j        | fi || fi |}t          |j                  dk    r|j        r|j        d         S |j        S )a  
    Creates a displayable Panel object given any valid Python object.

    The appropriate Pane to render a specific object is determined by
    iterating over all defined Pane types and querying it's `.applies`
    method for a priority value.

    Any keyword arguments are passed down to the applicable Pane.

    Setting `loading_indicator=True` will display a loading indicator while the function is being
    evaluated.

    To lazily render components when the application loads, you may also provide a Python
    function, with or without bound parameter dependencies and set
    `defer_load=True`.

    Reference: https://panel.holoviz.org/explanation/components/components_overview.html#panes

    >>> pn.panel(some_python_object, width=500)

    Arguments
    ---------
    obj: object
       Any object to be turned into a Panel
    **kwargs: dict
       Any keyword arguments to be passed to the applicable Pane

    Returns
    -------
    layout: Viewable
       A Viewable representation of the input object
    	__panel__nameFN   r   )
isinstancer+   r*   hasattrr,   _create_viewtype
issubclasspanelr3   getpopPaneBaseget_pane_typelenlayout_unpack)r0   kwargspanes      /lib/python3.11/site-packages/panel/pane/base.pyr;   r;   ,   s.   B #-011 &
	k	"	" &c6"" 	&##%%%c4   	,ZV%<%< 	,**+++S]]__%%%zz&%  (

608!#0000????D
4;1{1~;    c                  (     e Zd ZdZdd fd
Z xZS )RerenderErrorzO
    Error raised when a pane requests re-rendering during initial render.
    NrA   c               H     t                      j        |i | || _        d S N)super__init__rA   )selfrA   argsrC   	__class__s       rE   rM   zRerenderError.__init__b   s*    $)&)))rF   )__name__
__module____qualname____doc__rM   __classcell__rP   s   @rE   rH   rH   ]   sQ          &*           rF   rH   Tr>   )boundc                      e Zd ZU dZ ej        eedd          Z e	dd          Z
 ej        dd	d
          ZdZded<   dZded<   d	Zded<   dZded<   dddZded<   dgZded<   dZd	ZdM fd	Z fdZdNdZd ZdOdPd%ZdQd)ZedRd+            ZedSd-            ZedSd.            ZdT fd0Z dUd9Z!dVd:Z"dWd<Z#	 	 dXdYdAZ$e%dZdE            Z&dMd[dIZ'	 	 dXd\dJZ(e%d]dL            Z) xZ*S )^r>   a  
    PaneBase is the abstract baseclass for all atomic displayable units
    in the Panel library. We call any child class of `PaneBase` a `Pane`.

    Panes defines an extensible interface for wrapping arbitrary
    objects and transforming them into Bokeh models.

    Panes are reactive in the sense that when the object they are
    wrapping is replaced or modified the `bokeh.model.Model` that
    is rendered should reflect these changes.
    FzX
        Defines the layout the model(s) returned by the pane will
        be placed in.)defaultclass_is_instancedoc)   
   z
        Allows to create additional space around the component. May
        be specified as a two-tuple of the form (vertical, horizontal)
        or a four-tuple (top, right, bottom, left).rZ   r]   NTT
        The object being wrapped, which will be converted to a
        Bokeh model.rZ   
allow_refsr]   g      ?zClassVar[float | bool | None]priorityzClassVar[bool]_applies_kwrB   _updates)default_layoutloading"ClassVar[Mapping[str, str | None]]_renameobjectzClassVar[List[str]]_rerender_params)
backgroundcss_classesmarginr4   c                l    d _          t                      j        dd|i|   j         j        fi  j        r|ni }t          |t                    r#|s! j                              j                    fd|	                                D             }  j
         fi | _         j                             j                             j        t#          t$          j                             j                             j         j                  g                                             d S )NFrk   c                J    i | ]\  }}|t           j        v r|j        v|| S  )r)   param_skip_layoutable).0kvrN   s      rE   
<dictcomp>z%PaneBase.__init__.<locals>.<dictcomp>   sD     
 
 
QqJ4D/D/DT*** q***rF   rr   )_object_changingrL   rM   appliesrk   re   r6   bool_type_erroritemsrg   rA   _internal_callbacksextendrs   watch_sync_layoutablelistr)   _update_panerl   )rN   rk   paramsrz   rC   rP   s   `    rE   rM   zPaneBase.__init__   sQ    %111&111$,t{SS9I/QvvrSSw%% 	*g 	*4;;RT[)))
 
 
 
#\\^^
 
 
 *d)$99&99 ''JT2D9I4J4JKKJT.0EFF)
 	 	 	 	rF   c                    t                                          ||           |dk    rB| j        s=|                     |          }t	          |t
                    r|st          d          d S d S d S d S )Nrk   zValue is not valid.)rL   _validate_refre   rz   r6   r{   RuntimeError)rN   pnamevaluerz   rP   s       rE   r   zPaneBase._validate_ref   s    eU+++HT%5ll5))G'4(( : :"#8999 : : : :rF   eventsparam.parameterized.Eventc                  	 t          t          j                  t          | j                  z
  |rfd|D             }n7fd| j                                                                        D             }| j        r| j        }t          |t                    r0t          |          dk    r|d         x}}|d         x}}n|\  }}}}n|x}x}x}}|
                    d          |d         |z   |z   |d<   |
                    d          |d         |z   |z   |d<   | j        j                                        	| j        j                            	fd|                                D                        d S )	Nc                <    i | ]}|j         v |j         |j        S rr   r4   new)ru   eventincludeds     rE   rx   z-PaneBase._sync_layoutable.<locals>.<dictcomp>   s2       */UZ8=S=S
EI=S=S=SrF   c                $    i | ]\  }}|v 	||S rr   rr   )ru   rv   rw   r   s      rE   rx   z-PaneBase._sync_layoutable.<locals>.<dictcomp>   s+       AX1rF   r   r   r5   widthheightc                4    i | ]\  }}||         k    ||S rr   rr   )ru   rv   rw   
old_valuess      rE   rx   z-PaneBase._sync_layoutable.<locals>.<dictcomp>   s.    !X!X!X41aQ*UV-EWEW!QEWEWEWrF   )setr)   rs   rt   valuesr}   ro   r6   tupler@   r<   rA   update)
rN   r   rC   ro   tbrlr   r   s
           @@rE   r   zPaneBase._sync_layoutable   s   z'((3t/D+E+EE 	   39  FF   !%!2!2!4!4!:!:!<!<  F ; 	<[F&%(( 'v;;!##"1I%A"1I%A!'JAq!QQ &&&A&Azz'""."(/A"5"9wzz(##/#)(#3a#7!#;x [&--//
  !X!X!X!X6<<>>!X!X!XYYYYYrF   c                t    t          t          |           j        dt          |          j        d          )Nz( pane does not support objects of type 'z'.)
ValueErrorr9   rQ   )rN   rk   s     rE   r|   zPaneBase._type_error   s@    t**---tF||/D/D/DF G G 	GrF   r   depthintr1   strc                    t          |           j        }t          | dg          }| j        dnt          | j                  j        }|rdnd}|                    |d                    |          |          S )Nrk   Nonez{cls}({obj}, {params})z{cls}({obj})z, )clsr   r0   )r9   rQ   r%   rk   formatjoin)rN   r   r   r   r0   templates         rE   __repr__zPaneBase.__repr__   sr    4jj!TH:..+ffdk1B1B1K/5I++>3tyy/@/@cJJJrF   index	int | strr+   c                    | j         |         S )zJ
        Allows pane objects to behave like the underlying layout
        rI   )rN   r   s     rE   __getitem__zPaneBase.__getitem__   s     {5!!rF   
Tuple[str]c                D     t           fd j        D                       S )Nc              3     K   | ]H}|t           j        vj                            ||          +j                            ||          V  Id S rK   )r>   rs   _property_mappingr<   ru   prN   s     rE   	<genexpr>z.PaneBase._linked_properties.<locals>.<genexpr>   sg       
 
12&&4+A+E+Ea+K+K+W "&&q!,,+W+W+W+W
 
rF   )r   rs   rN   s   `rE   _linked_propertieszPaneBase._linked_properties   s=     
 
 
 
6:j
 
 
 
 
 	
rF   	List[str]c                *      fd j         D             S )Nc                J    g | ]}j                             |d           | S F)r   r<   r   s     rE   
<listcomp>z-PaneBase._linkable_params.<locals>.<listcomp>   s2    ccca$2H2L2LQPU2V2V2b2b2b2brF   )_synced_paramsr   s   `rE   _linkable_paramszPaneBase._linkable_params   s     cccc4.ccccrF   c                B    g d| j         z   fd| j        D             S )N)r4   rg   rh   rm   stylesheetsc                F    g | ]}|v|                     d           |S )_)
startswith)ru   r   ignored_paramss     rE   r   z+PaneBase._synced_params.<locals>.<listcomp>   s5    [[[a.)@)@VYIZIZ)@)@)@)@rF   )rl   rs   )rN   r   s    @rE   r   zPaneBase._synced_params   s3    [[[\`\qq[[[[4:[[[[rF   r   c                F    | j         rd S  t                      j        |  d S rK   )ry   rL   _param_change)rN   r   rP   s     rE   r   zPaneBase._param_change   s-      	Fv&&&&rF   refr]   
'Document'rootr.   parentcommComm | Nonec                    | j         |         d         | j        r|                     |           d S |                     ||||          }	 t	          |t
                    rLfdt          |j                  D             }|r	|d         }nt          |f|j        |         dd          z   }nt	          |t                    rO|j        
                                D ]4\  }	}
|
v r+|
                              }t          |
          }|||<    n5nTt	          |t                    r%d |j        D                                           }n|j                                      }t	          |t                    r||j        |	<   ndt	          |t                    rE|j        |         }t          |                                |          }t#          di ||j        |<   n
||j        |<   | j        j                             |d g          d         }||u ro |j        di | j                            |j        t          | j        j        | j        j        | j        j        | j        j        | j        j                             nE# t          $ r8 | j                            t;          |           j         dd|d	           Y nw xY wd
dlm } |j!        d         }||j"        v r(|j"        |         d         #                    |           d S d S )Nr   c                .    g | ]\  }}|d          u |S r   rr   )ru   ichild	old_models      rE   r   z+PaneBase._update_object.<locals>.<listcomp>  s6       "!UQx9,, ,,,rF   r5   c                    g | ]	}|j         
S rr   r   )ru   tabs     rE   r   z+PaneBase._update_object.<locals>.<listcomp>  s    :::s:::rF   r   )sizing_modestylesr   	min_widthro   z pane model z& could not be replaced with new model zU, ensure that the parent is not modified at the same time the panel is being updated.r   r   idrr   )$_modelsrf   _update
_get_modelr6   
_BkGridBox	enumeratechildrenr   _BkReactiveHTMLr}   r   r   _BkTabstabsdictproperties_with_values_BkTabPanelrA   r<   r   _compute_sizing_moder   r   r   r   ro   rs   warningr9   rQ   ior   r   _views_preprocess)rN   r   r]   r   r   r   	new_modelindexesr   noder   
new_modelsold_tabpropslayout_parentr   r   s                   @rE   _update_objectzPaneBase._update_object   s    L%a(	= 	LLi(((FOOCvt<<	0	&*-- 9   &/&@&@    %#AJEE$$&L6?5+A!""+EE		FO44 
9&,o&;&;&=&=  ND( H,, (y 9 9%)(^^
,5
5)	 -
 FG,, 9::fk:::@@KK--i88 &/22 3(2%%FG,, 3 +e,W;;==YOOO%0%9%95%9%9E"")2& K/33C$@@CM&& 	 	 @ @O$(K$;#{1"k/"&+"7#{1  	! 	! 	 	 	#  	 	 	J::& O OI O O+4O O O    	8 	htn%,La ,,T22222 s   DJ ?KKc           	        | j                                         D ]\  }\  }}|t          j        vs|t          j        v r%t          j        |         \  }}}}|st          j        |          r[t                      5  |                     |||||           d d d            n# 1 swxY w Y   |rd|j        vrt          ||           t          | j        |||||          }	|j        r|                    |	            |	             d S )Nembedded)r   r}   r   r   _fake_roots
_unblockedr   r   tagsr   r   session_contextadd_next_tick_callback)
rN   r   r   r   r   viewabler   r]   r   cbs
             rE   r   zPaneBase._update_pane=  su    $ 2 2 4 4 	 	C!V%,&&#1B*B*B(-S(9%HdC 
u',, 
ZZ F F''S$EEEF F F F F F F F F F F F F F F $Jdi77dOOOT0#sD&$OO& ..r2222BDDDD	 	s   :B  B$	'B$	modelc                    t           )z
        If _updates=True this method is used to update an existing
        Bokeh model instead of replacing the model entirely. The
        supplied model should be updated with the current state.
        )NotImplementedErrorrN   r   r   s      rE   r   zPaneBase._updateN  s
     "!rF   Optional[Document]
preprocessr{   Tuple[Viewable, Model]c                    | j         r|                     ||          }| }n#| j                            ||          }| j        }|r|                     |           ||fS )N)r   )rf   r   rA   r   )rN   r]   r   r  r   	root_views         rE   _get_root_modelzPaneBase._get_root_modelV  sq     = 	$??3T?22DII;))#D)99DI 	#T"""$rF   r0   r   float | bool | Nonec                    dS )a  
        Returns boolean or float indicating whether the Pane
        can render the object.

        If the priority of the pane is set to
        `None`, this method may also be used to define a float priority
        depending on the object being rendered.
        Nrr   )r   r0   s     rE   rz   zPaneBase.appliesh  s	     trF   rN   rW   Optional[Any]c                      fd j                                                                         D             }t          |fi |}|                    dd          }||} t                     |fi |S )a  
        Makes a copy of the Pane sharing the same parameters.

        Arguments
        ---------
        object: Optional new object to render
        params: Keyword arguments override the parameters on the clone.

        Returns
        -------
        Cloned Pane object
        c                    i | ]B\  }}j         |         j        s+|j         |         j        ur|j         |         j        ?||CS rK   )rs   readonlyrZ   
allow_None)ru   r   rw   rN   s      rE   rx   z"PaneBase.clone.<locals>.<dictcomp>  s^     
 
 
Q:a=)
./tz!}7L.L.LYtz!}'?Y qYYrF   rk   N)rs   r   r}   r   r=   r9   )rN   rk   r   	inherited
old_objects   `    rE   clonezPaneBase.clonet  s    
 
 
 
!Z..006688
 
 
	
 i**6**ZZ$//
>FtDzz&++F+++rF   c                P   t          |          }| j        rU|rS| j                            |           }|| u r|                     |||          \  }}n4|}|                    |||          }n|                     |||          \  }}|j        d         }||||ft          j        |<   |S )a  
        Returns the root model and applies pre-processing hooks

        Arguments
        ---------
        doc: bokeh.document.Document
          Optional Bokeh document the bokeh model will be attached to.
        comm: pyviz_comms.Comm
          Optional pyviz_comms when working in notebook
        preprocess: bool (default=True)
          Whether to run preprocessing hooks

        Returns
        -------
        Returns the bokeh model corresponding to this panel object
        r   )r   _design_wrapperr  get_rootr   r   r   )rN   r]   r   r  wrapperr  r   r   s           rE   r  zPaneBase.get_root  s    ( (,,< 	JD 	Jl++D11G$"&"6"6sD*"M"M	44#	''T:>>"223jIIOIthtn&c48SrF   Type['PaneBase']c                   t          |t                    rt          |          S g }t          j        t
                                                    D ]}|j        -d}	  |j        |fi |j	        r|ni }n# t          $ r d}Y nw xY wd}|j        }t          |t                    r|rt          d|j        z            ||du rt|                    |||f           t          t!          |d                     }|D ]9\  }}}	|+	  |	j        |fi |	j	        r|ni }n# t          $ r d}Y nw xY w|s6|	c S t#          dt          |          j        z            )a{  
        Returns the applicable Pane type given an object by resolving
        the precedence of all types whose applies method declares that
        the object is supported.

        Arguments
        ---------
        obj (object): The object type to return a Pane type for

        Returns
        -------
        The applicable Pane type with the highest precedence.
        NTFzIf a Pane declares no priority the applies method should return a priority value specific to the object type or False, but the %s pane declares no priority.c                    | d         S )Nr   rr   )xs    rE   <lambda>z(PaneBase.get_pane_type.<locals>.<lambda>  s
    ! rF   )keyz%s type could not be rendered.)r6   r+   r9   rs   concrete_descendentsr>   r   rd   rz   re   	Exceptionr{   r   rQ   appendreversedsorted	TypeError)
r   r0   rC   descendentsr   rz   rd   
pane_typesr   	pane_types
             rE   r?   zPaneBase.get_pane_type  s    c8$$ 	99+H55<<>> 	7 	7Az!%(qyRR1=1PbRRHH  % % %$HHH% :(D)) h   "9 <=:	"F G G G
 !X%6%6'156666f[nnEEEFF
%/ 	 	!Aw	$/i/aa)BW8_]_aaGG  $ $ $#GGG$ 8499;MMNNNs$   A66BB	D!!D0/D0rK   )r   r   r   )r   r   r1   r   )r   r   r1   r+   )r1   r   )r1   r   )r   r   r1   r   )r   r   r]   r   r   r.   r   r.   r   r   r1   r   r1   r   r   r   r   r.   r1   r   )NNT)r]   r   r   r   r  r{   r1   r  )r0   r   r1   r  )rN   rW   rk   r  r1   rW   )r]   r   r   r   r  r{   r1   r.   )r0   r   r1   r  )+rQ   rR   rS   rT   rs   ClassSelectorr!   r    rg   r   ro   	Parameterrk   rd   __annotations__re   rB   rf   rj   rl   rt   _PaneBase__abstractrM   r   r   r|   r   r   propertyr   r   r   r   r   r   r   r  classmethodrz   r  r  r?   rU   rV   s   @rE   r>   r>   i   s(        
 
 )U(e5: A  N
 VG *7 8 8 8F
 U_Td A   F /2H1111 #(K'''' #G""""  %H$$$$ 43 3G    
 .6J6666FJ           $: : : : :Z Z Z Z6G G GK K K K K" " " " 
 
 
 X
 d d d Xd \ \ \ X\' ' ' ' ' '
>3 >3 >3 >3@   "" " " " CG    $ 	 	 	 [	, , , , ,2 CG         D .O .O .O [.O .O .O .O .OrF   c                  V     e Zd ZU dZded<   dZ	 	 dddZddZd ZddZ	 fdZ
 xZS )	ModelPanea  
    ModelPane provides a baseclass that allows quickly wrapping a
    Bokeh model and translating parameters defined on the class
    with properties defined on the model.

    In simple cases subclasses only have to define the Bokeh model to
    render to and the `_transform_object` method which transforms the
    Python object being wrapped into properties that the
    `bokeh.model.Model` can consume.
    zClassVar[Model]_bokeh_modelTNr]   r-   r   Model | Noner   r   r   r1   r.   c                     | j         di |                     |          }||}||f| j        |j        d         <   |                     || j        |||           |S )Nr   rr   )r.  _get_propertiesr   r   _link_propsr   )rN   r]   r   r   r   r   s         rE   r   zModelPane._get_model  sn     "!>>D$8$8$=$=>><D(-vTXd^$ 7dDIIIrF   r   r   r   r   c                P     |j         di |                     |j                   d S )Nrr   )r   r1  documentr   s      rE   r   zModelPane._update  s0    <<t++EN;;<<<<<rF   c                    d | j                                                                         D             }| j        |d<   |S )Nc                &    i | ]\  }}||dv||S )N)r4   rg   rr   )ru   r   rw   s      rE   rx   z*ModelPane._init_params.<locals>.<dictcomp>  s8     
 
 
Q}*D!D!D q!D!D!DrF   rk   )rs   r   r}   rk   )rN   r   s     rE   _init_paramszModelPane._init_params  sM    
 
!Z..006688
 
 
  ;xrF   r0   r   Dict[str, Any]c                "    t          |          S )Nrk   )r   )rN   r0   s     rE   _transform_objectzModelPane._transform_object  s    3rF   c                6   d|v r;|                     |                     |                    d                               | j        2d|v r.t	          | j        dg           }d |D             |d         z   |d<   t                                          |          S )Nrk   r   __css__c                .    g | ]}t          |           S ))urlr   )ru   sss     rE   r   z3ModelPane._process_param_change.<locals>.<listcomp>  s1     % % %/1"r***% % %rF   )r   r;  r=   r.  getattrrL   _process_param_change)rN   r   cssrP   s      rE   rB  zModelPane._process_param_change	  s    vMM$00H1E1EFFGGG(]f-D-D$+Y;;C% %58% % %}%%&F=! ww,,V444rF   NNN
r]   r-   r   r/  r   r/  r   r   r1   r.   r%  )r0   r   r1   r8  )rQ   rR   rS   rT   r(  _ModelPane__abstractr   r   r7  r;  rB  rU   rV   s   @rE   r-  r-    s         	 	 "!!!J 379=	 	 	 	 	= = = =         5 5 5 5 5 5 5 5 5rF   r-  c                      e Zd ZU dZ ej        dd          Z ej        ddd          Z ej	        e
d          Zd	Zd
ed<   dZd
ed<   dddZded<   dZded<   dZd9d: fdZ	 	 d;d<d Z ej        d!d"d#d$d%          d&             Zd' Zed=d+            Zed>d?d/            Zd@d2Zd9dA fd3ZdBd4Zd9dC fd8Z xZS )DReplacementPanea  
    ReplacementPane provides a baseclass for dynamic components that
    may have to dynamically update or switch out their contents, e.g.
    a dynamic callback that may return different objects to be rendered.

    When the pane updates it either entirely replaces the underlying
    `bokeh.model.Model`, by creating an internal layout to replace the
    children on, or updates the existing model in place.
    Fz.
        Whether to update the object inplace.r`   Nra   rb   )r[   rc   r:  zClassVar[Tuple[str, ...]]_ignored_refsrr   r   )_paneinplaceri   rj   Tr{   rf   rk   r   c                     fdt                    D              _         t                      j        |fi  t	          d            _        d _        t           j        fi d                                 D              _	         j
                             j                             j        t          t          j                                                                         d S )Nc                N    i | ]!}|j         v|                    |          "S rr   )rs   r=   )ru   r   r   rN   s     rE   rx   z,ReplacementPane.__init__.<locals>.<dictcomp>3  s;     1 1 1aTZ// FJJqMM///rF   Tc                6    i | ]\  }}|t           j        v ||S rr   )r   rs   ru   rv   rw   s      rE   rx   z,ReplacementPane.__init__.<locals>.<dictcomp>8  s-    2h2h2hDAqVW[a[gVgVg1aVgVgVgrF   )r   _kwargsrL   rM   r;   rJ  	_internalr   r}   _inner_layoutr~   r  rs   r   _update_inner_layoutr)   _sync_layout)rN   rk   r   rP   s   ` `rE   rM   zReplacementPane.__init__2  s    1 1 1 1 14<< 1 1 1**6***4[[
#DJii2h2hFLLNN2h2h2hii ''JT6Z=M8N8NOO	
 	
 	
 	rF   r]   r-   r   r/  r   r   r   r1   r.   c                    |r+|j         d         }|| j        v r|                     |           | j                            ||||          }|p|}||f| j        |j         d         <   |S )Nr   )r   r   _cleanuprR  r   )rN   r]   r   r   r   r   r   s          rE   r   zReplacementPane._get_model>  sv      	$(4.Cdl""d###"--c4FF}u(-vTXd^$rF   rJ  z_pane.sizing_modez_pane.width_policyz_pane.height_policy)r   c                   t          | d          r| j        t          | j        dd          rd S | j        j                            d | j        j                                                                        D                        d S )NrR  ry   Fc                "    i | ]\  }}|d v 	||S ))r   width_policyheight_policyrr   rO  s      rE   rx   z0ReplacementPane._sync_layout.<locals>.<dictcomp>O  s4     )
 )
 )
QDDD qDDDrF   )r7   rJ  rA  rR  rs   r   r   r}   r   s    rE   rT  zReplacementPane._sync_layoutK  s    t_-- 	$*2HWUYU_asuzM{M{2HF '' )
 )
!Z-4466<<>>)
 )
 )
 	 	 	 	 	rF   c                X    | j         j                            d |D                        d S )Nc                (    i | ]}|j         |j        S rr   r   )ru   r   s     rE   rx   z8ReplacementPane._update_inner_layout.<locals>.<dictcomp>U  s     K K K5UY K K KrF   )rJ  rs   r   rN   r   s     rE   rS  z$ReplacementPane._update_inner_layoutT  s0    
 K KF K K KLLLLLrF   oldr$   r   c                X   d}t          |t                    rt                    t          |          k    rt          t	          |                    D ]l\  }\  }}t          |          t          |          ur||<   ,t          |t                    r|j        |         j        |<   |                     ||           m|dz  }t          j
                                                  }i }|j
                                                                        D ]\  }	}
||	         }|	|v s|
|u r	 |
|k    }t          |          s)t          |          st          |t          j                  r|                                }t%          |          }nD# t&          $ r7 	 t)          |
          t)          |          k    }n# t&          $ r d}Y nw xY wY nw xY w|s|
||	<   t          t*                    rvt-          fd|D                       }|_        	 t          j                  5   j
        j        di | ddd           n# 1 swxY w Y   d_        dS # d_        w xY wt          j                  5   j
        j        di | ddd           dS # 1 swxY w Y   dS )a  
        Recursively descends through Panel layouts and diffs their
        contents updating only changed parameters ensuring we don't
        have to trigger a full re-render of the entire component.

        Arguments
        ---------
        old: Reactive
          The Reactive component being updated or replaced.
        new: Reactive
          The new Reactive component that the old one is being updated
          or replaced with.
        )r4   )objectsFc              3  *   K   | ]}|j         v V  d S rK   )rl   )ru   r   r^  s     rE   r   z4ReplacementPane._recursive_update.<locals>.<genexpr>  s+      II1 44IIIIIIrF   Nrr   )r6   r   r@   r   zipr9   r   _names_recursive_updater   rs   r   r}   r'   r(   npndarrayallr{   r  r   r>   anyry   edit_constantr   )r   r^  r   ignoredr   sub_oldsub_newpvals
new_paramsr   p_newp_oldequalchangings    `            rE   rd  z!ReplacementPane._recursive_updateW  sw    c9%% 		(3xx3s88##-6s3}}-E-E < <)A)G}}DMM99!$A !#~66 6(+
1
1))'7;;;;<'SY%%''((
	((**0022 	& 	&HAu!HEG||u~~	"&& ()E*:*: (jPRPZ>[>[ (!IIKKEU " " ""*511^E5J5JJEE  " " "!EEE""
  & %
1c8$$ 
	/IIIIjIIIIIH#+C -(-- 3 3$CI$22z2223 3 3 3 3 3 3 3 3 3 3 3 3 3 3 (-$$$u$,,,,$S)) / / 	 ..:.../ / / / / / / / / / / / / / / / / /sy   2A!F
G G ?G GGGGGI ,I?I II II 	I(?JJ#&J#r  was_internalrK  c                   |                                	 t          j                                      }n# t          $ r g }Y nw xY wg }t          t                    r9d t                                                    D             }fd|D             }d |}
}	t          |          u r|s|s|s|rt          t                    rt          |          t                    k    rat          t          |                    D ]B\  }\  }}t          |          t          |          ur|||<   ,|                     ||           Cnt          t                    r|                     |           nY|_        nQt!          fi fd|                                D             }	|	u r|s|s                                }	d}
nd}
n|u}
|	|
fS )Nc                J    g | ] }|                                 D ]	}|D ]}|
!S rr   )r   )ru   	pwatchers	awatchersws       rE   r   z7ReplacementPane._update_from_object.<locals>.<listcomp>  s]       !*!1!1!3!3 Y 89     rF   c                P    g | ]"}|j         vt          |j        d            |#S )_watcher_name)r~   r7   fn)ru   wfnrk   s     rE   r   z7ReplacementPane._update_from_object.<locals>.<listcomp>  sB       3f6P+P+PCFO44 ,Q+P+P+PrF   c                .    i | ]\  }}|j         v ||S rr   )rs   )ru   rv   rw   r#  s      rE   rx   z7ReplacementPane._update_from_object.<locals>.<dictcomp>  s5     $= $= $=TQ'(IO';'; %&q';';';rF   TF)r?   r"   registryr<   r   r6   r$   r&   r   r9   r    r@   r   rb  rd  rk   r;   r}   r  )r   rk   r  rs  rK  rC   linkscustom_watcherswatchersrD   internalr   r^  r   r#  s    `            @rE   _update_from_objectz#ReplacementPane._update_from_object  s[   %%f--		M%%f--EE 	 	 	EEE	fh'' 	 #1&#9#9#@#@#B#B  H   '  O
 |h 
y((5((Ua(fm(&%(( 	+S__F-K-K%.s:v/F/F%G%G 4 4MAzSCyyS		11(+
1 ))#s3333	4
 FH-- +%%j&9999$*
!!  > > $= $= $= $=V\\^^ $= $= $= > >Dv~~
 ( %5 %!<<>>D#HH$HH!3X~s   9 AA
new_objectr   c                    t          | j                                        fi | j        }|d=  | j        || j        | j        fi |\  }}|d S || _        | j        g| j        d d <   || _        d S )Nrk   )r   rs   r   rP  r  rJ  rQ  rR  )rN   r  rC   new_paner  s        rE   _update_innerzReplacementPane._update_inner  s    dj''))::T\::85T5
DN
 
6<
 
( F
!%111!rF   c                ~    | j                             |           t                                          |           d S rK   )rR  rV  rL   )rN   r   rP   s     rE   rV  zReplacementPane._cleanup  s8    ##D)))rF   c                    dS )zD
        Updating of the object should be handled manually.
        Nrr   r]  s     rE   r   zReplacementPane._update_pane  s      rF   selectortype | Callable | NoneList[Viewable]c                    t                                          |          }|| j                            |          z  }|S )a  
        Iterates over the Viewable and any potential children in the
        applying the Selector.

        Arguments
        ---------
        selector: (type | callable | None)
          The selector allows selecting a subset of Viewables by
          declaring a type or callable function to filter by.

        Returns
        -------
        viewables: list(Viewable)
        )rL   selectrR  )rN   r  selectedrP   s      rE   r  zReplacementPane.select  s:     77>>(++D&--h777rF   rK   )rk   r   rD  rE  )r^  r$   r   r$   r   )rk   r   r  r   rs  r{   rK  r{   )r  r   r1   r   )r   r/  r1   r   r$  )r  r  r1   r  )rQ   rR   rS   rT   rs   BooleanrK  r'  rk   r&  r+   rJ  rI  r(  r   rj   rf   _ReplacementPane__abstractrM   r   dependsrT  rS  r+  rd  r  r  rV  r   r  rU   rV   s   @rE   rH  rH    s          emE 01 2 2 2G U_Te B   F  ExEBBBE.9M9999355555<@T2R2RGRRRRHJ
 
 
 
 
 
 
 379=     U]7/1EG\dhiii  jiM M M 5/ 5/ 5/ [5/n / / / / [/b" " " "                   rF   rH  )r0   r   r1   r+   )MrT   
__future__r   	functoolsr   typingr   r   r   r   r	   r
   r   r   r   r   r   numpyre  rs   bokeh.modelsr   bokeh.models.layoutsr   r   r   r   r   r   _paramr   io.cacher   io.documentr   r   io.notebookr   io.stater   layout.baser   r   r   r    r!   r  r"   modelsr#   r   reactiver$   utilr%   r&   util.checksr'   r(   r   r)   r*   r+   r,   bokeh.documentr-   bokeh.modelr.   pyviz_commsr/   r;   r   rH   rW   r>   r-  rH  rr   rF   rE   <module>r     s    # " " " " "                               
      + + + + + +                % % % % % % = = = = = = = =                                4 4 4 4 4 4       . . . . . . . . 1 1 1 1 1 1 1 1             !''''''!!!!!!      . . . .b    L    GCz"""tO tO tO tO tOx tO tO tOn15 15 15 15 15 15 15 15h\ \ \ \ \h \ \ \ \ \rF   