import '../../../globals.js';
import sun from '../sun.js';
import RectangularButton from './RectangularButton.js';
import StickyToggleButtonInteractionStateProperty from './StickyToggleButtonInteractionStateProperty.js';
import StickyToggleButtonModel from './StickyToggleButtonModel.js';
import Tandem from '../../../tandem/js/Tandem.js';
import sharedSoundPlayers from '../../../tambo/js/sharedSoundPlayers.js';
import optionize from '../../../phet-core/js/optionize.js';
export default class RectangularStickyToggleButton extends RectangularButton {
    /**
     * @param valueProperty - axon Property that can be either valueUp or valueDown.
     * @param valueUp - value when the toggle is in the 'up' position
     * @param valueDown - value when the toggle is in the 'down' position
     * @param providedOptions?
     */
    constructor(valueProperty, valueUp, valueDown, providedOptions) {
        const options = optionize()({
            soundPlayer: sharedSoundPlayers.get('pushButton'),
            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 StickyToggleButtonModel(valueUp, valueDown, valueProperty, providedOptions);
        const stickyToggleButtonInteractionStateProperty = new StickyToggleButtonInteractionStateProperty(buttonModel);
        super(buttonModel, stickyToggleButtonInteractionStateProperty, options);
        // sound generation
        const playSound = () => options.soundPlayer.play();
        buttonModel.produceSoundEmitter.addListener(playSound);
        // pdom - signify button is 'pressed' when down
        const setAriaPressed = () => this.setPDOMAttribute('aria-pressed', valueProperty.value === valueDown);
        valueProperty.link(setAriaPressed);
        this.disposeRectangularStickyToggleButton = () => {
            valueProperty.unlink(setAriaPressed);
            buttonModel.produceSoundEmitter.removeListener(playSound);
            buttonModel.dispose();
        };
    }
    dispose() {
        this.disposeRectangularStickyToggleButton();
        super.dispose();
    }
}
sun.register('RectangularStickyToggleButton', RectangularStickyToggleButton);
//# sourceMappingURL=RectangularStickyToggleButton.js.map