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



#include <optional>

namespace margelo::nitro::video {

  /**
   * A struct which can be represented as a JavaScript object (LivePlaybackParams).
   */
  struct LivePlaybackParams {
  public:
    std::optional<double> minPlaybackSpeed     SWIFT_PRIVATE;
    std::optional<double> maxPlaybackSpeed     SWIFT_PRIVATE;
    std::optional<double> maxOffsetMs     SWIFT_PRIVATE;
    std::optional<double> minOffsetMs     SWIFT_PRIVATE;
    std::optional<double> targetOffsetMs     SWIFT_PRIVATE;

  public:
    LivePlaybackParams() = default;
    explicit LivePlaybackParams(std::optional<double> minPlaybackSpeed, std::optional<double> maxPlaybackSpeed, std::optional<double> maxOffsetMs, std::optional<double> minOffsetMs, std::optional<double> targetOffsetMs): minPlaybackSpeed(minPlaybackSpeed), maxPlaybackSpeed(maxPlaybackSpeed), maxOffsetMs(maxOffsetMs), minOffsetMs(minOffsetMs), targetOffsetMs(targetOffsetMs) {}
  };

} // namespace margelo::nitro::video

namespace margelo::nitro {

  // C++ LivePlaybackParams <> JS LivePlaybackParams (object)
  template <>
  struct JSIConverter<margelo::nitro::video::LivePlaybackParams> final {
    static inline margelo::nitro::video::LivePlaybackParams fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::video::LivePlaybackParams(
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "minPlaybackSpeed")),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "maxPlaybackSpeed")),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "maxOffsetMs")),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "minOffsetMs")),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "targetOffsetMs"))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::video::LivePlaybackParams& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, "minPlaybackSpeed", JSIConverter<std::optional<double>>::toJSI(runtime, arg.minPlaybackSpeed));
      obj.setProperty(runtime, "maxPlaybackSpeed", JSIConverter<std::optional<double>>::toJSI(runtime, arg.maxPlaybackSpeed));
      obj.setProperty(runtime, "maxOffsetMs", JSIConverter<std::optional<double>>::toJSI(runtime, arg.maxOffsetMs));
      obj.setProperty(runtime, "minOffsetMs", JSIConverter<std::optional<double>>::toJSI(runtime, arg.minOffsetMs));
      obj.setProperty(runtime, "targetOffsetMs", JSIConverter<std::optional<double>>::toJSI(runtime, arg.targetOffsetMs));
      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<double>>::canConvert(runtime, obj.getProperty(runtime, "minPlaybackSpeed"))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "maxPlaybackSpeed"))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "maxOffsetMs"))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "minOffsetMs"))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "targetOffsetMs"))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
