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

#pragma once

#if __has_include(<NitroModules/JSIConverter.hpp>)
#include <NitroModules/JSIConverter.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/NitroDefines.hpp>)
#include <NitroModules/NitroDefines.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/JSIHelpers.hpp>)
#include <NitroModules/JSIHelpers.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
#include <NitroModules/PropNameIDCache.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif

// Forward declaration of `HybridImageSpec` to properly resolve imports.
namespace margelo::nitro::image { class HybridImageSpec; }

#include <functional>
#include <optional>
#include <memory>
#include <NitroImage/HybridImageSpec.hpp>

namespace margelo::nitro::camera {

  /**
   * A struct which can be represented as a JavaScript object (CapturePhotoCallbacks).
   */
  struct CapturePhotoCallbacks final {
  public:
    std::optional<std::function<void()>> onWillBeginCapture     SWIFT_PRIVATE;
    std::optional<std::function<void()>> onWillCapturePhoto     SWIFT_PRIVATE;
    std::optional<std::function<void()>> onDidCapturePhoto     SWIFT_PRIVATE;
    std::optional<std::function<void(const std::shared_ptr<margelo::nitro::image::HybridImageSpec>& /* previewImage */)>> onPreviewImageAvailable     SWIFT_PRIVATE;

  public:
    CapturePhotoCallbacks() = default;
    explicit CapturePhotoCallbacks(std::optional<std::function<void()>> onWillBeginCapture, std::optional<std::function<void()>> onWillCapturePhoto, std::optional<std::function<void()>> onDidCapturePhoto, std::optional<std::function<void(const std::shared_ptr<margelo::nitro::image::HybridImageSpec>& /* previewImage */)>> onPreviewImageAvailable): onWillBeginCapture(onWillBeginCapture), onWillCapturePhoto(onWillCapturePhoto), onDidCapturePhoto(onDidCapturePhoto), onPreviewImageAvailable(onPreviewImageAvailable) {}

  public:
    // CapturePhotoCallbacks is not equatable because these properties are not equatable: onWillBeginCapture, onWillCapturePhoto, onDidCapturePhoto, onPreviewImageAvailable
  };

} // namespace margelo::nitro::camera

namespace margelo::nitro {

  // C++ CapturePhotoCallbacks <> JS CapturePhotoCallbacks (object)
  template <>
  struct JSIConverter<margelo::nitro::camera::CapturePhotoCallbacks> final {
    static inline margelo::nitro::camera::CapturePhotoCallbacks fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::camera::CapturePhotoCallbacks(
        JSIConverter<std::optional<std::function<void()>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onWillBeginCapture"))),
        JSIConverter<std::optional<std::function<void()>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onWillCapturePhoto"))),
        JSIConverter<std::optional<std::function<void()>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onDidCapturePhoto"))),
        JSIConverter<std::optional<std::function<void(const std::shared_ptr<margelo::nitro::image::HybridImageSpec>&)>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onPreviewImageAvailable")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::camera::CapturePhotoCallbacks& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "onWillBeginCapture"), JSIConverter<std::optional<std::function<void()>>>::toJSI(runtime, arg.onWillBeginCapture));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "onWillCapturePhoto"), JSIConverter<std::optional<std::function<void()>>>::toJSI(runtime, arg.onWillCapturePhoto));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "onDidCapturePhoto"), JSIConverter<std::optional<std::function<void()>>>::toJSI(runtime, arg.onDidCapturePhoto));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "onPreviewImageAvailable"), JSIConverter<std::optional<std::function<void(const std::shared_ptr<margelo::nitro::image::HybridImageSpec>&)>>>::toJSI(runtime, arg.onPreviewImageAvailable));
      return obj;
    }
    static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
      if (!value.isObject()) {
        return false;
      }
      jsi::Object obj = value.getObject(runtime);
      if (!nitro::isPlainObject(runtime, obj)) {
        return false;
      }
      if (!JSIConverter<std::optional<std::function<void()>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onWillBeginCapture")))) return false;
      if (!JSIConverter<std::optional<std::function<void()>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onWillCapturePhoto")))) return false;
      if (!JSIConverter<std::optional<std::function<void()>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onDidCapturePhoto")))) return false;
      if (!JSIConverter<std::optional<std::function<void(const std::shared_ptr<margelo::nitro::image::HybridImageSpec>&)>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onPreviewImageAvailable")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
