///
/// SpeechSynthesisUtterance.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



#include <string>
#include <optional>

namespace margelo::nitro::one {

  /**
   * A struct which can be represented as a JavaScript object (SpeechSynthesisUtterance).
   */
  struct SpeechSynthesisUtterance final {
  public:
    std::string text     SWIFT_PRIVATE;
    std::optional<std::string> language     SWIFT_PRIVATE;
    std::optional<double> pitch     SWIFT_PRIVATE;
    std::optional<double> rate     SWIFT_PRIVATE;
    std::optional<std::string> voice     SWIFT_PRIVATE;
    std::optional<double> volume     SWIFT_PRIVATE;

  public:
    SpeechSynthesisUtterance() = default;
    explicit SpeechSynthesisUtterance(std::string text, std::optional<std::string> language, std::optional<double> pitch, std::optional<double> rate, std::optional<std::string> voice, std::optional<double> volume): text(text), language(language), pitch(pitch), rate(rate), voice(voice), volume(volume) {}

  public:
    friend bool operator==(const SpeechSynthesisUtterance& lhs, const SpeechSynthesisUtterance& rhs) = default;
  };

} // namespace margelo::nitro::one

namespace margelo::nitro {

  // C++ SpeechSynthesisUtterance <> JS SpeechSynthesisUtterance (object)
  template <>
  struct JSIConverter<margelo::nitro::one::SpeechSynthesisUtterance> final {
    static inline margelo::nitro::one::SpeechSynthesisUtterance fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::one::SpeechSynthesisUtterance(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "text"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "language"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "pitch"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rate"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "voice"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "volume")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::one::SpeechSynthesisUtterance& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "text"), JSIConverter<std::string>::toJSI(runtime, arg.text));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "language"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.language));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "pitch"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.pitch));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "rate"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.rate));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "voice"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.voice));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "volume"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.volume));
      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, "text")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "language")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "pitch")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rate")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "voice")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "volume")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
