import{R as u}from"./index-T8LZyOXI.js";import{b as p}from"./KHR_interactivity-BRnQ0PPJ.js";import{R as n}from"./declarationMapper-YJJdbZ_c.js";import"./index-BkylzejB.js";import"./objectModelMapping-D1pI71RW.js";class f extends p{constructor(a){if(super(a),!a.variable&&!a.variables)throw new Error("FlowGraphSetVariableBlock: variable/variables is not defined");if(a.variables&&a.variable)throw new Error("FlowGraphSetVariableBlock: variable and variables are both defined");if(a.variables)for(const i of a.variables)this.registerDataInput(i,n);else this.registerDataInput("value",n)}_execute(a,i){if(this.config?.variables)for(const t of this.config.variables)this._saveVariable(a,t);else this._saveVariable(a,this.config?.variable,"value");this.out._activateSignal(a)}_saveVariable(a,i,t){const e=a._getGlobalContextVariable("currentlyRunningAnimationGroups",[]);for(const s of e){const l=a.assetsContext.animationGroups.find(r=>r.uniqueId==s);if(l){for(const r of l.targetedAnimations)if(r.target===a&&r.animation.targetProperty===i){l.stop();const o=e.indexOf(s);o>-1&&e.splice(o,1),a._setGlobalContextVariable("currentlyRunningAnimationGroups",e);break}}}const b=this.getDataInput(t||i)?.getValue(a);a.setVariable(i,b)}getClassName(){return"FlowGraphSetVariableBlock"}serialize(a){super.serialize(a),a.config.variable=this.config?.variable}}u("FlowGraphSetVariableBlock",f);export{f as FlowGraphSetVariableBlock};
