"""
This type stub file was generated by pyright.
"""

import pyarrow as pa
from collections.abc import Mapping
from enum import Enum
from typing import Final, Literal, TYPE_CHECKING, Union
from typing_extensions import TypeAlias
from streamlit.dataframe_util import DataFormat
from streamlit.elements.lib.column_types import ColumnConfig, ColumnType
from pandas import DataFrame
from streamlit.proto.Arrow_pb2 import Arrow as ArrowProto

if TYPE_CHECKING:
    ...
IndexIdentifierType = Literal["_index"]
INDEX_IDENTIFIER: IndexIdentifierType = ...
_NUMERICAL_POSITION_PREFIX = ...
class ColumnDataKind(str, Enum):
    INTEGER = ...
    FLOAT = ...
    DATE = ...
    TIME = ...
    DATETIME = ...
    BOOLEAN = ...
    STRING = ...
    TIMEDELTA = ...
    PERIOD = ...
    INTERVAL = ...
    BYTES = ...
    DECIMAL = ...
    COMPLEX = ...
    LIST = ...
    DICT = ...
    EMPTY = ...
    UNKNOWN = ...


DataframeSchema: TypeAlias = dict[str, ColumnDataKind]
_EDITING_COMPATIBILITY_MAPPING: Final[dict[ColumnType, list[ColumnDataKind]]] = ...
def is_type_compatible(column_type: ColumnType, data_kind: ColumnDataKind) -> bool:
    """Check if the column type is compatible with the underlying data kind.

    This check only applies to editable column types (e.g. number or text).
    Non-editable column types (e.g. bar_chart or image) can be configured for
    all data kinds (this might change in the future).

    Parameters
    ----------
    column_type : ColumnType
        The column type to check.

    data_kind : ColumnDataKind
        The data kind to check.

    Returns
    -------
    bool
        True if the column type is compatible with the data kind, False otherwise.
    """
    ...

def determine_dataframe_schema(data_df: DataFrame, arrow_schema: pa.Schema) -> DataframeSchema:
    """Determine the schema of a dataframe.

    Parameters
    ----------
    data_df : pd.DataFrame
        The dataframe to determine the schema of.
    arrow_schema : pa.Schema
        The Arrow schema of the dataframe.

    Returns
    -------
    DataframeSchema
        A mapping that contains the detected data type for the index and columns.
        The key is the column name in the underlying dataframe or ``_index`` for index columns.
    """
    ...

ColumnConfigMapping: TypeAlias = dict[Union[IndexIdentifierType, str], ColumnConfig]
ColumnConfigMappingInput: TypeAlias = Mapping[Union[IndexIdentifierType, str], Union[ColumnConfig, None, str],]
def process_config_mapping(column_config: ColumnConfigMappingInput | None = ...) -> ColumnConfigMapping:
    """Transforms a user-provided column config mapping into a valid column config mapping
    that can be used by the frontend.

    Parameters
    ----------
    column_config: dict or None
        The user-provided column config mapping.

    Returns
    -------
    dict
        The transformed column config mapping.
    """
    ...

def update_column_config(column_config_mapping: ColumnConfigMapping, column: str, column_config: ColumnConfig) -> None:
    """Updates the column config value for a single column within the mapping.

    Parameters
    ----------
    column_config_mapping : ColumnConfigMapping
        The column config mapping to update.

    column : str
        The column to update the config value for.

    column_config : ColumnConfig
        The column config to update.
    """
    ...

def apply_data_specific_configs(columns_config: ColumnConfigMapping, data_format: DataFormat) -> None:
    """Apply data specific configurations to the provided dataframe.

    This will apply inplace changes to the dataframe and the column configurations
    depending on the data format.

    Parameters
    ----------
    columns_config : ColumnConfigMapping
        A mapping of column names/ids to column configurations.

    data_format : DataFormat
        The format of the data.
    """
    ...

def marshall_column_config(proto: ArrowProto, column_config_mapping: ColumnConfigMapping) -> None:
    """Marshall the column config into the Arrow proto.

    Parameters
    ----------
    proto : ArrowProto
        The proto to marshall into.

    column_config_mapping : ColumnConfigMapping
        The column config to marshall.
    """
    ...

