import {
  useDeps_default,
  useUpdatingRef_default
} from "./chunk-W3FLVN5D.js";

// src/js-tools/react-utils/hooks/useAsyncEffect.ts
import {
  useEffect,
  useRef
} from "react";
function useAsyncEffect(getEffect, deps, useEffectCaller = useEffect) {
  const getEffectRef = useUpdatingRef_default(getEffect);
  const promiseRef = useRef(Promise.resolve());
  const seq = useDeps_default(deps);
  const seqRef = useUpdatingRef_default(seq);
  useEffectCaller(() => {
    const controller = new AbortController();
    const mySeq = seq;
    promiseRef.current = promiseRef.current.then(() => {
      if (mySeq < seqRef.current) return void 0;
      return getEffectRef.current()(controller.signal);
    });
    return () => {
      controller.abort();
      promiseRef.current = promiseRef.current.then((destructor) => {
        if (destructor) {
          return destructor();
        }
      });
    };
  }, [seq]);
}
var useAsyncEffect_default = useAsyncEffect;

// src/js-tools/react-utils/hooks/useMemoObjectDeep.ts
import isEqual from "lodash-es/isEqual";
import { useRef as useRef2 } from "react";
function useMemoObjectDeep(obj) {
  const objRef = useRef2(obj);
  if (!isEqual(objRef.current, obj)) {
    objRef.current = obj;
  }
  return objRef.current;
}
var useMemoObjectDeep_default = useMemoObjectDeep;

export {
  useAsyncEffect_default,
  useMemoObjectDeep_default
};
