import _ from 'lodash';
import '../../../../globals.js';
// Copyright 2023-2024, University of Colorado Boulder
/**
 * TODO: doc
 *
 * @author Jonathan Olson <jonathan.olson@colorado.edu>
 */
import { alpenglow, BufferSlotSlice, ResourceSlot } from '../../imports.js';
export default class BufferSlot extends ResourceSlot {
    constructor(concreteType) {
        super();
        this.concreteType = concreteType;
        this.bufferSlotSlices = [];
        this.size = concreteType.bytesPerElement;
    }
    hasChildSlot(slot) {
        return this.bufferSlotSlices.some(slice => slice.bufferSlot === slot);
    }
    getSubtreeSlots() {
        return _.uniq([
            this,
            ...this.bufferSlotSlices.flatMap(slice => slice.bufferSlot.getSubtreeSlots())
        ]);
    }
    toDebugString() {
        return `BufferSlot[#${this.id} size:${this.size} type:${this.concreteType.name}]`;
    }
    castTo(concreteType) {
        const slot = new BufferSlot(concreteType);
        this.bufferSlotSlices.push(new BufferSlotSlice(slot, 0));
        return slot;
    }
}
alpenglow.register('BufferSlot', BufferSlot);
//# sourceMappingURL=BufferSlot.js.map