import { F as FlowGraphBlock, g as getNumericValue, G as GetFlowGraphAssetWithType } from './KHR_interactivity-CGdlBFnr.esm.js';
import { R as RichTypeAny, b as FlowGraphInteger } from './declarationMapper-CyyfQT3q.esm.js';
import { g as RegisterClass } from './index-D9EJJo2H.esm.js';
import './objectModelMapping-B3k5cPS3.esm.js';

/**
 * A block that will deliver an asset as an output, based on its type and place in the assets index.
 *
 * The assets are loaded from the assetsContext defined in the context running this block. The assetsContext is a class extending AbstractClass,
 * meaning it can be a Scene, an AssetsContainers, and any other class that extends AbstractClass.
 */
class FlowGraphGetAssetBlock extends FlowGraphBlock {
    constructor(
    /**
     * the configuration of the block
     */
    config) {
        super(config);
        this.config = config;
        this.type = this.registerDataInput("type", RichTypeAny, config.type);
        this.value = this.registerDataOutput("value", RichTypeAny);
        this.index = this.registerDataInput("index", RichTypeAny, new FlowGraphInteger(getNumericValue(config.index ?? -1)));
    }
    _updateOutputs(context) {
        const type = this.type.getValue(context);
        const index = this.index.getValue(context);
        // get the asset from the context
        const asset = GetFlowGraphAssetWithType(context.assetsContext, type, getNumericValue(index), this.config.useIndexAsUniqueId);
        this.value.setValue(asset, context);
    }
    /**
     * Gets the class name of this block
     * @returns the class name
     */
    getClassName() {
        return "FlowGraphGetAssetBlock" /* FlowGraphBlockNames.GetAsset */;
    }
}
RegisterClass("FlowGraphGetAssetBlock" /* FlowGraphBlockNames.GetAsset */, FlowGraphGetAssetBlock);

export { FlowGraphGetAssetBlock };
//# sourceMappingURL=flowGraphGetAssetBlock-B1kq3SCo.esm.js.map
