///
/// DynamicRange.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 `DynamicRangeBitDepth` to properly resolve imports.
namespace margelo::nitro::camera { enum class DynamicRangeBitDepth; }
// Forward declaration of `ColorSpace` to properly resolve imports.
namespace margelo::nitro::camera { enum class ColorSpace; }
// Forward declaration of `ColorRange` to properly resolve imports.
namespace margelo::nitro::camera { enum class ColorRange; }

#include "DynamicRangeBitDepth.hpp"
#include "ColorSpace.hpp"
#include "ColorRange.hpp"

namespace margelo::nitro::camera {

  /**
   * A struct which can be represented as a JavaScript object (DynamicRange).
   */
  struct DynamicRange final {
  public:
    DynamicRangeBitDepth bitDepth     SWIFT_PRIVATE;
    ColorSpace colorSpace     SWIFT_PRIVATE;
    ColorRange colorRange     SWIFT_PRIVATE;

  public:
    DynamicRange() = default;
    explicit DynamicRange(DynamicRangeBitDepth bitDepth, ColorSpace colorSpace, ColorRange colorRange): bitDepth(bitDepth), colorSpace(colorSpace), colorRange(colorRange) {}

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

} // namespace margelo::nitro::camera

namespace margelo::nitro {

  // C++ DynamicRange <> JS DynamicRange (object)
  template <>
  struct JSIConverter<margelo::nitro::camera::DynamicRange> final {
    static inline margelo::nitro::camera::DynamicRange fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::camera::DynamicRange(
        JSIConverter<margelo::nitro::camera::DynamicRangeBitDepth>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bitDepth"))),
        JSIConverter<margelo::nitro::camera::ColorSpace>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "colorSpace"))),
        JSIConverter<margelo::nitro::camera::ColorRange>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "colorRange")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::camera::DynamicRange& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "bitDepth"), JSIConverter<margelo::nitro::camera::DynamicRangeBitDepth>::toJSI(runtime, arg.bitDepth));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "colorSpace"), JSIConverter<margelo::nitro::camera::ColorSpace>::toJSI(runtime, arg.colorSpace));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "colorRange"), JSIConverter<margelo::nitro::camera::ColorRange>::toJSI(runtime, arg.colorRange));
      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::DynamicRangeBitDepth>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bitDepth")))) return false;
      if (!JSIConverter<margelo::nitro::camera::ColorSpace>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "colorSpace")))) return false;
      if (!JSIConverter<margelo::nitro::camera::ColorRange>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "colorRange")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
