///
/// HybridTTSSpecSwift.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2026 Marc Rousavy @ Margelo
///

#pragma once

#include "HybridTTSSpec.hpp"

// Forward declaration of `HybridTTSSpec_cxx` to properly resolve imports.
namespace MLXReactNative { class HybridTTSSpec_cxx; }

// Forward declaration of `TTSLoadOptions` to properly resolve imports.
namespace margelo::nitro::mlxreactnative { struct TTSLoadOptions; }
// Forward declaration of `ArrayBufferHolder` to properly resolve imports.
namespace NitroModules { class ArrayBufferHolder; }
// Forward declaration of `TTSGenerateOptions` to properly resolve imports.
namespace margelo::nitro::mlxreactnative { struct TTSGenerateOptions; }

#include <string>
#include <NitroModules/Promise.hpp>
#include "TTSLoadOptions.hpp"
#include <optional>
#include <functional>
#include <NitroModules/ArrayBuffer.hpp>
#include <NitroModules/ArrayBufferHolder.hpp>
#include "TTSGenerateOptions.hpp"

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

namespace margelo::nitro::mlxreactnative {

  /**
   * The C++ part of HybridTTSSpec_cxx.swift.
   *
   * HybridTTSSpecSwift (C++) accesses HybridTTSSpec_cxx (Swift), and might
   * contain some additional bridging code for C++ <> Swift interop.
   *
   * Since this obviously introduces an overhead, I hope at some point in
   * the future, HybridTTSSpec_cxx can directly inherit from the C++ class HybridTTSSpec
   * to simplify the whole structure and memory management.
   */
  class HybridTTSSpecSwift: public virtual HybridTTSSpec {
  public:
    // Constructor from a Swift instance
    explicit HybridTTSSpecSwift(const MLXReactNative::HybridTTSSpec_cxx& swiftPart):
      HybridObject(HybridTTSSpec::TAG),
      _swiftPart(swiftPart) { }

  public:
    // Get the Swift part
    inline MLXReactNative::HybridTTSSpec_cxx& getSwiftPart() noexcept {
      return _swiftPart;
    }

  public:
    inline size_t getExternalMemorySize() noexcept override {
      return _swiftPart.getMemorySize();
    }
    void dispose() noexcept override {
      _swiftPart.dispose();
    }
    std::string toString() override {
      return _swiftPart.toString();
    }

  public:
    // Properties
    inline bool getIsLoaded() noexcept override {
      return _swiftPart.isLoaded();
    }
    inline bool getIsGenerating() noexcept override {
      return _swiftPart.isGenerating();
    }
    inline std::string getModelId() noexcept override {
      auto __result = _swiftPart.getModelId();
      return __result;
    }
    inline double getSampleRate() noexcept override {
      return _swiftPart.getSampleRate();
    }

  public:
    // Methods
    inline std::shared_ptr<Promise<void>> load(const std::string& modelId, const std::optional<TTSLoadOptions>& options) override {
      auto __result = _swiftPart.load(modelId, options);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::shared_ptr<ArrayBuffer>>> generate(const std::string& text, const std::optional<TTSGenerateOptions>& options) override {
      auto __result = _swiftPart.generate(text, options);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> stream(const std::string& text, const std::function<void(const std::shared_ptr<ArrayBuffer>& /* audio */)>& onAudioChunk, const std::optional<TTSGenerateOptions>& options) override {
      auto __result = _swiftPart.stream(text, onAudioChunk, options);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void stop() override {
      auto __result = _swiftPart.stop();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void unload() override {
      auto __result = _swiftPart.unload();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }

  private:
    MLXReactNative::HybridTTSSpec_cxx _swiftPart;
  };

} // namespace margelo::nitro::mlxreactnative
