///
/// NativeLinearListLayoutConfig.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 `NativeLinearListLayoutIOSConfig` to properly resolve imports.
namespace margelo::nitro::reactnativelist { struct NativeLinearListLayoutIOSConfig; }

#include "NativeLinearListLayoutIOSConfig.hpp"
#include <optional>

namespace margelo::nitro::reactnativelist {

  /**
   * A struct which can be represented as a JavaScript object (NativeLinearListLayoutConfig).
   */
  struct NativeLinearListLayoutConfig final {
  public:
    double topInset     SWIFT_PRIVATE;
    double bottomInset     SWIFT_PRIVATE;
    double itemSpacing     SWIFT_PRIVATE;
    double itemHorizontalInset     SWIFT_PRIVATE;
    double itemVerticalInset     SWIFT_PRIVATE;
    std::optional<NativeLinearListLayoutIOSConfig> iosConfig     SWIFT_PRIVATE;

  public:
    NativeLinearListLayoutConfig() = default;
    explicit NativeLinearListLayoutConfig(double topInset, double bottomInset, double itemSpacing, double itemHorizontalInset, double itemVerticalInset, std::optional<NativeLinearListLayoutIOSConfig> iosConfig): topInset(topInset), bottomInset(bottomInset), itemSpacing(itemSpacing), itemHorizontalInset(itemHorizontalInset), itemVerticalInset(itemVerticalInset), iosConfig(iosConfig) {}

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

} // namespace margelo::nitro::reactnativelist

namespace margelo::nitro {

  // C++ NativeLinearListLayoutConfig <> JS NativeLinearListLayoutConfig (object)
  template <>
  struct JSIConverter<margelo::nitro::reactnativelist::NativeLinearListLayoutConfig> final {
    static inline margelo::nitro::reactnativelist::NativeLinearListLayoutConfig fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::reactnativelist::NativeLinearListLayoutConfig(
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "topInset"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bottomInset"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "itemSpacing"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "itemHorizontalInset"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "itemVerticalInset"))),
        JSIConverter<std::optional<margelo::nitro::reactnativelist::NativeLinearListLayoutIOSConfig>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "iosConfig")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::reactnativelist::NativeLinearListLayoutConfig& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "topInset"), JSIConverter<double>::toJSI(runtime, arg.topInset));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "bottomInset"), JSIConverter<double>::toJSI(runtime, arg.bottomInset));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "itemSpacing"), JSIConverter<double>::toJSI(runtime, arg.itemSpacing));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "itemHorizontalInset"), JSIConverter<double>::toJSI(runtime, arg.itemHorizontalInset));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "itemVerticalInset"), JSIConverter<double>::toJSI(runtime, arg.itemVerticalInset));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "iosConfig"), JSIConverter<std::optional<margelo::nitro::reactnativelist::NativeLinearListLayoutIOSConfig>>::toJSI(runtime, arg.iosConfig));
      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, "topInset")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bottomInset")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "itemSpacing")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "itemHorizontalInset")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "itemVerticalInset")))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::reactnativelist::NativeLinearListLayoutIOSConfig>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "iosConfig")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
