unpeek 4.1.0 → 4.2.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 (38) hide show
  1. package/README.md +7 -7
  2. package/README.tr.md +7 -7
  3. package/dist/adapters/esbuild.cjs +4 -4
  4. package/dist/adapters/esbuild.js +2 -2
  5. package/dist/adapters/next/adapter.cjs +4 -4
  6. package/dist/adapters/next/adapter.js +3 -3
  7. package/dist/adapters/next/index.cjs +4 -4
  8. package/dist/adapters/next/index.js +3 -3
  9. package/dist/adapters/rollup.cjs +4 -4
  10. package/dist/adapters/rollup.js +2 -2
  11. package/dist/adapters/rspack.cjs +4 -4
  12. package/dist/adapters/rspack.js +2 -2
  13. package/dist/adapters/vite.cjs +4 -4
  14. package/dist/adapters/vite.js +2 -2
  15. package/dist/adapters/webpack.cjs +4 -4
  16. package/dist/adapters/webpack.js +2 -2
  17. package/dist/browser.cjs +2 -2
  18. package/dist/browser.d.cts +3 -2
  19. package/dist/browser.d.ts +3 -2
  20. package/dist/browser.js +1 -1
  21. package/dist/{chunk-STTUFUDC.js → chunk-APQOBFRO.js} +1 -1
  22. package/dist/{chunk-6KLUNEKE.js → chunk-BL2UXZGD.js} +1187 -162
  23. package/dist/{chunk-TOUYQ4N5.js → chunk-GCWXTWTN.js} +1 -1
  24. package/dist/{chunk-HV47WJIR.js → chunk-K77WRITN.js} +2 -2
  25. package/dist/{chunk-WYW5UOBE.cjs → chunk-KIAYVIC5.cjs} +11 -11
  26. package/dist/{chunk-VLL4THTG.cjs → chunk-MSECP2P4.cjs} +1326 -301
  27. package/dist/{chunk-FLZ4FSP5.cjs → chunk-SJK45WAU.cjs} +6 -6
  28. package/dist/{chunk-Q4DFRMAV.cjs → chunk-UUJLTW7O.cjs} +9 -9
  29. package/dist/cli/index.js +1332 -171
  30. package/dist/index.cjs +159 -19
  31. package/dist/index.d.cts +2 -2
  32. package/dist/index.d.ts +2 -2
  33. package/dist/index.js +150 -10
  34. package/dist/plugins/unplugin.cjs +3 -3
  35. package/dist/plugins/unplugin.js +2 -2
  36. package/dist/{types-BZqvBhBI.d.ts → types-BDpFfokR.d.ts} +2 -1
  37. package/dist/{types-E4ugA4Oz.d.cts → types-WIoud53X.d.cts} +2 -1
  38. package/package.json +1 -1
@@ -2956,7 +2956,7 @@ function createDeterrentSnippet(config) {
2956
2956
  const consoleSilence = deterrentMode === "gradual" ? "for(var k in console)console[k]=()=>0;" : "";
2957
2957
  const symLit = JSON.stringify(sym);
2958
2958
  const headlessDecl = detectHeadless ? ",n=w.navigator||0" : "";
2959
- const headlessCond = detectHeadless ? "||n.webdriver||/HeadlessChrome/.test(n.userAgent)" : "";
2959
+ const headlessCond = detectHeadless ? "||n.webdriver||/HeadlessChrome/.test(n.userAgent)||['__playwright','__puppeteer_evaluation_script__','__nightmare','frida','_frida_'].some(k=>w[k]||G[k])" : "";
2960
2960
  const k1Mul = (seed | 1) >>> 0;
2961
2961
  return `(function ${fnName}(w){var G=globalThis||w;if(w){var O=Object,P=O.getOwnPropertyDescriptor,RF=G.Reflect,R=RF&&RF.apply,FP=Function.prototype,SP=String.prototype,ER=Error,EP=ER.prototype,Q='__unpeek_',y=${symLit},z=y+'_s',U='__unpeek_tampered',K=Q+'seed',ST='stack',PS='prepareStackTrace',A='\\n at ',T=(o,k)=>{try{for(var r;o;o=O.getPrototypeOf(o))if((r=P(o,k))&&(r.set||!r.writable))return 1;}catch(e){return 1;}},D=k=>T(w,k)|T(G,k),B=(k,v,c,W)=>{W=o=>{try{if(!c||!T(o,k))o[k]=v;}catch(e){}};W(G);W(w);},s=FP.toString${headlessDecl},src='',t=+((G[z]||w[z])?.[0]==2),sd=P(EP,ST),ep=ER[PS],M=/^function (?:get )?(\\w*)\\(\\)\\s*\\x7b\\s*\\[native code\\]\\s*\\}$/;try{var ps,rf=P(new ER(),ST),Z=()=>{if(ER[PS]!==void 0){if(typeof process>'u')t=1;ER[PS]=void 0;}},F=(f,n,l)=>typeof f!='function'||'prototype'in f||(l>=0&&(f.name!=n||f.length!=l))||M.exec(R(R,null,[s,f,[]]))?.[1]!=n,E=(f,a,b)=>{try{R(f,a,b);t=1;}catch(e){Z();var ed=P(e,ST),st=sd&&sd.get?R(sd.get,e,[]):ed&&ed.get?R(ed.get,e,[]):e[ST];if(ed&&(!rf||F(ed.get,'',0)))t=1;t|=e?.name!='TypeError'||!st||st.indexOf(A)<0||/(?:Object|Proxy)\\.apply\\b|\\n at (?!.* \\(<anonymous>\\)$)/m.test(st.split(A+'E (')[0]);}};Z();try{E(P,null,[]);E(s,{toString(){}},[]);E(R,s,[null,s,[]]);}finally{if(ep!==void 0)ER[PS]=ep;}src=R(s,${fnName},[]);t|=(sd&&F(sd.get,ST,-1))|F(R,'apply',3)|F(s,'toString',0)|s.call(T)!==(ps=R(s,T,[]))|FP.call.call(s,T)!==ps|/\\n/.test(src)${headlessCond};}catch(e){t=1;}t|=D(y)|D(z)|D(U)|T(SP,'_u')|T(FP,'toString')|T(FP,'call')|T(RF,'apply')|T(ER,PS)|(sd?T(O.getPrototypeOf(EP),ST):T(EP,ST));for(var h=2166136261,i=0;i<src.length;)h=Math.imul(h^src.charCodeAt(i++),16777619);var d=h&65535,pd=t?d^((h>>>16^23131)||1):d;B(z,[t+1,h^${seed}^t,h^${k1Mul}^t,1,d^h>>>16],t);B(y,pd,t);if(t){B(y+'_t',!0);B(Q+'delta',pd);try{SP._u=14;}catch(e){}B(K,((w[K]||${seed})^1)>>>0);B(U,!0);try{${consoleSilence}w.dispatchEvent?.(new CustomEvent('unpeek:tamper'));}catch(e){}}}})(typeof window!=='undefined'?window:typeof self<'u'?self:typeof globalThis<'u'?globalThis:0);`;
2962
2962
  }
@@ -3061,7 +3061,88 @@ function deriveWasmHostParams(seed) {
3061
3061
  const pcMask = computeFnv1aHash("wasm-pcmask", seed) | 1 | 0;
3062
3062
  return { gArr, sOff, rA0, rA1, rA2, rA3, gMask, pcMask };
3063
3063
  }
3064
- function generateWasmKdfBinary(seed) {
3064
+ var ABI_START_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
3065
+ var ABI_CONT_CHARS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
3066
+ var FORBIDDEN_ABI_NAMES = /* @__PURE__ */ new Set([
3067
+ "env",
3068
+ "g",
3069
+ "m",
3070
+ "kdf",
3071
+ "bulkmix",
3072
+ "mem",
3073
+ "as",
3074
+ "do",
3075
+ "if",
3076
+ "in",
3077
+ "of",
3078
+ "for",
3079
+ "int",
3080
+ "let",
3081
+ "new",
3082
+ "try",
3083
+ "var",
3084
+ "nan",
3085
+ "map",
3086
+ "set",
3087
+ "url",
3088
+ "top",
3089
+ "get",
3090
+ "set"
3091
+ ]);
3092
+ function avalancheMix32(h) {
3093
+ let x = h >>> 0;
3094
+ x = Math.imul(x ^ x >>> 16, 2246822507) >>> 0;
3095
+ x = Math.imul(x ^ x >>> 13, 3266489909) >>> 0;
3096
+ return (x ^ x >>> 16) >>> 0;
3097
+ }
3098
+ function encodeWasmName(name) {
3099
+ const utf8 = new TextEncoder().encode(name);
3100
+ return [...encodeUnsignedLeb128(utf8.length), ...utf8];
3101
+ }
3102
+ function deriveWasmAbiNames(seed) {
3103
+ const s = seed >>> 0;
3104
+ const used = new Set(FORBIDDEN_ABI_NAMES);
3105
+ const pickName = (role) => {
3106
+ for (let attempt = 0; attempt < 64; attempt++) {
3107
+ const h = avalancheMix32(computeFnv1aHash(`wasm-abi:${role}:${attempt}`, s));
3108
+ const len = h >>> 18 & 1 ? 3 : 2;
3109
+ const c0 = ABI_START_CHARS[h % ABI_START_CHARS.length];
3110
+ const c1 = ABI_CONT_CHARS[(h >>> 6) % ABI_CONT_CHARS.length];
3111
+ const c2 = len === 3 ? ABI_CONT_CHARS[(h >>> 12) % ABI_CONT_CHARS.length] : "";
3112
+ const candidate = `${c0}${c1}${c2}`;
3113
+ const lower = candidate.toLowerCase();
3114
+ if (!candidate.startsWith("__") && !used.has(lower)) {
3115
+ used.add(lower);
3116
+ return candidate;
3117
+ }
3118
+ }
3119
+ const fallback = `w${s.toString(36).slice(0, 2).padStart(2, "0")}`;
3120
+ used.add(fallback.toLowerCase());
3121
+ return fallback;
3122
+ };
3123
+ const envMod = pickName("envMod");
3124
+ const gImport = pickName("gImport");
3125
+ const mImport = pickName("mImport");
3126
+ const kdfExport = pickName("kdfExport");
3127
+ const bulkMixExport = pickName("bulkMixExport");
3128
+ const memExport = pickName("memExport");
3129
+ const exportOrder = [0, 1, 2];
3130
+ const orderHash = avalancheMix32(computeFnv1aHash("wasm-abi:order", s));
3131
+ const j2 = orderHash % 3;
3132
+ [exportOrder[2], exportOrder[j2]] = [exportOrder[j2], exportOrder[2]];
3133
+ const j1 = (orderHash >>> 8) % 2;
3134
+ [exportOrder[1], exportOrder[j1]] = [exportOrder[j1], exportOrder[1]];
3135
+ return {
3136
+ envMod,
3137
+ gImport,
3138
+ mImport,
3139
+ kdfExport,
3140
+ bulkMixExport,
3141
+ memExport,
3142
+ exportOrder
3143
+ };
3144
+ }
3145
+ function generateWasmKdfBinary(seed, options) {
3065
3146
  const { sVal, c1, c2, k0, r1, r2 } = deriveKdfParams(seed);
3066
3147
  const { gMask, pcMask } = deriveWasmHostParams(seed);
3067
3148
  const memBase = (seed >>> 0 & 127) * 4;
@@ -3587,27 +3668,23 @@ function generateWasmKdfBinary(seed) {
3587
3668
  ...encodeUnsignedLeb128(typePayload.length),
3588
3669
  ...typePayload
3589
3670
  ];
3671
+ const abi = _optionalChain([options, 'optionalAccess', _239 => _239.polymorphicAbi]) ? deriveWasmAbiNames(seed) : null;
3672
+ const envModName = abi ? abi.envMod : "env";
3673
+ const gImportName = abi ? abi.gImport : "g";
3674
+ const mImportName = abi ? abi.mImport : "m";
3590
3675
  const importPayload = [
3591
3676
  2,
3592
3677
  // 2 imports
3593
- 3,
3594
- 101,
3595
- 110,
3596
- 118,
3597
- 1,
3598
- 103,
3678
+ ...encodeWasmName(envModName),
3679
+ ...encodeWasmName(gImportName),
3599
3680
  0,
3600
3681
  0,
3601
- // env.g: func type 0
3602
- 3,
3603
- 101,
3604
- 110,
3605
- 118,
3606
- 1,
3607
- 109,
3682
+ // g: func type 0
3683
+ ...encodeWasmName(envModName),
3684
+ ...encodeWasmName(mImportName),
3608
3685
  0,
3609
3686
  1
3610
- // env.m: func type 1
3687
+ // m: func type 1
3611
3688
  ];
3612
3689
  const importSection = [
3613
3690
  2,
@@ -3621,35 +3698,21 @@ function generateWasmKdfBinary(seed) {
3621
3698
  ...funcPayload
3622
3699
  ];
3623
3700
  const memSection = [5, 3, 1, 0, 1];
3624
- const exportPayload = [
3625
- 3,
3626
- // 3 exports
3627
- 3,
3628
- 107,
3629
- 100,
3630
- 102,
3631
- 0,
3632
- 2,
3633
- // "kdf" -> func 2
3634
- 7,
3635
- 98,
3636
- 117,
3637
- 108,
3638
- 107,
3639
- 77,
3640
- 105,
3641
- 120,
3642
- 0,
3643
- 3,
3644
- // "bulkMix" -> func 3
3645
- 3,
3646
- 109,
3647
- 101,
3648
- 109,
3649
- 2,
3650
- 0
3651
- // "mem" -> memory 0
3701
+ const exportSpecs = abi ? [
3702
+ [abi.kdfExport, 0, 2],
3703
+ [abi.bulkMixExport, 0, 3],
3704
+ [abi.memExport, 2, 0]
3705
+ ] : [
3706
+ ["kdf", 0, 2],
3707
+ ["bulkMix", 0, 3],
3708
+ ["mem", 2, 0]
3652
3709
  ];
3710
+ const exportOrder = abi ? abi.exportOrder : [0, 1, 2];
3711
+ const exportPayload = [3];
3712
+ for (const idx of exportOrder) {
3713
+ const [name, kind, targetIdx] = exportSpecs[idx];
3714
+ exportPayload.push(...encodeWasmName(name), kind, targetIdx);
3715
+ }
3653
3716
  const exportSection = [
3654
3717
  7,
3655
3718
  ...encodeUnsignedLeb128(exportPayload.length),
@@ -3726,8 +3789,8 @@ function fallbackKdf(fnId, callSiteSalt, shieldHash, seed) {
3726
3789
  function isWasmVaultAlreadyInjected(ast) {
3727
3790
  if (!ast || !Array.isArray(ast.body)) return false;
3728
3791
  return ast.body.some((stmt) => {
3729
- if (stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _239 => _239.declarations, 'optionalAccess', _240 => _240.some, 'call', _241 => _241(
3730
- (d) => _optionalChain([d, 'access', _242 => _242.id, 'optionalAccess', _243 => _243.type]) === "Identifier" && typeof d.id.name === "string" && d.id.name.startsWith("_wKdf")
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")
3731
3794
  )])) {
3732
3795
  return true;
3733
3796
  }
@@ -3740,19 +3803,20 @@ function injectWasmVault(ast, seed = 2654435769) {
3740
3803
  const wasmVarName = `_wb${suffix}`;
3741
3804
  if (isWasmVaultAlreadyInjected(ast)) {
3742
3805
  const existing = ast.body.find(
3743
- (stmt) => stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _244 => _244.declarations, 'optionalAccess', _245 => _245.some, 'call', _246 => _246(
3744
- (d) => _optionalChain([d, 'access', _247 => _247.id, 'optionalAccess', _248 => _248.type]) === "Identifier" && typeof d.id.name === "string" && d.id.name.startsWith("_wKdf")
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")
3745
3808
  )])
3746
3809
  );
3747
- const id = _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _249 => _249.declarations, 'access', _250 => _250[0], 'optionalAccess', _251 => _251.id, 'optionalAccess', _252 => _252.name]), () => ( kdfFnName));
3810
+ const id = _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _250 => _250.declarations, 'access', _251 => _251[0], 'optionalAccess', _252 => _252.id, 'optionalAccess', _253 => _253.name]), () => ( kdfFnName));
3748
3811
  return {
3749
3812
  kdfFnName: id,
3750
- wasmBytes: generateWasmKdfBinary(seed),
3813
+ wasmBytes: generateWasmKdfBinary(seed, { polymorphicAbi: true }),
3751
3814
  wasmVarName,
3752
3815
  kdfParityVerified: true
3753
3816
  };
3754
3817
  }
3755
- const wasmBytes = generateWasmKdfBinary(seed);
3818
+ const abi = deriveWasmAbiNames(seed);
3819
+ const wasmBytes = generateWasmKdfBinary(seed, { polymorphicAbi: true });
3756
3820
  const byteArrayLiteral = Array.from(wasmBytes).join(",");
3757
3821
  const { sVal, c1, c2, k0, r1, r2 } = deriveKdfParams(seed);
3758
3822
  const { gArr, sOff, rA0, rA1, rA2, rA3, gMask, pcMask } = deriveWasmHostParams(seed);
