import { hasAnchor as f } from "./accelbyte-widgets711.mjs";
function s(n, t, r) {
  if (Array.isArray(n))
    return n.map((o, e) => s(o, String(e), r));
  if (n && typeof n.toJSON == "function") {
    if (!r || !f(n))
      return n.toJSON(t, r);
    const o = { aliasCount: 0, count: 1, res: void 0 };
    r.anchors.set(n, o), r.onCreate = (i) => {
      o.res = i, delete r.onCreate;
    };
    const e = n.toJSON(t, r);
    return r.onCreate && r.onCreate(e), e;
  }
  return typeof n == "bigint" && !(r != null && r.keep) ? Number(n) : n;
}
export {
  s as toJS
};
