import '../../../../../assert/js/assert.js';
import '../../../../../globals.js';
// Copyright 2024, University of Colorado Boulder
/**
 * A single level of scan (prefix sum) with configurable options.
 *
 * @author Jonathan Olson <jonathan.olson@colorado.edu>
 */
import { alpenglow, DIRECT_MODULE_DEFAULTS, DirectModule, MAIN_SCAN_DEFAULTS, mainScanWGSL } from '../../../imports.js';
import { combineOptions } from '../../../../../phet-core/js/optionize.js';
export const MAIN_SCAN_MODULE_DEFAULTS = {
    // eslint-disable-next-line phet/no-object-spread-on-non-literals
    ...DIRECT_MODULE_DEFAULTS,
    // eslint-disable-next-line phet/no-object-spread-on-non-literals
    ...MAIN_SCAN_DEFAULTS
};
// inputSize: number
export default class MainScanModule extends DirectModule {
    constructor(providedOptions) {
        const options = combineOptions({
            main: mainScanWGSL(providedOptions),
            setDispatchSize: (dispatchSize, inputSize) => {
                dispatchSize.x = Math.ceil(inputSize / (providedOptions.workgroupSize * providedOptions.grainSize));
            }
        }, providedOptions);
        super(options);
        this.reduction = null;
        this.scannedReduction = null;
        this.scannedDoubleReduction = null;
        if (options.inPlace) {
            assert && assert(options.data);
            this.input = options.data;
            this.output = options.data;
        }
        else {
            assert && assert(options.input);
            assert && assert(options.output);
            this.input = options.input;
            this.output = options.output;
        }
        if (options.storeReduction) {
            assert && assert(options.reduction);
            this.reduction = options.reduction;
        }
        if (options.addScannedReduction) {
            assert && assert(options.scannedReduction);
            this.scannedReduction = options.scannedReduction;
            if (options.addScannedDoubleReduction) {
                assert && assert(options.scannedDoubleReduction);
                this.scannedDoubleReduction = options.scannedDoubleReduction;
            }
        }
    }
}
alpenglow.register('MainScanModule', MainScanModule);
//# sourceMappingURL=MainScanModule.js.map