from collections.abc import Callable
from typing import Any

from django import forms
from django.contrib.auth.models import Permission
from django.db import models
from django.db.models import Options, QuerySet
from django.forms import BaseModelForm
from django.http.response import HttpResponseBase
from django.urls import URLPattern
from django.utils.functional import cached_property
from wagtail.admin.admin_url_finder import ModelAdminURLFinder
from wagtail.admin.filters import WagtailFilterSet
from wagtail.admin.menu import MenuItem
from wagtail.admin.panels.group import ObjectList
from wagtail.admin.ui.tables import Column
from wagtail.admin.views import generic
from wagtail.admin.views.generic import history, usage
from wagtail.admin.viewsets.base import ViewSet, ViewSetGroup
from wagtail.permissions import ModelPermissionPolicy

class ModelViewSet(ViewSet):
    add_to_reference_index: bool
    sort_order_field: str | None
    index_view_class: type[generic.IndexView]
    add_view_class: type[generic.CreateView]
    edit_view_class: type[generic.EditView]
    delete_view_class: type[generic.DeleteView]
    history_view_class: type[history.HistoryView]
    usage_view_class: type[usage.UsageView]
    copy_view_class: type[generic.CopyView]
    inspect_view_class: type[generic.InspectView]
    template_prefix: str
    list_per_page: int
    ordering: str | list[str] | tuple[str, ...] | None
    inspect_view_enabled: bool
    inspect_view_fields: list[str]
    inspect_view_fields_exclude: list[str]
    copy_view_enabled: bool
    model: type[models.Model]
    model_opts: Options[models.Model]
    app_label: str
    model_name: str
    def __init__(self, name: str | None = None, **kwargs: Any) -> None: ...
    @property
    def permission_policy(self) -> ModelPermissionPolicy: ...
    @cached_property
    def name(self) -> str: ...  # type: ignore[override]
    def get_common_view_kwargs(self, **kwargs: Any) -> dict[str, Any]: ...
    def get_index_view_kwargs(self, **kwargs: Any) -> dict[str, Any]: ...
    def get_add_view_kwargs(self, **kwargs: Any) -> dict[str, Any]: ...
    def get_edit_view_kwargs(self, **kwargs: Any) -> dict[str, Any]: ...
    def get_delete_view_kwargs(self, **kwargs: Any) -> dict[str, Any]: ...
    def get_history_view_kwargs(self, **kwargs: Any) -> dict[str, Any]: ...
    def get_usage_view_kwargs(self, **kwargs: Any) -> dict[str, Any]: ...
    def get_inspect_view_kwargs(self, **kwargs: Any) -> dict[str, Any]: ...
    def get_copy_view_kwargs(self, **kwargs: Any) -> dict[str, Any]: ...
    @property
    def index_view(self) -> Callable[..., HttpResponseBase]: ...
    @property
    def index_results_view(self) -> Callable[..., HttpResponseBase]: ...
    @property
    def add_view(self) -> Callable[..., HttpResponseBase]: ...
    @property
    def edit_view(self) -> Callable[..., HttpResponseBase]: ...
    @property
    def delete_view(self) -> Callable[..., HttpResponseBase]: ...
    @property
    def history_view(self) -> Callable[..., HttpResponseBase]: ...
    @property
    def history_results_view(self) -> Callable[..., HttpResponseBase]: ...
    @property
    def usage_view(self) -> Callable[..., HttpResponseBase]: ...
    @property
    def inspect_view(self) -> Callable[..., HttpResponseBase]: ...
    @property
    def copy_view(self) -> Callable[..., HttpResponseBase]: ...
    def get_templates(self, name: str = "index", fallback: str = "") -> list[str]: ...
    @cached_property
    def index_template_name(self) -> list[str]: ...
    @cached_property
    def index_results_template_name(self) -> list[str]: ...
    @cached_property
    def create_template_name(self) -> list[str]: ...
    @cached_property
    def edit_template_name(self) -> list[str]: ...
    @cached_property
    def delete_template_name(self) -> list[str]: ...
    @cached_property
    def history_template_name(self) -> list[str]: ...
    @cached_property
    def inspect_template_name(self) -> list[str]: ...
    @cached_property
    def list_display(self) -> list[str | Column]: ...
    @cached_property
    def list_filter(self) -> list[str] | None: ...
    @cached_property
    def filterset_class(self) -> type[WagtailFilterSet]: ...
    @cached_property
    def search_fields(self) -> list[str] | None: ...
    @cached_property
    def search_backend_name(self) -> str | None: ...
    @cached_property
    def list_export(self) -> list[str]: ...
    @cached_property
    def export_headings(self) -> dict[str, str]: ...
    @cached_property
    def export_filename(self) -> str: ...
    @cached_property
    def menu_label(self) -> str: ...
    @cached_property
    def menu_item_class(self) -> type[MenuItem]: ...
    def formfield_for_dbfield(self, db_field: models.Field[Any, Any], **kwargs: Any) -> forms.Field | None: ...
    def get_form_class(self, for_update: bool = False) -> type[BaseModelForm]: ...
    def get_form_fields(self) -> list[str] | None: ...
    def get_exclude_form_fields(self) -> list[str] | None: ...
    def get_edit_handler(self) -> ObjectList | None: ...
    @cached_property
    def _edit_handler(self) -> ObjectList | None: ...
    @property
    def url_finder_class(self) -> type[ModelAdminURLFinder]: ...
    def register_admin_url_finder(self) -> None: ...
    def register_reference_index(self) -> None: ...
    def get_permissions_to_register(self) -> QuerySet[Permission]: ...
    def register_permissions(self) -> None: ...
    def get_urlpatterns(self) -> list[URLPattern]: ...
    def on_register(self) -> None: ...

class ModelViewSetGroup(ViewSetGroup):
    def get_app_label_from_subitems(self) -> str: ...
    @cached_property
    def menu_label(self) -> str: ...
