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

#pragma once

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

#include "CameraDevice.hpp"
#include "JCameraDevice.hpp"
#include <optional>

namespace margelo::nitro::multipleimagepicker {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct PickerCameraConfig by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    PickerCameraConfig toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldCameraDevice = clazz->getField<JCameraDevice>("cameraDevice");
      jni::local_ref<JCameraDevice> cameraDevice = this->getFieldValue(fieldCameraDevice);
      static const auto fieldVideoMaximumDuration = clazz->getField<jni::JDouble>("videoMaximumDuration");
      jni::local_ref<jni::JDouble> videoMaximumDuration = this->getFieldValue(fieldVideoMaximumDuration);
      return PickerCameraConfig(
        cameraDevice != nullptr ? std::make_optional(cameraDevice->toCpp()) : std::nullopt,
        videoMaximumDuration != nullptr ? std::make_optional(videoMaximumDuration->value()) : 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<JPickerCameraConfig::javaobject> fromCpp(const PickerCameraConfig& value) {
      return newInstance(
        value.cameraDevice.has_value() ? JCameraDevice::fromCpp(value.cameraDevice.value()) : nullptr,
        value.videoMaximumDuration.has_value() ? jni::JDouble::valueOf(value.videoMaximumDuration.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::multipleimagepicker
