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

Runtime domain exposes JavaScript runtime by means of remote evaluation and mirror objects.
Evaluation results are returned as mirror object that expose object type, string representation
and unique identifier that can be used for further object reference. Original objects are
maintained in memory unless they are either explicitly released or are released along with the
other objects in their object group.
https://chromedevtools.github.io/devtools-protocol/tot/Runtime/

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

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


class AwaitPromiseInput(InputModel):

    promiseObjectId: Runtime.RemoteObjectId  # deprecated
    returnByValue: bool | None = None  # deprecated
    generatePreview: bool | None = None  # deprecated


class AwaitPromiseOutput(OutputModel):

    result: Runtime.RemoteObject  # deprecated
    exceptionDetails: Runtime.ExceptionDetails | None = None  # deprecated


class AwaitPromise(CDPMethod[AwaitPromiseOutput]):  # deprecated
    """ Add handler to promise with given promise object id. """

    INPUT_VALIDATOR = AwaitPromiseInput
    OUTPUT_VALIDATOR = AwaitPromiseOutput

    def __init__(
        self,
        *,
        promise_object_id: Runtime.RemoteObjectId,
        return_by_value: bool | None = None,
        generate_preview: bool | None = None
    ):
        super().__init__(
            promiseObjectId=promise_object_id,
            returnByValue=return_by_value,
            generatePreview=generate_preview
        )


class CallFunctionOnInput(InputModel):

    functionDeclaration: str  # deprecated
    objectId: Runtime.RemoteObjectId | None = None  # deprecated
    arguments: list[Runtime.CallArgument] | None = None  # deprecated
    silent: bool | None = None  # deprecated
    returnByValue: bool | None = None  # deprecated
    generatePreview: bool | None = None  # experimental deprecated
    userGesture: bool | None = None  # deprecated
    awaitPromise: bool | None = None  # deprecated
    executionContextId: Runtime.ExecutionContextId | None = None  # deprecated
    objectGroup: str | None = None  # deprecated
    throwOnSideEffect: bool | None = None  # experimental deprecated
    uniqueContextId: str | None = None  # experimental deprecated
    serializationOptions: Runtime.SerializationOptions | None = None  # experimental deprecated


class CallFunctionOnOutput(OutputModel):

    result: Runtime.RemoteObject  # deprecated
    exceptionDetails: Runtime.ExceptionDetails | None = None  # deprecated


class CallFunctionOn(CDPMethod[CallFunctionOnOutput]):  # deprecated
    """ Calls function with given declaration on the given object. Object group of the result is
    inherited from the target object. """

    INPUT_VALIDATOR = CallFunctionOnInput
    OUTPUT_VALIDATOR = CallFunctionOnOutput

    def __init__(
        self,
        *,
        function_declaration: str,
        object_id: Runtime.RemoteObjectId | None = None,
        arguments: list[Runtime.CallArgument] | None = None,
        silent: bool | None = None,
        return_by_value: bool | None = None,
        generate_preview: bool | None = None,
        user_gesture: bool | None = None,
        await_promise: bool | None = None,
        execution_context_id: Runtime.ExecutionContextId | None = None,
        object_group: str | None = None,
        throw_on_side_effect: bool | None = None,
        unique_context_id: str | None = None,
        serialization_options: Runtime.SerializationOptions | None = None
    ):
        super().__init__(
            functionDeclaration=function_declaration,
            objectId=object_id,
            arguments=arguments,
            silent=silent,
            returnByValue=return_by_value,
            generatePreview=generate_preview,
            userGesture=user_gesture,
            awaitPromise=await_promise,
            executionContextId=execution_context_id,
            objectGroup=object_group,
            throwOnSideEffect=throw_on_side_effect,
            uniqueContextId=unique_context_id,
            serializationOptions=serialization_options
        )


class CompileScriptInput(InputModel):

    expression: str  # deprecated
    sourceURL: str  # deprecated
    persistScript: bool  # deprecated
    executionContextId: Runtime.ExecutionContextId | None = None  # deprecated


class CompileScriptOutput(OutputModel):

    scriptId: Runtime.ScriptId | None = None  # deprecated
    exceptionDetails: Runtime.ExceptionDetails | None = None  # deprecated


