import { ExternalActionId as e } from "../../types/external-action.types.mjs";
import { networkRegistry as t } from "../../constants/chains.constants.mjs";
import { zeroAddress as n } from "../../constants/protocol.constants.mjs";
import { zeroFeeStructure as r } from "../../types/hinkal.types.mjs";
import { addPaddingToUtxos as i } from "../../functions/web3/events/getShieldedBalance.mjs";
import { outputUtxoProcessing as a } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
import { calculateTotalFee as o } from "../../functions/utils/fees.utils.mjs";
import { constructZkProof as s } from "../../functions/snarkjs/constructGeneralZkProof.mjs";
import { ethers as c } from "ethers";
//#region libs/shared/common/src/data-structures/Hinkal/prepareDepositOnChainUtxosZkProof.ts
var l = async (l, u, d, f, p, m = {}) => {
	let h = d.erc20TokenAddress, g = f.map((e) => e + o(e, p)), _ = g.reduce((e, t) => e + t, 0n), v = [h], y = [0n], b = [!0], x = c.AbiCoder.defaultAbiCoder().encode(["uint256[]"], [g]), { hinkalWrapperAddress: S, hinkalWrapperABI: C, depositOnChainUtxosExternalActionAddress: w, depositOnChainUtxosExternalActionABI: T } = t[u].contractData;
	if (!S || !C || !w || !T) throw Error("contract data not set in networkRegistry");
	let E = [...await i(l, u, v, y)], D = [];
	for (let e = 0; e < E.length; e += 1) {
		let { outputUtxos: t } = a(l.userKeys, E[e], y[e]);
		D.push(t);
	}
	let { zkCallData: O, circomData: k, dimData: A } = await s(l.merkleTreeHinkalByChain[u], E, D, l.userKeys, e.DepositOnChainUtxos, w, x, l.generateProofRemotely, r, n, u, b, m.hookData, S);
	return {
		zkCallData: O,
		circomData: k,
		dimData: A,
		utxoAmounts: g,
		totalAmount: _,
		hinkalWrapperAddress: S,
		depositOnChainUtxosExternalActionAddress: w,
		hinkalWrapperABI: C,
		depositOnChainUtxosExternalActionABI: T,
		inputUtxosArray: E
	};
};
//#endregion
export { l as prepareDepositOnChainUtxosZkProof };
