import { waitLittle as e } from "../utils/time.utils.mjs";
//#region libs/shared/common/src/functions/pre-transaction/waitForDepositedUtxosInMerkleTree.ts
var t = 60, n = (e, t) => {
	if (!e.length) return !0;
	let n = new Set(t.map((e) => e.toString()));
	return e.every(({ utxo: e }) => {
		let t = BigInt(e.getCommitment());
		return n.has(t.toString());
	});
}, r = (e, t, n = 20) => {
	let r = e.merkleTreeHinkalByChain[t], i = r.getStartIndex(), { count: a } = r.toJSON(), o = BigInt(a);
	if (o === 0n) return [];
	let s = r.getMerkleData(), c = [], l = o < BigInt(n) ? o : BigInt(n);
	for (let e = 0n; e < l; e += 1n) {
		let t = i + o - 1n - e, n = s.get(t);
		n && n !== 0n && c.push(n);
	}
	return c;
}, i = async (i, a, o) => {
	if (o.length) {
		for (let s = 0; s < t; s += 1) {
			if (n(o, r(i, a))) return;
			await e();
		}
		throw Error("Timeout while waiting for deposited UTXOs to appear in Merkle tree.");
	}
};
//#endregion
export { i as waitForDepositedUtxosInMerkleTree };