class CompileScript(CDPMethod[CompileScriptOutput]):  # deprecated
    """ Compiles expression. """

    INPUT_VALIDATOR = CompileScriptInput
    OUTPUT_VALIDATOR = CompileScriptOutput

    def __init__(
        self,
        *,
        expression: str,
        source_url: str,
        persist_script: bool,
        execution_context_id: Runtime.ExecutionContextId | None = None
    ):
        super().__init__(
            expression=expression,
            sourceURL=source_url,
            persistScript=persist_script,
            executionContextId=execution_context_id
        )


class Disable(CDPMethod[None]):  # deprecated
    """ Disables reporting of execution contexts creation. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class DiscardConsoleEntries(CDPMethod[None]):  # deprecated
    """ Discards collected exceptions and console API calls. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class Enable(CDPMethod[None]):  # deprecated
    """ Enables reporting of execution contexts creation by means of `executionContextCreated` event.
    When the reporting gets enabled the event will be sent immediately for each existing execution
    context. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class EvaluateInput(InputModel):

    expression: str  # deprecated
    objectGroup: str | None = None  # deprecated
    includeCommandLineAPI: bool | None = None  # deprecated
    silent: bool | None = None  # deprecated
    contextId: Runtime.ExecutionContextId | None = None  # deprecated
    returnByValue: bool | None = None  # deprecated
    generatePreview: bool | None = None  # experimental deprecated
    userGesture: bool | None = None  # deprecated
    awaitPromise: bool | None = None  # deprecated
    throwOnSideEffect: bool | None = None  # experimental deprecated
    timeout: Runtime.TimeDelta | None = None  # experimental deprecated
    disableBreaks: bool | None = None  # experimental deprecated
    replMode: bool | None = None  # experimental deprecated
    allowUnsafeEvalBlockedByCSP: bool | None = None  # experimental deprecated
    uniqueContextId: str | None = None  # experimental deprecated
    serializationOptions: Runtime.SerializationOptions | None = None  # experimental deprecated


class EvaluateOutput(OutputModel):

    result: Runtime.RemoteObject  # deprecated
    exceptionDetails: Runtime.ExceptionDetails | None = None  # deprecated


class Evaluate(CDPMethod[EvaluateOutput]):  # deprecated
    """ Evaluates expression on global object. """

    INPUT_VALIDATOR = EvaluateInput
    OUTPUT_VALIDATOR = EvaluateOutput

    def __init__(
        self,
        *,
        expression: str,
        object_group: str | None = None,
        include_command_line_api: bool | None = None,
        silent: bool | None = None,
        context_id: Runtime.ExecutionContextId | None = None,
        return_by_value: bool | None = None,
        generate_preview: bool | None = None,
        user_gesture: bool | None = None,
        await_promise: bool | None = None,
        throw_on_side_effect: bool | None = None,
        timeout: Runtime.TimeDelta | None = None,
        disable_breaks: bool | None = None,
        repl_mode: bool | None = None,
        allow_unsafe_eval_blocked_by_csp: bool | None = None,
        unique_context_id: str | None = None,
        serialization_options: Runtime.SerializationOptions | None = None
    ):
        super().__init__(
            expression=expression,
            objectGroup=object_group,
            includeCommandLineAPI=include_command_line_api,
            silent=silent,
            contextId=context_id,
            returnByValue=return_by_value,
            generatePreview=generate_preview,
            userGesture=user_gesture,
            awaitPromise=await_promise,
            throwOnSideEffect=throw_on_side_effect,
            timeout=timeout,
            disableBreaks=disable_breaks,
            replMode=repl_mode,
            allowUnsafeEvalBlockedByCSP=allow_unsafe_eval_blocked_by_csp,
            uniqueContextId=unique_context_id,
            serializationOptions=serialization_options
        )


class GetIsolateIdOutput(OutputModel):

    id: str  # deprecated


class GetIsolateId(CDPMethod[GetIsolateIdOutput]):  # experimental deprecated
    """ Returns the isolate id. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = GetIsolateIdOutput


class GetHeapUsageOutput(OutputModel):

    usedSize: float  # deprecated
    totalSize: float  # deprecated
    embedderHeapUsedSize: float  # deprecated
    backingStorageSize: float  # deprecated


