const e=require(`../../constants/protocol.constants.cjs`),t=require(`../../types/ethereum-network.types.cjs`),n=require(`../../types/admin.types.cjs`);require(`../../types/index.cjs`);const r=require(`../../error-handling/error-codes.constants.cjs`),i=require(`../../functions/utils/time.utils.cjs`),a=require(`../utxo/Utxo.cjs`),o=require(`../../functions/utils/addresses.cjs`),s=require(`../../functions/utils/token-check.utils.cjs`),c=require(`../../functions/web3/events/getShieldedBalance.cjs`),l=require(`../../functions/pre-transaction/outputUtxoProcessing.cjs`),u=require(`../../functions/pre-transaction/constructAdminData.cjs`),d=require(`../../functions/pre-transaction/getKycAndSignatureData.cjs`),f=require(`../../functions/snarkjs/constructGeneralZkProof.cjs`),p=require(`../../functions/web3/functionCalls/transactCallDirect.cjs`),m=require(`../../API/admin-calls.cjs`);var h=async(e,t,n,r)=>{let i=await e.getEthereumAddressByChain(t),{patchAccessTokenMerkleTree:a,signatureData:o}=await d.getKycAndSignatureData(e,t,n,r,i);return{signatureData:o,externalActionData:{externalActionId:0n,externalAddress:i,externalActionMetadata:`0x00`},contractTransaction:void 0,contractToApprove:void 0,patchAccessTokenMerkleTree:a}},g=async(e,t,n,r)=>{let a=[...await c.addPaddingToUtxos(e,t,n,r)],o=[],s=i.getCurrentTimeInSeconds().toString();for(let t=0;t<n.length;t+=1){let{outputUtxos:n}=l.outputUtxoProcessing(e.userKeys,a[t],r[t],s);o.push(n)}return{inputUtxosArray:a,outputUtxosArray:o}},_=async(r,i,a,o=!0,c=!1)=>{let l=s.validateAndGetChainId(i),d=i.map(e=>e.erc20TokenAddress),[{externalActionData:_,contractTransaction:v,contractToApprove:y,patchAccessTokenMerkleTree:b,signatureData:x},{inputUtxosArray:S,outputUtxosArray:C}]=await Promise.all([h(r,l,d,a),g(r,l,d,a)]),w=`swapperM${a.length.toString()}x${S[0].length}x1`,{zkCallData:T,circomData:E,dimData:D}=await f.constructZkProof(r.merkleTreeHinkalByChain[l],r.merkleTreeAccessTokenByChain[l],S,C,r.userKeys,w,_.externalActionId,_.externalAddress,_.externalActionMetadata,r.generateProofRemotely,e.zeroAddress,l,void 0,void 0,void 0,b,void 0,void 0,r.getContractWithFetcher(l,t.ContractType.HinkalHelperContract),x),O=await p.transactCallDirect(r,l,a,i,T,E,D,y,v,o,c);return m.emitTxPublicData(u.constructAdminData(n.AdminTransactionType.Onboarding,l,d,a,await r.getEthereumAddress())),O},v=async(i,c,l,d,g=!0,_=!1)=>{let v=s.validateAndGetChainId(c),y=c.map(e=>e.erc20TokenAddress),[b,x,S]=d.split(`,`);if(!o.isValidPrivateAddress(d))throw Error(r.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);let C=y.map(e=>[new a.Utxo({amount:0n,erc20TokenAddress:e,shieldedPrivateKey:i.userKeys.getShieldedPrivateKey()}),new a.Utxo({amount:0n,erc20TokenAddress:e,shieldedPrivateKey:i.userKeys.getShieldedPrivateKey()})]),w=`swapperM${l.length.toString()}x${C[0].length}x1`,T=y.map((e,t)=>[new a.Utxo({amount:l[t],erc20TokenAddress:e,randomization:BigInt(b),stealthAddress:x,encryptionKey:S})]),{externalActionData:E,contractTransaction:D,contractToApprove:O,patchAccessTokenMerkleTree:k}=await h(i,v,y,l),{zkCallData:A,circomData:j,dimData:M}=await f.constructZkProof(i.merkleTreeHinkalByChain[v],i.merkleTreeAccessTokenByChain[v],C,T,i.userKeys,w,E.externalActionId,E.externalAddress,E.externalActionMetadata,i.generateProofRemotely,e.zeroAddress,v,void 0,void 0,void 0,k,void 0,void 0,i.getContractWithFetcher(v,t.ContractType.HinkalHelperContract)),N=await p.transactCallDirect(i,v,l,c,A,j,M,O,D,g,_);return m.emitTxPublicData(u.constructAdminData(n.AdminTransactionType.PaymentLink,v,y,l,await i.getEthereumAddress())),N};exports.hinkalDeposit=_,exports.hinkalDepositForOther=v;