"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTagWidth = void 0;
const Tag_1 = require("../../Tag");
const getTagWidth = (label, theme, isCounter = false) => {
    /** 16px иконка и 2px padding */
    const DELETE_ICON_WIDTH = 18;
    const el = document.createElement('div');
    el.textContent = label.toString();
    el.style.visibility = 'hidden';
    el.style.position = 'absolute';
    el.style.display = 'inline-flex';
    el.style.whiteSpace = 'nowrap';
    el.style.padding = theme.spacing(0, 2);
    el.style.paddingLeft = theme.spacing(2);
    el.style.paddingRight = isCounter ? theme.spacing(2) : theme.microSpacing(1);
    el.style.boxSizing = 'border-box';
    document.body.appendChild(el);
    const width = isCounter
        ? el.getBoundingClientRect().width
        : el.getBoundingClientRect().width + DELETE_ICON_WIDTH;
    document.body.removeChild(el);
    return Math.ceil(Math.min(width, parseInt(Tag_1.MAX_TAG_WIDTH, 10)));
};
exports.getTagWidth = getTagWidth;
