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

#pragma once

#include <optional>
#include <NitroModules/NitroDefines.hpp>
#include <NitroModules/NitroHash.hpp>
#include <NitroModules/CachedProp.hpp>
#include <react/renderer/core/ConcreteComponentDescriptor.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
#include <react/renderer/components/view/ViewProps.h>

#include <vector>
#include <optional>
#include "Vector.hpp"
#include <memory>
#include "HybridLinearGradientViewSpec.hpp"
#include <functional>

namespace margelo::nitro::gradient::views {

  using namespace facebook;

  /**
   * The name of the actual native View.
   */
  extern const char HybridLinearGradientViewComponentName[];

  /**
   * Props for the "LinearGradientView" View.
   */
  class HybridLinearGradientViewProps final: public react::ViewProps {
  public:
    HybridLinearGradientViewProps() = default;
    HybridLinearGradientViewProps(const HybridLinearGradientViewProps&);
    HybridLinearGradientViewProps(const react::PropsParserContext& context,
                                  const HybridLinearGradientViewProps& sourceProps,
                                  const react::RawProps& rawProps);

  public:
    CachedProp<std::vector<double>> colors;
    CachedProp<std::optional<std::vector<double>>> positions;
    CachedProp<std::optional<Vector>> start;
    CachedProp<std::optional<Vector>> end;
    CachedProp<std::optional<double>> angle;
    CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridLinearGradientViewSpec>& /* ref */)>>> hybridRef;

  private:
    static bool filterObjectKeys(const std::string& propName);
  };

  /**
   * State for the "LinearGradientView" View.
   */
  class HybridLinearGradientViewState final {
  public:
    HybridLinearGradientViewState() = default;

  public:
    void setProps(const HybridLinearGradientViewProps& props) { _props.emplace(props); }
    const std::optional<HybridLinearGradientViewProps>& getProps() const { return _props; }

  public:
#ifdef ANDROID
  HybridLinearGradientViewState(const HybridLinearGradientViewState& /* previousState */, folly::dynamic /* data */) {}
  folly::dynamic getDynamic() const {
    throw std::runtime_error("HybridLinearGradientViewState does not support folly!");
  }
  react::MapBuffer getMapBuffer() const {
    throw std::runtime_error("HybridLinearGradientViewState does not support MapBuffer!");
  };
#endif

  private:
    std::optional<HybridLinearGradientViewProps> _props;
  };

  /**
   * The Shadow Node for the "LinearGradientView" View.
   */
  using HybridLinearGradientViewShadowNode = react::ConcreteViewShadowNode<HybridLinearGradientViewComponentName /* "HybridLinearGradientView" */,
                                                                           HybridLinearGradientViewProps /* custom props */,
                                                                           react::ViewEventEmitter /* default */,
                                                                           HybridLinearGradientViewState /* custom state */>;

  /**
   * The Component Descriptor for the "LinearGradientView" View.
   */
  class HybridLinearGradientViewComponentDescriptor final: public react::ConcreteComponentDescriptor<HybridLinearGradientViewShadowNode> {
  public:
    HybridLinearGradientViewComponentDescriptor(const react::ComponentDescriptorParameters& parameters);

  public:
    /**
     * A faster path for cloning props - reuses the caching logic from `HybridLinearGradientViewProps`.
     */
    std::shared_ptr<const react::Props> cloneProps(const react::PropsParserContext& context,
                                                   const std::shared_ptr<const react::Props>& props,
                                                   react::RawProps rawProps) const override;
#ifdef ANDROID
    void adopt(react::ShadowNode& shadowNode) const override;
#endif
  };

  /* The actual view for "LinearGradientView" needs to be implemented in platform-specific code. */

} // namespace margelo::nitro::gradient::views
