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


https://chromedevtools.github.io/devtools-protocol/tot/Accessibility/

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

from cdpkit.protocol._types import (
    DOM,
    Accessibility,
    Page,
    Runtime,
)
from cdpkit.protocol.base import CDPMethod, InputModel, OutputModel


class Disable(CDPMethod[None]):
    """ Disables the accessibility domain. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class Enable(CDPMethod[None]):
    """ Enables the accessibility domain which causes `AXNodeId`s to remain consistent between method calls.
    This turns on accessibility for the page, which can impact performance until accessibility is disabled. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class GetPartialAXTreeInput(InputModel):

    nodeId: DOM.NodeId | None = None
    backendNodeId: DOM.BackendNodeId | None = None
    objectId: Runtime.RemoteObjectId | None = None
    fetchRelatives: bool | None = None


class GetPartialAXTreeOutput(OutputModel):

    nodes: list[Accessibility.AXNode]


class GetPartialAXTree(CDPMethod[GetPartialAXTreeOutput]):  # experimental
    """ Fetches the accessibility node and partial accessibility tree for this DOM node, if it exists. """

    INPUT_VALIDATOR = GetPartialAXTreeInput
    OUTPUT_VALIDATOR = GetPartialAXTreeOutput

    def __init__(
        self,
        *,
        node_id: DOM.NodeId | None = None,
        backend_node_id: DOM.BackendNodeId | None = None,
        object_id: Runtime.RemoteObjectId | None = None,
        fetch_relatives: bool | None = None
    ):
        super().__init__(
            nodeId=node_id,
            backendNodeId=backend_node_id,
            objectId=object_id,
            fetchRelatives=fetch_relatives
        )


class GetFullAXTreeInput(InputModel):

    depth: int | None = None
    frameId: Page.FrameId | None = None


class GetFullAXTreeOutput(OutputModel):

    nodes: list[Accessibility.AXNode]


class GetFullAXTree(CDPMethod[GetFullAXTreeOutput]):  # experimental
    """ Fetches the entire accessibility tree for the root Document """

    INPUT_VALIDATOR = GetFullAXTreeInput
    OUTPUT_VALIDATOR = GetFullAXTreeOutput

    def __init__(
        self,
        *,
        depth: int | None = None,
        frame_id: Page.FrameId | None = None
    ):
        super().__init__(
            depth=depth,
            frameId=frame_id
        )


class GetRootAXNodeInput(InputModel):

    frameId: Page.FrameId | None = None


class GetRootAXNodeOutput(OutputModel):

    node: Accessibility.AXNode


class GetRootAXNode(CDPMethod[GetRootAXNodeOutput]):  # experimental
    """ Fetches the root node.
    Requires `enable()` to have been called previously. """

    INPUT_VALIDATOR = GetRootAXNodeInput
    OUTPUT_VALIDATOR = GetRootAXNodeOutput

    def __init__(
        self,
        *,
        frame_id: Page.FrameId | None = None
    ):
        super().__init__(
            frameId=frame_id
        )


class GetAXNodeAndAncestorsInput(InputModel):

    nodeId: DOM.NodeId | None = None
    backendNodeId: DOM.BackendNodeId | None = None
    objectId: Runtime.RemoteObjectId | None = None


class GetAXNodeAndAncestorsOutput(OutputModel):

    nodes: list[Accessibility.AXNode]


class GetAXNodeAndAncestors(CDPMethod[GetAXNodeAndAncestorsOutput]):  # experimental
    """ Fetches a node and all ancestors up to and including the root.
    Requires `enable()` to have been called previously. """

    INPUT_VALIDATOR = GetAXNodeAndAncestorsInput
    OUTPUT_VALIDATOR = GetAXNodeAndAncestorsOutput

    def __init__(
        self,
        *,
        node_id: DOM.NodeId | None = None,
        backend_node_id: DOM.BackendNodeId | None = None,
        object_id: Runtime.RemoteObjectId | None = None
    ):
        super().__init__(
            nodeId=node_id,
            backendNodeId=backend_node_id,
            objectId=object_id
        )


class GetChildAXNodesInput(InputModel):

    id: Accessibility.AXNodeId
    frameId: Page.FrameId | None = None


class GetChildAXNodesOutput(OutputModel):

    nodes: list[Accessibility.AXNode]


class GetChildAXNodes(CDPMethod[GetChildAXNodesOutput]):  # experimental
    """ Fetches a particular accessibility node by AXNodeId.
    Requires `enable()` to have been called previously. """

    INPUT_VALIDATOR = GetChildAXNodesInput
    OUTPUT_VALIDATOR = GetChildAXNodesOutput

    def __init__(
        self,
        *,
        id_: Accessibility.AXNodeId,
        frame_id: Page.FrameId | None = None
    ):
        super().__init__(
            id=id_,
            frameId=frame_id
        )


class QueryAXTreeInput(InputModel):

    nodeId: DOM.NodeId | None = None
    backendNodeId: DOM.BackendNodeId | None = None
    objectId: Runtime.RemoteObjectId | None = None
    accessibleName: str | None = None
    role: str | None = None


class QueryAXTreeOutput(OutputModel):

    nodes: list[Accessibility.AXNode]


class QueryAXTree(CDPMethod[QueryAXTreeOutput]):  # experimental
    """ Query a DOM node's accessibility subtree for accessible name and role.
    This command computes the name and role for all nodes in the subtree, including those that are
    ignored for accessibility, and returns those that match the specified name and role. If no DOM
    node is specified, or the DOM node does not exist, the command returns an error. If neither
    `accessibleName` or `role` is specified, it returns all the accessibility nodes in the subtree. """

    INPUT_VALIDATOR = QueryAXTreeInput
    OUTPUT_VALIDATOR = QueryAXTreeOutput

    def __init__(
        self,
        *,
        node_id: DOM.NodeId | None = None,
        backend_node_id: DOM.BackendNodeId | None = None,
        object_id: Runtime.RemoteObjectId | None = None,
        accessible_name: str | None = None,
        role: str | None = None
    ):
        super().__init__(
            nodeId=node_id,
            backendNodeId=backend_node_id,
            objectId=object_id,
            accessibleName=accessible_name,
            role=role
        )
