import { jsx as s } from "react/jsx-runtime";
import { useState as r } from "react";
import { G as b, b as _, K as n } from "../../config-BDnHptBC.js";
import "ethers";
import "../../machine/machine.js";
import { notReachable as l } from "../../utils/notReachable.js";
import { l as c } from "../../localstorage-DVS0q1yC.js";
import { useCompatibilityCheck as g } from "../../hooks/useCompatibilityCheck.js";
function I({ onMsg: a }) {
  const { providers: p } = b(), [f, i] = r(!1), [y, m] = r(!1), {
    ctx: { walletAddress: t }
  } = _(), { handleSign: d, isSigning: u } = g({
    providers: p,
    walletAddress: t
  });
  async function h() {
    if (!t)
      return;
    if (!await d()) {
      i(!0);
      return;
    }
    const o = c.getItem("verifiedWallets");
    o.push(t), c.setItem("verifiedWallets", o), m(!0);
  }
  return f ? /* @__PURE__ */ s(
    n.Error,
    {
      onMsg: async (e) => {
        switch (e.type) {
          case "on_close":
          case "on_sign_out":
            a({ type: e.type });
            break;
          case "on_try_again":
            i(!1);
            break;
          default:
            l(e.type);
        }
      }
    }
  ) : /* @__PURE__ */ s(
    n,
    {
      isSigned: y,
      isSigning: u,
      onMsg: async (e) => {
        switch (e.type) {
          case "on_close":
          case "on_sign_out":
            a({ type: e.type });
            break;
          case "on_check_compatibility":
            await h();
            break;
          default:
            l(e.type);
        }
      }
    }
  );
}
export {
  I as WalletCompatibilityCheck
};
//# sourceMappingURL=index.js.map
