import '../../assert/js/assert.js';
import '../../globals.js';
import optionize, { combineOptions } from '../../phet-core/js/optionize.js';
import { VBox } from '../../scenery/js/imports.js';
import Tandem from '../../tandem/js/Tandem.js';
import Checkbox from './Checkbox.js';
import { getGroupItemNodes } from './GroupItemOptions.js';
import sun from './sun.js';
export default class VerticalCheckboxGroup extends VBox {
    constructor(items, providedOptions) {
        const options = optionize()({
            // dilation of pointer areas for each checkbox, y dimension is computed
            touchAreaXDilation: 5,
            mouseAreaXDilation: 5,
            // supertype options
            spacing: 10, // vertical spacing
            align: 'left',
            stretch: true,
            tandem: Tandem.REQUIRED
        }, providedOptions);
        const nodes = getGroupItemNodes(items, options.tandem);
        const checkboxes = [];
        // Create a checkbox for each item
        options.children = [];
        for (let i = 0; i < items.length; i++) {
            const item = items[i];
            const node = nodes[i];
            assert && assert(!node.hasPDOMContent, 'Accessibility is provided by Checkbox and VerticalCheckboxGroupItem.options. ' +
                'Additional PDOM content in the provided Node could break accessibility.');
            // set pointer areas, y dimensions are computed
            const yDilation = options.spacing / 2;
            // @ts-expect-error - runtime check to prevent prior pattern, see https://github.com/phetsims/sun/issues/794
            assert && assert(!item.tandem, 'Cannot specify tandem on item, use tandemName instead');
            const checkbox = new Checkbox(item.property, node, combineOptions({
                tandem: item.tandemName ? options.tandem.createTandem(item.tandemName) : Tandem.OPTIONAL,
                mouseAreaXDilation: options.mouseAreaXDilation,
                touchAreaXDilation: options.touchAreaXDilation,
                mouseAreaYDilation: yDilation,
                touchAreaYDilation: yDilation
            }, options.checkboxOptions, item.options));
            // For disposal
            checkboxes.push(checkbox);
            options.children.push(checkbox);
        }
        super(options);
        this.disposeVerticalCheckboxGroup = () => {
            checkboxes.forEach(checkbox => checkbox.dispose());
            nodes.forEach(node => node.dispose());
        };
    }
    dispose() {
        this.disposeVerticalCheckboxGroup();
        super.dispose();
    }
}
sun.register('VerticalCheckboxGroup', VerticalCheckboxGroup);
//# sourceMappingURL=VerticalCheckboxGroup.js.map