1import{r as i,E as A,_ as z,b4 as t,p as H,b5 as P,f as c,L as x,o as G,m as q,h as p,j as l,k as v,P as F,q as U,aC as X,b6 as Y,O as j}from"./index.RuhrnD1v.js";import{e as J,S as K,a as Q,b as Z}from"./embed.BiANn3cj.js";import{W as ee}from"./WidgetLabelHelpIconInline.p-GgbwF5.js";import{i as R,f as re}from"./formatNumber.BdmueDpm.js";import{a as te}from"./styled-components.CXqQ-NdV.js";import"./threshold.CEb3xhGW.js";import"./value.X_5h6zV4.js";import"./timer.DrnPlWJ3.js";import"./numbro.B9_PXfzp.js";import"./sprintfjs.DSsuEWyc.js";var D=i.forwardRef(function(e,r){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return i.createElement(A,z({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:r}),i.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),i.createElement("path",{d:"M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z"}))});D.displayName="ArrowDownward";var b=i.forwardRef(function(e,r){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return i.createElement(A,z({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:r}),i.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),i.createElement("path",{d:"M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z"}))});b.displayName="ArrowUpward";function k(e,r){switch(r){case t.MetricColor.RED:return e.colors.redColor;case t.MetricColor.GREEN:return e.colors.greenColor;case t.MetricColor.ORANGE:return e.colors.orangeColor;case t.MetricColor.YELLOW:return e.colors.yellowColor;case t.MetricColor.BLUE:return e.colors.blueColor;case t.MetricColor.VIOLET:return e.colors.violetColor;case t.MetricColor.PRIMARY:return e.colors.primary;default:return e.colors.grayColor}}function W(e,r){const o=H(e);switch(r){case t.MetricColor.RED:return e.colors.redBackgroundColor;case t.MetricColor.GREEN:return e.colors.greenBackgroundColor;case t.MetricColor.ORANGE:return e.colors.orangeBackgroundColor;case t.MetricColor.YELLOW:return e.colors.yellowBackgroundColor;case t.MetricColor.BLUE:return e.colors.blueBackgroundColor;case t.MetricColor.VIOLET:return e.colors.violetBackgroundColor;case t.MetricColor.PRIMARY:return P(e.colors.primary,o?.9:.7);default:return e.colors.grayBackgroundColor}}function oe(e,r){switch(r){case t.MetricColor.RED:return e.colors.redTextColor;case t.MetricColor.GREEN:return e.colors.greenTextColor;case t.MetricColor.ORANGE:return e.colors.orangeTextColor;case t.MetricColor.YELLOW:return e.colors.yellowTextColor;case t.MetricColor.BLUE:return e.colors.blueTextColor;case t.MetricColor.VIOLET:return e.colors.violetTextColor;case t.MetricColor.PRIMARY:return e.colors.primary;default:return e.colors.grayTextColor}}const ie=c("div",{target:"e1v75nrm0"})(({theme:e,showBorder:r})=>({height:"100%",...r&&{border:`${e.sizes.borderWidth} solid ${e.colors.borderColor}`,borderRadius:e.radii.default,overflow:"hidden"}})),ae=c("div",{target:"e1v75nrm1"})(({theme:e,showBorder:r})=>({...r&&{padding:`calc(${e.spacing.lg} - ${e.sizes.borderWidth})`}})),le=c("div",{target:"e1v75nrm2"})(({theme:e,showBorder:r})=>({marginTop:r?void 0:e.spacing.lg,marginBottom:r?e.spacing.twoXL:void 0})),ne=c(te,{target:"e1v75nrm3"})(({visibility:e})=>({marginBottom:0,display:e===x.Collapsed?"none":"grid",gridTemplateColumns:e===x.Collapsed?"initial":"auto 1fr",visibility:e===x.Hidden?"hidden":"visible"})),se=c("div",{target:"e1v75nrm4"})(({theme:e})=>({fontSize:e.metricValueFontSize??e.fontSizes.threeXL,lineHeight:"normal",...e.metricValueFontWeight!==void 0&&{fontWeight:e.metricValueFontWeight},color:e.colors.bodyText,paddingBottom:e.spacing.twoXS})),ce=c("div",{target:"e1v75nrm5"})(({theme:e,metricColor:r,showArrow:o})=>({color:oe(e,r),backgroundColor:W(e,r),fontSize:e.fontSizes.sm,lineHeight:"normal",display:"inline-flex",flexDirection:"row",alignItems:"center",fontWeight:e.fontWeights.normal,borderRadius:e.radii.full,maxWidth:"100%",flexShrink:0,padding:`${e.spacing.threeXS} ${e.spacing.xs}`,...o&&{paddingLeft:e.spacing.twoXS}})),de=c("div",{target:"e1v75nrm6"})(({theme:e})=>({display:"flex",flexDirection:"row",alignItems:"center",gap:"0.5em",maxWidth:"100%",overflow:"hidden",paddingBottom:e.spacing.twoXS})),ue=c("div",{target:"e1v75nrm7"})({overflow:"hidden",flexShrink:1,minWidth:0}),pe=1e3;function V(e,r){try{return re(Number(e),r)}catch{return e}}function ge(e,r,o,a,g){const n=`metric_chart_${Math.random().toString(36).slice(2,10)}`,y=e.length===1?[e[0],e[0]]:e,s={$schema:"https://vega.github.io/schema/vega-lite/v5.json",width:Math.round(o),height:Math.round(j("3.5rem")),data:{values:y.map((w,f)=>({x:f,y:w}))},layer:[{name:`${n}_mark`,mark:{type:"line",...r===t.ChartType.LINE&&{type:"line",strokeCap:"round",strokeWidth:a.sizes.metricStrokeWidth},...r===t.ChartType.BAR&&{type:"bar",cornerRadius:parseFloat(a.radii.full)},...r===t.ChartType.AREA&&{type:"area",color:W(a,g),opacity:1,line:{color:k(a,g),opacity:1,strokeWidth:a.sizes.metricStrokeWidth,strokeCap:"round"}}},encoding:{x:{field:"x",type:"quantitative",axis:null,scale:{zero:!1,nice:!1}},y:{field:"y",type:"quantitative",axis:null,scale:{zero:!1,nice:!1}}}},{name:`${n}_points`,mark:{type:"point",opacity:0}
1,encoding:{x:{field:"x",type:"quantitative",axis:null,scale:{zero:!1,nice:!1}},y:{field:"y",type:"quantitative",axis:null,scale:{zero:!1,nice:!1}}},params:[{name:`${n}_hover_selection`,select:{type:"point",encodings:["x"],nearest:!0,on:e.length>pe?"mousemove{16}":"mousemove",clear:"mouseleave"}}]},{name:`${n}_highlighted_points`,transform:[{filter:{param:`${n}_hover_selection`,empty:!1}}],mark:{type:"point",filled:!0,size:65,tooltip:!0},encoding:{x:{field:"x",type:"quantitative",axis:null,scale:{zero:!1,nice:!1}},y:{field:"y",type:"quantitative",axis:null,scale:{zero:!1,nice:!1}}}}],config:{view:{stroke:null},padding:{left:-3,right:-3,top:2,bottom:2},...r===t.ChartType.BAR&&{padding:{left:0,right:0,top:2,bottom:2}},mark:{tooltip:{content:"encoding"},color:k(a,g)}}};return s.config=Q(s.config,a),s}function fe({element:e}){const r=G(),o=i.useRef(null),{width:a,elementRef:g}=q(),{MetricDirection:C}=t,{body:n,label:y,delta:s,direction:w,color:f,labelVisibility:B,help:E,showBorder:h,chartData:d,chartType:L,format:M,deltaDescription:m}=e,I=M&&R(n)?V(n,M):n,N=M&&s&&R(s)?V(s,M):s;let u=null;switch(w){case C.DOWN:u=D;break;case C.UP:u=b;break;case C.NONE:break}const _="0 threeXS 0 0",T=s!=="",S=i.useId();return i.useEffect(()=>{if(d&&d.length>0&&o.current&&a>0){const O=ge(d,L,a,r,f);J(o.current,O,{actions:!1,renderer:"svg",ast:!0,expr:Z,tooltip:{theme:"custom",formatTooltip:$=>`${$.y}`}})}},[d,f,r,a,L,o]),p(ie,{className:"stMetric","data-testid":"stMetric",showBorder:h,children:[p(ae,{showBorder:h,children:[p(ne,{"data-testid":"stMetricLabel",visibility:U(B?.value),children:[l(v,{source:y,allowHTML:!1,isLabel:!0,truncate:!0}),E&&l(ee,{content:E,placement:F.TOP_RIGHT,label:y})]}),l(se,{"data-testid":"stMetricValue",children:l(v,{source:I,allowHTML:!1,isLabel:!0,inheritFont:!0,truncate:!0})}),(T||m)&&p(de,{children:[T&&p(ce,{"data-testid":"stMetricDelta",metricColor:f,showArrow:u!==null,"aria-describedby":m?S:void 0,children:[u&&l(X,{testid:u===b?"stMetricDeltaIcon-Up":"stMetricDeltaIcon-Down",content:u,size:"md",margin:_}),l(v,{source:N,allowHTML:!1,isLabel:!0,inheritFont:!0,truncate:!0})]}),m&&l(ue,{"data-testid":"stMetricDeltaDescription",id:S,title:m,children:l(v,{source:m,allowHTML:!1,isLabel:!0,isCaption:!0,truncate:!0})})]})]}),d&&d.length>0&&p("div",{ref:g,children:[l(Y,{styles:[K]}),l(le,{ref:o,"data-testid":"stMetricChart",showBorder:h})]})]})}const Le=i.memo(fe);export{Le as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.