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

#pragma once

#include "Modules/ModuleManager.h"

INWORLDRUNTIME_API DECLARE_LOG_CATEGORY_EXTERN(LogInworldRuntime, Log, All);

struct FInworldData_Struct;

/**
 * @class FInworldRuntimeModule
 * @brief Main module class for the Inworld Runtime plugin.
 *
 * This class manages the lifecycle of the Inworld Runtime plugin, handling
 * module startup, shutdown, and configuration of telemetry and endpoint settings.
 */
class FInworldRuntimeModule : public IModuleInterface
{
public:
	static FInworldRuntimeModule& Get()
	{
		return FModuleManager::Get().GetModuleChecked<FInworldRuntimeModule>("InworldRuntime");
	}

	/** IModuleInterface implementation */
	virtual void StartupModule() override;
	virtual void ShutdownModule() override;

	/**
	 * @brief Configures telemetry settings for the runtime system.
	 */
	void ConfigureTelemetry();

	/**
	 * @brief Initialize environment variables for the runtime system.
	 */
	void InitEnvironmentVariables();

#if WITH_EDITOR
	DECLARE_EVENT_TwoParams(FInworldRuntimeModule, FInworldEmitTrackingEvent, const FString&, const FInworldData_Struct&)

		FInworldEmitTrackingEvent OnEmitTrackingEvent;
#endif

private:
	void* DllHandle{nullptr};
	bool bTelemetryConfigured{false};
};
