from typing import Any

from django.db import models
from django.forms import Form
from django.http import HttpRequest, HttpResponse, JsonResponse
from django.http.request import QueryDict
from django.utils.functional import cached_property
from django.views.generic import TemplateView, View
from wagtail.blocks.base import Block

from .permissions import PermissionCheckedMixin

class PreviewOnEdit(PermissionCheckedMixin, View):
    model: type[models.Model] | None
    form_class: type[Form] | None
    http_method_names: tuple[str, ...]
    preview_expiration_timeout: int
    session_key_prefix: str
    permission_required: str
    object: models.Model
    def setup(self, request: HttpRequest, *args: Any, **kwargs: Any) -> None: ...
    def dispatch(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...
    def remove_old_preview_data(self) -> None: ...
    @property
    def session_key(self) -> str: ...
    def get_object(self) -> models.Model: ...
    def get_form_class(self) -> type[Form]: ...
    def get_form(self, query_dict: QueryDict | None) -> Form: ...
    def _get_data_from_session(self) -> QueryDict: ...
    def validate_form(self, form: Form) -> bool: ...
    def post(self, request: HttpRequest, *args: Any, **kwargs: Any) -> JsonResponse: ...
    def error_response(self) -> HttpResponse: ...
    def get(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...
    def delete(self, request: HttpRequest, *args: Any, **kwargs: Any) -> JsonResponse: ...

class PreviewOnCreate(PreviewOnEdit):
    permission_required: str
    @property
    def session_key(self) -> str: ...
    def get_object(self) -> models.Model: ...

class PreviewRevision(View):
    model: type[models.Model] | None
    http_method_names: tuple[str, ...]
    pk: str
    revision_id: int
    object: models.Model
    revision_object: models.Model
    def setup(self, request: HttpRequest, pk: str, revision_id: int, *args: Any, **kwargs: Any) -> None: ...
    def get_object(self) -> models.Model: ...
    def get_revision_object(self) -> models.Model: ...
    def get(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...

class StreamFieldBlockPreview(TemplateView):
    http_method_names: tuple[str, ...]
    @cached_property
    def block_id(self) -> str | None: ...
    @cached_property
    def block_def(self) -> Block: ...
    @cached_property
    def block_value(self) -> Any: ...
    @cached_property
    def page_title(self) -> str: ...
    @cached_property
    def base_context(self) -> dict[str, Any]: ...
    def get_template_names(self) -> list[str]: ...
    def get_context_data(self, **kwargs: Any) -> dict[str, Any]: ...
