
    4iZ                       U d dl mZ d dlZd dlmZ d dlmZmZmZm	Z	m
Z
mZmZmZ d dlmZ d dlmZ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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, d dl-m.Z. erd dl/m0Z0m1Z1 d dl2m3Z3 d dl4m5Z5 dd d d ddiZ6de7d<   e	d   Z8de7d<   ddhZ9de7d<   	 	 	 	 d-d Z: G d! d"ed#$      Z; G d% d&ed#$      Z<e G d' d(             Z= G d) d*      Z>d.d+Z?d/d,Z@y)0    )annotationsN)	dataclass)TYPE_CHECKINGAnyFinalLiteral	TypeAlias	TypedDictcastoverload)config)make_deprecated_name_warningshow_deprecation_warning)current_form_id)HeightWithoutContentLayoutConfigWidthWithoutContentvalidate_heightvalidate_width)check_widget_policies)Keycompute_and_register_element_idto_key)StreamlitAPIException)DeckGlJsonChart)gather_metrics)get_script_run_ctx)WidgetCallbackregister_widget)AttributeDictionary)IterableMapping)Deck)DeltaGeneratorinitialViewState   )latitude	longitudepitchzoomzFinal[Mapping[str, Any]]	EMPTY_MAP)single-objectmulti-objectr	   SelectionModer,   r-   zFinal[set[SelectionMode]]_SELECTION_MODESc                   t        | t              r| h}nt        d|  dd      |j                  t              st        d|  dt               |j                  ddh      rt        d      g }|D ]`  }|dk(  r*|j                  t        j                  j                         2|dk(  s8|j                  t        j                  j                         b t        |      S )z2Parse and check the user provided selection modes.zInvalid selection mode: z. z=Selection mode must be a single value, but got a set instead.z. Valid options are: r,   r-   zPOnly one of `single-object` or `multi-object` can be selected as selection mode.)
isinstancestrr   issubsetr/   
issupersetappendPydeckProtor.   SINGLE_OBJECTMULTI_OBJECTset)selection_modeselection_mode_setparsed_selection_modesmodes       o/home/obispo/Crisostomo_bridge/mision_env/lib/python3.12/site-packages/streamlit/elements/deck_gl_json_chart.pyparse_selection_moder?   K   s     .#&,- $&~&6b9K
 	

 &&'78#&~&6 7""2!35
 	

 $$o~%FG#^
 	
  " R?""))+*C*C*Q*QR^#"))+*C*C*P*PQ	R
 %&&    c                  &    e Zd ZU dZded<   ded<   y)PydeckSelectionStatea3  
    The schema for the PyDeck chart selection state.

    The selection state is stored in a dictionary-like object that supports
    both key and attribute notation. Selection states cannot be
    programmatically changed or set through Session State.

    You must define ``id`` in ``pydeck.Layer`` to ensure statefulness when
    using selections with ``st.pydeck_chart``.

    Attributes
    ----------
    indices : dict[str, list[int]]
        A dictionary of selected objects by layer. Each key in the dictionary
        is a layer id, and each value is a list of object indices within that
        layer.
    objects : dict[str, list[dict[str, Any]]]
        A dictionary of object attributes by layer. Each key in the dictionary
        is a layer id, and each value is a list of metadata dictionaries for
        the selected objects in that layer.

    Examples
    --------
    The following example has multi-object selection enabled. The chart
    displays US state capitals by population (2023 US Census estimate). You
    can access this `data
    <https://github.com/streamlit/docs/blob/main/python/api-examples-source/data/capitals.csv>`_
    from GitHub.

    >>> import streamlit as st
    >>> import pydeck
    >>> import pandas as pd
    >>>
    >>> capitals = pd.read_csv(
    ...     "capitals.csv",
    ...     header=0,
    ...     names=[
    ...         "Capital",
    ...         "State",
    ...         "Abbreviation",
    ...         "Latitude",
    ...         "Longitude",
    ...         "Population",
    ...     ],
    ... )
    >>> capitals["size"] = capitals.Population / 10
    >>>
    >>> point_layer = pydeck.Layer(
    ...     "ScatterplotLayer",
    ...     data=capitals,
    ...     id="capital-cities",
    ...     get_position=["Longitude", "Latitude"],
    ...     get_color="[255, 75, 75]",
    ...     pickable=True,
    ...     auto_highlight=True,
    ...     get_radius="size",
    ... )
    >>>
    >>> view_state = pydeck.ViewState(
    ...     latitude=40, longitude=-117, controller=True, zoom=2.4, pitch=30
    ... )
    >>>
    >>> chart = pydeck.Deck(
    ...     point_layer,
    ...     initial_view_state=view_state,
    ...     tooltip={"text": "{Capital}, {Abbreviation}\nPopulation: {Population}"},
    ... )
    >>>
    >>> event = st.pydeck_chart(chart, on_select="rerun", selection_mode="multi-object")
    >>>
    >>> event.selection

    .. output::
        https://doc-pydeck-event-state-selections.streamlit.app/
        height: 700px

    This is an example of the selection state when selecting a single object
    from a layer with id, ``"captial-cities"``:

    >>> {
    >>>   "indices":{
    >>>     "capital-cities":[
    >>>       2
    >>>     ]
    >>>   },
    >>>   "objects":{
    >>>     "capital-cities":[
    >>>       {
    >>>         "Abbreviation":" AZ"
    >>>         "Capital":"Phoenix"
    >>>         "Latitude":33.448457
    >>>         "Longitude":-112.073844
    >>>         "Population":1650070
    >>>         "State":" Arizona"
    >>>         "size":165007.0
    >>>       }
    >>>     ]
    >>>   }
    >>> }

    zdict[str, list[int]]indiceszdict[str, list[dict[str, Any]]]objectsN__name__
