@divami-artefacts/ai-design-system 1.0.56 → 1.0.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +4 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`react-dom/client`),t=require(`react`),n=require(`react/jsx-runtime`);function r({children:e,className:t=``}){return(0,n.jsx)(`div`,{className:`d3-chart ${t}`.trim(),children:e})}var i={bg:`#0C0E12`,bgL:`#0C1420`,sf:`#13161B`,bd:`#22262F`,blue:`#4C93D9`,cyan:`#36BFFA`,orange:`#EC772A`,red:`#EC772A`,green:`#5DA537`,purple:`#818FF8`,amber:`#EEBF3B`,teal:`#69DFE9`,tealDark:`#00818F`,barBg:`#7DB9DF`,t1:`#F7F9FA`,t2:`#B3B5B6`,t3:`#94979C`,t4:`#334155`},a={teal:[`#00818F`,`#69DFE9`],violet:[`#5B3CB1`,`#C8B6F3`],mint:[`#27837A`,`#81E8CE`],magenta:[`#8732A7`,`#E7A1F0`],sky:[`#0068BE`,`#8EC2F6`],blue:[`#084CF0`,`#8BA9FF`],purple:[`#5C42B8`,`#9DA5FD`],royal:[`#2556C8`,`#A9B1F8`],success:[`#58B21C`,`#97F558`],warning:[`#FFD974`,`#E4AA0D`],error:[`#EC8C42`,`#E46A0D`]},o={teal:`#69DFE9`,violet:`#C8B6F3`,mint:`#81E8CE`,magenta:`#E7A1F0`,sky:`#0068BE`,blue:`#084CF0`,purple:`#5C42B8`,royal:`#2556C8`,success:`#58B21C`,warning:`#E4AA0D`,error:`#E46A0D`},s=[i.blue,i.amber,i.purple,i.green,i.red],c=[a.teal,a.mint,a.sky,a.blue,a.royal,a.purple,a.violet,a.magenta],l=[o.teal,o.mint,o.sky,o.blue,o.royal,o.purple,o.violet,o.magenta],u={font:`400 16px 'Satoshi Variable', 'DM Sans', sans-serif`,color:`#F7F7F7`,letterSpacing:`0px`},d={font:`500 16px 'Satoshi Variable', 'DM Sans', sans-serif`,color:`#F7F7F7`},f={font:`400 18px 'Satoshi Variable', 'DM Sans', sans-serif`,color:`#B3B5B6`,letterSpacing:`0px`};function p(e,t=1){let n=e.replace(`#`,``);return`rgba(${parseInt(n.substring(0,2),16)},${parseInt(n.substring(2,4),16)},${parseInt(n.substring(4,6),16)},${t})`}function m(e,t,n){return e+(t-e)*n}function h(e,t,n){let r=e=>{let t=e.replace(`#`,``);return[parseInt(t.substring(0,2),16),parseInt(t.substring(2,4),16),parseInt(t.substring(4,6),16)]},[i,a,o]=r(e),[s,c,l]=r(t),u=e=>Math.max(0,Math.min(255,Math.round(e)));return[u(m(i,s,n)),u(m(a,c,n)),u(m(o,l,n))].map(e=>e.toString(16).padStart(2,`0`)).join(``).replace(/^/,`#`)}function g(e,t,n,r=2){e.width=t*r,e.height=n*r;let i=e.getContext(`2d`);return i.scale(r,r),i}function _(e,t,n,r,i,a=.3){let o=e.createRadialGradient(t,n,0,t,n,r);o.addColorStop(0,p(i,a)),o.addColorStop(1,p(i,0)),e.fillStyle=o,e.beginPath(),e.arc(t,n,r,0,Math.PI*2),e.fill()}function v(e,t,n,r,a=50,o=p(i.blue,.05)){for(let i=0;i<a;i++)e.beginPath(),e.arc((Math.sin(r*.001+i*23)*.5+.5)*t,(Math.cos(r*8e-4+i*37)*.5+.5)*n,.6,0,Math.PI*2),e.fillStyle=o,e.fill()}function y(e,t,n,r,i=.015){e.fillStyle=`rgba(0,0,0,${i})`;let a=r*.5%6;for(let r=a;r<n;r+=3)e.fillRect(0,r,t,1)}function b(e,t,n,r,a=p(i.t1,.08)){e.strokeStyle=a,e.lineWidth=1,e.setLineDash([3,3]),e.beginPath(),e.moveTo(t,n),e.lineTo(t,r),e.stroke(),e.setLineDash([])}function x({visible:e,x:r,y:a,content:o,parentW:s,parentH:c}){let l=(0,t.useRef)(null);if((0,t.useLayoutEffect)(()=>{let t=l.current;if(!t)return;let n=t.offsetWidth,u=t.offsetHeight,d=s??400,f=c??800,p=r+14,m=a-u-14;p+n>d-4&&(p=r-n-14),m<4&&(m=a+14),p<4&&(p=4),m+u>f-4&&(m=f-u-4),t.style.transform=`translate(${p}px, ${m}px)`,t.style.opacity=e?`1`:`0`;let h=o&&typeof o==`object`&&o.color?o.color:i.blue;t.style.setProperty(`--tooltip-accent`,h??i.blue)},[e,r,a,s,o]),!o)return null;let u=typeof o==`object`,d=u?o.label:null,f=u?o.value:o,p=u?o.sublabel:null;return(0,n.jsxs)(`div`,{ref:l,style:{position:`absolute`,top:0,left:0,minWidth:80,pointerEvents:`none`,background:i.sf,border:`1px solid ${i.bd}`,borderLeft:`2px solid var(--tooltip-accent)`,borderRadius:6,padding:`8px 12px`,opacity:0,transition:`opacity 0.15s ease`,zIndex:20,fontFamily:`'Satoshi Variable', 'DM Sans', sans-serif`},children:[d&&(0,n.jsx)(`div`,{style:{fontSize:14,fontWeight:400,color:i.t2,marginBottom:3,whiteSpace:`nowrap`,lineHeight:`20px`},children:d}),f&&(0,n.jsx)(`div`,{style:{fontSize:16,fontWeight:500,color:i.t1,whiteSpace:`nowrap`,lineHeight:`22px`},children:f}),p&&(0,n.jsx)(`div`,{style:{fontSize:14,fontWeight:400,color:`var(--tooltip-accent)`,marginTop:3,whiteSpace:`nowrap`,lineHeight:`20px`},children:p})]})}function S(e,{width:n,height:r,onClick:i,enabled:a=!0}){let o=(0,t.useRef)({x:-1,y:-1,over:!1}),s=(0,t.useRef)(null),c=(0,t.useRef)([]),[l,u]=(0,t.useState)({visible:!1,x:0,y:0,content:null}),d=(0,t.useCallback)((e,t,n)=>{u({visible:!0,x:e,y:t,content:n})},[]),f=(0,t.useCallback)(()=>{u(e=>e.visible?{visible:!1,x:e.x,y:e.y,content:e.content}:e)},[]);return(0,t.useEffect)(()=>{let t=e.current;if(!t||!a)return;let l=e=>{let i=t.getBoundingClientRect(),a=n/i.width,l=r/i.height;o.current.x=(e.clientX-i.left)*a,o.current.y=(e.clientY-i.top)*l,o.current.over=!0;let u=null,p=c.current;for(let e=p.length-1;e>=0;e--)if(p[e].test(o.current.x,o.current.y)){u=p[e];break}let m=s.current;s.current=u?u.id:null,t.style.cursor=u?`pointer`:`default`,u?d((e.clientX-i.left)*a,(e.clientY-i.top)*l,u.data):m&&f()},u=()=>{o.current={x:-1,y:-1,over:!1},s.current&&(s.current=null,t.style.cursor=`default`,f())},p=()=>{if(s.current&&i){let e=c.current.find(e=>e.id===s.current);if(e){let a=t.getBoundingClientRect(),o=a.top+e.centerY*(a.height/r),s=a.left+e.centerX*(a.width/n),c=e.sourceY==null?void 0:a.top+e.sourceY*(a.height/r);t.dispatchEvent(new CustomEvent(`viz-item-click`,{bubbles:!0,detail:{centerClientY:o,centerClientX:s,sourceClientY:c}})),i(e.id,e.data)}}};return t.addEventListener(`mousemove`,l),t.addEventListener(`mouseleave`,u),t.addEventListener(`click`,p),()=>{t.removeEventListener(`mousemove`,l),t.removeEventListener(`mouseleave`,u),t.removeEventListener(`click`,p)}},[e,n,r,a,i,d,f]),{mouseRef:o,hoveredRef:s,tooltip:l,showTooltip:d,hideTooltip:f,hitZonesRef:c}}function C(e,t,n,r,i,a,o){e.push({id:t,data:a,centerY:r,centerX:o??n,test:(e,t)=>(e-n)**2+(t-r)**2<=i*i})}function w(e,t,n,r,i,a,o,s,c,l){e.push({id:t,data:o,centerY:s??r+a/2,centerX:c??n+i/2,sourceY:l,test:(e,t)=>e>=n&&e<=n+i&&t>=r&&t<=r+a})}var T=e=>1-(1-e)**3,E=e=>1-(1-e)**4,D=e=>e===1?1:1-2**(-10*e),O=e=>{let t=1.70158;return 1+(t+1)*(e-1)**3+t*(e-1)**2},k=(e,t=.04,n=.001)=>Math.sin(e*t)*Math.exp(-Math.min(e*n,4)),A=(e,t,n,r=T)=>{let i=Math.min(.06,.5/n),a=t*i,o=1-(n-1)*i;return r(Math.max(0,Math.min((e-a)/o,1)))};function j(e,t,n=.12){e.forEach((r,i)=>{let a=i===t?1:0,o=r+(a-r)*n;Math.abs(o-a)<.005?a===0?e.delete(i):e.set(i,1):e.set(i,o)}),t&&!e.has(t)&&e.set(t,0)}var M=760,N=250;function P({rows:e=[],variant:a,className:o,colors:s}){let c=(0,t.useRef)(null),l=(0,t.useRef)(new Map),u=(0,t.useRef)(0),{mouseRef:d,hoveredRef:f,tooltip:m,hitZonesRef:h}=S(c,{width:M,height:N});return(0,t.useEffect)(()=>{let t=c.current;if(!t)return;let n=g(t,M,N);u.current=0;let r=s?.line??i.blue,o=s?.point??i.blue,m=s?.axisLine??i.bd,v=s?.areaFill??i.blue,y={top:24,right:24,bottom:44,left:24},x=M-y.left-y.right,S=N-y.top-y.bottom,w,T=()=>{u.current++;let t=u.current;if(n.clearRect(0,0,M,N),e.length<2){w=requestAnimationFrame(T);return}let s=e.map(e=>e.pricing??0),c=Math.max(100,...s),g=t=>y.left+t/(e.length-1)*x,E=e=>y.top+(1-e/c)*S,O=D(Math.min(t/48,1)),A=Math.max(2,Math.floor(O*e.length));j(l.current,f.current),h.current=[],n.strokeStyle=p(i.bd,.2),n.lineWidth=.5;for(let e=0;e<=4;e++){let t=y.top+e/4*S;n.beginPath(),n.moveTo(y.left,t),n.lineTo(y.left+x,t),n.stroke()}if(n.strokeStyle=p(m,.4),n.lineWidth=1,n.setLineDash([]),n.beginPath(),n.moveTo(y.left,E(0)),n.lineTo(y.left+x,E(0)),n.stroke(),d.current.over&&f.current){let e=parseInt(f.current.split(`-`)[1]);isNaN(e)||b(n,g(e),y.top,y.top+S)}if(a===`area`&&A>1){let t=n.createLinearGradient(0,y.top,0,y.top+S);t.addColorStop(0,p(v,.12)),t.addColorStop(1,p(v,0)),n.fillStyle=t,n.beginPath(),n.moveTo(g(0),y.top+S);for(let t=0;t<A;t++)n.lineTo(g(t),E(e[t].pricing??0));n.lineTo(g(A-1),y.top+S),n.closePath(),n.fill()}if(A>1){n.strokeStyle=p(r,.85),n.lineWidth=2,n.setLineDash([]),n.beginPath();for(let t=0;t<A;t++){let r=g(t),i=E(e[t].pricing??0);t===0?n.moveTo(r,i):n.lineTo(r,i)}n.stroke()}for(let r=0;r<A;r++){let s=g(r),c=E(e[r].pricing??0),u=`sc-${r}`,d=l.current.get(u)??0,f=r===e.length-1;C(h.current,u,s,c,12,{label:e[r].vendor,value:String(e[r].pricing??0),color:f?i.red:o}),d>0&&_(n,s,c,16*d,o,.2*d);let m=f?k(t,.05,5e-4):0,v=a===`area`?5:6;f?(n.shadowColor=p(i.red,.5),n.shadowBlur=(8+m*4)*(1+d*.5),n.fillStyle=i.red,n.beginPath(),n.arc(s,c,(v+m*1.5)*(1+d*.3),0,Math.PI*2),n.fill(),n.shadowBlur=0):(n.fillStyle=p(o,.7+d*.3),n.beginPath(),n.arc(s,c,v+d*2,0,Math.PI*2),n.fill()),n.font=`10px 'JetBrains Mono', monospace`,n.fillStyle=p(i.t3,.6+d*.3),n.textAlign=`center`,n.fillText(e[r].vendor,s,N-14)}w=requestAnimationFrame(T)};return T(),()=>cancelAnimationFrame(w)},[e,a,s]),(0,n.jsx)(r,{className:o,children:(0,n.jsxs)(`div`,{style:{position:`relative`,width:M,height:N},children:[(0,n.jsx)(`canvas`,{ref:c,role:`img`,"aria-label":`${a} chart`,style:{width:M,height:N,display:`block`,borderRadius:8}}),(0,n.jsx)(x,{...m,parentW:M,parentH:N})]})})}function F({rows:e=[],className:t,colors:r}){return(0,n.jsx)(P,{rows:e,variant:`area`,className:t,colors:r})}var I=760,L=280;function R({rows:e=[],className:a,colors:o}){let c=(0,t.useRef)(null),l=(0,t.useRef)(new Map),u=(0,t.useRef)(0),{hoveredRef:d,tooltip:f,hitZonesRef:m}=S(c,{width:I,height:L});return(0,t.useEffect)(()=>{let t=c.current;if(!t)return;let n=g(t,I,L);u.current=0;let r=o?.bars??s,a=o?.axisLine??i.bd,f=o?.valueLabel??i.t2,h={top:24,right:24,bottom:56,left:24},v=L-h.top-h.bottom,y=(I-h.left-h.right)/Math.max(e.length,1),b=Math.max(100,...e.map(e=>e.pricing??0)),x=h.top+v,S,C=()=>{u.current++;let t=u.current;n.clearRect(0,0,I,L);let o=E(Math.min(t/48,1));j(l.current,d.current),m.current=[],n.strokeStyle=p(a,.4),n.lineWidth=1,n.setLineDash([]),n.beginPath(),n.moveTo(h.left,x),n.lineTo(I-h.right,x),n.stroke(),e.forEach((t,a)=>{let s=h.left+a*y,c=A(o,a,e.length,E),u=b>0?(t.pricing??0)/b*v:0,d=Math.max(u>0?4:0,u*c),g=r[a%r.length],S=l.current.get(t.id??`bar-${a}`)??0;w(m.current,t.id??`bar-${a}`,s+4,x-d,y-8,d,{label:t.vendor,value:String(t.pricing??0),color:g}),d>0&&(S>0&&_(n,s+y/2,x-d/2,y*.8,g,.12*S),n.shadowColor=p(g,.2*(S>0?S:0)),n.shadowBlur=S>0?6:0,n.fillStyle=p(g,.5+S*.25),n.beginPath(),n.roundRect(s+4,x-d,y-8,d,[4,4,0,0]),n.fill(),n.shadowBlur=0,S>0&&(n.strokeStyle=p(g,.4*S),n.lineWidth=1,n.beginPath(),n.roundRect(s+4,x-d,y-8,d,[4,4,0,0]),n.stroke())),c>.5&&d>0&&(n.globalAlpha=Math.min(1,(c-.5)*2),n.font=`bold 10px 'JetBrains Mono', monospace`,n.fillStyle=S>0?g:p(f,.7),n.textAlign=`center`,n.fillText(String(t.pricing??``),s+y/2,x-d-6),n.globalAlpha=1),n.font=`${S>0?`bold `:``}9px 'JetBrains Mono', monospace`,n.fillStyle=S>0?g:p(i.t3,.6),n.textAlign=`center`,n.fillText(t.vendor,s+y/2,L-14)}),S=requestAnimationFrame(C)};return C(),()=>cancelAnimationFrame(S)},[e,o]),(0,n.jsx)(r,{className:a,children:(0,n.jsxs)(`div`,{style:{position:`relative`,width:I,height:L},children:[(0,n.jsx)(`canvas`,{ref:c,role:`img`,"aria-label":`bar chart`,style:{width:I,height:L,display:`block`,borderRadius:8}}),(0,n.jsx)(x,{...f,parentW:I,parentH:L})]})})}function z(e){let n=(0,t.useRef)(null),[r,i]=(0,t.useState)(e);return(0,t.useEffect)(()=>{let e=n.current;if(!e)return;let t=new ResizeObserver(e=>{let t=e[0]?.contentRect.width;t&&t>0&&i(Math.floor(t))});return t.observe(e),()=>t.disconnect()},[]),[n,r]}function B({width:e,height:t,message:r=`No data available`,testID:i}){return(0,n.jsx)(`div`,{"data-testid":i,style:{width:e,height:t,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:8,background:`rgba(255,255,255,0.03)`,color:`rgba(255,255,255,0.35)`,fontSize:14,fontFamily:`'Satoshi Variable', 'DM Sans', sans-serif`},children:r})}function ee({expanded:e,onToggle:t,labelExpanded:r=`View Less`,labelCollapsed:i=`View More`,testID:a}){return(0,n.jsxs)(`button`,{type:`button`,"data-testid":a,onClick:t,style:{display:`flex`,width:90,height:20,justifyContent:`center`,alignItems:`center`,gap:4,boxSizing:`border-box`,border:`none`,borderRadius:6,color:`#69DFE9`,fontSize:14,fontFamily:`'Satoshi Variable', 'DM Sans', sans-serif`,fontStyle:`normal`,fontWeight:400,lineHeight:`19.5px`,textAlign:`center`,cursor:`pointer`,userSelect:`none`},children:[e?r:i,(0,n.jsx)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 10 10`,fill:`none`,style:{transform:e?`rotate(180deg)`:`rotate(0deg)`},children:(0,n.jsx)(`path`,{d:`M2 3.5L5 6.5L8 3.5`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})]})}var V=[{value:0xe8d4a51000,suffix:`T`,divisor:0xe8d4a51000},{value:1e9,suffix:`B`,divisor:1e9},{value:1e6,suffix:`M`,divisor:1e6},{value:1e3,suffix:`K`,divisor:1e3}];function H(e,t=1){let n=Math.abs(e),r=e<0?`-`:``;for(let e of V)if(n>=e.value)return`${r}${(n/e.divisor).toFixed(t)}${e.suffix}`;return`${r}${n.toFixed(0)}`}var te=660,U=4,ne=30,re=ne/2,ie=ne/2,ae=8;function oe(e,t,n){if(e.measureText(t).width<=n)return t;let r=t;for(;r.length>0&&e.measureText(r+`…`).width>n;)r=r.slice(0,-1);return r+`…`}function se({items:e=[],itemsByEntity:r,onItemClick:a,selectedId:o,colorOffset:s=0,testID:l}){let[f,m]=z(te),h=(0,t.useRef)(null),b=(0,t.useRef)(0),E=(0,t.useRef)(new Map),D=(0,t.useRef)(o);D.current=o;let O=(0,t.useRef)([]),k=(0,t.useCallback)((e,t)=>{let n=typeof t==`object`?t.label??e:e,r=O.current.find(t=>t.id===e);a?.(e,n,r?.subentity)},[a]),[A,j]=(0,t.useState)(!1),M=!!(o&&r?.[o]),N=M?r[o]:e,P=(0,t.useMemo)(()=>e.filter(e=>typeof e==`object`&&!!e),[e]),F=(0,t.useMemo)(()=>N.filter(e=>typeof e==`object`&&!!e),[N]),I=(0,t.useMemo)(()=>[...F].sort((e,t)=>(t.percentage??0)-(e.percentage??0)),[F]),L=(0,t.useMemo)(()=>A?I:I.slice(0,ae),[I,A]);O.current=L;let R=L.length,V=re+ie+R*U+Math.max(0,R-1)*ne,{hoveredRef:se,tooltip:ce,hitZonesRef:le}=S(h,{width:m,height:V,onClick:a?k:void 0});return(0,t.useEffect)(()=>{let e=h.current;if(!e)return;let t=g(e,m,V);b.current=0,t.font=u.font,t.letterSpacing=u.letterSpacing;let n=L.reduce((e,n)=>Math.max(e,t.measureText(n.name??n.abbreviation??``).width),0);t.font=d.font;let r=L.reduce((e,n)=>Math.max(e,t.measureText(H(n.total??0)).width),0),a=Math.max(Math.min(n+20,m*.3),40),o=Math.max(r+20,28),l=m-a-o,[f,x]=c[s%c.length],S,O=()=>{b.current++;let e=b.current;t.clearRect(0,0,m,V),t.letterSpacing=u.letterSpacing,le.current=[],E.current.forEach((e,t)=>{let n=t===se.current?1:0,r=e+(n-e)*.12;Math.abs(r-n)<.005?n===0?E.current.delete(t):E.current.set(t,1):E.current.set(t,r)}),se.current&&!E.current.has(se.current)&&E.current.set(se.current,0),v(t,m,V,e,40,p(x,.04));let n=Math.max(...L.map(e=>e.total??0),1);L.forEach((o,s)=>{let c=E.current.get(o.id)??0,m=!M&&D.current&&o.id!==D.current?.6:1,h=re+s*(U+ne);t.fillStyle=p(i.barBg,.2),t.beginPath(),t.rect(a,h,l,U),t.fill();let g=(o.total??0)/n,v=a+l*Math.min(g,g*T(Math.min(1,e*.005)));if(v>a+2){let e=t.createLinearGradient(a,0,v,0);e.addColorStop(0,p(f,.75*m)),e.addColorStop(1,p(x,.95*m)),t.fillStyle=e,t.beginPath(),t.rect(a,h,v-a,U),t.fill()}c>0&&_(t,v,h+U/2,12*c,x,.35*c);let y={label:o.name,sublabel:o.totalLabel??(o.total==null?void 0:H(o.total)),color:x};w(le.current,o.id,0,h-ne/2,a+l,U+ne,y,void 0,a+l+12+r+14),C(le.current,o.id,v,h+U/2,10,y),t.font=d.font,t.fillStyle=c>0?p(x,1*m):p(i.t1,.85*m),t.textAlign=`left`,t.textBaseline=`middle`,t.fillText(H(o.total??0),a+l+12,h+U/2),t.font=u.font,t.fillStyle=c>0?p(x,1*m):p(i.t2,.85*m),t.textAlign=`right`,t.fillText(oe(t,o.name??o.abbreviation??``,a-16),a-8,h+U/2)}),y(t,m,V,e,.015),S=requestAnimationFrame(O)};return O(),()=>cancelAnimationFrame(S)},[L,V,s,m]),I.length===0?(0,n.jsx)(`div`,{ref:f,style:{width:`100%`},children:(0,n.jsx)(B,{width:m,height:160,testID:l})}):(0,n.jsxs)(`div`,{ref:f,"data-testid":l,style:{width:`100%`},children:[(0,n.jsxs)(`div`,{style:{position:`relative`},children:[(0,n.jsx)(`canvas`,{ref:h,role:`img`,"aria-label":`Commitment race — contractors ranked by commitment percentage`,style:{width:`100%`,height:V,display:`block`,borderRadius:8}}),(0,n.jsx)(x,{...ce,parentW:m,parentH:V})]}),P.length>ae&&(0,n.jsx)(`div`,{style:{marginTop:8},children:(0,n.jsx)(ee,{expanded:A,onToggle:()=>j(e=>!e)})})]})}var ce=480,le=310,ue=18;function de(e,t,n){let r=t.split(` `),i=[],a=``;for(let t of r){let r=a?`${a} ${t}`:t;e.measureText(r).width>n&&a?(i.push(a),a=t):a=r}return a&&i.push(a),i}function fe({confirmed:e,total:r,label:a,colorOffset:o=0,selectedId:s,selectedLabel:l,gaugeByEntity:d,onItemClick:m,subentity:h,testID:v}){let y=(0,t.useRef)(null),b=(0,t.useRef)(0),C=s&&d?.[s]?d[s]:{confirmed:e,total:r},E=C.confirmed,D=C.total,k=(0,t.useCallback)(()=>{m?.(`confirmed`,a??`confirmed`,h)},[m,a,h]),{tooltip:A,hitZonesRef:j}=S(y,{width:ce,height:le,onClick:m?k:void 0});return(0,t.useEffect)(()=>{let e=y.current;if(!e)return;let t=g(e,ce,le);b.current=0;let[n,r]=c[o%c.length],s=ce/2,l=Math.PI,d=2*Math.PI,m=Math.PI,h,v=()=>{b.current++;let e=b.current;t.clearRect(0,0,ce,le),t.letterSpacing=u.letterSpacing,j.current=[],w(j.current,`confirmed`,s-148,27,296,148,{label:a??`Confirmed`,value:`${H(E??0)} / ${H(D??0)}`,sublabel:`${Math.round((E??0)/(D||1)*100)}%`,color:r});let o=T(Math.min(e/80,1)),c=O(Math.min(e/72,1)),g=Math.round((E??0)/(D||1)*100),y=l+g/100*m*o;t.beginPath(),t.arc(s,175,148,l,d),t.strokeStyle=p(r,.28),t.lineWidth=4,t.lineCap=`round`,t.stroke(),t.lineCap=`butt`,t.beginPath(),t.moveTo(s,175),t.arc(s,175,133,l,y),t.closePath(),t.fillStyle=p(n,.35*o),t.fill();let x=s+Math.cos(y)*148,S=175+Math.sin(y)*148;_(t,x,S,10,r,.3*o);let C=t.createLinearGradient(s+Math.cos(l)*148,175+Math.sin(l)*148,x,S);C.addColorStop(0,p(n,.9*o)),C.addColorStop(1,p(r,1*o)),t.beginPath(),t.arc(s,175,148,l,y),t.strokeStyle=C,t.lineWidth=4,t.lineCap=`round`,t.stroke(),t.lineCap=`butt`;let k=l+g/100*m*c,A=s+Math.cos(k)*133,M=175+Math.sin(k)*133,N=s-Math.cos(k)*24,P=175-Math.sin(k)*24,F=-Math.sin(k),I=Math.cos(k),L=2.5*c;t.beginPath(),t.moveTo(A,M),t.lineTo(s+F*L,175+I*L),t.lineTo(N+F*1,P+I*1),t.lineTo(N-F*1,P-I*1),t.lineTo(s-F*L,175-I*L),t.closePath(),t.fillStyle=p(i.t1,c),t.fill(),t.beginPath(),t.arc(s,175,11,0,Math.PI*2),t.strokeStyle=p(r,.85*c),t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(s,175,9,0,Math.PI*2),t.fillStyle=i.t1,t.fill(),[[0,`0%`],[.5,`50%`],[1,`100%`]].forEach(([e,n])=>{let r=l+e*m,i=e===1?184:168,a=s+Math.cos(r)*i,o=175+Math.sin(r)*i;t.font=u.font,t.fillStyle=u.color,t.textAlign=`center`,t.fillText(n,a,o+4)}),o>.4&&(t.globalAlpha=Math.min(1,(o-.4)/.4),t.font=`700 32px 'Satoshi Variable', 'DM Sans', sans-serif`,t.fillStyle=i.t1,t.textAlign=`center`,t.fillText(`${Math.round(g*c)}%`,s,247),t.globalAlpha=1),o>.7&&a&&(t.globalAlpha=Math.min(1,(o-.7)/.3),t.font=f.font,t.fillStyle=f.color,t.textAlign=`center`,de(t,`${H(E??0)} of ${H(D??0)} ${a}`,ce-40).forEach((e,n)=>{t.fillText(e,s,287+n*ue)}),t.globalAlpha=1),h=requestAnimationFrame(v)};return v(),()=>cancelAnimationFrame(h)},[E,D,a,o,s,l]),(0,n.jsxs)(`div`,{"data-testid":v,style:{position:`relative`,width:`100%`,maxWidth:ce,margin:`0 auto`},children:[(0,n.jsx)(`canvas`,{ref:y,role:`img`,"aria-label":`Compensation event gauge — ${Math.round((E??0)/(D||1)*100)}% of NCEs confirmed as compensation events`,style:{width:`100%`,aspectRatio:`${ce} / ${le}`,display:`block`}}),(0,n.jsx)(x,{...A,parentW:ce,parentH:le})]})}function pe(e,n,r,i,a=!0,o={}){let s=(0,t.useRef)(0),{easing:c=T,durationFrames:l=48}=o;(0,t.useEffect)(()=>{let t=e.current;if(!t||!n||!r)return;let o=t.getContext(`2d`);if(!o)return;t.width=n*2,t.height=r*2,o.scale(2,2);let u;s.current=0;let d=()=>{s.current++;let e=s.current;o.clearRect(0,0,n,r);let t=a?Math.min(e/l,1):1;if(i(o,c(t),e),t<1)u=requestAnimationFrame(d);else{let e=()=>{s.current++,o.clearRect(0,0,n,r),i(o,1,s.current),u=requestAnimationFrame(e)};u=requestAnimationFrame(e)}};return d(),()=>cancelAnimationFrame(u)},[n,r,a])}var W=780,me=234,he=130,ge=52,_e=[i.blue,i.amber,i.purple,i.green],ve=[`Base Value`,`Variations`,`Commitment`],ye=[`Base`,`Var`,`Commit`];function be({items:e=[],testID:r}){let a=(0,t.useRef)(null),o=(0,t.useRef)(new Map),{hoveredRef:s,tooltip:c,hitZonesRef:l}=S(a,{width:W,height:me}),d=(0,t.useMemo)(()=>e.filter(e=>typeof e==`object`&&!!e),[e]),m=(0,t.useMemo)(()=>{let e=Math.max(...d.map(e=>e.base??0)),t=Math.max(...d.map(e=>e.variation??0));return d.map((n,r)=>{let i=W*(.12+r*.19),a=he,o=Math.min(W*.075,ge),s=_e[r%_e.length],c=[(n.base??0)/(e||1)*100,(n.variation??0)/(t||1)*100,n.percentage??0],l=[n.baseLabel??String(n.base??0),n.variationLabel??String(n.variation??0),`${n.percentage??0}%`],u=c.map((e,t)=>{let n=-Math.PI/2+t/ve.length*Math.PI*2,r=e/100,s=o*Math.max(.08,r);return{name:ve[t],short:ye[t],label:l[t],val:Math.round(e),x:i+Math.cos(n)*s,y:a+Math.sin(n)*s,angle:n,norm:r}}),d=u.reduce((e,t)=>e+t.x,0)/u.length,f=u.reduce((e,t)=>e+t.y,0)/u.length,p=Math.sqrt(u.reduce((e,t)=>e+(t.x-d)**2+(t.y-f)**2,0)/u.length);return{...n,cx:i,cy:a,baseR:o,stars:u,scatter:p,color:s}})},[d]);return pe(a,W,me,(e,t,n)=>{j(o.current,s.current),l.current=[],v(e,W,me,n,30),m.forEach((t,r)=>{let a=t.color,s=`constellation-${r}`,c=o.current.get(s)??0;e.beginPath(),e.arc(t.cx,t.cy,t.baseR+5,0,Math.PI*2),e.strokeStyle=p(i.bd,.08+.08*c),e.lineWidth=.5,e.stroke(),e.beginPath(),t.stars.forEach((t,n)=>{n===0?e.moveTo(t.x,t.y):e.lineTo(t.x,t.y)}),e.closePath(),e.fillStyle=p(a,.04+.03*c),e.fill(),e.strokeStyle=p(a,.15+.1*c),e.lineWidth=.8,e.stroke(),t.stars.forEach((i,s)=>{let c=k(n,.05,5e-4)*.3+.7,d=3.5*c,f=`star-${r}-${s}`,m=o.current.get(f)??0,h=e.createRadialGradient(i.x,i.y,0,i.x,i.y,d*4);h.addColorStop(0,p(a,(.2+.1*m)*c)),h.addColorStop(1,p(a,0)),e.fillStyle=h,e.beginPath(),e.arc(i.x,i.y,d*4,0,Math.PI*2),e.fill(),e.beginPath(),e.arc(i.x,i.y,d+m*2,0,Math.PI*2),e.fillStyle=p(a,(.8+.2*m)*c),e.fill();let g=Math.sin(i.angle)<-.3;e.textAlign=`center`,e.textBaseline=`middle`,g?(e.font=u.font,e.fillStyle=p(a,.5+.15*m),e.fillText(i.short,i.x,i.y-24),e.font=u.font,e.fillStyle=p(a,.8+.15*m),e.fillText(i.label,i.x,i.y-11)):(e.font=u.font,e.fillStyle=p(a,.5+.15*m),e.fillText(i.short,i.x,i.y+11),e.font=u.font,e.fillStyle=p(a,.8+.15*m),e.fillText(i.label,i.x,i.y+24)),C(l.current,f,i.x,i.y,d*4+2,{label:i.name,value:i.label,sublabel:t.abbreviation??t.name.slice(0,6),color:a})}),c>0&&_(e,t.cx,t.cy,16*c,a,.15*c),e.beginPath(),e.arc(t.cx,t.cy,t.baseR+12,0,Math.PI*2),e.strokeStyle=p(a,.1+k(n,.03,5e-4)*.05),e.lineWidth=1,e.stroke(),e.font=u.font,e.textAlign=`center`,e.textBaseline=`alphabetic`,e.fillStyle=c>0?t.color:u.color,e.fillText(t.abbreviation??t.name.slice(0,6),t.cx,t.cy+t.baseR+26),C(l.current,s,t.cx,t.cy,t.baseR+5,{label:t.name,value:`${t.totalLabel??String(t.total??0)} total`,sublabel:`${t.percentage??0}% committed · scatter ${t.scatter.toFixed(1)}`,color:a})}),e.font=f.font,e.textAlign=`center`,e.textBaseline=`middle`,e.fillStyle=f.color,e.fillText(`▲ top = Base value · ▼▸ lower-right = Variations · ◂▼ lower-left = Commitment % · hover stars for details`,W/2,me-14),y(e,W,me,n,.012)},!0),m.length===0?(0,n.jsx)(B,{width:W,height:me,testID:r}):(0,n.jsxs)(`div`,{"data-testid":r,style:{position:`relative`,width:W,height:me},children:[(0,n.jsx)(`canvas`,{ref:a,role:`img`,"aria-label":`Contract value breakdown per contractor — multi-KPI constellation chart`,style:{width:W,height:me,display:`block`}}),(0,n.jsx)(x,{...c,parentW:W,parentH:me})]})}var xe=680,Se=220,Ce=8,we=[i.teal],G={left:8,right:100,top:16,bottom:38},Te=150,K=6;function Ee(e,t,n){if(e.measureText(t).width<=n)return t;let r=t;for(;r.length>0&&e.measureText(r+`…`).width>n;)r=r.slice(0,-1);return r+`…`}function De(e){let t=Math.abs(e),n=e<0?`-`:``;return t>=1e6?`${n}£${(t/1e6).toFixed(1)}M`:t>=1e3?`${n}£${(t/1e3).toFixed(1)}K`:`${n}£${t.toFixed(0)}`}function Oe({data:e,dataByEntity:r,onItemClick:a,selectedId:o,testID:s}){let[c,l]=z(xe),m=(0,t.useRef)(null),h=(0,t.useRef)(new Map),g=(0,t.useRef)(o);g.current=o;let v=(0,t.useCallback)((e,t)=>{let n=typeof t==`object`?t.label??e:e,r=R.current.visibleItems.find(t=>t.id===e);a?.(e,n,r?.subentity)},[a]),[y,b]=(0,t.useState)(!1),C=!!(o&&r?.[o]),{items:T=[],totals:D}=C?r[o]:e,O=T.filter(e=>typeof e==`object`&&!!e),k=[...O].sort((e,t)=>(t.total??0)-(e.total??0)),M=y?k:k.slice(0,Ce),N=M.length,P=Math.max(...k.map(e=>Math.abs(e.total??0)),1),F=N*K+Math.max(0,N-1)*38,I=G.top+G.bottom+F,L=l-G.left-Te-G.right,R=(0,t.useRef)({visibleItems:M,maxCommitment:P,totals:D,barArea:L,BAR_GAP:38,n:N,dynamicH:I,isDrillMode:C});R.current={visibleItems:M,maxCommitment:P,totals:D,barArea:L,BAR_GAP:38,n:N,dynamicH:I,isDrillMode:C};let V=(e.items??[]).filter(e=>typeof e==`object`&&!!e).length===0,{hoveredRef:H,tooltip:te,hitZonesRef:U}=S(m,{width:l,height:I,onClick:a?v:void 0});return pe(m,l,I,(e,t)=>{let{visibleItems:n,maxCommitment:r,totals:a,barArea:o,BAR_GAP:s,n:c,dynamicH:m,isDrillMode:v}=R.current;j(h.current,H.current),U.current=[],n.forEach((n,a)=>{let l=we[a%we.length],f=A(t,a,c,E),m=G.top+a*(K+s),y=G.left+Te,b=h.current.get(n.id)??0,x=!v&&g.current&&n.id!==g.current?.2:1,S=Math.max(n.total??0,0)/r*o*f;if(e.font=u.font,e.fillStyle=b>0?l:u.color,e.textAlign=`right`,e.textBaseline=`middle`,e.fillText(Ee(e,n.name??``,Te-16),y-8,m+K/2),w(U.current,n.id,0,m,y,K,{label:n.name,value:`${n.totalLabel??De(n.total??0)} total`,sublabel:`Base ${n.baseLabel??De(n.base??0)} + Var ${n.variationLabel??De(n.variation??0)}`,color:l}),S>0){b>0&&_(e,y+S/2,m+K/2,S*.15,i.teal,.12*b);let t=e.createLinearGradient(y,0,y+S,0);t.addColorStop(0,p(i.tealDark,.85*x)),t.addColorStop(1,p(i.teal,1*x)),e.fillStyle=t,e.beginPath(),e.rect(y,m,S,K),e.fill()}let C=L*f,T=y+S,D=C-S;if(D>2&&(e.fillStyle=p(i.barBg,.2),e.beginPath(),e.rect(T,m,D,K),e.fill()),S>4){let t=y+S,n=m+K;e.strokeStyle=p(i.t4,.9*f),e.lineWidth=4,e.beginPath(),e.moveTo(t,m),e.lineTo(t,n),e.stroke();let r=n+3,a={x:t,y:r},o={x:t+10,y:r+12},s={x:t-10,y:r+12};e.fillStyle=p(i.t1,f),e.beginPath(),e.moveTo((a.x+o.x)/2,(a.y+o.y)/2),e.arcTo(o.x,o.y,s.x,s.y,1),e.arcTo(s.x,s.y,a.x,a.y,1),e.arcTo(a.x,a.y,o.x,o.y,1),e.closePath(),e.fill()}f>.35&&(e.globalAlpha=Math.min(1,(f-.35)/.4)*x,e.font=d.font,e.fillStyle=b>0?l:d.color,e.textAlign=`left`,e.textBaseline=`middle`,e.fillText(n.totalLabel??De(n.total??0),y+o+28,m+K/2),e.globalAlpha=1),w(U.current,n.id,y,m,Math.max(S,1),K,{label:n.name,value:n.totalLabel??De(n.total??0),sublabel:`${n.baseLabel??De(n.base??0)} + ${n.variationLabel??De(n.variation??0)}`,color:l})});let y=m-14;e.textBaseline=`middle`,e.font=f.font,e.textAlign=`left`;let b=e.createLinearGradient(G.left+Te,0,G.left+Te+14,0);b.addColorStop(0,p(i.tealDark,.85)),b.addColorStop(1,p(i.teal,1)),e.fillStyle=b,e.beginPath(),e.rect(G.left+Te,y-6,12,12),e.fill(),e.fillStyle=f.color,e.fillText(`base value`,G.left+Te+16,y),e.fillStyle=p(i.teal,.35),e.beginPath(),e.rect(G.left+Te+160,y-6,12,12),e.fill(),e.fillStyle=f.color,e.fillText(`approved variations`,G.left+Te+176,y),e.font=f.font,e.textAlign=`right`,e.fillStyle=f.color,e.fillText(`Portfolio: ${De(a?.total??0)}`,l-8,y)},!0,{easing:E}),V?(0,n.jsx)(`div`,{ref:c,style:{width:`100%`},children:(0,n.jsx)(B,{width:l,height:Se,message:`No contract data available`,testID:s})}):(0,n.jsxs)(`div`,{ref:c,"data-testid":s,style:{width:`100%`},children:[(0,n.jsxs)(`div`,{style:{position:`relative`},children:[(0,n.jsx)(`canvas`,{ref:m,role:`img`,"aria-label":`Total contract value per contractor — horizontal bar chart`,style:{width:`100%`,height:I,display:`block`,borderRadius:8}}),(0,n.jsx)(x,{...te,parentW:l,parentH:I})]}),O.length>Ce&&(0,n.jsx)(`div`,{style:{marginTop:8},children:(0,n.jsx)(ee,{expanded:y,onToggle:()=>b(e=>!e)})})]})}var ke=780,Ae=240,je=12,Me=10,Ne=5;function Pe({items:e=[],onItemClick:r,testID:a}){let[o,c]=z(ke),l=(0,t.useRef)(null),f=(0,t.useRef)(0),m=(0,t.useRef)(new Map),h=[...(0,t.useMemo)(()=>e.filter(e=>typeof e==`object`&&!!e),[e])].sort((e,t)=>(t.count??0)-(e.count??0)).slice(0,5),v=h.reduce((e,t)=>e+(t.count??0),0),b=(0,t.useRef)(h);b.current=h;let C=(0,t.useCallback)((e,t)=>{let n=typeof t==`object`?t.label??e:e,i=b.current.find(t=>t.id===e);r?.(e,n,i?.subentity)},[r]),T=Math.min(Ne,h.length),E=T>0?(c-2*je-(T-1)*Me)/T:(c-2*je)/Ne,{hoveredRef:D,tooltip:O,hitZonesRef:A}=S(l,{width:c,height:Ae,onClick:r?C:void 0});return(0,t.useEffect)(()=>{let e=l.current;if(!e)return;let t=g(e,c,Ae);f.current=0;let n=Ae*.84,r=Ae*.08,a=je,o,b=()=>{f.current++;let e=f.current;t.clearRect(0,0,c,Ae),t.letterSpacing=u.letterSpacing,A.current=[],m.current.forEach((e,t)=>{let n=t===D.current?1:0,r=e+(n-e)*.12;Math.abs(r-n)<.005?n===0?m.current.delete(t):m.current.set(t,1):m.current.set(t,r)}),D.current&&!m.current.has(D.current)&&m.current.set(D.current,0),h.forEach((o,c)=>{let l=c===0,u=c===0?i.red:c===1?i.amber:s[c%s.length],f=a+c*(E+Me),h=m.current.get(o.id)??0,g=h*8,y=f-g/2,b=E+g,x=l?k(e,.04,3e-4)*.06+.06:0;t.fillStyle=p(u,.08+h*.07),t.beginPath(),t.roundRect(y,r,b,n,6),t.fill(),t.strokeStyle=p(u,.2+h*.4+x),t.lineWidth=l?1.5:1,t.stroke(),(h>.01||l)&&_(t,y+b/2,r+n/2,b*.55,u,x+h*.14),t.font=d.font,t.textAlign=`left`,t.textBaseline=`top`,t.fillStyle=p(u,.5+h*.35),t.fillText(`#${c+1}`,y+7,r+6);let S=Math.min(E*.28,n*.32,72),C=y+b/2,T=r+n*.38,D=t.createRadialGradient(C,T-S*.2,0,C,T,S);D.addColorStop(0,p(u,.5+h*.2)),D.addColorStop(1,p(u,.2+h*.1)),t.beginPath(),t.arc(C,T,S,0,Math.PI*2),t.fillStyle=D,t.fill(),t.strokeStyle=p(u,.4+h*.3),t.lineWidth=1,t.stroke(),t.font=d.font,t.textAlign=`center`,t.textBaseline=`middle`,t.fillStyle=p(i.t1,.9);let O=o.abbreviation??o.name??``,j=S*1.7,M=O;for(;t.measureText(M).width>j&&M.length>1;)M=M.slice(0,-1);M!==O&&(M=M.slice(0,-1)+`…`),t.fillText(M,C,T);let N=o.count==null?null:H(o.count),P=o.label??N;if(P){t.font=d.font,t.textBaseline=`alphabetic`,t.fillStyle=p(u,.9+h*.1);let e=b-16,i=P;for(;t.measureText(i).width>e&&i.length>1;)i=i.slice(0,-1);i!==P&&(i=i.slice(0,-1)+`…`),t.fillText(i,C,r+n*.74)}let F=Math.round((o.count??0)/(v||1)*100);w(A.current,o.id,f,r,E,n,{label:o.name,value:`${P} · ${F}% of total`,sublabel:`Rank #${c+1}`,color:u})}),y(t,c,Ae,e,.015),o=requestAnimationFrame(b)};return b(),()=>cancelAnimationFrame(o)},[h,v,c]),h.length===0?(0,n.jsx)(B,{width:c,height:Ae,testID:a}):(0,n.jsxs)(`div`,{"data-testid":a,style:{position:`relative`,width:c,height:Ae},children:[(0,n.jsx)(`canvas`,{ref:l,role:`img`,"aria-label":`Contractor rank — open EW count per contractor`,style:{width:c,height:Ae,display:`block`,borderRadius:8}}),(0,n.jsx)(x,{...O,parentW:c,parentH:Ae})]})}var q=680,J=260;function Fe({items:e=[],testID:r}){let a=(0,t.useRef)(null),o=(0,t.useRef)(0),s=(0,t.useRef)(new Map),{hoveredRef:c,tooltip:l,hitZonesRef:d}=S(a,{width:q,height:J}),f=(0,t.useMemo)(()=>e.filter(e=>typeof e==`object`&&!!e),[e]);return(0,t.useEffect)(()=>{let e=a.current;if(!e)return;let t=g(e,q,J);o.current=0;let n=f.length,r=Math.max(...f.map(e=>e.count),1),l=r,m=q*.05,h=J*.1,b=q*.9/n,x=J*.7/l,S=f.reduce((e,t)=>e+t.count,0),w,T=()=>{o.current++;let e=o.current;t.clearRect(0,0,q,J),d.current=[],s.current.forEach((e,t)=>{let n=t===c.current?1:0,r=e+(n-e)*.12;Math.abs(r-n)<.005?n===0?s.current.delete(t):s.current.set(t,1):s.current.set(t,r)}),c.current&&!s.current.has(c.current)&&s.current.set(c.current,0),v(t,q,J,e,40,p(i.blue,.04)),f.forEach((n,a)=>{let o=n.count===r,c=i.blue,f=s.current.get(`${n.category}-col`)??0;for(let i=0;i<l;i++){let l=m+a*b+b/2,u=h+i*x+x/2,g=Math.min(b,x)*.38;if(i>=r-n.count){let r=g*(1+(k(e,.04,5e-4)+Math.sin(a*.6+i*1.2)*.3)*.12);(o||f>.01)&&_(t,l,u,r*3,c,(o?.2:.1)+f*.1),t.beginPath(),t.arc(l,u,r,0,Math.PI*2),t.fillStyle=p(c,o?.8:.5+f*.2),t.fill();let m=`${n.category}-${i}`;C(d.current,m,l,u,g+4,{label:n.fullName,value:`${n.count} Early Warnings`,sublabel:`${Math.round(n.count/S*100)}% of total`,color:c}),s.current.get(`${n.category}-col`)}else t.beginPath(),t.arc(l,u,1,0,Math.PI*2),t.fillStyle=p(c,.08),t.fill()}let g=h+l*x+16;t.font=u.font,t.textAlign=`center`,t.textBaseline=`alphabetic`,t.fillStyle=o?i.blue:p(i.t2,.65),t.fillText(n.category,m+a*b+b/2,g)}),y(t,q,J,e,.015),w=requestAnimationFrame(T)};return T(),()=>cancelAnimationFrame(w)},[f]),f.length===0?(0,n.jsx)(B,{width:q,height:J,testID:r}):(0,n.jsxs)(`div`,{"data-testid":r,style:{position:`relative`,width:q,height:J},children:[(0,n.jsx)(`canvas`,{ref:a,role:`img`,"aria-label":`Early Warning count by category — breathing dot grid`,style:{width:q,height:J,display:`block`,borderRadius:8}}),(0,n.jsx)(x,{...l,parentW:q,parentH:J})]})}function Ie({rows:e=[],className:t,colors:r}){return(0,n.jsx)(P,{rows:e,variant:`line`,className:t,colors:r})}var Y={LINE:`line`,AREA:`area`,BAR:`bar`,PIE:`pie`,DONUT:`donut`,SANKEY:`sankey`,FLOW:`flow`,TREND:`trend`,MINI_BARS:`mini-bars`,STACKED_HORIZONTAL_BAR:`stacked-horizontal-bar-chart`,MULTI_METRIC_CONSTELLATION:`multi-metric-constellation-chart`,PROGRESS_RACE:`progress-race-chart`,HUB_AND_SPOKE_RADIAL:`hub-and-spoke-radial-chart`,DOT_MATRIX:`dot-matrix-chart`,RANKED_CARD_LEADERBOARD:`ranked-card-leaderboard`,PROPORTIONAL_BAND:`proportional-band-chart`,RADIAL_FAN_TREE:`radial-fan-tree-chart`,SEMI_CIRCULAR_GAUGE:`semi-circular-gauge-chart`,SEGMENTED_SPLIT_BAR:`segmented-split-bar-chart`,BALANCE_SCALE:`balance-scale-chart`,AREA_LINE:`area-line-chart`,TREND_VIEW:`trend-view`,WEEKLY_FLOW:`weekly-flow`,HORIZONTAL_BAR:`horizontal-bar-chart`},Le=[`#4C93D9`,`#5DA537`,`#F3862C`,`#4F72C6`,`#A0B724`,`#EEBF3B`,`#3C45D1`],Re={nodes:[{id:`supplier-x`,name:`Supplier X`,valueLabel:`Si +0.12%`},{id:`bf3-superheat`,name:`BF-3 Superheat`,valueLabel:`22°C (target 34)`},{id:`ccm3-solidification`,name:`CCM-3 Solidification`,valueLabel:`Rate deviation`},{id:`grade-risk`,name:`Grade Risk`,valueLabel:`Automotive 74%`}],links:[{source:`supplier-x`,target:`bf3-superheat`,value:92},{source:`bf3-superheat`,target:`ccm3-solidification`,value:87},{source:`ccm3-solidification`,target:`grade-risk`,value:74}]};function ze({rows:e=[],className:t,colors:r}){let i=r?.slices??Le;return(0,n.jsx)(`div`,{className:[`d3-mini-bars`,t].filter(Boolean).join(` `),children:e.map(([e,t,r],a)=>(0,n.jsxs)(`div`,{className:`d3-mini-row`,children:[(0,n.jsx)(`span`,{children:e}),(0,n.jsx)(`div`,{className:`d3-mini-track`,children:(0,n.jsxs)(`svg`,{viewBox:`0 0 100 12`,className:`d3-mini-svg`,"aria-hidden":`true`,children:[(0,n.jsx)(`rect`,{x:`0`,y:`0`,width:`100`,height:`12`,rx:`6`,className:`d3-mini-track-fill`}),(0,n.jsx)(`rect`,{x:`0`,y:`0`,width:Math.max(0,Math.min(100,t)),height:`12`,rx:`6`,className:`d3-mini-fill tone-${a%Le.length}`,fill:i[a%i.length]})]})}),(0,n.jsx)(`span`,{children:r})]},`${e}-${a}`))})}var Be=770,Ve=320,He=60,Ue=28;function We({total:e=0,totalLabel:r,items:a=[],dataByEntity:o,onItemClick:s,selectedId:c,colorOffset:f=0,testID:m}){let[h,v]=z(Be),y=(0,t.useRef)(null),b=(0,t.useRef)(new Map),w=(0,t.useRef)(0),E=(0,t.useRef)(c);E.current=c;let D=(0,t.useRef)([]),O=(0,t.useCallback)((e,t)=>{if(e===`__root__`)return;let n=typeof t==`object`?t.label??e:e,r=D.current.find(t=>t.id===e);s?.(e,n,r?.subentity)},[s]),k=!!(c&&o?.[c]),M=k?o[c]:null,N=M?M.total:e,P=M?M.totalLabel:r,F=M?M.items:a,I=(0,t.useMemo)(()=>F.filter(e=>typeof e==`object`&&!!e),[F]);D.current=I;let L=(0,t.useMemo)(()=>Math.max(Ve,He+Math.max(0,I.length-1)*Ue),[I.length]),R=L,{hoveredRef:ee,tooltip:V,hitZonesRef:te}=S(y,{width:v,height:L,onClick:s?O:void 0});return(0,t.useEffect)(()=>{let e=y.current;if(!e)return;let t=g(e,v,R);w.current=0;let n=L/2,r=v-140,a=Math.max(...I.map(e=>e.count??0),1),o=I.length>1?(L-60)/(I.length-1):60,s=Math.min(22,o/2-3),c=Math.min(8,Math.max(3,s-6)),m=r+s+10,h=I.map((e,t)=>({x:r,y:30+t*o})),x,S=()=>{w.current++;let e=w.current;t.clearRect(0,0,v,R),t.letterSpacing=u.letterSpacing;let o=T(Math.min(e/72,1));j(b.current,ee.current),te.current=[];let g=l[f%l.length],y=100+60*Math.min(1,o*2.5),D=t.createLinearGradient(100,0,y,0);D.addColorStop(0,p(g,.8)),D.addColorStop(1,p(g,.7)),t.beginPath(),t.moveTo(100,n),t.lineTo(y,n),t.strokeStyle=D,t.lineWidth=1.33,t.stroke(),I.forEach((e,l)=>{let f=A(o,l,I.length,T),y=h[l],x=b.current.get(e.id)??0,S=!k&&E.current&&e.id!==E.current?.6:1;if(f<.01)return;let w=160+(r-160)*.35,D=n,O=160+(r-160)*.65,j=y.y;t.beginPath();for(let e=0;e<=40;e++){let r=e/40*f,i=(1-r)**3*160+3*(1-r)**2*r*w+3*(1-r)*r**2*O+r**3*y.x,a=(1-r)**3*n+3*(1-r)**2*r*D+3*(1-r)*r**2*j+r**3*y.y;e===0?t.moveTo(i,a):t.lineTo(i,a)}let M=t.createLinearGradient(160,n,y.x,y.y);if(M.addColorStop(0,p(g,(x>0?1:.8)*S)),M.addColorStop(1,p(g,(x>0?1:.7)*S)),t.strokeStyle=M,t.lineWidth=x>0?2:1.33,t.stroke(),f>.85){let n=Math.min(1,(f-.85)/.15),r=c+(e.count??0)/a*(s-c);_(t,y.x,y.y,r*2,g,(.2+x*.2)*n*S),t.beginPath(),t.arc(y.x,y.y,r*n,0,Math.PI*2),t.fillStyle=p(g,n*S),t.fill();let o=H(e.count??0);C(te.current,e.id,y.x,y.y,r+8,{label:e.name,value:o,sublabel:`${Math.round((e.count??0)/(N||1)*100)}% of total`,color:g},v),t.globalAlpha=n*S,t.font=u.font,t.textAlign=`left`;let l=e.abbreviation??e.name?.slice(0,6)??``,h=` ${H(e.count??0)}`,b=y.y+4;t.fillStyle=x>0?g:p(i.t2,.85),t.fillText(l,m,b);let w=t.measureText(l).width;t.font=d.font,t.fillStyle=x>0?g:i.t1,t.fillText(h,m+w,b),t.globalAlpha=1}});let O=40*o,M=t.createRadialGradient(60,n,0,60,n,O);if(M.addColorStop(0,p(g,.02*o)),M.addColorStop(.55,p(g,.02*o)),M.addColorStop(1,p(g,.15*o)),t.beginPath(),t.arc(60,n,O,0,Math.PI*2),t.fillStyle=M,t.fill(),t.beginPath(),t.arc(60,n,O,0,Math.PI*2),t.strokeStyle=p(g,.8*o),t.lineWidth=1,t.stroke(),o>.4){t.globalAlpha=Math.min(1,(o-.4)/.4);let e=H(N,0)??P;t.font=`500 16px 'Satoshi Variable', 'DM Sans', sans-serif`;let r=e;for(;t.measureText(r).width>68&&r.length>1;)r=r.slice(0,-1);r!==e&&(r=r.slice(0,-1)+`…`),t.fillStyle=i.t1,t.textAlign=`center`,t.textBaseline=`middle`,t.fillText(r,60,n),t.textBaseline=`alphabetic`,t.globalAlpha=1}C(te.current,`__root__`,60,n,40,{label:P??`Total`,value:H(N,0),sublabel:`${I.length} items`,color:g}),x=requestAnimationFrame(S)};return S(),()=>cancelAnimationFrame(x)},[N,P,I,L,v,k]),I.length===0?(0,n.jsx)(`div`,{ref:h,style:{width:`100%`},children:(0,n.jsx)(B,{width:v,height:Ve,testID:m})}):(0,n.jsxs)(`div`,{ref:h,"data-testid":m,style:{position:`relative`,width:`100%`,height:R},children:[(0,n.jsx)(`canvas`,{ref:y,role:`img`,"aria-label":`NCE fault tree — NCEs per contractor as branching tree`,style:{width:`100%`,height:R,display:`block`}}),(0,n.jsx)(x,{...V,parentW:v,parentH:R})]})}var Ge=192,Ke=Ge,qe=Ge+80;function Je({rows:e=[],variant:a,className:o,colors:c}){let l=(0,t.useRef)(null),u=(0,t.useRef)(new Map),d=(0,t.useRef)(0),f=c?.slices??s,{hoveredRef:m,tooltip:v,hitZonesRef:y}=S(l,{width:Ke,height:qe});return(0,t.useEffect)(()=>{let t=l.current;if(!t)return;let n=g(t,Ke,qe);d.current=0;let r=Ke/2,o=Ge/2,s=Ge*.4,c=a===`donut`?Ge*.21:0,v=e.reduce((e,t)=>e+(t.pricing??0),0)||1,b,x=()=>{d.current++;let t=d.current;n.clearRect(0,0,Ke,qe);let l=1-(1-Math.min(t/48,1))**3;j(u.current,m.current),y.current=[];let g=-Math.PI/2;e.forEach((e,a)=>{let d=(e.pricing??0)/v,m=d*Math.PI*2*l,h=g+m,b=f[a%f.length],x=u.current.get(e.id??`sl-${a}`)??0,S=g+m/2,w=(s+c)/2,T=r+Math.cos(S)*w,E=o+Math.sin(S)*w,D=(s-c)/2+8;C(y.current,e.id??`sl-${a}`,T,E,D,{label:e.vendor,value:`${e.pricing??0} (${Math.round(d*100)}%)`,color:b}),x>0&&_(n,T,E,D*2*x,b,.2*x);let O=k(t,.03,3e-4),A=s+x*6+(x>0?O*2:0);n.beginPath(),n.moveTo(r+Math.cos(g)*c,o+Math.sin(g)*c),n.arc(r,o,A,g,h),c>0?n.arc(r,o,c,h,g,!0):n.lineTo(r,o),n.closePath(),n.fillStyle=p(b,.7+x*.2),n.fill(),n.strokeStyle=p(i.bg,.8),n.lineWidth=1.5,n.stroke(),g=h}),a===`donut`&&e.length>0&&_(n,r,o,c*.8,i.blue,.06);let S=Ge+12;e.forEach((e,t)=>{let r=f[t%f.length],a=(e.pricing??0)/v,o=u.current.get(e.id??`sl-${t}`)??0,s=S+t*18;n.fillStyle=p(r,.8+o*.2),n.fillRect(4,s-6,12,12),n.font=`9px 'JetBrains Mono', monospace`,n.fillStyle=p(i.t2,.7+o*.2),n.textAlign=`left`,n.fillText(e.vendor,18,s+3.5),n.font=`bold 9px 'JetBrains Mono', monospace`,n.fillStyle=h(i.t3,r,o),n.textAlign=`right`,n.fillText(`${e.pricing??0} (${Math.round(a*100)}%)`,Ke-4,s+3.5)}),b=requestAnimationFrame(x)};return x(),()=>cancelAnimationFrame(b)},[e,a,c,f]),(0,n.jsx)(r,{className:[`canvas-pie-frame`,o].filter(Boolean).join(` `),children:(0,n.jsxs)(`div`,{style:{position:`relative`,width:Ke,height:qe},children:[(0,n.jsx)(`canvas`,{ref:l,role:`img`,"aria-label":`${a} chart`,style:{width:Ke,height:qe,display:`block`,borderRadius:8}}),(0,n.jsx)(x,{...v,parentW:Ke,parentH:qe})]})})}function Ye(e,t,n,r){let i=new Set(t.map(e=>e.source)),a=new Set(t.map(e=>e.target)),o=new Map,s=[];for(e.forEach(e=>{i.has(e.id)&&!a.has(e.id)&&s.push({id:e.id,depth:0})});s.length>0;){let e=s.shift();if(!e)break;let{id:n,depth:r}=e;o.has(n)||(o.set(n,r),t.filter(e=>e.source===n).forEach(e=>{o.has(e.target)||s.push({id:e.target,depth:r+1})}))}let c=o.size>0?Math.max(...Array.from(o.values())):0;e.forEach(e=>{o.has(e.id)||o.set(e.id,c+1)});let l=new Map;e.forEach(e=>{let t=o.get(e.id)??0;l.has(t)||l.set(t,[]),l.get(t).push(e.id)});let u=Math.max(...Array.from(l.keys()))+1,d={left:100,right:80,top:40,bottom:40},f=new Map;return l.forEach((e,t)=>{let i=d.left+t/Math.max(u-1,1)*(n-d.left-d.right),a=r-d.top-d.bottom,o=Math.max(24,(a-(e.length-1)*12)/e.length),s=e.length*o+(e.length-1)*12,c=d.top+(a-s)/2;e.forEach((e,t)=>{f.set(e,{x:i-20/2,y:c+t*(o+12),w:20,h:o})})}),f}function Xe({nodes:e,links:a,width:o=960,height:c=280,ariaLabel:l,selectedEntity:u,className:d,colors:f}){let m=(0,t.useRef)(null),h=(0,t.useRef)(new Map),v=(0,t.useRef)(0),b=(0,t.useRef)([]),T=f?.nodes??s,E=f?.links??i.bd,D=f?.activeLinks??i.blue,O=f?.activeNodes??i.blue,A=(0,t.useMemo)(()=>Ye(e,a,o,c),[e,a,o,c]),{hoveredRef:M,tooltip:N,hitZonesRef:P}=S(m,{width:o,height:c});return(0,t.useEffect)(()=>{let t=m.current;if(!t)return;let n=g(t,o,c);v.current=0,b.current=[];let r=a.length>0?Math.max(...a.map(e=>e.value)):1,s,l=()=>{v.current++;let t=v.current;n.clearRect(0,0,o,c);let d=1-(1-Math.min(t/56,1))**3;j(h.current,M.current),P.current=[],a.forEach((e,a)=>{let o=A.get(e.source),s=A.get(e.target);if(!o||!s)return;let c=!!u&&(e.source===u||e.target===u),l=c?D:E,f=c?.5:.2,m=Math.max(3,e.value/r*36*d),h=m/2,g=o.x+o.w,_=o.y+o.h/2,v=s.x,y=s.y+s.h/2,x=(g+v)/2;for(let e=0;e<30;e++){let r=e/30,i=(e+1)/30,o=1-r,s=1-i,c=o*o*g+2*o*r*x+r*r*v,u=o*o*_+2*o*r*_+r*r*y,d=s*s*g+2*s*i*x+i*i*v,m=s*s*_+2*s*i*_+i*i*y,b=k(t+r*120+a*40,.025,3e-4)*1.2;n.beginPath(),n.moveTo(c,u-h+b),n.lineTo(d,m-h+b),n.lineTo(d,m+h+b),n.lineTo(c,u+h+b),n.closePath(),n.fillStyle=p(l,f*(.5+r*.5)),n.fill()}C(P.current,`link-${a}`,x,(_+y)/2,m+6,{label:`${e.source} → ${e.target}`,value:String(e.value),color:c?D:i.blue}),Math.random()<.08&&b.current.push({linkIdx:a,prog:0,speed:.006+Math.random()*.006,off:(Math.random()-.5)*m*.5,sz:1+Math.random()})}),e.forEach((e,r)=>{let a=A.get(e.id);if(!a)return;let o=u===e.id,s=M.current===`node-${r}`,c=h.current.get(`node-${r}`)??0,l=o?O:T[r%T.length];w(P.current,`node-${r}`,a.x,a.y,a.w,a.h,{label:e.name,value:e.valueLabel??e.id,color:l}),(c>0||o)&&_(n,a.x+a.w/2,a.y+a.h/2,a.w*2,l,.2*Math.max(c,o?.6:0));let d=o?k(t,.03,3e-4)*.15:0;n.fillStyle=p(l,.6+c*.25+d),n.beginPath(),n.roundRect(a.x,a.y,a.w,a.h,4),n.fill(),(o||c>0)&&(n.strokeStyle=p(l,.5*Math.max(c,o?1:0)),n.lineWidth=1,n.beginPath(),n.roundRect(a.x,a.y,a.w,a.h,4),n.stroke());let f=a.x+a.w+8;n.font=`${o||s?`bold `:``}10px 'JetBrains Mono', monospace`,n.fillStyle=p(o?l:i.t2,.7+c*.2),n.textAlign=`left`,n.fillText(e.name,f,a.y+a.h/2+4),e.valueLabel&&(n.font=`9px 'JetBrains Mono', monospace`,n.fillStyle=p(l,.5+c*.2),n.fillText(e.valueLabel,f,a.y+a.h/2+17))}),b.current=b.current.filter(e=>{if(e.prog+=e.speed,e.prog>1)return!1;let t=a[e.linkIdx];if(!t)return!1;let r=A.get(t.source),o=A.get(t.target);if(!r||!o)return!1;let s=r.x+r.w,c=r.y+r.h/2,l=o.x,u=o.y+o.h/2,d=(s+l)/2,m=1-e.prog,h=m*m*s+2*m*e.prog*d+e.prog*e.prog*l,g=m*m*c+2*m*e.prog*c+e.prog*e.prog*u+e.off,_=Math.sin(e.prog*Math.PI)*.5,v=f?.links??i.blue;return n.beginPath(),n.arc(h,g,e.sz,0,Math.PI*2),n.fillStyle=p(v,_),n.fill(),!0}),b.current.length>150&&(b.current=b.current.slice(-150)),y(n,o,c,t,.01),s=requestAnimationFrame(l)};return l(),()=>{cancelAnimationFrame(s),b.current=[]}},[e,a,o,c,u,f,A]),(0,n.jsx)(r,{className:[`canvas-sankey-frame`,d].filter(Boolean).join(` `),children:(0,n.jsxs)(`div`,{role:`img`,"aria-label":l,style:{position:`relative`,width:o,height:c},children:[(0,n.jsx)(`canvas`,{ref:m,style:{width:o,height:c,display:`block`,borderRadius:8}}),(0,n.jsx)(x,{...N,parentW:o,parentH:c})]})})}var Ze=[{x:.13,y:.48},{x:.37,y:.28},{x:.63,y:.62},{x:.87,y:.38},{x:.25,y:.72},{x:.5,y:.18},{x:.75,y:.7},{x:.92,y:.22}],Qe=[i.blue,i.orange,i.red,i.purple,i.green,i.amber,i.t2],$e=[26,24,24,26,22,22,22,22];function et(e,t){let n=1-t;return{x:n*n*n*e.p0.x+3*n*n*t*e.p1.x+3*n*t*t*e.p2.x+t*t*t*e.p3.x,y:n*n*n*e.p0.y+3*n*n*t*e.p1.y+3*n*t*t*e.p2.y+t*t*t*e.p3.y}}function tt(e,t){let n=1-t,r=3*n*n*(e.p1.x-e.p0.x)+6*n*t*(e.p2.x-e.p1.x)+3*t*t*(e.p3.x-e.p2.x),i=3*n*n*(e.p1.y-e.p0.y)+6*n*t*(e.p2.y-e.p1.y)+3*t*t*(e.p3.y-e.p2.y),a=Math.sqrt(r*r+i*i)||1;return{x:-i/a,y:r/a}}function nt(e,t){let n=t.x-e.x,r=t.y-e.y;return{p0:{x:e.x,y:e.y},p1:{x:e.x+n*.3+r*.15,y:e.y+r*.3-n*.15},p2:{x:t.x-n*.3+r*.08,y:t.y-r*.3-n*.08},p3:{x:t.x,y:t.y}}}function rt({nodes:e,links:r,width:a=960,height:o=280,selectedEntity:s}){let c=(0,t.useRef)(null),l=(0,t.useRef)(0),u=(0,t.useRef)([]),{hoveredRef:d,tooltip:f,hitZonesRef:m}=S(c,{width:a,height:o}),b=(0,t.useMemo)(()=>{let t=new Map;return e.forEach((e,n)=>t.set(e.id,n)),t},[e]),w=(0,t.useMemo)(()=>r.length>0?Math.max(...r.map(e=>e.value)):100,[r]),E=e=>w>1?e/100:e,D=(0,t.useMemo)(()=>e.map((e,t)=>{let n=Ze[t%Ze.length];return{id:e.id,label:e.name,sub:e.valueLabel??``,x:n.x*a,y:n.y*o,r:$e[t%$e.length],color:Qe[t%Qe.length]}}),[e,a,o]),O=(0,t.useMemo)(()=>r.map(e=>({fromIdx:b.get(e.source)??-1,toIdx:b.get(e.target)??-1,conf:E(e.value)})).filter(e=>e.fromIdx>=0&&e.toIdx>=0),[r,b]);return(0,t.useEffect)(()=>{let e=c.current;if(!e)return;let t=g(e,a,o);l.current=0,u.current=[];let n,r=()=>{l.current++;let e=l.current;if(t.clearRect(0,0,a,o),m.current=[],v(t,a,o,e,50,p(i.blue,.05)),O.forEach((e,n)=>{let r=D[e.fromIdx],a=D[e.toIdx];if(!r||!a)return;let o=!!s&&(r.id===s||a.id===s),c=h(r.color,a.color,.5),l=o?.18:.05,d=o?.25:.1,f=nt(r,a);t.beginPath(),t.moveTo(f.p0.x,f.p0.y),t.bezierCurveTo(f.p1.x,f.p1.y,f.p2.x,f.p2.y,f.p3.x,f.p3.y),t.strokeStyle=p(c,l),t.lineWidth=16,t.lineCap=`round`,t.stroke(),t.strokeStyle=p(c,d),t.lineWidth=1.5,t.stroke();for(let t=0;t<e.conf*2.5;t++)Math.random()<.45&&u.current.push({edgeIdx:n,t:0,speed:.003+Math.random()*.004,off:(Math.random()-.5)*13,sz:.7+Math.random()*2});let m=et(f,.5),g=`${Math.round(e.conf*100)}%`;t.font=`bold 12px 'JetBrains Mono', monospace`,t.textBaseline=`middle`;let _=t.measureText(g).width+14;t.fillStyle=`rgba(10,16,24,0.88)`,t.beginPath(),t.roundRect(m.x-_/2,m.y-11,_,22,6),t.fill(),t.strokeStyle=p(i.blue,.25),t.lineWidth=1,t.stroke(),t.fillStyle=p(i.blue,.9),t.textAlign=`center`,t.fillText(g,m.x,m.y)}),u.current=u.current.filter(e=>{if(e.t+=e.speed,e.t>1)return!1;let n=O[e.edgeIdx];if(!n)return!1;let r=D[n.fromIdx],i=D[n.toIdx];if(!r||!i)return!1;let a=nt(r,i),o=et(a,e.t),s=tt(a,e.t),c=o.x+s.x*e.off,l=o.y+s.y*e.off,u=Math.sin(e.t*Math.PI)*.7,d=h(r.color,i.color,e.t);return _(t,c,l,e.sz*3,d,u*.1),t.beginPath(),t.arc(c,l,e.sz,0,Math.PI*2),t.fillStyle=p(d,u),t.fill(),!0}),u.current.length>350&&(u.current=u.current.slice(-350)),D.forEach((n,r)=>{let a=s===n.id,o=d.current===`node-${r}`,c=k(e,.03,3e-4)*.1+1,l=n.r*c*(a?1.15:1);t.beginPath(),t.arc(n.x,n.y,l+6,0,Math.PI*2),t.strokeStyle=p(n.color,a?.3:.1),t.lineWidth=a?1.5:.7,t.stroke(),_(t,n.x,n.y,l*3,n.color,a?.22:.12);let u=t.createRadialGradient(n.x,n.y-l*.2,0,n.x,n.y,l);if(u.addColorStop(0,p(n.color,a?1:.85)),u.addColorStop(1,p(n.color,a?.65:.45)),t.fillStyle=u,t.beginPath(),t.arc(n.x,n.y,l,0,Math.PI*2),t.fill(),a||r===D.length-1){let r=l+16,i=e*.04,a=n.x+Math.cos(i)*r,o=n.y+Math.sin(i)*r;_(t,a,o,6,n.color,.3),t.beginPath(),t.arc(a,o,2,0,Math.PI*2),t.fillStyle=p(n.color,.75),t.fill()}C(m.current,`node-${r}`,n.x,n.y,l+8,{label:n.label,value:n.sub||n.id,color:n.color}),t.font=`${a||o?`bold `:``}12px 'DM Sans', sans-serif`,t.textAlign=`center`,t.textBaseline=`alphabetic`,t.fillStyle=p(n.color,a?1:.9),t.fillText(n.label,n.x,n.y+l+18),n.sub&&(t.font=`10px 'JetBrains Mono', monospace`,t.fillStyle=p(i.t3,.65),t.fillText(n.sub,n.x,n.y+l+32))}),O.length>=2){let n=O.reduce((e,t)=>e*t.conf,1),r=o*.92,s=a*.12,c=a*.76,l=T(Math.min(e*.008,1));t.fillStyle=p(i.bd,.35),t.beginPath(),t.roundRect(s,r,c,5,3),t.fill(),t.fillStyle=p(i.orange,.6),t.beginPath(),t.roundRect(s,r,c*n*l,5,3),t.fill(),t.font=`bold 12px 'JetBrains Mono', monospace`,t.textAlign=`left`,t.textBaseline=`middle`,t.fillStyle=p(i.orange,.85),t.fillText(`${Math.round(n*100)}% compound confidence`,s+c*n*l+10,r+2);let u=O.map(e=>e.conf.toFixed(2)).join(` × `);t.textAlign=`right`,t.font=`9px 'JetBrains Mono', monospace`,t.fillStyle=p(i.t4,.6),t.fillText(u,s-6,r+2)}y(t,a,o,e,.012),n=requestAnimationFrame(r)};return r(),()=>{cancelAnimationFrame(n),u.current=[]}},[D,O,a,o,s]),(0,n.jsxs)(`div`,{style:{position:`relative`,width:a,height:o},children:[(0,n.jsx)(`canvas`,{ref:c,style:{width:a,height:o,display:`block`,borderRadius:8},role:`img`,"aria-label":`causal flow diagram`}),(0,n.jsx)(x,{...f,parentW:a,parentH:o})]})}function it({selectedEntity:e,colors:t}){return(0,n.jsx)(rt,{nodes:Re.nodes,links:Re.links,width:960,height:280,selectedEntity:e})}function at({rows:e=[],className:r,colors:i}){let{nodes:a,links:o}=(0,t.useMemo)(()=>{let t=e.slice(0,5);return{nodes:[{id:`score`,name:`Portfolio Score`},...t.map(e=>({id:e.id??e.vendor,name:e.vendor}))],links:t.map(e=>({source:e.id??e.vendor,target:`score`,value:Math.max(8,e.pricing??0)}))}},[e]);return(0,n.jsx)(Xe,{nodes:a,links:o,width:760,height:280,ariaLabel:`sankey chart`,className:r,colors:i})}var ot=780,st=420;function ct({left:e,right:r,leftTitle:a=`Accepted`,rightTitle:o=`Submitted`,unit:s=`quotations`,selectedId:c,dataByEntity:l,onItemClick:d,testID:f}){let m=(0,t.useRef)(null),h=(0,t.useRef)(0),v=c&&l?.[c]?l[c]:{left:e,right:r},y=v.left,b=v.right,C=(0,t.useRef)({left:y,right:b,leftTitle:a,rightTitle:o});C.current={left:y,right:b,leftTitle:a,rightTitle:o};let E=(0,t.useRef)(c);E.current=c;let D=(0,t.useCallback)((e,t)=>{let n=typeof t==`object`?t.label??e:e,r=e===`left`?C.current.left:C.current.right;d?.(e,n,r?.subentity)},[d]),{hitZonesRef:k,tooltip:A,hoveredRef:j}=S(m,{width:ot,height:st,onClick:d?D:void 0});return(0,t.useEffect)(()=>{let e=m.current;if(!e)return;let t=g(e,ot,st);h.current=0;let n=ot/2,r=Math.abs(y.value??0),c=Math.abs(b.value??0),l=Math.max(r,c,1),d=(y.value-b.value)/(2*l)*14,f=Math.max(-14,Math.min(14,d)),v=(e,n,r,a,o)=>{let s=n-99/2,c=r+30,l=[0,0,10,10];t.save(),t.beginPath(),t.roundRect(s,c,99,a,l),t.clip();let u=p(e,.27*o),d=p(e,0),f=t.createLinearGradient(s,0,s+25,0);f.addColorStop(0,u),f.addColorStop(1,d),t.fillStyle=f,t.fillRect(s,c,25,a);let m=t.createLinearGradient(s+99,0,s+99-25,0);m.addColorStop(0,u),m.addColorStop(1,d),t.fillStyle=m,t.fillRect(s+99-25,c,25,a);let h=t.createLinearGradient(0,c,0,c+25);h.addColorStop(0,u),h.addColorStop(1,d),t.fillStyle=h,t.fillRect(s,c,99,25);let g=t.createLinearGradient(0,c+a,0,c+a-25);g.addColorStop(0,u),g.addColorStop(1,d),t.fillStyle=g,t.fillRect(s,c+a-25,99,25),t.restore(),t.beginPath(),t.roundRect(s,c,99,a,l),t.strokeStyle=p(e,1*o),t.lineWidth=1,t.stroke();let _=s+99/2,v=c-5;t.strokeStyle=p(i.t2,.5*o),t.lineWidth=1,t.beginPath(),t.moveTo(n,r+4),t.lineTo(_,v),t.stroke(),t.beginPath(),t.moveTo(_,v),t.lineTo(_-10,c),t.stroke(),t.beginPath(),t.moveTo(_,v),t.lineTo(_+10,c),t.stroke(),t.beginPath(),t.arc(n,r,3,0,Math.PI*2),t.fillStyle=p(i.t2,.7*o),t.fill()},x,S=()=>{h.current++;let e=h.current;t.clearRect(0,0,ot,st),t.letterSpacing=u.letterSpacing,k.current=[];let d=T(Math.min(e/80,1)),m=f*O(Math.min(e/80,1))*Math.PI/180,g={x:n-Math.cos(m)*240,y:100+Math.sin(-m)*240},C={x:n+Math.cos(m)*240,y:100+Math.sin(m)*240};t.strokeStyle=p(i.t2,.55*d),t.lineWidth=1.5,t.beginPath(),t.moveTo(g.x,g.y),t.lineTo(C.x,C.y),t.stroke(),_(t,n,100,18,i.t2,.14*d),t.beginPath(),t.arc(n,100,9*d,0,Math.PI*2),t.fillStyle=p(i.t2,.85*d),t.fill();let D=Math.max(20,r/l*95*d),A=Math.max(20,c/l*95*d),j=E.current===`right`?.6:1,M=E.current===`left`?.6:1;v(i.green,g.x,g.y,D,d*j),v(i.amber,C.x,C.y,A,d*M);let N=g.y+30+D,P=C.y+30+A;if(w(k.current,`left`,g.x-99/2,g.y+30,99,D+90,{label:a,value:y.label,sublabel:`${y.count} ${s}`,color:i.green},st,g.x,N+102),w(k.current,`right`,C.x-99/2,C.y+30,99,A+90,{label:o,value:b.label,sublabel:`${b.count} ${s}`,color:i.amber},st,C.x,P+102),d>.5){let e=Math.min(1,(d-.5)/.5);t.textAlign=`center`,t.textBaseline=`top`;let n=g.y+30+D+14,r=C.y+30+A+14;t.globalAlpha=e*j,t.font=`700 34px 'Satoshi Variable', 'DM Sans', sans-serif`,t.fillStyle=i.t1,t.fillText(y.label,g.x,n),t.font=u.font,t.fillStyle=u.color,t.fillText(`${a} ${y.count} ${s}`,g.x,n+42),t.globalAlpha=e*M,t.font=`700 34px 'Satoshi Variable', 'DM Sans', sans-serif`,t.fillStyle=i.t1,t.fillText(b.label,C.x,r),t.font=u.font,t.fillStyle=u.color,t.fillText(`${o} ${b.count} ${s}`,C.x,r+42),t.globalAlpha=1,t.textBaseline=`alphabetic`}x=requestAnimationFrame(S)};return S(),()=>cancelAnimationFrame(x)},[y,b]),(0,n.jsxs)(`div`,{"data-testid":f,style:{position:`relative`,width:`100%`,maxWidth:ot},children:[(0,n.jsx)(`canvas`,{ref:m,role:`img`,"aria-label":`Quotation balance — accepted vs submitted quotation value`,style:{width:`100%`,aspectRatio:`${ot} / ${st}`,display:`block`,borderRadius:8}}),(0,n.jsx)(x,{...A,parentW:ot,parentH:st})]})}var lt=780,ut=360;function dt({points:e=[],testID:r}){let a=(0,t.useRef)(null),o=(0,t.useRef)(new Map),s=(0,t.useRef)(0),{hoveredRef:c,tooltip:l,hitZonesRef:d}=S(a,{width:lt,height:ut}),f=(0,t.useMemo)(()=>e.filter(e=>typeof e==`object`&&!!e),[e]);return(0,t.useEffect)(()=>{let e=a.current;if(!e)return;let t=g(e,lt,ut);s.current=0;let n=lt-64-48,r=ut-48-68,l=Math.max(...f.map(e=>e.count),1),m=f.length,h=m>1?n/(m-1):n,v=f.map((e,t)=>({x:64+t*h,y:48+r-e.count/l*r,point:e})),y,x=()=>{s.current++;let e=s.current;t.clearRect(0,0,lt,ut),t.letterSpacing=u.letterSpacing;let a=T(Math.min(e/72,1));j(o.current,c.current),d.current=[],[0,.25,.5,.75,1].forEach(e=>{let a=48+r-e*r;t.strokeStyle=p(i.bd,.18),t.lineWidth=1,t.setLineDash([3,5]),t.beginPath(),t.moveTo(64,a),t.lineTo(64+n,a),t.stroke(),t.setLineDash([]),t.font=u.font,t.fillStyle=u.color,t.textAlign=`right`,t.fillText(String(Math.round(l*e)),58,a+3)}),t.save(),t.translate(12,48+r/2),t.rotate(-Math.PI/2),t.font=u.font,t.fillStyle=u.color,t.textAlign=`center`,t.fillText(`Count`,0,0),t.restore(),t.strokeStyle=p(i.bd,.3),t.lineWidth=1,t.setLineDash([]),t.beginPath(),t.moveTo(64,48+r),t.lineTo(64+n,48+r),t.stroke();let f=a*(m-1),h=Math.floor(f)+1;if(h>=2){t.beginPath(),t.moveTo(v[0].x,48+r),t.lineTo(v[0].x,v[0].y);for(let e=1;e<h;e++){let n=f-Math.floor(f),r=e<h-1?v[e].x:v[e-1].x+(v[e].x-v[e-1].x)*(e===Math.ceil(f)?n:1),i=e<h-1?v[e].y:v[e-1].y+(v[e].y-v[e-1].y)*(e===Math.ceil(f)?n:1);t.lineTo(r,i)}let e=v[Math.min(h-1,m-1)];t.lineTo(e.x,48+r),t.closePath();let n=t.createLinearGradient(0,48,0,48+r);n.addColorStop(0,p(i.teal,.12)),n.addColorStop(1,p(i.teal,.02)),t.fillStyle=n,t.fill()}t.beginPath();for(let e=0;e<h;e++){let n=f-Math.floor(f),r=e===h-1&&e>0&&e===Math.ceil(f),i=e===0||e<h-1?v[e].x:v[e-1].x+(v[e].x-v[e-1].x)*(r?n:1),a=e===0||e<h-1?v[e].y:v[e-1].y+(v[e].y-v[e-1].y)*(r?n:1);e===0?t.moveTo(i,a):t.lineTo(i,a)}t.strokeStyle=p(i.teal,.85),t.lineWidth=2,t.stroke(),v.forEach((e,n)=>{if(n>=h)return;let a=`pt-${n}`,s=o.current.get(a)??0;C(d.current,a,e.x,e.y,10,{label:e.point.week,value:String(e.point.count),color:i.teal}),s>0&&b(t,e.x,48,48+r,p(i.teal,.15*s));let c=e.point.count===l;(s>0||c)&&_(t,e.x,e.y,14,i.teal,(c?.3:0)+s*.25),t.beginPath(),t.arc(e.x,e.y,s>0?5:3.5,0,Math.PI*2),t.fillStyle=p(i.teal,s>0?1:.8),t.fill(),(s>0||c)&&(t.font=u.font,t.fillStyle=i.teal,t.textAlign=`center`,t.fillText(String(e.point.count),e.x,e.y-10)),t.font=u.font,t.fillStyle=s>0?i.teal:u.color,t.textAlign=`center`,t.fillText(e.point.week,e.x,ut-68+14)}),y=requestAnimationFrame(x)};return x(),()=>cancelAnimationFrame(y)},[f]),f.length<2?(0,n.jsx)(B,{width:lt,height:ut,testID:r}):(0,n.jsx)(`div`,{"data-testid":r,className:`trend-scroll`,style:{width:`100%`,overflowX:`auto`},children:(0,n.jsxs)(`div`,{style:{position:`relative`,width:lt,height:ut},children:[(0,n.jsx)(`canvas`,{ref:a,role:`img`,"aria-label":`Trend chart — count over time`,style:{width:lt,height:ut,display:`block`}}),(0,n.jsx)(x,{...l,parentW:lt,parentH:ut})]})})}var ft=680,X=280,pt=80,mt=48,ht=64,gt=u.font,_t=12,vt=Math.PI*2,yt=72,bt=20,xt=5e3;function St({points:e=[],selectedId:r,seriesByEntity:a,colorOffset:o=0,testID:s}){let c=(0,t.useRef)(null),d=(0,t.useRef)(null),f=(0,t.useRef)(0),m=r&&a?.[r]?a[r]:e,h=(0,t.useMemo)(()=>m.filter(e=>typeof e==`object`&&!!e),[m]),_=(0,t.useMemo)(()=>{if(h.length<=1)return ht;let e=document.createElement(`canvas`).getContext(`2d`);if(!e)return ht;e.font=gt;let t=Math.max(1,Math.ceil(h.length/bt)),n=Math.max(...h.filter((e,n)=>n%t===0).map(t=>e.measureText(t.week).width));return Math.max(ht,n+_t)},[h]),v=Math.round(_/2),y=mt+v+Math.max(0,h.length-1)*_,b=Math.max(ft-pt,Math.min(y,xt)),{tooltip:w,hitZonesRef:E}=S(c,{width:b,height:X});return(0,t.useEffect)(()=>{let e=c.current;if(!e)return;let t=g(e,b,X),n=d.current?g(d.current,pt,X):null;f.current=0;let r=l[o%l.length],a=h.length<=yt?yt:Math.max(24,Math.round(yt*(yt/h.length))),s=b-mt,m=X-42-54,y=h.length>0?h.map(e=>e.count):[0],x=Math.min(...y),S=Math.max(...y),w=S-x||1,D=h.length,O=D>1?(s-v)/(D-1):0,k=Math.max(1,Math.ceil(_/O)),A=x<0,j=A?42+m- -x/w*m:42+m,M=v+(s-v)/2,N=h.map((e,t)=>({x:D===1?M:v+t*O,y:42+m-(A?(e.count-x)/w:e.count/(S||1))*m,point:e}));if(n){n.clearRect(0,0,pt,X),n.letterSpacing=u.letterSpacing;let e=A?[x,x+w*.25,x+w*.5,x+w*.75,S]:[0,S*.25,S*.5,S*.75,S];e.forEach((t,r)=>{let i=r/(e.length-1),a=42+m-i*m;n.font=u.font,n.fillStyle=u.color,n.textAlign=`right`,n.fillText(H(t),pt-6,a+3)}),n.save(),n.translate(12,42+m/2),n.rotate(-Math.PI/2),n.font=u.font,n.fillStyle=u.color,n.textAlign=`center`,n.fillText(`Count`,0,0),n.restore()}let P=t.createLinearGradient(0,42,0,42+m);P.addColorStop(0,p(r,.12)),P.addColorStop(1,p(r,.02));let F=0,I,L=e=>{t.font=gt,t.fillStyle=u.color,t.textAlign=`center`;for(let n=0;n<e;n++)n%k===0&&t.fillText(N[n].point.week,N[n].x,X-54+14)},R=()=>{f.current++;let e=Math.min(f.current/a,1),n=T(e),o=e>=1;t.clearRect(0,0,b,X),t.letterSpacing=u.letterSpacing,(A?[0,.25,.5,.75,1]:[.25,.5,.75,1]).forEach(e=>{let n=42+m-e*m;t.strokeStyle=p(i.bd,.18),t.lineWidth=1,t.setLineDash([3,5]),t.beginPath(),t.moveTo(0,n),t.lineTo(s,n),t.stroke(),t.setLineDash([])}),t.font=u.font,t.fillStyle=u.color,t.textAlign=`center`,t.fillText(`Period`,v+(s-v)/2,X-6),t.strokeStyle=p(i.bd,A?.5:.3),t.lineWidth=A?2:1,t.beginPath(),t.moveTo(v,A?j:42+m),t.lineTo(s,A?j:42+m),t.stroke();let c=n*(D-1),l=Math.floor(c)+1;if(l>=2){let e=A?j:42+m;t.beginPath(),t.moveTo(N[0].x,e),t.lineTo(N[0].x,N[0].y);for(let e=1;e<l;e++){let n=c-Math.floor(c),r=e===l-1&&e===Math.ceil(c)&&n>0,i=r?N[e-1].x+(N[e].x-N[e-1].x)*n:N[e].x,a=r?N[e-1].y+(N[e].y-N[e-1].y)*n:N[e].y;t.lineTo(i,a)}t.lineTo(N[l-1].x,e),t.closePath(),t.fillStyle=P,t.fill()}t.beginPath();for(let e=0;e<l;e++){let n=c-Math.floor(c),r=e===l-1&&e>0&&e===Math.ceil(c)&&n>0,i=r?N[e-1].x+(N[e].x-N[e-1].x)*n:N[e].x,a=r?N[e-1].y+(N[e].y-N[e-1].y)*n:N[e].y;e===0?t.moveTo(i,a):t.lineTo(i,a)}t.strokeStyle=p(r,.85),t.lineWidth=2,t.stroke(),t.fillStyle=p(r,.8),t.beginPath();for(let e=0;e<l;e++)t.moveTo(N[e].x+3.5,N[e].y),t.arc(N[e].x,N[e].y,3.5,0,vt);if(t.fill(),l>F){E.current=[];for(let e=0;e<l;e++)C(E.current,`pt-${e}`,N[e].x,N[e].y,10,{label:N[e].point.week,value:String(N[e].point.count),color:r});F=l}o&&L(D),o||(I=requestAnimationFrame(R))};return R(),()=>cancelAnimationFrame(I)},[h,b,_,E,o]),h.length===0?(0,n.jsx)(B,{width:ft,height:X,testID:s}):(0,n.jsxs)(`div`,{"data-testid":s,style:{position:`relative`,width:`100%`,display:`flex`},children:[(0,n.jsx)(`canvas`,{ref:d,"aria-hidden":`true`,style:{width:pt,height:X,display:`block`,flexShrink:0}}),(0,n.jsx)(`div`,{className:`trend-scroll`,style:{flex:1,minWidth:0,overflowX:`auto`},children:(0,n.jsxs)(`div`,{style:{position:`relative`,width:b,height:X},children:[(0,n.jsx)(`canvas`,{ref:c,role:`img`,"aria-label":`Trend chart — count over time`,style:{width:b,height:X,display:`block`}}),(0,n.jsx)(x,{...w,parentW:b,parentH:X})]})})]})}var Ct=780,wt=340,Tt=28,Et=4;function Dt(e,t,n){if(e.measureText(t).width<=n)return t;let r=t;for(;r.length>0&&e.measureText(`${r}…`).width>n;)r=r.slice(0,-1);return`${r}…`}function Ot({severities:e=[],colorOffset:r=0,onItemClick:a,testID:o}){let[s,c]=z(Ct),d=(0,t.useRef)(null),f=(0,t.useRef)(new Map),m=(0,t.useRef)(0),h=(0,t.useMemo)(()=>e.filter(e=>typeof e==`object`&&!!e),[e]),_=(0,t.useRef)(h);_.current=h;let v=(0,t.useCallback)((e,t)=>{let n=typeof t==`object`?t.label??e:e,r=_.current.find(t=>t.severity===e);a?.(e,n,r?.subentity)},[a]),{hoveredRef:y,tooltip:b,hitZonesRef:C}=S(d,{width:c,height:wt,onClick:a?v:void 0});return(0,t.useEffect)(()=>{let e=d.current;if(!e)return;let t=g(e,c,wt);m.current=0;let n=h.reduce((e,t)=>e+(t.count??0),0),a=Tt,o=Tt,s=c-a-o,_=wt-54-54,v=s-Math.max(0,h.length-1)*Et,b=h.map(e=>(e.count??0)/(n||1)*v),x=l[r%l.length],S,T=()=>{m.current++;let e=m.current;t.clearRect(0,0,c,wt),t.letterSpacing=u.letterSpacing;let r=E(Math.min(e/60,1));j(f.current,y.current),C.current=[];let o=a;h.forEach((e,a)=>{let s=b[a]??0,c=f.current.get(e.severity)??0,l=o+s/2,d=s*.78,m=s*r,h=d*r,g=l-h/2;if(m>0){let e=()=>{t.beginPath(),t.moveTo(g,54),t.lineTo(g+h,54),t.lineTo(o+m,54+_),t.lineTo(o,54+_),t.closePath()},n=o+s/2,i=54+_/2,a=Math.sqrt((s/2)**2+(_/2)**2),l=t.createRadialGradient(n,i,0,n,i,a);l.addColorStop(0,p(x,(.03+c*.02)*r)),l.addColorStop(.5,p(x,(.12+c*.04)*r)),l.addColorStop(1,p(x,(.28+c*.08)*r)),t.save(),e(),t.clip(),e(),t.fillStyle=l,t.fill(),t.restore(),e(),t.strokeStyle=p(x,.9*r),t.lineWidth=1,t.stroke()}if(w(C.current,e.severity,o,54,s,_,{label:e.severity,value:H(e.count??0),sublabel:`${Math.round((e.count??0)/(n||1)*100)}%`,color:x}),r>.5){let a=Math.min(1,(r-.5)/.5),l=o+s/2;t.globalAlpha=a,t.font=u.font,t.fillStyle=c>0?x:p(i.t1,.65),t.textAlign=`center`,t.fillText(Dt(t,e.severity,s-8),l,40),t.font=`600 22px 'Satoshi Variable', 'DM Sans', sans-serif`,t.fillStyle=p(i.t1,.92+c*.08),t.fillText(H(e.count??0),l,54+_/2+8),t.font=u.font,t.fillStyle=c>0?x:p(i.t1,.5),t.fillText(`${Math.round((e.count??0)/(n||1)*100)}%`,l,54+_+22),t.globalAlpha=1}o+=s+Et}),S=requestAnimationFrame(T)};return T(),()=>cancelAnimationFrame(S)},[h,c,r]),h.length===0?(0,n.jsx)(`div`,{ref:s,style:{width:`100%`},children:(0,n.jsx)(B,{width:c,height:wt,testID:o})}):(0,n.jsxs)(`div`,{ref:s,"data-testid":o,style:{position:`relative`,width:`100%`,height:wt},children:[(0,n.jsx)(`canvas`,{ref:d,role:`img`,"aria-label":`Early Warning severity distribution — prism spectrum bands`,style:{width:`100%`,height:wt,display:`block`}}),(0,n.jsx)(x,{...b,parentW:c,parentH:wt})]})}var kt=300,At=280,jt=100,Mt={Open:i.red,Submitted:i.amber,Closed:i.green};function Nt({segments:e=[],title:r,unitLabel:a=``,testID:o}){let s=(0,t.useRef)(null),c=(0,t.useRef)(0),l=(0,t.useRef)(new Map),{hoveredRef:f,tooltip:m,hitZonesRef:h}=S(s,{width:kt,height:At}),b=(0,t.useMemo)(()=>e.filter(e=>typeof e==`object`&&!!e),[e]);return(0,t.useEffect)(()=>{let e=s.current;if(!e)return;let t=g(e,kt,At);c.current=0;let n=kt*.5,o=At*.56,m=jt,x=b.reduce((e,t)=>e+(t.count??0),0),S=Math.max(...b.map(e=>e.count??0),1),w,T=()=>{c.current++;let e=c.current;t.clearRect(0,0,kt,At),t.letterSpacing=u.letterSpacing,h.current=[],l.current.forEach((e,t)=>{let n=t===f.current?1:0,r=e+(n-e)*.12;Math.abs(r-n)<.005?n===0?l.current.delete(t):l.current.set(t,1):l.current.set(t,r)}),f.current&&!l.current.has(f.current)&&l.current.set(f.current,0),v(t,kt,At,e,40,p(i.blue,.04)),b.forEach((r,a)=>{let s=a/3*Math.PI*2-Math.PI/2,c=n+Math.cos(s)*m,l=o+Math.sin(s)*m,u=Mt[r.status]??i.blue,f=2+r.count/S*8;t.beginPath(),t.moveTo(n,o),t.lineTo(c,l),t.strokeStyle=p(u,.08),t.lineWidth=f*2,t.stroke(),t.beginPath(),t.moveTo(n,o),t.lineTo(c,l),t.strokeStyle=p(u,.25),t.lineWidth=1,t.stroke();let h=(e*.005+a*.33)%1,g=n+(c-n)*h,v=o+(l-o)*h;_(t,g,v,6,u,.4),t.beginPath(),t.arc(g,v,2,0,Math.PI*2),t.fillStyle=p(u,.8),t.fill();let y=(n+c)/2,b=(o+l)/2;t.font=d.font,t.textAlign=`center`,t.textBaseline=`middle`,t.fillStyle=p(u,.85),t.fillText(String(r.count),y,b)}),b.forEach((e,r)=>{let s=r/3*Math.PI*2-Math.PI/2,c=n+Math.cos(s)*m,d=o+Math.sin(s)*m,f=Mt[e.status]??i.blue,g=10+e.count/S*18,v=l.current.get(e.status)??0;_(t,c,d,g*2.5,f,.2+v*.15);let y=t.createRadialGradient(c,d-g*.2,0,c,d,g);y.addColorStop(0,p(f,.8+v*.2)),y.addColorStop(1,p(f,.4+v*.1)),t.beginPath(),t.arc(c,d,g,0,Math.PI*2),t.fillStyle=y,t.fill(),t.font=`bold `+u.font,t.textAlign=`center`,t.textBaseline=`middle`,t.fillStyle=p(i.t1,.9),t.fillText(e.status,c,d),C(h.current,e.status,c,d,g+6,{label:e.status,value:a?`${e.count} ${a}`:String(e.count),sublabel:`${Math.round((e.count??0)/(x||1)*100)}%`,color:f})});let s=l.current.get(`center`)??0;_(t,n,o,36,i.t2,.2+s*.15);let g=t.createRadialGradient(n,o-4,0,n,o,22);g.addColorStop(0,p(i.t2,.9)),g.addColorStop(1,p(i.t2,.5)),t.beginPath(),t.arc(n,o,22,0,Math.PI*2),t.fillStyle=g,t.fill(),t.font=d.font,t.textAlign=`center`,t.textBaseline=`middle`,t.fillStyle=p(i.t1,.9),t.fillText(r??``,n,o-4),t.font=`bold `+u.font,t.fillStyle=i.t1,t.fillText(String(x),n,o+8),C(h.current,`center`,n,o,28,{label:r??`Total`,value:a?`${x} ${a}`:String(x),color:i.t2}),y(t,kt,At,e,.015),w=requestAnimationFrame(T)};return T(),()=>cancelAnimationFrame(w)},[b,r,a]),b.length===0?(0,n.jsx)(B,{width:kt,height:At,testID:o}):(0,n.jsxs)(`div`,{"data-testid":o,style:{position:`relative`,width:kt,height:At},children:[(0,n.jsx)(`canvas`,{ref:s,role:`img`,"aria-label":r??`EW status arc visualization`,style:{width:kt,height:At,display:`block`,borderRadius:8}}),(0,n.jsx)(x,{...m,parentW:kt,parentH:At})]})}var Pt=280,Ft=96;function It({points:e=[],className:a,colors:o}){let s=(0,t.useRef)(null),c=(0,t.useRef)(new Map),l=(0,t.useRef)(0),u=(0,t.useMemo)(()=>e.filter(Array.isArray).map(([e,t])=>{let n=String(t).match(/-?\d+(\.\d+)?/);return{label:e,value:n?Number(n[0]):0}}),[e]),{mouseRef:d,hoveredRef:f,tooltip:m,hitZonesRef:h}=S(s,{width:Pt,height:Ft});return(0,t.useEffect)(()=>{let e=s.current;if(!e)return;let t=g(e,Pt,Ft);l.current=0;let n=o?.line??i.teal,r=o?.point??i.teal,a=o?.axisLine??i.bd,m,v=()=>{l.current++;let e=l.current;if(t.clearRect(0,0,Pt,Ft),u.length<2){m=requestAnimationFrame(v);return}let o={left:12,right:12,top:16,bottom:20},s=Pt-o.left-o.right,g=Ft-o.top-o.bottom,y=u.map(e=>e.value),x=Math.min(...y),S=Math.max(...y)-x||1,w=e=>o.left+e/(u.length-1)*s,T=e=>o.top+(1-(e-x)/S)*g,E=1-(1-Math.min(e/48,1))**3,D=Math.max(2,Math.floor(E*u.length));if(j(c.current,f.current),h.current=[],t.strokeStyle=p(a,.3),t.lineWidth=.5,t.setLineDash([]),t.beginPath(),t.moveTo(o.left,Ft-o.bottom),t.lineTo(Pt-o.right,Ft-o.bottom),t.stroke(),t.font=`9px 'JetBrains Mono', monospace`,t.fillStyle=p(i.t4,.9),t.textAlign=`center`,u.forEach((e,n)=>{t.fillText(e.label.replace(`Day `,`D`),w(n),Ft-4)}),d.current.over&&f.current){let e=parseInt(f.current.split(`-`)[1]);isNaN(e)||b(t,w(e),o.top,o.top+g)}if(D>1){let e=t.createLinearGradient(0,o.top,0,o.top+g);e.addColorStop(0,p(n,.15)),e.addColorStop(1,p(n,0)),t.fillStyle=e,t.beginPath(),t.moveTo(w(0),o.top+g);for(let e=0;e<D;e++)t.lineTo(w(e),T(u[e].value));t.lineTo(w(D-1),o.top+g),t.closePath(),t.fill(),t.strokeStyle=p(n,.8),t.lineWidth=1.5,t.setLineDash([]),t.beginPath();for(let e=0;e<D;e++){let n=w(e),r=T(u[e].value);e===0?t.moveTo(n,r):t.lineTo(n,r)}t.stroke()}for(let e=0;e<D;e++){let n=w(e),a=T(u[e].value),o=`tp-${e}`,s=c.current.get(o)??0,l=e===u.length-1;C(h.current,o,n,a,10,{label:u[e].label,value:String(u[e].value),color:l?i.red:r}),s>0&&!l&&(_(t,n,a,12*s,r,.2*s),t.fillStyle=p(r,.8),t.beginPath(),t.arc(n,a,3+s*2,0,Math.PI*2),t.fill())}if(D>=u.length){let n=u.length-1,r=w(n),a=T(u[n].value),o=c.current.get(`tp-${n}`)??0,s=k(e,.05,5e-4),l=1+o*.5;t.shadowColor=p(i.red,.5),t.shadowBlur=(8+s*4)*l,t.fillStyle=i.red,t.beginPath(),t.arc(r,a,(3.5+s*1.5)*l,0,Math.PI*2),t.fill(),t.shadowBlur=0}m=requestAnimationFrame(v)};return v(),()=>cancelAnimationFrame(m)},[u,o]),(0,n.jsx)(r,{className:[`canvas-trend-frame`,a].filter(Boolean).join(` `),children:(0,n.jsxs)(`div`,{style:{position:`relative`,width:Pt,height:Ft},children:[(0,n.jsx)(`canvas`,{ref:s,role:`img`,"aria-label":`trend chart`,style:{width:Pt,height:Ft,display:`block`,borderRadius:8}}),(0,n.jsx)(x,{...m,parentW:Pt,parentH:Ft})]})})}function Lt(e,t,n){if(e.measureText(t).width<=n)return t;let r=t;for(;r.length>0&&e.measureText(r+`…`).width>n;)r=r.slice(0,-1);return r+`…`}var Rt=680,zt=8,Z=4,Bt=8,Vt=Z*2+Bt,Ht=36,Ut=Ht/2,Wt=48;function Gt({items:e=[],itemsByEntity:r,onItemClick:a,selectedId:o,labelA:s=`Implemented`,labelB:c=`Unimplemented`,unit:l=`variations`,testID:m}){let[h,v]=z(Rt),y=(0,t.useRef)(null),b=(0,t.useRef)(new Map),C=(0,t.useRef)(0),T=(0,t.useRef)(o);T.current=o;let D=(0,t.useRef)([]),O=(0,t.useCallback)((e,t)=>{let n=e.replace(/-impl$|-un$/,``),r=typeof t==`object`?t.label??n:n,i=D.current.find(e=>e.id===n);a?.(n,r,i?.subentity)},[a]),[k,M]=(0,t.useState)(!1),N=(0,t.useMemo)(()=>e.filter(e=>typeof e==`object`&&!!e),[e]),P=!!(o&&r?.[o]),F=P?r[o]:e,I=(0,t.useMemo)(()=>F.filter(e=>typeof e==`object`&&!!e),[F]),L=(0,t.useMemo)(()=>k?I:I.slice(0,zt),[I,k]);D.current=L;let R=Ut+Wt+L.length*(Vt+Ht)-Ht,{hoveredRef:V,tooltip:te,hitZonesRef:U}=S(y,{width:v,height:R,onClick:a?O:void 0});return(0,t.useEffect)(()=>{let e=y.current;if(!e)return;let t=g(e,v,R);C.current=0,t.font=u.font;let n=L.reduce((e,n)=>Math.max(e,t.measureText(n.abbreviation??n.name??``).width),0);t.font=d.font;let r=L.reduce((e,n)=>Math.max(e,t.measureText(H(n.implemented??0)).width,t.measureText(H(n.unimplemented??0)).width),0),a=Math.max(Math.min(n+20,v*.3),40),o=Math.max(r+24,32),m=v-a-o,h=Math.max(...L.map(e=>e.implemented??0),...L.map(e=>e.unimplemented??0),1),x=L.length*(Vt+Ht)-Ht,S=Ut+(R-Ut-Wt-x)/2,D,O=()=>{C.current++;let e=C.current;t.clearRect(0,0,v,R);let n=E(Math.min(e/60,1));j(b.current,V.current),U.current=[],L.forEach((e,o)=>{let f=A(n,o,L.length,E),g=S+o*(Vt+Ht),v=g,y=g+Z+Bt,x=`${e.id}-impl`,C=`${e.id}-un`,D=b.current.get(x)??0,O=b.current.get(C)??0,k=!P&&T.current&&e.id!==T.current?.6:1,j=(e.implemented??0)/h*m*f,M=(e.unimplemented??0)/h*m*f;if(t.font=u.font,t.fillStyle=D>0||O>0?i.t1:i.t2,t.textAlign=`right`,t.textBaseline=`middle`,t.fillText(Lt(t,e.abbreviation??e.name??``,a-16),a-8,g+Vt/2),t.textBaseline=`alphabetic`,w(U.current,x,0,g,a,Vt,{label:e.name??e.abbreviation??``,value:`${H((e.implemented??0)+(e.unimplemented??0))} total ${l}`,sublabel:`${s}: ${H(e.implemented??0)} · ${c}: ${H(e.unimplemented??0)}`,color:i.green},void 0,a+Math.max(j,M)+16+r+14),j>0){D>0&&_(t,a+j/2,v+Z/2,j*.15,i.green,.18*D);let e=t.createLinearGradient(a,0,a+j,0);e.addColorStop(0,p(i.green,.7*k)),e.addColorStop(1,p(i.green,1*k)),t.fillStyle=e,t.beginPath(),t.roundRect(a,v,j,Z,Z/2),t.fill()}if(w(U.current,x,a,v,Math.max(j,1),Z,{label:e.name,value:H(e.implemented??0),color:i.green},g+Vt/2,a+Math.max(j,M)+16+r+14),f>.4&&(t.globalAlpha=Math.min(1,(f-.4)/.4),t.font=d.font,t.fillStyle=i.t1,t.textAlign=`left`,t.textBaseline=`middle`,t.fillText(H(e.implemented??0),a+j+16,v+Z/2),t.globalAlpha=1,t.textBaseline=`alphabetic`),M>0){O>0&&_(t,a+M/2,y+Z/2,M*.15,i.amber,.18*O);let e=t.createLinearGradient(a,0,a+M,0);e.addColorStop(0,p(i.amber,.5*k)),e.addColorStop(1,p(i.amber,.9*k)),t.fillStyle=e,t.beginPath(),t.roundRect(a,y,M,Z,Z/2),t.fill()}w(U.current,C,a,y,Math.max(M,1),Z,{label:e.name,value:H(e.unimplemented??0),color:i.amber},g+Vt/2,a+Math.max(j,M)+16+r+14),f>.4&&(t.globalAlpha=Math.min(1,(f-.4)/.4),t.font=d.font,t.fillStyle=i.t1,t.textAlign=`left`,t.textBaseline=`middle`,t.fillText(H(e.unimplemented??0),a+M+16,y+Z/2),t.globalAlpha=1,t.textBaseline=`alphabetic`)});let o=S+x+28;t.font=f.font,t.textBaseline=`middle`,t.textAlign=`left`;let g=t.measureText(s).width,y=t.measureText(c).width,k=18+g,M=18+y,N=(v-(k+24+M))/2,F=t.createLinearGradient(N,0,N+12,0);F.addColorStop(0,p(i.green,.7)),F.addColorStop(1,p(i.green,1)),t.fillStyle=F,t.beginPath(),t.rect(N,o-6,12,12),t.fill(),t.fillStyle=f.color,t.fillText(s,N+12+6,o);let I=N+k+24,z=t.createLinearGradient(I,0,I+12,0);z.addColorStop(0,p(i.amber,.5)),z.addColorStop(1,p(i.amber,.9)),t.fillStyle=z,t.beginPath(),t.rect(I,o-6,12,12),t.fill(),t.fillStyle=f.color,t.fillText(c,I+12+6,o),t.textBaseline=`alphabetic`,D=requestAnimationFrame(O)};return O(),()=>cancelAnimationFrame(D)},[L,R,v]),N.length===0?(0,n.jsx)(`div`,{ref:h,style:{width:`100%`},children:(0,n.jsx)(B,{width:v,height:160,testID:m})}):(0,n.jsxs)(`div`,{ref:h,"data-testid":m,style:{width:`100%`},children:[(0,n.jsxs)(`div`,{style:{position:`relative`,height:R},children:[(0,n.jsx)(`canvas`,{ref:y,role:`img`,"aria-label":`Implemented vs unimplemented variations per contractor — split bar`,style:{width:`100%`,height:R,display:`block`}}),(0,n.jsx)(x,{...te,parentW:v,parentH:R})]}),N.length>zt&&(0,n.jsx)(`div`,{style:{marginTop:8},children:(0,n.jsx)(ee,{expanded:k,onToggle:()=>M(e=>!e)})})]})}var Kt=800,qt=360;function Jt({items:e=[],onItemClick:r,testID:a}){let[o,c]=z(Kt),l=(0,t.useRef)(null),f=(0,t.useRef)(new Map),m=(0,t.useRef)(0),h=(0,t.useRef)(e);h.current=e;let v=(0,t.useCallback)((e,t)=>{let n=typeof t==`object`?t.label??e:e,i=h.current.find(t=>t.id===e);r?.(e,n,i?.subentity)},[r]),{hoveredRef:y,tooltip:b,hitZonesRef:C}=S(l,{width:c,height:qt,onClick:r?v:void 0});return(0,t.useEffect)(()=>{let t=l.current;if(!t)return;let n=g(t,c,qt);m.current=0;let r=Math.round(c*.125),a=Math.round(c*.525),o=Math.round(c*.9),h=Math.max(60,Math.round(c*.1375)),v=e.reduce((e,t)=>e+(t.base??0),0),b=e.reduce((e,t)=>e+(t.variation??0),0),x=e.reduce((e,t)=>e+(t.total??0),0),S=qt-20-26,E=S-6*(e.length-1),D=20,O=e.map((e,t)=>{let n=Math.max(24,(e.total??0)/(x||1)*E),i={x:r-h/2,y:D,h:n,cy:D+n/2,c:e,color:s[t%s.length]};return D+=n+6,i}),k=E-14,M=Math.max(28,v/(x||1)*k),N=Math.max(18,b/(x||1)*k),P=20+(S-(M+N+14))/2,F={x:a-h/2,y:P,h:M,cy:P+M/2},I={x:a-h/2,y:P+M+14,h:N,cy:P+M+14+N/2},L={x:o-h/2,y:20,h:S,cy:20+S/2},R,z=()=>{m.current++;let t=m.current;n.clearRect(0,0,c,qt),n.letterSpacing=u.letterSpacing;let s=T(Math.min(t/80,1));if(j(f.current,y.current),C.current=[],e.forEach((t,r)=>{let i=O[r],o=A(s,r,e.length,T),c=f.current.get(t.id)??0;if(o<.01)return;let l=(t.base??0)/(t.total||1),u=(t.variation??0)/(t.total||1),d=i.h*l,p=i.h*u,m=i.y+d/2,g=i.y+d+p/2,_=Math.max(2,(t.base??0)/v*M),y=Math.max(2,(t.variation??0)/b*N),x=F.y+e.slice(0,r).reduce((e,t)=>e+(t.base??0)/v*M,0)+_/2,S=I.y+e.slice(0,r).reduce((e,t)=>e+(t.variation??0)/b*N,0)+y/2,C=c*.2+.18;Yt(n,i.x+h,m,a-h/2,x,_*o,i.color,C),Yt(n,i.x+h,g,a-h/2,S,y*o,i.color,C*.75)}),s>.3){let e=Math.min(1,(s-.3)/.7),t=L.y+v/x*S/2,r=L.y+S-b/x*S/2;Yt(n,a+h/2,F.cy,o-h/2,t,M*e,i.blue,.25*e),Yt(n,a+h/2,I.cy,o-h/2,r,N*e,i.amber,.22*e)}if([`Contractors`,`Components`,`Total`].forEach((e,t)=>{let i=[r,a,o][t];n.font=u.font,n.fillStyle=u.color,n.textAlign=`center`,n.fillText(e,i,qt-8)}),e.forEach((t,r)=>{let a=O[r],o=A(s,r,e.length,T),c=f.current.get(t.id)??0;w(C.current,t.id,a.x,a.y,h,a.h,{label:t.name,value:t.totalLabel??String(t.total??0),sublabel:`${t.baseLabel??String(t.base??0)} + ${t.variationLabel??String(t.variation??0)}`,color:a.color}),c>0&&_(n,a.x+h/2,a.cy,h*.6,a.color,.12*c),n.fillStyle=p(a.color,(.3+c*.15)*o),n.strokeStyle=p(a.color,(.55+c*.25)*o),n.lineWidth=1,n.beginPath(),n.roundRect(a.x,a.y,h*o,a.h,4),n.fill(),n.stroke(),o>.6&&a.h>=24&&(n.globalAlpha=Math.min(1,(o-.6)/.4),n.font=u.font,n.fillStyle=c>0?a.color:p(i.t2,.9),n.textAlign=`center`,n.textBaseline=`middle`,n.fillText(t.abbreviation??t.name?.slice(0,6)??``,a.x+h/2,a.h>=36?a.cy-5:a.cy),a.h>=36&&(n.font=`400 12px 'Satoshi Variable', 'DM Sans', sans-serif`,n.fillStyle=p(i.t3,.8),n.fillText(t.totalLabel??String(t.total??0),a.x+h/2,a.cy+7)),n.globalAlpha=1,n.textBaseline=`alphabetic`)}),s>.2){let e=Math.min(1,(s-.2)/.4);_(n,a,F.cy,30,i.blue,.1*e),n.fillStyle=p(i.blue,.3*e),n.strokeStyle=p(i.blue,.5*e),n.lineWidth=1,n.beginPath(),n.roundRect(F.x,F.y,h,F.h*e,4),n.fill(),n.stroke(),n.globalAlpha=e,n.textBaseline=`middle`,n.font=u.font,n.fillStyle=i.blue,n.textAlign=`center`,n.fillText(`Base Value`,a,F.cy-6),n.font=d.font,n.fillStyle=d.color,n.fillText(H(v),a,F.cy+8),n.globalAlpha=1,n.textBaseline=`alphabetic`,_(n,a,I.cy,24,i.amber,.1*e),n.fillStyle=p(i.amber,.22*e),n.strokeStyle=p(i.amber,.4*e),n.beginPath(),n.roundRect(I.x,I.y,h,I.h*e,4),n.fill(),n.stroke(),n.globalAlpha=e,n.textBaseline=`middle`,n.font=u.font,n.fillStyle=i.amber,n.textAlign=`center`,n.fillText(`Variations`,a,I.cy-4),n.font=d.font,n.fillStyle=d.color,n.fillText(H(b),a,I.cy+8),n.globalAlpha=1,n.textBaseline=`alphabetic`}if(s>.5){let e=Math.min(1,(s-.5)/.5);_(n,o,L.cy,44,i.blue,.2*e),n.fillStyle=p(i.blue,.25*e),n.strokeStyle=p(i.blue,.6*e),n.lineWidth=1.5,n.beginPath(),n.roundRect(L.x,L.y,h,L.h*e,6),n.fill(),n.stroke(),n.globalAlpha=e,n.textBaseline=`middle`,n.font=u.font,n.fillStyle=i.t2,n.textAlign=`center`,n.fillText(`Total Commitment`,o,L.cy-12),n.font=d.font,n.fillStyle=i.blue,n.fillText(H(x),o,L.cy+6),n.globalAlpha=1,n.textBaseline=`alphabetic`}R=requestAnimationFrame(z)};return z(),()=>cancelAnimationFrame(R)},[e,c]),(0,n.jsxs)(`div`,{ref:o,"data-testid":a,style:{position:`relative`,width:`100%`,height:qt},children:[(0,n.jsx)(`canvas`,{ref:l,role:`img`,"aria-label":`Weekly report flow — base value and variations per contractor flowing to total commitment`,style:{width:`100%`,height:qt,display:`block`}}),(0,n.jsx)(x,{...b,parentW:c,parentH:qt})]})}function Yt(e,t,n,r,i,a,o,s){let c=(t+r)/2;e.beginPath(),e.moveTo(t,n-a/2),e.bezierCurveTo(c,n-a/2,c,i-a/2,r,i-a/2),e.lineTo(r,i+a/2),e.bezierCurveTo(c,i+a/2,c,n+a/2,t,n+a/2),e.closePath(),e.fillStyle=p(o,s),e.fill()}var Xt=680,Zt=160,Qt={left:8,right:90,top:16,bottom:16},$t=150,en=4,tn=48,nn=8;function rn(e,t,n){if(e.measureText(t).width<=n)return t;let r=t;for(;r.length>0&&e.measureText(r+`…`).width>n;)r=r.slice(0,-1);return r+`…`}function an(e,t){let n=Math.abs(e),r=e<0?`-`:``;return n>=1e6?`${r}${t}${(n/1e6).toFixed(1)}M`:n>=1e3?`${r}${t}${(n/1e3).toFixed(1)}K`:`${r}${t}${n.toFixed(0)}`}function on({rows:e,valuePrefix:r=`$`,onItemClick:a,testID:o}){let[s,c]=z(Xt),l=(0,t.useRef)(null),f=(0,t.useRef)(new Map),[m,h]=(0,t.useState)(!1),g=(0,t.useRef)(e);g.current=e;let v=(0,t.useCallback)((e,t)=>{let n=typeof t==`object`?t.label??e:e,r=g.current.find(t=>t.id===e);a?.(e,n,r?.subentity)},[a]),y=e.filter(e=>e!=null&&typeof e.value==`number`),b=m?y:y.slice(0,nn),C=b.length,T=Math.max(...y.map(e=>Math.abs(e.value)),1),D=c-Qt.left-$t-Qt.right,O=C*tn,k=Qt.top+Qt.bottom+O,{hoveredRef:M,tooltip:N,hitZonesRef:P}=S(l,{width:c,height:k,onClick:a?v:void 0});return pe(l,c,k,(e,t)=>{j(f.current,M.current),P.current=[],b.forEach((n,a)=>{let o=A(t,a,C,E),s=Qt.top+a*tn,l=s+(tn-en)/2,m=s+tn/2,h=Qt.left+$t,g=f.current.get(n.id)??0,v=Math.abs(n.value)/T*D*o,y=n.valueLabel??an(n.value,r);if(e.save(),e.font=u.font,e.fillStyle=g>0?i.cyan:u.color,e.textAlign=`right`,e.textBaseline=`middle`,e.fillText(rn(e,n.name,$t-16),h-8,m),w(P.current,n.id,0,s,h,tn,{label:n.name,value:y,color:i.cyan}),e.fillStyle=p(i.cyan,.1),e.beginPath(),e.roundRect(h,l,D,en,en/2),e.fill(),v>0){g>0&&_(e,h+v,l+en/2,v*.25,i.cyan,.14*g);let t=e.createLinearGradient(h,l,h+v,l);t.addColorStop(0,p(i.cyan,.2+g*.05)),t.addColorStop(.55,p(i.cyan,.55+g*.15)),t.addColorStop(1,p(i.cyan,.72+g*.18)),e.fillStyle=t,e.beginPath(),e.roundRect(h,l,v,en,en/2),e.fill()}g>0&&v>0&&(e.strokeStyle=p(i.cyan,.6*g),e.lineWidth=1,e.beginPath(),e.roundRect(h,l,v,en,en/2),e.stroke()),o>.35&&(e.globalAlpha=Math.min(1,(o-.35)/.4),e.font=d.font,e.fillStyle=g>0?i.cyan:d.color,e.textAlign=`right`,e.textBaseline=`middle`,e.fillText(y,c-8,m)),e.restore(),w(P.current,n.id,h,s,Math.max(v,1),tn,{label:n.name,value:y,color:i.cyan})})},!0,{easing:E}),y.length===0?(0,n.jsx)(`div`,{ref:s,style:{width:`100%`},children:(0,n.jsx)(B,{width:c,height:Zt,message:`No data available`,testID:o})}):(0,n.jsxs)(`div`,{ref:s,"data-testid":o,style:{width:`100%`},children:[(0,n.jsxs)(`div`,{style:{position:`relative`},children:[(0,n.jsx)(`canvas`,{ref:l,role:`img`,"aria-label":`Horizontal bar chart`,style:{width:`100%`,height:k,display:`block`,borderRadius:8}}),(0,n.jsx)(x,{...N,parentW:c,parentH:k})]}),y.length>nn&&(0,n.jsx)(`div`,{style:{marginTop:8},children:(0,n.jsx)(ee,{expanded:m,onToggle:()=>h(e=>!e),"data-testid":o?`${o}-toggle`:void 0})})]})}function sn({config:e,className:t,colorOffset:r=0,onItemClick:i,selectedId:a,listenerItems:o}){let s=o?void 0:a;if(e.type===Y.LINE)return(0,n.jsx)(Ie,{rows:e.rows,className:t});if(e.type===Y.AREA)return(0,n.jsx)(F,{rows:e.rows,className:t});if(e.type===Y.BAR)return(0,n.jsx)(R,{rows:e.rows,className:t});if(e.type===Y.PIE)return(0,n.jsx)(Je,{rows:e.rows,variant:`pie`,className:t});if(e.type===Y.DONUT)return(0,n.jsx)(Je,{rows:e.rows,variant:`donut`,className:t});if(e.type===Y.SANKEY)return(0,n.jsx)(at,{rows:e.rows,className:t});if(e.type===Y.FLOW)return(0,n.jsx)(it,{selectedEntity:e.selectedEntity,className:t});if(e.type===Y.TREND)return(0,n.jsx)(It,{points:e.points,className:t});if(e.type===Y.MINI_BARS)return(0,n.jsx)(ze,{rows:e.rows,className:t});if(e.type===Y.STACKED_HORIZONTAL_BAR){let t=e.data??{items:e.items??[]};return(0,n.jsx)(Oe,{data:o?{items:o}:t,dataByEntity:e.dataByEntity,onItemClick:i,selectedId:s})}if(e.type===Y.MULTI_METRIC_CONSTELLATION)return(0,n.jsx)(be,{items:e.items});if(e.type===Y.PROGRESS_RACE)return(0,n.jsx)(se,{items:o||e.items,itemsByEntity:e.itemsByEntity,colorOffset:r,onItemClick:i,selectedId:s});if(e.type===Y.HUB_AND_SPOKE_RADIAL)return(0,n.jsx)(Nt,{segments:e.segments,title:e.title,unitLabel:e.unitLabel});if(e.type===Y.DOT_MATRIX)return(0,n.jsx)(Fe,{items:e.items});if(e.type===Y.RANKED_CARD_LEADERBOARD)return(0,n.jsx)(Pe,{items:o||e.items,onItemClick:i});if(e.type===Y.PROPORTIONAL_BAND)return(0,n.jsx)(Ot,{severities:o||e.severities,colorOffset:r,onItemClick:i});if(e.type===Y.RADIAL_FAN_TREE){let t=o&&!Array.isArray(o)?o:null,a=t?t.items:o||e.items;return(0,n.jsx)(We,{total:t?t.total:o?o.reduce((e,t)=>e+(t.count??0),0):e.total,totalLabel:t?t.totalLabel:e.totalLabel,items:a,dataByEntity:e.dataByEntity,colorOffset:r,onItemClick:i,selectedId:s})}if(e.type===Y.SEMI_CIRCULAR_GAUGE){let t=Array.isArray(o)?o[0]:void 0;return(0,n.jsx)(fe,{confirmed:t?Number(t.confirmed??0):e.confirmed,total:t?Number(t.total??1):e.total,label:e.label,gaugeByEntity:e.gaugeByEntity,colorOffset:r,selectedId:s,onItemClick:i,subentity:e.subentity})}if(e.type===Y.SEGMENTED_SPLIT_BAR)return(0,n.jsx)(Gt,{items:o||e.items,itemsByEntity:e.itemsByEntity,labelA:e.labelA,labelB:e.labelB,unit:e.unit,onItemClick:i,selectedId:s});if(e.type===Y.BALANCE_SCALE){let t=e.left,r=e.right;if(o&&!Array.isArray(o)){let e=o;if(e.items?.length>=2){let n=Number(e.items[0].count??0),i=Number(e.items[1].count??0);t={value:n,count:1,label:`£`+H(n,2)},r={value:i,count:1,label:`£`+H(i,2)}}}return(0,n.jsx)(ct,{left:t,right:r,leftTitle:e.leftTitle,rightTitle:e.rightTitle,unit:e.unit,dataByEntity:e.dataByEntity,onItemClick:i,selectedId:s})}return e.type===Y.AREA_LINE?(0,n.jsx)(dt,{points:e.points}):e.type===Y.TREND_VIEW?(0,n.jsx)(St,{points:(o&&!Array.isArray(o)?o.points??[]:void 0)??e.points,colorOffset:r}):e.type===Y.WEEKLY_FLOW?(0,n.jsx)(Jt,{items:o||e.items,onItemClick:i}):e.type===Y.HORIZONTAL_BAR?(0,n.jsx)(on,{rows:o||e.rows,valuePrefix:e.valuePrefix,onItemClick:i}):(0,n.jsx)(`div`,{className:`viz-empty`,children:`Visualization unavailable`})}var cn=[];function ln(e){try{return JSON.parse(decodeURIComponent(e))}catch{return null}}function un(){for(;cn.length;){let e=cn.pop();e&&e.unmount()}}function dn(){un(),document.querySelectorAll(`[data-d3-viz]`).forEach(t=>{let r=t.dataset.d3Viz;if(!r)return;let i=ln(r);if(!i)return;let a=(0,e.createRoot)(t);cn.push(a),a.render((0,n.jsx)(sn,{config:i}))})}function fn(e){return encodeURIComponent(JSON.stringify(e))}function pn({rows:e=[],className:t,colors:r}){return(0,n.jsx)(Je,{rows:e,variant:`donut`,className:t,colors:r})}var Q={bg:`transparent`,border:`transparent`,t1:i.t1,t2:i.t2,t3:i.t3,t4:i.t4,red:i.red,amber:i.amber,green:i.green},$=`'Satoshi Variable', 'DM Sans', sans-serif`,mn={color:`#F7F7F7`,fontFamily:$,fontSize:24,fontWeight:500,lineHeight:`32px`},hn={color:`#B3B5B6`,fontFamily:$,fontSize:18,fontWeight:400,lineHeight:`20px`};function gn({items:e=[]}){let t=e.filter(e=>e.value);return t.length===0?null:(0,n.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:20},children:t.map((e,t)=>(0,n.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,justifyContent:`space-between`,alignItems:`center`,width:286,minHeight:129,padding:`20px 16px`,flexShrink:0,border:`1px solid rgba(255,255,255,0.20)`,background:`rgba(255,255,255,0.05)`,boxShadow:`3.42px 3.42px 3.42px 0px rgba(0,0,0,0.30)`,boxSizing:`border-box`},children:[(0,n.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:24,flex:1,minWidth:0},children:[(0,n.jsx)(`div`,{style:{...mn,color:`#FFFFFF`},children:e.value}),(0,n.jsx)(`div`,{style:{...hn,color:`rgba(255,255,255,0.70)`},children:e.label})]}),e.icon&&(0,n.jsx)(`div`,{style:{width:60,height:60,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,n.jsx)(`img`,{src:e.icon,width:60,height:60,alt:``,style:{objectFit:`contain`}})})]},t))})}function _n({items:e=[]}){let t=e.filter(e=>e.name??e.value);return t.length===0?null:(0,n.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:t.map((e,t)=>(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,padding:`10px 0px`,background:Q.bg,border:`1px solid ${Q.border}`},children:[(0,n.jsx)(`span`,{style:{fontSize:18,fontWeight:500,color:Q.t2,background:`transparent`,padding:`2px 8px`,borderRadius:4,fontFamily:$,flexShrink:0},children:e.name}),(0,n.jsx)(`span`,{style:{...mn,fontSize:18,color:Q.t1,minWidth:70,flexShrink:0},children:e.value}),(0,n.jsx)(`span`,{style:{...hn,flex:1},children:e.kpiLabel})]},t))})}function vn({items:e=[]}){let t=e.filter(e=>e.value);return t.length===0?null:(0,n.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:20},children:t.map((e,t)=>(0,n.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,justifyContent:`space-between`,alignItems:`center`,width:286,minHeight:129,padding:`20px 16px`,flexShrink:0,border:`1px solid rgba(255,255,255,0.20)`,background:`rgba(255,255,255,0.05)`,boxShadow:`3.42px 3.42px 3.42px 0px rgba(0,0,0,0.30)`,boxSizing:`border-box`},children:[(0,n.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:24,flex:1,minWidth:0},children:[(0,n.jsx)(`div`,{style:{...mn,color:`#FFFFFF`},children:e.value}),(0,n.jsx)(`div`,{style:{...hn,color:`rgba(255,255,255,0.70)`},children:e.label})]}),e.icon&&(0,n.jsx)(`div`,{style:{width:60,height:60,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,n.jsx)(`img`,{src:e.icon,width:60,height:60,alt:``,style:{objectFit:`contain`}})})]},t))})}var yn={red:Q.red,amber:Q.amber,green:Q.green};function bn({items:e=[]}){let t=e.filter(e=>e.text);return t.length===0?null:(0,n.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:t.map((e,t)=>(yn[e.severity],(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:10,padding:`10px 0px`,background:Q.bg,border:`1px solid ${Q.border}`},children:[(0,n.jsx)(`span`,{style:{width:7,height:7,borderRadius:`50%`,background:i.t2,flexShrink:0,marginTop:5}}),(0,n.jsx)(`span`,{style:{...hn,color:`#B3B5B6`},children:e.text})]},t)))})}function xn({min:e,max:t,unit:r,dots:a=[],chips:o=[]}){let s=a.filter(e=>e.name);if(s.length===0)return null;let c=t-e;return(0,n.jsxs)(`div`,{children:[(0,n.jsxs)(`div`,{style:{position:`relative`,height:90,padding:`10px 0px`},children:[(0,n.jsx)(`div`,{style:{position:`absolute`,top:38,left:8,right:8,height:2,background:`rgba(255,255,255,0.08)`,borderRadius:1}}),(0,n.jsxs)(`div`,{style:{position:`absolute`,top:43,left:0,fontSize:16,color:Q.t4,fontFamily:$},children:[e,r]}),(0,n.jsxs)(`div`,{style:{position:`absolute`,top:43,right:0,fontSize:16,color:Q.t4,fontFamily:$},children:[t,r]}),s.map((t,a)=>{let o=(t.val-e)/c*100,s=t.color??i.blue,l=a%2==0;return(0,n.jsxs)(`div`,{style:{position:`absolute`,left:`${o}%`,top:0,transform:`translateX(-50%)`},children:[l&&(0,n.jsxs)(`div`,{style:{textAlign:`center`,marginBottom:2},children:[(0,n.jsx)(`div`,{style:{fontSize:18,color:s,fontFamily:$,whiteSpace:`nowrap`},children:t.name}),(0,n.jsxs)(`div`,{style:{fontSize:18,fontWeight:500,color:s,fontFamily:$,whiteSpace:`nowrap`},children:[t.val,r]})]}),(0,n.jsx)(`div`,{style:{width:10,height:10,borderRadius:`50%`,background:s,boxShadow:`0 0 8px ${s}70`,margin:l?`0 auto`:`26px auto 0`}}),!l&&(0,n.jsxs)(`div`,{style:{textAlign:`center`,marginTop:4},children:[(0,n.jsx)(`div`,{style:{fontSize:18,color:s,fontFamily:$,whiteSpace:`nowrap`},children:t.name}),(0,n.jsxs)(`div`,{style:{fontSize:18,fontWeight:500,color:s,fontFamily:$,whiteSpace:`nowrap`},children:[t.val,r]})]})]},a)})]}),o&&o.length>0&&(0,n.jsx)(vn,{items:o})]})}function Sn({leftPct:e,leftLabel:t,leftValue:r,leftColor:a,rightPct:o,rightLabel:s,rightValue:c,rightColor:l,chips:u}){if(!t&&!s)return null;let d=a??i.blue,f=l??i.blue;return(0,n.jsxs)(`div`,{children:[(0,n.jsxs)(`div`,{style:{display:`flex`,borderRadius:6,overflow:`hidden`,height:36,margin:`10px 0`},children:[(0,n.jsx)(`div`,{style:{width:`${e}%`,background:d+`38`,display:`flex`,alignItems:`center`,justifyContent:`flex-end`,paddingRight:12},children:(0,n.jsx)(`span`,{style:{fontSize:18,fontWeight:500,color:Q.t2,fontFamily:$},children:r})}),(0,n.jsx)(`div`,{style:{width:1,background:`rgba(255,255,255,0.12)`,flexShrink:0}}),(0,n.jsx)(`div`,{style:{width:`${o}%`,background:f+`2A`,display:`flex`,alignItems:`center`,paddingLeft:12},children:(0,n.jsx)(`span`,{style:{fontSize:18,fontWeight:500,color:Q.t2,fontFamily:$},children:c})})]}),(0,n.jsxs)(`div`,{style:{display:`flex`,marginBottom:u?4:0},children:[(0,n.jsx)(`div`,{style:{width:`${e}%`},children:(0,n.jsxs)(`span`,{style:{fontSize:18,color:d,fontFamily:$},children:[e,`% `,t]})}),(0,n.jsx)(`div`,{style:{width:`${o}%`,paddingLeft:10},children:(0,n.jsxs)(`span`,{style:{fontSize:18,color:f,fontFamily:$},children:[o,`% `,s]})})]}),u&&u.length>0&&(0,n.jsx)(vn,{items:u})]})}function Cn({pct:e,label:t,color:r,chips:a}){if(e==null&&!t)return null;let o=r??i.blue,s=2*Math.PI*30,c=s*(1-e/100);return(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:20},children:[(0,n.jsxs)(`div`,{style:{position:`relative`,flexShrink:0,width:80,height:80},children:[(0,n.jsxs)(`svg`,{width:80,height:80,style:{transform:`rotate(-90deg)`},children:[(0,n.jsx)(`circle`,{cx:40,cy:40,r:30,fill:`none`,stroke:`rgba(255,255,255,0.07)`,strokeWidth:8}),(0,n.jsx)(`circle`,{cx:40,cy:40,r:30,fill:`none`,stroke:o,strokeWidth:8,strokeDasharray:s,strokeDashoffset:c,strokeLinecap:`round`})]}),(0,n.jsx)(`div`,{style:{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,textAlign:`center`},children:(0,n.jsxs)(`div`,{style:{fontSize:18,fontWeight:500,color:o,fontFamily:$},children:[e,`%`]})})]}),(0,n.jsxs)(`div`,{style:{flex:1},children:[(0,n.jsx)(`div`,{style:{...hn,padding:`10px 0px`},children:t}),a&&(0,n.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:a.map((e,t)=>(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`baseline`,gap:8,padding:`10px 10px`,background:Q.bg,border:`1px solid ${Q.border}`,borderRadius:5},children:[(0,n.jsx)(`span`,{style:{...mn,color:Q.t2},children:e.value}),(0,n.jsx)(`span`,{style:{...mn,color:Q.t2,fontWeight:400,userSelect:`none`},children:`|`}),(0,n.jsx)(`span`,{style:{...hn},children:e.label})]},t))})]})]})}function wn({items:e=[]}){let t=e.filter(e=>e.name??e.value);return t.length===0?null:(0,n.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:t.map((e,t)=>(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,padding:`10px 0px`,background:Q.bg,border:`1px solid ${Q.border}`},children:[(0,n.jsx)(`span`,{style:{fontSize:18,fontWeight:500,color:Q.t2,background:`transparent`,padding:`2px 7px`,borderRadius:4,fontFamily:$,flexShrink:0,minWidth:62,textAlign:`center`},children:e.name}),(0,n.jsx)(`div`,{style:{flex:1,height:4,background:`rgba(255,255,255,0.07)`,borderRadius:0,overflow:`hidden`},children:(0,n.jsx)(`div`,{style:{height:`100%`,width:`${e.pct}%`,background:e.color??i.purple,borderRadius:0,opacity:.75}})}),(0,n.jsx)(`span`,{style:{fontSize:18,fontWeight:400,color:Q.t2,fontFamily:$,flexShrink:0,minWidth:320,textAlign:`right`},children:[e.value,e.badge,e.sublabel].filter(Boolean).join(` `)})]},t))})}var Tn={red:Q.red,amber:Q.amber,green:Q.green};function En({items:e=[]}){let t=e.filter(e=>e.text);return t.length===0?null:(0,n.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:t.map((e,t)=>{let r=Tn[e.severity];return(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:10,padding:`9px 12px`,background:`transparent`},children:[(0,n.jsx)(`span`,{style:{fontSize:18,fontWeight:500,color:r,background:r+`20`,padding:`2px 7px`,borderRadius:4,fontFamily:$,flexShrink:0},children:e.tag}),(0,n.jsx)(`span`,{style:{flex:1,...hn},children:e.text}),(0,n.jsx)(`span`,{style:{...hn,flexShrink:0,marginTop:1},children:e.date})]},t)})})}function Dn({columns:e=[],rows:t=[]}){return t.length===0?null:(0,n.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:[(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,padding:`0 0px 6px`,borderBottom:`1px solid ${Q.border}`},children:[(0,n.jsx)(`div`,{style:{minWidth:64}}),e.map((e,t)=>(0,n.jsx)(`div`,{style:{flex:1,fontSize:18,fontWeight:500,color:Q.t2,fontFamily:$,textTransform:`uppercase`,letterSpacing:.6},children:e},t))]}),t.map((e,t)=>(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,padding:`8px 0px`,background:Q.bg,border:`1px solid ${Q.border}`},children:[(0,n.jsx)(`span`,{style:{fontSize:18,fontWeight:500,color:Q.t1,background:`transparent`,padding:`2px 8px`,borderRadius:4,fontFamily:$,flexShrink:0,minWidth:64,textAlign:`center`},children:e.label}),e.cells.map((e,t)=>(0,n.jsx)(`span`,{style:{flex:1,fontSize:18,fontWeight:500,color:Q.t2,fontFamily:$},children:e},t))]},t))]})}function On({block:e}){if(!e)return null;switch(e.type){case`stats`:return(0,n.jsx)(gn,{items:e.items});case`ranked`:return(0,n.jsx)(_n,{items:e.items});case`chips`:return(0,n.jsx)(vn,{items:e.items});case`badges`:return(0,n.jsx)(bn,{items:e.items});case`dot-strip`:return(0,n.jsx)(xn,{min:e.min,max:e.max,unit:e.unit,dots:e.dots,chips:e.chips});case`proportion`:return(0,n.jsx)(Sn,{leftPct:e.leftPct,leftLabel:e.leftLabel,leftValue:e.leftValue,leftColor:e.leftColor,rightPct:e.rightPct,rightLabel:e.rightLabel,rightValue:e.rightValue,rightColor:e.rightColor,chips:e.chips});case`ring`:return(0,n.jsx)(Cn,{pct:e.pct,label:e.label,color:e.color,chips:e.chips});case`scorecard-rows`:return(0,n.jsx)(wn,{items:e.items});case`flags-list`:return(0,n.jsx)(En,{items:e.items});case`comparison-rows`:return(0,n.jsx)(Dn,{columns:e.columns,rows:e.rows});default:return null}}var kn=`'Satoshi Variable', 'DM Sans', sans-serif`,An={color:`#C2C2C2`,fontFamily:kn,fontSize:18,fontWeight:400,lineHeight:1.65};function jn({text:e}){return(0,n.jsxs)(`div`,{style:{padding:`8px 0px`,border:`transparent`,borderRadius:5,background:`transparent`},children:[(0,n.jsx)(`span`,{style:{fontSize:18,fontWeight:500,color:i.t1,fontFamily:kn,lineHeight:1.65,marginRight:8},children:`Takeaway`}),(0,n.jsx)(`span`,{style:{...An},children:e})]})}var Mn=`data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_3072_19126)'%3e%3cpath%20d='M14.375%208.125H18.125V4.375'%20stroke='%2369DFE9'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M14.7188%2015C13.736%2015.9274%2012.5017%2016.5446%2011.1701%2016.7745C9.83859%2017.0044%208.46881%2016.8368%207.23196%2016.2926C5.99511%2015.7485%204.94602%2014.852%204.21579%2013.715C3.48556%2012.5781%203.10656%2011.2511%203.12615%209.90004C3.14574%208.54893%203.56304%207.23355%204.32593%206.11825C5.08881%205.00295%206.16344%204.13719%207.41555%203.62914C8.66765%203.12109%2010.0417%202.99329%2011.366%203.26169C12.6904%203.5301%2013.9062%204.18281%2014.8617%205.13828L18.125%208.125'%20stroke='%2369DFE9'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_3072_19126'%3e%3crect%20width='20'%20height='20'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e`;function Nn(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``)}var Pn=56;function Fn({items:e,colorOffset:r=0,title:i,"data-testid":a}){let[o,s]=(0,t.useState)(void 0),[c,l]=(0,t.useState)(void 0),[u,d]=(0,t.useState)(null),[f,p]=(0,t.useState)(null),[m,h]=(0,t.useState)(null),[g,_]=(0,t.useState)(null),[v,y]=(0,t.useState)(null),[b,x]=(0,t.useState)(0),[S,C]=(0,t.useState)(0),w=(0,t.useRef)(null),T=(0,t.useRef)(null),E=(0,t.useRef)(null),D=(0,t.useRef)(null),O=(0,t.useRef)(null);(0,t.useEffect)(()=>{let e=w.current;if(!e)return;let t=t=>{let{centerClientY:n,centerClientX:r,sourceClientY:i}=t.detail,a=e.getBoundingClientRect(),o=t.target,s=o.getBoundingClientRect();T.current=o,E.current=n-s.top,D.current=r-s.left,O.current=i==null?null:i-s.top,h(n-a.top),_(r-a.left),y(i==null?null:i-a.top),x(a.height),C(a.width)};return e.addEventListener(`viz-item-click`,t),()=>e.removeEventListener(`viz-item-click`,t)},[]),(0,t.useLayoutEffect)(()=>{if(!u||T.current===null||E.current===null)return;let e=w.current;if(!e)return;let t=T.current.getBoundingClientRect(),n=e.getBoundingClientRect();h(t.top-n.top+E.current),D.current!==null&&_(t.left-n.left+D.current),O.current!==null&&y(t.top-n.top+O.current),x(n.height),C(n.width)},[u]);let k=(0,t.useCallback)((e,t,n,r)=>{if(!(r!=null&&(!Array.isArray(r)||r.length>0)))return;let i=Nn(t);s(t=>{let a=t===i?void 0:i;return l(a?n:void 0),a?(p(e),d(r)):(d(null),p(null)),a})},[]),A=(0,t.useCallback)(()=>{s(void 0),l(void 0),d(null),p(null),h(null),_(null),y(null),T.current=null,E.current=null,D.current=null,O.current=null},[]),j=f!==null&&m!==null,M=m??b/2,N=e.length-1,P=S>0?(S-N*Pn)/e.length:null,F=t=>j&&f===t&&e[t]?.type===Y.BALANCE_SCALE,I=f!==null&&e[f]?.type===Y.BALANCE_SCALE&&j&&g!==null&&v!==null&&P!==null;return(0,n.jsxs)(`div`,{className:`viz-group`,"data-testid":a,children:[i&&(0,n.jsx)(`div`,{className:`viz-group__title`,children:i}),(0,n.jsx)(`div`,{className:`viz-group__bar`,children:o?(0,n.jsxs)(`button`,{type:`button`,className:`viz-group__reset-btn`,onClick:A,"aria-label":`Reset selection`,children:[(0,n.jsx)(`img`,{src:Mn,alt:``,className:`viz-group__reset-icon`}),`Reset`]}):(0,n.jsx)(`span`,{className:`viz-group__hint`,children:`↑ Click a row to drill down`})}),(0,n.jsxs)(`div`,{ref:w,className:`viz-group__charts`,children:[e.flatMap((t,i)=>{let a=f===null?i===e.length-1:i!==f,s=F(i)&&g!==null&&v!==null&&P!==null,l=(0,n.jsxs)(`div`,{className:`viz-group__chart viz-group__chart--${t.type}${a?` viz-group__chart--listener`:``}`,children:[a&&(0,n.jsx)(`div`,{className:`viz-group__listener-label`,children:f===null?null:c}),(0,n.jsx)(sn,{config:t,colorOffset:r+i,onItemClick:(e,t,n)=>k(i,e,t,n),selectedId:o,listenerItems:i!==f&&u?u:void 0})]},i);if(i===e.length-1)return[l];let d=f!==null&&f>i,p=d?-.7:Pn+.7,m=g!==null&&P!==null?g-P:d?Pn+20:-20,h=`M ${s?d?Pn:0:m} ${M} H ${p}`;return[l,(0,n.jsx)(`div`,{className:`viz-group__connector${j?` viz-group__connector--active`:``}`,children:(0,n.jsxs)(`svg`,{className:`viz-group__connector-svg`,xmlns:`http://www.w3.org/2000/svg`,"aria-hidden":`true`,children:[!s&&(0,n.jsx)(`line`,{x1:m,y1:M-7,x2:m,y2:M+7,className:`viz-group__connector-tick`}),(0,n.jsx)(`path`,{d:h,className:`viz-group__connector-path`}),(0,n.jsx)(`circle`,{cx:p,cy:M,r:`4`,className:`viz-group__connector-dot`})]})},`connector-${i}`)]}),I&&(0,n.jsxs)(`svg`,{className:`viz-group__route-svg`,xmlns:`http://www.w3.org/2000/svg`,"aria-hidden":`true`,children:[(0,n.jsx)(`line`,{x1:g-7,y1:v,x2:g+7,y2:v,className:`viz-group__connector-tick`}),(0,n.jsx)(`path`,{d:`M ${g} ${v} L ${g} ${M} H ${P}`,className:`viz-group__connector-path`})]})]})]})}exports.AreaChart=F,exports.BarChart=R,exports.CHART_PALETTE=l,exports.ChartFrame=r,exports.DonutChart=pn,exports.GRAD=a,exports.KeyHighlights=On,exports.LineChart=Ie,exports.MiniBars=ze,exports.PALETTE=s,exports.PieChart=Je,exports.ProcessSankey=it,exports.RankingSankey=at,exports.SOLID=o,exports.SankeySvg=Xe,exports.SeriesChart=P,exports.Takeaway=jn,exports.Trend=St,exports.TrendChart=It,exports.VisualizationGroup=Fn,exports.VisualizationRenderer=sn,exports.cleanupVisualizationMounts=un,exports.hydrateVisualizationMounts=dn,exports.serializeVisualizationConfig=fn;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`react-dom/client`),t=require(`react`),n=require(`react/jsx-runtime`);function r({children:e,className:t=``}){return(0,n.jsx)(`div`,{className:`d3-chart ${t}`.trim(),children:e})}var i={bg:`#0C0E12`,bgL:`#0C1420`,sf:`#13161B`,bd:`#22262F`,blue:`#4C93D9`,cyan:`#36BFFA`,orange:`#EC772A`,red:`#EC772A`,green:`#5DA537`,purple:`#818FF8`,amber:`#EEBF3B`,teal:`#69DFE9`,tealDark:`#00818F`,barBg:`#7DB9DF`,t1:`#F7F9FA`,t2:`#B3B5B6`,t3:`#94979C`,t4:`#334155`},a={teal:[`#00818F`,`#69DFE9`],violet:[`#5B3CB1`,`#C8B6F3`],mint:[`#27837A`,`#81E8CE`],magenta:[`#8732A7`,`#E7A1F0`],sky:[`#0068BE`,`#8EC2F6`],blue:[`#084CF0`,`#8BA9FF`],purple:[`#5C42B8`,`#9DA5FD`],royal:[`#2556C8`,`#A9B1F8`],success:[`#58B21C`,`#97F558`],warning:[`#FFD974`,`#E4AA0D`],error:[`#EC8C42`,`#E46A0D`]},o={teal:`#69DFE9`,violet:`#C8B6F3`,mint:`#81E8CE`,magenta:`#E7A1F0`,sky:`#0068BE`,blue:`#084CF0`,purple:`#5C42B8`,royal:`#2556C8`,success:`#58B21C`,warning:`#E4AA0D`,error:`#E46A0D`},s=[i.blue,i.amber,i.purple,i.green,i.red],c=[a.teal,a.mint,a.sky,a.blue,a.royal,a.purple,a.violet,a.magenta],l=[o.teal,o.mint,o.sky,o.blue,o.royal,o.purple,o.violet,o.magenta],u={font:`400 16px 'Satoshi Variable', 'DM Sans', sans-serif`,color:`#F7F7F7`,letterSpacing:`0px`},d={font:`500 16px 'Satoshi Variable', 'DM Sans', sans-serif`,color:`#F7F7F7`},f={font:`400 18px 'Satoshi Variable', 'DM Sans', sans-serif`,color:`#B3B5B6`,letterSpacing:`0px`};function p(e,t=1){let n=e.replace(`#`,``);return`rgba(${parseInt(n.substring(0,2),16)},${parseInt(n.substring(2,4),16)},${parseInt(n.substring(4,6),16)},${t})`}function m(e,t,n){return e+(t-e)*n}function h(e,t,n){let r=e=>{let t=e.replace(`#`,``);return[parseInt(t.substring(0,2),16),parseInt(t.substring(2,4),16),parseInt(t.substring(4,6),16)]},[i,a,o]=r(e),[s,c,l]=r(t),u=e=>Math.max(0,Math.min(255,Math.round(e)));return[u(m(i,s,n)),u(m(a,c,n)),u(m(o,l,n))].map(e=>e.toString(16).padStart(2,`0`)).join(``).replace(/^/,`#`)}function g(e,t,n,r=2){e.width=t*r,e.height=n*r;let i=e.getContext(`2d`);return i.scale(r,r),i}function _(e,t,n,r,i,a=.3){let o=e.createRadialGradient(t,n,0,t,n,r);o.addColorStop(0,p(i,a)),o.addColorStop(1,p(i,0)),e.fillStyle=o,e.beginPath(),e.arc(t,n,r,0,Math.PI*2),e.fill()}function v(e,t,n,r,a=50,o=p(i.blue,.05)){for(let i=0;i<a;i++)e.beginPath(),e.arc((Math.sin(r*.001+i*23)*.5+.5)*t,(Math.cos(r*8e-4+i*37)*.5+.5)*n,.6,0,Math.PI*2),e.fillStyle=o,e.fill()}function y(e,t,n,r,i=.015){e.fillStyle=`rgba(0,0,0,${i})`;let a=r*.5%6;for(let r=a;r<n;r+=3)e.fillRect(0,r,t,1)}function b(e,t,n,r,a=p(i.t1,.08)){e.strokeStyle=a,e.lineWidth=1,e.setLineDash([3,3]),e.beginPath(),e.moveTo(t,n),e.lineTo(t,r),e.stroke(),e.setLineDash([])}function x({visible:e,x:r,y:a,content:o,parentW:s,parentH:c}){let l=(0,t.useRef)(null);if((0,t.useLayoutEffect)(()=>{let t=l.current;if(!t)return;let n=t.offsetWidth,u=t.offsetHeight,d=s??400,f=c??800,p=r+14,m=a-u-14;p+n>d-4&&(p=r-n-14),m<4&&(m=a+14),p<4&&(p=4),m+u>f-4&&(m=f-u-4),t.style.transform=`translate(${p}px, ${m}px)`,t.style.opacity=e?`1`:`0`;let h=o&&typeof o==`object`&&o.color?o.color:i.blue;t.style.setProperty(`--tooltip-accent`,h??i.blue)},[e,r,a,s,o]),!o)return null;let u=typeof o==`object`,d=u?o.label:null,f=u?o.value:o,p=u?o.sublabel:null;return(0,n.jsxs)(`div`,{ref:l,style:{position:`absolute`,top:0,left:0,minWidth:80,pointerEvents:`none`,background:i.sf,border:`1px solid ${i.bd}`,borderLeft:`2px solid var(--tooltip-accent)`,borderRadius:6,padding:`8px 12px`,opacity:0,transition:`opacity 0.15s ease`,zIndex:20,fontFamily:`'Satoshi Variable', 'DM Sans', sans-serif`},children:[d&&(0,n.jsx)(`div`,{style:{fontSize:14,fontWeight:400,color:i.t2,marginBottom:3,whiteSpace:`nowrap`,lineHeight:`20px`},children:d}),f&&(0,n.jsx)(`div`,{style:{fontSize:16,fontWeight:500,color:i.t1,whiteSpace:`nowrap`,lineHeight:`22px`},children:f}),p&&(0,n.jsx)(`div`,{style:{fontSize:14,fontWeight:400,color:`var(--tooltip-accent)`,marginTop:3,whiteSpace:`nowrap`,lineHeight:`20px`},children:p})]})}function S(e,{width:n,height:r,onClick:i,enabled:a=!0}){let o=(0,t.useRef)({x:-1,y:-1,over:!1}),s=(0,t.useRef)(null),c=(0,t.useRef)([]),[l,u]=(0,t.useState)({visible:!1,x:0,y:0,content:null}),d=(0,t.useCallback)((e,t,n)=>{u({visible:!0,x:e,y:t,content:n})},[]),f=(0,t.useCallback)(()=>{u(e=>e.visible?{visible:!1,x:e.x,y:e.y,content:e.content}:e)},[]);return(0,t.useEffect)(()=>{let t=e.current;if(!t||!a)return;let l=e=>{let i=t.getBoundingClientRect(),a=n/i.width,l=r/i.height;o.current.x=(e.clientX-i.left)*a,o.current.y=(e.clientY-i.top)*l,o.current.over=!0;let u=null,p=c.current;for(let e=p.length-1;e>=0;e--)if(p[e].test(o.current.x,o.current.y)){u=p[e];break}let m=s.current;s.current=u?u.id:null,t.style.cursor=u?`pointer`:`default`,u?d((e.clientX-i.left)*a,(e.clientY-i.top)*l,u.data):m&&f()},u=()=>{o.current={x:-1,y:-1,over:!1},s.current&&(s.current=null,t.style.cursor=`default`,f())},p=()=>{if(s.current&&i){let e=c.current.find(e=>e.id===s.current);if(e){let a=t.getBoundingClientRect(),o=a.top+e.centerY*(a.height/r),s=a.left+e.centerX*(a.width/n),c=e.sourceY==null?void 0:a.top+e.sourceY*(a.height/r);t.dispatchEvent(new CustomEvent(`viz-item-click`,{bubbles:!0,detail:{centerClientY:o,centerClientX:s,sourceClientY:c}})),i(e.id,e.data)}}};return t.addEventListener(`mousemove`,l),t.addEventListener(`mouseleave`,u),t.addEventListener(`click`,p),()=>{t.removeEventListener(`mousemove`,l),t.removeEventListener(`mouseleave`,u),t.removeEventListener(`click`,p)}},[e,n,r,a,i,d,f]),{mouseRef:o,hoveredRef:s,tooltip:l,showTooltip:d,hideTooltip:f,hitZonesRef:c}}function C(e,t,n,r,i,a,o){e.push({id:t,data:a,centerY:r,centerX:o??n,test:(e,t)=>(e-n)**2+(t-r)**2<=i*i})}function w(e,t,n,r,i,a,o,s,c,l){e.push({id:t,data:o,centerY:s??r+a/2,centerX:c??n+i/2,sourceY:l,test:(e,t)=>e>=n&&e<=n+i&&t>=r&&t<=r+a})}var T=e=>1-(1-e)**3,E=e=>1-(1-e)**4,D=e=>e===1?1:1-2**(-10*e),O=e=>{let t=1.70158;return 1+(t+1)*(e-1)**3+t*(e-1)**2},k=(e,t=.04,n=.001)=>Math.sin(e*t)*Math.exp(-Math.min(e*n,4)),A=(e,t,n,r=T)=>{let i=Math.min(.06,.5/n),a=t*i,o=1-(n-1)*i;return r(Math.max(0,Math.min((e-a)/o,1)))};function j(e,t,n=.12){e.forEach((r,i)=>{let a=i===t?1:0,o=r+(a-r)*n;Math.abs(o-a)<.005?a===0?e.delete(i):e.set(i,1):e.set(i,o)}),t&&!e.has(t)&&e.set(t,0)}var M=760,N=250;function P({rows:e=[],variant:a,className:o,colors:s}){let c=(0,t.useRef)(null),l=(0,t.useRef)(new Map),u=(0,t.useRef)(0),{mouseRef:d,hoveredRef:f,tooltip:m,hitZonesRef:h}=S(c,{width:M,height:N});return(0,t.useEffect)(()=>{let t=c.current;if(!t)return;let n=g(t,M,N);u.current=0;let r=s?.line??i.blue,o=s?.point??i.blue,m=s?.axisLine??i.bd,v=s?.areaFill??i.blue,y={top:24,right:24,bottom:44,left:24},x=M-y.left-y.right,S=N-y.top-y.bottom,w,T=()=>{u.current++;let t=u.current;if(n.clearRect(0,0,M,N),e.length<2){w=requestAnimationFrame(T);return}let s=e.map(e=>e.pricing??0),c=Math.max(100,...s),g=t=>y.left+t/(e.length-1)*x,E=e=>y.top+(1-e/c)*S,O=D(Math.min(t/48,1)),A=Math.max(2,Math.floor(O*e.length));j(l.current,f.current),h.current=[],n.strokeStyle=p(i.bd,.2),n.lineWidth=.5;for(let e=0;e<=4;e++){let t=y.top+e/4*S;n.beginPath(),n.moveTo(y.left,t),n.lineTo(y.left+x,t),n.stroke()}if(n.strokeStyle=p(m,.4),n.lineWidth=1,n.setLineDash([]),n.beginPath(),n.moveTo(y.left,E(0)),n.lineTo(y.left+x,E(0)),n.stroke(),d.current.over&&f.current){let e=parseInt(f.current.split(`-`)[1]);isNaN(e)||b(n,g(e),y.top,y.top+S)}if(a===`area`&&A>1){let t=n.createLinearGradient(0,y.top,0,y.top+S);t.addColorStop(0,p(v,.12)),t.addColorStop(1,p(v,0)),n.fillStyle=t,n.beginPath(),n.moveTo(g(0),y.top+S);for(let t=0;t<A;t++)n.lineTo(g(t),E(e[t].pricing??0));n.lineTo(g(A-1),y.top+S),n.closePath(),n.fill()}if(A>1){n.strokeStyle=p(r,.85),n.lineWidth=2,n.setLineDash([]),n.beginPath();for(let t=0;t<A;t++){let r=g(t),i=E(e[t].pricing??0);t===0?n.moveTo(r,i):n.lineTo(r,i)}n.stroke()}for(let r=0;r<A;r++){let s=g(r),c=E(e[r].pricing??0),u=`sc-${r}`,d=l.current.get(u)??0,f=r===e.length-1;C(h.current,u,s,c,12,{label:e[r].vendor,value:String(e[r].pricing??0),color:f?i.red:o}),d>0&&_(n,s,c,16*d,o,.2*d);let m=f?k(t,.05,5e-4):0,v=a===`area`?5:6;f?(n.shadowColor=p(i.red,.5),n.shadowBlur=(8+m*4)*(1+d*.5),n.fillStyle=i.red,n.beginPath(),n.arc(s,c,(v+m*1.5)*(1+d*.3),0,Math.PI*2),n.fill(),n.shadowBlur=0):(n.fillStyle=p(o,.7+d*.3),n.beginPath(),n.arc(s,c,v+d*2,0,Math.PI*2),n.fill()),n.font=`10px 'JetBrains Mono', monospace`,n.fillStyle=p(i.t3,.6+d*.3),n.textAlign=`center`,n.fillText(e[r].vendor,s,N-14)}w=requestAnimationFrame(T)};return T(),()=>cancelAnimationFrame(w)},[e,a,s]),(0,n.jsx)(r,{className:o,children:(0,n.jsxs)(`div`,{style:{position:`relative`,width:M,height:N},children:[(0,n.jsx)(`canvas`,{ref:c,role:`img`,"aria-label":`${a} chart`,style:{width:M,height:N,display:`block`,borderRadius:8}}),(0,n.jsx)(x,{...m,parentW:M,parentH:N})]})})}function F({rows:e=[],className:t,colors:r}){return(0,n.jsx)(P,{rows:e,variant:`area`,className:t,colors:r})}var I=760,L=280;function R({rows:e=[],className:a,colors:o}){let c=(0,t.useRef)(null),l=(0,t.useRef)(new Map),u=(0,t.useRef)(0),{hoveredRef:d,tooltip:f,hitZonesRef:m}=S(c,{width:I,height:L});return(0,t.useEffect)(()=>{let t=c.current;if(!t)return;let n=g(t,I,L);u.current=0;let r=o?.bars??s,a=o?.axisLine??i.bd,f=o?.valueLabel??i.t2,h={top:24,right:24,bottom:56,left:24},v=L-h.top-h.bottom,y=(I-h.left-h.right)/Math.max(e.length,1),b=Math.max(100,...e.map(e=>e.pricing??0)),x=h.top+v,S,C=()=>{u.current++;let t=u.current;n.clearRect(0,0,I,L);let o=E(Math.min(t/48,1));j(l.current,d.current),m.current=[],n.strokeStyle=p(a,.4),n.lineWidth=1,n.setLineDash([]),n.beginPath(),n.moveTo(h.left,x),n.lineTo(I-h.right,x),n.stroke(),e.forEach((t,a)=>{let s=h.left+a*y,c=A(o,a,e.length,E),u=b>0?(t.pricing??0)/b*v:0,d=Math.max(u>0?4:0,u*c),g=r[a%r.length],S=l.current.get(t.id??`bar-${a}`)??0;w(m.current,t.id??`bar-${a}`,s+4,x-d,y-8,d,{label:t.vendor,value:String(t.pricing??0),color:g}),d>0&&(S>0&&_(n,s+y/2,x-d/2,y*.8,g,.12*S),n.shadowColor=p(g,.2*(S>0?S:0)),n.shadowBlur=S>0?6:0,n.fillStyle=p(g,.5+S*.25),n.beginPath(),n.roundRect(s+4,x-d,y-8,d,[4,4,0,0]),n.fill(),n.shadowBlur=0,S>0&&(n.strokeStyle=p(g,.4*S),n.lineWidth=1,n.beginPath(),n.roundRect(s+4,x-d,y-8,d,[4,4,0,0]),n.stroke())),c>.5&&d>0&&(n.globalAlpha=Math.min(1,(c-.5)*2),n.font=`bold 10px 'JetBrains Mono', monospace`,n.fillStyle=S>0?g:p(f,.7),n.textAlign=`center`,n.fillText(String(t.pricing??``),s+y/2,x-d-6),n.globalAlpha=1),n.font=`${S>0?`bold `:``}9px 'JetBrains Mono', monospace`,n.fillStyle=S>0?g:p(i.t3,.6),n.textAlign=`center`,n.fillText(t.vendor,s+y/2,L-14)}),S=requestAnimationFrame(C)};return C(),()=>cancelAnimationFrame(S)},[e,o]),(0,n.jsx)(r,{className:a,children:(0,n.jsxs)(`div`,{style:{position:`relative`,width:I,height:L},children:[(0,n.jsx)(`canvas`,{ref:c,role:`img`,"aria-label":`bar chart`,style:{width:I,height:L,display:`block`,borderRadius:8}}),(0,n.jsx)(x,{...f,parentW:I,parentH:L})]})})}function z(e){let n=(0,t.useRef)(null),[r,i]=(0,t.useState)(e);return(0,t.useEffect)(()=>{let e=n.current;if(!e)return;let t=new ResizeObserver(e=>{let t=e[0]?.contentRect.width;t&&t>0&&i(Math.floor(t))});return t.observe(e),()=>t.disconnect()},[]),[n,r]}function B({width:e,height:t,message:r=`No data available`,testID:i}){return(0,n.jsx)(`div`,{"data-testid":i,style:{width:e,height:t,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:8,background:`rgba(255,255,255,0.03)`,color:`rgba(255,255,255,0.35)`,fontSize:14,fontFamily:`'Satoshi Variable', 'DM Sans', sans-serif`},children:r})}function ee({expanded:e,onToggle:t,labelExpanded:r=`View Less`,labelCollapsed:i=`View More`,testID:a}){return(0,n.jsxs)(`button`,{type:`button`,"data-testid":a,onClick:t,style:{display:`flex`,width:90,height:20,justifyContent:`center`,alignItems:`center`,gap:4,boxSizing:`border-box`,border:`none`,borderRadius:6,color:`#69DFE9`,fontSize:14,fontFamily:`'Satoshi Variable', 'DM Sans', sans-serif`,fontStyle:`normal`,fontWeight:400,lineHeight:`19.5px`,textAlign:`center`,cursor:`pointer`,userSelect:`none`},children:[e?r:i,(0,n.jsx)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 10 10`,fill:`none`,style:{transform:e?`rotate(180deg)`:`rotate(0deg)`},children:(0,n.jsx)(`path`,{d:`M2 3.5L5 6.5L8 3.5`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})]})}var V=[{value:0xe8d4a51000,suffix:`T`,divisor:0xe8d4a51000},{value:1e9,suffix:`B`,divisor:1e9},{value:1e6,suffix:`M`,divisor:1e6},{value:1e3,suffix:`K`,divisor:1e3}];function H(e,t=1){let n=Math.abs(e),r=e<0?`-`:``;for(let e of V)if(n>=e.value)return`${r}${(n/e.divisor).toFixed(t)}${e.suffix}`;return t===0?`${r}${Math.round(n)}`:`${r}${parseFloat(n.toFixed(t))}`}var te=660,U=4,ne=30,re=ne/2,ie=ne/2,ae=8;function oe(e,t,n){if(e.measureText(t).width<=n)return t;let r=t;for(;r.length>0&&e.measureText(r+`…`).width>n;)r=r.slice(0,-1);return r+`…`}function se({items:e=[],itemsByEntity:r,onItemClick:a,selectedId:o,colorOffset:s=0,testID:l}){let[f,m]=z(te),h=(0,t.useRef)(null),b=(0,t.useRef)(0),E=(0,t.useRef)(new Map),D=(0,t.useRef)(o);D.current=o;let O=(0,t.useRef)([]),k=(0,t.useCallback)((e,t)=>{let n=typeof t==`object`?t.label??e:e,r=O.current.find(t=>t.id===e);a?.(e,n,r?.subentity)},[a]),[A,j]=(0,t.useState)(!1),M=!!(o&&r?.[o]),N=M?r[o]:e,P=(0,t.useMemo)(()=>e.filter(e=>typeof e==`object`&&!!e),[e]),F=(0,t.useMemo)(()=>N.filter(e=>typeof e==`object`&&!!e),[N]),I=(0,t.useMemo)(()=>[...F].sort((e,t)=>(t.percentage??0)-(e.percentage??0)),[F]),L=(0,t.useMemo)(()=>A?I:I.slice(0,ae),[I,A]);O.current=L;let R=L.length,V=re+ie+R*U+Math.max(0,R-1)*ne,{hoveredRef:se,tooltip:ce,hitZonesRef:le}=S(h,{width:m,height:V,onClick:a?k:void 0});return(0,t.useEffect)(()=>{let e=h.current;if(!e)return;let t=g(e,m,V);b.current=0,t.font=u.font,t.letterSpacing=u.letterSpacing;let n=L.reduce((e,n)=>Math.max(e,t.measureText(n.name??n.abbreviation??``).width),0);t.font=d.font;let r=L.reduce((e,n)=>Math.max(e,t.measureText(H(n.total??0)).width),0),a=Math.max(Math.min(n+20,m*.3),40),o=Math.max(r+20,28),l=m-a-o,[f,x]=c[s%c.length],S,O=()=>{b.current++;let e=b.current;t.clearRect(0,0,m,V),t.letterSpacing=u.letterSpacing,le.current=[],E.current.forEach((e,t)=>{let n=t===se.current?1:0,r=e+(n-e)*.12;Math.abs(r-n)<.005?n===0?E.current.delete(t):E.current.set(t,1):E.current.set(t,r)}),se.current&&!E.current.has(se.current)&&E.current.set(se.current,0),v(t,m,V,e,40,p(x,.04));let n=Math.max(...L.map(e=>e.total??0),1);L.forEach((o,s)=>{let c=E.current.get(o.id)??0,m=!M&&D.current&&o.id!==D.current?.6:1,h=re+s*(U+ne);t.fillStyle=p(i.barBg,.2),t.beginPath(),t.rect(a,h,l,U),t.fill();let g=(o.total??0)/n,v=a+l*Math.min(g,g*T(Math.min(1,e*.005)));if(v>a+2){let e=t.createLinearGradient(a,0,v,0);e.addColorStop(0,p(f,.75*m)),e.addColorStop(1,p(x,.95*m)),t.fillStyle=e,t.beginPath(),t.rect(a,h,v-a,U),t.fill()}c>0&&_(t,v,h+U/2,12*c,x,.35*c);let y={label:o.name,sublabel:o.totalLabel??(o.total==null?void 0:H(o.total)),color:x};w(le.current,o.id,0,h-ne/2,a+l,U+ne,y,void 0,a+l+12+r+14),C(le.current,o.id,v,h+U/2,10,y),t.font=d.font,t.fillStyle=c>0?p(x,1*m):p(i.t1,.85*m),t.textAlign=`left`,t.textBaseline=`middle`,t.fillText(H(o.total??0),a+l+12,h+U/2),t.font=u.font,t.fillStyle=c>0?p(x,1*m):p(i.t2,.85*m),t.textAlign=`right`,t.fillText(oe(t,o.name??o.abbreviation??``,a-16),a-8,h+U/2)}),y(t,m,V,e,.015),S=requestAnimationFrame(O)};return O(),()=>cancelAnimationFrame(S)},[L,V,s,m]),I.length===0?(0,n.jsx)(`div`,{ref:f,style:{width:`100%`},children:(0,n.jsx)(B,{width:m,height:160,testID:l})}):(0,n.jsxs)(`div`,{ref:f,"data-testid":l,style:{width:`100%`},children:[(0,n.jsxs)(`div`,{style:{position:`relative`},children:[(0,n.jsx)(`canvas`,{ref:h,role:`img`,"aria-label":`Commitment race — contractors ranked by commitment percentage`,style:{width:`100%`,height:V,display:`block`,borderRadius:8}}),(0,n.jsx)(x,{...ce,parentW:m,parentH:V})]}),P.length>ae&&(0,n.jsx)(`div`,{style:{marginTop:8},children:(0,n.jsx)(ee,{expanded:A,onToggle:()=>j(e=>!e)})})]})}var ce=480,le=310,ue=18;function de(e,t,n){let r=t.split(` `),i=[],a=``;for(let t of r){let r=a?`${a} ${t}`:t;e.measureText(r).width>n&&a?(i.push(a),a=t):a=r}return a&&i.push(a),i}function fe({confirmed:e,total:r,label:a,colorOffset:o=0,selectedId:s,selectedLabel:l,gaugeByEntity:d,onItemClick:m,subentity:h,testID:v}){let y=(0,t.useRef)(null),b=(0,t.useRef)(0),C=s&&d?.[s]?d[s]:{confirmed:e,total:r},E=C.confirmed,D=C.total,k=(0,t.useCallback)(()=>{m?.(`confirmed`,a??`confirmed`,h)},[m,a,h]),{tooltip:A,hitZonesRef:j}=S(y,{width:ce,height:le,onClick:m?k:void 0});return(0,t.useEffect)(()=>{let e=y.current;if(!e)return;let t=g(e,ce,le);b.current=0;let[n,r]=c[o%c.length],s=ce/2,l=Math.PI,d=2*Math.PI,m=Math.PI,h,v=()=>{b.current++;let e=b.current;t.clearRect(0,0,ce,le),t.letterSpacing=u.letterSpacing,j.current=[],w(j.current,`confirmed`,s-148,27,296,148,{label:a??`Confirmed`,value:`${H(E??0)} / ${H(D??0)}`,sublabel:`${Math.round((E??0)/(D||1)*100)}%`,color:r});let o=T(Math.min(e/80,1)),c=O(Math.min(e/72,1)),g=Math.round((E??0)/(D||1)*100),y=l+g/100*m*o;t.beginPath(),t.arc(s,175,148,l,d),t.strokeStyle=p(r,.28),t.lineWidth=4,t.lineCap=`round`,t.stroke(),t.lineCap=`butt`,t.beginPath(),t.moveTo(s,175),t.arc(s,175,133,l,y),t.closePath(),t.fillStyle=p(n,.35*o),t.fill();let x=s+Math.cos(y)*148,S=175+Math.sin(y)*148;_(t,x,S,10,r,.3*o);let C=t.createLinearGradient(s+Math.cos(l)*148,175+Math.sin(l)*148,x,S);C.addColorStop(0,p(n,.9*o)),C.addColorStop(1,p(r,1*o)),t.beginPath(),t.arc(s,175,148,l,y),t.strokeStyle=C,t.lineWidth=4,t.lineCap=`round`,t.stroke(),t.lineCap=`butt`;let k=l+g/100*m*c,A=s+Math.cos(k)*133,M=175+Math.sin(k)*133,N=s-Math.cos(k)*24,P=175-Math.sin(k)*24,F=-Math.sin(k),I=Math.cos(k),L=2.5*c;t.beginPath(),t.moveTo(A,M),t.lineTo(s+F*L,175+I*L),t.lineTo(N+F*1,P+I*1),t.lineTo(N-F*1,P-I*1),t.lineTo(s-F*L,175-I*L),t.closePath(),t.fillStyle=p(i.t1,c),t.fill(),t.beginPath(),t.arc(s,175,11,0,Math.PI*2),t.strokeStyle=p(r,.85*c),t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(s,175,9,0,Math.PI*2),t.fillStyle=i.t1,t.fill(),[[0,`0%`],[.5,`50%`],[1,`100%`]].forEach(([e,n])=>{let r=l+e*m,i=e===1?184:168,a=s+Math.cos(r)*i,o=175+Math.sin(r)*i;t.font=u.font,t.fillStyle=u.color,t.textAlign=`center`,t.fillText(n,a,o+4)}),o>.4&&(t.globalAlpha=Math.min(1,(o-.4)/.4),t.font=`700 32px 'Satoshi Variable', 'DM Sans', sans-serif`,t.fillStyle=i.t1,t.textAlign=`center`,t.fillText(`${Math.round(g*c)}%`,s,247),t.globalAlpha=1),o>.7&&a&&(t.globalAlpha=Math.min(1,(o-.7)/.3),t.font=f.font,t.fillStyle=f.color,t.textAlign=`center`,de(t,`${H(E??0)} of ${H(D??0)} ${a}`,ce-40).forEach((e,n)=>{t.fillText(e,s,287+n*ue)}),t.globalAlpha=1),h=requestAnimationFrame(v)};return v(),()=>cancelAnimationFrame(h)},[E,D,a,o,s,l]),(0,n.jsxs)(`div`,{"data-testid":v,style:{position:`relative`,width:`100%`,maxWidth:ce,margin:`0 auto`},children:[(0,n.jsx)(`canvas`,{ref:y,role:`img`,"aria-label":`Compensation event gauge — ${Math.round((E??0)/(D||1)*100)}% of NCEs confirmed as compensation events`,style:{width:`100%`,aspectRatio:`${ce} / ${le}`,display:`block`}}),(0,n.jsx)(x,{...A,parentW:ce,parentH:le})]})}function pe(e,n,r,i,a=!0,o={}){let s=(0,t.useRef)(0),{easing:c=T,durationFrames:l=48}=o;(0,t.useEffect)(()=>{let t=e.current;if(!t||!n||!r)return;let o=t.getContext(`2d`);if(!o)return;t.width=n*2,t.height=r*2,o.scale(2,2);let u;s.current=0;let d=()=>{s.current++;let e=s.current;o.clearRect(0,0,n,r);let t=a?Math.min(e/l,1):1;if(i(o,c(t),e),t<1)u=requestAnimationFrame(d);else{let e=()=>{s.current++,o.clearRect(0,0,n,r),i(o,1,s.current),u=requestAnimationFrame(e)};u=requestAnimationFrame(e)}};return d(),()=>cancelAnimationFrame(u)},[n,r,a])}var W=780,me=234,he=130,ge=52,_e=[i.blue,i.amber,i.purple,i.green],ve=[`Base Value`,`Variations`,`Commitment`],ye=[`Base`,`Var`,`Commit`];function be({items:e=[],testID:r}){let a=(0,t.useRef)(null),o=(0,t.useRef)(new Map),{hoveredRef:s,tooltip:c,hitZonesRef:l}=S(a,{width:W,height:me}),d=(0,t.useMemo)(()=>e.filter(e=>typeof e==`object`&&!!e),[e]),m=(0,t.useMemo)(()=>{let e=Math.max(...d.map(e=>e.base??0)),t=Math.max(...d.map(e=>e.variation??0));return d.map((n,r)=>{let i=W*(.12+r*.19),a=he,o=Math.min(W*.075,ge),s=_e[r%_e.length],c=[(n.base??0)/(e||1)*100,(n.variation??0)/(t||1)*100,n.percentage??0],l=[n.baseLabel??String(n.base??0),n.variationLabel??String(n.variation??0),`${n.percentage??0}%`],u=c.map((e,t)=>{let n=-Math.PI/2+t/ve.length*Math.PI*2,r=e/100,s=o*Math.max(.08,r);return{name:ve[t],short:ye[t],label:l[t],val:Math.round(e),x:i+Math.cos(n)*s,y:a+Math.sin(n)*s,angle:n,norm:r}}),d=u.reduce((e,t)=>e+t.x,0)/u.length,f=u.reduce((e,t)=>e+t.y,0)/u.length,p=Math.sqrt(u.reduce((e,t)=>e+(t.x-d)**2+(t.y-f)**2,0)/u.length);return{...n,cx:i,cy:a,baseR:o,stars:u,scatter:p,color:s}})},[d]);return pe(a,W,me,(e,t,n)=>{j(o.current,s.current),l.current=[],v(e,W,me,n,30),m.forEach((t,r)=>{let a=t.color,s=`constellation-${r}`,c=o.current.get(s)??0;e.beginPath(),e.arc(t.cx,t.cy,t.baseR+5,0,Math.PI*2),e.strokeStyle=p(i.bd,.08+.08*c),e.lineWidth=.5,e.stroke(),e.beginPath(),t.stars.forEach((t,n)=>{n===0?e.moveTo(t.x,t.y):e.lineTo(t.x,t.y)}),e.closePath(),e.fillStyle=p(a,.04+.03*c),e.fill(),e.strokeStyle=p(a,.15+.1*c),e.lineWidth=.8,e.stroke(),t.stars.forEach((i,s)=>{let c=k(n,.05,5e-4)*.3+.7,d=3.5*c,f=`star-${r}-${s}`,m=o.current.get(f)??0,h=e.createRadialGradient(i.x,i.y,0,i.x,i.y,d*4);h.addColorStop(0,p(a,(.2+.1*m)*c)),h.addColorStop(1,p(a,0)),e.fillStyle=h,e.beginPath(),e.arc(i.x,i.y,d*4,0,Math.PI*2),e.fill(),e.beginPath(),e.arc(i.x,i.y,d+m*2,0,Math.PI*2),e.fillStyle=p(a,(.8+.2*m)*c),e.fill();let g=Math.sin(i.angle)<-.3;e.textAlign=`center`,e.textBaseline=`middle`,g?(e.font=u.font,e.fillStyle=p(a,.5+.15*m),e.fillText(i.short,i.x,i.y-24),e.font=u.font,e.fillStyle=p(a,.8+.15*m),e.fillText(i.label,i.x,i.y-11)):(e.font=u.font,e.fillStyle=p(a,.5+.15*m),e.fillText(i.short,i.x,i.y+11),e.font=u.font,e.fillStyle=p(a,.8+.15*m),e.fillText(i.label,i.x,i.y+24)),C(l.current,f,i.x,i.y,d*4+2,{label:i.name,value:i.label,sublabel:t.abbreviation??t.name.slice(0,6),color:a})}),c>0&&_(e,t.cx,t.cy,16*c,a,.15*c),e.beginPath(),e.arc(t.cx,t.cy,t.baseR+12,0,Math.PI*2),e.strokeStyle=p(a,.1+k(n,.03,5e-4)*.05),e.lineWidth=1,e.stroke(),e.font=u.font,e.textAlign=`center`,e.textBaseline=`alphabetic`,e.fillStyle=c>0?t.color:u.color,e.fillText(t.abbreviation??t.name.slice(0,6),t.cx,t.cy+t.baseR+26),C(l.current,s,t.cx,t.cy,t.baseR+5,{label:t.name,value:`${t.totalLabel??String(t.total??0)} total`,sublabel:`${t.percentage??0}% committed · scatter ${t.scatter.toFixed(1)}`,color:a})}),e.font=f.font,e.textAlign=`center`,e.textBaseline=`middle`,e.fillStyle=f.color,e.fillText(`▲ top = Base value · ▼▸ lower-right = Variations · ◂▼ lower-left = Commitment % · hover stars for details`,W/2,me-14),y(e,W,me,n,.012)},!0),m.length===0?(0,n.jsx)(B,{width:W,height:me,testID:r}):(0,n.jsxs)(`div`,{"data-testid":r,style:{position:`relative`,width:W,height:me},children:[(0,n.jsx)(`canvas`,{ref:a,role:`img`,"aria-label":`Contract value breakdown per contractor — multi-KPI constellation chart`,style:{width:W,height:me,display:`block`}}),(0,n.jsx)(x,{...c,parentW:W,parentH:me})]})}var xe=680,Se=220,Ce=8,we=[i.teal],G={left:8,right:100,top:16,bottom:38},Te=150,K=6;function Ee(e,t,n){if(e.measureText(t).width<=n)return t;let r=t;for(;r.length>0&&e.measureText(r+`…`).width>n;)r=r.slice(0,-1);return r+`…`}function De(e){let t=Math.abs(e),n=e<0?`-`:``;return t>=1e6?`${n}£${(t/1e6).toFixed(1)}M`:t>=1e3?`${n}£${(t/1e3).toFixed(1)}K`:`${n}£${t.toFixed(0)}`}function Oe({data:e,dataByEntity:r,onItemClick:a,selectedId:o,testID:s}){let[c,l]=z(xe),m=(0,t.useRef)(null),h=(0,t.useRef)(new Map),g=(0,t.useRef)(o);g.current=o;let v=(0,t.useCallback)((e,t)=>{let n=typeof t==`object`?t.label??e:e,r=R.current.visibleItems.find(t=>t.id===e);a?.(e,n,r?.subentity)},[a]),[y,b]=(0,t.useState)(!1),C=!!(o&&r?.[o]),{items:T=[],totals:D}=C?r[o]:e,O=T.filter(e=>typeof e==`object`&&!!e),k=[...O].sort((e,t)=>(t.total??0)-(e.total??0)),M=y?k:k.slice(0,Ce),N=M.length,P=Math.max(...k.map(e=>Math.abs(e.total??0)),1),F=N*K+Math.max(0,N-1)*38,I=G.top+G.bottom+F,L=l-G.left-Te-G.right,R=(0,t.useRef)({visibleItems:M,maxCommitment:P,totals:D,barArea:L,BAR_GAP:38,n:N,dynamicH:I,isDrillMode:C});R.current={visibleItems:M,maxCommitment:P,totals:D,barArea:L,BAR_GAP:38,n:N,dynamicH:I,isDrillMode:C};let V=(e.items??[]).filter(e=>typeof e==`object`&&!!e).length===0,{hoveredRef:H,tooltip:te,hitZonesRef:U}=S(m,{width:l,height:I,onClick:a?v:void 0});return pe(m,l,I,(e,t)=>{let{visibleItems:n,maxCommitment:r,totals:a,barArea:o,BAR_GAP:s,n:c,dynamicH:m,isDrillMode:v}=R.current;j(h.current,H.current),U.current=[],n.forEach((n,a)=>{let l=we[a%we.length],f=A(t,a,c,E),m=G.top+a*(K+s),y=G.left+Te,b=h.current.get(n.id)??0,x=!v&&g.current&&n.id!==g.current?.2:1,S=Math.max(n.total??0,0)/r*o*f;if(e.font=u.font,e.fillStyle=b>0?l:u.color,e.textAlign=`right`,e.textBaseline=`middle`,e.fillText(Ee(e,n.name??``,Te-16),y-8,m+K/2),w(U.current,n.id,0,m,y,K,{label:n.name,value:`${n.totalLabel??De(n.total??0)} total`,sublabel:`Base ${n.baseLabel??De(n.base??0)} + Var ${n.variationLabel??De(n.variation??0)}`,color:l}),S>0){b>0&&_(e,y+S/2,m+K/2,S*.15,i.teal,.12*b);let t=e.createLinearGradient(y,0,y+S,0);t.addColorStop(0,p(i.tealDark,.85*x)),t.addColorStop(1,p(i.teal,1*x)),e.fillStyle=t,e.beginPath(),e.rect(y,m,S,K),e.fill()}let C=L*f,T=y+S,D=C-S;if(D>2&&(e.fillStyle=p(i.barBg,.2),e.beginPath(),e.rect(T,m,D,K),e.fill()),S>4){let t=y+S,n=m+K;e.strokeStyle=p(i.t4,.9*f),e.lineWidth=4,e.beginPath(),e.moveTo(t,m),e.lineTo(t,n),e.stroke();let r=n+3,a={x:t,y:r},o={x:t+10,y:r+12},s={x:t-10,y:r+12};e.fillStyle=p(i.t1,f),e.beginPath(),e.moveTo((a.x+o.x)/2,(a.y+o.y)/2),e.arcTo(o.x,o.y,s.x,s.y,1),e.arcTo(s.x,s.y,a.x,a.y,1),e.arcTo(a.x,a.y,o.x,o.y,1),e.closePath(),e.fill()}f>.35&&(e.globalAlpha=Math.min(1,(f-.35)/.4)*x,e.font=d.font,e.fillStyle=b>0?l:d.color,e.textAlign=`left`,e.textBaseline=`middle`,e.fillText(n.totalLabel??De(n.total??0),y+o+28,m+K/2),e.globalAlpha=1),w(U.current,n.id,y,m,Math.max(S,1),K,{label:n.name,value:n.totalLabel??De(n.total??0),sublabel:`${n.baseLabel??De(n.base??0)} + ${n.variationLabel??De(n.variation??0)}`,color:l})});let y=m-14;e.textBaseline=`middle`,e.font=f.font,e.textAlign=`left`;let b=e.createLinearGradient(G.left+Te,0,G.left+Te+14,0);b.addColorStop(0,p(i.tealDark,.85)),b.addColorStop(1,p(i.teal,1)),e.fillStyle=b,e.beginPath(),e.rect(G.left+Te,y-6,12,12),e.fill(),e.fillStyle=f.color,e.fillText(`base value`,G.left+Te+16,y),e.fillStyle=p(i.teal,.35),e.beginPath(),e.rect(G.left+Te+160,y-6,12,12),e.fill(),e.fillStyle=f.color,e.fillText(`approved variations`,G.left+Te+176,y),e.font=f.font,e.textAlign=`right`,e.fillStyle=f.color,e.fillText(`Portfolio: ${De(a?.total??0)}`,l-8,y)},!0,{easing:E}),V?(0,n.jsx)(`div`,{ref:c,style:{width:`100%`},children:(0,n.jsx)(B,{width:l,height:Se,message:`No contract data available`,testID:s})}):(0,n.jsxs)(`div`,{ref:c,"data-testid":s,style:{width:`100%`},children:[(0,n.jsxs)(`div`,{style:{position:`relative`},children:[(0,n.jsx)(`canvas`,{ref:m,role:`img`,"aria-label":`Total contract value per contractor — horizontal bar chart`,style:{width:`100%`,height:I,display:`block`,borderRadius:8}}),(0,n.jsx)(x,{...te,parentW:l,parentH:I})]}),O.length>Ce&&(0,n.jsx)(`div`,{style:{marginTop:8},children:(0,n.jsx)(ee,{expanded:y,onToggle:()=>b(e=>!e)})})]})}var ke=780,Ae=240,je=12,Me=10,Ne=5;function Pe({items:e=[],onItemClick:r,testID:a}){let[o,c]=z(ke),l=(0,t.useRef)(null),f=(0,t.useRef)(0),m=(0,t.useRef)(new Map),h=[...(0,t.useMemo)(()=>e.filter(e=>typeof e==`object`&&!!e),[e])].sort((e,t)=>(t.count??0)-(e.count??0)).slice(0,5),v=h.reduce((e,t)=>e+(t.count??0),0),b=(0,t.useRef)(h);b.current=h;let C=(0,t.useCallback)((e,t)=>{let n=typeof t==`object`?t.label??e:e,i=b.current.find(t=>t.id===e);r?.(e,n,i?.subentity)},[r]),T=Math.min(Ne,h.length),E=T>0?(c-2*je-(T-1)*Me)/T:(c-2*je)/Ne,{hoveredRef:D,tooltip:O,hitZonesRef:A}=S(l,{width:c,height:Ae,onClick:r?C:void 0});return(0,t.useEffect)(()=>{let e=l.current;if(!e)return;let t=g(e,c,Ae);f.current=0;let n=Ae*.84,r=Ae*.08,a=je,o,b=()=>{f.current++;let e=f.current;t.clearRect(0,0,c,Ae),t.letterSpacing=u.letterSpacing,A.current=[],m.current.forEach((e,t)=>{let n=t===D.current?1:0,r=e+(n-e)*.12;Math.abs(r-n)<.005?n===0?m.current.delete(t):m.current.set(t,1):m.current.set(t,r)}),D.current&&!m.current.has(D.current)&&m.current.set(D.current,0),h.forEach((o,c)=>{let l=c===0,u=c===0?i.red:c===1?i.amber:s[c%s.length],f=a+c*(E+Me),h=m.current.get(o.id)??0,g=h*8,y=f-g/2,b=E+g,x=l?k(e,.04,3e-4)*.06+.06:0;t.fillStyle=p(u,.08+h*.07),t.beginPath(),t.roundRect(y,r,b,n,6),t.fill(),t.strokeStyle=p(u,.2+h*.4+x),t.lineWidth=l?1.5:1,t.stroke(),(h>.01||l)&&_(t,y+b/2,r+n/2,b*.55,u,x+h*.14),t.font=d.font,t.textAlign=`left`,t.textBaseline=`top`,t.fillStyle=p(u,.5+h*.35),t.fillText(`#${c+1}`,y+7,r+6);let S=Math.min(E*.28,n*.32,72),C=y+b/2,T=r+n*.38,D=t.createRadialGradient(C,T-S*.2,0,C,T,S);D.addColorStop(0,p(u,.5+h*.2)),D.addColorStop(1,p(u,.2+h*.1)),t.beginPath(),t.arc(C,T,S,0,Math.PI*2),t.fillStyle=D,t.fill(),t.strokeStyle=p(u,.4+h*.3),t.lineWidth=1,t.stroke(),t.font=d.font,t.textAlign=`center`,t.textBaseline=`middle`,t.fillStyle=p(i.t1,.9);let O=o.abbreviation??o.name??``,j=S*1.7,M=O;for(;t.measureText(M).width>j&&M.length>1;)M=M.slice(0,-1);M!==O&&(M=M.slice(0,-1)+`…`),t.fillText(M,C,T);let N=o.count==null?null:H(o.count),P=o.label??N;if(P){t.font=d.font,t.textBaseline=`alphabetic`,t.fillStyle=p(u,.9+h*.1);let e=b-16,i=P;for(;t.measureText(i).width>e&&i.length>1;)i=i.slice(0,-1);i!==P&&(i=i.slice(0,-1)+`…`),t.fillText(i,C,r+n*.74)}let F=Math.round((o.count??0)/(v||1)*100);w(A.current,o.id,f,r,E,n,{label:o.name,value:`${P} · ${F}% of total`,sublabel:`Rank #${c+1}`,color:u})}),y(t,c,Ae,e,.015),o=requestAnimationFrame(b)};return b(),()=>cancelAnimationFrame(o)},[h,v,c]),h.length===0?(0,n.jsx)(B,{width:c,height:Ae,testID:a}):(0,n.jsxs)(`div`,{"data-testid":a,style:{position:`relative`,width:c,height:Ae},children:[(0,n.jsx)(`canvas`,{ref:l,role:`img`,"aria-label":`Contractor rank — open EW count per contractor`,style:{width:c,height:Ae,display:`block`,borderRadius:8}}),(0,n.jsx)(x,{...O,parentW:c,parentH:Ae})]})}var q=680,J=260;function Fe({items:e=[],testID:r}){let a=(0,t.useRef)(null),o=(0,t.useRef)(0),s=(0,t.useRef)(new Map),{hoveredRef:c,tooltip:l,hitZonesRef:d}=S(a,{width:q,height:J}),f=(0,t.useMemo)(()=>e.filter(e=>typeof e==`object`&&!!e),[e]);return(0,t.useEffect)(()=>{let e=a.current;if(!e)return;let t=g(e,q,J);o.current=0;let n=f.length,r=Math.max(...f.map(e=>e.count),1),l=r,m=q*.05,h=J*.1,b=q*.9/n,x=J*.7/l,S=f.reduce((e,t)=>e+t.count,0),w,T=()=>{o.current++;let e=o.current;t.clearRect(0,0,q,J),d.current=[],s.current.forEach((e,t)=>{let n=t===c.current?1:0,r=e+(n-e)*.12;Math.abs(r-n)<.005?n===0?s.current.delete(t):s.current.set(t,1):s.current.set(t,r)}),c.current&&!s.current.has(c.current)&&s.current.set(c.current,0),v(t,q,J,e,40,p(i.blue,.04)),f.forEach((n,a)=>{let o=n.count===r,c=i.blue,f=s.current.get(`${n.category}-col`)??0;for(let i=0;i<l;i++){let l=m+a*b+b/2,u=h+i*x+x/2,g=Math.min(b,x)*.38;if(i>=r-n.count){let r=g*(1+(k(e,.04,5e-4)+Math.sin(a*.6+i*1.2)*.3)*.12);(o||f>.01)&&_(t,l,u,r*3,c,(o?.2:.1)+f*.1),t.beginPath(),t.arc(l,u,r,0,Math.PI*2),t.fillStyle=p(c,o?.8:.5+f*.2),t.fill();let m=`${n.category}-${i}`;C(d.current,m,l,u,g+4,{label:n.fullName,value:`${n.count} Early Warnings`,sublabel:`${Math.round(n.count/S*100)}% of total`,color:c}),s.current.get(`${n.category}-col`)}else t.beginPath(),t.arc(l,u,1,0,Math.PI*2),t.fillStyle=p(c,.08),t.fill()}let g=h+l*x+16;t.font=u.font,t.textAlign=`center`,t.textBaseline=`alphabetic`,t.fillStyle=o?i.blue:p(i.t2,.65),t.fillText(n.category,m+a*b+b/2,g)}),y(t,q,J,e,.015),w=requestAnimationFrame(T)};return T(),()=>cancelAnimationFrame(w)},[f]),f.length===0?(0,n.jsx)(B,{width:q,height:J,testID:r}):(0,n.jsxs)(`div`,{"data-testid":r,style:{position:`relative`,width:q,height:J},children:[(0,n.jsx)(`canvas`,{ref:a,role:`img`,"aria-label":`Early Warning count by category — breathing dot grid`,style:{width:q,height:J,display:`block`,borderRadius:8}}),(0,n.jsx)(x,{...l,parentW:q,parentH:J})]})}function Ie({rows:e=[],className:t,colors:r}){return(0,n.jsx)(P,{rows:e,variant:`line`,className:t,colors:r})}var Y={LINE:`line`,AREA:`area`,BAR:`bar`,PIE:`pie`,DONUT:`donut`,SANKEY:`sankey`,FLOW:`flow`,TREND:`trend`,MINI_BARS:`mini-bars`,STACKED_HORIZONTAL_BAR:`stacked-horizontal-bar-chart`,MULTI_METRIC_CONSTELLATION:`multi-metric-constellation-chart`,PROGRESS_RACE:`progress-race-chart`,HUB_AND_SPOKE_RADIAL:`hub-and-spoke-radial-chart`,DOT_MATRIX:`dot-matrix-chart`,RANKED_CARD_LEADERBOARD:`ranked-card-leaderboard`,PROPORTIONAL_BAND:`proportional-band-chart`,RADIAL_FAN_TREE:`radial-fan-tree-chart`,SEMI_CIRCULAR_GAUGE:`semi-circular-gauge-chart`,SEGMENTED_SPLIT_BAR:`segmented-split-bar-chart`,BALANCE_SCALE:`balance-scale-chart`,AREA_LINE:`area-line-chart`,TREND_VIEW:`trend-view`,WEEKLY_FLOW:`weekly-flow`,HORIZONTAL_BAR:`horizontal-bar-chart`},Le=[`#4C93D9`,`#5DA537`,`#F3862C`,`#4F72C6`,`#A0B724`,`#EEBF3B`,`#3C45D1`],Re={nodes:[{id:`supplier-x`,name:`Supplier X`,valueLabel:`Si +0.12%`},{id:`bf3-superheat`,name:`BF-3 Superheat`,valueLabel:`22°C (target 34)`},{id:`ccm3-solidification`,name:`CCM-3 Solidification`,valueLabel:`Rate deviation`},{id:`grade-risk`,name:`Grade Risk`,valueLabel:`Automotive 74%`}],links:[{source:`supplier-x`,target:`bf3-superheat`,value:92},{source:`bf3-superheat`,target:`ccm3-solidification`,value:87},{source:`ccm3-solidification`,target:`grade-risk`,value:74}]};function ze({rows:e=[],className:t,colors:r}){let i=r?.slices??Le;return(0,n.jsx)(`div`,{className:[`d3-mini-bars`,t].filter(Boolean).join(` `),children:e.map(([e,t,r],a)=>(0,n.jsxs)(`div`,{className:`d3-mini-row`,children:[(0,n.jsx)(`span`,{children:e}),(0,n.jsx)(`div`,{className:`d3-mini-track`,children:(0,n.jsxs)(`svg`,{viewBox:`0 0 100 12`,className:`d3-mini-svg`,"aria-hidden":`true`,children:[(0,n.jsx)(`rect`,{x:`0`,y:`0`,width:`100`,height:`12`,rx:`6`,className:`d3-mini-track-fill`}),(0,n.jsx)(`rect`,{x:`0`,y:`0`,width:Math.max(0,Math.min(100,t)),height:`12`,rx:`6`,className:`d3-mini-fill tone-${a%Le.length}`,fill:i[a%i.length]})]})}),(0,n.jsx)(`span`,{children:r})]},`${e}-${a}`))})}var Be=770,Ve=320,He=60,Ue=28;function We({total:e=0,totalLabel:r,items:a=[],dataByEntity:o,onItemClick:s,selectedId:c,colorOffset:f=0,testID:m}){let[h,v]=z(Be),y=(0,t.useRef)(null),b=(0,t.useRef)(new Map),w=(0,t.useRef)(0),E=(0,t.useRef)(c);E.current=c;let D=(0,t.useRef)([]),O=(0,t.useCallback)((e,t)=>{if(e===`__root__`)return;let n=typeof t==`object`?t.label??e:e,r=D.current.find(t=>t.id===e);s?.(e,n,r?.subentity)},[s]),k=!!(c&&o?.[c]),M=k?o[c]:null,N=M?M.total:e,P=M?M.totalLabel:r,F=M?M.items:a,I=(0,t.useMemo)(()=>F.filter(e=>typeof e==`object`&&!!e),[F]);D.current=I;let L=(0,t.useMemo)(()=>Math.max(Ve,He+Math.max(0,I.length-1)*Ue),[I.length]),R=L,{hoveredRef:ee,tooltip:V,hitZonesRef:te}=S(y,{width:v,height:L,onClick:s?O:void 0});return(0,t.useEffect)(()=>{let e=y.current;if(!e)return;let t=g(e,v,R);w.current=0;let n=L/2,r=v-140,a=Math.max(...I.map(e=>e.count??0),1),o=I.length>1?(L-60)/(I.length-1):60,s=Math.min(22,o/2-3),c=Math.min(8,Math.max(3,s-6)),m=r+s+10,h=I.map((e,t)=>({x:r,y:30+t*o})),x,S=()=>{w.current++;let e=w.current;t.clearRect(0,0,v,R),t.letterSpacing=u.letterSpacing;let o=T(Math.min(e/72,1));j(b.current,ee.current),te.current=[];let g=l[f%l.length],y=100+60*Math.min(1,o*2.5),D=t.createLinearGradient(100,0,y,0);D.addColorStop(0,p(g,.8)),D.addColorStop(1,p(g,.7)),t.beginPath(),t.moveTo(100,n),t.lineTo(y,n),t.strokeStyle=D,t.lineWidth=1.33,t.stroke(),I.forEach((e,l)=>{let f=A(o,l,I.length,T),y=h[l],x=b.current.get(e.id)??0,S=!k&&E.current&&e.id!==E.current?.6:1;if(f<.01)return;let w=160+(r-160)*.35,D=n,O=160+(r-160)*.65,j=y.y;t.beginPath();for(let e=0;e<=40;e++){let r=e/40*f,i=(1-r)**3*160+3*(1-r)**2*r*w+3*(1-r)*r**2*O+r**3*y.x,a=(1-r)**3*n+3*(1-r)**2*r*D+3*(1-r)*r**2*j+r**3*y.y;e===0?t.moveTo(i,a):t.lineTo(i,a)}let M=t.createLinearGradient(160,n,y.x,y.y);if(M.addColorStop(0,p(g,(x>0?1:.8)*S)),M.addColorStop(1,p(g,(x>0?1:.7)*S)),t.strokeStyle=M,t.lineWidth=x>0?2:1.33,t.stroke(),f>.85){let n=Math.min(1,(f-.85)/.15),r=c+(e.count??0)/a*(s-c);_(t,y.x,y.y,r*2,g,(.2+x*.2)*n*S),t.beginPath(),t.arc(y.x,y.y,r*n,0,Math.PI*2),t.fillStyle=p(g,n*S),t.fill();let o=H(e.count??0);C(te.current,e.id,y.x,y.y,r+8,{label:e.name,value:o,sublabel:`${Math.round((e.count??0)/(N||1)*100)}% of total`,color:g},v),t.globalAlpha=n*S,t.font=u.font,t.textAlign=`left`;let l=e.abbreviation??e.name?.slice(0,6)??``,h=` ${H(e.count??0)}`,b=y.y+4;t.fillStyle=x>0?g:p(i.t2,.85),t.fillText(l,m,b);let w=t.measureText(l).width;t.font=d.font,t.fillStyle=x>0?g:i.t1,t.fillText(h,m+w,b),t.globalAlpha=1}});let O=40*o,M=t.createRadialGradient(60,n,0,60,n,O);if(M.addColorStop(0,p(g,.02*o)),M.addColorStop(.55,p(g,.02*o)),M.addColorStop(1,p(g,.15*o)),t.beginPath(),t.arc(60,n,O,0,Math.PI*2),t.fillStyle=M,t.fill(),t.beginPath(),t.arc(60,n,O,0,Math.PI*2),t.strokeStyle=p(g,.8*o),t.lineWidth=1,t.stroke(),o>.4){t.globalAlpha=Math.min(1,(o-.4)/.4);let e=H(N);t.font=`500 16px 'Satoshi Variable', 'DM Sans', sans-serif`;let r=e;for(;t.measureText(r).width>68&&r.length>1;)r=r.slice(0,-1);r!==e&&(r=r.slice(0,-1)+`…`),t.fillStyle=i.t1,t.textAlign=`center`,t.textBaseline=`middle`,t.fillText(r,60,n),t.textBaseline=`alphabetic`,t.globalAlpha=1}C(te.current,`__root__`,60,n,40,{label:P??`Total`,value:H(N),sublabel:`${I.length} items`,color:g}),x=requestAnimationFrame(S)};return S(),()=>cancelAnimationFrame(x)},[N,P,I,L,v,k]),I.length===0?(0,n.jsx)(`div`,{ref:h,style:{width:`100%`},children:(0,n.jsx)(B,{width:v,height:Ve,testID:m})}):(0,n.jsxs)(`div`,{ref:h,"data-testid":m,style:{position:`relative`,width:`100%`,height:R},children:[(0,n.jsx)(`canvas`,{ref:y,role:`img`,"aria-label":`NCE fault tree — NCEs per contractor as branching tree`,style:{width:`100%`,height:R,display:`block`}}),(0,n.jsx)(x,{...V,parentW:v,parentH:R})]})}var Ge=192,Ke=Ge,qe=Ge+80;function Je({rows:e=[],variant:a,className:o,colors:c}){let l=(0,t.useRef)(null),u=(0,t.useRef)(new Map),d=(0,t.useRef)(0),f=c?.slices??s,{hoveredRef:m,tooltip:v,hitZonesRef:y}=S(l,{width:Ke,height:qe});return(0,t.useEffect)(()=>{let t=l.current;if(!t)return;let n=g(t,Ke,qe);d.current=0;let r=Ke/2,o=Ge/2,s=Ge*.4,c=a===`donut`?Ge*.21:0,v=e.reduce((e,t)=>e+(t.pricing??0),0)||1,b,x=()=>{d.current++;let t=d.current;n.clearRect(0,0,Ke,qe);let l=1-(1-Math.min(t/48,1))**3;j(u.current,m.current),y.current=[];let g=-Math.PI/2;e.forEach((e,a)=>{let d=(e.pricing??0)/v,m=d*Math.PI*2*l,h=g+m,b=f[a%f.length],x=u.current.get(e.id??`sl-${a}`)??0,S=g+m/2,w=(s+c)/2,T=r+Math.cos(S)*w,E=o+Math.sin(S)*w,D=(s-c)/2+8;C(y.current,e.id??`sl-${a}`,T,E,D,{label:e.vendor,value:`${e.pricing??0} (${Math.round(d*100)}%)`,color:b}),x>0&&_(n,T,E,D*2*x,b,.2*x);let O=k(t,.03,3e-4),A=s+x*6+(x>0?O*2:0);n.beginPath(),n.moveTo(r+Math.cos(g)*c,o+Math.sin(g)*c),n.arc(r,o,A,g,h),c>0?n.arc(r,o,c,h,g,!0):n.lineTo(r,o),n.closePath(),n.fillStyle=p(b,.7+x*.2),n.fill(),n.strokeStyle=p(i.bg,.8),n.lineWidth=1.5,n.stroke(),g=h}),a===`donut`&&e.length>0&&_(n,r,o,c*.8,i.blue,.06);let S=Ge+12;e.forEach((e,t)=>{let r=f[t%f.length],a=(e.pricing??0)/v,o=u.current.get(e.id??`sl-${t}`)??0,s=S+t*18;n.fillStyle=p(r,.8+o*.2),n.fillRect(4,s-6,12,12),n.font=`9px 'JetBrains Mono', monospace`,n.fillStyle=p(i.t2,.7+o*.2),n.textAlign=`left`,n.fillText(e.vendor,18,s+3.5),n.font=`bold 9px 'JetBrains Mono', monospace`,n.fillStyle=h(i.t3,r,o),n.textAlign=`right`,n.fillText(`${e.pricing??0} (${Math.round(a*100)}%)`,Ke-4,s+3.5)}),b=requestAnimationFrame(x)};return x(),()=>cancelAnimationFrame(b)},[e,a,c,f]),(0,n.jsx)(r,{className:[`canvas-pie-frame`,o].filter(Boolean).join(` `),children:(0,n.jsxs)(`div`,{style:{position:`relative`,width:Ke,height:qe},children:[(0,n.jsx)(`canvas`,{ref:l,role:`img`,"aria-label":`${a} chart`,style:{width:Ke,height:qe,display:`block`,borderRadius:8}}),(0,n.jsx)(x,{...v,parentW:Ke,parentH:qe})]})})}function Ye(e,t,n,r){let i=new Set(t.map(e=>e.source)),a=new Set(t.map(e=>e.target)),o=new Map,s=[];for(e.forEach(e=>{i.has(e.id)&&!a.has(e.id)&&s.push({id:e.id,depth:0})});s.length>0;){let e=s.shift();if(!e)break;let{id:n,depth:r}=e;o.has(n)||(o.set(n,r),t.filter(e=>e.source===n).forEach(e=>{o.has(e.target)||s.push({id:e.target,depth:r+1})}))}let c=o.size>0?Math.max(...Array.from(o.values())):0;e.forEach(e=>{o.has(e.id)||o.set(e.id,c+1)});let l=new Map;e.forEach(e=>{let t=o.get(e.id)??0;l.has(t)||l.set(t,[]),l.get(t).push(e.id)});let u=Math.max(...Array.from(l.keys()))+1,d={left:100,right:80,top:40,bottom:40},f=new Map;return l.forEach((e,t)=>{let i=d.left+t/Math.max(u-1,1)*(n-d.left-d.right),a=r-d.top-d.bottom,o=Math.max(24,(a-(e.length-1)*12)/e.length),s=e.length*o+(e.length-1)*12,c=d.top+(a-s)/2;e.forEach((e,t)=>{f.set(e,{x:i-20/2,y:c+t*(o+12),w:20,h:o})})}),f}function Xe({nodes:e,links:a,width:o=960,height:c=280,ariaLabel:l,selectedEntity:u,className:d,colors:f}){let m=(0,t.useRef)(null),h=(0,t.useRef)(new Map),v=(0,t.useRef)(0),b=(0,t.useRef)([]),T=f?.nodes??s,E=f?.links??i.bd,D=f?.activeLinks??i.blue,O=f?.activeNodes??i.blue,A=(0,t.useMemo)(()=>Ye(e,a,o,c),[e,a,o,c]),{hoveredRef:M,tooltip:N,hitZonesRef:P}=S(m,{width:o,height:c});return(0,t.useEffect)(()=>{let t=m.current;if(!t)return;let n=g(t,o,c);v.current=0,b.current=[];let r=a.length>0?Math.max(...a.map(e=>e.value)):1,s,l=()=>{v.current++;let t=v.current;n.clearRect(0,0,o,c);let d=1-(1-Math.min(t/56,1))**3;j(h.current,M.current),P.current=[],a.forEach((e,a)=>{let o=A.get(e.source),s=A.get(e.target);if(!o||!s)return;let c=!!u&&(e.source===u||e.target===u),l=c?D:E,f=c?.5:.2,m=Math.max(3,e.value/r*36*d),h=m/2,g=o.x+o.w,_=o.y+o.h/2,v=s.x,y=s.y+s.h/2,x=(g+v)/2;for(let e=0;e<30;e++){let r=e/30,i=(e+1)/30,o=1-r,s=1-i,c=o*o*g+2*o*r*x+r*r*v,u=o*o*_+2*o*r*_+r*r*y,d=s*s*g+2*s*i*x+i*i*v,m=s*s*_+2*s*i*_+i*i*y,b=k(t+r*120+a*40,.025,3e-4)*1.2;n.beginPath(),n.moveTo(c,u-h+b),n.lineTo(d,m-h+b),n.lineTo(d,m+h+b),n.lineTo(c,u+h+b),n.closePath(),n.fillStyle=p(l,f*(.5+r*.5)),n.fill()}C(P.current,`link-${a}`,x,(_+y)/2,m+6,{label:`${e.source} → ${e.target}`,value:String(e.value),color:c?D:i.blue}),Math.random()<.08&&b.current.push({linkIdx:a,prog:0,speed:.006+Math.random()*.006,off:(Math.random()-.5)*m*.5,sz:1+Math.random()})}),e.forEach((e,r)=>{let a=A.get(e.id);if(!a)return;let o=u===e.id,s=M.current===`node-${r}`,c=h.current.get(`node-${r}`)??0,l=o?O:T[r%T.length];w(P.current,`node-${r}`,a.x,a.y,a.w,a.h,{label:e.name,value:e.valueLabel??e.id,color:l}),(c>0||o)&&_(n,a.x+a.w/2,a.y+a.h/2,a.w*2,l,.2*Math.max(c,o?.6:0));let d=o?k(t,.03,3e-4)*.15:0;n.fillStyle=p(l,.6+c*.25+d),n.beginPath(),n.roundRect(a.x,a.y,a.w,a.h,4),n.fill(),(o||c>0)&&(n.strokeStyle=p(l,.5*Math.max(c,o?1:0)),n.lineWidth=1,n.beginPath(),n.roundRect(a.x,a.y,a.w,a.h,4),n.stroke());let f=a.x+a.w+8;n.font=`${o||s?`bold `:``}10px 'JetBrains Mono', monospace`,n.fillStyle=p(o?l:i.t2,.7+c*.2),n.textAlign=`left`,n.fillText(e.name,f,a.y+a.h/2+4),e.valueLabel&&(n.font=`9px 'JetBrains Mono', monospace`,n.fillStyle=p(l,.5+c*.2),n.fillText(e.valueLabel,f,a.y+a.h/2+17))}),b.current=b.current.filter(e=>{if(e.prog+=e.speed,e.prog>1)return!1;let t=a[e.linkIdx];if(!t)return!1;let r=A.get(t.source),o=A.get(t.target);if(!r||!o)return!1;let s=r.x+r.w,c=r.y+r.h/2,l=o.x,u=o.y+o.h/2,d=(s+l)/2,m=1-e.prog,h=m*m*s+2*m*e.prog*d+e.prog*e.prog*l,g=m*m*c+2*m*e.prog*c+e.prog*e.prog*u+e.off,_=Math.sin(e.prog*Math.PI)*.5,v=f?.links??i.blue;return n.beginPath(),n.arc(h,g,e.sz,0,Math.PI*2),n.fillStyle=p(v,_),n.fill(),!0}),b.current.length>150&&(b.current=b.current.slice(-150)),y(n,o,c,t,.01),s=requestAnimationFrame(l)};return l(),()=>{cancelAnimationFrame(s),b.current=[]}},[e,a,o,c,u,f,A]),(0,n.jsx)(r,{className:[`canvas-sankey-frame`,d].filter(Boolean).join(` `),children:(0,n.jsxs)(`div`,{role:`img`,"aria-label":l,style:{position:`relative`,width:o,height:c},children:[(0,n.jsx)(`canvas`,{ref:m,style:{width:o,height:c,display:`block`,borderRadius:8}}),(0,n.jsx)(x,{...N,parentW:o,parentH:c})]})})}var Ze=[{x:.13,y:.48},{x:.37,y:.28},{x:.63,y:.62},{x:.87,y:.38},{x:.25,y:.72},{x:.5,y:.18},{x:.75,y:.7},{x:.92,y:.22}],Qe=[i.blue,i.orange,i.red,i.purple,i.green,i.amber,i.t2],$e=[26,24,24,26,22,22,22,22];function et(e,t){let n=1-t;return{x:n*n*n*e.p0.x+3*n*n*t*e.p1.x+3*n*t*t*e.p2.x+t*t*t*e.p3.x,y:n*n*n*e.p0.y+3*n*n*t*e.p1.y+3*n*t*t*e.p2.y+t*t*t*e.p3.y}}function tt(e,t){let n=1-t,r=3*n*n*(e.p1.x-e.p0.x)+6*n*t*(e.p2.x-e.p1.x)+3*t*t*(e.p3.x-e.p2.x),i=3*n*n*(e.p1.y-e.p0.y)+6*n*t*(e.p2.y-e.p1.y)+3*t*t*(e.p3.y-e.p2.y),a=Math.sqrt(r*r+i*i)||1;return{x:-i/a,y:r/a}}function nt(e,t){let n=t.x-e.x,r=t.y-e.y;return{p0:{x:e.x,y:e.y},p1:{x:e.x+n*.3+r*.15,y:e.y+r*.3-n*.15},p2:{x:t.x-n*.3+r*.08,y:t.y-r*.3-n*.08},p3:{x:t.x,y:t.y}}}function rt({nodes:e,links:r,width:a=960,height:o=280,selectedEntity:s}){let c=(0,t.useRef)(null),l=(0,t.useRef)(0),u=(0,t.useRef)([]),{hoveredRef:d,tooltip:f,hitZonesRef:m}=S(c,{width:a,height:o}),b=(0,t.useMemo)(()=>{let t=new Map;return e.forEach((e,n)=>t.set(e.id,n)),t},[e]),w=(0,t.useMemo)(()=>r.length>0?Math.max(...r.map(e=>e.value)):100,[r]),E=e=>w>1?e/100:e,D=(0,t.useMemo)(()=>e.map((e,t)=>{let n=Ze[t%Ze.length];return{id:e.id,label:e.name,sub:e.valueLabel??``,x:n.x*a,y:n.y*o,r:$e[t%$e.length],color:Qe[t%Qe.length]}}),[e,a,o]),O=(0,t.useMemo)(()=>r.map(e=>({fromIdx:b.get(e.source)??-1,toIdx:b.get(e.target)??-1,conf:E(e.value)})).filter(e=>e.fromIdx>=0&&e.toIdx>=0),[r,b]);return(0,t.useEffect)(()=>{let e=c.current;if(!e)return;let t=g(e,a,o);l.current=0,u.current=[];let n,r=()=>{l.current++;let e=l.current;if(t.clearRect(0,0,a,o),m.current=[],v(t,a,o,e,50,p(i.blue,.05)),O.forEach((e,n)=>{let r=D[e.fromIdx],a=D[e.toIdx];if(!r||!a)return;let o=!!s&&(r.id===s||a.id===s),c=h(r.color,a.color,.5),l=o?.18:.05,d=o?.25:.1,f=nt(r,a);t.beginPath(),t.moveTo(f.p0.x,f.p0.y),t.bezierCurveTo(f.p1.x,f.p1.y,f.p2.x,f.p2.y,f.p3.x,f.p3.y),t.strokeStyle=p(c,l),t.lineWidth=16,t.lineCap=`round`,t.stroke(),t.strokeStyle=p(c,d),t.lineWidth=1.5,t.stroke();for(let t=0;t<e.conf*2.5;t++)Math.random()<.45&&u.current.push({edgeIdx:n,t:0,speed:.003+Math.random()*.004,off:(Math.random()-.5)*13,sz:.7+Math.random()*2});let m=et(f,.5),g=`${Math.round(e.conf*100)}%`;t.font=`bold 12px 'JetBrains Mono', monospace`,t.textBaseline=`middle`;let _=t.measureText(g).width+14;t.fillStyle=`rgba(10,16,24,0.88)`,t.beginPath(),t.roundRect(m.x-_/2,m.y-11,_,22,6),t.fill(),t.strokeStyle=p(i.blue,.25),t.lineWidth=1,t.stroke(),t.fillStyle=p(i.blue,.9),t.textAlign=`center`,t.fillText(g,m.x,m.y)}),u.current=u.current.filter(e=>{if(e.t+=e.speed,e.t>1)return!1;let n=O[e.edgeIdx];if(!n)return!1;let r=D[n.fromIdx],i=D[n.toIdx];if(!r||!i)return!1;let a=nt(r,i),o=et(a,e.t),s=tt(a,e.t),c=o.x+s.x*e.off,l=o.y+s.y*e.off,u=Math.sin(e.t*Math.PI)*.7,d=h(r.color,i.color,e.t);return _(t,c,l,e.sz*3,d,u*.1),t.beginPath(),t.arc(c,l,e.sz,0,Math.PI*2),t.fillStyle=p(d,u),t.fill(),!0}),u.current.length>350&&(u.current=u.current.slice(-350)),D.forEach((n,r)=>{let a=s===n.id,o=d.current===`node-${r}`,c=k(e,.03,3e-4)*.1+1,l=n.r*c*(a?1.15:1);t.beginPath(),t.arc(n.x,n.y,l+6,0,Math.PI*2),t.strokeStyle=p(n.color,a?.3:.1),t.lineWidth=a?1.5:.7,t.stroke(),_(t,n.x,n.y,l*3,n.color,a?.22:.12);let u=t.createRadialGradient(n.x,n.y-l*.2,0,n.x,n.y,l);if(u.addColorStop(0,p(n.color,a?1:.85)),u.addColorStop(1,p(n.color,a?.65:.45)),t.fillStyle=u,t.beginPath(),t.arc(n.x,n.y,l,0,Math.PI*2),t.fill(),a||r===D.length-1){let r=l+16,i=e*.04,a=n.x+Math.cos(i)*r,o=n.y+Math.sin(i)*r;_(t,a,o,6,n.color,.3),t.beginPath(),t.arc(a,o,2,0,Math.PI*2),t.fillStyle=p(n.color,.75),t.fill()}C(m.current,`node-${r}`,n.x,n.y,l+8,{label:n.label,value:n.sub||n.id,color:n.color}),t.font=`${a||o?`bold `:``}12px 'DM Sans', sans-serif`,t.textAlign=`center`,t.textBaseline=`alphabetic`,t.fillStyle=p(n.color,a?1:.9),t.fillText(n.label,n.x,n.y+l+18),n.sub&&(t.font=`10px 'JetBrains Mono', monospace`,t.fillStyle=p(i.t3,.65),t.fillText(n.sub,n.x,n.y+l+32))}),O.length>=2){let n=O.reduce((e,t)=>e*t.conf,1),r=o*.92,s=a*.12,c=a*.76,l=T(Math.min(e*.008,1));t.fillStyle=p(i.bd,.35),t.beginPath(),t.roundRect(s,r,c,5,3),t.fill(),t.fillStyle=p(i.orange,.6),t.beginPath(),t.roundRect(s,r,c*n*l,5,3),t.fill(),t.font=`bold 12px 'JetBrains Mono', monospace`,t.textAlign=`left`,t.textBaseline=`middle`,t.fillStyle=p(i.orange,.85),t.fillText(`${Math.round(n*100)}% compound confidence`,s+c*n*l+10,r+2);let u=O.map(e=>e.conf.toFixed(2)).join(` × `);t.textAlign=`right`,t.font=`9px 'JetBrains Mono', monospace`,t.fillStyle=p(i.t4,.6),t.fillText(u,s-6,r+2)}y(t,a,o,e,.012),n=requestAnimationFrame(r)};return r(),()=>{cancelAnimationFrame(n),u.current=[]}},[D,O,a,o,s]),(0,n.jsxs)(`div`,{style:{position:`relative`,width:a,height:o},children:[(0,n.jsx)(`canvas`,{ref:c,style:{width:a,height:o,display:`block`,borderRadius:8},role:`img`,"aria-label":`causal flow diagram`}),(0,n.jsx)(x,{...f,parentW:a,parentH:o})]})}function it({selectedEntity:e,colors:t}){return(0,n.jsx)(rt,{nodes:Re.nodes,links:Re.links,width:960,height:280,selectedEntity:e})}function at({rows:e=[],className:r,colors:i}){let{nodes:a,links:o}=(0,t.useMemo)(()=>{let t=e.slice(0,5);return{nodes:[{id:`score`,name:`Portfolio Score`},...t.map(e=>({id:e.id??e.vendor,name:e.vendor}))],links:t.map(e=>({source:e.id??e.vendor,target:`score`,value:Math.max(8,e.pricing??0)}))}},[e]);return(0,n.jsx)(Xe,{nodes:a,links:o,width:760,height:280,ariaLabel:`sankey chart`,className:r,colors:i})}var ot=780,st=420;function ct({left:e,right:r,leftTitle:a=`Accepted`,rightTitle:o=`Submitted`,unit:s=`quotations`,selectedId:c,dataByEntity:l,onItemClick:d,testID:f}){let m=(0,t.useRef)(null),h=(0,t.useRef)(0),v=c&&l?.[c]?l[c]:{left:e,right:r},y=v.left,b=v.right,C=(0,t.useRef)({left:y,right:b,leftTitle:a,rightTitle:o});C.current={left:y,right:b,leftTitle:a,rightTitle:o};let E=(0,t.useRef)(c);E.current=c;let D=(0,t.useCallback)((e,t)=>{let n=typeof t==`object`?t.label??e:e,r=e===`left`?C.current.left:C.current.right;d?.(e,n,r?.subentity)},[d]),{hitZonesRef:k,tooltip:A,hoveredRef:j}=S(m,{width:ot,height:st,onClick:d?D:void 0});return(0,t.useEffect)(()=>{let e=m.current;if(!e)return;let t=g(e,ot,st);h.current=0;let n=ot/2,r=Math.abs(y.value??0),c=Math.abs(b.value??0),l=Math.max(r,c,1),d=(y.value-b.value)/(2*l)*14,f=Math.max(-14,Math.min(14,d)),v=(e,n,r,a,o)=>{let s=n-99/2,c=r+30,l=[0,0,10,10];t.save(),t.beginPath(),t.roundRect(s,c,99,a,l),t.clip();let u=p(e,.27*o),d=p(e,0),f=t.createLinearGradient(s,0,s+25,0);f.addColorStop(0,u),f.addColorStop(1,d),t.fillStyle=f,t.fillRect(s,c,25,a);let m=t.createLinearGradient(s+99,0,s+99-25,0);m.addColorStop(0,u),m.addColorStop(1,d),t.fillStyle=m,t.fillRect(s+99-25,c,25,a);let h=t.createLinearGradient(0,c,0,c+25);h.addColorStop(0,u),h.addColorStop(1,d),t.fillStyle=h,t.fillRect(s,c,99,25);let g=t.createLinearGradient(0,c+a,0,c+a-25);g.addColorStop(0,u),g.addColorStop(1,d),t.fillStyle=g,t.fillRect(s,c+a-25,99,25),t.restore(),t.beginPath(),t.roundRect(s,c,99,a,l),t.strokeStyle=p(e,1*o),t.lineWidth=1,t.stroke();let _=s+99/2,v=c-5;t.strokeStyle=p(i.t2,.5*o),t.lineWidth=1,t.beginPath(),t.moveTo(n,r+4),t.lineTo(_,v),t.stroke(),t.beginPath(),t.moveTo(_,v),t.lineTo(_-10,c),t.stroke(),t.beginPath(),t.moveTo(_,v),t.lineTo(_+10,c),t.stroke(),t.beginPath(),t.arc(n,r,3,0,Math.PI*2),t.fillStyle=p(i.t2,.7*o),t.fill()},x,S=()=>{h.current++;let e=h.current;t.clearRect(0,0,ot,st),t.letterSpacing=u.letterSpacing,k.current=[];let d=T(Math.min(e/80,1)),m=f*O(Math.min(e/80,1))*Math.PI/180,g={x:n-Math.cos(m)*240,y:100+Math.sin(-m)*240},C={x:n+Math.cos(m)*240,y:100+Math.sin(m)*240};t.strokeStyle=p(i.t2,.55*d),t.lineWidth=1.5,t.beginPath(),t.moveTo(g.x,g.y),t.lineTo(C.x,C.y),t.stroke(),_(t,n,100,18,i.t2,.14*d),t.beginPath(),t.arc(n,100,9*d,0,Math.PI*2),t.fillStyle=p(i.t2,.85*d),t.fill();let D=Math.max(20,r/l*95*d),A=Math.max(20,c/l*95*d),j=E.current===`right`?.6:1,M=E.current===`left`?.6:1;v(i.green,g.x,g.y,D,d*j),v(i.amber,C.x,C.y,A,d*M);let N=g.y+30+D,P=C.y+30+A;if(w(k.current,`left`,g.x-99/2,g.y+30,99,D+90,{label:a,value:y.label,sublabel:`${y.count} ${s}`,color:i.green},st,g.x,N+102),w(k.current,`right`,C.x-99/2,C.y+30,99,A+90,{label:o,value:b.label,sublabel:`${b.count} ${s}`,color:i.amber},st,C.x,P+102),d>.5){let e=Math.min(1,(d-.5)/.5);t.textAlign=`center`,t.textBaseline=`top`;let n=g.y+30+D+14,r=C.y+30+A+14;t.globalAlpha=e*j,t.font=`700 34px 'Satoshi Variable', 'DM Sans', sans-serif`,t.fillStyle=i.t1,t.fillText(y.label,g.x,n),t.font=u.font,t.fillStyle=u.color,t.fillText(`${a} ${y.count} ${s}`,g.x,n+42),t.globalAlpha=e*M,t.font=`700 34px 'Satoshi Variable', 'DM Sans', sans-serif`,t.fillStyle=i.t1,t.fillText(b.label,C.x,r),t.font=u.font,t.fillStyle=u.color,t.fillText(`${o} ${b.count} ${s}`,C.x,r+42),t.globalAlpha=1,t.textBaseline=`alphabetic`}x=requestAnimationFrame(S)};return S(),()=>cancelAnimationFrame(x)},[y,b]),(0,n.jsxs)(`div`,{"data-testid":f,style:{position:`relative`,width:`100%`,maxWidth:ot},children:[(0,n.jsx)(`canvas`,{ref:m,role:`img`,"aria-label":`Quotation balance — accepted vs submitted quotation value`,style:{width:`100%`,aspectRatio:`${ot} / ${st}`,display:`block`,borderRadius:8}}),(0,n.jsx)(x,{...A,parentW:ot,parentH:st})]})}var lt=780,ut=360;function dt({points:e=[],testID:r}){let a=(0,t.useRef)(null),o=(0,t.useRef)(new Map),s=(0,t.useRef)(0),{hoveredRef:c,tooltip:l,hitZonesRef:d}=S(a,{width:lt,height:ut}),f=(0,t.useMemo)(()=>e.filter(e=>typeof e==`object`&&!!e),[e]);return(0,t.useEffect)(()=>{let e=a.current;if(!e)return;let t=g(e,lt,ut);s.current=0;let n=lt-64-48,r=ut-48-68,l=Math.max(...f.map(e=>e.count),1),m=f.length,h=m>1?n/(m-1):n,v=f.map((e,t)=>({x:64+t*h,y:48+r-e.count/l*r,point:e})),y,x=()=>{s.current++;let e=s.current;t.clearRect(0,0,lt,ut),t.letterSpacing=u.letterSpacing;let a=T(Math.min(e/72,1));j(o.current,c.current),d.current=[],[0,.25,.5,.75,1].forEach(e=>{let a=48+r-e*r;t.strokeStyle=p(i.bd,.18),t.lineWidth=1,t.setLineDash([3,5]),t.beginPath(),t.moveTo(64,a),t.lineTo(64+n,a),t.stroke(),t.setLineDash([]),t.font=u.font,t.fillStyle=u.color,t.textAlign=`right`,t.fillText(String(Math.round(l*e)),58,a+3)}),t.save(),t.translate(12,48+r/2),t.rotate(-Math.PI/2),t.font=u.font,t.fillStyle=u.color,t.textAlign=`center`,t.fillText(`Count`,0,0),t.restore(),t.strokeStyle=p(i.bd,.3),t.lineWidth=1,t.setLineDash([]),t.beginPath(),t.moveTo(64,48+r),t.lineTo(64+n,48+r),t.stroke();let f=a*(m-1),h=Math.floor(f)+1;if(h>=2){t.beginPath(),t.moveTo(v[0].x,48+r),t.lineTo(v[0].x,v[0].y);for(let e=1;e<h;e++){let n=f-Math.floor(f),r=e<h-1?v[e].x:v[e-1].x+(v[e].x-v[e-1].x)*(e===Math.ceil(f)?n:1),i=e<h-1?v[e].y:v[e-1].y+(v[e].y-v[e-1].y)*(e===Math.ceil(f)?n:1);t.lineTo(r,i)}let e=v[Math.min(h-1,m-1)];t.lineTo(e.x,48+r),t.closePath();let n=t.createLinearGradient(0,48,0,48+r);n.addColorStop(0,p(i.teal,.12)),n.addColorStop(1,p(i.teal,.02)),t.fillStyle=n,t.fill()}t.beginPath();for(let e=0;e<h;e++){let n=f-Math.floor(f),r=e===h-1&&e>0&&e===Math.ceil(f),i=e===0||e<h-1?v[e].x:v[e-1].x+(v[e].x-v[e-1].x)*(r?n:1),a=e===0||e<h-1?v[e].y:v[e-1].y+(v[e].y-v[e-1].y)*(r?n:1);e===0?t.moveTo(i,a):t.lineTo(i,a)}t.strokeStyle=p(i.teal,.85),t.lineWidth=2,t.stroke(),v.forEach((e,n)=>{if(n>=h)return;let a=`pt-${n}`,s=o.current.get(a)??0;C(d.current,a,e.x,e.y,10,{label:e.point.week,value:String(e.point.count),color:i.teal}),s>0&&b(t,e.x,48,48+r,p(i.teal,.15*s));let c=e.point.count===l;(s>0||c)&&_(t,e.x,e.y,14,i.teal,(c?.3:0)+s*.25),t.beginPath(),t.arc(e.x,e.y,s>0?5:3.5,0,Math.PI*2),t.fillStyle=p(i.teal,s>0?1:.8),t.fill(),(s>0||c)&&(t.font=u.font,t.fillStyle=i.teal,t.textAlign=`center`,t.fillText(String(e.point.count),e.x,e.y-10)),t.font=u.font,t.fillStyle=s>0?i.teal:u.color,t.textAlign=`center`,t.fillText(e.point.week,e.x,ut-68+14)}),y=requestAnimationFrame(x)};return x(),()=>cancelAnimationFrame(y)},[f]),f.length<2?(0,n.jsx)(B,{width:lt,height:ut,testID:r}):(0,n.jsx)(`div`,{"data-testid":r,className:`trend-scroll`,style:{width:`100%`,overflowX:`auto`},children:(0,n.jsxs)(`div`,{style:{position:`relative`,width:lt,height:ut},children:[(0,n.jsx)(`canvas`,{ref:a,role:`img`,"aria-label":`Trend chart — count over time`,style:{width:lt,height:ut,display:`block`}}),(0,n.jsx)(x,{...l,parentW:lt,parentH:ut})]})})}var ft=680,X=280,pt=80,mt=48,ht=64,gt=u.font,_t=12,vt=Math.PI*2,yt=72,bt=20,xt=5e3;function St({points:e=[],selectedId:r,seriesByEntity:a,colorOffset:o=0,testID:s}){let c=(0,t.useRef)(null),d=(0,t.useRef)(null),f=(0,t.useRef)(0),m=r&&a?.[r]?a[r]:e,h=(0,t.useMemo)(()=>m.filter(e=>typeof e==`object`&&!!e),[m]),_=(0,t.useMemo)(()=>{if(h.length<=1)return ht;let e=document.createElement(`canvas`).getContext(`2d`);if(!e)return ht;e.font=gt;let t=Math.max(1,Math.ceil(h.length/bt)),n=Math.max(...h.filter((e,n)=>n%t===0).map(t=>e.measureText(t.week).width));return Math.max(ht,n+_t)},[h]),v=Math.round(_/2),y=mt+v+Math.max(0,h.length-1)*_,b=Math.max(ft-pt,Math.min(y,xt)),{tooltip:w,hitZonesRef:E}=S(c,{width:b,height:X});return(0,t.useEffect)(()=>{let e=c.current;if(!e)return;let t=g(e,b,X),n=d.current?g(d.current,pt,X):null;f.current=0;let r=l[o%l.length],a=h.length<=yt?yt:Math.max(24,Math.round(yt*(yt/h.length))),s=b-mt,m=X-42-54,y=h.length>0?h.map(e=>e.count):[0],x=Math.min(...y),S=Math.max(...y),w=S-x||1,D=h.length,O=D>1?(s-v)/(D-1):0,k=Math.max(1,Math.ceil(_/O)),A=x<0,j=A?42+m- -x/w*m:42+m,M=v+(s-v)/2,N=h.map((e,t)=>({x:D===1?M:v+t*O,y:42+m-(A?(e.count-x)/w:e.count/(S||1))*m,point:e}));if(n){n.clearRect(0,0,pt,X),n.letterSpacing=u.letterSpacing;let e=A?[x,x+w*.25,x+w*.5,x+w*.75,S]:[0,S*.25,S*.5,S*.75,S];e.forEach((t,r)=>{let i=r/(e.length-1),a=42+m-i*m;n.font=u.font,n.fillStyle=u.color,n.textAlign=`right`,n.fillText(H(t),pt-6,a+3)}),n.save(),n.translate(12,42+m/2),n.rotate(-Math.PI/2),n.font=u.font,n.fillStyle=u.color,n.textAlign=`center`,n.fillText(`Count`,0,0),n.restore()}let P=t.createLinearGradient(0,42,0,42+m);P.addColorStop(0,p(r,.12)),P.addColorStop(1,p(r,.02));let F=0,I,L=e=>{t.font=gt,t.fillStyle=u.color,t.textAlign=`center`;for(let n=0;n<e;n++)n%k===0&&t.fillText(N[n].point.week,N[n].x,X-54+14)},R=()=>{f.current++;let e=Math.min(f.current/a,1),n=T(e),o=e>=1;t.clearRect(0,0,b,X),t.letterSpacing=u.letterSpacing,(A?[0,.25,.5,.75,1]:[.25,.5,.75,1]).forEach(e=>{let n=42+m-e*m;t.strokeStyle=p(i.bd,.18),t.lineWidth=1,t.setLineDash([3,5]),t.beginPath(),t.moveTo(0,n),t.lineTo(s,n),t.stroke(),t.setLineDash([])}),t.font=u.font,t.fillStyle=u.color,t.textAlign=`center`,t.fillText(`Period`,v+(s-v)/2,X-6),t.strokeStyle=p(i.bd,A?.5:.3),t.lineWidth=A?2:1,t.beginPath(),t.moveTo(v,A?j:42+m),t.lineTo(s,A?j:42+m),t.stroke();let c=n*(D-1),l=Math.floor(c)+1;if(l>=2){let e=A?j:42+m;t.beginPath(),t.moveTo(N[0].x,e),t.lineTo(N[0].x,N[0].y);for(let e=1;e<l;e++){let n=c-Math.floor(c),r=e===l-1&&e===Math.ceil(c)&&n>0,i=r?N[e-1].x+(N[e].x-N[e-1].x)*n:N[e].x,a=r?N[e-1].y+(N[e].y-N[e-1].y)*n:N[e].y;t.lineTo(i,a)}t.lineTo(N[l-1].x,e),t.closePath(),t.fillStyle=P,t.fill()}t.beginPath();for(let e=0;e<l;e++){let n=c-Math.floor(c),r=e===l-1&&e>0&&e===Math.ceil(c)&&n>0,i=r?N[e-1].x+(N[e].x-N[e-1].x)*n:N[e].x,a=r?N[e-1].y+(N[e].y-N[e-1].y)*n:N[e].y;e===0?t.moveTo(i,a):t.lineTo(i,a)}t.strokeStyle=p(r,.85),t.lineWidth=2,t.stroke(),t.fillStyle=p(r,.8),t.beginPath();for(let e=0;e<l;e++)t.moveTo(N[e].x+3.5,N[e].y),t.arc(N[e].x,N[e].y,3.5,0,vt);if(t.fill(),l>F){E.current=[];for(let e=0;e<l;e++)C(E.current,`pt-${e}`,N[e].x,N[e].y,10,{label:N[e].point.week,value:String(N[e].point.count),color:r});F=l}o&&L(D),o||(I=requestAnimationFrame(R))};return R(),()=>cancelAnimationFrame(I)},[h,b,_,E,o]),h.length===0?(0,n.jsx)(B,{width:ft,height:X,testID:s}):(0,n.jsxs)(`div`,{"data-testid":s,style:{position:`relative`,width:`100%`,display:`flex`},children:[(0,n.jsx)(`canvas`,{ref:d,"aria-hidden":`true`,style:{width:pt,height:X,display:`block`,flexShrink:0}}),(0,n.jsx)(`div`,{className:`trend-scroll`,style:{flex:1,minWidth:0,overflowX:`auto`},children:(0,n.jsxs)(`div`,{style:{position:`relative`,width:b,height:X},children:[(0,n.jsx)(`canvas`,{ref:c,role:`img`,"aria-label":`Trend chart — count over time`,style:{width:b,height:X,display:`block`}}),(0,n.jsx)(x,{...w,parentW:b,parentH:X})]})})]})}var Ct=780,wt=340,Tt=28,Et=4;function Dt(e,t,n){if(e.measureText(t).width<=n)return t;let r=t;for(;r.length>0&&e.measureText(`${r}…`).width>n;)r=r.slice(0,-1);return`${r}…`}function Ot({severities:e=[],colorOffset:r=0,onItemClick:a,testID:o}){let[s,c]=z(Ct),d=(0,t.useRef)(null),f=(0,t.useRef)(new Map),m=(0,t.useRef)(0),h=(0,t.useMemo)(()=>e.filter(e=>typeof e==`object`&&!!e),[e]),_=(0,t.useRef)(h);_.current=h;let v=(0,t.useCallback)((e,t)=>{let n=typeof t==`object`?t.label??e:e,r=_.current.find(t=>t.severity===e);a?.(e,n,r?.subentity)},[a]),{hoveredRef:y,tooltip:b,hitZonesRef:C}=S(d,{width:c,height:wt,onClick:a?v:void 0});return(0,t.useEffect)(()=>{let e=d.current;if(!e)return;let t=g(e,c,wt);m.current=0;let n=h.reduce((e,t)=>e+(t.count??0),0),a=Tt,o=Tt,s=c-a-o,_=wt-54-54,v=s-Math.max(0,h.length-1)*Et,b=h.map(e=>(e.count??0)/(n||1)*v),x=l[r%l.length],S,T=()=>{m.current++;let e=m.current;t.clearRect(0,0,c,wt),t.letterSpacing=u.letterSpacing;let r=E(Math.min(e/60,1));j(f.current,y.current),C.current=[];let o=a;h.forEach((e,a)=>{let s=b[a]??0,c=f.current.get(e.severity)??0,l=o+s/2,d=s*.78,m=s*r,h=d*r,g=l-h/2;if(m>0){let e=()=>{t.beginPath(),t.moveTo(g,54),t.lineTo(g+h,54),t.lineTo(o+m,54+_),t.lineTo(o,54+_),t.closePath()},n=o+s/2,i=54+_/2,a=Math.sqrt((s/2)**2+(_/2)**2),l=t.createRadialGradient(n,i,0,n,i,a);l.addColorStop(0,p(x,(.03+c*.02)*r)),l.addColorStop(.5,p(x,(.12+c*.04)*r)),l.addColorStop(1,p(x,(.28+c*.08)*r)),t.save(),e(),t.clip(),e(),t.fillStyle=l,t.fill(),t.restore(),e(),t.strokeStyle=p(x,.9*r),t.lineWidth=1,t.stroke()}if(w(C.current,e.severity,o,54,s,_,{label:e.severity,value:H(e.count??0),sublabel:`${Math.round((e.count??0)/(n||1)*100)}%`,color:x}),r>.5){let a=Math.min(1,(r-.5)/.5),l=o+s/2;t.globalAlpha=a,t.font=u.font,t.fillStyle=c>0?x:p(i.t1,.65),t.textAlign=`center`,t.fillText(Dt(t,e.severity,s-8),l,40),t.font=`600 22px 'Satoshi Variable', 'DM Sans', sans-serif`,t.fillStyle=p(i.t1,.92+c*.08),t.fillText(H(e.count??0),l,54+_/2+8),t.font=u.font,t.fillStyle=c>0?x:p(i.t1,.5),t.fillText(`${Math.round((e.count??0)/(n||1)*100)}%`,l,54+_+22),t.globalAlpha=1}o+=s+Et}),S=requestAnimationFrame(T)};return T(),()=>cancelAnimationFrame(S)},[h,c,r]),h.length===0?(0,n.jsx)(`div`,{ref:s,style:{width:`100%`},children:(0,n.jsx)(B,{width:c,height:wt,testID:o})}):(0,n.jsxs)(`div`,{ref:s,"data-testid":o,style:{position:`relative`,width:`100%`,height:wt},children:[(0,n.jsx)(`canvas`,{ref:d,role:`img`,"aria-label":`Early Warning severity distribution — prism spectrum bands`,style:{width:`100%`,height:wt,display:`block`}}),(0,n.jsx)(x,{...b,parentW:c,parentH:wt})]})}var kt=300,At=280,jt=100,Mt={Open:i.red,Submitted:i.amber,Closed:i.green};function Nt({segments:e=[],title:r,unitLabel:a=``,testID:o}){let s=(0,t.useRef)(null),c=(0,t.useRef)(0),l=(0,t.useRef)(new Map),{hoveredRef:f,tooltip:m,hitZonesRef:h}=S(s,{width:kt,height:At}),b=(0,t.useMemo)(()=>e.filter(e=>typeof e==`object`&&!!e),[e]);return(0,t.useEffect)(()=>{let e=s.current;if(!e)return;let t=g(e,kt,At);c.current=0;let n=kt*.5,o=At*.56,m=jt,x=b.reduce((e,t)=>e+(t.count??0),0),S=Math.max(...b.map(e=>e.count??0),1),w,T=()=>{c.current++;let e=c.current;t.clearRect(0,0,kt,At),t.letterSpacing=u.letterSpacing,h.current=[],l.current.forEach((e,t)=>{let n=t===f.current?1:0,r=e+(n-e)*.12;Math.abs(r-n)<.005?n===0?l.current.delete(t):l.current.set(t,1):l.current.set(t,r)}),f.current&&!l.current.has(f.current)&&l.current.set(f.current,0),v(t,kt,At,e,40,p(i.blue,.04)),b.forEach((r,a)=>{let s=a/3*Math.PI*2-Math.PI/2,c=n+Math.cos(s)*m,l=o+Math.sin(s)*m,u=Mt[r.status]??i.blue,f=2+r.count/S*8;t.beginPath(),t.moveTo(n,o),t.lineTo(c,l),t.strokeStyle=p(u,.08),t.lineWidth=f*2,t.stroke(),t.beginPath(),t.moveTo(n,o),t.lineTo(c,l),t.strokeStyle=p(u,.25),t.lineWidth=1,t.stroke();let h=(e*.005+a*.33)%1,g=n+(c-n)*h,v=o+(l-o)*h;_(t,g,v,6,u,.4),t.beginPath(),t.arc(g,v,2,0,Math.PI*2),t.fillStyle=p(u,.8),t.fill();let y=(n+c)/2,b=(o+l)/2;t.font=d.font,t.textAlign=`center`,t.textBaseline=`middle`,t.fillStyle=p(u,.85),t.fillText(String(r.count),y,b)}),b.forEach((e,r)=>{let s=r/3*Math.PI*2-Math.PI/2,c=n+Math.cos(s)*m,d=o+Math.sin(s)*m,f=Mt[e.status]??i.blue,g=10+e.count/S*18,v=l.current.get(e.status)??0;_(t,c,d,g*2.5,f,.2+v*.15);let y=t.createRadialGradient(c,d-g*.2,0,c,d,g);y.addColorStop(0,p(f,.8+v*.2)),y.addColorStop(1,p(f,.4+v*.1)),t.beginPath(),t.arc(c,d,g,0,Math.PI*2),t.fillStyle=y,t.fill(),t.font=`bold `+u.font,t.textAlign=`center`,t.textBaseline=`middle`,t.fillStyle=p(i.t1,.9),t.fillText(e.status,c,d),C(h.current,e.status,c,d,g+6,{label:e.status,value:a?`${e.count} ${a}`:String(e.count),sublabel:`${Math.round((e.count??0)/(x||1)*100)}%`,color:f})});let s=l.current.get(`center`)??0;_(t,n,o,36,i.t2,.2+s*.15);let g=t.createRadialGradient(n,o-4,0,n,o,22);g.addColorStop(0,p(i.t2,.9)),g.addColorStop(1,p(i.t2,.5)),t.beginPath(),t.arc(n,o,22,0,Math.PI*2),t.fillStyle=g,t.fill(),t.font=d.font,t.textAlign=`center`,t.textBaseline=`middle`,t.fillStyle=p(i.t1,.9),t.fillText(r??``,n,o-4),t.font=`bold `+u.font,t.fillStyle=i.t1,t.fillText(String(x),n,o+8),C(h.current,`center`,n,o,28,{label:r??`Total`,value:a?`${x} ${a}`:String(x),color:i.t2}),y(t,kt,At,e,.015),w=requestAnimationFrame(T)};return T(),()=>cancelAnimationFrame(w)},[b,r,a]),b.length===0?(0,n.jsx)(B,{width:kt,height:At,testID:o}):(0,n.jsxs)(`div`,{"data-testid":o,style:{position:`relative`,width:kt,height:At},children:[(0,n.jsx)(`canvas`,{ref:s,role:`img`,"aria-label":r??`EW status arc visualization`,style:{width:kt,height:At,display:`block`,borderRadius:8}}),(0,n.jsx)(x,{...m,parentW:kt,parentH:At})]})}var Pt=280,Ft=96;function It({points:e=[],className:a,colors:o}){let s=(0,t.useRef)(null),c=(0,t.useRef)(new Map),l=(0,t.useRef)(0),u=(0,t.useMemo)(()=>e.filter(Array.isArray).map(([e,t])=>{let n=String(t).match(/-?\d+(\.\d+)?/);return{label:e,value:n?Number(n[0]):0}}),[e]),{mouseRef:d,hoveredRef:f,tooltip:m,hitZonesRef:h}=S(s,{width:Pt,height:Ft});return(0,t.useEffect)(()=>{let e=s.current;if(!e)return;let t=g(e,Pt,Ft);l.current=0;let n=o?.line??i.teal,r=o?.point??i.teal,a=o?.axisLine??i.bd,m,v=()=>{l.current++;let e=l.current;if(t.clearRect(0,0,Pt,Ft),u.length<2){m=requestAnimationFrame(v);return}let o={left:12,right:12,top:16,bottom:20},s=Pt-o.left-o.right,g=Ft-o.top-o.bottom,y=u.map(e=>e.value),x=Math.min(...y),S=Math.max(...y)-x||1,w=e=>o.left+e/(u.length-1)*s,T=e=>o.top+(1-(e-x)/S)*g,E=1-(1-Math.min(e/48,1))**3,D=Math.max(2,Math.floor(E*u.length));if(j(c.current,f.current),h.current=[],t.strokeStyle=p(a,.3),t.lineWidth=.5,t.setLineDash([]),t.beginPath(),t.moveTo(o.left,Ft-o.bottom),t.lineTo(Pt-o.right,Ft-o.bottom),t.stroke(),t.font=`9px 'JetBrains Mono', monospace`,t.fillStyle=p(i.t4,.9),t.textAlign=`center`,u.forEach((e,n)=>{t.fillText(e.label.replace(`Day `,`D`),w(n),Ft-4)}),d.current.over&&f.current){let e=parseInt(f.current.split(`-`)[1]);isNaN(e)||b(t,w(e),o.top,o.top+g)}if(D>1){let e=t.createLinearGradient(0,o.top,0,o.top+g);e.addColorStop(0,p(n,.15)),e.addColorStop(1,p(n,0)),t.fillStyle=e,t.beginPath(),t.moveTo(w(0),o.top+g);for(let e=0;e<D;e++)t.lineTo(w(e),T(u[e].value));t.lineTo(w(D-1),o.top+g),t.closePath(),t.fill(),t.strokeStyle=p(n,.8),t.lineWidth=1.5,t.setLineDash([]),t.beginPath();for(let e=0;e<D;e++){let n=w(e),r=T(u[e].value);e===0?t.moveTo(n,r):t.lineTo(n,r)}t.stroke()}for(let e=0;e<D;e++){let n=w(e),a=T(u[e].value),o=`tp-${e}`,s=c.current.get(o)??0,l=e===u.length-1;C(h.current,o,n,a,10,{label:u[e].label,value:String(u[e].value),color:l?i.red:r}),s>0&&!l&&(_(t,n,a,12*s,r,.2*s),t.fillStyle=p(r,.8),t.beginPath(),t.arc(n,a,3+s*2,0,Math.PI*2),t.fill())}if(D>=u.length){let n=u.length-1,r=w(n),a=T(u[n].value),o=c.current.get(`tp-${n}`)??0,s=k(e,.05,5e-4),l=1+o*.5;t.shadowColor=p(i.red,.5),t.shadowBlur=(8+s*4)*l,t.fillStyle=i.red,t.beginPath(),t.arc(r,a,(3.5+s*1.5)*l,0,Math.PI*2),t.fill(),t.shadowBlur=0}m=requestAnimationFrame(v)};return v(),()=>cancelAnimationFrame(m)},[u,o]),(0,n.jsx)(r,{className:[`canvas-trend-frame`,a].filter(Boolean).join(` `),children:(0,n.jsxs)(`div`,{style:{position:`relative`,width:Pt,height:Ft},children:[(0,n.jsx)(`canvas`,{ref:s,role:`img`,"aria-label":`trend chart`,style:{width:Pt,height:Ft,display:`block`,borderRadius:8}}),(0,n.jsx)(x,{...m,parentW:Pt,parentH:Ft})]})})}function Lt(e,t,n){if(e.measureText(t).width<=n)return t;let r=t;for(;r.length>0&&e.measureText(r+`…`).width>n;)r=r.slice(0,-1);return r+`…`}var Rt=680,zt=8,Z=4,Bt=8,Vt=Z*2+Bt,Ht=36,Ut=Ht/2,Wt=48;function Gt({items:e=[],itemsByEntity:r,onItemClick:a,selectedId:o,labelA:s=`Implemented`,labelB:c=`Unimplemented`,unit:l=`variations`,testID:m}){let[h,v]=z(Rt),y=(0,t.useRef)(null),b=(0,t.useRef)(new Map),C=(0,t.useRef)(0),T=(0,t.useRef)(o);T.current=o;let D=(0,t.useRef)([]),O=(0,t.useCallback)((e,t)=>{let n=e.replace(/-impl$|-un$/,``),r=typeof t==`object`?t.label??n:n,i=D.current.find(e=>e.id===n);a?.(n,r,i?.subentity)},[a]),[k,M]=(0,t.useState)(!1),N=(0,t.useMemo)(()=>e.filter(e=>typeof e==`object`&&!!e),[e]),P=!!(o&&r?.[o]),F=P?r[o]:e,I=(0,t.useMemo)(()=>F.filter(e=>typeof e==`object`&&!!e),[F]),L=(0,t.useMemo)(()=>k?I:I.slice(0,zt),[I,k]);D.current=L;let R=Ut+Wt+L.length*(Vt+Ht)-Ht,{hoveredRef:V,tooltip:te,hitZonesRef:U}=S(y,{width:v,height:R,onClick:a?O:void 0});return(0,t.useEffect)(()=>{let e=y.current;if(!e)return;let t=g(e,v,R);C.current=0,t.font=u.font;let n=L.reduce((e,n)=>Math.max(e,t.measureText(n.abbreviation??n.name??``).width),0);t.font=d.font;let r=L.reduce((e,n)=>Math.max(e,t.measureText(H(n.implemented??0)).width,t.measureText(H(n.unimplemented??0)).width),0),a=Math.max(Math.min(n+20,v*.3),40),o=Math.max(r+24,32),m=v-a-o,h=Math.max(...L.map(e=>e.implemented??0),...L.map(e=>e.unimplemented??0),1),x=L.length*(Vt+Ht)-Ht,S=Ut+(R-Ut-Wt-x)/2,D,O=()=>{C.current++;let e=C.current;t.clearRect(0,0,v,R);let n=E(Math.min(e/60,1));j(b.current,V.current),U.current=[],L.forEach((e,o)=>{let f=A(n,o,L.length,E),g=S+o*(Vt+Ht),v=g,y=g+Z+Bt,x=`${e.id}-impl`,C=`${e.id}-un`,D=b.current.get(x)??0,O=b.current.get(C)??0,k=!P&&T.current&&e.id!==T.current?.6:1,j=(e.implemented??0)/h*m*f,M=(e.unimplemented??0)/h*m*f;if(t.font=u.font,t.fillStyle=D>0||O>0?i.t1:i.t2,t.textAlign=`right`,t.textBaseline=`middle`,t.fillText(Lt(t,e.abbreviation??e.name??``,a-16),a-8,g+Vt/2),t.textBaseline=`alphabetic`,w(U.current,x,0,g,a,Vt,{label:e.name??e.abbreviation??``,value:`${H((e.implemented??0)+(e.unimplemented??0))} total ${l}`,sublabel:`${s}: ${H(e.implemented??0)} · ${c}: ${H(e.unimplemented??0)}`,color:i.green},void 0,a+Math.max(j,M)+16+r+14),j>0){D>0&&_(t,a+j/2,v+Z/2,j*.15,i.green,.18*D);let e=t.createLinearGradient(a,0,a+j,0);e.addColorStop(0,p(i.green,.7*k)),e.addColorStop(1,p(i.green,1*k)),t.fillStyle=e,t.beginPath(),t.roundRect(a,v,j,Z,Z/2),t.fill()}if(w(U.current,x,a,v,Math.max(j,1),Z,{label:e.name,value:H(e.implemented??0),color:i.green},g+Vt/2,a+Math.max(j,M)+16+r+14),f>.4&&(t.globalAlpha=Math.min(1,(f-.4)/.4),t.font=d.font,t.fillStyle=i.t1,t.textAlign=`left`,t.textBaseline=`middle`,t.fillText(H(e.implemented??0),a+j+16,v+Z/2),t.globalAlpha=1,t.textBaseline=`alphabetic`),M>0){O>0&&_(t,a+M/2,y+Z/2,M*.15,i.amber,.18*O);let e=t.createLinearGradient(a,0,a+M,0);e.addColorStop(0,p(i.amber,.5*k)),e.addColorStop(1,p(i.amber,.9*k)),t.fillStyle=e,t.beginPath(),t.roundRect(a,y,M,Z,Z/2),t.fill()}w(U.current,C,a,y,Math.max(M,1),Z,{label:e.name,value:H(e.unimplemented??0),color:i.amber},g+Vt/2,a+Math.max(j,M)+16+r+14),f>.4&&(t.globalAlpha=Math.min(1,(f-.4)/.4),t.font=d.font,t.fillStyle=i.t1,t.textAlign=`left`,t.textBaseline=`middle`,t.fillText(H(e.unimplemented??0),a+M+16,y+Z/2),t.globalAlpha=1,t.textBaseline=`alphabetic`)});let o=S+x+28;t.font=f.font,t.textBaseline=`middle`,t.textAlign=`left`;let g=t.measureText(s).width,y=t.measureText(c).width,k=18+g,M=18+y,N=(v-(k+24+M))/2,F=t.createLinearGradient(N,0,N+12,0);F.addColorStop(0,p(i.green,.7)),F.addColorStop(1,p(i.green,1)),t.fillStyle=F,t.beginPath(),t.rect(N,o-6,12,12),t.fill(),t.fillStyle=f.color,t.fillText(s,N+12+6,o);let I=N+k+24,z=t.createLinearGradient(I,0,I+12,0);z.addColorStop(0,p(i.amber,.5)),z.addColorStop(1,p(i.amber,.9)),t.fillStyle=z,t.beginPath(),t.rect(I,o-6,12,12),t.fill(),t.fillStyle=f.color,t.fillText(c,I+12+6,o),t.textBaseline=`alphabetic`,D=requestAnimationFrame(O)};return O(),()=>cancelAnimationFrame(D)},[L,R,v]),N.length===0?(0,n.jsx)(`div`,{ref:h,style:{width:`100%`},children:(0,n.jsx)(B,{width:v,height:160,testID:m})}):(0,n.jsxs)(`div`,{ref:h,"data-testid":m,style:{width:`100%`},children:[(0,n.jsxs)(`div`,{style:{position:`relative`,height:R},children:[(0,n.jsx)(`canvas`,{ref:y,role:`img`,"aria-label":`Implemented vs unimplemented variations per contractor — split bar`,style:{width:`100%`,height:R,display:`block`}}),(0,n.jsx)(x,{...te,parentW:v,parentH:R})]}),N.length>zt&&(0,n.jsx)(`div`,{style:{marginTop:8},children:(0,n.jsx)(ee,{expanded:k,onToggle:()=>M(e=>!e)})})]})}var Kt=800,qt=360;function Jt({items:e=[],onItemClick:r,testID:a}){let[o,c]=z(Kt),l=(0,t.useRef)(null),f=(0,t.useRef)(new Map),m=(0,t.useRef)(0),h=(0,t.useRef)(e);h.current=e;let v=(0,t.useCallback)((e,t)=>{let n=typeof t==`object`?t.label??e:e,i=h.current.find(t=>t.id===e);r?.(e,n,i?.subentity)},[r]),{hoveredRef:y,tooltip:b,hitZonesRef:C}=S(l,{width:c,height:qt,onClick:r?v:void 0});return(0,t.useEffect)(()=>{let t=l.current;if(!t)return;let n=g(t,c,qt);m.current=0;let r=Math.round(c*.125),a=Math.round(c*.525),o=Math.round(c*.9),h=Math.max(60,Math.round(c*.1375)),v=e.reduce((e,t)=>e+(t.base??0),0),b=e.reduce((e,t)=>e+(t.variation??0),0),x=e.reduce((e,t)=>e+(t.total??0),0),S=qt-20-26,E=S-6*(e.length-1),D=20,O=e.map((e,t)=>{let n=Math.max(24,(e.total??0)/(x||1)*E),i={x:r-h/2,y:D,h:n,cy:D+n/2,c:e,color:s[t%s.length]};return D+=n+6,i}),k=E-14,M=Math.max(28,v/(x||1)*k),N=Math.max(18,b/(x||1)*k),P=20+(S-(M+N+14))/2,F={x:a-h/2,y:P,h:M,cy:P+M/2},I={x:a-h/2,y:P+M+14,h:N,cy:P+M+14+N/2},L={x:o-h/2,y:20,h:S,cy:20+S/2},R,z=()=>{m.current++;let t=m.current;n.clearRect(0,0,c,qt),n.letterSpacing=u.letterSpacing;let s=T(Math.min(t/80,1));if(j(f.current,y.current),C.current=[],e.forEach((t,r)=>{let i=O[r],o=A(s,r,e.length,T),c=f.current.get(t.id)??0;if(o<.01)return;let l=(t.base??0)/(t.total||1),u=(t.variation??0)/(t.total||1),d=i.h*l,p=i.h*u,m=i.y+d/2,g=i.y+d+p/2,_=Math.max(2,(t.base??0)/v*M),y=Math.max(2,(t.variation??0)/b*N),x=F.y+e.slice(0,r).reduce((e,t)=>e+(t.base??0)/v*M,0)+_/2,S=I.y+e.slice(0,r).reduce((e,t)=>e+(t.variation??0)/b*N,0)+y/2,C=c*.2+.18;Yt(n,i.x+h,m,a-h/2,x,_*o,i.color,C),Yt(n,i.x+h,g,a-h/2,S,y*o,i.color,C*.75)}),s>.3){let e=Math.min(1,(s-.3)/.7),t=L.y+v/x*S/2,r=L.y+S-b/x*S/2;Yt(n,a+h/2,F.cy,o-h/2,t,M*e,i.blue,.25*e),Yt(n,a+h/2,I.cy,o-h/2,r,N*e,i.amber,.22*e)}if([`Contractors`,`Components`,`Total`].forEach((e,t)=>{let i=[r,a,o][t];n.font=u.font,n.fillStyle=u.color,n.textAlign=`center`,n.fillText(e,i,qt-8)}),e.forEach((t,r)=>{let a=O[r],o=A(s,r,e.length,T),c=f.current.get(t.id)??0;w(C.current,t.id,a.x,a.y,h,a.h,{label:t.name,value:t.totalLabel??String(t.total??0),sublabel:`${t.baseLabel??String(t.base??0)} + ${t.variationLabel??String(t.variation??0)}`,color:a.color}),c>0&&_(n,a.x+h/2,a.cy,h*.6,a.color,.12*c),n.fillStyle=p(a.color,(.3+c*.15)*o),n.strokeStyle=p(a.color,(.55+c*.25)*o),n.lineWidth=1,n.beginPath(),n.roundRect(a.x,a.y,h*o,a.h,4),n.fill(),n.stroke(),o>.6&&a.h>=24&&(n.globalAlpha=Math.min(1,(o-.6)/.4),n.font=u.font,n.fillStyle=c>0?a.color:p(i.t2,.9),n.textAlign=`center`,n.textBaseline=`middle`,n.fillText(t.abbreviation??t.name?.slice(0,6)??``,a.x+h/2,a.h>=36?a.cy-5:a.cy),a.h>=36&&(n.font=`400 12px 'Satoshi Variable', 'DM Sans', sans-serif`,n.fillStyle=p(i.t3,.8),n.fillText(t.totalLabel??String(t.total??0),a.x+h/2,a.cy+7)),n.globalAlpha=1,n.textBaseline=`alphabetic`)}),s>.2){let e=Math.min(1,(s-.2)/.4);_(n,a,F.cy,30,i.blue,.1*e),n.fillStyle=p(i.blue,.3*e),n.strokeStyle=p(i.blue,.5*e),n.lineWidth=1,n.beginPath(),n.roundRect(F.x,F.y,h,F.h*e,4),n.fill(),n.stroke(),n.globalAlpha=e,n.textBaseline=`middle`,n.font=u.font,n.fillStyle=i.blue,n.textAlign=`center`,n.fillText(`Base Value`,a,F.cy-6),n.font=d.font,n.fillStyle=d.color,n.fillText(H(v),a,F.cy+8),n.globalAlpha=1,n.textBaseline=`alphabetic`,_(n,a,I.cy,24,i.amber,.1*e),n.fillStyle=p(i.amber,.22*e),n.strokeStyle=p(i.amber,.4*e),n.beginPath(),n.roundRect(I.x,I.y,h,I.h*e,4),n.fill(),n.stroke(),n.globalAlpha=e,n.textBaseline=`middle`,n.font=u.font,n.fillStyle=i.amber,n.textAlign=`center`,n.fillText(`Variations`,a,I.cy-4),n.font=d.font,n.fillStyle=d.color,n.fillText(H(b),a,I.cy+8),n.globalAlpha=1,n.textBaseline=`alphabetic`}if(s>.5){let e=Math.min(1,(s-.5)/.5);_(n,o,L.cy,44,i.blue,.2*e),n.fillStyle=p(i.blue,.25*e),n.strokeStyle=p(i.blue,.6*e),n.lineWidth=1.5,n.beginPath(),n.roundRect(L.x,L.y,h,L.h*e,6),n.fill(),n.stroke(),n.globalAlpha=e,n.textBaseline=`middle`,n.font=u.font,n.fillStyle=i.t2,n.textAlign=`center`,n.fillText(`Total Commitment`,o,L.cy-12),n.font=d.font,n.fillStyle=i.blue,n.fillText(H(x),o,L.cy+6),n.globalAlpha=1,n.textBaseline=`alphabetic`}R=requestAnimationFrame(z)};return z(),()=>cancelAnimationFrame(R)},[e,c]),(0,n.jsxs)(`div`,{ref:o,"data-testid":a,style:{position:`relative`,width:`100%`,height:qt},children:[(0,n.jsx)(`canvas`,{ref:l,role:`img`,"aria-label":`Weekly report flow — base value and variations per contractor flowing to total commitment`,style:{width:`100%`,height:qt,display:`block`}}),(0,n.jsx)(x,{...b,parentW:c,parentH:qt})]})}function Yt(e,t,n,r,i,a,o,s){let c=(t+r)/2;e.beginPath(),e.moveTo(t,n-a/2),e.bezierCurveTo(c,n-a/2,c,i-a/2,r,i-a/2),e.lineTo(r,i+a/2),e.bezierCurveTo(c,i+a/2,c,n+a/2,t,n+a/2),e.closePath(),e.fillStyle=p(o,s),e.fill()}var Xt=680,Zt=160,Qt={left:8,right:90,top:16,bottom:16},$t=150,en=4,tn=48,nn=8;function rn(e,t,n){if(e.measureText(t).width<=n)return t;let r=t;for(;r.length>0&&e.measureText(r+`…`).width>n;)r=r.slice(0,-1);return r+`…`}function an(e,t){let n=Math.abs(e),r=e<0?`-`:``;return n>=1e6?`${r}${t}${(n/1e6).toFixed(1)}M`:n>=1e3?`${r}${t}${(n/1e3).toFixed(1)}K`:`${r}${t}${n.toFixed(0)}`}function on({rows:e,valuePrefix:r=`$`,onItemClick:a,testID:o}){let[s,c]=z(Xt),l=(0,t.useRef)(null),f=(0,t.useRef)(new Map),[m,h]=(0,t.useState)(!1),g=(0,t.useRef)(e);g.current=e;let v=(0,t.useCallback)((e,t)=>{let n=typeof t==`object`?t.label??e:e,r=g.current.find(t=>t.id===e);a?.(e,n,r?.subentity)},[a]),y=e.filter(e=>e!=null&&typeof e.value==`number`),b=m?y:y.slice(0,nn),C=b.length,T=Math.max(...y.map(e=>Math.abs(e.value)),1),D=c-Qt.left-$t-Qt.right,O=C*tn,k=Qt.top+Qt.bottom+O,{hoveredRef:M,tooltip:N,hitZonesRef:P}=S(l,{width:c,height:k,onClick:a?v:void 0});return pe(l,c,k,(e,t)=>{j(f.current,M.current),P.current=[],b.forEach((n,a)=>{let o=A(t,a,C,E),s=Qt.top+a*tn,l=s+(tn-en)/2,m=s+tn/2,h=Qt.left+$t,g=f.current.get(n.id)??0,v=Math.abs(n.value)/T*D*o,y=n.valueLabel??an(n.value,r);if(e.save(),e.font=u.font,e.fillStyle=g>0?i.cyan:u.color,e.textAlign=`right`,e.textBaseline=`middle`,e.fillText(rn(e,n.name,$t-16),h-8,m),w(P.current,n.id,0,s,h,tn,{label:n.name,value:y,color:i.cyan}),e.fillStyle=p(i.cyan,.1),e.beginPath(),e.roundRect(h,l,D,en,en/2),e.fill(),v>0){g>0&&_(e,h+v,l+en/2,v*.25,i.cyan,.14*g);let t=e.createLinearGradient(h,l,h+v,l);t.addColorStop(0,p(i.cyan,.2+g*.05)),t.addColorStop(.55,p(i.cyan,.55+g*.15)),t.addColorStop(1,p(i.cyan,.72+g*.18)),e.fillStyle=t,e.beginPath(),e.roundRect(h,l,v,en,en/2),e.fill()}g>0&&v>0&&(e.strokeStyle=p(i.cyan,.6*g),e.lineWidth=1,e.beginPath(),e.roundRect(h,l,v,en,en/2),e.stroke()),o>.35&&(e.globalAlpha=Math.min(1,(o-.35)/.4),e.font=d.font,e.fillStyle=g>0?i.cyan:d.color,e.textAlign=`right`,e.textBaseline=`middle`,e.fillText(y,c-8,m)),e.restore(),w(P.current,n.id,h,s,Math.max(v,1),tn,{label:n.name,value:y,color:i.cyan})})},!0,{easing:E}),y.length===0?(0,n.jsx)(`div`,{ref:s,style:{width:`100%`},children:(0,n.jsx)(B,{width:c,height:Zt,message:`No data available`,testID:o})}):(0,n.jsxs)(`div`,{ref:s,"data-testid":o,style:{width:`100%`},children:[(0,n.jsxs)(`div`,{style:{position:`relative`},children:[(0,n.jsx)(`canvas`,{ref:l,role:`img`,"aria-label":`Horizontal bar chart`,style:{width:`100%`,height:k,display:`block`,borderRadius:8}}),(0,n.jsx)(x,{...N,parentW:c,parentH:k})]}),y.length>nn&&(0,n.jsx)(`div`,{style:{marginTop:8},children:(0,n.jsx)(ee,{expanded:m,onToggle:()=>h(e=>!e),"data-testid":o?`${o}-toggle`:void 0})})]})}function sn({config:e,className:t,colorOffset:r=0,onItemClick:i,selectedId:a,listenerItems:o}){let s=o?void 0:a;if(e.type===Y.LINE)return(0,n.jsx)(Ie,{rows:e.rows,className:t});if(e.type===Y.AREA)return(0,n.jsx)(F,{rows:e.rows,className:t});if(e.type===Y.BAR)return(0,n.jsx)(R,{rows:e.rows,className:t});if(e.type===Y.PIE)return(0,n.jsx)(Je,{rows:e.rows,variant:`pie`,className:t});if(e.type===Y.DONUT)return(0,n.jsx)(Je,{rows:e.rows,variant:`donut`,className:t});if(e.type===Y.SANKEY)return(0,n.jsx)(at,{rows:e.rows,className:t});if(e.type===Y.FLOW)return(0,n.jsx)(it,{selectedEntity:e.selectedEntity,className:t});if(e.type===Y.TREND)return(0,n.jsx)(It,{points:e.points,className:t});if(e.type===Y.MINI_BARS)return(0,n.jsx)(ze,{rows:e.rows,className:t});if(e.type===Y.STACKED_HORIZONTAL_BAR){let t=e.data??{items:e.items??[]};return(0,n.jsx)(Oe,{data:o?{items:o}:t,dataByEntity:e.dataByEntity,onItemClick:i,selectedId:s})}if(e.type===Y.MULTI_METRIC_CONSTELLATION)return(0,n.jsx)(be,{items:e.items});if(e.type===Y.PROGRESS_RACE)return(0,n.jsx)(se,{items:o||e.items,itemsByEntity:e.itemsByEntity,colorOffset:r,onItemClick:i,selectedId:s});if(e.type===Y.HUB_AND_SPOKE_RADIAL)return(0,n.jsx)(Nt,{segments:e.segments,title:e.title,unitLabel:e.unitLabel});if(e.type===Y.DOT_MATRIX)return(0,n.jsx)(Fe,{items:e.items});if(e.type===Y.RANKED_CARD_LEADERBOARD)return(0,n.jsx)(Pe,{items:o||e.items,onItemClick:i});if(e.type===Y.PROPORTIONAL_BAND)return(0,n.jsx)(Ot,{severities:o||e.severities,colorOffset:r,onItemClick:i});if(e.type===Y.RADIAL_FAN_TREE){let t=o&&!Array.isArray(o)?o:null,a=t?t.items:o||e.items;return(0,n.jsx)(We,{total:t?t.total:o?o.reduce((e,t)=>e+(t.count??0),0):e.total,totalLabel:t?t.totalLabel:e.totalLabel,items:a,dataByEntity:e.dataByEntity,colorOffset:r,onItemClick:i,selectedId:s})}if(e.type===Y.SEMI_CIRCULAR_GAUGE){let t=Array.isArray(o)?o[0]:void 0;return(0,n.jsx)(fe,{confirmed:t?Number(t.confirmed??0):e.confirmed,total:t?Number(t.total??1):e.total,label:e.label,gaugeByEntity:e.gaugeByEntity,colorOffset:r,selectedId:s,onItemClick:i,subentity:e.subentity})}if(e.type===Y.SEGMENTED_SPLIT_BAR)return(0,n.jsx)(Gt,{items:o||e.items,itemsByEntity:e.itemsByEntity,labelA:e.labelA,labelB:e.labelB,unit:e.unit,onItemClick:i,selectedId:s});if(e.type===Y.BALANCE_SCALE){let t=e.left,r=e.right;if(o&&!Array.isArray(o)){let e=o;if(e.items?.length>=2){let n=Number(e.items[0].count??0),i=Number(e.items[1].count??0);t={value:n,count:1,label:`£`+H(n,2)},r={value:i,count:1,label:`£`+H(i,2)}}}return(0,n.jsx)(ct,{left:t,right:r,leftTitle:e.leftTitle,rightTitle:e.rightTitle,unit:e.unit,dataByEntity:e.dataByEntity,onItemClick:i,selectedId:s})}return e.type===Y.AREA_LINE?(0,n.jsx)(dt,{points:e.points}):e.type===Y.TREND_VIEW?(0,n.jsx)(St,{points:(o&&!Array.isArray(o)?o.points??[]:void 0)??e.points,colorOffset:r}):e.type===Y.WEEKLY_FLOW?(0,n.jsx)(Jt,{items:o||e.items,onItemClick:i}):e.type===Y.HORIZONTAL_BAR?(0,n.jsx)(on,{rows:o||e.rows,valuePrefix:e.valuePrefix,onItemClick:i}):(0,n.jsx)(`div`,{className:`viz-empty`,children:`Visualization unavailable`})}var cn=[];function ln(e){try{return JSON.parse(decodeURIComponent(e))}catch{return null}}function un(){for(;cn.length;){let e=cn.pop();e&&e.unmount()}}function dn(){un(),document.querySelectorAll(`[data-d3-viz]`).forEach(t=>{let r=t.dataset.d3Viz;if(!r)return;let i=ln(r);if(!i)return;let a=(0,e.createRoot)(t);cn.push(a),a.render((0,n.jsx)(sn,{config:i}))})}function fn(e){return encodeURIComponent(JSON.stringify(e))}function pn({rows:e=[],className:t,colors:r}){return(0,n.jsx)(Je,{rows:e,variant:`donut`,className:t,colors:r})}var Q={bg:`transparent`,border:`transparent`,t1:i.t1,t2:i.t2,t3:i.t3,t4:i.t4,red:i.red,amber:i.amber,green:i.green},$=`'Satoshi Variable', 'DM Sans', sans-serif`,mn={color:`#F7F7F7`,fontFamily:$,fontSize:24,fontWeight:500,lineHeight:`32px`},hn={color:`#B3B5B6`,fontFamily:$,fontSize:18,fontWeight:400,lineHeight:`20px`};function gn({items:e=[]}){let t=e.filter(e=>e.value);return t.length===0?null:(0,n.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:20},children:t.map((e,t)=>(0,n.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,justifyContent:`space-between`,alignItems:`center`,width:286,minHeight:129,padding:`20px 16px`,flexShrink:0,border:`1px solid rgba(255,255,255,0.20)`,background:`rgba(255,255,255,0.05)`,boxShadow:`3.42px 3.42px 3.42px 0px rgba(0,0,0,0.30)`,boxSizing:`border-box`},children:[(0,n.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:24,flex:1,minWidth:0},children:[(0,n.jsx)(`div`,{style:{...mn,color:`#FFFFFF`},children:e.value}),(0,n.jsx)(`div`,{style:{...hn,color:`rgba(255,255,255,0.70)`},children:e.label})]}),e.icon&&(0,n.jsx)(`div`,{style:{width:60,height:60,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,n.jsx)(`img`,{src:e.icon,width:60,height:60,alt:``,style:{objectFit:`contain`}})})]},t))})}function _n({items:e=[]}){let t=e.filter(e=>e.name??e.value);return t.length===0?null:(0,n.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:t.map((e,t)=>(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,padding:`10px 0px`,background:Q.bg,border:`1px solid ${Q.border}`},children:[(0,n.jsx)(`span`,{style:{fontSize:18,fontWeight:500,color:Q.t2,background:`transparent`,padding:`2px 8px`,borderRadius:4,fontFamily:$,flexShrink:0},children:e.name}),(0,n.jsx)(`span`,{style:{...mn,fontSize:18,color:Q.t1,minWidth:70,flexShrink:0},children:e.value}),(0,n.jsx)(`span`,{style:{...hn,flex:1},children:e.kpiLabel})]},t))})}function vn({items:e=[]}){let t=e.filter(e=>e.value);return t.length===0?null:(0,n.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:20},children:t.map((e,t)=>(0,n.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,justifyContent:`space-between`,alignItems:`center`,width:286,minHeight:129,padding:`20px 16px`,flexShrink:0,border:`1px solid rgba(255,255,255,0.20)`,background:`rgba(255,255,255,0.05)`,boxShadow:`3.42px 3.42px 3.42px 0px rgba(0,0,0,0.30)`,boxSizing:`border-box`},children:[(0,n.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:24,flex:1,minWidth:0},children:[(0,n.jsx)(`div`,{style:{...mn,color:`#FFFFFF`},children:e.value}),(0,n.jsx)(`div`,{style:{...hn,color:`rgba(255,255,255,0.70)`},children:e.label})]}),e.icon&&(0,n.jsx)(`div`,{style:{width:60,height:60,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,n.jsx)(`img`,{src:e.icon,width:60,height:60,alt:``,style:{objectFit:`contain`}})})]},t))})}var yn={red:Q.red,amber:Q.amber,green:Q.green};function bn({items:e=[]}){let t=e.filter(e=>e.text);return t.length===0?null:(0,n.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:t.map((e,t)=>(yn[e.severity],(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:10,padding:`10px 0px`,background:Q.bg,border:`1px solid ${Q.border}`},children:[(0,n.jsx)(`span`,{style:{width:7,height:7,borderRadius:`50%`,background:i.t2,flexShrink:0,marginTop:5}}),(0,n.jsx)(`span`,{style:{...hn,color:`#B3B5B6`},children:e.text})]},t)))})}function xn({min:e,max:t,unit:r,dots:a=[],chips:o=[]}){let s=a.filter(e=>e.name);if(s.length===0)return null;let c=t-e;return(0,n.jsxs)(`div`,{children:[(0,n.jsxs)(`div`,{style:{position:`relative`,height:90,padding:`10px 0px`},children:[(0,n.jsx)(`div`,{style:{position:`absolute`,top:38,left:8,right:8,height:2,background:`rgba(255,255,255,0.08)`,borderRadius:1}}),(0,n.jsxs)(`div`,{style:{position:`absolute`,top:43,left:0,fontSize:16,color:Q.t4,fontFamily:$},children:[e,r]}),(0,n.jsxs)(`div`,{style:{position:`absolute`,top:43,right:0,fontSize:16,color:Q.t4,fontFamily:$},children:[t,r]}),s.map((t,a)=>{let o=(t.val-e)/c*100,s=t.color??i.blue,l=a%2==0;return(0,n.jsxs)(`div`,{style:{position:`absolute`,left:`${o}%`,top:0,transform:`translateX(-50%)`},children:[l&&(0,n.jsxs)(`div`,{style:{textAlign:`center`,marginBottom:2},children:[(0,n.jsx)(`div`,{style:{fontSize:18,color:s,fontFamily:$,whiteSpace:`nowrap`},children:t.name}),(0,n.jsxs)(`div`,{style:{fontSize:18,fontWeight:500,color:s,fontFamily:$,whiteSpace:`nowrap`},children:[t.val,r]})]}),(0,n.jsx)(`div`,{style:{width:10,height:10,borderRadius:`50%`,background:s,boxShadow:`0 0 8px ${s}70`,margin:l?`0 auto`:`26px auto 0`}}),!l&&(0,n.jsxs)(`div`,{style:{textAlign:`center`,marginTop:4},children:[(0,n.jsx)(`div`,{style:{fontSize:18,color:s,fontFamily:$,whiteSpace:`nowrap`},children:t.name}),(0,n.jsxs)(`div`,{style:{fontSize:18,fontWeight:500,color:s,fontFamily:$,whiteSpace:`nowrap`},children:[t.val,r]})]})]},a)})]}),o&&o.length>0&&(0,n.jsx)(vn,{items:o})]})}function Sn({leftPct:e,leftLabel:t,leftValue:r,leftColor:a,rightPct:o,rightLabel:s,rightValue:c,rightColor:l,chips:u}){if(!t&&!s)return null;let d=a??i.blue,f=l??i.blue;return(0,n.jsxs)(`div`,{children:[(0,n.jsxs)(`div`,{style:{display:`flex`,borderRadius:6,overflow:`hidden`,height:36,margin:`10px 0`},children:[(0,n.jsx)(`div`,{style:{width:`${e}%`,background:d+`38`,display:`flex`,alignItems:`center`,justifyContent:`flex-end`,paddingRight:12},children:(0,n.jsx)(`span`,{style:{fontSize:18,fontWeight:500,color:Q.t2,fontFamily:$},children:r})}),(0,n.jsx)(`div`,{style:{width:1,background:`rgba(255,255,255,0.12)`,flexShrink:0}}),(0,n.jsx)(`div`,{style:{width:`${o}%`,background:f+`2A`,display:`flex`,alignItems:`center`,paddingLeft:12},children:(0,n.jsx)(`span`,{style:{fontSize:18,fontWeight:500,color:Q.t2,fontFamily:$},children:c})})]}),(0,n.jsxs)(`div`,{style:{display:`flex`,marginBottom:u?4:0},children:[(0,n.jsx)(`div`,{style:{width:`${e}%`},children:(0,n.jsxs)(`span`,{style:{fontSize:18,color:d,fontFamily:$},children:[e,`% `,t]})}),(0,n.jsx)(`div`,{style:{width:`${o}%`,paddingLeft:10},children:(0,n.jsxs)(`span`,{style:{fontSize:18,color:f,fontFamily:$},children:[o,`% `,s]})})]}),u&&u.length>0&&(0,n.jsx)(vn,{items:u})]})}function Cn({pct:e,label:t,color:r,chips:a}){if(e==null&&!t)return null;let o=r??i.blue,s=2*Math.PI*30,c=s*(1-e/100);return(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:20},children:[(0,n.jsxs)(`div`,{style:{position:`relative`,flexShrink:0,width:80,height:80},children:[(0,n.jsxs)(`svg`,{width:80,height:80,style:{transform:`rotate(-90deg)`},children:[(0,n.jsx)(`circle`,{cx:40,cy:40,r:30,fill:`none`,stroke:`rgba(255,255,255,0.07)`,strokeWidth:8}),(0,n.jsx)(`circle`,{cx:40,cy:40,r:30,fill:`none`,stroke:o,strokeWidth:8,strokeDasharray:s,strokeDashoffset:c,strokeLinecap:`round`})]}),(0,n.jsx)(`div`,{style:{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,textAlign:`center`},children:(0,n.jsxs)(`div`,{style:{fontSize:18,fontWeight:500,color:o,fontFamily:$},children:[e,`%`]})})]}),(0,n.jsxs)(`div`,{style:{flex:1},children:[(0,n.jsx)(`div`,{style:{...hn,padding:`10px 0px`},children:t}),a&&(0,n.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:a.map((e,t)=>(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`baseline`,gap:8,padding:`10px 10px`,background:Q.bg,border:`1px solid ${Q.border}`,borderRadius:5},children:[(0,n.jsx)(`span`,{style:{...mn,color:Q.t2},children:e.value}),(0,n.jsx)(`span`,{style:{...mn,color:Q.t2,fontWeight:400,userSelect:`none`},children:`|`}),(0,n.jsx)(`span`,{style:{...hn},children:e.label})]},t))})]})]})}function wn({items:e=[]}){let t=e.filter(e=>e.name??e.value);return t.length===0?null:(0,n.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:t.map((e,t)=>(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,padding:`10px 0px`,background:Q.bg,border:`1px solid ${Q.border}`},children:[(0,n.jsx)(`span`,{style:{fontSize:18,fontWeight:500,color:Q.t2,background:`transparent`,padding:`2px 7px`,borderRadius:4,fontFamily:$,flexShrink:0,minWidth:62,textAlign:`center`},children:e.name}),(0,n.jsx)(`div`,{style:{flex:1,height:4,background:`rgba(255,255,255,0.07)`,borderRadius:0,overflow:`hidden`},children:(0,n.jsx)(`div`,{style:{height:`100%`,width:`${e.pct}%`,background:e.color??i.purple,borderRadius:0,opacity:.75}})}),(0,n.jsx)(`span`,{style:{fontSize:18,fontWeight:400,color:Q.t2,fontFamily:$,flexShrink:0,minWidth:320,textAlign:`right`},children:[e.value,e.badge,e.sublabel].filter(Boolean).join(` `)})]},t))})}var Tn={red:Q.red,amber:Q.amber,green:Q.green};function En({items:e=[]}){let t=e.filter(e=>e.text);return t.length===0?null:(0,n.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:t.map((e,t)=>{let r=Tn[e.severity];return(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:10,padding:`9px 12px`,background:`transparent`},children:[(0,n.jsx)(`span`,{style:{fontSize:18,fontWeight:500,color:r,background:r+`20`,padding:`2px 7px`,borderRadius:4,fontFamily:$,flexShrink:0},children:e.tag}),(0,n.jsx)(`span`,{style:{flex:1,...hn},children:e.text}),(0,n.jsx)(`span`,{style:{...hn,flexShrink:0,marginTop:1},children:e.date})]},t)})})}function Dn({columns:e=[],rows:t=[]}){return t.length===0?null:(0,n.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:[(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,padding:`0 0px 6px`,borderBottom:`1px solid ${Q.border}`},children:[(0,n.jsx)(`div`,{style:{minWidth:64}}),e.map((e,t)=>(0,n.jsx)(`div`,{style:{flex:1,fontSize:18,fontWeight:500,color:Q.t2,fontFamily:$,textTransform:`uppercase`,letterSpacing:.6},children:e},t))]}),t.map((e,t)=>(0,n.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,padding:`8px 0px`,background:Q.bg,border:`1px solid ${Q.border}`},children:[(0,n.jsx)(`span`,{style:{fontSize:18,fontWeight:500,color:Q.t1,background:`transparent`,padding:`2px 8px`,borderRadius:4,fontFamily:$,flexShrink:0,minWidth:64,textAlign:`center`},children:e.label}),e.cells.map((e,t)=>(0,n.jsx)(`span`,{style:{flex:1,fontSize:18,fontWeight:500,color:Q.t2,fontFamily:$},children:e},t))]},t))]})}function On({block:e}){if(!e)return null;switch(e.type){case`stats`:return(0,n.jsx)(gn,{items:e.items});case`ranked`:return(0,n.jsx)(_n,{items:e.items});case`chips`:return(0,n.jsx)(vn,{items:e.items});case`badges`:return(0,n.jsx)(bn,{items:e.items});case`dot-strip`:return(0,n.jsx)(xn,{min:e.min,max:e.max,unit:e.unit,dots:e.dots,chips:e.chips});case`proportion`:return(0,n.jsx)(Sn,{leftPct:e.leftPct,leftLabel:e.leftLabel,leftValue:e.leftValue,leftColor:e.leftColor,rightPct:e.rightPct,rightLabel:e.rightLabel,rightValue:e.rightValue,rightColor:e.rightColor,chips:e.chips});case`ring`:return(0,n.jsx)(Cn,{pct:e.pct,label:e.label,color:e.color,chips:e.chips});case`scorecard-rows`:return(0,n.jsx)(wn,{items:e.items});case`flags-list`:return(0,n.jsx)(En,{items:e.items});case`comparison-rows`:return(0,n.jsx)(Dn,{columns:e.columns,rows:e.rows});default:return null}}var kn=`'Satoshi Variable', 'DM Sans', sans-serif`,An={color:`#C2C2C2`,fontFamily:kn,fontSize:18,fontWeight:400,lineHeight:1.65};function jn({text:e}){return(0,n.jsxs)(`div`,{style:{padding:`8px 0px`,border:`transparent`,borderRadius:5,background:`transparent`},children:[(0,n.jsx)(`span`,{style:{fontSize:18,fontWeight:500,color:i.t1,fontFamily:kn,lineHeight:1.65,marginRight:8},children:`Takeaway`}),(0,n.jsx)(`span`,{style:{...An},children:e})]})}var Mn=`data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_3072_19126)'%3e%3cpath%20d='M14.375%208.125H18.125V4.375'%20stroke='%2369DFE9'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M14.7188%2015C13.736%2015.9274%2012.5017%2016.5446%2011.1701%2016.7745C9.83859%2017.0044%208.46881%2016.8368%207.23196%2016.2926C5.99511%2015.7485%204.94602%2014.852%204.21579%2013.715C3.48556%2012.5781%203.10656%2011.2511%203.12615%209.90004C3.14574%208.54893%203.56304%207.23355%204.32593%206.11825C5.08881%205.00295%206.16344%204.13719%207.41555%203.62914C8.66765%203.12109%2010.0417%202.99329%2011.366%203.26169C12.6904%203.5301%2013.9062%204.18281%2014.8617%205.13828L18.125%208.125'%20stroke='%2369DFE9'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_3072_19126'%3e%3crect%20width='20'%20height='20'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e`;function Nn(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``)}var Pn=56;function Fn({items:e,colorOffset:r=0,title:i,"data-testid":a}){let[o,s]=(0,t.useState)(void 0),[c,l]=(0,t.useState)(void 0),[u,d]=(0,t.useState)(null),[f,p]=(0,t.useState)(null),[m,h]=(0,t.useState)(null),[g,_]=(0,t.useState)(null),[v,y]=(0,t.useState)(null),[b,x]=(0,t.useState)(0),[S,C]=(0,t.useState)(0),w=(0,t.useRef)(null),T=(0,t.useRef)(null),E=(0,t.useRef)(null),D=(0,t.useRef)(null),O=(0,t.useRef)(null);(0,t.useEffect)(()=>{let e=w.current;if(!e)return;let t=t=>{let{centerClientY:n,centerClientX:r,sourceClientY:i}=t.detail,a=e.getBoundingClientRect(),o=t.target,s=o.getBoundingClientRect();T.current=o,E.current=n-s.top,D.current=r-s.left,O.current=i==null?null:i-s.top,h(n-a.top),_(r-a.left),y(i==null?null:i-a.top),x(a.height),C(a.width)};return e.addEventListener(`viz-item-click`,t),()=>e.removeEventListener(`viz-item-click`,t)},[]),(0,t.useLayoutEffect)(()=>{if(!u||T.current===null||E.current===null)return;let e=w.current;if(!e)return;let t=T.current.getBoundingClientRect(),n=e.getBoundingClientRect();h(t.top-n.top+E.current),D.current!==null&&_(t.left-n.left+D.current),O.current!==null&&y(t.top-n.top+O.current),x(n.height),C(n.width)},[u]);let k=(0,t.useCallback)((e,t,n,r)=>{if(!(r!=null&&(!Array.isArray(r)||r.length>0)))return;let i=Nn(t);s(t=>{let a=t===i?void 0:i;return l(a?n:void 0),a?(p(e),d(r)):(d(null),p(null)),a})},[]),A=(0,t.useCallback)(()=>{s(void 0),l(void 0),d(null),p(null),h(null),_(null),y(null),T.current=null,E.current=null,D.current=null,O.current=null},[]),j=f!==null&&m!==null,M=m??b/2,N=e.length-1,P=S>0?(S-N*Pn)/e.length:null,F=t=>j&&f===t&&e[t]?.type===Y.BALANCE_SCALE,I=f!==null&&e[f]?.type===Y.BALANCE_SCALE&&j&&g!==null&&v!==null&&P!==null;return(0,n.jsxs)(`div`,{className:`viz-group`,"data-testid":a,children:[i&&(0,n.jsx)(`div`,{className:`viz-group__title`,children:i}),(0,n.jsx)(`div`,{className:`viz-group__bar`,children:o?(0,n.jsxs)(`button`,{type:`button`,className:`viz-group__reset-btn`,onClick:A,"aria-label":`Reset selection`,children:[(0,n.jsx)(`img`,{src:Mn,alt:``,className:`viz-group__reset-icon`}),`Reset`]}):(0,n.jsx)(`span`,{className:`viz-group__hint`,children:`↑ Click a row to drill down`})}),(0,n.jsxs)(`div`,{ref:w,className:`viz-group__charts`,children:[e.flatMap((t,i)=>{let a=f===null?i===e.length-1:i!==f,s=F(i)&&g!==null&&v!==null&&P!==null,l=(0,n.jsxs)(`div`,{className:`viz-group__chart viz-group__chart--${t.type}${a?` viz-group__chart--listener`:``}`,children:[a&&(0,n.jsx)(`div`,{className:`viz-group__listener-label`,children:f===null?null:c}),(0,n.jsx)(sn,{config:t,colorOffset:r+i,onItemClick:f!==null&&a?void 0:(e,t,n)=>k(i,e,t,n),selectedId:o,listenerItems:i!==f&&u?u:void 0})]},i);if(i===e.length-1)return[l];let d=f!==null&&f>i,p=d?-.7:Pn+.7,m=g!==null&&P!==null?g-P:d?Pn+20:-20,h=`M ${s?d?Pn:0:m} ${M} H ${p}`;return[l,(0,n.jsx)(`div`,{className:`viz-group__connector${j?` viz-group__connector--active`:``}`,children:(0,n.jsxs)(`svg`,{className:`viz-group__connector-svg`,xmlns:`http://www.w3.org/2000/svg`,"aria-hidden":`true`,children:[!s&&(0,n.jsx)(`line`,{x1:m,y1:M-7,x2:m,y2:M+7,className:`viz-group__connector-tick`}),(0,n.jsx)(`path`,{d:h,className:`viz-group__connector-path`}),(0,n.jsx)(`circle`,{cx:p,cy:M,r:`4`,className:`viz-group__connector-dot`})]})},`connector-${i}`)]}),I&&(0,n.jsxs)(`svg`,{className:`viz-group__route-svg`,xmlns:`http://www.w3.org/2000/svg`,"aria-hidden":`true`,children:[(0,n.jsx)(`line`,{x1:g-7,y1:v,x2:g+7,y2:v,className:`viz-group__connector-tick`}),(0,n.jsx)(`path`,{d:`M ${g} ${v} L ${g} ${M} H ${P}`,className:`viz-group__connector-path`})]})]})]})}exports.AreaChart=F,exports.BarChart=R,exports.CHART_PALETTE=l,exports.ChartFrame=r,exports.DonutChart=pn,exports.GRAD=a,exports.KeyHighlights=On,exports.LineChart=Ie,exports.MiniBars=ze,exports.PALETTE=s,exports.PieChart=Je,exports.ProcessSankey=it,exports.RankingSankey=at,exports.SOLID=o,exports.SankeySvg=Xe,exports.SeriesChart=P,exports.Takeaway=jn,exports.Trend=St,exports.TrendChart=It,exports.VisualizationGroup=Fn,exports.VisualizationRenderer=sn,exports.cleanupVisualizationMounts=un,exports.hydrateVisualizationMounts=dn,exports.serializeVisualizationConfig=fn;
|
package/dist/index.js
CHANGED
|
@@ -595,7 +595,7 @@ var ne = [
|
|
|
595
595
|
function K(e, t = 1) {
|
|
596
596
|
let n = Math.abs(e), r = e < 0 ? "-" : "";
|
|
597
597
|
for (let e of ne) if (n >= e.value) return `${r}${(n / e.divisor).toFixed(t)}${e.suffix}`;
|
|
598
|
-
return `${r}${n.toFixed(
|
|
598
|
+
return t === 0 ? `${r}${Math.round(n)}` : `${r}${parseFloat(n.toFixed(t))}`;
|
|
599
599
|
}
|
|
600
600
|
//#endregion
|
|
601
601
|
//#region src/components/progressRaceChart/ProgressRaceChart.tsx
|
|
@@ -1386,7 +1386,7 @@ function Xe({ total: e = 0, totalLabel: r, items: o = [], dataByEntity: l, onIte
|
|
|
1386
1386
|
let S = 40 * a, D = t.createRadialGradient(60, n, 0, 60, n, S);
|
|
1387
1387
|
if (D.addColorStop(0, y(m, .02 * a)), D.addColorStop(.55, y(m, .02 * a)), D.addColorStop(1, y(m, .15 * a)), t.beginPath(), t.arc(60, n, S, 0, Math.PI * 2), t.fillStyle = D, t.fill(), t.beginPath(), t.arc(60, n, S, 0, Math.PI * 2), t.strokeStyle = y(m, .8 * a), t.lineWidth = 1, t.stroke(), a > .4) {
|
|
1388
1388
|
t.globalAlpha = Math.min(1, (a - .4) / .4);
|
|
1389
|
-
let e = K(F
|
|
1389
|
+
let e = K(F);
|
|
1390
1390
|
t.font = "500 16px 'Satoshi Variable', 'DM Sans', sans-serif";
|
|
1391
1391
|
let r = e;
|
|
1392
1392
|
for (; t.measureText(r).width > 68 && r.length > 1;) r = r.slice(0, -1);
|
|
@@ -1394,7 +1394,7 @@ function Xe({ total: e = 0, totalLabel: r, items: o = [], dataByEntity: l, onIte
|
|
|
1394
1394
|
}
|
|
1395
1395
|
k(te.current, "__root__", 60, n, 40, {
|
|
1396
1396
|
label: R ?? "Total",
|
|
1397
|
-
value: K(F
|
|
1397
|
+
value: K(F),
|
|
1398
1398
|
sublabel: `${B.length} items`,
|
|
1399
1399
|
color: m
|
|
1400
1400
|
}), d = requestAnimationFrame(f);
|
|
@@ -3920,7 +3920,7 @@ function Vn({ items: e, colorOffset: i = 0, title: l, "data-testid": u }) {
|
|
|
3920
3920
|
}), /* @__PURE__ */ s(pn, {
|
|
3921
3921
|
config: t,
|
|
3922
3922
|
colorOffset: i + n,
|
|
3923
|
-
onItemClick: (e, t, r) => P(n, e, t, r),
|
|
3923
|
+
onItemClick: _ !== null && r ? void 0 : (e, t, r) => P(n, e, t, r),
|
|
3924
3924
|
selectedId: d,
|
|
3925
3925
|
listenerItems: n !== _ && h ? h : void 0
|
|
3926
3926
|
})]
|