import { H as u, a2 as a, cj as p, c5 as f, a7 as c, cv as x, g as y, df as m, G as o, cI as b, dg as k, dh as w } from "./platform-Cil_UtAQ.mjs";
const $ = new RegExp("^bytes([0-9]+)$"), l = new RegExp("^(u?int)([0-9]*)$"), B = new RegExp("^(.*)\\[([0-9]*)\\]$");
function d(e, t, i) {
  switch (e) {
    case "address":
      return i ? c(o(t, 32)) : c(y(t));
    case "string":
      return x(t);
    case "bytes":
      return c(t);
    case "bool":
      return t = t ? "0x01" : "0x00", i ? c(o(t, 32)) : c(t);
  }
  let n = e.match(l);
  if (n) {
    let r = n[1] === "int", s = parseInt(n[2] || "256");
    return a((!n[2] || n[2] === String(s)) && s % 8 === 0 && s !== 0 && s <= 256, "invalid number type", "type", e), i && (s = 256), r && (t = m(t, s)), c(o(b(t), s / 8));
  }
  if (n = e.match($), n) {
    const r = parseInt(n[1]);
    return a(String(r) === n[1] && r !== 0 && r <= 32, "invalid bytes type", "type", e), a(k(t) === r, `invalid value for ${e}`, "value", t), i ? c(w(t, 32)) : t;
  }
  if (n = e.match(B), n && Array.isArray(t)) {
    const r = n[1], s = parseInt(n[2] || String(t.length));
    a(s === t.length, `invalid array length for ${e}`, "value", t);
    const g = [];
    return t.forEach(function(h) {
      g.push(d(r, h, !0));
    }), c(f(g));
  }
  a(!1, "invalid type", "type", e);
}
function E(e, t) {
  a(e.length === t.length, "wrong number of values; expected ${ types.length }", "values", t);
  const i = [];
  return e.forEach(function(n, r) {
    i.push(d(n, t[r]));
  }), p(f(i));
}
function I(e, t) {
  return u(E(e, t));
}
export {
  E as a,
  I as s
};
