/**

 * Resolve hook: swap wallet_crypto.js for a Node-safe stub during policy tests.

 */

export async function initialize(data) {

  globalThis.__sarmadStubWallet = data.stubWallet;

}



export async function resolve(specifier, context, nextResolve) {

  const stub = globalThis.__sarmadStubWallet;

  if (

    stub &&

    (specifier === "./wallet_crypto.js" ||

      specifier.endsWith("/wallet_crypto.js") ||

      specifier.includes("wallet_crypto.js"))

  ) {

    return { url: stub, shortCircuit: true };

  }

  if (specifier.startsWith("https://")) {

    throw new Error("Unexpected CDN import during policy tests: " + specifier);

  }

  return nextResolve(specifier, context);

}


