import { Z as Me, ac as Kr, a1 as Xn, V as Ze } from "./index-CjwA7HmM.mjs";
import { k as Yn, l as qn, m as Zn, n as Qn, o as ei, p as ti, q as ri, t as ni, u as ii, v as si, w as oi, y as Ur, r as Wr, c as ai } from "./index-fzN-meRd.mjs";
import { e as fi } from "./events-BL2eUG60.mjs";
function Hr(e = 0) {
  return globalThis.Buffer != null && globalThis.Buffer.allocUnsafe != null ? globalThis.Buffer.allocUnsafe(e) : new Uint8Array(e);
}
function ci(e, r) {
  r || (r = e.reduce((s, h) => s + h.length, 0));
  const n = Hr(r);
  let a = 0;
  for (const s of e)
    n.set(s, a), a += s.length;
  return n;
}
const wr = {
  ...Yn,
  ...qn,
  ...Zn,
  ...Qn,
  ...ei,
  ...ti,
  ...ri,
  ...ni,
  ...ii,
  ...si
};
function $r(e, r, n, a) {
  return {
    name: e,
    prefix: r,
    encoder: {
      name: e,
      prefix: r,
      encode: n
    },
    decoder: { decode: a }
  };
}
const vr = $r("utf8", "u", (e) => "u" + new TextDecoder("utf8").decode(e), (e) => new TextEncoder().encode(e.substring(1))), Vt = $r("ascii", "a", (e) => {
  let r = "a";
  for (let n = 0; n < e.length; n++)
    r += String.fromCharCode(e[n]);
  return r;
}, (e) => {
  e = e.substring(1);
  const r = Hr(e.length);
  for (let n = 0; n < e.length; n++)
    r[n] = e.charCodeAt(n);
  return r;
}), kr = {
  utf8: vr,
  "utf-8": vr,
  hex: wr.base16,
  latin1: Vt,
  ascii: Vt,
  binary: Vt,
  ...wr
};
function nr(e, r = "utf8") {
  const n = kr[r];
  if (!n)
    throw new Error(`Unsupported encoding "${r}"`);
  return (r === "utf8" || r === "utf-8") && globalThis.Buffer != null && globalThis.Buffer.from != null ? globalThis.Buffer.from(e, "utf8") : n.decoder.decode(`${n.prefix}${e}`);
}
function ir(e, r = "utf8") {
  const n = kr[r];
  if (!n)
    throw new Error(`Unsupported encoding "${r}"`);
  return (r === "utf8" || r === "utf-8") && globalThis.Buffer != null && globalThis.Buffer.from != null ? globalThis.Buffer.from(e.buffer, e.byteOffset, e.byteLength).toString("utf8") : n.encoder.encode(e).substring(1);
}
var mr = function(e, r, n) {
  if (n || arguments.length === 2) for (var a = 0, s = r.length, h; a < s; a++)
    (h || !(a in r)) && (h || (h = Array.prototype.slice.call(r, 0, a)), h[a] = r[a]);
  return e.concat(h || Array.prototype.slice.call(r));
}, ui = (
  /** @class */
  /* @__PURE__ */ function() {
    function e(r, n, a) {
      this.name = r, this.version = n, this.os = a, this.type = "browser";
    }
    return e;
  }()
), li = (
  /** @class */
  /* @__PURE__ */ function() {
    function e(r) {
      this.version = r, this.type = "node", this.name = "node", this.os = Me.process.platform;
    }
    return e;
  }()
), hi = (
  /** @class */
  /* @__PURE__ */ function() {
    function e(r, n, a, s) {
      this.name = r, this.version = n, this.os = a, this.bot = s, this.type = "bot-device";
    }
    return e;
  }()
), di = (
  /** @class */
  /* @__PURE__ */ function() {
    function e() {
      this.type = "bot", this.bot = !0, this.name = "bot", this.version = null, this.os = null;
    }
    return e;
  }()
), bi = (
  /** @class */
  /* @__PURE__ */ function() {
    function e() {
      this.type = "react-native", this.name = "react-native", this.version = null, this.os = null;
    }
    return e;
  }()
), gi = /alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/, yi = /(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/, xr = 3, pi = [
  ["aol", /AOLShield\/([0-9\._]+)/],
  ["edge", /Edge\/([0-9\._]+)/],
  ["edge-ios", /EdgiOS\/([0-9\._]+)/],
  ["yandexbrowser", /YaBrowser\/([0-9\._]+)/],
  ["kakaotalk", /KAKAOTALK\s([0-9\.]+)/],
  ["samsung", /SamsungBrowser\/([0-9\.]+)/],
  ["silk", /\bSilk\/([0-9._-]+)\b/],
  ["miui", /MiuiBrowser\/([0-9\.]+)$/],
  ["beaker", /BeakerBrowser\/([0-9\.]+)/],
  ["edge-chromium", /EdgA?\/([0-9\.]+)/],
  [
    "chromium-webview",
    /(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/
  ],
  ["chrome", /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],
  ["phantomjs", /PhantomJS\/([0-9\.]+)(:?\s|$)/],
  ["crios", /CriOS\/([0-9\.]+)(:?\s|$)/],
  ["firefox", /Firefox\/([0-9\.]+)(?:\s|$)/],
  ["fxios", /FxiOS\/([0-9\.]+)/],
  ["opera-mini", /Opera Mini.*Version\/([0-9\.]+)/],
  ["opera", /Opera\/([0-9\.]+)(?:\s|$)/],
  ["opera", /OPR\/([0-9\.]+)(:?\s|$)/],
  ["pie", /^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],
  ["pie", /^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],
  ["netfront", /^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],
  ["ie", /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],
  ["ie", /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],
  ["ie", /MSIE\s(7\.0)/],
  ["bb10", /BB10;\sTouch.*Version\/([0-9\.]+)/],
  ["android", /Android\s([0-9\.]+)/],
  ["ios", /Version\/([0-9\._]+).*Mobile.*Safari.*/],
  ["safari", /Version\/([0-9\._]+).*Safari/],
  ["facebook", /FB[AS]V\/([0-9\.]+)/],
  ["instagram", /Instagram\s([0-9\.]+)/],
  ["ios-webview", /AppleWebKit\/([0-9\.]+).*Mobile/],
  ["ios-webview", /AppleWebKit\/([0-9\.]+).*Gecko\)$/],
  ["curl", /^curl\/([0-9\.]+)$/],
  ["searchbot", gi]
], Sr = [
  ["iOS", /iP(hone|od|ad)/],
  ["Android OS", /Android/],
  ["BlackBerry OS", /BlackBerry|BB10/],
  ["Windows Mobile", /IEMobile/],
  ["Amazon OS", /Kindle/],
  ["Windows 3.11", /Win16/],
  ["Windows 95", /(Windows 95)|(Win95)|(Windows_95)/],
  ["Windows 98", /(Windows 98)|(Win98)/],
  ["Windows 2000", /(Windows NT 5.0)|(Windows 2000)/],
  ["Windows XP", /(Windows NT 5.1)|(Windows XP)/],
  ["Windows Server 2003", /(Windows NT 5.2)/],
  ["Windows Vista", /(Windows NT 6.0)/],
  ["Windows 7", /(Windows NT 6.1)/],
  ["Windows 8", /(Windows NT 6.2)/],
  ["Windows 8.1", /(Windows NT 6.3)/],
  ["Windows 10", /(Windows NT 10.0)/],
  ["Windows ME", /Windows ME/],
  ["Windows CE", /Windows CE|WinCE|Microsoft Pocket Internet Explorer/],
  ["Open BSD", /OpenBSD/],
  ["Sun OS", /SunOS/],
  ["Chrome OS", /CrOS/],
  ["Linux", /(Linux)|(X11)/],
  ["Mac OS", /(Mac_PowerPC)|(Macintosh)/],
  ["QNX", /QNX/],
  ["BeOS", /BeOS/],
  ["OS/2", /OS\/2/]
];
function zo(e) {
  return typeof document > "u" && typeof navigator < "u" && navigator.product === "ReactNative" ? new bi() : typeof navigator < "u" ? wi(navigator.userAgent) : mi();
}
function _i(e) {
  return e !== "" && pi.reduce(function(r, n) {
    var a = n[0], s = n[1];
    if (r)
      return r;
    var h = s.exec(e);
    return !!h && [a, h];
  }, !1);
}
function wi(e) {
  var r = _i(e);
  if (!r)
    return null;
  var n = r[0], a = r[1];
  if (n === "searchbot")
    return new di();
  var s = a[1] && a[1].split(".").join("_").split("_").slice(0, 3);
  s ? s.length < xr && (s = mr(mr([], s, !0), xi(xr - s.length), !0)) : s = [];
  var h = s.join("."), S = vi(e), m = yi.exec(e);
  return m && m[1] ? new hi(n, h, S, m[1]) : new ui(n, h, S);
}
function vi(e) {
  for (var r = 0, n = Sr.length; r < n; r++) {
    var a = Sr[r], s = a[0], h = a[1], S = h.exec(e);
    if (S)
      return s;
  }
  return null;
}
function mi() {
  var e = typeof Me.process < "u" && Me.process.version;
  return e ? new li(Me.process.version.slice(1)) : null;
}
function xi(e) {
  for (var r = [], n = 0; n < e; n++)
    r.push("0");
  return r;
}
const Do = { waku: { publish: "waku_publish", batchPublish: "waku_batchPublish", subscribe: "waku_subscribe", batchSubscribe: "waku_batchSubscribe", subscription: "waku_subscription", unsubscribe: "waku_unsubscribe", batchUnsubscribe: "waku_batchUnsubscribe", batchFetchMessages: "waku_batchFetchMessages" }, irn: { publish: "irn_publish", batchPublish: "irn_batchPublish", subscribe: "irn_subscribe", batchSubscribe: "irn_batchSubscribe", subscription: "irn_subscription", unsubscribe: "irn_unsubscribe", batchUnsubscribe: "irn_batchUnsubscribe", batchFetchMessages: "irn_batchFetchMessages" }, iridium: { publish: "iridium_publish", batchPublish: "iridium_batchPublish", subscribe: "iridium_subscribe", batchSubscribe: "iridium_batchSubscribe", subscription: "iridium_subscription", unsubscribe: "iridium_unsubscribe", batchUnsubscribe: "iridium_batchUnsubscribe", batchFetchMessages: "iridium_batchFetchMessages" } }, Si = /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/, Ei = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/, Ii = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
function Oi(e, r) {
  if (e === "__proto__" || e === "constructor" && r && typeof r == "object" && "prototype" in r) {
    Ti(e);
    return;
  }
  return r;
}
function Ti(e) {
  console.warn(`[destr] Dropping "${e}" key to prevent prototype pollution.`);
}
function zt(e, r = {}) {
  if (typeof e != "string")
    return e;
  const n = e.trim();
  if (
    // eslint-disable-next-line unicorn/prefer-at
    e[0] === '"' && e.endsWith('"') && !e.includes("\\")
  )
    return n.slice(1, -1);
  if (n.length <= 9) {
    const a = n.toLowerCase();
    if (a === "true")
      return !0;
    if (a === "false")
      return !1;
    if (a === "undefined")
      return;
    if (a === "null")
      return null;
    if (a === "nan")
      return Number.NaN;
    if (a === "infinity")
      return Number.POSITIVE_INFINITY;
    if (a === "-infinity")
      return Number.NEGATIVE_INFINITY;
  }
  if (!Ii.test(e)) {
    if (r.strict)
      throw new SyntaxError("[destr] Invalid JSON");
    return e;
  }
  try {
    if (Si.test(e) || Ei.test(e)) {
      if (r.strict)
        throw new Error("[destr] Possible prototype pollution");
      return JSON.parse(e, Oi);
    }
    return JSON.parse(e);
  } catch (a) {
    if (r.strict)
      throw a;
    return e;
  }
}
function Ai(e) {
  return !e || typeof e.then != "function" ? Promise.resolve(e) : e;
}
function Oe(e, ...r) {
  try {
    return Ai(e(...r));
  } catch (n) {
    return Promise.reject(n);
  }
}
function Li(e) {
  const r = typeof e;
  return e === null || r !== "object" && r !== "function";
}
function Ri(e) {
  const r = Object.getPrototypeOf(e);
  return !r || r.isPrototypeOf(Object);
}
function Ut(e) {
  if (Li(e))
    return String(e);
  if (Ri(e) || Array.isArray(e))
    return JSON.stringify(e);
  if (typeof e.toJSON == "function")
    return Ut(e.toJSON());
  throw new Error("[unstorage] Cannot stringify value!");
}
function Gr() {
  if (typeof Me.Buffer === void 0)
    throw new TypeError("[unstorage] Buffer is not supported!");
}
const Zt = "base64:";
function Pi(e) {
  if (typeof e == "string")
    return e;
  Gr();
  const r = Me.Buffer.from(e).toString("base64");
  return Zt + r;
}
function Mi(e) {
  return typeof e != "string" || !e.startsWith(Zt) ? e : (Gr(), Me.Buffer.from(e.slice(Zt.length), "base64"));
}
function Ke(e) {
  return e ? e.split("?")[0].replace(/[/\\]/g, ":").replace(/:+/g, ":").replace(/^:|:$/g, "") : "";
}
function Ci(...e) {
  return Ke(e.join(":"));
}
function Dt(e) {
  return e = Ke(e), e ? e + ":" : "";
}
const Ni = "memory", Bi = () => {
  const e = /* @__PURE__ */ new Map();
  return {
    name: Ni,
    options: {},
    hasItem(r) {
      return e.has(r);
    },
    getItem(r) {
      return e.get(r) ?? null;
    },
    getItemRaw(r) {
      return e.get(r) ?? null;
    },
    setItem(r, n) {
      e.set(r, n);
    },
    setItemRaw(r, n) {
      e.set(r, n);
    },
    removeItem(r) {
      e.delete(r);
    },
    getKeys() {
      return Array.from(e.keys());
    },
    clear() {
      e.clear();
    },
    dispose() {
      e.clear();
    }
  };
};
function ji(e = {}) {
  const r = {
    mounts: { "": e.driver || Bi() },
    mountpoints: [""],
    watching: !1,
    watchListeners: [],
    unwatch: {}
  }, n = (o) => {
    for (const l of r.mountpoints)
      if (o.startsWith(l))
        return {
          base: l,
          relativeKey: o.slice(l.length),
          driver: r.mounts[l]
        };
    return {
      base: "",
      relativeKey: o,
      driver: r.mounts[""]
    };
  }, a = (o, l) => r.mountpoints.filter(
    (y) => y.startsWith(o) || l && o.startsWith(y)
  ).map((y) => ({
    relativeBase: o.length > y.length ? o.slice(y.length) : void 0,
    mountpoint: y,
    driver: r.mounts[y]
  })), s = (o, l) => {
    if (r.watching) {
      l = Ke(l);
      for (const y of r.watchListeners)
        y(o, l);
    }
  }, h = async () => {
    if (!r.watching) {
      r.watching = !0;
      for (const o in r.mounts)
        r.unwatch[o] = await Er(
          r.mounts[o],
          s,
          o
        );
    }
  }, S = async () => {
    if (r.watching) {
      for (const o in r.unwatch)
        await r.unwatch[o]();
      r.unwatch = {}, r.watching = !1;
    }
  }, m = (o, l, y) => {
    const E = /* @__PURE__ */ new Map(), x = (v) => {
      let N = E.get(v.base);
      return N || (N = {
        driver: v.driver,
        base: v.base,
        items: []
      }, E.set(v.base, N)), N;
    };
    for (const v of o) {
      const N = typeof v == "string", F = Ke(N ? v : v.key), X = N ? void 0 : v.value, B = N || !v.options ? l : { ...l, ...v.options }, Te = n(F);
      x(Te).items.push({
        key: F,
        value: X,
        relativeKey: Te.relativeKey,
        options: B
      });
    }
    return Promise.all([...E.values()].map((v) => y(v))).then(
      (v) => v.flat()
    );
  }, g = {
    // Item
    hasItem(o, l = {}) {
      o = Ke(o);
      const { relativeKey: y, driver: E } = n(o);
      return Oe(E.hasItem, y, l);
    },
    getItem(o, l = {}) {
      o = Ke(o);
      const { relativeKey: y, driver: E } = n(o);
      return Oe(E.getItem, y, l).then(
        (x) => zt(x)
      );
    },
    getItems(o, l) {
      return m(o, l, (y) => y.driver.getItems ? Oe(
        y.driver.getItems,
        y.items.map((E) => ({
          key: E.relativeKey,
          options: E.options
        })),
        l
      ).then(
        (E) => E.map((x) => ({
          key: Ci(y.base, x.key),
          value: zt(x.value)
        }))
      ) : Promise.all(
        y.items.map((E) => Oe(
          y.driver.getItem,
          E.relativeKey,
          E.options
        ).then((x) => ({
          key: E.key,
          value: zt(x)
        })))
      ));
    },
    getItemRaw(o, l = {}) {
      o = Ke(o);
      const { relativeKey: y, driver: E } = n(o);
      return E.getItemRaw ? Oe(E.getItemRaw, y, l) : Oe(E.getItem, y, l).then(
        (x) => Mi(x)
      );
    },
    async setItem(o, l, y = {}) {
      if (l === void 0)
        return g.removeItem(o);
      o = Ke(o);
      const { relativeKey: E, driver: x } = n(o);
      x.setItem && (await Oe(x.setItem, E, Ut(l), y), x.watch || s("update", o));
    },
    async setItems(o, l) {
      await m(o, l, async (y) => {
        if (y.driver.setItems)
          return Oe(
            y.driver.setItems,
            y.items.map((E) => ({
              key: E.relativeKey,
              value: Ut(E.value),
              options: E.options
            })),
            l
          );
        y.driver.setItem && await Promise.all(
          y.items.map((E) => Oe(
            y.driver.setItem,
            E.relativeKey,
            Ut(E.value),
            E.options
          ))
        );
      });
    },
    async setItemRaw(o, l, y = {}) {
      if (l === void 0)
        return g.removeItem(o, y);
      o = Ke(o);
      const { relativeKey: E, driver: x } = n(o);
      if (x.setItemRaw)
        await Oe(x.setItemRaw, E, l, y);
      else if (x.setItem)
        await Oe(x.setItem, E, Pi(l), y);
      else
        return;
      x.watch || s("update", o);
    },
    async removeItem(o, l = {}) {
      typeof l == "boolean" && (l = { removeMeta: l }), o = Ke(o);
      const { relativeKey: y, driver: E } = n(o);
      E.removeItem && (await Oe(E.removeItem, y, l), (l.removeMeta || l.removeMata) && await Oe(E.removeItem, y + "$", l), E.watch || s("remove", o));
    },
    // Meta
    async getMeta(o, l = {}) {
      typeof l == "boolean" && (l = { nativeOnly: l }), o = Ke(o);
      const { relativeKey: y, driver: E } = n(o), x = /* @__PURE__ */ Object.create(null);
      if (E.getMeta && Object.assign(x, await Oe(E.getMeta, y, l)), !l.nativeOnly) {
        const v = await Oe(
          E.getItem,
          y + "$",
          l
        ).then((N) => zt(N));
        v && typeof v == "object" && (typeof v.atime == "string" && (v.atime = new Date(v.atime)), typeof v.mtime == "string" && (v.mtime = new Date(v.mtime)), Object.assign(x, v));
      }
      return x;
    },
    setMeta(o, l, y = {}) {
      return this.setItem(o + "$", l, y);
    },
    removeMeta(o, l = {}) {
      return this.removeItem(o + "$", l);
    },
    // Keys
    async getKeys(o, l = {}) {
      o = Dt(o);
      const y = a(o, !0);
      let E = [];
      const x = [];
      for (const v of y) {
        const F = (await Oe(
          v.driver.getKeys,
          v.relativeBase,
          l
        )).map((X) => v.mountpoint + Ke(X)).filter((X) => !E.some((B) => X.startsWith(B)));
        x.push(...F), E = [
          v.mountpoint,
          ...E.filter((X) => !X.startsWith(v.mountpoint))
        ];
      }
      return o ? x.filter((v) => v.startsWith(o) && !v.endsWith("$")) : x.filter((v) => !v.endsWith("$"));
    },
    // Utils
    async clear(o, l = {}) {
      o = Dt(o), await Promise.all(
        a(o, !1).map(async (y) => {
          if (y.driver.clear)
            return Oe(y.driver.clear, y.relativeBase, l);
          if (y.driver.removeItem) {
            const E = await y.driver.getKeys(y.relativeBase || "", l);
            return Promise.all(
              E.map((x) => y.driver.removeItem(x, l))
            );
          }
        })
      );
    },
    async dispose() {
      await Promise.all(
        Object.values(r.mounts).map((o) => Ir(o))
      );
    },
    async watch(o) {
      return await h(), r.watchListeners.push(o), async () => {
        r.watchListeners = r.watchListeners.filter(
          (l) => l !== o
        ), r.watchListeners.length === 0 && await S();
      };
    },
    async unwatch() {
      r.watchListeners = [], await S();
    },
    // Mount
    mount(o, l) {
      if (o = Dt(o), o && r.mounts[o])
        throw new Error(`already mounted at ${o}`);
      return o && (r.mountpoints.push(o), r.mountpoints.sort((y, E) => E.length - y.length)), r.mounts[o] = l, r.watching && Promise.resolve(Er(l, s, o)).then((y) => {
        r.unwatch[o] = y;
      }).catch(console.error), g;
    },
    async unmount(o, l = !0) {
      o = Dt(o), !(!o || !r.mounts[o]) && (r.watching && o in r.unwatch && (r.unwatch[o](), delete r.unwatch[o]), l && await Ir(r.mounts[o]), r.mountpoints = r.mountpoints.filter((y) => y !== o), delete r.mounts[o]);
    },
    getMount(o = "") {
      o = Ke(o) + ":";
      const l = n(o);
      return {
        driver: l.driver,
        base: l.base
      };
    },
    getMounts(o = "", l = {}) {
      return o = Ke(o), a(o, l.parents).map((E) => ({
        driver: E.driver,
        base: E.mountpoint
      }));
    }
  };
  return g;
}
function Er(e, r, n) {
  return e.watch ? e.watch((a, s) => r(a, n + s)) : () => {
  };
}
async function Ir(e) {
  typeof e.dispose == "function" && await Oe(e.dispose);
}
function dt(e) {
  return new Promise((r, n) => {
    e.oncomplete = e.onsuccess = () => r(e.result), e.onabort = e.onerror = () => n(e.error);
  });
}
function Fr(e, r) {
  const n = indexedDB.open(e);
  n.onupgradeneeded = () => n.result.createObjectStore(r);
  const a = dt(n);
  return (s, h) => a.then((S) => h(S.transaction(r, s).objectStore(r)));
}
let Xt;
function At() {
  return Xt || (Xt = Fr("keyval-store", "keyval")), Xt;
}
function Or(e, r = At()) {
  return r("readonly", (n) => dt(n.get(e)));
}
function zi(e, r, n = At()) {
  return n("readwrite", (a) => (a.put(r, e), dt(a.transaction)));
}
function Di(e, r = At()) {
  return r("readwrite", (n) => (n.delete(e), dt(n.transaction)));
}
function Ki(e = At()) {
  return e("readwrite", (r) => (r.clear(), dt(r.transaction)));
}
function Ui(e, r) {
  return e.openCursor().onsuccess = function() {
    this.result && (r(this.result), this.result.continue());
  }, dt(e.transaction);
}
function Wi(e = At()) {
  return e("readonly", (r) => {
    if (r.getAllKeys)
      return dt(r.getAllKeys());
    const n = [];
    return Ui(r, (a) => n.push(a.key)).then(() => n);
  });
}
const Hi = (e) => JSON.stringify(e, (r, n) => typeof n == "bigint" ? n.toString() + "n" : n), $i = (e) => {
  const r = /([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g, n = e.replace(r, '$1"$2n"$3');
  return JSON.parse(n, (a, s) => typeof s == "string" && s.match(/^\d+n$/) ? BigInt(s.substring(0, s.length - 1)) : s);
};
function sr(e) {
  if (typeof e != "string")
    throw new Error(`Cannot safe json parse value of type ${typeof e}`);
  try {
    return $i(e);
  } catch {
    return e;
  }
}
function wt(e) {
  return typeof e == "string" ? e : Hi(e) || "";
}
const ki = "idb-keyval";
var Gi = (e = {}) => {
  const r = e.base && e.base.length > 0 ? `${e.base}:` : "", n = (s) => r + s;
  let a;
  return e.dbName && e.storeName && (a = Fr(e.dbName, e.storeName)), { name: ki, options: e, async hasItem(s) {
    return !(typeof await Or(n(s), a) > "u");
  }, async getItem(s) {
    return await Or(n(s), a) ?? null;
  }, setItem(s, h) {
    return zi(n(s), h, a);
  }, removeItem(s) {
    return Di(n(s), a);
  }, getKeys() {
    return Wi(a);
  }, clear() {
    return Ki(a);
  } };
};
const Fi = "WALLET_CONNECT_V2_INDEXED_DB", Ji = "keyvaluestorage";
let Vi = class {
  constructor() {
    this.indexedDb = ji({ driver: Gi({ dbName: Fi, storeName: Ji }) });
  }
  async getKeys() {
    return this.indexedDb.getKeys();
  }
  async getEntries() {
    return (await this.indexedDb.getItems(await this.indexedDb.getKeys())).map((r) => [r.key, r.value]);
  }
  async getItem(r) {
    const n = await this.indexedDb.getItem(r);
    if (n !== null) return n;
  }
  async setItem(r, n) {
    await this.indexedDb.setItem(r, wt(n));
  }
  async removeItem(r) {
    await this.indexedDb.removeItem(r);
  }
};
var Yt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof Me.global < "u" ? Me.global : typeof self < "u" ? self : {}, Wt = { exports: {} };
(function() {
  let e;
  function r() {
  }
  e = r, e.prototype.getItem = function(n) {
    return this.hasOwnProperty(n) ? String(this[n]) : null;
  }, e.prototype.setItem = function(n, a) {
    this[n] = String(a);
  }, e.prototype.removeItem = function(n) {
    delete this[n];
  }, e.prototype.clear = function() {
    const n = this;
    Object.keys(n).forEach(function(a) {
      n[a] = void 0, delete n[a];
    });
  }, e.prototype.key = function(n) {
    return n = n || 0, Object.keys(this)[n];
  }, e.prototype.__defineGetter__("length", function() {
    return Object.keys(this).length;
  }), typeof Yt < "u" && Yt.localStorage ? Wt.exports = Yt.localStorage : typeof window < "u" && window.localStorage ? Wt.exports = window.localStorage : Wt.exports = new r();
})();
function Xi(e) {
  var r;
  return [e[0], sr((r = e[1]) != null ? r : "")];
}
class Yi {
  constructor() {
    this.localStorage = Wt.exports;
  }
  async getKeys() {
    return Object.keys(this.localStorage);
  }
  async getEntries() {
    return Object.entries(this.localStorage).map(Xi);
  }
  async getItem(r) {
    const n = this.localStorage.getItem(r);
    if (n !== null) return sr(n);
  }
  async setItem(r, n) {
    this.localStorage.setItem(r, wt(n));
  }
  async removeItem(r) {
    this.localStorage.removeItem(r);
  }
}
const qi = "wc_storage_version", Tr = 1, Zi = async (e, r, n) => {
  const a = qi, s = await r.getItem(a);
  if (s && s >= Tr) {
    n(r);
    return;
  }
  const h = await e.getKeys();
  if (!h.length) {
    n(r);
    return;
  }
  const S = [];
  for (; h.length; ) {
    const m = h.shift();
    if (!m) continue;
    const g = m.toLowerCase();
    if (g.includes("wc@") || g.includes("walletconnect") || g.includes("wc_") || g.includes("wallet_connect")) {
      const o = await e.getItem(m);
      await r.setItem(m, o), S.push(m);
    }
  }
  await r.setItem(a, Tr), n(r), Qi(e, S);
}, Qi = async (e, r) => {
  r.length && r.forEach(async (n) => {
    await e.removeItem(n);
  });
};
let Uo = class {
  constructor() {
    this.initialized = !1, this.setInitialized = (n) => {
      this.storage = n, this.initialized = !0;
    };
    const r = new Yi();
    this.storage = r;
    try {
      const n = new Vi();
      Zi(r, n, this.setInitialized);
    } catch {
      this.initialized = !0;
    }
  }
  async getKeys() {
    return await this.initialize(), this.storage.getKeys();
  }
  async getEntries() {
    return await this.initialize(), this.storage.getEntries();
  }
  async getItem(r) {
    return await this.initialize(), this.storage.getItem(r);
  }
  async setItem(r, n) {
    return await this.initialize(), this.storage.setItem(r, n);
  }
  async removeItem(r) {
    return await this.initialize(), this.storage.removeItem(r);
  }
  async initialize() {
    this.initialized || await new Promise((r) => {
      const n = setInterval(() => {
        this.initialized && (clearInterval(n), r());
      }, 20);
    });
  }
};
class Ho {
}
function es(e) {
  try {
    return JSON.stringify(e);
  } catch {
    return '"[Circular]"';
  }
}
var ts = rs;
function rs(e, r, n) {
  var a = n && n.stringify || es, s = 1;
  if (typeof e == "object" && e !== null) {
    var h = r.length + s;
    if (h === 1) return e;
    var S = new Array(h);
    S[0] = a(e);
    for (var m = 1; m < h; m++)
      S[m] = a(r[m]);
    return S.join(" ");
  }
  if (typeof e != "string")
    return e;
  var g = r.length;
  if (g === 0) return e;
  for (var o = "", l = 1 - s, y = -1, E = e && e.length || 0, x = 0; x < E; ) {
    if (e.charCodeAt(x) === 37 && x + 1 < E) {
      switch (y = y > -1 ? y : 0, e.charCodeAt(x + 1)) {
        case 100:
        case 102:
          if (l >= g || r[l] == null) break;
          y < x && (o += e.slice(y, x)), o += Number(r[l]), y = x + 2, x++;
          break;
        case 105:
          if (l >= g || r[l] == null) break;
          y < x && (o += e.slice(y, x)), o += Math.floor(Number(r[l])), y = x + 2, x++;
          break;
        case 79:
        case 111:
        case 106:
          if (l >= g || r[l] === void 0) break;
          y < x && (o += e.slice(y, x));
          var v = typeof r[l];
          if (v === "string") {
            o += "'" + r[l] + "'", y = x + 2, x++;
            break;
          }
          if (v === "function") {
            o += r[l].name || "<anonymous>", y = x + 2, x++;
            break;
          }
          o += a(r[l]), y = x + 2, x++;
          break;
        case 115:
          if (l >= g)
            break;
          y < x && (o += e.slice(y, x)), o += String(r[l]), y = x + 2, x++;
          break;
        case 37:
          y < x && (o += e.slice(y, x)), o += "%", y = x + 2, x++, l--;
          break;
      }
      ++l;
    }
    ++x;
  }
  return y === -1 ? e : (y < E && (o += e.slice(y)), o);
}
const Ar = ts;
var _t = Qe;
const It = hs().console || {}, ns = {
  mapHttpRequest: Kt,
  mapHttpResponse: Kt,
  wrapRequestSerializer: qt,
  wrapResponseSerializer: qt,
  wrapErrorSerializer: qt,
  req: Kt,
  res: Kt,
  err: fs
};
function is(e, r) {
  return Array.isArray(e) ? e.filter(function(a) {
    return a !== "!stdSerializers.err";
  }) : e === !0 ? Object.keys(r) : !1;
}
function Qe(e) {
  e = e || {}, e.browser = e.browser || {};
  const r = e.browser.transmit;
  if (r && typeof r.send != "function")
    throw Error("pino: transmit option must have a send function");
  const n = e.browser.write || It;
  e.browser.write && (e.browser.asObject = !0);
  const a = e.serializers || {}, s = is(e.browser.serialize, a);
  let h = e.browser.serialize;
  Array.isArray(e.browser.serialize) && e.browser.serialize.indexOf("!stdSerializers.err") > -1 && (h = !1);
  const S = ["error", "fatal", "warn", "info", "debug", "trace"];
  typeof n == "function" && (n.error = n.fatal = n.warn = n.info = n.debug = n.trace = n), e.enabled === !1 && (e.level = "silent");
  const m = e.level || "info", g = Object.create(n);
  g.log || (g.log = Ot), Object.defineProperty(g, "levelVal", {
    get: l
  }), Object.defineProperty(g, "level", {
    get: y,
    set: E
  });
  const o = {
    transmit: r,
    serialize: s,
    asObject: e.browser.asObject,
    levels: S,
    timestamp: cs(e)
  };
  g.levels = Qe.levels, g.level = m, g.setMaxListeners = g.getMaxListeners = g.emit = g.addListener = g.on = g.prependListener = g.once = g.prependOnceListener = g.removeListener = g.removeAllListeners = g.listeners = g.listenerCount = g.eventNames = g.write = g.flush = Ot, g.serializers = a, g._serialize = s, g._stdErrSerialize = h, g.child = x, r && (g._logEvent = Qt());
  function l() {
    return this.level === "silent" ? 1 / 0 : this.levels.values[this.level];
  }
  function y() {
    return this._level;
  }
  function E(v) {
    if (v !== "silent" && !this.levels.values[v])
      throw Error("unknown level " + v);
    this._level = v, yt(o, g, "error", "log"), yt(o, g, "fatal", "error"), yt(o, g, "warn", "error"), yt(o, g, "info", "log"), yt(o, g, "debug", "log"), yt(o, g, "trace", "log");
  }
  function x(v, N) {
    if (!v)
      throw new Error("missing bindings for child Pino");
    N = N || {}, s && v.serializers && (N.serializers = v.serializers);
    const F = N.serializers;
    if (s && F) {
      var X = Object.assign({}, a, F), B = e.browser.serialize === !0 ? Object.keys(X) : s;
      delete v.serializers, Ft([v], B, X, this._stdErrSerialize);
    }
    function Te(be) {
      this._childLevel = (be._childLevel | 0) + 1, this.error = pt(be, v, "error"), this.fatal = pt(be, v, "fatal"), this.warn = pt(be, v, "warn"), this.info = pt(be, v, "info"), this.debug = pt(be, v, "debug"), this.trace = pt(be, v, "trace"), X && (this.serializers = X, this._serialize = B), r && (this._logEvent = Qt(
        [].concat(be._logEvent.bindings, v)
      ));
    }
    return Te.prototype = this, new Te(this);
  }
  return g;
}
Qe.levels = {
  values: {
    fatal: 60,
    error: 50,
    warn: 40,
    info: 30,
    debug: 20,
    trace: 10
  },
  labels: {
    10: "trace",
    20: "debug",
    30: "info",
    40: "warn",
    50: "error",
    60: "fatal"
  }
};
Qe.stdSerializers = ns;
Qe.stdTimeFunctions = Object.assign({}, { nullTime: Jr, epochTime: Vr, unixTime: us, isoTime: ls });
function yt(e, r, n, a) {
  const s = Object.getPrototypeOf(r);
  r[n] = r.levelVal > r.levels.values[n] ? Ot : s[n] ? s[n] : It[n] || It[a] || Ot, ss(e, r, n);
}
function ss(e, r, n) {
  !e.transmit && r[n] === Ot || (r[n] = /* @__PURE__ */ function(a) {
    return function() {
      const h = e.timestamp(), S = new Array(arguments.length), m = Object.getPrototypeOf && Object.getPrototypeOf(this) === It ? It : this;
      for (var g = 0; g < S.length; g++) S[g] = arguments[g];
      if (e.serialize && !e.asObject && Ft(S, this._serialize, this.serializers, this._stdErrSerialize), e.asObject ? a.call(m, os(this, n, S, h)) : a.apply(m, S), e.transmit) {
        const o = e.transmit.level || r.level, l = Qe.levels.values[o], y = Qe.levels.values[n];
        if (y < l) return;
        as(this, {
          ts: h,
          methodLevel: n,
          methodValue: y,
          transmitLevel: o,
          transmitValue: Qe.levels.values[e.transmit.level || r.level],
          send: e.transmit.send,
          val: r.levelVal
        }, S);
      }
    };
  }(r[n]));
}
function os(e, r, n, a) {
  e._serialize && Ft(n, e._serialize, e.serializers, e._stdErrSerialize);
  const s = n.slice();
  let h = s[0];
  const S = {};
  a && (S.time = a), S.level = Qe.levels.values[r];
  let m = (e._childLevel | 0) + 1;
  if (m < 1 && (m = 1), h !== null && typeof h == "object") {
    for (; m-- && typeof s[0] == "object"; )
      Object.assign(S, s.shift());
    h = s.length ? Ar(s.shift(), s) : void 0;
  } else typeof h == "string" && (h = Ar(s.shift(), s));
  return h !== void 0 && (S.msg = h), S;
}
function Ft(e, r, n, a) {
  for (const s in e)
    if (a && e[s] instanceof Error)
      e[s] = Qe.stdSerializers.err(e[s]);
    else if (typeof e[s] == "object" && !Array.isArray(e[s]))
      for (const h in e[s])
        r && r.indexOf(h) > -1 && h in n && (e[s][h] = n[h](e[s][h]));
}
function pt(e, r, n) {
  return function() {
    const a = new Array(1 + arguments.length);
    a[0] = r;
    for (var s = 1; s < a.length; s++)
      a[s] = arguments[s - 1];
    return e[n].apply(this, a);
  };
}
function as(e, r, n) {
  const a = r.send, s = r.ts, h = r.methodLevel, S = r.methodValue, m = r.val, g = e._logEvent.bindings;
  Ft(
    n,
    e._serialize || Object.keys(e.serializers),
    e.serializers,
    e._stdErrSerialize === void 0 ? !0 : e._stdErrSerialize
  ), e._logEvent.ts = s, e._logEvent.messages = n.filter(function(o) {
    return g.indexOf(o) === -1;
  }), e._logEvent.level.label = h, e._logEvent.level.value = S, a(h, e._logEvent, m), e._logEvent = Qt(g);
}
function Qt(e) {
  return {
    ts: 0,
    messages: [],
    bindings: e || [],
    level: { label: "", value: 0 }
  };
}
function fs(e) {
  const r = {
    type: e.constructor.name,
    msg: e.message,
    stack: e.stack
  };
  for (const n in e)
    r[n] === void 0 && (r[n] = e[n]);
  return r;
}
function cs(e) {
  return typeof e.timestamp == "function" ? e.timestamp : e.timestamp === !1 ? Jr : Vr;
}
function Kt() {
  return {};
}
function qt(e) {
  return e;
}
function Ot() {
}
function Jr() {
  return !1;
}
function Vr() {
  return Date.now();
}
function us() {
  return Math.round(Date.now() / 1e3);
}
function ls() {
  return new Date(Date.now()).toISOString();
}
function hs() {
  function e(r) {
    return typeof r < "u" && r;
  }
  try {
    return typeof globalThis < "u" || Object.defineProperty(Object.prototype, "globalThis", {
      get: function() {
        return delete Object.prototype.globalThis, this.globalThis = this;
      },
      configurable: !0
    }), globalThis;
  } catch {
    return e(self) || e(window) || e(this) || {};
  }
}
const Xr = /* @__PURE__ */ Kr(_t), ds = { level: "info" }, Lt = "custom_context", or = 1e3 * 1024;
class bs {
  constructor(r) {
    this.nodeValue = r, this.sizeInBytes = new TextEncoder().encode(this.nodeValue).length, this.next = null;
  }
  get value() {
    return this.nodeValue;
  }
  get size() {
    return this.sizeInBytes;
  }
}
class Lr {
  constructor(r) {
    this.head = null, this.tail = null, this.lengthInNodes = 0, this.maxSizeInBytes = r, this.sizeInBytes = 0;
  }
  append(r) {
    const n = new bs(r);
    if (n.size > this.maxSizeInBytes) throw new Error(`[LinkedList] Value too big to insert into list: ${r} with size ${n.size}`);
    for (; this.size + n.size > this.maxSizeInBytes; ) this.shift();
    this.head ? (this.tail && (this.tail.next = n), this.tail = n) : (this.head = n, this.tail = n), this.lengthInNodes++, this.sizeInBytes += n.size;
  }
  shift() {
    if (!this.head) return;
    const r = this.head;
    this.head = this.head.next, this.head || (this.tail = null), this.lengthInNodes--, this.sizeInBytes -= r.size;
  }
  toArray() {
    const r = [];
    let n = this.head;
    for (; n !== null; ) r.push(n.value), n = n.next;
    return r;
  }
  get length() {
    return this.lengthInNodes;
  }
  get size() {
    return this.sizeInBytes;
  }
  toOrderedArray() {
    return Array.from(this);
  }
  [Symbol.iterator]() {
    let r = this.head;
    return { next: () => {
      if (!r) return { done: !0, value: null };
      const n = r.value;
      return r = r.next, { done: !1, value: n };
    } };
  }
}
class Yr {
  constructor(r, n = or) {
    this.level = r ?? "error", this.levelValue = _t.levels.values[this.level], this.MAX_LOG_SIZE_IN_BYTES = n, this.logs = new Lr(this.MAX_LOG_SIZE_IN_BYTES);
  }
  forwardToConsole(r, n) {
    n === _t.levels.values.error ? console.error(r) : n === _t.levels.values.warn ? console.warn(r) : n === _t.levels.values.debug ? console.debug(r) : n === _t.levels.values.trace ? console.trace(r) : console.log(r);
  }
  appendToLogs(r) {
    this.logs.append(wt({ timestamp: (/* @__PURE__ */ new Date()).toISOString(), log: r }));
    const n = typeof r == "string" ? JSON.parse(r).level : r.level;
    n >= this.levelValue && this.forwardToConsole(r, n);
  }
  getLogs() {
    return this.logs;
  }
  clearLogs() {
    this.logs = new Lr(this.MAX_LOG_SIZE_IN_BYTES);
  }
  getLogArray() {
    return Array.from(this.logs);
  }
  logsToBlob(r) {
    const n = this.getLogArray();
    return n.push(wt({ extraMetadata: r })), new Blob(n, { type: "application/json" });
  }
}
class gs {
  constructor(r, n = or) {
    this.baseChunkLogger = new Yr(r, n);
  }
  write(r) {
    this.baseChunkLogger.appendToLogs(r);
  }
  getLogs() {
    return this.baseChunkLogger.getLogs();
  }
  clearLogs() {
    this.baseChunkLogger.clearLogs();
  }
  getLogArray() {
    return this.baseChunkLogger.getLogArray();
  }
  logsToBlob(r) {
    return this.baseChunkLogger.logsToBlob(r);
  }
  downloadLogsBlobInBrowser(r) {
    const n = URL.createObjectURL(this.logsToBlob(r)), a = document.createElement("a");
    a.href = n, a.download = `walletconnect-logs-${(/* @__PURE__ */ new Date()).toISOString()}.txt`, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(n);
  }
}
class ys {
  constructor(r, n = or) {
    this.baseChunkLogger = new Yr(r, n);
  }
  write(r) {
    this.baseChunkLogger.appendToLogs(r);
  }
  getLogs() {
    return this.baseChunkLogger.getLogs();
  }
  clearLogs() {
    this.baseChunkLogger.clearLogs();
  }
  getLogArray() {
    return this.baseChunkLogger.getLogArray();
  }
  logsToBlob(r) {
    return this.baseChunkLogger.logsToBlob(r);
  }
}
var ps = Object.defineProperty, _s = Object.defineProperties, ws = Object.getOwnPropertyDescriptors, Rr = Object.getOwnPropertySymbols, vs = Object.prototype.hasOwnProperty, ms = Object.prototype.propertyIsEnumerable, Pr = (e, r, n) => r in e ? ps(e, r, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[r] = n, Ht = (e, r) => {
  for (var n in r || (r = {})) vs.call(r, n) && Pr(e, n, r[n]);
  if (Rr) for (var n of Rr(r)) ms.call(r, n) && Pr(e, n, r[n]);
  return e;
}, $t = (e, r) => _s(e, ws(r));
function $o(e) {
  return $t(Ht({}, e), { level: (e == null ? void 0 : e.level) || ds.level });
}
function xs(e, r = Lt) {
  return e[r] || "";
}
function Ss(e, r, n = Lt) {
  return e[n] = r, e;
}
function Es(e, r = Lt) {
  let n = "";
  return typeof e.bindings > "u" ? n = xs(e, r) : n = e.bindings().context || "", n;
}
function Is(e, r, n = Lt) {
  const a = Es(e, n);
  return a.trim() ? `${a}/${r}` : r;
}
function ko(e, r, n = Lt) {
  const a = Is(e, r, n), s = e.child({ context: a });
  return Ss(s, a, n);
}
function Os(e) {
  var r, n;
  const a = new gs((r = e.opts) == null ? void 0 : r.level, e.maxSizeInBytes);
  return { logger: Xr($t(Ht({}, e.opts), { level: "trace", browser: $t(Ht({}, (n = e.opts) == null ? void 0 : n.browser), { write: (s) => a.write(s) }) })), chunkLoggerController: a };
}
function Ts(e) {
  var r;
  const n = new ys((r = e.opts) == null ? void 0 : r.level, e.maxSizeInBytes);
  return { logger: Xr($t(Ht({}, e.opts), { level: "trace" }), n), chunkLoggerController: n };
}
function Go(e) {
  return typeof e.loggerOverride < "u" && typeof e.loggerOverride != "string" ? { logger: e.loggerOverride, chunkLoggerController: null } : typeof window < "u" ? Os(e) : Ts(e);
}
var ar = {}, qr = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 });
  var r = oi, n = Ur;
  e.DIGEST_LENGTH = 64, e.BLOCK_SIZE = 128;
  var a = (
    /** @class */
    function() {
      function m() {
        this.digestLength = e.DIGEST_LENGTH, this.blockSize = e.BLOCK_SIZE, this._stateHi = new Int32Array(8), this._stateLo = new Int32Array(8), this._tempHi = new Int32Array(16), this._tempLo = new Int32Array(16), this._buffer = new Uint8Array(256), this._bufferLength = 0, this._bytesHashed = 0, this._finished = !1, this.reset();
      }
      return m.prototype._initState = function() {
        this._stateHi[0] = 1779033703, this._stateHi[1] = 3144134277, this._stateHi[2] = 1013904242, this._stateHi[3] = 2773480762, this._stateHi[4] = 1359893119, this._stateHi[5] = 2600822924, this._stateHi[6] = 528734635, this._stateHi[7] = 1541459225, this._stateLo[0] = 4089235720, this._stateLo[1] = 2227873595, this._stateLo[2] = 4271175723, this._stateLo[3] = 1595750129, this._stateLo[4] = 2917565137, this._stateLo[5] = 725511199, this._stateLo[6] = 4215389547, this._stateLo[7] = 327033209;
      }, m.prototype.reset = function() {
        return this._initState(), this._bufferLength = 0, this._bytesHashed = 0, this._finished = !1, this;
      }, m.prototype.clean = function() {
        n.wipe(this._buffer), n.wipe(this._tempHi), n.wipe(this._tempLo), this.reset();
      }, m.prototype.update = function(g, o) {
        if (o === void 0 && (o = g.length), this._finished)
          throw new Error("SHA512: can't update because hash was finished.");
        var l = 0;
        if (this._bytesHashed += o, this._bufferLength > 0) {
          for (; this._bufferLength < e.BLOCK_SIZE && o > 0; )
            this._buffer[this._bufferLength++] = g[l++], o--;
          this._bufferLength === this.blockSize && (h(this._tempHi, this._tempLo, this._stateHi, this._stateLo, this._buffer, 0, this.blockSize), this._bufferLength = 0);
        }
        for (o >= this.blockSize && (l = h(this._tempHi, this._tempLo, this._stateHi, this._stateLo, g, l, o), o %= this.blockSize); o > 0; )
          this._buffer[this._bufferLength++] = g[l++], o--;
        return this;
      }, m.prototype.finish = function(g) {
        if (!this._finished) {
          var o = this._bytesHashed, l = this._bufferLength, y = o / 536870912 | 0, E = o << 3, x = o % 128 < 112 ? 128 : 256;
          this._buffer[l] = 128;
          for (var v = l + 1; v < x - 8; v++)
            this._buffer[v] = 0;
          r.writeUint32BE(y, this._buffer, x - 8), r.writeUint32BE(E, this._buffer, x - 4), h(this._tempHi, this._tempLo, this._stateHi, this._stateLo, this._buffer, 0, x), this._finished = !0;
        }
        for (var v = 0; v < this.digestLength / 8; v++)
          r.writeUint32BE(this._stateHi[v], g, v * 8), r.writeUint32BE(this._stateLo[v], g, v * 8 + 4);
        return this;
      }, m.prototype.digest = function() {
        var g = new Uint8Array(this.digestLength);
        return this.finish(g), g;
      }, m.prototype.saveState = function() {
        if (this._finished)
          throw new Error("SHA256: cannot save finished state");
        return {
          stateHi: new Int32Array(this._stateHi),
          stateLo: new Int32Array(this._stateLo),
          buffer: this._bufferLength > 0 ? new Uint8Array(this._buffer) : void 0,
          bufferLength: this._bufferLength,
          bytesHashed: this._bytesHashed
        };
      }, m.prototype.restoreState = function(g) {
        return this._stateHi.set(g.stateHi), this._stateLo.set(g.stateLo), this._bufferLength = g.bufferLength, g.buffer && this._buffer.set(g.buffer), this._bytesHashed = g.bytesHashed, this._finished = !1, this;
      }, m.prototype.cleanSavedState = function(g) {
        n.wipe(g.stateHi), n.wipe(g.stateLo), g.buffer && n.wipe(g.buffer), g.bufferLength = 0, g.bytesHashed = 0;
      }, m;
    }()
  );
  e.SHA512 = a;
  var s = new Int32Array([
    1116352408,
    3609767458,
    1899447441,
    602891725,
    3049323471,
    3964484399,
    3921009573,
    2173295548,
    961987163,
    4081628472,
    1508970993,
    3053834265,
    2453635748,
    2937671579,
    2870763221,
    3664609560,
    3624381080,
    2734883394,
    310598401,
    1164996542,
    607225278,
    1323610764,
    1426881987,
    3590304994,
    1925078388,
    4068182383,
    2162078206,
    991336113,
    2614888103,
    633803317,
    3248222580,
    3479774868,
    3835390401,
    2666613458,
    4022224774,
    944711139,
    264347078,
    2341262773,
    604807628,
    2007800933,
    770255983,
    1495990901,
    1249150122,
    1856431235,
    1555081692,
    3175218132,
    1996064986,
    2198950837,
    2554220882,
    3999719339,
    2821834349,
    766784016,
    2952996808,
    2566594879,
    3210313671,
    3203337956,
    3336571891,
    1034457026,
    3584528711,
    2466948901,
    113926993,
    3758326383,
    338241895,
    168717936,
    666307205,
    1188179964,
    773529912,
    1546045734,
    1294757372,
    1522805485,
    1396182291,
    2643833823,
    1695183700,
    2343527390,
    1986661051,
    1014477480,
    2177026350,
    1206759142,
    2456956037,
    344077627,
    2730485921,
    1290863460,
    2820302411,
    3158454273,
    3259730800,
    3505952657,
    3345764771,
    106217008,
    3516065817,
    3606008344,
    3600352804,
    1432725776,
    4094571909,
    1467031594,
    275423344,
    851169720,
    430227734,
    3100823752,
    506948616,
    1363258195,
    659060556,
    3750685593,
    883997877,
    3785050280,
    958139571,
    3318307427,
    1322822218,
    3812723403,
    1537002063,
    2003034995,
    1747873779,
    3602036899,
    1955562222,
    1575990012,
    2024104815,
    1125592928,
    2227730452,
    2716904306,
    2361852424,
    442776044,
    2428436474,
    593698344,
    2756734187,
    3733110249,
    3204031479,
    2999351573,
    3329325298,
    3815920427,
    3391569614,
    3928383900,
    3515267271,
    566280711,
    3940187606,
    3454069534,
    4118630271,
    4000239992,
    116418474,
    1914138554,
    174292421,
    2731055270,
    289380356,
    3203993006,
    460393269,
    320620315,
    685471733,
    587496836,
    852142971,
    1086792851,
    1017036298,
    365543100,
    1126000580,
    2618297676,
    1288033470,
    3409855158,
    1501505948,
    4234509866,
    1607167915,
    987167468,
    1816402316,
    1246189591
  ]);
  function h(m, g, o, l, y, E, x) {
    for (var v = o[0], N = o[1], F = o[2], X = o[3], B = o[4], Te = o[5], be = o[6], Ce = o[7], H = l[0], C = l[1], Ne = l[2], et = l[3], ge = l[4], Ge = l[5], Ue = l[6], Ve = l[7], w, _, Y, ue, L, I, O, A; x >= 128; ) {
      for (var Ae = 0; Ae < 16; Ae++) {
        var re = 8 * Ae + E;
        m[Ae] = r.readUint32BE(y, re), g[Ae] = r.readUint32BE(y, re + 4);
      }
      for (var Ae = 0; Ae < 80; Ae++) {
        var vt = v, j = N, bt = F, b = X, d = B, u = Te, t = be, f = Ce, R = H, P = C, D = Ne, K = et, z = ge, U = Ge, Le = Ue, le = Ve;
        if (w = Ce, _ = Ve, L = _ & 65535, I = _ >>> 16, O = w & 65535, A = w >>> 16, w = (B >>> 14 | ge << 18) ^ (B >>> 18 | ge << 14) ^ (ge >>> 9 | B << 23), _ = (ge >>> 14 | B << 18) ^ (ge >>> 18 | B << 14) ^ (B >>> 9 | ge << 23), L += _ & 65535, I += _ >>> 16, O += w & 65535, A += w >>> 16, w = B & Te ^ ~B & be, _ = ge & Ge ^ ~ge & Ue, L += _ & 65535, I += _ >>> 16, O += w & 65535, A += w >>> 16, w = s[Ae * 2], _ = s[Ae * 2 + 1], L += _ & 65535, I += _ >>> 16, O += w & 65535, A += w >>> 16, w = m[Ae % 16], _ = g[Ae % 16], L += _ & 65535, I += _ >>> 16, O += w & 65535, A += w >>> 16, I += L >>> 16, O += I >>> 16, A += O >>> 16, Y = O & 65535 | A << 16, ue = L & 65535 | I << 16, w = Y, _ = ue, L = _ & 65535, I = _ >>> 16, O = w & 65535, A = w >>> 16, w = (v >>> 28 | H << 4) ^ (H >>> 2 | v << 30) ^ (H >>> 7 | v << 25), _ = (H >>> 28 | v << 4) ^ (v >>> 2 | H << 30) ^ (v >>> 7 | H << 25), L += _ & 65535, I += _ >>> 16, O += w & 65535, A += w >>> 16, w = v & N ^ v & F ^ N & F, _ = H & C ^ H & Ne ^ C & Ne, L += _ & 65535, I += _ >>> 16, O += w & 65535, A += w >>> 16, I += L >>> 16, O += I >>> 16, A += O >>> 16, f = O & 65535 | A << 16, le = L & 65535 | I << 16, w = b, _ = K, L = _ & 65535, I = _ >>> 16, O = w & 65535, A = w >>> 16, w = Y, _ = ue, L += _ & 65535, I += _ >>> 16, O += w & 65535, A += w >>> 16, I += L >>> 16, O += I >>> 16, A += O >>> 16, b = O & 65535 | A << 16, K = L & 65535 | I << 16, N = vt, F = j, X = bt, B = b, Te = d, be = u, Ce = t, v = f, C = R, Ne = P, et = D, ge = K, Ge = z, Ue = U, Ve = Le, H = le, Ae % 16 === 15)
          for (var re = 0; re < 16; re++)
            w = m[re], _ = g[re], L = _ & 65535, I = _ >>> 16, O = w & 65535, A = w >>> 16, w = m[(re + 9) % 16], _ = g[(re + 9) % 16], L += _ & 65535, I += _ >>> 16, O += w & 65535, A += w >>> 16, Y = m[(re + 1) % 16], ue = g[(re + 1) % 16], w = (Y >>> 1 | ue << 31) ^ (Y >>> 8 | ue << 24) ^ Y >>> 7, _ = (ue >>> 1 | Y << 31) ^ (ue >>> 8 | Y << 24) ^ (ue >>> 7 | Y << 25), L += _ & 65535, I += _ >>> 16, O += w & 65535, A += w >>> 16, Y = m[(re + 14) % 16], ue = g[(re + 14) % 16], w = (Y >>> 19 | ue << 13) ^ (ue >>> 29 | Y << 3) ^ Y >>> 6, _ = (ue >>> 19 | Y << 13) ^ (Y >>> 29 | ue << 3) ^ (ue >>> 6 | Y << 26), L += _ & 65535, I += _ >>> 16, O += w & 65535, A += w >>> 16, I += L >>> 16, O += I >>> 16, A += O >>> 16, m[re] = O & 65535 | A << 16, g[re] = L & 65535 | I << 16;
      }
      w = v, _ = H, L = _ & 65535, I = _ >>> 16, O = w & 65535, A = w >>> 16, w = o[0], _ = l[0], L += _ & 65535, I += _ >>> 16, O += w & 65535, A += w >>> 16, I += L >>> 16, O += I >>> 16, A += O >>> 16, o[0] = v = O & 65535 | A << 16, l[0] = H = L & 65535 | I << 16, w = N, _ = C, L = _ & 65535, I = _ >>> 16, O = w & 65535, A = w >>> 16, w = o[1], _ = l[1], L += _ & 65535, I += _ >>> 16, O += w & 65535, A += w >>> 16, I += L >>> 16, O += I >>> 16, A += O >>> 16, o[1] = N = O & 65535 | A << 16, l[1] = C = L & 65535 | I << 16, w = F, _ = Ne, L = _ & 65535, I = _ >>> 16, O = w & 65535, A = w >>> 16, w = o[2], _ = l[2], L += _ & 65535, I += _ >>> 16, O += w & 65535, A += w >>> 16, I += L >>> 16, O += I >>> 16, A += O >>> 16, o[2] = F = O & 65535 | A << 16, l[2] = Ne = L & 65535 | I << 16, w = X, _ = et, L = _ & 65535, I = _ >>> 16, O = w & 65535, A = w >>> 16, w = o[3], _ = l[3], L += _ & 65535, I += _ >>> 16, O += w & 65535, A += w >>> 16, I += L >>> 16, O += I >>> 16, A += O >>> 16, o[3] = X = O & 65535 | A << 16, l[3] = et = L & 65535 | I << 16, w = B, _ = ge, L = _ & 65535, I = _ >>> 16, O = w & 65535, A = w >>> 16, w = o[4], _ = l[4], L += _ & 65535, I += _ >>> 16, O += w & 65535, A += w >>> 16, I += L >>> 16, O += I >>> 16, A += O >>> 16, o[4] = B = O & 65535 | A << 16, l[4] = ge = L & 65535 | I << 16, w = Te, _ = Ge, L = _ & 65535, I = _ >>> 16, O = w & 65535, A = w >>> 16, w = o[5], _ = l[5], L += _ & 65535, I += _ >>> 16, O += w & 65535, A += w >>> 16, I += L >>> 16, O += I >>> 16, A += O >>> 16, o[5] = Te = O & 65535 | A << 16, l[5] = Ge = L & 65535 | I << 16, w = be, _ = Ue, L = _ & 65535, I = _ >>> 16, O = w & 65535, A = w >>> 16, w = o[6], _ = l[6], L += _ & 65535, I += _ >>> 16, O += w & 65535, A += w >>> 16, I += L >>> 16, O += I >>> 16, A += O >>> 16, o[6] = be = O & 65535 | A << 16, l[6] = Ue = L & 65535 | I << 16, w = Ce, _ = Ve, L = _ & 65535, I = _ >>> 16, O = w & 65535, A = w >>> 16, w = o[7], _ = l[7], L += _ & 65535, I += _ >>> 16, O += w & 65535, A += w >>> 16, I += L >>> 16, O += I >>> 16, A += O >>> 16, o[7] = Ce = O & 65535 | A << 16, l[7] = Ve = L & 65535 | I << 16, E += 128, x -= 128;
    }
    return E;
  }
  function S(m) {
    var g = new a();
    g.update(m);
    var o = g.digest();
    return g.clean(), o;
  }
  e.hash = S;
})(qr);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.convertSecretKeyToX25519 = e.convertPublicKeyToX25519 = e.verify = e.sign = e.extractPublicKeyFromSecretKey = e.generateKeyPair = e.generateKeyPairFromSeed = e.SEED_LENGTH = e.SECRET_KEY_LENGTH = e.PUBLIC_KEY_LENGTH = e.SIGNATURE_LENGTH = void 0;
  const r = Wr, n = qr, a = Ur;
  e.SIGNATURE_LENGTH = 64, e.PUBLIC_KEY_LENGTH = 32, e.SECRET_KEY_LENGTH = 64, e.SEED_LENGTH = 32;
  function s(b) {
    const d = new Float64Array(16);
    if (b)
      for (let u = 0; u < b.length; u++)
        d[u] = b[u];
    return d;
  }
  const h = new Uint8Array(32);
  h[0] = 9;
  const S = s(), m = s([1]), g = s([
    30883,
    4953,
    19914,
    30187,
    55467,
    16705,
    2637,
    112,
    59544,
    30585,
    16505,
    36039,
    65139,
    11119,
    27886,
    20995
  ]), o = s([
    61785,
    9906,
    39828,
    60374,
    45398,
    33411,
    5274,
    224,
    53552,
    61171,
    33010,
    6542,
    64743,
    22239,
    55772,
    9222
  ]), l = s([
    54554,
    36645,
    11616,
    51542,
    42930,
    38181,
    51040,
    26924,
    56412,
    64982,
    57905,
    49316,
    21502,
    52590,
    14035,
    8553
  ]), y = s([
    26200,
    26214,
    26214,
    26214,
    26214,
    26214,
    26214,
    26214,
    26214,
    26214,
    26214,
    26214,
    26214,
    26214,
    26214,
    26214
  ]), E = s([
    41136,
    18958,
    6951,
    50414,
    58488,
    44335,
    6150,
    12099,
    55207,
    15867,
    153,
    11085,
    57099,
    20417,
    9344,
    11139
  ]);
  function x(b, d) {
    for (let u = 0; u < 16; u++)
      b[u] = d[u] | 0;
  }
  function v(b) {
    let d = 1;
    for (let u = 0; u < 16; u++) {
      let t = b[u] + d + 65535;
      d = Math.floor(t / 65536), b[u] = t - d * 65536;
    }
    b[0] += d - 1 + 37 * (d - 1);
  }
  function N(b, d, u) {
    const t = ~(u - 1);
    for (let f = 0; f < 16; f++) {
      const R = t & (b[f] ^ d[f]);
      b[f] ^= R, d[f] ^= R;
    }
  }
  function F(b, d) {
    const u = s(), t = s();
    for (let f = 0; f < 16; f++)
      t[f] = d[f];
    v(t), v(t), v(t);
    for (let f = 0; f < 2; f++) {
      u[0] = t[0] - 65517;
      for (let P = 1; P < 15; P++)
        u[P] = t[P] - 65535 - (u[P - 1] >> 16 & 1), u[P - 1] &= 65535;
      u[15] = t[15] - 32767 - (u[14] >> 16 & 1);
      const R = u[15] >> 16 & 1;
      u[14] &= 65535, N(t, u, 1 - R);
    }
    for (let f = 0; f < 16; f++)
      b[2 * f] = t[f] & 255, b[2 * f + 1] = t[f] >> 8;
  }
  function X(b, d) {
    let u = 0;
    for (let t = 0; t < 32; t++)
      u |= b[t] ^ d[t];
    return (1 & u - 1 >>> 8) - 1;
  }
  function B(b, d) {
    const u = new Uint8Array(32), t = new Uint8Array(32);
    return F(u, b), F(t, d), X(u, t);
  }
  function Te(b) {
    const d = new Uint8Array(32);
    return F(d, b), d[0] & 1;
  }
  function be(b, d) {
    for (let u = 0; u < 16; u++)
      b[u] = d[2 * u] + (d[2 * u + 1] << 8);
    b[15] &= 32767;
  }
  function Ce(b, d, u) {
    for (let t = 0; t < 16; t++)
      b[t] = d[t] + u[t];
  }
  function H(b, d, u) {
    for (let t = 0; t < 16; t++)
      b[t] = d[t] - u[t];
  }
  function C(b, d, u) {
    let t, f, R = 0, P = 0, D = 0, K = 0, z = 0, U = 0, Le = 0, le = 0, Re = 0, ye = 0, he = 0, ne = 0, te = 0, q = 0, J = 0, W = 0, ie = 0, pe = 0, $ = 0, Be = 0, ze = 0, We = 0, He = 0, De = 0, Xe = 0, qe = 0, st = 0, $e = 0, ct = 0, mt = 0, Rt = 0, se = u[0], Z = u[1], oe = u[2], ae = u[3], fe = u[4], Q = u[5], _e = u[6], we = u[7], ve = u[8], me = u[9], xe = u[10], de = u[11], ce = u[12], G = u[13], Se = u[14], Ee = u[15];
    t = d[0], R += t * se, P += t * Z, D += t * oe, K += t * ae, z += t * fe, U += t * Q, Le += t * _e, le += t * we, Re += t * ve, ye += t * me, he += t * xe, ne += t * de, te += t * ce, q += t * G, J += t * Se, W += t * Ee, t = d[1], P += t * se, D += t * Z, K += t * oe, z += t * ae, U += t * fe, Le += t * Q, le += t * _e, Re += t * we, ye += t * ve, he += t * me, ne += t * xe, te += t * de, q += t * ce, J += t * G, W += t * Se, ie += t * Ee, t = d[2], D += t * se, K += t * Z, z += t * oe, U += t * ae, Le += t * fe, le += t * Q, Re += t * _e, ye += t * we, he += t * ve, ne += t * me, te += t * xe, q += t * de, J += t * ce, W += t * G, ie += t * Se, pe += t * Ee, t = d[3], K += t * se, z += t * Z, U += t * oe, Le += t * ae, le += t * fe, Re += t * Q, ye += t * _e, he += t * we, ne += t * ve, te += t * me, q += t * xe, J += t * de, W += t * ce, ie += t * G, pe += t * Se, $ += t * Ee, t = d[4], z += t * se, U += t * Z, Le += t * oe, le += t * ae, Re += t * fe, ye += t * Q, he += t * _e, ne += t * we, te += t * ve, q += t * me, J += t * xe, W += t * de, ie += t * ce, pe += t * G, $ += t * Se, Be += t * Ee, t = d[5], U += t * se, Le += t * Z, le += t * oe, Re += t * ae, ye += t * fe, he += t * Q, ne += t * _e, te += t * we, q += t * ve, J += t * me, W += t * xe, ie += t * de, pe += t * ce, $ += t * G, Be += t * Se, ze += t * Ee, t = d[6], Le += t * se, le += t * Z, Re += t * oe, ye += t * ae, he += t * fe, ne += t * Q, te += t * _e, q += t * we, J += t * ve, W += t * me, ie += t * xe, pe += t * de, $ += t * ce, Be += t * G, ze += t * Se, We += t * Ee, t = d[7], le += t * se, Re += t * Z, ye += t * oe, he += t * ae, ne += t * fe, te += t * Q, q += t * _e, J += t * we, W += t * ve, ie += t * me, pe += t * xe, $ += t * de, Be += t * ce, ze += t * G, We += t * Se, He += t * Ee, t = d[8], Re += t * se, ye += t * Z, he += t * oe, ne += t * ae, te += t * fe, q += t * Q, J += t * _e, W += t * we, ie += t * ve, pe += t * me, $ += t * xe, Be += t * de, ze += t * ce, We += t * G, He += t * Se, De += t * Ee, t = d[9], ye += t * se, he += t * Z, ne += t * oe, te += t * ae, q += t * fe, J += t * Q, W += t * _e, ie += t * we, pe += t * ve, $ += t * me, Be += t * xe, ze += t * de, We += t * ce, He += t * G, De += t * Se, Xe += t * Ee, t = d[10], he += t * se, ne += t * Z, te += t * oe, q += t * ae, J += t * fe, W += t * Q, ie += t * _e, pe += t * we, $ += t * ve, Be += t * me, ze += t * xe, We += t * de, He += t * ce, De += t * G, Xe += t * Se, qe += t * Ee, t = d[11], ne += t * se, te += t * Z, q += t * oe, J += t * ae, W += t * fe, ie += t * Q, pe += t * _e, $ += t * we, Be += t * ve, ze += t * me, We += t * xe, He += t * de, De += t * ce, Xe += t * G, qe += t * Se, st += t * Ee, t = d[12], te += t * se, q += t * Z, J += t * oe, W += t * ae, ie += t * fe, pe += t * Q, $ += t * _e, Be += t * we, ze += t * ve, We += t * me, He += t * xe, De += t * de, Xe += t * ce, qe += t * G, st += t * Se, $e += t * Ee, t = d[13], q += t * se, J += t * Z, W += t * oe, ie += t * ae, pe += t * fe, $ += t * Q, Be += t * _e, ze += t * we, We += t * ve, He += t * me, De += t * xe, Xe += t * de, qe += t * ce, st += t * G, $e += t * Se, ct += t * Ee, t = d[14], J += t * se, W += t * Z, ie += t * oe, pe += t * ae, $ += t * fe, Be += t * Q, ze += t * _e, We += t * we, He += t * ve, De += t * me, Xe += t * xe, qe += t * de, st += t * ce, $e += t * G, ct += t * Se, mt += t * Ee, t = d[15], W += t * se, ie += t * Z, pe += t * oe, $ += t * ae, Be += t * fe, ze += t * Q, We += t * _e, He += t * we, De += t * ve, Xe += t * me, qe += t * xe, st += t * de, $e += t * ce, ct += t * G, mt += t * Se, Rt += t * Ee, R += 38 * ie, P += 38 * pe, D += 38 * $, K += 38 * Be, z += 38 * ze, U += 38 * We, Le += 38 * He, le += 38 * De, Re += 38 * Xe, ye += 38 * qe, he += 38 * st, ne += 38 * $e, te += 38 * ct, q += 38 * mt, J += 38 * Rt, f = 1, t = R + f + 65535, f = Math.floor(t / 65536), R = t - f * 65536, t = P + f + 65535, f = Math.floor(t / 65536), P = t - f * 65536, t = D + f + 65535, f = Math.floor(t / 65536), D = t - f * 65536, t = K + f + 65535, f = Math.floor(t / 65536), K = t - f * 65536, t = z + f + 65535, f = Math.floor(t / 65536), z = t - f * 65536, t = U + f + 65535, f = Math.floor(t / 65536), U = t - f * 65536, t = Le + f + 65535, f = Math.floor(t / 65536), Le = t - f * 65536, t = le + f + 65535, f = Math.floor(t / 65536), le = t - f * 65536, t = Re + f + 65535, f = Math.floor(t / 65536), Re = t - f * 65536, t = ye + f + 65535, f = Math.floor(t / 65536), ye = t - f * 65536, t = he + f + 65535, f = Math.floor(t / 65536), he = t - f * 65536, t = ne + f + 65535, f = Math.floor(t / 65536), ne = t - f * 65536, t = te + f + 65535, f = Math.floor(t / 65536), te = t - f * 65536, t = q + f + 65535, f = Math.floor(t / 65536), q = t - f * 65536, t = J + f + 65535, f = Math.floor(t / 65536), J = t - f * 65536, t = W + f + 65535, f = Math.floor(t / 65536), W = t - f * 65536, R += f - 1 + 37 * (f - 1), f = 1, t = R + f + 65535, f = Math.floor(t / 65536), R = t - f * 65536, t = P + f + 65535, f = Math.floor(t / 65536), P = t - f * 65536, t = D + f + 65535, f = Math.floor(t / 65536), D = t - f * 65536, t = K + f + 65535, f = Math.floor(t / 65536), K = t - f * 65536, t = z + f + 65535, f = Math.floor(t / 65536), z = t - f * 65536, t = U + f + 65535, f = Math.floor(t / 65536), U = t - f * 65536, t = Le + f + 65535, f = Math.floor(t / 65536), Le = t - f * 65536, t = le + f + 65535, f = Math.floor(t / 65536), le = t - f * 65536, t = Re + f + 65535, f = Math.floor(t / 65536), Re = t - f * 65536, t = ye + f + 65535, f = Math.floor(t / 65536), ye = t - f * 65536, t = he + f + 65535, f = Math.floor(t / 65536), he = t - f * 65536, t = ne + f + 65535, f = Math.floor(t / 65536), ne = t - f * 65536, t = te + f + 65535, f = Math.floor(t / 65536), te = t - f * 65536, t = q + f + 65535, f = Math.floor(t / 65536), q = t - f * 65536, t = J + f + 65535, f = Math.floor(t / 65536), J = t - f * 65536, t = W + f + 65535, f = Math.floor(t / 65536), W = t - f * 65536, R += f - 1 + 37 * (f - 1), b[0] = R, b[1] = P, b[2] = D, b[3] = K, b[4] = z, b[5] = U, b[6] = Le, b[7] = le, b[8] = Re, b[9] = ye, b[10] = he, b[11] = ne, b[12] = te, b[13] = q, b[14] = J, b[15] = W;
  }
  function Ne(b, d) {
    C(b, d, d);
  }
  function et(b, d) {
    const u = s();
    let t;
    for (t = 0; t < 16; t++)
      u[t] = d[t];
    for (t = 253; t >= 0; t--)
      Ne(u, u), t !== 2 && t !== 4 && C(u, u, d);
    for (t = 0; t < 16; t++)
      b[t] = u[t];
  }
  function ge(b, d) {
    const u = s();
    let t;
    for (t = 0; t < 16; t++)
      u[t] = d[t];
    for (t = 250; t >= 0; t--)
      Ne(u, u), t !== 1 && C(u, u, d);
    for (t = 0; t < 16; t++)
      b[t] = u[t];
  }
  function Ge(b, d) {
    const u = s(), t = s(), f = s(), R = s(), P = s(), D = s(), K = s(), z = s(), U = s();
    H(u, b[1], b[0]), H(U, d[1], d[0]), C(u, u, U), Ce(t, b[0], b[1]), Ce(U, d[0], d[1]), C(t, t, U), C(f, b[3], d[3]), C(f, f, o), C(R, b[2], d[2]), Ce(R, R, R), H(P, t, u), H(D, R, f), Ce(K, R, f), Ce(z, t, u), C(b[0], P, D), C(b[1], z, K), C(b[2], K, D), C(b[3], P, z);
  }
  function Ue(b, d, u) {
    for (let t = 0; t < 4; t++)
      N(b[t], d[t], u);
  }
  function Ve(b, d) {
    const u = s(), t = s(), f = s();
    et(f, d[2]), C(u, d[0], f), C(t, d[1], f), F(b, t), b[31] ^= Te(u) << 7;
  }
  function w(b, d, u) {
    x(b[0], S), x(b[1], m), x(b[2], m), x(b[3], S);
    for (let t = 255; t >= 0; --t) {
      const f = u[t / 8 | 0] >> (t & 7) & 1;
      Ue(b, d, f), Ge(d, b), Ge(b, b), Ue(b, d, f);
    }
  }
  function _(b, d) {
    const u = [s(), s(), s(), s()];
    x(u[0], l), x(u[1], y), x(u[2], m), C(u[3], l, y), w(b, u, d);
  }
  function Y(b) {
    if (b.length !== e.SEED_LENGTH)
      throw new Error(`ed25519: seed must be ${e.SEED_LENGTH} bytes`);
    const d = (0, n.hash)(b);
    d[0] &= 248, d[31] &= 127, d[31] |= 64;
    const u = new Uint8Array(32), t = [s(), s(), s(), s()];
    _(t, d), Ve(u, t);
    const f = new Uint8Array(64);
    return f.set(b), f.set(u, 32), {
      publicKey: u,
      secretKey: f
    };
  }
  e.generateKeyPairFromSeed = Y;
  function ue(b) {
    const d = (0, r.randomBytes)(32, b), u = Y(d);
    return (0, a.wipe)(d), u;
  }
  e.generateKeyPair = ue;
  function L(b) {
    if (b.length !== e.SECRET_KEY_LENGTH)
      throw new Error(`ed25519: secret key must be ${e.SECRET_KEY_LENGTH} bytes`);
    return new Uint8Array(b.subarray(32));
  }
  e.extractPublicKeyFromSecretKey = L;
  const I = new Float64Array([
    237,
    211,
    245,
    92,
    26,
    99,
    18,
    88,
    214,
    156,
    247,
    162,
    222,
    249,
    222,
    20,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    16
  ]);
  function O(b, d) {
    let u, t, f, R;
    for (t = 63; t >= 32; --t) {
      for (u = 0, f = t - 32, R = t - 12; f < R; ++f)
        d[f] += u - 16 * d[t] * I[f - (t - 32)], u = Math.floor((d[f] + 128) / 256), d[f] -= u * 256;
      d[f] += u, d[t] = 0;
    }
    for (u = 0, f = 0; f < 32; f++)
      d[f] += u - (d[31] >> 4) * I[f], u = d[f] >> 8, d[f] &= 255;
    for (f = 0; f < 32; f++)
      d[f] -= u * I[f];
    for (t = 0; t < 32; t++)
      d[t + 1] += d[t] >> 8, b[t] = d[t] & 255;
  }
  function A(b) {
    const d = new Float64Array(64);
    for (let u = 0; u < 64; u++)
      d[u] = b[u];
    for (let u = 0; u < 64; u++)
      b[u] = 0;
    O(b, d);
  }
  function Ae(b, d) {
    const u = new Float64Array(64), t = [s(), s(), s(), s()], f = (0, n.hash)(b.subarray(0, 32));
    f[0] &= 248, f[31] &= 127, f[31] |= 64;
    const R = new Uint8Array(64);
    R.set(f.subarray(32), 32);
    const P = new n.SHA512();
    P.update(R.subarray(32)), P.update(d);
    const D = P.digest();
    P.clean(), A(D), _(t, D), Ve(R, t), P.reset(), P.update(R.subarray(0, 32)), P.update(b.subarray(32)), P.update(d);
    const K = P.digest();
    A(K);
    for (let z = 0; z < 32; z++)
      u[z] = D[z];
    for (let z = 0; z < 32; z++)
      for (let U = 0; U < 32; U++)
        u[z + U] += K[z] * f[U];
    return O(R.subarray(32), u), R;
  }
  e.sign = Ae;
  function re(b, d) {
    const u = s(), t = s(), f = s(), R = s(), P = s(), D = s(), K = s();
    return x(b[2], m), be(b[1], d), Ne(f, b[1]), C(R, f, g), H(f, f, b[2]), Ce(R, b[2], R), Ne(P, R), Ne(D, P), C(K, D, P), C(u, K, f), C(u, u, R), ge(u, u), C(u, u, f), C(u, u, R), C(u, u, R), C(b[0], u, R), Ne(t, b[0]), C(t, t, R), B(t, f) && C(b[0], b[0], E), Ne(t, b[0]), C(t, t, R), B(t, f) ? -1 : (Te(b[0]) === d[31] >> 7 && H(b[0], S, b[0]), C(b[3], b[0], b[1]), 0);
  }
  function vt(b, d, u) {
    const t = new Uint8Array(32), f = [s(), s(), s(), s()], R = [s(), s(), s(), s()];
    if (u.length !== e.SIGNATURE_LENGTH)
      throw new Error(`ed25519: signature must be ${e.SIGNATURE_LENGTH} bytes`);
    if (re(R, b))
      return !1;
    const P = new n.SHA512();
    P.update(u.subarray(0, 32)), P.update(b), P.update(d);
    const D = P.digest();
    return A(D), w(f, R, D), _(R, u.subarray(32)), Ge(f, R), Ve(t, f), !X(u, t);
  }
  e.verify = vt;
  function j(b) {
    let d = [s(), s(), s(), s()];
    if (re(d, b))
      throw new Error("Ed25519: invalid public key");
    let u = s(), t = s(), f = d[1];
    Ce(u, m, f), H(t, m, f), et(t, t), C(u, u, t);
    let R = new Uint8Array(32);
    return F(R, u), R;
  }
  e.convertPublicKeyToX25519 = j;
  function bt(b) {
    const d = (0, n.hash)(b.subarray(0, 32));
    d[0] &= 248, d[31] &= 127, d[31] |= 64;
    const u = new Uint8Array(d.subarray(0, 32));
    return (0, a.wipe)(d), u;
  }
  e.convertSecretKeyToX25519 = bt;
})(ar);
const As = "EdDSA", Ls = "JWT", Zr = ".", Qr = "base64url", Rs = "utf8", Ps = "utf8", Ms = ":", Cs = "did", Ns = "key", Mr = "base58btc", Bs = "z", js = "K36", zs = 32;
function kt(e) {
  return ir(nr(wt(e), Rs), Qr);
}
function Ds(e) {
  const r = nr(js, Mr), n = Bs + ir(ci([r, e]), Mr);
  return [Cs, Ns, n].join(Ms);
}
function Ks(e) {
  return ir(e, Qr);
}
function Us(e) {
  return nr([kt(e.header), kt(e.payload)].join(Zr), Ps);
}
function Ws(e) {
  return [
    kt(e.header),
    kt(e.payload),
    Ks(e.signature)
  ].join(Zr);
}
function Fo(e = Wr.randomBytes(zs)) {
  return ar.generateKeyPairFromSeed(e);
}
async function Jo(e, r, n, a, s = ai.fromMiliseconds(Date.now())) {
  const h = { alg: As, typ: Ls }, S = Ds(a.publicKey), m = s + n, g = { iss: S, sub: e, aud: r, iat: s, exp: m }, o = Us({ header: h, payload: g }), l = ar.sign(a.secretKey, o);
  return Ws({ header: h, payload: g, signature: l });
}
const Hs = "PARSE_ERROR", $s = "INVALID_REQUEST", ks = "METHOD_NOT_FOUND", Gs = "INVALID_PARAMS", en = "INTERNAL_ERROR", fr = "SERVER_ERROR", Fs = [-32700, -32600, -32601, -32602, -32603], Et = {
  [Hs]: { code: -32700, message: "Parse error" },
  [$s]: { code: -32600, message: "Invalid Request" },
  [ks]: { code: -32601, message: "Method not found" },
  [Gs]: { code: -32602, message: "Invalid params" },
  [en]: { code: -32603, message: "Internal error" },
  [fr]: { code: -32e3, message: "Server error" }
}, tn = fr;
function Js(e) {
  return Fs.includes(e);
}
function Cr(e) {
  return Object.keys(Et).includes(e) ? Et[e] : Et[tn];
}
function Vs(e) {
  const r = Object.values(Et).find((n) => n.code === e);
  return r || Et[tn];
}
function Xs(e, r, n) {
  return e.message.includes("getaddrinfo ENOTFOUND") || e.message.includes("connect ECONNREFUSED") ? new Error(`Unavailable ${n} RPC url at ${r}`) : e;
}
var rn = {};
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var er = function(e, r) {
  return er = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(n, a) {
    n.__proto__ = a;
  } || function(n, a) {
    for (var s in a) a.hasOwnProperty(s) && (n[s] = a[s]);
  }, er(e, r);
};
function Ys(e, r) {
  er(e, r);
  function n() {
    this.constructor = e;
  }
  e.prototype = r === null ? Object.create(r) : (n.prototype = r.prototype, new n());
}
var tr = function() {
  return tr = Object.assign || function(r) {
    for (var n, a = 1, s = arguments.length; a < s; a++) {
      n = arguments[a];
      for (var h in n) Object.prototype.hasOwnProperty.call(n, h) && (r[h] = n[h]);
    }
    return r;
  }, tr.apply(this, arguments);
};
function qs(e, r) {
  var n = {};
  for (var a in e) Object.prototype.hasOwnProperty.call(e, a) && r.indexOf(a) < 0 && (n[a] = e[a]);
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
    for (var s = 0, a = Object.getOwnPropertySymbols(e); s < a.length; s++)
      r.indexOf(a[s]) < 0 && Object.prototype.propertyIsEnumerable.call(e, a[s]) && (n[a[s]] = e[a[s]]);
  return n;
}
function Zs(e, r, n, a) {
  var s = arguments.length, h = s < 3 ? r : a === null ? a = Object.getOwnPropertyDescriptor(r, n) : a, S;
  if (typeof Reflect == "object" && typeof Reflect.decorate == "function") h = Reflect.decorate(e, r, n, a);
  else for (var m = e.length - 1; m >= 0; m--) (S = e[m]) && (h = (s < 3 ? S(h) : s > 3 ? S(r, n, h) : S(r, n)) || h);
  return s > 3 && h && Object.defineProperty(r, n, h), h;
}
function Qs(e, r) {
  return function(n, a) {
    r(n, a, e);
  };
}
function eo(e, r) {
  if (typeof Reflect == "object" && typeof Reflect.metadata == "function") return Reflect.metadata(e, r);
}
function to(e, r, n, a) {
  function s(h) {
    return h instanceof n ? h : new n(function(S) {
      S(h);
    });
  }
  return new (n || (n = Promise))(function(h, S) {
    function m(l) {
      try {
        o(a.next(l));
      } catch (y) {
        S(y);
      }
    }
    function g(l) {
      try {
        o(a.throw(l));
      } catch (y) {
        S(y);
      }
    }
    function o(l) {
      l.done ? h(l.value) : s(l.value).then(m, g);
    }
    o((a = a.apply(e, r || [])).next());
  });
}
function ro(e, r) {
  var n = { label: 0, sent: function() {
    if (h[0] & 1) throw h[1];
    return h[1];
  }, trys: [], ops: [] }, a, s, h, S;
  return S = { next: m(0), throw: m(1), return: m(2) }, typeof Symbol == "function" && (S[Symbol.iterator] = function() {
    return this;
  }), S;
  function m(o) {
    return function(l) {
      return g([o, l]);
    };
  }
  function g(o) {
    if (a) throw new TypeError("Generator is already executing.");
    for (; n; ) try {
      if (a = 1, s && (h = o[0] & 2 ? s.return : o[0] ? s.throw || ((h = s.return) && h.call(s), 0) : s.next) && !(h = h.call(s, o[1])).done) return h;
      switch (s = 0, h && (o = [o[0] & 2, h.value]), o[0]) {
        case 0:
        case 1:
          h = o;
          break;
        case 4:
          return n.label++, { value: o[1], done: !1 };
        case 5:
          n.label++, s = o[1], o = [0];
          continue;
        case 7:
          o = n.ops.pop(), n.trys.pop();
          continue;
        default:
          if (h = n.trys, !(h = h.length > 0 && h[h.length - 1]) && (o[0] === 6 || o[0] === 2)) {
            n = 0;
            continue;
          }
          if (o[0] === 3 && (!h || o[1] > h[0] && o[1] < h[3])) {
            n.label = o[1];
            break;
          }
          if (o[0] === 6 && n.label < h[1]) {
            n.label = h[1], h = o;
            break;
          }
          if (h && n.label < h[2]) {
            n.label = h[2], n.ops.push(o);
            break;
          }
          h[2] && n.ops.pop(), n.trys.pop();
          continue;
      }
      o = r.call(e, n);
    } catch (l) {
      o = [6, l], s = 0;
    } finally {
      a = h = 0;
    }
    if (o[0] & 5) throw o[1];
    return { value: o[0] ? o[1] : void 0, done: !0 };
  }
}
function no(e, r, n, a) {
  a === void 0 && (a = n), e[a] = r[n];
}
function io(e, r) {
  for (var n in e) n !== "default" && !r.hasOwnProperty(n) && (r[n] = e[n]);
}
function rr(e) {
  var r = typeof Symbol == "function" && Symbol.iterator, n = r && e[r], a = 0;
  if (n) return n.call(e);
  if (e && typeof e.length == "number") return {
    next: function() {
      return e && a >= e.length && (e = void 0), { value: e && e[a++], done: !e };
    }
  };
  throw new TypeError(r ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function nn(e, r) {
  var n = typeof Symbol == "function" && e[Symbol.iterator];
  if (!n) return e;
  var a = n.call(e), s, h = [], S;
  try {
    for (; (r === void 0 || r-- > 0) && !(s = a.next()).done; ) h.push(s.value);
  } catch (m) {
    S = { error: m };
  } finally {
    try {
      s && !s.done && (n = a.return) && n.call(a);
    } finally {
      if (S) throw S.error;
    }
  }
  return h;
}
function so() {
  for (var e = [], r = 0; r < arguments.length; r++)
    e = e.concat(nn(arguments[r]));
  return e;
}
function oo() {
  for (var e = 0, r = 0, n = arguments.length; r < n; r++) e += arguments[r].length;
  for (var a = Array(e), s = 0, r = 0; r < n; r++)
    for (var h = arguments[r], S = 0, m = h.length; S < m; S++, s++)
      a[s] = h[S];
  return a;
}
function Tt(e) {
  return this instanceof Tt ? (this.v = e, this) : new Tt(e);
}
function ao(e, r, n) {
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  var a = n.apply(e, r || []), s, h = [];
  return s = {}, S("next"), S("throw"), S("return"), s[Symbol.asyncIterator] = function() {
    return this;
  }, s;
  function S(E) {
    a[E] && (s[E] = function(x) {
      return new Promise(function(v, N) {
        h.push([E, x, v, N]) > 1 || m(E, x);
      });
    });
  }
  function m(E, x) {
    try {
      g(a[E](x));
    } catch (v) {
      y(h[0][3], v);
    }
  }
  function g(E) {
    E.value instanceof Tt ? Promise.resolve(E.value.v).then(o, l) : y(h[0][2], E);
  }
  function o(E) {
    m("next", E);
  }
  function l(E) {
    m("throw", E);
  }
  function y(E, x) {
    E(x), h.shift(), h.length && m(h[0][0], h[0][1]);
  }
}
function fo(e) {
  var r, n;
  return r = {}, a("next"), a("throw", function(s) {
    throw s;
  }), a("return"), r[Symbol.iterator] = function() {
    return this;
  }, r;
  function a(s, h) {
    r[s] = e[s] ? function(S) {
      return (n = !n) ? { value: Tt(e[s](S)), done: s === "return" } : h ? h(S) : S;
    } : h;
  }
}
function co(e) {
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  var r = e[Symbol.asyncIterator], n;
  return r ? r.call(e) : (e = typeof rr == "function" ? rr(e) : e[Symbol.iterator](), n = {}, a("next"), a("throw"), a("return"), n[Symbol.asyncIterator] = function() {
    return this;
  }, n);
  function a(h) {
    n[h] = e[h] && function(S) {
      return new Promise(function(m, g) {
        S = e[h](S), s(m, g, S.done, S.value);
      });
    };
  }
  function s(h, S, m, g) {
    Promise.resolve(g).then(function(o) {
      h({ value: o, done: m });
    }, S);
  }
}
function uo(e, r) {
  return Object.defineProperty ? Object.defineProperty(e, "raw", { value: r }) : e.raw = r, e;
}
function lo(e) {
  if (e && e.__esModule) return e;
  var r = {};
  if (e != null) for (var n in e) Object.hasOwnProperty.call(e, n) && (r[n] = e[n]);
  return r.default = e, r;
}
function ho(e) {
  return e && e.__esModule ? e : { default: e };
}
function bo(e, r) {
  if (!r.has(e))
    throw new TypeError("attempted to get private field on non-instance");
  return r.get(e);
}
function go(e, r, n) {
  if (!r.has(e))
    throw new TypeError("attempted to set private field on non-instance");
  return r.set(e, n), n;
}
const yo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  get __assign() {
    return tr;
  },
  __asyncDelegator: fo,
  __asyncGenerator: ao,
  __asyncValues: co,
  __await: Tt,
  __awaiter: to,
  __classPrivateFieldGet: bo,
  __classPrivateFieldSet: go,
  __createBinding: no,
  __decorate: Zs,
  __exportStar: io,
  __extends: Ys,
  __generator: ro,
  __importDefault: ho,
  __importStar: lo,
  __makeTemplateObject: uo,
  __metadata: eo,
  __param: Qs,
  __read: nn,
  __rest: qs,
  __spread: so,
  __spreadArrays: oo,
  __values: rr
}, Symbol.toStringTag, { value: "Module" })), po = /* @__PURE__ */ Xn(yo);
var nt = {}, Nr;
function _o() {
  if (Nr) return nt;
  Nr = 1, Object.defineProperty(nt, "__esModule", { value: !0 }), nt.isBrowserCryptoAvailable = nt.getSubtleCrypto = nt.getBrowerCrypto = void 0;
  function e() {
    return (Ze === null || Ze === void 0 ? void 0 : Ze.crypto) || (Ze === null || Ze === void 0 ? void 0 : Ze.msCrypto) || {};
  }
  nt.getBrowerCrypto = e;
  function r() {
    const a = e();
    return a.subtle || a.webkitSubtle;
  }
  nt.getSubtleCrypto = r;
  function n() {
    return !!e() && !!r();
  }
  return nt.isBrowserCryptoAvailable = n, nt;
}
var it = {}, Br;
function wo() {
  if (Br) return it;
  Br = 1, Object.defineProperty(it, "__esModule", { value: !0 }), it.isBrowser = it.isNode = it.isReactNative = void 0;
  function e() {
    return typeof document > "u" && typeof navigator < "u" && navigator.product === "ReactNative";
  }
  it.isReactNative = e;
  function r() {
    return typeof Me.process < "u" && typeof Me.process.versions < "u" && typeof Me.process.versions.node < "u";
  }
  it.isNode = r;
  function n() {
    return !e() && !r();
  }
  return it.isBrowser = n, it;
}
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 });
  const r = po;
  r.__exportStar(_o(), e), r.__exportStar(wo(), e);
})(rn);
function sn(e = 3) {
  const r = Date.now() * Math.pow(10, e), n = Math.floor(Math.random() * Math.pow(10, e));
  return r + n;
}
function Vo(e = 6) {
  return BigInt(sn(e));
}
function Xo(e, r, n) {
  return {
    id: n || sn(),
    jsonrpc: "2.0",
    method: e,
    params: r
  };
}
function Yo(e, r) {
  return {
    id: e,
    jsonrpc: "2.0",
    result: r
  };
}
function vo(e, r, n) {
  return {
    id: e,
    jsonrpc: "2.0",
    error: mo(r)
  };
}
function mo(e, r) {
  return typeof e > "u" ? Cr(en) : (typeof e == "string" && (e = Object.assign(Object.assign({}, Cr(fr)), { message: e })), Js(e.code) && (e = Vs(e.code)), e);
}
class xo {
}
class So extends xo {
  constructor() {
    super();
  }
}
class qo extends So {
  constructor(r) {
    super();
  }
}
const Eo = "^https?:", Io = "^wss?:";
function Oo(e) {
  const r = e.match(new RegExp(/^\w+:/, "gi"));
  if (!(!r || !r.length))
    return r[0];
}
function on(e, r) {
  const n = Oo(e);
  return typeof n > "u" ? !1 : new RegExp(r).test(n);
}
function Zo(e) {
  return on(e, Eo);
}
function jr(e) {
  return on(e, Io);
}
function To(e) {
  return new RegExp("wss?://localhost(:d{2,5})?").test(e);
}
function an(e) {
  return typeof e == "object" && "id" in e && "jsonrpc" in e && e.jsonrpc === "2.0";
}
function Qo(e) {
  return an(e) && "method" in e;
}
function ea(e) {
  return an(e) && (Ao(e) || Lo(e));
}
function Ao(e) {
  return "result" in e;
}
function Lo(e) {
  return "error" in e;
}
const Ro = () => typeof WebSocket < "u" ? WebSocket : typeof Me.global < "u" && typeof Me.global.WebSocket < "u" ? Me.global.WebSocket : typeof window < "u" && typeof window.WebSocket < "u" ? window.WebSocket : typeof self < "u" && typeof self.WebSocket < "u" ? self.WebSocket : require("ws"), Po = () => typeof WebSocket < "u" || typeof Me.global < "u" && typeof Me.global.WebSocket < "u" || typeof window < "u" && typeof window.WebSocket < "u" || typeof self < "u" && typeof self.WebSocket < "u", zr = (e) => e.split("?")[0], Dr = 10, Mo = Ro();
class ta {
  constructor(r) {
    if (this.url = r, this.events = new fi.EventEmitter(), this.registering = !1, !jr(r)) throw new Error(`Provided URL is not compatible with WebSocket connection: ${r}`);
    this.url = r;
  }
  get connected() {
    return typeof this.socket < "u";
  }
  get connecting() {
    return this.registering;
  }
  on(r, n) {
    this.events.on(r, n);
  }
  once(r, n) {
    this.events.once(r, n);
  }
  off(r, n) {
    this.events.off(r, n);
  }
  removeListener(r, n) {
    this.events.removeListener(r, n);
  }
  async open(r = this.url) {
    await this.register(r);
  }
  async close() {
    return new Promise((r, n) => {
      if (typeof this.socket > "u") {
        n(new Error("Connection already closed"));
        return;
      }
      this.socket.onclose = (a) => {
        this.onClose(a), r();
      }, this.socket.close();
    });
  }
  async send(r) {
    typeof this.socket > "u" && (this.socket = await this.register());
    try {
      this.socket.send(wt(r));
    } catch (n) {
      this.onError(r.id, n);
    }
  }
  register(r = this.url) {
    if (!jr(r)) throw new Error(`Provided URL is not compatible with WebSocket connection: ${r}`);
    if (this.registering) {
      const n = this.events.getMaxListeners();
      return (this.events.listenerCount("register_error") >= n || this.events.listenerCount("open") >= n) && this.events.setMaxListeners(n + 1), new Promise((a, s) => {
        this.events.once("register_error", (h) => {
          this.resetMaxListeners(), s(h);
        }), this.events.once("open", () => {
          if (this.resetMaxListeners(), typeof this.socket > "u") return s(new Error("WebSocket connection is missing or invalid"));
          a(this.socket);
        });
      });
    }
    return this.url = r, this.registering = !0, new Promise((n, a) => {
      const s = new URLSearchParams(r).get("origin"), h = rn.isReactNative() ? { headers: { origin: s } } : { rejectUnauthorized: !To(r) }, S = new Mo(r, [], h);
      Po() ? S.onerror = (m) => {
        const g = m;
        a(this.emitError(g.error));
      } : S.on("error", (m) => {
        a(this.emitError(m));
      }), S.onopen = () => {
        this.onOpen(S), n(S);
      };
    });
  }
  onOpen(r) {
    r.onmessage = (n) => this.onPayload(n), r.onclose = (n) => this.onClose(n), this.socket = r, this.registering = !1, this.events.emit("open");
  }
  onClose(r) {
    this.socket = void 0, this.registering = !1, this.events.emit("close", r);
  }
  onPayload(r) {
    if (typeof r.data > "u") return;
    const n = typeof r.data == "string" ? sr(r.data) : r.data;
    this.events.emit("payload", n);
  }
  onError(r, n) {
    const a = this.parseError(n), s = a.message || a.toString(), h = vo(r, s);
    this.events.emit("payload", h);
  }
  parseError(r, n = this.url) {
    return Xs(r, zr(n), "WS");
  }
  resetMaxListeners() {
    this.events.getMaxListeners() > Dr && this.events.setMaxListeners(Dr);
  }
  emitError(r) {
    const n = this.parseError(new Error((r == null ? void 0 : r.message) || `WebSocket connection failed for host: ${zr(this.url)}`));
    return this.events.emit("register_error", n), n;
  }
}
var Gt = { exports: {} };
Gt.exports;
(function(e, r) {
  var n = 200, a = "__lodash_hash_undefined__", s = 1, h = 2, S = 9007199254740991, m = "[object Arguments]", g = "[object Array]", o = "[object AsyncFunction]", l = "[object Boolean]", y = "[object Date]", E = "[object Error]", x = "[object Function]", v = "[object GeneratorFunction]", N = "[object Map]", F = "[object Number]", X = "[object Null]", B = "[object Object]", Te = "[object Promise]", be = "[object Proxy]", Ce = "[object RegExp]", H = "[object Set]", C = "[object String]", Ne = "[object Symbol]", et = "[object Undefined]", ge = "[object WeakMap]", Ge = "[object ArrayBuffer]", Ue = "[object DataView]", Ve = "[object Float32Array]", w = "[object Float64Array]", _ = "[object Int8Array]", Y = "[object Int16Array]", ue = "[object Int32Array]", L = "[object Uint8Array]", I = "[object Uint8ClampedArray]", O = "[object Uint16Array]", A = "[object Uint32Array]", Ae = /[\\^$.*+?()[\]{}|]/g, re = /^\[object .+?Constructor\]$/, vt = /^(?:0|[1-9]\d*)$/, j = {};
  j[Ve] = j[w] = j[_] = j[Y] = j[ue] = j[L] = j[I] = j[O] = j[A] = !0, j[m] = j[g] = j[Ge] = j[l] = j[Ue] = j[y] = j[E] = j[x] = j[N] = j[F] = j[B] = j[Ce] = j[H] = j[C] = j[ge] = !1;
  var bt = typeof Ze == "object" && Ze && Ze.Object === Object && Ze, b = typeof self == "object" && self && self.Object === Object && self, d = bt || b || Function("return this")(), u = r && !r.nodeType && r, t = u && !0 && e && !e.nodeType && e, f = t && t.exports === u, R = f && bt.process, P = function() {
    try {
      return R && R.binding && R.binding("util");
    } catch {
    }
  }(), D = P && P.isTypedArray;
  function K(i, c) {
    for (var p = -1, T = i == null ? 0 : i.length, k = 0, M = []; ++p < T; ) {
      var ee = i[p];
      c(ee, p, i) && (M[k++] = ee);
    }
    return M;
  }
  function z(i, c) {
    for (var p = -1, T = c.length, k = i.length; ++p < T; )
      i[k + p] = c[p];
    return i;
  }
  function U(i, c) {
    for (var p = -1, T = i == null ? 0 : i.length; ++p < T; )
      if (c(i[p], p, i))
        return !0;
    return !1;
  }
  function Le(i, c) {
    for (var p = -1, T = Array(i); ++p < i; )
      T[p] = c(p);
    return T;
  }
  function le(i) {
    return function(c) {
      return i(c);
    };
  }
  function Re(i, c) {
    return i.has(c);
  }
  function ye(i, c) {
    return i == null ? void 0 : i[c];
  }
  function he(i) {
    var c = -1, p = Array(i.size);
    return i.forEach(function(T, k) {
      p[++c] = [k, T];
    }), p;
  }
  function ne(i, c) {
    return function(p) {
      return i(c(p));
    };
  }
  function te(i) {
    var c = -1, p = Array(i.size);
    return i.forEach(function(T) {
      p[++c] = T;
    }), p;
  }
  var q = Array.prototype, J = Function.prototype, W = Object.prototype, ie = d["__core-js_shared__"], pe = J.toString, $ = W.hasOwnProperty, Be = function() {
    var i = /[^.]+$/.exec(ie && ie.keys && ie.keys.IE_PROTO || "");
    return i ? "Symbol(src)_1." + i : "";
  }(), ze = W.toString, We = RegExp(
    "^" + pe.call($).replace(Ae, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
  ), He = f ? d.Buffer : void 0, De = d.Symbol, Xe = d.Uint8Array, qe = W.propertyIsEnumerable, st = q.splice, $e = De ? De.toStringTag : void 0, ct = Object.getOwnPropertySymbols, mt = He ? He.isBuffer : void 0, Rt = ne(Object.keys, Object), se = gt(d, "DataView"), Z = gt(d, "Map"), oe = gt(d, "Promise"), ae = gt(d, "Set"), fe = gt(d, "WeakMap"), Q = gt(Object, "create"), _e = lt(se), we = lt(Z), ve = lt(oe), me = lt(ae), xe = lt(fe), de = De ? De.prototype : void 0, ce = de ? de.valueOf : void 0;
  function G(i) {
    var c = -1, p = i == null ? 0 : i.length;
    for (this.clear(); ++c < p; ) {
      var T = i[c];
      this.set(T[0], T[1]);
    }
  }
  function Se() {
    this.__data__ = Q ? Q(null) : {}, this.size = 0;
  }
  function Ee(i) {
    var c = this.has(i) && delete this.__data__[i];
    return this.size -= c ? 1 : 0, c;
  }
  function fn(i) {
    var c = this.__data__;
    if (Q) {
      var p = c[i];
      return p === a ? void 0 : p;
    }
    return $.call(c, i) ? c[i] : void 0;
  }
  function cn(i) {
    var c = this.__data__;
    return Q ? c[i] !== void 0 : $.call(c, i);
  }
  function un(i, c) {
    var p = this.__data__;
    return this.size += this.has(i) ? 0 : 1, p[i] = Q && c === void 0 ? a : c, this;
  }
  G.prototype.clear = Se, G.prototype.delete = Ee, G.prototype.get = fn, G.prototype.has = cn, G.prototype.set = un;
  function tt(i) {
    var c = -1, p = i == null ? 0 : i.length;
    for (this.clear(); ++c < p; ) {
      var T = i[c];
      this.set(T[0], T[1]);
    }
  }
  function ln() {
    this.__data__ = [], this.size = 0;
  }
  function hn(i) {
    var c = this.__data__, p = Mt(c, i);
    if (p < 0)
      return !1;
    var T = c.length - 1;
    return p == T ? c.pop() : st.call(c, p, 1), --this.size, !0;
  }
  function dn(i) {
    var c = this.__data__, p = Mt(c, i);
    return p < 0 ? void 0 : c[p][1];
  }
  function bn(i) {
    return Mt(this.__data__, i) > -1;
  }
  function gn(i, c) {
    var p = this.__data__, T = Mt(p, i);
    return T < 0 ? (++this.size, p.push([i, c])) : p[T][1] = c, this;
  }
  tt.prototype.clear = ln, tt.prototype.delete = hn, tt.prototype.get = dn, tt.prototype.has = bn, tt.prototype.set = gn;
  function ut(i) {
    var c = -1, p = i == null ? 0 : i.length;
    for (this.clear(); ++c < p; ) {
      var T = i[c];
      this.set(T[0], T[1]);
    }
  }
  function yn() {
    this.size = 0, this.__data__ = {
      hash: new G(),
      map: new (Z || tt)(),
      string: new G()
    };
  }
  function pn(i) {
    var c = Ct(this, i).delete(i);
    return this.size -= c ? 1 : 0, c;
  }
  function _n(i) {
    return Ct(this, i).get(i);
  }
  function wn(i) {
    return Ct(this, i).has(i);
  }
  function vn(i, c) {
    var p = Ct(this, i), T = p.size;
    return p.set(i, c), this.size += p.size == T ? 0 : 1, this;
  }
  ut.prototype.clear = yn, ut.prototype.delete = pn, ut.prototype.get = _n, ut.prototype.has = wn, ut.prototype.set = vn;
  function Pt(i) {
    var c = -1, p = i == null ? 0 : i.length;
    for (this.__data__ = new ut(); ++c < p; )
      this.add(i[c]);
  }
  function mn(i) {
    return this.__data__.set(i, a), this;
  }
  function xn(i) {
    return this.__data__.has(i);
  }
  Pt.prototype.add = Pt.prototype.push = mn, Pt.prototype.has = xn;
  function ot(i) {
    var c = this.__data__ = new tt(i);
    this.size = c.size;
  }
  function Sn() {
    this.__data__ = new tt(), this.size = 0;
  }
  function En(i) {
    var c = this.__data__, p = c.delete(i);
    return this.size = c.size, p;
  }
  function In(i) {
    return this.__data__.get(i);
  }
  function On(i) {
    return this.__data__.has(i);
  }
  function Tn(i, c) {
    var p = this.__data__;
    if (p instanceof tt) {
      var T = p.__data__;
      if (!Z || T.length < n - 1)
        return T.push([i, c]), this.size = ++p.size, this;
      p = this.__data__ = new ut(T);
    }
    return p.set(i, c), this.size = p.size, this;
  }
  ot.prototype.clear = Sn, ot.prototype.delete = En, ot.prototype.get = In, ot.prototype.has = On, ot.prototype.set = Tn;
  function An(i, c) {
    var p = Nt(i), T = !p && $n(i), k = !p && !T && Jt(i), M = !p && !T && !k && pr(i), ee = p || T || k || M, Ie = ee ? Le(i.length, String) : [], Pe = Ie.length;
    for (var V in i)
      $.call(i, V) && !(ee && // Safari 9 has enumerable `arguments.length` in strict mode.
      (V == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
      k && (V == "offset" || V == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
      M && (V == "buffer" || V == "byteLength" || V == "byteOffset") || // Skip index properties.
      Dn(V, Pe))) && Ie.push(V);
    return Ie;
  }
  function Mt(i, c) {
    for (var p = i.length; p--; )
      if (dr(i[p][0], c))
        return p;
    return -1;
  }
  function Ln(i, c, p) {
    var T = c(i);
    return Nt(i) ? T : z(T, p(i));
  }
  function xt(i) {
    return i == null ? i === void 0 ? et : X : $e && $e in Object(i) ? jn(i) : Hn(i);
  }
  function cr(i) {
    return St(i) && xt(i) == m;
  }
  function ur(i, c, p, T, k) {
    return i === c ? !0 : i == null || c == null || !St(i) && !St(c) ? i !== i && c !== c : Rn(i, c, p, T, ur, k);
  }
  function Rn(i, c, p, T, k, M) {
    var ee = Nt(i), Ie = Nt(c), Pe = ee ? g : at(i), V = Ie ? g : at(c);
    Pe = Pe == m ? B : Pe, V = V == m ? B : V;
    var ke = Pe == B, Ye = V == B, je = Pe == V;
    if (je && Jt(i)) {
      if (!Jt(c))
        return !1;
      ee = !0, ke = !1;
    }
    if (je && !ke)
      return M || (M = new ot()), ee || pr(i) ? lr(i, c, p, T, k, M) : Nn(i, c, Pe, p, T, k, M);
    if (!(p & s)) {
      var Fe = ke && $.call(i, "__wrapped__"), Je = Ye && $.call(c, "__wrapped__");
      if (Fe || Je) {
        var ft = Fe ? i.value() : i, rt = Je ? c.value() : c;
        return M || (M = new ot()), k(ft, rt, p, T, M);
      }
    }
    return je ? (M || (M = new ot()), Bn(i, c, p, T, k, M)) : !1;
  }
  function Pn(i) {
    if (!yr(i) || Un(i))
      return !1;
    var c = br(i) ? We : re;
    return c.test(lt(i));
  }
  function Mn(i) {
    return St(i) && gr(i.length) && !!j[xt(i)];
  }
  function Cn(i) {
    if (!Wn(i))
      return Rt(i);
    var c = [];
    for (var p in Object(i))
      $.call(i, p) && p != "constructor" && c.push(p);
    return c;
  }
  function lr(i, c, p, T, k, M) {
    var ee = p & s, Ie = i.length, Pe = c.length;
    if (Ie != Pe && !(ee && Pe > Ie))
      return !1;
    var V = M.get(i);
    if (V && M.get(c))
      return V == c;
    var ke = -1, Ye = !0, je = p & h ? new Pt() : void 0;
    for (M.set(i, c), M.set(c, i); ++ke < Ie; ) {
      var Fe = i[ke], Je = c[ke];
      if (T)
        var ft = ee ? T(Je, Fe, ke, c, i, M) : T(Fe, Je, ke, i, c, M);
      if (ft !== void 0) {
        if (ft)
          continue;
        Ye = !1;
        break;
      }
      if (je) {
        if (!U(c, function(rt, ht) {
          if (!Re(je, ht) && (Fe === rt || k(Fe, rt, p, T, M)))
            return je.push(ht);
        })) {
          Ye = !1;
          break;
        }
      } else if (!(Fe === Je || k(Fe, Je, p, T, M))) {
        Ye = !1;
        break;
      }
    }
    return M.delete(i), M.delete(c), Ye;
  }
  function Nn(i, c, p, T, k, M, ee) {
    switch (p) {
      case Ue:
        if (i.byteLength != c.byteLength || i.byteOffset != c.byteOffset)
          return !1;
        i = i.buffer, c = c.buffer;
      case Ge:
        return !(i.byteLength != c.byteLength || !M(new Xe(i), new Xe(c)));
      case l:
      case y:
      case F:
        return dr(+i, +c);
      case E:
        return i.name == c.name && i.message == c.message;
      case Ce:
      case C:
        return i == c + "";
      case N:
        var Ie = he;
      case H:
        var Pe = T & s;
        if (Ie || (Ie = te), i.size != c.size && !Pe)
          return !1;
        var V = ee.get(i);
        if (V)
          return V == c;
        T |= h, ee.set(i, c);
        var ke = lr(Ie(i), Ie(c), T, k, M, ee);
        return ee.delete(i), ke;
      case Ne:
        if (ce)
          return ce.call(i) == ce.call(c);
    }
    return !1;
  }
  function Bn(i, c, p, T, k, M) {
    var ee = p & s, Ie = hr(i), Pe = Ie.length, V = hr(c), ke = V.length;
    if (Pe != ke && !ee)
      return !1;
    for (var Ye = Pe; Ye--; ) {
      var je = Ie[Ye];
      if (!(ee ? je in c : $.call(c, je)))
        return !1;
    }
    var Fe = M.get(i);
    if (Fe && M.get(c))
      return Fe == c;
    var Je = !0;
    M.set(i, c), M.set(c, i);
    for (var ft = ee; ++Ye < Pe; ) {
      je = Ie[Ye];
      var rt = i[je], ht = c[je];
      if (T)
        var _r = ee ? T(ht, rt, je, c, i, M) : T(rt, ht, je, i, c, M);
      if (!(_r === void 0 ? rt === ht || k(rt, ht, p, T, M) : _r)) {
        Je = !1;
        break;
      }
      ft || (ft = je == "constructor");
    }
    if (Je && !ft) {
      var Bt = i.constructor, jt = c.constructor;
      Bt != jt && "constructor" in i && "constructor" in c && !(typeof Bt == "function" && Bt instanceof Bt && typeof jt == "function" && jt instanceof jt) && (Je = !1);
    }
    return M.delete(i), M.delete(c), Je;
  }
  function hr(i) {
    return Ln(i, Fn, zn);
  }
  function Ct(i, c) {
    var p = i.__data__;
    return Kn(c) ? p[typeof c == "string" ? "string" : "hash"] : p.map;
  }
  function gt(i, c) {
    var p = ye(i, c);
    return Pn(p) ? p : void 0;
  }
  function jn(i) {
    var c = $.call(i, $e), p = i[$e];
    try {
      i[$e] = void 0;
      var T = !0;
    } catch {
    }
    var k = ze.call(i);
    return T && (c ? i[$e] = p : delete i[$e]), k;
  }
  var zn = ct ? function(i) {
    return i == null ? [] : (i = Object(i), K(ct(i), function(c) {
      return qe.call(i, c);
    }));
  } : Jn, at = xt;
  (se && at(new se(new ArrayBuffer(1))) != Ue || Z && at(new Z()) != N || oe && at(oe.resolve()) != Te || ae && at(new ae()) != H || fe && at(new fe()) != ge) && (at = function(i) {
    var c = xt(i), p = c == B ? i.constructor : void 0, T = p ? lt(p) : "";
    if (T)
      switch (T) {
        case _e:
          return Ue;
        case we:
          return N;
        case ve:
          return Te;
        case me:
          return H;
        case xe:
          return ge;
      }
    return c;
  });
  function Dn(i, c) {
    return c = c ?? S, !!c && (typeof i == "number" || vt.test(i)) && i > -1 && i % 1 == 0 && i < c;
  }
  function Kn(i) {
    var c = typeof i;
    return c == "string" || c == "number" || c == "symbol" || c == "boolean" ? i !== "__proto__" : i === null;
  }
  function Un(i) {
    return !!Be && Be in i;
  }
  function Wn(i) {
    var c = i && i.constructor, p = typeof c == "function" && c.prototype || W;
    return i === p;
  }
  function Hn(i) {
    return ze.call(i);
  }
  function lt(i) {
    if (i != null) {
      try {
        return pe.call(i);
      } catch {
      }
      try {
        return i + "";
      } catch {
      }
    }
    return "";
  }
  function dr(i, c) {
    return i === c || i !== i && c !== c;
  }
  var $n = cr(/* @__PURE__ */ function() {
    return arguments;
  }()) ? cr : function(i) {
    return St(i) && $.call(i, "callee") && !qe.call(i, "callee");
  }, Nt = Array.isArray;
  function kn(i) {
    return i != null && gr(i.length) && !br(i);
  }
  var Jt = mt || Vn;
  function Gn(i, c) {
    return ur(i, c);
  }
  function br(i) {
    if (!yr(i))
      return !1;
    var c = xt(i);
    return c == x || c == v || c == o || c == be;
  }
  function gr(i) {
    return typeof i == "number" && i > -1 && i % 1 == 0 && i <= S;
  }
  function yr(i) {
    var c = typeof i;
    return i != null && (c == "object" || c == "function");
  }
  function St(i) {
    return i != null && typeof i == "object";
  }
  var pr = D ? le(D) : Mn;
  function Fn(i) {
    return kn(i) ? An(i) : Cn(i);
  }
  function Jn() {
    return [];
  }
  function Vn() {
    return !1;
  }
  e.exports = Gn;
})(Gt, Gt.exports);
var Co = Gt.exports;
const ra = /* @__PURE__ */ Kr(Co);
export {
  Go as A,
  Do as C,
  ko as E,
  Ho as I,
  ra as W,
  Xo as a,
  ea as b,
  ci as c,
  zo as d,
  Fo as e,
  nr as f,
  Vo as g,
  Uo as h,
  Lo as i,
  Ds as j,
  $o as k,
  wt as l,
  sr as m,
  ta as n,
  Xr as o,
  Qo as p,
  Yo as q,
  qo as r,
  Jo as s,
  ir as t,
  vo as u,
  Ao as v,
  sn as w,
  Zo as x,
  Es as y,
  Xs as z
};
