Ë
    Eêñi�:  ã            	      óŒ  — 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mZ d dlmZ d dlmZ erd d	lmZ d d
lmZ d dlmZmZ d dlmZ 	 	 	 	 dd„Z	 d	 	 	 	 	 	 	 dd„Zej>                  j@                  ej>                  jB                  ej>                  jD                  ej>                  jF                  ej>                  jH                  ej>                  jJ                  ej>                  jL                  ej>                  jN                  ej>                  jP                  h	Z)	 	 	 	 	 	 dd„Z*	 	 	 	 	 	 dd„Z+ G d„ d«      Z,y)é    )Úannotations)ÚTYPE_CHECKINGÚLiteralÚcast)Údataframe_util)Úcreate_layout_config)Úmarshall_styler)ÚStreamlitAPIExceptionÚStreamlitValueError)ÚTable)Úgather_metrics)ÚData)ÚDeltaGenerator)ÚHeightÚWidth)Ú	ArrowDatac                óè   — t        | t        «      r6| rt        j                  j                  S t        j                  j
                  S | dk(  rt        j                  j                  S t        dg d¢«      ‚)z.Parse and check the user provided border mode.Ú
horizontalÚborder)ÚTrueÚFalsez'horizontal')Ú
isinstanceÚboolÚ
TableProtoÚ
BorderModeÚALLÚNONEÚ
HORIZONTALr   )r   s    úZ/var/www/pod-logistic/pod-ai/venv/lib/python3.12/site-packages/streamlit/elements/table.pyÚparse_border_moder    !   s[   € ô �&œ$ÔÙ,2Œz×$Ñ$×(Ñ(ÐR¼
×8MÑ8M×8RÑ8RÐRØ�ÒÜ×$Ñ$×/Ñ/Ð/Ü
˜hÒ(IÓ
JÐJó    Nc                ó²   — t        j                  |«      r(t        |t        «      st	        d«      ‚t        | ||«       t        j                  |«      | _        y)a\  Marshall data into an ArrowData proto for Table element.

    Parameters
    ----------
    proto : proto.ArrowData
        Output. The protobuf for Streamlit ArrowData proto.

    data : pandas.DataFrame, pandas.Styler, pyarrow.Table, numpy.ndarray, pyspark.sql.DataFrame, snowflake.snowpark.DataFrame, Iterable, dict, or None
        Something that is or can be converted to a dataframe.

    default_uuid : str | None
        If pandas.Styler UUID is not provided, this value will be used.
        This attribute is optional and only used for pandas.Styler, other elements
        can ignore it.

    z.Default UUID must be a string for Styler data.N)r   Úis_pandas_stylerr   Ústrr
   r	   Úconvert_anything_to_arrow_bytesÚdata)Úprotor&   Údefault_uuids      r   Úmarshall_tabler)   ,   sN   € ô( ×&Ñ& tÔ,ô ˜,¬Ô,Ü'Ø@óð ô 	˜˜t \Ô2ä×?Ñ?ÀÓE€E…Jr!   c                ó(  — ddl }|�|S t        j                  | «      rt        j                  | j                  «      S t        | |j                  «      rt        j                  | «      S t        j                  | d¬«      }t        j                  |«      S )a/  Compute whether the index column should be hidden.

    Parameters
    ----------
    data : Data
        The original input data.
    hide_index : bool | None
        The user-provided hide_index value.

    Returns
    -------
    bool
        True if the index should be hidden, False otherwise.
    r   NF)Úensure_copy)Úpandasr   r#   Úhas_range_indexr&   r   Ú	DataFrameÚconvert_anything_to_pandas_df)r&   Ú
hide_indexÚpdÚdfs       r   Ú_compute_hide_indexr3   Z   s~   € ó$ àÐØÐô ×&Ñ& tÔ,ä×-Ñ-¨d¯i©iÓ8Ð8ô �$˜Ÿ™Ô%Ü×-Ñ-¨dÓ3Ð3ô 
×	5Ñ	5°dÈÔ	N€BÜ×)Ñ)¨"Ó-Ð-r!   c                ó   — |�|S | t         v S )aC  Compute whether the column headers should be hidden.

    Parameters
    ----------
    data_format : DataFormat
        The format of the input data.
    hide_header : bool | None
        The user-provided hide_header value.

    Returns
    -------
    bool
        True if headers should be hidden, False otherwise.
    )Ú_HIDE_HEADER_DATA_FORMATS)Údata_formatÚhide_headers     r   Ú_compute_hide_headerr8   €   s   € ð" ÐØÐð Ô3Ð3Ð3r!   c                  óh   — e Zd Z ed«      	 d	ddddddœ	 	 	 	 	 	 	 	 	 	 	 	 	 d
