var s = (n) => setTimeout(n, 0);
function c() {
  let n = [], r = 0, u = (t) => {
    t();
  }, i = (t) => {
    t();
  }, l = s;
  const o = (t) => {
    r ? n.push(t) : l(() => {
      u(t);
    });
  }, a = () => {
    const t = n;
    n = [], t.length && l(() => {
      i(() => {
        t.forEach((e) => {
          u(e);
        });
      });
    });
  };
  return {
    batch: (t) => {
      let e;
      r++;
      try {
        e = t();
      } finally {
        r--, r || a();
      }
      return e;
    },
    /**
     * All calls to the wrapped function will be batched.
     */
    batchCalls: (t) => (...e) => {
      o(() => {
        t(...e);
      });
    },
    schedule: o,
    /**
     * Use this method to set a custom notify function.
     * This can be used to for example wrap notifications with `React.act` while running tests.
     */
    setNotifyFunction: (t) => {
      u = t;
    },
    /**
     * Use this method to set a custom function to batch notifications together into a single tick.
     * By default React Query will use the batch function provided by ReactDOM or React Native.
     */
    setBatchNotifyFunction: (t) => {
      i = t;
    },
    setScheduler: (t) => {
      l = t;
    }
  };
}
var f = c();
export {
  c as createNotifyManager,
  s as defaultScheduler,
  f as notifyManager
};
//# sourceMappingURL=notifyManager.js.map
