"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useLogic = void 0;
const useOverflowed_1 = require("../hooks/useOverflowed");
const utils_1 = require("../utils");
const useLogic = ({ forwardedRef, children, visibleLastSymbolsCount = 0, rowsCount = 1, }) => {
    const canSlice = Boolean(children && typeof children === 'string');
    const hasVisibleLastSymbols = canSlice && visibleLastSymbolsCount > 0;
    const hasMultipleRows = hasVisibleLastSymbols ? false : rowsCount > 1;
    const { ref, isOverflowed } = (0, useOverflowed_1.useOverflowed)(forwardedRef, hasMultipleRows, hasVisibleLastSymbols);
    const { firstPartLabel, secondPartLabel } = hasVisibleLastSymbols && typeof children === 'string'
        ? (0, utils_1.truncateString)(visibleLastSymbolsCount, children)
        : { firstPartLabel: '', secondPartLabel: '' };
    const tooltipTitle = isOverflowed && children;
    return {
        hasVisibleLastSymbols,
        ref,
        firstPartLabel,
        secondPartLabel,
        hasMultipleRows,
        tooltipTitle,
    };
};
exports.useLogic = useLogic;
