import { transactionErrorCodes as e } from "../../error-handling/error-codes.constants.mjs";
import { bigintMax as t, countTotalAmountInUtxos as n } from "../utils/amounts.utils.mjs";
import { Utxo as r } from "../../data-structures/utxo/Utxo.mjs";
//#region libs/shared/common/src/functions/pre-transaction/outputUtxoProcessing.ts
var i = (i, a, o, s, c = !0, l, u) => {
	let d = n(a), { erc20TokenAddress: f, mintAddress: p } = a[0];
	if (c && o < 0n && d + o < 0n) throw Error(e.INSUFFICIENT_FUNDS_TO_TRANSACT);
	let m = [new r({
		amount: t(d + o, 0n),
		erc20TokenAddress: f,
		mintAddress: p,
		nullifyingKey: i.getShieldedPrivateKey(),
		timeStamp: s,
		spendingPublicKey: i.getSpendingKeyPair().pubSpendingBJJPoint,
		isNewStyle: !0
	})];
	if (l !== void 0 && u !== void 0) {
		let [e, t, n, , i] = l.split(",");
		m.push(new r({
			amount: u,
			erc20TokenAddress: f,
			mintAddress: p,
			H0: [BigInt(t), BigInt(n)],
			stealthAddress: e,
			encryptionKey: i,
			timeStamp: s,
			isNewStyle: !0
		}));
	}
	return { outputUtxos: m };
};
//#endregion
export { i as outputUtxoProcessing };
