import { isSolanaLike as e, networkRegistry as t } from "../../constants/chains.constants.mjs";
import { addPaddingToUtxos as n } from "../web3/events/getShieldedBalance.mjs";
import { getNullifierAccount as r } from "./solana.mjs";
import { createCustomSolanaConnection as i } from "../utils/create-provider.mjs";
import { PublicKey as a } from "@solana/web3.js";
//#region libs/shared/common/src/functions/pre-transaction/calculateSolanaNullifierCount.ts
var o = async (o, s, c, l) => {
	if (!e(s) || c.length === 0 || l.length === 0) return 0;
	try {
		let e = (await n(o, s, c, l, 6)).flat().filter((e) => e.amount !== 0n);
		if (e.length === 0) return 0;
		let { fetchRpcUrl: u, contractData: d } = t[s], { originalDeployer: f, hinkalIdl: p } = d;
		if (!u) throw Error("RPC URL not found for chain ID");
		if (!f) throw Error("Original deployer not found for chain ID");
		if (!p) throw Error("Hinkal IDL not found for chain ID");
		let m = i(u), h = new a(f), g = new a(p.address), _ = e.map((e) => r(BigInt(e.getNullifier()), h, g));
		return (await m.getMultipleAccountsInfo(_)).filter((e) => e === null).length;
	} catch (e) {
		return (e instanceof Error ? e.message : String(e)).toLowerCase().includes("utxos limitations") ? 6 : 0;
	}
};
//#endregion
export { o as calculateSolanaNullifierCount };
