# 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 <%= BiDiGenerate::BIDI_DOC_URL %>
        class <%= mod.ruby_class %> < Domain
<%- unless mod.events.empty? -%>
          EVENTS = {
            <%= mod.events.map { |event| "#{event.event_name}: '#{event.wire_name}'" }.join(",\n            ") %>
          }.freeze

<%- end -%>
<%- mod.enums.each do |enum| -%>
          <%= enum.constant_name %> = {
            <%= enum.pairs.map { |key, wire_val| "#{key}: '#{wire_val}'" }.join(",\n            ") %>
          }.freeze

<%- end -%>
<%- mod.types.each do |type| -%>
<%- if type.union? -%>
          # @api private
          # @see <%= BiDiGenerate::BIDI_DOC_URL %>
          class <%= type.ruby_name %> < Serialization::Union
<%- if type.discriminator_wire && !type.value_variants.empty? -%>
            <%= type.discriminator_decl(12) %>
            variants(
              <%= type.value_variants.map(&:variant_entry).join(",\n              ") %>
            )
<%- end -%>
<%- unless type.presence_variants.empty? -%>
            presence(
              <%= type.presence_variants.map { |v| "'#{v.ref}' => [#{v.requires.map { |w| "'#{w}'" }.join(', ')}]" }.join(",\n              ") %>
            )
<%- end -%>
<%- if type.fallback_variant -%>
            fallback '<%= type.fallback_variant.ref %>'
<%- end -%>
<%- type.nested_types.each do |nested| -%>

            # @api private
            # @see <%= BiDiGenerate::BIDI_DOC_URL %>
            <%= nested.define_assignment(nested.ruby_name, 12) %>
<%- end -%>
          end

<%- else -%>
          # @api private
          # @see <%= BiDiGenerate::BIDI_DOC_URL %>
          <%= type.define_assignment(type.ruby_name, 10) %>
<%- type.nested_types.each do |nested| -%>

          # @api private
          # @see <%= BiDiGenerate::BIDI_DOC_URL %>
          <%= nested.define_assignment("#{type.ruby_name}::#{nested.ruby_name}", 10) %>
<%- end -%>

<%- end -%>
<%- end -%>
<%- unless mod.events.empty? -%>
          EVENT_TYPES = {
            <%= mod.events.map(&:type_entry).join(",\n            ") %>
          }.freeze
<%- unless mod.commands.empty? -%>

<%- end -%>
<%- end -%>
<%- mod.commands.each_with_index do |cmd, index| -%>
<%- unless index.zero? -%>

<%- end -%>
          # @api private
          # @see <%= BiDiGenerate::BIDI_DOC_URL %>
          <%= cmd.def_header(10) %>
<%- cmd.enum_checks(12).each do |check| -%>
            <%= check %>
<%- end -%>
<%- if cmd.params_assignment(12) -%>
            <%= cmd.params_assignment(12) %>
<%- end -%>
            <%= cmd.execute_call(12) %>
          end
<%- end -%>
        end # <%= mod.ruby_class %>
      end # Protocol
    end # BiDi
  end # WebDriver
end # Selenium
