"use client";
import { getHotkeyMatcher } from "./parse-hotkey.mjs";
import { useEffect, useEffectEvent } from "react";
//#region packages/@mantine/hooks/src/use-hotkeys/use-hotkeys.ts
function shouldFireEvent(event, tagsToIgnore, triggerOnContentEditable = false) {
	if (event.target instanceof HTMLElement) {
		if (triggerOnContentEditable) return !tagsToIgnore.includes(event.target.tagName);
		return !event.target.isContentEditable && !tagsToIgnore.includes(event.target.tagName);
	}
	return true;
}
function useHotkeys(hotkeys, tagsToIgnore = [
	"INPUT",
	"TEXTAREA",
	"SELECT"
], triggerOnContentEditable = false) {
	const handleKeydown = useEffectEvent((event) => {
		hotkeys.forEach(([hotkey, handler, options = {
			preventDefault: true,
			usePhysicalKeys: false
		}]) => {
			if (getHotkeyMatcher(hotkey, options.usePhysicalKeys)(event) && shouldFireEvent(event, tagsToIgnore, triggerOnContentEditable)) {
				if (options.preventDefault) event.preventDefault();
				handler(event);
			}
		});
	});
	useEffect(() => {
		document.documentElement.addEventListener("keydown", handleKeydown);
		return () => document.documentElement.removeEventListener("keydown", handleKeydown);
	}, []);
}
//#endregion
export { useHotkeys };

//# sourceMappingURL=use-hotkeys.mjs.map