///
/// HybridNitroGoogleSsoSpecSwift.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///

#pragma once

#include "HybridNitroGoogleSsoSpec.hpp"

// Forward declaration of `HybridNitroGoogleSsoSpec_cxx` to properly resolve imports.
namespace NitroGoogleSso { class HybridNitroGoogleSsoSpec_cxx; }

// Forward declaration of `NitroGoogleSSOConfig` to properly resolve imports.
namespace margelo::nitro::nitrogooglesso { struct NitroGoogleSSOConfig; }
// Forward declaration of `NitroGoogleUserInfo` to properly resolve imports.
namespace margelo::nitro::nitrogooglesso { struct NitroGoogleUserInfo; }

#include "NitroGoogleSSOConfig.hpp"
#include <string>
#include <optional>
#include <NitroModules/Null.hpp>
#include "NitroGoogleUserInfo.hpp"
#include <variant>
#include <NitroModules/Promise.hpp>

#include "NitroGoogleSso-Swift-Cxx-Umbrella.hpp"

namespace margelo::nitro::nitrogooglesso {

  /**
   * The C++ part of HybridNitroGoogleSsoSpec_cxx.swift.
   *
   * HybridNitroGoogleSsoSpecSwift (C++) accesses HybridNitroGoogleSsoSpec_cxx (Swift), and might
   * contain some additional bridging code for C++ <> Swift interop.
   *
   * Since this obviously introduces an overhead, I hope at some point in
   * the future, HybridNitroGoogleSsoSpec_cxx can directly inherit from the C++ class HybridNitroGoogleSsoSpec
   * to simplify the whole structure and memory management.
   */
  class HybridNitroGoogleSsoSpecSwift: public virtual HybridNitroGoogleSsoSpec {
  public:
    // Constructor from a Swift instance
    explicit HybridNitroGoogleSsoSpecSwift(const NitroGoogleSso::HybridNitroGoogleSsoSpec_cxx& swiftPart):
      HybridObject(HybridNitroGoogleSsoSpec::TAG),
      _swiftPart(swiftPart) { }

  public:
    // Get the Swift part
    inline NitroGoogleSso::HybridNitroGoogleSsoSpec_cxx& getSwiftPart() noexcept {
      return _swiftPart;
    }

  public:
    inline size_t getExternalMemorySize() noexcept override {
      return _swiftPart.getMemorySize();
    }
    bool equals(const std::shared_ptr<HybridObject>& other) override {
      if (auto otherCast = std::dynamic_pointer_cast<HybridNitroGoogleSsoSpecSwift>(other)) {
        return _swiftPart.equals(otherCast->_swiftPart);
      }
      return false;
    }
    void dispose() noexcept override {
      _swiftPart.dispose();
    }
    std::string toString() override {
      return _swiftPart.toString();
    }

  public:
    // Properties
    

  public:
    // Methods
    inline void configure(const NitroGoogleSSOConfig& config) override {
      auto __result = _swiftPart.configure(std::forward<decltype(config)>(config));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline std::shared_ptr<Promise<std::variant<nitro::NullType, NitroGoogleUserInfo>>> signIn() override {
      auto __result = _swiftPart.signIn();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::variant<nitro::NullType, NitroGoogleUserInfo>>> oneTapSignIn() override {
      auto __result = _swiftPart.oneTapSignIn();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> signOut() override {
      auto __result = _swiftPart.signOut();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::variant<nitro::NullType, NitroGoogleUserInfo>>> getCurrentUser() override {
      auto __result = _swiftPart.getCurrentUser();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }

  private:
    NitroGoogleSso::HybridNitroGoogleSsoSpec_cxx _swiftPart;
  };

} // namespace margelo::nitro::nitrogooglesso
