// Copyright 2014-2025, University of Colorado Boulder
/**
 * RoundToggleButton is a round toggle button that toggles the value of a Property between 2 values.
 * It has the same look for both values.
 *
 * @author John Blanco (PhET Interactive Simulations)
 * @author Sam Reid (PhET Interactive Simulations)
 */
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 RoundButton from './RoundButton.js';
import ToggleButtonInteractionStateProperty from './ToggleButtonInteractionStateProperty.js';
import ToggleButtonModel from './ToggleButtonModel.js';
export default class RoundToggleButton extends RoundButton {
    /**
     * @param property - axon Property that can be either valueOff or valueOn
     * @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'),
            // phet-io support
            tandem: Tandem.REQUIRED,
            phetioFeatured: true,
            listenerOptions: {
                tandem: Tandem.OPT_OUT // ToggleButtonModel provides a toggledEmitter which is sufficient
            }
        }, providedOptions);
        // Note it shares a tandem with this, so the emitter will be instrumented as a child of the button
        const toggleButtonModel = new ToggleButtonModel(valueOff, valueOn, property, options);
        const toggleButtonInteractionStateProperty = new ToggleButtonInteractionStateProperty(toggleButtonModel);
        super(toggleButtonModel, toggleButtonInteractionStateProperty, options);
        this.addLinkedElement(property, {
            tandemName: 'property'
        });
        ;
        // sound generation
        const playSounds = () => {
            if (property.value === valueOff) {
                options.valueOffSoundPlayer.play();
            }
            else if (property.value === valueOn) {
                options.valueOnSoundPlayer.play();
            }
        };
        this.buttonModel.produceSoundEmitter.addListener(playSounds);
        this.disposeRoundToggleButton = () => {
            this.buttonModel.produceSoundEmitter.removeListener(playSounds);
            toggleButtonModel.dispose();
        };
    }
    dispose() {
        this.disposeRoundToggleButton();
        super.dispose();
    }
}
//# sourceMappingURL=RoundToggleButton.js.map