"""
This file is generated by generator/run.py based on the Chrome DevTools Protocol.

Audits domain allows investigation of page violations and possible improvements.
https://chromedevtools.github.io/devtools-protocol/tot/Audits/

***************************************************
                    Methods
***************************************************
"""
from __future__ import annotations

from typing import Literal

from cdpkit.protocol._types import (
    Audits,
    Network,
)
from cdpkit.protocol.base import CDPMethod, InputModel, OutputModel


class GetEncodedResponseInput(InputModel):

    requestId: Network.RequestId
    encoding: Literal['webp', 'jpeg', 'png']
    quality: float | None = None
    sizeOnly: bool | None = None


class GetEncodedResponseOutput(OutputModel):

    body: str | None = None
    originalSize: int
    encodedSize: int


class GetEncodedResponse(CDPMethod[GetEncodedResponseOutput]):
    """ Returns the response body and size if it were re-encoded with the specified settings. Only
    applies to images. """

    INPUT_VALIDATOR = GetEncodedResponseInput
    OUTPUT_VALIDATOR = GetEncodedResponseOutput

    def __init__(
        self,
        *,
        request_id: Network.RequestId,
        encoding: Literal['webp', 'jpeg', 'png'],
        quality: float | None = None,
        size_only: bool | None = None
    ):
        super().__init__(
            requestId=request_id,
            encoding=encoding,
            quality=quality,
            sizeOnly=size_only
        )


class Disable(CDPMethod[None]):
    """ Disables issues domain, prevents further issues from being reported to the client. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class Enable(CDPMethod[None]):
    """ Enables issues domain, sends the issues collected so far to the client by means of the
    `issueAdded` event. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class CheckContrastInput(InputModel):

    reportAAA: bool | None = None


class CheckContrast(CDPMethod[None]):
    """ Runs the contrast check for the target page. Found issues are reported
    using Audits.issueAdded event. """

    INPUT_VALIDATOR = CheckContrastInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        report_aaa: bool | None = None
    ):
        super().__init__(
            reportAAA=report_aaa
        )


class CheckFormsIssuesOutput(OutputModel):

    formIssues: list[Audits.GenericIssueDetails]


class CheckFormsIssues(CDPMethod[CheckFormsIssuesOutput]):
    """ Runs the form issues check for the target page. Found issues are reported
    using Audits.issueAdded event. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = CheckFormsIssuesOutput
