///
/// ToolDefinition.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 `ToolParameter` to properly resolve imports.
namespace margelo::nitro::mlxreactnative { struct ToolParameter; }

#include <string>
#include "ToolParameter.hpp"
#include <vector>
#include <NitroModules/AnyMap.hpp>
#include <NitroModules/Promise.hpp>
#include <functional>

namespace margelo::nitro::mlxreactnative {

  /**
   * A struct which can be represented as a JavaScript object (ToolDefinition).
   */
  struct ToolDefinition final {
  public:
    std::string name     SWIFT_PRIVATE;
    std::string description     SWIFT_PRIVATE;
    std::vector<ToolParameter> parameters     SWIFT_PRIVATE;
    std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::shared_ptr<AnyMap>>>>>(const std::shared_ptr<AnyMap>& /* args */)> handler     SWIFT_PRIVATE;

  public:
    ToolDefinition() = default;
    explicit ToolDefinition(std::string name, std::string description, std::vector<ToolParameter> parameters, std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::shared_ptr<AnyMap>>>>>(const std::shared_ptr<AnyMap>& /* args */)> handler): name(name), description(description), parameters(parameters), handler(handler) {}

  public:
    // ToolDefinition is not equatable because these properties are not equatable: handler
  };

} // namespace margelo::nitro::mlxreactnative

namespace margelo::nitro {

  // C++ ToolDefinition <> JS ToolDefinition (object)
  template <>
  struct JSIConverter<margelo::nitro::mlxreactnative::ToolDefinition> final {
    static inline margelo::nitro::mlxreactnative::ToolDefinition fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::mlxreactnative::ToolDefinition(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "description"))),
        JSIConverter<std::vector<margelo::nitro::mlxreactnative::ToolParameter>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "parameters"))),
        JSIConverter<std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::shared_ptr<AnyMap>>>>>(const std::shared_ptr<AnyMap>&)>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "handler")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::mlxreactnative::ToolDefinition& 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, "description"), JSIConverter<std::string>::toJSI(runtime, arg.description));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "parameters"), JSIConverter<std::vector<margelo::nitro::mlxreactnative::ToolParameter>>::toJSI(runtime, arg.parameters));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "handler"), JSIConverter<std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::shared_ptr<AnyMap>>>>>(const std::shared_ptr<AnyMap>&)>>::toJSI(runtime, arg.handler));
      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<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "description")))) return false;
      if (!JSIConverter<std::vector<margelo::nitro::mlxreactnative::ToolParameter>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "parameters")))) return false;
      if (!JSIConverter<std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::shared_ptr<AnyMap>>>>>(const std::shared_ptr<AnyMap>&)>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "handler")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
