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

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

namespace margelo::nitro::munimbluetooth {

  /**
   * A struct which can be represented as a JavaScript object (MultipeerSessionOptions).
   */
  struct MultipeerSessionOptions final {
  public:
    std::string serviceType     SWIFT_PRIVATE;
    std::optional<std::string> displayName     SWIFT_PRIVATE;
    std::optional<std::vector<MultipeerDiscoveryInfoEntry>> discoveryInfo     SWIFT_PRIVATE;
    std::optional<bool> autoInvite     SWIFT_PRIVATE;
    std::optional<bool> autoAcceptInvitations     SWIFT_PRIVATE;
    std::optional<double> inviteTimeout     SWIFT_PRIVATE;
    std::optional<MultipeerEncryptionPreference> encryptionPreference     SWIFT_PRIVATE;

  public:
    MultipeerSessionOptions() = default;
    explicit MultipeerSessionOptions(std::string serviceType, std::optional<std::string> displayName, std::optional<std::vector<MultipeerDiscoveryInfoEntry>> discoveryInfo, std::optional<bool> autoInvite, std::optional<bool> autoAcceptInvitations, std::optional<double> inviteTimeout, std::optional<MultipeerEncryptionPreference> encryptionPreference): serviceType(serviceType), displayName(displayName), discoveryInfo(discoveryInfo), autoInvite(autoInvite), autoAcceptInvitations(autoAcceptInvitations), inviteTimeout(inviteTimeout), encryptionPreference(encryptionPreference) {}

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

} // namespace margelo::nitro::munimbluetooth

namespace margelo::nitro {

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

} // namespace margelo::nitro
