"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 getCalculatedPos () {
        return getCalculatedPos;
    },
    get getItemElementByIndex () {
        return getItemElementByIndex;
    }
});
const getItemElementByIndex = ({ trackRef, itemsCollection, index, itemAttribute })=>{
    const indexedItem = trackRef.current?.querySelector(`[${itemAttribute}="${index}"]`);
    if (indexedItem) {
        return indexedItem;
    }
    return itemsCollection.item(index);
};
const getCalculatedPos = ({ scrollRef, trackRef, itemsCollection, index, scrollAlign, itemAttribute })=>{
    const item = getItemElementByIndex({
        trackRef,
        itemsCollection,
        index,
        itemAttribute
    });
    if (!item || !trackRef.current || !scrollRef.current) {
        return 0;
    }
    const itemRect = item.getBoundingClientRect();
    const trackRect = trackRef.current.getBoundingClientRect();
    const scrollRect = scrollRef.current.getBoundingClientRect();
    const left = itemRect.left - trackRect.left + trackRef.current.scrollLeft;
    switch(scrollAlign){
        case 'start':
            {
                return left;
            }
        case 'center':
            {
                return left - scrollRect.width / 2 + itemRect.width / 2;
            }
        case 'end':
            {
                return left - scrollRect.width + itemRect.width;
            }
        default:
            {
                return 0;
            }
    }
};
