o
    Yh$                     @  s   d dl mZ d dlZd dlZd dlmZmZ d dlmZm	Z	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mZmZ erJd d	lmZ dddZG dd dZdS )    )annotationsN)ChainMapUserDict)TYPE_CHECKINGAnycast)LayoutConfigWidthWithoutContentvalidate_width)Json)gather_metrics)is_custom_dictis_list_likeis_namedtupleis_pydantic_model)DeltaGeneratoroobjectreturnstr | list[Any]c                 C  s   t | tr	t| S t| S )z\A repr function for json.dumps default arg, which tries to serialize sets
    as lists.
    )
isinstancesetlistrepr)r    r   X/var/www/html/Persson_Maskin/env/lib/python3.10/site-packages/streamlit/elements/json.py_ensure_serialization(   s   r   c                   @  s4   e Zd ZedddddddZedddZdS )	JsonMixinjsonTstretch)expandedwidthbodyr   r    
bool | intr!   r	   r   r   c             
   C  s&  t |r| }t|r| }t|ttjtfst	|r!t
|}t|r)t|}t|ts\z	tj|td}W n$ ty[ } z| jd| d tj|dtd}W Y d}~nd}~ww t }||_t|trk||_nt|trwd|_||_n
tdt| dt| t|d	}| jjd
||dS )a  Display an object or string as a pretty-printed, interactive JSON string.

        Parameters
        ----------
        body : object or str
            The object to print as JSON. All referenced objects should be
            serializable to JSON as well. If object is a string, we assume it
            contains serialized JSON.

        expanded : bool or int
            The initial expansion state of the JSON element. This can be one
            of the following:

            - ``True`` (default): The element is fully expanded.
            - ``False``: The element is fully collapsed.
            - An integer: The element is expanded to the depth specified. The
              integer must be non-negative. ``expanded=0`` is equivalent to
              ``expanded=False``.

            Regardless of the initial expansion state, users can collapse or
            expand any key-value pair to show or hide any part of the object.

        width : "stretch" or int
            The width of the JSON element. This can be one of the following:

            - ``"stretch"`` (default): The width of the element matches the
              width of the parent container.
            - An integer specifying the width in pixels: The element has a
              fixed width. If the specified width is greater than the width of
              the parent container, the width of the element matches the width
              of the parent container.

        Example
        -------
        >>> import streamlit as st
        >>>
        >>> st.json(
        ...     {
        ...         "foo": "bar",
        ...         "stuff": [
        ...             "stuff 1",
        ...             "stuff 2",
        ...             "stuff 3",
        ...         ],
        ...         "level1": {"level2": {"level3": {"a": "b"}}},
        ...     },
        ...     expanded=2,
        ... )

        .. output::
           https://doc-json.streamlit.app/
           height: 385px

        )defaultzqWarning: this data structure was not fully serializable as JSON due to one or more unexpected keys.  (Error was: )T)skipkeysr$   Nz	The type z5 of `expanded` is not supported, must be bool or int.)r!   r   )layout_config)r   to_dictr   _asdictr   r   typesMappingProxyTyper   r   dictr   r   strr   dumpsr   	TypeErrordgwarning	JsonProtor"   boolr    intmax_expand_depthtyper
   r   _enqueue)selfr"   r    r!   err
json_protor'   r   r   r   r   0   sJ   ?



zJsonMixin.jsonc                 C  s
   t d| S )zGet our DeltaGenerator.r   )r   )r8   r   r   r   r0      s   
zJsonMixin.dgN)r"   r   r    r#   r!   r	   r   r   )r   r   )__name__
__module____qualname__r   r   propertyr0   r   r   r   r   r   /   s    jr   )r   r   r   r   )
__future__r   r   r*   collectionsr   r   typingr   r   r   #streamlit.elements.lib.layout_utilsr   r	   r
   streamlit.proto.Json_pb2r   r2   streamlit.runtime.metrics_utilr   streamlit.type_utilr   r   r   r   streamlit.delta_generatorr   r   r   r   r   r   r   <module>   s   
