import{__assign as e}from'./../../../ext-esm/tslib/tslib.es6.js';import{jsx as t,jsxs as r,Fragment as a}from"react/jsx-runtime";import{memo as o}from"react";import i from"moment";import{isEqual as n,template as l}from"lodash";import{makeStyles as s}from"@material-ui/core";import p from"@material-ui/icons/ArrowForward";import{Tooltip as c}from"../../Tooltip/Tooltip.js";import"../../Tooltip/ScrollableTooltip.js";import{getDeductsFromScoreClass as m,isResolved as d,getDeductsFromScoreValue as h}from"../utils.js";import{ALERT_STATES as f,BADGE_ICON_STATUSES as g}from"../constants.js";import{UniversalLink as u}from"../../DevCenter/DevCenterRouterContext/UniversalLink/UniversalLink.js";import{useDQUnvalidatedContentStyles as x}from"../styles.js";import{MIXPANEL_ACTION_TYPES as w}from"../../../constants/mixpanel.js";var y=s((function(e){return{errorIcon:{width:20,height:18},title:{maxWidth:198,padding:"0 0 8px",fontSize:16,lineHeight:"22px",color:e.palette.primary.text1,display:"flex",alignItems:"center"},emptyMessage:{padding:"0",fontSize:16,lineHeight:"22px",color:e.palette.primary.contrastText},alertTime:{fontSize:14,color:e.palette.primary.text6,"& span":{color:e.palette.primary.text1}},alertMessage:{width:"100%",height:40,margin:0,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box","-webkit-line-clamp":2,"-webkit-box-orient":"vertical",whiteSpace:"pre-wrap",fontSize:14,lineHeight:"20px",color:e.palette.primary.text1},alertMessageFull:{marginBottom:8,fontSize:14,lineHeight:"20px",color:e.palette.primary.text1,whiteSpace:"pre-wrap"},alertInfo:{display:"flex",alignItems:"center",flexWrap:"wrap",marginBottom:8,fontSize:14,textTransform:"capitalize","& span":{color:e.palette.primary.text6,marginRight:8},"& .error":{color:e.palette.error.main},"& .warning":{color:"#ffa500"}},resolvedInfo:{display:"flex",alignItems:"center",marginBottom:8,color:e.palette.primary.text6,fontSize:14},infoIcon:{color:e.palette.info.main,marginRight:8,fontSize:16},popover:{marginLeft:77,width:270,padding:12,display:"flex",flexDirection:"column",justifyContent:"space-between",backgroundColor:e.palette.background.b9,border:"1px solid ".concat(e.palette.primary.text9),boxShadow:"0px 3px 10px rgba(0, 0, 0, 0.4)",borderRadius:4,zIndex:500,"& .MuiTooltip-tooltip":{backgroundColor:e.palette.background.b9,fontWeight:400,lineHeight:"20px",margin:0,padding:0}},message:{whiteSpace:"pre-wrap"},note:{marginBottom:4},ok:{color:"#F99500 !important"},good:{color:"".concat(e.palette.warning.light," !important")}}})),v=function(e,t){return void 0===t&&(t="MMM D YYYY, hh:mm A"),e?i.unix(e).format(t):null},b=function(e){return i.unix(e).format("DD MMM HH:mm (Z)")},S=function(r){var a=r.children,o=y(),i=l(a)({timestampFormatter:b}).split("**").map((function(e,r){return r%2==1?t("b",{children:e}):e}));return t("span",e({className:o.message},{children:i}))},N=o((function(o){var i,n=o.alert,l=o.alertIcon,s=o.children,b=o.linkToDQPage,N=y(),I=x({}),M=Math.max(n.statusUpdatedAt,n.lastCheckedAt),T=v(M);return t(c,{interactive:!0,children:s,PopperProps:{className:N.popover},placement:"right",title:r(a,{children:[n.emptyMessage&&t("div",e({className:N.emptyMessage},{children:n.statusUpdatedAt?v(n.statusUpdatedAt):n.emptyMessage})),!n.emptyMessage&&r(a,{children:[r("div",e({className:N.title},{children:[n.name,t(c,e({isFullScreen:!1,title:"Go to Data Quality page"},{children:t("div",{children:t(u,e({className:I.link,href:b,onClick:function(){var e;null===(e=window[Symbol.for("logToMixpanel")])||void 0===e||e.call(window,w.REDIRECT.ASSET_DASHBOARD,{referer:"DQ Badge"})}},{children:t(p,{className:I.linkIcon})}))})}))]})),r("span",e({className:N.alertInfo},{children:[t("span",{children:"Category:"})," ",n.category]})),r("span",e({className:N.alertInfo},{children:[t("span",{children:"Status:"})," ",n.status]})),r("span",e({className:N.alertInfo},{children:[t("span",{children:"Error Type:"}),t("div",e({className:N.errorIcon},{children:l})),t("span",e({className:n.state===f.issue?g.warning:g.error},{children:n.state}))]})),r("span",e({className:N.alertInfo},{children:[t("span",{children:"Score Deduction:"}),t("span",e({className:m(N,n.deductsFromScore,d(n.status))},{children:h(n.deductsFromScore,d(n.status))}))]})),r("div",e({className:N.alertMessageFull},{children:[n.isThrottled&&t("b",{children:"[Throttled]: "}),t(S,{children:n.message})]})),r("span",e({className:N.alertInfo},{children:[t("span",e({className:N.note},{children:"Note:"}))," ",(null===(i=n.note)||void 0===i?void 0:i.length)?n.note:"—"]})),r("span",e({className:N.alertTime},{children:["Updated at: ",t("span",{children:T})]}))]})]})})}),(function(e,t){return n(e.alert,t.alert)}));export{N as DQAlertsTooltip};