__module____qualname____doc____annotations__ r@   r>   rB   rB   p   s    dL "!,,r@   rB   F)totalc                      e Zd ZU dZded<   y)PydeckStateaQ  
    The schema for the PyDeck event state.

    The event state is stored in a dictionary-like object that supports both
    key and attribute notation. Event states cannot be programmatically changed
    or set through Session State.

    Only selection events are supported at this time.

    Attributes
    ----------
    selection : dict
        The state of the ``on_select`` event. This attribute returns a
        dictionary-like object that supports both key and attribute notation.
        The attributes are described by the ``PydeckSelectionState``
        dictionary schema.

    rB   	selectionNrE   rK   r@   r>   rN   rN      s    & $#r@   rN   c                       e Zd ZdZddZddZy)PydeckSelectionSerdezUPydeckSelectionSerde is used to serialize and deserialize the Pydeck selection state.c                x    di i di}||nt        j                  |      }d|vr|}t        dt        |            S )NrO   )rC   rD   rN   )jsonloadsr   r    )selfui_valueempty_selection_stateselection_states       r>   deserializez PydeckSelectionSerde.deserialize   sU    .
 &.%5!4::h;O 	 o-3OM#6#GHHr@   c                8    t        j                  |t              S )N)default)rS   dumpsr2   )rU   rX   s     r>   	serializezPydeckSelectionSerde.serialize
  s    zz/377r@   N)rV   z
str | NonereturnrN   )rX   rN   r^   r2   )rF   rG   rH   rI   rY   r]   rK   r@   r>   rQ   rQ      s    _I(8r@   rQ   c            	          e Zd Ze	 dddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Ze	 dddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd	       Z ed
      	 dddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Zedd       Zy)PydeckMixinNstretchi  )widthuse_container_widthheightkeyc                    y NrK   rU   
