"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: Object.getOwnPropertyDescriptor(all, name).get
    });
}
_export(exports, {
    get isImmediatePropagationStopped () {
        return isImmediatePropagationStopped;
    },
    get isLeftClick () {
        return isLeftClick;
    },
    get isRightClick () {
        return isRightClick;
    },
    get isTouchEvent () {
        return isTouchEvent;
    },
    get offsetRelativeTo () {
        return offsetRelativeTo;
    },
    get stopImmediatePropagation () {
        return stopImmediatePropagation;
    }
});
const _element = require("./element");
function stopImmediatePropagation(event) {
    event.isImmediatePropagationEnabled = false;
    event.cancelBubble = true;
}
function isImmediatePropagationStopped(event) {
    return event.isImmediatePropagationEnabled === false;
}
function isRightClick(event) {
    return event.button === 2;
}
function isLeftClick(event) {
    return event.button === 0;
}
function isTouchEvent(event) {
    return typeof TouchEvent !== 'undefined' && event instanceof TouchEvent;
}
function offsetRelativeTo(event, untilElement) {
    const offset = {
        x: event.offsetX,
        y: event.offsetY
    };
    let element = event.target;
    if (!(0, _element.isHTMLElement)(untilElement) || element !== untilElement && element.contains(untilElement)) {
        return offset;
    }
    while(element !== untilElement){
        offset.x += element.offsetLeft;
        offset.y += element.offsetTop;
        element = element.offsetParent;
    }
    return offset;
}