class GetHeapUsage(CDPMethod[GetHeapUsageOutput]):  # experimental deprecated
    """ Returns the JavaScript heap usage.
    It is the total usage of the corresponding isolate not scoped to a particular Runtime. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = GetHeapUsageOutput


class GetPropertiesInput(InputModel):

    objectId: Runtime.RemoteObjectId  # deprecated
    ownProperties: bool | None = None  # deprecated
    accessorPropertiesOnly: bool | None = None  # experimental deprecated
    generatePreview: bool | None = None  # experimental deprecated
    nonIndexedPropertiesOnly: bool | None = None  # experimental deprecated


class GetPropertiesOutput(OutputModel):

    result: list[Runtime.PropertyDescriptor]  # deprecated
    internalProperties: list[Runtime.InternalPropertyDescriptor] | None = None  # deprecated
    privateProperties: list[Runtime.PrivatePropertyDescriptor] | None = None  # experimental deprecated
    exceptionDetails: Runtime.ExceptionDetails | None = None  # deprecated


class GetProperties(CDPMethod[GetPropertiesOutput]):  # deprecated
    """ Returns properties of a given object. Object group of the result is inherited from the target
    object. """

    INPUT_VALIDATOR = GetPropertiesInput
    OUTPUT_VALIDATOR = GetPropertiesOutput

    def __init__(
        self,
        *,
        object_id: Runtime.RemoteObjectId,
        own_properties: bool | None = None,
        accessor_properties_only: bool | None = None,
        generate_preview: bool | None = None,
        non_indexed_properties_only: bool | None = None
    ):
        super().__init__(
            objectId=object_id,
            ownProperties=own_properties,
            accessorPropertiesOnly=accessor_properties_only,
            generatePreview=generate_preview,
            nonIndexedPropertiesOnly=non_indexed_properties_only
        )


class GlobalLexicalScopeNamesInput(InputModel):

    executionContextId: Runtime.ExecutionContextId | None = None  # deprecated


class GlobalLexicalScopeNamesOutput(OutputModel):

    names: list[str]


class GlobalLexicalScopeNames(CDPMethod[GlobalLexicalScopeNamesOutput]):  # deprecated
    """ Returns all let, const and class variables from global scope. """

    INPUT_VALIDATOR = GlobalLexicalScopeNamesInput
    OUTPUT_VALIDATOR = GlobalLexicalScopeNamesOutput

    def __init__(
        self,
        *,
        execution_context_id: Runtime.ExecutionContextId | None = None
    ):
        super().__init__(
            executionContextId=execution_context_id
        )


class QueryObjectsInput(InputModel):

    prototypeObjectId: Runtime.RemoteObjectId  # deprecated
    objectGroup: str | None = None  # deprecated


class QueryObjectsOutput(OutputModel):

    objects: Runtime.RemoteObject  # deprecated


class QueryObjects(CDPMethod[QueryObjectsOutput]):

    INPUT_VALIDATOR = QueryObjectsInput
    OUTPUT_VALIDATOR = QueryObjectsOutput

    def __init__(
        self,
        *,
        prototype_object_id: Runtime.RemoteObjectId,
        object_group: str | None = None
    ):
        super().__init__(
            prototypeObjectId=prototype_object_id,
            objectGroup=object_group
        )


class ReleaseObjectInput(InputModel):

    objectId: Runtime.RemoteObjectId  # deprecated


class ReleaseObject(CDPMethod[None]):  # deprecated
    """ Releases remote object with given id. """

    INPUT_VALIDATOR = ReleaseObjectInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        object_id: Runtime.RemoteObjectId
    ):
        super().__init__(
            objectId=object_id
        )


class ReleaseObjectGroupInput(InputModel):

    objectGroup: str  # deprecated


class ReleaseObjectGroup(CDPMethod[None]):  # deprecated
    """ Releases all remote objects that belong to a given group. """

    INPUT_VALIDATOR = ReleaseObjectGroupInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        object_group: str
    ):
        super().__init__(
            objectGroup=object_group
        )


class RunIfWaitingForDebugger(CDPMethod[None]):  # deprecated
    """ Tells inspected instance to run if it was waiting for debugger to attach. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class RunScriptInput(InputModel):

    scriptId: Runtime.ScriptId  # deprecated
    executionContextId: Runtime.ExecutionContextId | None = None  # deprecated
    objectGroup: str | None = None  # deprecated
    silent: bool | None = None  # deprecated
    includeCommandLineAPI: bool | None = None  # deprecated
    returnByValue: bool | None = None  # deprecated
    generatePreview: bool | None = None  # deprecated
    awaitPromise: bool | None = None  # deprecated


