///
/// TextBlock.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 `BoundingFrame` to properly resolve imports.
namespace margelo::nitro::visioncameraocrplus { struct BoundingFrame; }
// Forward declaration of `CornerPoint` to properly resolve imports.
namespace margelo::nitro::visioncameraocrplus { struct CornerPoint; }
// Forward declaration of `TextLine` to properly resolve imports.
namespace margelo::nitro::visioncameraocrplus { struct TextLine; }

#include <string>
#include "BoundingFrame.hpp"
#include "CornerPoint.hpp"
#include <vector>
#include "TextLine.hpp"

namespace margelo::nitro::visioncameraocrplus {

  /**
   * A struct which can be represented as a JavaScript object (TextBlock).
   */
  struct TextBlock final {
  public:
    std::string blockText     SWIFT_PRIVATE;
    BoundingFrame blockFrame     SWIFT_PRIVATE;
    std::vector<CornerPoint> blockCornerPoints     SWIFT_PRIVATE;
    std::vector<TextLine> lines     SWIFT_PRIVATE;

  public:
    TextBlock() = default;
    explicit TextBlock(std::string blockText, BoundingFrame blockFrame, std::vector<CornerPoint> blockCornerPoints, std::vector<TextLine> lines): blockText(blockText), blockFrame(blockFrame), blockCornerPoints(blockCornerPoints), lines(lines) {}

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

} // namespace margelo::nitro::visioncameraocrplus

namespace margelo::nitro {

  // C++ TextBlock <> JS TextBlock (object)
  template <>
  struct JSIConverter<margelo::nitro::visioncameraocrplus::TextBlock> final {
    static inline margelo::nitro::visioncameraocrplus::TextBlock fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::visioncameraocrplus::TextBlock(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "blockText"))),
        JSIConverter<margelo::nitro::visioncameraocrplus::BoundingFrame>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "blockFrame"))),
        JSIConverter<std::vector<margelo::nitro::visioncameraocrplus::CornerPoint>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "blockCornerPoints"))),
        JSIConverter<std::vector<margelo::nitro::visioncameraocrplus::TextLine>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "lines")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::visioncameraocrplus::TextBlock& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "blockText"), JSIConverter<std::string>::toJSI(runtime, arg.blockText));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "blockFrame"), JSIConverter<margelo::nitro::visioncameraocrplus::BoundingFrame>::toJSI(runtime, arg.blockFrame));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "blockCornerPoints"), JSIConverter<std::vector<margelo::nitro::visioncameraocrplus::CornerPoint>>::toJSI(runtime, arg.blockCornerPoints));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "lines"), JSIConverter<std::vector<margelo::nitro::visioncameraocrplus::TextLine>>::toJSI(runtime, arg.lines));
      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, "blockText")))) return false;
      if (!JSIConverter<margelo::nitro::visioncameraocrplus::BoundingFrame>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "blockFrame")))) return false;
      if (!JSIConverter<std::vector<margelo::nitro::visioncameraocrplus::CornerPoint>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "blockCornerPoints")))) return false;
      if (!JSIConverter<std::vector<margelo::nitro::visioncameraocrplus::TextLine>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "lines")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
