///
/// MultipeerPeer.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 `MultipeerPeerState` to properly resolve imports.
namespace margelo::nitro::munimbluetooth { enum class MultipeerPeerState; }
// Forward declaration of `MultipeerDiscoveryInfoEntry` to properly resolve imports.
namespace margelo::nitro::munimbluetooth { struct MultipeerDiscoveryInfoEntry; }

#include <string>
#include "MultipeerPeerState.hpp"
#include "MultipeerDiscoveryInfoEntry.hpp"
#include <vector>
#include <optional>

namespace margelo::nitro::munimbluetooth {

  /**
   * A struct which can be represented as a JavaScript object (MultipeerPeer).
   */
  struct MultipeerPeer final {
  public:
    std::string id     SWIFT_PRIVATE;
    std::string displayName     SWIFT_PRIVATE;
    MultipeerPeerState state     SWIFT_PRIVATE;
    std::optional<std::vector<MultipeerDiscoveryInfoEntry>> discoveryInfo     SWIFT_PRIVATE;

  public:
    MultipeerPeer() = default;
    explicit MultipeerPeer(std::string id, std::string displayName, MultipeerPeerState state, std::optional<std::vector<MultipeerDiscoveryInfoEntry>> discoveryInfo): id(id), displayName(displayName), state(state), discoveryInfo(discoveryInfo) {}

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

} // namespace margelo::nitro::munimbluetooth

namespace margelo::nitro {

  // C++ MultipeerPeer <> JS MultipeerPeer (object)
  template <>
  struct JSIConverter<margelo::nitro::munimbluetooth::MultipeerPeer> final {
    static inline margelo::nitro::munimbluetooth::MultipeerPeer fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::munimbluetooth::MultipeerPeer(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "id"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "displayName"))),
        JSIConverter<margelo::nitro::munimbluetooth::MultipeerPeerState>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "state"))),
        JSIConverter<std::optional<std::vector<margelo::nitro::munimbluetooth::MultipeerDiscoveryInfoEntry>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "discoveryInfo")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::munimbluetooth::MultipeerPeer& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "id"), JSIConverter<std::string>::toJSI(runtime, arg.id));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "displayName"), JSIConverter<std::string>::toJSI(runtime, arg.displayName));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "state"), JSIConverter<margelo::nitro::munimbluetooth::MultipeerPeerState>::toJSI(runtime, arg.state));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "discoveryInfo"), JSIConverter<std::optional<std::vector<margelo::nitro::munimbluetooth::MultipeerDiscoveryInfoEntry>>>::toJSI(runtime, arg.discoveryInfo));
      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, "id")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "displayName")))) return false;
      if (!JSIConverter<margelo::nitro::munimbluetooth::MultipeerPeerState>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "state")))) return false;
      if (!JSIConverter<std::optional<std::vector<margelo::nitro::munimbluetooth::MultipeerDiscoveryInfoEntry>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "discoveryInfo")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
