
    -e/                        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 dd	lmZ erdd
lmZ dZddZe	dd            ZddZg aded<   dS )z

    )annotationsN)contextmanager)TYPE_CHECKINGIteratorcast   )Document   )curstate)UnlockedDocumentProxy)curdocpatch_curdoc
set_curdocreturnr	   c                     t          t                    dk    r:t          d                     } | t          d          t          t          |           S t                      j        S )z Return the document for the current default state.

    Returns:
        Document : the current default document object.

    r   Nz,Patched curdoc has been previously destroyed)len_PATCHED_CURDOCSRuntimeErrorr   r	   r   documentdocs    ,lib/python3.11/site-packages/bokeh/io/doc.pyr   r   1   sY     q  r"$$;MNNNHc"""::    r    Document | UnlockedDocumentProxyIterator[None]c              #     K   t                               t          j        |                      ~ dV  t                                            dS )a2   Temporarily override the value of ``curdoc()`` and then return it to
    its original state.

    This context manager is useful for controlling the value of ``curdoc()``
    while invoking functions (e.g. callbacks). The cont

    Args:
        doc (Document) : new Document to use for ``curdoc()``

    N)r   appendweakrefrefpopr   s    r   r   r   C   sJ       GK,,---	EEEr   Nonec                ,    | t                      _        dS )z Configure the current document (returned by curdoc()).

    Args:
        doc (Document) : new Document to use for curdoc()

    Returns:
        None

    .. warning::
        Calling this function will replace any existing document.

    N)r   r   r   s    r   r   r   U   s     HJJr   z=list[weakref.ReferenceType[Document | UnlockedDocumentProxy]]r   )r   r	   )r   r   r   r   )r   r	   r   r"   )__doc__
__future__r   logging	getLogger__name__logr   
contextlibr   typingr   r   r   r   r	   stater   document.lockingr   __all__r   r   r   r   __annotations__ r   r   <module>r1      s)     # " " " " " g!!  % % % % % % 0 0 0 0 0 0 0 0 0 0              9888888   $    "   & SU  T T T T T Tr   