import{R as r}from"./index-6jOCfdig.js";import{e as n}from"./KHR_interactivity-DRPs30Rf.js";import{i as a,F as o}from"./declarationMapper-CGPHX8aB.js";import"./index-Ds2meNS5.js";import"./svelte/svelte_svelte.js";import"./svelte/svelte_animate.js";import"./svelte/svelte_attachments.js";import"./svelte/svelte_easing.js";import"./svelte/svelte_internal_client.js";import"./svelte/svelte_internal_flags_async.js";import"./svelte/svelte_internal_flags_legacy.js";import"./svelte/svelte_internal_flags_tracing.js";import"./svelte/svelte_internal_server.js";import"./svelte/svelte_legacy.js";import"./svelte/svelte_motion.js";import"./svelte/svelte_reactivity.js";import"./svelte/svelte_reactivity_window.js";import"./svelte/svelte_server.js";import"./svelte/svelte_store.js";import"./svelte/svelte_transition.js";import"./svelte/svelte_events.js";import"./objectModelMapping-DT0r674A.js";class l extends n{constructor(t){super(t),this.config=t,this.outputSignals=[],this.reset=this._registerSignalInput("reset"),this.lastIndex=this.registerDataOutput("lastIndex",a,new o(-1)),this.setNumberOfOutputSignals(t?.outputSignalCount)}_getNextIndex(t){if(t.includes(!1)||this.config.isLoop&&t.fill(!1),this.config.isRandom){const i=t.map((e,s)=>e?-1:s).filter(e=>e!==-1);return i.length?i[Math.floor(Math.random()*i.length)]:-1}else return t.indexOf(!1)}setNumberOfOutputSignals(t=1){for(;this.outputSignals.length>t;){const i=this.outputSignals.pop();i&&(i.disconnectFromAll(),this._unregisterSignalOutput(i.name))}for(;this.outputSignals.length<t;)this.outputSignals.push(this._registerSignalOutput(`out_${this.outputSignals.length}`))}_execute(t,i){if(t._hasExecutionVariable(this,"indexesUsed")||t._setExecutionVariable(this,"indexesUsed",this.outputSignals.map(()=>!1)),i===this.reset){t._deleteExecutionVariable(this,"indexesUsed"),this.lastIndex.setValue(new o(-1),t);return}const e=t._getExecutionVariable(this,"indexesUsed",[]),s=this._getNextIndex(e);s>-1&&(this.lastIndex.setValue(new o(s),t),e[s]=!0,t._setExecutionVariable(this,"indexesUsed",e),this.outputSignals[s]._activateSignal(t))}getClassName(){return"FlowGraphMultiGateBlock"}serialize(t){super.serialize(t),t.config.outputSignalCount=this.config.outputSignalCount,t.config.isRandom=this.config.isRandom,t.config.loop=this.config.isLoop,t.config.startIndex=this.config.startIndex}}r("FlowGraphMultiGateBlock",l);export{l as FlowGraphMultiGateBlock};
