#pragma once

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

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

public:
	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingAttemptHistoryEntry MakeAttemptHistoryEntry(
		const FHyperTwistTrainingSession& Session,
		const FHyperTwistTrainingAttempt& Attempt
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static EHyperTwistTrainingReviewGrade DeriveReviewGrade(
		const FHyperTwistTrainingAttemptHistoryEntry& AttemptHistoryEntry,
		const TArray<FHyperTwistTrainingReviewHistoryEntry>& ExistingReviewHistory
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingReviewHistoryEntry MakeReviewHistoryEntry(
		const FHyperTwistTrainingSession& Session,
		const FHyperTwistTrainingAttempt& Attempt,
		const TArray<FHyperTwistTrainingReviewHistoryEntry>& ExistingReviewHistory
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingSolveHistoryEntry MakeSolveHistoryEntry(
		const FHyperTwistTrainingAttempt& Attempt
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingRunRecord BuildRunRecord(
		const FHyperTwistTrainingRunState& RunState
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Drill")
	static FHyperTwistTrainingMethodDrillFavoriteEntry MakeMethodDrillFavoriteEntry(
		const FHyperTwistTrainingMethodDrillDefinition& DrillDefinition,
		const FString& UserId,
		const FString& CaseId,
		const FString& AddedAtUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Drill")
	static TArray<FHyperTwistTrainingMethodDrillFavoriteEntry> ListMethodDrillFavorites(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& MethodSegmentId
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Drill")
	static FHyperTwistTrainingRepositoryState UpsertMethodDrillFavorite(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FHyperTwistTrainingMethodDrillFavoriteEntry& FavoriteEntry
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Drill")
	static FHyperTwistTrainingRepositoryState RemoveMethodDrillFavorite(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& DrillId,
		const FString& CaseId
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Drill")
	static TArray<FHyperTwistTrainingMethodDrillBatch> ListMethodDrillBatches(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& MethodSegmentId
	);

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Repository|Drill")
	static bool TryGetMethodDrillBatch(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& BatchId,
		FHyperTwistTrainingMethodDrillBatch& OutBatch
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Drill")
	static FHyperTwistTrainingRepositoryState UpsertMethodDrillBatch(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FHyperTwistTrainingMethodDrillBatch& DrillBatch
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Drill")
	static FHyperTwistTrainingRepositoryState RemoveMethodDrillBatch(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& BatchId
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Drill")
	static FHyperTwistTrainingMethodDrillBatchReadiness DeriveDrillBatchReadiness(
		const FHyperTwistTrainingMethodDrillBatch& DrillBatch,
		const FHyperTwistTrainingMethodDrillDefinition& CurrentDefinition
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Drill")
	static TArray<FHyperTwistTrainingMethodDrillBatch> ListResumableDrillBatches(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& MethodSegmentId
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Drill")
	static FHyperTwistTrainingMethodDrillBatch RebuildDrillBatchForResume(
		const FHyperTwistTrainingMethodDrillBatch& SavedBatch,
		const FHyperTwistTrainingMethodDrillDefinition& CurrentDefinition
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Drill")
	static FHyperTwistTrainingMethodDrillDefinition BuildDrillDefinitionFavoriteFirst(
		const FHyperTwistTrainingMethodDrillDefinition& BaseDefinition,
		const TArray<FHyperTwistTrainingMethodDrillFavoriteEntry>& Favorites,
		int32 MaxFavoriteCases
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Drill")
	static FHyperTwistTrainingSessionTemplate BuildMethodDrillFollowUpTemplate(
		const FHyperTwistTrainingMethodDrillDiagnosticPacket& DiagnosticPacket,
		const FString& TemplateId
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Social")
	static TArray<FHyperTwistTrainingFriendLinkRecord> ListFriendLinksForUser(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId
	);

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Repository|Social")
	static bool TryGetFriendLinkRecord(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& FriendUserId,
		FHyperTwistTrainingFriendLinkRecord& OutFriendLinkRecord
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Social")
	static FHyperTwistTrainingRepositoryState UpsertFriendLinkRecord(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FHyperTwistTrainingFriendLinkRecord& FriendLinkRecord
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Social")
	static FHyperTwistTrainingFriendLinkRecord ResolveFriendLinkRecordState(
		const FHyperTwistTrainingFriendLinkRecord& FriendLinkRecord,
		EHyperTwistTrainingFriendLinkState State,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Social")
	static TArray<FHyperTwistTrainingNotificationRecord> ListNotificationsForUser(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId
	);

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Repository|Social")
	static bool TryGetNotificationRecord(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& NotificationId,
		FHyperTwistTrainingNotificationRecord& OutNotificationRecord
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Social")
	static FHyperTwistTrainingRepositoryState UpsertNotificationRecord(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FHyperTwistTrainingNotificationRecord& NotificationRecord
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Social")
	static FHyperTwistTrainingRepositoryState MarkNotificationRead(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& NotificationId,
		const FString& ReadAtUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Social")
	static FHyperTwistTrainingRepositoryState AcknowledgeNotification(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& NotificationId,
		const FString& AcknowledgedAtUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Social")
	static FHyperTwistTrainingRepositoryState ArchiveNotification(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& NotificationId,
		const FString& ArchivedAtUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Social")
	static TArray<FHyperTwistTrainingChallengeRecord> ListChallengesForUser(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId
	);

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Repository|Social")
	static bool TryGetChallengeRecord(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& ChallengeId,
		FHyperTwistTrainingChallengeRecord& OutChallengeRecord
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Social")
	static FHyperTwistTrainingRepositoryState UpsertChallengeRecord(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FHyperTwistTrainingChallengeRecord& ChallengeRecord
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Social")
	static FHyperTwistTrainingChallengeRecord ResolveChallengeRecordState(
		const FHyperTwistTrainingChallengeRecord& ChallengeRecord,
		EHyperTwistTrainingChallengeLifecycleState LifecycleState,
		EHyperTwistTrainingLocalMatchReadinessState MatchReadinessState,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Social")
	static FHyperTwistTrainingChallengeComparisonBundle BuildChallengeComparisonBundle(
		const FHyperTwistTrainingChallengeRecord& ChallengeRecord
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Social")
	static FHyperTwistTrainingSocialChallengeBundle DeriveSocialChallengeBundle(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& ReferenceUtc,
		const FHyperTwistTrainingEntitlementGateState& EntitlementGateState
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|SmartDevice")
	static FHyperTwistTrainingRepositoryState UpsertSmartDeviceSessionRecord(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FHyperTwistTrainingSmartDeviceSessionRecord& SessionRecord
	);

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Repository|SmartDevice")
	static bool TryGetSmartDeviceSessionRecord(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& DeviceSessionId,
		FHyperTwistTrainingSmartDeviceSessionRecord& OutSessionRecord
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|SmartDevice")
	static bool HasSmartDeviceEventFrame(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& DeviceSessionId,
		const FString& EventId
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|SmartDevice")
	static FHyperTwistTrainingRepositoryState RecordSmartDeviceEventFrame(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FHyperTwistTrainingSmartDeviceEventFrame& EventFrame
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingRepositoryState UpsertRunRecord(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FHyperTwistTrainingRunRecord& RunRecord
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingRepositoryState RecordRunState(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FHyperTwistTrainingRunState& RunState
	);

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Repository")
	static bool TryGetRunRecord(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& TrainingSessionId,
		FHyperTwistTrainingRunRecord& OutRunRecord
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static TArray<FHyperTwistTrainingRunRecord> ListRunRecordsForDeck(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& DeckId
	);

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Repository")
	static bool TryGetLatestGeneratedModeLaunchRequestForDeck(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& DeckId,
		FHyperTwistTrainingImportedGeneratedModeLaunchRequest& OutLaunchRequest
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingCaseLearnerState DeriveLearnerStateForCase(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& DeckId,
		const FString& CaseId
	);

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Repository")
	static bool TryGetLearnerState(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& DeckId,
		const FString& CaseId,
		FHyperTwistTrainingCaseLearnerState& OutLearnerState
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static TArray<FHyperTwistTrainingCaseLearnerState> ListLearnerStatesForDeck(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& DeckId
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingDeckHistorySummary DeriveDeckHistorySummary(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& DeckId
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingTimingTrendSummary DeriveTimingTrendSummary(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& DeckId,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingPersonalBestSummary DerivePersonalBestSummary(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& DeckId,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingTimerExportPacket ExportTimerResultsForDeck(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& DeckId,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingRepositoryState ImportTimerResults(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FHyperTwistTrainingTimerExportPacket& TimerExportPacket
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingTimerExportIntegrityReport DeriveTimerExportIntegrityReport(
		const FHyperTwistTrainingTimerExportPacket& TimerExportPacket
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingTimerExportPacket NormalizeTimerExportPacket(
		const FHyperTwistTrainingTimerExportPacket& TimerExportPacket
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingRepositoryIntegrityReport DeriveRepositoryIntegrityReport(
		const FHyperTwistTrainingRepositoryState& RepositoryState
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingRepositoryState RepairRepositoryState(
		const FHyperTwistTrainingRepositoryState& RepositoryState
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingCaseScopedStats DeriveCaseScopedStats(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& DeckId,
		const FString& CaseId,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static TArray<FHyperTwistTrainingCaseScopedStats> ListCaseScopedStatsForDeck(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& DeckId,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingDeckScopedStats DeriveDeckScopedStats(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& DeckId,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingTemplateLaunchScopedStats DeriveTemplateLaunchScopedStats(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& TemplateId,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static TArray<FHyperTwistTrainingTemplateLaunchScopedStats> ListTemplateLaunchScopedStatsForUser(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingLearnerDeckStateSummary DeriveLearnerDeckStateSummary(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& DeckId,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingLearnerProfile DeriveLearnerProfile(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingCoachMemorySnapshot DeriveCoachMemorySnapshot(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static TArray<FHyperTwistTrainingMethodSegment> DeriveLearnerMethodSegments(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static TArray<FHyperTwistTrainingLearnerPreset> DeriveLearnerPresets(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static TArray<FHyperTwistTrainingSessionTemplate> DeriveTrainingSessionTemplates(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static TArray<FHyperTwistTrainingSessionTemplate> ListStoredTrainingSessionTemplates(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId
	);

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Repository")
	static bool TryGetStoredTrainingSessionTemplate(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& TemplateId,
		FHyperTwistTrainingSessionTemplate& OutTemplate
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingRepositoryState UpsertStoredTrainingSessionTemplate(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FHyperTwistTrainingSessionTemplate& SessionTemplate
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingRepositoryState RemoveStoredTrainingSessionTemplate(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& TemplateId
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static TArray<FHyperTwistTrainingSessionTemplate> MergeTrainingSessionTemplates(
		const TArray<FHyperTwistTrainingSessionTemplate>& DerivedTemplates,
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Coach")
	static FHyperTwistTrainingCoachActionPlan BuildCoachActionPlan(
		const FHyperTwistCoachBrief& CoachBrief,
		const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot,
		const FString& PlanId,
		const FString& ReferenceUtc,
		int32 RequestedLaunchCaseCount,
		int32 PlannedLaunchCaseCount,
		const FString& LaunchBudgetReasonLine,
		const TArray<FString>& LaunchedCaseIds
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Coach")
	static FHyperTwistTrainingCoachActionPlan ActivateCoachActionPlan(
		const FHyperTwistTrainingCoachActionPlan& ActionPlan,
		const FString& TrainingSessionId,
		const FString& StartedAtUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Coach")
	static FHyperTwistTrainingCoachActionPlan FinalizeCoachActionPlan(
		const FHyperTwistTrainingCoachActionPlan& ActionPlan,
		const FHyperTwistTrainingSession& Session,
		bool bAbortPlan
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Coach")
	static TArray<FHyperTwistTrainingCoachActionPlan> ListCoachActionPlansForUser(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId
	);

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Repository|Coach")
	static bool TryGetCoachActionPlan(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& PlanId,
		FHyperTwistTrainingCoachActionPlan& OutActionPlan
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Coach")
	static FHyperTwistTrainingRepositoryState UpsertCoachActionPlan(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FHyperTwistTrainingCoachActionPlan& ActionPlan
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Coach")
	static FHyperTwistTrainingCoachSessionQueueState BuildCoachSessionQueueState(
		const FHyperTwistCoachSessionQueueSummary& QueueSummary,
		const FString& QueueId,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Coach")
	static FHyperTwistTrainingCoachSessionQueueState ResolveCoachSessionQueueState(
		const FHyperTwistTrainingCoachSessionQueueState& ExistingQueueState,
		const FHyperTwistCoachSessionQueueSummary& QueueSummary,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Coach")
	static FHyperTwistTrainingCoachSessionQueueState StartCoachSessionQueueEntryBySourceLabel(
		const FHyperTwistTrainingCoachSessionQueueState& QueueState,
		const FString& SourceLabel,
		const FString& TrainingSessionId,
		const FString& StartedAtUtc,
		const FString& StartActionSourceLabel
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Coach")
	static FHyperTwistTrainingCoachSessionQueueState StartCoachSessionQueueEntryById(
		const FHyperTwistTrainingCoachSessionQueueState& QueueState,
		const FString& EntryId,
		const FString& TrainingSessionId,
		const FString& StartedAtUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Coach")
	static FHyperTwistTrainingCoachSessionQueueState FinalizeCoachSessionQueueEntry(
		const FHyperTwistTrainingCoachSessionQueueState& QueueState,
		const FString& TrainingSessionId,
		const FString& CompletedAtUtc,
		bool bAbortEntry
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Coach")
	static FHyperTwistTrainingCoachSessionQueueState DeferCoachSessionQueueEntry(
		const FHyperTwistTrainingCoachSessionQueueState& QueueState,
		const FString& EntryId,
		const FString& DeferredUntilUtc,
		const FString& DeferralReasonLabel,
		bool bManualReschedule,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Coach")
	static FHyperTwistTrainingCoachSessionQueueState PromoteCoachSessionQueueEntry(
		const FHyperTwistTrainingCoachSessionQueueState& QueueState,
		const FString& EntryId,
		const FString& StartActionSourceLabel,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Coach")
	static TArray<FHyperTwistTrainingCoachSessionQueueState> ListCoachSessionQueueStatesForUser(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Coach")
	static TArray<FHyperTwistTrainingCoachSessionQueueHistoryEntry> ListCoachSessionQueueHistoryEntries(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& QueueId
	);

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Repository|Coach")
	static bool TryGetCoachSessionQueueState(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& QueueId,
		FHyperTwistTrainingCoachSessionQueueState& OutQueueState
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Coach")
	static FHyperTwistTrainingRepositoryState UpsertCoachSessionQueueState(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FHyperTwistTrainingCoachSessionQueueState& QueueState
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Coach")
	static FHyperTwistTrainingRepositoryState RemoveCoachSessionQueueState(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& QueueId
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Coach")
	static FHyperTwistTrainingCoachSessionQueueExecutionSummary DeriveCoachSessionQueueExecutionSummary(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& QueueId,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Coach")
	static FHyperTwistTrainingCoachActionPlanSummary DeriveCoachActionPlanSummary(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Coach")
	static FHyperTwistTrainingCoachActionPlanOutcomeSummary DeriveCoachActionPlanOutcomeSummary(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FHyperTwistTrainingCoachActionPlan& ActionPlan,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Coach")
	static FHyperTwistTrainingCoachActionSequenceSummary DeriveCoachActionSequenceSummary(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FHyperTwistTrainingCoachActionPlan& AnchorPlan,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Coach")
	static FHyperTwistTrainingCoachActionClosureSummary DeriveCoachActionClosureSummary(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FHyperTwistTrainingCoachActionPlan& AnchorPlan,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Coach")
	static FHyperTwistTrainingCoachClosureMemorySummary DeriveCoachClosureMemorySummary(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Coach")
	static FHyperTwistTrainingCoachRecommendationHistorySummary DeriveCoachRecommendationHistorySummary(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Coach")
	static FHyperTwistTrainingCoachCarryForwardPolicySummary DeriveCoachCarryForwardPolicySummary(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository|Coach")
	static FHyperTwistTrainingCoachArchivePolicySummary DeriveCoachArchivePolicySummary(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingCaseRecommendation MakeCaseRecommendation(
		const FHyperTwistTrainingCase& TrainingCase,
		const FHyperTwistTrainingCaseLearnerState& LearnerState,
		const FString& ReferenceUtc
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingReviewPolicy GetDefaultReviewPolicy(
		EHyperTwistTrainingDeliveryMode DeliveryMode
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static TArray<FHyperTwistTrainingCaseRecommendation> ListCaseRecommendationsForDeck(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FHyperTwistTrainingDeck& Deck,
		const FString& UserId,
		const FString& ReferenceUtc,
		int32 MaxRecommendations
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static TArray<FHyperTwistTrainingCaseRecommendation> ApplyReviewPolicyToRecommendations(
		const TArray<FHyperTwistTrainingCaseRecommendation>& Recommendations,
		const FHyperTwistTrainingReviewPolicy& ReviewPolicy,
		int32 MaxRecommendations
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingDeck BuildReviewDeckFromRecommendations(
		const FHyperTwistTrainingDeck& SourceDeck,
		const TArray<FHyperTwistTrainingCaseRecommendation>& Recommendations,
		int32 MaxCases
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingReviewPlanState BuildReviewPlan(
		const FHyperTwistTrainingDeck& SourceDeck,
		const FHyperTwistTrainingDeck& ReviewDeck,
		const FString& UserId,
		const TArray<FHyperTwistTrainingCaseRecommendation>& Recommendations,
		const FHyperTwistTrainingReviewPolicy& ReviewPolicy,
		const FString& PlanId,
		const FString& ReferenceUtc,
		EHyperTwistTrainingDeliveryMode DeliveryMode
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingRepositoryState UpsertReviewPlan(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FHyperTwistTrainingReviewPlanState& ReviewPlan
	);

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Repository")
	static bool TryGetReviewPlan(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& PlanId,
		FHyperTwistTrainingReviewPlanState& OutReviewPlan
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingReviewPlanState UpdateReviewPlanAfterAttempt(
		const FHyperTwistTrainingReviewPlanState& ReviewPlan,
		const FHyperTwistTrainingRunStepResult& StepResult,
		const FHyperTwistTrainingAttempt& Attempt
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingReviewPlanState FinalizeReviewPlan(
		const FHyperTwistTrainingReviewPlanState& ReviewPlan,
		const FHyperTwistTrainingSession& Session
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingReviewFlowStatus DeriveReviewFlowStatus(
		const FHyperTwistTrainingReviewPlanState& ReviewPlan
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Repository")
	static FHyperTwistTrainingReviewProgramSummary DeriveReviewProgramSummary(
		const FHyperTwistTrainingRepositoryState& RepositoryState,
		const FString& UserId,
		const FString& ReferenceUtc
	);
};
