import * as React from "react";
function useEnhancedClickHandler(handler) {
  const lastClickInteractionTypeRef = React.useRef("");
  const handlePointerDown = React.useCallback((event) => {
    if (event.defaultPrevented) {
      return;
    }
    lastClickInteractionTypeRef.current = event.pointerType;
    handler(event, event.pointerType);
  }, [handler]);
  const handleClick = React.useCallback((event) => {
    if (event.detail === 0) {
      handler(event, "keyboard");
      return;
    }
    if ("pointerType" in event) {
      handler(event, event.pointerType);
    }
    handler(event, lastClickInteractionTypeRef.current);
    lastClickInteractionTypeRef.current = "";
  }, [handler]);
  return {
    onClick: handleClick,
    onPointerDown: handlePointerDown
  };
}
export {
  useEnhancedClickHandler
};
//# sourceMappingURL=useEnhancedClickHandler.js.map
