/**
 * AST Provenance Tracking Runtime for isolated-vm
 * This code is injected into the isolate and runs INSIDE the sandbox
 * It must be plain JavaScript with no imports
 *
 * This runtime provides comprehensive taint tracking by:
 * 1. Deep-tainting all primitives from tool results
 * 2. Intercepting native methods with re-entry protection
 * 3. Supporting cross-execution tracking via hints
 */
export declare const AST_TRACKING_RUNTIME = "\n// Pure JavaScript SHA-256 implementation for digest computation\nfunction sha256(str) {\n\tfunction rightRotate(value, amount) {\n\t\treturn (value >>> amount) | (value << (32 - amount));\n\t}\n\t\n\tconst mathPow = Math.pow;\n\tconst maxWord = mathPow(2, 32);\n\tconst lengthProperty = 'length';\n\tlet i, j;\n\tlet result = '';\n\t\n\tconst words = [];\n\tconst asciiBitLength = str[lengthProperty] * 8;\n\t\n\tlet hash = sha256.h = sha256.h || [];\n\tconst k = sha256.k = sha256.k || [];\n\tlet primeCounter = k[lengthProperty];\n\t\n\tconst isComposite = {};\n\tfor (let candidate = 2; primeCounter < 64; candidate++) {\n\t\tif (!isComposite[candidate]) {\n\t\t\tfor (i = 0; i < 313; i += candidate) {\n\t\t\t\tisComposite[i] = candidate;\n\t\t\t}\n\t\t\thash[primeCounter] = (mathPow(candidate, .5) * maxWord) | 0;\n\t\t\tk[primeCounter++] = (mathPow(candidate, 1 / 3) * maxWord) | 0;\n\t\t}\n\t}\n\t\n\tstr += '\\x80';\n\twhile (str[lengthProperty] % 64 - 56) str += '\\x00';\n\tfor (i = 0; i < str[lengthProperty]; i++) {\n\t\tj = str.charCodeAt(i);\n\t\tif (j >> 8) return;\n\t\twords[i >> 2] |= j << ((3 - i) % 4) * 8;\n\t}\n\twords[words[lengthProperty]] = ((asciiBitLength / maxWord) | 0);\n\twords[words[lengthProperty]] = (asciiBitLength);\n\t\n\tfor (j = 0; j < words[lengthProperty];) {\n\t\tconst w = words.slice(j, j += 16);\n\t\tconst oldHash = hash;\n\t\thash = hash.slice(0, 8);\n\t\t\n\t\tfor (i = 0; i < 64; i++) {\n\t\t\tconst w15 = w[i - 15], w2 = w[i - 2];\n\t\t\t\n\t\t\tconst a = hash[0], e = hash[4];\n\t\t\tconst temp1 = hash[7]\n\t\t\t\t+ (rightRotate(e, 6) ^ rightRotate(e, 11) ^ rightRotate(e, 25))\n\t\t\t\t+ ((e & hash[5]) ^ ((~e) & hash[6]))\n\t\t\t\t+ k[i]\n\t\t\t\t+ (w[i] = (i < 16) ? w[i] : (\n\t\t\t\t\t\tw[i - 16]\n\t\t\t\t\t\t+ (rightRotate(w15, 7) ^ rightRotate(w15, 18) ^ (w15 >>> 3))\n\t\t\t\t\t\t+ w[i - 7]\n\t\t\t\t\t\t+ (rightRotate(w2, 17) ^ rightRotate(w2, 19) ^ (w2 >>> 10))\n\t\t\t\t\t) | 0\n\t\t\t\t);\n\t\t\tconst temp2 = (rightRotate(a, 2) ^ rightRotate(a, 13) ^ rightRotate(a, 22))\n\t\t\t\t+ ((a & hash[1]) ^ (a & hash[2]) ^ (hash[1] & hash[2]));\n\t\t\t\n\t\t\thash = [(temp1 + temp2) | 0].concat(hash);\n\t\t\thash[4] = (hash[4] + temp1) | 0;\n\t\t}\n\t\t\n\t\tfor (i = 0; i < 8; i++) {\n\t\t\thash[i] = (hash[i] + oldHash[i]) | 0;\n\t\t}\n\t}\n\t\n\tfor (i = 0; i < 8; i++) {\n\t\tfor (j = 3; j + 1; j--) {\n\t\t\tconst b = (hash[i] >> (j * 8)) & 255;\n\t\t\tresult += ((b < 16) ? 0 : '') + b.toString(16);\n\t\t}\n\t}\n\t\n\t// Convert hex to base64url\n\tconst hex = result;\n\tconst bytes = [];\n\tfor (let i = 0; i < hex.length; i += 2) {\n\t\tbytes.push(parseInt(hex.substring(i, i + 2), 16));\n\t}\n\tlet binary = '';\n\tfor (let i = 0; i < bytes.length; i++) {\n\t\tbinary += String.fromCharCode(bytes[i]);\n\t}\n\tconst base64 = btoa(binary);\n\treturn base64.replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=/g, '');\n}\n\n// Re-entry guard to prevent infinite recursion in wrapped methods\nlet __inTrackingCall = false;\n\nconst __astTracker = {\n\tmetadata: new Map(),\n\tnextId: 0,\n\thints: new Map(globalThis.__provenance_hints || []),\n\thintValues: new Map(globalThis.__provenance_hint_values || []),\n\t// Track tainted objects via WeakMap for O(1) lookup\n\ttaintedObjects: new WeakMap(),\n\t\n\tcomputeDigest(value) {\n\t\tif (__inTrackingCall) return null;\n\t\ttry {\n\t\t\t__inTrackingCall = true;\n\t\t\tconst str = JSON.stringify(value);\n\t\t\t__inTrackingCall = false;\n\t\t\treturn sha256(str);\n\t\t} catch (e) {\n\t\t\t__inTrackingCall = false;\n\t\t\treturn null;\n\t\t}\n\t},\n\t\n\tgetId(value) {\n\t\tif (typeof value === 'object' && value !== null) {\n\t\t\tif (!value.__prov_id__) {\n\t\t\t\tconst id = 'tracked_' + Date.now() + '_' + (Math.random().toString(36).substring(2, 8));\n\t\t\t\ttry {\n\t\t\t\t\tObject.defineProperty(value, '__prov_id__', {\n\t\t\t\t\t\tvalue: id,\n\t\t\t\t\t\twritable: false,\n\t\t\t\t\t\tenumerable: false,\n\t\t\t\t\t\tconfigurable: true\n\t\t\t\t\t});\n\t\t\t\t} catch (e) {\n\t\t\t\t\treturn 'temp_' + Date.now() + '_' + Math.random();\n\t\t\t\t}\n\t\t\t\treturn id;\n\t\t\t}\n\t\t\treturn value.__prov_id__;\n\t\t}\n\t\treturn 'primitive_' + Date.now() + '_' + Math.random();\n\t},\n\t\n\t// Register a primitive value as tainted\n\tregisterTaintedPrimitive(value, metadata) {\n\t\t// Accept any non-empty string or any valid number (including 0)\n\t\tconst isValidString = typeof value === 'string' && value !== '';\n\t\tconst isValidNumber = typeof value === 'number' && !Number.isNaN(value);\n\t\t\n\t\tif (isValidString || isValidNumber) {\n\t\t\tconst taintedKey = 'tainted:' + String(value);\n\t\t\tthis.metadata.set(taintedKey, {\n\t\t\t\t...metadata,\n\t\t\t\treaders: metadata.readers || { type: 'restricted', readers: [] },\n\t\t\t\tdependencies: metadata.dependencies || metadata.deps || []\n\t\t\t});\n\t\t}\n\t},\n\t\n\t// Deep taint an object - register all nested primitives\n\tdeepTaintObject(obj, metadata, visited = new WeakSet()) {\n\t\tif (!obj || typeof obj !== 'object') return;\n\t\tif (visited.has(obj)) return;\n\t\tvisited.add(obj);\n\t\t\n\t\t// Mark object in WeakMap for fast lookup\n\t\tthis.taintedObjects.set(obj, metadata);\n\t\t\n\t\t// Set __prov_id__ and register in metadata\n\t\tconst id = this.getId(obj);\n\t\tthis.metadata.set(id, metadata);\n\t\t\n\t\t// Register all primitive properties\n\t\tconst keys = Object.keys(obj);\n\t\tfor (let i = 0; i < keys.length; i++) {\n\t\t\tconst key = keys[i];\n\t\t\tconst value = obj[key];\n\t\t\t\n\t\t\tif (typeof value === 'string' || typeof value === 'number') {\n\t\t\t\tthis.registerTaintedPrimitive(value, metadata);\n\t\t\t\t// Also store by object:key:value for additional lookup\n\t\t\t\tconst primitiveKey = id + ':' + key + ':' + String(value);\n\t\t\t\tthis.metadata.set(primitiveKey, metadata);\n\t\t\t} else if (Array.isArray(value)) {\n\t\t\t\t// Taint array and its elements\n\t\t\t\tthis.deepTaintObject(value, metadata, visited);\n\t\t\t\tfor (let j = 0; j < value.length; j++) {\n\t\t\t\t\tconst elem = value[j];\n\t\t\t\t\tif (typeof elem === 'string' || typeof elem === 'number') {\n\t\t\t\t\t\tthis.registerTaintedPrimitive(elem, metadata);\n\t\t\t\t\t} else if (typeof elem === 'object' && elem !== null) {\n\t\t\t\t\t\tthis.deepTaintObject(elem, metadata, visited);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (typeof value === 'object' && value !== null) {\n\t\t\t\tthis.deepTaintObject(value, metadata, visited);\n\t\t\t}\n\t\t}\n\t},\n\t\n\ttrack(value, source, deps) {\n\t\ttry {\n\t\t\tconst id = this.getId(value);\n\t\t\tconst metadata = { \n\t\t\t\tid, \n\t\t\t\tsource, \n\t\t\t\tdeps: deps || [],\n\t\t\t\treaders: source.readers || { type: 'restricted', readers: ['tool:' + (source.tool || source.operation || 'unknown')] },\n\t\t\t\tdependencies: []\n\t\t\t};\n\t\t\tthis.metadata.set(id, metadata);\n\t\t\t\n\t\t\t// Deep taint all nested primitives\n\t\t\tif (value && typeof value === 'object') {\n\t\t\t\tthis.deepTaintObject(value, metadata);\n\t\t\t}\n\t\t\t\n\t\t\treturn value;\n\t\t} catch (error) {\n\t\t\treturn value;\n\t\t}\n\t},\n\t\n\ttrackBinary(left, right, operator) {\n\t\tlet result;\n\t\tswitch (operator) {\n\t\t\tcase '+': result = left + right; break;\n\t\t\tcase '-': result = left - right; break;\n\t\t\tcase '*': result = left * right; break;\n\t\t\tcase '/': result = left / right; break;\n\t\t\tcase '%': result = left % right; break;\n\t\t\tcase '==': result = left == right; break;\n\t\t\tcase '===': result = left === right; break;\n\t\t\tcase '!=': result = left != right; break;\n\t\t\tcase '!==': result = left !== right; break;\n\t\t\tcase '<': result = left < right; break;\n\t\t\tcase '>': result = left > right; break;\n\t\t\tcase '<=': result = left <= right; break;\n\t\t\tcase '>=': result = left >= right; break;\n\t\t\tcase '&&': result = left && right; break;\n\t\t\tcase '||': result = left || right; break;\n\t\t\tdefault: result = left;\n\t\t}\n\t\t\n\t\t// Propagate taint from operands to result\n\t\tconst leftMeta = this.checkProvenance(left);\n\t\tconst rightMeta = this.checkProvenance(right);\n\t\tconst toolMetadata = leftMeta || rightMeta;\n\t\t\n\t\tif (toolMetadata && (typeof result === 'string' || typeof result === 'number')) {\n\t\t\tthis.registerTaintedPrimitive(result, toolMetadata);\n\t\t}\n\t\t\n\t\treturn result;\n\t},\n\t\n\ttrackAssign(name, value) {\n\t\treturn value;\n\t},\n\t\n\tasync trackMethod(object, method, args) {\n\t\t// Wrap tainted primitives in arguments before calling API methods\n\t\tconst self = this;\n\t\tfunction wrapTaintedInArgs(val, visited = new WeakSet()) {\n\t\t\tif (val === null || val === undefined) return val;\n\t\t\t\n\t\t\tconst prov = self.checkProvenance(val);\n\t\t\tif (prov && (typeof val === 'string' || typeof val === 'number')) {\n\t\t\t\treturn { __tainted_value: val, __prov_meta: prov };\n\t\t\t}\n\t\t\t\n\t\t\tif (typeof val === 'object') {\n\t\t\t\tif (visited.has(val)) return val;\n\t\t\t\tvisited.add(val);\n\t\t\t\t\n\t\t\t\tif (Array.isArray(val)) {\n\t\t\t\t\treturn val.map(item => wrapTaintedInArgs(item, visited));\n\t\t\t\t} else {\n\t\t\t\t\tconst wrapped = {};\n\t\t\t\t\tconst keys = Object.keys(val);\n\t\t\t\t\tfor (let i = 0; i < keys.length; i++) {\n\t\t\t\t\t\twrapped[keys[i]] = wrapTaintedInArgs(val[keys[i]], visited);\n\t\t\t\t\t}\n\t\t\t\t\treturn wrapped;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\treturn val;\n\t\t}\n\t\t\n\t\tconst wrappedArgs = args.map(arg => wrapTaintedInArgs(arg));\n\t\t\n\t\tif (typeof object === 'object' && object !== null && method in object) {\n\t\t\tconst result = await object[method](...wrappedArgs);\n\t\t\t\n\t\t\tif (result && typeof result === 'object') {\n\t\t\t\tconst id = this.getId(result);\n\t\t\t\t\n\t\t\t\tlet authorizedReaders = [];\n\t\t\t\tfor (const arg of args) {\n\t\t\t\t\tif (arg && typeof arg === 'object') {\n\t\t\t\t\t\tconst value = arg.email || arg.user || arg.userId;\n\t\t\t\t\t\tif (typeof value === 'string' && value.length > 0) {\n\t\t\t\t\t\t\tauthorizedReaders.push(value);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (authorizedReaders.length === 0) {\n\t\t\t\t\tauthorizedReaders = ['tool:' + method];\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tconst metadata = { \n\t\t\t\t\tid, \n\t\t\t\t\tsource: { type: 'tool', operation: method, toolName: method, timestamp: Date.now() },\n\t\t\t\t\treaders: { type: 'restricted', readers: authorizedReaders },\n\t\t\t\t\tdeps: [],\n\t\t\t\t\tdependencies: []\n\t\t\t\t};\n\t\t\t\tthis.metadata.set(id, metadata);\n\t\t\t\tthis.deepTaintObject(result, metadata);\n\t\t\t}\n\t\t\t\n\t\t\treturn result;\n\t\t}\n\t\treturn undefined;\n\t},\n\t\n\ttrackTemplate(expressions, quasis) {\n\t\tlet result = '';\n\t\tlet toolMetadata = null;\n\t\t\n\t\tfor (let i = 0; i < quasis.length; i++) {\n\t\t\tresult += quasis[i] || '';\n\t\t\tif (i < expressions.length) {\n\t\t\t\tconst expr = expressions[i];\n\t\t\t\tresult += String(expr);\n\t\t\t\t\n\t\t\t\tif (!toolMetadata) {\n\t\t\t\t\ttoolMetadata = this.checkProvenance(expr);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (toolMetadata) {\n\t\t\tthis.registerTaintedPrimitive(result, toolMetadata);\n\t\t}\n\t\t\n\t\treturn result;\n\t},\n\t\n\t// Propagate taint from source to result for native method calls\n\tpropagateTaint(source, args, result) {\n\t\tif (__inTrackingCall) return result;\n\t\t\n\t\t__inTrackingCall = true;\n\t\ttry {\n\t\t\t// Check if source or any arg is tainted\n\t\t\tlet metadata = this.checkProvenanceInternal(source);\n\t\t\t\n\t\t\tif (!metadata && args) {\n\t\t\t\tfor (let i = 0; i < args.length; i++) {\n\t\t\t\t\tmetadata = this.checkProvenanceInternal(args[i]);\n\t\t\t\t\tif (metadata) break;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t// Propagate taint to result\n\t\t\tif (metadata) {\n\t\t\t\tif (typeof result === 'string' || typeof result === 'number') {\n\t\t\t\t\tthis.registerTaintedPrimitive(result, metadata);\n\t\t\t\t} else if (Array.isArray(result)) {\n\t\t\t\t\tthis.deepTaintObject(result, metadata);\n\t\t\t\t} else if (typeof result === 'object' && result !== null) {\n\t\t\t\t\tthis.deepTaintObject(result, metadata);\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\t__inTrackingCall = false;\n\t\t}\n\t\t\n\t\treturn result;\n\t},\n\t\n\tgetMetadata(value) {\n\t\tconst id = typeof value === 'object' && value && value.__prov_id__;\n\t\treturn id ? this.metadata.get(id) : null;\n\t},\n\t\n\tgetAllMetadata() {\n\t\treturn Array.from(this.metadata.entries());\n\t},\n\t\n\t// Internal provenance check (no re-entry guard - caller must set it)\n\tcheckProvenanceInternal(value) {\n\t\tif (value === null || value === undefined) return null;\n\t\t\n\t\t// Fast path: check WeakMap for objects\n\t\tif (typeof value === 'object' && this.taintedObjects.has(value)) {\n\t\t\treturn this.taintedObjects.get(value);\n\t\t}\n\t\t\n\t\t// Check object __prov_id__\n\t\tif (typeof value === 'object' && value.__prov_id__) {\n\t\t\tconst meta = this.metadata.get(value.__prov_id__);\n\t\t\tif (meta && meta.source && meta.source.type === 'tool') {\n\t\t\t\treturn meta;\n\t\t\t}\n\t\t}\n\t\t\n\t\t// Check primitive taint\n\t\tif (typeof value === 'string' || typeof value === 'number') {\n\t\t\tconst taintedKey = 'tainted:' + String(value);\n\t\t\tconst taintedMeta = this.metadata.get(taintedKey);\n\t\t\tif (taintedMeta && taintedMeta.source && taintedMeta.source.type === 'tool') {\n\t\t\t\treturn taintedMeta;\n\t\t\t}\n\t\t\t\n\t\t\t// Check primitive map (object:key:value format)\n\t\t\tfor (const [key, meta] of this.metadata.entries()) {\n\t\t\t\t// Skip non-string keys (could be Symbols)\n\t\t\t\tif (typeof key !== 'string') continue;\n\t\t\t\tif (!key.startsWith('tainted:') && key.includes(':')) {\n\t\t\t\t\tconst parts = key.split(':');\n\t\t\t\t\tif (parts.length >= 3) {\n\t\t\t\t\t\tconst primitiveValue = parts.slice(2).join(':');\n\t\t\t\t\t\tif (primitiveValue === String(value) && meta.source && meta.source.type === 'tool') {\n\t\t\t\t\t\t\treturn meta;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t// Check hints (cross-execution)\n\t\t\tconst digest = this.computeDigest(value);\n\t\t\tif (digest) {\n\t\t\t\tconst hintMeta = this.hints.get(digest);\n\t\t\t\tif (hintMeta && hintMeta.source && hintMeta.source.type === 'tool') {\n\t\t\t\t\treturn hintMeta;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t// Check substring containment in hint values\n\t\t\tif (typeof value === 'string' && this.hintValues && this.hintValues.size > 0) {\n\t\t\t\tfor (const [hintValue, meta] of this.hintValues.entries()) {\n\t\t\t\t\tif (value.includes(hintValue) && meta.source && meta.source.type === 'tool') {\n\t\t\t\t\t\treturn meta;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t// Recursively check object properties\n\t\tif (typeof value === 'object') {\n\t\t\tconst keys = Object.keys(value);\n\t\t\tfor (let i = 0; i < keys.length; i++) {\n\t\t\t\tconst nestedMeta = this.checkProvenanceInternal(value[keys[i]]);\n\t\t\t\tif (nestedMeta) return nestedMeta;\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn null;\n\t},\n\t\n\t// Public provenance check with re-entry guard\n\tcheckProvenance(value) {\n\t\tif (__inTrackingCall) return null;\n\t\t\n\t\t__inTrackingCall = true;\n\t\ttry {\n\t\t\treturn this.checkProvenanceInternal(value);\n\t\t} finally {\n\t\t\t__inTrackingCall = false;\n\t\t}\n\t}\n};\n\n// ============================================================================\n// NATIVE METHOD INTERCEPTION\n// We store originals and wrap methods with taint propagation\n// ============================================================================\n\nconst __originals = {\n\tString_toUpperCase: String.prototype.toUpperCase,\n\tString_toLowerCase: String.prototype.toLowerCase,\n\tString_slice: String.prototype.slice,\n\tString_substring: String.prototype.substring,\n\tString_substr: String.prototype.substr,\n\tString_trim: String.prototype.trim,\n\tString_trimStart: String.prototype.trimStart,\n\tString_trimEnd: String.prototype.trimEnd,\n\tString_replace: String.prototype.replace,\n\tString_replaceAll: String.prototype.replaceAll,\n\tString_split: String.prototype.split,\n\tString_charAt: String.prototype.charAt,\n\tString_concat: String.prototype.concat,\n\tString_padStart: String.prototype.padStart,\n\tString_padEnd: String.prototype.padEnd,\n\tString_repeat: String.prototype.repeat,\n\tString_normalize: String.prototype.normalize,\n\t\n\tArray_map: Array.prototype.map,\n\tArray_filter: Array.prototype.filter,\n\tArray_reduce: Array.prototype.reduce,\n\tArray_reduceRight: Array.prototype.reduceRight,\n\tArray_join: Array.prototype.join,\n\tArray_slice: Array.prototype.slice,\n\tArray_concat: Array.prototype.concat,\n\tArray_flat: Array.prototype.flat,\n\tArray_flatMap: Array.prototype.flatMap,\n\tArray_find: Array.prototype.find,\n\tArray_every: Array.prototype.every,\n\tArray_some: Array.prototype.some,\n\t\n\tNumber_toFixed: Number.prototype.toFixed,\n\tNumber_toPrecision: Number.prototype.toPrecision,\n\tNumber_toExponential: Number.prototype.toExponential,\n\t\n\tJSON_stringify: JSON.stringify,\n\tJSON_parse: JSON.parse,\n\t\n\tString_ctor: String,\n\tNumber_ctor: Number,\n\tparseInt_fn: parseInt,\n\tparseFloat_fn: parseFloat,\n};\n\n// String method wrappers - use this.valueOf() to get primitive for provenance check\nString.prototype.toUpperCase = function() {\n\tconst result = __originals.String_toUpperCase.call(this);\n\tconst primitiveThis = typeof this === 'object' ? this.valueOf() : this;\n\treturn __astTracker.propagateTaint(primitiveThis, [], result);\n};\n\nString.prototype.toLowerCase = function() {\n\tconst result = __originals.String_toLowerCase.call(this);\n\tconst primitiveThis = typeof this === 'object' ? this.valueOf() : this;\n\treturn __astTracker.propagateTaint(primitiveThis, [], result);\n};\n\nString.prototype.slice = function(start, end) {\n\tconst result = __originals.String_slice.call(this, start, end);\n\tconst primitiveThis = typeof this === 'object' ? this.valueOf() : this;\n\treturn __astTracker.propagateTaint(primitiveThis, [], result);\n};\n\nString.prototype.substring = function(start, end) {\n\tconst result = __originals.String_substring.call(this, start, end);\n\tconst primitiveThis = typeof this === 'object' ? this.valueOf() : this;\n\treturn __astTracker.propagateTaint(primitiveThis, [], result);\n};\n\nString.prototype.substr = function(start, length) {\n\tconst result = __originals.String_substr.call(this, start, length);\n\tconst primitiveThis = typeof this === 'object' ? this.valueOf() : this;\n\treturn __astTracker.propagateTaint(primitiveThis, [], result);\n};\n\nString.prototype.trim = function() {\n\tconst result = __originals.String_trim.call(this);\n\tconst primitiveThis = typeof this === 'object' ? this.valueOf() : this;\n\treturn __astTracker.propagateTaint(primitiveThis, [], result);\n};\n\nString.prototype.trimStart = function() {\n\tconst result = __originals.String_trimStart.call(this);\n\tconst primitiveThis = typeof this === 'object' ? this.valueOf() : this;\n\treturn __astTracker.propagateTaint(primitiveThis, [], result);\n};\n\nString.prototype.trimEnd = function() {\n\tconst result = __originals.String_trimEnd.call(this);\n\tconst primitiveThis = typeof this === 'object' ? this.valueOf() : this;\n\treturn __astTracker.propagateTaint(primitiveThis, [], result);\n};\n\nString.prototype.replace = function(searchValue, replaceValue) {\n\tconst result = __originals.String_replace.call(this, searchValue, replaceValue);\n\tconst primitiveThis = typeof this === 'object' ? this.valueOf() : this;\n\treturn __astTracker.propagateTaint(primitiveThis, [], result);\n};\n\nString.prototype.replaceAll = function(searchValue, replaceValue) {\n\tconst result = __originals.String_replaceAll.call(this, searchValue, replaceValue);\n\tconst primitiveThis = typeof this === 'object' ? this.valueOf() : this;\n\treturn __astTracker.propagateTaint(primitiveThis, [], result);\n};\n\nString.prototype.split = function(separator, limit) {\n\tconst result = __originals.String_split.call(this, separator, limit);\n\tconst primitiveThis = typeof this === 'object' ? this.valueOf() : this;\n\treturn __astTracker.propagateTaint(primitiveThis, [], result);\n};\n\nString.prototype.charAt = function(index) {\n\tconst result = __originals.String_charAt.call(this, index);\n\tconst primitiveThis = typeof this === 'object' ? this.valueOf() : this;\n\treturn __astTracker.propagateTaint(primitiveThis, [], result);\n};\n\nString.prototype.concat = function(...args) {\n\tconst result = __originals.String_concat.apply(this, args);\n\tconst primitiveThis = typeof this === 'object' ? this.valueOf() : this;\n\treturn __astTracker.propagateTaint(primitiveThis, args, result);\n};\n\nString.prototype.padStart = function(targetLength, padString) {\n\tconst result = __originals.String_padStart.call(this, targetLength, padString);\n\tconst primitiveThis = typeof this === 'object' ? this.valueOf() : this;\n\treturn __astTracker.propagateTaint(primitiveThis, [], result);\n};\n\nString.prototype.padEnd = function(targetLength, padString) {\n\tconst result = __originals.String_padEnd.call(this, targetLength, padString);\n\tconst primitiveThis = typeof this === 'object' ? this.valueOf() : this;\n\treturn __astTracker.propagateTaint(primitiveThis, [], result);\n};\n\nString.prototype.repeat = function(count) {\n\tconst result = __originals.String_repeat.call(this, count);\n\tconst primitiveThis = typeof this === 'object' ? this.valueOf() : this;\n\treturn __astTracker.propagateTaint(primitiveThis, [], result);\n};\n\nString.prototype.normalize = function(form) {\n\tconst result = __originals.String_normalize.call(this, form);\n\tconst primitiveThis = typeof this === 'object' ? this.valueOf() : this;\n\treturn __astTracker.propagateTaint(primitiveThis, [], result);\n};\n\n// Array method wrappers\nArray.prototype.map = function(callback, thisArg) {\n\tconst result = __originals.Array_map.call(this, callback, thisArg);\n\treturn __astTracker.propagateTaint(this, [], result);\n};\n\nArray.prototype.filter = function(callback, thisArg) {\n\tconst result = __originals.Array_filter.call(this, callback, thisArg);\n\treturn __astTracker.propagateTaint(this, [], result);\n};\n\nArray.prototype.reduce = function(callback, initialValue) {\n\tconst result = arguments.length > 1 \n\t\t? __originals.Array_reduce.call(this, callback, initialValue)\n\t\t: __originals.Array_reduce.call(this, callback);\n\treturn __astTracker.propagateTaint(this, [], result);\n};\n\nArray.prototype.reduceRight = function(callback, initialValue) {\n\tconst result = arguments.length > 1\n\t\t? __originals.Array_reduceRight.call(this, callback, initialValue)\n\t\t: __originals.Array_reduceRight.call(this, callback);\n\treturn __astTracker.propagateTaint(this, [], result);\n};\n\nArray.prototype.join = function(separator) {\n\tconst result = __originals.Array_join.call(this, separator);\n\treturn __astTracker.propagateTaint(this, [], result);\n};\n\nArray.prototype.slice = function(start, end) {\n\tconst result = __originals.Array_slice.call(this, start, end);\n\treturn __astTracker.propagateTaint(this, [], result);\n};\n\nArray.prototype.concat = function(...args) {\n\tconst result = __originals.Array_concat.apply(this, args);\n\treturn __astTracker.propagateTaint(this, args, result);\n};\n\nArray.prototype.flat = function(depth) {\n\tconst result = __originals.Array_flat.call(this, depth);\n\treturn __astTracker.propagateTaint(this, [], result);\n};\n\nArray.prototype.flatMap = function(callback, thisArg) {\n\tconst result = __originals.Array_flatMap.call(this, callback, thisArg);\n\treturn __astTracker.propagateTaint(this, [], result);\n};\n\nArray.prototype.find = function(callback, thisArg) {\n\tconst result = __originals.Array_find.call(this, callback, thisArg);\n\treturn __astTracker.propagateTaint(this, [], result);\n};\n\nArray.prototype.every = function(callback, thisArg) {\n\treturn __originals.Array_every.call(this, callback, thisArg);\n};\n\nArray.prototype.some = function(callback, thisArg) {\n\treturn __originals.Array_some.call(this, callback, thisArg);\n};\n\n// Number method wrappers - use this.valueOf() to get primitive for provenance check\nNumber.prototype.toFixed = function(digits) {\n\tconst result = __originals.Number_toFixed.call(this, digits);\n\tconst primitiveThis = typeof this === 'object' ? this.valueOf() : this;\n\treturn __astTracker.propagateTaint(primitiveThis, [], result);\n};\n\nNumber.prototype.toPrecision = function(precision) {\n\tconst result = __originals.Number_toPrecision.call(this, precision);\n\tconst primitiveThis = typeof this === 'object' ? this.valueOf() : this;\n\treturn __astTracker.propagateTaint(primitiveThis, [], result);\n};\n\nNumber.prototype.toExponential = function(fractionDigits) {\n\tconst result = __originals.Number_toExponential.call(this, fractionDigits);\n\tconst primitiveThis = typeof this === 'object' ? this.valueOf() : this;\n\treturn __astTracker.propagateTaint(primitiveThis, [], result);\n};\n\n// JSON wrappers\nJSON.stringify = function(value, replacer, space) {\n\tconst result = __originals.JSON_stringify(value, replacer, space);\n\treturn __astTracker.propagateTaint(value, [], result);\n};\n\nJSON.parse = function(text, reviver) {\n\tconst result = __originals.JSON_parse(text, reviver);\n\t// If input was tainted, taint the parsed object\n\tif (!__inTrackingCall) {\n\t\t__inTrackingCall = true;\n\t\ttry {\n\t\t\tconst inputMeta = __astTracker.checkProvenanceInternal(text);\n\t\t\tif (inputMeta && result && typeof result === 'object') {\n\t\t\t\t__astTracker.deepTaintObject(result, inputMeta);\n\t\t\t}\n\t\t} finally {\n\t\t\t__inTrackingCall = false;\n\t\t}\n\t}\n\treturn result;\n};\n\n// Global function wrappers\nconst __OrigString = __originals.String_ctor;\nglobalThis.String = function(value) {\n\tif (new.target) {\n\t\treturn new __OrigString(value);\n\t}\n\tconst result = __OrigString(value);\n\treturn __astTracker.propagateTaint(value, [], result);\n};\nObject.setPrototypeOf(globalThis.String, __OrigString);\nglobalThis.String.prototype = __OrigString.prototype;\nglobalThis.String.fromCharCode = __OrigString.fromCharCode;\nglobalThis.String.fromCodePoint = __OrigString.fromCodePoint;\nglobalThis.String.raw = __OrigString.raw;\n\nconst __OrigNumber = __originals.Number_ctor;\nglobalThis.Number = function(value) {\n\tif (new.target) {\n\t\treturn new __OrigNumber(value);\n\t}\n\tconst result = __OrigNumber(value);\n\treturn __astTracker.propagateTaint(value, [], result);\n};\nObject.setPrototypeOf(globalThis.Number, __OrigNumber);\nglobalThis.Number.prototype = __OrigNumber.prototype;\nglobalThis.Number.isNaN = __OrigNumber.isNaN;\nglobalThis.Number.isFinite = __OrigNumber.isFinite;\nglobalThis.Number.isInteger = __OrigNumber.isInteger;\nglobalThis.Number.isSafeInteger = __OrigNumber.isSafeInteger;\nglobalThis.Number.parseFloat = __OrigNumber.parseFloat;\nglobalThis.Number.parseInt = __OrigNumber.parseInt;\nglobalThis.Number.MAX_VALUE = __OrigNumber.MAX_VALUE;\nglobalThis.Number.MIN_VALUE = __OrigNumber.MIN_VALUE;\nglobalThis.Number.NaN = __OrigNumber.NaN;\nglobalThis.Number.NEGATIVE_INFINITY = __OrigNumber.NEGATIVE_INFINITY;\nglobalThis.Number.POSITIVE_INFINITY = __OrigNumber.POSITIVE_INFINITY;\nglobalThis.Number.MAX_SAFE_INTEGER = __OrigNumber.MAX_SAFE_INTEGER;\nglobalThis.Number.MIN_SAFE_INTEGER = __OrigNumber.MIN_SAFE_INTEGER;\nglobalThis.Number.EPSILON = __OrigNumber.EPSILON;\n\nglobalThis.parseInt = function(string, radix) {\n\tconst result = __originals.parseInt_fn(string, radix);\n\treturn __astTracker.propagateTaint(string, [], result);\n};\n\nglobalThis.parseFloat = function(string) {\n\tconst result = __originals.parseFloat_fn(string);\n\treturn __astTracker.propagateTaint(string, [], result);\n};\n\n// ============================================================================\n// GLOBAL TRACKING FUNCTIONS\n// ============================================================================\n\nglobalThis.__track = (v, s, d) => __astTracker.track(v, s, d);\nglobalThis.__track_binary = (l, r, o) => __astTracker.trackBinary(l, r, o);\nglobalThis.__track_assign = (n, v) => __astTracker.trackAssign(n, v);\nglobalThis.__track_method = (o, m, a) => __astTracker.trackMethod(o, m, a);\nglobalThis.__track_template = (e, q) => __astTracker.trackTemplate(e, q);\nglobalThis.__get_provenance = (v) => __astTracker.getMetadata(v);\nglobalThis.__get_all_metadata = () => __astTracker.getAllMetadata();\nglobalThis.__check_provenance = (v) => __astTracker.checkProvenance(v);\n\nglobalThis.__mark_tainted = (value) => {\n\tif (__inTrackingCall) return value;\n\t__inTrackingCall = true;\n\ttry {\n\t\tconst digest = __astTracker.computeDigest(value);\n\t\tif (digest) {\n\t\t\tconst hintMeta = __astTracker.hints.get(digest);\n\t\t\tif (hintMeta) {\n\t\t\t\t__astTracker.registerTaintedPrimitive(value, hintMeta);\n\t\t\t\treturn value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (typeof value === 'string' && __astTracker.hintValues && __astTracker.hintValues.size > 0) {\n\t\t\tfor (const [hintValue, metadata] of __astTracker.hintValues.entries()) {\n\t\t\t\tif (value.includes(hintValue)) {\n\t\t\t\t\t__astTracker.registerTaintedPrimitive(value, metadata);\n\t\t\t\t\treturn value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} finally {\n\t\t__inTrackingCall = false;\n\t}\n\treturn value;\n};\n";
//# sourceMappingURL=ast-tracking-runtime.d.ts.map