import { L as p, f as B, b as D, i as b, a as d } from "./index-D-wp6FoM.mjs";
import { cG as $, dD as G } from "./index-AQHVSZ4p.mjs";
const M = "bignumber/5.7.0";
var N = $.BN;
const l = new p(M), E = {}, O = 9007199254740991;
let T = !1;
class c {
  constructor(r, n) {
    r !== E && l.throwError("cannot call constructor directly; use BigNumber.from", p.errors.UNSUPPORTED_OPERATION, {
      operation: "new (BigNumber)"
    }), this._hex = n, this._isBigNumber = !0, Object.freeze(this);
  }
  fromTwos(r) {
    return s(o(this).fromTwos(r));
  }
  toTwos(r) {
    return s(o(this).toTwos(r));
  }
  abs() {
    return this._hex[0] === "-" ? c.from(this._hex.substring(1)) : this;
  }
  add(r) {
    return s(o(this).add(o(r)));
  }
  sub(r) {
    return s(o(this).sub(o(r)));
  }
  div(r) {
    return c.from(r).isZero() && a("division-by-zero", "div"), s(o(this).div(o(r)));
  }
  mul(r) {
    return s(o(this).mul(o(r)));
  }
  mod(r) {
    const n = o(r);
    return n.isNeg() && a("division-by-zero", "mod"), s(o(this).umod(n));
  }
  pow(r) {
    const n = o(r);
    return n.isNeg() && a("negative-power", "pow"), s(o(this).pow(n));
  }
  and(r) {
    const n = o(r);
    return (this.isNegative() || n.isNeg()) && a("unbound-bitwise-result", "and"), s(o(this).and(n));
  }
  or(r) {
    const n = o(r);
    return (this.isNegative() || n.isNeg()) && a("unbound-bitwise-result", "or"), s(o(this).or(n));
  }
  xor(r) {
    const n = o(r);
    return (this.isNegative() || n.isNeg()) && a("unbound-bitwise-result", "xor"), s(o(this).xor(n));
  }
  mask(r) {
    return (this.isNegative() || r < 0) && a("negative-width", "mask"), s(o(this).maskn(r));
  }
  shl(r) {
    return (this.isNegative() || r < 0) && a("negative-width", "shl"), s(o(this).shln(r));
  }
  shr(r) {
    return (this.isNegative() || r < 0) && a("negative-width", "shr"), s(o(this).shrn(r));
  }
  eq(r) {
    return o(this).eq(o(r));
  }
  lt(r) {
    return o(this).lt(o(r));
  }
  lte(r) {
    return o(this).lte(o(r));
  }
  gt(r) {
    return o(this).gt(o(r));
  }
  gte(r) {
    return o(this).gte(o(r));
  }
  isNegative() {
    return this._hex[0] === "-";
  }
  isZero() {
    return o(this).isZero();
  }
  toNumber() {
    try {
      return o(this).toNumber();
    } catch {
      a("overflow", "toNumber", this.toString());
    }
    return null;
  }
  toBigInt() {
    try {
      return BigInt(this.toString());
    } catch {
    }
    return l.throwError("this platform does not support BigInt", p.errors.UNSUPPORTED_OPERATION, {
      value: this.toString()
    });
  }
  toString() {
    return arguments.length > 0 && (arguments[0] === 10 ? T || (T = !0, l.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")) : arguments[0] === 16 ? l.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()", p.errors.UNEXPECTED_ARGUMENT, {}) : l.throwError("BigNumber.toString does not accept parameters", p.errors.UNEXPECTED_ARGUMENT, {})), o(this).toString(10);
  }
  toHexString() {
    return this._hex;
  }
  toJSON(r) {
    return { type: "BigNumber", hex: this.toHexString() };
  }
  static from(r) {
    if (r instanceof c)
      return r;
    if (typeof r == "string")
      return r.match(/^-?0x[0-9a-f]+$/i) ? new c(E, m(r)) : r.match(/^-?[0-9]+$/) ? new c(E, m(new N(r))) : l.throwArgumentError("invalid BigNumber string", "value", r);
    if (typeof r == "number")
      return r % 1 && a("underflow", "BigNumber.from", r), (r >= O || r <= -O) && a("overflow", "BigNumber.from", r), c.from(String(r));
    const n = r;
    if (typeof n == "bigint")
      return c.from(n.toString());
    if (B(n))
      return c.from(D(n));
    if (n)
      if (n.toHexString) {
        const e = n.toHexString();
        if (typeof e == "string")
          return c.from(e);
      } else {
        let e = n._hex;
        if (e == null && n.type === "BigNumber" && (e = n.hex), typeof e == "string" && (b(e) || e[0] === "-" && b(e.substring(1))))
          return c.from(e);
      }
    return l.throwArgumentError("invalid BigNumber value", "value", r);
  }
  static isBigNumber(r) {
    return !!(r && r._isBigNumber);
  }
}
function m(t) {
  if (typeof t != "string")
    return m(t.toString(16));
  if (t[0] === "-")
    return t = t.substring(1), t[0] === "-" && l.throwArgumentError("invalid hex", "value", t), t = m(t), t === "0x00" ? t : "-" + t;
  if (t.substring(0, 2) !== "0x" && (t = "0x" + t), t === "0x")
    return "0x00";
  for (t.length % 2 && (t = "0x0" + t.substring(2)); t.length > 4 && t.substring(0, 4) === "0x00"; )
    t = "0x" + t.substring(4);
  return t;
}
function s(t) {
  return c.from(m(t));
}
function o(t) {
  const r = c.from(t).toHexString();
  return r[0] === "-" ? new N("-" + r.substring(3), 16) : new N(r.substring(2), 16);
}
function a(t, r, n) {
  const e = { fault: t, operation: r };
  return n != null && (e.value = n), l.throwError(t, p.errors.NUMERIC_FAULT, e);
}
function P(t) {
  return new N(t, 36).toString(16);
}
const X = "properties/5.7.0", F = new p(X);
function L(t, r, n) {
  Object.defineProperty(t, r, {
    enumerable: !0,
    value: n,
    writable: !1
  });
}
function et(t, r) {
  for (let n = 0; n < 32; n++) {
    if (t[r])
      return t[r];
    if (!t.prototype || typeof t.prototype != "object")
      break;
    t = Object.getPrototypeOf(t.prototype).constructor;
  }
  return null;
}
const H = { bigint: !0, boolean: !0, function: !0, number: !0, string: !0 };
function k(t) {
  if (t == null || H[typeof t])
    return !0;
  if (Array.isArray(t) || typeof t == "object") {
    if (!Object.isFrozen(t))
      return !1;
    const r = Object.keys(t);
    for (let n = 0; n < r.length; n++) {
      let e = null;
      try {
        e = t[r[n]];
      } catch {
        continue;
      }
      if (!k(e))
        return !1;
    }
    return !0;
  }
  return F.throwArgumentError(`Cannot deepCopy ${typeof t}`, "object", t);
}
function z(t) {
  if (k(t))
    return t;
  if (Array.isArray(t))
    return Object.freeze(t.map((r) => A(r)));
  if (typeof t == "object") {
    const r = {};
    for (const n in t) {
      const e = t[n];
      e !== void 0 && L(r, n, A(e));
    }
    return r;
  }
  return F.throwArgumentError(`Cannot deepCopy ${typeof t}`, "object", t);
}
function A(t) {
  return z(t);
}
class it {
  constructor(r) {
    for (const n in r)
      this[n] = A(r[n]);
  }
}
function V(t) {
  return "0x" + G.keccak_256(d(t));
}
const v = "address/5.7.0", x = new p(v);
function U(t) {
  b(t, 20) || x.throwArgumentError("invalid address", "address", t), t = t.toLowerCase();
  const r = t.substring(2).split(""), n = new Uint8Array(40);
  for (let i = 0; i < 40; i++)
    n[i] = r[i].charCodeAt(0);
  const e = d(V(n));
  for (let i = 0; i < 40; i += 2)
    e[i >> 1] >> 4 >= 8 && (r[i] = r[i].toUpperCase()), (e[i >> 1] & 15) >= 8 && (r[i + 1] = r[i + 1].toUpperCase());
  return "0x" + r.join("");
}
const K = 9007199254740991;
function Z(t) {
  return Math.log10 ? Math.log10(t) : Math.log(t) / Math.LN10;
}
const S = {};
for (let t = 0; t < 10; t++)
  S[String(t)] = String(t);
