from typing import Any

from django.core.paginator import Page, Paginator
from django.db import models
from django.db.models.options import Options
from django.http import HttpRequest, HttpResponse
from django.utils.functional import cached_property
from django.views import View
from django.views.generic.base import ContextMixin, TemplateResponseMixin
from django.views.generic.list import BaseListView
from wagtail.admin.active_filters import ActiveFilter
from wagtail.admin.forms.search import SearchForm
from wagtail.admin.ui.tables import Column, Table
from wagtail.admin.widgets.button import Button
import django_filters

class WagtailAdminTemplateMixin(TemplateResponseMixin, ContextMixin):
    page_title: str
    page_subtitle: str
    header_icon: str
    breadcrumbs_items: list[dict[str, Any]]
    template_name: str | list[str] | tuple[str, ...]
    header_buttons: list[Button]
    header_more_buttons: list[Button]
    def get_page_title(self) -> str: ...
    def get_page_subtitle(self) -> str: ...
    def get_header_title(self) -> str: ...
    def get_header_icon(self) -> str: ...
    def get_breadcrumbs_items(self) -> list[dict[str, Any]]: ...
    def get_header_buttons(self) -> list[Button]: ...
    def get_header_more_buttons(self) -> list[Button]: ...
    def get_context_data(self, **kwargs: Any) -> dict[str, Any]: ...
    def get_template_names(self) -> list[str]: ...

class BaseObjectMixin:
    model: type[models.Model] | None
    pk_url_kwarg: str
    pk: str
    object: models.Model
    model_opts: Options
    def setup(self, request: HttpRequest, *args: Any, **kwargs: Any) -> None: ...
    def get_pk(self) -> str: ...
    def get_base_object_queryset(self) -> models.QuerySet[models.Model]: ...
    def get_object(self) -> models.Model: ...

class BaseOperationView(BaseObjectMixin, View):
    success_message: str | None
    success_message_extra_tags: str
    success_url_name: str | None
    next_url: str | None
    def setup(self, request: HttpRequest, *args: Any, **kwargs: Any) -> None: ...
    def perform_operation(self) -> None: ...
    def get_success_message(self) -> str | None: ...
    def add_success_message(self) -> None: ...
    def get_success_url(self) -> str: ...
    def post(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...

class BaseListingView(WagtailAdminTemplateMixin, BaseListView):
    template_name: str | list[str] | tuple[str, ...]
    results_template_name: str | list[str] | tuple[str, ...]
    results_only: bool
    table_class: type[Table]
    table_classname: str | None
    columns: list[Column]
    index_url_name: str | None
    index_results_url_name: str | None
    page_kwarg: str
    is_searchable: bool | None
    search_kwarg: str
    search_fields: list[str] | None
    search_backend_name: str
    default_ordering: str | None
    filterset_class: type[django_filters.FilterSet] | None
    verbose_name_plural: str | None
    paginator_class: type[Paginator]
    def get_template_names(self) -> list[str]: ...
    def get_breadcrumbs_items(self) -> list[dict[str, Any]]: ...
    def get_search_form(self) -> SearchForm | None: ...
    @cached_property
    def search_form(self) -> SearchForm | None: ...
    @cached_property
    def search_query(self) -> str: ...
    @cached_property
    def is_searching(self) -> bool: ...
    def search_queryset(self, queryset: models.QuerySet[models.Model]) -> models.QuerySet[models.Model]: ...
    @cached_property
    def filters(self) -> django_filters.FilterSet | None: ...
    @cached_property
    def is_filtering(self) -> bool: ...
    def get_filterset_kwargs(self) -> dict[str, Any]: ...
    def filter_queryset(self, queryset: models.QuerySet[models.Model]) -> models.QuerySet[models.Model]: ...
    @cached_property
    def active_filters(self) -> list[ActiveFilter]: ...
    def get_valid_orderings(self) -> list[str]: ...
    @cached_property
    def is_explicitly_ordered(self) -> bool: ...
    def get_ordering(self) -> str | None: ...
    @cached_property
    def ordering(self) -> str | None: ...
    def order_queryset(self, queryset: models.QuerySet[models.Model]) -> models.QuerySet[models.Model]: ...
    def get_base_queryset(self) -> models.QuerySet[models.Model]: ...
    def get_queryset(self) -> models.QuerySet[models.Model]: ...
    def paginate_queryset(
        self, queryset: models.QuerySet[models.Model], page_size: int
    ) -> tuple[Paginator, Page, models.QuerySet[models.Model], bool]: ...
    def get_table_kwargs(self) -> dict[str, Any]: ...
    def get_table(self, object_list: models.QuerySet[models.Model]) -> Table: ...
    @cached_property
    def index_url(self) -> str | None: ...
    def get_index_url(self) -> str | None: ...
    @cached_property
    def index_results_url(self) -> str | None: ...
    def get_index_results_url(self) -> str | None: ...
    @cached_property
    def no_results_message(self) -> str: ...
    def get_context_data(self, *args: Any, **kwargs: Any) -> dict[str, Any]: ...
