"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("classnames"),r=require("react"),i=require("lodash"),n=require("../Tooltip/Tooltip.js"),s=require("./TextTruncated.scss.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=u(t);exports.TextTruncated=function(t){var u=t.children,a=t.disableTooltip,l=t.maxLines,o=void 0===l?1:l,d=t.testId,f=t.className,v=o>1,b=r.useRef(null),h=r.useRef(v),p=r.useState(null),x=p[0],T=p[1],j=r.useState(!0),m=j[0],q=j[1];return h.current=v,r.useLayoutEffect((function(){var e=i.debounce((function(){var e=b.current;e&&(T(e.textContent),q(e.scrollWidth<=e.clientWidth&&(e.scrollHeight<=e.clientHeight||!h.current)))}),200),t=new ResizeObserver(e),r=new MutationObserver(e);return b.current&&(t.observe(b.current),r.observe(b.current,{childList:!0,subtree:!0,characterData:!0})),function(){t.disconnect(),r.disconnect()}}),[]),e.jsx(n.Tooltip,{title:x,disabled:m||a,children:e.jsx("div",{className:c.default(s.root,v?s.multiLine:s.singleLine,f),style:v?{WebkitLineClamp:o}:void 0,ref:b,"data-testid":d,children:u})})};
