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





namespace margelo::nitro::aviation {

  /**
   * A struct which can be represented as a JavaScript object (MediaPosition).
   */
  struct MediaPosition final {
  public:
    double currentMs     SWIFT_PRIVATE;
    double durationMs     SWIFT_PRIVATE;
    double seekableStartMs     SWIFT_PRIVATE;
    double seekableEndMs     SWIFT_PRIVATE;
    bool isLive     SWIFT_PRIVATE;
    double progress     SWIFT_PRIVATE;
    double liveEdgeOffsetMs     SWIFT_PRIVATE;
    bool isAtLiveEdge     SWIFT_PRIVATE;

  public:
    MediaPosition() = default;
    explicit MediaPosition(double currentMs, double durationMs, double seekableStartMs, double seekableEndMs, bool isLive, double progress, double liveEdgeOffsetMs, bool isAtLiveEdge): currentMs(currentMs), durationMs(durationMs), seekableStartMs(seekableStartMs), seekableEndMs(seekableEndMs), isLive(isLive), progress(progress), liveEdgeOffsetMs(liveEdgeOffsetMs), isAtLiveEdge(isAtLiveEdge) {}

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

} // namespace margelo::nitro::aviation

namespace margelo::nitro {

  // C++ MediaPosition <> JS MediaPosition (object)
  template <>
  struct JSIConverter<margelo::nitro::aviation::MediaPosition> final {
    static inline margelo::nitro::aviation::MediaPosition fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::aviation::MediaPosition(
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "currentMs"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "durationMs"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "seekableStartMs"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "seekableEndMs"))),
        JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isLive"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "progress"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "liveEdgeOffsetMs"))),
        JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isAtLiveEdge")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::aviation::MediaPosition& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "currentMs"), JSIConverter<double>::toJSI(runtime, arg.currentMs));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "durationMs"), JSIConverter<double>::toJSI(runtime, arg.durationMs));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "seekableStartMs"), JSIConverter<double>::toJSI(runtime, arg.seekableStartMs));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "seekableEndMs"), JSIConverter<double>::toJSI(runtime, arg.seekableEndMs));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "isLive"), JSIConverter<bool>::toJSI(runtime, arg.isLive));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "progress"), JSIConverter<double>::toJSI(runtime, arg.progress));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "liveEdgeOffsetMs"), JSIConverter<double>::toJSI(runtime, arg.liveEdgeOffsetMs));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "isAtLiveEdge"), JSIConverter<bool>::toJSI(runtime, arg.isAtLiveEdge));
      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, "currentMs")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "durationMs")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "seekableStartMs")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "seekableEndMs")))) return false;
      if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isLive")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "progress")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "liveEdgeOffsetMs")))) return false;
      if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isAtLiveEdge")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
