require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`),t=require(`../web3/etherFunctions.cjs`),n=require(`../../crypto/poseidon.cjs`),r=require(`../utils/bit.operations.cjs`),i=require(`../utils/solanaMint.utils.cjs`),a=require(`./common.snarkjs.cjs`),o=require(`../pre-transaction/solana.cjs`),s=require(`./signedMessageHash.cjs`),c=require(`./generateZkProof.cjs`);require(`../pre-transaction/index.cjs`),require(`../utils/index.cjs`);const l=require(`./getMerkleTreeSiblingsAndRootHashes.cjs`),u=require(`../pre-transaction/getSolanaCalldataHash.cjs`);require(`../web3/index.cjs`);let d=require(`@solana/web3.js`);var f=async(f,p,m,h,g,_,v,y,b,x,S,C,w,T=e.chainIds.solanaLocalnet,E=[],D=[],O=0n)=>{let k=new d.PublicKey(x),A=new d.PublicKey(S),j=m.getShieldedPrivateKey(),{pubSpendingBJJPoint:M}=m.getSpendingKeyPair(),N=a.calcStealthAddressStructure(v,j,m.getSpendingKeyPair().pubSpendingBJJPoint),P=t.randomBigInt(31),F=n.poseidonFunction(P),I=n.poseidonFunction(O),L=h.map(e=>i.formatMintAddress(e)),R=L.map(e=>e.mintAccountPart1),z=L.map(e=>e.mintAccountPart2),B=u.getSolanaCalldataHash(C,k,A,w,y,b,E,D),V=`${C.tokenNumber}x${C.nullifierAmount}x${C.outputAmount}`,H=a.calcAmountChanges(g,_),{inCommitmentSiblings:U,inCommitmentSiblingSides:W,rootHashHinkal:G,inNullifiers:K}=await l.getDataFromWorkers(T,p,g.map(e=>e.map(e=>e.getConstructableParams()))),q=a.buildOutCommitments(_),J=r.takeOffHighestBit(N.extraRandomization),Y=N.H0,X=s.computeSignedMessageHashSolana({rootHashHinkal:G,mintAccountPart1:R,mintAccountPart2:z,amountChanges:H,outTimeStamp:BigInt(_[0][0].timeStamp),inNullifiers:K,outCommitments:q,calldataHash:B,message:F,swapperAccountAdditionalSeed:I,outH1Ay:N.H1,H0Ax:J,H0Ay:Y}),{R8:Z,S:Q}=m.signEddsa(X),$={rootHashHinkal:G,spendingPublicKey:M,eddsaSignature:[Z[0],Z[1],Q],signedMessageHash:X,nullifyingPrivateKey:j,mintAccountPart1:R,mintAccountPart2:z,amountChanges:H,inAmounts:g.map(e=>e.map(e=>e.amount.toString())),inRandomizations:g.map(e=>e.map(e=>a.getUtxoCircuitInRandomization(e))),inH0Ax:g.map(e=>e.map(e=>a.getUtxoCircuitH0Coords(e)[0].toString())),inH0Ay:g.map(e=>e.map(e=>a.getUtxoCircuitH0Coords(e)[1].toString())),isNewStyle:g.map(e=>e.map(e=>!!e.isNewStyle)),inTimeStamps:g.map(e=>e.map(e=>e.timeStamp)),inNullifiers:K,inCommitmentSiblings:U,inCommitmentSiblingSides:W,outAmounts:_.map(e=>e.map(e=>e.amount.toString())),outTimeStamp:BigInt(_[0][0].timeStamp),outPublicKeys:_.map(e=>e.map(e=>e.getStealthAddress())),outCommitments:q,calldataHash:B,messageSeed:P,swapperAccountSalt:O,H0Ax:J,H0Ay:Y},{publicSignals:ee,zkCallData:te}=await c.generateZkProof(T,`mainSolanaCircuit${V}`,$,f),[ne,re,ie]=te;return{proofAArr:ne.map(BigInt).map(o.encodeToByte32Array).flat(),proofBArr:re.flat().map(BigInt).map(o.encodeToByte32Array).flat(),proofCArr:ie.map(BigInt).map(o.encodeToByte32Array).flat(),publicInputsArr:ee.map(BigInt).map(o.encodeToByte32Array)}};exports.constructSolanaZkProof=f;