import '../../globals.js';
// Copyright 2024, University of Colorado Boulder
/**
 * The GatedBooleanProperty class abstracts the process of creating a boolean Property with an extra controlling Property.
 * Partially designed for its primary use case, PhET-iO instrumented Properties. This pattern comes in handy when an
 * object's boolean value is already controlled within the simulation, but there is a need to grant additional control
 * to an external entity such as a studio or a PhET-iO client. Here "gate" is an extra level of control (via the
 * composed Property). The class is a DerivedProperty that listens correctly to convey the boolean with
 * respect to all inputs.
 *
 * Subclasses GatedVisibleProperty and GatedEnabledProperty should be used when your Property fills the role
 * of a visibleProperty or enabledProperty respectively. These subclasses provide standardized tandem names
 * and PhET-iO metadata.
 *
 * @author Marla Schulz (PhET Interactive Simulations)
 * @author Michael Kauzmann (PhET Interactive Simulations)
 * @author Sam Reid (PhET Interactive Simulations)
 */
import optionize from '../../phet-core/js/optionize.js';
import BooleanIO from '../../tandem/js/types/BooleanIO.js';
import axon from './axon.js';
import BooleanProperty from './BooleanProperty.js';
import { DerivedProperty2 } from './DerivedProperty.js';
class GatedBooleanProperty extends DerivedProperty2 {
    constructor(providedBooleanProperty, parentTandem, providedOptions) {
        const options = optionize()({
            tandemName: 'property',
            selfTandemName: 'selfProperty',
            selfBooleanInitialValue: true,
            selfBooleanPropertyOptions: {
                phetioFeatured: true
            },
            phetioValueType: BooleanIO
            // see below for phetioDocumentation, replaces {{SELF_PROPERTY_TANDEM_NAME}} with the name of the self property
        }, providedOptions);
        if (!options.tandem) {
            options.tandem = parentTandem.createTandem(options.tandemName);
        }
        if (!options.selfBooleanPropertyOptions.tandem) {
            options.selfBooleanPropertyOptions.tandem = parentTandem.createTandem(options.selfTandemName);
        }
        const selfBooleanProperty = new BooleanProperty(options.selfBooleanInitialValue, options.selfBooleanPropertyOptions);
        if (options.phetioDocumentation) {
            options.phetioDocumentation = options.phetioDocumentation.replace('{{SELF_PROPERTY_TANDEM_NAME}}', selfBooleanProperty.tandem.name);
        }
        super([providedBooleanProperty, selfBooleanProperty], (providedBoolean, selfBoolean) => providedBoolean && selfBoolean, options);
        this.selfBooleanProperty = selfBooleanProperty;
    }
    dispose() {
        // Remove the selfBooleanProperty from the PhET-iO registry
        this.selfBooleanProperty.dispose();
        super.dispose();
    }
}
export class GatedVisibleProperty extends GatedBooleanProperty {
    constructor(providedBooleanProperty, parentTandem, providedOptions) {
        const options = optionize()({
            tandemName: 'visibleProperty',
            selfTandemName: 'selfVisibleProperty',
            phetioDocumentation: 'Whether the PhET-iO Element is visible, see {{SELF_PROPERTY_TANDEM_NAME}} for customization.',
            selfBooleanPropertyOptions: {
                phetioDocumentation: 'Provides an additional way to toggle the visibility for the PhET-iO Element.'
            }
        }, providedOptions);
        super(providedBooleanProperty, parentTandem, options);
    }
}
export class GatedEnabledProperty extends GatedBooleanProperty {
    constructor(providedBooleanProperty, parentTandem, providedOptions) {
        const options = optionize()({
            tandemName: 'enabledProperty',
            selfTandemName: 'selfEnabledProperty',
            phetioDocumentation: 'Whether the PhET-iO Element is enabled, see {{SELF_PROPERTY_TANDEM_NAME}} for customization.',
            selfBooleanPropertyOptions: {
                phetioDocumentation: 'Provides an additional way to toggle enabled for the PhET-iO Element.'
            }
        }, providedOptions);
        super(providedBooleanProperty, parentTandem, options);
    }
}
export default GatedBooleanProperty;
axon.register('GatedBooleanProperty', GatedBooleanProperty);
//# sourceMappingURL=GatedBooleanProperty.js.map