export const focusableSelectors = [
    'a[href]',
    'area[href]',
    'input:not([disabled]):not([type="hidden"])',
    'textarea:not([disabled])',
    'button:not([disabled])',
    '[tabindex="0"]'
];
export const canFocusSelectors = focusableSelectors.join(', ');
export const isFocusable = (element) => {
    return element && element.matches && element.matches(canFocusSelectors);
};
export const getFocusable = (element) => {
    return Array.from(element.querySelectorAll(canFocusSelectors));
};
export const focusBounds = (element) => {
    const els = getFocusable(element);
    return [els[0], els[els.length - 1]];
};
export const constrainFocus = (event, element) => {
    const active = element.ownerDocument.activeElement;
    const [first, last] = focusBounds(element);
    if (event.shiftKey && active === first) {
        event.preventDefault();
        last.focus();
    }
    else if (active === last) {
        event.preventDefault();
        first.focus();
    }
};
