let cachedRtlScrollType = null;
/**
 * Detects how this browser reports scrollLeft for RTL overflow containers.
 * @see https://github.com/othree/jquery.rtl-scroll-type
 */
function getRtlScrollType() {
    if (cachedRtlScrollType) {
        return cachedRtlScrollType;
    }
    if (typeof document === 'undefined') {
        cachedRtlScrollType = 'default';
        return cachedRtlScrollType;
    }
    const probe = document.createElement('div');
    probe.style.width = '100px';
    probe.style.height = '100px';
    probe.style.position = 'absolute';
    probe.style.top = '-1000px';
    probe.style.overflow = 'scroll';
    probe.style.direction = 'rtl';
    const inner = document.createElement('div');
    inner.style.width = '200px';
    inner.style.height = '100px';
    probe.appendChild(inner);
    document.body.appendChild(probe);
    if (probe.scrollLeft > 0) {
        cachedRtlScrollType = 'reverse';
    }
    else {
        probe.scrollLeft = 1;
        cachedRtlScrollType = probe.scrollLeft === 0 ? 'negative' : 'default';
    }
    document.body.removeChild(probe);
    return cachedRtlScrollType;
}
/** True when the element's used text direction is RTL (inherits from ancestors). */
function isRtlDirection(element) {
    return getComputedStyle(element).direction === 'rtl';
}
/**
 * RTL scroll offset from inline-start for a known browser scrollLeft model.
 * @see https://github.com/othree/jquery.rtl-scroll-type#3-types-of-scrollleft-scrollwidth--100
 */
function getRtlScrollOffsetFromStart(scrollLeft, maxScroll, rtlType) {
    switch (rtlType) {
        case 'negative':
            return Math.max(0, -scrollLeft);
        case 'reverse':
            return Math.max(0, scrollLeft);
        case 'default':
        default:
            return Math.max(0, maxScroll - scrollLeft);
    }
}
/**
 * Distance scrolled from the inline-start edge (LTR: left, RTL: right).
 */
function getScrollOffsetFromStart(container) {
    const { scrollLeft, scrollWidth, clientWidth } = container;
    const maxScroll = Math.max(0, scrollWidth - clientWidth);
    if (maxScroll <= 0) {
        return 0;
    }
    const isRtl = isRtlDirection(container);
    if (!isRtl) {
        return scrollLeft;
    }
    return getRtlScrollOffsetFromStart(scrollLeft, maxScroll, getRtlScrollType());
}
/** True when the container is scrolled away from its inline-start edge. */
function isScrolledFromInlineStart(container) {
    return getScrollOffsetFromStart(container) > 0;
}

export { isScrolledFromInlineStart as a, getScrollOffsetFromStart as g, isRtlDirection as i };
//# sourceMappingURL=scroll-DtgUQhjl.js.map

//# sourceMappingURL=scroll-DtgUQhjl.js.map