ecma-evaluator 2.0.10 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"cjs/index.cjs","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../src/block.js","../../src/Evaluator.js","../../src/TemplateParser.js","../../src/index.js"],"sourcesContent":["__webpack_require__.d = function(exports, definition) {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }","// define __esModule on exports\n__webpack_require__.r = function(exports) {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const mutableMethods = [\n\t\"Array.prototype.push\",\n\t\"Array.prototype.pop\",\n\t\"Array.prototype.shift\",\n\t\"Array.prototype.unshift\",\n\t\"Array.prototype.splice\",\n\t\"Array.prototype.reverse\",\n\t\"Array.prototype.sort\",\n\t\"Array.prototype.fill\",\n\t\"Array.prototype.copyWithin\",\n\n\t\"Object.defineProperty\",\n\t\"Object.defineProperties\",\n\t\"Object.preventExtensions\",\n\t\"Object.seal\",\n\t\"Object.freeze\",\n\t\"Object.setPrototypeOf\",\n\t\"Object.assign\",\n\t\"Object.prototype.__defineGetter__\",\n\t\"Object.prototype.__defineSetter__\",\n\n\t\"Reflect.set\",\n\t\"Reflect.defineProperty\",\n\t\"Reflect.deleteProperty\",\n\t\"Reflect.setPrototypeOf\",\n\t\"Reflect.preventExtensions\",\n\n\t\"Set.prototype.add\",\n\t\"Set.prototype.delete\",\n\t\"Set.prototype.clear\",\n\t\"WeakSet.prototype.add\",\n\t\"WeakSet.prototype.delete\",\n\n\t\"Map.prototype.set\",\n\t\"Map.prototype.delete\",\n\t\"Map.prototype.clear\",\n\t\"WeakMap.prototype.set\",\n\t\"WeakMap.prototype.delete\",\n\n\t\"Date.prototype.setTime\",\n\t\"Date.prototype.setMilliseconds\",\n\t\"Date.prototype.setUTCSeconds\",\n\t\"Date.prototype.setSeconds\",\n\t\"Date.prototype.setMinutes\",\n\t\"Date.prototype.setHours\",\n\t\"Date.prototype.setDate\",\n\t\"Date.prototype.setMonth\",\n\t\"Date.prototype.setFullYear\",\n\t\"Date.prototype.setYear\",\n\t\"Date.prototype.setUTCMilliseconds\",\n\t\"Date.prototype.setUTCMinutes\",\n\t\"Date.prototype.setUTCHours\",\n\t\"Date.prototype.setUTCDate\",\n\t\"Date.prototype.setUTCMonth\",\n\t\"Date.prototype.setUTCFullYear\",\n\n\t\"RegExp.prototype.compile\",\n\n\t\"Int8Array.prototype.set\",\n\t\"Uint8Array.prototype.set\",\n\t\"Uint8ClampedArray.prototype.set\",\n\t\"Int16Array.prototype.set\",\n\t\"Uint16Array.prototype.set\",\n\t\"Int32Array.prototype.set\",\n\t\"Uint32Array.prototype.set\",\n\t\"Float32Array.prototype.set\",\n\t\"Float64Array.prototype.set\",\n\t\"BigInt64Array.prototype.set\",\n\t\"BigUint64Array.prototype.set\",\n\n\t\"Int8Array.prototype.fill\",\n\t\"Uint8Array.prototype.fill\",\n\t\"Uint8ClampedArray.prototype.fill\",\n\t\"Int16Array.prototype.fill\",\n\t\"Uint16Array.prototype.fill\",\n\t\"Int32Array.prototype.fill\",\n\t\"Uint32Array.prototype.fill\",\n\t\"Float32Array.prototype.fill\",\n\t\"Float64Array.prototype.fill\",\n\t\"BigInt64Array.prototype.fill\",\n\t\"BigUint64Array.prototype.fill\",\n\n\t\"Int8Array.prototype.reverse\",\n\t\"Uint8Array.prototype.reverse\",\n\t\"Uint8ClampedArray.prototype.reverse\",\n\t\"Int16Array.prototype.reverse\",\n\t\"Uint16Array.prototype.reverse\",\n\t\"Int32Array.prototype.reverse\",\n\t\"Uint32Array.prototype.reverse\",\n\t\"Float32Array.prototype.reverse\",\n\t\"Float64Array.prototype.reverse\",\n\t\"BigInt64Array.prototype.reverse\",\n\t\"BigUint64Array.prototype.reverse\",\n\n\t\"Int8Array.prototype.sort\",\n\t\"Uint8Array.prototype.sort\",\n\t\"Uint8ClampedArray.prototype.sort\",\n\t\"Int16Array.prototype.sort\",\n\t\"Uint16Array.prototype.sort\",\n\t\"Int32Array.prototype.sort\",\n\t\"Uint32Array.prototype.sort\",\n\t\"Float32Array.prototype.sort\",\n\t\"Float64Array.prototype.sort\",\n\t\"BigInt64Array.prototype.sort\",\n\t\"BigUint64Array.prototype.sort\",\n\n\t\"Int8Array.prototype.copyWithin\",\n\t\"Uint8Array.prototype.copyWithin\",\n\t\"Uint8ClampedArray.prototype.copyWithin\",\n\t\"Int16Array.prototype.copyWithin\",\n\t\"Uint16Array.prototype.copyWithin\",\n\t\"Int32Array.prototype.copyWithin\",\n\t\"Uint32Array.prototype.copyWithin\",\n\t\"Float32Array.prototype.copyWithin\",\n\t\"Float64Array.prototype.copyWithin\",\n\t\"BigInt64Array.prototype.copyWithin\",\n\t\"BigUint64Array.prototype.copyWithin\",\n\n\t\"ArrayBuffer.prototype.transfer\",\n\t\"ArrayBuffer.prototype.transferToFixedLength\",\n\n\t\"SharedArrayBuffer.prototype.grow\",\n\n\t\"DataView.prototype.setInt8\",\n\t\"DataView.prototype.setUint8\",\n\t\"DataView.prototype.setInt16\",\n\t\"DataView.prototype.setUint16\",\n\t\"DataView.prototype.setInt32\",\n\t\"DataView.prototype.setUint32\",\n\t\"DataView.prototype.setFloat32\",\n\t\"DataView.prototype.setFloat64\",\n\t\"DataView.prototype.setBigInt64\",\n\t\"DataView.prototype.setBigUint64\",\n\n\t\"Generator.prototype.next\",\n\t\"Generator.prototype.return\",\n\t\"Generator.prototype.throw\",\n\n\t\"AsyncGenerator.prototype.next\",\n\t\"AsyncGenerator.prototype.return\",\n\t\"AsyncGenerator.prototype.throw\",\n\n\t\"Iterator.prototype.next\",\n\n\t\"WeakRef.prototype.deref\",\n\n\t\"FinalizationRegistry.prototype.register\",\n\t\"FinalizationRegistry.prototype.unregister\",\n\n\t\"URLSearchParams.prototype.append\",\n\t\"URLSearchParams.prototype.delete\",\n\t\"URLSearchParams.prototype.set\",\n\t\"URLSearchParams.prototype.sort\",\n\n\t\"FormData.prototype.append\",\n\t\"FormData.prototype.delete\",\n\t\"FormData.prototype.set\",\n\n\t\"Headers.prototype.append\",\n\t\"Headers.prototype.delete\",\n\t\"Headers.prototype.set\",\n\n\t// Function call/apply/bind can be used to invoke with arbitrary `this`\n\t\"Function.prototype.call\",\n\t\"Function.prototype.apply\",\n\t\"Function.prototype.bind\",\n\t\"Function.prototype.constructor\",\n\n\t// Legacy lookup helpers\n\t\"Object.prototype.__lookupGetter__\",\n\t\"Object.prototype.__lookupSetter__\",\n\n\t// Constructor property can be abused to retrieve the Function constructor\n\t\"Object.prototype.constructor\",\n];\n\nconst dangerousMethods = [\n\t\"Object.getPrototypeOf\",\n\t// Various reflective/object-inspection APIs that may expose internals\n\t\"Object.getOwnPropertyDescriptor\",\n\t\"Object.getOwnPropertyDescriptors\",\n\t\"Object.getOwnPropertyNames\",\n\t\"Object.getOwnPropertySymbols\",\n\n\t// Error reflection: Error.captureStackTrace(obj) installs a host `stack`\n\t// property on any object - including Object.prototype - polluting the\n\t// host. Error.prepareStackTrace is a host-installed callback that, if\n\t// called with attacker-controlled Error/frames, executes host code paths.\n\t\"Error.captureStackTrace\",\n\t\"Error.prepareStackTrace\",\n];\n\n// Some prototype-style aliases/properties that can be used to break sandboxes\nmutableMethods.push(\"Object.prototype.__proto__\");\n\n/**\n * List of methods to block due to mutability or dangerousness\n */\nexport const blockedMethods = [...mutableMethods, ...dangerousMethods];\n\n/**\n * List of global built-ins to block entirely\n */\nexport const blockedGlobalBuiltIns = [\n\t\"Function\",\n\t\"GeneratorFunction\",\n\t\"AsyncFunction\",\n\t\"AsyncGeneratorFunction\",\n\t\"eval\",\n\t\"setTimeout\",\n\t\"setInterval\",\n\t\"clearTimeout\",\n\t\"clearInterval\",\n\t\"setImmediate\",\n\t\"XMLHttpRequest\",\n\t\"fetch\",\n\t\"WebSocket\",\n\t\"globalThis\",\n\n\t// Node / runtime globals\n\t\"process\",\n\t\"require\",\n\t\"module\",\n\t\"exports\",\n\t\"global\",\n\t\"Buffer\",\n\t\"setImmediate\",\n\t\"clearImmediate\",\n\n\t// Worker / threading / messaging\n\t\"importScripts\",\n\t\"Worker\",\n\t\"SharedWorker\",\n\t\"ServiceWorker\",\n\t\"BroadcastChannel\",\n\t\"MessageChannel\",\n\t\"MessagePort\",\n\t\"postMessage\",\n\n\t// Host environment globals (browser)\n\t\"window\",\n\t\"document\",\n\t\"navigator\",\n\t\"location\",\n\t\"localStorage\",\n\t\"sessionStorage\",\n\t\"indexedDB\",\n\t\"performance\",\n\n\t// Low-level / concurrent / binary APIs\n\t\"Proxy\",\n\t\"Reflect\",\n\t\"Atomics\",\n\t\"WebAssembly\",\n\t// SharedArrayBuffer escapes as a live reference to host shared memory\n\t// (structuredClone copies the handle, not the memory) and its constructor\n\t// allows multi-GiB allocations from ~20 characters of input\n\t\"SharedArrayBuffer\",\n\n\t// Asynchronous scheduling primitives that invoke callbacks in the host\n\t// runtime after evaluate() returns, escaping synchronous error handling\n\t\"queueMicrotask\",\n\t// AbortSignal.timeout() schedules a host timer whose abort listener runs\n\t// outside the interpreter; the whole global is blocked to close that hole\n\t\"AbortSignal\",\n\n\t// Promise is removed entirely. Any Promise that escapes evaluate() would\n\t// schedule its settlement callbacks in the host microtask queue, where\n\t// errors bypass the caller's synchronous try/catch and become unhandled\n\t// rejections. This single entry replaces the former per-method blocklist\n\t// (then/catch/finally/resolve/reject/all/race/any/allSettled/withResolvers).\n\t\"Promise\",\n\n\t// Console and internationalization\n\t\"console\",\n\t\"Intl\",\n\n\t// Other runtimes\n\t\"Deno\",\n];\n","import * as acorn from \"acorn\";\nimport globals from \"globals\";\nimport { blockedGlobalBuiltIns, blockedMethods } from \"./block.js\";\n\n// Error message constants for better maintainability\nconst ERROR_MESSAGES = {\n\tCAN_NOT_READ_PROPERTY: \"Cannot read property of {0} (reading '{1}')\",\n\tIS_INVALID_SYNTAX: \"{0} is not a valid syntax\",\n\tIS_NOT_FUNCTION: \"{0} is not a function\",\n\tIS_NOT_DEFINED: \"{0} is not defined\",\n\tIS_NOT_ALLOWED: \"{0} is not allowed\",\n\tEXPRESSION_TOO_LONG: \"Expression exceeds the maximum length of {0} characters\",\n};\n\n/**\n * Default maximum input length for a single expression.\n * Protects against resource exhaustion from overly long inputs.\n * Can be overridden per-instance via `new Evaluator(variables, { maxInputLength })`.\n */\nconst DEFAULT_MAX_INPUT_LENGTH = 10000;\nconst MAX_CONFIGURABLE_INPUT_LENGTH = 100000;\nconst DEFAULT_MAX_EVALUATION_STEPS = 10000;\nconst MAX_CONFIGURABLE_EVALUATION_STEPS = 100000;\nconst MAX_ARRAY_LENGTH = 10000;\nconst MAX_BUFFER_BYTES = 1000000;\nconst MAX_STRING_LENGTH = 100000;\nconst MAX_DATA_NODES = 100000;\nconst MAX_BIGINT_EXPONENT = 256n;\nconst MAX_BIGINT_BITS = 65536;\nconst TYPED_ARRAY_CONSTRUCTORS = new Set(\n\t[\n\t\tInt8Array,\n\t\tUint8Array,\n\t\tUint8ClampedArray,\n\t\tInt16Array,\n\t\tUint16Array,\n\t\tInt32Array,\n\t\tUint32Array,\n\t\tFloat32Array,\n\t\tFloat64Array,\n\t\ttypeof BigInt64Array === \"function\" ? BigInt64Array : null,\n\t\ttypeof BigUint64Array === \"function\" ? BigUint64Array : null,\n\t].filter((constructor) => typeof constructor === \"function\")\n);\n/**\n * Sentinel used to distinguish \"caller passed no pre-evaluated object\" from\n * \"the object expression itself evaluated to undefined\". See\n * {@link Evaluator#handleMemberExpression}.\n */\nconst NO_OBJECT = Symbol(\"no-object\");\n\n/**\n * Renders an error message by replacing placeholders with context values.\n * @param {string} template\n * @param {Record<string, any>} context\n * @example\n * ```js\n * const msg = renderErrorMessage(\"Cannot call mutable prototype method: {method}\", { method: \"push\" });\n * ```\n */\nconst renderErrorMessage = (template, context = {}) => template.replace(/{(\\w+)}/g, (_, key) => String(context[key]));\n\nfunction validateLimit(value, name, defaultValue, maximum) {\n\tif (value === undefined) {\n\t\treturn defaultValue;\n\t}\n\tif (!Number.isSafeInteger(value) || value < 1 || value > maximum) {\n\t\tthrow new RangeError(`${name} must be an integer between 1 and ${maximum}`);\n\t}\n\treturn value;\n}\n\nfunction countLiteralMatches(value, search, all) {\n\tif (search === \"\") {\n\t\treturn all ? value.length + 1 : 1;\n\t}\n\tlet count = 0;\n\tlet position = 0;\n\twhile ((position = value.indexOf(search, position)) !== -1) {\n\t\tcount++;\n\t\tif (!all) {\n\t\t\tbreak;\n\t\t}\n\t\tposition += search.length;\n\t}\n\treturn count;\n}\n\nfunction assertBoundedData(value, label) {\n\tconst pending = [value];\n\tconst seen = new WeakSet();\n\tlet dataSize = 0;\n\tlet dataNodes = 0;\n\tconst enqueueProperties = (object) => {\n\t\tconst keys = Object.keys(object);\n\t\tif (pending.length + keys.length > MAX_DATA_NODES) {\n\t\t\tthrow new RangeError(`${label} exceeds the maximum data node count`);\n\t\t}\n\t\tfor (const key of keys) {\n\t\t\tdataSize += key.length;\n\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(object, key);\n\t\t\tif (!descriptor || !Object.hasOwn(descriptor, \"value\")) {\n\t\t\t\tthrow new TypeError(`${label} cannot contain accessor properties`);\n\t\t\t}\n\t\t\tpending.push(descriptor.value);\n\t\t}\n\t};\n\n\twhile (pending.length > 0) {\n\t\tconst current = pending.pop();\n\t\tdataNodes++;\n\t\tif (dataNodes > MAX_DATA_NODES) {\n\t\t\tthrow new RangeError(`${label} exceeds the maximum data node count`);\n\t\t}\n\n\t\tif (typeof current === \"string\") {\n\t\t\tif (current.length > MAX_STRING_LENGTH) {\n\t\t\t\tthrow new RangeError(`${label} contains a string that exceeds the maximum length`);\n\t\t\t}\n\t\t\tdataSize += current.length + 8;\n\t\t} else if (current === null || (typeof current !== \"object\" && typeof current !== \"function\")) {\n\t\t\tdataSize += 8;\n\t\t\tcontinue;\n\t\t} else if (typeof current === \"function\" || seen.has(current)) {\n\t\t\tcontinue;\n\t\t} else {\n\t\t\tseen.add(current);\n\t\t\tdataSize += 16;\n\t\t\tif (current instanceof ArrayBuffer || ArrayBuffer.isView(current)) {\n\t\t\t\tdataSize += current.byteLength;\n\t\t\t} else if (Array.isArray(current)) {\n\t\t\t\tif (current.length > MAX_ARRAY_LENGTH) {\n\t\t\t\t\tthrow new RangeError(`${label} contains an array that exceeds the maximum length`);\n\t\t\t\t}\n\t\t\t\tdataSize += current.length * 8;\n\t\t\t\tenqueueProperties(current);\n\t\t\t} else if (current instanceof Map) {\n\t\t\t\tif (current.size > MAX_ARRAY_LENGTH) {\n\t\t\t\t\tthrow new RangeError(`${label} contains a map that exceeds the maximum size`);\n\t\t\t\t}\n\t\t\t\tdataSize += current.size * 16;\n\t\t\t\tMap.prototype.forEach.call(current, (item, key) => pending.push(key, item));\n\t\t\t} else if (current instanceof Set) {\n\t\t\t\tif (current.size > MAX_ARRAY_LENGTH) {\n\t\t\t\t\tthrow new RangeError(`${label} contains a set that exceeds the maximum size`);\n\t\t\t\t}\n\t\t\t\tdataSize += current.size * 8;\n\t\t\t\tSet.prototype.forEach.call(current, (item) => pending.push(item));\n\t\t\t} else {\n\t\t\t\tenqueueProperties(current);\n\t\t\t}\n\t\t}\n\n\t\tif (dataSize > MAX_BUFFER_BYTES) {\n\t\t\tthrow new RangeError(`${label} exceeds the maximum data size`);\n\t\t}\n\t}\n\treturn { dataSize, dataNodes };\n}\n\nconst BINARY_OPERATION_MAP = {\n\t\"+\": (a, b) => a + b,\n\t\"-\": (a, b) => a - b,\n\t\"*\": (a, b) => a * b,\n\t\"**\": (a, b) => a ** b,\n\t\"==\": (a, b) => a == b,\n\t\"===\": (a, b) => a === b,\n\t\"!=\": (a, b) => a != b,\n\t\"!==\": (a, b) => a !== b,\n\t\">\": (a, b) => a > b,\n\t\">=\": (a, b) => a >= b,\n\t\"<\": (a, b) => a < b,\n\t\"<=\": (a, b) => a <= b,\n\t\"%\": (a, b) => a % b,\n\t\"/\": (a, b) => a / b,\n\t\"|\": (a, b) => a | b,\n\t\"&\": (a, b) => a & b,\n\t\"^\": (a, b) => a ^ b,\n\t\"<<\": (a, b) => a << b,\n\t\">>\": (a, b) => a >> b,\n\t\">>>\": (a, b) => a >>> b,\n\tin: (a, b) => a in b,\n\tinstanceof: (a, b) => a instanceof b,\n};\n\nfunction createGlobalScope() {\n\tconst scope = Object.create(null);\n\tconst { builtin } = globals;\n\n\tfor (const key in builtin) {\n\t\tif (blockedGlobalBuiltIns.includes(key)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t/** @type {boolean} */\n\t\tconst isWritable = builtin[key];\n\n\t\tObject.defineProperty(scope, key, {\n\t\t\tvalue: globalThis[key],\n\t\t\twritable: isWritable,\n\t\t\tenumerable: false,\n\t\t\tconfigurable: false,\n\t\t});\n\t}\n\n\tObject.defineProperty(scope, \"globalThis\", {\n\t\tvalue: scope,\n\t\twritable: false,\n\t\tenumerable: false,\n\t\tconfigurable: false,\n\t});\n\n\treturn scope;\n}\n\nconst getBlockedMethods = (() => {\n\t/**\n\t * @type {Map<Function, string>}\n\t */\n\tlet BLOCKED_METHODS = null;\n\n\treturn () => {\n\t\tif (BLOCKED_METHODS) return BLOCKED_METHODS;\n\n\t\tconst map = new Map();\n\t\tfor (const path of blockedMethods) {\n\t\t\tconst [object, ...properties] = path.split(\".\");\n\t\t\tlet current = globalThis[object];\n\t\t\tfor (const prop of properties) {\n\t\t\t\tif (current && Object.hasOwn(current, prop)) {\n\t\t\t\t\tcurrent = current[prop];\n\t\t\t\t} else {\n\t\t\t\t\tcurrent = null;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (typeof current === \"function\") map.set(current, path);\n\t\t}\n\t\tBLOCKED_METHODS = map;\n\n\t\treturn BLOCKED_METHODS;\n\t};\n})();\n\n/**\n * A JavaScript expression evaluator that safely evaluates expressions within a sandboxed environment.\n * Supports various JavaScript features including arithmetic, logical operations, functions, and more.\n *\n * Security features:\n * - Blocks mutable methods to prevent side effects\n * - No access to eval() or Function() constructor\n * - Sandboxed scope with limited global objects\n *\n * @example\n * const evaluator = new Evaluator({ x: 10, y: 20 });\n * evaluator.evaluate('x + y') // returns 30\n */\nexport class Evaluator {\n\t/**\n\t * Creates a new Evaluator instance with a custom variable context.\n\t * The scope hierarchy is: user variables -> global scope\n\t * @param {Object} [variables={}] - An optional object containing variables to make available in the evaluation context\n\t * @param {Object} [options={}] - Additional configuration options\n\t * @param {number} [options.maxInputLength=10000] - Maximum expression length (hard maximum: 100000)\n\t * @param {number} [options.maxEvaluationSteps=10000] - Maximum AST node visits per evaluation (hard maximum: 100000)\n\t */\n\tconstructor(variables = Object.create(null), options) {\n\t\tthis.maxInputLength = validateLimit(options?.maxInputLength, \"maxInputLength\", DEFAULT_MAX_INPUT_LENGTH, MAX_CONFIGURABLE_INPUT_LENGTH);\n\t\tthis.maxEvaluationSteps = validateLimit(options?.maxEvaluationSteps, \"maxEvaluationSteps\", DEFAULT_MAX_EVALUATION_STEPS, MAX_CONFIGURABLE_EVALUATION_STEPS);\n\t\tassertBoundedData(variables, \"Evaluation context\");\n\t\tconst clonedVariables = structuredClone(variables);\n\t\tthis.scopes = [clonedVariables, createGlobalScope()].filter((scope) => scope !== null && scope !== undefined);\n\t\tthis.source = undefined;\n\t\tthis.remainingEvaluationSteps = 0;\n\t\tthis.remainingDataSize = MAX_BUFFER_BYTES;\n\t\tthis.remainingDataNodes = MAX_DATA_NODES;\n\t}\n\n\t/**\n\t * Evaluates a JavaScript expression with an optional context.\n\t * @param {string} expression\n\t * @param {unknown} [context]\n\t * @returns\n\t */\n\tstatic evaluate(expression, context) {\n\t\tconst evaluator = new Evaluator(context);\n\t\treturn evaluator.evaluate(expression);\n\t}\n\n\t/**\n\t * Parses and evaluates a JavaScript expression using acorn parser.\n\t * @param {string} expression - The JavaScript expression to evaluate\n\t * @returns {*} The result of the evaluation\n\t * @throws {SyntaxError} If the expression has invalid syntax\n\t * @throws {ReferenceError} If referencing undefined variables\n\t * @throws {TypeError} If performing invalid operations\n\t */\n\tevaluate(expression) {\n\t\tif (typeof expression !== \"string\") {\n\t\t\tthrow new TypeError(\"Expression must be a string\");\n\t\t}\n\n\t\tif (expression.length > this.maxInputLength) {\n\t\t\tthrow new SyntaxError(renderErrorMessage(ERROR_MESSAGES.EXPRESSION_TOO_LONG, [this.maxInputLength]));\n\t\t}\n\n\t\tthis.source = expression;\n\t\tthis.remainingEvaluationSteps = this.maxEvaluationSteps;\n\t\tthis.remainingDataSize = MAX_BUFFER_BYTES;\n\t\tthis.remainingDataNodes = MAX_DATA_NODES;\n\n\t\tconst ast = acorn.parse(expression, { ecmaVersion: \"latest\" });\n\n\t\t// Start recursive evaluation from the root node\n\t\ttry {\n\t\t\treturn this.execute(ast.body);\n\t\t} finally {\n\t\t\tthis.source = undefined;\n\t\t}\n\t}\n\n\t/**\n\t * Executes an array of AST body nodes sequentially.\n\t * @private\n\t * @param {Array} body - Array of AST nodes to execute\n\t * @returns {*} The result of the last executed node\n\t */\n\texecute(body) {\n\t\tif (this.remainingEvaluationSteps === 0) {\n\t\t\tthis.remainingEvaluationSteps = this.maxEvaluationSteps;\n\t\t\tthis.remainingDataSize = MAX_BUFFER_BYTES;\n\t\t\tthis.remainingDataNodes = MAX_DATA_NODES;\n\t\t}\n\t\tlet result;\n\n\t\tfor (const node of body) {\n\t\t\tresult = this.visit(node);\n\t\t}\n\n\t\tif (typeof result === \"function\") {\n\t\t\tthrow new Error(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"Returning functions from expressions\"]));\n\t\t}\n\n\t\tassertBoundedData(result, \"Evaluation result\");\n\n\t\t// A leaked Promise schedules sandbox callbacks (and rejection errors)\n\t\t// in the host microtask queue, outside the caller's try/catch. Never\n\t\t// allow one to escape evaluate() as a value.\n\t\tif (result instanceof Promise) {\n\t\t\tthrow new Error(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"Returning promises from expressions\"]));\n\t\t}\n\n\t\t// Final gate: the return value must be cloneable, pure data. A\n\t\t// function (or any non-cloneable object) smuggled inside an object or\n\t\t// array - no matter how deeply nested - fails structuredClone with a\n\t\t// DataCloneError. Without this, closures could escape evaluate() (e.g.\n\t\t// `({ f: () => secret })`) and keep reading the evaluator's scopes\n\t\t// (and host-passed objects) long after evaluate() returned. Cloning\n\t\t// also hands the host a copy instead of a reference to sandbox\n\t\t// internals, and it rejects WeakRef/FinalizationRegistry/Proxy and\n\t\t// other host-only objects.\n\t\ttry {\n\t\t\treturn structuredClone(result);\n\t\t} catch (error) {\n\t\t\tif (error && error.name === \"DataCloneError\") {\n\t\t\t\tthrow new Error(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"Returning non-cloneable values from expressions\"]));\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Visits an AST node and delegates to the appropriate handler based on node type.\n\t * @private\n\t * @param {import(\"acorn\").Node} node - The AST node to visit\n\t * @returns {*} The result of visiting the node\n\t */\n\tvisit(node) {\n\t\tthis.remainingEvaluationSteps--;\n\t\tif (this.remainingEvaluationSteps < 0) {\n\t\t\tthrow new RangeError(\"Evaluation step limit exceeded\");\n\t\t}\n\n\t\tswitch (node.type) {\n\t\t\tcase \"ExpressionStatement\": {\n\t\t\t\treturn this.visit(node.expression);\n\t\t\t}\n\t\t\tcase \"BinaryExpression\": {\n\t\t\t\treturn this.handleBinaryExpression(node);\n\t\t\t}\n\t\t\tcase \"LogicalExpression\": {\n\t\t\t\treturn this.handleLogicalExpression(node);\n\t\t\t}\n\t\t\tcase \"UnaryExpression\": {\n\t\t\t\treturn this.handleUnaryExpression(node);\n\t\t\t}\n\t\t\tcase \"Identifier\": {\n\t\t\t\treturn this.handleIdentifier(node);\n\t\t\t}\n\t\t\tcase \"Literal\": {\n\t\t\t\treturn node.value;\n\t\t\t}\n\t\t\tcase \"MemberExpression\": {\n\t\t\t\treturn this.handleMemberExpression(node);\n\t\t\t}\n\t\t\tcase \"ArrayExpression\": {\n\t\t\t\treturn this.handleArrayExpression(node);\n\t\t\t}\n\t\t\tcase \"SpreadElement\": {\n\t\t\t\treturn this.handleSpreadElement(node);\n\t\t\t}\n\t\t\tcase \"ObjectExpression\": {\n\t\t\t\treturn this.handleObjectExpression(node);\n\t\t\t}\n\t\t\tcase \"FunctionExpression\": {\n\t\t\t\tthrow new SyntaxError(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"Function expression\"]));\n\t\t\t}\n\t\t\tcase \"ArrowFunctionExpression\": {\n\t\t\t\treturn this.handleArrowFunctionExpression(node);\n\t\t\t}\n\t\t\tcase \"CallExpression\": {\n\t\t\t\treturn this.handleCallExpression(node);\n\t\t\t}\n\t\t\tcase \"ConditionalExpression\": {\n\t\t\t\treturn this.visit(node.test) ? this.visit(node.consequent) : this.visit(node.alternate);\n\t\t\t}\n\t\t\tcase \"NewExpression\": {\n\t\t\t\tif (node.callee.type !== \"Identifier\") {\n\t\t\t\t\tthrow new Error(`Unsupported callee type '${node.callee.type}' in new expression`);\n\t\t\t\t}\n\n\t\t\t\tif (node.callee.name === \"Function\") {\n\t\t\t\t\tthrow new Error(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"new Function() constructor\"]));\n\t\t\t\t}\n\n\t\t\t\t// Promise is fully removed from the sandbox; give a clear error\n\t\t\t\t// instead of a generic \"not defined\". Its executor runs\n\t\t\t\t// synchronously, but a throwing executor would turn into a\n\t\t\t\t// rejected Promise that escapes evaluate() and crashes the host.\n\t\t\t\tif (node.callee.name === \"Promise\") {\n\t\t\t\t\tthrow new Error(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"Promise constructor\"]));\n\t\t\t\t}\n\t\t\t\tconst Constructor = this.visit(node.callee);\n\n\t\t\t\t// 仅在存在参数时构建数组\n\t\t\t\tconst args = node.arguments.length ? node.arguments.map((arg) => this.visit(arg)) : [];\n\t\t\t\tthis.assertBoundedConstruction(Constructor, args);\n\n\t\t\t\treturn new Constructor(...args);\n\t\t\t}\n\t\t\tcase \"ChainExpression\": {\n\t\t\t\treturn this.visit(node.expression);\n\t\t\t}\n\t\t\tcase \"TemplateLiteral\": {\n\t\t\t\treturn this.handleTemplateLiteral(node);\n\t\t\t}\n\t\t\tcase \"ThisExpression\": {\n\t\t\t\tthrow new SyntaxError(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"'this' expression\"]));\n\t\t\t}\n\t\t\tcase \"WithStatement\": {\n\t\t\t\tthrow new SyntaxError(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"'with' statement\"]));\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tlet content = this.source.slice(node.start, node.end);\n\n\t\t\t\tif (content.length > 20) {\n\t\t\t\t\tcontent = content.slice(0, 17) + \"...\";\n\t\t\t\t}\n\n\t\t\t\tthrow new SyntaxError(`'${content}'` + \" \" + renderErrorMessage(ERROR_MESSAGES.IS_INVALID_SYNTAX, [content]));\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Handles binary expressions (arithmetic and comparison operations).\n\t * @param {import('acorn').BinaryExpression} node\n\t * @private\n\t */\n\thandleBinaryExpression(node) {\n\t\tconst op = node.operator;\n\t\tconst left = this.visit(node.left);\n\t\tconst right = this.visit(node.right);\n\t\tif (op === \"+\" && (typeof left === \"string\" || typeof right === \"string\")) {\n\t\t\tif (String(left).length + String(right).length > MAX_STRING_LENGTH) {\n\t\t\t\tthrow new RangeError(\"String result exceeds the maximum allowed length\");\n\t\t\t}\n\t\t}\n\t\tif (typeof left === \"bigint\" && typeof right === \"bigint\") {\n\t\t\tif (op === \"**\" && (right > MAX_BIGINT_EXPONENT || right < 0n)) {\n\t\t\t\tthrow new RangeError(`BigInt exponent must be between 0 and ${MAX_BIGINT_EXPONENT}`);\n\t\t\t}\n\t\t\tconst leftBits = left.toString(2).length;\n\t\t\tconst rightBits = right.toString(2).length;\n\t\t\tif (\n\t\t\t\t(op === \"**\" && leftBits * Number(right) > MAX_BIGINT_BITS) ||\n\t\t\t\t(op === \"<<\" && right > BigInt(MAX_BIGINT_BITS)) ||\n\t\t\t\t(op === \"<<\" && right >= 0n && leftBits + Number(right) > MAX_BIGINT_BITS) ||\n\t\t\t\t(op === \"*\" && leftBits + rightBits > MAX_BIGINT_BITS) ||\n\t\t\t\t((op === \"+\" || op === \"-\") && Math.max(leftBits, rightBits) + 1 > MAX_BIGINT_BITS)\n\t\t\t) {\n\t\t\t\tthrow new RangeError(\"BigInt result exceeds the maximum allowed size\");\n\t\t\t}\n\t\t}\n\n\t\tif (BINARY_OPERATION_MAP.hasOwnProperty(op)) {\n\t\t\treturn BINARY_OPERATION_MAP[op](left, right);\n\t\t}\n\n\t\tthrow new SyntaxError(`Unsupported operator: ${node.operator}`);\n\t}\n\n\tassertBoundedConstruction(Constructor, args) {\n\t\tconst size = args[0];\n\t\tif (Constructor === Array && args.length === 1 && typeof size === \"number\" && size > MAX_ARRAY_LENGTH) {\n\t\t\tthrow new RangeError(\"Array length exceeds the maximum allowed length\");\n\t\t}\n\t\tif (Constructor === ArrayBuffer && (size > MAX_BUFFER_BYTES || args[1]?.maxByteLength > MAX_BUFFER_BYTES)) {\n\t\t\tthrow new RangeError(\"ArrayBuffer size exceeds the maximum allowed size\");\n\t\t}\n\t\tif (Constructor === DataView && size instanceof ArrayBuffer && size.byteLength > MAX_BUFFER_BYTES) {\n\t\t\tthrow new RangeError(\"DataView size exceeds the maximum allowed size\");\n\t\t}\n\t\tif (Constructor === Map || Constructor === Set) {\n\t\t\tconst collectionSize = typeof size === \"string\" || Array.isArray(size) ? size.length : size?.size ?? size?.length;\n\t\t\tif (typeof collectionSize === \"number\" && collectionSize > MAX_ARRAY_LENGTH) {\n\t\t\t\tthrow new RangeError(\"Collection source exceeds the maximum allowed size\");\n\t\t\t}\n\t\t}\n\t\tif (TYPED_ARRAY_CONSTRUCTORS.has(Constructor)) {\n\t\t\tlet byteLength;\n\t\t\tif (size instanceof ArrayBuffer) {\n\t\t\t\tconst offset = args[1] ?? 0;\n\t\t\t\tconst elementCount = args[2] ?? Math.floor((size.byteLength - offset) / Constructor.BYTES_PER_ELEMENT);\n\t\t\t\tbyteLength = elementCount * Constructor.BYTES_PER_ELEMENT;\n\t\t\t} else {\n\t\t\t\tconst elementCount = typeof size === \"number\" ? size : size?.length ?? 0;\n\t\t\t\tbyteLength = elementCount * Constructor.BYTES_PER_ELEMENT;\n\t\t\t}\n\t\t\tif (byteLength > MAX_BUFFER_BYTES) {\n\t\t\t\tthrow new RangeError(\"Typed array size exceeds the maximum allowed size\");\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Handles logical expressions (&&, ||, ??).\n\t * Implements proper short-circuit evaluation for performance.\n\t * @private\n\t */\n\thandleLogicalExpression(node) {\n\t\tswitch (node.operator) {\n\t\t\tcase \"&&\": {\n\t\t\t\tconst left = this.visit(node.left);\n\t\t\t\treturn left ? this.visit(node.right) : left;\n\t\t\t}\n\t\t\tcase \"||\": {\n\t\t\t\tconst left = this.visit(node.left);\n\t\t\t\treturn left ? left : this.visit(node.right);\n\t\t\t}\n\t\t\tcase \"??\": {\n\t\t\t\tconst left = this.visit(node.left);\n\t\t\t\treturn left !== null && left !== undefined ? left : this.visit(node.right);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new SyntaxError(`Unsupported logical operator: ${node.operator}`);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Handles unary expressions (-, +, !, ~, typeof, void).\n\t * @private\n\t */\n\thandleUnaryExpression(node) {\n\t\tswitch (node.operator) {\n\t\t\tcase \"-\": {\n\t\t\t\treturn -this.visit(node.argument);\n\t\t\t}\n\t\t\tcase \"+\": {\n\t\t\t\treturn +this.visit(node.argument);\n\t\t\t}\n\t\t\tcase \"!\": {\n\t\t\t\treturn !this.visit(node.argument);\n\t\t\t}\n\t\t\tcase \"~\": {\n\t\t\t\treturn ~this.visit(node.argument);\n\t\t\t}\n\t\t\tcase \"typeof\": {\n\t\t\t\treturn typeof this.visit(node.argument);\n\t\t\t}\n\t\t\tcase \"void\": {\n\t\t\t\treturn void this.visit(node.argument);\n\t\t\t}\n\t\t\tcase \"delete\": {\n\t\t\t\tthrow new SyntaxError(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"Delete operator\"]));\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new SyntaxError(`Unsupported unary operator: ${node.operator}`);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Handles identifier (variable) lookups in the scope chain.\n\t * @private\n\t */\n\thandleIdentifier(node) {\n\t\tconst name = node.name;\n\t\tfor (const scope of this.scopes) {\n\t\t\tif (Object.hasOwn(scope, name)) {\n\t\t\t\treturn scope[name];\n\t\t\t}\n\t\t}\n\n\t\tthrow new ReferenceError(renderErrorMessage(ERROR_MESSAGES.IS_NOT_DEFINED, [name]));\n\t}\n\n\t/**\n\t * Handles member expressions (property access like obj.prop or obj[prop]).\n\t * @private\n\t */\n\thandleMemberExpression(node, objectValue = NO_OBJECT) {\n\t\tconst object = objectValue === NO_OBJECT ? this.visit(node.object) : objectValue;\n\t\t// Determine property name: either identifier name or computed value\n\t\tconst isStaticProperty = node.property.type === \"Identifier\" && !node.computed;\n\t\tconst property = isStaticProperty ? node.property.name : this.visit(node.property);\n\n\t\t// Reading `.stack` on an Error instance forces V8 to materialize the\n\t\t// stack, which invokes a host-installed Error.prepareStackTrace with\n\t\t// sandbox-owned values. Block it *before* any property access, since\n\t\t// even the prototype check below would trigger the getter.\n\t\tif (property === \"stack\" && object instanceof Error) {\n\t\t\tthrow new Error(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"Accessing error stack\"]));\n\t\t}\n\n\t\t// Prevent access to prototype properties\n\t\tif (typeof object !== \"undefined\" && object !== null && object[property] === object?.__proto__) {\n\t\t\tthrow new Error(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"Accessing prototype properties\"]));\n\t\t}\n\n\t\tif (object === null || object === undefined) {\n\t\t\t// optional chaining\n\t\t\tif (node.optional) {\n\t\t\t\treturn void 0;\n\t\t\t}\n\t\t\tthrow new TypeError(renderErrorMessage(ERROR_MESSAGES.CAN_NOT_READ_PROPERTY, [object, property]));\n\t\t}\n\n\t\tconst result = object[property];\n\n\t\t// The Function constructor must never be reachable from an expression.\n\t\t// If it escapes as a value, native callbacks (e.g. Promise.then,\n\t\t// Array.prototype.map) invoke it outside the interpreter's call path,\n\t\t// enabling arbitrary host code execution. This is a structural guard:\n\t\t// no matter how many `.constructor` hops an expression takes, the\n\t\t// final value can never be `Function` (or its prototype).\n\t\tif (result === Function || result === Function.prototype) {\n\t\t\tthrow new Error(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"Function constructor\"]));\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Handles array literal expressions.\n\t * @private\n\t */\n\thandleArrayExpression(node) {\n\t\tconst result = [];\n\n\t\tfor (let i = 0; i < node.elements.length; i++) {\n\t\t\tconst element = node.elements.at(i);\n\n\t\t\t// Array holes (`[1, , 3]`) are represented as null elements by\n\t\t\t// acorn. Preserve them instead of crashing on node.type access.\n\t\t\tif (element === null) {\n\t\t\t\tresult.length++;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst value = this.visit(element);\n\n\t\t\tif (element.type === \"SpreadElement\") {\n\t\t\t\tthis.assertBoundedSpread(result.length, value);\n\t\t\t\tresult.push(...value);\n\t\t\t} else {\n\t\t\t\tresult.push(value);\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tassertBoundedSpread(currentLength, value) {\n\t\tconst size = typeof value === \"string\" || Array.isArray(value) ? value.length : value?.size;\n\t\tif (typeof size === \"number\" && currentLength + size > MAX_ARRAY_LENGTH) {\n\t\t\tthrow new RangeError(\"Spread value exceeds the maximum allowed length\");\n\t\t}\n\t}\n\n\t/**\n\t * Handles object literal expressions.\n\t * @returns\n\t */\n\thandleObjectExpression(node) {\n\t\tconst obj = {};\n\t\tlet spreadPropertyCount = 0;\n\t\tfor (const prop of node.properties) {\n\t\t\tif (prop.type === \"SpreadElement\") {\n\t\t\t\tconst spreadValue = this.visit(prop.argument);\n\t\t\t\tspreadPropertyCount += Object.keys(spreadValue).length;\n\t\t\t\tif (spreadPropertyCount > MAX_ARRAY_LENGTH) {\n\t\t\t\t\tthrow new RangeError(\"Object spread exceeds the maximum allowed property count\");\n\t\t\t\t}\n\t\t\t\tObject.assign(obj, spreadValue);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// Computed keys must be *evaluated* (`{ [1 + 1]: v }` -> key \"2\"),\n\t\t\t// not taken from the property name. Non-computed keys keep the\n\t\t\t// literal `__proto__: v` semantics (which sets the prototype via\n\t\t\t// the Object.prototype.__proto__ setter), while computed keys are\n\t\t\t// plain properties: `{ [\"__proto__\"]: v }` must NOT touch the\n\t\t\t// prototype.\n\t\t\tconst key = prop.computed ? this.visit(prop.key) : prop.key.name || prop.key.value;\n\t\t\tconst value = this.visit(prop.value);\n\t\t\tif (prop.computed) {\n\t\t\t\tObject.defineProperty(obj, key, { value, writable: true, enumerable: true, configurable: true });\n\t\t\t} else {\n\t\t\t\tobj[key] = value;\n\t\t\t}\n\t\t}\n\t\treturn obj;\n\t}\n\n\thandleSpreadElement(node) {\n\t\treturn this.visit(node.argument);\n\t}\n\n\t/**\n\t * Handles arrow function expressions.\n\t * Creates a closure that captures the current scope and executes the function body\n\t * with parameters bound to a new scope.\n\t * @private\n\t */\n\thandleArrowFunctionExpression(node) {\n\t\treturn (...args) => {\n\t\t\t// Create new scope with parameters bound to arguments\n\t\t\tconst newScope = {};\n\t\t\tconst paramCount = node.params.length;\n\t\t\tfor (let i = 0; i < paramCount; i++) {\n\t\t\t\tnewScope[node.params[i].name] = args[i];\n\t\t\t}\n\n\t\t\t// Push new scope, evaluate body, then pop scope. The scope must be\n\t\t\t// popped even when the body throws: a leaked scope would make the\n\t\t\t// parameter bindings visible to subsequent evaluations on the same\n\t\t\t// instance.\n\t\t\tthis.scopes.unshift(newScope);\n\t\t\ttry {\n\t\t\t\tconst result = this.visit(node.body);\n\t\t\t\tthis.consumeEvaluationValue(result);\n\t\t\t\treturn result;\n\t\t\t} finally {\n\t\t\t\tthis.scopes.shift();\n\t\t\t}\n\t\t};\n\t}\n\n\tconsumeEvaluationValue(value) {\n\t\tconst { dataSize, dataNodes } = assertBoundedData(value, \"Intermediate evaluation result\");\n\t\tthis.remainingDataSize -= dataSize;\n\t\tthis.remainingDataNodes -= dataNodes;\n\t\tif (this.remainingDataSize < 0 || this.remainingDataNodes < 0) {\n\t\t\tthrow new RangeError(\"Evaluation allocation budget exceeded\");\n\t\t}\n\t}\n\n\t/**\n\t * Handles function call expressions, including optional chaining.\n\t * @private\n\t */\n\thandleCallExpression(node) {\n\t\tconst isOptional = node.optional || (node.callee.type === \"MemberExpression\" && node.callee.optional);\n\t\tlet func;\n\t\tlet target = null;\n\n\t\tif (node.callee.type === \"MemberExpression\") {\n\t\t\t// Evaluate the object expression exactly once, then resolve the\n\t\t\t// property through handleMemberExpression so that all of its\n\t\t\t// guards (.stack access, prototype access, Function constructor)\n\t\t\t// still apply. Visiting the whole callee and then the object again\n\t\t\t// would double-evaluate side-effecting expressions such as\n\t\t\t// `new Date(1000).getTime()` or `f().g()`.\n\t\t\ttarget = this.visit(node.callee.object);\n\t\t\tfunc = this.handleMemberExpression(node.callee, target);\n\t\t} else {\n\t\t\tfunc = this.visit(node.callee);\n\t\t}\n\n\t\tif ((func === undefined || func === null) && isOptional) {\n\t\t\treturn void 0;\n\t\t}\n\n\t\tif (func === Function) {\n\t\t\tthrow new Error(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"Function constructor\"]));\n\t\t}\n\t\t// Error.prepareStackTrace is a host-installed callback. It must be\n\t\t// checked dynamically: the blocked-methods map is built lazily on first\n\t\t// use, so a host that installs the callback *after* that point would\n\t\t// otherwise evade the static blocklist.\n\t\tif (func === Error.prepareStackTrace) {\n\t\t\tthrow new Error(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"Error.prepareStackTrace\"]));\n\t\t}\n\n\t\tif (getBlockedMethods().has(func)) {\n\t\t\tconst path = getBlockedMethods().get(func);\n\t\t\tthrow new Error(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [path]));\n\t\t}\n\n\t\t// 仅在存在参数时构建数组\n\t\tconst args = (() => {\n\t\t\tif (node.arguments.length === 0) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tlet result = [];\n\n\t\t\tfor (let i = 0; i < node.arguments.length; i++) {\n\t\t\t\tconst element = node.arguments.at(i);\n\t\t\t\tconst value = this.visit(element);\n\n\t\t\t\tif (element.type === \"SpreadElement\") {\n\t\t\t\t\tthis.assertBoundedSpread(result.length, value);\n\t\t\t\t\tresult.push(...value);\n\t\t\t\t} else {\n\t\t\t\t\tresult.push(value);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn result;\n\t\t})();\n\n\t\t// Defense in depth: even if a `Function` reference were somehow\n\t\t// produced by an expression, it must not be passed as an argument.\n\t\t// Native methods (Promise.then, Array.prototype.map, ...) would\n\t\t// invoke it in the host runtime, outside this interpreter's checks.\n\t\tif (args.some((arg) => arg === Function)) {\n\t\t\tthrow new Error(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"Function constructor\"]));\n\t\t}\n\t\tif (typeof target === \"string\") {\n\t\t\tif (String.prototype.repeat && func === String.prototype.repeat && target.length * Number(args[0]) > MAX_STRING_LENGTH) {\n\t\t\t\tthrow new RangeError(\"String result exceeds the maximum allowed length\");\n\t\t\t}\n\t\t\tif ((String.prototype.padStart && func === String.prototype.padStart || func === String.prototype.padEnd) && Number(args[0]) > MAX_STRING_LENGTH) {\n\t\t\t\tthrow new RangeError(\"String result exceeds the maximum allowed length\");\n\t\t\t}\n\t\t\tif (String.prototype.concat && func === String.prototype.concat) {\n\t\t\t\tconst resultLength = target.length + args.reduce((length, value) => length + String(value).length, 0);\n\t\t\t\tif (resultLength > MAX_STRING_LENGTH) {\n\t\t\t\t\tthrow new RangeError(\"String result exceeds the maximum allowed length\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ((String.prototype.replace && func === String.prototype.replace) || (String.prototype.replaceAll && func === String.prototype.replaceAll)) {\n\t\t\t\tif (typeof args[0] === \"string\") {\n\t\t\t\t\tif (typeof args[1] === \"function\" || (typeof args[1] === \"string\" && /\\$(?:[$&'`])/u.test(args[1]))) {\n\t\t\t\t\t\tthrow new Error(\"Only literal string replacements are allowed\");\n\t\t\t\t\t}\n\t\t\t\t\tif (target.length * Math.max(1, args[0].length) > 10000000) {\n\t\t\t\t\t\tthrow new RangeError(\"String operation exceeds the maximum work limit\");\n\t\t\t\t\t}\n\t\t\t\t\tconst matchCount = countLiteralMatches(target, args[0], func === String.prototype.replaceAll);\n\t\t\t\t\tif (target.length + matchCount * String(args[1]).length > MAX_STRING_LENGTH) {\n\t\t\t\t\t\tthrow new RangeError(\"String result exceeds the maximum allowed length\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (func === String.prototype.split) {\n\t\t\t\tif (args[0] === \"\" && target.length > MAX_ARRAY_LENGTH) {\n\t\t\t\t\tthrow new RangeError(\"Split result exceeds the maximum allowed length\");\n\t\t\t\t}\n\t\t\t\tif (typeof args[0] === \"string\" && args[0] !== \"\" && countLiteralMatches(target, args[0], true) >= MAX_ARRAY_LENGTH) {\n\t\t\t\t\tthrow new RangeError(\"Split result exceeds the maximum allowed length\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif ((target === Array || TYPED_ARRAY_CONSTRUCTORS.has(target)) && func === target.from) {\n\t\t\tconst source = args[0];\n\t\t\tconst size = typeof source === \"string\" || Array.isArray(source) ? source.length : source?.size ?? source?.length;\n\t\t\tif (typeof size === \"number\" && size > MAX_ARRAY_LENGTH) {\n\t\t\t\tthrow new RangeError(\"Array.from source exceeds the maximum allowed length\");\n\t\t\t}\n\t\t}\n\n\t\tif (typeof func !== \"function\") {\n\t\t\tconst calledString = getNodeString(node.callee);\n\t\t\tthrow new TypeError(renderErrorMessage(ERROR_MESSAGES.IS_NOT_FUNCTION, [calledString]));\n\t\t}\n\n\t\tconst result = func.apply(target, args);\n\n\t\t// Defense in depth: never let a Promise escape as a call result. Its\n\t\t// settlement callbacks run in the host microtask queue, where errors\n\t\t// bypass the caller's synchronous try/catch entirely.\n\t\tif (result instanceof Promise) {\n\t\t\tthrow new Error(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"Returning promises from expressions\"]));\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Handles template literal expressions.\n\t * More efficient implementation that interleaves quasis and expressions without sorting.\n\t * @private\n\t */\n\thandleTemplateLiteral(node) {\n\t\tlet result = \"\";\n\t\tconst expressionCount = node.expressions.length;\n\n\t\tfor (let i = 0; i < node.quasis.length; i++) {\n\t\t\tresult += node.quasis[i].value.raw;\n\t\t\tif (i < expressionCount) {\n\t\t\t\tresult += this.visit(node.expressions[i]);\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n}\n\n/**\n *\n * @param {import('acorn').Node} node\n * @returns\n */\nexport function getNodeString(node) {\n\tswitch (node.type) {\n\t\tcase \"Identifier\": {\n\t\t\treturn node.name;\n\t\t}\n\t\tcase \"Literal\": {\n\t\t\treturn node.raw;\n\t\t}\n\t\tcase \"ArrayExpression\": {\n\t\t\treturn `[${node.elements.map((child) => getNodeString(child)).join(\",\")}]`;\n\t\t}\n\t\tcase \"ObjectExpression\": {\n\t\t\t// if keys is empty\n\t\t\tif (node.properties.length === 0) {\n\t\t\t\treturn \"{}\";\n\t\t\t}\n\n\t\t\treturn \"{(intermediate value)}\";\n\t\t}\n\t\tcase \"MemberExpression\": {\n\t\t\tconst objectStr = getNodeString(node.object);\n\t\t\tconst propertyStr = getNodeString(node.property);\n\n\t\t\tif (node.computed) {\n\t\t\t\treturn `${objectStr}[${propertyStr}]`;\n\t\t\t}\n\t\t\treturn `${objectStr}.${propertyStr}`;\n\t\t}\n\t\tdefault: {\n\t\t\treturn null;\n\t\t}\n\t}\n}\n","/**\n * 简单状态机模板解析器\n * 能够正确处理表达式中包含字符串、转义字符和结束标记的情况\n * @class SimpleStateTemplateParser\n */\nconst DEFAULT_MAX_TEMPLATE_LENGTH = 100000;\nconst MAX_CONFIGURABLE_TEMPLATE_LENGTH = 1000000;\nconst DEFAULT_MAX_TOKENS = 1000;\nconst MAX_CONFIGURABLE_TOKENS = 10000;\n\nfunction validateLimit(value, name, defaultValue, maximum) {\n\tif (value === undefined) {\n\t\treturn defaultValue;\n\t}\n\tif (!Number.isSafeInteger(value) || value < 1 || value > maximum) {\n\t\tthrow new RangeError(`${name} must be an integer between 1 and ${maximum}`);\n\t}\n\treturn value;\n}\n\nclass TemplateParser {\n\t/**\n\t * 创建解析器实例\n\t * @param {Object} [options] - 配置选项\n\t * @param {string} [options.expressionStart='{{'] - 表达式开始标记\n\t * @param {string} [options.expressionEnd='}}'] - 表达式结束标记\n\t * @param {boolean} [options.preserveWhitespace=true] - 是否保留表达式周围的空白字符\n\t */\n\tconstructor(options = {}) {\n\t\toptions ??= {};\n\t\tthis.maxTemplateLength = validateLimit(options.maxTemplateLength, \"maxTemplateLength\", DEFAULT_MAX_TEMPLATE_LENGTH, MAX_CONFIGURABLE_TEMPLATE_LENGTH);\n\t\tthis.maxTokens = validateLimit(options.maxTokens, \"maxTokens\", DEFAULT_MAX_TOKENS, MAX_CONFIGURABLE_TOKENS);\n\t\tif (options.expressionStart !== undefined && (typeof options.expressionStart !== \"string\" || options.expressionStart.length === 0 || options.expressionStart.length > 128)) {\n\t\t\tthrow new TypeError(\"expressionStart must be a non-empty string of at most 128 characters\");\n\t\t}\n\t\tif (options.expressionEnd !== undefined && (typeof options.expressionEnd !== \"string\" || options.expressionEnd.length === 0 || options.expressionEnd.length > 128)) {\n\t\t\tthrow new TypeError(\"expressionEnd must be a non-empty string of at most 128 characters\");\n\t\t}\n\t\t// 表达式标记配置\n\t\tthis.exprStart = options.expressionStart || \"{{\";\n\t\tthis.exprEnd = options.expressionEnd || \"}}\";\n\n\t\t// 标记长度缓存,避免重复计算\n\t\tthis.startLen = this.exprStart.length;\n\t\tthis.endLen = this.exprEnd.length;\n\n\t\t// 其他配置\n\t\tthis.preserveWhitespace = options.preserveWhitespace === true;\n\t}\n\n\t/**\n\t * 解析模板字符串,将其转换为 token 数组\n\t * @param {string} template - 要解析的模板字符串\n\t * @returns {Array<{type: string, value: string}>} token 数组\n\t */\n\tparse(template) {\n\t\t// 输入验证\n\t\tif (typeof template !== \"string\") {\n\t\t\tthrow new TypeError(\"模板必须是字符串\");\n\t\t}\n\t\tif (template.length > this.maxTemplateLength) {\n\t\t\tthrow new RangeError(`Template exceeds the maximum length of ${this.maxTemplateLength} characters`);\n\t\t}\n\n\t\tconst tokens = []; // 存储解析结果的 token 数组\n\t\tconst pushToken = (token) => {\n\t\t\tif (tokens.length >= this.maxTokens) {\n\t\t\t\tthrow new RangeError(`Template exceeds the maximum token count of ${this.maxTokens}`);\n\t\t\t}\n\t\t\ttokens.push(token);\n\t\t};\n\t\tconst length = template.length;\n\n\t\t// 状态机变量\n\t\tlet state = \"TEXT\"; // 当前状态:TEXT | EXPR | STRING_SQ | STRING_DQ | TEMPLATE | ESCAPE_*\n\t\tlet buffer = \"\"; // 当前状态的字符缓冲区\n\t\tlet exprStartPos = 0; // 当前表达式的开始位置(用于错误恢复)\n\t\tlet pos = 0; // 当前扫描位置\n\n\t\t// 主解析循环:逐个字符扫描模板\n\t\twhile (pos < length) {\n\t\t\tconst char = template[pos];\n\t\t\tconst nextChar = template[pos + 1];\n\n\t\t\t// 状态机核心逻辑\n\t\t\tswitch (state) {\n\t\t\t\t// ==================== 文本状态 ====================\n\t\t\t\tcase \"TEXT\":\n\t\t\t\t\t// 检查是否遇到表达式开始标记\n\t\t\t\t\tif (this._isMatch(pos, template, this.exprStart)) {\n\t\t\t\t\t\t// 将缓冲区中的文本保存为 token\n\t\t\t\t\t\tif (buffer.length > 0) {\n\t\t\t\t\t\t\tpushToken({ type: \"text\", value: buffer, start: pos - buffer.length, end: pos });\n\t\t\t\t\t\t\tbuffer = \"\";\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// 切换到表达式状态\n\t\t\t\t\t\tstate = \"EXPR\";\n\t\t\t\t\t\texprStartPos = pos; // 记录表达式开始位置\n\t\t\t\t\t\tpos += this.startLen; // 跳过开始标记\n\t\t\t\t\t\tcontinue; // 继续处理下一个字符(跳过本次循环的剩余部分)\n\t\t\t\t\t}\n\t\t\t\t\t// 普通文本字符,添加到缓冲区\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tbreak;\n\n\t\t\t\t// ==================== 表达式状态 ====================\n\t\t\t\tcase \"EXPR\":\n\t\t\t\t\t// 在表达式中,需要处理各种字符串和转义字符\n\t\t\t\t\tif (char === \"'\") {\n\t\t\t\t\t\t// 进入单引号字符串状态\n\t\t\t\t\t\tstate = \"STRING_SQ\";\n\t\t\t\t\t} else if (char === '\"') {\n\t\t\t\t\t\t// 进入双引号字符串状态\n\t\t\t\t\t\tstate = \"STRING_DQ\";\n\t\t\t\t\t} else if (char === \"`\") {\n\t\t\t\t\t\t// 进入模板字符串状态\n\t\t\t\t\t\tstate = \"TEMPLATE\";\n\t\t\t\t\t} else if (char === \"\\\\\") {\n\t\t\t\t\t\t// 遇到转义字符,根据当前上下文进入相应的转义状态\n\t\t\t\t\t\tif (nextChar === \"'\") state = \"ESCAPE_SQ\";\n\t\t\t\t\t\telse if (nextChar === '\"') state = \"ESCAPE_DQ\";\n\t\t\t\t\t\telse if (nextChar === \"`\") state = \"ESCAPE_TEMPLATE\";\n\t\t\t\t\t\telse state = \"ESCAPE_EXPR\";\n\t\t\t\t\t} else if (this._isMatch(pos, template, this.exprEnd)) {\n\t\t\t\t\t\t// 找到表达式结束标记,且不在字符串中\n\t\t\t\t\t\tconst exprValue = this.preserveWhitespace ? buffer : buffer.trim();\n\t\t\t\t\t\tif (exprValue.length > 0) {\n\t\t\t\t\t\t\tpushToken({\n\t\t\t\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\t\t\t\tvalue: exprValue,\n\t\t\t\t\t\t\t\tstart: exprStartPos,\n\t\t\t\t\t\t\t\tend: pos + this.endLen,\n\t\t\t\t\t\t\t\tcontentStart: exprStartPos + this.startLen,\n\t\t\t\t\t\t\t\tcontentEnd: pos,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// 重置状态,准备处理后续文本\n\t\t\t\t\t\tbuffer = \"\";\n\t\t\t\t\t\tstate = \"TEXT\";\n\t\t\t\t\t\tpos += this.endLen; // 跳过结束标记\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\t// 将当前字符添加到表达式缓冲区\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tbreak;\n\n\t\t\t\t// ==================== 字符串状态 ====================\n\t\t\t\tcase \"STRING_SQ\": // 单引号字符串\n\t\t\t\t\tif (char === \"\\\\\") {\n\t\t\t\t\t\tstate = \"ESCAPE_SQ\"; // 遇到转义字符\n\t\t\t\t\t} else if (char === \"'\") {\n\t\t\t\t\t\tstate = \"EXPR\"; // 字符串结束,回到表达式状态\n\t\t\t\t\t}\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"STRING_DQ\": // 双引号字符串\n\t\t\t\t\tif (char === \"\\\\\") {\n\t\t\t\t\t\tstate = \"ESCAPE_DQ\";\n\t\t\t\t\t} else if (char === '\"') {\n\t\t\t\t\t\tstate = \"EXPR\";\n\t\t\t\t\t}\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"TEMPLATE\": // 模板字符串\n\t\t\t\t\tif (char === \"\\\\\") {\n\t\t\t\t\t\tstate = \"ESCAPE_TEMPLATE\";\n\t\t\t\t\t} else if (char === \"`\") {\n\t\t\t\t\t\tstate = \"EXPR\";\n\t\t\t\t\t}\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tbreak;\n\n\t\t\t\t// ==================== 转义状态 ====================\n\t\t\t\t// 转义状态:处理转义字符,然后返回到之前的状态\n\t\t\t\tcase \"ESCAPE_SQ\":\n\t\t\t\t\tbuffer += char; // 添加转义后的字符\n\t\t\t\t\tstate = \"STRING_SQ\"; // 回到单引号字符串状态\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"ESCAPE_DQ\":\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tstate = \"STRING_DQ\";\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"ESCAPE_TEMPLATE\":\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tstate = \"TEMPLATE\";\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"ESCAPE_EXPR\":\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tstate = \"EXPR\";\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// 移动到下一个字符\n\t\t\tpos++;\n\t\t}\n\n\t\t// ==================== 后处理 ====================\n\t\t// 处理扫描结束后缓冲区中剩余的内容\n\t\tif (buffer.length > 0) {\n\t\t\tif (state === \"TEXT\") {\n\t\t\t\t// 剩余的文本内容\n\t\t\t\tpushToken({ type: \"text\", value: buffer, start: pos - buffer.length, end: pos });\n\t\t\t} else {\n\t\t\t\t// 未完成的表达式,将其作为普通文本处理\n\t\t\t\tconst incompleteExpr = this.exprStart + buffer;\n\t\t\t\tpushToken({ type: \"text\", value: incompleteExpr, start: exprStartPos, end: pos });\n\t\t\t}\n\t\t}\n\n\t\treturn tokens;\n\t}\n\n\t/**\n\t * 检查指定位置是否匹配给定的字符序列\n\t * @param {number} pos - 开始检查的位置\n\t * @param {string} template - 模板字符串\n\t * @param {string} sequence - 要匹配的字符序列\n\t * @returns {boolean} 是否匹配\n\t * @private\n\t */\n\t_isMatch(pos, template, sequence) {\n\t\t// 检查剩余长度是否足够\n\t\tif (pos + sequence.length > template.length) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// 逐个字符比较\n\t\tfor (let i = 0; i < sequence.length; i++) {\n\t\t\tif (template[pos + i] !== sequence[i]) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * 静态方法:快速解析模板\n\t * @param {string} template - 模板字符串\n\t * @param {Object} [options] - 配置选项\n\t * @returns {Array} token 数组\n\t */\n\tstatic parse(template, options) {\n\t\tconst parser = new TemplateParser(options);\n\t\treturn parser.parse(template);\n\t}\n}\n\nexport { TemplateParser };\n","import { Evaluator } from \"./Evaluator.js\";\nimport { TemplateParser } from \"./TemplateParser.js\";\n\nexport { Evaluator, TemplateParser };\n\nconst DEFAULT_MAX_TEMPLATE_EXPRESSIONS = 100;\nconst MAX_TEMPLATE_EXPRESSIONS = 1000;\nconst DEFAULT_MAX_TEMPLATE_OUTPUT_LENGTH = 100000;\nconst MAX_TEMPLATE_OUTPUT_LENGTH = 1000000;\n\nfunction validateLimit(value, name, defaultValue, maximum) {\n\tif (value === undefined) {\n\t\treturn defaultValue;\n\t}\n\tif (!Number.isSafeInteger(value) || value < 1 || value > maximum) {\n\t\tthrow new RangeError(`${name} must be an integer between 1 and ${maximum}`);\n\t}\n\treturn value;\n}\n\n/**\n * Evaluates a JavaScript expression with an optional context.\n * @param {string} expression - The JavaScript expression to evaluate\n * @param {unknown} [context] - Optional context object with variables to use in the expression\n * @returns {*} The result of evaluating the expression\n * @example\n * evalExpression('a + b', { a: 1, b: 2 }) // returns 3\n */\nexport function evalExpression(expression, context) {\n\treturn Evaluator.evaluate(expression, context);\n}\n\n/**\n * Evaluates a template string by replacing {{ expression }} patterns with their evaluated values.\n * Undefined variables in expressions are replaced with empty strings instead of throwing errors.\n * @param {string} template - The template string containing {{ expression }} patterns\n * @param {Object} [context] - Optional context object with variables to use in expressions\n * @param {Object} [templateParserOptions] - Optional options for the template parser\n * @returns {string} The template with all expressions evaluated and replaced\n * @example\n * evalTemplate('Hello {{ name }}!', { name: 'World' }) // returns 'Hello World!'\n */\nexport function evalTemplate(template, context, templateParserOptions) {\n\tconst options = templateParserOptions ?? {};\n\tconst maxExpressions = validateLimit(options.maxExpressions, \"maxExpressions\", DEFAULT_MAX_TEMPLATE_EXPRESSIONS, MAX_TEMPLATE_EXPRESSIONS);\n\tconst maxOutputLength = validateLimit(options.maxOutputLength, \"maxOutputLength\", DEFAULT_MAX_TEMPLATE_OUTPUT_LENGTH, MAX_TEMPLATE_OUTPUT_LENGTH);\n\tconst tokens = TemplateParser.parse(template, options);\n\tlet result = \"\";\n\tlet expressionCount = 0;\n\n\t// Reuse a single Evaluator instance for every expression in the template.\n\t// `Evaluator.evaluate` builds a new instance per call, cloning the whole\n\t// context via structuredClone for each expression - wasteful when a\n\t// template contains many expressions. Reusing one instance is safe here:\n\t// evaluate() never mutates the scope chain outside its own call (arrow\n\t// function scopes are pushed and popped in a finally block), and closures\n\t// cannot escape because the cloneable-return gate rejects them.\n\tconst evaluator = new Evaluator(context, {\n\t\tmaxInputLength: options.maxExpressionLength,\n\t\tmaxEvaluationSteps: options.maxEvaluationSteps,\n\t});\n\n\tconst typeHandler = {\n\t\ttext: (token) => token.value,\n\t\texpression: (token) => {\n\t\t\ttry {\n\t\t\t\treturn evaluator.evaluate(token.value);\n\t\t\t} catch (error) {\n\t\t\t\t// Replace undefined variables with empty string for graceful degradation\n\t\t\t\tif (error instanceof ReferenceError && error.message.endsWith(\"is not defined\")) {\n\t\t\t\t\treturn \"undefined\";\n\t\t\t\t} else {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t};\n\n\tfor (const token of tokens) {\n\t\t// Unknown token type, treat as text\n\t\tconst handler = typeHandler[token.type] ?? typeHandler[\"text\"];\n\t\tif (token.type === \"expression\") {\n\t\t\texpressionCount++;\n\t\t\tif (expressionCount > maxExpressions) {\n\t\t\t\tthrow new RangeError(`Template exceeds the maximum expression count of ${maxExpressions}`);\n\t\t\t}\n\t\t}\n\n\t\tconst chunk = String(handler(token));\n\t\tif (result.length + chunk.length > maxOutputLength) {\n\t\t\tthrow new RangeError(`Template output exceeds the maximum length of ${maxOutputLength} characters`);\n\t\t}\n\t\tresult += chunk;\n\t}\n\n\treturn result;\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","mutableMethods","dangerousMethods","blockedMethods","blockedGlobalBuiltIns","ERROR_MESSAGES","DEFAULT_MAX_INPUT_LENGTH","MAX_CONFIGURABLE_INPUT_LENGTH","DEFAULT_MAX_EVALUATION_STEPS","MAX_CONFIGURABLE_EVALUATION_STEPS","MAX_ARRAY_LENGTH","MAX_BUFFER_BYTES","MAX_STRING_LENGTH","MAX_DATA_NODES","MAX_BIGINT_EXPONENT","MAX_BIGINT_BITS","TYPED_ARRAY_CONSTRUCTORS","Set","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array","constructor","NO_OBJECT","renderErrorMessage","template","context","_","String","validateLimit","value","name","defaultValue","maximum","undefined","Number","RangeError","countLiteralMatches","search","all","count","position","assertBoundedData","label","pending","seen","WeakSet","dataSize","dataNodes","enqueueProperties","object","keys","_iteratorError","descriptor","TypeError","current","_type_of","_instanceof","ArrayBuffer","Array","Map","item","BINARY_OPERATION_MAP","a","b","createGlobalScope","scope","builtin","globals","isWritable","globalThis","getBlockedMethods","BLOCKED_METHODS","map","path","_path_split","properties","_iteratorError1","Evaluator","variables","options","clonedVariables","structuredClone","evaluate","expression","SyntaxError","ast","acorn","execute","body","result","node","Error","Promise","error","visit","Constructor","args","arg","content","handleBinaryExpression","op","left","right","leftBits","rightBits","BigInt","Math","assertBoundedConstruction","_args_","size","DataView","_size_size","collectionSize","byteLength","_args_1","offset","_args_2","elementCount","_size_length","elementCount1","handleLogicalExpression","left1","left2","handleUnaryExpression","handleIdentifier","ReferenceError","handleMemberExpression","objectValue","isStaticProperty","property","Function","handleArrayExpression","i","element","_result","assertBoundedSpread","currentLength","handleObjectExpression","spreadPropertyCount","spreadValue","handleSpreadElement","handleArrowFunctionExpression","newScope","paramCount","consumeEvaluationValue","_assertBoundedData","handleCallExpression","isOptional","func","target","resultLength","length","matchCount","source","_source_size","calledString","getNodeString","handleTemplateLiteral","expressionCount","evaluator","child","objectStr","propertyStr","DEFAULT_MAX_TEMPLATE_LENGTH","MAX_CONFIGURABLE_TEMPLATE_LENGTH","DEFAULT_MAX_TOKENS","MAX_CONFIGURABLE_TOKENS","TemplateParser","parse","tokens","pushToken","token","state","buffer","exprStartPos","pos","char","nextChar","exprValue","incompleteExpr","_isMatch","sequence","parser","DEFAULT_MAX_TEMPLATE_EXPRESSIONS","MAX_TEMPLATE_EXPRESSIONS","DEFAULT_MAX_TEMPLATE_OUTPUT_LENGTH","MAX_TEMPLATE_OUTPUT_LENGTH","evalExpression","evalTemplate","templateParserOptions","maxExpressions","maxOutputLength","typeHandler","_typeHandler_token_type","handler","chunk"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,SAAS,QAAO,EAAEC,UAAU;QACnD,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,SAASI,GAAG,EAAEC,IAAI;QAAI,OAAOF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;IAAO;;;ICCtGL,oBAAoB,CAAC,GAAG,SAAS,QAAO;QACvC,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACNA,IAAMI,iBAAiB;IACtB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IAEA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IAEA;IACA;IACA;IAEA;IAEA;IAEA;IACA;IAEA;IACA;IACA;IACA;IAEA;IACA;IACA;IAEA;IACA;IACA;IAGA;IACA;IACA;IACA;IAGA;IACA;IAGA;CACA;AAED,IAAMC,mBAAmB;IACxB;IAEA;IACA;IACA;IACA;IAMA;IACA;CACA;AAGDD,eAAe,IAAI,CAAC;AAKb,IAAME,iBAAkB,qBAAGF,gBAAAA,MAAAA,CAAgB,qBAAGC;AAK9C,IAAME,wBAAwB;IACpC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAC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MAAM,OAAO,CAAC,QAAQ,CAAC,mBAC7D,OAAO;gBAEP,MAAMA;YAER;QACD;IACD;QAEK1C,4BAAAA,MAAAA,oBAAAA,OAAAA,iBAAAA;;QAAL,QAAKA,YAAesH,MAAM,CAANA,OAAAA,QAAAA,CAAAA,IAAftH,OAAAA,CAAAA,CAAAA,4BAAAA,AAAAA,CAAAA,QAAAA,UAAAA,IAAAA,EAAAA,EAAAA,IAAAA,AAAAA,GAAAA,4BAAAA,KAAuB;YAAvBA,IAAMwH,QAANxH,MAAAA,KAAAA;gBAEY8I;YAAhB,IAAMC,UAAUD,QAAAA,CAAAA,0BAAAA,WAAW,CAACtB,MAAM,IAAI,CAAC,AAAD,IAAtBsB,0BAA2BD,WAAW,CAAC,OAAO;YAC9D,IAAIrB,AAAe,iBAAfA,MAAM,IAAI,EAAmB;gBAChCb;gBACA,IAAIA,kBAAkBgC,gBACrB,MAAM,IAAI3J,WAAY,oDAAkE,OAAf2J;YAE3E;YAEA,IAAMK,QAAQxK,OAAOuK,QAAQvB;YAC7B,IAAIlF,OAAO,MAAM,GAAG0G,MAAM,MAAM,GAAGJ,iBAClC,MAAM,IAAI5J,WAAY,iDAAgE,OAAhB4J,iBAAgB;YAEvFtG,UAAU0G;QACX;;QAfKhJ,oBAAAA;QAAAA,iBAAAA;;;iBAAAA,6BAAAA,AAAAA,QAAAA,UAAAA,MAAAA,EAAAA,UAAAA,MAAAA;;gBAAAA,mB,MAAAA;;;IAiBL,OAAOsC;AACR"}
1
+ {"version":3,"file":"cjs/index.cjs","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../src/block.js","../../src/Evaluator.js","../../src/TemplateParser.js","../../src/index.js"],"sourcesContent":["__webpack_require__.d = function(exports, definition) {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }","// define __esModule on exports\n__webpack_require__.r = function(exports) {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const mutableMethods = [\n\t\"Array.prototype.push\",\n\t\"Array.prototype.pop\",\n\t\"Array.prototype.shift\",\n\t\"Array.prototype.unshift\",\n\t\"Array.prototype.splice\",\n\t\"Array.prototype.reverse\",\n\t\"Array.prototype.sort\",\n\t\"Array.prototype.fill\",\n\t\"Array.prototype.copyWithin\",\n\n\t\"Object.create\",\n\t\"Object.defineProperty\",\n\t\"Object.defineProperties\",\n\t\"Object.preventExtensions\",\n\t\"Object.seal\",\n\t\"Object.freeze\",\n\t\"Object.setPrototypeOf\",\n\t\"Object.assign\",\n\t\"Object.prototype.__defineGetter__\",\n\t\"Object.prototype.__defineSetter__\",\n\n\t\"Reflect.set\",\n\t\"Reflect.defineProperty\",\n\t\"Reflect.deleteProperty\",\n\t\"Reflect.setPrototypeOf\",\n\t\"Reflect.preventExtensions\",\n\n\t\"Set.prototype.add\",\n\t\"Set.prototype.delete\",\n\t\"Set.prototype.clear\",\n\t\"WeakSet.prototype.add\",\n\t\"WeakSet.prototype.delete\",\n\n\t\"Map.prototype.set\",\n\t\"Map.prototype.delete\",\n\t\"Map.prototype.clear\",\n\t\"WeakMap.prototype.set\",\n\t\"WeakMap.prototype.delete\",\n\n\t\"Date.prototype.setTime\",\n\t\"Date.prototype.setMilliseconds\",\n\t\"Date.prototype.setUTCSeconds\",\n\t\"Date.prototype.setSeconds\",\n\t\"Date.prototype.setMinutes\",\n\t\"Date.prototype.setHours\",\n\t\"Date.prototype.setDate\",\n\t\"Date.prototype.setMonth\",\n\t\"Date.prototype.setFullYear\",\n\t\"Date.prototype.setYear\",\n\t\"Date.prototype.setUTCMilliseconds\",\n\t\"Date.prototype.setUTCMinutes\",\n\t\"Date.prototype.setUTCHours\",\n\t\"Date.prototype.setUTCDate\",\n\t\"Date.prototype.setUTCMonth\",\n\t\"Date.prototype.setUTCFullYear\",\n\n\t\"RegExp.prototype.compile\",\n\n\t\"Int8Array.prototype.set\",\n\t\"Uint8Array.prototype.set\",\n\t\"Uint8ClampedArray.prototype.set\",\n\t\"Int16Array.prototype.set\",\n\t\"Uint16Array.prototype.set\",\n\t\"Int32Array.prototype.set\",\n\t\"Uint32Array.prototype.set\",\n\t\"Float32Array.prototype.set\",\n\t\"Float64Array.prototype.set\",\n\t\"BigInt64Array.prototype.set\",\n\t\"BigUint64Array.prototype.set\",\n\n\t\"Int8Array.prototype.fill\",\n\t\"Uint8Array.prototype.fill\",\n\t\"Uint8ClampedArray.prototype.fill\",\n\t\"Int16Array.prototype.fill\",\n\t\"Uint16Array.prototype.fill\",\n\t\"Int32Array.prototype.fill\",\n\t\"Uint32Array.prototype.fill\",\n\t\"Float32Array.prototype.fill\",\n\t\"Float64Array.prototype.fill\",\n\t\"BigInt64Array.prototype.fill\",\n\t\"BigUint64Array.prototype.fill\",\n\n\t\"Int8Array.prototype.reverse\",\n\t\"Uint8Array.prototype.reverse\",\n\t\"Uint8ClampedArray.prototype.reverse\",\n\t\"Int16Array.prototype.reverse\",\n\t\"Uint16Array.prototype.reverse\",\n\t\"Int32Array.prototype.reverse\",\n\t\"Uint32Array.prototype.reverse\",\n\t\"Float32Array.prototype.reverse\",\n\t\"Float64Array.prototype.reverse\",\n\t\"BigInt64Array.prototype.reverse\",\n\t\"BigUint64Array.prototype.reverse\",\n\n\t\"Int8Array.prototype.sort\",\n\t\"Uint8Array.prototype.sort\",\n\t\"Uint8ClampedArray.prototype.sort\",\n\t\"Int16Array.prototype.sort\",\n\t\"Uint16Array.prototype.sort\",\n\t\"Int32Array.prototype.sort\",\n\t\"Uint32Array.prototype.sort\",\n\t\"Float32Array.prototype.sort\",\n\t\"Float64Array.prototype.sort\",\n\t\"BigInt64Array.prototype.sort\",\n\t\"BigUint64Array.prototype.sort\",\n\n\t\"Int8Array.prototype.copyWithin\",\n\t\"Uint8Array.prototype.copyWithin\",\n\t\"Uint8ClampedArray.prototype.copyWithin\",\n\t\"Int16Array.prototype.copyWithin\",\n\t\"Uint16Array.prototype.copyWithin\",\n\t\"Int32Array.prototype.copyWithin\",\n\t\"Uint32Array.prototype.copyWithin\",\n\t\"Float32Array.prototype.copyWithin\",\n\t\"Float64Array.prototype.copyWithin\",\n\t\"BigInt64Array.prototype.copyWithin\",\n\t\"BigUint64Array.prototype.copyWithin\",\n\n\t\"ArrayBuffer.prototype.transfer\",\n\t\"ArrayBuffer.prototype.transferToFixedLength\",\n\n\t\"SharedArrayBuffer.prototype.grow\",\n\n\t\"DataView.prototype.setInt8\",\n\t\"DataView.prototype.setUint8\",\n\t\"DataView.prototype.setInt16\",\n\t\"DataView.prototype.setUint16\",\n\t\"DataView.prototype.setInt32\",\n\t\"DataView.prototype.setUint32\",\n\t\"DataView.prototype.setFloat32\",\n\t\"DataView.prototype.setFloat64\",\n\t\"DataView.prototype.setBigInt64\",\n\t\"DataView.prototype.setBigUint64\",\n\n\t\"Generator.prototype.next\",\n\t\"Generator.prototype.return\",\n\t\"Generator.prototype.throw\",\n\n\t\"AsyncGenerator.prototype.next\",\n\t\"AsyncGenerator.prototype.return\",\n\t\"AsyncGenerator.prototype.throw\",\n\n\t\"Iterator.prototype.next\",\n\n\t\"WeakRef.prototype.deref\",\n\n\t\"FinalizationRegistry.prototype.register\",\n\t\"FinalizationRegistry.prototype.unregister\",\n\n\t\"URLSearchParams.prototype.append\",\n\t\"URLSearchParams.prototype.delete\",\n\t\"URLSearchParams.prototype.set\",\n\t\"URLSearchParams.prototype.sort\",\n\n\t\"FormData.prototype.append\",\n\t\"FormData.prototype.delete\",\n\t\"FormData.prototype.set\",\n\n\t\"Headers.prototype.append\",\n\t\"Headers.prototype.delete\",\n\t\"Headers.prototype.set\",\n\n\t// Function call/apply/bind can be used to invoke with arbitrary `this`\n\t\"Function.prototype.call\",\n\t\"Function.prototype.apply\",\n\t\"Function.prototype.bind\",\n\t\"Function.prototype.constructor\",\n\n\t// Legacy lookup helpers\n\t\"Object.prototype.__lookupGetter__\",\n\t\"Object.prototype.__lookupSetter__\",\n\n\t// Constructor property can be abused to retrieve the Function constructor\n\t\"Object.prototype.constructor\",\n];\n\nconst dangerousMethods = [\n\t\"Object.getPrototypeOf\",\n\t// Various reflective/object-inspection APIs that may expose internals\n\t\"Object.getOwnPropertyDescriptor\",\n\t\"Object.getOwnPropertyDescriptors\",\n\t\"Object.getOwnPropertyNames\",\n\t\"Object.getOwnPropertySymbols\",\n\n\t// Error reflection: Error.captureStackTrace(obj) installs a host `stack`\n\t// property on any object - including Object.prototype - polluting the\n\t// host. Error.prepareStackTrace is a host-installed callback that, if\n\t// called with attacker-controlled Error/frames, executes host code paths.\n\t\"Error.captureStackTrace\",\n\t\"Error.prepareStackTrace\",\n];\n\n// Some prototype-style aliases/properties that can be used to break sandboxes\nmutableMethods.push(\"Object.prototype.__proto__\");\n\n/**\n * List of methods to block due to mutability or dangerousness\n */\nexport const blockedMethods = [...mutableMethods, ...dangerousMethods];\n\n/**\n * List of global built-ins to block entirely\n */\nexport const blockedGlobalBuiltIns = [\n\t\"Function\",\n\t\"GeneratorFunction\",\n\t\"AsyncFunction\",\n\t\"AsyncGeneratorFunction\",\n\t\"eval\",\n\t\"setTimeout\",\n\t\"setInterval\",\n\t\"clearTimeout\",\n\t\"clearInterval\",\n\t\"setImmediate\",\n\t\"XMLHttpRequest\",\n\t\"fetch\",\n\t\"WebSocket\",\n\t\"globalThis\",\n\n\t// Node / runtime globals\n\t\"process\",\n\t\"require\",\n\t\"module\",\n\t\"exports\",\n\t\"global\",\n\t\"Buffer\",\n\t\"setImmediate\",\n\t\"clearImmediate\",\n\n\t// Worker / threading / messaging\n\t\"importScripts\",\n\t\"Worker\",\n\t\"SharedWorker\",\n\t\"ServiceWorker\",\n\t\"BroadcastChannel\",\n\t\"MessageChannel\",\n\t\"MessagePort\",\n\t\"postMessage\",\n\n\t// Host environment globals (browser)\n\t\"window\",\n\t\"document\",\n\t\"navigator\",\n\t\"location\",\n\t\"localStorage\",\n\t\"sessionStorage\",\n\t\"indexedDB\",\n\t\"performance\",\n\n\t// Low-level / concurrent / binary APIs\n\t\"Proxy\",\n\t\"Reflect\",\n\t\"Atomics\",\n\t\"WebAssembly\",\n\t// SharedArrayBuffer escapes as a live reference to host shared memory\n\t// (structuredClone copies the handle, not the memory) and its constructor\n\t// allows multi-GiB allocations from ~20 characters of input\n\t\"SharedArrayBuffer\",\n\n\t// Asynchronous scheduling primitives that invoke callbacks in the host\n\t// runtime after evaluate() returns, escaping synchronous error handling\n\t\"queueMicrotask\",\n\t// AbortSignal.timeout() schedules a host timer whose abort listener runs\n\t// outside the interpreter; the whole global is blocked to close that hole\n\t\"AbortSignal\",\n\n\t// Promise is removed entirely. Any Promise that escapes evaluate() would\n\t// schedule its settlement callbacks in the host microtask queue, where\n\t// errors bypass the caller's synchronous try/catch and become unhandled\n\t// rejections. This single entry replaces the former per-method blocklist\n\t// (then/catch/finally/resolve/reject/all/race/any/allSettled/withResolvers).\n\t\"Promise\",\n\n\t// Console and internationalization\n\t\"console\",\n\t\"Intl\",\n\n\t// Other runtimes\n\t\"Deno\",\n];\n","import * as acorn from \"acorn\";\nimport globals from \"globals\";\nimport { blockedGlobalBuiltIns, blockedMethods } from \"./block.js\";\n\n// Error message constants for better maintainability\nconst ERROR_MESSAGES = {\n\tCAN_NOT_READ_PROPERTY: \"Cannot read property of {0} (reading '{1}')\",\n\tIS_INVALID_SYNTAX: \"{0} is not a valid syntax\",\n\tIS_NOT_FUNCTION: \"{0} is not a function\",\n\tIS_NOT_DEFINED: \"{0} is not defined\",\n\tIS_NOT_ALLOWED: \"{0} is not allowed\",\n\tEXPRESSION_TOO_LONG: \"Expression exceeds the maximum length of {0} characters\",\n};\n\n/**\n * Default maximum input length for a single expression.\n * Protects against resource exhaustion from overly long inputs.\n * Can be overridden per-instance via `new Evaluator(variables, { maxInputLength })`.\n */\nconst DEFAULT_MAX_INPUT_LENGTH = 10000;\nconst MAX_CONFIGURABLE_INPUT_LENGTH = 100000;\nconst DEFAULT_MAX_EVALUATION_STEPS = 10000;\nconst MAX_CONFIGURABLE_EVALUATION_STEPS = 100000;\nconst MAX_ARRAY_LENGTH = 10000;\nconst MAX_BUFFER_BYTES = 1000000;\nconst MAX_STRING_LENGTH = 100000;\nconst MAX_DATA_NODES = 100000;\nconst MAX_BIGINT_EXPONENT = 256n;\nconst MAX_BIGINT_BITS = 65536;\nconst DEFAULT_MAX_DEPTH = 1000;\nconst MAX_CONFIGURABLE_DEPTH = 2000;\nconst MAX_REGEXP_SOURCE_LENGTH = 1000;\nconst MAX_REGEXP_FLAGS_LENGTH = 32;\n/**\n * Builtins that must never be exposed even though the host runtime provides\n * them. They are either host-only references (WeakRef/FinalizationRegistry),\n * escaped-memory handles (SharedArrayBuffer), deprecated helpers, or reflection\n * surfaces with no legitimate expression use. Kept as an explicit exclusion\n * list on top of the allowlist below so a future V8 global cannot slip in.\n */\nconst NON_SANDBOX_GLOBALS = new Set([\"WeakRef\", \"FinalizationRegistry\", \"Iterator\", \"SharedArrayBuffer\", \"escape\", \"unescape\"]);\nconst TYPED_ARRAY_CONSTRUCTORS = new Set(\n\t[\n\t\tInt8Array,\n\t\tUint8Array,\n\t\tUint8ClampedArray,\n\t\tInt16Array,\n\t\tUint16Array,\n\t\tInt32Array,\n\t\tUint32Array,\n\t\ttypeof Float16Array === \"function\" ? Float16Array : null,\n\t\tFloat32Array,\n\t\tFloat64Array,\n\t\ttypeof BigInt64Array === \"function\" ? BigInt64Array : null,\n\t\ttypeof BigUint64Array === \"function\" ? BigUint64Array : null,\n\t].filter((constructor) => typeof constructor === \"function\")\n);\n\n/**\n * Returns whether `value` is a typed-array constructor. The explicit set is\n * the fast path; the `BYTES_PER_ELEMENT` probe also catches typed-array\n * constructors added to the host *after* this module was loaded, so a new\n * global (e.g. a future Float16Array) cannot silently escape the size bounds\n * enforced by {@link Evaluator#assertBoundedConstruction}.\n */\nfunction isTypedArrayConstructor(value) {\n\treturn TYPED_ARRAY_CONSTRUCTORS.has(value) || (typeof value === \"function\" && typeof value.BYTES_PER_ELEMENT === \"number\");\n}\n\n/**\n * Prototype mutators shared by every typed array. They are inherited from\n * `%TypedArray%.prototype`, so a `hasOwnProperty` walk over each typed-array\n * prototype never finds them - the explicit string paths in `block.js` are\n * therefore resolved here against the actual prototype functions.\n */\nconst TYPED_ARRAY_MUTATORS = (() => {\n\tconst map = new Map();\n\tfor (const constructor of TYPED_ARRAY_CONSTRUCTORS) {\n\t\tfor (const name of [\"set\", \"fill\", \"reverse\", \"sort\", \"copyWithin\"]) {\n\t\t\tconst method = constructor.prototype[name];\n\t\t\tif (typeof method === \"function\" && !map.has(method)) {\n\t\t\t\tmap.set(method, name);\n\t\t\t}\n\t\t}\n\t}\n\treturn map;\n})();\n/**\n * Sentinel used to distinguish \"caller passed no pre-evaluated object\" from\n * \"the object expression itself evaluated to undefined\". See\n * {@link Evaluator#handleMemberExpression}.\n */\nconst NO_OBJECT = Symbol(\"no-object\");\n\n/**\n * Renders an error message by replacing placeholders with context values.\n * @param {string} template\n * @param {Record<string, any>} context\n * @example\n * ```js\n * const msg = renderErrorMessage(\"Cannot call mutable prototype method: {method}\", { method: \"push\" });\n * ```\n */\nconst renderErrorMessage = (template, context = {}) => template.replace(/{(\\w+)}/g, (_, key) => String(context[key]));\n\nfunction validateLimit(value, name, defaultValue, maximum) {\n\tif (value === undefined) {\n\t\treturn defaultValue;\n\t}\n\tif (!Number.isSafeInteger(value) || value < 1 || value > maximum) {\n\t\tthrow new RangeError(`${name} must be an integer between 1 and ${maximum}`);\n\t}\n\treturn value;\n}\n\nfunction countLiteralMatches(value, search, all) {\n\tif (search === \"\") {\n\t\treturn all ? value.length + 1 : 1;\n\t}\n\tlet count = 0;\n\tlet position = 0;\n\twhile ((position = value.indexOf(search, position)) !== -1) {\n\t\tcount++;\n\t\tif (!all) {\n\t\t\tbreak;\n\t\t}\n\t\tposition += search.length;\n\t}\n\treturn count;\n}\n\nfunction assertBoundedData(value, label) {\n\tconst pending = [value];\n\tconst seen = new WeakSet();\n\tlet dataSize = 0;\n\tlet dataNodes = 0;\n\tconst enqueueProperties = (object) => {\n\t\tconst keys = Object.keys(object);\n\t\tif (pending.length + keys.length > MAX_DATA_NODES) {\n\t\t\tthrow new RangeError(`${label} exceeds the maximum data node count`);\n\t\t}\n\t\tfor (const key of keys) {\n\t\t\tdataSize += key.length;\n\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(object, key);\n\t\t\tif (!descriptor || !Object.hasOwn(descriptor, \"value\")) {\n\t\t\t\tthrow new TypeError(`${label} cannot contain accessor properties`);\n\t\t\t}\n\t\t\tpending.push(descriptor.value);\n\t\t}\n\t};\n\n\twhile (pending.length > 0) {\n\t\tconst current = pending.pop();\n\t\tdataNodes++;\n\t\tif (dataNodes > MAX_DATA_NODES) {\n\t\t\tthrow new RangeError(`${label} exceeds the maximum data node count`);\n\t\t}\n\n\t\tif (typeof current === \"string\") {\n\t\t\tif (current.length > MAX_STRING_LENGTH) {\n\t\t\t\tthrow new RangeError(`${label} contains a string that exceeds the maximum length`);\n\t\t\t}\n\t\t\tdataSize += current.length + 8;\n\t\t} else if (current === null || (typeof current !== \"object\" && typeof current !== \"function\")) {\n\t\t\tdataSize += 8;\n\t\t\tcontinue;\n\t\t} else if (typeof current === \"function\" || seen.has(current)) {\n\t\t\tcontinue;\n\t\t} else {\n\t\t\tseen.add(current);\n\t\t\tdataSize += 16;\n\t\t\tif (current instanceof ArrayBuffer || ArrayBuffer.isView(current)) {\n\t\t\t\tdataSize += current.byteLength;\n\t\t\t} else if (Array.isArray(current)) {\n\t\t\t\tif (current.length > MAX_ARRAY_LENGTH) {\n\t\t\t\t\tthrow new RangeError(`${label} contains an array that exceeds the maximum length`);\n\t\t\t\t}\n\t\t\t\tdataSize += current.length * 8;\n\t\t\t\tenqueueProperties(current);\n\t\t\t} else if (current instanceof Map) {\n\t\t\t\tif (current.size > MAX_ARRAY_LENGTH) {\n\t\t\t\t\tthrow new RangeError(`${label} contains a map that exceeds the maximum size`);\n\t\t\t\t}\n\t\t\t\tdataSize += current.size * 16;\n\t\t\t\tMap.prototype.forEach.call(current, (item, key) => pending.push(key, item));\n\t\t\t} else if (current instanceof Set) {\n\t\t\t\tif (current.size > MAX_ARRAY_LENGTH) {\n\t\t\t\t\tthrow new RangeError(`${label} contains a set that exceeds the maximum size`);\n\t\t\t\t}\n\t\t\t\tdataSize += current.size * 8;\n\t\t\t\tSet.prototype.forEach.call(current, (item) => pending.push(item));\n\t\t\t} else {\n\t\t\t\tenqueueProperties(current);\n\t\t\t}\n\t\t}\n\n\t\tif (dataSize > MAX_BUFFER_BYTES) {\n\t\t\tthrow new RangeError(`${label} exceeds the maximum data size`);\n\t\t}\n\t}\n\treturn { dataSize, dataNodes };\n}\n\nconst BINARY_OPERATION_MAP = {\n\t\"+\": (a, b) => a + b,\n\t\"-\": (a, b) => a - b,\n\t\"*\": (a, b) => a * b,\n\t\"**\": (a, b) => a ** b,\n\t\"==\": (a, b) => a == b,\n\t\"===\": (a, b) => a === b,\n\t\"!=\": (a, b) => a != b,\n\t\"!==\": (a, b) => a !== b,\n\t\">\": (a, b) => a > b,\n\t\">=\": (a, b) => a >= b,\n\t\"<\": (a, b) => a < b,\n\t\"<=\": (a, b) => a <= b,\n\t\"%\": (a, b) => a % b,\n\t\"/\": (a, b) => a / b,\n\t\"|\": (a, b) => a | b,\n\t\"&\": (a, b) => a & b,\n\t\"^\": (a, b) => a ^ b,\n\t\"<<\": (a, b) => a << b,\n\t\">>\": (a, b) => a >> b,\n\t\">>>\": (a, b) => a >>> b,\n\tin: (a, b) => a in b,\n\tinstanceof: (a, b) => a instanceof b,\n};\n\nfunction createGlobalScope() {\n\tconst scope = Object.create(null);\n\tconst { builtin } = globals;\n\n\t// Allowlist: expose a builtin only when the host actually provides it and\n\t// it is not explicitly denied. A missing global (e.g. BigInt64Array on an\n\t// old runtime, or Float16Array before it shipped) is simply skipped instead\n\t// of being defined as `undefined`, so `typeof Missing === \"undefined\"` and\n\t// identifier resolution behave as the platform does.\n\tfor (const key in builtin) {\n\t\tif (blockedGlobalBuiltIns.includes(key)) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (NON_SANDBOX_GLOBALS.has(key)) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (!Object.hasOwn(globalThis, key)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t/** @type {boolean} */\n\t\tconst isWritable = builtin[key];\n\n\t\tObject.defineProperty(scope, key, {\n\t\t\tvalue: globalThis[key],\n\t\t\twritable: isWritable,\n\t\t\tenumerable: false,\n\t\t\tconfigurable: false,\n\t\t});\n\t}\n\n\tObject.defineProperty(scope, \"globalThis\", {\n\t\tvalue: scope,\n\t\twritable: false,\n\t\tenumerable: false,\n\t\tconfigurable: false,\n\t});\n\n\treturn scope;\n}\n\n// The sandbox global scope is identical for every instance, so build it once.\n// Rebuilding it per `new Evaluator()` cost a full `defineProperty` pass over\n// every builtin (measurably ~5x slower for short-lived instances).\nconst GLOBAL_SCOPE = createGlobalScope();\n\nconst getBlockedMethods = (() => {\n\t/**\n\t * @type {Map<Function, string>}\n\t */\n\tlet BLOCKED_METHODS = null;\n\n\treturn () => {\n\t\tif (BLOCKED_METHODS) return BLOCKED_METHODS;\n\n\t\tconst map = new Map();\n\t\tfor (const path of blockedMethods) {\n\t\t\tconst [object, ...properties] = path.split(\".\");\n\t\t\tlet current = globalThis[object];\n\t\t\tfor (const prop of properties) {\n\t\t\t\tif (current && Object.hasOwn(current, prop)) {\n\t\t\t\t\tcurrent = current[prop];\n\t\t\t\t} else {\n\t\t\t\t\tcurrent = null;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (typeof current === \"function\") map.set(current, path);\n\t\t}\n\t\tBLOCKED_METHODS = map;\n\n\t\treturn BLOCKED_METHODS;\n\t};\n})();\n\n/**\n * A JavaScript expression evaluator that safely evaluates expressions within a sandboxed environment.\n * Supports various JavaScript features including arithmetic, logical operations, functions, and more.\n *\n * Security features:\n * - Blocks mutable methods to prevent side effects\n * - No access to eval() or Function() constructor\n * - Sandboxed scope with limited global objects\n *\n * @example\n * const evaluator = new Evaluator({ x: 10, y: 20 });\n * evaluator.evaluate('x + y') // returns 30\n */\nexport class Evaluator {\n\t/**\n\t * Creates a new Evaluator instance with a custom variable context.\n\t * The scope hierarchy is: user variables -> global scope\n\t * @param {Object} [variables={}] - An optional object containing variables to make available in the evaluation context\n\t * @param {Object} [options={}] - Additional configuration options\n\t * @param {number} [options.maxInputLength=10000] - Maximum expression length (hard maximum: 100000)\n\t * @param {number} [options.maxEvaluationSteps=10000] - Maximum AST node visits per evaluation (hard maximum: 100000)\n\t */\n\tconstructor(variables = Object.create(null), options) {\n\t\tthis.maxInputLength = validateLimit(options?.maxInputLength, \"maxInputLength\", DEFAULT_MAX_INPUT_LENGTH, MAX_CONFIGURABLE_INPUT_LENGTH);\n\t\tthis.maxEvaluationSteps = validateLimit(options?.maxEvaluationSteps, \"maxEvaluationSteps\", DEFAULT_MAX_EVALUATION_STEPS, MAX_CONFIGURABLE_EVALUATION_STEPS);\n\t\tthis.maxDepth = validateLimit(options?.maxDepth, \"maxDepth\", DEFAULT_MAX_DEPTH, MAX_CONFIGURABLE_DEPTH);\n\t\tassertBoundedData(variables, \"Evaluation context\");\n\t\tconst clonedVariables = structuredClone(variables);\n\t\tthis.scopes = [clonedVariables, GLOBAL_SCOPE].filter((scope) => scope !== null && scope !== undefined);\n\t\tthis.source = undefined;\n\t\tthis.remainingEvaluationSteps = 0;\n\t\tthis.remainingDataSize = MAX_BUFFER_BYTES;\n\t\tthis.remainingDataNodes = MAX_DATA_NODES;\n\t\tthis.evaluationDepth = 0;\n\t}\n\n\t/**\n\t * Evaluates a JavaScript expression with an optional context.\n\t * @param {string} expression\n\t * @param {unknown} [context]\n\t * @returns\n\t */\n\tstatic evaluate(expression, context) {\n\t\tconst evaluator = new Evaluator(context);\n\t\treturn evaluator.evaluate(expression);\n\t}\n\n\t/**\n\t * Parses and evaluates a JavaScript expression using acorn parser.\n\t * @param {string} expression - The JavaScript expression to evaluate\n\t * @returns {*} The result of the evaluation\n\t * @throws {SyntaxError} If the expression has invalid syntax\n\t * @throws {ReferenceError} If referencing undefined variables\n\t * @throws {TypeError} If performing invalid operations\n\t */\n\tevaluate(expression) {\n\t\tif (typeof expression !== \"string\") {\n\t\t\tthrow new TypeError(\"Expression must be a string\");\n\t\t}\n\n\t\tif (expression.length > this.maxInputLength) {\n\t\t\tthrow new SyntaxError(renderErrorMessage(ERROR_MESSAGES.EXPRESSION_TOO_LONG, [this.maxInputLength]));\n\t\t}\n\n\t\tthis.source = expression;\n\t\tthis.remainingEvaluationSteps = this.maxEvaluationSteps;\n\t\tthis.remainingDataSize = MAX_BUFFER_BYTES;\n\t\tthis.remainingDataNodes = MAX_DATA_NODES;\n\t\tthis.evaluationDepth = 0;\n\n\t\tlet ast;\n\t\ttry {\n\t\t\tast = acorn.parse(expression, { ecmaVersion: \"latest\" });\n\t\t} catch (error) {\n\t\t\t// acorn parses recursively; a deeply nested expression can exhaust the\n\t\t\t// host call stack before evaluation ever starts. Surface it as a\n\t\t\t// normal SyntaxError instead of leaking a stack-overflow RangeError.\n\t\t\tif (error instanceof RangeError && /call stack/i.test(error.message)) {\n\t\t\t\tthrow new SyntaxError(\"Expression nesting is too deep to parse\");\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\n\t\t// Start recursive evaluation from the root node\n\t\ttry {\n\t\t\treturn this.execute(ast.body);\n\t\t} finally {\n\t\t\tthis.source = undefined;\n\t\t}\n\t}\n\n\t/**\n\t * Executes an array of AST body nodes sequentially.\n\t * @private\n\t * @param {Array} body - Array of AST nodes to execute\n\t * @returns {*} The result of the last executed node\n\t */\n\texecute(body) {\n\t\tif (this.remainingEvaluationSteps === 0) {\n\t\t\tthis.remainingEvaluationSteps = this.maxEvaluationSteps;\n\t\t\tthis.remainingDataSize = MAX_BUFFER_BYTES;\n\t\t\tthis.remainingDataNodes = MAX_DATA_NODES;\n\t\t}\n\t\tlet result;\n\n\t\tfor (const node of body) {\n\t\t\tresult = this.visit(node);\n\t\t}\n\n\t\tif (typeof result === \"function\") {\n\t\t\tthrow new Error(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"Returning functions from expressions\"]));\n\t\t}\n\n\t\tassertBoundedData(result, \"Evaluation result\");\n\n\t\t// A leaked Promise schedules sandbox callbacks (and rejection errors)\n\t\t// in the host microtask queue, outside the caller's try/catch. Never\n\t\t// allow one to escape evaluate() as a value.\n\t\tif (result instanceof Promise) {\n\t\t\tthrow new Error(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"Returning promises from expressions\"]));\n\t\t}\n\n\t\t// Final gate: the return value must be cloneable, pure data. A\n\t\t// function (or any non-cloneable object) smuggled inside an object or\n\t\t// array - no matter how deeply nested - fails structuredClone with a\n\t\t// DataCloneError. Without this, closures could escape evaluate() (e.g.\n\t\t// `({ f: () => secret })`) and keep reading the evaluator's scopes\n\t\t// (and host-passed objects) long after evaluate() returned. Cloning\n\t\t// also hands the host a copy instead of a reference to sandbox\n\t\t// internals, and it rejects WeakRef/FinalizationRegistry/Proxy and\n\t\t// other host-only objects.\n\t\ttry {\n\t\t\treturn structuredClone(result);\n\t\t} catch (error) {\n\t\t\tif (error && error.name === \"DataCloneError\") {\n\t\t\t\tthrow new Error(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"Returning non-cloneable values from expressions\"]));\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Visits an AST node and delegates to the appropriate handler based on node type.\n\t * @private\n\t * @param {import(\"acorn\").Node} node - The AST node to visit\n\t * @returns {*} The result of visiting the node\n\t */\n\tvisit(node) {\n\t\tthis.remainingEvaluationSteps--;\n\t\tif (this.remainingEvaluationSteps < 0) {\n\t\t\tthrow new RangeError(\"Evaluation step limit exceeded\");\n\t\t}\n\n\t\t// Bound interpreter recursion depth so a deeply nested expression\n\t\t// (e.g. `[[[[...]]]]`) cannot exhaust the host call stack. The parser\n\t\t// has its own, lower practical limit, but the visitor is reached from\n\t\t// native callbacks too, so it needs an explicit ceiling.\n\t\tthis.evaluationDepth++;\n\t\tif (this.evaluationDepth > this.maxDepth) {\n\t\t\tthis.evaluationDepth--;\n\t\t\tthrow new RangeError(\"Maximum evaluation depth exceeded\");\n\t\t}\n\t\ttry {\n\t\t\treturn this.visitNode(node);\n\t\t} finally {\n\t\t\tthis.evaluationDepth--;\n\t\t}\n\t}\n\n\tvisitNode(node) {\n\t\tswitch (node.type) {\n\t\t\tcase \"ExpressionStatement\": {\n\t\t\t\treturn this.visit(node.expression);\n\t\t\t}\n\t\t\tcase \"BinaryExpression\": {\n\t\t\t\treturn this.handleBinaryExpression(node);\n\t\t\t}\n\t\t\tcase \"LogicalExpression\": {\n\t\t\t\treturn this.handleLogicalExpression(node);\n\t\t\t}\n\t\t\tcase \"UnaryExpression\": {\n\t\t\t\treturn this.handleUnaryExpression(node);\n\t\t\t}\n\t\t\tcase \"Identifier\": {\n\t\t\t\treturn this.handleIdentifier(node);\n\t\t\t}\n\t\t\tcase \"Literal\": {\n\t\t\t\treturn node.value;\n\t\t\t}\n\t\t\tcase \"MemberExpression\": {\n\t\t\t\treturn this.handleMemberExpression(node);\n\t\t\t}\n\t\t\tcase \"ArrayExpression\": {\n\t\t\t\treturn this.handleArrayExpression(node);\n\t\t\t}\n\t\t\tcase \"SpreadElement\": {\n\t\t\t\treturn this.handleSpreadElement(node);\n\t\t\t}\n\t\t\tcase \"ObjectExpression\": {\n\t\t\t\treturn this.handleObjectExpression(node);\n\t\t\t}\n\t\t\tcase \"FunctionExpression\": {\n\t\t\t\tthrow new SyntaxError(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"Function expression\"]));\n\t\t\t}\n\t\t\tcase \"ArrowFunctionExpression\": {\n\t\t\t\treturn this.handleArrowFunctionExpression(node);\n\t\t\t}\n\t\t\tcase \"CallExpression\": {\n\t\t\t\treturn this.handleCallExpression(node);\n\t\t\t}\n\t\t\tcase \"ConditionalExpression\": {\n\t\t\t\treturn this.visit(node.test) ? this.visit(node.consequent) : this.visit(node.alternate);\n\t\t\t}\n\t\t\tcase \"NewExpression\": {\n\t\t\t\tif (node.callee.type !== \"Identifier\") {\n\t\t\t\t\tthrow new Error(`Unsupported callee type '${node.callee.type}' in new expression`);\n\t\t\t\t}\n\n\t\t\t\tif (node.callee.name === \"Function\") {\n\t\t\t\t\tthrow new Error(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"new Function() constructor\"]));\n\t\t\t\t}\n\n\t\t\t\t// Promise is fully removed from the sandbox; give a clear error\n\t\t\t\t// instead of a generic \"not defined\". Its executor runs\n\t\t\t\t// synchronously, but a throwing executor would turn into a\n\t\t\t\t// rejected Promise that escapes evaluate() and crashes the host.\n\t\t\t\tif (node.callee.name === \"Promise\") {\n\t\t\t\t\tthrow new Error(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"Promise constructor\"]));\n\t\t\t\t}\n\t\t\t\tconst Constructor = this.visit(node.callee);\n\n\t\t\t\t// 仅在存在参数时构建数组\n\t\t\t\tconst args = node.arguments.length ? node.arguments.map((arg) => this.visit(arg)) : [];\n\t\t\t\tthis.assertBoundedConstruction(Constructor, args);\n\n\t\t\t\treturn new Constructor(...args);\n\t\t\t}\n\t\t\tcase \"ChainExpression\": {\n\t\t\t\treturn this.visit(node.expression);\n\t\t\t}\n\t\t\tcase \"TemplateLiteral\": {\n\t\t\t\treturn this.handleTemplateLiteral(node);\n\t\t\t}\n\t\t\tcase \"ThisExpression\": {\n\t\t\t\tthrow new SyntaxError(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"'this' expression\"]));\n\t\t\t}\n\t\t\tcase \"WithStatement\": {\n\t\t\t\tthrow new SyntaxError(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"'with' statement\"]));\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tlet content = this.source.slice(node.start, node.end);\n\n\t\t\t\tif (content.length > 20) {\n\t\t\t\t\tcontent = content.slice(0, 17) + \"...\";\n\t\t\t\t}\n\n\t\t\t\tthrow new SyntaxError(`'${content}'` + \" \" + renderErrorMessage(ERROR_MESSAGES.IS_INVALID_SYNTAX, [content]));\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Handles binary expressions (arithmetic and comparison operations).\n\t * @param {import('acorn').BinaryExpression} node\n\t * @private\n\t */\n\thandleBinaryExpression(node) {\n\t\tconst op = node.operator;\n\t\tconst left = this.visit(node.left);\n\t\tconst right = this.visit(node.right);\n\t\tif (op === \"+\" && (typeof left === \"string\" || typeof right === \"string\")) {\n\t\t\tif (String(left).length + String(right).length > MAX_STRING_LENGTH) {\n\t\t\t\tthrow new RangeError(\"String result exceeds the maximum allowed length\");\n\t\t\t}\n\t\t}\n\t\tif (typeof left === \"bigint\" && typeof right === \"bigint\") {\n\t\t\tif (op === \"**\" && (right > MAX_BIGINT_EXPONENT || right < 0n)) {\n\t\t\t\tthrow new RangeError(`BigInt exponent must be between 0 and ${MAX_BIGINT_EXPONENT}`);\n\t\t\t}\n\t\t\tconst leftBits = left.toString(2).length;\n\t\t\tconst rightBits = right.toString(2).length;\n\t\t\tif (\n\t\t\t\t(op === \"**\" && leftBits * Number(right) > MAX_BIGINT_BITS) ||\n\t\t\t\t(op === \"<<\" && right > BigInt(MAX_BIGINT_BITS)) ||\n\t\t\t\t(op === \"<<\" && right >= 0n && leftBits + Number(right) > MAX_BIGINT_BITS) ||\n\t\t\t\t(op === \"*\" && leftBits + rightBits > MAX_BIGINT_BITS) ||\n\t\t\t\t((op === \"+\" || op === \"-\") && Math.max(leftBits, rightBits) + 1 > MAX_BIGINT_BITS)\n\t\t\t) {\n\t\t\t\tthrow new RangeError(\"BigInt result exceeds the maximum allowed size\");\n\t\t\t}\n\t\t}\n\n\t\tif (BINARY_OPERATION_MAP.hasOwnProperty(op)) {\n\t\t\treturn BINARY_OPERATION_MAP[op](left, right);\n\t\t}\n\n\t\tthrow new SyntaxError(`Unsupported operator: ${node.operator}`);\n\t}\n\n\t/**\n\t * Bounds a regular-expression pattern. There is no execution-time limit on\n\t * a native RegExp, so an oversized source/flags string is rejected up front\n\t * rather than allowed to build a pathological matcher.\n\t * @private\n\t */\n\tassertBoundedRegExp(args) {\n\t\tif (typeof args[0] === \"string\" && args[0].length > MAX_REGEXP_SOURCE_LENGTH) {\n\t\t\tthrow new RangeError(\"RegExp source exceeds the maximum allowed length\");\n\t\t}\n\t\tif (typeof args[1] === \"string\" && args[1].length > MAX_REGEXP_FLAGS_LENGTH) {\n\t\t\tthrow new RangeError(\"RegExp flags exceed the maximum allowed length\");\n\t\t}\n\t}\n\n\tassertBoundedConstruction(Constructor, args) {\n\t\tif (Constructor === RegExp) {\n\t\t\tthis.assertBoundedRegExp(args);\n\t\t}\n\t\tconst size = args[0];\n\t\tif (Constructor === Array && args.length === 1 && typeof size === \"number\" && size > MAX_ARRAY_LENGTH) {\n\t\t\tthrow new RangeError(\"Array length exceeds the maximum allowed length\");\n\t\t}\n\t\tif (Constructor === ArrayBuffer && (size > MAX_BUFFER_BYTES || args[1]?.maxByteLength > MAX_BUFFER_BYTES)) {\n\t\t\tthrow new RangeError(\"ArrayBuffer size exceeds the maximum allowed size\");\n\t\t}\n\t\tif (Constructor === DataView && size instanceof ArrayBuffer && size.byteLength > MAX_BUFFER_BYTES) {\n\t\t\tthrow new RangeError(\"DataView size exceeds the maximum allowed size\");\n\t\t}\n\t\tif (Constructor === Map || Constructor === Set) {\n\t\t\tconst collectionSize = typeof size === \"string\" || Array.isArray(size) ? size.length : size?.size ?? size?.length;\n\t\t\tif (typeof collectionSize === \"number\" && collectionSize > MAX_ARRAY_LENGTH) {\n\t\t\t\tthrow new RangeError(\"Collection source exceeds the maximum allowed size\");\n\t\t\t}\n\t\t}\n\t\tif (isTypedArrayConstructor(Constructor)) {\n\t\t\tlet byteLength;\n\t\t\tif (size instanceof ArrayBuffer) {\n\t\t\t\tconst offset = args[1] ?? 0;\n\t\t\t\tconst elementCount = args[2] ?? Math.floor((size.byteLength - offset) / Constructor.BYTES_PER_ELEMENT);\n\t\t\t\tbyteLength = elementCount * Constructor.BYTES_PER_ELEMENT;\n\t\t\t} else {\n\t\t\t\tconst elementCount = typeof size === \"number\" ? size : size?.length ?? 0;\n\t\t\t\tbyteLength = elementCount * Constructor.BYTES_PER_ELEMENT;\n\t\t\t}\n\t\t\tif (byteLength > MAX_BUFFER_BYTES) {\n\t\t\t\tthrow new RangeError(\"Typed array size exceeds the maximum allowed size\");\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Handles logical expressions (&&, ||, ??).\n\t * Implements proper short-circuit evaluation for performance.\n\t * @private\n\t */\n\thandleLogicalExpression(node) {\n\t\tswitch (node.operator) {\n\t\t\tcase \"&&\": {\n\t\t\t\tconst left = this.visit(node.left);\n\t\t\t\treturn left ? this.visit(node.right) : left;\n\t\t\t}\n\t\t\tcase \"||\": {\n\t\t\t\tconst left = this.visit(node.left);\n\t\t\t\treturn left ? left : this.visit(node.right);\n\t\t\t}\n\t\t\tcase \"??\": {\n\t\t\t\tconst left = this.visit(node.left);\n\t\t\t\treturn left !== null && left !== undefined ? left : this.visit(node.right);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new SyntaxError(`Unsupported logical operator: ${node.operator}`);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Handles unary expressions (-, +, !, ~, typeof, void).\n\t * @private\n\t */\n\thandleUnaryExpression(node) {\n\t\tswitch (node.operator) {\n\t\t\tcase \"-\": {\n\t\t\t\treturn -this.visit(node.argument);\n\t\t\t}\n\t\t\tcase \"+\": {\n\t\t\t\treturn +this.visit(node.argument);\n\t\t\t}\n\t\t\tcase \"!\": {\n\t\t\t\treturn !this.visit(node.argument);\n\t\t\t}\n\t\t\tcase \"~\": {\n\t\t\t\treturn ~this.visit(node.argument);\n\t\t\t}\n\t\t\tcase \"typeof\": {\n\t\t\t\treturn typeof this.visit(node.argument);\n\t\t\t}\n\t\t\tcase \"void\": {\n\t\t\t\treturn void this.visit(node.argument);\n\t\t\t}\n\t\t\tcase \"delete\": {\n\t\t\t\tthrow new SyntaxError(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"Delete operator\"]));\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new SyntaxError(`Unsupported unary operator: ${node.operator}`);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Handles identifier (variable) lookups in the scope chain.\n\t * @private\n\t */\n\thandleIdentifier(node) {\n\t\tconst name = node.name;\n\t\tfor (const scope of this.scopes) {\n\t\t\tif (Object.hasOwn(scope, name)) {\n\t\t\t\treturn scope[name];\n\t\t\t}\n\t\t}\n\n\t\tthrow new ReferenceError(renderErrorMessage(ERROR_MESSAGES.IS_NOT_DEFINED, [name]));\n\t}\n\n\t/**\n\t * Handles member expressions (property access like obj.prop or obj[prop]).\n\t * @private\n\t */\n\thandleMemberExpression(node, objectValue = NO_OBJECT) {\n\t\tconst object = objectValue === NO_OBJECT ? this.visit(node.object) : objectValue;\n\t\t// Determine property name: either identifier name or computed value\n\t\tconst isStaticProperty = node.property.type === \"Identifier\" && !node.computed;\n\t\tconst property = isStaticProperty ? node.property.name : this.visit(node.property);\n\n\t\t// Reading `.stack` on an Error instance forces V8 to materialize the\n\t\t// stack, which invokes a host-installed Error.prepareStackTrace with\n\t\t// sandbox-owned values. Block it *before* any property access, since\n\t\t// even the prototype check below would trigger the getter.\n\t\tif (property === \"stack\" && object instanceof Error) {\n\t\t\tthrow new Error(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"Accessing error stack\"]));\n\t\t}\n\n\t\t// Prevent access to prototype properties. The comparison must be guarded\n\t\t// against a null/undefined prototype: for a null-prototype object\n\t\t// (`Object.create(null)`) `object[property]` and `object.__proto__` are\n\t\t// both `undefined`, and `undefined === undefined` would otherwise reject\n\t\t// every missing property with a misleading \"prototype\" error.\n\t\tif (typeof object !== \"undefined\" && object !== null && object.__proto__ !== undefined && object[property] === object.__proto__) {\n\t\t\tthrow new Error(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"Accessing prototype properties\"]));\n\t\t}\n\n\t\tif (object === null || object === undefined) {\n\t\t\t// optional chaining\n\t\t\tif (node.optional) {\n\t\t\t\treturn void 0;\n\t\t\t}\n\t\t\tthrow new TypeError(renderErrorMessage(ERROR_MESSAGES.CAN_NOT_READ_PROPERTY, [object, property]));\n\t\t}\n\n\t\tconst result = object[property];\n\n\t\t// The Function constructor must never be reachable from an expression.\n\t\t// If it escapes as a value, native callbacks (e.g. Promise.then,\n\t\t// Array.prototype.map) invoke it outside the interpreter's call path,\n\t\t// enabling arbitrary host code execution. This is a structural guard:\n\t\t// no matter how many `.constructor` hops an expression takes, the\n\t\t// final value can never be `Function` (or its prototype).\n\t\tif (result === Function || result === Function.prototype) {\n\t\t\tthrow new Error(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"Function constructor\"]));\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Handles array literal expressions.\n\t * @private\n\t */\n\thandleArrayExpression(node) {\n\t\tconst result = [];\n\n\t\tfor (let i = 0; i < node.elements.length; i++) {\n\t\t\tconst element = node.elements.at(i);\n\n\t\t\t// Array holes (`[1, , 3]`) are represented as null elements by\n\t\t\t// acorn. Preserve them instead of crashing on node.type access.\n\t\t\tif (element === null) {\n\t\t\t\tresult.length++;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst value = this.visit(element);\n\n\t\t\tif (element.type === \"SpreadElement\") {\n\t\t\t\tthis.assertBoundedSpread(result.length, value);\n\t\t\t\tresult.push(...value);\n\t\t\t} else {\n\t\t\t\tresult.push(value);\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tassertBoundedSpread(currentLength, value) {\n\t\tconst size = typeof value === \"string\" || Array.isArray(value) ? value.length : value?.size;\n\t\tif (typeof size === \"number\" && currentLength + size > MAX_ARRAY_LENGTH) {\n\t\t\tthrow new RangeError(\"Spread value exceeds the maximum allowed length\");\n\t\t}\n\t}\n\n\t/**\n\t * Handles object literal expressions.\n\t * @returns\n\t */\n\thandleObjectExpression(node) {\n\t\tconst obj = {};\n\t\tlet spreadPropertyCount = 0;\n\t\tfor (const prop of node.properties) {\n\t\t\tif (prop.type === \"SpreadElement\") {\n\t\t\t\tconst spreadValue = this.visit(prop.argument);\n\t\t\t\tspreadPropertyCount += Object.keys(spreadValue).length;\n\t\t\t\tif (spreadPropertyCount > MAX_ARRAY_LENGTH) {\n\t\t\t\t\tthrow new RangeError(\"Object spread exceeds the maximum allowed property count\");\n\t\t\t\t}\n\t\t\t\tObject.assign(obj, spreadValue);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// Computed keys must be *evaluated* (`{ [1 + 1]: v }` -> key \"2\"),\n\t\t\t// not taken from the property name. Non-computed keys keep the\n\t\t\t// literal `__proto__: v` semantics (which sets the prototype via\n\t\t\t// the Object.prototype.__proto__ setter), while computed keys are\n\t\t\t// plain properties: `{ [\"__proto__\"]: v }` must NOT touch the\n\t\t\t// prototype.\n\t\t\tconst key = prop.computed ? this.visit(prop.key) : prop.key.name || prop.key.value;\n\t\t\tconst value = this.visit(prop.value);\n\t\t\tif (prop.computed) {\n\t\t\t\tObject.defineProperty(obj, key, { value, writable: true, enumerable: true, configurable: true });\n\t\t\t} else {\n\t\t\t\tobj[key] = value;\n\t\t\t}\n\t\t}\n\t\treturn obj;\n\t}\n\n\thandleSpreadElement(node) {\n\t\treturn this.visit(node.argument);\n\t}\n\n\t/**\n\t * Handles arrow function expressions.\n\t * Creates a closure that captures the current scope and executes the function body\n\t * with parameters bound to a new scope.\n\t * @private\n\t */\n\thandleArrowFunctionExpression(node) {\n\t\treturn (...args) => {\n\t\t\t// Create new scope with parameters bound to arguments\n\t\t\tconst newScope = {};\n\t\t\tconst paramCount = node.params.length;\n\t\t\tfor (let i = 0; i < paramCount; i++) {\n\t\t\t\tnewScope[node.params[i].name] = args[i];\n\t\t\t}\n\n\t\t\t// Push new scope, evaluate body, then pop scope. The scope must be\n\t\t\t// popped even when the body throws: a leaked scope would make the\n\t\t\t// parameter bindings visible to subsequent evaluations on the same\n\t\t\t// instance.\n\t\t\tthis.scopes.unshift(newScope);\n\t\t\ttry {\n\t\t\t\tconst result = this.visit(node.body);\n\t\t\t\tthis.consumeEvaluationValue(result);\n\t\t\t\treturn result;\n\t\t\t} finally {\n\t\t\t\tthis.scopes.shift();\n\t\t\t}\n\t\t};\n\t}\n\n\tconsumeEvaluationValue(value) {\n\t\tconst { dataSize, dataNodes } = assertBoundedData(value, \"Intermediate evaluation result\");\n\t\tthis.remainingDataSize -= dataSize;\n\t\tthis.remainingDataNodes -= dataNodes;\n\t\tif (this.remainingDataSize < 0 || this.remainingDataNodes < 0) {\n\t\t\tthrow new RangeError(\"Evaluation allocation budget exceeded\");\n\t\t}\n\t}\n\n\t/**\n\t * Handles function call expressions, including optional chaining.\n\t * @private\n\t */\n\thandleCallExpression(node) {\n\t\tconst isOptional = node.optional || (node.callee.type === \"MemberExpression\" && node.callee.optional);\n\t\tlet func;\n\t\tlet target = null;\n\n\t\tif (node.callee.type === \"MemberExpression\") {\n\t\t\t// Evaluate the object expression exactly once, then resolve the\n\t\t\t// property through handleMemberExpression so that all of its\n\t\t\t// guards (.stack access, prototype access, Function constructor)\n\t\t\t// still apply. Visiting the whole callee and then the object again\n\t\t\t// would double-evaluate side-effecting expressions such as\n\t\t\t// `new Date(1000).getTime()` or `f().g()`.\n\t\t\ttarget = this.visit(node.callee.object);\n\t\t\tfunc = this.handleMemberExpression(node.callee, target);\n\t\t} else {\n\t\t\tfunc = this.visit(node.callee);\n\t\t}\n\n\t\tif ((func === undefined || func === null) && isOptional) {\n\t\t\treturn void 0;\n\t\t}\n\n\t\tif (func === Function) {\n\t\t\tthrow new Error(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"Function constructor\"]));\n\t\t}\n\t\t// Error.prepareStackTrace is a host-installed callback. It must be\n\t\t// checked dynamically: the blocked-methods map is built lazily on first\n\t\t// use, so a host that installs the callback *after* that point would\n\t\t// otherwise evade the static blocklist.\n\t\tif (func === Error.prepareStackTrace) {\n\t\t\tthrow new Error(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"Error.prepareStackTrace\"]));\n\t\t}\n\n\t\tif (getBlockedMethods().has(func)) {\n\t\t\tconst path = getBlockedMethods().get(func);\n\t\t\tthrow new Error(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [path]));\n\t\t}\n\t\t// Typed-array mutators live on `%TypedArray%.prototype`, which the\n\t\t// own-property walk in `getBlockedMethods` never reaches, so resolve\n\t\t// them against the real prototype functions here.\n\t\tif (TYPED_ARRAY_MUTATORS.has(func)) {\n\t\t\tthrow new Error(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [`TypedArray.prototype.${TYPED_ARRAY_MUTATORS.get(func)}`]));\n\t\t}\n\n\t\t// 仅在存在参数时构建数组\n\t\tconst args = (() => {\n\t\t\tif (node.arguments.length === 0) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tlet result = [];\n\n\t\t\tfor (let i = 0; i < node.arguments.length; i++) {\n\t\t\t\tconst element = node.arguments.at(i);\n\t\t\t\tconst value = this.visit(element);\n\n\t\t\t\tif (element.type === \"SpreadElement\") {\n\t\t\t\t\tthis.assertBoundedSpread(result.length, value);\n\t\t\t\t\tresult.push(...value);\n\t\t\t\t} else {\n\t\t\t\t\tresult.push(value);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn result;\n\t\t})();\n\n\t\t// Defense in depth: even if a `Function` reference were somehow\n\t\t// produced by an expression, it must not be passed as an argument.\n\t\t// Native methods (Promise.then, Array.prototype.map, ...) would\n\t\t// invoke it in the host runtime, outside this interpreter's checks.\n\t\tif (args.some((arg) => arg === Function)) {\n\t\t\tthrow new Error(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"Function constructor\"]));\n\t\t}\n\t\tif (typeof target === \"string\") {\n\t\t\tif (String.prototype.repeat && func === String.prototype.repeat && target.length * Number(args[0]) > MAX_STRING_LENGTH) {\n\t\t\t\tthrow new RangeError(\"String result exceeds the maximum allowed length\");\n\t\t\t}\n\t\t\tif ((String.prototype.padStart && func === String.prototype.padStart || func === String.prototype.padEnd) && Number(args[0]) > MAX_STRING_LENGTH) {\n\t\t\t\tthrow new RangeError(\"String result exceeds the maximum allowed length\");\n\t\t\t}\n\t\t\tif (String.prototype.concat && func === String.prototype.concat) {\n\t\t\t\tconst resultLength = target.length + args.reduce((length, value) => length + String(value).length, 0);\n\t\t\t\tif (resultLength > MAX_STRING_LENGTH) {\n\t\t\t\t\tthrow new RangeError(\"String result exceeds the maximum allowed length\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ((String.prototype.replace && func === String.prototype.replace) || (String.prototype.replaceAll && func === String.prototype.replaceAll)) {\n\t\t\t\tif (typeof args[0] === \"string\") {\n\t\t\t\t\tif (typeof args[1] === \"function\" || (typeof args[1] === \"string\" && /\\$(?:[$&'`])/u.test(args[1]))) {\n\t\t\t\t\t\tthrow new Error(\"Only literal string replacements are allowed\");\n\t\t\t\t\t}\n\t\t\t\t\tif (target.length * Math.max(1, args[0].length) > 10000000) {\n\t\t\t\t\t\tthrow new RangeError(\"String operation exceeds the maximum work limit\");\n\t\t\t\t\t}\n\t\t\t\t\tconst matchCount = countLiteralMatches(target, args[0], func === String.prototype.replaceAll);\n\t\t\t\t\tif (target.length + matchCount * String(args[1]).length > MAX_STRING_LENGTH) {\n\t\t\t\t\t\tthrow new RangeError(\"String result exceeds the maximum allowed length\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (func === String.prototype.split) {\n\t\t\t\tif (args[0] === \"\" && target.length > MAX_ARRAY_LENGTH) {\n\t\t\t\t\tthrow new RangeError(\"Split result exceeds the maximum allowed length\");\n\t\t\t\t}\n\t\t\t\tif (typeof args[0] === \"string\" && args[0] !== \"\" && countLiteralMatches(target, args[0], true) >= MAX_ARRAY_LENGTH) {\n\t\t\t\t\tthrow new RangeError(\"Split result exceeds the maximum allowed length\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (func === RegExp) {\n\t\t\tthis.assertBoundedRegExp(args);\n\t\t}\n\t\tif ((target === Array || isTypedArrayConstructor(target)) && func === target.from) {\n\t\t\tconst source = args[0];\n\t\t\tconst size = typeof source === \"string\" || Array.isArray(source) ? source.length : source?.size ?? source?.length;\n\t\t\tif (typeof size === \"number\" && size > MAX_ARRAY_LENGTH) {\n\t\t\t\tthrow new RangeError(\"Array.from source exceeds the maximum allowed length\");\n\t\t\t}\n\t\t}\n\n\t\tif (typeof func !== \"function\") {\n\t\t\tconst calledString = getNodeString(node.callee);\n\t\t\tthrow new TypeError(renderErrorMessage(ERROR_MESSAGES.IS_NOT_FUNCTION, [calledString]));\n\t\t}\n\n\t\tconst result = func.apply(target, args);\n\n\t\t// Defense in depth: never let a Promise escape as a call result. Its\n\t\t// settlement callbacks run in the host microtask queue, where errors\n\t\t// bypass the caller's synchronous try/catch entirely.\n\t\tif (result instanceof Promise) {\n\t\t\tthrow new Error(renderErrorMessage(ERROR_MESSAGES.IS_NOT_ALLOWED, [\"Returning promises from expressions\"]));\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Handles template literal expressions.\n\t * More efficient implementation that interleaves quasis and expressions without sorting.\n\t * @private\n\t */\n\thandleTemplateLiteral(node) {\n\t\tlet result = \"\";\n\t\tconst expressionCount = node.expressions.length;\n\n\t\tfor (let i = 0; i < node.quasis.length; i++) {\n\t\t\tresult += node.quasis[i].value.raw;\n\t\t\tif (i < expressionCount) {\n\t\t\t\tresult += this.visit(node.expressions[i]);\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n}\n\n/**\n *\n * @param {import('acorn').Node} node\n * @returns\n */\nexport function getNodeString(node) {\n\tswitch (node.type) {\n\t\tcase \"Identifier\": {\n\t\t\treturn node.name;\n\t\t}\n\t\tcase \"Literal\": {\n\t\t\treturn node.raw;\n\t\t}\n\t\tcase \"ArrayExpression\": {\n\t\t\treturn `[${node.elements.map((child) => (child === null ? \"\" : getNodeString(child))).join(\",\")}]`;\n\t\t}\n\t\tcase \"ObjectExpression\": {\n\t\t\t// if keys is empty\n\t\t\tif (node.properties.length === 0) {\n\t\t\t\treturn \"{}\";\n\t\t\t}\n\n\t\t\treturn \"{(intermediate value)}\";\n\t\t}\n\t\tcase \"MemberExpression\": {\n\t\t\tconst objectStr = getNodeString(node.object);\n\t\t\tconst propertyStr = getNodeString(node.property);\n\n\t\t\tif (node.computed) {\n\t\t\t\treturn `${objectStr}[${propertyStr}]`;\n\t\t\t}\n\t\t\treturn `${objectStr}.${propertyStr}`;\n\t\t}\n\t\tdefault: {\n\t\t\treturn null;\n\t\t}\n\t}\n}\n","/**\n * 简单状态机模板解析器\n * 能够正确处理表达式中包含字符串、转义字符和结束标记的情况\n * @class SimpleStateTemplateParser\n */\nconst DEFAULT_MAX_TEMPLATE_LENGTH = 100000;\nconst MAX_CONFIGURABLE_TEMPLATE_LENGTH = 1000000;\nconst DEFAULT_MAX_TOKENS = 1000;\nconst MAX_CONFIGURABLE_TOKENS = 10000;\n\nfunction validateLimit(value, name, defaultValue, maximum) {\n\tif (value === undefined) {\n\t\treturn defaultValue;\n\t}\n\tif (!Number.isSafeInteger(value) || value < 1 || value > maximum) {\n\t\tthrow new RangeError(`${name} must be an integer between 1 and ${maximum}`);\n\t}\n\treturn value;\n}\n\nclass TemplateParser {\n\t/**\n\t * 创建解析器实例\n\t * @param {Object} [options] - 配置选项\n\t * @param {string} [options.expressionStart='{{'] - 表达式开始标记\n\t * @param {string} [options.expressionEnd='}}'] - 表达式结束标记\n\t * @param {boolean} [options.preserveWhitespace=true] - 是否保留表达式周围的空白字符\n\t */\n\tconstructor(options = {}) {\n\t\toptions ??= {};\n\t\tthis.maxTemplateLength = validateLimit(options.maxTemplateLength, \"maxTemplateLength\", DEFAULT_MAX_TEMPLATE_LENGTH, MAX_CONFIGURABLE_TEMPLATE_LENGTH);\n\t\tthis.maxTokens = validateLimit(options.maxTokens, \"maxTokens\", DEFAULT_MAX_TOKENS, MAX_CONFIGURABLE_TOKENS);\n\t\tif (options.expressionStart !== undefined && (typeof options.expressionStart !== \"string\" || options.expressionStart.length === 0 || options.expressionStart.length > 128)) {\n\t\t\tthrow new TypeError(\"expressionStart must be a non-empty string of at most 128 characters\");\n\t\t}\n\t\tif (options.expressionEnd !== undefined && (typeof options.expressionEnd !== \"string\" || options.expressionEnd.length === 0 || options.expressionEnd.length > 128)) {\n\t\t\tthrow new TypeError(\"expressionEnd must be a non-empty string of at most 128 characters\");\n\t\t}\n\t\t// 表达式标记配置\n\t\tthis.exprStart = options.expressionStart || \"{{\";\n\t\tthis.exprEnd = options.expressionEnd || \"}}\";\n\n\t\t// 标记长度缓存,避免重复计算\n\t\tthis.startLen = this.exprStart.length;\n\t\tthis.endLen = this.exprEnd.length;\n\n\t\t// 其他配置\n\t\tthis.preserveWhitespace = options.preserveWhitespace === true;\n\t}\n\n\t/**\n\t * 解析模板字符串,将其转换为 token 数组\n\t * @param {string} template - 要解析的模板字符串\n\t * @returns {Array<{type: string, value: string}>} token 数组\n\t */\n\tparse(template) {\n\t\t// 输入验证\n\t\tif (typeof template !== \"string\") {\n\t\t\tthrow new TypeError(\"模板必须是字符串\");\n\t\t}\n\t\tif (template.length > this.maxTemplateLength) {\n\t\t\tthrow new RangeError(`Template exceeds the maximum length of ${this.maxTemplateLength} characters`);\n\t\t}\n\n\t\tconst tokens = []; // 存储解析结果的 token 数组\n\t\tconst pushToken = (token) => {\n\t\t\tif (tokens.length >= this.maxTokens) {\n\t\t\t\tthrow new RangeError(`Template exceeds the maximum token count of ${this.maxTokens}`);\n\t\t\t}\n\t\t\ttokens.push(token);\n\t\t};\n\t\tconst length = template.length;\n\n\t\t// 状态机变量\n\t\tlet state = \"TEXT\"; // 当前状态:TEXT | EXPR | STRING_SQ | STRING_DQ | TEMPLATE | REGEX | REGEX_CLASS | ESCAPE_*\n\t\tlet buffer = \"\"; // 当前状态的字符缓冲区\n\t\tlet exprStartPos = 0; // 当前表达式的开始位置(用于错误恢复)\n\t\tlet pos = 0; // 当前扫描位置\n\t\t// 上一次有意义的表达式字符,用于区分正则字面量的 `/` 与除号 `/`\n\t\tlet prevExprChar = \"\";\n\n\t\t// 主解析循环:逐个字符扫描模板\n\t\twhile (pos < length) {\n\t\t\tconst char = template[pos];\n\t\t\tconst nextChar = template[pos + 1];\n\n\t\t\t// 状态机核心逻辑\n\t\t\tswitch (state) {\n\t\t\t\t// ==================== 文本状态 ====================\n\t\t\t\tcase \"TEXT\":\n\t\t\t\t\t// 检查是否遇到表达式开始标记\n\t\t\t\t\tif (this._isMatch(pos, template, this.exprStart)) {\n\t\t\t\t\t\t// 将缓冲区中的文本保存为 token\n\t\t\t\t\t\tif (buffer.length > 0) {\n\t\t\t\t\t\t\tpushToken({ type: \"text\", value: buffer, start: pos - buffer.length, end: pos });\n\t\t\t\t\t\t\tbuffer = \"\";\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// 切换到表达式状态\n\t\t\t\t\t\tstate = \"EXPR\";\n\t\t\t\t\t\texprStartPos = pos; // 记录表达式开始位置\n\t\t\t\t\t\tprevExprChar = \"\"; // 每个表达式独立判断正则/除号上下文\n\t\t\t\t\t\tpos += this.startLen; // 跳过开始标记\n\t\t\t\t\t\tcontinue; // 继续处理下一个字符(跳过本次循环的剩余部分)\n\t\t\t\t\t}\n\t\t\t\t\t// 普通文本字符,添加到缓冲区\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tbreak;\n\n\t\t\t\t// ==================== 表达式状态 ====================\n\t\t\t\tcase \"EXPR\":\n\t\t\t\t\t// 在表达式中,需要处理各种字符串和转义字符\n\t\t\t\t\tif (char === \"'\") {\n\t\t\t\t\t\t// 进入单引号字符串状态\n\t\t\t\t\t\tstate = \"STRING_SQ\";\n\t\t\t\t\t} else if (char === '\"') {\n\t\t\t\t\t\t// 进入双引号字符串状态\n\t\t\t\t\t\tstate = \"STRING_DQ\";\n\t\t\t\t\t} else if (char === \"`\") {\n\t\t\t\t\t\t// 进入模板字符串状态\n\t\t\t\t\t\tstate = \"TEMPLATE\";\n\t\t\t\t\t} else if (char === \"/\" && this._isRegexPosition(prevExprChar)) {\n\t\t\t\t\t\t// A `/` in expression position starts a regex literal, which may\n\t\t\t\t\t\t// itself contain the closing delimiter (e.g. `/}}/`). Track it so\n\t\t\t\t\t\t// the delimiter inside the pattern is not mistaken for the end of\n\t\t\t\t\t\t// the expression.\n\t\t\t\t\t\tstate = \"REGEX\";\n\t\t\t\t\t} else if (char === \"\\\\\") {\n\t\t\t\t\t\t// 遇到转义字符,根据当前上下文进入相应的转义状态\n\t\t\t\t\t\tif (nextChar === \"'\") state = \"ESCAPE_SQ\";\n\t\t\t\t\t\telse if (nextChar === '\"') state = \"ESCAPE_DQ\";\n\t\t\t\t\t\telse if (nextChar === \"`\") state = \"ESCAPE_TEMPLATE\";\n\t\t\t\t\t\telse state = \"ESCAPE_EXPR\";\n\t\t\t\t\t} else if (this._isMatch(pos, template, this.exprEnd)) {\n\t\t\t\t\t\t// 找到表达式结束标记,且不在字符串中\n\t\t\t\t\t\tconst exprValue = this.preserveWhitespace ? buffer : buffer.trim();\n\t\t\t\t\t\tif (exprValue.length > 0) {\n\t\t\t\t\t\t\tpushToken({\n\t\t\t\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\t\t\t\tvalue: exprValue,\n\t\t\t\t\t\t\t\tstart: exprStartPos,\n\t\t\t\t\t\t\t\tend: pos + this.endLen,\n\t\t\t\t\t\t\t\tcontentStart: exprStartPos + this.startLen,\n\t\t\t\t\t\t\t\tcontentEnd: pos,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// 重置状态,准备处理后续文本\n\t\t\t\t\t\tbuffer = \"\";\n\t\t\t\t\t\tstate = \"TEXT\";\n\t\t\t\t\t\tpos += this.endLen; // 跳过结束标记\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\t// 将当前字符添加到表达式缓冲区。空白字符不更新 prevExprChar,\n\t\t\t\t\t// 这样 `{{ /re/ }}` 中前导空格不会让 `/` 被误判为除号。\n\t\t\t\t\tif (!/\\s/u.test(char)) {\n\t\t\t\t\t\tprevExprChar = char;\n\t\t\t\t\t}\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tbreak;\n\n\t\t\t\t// ==================== 字符串状态 ====================\n\t\t\t\tcase \"STRING_SQ\": // 单引号字符串\n\t\t\t\t\tif (char === \"\\\\\") {\n\t\t\t\t\t\tstate = \"ESCAPE_SQ\"; // 遇到转义字符\n\t\t\t\t\t} else if (char === \"'\") {\n\t\t\t\t\t\tstate = \"EXPR\"; // 字符串结束,回到表达式状态\n\t\t\t\t\t}\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"STRING_DQ\": // 双引号字符串\n\t\t\t\t\tif (char === \"\\\\\") {\n\t\t\t\t\t\tstate = \"ESCAPE_DQ\";\n\t\t\t\t\t} else if (char === '\"') {\n\t\t\t\t\t\tstate = \"EXPR\";\n\t\t\t\t\t}\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"TEMPLATE\": // 模板字符串\n\t\t\t\t\tif (char === \"\\\\\") {\n\t\t\t\t\t\tstate = \"ESCAPE_TEMPLATE\";\n\t\t\t\t\t} else if (char === \"`\") {\n\t\t\t\t\t\tstate = \"EXPR\";\n\t\t\t\t\t}\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"REGEX\": // 正则字面量\n\t\t\t\t\tif (char === \"\\\\\") {\n\t\t\t\t\t\tstate = \"ESCAPE_REGEX\";\n\t\t\t\t\t} else if (char === \"[\") {\n\t\t\t\t\t\t// A character class may contain an unescaped `/`.\n\t\t\t\t\t\tstate = \"REGEX_CLASS\";\n\t\t\t\t\t} else if (char === \"/\") {\n\t\t\t\t\t\tstate = \"EXPR\"; // 正则结束(flags 之后回到表达式状态)\n\t\t\t\t\t}\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"REGEX_CLASS\": // 正则字符类 [...]\n\t\t\t\t\tif (char === \"\\\\\") {\n\t\t\t\t\t\tstate = \"ESCAPE_REGEX\";\n\t\t\t\t\t} else if (char === \"]\") {\n\t\t\t\t\t\tstate = \"REGEX\";\n\t\t\t\t\t}\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tbreak;\n\n\t\t\t\t// ==================== 转义状态 ====================\n\t\t\t\t// 转义状态:处理转义字符,然后返回到之前的状态\n\t\t\t\tcase \"ESCAPE_SQ\":\n\t\t\t\t\tbuffer += char; // 添加转义后的字符\n\t\t\t\t\tstate = \"STRING_SQ\"; // 回到单引号字符串状态\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"ESCAPE_DQ\":\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tstate = \"STRING_DQ\";\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"ESCAPE_TEMPLATE\":\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tstate = \"TEMPLATE\";\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"ESCAPE_REGEX\":\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tstate = \"REGEX\";\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"ESCAPE_EXPR\":\n\t\t\t\t\tbuffer += char;\n\t\t\t\t\tstate = \"EXPR\";\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// 移动到下一个字符\n\t\t\tpos++;\n\t\t}\n\n\t\t// ==================== 后处理 ====================\n\t\t// 处理扫描结束后缓冲区中剩余的内容\n\t\tif (buffer.length > 0) {\n\t\t\tif (state === \"TEXT\") {\n\t\t\t\t// 剩余的文本内容\n\t\t\t\tpushToken({ type: \"text\", value: buffer, start: pos - buffer.length, end: pos });\n\t\t\t} else {\n\t\t\t\t// 未完成的表达式,将其作为普通文本处理\n\t\t\t\tconst incompleteExpr = this.exprStart + buffer;\n\t\t\t\tpushToken({ type: \"text\", value: incompleteExpr, start: exprStartPos, end: pos });\n\t\t\t}\n\t\t}\n\n\t\treturn tokens;\n\t}\n\n\t/**\n\t * 判断 `/` 是否处于正则字面量的起始位置。当上一个有意义的字符是\n\t * 开头、运算符或左括号时,`/` 开始一个正则;否则它是除号。\n\t * @param {string} prev - 上一个有意义的表达式字符(可能为空)\n\t * @returns {boolean}\n\t * @private\n\t */\n\t_isRegexPosition(prev) {\n\t\treturn prev === \"\" || \"(,=:[!&|?{};+-*%^~<>\".includes(prev);\n\t}\n\n\t/**\n\t * 检查指定位置是否匹配给定的字符序列\n\t * @param {number} pos - 开始检查的位置\n\t * @param {string} template - 模板字符串\n\t * @param {string} sequence - 要匹配的字符序列\n\t * @returns {boolean} 是否匹配\n\t * @private\n\t */\n\t_isMatch(pos, template, sequence) {\n\t\t// 检查剩余长度是否足够\n\t\tif (pos + sequence.length > template.length) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// 逐个字符比较\n\t\tfor (let i = 0; i < sequence.length; i++) {\n\t\t\tif (template[pos + i] !== sequence[i]) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * 静态方法:快速解析模板\n\t * @param {string} template - 模板字符串\n\t * @param {Object} [options] - 配置选项\n\t * @returns {Array} token 数组\n\t */\n\tstatic parse(template, options) {\n\t\tconst parser = new TemplateParser(options);\n\t\treturn parser.parse(template);\n\t}\n}\n\nexport { TemplateParser };\n","import { Evaluator } from \"./Evaluator.js\";\nimport { TemplateParser } from \"./TemplateParser.js\";\n\nexport { Evaluator, TemplateParser };\n\nconst DEFAULT_MAX_TEMPLATE_EXPRESSIONS = 100;\nconst MAX_TEMPLATE_EXPRESSIONS = 1000;\nconst DEFAULT_MAX_TEMPLATE_OUTPUT_LENGTH = 100000;\nconst MAX_TEMPLATE_OUTPUT_LENGTH = 1000000;\n\nfunction validateLimit(value, name, defaultValue, maximum) {\n\tif (value === undefined) {\n\t\treturn defaultValue;\n\t}\n\tif (!Number.isSafeInteger(value) || value < 1 || value > maximum) {\n\t\tthrow new RangeError(`${name} must be an integer between 1 and ${maximum}`);\n\t}\n\treturn value;\n}\n\n/**\n * Evaluates a JavaScript expression with an optional context.\n * @param {string} expression - The JavaScript expression to evaluate\n * @param {unknown} [context] - Optional context object with variables to use in the expression\n * @returns {*} The result of evaluating the expression\n * @example\n * evalExpression('a + b', { a: 1, b: 2 }) // returns 3\n */\nexport function evalExpression(expression, context) {\n\treturn Evaluator.evaluate(expression, context);\n}\n\n/**\n * Evaluates a template string by replacing {{ expression }} patterns with their evaluated values.\n * An expression that references an undefined variable resolves to the string\n * `\"undefined\"` instead of throwing, so a missing variable degrades gracefully.\n * @param {string} template - The template string containing {{ expression }} patterns\n * @param {Object} [context] - Optional context object with variables to use in expressions\n * @param {Object} [templateParserOptions] - Optional options for the template parser\n * @returns {string} The template with all expressions evaluated and replaced\n * @example\n * evalTemplate('Hello {{ name }}!', { name: 'World' }) // returns 'Hello World!'\n */\nexport function evalTemplate(template, context, templateParserOptions) {\n\tconst options = templateParserOptions ?? {};\n\tconst maxExpressions = validateLimit(options.maxExpressions, \"maxExpressions\", DEFAULT_MAX_TEMPLATE_EXPRESSIONS, MAX_TEMPLATE_EXPRESSIONS);\n\tconst maxOutputLength = validateLimit(options.maxOutputLength, \"maxOutputLength\", DEFAULT_MAX_TEMPLATE_OUTPUT_LENGTH, MAX_TEMPLATE_OUTPUT_LENGTH);\n\tconst tokens = TemplateParser.parse(template, options);\n\tlet result = \"\";\n\tlet expressionCount = 0;\n\n\t// Reuse a single Evaluator instance for every expression in the template.\n\t// `Evaluator.evaluate` builds a new instance per call, cloning the whole\n\t// context via structuredClone for each expression - wasteful when a\n\t// template contains many expressions. Reusing one instance is safe here:\n\t// evaluate() never mutates the scope chain outside its own call (arrow\n\t// function scopes are pushed and popped in a finally block), and closures\n\t// cannot escape because the cloneable-return gate rejects them.\n\tconst evaluator = new Evaluator(context, {\n\t\tmaxInputLength: options.maxExpressionLength,\n\t\tmaxEvaluationSteps: options.maxEvaluationSteps,\n\t});\n\n\tconst typeHandler = {\n\t\ttext: (token) => token.value,\n\t\texpression: (token) => {\n\t\t\ttry {\n\t\t\t\treturn evaluator.evaluate(token.value);\n\t\t\t} catch (error) {\n\t\t\t\t// Replace undefined variables with empty string for graceful degradation\n\t\t\t\tif (error instanceof ReferenceError && error.message.endsWith(\"is not defined\")) {\n\t\t\t\t\treturn \"undefined\";\n\t\t\t\t} else {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t};\n\n\tfor (const token of tokens) {\n\t\t// Unknown token type, treat as text\n\t\tconst handler = typeHandler[token.type] ?? typeHandler[\"text\"];\n\t\tif (token.type === \"expression\") {\n\t\t\texpressionCount++;\n\t\t\tif (expressionCount > maxExpressions) {\n\t\t\t\tthrow new RangeError(`Template exceeds the maximum expression count of ${maxExpressions}`);\n\t\t\t}\n\t\t}\n\n\t\tconst chunk = String(handler(token));\n\t\tif (result.length + chunk.length > maxOutputLength) {\n\t\t\tthrow new RangeError(`Template output exceeds the maximum length of ${maxOutputLength} characters`);\n\t\t}\n\t\tresult += chunk;\n\t}\n\n\treturn result;\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","mutableMethods","dangerousMethods","blockedMethods","blockedGlobalBuiltIns","ERROR_MESSAGES","DEFAULT_MAX_INPUT_LENGTH","MAX_CONFIGURABLE_INPUT_LENGTH","DEFAULT_MAX_EVALUATION_STEPS","MAX_CONFIGURABLE_EVALUATION_STEPS","MAX_ARRAY_LENGTH","MAX_BUFFER_BYTES","MAX_STRING_LENGTH","MAX_DATA_NODES","MAX_BIGINT_EXPONENT","MAX_BIGINT_BITS","DEFAULT_MAX_DEPTH","MAX_CONFIGURABLE_DEPTH","MAX_REGEXP_SOURCE_LENGTH","MAX_REGEXP_FLAGS_LENGTH","NON_SANDBOX_GLOBALS","Set","TYPED_ARRAY_CONSTRUCTORS","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float16Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array","constructor","isTypedArrayConstructor","value","TYPED_ARRAY_MUTATORS","map","Map","_iteratorError","_iter","name","method","NO_OBJECT","renderErrorMessage","template","context","_","String","validateLimit","defaultValue","maximum","undefined","Number","RangeError","countLiteralMatches","search","all","count","position","assertBoundedData","label","pending","seen","WeakSet","dataSize","dataNodes","enqueueProperties","object","keys","descriptor","TypeError","current","_type_of","_instanceof","ArrayBuffer","Array","item","BINARY_OPERATION_MAP","a","b","createGlobalScope","scope","builtin","globals","globalThis","isWritable","GLOBAL_SCOPE","getBlockedMethods","BLOCKED_METHODS","path","_path_split","properties","_iteratorError1","Evaluator","variables","options","clonedVariables","structuredClone","evaluate","expression","SyntaxError","ast","acorn","error","execute","body","result","node","Error","Promise","visit","visitNode","Constructor","args","arg","content","handleBinaryExpression","op","left","right","leftBits","rightBits","BigInt","Math","assertBoundedRegExp","assertBoundedConstruction","_args_","RegExp","size","DataView","_size_size","collectionSize","byteLength","_args_1","offset","_args_2","elementCount","_size_length","elementCount1","handleLogicalExpression","left1","left2","handleUnaryExpression","handleIdentifier","ReferenceError","handleMemberExpression","objectValue","isStaticProperty","property","Function","handleArrayExpression","i","element","_result","assertBoundedSpread","currentLength","handleObjectExpression","spreadPropertyCount","spreadValue","handleSpreadElement","handleArrowFunctionExpression","newScope","paramCount","consumeEvaluationValue","_assertBoundedData","handleCallExpression","isOptional","func","target","resultLength","length","matchCount","source","_source_size","calledString","getNodeString","handleTemplateLiteral","expressionCount","evaluator","child","objectStr","propertyStr","DEFAULT_MAX_TEMPLATE_LENGTH","MAX_CONFIGURABLE_TEMPLATE_LENGTH","DEFAULT_MAX_TOKENS","MAX_CONFIGURABLE_TOKENS","TemplateParser","parse","tokens","pushToken","token","state","buffer","exprStartPos","pos","prevExprChar","char","nextChar","exprValue","incompleteExpr","_isRegexPosition","prev","_isMatch","sequence","parser","DEFAULT_MAX_TEMPLATE_EXPRESSIONS","MAX_TEMPLATE_EXPRESSIONS","DEFAULT_MAX_TEMPLATE_OUTPUT_LENGTH","MAX_TEMPLATE_OUTPUT_LENGTH","evalExpression","evalTemplate","templateParserOptions","maxExpressions","maxOutputLength","typeHandler","_typeHandler_token_type","handler","chunk"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,SAAS,QAAO,EAAEC,UAAU;QACnD,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,SAASI,GAAG,EAAEC,IAAI;QAAI,OAAOF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;IAAO;;;ICCtGL,oBAAoB,CAAC,GAAG,SAAS,QAAO;QACvC,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACNA,IAAMI,iBAAiB;IACtB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IAEA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IAEA;IACA;IACA;IAEA;IAEA;IAEA;IACA;IAEA;IACA;IACA;IACA;IAEA;IACA;IACA;IAEA;IACA;IACA;IAGA;IACA;IACA;IACA;IAGA;IACA;IAGA;CACA;AAED,IAAMC,mBAAmB;IACxB;IAEA;IACA;IACA;IACA;IAMA;IACA;CACA;AAGDD,eAAe,IAAI,CAAC;AAKb,IAAME,iBAAkB,qBAAGF,gBAAAA,MAAAA,CAAgB,qBAAGC;AAK9C,IAAME,wBAAwB;IACpC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAGA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAGA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAGA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAGA;IACA;IACA;IACA;IAIA;IAIA;IAGA;IAOA;IAGA;IACA;IAGA;CACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACnRD,IAAMC,iBAAiB;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/**
15
+ * Maximum interpreter recursion depth (hard maximum: 2000). Bounds nested
16
+ * expressions so a deeply nested input cannot exhaust the host call stack.
17
+ * @default 1000
18
+ */
19
+ maxDepth?: number;
14
20
  }
15
21
 
16
22
  export declare class Evaluator {
@@ -21,4 +27,8 @@ export declare class Evaluator {
21
27
  evaluate<T = unknown>(expression: string): T;
22
28
  }
23
29
 
24
- export declare function getNodeString(node: Node): string;
30
+ /**
31
+ * Renders an AST node back to a short source-like string. Returns `null` for
32
+ * node types that have no textual representation.
33
+ */
34
+ export declare function getNodeString(node: Node): string | null;