import { Optional } from '@ephox/katamari';
import { SugarElement, SugarNode, Traverse } from '@ephox/sugar';
const insideComponent = (component, x, y) => {
    const isInside = (node) => component.element.dom.contains(node.dom);
    const hasValidRect = (node) => {
        const elem = SugarNode.isText(node) ? Traverse.parentElement(node) : Optional.some(node);
        return elem.exists((e) => {
            const rect = e.dom.getBoundingClientRect();
            return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom;
        });
    };
    const doc = Traverse.owner(component.element);
    return SugarElement.fromPoint(doc, x, y).filter(isInside).filter(hasValidRect);
};
export { insideComponent };
//# sourceMappingURL=ElementFromPoint.js.map