@@ -3789,8 +3853,8 @@ function injectWasmVault(ast, seed = 2654435769) {
3789
3853
  try {
3790
3854
  var ${wasmVarName} = new Uint8Array([${byteArrayLiteral}]);
3791
3855
  var _wm${suffix} = new WebAssembly.Module(${wasmVarName});
3792
- var _wi${suffix} = new WebAssembly.Instance(_wm${suffix}, { env: { g: _eG, m: _eM } });
3793
- ${kdfFnName} = _wi${suffix}.exports.kdf;
3856
+ var _wi${suffix} = new WebAssembly.Instance(_wm${suffix}, { ${abi.envMod}: { ${abi.gImport}: _eG, ${abi.mImport}: _eM } });
3857
+ ${kdfFnName} = _wi${suffix}.exports[${JSON.stringify(abi.kdfExport)}];
3794
3858
  } catch (e) {
3795
3859
  var _kx = [${rivEncodedTargets.join(",")}];
3796
3860
  var _k = [];
@@ -3827,7 +3891,7 @@ function injectWasmVault(ast, seed = 2654435769) {
3827
3891
  let insertIdx = 0;
3828
3892
  while (insertIdx < ast.body.length) {
3829
3893
  const stmt = ast.body[insertIdx];
3830
- const isDirective = stmt.type === "ExpressionStatement" && (Boolean(stmt.directive) || _optionalChain([stmt, 'access', _253 => _253.expression, 'optionalAccess', _254 => _254.type]) === "Literal" && typeof stmt.expression.value === "string" && /^(?:use\s+[a-zA-Z0-9_-]+)/.test(stmt.expression.value.trim()));
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()));
3831
3895
  if (isDirective || stmt.type === "ImportDeclaration") {
3832
3896
  insertIdx++;
3833
3897
  } else {
@@ -3858,7 +3922,7 @@ function isWebpackModuleMap(node) {
3858
3922
  return false;
3859
3923
  }
3860
3924
  return node.properties.some(
3861
- (p) => _optionalChain([p, 'optionalAccess', _255 => _255.type]) === "Property" && (_optionalChain([p, 'access', _256 => _256.value, 'optionalAccess', _257 => _257.type]) === "FunctionExpression" || _optionalChain([p, 'access', _258 => _258.value, 'optionalAccess', _259 => _259.type]) === "ArrowFunctionExpression")
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")
3862
3926
  );
3863
3927
  }
3864
3928
  function exemptWebpackPushArg(arg, exemptSubtreeRoots) {
@@ -3878,9 +3942,9 @@ function exemptWebpackPushArg(arg, exemptSubtreeRoots) {
3878
3942
  exemptSubtreeRoots.add(arg);
3879
3943
  }
3880
3944
  function exemptTurbopackPropertyKeys(objNode, exemptSubtreeRoots) {
3881
- if (!Array.isArray(_optionalChain([objNode, 'optionalAccess', _260 => _260.properties]))) return;
3945
+ if (!Array.isArray(_optionalChain([objNode, 'optionalAccess', _261 => _261.properties]))) return;
3882
3946
  for (const prop of objNode.properties) {
3883
- if (_optionalChain([prop, 'optionalAccess', _261 => _261.type]) === "Property" && prop.key && typeof prop.key === "object") {
3947
+ if (_optionalChain([prop, 'optionalAccess', _262 => _262.type]) === "Property" && prop.key && typeof prop.key === "object") {
3884
3948
  exemptSubtreeRoots.add(prop.key);
3885
3949
  }
3886
3950
  }
@@ -3919,11 +3983,11 @@ function isHostMember(node, matcher) {
3919
3983
  if (node.type === "Identifier" && matchesPropName(node.name, matcher)) {
3920
3984
  return true;
3921
3985
  }
3922
- if (node.type === "MemberExpression" && (_optionalChain([node, 'access', _262 => _262.object, 'optionalAccess', _263 => _263.type]) === "Identifier" && GLOBAL_HOSTS.has(node.object.name) || _optionalChain([node, 'access', _264 => _264.object, 'optionalAccess', _265 => _265.type]) === "ThisExpression")) {
3923
- if (!node.computed && _optionalChain([node, 'access', _266 => _266.property, 'optionalAccess', _267 => _267.type]) === "Identifier") {
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") {
3924
3988
  return matchesPropName(node.property.name, matcher);
3925
3989
  }
3926
- if (node.computed && _optionalChain([node, 'access', _268 => _268.property, 'optionalAccess', _269 => _269.type]) === "Literal" && typeof node.property.value === "string") {
3990
+ if (node.computed && _optionalChain([node, 'access', _269 => _269.property, 'optionalAccess', _270 => _270.type]) === "Literal" && typeof node.property.value === "string") {
3927
3991
  return matchesPropName(node.property.value, matcher);
3928
3992
  }
3929
3993
  }
@@ -3959,7 +4023,7 @@ function classifyChunkBoundary(ast) {
3959
4023
  walk2.simple(ast, {
3960
4024
  CallExpression(node) {
3961
4025
  const callee = node.callee;
3962
- const isPushCall = _optionalChain([callee, 'optionalAccess', _270 => _270.type]) === "MemberExpression" && (!callee.computed && _optionalChain([callee, 'access', _271 => _271.property, 'optionalAccess', _272 => _272.type]) === "Identifier" && callee.property.name === "push" || callee.computed && _optionalChain([callee, 'access', _273 => _273.property, 'optionalAccess', _274 => _274.type]) === "Literal" && callee.property.value === "push");
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");
3963
4027
  if (isPushCall) {
3964
4028
  if (unwrapAssignedHostMember(callee.object, "__next_f")) {
3965
4029
  hasRscFlight = true;
@@ -3999,13 +4063,13 @@ function classifyChunkBoundary(ast) {
3999
4063
  if (isHostMember(node.left, "TURBOPACK") || isHostMember(node.left, isWebpackOrRspackChunkName)) {
4000
4064
  hasEntryBootstrap = true;
4001
4065
  exemptSubtreeRoots.add(node);
4002
- } else if (_optionalChain([node, 'access', _275 => _275.left, 'optionalAccess', _276 => _276.type]) === "Identifier" && node.left.name === "__vite__mapDeps") {
4066
+ } else if (_optionalChain([node, 'access', _276 => _276.left, 'optionalAccess', _277 => _277.type]) === "Identifier" && node.left.name === "__vite__mapDeps") {
4003
4067
  hasPreloadManifest = true;
4004
4068
  exemptSubtreeRoots.add(node);
4005
4069
  }
4006
4070
  },
4007
4071
  VariableDeclarator(node) {
4008
- if (_optionalChain([node, 'access', _277 => _277.id, 'optionalAccess', _278 => _278.type]) === "Identifier") {
4072
+ if (_optionalChain([node, 'access', _278 => _278.id, 'optionalAccess', _279 => _279.type]) === "Identifier") {
4009
4073
  if (node.id.name === "__vite__mapDeps") {
4010
4074
  hasPreloadManifest = true;
4011
4075
  exemptSubtreeRoots.add(node);
@@ -4016,7 +4080,7 @@ function classifyChunkBoundary(ast) {
4016
4080
  }
4017
4081
  },
4018
4082
  FunctionDeclaration(node) {
4019
- if (_optionalChain([node, 'access', _279 => _279.id, 'optionalAccess', _280 => _280.type]) === "Identifier" && node.id.name === "__vite__mapDeps") {
4083
+ if (_optionalChain([node, 'access', _280 => _280.id, 'optionalAccess', _281 => _281.type]) === "Identifier" && node.id.name === "__vite__mapDeps") {
4020
4084
  hasPreloadManifest = true;
4021
4085
  exemptSubtreeRoots.add(node);
4022
4086
  }
@@ -4058,7 +4122,7 @@ function attachMagicComments(importExpressions, comments) {
4058
4122
  const magicComments = comments.filter((c) => MAGIC_COMMENT_RE.test(c.value));
4059
4123
  if (magicComments.length === 0) return;
4060
4124
  for (const expr of importExpressions) {
4061
- const src = _optionalChain([expr, 'optionalAccess', _281 => _281.source]);
4125
+ const src = _optionalChain([expr, 'optionalAccess', _282 => _282.source]);
4062
4126
  if (!src || typeof expr.start !== "number" || typeof src.start !== "number") {
4063
4127
  continue;
4064
4128
  }
@@ -4153,8 +4217,8 @@ function encodeSaltedString(str, k) {
4153
4217
  function isAstAlreadySalted(ast) {
4154
4218
  if (!ast || !Array.isArray(ast.body)) return false;
4155
4219
  return ast.body.some((stmt) => {
4156
- if (stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _282 => _282.declarations, 'optionalAccess', _283 => _283.some, 'call', _284 => _284(
4157
- (d) => _optionalChain([d, 'access', _285 => _285.id, 'optionalAccess', _286 => _286.type]) === "Identifier" && typeof d.id.name === "string" && (d.id.name.startsWith("_uP") || _optionalChain([d, 'access', _287 => _287.init, 'optionalAccess', _288 => _288.type]) === "CallExpression" && _optionalChain([d, 'access', _289 => _289.init, 'access', _290 => _290.callee, 'optionalAccess', _291 => _291.type]) === "FunctionExpression" && _optionalChain([d, 'access', _292 => _292.init, 'access', _293 => _293.callee, 'optionalAccess', _294 => _294.id, 'optionalAccess', _295 => _295.name]) === "f" && _optionalChain([d, 'access', _296 => _296.init, 'access', _297 => _297.arguments, 'optionalAccess', _298 => _298[0], 'optionalAccess', _299 => _299.type]) === "ArrayExpression")
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")
4158
4222
  )])) {
4159
4223
  return true;
4160
4224
  }
@@ -4189,29 +4253,52 @@ function applySaltedStringVault(ast, seed = 2654435769, minStringLength = 4, hot
4189
4253
  shaderBuffersCount: 0
4190
4254
  };
4191
4255
  }
4192
- const minLen = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _300 => _300.vault, 'optionalAccess', _301 => _301.minStringLength]), () => ( minStringLength));
4256
+ const minLen = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _301 => _301.vault, 'optionalAccess', _302 => _302.minStringLength]), () => ( minStringLength));
4193
4257
  const activeDirectives = new Set(DIRECTIVE_STRINGS);
4194
- if (_optionalChain([config, 'optionalAccess', _302 => _302.vault, 'optionalAccess', _303 => _303.customDirectives])) {
4258
+ if (_optionalChain([config, 'optionalAccess', _303 => _303.vault, 'optionalAccess', _304 => _304.customDirectives])) {
4195
4259
  for (const dir of config.vault.customDirectives) {
4196
4260
  activeDirectives.add(dir);
4197
4261
  }
4198
4262
  }
4199
- const customReserved = _optionalChain([config, 'optionalAccess', _304 => _304.vault, 'optionalAccess', _305 => _305.reservedProps]) ? new Set(config.vault.reservedProps) : void 0;
4263
+ const customReserved = _optionalChain([config, 'optionalAccess', _305 => _305.vault, 'optionalAccess', _306 => _306.reservedProps]) ? new Set(config.vault.reservedProps) : void 0;
4200
4264
  const targetsToReplace = [];
4201
4265
  const encryptedPayloads = [];
4202
4266
  const shaderToIndex = /* @__PURE__ */ new Map();
4203
4267
  const shaderPayloads = [];
4204
4268
  const shaderTargets = [];
4205
- function processSaltedCandidate(val, node, parent, ancestors) {
4269
+ const interpolatedTemplates = [];
4270
+ let regExpShadowedScopes;
4271
+ const getRegExpShadowedScopes = () => {
4272
+ regExpShadowedScopes ??= collectIdentifierShadowedScopes(ast, "RegExp");
4273
+ return regExpShadowedScopes;
4274
+ };
4275
+ function pushSaltedTarget(rawString, node, parent, extra) {
4276
+ const callSiteIdx = targetsToReplace.length;
4277
+ const [saltLo, saltHi] = computeCallSiteSalt64(
4278
+ seed >>> 0,
4279
+ callSiteIdx >>> 0,
4280
+ seed >>> 0
4281
+ );
4282
+ const localSalt = ((saltLo ^ saltHi) & 2147483647 | 1) >>> 0;
4283
+ targetsToReplace.push({
4284
+ node,
4285
+ parent,
4286
+ callSiteIdx,
4287
+ localSalt,
4288
+ rawString,
4289
+ ...extra
4290
+ });
4291
+ }
4292
+ function processSaltedCandidate(val, node, parent, ancestors, onReplace) {
4206
4293
  if (isNodeInExemptSubtree(ancestors, exemptSubtreeRoots)) {
4207
- return;
4294
+ return false;
4208
4295
  }
4209
4296
  if (parent.type === "ExpressionStatement" && (Boolean(parent.directive) || activeDirectives.has(val))) {
4210
- return;
4297
+ return false;
4211
4298
  }
4212
4299
  for (let i = ancestors.length - 2; i >= 0; i--) {
4213
4300
  if (ancestors[i].type === "ExpressionStatement" && Boolean(ancestors[i].directive)) {
4214
- return;
4301
+ return false;
4215
4302
  }
4216
4303
  }
4217
4304
  let isHotExempt = false;
@@ -4238,11 +4325,11 @@ function applySaltedStringVault(ast, seed = 2654435769, minStringLength = 4, hot
4238
4325
  shaderToIndex.set(val, idx);
4239
4326
  shaderPayloads.push(val);
4240
4327
  }
4241
- shaderTargets.push({ node, parent, idx });
4242
- return;
4328
+ shaderTargets.push({ node, parent, idx, ...onReplace ? { onReplace } : {} });
4329
+ return true;
4243
4330
  }
4244
4331
  if (isHotExempt) {
4245
- return;
4332
+ return false;
4246
4333
  }
4247
4334
  if (!shouldEncryptString(
4248
4335
  val,
@@ -4251,25 +4338,33 @@ function applySaltedStringVault(ast, seed = 2654435769, minStringLength = 4, hot
4251
4338
  activeDirectives,
4252
4339
  customReserved
4253
4340
  )) {
4254
- return;
4341
+ return false;
4255
4342
  }
4256
- const callSiteIdx = targetsToReplace.length;
4257
- const [saltLo, saltHi] = computeCallSiteSalt64(
4258
- seed >>> 0,
4259
- callSiteIdx >>> 0,
4260
- seed >>> 0
4261
- );
4262
- const localSalt = ((saltLo ^ saltHi) & 2147483647 | 1) >>> 0;
4263
- targetsToReplace.push({
4264
- node,
4265
- parent,
4266
- callSiteIdx,
4267
- localSalt,
4268
- rawString: val
4269
- });
4343
+ pushSaltedTarget(val, node, parent, onReplace ? { onReplace } : void 0);
4344
+ return true;
4270
4345
  }
4271
4346
  walk3.ancestor(ast, {
4272
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,
4358
+ node,
4359
+ ancestors[ancestors.length - 2],
4360
+ {
4361
+ replaceMode: "regexp",
4362
+ flags: _nullishCoalesce(node.regex.flags, () => ( ""))
4363
+ }
4364
+ );
4365
+ }
4366
+ return;
4367
+ }
4273
4368
  if (typeof node.value !== "string") return;
4274
4369
  const val = node.value;
4275
4370
  if (activeDirectives.has(val)) return;
@@ -4290,19 +4385,42 @@ function applySaltedStringVault(ast, seed = 2654435769, minStringLength = 4, hot
4290
4385
  processSaltedCandidate(val, node, parent, ancestors);
4291
4386
  },
4292
4387
  TemplateLiteral(node, ancestors) {
4293
- if (!node.quasis || node.quasis.length !== 1) return;
4294
- if (node.expressions && node.expressions.length !== 0) return;
4295
- const val = _nullishCoalesce(node.quasis[0].value.cooked, () => ( node.quasis[0].value.raw));
4296
- if (typeof val !== "string" || activeDirectives.has(val)) return;
4388
+ if (!Array.isArray(node.quasis) || node.quasis.length === 0) return;
4297
4389
  const parent = ancestors[ancestors.length - 2];
4298
- if (!parent) return;
4299
- if (parent.type === "TaggedTemplateExpression" && parent.quasi === node) {
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
+ processSaltedCandidate(val, node, parent, ancestors);
4300
4397
  return;
4301
4398
  }
4302
- if (parent.type === "ImportExpression" && parent.source === node) {
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")) {
4303
4401
  return;
4304
4402
  }
4305
- processSaltedCandidate(val, node, parent, ancestors);
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);
4415
+ }
4416
+ );
4417
+ if (queued) {
4418
+ queuedCount++;
4419
+ }
4420
+ }
4421
+ if (queuedCount > 0) {
4422
+ interpolatedTemplates.push({ node, replacements });
4423
+ }
4306
4424
  }
4307
4425
  });
4308
4426
  if (targetsToReplace.length === 0 && shaderTargets.length === 0) {
@@ -4383,7 +4501,17 @@ function applySaltedStringVault(ast, seed = 2654435769, minStringLength = 4, hot
4383
4501
  ],
4384
4502
  optional: false
4385
4503
  };
4386
- replaceNodeInParent(target.parent, target.node, callExpr);
4504
+ if (target.onReplace) {
4505
+ target.onReplace(callExpr);
4506
+ } else if (target.replaceMode === "regexp") {
4507
+ replaceNodeInParent(
4508
+ target.parent,
4509
+ target.node,
4510
+ createNewRegExpAst(callExpr, _nullishCoalesce(target.flags, () => ( "")))
4511
+ );
4512
+ } else {
4513
+ replaceNodeInParent(target.parent, target.node, callExpr);
4514
+ }
4387
4515
  }
4388
4516
  const serializedTable = JSON.stringify(encryptedPayloads);
4389
4517
  integrityToken = computeFnv1aHash(serializedTable, seed);
@@ -4413,7 +4541,11 @@ function applySaltedStringVault(ast, seed = 2654435769, minStringLength = 4, hot
4413
4541
  ],
4414
4542
  optional: false
4415
4543
  };
4416
- replaceNodeInParent(target.parent, target.node, callExpr);
4544
+ if (target.onReplace) {
4545
+ target.onReplace(callExpr);
4546
+ } else {
4547
+ replaceNodeInParent(target.parent, target.node, callExpr);
4548
+ }
4417
4549
  }
4418
4550
  const shaderHelperStmt = createShaderVaultAst(
4419
4551
  shaderVarName,
@@ -4429,6 +4561,7 @@ function applySaltedStringVault(ast, seed = 2654435769, minStringLength = 4, hot
4429
4561
  integrityToken = computeFnv1aHash(JSON.stringify(shaderPayloads), seed);
4430
4562
  }
4431
4563
  }
4564
+ rebuildInterpolatedTemplates(interpolatedTemplates);
4432
4565
  return {
4433
4566
  encryptedStringsCount: targetsToReplace.length,
4434
4567
  integrityToken,
@@ -4438,6 +4571,133 @@ function applySaltedStringVault(ast, seed = 2654435769, minStringLength = 4, hot
4438
4571
  };
4439
4572
  }
4440
4573
 
4574
+ // src/ast/secret-patterns.ts
4575
+ var PEM_HEADER_RE = /-----BEGIN\s+[A-Z0-9 ]+-----/;
4576
+ var PEM_REGEX_HEADER_RE = /-----BEGIN(?:\s|\\s[+*?]?)+(?:[A-Z0-9 ]|\\s[+*?]?)+-----/;
4577
+ var TOKEN_PREFIX_RE = /\b(?:sk_live_|sk_test_|pk_live_|ghp_|gho_|github_pat_|xox[baprs]-|AKIA[0-9A-Z]{16}|AIza[0-9A-Za-z_-]{35}|FLAG\{[^}]{4,}\}|eyJ[A-Za-z0-9_-]{10,}\.eyJ[A-Za-z0-9_-]{10,})/;
4578
+ var ESCAPED_FLAG_REGEX_RE = /\bFLAG\\\{[^}]{4,}\\\}/;
4579
+ var HEX_RE = /^[0-9a-fA-F]+$/;
4580
+ var BASE64_RE = /^[A-Za-z0-9+/]+=*$/;
4581
+ var TOKEN_CHARSET_RE = /^[A-Za-z0-9_\-+/=.~:@!#$%^&*]+$/;
4582
+ var PATH_LIKE_RE = /^(?:\.{1,2}\/|@[\w.-]+\/)|\.(?:[cm]?[jt]sx?|json|css|map|wasm|html?|node|svg|png|jpe?g|gif|woff2?|ttf|md|txt|ya?ml|toml|lock)$/i;
4583
+ var REGEX_CHAR_CLASS_RE = /\[(?:\\[\s\S]|[^\]\\])*\]/g;
4584
+ var REGEX_META_SPLIT_RE = /\(\?(?:<[=!]|<[^>]+>|[:=!])?|\\[\s\S]|[\s^$.*+?()[\]{}|/]+/;
4585
+ var COMMON_BIGRAMS = new Set(
4586
+ "th he in er an re on at en nd ti es or te of ed is it al ar st to nt ng se ha as ou io le ve co me de hi ri ro ic ne ea ra ce li ch ll be ma si om ur ca el ta la ns ge ec ct pe ol un il us ss ac em tr pr po fi ad lo ut id pa so mo wi no di ee ul et ai rs oo ex".split(" ")
4587
+ );
4588
+ var COMMON_BIGRAM_CHANCE = COMMON_BIGRAMS.size / 676;
4589
+ var NATURAL_TEXT_Z = 3.5;
4590
+ function isAsciiLetter(code) {
4591
+ return code >= 65 && code <= 90 || code >= 97 && code <= 122;
4592
+ }
4593
+ function isBinaryOrWasmPrefix(value) {
4594
+ return value.startsWith("AGFzbQE") || /^data:/i.test(value);
4595
+ }
4596
+ function countBase64MarkerRatio(value) {
4597
+ let hits = 0;
4598
+ for (let i = 0; i < value.length; i++) {
4599
+ const code = value.charCodeAt(i);
4600
+ if (code >= 48 && code <= 57 || // 0-9
4601
+ code === 43 || // +
4602
+ code === 47 || // /
4603
+ code === 61) {
4604
+ hits += 1;
4605
+ }
4606
+ }
4607
+ return hits / value.length;
4608
+ }
4609
+ function shannonEntropy(value) {
4610
+ if (value.length === 0) return 0;
4611
+ const counts = /* @__PURE__ */ new Map();
4612
+ for (let i = 0; i < value.length; i++) {
4613
+ const code = value.charCodeAt(i);
4614
+ counts.set(code, (_nullishCoalesce(counts.get(code), () => ( 0))) + 1);
4615
+ }
4616
+ let h = 0;
4617
+ for (const count of counts.values()) {
4618
+ const p = count / value.length;
4619
+ h -= p * Math.log2(p);
4620
+ }
4621
+ return h;
4622
+ }
4623
+ function isSequentialAlphabet(value) {
4624
+ if (value.length < 8) return false;
4625
+ let ascending = 0;
4626
+ for (let i = 1; i < value.length; i++) {
4627
+ if (value.charCodeAt(i) - value.charCodeAt(i - 1) === 1) {
4628
+ ascending += 1;
4629
+ }
4630
+ }
4631
+ return ascending / (value.length - 1) >= 0.6;
4632
+ }
4633
+ function looksLikeNaturalText(value) {
4634
+ let pairs = 0;
4635
+ let hits = 0;
4636
+ const lower = value.toLowerCase();
4637
+ for (let i = 1; i < value.length; i++) {
4638
+ const a = value.charCodeAt(i - 1);
4639
+ const b = value.charCodeAt(i);
4640
+ if (!isAsciiLetter(a) || !isAsciiLetter(b)) continue;
4641
+ pairs += 1;
4642
+ if (a >= 97 && b <= 90) continue;
4643
+ if (COMMON_BIGRAMS.has(lower[i - 1] + lower[i])) {
4644
+ hits += 1;
4645
+ }
4646
+ }
4647
+ if (pairs < 4) return false;
4648
+ const expected = COMMON_BIGRAM_CHANCE * pairs;
4649
+ const deviation = Math.sqrt(
4650
+ pairs * COMMON_BIGRAM_CHANCE * (1 - COMMON_BIGRAM_CHANCE)
4651
+ );
4652
+ return (hits - expected) / deviation >= NATURAL_TEXT_Z;
4653
+ }
4654
+ function classifyPlaintextSecret(value) {
4655
+ if (typeof value !== "string" || value.length < 8) return null;
4656
+ if (isBinaryOrWasmPrefix(value)) return null;
4657
+ if (PATH_LIKE_RE.test(value)) return null;
4658
+ const entropy = shannonEntropy(value);
4659
+ if (PEM_HEADER_RE.test(value)) {
4660
+ return { category: "pem-header", entropy };
4661
+ }
4662
+ if (TOKEN_PREFIX_RE.test(value)) {
4663
+ return { category: "token-prefix", entropy };
4664
+ }
4665
+ if (isSequentialAlphabet(value)) {
4666
+ return null;
4667
+ }
4668
+ const isHex = value.length >= 24 && value.length % 2 === 0 && HEX_RE.test(value) && entropy >= 3.2;
4669
+ if (isHex) {
4670
+ return { category: "hex-or-base64", entropy };
4671
+ }
4672
+ const isBase64Like = value.length >= 28 && BASE64_RE.test(value) && countBase64MarkerRatio(value) >= 0.15 && !looksLikeNaturalText(value) && entropy >= 4;
4673
+ if (isBase64Like) {
4674
+ return { category: "hex-or-base64", entropy };
4675
+ }
4676
+ if (value.length >= 20 && value.length <= 512 && TOKEN_CHARSET_RE.test(value) && !looksLikeNaturalText(value) && entropy >= 4.1) {
4677
+ return { category: "high-entropy", entropy };
4678
+ }
4679
+ return null;
4680
+ }
4681
+ function isLikelySecretLiteral(value) {
4682
+ return classifyPlaintextSecret(value) !== null;
4683
+ }
4684
+ function hasRegexSecretRun(pattern) {
4685
+ if (typeof pattern !== "string" || pattern.length === 0 || pattern.length > 4096) {
4686
+ return false;
4687
+ }
4688
+ if (PEM_HEADER_RE.test(pattern) || PEM_REGEX_HEADER_RE.test(pattern) || TOKEN_PREFIX_RE.test(pattern) || ESCAPED_FLAG_REGEX_RE.test(pattern)) {
4689
+ return true;
4690
+ }
4691
+ const outsideClasses = pattern.replace(REGEX_CHAR_CLASS_RE, " ");
4692
+ const parts = outsideClasses.split(REGEX_META_SPLIT_RE);
4693
+ for (const part of parts) {
4694
+ if (part.length >= 20 && isLikelySecretLiteral(part)) {
4695
+ return true;
4696
+ }
4697
+ }
4698
+ return false;
4699
+ }
4700
+
4441
4701
  // src/ast/string-vault.ts
4442
4702
  var SAFE_ALPHA = " !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~";
4443
4703
  var DIRECTIVE_STRINGS = /* @__PURE__ */ new Set([
@@ -4494,7 +4754,7 @@ function isReactDomSpecialProp(val, node, parent, customReserved) {
4494
4754
  if (parent.key === node && !parent.computed) {
4495
4755
  return true;
4496
4756
  }
4497
- const keyName = _optionalChain([parent, 'access', _306 => _306.key, 'optionalAccess', _307 => _307.type]) === "Identifier" ? parent.key.name : _optionalChain([parent, 'access', _308 => _308.key, 'optionalAccess', _309 => _309.type]) === "Literal" ? String(parent.key.value) : "";
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) : "";
4498
4758
  if (keyName && isReservedProp(keyName, customReserved)) {
4499
4759
  return true;
4500
4760
  }
@@ -4557,11 +4817,11 @@ var DEFAULT_SEMANTIC_ANCHOR_RE = /(?:\bapi\/|\bcheckout\b|\badmin\b|\bauth\b|\bt
4557
4817
  function isUiClassName(val, parent) {
4558
4818
  if (parent) {
4559
4819
  if (parent.type === "Property") {
4560
- const k = _optionalChain([parent, 'access', _310 => _310.key, 'optionalAccess', _311 => _311.type]) === "Identifier" ? parent.key.name : _optionalChain([parent, 'access', _312 => _312.key, 'optionalAccess', _313 => _313.type]) === "Literal" ? String(parent.key.value) : "";
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) : "";
4561
4821
  if (k === "className" || k === "class" || k === "classList") return true;
4562
4822
  }
4563
4823
  if (parent.type === "JSXAttribute") {
4564
- const name = _optionalChain([parent, 'access', _314 => _314.name, 'optionalAccess', _315 => _315.name]);
4824
+ const name = _optionalChain([parent, 'access', _317 => _317.name, 'optionalAccess', _318 => _318.name]);
4565
4825
  if (name === "className" || name === "class") return true;
4566
4826
  }
4567
4827
  }
@@ -4657,7 +4917,7 @@ function isBinaryOrBase64Payload(val) {
4657
4917
  function isShaderPayload(val, node, parent, ancestors, seed, isHotExempt, customReserved) {
4658
4918
  if (isBinaryOrBase64Payload(val)) return false;
4659
4919
  if (isInsideLoopOrSerialized(ancestors)) return false;
4660
- if (_optionalChain([parent, 'optionalAccess', _316 => _316.type]) === "Property" && parent.key === node && !parent.computed) return false;
4920
+ if (_optionalChain([parent, 'optionalAccess', _319 => _319.type]) === "Property" && parent.key === node && !parent.computed) return false;
4661
4921
  if (isReservedProp(val, customReserved)) return false;
4662
4922
  if (isTailwindNoise(val)) return false;
4663
4923
  if (isSvgPathString(val, parent)) return false;
@@ -4674,7 +4934,7 @@ function findVaultInsertIndex(ast, activeDirectives = DIRECTIVE_STRINGS) {
4674
4934
  let insertIdx = 0;
4675
4935
  while (insertIdx < ast.body.length) {
4676
4936
  const stmt = ast.body[insertIdx];
4677
- const isDirective = stmt.type === "ExpressionStatement" && (Boolean(stmt.directive) || _optionalChain([stmt, 'access', _317 => _317.expression, 'optionalAccess', _318 => _318.type]) === "Literal" && typeof stmt.expression.value === "string" && (activeDirectives.has(stmt.expression.value) || /^(?:use\s+[a-zA-Z0-9_-]+)/.test(stmt.expression.value.trim())));
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())));
4678
4938
  if (isDirective || stmt.type === "ImportDeclaration") {
4679
4939
  insertIdx++;
4680
4940
  } else {
@@ -4825,25 +5085,241 @@ function findLowestCommonScope(ast, chains) {
4825
5085
  }
4826
5086
  return _nullishCoalesce(lca[lca.length - 1], () => ( ast));
4827
5087
  }
5088
+ function isExemptTemplateLiteral(node, parent) {
5089
+ if (!parent) return true;
5090
+ if (parent.type === "TaggedTemplateExpression" && parent.quasi === node) {
5091
+ return true;
5092
+ }
5093
+ if (parent.type === "ImportExpression" && parent.source === node) {
5094
+ return true;
5095
+ }
5096
+ return false;
5097
+ }
5098
+ function rebuildInterpolatedTemplates(plans) {
5099
+ for (const { node, replacements } of plans) {
5100
+ if (replacements.size === 0) continue;
5101
+ const origQuasis = node.quasis;
5102
+ const origExprs = node.expressions;
5103
+ const nextQuasis = [];
5104
+ const nextExprs = [];
5105
+ let pendingRaw = "";
5106
+ let pendingCooked = "";
5107
+ const flushQuasi = (tail) => {
5108
+ nextQuasis.push({
5109
+ type: "TemplateElement",
5110
+ value: { raw: pendingRaw, cooked: pendingCooked },
5111
+ tail
5112
+ });
5113
+ pendingRaw = "";
5114
+ pendingCooked = "";
5115
+ };
5116
+ for (let i = 0; i < origQuasis.length; i++) {
5117
+ const quasi = origQuasis[i];
5118
+ const replacement = replacements.get(i);
5119
+ if (replacement !== void 0) {
5120
+ flushQuasi(false);
5121
+ nextExprs.push(replacement);
5122
+ } 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]), () => ( ""));
5125
+ }
5126
+ if (i < origExprs.length) {
5127
+ flushQuasi(false);
5128
+ nextExprs.push(origExprs[i]);
5129
+ }
5130
+ }
5131
+ flushQuasi(true);
5132
+ node.quasis = nextQuasis;
5133
+ node.expressions = nextExprs;
5134
+ }
5135
+ }
5136
+ function createNewRegExpAst(sourceExpr, flags) {
5137
+ return {
5138
+ type: "NewExpression",
5139
+ callee: { type: "Identifier", name: "RegExp" },
5140
+ arguments: flags.length > 0 ? [
5141
+ sourceExpr,
5142
+ {
5143
+ type: "Literal",
5144
+ value: flags,
5145
+ raw: JSON.stringify(flags)
5146
+ }
5147
+ ] : [sourceExpr]
5148
+ };
5149
+ }
5150
+ function mutateNodeToNewRegExp(node, sourceExpr, flags) {
5151
+ const newExpr = createNewRegExpAst(sourceExpr, flags);
5152
+ node.type = "NewExpression";
5153
+ node.callee = newExpr.callee;
5154
+ node.arguments = newExpr.arguments;
5155
+ delete node.value;
5156
+ delete node.raw;
5157
+ delete node.regex;
5158
+ delete node.optional;
5159
+ }
5160
+ var SCOPE_FUNCTION_TYPES = /* @__PURE__ */ new Set([
5161
+ "FunctionDeclaration",
5162
+ "FunctionExpression",
5163
+ "ArrowFunctionExpression"
5164
+ ]);
5165
+ var SCOPE_LEXICAL_TYPES = /* @__PURE__ */ new Set([
5166
+ "Program",
5167
+ "FunctionDeclaration",
5168
+ "FunctionExpression",
5169
+ "ArrowFunctionExpression",
5170
+ "BlockStatement",
5171
+ "ForStatement",
5172
+ "ForInStatement",
5173
+ "ForOfStatement",
5174
+ "SwitchStatement",
5175
+ "CatchClause",
5176
+ "ClassDeclaration",
5177
+ "ClassExpression",
5178
+ "StaticBlock"
5179
+ ]);
5180
+ function patternContainsIdentifier(pattern, targetName) {
5181
+ if (!pattern || typeof pattern !== "object") return false;
5182
+ switch (pattern.type) {
5183
+ case "Identifier":
5184
+ return pattern.name === targetName;
5185
+ case "AssignmentPattern":
5186
+ return patternContainsIdentifier(pattern.left, targetName);
5187
+ case "RestElement":
5188
+ return patternContainsIdentifier(pattern.argument, targetName);
5189
+ case "ArrayPattern":
5190
+ return (pattern.elements || []).some(
5191
+ (el) => patternContainsIdentifier(el, targetName)
5192
+ );
5193
+ case "ObjectPattern":
5194
+ 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
5196
+ );
5197
+ default:
5198
+ return false;
5199
+ }
5200
+ }
5201
+ function findEnclosingScope(ancestors, scopeSet, fallback) {
5202
+ for (let i = ancestors.length - 1; i >= 0; i--) {
5203
+ if (scopeSet.has(ancestors[i].type)) {
5204
+ return ancestors[i];
5205
+ }
5206
+ }
5207
+ return fallback;
5208
+ }
5209
+ function collectIdentifierShadowedScopes(ast, identName = "RegExp") {
5210
+ const shadowed = /* @__PURE__ */ new WeakSet();
5211
+ walk4.ancestor(ast, {
5212
+ FunctionDeclaration(node, _state, ancestors) {
5213
+ if (_optionalChain([node, 'access', _328 => _328.id, 'optionalAccess', _329 => _329.name]) === identName) {
5214
+ shadowed.add(
5215
+ findEnclosingScope(ancestors.slice(0, -1), SCOPE_LEXICAL_TYPES, ast)
5216
+ );
5217
+ shadowed.add(node);
5218
+ }
5219
+ if (Array.isArray(node.params) && node.params.some((p) => patternContainsIdentifier(p, identName))) {
5220
+ shadowed.add(node);
5221
+ }
5222
+ },
5223
+ 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))) {
5225
+ shadowed.add(node);
5226
+ }
5227
+ },
5228
+ ArrowFunctionExpression(node) {
5229
+ if (Array.isArray(node.params) && node.params.some((p) => patternContainsIdentifier(p, identName))) {
5230
+ shadowed.add(node);
5231
+ }
5232
+ },
5233
+ ClassDeclaration(node, _state, ancestors) {
5234
+ if (_optionalChain([node, 'access', _332 => _332.id, 'optionalAccess', _333 => _333.name]) === identName) {
5235
+ shadowed.add(
5236
+ findEnclosingScope(ancestors.slice(0, -1), SCOPE_LEXICAL_TYPES, ast)
5237
+ );
5238
+ shadowed.add(node);
5239
+ }
5240
+ },
5241
+ ClassExpression(node) {
5242
+ if (_optionalChain([node, 'access', _334 => _334.id, 'optionalAccess', _335 => _335.name]) === identName) {
5243
+ shadowed.add(node);
5244
+ }
5245
+ },
5246
+ CatchClause(node) {
5247
+ if (node.param && patternContainsIdentifier(node.param, identName)) {
5248
+ shadowed.add(node);
5249
+ }
5250
+ },
5251
+ WithStatement(node) {
5252
+ shadowed.add(node);
5253
+ },
5254
+ ImportDeclaration(node) {
5255
+ if (Array.isArray(node.specifiers) && node.specifiers.some((s) => _optionalChain([s, 'optionalAccess', _336 => _336.local, 'optionalAccess', _337 => _337.name]) === identName)) {
5256
+ shadowed.add(ast);
5257
+ }
5258
+ },
5259
+ VariableDeclaration(node, _state, ancestors) {
5260
+ if (!Array.isArray(node.declarations) || !node.declarations.some(
5261
+ (d) => patternContainsIdentifier(_optionalChain([d, 'optionalAccess', _338 => _338.id]), identName)
5262
+ )) {
5263
+ return;
5264
+ }
5265
+ if (node.kind === "var") {
5266
+ for (let i = ancestors.length - 1; i >= 0; i--) {
5267
+ const a = ancestors[i];
5268
+ if (SCOPE_FUNCTION_TYPES.has(a.type) || a.type === "StaticBlock" || a.type === "Program") {
5269
+ shadowed.add(a);
5270
+ break;
5271
+ }
5272
+ }
5273
+ } else {
5274
+ shadowed.add(
5275
+ findEnclosingScope(ancestors.slice(0, -1), SCOPE_LEXICAL_TYPES, ast)
5276
+ );
5277
+ }
5278
+ }
5279
+ });
5280
+ return shadowed;
5281
+ }
5282
+ function isEligibleSecretRegExp(node, ancestors, hotExemptNodes, exemptSubtreeRoots, getShadowedScopes) {
5283
+ const pattern = _optionalChain([node, 'optionalAccess', _339 => _339.regex, 'optionalAccess', _340 => _340.pattern]);
5284
+ if (typeof pattern !== "string" || pattern.length === 0 || pattern.length > 4096) {
5285
+ return false;
5286
+ }
5287
+ if (!hasRegexSecretRun(pattern)) {
5288
+ return false;
5289
+ }
5290
+ if (isNodeInExemptSubtree(ancestors, exemptSubtreeRoots)) {
5291
+ return false;
5292
+ }
5293
+ if (isInsideLoopOrSerialized(ancestors)) {
5294
+ return false;
5295
+ }
5296
+ if (isNodeInExemptSubtree(ancestors, hotExemptNodes)) {
5297
+ return false;
5298
+ }
5299
+ if (getShadowedScopes && isNodeInExemptSubtree(ancestors, getShadowedScopes())) {
5300
+ return false;
5301
+ }
5302
+ return true;
5303
+ }
4828
5304
  function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExemptNodes, windowKeySymbol, expectedDelta, deterrentMode, config, shieldCoupled = true, detectHeadless = false, exemptSubtreeRoots) {
4829
- const minLen = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _319 => _319.vault, 'optionalAccess', _320 => _320.minStringLength]), () => ( minStringLength));
5305
+ const minLen = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _341 => _341.vault, 'optionalAccess', _342 => _342.minStringLength]), () => ( minStringLength));
4830
5306
  const activeDirectives = new Set(DIRECTIVE_STRINGS);
