# frozen_string_literal: true

# Licensed to the Software Freedom Conservancy (SFC) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The SFC licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

# This file is automatically generated. DO NOT EDIT!
# Regenerate with: bazel run //rb/lib/selenium/webdriver:bidi-generate

module Selenium
  module WebDriver
    class BiDi
      module Protocol
        # @api private
        # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
        class Input < Domain
          EVENTS = {
            file_dialog_opened: 'input.fileDialogOpened'
          }.freeze

          POINTER_TYPE = {
            mouse: 'mouse',
            pen: 'pen',
            touch: 'touch'
          }.freeze

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          ElementOrigin = Serialization::Record.define(
            type: {fixed: 'element'},
            element: {wire_key: 'element', ref: 'Script::SharedReference'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          PerformActionsParameters = Serialization::Record.define(
            context: 'context',
            actions: {wire_key: 'actions', ref: 'Input::SourceActions', list: true}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          class SourceActions < Serialization::Union
            discriminator 'type', {none: 'none', key: 'key', pointer: 'pointer', wheel: 'wheel'}
            variants(
              none: 'Input::NoneSourceActions',
              key: 'Input::KeySourceActions',
              pointer: 'Input::PointerSourceActions',
              wheel: 'Input::WheelSourceActions'
            )
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          NoneSourceActions = Serialization::Record.define(
            type: {fixed: 'none'},
            id: {wire_key: 'id', primitive: 'string'},
            actions: {wire_key: 'actions', ref: 'Input::PauseAction', list: true}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          KeySourceActions = Serialization::Record.define(
            type: {fixed: 'key'},
            id: {wire_key: 'id', primitive: 'string'},
            actions: {wire_key: 'actions', ref: 'Input::KeySourceAction', list: true}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          class KeySourceAction < Serialization::Union
            discriminator 'type', {pause: 'pause', key_down: 'keyDown', key_up: 'keyUp'}
            variants(
              pause: 'Input::PauseAction',
              key_down: 'Input::KeyDownAction',
              key_up: 'Input::KeyUpAction'
            )
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          PointerSourceActions = Serialization::Record.define(
            type: {fixed: 'pointer'},
            id: {wire_key: 'id', primitive: 'string'},
            parameters: {wire_key: 'parameters', required: false, ref: 'Input::PointerParameters'},
            actions: {wire_key: 'actions', ref: 'Input::PointerSourceAction', list: true}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          PointerParameters = Serialization::Record.define(
            pointer_type: {wire_key: 'pointerType', required: false, enum: 'Input::POINTER_TYPE'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          class PointerSourceAction < Serialization::Union
            discriminator 'type', {
              pause: 'pause',
              pointer_down: 'pointerDown',
              pointer_up: 'pointerUp',
              pointer_move: 'pointerMove'
            }
            variants(
              pause: 'Input::PauseAction',
              pointer_down: 'Input::PointerDownAction',
              pointer_up: 'Input::PointerUpAction',
              pointer_move: 'Input::PointerMoveAction'
            )
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          WheelSourceActions = Serialization::Record.define(
            type: {fixed: 'wheel'},
            id: {wire_key: 'id', primitive: 'string'},
            actions: {wire_key: 'actions', ref: 'Input::WheelSourceAction', list: true}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          class WheelSourceAction < Serialization::Union
            discriminator 'type', {pause: 'pause', scroll: 'scroll'}
            variants(
              pause: 'Input::PauseAction',
              scroll: 'Input::WheelScrollAction'
            )
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          PauseAction = Serialization::Record.define(
            type: {fixed: 'pause'},
            duration: {wire_key: 'duration', required: false}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          KeyDownAction = Serialization::Record.define(
            type: {fixed: 'keyDown'},
            value: {wire_key: 'value', primitive: 'string'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          KeyUpAction = Serialization::Record.define(
            type: {fixed: 'keyUp'},
            value: {wire_key: 'value', primitive: 'string'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          PointerUpAction = Serialization::Record.define(type: {fixed: 'pointerUp'}, button: 'button')

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          PointerDownAction = Serialization::Record.define(
            type: {fixed: 'pointerDown'},
            button: 'button',
            width: {wire_key: 'width', required: false},
            height: {wire_key: 'height', required: false},
            pressure: {wire_key: 'pressure', required: false, primitive: 'integer'},
            tangential_pressure: {wire_key: 'tangentialPressure', required: false, primitive: 'integer'},
            twist: {wire_key: 'twist', required: false, primitive: 'integer'},
            altitude_angle: {wire_key: 'altitudeAngle', required: false, primitive: 'number'},
            azimuth_angle: {wire_key: 'azimuthAngle', required: false, primitive: 'number'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          PointerMoveAction = Serialization::Record.define(
            type: {fixed: 'pointerMove'},
            x: {wire_key: 'x', primitive: 'number'},
            y: {wire_key: 'y', primitive: 'number'},
            duration: {wire_key: 'duration', required: false},
            origin: {wire_key: 'origin', required: false, ref: 'Input::Origin'},
            width: {wire_key: 'width', required: false},
            height: {wire_key: 'height', required: false},
            pressure: {wire_key: 'pressure', required: false, primitive: 'integer'},
            tangential_pressure: {wire_key: 'tangentialPressure', required: false, primitive: 'integer'},
            twist: {wire_key: 'twist', required: false, primitive: 'integer'},
            altitude_angle: {wire_key: 'altitudeAngle', required: false, primitive: 'number'},
            azimuth_angle: {wire_key: 'azimuthAngle', required: false, primitive: 'number'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          WheelScrollAction = Serialization::Record.define(
            type: {fixed: 'scroll'},
            x: 'x',
            y: 'y',
            delta_x: 'deltaX',
            delta_y: 'deltaY',
            duration: {wire_key: 'duration', required: false},
            origin: {wire_key: 'origin', required: false, ref: 'Input::Origin'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          PointerCommonProperties = Serialization::Record.define(
            width: {wire_key: 'width', required: false},
            height: {wire_key: 'height', required: false},
            pressure: {wire_key: 'pressure', required: false, primitive: 'integer'},
            tangential_pressure: {wire_key: 'tangentialPressure', required: false, primitive: 'integer'},
            twist: {wire_key: 'twist', required: false, primitive: 'integer'},
            altitude_angle: {wire_key: 'altitudeAngle', required: false, primitive: 'number'},
            azimuth_angle: {wire_key: 'azimuthAngle', required: false, primitive: 'number'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          class Origin < Serialization::Union
            discriminator 'type', {element: 'element'}
            variants(
              element: 'Input::ElementOrigin'
            )
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          ReleaseActionsParameters = Serialization::Record.define(context: 'context')

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          SetFilesParameters = Serialization::Record.define(
            context: 'context',
            element: {wire_key: 'element', ref: 'Script::SharedReference'},
            files: {wire_key: 'files', list: true}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          FileDialogInfo = Serialization::Record.define(
            context: 'context',
            user_context: {wire_key: 'userContext', required: false},
            element: {wire_key: 'element', required: false, ref: 'Script::SharedReference'},
            multiple: {wire_key: 'multiple', primitive: 'boolean'}
          )

          EVENT_TYPES = {
            'input.fileDialogOpened' => Input::FileDialogInfo
          }.freeze

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          def perform_actions(context:, actions:)
            params = PerformActionsParameters.new(context: context, actions: actions)
            execute(cmd: 'input.performActions', params: params)
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          def release_actions(context:)
            params = ReleaseActionsParameters.new(context: context)
            execute(cmd: 'input.releaseActions', params: params)
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          def set_files(context:, element:, files:)
            params = SetFilesParameters.new(context: context, element: element, files: files)
            execute(cmd: 'input.setFiles', params: params)
          end
        end # Input
      end # Protocol
    end # BiDi
  end # WebDriver
end # Selenium