pydeck_objrb   rc   rd   r:   	on_selectre   s           r>   pydeck_chartzPydeckMixin.pydeck_chart  s     r@   r,   rerun)rb   rc   rd   r:   rj   re   c                    y rg   rK   rh   s           r>   rk   zPydeckMixin.pydeck_chart  s     r@   rk   ignorec          
        |t        t        ddddd      d       |rd	}t        |d
       t        |d
       t	               }t               }	|t        j                  t              n|j                         }
|
|_        t        |      }|rt        j                  |      |_        t        |dd      }||dk(  rt        j                  d      }|r||_        t!        |      }|dk7  }|dvrt#        |      st%        d| d      |r|j&                  j)                  t+        |             t#        |      }t-        | j.                  ||rt1        d|      nddd|       t3        | j.                        |_        t7        d|d| j.                  ||||
      |_        t;               }t=        |j8                  |	|j>                  t#        |      r|nd|j@                  d      }tC        ||      }| j.                  jE                  d||       |jF                  S tC        ||      }| j.                  jE                  d||      S )a}   Draw a chart using the PyDeck library.

        This supports 3D maps, point clouds, and more! More info about PyDeck
        at https://deckgl.readthedocs.io/en/latest/.

        These docs are also quite useful:

        - DeckGL docs: https://github.com/uber/deck.gl/tree/master/docs
        - DeckGL JSON docs: https://github.com/uber/deck.gl/tree/master/modules/json

        When using this command, a service called Carto_ provides the map tiles to render
        map content. If you're using advanced PyDeck features you may need to obtain
        an API key from Carto first. You can do that as
        ``pydeck.Deck(api_keys={"carto": YOUR_KEY})`` or by setting the CARTO_API_KEY
        environment variable. See `PyDeck's documentation`_ for more information.

        Another common provider for map tiles is Mapbox_. If you prefer to use that,
        you'll need to create an account at https://mapbox.com and specify your Mapbox
        key when creating the ``pydeck.Deck`` object. You can do that as
        ``pydeck.Deck(api_keys={"mapbox": YOUR_KEY})`` or by setting the MAPBOX_API_KEY
        environment variable.

        .. _Carto: https://carto.com
        .. _Mapbox: https://mapbox.com
        .. _PyDeck's documentation: https://deckgl.readthedocs.io/en/latest/deck.html

        Carto and Mapbox are third-party products and Streamlit accepts no responsibility
        or liability of any kind for Carto or Mapbox, or for any content or information
        made available by Carto or Mapbox. The use of Carto or Mapbox is governed by
        their respective Terms of Use.

        .. note::
            Pydeck uses two WebGL contexts per chart, and different browsers
            have different limits on the number of WebGL contexts per page.
            If you exceed this limit, the oldest contexts will be dropped to
            make room for the new ones. To avoid this limitation in most
            browsers, don't display more than eight Pydeck charts on a single
            page.

        Parameters
        ----------
        pydeck_obj : pydeck.Deck or None
            Object specifying the PyDeck chart to draw.
        width : "stretch" or int
            The width of the chart 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.

        use_container_width : bool or None
            Whether to override the chart's native width with the width of
            the parent container. This can be one of the following:

            - ``None`` (default): Streamlit will use the chart's default behavior.
            - ``True``: Streamlit sets the width of the chart to match the
              width of the parent container.
            - ``False``: Streamlit sets the width of the chart to fit its
              contents according to the plotting library, up to the width of
              the parent container.

            .. deprecated::
               ``use_container_width`` is deprecated and will be removed in a
                future release. For ``use_container_width=True``, use
                ``width="stretch"``.

        height : "stretch" or int
            The height of the chart element. This can be one of the following:

            - An integer specifying the height in pixels: The element has a
              fixed height. If the content is larger than the specified
              height, scrolling is enabled. This is ``500`` by default.
            - ``"stretch"``: The height of the element matches the height of
              its content or the height of the parent container, whichever is
              larger. If the element is not in a parent container, the height
              of the element matches the height of its content.

        on_select : "ignore" or "rerun" or callable
            How the figure should respond to user selection events. This controls
            whether or not the chart behaves like an input widget.
            ``on_select`` can be one of the following:

            - ``"ignore"`` (default): Streamlit will not react to any selection
              events in the chart. The figure will not behave like an
              input widget.
            - ``"rerun"``: Streamlit will rerun the app when the user selects
              data in the chart. In this case, ``st.pydeck_chart`` will return
              the selection data as a dictionary.
            - A ``callable``: Streamlit will rerun the app and execute the callable
              as a callback function before the rest of the app. In this case,
              ``st.pydeck_chart`` will return the selection data as a
              dictionary.

            If ``on_select`` is not ``"ignore"``, all layers must have a
            declared ``id`` to keep the chart stateful across reruns.
        selection_mode : "single-object" or "multi-object"
            The selection mode of the chart. This can be one of the following:

            - ``"single-object"`` (default): Only one object can be selected at
              a time.
            - ``"multi-object"``: Multiple objects can be selected at a time.

        key : str
            An optional string to use for giving this element a stable
            identity. If ``key`` is ``None`` (default), this element's identity
            will be determined based on the values of the other parameters.

            Additionally, if selections are activated and ``key`` is provided,
            Streamlit will register the key in Session State to store the
            selection state. The selection state is read-only.

        Returns
        -------
        element or dict
            If ``on_select`` is ``"ignore"`` (default), this command returns an
            internal placeholder for the chart element. Otherwise, this method
            returns a dictionary-like object that supports both key and
            attribute notation. The attributes are described by the
            ``PydeckState`` dictionary schema.

        Example
        -------
        Here's a chart using a HexagonLayer and a ScatterplotLayer. It uses either the
        light or dark map style, based on which Streamlit theme is currently active:

        >>> import pandas as pd
        >>> import pydeck as pdk
        >>> import streamlit as st
        >>> from numpy.random import default_rng as rng
        >>>
        >>> df = pd.DataFrame(
        ...     rng(0).standard_normal((1000, 2)) / [50, 50] + [37.76, -122.4],
        ...     columns=["lat", "lon"],
        ... )
        >>>
        >>> st.pydeck_chart(
        ...     pdk.Deck(
        ...         map_style=None,  # Use Streamlit theme to pick map style
        ...         initial_view_state=pdk.ViewState(
        ...             latitude=37.76,
        ...             longitude=-122.4,
        ...             zoom=11,
        ...             pitch=50,
        ...         ),
        ...         layers=[
        ...             pdk.Layer(
        ...                 "HexagonLayer",
        ...                 data=df,
        ...                 get_position="[lon, lat]",
        ...                 radius=200,
        ...                 elevation_scale=4,
        ...                 elevation_range=[0, 1000],
        ...                 pickable=True,
        ...                 extruded=True,
        ...             ),
        ...             pdk.Layer(
        ...                 "ScatterplotLayer",
        ...                 data=df,
        ...                 get_position="[lon, lat]",
        ...                 get_color="[200, 30, 0, 160]",
        ...                 get_radius=200,
        ...             ),
        ...         ],
        ...     )
        ... )

        .. output::
           https://doc-pydeck-chart.streamlit.app/
           height: 530px

        .. note::
           To make the PyDeck chart's style consistent with Streamlit's theme,
           you can set ``map_style=None`` in the ``pydeck.Deck`` object.

        Nrc   rb   z
