
    /_i                       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mZm	Z	m
Z
mZ d dlmZ erd dlmZmZ  ej"                  d      Z ej"                  d      Z ed      ej(                  	 d	 	 	 dd	              Zdd
ZddZy)    )annotationsN)TYPE_CHECKINGAnyLiteralcast)gather_metrics)	GeneratorIterablez\s*z\s*
echoc              #    K   ddl m}m}m}m} | dk(  r|}|}n |       }|j                  }|j                  }	 t        j                         d   }|j                  |j                  xs d}
}	|j                  |	      5 }|j                         }ddd       t        j                  dj                              }i dfd |       |
   j                  d   j                  dz
  }|
   j                  }||| }t!        j"                  dj                  |            }d  ||d	       y# 1 sw Y   xY w# t$        $ r} |d
|        Y d}~yd}~ww xY ww)a  Use in a `with` block to draw some code on the app, then execute it.

    Parameters
    ----------
    code_location : "above" or "below"
        Whether to show the echoed code before or after the results of the
        executed code block.

    Example
    -------
    >>> import streamlit as st
    >>>
    >>> with st.echo():
    >>>     st.write('This code will be printed')

    r   )codeemptysource_utilwarningbelowN c                    t        | d      sy t        j                  |       D ]0  }t        |d      s|t        d|j                        <    |       2 y )Nbodylinenoint)hasattrastiter_child_nodesr   r   )nodechildcollect_body_statementsline_to_node_maps     V/var/www/html/land_sniper/venv/lib/python3.12/site-packages/streamlit/commands/echo.pyr   z%echo.<locals>.collect_body_statementsN   sR    4(--d3 35(+BG$T%%>?+E2	3       pythonzUnable to display code. )r   zast.ASTreturnNone)	streamlitr   r   r   r   	tracebackextract_stackfilenamer   open_python_file	readlinesr   parsejoinr   
end_linenotextwrapdedentFileNotFoundError)code_locationr   r   r   r   	show_codeshow_warningplaceholderframer(   
start_linesource_filesource_lines	root_nodeecho_block_start_lineecho_block_end_linelines_to_displaycode_stringerrr   r   s                      @@r   r   r   !   sa    * <;	g$$	"**(7 '')"-$~~u||/@q* ))(3 	3{&002L	3 IIbggl34	+-	3 	 	* !1 < A A! D K Ka O.z:EE'(=>QRoobgg.>&?@ 	 	+x(=	3 	3@  7/u5667sH   6EAD> ?D2B!D> 1E2D;7D> >	EEEEEc                4    | D ]  }t        |      }||c S  y)zeReturn the indent of the first non-empty line in the list.
    If all lines are empty, return 0.
    r   )_get_indent)lineslineindents      r   _get_initial_indentrD   k   s-      T"M
 r    c                    t         j                  |       yt        j                  |       }||j                         S dS )zGet the number of whitespaces at the beginning of the given line.
    If the line is empty, or if it contains just whitespace and a newline,
    return None.
    Nr   )_EMPTY_LINE_REmatch
_SPACES_REend)rB   rG   s     r   r@   r@   w   s>    
 D!-T"E+599;22r    )above)r1   zLiteral['above', 'below']r#   zGenerator[None, None, None])rA   zIterable[str]r#   r   )rB   strr#   z
int | None)
__future__r   r   
contextlibrer.   r&   typingr   r   r   r   streamlit.runtime.metrics_utilr   collections.abcr	   r
   compilerH   rF   contextmanagerr   rD   r@    r    r   <module>rU      s    # 
  	   4 4 93RZZ
H% /6E7,E7 E7  E7P		3r    