///
/// FrameOutputOptions.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 `Size` to properly resolve imports.
namespace margelo::nitro::camera { struct Size; }
// Forward declaration of `TargetVideoPixelFormat` to properly resolve imports.
namespace margelo::nitro::camera { enum class TargetVideoPixelFormat; }

#include "Size.hpp"
#include "TargetVideoPixelFormat.hpp"

namespace margelo::nitro::camera {

  /**
   * A struct which can be represented as a JavaScript object (FrameOutputOptions).
   */
  struct FrameOutputOptions final {
  public:
    Size targetResolution     SWIFT_PRIVATE;
    bool enablePreviewSizedOutputBuffers     SWIFT_PRIVATE;
    bool allowDeferredStart     SWIFT_PRIVATE;
    TargetVideoPixelFormat pixelFormat     SWIFT_PRIVATE;
    bool enablePhysicalBufferRotation     SWIFT_PRIVATE;
    bool enableCameraMatrixDelivery     SWIFT_PRIVATE;
    bool dropFramesWhileBusy     SWIFT_PRIVATE;

  public:
    FrameOutputOptions() = default;
    explicit FrameOutputOptions(Size targetResolution, bool enablePreviewSizedOutputBuffers, bool allowDeferredStart, TargetVideoPixelFormat pixelFormat, bool enablePhysicalBufferRotation, bool enableCameraMatrixDelivery, bool dropFramesWhileBusy): targetResolution(targetResolution), enablePreviewSizedOutputBuffers(enablePreviewSizedOutputBuffers), allowDeferredStart(allowDeferredStart), pixelFormat(pixelFormat), enablePhysicalBufferRotation(enablePhysicalBufferRotation), enableCameraMatrixDelivery(enableCameraMatrixDelivery), dropFramesWhileBusy(dropFramesWhileBusy) {}

  public:
    friend bool operator==(const FrameOutputOptions& lhs, const FrameOutputOptions& rhs) = default;
  };

} // namespace margelo::nitro::camera

namespace margelo::nitro {

  // C++ FrameOutputOptions <> JS FrameOutputOptions (object)
  template <>
  struct JSIConverter<margelo::nitro::camera::FrameOutputOptions> final {
    static inline margelo::nitro::camera::FrameOutputOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::camera::FrameOutputOptions(
        JSIConverter<margelo::nitro::camera::Size>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "targetResolution"))),
        JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "enablePreviewSizedOutputBuffers"))),
        JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "allowDeferredStart"))),
        JSIConverter<margelo::nitro::camera::TargetVideoPixelFormat>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "pixelFormat"))),
        JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "enablePhysicalBufferRotation"))),
        JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "enableCameraMatrixDelivery"))),
        JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "dropFramesWhileBusy")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::camera::FrameOutputOptions& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "targetResolution"), JSIConverter<margelo::nitro::camera::Size>::toJSI(runtime, arg.targetResolution));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "enablePreviewSizedOutputBuffers"), JSIConverter<bool>::toJSI(runtime, arg.enablePreviewSizedOutputBuffers));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "allowDeferredStart"), JSIConverter<bool>::toJSI(runtime, arg.allowDeferredStart));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "pixelFormat"), JSIConverter<margelo::nitro::camera::TargetVideoPixelFormat>::toJSI(runtime, arg.pixelFormat));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "enablePhysicalBufferRotation"), JSIConverter<bool>::toJSI(runtime, arg.enablePhysicalBufferRotation));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "enableCameraMatrixDelivery"), JSIConverter<bool>::toJSI(runtime, arg.enableCameraMatrixDelivery));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "dropFramesWhileBusy"), JSIConverter<bool>::toJSI(runtime, arg.dropFramesWhileBusy));
      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<margelo::nitro::camera::Size>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "targetResolution")))) return false;
      if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "enablePreviewSizedOutputBuffers")))) return false;
      if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "allowDeferredStart")))) return false;
      if (!JSIConverter<margelo::nitro::camera::TargetVideoPixelFormat>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "pixelFormat")))) return false;
      if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "enablePhysicalBufferRotation")))) return false;
      if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "enableCameraMatrixDelivery")))) return false;
      if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "dropFramesWhileBusy")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
