import '../../../../assert/js/assert.js';
import '../../../../globals.js';
// Copyright 2021-2024, University of Colorado Boulder
/**
 * Generic base class responsible for interfacing between a Node to alert description.
 * @author Michael Kauzmann (PhET Interactive Simulations)
 */
import EnabledComponent from '../../../../axon/js/EnabledComponent.js';
import optionize from '../../../../phet-core/js/optionize.js';
import { Voicing } from '../../../../scenery/js/imports.js';
import Utterance from '../../../../utterance-queue/js/Utterance.js';
import sceneryPhet from '../../sceneryPhet.js';
class Alerter extends EnabledComponent {
    constructor(providedOptions) {
        const options = optionize()({
            alertToVoicing: true,
            descriptionAlertNode: null
        }, providedOptions);
        super(options);
        this.alertToVoicing = options.alertToVoicing;
        this.descriptionAlertNode = options.descriptionAlertNode;
    }
    /**
     * Alert to both description and voicing utteranceQueues, depending on if both are supported by this instance
     */
    alert(alertable) {
        if (this.enabled) {
            if (this.alertToVoicing) {
                assert && assert(alertable instanceof Utterance, 'If alerting to Voicing, the alertable needs to be an Utterance'); // eslint-disable-line phet/no-simple-type-checking-assertions
                Voicing.alertUtterance(alertable);
            }
            this.alertDescriptionUtterance(alertable);
        }
    }
    /**
     * Forward to provided Node for UtteranceQueue alerting logic. See ParallelDOM.alertDescriptionUtterance() for details.
     */
    alertDescriptionUtterance(alertable) {
        this.enabled && this.descriptionAlertNode && this.descriptionAlertNode.alertDescriptionUtterance(alertable);
    }
    /**
     * Forward to provided Node for UtteranceQueue alerting logic. See ParallelDOM.forEachUtteranceQueue() for details.
     */
    forEachUtteranceQueue(utteranceQueueCallback) {
        this.enabled && this.descriptionAlertNode && this.descriptionAlertNode.forEachUtteranceQueue(utteranceQueueCallback);
    }
}
sceneryPhet.register('Alerter', Alerter);
export default Alerter;
//# sourceMappingURL=Alerter.js.map