import { logger as f } from "./logger.js";
function S(e) {
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
var v = { exports: {} }, r = v.exports = {}, n, i;
function p() {
  throw new Error("setTimeout has not been defined");
}
function g() {
  throw new Error("clearTimeout has not been defined");
}
(function() {
  try {
    typeof setTimeout == "function" ? n = setTimeout : n = p;
  } catch {
    n = p;
  }
  try {
    typeof clearTimeout == "function" ? i = clearTimeout : i = g;
  } catch {
    i = g;
  }
})();
function T(e) {
  if (n === setTimeout)
    return setTimeout(e, 0);
  if ((n === p || !n) && setTimeout)
    return n = setTimeout, setTimeout(e, 0);
  try {
    return n(e, 0);
  } catch {
    try {
      return n.call(null, e, 0);
    } catch {
      return n.call(this, e, 0);
    }
  }
}
function b(e) {
  if (i === clearTimeout)
    return clearTimeout(e);
  if ((i === g || !i) && clearTimeout)
    return i = clearTimeout, clearTimeout(e);
  try {
    return i(e);
  } catch {
    try {
      return i.call(null, e);
    } catch {
      return i.call(this, e);
    }
  }
}
var s = [], c = !1, l, d = -1;
function y() {
  !c || !l || (c = !1, l.length ? s = l.concat(s) : d = -1, s.length && E());
}
function E() {
  if (!c) {
    var e = T(y);
    c = !0;
    for (var t = s.length; t; ) {
      for (l = s, s = []; ++d < t; )
        l && l[d].run();
      d = -1, t = s.length;
    }
    l = null, c = !1, b(e);
  }
}
r.nextTick = function(e) {
  var t = new Array(arguments.length - 1);
  if (arguments.length > 1)
    for (var o = 1; o < arguments.length; o++)
      t[o - 1] = arguments[o];
  s.push(new I(e, t)), s.length === 1 && !c && T(E);
};
function I(e, t) {
  this.fun = e, this.array = t;
}
I.prototype.run = function() {
  this.fun.apply(null, this.array);
};
r.title = "browser";
r.browser = !0;
r.env = {};
r.argv = [];
r.version = "";
r.versions = {};
function u() {
}
r.on = u;
r.addListener = u;
r.once = u;
r.off = u;
r.removeListener = u;
r.removeAllListeners = u;
r.emit = u;
r.prependListener = u;
r.prependOnceListener = u;
r.listeners = function(e) {
  return [];
};
r.binding = function(e) {
  throw new Error("process.binding is not supported");
};
r.cwd = function() {
  return "/";
};
r.chdir = function(e) {
  throw new Error("process.chdir is not supported");
};
r.umask = function() {
  return 0;
};
var D = v.exports;
const w = /* @__PURE__ */ S(D), m = {
  verifiedWallets: [],
  verifiedNearAccounts: [],
  nearWalletsPk: {}
}, h = typeof window < "u" && !!window.localStorage, N = "sw", a = (e) => `${N}.${e}`, $ = (e) => {
  if (!h)
    return w.env.NODE_ENV === "development" && f.debug(
      `[WIDGET] Attempted to read ${a(e)} from localstorage on server; returning default`
    ), m[e];
  try {
    const t = window.localStorage.getItem(e);
    let o = window.localStorage.getItem(a(e));
    return t && !o && (o = t, window.localStorage.setItem(a(e), t), window.localStorage.removeItem(e)), // @ts-expect-error It's ok to pass null to JSON.parse
    JSON.parse(o) ?? m[e];
  } catch (t) {
    return f.warn(
      `[WIDGET] Failed to parse ${a(e)} from localStorage:`,
      t
    ), m[e];
  }
}, O = (e, t) => {
  if (!h) {
    w.env.NODE_ENV === "development" && f.debug(
      `[WIDGET] Attempted to set ${a(e)} on server; skipping`
    );
    return;
  }
  try {
    const o = typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? String(t) : JSON.stringify(t);
    window.localStorage.setItem(a(e), o);
  } catch (o) {
    f.warn(
      `[WIDGET] Failed to set ${a(e)} in localStorage:`,
      o
    );
  }
}, W = (e) => {
  if (!h) {
    w.env.NODE_ENV === "development" && f.debug(
      `[WIDGET] Attempted to remove ${a(e)} from localstorage on server; skipping`
    );
    return;
  }
  try {
    window.localStorage.removeItem(a(e));
  } catch (t) {
    f.warn(
      `[WIDGET] Failed to remove ${a(e)} from localStorage:`,
      t
    );
  }
}, G = {
  getItem: $,
  setItem: O,
  removeItem: W
};
export {
  m as d,
  G as l,
  w as p
};
//# sourceMappingURL=localstorage-DVS0q1yC.js.map
