#pragma once

#include "CoreMinimal.h"
#include "HyperTwistCore/HyperTwistCoreTypes.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "HyperTwistTraining/HyperTwistTrainingTypes.h"
#include "HyperTwistTrainingTilingLibrary.generated.h"

USTRUCT(BlueprintType)
struct FHyperTwistTrainingTilingPackageReference
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString PackageId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString Label;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString ExportPath;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString OwnershipRole;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString LicensePosture;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString Summary;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> RetainedSurfaceTags;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> RequiredNoticeActions;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> ExplicitExclusions;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FHyperTwistTrainingSourceAttribution SourceAttribution;

	bool IsStructurallyValid() const
	{
		return !PackageId.IsEmpty() && !Label.IsEmpty() && !ExportPath.IsEmpty()
			&& !OwnershipRole.IsEmpty() && SourceAttribution.IsStructurallyValid();
	}
};

USTRUCT(BlueprintType)
struct FHyperTwistTrainingTilingTopologyContract
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString ContractId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString Title;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString Summary;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> RequiredPackageIds;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> PuzzleFamilies;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> GeometrySurfaceTags;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> TopologySurfaceTags;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> ExplicitExclusions;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FHyperTwistTrainingSourceAttribution SourceAttribution;

	bool IsStructurallyValid() const
	{
		return !ContractId.IsEmpty() && !Title.IsEmpty() && SourceAttribution.IsStructurallyValid();
	}
};

USTRUCT(BlueprintType)
struct FHyperTwistTrainingTilingLoaderBoundary
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString BoundaryId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString Title;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString Summary;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> RequiredPackageIds;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> LoaderSurfaceTags;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> RuntimeBoundaryTags;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> ExplicitExclusions;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FHyperTwistTrainingSourceAttribution SourceAttribution;

	bool IsStructurallyValid() const
	{
		return !BoundaryId.IsEmpty() && !Title.IsEmpty() && SourceAttribution.IsStructurallyValid();
	}
};

USTRUCT(BlueprintType)
struct FHyperTwistTrainingTilingAttributionBoundary
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString BoundaryId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString Title;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString Summary;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> AllowedUseTags;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> RequiredNoticeActions;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> ExplicitExclusions;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FHyperTwistTrainingSourceAttribution SourceAttribution;

	bool IsStructurallyValid() const
	{
		return !BoundaryId.IsEmpty() && !Title.IsEmpty() && SourceAttribution.IsStructurallyValid();
	}
};

USTRUCT(BlueprintType)
struct FHyperTwistTrainingTilingMacroRemappingContract
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString ContractId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString Title;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString Summary;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> RequiredPackageIds;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> ReferenceSurfaceTags;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> TransformSurfaceTags;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> PlaybackSurfaceTags;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> ExplicitExclusions;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FHyperTwistTrainingSourceAttribution SourceAttribution;

	bool IsStructurallyValid() const
	{
		return !ContractId.IsEmpty() && !Title.IsEmpty() && SourceAttribution.IsStructurallyValid();
	}
};

USTRUCT(BlueprintType)
struct FHyperTwistTrainingTilingMacroPersistenceBoundary
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString BoundaryId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString Title;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString Summary;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> RequiredPackageIds;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> PersistenceSurfaceTags;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> CompatibilitySurfaceTags;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> ProvenanceCaveats;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> ExplicitExclusions;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FHyperTwistTrainingSourceAttribution SourceAttribution;

	bool IsStructurallyValid() const
	{
		return !BoundaryId.IsEmpty() && !Title.IsEmpty() && SourceAttribution.IsStructurallyValid();
	}
};

UENUM(BlueprintType)
enum class EHyperTwistTrainingTilingHostKind : uint8
{
	EmbeddedBrowserCef UMETA(DisplayName = "Embedded Browser CEF"),
	NativeUnrealDeferred UMETA(DisplayName = "Native Unreal Deferred")
};

USTRUCT(BlueprintType)
struct FHyperTwistTrainingTilingHostDecision
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString DecisionId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	EHyperTwistTrainingTilingHostKind HostKind =
		EHyperTwistTrainingTilingHostKind::EmbeddedBrowserCef;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString Title;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString Summary;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> RequiredPackageIds;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> BrowserSurfaceTags;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> DeferredPortReasons;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> ExplicitExclusions;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FHyperTwistTrainingSourceAttribution SourceAttribution;

	bool IsStructurallyValid() const
	{
		return !DecisionId.IsEmpty() && !Title.IsEmpty()
			&& SourceAttribution.IsStructurallyValid();
	}
};

USTRUCT(BlueprintType)
struct FHyperTwistTrainingTilingStateBridgeContract
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString ContractId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString HostDecisionId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString Title;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString Summary;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> RequiredPackageIds;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> StateSurfaceTags;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> TransportSurfaceTags;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> ScrambleSurfaceTags;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> TimerSurfaceTags;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> ExplicitExclusions;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FHyperTwistTrainingSourceAttribution SourceAttribution;

	bool IsStructurallyValid() const
	{
		return !ContractId.IsEmpty() && !HostDecisionId.IsEmpty() && !Title.IsEmpty()
			&& SourceAttribution.IsStructurallyValid();
	}
};

