1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8403],{16301:(e,t,a)=>{"use strict";a.d(t,{II:()=>h,Nt:()=>f,X1:()=>p,at:()=>m,uy:()=>u});var r=a(73154),s=a(96810),n=a(20767),o=a(19381),l=a(79695),i=a(81509);let c={light:"",dark:".dark"},d=s.createContext(null);function u(){let e=s.useContext(d);if(!e)throw Error("useChart must be used within a <ChartContainer />");return e}let m=s.forwardRef((e,t)=>{let{id:a,className:o,children:l,config:c,...u}=e,m=s.useId(),h="chart-".concat(a||m.replace(/:/g,""));return(0,r.jsx)(d.Provider,{value:{config:c},children:(0,r.jsxs)("div",{"data-chart":h,ref:t,className:(0,i.cn)("h-full w-full flex-1 justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",o),...u,children:[(0,r.jsx)(x,{id:h,c
1onfig:c}),(0,r.jsx)(n.u,{children:l})]})})});m.displayName="Chart";let x=e=>{let{id:t,config:a}=e,s=Object.entries(a).filter(e=>{let[,t]=e;return t.theme||t.color});return s.length?(0,r.jsx)("style",{dangerouslySetInnerHTML:{__html:Object.entries(c).map(e=>{let[a,r]=e;return"\n".concat(r," [data-chart=").concat(t,"] {\n").concat(s.map(e=>{var t;let[r,s]=e,n=(null==(t=s.theme)?void 0:t[a])||s.color;return n?" --color-".concat(r,": ").concat(n,";"):null}).join("\n"),"\n}\n")}).join("\n")},"data-sentry-component":"ChartStyle","data-sentry-source-file":"chart.tsx"}):null},h=o.m,f=s.forwardRef((e,t)=>{let{active:a,payload:n,className:o,indicator:l="dot",hideLabel:c=!1,hideIndicator:d=!1,label:m,labelFormatter:x,labelClassName:h,formatter:f,color:g,nameKey:v,labelKey:y,valueFormatter:b,nameFormatter:j,sortPayloadByValue:N}=e,{config:C}=u(),S=s.useMemo(()=>(null==n?void 0:n.length)&&N?[...n].sort((e,t)=>{var a,r;let s=Number(null!=(a=e.value)?a:0),n=Number(null!=(r=t.value)?r:0);return"desc"===N?n-s:s-n}):null!=n?n:[],[n,N]),w=s.useMemo(()=>{var e;if(c||!(null==n?void 0:n.length))return null;let[t]=n,a="".concat(y||(null==t?void 0:t.dataKey)||(null==t?void 0:t.name)||"value"),s=p(C,t,a),o=y||"string"!=typeof m?null==s?void 0:s.label:(null==(e=C[m])?void 0:e.label)||m;return x?(0,r.jsx)("div",{className:(0,i.cn)("font-medium",h),children:x(o,n)}):o?(0,r.jsx)("div",{className:(0,i.cn)("font-medium",h),children:o}):null},[m,x,n,c,h,C,y]);if(!a||!(null==n?void 0:n.length))return null;let M=1===S.length&&"dot"!==l;return(0,r.jsxs)("div",{ref:t,className:(0,i.cn)("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",o),children:[M?null:w,(0,r.jsx)("div",{className:"grid gap-1.5",children:S.map((e,t)=>{var a,s;let n="".concat(v||e.name||e.dataKey||"value"),o=p(C,e,n),c=g||e.payload.fill||e.color;return(0,r.jsx)("div",{className:(0,i.cn)("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground","dot"===l&&"items-center"),children:f&&(null==e?void 0:e.value)!==void 0&&e.name?f(e.value,e.name,e,t,e.payload):(0,r.jsxs)(r.Fragment,{children:[(null==o?void 0:o.icon)?(0,r.jsx)(o.icon,{}):!d&&(0,r.jsx)("div",{className:(0,i.cn)("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":"dot"===l,"w-1":"line"===l,"w-0 border-[1.5px] border-dashed bg-transparent":"dashed"===l,"my-0.5":M&&"dashed"===l}),style:{"--color-bg":c,"--color-border":c}}),(0,r.jsxs)("div",{className:(0,i.cn)("flex flex-1 justify-between leading-none",M?"items-end":"items-center"),children:[(0,r.jsxs)("div",{className:"grid gap-1.5",children:[M?w:null,(0,r.jsx)("span",{className:"text-muted-foreground",children:j?j(String(null!=(s=null!=(a=e.name)?a:e.dataKey)?s:"")):(null==o?void 0:o.label)||e.name})]}),void 0!==e.value&&null!==e.value&&(0,r.jsx)("span",{className:"font-mono font-medium tabular-nums text-foreground",children:b?b(Number(e.value)):e.value.toLocaleString()})]})]})},e.dataKey)})})]})});function p(e,t,a){if("object"!=typeof t||null===t)return;let r="payload"in t&&"object"==typeof t.payload&&null!==t.payload?t.payload:void 0,s=a;return a in t&&"string"==typeof t[a]?s=t[a]:r&&a in r&&"string"==typeof r[a]&&(s=r[a]),s in e?e[s]:e[a]}f.displayName="ChartTooltip",l.s,s.forwardRef((e,t)=>{let{className:a,hideIcon:s=!1,payload:n,verticalAlign:o="bottom",nameKey:l}=e,{config:c}=u();return(null==n?void 0:n.length)?(0,r.jsx)("div",{ref:t,className:(0,i.cn)("flex items-center justify-center gap-4","top"===o?"pb-3":"pt-3",a),children:n.map(e=>{let t="".concat(l||e.dataKey||"value"),a=p(c,e,t);return(0,r.jsxs)("div",{className:(0,i.cn)("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[(null==a?void 0:a.icon)&&!s?(0,r.jsx)(a.icon,{}):(0,r.jsx)("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:e.color}}),null==a?void 0:a.label]},e.value)})}):null}).displayName="ChartLegend"},26159:(e,t,a)=>{"use strict";a.d(t,{A:()=>o});var r=a(73154),s=a(49757),n=a(81509);let o=e=>{let{children:t,headerProps:a,scrollable:o=!1,withPadding:l=!1}=e;return(0,r.jsxs)("div",{className:(0,n.cn)("flex flex-col",o?"relative flex min-h-screen-with-banner flex-1":"h-full"),id:"page","data-sentry-component":"Page","data-sentry-source-file":"page.tsx",children:[(0,r.jsx)("header",{className:"sticky top-0 z-50 w-full",children:(0,r.jsx)(s.A,{...a,container:!1,className:"top-0","data-sentry-element":"PageHeader","data-sentry-source-file":"page.tsx"})}),(0,r.jsx)("main",{className:(0,n.cn)("flex flex-1 flex-col",o?"relative flex min-h-screen-with-banner":"h-full overflow-hidden",l&&"p-3"),children:t})]})}},37982:(e,t,a)=>{"use strict";a.d(t,{G:()=>x});var r=a(73154),s=a(96810),n=a(31642),o=a(92273),l=a(81509),i=a(86843),c=a(95266),d=a(97638);function u(e){return e.length>0&&"object"==typeof e[0]&&"options"in e[0]&&Array.isArray(e[0].options)}function m(e,t){return e&&t&&"object"==typeof e&&"object"==typeof t&&"id"in e&&"id"in t?e.id===t.id:e===t}function x(e){var t;let{options:a,value:x,onValueChange:h,placeholder:f="Select option...",emptyText:p="No option found.",searchPlaceholder:g="Search...",disabled:v=!1,className:y,name:b}=e,[j,N]=s.useState(!1),C=s.useMemo(()=>
1{if(u(a)){for(let e of a){let t=e.options.find(e=>m(e.value,x));if(t)return t}return}return a.find(e=>m(e.value,x))},[a,x]);return(0,r.jsxs)(d.AM,{open:j,onOpenChange:N,"data-sentry-element":"Popover","data-sentry-component":"Combobox","data-sentry-source-file":"combobox.tsx",children:[(0,r.jsx)(d.Wv,{asChild:!0,"data-sentry-element":"PopoverTrigger","data-sentry-source-file":"combobox.tsx",children:(0,r.jsxs)(i.$,{variant:"outline",role:"combobox","aria-expanded":j,className:(0,l.cn)("w-full justify-between text-xs font-normal",!x&&"text-muted-foreground",y),disabled:v,name:b,"data-sentry-element":"Button","data-sentry-source-file":"combobox.tsx",children:[(0,r.jsx)("span",{className:"truncate",children:C?null!=(t=C.label)?t:String(C.value):f}),(0,r.jsx)(n.A,{className:"ml-2 h-4 w-4 shrink-0 opacity-50","data-sentry-element":"ChevronsUpDown","data-sentry-source-file":"combobox.tsx"})]})}),(0,r.jsx)(d.hl,{className:"w-[var(--radix-popover-trigger-width)] p-0","data-sentry-element":"PopoverContent","data-sentry-source-file":"combobox.tsx",children:(0,r.jsxs)(c.uB,{"data-sentry-element":"Command","data-sentry-source-file":"combobox.tsx",children:[(0,r.jsx)(c.G7,{placeholder:g,className:"text-xs","data-sentry-element":"CommandInput","data-sentry-source-file":"combobox.tsx"}),(0,r.jsxs)(c.oI,{"data-sentry-element":"CommandList","data-sentry-source-file":"combobox.tsx",children:[(0,r.jsx)(c.xL,{"data-sentry-element":"CommandEmpty","data-sentry-source-file":"combobox.tsx",children:p}),u(a)?a.map((e,t)=>(0,r.jsx)(c.L$,{heading:e.heading,children:e.options.map(e=>{var t,a;return(0,r.jsxs)(c.h_,{value:null!=(t=e.label)?t:String(e.value),disabled:e.disabled,onSelect:()=>{!e.disabled&&h&&(h(e.value),N(!1))},className:(0,l.cn)("text-xs",e.disabled&&"text-muted-foreground line-through"),children:[(0,r.jsx)(o.A,{className:(0,l.cn)("mr-2 h-4 w-4",m(x,e.value)?"opacity-100":"opacity-0")}),null!=(a=e.label)?a:String(e.value)]},"object"==typeof e.value?e.value.id:String(e.value))})},t)):(0,r.jsx)(c.L$,{children:a.map(e=>{var t,a;return(0,r.jsxs)(c.h_,{value:null!=(t=e.label)?t:String(e.value),disabled:e.disabled,onSelect:()=>{!e.disabled&&h&&(h(e.value),N(!1))},className:(0,l.cn)("text-xs",e.disabled&&"text-muted-foreground line-through"),children:[(0,r.jsx)(o.A,{className:(0,l.cn)("mr-2 h-4 w-4",m(x,e.value)?"opacity-100":"opacity-0")}),null!=(a=e.label)?a:String(e.value)]},"object"==typeof e.value?e.value.id:String(e.value))})})]})]})})]})}},46696:(e,t,a)=>{"use strict";a.d(t,{$:()=>r,U:()=>s});let r={SCORES:"scores",ANALYTICS:"analytics"},s=e=>[{value:r.SCORES,label:"Scores",href:"/project/".concat(e,"/scores")},{value:r.ANALYTICS,label:"Analytics",href:"/project/".concat(e,"/scores/analytics")}]},55029:(e,t,a)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/project/[projectId]/scores/analytics",function(){return a(66847)}])},60430:(e,t,a)=>{"use strict";a.d(t,{D:()=>o});var r=a(6300),s=a(8277),n=a(96810);function o(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=null!=(e=t.defaultRelativeAggregation)?e:s.t8,[o,l]=(0,r.useQueryParams)({dateRange:(0,r.withDefault)(r.StringParam,(0,s.qE)(a))});return(0,n.useMemo)(()=>({timeRange:(0,s.JR)(o.dateRange,s.P6,a),setTimeRange:e=>{l({dateRange:(0,s.gG)(e)})}}),[o.dateRange,a,l])}},66847:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>e1});var r=a(73154),s=a(39156),n=a(96810),o=a(26159),l=a(46696),i=a(6300);function c(){var e,t;let[a,r]=(0,i.useQueryParams)({score1:i.StringParam,score2:i.StringParam,dateRange:(0,i.withDefault)(i.StringParam,"1d"),objectType:(0,i.withDefault)(i.StringParam,"all")}),s={score1:null!=(e=a.score1)?e:void 0,score2:null!=(t=a.score2)?t:void 0,dateRange:a.dateRange,objectType:a.objectType},n=e=>{r(e,"pushIn")};return{state:s,setState:n,setScore1:e=>{n({score1:e})},setScore2:e=>{n({score2:e})},setDateRange:e=>{n({dateRange:e})},setObjectType:e=>{n({objectType:e})},clearScores:()=>{n({score1:void 0,score2:void 0})}}}var d=a(60430),u=a(8277),m=a(13882),x=a(51883),h=a(93367),f=a(19319),p=a(7915),g=a(22877),v=a(8113),y=a(79405),b=a(83216),j=a(23247),N=a(72074),C=a(84410),S=a(55760),w=a(58272),M=a(46116),T=a(90591),k=a(48802);
1function L(e,t,a,r){let{count:s,unit:n}=r;return 1===s||7===s&&"day"===n?function(e,t,a,r){let{count:s,unit:n}=r,o=7===s&&"day"===n?e=>(0,j.k)(e,{weekStartsOn:1}):e=>{switch(n){case"second":return(0,f.a)(e);case"minute":return(0,p.c)(e);case"hour":return(0,g.Q)(e);case"day":return(0,v.o)(e);case"month":return(0,y.w)(e);case"year":return(0,b.D)(e)}},l=7===s&&"day"===n?e=>(0,k.J)(e,1):e=>{switch(n){case"second":return(0,N.p)(e,1);case"minute":return(0,C.z)(e,1);case"hour":return(0,S.L)(e,1);case"day":return(0,w.f)(e,1);case"month":return(0,M.P)(e,1);case"year":return(0,T.e)(e,1)}},i=o(t),c=new Map;for(let t of e){let e=o(t.timestamp).getTime();c.set(e,t)}let d=[];if(0===e.length)return d;let u=Math.max(...e.map(e=>o(e.timestamp).getTime())),m=i;for(;m.getTime()<=u;){let t=m.getTime(),a=c.get(t);if(a)d.push(a);else{let a={timestamp:new Date(t)};if(e.length>0){let t=e[0];if(t)for(let e in t)"timestamp"!==e&&"number"==typeof t[e]?a[e]=null:"timestamp"!==e&&(a[e]=t[e])}d.push(a)}m=l(m)}return d}(e,t,0,r):function(e,t,a,r){let{count:s,unit:n}=r;if(0===e.length)return[];let o=e=>{switch(n){case"second":return(0,f.a)(e);case"minute":return(0,p.c)(e);case"hour":return(0,g.Q)(e);case"day":return(0,v.o)(e);case"month":return(0,y.w)(e);case"year":return(0,b.D)(e)}},l=e=>{switch(n){case"second":return(0,N.p)(e,-1);case"minute":return(0,C.z)(e,-1);case"hour":return(0,S.L)(e,-1);case"day":return(0,w.f)(e,-1);case"month":return(0,M.P)(e,-1);case"year":return(0,T.e)(e,-1)}},i=[],c=a,d=0;for(;c>=t&&d<1e4;){d++;let e=c;for(let t=0;t<s-1;t++)e=l(e);e<a&&i.unshift({start:e,end:c,dataPoints:[]});for(let e=0;e<s;e++)c=l(c)}for(let t of e){let e=o(t.timestamp);for(let a of i)if(e>=a.start&&e<=a.end){a.dataPoints.push(t);break}}let u=[];for(let t of i)if(0===t.dataPoints.length){let a={timestamp:t.end};if(e.length>0){let t=e[0];if(t)for(let e in t)"timestamp"!==e&&"number"==typeof t[e]?a[e]=null:"timestamp"!==e&&(a[e]=t[e])}u.push(a)}else{let e={timestamp:t.end},a=t.dataPoints[0];for(let r in a)if("timestamp"!==r)if("number"==typeof a[r]){let a=t.dataPoints.map(e=>e[r]).filter(e=>null!==e);if(a.length>0){let t=a.reduce((e,t)=>e+t,0);e[r]=t/a.length}else e[r]=null}else e[r]=a[r];u.push(e)}return u}(e,t,a,r)}function A(e,t,a,r){let{count:s,unit:n}=r,o=Array.from(new Set(e.map(e=>e.category)));return 0===o.length?[]:1===s||7===s&&"day"===n?function(e,t,a,r,s){let{count:n,unit:o}=r,l=7===n&&"day"===o?e=>(0,j.k)(e,{weekStartsOn:1}):e=>{switch(o){case"second":return(0,f.a)(e);case"minute":return(0,p.c)(e);case"hour":return(0,g.Q)(e);case"day":return(0,v.o)(e);case"month":return(0,y.w)(e);case"year":return(0,b.D)(e)}},i=7===n&&"day"===o?e=>(0,k.J)(e,1):e=>{switch(o){case"second":return(0,N.p)(e,1);case"minute":return(0,C.z)(e,1);case"hour":return(0,S.L)(e,1);case"day":return(0,w.f)(e,1);case"month":return(0,M.P)(e,1);case"year":return(0,T.e)(e,1)}},c=l(t),d=l(a),u=new Map;for(let t of e){let e=l(t.timestamp).getTime();u.has(e)||u.set(e,new Map),u.get(e).set(t.category,t.count)}let m=[],x=c;for(;x.getTime()<=d.getTime();){let e=x.getTime(),t=u.get(e);for(let a of s){var h;let r=null!=(h=null==t?void 0:t.get(a))?h:0;m.push({timestamp:new Date(e),category:a,count:r})}x=i(x)}return m}(e,t,a,r,o):function(e,t,a,r,s){let{count:n,unit:o}=r;if(0===e.length)return[];let l=e=>{switch(o){case"second":return(0,f.a)(e);case"minute":return(0,p.c)(e);case"hour":return(0,g.Q)(e);case"day":return(0,v.o)(e);case"month":return(0,y.w)(e);case"year":return(0,b.D)(e)}},i=e=>{switch(o){case"second":return(0,N.p)(e,-1);case"minute":return(0,C.z)(e,-1);case"hour":return(0,S.L)(e,-1);case"day":return(0,w.f)(e,-1);case"month":return(0,M.P)(e,-1);case"year":return(0,T.e)(e,-1)}},c=[],d=a,u=0;for(;d>=t&&u<1e4;){u++;let e=d;for(let t=0;t<n-1;t++)e=i(e);e<a&&c.unshift({start:e,end:d,dataPoints:[]});for(let e=0;e<n;e++)d=i(d)}for(let t of e){let e=l(t.timestamp);for(let a of c)if(e>=a.start&&e<=a.end){a.dataPoints.push(t);break}}let m=[];for(let e of c){var x,h;let t=new Map;for(let e of s)t.set(e,0);for(let a of e.dataPoints){let e=null!=(x=t.get(a.category))?x:0;t.set(a.category,e+a.count)}
1for(let a of s)m.push({timestamp:e.end,category:a,count:null!=(h=t.get(a))?h:0})}return m}(e,t,a,r,o)}function _(e,t){let a;return a=t>=10?1:t>=1?2:t>=.1?3:4,e.toFixed(a)}function E(e,t){let a=new Map(e.map(e=>[e.binIndex,e.count]));return t.map((e,t)=>{var r;return{binIndex:t,count:null!=(r=a.get(t))?r:0}})}function D(e){if(0===e.distribution.length||0===e.timeSeries.length)return null;let t=new Map(Array.from(new Set(e.timeSeries.map(e=>e.category))).sort().map((e,t)=>[t,e])),a=Math.max(...e.distribution.map(e=>e.count)),r=e.distribution.find(e=>e.count===a);if(!r)return null;let s=t.get(r.binIndex);if(!s)return null;let n=r.count/e.totalCount*100;return{mode:{category:s,count:r.count},modePercentage:n}}function I(e){let{min:t,max:a,nBins:r}=e,s=(a-t)/r;return Array.from({length:r},(e,a)=>(function(e,t){let a,r=Math.abs(t-e);return a=r>=1?1:r>=.1?2:3,"".concat(e.toFixed(a)," - ").concat(t.toFixed(a))})(t+a*s,t+(a+1)*s))}var R=a(46836);let B={score1:"hsl(var(--chart-3))",score2:"hsl(var(--chart-2))"};function O(e){let t={"hsl(var(--chart-1))":"#f97316","hsl(var(--chart-2))":"#eab308","hsl(var(--chart-3))":"#3b82f6","hsl(var(--chart-4))":"#8b5cf6","hsl(var(--chart-5))":"#ec4899"};if(e in t)return t[e];if("undefined"!=typeof document)try{let t=document.createElement("div");t.style.color=e,document.body.appendChild(t);let a=window.getComputedStyle(t).color;if(document.body.removeChild(t),a&&a.startsWith("rgb"))return(0,R.Ay)(a).hex()}catch(e){}return"#3b82f6"}function P(e,t,a){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,n=Math.max(r,Math.min(s,a));return R.Ay.mix(t,e,n,"oklab").hex()}function F(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"white",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,n=O(e),o=[];for(let e=0;e<t;e++){let l=s-(s-r)*e/(t-1);o.push(P(n,a,l,r,s))}return o}function H(e,t,a){let r=1===e?B.score1:B.score2,s=[...t].sort(),n=F(r,Math.max(s.length,2),"white",.2,1),o=(null==a?void 0:a.reverse)?[...n].reverse():n,l={};return s.forEach((e,t)=>{l[e]=o[t]||o[0]}),l}function K(e){let t=F(1===e?B.score1:B.score2,2,"white",.3,.8);return{True:t[0],False:t[1]}}function W(e){return P(O(1===e?B.score1:B.score2),"white",1,.1,1)}function U(e,t,a,r){if(0===t)return"transparent";let s=O(1===e?B.score1:B.score2);return r===a?P(s,"white",.55,.1,1):P(s,"white",.1+(t-a)/(r-a)*.9,.1,1)}let V={SCORE1_NUMERIC:"__score1_numeric__",SCORE2_NUMERIC:"__score2_numeric__",SCORE2_TRUE:"__score2_True",SCORE2_FALSE:"__score2_False"},Z=(0,n.createContext)(void 0);function z(e){var t,a,s,o,l;let{params:i,children:c}=e,d=void 0!==i.score1,u=void 0===i.score2?"single":"two",m=h.FH.scoreAnalytics.estimateScoreComparisonSize.useQuery({projectId:i.projectId,score1:null!=(a=i.score1)?a:{name:"",dataType:"",source:""},score2:null!=(o=null!=(s=i.score2)?s:i.score1)?o:{name:"",dataType:"",source:""},fromTimestamp:i.fromTimestamp,toTimestamp:i.toTimestamp,objectType:null!=(l=i.objectType)?l:"all",mode:u},{enabled:d,staleTime:3e4,trpc:{abortOnUnmount:!0}}),x=function(e,t){var a;let{projectId:r,score1:s,score2:o,fromTimestamp:l,toTimestamp:i,interval:c,objectType:d,nBins:u=10,estimateResults:m}=e,x=void 0===o?"single":"two",{data:f,isLoading:p,error:g}=h.FH.scoreAnalytics.getScoreComparisonAnalytics.useQuery({projectId:r,score1:s,score2:null!=o?o:s,mode:x,fromTimestamp:l,toTimestamp:i,interval:c,objectType:d,estimateResults:m},{enabled:(null==(a=null==t?void 0:t.enabled)||a)&&!!(r&&s),trpc:{abortOnUnmount:!0}});return{data:(0,n.useMemo)(()=>{var e,t,a,r,n,d,m,x,h,p,g,v,y,b,j,N,C,S,w,M,T;let k,R,B;if(!f)return null;let{mode:O,isSameScore:P}=f.metadata,F=f.metadata.dataType,H="NUMERIC"===F,K=function(e){if("NUMERIC"!==e.dataType){if("BOOLEAN"===e.dataType)return["False","True"];if(e.stackedDistribution&&e.stackedDistribution.length>0){let t=new Set;return e.stackedDistribution.forEach(e=>{t.add(e.score1Category)}),Array.from(t).sort()}if(e.confusionMatrix.length>0){let t=new Set;
1return e.confusionMatrix.forEach(e=>{t.add(e.rowCategory)}),Array.from(t).sort()}}}({dataType:F,confusionMatrix:f.confusionMatrix,stackedDistribution:f.stackedDistribution}),W=f.score2Categories&&f.score2Categories.length>0?f.score2Categories:"two"===O&&K?K:void 0,U=K?E(f.distribution1,K):f.distribution1.slice().sort((e,t)=>e.binIndex-t.binIndex),V=K&&"two"===O?E(f.distribution2,K):f.distribution2.slice().sort((e,t)=>e.binIndex-t.binIndex),Z=K?E(f.distribution1Individual,K):f.distribution1Individual.slice().sort((e,t)=>e.binIndex-t.binIndex),z=W?E(f.distribution2Individual,W):f.distribution2Individual.slice().sort((e,t)=>e.binIndex-t.binIndex),X=K?E(f.distribution1Matched,K):f.distribution1Matched.slice().sort((e,t)=>e.binIndex-t.binIndex),G=W?E(f.distribution2Matched,W):f.distribution2Matched.slice().sort((e,t)=>e.binIndex-t.binIndex);if(H){if(f.heatmap[0])k=I({min:f.heatmap[0].min1,max:f.heatmap[0].max1,nBins:u}),R=I({min:f.heatmap[0].min2,max:f.heatmap[0].max2,nBins:u}),B=I({min:f.heatmap[0].globalMin,max:f.heatmap[0].globalMax,nBins:u});else if(f.statistics&&null!==f.statistics.mean1&&null!==f.statistics.std1){let e=f.statistics.mean1,t=f.statistics.std1;if(k=I({min:e-3*t,max:e+3*t,nBins:u}),null!==f.statistics.mean2&&null!==f.statistics.std2){let a=f.statistics.mean2,r=f.statistics.std2;R=I({min:a-3*r,max:a+3*r,nBins:u}),B=I({min:Math.min(e-3*t,a-3*r),max:Math.max(e+3*t,a+3*r),nBins:u})}else R=k,B=k}}let q=function(e){let{apiData:t,dataType:a}=e;if(!t)return null;let r="NUMERIC"===a;return r&&t.heatmap.length>0?function(e){let{data:t,nBins:a,showPercentages:r=!1,showCounts:s=!0}=e;if(0===t.length)return{cells:[],rowLabels:[],colLabels:[],maxValue:0};let n=t.reduce((e,t)=>e+t.count,0),o=Math.max(...t.map(e=>e.count)),{min1:l,max1:i,min2:c,max2:d}=t[0],u=(i-l)/a,m=(d-c)/a,x=t.map(e=>{let t=n>0?e.count/n*100:0,a=[c+e.bin_x*m,c+(e.bin_x+1)*m],o=[l+e.bin_y*u,l+(e.bin_y+1)*u],i="";return s&&r?i="".concat(e.count,"\n").concat(t.toFixed(1),"%"):s?i=String(e.count):r&&(i="".concat(t.toFixed(1),"%")),{row:e.bin_y,col:e.bin_x,value:e.count,displayValue:i,metadata:{xRange:a,yRange:o,percentage:t}}}),h=i-l,f=d-c;return{cells:x,rowLabels:Array.from({length:a+1},(e,t)=>_(l+t*u,h)),colLabels:Array.from({length:a+1},(e,t)=>_(c+t*m,f)),maxValue:o}}({data:t.heatmap.map(e=>({bin_x:e.binX,bin_y:e.binY,count:e.count,min1:e.min1,max1:e.max1,min2:e.min2,max2:e.max2})),nBins:10,showCounts:!0,showPercentages:!1}):!r&&t.confusionMatrix.length>0?function(e){let{data:t,showPercentages:a=!1,showCounts:r=!0}=e;if(0===t.length)return{cells:[],rowLabels:[],colLabels:[],rows:0,cols:0,maxValue:0};let s=Array.from(new Set(t.map(e=>e.row_category))).sort(),n=Array.from(new Set(t.map(e=>e.col_category))).sort(),o=t.reduce((e,t)=>e+t.count,0),l=Math.max(...t.map(e=>e.count)),i=new Map;t.forEach(e=>{i.set("".concat(e.row_category,"-").concat(e.col_category),e.count)});let c=[];return s.forEach((e,t)=>{n.forEach((s,n)=>{let l=i.get("".concat(e,"-").concat(s))||0,d=o>0?l/o*100:0,u=e===s,m="";r&&a?m="".concat(l,"\n").concat(d.toFixed(1),"%"):r?m=String(l):a&&(m="".concat(d.toFixed(1),"%")),c.push({row:t,col:n,value:l,displayValue:m,metadata:{rowCategory:e,colCategory:s,percentage:d,isDiagonal:u}})})}),{cells:c,rowLabels:s,colLabels:n,rows:s.length,cols:n.length,maxValue:l}}({data:t.confusionMatrix.map(e=>({row_category:e.rowCategory,col_category:e.colCategory,count:e.count})),showCounts:!0,showPercentages:!0}):null}({apiData:f,dataType:F,parsedScore1:s}),$=H?null:D({distribution:f.distribution1,timeSeries:f.timeSeriesCategorical1,totalCount:f.counts.score1Total}),Q=H||"two"!==O?null:P?D({distribution:f.distribution1,timeSeries:f.timeSeriesCategorical1,totalCount:f.counts.score2Total}):D({distribution:f.distribution2,timeSeries:f.timeSeriesCategorical2,totalCount:f.counts.score2Total}),Y=L(f.timeSeries,l,i,c),J=L(f.timeSeriesMatched,l,i,c);P&&"two"===O&&(Y.forEach(e=>{null===e.avg2&&null!==e.avg1&&(e.avg2=e.avg1)}),J.forEach(e=>{null===e.avg2&&null!==e.avg1&&(e.avg2=e.avg1)}));let ee=A(f.timeSeriesCategorical1,l,i,c),et=A(f.timeSeriesCategorical2,l,i,c),ea=A(f.timeSeriesCategorical1Matched,l,i,c),er=A(f.timeSeriesCategorical2Matched,l,i,c);P&&"two"===O&&(et.length=0,et.push(...ee),er.length=0,er.push(...ea));let es=(e,t)=>e.map(e=>({...e,category:"".concat(t,": ").concat(e.category)})),en="two"===O&&s.name===(null==o?void 0:o.name)&&s.source!==(null==o?void 0:o.source)?"".concat(s.name,"
1(").concat(s.source,")"):s.name,eo="two"===O&&o&&s.name===o.name&&s.source!==o.source?"".concat(o.name," (").concat(o.source,")"):null!=(h=null==o?void 0:o.name)?h:"",el="two"===O?[...es(ee,en),...es(et,eo)]:ee,ei="two"===O?[...es(ea,en),...es(er,eo)]:ea;return{statistics:{score1:{total:f.counts.score1Total,mean:null!=(p=null==(e=f.statistics)?void 0:e.mean1)?p:null,std:null!=(g=null==(t=f.statistics)?void 0:t.std1)?g:null,mode:null!=(v=null==$?void 0:$.mode)?v:null,modePercentage:null!=(y=null==$?void 0:$.modePercentage)?y:null},score2:"two"===O?{total:f.counts.score2Total,mean:null!=(b=null==(a=f.statistics)?void 0:a.mean2)?b:null,std:null!=(j=null==(r=f.statistics)?void 0:r.std2)?j:null,mode:null!=(N=null==Q?void 0:Q.mode)?N:null,modePercentage:null!=(C=null==Q?void 0:Q.modePercentage)?C:null}:null,comparison:"two"===O?{matchedCount:f.counts.matchedCount,pearsonCorrelation:null!=(S=null==(n=f.statistics)?void 0:n.pearsonCorrelation)?S:null,spearmanCorrelation:null!=(w=null==(d=f.statistics)?void 0:d.spearmanCorrelation)?w:null,mae:null!=(M=null==(m=f.statistics)?void 0:m.mae)?M:null,rmse:null!=(T=null==(x=f.statistics)?void 0:x.rmse)?T:null,confusionMatrix:f.confusionMatrix}:null},distribution:{score1:U,score2:"two"===O?V:null,categories:K,binLabels:B,binLabelsIndividual1:k,binLabelsIndividual2:R,binLabelsGlobal:B,score1Individual:Z,score2Individual:z,score1Matched:X,score2Matched:G,stackedDistribution:f.stackedDistribution,stackedDistributionMatched:f.stackedDistributionMatched,score2Categories:f.score2Categories&&f.score2Categories.length>0?f.score2Categories:"two"===O&&K?K:void 0},timeSeries:{numeric:{all:Y,matched:J},categorical:{score1:ee,score2:et,score1Matched:ea,score2Matched:er,all:el,allMatched:ei}},heatmap:q,metadata:{mode:O,isSameScore:P,dataType:F},samplingMetadata:f.samplingMetadata}},[f,s,o,l,i,c,u]),isLoading:p,error:g}}({...i,estimateResults:m.data?{score1Count:m.data.score1Count,score2Count:m.data.score2Count,estimatedMatchedCount:m.data.estimatedMatchedCount}:void 0},{enabled:!d||m.isSuccess}),f=(0,n.useMemo)(()=>{var e;return"two"===(null==(e=x.data)?void 0:e.metadata.mode)?{score1:"hsl(var(--chart-3))",score2:"hsl(var(--chart-2))"}:{score:"hsl(var(--chart-3))"}},[null==(t=x.data)?void 0:t.metadata.mode]),p=(0,n.useMemo)(()=>{var e,t;let a=x.data;return a?function(e){let t={},{dataType:a,mode:r,score1Name:s,score2Name:n,score1Source:o,score2Source:l,categories:i,score2Categories:c}=e,d="two"===r&&s===n&&o!==l?"".concat(s," (").concat(o,")"):s,u="two"===r&&n&&s===n&&o!==l?"".concat(n," (").concat(l,")"):null!=n?n:"";if("CATEGORICAL"===a&&i){let e=H(1,i);
1Object.assign(t,e),"two"===r&&i.forEach(a=>{t["".concat(d,": ").concat(a)]=e[a]})}else if("BOOLEAN"===a&&i){let e=K(1);Object.assign(t,e),"two"===r&&i.forEach(a=>{t["".concat(d,": ").concat(a)]=e[a]})}else"NUMERIC"===a&&(t[V.SCORE1_NUMERIC]=W(1));if("two"===r)if("CATEGORICAL"===a&&c){let e=H(2,c);Object.assign(t,e),c.forEach(a=>{t["".concat(u,": ").concat(a)]=e[a]})}else if("BOOLEAN"===a&&i){let e=K(2);t[V.SCORE2_TRUE]=e.True,t[V.SCORE2_FALSE]=e.False,i.forEach(a=>{t["".concat(u,": ").concat(a)]=e[a]})}else"NUMERIC"===a&&(t[V.SCORE2_NUMERIC]=W(2));return t}({dataType:a.metadata.dataType,mode:a.metadata.mode,score1Name:i.score1.name,score2Name:null==(e=i.score2)?void 0:e.name,score1Source:i.score1.source,score2Source:null==(t=i.score2)?void 0:t.source,categories:a.distribution.categories,score2Categories:a.distribution.score2Categories}):{}},[x.data,i]),g=(0,n.useCallback)(e=>W(e),[]),v=(0,n.useMemo)(()=>({...x,colors:f,params:i,colorMappings:p,getColorForScore:g,estimate:m.data,isEstimating:m.isLoading}),[x,f,i,p,g,m.data,m.isLoading]);return(0,r.jsx)(Z.Provider,{value:v,"data-sentry-element":"ScoreAnalyticsContext.Provider","data-sentry-component":"ScoreAnalyticsProvider","data-sentry-source-file":"ScoreAnalyticsProvider.tsx",children:c})}function X(){let e=(0,n.useContext)(Z);if(!e)throw Error("useScoreAnalytics must be used within a ScoreAnalyticsProvider");return e}var G=a(72459),q=a(37982),$=a(86843),Q=a(41641);function Y(e){let{value:t,onChange:a,options:s,placeholder:o="Select score",filterByDataType:l,disabled:i=!1,className:c}=e,d=(0,n.useMemo)(()=>l?s.filter(e=>Array.isArray(l)?l.includes(e.dataType):e.dataType===l):s,[s,l]),u=(0,n.useMemo)(()=>{let e=d.reduce((e,t)=>(e[t.dataType]||(e[t.dataType]=[]),e[t.dataType].push(t),e),{}),t={BOOLEAN:"Boolean",CATEGORICAL:"Categorical",NUMERIC:"Numeric"};return["BOOLEAN","CATEGORICAL","NUMERIC"].filter(t=>{var a;return(null==(a=e[t])?void 0:a.length)>0}).map(a=>({heading:t[a],options:e[a].map(e=>({value:e.value,label:"".concat(e.name," ⢠").concat(e.source)}))}))},[d]);return(0,r.jsxs)("div",{className:"flex items-center gap-2","data-sentry-component":"ScoreCombobox","data-sentry-source-file":"ScoreCombobox.tsx",children:[(0,r.jsx)(q.G,{value:null!=t?t:"",onValueChange:e=>{a(e)},options:u,placeholder:o,searchPlaceholder:"Search scores...",emptyText:"No scores found.",disabled:i,className:c,"data-sentry-element":"Combobox","data-sentry-source-file":"ScoreCombobox.tsx"}),t&&!i&&(0,r.jsx)($.$,{variant:"ghost",size:"icon",onClick:e=>{e.stopPropagation(),a(void 0)},title:"Clear selection",className:"h-6 w-6 shrink-0",children:(0,r.jsx)(Q.A,{className:"h-3 w-3"})})]})}var J=a(93323);let ee=[{value:"all",label:"All Objects"},{value:"trace",label:"Traces"},{value:"session",label:"Sessions"},{value:"observation",label:"Observations"},{value:"dataset_run",label:"Dataset Runs"}];function et(e){let{value:t,onChange:a,className:s}=e;return(0,r.jsxs)(J.l6,{value:t,onValueChange:a,"data-sentry-element":"Select","data-sentry-component":"ObjectTypeFilter","data-sentry-source-file":"ObjectTypeFilter.tsx",children:[(0,r.jsx)(J.bq,{className:s,"aria-label":"Object type","data-sentry-element":"SelectTrigger","data-sentry-source-file":"ObjectTypeFilter.tsx",children:(0,r.jsx)(J.yv,{placeholder:"Object type","data-sentry-element":"SelectValue","data-sentry-source-file":"ObjectTypeFilter.tsx"})}),(0,r.jsx)(J.gC,{"data-sentry-element":"SelectContent","data-sentry-source-file":"ObjectTypeFilter.tsx",children:ee.map(e=>(0,r.jsx)(J.eb,{value:e.value,children:e.label},e.value))})]})}var ea=a(51278),er=a(67716),es=a(97898);function en(e){let{scoreOptions:t,timeRange:a,onTimeRangeChange:s,compatibleScore2DataTypes:o}=e,l=c(),{state:i,setScore2:d,setObjectType:m}=l,x=(0,n.useCallback)(e=>{l.setScore1(e),void 0===e&&l.setScore2(void 0)},[l]);return(0,r.jsxs)("div",{className:"flex flex-col gap-1 border-b border-border p-2 lg:flex-row lg:items-center lg:gap-4","data-sentry-component":"ScoreAnalyticsHeader","data-sentry-source-file":"ScoreAnalyticsHeader.tsx",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(Y,{value:i.score1,onChange:x,options:t,placeholder:"First score",className:"h-8 w-[200px]","data-sentry-element":"ScoreCombobox","data-sentry-source-file":"ScoreAnalyticsHeader.tsx"}),(0,r.jsx)(Y,{value:i.score2,onChange:d,options:t,placeholder:"Second score",f
1ilterByDataType:o,disabled:!i.score1,className:"h-8 w-[200px]","data-sentry-element":"ScoreCombobox","data-sentry-source-file":"ScoreAnalyticsHeader.tsx"}),(0,r.jsxs)(es.jc,{"data-sentry-element":"HoverCard","data-sentry-source-file":"ScoreAnalyticsHeader.tsx",children:[(0,r.jsx)(es.d0,{asChild:!0,"data-sentry-element":"HoverCardTrigger","data-sentry-source-file":"ScoreAnalyticsHeader.tsx",children:(0,r.jsx)(er.E,{variant:"warning",className:"cursor-help","data-sentry-element":"Badge","data-sentry-source-file":"ScoreAnalyticsHeader.tsx",children:"Beta Feature"})}),(0,r.jsx)(es.Et,{className:"w-80","data-sentry-element":"HoverCardContent","data-sentry-source-file":"ScoreAnalyticsHeader.tsx",children:(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("h4",{className:"text-sm font-semibold",children:"Beta Feature"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"Score analytics is currently in beta. We're actively improving this feature and would love to hear your feedback."}),(0,r.jsxs)("a",{href:"https://langfuse.com/discussions",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm font-medium text-primary hover:underline",children:["Share feedback on GitHub Discussions",(0,r.jsx)(G.A,{className:"h-3 w-3","data-sentry-element":"ExternalLink","data-sentry-source-file":"ScoreAnalyticsHeader.tsx"})]})]})})]})]}),(0,r.jsx)("div",{className:"hidden flex-1 lg:block"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(et,{value:i.objectType,onChange:m,className:"h-8 w-[140px]","data-sentry-element":"ObjectTypeFilter","data-sentry-source-file":"ScoreAnalyticsHeader.tsx"}),(0,r.jsx)(ea.$6,{timeRange:a,onTimeRangeChange:s,timeRangePresets:u.P6,className:"my-0","data-sentry-element":"TimeRangePicker","data-sentry-source-file":"ScoreAnalyticsHeader.tsx"})]})]})}var eo=a(25277),el=a(53524),ei=a(65836),ec=a(36932);function ed(e){let{label:t,value:a,interpretation:s,helpText:n,warning:o,isPlaceholder:l=!1,isContext:i=!1}=e,c="N/A"===a;return(0,r.jsxs)("div",{className:"flex flex-col gap-0.5","data-sentry-component":"MetricCard","data-sentry-source-file":"MetricCard.tsx",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:t}),n&&(0,r.jsx)(el.Bc,{children:(0,r.jsxs)(el.m_,{children:[(0,r.jsx)(el.k$,{asChild:!0,children:(0,r.jsx)(ei.A,{className:"h-3 w-3 text-muted-foreground"})}),(0,r.jsx)(el.ZI,{side:"top",className:"max-w-xs",children:(0,r.jsx)("p",{className:"text-xs",children:n})})]})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[c?(0,r.jsx)("span",{className:"text-sm text-muted-foreground/50",children:"â"}):(0,r.jsx)("p",{className:"text-lg font-semibold",children:l?"--":a}),s&&!l&&!c&&"N/A"!==s.strength&&(0,r.jsx)(el.Bc,{children:(0,r.jsxs)(el.m_,{children:[(0,r.jsx)(el.k$,{asChild:!0,children:(0,r.jsx)(er.E,{variant:(e=>{switch(e){case"green":return"default";case"blue":return"secondary";case"yellow":case"orange":case"gray":default:return"outline";case"red":return"destructive"}})(s.color),className:"px-1.5 py-0 text-[10px] font-normal opacity-70",children:s.strength})}),(0,r.jsx)(el.ZI,{side:"top",className:"max-w-xs",children:(0,r.jsx)("p",{className:"text-xs",children:s.description})})]})}),(null==o?void 0:o.show)&&!l&&!c&&(0,r.jsxs)(es.jc,{children:[(0,r.jsx)(es.d0,{asChild:!0,children:(0,r.jsx)(ec.A,{className:"h-4 w-4 cursor-help text-amber-500"})}),(0,r.jsx)(es.Et,{className:"w-80",children:o.content})]})]})]})}var eu=a(80263);function em(e){var t,a,s,n;let{samplingMetadata:o,mode:l="two",showLabel:i=!1}=e;return(0,r.jsxs)(es.jc,{"data-sentry-element":"HoverCard","data-sentry-component":"SamplingDetailsHoverCard","data-sentry-source-file":"SamplingDetailsHoverCard.tsx",children:[(0,r.jsx)(es.d0,{asChild:!0,"data-sentry-element":"HoverCardTrigger","data-sentry-source-file":"SamplingDetailsHoverCard.tsx",children:(0,r.jsxs)("button",{className:i?"inline-flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground":"inline-flex h-4 w-4 items-center justify-center rounded-full hover:bg-muted-foreground
1/10","aria-label":"View sampling details",children:[i&&(0,r.jsx)("span",{children:"Sampled Data"}),(0,r.jsx)(eu.A,{className:i?"h-3 w-3":"h-3 w-3 text-muted-foreground","data-sentry-element":"Info","data-sentry-source-file":"SamplingDetailsHoverCard.tsx"})]})}),(0,r.jsx)(es.Et,{className:"w-80",align:"start","data-sentry-element":"HoverCardContent","data-sentry-source-file":"SamplingDetailsHoverCard.tsx",children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"mb-2 text-sm font-semibold",children:"single"===l?"Estimated Score Count":"Estimated Scores"}),(0,r.jsx)("dl",{className:"space-y-1 text-sm",children:"single"===l?(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("dt",{className:"text-muted-foreground",children:"Total Scores:"}),(0,r.jsxs)("dd",{className:"font-medium",children:["~",null==(t=o.preflightEstimates)?void 0:t.score1Count.toLocaleString()]})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("dt",{className:"text-muted-foreground",children:"Score 1:"}),(0,r.jsxs)("dd",{className:"font-medium",children:["~",null==(a=o.preflightEstimates)?void 0:a.score1Count.toLocaleString()]})]}),(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("dt",{className:"text-muted-foreground",children:"Score 2:"}),(0,r.jsxs)("dd",{className:"font-medium",children:["~",null==(s=o.preflightEstimates)?void 0:s.score2Count.toLocaleString()]})]}),(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("dt",{className:"text-muted-foreground",children:"Estimated Matches:"}),(0,r.jsxs)("dd",{className:"font-medium",children:["~",null==(n=o.preflightEstimates)?void 0:n.estimatedMatchedCount.toLocaleString()]})]})]})})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"mb-2 text-sm font-semibold",children:"Query Optimizations"}),(0,r.jsxs)("dl",{className:"space-y-1 text-sm",children:[(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("dt",{className:"text-muted-foreground",children:"Sampling:"}),(0,r.jsxs)("dd",{className:"font-medium",children:[(100*o.samplingRate).toFixed(1),"% (hash-based)"]})]}),o.adaptiveFinal&&(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("dt",{className:"text-muted-foreground",children:"Deduplication:"}),(0,r.jsx)("dd",{className:"font-medium",children:o.adaptiveFinal.usedFinal?"Enabled":"Skipped for performance"})]})]})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Hash-based sampling ensures consistent, repeatable results while maintaining statistical accuracy."})]})})]})}function ex(){var e,t,a,s,n,o,l,i,c,d,u;let{data:m,isLoading:h,params:f}=X();if(h)return(0,r.jsxs)(eo.Zp,{children:[(0,r.jsxs)(eo.aR,{children:[(0,r.jsx)(eo.ZB,{children:"Statistics"}),(0,r.jsx)(eo.BT,{children:"Loading statistics..."})]}),(0,r.jsx)(eo.Wu,{className:"flex items-center justify-center py-12",children:(0,r.jsx)(x.A,{className:"h-8 w-8 animate-spin text-muted-foreground"})})]});if(!m)return(0,r.jsxs)(eo.Zp,{children:[(0,r.jsxs)(eo.aR,{children:[(0,r.jsx)(eo.ZB,{children:"Statistics"}),(0,r.jsx)(eo.BT,{children:"No data available"})]}),(0,r.jsx)(eo.Wu,{className:"py-12 text-center text-sm text-muted-foreground",children:"Select a score to view statistics"})]});let{statistics:p,metadata:g}=m,{dataType:v}=g,{score1:y,score2:b}=f,j=p.comparison&&p.comparison.matchedCount>p.score1.total&&p.score2&&p.comparison.matchedCount>p.score2.total,N=p.score1.total>0,C=null!==p.score2,S=null!==p.comparison,w=S&&(null==(e=p.comparison)?void 0:e.confusionMatrix)?function(e){if(!e||0===e.length)return null;let t=e.reduce((e,t)=>e+t.count,0);if(0===t)return null;let a=Array.from(new Set([...e.map(e=>e.rowCategory),...e.map(e=>e.colCategory)])).sort(),r=e.filter(e=>e.rowCategory===e.colCategory).reduce((e,t)=>e+t.count,0)/t,s={},n={};e.forEach(e=>{s[e.rowCategory]=(s[e.rowCategory]||0)+e.count,n[e.colCategory]=(n[e.colCategory]||0)+e.count});let o=a.reduce((e,a)=>e+(s[a]||0)/t*((n[a]||0)/t),0),l=1-o;return 1e-10>
1Math.abs(l)?1===r?1:null:Math.round((r-o)/l*1e3)/1e3}(p.comparison.confusionMatrix):null,M=S&&(null==(t=p.comparison)?void 0:t.confusionMatrix)?function(e){if(!e||0===e.length)return null;let t=e.reduce((e,t)=>e+t.count,0);return 0===t?null:Math.round(1e3*(Array.from(new Set(e.flatMap(e=>[e.rowCategory,e.colCategory]))).sort().map(t=>{var a;let r=(null==(a=e.find(e=>e.rowCategory===t&&e.colCategory===t))?void 0:a.count)||0,s=e.filter(e=>e.colCategory===t&&e.rowCategory!==t).reduce((e,t)=>e+t.count,0),n=e.filter(e=>e.rowCategory===t&&e.colCategory!==t).reduce((e,t)=>e+t.count,0),o=r+s>0?r/(r+s):0,l=r+n>0?r/(r+n):0;return{f1:o+l>0?2*o*l/(o+l):0,support:r+n}}).reduce((e,t)=>{let{f1:a,support:r}=t;return e+a*r},0)/t))/1e3}(p.comparison.confusionMatrix):null,T=S&&(null==(a=p.comparison)?void 0:a.confusionMatrix)?function(e){if(!e||0===e.length)return null;let t=e.reduce((e,t)=>e+t.count,0);return 0===t?null:Math.round(e.filter(e=>e.rowCategory===e.colCategory).reduce((e,t)=>e+t.count,0)/t*1e3)/1e3}(p.comparison.confusionMatrix):null;return(0,r.jsxs)(eo.Zp,{"data-sentry-element":"Card","data-sentry-component":"StatisticsCard","data-sentry-source-file":"StatisticsCard.tsx",children:[(0,r.jsxs)(eo.aR,{"data-sentry-element":"CardHeader","data-sentry-source-file":"StatisticsCard.tsx",children:[(0,r.jsxs)(eo.ZB,{className:"flex items-center gap-2","data-sentry-element":"CardTitle","data-sentry-source-file":"StatisticsCard.tsx",children:["Statistics",m.samplingMetadata.isSampled&&(0,r.jsx)(em,{samplingMetadata:m.samplingMetadata,mode:m.metadata.mode,showLabel:!0})]}),(0,r.jsx)(eo.BT,{"data-sentry-element":"CardDescription","data-sentry-source-file":"StatisticsCard.tsx",children:b?"".concat(y.name," vs ").concat(b.name):"".concat(y.name," - Select a second score for comparison")})]}),(0,r.jsxs)(eo.Wu,{className:"space-y-4","data-sentry-element":"CardContent","data-sentry-source-file":"StatisticsCard.tsx",children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("h4",{className:"mb-2 text-xs font-semibold",children:[y.name," (",y.source,")"]}),"NUMERIC"===v?(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[(0,r.jsx)(ed,{label:"Total",value:N?p.score1.total.toLocaleString():"--",helpText:"Total number of ".concat(y.name," scores"),isPlaceholder:!N,isContext:!0}),(0,r.jsx)(ed,{label:"Mean",value:N&&null!==p.score1.mean?p.score1.mean.toFixed(2):N?"N/A":"--",helpText:"Average value for ".concat(y.name),isPlaceholder:!N,isContext:!0}),(0,r.jsx)(ed,{label:"Std Dev",value:N&&null!==p.score1.std?p.score1.std.toFixed(2):N?"N/A":"--",helpText:"Standard deviation for ".concat(y.name),isPlaceholder:!N,isContext:!0})]}):(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[(0,r.jsx)(ed,{label:"Total",value:N?p.score1.total.toLocaleString():"--",helpText:"Total number of ".concat(y.name," scores"),isPlaceholder:!N,isContext:!0}),(0,r.jsx)(ed,{label:"Mode",value:N&&p.score1.mode?"".concat(p.score1.mode.category," (").concat(p.score1.mode.count.toLocaleString(),")"):N?"N/A":"--",helpText:"Most frequent category and its count",isPlaceholder:!N,isContext:!0}),(0,r.jsx)(ed,{label:"Mode %",value:N&&null!==p.score1.modePercentage?"".concat(p.score1.modePercentage.toFixed(1),"%"):N?"N/A":"--",helpText:"Percentage of observations with the most frequent category",isPlaceholder:!N,isContext:!0})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("h4",{className:"mb-2 text-xs font-semibold",children:[null!=(n=null==b?void 0:b.name)?n:"Score 2",(null==b?void 0:b.source)?" (".concat(b.source,")"):""]}),"NUMERIC"===v?(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[(0,r.jsx)(ed,{label:"Total",value:C&&p.score2?p.score2.total.toLocaleString():"--",helpText:"Total number of ".concat(null!=(o=null==b?void 0:b.name)?o:"Score 2"," scores"),isPlaceholder:!C,isContext:!0}),(0,r.jsx)(ed,{label:"Mean",value:C&&p.score2&&null!==p.score2.mean?p.score2.mean.toFixed(2):C?"N/A":"--",helpText:"Average value for ".concat(null!=(l=null==b?void 0:b.name)?l:"Score 2"),isPlaceholder:!C,isContext:!0}),(0,r.jsx)(ed,{label:"Std Dev",value:C&&p.score2&&null!==p.score2.std?p.score2.std.toFixed(2):C?"N/A":"--",helpText:"Standard deviation for ".concat(null!=(i=null==b?void 0:b.name)?i:"Score 2"),isPlaceholder:!C,isContext:!0})]}):(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[(0,r.jsx)(ed,{label:"Total",value:C&&p.score2?p.score2.total.toLocaleStr
1ing():"--",helpText:"Total number of ".concat(null!=(c=null==b?void 0:b.name)?c:"Score 2"," scores"),isPlaceholder:!C,isContext:!0}),(0,r.jsx)(ed,{label:"Mode",value:C&&(null==(s=p.score2)?void 0:s.mode)?"".concat(p.score2.mode.category," (").concat(p.score2.mode.count.toLocaleString(),")"):C?"N/A":"--",helpText:"Most frequent category and its count",isPlaceholder:!C,isContext:!0}),(0,r.jsx)(ed,{label:"Mode %",value:C&&p.score2&&null!==p.score2.modePercentage?"".concat(p.score2.modePercentage.toFixed(1),"%"):C?"N/A":"--",helpText:"Percentage of observations with the most frequent category",isPlaceholder:!C,isContext:!0})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"mb-2 text-xs font-semibold",children:"Comparison"}),"NUMERIC"===v?(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[(0,r.jsx)(ed,{label:"Matched",value:S&&p.comparison?p.comparison.matchedCount.toLocaleString():"--",helpText:"Number of observations with both scores",warning:j?{show:!0,content:(0,r.jsxs)("div",{className:"space-y-2 text-xs",children:[(0,r.jsx)("p",{className:"font-semibold",children:"Matched count exceeds individual score counts due to Cartesian product"}),(0,r.jsx)("p",{children:"This occurs when multiple scores of the same name/source exist on a single attachment point (trace/observation/session/run). Each combination creates a match."}),(0,r.jsxs)("p",{className:"text-muted-foreground",children:[(0,r.jsx)("strong",{children:"Example:"}),' If one trace has 2 "gpt4" scores and 3 "gemini" scores, this creates 6 matched pairs (2 \xd7 3 = 6).']})]})}:void 0,isContext:!0,isPlaceholder:!S}),(0,r.jsx)(ed,{label:"Pearson r",value:S&&p.comparison&&null!==p.comparison.pearsonCorrelation?p.comparison.pearsonCorrelation.toFixed(3):S?"N/A":"--",interpretation:S&&p.comparison&&null!==p.comparison.pearsonCorrelation?function(e){if(null===e)return{strength:"N/A",color:"gray",description:"No data available"};let t=Math.abs(e),a=e>0?"positive":e<0?"negative":"no";return t>=.9?{strength:"Very Strong",color:"green",description:"Very strong ".concat(a," linear correlation")}:t>=.7?{strength:"Strong",color:"blue",description:"Strong ".concat(a," linear correlation")}:t>=.5?{strength:"Moderate",color:"yellow",description:"Moderate ".concat(a," linear correlation")}:t>=.3?{strength:"Weak",color:"orange",description:"Weak ".concat(a," linear correlation")}:{strength:"Very Weak",color:"red",description:"Very weak or no linear correlation"}}(p.comparison.pearsonCorrelation):void 0,helpText:"Linear correlation (-1 to 1)",isPlaceholder:!S}),(0,r.jsx)(ed,{label:"Spearman Ï",value:S&&p.comparison&&null!==p.comparison.spearmanCorrelation?p.comparison.spearmanCorrelation.toFixed(3):S?"N/A":"--",interpretation:S&&p.comparison&&null!==p.comparison.spearmanCorrelation?function(e){if(null===e)return{strength:"N/A",color:"gray",description:"No data available"};let t=Math.abs(e),a=e>0?"positive":e<0?"negative":"no";return t>=.9?{strength:"Very Strong",color:"green",description:"Very strong ".concat(a," monotonic relationship")}:t>=.7?{strength:"Strong",color:"blue",description:"Strong ".concat(a," monotonic relationship")}:t>=.5?{strength:"Moderate",color:"yellow",description:"Moderate ".concat(a," monotonic relationship")}:t>=.3?{strength:"Weak",color:"orange",description:"Weak ".concat(a," monotonic relationship")}:{strength:"Very Weak",color:"red",description:"Very weak or no monotonic relationship"}}(p.comparison.spearmanCorrelation):void 0,helpText:"Rank correlation (-1 to 1)",isPlaceholder:!S})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[(0,r.jsx)("div",{}),(0,r.jsx)(ed,{label:"MAE",value:S&&p.comparison&&null!==p.comparison.mae?p.comparison.mae.toFixed(3):S?"N/A":"--",interpretation:S&&p.comparison&&null!==p.comparison.mae?null===(d=p.comparison.mae)?{strength:"N/A",color:"gray",description:"No data available"}:{strength:"N/A",color:"gray",description:"Average error: ".concat(d.toFixed(3))}:void 0,helpText:"Mean Absolute Error",isPlaceholder:!S}),(0,r.jsx)(ed,{label:"RMSE",value:S&&p.comparison&&null!==p.comparison.rmse?p.comparison.rmse.toFixed(3):S?"N/A":"--",interpretation:S&&p.comparison&&null!==p.comparison.rmse?null===(u=p.comparison.rmse)?{strength:"N/A",color:"gray",de
1scription:"No data available"}:{strength:"N/A",color:"gray",description:"Root mean squared error: ".concat(u.toFixed(3))}:void 0,helpText:"Root Mean Square Error",isPlaceholder:!S})]})]}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[(0,r.jsx)(ed,{label:"Matched",value:S&&p.comparison?p.comparison.matchedCount.toLocaleString():"--",helpText:"Number of observations with both scores",warning:j?{show:!0,content:(0,r.jsxs)("div",{className:"space-y-2 text-xs",children:[(0,r.jsx)("p",{className:"font-semibold",children:"Matched count exceeds individual score counts due to Cartesian product"}),(0,r.jsx)("p",{children:"This occurs when multiple scores of the same name/source exist on a single attachment point (trace/observation/session/run). Each combination creates a match."}),(0,r.jsxs)("p",{className:"text-muted-foreground",children:[(0,r.jsx)("strong",{children:"Example:"}),' If one trace has 2 "gpt4" scores and 3 "gemini" scores, this creates 6 matched pairs (2 \xd7 3 = 6).']})]})}:void 0,isContext:!0,isPlaceholder:!S}),(0,r.jsx)(ed,{label:"Agreement",value:S&&null!==T?"".concat((100*T).toFixed(1),"%"):S?"N/A":"--",interpretation:S&&null!==T?function(e){if(null===e)return{strength:"N/A",color:"gray",description:"No data available"};let t=Math.round(100*e);return e>=.9?{strength:"Excellent",color:"green",description:"".concat(t,"% of predictions match")}:e>=.8?{strength:"Good",color:"blue",description:"".concat(t,"% of predictions match")}:e>=.6?{strength:"Fair",color:"yellow",description:"".concat(t,"% of predictions match")}:e>=.4?{strength:"Poor",color:"orange",description:"".concat(t,"% of predictions match")}:{strength:"Very Poor",color:"red",description:"".concat(t,"% of predictions match")}}(T):void 0,helpText:"Overall agreement percentage",isPlaceholder:!S})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[(0,r.jsx)("div",{}),(0,r.jsx)(ed,{label:"Cohen's κ",value:S&&null!==w?w.toFixed(3):S?"N/A":"--",interpretation:S&&null!==w?null===w?{strength:"N/A",color:"gray",description:"No data available"}:w>=1?{strength:"Perfect",color:"green",description:"perfect agreement between scores"}:w>=.81?{strength:"Almost Perfect",color:"green",description:"Almost perfect agreement between scores"}:w>=.61?{strength:"Substantial",color:"blue",description:"Substantial agreement between scores"}:w>=.41?{strength:"Moderate",color:"yellow",description:"Moderate agreement between scores"}:w>=.21?{strength:"Fair",color:"orange",description:"Fair agreement between scores"}:w>0?{strength:"Slight",color:"red",description:"Slight agreement between scores"}:{strength:"Poor",color:"red",description:"Poor agreement (worse than chance)"}:void 0,helpText:"Inter-rater reliability (-1 to 1)",isPlaceholder:!S}),(0,r.jsx)(ed,{label:"F1 Score",value:S&&null!==M?M.toFixed(3):S?"N/A":"--",interpretation:S&&null!==M?null===M?{strength:"N/A",color:"gray",description:"No data available"}:M>=.9?{strength:"Excellent",color:"green",description:"Excellent classification performance"}:M>=.8?{strength:"Good",color:"blue",description:"Good classification performance"}:M>=.6?{strength:"Fair",color:"yellow",description:"Fair classification performance"}:M>=.4?{strength:"Poor",color:"orange",description:"Poor classification performance"}:{strength:"Very Poor",color:"red",description:"Very poor classification performance"}:void 0,helpText:"Weighted F1 score (0 to 1)",isPlaceholder:!S})]})]})]})]})]})}var eh=a(90859),ef=a(91819),ep=a(97042),eg=a(23053),ev=a(84051),ey=a(79695),eb=a(16301),ej=a(67005),eN=a(68780);function eC(e,t,a){let r=(0,u.lT)(t,a);return(0,eN.GP)(e,r)}var eS=a(81509);function ew(e){let t,{active:a,payload:s,label:n,interval:o,timeRange:l,valueFormatter:i=e=>e.toString(),labelFormatter:c}=e,{config:d}=(0,eb.uy)();if(!a||!s||0===s.length)return null;let m=Array.from(new Map(s.map(e=>{var t;return[null!=(t=e.name)?t:e.dataKey,e]})).values()),x=Object.keys(d),h=m.sort((e,t)=>{var a,r,s,n,o,l;let i=null!=(r=null!=(a=e.name)?a:e.dataKey)?r:"",c=null!=(n=null!=(s=t.name)?s:t.dataKey)?n:"",d=x.indexOf(i),u=x.indexOf(c);return -1!==d&&-1!==u?u-d:(null!=(o=Number(t.value))?o:0)-(null!=(l=Number(e.value))?l:0)});
1return t=c?c(null!=n?n:""):"string"==typeof n?n:o&&l&&n?function(e,t,a){let r=(0,u.tp)(t,a);return(0,eN.GP)(e,r)}(new Date(n),o,l):String(null!=n?n:""),(0,r.jsxs)("div",{className:"rounded-md border border-border bg-background opacity-100 shadow-lg","data-sentry-component":"ScoreChartTooltip","data-sentry-source-file":"ScoreChartTooltip.tsx",children:[(0,r.jsx)("div",{className:(0,eS.cn)("border-b border-border px-3 py-1.5"),children:(0,r.jsx)("p",{className:(0,eS.cn)("text-sm font-medium text-muted-foreground"),children:t})}),(0,r.jsx)("div",{className:(0,eS.cn)("space-y-1 px-3 py-1.5"),children:h.map((e,t)=>{var a,s,n,o;let l=e.name||e.dataKey||"",c=(null==(a=d[l])?void 0:a.label)||l;return(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"h-3 w-3 flex-shrink-0 rounded-sm",style:{backgroundColor:null!=(s=e.color)?s:"hsl(var(--primary))"}}),(0,r.jsx)("span",{className:"flex-1 text-sm text-muted-foreground",children:null!=(n=null==c?void 0:c.toString())?n:""}),(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:i(Number(null!=(o=e.value)?o:0))})]},"".concat(t,"-").concat(e.name))})})]})}var eM=a(88997),eT=a(97638);let ek=e=>{let{color:t,label:a,visible:s,interactive:n,onClick:o,noTruncate:l=!1}=e;return(0,r.jsxs)("button",{type:"button",onClick:o,disabled:!n,"aria-pressed":s,"aria-label":"".concat(s?"Hide":"Show"," ").concat(a),className:(0,eS.cn)("flex items-center gap-1.5 text-sm transition-opacity",n&&"cursor-pointer hover:opacity-80",!n&&"cursor-default",!s&&"opacity-50"),"data-sentry-component":"LegendItem","data-sentry-source-file":"ScoreChartLegendContent.tsx",children:[(0,r.jsx)("div",{className:(0,eS.cn)("h-2 w-2 shrink-0 rounded-full",s?"bg-current":"border-2 border-current bg-transparent"),style:{color:t,...s?{backgroundColor:t}:{borderColor:t,backgroundColor:"transparent"}}}),(0,r.jsx)("span",{className:(0,eS.cn)("text-muted-foreground",!l&&"max-w-[120px] truncate",!s&&"line-through"),children:a})]})},eL=n.forwardRef((e,t)=>{let{payload:a,interactive:s=!1,visibilityState:o,onVisibilityChange:l,formatLabel:i,verticalAlign:c="bottom",className:d,nameKey:u}=e,{config:m}=(0,eb.uy)(),x=(0,n.useRef)(null),h=(0,n.useRef)(null),[f,p]=(0,n.useState)(!1),[g,v]=(0,n.useState)(!1),[y,b]=(0,n.useState)(140),[j,N]=(0,n.useState)(null);(0,n.useLayoutEffect)(()=>{if(h.current){let e=h.current.offsetWidth;e>0&&b(e)}},[]),(0,n.useLayoutEffect)(()=>{if(!x.current||!a||0===a.length){v(!1),N(null);return}let e=x.current,t=!1,r=0,s=0,n=()=>{if(!e||t)return;let n=e.clientWidth,o=e.scrollHeight;if(10>Math.abs(n-r)&&10>Math.abs(o-s))return;t=!0,r=n,s=o;let l=e.scrollHeight;if(!(l>2*parseInt(window.getComputedStyle(e).lineHeight||"24")+6)){v(e=>!1===e&&e),N(e=>null!==e?null:e),t=!1;return}v(e=>!0!==e||e);let i=e.clientWidth,c=y+12,d=Array.from(e.querySelectorAll("button[aria-pressed]"));if(0===d.length){let e=Math.max(6,Math.floor(.7*a.length));N(t=>t!==e?e:t),t=!1;return}let u=0,m=0;for(let e=0;e<d.length;e++){let t=d[e].offsetWidth,a=0===e?t:t+12;if(u+a<=i)u+=a,m++;else break}let x=i-c,h=0,f=0;for(let e=m;e<d.length;e++){let t=d[e].offsetWidth,a=e===m?t:t+12;if(h+a<=x)h+=a,f++;else break}let p=Math.max(5,m+f-1);N(e=>null===e||Math.abs(e-p)>1?p:e),t=!1},o=setTimeout(()=>{n()},0),l=new ResizeObserver(()=>{requestAnimationFrame(()=>{n()})});return l.observe(e),()=>{clearTimeout(o),l.disconnect()}},[a,y]);let C=e=>{var t;if(!s||!l)return;let a=null==(t=null==o?void 0:o[e])||t;l(e,!a)},S=(0,n.useMemo)(()=>{if(!a||0===a.length)return{};let e={};return a.forEach(t=>{let a="".concat(u||t.dataKey||"value"),r="Categories";if(a.includes("-")){let e=a.split("-")[0];e&&(r=e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())}e[r]||(e[r]=[]),e[r].push(t)}),e},[a,u]);if(!a||0===a.length)return null;let w=g?null!=j?j:Math.max(6,Math.floor(.7*a.length)):a.length,M=a.slice(0,w),T=a.length-M.length,k=e=>{let t="".concat(u||e.dataKey||"value"),a=(0,eb.X1)(m,e,t);if(null==a?void 0:a.label)return String(a.label);let r=e.value||t;return"__unmatched__"===r||"unmatched"===r?"Unmatched":i?String(i(r,e)):(e=>{if(!e||"string"!=typeof e)return String(e);if(e.includes("-")){let t=e.split("-").pop();if(t)return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}return e.includes("_")?e.split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" "):/[a-z][A-Z]/.test(e)?e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()})(String(r))};return(0,r.jsx)("div",{ref:t,className:(0,eS.cn)("flex min-h-[48px] items-center justify-center gap-2","top"===c?"pb-3":"pt-3",d),children:(0,r.jsxs)("div",{ref:x,className:"flex max-h-[48px] flex-1 flex-wrap items-center justify-center gap-x-3 gap-y-1 overflow-hidden",children:[M.map(e=>{var t;let a="".concat(u||e.dataKey||"value"),n=null==(t=null==o?void 0:o[a])||t,l=e.color||("object"==typeof e.payload&&e.payload&&"fill"in e.payload?e.payload.fill:"hsl(var(--chart-1))");return(0,r.jsx)(ek,{color:l,label:k(e),visible:n,interactive:s,onClick:()=>C(a)},a)}),g&&(0,r.jsxs)(eT.AM,{open:f,onOpenChange:p,children:[(0,r.jsx)(eT.Wv,{asChild:!0,children:(0,r.jsxs)($.$,{ref:h,variant:"ghost",size:"sm",className:"h-6 shrink-0 gap-1 px-2 text-xs text-muted-foreground hover:bg-accent","aria-label":"Show all ".concat(a.length," categories"),children:[(0,r.jsxs)("span",{children:["Show all ",a.length]}),T>0&&(0,r.jsxs)("span",{className:"font-medium",children:["(+",T,")"]}),(0,r.jsx)(eM.A,{className:"h-3 w-3"})]})}),(0,r.jsx)(eT.hl,{className:"w-80",align:"end",side:"top"===c?"bottom":"top",children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("p",{className:"text-sm font-medium",children:"All Categories"}),(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[a.length," total"]})]}),(0,r.jsx)("div",{className:"space-y-3",children:Object.entries(S).map((e,t)=>{let[a,n]=e;return(0,r.jsxs)("div",{children:[Object.keys(S).length>1&&(0,r.jsx)("h4",{className:"mb-2 text-xs font-medium text-muted-foreground",children:a}),(0,r.jsx)("div",{className:"space-y-1",children:n.map(e=>{var t;let a="".concat(u||e.dataKey||"value"),n=null==(t=null==o?void 0:o[a])||t,l=e.color||("object"==typeof e.payload&&e.payload&&"fill"in e.payload?e.payload.fill:"hsl(var(--chart-1))");return(0,r.jsx)("div",{className:"rounded-sm px-2 py-1.5 hover:bg-accent/50",children:(0,r.jsx)(ek,{color:l,label:k(e),visible:n,interactive:s,onClick:()=>C(a),noTruncate:!0})},a)})})]},a)})})]})})]})]})})});function eA(e){let{data:t,score1Name:a,score2Name:s,interval:o,timeRange:l,colors:i}=e,c=!!s,d=(0,n.useMemo)(()=>t.map(e=>{let t=eC(e.timestamp,o,l);return c?{time_dimension:t,[a]:e.avg1,[s]:e.avg2}:{time_dimension:t,[a]:e.avg1}}
1),[t,a,s,o,l,c]),[u,m]=(0,n.useState)(new Set),x=(0,n.useMemo)(()=>{if(c)return{[a]:!u.has(a),...s&&{[s]:!u.has(s)}}},[u,a,s,c]),h=(0,n.useCallback)((e,t)=>{m(a=>{let r=new Set(a);return t?r.delete(e):r.add(e),r})},[]),f=(0,n.useMemo)(()=>c&&s?{[a]:{label:a,color:i.score1},[s]:{label:s,color:i.score2}}:{[a]:{label:a,color:i.score1}},[a,s,c,i]);return 0===d.length?(0,r.jsx)("div",{className:"flex h-[200px] items-center justify-center text-sm text-muted-foreground",children:"No time series data available"}):d.some(e=>c?null!==e[a]||null!==e[s]:null!==e[a])?(0,r.jsx)(eb.at,{config:f,"data-sentry-element":"ChartContainer","data-sentry-component":"ScoreTimeSeriesNumericChart","data-sentry-source-file":"ScoreTimeSeriesNumericChart.tsx",children:(0,r.jsxs)(ef.b,{accessibilityLayer:!0,data:d,"data-sentry-element":"LineChart","data-sentry-source-file":"ScoreTimeSeriesNumericChart.tsx",children:[(0,r.jsx)(ep.W,{dataKey:"time_dimension",stroke:"hsl(var(--chart-grid))",fontSize:12,tickLine:!1,axisLine:{stroke:"hsl(var(--border) / 0.5)"},interval:1,"data-sentry-element":"XAxis","data-sentry-source-file":"ScoreTimeSeriesNumericChart.tsx"}),(0,r.jsx)(eg.h,{stroke:"hsl(var(--chart-grid))",fontSize:12,tickLine:!1,axisLine:!1,tickFormatter:e=>(0,ej.zo)(e),"data-sentry-element":"YAxis","data-sentry-source-file":"ScoreTimeSeriesNumericChart.tsx"}),(0,r.jsx)(ev.N,{type:"monotone",dataKey:a,stroke:i.score1,strokeWidth:2,strokeOpacity:+!u.has(a),dot:!u.has(a),activeDot:!u.has(a)&&{r:6,strokeWidth:0},connectNulls:!0,"data-sentry-element":"Line","data-sentry-source-file":"ScoreTimeSeriesNumericChart.tsx"}),c&&s&&(0,r.jsx)(ev.N,{type:"monotone",dataKey:s,stroke:i.score2,strokeWidth:2,strokeOpacity:+!u.has(s),dot:!u.has(s),activeDot:!u.has(s)&&{r:6,strokeWidth:0},connectNulls:!0}),(0,r.jsx)(eb.II,{content:(0,r.jsx)(ew,{interval:o,timeRange:l,valueFormatter:ej.zo}),"data-sentry-element":"ChartTooltip","data-sentry-source-file":"ScoreTimeSeriesNumericChart.tsx"}),(0,r.jsx)(ey.s,{content:(0,r.jsx)(eL,{interactive:c,visibilityState:x,onVisibilityChange:h}),"data-sentry-element":"Legend","data-sentry-source-file":"ScoreTimeSeriesNumericChart.tsx"})]})}):(0,r.jsx)("div",{className:"flex h-[200px] items-center justify-center text-sm text-muted-foreground",children:"No data points available for the selected time range"})}function e_(e){let{data:t,score1Name:a,score2Name:s,interval:o,timeRange:l,colors:i}=e,{chartData:c,categories:d}=(0,n.useMemo)(()=>{let e=new Map,a=new Set;return t.forEach(t=>{let r=t.timestamp.getTime();e.has(r)||e.set(r,new Map),e.get(r).set(t.category,t.count),a.add(t.category)}),{chartData:Array.from(e.entries()).sort((e,t)=>{let[a]=e,[r]=t;return a-r}).map(e=>{let[t,r]=e,s={time_dimension:eC(new Date(t),o,l)};return a.forEach(e=>{var t;s[e]=null!=(t=r.get(e))?t:0}),s}),categories:Array.from(a).sort()}},[t,o,l]),[u,m]=(0,n.useState)(new Set),x=(0,n.useMemo)(()=>{let e={};return d.forEach(t=>{e[t]=!u.has(t)}),e},[u,d]),h=(0,n.useCallback)((e,t)=>{m(a=>{let r=new Set(a);return t?r.delete(e):r.add(e),r})},[]),f=(0,n.useMemo)(()=>{let e={};return d.forEach(t=>{e[t]={label:t,color:i[t]||Object.values(i)[0]}}),e},[d,i]);return 0===c.length||0===d.length?(0,r.jsx)("div",{className:"flex h-[200px] items-center justify-center text-sm text-muted-foreground",children:"No time series data available"}):c.some(e=>d.some(t=>e[t]>0))?(0,r.jsx)(eb.at,{config:f,"data-sentry-element":"ChartContainer","data-sentry-component":"ScoreTimeSeriesBooleanChart","data-sentry-source-file":"ScoreTimeSeriesBooleanChart.tsx",children:(0,r.jsxs)(ef.b,{accessibilityLayer:!0,data:c,"data-sentry-element":"LineChart","data-sentry-source-file":"ScoreTimeSeriesBooleanChart.tsx",children:[(0,r.jsx)(ep.W,{dataKey:"time_dimension",stroke:"hsl(var(--chart-grid))",fontSize:12,tickLine:!1,axisLine:{stroke:"hsl(var(--border) / 0.5)"},interval:1,"data-sentry-element":"XAxis","data-sentry-source-file":"ScoreTimeSeriesBooleanChart.tsx"}),(0,r.jsx)(eg.h,{stroke:"hsl(var(--chart-grid))",fontSize:12,tickLine:!1,axisLine:!1,label:{value:"Count",angle:-90,position:"insideLeft"},tickFormatter:e=>
1e.toLocaleString(),"data-sentry-element":"YAxis","data-sentry-source-file":"ScoreTimeSeriesBooleanChart.tsx"}),d.map(e=>{var t;let a=u.has(e);return(0,r.jsx)(ev.N,{type:"monotone",dataKey:e,stroke:null==(t=f[e])?void 0:t.color,strokeWidth:2,strokeOpacity:+!a,dot:!a,activeDot:!a&&{r:6,strokeWidth:0},connectNulls:!0},e)}),(0,r.jsx)(eb.II,{content:(0,r.jsx)(ew,{interval:o,timeRange:l,valueFormatter:e=>e.toLocaleString()}),"data-sentry-element":"ChartTooltip","data-sentry-source-file":"ScoreTimeSeriesBooleanChart.tsx"}),(0,r.jsx)(ey.s,{content:(0,r.jsx)(eL,{interactive:!0,visibilityState:x,onVisibilityChange:h}),"data-sentry-element":"Legend","data-sentry-source-file":"ScoreTimeSeriesBooleanChart.tsx"})]})}):(0,r.jsx)("div",{className:"flex h-[200px] items-center justify-center text-sm text-muted-foreground",children:"No data points available for the selected time range"})}function eE(e){let{data:t,score1Name:a,score2Name:s,interval:o,timeRange:l,colors:i}=e,{chartData:c,categories:d}=(0,n.useMemo)(()=>{let e=new Map,a=new Set;return t.forEach(t=>{let r=t.timestamp.getTime();e.has(r)||e.set(r,new Map),e.get(r).set(t.category,t.count),a.add(t.category)}),{chartData:Array.from(e.entries()).sort((e,t)=>{let[a]=e,[r]=t;return a-r}).map(e=>{let[t,r]=e,s={time_dimension:eC(new Date(t),o,l)};return a.forEach(e=>{var t;s[e]=null!=(t=r.get(e))?t:0}),s}),categories:Array.from(a).sort()}},[t,o,l]),[u,m]=(0,n.useState)(new Set),x=(0,n.useMemo)(()=>{let e={};return d.forEach(t=>{e[t]=!u.has(t)}),e},[u,d]),h=(0,n.useCallback)((e,t)=>{m(a=>{let r=new Set(a);return t?r.delete(e):r.add(e),r})},[]),f=(0,n.useMemo)(()=>{let e={};return d.forEach(t=>{e[t]={label:t,color:i[t]||Object.values(i)[0]}}),e},[d,i]);return 0===c.length||0===d.length?(0,r.jsx)("div",{className:"flex h-[200px] items-center justify-center text-sm text-muted-foreground",children:"No time series data available"}):c.some(e=>d.some(t=>e[t]>0))?(0,r.jsx)(eb.at,{config:f,"data-sentry-element":"ChartContainer","data-sentry-component":"ScoreTimeSeriesCategoricalChart","data-sentry-source-file":"ScoreTimeSeriesCategoricalChart.tsx",children:(0,r.jsxs)(ef.b,{accessibilityLayer:!0,data:c,"data-sentry-element":"LineChart","data-sentry-source-file":"ScoreTimeSeriesCategoricalChart.tsx",children:[(0,r.jsx)(ep.W,{dataKey:"time_dimension",stroke:"hsl(var(--chart-grid))",fontSize:12,tickLine:!1,axisLine:{stroke:"hsl(var(--border) / 0.5)"},interval:1,"data-sentry-element":"XAxis","data-sentry-source-file":"ScoreTimeSeriesCategoricalChart.tsx"}),(0,r.jsx)(eg.h,{stroke:"hsl(var(--chart-grid))",fontSize:12,tickLine:!1,axisLine:!1,label:{value:"Count",angle:-90,position:"insideLeft"},tickFormatter:e=>e.toLocaleString(),"data-sentry-element":"YAxis","data-sentry-source-file":"ScoreTimeSeriesCategoricalChart.tsx"}),d.map(e=>{var t;let a=u.has(e);return(0,r.jsx)(ev.N,{type:"monotone",dataKey:e,stroke:null==(t=f[e])?void 0:t.color,strokeWidth:2,strokeOpacity:+!a,dot:!a,activeDot:!a&&{r:6,strokeWidth:0},connectNulls:!0},e)}),(0,r.jsx)(eb.II,{content:(0,r.jsx)(ew,{interval:o,timeRange:l,valueFormatter:e=>e.toLocaleString()}),"data-sentry-element":"ChartTooltip","data-sentry-source-file":"ScoreTimeSeriesCategoricalChart.tsx"}),(0,r.jsx)(ey.s,{content:(0,r.jsx)(eL,{interactive:!0,visibilityState:x,onVisibilityChange:h}),"data-sentry-element":"Legend","data-sentry-source-file":"ScoreTimeSeriesCategoricalChart.tsx"})]})}):(0,r.jsx)("div",{className:"flex h-[200px] items-center justify-center text-sm text-muted-foreground",children:"No data points available for the selected time range"})}function eD(e){let{data:t,dataType:a,score1Name:s,score2Name:n,interval:o,timeRange:l,colors:i}=e;switch(a){case"NUMERIC":return(0,r.jsx)(eA,{data:t,score1Name:s,score2Name:n,interval:o,timeRange:l,colors:i});case"BOOLEAN":return(0,r.jsx)(e_,{data:t,score1Name:s,score2Name:n,interval:o,timeRange:l,colors:i});case"CATEGORICAL":return(0,r.jsx)(eE,{data:t,score1Name:s,score2Name:n,interval:o,timeRange:l,colors:i})}}function eI(){let{data:e,isLoading:t,params:a,colorMappings:s,getColorForScore:o}=X(),[l,i]=(0,n.useState)("all"),c=(0,n.useMemo)(()=>
1{if(!e||"NUMERIC"!==e.metadata.dataType)return null;let t=e.timeSeries.numeric.all;if(0===t.length)return 0;let a=t.map(e=>e.avg1).filter(e=>null!==e);return 0===a.length?0:a.reduce((e,t)=>e+t,0)/a.length},[e]),d=(0,n.useMemo)(()=>{if(!e)return[];let{timeSeries:t,metadata:a}=e,{dataType:r}=a;if("NUMERIC"!==r)return"score1"===l?t.categorical.score1:"score2"===l?t.categorical.score2:"all"===l?t.categorical.all:t.categorical.allMatched;let s="matched"===l?t.numeric.matched:t.numeric.all;return"score1"===l?s.map(e=>({timestamp:e.timestamp,avg1:e.avg1,avg2:null,count:e.count})):"score2"===l?s.map(e=>({timestamp:e.timestamp,avg1:e.avg2,avg2:null,count:e.count})):s},[e,l]),u=(0,n.useMemo)(()=>{if(!e)return s;let{dataType:t}=e.metadata;if("NUMERIC"===t)return"score1"===l?{score1:o(1)}:"score2"===l?{score1:o(2)}:{score1:o(1),score2:o(2)};if("CATEGORICAL"===t||"BOOLEAN"===t){if("score1"===l&&e.distribution.categories)return"CATEGORICAL"===t?H(1,e.distribution.categories):K(1);if("score2"===l&&e.distribution.score2Categories)return"CATEGORICAL"===t?H(2,e.distribution.score2Categories):K(2)}return s},[l,e,s,o]),m=(0,n.useMemo)(()=>{if(!e)return"";let{metadata:t,statistics:r}=e,{mode:s,dataType:n}=t,{interval:o}=a,i=[];return i.push("".concat("NUMERIC"===n?"Average":"Count"," by ").concat(o.count," ").concat(o.unit).concat(o.count>1?"s":"")),"NUMERIC"===n&&null!==c&&c>0&&i.push("Overall avg: ".concat(c.toFixed(3))),"two"===s&&r.comparison&&"matched"===l&&i.push("".concat(r.comparison.matchedCount.toLocaleString()," matched")),i.join(" | ")},[e,c,l,a]);if(t)return(0,r.jsxs)(eo.Zp,{children:[(0,r.jsxs)(eo.aR,{children:[(0,r.jsx)(eo.ZB,{children:"Trend Over Time"}),(0,r.jsx)(eo.BT,{children:"Loading chart..."})]}),(0,r.jsx)(eo.Wu,{className:"flex h-[340px] grow items-center justify-center",children:(0,r.jsx)(x.A,{className:"h-8 w-8 animate-spin text-muted-foreground"})})]});if(!e)return(0,r.jsxs)(eo.Zp,{children:[(0,r.jsxs)(eo.aR,{children:[(0,r.jsx)(eo.ZB,{children:"Trend Over Time"}),(0,r.jsx)(eo.BT,{children:"No data available"})]}),(0,r.jsx)(eo.Wu,{className:"flex h-[340px] items-center justify-center text-sm text-muted-foreground",children:"Select a score to view trends"})]});let{metadata:h}=e,{mode:f,dataType:p}=h,{score1:g,score2:v,interval:y,fromTimestamp:b,toTimestamp:j}=a,N=d.length>0,C=e=>e.length<=20?e:e.substring(0,17)+"...",S=g.name===(null==v?void 0:v.name)?"".concat(g.source," \xb7 ").concat(g.name):g.name,w=v?v.name===g.name?"".concat(v.source," \xb7 ").concat(v.name):v.name:"Score 2";return(0,r.jsxs)(eo.Zp,{"data-sentry-element":"Card","data-sentry-component":"TimelineChartCard","data-sentry-source-file":"TimelineChartCard.tsx",children:[(0,r.jsx)(eo.aR,{"data-sentry-element":"CardHeader","data-sentry-source-file":"TimelineChartCard.tsx",children:(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsx)("div",{className:"flex items-start justify-between",children:(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsxs)(eo.ZB,{className:"flex items-center gap-2","data-sentry-element":"CardTitle","data-sentry-source-file":"TimelineChartCard.tsx",children:["Trend Over Time",e.samplingMetadata.isSampled&&(0,r.jsx)(em,{samplingMetadata:e.samplingMetadata,showLabel:!0})]}),(0,r.jsx)(eo.BT,{"data-sentry-element":"CardDescription","data-sentry-source-file":"TimelineChartCard.tsx",children:m})]})}),"two"===f&&(0,r.jsx)(eh.tU,{value:l,onValueChange:e=>i(e),children:(0,r.jsxs)(eh.j7,{className:"h-7",children:[(0,r.jsx)(eh.Xi,{value:"score1",title:S,className:"h-5 px-2 text-xs",children:C(S)}),(0,r.jsx)(eh.Xi,{value:"score2",title:w,className:"h-5 px-2 text-xs",children:C(w)}),(0,r.jsx)(eh.Xi,{value:"all",className:"h-5 px-2 text-xs",children:"all"}),(0,r.jsx)(eh.Xi,{value:"matched",className:"h-5 px-2 text-xs",children:"matched"})]})})]})}),(0,r.jsx)(eo.Wu,{className:"flex h-[340px] flex-col pl-1","data-sentry-element":"CardContent","data-sentry-source-file":"TimelineChartCard.tsx",children:N?(0,r.jsx)(eD,{data:d,dataType:p,score1Name:"score1"===l?"".concat(g.name," (").concat(g.source,")"):"score2"===l&&v?"".concat(v.name," (").concat(v.source,")"):"".concat(g.name," (").concat(g.source,")"),score2Name:"score1"===l||"score2"===l?void 0:"two"===f&&v?"".concat(v.name," (").concat(v.source,")"):void 0,interval:y,timeRange:{from:b,to:j},colors:u}):(0,r.jsx)("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"No time series data available for the selected time range"})})]})}eL.displayName="ScoreChartLegendContent";var eR=a(3176),eB=a(99920);function eO(e){let{distribution1:t,distribution2:a,binLabels:s,score1Name:o,score2Name:l,colors:i}=e,c=!!(a&&l),d=(0,n.useMemo)(()=>{let e=a?new Map(a.map(e=>[e.binIndex,e.count])):null;return[...t].sort((e,t)=>
1e.binIndex-t.binIndex).map(t=>{var a,r;let n=null!=(a=s[t.binIndex])?a:"Bin ".concat(t.binIndex);return c&&e?{dimension:n,pv:t.count,uv:null!=(r=e.get(t.binIndex))?r:0}:{dimension:n,pv:t.count}})},[t,a,s,c]),u=(0,n.useMemo)(()=>{let e={pv:{label:o,color:i.score1}};return c&&l&&(e.uv={label:l,color:i.score2}),e},[c,o,l,i]),[m,x]=(0,n.useState)(new Set),h=(0,n.useMemo)(()=>{if(c)return{pv:!m.has("pv"),uv:!m.has("uv")}},[m,c]),f=(0,n.useCallback)((e,t)=>{x(a=>{let r=new Set(a);return t?r.delete(e):r.add(e),r})},[]);return(0,r.jsx)(eb.at,{config:u,className:"[&_.recharts-rectangle.recharts-tooltip-cursor]:fill-transparent","data-sentry-element":"ChartContainer","data-sentry-component":"ScoreDistributionNumericChart","data-sentry-source-file":"ScoreDistributionNumericChart.tsx",children:(0,r.jsxs)(eR.E,{accessibilityLayer:!0,data:d,margin:{bottom:20},"data-sentry-element":"BarChart","data-sentry-source-file":"ScoreDistributionNumericChart.tsx",children:[(0,r.jsx)(ep.W,{dataKey:"dimension",stroke:"hsl(var(--chart-grid))",fontSize:12,tickLine:!1,axisLine:{stroke:"hsl(var(--border) / 0.5)"},interval:1,"data-sentry-element":"XAxis","data-sentry-source-file":"ScoreDistributionNumericChart.tsx"}),(0,r.jsx)(eg.h,{stroke:"hsl(var(--chart-grid))",fontSize:12,tickLine:!1,axisLine:!1,tickFormatter:e=>(0,ej.zo)(e),"data-sentry-element":"YAxis","data-sentry-source-file":"ScoreDistributionNumericChart.tsx"}),(0,r.jsx)(eb.II,{content:(0,r.jsx)(ew,{valueFormatter:ej.zo,labelFormatter:e=>String(e)}),"data-sentry-element":"ChartTooltip","data-sentry-source-file":"ScoreDistributionNumericChart.tsx"}),(0,r.jsx)(eB.y,{dataKey:"pv",fill:i.score1,fillOpacity:+!m.has("pv"),radius:[4,4,0,0],"data-sentry-element":"Bar","data-sentry-source-file":"ScoreDistributionNumericChart.tsx"}),c&&(0,r.jsx)(eB.y,{dataKey:"uv",fill:i.score2,fillOpacity:+!m.has("uv"),radius:[4,4,0,0]}),(0,r.jsx)(ey.s,{content:(0,r.jsx)(eL,{interactive:c,visibilityState:h,onVisibilityChange:f}),"data-sentry-element":"Legend","data-sentry-source-file":"ScoreDistributionNumericChart.tsx"})]})})}function eP(){var e;let{data:t,isLoading:a,params:s,getColorForScore:o}=X(),[l,i]=(0,n.useState)("all"),c=(0,n.useMemo)(()=>{if(!(null==t?void 0:t.distribution))return;let{distribution:e,metadata:a}=t,{mode:r}=a;if("single"===r)return e.binLabelsIndividual1;switch(l){case"score1":return e.binLabelsIndividual1;case"score2":return e.binLabelsIndividual2;default:return e.binLabelsGlobal}},[t,l]),{distribution1Data:d,distribution2Data:u,description:m}=(0,n.useMemo)(()=>{var e,a,r,n;if(!t)return{distribution1Data:[],distribution2Data:void 0,description:""};let{distribution:o,metadata:i,statistics:c}=t,{mode:d}=i,{score1:u,score2:m}=s;if("single"===d)return{distribution1Data:o.score1,distribution2Data:void 0,description:"".concat(c.score1.total.toLocaleString()," observations").concat(null!==c.score1.mean?" | Average: ".concat(c.score1.mean.toFixed(3)):"")};switch(l){case"score1":return{distribution1Data:o.score1Individual&&o.score1Individual.length>0?o.score1Individual:o.score1,distribution2Data:void 0,description:"".concat(u.name," - ").concat(c.score1.total.toLocaleString()," observations")};case"score2":return{distribution1Data:o.score2Individual&&o.score2Individual.length>0?o.score2Individual:o.score2,distribution2Data:void 0,description:"".concat(null!=(a=null==m?void 0:m.name)?a:"Score 2"," - ").concat(null==(e=c.score2)?void 0:e.total.toLocaleString()," observations")};case"all":return{distribution1Data:o.score1,distribution2Data:o.score2,description:"".concat(u.name," (").concat(c.score1.total.toLocaleString(),") vs ").concat(null==m?void 0:m.name," (").concat(null==(r=c.score2)?void 0:r.total.toLocaleString(),")")};case"matched":return{distribution1Data:o.score1Matched,distribution2Data:o.score2Matched,description:"".concat(u.name," vs ").concat(null==m?void 0:m.name," - ").concat(null==(n=c.comparison)?void 0:n.matchedCount.toLocaleString()," matched")}}},[t,l,s]),h=(0,n.useMemo)(()=>"score1"===l?{score1:o(1)}:"score2"===l?{score1:o(2)}:{score1:o(1),score2:o(2)},[l,o]);if(a)return(0,r.jsxs)(eo.Zp,{children:[(0,r.jsxs)(eo.aR,{children:[(0,r.jsx)(eo.ZB,{children:"Distribution"}),(0,r.jsx)(eo.BT,{children:"Loading chart..."})]}),(0,r.jsx)(eo.Wu,{className:"flex h-[340px] flex-col items-center justify-center pl-0",children:(0,r.jsx)(x.A,{className:"h-8 w-8 animate-spin text-muted-foreground"})})]});if(!t)return(0,r.jsxs)(eo.Zp,{children:[(0,r.jsxs)(eo.aR,{children:[(0,r.jsx)(eo.ZB,{children:"Distribution"}),(0,r.jsx)(eo.BT,{children:"No data available"})]}),(0,r.jsx)(eo.Wu,{className:"flex h-[340px] flex-col items-center justify-center pl-0 text-sm text-muted-foreground",children:"Select a score to view distribution"})]});let{metadata:f}=t,{mode:p}=f,{score1:g,score2:v}=s,y=(null!=(e=null==d?void 0:d.length)?e:0)>0,b=e=>e.length<=20?e:e.substring(0,17)+"...",j=g.name===(null==v?void 0:v.name)?"".concat(g.source," \xb7 ").concat(g.name):g.name,N=v?v.name===g.name?"".concat(v.source," \xb7 ").concat(v.name):v.name:"Score 2";return(0,r.jsxs)(eo.Zp,{"data-sentry-element":"Card","data-sentry-component":"DistributionNumericCard","data-sentry-source-file":"DistributionNumericCard.tsx",children:[(0,r.jsx)(eo.aR,{"data-sentry-element":"CardHeader","data-sentry-source-file":"DistributionNumericCard.tsx",children:(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsx)("div",{className:"flex items-start justify-between",children:(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsxs)(eo.ZB,{className:"flex items-center gap-2","data-sentry-element":"CardTitle","data-sentry-source-file":"DistributionNumericCard.tsx",children:["Distribution",t.samplingMetadata.isSampled&&(0,r.jsx)(em,{samplingMetadata:t.samplingMetadata,showLabel:!0})]}),(0,r.jsx)(eo.BT,{"data-sentry-element":"CardDescription","data-sentry-source-file":"DistributionNumericCard.tsx",children:m})]})}
1),"two"===p&&(0,r.jsx)(eh.tU,{value:l,onValueChange:e=>i(e),children:(0,r.jsxs)(eh.j7,{className:"h-7",children:[(0,r.jsx)(eh.Xi,{value:"score1",title:j,className:"h-5 px-2 text-xs",children:b(j)}),(0,r.jsx)(eh.Xi,{value:"score2",title:N,className:"h-5 px-2 text-xs",children:b(N)}),(0,r.jsx)(eh.Xi,{value:"all",className:"h-5 px-2 text-xs",children:"all"}),(0,r.jsx)(eh.Xi,{value:"matched",className:"h-5 px-2 text-xs",children:"matched"})]})})]})}),(0,r.jsx)(eo.Wu,{className:"flex h-[340px] flex-col pl-0","data-sentry-element":"CardContent","data-sentry-source-file":"DistributionNumericCard.tsx",children:y&&c?(0,r.jsx)(eO,{distribution1:null!=d?d:[],distribution2:"score1"===l||"score2"===l?void 0:null!=u?u:void 0,binLabels:c,score1Name:"score2"===l&&v?"".concat(v.name," (").concat(v.source,")"):"".concat(g.name," (").concat(g.source,")"),score2Name:"score1"===l||"score2"===l?void 0:"two"===p&&v?"".concat(v.name," (").concat(v.source,")"):void 0,colors:h}):(0,r.jsx)("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"No distribution data available for the selected time range"})})]})}function eF(e){let{distribution1:t,categories:a,score1Name:s,stackedDistribution:o,score2Categories:l,score2Name:i,score2Source:c,colors:d}=e,u=!!(o&&o.length>0),m=e=>"__unmatched__"===e||"0"===e||""===e||"null"===e,x=(0,n.useMemo)(()=>{if(!u||!o||!l)return[];let e=new Set;o.forEach(t=>{e.add(t.score2Stack)});let t=Array.from(e).map(e=>m(e)?"__unmatched__":e),a=Array.from(new Set([...t,...l])).filter(e=>"__unmatched__"!==e).sort();return t.includes("__unmatched__")?[...a,"__unmatched__"]:a},[u,o,l]),h=(0,n.useMemo)(()=>{if(u&&o&&l){let e=new Map;return o.forEach(t=>{e.has(t.score1Category)||e.set(t.score1Category,{});let a=m(t.score2Stack)?"__unmatched__":t.score2Stack;e.get(t.score1Category)[a]=t.count}),Array.from(e.entries()).sort((e,t)=>"__unmatched__"===e[0]?1:"__unmatched__"===t[0]?-1:e[0].localeCompare(t[0])).map(e=>{let[t,a]=e,r={};return x.forEach(e=>{var t;r[e]=null!=(t=a[e])?t:0}),{name:"__unmatched__"===t?"no match":t,...r}})}return[...t].sort((e,t)=>e.binIndex-t.binIndex).map(e=>{var t;return{name:null!=(t=a[e.binIndex])?t:"Category ".concat(e.binIndex),pv:e.count}})},[t,a,u,o,l,x]),[f,p]=(0,n.useState)(new Set),g=(0,n.useMemo)(()=>{if(!u)return{};let e={};return x.forEach(t=>{e[t]=!f.has(t)}),e},[f,u,x]),v=(0,n.useCallback)((e,t)=>{p(a=>{let r=new Set(a);return t?r.delete(e):r.add(e),r})},[]),y=(0,n.useMemo)(()=>{if(u&&x.length>0){let e={};return x.forEach(t=>{let a;if("__unmatched__"===t){e[t]={label:"no match",color:"hsl(var(--muted))"};return}i&&c&&(a=d["".concat(i," (").concat(c,"): ").concat(t)]),a||(a=d[t]),a||(a=Object.values(d)[0]),e[t]={label:t,color:a}}),e}return{pv:{label:s,color:a[0]?d[a[0]]:Object.values(d)[0]}}},[u,x,s,i,c,d,a]);return(0,r.jsx)(eb.at,{config:y,className:"[&_.recharts-rectangle.recharts-tooltip-cursor]:fill-transparent","data-sentry-element":"ChartContainer","data-sentry-component":"ScoreDistributionCategoricalChart","data-sentry-source-file":"ScoreDistributionCategoricalChart.tsx",children:(0,r.jsxs)(eR.E,{accessibilityLayer:!0,data:h,margin:{bottom:20},"data-sentry-element":"BarChart","data-sentry-source-file":"ScoreDistributionCategoricalChart.tsx",children:[(0,r.jsx)(ep.W,{dataKey:"name",stroke:"hsl(var(--chart-grid))",fontSize:12,tickLine:!1,axisLine:{stroke:"hsl(var(--border) / 0.5)"},interval:0,"data-sentry-element":"XAxis","data-sentry-source-file":"ScoreDistributionCategoricalChart.tsx"}),(0,r.jsx)(eg.h,{stroke:"hsl(var(--chart-grid))",fontSize:12,tickLine:!1,axisLine:!1,tickFormatter:e=>e.toLocaleString(),"data-sentry-element":"YAxis","data-sentry-source-file":"ScoreDistributionCategoricalChart.tsx"}),(0,r.jsx)(eb.II,{content:(0,r.jsx)(ew,{valueFormatter:e=>e.toLocaleString(),labelFormatter:e=>String(e)}),"data-sentry-element":"ChartTooltip","data-sentry-source-file":"ScoreDistributionCategoricalChart.tsx"}),u&&x.map(e=>{var t,a;let s=f.has(e);return(0,r.jsx)(eB.y,{dataKey:e,stackId:"stack",fill:null!=(a=null==(t=y[e])?void 0:t.color)?a:"hsl(var(--chart-1))",fillOpacity:+!s,radius:[0,0,0,0]},e)}),!u&&(0,r.jsx)(eB.y,{dataKey:"pv",fill:y.pv.color,radius:[4,4,0,0]},"pv"),(0,r.jsx)(ey.s,{content:(0,r.jsx)(eL,{interactive:u,visibilityState:g,onVisibilityChange:v}),"data-sentry-element":"Legend","data-sentry-source-file":"ScoreDistributionCategoricalChart.tsx"})]})})}function eH(){var e;let{data:t,isLoading:a,params:s,colorMappings:o}
1=X(),[l,i]=(0,n.useState)("all"),c=(0,n.useMemo)(()=>{var e,a,r,n,o,i,c,d,u,m,x,h,f,p;if(!t)return null;let{distribution:g,metadata:v,statistics:y}=t,{mode:b}=v,{score1:j,score2:N}=s;if("single"===b)return{distribution1:g.score1,categories:null!=(e=g.categories)?e:[],stackedDistribution:void 0,score2Categories:void 0,description:"".concat(y.score1.total.toLocaleString()," observations").concat(y.score1.mode?" | Most frequent: ".concat(y.score1.mode.category," (").concat(y.score1.mode.count.toLocaleString(),")"):"")};switch(l){case"score1":return{distribution1:g.score1Individual,categories:null!=(a=g.categories)?a:[],stackedDistribution:void 0,score2Categories:void 0,description:"".concat(j.name," - ").concat(y.score1.total.toLocaleString()," observations")};case"score2":return{distribution1:g.score2Individual,categories:null!=(n=g.score2Categories)?n:[],stackedDistribution:void 0,score2Categories:void 0,description:"".concat(null!=(o=null==N?void 0:N.name)?o:"Score 2"," - ").concat(null==(r=y.score2)?void 0:r.total.toLocaleString()," observations")};case"all":{let e=function(e,t,a){let r=e=>"__unmatched__"===e||"0"===e||""===e||"null"===e,s=new Map;e.forEach(e=>{if(e.binIndex>=0&&e.binIndex<a.length){let t=a[e.binIndex];t&&s.set(t,e.count)}});let n=new Map;t.forEach(e=>{if(!r(e.score2Stack)&&!r(e.score1Category)){let t=n.get(e.score2Stack)||0;n.set(e.score2Stack,t+e.count)}});let o=[];return a.forEach(e=>{let t=Math.max(0,(s.get(e)||0)-(n.get(e)||0));t>0&&o.push({score1Category:"__unmatched__",score2Stack:e,count:t})}),o}(g.score2Individual,null!=(c=g.stackedDistribution)?c:[],null!=(d=g.score2Categories)?d:[]),t=[...null!=(u=g.stackedDistribution)?u:[],...e];return{distribution1:void 0,categories:null!=(m=g.categories)?m:[],stackedDistribution:t,score2Categories:null!=(x=g.score2Categories)?x:[],description:"".concat(j.name," (").concat(y.score1.total.toLocaleString(),") vs ").concat(null==N?void 0:N.name,"
1(").concat(null==(i=y.score2)?void 0:i.total.toLocaleString(),")")}}case"matched":return{distribution1:void 0,categories:null!=(f=g.categories)?f:[],stackedDistribution:g.stackedDistributionMatched,score2Categories:null!=(p=g.score2Categories)?p:[],description:"".concat(j.name," vs ").concat(null==N?void 0:N.name," - ").concat(null==(h=y.comparison)?void 0:h.matchedCount.toLocaleString()," matched")}}},[t,l,s]),d=(0,n.useMemo)(()=>{if(!t)return o;let{distribution:e}=t;return"score1"===l&&e.categories?H(1,e.categories):"score2"===l&&e.score2Categories?H(2,e.score2Categories):o},[l,t,o]);if(a)return(0,r.jsxs)(eo.Zp,{children:[(0,r.jsxs)(eo.aR,{children:[(0,r.jsx)(eo.ZB,{children:"Distribution"}),(0,r.jsx)(eo.BT,{children:"Loading chart..."})]}),(0,r.jsx)(eo.Wu,{className:"flex h-[340px] flex-col items-center justify-center pl-0",children:(0,r.jsx)(x.A,{className:"h-8 w-8 animate-spin text-muted-foreground"})})]});if(!t||!c)return(0,r.jsxs)(eo.Zp,{children:[(0,r.jsxs)(eo.aR,{children:[(0,r.jsx)(eo.ZB,{children:"Distribution"}),(0,r.jsx)(eo.BT,{children:"No data available"})]}),(0,r.jsx)(eo.Wu,{className:"flex h-[340px] flex-col items-center justify-center pl-0 text-sm text-muted-foreground",children:"Select a score to view distribution"})]});let{metadata:u}=t,{mode:m}=u,{score1:h,score2:f}=s,p=c.distribution1&&c.distribution1.length>0||c.stackedDistribution&&c.stackedDistribution.length>0,g=e=>e.length<=20?e:e.substring(0,17)+"...",v=h.name===(null==f?void 0:f.name)?"".concat(h.source," \xb7 ").concat(h.name):h.name,y=f?f.name===h.name?"".concat(f.source," \xb7 ").concat(f.name):f.name:"Score 2";return(0,r.jsxs)(eo.Zp,{"data-sentry-element":"Card","data-sentry-component":"DistributionCategoricalCard","data-sentry-source-file":"DistributionCategoricalCard.tsx",children:[(0,r.jsx)(eo.aR,{"data-sentry-element":"CardHeader","data-sentry-source-file":"DistributionCategoricalCard.tsx",children:(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsx)("div",{className:"flex items-start justify-between",children:(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsxs)(eo.ZB,{className:"flex items-center gap-2","data-sentry-element":"CardTitle","data-sentry-source-file":"DistributionCategoricalCard.tsx",children:["Distribution",t.samplingMetadata.isSampled&&(0,r.jsx)(em,{samplingMetadata:t.samplingMetadata,showLabel:!0})]}),(0,r.jsx)(eo.BT,{"data-sentry-element":"CardDescription","data-sentry-source-file":"DistributionCategoricalCard.tsx",children:c.description})]})}),"two"===m&&(0,r.jsx)(eh.tU,{value:l,onValueChange:e=>i(e),children:(0,r.jsxs)(eh.j7,{className:"h-7",children:[(0,r.jsx)(eh.Xi,{value:"score1",title:v,className:"h-5 px-2 text-xs",children:g(v)}),(0,r.jsx)(eh.Xi,{value:"score2",title:y,className:"h-5 px-2 text-xs",children:g(y)}),(0,r.jsx)(eh.Xi,{value:"all",className:"h-5 px-2 text-xs",children:"all"}),(0,r.jsx)(eh.Xi,{value:"matched",className:"h-5 px-2 text-xs",children:"matched"})]})})]})}),(0,r.jsx)(eo.Wu,{className:"flex h-[340px] flex-col pl-0","data-sentry-element":"CardContent","data-sentry-source-file":"DistributionCategoricalCard.tsx",children:p?(0,r.jsx)(eF,{distribution1:null!=(e=c.distribution1)?e:[],categories:c.categories,score1Name:"score2"===l&&f?"".concat(f.name," (").concat(f.source,")"):"".concat(h.name," (").concat(h.source,")"),stackedDistribution:c.stackedDistribution,score2Categories:c.score2Categories,score2Name:"score1"===l||"score2"===l?void 0:"two"===m&&f?"".concat(f.name," (").concat(f.source,")"):void 0,score2Source:"score1"===l||"score2"===l?void 0:"two"===m&&f?f.source:void 0,colors:d}):(0,r.jsx)("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"No distribution data available for the selected time range"})})]})}function eK(e){var t,a;let{distribution1:s,distribution2:o,categories:l,score1Name:i,score2Name:c,colors:d}=e,u=!!(o&&c),m=(0,n.useMemo)(()=>{let e=Object.keys(d);if(!e.some(e=>e.includes(":")))return null;let t={};return l.forEach(a=>{t[a]=e.filter(e=>e.endsWith(": ".concat(a)))}),t},[d,l]),x=(0,n.useMemo)(()=>{let e=o?new Map(o.map(e=>[e.binIndex,e.count])):null;return[...s].sort((e,t)=>
1e.binIndex-t.binIndex).map(t=>{var a,r,s,n,o;let i=null!=(a=l[t.binIndex])?a:"Value ".concat(t.binIndex);if(!u||!e)return{name:i,pv:t.count};if(m&&m[i]){let a=m[i],o=null!=(r=a[0])?r:"pv",l=null!=(s=a[1])?s:"uv";return{name:i,[o]:t.count,[l]:null!=(n=e.get(t.binIndex))?n:0}}return{name:i,pv:t.count,uv:null!=(o=e.get(t.binIndex))?o:0}})},[s,o,l,u,m]),h=(0,n.useMemo)(()=>{if(!u)return{score1Key:"pv",score2Key:null};if(m&&l.length>0){let e=m[l[0]];if(e&&e.length>=2)return{score1Key:e[0],score2Key:e[1]}}return{score1Key:"pv",score2Key:"uv"}},[u,m,l]),[f,p]=(0,n.useState)(new Set),g=(0,n.useMemo)(()=>{if(u)return{[h.score1Key]:!f.has(h.score1Key),...h.score2Key&&{[h.score2Key]:!f.has(h.score2Key)}}},[f,u,h]),v=(0,n.useCallback)((e,t)=>{p(a=>{let r=new Set(a);return t?r.delete(e):r.add(e),r})},[]),y=(0,n.useMemo)(()=>{if(m&&u){let e={};return e[h.score1Key]={label:h.score1Key,color:d[h.score1Key]||Object.values(d)[0]},h.score2Key&&(e[h.score2Key]={label:h.score2Key,color:d[h.score2Key]||Object.values(d)[1]}),e}let e=d.True||d.False||Object.values(d)[0],t={pv:{label:i,color:e}};return u&&c&&(t.uv={label:c,color:d.__score2_True||d.__score2_False||Object.values(d)[1]||e}),t},[u,i,c,d,m,h]);return(0,r.jsx)(eb.at,{config:y,className:"[&_.recharts-rectangle.recharts-tooltip-cursor]:fill-transparent","data-sentry-element":"ChartContainer","data-sentry-component":"ScoreDistributionBooleanChart","data-sentry-source-file":"ScoreDistributionBooleanChart.tsx",children:(0,r.jsxs)(eR.E,{accessibilityLayer:!0,data:x,margin:{bottom:20},"data-sentry-element":"BarChart","data-sentry-source-file":"ScoreDistributionBooleanChart.tsx",children:[(0,r.jsx)(ep.W,{dataKey:"name",stroke:"hsl(var(--chart-grid))",fontSize:12,tickLine:!1,axisLine:{stroke:"hsl(var(--border) / 0.5)"},interval:0,"data-sentry-element":"XAxis","data-sentry-source-file":"ScoreDistributionBooleanChart.tsx"}),(0,r.jsx)(eg.h,{stroke:"hsl(var(--chart-grid))",fontSize:12,tickLine:!1,axisLine:!1,tickFormatter:e=>e.toLocaleString(),"data-sentry-element":"YAxis","data-sentry-source-file":"ScoreDistributionBooleanChart.tsx"}),(0,r.jsx)(eb.II,{content:(0,r.jsx)(ew,{valueFormatter:e=>e.toLocaleString(),labelFormatter:e=>String(e)}),"data-sentry-element":"ChartTooltip","data-sentry-source-file":"ScoreDistributionBooleanChart.tsx"}),(0,r.jsx)(eB.y,{dataKey:h.score1Key,fill:null==(t=y[h.score1Key])?void 0:t.color,fillOpacity:+!f.has(h.score1Key),radius:[4,4,0,0],"data-sentry-element":"Bar","data-sentry-source-file":"ScoreDistributionBooleanChart.tsx"}),u&&h.score2Key&&(0,r.jsx)(eB.y,{dataKey:h.score2Key,fill:null==(a=y[h.score2Key])?void 0:a.color,fillOpacity:+!f.has(h.score2Key),radius:[4,4,0,0]}),(0,r.jsx)(ey.s,{content:(0,r.jsx)(eL,{interactive:u,visibilityState:g,onVisibilityChange:v}),"data-sentry-element":"Legend","data-sentry-source-file":"ScoreDistributionBooleanChart.tsx"})]})})}function eW(){let{data:e,isLoading:t,params:a,colorMappings:s,getColorForScore:o}=X(),[l,i]=(0,n.useState)("all"),{distribution1Data:c,distribution2Data:d,categories:u,description:m}=(0,n.useMemo)(()=>{var t,r,s,n,o,i,c,d,u;if(!e)return{distribution1Data:[],distribution2Data:void 0,categories:[],description:""};let{distribution:m,metadata:x,statistics:h}=e,{mode:f}=x,{score1:p,score2:g}=a;if("single"===f)return{distribution1Data:m.score1,distribution2Data:void 0,categories:null!=(t=m.categories)?t:[],description:"".concat(h.score1.total.toLocaleString()," observations").concat(h.score1.mode?" | Most frequent: ".concat(h.score1.mode.category," (").concat(h.score1.mode.count.toLocaleString(),")"):"")};switch(l){case"score1":return{distribution1Data:m.score1Individual,distribution2Data:void 0,categories:null!=(r=m.categories)?r:[],description:"".concat(p.name," - ").concat(h.score1.total.toLocaleString()," observations")};case"score2":return{distribution1Data:m.score2Individual,distribution2Data:void 0,categories:null!=(n=m.score2Categories)?n:[],description:"".concat(null!=(o=null==g?void 0:g.name)?o:"Score 2"," - ").concat(null==(s=h.score2)?void 0:s.total.toLocaleString()," observations")};case"all":return{distribution1Data:m.score1Individual,distribution2Data:m.score2Individual,categories:null!=(c=m.categories)?c:[],description:"".concat(p.name,"
1(").concat(h.score1.total.toLocaleString(),") vs ").concat(null==g?void 0:g.name," (").concat(null==(i=h.score2)?void 0:i.total.toLocaleString(),")")};case"matched":return{distribution1Data:m.score1Matched,distribution2Data:m.score2Matched,categories:null!=(u=m.categories)?u:[],description:"".concat(p.name," vs ").concat(null==g?void 0:g.name," - ").concat(null==(d=h.comparison)?void 0:d.matchedCount.toLocaleString()," matched")}}},[e,l,a]),h=(0,n.useMemo)(()=>e?"score1"===l?{score1:o(1)}:"score2"===l?{score1:o(2)}:{score1:o(1),score2:o(2)}:s,[l,e,s,o]);if(t)return(0,r.jsxs)(eo.Zp,{children:[(0,r.jsxs)(eo.aR,{children:[(0,r.jsx)(eo.ZB,{children:"Distribution"}),(0,r.jsx)(eo.BT,{children:"Loading chart..."})]}),(0,r.jsx)(eo.Wu,{className:"flex h-[340px] flex-col items-center justify-center pl-0",children:(0,r.jsx)(x.A,{className:"h-8 w-8 animate-spin text-muted-foreground"})})]});if(!e)return(0,r.jsxs)(eo.Zp,{children:[(0,r.jsxs)(eo.aR,{children:[(0,r.jsx)(eo.ZB,{children:"Distribution"}),(0,r.jsx)(eo.BT,{children:"No data available"})]}),(0,r.jsx)(eo.Wu,{className:"flex h-[340px] flex-col items-center justify-center pl-0 text-sm text-muted-foreground",children:"Select a score to view distribution"})]});let{metadata:f}=e,{mode:p}=f,{score1:g,score2:v}=a,y=c.length>0,b=e=>e.length<=20?e:e.substring(0,17)+"...",j=g.name===(null==v?void 0:v.name)?"".concat(g.source," \xb7 ").concat(g.name):g.name,N=v?v.name===g.name?"".concat(v.source," \xb7 ").concat(v.name):v.name:"Score 2";return(0,r.jsxs)(eo.Zp,{"data-sentry-element":"Card","data-sentry-component":"DistributionBooleanCard","data-sentry-source-file":"DistributionBooleanCard.tsx",children:[(0,r.jsx)(eo.aR,{"data-sentry-element":"CardHeader","data-sentry-source-file":"DistributionBooleanCard.tsx",children:(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsx)("div",{className:"flex items-start justify-between",children:(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsxs)(eo.ZB,{className:"flex items-center gap-2","data-sentry-element":"CardTitle","data-sentry-source-file":"DistributionBooleanCard.tsx",children:["Distribution",e.samplingMetadata.isSampled&&(0,r.jsx)(em,{samplingMetadata:e.samplingMetadata,showLabel:!0})]}),(0,r.jsx)(eo.BT,{"data-sentry-element":"CardDescription","data-sentry-source-file":"DistributionBooleanCard.tsx",children:m})]})}
1),"two"===p&&(0,r.jsx)(eh.tU,{value:l,onValueChange:e=>i(e),children:(0,r.jsxs)(eh.j7,{className:"h-7",children:[(0,r.jsx)(eh.Xi,{value:"score1",title:j,className:"h-5 px-2 text-xs",children:b(j)}),(0,r.jsx)(eh.Xi,{value:"score2",title:N,className:"h-5 px-2 text-xs",children:b(N)}),(0,r.jsx)(eh.Xi,{value:"all",className:"h-5 px-2 text-xs",children:"all"}),(0,r.jsx)(eh.Xi,{value:"matched",className:"h-5 px-2 text-xs",children:"matched"})]})})]})}),(0,r.jsx)(eo.Wu,{className:"flex h-[340px] flex-col pl-0","data-sentry-element":"CardContent","data-sentry-source-file":"DistributionBooleanCard.tsx",children:y?(0,r.jsx)(eK,{distribution1:c,distribution2:"score1"===l||"score2"===l?void 0:d,categories:u,score1Name:"score2"===l&&v?"".concat(v.name," (").concat(v.source,")"):"".concat(g.name," (").concat(g.source,")"),score2Name:"score1"===l||"score2"===l?void 0:"two"===p&&v?"".concat(v.name," (").concat(v.source,")"):void 0,colors:h}):(0,r.jsx)("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"No distribution data available for the selected time range"})})]})}function eU(e){let{cellClassName:t}=e;return(0,r.jsx)("div",{className:(0,eS.cn)("h-full w-full rounded-sm border transition-all duration-150","hover:brightness-95",t),style:{backgroundColor:"hsl(var(--background))",borderColor:"hsl(var(--border) / 0.5)"},"aria-hidden":"true","data-sentry-component":"EmptyCell","data-sentry-source-file":"HeatmapCell.tsx"})}function eV(e){let{cell:t,color:a,onHover:s,onClick:o,renderTooltip:l,cellClassName:i,showValues:c}
1=e,[d,u]=(0,n.useState)(!1),m=0===t.value,x=void 0!==o,h=a||"transparent",f=m?"hsl(var(--muted-foreground))":function(e){let t=e.match(/oklch\((\d+\.?\d*)%/);return(t?parseFloat(t[1]):50)>60?"black":"white"}(h),p=(0,eS.cn)("h-full w-full rounded-sm border-[0.5px]","flex items-center justify-center","text-xs font-medium","transition-all duration-150","whitespace-pre-line text-center leading-tight",x&&"cursor-pointer",!x&&"cursor-default",m&&d&&"brightness-95",!m&&d&&"brightness-75 saturate-[3]",i),g={backgroundColor:m?"hsl(var(--background))":h,borderColor:m?"hsl(var(--border) / 0.34)":h,color:"white"===f?"white":"black"},v=()=>{u(!0),null==s||s(t)},y=()=>{u(!1),null==s||s(null)},b=x?(0,r.jsx)("button",{type:"button",className:(0,eS.cn)(p,"focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"),style:g,onMouseEnter:v,onMouseLeave:y,onClick:()=>null==o?void 0:o(t),"aria-label":t.displayValue||"Value: ".concat(t.value),children:c&&(0,r.jsx)("span",{className:"text-[10px] sm:text-xs",children:t.displayValue})}):(0,r.jsx)("div",{className:p,style:g,onMouseEnter:v,onMouseLeave:y,"aria-label":t.displayValue||"Value: ".concat(t.value),children:c&&(0,r.jsx)("span",{className:"text-[10px] sm:text-xs",children:t.displayValue})});return l?(0,r.jsxs)(el.m_,{children:[(0,r.jsx)(el.k$,{asChild:!0,children:b}),(0,r.jsx)(el.ZI,{className:"max-w-xs",children:l(t)})]}):b}function eZ(e){let{cell:t,color:a,onHover:s,onClick:n,renderTooltip:o,cellClassName:l,showValues:i=!0}=e;return t?(0,r.jsx)(eV,{cell:t,color:a,onHover:s,onClick:n,renderTooltip:o,cellClassName:l,showValues:i,"data-sentry-element":"CellWithData","data-sentry-component":"HeatmapCellComponent","data-sentry-source-file":"HeatmapCell.tsx"}):(0,r.jsx)(eU,{cellClassName:l})}function ez(e){let{data:t,rows:a,cols:s,rowLabels:o,colLabels:l,xAxisLabel:i,yAxisLabel:c,cellClassName:d,cellHeight:u,width:m="100%",height:x,className:h,getColor:f,showValues:p=!0,renderTooltip:g,onCellClick:v,onCellHover:y,ariaLabel:b="Score comparison heatmap"}=e,j=(0,n.useMemo)(()=>{let e=new Map;return t.forEach(t=>{e.set("".concat(t.row,"-").concat(t.col),t)}),e},[t]),N=o&&o.length===a+1&&l&&l.length===s+1,C=(0,n.useMemo)(()=>N?a>=20||s>=20?4:a>=15||s>=15?3:a>=10||s>=10?2:1:1,[N,a,s]),S="minmax(32px, 1fr)",w=u?"".concat(u,"px"):"minmax(24px, 40px)",M=(0,n.useMemo)(()=>s<4?12:s<8?10:6,[s]),T=(0,n.useRef)(null),[k,L]=(0,n.useState)(60);return(0,n.useLayoutEffect)(()=>{if(T.current&&o&&o.length>0){let e=T.current.querySelectorAll("span"),t=0;e.forEach(e=>{let a=e.offsetWidth;t=Math.max(t,a)}),L(Math.max(36,Math.min(t+8,120)))}},[o,N]),(0,r.jsx)(el.Bc,{delayDuration:0,"data-sentry-element":"TooltipProvider","data-sentry-component":"Heatmap","data-sentry-source-file":"Heatmap.tsx",children:(0,r.jsxs)("div",{className:(0,eS.cn)("flex w-full flex-1 flex-col gap-4",h),style:{width:m,height:x},role:"img","aria-label":b,children:[(0,r.jsxs)("div",{className:"flex flex-1 items-stretch justify-center gap-1 sm:gap-2",children:[c&&(0,r.jsx)("div",{className:"flex items-center justify-center",children:(0,r.jsx)("span",{className:"text-xs font-normal text-muted-foreground",style:{writingMode:"vertical-rl",transform:"rotate(180deg)"},children:c})}),o&&o.length>0&&(0,r.jsx)("div",{ref:T,className:(0,eS.cn)("pr-1 text-right text-[10px] text-muted-foreground sm:pr-2 sm:text-xs",N?"flex flex-col justify-between self-stretch":"grid gap-1"),style:{width:"".concat(k,"px"),...N?{}:{gridTemplateRows:"repeat(".concat(a,", ").concat(w,")")}},children:o.map((e,t)=>{if(!(!N||t%C==0))return(0,r.jsx)("div",{className:"h-0"},t);let a=!N&&e.length>8,s=a?e.slice(0,5)+"...":e;return(0,r.jsx)("div",{className:(0,eS.cn)("flex justify-end",N?"items-start":"items-center"),children:a?(0,r.jsxs)(es.jc,{children:[(0,r.jsx)(es.d0,{asChild:!0,children:(0,r.jsx)("span",{className:"cursor-help text-right",children:s})}),(0,r.jsx)(es.Et,{side:"left",align:"center",className:"w-auto",children:(0,r.jsx)("div",{className:"space-y-1",children:(0,r.jsx)("p",{className:"font-semibold",children:e})})})]}):(0,r.jsx)("span",{children:e})},t)})}),(0,r.jsx)("div",{className:"grid w-full flex-1 gap-0.5",style:{gridTemplateColumns:"repeat(".concat(s,", ").concat(S,")"),gridTemplateRows:"repeat(".concat(a,", ").concat(w,")"),height:x||"auto"},role:"grid",children:Array.from({length:a*s}
1).map((e,t)=>{let a=Math.floor(t/s),n=j.get("".concat(a,"-").concat(t%s));return(0,r.jsx)(eZ,{cell:n,color:n?f(n):void 0,onHover:y,onClick:v,renderTooltip:g,cellClassName:d,showValues:p},t)})}),o&&o.length>0&&(0,r.jsx)("div",{className:"w-0 sm:w-2"})]}),l&&l.length>0&&(0,r.jsxs)("div",{className:"flex items-start gap-2 sm:gap-4",children:[o&&o.length>0&&(0,r.jsx)("div",{style:{width:"".concat(k,"px")}}),(0,r.jsx)("div",{className:(0,eS.cn)("w-full flex-1 text-center text-[10px] text-muted-foreground sm:text-xs",N?"flex justify-between":"grid gap-1"),style:N?void 0:{gridTemplateColumns:"repeat(".concat(s,", ").concat(S,")")},children:l.map((e,t)=>{if(!(!N||t%C==0))return(0,r.jsx)("div",{className:"w-0"},t);let a=!N&&e.length>M,s=a?e.slice(0,M-3)+"...":e;return(0,r.jsx)("div",{className:(0,eS.cn)("flex justify-center",N?"items-start":"items-center"),children:a?(0,r.jsxs)(es.jc,{children:[(0,r.jsx)(es.d0,{asChild:!0,children:(0,r.jsx)("span",{className:"cursor-help",children:s})}),(0,r.jsx)(es.Et,{side:"bottom",align:"center",className:"w-auto",children:(0,r.jsx)("div",{className:"space-y-1",children:(0,r.jsx)("p",{className:"text-xs",children:e})})})]}):(0,r.jsx)("span",{children:e})},t)})}),o&&o.length>0&&(0,r.jsx)("div",{className:"w-0 sm:w-2"})]}),i&&(0,r.jsx)("div",{className:"text-center text-xs font-normal text-muted-foreground",children:i})]})})}function eX(e){try{return(0,R.Ay)(e).get("hsl.l")>.85}catch(e){return!1}}function eG(e){let{min:t,max:a,scoreNumber:s=1,title:o,className:l,orientation:i="horizontal",steps:c=5}
1=e,[d,u]=(0,n.useState)(null),m=Array.from({length:c},(e,r)=>U(s,t+(a-t)*r/(c-1),t,a)),x=Array.from({length:c},(e,r)=>(t+(a-t)*r/(c-1)).toFixed(0));return"vertical"===i?(0,r.jsxs)("div",{className:(0,eS.cn)("flex flex-col gap-2",l),children:[o&&(0,r.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:o}),(0,r.jsx)("div",{className:"flex flex-col gap-1",children:m.slice().reverse().map((e,t)=>{let a=c-1-t,s=d===t,n=eX(e);return(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:(0,eS.cn)("h-3.5 w-3.5 rounded border border-border transition-all duration-150",s&&n&&"brightness-95",s&&!n&&"brightness-75 saturate-[3]"),style:{backgroundColor:e},onMouseEnter:()=>u(t),onMouseLeave:()=>u(null)}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:x[a]})]},t)})})]}):(0,r.jsxs)("div",{className:(0,eS.cn)("flex items-center gap-2",l),"data-sentry-component":"HeatmapLegend","data-sentry-source-file":"HeatmapLegend.tsx",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:t}),(0,r.jsx)("div",{className:"flex items-center gap-0.5",children:m.map((e,t)=>{let a=d===t,s=eX(e);return(0,r.jsx)("div",{className:(0,eS.cn)("h-3.5 w-3.5 rounded-sm border-[0.5px] border-border/30 transition-all duration-150",a&&s&&"brightness-95",a&&!s&&"brightness-75 saturate-[3]"),style:{backgroundColor:e},onMouseEnter:()=>u(t),onMouseLeave:()=>u(null)},t)})}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:a})]})}function eq(e){let{rows:t=10,cols:a=10,cellHeight:s,showLabels:o=!0,showAxisLabels:l=!0,className:i}=e,c=(0,n.useMemo)(()=>1e3*Math.random(),[]),d="minmax(32px, 1fr)",u=s?"".concat(s,"px"):"minmax(24px, 40px)";return(0,r.jsxs)("div",{className:(0,eS.cn)("flex w-full flex-1 flex-col gap-4",i),role:"status","aria-label":"Loading heatmap visualization","data-sentry-component":"HeatmapSkeleton","data-sentry-source-file":"HeatmapSkeleton.tsx",children:[(0,r.jsxs)("div",{className:"flex flex-1 items-stretch justify-center gap-1 sm:gap-2",children:[l&&(0,r.jsx)("div",{className:"flex items-center justify-center",children:(0,r.jsx)("div",{className:"h-16 w-3 animate-pulse rounded-sm bg-muted/40",style:{writingMode:"vertical-rl",transform:"rotate(180deg)"}})}),o&&(0,r.jsx)("div",{className:"grid gap-1 pr-1 text-right sm:pr-2",style:{width:"".concat(60,"px"),gridTemplateRows:"repeat(".concat(t,", ").concat(u,")")},children:Array.from({length:t}).map((e,t)=>(0,r.jsx)("div",{className:"flex items-center justify-end",children:(0,r.jsx)("div",{className:"h-3 w-10 animate-pulse rounded-sm bg-muted/40"})},t))}),(0,r.jsx)("div",{className:"grid w-full flex-1 gap-0.5",style:{gridTemplateColumns:"repeat(".concat(a,", ").concat(d,")"),gridTemplateRows:"repeat(".concat(t,", ").concat(u,")"),height:"auto"},role:"grid",children:Array.from({length:t*a}).map((e,s)=>{let n=function(e,t,a,r,s){let n,o,l=Math.abs(e/(a-1)-t/(r-1));return l<.33?(n=.05,o=.15):l<.66?(n=.02,o=.08):(n=.01,o=.04),n+(73*e+37*t+41*s)%100/100*(o-n)}(Math.floor(s/a),s%a,t,a,c);return(0,r.jsx)("div",{className:"rounded-sm border border-border/50 transition-all duration-150 hover:brightness-95",style:{backgroundColor:"hsl(var(--foreground) / ".concat(n,")")}},s)})}),o&&(0,r.jsx)("div",{className:"w-0 sm:w-2"})]}),o&&(0,r.jsxs)("div",{className:"flex items-start gap-2 sm:gap-4",children:[o&&(0,r.jsx)("div",{style:{width:"".concat(60,"px")}}),(0,r.jsx)("div",{className:"grid w-full flex-1 gap-1 text-center",style:{gridTemplateColumns:"repeat(".concat(a,", ").concat(d,")")},children:Array.from({length:a}).map((e,t)=>(0,r.jsx)("div",{className:"flex items-center justify-center",children:(0,r.jsx)("div",{className:"h-2.5 w-8 animate-pulse rounded-sm bg-muted/40"})},t))}),o&&(0,r.jsx)("div",{className:"w-0 sm:w-2"})]}),l&&(0,r.jsx)("div",{className:"flex justify-center text-center",children:(0,r.jsx)("div",{className:"h-3 w-16 animate-pulse rounded-sm bg-muted/40"})})]})}function e$(e){var t,a,s,n,o,l,i,c,d,u,m,x,h,f,p,g;let{cell:v,dataType:y,score1:b,score2:j,score1Color:N,score2Color:C,totalMatchedPairs:S}=e,w=null!=(g=null==(t=v.metadata)?void 0:t.percentage)?g:0;return(0,r.jsxs)("div",{className:"space-y-2","data-sentry-component":"HeatmapTooltipContent","data-sentry-source-file":"HeatmapCard.tsx",children:[(0,r.jsx)("div",{className:"border-b border-border pb-2",children:(0,r.jsx)("p",{className:"text-sm font-medium text-muted-foreground",children:"NUMERIC"===y?"Bin ".concat(v.row,"\xd7").concat(v.col):"".concat(null==(a=v.metadata)?void 0:a.rowCategory," â ").concat(null==(s=v.metadata)?void 0:s.colCategory)})}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsxs)("p",{className:"text-base font-semibold text-foreground",children:[v.value.toLocaleStr
1ing()," observations"]}),(0,r.jsxs)("p",{className:"text-xs text-muted-foreground",children:[w.toFixed(1),"% of ",S.toLocaleString()," ","matched pairs"]})]}),(0,r.jsx)("div",{className:"space-y-1 border-t border-border pt-2",children:"NUMERIC"===y?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"h-3 w-3 flex-shrink-0 rounded-sm",style:{backgroundColor:N}}),(0,r.jsxs)("span",{className:"flex-1 text-xs text-muted-foreground",children:[b.name," (",b.source,")"]}),(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[null==(l=v.metadata)||null==(o=l.yRange)||null==(n=o[0])?void 0:n.toFixed(2)," -"," ",null==(d=v.metadata)||null==(c=d.yRange)||null==(i=c[1])?void 0:i.toFixed(2)]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"h-3 w-3 flex-shrink-0 rounded-sm",style:{backgroundColor:C}}),(0,r.jsxs)("span",{className:"flex-1 text-xs text-muted-foreground",children:[null==j?void 0:j.name," (",null==j?void 0:j.source,")"]}),(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[null==(x=v.metadata)||null==(m=x.xRange)||null==(u=m[0])?void 0:u.toFixed(2)," -"," ",null==(p=v.metadata)||null==(f=p.xRange)||null==(h=f[1])?void 0:h.toFixed(2)]})]})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"h-3 w-3 flex-shrink-0 rounded-sm",style:{backgroundColor:N}}),(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[b.name," (",b.source,")"]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"h-3 w-3 flex-shrink-0 rounded-sm",style:{backgroundColor:C}}),(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[null==j?void 0:j.name," (",null==j?void 0:j.source,")"]})]})]})})]})}function eQ(){var e,t;let{data:a,isLoading:s,params:o,getColorForScore:l}=X(),i=(null==a?void 0:a.heatmap)&&a.heatmap.cells&&a.heatmap.cells.length>0?"maxValue"in a.heatmap&&"number"==typeof a.heatmap.maxValue?a.heatmap.maxValue:Math.max(...a.heatmap.cells.map(e=>e.value)):0,c=(0,n.useCallback)(e=>U(1,e.value,0,i),[i]);if(s)return(0,r.jsxs)(eo.Zp,{children:[(0,r.jsxs)(eo.aR,{children:[(0,r.jsx)(eo.ZB,{children:"Score Comparison"}),(0,r.jsx)(eo.BT,{children:"Loading heatmap..."})]}),(0,r.jsx)(eo.Wu,{className:"flex flex-1 flex-col items-center justify-center pl-1",children:(0,r.jsx)(x.A,{className:"h-8 w-8 animate-spin text-muted-foreground"})})]});if(!a)return(0,r.jsxs)(eo.Zp,{children:[(0,r.jsxs)(eo.aR,{children:[(0,r.jsx)(eo.ZB,{children:"Score Comparison"}),(0,r.jsx)(eo.BT,{children:"No data available"})]}),(0,r.jsx)(eo.Wu,{className:"flex flex-1 flex-col items-center justify-center pl-0 text-sm text-muted-foreground",children:"Select a score to view comparison"})]});let{heatmap:d,metadata:u,statistics:m}=a,{mode:h,dataType:f}=u,{score1:p,score2:g}=o,v=null!=(t=null==(e=m.comparison)?void 0:e.matchedCount)?t:0,y="NUMERIC"===f?"Score Comparison Heatmap":"Confusion Matrix",b="single"===h?"NUMERIC"===f?"Distribution of matched score pairs showing correlation patterns":"Agreement matrix between categorical scores":"NUMERIC"===f?"".concat(v.toLocaleString()," matched pairs showing correlation patterns"):"".concat(v.toLocaleString()," matched pairs showing agreement");if("single"===h)return(0,r.jsxs)(eo.Zp,{children:[(0,r.jsxs)(eo.aR,{children:[(0,r.jsx)(eo.ZB,{children:y}),(0,r.jsx)(eo.BT,{children:b})]}),(0,r.jsxs)(eo.Wu,{className:"flex flex-1 flex-col items-center gap-4 pl-0",children:[(0,r.jsx)(eq,{rows:10,cols:10,cellHeight:Math.floor(20),showLabels:!0,showAxisLabels:!0}),(0,r.jsx)("p",{className:"text-center text-sm font-light text-muted-foreground",children:"Select a second score to view comparison heatmap"})]})]});let j=d&&d.cells.length>0,N="NUMERIC"===f?10:d&&"rows"in d?d.rows:10,C=Math.floor(200/N);return(0,r.jsxs)(eo.Zp,{"data-sentry-element":"Card","data-sentry-component":"HeatmapCard","data-sentry-source-file":"HeatmapCard.tsx",children:[(0,r.jsx)(eo.aR,{"data-sentry-element":"CardHeader","data-sentry-source-file":"HeatmapCard.tsx",children:(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsxs)("div",{className:"flex items-start justify-between",children:[(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsxs)(eo.ZB,{className:"flex items-center gap-2","data-sentry-element":"CardTitle","data-sentry-source-file":"HeatmapCard.tsx",children:[y,a.samplingMetadata.isSampled&&(0,r.jsx)(em,{samplingMetadata:a.samplingMetadata,showLabel:!0})]}),(0,r.jsx)(eo.BT,{"data-sentry-element":"CardDescription","data-sentry-source-file":"HeatmapCard.tsx",children:b})]}),j&&(0,r.jsx)(eG,{min:0,max:i,scoreNumber:1,orientation:"horizontal",steps:5})]}),(0,r.jsx)("div",{className:"h-10"})]})}),(0,r.jsx)(eo.Wu,{className:"flex flex-1 flex-col items-center gap-4 pl-0","data-sentry-element":"CardContent","data-sentry-source-file":"HeatmapCard.tsx",children:j?(0,r.jsx)(ez,{height:"100%",cellHeight:C,data:d.cells,rows:"NUMERIC"===f?10:"rows"in d?d.rows:0,cols:"NUMERIC"===f?10:"cols"in d?d.cols:0,rowLabels:d.rowLabels,colLabels:d.c
1olLabels,xAxisLabel:"".concat(null==g?void 0:g.name," (").concat(null==g?void 0:g.source,")"),yAxisLabel:"".concat(p.name," (").concat(p.source,")"),getColor:c,showValues:!1,renderTooltip:e=>(0,r.jsx)(e$,{cell:e,dataType:f,score1:p,score2:g,score1Color:l(1),score2Color:l(2),totalMatchedPairs:v})}):(0,r.jsx)(eq,{rows:N,cols:"NUMERIC"===f?10:d&&"cols"in d?d.cols:10,cellHeight:C,showLabels:!0,showAxisLabels:!0})})]})}var eY=a(73215);function eJ(){let{isEstimating:e,estimate:t,isLoading:a,data:s}=X(),[o,l]=(0,n.useState)(!1);if((0,n.useEffect)(()=>{if(e||t&&a){let e=setTimeout(()=>{l(!0)},1500);return()=>clearTimeout(e)}l(!1)},[e,t,a]),!e&&!t)return null;if(e||t&&a){let e=t&&t.estimatedMatchedCount>1e5;return o||e?(0,r.jsx)("div",{className:"mb-4 rounded-md bg-muted px-4 py-3",children:(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)(eY.A,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),(0,r.jsxs)("div",{className:"flex-1 space-y-1",children:[(0,r.jsx)("div",{className:"text-sm font-medium",children:e?"Processing large dataset...":"Loading analytics..."}),t&&(0,r.jsxs)("div",{className:"text-sm text-muted-foreground",children:["single"===t.mode?"Analyzing ~".concat(t.score1Count.toLocaleString()," scores"):"Analyzing ~".concat(t.score1Count.toLocaleString()," (Score 1) and ~").concat(t.score2Count.toLocaleString()," (Score 2) scores"),t.willSample&&" ⢠Sampling will be applied",t.estimatedQueryTime&&(0,r.jsxs)(r.Fragment,{children:[" ⢠Est. time: ",t.estimatedQueryTime]})]})]})]})}):null}if(null==s?void 0:s.samplingMetadata.isSampled){var i,c,d;return(0,r.jsx)("div",{className:"mb-4 rounded-md bg-muted px-4 py-3",children:(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)(eu.A,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),(0,r.jsxs)("div",{className:"flex-1 space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium",children:["Sampled Data",(0,r.jsx)(em,{samplingMetadata:s.samplingMetadata,mode:s.metadata.mode})]}),(0,r.jsx)("div",{className:"text-sm text-muted-foreground",children:"single"===s.metadata.mode?"Results based on a ".concat((100*s.samplingMetadata.samplingRate).toFixed(2),"% sample of ~").concat(null==(i=s.samplingMetadata.preflightEstimates)?void 0:i.score1Count.toLocaleString()," scores."):"Results based on a ".concat((100*s.samplingMetadata.samplingRate).toFixed(2),"% sample of ~").concat(null==(c=s.samplingMetadata.preflightEstimates)?void 0:c.score1Count.toLocaleString()," Score 1 and ~").concat(null==(d=s.samplingMetadata.preflightEstimates)?void 0:d.score2Count.toLocaleString()," Score 2 data.")})]})]})})}return null}function e0(){let{data:e}=X();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eJ,{"data-sentry-element":"ScoreAnalyticsNoticeBanner","data-sentry-source-file":"ScoreAnalyticsDashboard.tsx"}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-4 xl:grid-cols-2",children:[(0,r.jsx)(ex,{"data-sentry-element":"StatisticsCard","data-sentry-source-file":"ScoreAnalyticsDashboard.tsx"}),(0,r.jsx)(eI,{"data-sentry-element":"TimelineChartCard","data-sentry-source-file":"ScoreAnalyticsDashboard.tsx"}),(()=>{if(!e)return(0,r.jsx)(eP,{});let{dataType:t}=e.metadata;switch(t){case"NUMERIC":default:return(0,r.jsx)(eP,{});case"CATEGORICAL":return(0,r.jsx)(eH,{});case"BOOLEAN":return(0,r.jsx)(eW,{})}})(),(0,r.jsx)(eQ,{"data-sentry-element":"HeatmapCard","data-sentry-source-file":"ScoreAnalyticsDashboard.tsx"})]})]})}function e1(){let e=(0,s.useRouter)().query.projectId,{state:t,setScore2:a}=c(),{timeRange:i,setTimeRange:f}=(0,d.D)(),{data:p,isLoading:g,error:v}=h.FH.scoreAnalytics.getScoreIdentifiers.useQuery({projectId:e},{enabled:!!e}),y=(0,n.useMemo)(()=>{if(!(null==p?void 0:p.scores))return[];let e={BOOLEAN:0,CATEGORICAL:1,NUMERIC:2};return p.scores.map(e=>({value:e.value,name:e.name,dataType:e.dataType,source:e.source})).sort((t,a)=>{var r,s;let n=null!=(r=e[t.dataType])?r:999,o=null!=(s=e[a.dataType])?s:999;return n!==o?n-o:t.name.localeCompare(a.name)})},[p]),b=(0,n.useMemo)(()=>{if(!t.score1)return;let e=y.find(e=>e.value===t.score1);return null==e?void 0:e.dataType},[t.score1,y]),j=(0,n.useMemo)(()=>
1{if(b)return[b]},[b]),N=(0,n.useRef)(void 0);(0,n.useEffect)(()=>{if(void 0===N.current){N.current=b;return}N.current!==b&&t.score2&&a(void 0),N.current=b},[b,t.score2,a]);let C=(0,n.useMemo)(()=>{if(!t.score1)return;let e=y.find(e=>e.value===t.score1);if(e)return{name:e.name,dataType:e.dataType,source:e.source}},[t.score1,y]),S=(0,n.useMemo)(()=>{if(!t.score2)return;let e=y.find(e=>e.value===t.score2);if(e)return{name:e.name,dataType:e.dataType,source:e.source}},[t.score2,y]),w=(0,n.useMemo)(()=>(0,u.b5)(i),[i]),M=(0,n.useMemo)(()=>w?(0,u.Aw)(w.from,w.to):{count:1,unit:"day"},[w]),T=(0,n.useMemo)(()=>{if(C&&e&&(null==w?void 0:w.from)&&(null==w?void 0:w.to))return{projectId:e,score1:C,score2:S,fromTimestamp:w.from,toTimestamp:w.to,interval:M,objectType:t.objectType}},[C,S,e,w,M,t.objectType]),k=!!v,L=!g&&0===y.length&&!v,A=!k&&!L&&!t.score1;return(0,r.jsx)(o.A,{headerProps:{title:"Scores",breadcrumb:[{name:"Scores",href:"/project/".concat(e,"/scores")}],help:{description:"A score is an evaluation of a trace or observation. It can be created from user feedback, model-based evaluations, or manual review. See docs to learn more.",href:"https://langfuse.com/docs/evaluation/overview"},tabsProps:{tabs:(0,l.U)(e),activeTab:l.$.ANALYTICS}},"data-sentry-element":"Page","data-sentry-component":"ScoresAnalyticsV2Page","data-sentry-source-file":"analytics.tsx",children:(0,r.jsxs)("div",{className:"flex max-h-full flex-col gap-0",children:[!k&&!L&&(0,r.jsx)(en,{scoreOptions:y,timeRange:i,onTimeRangeChange:f,compatibleScore2DataTypes:j}),(0,r.jsx)("div",{className:"max-h-full overflow-y-scroll p-4 pt-6",children:k?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4 roun
1ded-lg border bg-destructive/10 p-12",children:[(0,r.jsx)(m.A,{className:"h-12 w-12 text-destructive"}),(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("h3",{className:"text-lg font-semibold",children:"Error Loading Scores"}),(0,r.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Failed to load score data. Please try refreshing the page."})]})]}):L?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4 rounded-lg border bg-muted/20 p-12",children:[(0,r.jsx)(m.A,{className:"h-12 w-12 text-muted-foreground"}),(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("h3",{className:"text-lg font-semibold",children:"No Scores Available"}),(0,r.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Create scores by adding evaluations to your traces and observations."})]})]}):A?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center gap-6 rounded-lg border bg-muted/20 p-12",children:[(0,r.jsx)(m.A,{className:"h-16 w-16 text-muted-foreground"}),(0,r.jsxs)("div",{className:"max-w-2xl text-center",children:[(0,r.jsx)("h3",{className:"text-2xl font-semibold",children:"Select a Score"}),(0,r.jsx)("p",{className:"mt-3 text-base text-muted-foreground",children:"Choose one or two scores from the dropdowns above to view analytics"}),(0,r.jsxs)("div",{className:"mt-6 space-y-3 text-sm text-muted-foreground",children:[(0,r.jsxs)("div",{className:"rounded-lg bg-background/50 p-4",children:[(0,r.jsx)("p",{className:"mb-1 font-semibold text-foreground",children:"Single score selected:"}),(0,r.jsx)("p",{children:"View distribution and trends over time"})]}),(0,r.jsxs)("div",{className:"rounded-lg bg-background/50 p-4",children:[(0,r.jsx)("p",{className:"mb-1 font-semibold text-foreground",children:"Two scores selected:"}),(0,r.jsx)("p",{children:"Compare scores with heatmaps, correlation analysis, and statistical metrics"})]})]})]})]}):T?(0,r.jsx)(z,{params:T,children:(0,r.jsx)(e0,{})}):(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4 roun
1ded-lg border p-12",children:[(0,r.jsx)(x.A,{className:"h-12 w-12 animate-spin text-muted-foreground"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loading analytics data..."})]})})]})})}},90859:(e,t,a)=>{"use strict";a.d(t,{Xi:()=>c,av:()=>d,j7:()=>i,tU:()=>l});var r=a(73154),s=a(96810),n=a(5746),o=a(81509);let l=n.bL,i=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)(n.B8,{ref:t,className:(0,o.cn)("inline-flex h-8 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",a),...s})});i.displayName=n.B8.displayName;let c=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)(n.l9,{ref:t,className:(0,o.cn)("inline-flex h-6 items-center justify-center whitespace-nowrap rounded-sm px-2 py-0.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",a),...s})});c.displayName=n.l9.displayName;let d=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)(n.UC,{ref:t,className:(0,o.cn)("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",a),...s})});d.displayName=n.UC.displayName},95266:(e,t,a)=>{"use strict";a.d(t,{G7:()=>m,Gj:()=>u,L$:()=>f,fx:()=>p,h_:()=>g,oI:()=>x,uB:()=>d,xL:()=>h});var r=a(73154),s=a(96810),n=a(2198),o=a(80676),l=a(27131),i=a(81509),c=a(14183);let d=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)(o.uB,{ref:t,className:(0,i.cn)("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",a),...s})});d.displayName=o.uB.displayName;let u=e=>{let{children:t,filter:a,...s}=e;return(0,r.jsx)(c.lG,{...s,"data-sentry-element":"Dialog","data-sentry-component":"CommandDialog","data-sentry-source-file":"command.tsx",children:(0,r.jsxs)(c.Cf,{className:"overflow-hidden p-0 shadow-lg",closeOnInteractionOutside:!0,"data-sentry-element":"DialogContent","data-sentry-source-file":"command.tsx",children:[(0,r.jsx)(c.c7,{className:"sr-only p-0","data-sentry-element":"DialogHeader","data-sentry-source-file":"command.tsx",children:(0,r.jsx)(n.L3,{"data-sentry-element":"DialogTitle","data-sentry-source-file":"command.tsx",children:"Search"})}),(0,r.jsx)(c.R4,{className:"p-0","data-sentry-element":"DialogBody","data-sentry-source-file":"command.tsx",children:(0,r.jsx)(d,{filter:a,className:"pb-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12","data-sentry-element":"Command","data-sentry-source-file":"command.tsx",children:t})})]})})},m=s.forwardRef((e,t)=>{let{className:a,showBorder:s=!0,...n}=e;return(0,r.jsxs)("div",{className:(0,i.cn)("relative flex items-center p-1",s&&"border-b","cmdk-input-wrapper"),children:[(0,r.jsx)(l.A,{className:"absolute left-2 top-1/2 mr-2 h-3.5 w-3.5 shrink-0 -translate-y-1/2 opacity-50"}),(0,r.jsx)(o.uB.Input,{ref:t,className:(0,i.cn)("flex h-8 w-full rounded-md bg-transparent py-3 pl-6 pr-6 text-sm outline-none placeholder:text-muted-foreground focus:outline-none focus:ring-0 disabled:cursor-not-allowed disabled:opacity-50",a),...n})]})});m.displayName=o.uB.Input.displayName;let x=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)(o.uB.List,{ref:t,className:(0,i.cn)("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...s})});x.displayName=o.uB.List.displayName;let h=s.forwardRef((e,t)=>(0,r.jsx)(o.uB.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));h.displayName=o.uB.Empty.displayName;let f=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)(o.uB.Group,{ref:t,className:(0,i.cn)("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",a),...s})});f.displayName=o.uB.Group.displayName;let p=s.forwardRef((e,t)=>
1{let{className:a,...s}=e;return(0,r.jsx)(o.uB.Separator,{ref:t,className:(0,i.cn)("-mx-1 h-px bg-border",a),...s})});p.displayName=o.uB.Separator.displayName;let g=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)(o.uB.Item,{ref:t,className:(0,i.cn)(a,"relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0"),...s})});g.displayName=o.uB.Item.displayName}},e=>{e.O(0,[202,9110,1454,531,9225,6694,8780,1857,672,6928,540,9594,636,6593,8792],()=>e(e.s=55029)),_N_E=e.O()}]);
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.