#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "HyperTwistTraining/HyperTwistTrainingTypes.h"
#include "HyperTwistTrainingPersistenceLibrary.generated.h"

UCLASS()
class UNREALHYPERTWIST_API UHyperTwistTrainingPersistenceLibrary : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()

public:
	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Persistence")
	static FString GetDefaultTrainingRepositoryPath();

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Persistence")
	static FString ResolveTrainingRepositoryPath(const FString& RepositoryPath);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Persistence")
	static FString GetDefaultTrainingRepositoryVerificationPath();

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Persistence")
	static FString ResolveTrainingRepositoryVerificationPath(const FString& RepositoryPath);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Persistence")
	static FString GetDefaultTrainingTimerExportPath(const FString& UserId, const FString& DeckId);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Persistence")
	static FString ResolveTrainingTimerExportPath(
		const FString& UserId,
		const FString& DeckId,
		const FString& ExportPath
	);

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Persistence")
	static bool SaveTrainingRepositoryStateToFile(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& RepositoryPath,
		FString& OutResolvedPath
	);

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Persistence")
	static bool SaveTrainingTimerExportPacketToFile(
		const FHyperTwistTrainingTimerExportPacket& TimerExportPacket,
		const FString& ExportPath,
		FString& OutResolvedPath
	);

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Persistence")
	static bool LoadTrainingRepositoryStateFromFile(
		const FString& RepositoryPath,
		FHyperTwistTrainingRepositoryState& OutRepositoryState,
		FString& OutResolvedPath
	);

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Persistence")
	static FHyperTwistTrainingRepositoryRoundTripVerification VerifyTrainingRepositoryStateRoundTrip(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& RepositoryPath
	);

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Persistence")
	static bool LoadTrainingTimerExportPacketFromFile(
		const FString& UserId,
		const FString& DeckId,
		const FString& ExportPath,
		FHyperTwistTrainingTimerExportPacket& OutTimerExportPacket,
		FString& OutResolvedPath
	);
};
