import '../../../../globals.js';
import optionize from '../../../../phet-core/js/optionize.js';
import SpeechSynthesisAnnouncer from '../../../../utterance-queue/js/SpeechSynthesisAnnouncer.js';
import { globalKeyStateTracker, KeyboardUtils, scenery } from '../../imports.js';
class VoicingManager extends SpeechSynthesisAnnouncer {
    constructor(providedOptions) {
        const options = optionize()({
            // All VoicingManager instances should respect responseCollector's current state.
            respectResponseCollectorProperties: true,
            // phet-io
            phetioDocumentation: 'Announcer that manages the voicing feature, providing audio responses via WebAudio.'
        }, providedOptions);
        super(options);
    }
    /**
     * The initialization with some additional scenery-specific work for voicingManager.
     */
    initialize(userGestureEmitter, options) {
        super.initialize(userGestureEmitter, options);
        // The control key will stop the synth from speaking if there is an active utterance. This key was decided because
        // most major screen readers will stop speech when this key is pressed
        globalKeyStateTracker.keyupEmitter.addListener(domEvent => {
            if (KeyboardUtils.isControlKey(domEvent)) {
                this.cancel();
            }
        });
    }
    /**
     * Returns true if voicing is supported for the provided locale. Currently, only English is supported.
     * @param locale - the locale string
     */
    voicingSupportedForLocale(locale) {
        return locale.startsWith('en');
    }
}
const voicingManager = new VoicingManager();
scenery.register('voicingManager', voicingManager);
export default voicingManager;
//# sourceMappingURL=voicingManager.js.map