"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;
    }
});
var getItemElementByIndex = function getItemElementByIndex(param) {
    var trackRef = param.trackRef, itemsCollection = param.itemsCollection, index = param.index, itemAttribute = param.itemAttribute;
    var _trackRef_current;
    var indexedItem = (_trackRef_current = trackRef.current) === null || _trackRef_current === void 0 ? void 0 : _trackRef_current.querySelector("[".concat(itemAttribute, '="').concat(index, '"]'));
    if (indexedItem) {
        return indexedItem;
    }
    return itemsCollection.item(index);
};
var getCalculatedPos = function getCalculatedPos(param) {
    var scrollRef = param.scrollRef, trackRef = param.trackRef, itemsCollection = param.itemsCollection, index = param.index, scrollAlign = param.scrollAlign, itemAttribute = param.itemAttribute;
    var item = getItemElementByIndex({
        trackRef: trackRef,
        itemsCollection: itemsCollection,
        index: index,
        itemAttribute: itemAttribute
    });
    if (!item || !trackRef.current || !scrollRef.current) {
        return 0;
    }
    var itemRect = item.getBoundingClientRect();
    var trackRect = trackRef.current.getBoundingClientRect();
    var scrollRect = scrollRef.current.getBoundingClientRect();
    var 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;
            }
    }
};
