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