USTRUCT(BlueprintType)
struct FHyperTwistTrainingTilingNativeBehaviorProofContract
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString ContractId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString HostDecisionId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString StateBridgeContractId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString Title;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString Summary;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> RequiredPackageIds;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> NativeInputSurfaceTags;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> NativeStateSurfaceTags;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> ReusedBridgeSurfaceTags;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> ExplicitExclusions;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FHyperTwistTrainingSourceAttribution SourceAttribution;

	bool IsStructurallyValid() const
	{
		return !ContractId.IsEmpty() && !HostDecisionId.IsEmpty()
			&& !StateBridgeContractId.IsEmpty() && !Title.IsEmpty()
			&& SourceAttribution.IsStructurallyValid();
	}
};

USTRUCT(BlueprintType)
struct FHyperTwistTrainingTilingStateEnvelope
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString SchemaVersion = TEXT("ht-tiling-state-bridge/v1");

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString HostDecisionId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString BridgeContractId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString SessionId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString PuzzleFamilyId = TEXT("Tiling");

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString PuzzleDefinitionId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString TransportKind = TEXT("browser-bridge-object");

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> SharedScrambleTokens;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString SharedScrambleNotation;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FHyperTwistPuzzleState PuzzleState;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FHyperTwistTrainingLiveTimerState TimerState;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString SourceRuntime = TEXT("embedded-browser-cef");

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString CapturedAtUtc;

	bool IsStructurallyValid() const
	{
		return !SchemaVersion.IsEmpty() && !HostDecisionId.IsEmpty()
			&& !BridgeContractId.IsEmpty() && !SessionId.IsEmpty()
			&& !PuzzleFamilyId.IsEmpty() && !PuzzleDefinitionId.IsEmpty()
			&& !TransportKind.IsEmpty() && PuzzleState.IsStructurallyValid()
			&& TimerState.IsStructurallyValid();
	}
};

USTRUCT(BlueprintType)
struct FHyperTwistTrainingTilingNativeBehaviorProofProbe
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString SchemaVersion = TEXT("ht-tiling-native-behavior-proof/v1");

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString ProofContractId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString HostDecisionId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString StateBridgeContractId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString SessionId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString PuzzleDefinitionId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString SelectedCellId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> CandidateTwistIds;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString PreviewTransformToken;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString CommitTwistId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FString> SharedScrambleTokens;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString SharedScrambleNotation;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FHyperTwistPuzzleState PuzzleState;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FHyperTwistTrainingLiveTimerState TimerState;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString SourceRuntime = TEXT("native-unreal-proof");

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString CapturedAtUtc;

	bool IsStructurallyValid() const
	{
		return !SchemaVersion.IsEmpty() && !ProofContractId.IsEmpty()
			&& !HostDecisionId.IsEmpty() && !StateBridgeContractId.IsEmpty()
			&& !SessionId.IsEmpty() && !PuzzleDefinitionId.IsEmpty()
			&& !SelectedCellId.IsEmpty() && CandidateTwistIds.Num() > 0
			&& !PreviewTransformToken.IsEmpty() && !CommitTwistId.IsEmpty()
			&& PuzzleState.IsStructurallyValid() && TimerState.IsStructurallyValid();
	}
};

USTRUCT(BlueprintType)
struct FHyperTwistTrainingTilingReferenceBundle
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString ReferenceUtc;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString PrimaryTopologyContractId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString PrimaryLoaderBoundaryId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString PrimaryAttributionBoundaryId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString PrimaryMacroRemappingContractId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString PrimaryMacroPersistenceBoundaryId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString PrimaryHostDecisionId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString PrimaryStateBridgeContractId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	FString PrimaryNativeBehaviorProofContractId;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FHyperTwistTrainingTilingPackageReference> PackageReferences;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FHyperTwistTrainingTilingTopologyContract> TopologyContracts;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FHyperTwistTrainingTilingLoaderBoundary> LoaderBoundaries;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FHyperTwistTrainingTilingAttributionBoundary> AttributionBoundaries;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FHyperTwistTrainingTilingMacroRemappingContract> MacroRemappingContracts;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FHyperTwistTrainingTilingMacroPersistenceBoundary> MacroPersistenceBoundaries;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FHyperTwistTrainingTilingHostDecision> HostDecisions;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FHyperTwistTrainingTilingStateBridgeContract> StateBridgeContracts;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist")
	TArray<FHyperTwistTrainingTilingNativeBehaviorProofContract> NativeBehaviorProofContracts;

	bool IsStructurallyValid() const
	{
		return !PrimaryTopologyContractId.IsEmpty() && !PrimaryLoaderBoundaryId.IsEmpty()
			&& !PrimaryAttributionBoundaryId.IsEmpty() && !PrimaryMacroRemappingContractId.IsEmpty()
			&& !PrimaryMacroPersistenceBoundaryId.IsEmpty() && !PrimaryHostDecisionId.IsEmpty()
			&& !PrimaryStateBridgeContractId.IsEmpty() && !PrimaryNativeBehaviorProofContractId.IsEmpty()
			&& PackageReferences.Num() > 0
			&& MacroRemappingContracts.Num() > 0 && MacroPersistenceBoundaries.Num() > 0
			&& HostDecisions.Num() > 0 && StateBridgeContracts.Num() > 0
			&& NativeBehaviorProofContracts.Num() > 0;
	}
};

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

