(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports", "tslib", "react", "../../../utils/getTextWidth", "../../../typography/P1", "../../../Label", "./styles"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var tslib_1 = require("tslib");
    var react_1 = (0, tslib_1.__importStar)(require("react"));
    var getTextWidth_1 = (0, tslib_1.__importDefault)(require("../../../utils/getTextWidth"));
    var P1_1 = (0, tslib_1.__importDefault)(require("../../../typography/P1"));
    var Label_1 = (0, tslib_1.__importDefault)(require("../../../Label"));
    var styles_1 = require("./styles");
    var SubHeaderRoll = (0, react_1.forwardRef)(function (_a, ref) {
        var title = _a.title, _b = _a.statusLabel, statusLabel = _b === void 0 ? "info" : _b, textLabel = _a.textLabel, textOverflow = _a.textOverflow, isIconLabel = _a.isIconLabel, props = (0, tslib_1.__rest)(_a, ["title", "statusLabel", "textLabel", "textOverflow", "isIconLabel"]);
        var titleRef = (0, react_1.useRef)(null);
        var setTooltipWhenOverflowTitle = function () {
            if (titleRef.current) {
                titleRef.current.removeAttribute("title");
                var widthText = (0, getTextWidth_1.default)(String(title), getComputedStyle(titleRef.current).font);
                if (widthText >= titleRef.current.clientWidth) {
                    titleRef.current.setAttribute("title", String(title));
                }
            }
        };
        (0, react_1.useEffect)(function () {
            setTooltipWhenOverflowTitle();
        }, [title]);
        return (react_1.default.createElement(styles_1.SubHeaderRollStyled, (0, tslib_1.__assign)({ ref: ref, textOverflow: textOverflow }, props),
            react_1.default.createElement(P1_1.default, { className: "title", ref: titleRef, type: "phoenix", as: "p" }, title),
            textLabel && (react_1.default.createElement(Label_1.default, { className: "subtitle", status: statusLabel, isIcon: isIconLabel }, textLabel))));
    });
    SubHeaderRoll.displayName = "SubHeaderRoll";
    exports.default = SubHeaderRoll;
});
