
    g                        d dl mZ d dlmZ d dlmZ d dlmZ 	 	 	 	 	 	 	 	 ddZ	 	 	 	 ddZ	 G d d      Z
 G d	 d
e
      Z G d de
      Zy)    )annotations)Any)util)get_script_run_ctxc                P    | g}|j                  |       |j                  |       |S N)extendappend)root_containerparent_pathindex
delta_paths       E/var/www/openai/venv/lib/python3.12/site-packages/streamlit/cursor.pymake_delta_pathr      s.     !!Jk"e    c                    | yt               }|y| |j                  v r|j                  |    S t        |       }||j                  | <   |S )zReturn the top-level RunningCursor for the given container.
    This is the cursor that is used when user code calls something like
    `st.foo` (which uses the main container) or `st.sidebar.foo` (which uses
    the sidebar container).
    N)r   )r   cursorsRunningCursor)r   ctxcursors      r   get_container_cursorr       sU     

C
{${{>**.9F"(CKKMr   c                      e Zd ZdZddZedd       Zedd       Zedd       Zedd       Z	edd       Z
ddZedd	       Zy
)CursorzA pointer to a delta location in the app.

    When adding an element to the app, you should always call
    get_locked_cursor() on that element's respective Cursor.
    c                ,    t        j                  |       S r   )r   repr_selfs    r   __repr__zCursor.__repr__?   s    zz$r   c                    t               )zwThe top-level container this cursor lives within - either
        RootContainer.MAIN or RootContainer.SIDEBAR.
        NotImplementedErrorr   s    r   r   zCursor.root_containerB   s    
 "##r   c                    t               )z0The cursor's parent's path within its container.r    r   s    r   r   zCursor.parent_pathI        "##r   c                    t               )z/The index of the Delta within its parent block.r    r   s    r   r   zCursor.indexN   r#   r   c                X    t        | j                  | j                  | j                        S )zrThe complete path of the delta pointed to by this cursor - its
        container, parent path, and index.
        )r   r   r   r   r   s    r   r   zCursor.delta_pathS   s#    
 t22D4D4DdjjQQr   c                    t               r   r    r   s    r   	is_lockedzCursor.is_lockedZ   s    !##r   c                    t               r   r    r   propss     r   get_locked_cursorzCursor.get_locked_cursor^   s    !##r   c                    t               )zOther data in this cursor. This is a temporary measure that will go
        away when we implement improved return values for elements.

        This is only implemented in LockedCursor.
        r    r   s    r   r*   zCursor.propsa   s     "##r   N)returnstrr-   intr-   tuple[int, ...])r-   	list[int]r-   boolr-   LockedCursorr-   r   )__name__
__module____qualname____doc__r   propertyr   r   r   r   r'   r+   r*    r   r   r   r   8   s      $ $ $ $ $ $ R R $ $$ $ $r   r   c                  f    e Zd Zdd	dZed
d       Zedd       Zed
d       Zedd       ZddZ	y)r   c                .    || _         || _        d| _        y)a  A moving pointer to a delta location in the app.

        RunningCursors auto-increment to the next available location when you
        call get_locked_cursor() on them.

        Parameters
        ----------
        root_container: int
            The root container this cursor lives in.
        parent_path: tuple of ints
          The full path of this cursor, consisting of the IDs of all ancestors.
          The 0th item is the topmost ancestor.

        r   N)_root_container_parent_path_index)r   r   r   s      r   __init__zRunningCursor.__init__l   s      .'r   c                    | j                   S r   rA   r   s    r   r   zRunningCursor.root_container       ###r   c                    | j                   S r   rB   r   s    r   r   zRunningCursor.parent_path          r   c                    | j                   S r   rC   r   s    r   r   zRunningCursor.index       {{r   c                     y)NFr>   r   s    r   r'   zRunningCursor.is_locked   s    r   c                    t        d| j                  | j                  | j                  d|}| xj                  dz  c_        |S )N)r   r   r      r>   )r7   rA   rB   rC   )r   r*   locked_cursors      r   r+   zRunningCursor.get_locked_cursor   sJ    $ 
//))++
 	
 	qr   N)r>   )r   r0   r   r2   r/   r1   r4   r6   )
r9   r:   r;   rD   r=   r   r   r   r'   r+   r>   r   r   r   r   k   s\    & $ $ ! !    
r   r   c                      e Zd Z	 	 d		 	 	 	 	 d
dZedd       Zedd       Zedd       Zedd       ZddZ	edd       Z
y)r7   c                <    || _         || _        || _        || _        y)a  A locked pointer to a location in the app.

        LockedCursors always point to the same location, even when you call
        get_locked_cursor() on them.

        Parameters
        ----------
        root_container: int
            The root container this cursor lives in.
        parent_path: tuple of ints
          The full path of this cursor, consisting of the IDs of all ancestors. The
          0th item is the topmost ancestor.
        index: int
        **props: any
          Anything else you want to store in this cursor. This is a temporary
          measure that will go away when we implement improved return values
          for elements.

        N)rA   rC   rB   _props)r   r   r   r   r*   s        r   rD   zLockedCursor.__init__   s"    4  .'r   c                    | j                   S r   rF   r   s    r   r   zLockedCursor.root_container   rG   r   c                    | j                   S r   rI   r   s    r   r   zLockedCursor.parent_path   rJ   r   c                    | j                   S r   rL   r   s    r   r   zLockedCursor.index   rM   r   c                     y)NTr>   r   s    r   r'   zLockedCursor.is_locked   s    r   c                    || _         | S r   rT   r)   s     r   r+   zLockedCursor.get_locked_cursor   s    r   c                    | j                   S r   rZ   r   s    r   r*   zLockedCursor.props   rM   r   N)r>   r   )r   r0   r   r2   r   r0   r/   r1   r4   r6   r8   )r9   r:   r;   rD   r=   r   r   r   r'   r+   r*   r>   r   r   r7   r7      s     (*	 % 	> $ $ ! !      r   r7   N)r   r0   r   r2   r   r0   r-   r3   )r   z
int | Noner-   zRunningCursor | None)
__future__r   typingr   	streamlitr   7streamlit.runtime.scriptrunner_utils.script_run_contextr   r   r   r   r   r7   r>   r   r   <module>r`      sq    #   V&5>A00$ 0$f.F .b66 6r   