
    -e@                    $   d Z ddlmZ ddlZ ej        e          ZddlmZ ddl	m
Z
mZ e
r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lmZ ddlmZ ddlmZ ddlmZmZm Z  e
rddl!m"Z" ddlm#Z# ddl$m%Z% dZ&d+dZ'di fd,d$Z(	 d-d.d*Z)dS )/z: Generate various HTML elements from Bokeh render items.

    )annotationsN)escape)TYPE_CHECKINGAny)Template   )serialize_json)DOC_JSFILEMACROSPLOT_DIVget_env)DEFAULT_TITLE)settings)make_id   )
RenderItem)wrap_in_onloadwrap_in_safelywrap_in_script_tag)ID)DocJson)Bundle)div_for_render_itemhtml_page_for_render_itemsscript_for_render_itemsitemr   returnstrc                8    t          j        | t                    S )z Render an HTML div for a Bokeh render item.

    Args:
        item (RenderItem):
            the item to create a div for

    Returns:
        str

    )docmacros)r   renderr   )r   s    4lib/python3.11/site-packages/bokeh/embed/elements.pyr   r   E   s     ?tF3333    bundleBundle | tuple[str, str]	docs_jsondict[ID, DocJson]render_itemslist[RenderItem]titletemplateTemplate | str | Nonetemplate_variablesdict[str, Any]c                   |t           }| \  }}t                      }t          t          |          d          }	t	          |	d|          }	t	          t          ||                    }
|                                }|                    t          ||||	|
z   |t          t                               t          |          dk    r!|d         d         |d	<   |d	         j        |d
<   d                    d |D                       |d<   |t          }n9t          |t                    r$t!                                          d|z             }|                    |          }|S )a   Render an HTML page from a template and Bokeh render items.

    Args:
        bundle (tuple):
            a tuple containing (bokehjs, bokehcss)

        docs_json (JSON-like):
            Serialized Bokeh Document

        render_items (RenderItems)
            Specific items to render from the document and where

        title (str or None)
            A title for the HTML page. If None, DEFAULT_TITLE is used

        template (str or Template or None, optional) :
            A Template to be used for the HTML page. If None, FILE is used.

        template_variables (dict, optional):
            Any Additional variables to pass to the template

    Returns:
        str

    NFquotezapplication/json)r,   bokeh_js	bokeh_cssplot_scriptdocsbaser"   r   r7   r   r!   roots
c              3  4   K   | ]}t          |          V  d S )N)r   .0r   s     r$   	<genexpr>z-html_page_for_render_items.<locals>.<genexpr>   s+      #W#W$$7$=$=#W#W#W#W#W#Wr%   plot_divz{% extends base %}
)r   r   r   r	   r   r   copyupdatedictr   r   lenr9   join
isinstancer   r   from_stringr#   )r&   r(   r*   r,   r-   r/   r4   r5   json_idjsonscriptcontexthtmls                r$   r   r   R   sh   8 } HiiiG.++5999Dd$6@@D 7 N NOOF %%''GNN4Vm      <A +"5>/ ))#W#W,#W#W#WWWGJ	Hc	"	" L99(()?()JKK??7##DKr%   docs_json_or_idID | dict[ID, DocJson]app_path
str | Noneabsolute_urlc                   t          | t                    rd|  d}nVt          | d          }t          |d          }|                    dd          }|                    dd	          }d|z   dz   }t          j        |t          d
 |D             d          ||          }t          j        st          |          }t          |          S )a8   Render an script for Bokeh render items.
    Args:
        docs_json_or_id:
            can be None

        render_items (RenderItems) :
            Specific items to render from the document and where

        app_path (str, optional) :

        absolute_url (Theme, optional) :

    Returns:
        str
    zdocument.getElementById('z').textContentF)prettyr2   'z&#x27;\z\\c                6    g | ]}|                                 S  )to_jsonr<   s     r$   
<listcomp>z+script_for_render_items.<locals>.<listcomp>   s     $O$O$Odllnn$O$O$Or%   )r(   r*   rN   rP   )rE   r   r	   r   replacer
   r#   r   devr   r   )rL   r*   rN   rP   r(   jss         r$   r   r      s    " /3'' +OOOO		 #?5AAA	9E222	%%c844	%%dF33	9_s*		#$O$O$O$O$OX]^^^!	
 
 
B <  B"r%   )r   r   r   r   )r&   r'   r(   r)   r*   r+   r,   r   r-   r.   r/   r0   r   r   )NN)
rL   rM   r*   r+   rN   rO   rP   rO   r   r   )*__doc__
__future__r   logging	getLogger__name__logrK   r   typingr   r   jinja2r   core.json_encoderr	   core.templatesr
   r   r   r   r   document.documentr   r   util.serializationr   utilr   wrappersr   r   r   
core.typesr   r   r&   r   __all__r   r   r   rV   r%   r$   <module>rl      s    # " " " " " g!!       % % % % % % % %    / . . . . .              . - - - - -       ( ( ( ( ( (       H H H H H H H H H H ++++++4 4 4 4 W[-/@ @ @ @ @F UY( ( ( ( ( ( (r%   