from collections.abc import Sequence
from types import MappingProxyType
from typing import (
    Any,
    TypedDict,
)

# Works on Python 3.11+
try:
    from typing import NotRequired
except ImportError:
    # Fallback for Python < 3.11 (or if you want to ensure typing_extensions is used)
    from typing_extensions import NotRequired

from qgis.core import Qgis

MappingQgisGeometryType = MappingProxyType(
    {
        Qgis.GeometryType.Point: "point",
        Qgis.GeometryType.Line: "line",
        Qgis.GeometryType.Polygon: "polygon",
        Qgis.GeometryType.Unknown: "unknown",
        Qgis.GeometryType.Null: "none",
    }
)


class ModelItem(TypedDict):
    wType: str
    type: str
    default: Any
    always_export: NotRequired[bool]
    use_proper_boolean: NotRequired[bool]
    list: NotRequired[Sequence]
    tooltip: NotRequired[str]
    isMetadata: NotRequired[bool]
    children: NotRequired[str]
    parent: NotRequired[str]
    comment: NotRequired[str]
    max_version: NotRequired[str]
    min_version: NotRequired[str]
    exclusive: NotRequired[bool]
    _api: NotRequired[bool]
