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