import useToken from './use-token';
const SENDER_INPUT_PADDING_HEIGHT = 4.35;
const useInputHeight = (styles, autoSize, editableRef) => {
    const { token } = useToken();
    const computedStyle = editableRef.current
        ? window.getComputedStyle(editableRef.current)
        : {};
    const lineHeight = parseFloat(`${styles.lineHeight || token.lineHeight}`);
    const fontSize = parseFloat(`${(computedStyle === null || computedStyle === void 0 ? void 0 : computedStyle.fontSize) || styles.fontSize || token.fontSize}`);
    const height = (computedStyle === null || computedStyle === void 0 ? void 0 : computedStyle.lineHeight)
        ? parseFloat(`${computedStyle === null || computedStyle === void 0 ? void 0 : computedStyle.lineHeight}`)
        : lineHeight * fontSize;
    if (autoSize === false || !autoSize) {
        return {};
    }
    if (autoSize === true) {
        return {
            height: 'auto',
        };
    }
    return {
        minHeight: autoSize.minRows
            ? (height + SENDER_INPUT_PADDING_HEIGHT) * autoSize.minRows
            : 'auto',
        maxHeight: autoSize.maxRows
            ? (height + SENDER_INPUT_PADDING_HEIGHT) * autoSize.maxRows
            : 'auto',
        overflowY: 'auto',
    };
};
export default useInputHeight;
