import { chainIds as e } from "../../constants/chains.constants.mjs";
import { encodeToByte32Array as t } from "../pre-transaction/solana.mjs";
import { hinkalCheckSolanaTokenRegistry as n } from "../../data-structures/Hinkal/hinkalCheckSolanaTokenRegistry.mjs";
import { formatMintAddress as r } from "../utils/solanaMint.utils.mjs";
import { calcAmountChanges as i } from "./common.snarkjs.mjs";
import { generateZkProof as a } from "./generateZkProof.mjs";
import "../pre-transaction/index.mjs";
import { getDataFromWorkers as o } from "./getMerkleTreeSiblingsAndRootHashes.mjs";
import { getSolanaCalldataHash as s } from "../pre-transaction/getSolanaCalldataHash.mjs";
import { PublicKey as c } from "@solana/web3.js";
//#region libs/shared/common/src/functions/snarkjs/constructSolanaZkProof.ts
var l = async (l, u, d, f, p, m, h, g, _, v, y, b, x, S, C, w, T = e.solanaLocalnet, E = !1, D = 0n, O = [], k = []) => {
	let A = new c(x), j = new c(S), M = p.getShieldedPrivateKey(), N = h.map((e) => r(e)), P = N.map((e) => e.mintAccountPart1), F = N.map((e) => e.mintAccountPart2), I = s(C, A, j, w, y, b, O, k), L = `${C.tokenNumber}x${C.nullifierAmount}x${C.outputAmount}`, R = i(g, _), z = await n(m, new c(u), h, R), { inCommitmentSiblings: B, inCommitmentSiblingSides: V, accessTokenSiblings: H, accessTokenSiblingSides: U, rootHashHinkal: W, rootHashAccessToken: G, inNullifiers: K } = await o(T, d, f, p, g.map((e) => e.map((e) => e.getConstructableParams())), E, z), q = {
		rootHashHinkal: W,
		shieldedPrivateKey: M,
		rootHashAccessToken: G,
		accessTokenSiblings: H,
		accessTokenSiblingSides: U,
		mintAccountPart1: P,
		mintAccountPart2: F,
		inAmounts: g.map((e) => e.map((e) => e.amount)),
		inTimeStamps: g.map((e) => e.map((e) => e.timeStamp)),
		inRandomizations: g.map((e) => e.map((e) => e.randomization)),
		inNullifiers: K,
		inCommitmentSiblings: B,
		inCommitmentSiblingSides: V,
		outAmounts: _.map((e) => e.map((e) => e.amount.toString())),
		outTimeStamp: BigInt(_[0][0].timeStamp),
		outPublicKeys: _.map((e) => e.map((e) => e.getStealthAddress())),
		extraRandomization: v,
		amountChanges: R,
		outCommitments: _.map((e) => e.map((e) => e.amount === 0n ? 0n : e.getCommitment())),
		calldataHash: I,
		swapperAccountSalt: D
	}, { publicSignals: J, zkCallData: Y } = await a(T, `basicSolana${L}`, q, l), [X, Z, Q] = Y;
	return {
		proofAArr: X.map(BigInt).map(t).flat(),
		proofBArr: Z.flat().map(BigInt).map(t).flat(),
		proofCArr: Q.map(BigInt).map(t).flat(),
		publicInputsArr: J.map(BigInt).map(t)
	};
};
//#endregion
export { l as constructSolanaZkProof };
