import { c3 as Q, cG as Y } from "./index-CTdUTRp6.mjs";
const rr = "logger/5.7.0";
let G = !1, L = !1;
const O = { debug: 1, default: 2, info: 2, warning: 3, error: 4, off: 5 };
let B = O.default, C = null;
function tr() {
  try {
    const r = [];
    if (["NFD", "NFC", "NFKD", "NFKC"].forEach((t) => {
      try {
        if ("test".normalize(t) !== "test")
          throw new Error("bad normalize");
      } catch {
        r.push(t);
      }
    }), r.length)
      throw new Error("missing " + r.join(", "));
    if ("é".normalize("NFD") !== "é")
      throw new Error("broken implementation");
  } catch (r) {
    return r.message;
  }
  return null;
}
const X = tr();
var M;
(function(r) {
  r.DEBUG = "DEBUG", r.INFO = "INFO", r.WARNING = "WARNING", r.ERROR = "ERROR", r.OFF = "OFF";
})(M || (M = {}));
var p;
(function(r) {
  r.UNKNOWN_ERROR = "UNKNOWN_ERROR", r.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", r.UNSUPPORTED_OPERATION = "UNSUPPORTED_OPERATION", r.NETWORK_ERROR = "NETWORK_ERROR", r.SERVER_ERROR = "SERVER_ERROR", r.TIMEOUT = "TIMEOUT", r.BUFFER_OVERRUN = "BUFFER_OVERRUN", r.NUMERIC_FAULT = "NUMERIC_FAULT", r.MISSING_NEW = "MISSING_NEW", r.INVALID_ARGUMENT = "INVALID_ARGUMENT", r.MISSING_ARGUMENT = "MISSING_ARGUMENT", r.UNEXPECTED_ARGUMENT = "UNEXPECTED_ARGUMENT", r.CALL_EXCEPTION = "CALL_EXCEPTION", r.INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS", r.NONCE_EXPIRED = "NONCE_EXPIRED", r.REPLACEMENT_UNDERPRICED = "REPLACEMENT_UNDERPRICED", r.UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT", r.TRANSACTION_REPLACED = "TRANSACTION_REPLACED", r.ACTION_REJECTED = "ACTION_REJECTED";
})(p || (p = {}));
const $ = "0123456789abcdef";
class o {
  constructor(t) {
    Object.defineProperty(this, "version", {
      enumerable: !0,
      value: t,
      writable: !1
    });
  }
  _log(t, e) {
    const n = t.toLowerCase();
    O[n] == null && this.throwArgumentError("invalid log level name", "logLevel", t), !(B > O[n]) && console.log.apply(console, e);
  }
  debug(...t) {
    this._log(o.levels.DEBUG, t);
  }
  info(...t) {
    this._log(o.levels.INFO, t);
  }
  warn(...t) {
    this._log(o.levels.WARNING, t);
  }
  makeError(t, e, n) {
    if (L)
      return this.makeError("censored error", e, {});
    e || (e = o.errors.UNKNOWN_ERROR), n || (n = {});
    const i = [];
    Object.keys(n).forEach((l) => {
      const R = n[l];
      try {
        if (R instanceof Uint8Array) {
          let U = "";
          for (let _ = 0; _ < R.length; _++)
            U += $[R[_] >> 4], U += $[R[_] & 15];
          i.push(l + "=Uint8Array(0x" + U + ")");
        } else
          i.push(l + "=" + JSON.stringify(R));
      } catch {
        i.push(l + "=" + JSON.stringify(n[l].toString()));
      }
    }), i.push(`code=${e}`), i.push(`version=${this.version}`);
    const f = t;
    let u = "";
    switch (e) {
      case p.NUMERIC_FAULT: {
        u = "NUMERIC_FAULT";
        const l = t;
        switch (l) {
          case "overflow":
          case "underflow":
          case "division-by-zero":
            u += "-" + l;
            break;
          case "negative-power":
          case "negative-width":
            u += "-unsupported";
            break;
          case "unbound-bitwise-result":
            u += "-unbound-result";
            break;
        }
        break;
      }
      case p.CALL_EXCEPTION:
      case p.INSUFFICIENT_FUNDS:
      case p.MISSING_NEW:
      case p.NONCE_EXPIRED:
      case p.REPLACEMENT_UNDERPRICED:
      case p.TRANSACTION_REPLACED:
      case p.UNPREDICTABLE_GAS_LIMIT:
        u = e;
        break;
    }
    u && (t += " [ See: https://links.ethers.org/v5-errors-" + u + " ]"), i.length && (t += " (" + i.join(", ") + ")");
    const h = new Error(t);
    return h.reason = f, h.code = e, Object.keys(n).forEach(function(l) {
      h[l] = n[l];
    }), h;
  }
  throwError(t, e, n) {
    throw this.makeError(t, e, n);
  }
  throwArgumentError(t, e, n) {
    return this.throwError(t, o.errors.INVALID_ARGUMENT, {
      argument: e,
      value: n
    });
  }
  assert(t, e, n, i) {
    t || this.throwError(e, n, i);
  }
  assertArgument(t, e, n, i) {
    t || this.throwArgumentError(e, n, i);
  }
  checkNormalize(t) {
    X && this.throwError("platform missing String.prototype.normalize", o.errors.UNSUPPORTED_OPERATION, {
      operation: "String.prototype.normalize",
      form: X
    });
  }
  checkSafeUint53(t, e) {
    typeof t == "number" && (e == null && (e = "value not safe"), (t < 0 || t >= 9007199254740991) && this.throwError(e, o.errors.NUMERIC_FAULT, {
      operation: "checkSafeInteger",
      fault: "out-of-safe-range",
      value: t
    }), t % 1 && this.throwError(e, o.errors.NUMERIC_FAULT, {
      operation: "checkSafeInteger",
      fault: "non-integer",
      value: t
    }));
  }
  checkArgumentCount(t, e, n) {
    n ? n = ": " + n : n = "", t < e && this.throwError("missing argument" + n, o.errors.MISSING_ARGUMENT, {
      count: t,
      expectedCount: e
    }), t > e && this.throwError("too many arguments" + n, o.errors.UNEXPECTED_ARGUMENT, {
      count: t,
      expectedCount: e
    });
  }
  checkNew(t, e) {
    (t === Object || t == null) && this.throwError("missing new", o.errors.MISSING_NEW, { name: e.name });
  }
  checkAbstract(t, e) {
    t === e ? this.throwError("cannot instantiate abstract class " + JSON.stringify(e.name) + " directly; use a sub-class", o.errors.UNSUPPORTED_OPERATION, { name: t.name, operation: "new" }) : (t === Object || t == null) && this.throwError("missing new", o.errors.MISSING_NEW, { name: e.name });
  }
  static globalLogger() {
    return C || (C = new o(rr)), C;
  }
  static setCensorship(t, e) {
    if (!t && e && this.globalLogger().throwError("cannot permanently disable censorship", o.errors.UNSUPPORTED_OPERATION, {
      operation: "setCensorship"
    }), G) {
      if (!t)
        return;
      this.globalLogger().throwError("error censorship permanent", o.errors.UNSUPPORTED_OPERATION, {
        operation: "setCensorship"
      });
    }
    L = !!t, G = !!e;
  }
  static setLogLevel(t) {
    const e = O[t.toLowerCase()];
    if (e == null) {
      o.globalLogger().warn("invalid log level - " + t);
      return;
    }
    B = e;
  }
  static from(t) {
    return new o(t);
  }
}
o.errors = p;
o.levels = M;
const er = "bytes/5.7.0", c = new o(er);
function K(r) {
  return !!r.toHexString;
}
function y(r) {
  return r.slice || (r.slice = function() {
    const t = Array.prototype.slice.call(arguments);
    return y(new Uint8Array(Array.prototype.slice.apply(r, t)));
  }), r;
}
function nr(r) {
  return x(r) && !(r.length % 2) || P(r);
}
function z(r) {
  return typeof r == "number" && r == r && r % 1 === 0;
}
function P(r) {
  if (r == null)
    return !1;
  if (r.constructor === Uint8Array)
    return !0;
  if (typeof r == "string" || !z(r.length) || r.length < 0)
    return !1;
  for (let t = 0; t < r.length; t++) {
    const e = r[t];
    if (!z(e) || e < 0 || e >= 256)
      return !1;
  }
  return !0;
}
function A(r, t) {
  if (t || (t = {}), typeof r == "number") {
    c.checkSafeUint53(r, "invalid arrayify value");
    const e = [];
    for (; r; )
      e.unshift(r & 255), r = parseInt(String(r / 256));
    return e.length === 0 && e.push(0), y(new Uint8Array(e));
  }
  if (t.allowMissingPrefix && typeof r == "string" && r.substring(0, 2) !== "0x" && (r = "0x" + r), K(r) && (r = r.toHexString()), x(r)) {
    let e = r.substring(2);
    e.length % 2 && (t.hexPad === "left" ? e = "0" + e : t.hexPad === "right" ? e += "0" : c.throwArgumentError("hex data is odd-length", "value", r));
    const n = [];
    for (let i = 0; i < e.length; i += 2)
      n.push(parseInt(e.substring(i, i + 2), 16));
    return y(new Uint8Array(n));
  }
  return P(r) ? y(new Uint8Array(r)) : c.throwArgumentError("invalid arrayify value", "value", r);
}
function Sr(r) {
  const t = r.map((i) => A(i)), e = t.reduce((i, f) => i + f.length, 0), n = new Uint8Array(e);
  return t.reduce((i, f) => (n.set(f, i), i + f.length), 0), y(n);
}
function ir(r, t) {
  r = A(r), r.length > t && c.throwArgumentError("value out of range", "value", arguments[0]);
  const e = new Uint8Array(t);
  return e.set(r, t - r.length), y(e);
}
function x(r, t) {
  return !(typeof r != "string" || !r.match(/^0x[0-9A-Fa-f]*$/) || t && r.length !== 2 + 2 * t);
}
const d = "0123456789abcdef";
function E(r, t) {
  if (t || (t = {}), typeof r == "number") {
    c.checkSafeUint53(r, "invalid hexlify value");
    let e = "";
    for (; r; )
      e = d[r & 15] + e, r = Math.floor(r / 16);
    return e.length ? (e.length % 2 && (e = "0" + e), "0x" + e) : "0x00";
  }
  if (typeof r == "bigint")
    return r = r.toString(16), r.length % 2 ? "0x0" + r : "0x" + r;
  if (t.allowMissingPrefix && typeof r == "string" && r.substring(0, 2) !== "0x" && (r = "0x" + r), K(r))
    return r.toHexString();
  if (x(r))
    return r.length % 2 && (t.hexPad === "left" ? r = "0x0" + r.substring(2) : t.hexPad === "right" ? r += "0" : c.throwArgumentError("hex data is odd-length", "value", r)), r.toLowerCase();
  if (P(r)) {
    let e = "0x";
    for (let n = 0; n < r.length; n++) {
      let i = r[n];
      e += d[(i & 240) >> 4] + d[i & 15];
    }
    return e;
  }
  return c.throwArgumentError("invalid hexlify value", "value", r);
}
function Ur(r) {
  if (typeof r != "string")
    r = E(r);
  else if (!x(r) || r.length % 2)
    return null;
  return (r.length - 2) / 2;
}
function _r(r, t, e) {
  return typeof r != "string" ? r = E(r) : (!x(r) || r.length % 2) && c.throwArgumentError("invalid hexData", "value", r), t = 2 + 2 * t, e != null ? "0x" + r.substring(t, 2 + 2 * e) : "0x" + r.substring(t);
}
function Or(r) {
  let t = "0x";
  return r.forEach((e) => {
    t += E(e).substring(2);
  }), t;
}
function D(r, t) {
  for (typeof r != "string" ? r = E(r) : x(r) || c.throwArgumentError("invalid hex string", "value", r), r.length > 2 * t + 2 && c.throwArgumentError("value out of range", "value", arguments[1]); r.length < 2 * t + 2; )
    r = "0x0" + r.substring(2);
  return r;
}
function Tr(r) {
  const t = {
    r: "0x",
    s: "0x",
    _vs: "0x",
    recoveryParam: 0,
    v: 0,
    yParityAndS: "0x",
    compact: "0x"
  };
  if (nr(r)) {
    let e = A(r);
    e.length === 64 ? (t.v = 27 + (e[32] >> 7), e[32] &= 127, t.r = E(e.slice(0, 32)), t.s = E(e.slice(32, 64))) : e.length === 65 ? (t.r = E(e.slice(0, 32)), t.s = E(e.slice(32, 64)), t.v = e[64]) : c.throwArgumentError("invalid signature string", "signature", r), t.v < 27 && (t.v === 0 || t.v === 1 ? t.v += 27 : c.throwArgumentError("signature invalid v byte", "signature", r)), t.recoveryParam = 1 - t.v % 2, t.recoveryParam && (e[32] |= 128), t._vs = E(e.slice(32, 64));
  } else {
    if (t.r = r.r, t.s = r.s, t.v = r.v, t.recoveryParam = r.recoveryParam, t._vs = r._vs, t._vs != null) {
      const i = ir(A(t._vs), 32);
      t._vs = E(i);
      const f = i[0] >= 128 ? 1 : 0;
      t.recoveryParam == null ? t.recoveryParam = f : t.recoveryParam !== f && c.throwArgumentError("signature recoveryParam mismatch _vs", "signature", r), i[0] &= 127;
      const u = E(i);
      t.s == null ? t.s = u : t.s !== u && c.throwArgumentError("signature v mismatch _vs", "signature", r);
    }
    if (t.recoveryParam == null)
      t.v == null ? c.throwArgumentError("signature missing v and recoveryParam", "signature", r) : t.v === 0 || t.v === 1 ? t.recoveryParam = t.v : t.recoveryParam = 1 - t.v % 2;
    else if (t.v == null)
      t.v = 27 + t.recoveryParam;
    else {
      const i = t.v === 0 || t.v === 1 ? t.v : 1 - t.v % 2;
      t.recoveryParam !== i && c.throwArgumentError("signature recoveryParam mismatch v", "signature", r);
    }
    t.r == null || !x(t.r) ? c.throwArgumentError("signature missing or invalid r", "signature", r) : t.r = D(t.r, 32), t.s == null || !x(t.s) ? c.throwArgumentError("signature missing or invalid s", "signature", r) : t.s = D(t.s, 32);
    const e = A(t.s);
    e[0] >= 128 && c.throwArgumentError("signature s out of range", "signature", r), t.recoveryParam && (e[0] |= 128);
    const n = E(e);
    t._vs && (x(t._vs) || c.throwArgumentError("signature invalid _vs", "signature", r), t._vs = D(t._vs, 32)), t._vs == null ? t._vs = n : t._vs !== n && c.throwArgumentError("signature _vs mismatch v and s", "signature", r);
  }
  return t.yParityAndS = t._vs, t.compact = t.r + t.yParityAndS.substring(2), t;
}
const sr = "bignumber/5.7.0";
var T = Q.BN;
const w = new o(sr), F = {}, or = 9007199254740991;
let H = !1;
class g {
  constructor(t, e) {
    t !== F && w.throwError("cannot call constructor directly; use BigNumber.from", o.errors.UNSUPPORTED_OPERATION, {
      operation: "new (BigNumber)"
    }), this._hex = e, this._isBigNumber = !0, Object.freeze(this);
  }
  fromTwos(t) {
    return a(s(this).fromTwos(t));
  }
  toTwos(t) {
    return a(s(this).toTwos(t));
  }
  abs() {
    return this._hex[0] === "-" ? g.from(this._hex.substring(1)) : this;
  }
  add(t) {
    return a(s(this).add(s(t)));
  }
  sub(t) {
    return a(s(this).sub(s(t)));
  }
  div(t) {
    return g.from(t).isZero() && m("division-by-zero", "div"), a(s(this).div(s(t)));
  }
  mul(t) {
    return a(s(this).mul(s(t)));
  }
  mod(t) {
    const e = s(t);
    return e.isNeg() && m("division-by-zero", "mod"), a(s(this).umod(e));
  }
  pow(t) {
    const e = s(t);
    return e.isNeg() && m("negative-power", "pow"), a(s(this).pow(e));
  }
  and(t) {
    const e = s(t);
    return (this.isNegative() || e.isNeg()) && m("unbound-bitwise-result", "and"), a(s(this).and(e));
  }
  or(t) {
    const e = s(t);
    return (this.isNegative() || e.isNeg()) && m("unbound-bitwise-result", "or"), a(s(this).or(e));
  }
  xor(t) {
    const e = s(t);
    return (this.isNegative() || e.isNeg()) && m("unbound-bitwise-result", "xor"), a(s(this).xor(e));
  }
  mask(t) {
    return (this.isNegative() || t < 0) && m("negative-width", "mask"), a(s(this).maskn(t));
  }
  shl(t) {
    return (this.isNegative() || t < 0) && m("negative-width", "shl"), a(s(this).shln(t));
  }
  shr(t) {
    return (this.isNegative() || t < 0) && m("negative-width", "shr"), a(s(this).shrn(t));
  }
  eq(t) {
    return s(this).eq(s(t));
  }
  lt(t) {
    return s(this).lt(s(t));
  }
  lte(t) {
    return s(this).lte(s(t));
  }
  gt(t) {
    return s(this).gt(s(t));
  }
  gte(t) {
    return s(this).gte(s(t));
  }
  isNegative() {
    return this._hex[0] === "-";
  }
  isZero() {
    return s(this).isZero();
  }
  toNumber() {
    try {
      return s(this).toNumber();
    } catch {
      m("overflow", "toNumber", this.toString());
    }
    return null;
  }
  toBigInt() {
    try {
      return BigInt(this.toString());
    } catch {
    }
    return w.throwError("this platform does not support BigInt", o.errors.UNSUPPORTED_OPERATION, {
      value: this.toString()
    });
  }
  toString() {
    return arguments.length > 0 && (arguments[0] === 10 ? H || (H = !0, w.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")) : arguments[0] === 16 ? w.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()", o.errors.UNEXPECTED_ARGUMENT, {}) : w.throwError("BigNumber.toString does not accept parameters", o.errors.UNEXPECTED_ARGUMENT, {})), s(this).toString(10);
  }
  toHexString() {
    return this._hex;
  }
  toJSON(t) {
    return { type: "BigNumber", hex: this.toHexString() };
  }
  static from(t) {
    if (t instanceof g)
      return t;
    if (typeof t == "string")
      return t.match(/^-?0x[0-9a-f]+$/i) ? new g(F, S(t)) : t.match(/^-?[0-9]+$/) ? new g(F, S(new T(t))) : w.throwArgumentError("invalid BigNumber string", "value", t);
    if (typeof t == "number")
      return t % 1 && m("underflow", "BigNumber.from", t), (t >= or || t <= -9007199254740991) && m("overflow", "BigNumber.from", t), g.from(String(t));
    const e = t;
    if (typeof e == "bigint")
      return g.from(e.toString());
    if (P(e))
      return g.from(E(e));
    if (e)
      if (e.toHexString) {
        const n = e.toHexString();
        if (typeof n == "string")
          return g.from(n);
      } else {
        let n = e._hex;
        if (n == null && e.type === "BigNumber" && (n = e.hex), typeof n == "string" && (x(n) || n[0] === "-" && x(n.substring(1))))
          return g.from(n);
      }
    return w.throwArgumentError("invalid BigNumber value", "value", t);
  }
  static isBigNumber(t) {
    return !!(t && t._isBigNumber);
  }
}
function S(r) {
  if (typeof r != "string")
    return S(r.toString(16));
  if (r[0] === "-")
    return r = r.substring(1), r[0] === "-" && w.throwArgumentError("invalid hex", "value", r), r = S(r), r === "0x00" ? r : "-" + r;
  if (r.substring(0, 2) !== "0x" && (r = "0x" + r), r === "0x")
    return "0x00";
  for (r.length % 2 && (r = "0x0" + r.substring(2)); r.length > 4 && r.substring(0, 4) === "0x00"; )
    r = "0x" + r.substring(4);
  return r;
}
function a(r) {
  return g.from(S(r));
}
function s(r) {
  const t = g.from(r).toHexString();
  return t[0] === "-" ? new T("-" + t.substring(3), 16) : new T(t.substring(2), 16);
}
function m(r, t, e) {
  const n = { fault: r, operation: t };
  return e != null && (n.value = e), w.throwError(r, o.errors.NUMERIC_FAULT, n);
}
function fr(r) {
  return new T(r, 36).toString(16);
}
const ur = "properties/5.7.0", j = new o(ur);
function cr(r, t, e) {
  Object.defineProperty(r, t, {
    enumerable: !0,
    value: e,
    writable: !1
  });
}
function br(r, t) {
  for (let e = 0; e < 32; e++) {
    if (r[t])
      return r[t];
    if (!r.prototype || typeof r.prototype != "object")
      break;
    r = Object.getPrototypeOf(r.prototype).constructor;
  }
  return null;
}
const hr = { bigint: !0, boolean: !0, function: !0, number: !0, string: !0 };
function J(r) {
  if (r == null || hr[typeof r])
    return !0;
  if (Array.isArray(r) || typeof r == "object") {
    if (!Object.isFrozen(r))
      return !1;
    const t = Object.keys(r);
    for (let e = 0; e < t.length; e++) {
      let n = null;
      try {
        n = r[t[e]];
      } catch {
        continue;
      }
      if (!J(n))
        return !1;
    }
    return !0;
  }
  return j.throwArgumentError(`Cannot deepCopy ${typeof r}`, "object", r);
}
function lr(r) {
  if (J(r))
    return r;
  if (Array.isArray(r))
    return Object.freeze(r.map((t) => v(t)));
  if (typeof r == "object") {
    const t = {};
    for (const e in r) {
      const n = r[e];
      n !== void 0 && cr(t, e, v(n));
    }
    return t;
  }
  return j.throwArgumentError(`Cannot deepCopy ${typeof r}`, "object", r);
}
function v(r) {
  return lr(r);
}
class Pr {
  constructor(t) {
    for (const e in t)
      this[e] = v(t[e]);
  }
}
function ar(r) {
  return "0x" + Y.keccak_256(A(r));
}
const gr = "address/5.7.0", I = new o(gr);
function V(r) {
  x(r, 20) || I.throwArgumentError("invalid address", "address", r), r = r.toLowerCase();
  const t = r.substring(2).split(""), e = new Uint8Array(40);
  for (let i = 0; i < 40; i++)
    e[i] = t[i].charCodeAt(0);
  const n = A(ar(e));
  for (let i = 0; i < 40; i += 2)
    n[i >> 1] >> 4 >= 8 && (t[i] = t[i].toUpperCase()), (n[i >> 1] & 15) >= 8 && (t[i + 1] = t[i + 1].toUpperCase());
  return "0x" + t.join("");
}
const Er = 9007199254740991;
function Nr(r) {
  return Math.log10 ? Math.log10(r) : Math.log(r) / Math.LN10;
}
const k = {};
for (let r = 0; r < 10; r++)
  k[String(r)] = String(r);