class RunScriptOutput(OutputModel):

    result: Runtime.RemoteObject  # deprecated
    exceptionDetails: Runtime.ExceptionDetails | None = None  # deprecated


class RunScript(CDPMethod[RunScriptOutput]):  # deprecated
    """ Runs script with given id in a given context. """

    INPUT_VALIDATOR = RunScriptInput
    OUTPUT_VALIDATOR = RunScriptOutput

    def __init__(
        self,
        *,
        script_id: Runtime.ScriptId,
        execution_context_id: Runtime.ExecutionContextId | None = None,
        object_group: str | None = None,
        silent: bool | None = None,
        include_command_line_api: bool | None = None,
        return_by_value: bool | None = None,
        generate_preview: bool | None = None,
        await_promise: bool | None = None
    ):
        super().__init__(
            scriptId=script_id,
            executionContextId=execution_context_id,
            objectGroup=object_group,
            silent=silent,
            includeCommandLineAPI=include_command_line_api,
            returnByValue=return_by_value,
            generatePreview=generate_preview,
            awaitPromise=await_promise
        )


class SetAsyncCallStackDepthInput(InputModel):

    maxDepth: int  # deprecated


class SetAsyncCallStackDepth(CDPMethod[None]):  # deprecated
    """ Enables or disables async call stacks tracking. """

    INPUT_VALIDATOR = SetAsyncCallStackDepthInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        max_depth: int
    ):
        super().__init__(
            maxDepth=max_depth
        )


class SetCustomObjectFormatterEnabledInput(InputModel):

    enabled: bool


class SetCustomObjectFormatterEnabled(CDPMethod[None]):  # experimental

    INPUT_VALIDATOR = SetCustomObjectFormatterEnabledInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        enabled: bool
    ):
        super().__init__(
            enabled=enabled
        )


class SetMaxCallStackSizeToCaptureInput(InputModel):

    size: int


class SetMaxCallStackSizeToCapture(CDPMethod[None]):  # experimental

    INPUT_VALIDATOR = SetMaxCallStackSizeToCaptureInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        size: int
    ):
        super().__init__(
            size=size
        )


class TerminateExecution(CDPMethod[None]):  # experimental deprecated
    """ Terminate current or next JavaScript execution.
    Will cancel the termination when the outer-most script execution ends. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class AddBindingInput(InputModel):

    name: str
    executionContextId: Runtime.ExecutionContextId | None = None  # experimental deprecated
    executionContextName: str | None = None  # deprecated


class AddBinding(CDPMethod[None]):  # deprecated
    """ If executionContextId is empty, adds binding with the given name on the
    global objects of all inspected contexts, including those created later,
    bindings survive reloads.
    Binding function takes exactly one argument, this argument should be string,
    in case of any other input, function throws an exception.
    Each binding function call produces Runtime.bindingCalled notification. """

    INPUT_VALIDATOR = AddBindingInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        name: str,
        execution_context_id: Runtime.ExecutionContextId | None = None,
        execution_context_name: str | None = None
    ):
        super().__init__(
            name=name,
            executionContextId=execution_context_id,
            executionContextName=execution_context_name
        )


class RemoveBindingInput(InputModel):

    name: str


class RemoveBinding(CDPMethod[None]):  # deprecated
    """ This method does not remove binding function from global object but
    unsubscribes current runtime agent from Runtime.bindingCalled notifications. """

    INPUT_VALIDATOR = RemoveBindingInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        name: str
    ):
        super().__init__(
            name=name
        )


class GetExceptionDetailsInput(InputModel):

    errorObjectId: Runtime.RemoteObjectId  # deprecated


class GetExceptionDetailsOutput(OutputModel):

    exceptionDetails: Runtime.ExceptionDetails | None = None


class GetExceptionDetails(CDPMethod[GetExceptionDetailsOutput]):  # experimental deprecated
    """ This method tries to lookup and populate exception details for a
    JavaScript Error object.
    Note that the stackTrace portion of the resulting exceptionDetails will
    only be populated if the Runtime domain was enabled at the time when the
    Error was thrown. """

    INPUT_VALIDATOR = GetExceptionDetailsInput
    OUTPUT_VALIDATOR = GetExceptionDetailsOutput

    def __init__(
        self,
        *,
        error_object_id: Runtime.RemoteObjectId
    ):
        super().__init__(
            errorObjectId=error_object_id
        )
