import { EventBus } from '../core/EventBus';
import type { TutorialProgress } from './TutorialEngine';
import type { Locale } from '../i18n/I18n';
export type BranchConditionType = 'quiz-correct' | 'quiz-incorrect' | 'quiz-answer' | 'code-valid' | 'code-invalid' | 'always';
export interface BranchCondition {
    type: BranchConditionType;
    /** For 'quiz-answer': the specific answer ID that triggers this branch. */
    answerId?: string;
}
export interface BranchRule {
    /** Condition that triggers this branch. */
    condition: BranchCondition;
    /** Step ID to jump to if condition is met. */
    targetStepId: string;
}
export interface BranchingStep {
    /** The step ID this branching config applies to. */
    stepId: string;
    /** Ordered list of branching rules. First matching rule wins. */
    rules: BranchRule[];
    /** Fallback step ID if no rules match (defaults to next sequential step). */
    fallbackStepId?: string;
}
export interface BranchingConfig {
    /** Tutorial ID this branching config belongs to. */
    tutorialId: string;
    /** Map of step ID → branching rules. */
    branches: BranchingStep[];
}
export declare class BranchingEngine {
    private configs;
    /** Register branching configuration for a tutorial. */
    register(config: BranchingConfig): void;
    /** Unregister branching for a tutorial. */
    unregister(tutorialId: string): void;
    /** Check if a step has branching rules. */
    hasBranching(tutorialId: string, stepId: string): boolean;
    /**
     * Resolve the next step ID based on branching rules and context.
     * Returns null if no branching is defined (use default sequential advance).
     */
    resolveNextStep(tutorialId: string, currentStepId: string, context: BranchContext): string | null;
    private evaluateCondition;
}
export interface BranchContext {
    /** Whether the quiz answer was correct (for quiz steps). */
    quizCorrect?: boolean;
    /** The specific quiz answer ID chosen. */
    quizAnswerId?: string;
    /** Whether the code validation passed (for code steps). */
    codeValid?: boolean;
}
export type AchievementTier = 'bronze' | 'silver' | 'gold' | 'platinum' | 'diamond';
export interface AchievementCondition {
    type: 'tutorial-complete' | 'tutorials-count' | 'category-complete' | 'streak' | 'quiz-perfect' | 'custom';
    /** For tutorial-complete: tutorial ID. */
    tutorialId?: string;
    /** For tutorials-count: minimum number. */
    count?: number;
    /** For category-complete: tutorial category. */
    category?: string;
    /** For streak: consecutive days. */
    streakDays?: number;
    /** For custom: custom condition ID evaluated externally. */
    customId?: string;
}
export interface AchievementDefinition {
    id: string;
    /** Localized title. */
    title: Record<string, string>;
    /** Localized description. */
    description: Record<string, string>;
    /** Emoji icon. */
    icon: string;
    /** Tier (visual style). */
    tier: AchievementTier;
    /** XP points awarded. */
    xp: number;
    /** Condition to unlock. */
    condition: AchievementCondition;
    /** Whether this is hidden until unlocked. */
    hidden?: boolean;
}
export interface AchievementProgress {
    achievementId: string;
    unlocked: boolean;
    unlockedAt?: number;
    /** Progress toward the goal (0-1). */
    progress: number;
}
export declare class AchievementEngine {
    private readonly persistToStorage;
    readonly events: EventBus;
    private definitions;
    private playerProgress;
    private customEvaluators;
    private readonly storageKey;
    constructor(persistToStorage?: boolean);
    /** Register an achievement definition. */
    registerAchievement(def: AchievementDefinition): void;
    /** Register multiple achievements. */
    registerAchievements(defs: AchievementDefinition[]): void;
    /** Register a custom evaluator for custom conditions. */
    registerCustomEvaluator(customId: string, evaluator: () => {
        met: boolean;
        progress: number;
    }): void;
    /**
     * Evaluate all achievements against current tutorial progress.
     * Returns newly unlocked achievement IDs.
     */
    evaluate(tutorialProgress: Map<string, TutorialProgress>, streakDays?: number): string[];
    private evaluateCondition;
    /** Get all achievement definitions. */
    getAllAchievements(): AchievementDefinition[];
    /** Get unlocked achievements. */
    getUnlocked(): AchievementDefinition[];
    /** Get progress for a specific achievement. */
    getProgress(achievementId: string): AchievementProgress | undefined;
    /** Total XP from unlocked achievements. */
    getTotalXP(): number;
    /** Get visible achievements (not hidden, or hidden but unlocked). */
    getVisible(locale?: Locale): Array<AchievementDefinition & {
        unlocked: boolean;
        progress: number;
    }>;
    /** Reset all progress. */
    reset(): void;
    private save;
    private load;
}
export declare const BUILT_IN_ACHIEVEMENTS: AchievementDefinition[];
