/**
 * Copyright 2022-2025 Theai, Inc. dba Inworld AI
 */

#pragma once

#include "InworldKeywordMatcherTypes.generated.h"

INWORLDRUNTIME_API DECLARE_LOG_CATEGORY_EXTERN(LogInworldKeywordMatcher, Log, All);

/**
 * @struct FInworldKeywordGroup
 * @brief Represents a named group of keywords.
 *
 * A KeywordGroup is a simple collection of related keywords that are
 * matched together. Groups help organize keywords by category (e.g.,
 * "unsafe_words", "sensitive_topics", "brand_names").
 *
 * @param Name
 * Unique identifier for this keyword group. Used to identify which group
 * triggered a match in the results.
 *
 * @param Keywords
 * List of keywords or phrases to match in this group. Can include single
 * words or multi-word phrases.
 */
USTRUCT(BlueprintType)
struct INWORLDRUNTIME_API FInworldKeywordGroup
{
	GENERATED_BODY()

	/** Unique name for this keyword group */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Inworld|Data",
		Meta =
			(ToolTip = "Unique identifier for this keyword group. Used to identify which group triggered a match in the results"))
	FString Name;

	/** List of keywords to match */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Inworld|Data",
		Meta = (ToolTip = "List of keywords or phrases to match in this group. Can include single words or multi-word phrases"))
	TArray<FString> Keywords;
};

/**
 * @struct FInworldKeywordMatch
 * @brief Information about a matched keyword.
 *
 * @param GroupName
 * The name of the keyword group that contained the matched keyword.
 *
 * @param Keyword
 * The keyword from the group that was matched.
 */
USTRUCT(BlueprintType)
struct INWORLDRUNTIME_API FInworldKeywordMatch
{
	GENERATED_BODY()

	/** Name of the keyword group that matched */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Inworld|Data",
		Meta = (ToolTip = "The name of the keyword group that contained the matched keyword"))
	FString GroupName;

	/** The keyword that was matched */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Inworld|Data",
		Meta = (ToolTip = "The keyword from the group that was matched"))
	FString Keyword;
};

/**
 * @struct FInworldKeywordMatcherNodeCreationConfig
 * @brief Configuration for creating the KeywordMatcherNode.
 *
 * KeywordMatcherNodeCreationConfig contains the configuration parameters
 * used at creation time to instantiate the underlying keyword matcher.
 */
USTRUCT(BlueprintType)
struct FInworldKeywordMatcherNodeCreationConfig
{
	GENERATED_BODY()

	/** Vector of keyword groups for matching */
	UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Inworld|TextClassifier",
		Meta = (ToolTip = "Array of keyword groups used for matching keywords in text input"))
	TArray<FInworldKeywordGroup> KeywordGroups;
};
