# DO NOT EDIT THIS FILE!
#
# This code is generated off of PyCDP modules. If you need to make
# changes, edit the generator and regenerate all of the modules.

from __future__ import annotations
import typing

from ..context import get_connection_context, get_session_context

import cdp.dom_snapshot
from cdp.dom_snapshot import (
    ArrayOfStrings,
    ComputedStyle,
    DOMNode,
    DocumentSnapshot,
    InlineTextBox,
    LayoutTreeNode,
    LayoutTreeSnapshot,
    NameValue,
    NodeTreeSnapshot,
    RareBooleanData,
    RareIntegerData,
    RareStringData,
    Rectangle,
    StringIndex,
    TextBoxSnapshot
)


async def capture_snapshot(
        computed_styles: typing.List[str],
        include_dom_rects: typing.Optional[bool] = None
    ) -> typing.Tuple[typing.List[DocumentSnapshot], typing.List[str]]:
    '''
    Returns a document snapshot, including the full DOM tree of the root node (including iframes,
    template contents, and imported documents) in a flattened array, as well as layout and
    white-listed computed style information for the nodes. Shadow DOM in the returned DOM tree is
    flattened.

    :param computed_styles: Whitelist of computed styles to return.
    :param include_dom_rects: *(Optional)* Whether to include DOM rectangles (offsetRects, clientRects, scrollRects) into the snapshot
    :returns: A tuple with the following items:

        0. **documents** – The nodes in the DOM tree. The DOMNode at index 0 corresponds to the root document.
        1. **strings** – Shared string table that all string properties refer to with indexes.
    '''
    session = get_session_context('dom_snapshot.capture_snapshot')
    return await session.execute(cdp.dom_snapshot.capture_snapshot(computed_styles, include_dom_rects))


async def disable() -> None:
    '''
    Disables DOM snapshot agent for the given page.
    '''
    session = get_session_context('dom_snapshot.disable')
    return await session.execute(cdp.dom_snapshot.disable())


async def enable() -> None:
    '''
    Enables DOM snapshot agent for the given page.
    '''
    session = get_session_context('dom_snapshot.enable')
    return await session.execute(cdp.dom_snapshot.enable())


async def get_snapshot(
        computed_style_whitelist: typing.List[str],
        include_event_listeners: typing.Optional[bool] = None,
        include_paint_order: typing.Optional[bool] = None,
        include_user_agent_shadow_tree: typing.Optional[bool] = None
    ) -> typing.Tuple[typing.List[DOMNode], typing.List[LayoutTreeNode], typing.List[ComputedStyle]]:
    '''
Returns a document snapshot, including the full DOM tree of the root node (including iframes,
template contents, and imported documents) in a flattened array, as well as layout and
white-listed computed style information for the nodes. Shadow DOM in the returned DOM tree is
flattened.

.. deprecated:: 1.3

:param computed_style_whitelist: Whitelist of computed styles to return.
:param include_event_listeners: *(Optional)* Whether or not to retrieve details of DOM listeners (default false).
:param include_paint_order: *(Optional)* Whether to determine and include the paint order index of LayoutTreeNodes (default false).
:param include_user_agent_shadow_tree: *(Optional)* Whether to include UA shadow tree in the snapshot (default false).
:returns: A tuple with the following items:

    0. **domNodes** – The nodes in the DOM tree. The DOMNode at index 0 corresponds to the root document.
    1. **layoutTreeNodes** – The nodes in the layout tree.
    2. **computedStyles** – Whitelisted ComputedStyle properties for each node in the layout tree.


.. deprecated:: 1.3
'''
    session = get_session_context('dom_snapshot.get_snapshot')
    return await session.execute(cdp.dom_snapshot.get_snapshot(computed_style_whitelist, include_event_listeners, include_paint_order, include_user_agent_shadow_tree))
