var u = function(e, t, r, n) {
  if (r === "a" && !n) throw new TypeError("Private accessor was defined without a getter");
  if (typeof t == "function" ? e !== t || !n : !t.has(e)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
  return r === "m" ? n : r === "a" ? n.call(e) : n ? n.value : t.get(e);
}, p = function(e, t, r, n, o) {
  if (n === "m") throw new TypeError("Private method is not writable");
  if (n === "a" && !o) throw new TypeError("Private accessor was defined without a setter");
  if (typeof t == "function" ? e !== t || !o : !t.has(e)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
  return n === "a" ? o.call(e, r) : o ? o.value = r : t.set(e, r), r;
}, s;
let d;
const c = /* @__PURE__ */ new Set();
function w(e) {
  i = void 0, c.add(e);
}
function h(e) {
  i = void 0, c.delete(e);
}
const a = {};
function b() {
  if (d || (d = Object.freeze({ register: l, get: g, on: y }), typeof window > "u"))
    return d;
  const e = Object.freeze({ register: l });
  try {
    window.addEventListener("wallet-standard:register-wallet", ({ detail: t }) => t(e));
  } catch (t) {
    console.error(`wallet-standard:register-wallet event listener could not be added
`, t);
  }
  try {
    window.dispatchEvent(new E(e));
  } catch (t) {
    console.error(`wallet-standard:app-ready event could not be dispatched
`, t);
  }
  return d;
}
function l(...e) {
  return e = e.filter((t) => !c.has(t)), e.length ? (e.forEach((t) => w(t)), a.register?.forEach((t) => f(() => t(...e))), function() {
    e.forEach((r) => h(r)), a.unregister?.forEach((r) => f(() => r(...e)));
  }) : () => {
  };
}
let i;
function g() {
  return i || (i = [...c]), i;
}
function y(e, t) {
  return a[e]?.push(t) || (a[e] = [t]), function() {
    a[e] = a[e]?.filter((n) => t !== n);
  };
}
function f(e) {
  try {
    e();
  } catch (t) {
    console.error(t);
  }
}
class E extends Event {
  get detail() {
    return u(this, s, "f");
  }
  get type() {
    return "wallet-standard:app-ready";
  }
  constructor(t) {
    super("wallet-standard:app-ready", {
      bubbles: !1,
      cancelable: !1,
      composed: !1
    }), s.set(this, void 0), p(this, s, t, "f");
  }
  /** @deprecated */
  preventDefault() {
    throw new Error("preventDefault cannot be called");
  }
  /** @deprecated */
  stopImmediatePropagation() {
    throw new Error("stopImmediatePropagation cannot be called");
  }
  /** @deprecated */
  stopPropagation() {
    throw new Error("stopPropagation cannot be called");
  }
}
s = /* @__PURE__ */ new WeakMap();
export {
  b as g
};