4831
- if (_optionalChain([config, 'optionalAccess', _321 => _321.vault, 'optionalAccess', _322 => _322.customDirectives])) {
5307
+ if (_optionalChain([config, 'optionalAccess', _343 => _343.vault, 'optionalAccess', _344 => _344.customDirectives])) {
4832
5308
  for (const dir of config.vault.customDirectives) {
4833
5309
  activeDirectives.add(dir);
4834
5310
  }
4835
5311
  }
4836
- const customReserved = _optionalChain([config, 'optionalAccess', _323 => _323.vault, 'optionalAccess', _324 => _324.reservedProps]) ? new Set(config.vault.reservedProps) : void 0;
4837
- const semanticPatterns = _optionalChain([config, 'optionalAccess', _325 => _325.vault, 'optionalAccess', _326 => _326.semanticAnchors, 'optionalAccess', _327 => _327.patterns, 'optionalAccess', _328 => _328.map, 'call', _329 => _329(
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(
4838
5314
  (p) => typeof p === "string" ? new RegExp(p) : p
4839
5315
  )]);
4840
- const excludeUi = _optionalChain([config, 'optionalAccess', _330 => _330.vault, 'optionalAccess', _331 => _331.semanticAnchors, 'optionalAccess', _332 => _332.excludeUiClasses]) !== false;
5316
+ const excludeUi = _optionalChain([config, 'optionalAccess', _352 => _352.vault, 'optionalAccess', _353 => _353.semanticAnchors, 'optionalAccess', _354 => _354.excludeUiClasses]) !== false;
4841
5317
  const suffix = (seed >>> 0 & 65535).toString(36);
4842
5318
  const decryptFnName = `_uD${suffix}`;
4843
5319
  const cacheVarName = derivePolymorphicIdent(seed, "vault");
4844
5320
  const shaderVarName = derivePolymorphicIdent(seed, "shader");
4845
5321
  const sym = _nullishCoalesce(windowKeySymbol, () => ( deriveWindowKeySymbol(seed)));
4846
- const browserOnly = _optionalChain([config, 'optionalAccess', _333 => _333.target]) === "browser";
5322
+ const browserOnly = _optionalChain([config, 'optionalAccess', _355 => _355.target]) === "browser";
4847
5323
  let expDelta = shieldCoupled ? expectedDelta : 0;
4848
5324
  if (shieldCoupled && expDelta === void 0) {
4849
5325
  const shield = generateRuntimeShield({
@@ -4855,8 +5331,8 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
4855
5331
  expDelta = _nullishCoalesce(shield.expectedDelta, () => ( 0));
4856
5332
  }
4857
5333
  const alreadyVaulted = ast.body.some(
4858
- (stmt) => stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _334 => _334.declarations, 'optionalAccess', _335 => _335.some, 'call', _336 => _336(
4859
- (d) => _optionalChain([d, 'access', _337 => _337.id, 'optionalAccess', _338 => _338.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', _339 => _339.init, 'optionalAccess', _340 => _340.type]) === "CallExpression" && _optionalChain([d, 'access', _341 => _341.init, 'access', _342 => _342.callee, 'optionalAccess', _343 => _343.type]) === "FunctionExpression" && _optionalChain([d, 'access', _344 => _344.init, 'access', _345 => _345.callee, 'optionalAccess', _346 => _346.id, 'optionalAccess', _347 => _347.name]) === "f" && _optionalChain([d, 'access', _348 => _348.init, 'access', _349 => _349.arguments, 'optionalAccess', _350 => _350[0], 'optionalAccess', _351 => _351.type]) === "ArrayExpression")
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")
4860
5336
  )])
4861
5337
  );
4862
5338
  if (alreadyVaulted) {
@@ -4886,6 +5362,12 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
4886
5362
  const shaderPayloads = [];
4887
5363
  const targetsToReplace = [];
4888
5364
  const hotTargetsToReplace = [];
5365
+ const interpolatedTemplates = [];
5366
+ let regExpShadowedScopes;
5367
+ const getRegExpShadowedScopes = () => {
5368
+ regExpShadowedScopes ??= collectIdentifierShadowedScopes(ast, "RegExp");
5369
+ return regExpShadowedScopes;
5370
+ };
4889
5371
  const customWalkBase = {
4890
5372
  ...walk4.base,
4891
5373
  Property(node, st, c) {
@@ -4893,16 +5375,16 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
4893
5375
  if (node.value) c(node.value, st);
4894
5376
  }
4895
5377
  };
4896
- function processVaultCandidate(val, node, parent, ancestors) {
5378
+ function processVaultCandidate(val, node, parent, ancestors, onReplace) {
4897
5379
  if (isNodeInExemptSubtree(ancestors, exemptSubtreeRoots)) {
4898
- return;
5380
+ return false;
4899
5381
  }
4900
5382
  if (parent.type === "ExpressionStatement" && (Boolean(parent.directive) || activeDirectives.has(val))) {
4901
- return;
5383
+ return false;
4902
5384
  }
4903
5385
  for (let i = ancestors.length - 2; i >= 0; i--) {
4904
5386
  if (ancestors[i].type === "ExpressionStatement" && Boolean(ancestors[i].directive)) {
4905
- return;
5387
+ return false;
4906
5388
  }
4907
5389
  }
4908
5390
  let isHotExempt = false;
@@ -4934,9 +5416,10 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
4934
5416
  node,
4935
5417
  parent,
4936
5418
  idx: idx2,
4937
- scopeChain: extractScopeChain(ast, ancestors)
5419
+ scopeChain: extractScopeChain(ast, ancestors),
5420
+ ...onReplace ? { onReplace } : {}
4938
5421
  });
4939
- return;
5422
+ return true;
4940
5423
  }
4941
5424
  if (isHotExempt) {
4942
5425
  if (isEligibleHotLiteral(
@@ -4955,10 +5438,12 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
4955
5438
  node,
4956
5439
  parent,
4957
5440
  val,
4958
- idx: hotTargetsToReplace.length
5441
+ idx: hotTargetsToReplace.length,
5442
+ ...onReplace ? { onReplace } : {}
4959
5443
  });
5444
+ return true;
4960
5445
  }
4961
- return;
5446
+ return false;
4962
5447
  }
4963
5448
  if (!shouldEncryptString(
4964
5449
  val,
@@ -4967,7 +5452,7 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
4967
5452
  activeDirectives,
4968
5453
  customReserved
4969
5454
  )) {
4970
- return;
5455
+ return false;
4971
5456
  }
4972
5457
  let idx = stringToIndex.get(val);
4973
5458
  if (idx === void 0) {
@@ -4980,13 +5465,44 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
4980
5465
  node,
4981
5466
  parent,
4982
5467
  idx,
4983
- scopeChain: extractScopeChain(ast, ancestors)
5468
+ scopeChain: extractScopeChain(ast, ancestors),
5469
+ ...onReplace ? { onReplace } : {}
4984
5470
  });
5471
+ return true;
4985
5472
  }
4986
5473
  walk4.ancestor(
4987
5474
  ast,
4988
5475
  {
4989
5476
  Literal(node, _state, ancestors) {
5477
+ if (node.regex) {
5478
+ if (isEligibleSecretRegExp(
5479
+ node,
5480
+ ancestors,
5481
+ hotExemptNodes,
5482
+ exemptSubtreeRoots,
5483
+ getRegExpShadowedScopes
5484
+ )) {
5485
+ const pattern = node.regex.pattern;
5486
+ const flags = _nullishCoalesce(node.regex.flags, () => ( ""));
5487
+ const parent2 = ancestors[ancestors.length - 2];
5488
+ let idx = stringToIndex.get(pattern);
5489
+ if (idx === void 0) {
5490
+ idx = uniqueStrings.length;
5491
+ stringToIndex.set(pattern, idx);
5492
+ uniqueStrings.push(pattern);
5493
+ }
5494
+ targetsToReplace.push({
5495
+ type: "string",
5496
+ node,
5497
+ parent: parent2,
5498
+ idx,
5499
+ scopeChain: extractScopeChain(ast, ancestors),
5500
+ replaceMode: "regexp",
5501
+ flags
5502
+ });
5503
+ }
5504
+ return;
5505
+ }
4990
5506
  if (typeof node.value !== "string") return;
4991
5507
  const val = node.value;
4992
5508
  if (activeDirectives.has(val)) return;
@@ -5004,19 +5520,42 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
5004
5520
  processVaultCandidate(val, node, parent, ancestors);
5005
5521
  },
5006
5522
  TemplateLiteral(node, _state, ancestors) {
5007
- if (!node.quasis || node.quasis.length !== 1) return;
5008
- if (node.expressions && node.expressions.length !== 0) return;
5009
- const val = _nullishCoalesce(node.quasis[0].value.cooked, () => ( node.quasis[0].value.raw));
5010
- if (typeof val !== "string" || activeDirectives.has(val)) return;
5523
+ if (!Array.isArray(node.quasis) || node.quasis.length === 0) return;
5011
5524
  const parent = ancestors[ancestors.length - 2];
5012
- if (!parent) return;
5013
- if (parent.type === "TaggedTemplateExpression" && parent.quasi === node) {
5525
+ if (isExemptTemplateLiteral(node, parent)) return;
5526
+ const exprCount = Array.isArray(node.expressions) ? node.expressions.length : 0;
5527
+ if (exprCount === 0) {
5528
+ if (node.quasis.length !== 1) return;
5529
+ const val = _nullishCoalesce(node.quasis[0].value.cooked, () => ( node.quasis[0].value.raw));
5530
+ if (typeof val !== "string" || activeDirectives.has(val)) return;
5531
+ processVaultCandidate(val, node, parent, ancestors);
5014
5532
  return;
5015
5533
  }
5016
- if (parent.type === "ImportExpression" && parent.source === node) {
5534
+ 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")) {
5017
5536
  return;
5018
5537
  }
5019
- processVaultCandidate(val, node, parent, ancestors);
5538
+ const replacements = /* @__PURE__ */ new Map();
5539
+ let queuedCount = 0;
5540
+ for (let qIdx = 0; qIdx < node.quasis.length; qIdx++) {
5541
+ const val = node.quasis[qIdx].value.cooked;
5542
+ if (activeDirectives.has(val)) continue;
5543
+ const queued = processVaultCandidate(
5544
+ val,
5545
+ node,
5546
+ parent,
5547
+ ancestors,
5548
+ (exprAst) => {
5549
+ replacements.set(qIdx, exprAst);
5550
+ }
5551
+ );
5552
+ if (queued) {
5553
+ queuedCount++;
5554
+ }
5555
+ }
5556
+ if (queuedCount > 0) {
5557
+ interpolatedTemplates.push({ node, replacements });
5558
+ }
5020
5559
  }
5021
5560
  },
5022
5561
  customWalkBase
@@ -5028,41 +5567,72 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
5028
5567
  shaderBuffersCount: 0
5029
5568
  };
5030
5569
  }
5031
- for (const { node, parent, val, idx } of hotTargetsToReplace) {
5570
+ for (const { node, parent, val, idx, onReplace } of hotTargetsToReplace) {
5032
5571
  const key = idx % 3 + 1;
5033
5572
  let encodedStr = "";
5034
5573
  for (let i = 0; i < val.length; i++) {
5035
5574
  encodedStr += String.fromCharCode(val.charCodeAt(i) ^ key);
5036
5575
  }
5037
- if (_optionalChain([parent, 'optionalAccess', _352 => _352.type]) === "Property" && parent.key === node) {
5576
+ const callExpr = {
5577
+ type: "CallExpression",
5578
+ callee: {
5579
+ type: "Identifier",
5580
+ name: "_hX"
5581
+ },
5582
+ arguments: [
5583
+ {
5584
+ type: "Literal",
5585
+ value: encodedStr,
5586
+ raw: JSON.stringify(encodedStr)
5587
+ },
5588
+ {
5589
+ type: "Literal",
5590
+ value: key,
5591
+ raw: String(key)
5592
+ }
5593
+ ],
5594
+ optional: false
5595
+ };
5596
+ if (onReplace) {
5597
+ onReplace(callExpr);
5598
+ continue;
5599
+ }
5600
+ if (_optionalChain([parent, 'optionalAccess', _376 => _376.type]) === "Property" && parent.key === node) {
5038
5601
  parent.computed = true;
5039
5602
  }
5040
5603
  node.type = "CallExpression";
5041
- node.callee = {
5042
- type: "Identifier",
5043
- name: "_hX"
5044
- };
5045
- node.arguments = [
5046
- {
5047
- type: "Literal",
5048
- value: encodedStr,
5049
- raw: JSON.stringify(encodedStr)
5050
- },
5051
- {
5052
- type: "Literal",
5053
- value: key,
5054
- raw: String(key)
5055
- }
5056
- ];
5604
+ node.callee = callExpr.callee;
5605
+ node.arguments = callExpr.arguments;
5057
5606
  node.optional = false;
5058
5607
  delete node.value;
5059
5608
  delete node.raw;
5060
5609
  delete node.quasis;
5061
5610
  delete node.expressions;
5062
5611
  }
5612
+ function applyVaultTargetReplacement(target, callExpr) {
5613
+ if (target.onReplace) {
5614
+ target.onReplace(callExpr);
5615
+ return;
5616
+ }
5617
+ if (target.replaceMode === "regexp") {
5618
+ mutateNodeToNewRegExp(target.node, callExpr, _nullishCoalesce(target.flags, () => ( "")));
5619
+ return;
5620
+ }
5621
+ if (_optionalChain([target, 'access', _377 => _377.parent, 'optionalAccess', _378 => _378.type]) === "Property" && target.parent.key === target.node) {
5622
+ target.parent.computed = true;
5623
+ }
5624
+ target.node.type = "CallExpression";
5625
+ target.node.callee = callExpr.callee;
5626
+ target.node.arguments = callExpr.arguments;
5627
+ target.node.optional = false;
5628
+ delete target.node.value;
5629
+ delete target.node.raw;
5630
+ delete target.node.quasis;
5631
+ delete target.node.expressions;
5632
+ }
5063
5633
  let insertIdx = findVaultInsertIndex(ast, activeDirectives);
5064
- const wantFragmented = Boolean(_optionalChain([config, 'optionalAccess', _353 => _353.vault, 'optionalAccess', _354 => _354.fragmented]));
5065
- let fragCount = Math.max(2, Math.min(8, Math.floor(_nullishCoalesce(_optionalChain([config, 'optionalAccess', _355 => _355.vault, 'optionalAccess', _356 => _356.fragmentCount]), () => ( 3)))));
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)))));
5066
5636
  while (fragCount > 2 && Math.floor(uniqueStrings.length / fragCount) < 4) {
5067
5637
  fragCount--;
5068
5638
  }
