/* ────────────────────────────────────────────────────────────────
   Phase 7 Sprint 7.2 — Accessibility
   
   Screen reader, high contrast, colorblind, remappable controls,
   subtitles, difficulty presets
──────────────────────────────────────────────────────────────── */
const DEFAULT_ACCESSIBILITY_CONFIG = {
    highContrast: false,
    colorblindMode: 'none',
    fontSize: 1,
    reducedMotion: false,
    screenReaderEnabled: false,
    subtitlesEnabled: false,
    subtitleSize: 1,
    subtitleBackground: true,
    hapticFeedback: true,
    autoAim: false,
    autoAimStrength: 0.5,
    holdToPress: false,
    inputDeadzone: 0.15,
    difficultyPreset: 'normal',
};
const DIFFICULTY_PRESETS = {
    easy: {
        damageMultiplier: 0.5, enemyHealthMultiplier: 0.7, enemyDamageMultiplier: 0.5,
        resourceMultiplier: 2, timeMultiplier: 1.5, respawnPenalty: false,
        friendlyFire: false, checkpoints: true, invincibilityFrames: 60,
    },
    normal: {
        damageMultiplier: 1, enemyHealthMultiplier: 1, enemyDamageMultiplier: 1,
        resourceMultiplier: 1, timeMultiplier: 1, respawnPenalty: false,
        friendlyFire: false, checkpoints: true, invincibilityFrames: 30,
    },
    hard: {
        damageMultiplier: 1.5, enemyHealthMultiplier: 1.5, enemyDamageMultiplier: 1.5,
        resourceMultiplier: 0.7, timeMultiplier: 0.8, respawnPenalty: true,
        friendlyFire: true, checkpoints: true, invincibilityFrames: 15,
    },
    custom: {
        damageMultiplier: 1, enemyHealthMultiplier: 1, enemyDamageMultiplier: 1,
        resourceMultiplier: 1, timeMultiplier: 1, respawnPenalty: false,
        friendlyFire: false, checkpoints: true, invincibilityFrames: 30,
    },
    assist: {
        damageMultiplier: 0, enemyHealthMultiplier: 0.5, enemyDamageMultiplier: 0,
        resourceMultiplier: 5, timeMultiplier: 3, respawnPenalty: false,
        friendlyFire: false, checkpoints: true, invincibilityFrames: 120,
    },
};
const COLORBLIND_MATRICES = {
    none: [1, 0, 0, 0, 1, 0, 0, 0, 1],
    protanopia: [0.567, 0.433, 0, 0.558, 0.442, 0, 0, 0.242, 0.758],
    deuteranopia: [0.625, 0.375, 0, 0.7, 0.3, 0, 0, 0.3, 0.7],
    tritanopia: [0.95, 0.05, 0, 0, 0.433, 0.567, 0, 0.475, 0.525],
    achromatopsia: [0.299, 0.587, 0.114, 0.299, 0.587, 0.114, 0.299, 0.587, 0.114],
};
function applyColorblindFilter(r, g, b, mode) {
    const m = COLORBLIND_MATRICES[mode];
    return {
        r: m[0] * r + m[1] * g + m[2] * b,
        g: m[3] * r + m[4] * g + m[5] * b,
        b: m[6] * r + m[7] * g + m[8] * b,
    };
}
/** Generate CSS filter string for colorblind mode (applied to canvas). */
function getColorblindCSSFilter(mode) {
    if (mode === 'none')
        return 'none';
    const m = COLORBLIND_MATRICES[mode];
    return `url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'><filter id='cb'><feColorMatrix values='${m[0]} ${m[1]} ${m[2]} 0 0 ${m[3]} ${m[4]} ${m[5]} 0 0 ${m[6]} ${m[7]} ${m[8]} 0 0 0 0 0 1 0'/></filter></svg>#cb")`;
}
/* ══════════════════════════════════════════════════════════════
   Screen Reader / Announcer
   ══════════════════════════════════════════════════════════════ */
class ScreenReaderAnnouncer {
    constructor() {
        this.liveRegion = null;
    }
    init() {
        if (typeof document === 'undefined')
            return;
        this.liveRegion = document.createElement('div');
        this.liveRegion.setAttribute('role', 'status');
        this.liveRegion.setAttribute('aria-live', 'polite');
        this.liveRegion.setAttribute('aria-atomic', 'true');
        this.liveRegion.style.cssText = 'position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden;';
        document.body.appendChild(this.liveRegion);
    }
    announce(message, priority = 'polite') {
        if (!this.liveRegion)
            return;
        this.liveRegion.setAttribute('aria-live', priority);
        this.liveRegion.textContent = '';
        // Force DOM reflow so screen reader re-reads
        void this.liveRegion.offsetHeight;
        this.liveRegion.textContent = message;
    }
    dispose() {
        if (this.liveRegion && this.liveRegion.parentNode) {
            this.liveRegion.parentNode.removeChild(this.liveRegion);
        }
        this.liveRegion = null;
    }
}
function getActiveSubtitles(track, currentTime) {
    const active = [];
    for (const entry of track.entries) {
        if (currentTime >= entry.startTime && currentTime <= entry.endTime) {
            active.push(entry);
        }
    }
    return active;
}
class ControlMapper {
    constructor() {
        this.mappings = new Map();
        this.defaults = new Map();
    }
    register(mapping) {
        this.mappings.set(mapping.action, { ...mapping });
        this.defaults.set(mapping.action, { ...mapping });
    }
    remap(action, update) {
        const current = this.mappings.get(action);
        if (!current)
            return;
        Object.assign(current, update);
    }
    getMapping(action) {
        return this.mappings.get(action);
    }
    resetToDefaults() {
        this.mappings.clear();
        for (const [key, val] of this.defaults) {
            this.mappings.set(key, { ...val });
        }
    }
    /** Export mappings as JSON for save/load. */
    serialize() {
        return Array.from(this.mappings.entries());
    }
    load(data) {
        for (const [key, mapping] of data) {
            this.mappings.set(key, mapping);
        }
    }
    allActions() {
        return Array.from(this.mappings.keys());
    }
}

export { COLORBLIND_MATRICES, ControlMapper, DEFAULT_ACCESSIBILITY_CONFIG, DIFFICULTY_PRESETS, ScreenReaderAnnouncer, applyColorblindFilter, getActiveSubtitles, getColorblindCSSFilter };
//# sourceMappingURL=Accessibility.js.map
