///
/// Progress.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 <optional>

namespace margelo::nitro::videopipeline {

  /**
   * A struct which can be represented as a JavaScript object (Progress).
   */
  struct Progress final {
  public:
    double framesCompleted     SWIFT_PRIVATE;
    std::optional<double> nbFrames     SWIFT_PRIVATE;
    double elapsedMs     SWIFT_PRIVATE;
    std::optional<double> estimatedRemainingMs     SWIFT_PRIVATE;

  public:
    Progress() = default;
    explicit Progress(double framesCompleted, std::optional<double> nbFrames, double elapsedMs, std::optional<double> estimatedRemainingMs): framesCompleted(framesCompleted), nbFrames(nbFrames), elapsedMs(elapsedMs), estimatedRemainingMs(estimatedRemainingMs) {}

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

} // namespace margelo::nitro::videopipeline

namespace margelo::nitro {

  // C++ Progress <> JS Progress (object)
  template <>
  struct JSIConverter<margelo::nitro::videopipeline::Progress> final {
    static inline margelo::nitro::videopipeline::Progress fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::videopipeline::Progress(
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "framesCompleted"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "nbFrames"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "elapsedMs"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "estimatedRemainingMs")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::videopipeline::Progress& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "framesCompleted"), JSIConverter<double>::toJSI(runtime, arg.framesCompleted));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "nbFrames"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.nbFrames));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "elapsedMs"), JSIConverter<double>::toJSI(runtime, arg.elapsedMs));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "estimatedRemainingMs"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.estimatedRemainingMs));
      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<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "framesCompleted")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "nbFrames")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "elapsedMs")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "estimatedRemainingMs")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
