const e=require(`../../_virtual/_rolldown/runtime.cjs`),t=require(`../../data-structures/http/HttpClient.cjs`),n=require(`../utils/bytes32.utils.cjs`),r=require(`./common.snarkjs.cjs`),i=require(`./getZKFiles.cjs`),a=require(`../pre-transaction/solana-public-signals.cjs`);let o=require(`ethers`),s=require(`snarkjs`);s=e.__toESM(s);var c=e=>e.flat().map(e=>BigInt(e).toString()),l=(e,t)=>{let n=t.inNullifiers[0]?.length??0;return i.getVKFile(`commitmentCalculator${t.tokenAddresses.length}x${n}`,e)},u=async(e,n)=>{let r=l(e,n);return t.httpClient.get(r)},d=e=>({pi_a:[...e.a],pi_b:[[e.b[0][1],e.b[0][0]],[e.b[1][1],e.b[1][0]]],pi_c:[...e.c],protocol:`groth16`}),f=e=>{let t=e.tokenAddresses.map(e=>o.ethers.getBigInt(e).toString()),n=c(e.inCommitments),r=c(e.inNullifiers);return[...t,...n,...r]},p=async(e,t,n)=>{if(c(t.inNullifiers).join(`,`)!==n.join(`,`))throw Error(`commitmentValidationData.inNullifiers mismatch with request input`);let r=await u(e,t),i=f(t),a=d(t.proof);if(!await s.groth16.verify(r,i,a))throw Error(`Invalid commitment validation proof`)},m=async e=>{let t=e.commitmentValidationData;if(!t)return;let n=c(r.deserializeCircomData(e.circomData).inputNullifiers);await p(e.chainId,t,n)},h=async e=>{let t=e.commitmentValidationData;if(!t)return;let r=a.convertSolanaPublicSignals(e.args.publicInputsArr,e.args.dimensions).inNullifiers.flat().map(e=>n.convertBytes32ToBigInt(e).toString());await p(e.chainId,t,r)};exports.verifyCommitmentValidationData=m,exports.verifyCommitmentValidationDataSolana=h;