2025-12-31zqFor `use_container_width=True`, use `width='stretch'`. For `use_container_width=False`, specify an integer width.F)include_st_prefix)show_in_browserra   )allow_content
mapbox_key zmapbox.tokenrn   )rn   rl   zYou have passed zH to `on_select`. But only 'ignore', 'rerun', or a callable is supported.r   )	on_changedefault_valuewrites_allowedenable_check_callback_rulesdeck_gl_json_chart)user_keykey_as_main_identitydgis_selection_activatedr:   rc   specstring_value)ctxdeserializeron_change_handler
serializer
value_type)rb   rd   )layout_config)$r   r   r   r   r6   r   rS   r\   r+   to_json_get_pydeck_tooltiptooltipgetattrr   
get_optionmapbox_tokenr   callabler   r:   extendr?   r   r|   r   r   form_idr   idrQ   r   rY   r]   r   _enqueuevalue)rU   ri   rb   rc   rd   r:   rj   re   pydeck_protor   r~   r   r   r}   is_callbackserdewidget_stater   s                     r>   rk   zPydeckMixin.pydeck_chart,  sX   | *$,) Q&+ !&
 #! 	uE2e4"} "(2(:tzz)$
@R@R@T %j1#'::g#6L 
 z<><2#5!,,^<L(4L%Sk!*h!6//8K'"9+ .J J 
 "''../CN/ST #9-K!?J$/;PT"$,7 $3477#;L =$%*77'=-$7	LO )*E*"../7	/B) ??)L )uVDMGG$l-    %%%$5@ww ,m   
 	