d„«       Zedd„«       Zy)Ú
TableMixinÚtableNTÚstretchÚcontent)r   ÚwidthÚheightr0   r7   c               óú  — t        ||dd¬«      }t        |«      }t        j                  |«      }	t        j                  |«      rt        j
                  |d¬«      }|�|nd}
nt        ||«      }
t        |	|«      }| j                  j                  «       }t        t        |«      «      }t        «       }t        |j                  ||«       ||_        |
|_        ||_        | j                  j%                  d||¬«      S )u‚  Display a static table.

        While ``st.dataframe`` is geared towards large datasets and interactive
        data exploration, ``st.table`` is useful for displaying small, styled
        tables without sorting or scrolling. For example, ``st.table`` may be
        the preferred way to display a confusion matrix or leaderboard.
        Additionally, ``st.table`` supports Markdown.

        Parameters
        ----------
        data : Anything supported by st.dataframe
            The table data.

            All cells including the index and column headers can optionally
            contain GitHub-flavored Markdown. Syntax information can be found
            at: https://github.github.com/gfm.

            See the ``body`` parameter of |st.markdown|_ for additional,
            supported Markdown directives.

            .. |st.markdown| replace:: ``st.markdown``
            .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown

        border : bool or "horizontal"
            Whether to show borders around the table and between cells. This can be one
            of the following:

            - ``True`` (default): Show borders around the table and between cells.
            - ``False``: Don't show any borders.
            - ``"horizontal"``: Show only horizontal borders between rows.

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

            - ``"stretch"`` (default): The width of the element matches the
              width of the parent container.
            - ``"content"``: The width of the element matches the width of its
              content, but doesn't exceed 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.

            Row index columns are sticky only when the content overflows a
            specified integer width. Otherwise, they aren't sticky.

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

            - ``"content"`` (default): The height of the element matches the
              height of its content, showing all rows.
            - ``"stretch"``: The height of the element expands to fill the
              available vertical space in its parent container. When multiple
              elements with stretch height are in the same container, they
              share the available vertical space evenly.
            - An integer specifying the height in pixels: The element has a
              fixed height. If the table content exceeds this height,
              scrolling is enabled with sticky headers.

        hide_index : bool or None
            Whether to hide the index column. This can be one of the following
            values:

            - ``None`` (default): Hide the index column if it's a default
              ``RangeIndex``. Show custom indices.
            - ``True``: Always hide the index column.
            - ``False``: Always show the index column.

        hide_header : bool or None
            Whether to hide the column header row. This can be one of the
            following values:

            - ``None`` (default): Auto-hide headers for data formats without
              user-defined column names, like ``dict``, ``list``, and
              ``numpy.ndarray``. Show headers for data with explicit column
              names, like ``pandas.DataFrame``.
            - ``True``: Always hide the column header row, including all levels
              of ``MultiIndex`` headers.
            - ``False``: Always show the column header row.

        Examples
        --------
        **Example 1: Display a confusion matrix as a static table**

        .. code-block:: python
            :filename: streamlit_app.py

            import pandas as pd
            import streamlit as st

            confusion_matrix = pd.DataFrame(
                {
                    "Predicted Cat": [85, 3, 2, 1],
                    "Predicted Dog": [2, 78, 4, 0],
                    "Predicted Bird": [1, 5, 72, 3],
                    "Predicted Fish": [0, 2, 1, 89],
                },
                index=["Actual Cat", "Actual Dog", "Actual Bird", "Actual Fish"],
            )
            st.table(confusion_matrix)

        .. output::
           https://doc-table-confusion.streamlit.app/
           height: 250px

        **Example 2: Display a product leaderboard with Markdown and horizontal borders**

        .. code-block:: python
            :filename: streamlit_app.py

            import streamlit as st

            product_data = {
                "Product": [
                    ":material/devices: Widget Pro",
                    ":material/smart_toy: Smart Device",
                    ":material/inventory: Premium Kit",
                ],
                "Category": [":blue[Electronics]", ":green[IoT]", ":violet[Bundle]"],
                "Stock": ["ðŸŸ¢ Full", "ðŸŸ¡ Low", "ðŸ”´ Empty"],
                "Units sold": [1247, 892, 654],
                "Revenue": [125000, 89000, 98000],
            }
            st.table(product_data, border="horizontal")

        .. output::
           https://doc-table-horizontal-border.streamlit.app/
           height: 200px

        **Example 3: Display a scrollable table with fixed height**

        .. code-block:: python
            :filename: streamlit_app.py

            import pandas as pd
            import streamlit as st
            from numpy.random import default_rng as rng

            df = pd.DataFrame(
                rng(0).standard_normal((50, 5)), columns=["A", "B", "C", "D", "E"]
            )
            st.table(df, height=300)

        **Example 4: Display key-value data**

        .. code-block:: python
            :filename: streamlit_app.py

            import streamlit as st

            st.table(
                {
                    ":material/folder: Project": "**Streamlit** - The fastest way to build data apps",
                    ":material/code: Repository": "[github.com/streamlit/streamlit](https://github.com/streamlit/streamlit)",
                    ":material/new_releases: Version": ":gray-badge[1.45.0]",
                    ":material/license: License": ":green-badge[Apache 2.0]",
                    ":material/group: Maintainers": ":blue-badge[Core Team] :violet-badge[Community]",
                },
                border="horizontal",
                width="content",
            )

        .. output::
           https://doc-table-auto-header.streamlit.app/
           height: 250px

        **Example 5: Display a minimal table without index and headers**

        .. code-block:: python
            :filename: streamlit_app.py

            import pandas as pd
            import streamlit as st

            df = pd.DataFrame({"Name": ["Alice", "Bob"], "Age": [25, 30]})
            st.table(df, hide_index=True, hide_header=True)

        .. output::
           https://doc-table-hide-header-and-index.streamlit.app/
           height: 200px

        T)r>   r?   Úallow_content_widthÚallow_content_heightéd   )Úmax_unevaluated_rowsr;   )Úlayout_config)r   r    r   Údetermine_data_formatÚis_unevaluated_data_objectr/   r3   r8   ÚdgÚ_get_delta_path_strr$   Úhashr   r)   Ú
