require(`../../constants/protocol.constants.cjs`);const e=require(`../../types/ethereum-network.types.cjs`),t=require(`../../error-handling/error-codes.constants.cjs`),n=require(`../../functions/utils/time.utils.cjs`),r=require(`../../functions/utils/token-check.utils.cjs`),i=require(`../../functions/web3/events/getShieldedBalance.cjs`),a=require(`../../functions/pre-transaction/outputUtxoProcessing.cjs`),o=require(`../../functions/pre-transaction/constructAdminData.cjs`),s=require(`../../functions/pre-transaction/getFeeStructure.cjs`),c=require(`../../functions/pre-transaction/getKycAndSignatureData.cjs`),l=require(`../../functions/pre-transaction/buildCommitmentValidationData.cjs`);require(`../../functions/pre-transaction/index.cjs`);const u=require(`../../functions/snarkjs/constructGeneralZkProof.cjs`),d=require(`../../functions/web3/functionCalls/transactCallRelayer.cjs`),f=require(`../../functions/pre-transaction/getExternalSwapAddress.cjs`),p=require(`../../functions/pre-transaction/merge-with-fee-structure.cjs`);var m=async(e,t,r,o)=>{let s=[...await i.addPaddingToUtxos(e,t,r,o)],c=[],l=n.getCurrentTimeInSeconds().toString();for(let t=0;t<r.length;t+=1){let{outputUtxos:n}=a.outputUtxoProcessing(e.userKeys,s[t],o[t],l);c.push(n)}return{inputUtxosArray:s,outputUtxosArray:c}},h=async(n,i,a,h,g,_,v,y)=>{let b=r.validateAndGetChainId(i),x=i.map(e=>e.erc20TokenAddress),S=await n.getEthereumAddressByChain(b),C=v??await s.getFeeStructure(b,_,x,h,void 0,35n);p.mergeWithFeeStructure(b,x,a,C);let w={externalActionId:h,externalAddress:f.getExternalSwapAddress(b,h),externalActionMetadata:g},[T,{patchAccessTokenMerkleTree:E,signatureData:D},{inputUtxosArray:O,outputUtxosArray:k}]=await Promise.all([n.getRandomRelay(b,!0),c.getKycAndSignatureData(n,b,x,a,S),m(n,b,x,a)]);if(!T)throw Error(t.transactionErrorCodes.RELAYER_NOT_AVAILABLE);let A=`swapperM${a.length.toString()}x${O[0].length}x1`,j=[!1,!0,!1].slice(0,a.length),[{zkCallData:M,circomData:N,dimData:P},F]=await Promise.all([u.constructZkProof(n.merkleTreeHinkalByChain[b],n.merkleTreeAccessTokenByChain[b],O,k,n.userKeys,A,w.externalActionId,w.externalAddress,w.externalActionMetadata,n.generateProofRemotely,T,b,j,void 0,void 0,E,void 0,C,n.getContractWithFetcher(b,e.ContractType.HinkalHelperContract),D),l.buildCommitmentValidationData(b,n.userKeys,x,O)]);return await d.transactCallRelayer(b,M,P,N,F,void 0,void 0,o.constructAdminData(y,b,x,a,S,i))};exports.hinkalSwap=h;