for (let r = 0; r < 26; r++)
  k[String.fromCharCode(65 + r)] = String(10 + r);
const W = Math.floor(Nr(Er));
function mr(r) {
  r = r.toUpperCase(), r = r.substring(4) + r.substring(0, 2) + "00";
  let t = r.split("").map((n) => k[n]).join("");
  for (; t.length >= W; ) {
    let n = t.substring(0, W);
    t = parseInt(n, 10) % 97 + t.substring(n.length);
  }
  let e = String(98 - parseInt(t, 10) % 97);
  for (; e.length < 2; )
    e = "0" + e;
  return e;
}
function Cr(r) {
  let t = null;
  if (typeof r != "string" && I.throwArgumentError("invalid address", "address", r), r.match(/^(0x)?[0-9a-fA-F]{40}$/))
    r.substring(0, 2) !== "0x" && (r = "0x" + r), t = V(r), r.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && t !== r && I.throwArgumentError("bad address checksum", "address", r);
  else if (r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
    for (r.substring(2, 4) !== mr(r) && I.throwArgumentError("bad icap checksum", "address", r), t = fr(r.substring(4)); t.length < 40; )
      t = "0" + t;
    t = V("0x" + t);
  } else
    I.throwArgumentError("invalid address", "address", r);
  return t;
}
const xr = "strings/5.7.0", Z = new o(xr);
var b;
(function(r) {
  r.current = "", r.NFC = "NFC", r.NFD = "NFD", r.NFKC = "NFKC", r.NFKD = "NFKD";
})(b || (b = {}));
var N;
(function(r) {
  r.UNEXPECTED_CONTINUE = "unexpected continuation byte", r.BAD_PREFIX = "bad codepoint prefix", r.OVERRUN = "string overrun", r.MISSING_CONTINUE = "missing continuation byte", r.OUT_OF_RANGE = "out of UTF-8 range", r.UTF16_SURROGATE = "UTF-16 surrogate", r.OVERLONG = "overlong representation";
})(N || (N = {}));
function pr(r, t, e, n, i) {
  return Z.throwArgumentError(`invalid codepoint at offset ${t}; ${r}`, "bytes", e);
}
function q(r, t, e, n, i) {
  if (r === N.BAD_PREFIX || r === N.UNEXPECTED_CONTINUE) {
    let f = 0;
    for (let u = t + 1; u < e.length && e[u] >> 6 === 2; u++)
      f++;
    return f;
  }
  return r === N.OVERRUN ? e.length - t - 1 : 0;
}
function wr(r, t, e, n, i) {
  return r === N.OVERLONG ? (n.push(i), 0) : (n.push(65533), q(r, t, e));
}
const Ar = Object.freeze({
  error: pr,
  ignore: q,
  replace: wr
});
function Rr(r, t) {
  t == null && (t = Ar.error), r = A(r);
  const e = [];
  let n = 0;
  for (; n < r.length; ) {
    const i = r[n++];
    if (!(i >> 7)) {
      e.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 ? n += t(N.UNEXPECTED_CONTINUE, n - 1, r, e) : n += t(N.BAD_PREFIX, n - 1, r, e);
      continue;
    }
    if (n - 1 + f >= r.length) {
      n += t(N.OVERRUN, n - 1, r, e);
      continue;
    }
    let h = i & (1 << 8 - f - 1) - 1;
    for (let l = 0; l < f; l++) {
      let R = r[n];
      if ((R & 192) != 128) {
        n += t(N.MISSING_CONTINUE, n, r, e), h = null;
        break;
      }
      h = h << 6 | R & 63, n++;
    }
    if (h !== null) {
      if (h > 1114111) {
        n += t(N.OUT_OF_RANGE, n - 1 - f, r, e, h);
        continue;
      }
      if (h >= 55296 && h <= 57343) {
        n += t(N.UTF16_SURROGATE, n - 1 - f, r, e, h);
        continue;
      }
      if (h <= u) {
        n += t(N.OVERLONG, n - 1 - f, r, e, h);
        continue;
      }
      e.push(h);
    }
  }
  return e;
}
function dr(r, t = b.current) {
  t != b.current && (Z.checkNormalize(), r = r.normalize(t));
  let e = [];
  for (let n = 0; n < r.length; n++) {
    const i = r.charCodeAt(n);
    if (i < 128)
      e.push(i);
    else if (i < 2048)
      e.push(i >> 6 | 192), e.push(i & 63 | 128);
    else if ((i & 64512) == 55296) {
      n++;
      const f = r.charCodeAt(n);
      if (n >= r.length || (f & 64512) !== 56320)
        throw new Error("invalid utf-8 string");
      const u = 65536 + ((i & 1023) << 10) + (f & 1023);
      e.push(u >> 18 | 240), e.push(u >> 12 & 63 | 128), e.push(u >> 6 & 63 | 128), e.push(u & 63 | 128);
    } else
      e.push(i >> 12 | 224), e.push(i >> 6 & 63 | 128), e.push(i & 63 | 128);
  }
  return A(e);
}
function yr(r) {
  return r.map((t) => t <= 65535 ? String.fromCharCode(t) : (t -= 65536, String.fromCharCode((t >> 10 & 1023) + 55296, (t & 1023) + 56320))).join("");
}
function Dr(r, t) {
  return yr(Rr(r, t));
}
export {
  g as B,
  Pr as D,
  o as L,
  A as a,
  E as b,
  Sr as c,
  cr as d,
  D as e,
  Dr as f,
  Cr as g,
  Or as h,
  br as i,
  _r as j,
  ar as k,
  x as l,
  Ur as m,
  Tr as s,
  dr as t
};
