///
/// Rect.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





namespace margelo::nitro::camera::barcodescanner {

  /**
   * A struct which can be represented as a JavaScript object (Rect).
   */
  struct Rect final {
  public:
    double left     SWIFT_PRIVATE;
    double right     SWIFT_PRIVATE;
    double top     SWIFT_PRIVATE;
    double bottom     SWIFT_PRIVATE;

  public:
    Rect() = default;
    explicit Rect(double left, double right, double top, double bottom): left(left), right(right), top(top), bottom(bottom) {}

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

} // namespace margelo::nitro::camera::barcodescanner

namespace margelo::nitro {

  // C++ Rect <> JS Rect (object)
  template <>
  struct JSIConverter<margelo::nitro::camera::barcodescanner::Rect> final {
    static inline margelo::nitro::camera::barcodescanner::Rect fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::camera::barcodescanner::Rect(
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "left"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "right"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "top"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bottom")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::camera::barcodescanner::Rect& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "left"), JSIConverter<double>::toJSI(runtime, arg.left));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "right"), JSIConverter<double>::toJSI(runtime, arg.right));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "top"), JSIConverter<double>::toJSI(runtime, arg.top));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "bottom"), JSIConverter<double>::toJSI(runtime, arg.bottom));
      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<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "left")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "right")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "top")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bottom")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
