import type { RtkIntegrationConfig, RuntimeStatus } from "./types.js";

export function shouldRequireRtkAvailabilityForCommandHandling(
	config: Pick<RtkIntegrationConfig, "commandRewritingEnabled" | "guardWhenRtkMissing">,
): boolean {
	return config.commandRewritingEnabled && config.guardWhenRtkMissing;
}

export function shouldSkipCommandHandlingWhenRtkMissing(
	config: Pick<RtkIntegrationConfig, "commandRewritingEnabled" | "guardWhenRtkMissing">,
	runtimeStatus: Pick<RuntimeStatus, "rtkAvailable">,
): boolean {
	return shouldRequireRtkAvailabilityForCommandHandling(config) && !runtimeStatus.rtkAvailable;
}