r@   c                    t        d|       S )zGet our DeltaGenerator.r$   )r   )rU   s    r>   r|   zPydeckMixin.dgN  s     $d++r@   rg   )ri   Deck | Nonerb   r   rc   bool | Nonerd   r   r:   zLiteral['single-object']rj   zLiteral['ignore']re   
Key | Noner^   r$   )ri   r   rb   r   rc   r   rd   r   r:   r.   rj   z!Literal['rerun'] | WidgetCallbackre   r   r^   rN   )ri   r   rb   r   rc   r   rd   r   r:   r.   rj   z+Literal['rerun', 'ignore'] | WidgetCallbackre   r   r^   zDeltaGenerator | PydeckState)r^   r$   )rF   rG   rH   r   rk   r   propertyr|   rK   r@   r>   r`   r`     s    #' &/+/'*  #	
 ) %
 %  
   #'
 &/+/'*(77>

 #	

 )
 %
 &
 5
 
 

 
 N# #'_
 &/+/'*(7AI_
_
 #	_

 )_
 %_
 &_
 ?_
 _
 
&_
 $_
B	 , ,r@   r`   c                j    | yt        | dd      }|!t        |t        t        f      rt        |      S y)z:Extract the width from a pydeck Deck object, if specified.Nrb   )r   r1   intfloat)ri   rb   s     r>   _get_pydeck_widthr   T  s9    J.EZU|<5zr@   c                    | y t        | dd       }|&t        |j                  t              r|j                  S t        | dd       }|t        |t              rt	        d|      S y )Ndeck_widget_tooltipzdict[str, str])r   r1   r   dictr   )ri   desk_widgetr   s      r>   r   r   `  sl     *mT:K:k.A.A4#H""" j*d3Gz'48$g..r@   )r:   z'SelectionMode | Iterable[SelectionMode]r^   z(set[PydeckProto.SelectionMode.ValueType])ri   r   r^   z
int | None)ri   r   r^   zdict[str, str] | None)A
__future__r   rS   dataclassesr   typingr   r   r   r   r	   r
   r   r   	streamlitr   streamlit.deprecation_utilr   r   !streamlit.elements.lib.form_utilsr   #streamlit.elements.lib.layout_utilsr   r   r   r   r   streamlit.elements.lib.policiesr   streamlit.elements.lib.utilsr   r   r   streamlit.errorsr   #streamlit.proto.DeckGlJsonChart_pb2r   r6   streamlit.runtime.metrics_utilr   7streamlit.runtime.scriptrunner_utils.script_run_contextr   streamlit.runtime.stater   r   streamlit.utilr    collections.abcr!   r"   pydeckr#   streamlit.delta_generatorr$   r+   rJ   r.   r/   r?   rB   rN   rQ   r`   r   r   rK   r@   r>   <module>r      s   #  !	 	 	  >  B U U 2 N 9 V /18
 QQAN'	#  ##BCy C/ + "';"'-"'Jh-9E h-V$)5 $. 8 8 86C, C,L
	r@   