import"./rolldown-runtime-DIIn1E2Q.js";function tokenize(e){let t=[],n=/(\d+(?:\.\d*)?|\.\d+)|([+\-*/%()])/g,r=0;for(let i of e.matchAll(n)){if(e.slice(r,i.index).trim())return;r=i.index+i[0].length,i[1]?t.push({type:`number`,value:parseFloat(i[1])}):t.push({type:`op`,value:i[2]})}if(!e.slice(r).trim())return t}function evaluateMathExpression(e){let t=tokenize(e);if(!t||t.length===0)return;let n=t,r=0,i=0;function peek(){return n[r]}function consume(){return n[r++]}function primary(){let e=peek();if(e){if(e.type===`number`)return consume(),e.value;if(e.type===`op`&&e.value===`(`){if(++i>200)return;consume();let e=expr();if(e===void 0)return;let t=peek();return!t||t.type!==`op`||t.value!==`)`?void 0:(consume(),i--,e)}}}function unary(){let e=peek();if(e?.type===`op`&&(e.value===`+`||e.value===`-`)){consume();let t=unary();return t===void 0?void 0:e.value===`-`?-t:t}return primary()}function factor(){let e=unary();if(e!==void 0){for(;peek()?.type===`op`&&(peek().value===`*`||peek().value===`/`||peek().value===`%`);){let t=consume().value,n=unary();if(n===void 0)return;e=t===`*`?e*n:t===`/`?e/n:e%n}return e}}function expr(){let e=factor();if(e!==void 0){for(;peek()?.type===`op`&&(peek().value===`+`||peek().value===`-`);){let t=consume().value,n=factor();if(n===void 0)return;e=t===`+`?e+n:e-n}return e}}let a=expr();if(!(a===void 0||r!==n.length))return a===0?0:a}function getWidgetStep(e){return e.step2||(e.step||10)*.1}function evaluateInput(e){let t=evaluateMathExpression(e);if(t!==void 0)return isFinite(t)?t:void 0;let n=Number(e);if(isFinite(n))return n}function resolveNodeRootGraphId(e,t){return e.graph?.rootGraph.id??t}export{getWidgetStep as n,resolveNodeRootGraphId as r,evaluateInput as t};
//# sourceMappingURL=widget-BH5tDli6.js.map