@@ -5076,28 +5646,28 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
5076
5646
  );
5077
5647
  }
5078
5648
  integrityToken = computeFnv1aHash(JSON.stringify(encryptedPayloads), seed);
5079
- for (const { type, node, parent, idx } of targetsToReplace) {
5080
- if (_optionalChain([parent, 'optionalAccess', _357 => _357.type]) === "Property" && parent.key === node) {
5081
- parent.computed = true;
5082
- }
5083
- if (type === "shader") {
5084
- node.type = "CallExpression";
5085
- node.callee = { type: "Identifier", name: shaderVarName };
5086
- node.arguments = [{ type: "Literal", value: idx, raw: String(idx) }];
5649
+ for (const target of targetsToReplace) {
5650
+ let callExpr;
5651
+ if (target.type === "shader") {
5652
+ callExpr = {
5653
+ type: "CallExpression",
5654
+ callee: { type: "Identifier", name: shaderVarName },
5655
+ arguments: [{ type: "Literal", value: target.idx, raw: String(target.idx) }],
5656
+ optional: false
5657
+ };
5087
5658
  } else {
5088
- const salt = computeCallSiteSalt(seed, idx);
5089
- node.type = "CallExpression";
5090
- node.callee = { type: "Identifier", name: decryptFnName };
5091
- node.arguments = [
5092
- { type: "Literal", value: idx, raw: String(idx) },
5093
- { type: "Literal", value: salt, raw: String(salt) }
5094
- ];
5095
- }
5096
- node.optional = false;
5097
- delete node.value;
5098
- delete node.raw;
5099
- delete node.quasis;
5100
- delete node.expressions;
5659
+ const salt = computeCallSiteSalt(seed, target.idx);
5660
+ callExpr = {
5661
+ type: "CallExpression",
5662
+ callee: { type: "Identifier", name: decryptFnName },
5663
+ arguments: [
5664
+ { type: "Literal", value: target.idx, raw: String(target.idx) },
5665
+ { type: "Literal", value: salt, raw: String(salt) }
5666
+ ],
5667
+ optional: false
5668
+ };
5669
+ }
5670
+ applyVaultTargetReplacement(target, callExpr);
5101
5671
  }
5102
5672
  } else {
5103
5673
  const perm = [];
@@ -5165,31 +5735,31 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
5165
5735
  chains: []
5166
5736
  });
5167
5737
  }
5168
- for (const { type, node, parent, idx, scopeChain } of targetsToReplace) {
5169
- if (_optionalChain([parent, 'optionalAccess', _358 => _358.type]) === "Property" && parent.key === node) {
5170
- parent.computed = true;
5171
- }
5172
- if (type === "shader") {
5173
- node.type = "CallExpression";
5174
- node.callee = { type: "Identifier", name: shaderVarName };
5175
- node.arguments = [{ type: "Literal", value: idx, raw: String(idx) }];
5738
+ for (const target of targetsToReplace) {
5739
+ let callExpr;
5740
+ if (target.type === "shader") {
5741
+ callExpr = {
5742
+ type: "CallExpression",
5743
+ callee: { type: "Identifier", name: shaderVarName },
5744
+ arguments: [{ type: "Literal", value: target.idx, raw: String(target.idx) }],
5745
+ optional: false
5746
+ };
5176
5747
  } else {
5177
- const { fragId, localIdx } = stringFragAssign[idx];
5748
+ const { fragId, localIdx } = stringFragAssign[target.idx];
5178
5749
  const meta = fragMeta[fragId];
5179
- meta.chains.push(scopeChain);
5750
+ meta.chains.push(target.scopeChain);
5180
5751
  const salt = computeCallSiteSalt(meta.fragSeed, localIdx);
5181
- node.type = "CallExpression";
5182
- node.callee = { type: "Identifier", name: meta.fnName };
5183
- node.arguments = [
5184
- { type: "Literal", value: localIdx, raw: String(localIdx) },
5185
- { type: "Literal", value: salt, raw: String(salt) }
5186
- ];
5187
- }
5188
- node.optional = false;
5189
- delete node.value;
5190
- delete node.raw;
5191
- delete node.quasis;
5192
- delete node.expressions;
5752
+ callExpr = {
5753
+ type: "CallExpression",
5754
+ callee: { type: "Identifier", name: meta.fnName },
5755
+ arguments: [
5756
+ { type: "Literal", value: localIdx, raw: String(localIdx) },
5757
+ { type: "Literal", value: salt, raw: String(salt) }
5758
+ ],
5759
+ optional: false
5760
+ };
5761
+ }
5762
+ applyVaultTargetReplacement(target, callExpr);
5193
5763
  }
5194
5764
  const allPayloads = [];
5195
5765
  for (const meta of fragMeta) {
@@ -5204,7 +5774,7 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
5204
5774
  ast.body.splice(insertIdx++, 0, helperStmt);
5205
5775
  } else {
5206
5776
  let blockInsertIdx = 0;
5207
- while (blockInsertIdx < lcaScope.body.length && _optionalChain([lcaScope, 'access', _359 => _359.body, 'access', _360 => _360[blockInsertIdx], 'optionalAccess', _361 => _361.type]) === "ExpressionStatement" && Boolean(_optionalChain([lcaScope, 'access', _362 => _362.body, 'access', _363 => _363[blockInsertIdx], 'optionalAccess', _364 => _364.directive]))) {
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]))) {
5208
5778
  blockInsertIdx++;
5209
5779
  }
5210
5780
  lcaScope.body.splice(blockInsertIdx, 0, helperStmt);
@@ -5212,9 +5782,10 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
5212
5782
  }
5213
5783
  integrityToken = computeFnv1aHash(JSON.stringify(allPayloads), seed);
5214
5784
  }