for (let t = 0; t < 26; t++)
  S[String.fromCharCode(65 + t)] = String(10 + t);
const _ = Math.floor(Z(K));
function q(t) {
  t = t.toUpperCase(), t = t.substring(4) + t.substring(0, 2) + "00";
  let r = t.split("").map((e) => S[e]).join("");
  for (; r.length >= _; ) {
    let e = r.substring(0, _);
    r = parseInt(e, 10) % 97 + r.substring(e.length);
  }
  let n = String(98 - parseInt(r, 10) % 97);
  for (; n.length < 2; )
    n = "0" + n;
  return n;
}
function ot(t) {
  let r = null;
  if (typeof t != "string" && x.throwArgumentError("invalid address", "address", t), t.match(/^(0x)?[0-9a-fA-F]{40}$/))
    t.substring(0, 2) !== "0x" && (t = "0x" + t), r = U(t), t.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && r !== t && x.throwArgumentError("bad address checksum", "address", t);
  else if (t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
    for (t.substring(2, 4) !== q(t) && x.throwArgumentError("bad icap checksum", "address", t), r = P(t.substring(4)); r.length < 40; )
      r = "0" + r;
    r = U("0x" + r);
  } else
    x.throwArgumentError("invalid address", "address", t);
  return r;
}
const J = "strings/5.7.0", R = new p(J);
var w;
(function(t) {
  t.current = "", t.NFC = "NFC", t.NFD = "NFD", t.NFKC = "NFKC", t.NFKD = "NFKD";
})(w || (w = {}));
var h;
(function(t) {
  t.UNEXPECTED_CONTINUE = "unexpected continuation byte", t.BAD_PREFIX = "bad codepoint prefix", t.OVERRUN = "string overrun", t.MISSING_CONTINUE = "missing continuation byte", t.OUT_OF_RANGE = "out of UTF-8 range", t.UTF16_SURROGATE = "UTF-16 surrogate", t.OVERLONG = "overlong representation";
})(h || (h = {}));
function Q(t, r, n, e, i) {
  return R.throwArgumentError(`invalid codepoint at offset ${r}; ${t}`, "bytes", n);
}
function I(t, r, n, e, i) {
  if (t === h.BAD_PREFIX || t === h.UNEXPECTED_CONTINUE) {
    let f = 0;
    for (let u = r + 1; u < n.length && n[u] >> 6 === 2; u++)
      f++;
    return f;
  }
  return t === h.OVERRUN ? n.length - r - 1 : 0;
}
function W(t, r, n, e, i) {
  return t === h.OVERLONG ? (e.push(i), 0) : (e.push(65533), I(t, r, n));
}
const Y = Object.freeze({
  error: Q,
  ignore: I,
  replace: W
});
function j(t, r) {
  r == null && (r = Y.error), t = d(t);
  const n = [];
  let e = 0;
  for (; e < t.length; ) {
    const i = t[e++];
    if (!(i >> 7)) {
      n.push(i);
      continue;
    }
    let f = null, u = null;
    if ((i & 224) === 192)
      f = 1, u = 127;
    else if ((i & 240) === 224)
      f = 2, u = 2047;
    else if ((i & 248) === 240)
      f = 3, u = 65535;
    else {
      (i & 192) === 128 ? e += r(h.UNEXPECTED_CONTINUE, e - 1, t, n) : e += r(h.BAD_PREFIX, e - 1, t, n);
      continue;
    }
    if (e - 1 + f >= t.length) {
      e += r(h.OVERRUN, e - 1, t, n);
      continue;
    }
    let g = i & (1 << 8 - f - 1) - 1;
    for (let y = 0; y < f; y++) {
      let C = t[e];
      if ((C & 192) != 128) {
        e += r(h.MISSING_CONTINUE, e, t, n), g = null;
        break;
      }
      g = g << 6 | C & 63, e++;
    }
    if (g !== null) {
      if (g > 1114111) {
        e += r(h.OUT_OF_RANGE, e - 1 - f, t, n, g);
        continue;
      }
      if (g >= 55296 && g <= 57343) {
        e += r(h.UTF16_SURROGATE, e - 1 - f, t, n, g);
        continue;
      }
      if (g <= u) {
        e += r(h.OVERLONG, e - 1 - f, t, n, g);
        continue;
      }
      n.push(g);
    }
  }
  return n;
}
function ft(t, r = w.current) {
  r != w.current && (R.checkNormalize(), t = t.normalize(r));
  let n = [];
  for (let e = 0; e < t.length; e++) {
    const i = t.charCodeAt(e);
    if (i < 128)
      n.push(i);
    else if (i < 2048)
      n.push(i >> 6 | 192), n.push(i & 63 | 128);
    else if ((i & 64512) == 55296) {
      e++;
      const f = t.charCodeAt(e);
      if (e >= t.length || (f & 64512) !== 56320)
        throw new Error("invalid utf-8 string");
      const u = 65536 + ((i & 1023) << 10) + (f & 1023);
      n.push(u >> 18 | 240), n.push(u >> 12 & 63 | 128), n.push(u >> 6 & 63 | 128), n.push(u & 63 | 128);
    } else
      n.push(i >> 12 | 224), n.push(i >> 6 & 63 | 128), n.push(i & 63 | 128);
  }
  return d(n);
}
function tt(t) {
  return t.map((r) => r <= 65535 ? String.fromCharCode(r) : (r -= 65536, String.fromCharCode((r >> 10 & 1023) + 55296, (r & 1023) + 56320))).join("");
}
function st(t, r) {
  return tt(j(t, r));
}
export {
  c as B,
  it as D,
  st as a,
  et as b,
  L as d,
  ot as g,
  V as k,
  ft as t
};
