///
/// InterruptionReason.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/NitroHash.hpp>)
#include <NitroModules/NitroHash.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#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

namespace margelo::nitro::camera {

  /**
   * An enum which can be represented as a JavaScript union (InterruptionReason).
   */
  enum class InterruptionReason {
    UNKNOWN      SWIFT_NAME(unknown) = 0,
    VIDEO_DEVICE_NOT_AVAILABLE_IN_BACKGROUND      SWIFT_NAME(videoDeviceNotAvailableInBackground) = 1,
    AUDIO_DEVICE_IN_USE_BY_ANOTHER_CLIENT      SWIFT_NAME(audioDeviceInUseByAnotherClient) = 2,
    VIDEO_DEVICE_IN_USE_BY_ANOTHER_CLIENT      SWIFT_NAME(videoDeviceInUseByAnotherClient) = 3,
    VIDEO_DEVICE_NOT_AVAILABLE_WITH_MULTIPLE_FOREGROUND_APPS      SWIFT_NAME(videoDeviceNotAvailableWithMultipleForegroundApps) = 4,
    VIDEO_DEVICE_NOT_AVAILABLE_DUE_TO_SYSTEM_PRESSURE      SWIFT_NAME(videoDeviceNotAvailableDueToSystemPressure) = 5,
    SENSITIVE_CONTENT_MITIGATION_ACTIVATED      SWIFT_NAME(sensitiveContentMitigationActivated) = 6,
  } CLOSED_ENUM;

} // namespace margelo::nitro::camera

namespace margelo::nitro {

  // C++ InterruptionReason <> JS InterruptionReason (union)
  template <>
  struct JSIConverter<margelo::nitro::camera::InterruptionReason> final {
    static inline margelo::nitro::camera::InterruptionReason fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
      switch (hashString(unionValue.c_str(), unionValue.size())) {
        case hashString("unknown"): return margelo::nitro::camera::InterruptionReason::UNKNOWN;
        case hashString("video-device-not-available-in-background"): return margelo::nitro::camera::InterruptionReason::VIDEO_DEVICE_NOT_AVAILABLE_IN_BACKGROUND;
        case hashString("audio-device-in-use-by-another-client"): return margelo::nitro::camera::InterruptionReason::AUDIO_DEVICE_IN_USE_BY_ANOTHER_CLIENT;
        case hashString("video-device-in-use-by-another-client"): return margelo::nitro::camera::InterruptionReason::VIDEO_DEVICE_IN_USE_BY_ANOTHER_CLIENT;
        case hashString("video-device-not-available-with-multiple-foreground-apps"): return margelo::nitro::camera::InterruptionReason::VIDEO_DEVICE_NOT_AVAILABLE_WITH_MULTIPLE_FOREGROUND_APPS;
        case hashString("video-device-not-available-due-to-system-pressure"): return margelo::nitro::camera::InterruptionReason::VIDEO_DEVICE_NOT_AVAILABLE_DUE_TO_SYSTEM_PRESSURE;
        case hashString("sensitive-content-mitigation-activated"): return margelo::nitro::camera::InterruptionReason::SENSITIVE_CONTENT_MITIGATION_ACTIVATED;
        default: [[unlikely]]
          throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum InterruptionReason - invalid value!");
      }
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::camera::InterruptionReason arg) {
      switch (arg) {
        case margelo::nitro::camera::InterruptionReason::UNKNOWN: return JSIConverter<std::string>::toJSI(runtime, "unknown");
        case margelo::nitro::camera::InterruptionReason::VIDEO_DEVICE_NOT_AVAILABLE_IN_BACKGROUND: return JSIConverter<std::string>::toJSI(runtime, "video-device-not-available-in-background");
        case margelo::nitro::camera::InterruptionReason::AUDIO_DEVICE_IN_USE_BY_ANOTHER_CLIENT: return JSIConverter<std::string>::toJSI(runtime, "audio-device-in-use-by-another-client");
        case margelo::nitro::camera::InterruptionReason::VIDEO_DEVICE_IN_USE_BY_ANOTHER_CLIENT: return JSIConverter<std::string>::toJSI(runtime, "video-device-in-use-by-another-client");
        case margelo::nitro::camera::InterruptionReason::VIDEO_DEVICE_NOT_AVAILABLE_WITH_MULTIPLE_FOREGROUND_APPS: return JSIConverter<std::string>::toJSI(runtime, "video-device-not-available-with-multiple-foreground-apps");
        case margelo::nitro::camera::InterruptionReason::VIDEO_DEVICE_NOT_AVAILABLE_DUE_TO_SYSTEM_PRESSURE: return JSIConverter<std::string>::toJSI(runtime, "video-device-not-available-due-to-system-pressure");
        case margelo::nitro::camera::InterruptionReason::SENSITIVE_CONTENT_MITIGATION_ACTIVATED: return JSIConverter<std::string>::toJSI(runtime, "sensitive-content-mitigation-activated");
        default: [[unlikely]]
          throw std::invalid_argument("Cannot convert InterruptionReason to JS - invalid value: "
                                    + std::to_string(static_cast<int>(arg)) + "!");
      }
    }
    static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
      if (!value.isString()) {
        return false;
      }
      std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
      switch (hashString(unionValue.c_str(), unionValue.size())) {
        case hashString("unknown"):
        case hashString("video-device-not-available-in-background"):
        case hashString("audio-device-in-use-by-another-client"):
        case hashString("video-device-in-use-by-another-client"):
        case hashString("video-device-not-available-with-multiple-foreground-apps"):
        case hashString("video-device-not-available-due-to-system-pressure"):
        case hashString("sensitive-content-mitigation-activated"):
          return true;
        default:
          return false;
      }
    }
  };

} // namespace margelo::nitro
