unpeek 4.2.0 → 4.3.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.
Files changed (34) hide show
  1. package/README.md +2 -2
  2. package/README.tr.md +2 -2
  3. package/dist/adapters/esbuild.cjs +5 -5
  4. package/dist/adapters/esbuild.js +3 -3
  5. package/dist/adapters/next/adapter.cjs +5 -5
  6. package/dist/adapters/next/adapter.js +4 -4
  7. package/dist/adapters/next/index.cjs +5 -5
  8. package/dist/adapters/next/index.js +4 -4
  9. package/dist/adapters/rollup.cjs +5 -5
  10. package/dist/adapters/rollup.js +3 -3
  11. package/dist/adapters/rspack.cjs +5 -5
  12. package/dist/adapters/rspack.js +3 -3
  13. package/dist/adapters/vite.cjs +5 -5
  14. package/dist/adapters/vite.js +3 -3
  15. package/dist/adapters/webpack.cjs +5 -5
  16. package/dist/adapters/webpack.js +3 -3
  17. package/dist/browser.cjs +2 -2
  18. package/dist/browser.js +1 -1
  19. package/dist/{chunk-UUJLTW7O.cjs → chunk-4IRIMLT3.cjs} +16 -16
  20. package/dist/{chunk-AD6UFBPA.cjs → chunk-4XSFPX2Z.cjs} +367 -8
  21. package/dist/{chunk-KIAYVIC5.cjs → chunk-7F75S3GQ.cjs} +60 -36
  22. package/dist/{chunk-K77WRITN.js → chunk-EASD7C2B.js} +3 -3
  23. package/dist/{chunk-APQOBFRO.js → chunk-GKWTP4Z5.js} +30 -6
  24. package/dist/{chunk-MSECP2P4.cjs → chunk-OR5M3SN2.cjs} +1199 -428
  25. package/dist/{chunk-32GLSJAW.js → chunk-RDP4MTHK.js} +359 -0
  26. package/dist/{chunk-BL2UXZGD.js → chunk-RM3V7KJA.js} +1040 -269
  27. package/dist/{chunk-SJK45WAU.cjs → chunk-SBRU7GSX.cjs} +8 -8
  28. package/dist/{chunk-GCWXTWTN.js → chunk-XEYMZUP5.js} +2 -2
  29. package/dist/cli/index.js +1425 -274
  30. package/dist/index.cjs +21 -21
  31. package/dist/index.js +3 -3
  32. package/dist/plugins/unplugin.cjs +4 -4
  33. package/dist/plugins/unplugin.js +3 -3
  34. package/package.json +1 -1
@@ -2815,8 +2815,119 @@ var compactGenerator = Object.assign({}, _astring.baseGenerator, {
2815
2815
  this[node.options.type](node.options, state);
2816
2816
  }
2817
2817
  state.write(")");
2818
+ },
2819
+ ImportSpecifier(node, state) {
2820
+ writeModuleBindingName(this, node.imported, state);
2821
+ const sameIdent = _optionalChain([node, 'access', _239 => _239.imported, 'optionalAccess', _240 => _240.type]) === "Identifier" && _optionalChain([node, 'access', _241 => _241.local, 'optionalAccess', _242 => _242.type]) === "Identifier" && node.imported.name === node.local.name;
2822
+ if (!sameIdent && _optionalChain([node, 'access', _243 => _243.local, 'optionalAccess', _244 => _244.name])) {
2823
+ state.write(" as " + node.local.name);
2824
+ }
2825
+ },
2826
+ ExportSpecifier(node, state) {
2827
+ writeModuleBindingName(this, node.local, state);
2828
+ const sameIdent = _optionalChain([node, 'access', _245 => _245.local, 'optionalAccess', _246 => _246.type]) === "Identifier" && _optionalChain([node, 'access', _247 => _247.exported, 'optionalAccess', _248 => _248.type]) === "Identifier" && node.local.name === node.exported.name;
2829
+ if (!sameIdent && node.exported) {
2830
+ state.write(" as ");
2831
+ writeModuleBindingName(this, node.exported, state);
2832
+ }
2833
+ },
2834
+ ImportDeclaration(node, state) {
2835
+ state.write("import ");
2836
+ const specifiers = node.specifiers || [];
2837
+ const len = specifiers.length;
2838
+ let i = 0;
2839
+ if (len > 0) {
2840
+ while (i < len) {
2841
+ if (i > 0) state.write(", ");
2842
+ const spec = specifiers[i];
2843
+ const tag = spec.type[6];
2844
+ if (tag === "D") {
2845
+ state.write(spec.local.name, spec);
2846
+ i++;
2847
+ } else if (tag === "N") {
2848
+ state.write("* as " + spec.local.name, spec);
2849
+ i++;
2850
+ } else {
2851
+ break;
2852
+ }
2853
+ }
2854
+ if (i < len) {
2855
+ state.write("{");
2856
+ for (; ; ) {
2857
+ this.ImportSpecifier(specifiers[i], state);
2858
+ if (++i < len) {
2859
+ state.write(", ");
2860
+ } else {
2861
+ break;
2862
+ }
2863
+ }
2864
+ state.write("}");
2865
+ }
2866
+ state.write(" from ");
2867
+ }
2868
+ this.Literal(node.source, state);
2869
+ writeImportAttributes(this, node.attributes, state);
2870
+ state.write(";");
2871
+ },
2872
+ ExportNamedDeclaration(node, state) {
2873
+ state.write("export ");
2874
+ if (node.declaration) {
2875
+ this[node.declaration.type](node.declaration, state);
2876
+ return;
2877
+ }
2878
+ state.write("{");
2879
+ const specifiers = node.specifiers || [];
2880
+ const len = specifiers.length;
2881
+ if (len > 0) {
2882
+ for (let i = 0; ; ) {
2883
+ this.ExportSpecifier(specifiers[i], state);
2884
+ if (++i < len) {
2885
+ state.write(", ");
2886
+ } else {
2887
+ break;
2888
+ }
2889
+ }
2890
+ }
2891
+ state.write("}");
2892
+ if (node.source) {
2893
+ state.write(" from ");
2894
+ this.Literal(node.source, state);
2895
+ }
2896
+ writeImportAttributes(this, node.attributes, state);
2897
+ state.write(";");
2898
+ },
2899
+ ExportAllDeclaration(node, state) {
2900
+ if (node.exported == null) {
2901
+ state.write("export * from ");
2902
+ } else {
2903
+ state.write("export * as ");
2904
+ writeModuleBindingName(this, node.exported, state);
2905
+ state.write(" from ");
2906
+ }
2907
+ this.Literal(node.source, state);
2908
+ writeImportAttributes(this, node.attributes, state);
2909
+ state.write(";");
2818
2910
  }
2819
2911
  });
2912
+ function writeModuleBindingName(generator, node, state) {
2913
+ if (!node) return;
2914
+ if (node.type === "Literal") {
2915
+ generator.Literal(node, state);
2916
+ } else {
2917
+ state.write(node.name, node);
2918
+ }
2919
+ }
2920
+ function writeImportAttributes(generator, attributes, state) {
2921
+ if (!attributes || attributes.length === 0) return;
2922
+ state.write(" with { ");
2923
+ for (let i = 0; i < attributes.length; i++) {
2924
+ generator.ImportAttribute(attributes[i], state);
2925
+ if (i < attributes.length - 1) {
2926
+ state.write(", ");
2927
+ }
2928
+ }
2929
+ state.write(" }");
2930
+ }
2820
2931
  var VLQ_BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2821
