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

Defines commands and events for Autofill.
https://chromedevtools.github.io/devtools-protocol/tot/Autofill/

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

from cdpkit.protocol._types import (
    DOM,
    Autofill,
    Page,
)
from cdpkit.protocol.base import CDPMethod, InputModel


class TriggerInput(InputModel):

    fieldId: DOM.BackendNodeId
    frameId: Page.FrameId | None = None
    card: Autofill.CreditCard | None = None
    address: Autofill.Address | None = None


class Trigger(CDPMethod[None]):
    """ Trigger autofill on a form identified by the fieldId.
    If the field and related form cannot be autofilled, returns an error. """

    INPUT_VALIDATOR = TriggerInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        field_id: DOM.BackendNodeId,
        frame_id: Page.FrameId | None = None,
        card: Autofill.CreditCard | None = None,
        address: Autofill.Address | None = None
    ):
        super().__init__(
            fieldId=field_id,
            frameId=frame_id,
            card=card,
            address=address
        )


class SetAddressesInput(InputModel):

    addresses: list[Autofill.Address]


class SetAddresses(CDPMethod[None]):
    """ Set addresses so that developers can verify their forms implementation. """

    INPUT_VALIDATOR = SetAddressesInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        addresses: list[Autofill.Address]
    ):
        super().__init__(
            addresses=addresses
        )


class Disable(CDPMethod[None]):
    """ Disables autofill domain notifications. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class Enable(CDPMethod[None]):
    """ Enables autofill domain notifications. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None
