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



#include <string>
#include <optional>

namespace margelo::nitro::readium {

  /**
   * A struct which can be represented as a JavaScript object (DecorationStyle).
   */
  struct DecorationStyle final {
  public:
    std::string type     SWIFT_PRIVATE;
    std::optional<std::string> tint     SWIFT_PRIVATE;
    std::optional<bool> isActive     SWIFT_PRIVATE;
    std::optional<std::string> id     SWIFT_PRIVATE;
    std::optional<std::string> html     SWIFT_PRIVATE;
    std::optional<std::string> css     SWIFT_PRIVATE;
    std::optional<std::string> layout     SWIFT_PRIVATE;
    std::optional<std::string> width     SWIFT_PRIVATE;

  public:
    DecorationStyle() = default;
    explicit DecorationStyle(std::string type, std::optional<std::string> tint, std::optional<bool> isActive, std::optional<std::string> id, std::optional<std::string> html, std::optional<std::string> css, std::optional<std::string> layout, std::optional<std::string> width): type(type), tint(tint), isActive(isActive), id(id), html(html), css(css), layout(layout), width(width) {}

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

} // namespace margelo::nitro::readium

namespace margelo::nitro {

  // C++ DecorationStyle <> JS DecorationStyle (object)
  template <>
  struct JSIConverter<margelo::nitro::readium::DecorationStyle> final {
    static inline margelo::nitro::readium::DecorationStyle fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::readium::DecorationStyle(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "type"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "tint"))),
        JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isActive"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "id"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "html"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "css"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "layout"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "width")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::readium::DecorationStyle& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "type"), JSIConverter<std::string>::toJSI(runtime, arg.type));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "tint"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.tint));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "isActive"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.isActive));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "id"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.id));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "html"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.html));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "css"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.css));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "layout"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.layout));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "width"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.width));
      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, "type")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "tint")))) return false;
      if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isActive")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "id")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "html")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "css")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "layout")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "width")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
