# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs
# Based on "crates/store/re_sdk_types/definitions/rerun/blueprint/components/column_order.fbs".

# You can extend this class by creating a "ColumnOrderExt" class in "column_order_ext.py".

from __future__ import annotations

from collections.abc import Sequence
from typing import TYPE_CHECKING, Any

import pyarrow as pa
from attrs import define, field

from ..._baseclasses import (
    BaseBatch,
    ComponentBatchMixin,
    ComponentMixin,
)
from .column_order_ext import ColumnOrderExt

__all__ = ["ColumnOrder", "ColumnOrderArrayLike", "ColumnOrderBatch", "ColumnOrderLike"]


@define(init=False)
class ColumnOrder(ColumnOrderExt, ComponentMixin):
    """
    **Component**: The order of component columns (which remain always grouped by entity path) in the dataframe view.

    Entities not in this list are appended at the end in their default order.
    Entities in this list that are not present in the view are ignored.

    ⚠️ **This type is _unstable_ and may change significantly in a way that the data won't be backwards compatible.**
    """

    _BATCH_TYPE = None

    def __init__(self: Any, entity_paths: ColumnOrderLike) -> None:
        """Create a new instance of the ColumnOrder component."""

        # You can define your own __init__ function as a member of ColumnOrderExt in column_order_ext.py
        self.__attrs_init__(entity_paths=entity_paths)

    entity_paths: list[datatypes.EntityPath] = field()

    def __len__(self) -> int:
        # You can define your own __len__ function as a member of ColumnOrderExt in column_order_ext.py
        return len(self.entity_paths)


if TYPE_CHECKING:
    from ... import datatypes

    ColumnOrderLike = ColumnOrder | Sequence[datatypes.EntityPathLike]
    """A type alias for any ColumnOrder-like object."""
else:
    ColumnOrderLike = Any

ColumnOrderArrayLike = ColumnOrder | Sequence[ColumnOrderLike]
"""A type alias for any ColumnOrder-like array object."""


class ColumnOrderBatch(BaseBatch[ColumnOrderArrayLike], ComponentBatchMixin):
    _ARROW_DATATYPE = pa.list_(pa.field("item", pa.utf8(), nullable=False, metadata={}))
    _COMPONENT_TYPE: str = "rerun.blueprint.components.ColumnOrder"

    @staticmethod
    def _native_to_pa_array(data: ColumnOrderArrayLike, data_type: pa.DataType) -> pa.Array:
        return ColumnOrderExt.native_to_pa_array_override(data, data_type)


# This is patched in late to avoid circular dependencies.
ColumnOrder._BATCH_TYPE = ColumnOrderBatch  # type: ignore[assignment]
