// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef IOS_CHROME_BROWSER_CONTEXTUAL_PANEL_MODEL_CONTEXTUAL_PANEL_ITEM_CONFIGURATION_H_
#define IOS_CHROME_BROWSER_CONTEXTUAL_PANEL_MODEL_CONTEXTUAL_PANEL_ITEM_CONFIGURATION_H_

#import <string>

#import "base/feature_list.h"
#import "base/functional/callback.h"
#import "base/memory/weak_ptr.h"
#import "base/time/time.h"
#import "ios/chrome/browser/shared/ui/symbols/symbols.h"

enum class ContextualPanelItemType;

// Data to configure a Contextual Panel item. Individual features can subclass
// this to add their own data.
struct ContextualPanelItemConfiguration {
  // A constant defined to always be a high relevance amount.
  static const int high_relevance;

  // A constant defined to always be a low relevance amount.
  static const int low_relevance;

  explicit ContextualPanelItemConfiguration(ContextualPanelItemType item_type);
  virtual ~ContextualPanelItemConfiguration();
  ContextualPanelItemConfiguration(
      const ContextualPanelItemConfiguration& other) = delete;
  ContextualPanelItemConfiguration& operator=(
      const ContextualPanelItemConfiguration& other) = delete;

  // Helper for checking if a given config can be used to show different
  // entrypoint loud moment states.
  bool CanShowLargeEntrypoint();
  bool CanShowEntrypointIPH();


  // Notify the configuration that it transitioned to a small entrypoint so it
  // can react accordingly depending on the type of configuration.
  virtual void DidTransitionToSmallEntrypoint();

  // The item type of this item.
  const ContextualPanelItemType item_type;

  // The string the UI can show the user if this item is the primary item in the
  // contextual panel. If none is provided, no large entrypoint can be shown.
  std::string entrypoint_message;

  // If this is the primary item in the contextual panel, then the message
  // always will be shown using a larger entrypoint.
  bool entrypoint_message_large_entrypoint_always_shown = false;


  // Required. The string the entrypoint's badge button should have for
  // accessibility label.
  std::string accessibility_label;

  // Optional. The string the entrypoint's badge button should have for
  // accessibility hint.
  std::string accessibility_hint;

  // Required. The symbol the UI can show the user if this item is the primary
  // item in the contextual panel.
  Symbol entrypoint_symbol;

  // Optional. If this is set, then this will be called when tapping the
  // contextual panel entrypoint while this item is the primary item, instead of
  // opening the contextual panel. If the contextual panel is already opened,
  // then it will be closed before the action is performed.
  base::RepeatingClosure entrypoint_custom_action;

  // Required. A value from 0 to 100 representing the relevance of this item to
  // the user. Individual panel models can use one of the provided constants or
  // set their own value.
  int relevance;

  // ** Entrypoint IPH (rich IPH type) related config keys. **

  // Optional. The FET feature controlling the impressions for the item's
  // entrypoint rich IPH (in-product help). The entrypoint will try to show the
  // IPH, but if the FET config decides it shouldn't be shown, the large
  // entrypoint will be shown. If nothing is set here, the IPH will never be
  // shown.
  raw_ptr<const base::Feature> iph_feature;

  // Optional (required if `iph_feature` is non-nil). The FET event name the
  // entrypoint should use when firing an event because the entrypoint was used
  // with the current infoblock model (the `used` key of the FET config). Any
  // number of events can be used in conjunction with the FET config to control
  // the IPH impressions.
  std::string iph_entrypoint_used_event_name;

  // Optional (required if `iph_feature` is non-nil). The FET event name the
  // entrypoint should use when firing an event because the in-product help was
  // explicitly dismissed by the user. Any number of events can be used in
  // conjunction with the FET config to control the IPH impressions.
  std::string iph_entrypoint_explicitly_dismissed;

  // Optional (required if `iph_feature` is non-nil). The title of the rich IPH
  // bubble.
  std::string iph_title;

  // Optional (required if `iph_feature` is non-nil). The main body text of the
  // rich IPH bubble.
  std::string iph_text;

  // ** End of entrypoint IPH (rich IPH type) related config keys. **

  base::WeakPtrFactory<ContextualPanelItemConfiguration> weak_ptr_factory{this};
};

#endif  // IOS_CHROME_BROWSER_CONTEXTUAL_PANEL_MODEL_CONTEXTUAL_PANEL_ITEM_CONFIGURATION_H_
