///
/// BarcodeScannerOutputOptions.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 `TargetBarcodeFormat` to properly resolve imports.
namespace margelo::nitro::camera::barcodescanner { enum class TargetBarcodeFormat; }
// Forward declaration of `BarcodeScannerOutputResolution` to properly resolve imports.
namespace margelo::nitro::camera::barcodescanner { enum class BarcodeScannerOutputResolution; }
// Forward declaration of `HybridBarcodeSpec` to properly resolve imports.
namespace margelo::nitro::camera::barcodescanner { class HybridBarcodeSpec; }

#include "TargetBarcodeFormat.hpp"
#include <vector>
#include "BarcodeScannerOutputResolution.hpp"
#include <optional>
#include <memory>
#include "HybridBarcodeSpec.hpp"
#include <functional>
#include <exception>

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

  /**
   * A struct which can be represented as a JavaScript object (BarcodeScannerOutputOptions).
   */
  struct BarcodeScannerOutputOptions final {
  public:
    std::vector<TargetBarcodeFormat> barcodeFormats     SWIFT_PRIVATE;
    std::optional<BarcodeScannerOutputResolution> outputResolution     SWIFT_PRIVATE;
    std::function<void(const std::vector<std::shared_ptr<HybridBarcodeSpec>>& /* barcodes */)> onBarcodeScanned     SWIFT_PRIVATE;
    std::function<void(const std::exception_ptr& /* error */)> onError     SWIFT_PRIVATE;

  public:
    BarcodeScannerOutputOptions() = default;
    explicit BarcodeScannerOutputOptions(std::vector<TargetBarcodeFormat> barcodeFormats, std::optional<BarcodeScannerOutputResolution> outputResolution, std::function<void(const std::vector<std::shared_ptr<HybridBarcodeSpec>>& /* barcodes */)> onBarcodeScanned, std::function<void(const std::exception_ptr& /* error */)> onError): barcodeFormats(barcodeFormats), outputResolution(outputResolution), onBarcodeScanned(onBarcodeScanned), onError(onError) {}

  public:
    // BarcodeScannerOutputOptions is not equatable because these properties are not equatable: onBarcodeScanned, onError
  };

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

namespace margelo::nitro {

  // C++ BarcodeScannerOutputOptions <> JS BarcodeScannerOutputOptions (object)
  template <>
  struct JSIConverter<margelo::nitro::camera::barcodescanner::BarcodeScannerOutputOptions> final {
    static inline margelo::nitro::camera::barcodescanner::BarcodeScannerOutputOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::camera::barcodescanner::BarcodeScannerOutputOptions(
        JSIConverter<std::vector<margelo::nitro::camera::barcodescanner::TargetBarcodeFormat>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "barcodeFormats"))),
        JSIConverter<std::optional<margelo::nitro::camera::barcodescanner::BarcodeScannerOutputResolution>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "outputResolution"))),
        JSIConverter<std::function<void(const std::vector<std::shared_ptr<margelo::nitro::camera::barcodescanner::HybridBarcodeSpec>>&)>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onBarcodeScanned"))),
        JSIConverter<std::function<void(const std::exception_ptr&)>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onError")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::camera::barcodescanner::BarcodeScannerOutputOptions& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "barcodeFormats"), JSIConverter<std::vector<margelo::nitro::camera::barcodescanner::TargetBarcodeFormat>>::toJSI(runtime, arg.barcodeFormats));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "outputResolution"), JSIConverter<std::optional<margelo::nitro::camera::barcodescanner::BarcodeScannerOutputResolution>>::toJSI(runtime, arg.outputResolution));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "onBarcodeScanned"), JSIConverter<std::function<void(const std::vector<std::shared_ptr<margelo::nitro::camera::barcodescanner::HybridBarcodeSpec>>&)>>::toJSI(runtime, arg.onBarcodeScanned));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "onError"), JSIConverter<std::function<void(const std::exception_ptr&)>>::toJSI(runtime, arg.onError));
      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::vector<margelo::nitro::camera::barcodescanner::TargetBarcodeFormat>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "barcodeFormats")))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::camera::barcodescanner::BarcodeScannerOutputResolution>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "outputResolution")))) return false;
      if (!JSIConverter<std::function<void(const std::vector<std::shared_ptr<margelo::nitro::camera::barcodescanner::HybridBarcodeSpec>>&)>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onBarcodeScanned")))) return false;
      if (!JSIConverter<std::function<void(const std::exception_ptr&)>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onError")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
