///
/// MLXReactNative-Swift-Cxx-Bridge.cpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///

#include "MLXReactNative-Swift-Cxx-Bridge.hpp"

// Include C++ implementation defined types
#include "HybridEmbeddingsSpecSwift.hpp"
#include "HybridLLMSpecSwift.hpp"
#include "HybridModelManagerSpecSwift.hpp"
#include "HybridSTTSpecSwift.hpp"
#include "HybridTTSSpecSwift.hpp"
#include "MLXReactNative-Swift-Cxx-Umbrella.hpp"
#include <NitroModules/NitroDefines.hpp>

namespace margelo::nitro::mlxreactnative::bridge::swift {

  // pragma MARK: std::function<void()>
  Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept {
    auto swiftClosure = MLXReactNative::Func_void::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)]() mutable -> void {
      swiftClosure.call();
    };
  }
  
  // pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
  Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* NON_NULL swiftClosureWrapper) noexcept {
    auto swiftClosure = MLXReactNative::Func_void_std__exception_ptr::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)](const std::exception_ptr& error) mutable -> void {
      swiftClosure.call(error);
    };
  }
  
  // pragma MARK: std::function<void(double /* progress */)>
  Func_void_double create_Func_void_double(void* NON_NULL swiftClosureWrapper) noexcept {
    auto swiftClosure = MLXReactNative::Func_void_double::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)](double progress) mutable -> void {
      swiftClosure.call(progress);
    };
  }
  
  // pragma MARK: std::function<void(const std::shared_ptr<ArrayBuffer>& /* result */)>
  Func_void_std__shared_ptr_ArrayBuffer_ create_Func_void_std__shared_ptr_ArrayBuffer_(void* NON_NULL swiftClosureWrapper) noexcept {
    auto swiftClosure = MLXReactNative::Func_void_std__shared_ptr_ArrayBuffer_::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)](const std::shared_ptr<ArrayBuffer>& result) mutable -> void {
      swiftClosure.call(ArrayBufferHolder(result));
    };
  }
  
  // pragma MARK: std::function<void(const std::vector<std::shared_ptr<ArrayBuffer>>& /* result */)>
  Func_void_std__vector_std__shared_ptr_ArrayBuffer__ create_Func_void_std__vector_std__shared_ptr_ArrayBuffer__(void* NON_NULL swiftClosureWrapper) noexcept {
    auto swiftClosure = MLXReactNative::Func_void_std__vector_std__shared_ptr_ArrayBuffer__::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)](const std::vector<std::shared_ptr<ArrayBuffer>>& result) mutable -> void {
      swiftClosure.call(result);
    };
  }
  
  // pragma MARK: std::shared_ptr<HybridEmbeddingsSpec>
  std::shared_ptr<HybridEmbeddingsSpec> create_std__shared_ptr_HybridEmbeddingsSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
    MLXReactNative::HybridEmbeddingsSpec_cxx swiftPart = MLXReactNative::HybridEmbeddingsSpec_cxx::fromUnsafe(swiftUnsafePointer);
    return std::make_shared<margelo::nitro::mlxreactnative::HybridEmbeddingsSpecSwift>(swiftPart);
  }
  void* NON_NULL get_std__shared_ptr_HybridEmbeddingsSpec_(std__shared_ptr_HybridEmbeddingsSpec_ cppType) {
    std::shared_ptr<margelo::nitro::mlxreactnative::HybridEmbeddingsSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::mlxreactnative::HybridEmbeddingsSpecSwift>(cppType);
    #ifdef NITRO_DEBUG
    if (swiftWrapper == nullptr) [[unlikely]] {
      throw std::runtime_error("Class \"HybridEmbeddingsSpec\" is not implemented in Swift!");
    }
    #endif
    MLXReactNative::HybridEmbeddingsSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
    return swiftPart.toUnsafe();
  }
  
  // pragma MARK: std::function<void(const std::shared_ptr<AnyMap>& /* result */)>
  Func_void_std__shared_ptr_AnyMap_ create_Func_void_std__shared_ptr_AnyMap_(void* NON_NULL swiftClosureWrapper) noexcept {
    auto swiftClosure = MLXReactNative::Func_void_std__shared_ptr_AnyMap_::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)](const std::shared_ptr<AnyMap>& result) mutable -> void {
      swiftClosure.call(result);
    };
  }
  
  // pragma MARK: std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::shared_ptr<AnyMap>>>>>(const std::shared_ptr<AnyMap>& /* args */)>
  Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_AnyMap______std__shared_ptr_AnyMap_ create_Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_AnyMap______std__shared_ptr_AnyMap_(void* NON_NULL swiftClosureWrapper) noexcept {
    auto swiftClosure = MLXReactNative::Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_AnyMap______std__shared_ptr_AnyMap_::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)](const std::shared_ptr<AnyMap>& args) mutable -> std::shared_ptr<Promise<std::shared_ptr<Promise<std::shared_ptr<AnyMap>>>>> {
      auto __result = swiftClosure.call(args);
      return __result;
    };
  }
  
  // pragma MARK: std::function<void(const std::shared_ptr<Promise<std::shared_ptr<AnyMap>>>& /* result */)>
  Func_void_std__shared_ptr_Promise_std__shared_ptr_AnyMap___ create_Func_void_std__shared_ptr_Promise_std__shared_ptr_AnyMap___(void* NON_NULL swiftClosureWrapper) noexcept {
    auto swiftClosure = MLXReactNative::Func_void_std__shared_ptr_Promise_std__shared_ptr_AnyMap___::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)](const std::shared_ptr<Promise<std::shared_ptr<AnyMap>>>& result) mutable -> void {
      swiftClosure.call(result);
    };
  }
  
  // pragma MARK: std::function<void(const std::string& /* result */)>
  Func_void_std__string create_Func_void_std__string(void* NON_NULL swiftClosureWrapper) noexcept {
    auto swiftClosure = MLXReactNative::Func_void_std__string::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)](const std::string& result) mutable -> void {
      swiftClosure.call(result);
    };
  }
  
  // pragma MARK: std::function<void(const std::string& /* toolName */, const std::string& /* args */)>
  Func_void_std__string_std__string create_Func_void_std__string_std__string(void* NON_NULL swiftClosureWrapper) noexcept {
    auto swiftClosure = MLXReactNative::Func_void_std__string_std__string::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)](const std::string& toolName, const std::string& args) mutable -> void {
      swiftClosure.call(toolName, args);
    };
  }
  
  // pragma MARK: std::shared_ptr<HybridLLMSpec>
  std::shared_ptr<HybridLLMSpec> create_std__shared_ptr_HybridLLMSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
    MLXReactNative::HybridLLMSpec_cxx swiftPart = MLXReactNative::HybridLLMSpec_cxx::fromUnsafe(swiftUnsafePointer);
    return std::make_shared<margelo::nitro::mlxreactnative::HybridLLMSpecSwift>(swiftPart);
  }
  void* NON_NULL get_std__shared_ptr_HybridLLMSpec_(std__shared_ptr_HybridLLMSpec_ cppType) {
    std::shared_ptr<margelo::nitro::mlxreactnative::HybridLLMSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::mlxreactnative::HybridLLMSpecSwift>(cppType);
    #ifdef NITRO_DEBUG
    if (swiftWrapper == nullptr) [[unlikely]] {
      throw std::runtime_error("Class \"HybridLLMSpec\" is not implemented in Swift!");
    }
    #endif
    MLXReactNative::HybridLLMSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
    return swiftPart.toUnsafe();
  }
  
  // pragma MARK: std::function<void(bool /* result */)>
  Func_void_bool create_Func_void_bool(void* NON_NULL swiftClosureWrapper) noexcept {
    auto swiftClosure = MLXReactNative::Func_void_bool::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)](bool result) mutable -> void {
      swiftClosure.call(result);
    };
  }
  
  // pragma MARK: std::function<void(const std::vector<std::string>& /* result */)>
  Func_void_std__vector_std__string_ create_Func_void_std__vector_std__string_(void* NON_NULL swiftClosureWrapper) noexcept {
    auto swiftClosure = MLXReactNative::Func_void_std__vector_std__string_::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)](const std::vector<std::string>& result) mutable -> void {
      swiftClosure.call(result);
    };
  }
  
  // pragma MARK: std::shared_ptr<HybridModelManagerSpec>
  std::shared_ptr<HybridModelManagerSpec> create_std__shared_ptr_HybridModelManagerSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
    MLXReactNative::HybridModelManagerSpec_cxx swiftPart = MLXReactNative::HybridModelManagerSpec_cxx::fromUnsafe(swiftUnsafePointer);
    return std::make_shared<margelo::nitro::mlxreactnative::HybridModelManagerSpecSwift>(swiftPart);
  }
  void* NON_NULL get_std__shared_ptr_HybridModelManagerSpec_(std__shared_ptr_HybridModelManagerSpec_ cppType) {
    std::shared_ptr<margelo::nitro::mlxreactnative::HybridModelManagerSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::mlxreactnative::HybridModelManagerSpecSwift>(cppType);
    #ifdef NITRO_DEBUG
    if (swiftWrapper == nullptr) [[unlikely]] {
      throw std::runtime_error("Class \"HybridModelManagerSpec\" is not implemented in Swift!");
    }
    #endif
    MLXReactNative::HybridModelManagerSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
    return swiftPart.toUnsafe();
  }
  
  // pragma MARK: std::shared_ptr<HybridSTTSpec>
  std::shared_ptr<HybridSTTSpec> create_std__shared_ptr_HybridSTTSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
    MLXReactNative::HybridSTTSpec_cxx swiftPart = MLXReactNative::HybridSTTSpec_cxx::fromUnsafe(swiftUnsafePointer);
    return std::make_shared<margelo::nitro::mlxreactnative::HybridSTTSpecSwift>(swiftPart);
  }
  void* NON_NULL get_std__shared_ptr_HybridSTTSpec_(std__shared_ptr_HybridSTTSpec_ cppType) {
    std::shared_ptr<margelo::nitro::mlxreactnative::HybridSTTSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::mlxreactnative::HybridSTTSpecSwift>(cppType);
    #ifdef NITRO_DEBUG
    if (swiftWrapper == nullptr) [[unlikely]] {
      throw std::runtime_error("Class \"HybridSTTSpec\" is not implemented in Swift!");
    }
    #endif
    MLXReactNative::HybridSTTSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
    return swiftPart.toUnsafe();
  }
  
  // pragma MARK: std::shared_ptr<HybridTTSSpec>
  std::shared_ptr<HybridTTSSpec> create_std__shared_ptr_HybridTTSSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
    MLXReactNative::HybridTTSSpec_cxx swiftPart = MLXReactNative::HybridTTSSpec_cxx::fromUnsafe(swiftUnsafePointer);
    return std::make_shared<margelo::nitro::mlxreactnative::HybridTTSSpecSwift>(swiftPart);
  }
  void* NON_NULL get_std__shared_ptr_HybridTTSSpec_(std__shared_ptr_HybridTTSSpec_ cppType) {
    std::shared_ptr<margelo::nitro::mlxreactnative::HybridTTSSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::mlxreactnative::HybridTTSSpecSwift>(cppType);
    #ifdef NITRO_DEBUG
    if (swiftWrapper == nullptr) [[unlikely]] {
      throw std::runtime_error("Class \"HybridTTSSpec\" is not implemented in Swift!");
    }
    #endif
    MLXReactNative::HybridTTSSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
    return swiftPart.toUnsafe();
  }

} // namespace margelo::nitro::mlxreactnative::bridge::swift