2932
  function encodeVlq2(value) {
2822
2933
  let vlq = value < 0 ? (-value << 1) + 1 : value << 1;
@@ -3668,7 +3779,7 @@ function generateWasmKdfBinary(seed, options) {
3668
3779
  ...encodeUnsignedLeb128(typePayload.length),
3669
3780
  ...typePayload
3670
3781
  ];
3671
- const abi = _optionalChain([options, 'optionalAccess', _239 => _239.polymorphicAbi]) ? deriveWasmAbiNames(seed) : null;
3782
+ const abi = _optionalChain([options, 'optionalAccess', _249 => _249.polymorphicAbi]) ? deriveWasmAbiNames(seed) : null;
3672
3783
  const envModName = abi ? abi.envMod : "env";
3673
3784
  const gImportName = abi ? abi.gImport : "g";
3674
3785
  const mImportName = abi ? abi.mImport : "m";
@@ -3789,8 +3900,8 @@ function fallbackKdf(fnId, callSiteSalt, shieldHash, seed) {
3789
3900
  function isWasmVaultAlreadyInjected(ast) {
3790
3901
  if (!ast || !Array.isArray(ast.body)) return false;
3791
3902
  return ast.body.some((stmt) => {
3792
- if (stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _240 => _240.declarations, 'optionalAccess', _241 => _241.some, 'call', _242 => _242(
3793
- (d) => _optionalChain([d, 'access', _243 => _243.id, 'optionalAccess', _244 => _244.type]) === "Identifier" && typeof d.id.name === "string" && d.id.name.startsWith("_wKdf")
3903
+ if (stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _250 => _250.declarations, 'optionalAccess', _251 => _251.some, 'call', _252 => _252(
3904
+ (d) => _optionalChain([d, 'access', _253 => _253.id, 'optionalAccess', _254 => _254.type]) === "Identifier" && typeof d.id.name === "string" && d.id.name.startsWith("_wKdf")
3794
3905
  )])) {
3795
3906
  return true;
3796
3907
  }
@@ -3803,11 +3914,11 @@ function injectWasmVault(ast, seed = 2654435769) {
3803
3914
  const wasmVarName = `_wb${suffix}`;
3804
3915
  if (isWasmVaultAlreadyInjected(ast)) {
3805
3916
  const existing = ast.body.find(
3806
- (stmt) => stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _245 => _245.declarations, 'optionalAccess', _246 => _246.some, 'call', _247 => _247(
3807
- (d) => _optionalChain([d, 'access', _248 => _248.id, 'optionalAccess', _249 => _249.type]) === "Identifier" && typeof d.id.name === "string" && d.id.name.startsWith("_wKdf")
3917
+ (stmt) => stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _255 => _255.declarations, 'optionalAccess', _256 => _256.some, 'call', _257 => _257(
3918
+ (d) => _optionalChain([d, 'access', _258 => _258.id, 'optionalAccess', _259 => _259.type]) === "Identifier" && typeof d.id.name === "string" && d.id.name.startsWith("_wKdf")
3808
3919
  )])
3809
3920
  );
3810
- const id = _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _250 => _250.declarations, 'access', _251 => _251[0], 'optionalAccess', _252 => _252.id, 'optionalAccess', _253 => _253.name]), () => ( kdfFnName));
3921
+ const id = _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _260 => _260.declarations, 'access', _261 => _261[0], 'optionalAccess', _262 => _262.id, 'optionalAccess', _263 => _263.name]), () => ( kdfFnName));
3811
3922
  return {
3812
3923
  kdfFnName: id,
3813
3924
  wasmBytes: generateWasmKdfBinary(seed, { polymorphicAbi: true }),
@@ -3828,7 +3939,8 @@ function injectWasmVault(ast, seed = 2654435769) {
3828
3939
  const mChars = [105 ^ strKey, 109 ^ strKey, 117 ^ strKey, 108 ^ strKey].join(",");
3829
3940
  const helperSnippet = `var ${kdfFnName};
3830
3941
  (function(){
3831
- var _G = typeof globalThis < 'u' ? globalThis : typeof self < 'u' ? self : 0;
3942
+ var _G = typeof globalThis < 'u' ? globalThis : typeof self < 'u' ? self : typeof window < 'u' ? window : 0;
3943
+ var _M = (_G && _G.Math) || Math;
3832
3944
  var _reg = _G ? (_G.__unpeek_wasm_kdf || (_G.__unpeek_wasm_kdf = {})) : 0;
3833
3945
  if (_reg && _reg['${suffix}']) {
3834
3946
  ${kdfFnName} = _reg['${suffix}'];
@@ -3836,10 +3948,10 @@ function injectWasmVault(ast, seed = 2654435769) {
3836
3948
  }
3837
3949
  var _g = [${gArr.join(",")}];
3838
3950
  var _evR = function(x) {
3839
- return (${rA0} + Math.imul(x, (${rA1} + Math.imul(x, (${rA2} + Math.imul(${rA3}, x)) | 0)) | 0)) | 0;
3951
+ return (${rA0} + _M.imul(x, (${rA1} + _M.imul(x, (${rA2} + _M.imul(${rA3}, x)) | 0)) | 0)) | 0;
3840
3952
  };
3841
3953
  var _sb = function(b) {
3842
- return (Math.imul(167, b & 255) + ${sOff}) & 255;
3954
+ return (_M.imul(167, b & 255) + ${sOff}) & 255;
3843
3955
  };
3844
3956
  var _tk = ['__','unp','eek_t','ampered'].join('');
3845
3957
  var _eG = function(sl) {
@@ -3866,7 +3978,7 @@ function injectWasmVault(ast, seed = 2654435769) {
3866
3978
  for (var _i = 0; _i < _c.length; _i++) {
3867
3979
  _p += String.fromCharCode(_c[_i] ^ ${strKey});
3868
3980
  }
3869
- var _m = Math[_p];
3981
+ var _m = _M[_p];
3870
3982
  ${kdfFnName} = function(f, s, h) {
3871
3983
  var _x = (f ^ _k[2] ^ _k[3] ^ (_eG(0) ^ ${gMask})) | 0;
3872
3984
  _x = (_x ^ (_x >>> 16)) | 0;
@@ -3891,7 +4003,7 @@ function injectWasmVault(ast, seed = 2654435769) {
3891
4003
  let insertIdx = 0;
3892
4004
  while (insertIdx < ast.body.length) {
3893
4005
  const stmt = ast.body[insertIdx];
3894
- const isDirective = stmt.type === "ExpressionStatement" && (Boolean(stmt.directive) || _optionalChain([stmt, 'access', _254 => _254.expression, 'optionalAccess', _255 => _255.type]) === "Literal" && typeof stmt.expression.value === "string" && /^(?:use\s+[a-zA-Z0-9_-]+)/.test(stmt.expression.value.trim()));
4006
+ const isDirective = stmt.type === "ExpressionStatement" && (Boolean(stmt.directive) || _optionalChain([stmt, 'access', _264 => _264.expression, 'optionalAccess', _265 => _265.type]) === "Literal" && typeof stmt.expression.value === "string" && /^(?:use\s+[a-zA-Z0-9_-]+)/.test(stmt.expression.value.trim()));
3895
4007
  if (isDirective || stmt.type === "ImportDeclaration") {
3896
4008
  insertIdx++;
3897
4009
  } else {
@@ -3922,7 +4034,7 @@ function isWebpackModuleMap(node) {
3922
4034
  return false;
3923
4035
  }
3924
4036
  return node.properties.some(
3925
- (p) => _optionalChain([p, 'optionalAccess', _256 => _256.type]) === "Property" && (_optionalChain([p, 'access', _257 => _257.value, 'optionalAccess', _258 => _258.type]) === "FunctionExpression" || _optionalChain([p, 'access', _259 => _259.value, 'optionalAccess', _260 => _260.type]) === "ArrowFunctionExpression")
4037
+ (p) => _optionalChain([p, 'optionalAccess', _266 => _266.type]) === "Property" && (_optionalChain([p, 'access', _267 => _267.value, 'optionalAccess', _268 => _268.type]) === "FunctionExpression" || _optionalChain([p, 'access', _269 => _269.value, 'optionalAccess', _270 => _270.type]) === "ArrowFunctionExpression")
3926
4038
  );
3927
4039
  }
3928
4040
  function exemptWebpackPushArg(arg, exemptSubtreeRoots) {
@@ -3942,9 +4054,9 @@ function exemptWebpackPushArg(arg, exemptSubtreeRoots) {
3942
4054
  exemptSubtreeRoots.add(arg);
3943
4055
  }
3944
4056
  function exemptTurbopackPropertyKeys(objNode, exemptSubtreeRoots) {
3945
- if (!Array.isArray(_optionalChain([objNode, 'optionalAccess', _261 => _261.properties]))) return;
4057
+ if (!Array.isArray(_optionalChain([objNode, 'optionalAccess', _271 => _271.properties]))) return;
3946
4058
  for (const prop of objNode.properties) {
3947
- if (_optionalChain([prop, 'optionalAccess', _262 => _262.type]) === "Property" && prop.key && typeof prop.key === "object") {
4059
+ if (_optionalChain([prop, 'optionalAccess', _272 => _272.type]) === "Property" && prop.key && typeof prop.key === "object") {
3948
4060
  exemptSubtreeRoots.add(prop.key);
3949
4061
  }
3950
4062
  }
@@ -3983,11 +4095,11 @@ function isHostMember(node, matcher) {
3983
4095
  if (node.type === "Identifier" && matchesPropName(node.name, matcher)) {
3984
4096
  return true;
3985
4097
  }
3986
- if (node.type === "MemberExpression" && (_optionalChain([node, 'access', _263 => _263.object, 'optionalAccess', _264 => _264.type]) === "Identifier" && GLOBAL_HOSTS.has(node.object.name) || _optionalChain([node, 'access', _265 => _265.object, 'optionalAccess', _266 => _266.type]) === "ThisExpression")) {
3987
- if (!node.computed && _optionalChain([node, 'access', _267 => _267.property, 'optionalAccess', _268 => _268.type]) === "Identifier") {
4098
+ if (node.type === "MemberExpression" && (_optionalChain([node, 'access', _273 => _273.object, 'optionalAccess', _274 => _274.type]) === "Identifier" && GLOBAL_HOSTS.has(node.object.name) || _optionalChain([node, 'access', _275 => _275.object, 'optionalAccess', _276 => _276.type]) === "ThisExpression")) {
4099
+ if (!node.computed && _optionalChain([node, 'access', _277 => _277.property, 'optionalAccess', _278 => _278.type]) === "Identifier") {
3988
4100
  return matchesPropName(node.property.name, matcher);
3989
4101
  }
3990
- if (node.computed && _optionalChain([node, 'access', _269 => _269.property, 'optionalAccess', _270 => _270.type]) === "Literal" && typeof node.property.value === "string") {
4102
+ if (node.computed && _optionalChain([node, 'access', _279 => _279.property, 'optionalAccess', _280 => _280.type]) === "Literal" && typeof node.property.value === "string") {
3991
4103
  return matchesPropName(node.property.value, matcher);
3992
4104
  }
3993
4105
  }
@@ -4013,6 +4125,61 @@ function unwrapAssignedHostMember(node, matcher, depth = 0) {
4013
4125
  return false;
4014
4126
  }
4015
4127
  }
4128
+ function isImportMetaMember(node, propName) {
4129
+ if (!node || node.type !== "MemberExpression") return false;
4130
+ const obj = node.object;
4131
+ if (_optionalChain([obj, 'optionalAccess', _281 => _281.type]) !== "MetaProperty" || _optionalChain([obj, 'access', _282 => _282.meta, 'optionalAccess', _283 => _283.type]) !== "Identifier" || obj.meta.name !== "import" || _optionalChain([obj, 'access', _284 => _284.property, 'optionalAccess', _285 => _285.type]) !== "Identifier" || obj.property.name !== "meta") {
4132
+ return false;
4133
+ }
4134
+ if (!node.computed && _optionalChain([node, 'access', _286 => _286.property, 'optionalAccess', _287 => _287.type]) === "Identifier") {
4135
+ return node.property.name === propName;
4136
+ }
4137
+ return node.computed && _optionalChain([node, 'access', _288 => _288.property, 'optionalAccess', _289 => _289.type]) === "Literal" && node.property.value === propName;
4138
+ }
4139
+ function isRequireResolveCallee(callee) {
4140
+ if (!callee || callee.type !== "MemberExpression") return false;
4141
+ if (_optionalChain([callee, 'access', _290 => _290.object, 'optionalAccess', _291 => _291.type]) !== "Identifier" || callee.object.name !== "require") {
4142
+ return false;
4143
+ }
4144
+ if (!callee.computed && _optionalChain([callee, 'access', _292 => _292.property, 'optionalAccess', _293 => _293.type]) === "Identifier") {
4145
+ return callee.property.name === "resolve";
4146
+ }
4147
+ return callee.computed && _optionalChain([callee, 'access', _294 => _294.property, 'optionalAccess', _295 => _295.type]) === "Literal" && callee.property.value === "resolve";
4148
+ }
4149
+ function isStaticModuleOrAssetPosition(node, parent) {
4150
+ if (!node || !parent) return false;
4151
+ if (parent.type === "ImportDeclaration" || parent.type === "ExportNamedDeclaration") {
4152
+ return parent.source === node;
4153
+ }
4154
+ if (parent.type === "ExportAllDeclaration") {
4155
+ return parent.source === node || parent.exported === node;
4156
+ }
4157
+ if (parent.type === "ImportExpression") {
4158
+ return parent.source === node;
4159
+ }
4160
+ if (parent.type === "ImportSpecifier") {
4161
+ return parent.imported === node;
4162
+ }
4163
+ if (parent.type === "ExportSpecifier") {
4164
+ return parent.local === node || parent.exported === node;
4165
+ }
4166
+ if (parent.type === "ImportAttribute") {
4167
+ return true;
4168
+ }
4169
+ if (parent.type === "NewExpression") {
4170
+ return _optionalChain([parent, 'access', _296 => _296.callee, 'optionalAccess', _297 => _297.type]) === "Identifier" && parent.callee.name === "URL" && Array.isArray(parent.arguments) && parent.arguments.length >= 2 && parent.arguments[0] === node && isImportMetaMember(parent.arguments[1], "url");
4171
+ }
4172
+ if (parent.type === "CallExpression") {
4173
+ if (!Array.isArray(parent.arguments) || parent.arguments[0] !== node) {
4174
+ return false;
4175
+ }
4176
+ const callee = parent.callee;
4177
+ if (isImportMetaMember(callee, "resolve")) return true;
4178
+ if (isRequireResolveCallee(callee)) return true;
4179
+ if (_optionalChain([callee, 'optionalAccess', _298 => _298.type]) === "Identifier" && callee.name === "require") return true;
4180
+ }
4181
+ return false;
4182
+ }
4016
4183
  function classifyChunkBoundary(ast) {
4017
4184
  const exemptSubtreeRoots = /* @__PURE__ */ new WeakSet();
4018
4185
  const importSourceNodes = /* @__PURE__ */ new WeakSet();
@@ -4022,8 +4189,12 @@ function classifyChunkBoundary(ast) {
4022
4189
  let hasPreloadManifest = false;
4023
4190
  walk2.simple(ast, {
4024
4191
  CallExpression(node) {
4192
+ const firstArg = Array.isArray(node.arguments) ? node.arguments[0] : void 0;
4193
+ if (firstArg && (firstArg.type === "Literal" || firstArg.type === "TemplateLiteral") && isStaticModuleOrAssetPosition(firstArg, node)) {
4194
+ exemptSubtreeRoots.add(firstArg);
4195
+ }
4025
4196
  const callee = node.callee;
4026
- const isPushCall = _optionalChain([callee, 'optionalAccess', _271 => _271.type]) === "MemberExpression" && (!callee.computed && _optionalChain([callee, 'access', _272 => _272.property, 'optionalAccess', _273 => _273.type]) === "Identifier" && callee.property.name === "push" || callee.computed && _optionalChain([callee, 'access', _274 => _274.property, 'optionalAccess', _275 => _275.type]) === "Literal" && callee.property.value === "push");
4197
+ const isPushCall = _optionalChain([callee, 'optionalAccess', _299 => _299.type]) === "MemberExpression" && (!callee.computed && _optionalChain([callee, 'access', _300 => _300.property, 'optionalAccess', _301 => _301.type]) === "Identifier" && callee.property.name === "push" || callee.computed && _optionalChain([callee, 'access', _302 => _302.property, 'optionalAccess', _303 => _303.type]) === "Literal" && callee.property.value === "push");
4027
4198
  if (isPushCall) {
4028
4199
  if (unwrapAssignedHostMember(callee.object, "__next_f")) {
4029
4200
  hasRscFlight = true;
@@ -4063,13 +4234,13 @@ function classifyChunkBoundary(ast) {
4063
4234
  if (isHostMember(node.left, "TURBOPACK") || isHostMember(node.left, isWebpackOrRspackChunkName)) {
4064
4235
  hasEntryBootstrap = true;
4065
4236
  exemptSubtreeRoots.add(node);
4066
- } else if (_optionalChain([node, 'access', _276 => _276.left, 'optionalAccess', _277 => _277.type]) === "Identifier" && node.left.name === "__vite__mapDeps") {
4237
+ } else if (_optionalChain([node, 'access', _304 => _304.left, 'optionalAccess', _305 => _305.type]) === "Identifier" && node.left.name === "__vite__mapDeps") {
4067
4238
  hasPreloadManifest = true;
4068
4239
  exemptSubtreeRoots.add(node);
4069
4240
  }
4070
4241
  },
4071
4242
  VariableDeclarator(node) {
4072
- if (_optionalChain([node, 'access', _278 => _278.id, 'optionalAccess', _279 => _279.type]) === "Identifier") {
4243
+ if (_optionalChain([node, 'access', _306 => _306.id, 'optionalAccess', _307 => _307.type]) === "Identifier") {
4073
4244
  if (node.id.name === "__vite__mapDeps") {
4074
4245
  hasPreloadManifest = true;
4075
4246
  exemptSubtreeRoots.add(node);
@@ -4080,11 +4251,54 @@ function classifyChunkBoundary(ast) {
4080
4251
  }
4081
4252
  },
4082
4253
  FunctionDeclaration(node) {
4083
- if (_optionalChain([node, 'access', _280 => _280.id, 'optionalAccess', _281 => _281.type]) === "Identifier" && node.id.name === "__vite__mapDeps") {
4254
+ if (_optionalChain([node, 'access', _308 => _308.id, 'optionalAccess', _309 => _309.type]) === "Identifier" && node.id.name === "__vite__mapDeps") {
4084
4255
  hasPreloadManifest = true;
4085
4256
  exemptSubtreeRoots.add(node);
4086
4257
  }
4087
4258
  },
4259
+ NewExpression(node) {
4260
+ const firstArg = Array.isArray(node.arguments) ? node.arguments[0] : void 0;
4261
+ if (firstArg && (firstArg.type === "Literal" || firstArg.type === "TemplateLiteral") && isStaticModuleOrAssetPosition(firstArg, node)) {
4262
+ exemptSubtreeRoots.add(firstArg);
4263
+ }
4264
+ },
4265
+ ImportDeclaration(node) {
4266
+ if (node.source && typeof node.source === "object") {
4267
+ exemptSubtreeRoots.add(node.source);
4268
+ }
4269
+ if (Array.isArray(node.specifiers)) {
4270
+ for (const spec of node.specifiers) {
4271
+ if (_optionalChain([spec, 'optionalAccess', _310 => _310.type]) === "ImportSpecifier" && _optionalChain([spec, 'access', _311 => _311.imported, 'optionalAccess', _312 => _312.type]) === "Literal") {
4272
+ exemptSubtreeRoots.add(spec.imported);
4273
+ }
4274
+ }
4275
+ }
4276
+ },
4277
+ ExportNamedDeclaration(node) {
4278
+ if (node.source && typeof node.source === "object") {
4279
+ exemptSubtreeRoots.add(node.source);
4280
+ }
4281
+ if (Array.isArray(node.specifiers)) {
4282
+ for (const spec of node.specifiers) {
4283
+ if (_optionalChain([spec, 'optionalAccess', _313 => _313.type]) === "ExportSpecifier") {
4284
+ if (_optionalChain([spec, 'access', _314 => _314.local, 'optionalAccess', _315 => _315.type]) === "Literal") {
4285
+ exemptSubtreeRoots.add(spec.local);
4286
+ }
4287
+ if (_optionalChain([spec, 'access', _316 => _316.exported, 'optionalAccess', _317 => _317.type]) === "Literal") {
4288
+ exemptSubtreeRoots.add(spec.exported);
4289
+ }
4290
+ }
4291
+ }
4292
+ }
4293
+ },
4294
+ ExportAllDeclaration(node) {
4295
+ if (node.source && typeof node.source === "object") {
4296
+ exemptSubtreeRoots.add(node.source);
4297
+ }
4298
+ if (node.exported && typeof node.exported === "object") {
4299
+ exemptSubtreeRoots.add(node.exported);
4300
+ }
4301
+ },
4088
4302
  ImportExpression(node) {
4089
4303
  importExpressions.push(node);
4090
4304
  if (node.source && typeof node.source === "object") {
@@ -4122,7 +4336,7 @@ function attachMagicComments(importExpressions, comments) {
4122
4336
  const magicComments = comments.filter((c) => MAGIC_COMMENT_RE.test(c.value));
4123
4337
  if (magicComments.length === 0) return;
4124
4338
  for (const expr of importExpressions) {
4125
- const src = _optionalChain([expr, 'optionalAccess', _282 => _282.source]);
4339
+ const src = _optionalChain([expr, 'optionalAccess', _318 => _318.source]);
4126
4340
  if (!src || typeof expr.start !== "number" || typeof src.start !== "number") {
4127
4341
  continue;
4128
4342
  }
@@ -4154,22 +4368,36 @@ function buildRivestDeltaExpr(seed, expectedDelta, varName = "_ed") {
4154
4368
  const xMasked = xEnc ^ xMask | 0;
4155
4369
  return `var _rx=(${xMasked}^${xMask | 0})|0,${varName}=(${rA0}+Math.imul(_rx,(${rA1}+Math.imul(_rx,(${rA2}+Math.imul(${rA3},_rx))|0))|0))&65535;`;
4156
4370
  }
4157
- function createSaltedDecryptorFnAst(seed, pChars, expectedDelta, windowKeySymbol, safeAlpha = SAFE_ALPHA, shieldCoupled = true, _browserOnly = false) {
4371
+ function buildLatchInitSnippet(seed, latchCoupling) {
4372
+ if (!latchCoupling || typeof latchCoupling.latchFnName !== "string" || !/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(latchCoupling.latchFnName)) {
4373
+ return { hasLatch: false, latchDecl: "" };
4374
+ }
4375
+ const tamperByte = seed >>> 8 & 127 | 53;
4376
+ const expectedLatch = latchCoupling.expectedLatchByte & 255;
4377
+ return {
4378
+ hasLatch: true,
4379
+ latchDecl: `var _ld=typeof ${latchCoupling.latchFnName}==="function"?((${latchCoupling.latchFnName}()^${expectedLatch})&255):${tamperByte};`
4380
+ };
4381
+ }
4382
+ function createSaltedDecryptorFnAst(seed, pChars, expectedDelta, windowKeySymbol, safeAlpha = SAFE_ALPHA, shieldCoupled = true, _browserOnly = false, latchCoupling) {
4158
4383
  const propAccess = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(windowKeySymbol) ? `.${windowKeySymbol}` : `[${JSON.stringify(windowKeySymbol)}]`;
4159
4384
  const stateSym = `${windowKeySymbol}_s`;
4160
4385
  const stateAccess = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(stateSym) ? `.${stateSym}` : `[${JSON.stringify(stateSym)}]`;
4161
4386
  const flagSym = `${windowKeySymbol}_t`;
4162
4387
  const flagAccess = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(flagSym) ? `.${flagSym}` : `[${JSON.stringify(flagSym)}]`;
4163
4388
  const tkExpr = `['__','unp','eek_t','ampered'].join('')`;
4389
+ const { hasLatch, latchDecl } = buildLatchInitSnippet(seed, latchCoupling);
4390
+ const charEmit = hasLatch ? `o+=String.fromCharCode((k<0?ch:A[(A.indexOf(P[(k-(t&65535)%92+92)%92])-(t>>>16)%92+92)%92]).charCodeAt(0)^_ld);` : `o+=k<0?ch:A[(A.indexOf(P[(k-(t&65535)%92+92)%92])-(t>>>16)%92+92)%92];`;
4391
+ const cacheGuardSuffix = hasLatch ? "&&!_ld" : "";
4164
4392
  let fBody;
4165
4393
  if (!shieldCoupled) {
4166
- fBody = `var m=[],c=Function.prototype.toString.call(f),_tk=${tkExpr};for(var h=0x811c9dc5,j=0;j<c.length;j++)h=Math.imul(h^c.charCodeAt(j),0x01000193)>>>0;var A="${safeAlpha}",P="${pChars}";return function(i,s){var G=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:this;var w=typeof window<"u"?window:typeof self<"u"?self:0;var tm=(G&&(G[_tk]===!0||G${flagAccess}===!0))||(w&&(w[_tk]===!0||w${flagAccess}===!0))||((""._u||a._u||0)!==0);if(!tm&&(i in m))return m[i];var d=tm?(((Math.imul(i+1,0x9e3779b1)^0x5a5b)&65535)|1):0;var q=(h^(""._u||a._u||0)^d)>>>0,p=a[i],o="";if(p)for(var t=q^s^Math.imul(i+1,0x01000193),j=0;j<p.length;j++){t=Math.imul(t^j+1,0x01000193)^0x811c9dc5;var ch=p[j],k=A.indexOf(ch);o+=k<0?ch:A[(A.indexOf(P[(k-(t&65535)%92+92)%92])-(t>>>16)%92+92)%92];}if(!tm)m[i]=o;return o;};`;
4394
+ fBody = `var m=[],c=Function.prototype.toString.call(f),_tk=${tkExpr};for(var h=0x811c9dc5,j=0;j<c.length;j++)h=Math.imul(h^c.charCodeAt(j),0x01000193)>>>0;var A="${safeAlpha}",P="${pChars}";return function(i,s){var G=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:this;var w=typeof window<"u"?window:typeof self<"u"?self:0;var tm=(G&&(G[_tk]===!0||G${flagAccess}===!0))||(w&&(w[_tk]===!0||w${flagAccess}===!0))||((""._u||a._u||0)!==0);if(!tm&&(i in m))return m[i];` + latchDecl + `var d=tm?(((Math.imul(i+1,0x9e3779b1)^0x5a5b)&65535)|1):0;var q=(h^(""._u||a._u||0)^d)>>>0,p=a[i],o="";if(p)for(var t=q^s^Math.imul(i+1,0x01000193),j=0;j<p.length;j++){t=Math.imul(t^j+1,0x01000193)^0x811c9dc5;var ch=p[j],k=A.indexOf(ch);` + charEmit + `}if(!tm${cacheGuardSuffix})m[i]=o;return o;};`;
4167
4395
  } else {
4168
4396
  const edInit = buildRivestDeltaExpr(seed, expectedDelta, "_ed");
4169
4397
  const hasWindowKey = Boolean(windowKeySymbol);
4170
4398
  const brDecl = hasWindowKey ? NARROWED_ASYNC_BR_DECL : "";
4171
4399
  const svCheck = hasWindowKey ? `(sv===void 0?!_br:sv!==_ed)` : `(sv!==void 0&&sv!==_ed)`;
4172
- fBody = `var m=[],c=Function.prototype.toString.call(f),_tk=${tkExpr};for(var h=0x811c9dc5,j=0;j<c.length;j++)h=Math.imul(h^c.charCodeAt(j),0x01000193)>>>0;var A="${safeAlpha}",P="${pChars}";${edInit}return function(i,s){var G=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:this;var w=typeof window<"u"?window:typeof self<"u"?self:0;` + brDecl + `var sv=G&&G${propAccess}!==void 0?G${propAccess}:w&&w${propAccess}!==void 0?w${propAccess}:void 0;var sr=G&&G${stateAccess}?G${stateAccess}:w&&w${stateAccess}?w${stateAccess}:void 0;var tm=(G&&(G[_tk]===!0||G${flagAccess}===!0))||(w&&(w[_tk]===!0||w${flagAccess}===!0))||(sr&&sr[0]===2)||((""._u||a._u||0)!==0)||${svCheck};if(!tm&&sv===_ed&&(i in m))return m[i];var d=tm?((_ed^(((Math.imul(i+1,0x9e3779b1)^0x5a5b)&65535)|1))&65535):_ed;var q=(h^(""._u||a._u||0)^d)>>>0,p=a[i],o="";if(p)for(var t=q^s^Math.imul(i+1,0x01000193),j=0;j<p.length;j++){t=Math.imul(t^j+1,0x01000193)^0x811c9dc5;var ch=p[j],k=A.indexOf(ch);o+=k<0?ch:A[(A.indexOf(P[(k-(t&65535)%92+92)%92])-(t>>>16)%92+92)%92];}if(!tm&&sv===_ed)m[i]=o;return o;};`;
4400
+ fBody = `var m=[],c=Function.prototype.toString.call(f),_tk=${tkExpr};for(var h=0x811c9dc5,j=0;j<c.length;j++)h=Math.imul(h^c.charCodeAt(j),0x01000193)>>>0;var A="${safeAlpha}",P="${pChars}";${edInit}return function(i,s){var G=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:this;var w=typeof window<"u"?window:typeof self<"u"?self:0;` + brDecl + `var sv=G&&G${propAccess}!==void 0?G${propAccess}:w&&w${propAccess}!==void 0?w${propAccess}:void 0;var sr=G&&G${stateAccess}?G${stateAccess}:w&&w${stateAccess}?w${stateAccess}:void 0;var tm=(G&&(G[_tk]===!0||G${flagAccess}===!0))||(w&&(w[_tk]===!0||w${flagAccess}===!0))||(sr&&sr[0]===2)||((""._u||a._u||0)!==0)||${svCheck};if(!tm&&sv===_ed&&(i in m))return m[i];` + latchDecl + `var d=tm?((_ed^(((Math.imul(i+1,0x9e3779b1)^0x5a5b)&65535)|1))&65535):_ed;var q=(h^(""._u||a._u||0)^d)>>>0,p=a[i],o="";if(p)for(var t=q^s^Math.imul(i+1,0x01000193),j=0;j<p.length;j++){t=Math.imul(t^j+1,0x01000193)^0x811c9dc5;var ch=p[j],k=A.indexOf(ch);` + charEmit + `}if(!tm&&sv===_ed${cacheGuardSuffix})m[i]=o;return o;};`;
4173
4401
  }
4174
4402
  return acorn3.parse(`(function f(a){${fBody}})`, {
4175
4403
  ecmaVersion: "latest",
@@ -4217,8 +4445,8 @@ function encodeSaltedString(str, k) {
4217
4445
  function isAstAlreadySalted(ast) {
4218
4446
  if (!ast || !Array.isArray(ast.body)) return false;
4219
4447
  return ast.body.some((stmt) => {
4220
- if (stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _283 => _283.declarations, 'optionalAccess', _284 => _284.some, 'call', _285 => _285(
4221
- (d) => _optionalChain([d, 'access', _286 => _286.id, 'optionalAccess', _287 => _287.type]) === "Identifier" && typeof d.id.name === "string" && (d.id.name.startsWith("_uP") || _optionalChain([d, 'access', _288 => _288.init, 'optionalAccess', _289 => _289.type]) === "CallExpression" && _optionalChain([d, 'access', _290 => _290.init, 'access', _291 => _291.callee, 'optionalAccess', _292 => _292.type]) === "FunctionExpression" && _optionalChain([d, 'access', _293 => _293.init, 'access', _294 => _294.callee, 'optionalAccess', _295 => _295.id, 'optionalAccess', _296 => _296.name]) === "f" && _optionalChain([d, 'access', _297 => _297.init, 'access', _298 => _298.arguments, 'optionalAccess', _299 => _299[0], 'optionalAccess', _300 => _300.type]) === "ArrayExpression")
4448
+ if (stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _319 => _319.declarations, 'optionalAccess', _320 => _320.some, 'call', _321 => _321(
4449
+ (d) => _optionalChain([d, 'access', _322 => _322.id, 'optionalAccess', _323 => _323.type]) === "Identifier" && typeof d.id.name === "string" && (d.id.name.startsWith("_uP") || _optionalChain([d, 'access', _324 => _324.init, 'optionalAccess', _325 => _325.type]) === "CallExpression" && _optionalChain([d, 'access', _326 => _326.init, 'access', _327 => _327.callee, 'optionalAccess', _328 => _328.type]) === "FunctionExpression" && _optionalChain([d, 'access', _329 => _329.init, 'access', _330 => _330.callee, 'optionalAccess', _331 => _331.id, 'optionalAccess', _332 => _332.name]) === "f" && _optionalChain([d, 'access', _333 => _333.init, 'access', _334 => _334.arguments, 'optionalAccess', _335 => _335[0], 'optionalAccess', _336 => _336.type]) === "ArrayExpression")
4222
4450
  )])) {
4223
4451
  return true;
4224
4452
  }
@@ -4243,7 +4471,7 @@ function replaceNodeInParent(parent, oldNode, newNode) {
4243
4471
  }
4244
4472
  return false;
4245
4473
  }
4246
- function applySaltedStringVault(ast, seed = 2654435769, minStringLength = 4, hotExemptNodes, config, windowKeySymbol, expectedDelta, deterrentMode, shieldCoupled = true, detectHeadless = false, exemptSubtreeRoots) {
4474
+ function applySaltedStringVault(ast, seed = 2654435769, minStringLength = 4, hotExemptNodes, config, windowKeySymbol, expectedDelta, deterrentMode, shieldCoupled = true, detectHeadless = false, exemptSubtreeRoots, latchCoupling) {
4247
4475
  if (isAstAlreadySalted(ast)) {
4248
4476
  return {
4249
4477
  encryptedStringsCount: 0,
@@ -4253,14 +4481,14 @@ function applySaltedStringVault(ast, seed = 2654435769, minStringLength = 4, hot
4253
4481
  shaderBuffersCount: 0
4254
4482
  };
4255
4483
  }
4256
- const minLen = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _301 => _301.vault, 'optionalAccess', _302 => _302.minStringLength]), () => ( minStringLength));
4484
+ const minLen = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _337 => _337.vault, 'optionalAccess', _338 => _338.minStringLength]), () => ( minStringLength));
4257
4485
  const activeDirectives = new Set(DIRECTIVE_STRINGS);
4258
- if (_optionalChain([config, 'optionalAccess', _303 => _303.vault, 'optionalAccess', _304 => _304.customDirectives])) {
4486
+ if (_optionalChain([config, 'optionalAccess', _339 => _339.vault, 'optionalAccess', _340 => _340.customDirectives])) {
4259
4487
  for (const dir of config.vault.customDirectives) {
4260
4488
  activeDirectives.add(dir);
4261
4489
  }
4262
4490
  }
4263
- const customReserved = _optionalChain([config, 'optionalAccess', _305 => _305.vault, 'optionalAccess', _306 => _306.reservedProps]) ? new Set(config.vault.reservedProps) : void 0;
4491
+ const customReserved = _optionalChain([config, 'optionalAccess', _341 => _341.vault, 'optionalAccess', _342 => _342.reservedProps]) ? new Set(config.vault.reservedProps) : void 0;
4264
4492
  const targetsToReplace = [];
4265
4493
  const encryptedPayloads = [];
4266
4494
  const shaderToIndex = /* @__PURE__ */ new Map();
@@ -4343,86 +4571,89 @@ function applySaltedStringVault(ast, seed = 2654435769, minStringLength = 4, hot
4343
4571
  pushSaltedTarget(val, node, parent, onReplace ? { onReplace } : void 0);
4344
4572
  return true;
4345
4573
  }
4346
- walk3.ancestor(ast, {
4347
- Literal(node, ancestors) {
4348
- if (node.regex) {
4349
- if (isEligibleSecretRegExp(
4350
- node,
4351
- ancestors,
4352
- hotExemptNodes,
4353
- exemptSubtreeRoots,
4354
- getRegExpShadowedScopes
4355
- )) {
4356
- pushSaltedTarget(
4357
- node.regex.pattern,
4574
+ walk3.ancestor(
4575
+ ast,
4576
+ {
4577
+ Literal(node, _state, ancestors) {
4578
+ if (node.regex) {
4579
+ if (isEligibleSecretRegExp(
4358
4580
  node,
4359
- ancestors[ancestors.length - 2],
4360
- {
4361
- replaceMode: "regexp",
4362
- flags: _nullishCoalesce(node.regex.flags, () => ( ""))
4363
- }
4364
- );
4581
+ ancestors,
4582
+ hotExemptNodes,
4583
+ exemptSubtreeRoots,
4584
+ getRegExpShadowedScopes
4585
+ )) {
4586
+ pushSaltedTarget(
4587
+ node.regex.pattern,
4588
+ node,
4589
+ ancestors[ancestors.length - 2],
4590
+ {
4591
+ replaceMode: "regexp",
4592
+ flags: _nullishCoalesce(node.regex.flags, () => ( ""))
4593
+ }
4594
+ );
4595
+ }
4596
+ return;
4597
+ }
4598
+ if (typeof node.value !== "string") return;
4599
+ const val = node.value;
4600
+ if (activeDirectives.has(val)) return;
4601
+ const parent = ancestors[ancestors.length - 2];
4602
+ if (!parent) return;
4603
+ if (isStaticModuleOrAssetPosition(node, parent)) {
4604
+ return;
4605
+ }
4606
+ if (parent.type === "Property" && parent.key === node && !parent.computed) {
4607
+ if (!isEligibleObjectPropertyKey(val, node, parent, ancestors)) {
4608
+ return;
4609
+ }
4610
+ }
4611
+ if ((parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") && parent.key === node && !parent.computed) {
4612
+ return;
4365
4613
  }
4366
- return;
4367
- }
4368
- if (typeof node.value !== "string") return;
4369
- const val = node.value;
4370
- if (activeDirectives.has(val)) return;
4371
- const parent = ancestors[ancestors.length - 2];
4372
- if (!parent) return;
4373
- if ((parent.type === "ImportDeclaration" || parent.type === "ExportNamedDeclaration" || parent.type === "ExportAllDeclaration" || parent.type === "ImportExpression") && parent.source === node) {
4374
- return;
4375
- }
4376
- if (parent.type === "Property" && parent.key === node && !parent.computed) {
4377
- return;
4378
- }
4379
- if ((parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") && parent.key === node && !parent.computed) {
4380
- return;
4381
- }
4382
- if (parent.type === "ImportAttribute" || parent.type === "ImportSpecifier" || parent.type === "ExportSpecifier") {
4383
- return;
4384
- }
4385
- processSaltedCandidate(val, node, parent, ancestors);
4386
- },
4387
- TemplateLiteral(node, ancestors) {
4388
- if (!Array.isArray(node.quasis) || node.quasis.length === 0) return;
4389
- const parent = ancestors[ancestors.length - 2];
4390
- if (isExemptTemplateLiteral(node, parent)) return;
4391
- const exprCount = Array.isArray(node.expressions) ? node.expressions.length : 0;
4392
- if (exprCount === 0) {
4393
- if (node.quasis.length !== 1) return;
4394
- const val = _nullishCoalesce(node.quasis[0].value.cooked, () => ( node.quasis[0].value.raw));
4395
- if (typeof val !== "string" || activeDirectives.has(val)) return;
4396
4614
  processSaltedCandidate(val, node, parent, ancestors);
4397
- return;
4398
- }
4399
- if (node.quasis.length !== exprCount + 1) return;
4400
- if (node.quasis.some((q) => typeof _optionalChain([q, 'optionalAccess', _307 => _307.value, 'optionalAccess', _308 => _308.cooked]) !== "string")) {
4401
- return;
4402
- }
4403
- const replacements = /* @__PURE__ */ new Map();
4404
- let queuedCount = 0;
4405
- for (let qIdx = 0; qIdx < node.quasis.length; qIdx++) {
4406
- const val = node.quasis[qIdx].value.cooked;
4407
- if (activeDirectives.has(val)) continue;
4408
- const queued = processSaltedCandidate(
4409
- val,
4410
- node,
4411
- parent,
4412
- ancestors,
4413
- (exprAst) => {
4414
- replacements.set(qIdx, exprAst);
4615
+ },
4616
+ TemplateLiteral(node, _state, ancestors) {
4617
+ if (!Array.isArray(node.quasis) || node.quasis.length === 0) return;
4618
+ const parent = ancestors[ancestors.length - 2];
4619
+ if (isExemptTemplateLiteral(node, parent)) return;
4620
+ const exprCount = Array.isArray(node.expressions) ? node.expressions.length : 0;
4621
+ if (exprCount === 0) {
4622
+ if (node.quasis.length !== 1) return;
4623
+ const val = _nullishCoalesce(node.quasis[0].value.cooked, () => ( node.quasis[0].value.raw));
4624
+ if (typeof val !== "string" || activeDirectives.has(val)) return;
4625
+ processSaltedCandidate(val, node, parent, ancestors);
4626
+ return;
4627
+ }
4628
+ if (node.quasis.length !== exprCount + 1) return;
4629
+ if (node.quasis.some((q) => typeof _optionalChain([q, 'optionalAccess', _343 => _343.value, 'optionalAccess', _344 => _344.cooked]) !== "string")) {
4630
+ return;
4631
+ }
4632
+ const replacements = /* @__PURE__ */ new Map();
4633
+ let queuedCount = 0;
4634
+ for (let qIdx = 0; qIdx < node.quasis.length; qIdx++) {
4635
+ const val = node.quasis[qIdx].value.cooked;
4636
+ if (activeDirectives.has(val)) continue;
4637
+ const queued = processSaltedCandidate(
4638
+ val,
4639
+ node,
4640
+ parent,
4641
+ ancestors,
4642
+ (exprAst) => {
4643
+ replacements.set(qIdx, exprAst);
4644
+ }
4645
+ );
4646
+ if (queued) {
4647
+ queuedCount++;
4415
4648
  }
4416
- );
4417
- if (queued) {
4418
- queuedCount++;
4649
+ }
4650
+ if (queuedCount > 0) {
4651
+ interpolatedTemplates.push({ node, replacements });
4419
4652
  }
4420
4653
  }
4421
- if (queuedCount > 0) {
4422
- interpolatedTemplates.push({ node, replacements });
4423
- }
4424
- }
4425
- });
4654
+ },
4655
+ VAULT_WALK_BASE
4656
+ );
4426
4657
  if (targetsToReplace.length === 0 && shaderTargets.length === 0) {
4427
4658
  return {
4428
4659
  encryptedStringsCount: 0,
@@ -4461,15 +4692,18 @@ function applySaltedStringVault(ast, seed = 2654435769, minStringLength = 4, hot
4461
4692
  const flagAccess = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(flagSym) ? `.${flagSym}` : `[${JSON.stringify(flagSym)}]`;
4462
4693
  const tkExpr = `['__','unp','eek_t','ampered'].join('')`;
4463
4694
  const dkExpr = `['__','unp','eek_d','elta'].join('')`;
4695
+ const { hasLatch, latchDecl } = buildLatchInitSnippet(seed, latchCoupling);
4696
+ const charMaskXor = hasLatch ? "^_ld" : "";
4697
+ const cacheGuardSuffix = hasLatch ? "&&!_ld" : "";
4464
4698
  let helperFnSnippet;
4465
4699
  if (!shieldCoupled) {
4466
- helperFnSnippet = `function ${decryptFnName}(i,s){var G=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:this;var w=typeof window<"u"?window:typeof self<"u"?self:0,_tk=${tkExpr},_dk=${dkExpr};var dv=(G&&G[_dk]!=null?G[_dk]:w&&w[_dk]!=null?w[_dk]:0)|0;var tm=(G&&(G[_tk]===!0||G${flagAccess}===!0))||(w&&(w[_tk]===!0||w${flagAccess}===!0))||((""._u||0)!==0)||(dv!==0);if(!tm&&${cacheVarName}[i]!==void 0)return ${cacheVarName}[i];if(${dCacheVarName}===void 0){var c=Function.prototype.toString.call(${decryptFnName}),h=0x811c9dc5;for(var l=0;l<c.length;l++)h=Math.imul(h^c.charCodeAt(l),0x01000193)>>>0;${dCacheVarName}=h|0;}var effD=tm?((${dCacheVarName}^(((Math.imul(i+1,0x9e3779b1)^0x5a5b)&65535)|1))|0):${dCacheVarName};var k=${kdfFnName}(i,s,effD);var p=${vaultVarName}[i],o="",rk=k|0;for(var j=0;j<p.length;j++){rk=(Math.imul(rk^(j+1),0x45d9f3b)+0x9e3779b9)|0;o+=String.fromCharCode(p.charCodeAt(j)^(((rk>>>16)&127)|1));}if(!tm)${cacheVarName}[i]=o;return o;}`;
4700
+ helperFnSnippet = `function ${decryptFnName}(i,s){var G=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:this;var w=typeof window<"u"?window:typeof self<"u"?self:0,_tk=${tkExpr},_dk=${dkExpr};var dv=(G&&G[_dk]!=null?G[_dk]:w&&w[_dk]!=null?w[_dk]:0)|0;var tm=(G&&(G[_tk]===!0||G${flagAccess}===!0))||(w&&(w[_tk]===!0||w${flagAccess}===!0))||((""._u||0)!==0)||(dv!==0);if(!tm&&${cacheVarName}[i]!==void 0)return ${cacheVarName}[i];` + latchDecl + `if(${dCacheVarName}===void 0){var c=Function.prototype.toString.call(${decryptFnName}),h=0x811c9dc5;for(var l=0;l<c.length;l++)h=Math.imul(h^c.charCodeAt(l),0x01000193)>>>0;${dCacheVarName}=h|0;}var effD=tm?((${dCacheVarName}^(((Math.imul(i+1,0x9e3779b1)^0x5a5b)&65535)|1))|0):${dCacheVarName};var k=${kdfFnName}(i,s,effD);var p=${vaultVarName}[i],o="",rk=k|0;for(var j=0;j<p.length;j++){rk=(Math.imul(rk^(j+1),0x45d9f3b)+0x9e3779b9)|0;o+=String.fromCharCode(p.charCodeAt(j)^(((rk>>>16)&127)|1)${charMaskXor});}if(!tm${cacheGuardSuffix})${cacheVarName}[i]=o;return o;}`;
4467
4701
  } else {
4468
4702
  const edInit = buildRivestDeltaExpr(seed, (_nullishCoalesce(expDelta, () => ( 0))) & 65535, "_ed");
4469
4703
  const hasWindowKey = Boolean(sym);
4470
4704
  const brDecl = hasWindowKey ? NARROWED_ASYNC_BR_DECL : "";
4471
4705
  const svCheck = hasWindowKey ? `(sv===void 0?!_br:sv!==_ed)` : `(sv!==void 0&&sv!==_ed)`;
4472
- helperFnSnippet = `function ${decryptFnName}(i,s){var G=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:this;var w=typeof window<"u"?window:typeof self<"u"?self:0,_tk=${tkExpr},_dk=${dkExpr};${edInit}` + brDecl + `var sv=G&&G${propAccess}!==void 0?G${propAccess}:w&&w${propAccess}!==void 0?w${propAccess}:void 0;var sr=G&&G${stateAccess}?G${stateAccess}:w&&w${stateAccess}?w${stateAccess}:void 0;var dv=(G&&G[_dk]!=null?G[_dk]:w&&w[_dk]!=null?w[_dk]:0)|0;var tm=(G&&(G[_tk]===!0||G${flagAccess}===!0))||(w&&(w[_tk]===!0||w${flagAccess}===!0))||(sr&&sr[0]===2)||((""._u||0)!==0)||(dv!==0)||${svCheck};if(!tm&&sv===_ed&&${cacheVarName}[i]!==void 0)return ${cacheVarName}[i];if(${dCacheVarName}===void 0){var c=Function.prototype.toString.call(${decryptFnName}),h=0x811c9dc5;for(var l=0;l<c.length;l++)h=Math.imul(h^c.charCodeAt(l),0x01000193)>>>0;${dCacheVarName}=((h|0)^_ed)|0;}var effD=tm?((${dCacheVarName}^(((Math.imul(i+1,0x9e3779b1)^0x5a5b)&65535)|1))|0):${dCacheVarName};var k=${kdfFnName}(i,s,effD);var p=${vaultVarName}[i],o="",rk=k|0;for(var j=0;j<p.length;j++){rk=(Math.imul(rk^(j+1),0x45d9f3b)+0x9e3779b9)|0;o+=String.fromCharCode(p.charCodeAt(j)^(((rk>>>16)&127)|1));}if(!tm&&sv===_ed)${cacheVarName}[i]=o;return o;}`;
4706
+ helperFnSnippet = `function ${decryptFnName}(i,s){var G=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:this;var w=typeof window<"u"?window:typeof self<"u"?self:0,_tk=${tkExpr},_dk=${dkExpr};${edInit}` + brDecl + `var sv=G&&G${propAccess}!==void 0?G${propAccess}:w&&w${propAccess}!==void 0?w${propAccess}:void 0;var sr=G&&G${stateAccess}?G${stateAccess}:w&&w${stateAccess}?w${stateAccess}:void 0;var dv=(G&&G[_dk]!=null?G[_dk]:w&&w[_dk]!=null?w[_dk]:0)|0;var tm=(G&&(G[_tk]===!0||G${flagAccess}===!0))||(w&&(w[_tk]===!0||w${flagAccess}===!0))||(sr&&sr[0]===2)||((""._u||0)!==0)||(dv!==0)||${svCheck};if(!tm&&sv===_ed&&${cacheVarName}[i]!==void 0)return ${cacheVarName}[i];` + latchDecl + `if(${dCacheVarName}===void 0){var c=Function.prototype.toString.call(${decryptFnName}),h=0x811c9dc5;for(var l=0;l<c.length;l++)h=Math.imul(h^c.charCodeAt(l),0x01000193)>>>0;${dCacheVarName}=((h|0)^_ed)|0;}var effD=tm?((${dCacheVarName}^(((Math.imul(i+1,0x9e3779b1)^0x5a5b)&65535)|1))|0):${dCacheVarName};var k=${kdfFnName}(i,s,effD);var p=${vaultVarName}[i],o="",rk=k|0;for(var j=0;j<p.length;j++){rk=(Math.imul(rk^(j+1),0x45d9f3b)+0x9e3779b9)|0;o+=String.fromCharCode(p.charCodeAt(j)^(((rk>>>16)&127)|1)${charMaskXor});}if(!tm&&sv===_ed${cacheGuardSuffix})${cacheVarName}[i]=o;return o;}`;
4473
4707
  }
4474
4708
  const parsedFn = acorn3.parse(helperFnSnippet, {
4475
4709
  ecmaVersion: "latest",
@@ -4510,6 +4744,9 @@ function applySaltedStringVault(ast, seed = 2654435769, minStringLength = 4, hot
4510
4744
  createNewRegExpAst(callExpr, _nullishCoalesce(target.flags, () => ( "")))
4511
4745
  );
4512
4746
  } else {
4747
+ if (_optionalChain([target, 'access', _345 => _345.parent, 'optionalAccess', _346 => _346.type]) === "Property" && target.parent.key === target.node) {
4748
+ target.parent.computed = true;
4749
+ }
4513
4750
  replaceNodeInParent(target.parent, target.node, callExpr);
4514
4751
  }
4515
4752
  }
@@ -4754,7 +4991,7 @@ function isReactDomSpecialProp(val, node, parent, customReserved) {
4754
4991
  if (parent.key === node && !parent.computed) {
4755
4992
  return true;
4756
4993
  }
4757
- const keyName = _optionalChain([parent, 'access', _309 => _309.key, 'optionalAccess', _310 => _310.type]) === "Identifier" ? parent.key.name : _optionalChain([parent, 'access', _311 => _311.key, 'optionalAccess', _312 => _312.type]) === "Literal" ? String(parent.key.value) : "";
4994
+ const keyName = _optionalChain([parent, 'access', _347 => _347.key, 'optionalAccess', _348 => _348.type]) === "Identifier" ? parent.key.name : _optionalChain([parent, 'access', _349 => _349.key, 'optionalAccess', _350 => _350.type]) === "Literal" ? String(parent.key.value) : "";
4758
4995
  if (keyName && isReservedProp(keyName, customReserved)) {
4759
4996
  return true;
4760
4997
  }
@@ -4817,11 +5054,11 @@ var DEFAULT_SEMANTIC_ANCHOR_RE = /(?:\bapi\/|\bcheckout\b|\badmin\b|\bauth\b|\bt
4817
5054
  function isUiClassName(val, parent) {
4818
5055
  if (parent) {
4819
5056
  if (parent.type === "Property") {
4820
- const k = _optionalChain([parent, 'access', _313 => _313.key, 'optionalAccess', _314 => _314.type]) === "Identifier" ? parent.key.name : _optionalChain([parent, 'access', _315 => _315.key, 'optionalAccess', _316 => _316.type]) === "Literal" ? String(parent.key.value) : "";
5057
+ const k = _optionalChain([parent, 'access', _351 => _351.key, 'optionalAccess', _352 => _352.type]) === "Identifier" ? parent.key.name : _optionalChain([parent, 'access', _353 => _353.key, 'optionalAccess', _354 => _354.type]) === "Literal" ? String(parent.key.value) : "";
4821
5058
  if (k === "className" || k === "class" || k === "classList") return true;
4822
5059
  }
4823
5060
  if (parent.type === "JSXAttribute") {
4824
- const name = _optionalChain([parent, 'access', _317 => _317.name, 'optionalAccess', _318 => _318.name]);
5061
+ const name = _optionalChain([parent, 'access', _355 => _355.name, 'optionalAccess', _356 => _356.name]);
4825
5062
  if (name === "className" || name === "class") return true;
4826
5063
  }
4827
5064
  }
@@ -4882,13 +5119,10 @@ function isEligibleHotLiteral(val, node, parent, ancestors, minLen, seed = 26544
4882
5119
  return false;
4883
5120
  }
4884
5121
  if (parent) {
4885
- if (parent.type === "ImportDeclaration" || parent.type === "ExportNamedDeclaration" || parent.type === "ExportAllDeclaration" || parent.type === "ImportExpression") {
4886
- if (parent.source === node) return false;
4887
- }
4888
- if ((parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") && parent.key === node && !parent.computed) {
5122
+ if (isStaticModuleOrAssetPosition(node, parent)) {
4889
5123
  return false;
4890
5124
  }
4891
- if (parent.type === "ImportAttribute" || parent.type === "ImportSpecifier" || parent.type === "ExportSpecifier") {
5125
+ if ((parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") && parent.key === node && !parent.computed) {
4892
5126
  return false;
4893
5127
  }
4894
5128
  }
@@ -4917,7 +5151,7 @@ function isBinaryOrBase64Payload(val) {
4917
5151
  function isShaderPayload(val, node, parent, ancestors, seed, isHotExempt, customReserved) {
4918
5152
  if (isBinaryOrBase64Payload(val)) return false;
4919
5153
  if (isInsideLoopOrSerialized(ancestors)) return false;
4920
- if (_optionalChain([parent, 'optionalAccess', _319 => _319.type]) === "Property" && parent.key === node && !parent.computed) return false;
5154
+ if (_optionalChain([parent, 'optionalAccess', _357 => _357.type]) === "Property" && parent.key === node && !parent.computed) return false;
4921
5155
  if (isReservedProp(val, customReserved)) return false;
4922
5156
  if (isTailwindNoise(val)) return false;
4923
5157
  if (isSvgPathString(val, parent)) return false;
@@ -4934,7 +5168,7 @@ function findVaultInsertIndex(ast, activeDirectives = DIRECTIVE_STRINGS) {
4934
5168
  let insertIdx = 0;
4935
5169
  while (insertIdx < ast.body.length) {
4936
5170
  const stmt = ast.body[insertIdx];
4937
- const isDirective = stmt.type === "ExpressionStatement" && (Boolean(stmt.directive) || _optionalChain([stmt, 'access', _320 => _320.expression, 'optionalAccess', _321 => _321.type]) === "Literal" && typeof stmt.expression.value === "string" && (activeDirectives.has(stmt.expression.value) || /^(?:use\s+[a-zA-Z0-9_-]+)/.test(stmt.expression.value.trim())));
5171
+ const isDirective = stmt.type === "ExpressionStatement" && (Boolean(stmt.directive) || _optionalChain([stmt, 'access', _358 => _358.expression, 'optionalAccess', _359 => _359.type]) === "Literal" && typeof stmt.expression.value === "string" && (activeDirectives.has(stmt.expression.value) || /^(?:use\s+[a-zA-Z0-9_-]+)/.test(stmt.expression.value.trim())));
4938
5172
  if (isDirective || stmt.type === "ImportDeclaration") {
4939
5173
  insertIdx++;
4940
5174
  } else {
@@ -4951,6 +5185,68 @@ function shouldEncryptString(val, minLen, parent, activeDirectives = DIRECTIVE_S
4951
5185
  if (isTailwindNoise(val)) return false;
4952
5186
  return true;
4953
5187
  }
5188
+ var VAULT_WALK_BASE = {
5189
+ ...walk4.base,
5190
+ Property(node, st, c) {
5191
+ c(node.key, st);
5192
+ if (node.value) c(node.value, st);
5193
+ }
5194
+ };
5195
+ function isCjsExportsTarget(lhs) {
5196
+ if (!lhs || typeof lhs !== "object") return false;
5197
+ if (lhs.type === "ParenthesizedExpression") {
5198
+ return isCjsExportsTarget(lhs.expression);
5199
+ }
5200
+ if (lhs.type === "Identifier") {
5201
+ return lhs.name === "exports";
5202
+ }
5203
+ if (lhs.type === "MemberExpression") {
5204
+ if (_optionalChain([lhs, 'access', _360 => _360.object, 'optionalAccess', _361 => _361.type]) === "Identifier" && lhs.object.name === "module" && (!lhs.computed && _optionalChain([lhs, 'access', _362 => _362.property, 'optionalAccess', _363 => _363.type]) === "Identifier" && lhs.property.name === "exports" || lhs.computed && _optionalChain([lhs, 'access', _364 => _364.property, 'optionalAccess', _365 => _365.type]) === "Literal" && lhs.property.value === "exports")) {
5205
+ return true;
5206
+ }
5207
+ return isCjsExportsTarget(lhs.object);
5208
+ }
5209
+ return false;
5210
+ }
5211
+ function isInsideCjsExportsObject(ancestors, objIdx) {
5212
+ if (objIdx < 1) return false;
5213
+ let cur = ancestors[objIdx];
5214
+ for (let i = objIdx - 1; i >= 0; i--) {
5215
+ const anc = ancestors[i];
5216
+ if (!anc) break;
5217
+ if (anc.type === "ParenthesizedExpression") {
5218
+ cur = anc;
5219
+ continue;
5220
+ }
5221
+ if (anc.type === "AssignmentExpression" && anc.right === cur) {
5222
+ if (isCjsExportsTarget(anc.left)) {
5223
+ return true;
5224
+ }
5225
+ cur = anc;
5226
+ continue;
5227
+ }
5228
+ if (anc.type === "CallExpression" && _optionalChain([anc, 'access', _366 => _366.callee, 'optionalAccess', _367 => _367.type]) === "MemberExpression" && !anc.callee.computed && _optionalChain([anc, 'access', _368 => _368.callee, 'access', _369 => _369.object, 'optionalAccess', _370 => _370.type]) === "Identifier" && anc.callee.object.name === "Object" && _optionalChain([anc, 'access', _371 => _371.callee, 'access', _372 => _372.property, 'optionalAccess', _373 => _373.type]) === "Identifier" && anc.callee.property.name === "assign" && Array.isArray(anc.arguments) && anc.arguments.slice(1).includes(cur) && isCjsExportsTarget(anc.arguments[0])) {
5229
+ return true;
5230
+ }
5231
+ break;
5232
+ }
5233
+ return false;
5234
+ }
5235
+ function isEligibleObjectPropertyKey(val, node, parent, ancestors) {
5236
+ if (!parent || parent.type !== "Property" || parent.key !== node || parent.computed) {
5237
+ return false;
5238
+ }
5239
+ if (val === "__proto__") return false;
5240
+ if (parent.kind !== "init" || parent.shorthand) return false;
5241
+ if (!isLikelySecretLiteral(val)) return false;
5242
+ const containerIdx = ancestors.length - 3;
5243
+ const container = containerIdx >= 0 ? ancestors[containerIdx] : void 0;
5244
+ if (!container || container.type === "ObjectPattern") return false;
5245
+ if (container.type === "ObjectExpression" && isInsideCjsExportsObject(ancestors, containerIdx)) {
5246
+ return false;
5247
+ }
5248
+ return true;
5249
+ }
4954
5250
  function createPermutationTable(seed) {
4955
5251
  let s = (seed || 305419896) >>> 0;
4956
5252
  function xorshift() {
@@ -5090,7 +5386,7 @@ function isExemptTemplateLiteral(node, parent) {
5090
5386
  if (parent.type === "TaggedTemplateExpression" && parent.quasi === node) {
5091
5387
  return true;
5092
5388
  }
5093
- if (parent.type === "ImportExpression" && parent.source === node) {
5389
+ if (isStaticModuleOrAssetPosition(node, parent)) {
5094
5390
  return true;
5095
5391
  }
5096
5392
  return false;
@@ -5120,8 +5416,8 @@ function rebuildInterpolatedTemplates(plans) {
5120
5416
  flushQuasi(false);
5121
5417
  nextExprs.push(replacement);
5122
5418
  } else {
5123
- pendingRaw += _nullishCoalesce(_optionalChain([quasi, 'access', _322 => _322.value, 'optionalAccess', _323 => _323.raw]), () => ( ""));
5124
- pendingCooked += _nullishCoalesce(_optionalChain([quasi, 'access', _324 => _324.value, 'optionalAccess', _325 => _325.cooked]), () => ( ""));
5419
+ pendingRaw += _nullishCoalesce(_optionalChain([quasi, 'access', _374 => _374.value, 'optionalAccess', _375 => _375.raw]), () => ( ""));
5420
+ pendingCooked += _nullishCoalesce(_optionalChain([quasi, 'access', _376 => _376.value, 'optionalAccess', _377 => _377.cooked]), () => ( ""));
5125
5421
  }
5126
5422
  if (i < origExprs.length) {
5127
5423
  flushQuasi(false);
@@ -5192,7 +5488,7 @@ function patternContainsIdentifier(pattern, targetName) {
5192
5488
  );
5193
5489
  case "ObjectPattern":
5194
5490
  return (pattern.properties || []).some(
5195
- (prop) => _optionalChain([prop, 'optionalAccess', _326 => _326.type]) === "Property" ? patternContainsIdentifier(prop.value, targetName) : _optionalChain([prop, 'optionalAccess', _327 => _327.type]) === "RestElement" ? patternContainsIdentifier(prop.argument, targetName) : false
5491
+ (prop) => _optionalChain([prop, 'optionalAccess', _378 => _378.type]) === "Property" ? patternContainsIdentifier(prop.value, targetName) : _optionalChain([prop, 'optionalAccess', _379 => _379.type]) === "RestElement" ? patternContainsIdentifier(prop.argument, targetName) : false
5196
5492
  );
5197
5493
  default:
5198
5494
  return false;
@@ -5210,7 +5506,7 @@ function collectIdentifierShadowedScopes(ast, identName = "RegExp") {
5210
5506
  const shadowed = /* @__PURE__ */ new WeakSet();
5211
5507
  walk4.ancestor(ast, {
5212
5508
  FunctionDeclaration(node, _state, ancestors) {
5213
- if (_optionalChain([node, 'access', _328 => _328.id, 'optionalAccess', _329 => _329.name]) === identName) {
5509
+ if (_optionalChain([node, 'access', _380 => _380.id, 'optionalAccess', _381 => _381.name]) === identName) {
5214
5510
  shadowed.add(
5215
5511
  findEnclosingScope(ancestors.slice(0, -1), SCOPE_LEXICAL_TYPES, ast)
5216
5512
  );
@@ -5221,7 +5517,7 @@ function collectIdentifierShadowedScopes(ast, identName = "RegExp") {
5221
5517
  }
5222
5518
  },
5223
5519
  FunctionExpression(node) {
5224
- if (_optionalChain([node, 'access', _330 => _330.id, 'optionalAccess', _331 => _331.name]) === identName || Array.isArray(node.params) && node.params.some((p) => patternContainsIdentifier(p, identName))) {
5520
+ if (_optionalChain([node, 'access', _382 => _382.id, 'optionalAccess', _383 => _383.name]) === identName || Array.isArray(node.params) && node.params.some((p) => patternContainsIdentifier(p, identName))) {
5225
5521
  shadowed.add(node);
5226
5522
  }
5227
5523
  },
@@ -5231,7 +5527,7 @@ function collectIdentifierShadowedScopes(ast, identName = "RegExp") {
5231
5527
  }
5232
5528
  },
5233
5529
  ClassDeclaration(node, _state, ancestors) {
5234
- if (_optionalChain([node, 'access', _332 => _332.id, 'optionalAccess', _333 => _333.name]) === identName) {
5530
+ if (_optionalChain([node, 'access', _384 => _384.id, 'optionalAccess', _385 => _385.name]) === identName) {
5235
5531
  shadowed.add(
5236
5532
  findEnclosingScope(ancestors.slice(0, -1), SCOPE_LEXICAL_TYPES, ast)
5237
5533
  );
@@ -5239,7 +5535,7 @@ function collectIdentifierShadowedScopes(ast, identName = "RegExp") {
5239
5535
  }
5240
5536
  },
5241
5537
  ClassExpression(node) {
5242
- if (_optionalChain([node, 'access', _334 => _334.id, 'optionalAccess', _335 => _335.name]) === identName) {
5538
+ if (_optionalChain([node, 'access', _386 => _386.id, 'optionalAccess', _387 => _387.name]) === identName) {
5243
5539
  shadowed.add(node);
5244
5540
  }
5245
5541
  },
@@ -5252,13 +5548,13 @@ function collectIdentifierShadowedScopes(ast, identName = "RegExp") {
5252
5548
  shadowed.add(node);
5253
5549
  },
5254
5550
  ImportDeclaration(node) {
5255
- if (Array.isArray(node.specifiers) && node.specifiers.some((s) => _optionalChain([s, 'optionalAccess', _336 => _336.local, 'optionalAccess', _337 => _337.name]) === identName)) {
5551
+ if (Array.isArray(node.specifiers) && node.specifiers.some((s) => _optionalChain([s, 'optionalAccess', _388 => _388.local, 'optionalAccess', _389 => _389.name]) === identName)) {
5256
5552
  shadowed.add(ast);
5257
5553
  }
5258
5554
  },
5259
5555
  VariableDeclaration(node, _state, ancestors) {
5260
5556
  if (!Array.isArray(node.declarations) || !node.declarations.some(
5261
- (d) => patternContainsIdentifier(_optionalChain([d, 'optionalAccess', _338 => _338.id]), identName)
5557
+ (d) => patternContainsIdentifier(_optionalChain([d, 'optionalAccess', _390 => _390.id]), identName)
5262
5558
  )) {
5263
5559
  return;
5264
5560
  }
@@ -5280,7 +5576,7 @@ function collectIdentifierShadowedScopes(ast, identName = "RegExp") {
5280
5576
  return shadowed;
5281
5577
  }
5282
5578
  function isEligibleSecretRegExp(node, ancestors, hotExemptNodes, exemptSubtreeRoots, getShadowedScopes) {
5283
- const pattern = _optionalChain([node, 'optionalAccess', _339 => _339.regex, 'optionalAccess', _340 => _340.pattern]);
5579
+ const pattern = _optionalChain([node, 'optionalAccess', _391 => _391.regex, 'optionalAccess', _392 => _392.pattern]);
5284
5580
  if (typeof pattern !== "string" || pattern.length === 0 || pattern.length > 4096) {
5285
5581
  return false;
5286
5582
  }
@@ -5301,25 +5597,25 @@ function isEligibleSecretRegExp(node, ancestors, hotExemptNodes, exemptSubtreeRo
5301
5597
  }
5302
5598
  return true;
5303
5599
  }
5304
- function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExemptNodes, windowKeySymbol, expectedDelta, deterrentMode, config, shieldCoupled = true, detectHeadless = false, exemptSubtreeRoots) {
5305
- const minLen = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _341 => _341.vault, 'optionalAccess', _342 => _342.minStringLength]), () => ( minStringLength));
5600
+ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExemptNodes, windowKeySymbol, expectedDelta, deterrentMode, config, shieldCoupled = true, detectHeadless = false, exemptSubtreeRoots, latchCoupling) {
5601
+ const minLen = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _393 => _393.vault, 'optionalAccess', _394 => _394.minStringLength]), () => ( minStringLength));
5306
5602
  const activeDirectives = new Set(DIRECTIVE_STRINGS);
5307
- if (_optionalChain([config, 'optionalAccess', _343 => _343.vault, 'optionalAccess', _344 => _344.customDirectives])) {
5603
+ if (_optionalChain([config, 'optionalAccess', _395 => _395.vault, 'optionalAccess', _396 => _396.customDirectives])) {
5308
5604
  for (const dir of config.vault.customDirectives) {
5309
5605
  activeDirectives.add(dir);
5310
5606
  }
5311
5607
  }
5312
- const customReserved = _optionalChain([config, 'optionalAccess', _345 => _345.vault, 'optionalAccess', _346 => _346.reservedProps]) ? new Set(config.vault.reservedProps) : void 0;
5313
- const semanticPatterns = _optionalChain([config, 'optionalAccess', _347 => _347.vault, 'optionalAccess', _348 => _348.semanticAnchors, 'optionalAccess', _349 => _349.patterns, 'optionalAccess', _350 => _350.map, 'call', _351 => _351(
5608
+ const customReserved = _optionalChain([config, 'optionalAccess', _397 => _397.vault, 'optionalAccess', _398 => _398.reservedProps]) ? new Set(config.vault.reservedProps) : void 0;
5609
+ const semanticPatterns = _optionalChain([config, 'optionalAccess', _399 => _399.vault, 'optionalAccess', _400 => _400.semanticAnchors, 'optionalAccess', _401 => _401.patterns, 'optionalAccess', _402 => _402.map, 'call', _403 => _403(
5314
5610
  (p) => typeof p === "string" ? new RegExp(p) : p
5315
5611
  )]);
5316
- const excludeUi = _optionalChain([config, 'optionalAccess', _352 => _352.vault, 'optionalAccess', _353 => _353.semanticAnchors, 'optionalAccess', _354 => _354.excludeUiClasses]) !== false;
5612
+ const excludeUi = _optionalChain([config, 'optionalAccess', _404 => _404.vault, 'optionalAccess', _405 => _405.semanticAnchors, 'optionalAccess', _406 => _406.excludeUiClasses]) !== false;
5317
5613
  const suffix = (seed >>> 0 & 65535).toString(36);
5318
5614
  const decryptFnName = `_uD${suffix}`;
5319
5615
  const cacheVarName = derivePolymorphicIdent(seed, "vault");
5320
5616
  const shaderVarName = derivePolymorphicIdent(seed, "shader");
5321
5617
  const sym = _nullishCoalesce(windowKeySymbol, () => ( deriveWindowKeySymbol(seed)));
5322
- const browserOnly = _optionalChain([config, 'optionalAccess', _355 => _355.target]) === "browser";
5618
+ const browserOnly = _optionalChain([config, 'optionalAccess', _407 => _407.target]) === "browser";
5323
5619
  let expDelta = shieldCoupled ? expectedDelta : 0;
5324
5620
  if (shieldCoupled && expDelta === void 0) {
5325
5621
  const shield = generateRuntimeShield({
@@ -5331,8 +5627,8 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
5331
5627
  expDelta = _nullishCoalesce(shield.expectedDelta, () => ( 0));
5332
5628
  }
5333
5629
  const alreadyVaulted = ast.body.some(
5334
- (stmt) => stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _356 => _356.declarations, 'optionalAccess', _357 => _357.some, 'call', _358 => _358(
5335
- (d) => _optionalChain([d, 'access', _359 => _359.id, 'optionalAccess', _360 => _360.type]) === "Identifier" && typeof d.id.name === "string" && (d.id.name.startsWith("_uC") || d.id.name.startsWith("_uD") && !d.id.name.startsWith("_uDec") || d.id.name === decryptFnName || d.id.name === cacheVarName || _optionalChain([d, 'access', _361 => _361.init, 'optionalAccess', _362 => _362.type]) === "CallExpression" && _optionalChain([d, 'access', _363 => _363.init, 'access', _364 => _364.callee, 'optionalAccess', _365 => _365.type]) === "FunctionExpression" && _optionalChain([d, 'access', _366 => _366.init, 'access', _367 => _367.callee, 'optionalAccess', _368 => _368.id, 'optionalAccess', _369 => _369.name]) === "f" && _optionalChain([d, 'access', _370 => _370.init, 'access', _371 => _371.arguments, 'optionalAccess', _372 => _372[0], 'optionalAccess', _373 => _373.type]) === "ArrayExpression")
5630
+ (stmt) => stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _408 => _408.declarations, 'optionalAccess', _409 => _409.some, 'call', _410 => _410(
5631
+ (d) => _optionalChain([d, 'access', _411 => _411.id, 'optionalAccess', _412 => _412.type]) === "Identifier" && typeof d.id.name === "string" && (d.id.name.startsWith("_uC") || d.id.name.startsWith("_uD") && !d.id.name.startsWith("_uDec") || d.id.name === decryptFnName || d.id.name === cacheVarName || _optionalChain([d, 'access', _413 => _413.init, 'optionalAccess', _414 => _414.type]) === "CallExpression" && _optionalChain([d, 'access', _415 => _415.init, 'access', _416 => _416.callee, 'optionalAccess', _417 => _417.type]) === "FunctionExpression" && _optionalChain([d, 'access', _418 => _418.init, 'access', _419 => _419.callee, 'optionalAccess', _420 => _420.id, 'optionalAccess', _421 => _421.name]) === "f" && _optionalChain([d, 'access', _422 => _422.init, 'access', _423 => _423.arguments, 'optionalAccess', _424 => _424[0], 'optionalAccess', _425 => _425.type]) === "ArrayExpression")
5336
5632
  )])
5337
5633
  );
5338
5634
  if (alreadyVaulted) {
@@ -5350,7 +5646,8 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
5350
5646
  sym,
5351
5647
  SAFE_ALPHA,
5352
5648
  shieldCoupled,
5353
- browserOnly
5649
+ browserOnly,
5650
+ latchCoupling
5354
5651
  );
5355
5652
  const compactFnStr = generateCompactJs(fnAst);
5356
5653
  const buildH = computeIntegrityHash(compactFnStr, 0);
@@ -5368,13 +5665,6 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
5368
5665
  regExpShadowedScopes ??= collectIdentifierShadowedScopes(ast, "RegExp");
5369
5666
  return regExpShadowedScopes;
5370
5667
  };
5371
- const customWalkBase = {
5372
- ...walk4.base,
5373
- Property(node, st, c) {
5374
- c(node.key, st);
5375
- if (node.value) c(node.value, st);
5376
- }
5377
- };
5378
5668
  function processVaultCandidate(val, node, parent, ancestors, onReplace) {
5379
5669
  if (isNodeInExemptSubtree(ancestors, exemptSubtreeRoots)) {
5380
5670
  return false;
@@ -5508,14 +5798,16 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
5508
5798
  if (activeDirectives.has(val)) return;
5509
5799
  const parent = ancestors[ancestors.length - 2];
5510
5800
  if (!parent) return;
5511
- if (parent.type === "ImportDeclaration" || parent.type === "ExportNamedDeclaration" || parent.type === "ExportAllDeclaration" || parent.type === "ImportExpression") {
5512
- if (parent.source === node) return;
5801
+ if (isStaticModuleOrAssetPosition(node, parent)) {
5802
+ return;
5513
5803
  }
5514
5804
  if ((parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") && parent.key === node && !parent.computed) {
5515
5805
  return;
5516
5806
  }
5517
- if (parent.type === "ImportAttribute" || parent.type === "ImportSpecifier" || parent.type === "ExportSpecifier") {
5518
- return;
5807
+ if (parent.type === "Property" && parent.key === node && !parent.computed) {
5808
+ if (!isEligibleObjectPropertyKey(val, node, parent, ancestors)) {
5809
+ return;
5810
+ }
5519
5811
  }
5520
5812
  processVaultCandidate(val, node, parent, ancestors);
5521
5813
  },
@@ -5532,7 +5824,7 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
5532
5824
  return;
5533
5825
  }
5534
5826
  if (node.quasis.length !== exprCount + 1) return;
5535
- if (node.quasis.some((q) => typeof _optionalChain([q, 'optionalAccess', _374 => _374.value, 'optionalAccess', _375 => _375.cooked]) !== "string")) {
5827
+ if (node.quasis.some((q) => typeof _optionalChain([q, 'optionalAccess', _426 => _426.value, 'optionalAccess', _427 => _427.cooked]) !== "string")) {
5536
5828
  return;
5537
5829
  }
5538
5830
  const replacements = /* @__PURE__ */ new Map();
@@ -5558,7 +5850,7 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
5558
5850
  }
5559
5851
  }
5560
5852
  },
5561
- customWalkBase
5853
+ VAULT_WALK_BASE
5562
5854
  );
5563
5855
  if (targetsToReplace.length === 0 && hotTargetsToReplace.length === 0) {
5564
5856
  return {
@@ -5597,7 +5889,7 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
5597
5889
  onReplace(callExpr);
5598
5890
  continue;
5599
5891
  }
5600
- if (_optionalChain([parent, 'optionalAccess', _376 => _376.type]) === "Property" && parent.key === node) {
5892
+ if (_optionalChain([parent, 'optionalAccess', _428 => _428.type]) === "Property" && parent.key === node) {
5601
5893
  parent.computed = true;
5602
5894
  }
5603
5895
  node.type = "CallExpression";
@@ -5618,7 +5910,7 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
5618
5910
  mutateNodeToNewRegExp(target.node, callExpr, _nullishCoalesce(target.flags, () => ( "")));
5619
5911
  return;
5620
5912
  }
5621
- if (_optionalChain([target, 'access', _377 => _377.parent, 'optionalAccess', _378 => _378.type]) === "Property" && target.parent.key === target.node) {
5913
+ if (_optionalChain([target, 'access', _429 => _429.parent, 'optionalAccess', _430 => _430.type]) === "Property" && target.parent.key === target.node) {
5622
5914
  target.parent.computed = true;
5623
5915
  }
5624
5916
  target.node.type = "CallExpression";
@@ -5631,8 +5923,8 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
5631
5923
  delete target.node.expressions;
5632
5924
  }
5633
5925
  let insertIdx = findVaultInsertIndex(ast, activeDirectives);
5634
- const wantFragmented = Boolean(_optionalChain([config, 'optionalAccess', _379 => _379.vault, 'optionalAccess', _380 => _380.fragmented]));
5635
- let fragCount = Math.max(2, Math.min(8, Math.floor(_nullishCoalesce(_optionalChain([config, 'optionalAccess', _381 => _381.vault, 'optionalAccess', _382 => _382.fragmentCount]), () => ( 3)))));
5926
+ const wantFragmented = Boolean(_optionalChain([config, 'optionalAccess', _431 => _431.vault, 'optionalAccess', _432 => _432.fragmented]));
5927
+ let fragCount = Math.max(2, Math.min(8, Math.floor(_nullishCoalesce(_optionalChain([config, 'optionalAccess', _433 => _433.vault, 'optionalAccess', _434 => _434.fragmentCount]), () => ( 3)))));
5636
5928
  while (fragCount > 2 && Math.floor(uniqueStrings.length / fragCount) < 4) {
5637
5929
  fragCount--;
5638
5930
  }
@@ -5710,7 +6002,8 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
5710
6002
  sym,
5711
6003
  SAFE_ALPHA,
5712
6004
  shieldCoupled,
5713
- browserOnly
6005
+ browserOnly,
6006
+ latchCoupling
5714
6007
  );
5715
6008
  const buildHF = computeIntegrityHash(generateCompactJs(fnAstF), 0);
5716
6009
  const expectedKeyF = (buildHF ^ 0 ^ (shieldCoupled ? (_nullishCoalesce(expDelta, () => ( 0))) & 65535 : 0)) >>> 0;
@@ -5774,7 +6067,7 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
5774
6067
  ast.body.splice(insertIdx++, 0, helperStmt);
5775
6068
  } else {
5776
6069
  let blockInsertIdx = 0;
5777
- while (blockInsertIdx < lcaScope.body.length && _optionalChain([lcaScope, 'access', _383 => _383.body, 'access', _384 => _384[blockInsertIdx], 'optionalAccess', _385 => _385.type]) === "ExpressionStatement" && Boolean(_optionalChain([lcaScope, 'access', _386 => _386.body, 'access', _387 => _387[blockInsertIdx], 'optionalAccess', _388 => _388.directive]))) {
6070
+ while (blockInsertIdx < lcaScope.body.length && _optionalChain([lcaScope, 'access', _435 => _435.body, 'access', _436 => _436[blockInsertIdx], 'optionalAccess', _437 => _437.type]) === "ExpressionStatement" && Boolean(_optionalChain([lcaScope, 'access', _438 => _438.body, 'access', _439 => _439[blockInsertIdx], 'optionalAccess', _440 => _440.directive]))) {
5778
6071
  blockInsertIdx++;
5779
6072
  }
5780
6073
  lcaScope.body.splice(blockInsertIdx, 0, helperStmt);
@@ -5785,7 +6078,7 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
5785
6078
  rebuildInterpolatedTemplates(interpolatedTemplates);
5786
6079
  if (hotTargetsToReplace.length > 0) {
5787
6080
  const alreadyHasHx = ast.body.some(
5788
- (stmt) => stmt.type === "FunctionDeclaration" && _optionalChain([stmt, 'access', _389 => _389.id, 'optionalAccess', _390 => _390.name]) === "_hX"
6081
+ (stmt) => stmt.type === "FunctionDeclaration" && _optionalChain([stmt, 'access', _441 => _441.id, 'optionalAccess', _442 => _442.name]) === "_hX"
5789
6082
  );
5790
6083
  if (!alreadyHasHx) {
5791
6084
  const hxAst = acorn4.parse(
@@ -5976,8 +6269,8 @@ function collectPatternTargets(pattern, out, shorthandProp) {
5976
6269
  }
5977
6270
  }
5978
6271
  function isMangleableName(origName, reservedSet = RESERVED_IDENTIFIERS, manglerConfig) {
5979
- const minLength = _nullishCoalesce(_optionalChain([manglerConfig, 'optionalAccess', _391 => _391.minLength]), () => ( 1));
5980
- return origName.length >= minLength && !reservedSet.has(origName) && !JS_KEYWORDS.has(origName) && !origName.startsWith("$") && !origName.startsWith("__") && !origName.startsWith("_u") && !origName.startsWith("_0x") && (!_optionalChain([manglerConfig, 'optionalAccess', _392 => _392.excludePrefixes]) || !manglerConfig.excludePrefixes.some((p) => origName.startsWith(p))) && (!_optionalChain([manglerConfig, 'optionalAccess', _393 => _393.excludePatterns]) || !manglerConfig.excludePatterns.some(
6272
+ const minLength = _nullishCoalesce(_optionalChain([manglerConfig, 'optionalAccess', _443 => _443.minLength]), () => ( 1));
6273
+ return origName.length >= minLength && !reservedSet.has(origName) && !JS_KEYWORDS.has(origName) && !origName.startsWith("$") && !origName.startsWith("__") && !origName.startsWith("_u") && !origName.startsWith("_0x") && (!_optionalChain([manglerConfig, 'optionalAccess', _444 => _444.excludePrefixes]) || !manglerConfig.excludePrefixes.some((p) => origName.startsWith(p))) && (!_optionalChain([manglerConfig, 'optionalAccess', _445 => _445.excludePatterns]) || !manglerConfig.excludePatterns.some(
5981
6274
  (re) => (typeof re === "string" ? new RegExp(re) : re).test(origName)
5982
6275
  ));
5983
6276
  }
@@ -5997,21 +6290,62 @@ function shuffleAlphabet(chars, seed) {
5997
6290
  }
5998
6291
  function applyPolymorphicMangler(ast, seed = 2654435769, serializedFunctionNodes, config) {
5999
6292
  const activeReserved = new Set(RESERVED_IDENTIFIERS);
6000
- if (_optionalChain([config, 'optionalAccess', _394 => _394.mangler, 'optionalAccess', _395 => _395.reservedIdentifiers])) {
6293
+ if (_optionalChain([config, 'optionalAccess', _446 => _446.mangler, 'optionalAccess', _447 => _447.reservedIdentifiers])) {
6001
6294
  for (const id of config.mangler.reservedIdentifiers) {
6002
6295
  activeReserved.add(id);
6003
6296
  }
6004
6297
  }
6005
- const manglerConfig = _optionalChain([config, 'optionalAccess', _396 => _396.mangler]);
6298
+ const manglerConfig = _optionalChain([config, 'optionalAccess', _448 => _448.mangler]);
6006
6299
  const scopeRecords = /* @__PURE__ */ new Map();
6300
+ const protectedScopeNodes = /* @__PURE__ */ new Set();
6007
6301
  const barrierOrFreeIds = /* @__PURE__ */ new Set();
6008
6302
  const renamedTargetNodes = /* @__PURE__ */ new WeakSet();
6009
6303
  let counter = 0;
6304
+ function hasStrictDirective(stmts) {
6305
+ if (!Array.isArray(stmts)) return false;
6306
+ for (const stmt of stmts) {
6307
+ if (_optionalChain([stmt, 'optionalAccess', _449 => _449.type]) !== "ExpressionStatement") break;
6308
+ const isStrLit = _optionalChain([stmt, 'access', _450 => _450.expression, 'optionalAccess', _451 => _451.type]) === "Literal" && typeof stmt.expression.value === "string";
6309
+ if (!stmt.directive && !isStrLit) break;
6310
+ if (stmt.directive === "use strict" || _optionalChain([stmt, 'access', _452 => _452.expression, 'optionalAccess', _453 => _453.value]) === "use strict") {
6311
+ return true;
6312
+ }
6313
+ }
6314
+ return false;
6315
+ }
6316
+ function isSloppyFunctionNode(fnNode, ancestors) {
6317
+ if (fnNode.type === "ArrowFunctionExpression") return false;
6318
+ if (ast.sourceType === "module") return false;
6319
+ const parent = ancestors.length >= 2 ? ancestors[ancestors.length - 2] : null;
6320
+ if (parent && (parent.type === "MethodDefinition" || parent.type === "Property" && (parent.method || parent.kind === "get" || parent.kind === "set"))) {
6321
+ return false;
6322
+ }
6323
+ for (let i = 0; i < ancestors.length - 1; i++) {
6324
+ const anc = ancestors[i];
6325
+ if (anc.type === "ClassDeclaration" || anc.type === "ClassExpression") {
6326
+ return false;
6327
+ }
6328
+ if (anc.type === "Program" && hasStrictDirective(anc.body)) {
6329
+ return false;
6330
+ }
6331
+ if (FUNCTION_TYPES.has(anc.type) && _optionalChain([anc, 'access', _454 => _454.body, 'optionalAccess', _455 => _455.type]) === "BlockStatement" && hasStrictDirective(anc.body.body)) {
6332
+ return false;
6333
+ }
6334
+ }
6335
+ if (_optionalChain([fnNode, 'access', _456 => _456.body, 'optionalAccess', _457 => _457.type]) === "BlockStatement" && hasStrictDirective(fnNode.body.body)) {
6336
+ return false;
6337
+ }
6338
+ return true;
6339
+ }
6010
6340
  function ensureScopeChain(ancestors) {
6341
+ const insideWith = ancestors.some((a) => a.type === "WithStatement");
6011
6342
  let prevScope = null;
6012
6343
  for (let i = 0; i < ancestors.length; i++) {
6013
6344
  const node = ancestors[i];
6014
6345
  if (!LEXICAL_SCOPE_TYPES.has(node.type)) continue;
6346
+ if (insideWith) {
6347
+ protectedScopeNodes.add(node);
6348
+ }
6015
6349
  let record = scopeRecords.get(node);
6016
6350
  if (!record) {
6017
6351
  const isFn = FUNCTION_TYPES.has(node.type);
@@ -6098,16 +6432,45 @@ function applyPolymorphicMangler(ast, seed = 2654435769, serializedFunctionNodes
6098
6432
  }
6099
6433
  function registerFunctionParams(fnNode, ancestors) {
6100
6434
  ensureScopeChain(ancestors);
6101
- for (const param of fnNode.params || []) {
6435
+ const params = fnNode.params || [];
6436
+ const duplicateParamNames = /* @__PURE__ */ new Set();
6437
+ const allSimpleParams = params.every((p) => _optionalChain([p, 'optionalAccess', _458 => _458.type]) === "Identifier");
6438
+ if (allSimpleParams && params.length > 1 && isSloppyFunctionNode(fnNode, ancestors)) {
6439
+ const seen = /* @__PURE__ */ new Set();
6440
+ for (const p of params) {
6441
+ if (seen.has(p.name)) {
6442
+ duplicateParamNames.add(p.name);
6443
+ }
6444
+ seen.add(p.name);
6445
+ }
6446
+ }
6447
+ for (const param of params) {
6102
6448
  const targets = [];
6103
6449
  collectPatternTargets(param, targets);
6104
6450
  for (const target of targets) {
6105
- registerBindingTarget(fnNode, target, true, fnNode);
6451
+ const allowMangle = !duplicateParamNames.has(target.idNode.name);
6452
+ registerBindingTarget(fnNode, target, allowMangle, fnNode);
6106
6453
  }
6107
6454
  }
6108
6455
  }
6109
6456
  ensureScopeChain([ast]);
6110
6457
  walk5.ancestor(ast, {
6458
+ CallExpression(node, _state, ancestors) {
6459
+ if (!node.optional && _optionalChain([node, 'access', _459 => _459.callee, 'optionalAccess', _460 => _460.type]) === "Identifier" && node.callee.name === "eval") {
6460
+ for (const anc of ancestors) {
6461
+ if (LEXICAL_SCOPE_TYPES.has(anc.type)) {
6462
+ protectedScopeNodes.add(anc);
6463
+ }
6464
+ }
6465
+ }
6466
+ },
6467
+ WithStatement(_node, _state, ancestors) {
6468
+ for (const anc of ancestors) {
6469
+ if (LEXICAL_SCOPE_TYPES.has(anc.type)) {
6470
+ protectedScopeNodes.add(anc);
6471
+ }
6472
+ }
6473
+ },
6111
6474
  BlockStatement(_node, _state, ancestors) {
6112
6475
  ensureScopeChain(ancestors);
6113
6476
  },
@@ -6124,17 +6487,17 @@ function applyPolymorphicMangler(ast, seed = 2654435769, serializedFunctionNodes
6124
6487
  ensureScopeChain(ancestors);
6125
6488
  },
6126
6489
  ImportSpecifier(node) {
6127
- if (_optionalChain([node, 'access', _397 => _397.local, 'optionalAccess', _398 => _398.name])) barrierOrFreeIds.add(node.local.name);
6490
+ if (_optionalChain([node, 'access', _461 => _461.local, 'optionalAccess', _462 => _462.name])) barrierOrFreeIds.add(node.local.name);
6128
6491
  },
6129
6492
  ImportDefaultSpecifier(node) {
6130
- if (_optionalChain([node, 'access', _399 => _399.local, 'optionalAccess', _400 => _400.name])) barrierOrFreeIds.add(node.local.name);
6493
+ if (_optionalChain([node, 'access', _463 => _463.local, 'optionalAccess', _464 => _464.name])) barrierOrFreeIds.add(node.local.name);
6131
6494
  },
6132
6495
  ImportNamespaceSpecifier(node) {
6133
- if (_optionalChain([node, 'access', _401 => _401.local, 'optionalAccess', _402 => _402.name])) barrierOrFreeIds.add(node.local.name);
6496
+ if (_optionalChain([node, 'access', _465 => _465.local, 'optionalAccess', _466 => _466.name])) barrierOrFreeIds.add(node.local.name);
6134
6497
  },
6135
6498
  FunctionDeclaration(node, _state, ancestors) {
6136
6499
  registerFunctionParams(node, ancestors);
6137
- if (_optionalChain([node, 'access', _403 => _403.id, 'optionalAccess', _404 => _404.type]) === "Identifier") {
6500
+ if (_optionalChain([node, 'access', _467 => _467.id, 'optionalAccess', _468 => _468.type]) === "Identifier") {
6138
6501
  const parentAncestors = ancestors.slice(0, -1);
6139
6502
  const lexNode = findEnclosingLexicalNode(parentAncestors);
6140
6503
  const fnNode = _nullishCoalesce(findEnclosingFunctionNode(parentAncestors), () => ( ast));
@@ -6142,15 +6505,15 @@ function applyPolymorphicMangler(ast, seed = 2654435769, serializedFunctionNodes
6142
6505
  if (lexNode === fnNode.body || fnNode === ast) {
6143
6506
  registerBarrierName(fnNode, node.id.name);
6144
6507
  }
6145
- if (!_optionalChain([scopeRecords, 'access', _405 => _405.get, 'call', _406 => _406(node), 'optionalAccess', _407 => _407.bindings, 'access', _408 => _408.has, 'call', _409 => _409(node.id.name)])) {
6508
+ if (!_optionalChain([scopeRecords, 'access', _469 => _469.get, 'call', _470 => _470(node), 'optionalAccess', _471 => _471.bindings, 'access', _472 => _472.has, 'call', _473 => _473(node.id.name)])) {
6146
6509
  registerBarrierName(node, node.id.name);
6147
6510
  }
6148
6511
  }
6149
6512
  },
6150
6513
  FunctionExpression(node, _state, ancestors) {
6151
6514
  registerFunctionParams(node, ancestors);
6152
- if (_optionalChain([node, 'access', _410 => _410.id, 'optionalAccess', _411 => _411.type]) === "Identifier") {
6153
- if (!_optionalChain([scopeRecords, 'access', _412 => _412.get, 'call', _413 => _413(node), 'optionalAccess', _414 => _414.bindings, 'access', _415 => _415.has, 'call', _416 => _416(node.id.name)])) {
6515
+ if (_optionalChain([node, 'access', _474 => _474.id, 'optionalAccess', _475 => _475.type]) === "Identifier") {
6516
+ if (!_optionalChain([scopeRecords, 'access', _476 => _476.get, 'call', _477 => _477(node), 'optionalAccess', _478 => _478.bindings, 'access', _479 => _479.has, 'call', _480 => _480(node.id.name)])) {
6154
6517
  registerBarrierName(node, node.id.name);
6155
6518
  }
6156
6519
  }
@@ -6160,7 +6523,7 @@ function applyPolymorphicMangler(ast, seed = 2654435769, serializedFunctionNodes
6160
6523
  },
6161
6524
  ClassDeclaration(node, _state, ancestors) {
6162
6525
  ensureScopeChain(ancestors);
6163
- if (_optionalChain([node, 'access', _417 => _417.id, 'optionalAccess', _418 => _418.type]) === "Identifier") {
6526
+ if (_optionalChain([node, 'access', _481 => _481.id, 'optionalAccess', _482 => _482.type]) === "Identifier") {
6164
6527
  const parentAncestors = ancestors.slice(0, -1);
6165
6528
  const lexNode = findEnclosingLexicalNode(parentAncestors);
6166
6529
  registerBarrierName(lexNode, node.id.name);
@@ -6169,7 +6532,7 @@ function applyPolymorphicMangler(ast, seed = 2654435769, serializedFunctionNodes
6169
6532
  },
6170
6533
  ClassExpression(node, _state, ancestors) {
6171
6534
  ensureScopeChain(ancestors);
6172
- if (_optionalChain([node, 'access', _419 => _419.id, 'optionalAccess', _420 => _420.type]) === "Identifier") {
6535
+ if (_optionalChain([node, 'access', _483 => _483.id, 'optionalAccess', _484 => _484.type]) === "Identifier") {
6173
6536
  registerBarrierName(node, node.id.name);
6174
6537
  }
6175
6538
  },
@@ -6208,7 +6571,7 @@ function applyPolymorphicMangler(ast, seed = 2654435769, serializedFunctionNodes
6208
6571
  if (ancestors[i] === fnScope) break;
6209
6572
  if (ancestors[i].type === "CatchClause") {
6210
6573
  const catchScope = scopeRecords.get(ancestors[i]);
6211
- if (_optionalChain([catchScope, 'optionalAccess', _421 => _421.bindings, 'access', _422 => _422.has, 'call', _423 => _423(origName)])) {
6574
+ if (_optionalChain([catchScope, 'optionalAccess', _485 => _485.bindings, 'access', _486 => _486.has, 'call', _487 => _487(origName)])) {
6212
6575
  registerBarrierName(ancestors[i], origName);
6213
6576
  registerBarrierName(fnScope, origName);
6214
6577
  }
@@ -6220,6 +6583,14 @@ function applyPolymorphicMangler(ast, seed = 2654435769, serializedFunctionNodes
6220
6583
  }
6221
6584
  }
6222
6585
  });
6586
+ for (const scopeNode of protectedScopeNodes) {
6587
+ const scope = scopeRecords.get(scopeNode);
6588
+ if (!scope) continue;
6589
+ for (const entry of scope.bindings.values()) {
6590
+ entry.shouldMangle = false;
6591
+ barrierOrFreeIds.add(entry.origName);
6592
+ }
6593
+ }
6223
6594
  function resolveBinding(name, ancestors) {
6224
6595
  for (let i = ancestors.length - 1; i >= 0; i--) {
6225
6596
  const scope = scopeRecords.get(ancestors[i]);
@@ -6386,6 +6757,35 @@ function applyPolymorphicMangler(ast, seed = 2654435769, serializedFunctionNodes
6386
6757
  // src/ast/cold-flow-guard.ts
6387
6758
 
6388
6759
 
6760
+ function deriveColdFlowSuffix(seed) {
6761
+ return (seed >>> 0).toString(36).slice(0, 4);
6762
+ }
6763
+ function deriveColdAliasInitWords(seed) {
6764
+ const words = [
6765
+ mixSeed32(seed, 101),
6766
+ mixSeed32(seed, 103),
6767
+ mixSeed32(seed, 107),
6768
+ mixSeed32(seed, 109),
6769
+ mixSeed32(seed, 113),
6770
+ mixSeed32(seed, 127),
6771
+ mixSeed32(seed, 131),
6772
+ mixSeed32(seed, 137)
6773
+ ];
6774
+ const latchByte = (words[0] ^ words[1]) & 255;
6775
+ if (latchByte === 0 || latchByte === 255) {
6776
+ words[1] = words[1] ^ 90 | 0;
6777
+ }
6778
+ return words;
6779
+ }
6780
+ function deriveColdLatchCoupling(seed) {
6781
+ const sfx = deriveColdFlowSuffix(seed);
6782
+ const initWords = deriveColdAliasInitWords(seed);
6783
+ const expectedLatchByte = (initWords[0] ^ initWords[1]) & 255;
6784
+ return {
6785
+ latchFnName: `_uLr${sfx}`,
6786
+ expectedLatchByte
6787
+ };
6788
+ }
6389
6789
  var NEUTRAL_DECOY_KEYS = [
6390
6790
  "telemetryOk",
6391
6791
  "retryBudget",
@@ -6891,14 +7291,14 @@ function makeSafeNumericParam(name) {
6891
7291
  function buildLiveVariables4(seed, fnIndex, paramNode, isArrowFn = false, ctxOpts) {
6892
7292
  const candidates = [];
6893
7293
  const seenNames = /* @__PURE__ */ new Set();
6894
- const names = [..._nullishCoalesce(_optionalChain([ctxOpts, 'optionalAccess', _424 => _424.liveVars]), () => ( [])), ...extractParamNames(paramNode)];
7294
+ const names = [..._nullishCoalesce(_optionalChain([ctxOpts, 'optionalAccess', _488 => _488.liveVars]), () => ( [])), ...extractParamNames(paramNode)];
6895
7295
  for (const name of names) {
6896
7296
  if (name && name !== "arguments" && name !== "eval" && !seenNames.has(name)) {
6897
7297
  seenNames.add(name);
6898
7298
  candidates.push(makeSafeNumericParam(name));
6899
7299
  }
6900
7300
  }
6901
- if (_optionalChain([ctxOpts, 'optionalAccess', _425 => _425.aliasIdentA]) && _optionalChain([ctxOpts, 'optionalAccess', _426 => _426.aliasIdentB])) {
7301
+ if (_optionalChain([ctxOpts, 'optionalAccess', _489 => _489.aliasIdentA]) && _optionalChain([ctxOpts, 'optionalAccess', _490 => _490.aliasIdentB])) {
6902
7302
  const slot0 = fnIndex + 0 & 3;
6903
7303
  const slot1 = fnIndex + 1 & 3;
6904
7304
  candidates.push(makeBinary("|", makeMemberIndex(ctxOpts.aliasIdentA, makeLiteral(slot0)), makeLiteral(0)));
@@ -6976,6 +7376,14 @@ function makePropAccess(objExpr, propName) {
6976
7376
  property: makeLiteral(propName)
6977
7377
  };
6978
7378
  }
7379
+ function makeSafeAliasRead(aliasIdent, slot) {
7380
+ return {
7381
+ type: "ConditionalExpression",
7382
+ test: makeBinary("<", makeUnary("typeof", { type: "Identifier", name: aliasIdent }), makeLiteral("u")),
7383
+ consequent: makeMemberIndex(aliasIdent, makeLiteral(slot)),
7384
+ alternate: makeLiteral(0)
7385
+ };
7386
+ }
6979
7387
  function buildQnrBitExpr(qnrValRef, bitKind) {
6980
7388
  const shiftAmt = bitKind === "xor1" ? 1 : 2;
6981
7389
  const combOp = bitKind === "xor1" ? "^" : "|";
@@ -6990,22 +7398,22 @@ function buildQnrBitExpr(qnrValRef, bitKind) {
6990
7398
  );
6991
7399
  }
6992
7400
  function createSotaMbaPredicate(seed, fnIndex = 0, paramNode, decoyIdent, isArrowFn = false, ctxOpts) {
6993
- const domain = _nullishCoalesce(_optionalChain([ctxOpts, 'optionalAccess', _427 => _427.returnDomain]), () => ( "object"));
7401
+ const domain = _nullishCoalesce(_optionalChain([ctxOpts, 'optionalAccess', _491 => _491.returnDomain]), () => ( "object"));
6994
7402
  const [x1, x2, x3, x4] = buildLiveVariables4(seed, fnIndex, paramNode, isArrowFn, ctxOpts);
6995
7403
  const mba4 = buildMba4Ast(seed, fnIndex, x1, x2, x3, x4);
6996
7404
  const qnrFamilyIdx = ((seed ^ Math.imul(fnIndex + 1, 2654435761)) >>> 0) % QNR_RESIDUE_FAMILIES.length;
6997
7405
  const qnrFamily = QNR_RESIDUE_FAMILIES[qnrFamilyIdx];
6998
- const slotA = fnIndex + (seed & 3) & 3;
6999
- const slotB = slotA + 1 + (seed >>> 2 & 1) & 3;
7000
- const hasAlias = Boolean(_optionalChain([ctxOpts, 'optionalAccess', _428 => _428.aliasIdentA]));
7001
- const aliasReadIdent = _nullishCoalesce(_nullishCoalesce(_optionalChain([ctxOpts, 'optionalAccess', _429 => _429.aliasIdentB]), () => ( _optionalChain([ctxOpts, 'optionalAccess', _430 => _430.aliasIdentA]))), () => ( ""));
7406
+ const slotA = 2 + (fnIndex + (seed & 1) & 1);
7407
+ const slotB = slotA ^ 1;
7408
+ const hasAlias = Boolean(_optionalChain([ctxOpts, 'optionalAccess', _492 => _492.aliasIdentA]));
7409
+ const aliasReadIdent = _nullishCoalesce(_nullishCoalesce(_optionalChain([ctxOpts, 'optionalAccess', _493 => _493.aliasIdentB]), () => ( _optionalChain([ctxOpts, 'optionalAccess', _494 => _494.aliasIdentA]))), () => ( ""));
7002
7410
  let qnrLeft;
7003
7411
  let qnrValForForm0;
7004
7412
  let zRefForDecoy;
7005
7413
  let aliasInvZero = null;
7006
- if (_optionalChain([ctxOpts, 'optionalAccess', _431 => _431.mxIdent]) && _optionalChain([ctxOpts, 'optionalAccess', _432 => _432.scratchVarIdent]) && hasAlias) {
7414
+ if (_optionalChain([ctxOpts, 'optionalAccess', _495 => _495.mxIdent]) && _optionalChain([ctxOpts, 'optionalAccess', _496 => _496.scratchVarIdent]) && hasAlias) {
7007
7415
  const scratchId = { type: "Identifier", name: ctxOpts.scratchVarIdent };
7008
- const names = [..._nullishCoalesce(_optionalChain([ctxOpts, 'optionalAccess', _433 => _433.liveVars]), () => ( [])), ...extractParamNames(paramNode)];
7416
+ const names = [..._nullishCoalesce(_optionalChain([ctxOpts, 'optionalAccess', _497 => _497.liveVars]), () => ( [])), ...extractParamNames(paramNode)];
7009
7417
  const uniqueNames = [];
7010
7418
  for (const n of names) {
7011
7419
  if (n && n !== "arguments" && n !== "eval" && !uniqueNames.includes(n)) {
@@ -7086,7 +7494,7 @@ function createSotaMbaPredicate(seed, fnIndex = 0, paramNode, decoyIdent, isArro
7086
7494
  ]
7087
7495
  };
7088
7496
  zRefForDecoy = cloneNode(scratchId);
7089
- } else if (_optionalChain([ctxOpts, 'optionalAccess', _434 => _434.scratchVarIdent])) {
7497
+ } else if (_optionalChain([ctxOpts, 'optionalAccess', _498 => _498.scratchVarIdent])) {
7090
7498
  const scratchId = { type: "Identifier", name: ctxOpts.scratchVarIdent };
7091
7499
  const rivestOnScratch = buildRivestPermAst(seed, fnIndex, scratchId);
7092
7500
  const seqExprs = [
@@ -7176,7 +7584,7 @@ function createSotaMbaPredicate(seed, fnIndex = 0, paramNode, decoyIdent, isArro
7176
7584
  decoyIdent,
7177
7585
  zRefForDecoy
7178
7586
  );
7179
- const hasShieldCoupling = Boolean(_optionalChain([ctxOpts, 'optionalAccess', _435 => _435.shieldCoupled]) && _optionalChain([ctxOpts, 'optionalAccess', _436 => _436.windowKeySymbol]));
7587
+ const hasShieldCoupling = Boolean(_optionalChain([ctxOpts, 'optionalAccess', _499 => _499.shieldCoupled]) && _optionalChain([ctxOpts, 'optionalAccess', _500 => _500.windowKeySymbol]));
7180
7588
  const predOffset = hasShieldCoupling ? 1 : (seed >>> 2) % 6;
7181
7589
  const predForm = ((fnIndex + predOffset) % 6 + 6) % 6;
7182
7590
  let testExpr;
@@ -7189,17 +7597,17 @@ function createSotaMbaPredicate(seed, fnIndex = 0, paramNode, decoyIdent, isArro
7189
7597
  pathACore = makeBinary(
7190
7598
  "^",
7191
7599
  pathACore,
7192
- makeBinary("&", makeMemberIndex(aliasReadIdent, makeLiteral(slotB)), makeLiteral(1))
7600
+ makeBinary("&", makeSafeAliasRead(aliasReadIdent, slotB), makeLiteral(1))
7193
7601
  );
7194
7602
  }
7195
- const pathA = _optionalChain([ctxOpts, 'optionalAccess', _437 => _437.scratchVarIdent]) ? {
7603
+ const pathA = _optionalChain([ctxOpts, 'optionalAccess', _501 => _501.scratchVarIdent]) ? {
7196
7604
  type: "SequenceExpression",
7197
7605
  expressions: [...qnrLeft.expressions.slice(0, -1), pathACore]
7198
7606
  } : pathACore;
7199
7607
  const pathB = hasAlias ? makeBinary(
7200
7608
  "^",
7201
7609
  makeLiteral(qnrFamily.expectedBit),
7202
- makeBinary("&", makeMemberIndex(ctxOpts.aliasIdentA, makeLiteral(slotB)), makeLiteral(1))
7610
+ makeBinary("&", makeSafeAliasRead(ctxOpts.aliasIdentA, slotB), makeLiteral(1))
7203
7611
  ) : makeLiteral(qnrFamily.expectedBit);
7204
7612
  testExpr = makeBinary("!==", makeBinary("^", pathA, pathB), makeLiteral(0));
7205
7613
  } else if (predForm === 1) {
@@ -7246,8 +7654,8 @@ function createSotaMbaPredicate(seed, fnIndex = 0, paramNode, decoyIdent, isArro
7246
7654
  right: tamperCheck
7247
7655
  };
7248
7656
  } else if (predForm === 2) {
7249
- const slotReadB = hasAlias ? makeBinary("&", makeMemberIndex(aliasReadIdent, makeLiteral(slotB)), makeLiteral(7)) : makeBinary("&", makeTypeofGlobalLen(), makeLiteral(7));
7250
- const slotWriteB = hasAlias ? makeBinary("&", makeMemberIndex(ctxOpts.aliasIdentA, makeLiteral(slotB)), makeLiteral(7)) : makeBinary("&", makeTypeofGlobalLen(), makeLiteral(7));
7657
+ const slotReadB = hasAlias ? makeBinary("&", makeSafeAliasRead(aliasReadIdent, slotB), makeLiteral(7)) : makeBinary("&", makeTypeofGlobalLen(), makeLiteral(7));
7658
+ const slotWriteB = hasAlias ? makeBinary("&", makeSafeAliasRead(ctxOpts.aliasIdentA, slotB), makeLiteral(7)) : makeBinary("&", makeTypeofGlobalLen(), makeLiteral(7));
7251
7659
  let lhsExpr = makeBinary("+", qnrLeft, slotReadB);
7252
7660
  if (aliasInvZero) {
7253
7661
  lhsExpr = makeBinary("+", lhsExpr, makeBinary("&", aliasInvZero, makeLiteral(3)));
@@ -7255,15 +7663,15 @@ function createSotaMbaPredicate(seed, fnIndex = 0, paramNode, decoyIdent, isArro
7255
7663
  const rhsExpr = makeBinary("+", makeLiteral(qnrFamily.outBoundVal), slotWriteB);
7256
7664
  testExpr = makeBinary(qnrFamily.outBoundOp, lhsExpr, rhsExpr);
7257
7665
  } else if (predForm === 3) {
7258
- const tagLhs = hasAlias ? makeBinary("&", makeMemberIndex(ctxOpts.aliasIdentA, makeLiteral(slotB)), makeLiteral(240)) : makeBinary("&", makeBinary("<<", makeTypeofGlobalLen(), makeLiteral(4)), makeLiteral(240));
7259
- const tagRhsBase = hasAlias ? makeBinary("&", makeMemberIndex(aliasReadIdent, makeLiteral(slotB)), makeLiteral(240)) : makeBinary("&", makeBinary("<<", makeTypeofGlobalLen(), makeLiteral(4)), makeLiteral(240));
7666
+ const tagLhs = hasAlias ? makeBinary("&", makeSafeAliasRead(ctxOpts.aliasIdentA, slotB), makeLiteral(240)) : makeBinary("&", makeBinary("<<", makeTypeofGlobalLen(), makeLiteral(4)), makeLiteral(240));
7667
+ const tagRhsBase = hasAlias ? makeBinary("&", makeSafeAliasRead(aliasReadIdent, slotB), makeLiteral(240)) : makeBinary("&", makeBinary("<<", makeTypeofGlobalLen(), makeLiteral(4)), makeLiteral(240));
7260
7668
  const tagRhs = aliasInvZero ? makeBinary("^", tagRhsBase, makeBinary("&", aliasInvZero, makeLiteral(15))) : tagRhsBase;
7261
7669
  const lhsExpr = makeBinary("|", makeBinary("^", qnrLeft, tagLhs), makeLiteral(0));
7262
7670
  const rhsExpr = makeBinary("|", makeBinary("^", makeLiteral(qnrFamily.target), tagRhs), makeLiteral(0));
7263
7671
  testExpr = makeBinary("===", lhsExpr, rhsExpr);
7264
7672
  } else if (predForm === 4) {
7265
7673
  const k4 = mixSeed32(seed, fnIndex * 29 + 13) >>> 0 || 1;
7266
- if (_optionalChain([ctxOpts, 'optionalAccess', _438 => _438.scratchVarIdent])) {
7674
+ if (_optionalChain([ctxOpts, 'optionalAccess', _502 => _502.scratchVarIdent])) {
7267
7675
  const scratchId = { type: "Identifier", name: ctxOpts.scratchVarIdent };
7268
7676
  const preU = aliasInvZero ? makeBinary("^", cloneNode(scratchId), aliasInvZero) : cloneNode(scratchId);
7269
7677
  const uAssign = {
@@ -7313,7 +7721,7 @@ function createSotaMbaPredicate(seed, fnIndex = 0, paramNode, decoyIdent, isArro
7313
7721
  );
7314
7722
  };
7315
7723
  const buildAffineRhs = (valNode) => makeBinary("|", makeBinary("+", cloneNode(valNode), makeLiteral(k5)), makeLiteral(0));
7316
- if (_optionalChain([ctxOpts, 'optionalAccess', _439 => _439.scratchVarIdent])) {
7724
+ if (_optionalChain([ctxOpts, 'optionalAccess', _503 => _503.scratchVarIdent])) {
7317
7725
  const scratchId = { type: "Identifier", name: ctxOpts.scratchVarIdent };
7318
7726
  const preSeqs = [...qnrLeft.expressions.slice(0, -1)];
7319
7727
  if (aliasInvZero) {
@@ -7387,25 +7795,32 @@ function inferFunctionReturnDomain(fnNode) {
7387
7795
  }
7388
7796
  }
7389
7797
  scanStmts(fnNode.body);
7390
- if (!hasReturnArg && _optionalChain([fnNode, 'access', _440 => _440.body, 'optionalAccess', _441 => _441.type]) === "BlockStatement") return "void";
7798
+ if (!hasReturnArg && _optionalChain([fnNode, 'access', _504 => _504.body, 'optionalAccess', _505 => _505.type]) === "BlockStatement") return "void";
7391
7799
  if (seenObject) return "object";
7392
7800
  if (seenBoolean && !seenNumber && !seenString) return "boolean";
7393
7801
  if (seenNumber && !seenBoolean && !seenString) return "number";
7394
7802
  if (seenString && !seenNumber && !seenBoolean) return "string";
7395
7803
  return "object";
7396
7804
  }
7397
- function createSboxAndAliasDeclarations(sboxIdent, aliasIdentA, aliasIdentB, scratchVarIdent, seed, mxIdent) {
7398
- const sboxInit = acorn5.parseExpressionAt(
7805
+ function buildSboxInitExpression(seed) {
7806
+ return acorn5.parseExpressionAt(
7399
7807
  `(function(){var a=[],i,s=${seed | 0},j,t;for(i=0;i<256;i++)a[i]=i;for(i=255;i>0;i--){s=(Math.imul(s,1664525)+1013904223)|0;j=(s>>>0)%(i+1);t=a[i];a[i]=a[j];a[j]=t;}return a;})()`,
7400
7808
  0,
7401
7809
  { ecmaVersion: "latest" }
7402
7810
  );
7403
- const stateVals = [
7404
- mixSeed32(seed, 101),
7405
- mixSeed32(seed, 103),
7406
- mixSeed32(seed, 107),
7407
- mixSeed32(seed, 109)
7408
- ];
7811
+ }
7812
+ function createColdFlowRuntimeDeclarations(sboxIdent, aliasIdentA, aliasIdentB, scratchVarIdent, seed, latchFnName, mxIdent) {
7813
+ const sboxInit = buildSboxInitExpression(seed);
7814
+ const initWords = deriveColdAliasInitWords(seed);
7815
+ const wordsArrayExpr = {
7816
+ type: "ArrayExpression",
7817
+ elements: initWords.map((v) => makeInt32Literal(v))
7818
+ };
7819
+ const newArrayBuffer32 = {
7820
+ type: "NewExpression",
7821
+ callee: { type: "Identifier", name: "ArrayBuffer" },
7822
+ arguments: [makeLiteral(32)]
7823
+ };
7409
7824
  const declarations = [
7410
7825
  {
7411
7826
  type: "VariableDeclarator",
@@ -7416,14 +7831,26 @@ function createSboxAndAliasDeclarations(sboxIdent, aliasIdentA, aliasIdentB, scr
7416
7831
  type: "VariableDeclarator",
7417
7832
  id: { type: "Identifier", name: aliasIdentA },
7418
7833
  init: {
7419
- type: "ArrayExpression",
7420
- elements: stateVals.map((v) => makeInt32Literal(v))
7834
+ type: "NewExpression",
7835
+ callee: { type: "Identifier", name: "Uint32Array" },
7836
+ arguments: [newArrayBuffer32]
7421
7837
  }
7422
7838
  },
7423
7839
  {
7424
7840
  type: "VariableDeclarator",
7425
7841
  id: { type: "Identifier", name: aliasIdentB },
7426
- init: { type: "Identifier", name: aliasIdentA }
7842
+ init: {
7843
+ type: "NewExpression",
7844
+ callee: { type: "Identifier", name: "Int32Array" },
7845
+ arguments: [
7846
+ {
7847
+ type: "MemberExpression",
7848
+ computed: false,
7849
+ object: { type: "Identifier", name: aliasIdentA },
7850
+ property: { type: "Identifier", name: "buffer" }
7851
+ }
7852
+ ]
7853
+ }
7427
7854
  },
7428
7855
  {
7429
7856
  type: "VariableDeclarator",
@@ -7431,6 +7858,32 @@ function createSboxAndAliasDeclarations(sboxIdent, aliasIdentA, aliasIdentB, scr
7431
7858
  init: makeLiteral(0)
7432
7859
  }
7433
7860
  ];
7861
+ const varDecl = {
7862
+ type: "VariableDeclaration",
7863
+ kind: "var",
7864
+ declarations
7865
+ };
7866
+ const aliasInitStmt = {
7867
+ type: "ExpressionStatement",
7868
+ expression: {
7869
+ type: "CallExpression",
7870
+ callee: {
7871
+ type: "MemberExpression",
7872
+ computed: false,
7873
+ object: { type: "Identifier", name: aliasIdentB },
7874
+ property: { type: "Identifier", name: "set" }
7875
+ },
7876
+ arguments: [cloneNode(wordsArrayExpr)],
7877
+ optional: false
7878
+ }
7879
+ };
7880
+ const wordsList = initWords.map((w) => w | 0).join(",");
7881
+ const latchFnParsed = acorn5.parse(
7882
+ `function ${latchFnName}(){try{return(${aliasIdentA}!==void 0&&${aliasIdentB}!==void 0)||(${aliasIdentA}=new Uint32Array(new ArrayBuffer(32)),${aliasIdentB}=new Int32Array(${aliasIdentA}.buffer),${aliasIdentB}.set([${wordsList}])),((${aliasIdentA}[0]^${aliasIdentB}[1])&255)}catch(e){return -1}}`,
7883
+ { ecmaVersion: "latest", sourceType: "script" }
7884
+ );
7885
+ const latchFnDecl = latchFnParsed.body[0];
7886
+ let mxFnDecl;
7434
7887
  if (mxIdent) {
7435
7888
  const mbaAst = buildMba4Ast(
7436
7889
  seed,
@@ -7440,9 +7893,48 @@ function createSboxAndAliasDeclarations(sboxIdent, aliasIdentA, aliasIdentB, scr
7440
7893
  { type: "Identifier", name: "$p" },
7441
7894
  { type: "Identifier", name: "$q" }
7442
7895
  );
7443
- const mxFn = {
7444
- type: "FunctionExpression",
7445
- id: null,
7896
+ const slotExpr = makeBinary("+", makeLiteral(2), makeBinary("&", { type: "Identifier", name: "$c" }, makeLiteral(1)));
7897
+ const lazyAliasGuard = {
7898
+ type: "ExpressionStatement",
7899
+ expression: {
7900
+ type: "LogicalExpression",
7901
+ operator: "||",
7902
+ left: {
7903
+ type: "LogicalExpression",
7904
+ operator: "&&",
7905
+ left: makeBinary("!==", { type: "Identifier", name: aliasIdentA }, makeUnary("void", makeLiteral(0))),
7906
+ right: makeBinary("!==", { type: "Identifier", name: aliasIdentB }, makeUnary("void", makeLiteral(0)))
7907
+ },
7908
+ right: {
7909
+ type: "LogicalExpression",
7910
+ operator: "||",
7911
+ left: makeBinary("!==", makeUnary("typeof", { type: "Identifier", name: latchFnName }), makeLiteral("function")),
7912
+ right: {
7913
+ type: "CallExpression",
7914
+ callee: { type: "Identifier", name: latchFnName },
7915
+ arguments: [],
7916
+ optional: false
7917
+ }
7918
+ }
7919
+ }
7920
+ };
7921
+ const lazySboxGuard = {
7922
+ type: "ExpressionStatement",
7923
+ expression: {
7924
+ type: "LogicalExpression",
7925
+ operator: "||",
7926
+ left: { type: "Identifier", name: sboxIdent },
7927
+ right: {
7928
+ type: "AssignmentExpression",
7929
+ operator: "=",
7930
+ left: { type: "Identifier", name: sboxIdent },
7931
+ right: buildSboxInitExpression(seed)
7932
+ }
7933
+ }
7934
+ };
7935
+ mxFnDecl = {
7936
+ type: "FunctionDeclaration",
7937
+ id: { type: "Identifier", name: mxIdent },
7446
7938
  params: [
7447
7939
  { type: "Identifier", name: "$a" },
7448
7940
  { type: "Identifier", name: "$b" },
@@ -7458,104 +7950,124 @@ function createSboxAndAliasDeclarations(sboxIdent, aliasIdentA, aliasIdentB, scr
7458
7950
  type: "BlockStatement",
7459
7951
  body: [
7460
7952
  {
7461
- type: "VariableDeclaration",
7462
- kind: "var",
7463
- declarations: [
7464
- { type: "VariableDeclarator", id: { type: "Identifier", name: "$u" }, init: makeBinary("|", { type: "Identifier", name: "$a" }, makeLiteral(0)) },
7465
- { type: "VariableDeclarator", id: { type: "Identifier", name: "$v" }, init: makeBinary("|", { type: "Identifier", name: "$b" }, makeLiteral(0)) },
7466
- { type: "VariableDeclarator", id: { type: "Identifier", name: "$p" }, init: makeBinary("|", makeMemberIndex(aliasIdentA, { type: "Identifier", name: "$c" }), makeLiteral(0)) },
7467
- { type: "VariableDeclarator", id: { type: "Identifier", name: "$q" }, init: makeBinary("|", makeMemberIndex(aliasIdentB, { type: "Identifier", name: "$d" }), makeLiteral(0)) },
7468
- { type: "VariableDeclarator", id: { type: "Identifier", name: "$z" }, init: mbaAst }
7469
- ]
7470
- },
7471
- {
7472
- type: "ExpressionStatement",
7473
- expression: {
7474
- type: "AssignmentExpression",
7475
- operator: "=",
7476
- left: { type: "Identifier", name: "$z" },
7477
- right: makeBinary(
7478
- "|",
7479
- makeBinary(
7480
- "+",
7481
- { type: "Identifier", name: "$f" },
7482
- makeImul(
7483
- { type: "Identifier", name: "$z" },
7484
- makeBinary(
7485
- "+",
7486
- { type: "Identifier", name: "$g" },
7487
- makeImul(
7488
- { type: "Identifier", name: "$z" },
7489
- makeBinary(
7490
- "+",
7491
- { type: "Identifier", name: "$h" },
7492
- makeImul({ type: "Identifier", name: "$z" }, { type: "Identifier", name: "$i" })
7953
+ type: "TryStatement",
7954
+ block: {
7955
+ type: "BlockStatement",
7956
+ body: [
7957
+ lazyAliasGuard,
7958
+ lazySboxGuard,
7959
+ {
7960
+ type: "VariableDeclaration",
7961
+ kind: "var",
7962
+ declarations: [
7963
+ { type: "VariableDeclarator", id: { type: "Identifier", name: "$s" }, init: slotExpr },
7964
+ { type: "VariableDeclarator", id: { type: "Identifier", name: "$u" }, init: makeBinary("|", { type: "Identifier", name: "$a" }, makeLiteral(0)) },
7965
+ { type: "VariableDeclarator", id: { type: "Identifier", name: "$v" }, init: makeBinary("|", { type: "Identifier", name: "$b" }, makeLiteral(0)) },
7966
+ { type: "VariableDeclarator", id: { type: "Identifier", name: "$p" }, init: makeBinary("|", makeMemberIndex(aliasIdentA, { type: "Identifier", name: "$s" }), makeLiteral(0)) },
7967
+ { type: "VariableDeclarator", id: { type: "Identifier", name: "$q" }, init: makeBinary("|", makeMemberIndex(aliasIdentB, { type: "Identifier", name: "$d" }), makeLiteral(0)) },
7968
+ { type: "VariableDeclarator", id: { type: "Identifier", name: "$z" }, init: mbaAst }
7969
+ ]
7970
+ },
7971
+ {
7972
+ type: "ExpressionStatement",
7973
+ expression: {
7974
+ type: "AssignmentExpression",
7975
+ operator: "=",
7976
+ left: { type: "Identifier", name: "$z" },
7977
+ right: makeBinary(
7978
+ "|",
7979
+ makeBinary(
7980
+ "+",
7981
+ { type: "Identifier", name: "$f" },
7982
+ makeImul(
7983
+ { type: "Identifier", name: "$z" },
7984
+ makeBinary(
7985
+ "+",
7986
+ { type: "Identifier", name: "$g" },
7987
+ makeImul(
7988
+ { type: "Identifier", name: "$z" },
7989
+ makeBinary(
7990
+ "+",
7991
+ { type: "Identifier", name: "$h" },
7992
+ makeImul({ type: "Identifier", name: "$z" }, { type: "Identifier", name: "$i" })
7993
+ )
7994
+ )
7995
+ )
7493
7996
  )
7494
- )
7997
+ ),
7998
+ makeLiteral(0)
7495
7999
  )
7496
- )
7497
- ),
7498
- makeLiteral(0)
7499
- )
7500
- }
7501
- },
7502
- {
7503
- type: "ExpressionStatement",
7504
- expression: {
7505
- type: "AssignmentExpression",
7506
- operator: "=",
7507
- left: { type: "Identifier", name: "$z" },
7508
- right: buildSboxMixAst(sboxIdent, "$z")
7509
- }
7510
- },
7511
- {
7512
- type: "VariableDeclaration",
7513
- kind: "var",
7514
- declarations: [
7515
- {
7516
- type: "VariableDeclarator",
7517
- id: { type: "Identifier", name: "$m" },
7518
- init: makeBinary("^", makeBinary("<<", { type: "Identifier", name: "$z" }, makeLiteral(3)), { type: "Identifier", name: "$e" })
7519
- }
7520
- ]
7521
- },
7522
- {
7523
- type: "ExpressionStatement",
7524
- expression: {
7525
- type: "AssignmentExpression",
7526
- operator: "=",
7527
- left: makeMemberIndex(aliasIdentA, { type: "Identifier", name: "$c" }),
7528
- right: makeBinary("|", makeBinary("^", makeMemberIndex(aliasIdentA, { type: "Identifier", name: "$c" }), { type: "Identifier", name: "$m" }), makeLiteral(0))
7529
- }
7530
- },
7531
- {
7532
- type: "VariableDeclaration",
7533
- kind: "var",
7534
- declarations: [
7535
- {
7536
- type: "VariableDeclarator",
7537
- id: { type: "Identifier", name: "$w" },
7538
- init: makeBinary(
7539
- "^",
7540
- makeBinary("|", makeBinary("^", makeMemberIndex(aliasIdentA, { type: "Identifier", name: "$c" }), { type: "Identifier", name: "$m" }), makeLiteral(0)),
7541
- {
8000
+ }
8001
+ },
8002
+ {
8003
+ type: "ExpressionStatement",
8004
+ expression: {
8005
+ type: "AssignmentExpression",
8006
+ operator: "=",
8007
+ left: { type: "Identifier", name: "$z" },
8008
+ right: buildSboxMixAst(sboxIdent, "$z")
8009
+ }
8010
+ },
8011
+ {
8012
+ type: "VariableDeclaration",
8013
+ kind: "var",
8014
+ declarations: [
8015
+ {
8016
+ type: "VariableDeclarator",
8017
+ id: { type: "Identifier", name: "$m" },
8018
+ init: makeBinary("^", makeBinary("<<", { type: "Identifier", name: "$z" }, makeLiteral(3)), { type: "Identifier", name: "$e" })
8019
+ }
8020
+ ]
8021
+ },
8022
+ {
8023
+ type: "ExpressionStatement",
8024
+ expression: {
7542
8025
  type: "AssignmentExpression",
7543
8026
  operator: "=",
7544
- left: makeMemberIndex(aliasIdentA, { type: "Identifier", name: "$c" }),
7545
- right: makeBinary("|", makeBinary("^", makeMemberIndex(aliasIdentA, { type: "Identifier", name: "$c" }), { type: "Identifier", name: "$m" }), makeLiteral(0))
8027
+ left: makeMemberIndex(aliasIdentA, { type: "Identifier", name: "$s" }),
8028
+ right: makeBinary("|", makeBinary("^", makeMemberIndex(aliasIdentA, { type: "Identifier", name: "$s" }), { type: "Identifier", name: "$m" }), makeLiteral(0))
7546
8029
  }
7547
- )
8030
+ },
8031
+ {
8032
+ type: "VariableDeclaration",
8033
+ kind: "var",
8034
+ declarations: [
8035
+ {
8036
+ type: "VariableDeclarator",
8037
+ id: { type: "Identifier", name: "$w" },
8038
+ init: makeBinary(
8039
+ "^",
8040
+ makeBinary("|", makeBinary("^", makeMemberIndex(aliasIdentA, { type: "Identifier", name: "$s" }), { type: "Identifier", name: "$m" }), makeLiteral(0)),
8041
+ {
8042
+ type: "AssignmentExpression",
8043
+ operator: "=",
8044
+ left: makeMemberIndex(aliasIdentA, { type: "Identifier", name: "$s" }),
8045
+ right: makeBinary("|", makeBinary("^", makeMemberIndex(aliasIdentA, { type: "Identifier", name: "$s" }), { type: "Identifier", name: "$m" }), makeLiteral(0))
8046
+ }
8047
+ )
8048
+ }
8049
+ ]
8050
+ },
8051
+ {
8052
+ type: "ReturnStatement",
8053
+ argument: {
8054
+ type: "AssignmentExpression",
8055
+ operator: "=",
8056
+ left: { type: "Identifier", name: scratchVarIdent },
8057
+ right: makeBinary("|", makeBinary("^", { type: "Identifier", name: "$z" }, { type: "Identifier", name: "$w" }), makeLiteral(0))
8058
+ }
8059
+ }
8060
+ ]
8061
+ },
8062
+ handler: {
8063
+ type: "CatchClause",
8064
+ param: { type: "Identifier", name: "$e" },
8065
+ body: {
8066
+ type: "BlockStatement",
8067
+ body: [{ type: "ReturnStatement", argument: makeLiteral(0) }]
7548
8068
  }
7549
- ]
7550
- },
7551
- {
7552
- type: "ReturnStatement",
7553
- argument: {
7554
- type: "AssignmentExpression",
7555
- operator: "=",
7556
- left: { type: "Identifier", name: scratchVarIdent },
7557
- right: makeBinary("|", makeBinary("^", { type: "Identifier", name: "$z" }, { type: "Identifier", name: "$w" }), makeLiteral(0))
7558
- }
8069
+ },
8070
+ finalizer: null
7559
8071
  }
7560
8072
  ]
7561
8073
  },
@@ -7563,16 +8075,12 @@ function createSboxAndAliasDeclarations(sboxIdent, aliasIdentA, aliasIdentB, scr
7563
8075
  async: false,
7564
8076
  expression: false
7565
8077
  };
7566
- declarations.push({
7567
- type: "VariableDeclarator",
7568
- id: { type: "Identifier", name: mxIdent },
7569
- init: mxFn
7570
- });
7571
8078
  }
7572
8079
  return {
7573
- type: "VariableDeclaration",
7574
- kind: "var",
7575
- declarations
8080
+ varDecl,
8081
+ aliasInitStmt,
8082
+ latchFnDecl,
8083
+ ...mxFnDecl ? { mxFnDecl } : {}
7576
8084
  };
7577
8085
  }
7578
8086
  var MAX_COLD_GUARDS_PER_CHUNK = 12;
@@ -7679,16 +8187,16 @@ function analyzeBitwiseMbaScopes(ast) {
7679
8187
  return;
7680
8188
  }
7681
8189
  if (node.type === "ImportSpecifier" || node.type === "ImportDefaultSpecifier" || node.type === "ImportNamespaceSpecifier") {
7682
- if (_optionalChain([node, 'access', _442 => _442.local, 'optionalAccess', _443 => _443.type]) === "Identifier") {
8190
+ if (_optionalChain([node, 'access', _506 => _506.local, 'optionalAccess', _507 => _507.type]) === "Identifier") {
7683
8191
  addBinding(ast, node.local.name);
7684
8192
  }
7685
8193
  } else if (node.type === "FunctionDeclaration") {
7686
- if (_optionalChain([node, 'access', _444 => _444.id, 'optionalAccess', _445 => _445.type]) === "Identifier") {
8194
+ if (_optionalChain([node, 'access', _508 => _508.id, 'optionalAccess', _509 => _509.type]) === "Identifier") {
7687
8195
  addBinding(getNearestLexicalScope(), node.id.name);
7688
8196
  addBinding(getNearestVarScope(), node.id.name);
7689
8197
  }
7690
8198
  } else if (node.type === "ClassDeclaration") {
7691
- if (_optionalChain([node, 'access', _446 => _446.id, 'optionalAccess', _447 => _447.type]) === "Identifier") {
8199
+ if (_optionalChain([node, 'access', _510 => _510.id, 'optionalAccess', _511 => _511.type]) === "Identifier") {
7692
8200
  addBinding(getNearestLexicalScope(), node.id.name);
7693
8201
  }
7694
8202
  } else if (node.type === "VariableDeclaration") {
@@ -7712,7 +8220,7 @@ function analyzeBitwiseMbaScopes(ast) {
7712
8220
  }
7713
8221
  }
7714
8222
  if (isFn) {
7715
- if (_optionalChain([node, 'access', _448 => _448.id, 'optionalAccess', _449 => _449.type]) === "Identifier") {
8223
+ if (_optionalChain([node, 'access', _512 => _512.id, 'optionalAccess', _513 => _513.type]) === "Identifier") {
7716
8224
  addBinding(node, node.id.name);
7717
8225
  }
7718
8226
  for (const param of node.params || []) {
@@ -7722,7 +8230,7 @@ function analyzeBitwiseMbaScopes(ast) {
7722
8230
  addBinding(node, name);
7723
8231
  }
7724
8232
  }
7725
- const bodyScope = _optionalChain([node, 'access', _450 => _450.body, 'optionalAccess', _451 => _451.type]) === "BlockStatement" ? node.body : node;
8233
+ const bodyScope = _optionalChain([node, 'access', _514 => _514.body, 'optionalAccess', _515 => _515.type]) === "BlockStatement" ? node.body : node;
7726
8234
  varTargetStack.push(bodyScope);
7727
8235
  } else if (node.type === "Program" || isStaticBlock) {
7728
8236
  varTargetStack.push(node);
@@ -7732,7 +8240,7 @@ function analyzeBitwiseMbaScopes(ast) {
7732
8240
  for (const name of names) {
7733
8241
  addBinding(node, name);
7734
8242
  }
7735
- } else if (node.type === "ClassExpression" && _optionalChain([node, 'access', _452 => _452.id, 'optionalAccess', _453 => _453.type]) === "Identifier") {
8243
+ } else if (node.type === "ClassExpression" && _optionalChain([node, 'access', _516 => _516.id, 'optionalAccess', _517 => _517.type]) === "Identifier") {
7736
8244
  addBinding(node, node.id.name);
7737
8245
  }
7738
8246
  try {
@@ -7821,7 +8329,7 @@ function buildColdBitwiseConditional(op, left, right, seed, subIndex, hotExemptN
7821
8329
  const uniqueIdents = [];
7822
8330
  const seenNames = /* @__PURE__ */ new Set();
7823
8331
  for (const operand of [left, right]) {
7824
- if (_optionalChain([operand, 'optionalAccess', _454 => _454.type]) === "Identifier" && !seenNames.has(operand.name)) {
8332
+ if (_optionalChain([operand, 'optionalAccess', _518 => _518.type]) === "Identifier" && !seenNames.has(operand.name)) {
7825
8333
  seenNames.add(operand.name);
7826
8334
  uniqueIdents.push(operand);
7827
8335
  }
@@ -7862,7 +8370,7 @@ function applyColdBitwiseMba(ast, coldFunctionNodes, seed = 2654435769, hotExemp
7862
8370
  function walkTransform(node, setInParent, inColdFn) {
7863
8371
  if (mbaCount >= MAX_COLD_BITWISE_MBA_PER_CHUNK) return;
7864
8372
  if (!node || typeof node !== "object" || typeof node.type !== "string") return;
7865
- if (_optionalChain([hotExemptNodes, 'optionalAccess', _455 => _455.has, 'call', _456 => _456(node)]) || _optionalChain([guardSubtreeNodes, 'optionalAccess', _457 => _457.has, 'call', _458 => _458(node)])) return;
8373
+ if (_optionalChain([hotExemptNodes, 'optionalAccess', _519 => _519.has, 'call', _520 => _520(node)]) || _optionalChain([guardSubtreeNodes, 'optionalAccess', _521 => _521.has, 'call', _522 => _522(node)])) return;
7866
8374
  if (node._unpeekGuardSubtree === true) return;
7867
8375
  if (node._unpeekSerialized || node._unpeekVirtualized === true) return;
7868
8376
  if (BITWISE_LOOP_NODE_TYPES.has(node.type)) return;
@@ -7877,7 +8385,7 @@ function applyColdBitwiseMba(ast, coldFunctionNodes, seed = 2654435769, hotExemp
7877
8385
  if (!isCoercionOrZero) {
7878
8386
  const leftAtomic = isSafeAtomicIntegerLiteral(left) || isLocalBoundIdentifier(left, scopeStack, scopeBindings, ast);
7879
8387
  const rightAtomic = isSafeAtomicIntegerLiteral(right) || isLocalBoundIdentifier(right, scopeStack, scopeBindings, ast);
7880
- const hasIdent = _optionalChain([left, 'optionalAccess', _459 => _459.type]) === "Identifier" || _optionalChain([right, 'optionalAccess', _460 => _460.type]) === "Identifier";
8388
+ const hasIdent = _optionalChain([left, 'optionalAccess', _523 => _523.type]) === "Identifier" || _optionalChain([right, 'optionalAccess', _524 => _524.type]) === "Identifier";
7881
8389
  if (leftAtomic && rightAtomic && hasIdent) {
7882
8390
  const replacement = buildColdBitwiseConditional(
7883
8391
  op,
@@ -7931,99 +8439,348 @@ function applyColdBitwiseMba(ast, coldFunctionNodes, seed = 2654435769, hotExemp
7931
8439
  }, false);
7932
8440
  return mbaCount;
7933
8441
  }
8442
+ var UNSAFE_EXPRESSION_NODE_TYPES = /* @__PURE__ */ new Set(["Super", "WithStatement"]);
8443
+ var UNSAFE_IF_NODE_TYPES = /* @__PURE__ */ new Set([
8444
+ "Super",
8445
+ "WithStatement",
8446
+ "FunctionDeclaration",
8447
+ "ClassDeclaration"
8448
+ ]);
8449
+ function containsAstNodeType(node, types) {
8450
+ if (!node || typeof node !== "object") return false;
8451
+ if (Array.isArray(node)) {
8452
+ for (const item of node) {
8453
+ if (containsAstNodeType(item, types)) return true;
8454
+ }
8455
+ return false;
8456
+ }
8457
+ if (typeof node.type === "string" && types.has(node.type)) {
8458
+ return true;
8459
+ }
8460
+ for (const key of Object.keys(node)) {
8461
+ if (key === "loc" || key === "range" || key === "start" || key === "end" || key === "comments" || key === "tokens") {
8462
+ continue;
8463
+ }
8464
+ const val = node[key];
8465
+ if (val && typeof val === "object" && containsAstNodeType(val, types)) {
8466
+ return true;
8467
+ }
8468
+ }
8469
+ return false;
8470
+ }
8471
+ function collectMathUnsafeScopes(ast) {
8472
+ const unsafe = /* @__PURE__ */ new WeakSet();
8473
+ const findEnclosing = (ancestors) => {
8474
+ for (let i = ancestors.length - 1; i >= 0; i--) {
8475
+ if (BITWISE_LEXICAL_SCOPE_TYPES.has(ancestors[i].type)) {
8476
+ return ancestors[i];
8477
+ }
8478
+ }
8479
+ return ast;
8480
+ };
8481
+ const markScopeAndEnclosingFn = (ancestors, scopeNode) => {
8482
+ unsafe.add(scopeNode);
8483
+ const parent = ancestors.length >= 2 ? ancestors[ancestors.length - 2] : null;
8484
+ if (parent && BITWISE_FUNCTION_TYPES.has(parent.type) && parent.body === scopeNode) {
8485
+ unsafe.add(parent);
8486
+ }
8487
+ };
8488
+ const patternHasMath = (pat) => {
8489
+ const names = [];
8490
+ collectBoundPatternNames(pat, names);
8491
+ return names.includes("Math");
8492
+ };
8493
+ walk6.ancestor(ast, {
8494
+ WithStatement(node, _st, ancestors) {
8495
+ unsafe.add(node);
8496
+ for (let i = ancestors.length - 2; i >= 0; i--) {
8497
+ const a = ancestors[i];
8498
+ if (BITWISE_FUNCTION_TYPES.has(a.type)) {
8499
+ unsafe.add(a);
8500
+ break;
8501
+ }
8502
+ if (a.type === "Program") break;
8503
+ }
8504
+ },
8505
+ ImportSpecifier(node) {
8506
+ if (_optionalChain([node, 'access', _525 => _525.local, 'optionalAccess', _526 => _526.name]) === "Math") unsafe.add(ast);
8507
+ },
8508
+ ImportDefaultSpecifier(node) {
8509
+ if (_optionalChain([node, 'access', _527 => _527.local, 'optionalAccess', _528 => _528.name]) === "Math") unsafe.add(ast);
8510
+ },
8511
+ ImportNamespaceSpecifier(node) {
8512
+ if (_optionalChain([node, 'access', _529 => _529.local, 'optionalAccess', _530 => _530.name]) === "Math") unsafe.add(ast);
8513
+ },
8514
+ FunctionDeclaration(node, _st, ancestors) {
8515
+ if (_optionalChain([node, 'access', _531 => _531.id, 'optionalAccess', _532 => _532.name]) === "Math") {
8516
+ const prefix = ancestors.slice(0, -1);
8517
+ markScopeAndEnclosingFn(prefix, findEnclosing(prefix));
8518
+ unsafe.add(node);
8519
+ }
8520
+ if (Array.isArray(node.params) && node.params.some(patternHasMath)) {
8521
+ unsafe.add(node);
8522
+ }
8523
+ },
8524
+ FunctionExpression(node) {
8525
+ if (_optionalChain([node, 'access', _533 => _533.id, 'optionalAccess', _534 => _534.name]) === "Math" || Array.isArray(node.params) && node.params.some(patternHasMath)) {
8526
+ unsafe.add(node);
8527
+ }
8528
+ },
8529
+ ArrowFunctionExpression(node) {
8530
+ if (Array.isArray(node.params) && node.params.some(patternHasMath)) {
8531
+ unsafe.add(node);
8532
+ }
8533
+ },
8534
+ ClassDeclaration(node, _st, ancestors) {
8535
+ if (_optionalChain([node, 'access', _535 => _535.id, 'optionalAccess', _536 => _536.name]) === "Math") {
8536
+ const prefix = ancestors.slice(0, -1);
8537
+ markScopeAndEnclosingFn(prefix, findEnclosing(prefix));
8538
+ unsafe.add(node);
8539
+ }
8540
+ },
8541
+ ClassExpression(node) {
8542
+ if (_optionalChain([node, 'access', _537 => _537.id, 'optionalAccess', _538 => _538.name]) === "Math") {
8543
+ unsafe.add(node);
8544
+ }
8545
+ },
8546
+ CatchClause(node) {
8547
+ if (node.param && patternHasMath(node.param)) {
8548
+ unsafe.add(node);
8549
+ }
8550
+ },
8551
+ VariableDeclaration(node, _st, ancestors) {
8552
+ if (!Array.isArray(node.declarations) || !node.declarations.some((d) => patternHasMath(_optionalChain([d, 'optionalAccess', _539 => _539.id])))) {
8553
+ return;
8554
+ }
8555
+ if (node.kind === "var") {
8556
+ for (let i = ancestors.length - 1; i >= 0; i--) {
8557
+ const a = ancestors[i];
8558
+ if (BITWISE_FUNCTION_TYPES.has(a.type) || a.type === "StaticBlock" || a.type === "Program") {
8559
+ unsafe.add(a);
8560
+ break;
8561
+ }
8562
+ }
8563
+ } else {
8564
+ const prefix = ancestors.slice(0, -1);
8565
+ markScopeAndEnclosingFn(prefix, findEnclosing(prefix));
8566
+ }
8567
+ }
8568
+ });
8569
+ return unsafe;
8570
+ }
8571
+ function isAnyAncestorInSet(ancestors, set) {
8572
+ if (!set) return false;
8573
+ for (let i = ancestors.length - 1; i >= 0; i--) {
8574
+ if (set.has(ancestors[i])) return true;
8575
+ }
8576
+ return false;
8577
+ }
8578
+ function isDirectiveStatement(stmt) {
8579
+ if (!stmt || stmt.type !== "ExpressionStatement") return false;
8580
+ if (stmt.directive) return true;
8581
+ return _optionalChain([stmt, 'access', _540 => _540.expression, 'optionalAccess', _541 => _541.type]) === "Literal" && typeof stmt.expression.value === "string" && /^(?:use\s+[a-zA-Z0-9_-]+)/.test(stmt.expression.value.trim());
8582
+ }
8583
+ function isSafeC9Statement(stmt, hotExemptNodes) {
8584
+ if (!stmt || typeof stmt !== "object") return false;
8585
+ if (stmt._unpeekGuardSubtree === true) return false;
8586
+ if (_optionalChain([hotExemptNodes, 'optionalAccess', _542 => _542.has, 'call', _543 => _543(stmt)])) return false;
8587
+ if (stmt.type === "ExpressionStatement") {
8588
+ if (isDirectiveStatement(stmt)) return false;
8589
+ return !containsAstNodeType(stmt, UNSAFE_EXPRESSION_NODE_TYPES);
8590
+ }
8591
+ if (stmt.type === "IfStatement") {
8592
+ return !containsAstNodeType(stmt, UNSAFE_IF_NODE_TYPES);
8593
+ }
8594
+ return false;
8595
+ }
7934
8596
  function applyColdFlowGuard(ast, coldFunctionNodes, seed = 2654435769, hotExemptNodes, windowKeySymbol, expectedDelta, shieldCoupled = false, options) {
7935
- const sfx = (seed >>> 0).toString(36).slice(0, 4);
8597
+ const sfx = deriveColdFlowSuffix(seed);
7936
8598
  const decoyIdent = `_uDec${sfx}`;
7937
8599
  const sboxIdent = `_uSb${sfx}`;
7938
8600
  const aliasIdentA = `_uAl${sfx}`;
7939
8601
  const aliasIdentB = `_uAm${sfx}`;
7940
8602
  const scratchVarIdent = `_uZt${sfx}`;
7941
8603
  const mxIdent = `_uMx${sfx}`;
8604
+ const latchFnName = `_uLr${sfx}`;
7942
8605
  if (Array.isArray(ast.body)) {
7943
8606
  const alreadyGuarded = ast.body.some(
7944
- (stmt) => stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _461 => _461.declarations, 'optionalAccess', _462 => _462.some, 'call', _463 => _463(
7945
- (d) => _optionalChain([d, 'access', _464 => _464.id, 'optionalAccess', _465 => _465.type]) === "Identifier" && (d.id.name === decoyIdent || d.id.name === sboxIdent || d.id.name === mxIdent)
7946
- )])
8607
+ (stmt) => stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _544 => _544.declarations, 'optionalAccess', _545 => _545.some, 'call', _546 => _546(
8608
+ (d) => _optionalChain([d, 'access', _547 => _547.id, 'optionalAccess', _548 => _548.type]) === "Identifier" && (d.id.name === decoyIdent || d.id.name === sboxIdent || d.id.name === mxIdent)
8609
+ )]) || stmt.type === "FunctionDeclaration" && _optionalChain([stmt, 'access', _549 => _549.id, 'optionalAccess', _550 => _550.type]) === "Identifier" && (stmt.id.name === mxIdent || stmt.id.name === latchFnName)
7947
8610
  );
7948
8611
  if (alreadyGuarded) return 0;
7949
8612
  }
7950
- if (_optionalChain([options, 'optionalAccess', _466 => _466.enableBitwiseMba])) {
8613
+ if (_optionalChain([options, 'optionalAccess', _551 => _551.enableBitwiseMba])) {
7951
8614
  applyColdBitwiseMba(ast, coldFunctionNodes, seed, hotExemptNodes);
7952
8615
  }
7953
- let guardedCount = 0;
7954
- function maybeInjectGuard(node) {
7955
- if (guardedCount >= MAX_COLD_GUARDS_PER_CHUNK) return;
8616
+ const mathUnsafeScopes = collectMathUnsafeScopes(ast);
8617
+ const C9_RESERVED_SLOTS = 4;
8618
+ const eligibleColdFns = [];
8619
+ function collectEligibleColdFn(node, _state, ancestors) {
8620
+ if (eligibleColdFns.length >= MAX_COLD_GUARDS_PER_CHUNK) return;
7956
8621
  if (!coldFunctionNodes.has(node)) return;
7957
- if (_optionalChain([hotExemptNodes, 'optionalAccess', _467 => _467.has, 'call', _468 => _468(node)]) || node._unpeekSerialized) return;
8622
+ if (isAnyAncestorInSet(ancestors, hotExemptNodes)) return;
8623
+ if (isAnyAncestorInSet(ancestors, mathUnsafeScopes)) return;
8624
+ if (node._unpeekSerialized) return;
7958
8625
  if (node._unpeekVirtualized === true) return;
7959
8626
  if (!node.body || node.body.type !== "BlockStatement") return;
7960
8627
  const paramNames = [];
7961
8628
  for (const p of node.params || []) {
7962
8629
  extractParamNames(p, paramNames);
7963
8630
  }
7964
- const firstParam = _optionalChain([node, 'access', _469 => _469.params, 'optionalAccess', _470 => _470[0]]);
7965
- const isArrow = node.type === "ArrowFunctionExpression";
7966
- const returnDomain = inferFunctionReturnDomain(node);
8631
+ eligibleColdFns.push({
8632
+ node,
8633
+ paramNames,
8634
+ firstParam: _optionalChain([node, 'access', _552 => _552.params, 'optionalAccess', _553 => _553[0]]),
8635
+ isArrow: node.type === "ArrowFunctionExpression",
8636
+ returnDomain: inferFunctionReturnDomain(node)
8637
+ });
8638
+ }
8639
+ walk6.ancestor(ast, {
8640
+ FunctionDeclaration: collectEligibleColdFn,
8641
+ FunctionExpression: collectEligibleColdFn,
8642
+ ArrowFunctionExpression: collectEligibleColdFn
8643
+ });
8644
+ let availableC9Slots = 0;
8645
+ for (const fnInfo of eligibleColdFns) {
8646
+ if (availableC9Slots >= C9_RESERVED_SLOTS) break;
8647
+ const bodyStmts = fnInfo.node.body.body;
8648
+ let idx = 0;
8649
+ while (idx < bodyStmts.length && isDirectiveStatement(bodyStmts[idx])) {
8650
+ idx++;
8651
+ }
8652
+ for (; idx < bodyStmts.length; idx++) {
8653
+ if (isSafeC9Statement(bodyStmts[idx], hotExemptNodes)) {
8654
+ availableC9Slots++;
8655
+ if (availableC9Slots >= C9_RESERVED_SLOTS) break;
8656
+ }
8657
+ }
8658
+ }
8659
+ const opaqueFalseLimit = MAX_COLD_GUARDS_PER_CHUNK - availableC9Slots;
8660
+ let opaqueFalseCount = 0;
8661
+ for (let i = 0; i < eligibleColdFns.length && opaqueFalseCount < opaqueFalseLimit; i++) {
8662
+ const fnInfo = eligibleColdFns[i];
7967
8663
  const guardStmt = createSotaMbaPredicate(
7968
8664
  seed,
7969
- guardedCount,
7970
- firstParam,
8665
+ opaqueFalseCount,
8666
+ fnInfo.firstParam,
7971
8667
  decoyIdent,
7972
- isArrow,
8668
+ fnInfo.isArrow,
7973
8669
  {
7974
- liveVars: paramNames,
8670
+ liveVars: fnInfo.paramNames,
7975
8671
  sboxIdent,
7976
8672
  aliasIdentA,
7977
8673
  aliasIdentB,
7978
8674
  scratchVarIdent,
7979
8675
  mxIdent,
7980
- returnDomain,
8676
+ returnDomain: fnInfo.returnDomain,
7981
8677
  windowKeySymbol,
7982
8678
  expectedDelta,
7983
8679
  shieldCoupled
7984
8680
  }
7985
8681
  );
7986
- guardedCount++;
8682
+ opaqueFalseCount++;
7987
8683
  guardStmt._unpeekGuardSubtree = true;
7988
8684
  if (hotExemptNodes) {
7989
8685
  hotExemptNodes.add(guardStmt);
7990
8686
  hotExemptNodes.add(guardStmt.consequent);
7991
8687
  }
7992
8688
  let insertIdx = 0;
7993
- while (insertIdx < node.body.body.length && node.body.body[insertIdx].type === "ExpressionStatement" && node.body.body[insertIdx].directive) {
8689
+ while (insertIdx < fnInfo.node.body.body.length && isDirectiveStatement(fnInfo.node.body.body[insertIdx])) {
7994
8690
  insertIdx++;
7995
8691
  }
7996
- node.body.body.splice(insertIdx, 0, guardStmt);
8692
+ fnInfo.node.body.body.splice(insertIdx, 0, guardStmt);
7997
8693
  }
7998
- walk6.simple(ast, {
7999
- FunctionDeclaration: maybeInjectGuard,
8000
- FunctionExpression: maybeInjectGuard,
8001
- ArrowFunctionExpression: maybeInjectGuard
8002
- });
8003
- if (guardedCount > 0 && Array.isArray(ast.body)) {
8694
+ let c9WrappedCount = 0;
8695
+ if (eligibleColdFns.length > 0 && opaqueFalseCount < MAX_COLD_GUARDS_PER_CHUNK) {
8696
+ const fnCursors = eligibleColdFns.map((fnInfo) => {
8697
+ const bodyStmts = fnInfo.node.body.body;
8698
+ let startIdx = 0;
8699
+ while (startIdx < bodyStmts.length && isDirectiveStatement(bodyStmts[startIdx])) {
8700
+ startIdx++;
8701
+ }
8702
+ return { fnInfo, bodyStmts, idx: startIdx };
8703
+ });
8704
+ let progress = true;
8705
+ while (progress && opaqueFalseCount + c9WrappedCount < MAX_COLD_GUARDS_PER_CHUNK) {
8706
+ progress = false;
8707
+ for (const cursor of fnCursors) {
8708
+ if (opaqueFalseCount + c9WrappedCount >= MAX_COLD_GUARDS_PER_CHUNK) break;
8709
+ const { fnInfo, bodyStmts } = cursor;
8710
+ while (cursor.idx < bodyStmts.length) {
8711
+ const stmt = bodyStmts[cursor.idx];
8712
+ const curIdx = cursor.idx++;
8713
+ if (!isSafeC9Statement(stmt, hotExemptNodes)) continue;
8714
+ const pred = createSotaMbaPredicate(
8715
+ seed,
8716
+ opaqueFalseCount + c9WrappedCount,
8717
+ fnInfo.firstParam,
8718
+ decoyIdent,
8719
+ fnInfo.isArrow,
8720
+ {
8721
+ liveVars: fnInfo.paramNames,
8722
+ sboxIdent,
8723
+ aliasIdentA,
8724
+ aliasIdentB,
8725
+ scratchVarIdent,
8726
+ mxIdent,
8727
+ returnDomain: "void",
8728
+ windowKeySymbol,
8729
+ expectedDelta,
8730
+ shieldCoupled
8731
+ }
8732
+ );
8733
+ const negatedTest = makeUnary("!", pred.test);
8734
+ negatedTest._unpeekGuardSubtree = true;
8735
+ if (hotExemptNodes) {
8736
+ hotExemptNodes.add(negatedTest);
8737
+ }
8738
+ bodyStmts[curIdx] = {
8739
+ type: "IfStatement",
8740
+ test: negatedTest,
8741
+ consequent: {
8742
+ type: "BlockStatement",
8743
+ body: [stmt]
8744
+ },
8745
+ alternate: null
8746
+ };
8747
+ c9WrappedCount++;
8748
+ progress = true;
8749
+ break;
8750
+ }
8751
+ }
8752
+ }
8753
+ }
8754
+ if ((opaqueFalseCount > 0 || c9WrappedCount > 0) && Array.isArray(ast.body)) {
8004
8755
  const sharedDecoyDecl = createSharedDecoyDeclaration(
8005
8756
  decoyIdent,
8006
- guardedCount,
8757
+ Math.max(1, opaqueFalseCount),
8007
8758
  seed
8008
8759
  );
8009
- const sboxAliasDecl = createSboxAndAliasDeclarations(
8760
+ const { varDecl, aliasInitStmt, latchFnDecl, mxFnDecl } = createColdFlowRuntimeDeclarations(
8010
8761
  sboxIdent,
8011
8762
  aliasIdentA,
8012
8763
  aliasIdentB,
8013
8764
  scratchVarIdent,
8014
8765
  seed,
8766
+ latchFnName,
8015
8767
  mxIdent
8016
8768
  );
8769
+ aliasInitStmt._unpeekGuardSubtree = true;
8770
+ latchFnDecl._unpeekGuardSubtree = true;
8771
+ if (mxFnDecl) {
8772
+ mxFnDecl._unpeekGuardSubtree = true;
8773
+ }
8017
8774
  if (hotExemptNodes) {
8018
8775
  hotExemptNodes.add(sharedDecoyDecl);
8019
- hotExemptNodes.add(sboxAliasDecl);
8020
- for (const decl of sboxAliasDecl.declarations || []) {
8021
- if (_optionalChain([decl, 'access', _471 => _471.init, 'optionalAccess', _472 => _472.type]) === "FunctionExpression") {
8022
- hotExemptNodes.add(decl.init);
8023
- }
8776
+ hotExemptNodes.add(varDecl);
8777
+ hotExemptNodes.add(aliasInitStmt);
8778
+ hotExemptNodes.add(latchFnDecl);
8779
+ if (mxFnDecl) {
8780
+ hotExemptNodes.add(mxFnDecl);
8024
8781
  }
8025
8782
  for (const decl of sharedDecoyDecl.declarations || []) {
8026
- if (_optionalChain([decl, 'access', _473 => _473.init, 'optionalAccess', _474 => _474.type]) === "ArrayExpression" && decl.init.elements) {
8783
+ if (_optionalChain([decl, 'access', _554 => _554.init, 'optionalAccess', _555 => _555.type]) === "ArrayExpression" && decl.init.elements) {
8027
8784
  for (const el of decl.init.elements) {
8028
8785
  if (el) hotExemptNodes.add(el);
8029
8786
  }
@@ -8033,16 +8790,23 @@ function applyColdFlowGuard(ast, coldFunctionNodes, seed = 2654435769, hotExempt
8033
8790
  let insertIdx = 0;
8034
8791
  while (insertIdx < ast.body.length) {
8035
8792
  const stmt = ast.body[insertIdx];
8036
- const isDirective = stmt.type === "ExpressionStatement" && (Boolean(stmt.directive) || _optionalChain([stmt, 'access', _475 => _475.expression, 'optionalAccess', _476 => _476.type]) === "Literal" && typeof stmt.expression.value === "string" && /^(?:use\s+[a-zA-Z0-9_-]+)/.test(stmt.expression.value.trim()));
8793
+ const isDirective = stmt.type === "ExpressionStatement" && (Boolean(stmt.directive) || _optionalChain([stmt, 'access', _556 => _556.expression, 'optionalAccess', _557 => _557.type]) === "Literal" && typeof stmt.expression.value === "string" && /^(?:use\s+[a-zA-Z0-9_-]+)/.test(stmt.expression.value.trim()));
8037
8794
  if (isDirective || stmt.type === "ImportDeclaration") {
8038
8795
  insertIdx++;
8039
8796
  } else {
8040
8797
  break;
8041
8798
  }
8042
8799
  }
8043
- ast.body.splice(insertIdx, 0, sboxAliasDecl, sharedDecoyDecl);
8800
+ const injectedDecls = [
8801
+ varDecl,
8802
+ aliasInitStmt,
8803
+ latchFnDecl,
8804
+ ...mxFnDecl ? [mxFnDecl] : [],
8805
+ sharedDecoyDecl
8806
+ ];
8807
+ ast.body.splice(insertIdx, 0, ...injectedDecls);
8044
8808
  }
8045
- return guardedCount;
8809
+ return opaqueFalseCount;
8046
8810
  }
8047
8811
 
8048
8812
  // src/ast/micro-vm.ts
@@ -8091,7 +8855,8 @@ var OP_TRY = 39;
8091
8855
  var OP_ENDTRY = 40;
8092
8856
  var OP_NULLISH = 41;
8093
8857
  var OP_DUP = 42;
8094
- var OPCODE_COUNT = 43;
8858
+ var OP_TOSTR = 43;
8859
+ var OPCODE_COUNT = 44;
8095
8860
  function shuffleRange(n, seed) {
8096
8861
  const arr = [];
8097
8862
  for (let i = 0; i < n; i++) arr.push(i);
@@ -8151,14 +8916,14 @@ function encryptBytecodeStream(plainBytecode, fnSalt, vmKey, stateSlots, accSlot
8151
8916
  accBefore[len] = ac;
8152
8917
  if (stateSlots) {
8153
8918
  for (const slot of stateSlots) {
8154
- const targetPc = _nullishCoalesce(_optionalChain([jumpTargets, 'optionalAccess', _477 => _477.get, 'call', _478 => _478(slot - 1)]), () => ( plainBytecode[slot - 1]));
8919
+ const targetPc = _nullishCoalesce(_optionalChain([jumpTargets, 'optionalAccess', _558 => _558.get, 'call', _559 => _559(slot - 1)]), () => ( plainBytecode[slot - 1]));
8155
8920
  const sBefore = _nullishCoalesce(stAtSlot.get(slot), () => ( 0));
8156
8921
  enc[slot] = stateBefore[targetPc] ^ sBefore | 0;
8157
8922
  }
8158
8923
  }
8159
8924
  if (accSlots) {
8160
8925
  for (const slot of accSlots) {
8161
- const targetPc = _nullishCoalesce(_optionalChain([jumpTargets, 'optionalAccess', _479 => _479.get, 'call', _480 => _480(slot - 2)]), () => ( plainBytecode[slot - 2]));
8926
+ const targetPc = _nullishCoalesce(_optionalChain([jumpTargets, 'optionalAccess', _560 => _560.get, 'call', _561 => _561(slot - 2)]), () => ( plainBytecode[slot - 2]));
8162
8927
  const aBefore = _nullishCoalesce(acAtSlot.get(slot), () => ( 0));
8163
8928
  enc[slot] = accBefore[targetPc] ^ aBefore | 0;
8164
8929
  }
@@ -8275,7 +9040,8 @@ function createInterpreterSource(vmHelperName, opMap, seed = 2654435769, windowK
8275
9040
  [OP_TRY]: { body: "var $cp=($rd($f)-$Z)&0xffff,$cs=$f.c[$f.p++]^$f.st,$ca=$f.c[$f.p++]^$f.ac;$f.e.push({p:$cp,r:$f.r,s:$cs,a:$ca});" },
8276
9041
  [OP_ENDTRY]: { body: "$f.r=($f.r+$Z)|0;$f.e.pop();$f.r=($f.r-$B)|0;" },
8277
9042
  [OP_NULLISH]: { body: "$f.r=($f.r+$Z)|0;var $v=$f.q[$f.r-(1+$B)];$f.q[$f.r-(1+$B)]=($v===null||$v===void 0);$f.r=($f.r-$B)|0;" },
8278
- [OP_DUP]: { body: "$f.r=($f.r+$Z)|0;var $top=$f.q[$f.r-(1+$B)];$f.q[($f.r++)-$B]=$top;$f.r=($f.r-$B)|0;" }
9043
+ [OP_DUP]: { body: "$f.r=($f.r+$Z)|0;var $top=$f.q[$f.r-(1+$B)];$f.q[($f.r++)-$B]=$top;$f.r=($f.r-$B)|0;" },
9044
+ [OP_TOSTR]: { body: "$f.r=($f.r+$Z)|0;var $v=$f.q[$f.r-(1+$B)];$f.r=($f.r-$B)|0;$f.q[$f.r-1]=`${$v}`;" }
8279
9045
  };
8280
9046
  const handlers = new Array(opCount);
8281
9047
  for (let op = 0; op < opCount; op++) {
@@ -8448,7 +9214,7 @@ function prepareLoweredFunction(fnNode, enclosingBindings) {
8448
9214
  loweredParams.push({ type: "Identifier", name: param.name });
8449
9215
  continue;
8450
9216
  }
8451
- if (param.type === "RestElement" && _optionalChain([param, 'access', _481 => _481.argument, 'optionalAccess', _482 => _482.type]) === "Identifier") {
9217
+ if (param.type === "RestElement" && _optionalChain([param, 'access', _562 => _562.argument, 'optionalAccess', _563 => _563.type]) === "Identifier") {
8452
9218
  wrapperParams.push(param);
8453
9219
  paramPassExprs.push({ type: "Identifier", name: param.argument.name });
8454
9220
  loweredParams.push({ type: "Identifier", name: param.argument.name });
@@ -8507,7 +9273,7 @@ function prepareLoweredFunction(fnNode, enclosingBindings) {
8507
9273
  return null;
8508
9274
  }
8509
9275
  clone.params = loweredParams;
8510
- if (_optionalChain([clone, 'access', _483 => _483.body, 'optionalAccess', _484 => _484.type]) !== "BlockStatement") {
9276
+ if (_optionalChain([clone, 'access', _564 => _564.body, 'optionalAccess', _565 => _565.type]) !== "BlockStatement") {
8511
9277
  clone.body = {
8512
9278
  type: "BlockStatement",
8513
9279
  body: [
@@ -8615,7 +9381,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
8615
9381
  }
8616
9382
  if (node.type === "TryStatement") {
8617
9383
  scanVarDecls(node.block, false);
8618
- if (_optionalChain([node, 'access', _485 => _485.handler, 'optionalAccess', _486 => _486.body])) scanVarDecls(node.handler.body, false);
9384
+ if (_optionalChain([node, 'access', _566 => _566.handler, 'optionalAccess', _567 => _567.body])) scanVarDecls(node.handler.body, false);
8619
9385
  if (node.finalizer) scanVarDecls(node.finalizer, false);
8620
9386
  return;
8621
9387
  }
@@ -8740,7 +9506,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
8740
9506
  if (prop.computed) {
8741
9507
  if (!compileExpr(prop.key, true)) return false;
8742
9508
  } else {
8743
- const keyName = _optionalChain([prop, 'access', _487 => _487.key, 'optionalAccess', _488 => _488.type]) === "Identifier" ? prop.key.name : _optionalChain([prop, 'access', _489 => _489.key, 'optionalAccess', _490 => _490.type]) === "Literal" ? String(prop.key.value) : void 0;
9509
+ const keyName = _optionalChain([prop, 'access', _568 => _568.key, 'optionalAccess', _569 => _569.type]) === "Identifier" ? prop.key.name : _optionalChain([prop, 'access', _570 => _570.key, 'optionalAccess', _571 => _571.type]) === "Literal" ? String(prop.key.value) : void 0;
8744
9510
  if (keyName === void 0) return false;
8745
9511
  emit(OP_LDC, addConst(keyName));
8746
9512
  }
@@ -8879,11 +9645,12 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
8879
9645
  case "TemplateLiteral": {
8880
9646
  const quasis = node.quasis || [];
8881
9647
  const exprs = node.expressions || [];
8882
- emit(OP_LDC, addConst(_nullishCoalesce(_nullishCoalesce(_optionalChain([quasis, 'access', _491 => _491[0], 'optionalAccess', _492 => _492.value, 'optionalAccess', _493 => _493.cooked]), () => ( _optionalChain([quasis, 'access', _494 => _494[0], 'optionalAccess', _495 => _495.value, 'optionalAccess', _496 => _496.raw]))), () => ( ""))));
9648
+ emit(OP_LDC, addConst(_nullishCoalesce(_nullishCoalesce(_optionalChain([quasis, 'access', _572 => _572[0], 'optionalAccess', _573 => _573.value, 'optionalAccess', _574 => _574.cooked]), () => ( _optionalChain([quasis, 'access', _575 => _575[0], 'optionalAccess', _576 => _576.value, 'optionalAccess', _577 => _577.raw]))), () => ( ""))));
8883
9649
  for (let i = 0; i < exprs.length; i++) {
8884
9650
  if (!compileExpr(exprs[i], true)) return false;
9651
+ emit(OP_TOSTR);
8885
9652
  emit(OP_ADD);
8886
- const qStr = _nullishCoalesce(_nullishCoalesce(_optionalChain([quasis, 'access', _497 => _497[i + 1], 'optionalAccess', _498 => _498.value, 'optionalAccess', _499 => _499.cooked]), () => ( _optionalChain([quasis, 'access', _500 => _500[i + 1], 'optionalAccess', _501 => _501.value, 'optionalAccess', _502 => _502.raw]))), () => ( ""));
9653
+ const qStr = _nullishCoalesce(_nullishCoalesce(_optionalChain([quasis, 'access', _578 => _578[i + 1], 'optionalAccess', _579 => _579.value, 'optionalAccess', _580 => _580.cooked]), () => ( _optionalChain([quasis, 'access', _581 => _581[i + 1], 'optionalAccess', _582 => _582.value, 'optionalAccess', _583 => _583.raw]))), () => ( ""));
8887
9654
  if (qStr.length > 0) {
8888
9655
  emit(OP_LDC, addConst(qStr));
8889
9656
  emit(OP_ADD);
@@ -8969,7 +9736,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
8969
9736
  if (inValuePos) emit(OP_LDC, addConst(void 0));
8970
9737
  return true;
8971
9738
  }
8972
- if (node.operator === "typeof" && _optionalChain([node, 'access', _503 => _503.argument, 'optionalAccess', _504 => _504.type]) === "Identifier") {
9739
+ if (node.operator === "typeof" && _optionalChain([node, 'access', _584 => _584.argument, 'optionalAccess', _585 => _585.type]) === "Identifier") {
8973
9740
  const name = node.argument.name;
8974
9741
  if (name === "undefined" && resolveLocal("undefined") === void 0) {
8975
9742
  emit(OP_LDC, addConst(void 0));
@@ -9016,7 +9783,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
9016
9783
  if (node.computed) {
9017
9784
  if (!compileExpr(node.property, true)) return false;
9018
9785
  } else {
9019
- if (_optionalChain([node, 'access', _505 => _505.property, 'optionalAccess', _506 => _506.type]) !== "Identifier") return false;
9786
+ if (_optionalChain([node, 'access', _586 => _586.property, 'optionalAccess', _587 => _587.type]) !== "Identifier") return false;
9020
9787
  emit(OP_LDC, addConst(node.property.name));
9021
9788
  }
9022
9789
  emit(OP_GETP);
@@ -9026,7 +9793,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
9026
9793
  case "CallExpression": {
9027
9794
  if (node.optional) return false;
9028
9795
  for (const arg of node.arguments || []) {
9029
- if (_optionalChain([arg, 'optionalAccess', _507 => _507.type]) === "SpreadElement") return false;
9796
+ if (_optionalChain([arg, 'optionalAccess', _588 => _588.type]) === "SpreadElement") return false;
9030
9797
  }
9031
9798
  if (node.callee.type === "MemberExpression") {
9032
9799
  if (node.callee.optional) return false;
@@ -9034,7 +9801,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
9034
9801
  if (node.callee.computed) {
9035
9802
  if (!compileExpr(node.callee.property, true)) return false;
9036
9803
  } else {
9037
- if (_optionalChain([node, 'access', _508 => _508.callee, 'access', _509 => _509.property, 'optionalAccess', _510 => _510.type]) !== "Identifier") return false;
9804
+ if (_optionalChain([node, 'access', _589 => _589.callee, 'access', _590 => _590.property, 'optionalAccess', _591 => _591.type]) !== "Identifier") return false;
9038
9805
  emit(OP_LDC, addConst(node.callee.property.name));
9039
9806
  }
9040
9807
  for (const arg of node.arguments) {
@@ -9053,7 +9820,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
9053
9820
  }
9054
9821
  case "NewExpression": {
9055
9822
  for (const arg of node.arguments || []) {
9056
- if (_optionalChain([arg, 'optionalAccess', _511 => _511.type]) === "SpreadElement") return false;
9823
+ if (_optionalChain([arg, 'optionalAccess', _592 => _592.type]) === "SpreadElement") return false;
9057
9824
  }
9058
9825
  if (!compileExpr(node.callee, true)) return false;
9059
9826
  for (const arg of node.arguments || []) {
@@ -9096,7 +9863,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
9096
9863
  if (node.left.computed) {
9097
9864
  if (!compileExpr(node.left.property, true)) return false;
9098
9865
  } else {
9099
- if (_optionalChain([node, 'access', _512 => _512.left, 'access', _513 => _513.property, 'optionalAccess', _514 => _514.type]) !== "Identifier") return false;
9866
+ if (_optionalChain([node, 'access', _593 => _593.left, 'access', _594 => _594.property, 'optionalAccess', _595 => _595.type]) !== "Identifier") return false;
9100
9867
  emit(OP_LDC, addConst(node.left.property.name));
9101
9868
  }
9102
9869
  if (!compileExpr(node.right, true)) return false;
@@ -9112,7 +9879,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
9112
9879
  if (node.left.computed) {
9113
9880
  if (!compileExpr(node.left.property, true)) return false;
9114
9881
  } else {
9115
- if (_optionalChain([node, 'access', _515 => _515.left, 'access', _516 => _516.property, 'optionalAccess', _517 => _517.type]) !== "Identifier") return false;
9882
+ if (_optionalChain([node, 'access', _596 => _596.left, 'access', _597 => _597.property, 'optionalAccess', _598 => _598.type]) !== "Identifier") return false;
9116
9883
  emit(OP_LDC, addConst(node.left.property.name));
9117
9884
  }
9118
9885
  emit(OP_STV, keySlot);
@@ -9132,7 +9899,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
9132
9899
  case "UpdateExpression": {
9133
9900
  const oneIdx = addConst(1);
9134
9901
  const stepOp = node.operator === "++" ? OP_ADD : OP_SUB;
9135
- if (_optionalChain([node, 'access', _518 => _518.argument, 'optionalAccess', _519 => _519.type]) === "Identifier") {
9902
+ if (_optionalChain([node, 'access', _599 => _599.argument, 'optionalAccess', _600 => _600.type]) === "Identifier") {
9136
9903
  const name = node.argument.name;
9137
9904
  if (!canWriteVar(name)) return false;
9138
9905
  if (node.prefix) {
@@ -9158,7 +9925,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
9158
9925
  }
9159
9926
  return true;
9160
9927
  }
9161
- if (_optionalChain([node, 'access', _520 => _520.argument, 'optionalAccess', _521 => _521.type]) === "MemberExpression" && !node.argument.optional) {
9928
+ if (_optionalChain([node, 'access', _601 => _601.argument, 'optionalAccess', _602 => _602.type]) === "MemberExpression" && !node.argument.optional) {
9162
9929
  const objSlot = allocTempSlot();
9163
9930
  const keySlot = allocTempSlot();
9164
9931
  const oldSlot = allocTempSlot();
@@ -9167,7 +9934,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
9167
9934
  if (node.argument.computed) {
9168
9935
  if (!compileExpr(node.argument.property, true)) return false;
9169
9936
  } else {
9170
- if (_optionalChain([node, 'access', _522 => _522.argument, 'access', _523 => _523.property, 'optionalAccess', _524 => _524.type]) !== "Identifier") return false;
9937
+ if (_optionalChain([node, 'access', _603 => _603.argument, 'access', _604 => _604.property, 'optionalAccess', _605 => _605.type]) !== "Identifier") return false;
9171
9938
  emit(OP_LDC, addConst(node.argument.property.name));
9172
9939
  }
9173
9940
  emit(OP_STV, keySlot);
@@ -9199,7 +9966,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
9199
9966
  if (prop.computed) {
9200
9967
  if (!compileExpr(prop.key, true)) return false;
9201
9968
  } else {
9202
- const keyName = _nullishCoalesce(_optionalChain([prop, 'access', _525 => _525.key, 'optionalAccess', _526 => _526.name]), () => ( _optionalChain([prop, 'access', _527 => _527.key, 'optionalAccess', _528 => _528.value])));
9969
+ const keyName = _nullishCoalesce(_optionalChain([prop, 'access', _606 => _606.key, 'optionalAccess', _607 => _607.name]), () => ( _optionalChain([prop, 'access', _608 => _608.key, 'optionalAccess', _609 => _609.value])));
9203
9970
  if (keyName === void 0) return false;
9204
9971
  emit(OP_LDC, addConst(keyName));
9205
9972
  }
@@ -9251,14 +10018,14 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
9251
10018
  }
9252
10019
  case "VariableDeclaration": {
9253
10020
  for (const decl of stmt.declarations) {
9254
- if (_optionalChain([decl, 'access', _529 => _529.id, 'optionalAccess', _530 => _530.type]) === "Identifier") {
10021
+ if (_optionalChain([decl, 'access', _610 => _610.id, 'optionalAccess', _611 => _611.type]) === "Identifier") {
9255
10022
  const slot = resolveLocal(decl.id.name);
9256
10023
  if (slot === void 0) return false;
9257
10024
  if (decl.init) {
9258
10025
  if (!compileExpr(decl.init, true)) return false;
9259
10026
  emit(OP_STV, slot);
9260
10027
  }
9261
- } else if (_optionalChain([decl, 'access', _531 => _531.id, 'optionalAccess', _532 => _532.type]) === "ObjectPattern" || _optionalChain([decl, 'access', _533 => _533.id, 'optionalAccess', _534 => _534.type]) === "ArrayPattern") {
10028
+ } else if (_optionalChain([decl, 'access', _612 => _612.id, 'optionalAccess', _613 => _613.type]) === "ObjectPattern" || _optionalChain([decl, 'access', _614 => _614.id, 'optionalAccess', _615 => _615.type]) === "ArrayPattern") {
9262
10029
  if (!decl.init) return false;
9263
10030
  const srcSlot = allocTempSlot();
9264
10031
  if (!compileExpr(decl.init, true)) return false;
@@ -9354,7 +10121,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
9354
10121
  }
9355
10122
  case "ForStatement": {
9356
10123
  let pushedForScope = false;
9357
- if (_optionalChain([stmt, 'access', _535 => _535.init, 'optionalAccess', _536 => _536.type]) === "VariableDeclaration" && stmt.init.kind !== "var") {
10124
+ if (_optionalChain([stmt, 'access', _616 => _616.init, 'optionalAccess', _617 => _617.type]) === "VariableDeclaration" && stmt.init.kind !== "var") {
9358
10125
  const forScope = /* @__PURE__ */ new Map();
9359
10126
  const names = /* @__PURE__ */ new Set();
9360
10127
  for (const decl of stmt.init.declarations || []) {
@@ -9422,7 +10189,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
9422
10189
  case "BreakStatement":
9423
10190
  case "ContinueStatement": {
9424
10191
  const isBreak = stmt.type === "BreakStatement";
9425
- const labelName = _optionalChain([stmt, 'access', _537 => _537.label, 'optionalAccess', _538 => _538.name]);
10192
+ const labelName = _optionalChain([stmt, 'access', _618 => _618.label, 'optionalAccess', _619 => _619.name]);
9426
10193
  let target;
9427
10194
  for (let i = loopStack.length - 1; i >= 0; i--) {
9428
10195
  if (!labelName || loopStack[i].label === labelName) {
@@ -9441,7 +10208,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
9441
10208
  return true;
9442
10209
  }
9443
10210
  case "LabeledStatement": {
9444
- return compileStmt(stmt.body, false, _optionalChain([stmt, 'access', _539 => _539.label, 'optionalAccess', _540 => _540.name]));
10211
+ return compileStmt(stmt.body, false, _optionalChain([stmt, 'access', _620 => _620.label, 'optionalAccess', _621 => _621.name]));
9445
10212
  }
9446
10213
  case "TryStatement": {
9447
10214
  if (stmt.finalizer) {
@@ -9571,12 +10338,12 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
9571
10338
  function findInjectedVmHelperName(ast) {
9572
10339
  if (!ast || !Array.isArray(ast.body)) return null;
9573
10340
  for (const stmt of ast.body) {
9574
- if (stmt.type === "FunctionDeclaration" && typeof _optionalChain([stmt, 'access', _541 => _541.id, 'optionalAccess', _542 => _542.name]) === "string" && stmt.id.name.startsWith("_uVm")) {
10341
+ if (stmt.type === "FunctionDeclaration" && typeof _optionalChain([stmt, 'access', _622 => _622.id, 'optionalAccess', _623 => _623.name]) === "string" && stmt.id.name.startsWith("_uVm")) {
9575
10342
  return stmt.id.name;
9576
10343
  }
9577
10344
  if (stmt.type === "VariableDeclaration" && Array.isArray(stmt.declarations)) {
9578
10345
  for (const d of stmt.declarations) {
9579
- if (_optionalChain([d, 'access', _543 => _543.id, 'optionalAccess', _544 => _544.type]) === "Identifier" && typeof d.id.name === "string" && d.id.name.startsWith("_uVm")) {
10346
+ if (_optionalChain([d, 'access', _624 => _624.id, 'optionalAccess', _625 => _625.type]) === "Identifier" && typeof d.id.name === "string" && d.id.name.startsWith("_uVm")) {
9580
10347
  return d.id.name;
9581
10348
  }
9582
10349
  }
@@ -9587,26 +10354,26 @@ function findInjectedVmHelperName(ast) {
9587
10354
  var PRIORITY_HANDLER_NAME_RE = /^(?:onSubmit|handleSubmit|submit[A-Za-z0-9_]*|validate[A-Za-z0-9_]*|login(?:[A-Z0-9_].*)?|signIn(?:[A-Z0-9_].*)?|register(?:[A-Z0-9_].*)?|checkout(?:[A-Z0-9_].*)?)$/i;
9588
10355
  var PRIORITY_CALL_NAME_RE = /^(?:onSubmit|handleSubmit|submit[A-Za-z0-9_]*|validate[A-Za-z0-9_]*|login(?:[A-Z0-9_].*)?|signIn(?:[A-Z0-9_].*)?|register(?:[A-Z0-9_].*)?|checkout(?:[A-Z0-9_].*)?|createServerReference|fetch)$/i;
9589
10356
  function getVmCandidateName(fn, ancestors) {
9590
- if (_optionalChain([fn, 'access', _545 => _545.id, 'optionalAccess', _546 => _546.type]) === "Identifier" && typeof fn.id.name === "string") {
10357
+ if (_optionalChain([fn, 'access', _626 => _626.id, 'optionalAccess', _627 => _627.type]) === "Identifier" && typeof fn.id.name === "string") {
9591
10358
  return fn.id.name;
9592
10359
  }
9593
10360
  const parent = ancestors.length >= 2 ? ancestors[ancestors.length - 2] : null;
9594
10361
  if (!parent) return "";
9595
- if (parent.type === "VariableDeclarator" && _optionalChain([parent, 'access', _547 => _547.id, 'optionalAccess', _548 => _548.type]) === "Identifier") {
10362
+ if (parent.type === "VariableDeclarator" && _optionalChain([parent, 'access', _628 => _628.id, 'optionalAccess', _629 => _629.type]) === "Identifier") {
9596
10363
  return parent.id.name;
9597
10364
  }
9598
10365
  if (parent.type === "Property") {
9599
- if (_optionalChain([parent, 'access', _549 => _549.key, 'optionalAccess', _550 => _550.type]) === "Identifier") return parent.key.name;
9600
- if (_optionalChain([parent, 'access', _551 => _551.key, 'optionalAccess', _552 => _552.type]) === "Literal" && typeof parent.key.value === "string") {
10366
+ if (_optionalChain([parent, 'access', _630 => _630.key, 'optionalAccess', _631 => _631.type]) === "Identifier") return parent.key.name;
10367
+ if (_optionalChain([parent, 'access', _632 => _632.key, 'optionalAccess', _633 => _633.type]) === "Literal" && typeof parent.key.value === "string") {
9601
10368
  return parent.key.value;
9602
10369
  }
9603
10370
  }
9604
- if (parent.type === "MethodDefinition" && _optionalChain([parent, 'access', _553 => _553.key, 'optionalAccess', _554 => _554.type]) === "Identifier") {
10371
+ if (parent.type === "MethodDefinition" && _optionalChain([parent, 'access', _634 => _634.key, 'optionalAccess', _635 => _635.type]) === "Identifier") {
9605
10372
  return parent.key.name;
9606
10373
  }
9607
10374
  if (parent.type === "AssignmentExpression") {
9608
- if (_optionalChain([parent, 'access', _555 => _555.left, 'optionalAccess', _556 => _556.type]) === "Identifier") return parent.left.name;
9609
- if (_optionalChain([parent, 'access', _557 => _557.left, 'optionalAccess', _558 => _558.type]) === "MemberExpression" && !parent.left.computed && _optionalChain([parent, 'access', _559 => _559.left, 'access', _560 => _560.property, 'optionalAccess', _561 => _561.type]) === "Identifier") {
10375
+ if (_optionalChain([parent, 'access', _636 => _636.left, 'optionalAccess', _637 => _637.type]) === "Identifier") return parent.left.name;
10376
+ if (_optionalChain([parent, 'access', _638 => _638.left, 'optionalAccess', _639 => _639.type]) === "MemberExpression" && !parent.left.computed && _optionalChain([parent, 'access', _640 => _640.left, 'access', _641 => _641.property, 'optionalAccess', _642 => _642.type]) === "Identifier") {
9610
10377
  return parent.left.property.name;
9611
10378
  }
9612
10379
  }
@@ -9619,11 +10386,11 @@ function bodyHasPrioritySignal(fnNode) {
9619
10386
  if (n !== fnNode && FUNCTION_NODE_TYPES2.has(n.type)) return false;
9620
10387
  if (n.type === "CallExpression") {
9621
10388
  const callee = n.callee;
9622
- if (_optionalChain([callee, 'optionalAccess', _562 => _562.type]) === "Identifier" && PRIORITY_CALL_NAME_RE.test(callee.name)) {
10389
+ if (_optionalChain([callee, 'optionalAccess', _643 => _643.type]) === "Identifier" && PRIORITY_CALL_NAME_RE.test(callee.name)) {
9623
10390
  matched = true;
9624
10391
  return false;
9625
10392
  }
9626
- if (_optionalChain([callee, 'optionalAccess', _563 => _563.type]) === "MemberExpression" && !callee.computed && _optionalChain([callee, 'access', _564 => _564.property, 'optionalAccess', _565 => _565.type]) === "Identifier" && PRIORITY_CALL_NAME_RE.test(callee.property.name)) {
10393
+ if (_optionalChain([callee, 'optionalAccess', _644 => _644.type]) === "MemberExpression" && !callee.computed && _optionalChain([callee, 'access', _645 => _645.property, 'optionalAccess', _646 => _646.type]) === "Identifier" && PRIORITY_CALL_NAME_RE.test(callee.property.name)) {
9627
10394
  matched = true;
9628
10395
  return false;
9629
10396
  }
@@ -9643,14 +10410,14 @@ function bodyHasPrioritySignal(fnNode) {
9643
10410
  }
9644
10411
  function scoreVmCandidate(fn, ancestors, criticalSet) {
9645
10412
  let score = 0;
9646
- if (_optionalChain([criticalSet, 'optionalAccess', _566 => _566.has, 'call', _567 => _567(fn)])) {
10413
+ if (_optionalChain([criticalSet, 'optionalAccess', _647 => _647.has, 'call', _648 => _648(fn)])) {
9647
10414
  score += 1e3;
9648
10415
  }
9649
10416
  const candName = getVmCandidateName(fn, ancestors);
9650
10417
  if (candName && PRIORITY_HANDLER_NAME_RE.test(candName) || bodyHasPrioritySignal(fn)) {
9651
10418
  score += 500;
9652
10419
  }
9653
- if (_optionalChain([fn, 'access', _568 => _568.body, 'optionalAccess', _569 => _569.type]) === "BlockStatement" && Array.isArray(fn.body.body)) {
10420
+ if (_optionalChain([fn, 'access', _649 => _649.body, 'optionalAccess', _650 => _650.type]) === "BlockStatement" && Array.isArray(fn.body.body)) {
9654
10421
  const stmtCount = fn.body.body.length;
9655
10422
  if (stmtCount >= 2) {
9656
10423
  score += Math.min(200, 10 + (stmtCount - 2) * 15);
@@ -9668,8 +10435,8 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
9668
10435
  vmHelperName: existingName
9669
10436
  };
9670
10437
  }
9671
- const maxFunctions = _nullishCoalesce(_optionalChain([extraOpts, 'optionalAccess', _570 => _570.maxFunctionsPerChunk]), () => ( 12));
9672
- const criticalSet = _optionalChain([extraOpts, 'optionalAccess', _571 => _571.criticalFunctionNodes]);
10438
+ const maxFunctions = _nullishCoalesce(_optionalChain([extraOpts, 'optionalAccess', _651 => _651.maxFunctionsPerChunk]), () => ( 12));
10439
+ const criticalSet = _optionalChain([extraOpts, 'optionalAccess', _652 => _652.criticalFunctionNodes]);
9673
10440
  const opMap = generateOpcodeMap(seed, OPCODE_COUNT);
9674
10441
  const vmKey = deriveVmKey(seed);
9675
10442
  const scopeBindings = /* @__PURE__ */ new Map();
@@ -9702,7 +10469,7 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
9702
10469
  walk7.ancestor(ast, {
9703
10470
  ImportDeclaration(node) {
9704
10471
  for (const spec of node.specifiers || []) {
9705
- if (_optionalChain([spec, 'access', _572 => _572.local, 'optionalAccess', _573 => _573.type]) === "Identifier") {
10472
+ if (_optionalChain([spec, 'access', _653 => _653.local, 'optionalAccess', _654 => _654.type]) === "Identifier") {
9706
10473
  addScopeBinding(ast, spec.local.name);
9707
10474
  }
9708
10475
  }
@@ -9719,7 +10486,7 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
9719
10486
  },
9720
10487
  FunctionDeclaration(node, _state, ancestors) {
9721
10488
  const parentAncestors = ancestors.slice(0, -1);
9722
- if (_optionalChain([node, 'access', _574 => _574.id, 'optionalAccess', _575 => _575.type]) === "Identifier") {
10489
+ if (_optionalChain([node, 'access', _655 => _655.id, 'optionalAccess', _656 => _656.type]) === "Identifier") {
9723
10490
  addScopeBinding(findNearestLexicalScope(parentAncestors), node.id.name);
9724
10491
  addScopeBinding(findNearestFunctionOrProgram(parentAncestors), node.id.name);
9725
10492
  }
@@ -9733,7 +10500,7 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
9733
10500
  rawCandidates.push({ fn: node, ancestors: ancestors.slice() });
9734
10501
  },
9735
10502
  FunctionExpression(node, _state, ancestors) {
9736
- if (_optionalChain([node, 'access', _576 => _576.id, 'optionalAccess', _577 => _577.type]) === "Identifier") {
10503
+ if (_optionalChain([node, 'access', _657 => _657.id, 'optionalAccess', _658 => _658.type]) === "Identifier") {
9737
10504
  addScopeBinding(node, node.id.name);
9738
10505
  }
9739
10506
  const paramNames = /* @__PURE__ */ new Set();
@@ -9756,13 +10523,13 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
9756
10523
  rawCandidates.push({ fn: node, ancestors: ancestors.slice() });
9757
10524
  },
9758
10525
  ClassDeclaration(node, _state, ancestors) {
9759
- if (_optionalChain([node, 'access', _578 => _578.id, 'optionalAccess', _579 => _579.type]) === "Identifier") {
10526
+ if (_optionalChain([node, 'access', _659 => _659.id, 'optionalAccess', _660 => _660.type]) === "Identifier") {
9760
10527
  addScopeBinding(findNearestLexicalScope(ancestors.slice(0, -1)), node.id.name);
9761
10528
  addScopeBinding(node, node.id.name);
9762
10529
  }
9763
10530
  },
9764
10531
  ClassExpression(node) {
9765
- if (_optionalChain([node, 'access', _580 => _580.id, 'optionalAccess', _581 => _581.type]) === "Identifier") {
10532
+ if (_optionalChain([node, 'access', _661 => _661.id, 'optionalAccess', _662 => _662.type]) === "Identifier") {
9766
10533
  addScopeBinding(node, node.id.name);
9767
10534
  }
9768
10535
  },
@@ -9794,7 +10561,7 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
9794
10561
  continue;
9795
10562
  }
9796
10563
  const parentNode = ancestors.length >= 2 ? ancestors[ancestors.length - 2] : null;
9797
- if (_optionalChain([parentNode, 'optionalAccess', _582 => _582.type]) === "MethodDefinition" && parentNode.kind === "constructor") {
10564
+ if (_optionalChain([parentNode, 'optionalAccess', _663 => _663.type]) === "MethodDefinition" && parentNode.kind === "constructor") {
9798
10565
  continue;
9799
10566
  }
9800
10567
  if (ancestors.some((a) => a.type === "WithStatement")) {
@@ -9816,7 +10583,7 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
9816
10583
  }
9817
10584
  }
9818
10585
  }
9819
- if (fn.type === "FunctionExpression" && _optionalChain([fn, 'access', _583 => _583.id, 'optionalAccess', _584 => _584.type]) === "Identifier") {
10586
+ if (fn.type === "FunctionExpression" && _optionalChain([fn, 'access', _664 => _664.id, 'optionalAccess', _665 => _665.type]) === "Identifier") {
9820
10587
  enclosingBindings.add(fn.id.name);
9821
10588
  }
9822
10589
  const lowered = prepareLoweredFunction(fn, enclosingBindings);
@@ -9955,7 +10722,7 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
9955
10722
  seed,
9956
10723
  windowKeySymbol,
9957
10724
  expectedDelta,
9958
- _optionalChain([extraOpts, 'optionalAccess', _585 => _585.expectedStateHash])
10725
+ _optionalChain([extraOpts, 'optionalAccess', _666 => _666.expectedStateHash])
9959
10726
  );
9960
10727
  const parsedHelper = acorn6.parse(interpreterSource, {
9961
10728
  ecmaVersion: "latest",
@@ -9964,7 +10731,7 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
9964
10731
  let insertIdx = 0;
9965
10732
  while (insertIdx < ast.body.length) {
9966
10733
  const stmt = ast.body[insertIdx];
9967
- const isDirective = stmt.type === "ExpressionStatement" && (Boolean(stmt.directive) || _optionalChain([stmt, 'access', _586 => _586.expression, 'optionalAccess', _587 => _587.type]) === "Literal" && typeof stmt.expression.value === "string" && /^(?:use\s+[a-zA-Z0-9_-]+)/.test(stmt.expression.value.trim()));
10734
+ const isDirective = stmt.type === "ExpressionStatement" && (Boolean(stmt.directive) || _optionalChain([stmt, 'access', _667 => _667.expression, 'optionalAccess', _668 => _668.type]) === "Literal" && typeof stmt.expression.value === "string" && /^(?:use\s+[a-zA-Z0-9_-]+)/.test(stmt.expression.value.trim()));
9968
10735
  if (isDirective || stmt.type === "ImportDeclaration") {
9969
10736
  insertIdx++;
9970
10737
  } else {
@@ -10051,10 +10818,10 @@ function scrubResidualPaths(ast, options = {}, hotExemptNodes, exemptSubtreeRoot
10051
10818
  Literal(node, _state, ancestors) {
10052
10819
  if (node.regex || typeof node.value !== "string") return;
10053
10820
  const val = node.value;
10054
- if (_optionalChain([exemptSet, 'optionalAccess', _588 => _588.has, 'call', _589 => _589(val)])) return;
10821
+ if (_optionalChain([exemptSet, 'optionalAccess', _669 => _669.has, 'call', _670 => _670(val)])) return;
10055
10822
  const parent = ancestors[ancestors.length - 2];
10056
10823
  if (!parent) return;
10057
- if ((parent.type === "ImportDeclaration" || parent.type === "ExportNamedDeclaration" || parent.type === "ExportAllDeclaration" || parent.type === "ImportExpression") && parent.source === node) {
10824
+ if (isStaticModuleOrAssetPosition(node, parent)) {
10058
10825
  return;
10059
10826
  }
10060
10827
  if (parent.type === "ExpressionStatement" && Boolean(parent.directive)) {
@@ -10076,12 +10843,12 @@ function scrubResidualPaths(ast, options = {}, hotExemptNodes, exemptSubtreeRoot
10076
10843
  return;
10077
10844
  }
10078
10845
  const parent = ancestors[ancestors.length - 2];
10079
- if (_optionalChain([parent, 'optionalAccess', _590 => _590.type]) === "ImportExpression" && parent.source === node) {
10846
+ if (isStaticModuleOrAssetPosition(node, parent)) {
10080
10847
  return;
10081
10848
  }
10082
10849
  for (const quasi of node.quasis) {
10083
- const val = _nullishCoalesce(_optionalChain([quasi, 'optionalAccess', _591 => _591.value, 'optionalAccess', _592 => _592.cooked]), () => ( _optionalChain([quasi, 'optionalAccess', _593 => _593.value, 'optionalAccess', _594 => _594.raw])));
10084
- if (typeof val !== "string" || _optionalChain([exemptSet, 'optionalAccess', _595 => _595.has, 'call', _596 => _596(val)])) continue;
10850
+ const val = _nullishCoalesce(_optionalChain([quasi, 'optionalAccess', _671 => _671.value, 'optionalAccess', _672 => _672.cooked]), () => ( _optionalChain([quasi, 'optionalAccess', _673 => _673.value, 'optionalAccess', _674 => _674.raw])));
10851
+ if (typeof val !== "string" || _optionalChain([exemptSet, 'optionalAccess', _675 => _675.has, 'call', _676 => _676(val)])) continue;
10085
10852
  const scrubbed = scrubStringValue(val, options.rootDir);
10086
10853
  if (scrubbed !== val) {
10087
10854
  quasi.value.cooked = scrubbed;
@@ -10121,24 +10888,24 @@ function isAstAlreadyProtected(ast) {
10121
10888
  return ast.body.some((stmt) => {
10122
10889
  if (stmt.type === "VariableDeclaration" && Array.isArray(stmt.declarations)) {
10123
10890
  for (const d of stmt.declarations) {
10124
- const name = _optionalChain([d, 'access', _597 => _597.id, 'optionalAccess', _598 => _598.type]) === "Identifier" ? d.id.name : void 0;
10891
+ const name = _optionalChain([d, 'access', _677 => _677.id, 'optionalAccess', _678 => _678.type]) === "Identifier" ? d.id.name : void 0;
10125
10892
  if (typeof name === "string") {
10126
- if (name.startsWith("_uC") || name.startsWith("_uD") || name.startsWith("_uS") || name.startsWith("_uSb") || name.startsWith("_uDec") || name.startsWith("_uAl") || name.startsWith("_uAm") || name.startsWith("_uZt") || name.startsWith("_uVm") || name.startsWith("_wKdf") || name.startsWith("_uP") || name.startsWith("_uCache") || name.startsWith("_uDc") || _optionalChain([d, 'access', _599 => _599.init, 'optionalAccess', _600 => _600.type]) === "CallExpression" && _optionalChain([d, 'access', _601 => _601.init, 'access', _602 => _602.callee, 'optionalAccess', _603 => _603.type]) === "FunctionExpression" && _optionalChain([d, 'access', _604 => _604.init, 'access', _605 => _605.callee, 'optionalAccess', _606 => _606.id, 'optionalAccess', _607 => _607.name]) === "f" && _optionalChain([d, 'access', _608 => _608.init, 'access', _609 => _609.arguments, 'optionalAccess', _610 => _610[0], 'optionalAccess', _611 => _611.type]) === "ArrayExpression" || _optionalChain([d, 'access', _612 => _612.init, 'optionalAccess', _613 => _613.type]) === "CallExpression" && _optionalChain([d, 'access', _614 => _614.init, 'access', _615 => _615.callee, 'optionalAccess', _616 => _616.type]) === "MemberExpression" && _optionalChain([d, 'access', _617 => _617.init, 'access', _618 => _618.callee, 'access', _619 => _619.object, 'optionalAccess', _620 => _620.type]) === "Identifier" && d.init.callee.object.name === "Symbol" && _optionalChain([d, 'access', _621 => _621.init, 'access', _622 => _622.callee, 'access', _623 => _623.property, 'optionalAccess', _624 => _624.type]) === "Identifier" && d.init.callee.property.name === "for" && typeof _optionalChain([d, 'access', _625 => _625.init, 'access', _626 => _626.arguments, 'optionalAccess', _627 => _627[0], 'optionalAccess', _628 => _628.value]) === "string" && d.init.arguments[0].value.startsWith("__upk_v4_")) {
10893
+ if (name.startsWith("_uC") || name.startsWith("_uD") || name.startsWith("_uS") || name.startsWith("_uSb") || name.startsWith("_uDec") || name.startsWith("_uAl") || name.startsWith("_uAm") || name.startsWith("_uZt") || name.startsWith("_uVm") || name.startsWith("_wKdf") || name.startsWith("_uP") || name.startsWith("_uCache") || name.startsWith("_uDc") || _optionalChain([d, 'access', _679 => _679.init, 'optionalAccess', _680 => _680.type]) === "CallExpression" && _optionalChain([d, 'access', _681 => _681.init, 'access', _682 => _682.callee, 'optionalAccess', _683 => _683.type]) === "FunctionExpression" && _optionalChain([d, 'access', _684 => _684.init, 'access', _685 => _685.callee, 'optionalAccess', _686 => _686.id, 'optionalAccess', _687 => _687.name]) === "f" && _optionalChain([d, 'access', _688 => _688.init, 'access', _689 => _689.arguments, 'optionalAccess', _690 => _690[0], 'optionalAccess', _691 => _691.type]) === "ArrayExpression" || _optionalChain([d, 'access', _692 => _692.init, 'optionalAccess', _693 => _693.type]) === "CallExpression" && _optionalChain([d, 'access', _694 => _694.init, 'access', _695 => _695.callee, 'optionalAccess', _696 => _696.type]) === "MemberExpression" && _optionalChain([d, 'access', _697 => _697.init, 'access', _698 => _698.callee, 'access', _699 => _699.object, 'optionalAccess', _700 => _700.type]) === "Identifier" && d.init.callee.object.name === "Symbol" && _optionalChain([d, 'access', _701 => _701.init, 'access', _702 => _702.callee, 'access', _703 => _703.property, 'optionalAccess', _704 => _704.type]) === "Identifier" && d.init.callee.property.name === "for" && typeof _optionalChain([d, 'access', _705 => _705.init, 'access', _706 => _706.arguments, 'optionalAccess', _707 => _707[0], 'optionalAccess', _708 => _708.value]) === "string" && d.init.arguments[0].value.startsWith("__upk_v4_")) {
10127
10894
  return true;
10128
10895
  }
10129
10896
  }
10130
10897
  }
10131
10898
  }
10132
- if (stmt.type === "FunctionDeclaration" && _optionalChain([stmt, 'access', _629 => _629.id, 'optionalAccess', _630 => _630.type]) === "Identifier") {
10899
+ if (stmt.type === "FunctionDeclaration" && _optionalChain([stmt, 'access', _709 => _709.id, 'optionalAccess', _710 => _710.type]) === "Identifier") {
10133
10900
  const fnName = stmt.id.name;
10134
- if (typeof fnName === "string" && (fnName.startsWith("_uD") || fnName.startsWith("_uVm") || fnName.startsWith("_wKdf") || fnName === "_hX")) {
10901
+ if (typeof fnName === "string" && (fnName.startsWith("_uD") || fnName.startsWith("_uVm") || fnName.startsWith("_wKdf") || fnName.startsWith("_uLr") || fnName.startsWith("_uMx") || fnName === "_hX")) {
10135
10902
  return true;
10136
10903
  }
10137
10904
  }
10138
- if (stmt.type === "ExpressionStatement" && _optionalChain([stmt, 'access', _631 => _631.expression, 'optionalAccess', _632 => _632.type]) === "CallExpression") {
10905
+ if (stmt.type === "ExpressionStatement" && _optionalChain([stmt, 'access', _711 => _711.expression, 'optionalAccess', _712 => _712.type]) === "CallExpression") {
10139
10906
  const callee = stmt.expression.callee;
10140
- if (_optionalChain([callee, 'optionalAccess', _633 => _633.type]) === "FunctionExpression") {
10141
- const name = _optionalChain([callee, 'access', _634 => _634.id, 'optionalAccess', _635 => _635.name]);
10907
+ if (_optionalChain([callee, 'optionalAccess', _713 => _713.type]) === "FunctionExpression") {
10908
+ const name = _optionalChain([callee, 'access', _714 => _714.id, 'optionalAccess', _715 => _715.name]);
10142
10909
  if (typeof name === "string" && name.startsWith("_u$") || containsUnpeekShieldMarker(callee.body)) {
10143
10910
  return true;
10144
10911
  }
@@ -10150,7 +10917,7 @@ function isAstAlreadyProtected(ast) {
10150
10917
  function transformJavaScript(code, options = {}) {
10151
10918
  const internalOptions = options;
10152
10919
  const seed = _nullishCoalesce(internalOptions.seed, () => ( 2654435769));
10153
- const minStringLength = _nullishCoalesce(_nullishCoalesce(options.minStringLength, () => ( _optionalChain([options, 'access', _636 => _636.config, 'optionalAccess', _637 => _637.vault, 'optionalAccess', _638 => _638.minStringLength]))), () => ( 4));
10920
+ const minStringLength = _nullishCoalesce(_nullishCoalesce(options.minStringLength, () => ( _optionalChain([options, 'access', _716 => _716.config, 'optionalAccess', _717 => _717.vault, 'optionalAccess', _718 => _718.minStringLength]))), () => ( 4));
10154
10921
  const isAggressive = _nullishCoalesce(options.aggressive, () => ( false));
10155
10922
  if (!code || !code.trim()) {
10156
10923
  const emptyResult = {
@@ -10215,7 +10982,7 @@ function transformJavaScript(code, options = {}) {
10215
10982
  const boundary = classifyChunkBoundary(ast);
10216
10983
  attachMagicComments(boundary.importExpressions, comments);
10217
10984
  const effectiveConfig = options.critical ? { ..._nullishCoalesce(options.config, () => ( {})), critical: options.critical } : options.config;
10218
- const effectiveProfile = _nullishCoalesce(options.profile, () => ( _optionalChain([effectiveConfig, 'optionalAccess', _639 => _639.profile])));
10985
+ const effectiveProfile = _nullishCoalesce(options.profile, () => ( _optionalChain([effectiveConfig, 'optionalAccess', _719 => _719.profile])));
10219
10986
  const originalSourceMap = internalOptions.originalSourceMap;
10220
10987
  const hotRes = analyzeAstHotPaths(ast, effectiveConfig, originalSourceMap);
10221
10988
  const {
@@ -10226,7 +10993,7 @@ function transformJavaScript(code, options = {}) {
10226
10993
  serializedFunctionNodes
10227
10994
  } = hotRes;
10228
10995
  const criticalFunctionNodes = hotRes.criticalFunctionNodes;
10229
- if (options.scrubPaths || _optionalChain([effectiveConfig, 'optionalAccess', _640 => _640.scrubPaths])) {
10996
+ if (options.scrubPaths || _optionalChain([effectiveConfig, 'optionalAccess', _720 => _720.scrubPaths])) {
10230
10997
  scrubResidualPaths(
10231
10998
  ast,
10232
10999
  {
@@ -10238,8 +11005,8 @@ function transformJavaScript(code, options = {}) {
10238
11005
  );
10239
11006
  }
10240
11007
  const shieldCoupled = _nullishCoalesce(internalOptions.shieldCoupled, () => ( Boolean(internalOptions.injectRuntimeShield)));
10241
- const deterrentMode = _nullishCoalesce(_nullishCoalesce(internalOptions.deterrentMode, () => ( _optionalChain([effectiveConfig, 'optionalAccess', _641 => _641.shield, 'optionalAccess', _642 => _642.deterrentMode]))), () => ( "passive"));
10242
- const detectHeadless = _nullishCoalesce(_nullishCoalesce(internalOptions.detectHeadless, () => ( _optionalChain([effectiveConfig, 'optionalAccess', _643 => _643.shield, 'optionalAccess', _644 => _644.detectHeadless]))), () => ( false));
11008
+ const deterrentMode = _nullishCoalesce(_nullishCoalesce(internalOptions.deterrentMode, () => ( _optionalChain([effectiveConfig, 'optionalAccess', _721 => _721.shield, 'optionalAccess', _722 => _722.deterrentMode]))), () => ( "passive"));
11009
+ const detectHeadless = _nullishCoalesce(_nullishCoalesce(internalOptions.detectHeadless, () => ( _optionalChain([effectiveConfig, 'optionalAccess', _723 => _723.shield, 'optionalAccess', _724 => _724.detectHeadless]))), () => ( false));
10243
11010
  const sym = shieldCoupled ? _nullishCoalesce(internalOptions.windowKeySymbol, () => ( deriveWindowKeySymbol(seed))) : void 0;
10244
11011
  let shieldDelta = shieldCoupled ? internalOptions.expectedDelta : void 0;
10245
11012
  let expectedStateHash = shieldCoupled ? internalOptions.expectedStateHash : void 0;
@@ -10259,9 +11026,9 @@ function transformJavaScript(code, options = {}) {
10259
11026
  }
10260
11027
  let virtualizedFunctionsCount = 0;
10261
11028
  if (isAggressive) {
10262
- const extraVmOpts = criticalFunctionNodes || _optionalChain([effectiveConfig, 'optionalAccess', _645 => _645.critical, 'optionalAccess', _646 => _646.maxFunctionsPerChunk]) !== void 0 || expectedStateHash !== void 0 ? {
11029
+ const extraVmOpts = criticalFunctionNodes || _optionalChain([effectiveConfig, 'optionalAccess', _725 => _725.critical, 'optionalAccess', _726 => _726.maxFunctionsPerChunk]) !== void 0 || expectedStateHash !== void 0 ? {
10263
11030
  ...criticalFunctionNodes ? { criticalFunctionNodes } : {},
10264
- ..._optionalChain([effectiveConfig, 'optionalAccess', _647 => _647.critical, 'optionalAccess', _648 => _648.maxFunctionsPerChunk]) !== void 0 ? { maxFunctionsPerChunk: effectiveConfig.critical.maxFunctionsPerChunk } : {},
11031
+ ..._optionalChain([effectiveConfig, 'optionalAccess', _727 => _727.critical, 'optionalAccess', _728 => _728.maxFunctionsPerChunk]) !== void 0 ? { maxFunctionsPerChunk: effectiveConfig.critical.maxFunctionsPerChunk } : {},
10265
11032
  ...expectedStateHash !== void 0 ? { expectedStateHash } : {}
10266
11033
  } : void 0;
10267
11034
  const vmRes = extraVmOpts ? applyMicroVm(
@@ -10282,8 +11049,9 @@ function transformJavaScript(code, options = {}) {
10282
11049
  );
10283
11050
  virtualizedFunctionsCount = vmRes.virtualizedCount;
10284
11051
  }
10285
- if (effectiveProfile !== "minimal" && _optionalChain([effectiveConfig, 'optionalAccess', _649 => _649.coldFlow]) !== false) {
10286
- applyColdFlowGuard(
11052
+ let coldFlowGuardedCount = 0;
11053
+ if (effectiveProfile !== "minimal" && _optionalChain([effectiveConfig, 'optionalAccess', _729 => _729.coldFlow]) !== false) {
11054
+ coldFlowGuardedCount = applyColdFlowGuard(
10287
11055
  ast,
10288
11056
  coldFunctionNodes,
10289
11057
  seed,
@@ -10294,6 +11062,7 @@ function transformJavaScript(code, options = {}) {
10294
11062
  { enableBitwiseMba: isAggressive || effectiveProfile === "strict" }
10295
11063
  );
10296
11064
  }
11065
+ const latchCoupling = coldFlowGuardedCount > 0 ? deriveColdLatchCoupling(seed) : void 0;
10297
11066
  const mangledSymbolsCount = applyPolymorphicMangler(
10298
11067
  ast,
10299
11068
  seed,
@@ -10315,7 +11084,8 @@ function transformJavaScript(code, options = {}) {
10315
11084
  deterrentMode,
10316
11085
  shieldCoupled,
10317
11086
  detectHeadless,
10318
- boundary.exemptSubtreeRoots
11087
+ boundary.exemptSubtreeRoots,
11088
+ latchCoupling
10319
11089
  );
10320
11090
  encryptedStringsCount = saltedRes.encryptedStringsCount;
10321
11091
  integrityToken = saltedRes.integrityToken;
@@ -10332,7 +11102,8 @@ function transformJavaScript(code, options = {}) {
10332
11102
  effectiveConfig,
10333
11103
  shieldCoupled,
10334
11104
  detectHeadless,
10335
- boundary.exemptSubtreeRoots
11105
+ boundary.exemptSubtreeRoots,
11106
+ latchCoupling
10336
11107
  );
10337
11108
  encryptedStringsCount = vaultRes.encryptedStringsCount;
10338
11109
  integrityToken = vaultRes.integrityToken;