from collections.abc import Callable

from django.contrib.auth.models import AbstractBaseUser
from django.http import HttpRequest, HttpResponse, HttpResponseRedirect
from wagtail.admin import messages as messages
from wagtail.admin.localization import get_localized_response as get_localized_response
from wagtail.log_actions import LogContext as LogContext
from wagtail.permission_policies.base import BasePermissionPolicy
from wagtail.permissions import page_permission_policy as page_permission_policy

type _ViewFunc = Callable[..., HttpResponse]
type _TestFunc = Callable[[AbstractBaseUser], bool]

def permission_denied(request: HttpRequest) -> HttpResponseRedirect: ...
def user_passes_test(test: _TestFunc) -> Callable[[_ViewFunc], _ViewFunc]: ...
def permission_required(permission_name: str) -> Callable[[_ViewFunc], _ViewFunc]: ...
def any_permission_required(*perms: str) -> Callable[[_ViewFunc], _ViewFunc]: ...

class PermissionPolicyChecker:
    policy: BasePermissionPolicy
    def __init__(self, policy: BasePermissionPolicy) -> None: ...
    def require(self, action: str) -> Callable[[_ViewFunc], _ViewFunc]: ...
    def require_any(self, *actions: str) -> Callable[[_ViewFunc], _ViewFunc]: ...

def user_has_any_page_permission(user: AbstractBaseUser) -> bool: ...
def reject_request(request: HttpRequest) -> HttpResponse: ...
def require_admin_access(view_func: _ViewFunc) -> _ViewFunc: ...
