import '../../../globals.js';
import optionize from '../../../phet-core/js/optionize.js';
import sharedSoundPlayers from '../../../tambo/js/sharedSoundPlayers.js';
import Tandem from '../../../tandem/js/Tandem.js';
import sun from '../sun.js';
import MomentaryButtonInteractionStateProperty from './MomentaryButtonInteractionStateProperty.js';
import MomentaryButtonModel from './MomentaryButtonModel.js';
import RoundButton from './RoundButton.js';
export default class RoundMomentaryButton extends RoundButton {
    /**
     * @param property
     * @param valueOff - value when the button is in the off state
     * @param valueOn - value when the button is in the on state
     * @param providedOptions?
     */
    constructor(property, valueOff, valueOn, providedOptions) {
        const options = optionize()({
            // SelfOptions
            valueOffSoundPlayer: sharedSoundPlayers.get('toggleOff'),
            valueOnSoundPlayer: sharedSoundPlayers.get('toggleOn'),
            tandem: Tandem.REQUIRED
        }, providedOptions);
        // Note it shares a tandem with this, so the emitter will be instrumented as a child of the button
        const buttonModel = new MomentaryButtonModel(valueOff, valueOn, property, options);
        super(buttonModel, new MomentaryButtonInteractionStateProperty(buttonModel), options);
        // sound generation
        const playSounds = () => {
            if (property.value === valueOff) {
                options.valueOffSoundPlayer.play();
            }
            else if (property.value === valueOn) {
                options.valueOnSoundPlayer.play();
            }
        };
        this.buttonModel.produceSoundEmitter.addListener(playSounds);
        // pdom - signify button is 'pressed' when down
        const setAriaPressed = () => this.setPDOMAttribute('aria-pressed', property.value === valueOn);
        property.link(setAriaPressed);
        this.disposeRoundMomentaryButton = () => {
            property.unlink(setAriaPressed);
            buttonModel.produceSoundEmitter.removeListener(playSounds);
            buttonModel.dispose();
        };
    }
    dispose() {
        this.disposeRoundMomentaryButton();
        super.dispose();
    }
}
sun.register('RoundMomentaryButton', RoundMomentaryButton);
//# sourceMappingURL=RoundMomentaryButton.js.map