{"ast":null,"code":"import { RichTypeNumber } from \"../../../flowGraphRichTypes.js\";\nimport { FlowGraphExecutionBlockWithOutSignal } from \"../../../flowGraphExecutionBlockWithOutSignal.js\";\nimport { RegisterClass } from \"../../../../Misc/typeStore.js\";\n/**\n * @experimental\n * A block that throttles the execution of its output flow.\n */\nexport class FlowGraphThrottleBlock extends FlowGraphExecutionBlockWithOutSignal {\n constructor(config) {\n super(config);\n this.reset = this._registerSignalInput(\"reset\");\n this.duration = this.registerDataInput(\"duration\", RichTypeNumber);\n this.timeRemaining = this.registerDataOutput(\"timeRemaining\", RichTypeNumber);\n }\n _execute(context, callingSignal) {\n const lastExecutedTime = context._getExecutionVariable(this, \"lastExecutedTime\");\n const durationValue = this.duration.getValue(context);\n const currentTime = Date.now();\n if (callingSignal === this.reset || lastExecutedTime === undefined || currentTime - lastExecutedTime > durationValue) {\n //activate the output flow\n this.timeRemaining.setValue(0, context);\n this.out._activateSignal(context);\n context._setExecutionVariable(this, \"lastExecutedTime\", currentTime);\n } else {\n //activate the output flow after the remaining time\n const remaining = durationValue - (currentTime - lastExecutedTime);\n this.timeRemaining.setValue(remaining, context);\n }\n }\n /**\n * @returns class name of the block.\n */\n getClassName() {\n return \"FGThrottleBlock\";\n }\n}\nRegisterClass(\"FGThrottleBlock\", FlowGraphThrottleBlock);","map":{"version":3,"names":["RichTypeNumber","FlowGraphExecutionBlockWithOutSignal","RegisterClass","FlowGraphThrottleBlock","constructor","config","reset","_registerSignalInput","duration","registerDataInput","timeRemaining","registerDataOutput","_execute","context","callingSignal","lastExecutedTime","_getExecutionVariable","durationValue","getValue","currentTime","Date","now","undefined","setValue","out","_activateSignal","_setExecutionVariable","remaining","getClassName"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js"],"sourcesContent":["import { RichTypeNumber } from \"../../../flowGraphRichTypes.js\";\nimport { FlowGraphExecutionBlockWithOutSignal } from \"../../../flowGraphExecutionBlockWithOutSignal.js\";\nimport { RegisterClass } from \"../../../../Misc/typeStore.js\";\n/**\n * @experimental\n * A block that throttles the execution of its output flow.\n */\nexport class FlowGraphThrottleBlock extends FlowGraphExecutionBlockWithOutSignal {\n constructor(config) {\n super(config);\n this.reset = this._registerSignalInput(\"reset\");\n this.duration = this.registerDataInput(\"duration\", RichTypeNumber);\n this.timeRemaining = this.registerDataOutput(\"timeRemaining\", RichTypeNumber);\n }\n _execute(context, callingSignal) {\n const lastExecutedTime = context._getExecutionVariable(this, \"lastExecutedTime\");\n const durationValue = this.duration.getValue(context);\n const currentTime = Date.now();\n if (callingSignal === this.reset || lastExecutedTime === undefined || currentTime - lastExecutedTime > durationValue) {\n //activate the output flow\n this.timeRemaining.setValue(0, context);\n this.out._activateSignal(context);\n context._setExecutionVariable(this, \"lastExecutedTime\", currentTime);\n }\n else {\n //activate the output flow after the remaining time\n const remaining = durationValue - (currentTime - lastExecutedTime);\n this.timeRemaining.setValue(remaining, context);\n }\n }\n /**\n * @returns class name of the block.\n */\n getClassName() {\n return \"FGThrottleBlock\";\n }\n}\nRegisterClass(\"FGThrottleBlock\", FlowGraphThrottleBlock);\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,gCAAgC;AAC/D,SAASC,oCAAoC,QAAQ,kDAAkD;AACvG,SAASC,aAAa,QAAQ,+BAA+B;AAC7D;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,SAASF,oCAAoC,CAAC;EAC7EG,WAAWA,CAACC,MAAM,EAAE;IAChB,KAAK,CAACA,MAAM,CAAC;IACb,IAAI,CAACC,KAAK,GAAG,IAAI,CAACC,oBAAoB,CAAC,OAAO,CAAC;IAC/C,IAAI,CAACC,QAAQ,GAAG,IAAI,CAACC,iBAAiB,CAAC,UAAU,EAAET,cAAc,CAAC;IAClE,IAAI,CAACU,aAAa,GAAG,IAAI,CAACC,kBAAkB,CAAC,eAAe,EAAEX,cAAc,CAAC;EACjF;EACAY,QAAQA,CAACC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