///
/// TextRecognitionConfig.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 `ScanRegion` to properly resolve imports.
namespace margelo::nitro::visioncameraocrplus { struct ScanRegion; }

#include <string>
#include "ScanRegion.hpp"
#include <optional>

namespace margelo::nitro::visioncameraocrplus {

  /**
   * A struct which can be represented as a JavaScript object (TextRecognitionConfig).
   */
  struct TextRecognitionConfig final {
  public:
    std::string language     SWIFT_PRIVATE;
    std::optional<ScanRegion> scanRegion     SWIFT_PRIVATE;
    double frameSkipThreshold     SWIFT_PRIVATE;
    bool useLightweightMode     SWIFT_PRIVATE;

  public:
    TextRecognitionConfig() = default;
    explicit TextRecognitionConfig(std::string language, std::optional<ScanRegion> scanRegion, double frameSkipThreshold, bool useLightweightMode): language(language), scanRegion(scanRegion), frameSkipThreshold(frameSkipThreshold), useLightweightMode(useLightweightMode) {}

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

} // namespace margelo::nitro::visioncameraocrplus

namespace margelo::nitro {

  // C++ TextRecognitionConfig <> JS TextRecognitionConfig (object)
  template <>
  struct JSIConverter<margelo::nitro::visioncameraocrplus::TextRecognitionConfig> final {
    static inline margelo::nitro::visioncameraocrplus::TextRecognitionConfig fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::visioncameraocrplus::TextRecognitionConfig(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "language"))),
        JSIConverter<std::optional<margelo::nitro::visioncameraocrplus::ScanRegion>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "scanRegion"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "frameSkipThreshold"))),
        JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "useLightweightMode")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::visioncameraocrplus::TextRecognitionConfig& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "language"), JSIConverter<std::string>::toJSI(runtime, arg.language));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "scanRegion"), JSIConverter<std::optional<margelo::nitro::visioncameraocrplus::ScanRegion>>::toJSI(runtime, arg.scanRegion));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "frameSkipThreshold"), JSIConverter<double>::toJSI(runtime, arg.frameSkipThreshold));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "useLightweightMode"), JSIConverter<bool>::toJSI(runtime, arg.useLightweightMode));
      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::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "language")))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::visioncameraocrplus::ScanRegion>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "scanRegion")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "frameSkipThreshold")))) return false;
      if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "useLightweightMode")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