5785
+ rebuildInterpolatedTemplates(interpolatedTemplates);
5215
5786
  if (hotTargetsToReplace.length > 0) {
5216
5787
  const alreadyHasHx = ast.body.some(
5217
- (stmt) => stmt.type === "FunctionDeclaration" && _optionalChain([stmt, 'access', _365 => _365.id, 'optionalAccess', _366 => _366.name]) === "_hX"
5788
+ (stmt) => stmt.type === "FunctionDeclaration" && _optionalChain([stmt, 'access', _389 => _389.id, 'optionalAccess', _390 => _390.name]) === "_hX"
5218
5789
  );
5219
5790
  if (!alreadyHasHx) {
5220
5791
  const hxAst = acorn4.parse(
@@ -5405,8 +5976,8 @@ function collectPatternTargets(pattern, out, shorthandProp) {
5405
5976
  }
5406
5977
  }
5407
5978
  function isMangleableName(origName, reservedSet = RESERVED_IDENTIFIERS, manglerConfig) {
5408
- const minLength = _nullishCoalesce(_optionalChain([manglerConfig, 'optionalAccess', _367 => _367.minLength]), () => ( 1));
5409
- return origName.length >= minLength && !reservedSet.has(origName) && !JS_KEYWORDS.has(origName) && !origName.startsWith("$") && !origName.startsWith("__") && !origName.startsWith("_u") && !origName.startsWith("_0x") && (!_optionalChain([manglerConfig, 'optionalAccess', _368 => _368.excludePrefixes]) || !manglerConfig.excludePrefixes.some((p) => origName.startsWith(p))) && (!_optionalChain([manglerConfig, 'optionalAccess', _369 => _369.excludePatterns]) || !manglerConfig.excludePatterns.some(
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(
5410
5981
  (re) => (typeof re === "string" ? new RegExp(re) : re).test(origName)
5411
5982
  ));
5412
5983
  }
@@ -5426,12 +5997,12 @@ function shuffleAlphabet(chars, seed) {
5426
5997
  }
5427
5998
  function applyPolymorphicMangler(ast, seed = 2654435769, serializedFunctionNodes, config) {
5428
5999
  const activeReserved = new Set(RESERVED_IDENTIFIERS);
5429
- if (_optionalChain([config, 'optionalAccess', _370 => _370.mangler, 'optionalAccess', _371 => _371.reservedIdentifiers])) {
6000
+ if (_optionalChain([config, 'optionalAccess', _394 => _394.mangler, 'optionalAccess', _395 => _395.reservedIdentifiers])) {
5430
6001
  for (const id of config.mangler.reservedIdentifiers) {
5431
6002
  activeReserved.add(id);
5432
6003
  }
5433
6004
  }
5434
- const manglerConfig = _optionalChain([config, 'optionalAccess', _372 => _372.mangler]);
6005
+ const manglerConfig = _optionalChain([config, 'optionalAccess', _396 => _396.mangler]);
5435
6006
  const scopeRecords = /* @__PURE__ */ new Map();
5436
6007
  const barrierOrFreeIds = /* @__PURE__ */ new Set();
5437
6008
  const renamedTargetNodes = /* @__PURE__ */ new WeakSet();
@@ -5553,17 +6124,17 @@ function applyPolymorphicMangler(ast, seed = 2654435769, serializedFunctionNodes
5553
6124
  ensureScopeChain(ancestors);
5554
6125
  },
5555
6126
  ImportSpecifier(node) {
5556
- if (_optionalChain([node, 'access', _373 => _373.local, 'optionalAccess', _374 => _374.name])) barrierOrFreeIds.add(node.local.name);
6127
+ if (_optionalChain([node, 'access', _397 => _397.local, 'optionalAccess', _398 => _398.name])) barrierOrFreeIds.add(node.local.name);
5557
6128
  },
5558
6129
  ImportDefaultSpecifier(node) {
5559
- if (_optionalChain([node, 'access', _375 => _375.local, 'optionalAccess', _376 => _376.name])) barrierOrFreeIds.add(node.local.name);
6130
+ if (_optionalChain([node, 'access', _399 => _399.local, 'optionalAccess', _400 => _400.name])) barrierOrFreeIds.add(node.local.name);
5560
6131
  },
5561
6132
  ImportNamespaceSpecifier(node) {
5562
- if (_optionalChain([node, 'access', _377 => _377.local, 'optionalAccess', _378 => _378.name])) barrierOrFreeIds.add(node.local.name);
6133
+ if (_optionalChain([node, 'access', _401 => _401.local, 'optionalAccess', _402 => _402.name])) barrierOrFreeIds.add(node.local.name);
5563
6134
  },
5564
6135
  FunctionDeclaration(node, _state, ancestors) {
5565
6136
  registerFunctionParams(node, ancestors);
5566
- if (_optionalChain([node, 'access', _379 => _379.id, 'optionalAccess', _380 => _380.type]) === "Identifier") {
6137
+ if (_optionalChain([node, 'access', _403 => _403.id, 'optionalAccess', _404 => _404.type]) === "Identifier") {
5567
6138
  const parentAncestors = ancestors.slice(0, -1);
5568
6139
  const lexNode = findEnclosingLexicalNode(parentAncestors);
5569
6140
  const fnNode = _nullishCoalesce(findEnclosingFunctionNode(parentAncestors), () => ( ast));
@@ -5571,15 +6142,15 @@ function applyPolymorphicMangler(ast, seed = 2654435769, serializedFunctionNodes
5571
6142
  if (lexNode === fnNode.body || fnNode === ast) {
5572
6143
  registerBarrierName(fnNode, node.id.name);
5573
6144
  }
5574
- if (!_optionalChain([scopeRecords, 'access', _381 => _381.get, 'call', _382 => _382(node), 'optionalAccess', _383 => _383.bindings, 'access', _384 => _384.has, 'call', _385 => _385(node.id.name)])) {
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)])) {
5575
6146
  registerBarrierName(node, node.id.name);
5576
6147
  }
5577
6148
  }
5578
6149
  },
5579
6150
  FunctionExpression(node, _state, ancestors) {
5580
6151
  registerFunctionParams(node, ancestors);
5581
- if (_optionalChain([node, 'access', _386 => _386.id, 'optionalAccess', _387 => _387.type]) === "Identifier") {
5582
- if (!_optionalChain([scopeRecords, 'access', _388 => _388.get, 'call', _389 => _389(node), 'optionalAccess', _390 => _390.bindings, 'access', _391 => _391.has, 'call', _392 => _392(node.id.name)])) {
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)])) {
5583
6154
  registerBarrierName(node, node.id.name);
5584
6155
  }
5585
6156
  }
@@ -5589,7 +6160,7 @@ function applyPolymorphicMangler(ast, seed = 2654435769, serializedFunctionNodes
5589
6160
  },
5590
6161
  ClassDeclaration(node, _state, ancestors) {
5591
6162
  ensureScopeChain(ancestors);
5592
- if (_optionalChain([node, 'access', _393 => _393.id, 'optionalAccess', _394 => _394.type]) === "Identifier") {
6163
+ if (_optionalChain([node, 'access', _417 => _417.id, 'optionalAccess', _418 => _418.type]) === "Identifier") {
5593
6164
  const parentAncestors = ancestors.slice(0, -1);
5594
6165
  const lexNode = findEnclosingLexicalNode(parentAncestors);
5595
6166
  registerBarrierName(lexNode, node.id.name);
@@ -5598,7 +6169,7 @@ function applyPolymorphicMangler(ast, seed = 2654435769, serializedFunctionNodes
5598
6169
  },
5599
6170
  ClassExpression(node, _state, ancestors) {
5600
6171
  ensureScopeChain(ancestors);
5601
- if (_optionalChain([node, 'access', _395 => _395.id, 'optionalAccess', _396 => _396.type]) === "Identifier") {
6172
+ if (_optionalChain([node, 'access', _419 => _419.id, 'optionalAccess', _420 => _420.type]) === "Identifier") {
5602
6173
  registerBarrierName(node, node.id.name);
5603
6174
  }
5604
6175
  },
@@ -5637,7 +6208,7 @@ function applyPolymorphicMangler(ast, seed = 2654435769, serializedFunctionNodes
5637
6208
  if (ancestors[i] === fnScope) break;
5638
6209
  if (ancestors[i].type === "CatchClause") {
5639
6210
  const catchScope = scopeRecords.get(ancestors[i]);
5640
- if (_optionalChain([catchScope, 'optionalAccess', _397 => _397.bindings, 'access', _398 => _398.has, 'call', _399 => _399(origName)])) {
6211
+ if (_optionalChain([catchScope, 'optionalAccess', _421 => _421.bindings, 'access', _422 => _422.has, 'call', _423 => _423(origName)])) {
5641
6212
  registerBarrierName(ancestors[i], origName);
5642
6213
  registerBarrierName(fnScope, origName);
5643
6214
  }
@@ -5838,6 +6409,26 @@ function mixSeed32(seed, salt) {
5838
6409
  h ^= h >>> 16;
5839
6410
  return h | 0;
5840
6411
  }
6412
+ function modInverseUint32(oddValue) {
6413
+ const m = (oddValue | 1) >>> 0;
6414
+ let inv = 1;
6415
+ for (let i = 0; i < 5; i++) {
6416
+ inv = Math.imul(inv, 2 - Math.imul(m, inv) | 0) >>> 0;
6417
+ }
6418
+ return inv >>> 0;
6419
+ }
6420
+ function deriveAffineMbaParams(seed, salt) {
6421
+ let m = (mixSeed32(seed, salt) | 1) >>> 0;
6422
+ if (m === 1 || m === 4294967295 || m === 2654435769) {
6423
+ m = (m ^ 1540483477 | 1) >>> 0;
6424
+ }
6425
+ const m2 = Math.imul(m, 2) >>> 0;
6426
+ const mInv = modInverseUint32(m);
6427
+ let c = mixSeed32(seed, salt + 40503) >>> 0;
6428
+ if (c === 0) c = 668265263;
6429
+ const d = -Math.imul(mInv, c) >>> 0;
6430
+ return { m, m2, mInv, c, d };
6431
+ }
5841
6432
  function cloneNode(node) {
5842
6433
  return JSON.parse(JSON.stringify(node));
5843
6434
  }
@@ -6300,14 +6891,14 @@ function makeSafeNumericParam(name) {
6300
6891
  function buildLiveVariables4(seed, fnIndex, paramNode, isArrowFn = false, ctxOpts) {
6301
6892
  const candidates = [];
6302
6893
  const seenNames = /* @__PURE__ */ new Set();
6303
- const names = [..._nullishCoalesce(_optionalChain([ctxOpts, 'optionalAccess', _400 => _400.liveVars]), () => ( [])), ...extractParamNames(paramNode)];
6894
+ const names = [..._nullishCoalesce(_optionalChain([ctxOpts, 'optionalAccess', _424 => _424.liveVars]), () => ( [])), ...extractParamNames(paramNode)];
6304
6895
  for (const name of names) {
6305
6896
  if (name && name !== "arguments" && name !== "eval" && !seenNames.has(name)) {
6306
6897
  seenNames.add(name);
6307
6898
  candidates.push(makeSafeNumericParam(name));
6308
6899
  }
6309
6900
  }
6310
- if (_optionalChain([ctxOpts, 'optionalAccess', _401 => _401.aliasIdentA]) && _optionalChain([ctxOpts, 'optionalAccess', _402 => _402.aliasIdentB])) {
6901
+ if (_optionalChain([ctxOpts, 'optionalAccess', _425 => _425.aliasIdentA]) && _optionalChain([ctxOpts, 'optionalAccess', _426 => _426.aliasIdentB])) {
6311
6902
  const slot0 = fnIndex + 0 & 3;
6312
6903
  const slot1 = fnIndex + 1 & 3;
6313
6904
  candidates.push(makeBinary("|", makeMemberIndex(ctxOpts.aliasIdentA, makeLiteral(slot0)), makeLiteral(0)));
@@ -6399,22 +6990,22 @@ function buildQnrBitExpr(qnrValRef, bitKind) {
6399
6990
  );
6400
6991
  }
6401
6992
  function createSotaMbaPredicate(seed, fnIndex = 0, paramNode, decoyIdent, isArrowFn = false, ctxOpts) {
6402
- const domain = _nullishCoalesce(_optionalChain([ctxOpts, 'optionalAccess', _403 => _403.returnDomain]), () => ( "object"));
6993
+ const domain = _nullishCoalesce(_optionalChain([ctxOpts, 'optionalAccess', _427 => _427.returnDomain]), () => ( "object"));
6403
6994
  const [x1, x2, x3, x4] = buildLiveVariables4(seed, fnIndex, paramNode, isArrowFn, ctxOpts);
6404
6995
  const mba4 = buildMba4Ast(seed, fnIndex, x1, x2, x3, x4);
6405
6996
  const qnrFamilyIdx = ((seed ^ Math.imul(fnIndex + 1, 2654435761)) >>> 0) % QNR_RESIDUE_FAMILIES.length;
6406
6997
  const qnrFamily = QNR_RESIDUE_FAMILIES[qnrFamilyIdx];
6407
6998
  const slotA = fnIndex + (seed & 3) & 3;
6408
6999
  const slotB = slotA + 1 + (seed >>> 2 & 1) & 3;
6409
- const hasAlias = Boolean(_optionalChain([ctxOpts, 'optionalAccess', _404 => _404.aliasIdentA]));
6410
- const aliasReadIdent = _nullishCoalesce(_nullishCoalesce(_optionalChain([ctxOpts, 'optionalAccess', _405 => _405.aliasIdentB]), () => ( _optionalChain([ctxOpts, 'optionalAccess', _406 => _406.aliasIdentA]))), () => ( ""));
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]))), () => ( ""));
6411
7002
  let qnrLeft;
6412
7003
  let qnrValForForm0;
6413
7004
  let zRefForDecoy;
6414
7005
  let aliasInvZero = null;
6415
- if (_optionalChain([ctxOpts, 'optionalAccess', _407 => _407.mxIdent]) && _optionalChain([ctxOpts, 'optionalAccess', _408 => _408.scratchVarIdent]) && hasAlias) {
7006
+ if (_optionalChain([ctxOpts, 'optionalAccess', _431 => _431.mxIdent]) && _optionalChain([ctxOpts, 'optionalAccess', _432 => _432.scratchVarIdent]) && hasAlias) {
6416
7007
  const scratchId = { type: "Identifier", name: ctxOpts.scratchVarIdent };
6417
- const names = [..._nullishCoalesce(_optionalChain([ctxOpts, 'optionalAccess', _409 => _409.liveVars]), () => ( [])), ...extractParamNames(paramNode)];
7008
+ const names = [..._nullishCoalesce(_optionalChain([ctxOpts, 'optionalAccess', _433 => _433.liveVars]), () => ( [])), ...extractParamNames(paramNode)];
6418
7009
  const uniqueNames = [];
6419
7010
  for (const n of names) {
6420
7011
  if (n && n !== "arguments" && n !== "eval" && !uniqueNames.includes(n)) {
@@ -6495,7 +7086,7 @@ function createSotaMbaPredicate(seed, fnIndex = 0, paramNode, decoyIdent, isArro
6495
7086
  ]
6496
7087
  };
6497
7088
  zRefForDecoy = cloneNode(scratchId);
6498
- } else if (_optionalChain([ctxOpts, 'optionalAccess', _410 => _410.scratchVarIdent])) {
7089
+ } else if (_optionalChain([ctxOpts, 'optionalAccess', _434 => _434.scratchVarIdent])) {
6499
7090
  const scratchId = { type: "Identifier", name: ctxOpts.scratchVarIdent };
6500
7091
  const rivestOnScratch = buildRivestPermAst(seed, fnIndex, scratchId);
6501
7092
  const seqExprs = [
@@ -6585,8 +7176,9 @@ function createSotaMbaPredicate(seed, fnIndex = 0, paramNode, decoyIdent, isArro
6585
7176
  decoyIdent,
6586
7177
  zRefForDecoy
6587
7178
  );
6588
- const hasShieldCoupling = Boolean(_optionalChain([ctxOpts, 'optionalAccess', _411 => _411.shieldCoupled]) && _optionalChain([ctxOpts, 'optionalAccess', _412 => _412.windowKeySymbol]));
6589
- const predForm = fnIndex + (hasShieldCoupling ? 1 : seed >>> 2 & 3) & 3;
7179
+ const hasShieldCoupling = Boolean(_optionalChain([ctxOpts, 'optionalAccess', _435 => _435.shieldCoupled]) && _optionalChain([ctxOpts, 'optionalAccess', _436 => _436.windowKeySymbol]));
7180
+ const predOffset = hasShieldCoupling ? 1 : (seed >>> 2) % 6;
7181
+ const predForm = ((fnIndex + predOffset) % 6 + 6) % 6;
6590
7182
  let testExpr;
6591
7183
  if (predForm === 0) {
6592
7184
  let pathACore = qnrValForForm0;
@@ -6600,7 +7192,7 @@ function createSotaMbaPredicate(seed, fnIndex = 0, paramNode, decoyIdent, isArro
6600
7192
  makeBinary("&", makeMemberIndex(aliasReadIdent, makeLiteral(slotB)), makeLiteral(1))
6601
7193
  );
6602
7194
  }
6603
- const pathA = _optionalChain([ctxOpts, 'optionalAccess', _413 => _413.scratchVarIdent]) ? {
7195
+ const pathA = _optionalChain([ctxOpts, 'optionalAccess', _437 => _437.scratchVarIdent]) ? {
6604
7196
  type: "SequenceExpression",
6605
7197
  expressions: [...qnrLeft.expressions.slice(0, -1), pathACore]
6606
7198
  } : pathACore;
@@ -6662,13 +7254,84 @@ function createSotaMbaPredicate(seed, fnIndex = 0, paramNode, decoyIdent, isArro
6662
7254
  }
6663
7255
  const rhsExpr = makeBinary("+", makeLiteral(qnrFamily.outBoundVal), slotWriteB);
6664
7256
  testExpr = makeBinary(qnrFamily.outBoundOp, lhsExpr, rhsExpr);
6665
- } else {
7257
+ } else if (predForm === 3) {
6666
7258
  const tagLhs = hasAlias ? makeBinary("&", makeMemberIndex(ctxOpts.aliasIdentA, makeLiteral(slotB)), makeLiteral(240)) : makeBinary("&", makeBinary("<<", makeTypeofGlobalLen(), makeLiteral(4)), makeLiteral(240));
6667
7259
  const tagRhsBase = hasAlias ? makeBinary("&", makeMemberIndex(aliasReadIdent, makeLiteral(slotB)), makeLiteral(240)) : makeBinary("&", makeBinary("<<", makeTypeofGlobalLen(), makeLiteral(4)), makeLiteral(240));
6668
7260
  const tagRhs = aliasInvZero ? makeBinary("^", tagRhsBase, makeBinary("&", aliasInvZero, makeLiteral(15))) : tagRhsBase;
6669
7261
  const lhsExpr = makeBinary("|", makeBinary("^", qnrLeft, tagLhs), makeLiteral(0));
6670
7262
  const rhsExpr = makeBinary("|", makeBinary("^", makeLiteral(qnrFamily.target), tagRhs), makeLiteral(0));
6671
7263
  testExpr = makeBinary("===", lhsExpr, rhsExpr);
7264
+ } else if (predForm === 4) {
7265
+ const k4 = mixSeed32(seed, fnIndex * 29 + 13) >>> 0 || 1;
7266
+ if (_optionalChain([ctxOpts, 'optionalAccess', _438 => _438.scratchVarIdent])) {
7267
+ const scratchId = { type: "Identifier", name: ctxOpts.scratchVarIdent };
7268
+ const preU = aliasInvZero ? makeBinary("^", cloneNode(scratchId), aliasInvZero) : cloneNode(scratchId);
7269
+ const uAssign = {
7270
+ type: "AssignmentExpression",
7271
+ operator: "=",
7272
+ left: cloneNode(scratchId),
7273
+ right: makeBinary(">>>", makeBinary("^", preU, makeLiteral(k4)), makeLiteral(0))
7274
+ };
7275
+ const uMinus1Lhs = makeBinary(">>>", makeBinary("-", cloneNode(scratchId), makeLiteral(1)), makeLiteral(0));
7276
+ const uMinus1Rhs = makeBinary(">>>", makeBinary("-", cloneNode(scratchId), makeLiteral(1)), makeLiteral(0));
7277
+ const orU = makeBinary(">>>", makeBinary("|", cloneNode(scratchId), uMinus1Lhs), makeLiteral(0));
7278
+ const xorU = makeBinary(">>>", makeBinary("^", cloneNode(scratchId), uMinus1Rhs), makeLiteral(0));
7279
+ const lhsSeq = {
7280
+ type: "SequenceExpression",
7281
+ expressions: [...qnrLeft.expressions.slice(0, -1), uAssign, orU]
7282
+ };
7283
+ testExpr = makeBinary("<", lhsSeq, xorU);
7284
+ } else {
7285
+ const uExpr = makeBinary(">>>", makeBinary("^", cloneNode(zRefForDecoy), makeLiteral(k4)), makeLiteral(0));
7286
+ const uMinus1Lhs = makeBinary(">>>", makeBinary("-", cloneNode(uExpr), makeLiteral(1)), makeLiteral(0));
7287
+ const uMinus1Rhs = makeBinary(">>>", makeBinary("-", cloneNode(uExpr), makeLiteral(1)), makeLiteral(0));
7288
+ const orU = makeBinary(">>>", makeBinary("|", cloneNode(uExpr), uMinus1Lhs), makeLiteral(0));
7289
+ const xorU = makeBinary(">>>", makeBinary("^", cloneNode(uExpr), uMinus1Rhs), makeLiteral(0));
7290
+ testExpr = makeBinary("<", orU, xorU);
7291
+ }
7292
+ } else {
7293
+ const k5 = mixSeed32(seed, fnIndex * 31 + 17) >>> 0 || 3;
7294
+ const { m, m2, mInv, c, d } = deriveAffineMbaParams(seed, fnIndex * 37 + 23);
7295
+ const buildAffineLhs = (valNode) => {
7296
+ const inner = makeBinary(
7297
+ "|",
7298
+ makeBinary(
7299
+ "+",
7300
+ makeBinary(
7301
+ "+",
7302
+ makeImul(makeLiteral(m), makeBinary("^", cloneNode(valNode), makeLiteral(k5))),
7303
+ makeImul(makeLiteral(m2), makeBinary("&", cloneNode(valNode), makeLiteral(k5)))
7304
+ ),
7305
+ makeLiteral(c)
7306
+ ),
7307
+ makeLiteral(0)
7308
+ );
7309
+ return makeBinary(
7310
+ "|",
7311
+ makeBinary("+", makeImul(makeLiteral(mInv), inner), makeLiteral(d)),
7312
+ makeLiteral(0)
7313
+ );
7314
+ };
7315
+ const buildAffineRhs = (valNode) => makeBinary("|", makeBinary("+", cloneNode(valNode), makeLiteral(k5)), makeLiteral(0));
7316
+ if (_optionalChain([ctxOpts, 'optionalAccess', _439 => _439.scratchVarIdent])) {
7317
+ const scratchId = { type: "Identifier", name: ctxOpts.scratchVarIdent };
7318
+ const preSeqs = [...qnrLeft.expressions.slice(0, -1)];
7319
+ if (aliasInvZero) {
7320
+ preSeqs.push({
7321
+ type: "AssignmentExpression",
7322
+ operator: "=",
7323
+ left: cloneNode(scratchId),
7324
+ right: makeBinary("|", makeBinary("^", cloneNode(scratchId), aliasInvZero), makeLiteral(0))
7325
+ });
7326
+ }
7327
+ const lhsSeq = {
7328
+ type: "SequenceExpression",
7329
+ expressions: [...preSeqs, buildAffineLhs(scratchId)]
7330
+ };
7331
+ testExpr = makeBinary("!==", lhsSeq, buildAffineRhs(scratchId));
7332
+ } else {
7333
+ testExpr = makeBinary("!==", buildAffineLhs(zRefForDecoy), buildAffineRhs(zRefForDecoy));
7334
+ }
6672
7335
  }
6673
7336
  return {
6674
7337
  type: "IfStatement",
@@ -6724,7 +7387,7 @@ function inferFunctionReturnDomain(fnNode) {
6724
7387
  }
6725
7388
  }
6726
7389
  scanStmts(fnNode.body);
6727
- if (!hasReturnArg && _optionalChain([fnNode, 'access', _414 => _414.body, 'optionalAccess', _415 => _415.type]) === "BlockStatement") return "void";
7390
+ if (!hasReturnArg && _optionalChain([fnNode, 'access', _440 => _440.body, 'optionalAccess', _441 => _441.type]) === "BlockStatement") return "void";
6728
7391
  if (seenObject) return "object";
6729
7392
  if (seenBoolean && !seenNumber && !seenString) return "boolean";
6730
7393
  if (seenNumber && !seenBoolean && !seenString) return "number";
@@ -6913,7 +7576,362 @@ function createSboxAndAliasDeclarations(sboxIdent, aliasIdentA, aliasIdentB, scr
6913
7576
  };
6914
7577
  }
6915
7578
  var MAX_COLD_GUARDS_PER_CHUNK = 12;
6916
- function applyColdFlowGuard(ast, coldFunctionNodes, seed = 2654435769, hotExemptNodes, windowKeySymbol, expectedDelta, shieldCoupled = false) {
7579
+ var MAX_COLD_BITWISE_MBA_PER_CHUNK = 8;
7580
+ var BITWISE_MBA_OPS = /* @__PURE__ */ new Set(["^", "|", "&"]);
7581
+ var BITWISE_LOOP_NODE_TYPES = /* @__PURE__ */ new Set([
7582
+ "ForStatement",
7583
+ "WhileStatement",
7584
+ "DoWhileStatement",
7585
+ "ForInStatement",
7586
+ "ForOfStatement"
7587
+ ]);
7588
+ var BITWISE_FUNCTION_TYPES = /* @__PURE__ */ new Set([
7589
+ "FunctionDeclaration",
7590
+ "FunctionExpression",
7591
+ "ArrowFunctionExpression"
7592
+ ]);
7593
+ var BITWISE_LEXICAL_SCOPE_TYPES = /* @__PURE__ */ new Set([
7594
+ "Program",
7595
+ "FunctionDeclaration",
7596
+ "FunctionExpression",
7597
+ "ArrowFunctionExpression",
7598
+ "BlockStatement",
7599
+ "ForStatement",
7600
+ "ForInStatement",
7601
+ "ForOfStatement",
7602
+ "SwitchStatement",
7603
+ "CatchClause",
7604
+ "StaticBlock"
7605
+ ]);
7606
+ var FORBIDDEN_BITWISE_IDENTIFIERS = /* @__PURE__ */ new Set([
7607
+ "arguments",
7608
+ "eval",
7609
+ "undefined",
7610
+ "NaN",
7611
+ "Infinity",
7612
+ "globalThis",
7613
+ "window",
7614
+ "self",
7615
+ "Math",
7616
+ "BigInt"
7617
+ ]);
7618
+ function collectBoundPatternNames(pattern, out) {
7619
+ if (!pattern || typeof pattern !== "object") return;
7620
+ switch (pattern.type) {
7621
+ case "Identifier":
7622
+ out.push(pattern.name);
7623
+ break;
7624
+ case "AssignmentPattern":
7625
+ collectBoundPatternNames(pattern.left, out);
7626
+ break;
7627
+ case "RestElement":
7628
+ collectBoundPatternNames(pattern.argument, out);
7629
+ break;
7630
+ case "ArrayPattern":
7631
+ for (const el of pattern.elements || []) {
7632
+ if (el) collectBoundPatternNames(el, out);
7633
+ }
7634
+ break;
7635
+ case "ObjectPattern":
7636
+ for (const prop of pattern.properties || []) {
7637
+ if (prop.type === "Property") {
7638
+ collectBoundPatternNames(prop.value, out);
7639
+ } else if (prop.type === "RestElement") {
7640
+ collectBoundPatternNames(prop.argument, out);
7641
+ }
7642
+ }
7643
+ break;
7644
+ }
7645
+ }
7646
+ function analyzeBitwiseMbaScopes(ast) {
7647
+ const scopeBindings = /* @__PURE__ */ new Map();
7648
+ let unsafe = false;
7649
+ const addBinding = (scopeNode, name) => {
7650
+ if (name === "Math") {
7651
+ unsafe = true;
7652
+ return;
7653
+ }
7654
+ let set = scopeBindings.get(scopeNode);
7655
+ if (!set) {
7656
+ set = /* @__PURE__ */ new Set();
7657
+ scopeBindings.set(scopeNode, set);
7658
+ }
7659
+ set.add(name);
7660
+ };
7661
+ const scopeStack = [];
7662
+ const varTargetStack = [];
7663
+ const getNearestLexicalScope = () => _nullishCoalesce(scopeStack[scopeStack.length - 1], () => ( ast));
7664
+ const getNearestVarScope = () => _nullishCoalesce(varTargetStack[varTargetStack.length - 1], () => ( ast));
7665
+ function scan(node) {
7666
+ if (unsafe || !node || typeof node !== "object" || typeof node.type !== "string") {
7667
+ return;
7668
+ }
7669
+ if (node.type === "WithStatement") {
7670
+ unsafe = true;
7671
+ return;
7672
+ }
7673
+ if (node.type === "Literal" && (typeof node.value === "bigint" || typeof node.bigint === "string") || node.type === "BigIntLiteral") {
7674
+ unsafe = true;
7675
+ return;
7676
+ }
7677
+ if (node.type === "Identifier" && node.name === "BigInt") {
7678
+ unsafe = true;
7679
+ return;
7680
+ }
7681
+ if (node.type === "ImportSpecifier" || node.type === "ImportDefaultSpecifier" || node.type === "ImportNamespaceSpecifier") {
7682
+ if (_optionalChain([node, 'access', _442 => _442.local, 'optionalAccess', _443 => _443.type]) === "Identifier") {
7683
+ addBinding(ast, node.local.name);
7684
+ }
7685
+ } else if (node.type === "FunctionDeclaration") {
7686
+ if (_optionalChain([node, 'access', _444 => _444.id, 'optionalAccess', _445 => _445.type]) === "Identifier") {
7687
+ addBinding(getNearestLexicalScope(), node.id.name);
7688
+ addBinding(getNearestVarScope(), node.id.name);
7689
+ }
7690
+ } else if (node.type === "ClassDeclaration") {
7691
+ if (_optionalChain([node, 'access', _446 => _446.id, 'optionalAccess', _447 => _447.type]) === "Identifier") {
7692
+ addBinding(getNearestLexicalScope(), node.id.name);
7693
+ }
7694
+ } else if (node.type === "VariableDeclaration") {
7695
+ const targetScope = node.kind === "var" ? getNearestVarScope() : getNearestLexicalScope();
7696
+ for (const decl of node.declarations || []) {
7697
+ const names = [];
7698
+ collectBoundPatternNames(decl.id, names);
7699
+ for (const name of names) {
7700
+ addBinding(targetScope, name);
7701
+ }
7702
+ }
7703
+ }
7704
+ if (unsafe) return;
7705
+ const pushesLexical = BITWISE_LEXICAL_SCOPE_TYPES.has(node.type);
7706
+ const isFn = BITWISE_FUNCTION_TYPES.has(node.type);
7707
+ const isStaticBlock = node.type === "StaticBlock";
7708
+ if (pushesLexical) {
7709
+ scopeStack.push(node);
7710
+ if (!scopeBindings.has(node)) {
7711
+ scopeBindings.set(node, /* @__PURE__ */ new Set());
7712
+ }
7713
+ }
7714
+ if (isFn) {
7715
+ if (_optionalChain([node, 'access', _448 => _448.id, 'optionalAccess', _449 => _449.type]) === "Identifier") {
7716
+ addBinding(node, node.id.name);
7717
+ }
7718
+ for (const param of node.params || []) {
7719
+ const names = [];
7720
+ collectBoundPatternNames(param, names);
7721
+ for (const name of names) {
7722
+ addBinding(node, name);
7723
+ }
7724
+ }
7725
+ const bodyScope = _optionalChain([node, 'access', _450 => _450.body, 'optionalAccess', _451 => _451.type]) === "BlockStatement" ? node.body : node;
7726
+ varTargetStack.push(bodyScope);
7727
+ } else if (node.type === "Program" || isStaticBlock) {
7728
+ varTargetStack.push(node);
7729
+ } else if (node.type === "CatchClause" && node.param) {
7730
+ const names = [];
7731
+ collectBoundPatternNames(node.param, names);
7732
+ for (const name of names) {
7733
+ addBinding(node, name);
7734
+ }
7735
+ } else if (node.type === "ClassExpression" && _optionalChain([node, 'access', _452 => _452.id, 'optionalAccess', _453 => _453.type]) === "Identifier") {
7736
+ addBinding(node, node.id.name);
7737
+ }
7738
+ try {
7739
+ for (const key of Object.keys(node)) {
7740
+ if (key === "loc" || key === "range" || key === "start" || key === "end" || key === "comments" || key === "tokens") {
7741
+ continue;
7742
+ }
7743
+ const child = node[key];
7744
+ if (Array.isArray(child)) {
7745
+ for (const item of child) {
7746
+ scan(item);
7747
+ if (unsafe) return;
7748
+ }
7749
+ } else if (child && typeof child === "object") {
7750
+ scan(child);
7751
+ if (unsafe) return;
7752
+ }
7753
+ }
7754
+ } finally {
7755
+ if (isFn || node.type === "Program" || isStaticBlock) {
7756
+ varTargetStack.pop();
7757
+ }
7758
+ if (pushesLexical) {
7759
+ scopeStack.pop();
7760
+ }
7761
+ }
7762
+ }
7763
+ scan(ast);
7764
+ return { unsafe, scopeBindings };
7765
+ }
7766
+ function isSafeAtomicIntegerLiteral(node) {
7767
+ return Boolean(
7768
+ node && node.type === "Literal" && typeof node.value === "number" && Number.isInteger(node.value) && node.value >= 0 && node.value <= 4294967295
7769
+ );
7770
+ }
7771
+ function isZeroNumericLiteral(node) {
7772
+ return Boolean(node && node.type === "Literal" && typeof node.value === "number" && node.value === 0);
7773
+ }
7774
+ function isLocalBoundIdentifier(node, scopeStack, scopeBindings, programNode) {
7775
+ if (!node || node.type !== "Identifier") return false;
7776
+ if (FORBIDDEN_BITWISE_IDENTIFIERS.has(node.name)) return false;
7777
+ for (let i = scopeStack.length - 1; i >= 0; i--) {
7778
+ const scopeNode = scopeStack[i];
7779
+ if (scopeNode === programNode) return false;
7780
+ const bindings = scopeBindings.get(scopeNode);
7781
+ if (bindings && bindings.has(node.name)) {
7782
+ return true;
7783
+ }
7784
+ }
7785
+ return false;
7786
+ }
7787
+ function buildColdBitwiseConditional(op, left, right, seed, subIndex, hotExemptNodes) {
7788
+ const { m, mInv, c, d } = deriveAffineMbaParams(seed, 16640 + subIndex * 43);
7789
+ const a1 = cloneNode(left);
7790
+ const b1 = cloneNode(right);
7791
+ const a2 = cloneNode(left);
7792
+ const b2 = cloneNode(right);
7793
+ let affineComb;
7794
+ if (op === "^") {
7795
+ affineComb = makeBinary(
7796
+ "-",
7797
+ makeImul(makeLiteral(m), makeBinary("|", a1, b1)),
7798
+ makeImul(makeLiteral(m), makeBinary("&", a2, b2))
7799
+ );
7800
+ } else if (op === "|") {
7801
+ affineComb = makeBinary(
7802
+ "+",
7803
+ makeImul(makeLiteral(m), makeBinary("&", a1, b1)),
7804
+ makeImul(makeLiteral(m), makeBinary("^", a2, b2))
7805
+ );
7806
+ } else {
7807
+ affineComb = makeBinary(
7808
+ "-",
7809
+ makeImul(makeLiteral(m), makeBinary("|", a1, b1)),
7810
+ makeImul(makeLiteral(m), makeBinary("^", a2, b2))
7811
+ );
7812
+ }
7813
+ const innerWithC = makeBinary("|", makeBinary("+", affineComb, makeLiteral(c)), makeLiteral(0));
7814
+ const consequent = makeBinary(
7815
+ "|",
7816
+ makeBinary("+", makeImul(makeLiteral(mInv), innerWithC), makeLiteral(d)),
7817
+ makeLiteral(0)
7818
+ );
7819
+ const alternate = makeBinary(op, cloneNode(left), cloneNode(right));
7820
+ const exemptNodes = [];
7821
+ const uniqueIdents = [];
7822
+ const seenNames = /* @__PURE__ */ new Set();
7823
+ for (const operand of [left, right]) {
7824
+ if (_optionalChain([operand, 'optionalAccess', _454 => _454.type]) === "Identifier" && !seenNames.has(operand.name)) {
7825
+ seenNames.add(operand.name);
7826
+ uniqueIdents.push(operand);
7827
+ }
7828
+ }
7829
+ const makeIsNumberExpr = (ident) => {
7830
+ const numLit = makeLiteral("number");
7831
+ const eqNode = makeBinary("===", makeUnary("typeof", { type: "Identifier", name: ident.name }), numLit);
7832
+ exemptNodes.push(numLit, eqNode);
7833
+ return eqNode;
7834
+ };
7835
+ const testExpr = uniqueIdents.length === 2 ? {
7836
+ type: "LogicalExpression",
7837
+ operator: "&&",
7838
+ left: makeIsNumberExpr(uniqueIdents[0]),
7839
+ right: makeIsNumberExpr(uniqueIdents[1])
7840
+ } : makeIsNumberExpr(uniqueIdents[0]);
7841
+ const replacement = {
7842
+ type: "ConditionalExpression",
7843
+ test: testExpr,
7844
+ consequent,
7845
+ alternate,
7846
+ _unpeekGuardSubtree: true
7847
+ };
7848
+ if (hotExemptNodes) {
7849
+ hotExemptNodes.add(replacement);
7850
+ hotExemptNodes.add(testExpr);
7851
+ for (const nodeToExempt of exemptNodes) {
7852
+ hotExemptNodes.add(nodeToExempt);
7853
+ }
7854
+ }
7855
+ return replacement;
7856
+ }
7857
+ function applyColdBitwiseMba(ast, coldFunctionNodes, seed = 2654435769, hotExemptNodes, guardSubtreeNodes) {
7858
+ const { unsafe, scopeBindings } = analyzeBitwiseMbaScopes(ast);
7859
+ if (unsafe) return 0;
7860
+ let mbaCount = 0;
7861
+ const scopeStack = [];
7862
+ function walkTransform(node, setInParent, inColdFn) {
7863
+ if (mbaCount >= MAX_COLD_BITWISE_MBA_PER_CHUNK) return;
7864
+ 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;
7866
+ if (node._unpeekGuardSubtree === true) return;
7867
+ if (node._unpeekSerialized || node._unpeekVirtualized === true) return;
7868
+ if (BITWISE_LOOP_NODE_TYPES.has(node.type)) return;
7869
+ const pushedScope = scopeBindings.has(node);
7870
+ if (pushedScope) scopeStack.push(node);
7871
+ try {
7872
+ const childInColdFn = BITWISE_FUNCTION_TYPES.has(node.type) ? coldFunctionNodes.has(node) : inColdFn;
7873
+ if (childInColdFn && node.type === "BinaryExpression" && BITWISE_MBA_OPS.has(node.operator)) {
7874
+ const op = node.operator;
7875
+ const { left, right } = node;
7876
+ const isCoercionOrZero = op === "|" && isZeroNumericLiteral(right);
7877
+ if (!isCoercionOrZero) {
7878
+ const leftAtomic = isSafeAtomicIntegerLiteral(left) || isLocalBoundIdentifier(left, scopeStack, scopeBindings, ast);
7879
+ 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";
7881
+ if (leftAtomic && rightAtomic && hasIdent) {
7882
+ const replacement = buildColdBitwiseConditional(
7883
+ op,
7884
+ left,
7885
+ right,
7886
+ seed,
7887
+ mbaCount,
7888
+ hotExemptNodes
7889
+ );
7890
+ mbaCount++;
7891
+ setInParent(replacement);
7892
+ return;
7893
+ }
7894
+ }
7895
+ }
7896
+ for (const key of Object.keys(node)) {
7897
+ if (mbaCount >= MAX_COLD_BITWISE_MBA_PER_CHUNK) break;
7898
+ if (key === "loc" || key === "range" || key === "start" || key === "end" || key === "comments" || key === "tokens") {
7899
+ continue;
7900
+ }
7901
+ const child = node[key];
7902
+ if (Array.isArray(child)) {
7903
+ for (let i = 0; i < child.length; i++) {
7904
+ if (mbaCount >= MAX_COLD_BITWISE_MBA_PER_CHUNK) break;
7905
+ const item = child[i];
7906
+ if (item && typeof item === "object" && typeof item.type === "string") {
7907
+ walkTransform(
7908
+ item,
7909
+ (rep) => {
7910
+ child[i] = rep;
7911
+ },
7912
+ childInColdFn
7913
+ );
7914
+ }
7915
+ }
7916
+ } else if (child && typeof child === "object" && typeof child.type === "string") {
7917
+ walkTransform(
7918
+ child,
7919
+ (rep) => {
7920
+ node[key] = rep;
7921
+ },
7922
+ childInColdFn
7923
+ );
7924
+ }
7925
+ }
7926
+ } finally {
7927
+ if (pushedScope) scopeStack.pop();
7928
+ }
7929
+ }
7930
+ walkTransform(ast, () => {
7931
+ }, false);
7932
+ return mbaCount;
7933
+ }
7934
+ function applyColdFlowGuard(ast, coldFunctionNodes, seed = 2654435769, hotExemptNodes, windowKeySymbol, expectedDelta, shieldCoupled = false, options) {
6917
7935
  const sfx = (seed >>> 0).toString(36).slice(0, 4);
6918
7936
  const decoyIdent = `_uDec${sfx}`;
6919
7937
  const sboxIdent = `_uSb${sfx}`;
@@ -6923,24 +7941,27 @@ function applyColdFlowGuard(ast, coldFunctionNodes, seed = 2654435769, hotExempt
6923
7941
  const mxIdent = `_uMx${sfx}`;
6924
7942
  if (Array.isArray(ast.body)) {
6925
7943
  const alreadyGuarded = ast.body.some(
6926
- (stmt) => stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _416 => _416.declarations, 'optionalAccess', _417 => _417.some, 'call', _418 => _418(
6927
- (d) => _optionalChain([d, 'access', _419 => _419.id, 'optionalAccess', _420 => _420.type]) === "Identifier" && (d.id.name === decoyIdent || d.id.name === sboxIdent || d.id.name === mxIdent)
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)
6928
7946
  )])
6929
7947
  );
6930
7948
  if (alreadyGuarded) return 0;
6931
7949
  }
7950
+ if (_optionalChain([options, 'optionalAccess', _466 => _466.enableBitwiseMba])) {
7951
+ applyColdBitwiseMba(ast, coldFunctionNodes, seed, hotExemptNodes);
7952
+ }
6932
7953
  let guardedCount = 0;
6933
7954
  function maybeInjectGuard(node) {
6934
7955
  if (guardedCount >= MAX_COLD_GUARDS_PER_CHUNK) return;
6935
7956
  if (!coldFunctionNodes.has(node)) return;
6936
- if (_optionalChain([hotExemptNodes, 'optionalAccess', _421 => _421.has, 'call', _422 => _422(node)]) || node._unpeekSerialized) return;
7957
+ if (_optionalChain([hotExemptNodes, 'optionalAccess', _467 => _467.has, 'call', _468 => _468(node)]) || node._unpeekSerialized) return;
6937
7958
  if (node._unpeekVirtualized === true) return;
6938
7959
  if (!node.body || node.body.type !== "BlockStatement") return;
6939
7960
  const paramNames = [];
6940
7961
  for (const p of node.params || []) {
6941
7962
  extractParamNames(p, paramNames);
6942
7963
  }
6943
- const firstParam = _optionalChain([node, 'access', _423 => _423.params, 'optionalAccess', _424 => _424[0]]);
7964
+ const firstParam = _optionalChain([node, 'access', _469 => _469.params, 'optionalAccess', _470 => _470[0]]);
6944
7965
  const isArrow = node.type === "ArrowFunctionExpression";
6945
7966
  const returnDomain = inferFunctionReturnDomain(node);
6946
7967
  const guardStmt = createSotaMbaPredicate(
@@ -6963,6 +7984,7 @@ function applyColdFlowGuard(ast, coldFunctionNodes, seed = 2654435769, hotExempt
6963
7984
  }
6964
7985
  );
6965
7986
  guardedCount++;
7987
+ guardStmt._unpeekGuardSubtree = true;
6966
7988
  if (hotExemptNodes) {
6967
7989
  hotExemptNodes.add(guardStmt);
6968
7990
  hotExemptNodes.add(guardStmt.consequent);
@@ -6996,12 +8018,12 @@ function applyColdFlowGuard(ast, coldFunctionNodes, seed = 2654435769, hotExempt
6996
8018
  hotExemptNodes.add(sharedDecoyDecl);
6997
8019
  hotExemptNodes.add(sboxAliasDecl);
6998
8020
  for (const decl of sboxAliasDecl.declarations || []) {
6999
- if (_optionalChain([decl, 'access', _425 => _425.init, 'optionalAccess', _426 => _426.type]) === "FunctionExpression") {
8021
+ if (_optionalChain([decl, 'access', _471 => _471.init, 'optionalAccess', _472 => _472.type]) === "FunctionExpression") {
7000
8022
  hotExemptNodes.add(decl.init);
7001
8023
  }
7002
8024
  }
7003
8025
  for (const decl of sharedDecoyDecl.declarations || []) {
7004
- if (_optionalChain([decl, 'access', _427 => _427.init, 'optionalAccess', _428 => _428.type]) === "ArrayExpression" && decl.init.elements) {
8026
+ if (_optionalChain([decl, 'access', _473 => _473.init, 'optionalAccess', _474 => _474.type]) === "ArrayExpression" && decl.init.elements) {
7005
8027
  for (const el of decl.init.elements) {
7006
8028
  if (el) hotExemptNodes.add(el);
7007
8029
  }
@@ -7011,7 +8033,7 @@ function applyColdFlowGuard(ast, coldFunctionNodes, seed = 2654435769, hotExempt
7011
8033
  let insertIdx = 0;
7012
8034
  while (insertIdx < ast.body.length) {
7013
8035
  const stmt = ast.body[insertIdx];
7014
- const isDirective = stmt.type === "ExpressionStatement" && (Boolean(stmt.directive) || _optionalChain([stmt, 'access', _429 => _429.expression, 'optionalAccess', _430 => _430.type]) === "Literal" && typeof stmt.expression.value === "string" && /^(?:use\s+[a-zA-Z0-9_-]+)/.test(stmt.expression.value.trim()));
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()));
7015
8037
  if (isDirective || stmt.type === "ImportDeclaration") {
7016
8038
  insertIdx++;
7017
8039
  } else {
@@ -7129,14 +8151,14 @@ function encryptBytecodeStream(plainBytecode, fnSalt, vmKey, stateSlots, accSlot
7129
8151
  accBefore[len] = ac;
7130
8152
  if (stateSlots) {
7131
8153
  for (const slot of stateSlots) {
7132
- const targetPc = _nullishCoalesce(_optionalChain([jumpTargets, 'optionalAccess', _431 => _431.get, 'call', _432 => _432(slot - 1)]), () => ( plainBytecode[slot - 1]));
8154
+ const targetPc = _nullishCoalesce(_optionalChain([jumpTargets, 'optionalAccess', _477 => _477.get, 'call', _478 => _478(slot - 1)]), () => ( plainBytecode[slot - 1]));
7133
8155
  const sBefore = _nullishCoalesce(stAtSlot.get(slot), () => ( 0));
7134
8156
  enc[slot] = stateBefore[targetPc] ^ sBefore | 0;
7135
8157
  }
7136
8158
  }
7137
8159
  if (accSlots) {
7138
8160
  for (const slot of accSlots) {
7139
- const targetPc = _nullishCoalesce(_optionalChain([jumpTargets, 'optionalAccess', _433 => _433.get, 'call', _434 => _434(slot - 2)]), () => ( plainBytecode[slot - 2]));
8161
+ const targetPc = _nullishCoalesce(_optionalChain([jumpTargets, 'optionalAccess', _479 => _479.get, 'call', _480 => _480(slot - 2)]), () => ( plainBytecode[slot - 2]));
7140
8162
  const aBefore = _nullishCoalesce(acAtSlot.get(slot), () => ( 0));
7141
8163
  enc[slot] = accBefore[targetPc] ^ aBefore | 0;
7142
8164
  }
@@ -7426,7 +8448,7 @@ function prepareLoweredFunction(fnNode, enclosingBindings) {
7426
8448
  loweredParams.push({ type: "Identifier", name: param.name });
7427
8449
  continue;
7428
8450
  }
7429
- if (param.type === "RestElement" && _optionalChain([param, 'access', _435 => _435.argument, 'optionalAccess', _436 => _436.type]) === "Identifier") {
8451
+ if (param.type === "RestElement" && _optionalChain([param, 'access', _481 => _481.argument, 'optionalAccess', _482 => _482.type]) === "Identifier") {
7430
8452
  wrapperParams.push(param);
7431
8453
  paramPassExprs.push({ type: "Identifier", name: param.argument.name });
7432
8454
  loweredParams.push({ type: "Identifier", name: param.argument.name });
@@ -7485,7 +8507,7 @@ function prepareLoweredFunction(fnNode, enclosingBindings) {
7485
8507
  return null;
7486
8508
  }
7487
8509
  clone.params = loweredParams;
7488
- if (_optionalChain([clone, 'access', _437 => _437.body, 'optionalAccess', _438 => _438.type]) !== "BlockStatement") {
8510
+ if (_optionalChain([clone, 'access', _483 => _483.body, 'optionalAccess', _484 => _484.type]) !== "BlockStatement") {
7489
8511
  clone.body = {
7490
8512
  type: "BlockStatement",
7491
8513
  body: [
@@ -7593,7 +8615,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
7593
8615
  }
7594
8616
  if (node.type === "TryStatement") {
7595
8617
  scanVarDecls(node.block, false);
7596
- if (_optionalChain([node, 'access', _439 => _439.handler, 'optionalAccess', _440 => _440.body])) scanVarDecls(node.handler.body, false);
8618
+ if (_optionalChain([node, 'access', _485 => _485.handler, 'optionalAccess', _486 => _486.body])) scanVarDecls(node.handler.body, false);
7597
8619
  if (node.finalizer) scanVarDecls(node.finalizer, false);
7598
8620
  return;
7599
8621
  }
@@ -7718,7 +8740,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
7718
8740
  if (prop.computed) {
7719
8741
  if (!compileExpr(prop.key, true)) return false;
7720
8742
  } else {
7721
- const keyName = _optionalChain([prop, 'access', _441 => _441.key, 'optionalAccess', _442 => _442.type]) === "Identifier" ? prop.key.name : _optionalChain([prop, 'access', _443 => _443.key, 'optionalAccess', _444 => _444.type]) === "Literal" ? String(prop.key.value) : void 0;
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;
7722
8744
  if (keyName === void 0) return false;
7723
8745
  emit(OP_LDC, addConst(keyName));
7724
8746
  }
@@ -7857,11 +8879,11 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
7857
8879
  case "TemplateLiteral": {
7858
8880
  const quasis = node.quasis || [];
7859
8881
  const exprs = node.expressions || [];
7860
- emit(OP_LDC, addConst(_nullishCoalesce(_nullishCoalesce(_optionalChain([quasis, 'access', _445 => _445[0], 'optionalAccess', _446 => _446.value, 'optionalAccess', _447 => _447.cooked]), () => ( _optionalChain([quasis, 'access', _448 => _448[0], 'optionalAccess', _449 => _449.value, 'optionalAccess', _450 => _450.raw]))), () => ( ""))));
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]))), () => ( ""))));
7861
8883
  for (let i = 0; i < exprs.length; i++) {
7862
8884
  if (!compileExpr(exprs[i], true)) return false;
7863
8885
  emit(OP_ADD);
7864
- const qStr = _nullishCoalesce(_nullishCoalesce(_optionalChain([quasis, 'access', _451 => _451[i + 1], 'optionalAccess', _452 => _452.value, 'optionalAccess', _453 => _453.cooked]), () => ( _optionalChain([quasis, 'access', _454 => _454[i + 1], 'optionalAccess', _455 => _455.value, 'optionalAccess', _456 => _456.raw]))), () => ( ""));
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]))), () => ( ""));
7865
8887
  if (qStr.length > 0) {
7866
8888
  emit(OP_LDC, addConst(qStr));
7867
8889
  emit(OP_ADD);
@@ -7947,7 +8969,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
7947
8969
  if (inValuePos) emit(OP_LDC, addConst(void 0));
7948
8970
  return true;
7949
8971
  }
7950
- if (node.operator === "typeof" && _optionalChain([node, 'access', _457 => _457.argument, 'optionalAccess', _458 => _458.type]) === "Identifier") {
8972
+ if (node.operator === "typeof" && _optionalChain([node, 'access', _503 => _503.argument, 'optionalAccess', _504 => _504.type]) === "Identifier") {
7951
8973
  const name = node.argument.name;
7952
8974
  if (name === "undefined" && resolveLocal("undefined") === void 0) {
7953
8975
  emit(OP_LDC, addConst(void 0));
@@ -7994,7 +9016,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
7994
9016
  if (node.computed) {
7995
9017
  if (!compileExpr(node.property, true)) return false;
7996
9018
  } else {
7997
- if (_optionalChain([node, 'access', _459 => _459.property, 'optionalAccess', _460 => _460.type]) !== "Identifier") return false;
9019
+ if (_optionalChain([node, 'access', _505 => _505.property, 'optionalAccess', _506 => _506.type]) !== "Identifier") return false;
7998
9020
  emit(OP_LDC, addConst(node.property.name));
7999
9021
  }
8000
9022
  emit(OP_GETP);
@@ -8004,7 +9026,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
8004
9026
  case "CallExpression": {
8005
9027
  if (node.optional) return false;
8006
9028
  for (const arg of node.arguments || []) {
8007
- if (_optionalChain([arg, 'optionalAccess', _461 => _461.type]) === "SpreadElement") return false;
9029
+ if (_optionalChain([arg, 'optionalAccess', _507 => _507.type]) === "SpreadElement") return false;
8008
9030
  }
8009
9031
  if (node.callee.type === "MemberExpression") {
8010
9032
  if (node.callee.optional) return false;
@@ -8012,7 +9034,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
8012
9034
  if (node.callee.computed) {
8013
9035
  if (!compileExpr(node.callee.property, true)) return false;
8014
9036
  } else {
8015
- if (_optionalChain([node, 'access', _462 => _462.callee, 'access', _463 => _463.property, 'optionalAccess', _464 => _464.type]) !== "Identifier") return false;
9037
+ if (_optionalChain([node, 'access', _508 => _508.callee, 'access', _509 => _509.property, 'optionalAccess', _510 => _510.type]) !== "Identifier") return false;
8016
9038
  emit(OP_LDC, addConst(node.callee.property.name));
8017
9039
  }
8018
9040
  for (const arg of node.arguments) {
@@ -8031,7 +9053,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
8031
9053
  }
8032
9054
  case "NewExpression": {
8033
9055
  for (const arg of node.arguments || []) {
8034
- if (_optionalChain([arg, 'optionalAccess', _465 => _465.type]) === "SpreadElement") return false;
9056
+ if (_optionalChain([arg, 'optionalAccess', _511 => _511.type]) === "SpreadElement") return false;
8035
9057
  }
8036
9058
  if (!compileExpr(node.callee, true)) return false;
8037
9059
  for (const arg of node.arguments || []) {
@@ -8074,7 +9096,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
8074
9096
  if (node.left.computed) {
8075
9097
  if (!compileExpr(node.left.property, true)) return false;
8076
9098
  } else {
8077
- if (_optionalChain([node, 'access', _466 => _466.left, 'access', _467 => _467.property, 'optionalAccess', _468 => _468.type]) !== "Identifier") return false;
9099
+ if (_optionalChain([node, 'access', _512 => _512.left, 'access', _513 => _513.property, 'optionalAccess', _514 => _514.type]) !== "Identifier") return false;
8078
9100
  emit(OP_LDC, addConst(node.left.property.name));
8079
9101
  }
8080
9102
  if (!compileExpr(node.right, true)) return false;
@@ -8090,7 +9112,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
8090
9112
  if (node.left.computed) {
8091
9113
  if (!compileExpr(node.left.property, true)) return false;
8092
9114
  } else {
8093
- if (_optionalChain([node, 'access', _469 => _469.left, 'access', _470 => _470.property, 'optionalAccess', _471 => _471.type]) !== "Identifier") return false;
9115
+ if (_optionalChain([node, 'access', _515 => _515.left, 'access', _516 => _516.property, 'optionalAccess', _517 => _517.type]) !== "Identifier") return false;
8094
9116
  emit(OP_LDC, addConst(node.left.property.name));
8095
9117
  }
8096
9118
  emit(OP_STV, keySlot);
@@ -8110,7 +9132,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
8110
9132
  case "UpdateExpression": {
8111
9133
  const oneIdx = addConst(1);
8112
9134
  const stepOp = node.operator === "++" ? OP_ADD : OP_SUB;
8113
- if (_optionalChain([node, 'access', _472 => _472.argument, 'optionalAccess', _473 => _473.type]) === "Identifier") {
9135
+ if (_optionalChain([node, 'access', _518 => _518.argument, 'optionalAccess', _519 => _519.type]) === "Identifier") {
8114
9136
  const name = node.argument.name;
8115
9137
  if (!canWriteVar(name)) return false;
8116
9138
  if (node.prefix) {
@@ -8136,7 +9158,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
8136
9158
  }
8137
9159
  return true;
8138
9160
  }
8139
- if (_optionalChain([node, 'access', _474 => _474.argument, 'optionalAccess', _475 => _475.type]) === "MemberExpression" && !node.argument.optional) {
9161
+ if (_optionalChain([node, 'access', _520 => _520.argument, 'optionalAccess', _521 => _521.type]) === "MemberExpression" && !node.argument.optional) {
8140
9162
  const objSlot = allocTempSlot();
8141
9163
  const keySlot = allocTempSlot();
8142
9164
  const oldSlot = allocTempSlot();
@@ -8145,7 +9167,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
8145
9167
  if (node.argument.computed) {
8146
9168
  if (!compileExpr(node.argument.property, true)) return false;
8147
9169
  } else {
8148
- if (_optionalChain([node, 'access', _476 => _476.argument, 'access', _477 => _477.property, 'optionalAccess', _478 => _478.type]) !== "Identifier") return false;
9170
+ if (_optionalChain([node, 'access', _522 => _522.argument, 'access', _523 => _523.property, 'optionalAccess', _524 => _524.type]) !== "Identifier") return false;
8149
9171
  emit(OP_LDC, addConst(node.argument.property.name));
8150
9172
  }
8151
9173
  emit(OP_STV, keySlot);
@@ -8177,7 +9199,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
8177
9199
  if (prop.computed) {
8178
9200
  if (!compileExpr(prop.key, true)) return false;
8179
9201
  } else {
8180
- const keyName = _nullishCoalesce(_optionalChain([prop, 'access', _479 => _479.key, 'optionalAccess', _480 => _480.name]), () => ( _optionalChain([prop, 'access', _481 => _481.key, 'optionalAccess', _482 => _482.value])));
9202
+ const keyName = _nullishCoalesce(_optionalChain([prop, 'access', _525 => _525.key, 'optionalAccess', _526 => _526.name]), () => ( _optionalChain([prop, 'access', _527 => _527.key, 'optionalAccess', _528 => _528.value])));
8181
9203
  if (keyName === void 0) return false;
8182
9204
  emit(OP_LDC, addConst(keyName));
8183
9205
  }
@@ -8229,14 +9251,14 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
8229
9251
  }
8230
9252
  case "VariableDeclaration": {
8231
9253
  for (const decl of stmt.declarations) {
8232
- if (_optionalChain([decl, 'access', _483 => _483.id, 'optionalAccess', _484 => _484.type]) === "Identifier") {
9254
+ if (_optionalChain([decl, 'access', _529 => _529.id, 'optionalAccess', _530 => _530.type]) === "Identifier") {
8233
9255
  const slot = resolveLocal(decl.id.name);
8234
9256
  if (slot === void 0) return false;
8235
9257
  if (decl.init) {
8236
9258
  if (!compileExpr(decl.init, true)) return false;
8237
9259
  emit(OP_STV, slot);
8238
9260
  }
8239
- } else if (_optionalChain([decl, 'access', _485 => _485.id, 'optionalAccess', _486 => _486.type]) === "ObjectPattern" || _optionalChain([decl, 'access', _487 => _487.id, 'optionalAccess', _488 => _488.type]) === "ArrayPattern") {
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") {
8240
9262
  if (!decl.init) return false;
8241
9263
  const srcSlot = allocTempSlot();
8242
9264
  if (!compileExpr(decl.init, true)) return false;
@@ -8332,7 +9354,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
8332
9354
  }
8333
9355
  case "ForStatement": {
8334
9356
  let pushedForScope = false;
8335
- if (_optionalChain([stmt, 'access', _489 => _489.init, 'optionalAccess', _490 => _490.type]) === "VariableDeclaration" && stmt.init.kind !== "var") {
9357
+ if (_optionalChain([stmt, 'access', _535 => _535.init, 'optionalAccess', _536 => _536.type]) === "VariableDeclaration" && stmt.init.kind !== "var") {
8336
9358
  const forScope = /* @__PURE__ */ new Map();
8337
9359
  const names = /* @__PURE__ */ new Set();
8338
9360
  for (const decl of stmt.init.declarations || []) {
@@ -8400,7 +9422,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
8400
9422
  case "BreakStatement":
8401
9423
  case "ContinueStatement": {
8402
9424
  const isBreak = stmt.type === "BreakStatement";
8403
- const labelName = _optionalChain([stmt, 'access', _491 => _491.label, 'optionalAccess', _492 => _492.name]);
9425
+ const labelName = _optionalChain([stmt, 'access', _537 => _537.label, 'optionalAccess', _538 => _538.name]);
8404
9426
  let target;
8405
9427
  for (let i = loopStack.length - 1; i >= 0; i--) {
8406
9428
  if (!labelName || loopStack[i].label === labelName) {
@@ -8419,7 +9441,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
8419
9441
  return true;
8420
9442
  }
8421
9443
  case "LabeledStatement": {
8422
- return compileStmt(stmt.body, false, _optionalChain([stmt, 'access', _493 => _493.label, 'optionalAccess', _494 => _494.name]));
9444
+ return compileStmt(stmt.body, false, _optionalChain([stmt, 'access', _539 => _539.label, 'optionalAccess', _540 => _540.name]));
8423
9445
  }
8424
9446
  case "TryStatement": {
8425
9447
  if (stmt.finalizer) {
@@ -8549,12 +9571,12 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654
8549
9571
  function findInjectedVmHelperName(ast) {
8550
9572
  if (!ast || !Array.isArray(ast.body)) return null;
8551
9573
  for (const stmt of ast.body) {
8552
- if (stmt.type === "FunctionDeclaration" && typeof _optionalChain([stmt, 'access', _495 => _495.id, 'optionalAccess', _496 => _496.name]) === "string" && stmt.id.name.startsWith("_uVm")) {
9574
+ if (stmt.type === "FunctionDeclaration" && typeof _optionalChain([stmt, 'access', _541 => _541.id, 'optionalAccess', _542 => _542.name]) === "string" && stmt.id.name.startsWith("_uVm")) {
8553
9575
  return stmt.id.name;
8554
9576
  }
8555
9577
  if (stmt.type === "VariableDeclaration" && Array.isArray(stmt.declarations)) {
8556
9578
  for (const d of stmt.declarations) {
8557
- if (_optionalChain([d, 'access', _497 => _497.id, 'optionalAccess', _498 => _498.type]) === "Identifier" && typeof d.id.name === "string" && d.id.name.startsWith("_uVm")) {
9579
+ if (_optionalChain([d, 'access', _543 => _543.id, 'optionalAccess', _544 => _544.type]) === "Identifier" && typeof d.id.name === "string" && d.id.name.startsWith("_uVm")) {
8558
9580
  return d.id.name;
8559
9581
  }
8560
9582
  }
@@ -8565,26 +9587,26 @@ function findInjectedVmHelperName(ast) {
8565
9587
  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;
8566
9588
  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;
8567
9589
  function getVmCandidateName(fn, ancestors) {
8568
- if (_optionalChain([fn, 'access', _499 => _499.id, 'optionalAccess', _500 => _500.type]) === "Identifier" && typeof fn.id.name === "string") {
9590
+ if (_optionalChain([fn, 'access', _545 => _545.id, 'optionalAccess', _546 => _546.type]) === "Identifier" && typeof fn.id.name === "string") {
8569
9591
  return fn.id.name;
8570
9592
  }
8571
9593
  const parent = ancestors.length >= 2 ? ancestors[ancestors.length - 2] : null;
8572
9594
  if (!parent) return "";
8573
- if (parent.type === "VariableDeclarator" && _optionalChain([parent, 'access', _501 => _501.id, 'optionalAccess', _502 => _502.type]) === "Identifier") {
9595
+ if (parent.type === "VariableDeclarator" && _optionalChain([parent, 'access', _547 => _547.id, 'optionalAccess', _548 => _548.type]) === "Identifier") {
8574
9596
  return parent.id.name;
8575
9597
  }
8576
9598
  if (parent.type === "Property") {
8577
- if (_optionalChain([parent, 'access', _503 => _503.key, 'optionalAccess', _504 => _504.type]) === "Identifier") return parent.key.name;
8578
- if (_optionalChain([parent, 'access', _505 => _505.key, 'optionalAccess', _506 => _506.type]) === "Literal" && typeof parent.key.value === "string") {
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") {
8579
9601
  return parent.key.value;
8580
9602
  }
8581
9603
  }
8582
- if (parent.type === "MethodDefinition" && _optionalChain([parent, 'access', _507 => _507.key, 'optionalAccess', _508 => _508.type]) === "Identifier") {
9604
+ if (parent.type === "MethodDefinition" && _optionalChain([parent, 'access', _553 => _553.key, 'optionalAccess', _554 => _554.type]) === "Identifier") {
8583
9605
  return parent.key.name;
8584
9606
  }
8585
9607
  if (parent.type === "AssignmentExpression") {
8586
- if (_optionalChain([parent, 'access', _509 => _509.left, 'optionalAccess', _510 => _510.type]) === "Identifier") return parent.left.name;
8587
- if (_optionalChain([parent, 'access', _511 => _511.left, 'optionalAccess', _512 => _512.type]) === "MemberExpression" && !parent.left.computed && _optionalChain([parent, 'access', _513 => _513.left, 'access', _514 => _514.property, 'optionalAccess', _515 => _515.type]) === "Identifier") {
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") {
8588
9610
  return parent.left.property.name;
8589
9611
  }
8590
9612
  }
@@ -8597,11 +9619,11 @@ function bodyHasPrioritySignal(fnNode) {
8597
9619
  if (n !== fnNode && FUNCTION_NODE_TYPES2.has(n.type)) return false;
8598
9620
  if (n.type === "CallExpression") {
8599
9621
  const callee = n.callee;
8600
- if (_optionalChain([callee, 'optionalAccess', _516 => _516.type]) === "Identifier" && PRIORITY_CALL_NAME_RE.test(callee.name)) {
9622
+ if (_optionalChain([callee, 'optionalAccess', _562 => _562.type]) === "Identifier" && PRIORITY_CALL_NAME_RE.test(callee.name)) {
8601
9623
  matched = true;
8602
9624
  return false;
8603
9625
  }
8604
- if (_optionalChain([callee, 'optionalAccess', _517 => _517.type]) === "MemberExpression" && !callee.computed && _optionalChain([callee, 'access', _518 => _518.property, 'optionalAccess', _519 => _519.type]) === "Identifier" && PRIORITY_CALL_NAME_RE.test(callee.property.name)) {
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)) {
8605
9627
  matched = true;
8606
9628
  return false;
8607
9629
  }
@@ -8621,14 +9643,14 @@ function bodyHasPrioritySignal(fnNode) {
8621
9643
  }
8622
9644
  function scoreVmCandidate(fn, ancestors, criticalSet) {
8623
9645
  let score = 0;
8624
- if (_optionalChain([criticalSet, 'optionalAccess', _520 => _520.has, 'call', _521 => _521(fn)])) {
9646
+ if (_optionalChain([criticalSet, 'optionalAccess', _566 => _566.has, 'call', _567 => _567(fn)])) {
8625
9647
  score += 1e3;
8626
9648
  }
8627
9649
  const candName = getVmCandidateName(fn, ancestors);
8628
9650
  if (candName && PRIORITY_HANDLER_NAME_RE.test(candName) || bodyHasPrioritySignal(fn)) {
8629
9651
  score += 500;
8630
9652
  }
8631
- if (_optionalChain([fn, 'access', _522 => _522.body, 'optionalAccess', _523 => _523.type]) === "BlockStatement" && Array.isArray(fn.body.body)) {
9653
+ if (_optionalChain([fn, 'access', _568 => _568.body, 'optionalAccess', _569 => _569.type]) === "BlockStatement" && Array.isArray(fn.body.body)) {
8632
9654
  const stmtCount = fn.body.body.length;
8633
9655
  if (stmtCount >= 2) {
8634
9656
  score += Math.min(200, 10 + (stmtCount - 2) * 15);
@@ -8646,8 +9668,8 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
8646
9668
  vmHelperName: existingName
8647
9669
  };
8648
9670
  }
8649
- const maxFunctions = _nullishCoalesce(_optionalChain([extraOpts, 'optionalAccess', _524 => _524.maxFunctionsPerChunk]), () => ( 12));
8650
- const criticalSet = _optionalChain([extraOpts, 'optionalAccess', _525 => _525.criticalFunctionNodes]);
9671
+ const maxFunctions = _nullishCoalesce(_optionalChain([extraOpts, 'optionalAccess', _570 => _570.maxFunctionsPerChunk]), () => ( 12));
9672
+ const criticalSet = _optionalChain([extraOpts, 'optionalAccess', _571 => _571.criticalFunctionNodes]);
8651
9673
  const opMap = generateOpcodeMap(seed, OPCODE_COUNT);
8652
9674
  const vmKey = deriveVmKey(seed);
8653
9675
  const scopeBindings = /* @__PURE__ */ new Map();
@@ -8680,7 +9702,7 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
8680
9702
  walk7.ancestor(ast, {
8681
9703
  ImportDeclaration(node) {
8682
9704
  for (const spec of node.specifiers || []) {
8683
- if (_optionalChain([spec, 'access', _526 => _526.local, 'optionalAccess', _527 => _527.type]) === "Identifier") {
9705
+ if (_optionalChain([spec, 'access', _572 => _572.local, 'optionalAccess', _573 => _573.type]) === "Identifier") {
8684
9706
  addScopeBinding(ast, spec.local.name);
8685
9707
  }
8686
9708
  }
@@ -8697,7 +9719,7 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
8697
9719
  },
8698
9720
  FunctionDeclaration(node, _state, ancestors) {
8699
9721
  const parentAncestors = ancestors.slice(0, -1);
8700
- if (_optionalChain([node, 'access', _528 => _528.id, 'optionalAccess', _529 => _529.type]) === "Identifier") {
9722
+ if (_optionalChain([node, 'access', _574 => _574.id, 'optionalAccess', _575 => _575.type]) === "Identifier") {
8701
9723
  addScopeBinding(findNearestLexicalScope(parentAncestors), node.id.name);
8702
9724
  addScopeBinding(findNearestFunctionOrProgram(parentAncestors), node.id.name);
8703
9725
  }
@@ -8711,7 +9733,7 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
8711
9733
  rawCandidates.push({ fn: node, ancestors: ancestors.slice() });
8712
9734
  },
8713
9735
  FunctionExpression(node, _state, ancestors) {
8714
- if (_optionalChain([node, 'access', _530 => _530.id, 'optionalAccess', _531 => _531.type]) === "Identifier") {
9736
+ if (_optionalChain([node, 'access', _576 => _576.id, 'optionalAccess', _577 => _577.type]) === "Identifier") {
8715
9737
  addScopeBinding(node, node.id.name);
8716
9738
  }
8717
9739
  const paramNames = /* @__PURE__ */ new Set();
@@ -8734,13 +9756,13 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
8734
9756
  rawCandidates.push({ fn: node, ancestors: ancestors.slice() });
8735
9757
  },
8736
9758
  ClassDeclaration(node, _state, ancestors) {
8737
- if (_optionalChain([node, 'access', _532 => _532.id, 'optionalAccess', _533 => _533.type]) === "Identifier") {
9759
+ if (_optionalChain([node, 'access', _578 => _578.id, 'optionalAccess', _579 => _579.type]) === "Identifier") {
8738
9760
  addScopeBinding(findNearestLexicalScope(ancestors.slice(0, -1)), node.id.name);
8739
9761
  addScopeBinding(node, node.id.name);
8740
9762
  }
8741
9763
  },
8742
9764
  ClassExpression(node) {
8743
- if (_optionalChain([node, 'access', _534 => _534.id, 'optionalAccess', _535 => _535.type]) === "Identifier") {
9765
+ if (_optionalChain([node, 'access', _580 => _580.id, 'optionalAccess', _581 => _581.type]) === "Identifier") {
8744
9766
  addScopeBinding(node, node.id.name);
8745
9767
  }
8746
9768
  },
@@ -8772,7 +9794,7 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
8772
9794
  continue;
8773
9795
  }
8774
9796
  const parentNode = ancestors.length >= 2 ? ancestors[ancestors.length - 2] : null;
8775
- if (_optionalChain([parentNode, 'optionalAccess', _536 => _536.type]) === "MethodDefinition" && parentNode.kind === "constructor") {
9797
+ if (_optionalChain([parentNode, 'optionalAccess', _582 => _582.type]) === "MethodDefinition" && parentNode.kind === "constructor") {
8776
9798
  continue;
8777
9799
  }
8778
9800
  if (ancestors.some((a) => a.type === "WithStatement")) {
@@ -8794,7 +9816,7 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
8794
9816
  }
8795
9817
  }
8796
9818
  }
8797
- if (fn.type === "FunctionExpression" && _optionalChain([fn, 'access', _537 => _537.id, 'optionalAccess', _538 => _538.type]) === "Identifier") {
9819
+ if (fn.type === "FunctionExpression" && _optionalChain([fn, 'access', _583 => _583.id, 'optionalAccess', _584 => _584.type]) === "Identifier") {
8798
9820
  enclosingBindings.add(fn.id.name);
8799
9821
  }
8800
9822
  const lowered = prepareLoweredFunction(fn, enclosingBindings);
@@ -8933,7 +9955,7 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
8933
9955
  seed,
8934
9956
  windowKeySymbol,
8935
9957
  expectedDelta,
8936
- _optionalChain([extraOpts, 'optionalAccess', _539 => _539.expectedStateHash])
9958
+ _optionalChain([extraOpts, 'optionalAccess', _585 => _585.expectedStateHash])
8937
9959
  );
8938
9960
  const parsedHelper = acorn6.parse(interpreterSource, {
8939
9961
  ecmaVersion: "latest",
@@ -8942,7 +9964,7 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
8942
9964
  let insertIdx = 0;
8943
9965
  while (insertIdx < ast.body.length) {
8944
9966
  const stmt = ast.body[insertIdx];
8945
- const isDirective = stmt.type === "ExpressionStatement" && (Boolean(stmt.directive) || _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()));
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()));
8946
9968
  if (isDirective || stmt.type === "ImportDeclaration") {
8947
9969
  insertIdx++;
8948
9970
  } else {
@@ -9029,7 +10051,7 @@ function scrubResidualPaths(ast, options = {}, hotExemptNodes, exemptSubtreeRoot
9029
10051
  Literal(node, _state, ancestors) {
9030
10052
  if (node.regex || typeof node.value !== "string") return;
9031
10053
  const val = node.value;
9032
- if (_optionalChain([exemptSet, 'optionalAccess', _542 => _542.has, 'call', _543 => _543(val)])) return;
10054
+ if (_optionalChain([exemptSet, 'optionalAccess', _588 => _588.has, 'call', _589 => _589(val)])) return;
9033
10055
  const parent = ancestors[ancestors.length - 2];
9034
10056
  if (!parent) return;
9035
10057
  if ((parent.type === "ImportDeclaration" || parent.type === "ExportNamedDeclaration" || parent.type === "ExportAllDeclaration" || parent.type === "ImportExpression") && parent.source === node) {
@@ -9054,12 +10076,12 @@ function scrubResidualPaths(ast, options = {}, hotExemptNodes, exemptSubtreeRoot
9054
10076
  return;
9055
10077
  }
9056
10078
  const parent = ancestors[ancestors.length - 2];
9057
- if (_optionalChain([parent, 'optionalAccess', _544 => _544.type]) === "ImportExpression" && parent.source === node) {
10079
+ if (_optionalChain([parent, 'optionalAccess', _590 => _590.type]) === "ImportExpression" && parent.source === node) {
9058
10080
  return;
9059
10081
  }
9060
10082
  for (const quasi of node.quasis) {
9061
- const val = _nullishCoalesce(_optionalChain([quasi, 'optionalAccess', _545 => _545.value, 'optionalAccess', _546 => _546.cooked]), () => ( _optionalChain([quasi, 'optionalAccess', _547 => _547.value, 'optionalAccess', _548 => _548.raw])));
9062
- if (typeof val !== "string" || _optionalChain([exemptSet, 'optionalAccess', _549 => _549.has, 'call', _550 => _550(val)])) continue;
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;
9063
10085
  const scrubbed = scrubStringValue(val, options.rootDir);
9064
10086
  if (scrubbed !== val) {
9065
10087
  quasi.value.cooked = scrubbed;
@@ -9099,24 +10121,24 @@ function isAstAlreadyProtected(ast) {
9099
10121
  return ast.body.some((stmt) => {
9100
10122
  if (stmt.type === "VariableDeclaration" && Array.isArray(stmt.declarations)) {
9101
10123
  for (const d of stmt.declarations) {
9102
- const name = _optionalChain([d, 'access', _551 => _551.id, 'optionalAccess', _552 => _552.type]) === "Identifier" ? d.id.name : void 0;
10124
+ const name = _optionalChain([d, 'access', _597 => _597.id, 'optionalAccess', _598 => _598.type]) === "Identifier" ? d.id.name : void 0;
9103
10125
  if (typeof name === "string") {
9104
- 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', _553 => _553.init, 'optionalAccess', _554 => _554.type]) === "CallExpression" && _optionalChain([d, 'access', _555 => _555.init, 'access', _556 => _556.callee, 'optionalAccess', _557 => _557.type]) === "FunctionExpression" && _optionalChain([d, 'access', _558 => _558.init, 'access', _559 => _559.callee, 'optionalAccess', _560 => _560.id, 'optionalAccess', _561 => _561.name]) === "f" && _optionalChain([d, 'access', _562 => _562.init, 'access', _563 => _563.arguments, 'optionalAccess', _564 => _564[0], 'optionalAccess', _565 => _565.type]) === "ArrayExpression" || _optionalChain([d, 'access', _566 => _566.init, 'optionalAccess', _567 => _567.type]) === "CallExpression" && _optionalChain([d, 'access', _568 => _568.init, 'access', _569 => _569.callee, 'optionalAccess', _570 => _570.type]) === "MemberExpression" && _optionalChain([d, 'access', _571 => _571.init, 'access', _572 => _572.callee, 'access', _573 => _573.object, 'optionalAccess', _574 => _574.type]) === "Identifier" && d.init.callee.object.name === "Symbol" && _optionalChain([d, 'access', _575 => _575.init, 'access', _576 => _576.callee, 'access', _577 => _577.property, 'optionalAccess', _578 => _578.type]) === "Identifier" && d.init.callee.property.name === "for" && typeof _optionalChain([d, 'access', _579 => _579.init, 'access', _580 => _580.arguments, 'optionalAccess', _581 => _581[0], 'optionalAccess', _582 => _582.value]) === "string" && d.init.arguments[0].value.startsWith("__upk_v4_")) {
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_")) {
9105
10127
  return true;
9106
10128
  }
9107
10129
  }
9108
10130
  }
9109
10131
  }
9110
- if (stmt.type === "FunctionDeclaration" && _optionalChain([stmt, 'access', _583 => _583.id, 'optionalAccess', _584 => _584.type]) === "Identifier") {
10132
+ if (stmt.type === "FunctionDeclaration" && _optionalChain([stmt, 'access', _629 => _629.id, 'optionalAccess', _630 => _630.type]) === "Identifier") {
9111
10133
  const fnName = stmt.id.name;
9112
10134
  if (typeof fnName === "string" && (fnName.startsWith("_uD") || fnName.startsWith("_uVm") || fnName.startsWith("_wKdf") || fnName === "_hX")) {
9113
10135
  return true;
9114
10136
  }
9115
10137
  }
9116
- if (stmt.type === "ExpressionStatement" && _optionalChain([stmt, 'access', _585 => _585.expression, 'optionalAccess', _586 => _586.type]) === "CallExpression") {
10138
+ if (stmt.type === "ExpressionStatement" && _optionalChain([stmt, 'access', _631 => _631.expression, 'optionalAccess', _632 => _632.type]) === "CallExpression") {
9117
10139
  const callee = stmt.expression.callee;
9118
- if (_optionalChain([callee, 'optionalAccess', _587 => _587.type]) === "FunctionExpression") {
9119
- const name = _optionalChain([callee, 'access', _588 => _588.id, 'optionalAccess', _589 => _589.name]);
10140
+ if (_optionalChain([callee, 'optionalAccess', _633 => _633.type]) === "FunctionExpression") {
10141
+ const name = _optionalChain([callee, 'access', _634 => _634.id, 'optionalAccess', _635 => _635.name]);
9120
10142
  if (typeof name === "string" && name.startsWith("_u$") || containsUnpeekShieldMarker(callee.body)) {
9121
10143
  return true;
9122
10144
  }
@@ -9128,7 +10150,7 @@ function isAstAlreadyProtected(ast) {
9128
10150
  function transformJavaScript(code, options = {}) {
9129
10151
  const internalOptions = options;
9130
10152
  const seed = _nullishCoalesce(internalOptions.seed, () => ( 2654435769));
9131
- const minStringLength = _nullishCoalesce(_nullishCoalesce(options.minStringLength, () => ( _optionalChain([options, 'access', _590 => _590.config, 'optionalAccess', _591 => _591.vault, 'optionalAccess', _592 => _592.minStringLength]))), () => ( 4));
10153
+ const minStringLength = _nullishCoalesce(_nullishCoalesce(options.minStringLength, () => ( _optionalChain([options, 'access', _636 => _636.config, 'optionalAccess', _637 => _637.vault, 'optionalAccess', _638 => _638.minStringLength]))), () => ( 4));
9132
10154
  const isAggressive = _nullishCoalesce(options.aggressive, () => ( false));
9133
10155
  if (!code || !code.trim()) {
9134
10156
  const emptyResult = {
@@ -9193,7 +10215,7 @@ function transformJavaScript(code, options = {}) {
9193
10215
  const boundary = classifyChunkBoundary(ast);
9194
10216
  attachMagicComments(boundary.importExpressions, comments);
9195
10217
  const effectiveConfig = options.critical ? { ..._nullishCoalesce(options.config, () => ( {})), critical: options.critical } : options.config;
9196
- const effectiveProfile = _nullishCoalesce(options.profile, () => ( _optionalChain([effectiveConfig, 'optionalAccess', _593 => _593.profile])));
10218
+ const effectiveProfile = _nullishCoalesce(options.profile, () => ( _optionalChain([effectiveConfig, 'optionalAccess', _639 => _639.profile])));
9197
10219
  const originalSourceMap = internalOptions.originalSourceMap;
9198
10220
  const hotRes = analyzeAstHotPaths(ast, effectiveConfig, originalSourceMap);
9199
10221
  const {
@@ -9204,7 +10226,7 @@ function transformJavaScript(code, options = {}) {
9204
10226
  serializedFunctionNodes
9205
10227
  } = hotRes;
9206
10228
  const criticalFunctionNodes = hotRes.criticalFunctionNodes;
9207
- if (options.scrubPaths || _optionalChain([effectiveConfig, 'optionalAccess', _594 => _594.scrubPaths])) {
10229
+ if (options.scrubPaths || _optionalChain([effectiveConfig, 'optionalAccess', _640 => _640.scrubPaths])) {
9208
10230
  scrubResidualPaths(
9209
10231
  ast,
9210
10232
  {
@@ -9216,8 +10238,8 @@ function transformJavaScript(code, options = {}) {
9216
10238
  );
9217
10239
  }
9218
10240
  const shieldCoupled = _nullishCoalesce(internalOptions.shieldCoupled, () => ( Boolean(internalOptions.injectRuntimeShield)));
9219
- const deterrentMode = _nullishCoalesce(_nullishCoalesce(internalOptions.deterrentMode, () => ( _optionalChain([effectiveConfig, 'optionalAccess', _595 => _595.shield, 'optionalAccess', _596 => _596.deterrentMode]))), () => ( "passive"));
9220
- const detectHeadless = _nullishCoalesce(_nullishCoalesce(internalOptions.detectHeadless, () => ( _optionalChain([effectiveConfig, 'optionalAccess', _597 => _597.shield, 'optionalAccess', _598 => _598.detectHeadless]))), () => ( false));
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));
9221
10243
  const sym = shieldCoupled ? _nullishCoalesce(internalOptions.windowKeySymbol, () => ( deriveWindowKeySymbol(seed))) : void 0;
9222
10244
  let shieldDelta = shieldCoupled ? internalOptions.expectedDelta : void 0;
9223
10245
  let expectedStateHash = shieldCoupled ? internalOptions.expectedStateHash : void 0;
@@ -9237,9 +10259,9 @@ function transformJavaScript(code, options = {}) {
9237
10259
  }
9238
10260
  let virtualizedFunctionsCount = 0;
9239
10261
  if (isAggressive) {
9240
- const extraVmOpts = criticalFunctionNodes || _optionalChain([effectiveConfig, 'optionalAccess', _599 => _599.critical, 'optionalAccess', _600 => _600.maxFunctionsPerChunk]) !== void 0 || expectedStateHash !== void 0 ? {
10262
+ const extraVmOpts = criticalFunctionNodes || _optionalChain([effectiveConfig, 'optionalAccess', _645 => _645.critical, 'optionalAccess', _646 => _646.maxFunctionsPerChunk]) !== void 0 || expectedStateHash !== void 0 ? {
9241
10263
  ...criticalFunctionNodes ? { criticalFunctionNodes } : {},
9242
- ..._optionalChain([effectiveConfig, 'optionalAccess', _601 => _601.critical, 'optionalAccess', _602 => _602.maxFunctionsPerChunk]) !== void 0 ? { maxFunctionsPerChunk: effectiveConfig.critical.maxFunctionsPerChunk } : {},
10264
+ ..._optionalChain([effectiveConfig, 'optionalAccess', _647 => _647.critical, 'optionalAccess', _648 => _648.maxFunctionsPerChunk]) !== void 0 ? { maxFunctionsPerChunk: effectiveConfig.critical.maxFunctionsPerChunk } : {},
9243
10265
  ...expectedStateHash !== void 0 ? { expectedStateHash } : {}
9244
10266
  } : void 0;
9245
10267
  const vmRes = extraVmOpts ? applyMicroVm(
@@ -9260,7 +10282,7 @@ function transformJavaScript(code, options = {}) {
9260
10282
  );
9261
10283
  virtualizedFunctionsCount = vmRes.virtualizedCount;
9262
10284
  }
9263
- if (effectiveProfile !== "minimal" && _optionalChain([effectiveConfig, 'optionalAccess', _603 => _603.coldFlow]) !== false) {
10285
+ if (effectiveProfile !== "minimal" && _optionalChain([effectiveConfig, 'optionalAccess', _649 => _649.coldFlow]) !== false) {
9264
10286
  applyColdFlowGuard(
9265
10287
  ast,
9266
10288
  coldFunctionNodes,
@@ -9268,7 +10290,8 @@ function transformJavaScript(code, options = {}) {
9268
10290
  hotExemptNodes,
9269
10291
  sym,
9270
10292
  shieldDelta,
9271
- shieldCoupled
10293
+ shieldCoupled,
10294
+ { enableBitwiseMba: isAggressive || effectiveProfile === "strict" }
9272
10295
  );
9273
10296
  }
9274
10297
  const mangledSymbolsCount = applyPolymorphicMangler(
@@ -9379,4 +10402,6 @@ ${finalCode}`;
9379
10402
 
9380
10403
 
9381
10404
 
9382
- exports.computeFnv1aHash = computeFnv1aHash; exports.flattenSourceMapSections = flattenSourceMapSections; exports.shiftSourceMapLines = shiftSourceMapLines; exports.computeDeterministicDebugId = computeDeterministicDebugId; exports.chainSourceMaps = chainSourceMaps; exports.resolvePosition = resolvePosition; exports.safeDecodeURIComponent = safeDecodeURIComponent; exports.symbolicateStackTrace = symbolicateStackTrace; exports.detectHotPaths = detectHotPaths; exports.computeIntegrityHash = computeIntegrityHash; exports.verifyCodeIntegrity = verifyCodeIntegrity; exports.deriveWindowKeySymbol = deriveWindowKeySymbol; exports.createDeterrentSnippet = createDeterrentSnippet; exports.generateRuntimeShield = generateRuntimeShield; exports.transformJavaScript = transformJavaScript;
10405
+
10406
+
10407
+ exports.computeFnv1aHash = computeFnv1aHash; exports.flattenSourceMapSections = flattenSourceMapSections; exports.shiftSourceMapLines = shiftSourceMapLines; exports.computeDeterministicDebugId = computeDeterministicDebugId; exports.chainSourceMaps = chainSourceMaps; exports.resolvePosition = resolvePosition; exports.safeDecodeURIComponent = safeDecodeURIComponent; exports.symbolicateStackTrace = symbolicateStackTrace; exports.detectHotPaths = detectHotPaths; exports.computeIntegrityHash = computeIntegrityHash; exports.verifyCodeIntegrity = verifyCodeIntegrity; exports.deriveWindowKeySymbol = deriveWindowKeySymbol; exports.createDeterrentSnippet = createDeterrentSnippet; exports.generateRuntimeShield = generateRuntimeShield; exports.classifyPlaintextSecret = classifyPlaintextSecret; exports.hasRegexSecretRun = hasRegexSecretRun; exports.transformJavaScript = transformJavaScript;