///
/// JInAppBrowserOptions.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///

#pragma once

#include <fbjni/fbjni.h>
#include "InAppBrowserOptions.hpp"

#include "BrowserAnimations.hpp"
#include "BrowserColorScheme.hpp"
#include "BrowserShareState.hpp"
#include "DismissButtonStyle.hpp"
#include "DynamicColor.hpp"
#include "FormSheetContentSize.hpp"
#include "JBrowserAnimations.hpp"
#include "JBrowserColorScheme.hpp"
#include "JBrowserShareState.hpp"
#include "JDismissButtonStyle.hpp"
#include "JDynamicColor.hpp"
#include "JFormSheetContentSize.hpp"
#include "JModalPresentationStyle.hpp"
#include "JModalTransitionStyle.hpp"
#include "JStatusBarStyle.hpp"
#include "JUserInterfaceStyle.hpp"
#include "ModalPresentationStyle.hpp"
#include "ModalTransitionStyle.hpp"
#include "StatusBarStyle.hpp"
#include "UserInterfaceStyle.hpp"
#include <optional>
#include <string>
#include <unordered_map>

namespace margelo::nitro::inappbrowsernitro {

  using namespace facebook;

  /**
   * The C++ JNI bridge between the C++ struct "InAppBrowserOptions" and the the Kotlin data class "InAppBrowserOptions".
   */
  struct JInAppBrowserOptions final: public jni::JavaClass<JInAppBrowserOptions> {
  public:
    static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/inappbrowsernitro/InAppBrowserOptions;";

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct InAppBrowserOptions by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    InAppBrowserOptions toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldDismissButtonStyle = clazz->getField<JDismissButtonStyle>("dismissButtonStyle");
      jni::local_ref<JDismissButtonStyle> dismissButtonStyle = this->getFieldValue(fieldDismissButtonStyle);
      static const auto fieldPreferredBarTintColor = clazz->getField<JDynamicColor>("preferredBarTintColor");
      jni::local_ref<JDynamicColor> preferredBarTintColor = this->getFieldValue(fieldPreferredBarTintColor);
      static const auto fieldPreferredControlTintColor = clazz->getField<JDynamicColor>("preferredControlTintColor");
      jni::local_ref<JDynamicColor> preferredControlTintColor = this->getFieldValue(fieldPreferredControlTintColor);
      static const auto fieldPreferredStatusBarStyle = clazz->getField<JStatusBarStyle>("preferredStatusBarStyle");
      jni::local_ref<JStatusBarStyle> preferredStatusBarStyle = this->getFieldValue(fieldPreferredStatusBarStyle);
      static const auto fieldReaderMode = clazz->getField<jni::JBoolean>("readerMode");
      jni::local_ref<jni::JBoolean> readerMode = this->getFieldValue(fieldReaderMode);
      static const auto fieldAnimated = clazz->getField<jni::JBoolean>("animated");
      jni::local_ref<jni::JBoolean> animated = this->getFieldValue(fieldAnimated);
      static const auto fieldModalPresentationStyle = clazz->getField<JModalPresentationStyle>("modalPresentationStyle");
      jni::local_ref<JModalPresentationStyle> modalPresentationStyle = this->getFieldValue(fieldModalPresentationStyle);
      static const auto fieldModalTransitionStyle = clazz->getField<JModalTransitionStyle>("modalTransitionStyle");
      jni::local_ref<JModalTransitionStyle> modalTransitionStyle = this->getFieldValue(fieldModalTransitionStyle);
      static const auto fieldModalEnabled = clazz->getField<jni::JBoolean>("modalEnabled");
      jni::local_ref<jni::JBoolean> modalEnabled = this->getFieldValue(fieldModalEnabled);
      static const auto fieldEnableBarCollapsing = clazz->getField<jni::JBoolean>("enableBarCollapsing");
      jni::local_ref<jni::JBoolean> enableBarCollapsing = this->getFieldValue(fieldEnableBarCollapsing);
      static const auto fieldEphemeralWebSession = clazz->getField<jni::JBoolean>("ephemeralWebSession");
      jni::local_ref<jni::JBoolean> ephemeralWebSession = this->getFieldValue(fieldEphemeralWebSession);
      static const auto fieldEnableEdgeDismiss = clazz->getField<jni::JBoolean>("enableEdgeDismiss");
      jni::local_ref<jni::JBoolean> enableEdgeDismiss = this->getFieldValue(fieldEnableEdgeDismiss);
      static const auto fieldOverrideUserInterfaceStyle = clazz->getField<JUserInterfaceStyle>("overrideUserInterfaceStyle");
      jni::local_ref<JUserInterfaceStyle> overrideUserInterfaceStyle = this->getFieldValue(fieldOverrideUserInterfaceStyle);
      static const auto fieldFormSheetPreferredContentSize = clazz->getField<JFormSheetContentSize>("formSheetPreferredContentSize");
      jni::local_ref<JFormSheetContentSize> formSheetPreferredContentSize = this->getFieldValue(fieldFormSheetPreferredContentSize);
      static const auto fieldShowTitle = clazz->getField<jni::JBoolean>("showTitle");
      jni::local_ref<jni::JBoolean> showTitle = this->getFieldValue(fieldShowTitle);
      static const auto fieldToolbarColor = clazz->getField<JDynamicColor>("toolbarColor");
      jni::local_ref<JDynamicColor> toolbarColor = this->getFieldValue(fieldToolbarColor);
      static const auto fieldSecondaryToolbarColor = clazz->getField<JDynamicColor>("secondaryToolbarColor");
      jni::local_ref<JDynamicColor> secondaryToolbarColor = this->getFieldValue(fieldSecondaryToolbarColor);
      static const auto fieldNavigationBarColor = clazz->getField<JDynamicColor>("navigationBarColor");
      jni::local_ref<JDynamicColor> navigationBarColor = this->getFieldValue(fieldNavigationBarColor);
      static const auto fieldNavigationBarDividerColor = clazz->getField<JDynamicColor>("navigationBarDividerColor");
      jni::local_ref<JDynamicColor> navigationBarDividerColor = this->getFieldValue(fieldNavigationBarDividerColor);
      static const auto fieldEnableUrlBarHiding = clazz->getField<jni::JBoolean>("enableUrlBarHiding");
      jni::local_ref<jni::JBoolean> enableUrlBarHiding = this->getFieldValue(fieldEnableUrlBarHiding);
      static const auto fieldEnableDefaultShare = clazz->getField<jni::JBoolean>("enableDefaultShare");
      jni::local_ref<jni::JBoolean> enableDefaultShare = this->getFieldValue(fieldEnableDefaultShare);
      static const auto fieldShareState = clazz->getField<JBrowserShareState>("shareState");
      jni::local_ref<JBrowserShareState> shareState = this->getFieldValue(fieldShareState);
      static const auto fieldColorScheme = clazz->getField<JBrowserColorScheme>("colorScheme");
      jni::local_ref<JBrowserColorScheme> colorScheme = this->getFieldValue(fieldColorScheme);
      static const auto fieldHeaders = clazz->getField<jni::JMap<jni::JString, jni::JString>>("headers");
      jni::local_ref<jni::JMap<jni::JString, jni::JString>> headers = this->getFieldValue(fieldHeaders);
      static const auto fieldForceCloseOnRedirection = clazz->getField<jni::JBoolean>("forceCloseOnRedirection");
      jni::local_ref<jni::JBoolean> forceCloseOnRedirection = this->getFieldValue(fieldForceCloseOnRedirection);
      static const auto fieldHasBackButton = clazz->getField<jni::JBoolean>("hasBackButton");
      jni::local_ref<jni::JBoolean> hasBackButton = this->getFieldValue(fieldHasBackButton);
      static const auto fieldBrowserPackage = clazz->getField<jni::JString>("browserPackage");
      jni::local_ref<jni::JString> browserPackage = this->getFieldValue(fieldBrowserPackage);
      static const auto fieldShowInRecents = clazz->getField<jni::JBoolean>("showInRecents");
      jni::local_ref<jni::JBoolean> showInRecents = this->getFieldValue(fieldShowInRecents);
      static const auto fieldIncludeReferrer = clazz->getField<jni::JBoolean>("includeReferrer");
      jni::local_ref<jni::JBoolean> includeReferrer = this->getFieldValue(fieldIncludeReferrer);
      static const auto fieldInstantAppsEnabled = clazz->getField<jni::JBoolean>("instantAppsEnabled");
      jni::local_ref<jni::JBoolean> instantAppsEnabled = this->getFieldValue(fieldInstantAppsEnabled);
      static const auto fieldEnablePullToRefresh = clazz->getField<jni::JBoolean>("enablePullToRefresh");
      jni::local_ref<jni::JBoolean> enablePullToRefresh = this->getFieldValue(fieldEnablePullToRefresh);
      static const auto fieldEnablePartialCustomTab = clazz->getField<jni::JBoolean>("enablePartialCustomTab");
      jni::local_ref<jni::JBoolean> enablePartialCustomTab = this->getFieldValue(fieldEnablePartialCustomTab);
      static const auto fieldAnimations = clazz->getField<JBrowserAnimations>("animations");
      jni::local_ref<JBrowserAnimations> animations = this->getFieldValue(fieldAnimations);
      return InAppBrowserOptions(
        dismissButtonStyle != nullptr ? std::make_optional(dismissButtonStyle->toCpp()) : std::nullopt,
        preferredBarTintColor != nullptr ? std::make_optional(preferredBarTintColor->toCpp()) : std::nullopt,
        preferredControlTintColor != nullptr ? std::make_optional(preferredControlTintColor->toCpp()) : std::nullopt,
        preferredStatusBarStyle != nullptr ? std::make_optional(preferredStatusBarStyle->toCpp()) : std::nullopt,
        readerMode != nullptr ? std::make_optional(static_cast<bool>(readerMode->value())) : std::nullopt,
        animated != nullptr ? std::make_optional(static_cast<bool>(animated->value())) : std::nullopt,
        modalPresentationStyle != nullptr ? std::make_optional(modalPresentationStyle->toCpp()) : std::nullopt,
        modalTransitionStyle != nullptr ? std::make_optional(modalTransitionStyle->toCpp()) : std::nullopt,
        modalEnabled != nullptr ? std::make_optional(static_cast<bool>(modalEnabled->value())) : std::nullopt,
        enableBarCollapsing != nullptr ? std::make_optional(static_cast<bool>(enableBarCollapsing->value())) : std::nullopt,
        ephemeralWebSession != nullptr ? std::make_optional(static_cast<bool>(ephemeralWebSession->value())) : std::nullopt,
        enableEdgeDismiss != nullptr ? std::make_optional(static_cast<bool>(enableEdgeDismiss->value())) : std::nullopt,
        overrideUserInterfaceStyle != nullptr ? std::make_optional(overrideUserInterfaceStyle->toCpp()) : std::nullopt,
        formSheetPreferredContentSize != nullptr ? std::make_optional(formSheetPreferredContentSize->toCpp()) : std::nullopt,
        showTitle != nullptr ? std::make_optional(static_cast<bool>(showTitle->value())) : std::nullopt,
        toolbarColor != nullptr ? std::make_optional(toolbarColor->toCpp()) : std::nullopt,
        secondaryToolbarColor != nullptr ? std::make_optional(secondaryToolbarColor->toCpp()) : std::nullopt,
        navigationBarColor != nullptr ? std::make_optional(navigationBarColor->toCpp()) : std::nullopt,
        navigationBarDividerColor != nullptr ? std::make_optional(navigationBarDividerColor->toCpp()) : std::nullopt,
        enableUrlBarHiding != nullptr ? std::make_optional(static_cast<bool>(enableUrlBarHiding->value())) : std::nullopt,
        enableDefaultShare != nullptr ? std::make_optional(static_cast<bool>(enableDefaultShare->value())) : std::nullopt,
        shareState != nullptr ? std::make_optional(shareState->toCpp()) : std::nullopt,
        colorScheme != nullptr ? std::make_optional(colorScheme->toCpp()) : std::nullopt,
        headers != nullptr ? std::make_optional([&]() {
          std::unordered_map<std::string, std::string> __map;
          __map.reserve(headers->size());
          for (const auto& __entry : *headers) {
            __map.emplace(__entry.first->toStdString(), __entry.second->toStdString());
          }
          return __map;
        }()) : std::nullopt,
        forceCloseOnRedirection != nullptr ? std::make_optional(static_cast<bool>(forceCloseOnRedirection->value())) : std::nullopt,
        hasBackButton != nullptr ? std::make_optional(static_cast<bool>(hasBackButton->value())) : std::nullopt,
        browserPackage != nullptr ? std::make_optional(browserPackage->toStdString()) : std::nullopt,
        showInRecents != nullptr ? std::make_optional(static_cast<bool>(showInRecents->value())) : std::nullopt,
        includeReferrer != nullptr ? std::make_optional(static_cast<bool>(includeReferrer->value())) : std::nullopt,
        instantAppsEnabled != nullptr ? std::make_optional(static_cast<bool>(instantAppsEnabled->value())) : std::nullopt,
        enablePullToRefresh != nullptr ? std::make_optional(static_cast<bool>(enablePullToRefresh->value())) : std::nullopt,
        enablePartialCustomTab != nullptr ? std::make_optional(static_cast<bool>(enablePartialCustomTab->value())) : std::nullopt,
        animations != nullptr ? std::make_optional(animations->toCpp()) : std::nullopt
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JInAppBrowserOptions::javaobject> fromCpp(const InAppBrowserOptions& value) {
      using JSignature = JInAppBrowserOptions(jni::alias_ref<JDismissButtonStyle>, jni::alias_ref<JDynamicColor>, jni::alias_ref<JDynamicColor>, jni::alias_ref<JStatusBarStyle>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<JModalPresentationStyle>, jni::alias_ref<JModalTransitionStyle>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<JUserInterfaceStyle>, jni::alias_ref<JFormSheetContentSize>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<JDynamicColor>, jni::alias_ref<JDynamicColor>, jni::alias_ref<JDynamicColor>, jni::alias_ref<JDynamicColor>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<JBrowserShareState>, jni::alias_ref<JBrowserColorScheme>, jni::alias_ref<jni::JMap<jni::JString, jni::JString>>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<JBrowserAnimations>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.dismissButtonStyle.has_value() ? JDismissButtonStyle::fromCpp(value.dismissButtonStyle.value()) : nullptr,
        value.preferredBarTintColor.has_value() ? JDynamicColor::fromCpp(value.preferredBarTintColor.value()) : nullptr,
        value.preferredControlTintColor.has_value() ? JDynamicColor::fromCpp(value.preferredControlTintColor.value()) : nullptr,
        value.preferredStatusBarStyle.has_value() ? JStatusBarStyle::fromCpp(value.preferredStatusBarStyle.value()) : nullptr,
        value.readerMode.has_value() ? jni::JBoolean::valueOf(value.readerMode.value()) : nullptr,
        value.animated.has_value() ? jni::JBoolean::valueOf(value.animated.value()) : nullptr,
        value.modalPresentationStyle.has_value() ? JModalPresentationStyle::fromCpp(value.modalPresentationStyle.value()) : nullptr,
        value.modalTransitionStyle.has_value() ? JModalTransitionStyle::fromCpp(value.modalTransitionStyle.value()) : nullptr,
        value.modalEnabled.has_value() ? jni::JBoolean::valueOf(value.modalEnabled.value()) : nullptr,
        value.enableBarCollapsing.has_value() ? jni::JBoolean::valueOf(value.enableBarCollapsing.value()) : nullptr,
        value.ephemeralWebSession.has_value() ? jni::JBoolean::valueOf(value.ephemeralWebSession.value()) : nullptr,
        value.enableEdgeDismiss.has_value() ? jni::JBoolean::valueOf(value.enableEdgeDismiss.value()) : nullptr,
        value.overrideUserInterfaceStyle.has_value() ? JUserInterfaceStyle::fromCpp(value.overrideUserInterfaceStyle.value()) : nullptr,
        value.formSheetPreferredContentSize.has_value() ? JFormSheetContentSize::fromCpp(value.formSheetPreferredContentSize.value()) : nullptr,
        value.showTitle.has_value() ? jni::JBoolean::valueOf(value.showTitle.value()) : nullptr,
        value.toolbarColor.has_value() ? JDynamicColor::fromCpp(value.toolbarColor.value()) : nullptr,
        value.secondaryToolbarColor.has_value() ? JDynamicColor::fromCpp(value.secondaryToolbarColor.value()) : nullptr,
        value.navigationBarColor.has_value() ? JDynamicColor::fromCpp(value.navigationBarColor.value()) : nullptr,
        value.navigationBarDividerColor.has_value() ? JDynamicColor::fromCpp(value.navigationBarDividerColor.value()) : nullptr,
        value.enableUrlBarHiding.has_value() ? jni::JBoolean::valueOf(value.enableUrlBarHiding.value()) : nullptr,
        value.enableDefaultShare.has_value() ? jni::JBoolean::valueOf(value.enableDefaultShare.value()) : nullptr,
        value.shareState.has_value() ? JBrowserShareState::fromCpp(value.shareState.value()) : nullptr,
        value.colorScheme.has_value() ? JBrowserColorScheme::fromCpp(value.colorScheme.value()) : nullptr,
        value.headers.has_value() ? [&]() -> jni::local_ref<jni::JMap<jni::JString, jni::JString>> {
          auto __map = jni::JHashMap<jni::JString, jni::JString>::create(value.headers.value().size());
          for (const auto& __entry : value.headers.value()) {
            __map->put(jni::make_jstring(__entry.first), jni::make_jstring(__entry.second));
          }
          return __map;
        }() : nullptr,
        value.forceCloseOnRedirection.has_value() ? jni::JBoolean::valueOf(value.forceCloseOnRedirection.value()) : nullptr,
        value.hasBackButton.has_value() ? jni::JBoolean::valueOf(value.hasBackButton.value()) : nullptr,
        value.browserPackage.has_value() ? jni::make_jstring(value.browserPackage.value()) : nullptr,
        value.showInRecents.has_value() ? jni::JBoolean::valueOf(value.showInRecents.value()) : nullptr,
        value.includeReferrer.has_value() ? jni::JBoolean::valueOf(value.includeReferrer.value()) : nullptr,
        value.instantAppsEnabled.has_value() ? jni::JBoolean::valueOf(value.instantAppsEnabled.value()) : nullptr,
        value.enablePullToRefresh.has_value() ? jni::JBoolean::valueOf(value.enablePullToRefresh.value()) : nullptr,
        value.enablePartialCustomTab.has_value() ? jni::JBoolean::valueOf(value.enablePartialCustomTab.value()) : nullptr,
        value.animations.has_value() ? JBrowserAnimations::fromCpp(value.animations.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::inappbrowsernitro
