"use client";
import * as React from "react";
import { useStableCallback } from "../../../utils/esm/useStableCallback.js";
import { useValueAsRef } from "../../../utils/esm/useValueAsRef.js";
import { useAnimationsFinished } from "./useAnimationsFinished.js";
function useOpenChangeComplete(parameters) {
  const {
    enabled = true,
    open,
    ref,
    onComplete: onCompleteParam
  } = parameters;
  const openRef = useValueAsRef(open);
  const onComplete = useStableCallback(onCompleteParam);
  const runOnceAnimationsFinish = useAnimationsFinished(ref, open);
  React.useEffect(() => {
    if (!enabled) {
      return;
    }
    runOnceAnimationsFinish(() => {
      if (open === openRef.current) {
        onComplete();
      }
    });
  }, [enabled, open, onComplete, runOnceAnimationsFinish, openRef]);
}
export {
  useOpenChangeComplete
};
//# sourceMappingURL=useOpenChangeComplete.js.map
