///
/// UnifiedRiveEvent.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 `RiveEventType` to properly resolve imports.
namespace margelo::nitro::rive { enum class RiveEventType; }

#include <string>
#include "RiveEventType.hpp"
#include <optional>
#include <variant>
#include <unordered_map>

namespace margelo::nitro::rive {

  /**
   * A struct which can be represented as a JavaScript object (UnifiedRiveEvent).
   */
  struct UnifiedRiveEvent final {
  public:
    std::string name     SWIFT_PRIVATE;
    RiveEventType type     SWIFT_PRIVATE;
    std::optional<double> delay     SWIFT_PRIVATE;
    std::optional<std::unordered_map<std::string, std::variant<bool, std::string, double>>> properties     SWIFT_PRIVATE;
    std::optional<std::string> url     SWIFT_PRIVATE;
    std::optional<std::string> target     SWIFT_PRIVATE;

  public:
    UnifiedRiveEvent() = default;
    explicit UnifiedRiveEvent(std::string name, RiveEventType type, std::optional<double> delay, std::optional<std::unordered_map<std::string, std::variant<bool, std::string, double>>> properties, std::optional<std::string> url, std::optional<std::string> target): name(name), type(type), delay(delay), properties(properties), url(url), target(target) {}

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

} // namespace margelo::nitro::rive

namespace margelo::nitro {

  // C++ UnifiedRiveEvent <> JS UnifiedRiveEvent (object)
  template <>
  struct JSIConverter<margelo::nitro::rive::UnifiedRiveEvent> final {
    static inline margelo::nitro::rive::UnifiedRiveEvent fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::rive::UnifiedRiveEvent(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name"))),
        JSIConverter<margelo::nitro::rive::RiveEventType>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "type"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "delay"))),
        JSIConverter<std::optional<std::unordered_map<std::string, std::variant<bool, std::string, double>>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "properties"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "url"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "target")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::rive::UnifiedRiveEvent& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "name"), JSIConverter<std::string>::toJSI(runtime, arg.name));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "type"), JSIConverter<margelo::nitro::rive::RiveEventType>::toJSI(runtime, arg.type));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "delay"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.delay));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "properties"), JSIConverter<std::optional<std::unordered_map<std::string, std::variant<bool, std::string, double>>>>::toJSI(runtime, arg.properties));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "url"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.url));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "target"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.target));
      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, "name")))) return false;
      if (!JSIConverter<margelo::nitro::rive::RiveEventType>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "type")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "delay")))) return false;
      if (!JSIConverter<std::optional<std::unordered_map<std::string, std::variant<bool, std::string, double>>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "properties")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "url")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "target")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