arrow_dataÚborder_moder0   r7   Ú_enqueue)Úselfr&   r   r>   r?   r0   r7   rE   rL   r6   Úshould_hide_indexÚshould_hide_headerÚ
delta_pathr(   r'   s                  r   r;   zTableMixin.table™   sû   € ôB -ØØØ $Ø!%ô	
ˆô (¨Ó/ˆô %×:Ñ:¸4Ó@ˆô ×4Ñ4°TÔ:Ü!×?Ñ?Ø¨3ôˆDð
 /9Ð.D¡
È$Ñô !4°D¸*Ó EÐô 2°+¸{ÓKÐð
 —W‘W×0Ñ0Ó2ˆ
Üœ4 
Ó+Ó,ˆä“ˆÜ�u×'Ñ'¨¨|Ô<Ø'ˆÔØ,ˆÔØ.ˆÔØ�w‰w×Ñ ¨¸mÐÓLÐLr!   c                ó   — t        d| «      S )zGet our DeltaGenerator.r   )r   )rN   s    r   rH   zTableMixin.dg†  s   € ô Ð$ dÓ+Ð+r!   ©N)r&   r   r   úbool | Literal['horizontal']r>   r   r?   r   r0   úbool | Noner7   rU   Úreturnr   )rV   r   )Ú__name__Ú
__module__Ú__qualname__r   r;   ÚpropertyrH   © r!   r   r:   r:   ˜   s¡   „ Ù�GÓð ðjMð 04Ø Ø"Ø"&Ø#'ñjMàðjMð -ð	jMð
 ðjMð ðjMð  ðjMð !ðjMð 
òjMó ðjMðX ò,ó ñ,r!   r:   )r   rT   rV   zTableProto.BorderMode.ValueTyperS   )r'   ÚArrowDataProtor&   r   r(   z
str | NonerV   ÚNone)r&   r   r0   rU   rV   r   )r6   zdataframe_util.DataFormatr7   rU   rV   r   )-Ú
__future__r   Útypingr   r   r   Ú	streamlitr   Ú#streamlit.elements.lib.layout_utilsr   Ú*streamlit.elements.lib.pandas_styler_utilsr	   Ústreamlit.errorsr
   r   Ústreamlit.proto.Table_pb2r   r   Ústreamlit.runtime.metrics_utilr   Ústreamlit.dataframe_utilr   Ústreamlit.delta_generatorr   r   r   Ústreamlit.proto.ArrowData_pb2r   r\   r    r)   Ú
DataFormatÚKEY_VALUE_DICTÚLIST_OF_ROWSÚLIST_OF_VALUESÚ
NUMPY_LISTÚNUMPY_MATRIXÚSET_OF_VALUESÚTUPLE_OF_VALUESÚPANDAS_ARRAYÚPYARROW_ARRAYr5   r3   r8   r:   r[   r!   r   ú<module>rs      sU  ðõ #ç /Ñ /å $Ý DÝ Fß GÝ 9Ý 9áÝ-Ý8ßAÝIðKØ(ðKà$óKð CGðFØðFØ!%ðFØ5?ðFà	óFðD ×Ñ×,Ñ,Ø×Ñ×*Ñ*Ø×Ñ×,Ñ,Ø×Ñ×(Ñ(Ø×Ñ×*Ñ*Ø×Ñ×+Ñ+Ø×Ñ×-Ñ-Ø×Ñ×*Ñ*Ø×Ñ×+Ñ+ð
Ð ð#.Ø
ð#.àð#.ð 
ó#.ðL4Ø*ð4Ø9Dð4à	ó4÷0q,ò q,r!   