/**
 * Whether a keyboard event's target is a place the user is typing (or otherwise
 * expects native key handling), so the reader must NOT hijack arrows/j/k/Home/End
 * for page navigation. Covers text inputs, textareas, native `<select>` dropdowns
 * (whose Home/End/arrows are their own), and any contenteditable region.
 */
export function isTypingTarget(target: EventTarget | null): boolean {
    const el = target as HTMLElement | null;
    if (!el) return false;
    const tag = el.tagName;
    // `isContentEditable` is the correct runtime signal (accounts for inherited
    // editability); the attribute check is a robust fallback for the explicit
    // case and for environments that don't compute the property (jsdom).
    const editable =
        el.isContentEditable === true ||
        el.getAttribute?.('contenteditable') === 'true' ||
        el.getAttribute?.('contenteditable') === '';
    return tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT' || editable;
}
