/**
 * "Mark for training" (the `t` shortcut) decision logic — issue #327.
 *
 * Training enrollment is document-level — two fixed script-type chips
 * (KURRENT_RECOGNITION / KURRENT_SEGMENTATION); there is no per-region training
 * flag yet (that arrives with #321). `t` toggles the primary recognition
 * enrollment and is a silent no-op unless a region is active, so it reads as an
 * action on the region the transcriber is working on.
 *
 * Pure so the no-op-when-no-region guard and the enrolled flip are testable
 * without mounting the page.
 */
export const RECOGNITION_TRAINING_LABEL = 'KURRENT_RECOGNITION';

export type TrainingMarkToggle = { label: string; enrolled: boolean };

/**
 * Decide the recognition-training toggle for the active region, or null when no
 * region is active (the `t` shortcut is then a silent no-op).
 *
 * @param activeAnnotationId the currently active region, or null
 * @param currentLabels the document's currently enrolled training labels
 */
export function resolveTrainingMark(
	activeAnnotationId: string | null,
	currentLabels: readonly string[]
): TrainingMarkToggle | null {
	if (!activeAnnotationId) return null;
	const enrolled = !currentLabels.includes(RECOGNITION_TRAINING_LABEL);
	return { label: RECOGNITION_TRAINING_LABEL, enrolled };
}