public:
	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Tiling")
	static FHyperTwistTrainingTilingReferenceBundle BuildBundledTilingReferenceBundle();

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Tiling")
	static bool TryGetTopologyContractById(
		const FHyperTwistTrainingTilingReferenceBundle& Bundle,
		const FString& ContractId,
		FHyperTwistTrainingTilingTopologyContract& OutContract
	);

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Tiling")
	static bool TryGetLoaderBoundaryById(
		const FHyperTwistTrainingTilingReferenceBundle& Bundle,
		const FString& BoundaryId,
		FHyperTwistTrainingTilingLoaderBoundary& OutBoundary
	);

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Tiling")
	static bool TryGetAttributionBoundaryById(
		const FHyperTwistTrainingTilingReferenceBundle& Bundle,
		const FString& BoundaryId,
		FHyperTwistTrainingTilingAttributionBoundary& OutBoundary
	);

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Tiling")
	static bool TryGetMacroRemappingContractById(
		const FHyperTwistTrainingTilingReferenceBundle& Bundle,
		const FString& ContractId,
		FHyperTwistTrainingTilingMacroRemappingContract& OutContract
	);

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Tiling")
	static bool TryGetMacroPersistenceBoundaryById(
		const FHyperTwistTrainingTilingReferenceBundle& Bundle,
		const FString& BoundaryId,
		FHyperTwistTrainingTilingMacroPersistenceBoundary& OutBoundary
	);

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Tiling")
	static bool TryGetHostDecisionById(
		const FHyperTwistTrainingTilingReferenceBundle& Bundle,
		const FString& DecisionId,
		FHyperTwistTrainingTilingHostDecision& OutDecision
	);

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Tiling")
	static bool TryGetStateBridgeContractById(
		const FHyperTwistTrainingTilingReferenceBundle& Bundle,
		const FString& ContractId,
		FHyperTwistTrainingTilingStateBridgeContract& OutContract
	);

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Tiling")
	static bool TryGetNativeBehaviorProofContractById(
		const FHyperTwistTrainingTilingReferenceBundle& Bundle,
		const FString& ContractId,
		FHyperTwistTrainingTilingNativeBehaviorProofContract& OutContract
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Tiling")
	static TArray<FString> ParseSharedScrambleNotation(const FString& SharedScrambleNotation);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Tiling")
	static FString BuildSharedScrambleNotation(const TArray<FString>& SharedScrambleTokens);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Tiling")
	static FHyperTwistTrainingTilingStateEnvelope NormalizeStateEnvelope(
		const FHyperTwistTrainingTilingStateEnvelope& StateEnvelope
	);

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Tiling")
	static bool TrySerializeStateEnvelopeToJson(
		const FHyperTwistTrainingTilingStateEnvelope& StateEnvelope,
		FString& OutJson
	);

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Tiling")
	static bool TryDeserializeStateEnvelopeFromJson(
		const FString& Json,
		FHyperTwistTrainingTilingStateEnvelope& OutStateEnvelope
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Tiling")
	static FHyperTwistTrainingTilingNativeBehaviorProofProbe CreateNativeBehaviorProofProbe(
		const FHyperTwistTrainingTilingStateEnvelope& StateEnvelope,
		const FString& SelectedCellId,
		const TArray<FString>& CandidateTwistIds,
		const FString& CommitTwistId,
		const FString& PreviewTransformToken
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Tiling")
	static FHyperTwistTrainingTilingNativeBehaviorProofProbe NormalizeNativeBehaviorProofProbe(
		const FHyperTwistTrainingTilingNativeBehaviorProofProbe& Probe
	);

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Tiling")
	static bool TrySerializeNativeBehaviorProofProbeToJson(
		const FHyperTwistTrainingTilingNativeBehaviorProofProbe& Probe,
		FString& OutJson
	);

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Tiling")
	static bool TryDeserializeNativeBehaviorProofProbeFromJson(
		const FString& Json,
		FHyperTwistTrainingTilingNativeBehaviorProofProbe& OutProbe
	);

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Tiling")
	static FString BuildPackageChecklistTsv(const FHyperTwistTrainingTilingReferenceBundle& Bundle);
};
