require(`../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../../constants/chains.constants.cjs`),t=require(`../../../data-structures/crypto-keys/keys.cjs`),n=require(`../../../data-structures/utxo/Utxo.cjs`),r=require(`../../utils/encryptInputForEnclave.cjs`),i=require(`../../utils/solanaMint.utils.cjs`),a=require(`../../utils/customEnclaveFunctionsRegister.cjs`);let o=require(`ethers`),s=require(`@solana/web3.js`);var c=e=>{if(!e)return;let t=o.ethers.getBytes(e);if(t.length!==32)return;let n=new s.PublicKey(t),r=n.toBase58(),{compressedAddress:a}=i.formatMintAddress(n);return{mintBase58:r,compressedAddress:a}},l=async(e,t,n)=>{let{keyCiphertext:i,inputCiphertext:a}=await r.makeEnclaveHandshakeAndEncryptUint8Array(n);return e.getAPI().decryptUtxoEnclaveCall(t,i,a)},u=async(r,i,s)=>{let u=s.getShieldedPrivateKey(),{privateKey:d,publicKey:f}=t.UserKeys.getEncryptionKeyPair(u),p=s.getSpendingKeyPair().pubSpendingBJJPoint,m=o.ethers.solidityPacked([`uint256`,`uint256`,`uint256`],[f,d,u]),h=o.ethers.getBytes(m),g=a.getCustomUtxoDecryptor(),{utxos:_,lastOutput:v,encryptedOutputs:y}=await(g?g(i,h):l(r,i,h));return{utxos:_.map(t=>{let r=t;if(e.isSolanaLike(i)){let e=c(t.mintAddress);if(!e)throw Error(`Invalid mint address`);r={...r,erc20TokenAddress:e.compressedAddress,mintAddress:e.mintBase58}}return new n.Utxo({...r,amount:BigInt(r.amount),randomization:r.randomization?BigInt(r.randomization):void 0,nullifyingKey:u,spendingPublicKey:p,isNewStyle:r.isNewStyle,H0:r.H0?[BigInt(r.H0[0]),BigInt(r.H0[1])]:void 0})}),encryptedOutputs:y,lastOutput:v}};exports.getInputUtxosEnclave=u;