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

#pragma once
#include "Graph/Nodes/InworldNode_TextProcessing.h"

#include "InworldNode_DialogResponseProcessor.generated.h"

/**
 * @class UInworldNode_DialogResponseProcessor
 * @brief A text processing node responsible for post-processing a character's dialog response.
 *
 * This class extends the general text processing functionality to support the removal of character names of the form: "token:"
 * (where "token" is replaced with the name specified in the Character Profile runtime data) from a text stream.
 *
 * @input FInworldData_DataStream_String
 * @output FInworldData_DataStream_String
 */
UCLASS()
class INWORLDCHARACTER_API UInworldNode_DialogResponseProcessor : public UInworldNode_GeneralTextProcessor
{
	GENERATED_BODY()

public:
	/**
	 * @brief Default constructor for the dialog response processor node.
	 */
	UInworldNode_DialogResponseProcessor();

	/** Runtime data key for accessing character profile information for name removal */
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Inworld|Graph",
		Meta = (ToolTip = "Runtime data key for accessing character profile information for name removal"))
	FName CharacterProfileRuntimeDataKey{"CharacterProfile"};

protected:
	/**
	 * @brief Retrieves the complete list of substrings to remove, including character name.
	 *
	 * This override extends the base class functionality by adding the character's name
	 * (extracted from the CharacterProfile runtime data) to the list of substrings to remove,
	 * specifically targeting patterns like "CharacterName:" in the dialogue text.
	 *
	 * @param ProcessContext The process context containing runtime data
	 * @return Vector of strings to be removed from the text stream
	 */
	virtual inworld::vector_string GetSubstringsToRemove(const UInworldProcessContext* ProcessContext) const override;

public:
	/** Whether to automatically remove the character's name followed by colon from dialogue text */
	UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Inworld",
		Meta = (EditCondition = "bRemoveSubstrings", DisplayAfter = "bRemovePlayerName",
			ToolTip = "Whether to automatically remove the character's name followed by colon from dialogue text"))
	bool bRemoveCharacterName{true};
};
