import { Q as Zt, a9 as O, aa as st, T as Yt, ab as It, Z as ht, a3 as $, ac as Nt, ad as wt, ae as ct, af as Qt, ag as dt, ah as Dt, a7 as Z, ai as Ut, aj as kt, ak as St, al as Wt } from "./index-6NRj6D5S.mjs";
import { a as Gt } from "./util--bw7gFPs.mjs";
import { g as _t } from "./wallets-B2tqS5lZ.mjs";
import { d as vt, a as Pt } from "./signer-BHB7SxtT.mjs";
var xt = { exports: {} };
(function(s) {
  var e = Object.prototype.hasOwnProperty, t = "~";
  function i() {
  }
  Object.create && (i.prototype = /* @__PURE__ */ Object.create(null), new i().__proto__ || (t = !1));
  function n(u, r, o) {
    this.fn = u, this.context = r, this.once = o || !1;
  }
  function a(u, r, o, g, y) {
    if (typeof o != "function")
      throw new TypeError("The listener must be a function");
    var d = new n(o, g || u, y), I = t ? t + r : r;
    return u._events[I] ? u._events[I].fn ? u._events[I] = [u._events[I], d] : u._events[I].push(d) : (u._events[I] = d, u._eventsCount++), u;
  }
  function h(u, r) {
    --u._eventsCount === 0 ? u._events = new i() : delete u._events[r];
  }
  function l() {
    this._events = new i(), this._eventsCount = 0;
  }
  l.prototype.eventNames = function() {
    var r = [], o, g;
    if (this._eventsCount === 0) return r;
    for (g in o = this._events)
      e.call(o, g) && r.push(t ? g.slice(1) : g);
    return Object.getOwnPropertySymbols ? r.concat(Object.getOwnPropertySymbols(o)) : r;
  }, l.prototype.listeners = function(r) {
    var o = t ? t + r : r, g = this._events[o];
    if (!g) return [];
    if (g.fn) return [g.fn];
    for (var y = 0, d = g.length, I = new Array(d); y < d; y++)
      I[y] = g[y].fn;
    return I;
  }, l.prototype.listenerCount = function(r) {
    var o = t ? t + r : r, g = this._events[o];
    return g ? g.fn ? 1 : g.length : 0;
  }, l.prototype.emit = function(r, o, g, y, d, I) {
    var A = t ? t + r : r;
    if (!this._events[A]) return !1;
    var M = this._events[A], L = arguments.length, j, N;
    if (M.fn) {
      switch (M.once && this.removeListener(r, M.fn, void 0, !0), L) {
        case 1:
          return M.fn.call(M.context), !0;
        case 2:
          return M.fn.call(M.context, o), !0;
        case 3:
          return M.fn.call(M.context, o, g), !0;
        case 4:
          return M.fn.call(M.context, o, g, y), !0;
        case 5:
          return M.fn.call(M.context, o, g, y, d), !0;
        case 6:
          return M.fn.call(M.context, o, g, y, d, I), !0;
      }
      for (N = 1, j = new Array(L - 1); N < L; N++)
        j[N - 1] = arguments[N];
      M.fn.apply(M.context, j);
    } else {
      var f = M.length, B;
      for (N = 0; N < f; N++)
        switch (M[N].once && this.removeListener(r, M[N].fn, void 0, !0), L) {
          case 1:
            M[N].fn.call(M[N].context);
            break;
          case 2:
            M[N].fn.call(M[N].context, o);
            break;
          case 3:
            M[N].fn.call(M[N].context, o, g);
            break;
          case 4:
            M[N].fn.call(M[N].context, o, g, y);
            break;
          default:
            if (!j) for (B = 1, j = new Array(L - 1); B < L; B++)
              j[B - 1] = arguments[B];
            M[N].fn.apply(M[N].context, j);
        }
    }
    return !0;
  }, l.prototype.on = function(r, o, g) {
    return a(this, r, o, g, !1);
  }, l.prototype.once = function(r, o, g) {
    return a(this, r, o, g, !0);
  }, l.prototype.removeListener = function(r, o, g, y) {
    var d = t ? t + r : r;
    if (!this._events[d]) return this;
    if (!o)
      return h(this, d), this;
    var I = this._events[d];
    if (I.fn)
      I.fn === o && (!y || I.once) && (!g || I.context === g) && h(this, d);
    else {
      for (var A = 0, M = [], L = I.length; A < L; A++)
        (I[A].fn !== o || y && !I[A].once || g && I[A].context !== g) && M.push(I[A]);
      M.length ? this._events[d] = M.length === 1 ? M[0] : M : h(this, d);
    }
    return this;
  }, l.prototype.removeAllListeners = function(r) {
    var o;
    return r ? (o = t ? t + r : r, this._events[o] && h(this, o)) : (this._events = new i(), this._eventsCount = 0), this;
  }, l.prototype.off = l.prototype.removeListener, l.prototype.addListener = l.prototype.on, l.prefixed = t, l.EventEmitter = l, s.exports = l;
})(xt);
var Bt = xt.exports;
const Vt = /* @__PURE__ */ Zt(Bt);
class x extends Error {
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
  constructor(e, t) {
    super(e), this.error = t;
  }
}
class Q extends x {
  constructor() {
    super(...arguments), this.name = "WalletNotReadyError";
  }
}
class Et extends x {
  constructor() {
    super(...arguments), this.name = "WalletLoadError";
  }
}
class P extends x {
  constructor() {
    super(...arguments), this.name = "WalletConfigError";
  }
}
class nt extends x {
  constructor() {
    super(...arguments), this.name = "WalletConnectionError";
  }
}
class ut extends x {
  constructor() {
    super(...arguments), this.name = "WalletDisconnectedError";
  }
}
class X extends x {
  constructor() {
    super(...arguments), this.name = "WalletDisconnectionError";
  }
}
class C extends x {
  constructor() {
    super(...arguments), this.name = "WalletAccountError";
  }
}
class v extends x {
  constructor() {
    super(...arguments), this.name = "WalletPublicKeyError";
  }
}
class T extends x {
  constructor() {
    super(...arguments), this.name = "WalletNotConnectedError";
  }
}
class k extends x {
  constructor() {
    super(...arguments), this.name = "WalletSendTransactionError";
  }
}
class m extends x {
  constructor() {
    super(...arguments), this.name = "WalletSignTransactionError";
  }
}
class F extends x {
  constructor() {
    super(...arguments), this.name = "WalletSignMessageError";
  }
}
class yt extends x {
  constructor() {
    super(...arguments), this.name = "WalletSignInError";
  }
}
class Rt extends x {
  constructor() {
    super(...arguments), this.name = "WalletWindowClosedError";
  }
}
var w;
(function(s) {
  s.Installed = "Installed", s.NotDetected = "NotDetected", s.Loadable = "Loadable", s.Unsupported = "Unsupported";
})(w || (w = {}));
class Ct extends Vt {
  get connected() {
    return !!this.publicKey;
  }
  async autoConnect() {
    await this.connect();
  }
  async prepareTransaction(e, t, i = {}) {
    const n = this.publicKey;
    if (!n)
      throw new T();
    return e.feePayer = e.feePayer || n, e.recentBlockhash = e.recentBlockhash || (await t.getLatestBlockhash({
      commitment: i.preflightCommitment,
      minContextSlot: i.minContextSlot
    })).blockhash, e;
  }
}
function K(s) {
  if (typeof window > "u" || typeof document > "u")
    return;
  const e = [];
  function t() {
    if (s())
      for (const a of e)
        a();
  }
  const i = (
    // TODO: #334 Replace with idle callback strategy.
    setInterval(t, 1e3)
  );
  e.push(() => clearInterval(i)), // Implies that `DOMContentLoaded` has not yet fired.
  document.readyState === "loading" && (document.addEventListener("DOMContentLoaded", t, { once: !0 }), e.push(() => document.removeEventListener("DOMContentLoaded", t))), // If the `complete` state has been reached, we're too late.
  document.readyState !== "complete" && (window.addEventListener("load", t, { once: !0 }), e.push(() => window.removeEventListener("load", t))), t();
}
function W(s) {
  return "version" in s;
}
class gt extends Ct {
  async sendTransaction(e, t, i = {}) {
    let n = !0;
    try {
      if (W(e)) {
        if (!this.supportedTransactionVersions)
          throw new k("Sending versioned transactions isn't supported by this wallet");
        if (!this.supportedTransactionVersions.has(e.version))
          throw new k(`Sending transaction version ${e.version} isn't supported by this wallet`);
        try {
          e = await this.signTransaction(e);
          const a = e.serialize();
          return await t.sendRawTransaction(a, i);
        } catch (a) {
          throw a instanceof m ? (n = !1, a) : new k(a == null ? void 0 : a.message, a);
        }
      } else
        try {
          const { signers: a, ...h } = i;
          e = await this.prepareTransaction(e, t, h), a != null && a.length && e.partialSign(...a), e = await this.signTransaction(e);
          const l = e.serialize();
          return await t.sendRawTransaction(l, h);
        } catch (a) {
          throw a instanceof m ? (n = !1, a) : new k(a == null ? void 0 : a.message, a);
        }
    } catch (a) {
      throw n && this.emit("error", a), a;
    }
  }
  async signAllTransactions(e) {
    for (const i of e)
      if (W(i)) {
        if (!this.supportedTransactionVersions)
          throw new m("Signing versioned transactions isn't supported by this wallet");
        if (!this.supportedTransactionVersions.has(i.version))
          throw new m(`Signing transaction version ${i.version} isn't supported by this wallet`);
      }
    const t = [];
    for (const i of e)
      t.push(await this.signTransaction(i));
    return t;
  }
}
class q extends gt {
}
const Y = "solana:signAndSendTransaction", at = "solana:signIn", V = "solana:signMessage", p = "solana:signTransaction", Ot = "standard:connect", jt = "standard:disconnect", bt = "standard:events";
function Jt(s) {
  return Ot in s.features && bt in s.features && (Y in s.features || p in s.features);
}
var H;
(function(s) {
  s.Mainnet = "mainnet-beta", s.Testnet = "testnet", s.Devnet = "devnet";
})(H || (H = {}));
const Ht = "Bitget";
class Xt extends q {
  constructor(e = {}) {
    super(), this.name = Ht, this.url = "https://web3.bitget.com", this.icon = "data:image/svg+xml;base64, ", this.supportedTransactionVersions = null, this._readyState = typeof window > "u" || typeof document > "u" ? w.Unsupported : w.NotDetected, this._connecting = !1, this._wallet = null, this._publicKey = null, this._readyState !== w.Unsupported && K(() => {
      var t, i;
      return (i = (t = window.bitkeep) == null ? void 0 : t.solana) != null && i.isBitKeep ? (this._readyState = w.Installed, this.emit("readyStateChange", this._readyState), !0) : !1;
    });
  }
  get publicKey() {
    return this._publicKey;
  }
  get connecting() {
    return this._connecting;
  }
  get readyState() {
    return this._readyState;
  }
  async connect() {
    try {
      if (this.connected || this.connecting)
        return;
      if (this._readyState !== w.Installed)
        throw new Q();
      this._connecting = !0;
      const e = window.bitkeep.solana;
      let t;
      try {
        t = await e.getAccount();
      } catch (n) {
        throw new C(n == null ? void 0 : n.message, n);
      }
      let i;
      try {
        i = new O(t);
      } catch (n) {
        throw new v(n == null ? void 0 : n.message, n);
      }
      this._wallet = e, this._publicKey = i, this.emit("connect", i);
    } catch (e) {
      throw this.emit("error", e), e;
    } finally {
      this._connecting = !1;
    }
  }
  async disconnect() {
    const e = this._wallet;
    if (e) {
      this._wallet = null, this._publicKey = null;
      try {
        await e.disconnect();
      } catch (t) {
        this.emit("error", new X(t == null ? void 0 : t.message, t));
      }
    }
    this.emit("disconnect");
  }
  async signTransaction(e) {
    try {
      const t = this._wallet;
      if (!t)
        throw new T();
      try {
        return await t.signTransaction(e) || e;
      } catch (i) {
        throw new m(i == null ? void 0 : i.message, i);
      }
    } catch (t) {
      throw this.emit("error", t), t;
    }
  }
  async signAllTransactions(e) {
    try {
      const t = this._wallet;
      if (!t)
        throw new T();
      try {
        return await t.signAllTransactions(e) || e;
      } catch (i) {
        throw new m(i == null ? void 0 : i.message, i);
      }
    } catch (t) {
      throw this.emit("error", t), t;
    }
  }
  async signMessage(e) {
    try {
      const t = this._wallet;
      if (!t)
        throw new T();
      try {
        const { signature: i } = await t.signMessage(e);
        return i;
      } catch (i) {
        throw new m(i == null ? void 0 : i.message, i);
      }
    } catch (t) {
      throw this.emit("error", t), t;
    }
  }
}
const Ft = "Clover";
class Kt extends q {
  constructor(e = {}) {
    super(), this.name = Ft, this.url = "https://clv.org", this.icon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDgiIGhlaWdodD0iNDgiIHZpZXdCb3g9IjAgMCA0OCA0OCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTM2LjQ4IDBIMTEuNTJDNS4xNTc2OCAwIDAgNS4xNTc2OCAwIDExLjUyVjM2LjQ4QzAgNDIuODQyMyA1LjE1NzY4IDQ4IDExLjUyIDQ4SDM2LjQ4QzQyLjg0MjMgNDggNDggNDIuODQyMyA0OCAzNi40OFYxMS41MkM0OCA1LjE1NzY4IDQyLjg0MjMgMCAzNi40OCAwWiIgZmlsbD0idXJsKCNwYWludDBfbGluZWFyXzc5MTBfMTYzMzUxKSIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTI0LjAwMDYgMzkuMzYwNkMzMi40ODM3IDM5LjM2MDYgMzkuMzYwNiAzMi40ODM3IDM5LjM2MDYgMjQuMDAwNkMzOS4zNjA2IDE1LjUxNzUgMzIuNDgzNyA4LjY0MDYyIDI0LjAwMDYgOC42NDA2MkMxNS41MTc1IDguNjQwNjIgOC42NDA2MiAxNS41MTc1IDguNjQwNjIgMjQuMDAwNkM4LjY0MDYyIDMyLjQ4MzcgMTUuNTE3NSAzOS4zNjA2IDI0LjAwMDYgMzkuMzYwNlpNMjEuMjg5OSAxNS44Njg4SDI2LjcxMVYyMS4zNDdIMjEuMjkwNFYyNi42NTRIMjYuNzExVjMyLjEzMjJIMjEuMjg5OVYyNi44MjUySDE1Ljg2OTNWMjEuMzQ3SDIxLjI4OTlWMTUuODY4OFpNMjYuNzEyIDIxLjM0N0gzMi4xMzMxVjI2LjgyNTJIMjYuNzEyVjIxLjM0N1oiIGZpbGw9ImJsYWNrIi8+CjxkZWZzPgo8bGluZWFyR3JhZGllbnQgaWQ9InBhaW50MF9saW5lYXJfNzkxMF8xNjMzNTEiIHgxPSI0OCIgeTE9Ii0xLjQzMDUxZS0wNiIgeDI9IjEuNDMwNTFlLTA2IiB5Mj0iNDgiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIj4KPHN0b3Agc3RvcC1jb2xvcj0iI0E5RkZFMCIvPgo8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiM4NkQ1RkYiLz4KPC9saW5lYXJHcmFkaWVudD4KPC9kZWZzPgo8L3N2Zz4=", this.supportedTransactionVersions = null, this._readyState = typeof window > "u" || typeof document > "u" ? w.Unsupported : w.NotDetected, this._connecting = !1, this._wallet = null, this._publicKey = null, this._readyState !== w.Unsupported && K(() => {
      var t;
      return (t = window.clover_solana) != null && t.isCloverWallet ? (this._readyState = w.Installed, this.emit("readyStateChange", this._readyState), !0) : !1;
    });
  }
  get publicKey() {
    return this._publicKey;
  }
  get connecting() {
    return this._connecting;
  }
  get readyState() {
    return this._readyState;
  }
  async connect() {
    try {
      if (this.connected || this.connecting)
        return;
      if (this._readyState !== w.Installed)
        throw new Q();
      this._connecting = !0;
      const e = window.clover_solana;
      let t;
      try {
        t = await e.getAccount();
      } catch (n) {
        throw new C(n == null ? void 0 : n.message, n);
      }
      let i;
      try {
        i = new O(t);
      } catch (n) {
        throw new v(n == null ? void 0 : n.message, n);
      }
      this._wallet = e, this._publicKey = i, this.emit("connect", i);
    } catch (e) {
      throw this.emit("error", e), e;
    } finally {
      this._connecting = !1;
    }
  }
  async disconnect() {
    this._wallet && (this._wallet = null, this._publicKey = null), this.emit("disconnect");
  }
  async signTransaction(e) {
    try {
      const t = this._wallet;
      if (!t)
        throw new T();
      try {
        return await t.signTransaction(e) || e;
      } catch (i) {
        throw new m(i == null ? void 0 : i.message, i);
      }
    } catch (t) {
      throw this.emit("error", t), t;
    }
  }
  async signAllTransactions(e) {
    try {
      const t = this._wallet;
      if (!t)
        throw new T();
      try {
        return await t.signAllTransactions(e) || e;
      } catch (i) {
        throw new m(i == null ? void 0 : i.message, i);
      }
    } catch (t) {
      throw this.emit("error", t), t;
    }
  }
  async signMessage(e) {
    try {
      const t = this._wallet;
      if (!t)
        throw new T();
      try {
        const { signature: i } = await t.signMessage(e);
        return Uint8Array.from(i);
      } catch (i) {
        throw new F(i == null ? void 0 : i.message, i);
      }
    } catch (t) {
      throw this.emit("error", t), t;
    }
  }
}
const qt = "Coin98";
class $t extends q {
  constructor(e = {}) {
    super(), this.name = qt, this.url = "https://coin98.com", this.icon = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA3NiA3NSI+CiAgPGRlZnM+CiAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImEiIHgxPSIxMDEuNjgxJSIgeDI9Ii0xLjU1NyUiIHkxPSIxNS4yNjglIiB5Mj0iODQuOTE3JSI+CiAgICAgIDxzdG9wIG9mZnNldD0iMCUiIHN0b3AtY29sb3I9IiNGMUQ5NjEiLz4KICAgICAgPHN0b3Agb2Zmc2V0PSIxMDAlIiBzdG9wLWNvbG9yPSIjQ0RBMTQ2Ii8+CiAgICA8L2xpbmVhckdyYWRpZW50PgogIDwvZGVmcz4KICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgPHJlY3Qgd2lkdGg9Ijc1IiBoZWlnaHQ9Ijc1IiBmaWxsPSIjMDAwIiByeD0iMTYiLz4KICAgIDxwYXRoIGZpbGw9InVybCgjYSkiIGZpbGwtcnVsZT0ibm9uemVybyIgZD0iTTYxLjQ0IDBhMTMu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2LjkxMSAwIDAgMS0xLjUtNy41MzYgNi45MTggNi45MTggMCAwIDEgMi41NS0zLjEwMyA2LjkzNyA2LjkzNyAwIDAgMSAzLjg1LTEuMTY2Wm0yNC41Ni00LjgxYTEwLjA1OSAxMC4wNTkgMCAwIDAtNy4xMDMgMi45NCAxMC4wMiAxMC4wMiAwIDAgMC0yLjk0IDcuMDkgOS45IDkuOSAwIDAgMCAxLjIzIDQuNzk1IDEzLjU3NSAxMy41NzUgMCAwIDEgNC4yMTQtMi4zMjIgNS4wODIgNS4wODIgMCAwIDEtLjYyNS0yLjQ3NyA1LjIwNiA1LjIwNiAwIDAgMSAxLjUwMy0zLjczNiA1LjIyMyA1LjIyMyAwIDAgMSAzLjcyMi0xLjU1NCA1LjIzNCA1LjIzNCAwIDAgMSAzLjcyIDEuNTU0IDUuMjEzIDUuMjEzIDAgMCAxIDEuNTA1IDMuNzM2IDUuMjc5IDUuMjc5IDAgMCAxLS42MjMgMi40NzMgMTMuNTc0IDEzLjU3NCAwIDAgMSA0LjIxMyAyLjMyMiA5LjkwMyA5LjkwMyAwIDAgMCAxLjIzLTQuNzk1IDEwLjAzMiAxMC4wMzIgMCAwIDAtMi45NDYtNy4wODYgMTAuMDcgMTAuMDcgMCAwIDAtNy4xLTIuOTRabS0yMy43NSA3Ljk5aC0xLjYxN3YxLjc1YTIuNDE5IDIuNDE5IDAgMCAwLTEuNTgyIDIuNjg3IDIuNDE0IDIuNDE0IDAgMCAwIDIuMzkgMi4wMDYgMi40NSAyLjQ1IDAgMCAwIDEuNTU1LS41NzQgMi40MTQgMi40MTQgMCAwIDAtLjc0Ni00LjExOXYtMS43NVoiLz4KICA8L2c+Cjwvc3ZnPgo=", this.supportedTransactionVersions = null, this._readyState = typeof window > "u" || typeof document > "u" ? w.Unsupported : w.NotDetected, this._connecting = !1, this._wallet = null, this._publicKey = null, this._readyState !== w.Unsupported && K(() => {
      var t;
      return (t = window.coin98) != null && t.sol ? (this._readyState = w.Installed, this.emit("readyStateChange", this._readyState), !0) : !1;
    });
  }
  get publicKey() {
    return this._publicKey;
  }
  get connecting() {
    return this._connecting;
  }
  get connected() {
    var e;
    return !!((e = this._wallet) != null && e.isConnected());
  }
  get readyState() {
    return this._readyState;
  }
  async connect() {
    try {
      if (this.connected || this.connecting)
        return;
      if (this._readyState !== w.Installed)
        throw new Q();
      this._connecting = !0;
      const e = window.coin98.sol;
      let t;
      try {
        t = (await e.connect())[0];
      } catch (n) {
        throw new C(n == null ? void 0 : n.message, n);
      }
      let i;
      try {
        i = new O(t);
      } catch (n) {
        throw new v(n == null ? void 0 : n.message, n);
      }
      this._wallet = e, this._publicKey = i, this.emit("connect", i);
    } catch (e) {
      throw this.emit("error", e), e;
    } finally {
      this._connecting = !1;
    }
  }
  async disconnect() {
    const e = this._wallet;
    if (e) {
      this._wallet = null, this._publicKey = null;
      try {
        await e.disconnect();
      } catch (t) {
        this.emit("error", new X(t == null ? void 0 : t.message, t));
      }
    }
    this.emit("disconnect");
  }
  async signTransaction(e) {
    try {
      const t = this._wallet;
      if (!t)
        throw new T();
      try {
        const i = await t.request({ method: "sol_sign", params: [e] }), n = new O(i.publicKey), a = st.decode(i.signature);
        return e.addSignature(n, a), e;
      } catch (i) {
        throw new m(i == null ? void 0 : i.message, i);
      }
    } catch (t) {
      throw this.emit("error", t), t;
    }
  }
  async signAllTransactions(e) {
    try {
      const t = this._wallet;
      if (!t)
        throw new T();
      try {
        const i = await t.request({ method: "sol_signAllTransactions", params: [e] }), n = new O(i.publicKey), a = i.signatures;
        return e.map((h, l) => {
          const u = st.decode(a[l]);
          return h.addSignature(n, u), h;
        });
      } catch (i) {
        throw new m(i == null ? void 0 : i.message, i);
      }
    } catch (t) {
      throw this.emit("error", t), t;
    }
  }
  async signMessage(e) {
    try {
      const t = this._wallet;
      if (!t)
        throw new T();
      try {
        const i = await t.request({ method: "sol_signMessage", params: [e] });
        return st.decode(i.signature);
      } catch (i) {
        throw new F(i == null ? void 0 : i.message, i);
      }
    } catch (t) {
      throw this.emit("error", t), t;
    }
  }
}
const te = "Nightly";
class ee extends q {
  constructor() {
    super(), this.name = te, this.url = "https://nightly.app", this.icon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iOTYiIGhlaWdodD0iOTYiIHZpZXdCb3g9IjAgMCA5NiA5NiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTQ4IDk2Qzc0LjUwOTcgOTYgOTYgNzQuNTA5NyA5NiA0OEM5NiAyMS40OTAzIDc0LjUwOTcgMCA0OCAwQzIxLjQ5MDMgMCAwIDIxLjQ5MDMgMCA0OEMwIDc0LjUwOTcgMjEuNDkwMyA5NiA0OCA5NloiIGZpbGw9IiM2RDczRjgiLz4KPHBhdGggZD0iTTQ4IDg1LjYzNTZDNDggODUuNjM1NiA1Mi40NTMzIDg1LjYzNTYgNTUuNDQgODIuNTg2N0M1OC45MTU1IDc5LjI4MDEgNTcuMzUxMSA3NS40MzEyIDYyLjI3NTUgNzEuNDMxMkM2Ni45ODY2IDY3LjY0NDUgNzIuOTI0NCA3MC4zMzc5IDcyLjkyNDQgNzAuMzM3OUM3Ny4wMjIyIDYyLjEyNDUgNzQuNzkxMSA1Mi41NjkgNzQuNzkxMSA1Mi41NjlDODEuNzY4OCAzNC4yNTc5IDc1Ljk2NDQgMjEuMTU1NyA3NC40NDQ0IDE3LjM2MDFDNjkuNDQ4OCAyNC4zMzc5IDYzLjE5MTEgMjkuMTczNCA1NS43OTU1IDMyLjQwOUM1My4yMjY2IDMxLjcwNjggNTAuNTk1NSAzMS4zMzM0IDQ4IDMxLjM2MDFDNDUuNDEzMyAzMS4zMzM0IDQyLjc3MzMgMzEuNzA2OCA0MC4yMDQ0IDMyLjQwOUMzMi44MTc3IDI5LjE2NDUgMjYuNTUxMSAyNC4zMzc5IDIxLjU1NTUgMTcuMzYwMUMyMC4wMzU1IDIxLjE1NTcgMTQuMjMxMSAzNC4yNTc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SJNNzMuNTAyMiAyMy4wOTM1Qzc1LjkxMTEgMzEuNTQ2OCA3NC44NzExIDQyLjI0MDIgNzEuMDY2NiA1MC4wMjY5QzY3LjE3MzMgNDcuMjcxMyA2My4wODQ0IDQzLjAxMzUgNjAuOTA2NiAzOC41MDY5QzY2LjAzNTUgMzQuNzExMyA3MC4zMzc3IDMxLjEwMjQgNzMuNTAyMiAyMy4wOTM1WiIgZmlsbD0iIzdCODFGOSIvPgo8cGF0aCBkPSJNNDcuOTk5OSA4NS4zMDY5QzUwLjE0MDQgODUuMzA2OSA1MS44NzU1IDgzLjc3ODcgNTEuODc1NSA4MS44OTM2QzUxLjg3NTUgODAuMDA4NCA1MC4xNDA0IDc4LjQ4MDIgNDcuOTk5OSA3OC40ODAyQzQ1Ljg1OTUgNzguNDgwMiA0NC4xMjQ0IDgwLjAwODQgNDQuMTI0NCA4MS44OTM2QzQ0LjEyNDQgODMuNzc4NyA0NS44NTk1IDg1LjMwNjkgNDcuOTk5OSA4NS4zMDY5WiIgZmlsbD0iIzdCODFGOSIvPgo8L3N2Zz4K", this.supportedTransactionVersions = /* @__PURE__ */ new Set(["legacy", 0]), this._readyState = typeof window > "u" || typeof document > "u" ? w.Unsupported : w.NotDetected, this._connecting = !1, this._publicKey = null, this._wallet = null, this._readyState !== w.Unsupported && K(() => {
      var e;
      return (e = window == null ? void 0 : window.nightly) != null && e.solana ? (this._readyState = w.Installed, this.emit("readyStateChange", this._readyState), !0) : !1;
    });
  }
  get connecting() {
    return this._connecting;
  }
  get readyState() {
    return this._readyState;
  }
  get publicKey() {
    return this._publicKey;
  }
  async connect() {
    try {
      if (this.connected || this.connecting)
        return;
      if (this._readyState !== w.Installed)
        throw new Q();
      this._connecting = !0;
      const e = window.nightly.solana;
      try {
        await e.connect();
      } catch (i) {
        throw new nt(i == null ? void 0 : i.message, i);
      }
      if (e.publicKey.toString() === "11111111111111111111111111111111")
        throw new C();
      let t;
      try {
        t = new O(e.publicKey.toBytes());
      } catch (i) {
        throw new v(i == null ? void 0 : i.message, i);
      }
      this._wallet = e, this._publicKey = t, this.emit("connect", t);
    } catch (e) {
      throw this.emit("error", e), e;
    } finally {
      this._connecting = !1;
    }
  }
  async disconnect() {
    const e = this._wallet;
    if (e) {
      this._wallet = null, this._publicKey = null;
      try {
        await e.disconnect();
      } catch {
        this.emit("error", new ut());
      }
    }
    this.emit("disconnect");
  }
  async signTransaction(e) {
    try {
      const t = this._wallet;
      if (!t)
        throw new T();
      try {
        return await t.signTransaction(e);
      } catch (i) {
        throw new m(i == null ? void 0 : i.message, i);
      }
    } catch (t) {
      throw this.emit("error", t), t;
    }
  }
  async signAllTransactions(e) {
    try {
      const t = this._wallet;
      if (!t)
        throw new T();
      try {
        return await t.signAllTransactions(e);
      } catch (i) {
        throw new m(i == null ? void 0 : i.message, i);
      }
    } catch (t) {
      throw this.emit("error", t), t;
    }
  }
  async signMessage(e) {
    try {
      const t = this._wallet;
      if (!t)
        throw new T();
      try {
        return t.signMessage(new TextDecoder().decode(e));
      } catch (i) {
        throw new m(i == null ? void 0 : i.message, i);
      }
    } catch (t) {
      throw this.emit("error", t), t;
    }
  }
}
const At = "solana:mainnet", ie = "solana:devnet", ne = "solana:testnet", se = "solana:localnet", ae = "Solong";
class re extends gt {
  constructor(e = {}) {
    super(), this.name = ae, this.url = "https://solongwallet.io", this.icon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAGlklEQVR4Ae3bA5DsyhfH8TNr49r2/du2bdu2bdu2zcdNrm3b9toz533rvctUn3Umk9p01WfdvVW/6nROBxJVS1rSkpa0pCUtaUlLWtKSpl4VXos3GJ4sujQFuUKfWl+qT730arzB8Ex9YksKcgXjFOCVeIPhBYydB8mawQ+yiGC8n0EN6zAVcgXhpQjoq1DDdsyDAAB9Pwo1HMC9INk0FIM8Bt1Qh9WohQQCvD+BtEMdtmC8I7y5aIE67MV0SBwDvB3qsE/UHwMJIpC/QB1OYiLEEeCPoQ7nM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to+iSPEif8aGPcjrA50GHyPMiOIT9B/N5apaMgQT8D2poxMdwt8s+hkao4X9ZDxBTIdHwy/h8AeqQxhMhAU9BB9ThPMqHTYCYjU6owy3uPstSfL4Z6uZPC+Mk8gOomz8DEg3vXshAHb4MMXwZarhXGDPwa739w2j48623BPAniOFPUMPsMAL8INTw9AgDrLZOCmjFPEjA3WD1aUJVGAG+CGr4ECRCy6GGg3iyaF0+n/PwFByEGpaJ+qkw1sB7QA3/hUTozdBetFymvXhTWGVMOc7bp36/FhKRamNW9dcxZmpZiI+32ad+vAQSoWejGzpAXXh22Fek3wY1rDD2kVnijR3ExYQMPgkJOUB/nFW0Is3vnw6JhlHX9a4N70Iq/ACBv0MNu7J9WxHw7jaA2deFOtw32zeVHtHLWvMN0dtSkOzwS3spYy7iH1hx2d/wYdyTvnkR3BdeQjjerVBDN14JyZIfQWH5RC7e1rw32npZV54LCc+SPD5/HgqYD3WW5+gTqt6X+rA4v0701hRkKF0+bL+HTM9Hgv/MHH60wyvHWigsafwA1ZAhMguLoL34kbDcQEI1uAH8mcbuxPHImf8i5EMGxqvER9EI7cUqVMTl0Y6HoxHaBzvxNkyC9EEe7oEv4Sy0D/YQ+IS4ver1JNT38z7sWnwbb8TT8Cg8Gs/Gu/Ar7EEXtI/2ud7Ni0GAYCbiJDQiazA57k9nTcdqaJb9UtSvitXbmjavCJ9AMzRkJ/B80boUJBLhDe7Nw1/QCR1i9fgKRg6HByzvjZ/hInQQMjiCT2PSMHxC1a/l8wvwGxyG9kEaW/EtPI4xiiE5JcLrd6PxcLwM78SH8EG8Fc/H/UUXVUByGh8SSYBJgEmASYCJJMAkwBi6A3xCqZhiBz8+AAAAAElFTkSuQmCC", this.supportedTransactionVersions = null, this._readyState = typeof window > "u" || typeof document > "u" ? w.Unsupported : w.NotDetected, this._connecting = !1, this._wallet = null, this._publicKey = null, this._readyState !== w.Unsupported && K(() => window.solong ? (this._readyState = w.Installed, this.emit("readyStateChange", this._readyState), !0) : !1);
  }
  get publicKey() {
    return this._publicKey;
  }
  get connecting() {
    return this._connecting;
  }
  get connected() {
    var e;
    return !!((e = this._wallet) != null && e.currentAccount);
  }
  get readyState() {
    return this._readyState;
  }
  async connect() {
    try {
      if (this.connected || this.connecting)
        return;
      if (this._readyState !== w.Installed)
        throw new Q();
      this._connecting = !0;
      const e = window.solong;
      let t;
      try {
        t = await e.selectAccount();
      } catch (n) {
        throw new C(n == null ? void 0 : n.message, n);
      }
      let i;
      try {
        i = new O(t);
      } catch (n) {
        throw new v(n == null ? void 0 : n.message, n);
      }
      this._wallet = e, this._publicKey = i, this.emit("connect", i);
    } catch (e) {
      throw this.emit("error", e), e;
    } finally {
      this._connecting = !1;
    }
  }
  async disconnect() {
    this._wallet && (this._wallet = null, this._publicKey = null), this.emit("disconnect");
  }
  async signTransaction(e) {
    try {
      const t = this._wallet;
      if (!t)
        throw new T();
      try {
        return await t.signTransaction(e) || e;
      } catch (i) {
        throw new m(i == null ? void 0 : i.message, i);
      }
    } catch (t) {
      throw this.emit("error", t), t;
    }
  }
}
const ce = "Torus";
class oe extends q {
  constructor({ params: e = { showTorusButton: !1 } } = { params: { showTorusButton: !1 } }) {
    super(), this.name = ce, this.url = "https://tor.us", this.icon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzMiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMyAzMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iMTYuNSIgY3k9IjE2IiByPSIxNiIgZmlsbD0iIzAzNjRGRiIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTExLjIxODYgOS40OTIxOUMxMC40NTM5IDkuNDkyMTkgOS44MzM5OCAxMC4xMTIxIDkuODMzOTggMTAuODc2OFYxMi40ODk4QzkuODMzOTggMTMuMjU0NSAxMC40NTM5IDEzLjg3NDQgMTEuMjE4NiAxMy44NzQ0SDEzLjY2ODRWMjIuODk3NkMxMy42Njg0IDIzLjY2MjMgMTQuMjg4MyAyNC4yODIyIDE1LjA1MyAyNC4yODIySDE2LjY2NkMxNy40MzA3IDI0LjI4MjIgMTguMDUwNiAyMy42NjIzIDE4LjA1MDYgMjIuODk3NlYxMi41MDE1QzE4LjA1MDYgMTIuNDk3NiAxOC4wNTA2IDEyLjQ5MzcgMTguMDUwNiAxMi40ODk4VjEwLjg3NjhDMTguMDUwNiAxMC4xMTIxIDE3LjQzMDcgOS40OTIxOSAxNi42NjYgOS40OTIxOUgxNS4wNTNIMTEuMjE4NloiIGZpbGw9IndoaXRlIi8+CjxwYXRoIGQ9Ik0yMS4zMzc2IDEzLjg3NDRDMjIuNTQ3NyAxMy44NzQ0IDIzLjUyODcgMTIuODkzNCAyMy41Mjg3IDExLjY4MzNDMjMuNTI4NyAxMC40NzMyIDIyLjU0NzcgOS40OTIxOSAyMS4zMzc2IDkuNDkyMTlDMjAuMTI3NSA5LjQ5MjE5IDE5LjE0NjUgMTAuNDczMiAxOS4xNDY1IDExLjY4MzNDMTkuMTQ2NSAxMi44OTM0IDIwLjEyNzUgMTMuODc0NCAyMS4zMzc2IDEzLjg3NDRaIiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4K", this.supportedTransactionVersions = null, this._readyState = typeof window > "u" || typeof document > "u" ? w.Unsupported : w.Loadable, this._connecting = !1, this._wallet = null, this._publicKey = null, this._params = e;
  }
  get publicKey() {
    return this._publicKey;
  }
  get connecting() {
    return this._connecting;
  }
  get connected() {
    var e;
    return !!((e = this._wallet) != null && e.isLoggedIn);
  }
  get readyState() {
    return this._readyState;
  }
  async connect() {
    try {
      if (this.connected || this.connecting)
        return;
      if (this._readyState !== w.Loadable)
        throw new Q();
      this._connecting = !0;
      let e;
      try {
        e = (await import("./solanaEmbed.esm-BZupTABA.mjs")).default;
      } catch (a) {
        throw new Et(a == null ? void 0 : a.message, a);
      }
      let t;
      try {
        t = window.torus || new e();
      } catch (a) {
        throw new P(a == null ? void 0 : a.message, a);
      }
      if (!t.isInitialized)
        try {
          await t.init(this._params);
        } catch (a) {
          throw new nt(a == null ? void 0 : a.message, a);
        }
      let i;
      try {
        i = await t.login();
      } catch (a) {
        throw new C(a == null ? void 0 : a.message, a);
      }
      let n;
      try {
        n = new O(i[0]);
      } catch (a) {
        throw new v(a == null ? void 0 : a.message, a);
      }
      this._wallet = t, this._publicKey = n, this.emit("connect", n);
    } catch (e) {
      throw this.emit("error", e), e;
    } finally {
      this._connecting = !1;
    }
  }
  async disconnect() {
    const e = this._wallet;
    if (e) {
      this._wallet = null, this._publicKey = null;
      try {
        e.isLoggedIn && await e.cleanUp();
      } catch (t) {
        this.emit("error", new X(t == null ? void 0 : t.message, t));
      }
    }
    this.emit("disconnect");
  }
  async sendTransaction(e, t, i = {}) {
    try {
      const n = this._wallet;
      if (!n)
        throw new T();
      try {
        const { signers: a, ...h } = i;
        e = await this.prepareTransaction(e, t, h), a != null && a.length && e.partialSign(...a), h.preflightCommitment = h.preflightCommitment || t.commitment;
        const { signature: l } = await n.signAndSendTransaction(e, h);
        return l;
      } catch (a) {
        throw a instanceof x ? a : new k(a == null ? void 0 : a.message, a);
      }
    } catch (n) {
      throw this.emit("error", n), n;
    }
  }
  async signTransaction(e) {
    try {
      const t = this._wallet;
      if (!t)
        throw new T();
      try {
        return await t.signTransaction(e) || e;
      } catch (i) {
        throw new m(i == null ? void 0 : i.message, i);
      }
    } catch (t) {
      throw this.emit("error", t), t;
    }
  }
  async signAllTransactions(e) {
    try {
      const t = this._wallet;
      if (!t)
        throw new T();
      try {
        return await t.signAllTransactions(e) || e;
      } catch (i) {
        throw new m(i == null ? void 0 : i.message, i);
      }
    } catch (t) {
      throw this.emit("error", t), t;
    }
  }
  async signMessage(e) {
    try {
      const t = this._wallet;
      if (!t)
        throw new T();
      try {
        return await t.signMessage(e);
      } catch (i) {
        throw new F(i == null ? void 0 : i.message, i);
      }
    } catch (t) {
      throw this.emit("error", t), t;
    }
  }
}
function rt(s) {
  switch (s) {
    case "processed":
    case "confirmed":
    case "finalized":
    case void 0:
      return s;
    case "recent":
      return "processed";
    case "single":
    case "singleGossip":
      return "confirmed";
    case "max":
    case "root":
      return "finalized";
    default:
      return;
  }
}
const Me = "https://api.mainnet-beta.solana.com";
function le(s) {
  return s.includes(Me) ? At : /\bdevnet\b/i.test(s) ? ie : /\btestnet\b/i.test(s) ? ne : /\blocalhost\b/i.test(s) || /\b127\.0\.0\.1\b/.test(s) ? se : At;
}
const ue = "WalletConnect";
class ge extends gt {
  constructor(e) {
    super(), this.name = ue, this.url = "https://walletconnect.org", this.icon = "data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjE4NSIgdmlld0JveD0iMCAwIDMwMCAxODUiIHdpZHRoPSIzMDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0ibTYxLjQzODU0MjkgMzYuMjU2MjYxMmM0OC45MTEyMjQxLTQ3Ljg4ODE2NjMgMTI4LjIxMTk4NzEtNDcuODg4MTY2MyAxNzcuMTIzMjA5MSAwbDUuODg2NTQ1IDUuNzYzNDE3NGMyLjQ0NTU2MSAyLjM5NDQwODEgMi40NDU1NjEgNi4yNzY1MTEyIDAgOC42NzA5MjA0bC0yMC4xMzY2OTUgMTkuNzE1NTAzYy0xLjIyMjc4MSAxLjE5NzIwNTEtMy4yMDUzIDEuMTk3MjA1MS00LjQyODA4MSAwbC04LjEwMDU4NC03LjkzMTE0NzljLTM0LjEyMTY5Mi0zMy40MDc5ODE3LTg5LjQ0Mzg4Ni0zMy40MDc5ODE3LTEyMy41NjU1Nzg4IDBsLTguNjc1MDU2MiA4LjQ5MzYwNTFjLTEuMjIyNzgxNiAxLjE5NzIwNDEtMy4yMDUzMDEgMS4xOTcyMDQxLTQuNDI4MDgwNiAwbC0yMC4xMzY2OTQ5LTE5LjcxNTUwMzFjLTIuNDQ1NTYxMi0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xNTUzMzNjMi40NDU1MDUtMi4zOTQ0NjMzIDYuNDEwNTQ0LTIuMzk0NTUzMSA4Ljg1NjE2MS0uMDAwMi4wMDAwMzQuMDAwMDMzNi4wMDAwNjguMDAwMDY3My4wMDAxMDEuMDAwMTAxbDU3LjM1NDkwMiA1Ni4xNTU0MzJjLjYxMTM5LjU5ODYwMSAxLjYwMjY1LjU5ODYwMSAyLjIxNDA0IDBsNTcuMzUzOTc1LTU2LjE1NDMyNDljMi40NDU1NjEtMi4zOTQ0MDkyIDYuNDEwNTk5LTIuMzk0NDA5MiA4Ljg1NjE2IDB6IiBmaWxsPSIjM2I5OWZjIi8+PC9zdmc+", this.supportedTransactionVersions = /* @__PURE__ */ new Set(["legacy", 0]), this._readyState = typeof window > "u" ? w.Unsupported : w.Loadable, this._disconnected = () => {
      const t = this._wallet;
      t && (t.client.off("session_delete", this._disconnected), this._wallet = null, this._publicKey = null, this.emit("error", new ut()), this.emit("disconnect"));
    }, this._publicKey = null, this._connecting = !1, this._wallet = null, this._config = e;
  }
  get publicKey() {
    return this._publicKey;
  }
  get connecting() {
    return this._connecting;
  }
  get readyState() {
    return this._readyState;
  }
  async connect() {
    try {
      if (this.connected || this.connecting)
        return;
      if (this._readyState !== w.Loadable)
        throw new Q();
      this._connecting = !0;
      let e, t;
      try {
        ({ WalletConnectWallet: e, WalletConnectChainID: t } = await import("./index-BArAN3-r.mjs"));
      } catch (a) {
        throw new Et(a == null ? void 0 : a.message, a);
      }
      let i, n;
      try {
        i = new e({
          network: this._config.network === H.Mainnet ? t.Mainnet : t.Devnet,
          options: this._config.options
        }), { publicKey: n } = await i.connect();
      } catch (a) {
        throw a.constructor.name === "QRCodeModalError" ? new Rt() : new nt(a == null ? void 0 : a.message, a);
      }
      i.client.on("session_delete", this._disconnected), this._wallet = i, this._publicKey = n, this.emit("connect", n);
    } catch (e) {
      throw this.emit("error", e), e;
    } finally {
      this._connecting = !1;
    }
  }
  async disconnect() {
    const e = this._wallet;
    if (e) {
      e.client.off("session_delete", this._disconnected), this._wallet = null, this._publicKey = null;
      try {
        await e.disconnect();
      } catch (t) {
        this.emit("error", new X(t == null ? void 0 : t.message, t));
      }
    }
    this.emit("disconnect");
  }
  async signTransaction(e) {
    try {
      const t = this._wallet;
      if (!t)
        throw new T();
      try {
        return await t.signTransaction(e);
      } catch (i) {
        throw new m(i == null ? void 0 : i.message, i);
      }
    } catch (t) {
      throw this.emit("error", t), t;
    }
  }
  async signMessage(e) {
    try {
      const t = this._wallet;
      if (!t)
        throw new T();
      try {
        return await t.signMessage(e);
      } catch (i) {
        throw new F(i == null ? void 0 : i.message, i);
      }
    } catch (t) {
      throw this.emit("error", t), t;
    }
  }
}
const Ie = {
  icon: "data:image/svg+xml;base64, ",
  name: "Bitget Wallet"
}, he = [Ie], Ne = (s) => he.find((e) => e.name.toLocaleLowerCase().includes(s.name.toLocaleLowerCase())) || s, we = (s, e, t) => e[s] || t[s], Tt = (s, e) => we(s, Ne(e), e);
class b extends Yt {
  constructor(e, t) {
    super(), this.adapter = e, this.connection = t;
  }
  /** Retrieve the underlying solana adapter */
  getAdapter() {
    return this.adapter;
  }
  getName() {
    return Tt("name", this.adapter);
  }
  getUrl() {
    return this.adapter.url;
  }
  async connect() {
    if (this.isConnected())
      return this.getAddresses();
    const e = await new Promise((t, i) => {
      this.adapter.on("connect", () => {
        this.adapter.off("connect"), this.adapter.off("error"), t(this.getAddresses());
      }), this.adapter.on("error", (n) => {
        this.adapter.off("connect"), this.adapter.off("error"), i(n);
      }), this.adapter.connect().catch(i);
    });
    return this.emit("connect"), this.adapter.on("disconnect", () => this.emit("disconnect")), e;
  }
  getNetworkInfo() {
    return {};
  }
  isConnected() {
    return this.adapter.connected;
  }
  async disconnect() {
    this.isConnected() && (await new Promise((e, t) => {
      this.adapter.on("disconnect", () => {
        this.adapter.off("disconnect"), this.adapter.off("error"), e(void 0);
      }), this.adapter.on("error", (i) => {
        this.adapter.off("disconnect"), this.adapter.off("error"), t(i);
      }), this.adapter.disconnect().catch(t);
    }), this.adapter.removeAllListeners(), this.emit("disconnect"));
  }
  getChainId() {
    return It;
  }
  getAddress() {
    var e;
    return (e = this.adapter.publicKey) == null ? void 0 : e.toString();
  }
  getAddresses() {
    const e = this.getAddress();
    return e ? [e] : [];
  }
  setMainAddress() {
    throw new Error("Not supported");
  }
  getBalance() {
    throw new Error("Not supported");
  }
  async signTransaction(e) {
    if (!this.adapter.signTransaction || !this.adapter.signAllTransactions)
      throw new Error("Not supported");
    return Array.isArray(e) ? this.adapter.signAllTransactions(e) : this.adapter.signTransaction(e);
  }
  async sendTransaction(e) {
    var a;
    const { transaction: t } = e, i = Array.isArray(t) ? t : [t];
    if (i.length === 0)
      throw new Error("Empty transactions array");
    const n = [];
    for (const h of i) {
      const l = await this.adapter.sendTransaction(h, this.connection, {
        ...e.options
      });
      n.push(l);
    }
    return await this.connection.confirmTransaction(n[0], (a = e.options) == null ? void 0 : a.commitment), {
      id: n[0],
      data: n.length === 1 ? n[0] : n
    };
  }
  async signAndSendTransaction(e) {
    return this.sendTransaction(e);
  }
  signMessage(e) {
    if (!this.adapter.signMessage)
      throw new Error("Not supported");
    return this.adapter.signMessage(e);
  }
  getIcon() {
    return Tt("icon", this.adapter);
  }
  getWalletState() {
    const e = this.adapter.readyState;
    if (!(e in ht))
      throw new Error(`Unknown wallet state ${e}`);
    return ht[e];
  }
  getFeatures() {
    const e = [
      $.SendTransaction,
      $.SignAndSendTransaction
    ];
    return this.adapter.signTransaction && this.adapter.signAllTransactions && e.push($.SignTransaction), this.adapter.signMessage && e.push($.SignMessage), e;
  }
  supportsChain(e) {
    return e === It;
  }
}
function de(s) {
  if (s.length >= 255)
    throw new TypeError("Alphabet too long");
  const e = new Uint8Array(256);
  for (let r = 0; r < e.length; r++)
    e[r] = 255;
  for (let r = 0; r < s.length; r++) {
    const o = s.charAt(r), g = o.charCodeAt(0);
    if (e[g] !== 255)
      throw new TypeError(o + " is ambiguous");
    e[g] = r;
  }
  const t = s.length, i = s.charAt(0), n = Math.log(t) / Math.log(256), a = Math.log(256) / Math.log(t);
  function h(r) {
    if (r instanceof Uint8Array || (ArrayBuffer.isView(r) ? r = new Uint8Array(r.buffer, r.byteOffset, r.byteLength) : Array.isArray(r) && (r = Uint8Array.from(r))), !(r instanceof Uint8Array))
      throw new TypeError("Expected Uint8Array");
    if (r.length === 0)
      return "";
    let o = 0, g = 0, y = 0;
    const d = r.length;
    for (; y !== d && r[y] === 0; )
      y++, o++;
    const I = (d - y) * a + 1 >>> 0, A = new Uint8Array(I);
    for (; y !== d; ) {
      let j = r[y], N = 0;
      for (let f = I - 1; (j !== 0 || N < g) && f !== -1; f--, N++)
        j += 256 * A[f] >>> 0, A[f] = j % t >>> 0, j = j / t >>> 0;
      if (j !== 0)
        throw new Error("Non-zero carry");
      g = N, y++;
    }
    let M = I - g;
    for (; M !== I && A[M] === 0; )
      M++;
    let L = i.repeat(o);
    for (; M < I; ++M)
      L += s.charAt(A[M]);
    return L;
  }
  function l(r) {
    if (typeof r != "string")
      throw new TypeError("Expected String");
    if (r.length === 0)
      return new Uint8Array();
    let o = 0, g = 0, y = 0;
    for (; r[o] === i; )
      g++, o++;
    const d = (r.length - o) * n + 1 >>> 0, I = new Uint8Array(d);
    for (; r[o]; ) {
      let j = e[r.charCodeAt(o)];
      if (j === 255)
        return;
      let N = 0;
      for (let f = d - 1; (j !== 0 || N < y) && f !== -1; f--, N++)
        j += t * I[f] >>> 0, I[f] = j % 256 >>> 0, j = j / 256 >>> 0;
      if (j !== 0)
        throw new Error("Non-zero carry");
      y = N, o++;
    }
    let A = d - y;
    for (; A !== d && I[A] === 0; )
      A++;
    const M = new Uint8Array(g + (d - A));
    let L = g;
    for (; A !== d; )
      M[L++] = I[A++];
    return M;
  }
  function u(r) {
    const o = l(r);
    if (o)
      return o;
    throw new Error("Non-base" + t + " character");
  }
  return {
    encode: h,
    decodeUnsafe: l,
    decode: u
  };
}
var De = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
const ye = de(De);
var c = function(s, e, t, i) {
  if (t === "a" && !i) throw new TypeError("Private accessor was defined without a getter");
  if (typeof e == "function" ? s !== e || !i : !e.has(s)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
  return t === "m" ? i : t === "a" ? i.call(s) : i ? i.value : e.get(s);
}, z = function(s, e, t, i, n) {
  if (i === "m") throw new TypeError("Private method is not writable");
  if (i === "a" && !n) throw new TypeError("Private accessor was defined without a setter");
  if (typeof e == "function" ? s !== e || !n : !e.has(s)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
  return i === "a" ? n.call(s, t) : n ? n.value = t : e.set(s, t), t;
}, S, E, G, _, U, R, et, D, it, ot, tt, Mt, J, lt, zt, mt, ft, Lt;
class je extends Ct {
  get name() {
    return c(this, D, "f").name;
  }
  get url() {
    return "https://github.com/solana-labs/wallet-standard";
  }
  get icon() {
    return c(this, D, "f").icon;
  }
  get readyState() {
    return c(this, it, "f");
  }
  get publicKey() {
    return c(this, G, "f");
  }
  get connecting() {
    return c(this, _, "f");
  }
  get supportedTransactionVersions() {
    return c(this, et, "f");
  }
  get wallet() {
    return c(this, D, "f");
  }
  get standard() {
    return !0;
  }
  constructor({ wallet: e }) {
    super(), S.add(this), E.set(this, void 0), G.set(this, void 0), _.set(this, void 0), U.set(this, void 0), R.set(this, void 0), et.set(this, void 0), D.set(this, void 0), it.set(this, typeof window > "u" || typeof document > "u" ? w.Unsupported : w.Installed), lt.set(this, (t) => {
      if ("accounts" in t) {
        const i = c(this, D, "f").accounts[0];
        c(this, E, "f") && !c(this, U, "f") && i !== c(this, E, "f") && (i ? c(this, S, "m", tt).call(this, i) : (this.emit("error", new ut()), c(this, S, "m", Mt).call(this)));
      }
      "features" in t && c(this, S, "m", J).call(this);
    }), z(this, D, e, "f"), z(this, E, null, "f"), z(this, G, null, "f"), z(this, _, !1, "f"), z(this, U, !1, "f"), z(this, R, c(this, D, "f").features[bt].on("change", c(this, lt, "f")), "f"), c(this, S, "m", J).call(this);
  }
  destroy() {
    z(this, E, null, "f"), z(this, G, null, "f"), z(this, _, !1, "f"), z(this, U, !1, "f");
    const e = c(this, R, "f");
    e && (z(this, R, null, "f"), e());
  }
  async autoConnect() {
    return c(this, S, "m", ot).call(this, { silent: !0 });
  }
  async connect() {
    return c(this, S, "m", ot).call(this);
  }
  async disconnect() {
    if (jt in c(this, D, "f").features)
      try {
        z(this, U, !0, "f"), await c(this, D, "f").features[jt].disconnect();
      } catch (e) {
        this.emit("error", new X(e == null ? void 0 : e.message, e));
      } finally {
        z(this, U, !1, "f");
      }
    c(this, S, "m", Mt).call(this);
  }
  async sendTransaction(e, t, i = {}) {
    try {
      const n = c(this, E, "f");
      if (!n)
        throw new T();
      let a;
      if (Y in c(this, D, "f").features)
        if (n.features.includes(Y))
          a = Y;
        else if (p in c(this, D, "f").features && n.features.includes(p))
          a = p;
        else
          throw new C();
      else if (p in c(this, D, "f").features) {
        if (!n.features.includes(p))
          throw new C();
        a = p;
      } else
        throw new P();
      const h = le(t.rpcEndpoint);
      if (!n.chains.includes(h))
        throw new k();
      try {
        const { signers: l, ...u } = i;
        let r;
        if (W(e) ? (l != null && l.length && e.sign(l), r = e.serialize()) : (e = await this.prepareTransaction(e, t, u), l != null && l.length && e.partialSign(...l), r = new Uint8Array(e.serialize({
          requireAllSignatures: !1,
          verifySignatures: !1
        }))), a === Y) {
          const [o] = await c(this, D, "f").features[Y].signAndSendTransaction({
            account: n,
            chain: h,
            transaction: r,
            options: {
              preflightCommitment: rt(u.preflightCommitment || t.commitment),
              skipPreflight: u.skipPreflight,
              maxRetries: u.maxRetries,
              minContextSlot: u.minContextSlot
            }
          });
          return ye.encode(o.signature);
        } else {
          const [o] = await c(this, D, "f").features[p].signTransaction({
            account: n,
            chain: h,
            transaction: r,
            options: {
              preflightCommitment: rt(u.preflightCommitment || t.commitment),
              minContextSlot: u.minContextSlot
            }
          });
          return await t.sendRawTransaction(o.signedTransaction, {
            ...u,
            preflightCommitment: rt(u.preflightCommitment || t.commitment)
          });
        }
      } catch (l) {
        throw l instanceof x ? l : new k(l == null ? void 0 : l.message, l);
      }
    } catch (n) {
      throw this.emit("error", n), n;
    }
  }
}
E = /* @__PURE__ */ new WeakMap(), G = /* @__PURE__ */ new WeakMap(), _ = /* @__PURE__ */ new WeakMap(), U = /* @__PURE__ */ new WeakMap(), R = /* @__PURE__ */ new WeakMap(), et = /* @__PURE__ */ new WeakMap(), D = /* @__PURE__ */ new WeakMap(), it = /* @__PURE__ */ new WeakMap(), lt = /* @__PURE__ */ new WeakMap(), S = /* @__PURE__ */ new WeakSet(), ot = async function(e) {
  try {
    if (this.connected || this.connecting)
      return;
    if (c(this, it, "f") !== w.Installed)
      throw new Q();
    if (z(this, _, !0, "f"), !c(this, D, "f").accounts.length)
      try {
        await c(this, D, "f").features[Ot].connect(e);
      } catch (i) {
        throw new nt(i == null ? void 0 : i.message, i);
      }
    const t = c(this, D, "f").accounts[0];
    if (!t)
      throw new C();
    c(this, S, "m", tt).call(this, t);
  } catch (t) {
    throw this.emit("error", t), t;
  } finally {
    z(this, _, !1, "f");
  }
}, tt = function(e) {
  let t;
  try {
    t = new O(e.address);
  } catch (i) {
    throw new v(i == null ? void 0 : i.message, i);
  }
  z(this, E, e, "f"), z(this, G, t, "f"), c(this, S, "m", J).call(this), this.emit("connect", t);
}, Mt = function() {
  z(this, E, null, "f"), z(this, G, null, "f"), c(this, S, "m", J).call(this), this.emit("disconnect");
}, J = function() {
  var t, i;
  const e = Y in c(this, D, "f").features ? c(this, D, "f").features[Y].supportedTransactionVersions : c(this, D, "f").features[p].supportedTransactionVersions;
  z(this, et, Gt(e, ["legacy"]) ? null : new Set(e), "f"), p in c(this, D, "f").features && ((t = c(this, E, "f")) != null && t.features.includes(p)) ? (this.signTransaction = c(this, S, "m", zt), this.signAllTransactions = c(this, S, "m", mt)) : (delete this.signTransaction, delete this.signAllTransactions), V in c(this, D, "f").features && ((i = c(this, E, "f")) != null && i.features.includes(V)) ? this.signMessage = c(this, S, "m", ft) : delete this.signMessage, at in c(this, D, "f").features ? this.signIn = c(this, S, "m", Lt) : delete this.signIn;
}, zt = async function(e) {
  try {
    const t = c(this, E, "f");
    if (!t)
      throw new T();
    if (!(p in c(this, D, "f").features))
      throw new P();
    if (!t.features.includes(p))
      throw new C();
    try {
      const n = (await c(this, D, "f").features[p].signTransaction({
        account: t,
        transaction: W(e) ? e.serialize() : new Uint8Array(e.serialize({
          requireAllSignatures: !1,
          verifySignatures: !1
        }))
      }))[0].signedTransaction;
      return W(e) ? Nt.deserialize(n) : wt.from(n);
    } catch (i) {
      throw i instanceof x ? i : new m(i == null ? void 0 : i.message, i);
    }
  } catch (t) {
    throw this.emit("error", t), t;
  }
}, mt = async function(e) {
  try {
    const t = c(this, E, "f");
    if (!t)
      throw new T();
    if (!(p in c(this, D, "f").features))
      throw new P();
    if (!t.features.includes(p))
      throw new C();
    try {
      const i = await c(this, D, "f").features[p].signTransaction(...e.map((n) => ({
        account: t,
        transaction: W(n) ? n.serialize() : new Uint8Array(n.serialize({
          requireAllSignatures: !1,
          verifySignatures: !1
        }))
      })));
      return e.map((n, a) => {
        const h = i[a].signedTransaction;
        return W(n) ? Nt.deserialize(h) : wt.from(h);
      });
    } catch (i) {
      throw new m(i == null ? void 0 : i.message, i);
    }
  } catch (t) {
    throw this.emit("error", t), t;
  }
}, ft = async function(e) {
  try {
    const t = c(this, E, "f");
    if (!t)
      throw new T();
    if (!(V in c(this, D, "f").features))
      throw new P();
    if (!t.features.includes(V))
      throw new C();
    try {
      return (await c(this, D, "f").features[V].signMessage({
        account: t,
        message: e
      }))[0].signature;
    } catch (i) {
      throw new F(i == null ? void 0 : i.message, i);
    }
  } catch (t) {
    throw this.emit("error", t), t;
  }
}, Lt = async function(e = {}) {
  try {
    if (!(at in c(this, D, "f").features))
      throw new P();
    let t;
    try {
      [t] = await c(this, D, "f").features[at].signIn(e);
    } catch (i) {
      throw new yt(i == null ? void 0 : i.message, i);
    }
    if (!t)
      throw new yt();
    return c(this, S, "m", tt).call(this, t.account), t;
  } catch (t) {
    throw this.emit("error", t), t;
  }
};
function Ae(s) {
  return _t().get().filter(Jt).map((e) => new b(new je({ wallet: e }), s));
}
function Te(s) {
  return s.includes("rpcpool.com") ? "triton" : s.includes("helius-rpc.com") ? "helius" : s.includes("rpc.ankr.com") ? "ankr" : "unknown";
}
async function ze(s, e, t, i) {
  const n = i.transaction.transaction, a = (h) => h.programId.toString() !== "ComputeBudget111111111111111111111111111111";
  if (ct(n)) {
    const h = (await Promise.all(
      n.message.addressTableLookups.map(
        (u) => s.getAddressLookupTable(u.accountKey)
      )
    )).map((u) => u.value).filter((u) => u !== null), l = Qt.decompile(n.message, {
      addressLookupTableAccounts: h
    });
    l.recentBlockhash = e, n.message.recentBlockhash = e, l.instructions = l.instructions.filter(a), l.instructions.push(
      ...await pt(s, n)
    ), n.message = l.compileToV0Message(h), n.sign(i.transaction.signers ?? []);
  } else
    n.recentBlockhash = e, n.lastValidBlockHeight = t, n.instructions = n.instructions.filter(
      a
    ), n.add(
      ...await pt(s, n)
    ), i.transaction.signers && n.partialSign(...i.transaction.signers);
  return n;
}
async function pt(s, e, t) {
  var L, j;
  let i = 2e5, n = 0;
  t: for (; ; ) {
    if (ct(e) && !e.message.recentBlockhash) {
      const { blockhash: f } = await s.getLatestBlockhash(t);
      e.message.recentBlockhash = f;
    }
    const N = await (ct(e) ? s.simulateTransaction(e, {
      commitment: t,
      replaceRecentBlockhash: !0
    }) : s.simulateTransaction(e));
    if (N.value.err) {
      if (me(N.value)) {
        if (n < 5) {
          n++, await dt(1e3);
          continue t;
        }
      } else if (n < 3) {
        n++, await dt(1e3);
        continue t;
      }
      throw new Error(
        `Simulation failed: ${JSON.stringify(N.value.err)}
Logs:
${(N.value.logs || []).join(`
  `)}`
      );
    } else {
      N.value.unitsConsumed && (i = N.value.unitsConsumed);
      break;
    }
  }
  const a = Math.floor(i * 1.2), h = [];
  h.push(
    Dt.setComputeUnitLimit({
      // Set compute budget to 120% of the units used in the simulated transaction
      units: a
    })
  );
  const l = ((j = (L = Z.transactionSettings) == null ? void 0 : L.Solana) == null ? void 0 : j.priorityFee) || {}, {
    percentile: u = 0.9,
    percentileMultiple: r = 1,
    min: o = 1e5,
    max: g = 1e8
  } = l, y = async (N) => {
    if (N === "triton")
      try {
        return {
          fee: await vt(
            s,
            e,
            u,
            r,
            o,
            g
          ),
          methodUsed: "triton"
        };
      } catch (f) {
        console.warn("Failed to determine priority fee using Triton RPC:", f);
      }
    try {
      return {
        fee: await Pt(
          s,
          e,
          u,
          r,
          o,
          g
        ),
        methodUsed: "default"
      };
    } catch (f) {
      return console.warn("Failed to determine priority fee using Triton RPC:", f), {
        fee: o,
        methodUsed: "minimum"
      };
    }
  }, d = Te(s.rpcEndpoint), { fee: I, methodUsed: A } = await y(d), M = I / // convert microlamports to lamports
  1e6 / // convert lamports to SOL
  kt * // multiply by maximum compute units used
  a;
  return console.table({
    "RPC Provider": d,
    "Method used": A,
    "Percentile used": u,
    "Multiple used": r,
    "Compute budget": a,
    "Priority fee": I,
    "Max fee in SOL": M
  }), h.push(
    Dt.setComputeUnitPrice({ microLamports: I })
  ), h;
}
function me(s) {
  const e = {};
  if (s.err === "BlockhashNotFound" && (e.BlockhashNotFound = "Blockhash not found during simulation. Trying again."), s.logs)
    for (const t of s.logs)
      t.includes("SlippageToleranceExceeded") && (e.SlippageToleranceExceeded = "Slippage failure during simulation. Trying again."), t.includes("RequireGteViolated") && (e.RequireGteViolated = "Swap instruction failure during simulation. Trying again.");
  return Ut(e) ? !1 : (console.table(e), !0);
}
const fe = (s) => s.getName().toLowerCase().replaceAll("wallet", "").trim();
function Ee() {
  const s = Z.isMainnet ? "mainnet-beta" : "devnet", e = new St(Z.rpcs.Solana || Wt(s));
  return {
    ...Ae(e).reduce((t, i) => (t[fe(i)] = i, t), {}),
    bitget: new b(new Xt(), e),
    clover: new b(new Kt(), e),
    coin98: new b(new $t(), e),
    solong: new b(new re(), e),
    torus: new b(new oe(), e),
    nightly: new b(new ee(), e),
    ...Z.ui.walletConnectProjectId ? {
      walletConnect: new b(
        new ge({
          network: Z.isMainnet ? H.Mainnet : H.Devnet,
          options: {
            projectId: Z.ui.walletConnectProjectId,
            customStoragePrefix: "wh-connect-solana-adapter"
          }
        }),
        e
      )
    } : {}
  };
}
async function Ce(s, e, t) {
  if (!e) throw new Error("Wallet not found");
  if (!Z.rpcs.Solana) throw new Error("Solana RPC not found");
  const i = (t == null ? void 0 : t.commitment) ?? "finalized", n = new St(Z.rpcs.Solana), { blockhash: a, lastValidBlockHeight: h } = await n.getLatestBlockhash(i), l = await ze(
    n,
    a,
    h,
    s
  );
  let u = null, r = null, o = 1, g = "";
  const d = (await e.signTransaction(l)).serialize(), I = {
    skipPreflight: !0,
    maxRetries: 0,
    preFlightCommitment: i
    // See PR and linked issue for why setting this matters: https://github.com/anza-xyz/agave/pull/483
  };
  g = await n.sendRawTransaction(d, I), u = n.confirmTransaction(
    {
      signature: g,
      blockhash: a,
      lastValidBlockHeight: h
    },
    i
  );
  const A = 5e3;
  for (; !r && (r = await Promise.race([
    u,
    new Promise(
      (M) => setTimeout(() => {
        M(null);
      }, A)
    )
  ]), !r); ) {
    console.log(
      `Tx not confirmed after ${A * o++}ms, resending`
    );
    try {
      await n.sendRawTransaction(d, I);
    } catch (M) {
      console.error("Failed to resend transaction:", M);
    }
  }
  if (r.value.err) {
    let M = `Transaction failed: ${r.value.err}`;
    if (typeof r.value.err == "object")
      try {
        M = `Transaction failed: ${JSON.stringify(
          r.value.err,
          (L, j) => typeof j == "bigint" ? j.toString() : j
          // Handle bigint props
        )}`;
      } catch {
        M = "Transaction failed: Unknown error";
      }
    throw new Error(`Transaction failed: ${M}`);
  }
  return g;
}
export {
  Ee as fetchOptions,
  Ce as signAndSendTransaction
};
