import{slicedToArray as i}from"../../_virtual/_rollupPluginBabelHelpers.js";import{jsx as e}from"react/jsx-runtime";import o,{useLayoutEffect as t}from"react";import s from"classnames";import l from"../Tooltip/Tooltip.js";import r from"../../hooks/useIsOverflowing.js";import n from"../../hooks/useStyle.js";import a from"../../hooks/useRefWithCallback.js";import p from"../TextWithHighlight/TextWithHighlight.js";import{HeadingTypes as m,HeadingSizes as c}from"./HeadingConstants.js";import"./Heading.scss.js";var u=function(u){var d=u.className,g=u.value,h=void 0===g?"":g,f=u.type,v=void 0===f?m.h1:f,j=u.size,y=void 0===j?c.LARGE:j,T=u.ariaLabel,b=void 0===T?"":T,x=u.id,E=u.customColor,H=u.ellipsis,P=void 0===H||H,k=u.ellipsisMaxLines,C=void 0===k?1:k,O=u.style,z=u.tooltipPosition,L=u.highlightTerm,W=void 0===L?null:L,A=u.suggestEditOnHover,N=void 0!==A&&A,R=u.nonEllipsisTooltip,_=void 0===R?null:R,w=a((function(i){return i.style.setProperty("--heading-clamp-lines",""+C)})),B=i(w,2),G=B[0],I=B[1],M=n(O,{color:E}),S=s("heading-component",d,"element-type-".concat(v),"size-".concat(y),{"multi-line-ellipsis":P&&C>1,"single-line-ellipsis":P&&1>=C,"suggest-edit-on-hover":N}),q=o.createElement(v,{className:S,"aria-label":b,id:x,ref:I,style:M},W?e(p,{highlightTerm:W,text:h,linesToClamp:C,useEllipsis:P,nonEllipsisTooltip:_,tooltipPosition:z}):h),D=r({ref:P?G:null});if((t((function(){G.current&&G.current.style.setProperty("--heading-clamp-lines",null==C?void 0:""+C)}),[G,C,D]),!W)&&(D||_))return e(l,Object.assign({content:D?h:_,position:z},{children:q}));return q};Object.assign(u,{types:m,sizes:c});var d=u;export{d as default};
