import _ from 'lodash';
import '../../../../globals.js';
// Copyright 2022-2024, University of Colorado Boulder
/**
 * A poolable internal representation of a line for layout handling in FlowConstraint
 *
 * @author Jonathan Olson <jonathan.olson@colorado.edu>
 */
import Orientation from '../../../../phet-core/js/Orientation.js';
import Pool from '../../../../phet-core/js/Pool.js';
import { LayoutLine, scenery } from '../../imports.js';
class FlowLine extends LayoutLine {
    /**
     * (scenery-internal)
     */
    constructor(orientation, cells) {
        super();
        this.initialize(orientation, cells);
    }
    /**
     * (scenery-internal)
     */
    initialize(orientation, cells) {
        this.orientation = orientation;
        this.cells = cells;
        this.initializeLayoutLine();
        return this;
    }
    /**
     * (scenery-internal)
     */
    getMinimumSize(spacing) {
        return (this.cells.length - 1) * spacing + _.sum(this.cells.map(cell => cell.getMinimumSize(this.orientation)));
    }
    /**
     * (scenery-internal)
     */
    freeToPool() {
        FlowLine.pool.freeToPool(this);
    }
    clean() {
        this.cells.length = 0;
        this.freeToPool();
    }
}
/**
 * (scenery-internal)
 */
FlowLine.pool = new Pool(FlowLine, {
    defaultArguments: [Orientation.HORIZONTAL, []]
});
export default FlowLine;
scenery.register('FlowLine', FlowLine);
//# sourceMappingURL=FlowLine.js.map