///
/// DeviceTraits.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 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

// Forward declaration of `ColorScheme` to properly resolve imports.
namespace margelo::nitro::stylesheet { enum class ColorScheme; }
// Forward declaration of `ScreenDimensions` to properly resolve imports.
namespace margelo::nitro::stylesheet { struct ScreenDimensions; }
// Forward declaration of `ScreenInsets` to properly resolve imports.
namespace margelo::nitro::stylesheet { struct ScreenInsets; }
// Forward declaration of `ScreenOrientation` to properly resolve imports.
namespace margelo::nitro::stylesheet { enum class ScreenOrientation; }

#include "ColorScheme.hpp"
#include "ScreenDimensions.hpp"
#include <string>
#include "ScreenInsets.hpp"
#include "ScreenOrientation.hpp"

namespace margelo::nitro::stylesheet {

  /**
   * A struct which can be represented as a JavaScript object (DeviceTraits).
   */
  struct DeviceTraits {
  public:
    ColorScheme colorScheme     SWIFT_PRIVATE;
    ScreenDimensions screenDimensions     SWIFT_PRIVATE;
    std::string contentSizeCategory     SWIFT_PRIVATE;
    ScreenInsets screenInsets     SWIFT_PRIVATE;
    double displayScale     SWIFT_PRIVATE;
    double fontScale     SWIFT_PRIVATE;
    bool isRTL     SWIFT_PRIVATE;
    ScreenOrientation screenOrientation     SWIFT_PRIVATE;
    double pixelRatio     SWIFT_PRIVATE;

  public:
    explicit DeviceTraits(ColorScheme colorScheme, ScreenDimensions screenDimensions, std::string contentSizeCategory, ScreenInsets screenInsets, double displayScale, double fontScale, bool isRTL, ScreenOrientation screenOrientation, double pixelRatio): colorScheme(colorScheme), screenDimensions(screenDimensions), contentSizeCategory(contentSizeCategory), screenInsets(screenInsets), displayScale(displayScale), fontScale(fontScale), isRTL(isRTL), screenOrientation(screenOrientation), pixelRatio(pixelRatio) {}
  };

} // namespace margelo::nitro::stylesheet

namespace margelo::nitro {

  using namespace margelo::nitro::stylesheet;

  // C++ DeviceTraits <> JS DeviceTraits (object)
  template <>
  struct JSIConverter<DeviceTraits> {
    static inline DeviceTraits fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return DeviceTraits(
        JSIConverter<ColorScheme>::fromJSI(runtime, obj.getProperty(runtime, "colorScheme")),
        JSIConverter<ScreenDimensions>::fromJSI(runtime, obj.getProperty(runtime, "screenDimensions")),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "contentSizeCategory")),
        JSIConverter<ScreenInsets>::fromJSI(runtime, obj.getProperty(runtime, "screenInsets")),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "displayScale")),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "fontScale")),
        JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "isRTL")),
        JSIConverter<ScreenOrientation>::fromJSI(runtime, obj.getProperty(runtime, "screenOrientation")),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "pixelRatio"))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const DeviceTraits& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, "colorScheme", JSIConverter<ColorScheme>::toJSI(runtime, arg.colorScheme));
      obj.setProperty(runtime, "screenDimensions", JSIConverter<ScreenDimensions>::toJSI(runtime, arg.screenDimensions));
      obj.setProperty(runtime, "contentSizeCategory", JSIConverter<std::string>::toJSI(runtime, arg.contentSizeCategory));
      obj.setProperty(runtime, "screenInsets", JSIConverter<ScreenInsets>::toJSI(runtime, arg.screenInsets));
      obj.setProperty(runtime, "displayScale", JSIConverter<double>::toJSI(runtime, arg.displayScale));
      obj.setProperty(runtime, "fontScale", JSIConverter<double>::toJSI(runtime, arg.fontScale));
      obj.setProperty(runtime, "isRTL", JSIConverter<bool>::toJSI(runtime, arg.isRTL));
      obj.setProperty(runtime, "screenOrientation", JSIConverter<ScreenOrientation>::toJSI(runtime, arg.screenOrientation));
      obj.setProperty(runtime, "pixelRatio", JSIConverter<double>::toJSI(runtime, arg.pixelRatio));
      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<ColorScheme>::canConvert(runtime, obj.getProperty(runtime, "colorScheme"))) return false;
      if (!JSIConverter<ScreenDimensions>::canConvert(runtime, obj.getProperty(runtime, "screenDimensions"))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "contentSizeCategory"))) return false;
      if (!JSIConverter<ScreenInsets>::canConvert(runtime, obj.getProperty(runtime, "screenInsets"))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "displayScale"))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "fontScale"))) return false;
      if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "isRTL"))) return false;
      if (!JSIConverter<ScreenOrientation>::canConvert(runtime, obj.getProperty(runtime, "screenOrientation"))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "pixelRatio"))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
