import React from "react";
const useAiImageModalShortcuts = ({
  state,
  modalRef,
  cancelPrompt,
  closeModal
}) => {
  React.useEffect(() => {
    if (typeof window === "undefined") {
      return;
    }
    const handleKeyDown = (e) => {
      if (!(modalRef?.contains(document.activeElement) || modalRef === document.activeElement)) {
        return;
      }
      switch (state.type) {
        case "IN_PROGRESS": {
          if (e.key === "Escape") {
            cancelPrompt();
            return;
          }
          break;
        }
        default: {
        }
      }
      if (e.key === "Escape") {
        closeModal();
        return;
      }
    };
    window.addEventListener("keydown", handleKeyDown);
    return () => {
      window.removeEventListener("keydown", handleKeyDown);
    };
  }, [modalRef, state, closeModal]);
};
export {
  useAiImageModalShortcuts
};
//# sourceMappingURL=use-ai-image-modal-shortcuts.js.map
