import { caseInsensitiveEqual as e } from "../utils/caseInsensitive.utils.mjs";
import { Utxo as t } from "../../data-structures/utxo/Utxo.mjs";
//#region libs/shared/common/src/functions/pre-transaction/recipientUtxoProcessing.ts
var n = (n, r, i, a) => {
	let { recipientInfo: o, amount: s, token: c } = n, [l, u, d, , f] = o.split(","), p = r.findIndex((t) => t.find((t) => e(t.erc20TokenAddress, n?.token.erc20TokenAddress)) !== void 0), m = new t({
		amount: s,
		erc20TokenAddress: c.erc20TokenAddress,
		timeStamp: a,
		H0: [BigInt(u), BigInt(d)],
		stealthAddress: l,
		encryptionKey: f,
		isNewStyle: !0
	});
	if (p === -1) throw Error("Private recipient index not found");
	r.forEach((e, n) => {
		if (n === p) e.push(m), i[n] += s;
		else {
			let n = new t({
				amount: 0n,
				erc20TokenAddress: e[0].erc20TokenAddress,
				timeStamp: a,
				H0: [BigInt(u), BigInt(d)],
				stealthAddress: l,
				encryptionKey: f,
				isNewStyle: !0
			});
			e.push(n);
		}
	});
};
//#endregion
export { n as recipientUtxoProcessing };
