///
/// Counterparty.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2025 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

// Forward declaration of `MerchantCounterparty` to properly resolve imports.
namespace margelo::nitro::rncandle { struct MerchantCounterparty; }
// Forward declaration of `UserCounterparty` to properly resolve imports.
namespace margelo::nitro::rncandle { struct UserCounterparty; }
// Forward declaration of `ServiceCounterparty` to properly resolve imports.
namespace margelo::nitro::rncandle { struct ServiceCounterparty; }

#include "MerchantCounterparty.hpp"
#include <optional>
#include "UserCounterparty.hpp"
#include "ServiceCounterparty.hpp"

namespace margelo::nitro::rncandle {

  /**
   * A struct which can be represented as a JavaScript object (Counterparty).
   */
  struct Counterparty {
  public:
    std::optional<MerchantCounterparty> merchantCounterparty     SWIFT_PRIVATE;
    std::optional<UserCounterparty> userCounterparty     SWIFT_PRIVATE;
    std::optional<ServiceCounterparty> serviceCounterparty     SWIFT_PRIVATE;

  public:
    Counterparty() = default;
    explicit Counterparty(std::optional<MerchantCounterparty> merchantCounterparty, std::optional<UserCounterparty> userCounterparty, std::optional<ServiceCounterparty> serviceCounterparty): merchantCounterparty(merchantCounterparty), userCounterparty(userCounterparty), serviceCounterparty(serviceCounterparty) {}
  };

} // namespace margelo::nitro::rncandle

namespace margelo::nitro {

  // C++ Counterparty <> JS Counterparty (object)
  template <>
  struct JSIConverter<margelo::nitro::rncandle::Counterparty> final {
    static inline margelo::nitro::rncandle::Counterparty fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::rncandle::Counterparty(
        JSIConverter<std::optional<margelo::nitro::rncandle::MerchantCounterparty>>::fromJSI(runtime, obj.getProperty(runtime, "merchantCounterparty")),
        JSIConverter<std::optional<margelo::nitro::rncandle::UserCounterparty>>::fromJSI(runtime, obj.getProperty(runtime, "userCounterparty")),
        JSIConverter<std::optional<margelo::nitro::rncandle::ServiceCounterparty>>::fromJSI(runtime, obj.getProperty(runtime, "serviceCounterparty"))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::rncandle::Counterparty& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, "merchantCounterparty", JSIConverter<std::optional<margelo::nitro::rncandle::MerchantCounterparty>>::toJSI(runtime, arg.merchantCounterparty));
      obj.setProperty(runtime, "userCounterparty", JSIConverter<std::optional<margelo::nitro::rncandle::UserCounterparty>>::toJSI(runtime, arg.userCounterparty));
      obj.setProperty(runtime, "serviceCounterparty", JSIConverter<std::optional<margelo::nitro::rncandle::ServiceCounterparty>>::toJSI(runtime, arg.serviceCounterparty));
      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 (!JSIConverter<std::optional<margelo::nitro::rncandle::MerchantCounterparty>>::canConvert(runtime, obj.getProperty(runtime, "merchantCounterparty"))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::rncandle::UserCounterparty>>::canConvert(runtime, obj.getProperty(runtime, "userCounterparty"))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::rncandle::ServiceCounterparty>>::canConvert(runtime, obj.getProperty(runtime, "serviceCounterparty"))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
