"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useScrollSelectedIntoView = void 0;
var scroll_1 = require("../../utils/scroll");
var tiles_1 = require("../../utils/tiles");
var useIsInitialLayoutEffect_1 = require("../layout/useIsInitialLayoutEffect");
exports.useScrollSelectedIntoView = function (containerRef, selected) {
    useIsInitialLayoutEffect_1.useIsInitialLayoutEffect(function (isInitial) {
        if (!containerRef.current)
            return;
        var container = containerRef.current;
        var tile = tiles_1.getTile(container, selected);
        if (isInitial) {
            scroll_1.scrollToCenter(container, tile, false);
        }
        else {
            scroll_1.scrollIntoView(container, tile);
        }
    }, [containerRef, selected]);
};
