// Copyright 2013-2025, University of Colorado Boulder
/**
 * This toggle button uses a boolean Property and a trueNode and falseNode to display its content.
 *
 * @author John Blanco (PhET Interactive Simulations)
 */
import '../../../globals.js';
import DerivedProperty from '../../../axon/js/DerivedProperty.js';
import optionize from '../../../phet-core/js/optionize.js';
import { findStringProperty } from '../../../scenery/js/accessibility/pdom/findStringProperty.js';
import Tandem from '../../../tandem/js/Tandem.js';
import BooleanToggleNode from '../BooleanToggleNode.js';
import RectangularToggleButton from './RectangularToggleButton.js';
export default class BooleanRectangularToggleButton extends RectangularToggleButton {
    /**
     * @param booleanProperty
     * @param trueNode - shown when booleanProperty is true
     * @param falseNode - shown when booleanProperty is false
     * @param providedOptions?
     */
    constructor(booleanProperty, trueNode, falseNode, providedOptions) {
        const content = new BooleanToggleNode(booleanProperty, trueNode, falseNode);
        const options = optionize()({
            content: content,
            tandem: Tandem.REQUIRED
        }, providedOptions);
        // If no accessibleName is provided, the default behavior finds the accessibleName from the content Nodes.
        // If either of the content Nodes do not have text content or if you need to customize the accessibleName,
        // you can provide an accessibleName option.
        let defaultAccessibleNameProperty = null;
        const trueStringProperty = findStringProperty(trueNode);
        const falseStringProperty = findStringProperty(falseNode);
        if (!options.accessibleName && trueStringProperty && falseStringProperty) {
            defaultAccessibleNameProperty = new DerivedProperty([
                booleanProperty,
                trueStringProperty,
                falseStringProperty
            ], (propertyValue, trueString, falseString) => {
                return propertyValue ? trueString : falseString;
            });
            options.accessibleName = defaultAccessibleNameProperty;
        }
        super(booleanProperty, false, true, options);
        this.disposeBooleanRectangularToggleButton = () => {
            defaultAccessibleNameProperty && defaultAccessibleNameProperty.dispose();
            content.dispose();
        };
    }
    dispose() {
        this.disposeBooleanRectangularToggleButton();
        super.dispose();
    }
}
//# sourceMappingURL=BooleanRectangularToggleButton.js.map