///
/// AssetAccount.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 `FiatAccount` to properly resolve imports.
namespace margelo::nitro::rncandle { struct FiatAccount; }
// Forward declaration of `MarketAccount` to properly resolve imports.
namespace margelo::nitro::rncandle { struct MarketAccount; }
// Forward declaration of `TransportAccount` to properly resolve imports.
namespace margelo::nitro::rncandle { struct TransportAccount; }

#include "FiatAccount.hpp"
#include <optional>
#include "MarketAccount.hpp"
#include "TransportAccount.hpp"

namespace margelo::nitro::rncandle {

  /**
   * A struct which can be represented as a JavaScript object (AssetAccount).
   */
  struct AssetAccount {
  public:
    std::optional<FiatAccount> fiatAccount     SWIFT_PRIVATE;
    std::optional<MarketAccount> marketAccount     SWIFT_PRIVATE;
    std::optional<TransportAccount> transportAccount     SWIFT_PRIVATE;

  public:
    AssetAccount() = default;
    explicit AssetAccount(std::optional<FiatAccount> fiatAccount, std::optional<MarketAccount> marketAccount, std::optional<TransportAccount> transportAccount): fiatAccount(fiatAccount), marketAccount(marketAccount), transportAccount(transportAccount) {}
  };

} // namespace margelo::nitro::rncandle

namespace margelo::nitro {

  // C++ AssetAccount <> JS AssetAccount (object)
  template <>
  struct JSIConverter<margelo::nitro::rncandle::AssetAccount> final {
    static inline margelo::nitro::rncandle::AssetAccount fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::rncandle::AssetAccount(
        JSIConverter<std::optional<margelo::nitro::rncandle::FiatAccount>>::fromJSI(runtime, obj.getProperty(runtime, "fiatAccount")),
        JSIConverter<std::optional<margelo::nitro::rncandle::MarketAccount>>::fromJSI(runtime, obj.getProperty(runtime, "marketAccount")),
        JSIConverter<std::optional<margelo::nitro::rncandle::TransportAccount>>::fromJSI(runtime, obj.getProperty(runtime, "transportAccount"))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::rncandle::AssetAccount& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, "fiatAccount", JSIConverter<std::optional<margelo::nitro::rncandle::FiatAccount>>::toJSI(runtime, arg.fiatAccount));
      obj.setProperty(runtime, "marketAccount", JSIConverter<std::optional<margelo::nitro::rncandle::MarketAccount>>::toJSI(runtime, arg.marketAccount));
      obj.setProperty(runtime, "transportAccount", JSIConverter<std::optional<margelo::nitro::rncandle::TransportAccount>>::toJSI(runtime, arg.transportAccount));
      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::FiatAccount>>::canConvert(runtime, obj.getProperty(runtime, "fiatAccount"))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::rncandle::MarketAccount>>::canConvert(runtime, obj.getProperty(runtime, "marketAccount"))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::rncandle::TransportAccount>>::canConvert(runtime, obj.getProperty(runtime, "transportAccount"))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
