"use client";
import { h as Z, y as ue } from "./index.modern-Cv1pl6jB.js";
const z = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 }, q = (e) => typeof e == "object" && e !== null, A = /* @__PURE__ */ new WeakMap(), x = /* @__PURE__ */ new WeakSet(), pe = (e = Object.is, t = (n, g) => new Proxy(n, g), s = (n) => q(n) && !x.has(n) && (Array.isArray(n) || !(Symbol.iterator in n)) && !(n instanceof WeakMap) && !(n instanceof WeakSet) && !(n instanceof Error) && !(n instanceof Number) && !(n instanceof Date) && !(n instanceof String) && !(n instanceof RegExp) && !(n instanceof ArrayBuffer), r = (n) => {
  switch (n.status) {
    case "fulfilled":
      return n.value;
    case "rejected":
      throw n.reason;
    default:
      throw n;
  }
}, l = /* @__PURE__ */ new WeakMap(), c = (n, g, I = r) => {
  const y = l.get(n);
  if ((y == null ? void 0 : y[0]) === g)
    return y[1];
  const v = Array.isArray(n) ? [] : Object.create(Object.getPrototypeOf(n));
  return Z(v, !0), l.set(n, [g, v]), Reflect.ownKeys(n).forEach((P) => {
    if (Object.getOwnPropertyDescriptor(v, P))
      return;
    const E = Reflect.get(n, P), M = {
      value: E,
      enumerable: !0,
      // This is intentional to avoid copying with proxy-compare.
      // It's still non-writable, so it avoids assigning a value.
      configurable: !0
    };
    if (x.has(E))
      Z(E, !1);
    else if (E instanceof Promise)
      delete M.value, M.get = () => I(E);
    else if (A.has(E)) {
      const [b, H] = A.get(
        E
      );
      M.value = c(
        b,
        H(),
        I
      );
    }
    Object.defineProperty(v, P, M);
  }), Object.preventExtensions(v);
}, m = /* @__PURE__ */ new WeakMap(), f = [1, 1], O = (n) => {
  if (!q(n))
    throw new Error("object required");
  const g = m.get(n);
  if (g)
    return g;
  let I = f[0];
  const y = /* @__PURE__ */ new Set(), v = (a, i = ++f[0]) => {
    I !== i && (I = i, y.forEach((o) => o(a, i)));
  };
  let P = f[1];
  const E = (a = ++f[1]) => (P !== a && !y.size && (P = a, b.forEach(([i]) => {
    const o = i[1](a);
    o > I && (I = o);
  })), I), M = (a) => (i, o) => {
    const h = [...i];
    h[1] = [a, ...h[1]], v(h, o);
  }, b = /* @__PURE__ */ new Map(), H = (a, i) => {
    if ((z ? "production" : void 0) !== "production" && b.has(a))
      throw new Error("prop listener already exists");
    if (y.size) {
      const o = i[3](M(a));
      b.set(a, [i, o]);
    } else
      b.set(a, [i]);
  }, Y = (a) => {
    var i;
    const o = b.get(a);
    o && (b.delete(a), (i = o[1]) == null || i.call(o));
  }, ce = (a) => (y.add(a), y.size === 1 && b.forEach(([o, h], k) => {
    if ((z ? "production" : void 0) !== "production" && h)
      throw new Error("remove already exists");
    const R = o[3](M(k));
    b.set(k, [o, R]);
  }), () => {
    y.delete(a), y.size === 0 && b.forEach(([o, h], k) => {
      h && (h(), b.set(k, [o]));
    });
  }), J = Array.isArray(n) ? [] : Object.create(Object.getPrototypeOf(n)), $ = t(J, {
    deleteProperty(a, i) {
      const o = Reflect.get(a, i);
      Y(i);
      const h = Reflect.deleteProperty(a, i);
      return h && v(["delete", [i], o]), h;
    },
    set(a, i, o, h) {
      const k = Reflect.has(a, i), R = Reflect.get(a, i, h);
      if (k && (e(R, o) || m.has(o) && e(R, m.get(o))))
        return !0;
      Y(i), q(o) && (o = ue(o) || o);
      let V = o;
      if (o instanceof Promise)
        o.then((C) => {
          o.status = "fulfilled", o.value = C, v(["resolve", [i], C]);
        }).catch((C) => {
          o.status = "rejected", o.reason = C, v(["reject", [i], C]);
        });
      else {
        !A.has(o) && s(o) && (V = O(o));
        const C = !x.has(V) && A.get(V);
        C && H(i, C);
      }
      return Reflect.set(a, i, V, h), v(["set", [i], o, R]), !0;
    }
  });
  m.set(n, $);
  const de = [
    J,
    E,
    c,
    ce
  ];
  return A.set($, de), Reflect.ownKeys(n).forEach((a) => {
    const i = Object.getOwnPropertyDescriptor(
      n,
      a
    );
    "value" in i && ($[a] = n[a], delete i.value, delete i.writable), Object.defineProperty(J, a, i);
  }), $;
}) => [
  // public functions
  O,
  // shared state
  A,
  x,
  // internal things
  e,
  t,
  s,
  r,
  l,
  c,
  m,
  f
], [fe] = pe();
function j(e = {}) {
  return fe(e);
}
function S(e, t, s) {
  const r = A.get(e);
  let l;
  const c = [], m = r[3];
  let f = !1;
  const n = m((g) => {
    if (c.push(g), s) {
      t(c.splice(0));
      return;
    }
    l || (l = Promise.resolve().then(() => {
      l = void 0, f && t(c.splice(0));
    }));
  });
  return f = !0, () => {
    f = !1, n();
  };
}
function me(e, t) {
  const s = A.get(e), [r, l, c] = s;
  return c(r, l(), t);
}
const d = j({ history: ["ConnectWallet"], view: "ConnectWallet", data: void 0 }), le = { state: d, subscribe(e) {
  return S(d, () => e(d));
}, push(e, t) {
  e !== d.view && (d.view = e, t && (d.data = t), d.history.push(e));
}, reset(e) {
  d.view = e, d.history = [e];
}, replace(e) {
  d.history.length > 1 && (d.history[d.history.length - 1] = e, d.view = e);
}, goBack() {
  if (d.history.length > 1) {
    d.history.pop();
    const [e] = d.history.slice(-1);
    d.view = e;
  }
}, setData(e) {
  d.data = e;
} }, p = { WALLETCONNECT_DEEPLINK_CHOICE: "WALLETCONNECT_DEEPLINK_CHOICE", WCM_VERSION: "WCM_VERSION", RECOMMENDED_WALLET_AMOUNT: 9, isMobile() {
  return typeof window < "u" ? !!(window.matchMedia("(pointer:coarse)").matches || /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)) : !1;
}, isAndroid() {
  return p.isMobile() && navigator.userAgent.toLowerCase().includes("android");
}, isIos() {
  const e = navigator.userAgent.toLowerCase();
  return p.isMobile() && (e.includes("iphone") || e.includes("ipad"));
}, isHttpUrl(e) {
  return e.startsWith("http://") || e.startsWith("https://");
}, isArray(e) {
  return Array.isArray(e) && e.length > 0;
}, formatNativeUrl(e, t, s) {
  if (p.isHttpUrl(e)) return this.formatUniversalUrl(e, t, s);
  let r = e;
  r.includes("://") || (r = e.replaceAll("/", "").replaceAll(":", ""), r = `${r}://`), r.endsWith("/") || (r = `${r}/`), this.setWalletConnectDeepLink(r, s);
  const l = encodeURIComponent(t);
  return `${r}wc?uri=${l}`;
}, formatUniversalUrl(e, t, s) {
  if (!p.isHttpUrl(e)) return this.formatNativeUrl(e, t, s);
  let r = e;
  r.endsWith("/") || (r = `${r}/`), this.setWalletConnectDeepLink(r, s);
  const l = encodeURIComponent(t);
  return `${r}wc?uri=${l}`;
}, async wait(e) {
  return new Promise((t) => {
    setTimeout(t, e);
  });
}, openHref(e, t) {
  window.open(e, t, "noreferrer noopener");
}, setWalletConnectDeepLink(e, t) {
  try {
    localStorage.setItem(p.WALLETCONNECT_DEEPLINK_CHOICE, JSON.stringify({ href: e, name: t }));
  } catch {
  }
}, setWalletConnectAndroidDeepLink(e) {
  try {
    const [t] = e.split("?");
    localStorage.setItem(p.WALLETCONNECT_DEEPLINK_CHOICE, JSON.stringify({ href: t, name: "Android" }));
  } catch {
  }
}, removeWalletConnectDeepLink() {
  try {
    localStorage.removeItem(p.WALLETCONNECT_DEEPLINK_CHOICE);
  } catch {
  }
}, setModalVersionInStorage() {
  try {
    typeof localStorage < "u" && localStorage.setItem(p.WCM_VERSION, "2.6.2");
  } catch {
  }
}, getWalletRouterData() {
  var e;
  const t = (e = le.state.data) == null ? void 0 : e.Wallet;
  if (!t) throw new Error('Missing "Wallet" view data');
  return t;
} }, he = typeof location < "u" && (location.hostname.includes("localhost") || location.protocol.includes("https")), u = j({ enabled: he, userSessionId: "", events: [], connectedWalletId: void 0 }), ge = { state: u, subscribe(e) {
  return S(u.events, () => e(me(u.events[u.events.length - 1])));
}, initialize() {
  u.enabled && typeof (crypto == null ? void 0 : crypto.randomUUID) < "u" && (u.userSessionId = crypto.randomUUID());
}, setConnectedWalletId(e) {
  u.connectedWalletId = e;
}, click(e) {
  if (u.enabled) {
    const t = { type: "CLICK", name: e.name, userSessionId: u.userSessionId, timestamp: Date.now(), data: e };
    u.events.push(t);
  }
}, track(e) {
  if (u.enabled) {
    const t = { type: "TRACK", name: e.name, userSessionId: u.userSessionId, timestamp: Date.now(), data: e };
    u.events.push(t);
  }
}, view(e) {
  if (u.enabled) {
    const t = { type: "VIEW", name: e.name, userSessionId: u.userSessionId, timestamp: Date.now(), data: e };
    u.events.push(t);
  }
} }, L = j({ chains: void 0, walletConnectUri: void 0, isAuth: !1, isCustomDesktop: !1, isCustomMobile: !1, isDataLoaded: !1, isUiLoaded: !1 }), w = { state: L, subscribe(e) {
  return S(L, () => e(L));
}, setChains(e) {
  L.chains = e;
}, setWalletConnectUri(e) {
  L.walletConnectUri = e;
}, setIsCustomDesktop(e) {
  L.isCustomDesktop = e;
}, setIsCustomMobile(e) {
  L.isCustomMobile = e;
}, setIsDataLoaded(e) {
  L.isDataLoaded = e;
}, setIsUiLoaded(e) {
  L.isUiLoaded = e;
}, setIsAuth(e) {
  L.isAuth = e;
} }, B = j({ projectId: "", mobileWallets: void 0, desktopWallets: void 0, walletImages: void 0, chains: void 0, enableAuthMode: !1, enableExplorer: !0, explorerExcludedWalletIds: void 0, explorerRecommendedWalletIds: void 0, termsOfServiceUrl: void 0, privacyPolicyUrl: void 0 }), N = { state: B, subscribe(e) {
  return S(B, () => e(B));
}, setConfig(e) {
  var t, s;
  ge.initialize(), w.setChains(e.chains), w.setIsAuth(!!e.enableAuthMode), w.setIsCustomMobile(!!((t = e.mobileWallets) != null && t.length)), w.setIsCustomDesktop(!!((s = e.desktopWallets) != null && s.length)), p.setModalVersionInStorage(), Object.assign(B, e);
} };
var be = Object.defineProperty, ee = Object.getOwnPropertySymbols, ye = Object.prototype.hasOwnProperty, ve = Object.prototype.propertyIsEnumerable, te = (e, t, s) => t in e ? be(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, we = (e, t) => {
  for (var s in t || (t = {})) ye.call(t, s) && te(e, s, t[s]);
  if (ee) for (var s of ee(t)) ve.call(t, s) && te(e, s, t[s]);
  return e;
};
const G = "https://explorer-api.walletconnect.com", Q = "wcm", X = "js-2.6.2";
async function K(e, t) {
  const s = we({ sdkType: Q, sdkVersion: X }, t), r = new URL(e, G);
  return r.searchParams.append("projectId", N.state.projectId), Object.entries(s).forEach(([l, c]) => {
    c && r.searchParams.append(l, String(c));
  }), (await fetch(r)).json();
}
const U = { async getDesktopListings(e) {
  return K("/w3m/v1/getDesktopListings", e);
}, async getMobileListings(e) {
  return K("/w3m/v1/getMobileListings", e);
}, async getInjectedListings(e) {
  return K("/w3m/v1/getInjectedListings", e);
}, async getAllListings(e) {
  return K("/w3m/v1/getAllListings", e);
}, getWalletImageUrl(e) {
  return `${G}/w3m/v1/getWalletImage/${e}?projectId=${N.state.projectId}&sdkType=${Q}&sdkVersion=${X}`;
}, getAssetImageUrl(e) {
  return `${G}/w3m/v1/getAssetImage/${e}?projectId=${N.state.projectId}&sdkType=${Q}&sdkVersion=${X}`;
} };
var Ie = Object.defineProperty, se = Object.getOwnPropertySymbols, Le = Object.prototype.hasOwnProperty, We = Object.prototype.propertyIsEnumerable, ne = (e, t, s) => t in e ? Ie(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, Ee = (e, t) => {
  for (var s in t || (t = {})) Le.call(t, s) && ne(e, s, t[s]);
  if (se) for (var s of se(t)) We.call(t, s) && ne(e, s, t[s]);
  return e;
};
const oe = p.isMobile(), W = j({ wallets: { listings: [], total: 0, page: 1 }, search: { listings: [], total: 0, page: 1 }, recomendedWallets: [] }), Pe = { state: W, async getRecomendedWallets() {
  const { explorerRecommendedWalletIds: e, explorerExcludedWalletIds: t } = N.state;
  if (e === "NONE" || t === "ALL" && !e) return W.recomendedWallets;
  if (p.isArray(e)) {
    const s = { recommendedIds: e.join(",") }, { listings: r } = await U.getAllListings(s), l = Object.values(r);
    l.sort((c, m) => {
      const f = e.indexOf(c.id), O = e.indexOf(m.id);
      return f - O;
    }), W.recomendedWallets = l;
  } else {
    const { chains: s, isAuth: r } = w.state, l = s == null ? void 0 : s.join(","), c = p.isArray(t), m = { page: 1, sdks: r ? "auth_v1" : void 0, entries: p.RECOMMENDED_WALLET_AMOUNT, chains: l, version: 2, excludedIds: c ? t.join(",") : void 0 }, { listings: f } = oe ? await U.getMobileListings(m) : await U.getDesktopListings(m);
    W.recomendedWallets = Object.values(f);
  }
  return W.recomendedWallets;
}, async getWallets(e) {
  const t = Ee({}, e), { explorerRecommendedWalletIds: s, explorerExcludedWalletIds: r } = N.state, { recomendedWallets: l } = W;
  if (r === "ALL") return W.wallets;
  l.length ? t.excludedIds = l.map((I) => I.id).join(",") : p.isArray(s) && (t.excludedIds = s.join(",")), p.isArray(r) && (t.excludedIds = [t.excludedIds, r].filter(Boolean).join(",")), w.state.isAuth && (t.sdks = "auth_v1");
  const { page: c, search: m } = e, { listings: f, total: O } = oe ? await U.getMobileListings(t) : await U.getDesktopListings(t), n = Object.values(f), g = m ? "search" : "wallets";
  return W[g] = { listings: [...W[g].listings, ...n], total: O, page: c ?? 1 }, { listings: n, total: O };
}, getWalletImageUrl(e) {
  return U.getWalletImageUrl(e);
}, getAssetImageUrl(e) {
  return U.getAssetImageUrl(e);
}, resetSearch() {
  W.search = { listings: [], total: 0, page: 1 };
} }, _ = j({ open: !1 }), F = { state: _, subscribe(e) {
  return S(_, () => e(_));
}, async open(e) {
  return new Promise((t) => {
    const { isUiLoaded: s, isDataLoaded: r } = w.state;
    if (p.removeWalletConnectDeepLink(), w.setWalletConnectUri(e == null ? void 0 : e.uri), w.setChains(e == null ? void 0 : e.chains), le.reset("ConnectWallet"), s && r) _.open = !0, t();
    else {
      const l = setInterval(() => {
        const c = w.state;
        c.isUiLoaded && c.isDataLoaded && (clearInterval(l), _.open = !0, t());
      }, 200);
    }
  });
}, close() {
  _.open = !1;
} };
var Oe = Object.defineProperty, re = Object.getOwnPropertySymbols, Ce = Object.prototype.hasOwnProperty, Ae = Object.prototype.propertyIsEnumerable, ie = (e, t, s) => t in e ? Oe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, je = (e, t) => {
  for (var s in t || (t = {})) Ce.call(t, s) && ie(e, s, t[s]);
  if (re) for (var s of re(t)) Ae.call(t, s) && ie(e, s, t[s]);
  return e;
};
function Me() {
  return typeof matchMedia < "u" && matchMedia("(prefers-color-scheme: dark)").matches;
}
const T = j({ themeMode: Me() ? "dark" : "light" }), ae = { state: T, subscribe(e) {
  return S(T, () => e(T));
}, setThemeConfig(e) {
  const { themeMode: t, themeVariables: s } = e;
  t && (T.themeMode = t), s && (T.themeVariables = je({}, s));
} }, D = j({ open: !1, message: "", variant: "success" }), ke = { state: D, subscribe(e) {
  return S(D, () => e(D));
}, openToast(e, t) {
  D.open = !0, D.message = e, D.variant = t;
}, closeToast() {
  D.open = !1;
} };
class Ue {
  constructor(t) {
    this.openModal = F.open, this.closeModal = F.close, this.subscribeModal = F.subscribe, this.setTheme = ae.setThemeConfig, ae.setThemeConfig(t), N.setConfig(t), this.initUi();
  }
  async initUi() {
    if (typeof window < "u") {
      await import("./index-B8JjUHnC.js");
      const t = document.createElement("wcm-modal");
      document.body.insertAdjacentElement("beforeend", t), w.setIsUiLoaded(!0);
    }
  }
}
const _e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  WalletConnectModal: Ue
}, Symbol.toStringTag, { value: "Module" }));
export {
  ge as R,
  le as T,
  p as a,
  _e as i,
  ae as n,
  ke as o,
  w as p,
  F as s,
  Pe as t,
  N as y
};
//# sourceMappingURL=index-D-q3md-W.js.map
