import logging
import types

from django.core.mail import EmailBackend
from wagtail.coreutils import camelcase_to_underscore as camelcase_to_underscore
from wagtail.models import (
    AbstractGroupApprovalTask as AbstractGroupApprovalTask,
)
from wagtail.models import (
    Page as Page,
)
from wagtail.models import (
    TaskState as TaskState,
)
from wagtail.models import (
    WorkflowState as WorkflowState,
)
from wagtail.users.models import UserProfile as UserProfile

logger: logging.Logger

class OpenedConnection:
    connection: EmailBackend
    def __init__(self, connection) -> None: ...
    def __enter__(self): ...
    def __exit__(
        self, type: type[BaseException] | None, value: BaseException | None, traceback: types.TracebackType | None
    ): ...

def send_mail(subject, message, recipient_list, from_email=None, **kwargs): ...
def send_notification(recipient_users, notification, extra_context): ...

class Notifier:
    notification: str
    template_directory: str
    valid_classes: tuple[type, ...]
    def __init__(self, valid_classes) -> None: ...
    def can_handle(self, instance, **kwargs): ...
    def get_valid_recipients(self, instance, **kwargs): ...
    def get_template_base_prefix(self, instance, **kwargs): ...
    def get_context(self, instance, **kwargs): ...
    def get_template_set(self, instance, **kwargs): ...
    def send_notifications(self, template_set, context, recipients, **kwargs) -> None: ...
    def __call__(self, instance=None, **kwargs): ...

class EmailNotificationMixin:
    def get_recipient_users(self, instance, **kwargs): ...
    def get_valid_recipients(self, instance, **kwargs): ...
    def get_template_set(self, instance, **kwargs): ...
    def send_emails(self, template_set, context, recipients, **kwargs): ...
    def send_notifications(self, template_set, context, recipients, **kwargs): ...

class BaseWorkflowStateEmailNotifier(EmailNotificationMixin, Notifier):
    def __init__(self) -> None: ...
    def get_context(self, workflow_state: WorkflowState, **kwargs): ...

class WorkflowStateApprovalEmailNotifier(BaseWorkflowStateEmailNotifier):
    notification: str
    def get_recipient_users(self, workflow_state: WorkflowState, **kwargs): ...

class WorkflowStateRejectionEmailNotifier(BaseWorkflowStateEmailNotifier):
    notification: str
    def get_recipient_users(self, workflow_state: WorkflowState, **kwargs): ...
    def get_context(self, workflow_state, **kwargs): ...

class WorkflowStateSubmissionEmailNotifier(BaseWorkflowStateEmailNotifier):
    notification: str
    def get_recipient_users(self, workflow_state: WorkflowState, **kwargs): ...
    def get_context(self, workflow_state, **kwargs): ...

class BaseGroupApprovalTaskStateEmailNotifier(EmailNotificationMixin, Notifier):
    def __init__(self) -> None: ...
    def can_handle(self, instance, **kwargs): ...
    def get_context(self, task_state, **kwargs): ...
    def get_recipient_users(self, task_state: TaskState, **kwargs): ...

class GroupApprovalTaskStateSubmissionEmailNotifier(BaseGroupApprovalTaskStateEmailNotifier):
    notification: str
