import { CIRCOM_P as e } from "../../constants/protocol.constants.mjs";
import { encodeToByte32Array as t } from "../pre-transaction/solana.mjs";
import { ethers as n } from "ethers";
import { BN as r } from "@coral-xyz/anchor";
//#region libs/shared/common/src/functions/snarkjs/signedMessageHash.ts
var i = (e) => [...new r(e.length).toArray("be", 8), ...e.flatMap((e) => t(e))], a = (t) => BigInt(n.keccak256(t)) % e, o = [
	"uint256",
	"uint256[]",
	"uint256[]",
	"uint256",
	"uint256[]",
	"uint256[]",
	"uint256",
	"uint256",
	"uint256",
	"uint256",
	"uint256"
], s = (e) => a(n.AbiCoder.defaultAbiCoder().encode(o, [
	e.rootHashHinkal,
	e.erc20TokenAddresses.map((e) => n.getBigInt(e)),
	e.amountChanges,
	e.outTimeStamp,
	e.inNullifiers.flat().map((e) => BigInt(e)),
	e.outCommitments.flat().map((e) => BigInt(e)),
	e.calldataHash,
	e.message,
	e.outH1Ay,
	e.H0Ax,
	e.H0Ay
])), c = (r) => {
	let a = r.inNullifiers.flat().map((e) => BigInt(e)), o = r.outCommitments.flat().map((e) => BigInt(e)), s = [
		...t(r.rootHashHinkal),
		...i(r.mintAccountPart1),
		...i(r.mintAccountPart2),
		...i(r.amountChanges),
		...t(r.outTimeStamp),
		...i(a),
		...i(o),
		...t(r.calldataHash),
		...t(r.message),
		...t(r.swapperAccountAdditionalSeed),
		...t(r.outH1Ay),
		...t(r.H0Ax),
		...t(r.H0Ay)
	];
	return BigInt(n.sha256(new Uint8Array(s))) % e;
};
//#endregion
export { s as computeSignedMessageHashEvm, c as computeSignedMessageHashSolana };
