"use strict";const t=require("./platform-CCG_jgOO.js"),f=new RegExp("^bytes([0-9]+)$"),u=new RegExp("^(u?int)([0-9]*)$"),y=new RegExp("^(.*)\\[([0-9]*)\\]$");function g(n,e,i){switch(n){case"address":return i?t.getBytes(t.zeroPadValue(e,32)):t.getBytes(t.getAddress(e));case"string":return t.toUtf8Bytes(e);case"bytes":return t.getBytes(e);case"bool":return e=e?"0x01":"0x00",i?t.getBytes(t.zeroPadValue(e,32)):t.getBytes(e)}let r=n.match(u);if(r){let s=r[1]==="int",c=parseInt(r[2]||"256");return t.assertArgument((!r[2]||r[2]===String(c))&&c%8===0&&c!==0&&c<=256,"invalid number type","type",n),i&&(c=256),s&&(e=t.toTwos(e,c)),t.getBytes(t.zeroPadValue(t.toBeArray(e),c/8))}if(r=n.match(f),r){const s=parseInt(r[1]);return t.assertArgument(String(s)===r[1]&&s!==0&&s<=32,"invalid bytes type","type",n),t.assertArgument(t.dataLength(e)===s,`invalid value for ${n}`,"value",e),i?t.getBytes(t.zeroPadBytes(e,32)):e}if(r=n.match(y),r&&Array.isArray(e)){const s=r[1],c=parseInt(r[2]||String(e.length));t.assertArgument(c===e.length,`invalid array length for ${n}`,"value",e);const o=[];return e.forEach(function(d){o.push(g(s,d,!0))}),t.getBytes(t.concat(o))}t.assertArgument(!1,"invalid type","type",n)}function a(n,e){t.assertArgument(n.length===e.length,"wrong number of values; expected ${ types.length }","values",e);const i=[];return n.forEach(function(r,s){i.push(g(r,e[s]))}),t.hexlify(t.concat(i))}function h(n,e){return t.keccak256(a(n,e))}exports.solidityPacked=a;exports.solidityPackedKeccak256=h;
