import{jsx as e,jsxs as r}from"react/jsx-runtime";import{memo as t,useState as n,useRef as i,useEffect as o}from"react";import{makeStyles as a,Tooltip as s}from"@material-ui/core";import c from"classnames";import{MIXPANEL_ACTION_TYPES as l}from"../../constants/mixpanel.js";import"../DevCenter/DevCenterRouterContext/DevCenterRouterContext.js";import{UniversalLink as m}from"../DevCenter/DevCenterRouterContext/UniversalLink/UniversalLink.js";import"@babel/runtime/helpers/defineProperty";import"@babel/runtime/helpers/objectWithoutProperties";import"react-router";import{truncateInTheMiddle as u}from"../../utils/formatting.js";import d from"./AssetNameLabel.styles.css.js";var p=a({assetName:{maxWidth:function(e){return e.chipMaxWidth}}}),f=t((function(t){var a,f=t.assetName,h=t.classes,v=t.coordinatesPixelWidth,x=t.dataTestId,C=t.href,N=t.icon,D=t.statusBadge,b=n(f),j=b[0],W=b[1],R=i(),w=i(),A=(a=v)>=1024?244:a>=768?184:a>=420?134:44,S=i(A),T=p({chipMaxWidth:A});return o((function(){W(f),w.current=null}),[f]),o((function(){w.current||(w.current=R.current.scrollWidth)}),[w.current]),o((function(){if(R.current&&w.current){if(A>S.current)return W(f),w.current=null,void(S.current=A);var e=u(f,R.current.clientWidth,w.current);W(e),S.current=A}}),[f,A,R.current,w.current]),e(s,{title:f||"",children:e("div",{className:c(d.wrapper),children:r(m,{className:c(d.item,null==h?void 0:h.item),"data-testid":x,href:C,onClick:function(){var e;null===(e=window[Symbol.for("logToMixpanel")])||void 0===e||e.call(window,l.REDIRECT.ASSET_DASHBOARD,{referer:"Asset Chip"})},children:[N&&e("div",{className:d.startIcon,children:N}),e("span",{className:c(d.assetName,T.assetName),ref:R,children:j}),D]})})})}));export{f as AssetNameLabel};
