import { useState } from "react";
import { useEventCallback } from "../_vendor/usehooks-ts/dist-index.js";
import { closeCompletion } from "../_vendor/@codemirror/autocomplete/dist-index.js";
function useEvent(editorViewRef) {
  const [dragging, setDragging] = useState(false);
  const blur = useEventCallback(() => {
    const editor = editorViewRef.current;
    if (editor) {
      editor.contentDOM.blur();
      closeCompletion(editor);
    }
  });
  const blurOnClickOutside = useEventCallback((event) => {
    var _a;
    if (event.target && !dragging && !((_a = editorViewRef.current) == null ? void 0 : _a.dom.contains(event.target))) {
      blur();
    }
    setDragging(false);
  });
  return {
    blur,
    blurOnClickOutside
  };
}
export {
  useEvent
};
//# sourceMappingURL=use-event.js.map
