@nice2dev/ui 1.3.6 → 1.3.8
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/CHANGELOG.md +54 -0
- package/dist/NiceCodeEditor-B5YtKZOe.js +1222 -0
- package/dist/NiceCodeEditor-D0QZW88r.cjs +268 -0
- package/dist/NiceColorPicker-Bzvei7D6.cjs +1 -0
- package/dist/NiceColorPicker-DzzJhSXT.js +552 -0
- package/dist/NiceDataGrid-BSaBBoNr.js +2267 -0
- package/dist/NiceDataGrid-C_E6zIGS.cjs +10 -0
- package/dist/NiceForm-D2P6XuaT.cjs +1 -0
- package/dist/NiceForm-_kaB4Ikt.js +5017 -0
- package/dist/NiceHtmlEditor-CBCJdjmy.cjs +10 -0
- package/dist/NiceHtmlEditor-DfkdSxL3.js +901 -0
- package/dist/NiceLoginForm-BFvbroGJ.js +820 -0
- package/dist/NiceLoginForm-FGf32sro.cjs +1 -0
- package/dist/NiceMention-CctjYriS.cjs +430 -0
- package/dist/NiceMention-umOghLCf.js +11653 -0
- package/dist/NiceModal-BRVzjuUN.cjs +1 -0
- package/dist/NiceModal-CU9FqzIH.js +83 -0
- package/dist/NiceModuleLifecyclePanel-DQT_forg.js +7404 -0
- package/dist/NiceModuleLifecyclePanel-DtOlPChV.cjs +1 -0
- package/dist/NicePagination-CK4ZJgu4.cjs +1 -0
- package/dist/NicePagination-flHgG-FT.js +200 -0
- package/dist/NicePivotGrid-99ZeQ9j6.js +1180 -0
- package/dist/NicePivotGrid-CpsBxUhq.cjs +152 -0
- package/dist/NiceSavedQueryPanel-Br1LQR7u.js +5311 -0
- package/dist/NiceSavedQueryPanel-C4SU6W22.cjs +586 -0
- package/dist/NiceScheduler-CeYqH0Ux.cjs +5 -0
- package/dist/NiceScheduler-yTpVRxfe.js +1710 -0
- package/dist/NiceSelect-C3NqDYwR.js +495 -0
- package/dist/NiceSelect-CTwSAb8G.cjs +1 -0
- package/dist/charts-B0tHOpJ7.cjs +768 -0
- package/dist/charts-C3u-VyJj.js +5019 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.mjs +1 -1
- package/dist/core-lazy-Bglo0hFt.cjs +1 -0
- package/dist/core-lazy-CRBgQkQl.js +351 -0
- package/dist/data.cjs +1 -1
- package/dist/data.mjs +3 -3
- package/dist/devops-Bzp3ZqZ3.cjs +18 -0
- package/dist/devops-fLElpPvD.js +9128 -0
- package/dist/devops.cjs +1 -1
- package/dist/devops.mjs +1 -1
- package/dist/editors.cjs +1 -1
- package/dist/editors.d.ts +5 -0
- package/dist/editors.mjs +7 -7
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.mjs +3 -3
- package/dist/index.cjs +251 -251
- package/dist/index.d.ts +76 -9
- package/dist/index.mjs +15550 -15248
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.mjs +18 -18
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.d.ts +42 -3
- package/dist/navigation.mjs +2 -2
- package/dist/no-code-Bt7SWzsN.js +8318 -0
- package/dist/no-code-DnT061qn.cjs +331 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.mjs +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,768 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),de=require("@nice2dev/ui-core"),c=require("react"),Ye=require("@nice2dev/i18n"),Fe=[],$e=["var(--nice-color-primary, #3b82f6)","var(--nice-color-error, #ef4444)","var(--nice-color-success, #22c55e)","var(--nice-color-warning, #f59e0b)","var(--nice-color-accent, #8b5cf6)","var(--nice-color-accent-pink, #ec4899)","var(--nice-color-info, #06b6d4)","var(--nice-success, #84cc16)"],Ae=({series:t=Fe,categories:s,width:l=600,height:r=400,title:i,showLegend:v=!0,showGrid:m=!0,axisLabels:C=!0,yAxisLabel:D,xAxisLabel:E,stacked:z,animated:p,zoomable:O,crosshair:$,annotations:L,legendInteractive:T,onDataPointClick:N,exportable:o,className:u,style:_,testId:A,"data-testid":I})=>{const{t:w}=de.useNiceTranslation(),b=c.useRef(null),[R,a]=c.useState(new Set),[j,d]=c.useState(null),[S,x]=c.useState(null),[P,k]=c.useState(!1),H=c.useRef(null),ee=c.useMemo(()=>t.filter(y=>!R.has(y.name)),[t,R]),Y=c.useCallback(y=>{T&&a(Q=>{const n=new Set(Q);return n.has(y)?n.delete(y):n.add(y),n})},[T]),q={top:i?40:20,right:20,bottom:E?60:40,left:D?60:50},Z=l-q.left-q.right,U=r-q.top-q.bottom,g=ee[0]?.data.length??t[0]?.data.length??0,V=S?.start??0,te=S?.end??g,ce=te-V,ae=c.useMemo(()=>ee.map(y=>({...y,data:y.data.slice(V,te)})),[ee,V,te]),he=c.useMemo(()=>s?.slice(V,te),[s,V,te]),{minY:F,maxY:h,yTicks:B}=c.useMemo(()=>{let y;if(z){y=[];for(let ie=0;ie<ce;ie++)y.push(ae.reduce((le,me)=>le+(me.data[ie]||0),0))}else y=ae.flatMap(ie=>ie.data);y.length===0&&(y=[0]);const Q=Math.min(0,...y),n=Math.max(0,...y),W=n-Q||1,K=Math.pow(10,Math.floor(Math.log10(W)))||1,M=Math.floor(Q/K)*K;let J=Math.ceil(n/K)*K;const re=[];for(let ie=M;ie<=J;ie+=K)re.push(Math.round(ie*1e6)/1e6);return re.length<2&&(J=M+K,re.push(Math.round(J*1e6)/1e6)),{minY:M,maxY:J,yTicks:re}},[ae,ce,z]),f=y=>U-(y-F)/(h-F||1)*U,X=y=>(y+.5)/ce*Z,fe=y=>(y.type||"bar")==="bar",G=new Map(ae.filter(fe).map((y,Q)=>[y,Q])),se=ce>0?Z/ce/(z?1.5:Math.max(G.size,1)*1.5):20,ue=se*.9,ve=c.useCallback(y=>{if(!O)return;y.preventDefault();const Q=S??{start:0,end:g},n=Q.end-Q.start,W=(Q.start+Q.end)/2,K=y.deltaY>0?1.2:.8,M=Math.max(2,Math.min(g,Math.round(n*K))),J=Math.max(0,Math.round(W-M/2)),re=Math.min(g,J+M);x({start:J,end:re})},[O,S,g]),Ne=c.useCallback(y=>{O&&(k(!0),H.current={x:y.clientX,range:S??{start:0,end:g}})},[O,S,g]),ye=c.useCallback(y=>{const Q=b.current?.getBoundingClientRect();if(Q&&d({x:y.clientX-Q.left-q.left,y:y.clientY-Q.top-q.top}),P&&H.current&&O){const n=y.clientX-H.current.x,W=Z/ce,K=-Math.round(n/W),M=H.current.range,J=M.end-M.start;let re=M.start+K;re<0&&(re=0),re+J>g&&(re=g-J),x({start:re,end:re+J})}},[P,O,Z,ce,g,q.left,q.top]),Me=c.useCallback(()=>{k(!1),H.current=null},[]),we=c.useCallback(()=>{d(null),k(!1),H.current=null},[]),ne=c.useCallback(()=>{const y=b.current;if(!y)return;const Q=new XMLSerializer().serializeToString(y),n=document.createElement("canvas");n.width=l,n.height=r+(v?30:0);const W=n.getContext("2d");if(!W)return;const K=new Image;K.onload=()=>{W.fillStyle=de.resolveCssColor("var(--nice-bg-primary, #fff)",W.canvas),W.fillRect(0,0,n.width,n.height),W.drawImage(K,0,0);const M=document.createElement("a");M.download="chart.png",M.href=n.toDataURL("image/png"),M.click()},K.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(Q)},[l,r,v]),oe=r+(v?30:0),xe=ae.length>0&&ae.every(y=>y.type==="radar"),je=c.useMemo(()=>{if(!xe)return 1;const y=ae.flatMap(Q=>Q.data);return Math.max(1,...y)},[xe,ae]);if(xe){const y=l/2,Q=(r-q.top-q.bottom)/2+q.top,n=Math.min(Z,r-q.top-q.bottom)/2-10,W=he?.length??ae[0]?.data.length??0,K=re=>re/W*Math.PI*2-Math.PI/2,M=(re,ie)=>{const le=ie/je*n;return[y+Math.cos(K(re))*le,Q+Math.sin(K(re))*le]},J=4;return e.jsx("div",{className:`nice-chart nice-chart--radar ${u||""}`,style:_,"data-testid":I??A,children:e.jsxs("svg",{ref:b,viewBox:`0 0 ${l} ${oe}`,preserveAspectRatio:"xMidYMid meet",width:"100%",height:"100%",className:"nice-chart__svg",style:{display:"block",maxWidth:"100%",maxHeight:"100%"},children:[i&&e.jsx("text",{x:l/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:i}),m&&Array.from({length:J},(re,ie)=>{const le=(ie+1)/J*n,me=[];for(let ge=0;ge<W;ge++)me.push(`${y+Math.cos(K(ge))*le},${Q+Math.sin(K(ge))*le}`);return e.jsx("polygon",{points:me.join(" "),fill:"none",className:"nice-chart__grid-line"},ie)}),Array.from({length:W},(re,ie)=>{const[le,me]=M(ie,je);return e.jsx("line",{x1:y,y1:Q,x2:le,y2:me,className:"nice-chart__grid-line"},ie)}),C&&he?.map((re,ie)=>{const[le,me]=M(ie,je*1.12);return e.jsx("text",{x:le,y:me,textAnchor:"middle",dominantBaseline:"middle",className:"nice-chart__axis-label",children:re},ie)}),ae.map((re,ie)=>{const le=re.color||$e[ie%$e.length],me=re.data.map((ge,ke)=>M(ke,ge).join(",")).join(" ");return e.jsxs("g",{className:p?"nice-chart__series nice-chart__series--radar nice-chart__series--anim":"nice-chart__series nice-chart__series--radar",children:[e.jsx("polygon",{points:me,fill:le,fillOpacity:.2,stroke:le,strokeWidth:2}),re.data.map((ge,ke)=>{const[Se,Ie]=M(ke,ge);return e.jsx("circle",{cx:Se,cy:Ie,r:3,fill:le,children:e.jsx("title",{children:`${re.name}: ${ge}`})},ke)})]},re.name)}),v&&e.jsx("g",{transform:`translate(${q.left}, ${r})`,children:t.map((re,ie)=>{const le=ie*120,me=R.has(re.name);return e.jsxs("g",{transform:`translate(${le}, 10)`,style:T?{cursor:"pointer"}:void 0,onClick:()=>Y(re.name),opacity:me?.35:1,children:[e.jsx("rect",{width:12,height:12,rx:2,fill:re.color||$e[ie%$e.length]}),e.jsx("text",{x:16,y:10,className:"nice-chart__legend-text",children:re.name})]},re.name)})})]})})}return e.jsxs("div",{className:`nice-chart ${u||""}`,style:_,"data-testid":I??A,children:[o&&e.jsx("button",{type:"button",className:"nice-chart__export-btn",onClick:ne,title:w("chart.exportPng","Export PNG"),"aria-label":w("chart.exportPng","Export PNG"),children:e.jsx(de.NiceIcon,{name:"camera",size:16})}),e.jsxs("svg",{ref:b,viewBox:`0 0 ${l} ${oe}`,preserveAspectRatio:"xMidYMid meet",width:"100%",height:"100%",style:{display:"block",maxWidth:"100%",maxHeight:"100%"},className:"nice-chart__svg",onWheel:ve,onMouseDown:Ne,onMouseMove:ye,onMouseUp:Me,onMouseLeave:we,children:[e.jsxs("g",{transform:`translate(${q.left},${q.top})`,children:[i&&e.jsx("text",{x:Z/2,y:-10,textAnchor:"middle",className:"nice-chart__title",children:i}),m&&B.map(y=>e.jsx("line",{x1:0,y1:f(y),x2:Z,y2:f(y),className:"nice-chart__grid-line"},`grid-${y}`)),C&&B.map(y=>e.jsx("text",{x:-8,y:f(y)+4,textAnchor:"end",className:"nice-chart__axis-label",children:y},`ylabel-${y}`)),C&&he&&he.map((y,Q)=>e.jsx("text",{x:X(Q),y:U+20,textAnchor:"middle",className:"nice-chart__axis-label",children:y},Q)),D&&e.jsx("text",{x:-q.left+14,y:U/2,textAnchor:"middle",transform:`rotate(-90, -${q.left-14}, ${U/2})`,className:"nice-chart__axis-title",children:D}),E&&e.jsx("text",{x:Z/2,y:U+45,textAnchor:"middle",className:"nice-chart__axis-title",children:E}),e.jsx("line",{x1:0,y1:0,x2:0,y2:U,className:"nice-chart__axis"}),e.jsx("line",{x1:0,y1:U,x2:Z,y2:U,className:"nice-chart__axis"}),L?.map((y,Q)=>{if(y.type==="line"){const n=f(y.value);return e.jsxs("g",{children:[e.jsx("line",{x1:0,y1:n,x2:Z,y2:n,stroke:y.color||"var(--nice-color-error, #ef4444)",strokeWidth:1.5,strokeDasharray:y.dash||"6,3"}),y.label&&e.jsx("text",{x:Z+4,y:n+4,className:"nice-chart__annotation-label",fill:y.color||"var(--nice-color-error, #ef4444)",children:y.label})]},Q)}return e.jsx("text",{x:X(y.value),y:-4,textAnchor:"middle",className:"nice-chart__annotation-label",fill:y.color||"var(--nice-text-muted, #6b7280)",children:y.label},Q)}),$&&j&&j.x>=0&&j.x<=Z&&j.y>=0&&j.y<=U&&e.jsxs(e.Fragment,{children:[e.jsx("line",{x1:j.x,y1:0,x2:j.x,y2:U,stroke:"var(--nice-text-muted, #9ca3af)",strokeWidth:1,strokeDasharray:"4,2"}),e.jsx("line",{x1:0,y1:j.y,x2:Z,y2:j.y,stroke:"var(--nice-text-muted, #9ca3af)",strokeWidth:1,strokeDasharray:"4,2"})]}),ae.map((y,Q)=>{const n=y.color||$e[Q%$e.length],W=y.type||"bar";if(W==="bar")return e.jsx("g",{className:p?"nice-chart__series nice-chart__series--bar nice-chart__series--anim":"nice-chart__series nice-chart__series--bar",children:y.data.map((M,J)=>{let re,ie;if(z){const ge=ae.slice(0,Q).filter(fe).reduce((ke,Se)=>ke+(Se.data[J]||0),0);re=f(ge+M),ie=f(ge)-re}else re=f(Math.max(0,M)),ie=Math.abs(f(M)-f(0));const le=G.get(y)??0,me=z?X(J)-ue/2:X(J)-G.size*se/2+le*se+(se-ue)/2;return e.jsx("rect",{x:me,y:re,width:ue,height:Math.max(0,ie),fill:n,rx:2,style:{transformOrigin:`${me+ue/2}px ${f(0)}px`,...N?{cursor:"pointer"}:{}},onClick:N?()=>N(y.name,V+J,M):void 0,children:e.jsx("title",{children:`${y.name}: ${M}`})},J)})},y.name);if(W==="scatter")return e.jsx("g",{className:p?"nice-chart__series nice-chart__series--scatter nice-chart__series--anim":"nice-chart__series nice-chart__series--scatter",children:y.data.map((M,J)=>e.jsx("circle",{cx:X(J),cy:f(M),r:5,fill:n,fillOpacity:.7,stroke:n,strokeWidth:1.5,style:N?{cursor:"pointer"}:void 0,onClick:N?()=>N(y.name,V+J,M):void 0,children:e.jsx("title",{children:`${y.name}: ${M}`})},J))},y.name);const K=y.data.map((M,J)=>`${X(J)},${f(M)}`);return e.jsxs("g",{className:p?`nice-chart__series nice-chart__series--${W} nice-chart__series--anim`:`nice-chart__series nice-chart__series--${W}`,children:[W==="area"&&ce>0&&e.jsx("polygon",{points:`${X(0)},${f(0)} ${K.join(" ")} ${X(ce-1)},${f(0)}`,fill:n,opacity:.15}),e.jsx("polyline",{points:K.join(" "),fill:"none",stroke:n,strokeWidth:2,className:p?"nice-chart__line":void 0}),y.data.map((M,J)=>e.jsx("circle",{cx:X(J),cy:f(M),r:3,fill:n,style:N?{cursor:"pointer"}:void 0,onClick:N?()=>N(y.name,V+J,M):void 0,children:e.jsx("title",{children:`${y.name}: ${M}`})},J))]},y.name)})]}),v&&e.jsx("g",{transform:`translate(${q.left}, ${r})`,children:t.map((y,Q)=>{const n=Q*120,W=R.has(y.name);return e.jsxs("g",{transform:`translate(${n}, 10)`,style:T?{cursor:"pointer"}:void 0,onClick:()=>Y(y.name),opacity:W?.35:1,children:[e.jsx("rect",{width:12,height:12,rx:2,fill:y.color||$e[Q%$e.length]}),e.jsx("text",{x:16,y:10,className:"nice-chart__legend-text",style:W?{textDecoration:"line-through"}:void 0,children:y.name})]},y.name)})})]})]})},He=Object.freeze(Object.defineProperty({__proto__:null,NiceChart:Ae},Symbol.toStringTag,{value:"Module"})),Ve=({value:t,min:s=0,max:l=100,width:r=200,height:i=200,startAngle:v=225,endAngle:m=-45,color:C="var(--nice-color-primary, #3b82f6)",trackColor:D,label:E,formatValue:z,ranges:p,className:O,style:$,testId:L,"data-testid":T})=>{const N=r/2,o=i/2,u=Math.min(N,o)-20,_=Math.max(0,Math.min(1,(t-s)/(l-s||1))),A=d=>d*Math.PI/180,I=(v-m+360)%360||360,w=d=>({x:N+u*Math.cos(A(d)),y:o-u*Math.sin(A(d))}),b=(d,S)=>{const x=w(d),P=w(S),H=(d-S+360)%360>180?1:0;return`M${x.x},${x.y} A${u},${u} 0 ${H},1 ${P.x},${P.y}`},R=v-_*I,a=w(R);let j=C;if(p){for(const d of p)if(t>=d.start&&t<=d.end){j=d.color;break}}return e.jsx("div",{className:`nice-gauge nice-gauge--circular ${O||""}`,style:$,"data-testid":T??L,children:e.jsxs("svg",{width:r,height:i,children:[e.jsx("path",{d:b(v,m),fill:"none",stroke:D||"var(--nice-border-color, #e2e8f0)",strokeWidth:12,strokeLinecap:"round"}),_>0&&e.jsx("path",{d:b(v,R),fill:"none",stroke:j,strokeWidth:12,strokeLinecap:"round"}),e.jsx("line",{x1:N,y1:o,x2:a.x,y2:a.y,stroke:"var(--nice-text-primary, #333)",strokeWidth:2,strokeLinecap:"round"}),e.jsx("circle",{cx:N,cy:o,r:4,fill:"var(--nice-text-primary, #333)"}),e.jsx("text",{x:N,y:o+u*.6,textAnchor:"middle",className:"nice-gauge__value",children:z?z(t):t}),E&&e.jsx("text",{x:N,y:o+u*.95,textAnchor:"middle",className:"nice-gauge__label",children:E})]})})},Xe=({value:t,min:s=0,max:l=100,width:r=300,height:i=60,orientation:v="horizontal",color:m="var(--nice-color-primary, #3b82f6)",label:C,formatValue:D,ranges:E,showTicks:z=!0,tickCount:p=5,className:O,style:$,testId:L,"data-testid":T})=>{const N=v==="horizontal",o=N?r-40:i-40,u=Math.max(0,Math.min(1,(t-s)/(l-s||1))),_=10;let A=m;if(E){for(const w of E)if(t>=w.start&&t<=w.end){A=w.color;break}}const I=Array.from({length:p},(w,b)=>s+(l-s)*(b/(p-1)));return N?e.jsx("div",{className:`nice-gauge nice-gauge--linear ${O||""}`,style:$,"data-testid":T??L,children:e.jsxs("svg",{width:r,height:i,children:[e.jsx("text",{x:20+o*u,y:14,textAnchor:"middle",className:"nice-gauge__value",style:{fontSize:12},children:D?D(t):t}),e.jsx("rect",{x:20,y:i/2-_/2,width:o,height:_,rx:5,fill:"var(--nice-border-color, #e2e8f0)"}),e.jsx("rect",{x:20,y:i/2-_/2,width:o*u,height:_,rx:5,fill:A}),e.jsx("polygon",{points:`${20+o*u},${i/2-_/2-2} ${20+o*u-5},${i/2-_/2-8} ${20+o*u+5},${i/2-_/2-8}`,fill:"var(--nice-text-primary, #333)"}),z&&I.map((w,b)=>{const R=20+(w-s)/(l-s)*o;return e.jsx("text",{x:R,y:i/2+_/2+12,textAnchor:"middle",className:"nice-gauge__tick",children:w},b)}),C&&e.jsx("text",{x:r/2,y:i-2,textAnchor:"middle",className:"nice-gauge__label",children:C})]})}):e.jsx("div",{className:`nice-gauge nice-gauge--linear nice-gauge--vertical ${O||""}`,style:$,"data-testid":T??L,children:e.jsxs("svg",{width:r,height:i,children:[e.jsx("rect",{x:r/2-_/2,y:20,width:_,height:o,rx:5,fill:"var(--nice-border-color, #e2e8f0)"}),e.jsx("rect",{x:r/2-_/2,y:20+o*(1-u),width:_,height:o*u,rx:5,fill:A}),e.jsx("text",{x:r/2,y:14,textAnchor:"middle",className:"nice-gauge__value",children:D?D(t):t}),C&&e.jsx("text",{x:r/2,y:i-4,textAnchor:"middle",className:"nice-gauge__label",children:C})]})})},_e=["#3b82f6","#ef4444","#22c55e","#f59e0b","#8b5cf6","#ec4899","#06b6d4","#84cc16"],Ge=[],ze=20,Ze=10,Ue=32,Ke=({items:t=Ge,min:s=0,max:l=100,width:r=300,height:i=300,startAngle:v=225,endAngle:m=-45,formatValue:C,title:D,className:E,style:z,testId:p,"data-testid":O})=>{const $=k=>k*Math.PI/180,L=(v-m+360)%360||360,T=[$(v),$(m)],N=k=>(v-k+720)%360<=L,o=N(90)?1:Math.max(0,...T.map(k=>Math.sin(k))),u=N(270)?1:Math.max(0,...T.map(k=>-Math.sin(k))),_=N(180)?1:Math.max(0,...T.map(k=>-Math.cos(k))),A=N(0)?1:Math.max(0,...T.map(k=>Math.cos(k))),I=D?Ue:0,w=Ze+ze/2,b=r-2*w,R=i-I-2*w,a=Math.max(0,Math.min(b/(_+A||1),R/(o+u||1))),j=w+_*a+(b-(_+A)*a)/2,d=I+w+o*a+(R-(o+u)*a)/2,S=Math.min(ze,a/(t.length+1)),x=4,P=(k,H,ee)=>{const Y=j+k*Math.cos($(H)),q=d-k*Math.sin($(H)),Z=j+k*Math.cos($(ee)),U=d-k*Math.sin($(ee)),g=(H-ee+360)%360;return`M${Y},${q} A${k},${k} 0 ${g>180?1:0},1 ${Z},${U}`};return e.jsx("div",{className:`nice-bargauge ${E||""}`,style:z,"data-testid":O??p,children:e.jsxs("svg",{width:r,height:i,children:[D&&e.jsx("text",{x:r/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:D}),t.map((k,H)=>{const ee=a-H*(S+x),Y=Math.max(0,Math.min(1,(k.value-s)/(l-s||1))),q=v-Y*L,Z=k.color||_e[H%_e.length];return e.jsxs("g",{children:[e.jsx("path",{d:P(ee,v,m),fill:"none",stroke:"var(--nice-border-color, #e2e8f0)",strokeWidth:S,strokeLinecap:"round"}),Y>0&&e.jsx("path",{d:P(ee,v,q),fill:"none",stroke:Z,strokeWidth:S,strokeLinecap:"round"})]},H)}),e.jsx("g",{children:t.map((k,H)=>e.jsxs("text",{x:j,y:d-((t.length-1)/2-H)*16,textAnchor:"middle",dominantBaseline:"middle",className:"nice-gauge__value",style:{fontSize:12},children:[k.label?`${k.label}: `:"",C?C(k.value):k.value]},H))})]})})},qe={sm:{width:160,height:22,fontSize:11},md:{width:220,height:32,fontSize:12},lg:{width:320,height:44,fontSize:14}},Je=({value:t,target:s,min:l=0,max:r=100,width:i,height:v,color:m="var(--nice-color-primary, #3b82f6)",targetColor:C="var(--nice-color-error, #ef4444)",size:D="md",label:E,labelPlacement:z="top",showValue:p=!1,showTarget:O=!1,formatValue:$=A=>String(A),state:L="normal",errorMessage:T,className:N,style:o,testId:u,"data-testid":_})=>{const{t:A}=de.useNiceTranslation(),I=qe[D],w=i??I.width,b=v??I.height,R=I.fontSize,a=4,j=w-a*2,d=O&&s!=null?R+4:a,S=O&&s!=null?b+(d-a):b,x=S-d-a,P=Math.max(0,Math.min(1,(t-l)/(r-l||1))),k=s!=null?Math.max(0,Math.min(1,(s-l)/(r-l||1))):null,H=()=>L==="error"?e.jsx("div",{role:"alert",style:{width:w,height:S,display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed var(--nice-color-error, #ef4444)",borderRadius:4,color:"var(--nice-color-error, #ef4444)",fontSize:R,padding:"0 8px",boxSizing:"border-box"},children:T??A("bullet.error","Error")}):L==="loading"?e.jsx("div",{role:"status","aria-label":A("bullet.loading","Loading"),className:"nice-bullet__skeleton",style:{width:w,height:S,borderRadius:4,background:"linear-gradient(90deg, var(--nice-bg-tertiary, #e5e7eb) 25%, var(--nice-bg-secondary, #f3f4f6) 50%, var(--nice-bg-tertiary, #e5e7eb) 75%)",backgroundSize:"200% 100%",animation:"nice-bullet-shimmer 1.4s linear infinite"}}):e.jsxs("svg",{width:w,height:S,role:"img","aria-label":typeof E=="string"?E:void 0,children:[e.jsx("rect",{x:a,y:d,width:j,height:x,rx:3,fill:"var(--nice-border-color, #e2e8f0)"}),e.jsx("rect",{x:a,y:d+x*.2,width:j*P,height:x*.6,rx:2,fill:m}),k!=null&&e.jsx("line",{x1:a+j*k,y1:d+2,x2:a+j*k,y2:d+x-2,stroke:C,strokeWidth:2}),p&&e.jsx("text",{x:a+Math.max(j*P,4),y:d+x/2,dx:j*P>24?-4:4,textAnchor:j*P>24?"end":"start",dominantBaseline:"middle",fontSize:R,fill:j*P>24?"var(--nice-color-white, #ffffff)":"var(--nice-text-primary)",fontWeight:600,children:$(t)}),O&&k!=null&&e.jsx("text",{x:a+j*k,y:d-2,textAnchor:"middle",fontSize:R-1,fill:C,fontWeight:600,children:$(s)})]});if(z==="none"||!E)return e.jsxs("div",{className:`nice-bullet ${N||""}`,style:o,"data-testid":_??u,children:[H(),e.jsx("style",{children:Le})]});const ee=z==="top"||z==="bottom",Y=e.jsx("span",{className:"nice-bullet__label",style:{fontSize:R,fontWeight:600,color:"var(--nice-text-primary)",...ee?{marginBottom:z==="top"?4:0,marginTop:z==="bottom"?4:0}:{},...z==="left"?{marginRight:8}:{},...z==="right"?{marginLeft:8}:{}},children:E});return e.jsxs("div",{className:`nice-bullet nice-bullet--${z} ${N||""}`,style:{display:"inline-flex",flexDirection:ee?"column":"row",alignItems:ee?"flex-start":"center",...o},"data-testid":_??u,children:[(z==="top"||z==="left")&&Y,H(),(z==="bottom"||z==="right")&&Y,e.jsx("style",{children:Le})]})},Le=`
|
|
2
|
+
@keyframes nice-bullet-shimmer {
|
|
3
|
+
0% { background-position: 200% 0; }
|
|
4
|
+
100% { background-position: -200% 0; }
|
|
5
|
+
}
|
|
6
|
+
`,Qe=[],et=({data:t=Qe,width:s=400,height:l=400,innerRadius:r=0,title:i,showLegend:v=!0,showLabels:m=!0,className:C,style:D,testId:E,"data-testid":z})=>{const p=s/2,O=(l-(v?30:0))/2+(i?10:0),$=Math.min(p,O)-40,L=t.reduce((o,u)=>o+u.value,0);let T=-Math.PI/2;const N=t.map((o,u)=>{const _=o.value/(L||1)*Math.PI*2,A=T;T+=_;const I=T,w=(A+I)/2,b=p+$*Math.cos(A),R=O+$*Math.sin(A),a=p+$*Math.cos(I),j=O+$*Math.sin(I),d=_>Math.PI?1:0,S=o.color||_e[u%_e.length],x=_>=Math.PI*2-1e-9;let P;if(x){const Z=(U,g)=>`M${p-U},${O} A${U},${U} 0 1,${g} ${p+U},${O} A${U},${U} 0 1,${g} ${p-U},${O} Z`;P=r>0?`${Z($,1)} ${Z(r,0)}`:Z($,1)}else if(r>0){const Z=p+r*Math.cos(A),U=O+r*Math.sin(A),g=p+r*Math.cos(I),V=O+r*Math.sin(I);P=`M${b},${R} A${$},${$} 0 ${d},1 ${a},${j} L${g},${V} A${r},${r} 0 ${d},0 ${Z},${U} Z`}else P=`M${p},${O} L${b},${R} A${$},${$} 0 ${d},1 ${a},${j} Z`;const k=Math.min(Math.max(r,0),$),H=k>0?(k+$)/2:$*.65,ee=x?p:p+H*Math.cos(w),Y=x?O:O+H*Math.sin(w),q=L>0?Math.round(o.value/L*100):0;return{...o,path:P,labelX:ee,labelY:Y,pct:q,color:S}});return e.jsx("div",{className:`nice-piechart ${C||""}`,style:D,"data-testid":z??E,children:e.jsxs("svg",{viewBox:`0 0 ${s} ${l}`,preserveAspectRatio:"xMidYMid meet",width:"100%",height:"100%",style:{display:"block",maxWidth:"100%",maxHeight:"100%"},className:"nice-piechart__svg",children:[i&&e.jsx("text",{x:p,y:20,textAnchor:"middle",className:"nice-chart__title",children:i}),N.map((o,u)=>e.jsxs("g",{children:[e.jsx("path",{d:o.path,fill:o.color,stroke:"var(--nice-bg-primary, #fff)",strokeWidth:2,children:e.jsx("title",{children:`${o.label}: ${o.value} (${o.pct}%)`})}),m&&o.pct>=5&&e.jsxs("text",{x:o.labelX,y:o.labelY,textAnchor:"middle",dominantBaseline:"middle",className:"nice-piechart__label",children:[o.pct,"%"]})]},u)),v&&e.jsx("g",{transform:`translate(10, ${l-25})`,children:t.map((o,u)=>e.jsxs("g",{transform:`translate(${u*100}, 0)`,children:[e.jsx("rect",{width:10,height:10,rx:2,fill:o.color||_e[u%_e.length]}),e.jsx("text",{x:14,y:9,className:"nice-chart__legend-text",children:o.label})]},u))})]})})},tt=[],nt=({data:t=tt,width:s=400,height:l=300,inverted:r,showLabels:i=!0,showValues:v=!0,title:m,className:C,style:D,testId:E,"data-testid":z})=>{const p={top:m?30:10,bottom:10,x:40},O=s-p.x*2,$=l-p.top-p.bottom,L=r?[...t].reverse():t,T=Math.max(...L.map(o=>o.value),1),N=$/L.length;return e.jsx("div",{className:`nice-funnel ${C||""}`,style:D,"data-testid":z??E,children:e.jsxs("svg",{width:s,height:l,children:[m&&e.jsx("text",{x:s/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:m}),L.map((o,u)=>{const _=o.value/T*O,A=u<L.length-1?L[u+1].value/T*O:_*.3,I=p.top+u*N,w=I+N,b=s/2,R=`${b-_/2},${I} ${b+_/2},${I} ${b+A/2},${w} ${b-A/2},${w}`,a=o.color||_e[u%_e.length];return e.jsxs("g",{children:[e.jsx("polygon",{points:R,fill:a,stroke:"var(--nice-bg-primary, #fff)",strokeWidth:1,children:e.jsx("title",{children:`${o.label}: ${o.value}`})}),i&&e.jsx("text",{x:b,y:I+N/2-(v?4:0),textAnchor:"middle",dominantBaseline:"middle",className:"nice-funnel__label",children:o.label}),v&&e.jsx("text",{x:b,y:I+N/2+10,textAnchor:"middle",dominantBaseline:"middle",className:"nice-funnel__value",children:o.value})]},u)})]})})},rt=[];function at(t,s,l){const r=$=>{const L=$.replace("#","");return[parseInt(L.slice(0,2),16),parseInt(L.slice(2,4),16),parseInt(L.slice(4,6),16)]},[i,v,m]=r(t),[C,D,E]=r(s),z=Math.round(i+(C-i)*l),p=Math.round(v+(D-v)*l),O=Math.round(m+(E-m)*l);return`rgb(${z},${p},${O})`}const ct=Object.assign(c.forwardRef(({data:t=rt,xLabels:s,yLabels:l,colors:r=["var(--nice-primary-bg, #e0f2fe)","var(--nice-color-primary-active, #1d4ed8)"],onCellClick:i,cellSize:v=40,showValues:m=!0,className:C,style:D,id:E,testId:z,"data-testid":p},O)=>{const $=de.useControlId(E),{minVal:L,maxVal:T}=c.useMemo(()=>{let o=1/0,u=-1/0;for(const _ of t)for(const A of _)A<o&&(o=A),A>u&&(u=A);return{minVal:o,maxVal:u}},[t]),N=c.useCallback(o=>T===L?.5:(o-L)/(T-L),[L,T]);return e.jsx("div",{ref:O,id:$,className:`nice-heatmap ${C||""}`,style:D,"data-testid":p??z,children:e.jsxs("table",{className:"nice-heatmap__table",children:[s&&e.jsx("thead",{children:e.jsxs("tr",{children:[l&&e.jsx("th",{}),s.map((o,u)=>e.jsx("th",{className:"nice-heatmap__header",children:o},u))]})}),e.jsx("tbody",{children:t.map((o,u)=>e.jsxs("tr",{children:[l&&e.jsx("th",{className:"nice-heatmap__row-label",children:l[u]}),o.map((_,A)=>e.jsx("td",{className:"nice-heatmap__cell",style:{background:at(r[0],r[1],N(_)),width:v,height:v,textAlign:"center",color:N(_)>.6?"var(--nice-color-white, #fff)":"var(--nice-text-primary, #333)",cursor:i?"pointer":void 0},onClick:()=>i?.(u,A,_),title:String(_),children:m?_:""},A))]},u))})]})})}),{displayName:"NiceHeatMap"}),st=[],it=[],Pe=({nodes:t=st,links:s=it,width:l=600,height:r=400,nodeWidth:i=20,nodePadding:v=10,title:m,className:C,style:D,testId:E,"data-testid":z})=>{const p={top:m?40:20,bottom:20,left:20,right:20},O=l-p.left-p.right,$=r-p.top-p.bottom,L=new Set(s.map(d=>d.source)),T=new Set(s.map(d=>d.target)),N=t.filter(d=>L.has(d.id)&&!T.has(d.id)),o=t.filter(d=>T.has(d.id)),u=t.filter(d=>L.has(d.id)&&T.has(d.id)),_=[N,...u.length?[u]:[],o].filter(d=>d.length>0),A=_.length,I=new Map;t.forEach(d=>{const S=s.filter(P=>P.source===d.id).reduce((P,k)=>P+k.value,0),x=s.filter(P=>P.target===d.id).reduce((P,k)=>P+k.value,0);I.set(d.id,Math.max(S,x))});const w=_.map(d=>d.reduce((S,x)=>S+(I.get(x.id)||0),0)+(d.length-1)*v),b=Math.max(...w,1),R=new Map;_.forEach((d,S)=>{const x=p.left+S/(A-1||1)*(O-i);let P=0;d.forEach(k=>{const H=(I.get(k.id)||0)/b*$;R.set(k.id,{x,y:p.top+P,h:H}),P+=H+v})});const a=new Map,j=new Map;return t.forEach(d=>{a.set(d.id,0),j.set(d.id,0)}),e.jsx("div",{className:`nice-sankey ${C||""}`,style:D,"data-testid":z??E,children:e.jsxs("svg",{width:l,height:r,children:[m&&e.jsx("text",{x:l/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:m}),s.map((d,S)=>{const x=R.get(d.source),P=R.get(d.target);if(!x||!P)return null;const k=a.get(d.source)||0,H=j.get(d.target)||0,ee=d.value/b*$;a.set(d.source,k+ee),j.set(d.target,H+ee);const Y=x.x+i,q=x.y+k,Z=P.x,U=P.y+H,g=(Y+Z)/2,te=t.find(ce=>ce.id===d.source)?.color||_e[S%_e.length];return e.jsx("path",{d:`M${Y},${q} C${g},${q} ${g},${U} ${Z},${U} L${Z},${U+ee} C${g},${U+ee} ${g},${q+ee} ${Y},${q+ee} Z`,fill:te,fillOpacity:.3,stroke:te,strokeOpacity:.5,strokeWidth:.5,children:e.jsx("title",{children:`${d.source} → ${d.target}: ${d.value}`})},S)}),t.map((d,S)=>{const x=R.get(d.id);if(!x)return null;const P=d.color||_e[S%_e.length];return e.jsxs("g",{children:[e.jsx("rect",{x:x.x,y:x.y,width:i,height:Math.max(x.h,2),fill:P,rx:2}),e.jsx("text",{x:x.x<O/2?x.x+i+4:x.x-4,y:x.y+x.h/2,textAnchor:x.x<O/2?"start":"end",dominantBaseline:"middle",className:"nice-chart__legend-text",children:d.label})]},d.id)})]})})},ot=Object.freeze(Object.defineProperty({__proto__:null,NiceSankey:Pe},Symbol.toStringTag,{value:"Module"}));function lt(t,s){const l=t.reduce((E,z)=>E+z.value,0);if(l===0||t.length===0)return[];const r=[];let{x:i,y:v,w:m,h:C}=s;const D=[...t].sort((E,z)=>z.value-E.value);for(const E of D){const z=E.value/l;if(m>=C){const p=m*z;r.push({x:i,y:v,w:p,h:C,node:E}),i+=p,m-=p}else{const p=C*z;r.push({x:i,y:v,w:m,h:p,node:E}),v+=p,C-=p}}return r}const dt=["var(--nice-color-primary, #3b82f6)","var(--nice-color-success, #10b981)","var(--nice-color-warning, #f59e0b)","var(--nice-color-error, #ef4444)","var(--nice-color-accent, #8b5cf6)","var(--nice-color-info, #06b6d4)","var(--nice-color-accent-pink, #ec4899)","var(--nice-success, #84cc16)"],Oe=Object.assign(c.forwardRef(({data:t,width:s=600,height:l=400,onNodeClick:r,colors:i=dt,className:v,style:m,id:C,testId:D,"data-testid":E},z)=>{const p=de.useControlId(C),O=c.useMemo(()=>{const $=t.children??[t];return lt($,{x:0,y:0,w:s,h:l})},[t,s,l]);return e.jsx("div",{ref:z,id:p,className:`nice-treemap ${v||""}`,style:m,"data-testid":E??D,children:e.jsx("svg",{width:s,height:l,className:"nice-treemap__svg",children:O.map(($,L)=>e.jsxs("g",{onClick:()=>r?.($.node),style:{cursor:r?"pointer":void 0},children:[e.jsx("rect",{x:$.x,y:$.y,width:Math.max($.w-1,0),height:Math.max($.h-1,0),fill:$.node.color??i[L%i.length],rx:2}),$.w>40&&$.h>20&&e.jsx("text",{x:$.x+$.w/2,y:$.y+$.h/2,textAnchor:"middle",dominantBaseline:"central",fill:"var(--nice-color-white, #fff)",fontSize:Math.min(12,$.w/6),className:"nice-treemap__label",children:$.node.label})]},$.node.key))})})}),{displayName:"NiceTreeMap"}),ht=Object.freeze(Object.defineProperty({__proto__:null,NiceTreeMap:Oe},Symbol.toStringTag,{value:"Module"})),ut=[],Be=({regions:t=ut,width:s=600,height:l=400,viewBox:r="0 0 1000 600",colorRange:i=["#dbeafe","#1d4ed8"],maxValue:v,onRegionClick:m,selectedRegionId:C,title:D,showTooltip:E=!0,className:z,style:p,testId:O,"data-testid":$})=>{const L=v??Math.max(...t.map(N=>N.value??0),1),T=N=>{const o=d=>[parseInt(d.slice(1,3),16),parseInt(d.slice(3,5),16),parseInt(d.slice(5,7),16)],[u,_,A]=o(i[0]),[I,w,b]=o(i[1]),R=Math.round(u+(I-u)*N),a=Math.round(_+(w-_)*N),j=Math.round(A+(b-A)*N);return`rgb(${R},${a},${j})`};return e.jsxs("div",{className:`nice-vectormap ${z||""}`,style:p,"data-testid":$??O,children:[D&&e.jsx("div",{className:"nice-vectormap__title",children:D}),e.jsx("svg",{width:s,height:l,viewBox:r,children:t.map(N=>{const o=N.value!=null?Math.max(0,Math.min(1,N.value/L)):0,u=N.value!=null?T(o):"var(--nice-bg-tertiary, #e5e7eb)",_=N.id===C;return e.jsx("path",{d:N.path,fill:u,stroke:_?"var(--nice-color-primary, #3b82f6)":"var(--nice-border-color, #d1d5db)",strokeWidth:_?2:.5,cursor:m?"pointer":void 0,onClick:()=>m?.(N),children:E&&e.jsx("title",{children:`${N.name}${N.value!=null?`: ${N.value}`:""}`})},N.id)})})]})},ft=Object.freeze(Object.defineProperty({__proto__:null,NiceVectorMap:Be},Symbol.toStringTag,{value:"Module"})),xt=Object.assign(c.forwardRef(({data:t,renderNode:s,selectable:l,selectedKey:r,onSelect:i,direction:v="top-down",collapsible:m=!0,className:C,style:D,id:E,testId:z,"data-testid":p},O)=>{const{t:$}=de.useNiceTranslation(),L=de.useControlId(E),[T,N]=c.useState(new Set),o=c.useCallback(A=>{N(I=>{const w=new Set(I);return w.has(A)?w.delete(A):w.add(A),w})},[]),u=c.useCallback(A=>{l&&i?.(A)},[l,i]),_=c.useCallback(A=>{const I=T.has(A.key),w=A.children&&A.children.length>0;return e.jsxs("li",{className:"nice-org-chart__item",children:[e.jsxs("div",{tabIndex:l?0:void 0,onKeyDown:l?de.clickOnActivationKey:void 0,className:`nice-org-chart__node${r===A.key?" nice-org-chart__node--selected":""}`,onClick:()=>u(A.key),role:l?"button":void 0,children:[s?s(A):e.jsx("span",{children:A.label}),m&&w&&e.jsx("button",{type:"button",className:"nice-org-chart__toggle",onClick:b=>{b.stopPropagation(),o(A.key)},"aria-label":I?$("organizationChart.expand","Expand"):$("organizationChart.collapse","Collapse"),children:e.jsx(de.NiceIcon,{name:I?"plus":"minus",size:14})})]}),w&&!I&&e.jsx("ul",{className:"nice-org-chart__children",children:A.children.map(b=>_(b))})]},A.key)},[T,r,s,l,m,u,o,$]);return e.jsx("div",{ref:O,id:L,className:`nice-org-chart nice-org-chart--${v} ${C||""}`,style:D,"data-testid":p??z,children:e.jsx("ul",{className:"nice-org-chart__root",children:_(t)})})}),{displayName:"NiceOrganizationChart"}),mt=[],pt=Object.assign(c.forwardRef(({data:t=mt,type:s="candlestick",showVolume:l=!0,width:r=800,height:i=400,bullColor:v="var(--nice-color-success, #22c55e)",bearColor:m="var(--nice-color-error, #ef4444)",className:C,style:D,id:E,testId:z,"data-testid":p},O)=>{const $=de.useControlId(E),L={top:20,right:20,bottom:l?80:30,left:60},T=r-L.left-L.right,N=l?50:0,o=i-L.top-L.bottom-N,{minP:u,maxP:_,maxVol:A}=c.useMemo(()=>{if(t.length===0)return{minP:0,maxP:1,maxVol:0};let a=1/0,j=-1/0,d=0;for(const S of t)S.low<a&&(a=S.low),S.high>j&&(j=S.high),S.volume&&S.volume>d&&(d=S.volume);return{minP:a,maxP:j,maxVol:d}},[t]),I=Math.max(1,T/t.length*.7),w=a=>L.left+(a+.5)*(T/t.length),b=a=>L.top+o-(a-u)/(_-u||1)*o,R=a=>i-L.bottom-N+N*(1-a/(A||1));return e.jsx("div",{ref:O,id:$,className:`nice-stock-chart ${C||""}`,style:D,"data-testid":p??z,children:e.jsxs("svg",{width:r,height:i,className:"nice-stock-chart__svg",children:[[0,.25,.5,.75,1].map(a=>{const j=u+a*(_-u);return e.jsxs("g",{children:[e.jsx("line",{x1:L.left,x2:r-L.right,y1:b(j),y2:b(j),stroke:"var(--nice-border, #e5e7eb)",strokeDasharray:"2,2"}),t.length>0&&e.jsx("text",{x:L.left-4,y:b(j)+4,textAnchor:"end",fontSize:10,fill:"var(--nice-text-secondary, #888)",children:j.toFixed(2)})]},a)}),s==="line"?e.jsx("polyline",{points:t.map((a,j)=>`${w(j)},${b(a.close)}`).join(" "),fill:"none",stroke:v,strokeWidth:1.5}):t.map((a,j)=>{const d=a.close>=a.open,S=d?v:m,x=w(j);if(s==="ohlc")return e.jsxs("g",{children:[e.jsx("line",{x1:x,x2:x,y1:b(a.high),y2:b(a.low),stroke:S,strokeWidth:1}),e.jsx("line",{x1:x-I/2,x2:x,y1:b(a.open),y2:b(a.open),stroke:S,strokeWidth:1.5}),e.jsx("line",{x1:x,x2:x+I/2,y1:b(a.close),y2:b(a.close),stroke:S,strokeWidth:1.5})]},j);const P=b(Math.max(a.open,a.close)),k=b(Math.min(a.open,a.close));return e.jsxs("g",{children:[e.jsx("line",{x1:x,x2:x,y1:b(a.high),y2:b(a.low),stroke:S,strokeWidth:1}),e.jsx("rect",{x:x-I/2,y:P,width:I,height:Math.max(k-P,1),fill:d?"transparent":S,stroke:S,strokeWidth:1})]},j)}),l&&t.map((a,j)=>{if(!a.volume)return null;const d=a.close>=a.open;return e.jsx("rect",{x:w(j)-I/2,y:R(a.volume),width:I,height:i-L.bottom-R(a.volume),fill:d?v:m,opacity:.3},`v${j}`)}),t.map((a,j)=>j%Math.max(1,Math.floor(t.length/8))!==0?null:e.jsx("text",{x:w(j),y:i-L.bottom+N+14,textAnchor:"middle",fontSize:9,fill:"var(--nice-text-secondary, #888)",children:a.date},`l${j}`))]})})}),{displayName:"NiceStockChart"}),gt=[],vt=({data:t=gt,width:s=120,height:l=30,type:r="line",color:i="var(--nice-color-primary, #3b82f6)",showMinMax:v,showLastPoint:m=!0,className:C,style:D,testId:E,"data-testid":z})=>{if(t.length===0)return null;const p=2,O=Math.min(...t),$=Math.max(...t),L=$-O||1,T=s-p*2,N=l-p*2,o=b=>p+b/(t.length-1||1)*T,u=b=>p+N-(b-O)/L*N;if(r==="bar"){const b=Math.max(1,T/t.length-1);return e.jsx("svg",{width:s,height:l,className:`nice-sparkline ${C||""}`,style:D,"data-testid":z??E,children:t.map((R,a)=>e.jsx("rect",{x:p+a/t.length*T,y:u(R),width:b,height:N-(u(R)-p),fill:i,rx:1},a))})}const _=t.map((b,R)=>`${o(R)},${u(b)}`).join(" "),A=t.indexOf(O),I=t.indexOf($),w=t.length-1;return e.jsxs("svg",{width:s,height:l,className:`nice-sparkline ${C||""}`,style:D,"data-testid":z??E,children:[r==="area"&&e.jsx("polygon",{points:`${o(0)},${p+N} ${_} ${o(w)},${p+N}`,fill:i,opacity:.15}),e.jsx("polyline",{points:_,fill:"none",stroke:i,strokeWidth:1.5}),v&&e.jsx("circle",{cx:o(A),cy:u(O),r:2,fill:"var(--nice-danger, #ef4444)"}),v&&e.jsx("circle",{cx:o(I),cy:u($),r:2,fill:"var(--nice-success, #22c55e)"}),m&&e.jsx("circle",{cx:o(w),cy:u(t[w]),r:2,fill:i})]})},yt=[],bt=[],_t=({series:t=yt,categories:s=bt,width:l=400,height:r=400,maxValue:i,title:v,showLegend:m=!0,className:C,style:D,testId:E,"data-testid":z})=>{const p=l/2,O=(r-(m?30:0))/2+(v?10:0),$=Math.min(p,O)-60,L=s.length,T=i??Math.max(...t.flatMap(_=>_.data),1),N=Math.PI*2/L,o=5,u=(_,A)=>{const I=_*N-Math.PI/2,w=A/T*$;return{x:p+w*Math.cos(I),y:O+w*Math.sin(I)}};return e.jsx("div",{className:`nice-polarchart ${C||""}`,style:D,"data-testid":z??E,children:e.jsxs("svg",{width:l,height:r,className:"nice-polarchart__svg",children:[v&&e.jsx("text",{x:p,y:20,textAnchor:"middle",className:"nice-chart__title",children:v}),Array.from({length:o},(_,A)=>{const I=$*((A+1)/o);return e.jsx("circle",{cx:p,cy:O,r:I,fill:"none",stroke:"var(--nice-border-color, #ddd)",strokeWidth:.5},A)}),s.map((_,A)=>{const I=u(A,T),w=u(A,T*1.22),b=A*N-Math.PI/2,R=Math.cos(b),a=Math.sin(b),j=R>.2?"start":R<-.2?"end":"middle",d=a>.2?"hanging":a<-.2?"auto":"middle";return e.jsxs("g",{children:[e.jsx("line",{x1:p,y1:O,x2:I.x,y2:I.y,stroke:"var(--nice-border-color, #ddd)",strokeWidth:.5}),e.jsx("text",{x:w.x,y:w.y,textAnchor:j,dominantBaseline:d,className:"nice-chart__axis-label nice-chart__axis-label--polar",children:_})]},A)}),t.map((_,A)=>{const I=_.color||_e[A%_e.length],w=_.data.map((b,R)=>{const a=u(R,b);return`${a.x},${a.y}`}).join(" ");return e.jsxs("g",{children:[e.jsx("polygon",{points:w,fill:_.fill!==!1?I:"none",fillOpacity:.15,stroke:I,strokeWidth:2}),_.data.map((b,R)=>{const a=u(R,b);return e.jsx("circle",{cx:a.x,cy:a.y,r:3,fill:I,children:e.jsx("title",{children:`${_.name} - ${s[R]}: ${b}`})},R)})]},_.name)}),m&&e.jsx("g",{transform:`translate(10, ${r-25})`,children:t.map((_,A)=>e.jsxs("g",{transform:`translate(${A*100}, 0)`,children:[e.jsx("rect",{width:10,height:10,rx:2,fill:_.color||_e[A%_e.length]}),e.jsx("text",{x:14,y:9,className:"nice-chart__legend-text",children:_.name})]},A))})]})})},jt=({data:t,min:s,max:l,start:r,end:i,onChange:v,width:m=500,height:C=100,step:D=1,formatValue:E,chartColor:z="var(--nice-color-primary, #3b82f6)",className:p,style:O,testId:$,"data-testid":L})=>{const T={top:10,bottom:30,left:10,right:10},N=m-T.left-T.right,o=C-T.top-T.bottom,u=R=>T.left+(R-s)/(l-s||1)*N,_=R=>{const a=Math.max(0,Math.min(1,(R-T.left)/N)),j=s+a*(l-s);return Math.round(j/D)*D},A=(R,a)=>{a.preventDefault();const j=a.target.closest("svg");if(!j)return;const d=x=>{const P=j.getBoundingClientRect(),k=_(x.clientX-P.left);R==="start"?v(Math.min(k,i),i):v(r,Math.max(k,r))},S=()=>{document.removeEventListener("pointermove",d),document.removeEventListener("pointerup",S)};document.addEventListener("pointermove",d),document.addEventListener("pointerup",S)},I=t?Math.min(...t):0,b=(t?Math.max(...t):1)-I||1;return e.jsx("div",{className:`nice-rangeselector ${p||""}`,style:O,"data-testid":L??$,children:e.jsxs("svg",{width:m,height:C,children:[t&&t.length>1&&e.jsx("polygon",{points:`${T.left},${T.top+o} ${t.map((R,a)=>`${T.left+a/(t.length-1)*N},${T.top+o-(R-I)/b*o}`).join(" ")} ${T.left+N},${T.top+o}`,fill:z,opacity:.15}),e.jsx("rect",{x:u(r),y:T.top,width:u(i)-u(r),height:o,fill:z,opacity:.1}),e.jsx("rect",{x:T.left,y:T.top,width:u(r)-T.left,height:o,fill:"var(--nice-bg-secondary, #f5f5f5)",opacity:.6}),e.jsx("rect",{x:u(i),y:T.top,width:T.left+N-u(i),height:o,fill:"var(--nice-bg-secondary, #f5f5f5)",opacity:.6}),e.jsx("rect",{x:u(r)-4,y:T.top,width:8,height:o,fill:z,rx:2,cursor:"ew-resize",onPointerDown:R=>A("start",R)}),e.jsx("rect",{x:u(i)-4,y:T.top,width:8,height:o,fill:z,rx:2,cursor:"ew-resize",onPointerDown:R=>A("end",R)}),e.jsx("text",{x:u(r),y:T.top+o+18,textAnchor:"middle",className:"nice-chart__axis-label",children:E?E(r):r}),e.jsx("text",{x:u(i),y:T.top+o+18,textAnchor:"middle",className:"nice-chart__axis-label",children:E?E(i):i})]})})},Mt=`
|
|
7
|
+
.nice-forecast-chart {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
11
|
+
border: 1px solid var(--nice-border-color, #e5e7eb);
|
|
12
|
+
border-radius: var(--nice-radius-lg, 0.5rem);
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.nice-forecast-chart__header {
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
justify-content: space-between;
|
|
20
|
+
padding: 0.75rem 1rem;
|
|
21
|
+
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.nice-forecast-chart__title {
|
|
25
|
+
font-size: 1rem;
|
|
26
|
+
font-weight: 600;
|
|
27
|
+
color: var(--nice-text-primary);
|
|
28
|
+
margin: 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.nice-forecast-chart__actions {
|
|
32
|
+
display: flex;
|
|
33
|
+
gap: 0.5rem;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.nice-forecast-chart__btn {
|
|
37
|
+
display: inline-flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
justify-content: center;
|
|
40
|
+
width: 2rem;
|
|
41
|
+
height: 2rem;
|
|
42
|
+
font-size: 1rem;
|
|
43
|
+
border-radius: var(--nice-radius-md, 0.375rem);
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
transition: all 0.15s ease;
|
|
46
|
+
border: 1px solid var(--nice-border-color, #d1d5db);
|
|
47
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
48
|
+
color: var(--nice-text-secondary);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.nice-forecast-chart__btn:hover {
|
|
52
|
+
background: var(--nice-bg-hover, #f3f4f6);
|
|
53
|
+
color: var(--nice-text-primary);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.nice-forecast-chart__btn:disabled {
|
|
57
|
+
opacity: 0.5;
|
|
58
|
+
cursor: not-allowed;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.nice-forecast-chart__container {
|
|
62
|
+
position: relative;
|
|
63
|
+
width: 100%;
|
|
64
|
+
padding: 1rem;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.nice-forecast-chart__svg {
|
|
68
|
+
width: 100%;
|
|
69
|
+
overflow: visible;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.nice-forecast-chart__grid-line {
|
|
73
|
+
stroke: var(--nice-border-divider, #f3f4f6);
|
|
74
|
+
stroke-width: 1;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.nice-forecast-chart__axis-line {
|
|
78
|
+
stroke: var(--nice-border-color, #e5e7eb);
|
|
79
|
+
stroke-width: 1;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.nice-forecast-chart__axis-label {
|
|
83
|
+
font-size: 0.6875rem;
|
|
84
|
+
fill: var(--nice-text-secondary);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.nice-forecast-chart__axis-title {
|
|
88
|
+
font-size: 0.75rem;
|
|
89
|
+
font-weight: 500;
|
|
90
|
+
fill: var(--nice-text-primary);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.nice-forecast-chart__historical-line {
|
|
94
|
+
fill: none;
|
|
95
|
+
stroke-width: 2;
|
|
96
|
+
stroke-linecap: round;
|
|
97
|
+
stroke-linejoin: round;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.nice-forecast-chart__forecast-line {
|
|
101
|
+
fill: none;
|
|
102
|
+
stroke-width: 2;
|
|
103
|
+
stroke-linecap: round;
|
|
104
|
+
stroke-linejoin: round;
|
|
105
|
+
stroke-dasharray: 6, 4;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.nice-forecast-chart__confidence-band {
|
|
109
|
+
opacity: 0.2;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.nice-forecast-chart__forecast-region {
|
|
113
|
+
fill: var(--nice-bg-secondary, #f9fafb);
|
|
114
|
+
opacity: 0.5;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.nice-forecast-chart__point {
|
|
118
|
+
cursor: pointer;
|
|
119
|
+
transition: r 0.15s ease;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.nice-forecast-chart__point:hover {
|
|
123
|
+
r: 6;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.nice-forecast-chart__annotation-line {
|
|
127
|
+
stroke-dasharray: 4, 2;
|
|
128
|
+
stroke-width: 1;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.nice-forecast-chart__annotation-marker {
|
|
132
|
+
cursor: pointer;
|
|
133
|
+
transition: transform 0.15s ease;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.nice-forecast-chart__annotation-marker:hover {
|
|
137
|
+
transform: scale(1.2);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.nice-forecast-chart__reference-line {
|
|
141
|
+
stroke-width: 1;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.nice-forecast-chart__reference-label {
|
|
145
|
+
font-size: 0.625rem;
|
|
146
|
+
fill: var(--nice-text-secondary);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.nice-forecast-chart__cash-runway {
|
|
150
|
+
pointer-events: none;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.nice-forecast-chart__cash-runway-line {
|
|
154
|
+
stroke: var(--nice-danger, #ef4444);
|
|
155
|
+
stroke-width: 2;
|
|
156
|
+
stroke-dasharray: 8, 4;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.nice-forecast-chart__cash-runway-label-bg {
|
|
160
|
+
fill: var(--nice-danger, #ef4444);
|
|
161
|
+
rx: 4;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.nice-forecast-chart__cash-runway-label {
|
|
165
|
+
font-size: 0.6875rem;
|
|
166
|
+
font-weight: 600;
|
|
167
|
+
fill: var(--nice-bg, #FFFFFF);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.nice-forecast-chart__cash-runway-date {
|
|
171
|
+
font-size: 0.625rem;
|
|
172
|
+
fill: var(--nice-danger, #ef4444);
|
|
173
|
+
font-weight: 500;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.nice-forecast-chart__tooltip {
|
|
177
|
+
position: absolute;
|
|
178
|
+
pointer-events: none;
|
|
179
|
+
z-index: 100;
|
|
180
|
+
padding: 0.75rem;
|
|
181
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
182
|
+
border: 1px solid var(--nice-border-color, #e5e7eb);
|
|
183
|
+
border-radius: var(--nice-radius-lg, 0.5rem);
|
|
184
|
+
box-shadow: 0 4px 12px var(--nice-overlay-10, rgba(0, 0, 0, 0.1));
|
|
185
|
+
font-size: 0.8125rem;
|
|
186
|
+
max-width: 250px;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.nice-forecast-chart__tooltip-date {
|
|
190
|
+
font-weight: 600;
|
|
191
|
+
color: var(--nice-text-primary);
|
|
192
|
+
margin-bottom: 0.5rem;
|
|
193
|
+
padding-bottom: 0.5rem;
|
|
194
|
+
border-bottom: 1px solid var(--nice-border-divider, #f3f4f6);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.nice-forecast-chart__tooltip-item {
|
|
198
|
+
display: flex;
|
|
199
|
+
align-items: center;
|
|
200
|
+
gap: 0.5rem;
|
|
201
|
+
margin-bottom: 0.25rem;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.nice-forecast-chart__tooltip-color {
|
|
205
|
+
width: 10px;
|
|
206
|
+
height: 10px;
|
|
207
|
+
border-radius: var(--nice-radius-sm, 2px);
|
|
208
|
+
flex-shrink: 0;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.nice-forecast-chart__tooltip-label {
|
|
212
|
+
color: var(--nice-text-secondary);
|
|
213
|
+
flex: 1;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.nice-forecast-chart__tooltip-value {
|
|
217
|
+
font-weight: 600;
|
|
218
|
+
color: var(--nice-text-primary);
|
|
219
|
+
font-variant-numeric: tabular-nums;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.nice-forecast-chart__tooltip-confidence {
|
|
223
|
+
font-size: 0.75rem;
|
|
224
|
+
color: var(--nice-text-tertiary);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.nice-forecast-chart__legend {
|
|
228
|
+
display: flex;
|
|
229
|
+
flex-wrap: wrap;
|
|
230
|
+
gap: 1rem;
|
|
231
|
+
padding: 0.75rem 1rem;
|
|
232
|
+
border-top: 1px solid var(--nice-border-color, #e5e7eb);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.nice-forecast-chart__legend-item {
|
|
236
|
+
display: flex;
|
|
237
|
+
align-items: center;
|
|
238
|
+
gap: 0.375rem;
|
|
239
|
+
font-size: 0.8125rem;
|
|
240
|
+
color: var(--nice-text-secondary);
|
|
241
|
+
cursor: pointer;
|
|
242
|
+
user-select: none;
|
|
243
|
+
transition: opacity 0.15s ease;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.nice-forecast-chart__legend-item:hover {
|
|
247
|
+
color: var(--nice-text-primary);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.nice-forecast-chart__legend-item--hidden {
|
|
251
|
+
opacity: 0.4;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.nice-forecast-chart__legend-color {
|
|
255
|
+
width: 16px;
|
|
256
|
+
height: 3px;
|
|
257
|
+
border-radius: var(--nice-radius-xs, 1px);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.nice-forecast-chart__legend-color--dashed {
|
|
261
|
+
background: repeating-linear-gradient(
|
|
262
|
+
90deg,
|
|
263
|
+
currentColor,
|
|
264
|
+
currentColor 4px,
|
|
265
|
+
transparent 4px,
|
|
266
|
+
transparent 6px
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.nice-forecast-chart__empty {
|
|
271
|
+
display: flex;
|
|
272
|
+
align-items: center;
|
|
273
|
+
justify-content: center;
|
|
274
|
+
height: 300px;
|
|
275
|
+
color: var(--nice-text-secondary);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/* Dark mode */
|
|
279
|
+
.dark .nice-forecast-chart {
|
|
280
|
+
background: var(--nice-bg-primary-dark, #111827);
|
|
281
|
+
border-color: var(--nice-border-color-dark, #374151);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.dark .nice-forecast-chart__tooltip {
|
|
285
|
+
background: var(--nice-bg-secondary-dark, #1f2937);
|
|
286
|
+
border-color: var(--nice-border-color-dark, #374151);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.dark .nice-forecast-chart__forecast-region {
|
|
290
|
+
fill: var(--nice-bg-secondary-dark, #1f2937);
|
|
291
|
+
}
|
|
292
|
+
`,De=["var(--nice-color-primary, #3b82f6)","var(--nice-color-success, #10b981)","var(--nice-color-warning, #f59e0b)","var(--nice-color-error, #ef4444)","var(--nice-color-accent, #8b5cf6)","var(--nice-color-accent-pink, #ec4899)","var(--nice-color-info, #06b6d4)","var(--nice-warning, #f97316)"];function be(t){return t instanceof Date?t:new Date(t)}function Te(t,s="pl-PL"){return t.toLocaleDateString(s,{year:"numeric",month:"short",day:"numeric"})}function Ce(t,s="pl-PL"){return new Intl.NumberFormat(s,{minimumFractionDigits:0,maximumFractionDigits:2}).format(t)}const Nt={top:20,right:30,bottom:40,left:60},wt=c.forwardRef(function(s,l){const{t:r}=de.useNiceTranslation(),{scenarios:i,data:v,annotations:m=[],referenceLines:C=[],forecastStartDate:D,cashRunway:E,xAxis:z,yAxis:p,confidenceBands:O=[{level:95,color:"var(--nice-color-primary, #3b82f6)",opacity:.15}],tooltip:$,legend:L={enabled:!0,position:"bottom",interactive:!0},height:T=350,showForecastRegion:N=!0,lineWidth:o=2,showPoints:u=!1,pointRadius:_=4,enableZoom:A=!1,zoomEnabled:I,animationDuration:w=300,showLegend:b,responsive:R=!0,onPointClick:a,onAnnotationClick:j,onScenarioToggle:d,onViewportChange:S,size:x="medium",disabled:P=!1,labels:k={},locale:H="pl-PL",className:ee,style:Y,testId:q,"data-testid":Z}=s,U=i&&i.length>0?i:v?[{id:"default",name:"Series",data:v}]:[],g={...L,enabled:b??L.enabled},[V,te]=c.useState(()=>U.map((n,W)=>({...n,color:n.color??De[W%De.length],visible:n.visible!==!1}))),[ce,ae]=c.useState(null),[he,F]=c.useState({x:0,y:0}),h=c.useRef(null),B=c.useRef(null),f=Nt,[X,fe]=c.useState({width:600,height:typeof T=="number"?T:350});c.useEffect(()=>{if(!R||!h.current)return;const n=new ResizeObserver(W=>{for(const K of W)fe(M=>({width:K.contentRect.width,height:M.height}))});return n.observe(h.current),()=>n.disconnect()},[R]),c.useEffect(()=>{const n="nice-forecast-chart-styles";if(!document.getElementById(n)){const W=document.createElement("style");W.id=n,W.textContent=Mt,document.head.appendChild(W)}},[]);const{xScale:G,yScale:se,allDates:ue,minY:ve,maxY:Ne}=c.useMemo(()=>{const W=V.filter(pe=>pe.visible!==!1).flatMap(pe=>pe.data);if(W.length===0)return{xScale:()=>0,yScale:()=>0,allDates:[],minY:0,maxY:100};const K=W.map(pe=>be(pe.date).getTime()),M=Math.min(...K),J=Math.max(...K),re=W.flatMap(pe=>[pe.value,pe.forecast,pe.lowerBound,pe.upperBound]).filter(pe=>pe!=null),ie=p?.min??Math.min(...re)*.95,le=p?.max??Math.max(...re)*1.05,me=X.width-f.left-f.right,ge=X.height-f.top-f.bottom,ke=pe=>{const Re=typeof pe=="number"?pe:pe.getTime();return f.left+(Re-M)/(J-M)*me},Se=pe=>f.top+ge-(pe-ie)/(le-ie)*ge,Ie=[...new Set(K)].sort((pe,Re)=>pe-Re).map(pe=>new Date(pe));return{xScale:ke,yScale:Se,allDates:Ie,minY:ie,maxY:le}},[V,X,f,p]),ye=D?be(D):null,Me=c.useMemo(()=>{if(!E?.enabled)return null;const n=E.threshold??0,W=E.scenarioId?V.find(M=>M.id===E.scenarioId&&M.visible!==!1):V.find(M=>M.visible!==!1);if(!W)return null;const K=W.data.sort((M,J)=>be(M.date).getTime()-be(J.date).getTime());for(let M=1;M<K.length;M++){const J=K[M-1],re=K[M],ie=J.forecast??J.value,le=re.forecast??re.value;if(ie!=null&&le!=null&&ie>n&&le<=n){const me=(ie-n)/(ie-le),ge=be(J.date).getTime(),ke=be(re.date).getTime(),Se=ge+me*(ke-ge);return new Date(Se)}}return null},[E,V]),we=c.useCallback((n,W)=>{const K=n.filter(M=>M[W]!=null).map(M=>({x:G(be(M.date)),y:se(M[W])}));return K.length===0?"":`M ${K.map(M=>`${M.x},${M.y}`).join(" L ")}`},[G,se]),ne=c.useCallback(n=>{const W=n.filter(J=>J.lowerBound!=null&&J.upperBound!=null);if(W.length===0)return"";const K=W.map(J=>({x:G(be(J.date)),y:se(J.upperBound)})),M=W.map(J=>({x:G(be(J.date)),y:se(J.lowerBound)})).reverse();return`M ${K.map(J=>`${J.x},${J.y}`).join(" L ")} L ${M.map(J=>`${J.x},${J.y}`).join(" L ")} Z`},[G,se]),oe=c.useCallback(n=>{if(!B.current||$?.enabled===!1)return;const W=B.current.getBoundingClientRect(),K=n.clientX-W.left;n.clientY-W.top;let M=null,J=1/0;for(const re of ue){const ie=G(re),le=Math.abs(ie-K);le<J&&(J=le,M=re)}if(M&&J<50){const re=V.filter(le=>le.visible!==!1).map(le=>{const me=le.data.find(ge=>be(ge.date).getTime()===M.getTime());return{scenario:le,value:me?.value,forecast:me?.forecast,lowerBound:me?.lowerBound,upperBound:me?.upperBound}}),ie=m.filter(le=>Math.abs(be(le.date).getTime()-M.getTime())<864e5);ae({date:M,values:re,annotations:ie}),F({x:n.clientX-W.left+10,y:n.clientY-W.top-10})}else ae(null)},[G,ue,V,m,$]),xe=c.useCallback(n=>{if(!g.interactive)return;te(K=>K.map(M=>M.id===n?{...M,visible:!M.visible}:M));const W=V.find(K=>K.id===n);W&&d?.(n,!W.visible)},[g.interactive,V,d]);c.useImperativeHandle(l,()=>({getScenarios:()=>V,updateScenario:(n,W)=>{te(K=>K.map(M=>M.id===n?{...M,data:W}:M))},toggleScenario:xe,setZoomRange:()=>{},resetZoom:()=>{},exportImage:n=>{if(!B.current)return null;const W=B.current,M=new XMLSerializer().serializeToString(W);return`data:image/svg+xml;base64,${btoa(M)}`},getDataAtDate:n=>{const W=V.filter(K=>K.visible!==!1).map(K=>{const M=K.data.find(J=>be(J.date).getTime()===n.getTime());return{scenario:K,value:M?.value,forecast:M?.forecast,lowerBound:M?.lowerBound,upperBound:M?.upperBound}});return{date:n,values:W,annotations:m.filter(K=>be(K.date).getTime()===n.getTime())}}}),[V,m,xe]),X.width-f.left-f.right;const je=X.height-f.top-f.bottom,y=c.useMemo(()=>{const n=p?.tickCount??5,W=[],K=(Ne-ve)/(n-1);for(let M=0;M<n;M++)W.push(ve+K*M);return W},[ve,Ne,p?.tickCount]),Q=c.useMemo(()=>{const n=z?.tickCount??6;if(ue.length===0)return[];const W=Math.max(1,Math.floor(ue.length/(n-1)));return ue.filter((K,M)=>M%W===0||M===ue.length-1)},[ue,z?.tickCount]);return V.length===0||V.every(n=>n.data.length===0)?e.jsx("div",{className:`nice-forecast-chart ${ee??""}`,style:Y,"data-testid":Z??q,children:e.jsx("div",{className:"nice-forecast-chart__empty",children:k.noData??r("forecastChart.noDataAvailable","No data available")})}):e.jsxs("div",{className:`nice-forecast-chart ${ee??""}`,style:{...Y,height:T},"data-testid":Z??q,children:[e.jsxs("div",{ref:h,className:"nice-forecast-chart__container",children:[e.jsxs("svg",{ref:B,className:"nice-forecast-chart__svg",width:X.width,height:X.height,onMouseMove:oe,onMouseLeave:()=>ae(null),children:[p?.showGrid!==!1&&y.map(n=>e.jsx("line",{className:"nice-forecast-chart__grid-line",x1:f.left,x2:X.width-f.right,y1:se(n),y2:se(n)},n)),N&&ye&&e.jsx("rect",{className:"nice-forecast-chart__forecast-region",x:G(ye),y:f.top,width:X.width-f.right-G(ye),height:je}),C.map(n=>e.jsxs("g",{children:[e.jsx("line",{className:"nice-forecast-chart__reference-line",x1:f.left,x2:X.width-f.right,y1:se(n.value),y2:se(n.value),stroke:n.color??"var(--nice-text-muted, #9ca3af)",strokeDasharray:n.dashArray??"4,2"}),n.label&&e.jsx("text",{className:"nice-forecast-chart__reference-label",x:X.width-f.right-4,y:se(n.value)-4,textAnchor:"end",children:n.label})]},n.id)),Me&&E?.enabled&&e.jsxs("g",{className:"nice-forecast-chart__cash-runway",children:[e.jsx("line",{className:"nice-forecast-chart__cash-runway-line",x1:G(Me),x2:G(Me),y1:f.top,y2:X.height-f.bottom,stroke:E.color??"var(--nice-color-error, #ef4444)"}),E.showLabel!==!1&&e.jsxs(e.Fragment,{children:[e.jsx("rect",{className:"nice-forecast-chart__cash-runway-label-bg",x:G(Me)-60,y:f.top-2,width:120,height:E.showDate!==!1?32:20,fill:E.color??"var(--nice-color-error, #ef4444)",rx:4}),e.jsx("text",{className:"nice-forecast-chart__cash-runway-label",x:G(Me),y:f.top+12,textAnchor:"middle",fill:"var(--nice-color-white, #fff)",children:E.label??k.cashRunsOut??r("forecastChart.cashRunsOut","Cash runs out")}),E.showDate!==!1&&e.jsx("text",{className:"nice-forecast-chart__cash-runway-label",x:G(Me),y:f.top+26,textAnchor:"middle",fill:"var(--nice-color-white, #fff)",style:{fontSize:"0.625rem",opacity:.9},children:Te(Me,H)})]})]}),V.filter(n=>n.visible!==!1&&n.showConfidenceBand).map(n=>e.jsx("path",{className:"nice-forecast-chart__confidence-band",d:ne(n.data),fill:n.color},`band-${n.id}`)),V.filter(n=>n.visible!==!1).map(n=>{const W=ye?n.data.filter(M=>be(M.date)<ye):n.data.filter(M=>M.value!=null),K=ye?n.data.filter(M=>be(M.date)>=ye):n.data.filter(M=>M.forecast!=null);return e.jsxs("g",{children:[e.jsx("path",{className:"nice-forecast-chart__historical-line",d:we(W,"value"),stroke:n.color,strokeWidth:o}),e.jsx("path",{className:"nice-forecast-chart__forecast-line",d:we(K,ye?"value":"forecast"),stroke:n.color,strokeWidth:o}),K.length>0&&n.data.some(M=>M.forecast!=null)&&e.jsx("path",{className:"nice-forecast-chart__forecast-line",d:we(n.data,"forecast"),stroke:n.color,strokeWidth:o}),u&&n.data.map((M,J)=>{const re=M.value??M.forecast;return re==null?null:e.jsx("circle",{className:"nice-forecast-chart__point",cx:G(be(M.date)),cy:se(re),r:_,fill:n.color,onClick:()=>a?.(M,n)},J)})]},n.id)}),m.map(n=>{const W=G(be(n.date));return e.jsxs("g",{className:"nice-forecast-chart__annotation-marker",onClick:()=>j?.(n),children:[n.showLine!==!1&&e.jsx("line",{className:"nice-forecast-chart__annotation-line",x1:W,x2:W,y1:f.top,y2:X.height-f.bottom,stroke:n.color??"var(--nice-text-muted, #9ca3af)"}),e.jsx("circle",{cx:W,cy:f.top+10,r:8,fill:n.color??"var(--nice-text-muted, #9ca3af)"}),e.jsx("text",{x:W,y:f.top+14,textAnchor:"middle",fill:"white",fontSize:"10",children:n.icon??"!"})]},n.id)}),e.jsx("line",{className:"nice-forecast-chart__axis-line",x1:f.left,x2:f.left,y1:f.top,y2:X.height-f.bottom}),e.jsx("line",{className:"nice-forecast-chart__axis-line",x1:f.left,x2:X.width-f.right,y1:X.height-f.bottom,y2:X.height-f.bottom}),y.map(n=>e.jsx("text",{className:"nice-forecast-chart__axis-label",x:f.left-8,y:se(n)+4,textAnchor:"end",children:p?.format?p.format(n):Ce(n,H)},n)),Q.map(n=>e.jsx("text",{className:"nice-forecast-chart__axis-label",x:G(n),y:X.height-f.bottom+16,textAnchor:"middle",children:z?.format?z.format(n):Te(n,H)},n.getTime())),p?.title&&e.jsx("text",{className:"nice-forecast-chart__axis-title",x:15,y:X.height/2,textAnchor:"middle",transform:`rotate(-90, 15, ${X.height/2})`,children:p.title})]}),ce&&e.jsxs("div",{className:"nice-forecast-chart__tooltip",style:{left:he.x,top:he.y},children:[e.jsx("div",{className:"nice-forecast-chart__tooltip-date",children:Te(ce.date,H)}),ce.values.map(n=>{const W=n.value??n.forecast;return W==null?null:e.jsxs("div",{className:"nice-forecast-chart__tooltip-item",children:[e.jsx("span",{className:"nice-forecast-chart__tooltip-color",style:{background:n.scenario.color}}),e.jsx("span",{className:"nice-forecast-chart__tooltip-label",children:n.scenario.name}),e.jsx("span",{className:"nice-forecast-chart__tooltip-value",children:Ce(W,H)})]},n.scenario.id)}),ce.values.some(n=>n.lowerBound!=null)&&e.jsxs("div",{className:"nice-forecast-chart__tooltip-confidence",children:[k.confidence??r("forecastChart.ci","CI"),":"," ",Ce(ce.values[0]?.lowerBound??0,H)," –"," ",Ce(ce.values[0]?.upperBound??0,H)]})]})]}),g.enabled&&e.jsx("div",{className:"nice-forecast-chart__legend",children:V.map(n=>e.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":n.visible!==!1,onKeyDown:de.clickOnActivationKey,className:`nice-forecast-chart__legend-item ${n.visible===!1?"nice-forecast-chart__legend-item--hidden":""}`,onClick:()=>xe(n.id),children:[e.jsx("span",{className:`nice-forecast-chart__legend-color ${n.isBase?"":"nice-forecast-chart__legend-color--dashed"}`,style:{background:n.color}}),n.name]},n.id))})]})}),kt=[];function $t(t,s){const l=t?typeof t=="number"?new Date(t):new Date(t):new Date,r=D=>D.toString().padStart(2,"0"),i=r(l.getHours()),v=r(l.getMinutes()),m=r(l.getSeconds()),C=l.getMilliseconds().toString().padStart(3,"0");switch(s){case"HH:mm:ss":return`${i}:${v}:${m}`;case"HH:mm":return`${i}:${v}`;case"mm:ss":return`${v}:${m}`;case"ss.SSS":return`${m}.${C}`;case"ISO":return l.toISOString();default:return`${i}:${v}:${m}`}}function Ee(t){if(t.length===0)return null;const s=Math.min(...t),l=Math.max(...t),r=t.reduce((v,m)=>v+m,0)/t.length,i=t[t.length-1];return{min:s,max:l,avg:r,current:i,count:t.length}}const St=Object.assign(c.forwardRef(({series:t=kt,maxPoints:s=100,slidingWindow:l=!0,refreshRate:r=16,dataSource:i,width:v=600,height:m=400,title:C,showLegend:D=!0,showGrid:E=!0,yAxisLabel:z,xAxisLabel:p,stacked:O,zoomable:$,crosshair:L,annotations:T=[],legendInteractive:N,onDataPointClick:o,exportable:u,showControls:_=!0,showStatus:A=!0,initialPaused:I=!1,onDataReceived:w,onDataDropped:b,timeFormat:R="HH:mm:ss",showStats:a,thresholds:j=[],className:d,style:S,testId:x,"data-testid":P},k)=>{const[H,ee]=c.useState(()=>{const ne=new Map;for(const oe of t)ne.set(oe.name,oe.initialData?.slice()??[]);return ne}),[Y,q]=c.useState([]),{t:Z}=de.useNiceTranslation(),[U,g]=c.useState(I),[V,te]=c.useState(!1),ce=c.useRef([]),ae=c.useRef(Date.now()),he=c.useRef(null),F=c.useRef(new Map),h=c.useRef(0),B=JSON.stringify(t.map(ne=>ne.name)),f=c.useMemo(()=>new Set(JSON.parse(B)),[B]),X=c.useRef(U),fe=c.useRef(w),G=c.useRef(b);c.useEffect(()=>{X.current=U,fe.current=w,G.current=b});const se=c.useRef(null);se.current===null&&(se.current=new Map(t.map(ne=>[ne.name,ne.initialData?.length??0])));const ue=c.useCallback(()=>{const ne=ce.current;if(ne.length===0)return;ce.current=[];const oe=se.current??new Map,xe=[];for(const y of ne){const Q=oe.get(y.series);Q!==void 0&&(l&&Q+1>s?(xe.push([y.series,Q+1-s]),oe.set(y.series,s)):oe.set(y.series,Q+1))}ee(y=>{const Q=new Map(y);for(const n of ne){const W=Q.get(n.series);if(!W)continue;const K=[...W,n.value];l&&K.length>s&&K.splice(0,K.length-s),Q.set(n.series,K)}return Q});for(const[y,Q]of xe)G.current?.(Q,y);const je=[];for(const y of ne){if(!f.has(y.series))continue;const Q=(F.current.get(y.series)??0)+1;F.current.set(y.series,Q),Q>h.current&&(h.current=Q,je.push(y.category??$t(y.timestamp,R)))}je.length>0&&q(y=>{const Q=[...y,...je];return l&&Q.length>s&&Q.splice(0,Q.length-s),Q})},[l,s,R,f]),ve=c.useCallback(()=>{const ne=Date.now();ne-ae.current>=r&&(ue(),ae.current=ne),he.current=requestAnimationFrame(ve)},[r,ue]);c.useEffect(()=>(U||(he.current=requestAnimationFrame(ve)),()=>{he.current!==null&&(cancelAnimationFrame(he.current),he.current=null)}),[U,ve]);const Ne=c.useCallback(ne=>{if(X.current)return;const oe="points"in ne?ne.points:[ne];for(const xe of oe)f.has(xe.series)&&(ce.current.push(xe),fe.current?.(xe))},[f]);c.useEffect(()=>{if(!i)return;const ne=i.subscribe(Ne);let oe;return i.onStatusChange?oe=i.onStatusChange(te):te(!0),i.fetchHistory&&i.fetchHistory(s).then(xe=>{for(const je of xe)ce.current.push(je);ue()}),()=>{ne(),oe?.()}},[i,Ne,s,ue]);const ye=c.useMemo(()=>t.map(ne=>({name:ne.name,color:ne.color,type:ne.type,data:H.get(ne.name)??[]})),[t,H]),Me=c.useMemo(()=>{const ne=[...T];for(const oe of j)ne.push({type:"line",value:oe.value,color:oe.color,label:oe.label,dash:oe.style==="dashed"?"5,5":oe.style==="dotted"?"2,2":void 0});return ne},[T,j]);c.useImperativeHandle(k,()=>({pause(){g(!0)},resume(){g(!1)},isPaused(){return U},clear(){ee(oe=>{const xe=new Map(oe);for(const je of xe.keys())xe.set(je,[]);return xe}),q([]),F.current=new Map,h.current=0,ce.current=[];const ne=se.current;if(ne)for(const oe of ne.keys())ne.set(oe,0)},addPoint(ne){Ne(ne)},addPoints(ne){Ne({points:ne})},getData(ne){return H.get(ne)??[]},getCategories(){return Y},exportData(){return{series:ye,categories:Y}},getStats(ne){const oe=H.get(ne);return oe?Ee(oe):null}}),[U,H,Y,ye,Ne]);const we=c.useMemo(()=>{if(!a)return null;const ne={};for(const[oe,xe]of H)ne[oe]=Ee(xe);return ne},[a,H]);return e.jsxs("div",{className:d,style:{position:"relative",...S},"data-testid":P??x,children:[A&&e.jsxs("div",{style:{position:"absolute",top:8,right:8,display:"flex",alignItems:"center",gap:4,fontSize:12,color:V?"var(--nice-color-success, #22c55e)":"var(--nice-color-error, #ef4444)",zIndex:10},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:V?"var(--nice-color-success, #22c55e)":"var(--nice-color-error, #ef4444)"}}),V?Z("charts.live","Live"):Z("charts.disconnected","Disconnected")]}),_&&e.jsx("div",{style:{position:"absolute",top:8,left:8,display:"flex",gap:4,zIndex:10},children:e.jsx("button",{onClick:()=>g(ne=>!ne),style:{padding:"4px 8px",fontSize:12,border:"1px solid var(--nice-border-color, #ddd)",borderRadius:4,background:U?"var(--nice-warning-bg, #fef3c7)":"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",cursor:"pointer"},title:U?Z("charts.resume","Resume"):Z("charts.pause","Pause"),"aria-label":U?Z("charts.resume","Resume"):Z("charts.pause","Pause"),children:e.jsx(de.NiceIcon,{name:U?"play":"pause",size:14})})}),a&&we&&e.jsx("div",{style:{position:"absolute",bottom:50,right:8,background:"color-mix(in srgb, var(--nice-bg-elevated, #fff) 92%, transparent)",color:"var(--nice-text-primary, #0f172a)",border:"1px solid var(--nice-border-color, #ddd)",borderRadius:4,padding:8,fontSize:11,zIndex:10},children:Object.entries(we).map(([ne,oe])=>oe?e.jsxs("div",{style:{marginBottom:4},children:[e.jsx("strong",{children:ne}),e.jsxs("div",{children:[Z("charts.stats.min","Min"),": ",oe.min.toFixed(2)," |"," ",Z("charts.stats.max","Max"),": ",oe.max.toFixed(2)]}),e.jsxs("div",{children:[Z("charts.stats.avg","Avg"),": ",oe.avg.toFixed(2)," |"," ",Z("charts.stats.now","Now"),": ",oe.current.toFixed(2)]})]},ne):null)}),e.jsx(Ae,{series:ye,categories:Y,width:v,height:m,title:C,showLegend:D,showGrid:E,yAxisLabel:z,xAxisLabel:p,stacked:O,zoomable:$,crosshair:L,annotations:Me,legendInteractive:N,onDataPointClick:o,exportable:u})]})}),{displayName:"NiceLiveChart"});function Ct(t){const{hubConnection:s,eventName:l="DataPoint",subscribeMethod:r="SubscribeToMetrics",historyMethod:i="GetMetricHistory",metricName:v}=t;return{subscribe(m){const C=D=>{m(D)};return s.on(l,C),s.state==="Connected"&&s.invoke(r,v).catch(()=>{}),()=>{s.off(l,C)}},async fetchHistory(m){try{return await s.invoke(i,v,m)}catch{return[]}},onStatusChange(m){const C=()=>m(s.state==="Connected");return s.onclose(()=>m(!1)),s.onreconnected(()=>m(!0)),C(),()=>{}}}}function At(t){const{url:s,autoReconnect:l=!0,reconnectDelay:r=3e3,parseMessage:i=z=>JSON.parse(z)}=t;let v=null,m=null,C=null,D=null;const E=()=>{v=new WebSocket(s),v.onopen=()=>{m?.(!0)},v.onclose=()=>{m?.(!1),l&&(D=setTimeout(E,r))},v.onerror=()=>{v?.close()},v.onmessage=z=>{try{const p=i(z.data);p&&C&&C(p)}catch{}}};return{subscribe(z){return C=z,E(),()=>{C=null,D&&clearTimeout(D),v?.close(),v=null}},onStatusChange(z){return m=z,()=>{m=null}}}}function It(t){const{seriesNames:s,interval:l=1e3,generateValue:r=()=>Math.random()*100}=t;let i=null,v=0;return{subscribe(m){return i=setInterval(()=>{for(const C of s)m({series:C,value:r(C,v),timestamp:Date.now()});v++},l),()=>{i&&clearInterval(i)}},onStatusChange(m){return m(!0),()=>{}}}}const Rt=[];function Tt(t){if(!t.length)return{categories:[],numericFields:[],sampleValues:{}};const s=t[0],l=[],r={};let i=null;for(const[m,C]of Object.entries(s))typeof C=="number"?(l.push(m),r[m]=t.map(D=>Number(D[m])||0)):!i&&(typeof C=="string"||C instanceof Date)&&(i=m);return{categories:i?t.map(m=>String(m[i]||"")):t.map((m,C)=>`Item ${C+1}`),numericFields:l,sampleValues:r}}function zt(t,s){const{categories:l,numericFields:r,sampleValues:i}=Tt(t);return{series:r.map((m,C)=>({name:m.replace(/([A-Z])/g," $1").replace(/^./,D=>D.toUpperCase()).trim(),data:i[m],type:s==="area"?"area":s==="line"?"line":"bar"})),categories:l}}const Lt=c.forwardRef(function(s,l){const{rawData:r,enableAI:i=!0,aiModel:v,enableAutoType:m=!0,enableInsights:C=!0,dataDescription:D,onChartSuggestion:E,onInsights:z,showAIToolbar:p=!0,showInsightsOnLoad:O=!1,series:$=Rt,categories:L,...T}=s,[N,o]=c.useState("bar"),[u,_]=c.useState(null),[A,I]=c.useState([]),[w,b]=c.useState(O),[R,a]=c.useState(null),{t:j}=Ye.useNiceTranslation(),d=de.useNiceAI(),{suggestChartType:S,generateInsights:x,isLoading:P}=de.useChartSuggestion(),k=i&&d.isConfigured,{series:H,categories:ee}=r?zt(r,R||N):{series:$||[],categories:L},Y=c.useCallback(async()=>{if(!k||!m)return{type:"bar",reason:"Default",config:{}};const V=r||($?.length?$.flatMap(te=>te.data.map((ce,ae)=>({[te.name]:ce,index:ae}))):[]);try{const te=await S(V,D),ce={type:te.type,reason:te.reason,config:te.config};return _(ce),o(ce.type),E?.(ce),ce}catch{return{type:"bar",reason:"Default fallback",config:{}}}},[k,m,r,$,D,S,E]),q=c.useCallback(async()=>{if(!k||!C)return[];const V=r||($?.length?$.flatMap(te=>te.data.map((ce,ae)=>({[te.name]:ce,category:L?.[ae]||ae}))):[]);try{const te=await x(V,R||N);return I(te),z?.(te),te}catch{return[]}},[k,C,r,$,L,N,R,x,z]),Z=c.useCallback(()=>R||N,[R,N]);c.useEffect(()=>{k&&m&&(r?.length||$?.length)&&Y()},[k,m,r,$]),c.useImperativeHandle(l,()=>({getSuggestion:Y,generateInsights:q,getCurrentType:Z}));const U=[{type:"bar",icon:"bar-chart",label:j("chartAI.bar","Bar")},{type:"line",icon:"line-chart",label:j("chartAI.line","Line")},{type:"area",icon:"area-chart",label:j("chartAI.area","Area")},{type:"pie",icon:"pie-chart",label:j("chartAI.pie","Pie")},{type:"donut",icon:"donut-chart",label:j("chartAI.donut","Donut")},{type:"scatter",icon:"scatter-chart",label:j("chartAI.scatter","Scatter")}],g=R||N;return e.jsxs("div",{className:"nice-chart-ai","data-testid":s["data-testid"],children:[p&&k&&e.jsxs("div",{className:"nice-chart-ai__toolbar",children:[e.jsxs("div",{className:"nice-chart-ai__toolbar-left",children:[e.jsx("span",{className:"nice-chart-ai__badge",children:j("chartAI.ai","AI")}),u&&e.jsxs("div",{className:"nice-chart-ai__suggestion",children:[e.jsx("span",{className:"nice-chart-ai__suggestion-icon",children:e.jsx(de.NiceIcon,{name:"lightbulb",size:14})}),e.jsxs("span",{className:"nice-chart-ai__suggestion-text",children:[j("chartAI.suggestedType","Suggested:")," ",u.type]}),e.jsxs("span",{className:"nice-chart-ai__suggestion-reason",title:u.reason,children:["(",u.reason,")"]})]}),P&&e.jsx("span",{className:"nice-chart-ai__loading",children:j("chartAI.analyzing","Analyzing...")})]}),e.jsx("div",{className:"nice-chart-ai__toolbar-center",children:e.jsx("div",{className:"nice-chart-ai__type-selector",children:U.filter(V=>["bar","line","area"].includes(V.type)).map(({type:V,icon:te,label:ce})=>e.jsx("button",{type:"button",className:`nice-chart-ai__type-btn ${g===V?"nice-chart-ai__type-btn--active":""}`,onClick:()=>a(V),title:ce,children:e.jsx(de.NiceIcon,{name:te,size:16})},V))})}),e.jsxs("div",{className:"nice-chart-ai__toolbar-right",children:[e.jsxs("button",{type:"button",className:"nice-chart-ai__auto-btn",onClick:()=>Y(),disabled:P,title:j("chartAI.autoDetect","Auto-detect best chart type"),children:[e.jsx(de.NiceIcon,{name:"zap",size:14})," ",j("chartAI.auto","Auto")]}),C&&e.jsxs("button",{type:"button",className:"nice-chart-ai__insights-btn",onClick:()=>{A.length||q(),b(!w)},disabled:P,title:j("chartAI.showInsights","Show data insights"),children:[e.jsx(de.NiceIcon,{name:"lightbulb",size:14})," ",j("chartAI.insights","Insights")]})]})]}),e.jsx("div",{className:"nice-chart-ai__chart-wrapper",children:e.jsx(Ae,{series:H,categories:ee,...T})}),w&&A.length>0&&e.jsxs("div",{className:"nice-chart-ai__insights",children:[e.jsxs("div",{className:"nice-chart-ai__insights-header",children:[e.jsxs("h4",{children:[e.jsx(de.NiceIcon,{name:"lightbulb",size:14})," ",j("chartAI.dataInsights","Data Insights")]}),e.jsx("button",{type:"button",className:"nice-chart-ai__insights-close",onClick:()=>b(!1),"aria-label":j("chartAI.close","Close"),children:e.jsx(de.NiceIcon,{name:"close",size:14})})]}),e.jsx("ul",{className:"nice-chart-ai__insights-list",children:A.map((V,te)=>e.jsxs("li",{className:"nice-chart-ai__insight",children:[e.jsx("span",{className:"nice-chart-ai__insight-icon",children:"•"}),V]},te))}),e.jsx("div",{className:"nice-chart-ai__insights-footer",children:e.jsxs("button",{type:"button",className:"nice-chart-ai__refresh",onClick:()=>q(),disabled:P,children:[e.jsx(de.NiceIcon,{name:"refresh",size:14})," ",j("chartAI.refresh","Refresh")]})})]}),w&&P&&e.jsx("div",{className:"nice-chart-ai__insights nice-chart-ai__insights--loading",children:e.jsxs("div",{className:"nice-chart-ai__loading-content",children:[e.jsx("span",{className:"nice-chart-ai__spinner"}),j("chartAI.generatingInsights","Generating insights...")]})})]})}),Dt=[],Et=[],Pt=[],We=["var(--nice-color-primary, #3b82f6)","var(--nice-color-error, #ef4444)","var(--nice-color-success, #22c55e)","var(--nice-color-warning, #f59e0b)","var(--nice-color-accent, #8b5cf6)","var(--nice-color-accent-pink, #ec4899)","var(--nice-color-info, #06b6d4)","var(--nice-color-success, #10b981)","var(--nice-color-warning, #f59e0b)","var(--nice-color-accent, #6366f1)"],Ot=Object.assign(c.forwardRef((t,s)=>{const{t:l}=de.useNiceTranslation(),{levels:r=Pt,initialLevelId:i,levelId:v,chartType:m="bar",width:C=600,height:D=400,showBreadcrumbs:E=!0,showBackButton:z=!0,animationDuration:p=300,onLevelChange:O,onItemClick:$,colors:L=We,showValues:T=!0,showLegend:N=!0,className:o,style:u,testId:_,"data-testid":A,...I}=t,w=v!==void 0,[b,R]=c.useState(i||r[0]?.id),[a,j]=c.useState([i||r[0]?.id]),d=c.useCallback(F=>{const h=[];let B=r.find(f=>f.id===F);for(;B&&!h.includes(B.id);){h.unshift(B.id);const f=B.parentId;B=f?r.find(X=>X.id===f):void 0}return h.length>0?h:[F]},[r]),S=v??b,x=c.useMemo(()=>v!==void 0?d(v):a,[v,a,d]),[P,k]=c.useState(!1),[H,ee]=c.useState("in"),Y=c.useMemo(()=>r.find(F=>F.id===S),[r,S]),q=c.useCallback(F=>{r.find(B=>B.id===F)&&(ee("in"),k(!0),setTimeout(()=>{w||(R(F),j(B=>[...B,F])),O?.(F,w?d(F):[...x,F]),k(!1)},p/2))},[r,x,p,O,w,d]),Z=c.useCallback(()=>{if(x.length<=1)return;ee("out"),k(!0);const F=x.slice(0,-1),h=F[F.length-1];setTimeout(()=>{w||(R(h),j(F)),O?.(h,F),k(!1)},p/2)},[x,p,O,w]),U=c.useCallback(()=>{const F=r[0]?.id;F&&(ee("out"),k(!0),setTimeout(()=>{w||(R(F),j([F])),O?.(F,[F]),k(!1)},p/2))},[r,p,O,w]);c.useImperativeHandle(s,()=>({drillDown:q,drillUp:Z,resetToRoot:U,getCurrentLevel:()=>S,getPath:()=>x}),[q,Z,U,S,x]);const g=c.useCallback((F,h)=>{$?.(F,S);const B=r.find(f=>f.parentId===S&&f.id===F.metadata?.childLevelId);B&&q(B.id)},[S,r,q,$]),V=c.useMemo(()=>Y?.data.reduce((F,h)=>F+h.value,0)||0,[Y]),te=c.useMemo(()=>x.map(F=>r.find(h=>h.id===F)?.label||F),[x,r]),ce=()=>{if(!Y)return null;const F=Y.data,h=Math.max(...F.map(f=>f.value)),B=Math.min(40,(D-100)/F.length-8);return e.jsx("div",{className:"nice-drilldown-bars",children:F.map((f,X)=>{const fe=f.value/h*100;return e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:de.clickOnActivationKey,className:"nice-drilldown-bar-row",onClick:()=>g(f,X),children:[e.jsx("span",{className:"nice-drilldown-bar-label",children:f.label||l("charts.item","Item {i}").replace("{i}",String(X+1))}),e.jsx("div",{className:"nice-drilldown-bar-track",children:e.jsx("div",{className:"nice-drilldown-bar-fill",style:{width:`${fe}%`,backgroundColor:f.color||L[X%L.length],height:B}})}),T&&e.jsx("span",{className:"nice-drilldown-bar-value",children:f.value.toLocaleString()})]},X)})})},ae=()=>{if(!Y)return null;const F=Y.data,h=C/2,B=(D-60)/2+30,f=Math.min(h,B)-40;let X=-90;const fe=F.map((G,se)=>{const ue=G.value/V*360,ve=X+ue,Ne=ue>180?1:0,ye=X*Math.PI/180,Me=ve*Math.PI/180,we=h+f*Math.cos(ye),ne=B+f*Math.sin(ye),oe=h+f*Math.cos(Me),xe=B+f*Math.sin(Me),je=(X+ue/2)*Math.PI/180,y=h+f*.7*Math.cos(je),Q=B+f*.7*Math.sin(je),n=`M ${h} ${B} L ${we} ${ne} A ${f} ${f} 0 ${Ne} 1 ${oe} ${xe} Z`;return X=ve,{path:n,color:G.color||L[se%L.length],label:G.label||l("charts.item","Item {i}").replace("{i}",String(se+1)),value:G.value,percentage:(G.value/V*100).toFixed(1),labelX:y,labelY:Q,item:G,index:se}});return e.jsx("svg",{width:C,height:D-40,className:"nice-drilldown-pie",children:e.jsx("g",{children:fe.map((G,se)=>e.jsxs("g",{onClick:()=>g(G.item,G.index),children:[e.jsx("path",{d:G.path,fill:G.color,stroke:"white",strokeWidth:2,className:"nice-drilldown-pie-slice"}),T&&parseFloat(G.percentage)>5&&e.jsxs("text",{x:G.labelX,y:G.labelY,textAnchor:"middle",dominantBaseline:"middle",fill:"white",fontSize:"12",fontWeight:"600",children:[G.percentage,"%"]})]},se))})})},he=()=>{if(!Y)return null;const F=Y.data,h=Math.max(...F.map(X=>X.value)),B=Math.min(60,(C-100)/F.length-8),f=D-100;return e.jsx("svg",{width:C,height:D-40,className:"nice-drilldown-columns",children:e.jsxs("g",{transform:"translate(50, 20)",children:[[0,.25,.5,.75,1].map((X,fe)=>e.jsxs("g",{children:[e.jsx("line",{x1:0,y1:f*(1-X),x2:C-80,y2:f*(1-X),stroke:"var(--nice-border-color, #e5e7eb)",strokeDasharray:X===0?void 0:"4"}),e.jsx("text",{x:-8,y:f*(1-X),textAnchor:"end",dominantBaseline:"middle",fontSize:"11",fill:"var(--nice-text-secondary, #6b7280)",children:Math.round(h*X).toLocaleString()})]},fe)),F.map((X,fe)=>{const G=X.value/h*f,se=fe*((C-100)/F.length)+((C-100)/F.length-B)/2;return e.jsxs("g",{onClick:()=>g(X,fe),children:[e.jsx("rect",{x:se,y:f-G,width:B,height:G,fill:X.color||L[fe%L.length],rx:4,className:"nice-drilldown-column-bar"}),e.jsx("text",{x:se+B/2,y:f+16,textAnchor:"middle",fontSize:"11",fill:"var(--nice-text-primary, #374151)",children:(X.label||`${fe+1}`).slice(0,10)}),T&&e.jsx("text",{x:se+B/2,y:f-G-8,textAnchor:"middle",fontSize:"11",fill:"var(--nice-text-primary, #374151)",fontWeight:"500",children:X.value.toLocaleString()})]},fe)})]})})};return e.jsxs("div",{className:`nice-drilldown-chart ${P?`animating ${H}`:""} ${o||""}`,style:{width:C,...u},"data-testid":A??_,...I,children:[e.jsxs("div",{className:"nice-drilldown-header",children:[z&&x.length>1&&e.jsxs("button",{className:"nice-drilldown-back",onClick:Z,children:[e.jsx(de.NiceIcon,{name:"arrow-left",size:14})," ",l("charts.back","Back")]}),E&&e.jsx("div",{className:"nice-drilldown-breadcrumbs",children:te.map((F,h)=>e.jsxs(c.Fragment,{children:[h>0&&e.jsx("span",{className:"nice-drilldown-separator",children:"/"}),e.jsx("span",{role:h<te.length-1?"button":void 0,tabIndex:h<te.length-1?0:void 0,"aria-current":h===te.length-1?"location":void 0,onKeyDown:h<te.length-1?de.clickOnActivationKey:void 0,className:`nice-drilldown-crumb ${h===te.length-1?"active":""}`,onClick:()=>{if(h<te.length-1){const B=x.slice(0,h+1),f=B[B.length-1];w||(j(B),R(f)),O?.(f,B)}},children:F})]},h))})]}),e.jsxs("div",{className:"nice-drilldown-content",style:{height:D-40},children:[m==="bar"&&ce(),m==="pie"&&ae(),m==="column"&&he()]}),N&&Y&&e.jsx("div",{className:"nice-drilldown-legend",children:Y.data.map((F,h)=>e.jsxs("div",{className:"nice-drilldown-legend-item",children:[e.jsx("span",{className:"nice-drilldown-legend-color",style:{backgroundColor:F.color||L[h%L.length]}}),e.jsx("span",{className:"nice-drilldown-legend-label",children:F.label||l("charts.item","Item {i}").replace("{i}",String(h+1))})]},h))}),e.jsx("style",{children:`
|
|
293
|
+
.nice-drilldown-chart {
|
|
294
|
+
font-family: inherit;
|
|
295
|
+
color: var(--nice-text-primary, #111827);
|
|
296
|
+
background: var(--nice-bg-elevated, #ffffff);
|
|
297
|
+
border-radius: 8px;
|
|
298
|
+
overflow: hidden;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.nice-drilldown-header {
|
|
302
|
+
display: flex;
|
|
303
|
+
align-items: center;
|
|
304
|
+
gap: 12px;
|
|
305
|
+
padding: 12px 16px;
|
|
306
|
+
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
307
|
+
min-height: 40px;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.nice-drilldown-back {
|
|
311
|
+
background: var(--nice-bg-secondary, #f3f4f6);
|
|
312
|
+
border: none;
|
|
313
|
+
padding: 6px 12px;
|
|
314
|
+
border-radius: 6px;
|
|
315
|
+
cursor: pointer;
|
|
316
|
+
font-size: 13px;
|
|
317
|
+
font-family: inherit;
|
|
318
|
+
color: var(--nice-text-primary, #374151);
|
|
319
|
+
transition: background 0.2s;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.nice-drilldown-back:hover {
|
|
323
|
+
background: var(--nice-hover-bg, #e5e7eb);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.nice-drilldown-breadcrumbs {
|
|
327
|
+
display: flex;
|
|
328
|
+
align-items: center;
|
|
329
|
+
gap: 4px;
|
|
330
|
+
font-size: 13px;
|
|
331
|
+
font-family: inherit;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.nice-drilldown-separator {
|
|
335
|
+
color: var(--nice-text-muted, #9ca3af);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
.nice-drilldown-crumb {
|
|
339
|
+
color: var(--nice-text-secondary, #6b7280);
|
|
340
|
+
cursor: pointer;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
.nice-drilldown-crumb:hover:not(.active) {
|
|
344
|
+
color: var(--nice-color-primary, #3b82f6);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.nice-drilldown-crumb.active {
|
|
348
|
+
color: var(--nice-text-primary, #111827);
|
|
349
|
+
font-weight: 500;
|
|
350
|
+
cursor: default;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
.nice-drilldown-content {
|
|
354
|
+
padding: 16px;
|
|
355
|
+
transition: opacity 0.15s, transform 0.15s;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
.nice-drilldown-chart.animating .nice-drilldown-content {
|
|
359
|
+
opacity: 0;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
.nice-drilldown-chart.animating.in .nice-drilldown-content {
|
|
363
|
+
transform: translateX(20px);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
.nice-drilldown-chart.animating.out .nice-drilldown-content {
|
|
367
|
+
transform: translateX(-20px);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
.nice-drilldown-bars {
|
|
371
|
+
display: flex;
|
|
372
|
+
flex-direction: column;
|
|
373
|
+
gap: 8px;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
.nice-drilldown-bar-row {
|
|
377
|
+
display: flex;
|
|
378
|
+
align-items: center;
|
|
379
|
+
gap: 12px;
|
|
380
|
+
cursor: pointer;
|
|
381
|
+
padding: 4px 8px;
|
|
382
|
+
margin: -4px -8px;
|
|
383
|
+
border-radius: 6px;
|
|
384
|
+
transition: background 0.2s;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
.nice-drilldown-bar-row:hover {
|
|
388
|
+
background: var(--nice-hover-bg, #f9fafb);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
.nice-drilldown-bar-label {
|
|
392
|
+
width: 120px;
|
|
393
|
+
font-size: 13px;
|
|
394
|
+
font-family: inherit;
|
|
395
|
+
color: var(--nice-text-primary, #374151);
|
|
396
|
+
overflow: hidden;
|
|
397
|
+
text-overflow: ellipsis;
|
|
398
|
+
white-space: nowrap;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
.nice-drilldown-bar-track {
|
|
402
|
+
flex: 1;
|
|
403
|
+
background: var(--nice-bg-tertiary, #f3f4f6);
|
|
404
|
+
border-radius: 6px;
|
|
405
|
+
overflow: hidden;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
.nice-drilldown-bar-fill {
|
|
409
|
+
transition: width 0.3s ease;
|
|
410
|
+
border-radius: 6px;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
.nice-drilldown-bar-value {
|
|
414
|
+
width: 80px;
|
|
415
|
+
text-align: right;
|
|
416
|
+
font-size: 13px;
|
|
417
|
+
font-family: inherit;
|
|
418
|
+
font-weight: 500;
|
|
419
|
+
color: var(--nice-text-primary, #111827);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
.nice-drilldown-pie-slice {
|
|
423
|
+
cursor: pointer;
|
|
424
|
+
transition: transform 0.2s, opacity 0.2s;
|
|
425
|
+
transform-origin: center;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
.nice-drilldown-pie-slice:hover {
|
|
429
|
+
opacity: 0.85;
|
|
430
|
+
transform: scale(1.02);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
.nice-drilldown-column-bar {
|
|
434
|
+
cursor: pointer;
|
|
435
|
+
transition: opacity 0.2s;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
.nice-drilldown-column-bar:hover {
|
|
439
|
+
opacity: 0.8;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
.nice-drilldown-legend {
|
|
443
|
+
display: flex;
|
|
444
|
+
flex-wrap: wrap;
|
|
445
|
+
gap: 16px;
|
|
446
|
+
padding: 12px 16px;
|
|
447
|
+
border-top: 1px solid var(--nice-border-color, #e5e7eb);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
.nice-drilldown-legend-item {
|
|
451
|
+
display: flex;
|
|
452
|
+
align-items: center;
|
|
453
|
+
gap: 6px;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
.nice-drilldown-legend-color {
|
|
457
|
+
width: 12px;
|
|
458
|
+
height: 12px;
|
|
459
|
+
border-radius: 3px;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
.nice-drilldown-legend-label {
|
|
463
|
+
font-size: 12px;
|
|
464
|
+
font-family: inherit;
|
|
465
|
+
color: var(--nice-text-secondary, #6b7280);
|
|
466
|
+
}
|
|
467
|
+
`})]})}),{displayName:"NiceDrillDownChart"}),Bt=["var(--nice-info-bg, #dbeafe)","var(--nice-color-primary-light, #93c5fd)","var(--nice-color-primary, #3b82f6)","var(--nice-color-primary-active, #1d4ed8)","var(--nice-color-primary, #6366f1)"],Wt=({type:t="choropleth",regions:s=[],bubbles:l=[],width:r=800,height:i=500,viewBox:v="0 0 800 500",colorScale:m,colorRange:C,minValue:D,maxValue:E,showTooltip:z=!0,showLegend:p=!0,onRegionClick:O,onBubbleClick:$,onRegionHover:L,title:T,mapSvg:N,zoomable:o=!1,className:u,style:_,testId:A,"data-testid":I,...w})=>{const b=m??C??Bt,{t:R}=de.useNiceTranslation(),[a,j]=c.useState(null),[d,S]=c.useState(1),[x,P]=c.useState({x:0,y:0}),k=c.useRef(null),H=c.useRef(!1),ee=c.useRef({x:0,y:0}),Y=D??Math.min(...s.map(h=>h.value),...l.map(h=>h.value)),q=E??Math.max(...s.map(h=>h.value),...l.map(h=>h.value)),Z=c.useCallback(h=>{const B=(h-Y)/(q-Y),f=Math.min(Math.floor(B*b.length),b.length-1);return b[Math.max(0,f)]},[Y,q,b]),U=c.useCallback(h=>{if(!z||!a)return;const B=k.current?.getBoundingClientRect();B&&j(f=>f?{...f,x:h.clientX-B.left,y:h.clientY-B.top}:null)},[z,a]),g=c.useCallback((h,B)=>{const f=k.current?.getBoundingClientRect();f&&z&&j({x:B.clientX-f.left,y:B.clientY-f.top,content:`${h.name}: ${h.value.toLocaleString()}`}),L?.(h)},[z,L]),V=c.useCallback(()=>{j(null),L?.(null)},[L]),te=c.useCallback(h=>{if(!o)return;h.preventDefault();const B=h.deltaY>0?.9:1.1;S(f=>Math.min(Math.max(f*B,.5),4))},[o]),ce=c.useCallback(h=>{o&&(H.current=!0,ee.current={x:h.clientX-x.x,y:h.clientY-x.y})},[o,x]),ae=c.useCallback(()=>{H.current=!1},[]),he=c.useCallback(h=>{H.current&&P({x:h.clientX-ee.current.x,y:h.clientY-ee.current.y})},[]),F=c.useMemo(()=>s.length>0?s:[{id:"mazowieckie",name:"Mazowieckie",value:100,path:"M400,200 L450,200 L460,250 L420,280 L380,250 Z"},{id:"slaskie",name:"Śląskie",value:80,path:"M350,280 L400,280 L390,330 L340,320 Z"},{id:"wielkopolskie",name:"Wielkopolskie",value:70,path:"M300,200 L350,200 L360,260 L310,270 L280,230 Z"}],[s]);return e.jsxs("div",{className:`nice-map-chart ${u||""}`,style:{width:r,..._},"data-testid":I??A,...w,children:[T&&e.jsx("div",{className:"nice-map-title",children:T}),e.jsx("svg",{ref:k,width:r,height:i,viewBox:v,className:"nice-map-svg",onWheel:te,onMouseDown:ce,onMouseUp:ae,onMouseLeave:ae,onMouseMove:h=>{U(h),he(h)},children:e.jsxs("g",{transform:`translate(${x.x}, ${x.y}) scale(${d})`,children:[N&&e.jsx("g",{dangerouslySetInnerHTML:{__html:N}}),t==="choropleth"&&F.map(h=>e.jsx("path",{d:h.path,fill:h.color||Z(h.value),stroke:"var(--nice-bg-primary, #ffffff)",strokeWidth:1,className:"nice-map-region",onClick:()=>O?.(h),onMouseEnter:B=>g(h,B),onMouseLeave:V},h.id)),(t==="bubble"||l.length>0)&&l.map(h=>{const B=Math.sqrt((h.value-Y)/(q-Y))*30+5;return e.jsx("circle",{cx:h.lng,cy:h.lat,r:B,fill:h.color||"var(--nice-color-primary, #3b82f6)",fillOpacity:.7,stroke:"var(--nice-bg-primary, #ffffff)",strokeWidth:1,className:"nice-map-bubble",onClick:()=>$?.(h),onMouseEnter:f=>{const X=k.current?.getBoundingClientRect();X&&z&&j({x:f.clientX-X.left,y:f.clientY-X.top,content:`${h.label||h.id}: ${h.value.toLocaleString()}`})},onMouseLeave:V,children:h.label&&e.jsxs("title",{children:[h.label,": ",h.value]})},h.id)})]})}),a&&e.jsx("div",{className:"nice-map-tooltip",style:{left:a.x+10,top:a.y-30},children:a.content}),p&&e.jsxs("div",{className:"nice-map-legend",children:[e.jsx("span",{className:"nice-map-legend-title",children:R("charts.value","Value")}),e.jsx("div",{className:"nice-map-legend-scale",children:b.map((h,B)=>e.jsx("div",{className:"nice-map-legend-item",style:{backgroundColor:h}},B))}),e.jsxs("div",{className:"nice-map-legend-labels",children:[e.jsx("span",{children:Y.toLocaleString()}),e.jsx("span",{children:q.toLocaleString()})]})]}),e.jsx("style",{children:`
|
|
468
|
+
.nice-map-chart {
|
|
469
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
470
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
471
|
+
border-radius: var(--nice-radius-lg, 8px);
|
|
472
|
+
overflow: hidden;
|
|
473
|
+
position: relative;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
.nice-map-title {
|
|
477
|
+
padding: var(--nice-space-3, 12px) var(--nice-space-4, 16px);
|
|
478
|
+
font-size: 16px;
|
|
479
|
+
font-weight: 600;
|
|
480
|
+
color: var(--nice-text-primary, #0f172a);
|
|
481
|
+
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
.nice-map-svg {
|
|
485
|
+
display: block;
|
|
486
|
+
cursor: grab;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
.nice-map-svg:active {
|
|
490
|
+
cursor: grabbing;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
.nice-map-region {
|
|
494
|
+
cursor: pointer;
|
|
495
|
+
transition: opacity 0.2s, stroke-width 0.2s;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
.nice-map-region:hover {
|
|
499
|
+
opacity: 0.8;
|
|
500
|
+
stroke-width: 2;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
.nice-map-bubble {
|
|
504
|
+
cursor: pointer;
|
|
505
|
+
transition: transform 0.2s, opacity 0.2s;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
.nice-map-bubble:hover {
|
|
509
|
+
opacity: 1;
|
|
510
|
+
transform: scale(1.1);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
.nice-map-tooltip {
|
|
514
|
+
position: absolute;
|
|
515
|
+
/* audit-allow: token-role — inverted chip like .nice-tooltip: the text colour is the
|
|
516
|
+
fill and the label uses --nice-text-inverse, so the pair flips together. */
|
|
517
|
+
background: var(--nice-text-primary, #0f172a);
|
|
518
|
+
color: var(--nice-text-inverse, #ffffff);
|
|
519
|
+
padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
|
|
520
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
521
|
+
font-size: 12px;
|
|
522
|
+
pointer-events: none;
|
|
523
|
+
z-index: 10;
|
|
524
|
+
white-space: nowrap;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
.nice-map-legend {
|
|
528
|
+
position: absolute;
|
|
529
|
+
right: 16px;
|
|
530
|
+
bottom: 16px;
|
|
531
|
+
background: var(--nice-bg-elevated, #ffffff);
|
|
532
|
+
padding: var(--nice-space-3, 12px);
|
|
533
|
+
border-radius: var(--nice-radius-md, 6px);
|
|
534
|
+
box-shadow: 0 2px 8px var(--nice-overlay-10, color-mix(in srgb, var(--nice-text-primary, #000) 10%, transparent));
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
.nice-map-legend-title {
|
|
538
|
+
display: block;
|
|
539
|
+
font-size: 11px;
|
|
540
|
+
color: var(--nice-text-secondary, #475569);
|
|
541
|
+
margin-bottom: var(--nice-space-1-5, 6px);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
.nice-map-legend-scale {
|
|
545
|
+
display: flex;
|
|
546
|
+
height: 12px;
|
|
547
|
+
border-radius: var(--nice-radius-sm, 2px);
|
|
548
|
+
overflow: hidden;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
.nice-map-legend-item {
|
|
552
|
+
flex: 1;
|
|
553
|
+
min-width: 24px;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
.nice-map-legend-labels {
|
|
557
|
+
display: flex;
|
|
558
|
+
justify-content: space-between;
|
|
559
|
+
font-size: 10px;
|
|
560
|
+
color: var(--nice-text-secondary, #475569);
|
|
561
|
+
margin-top: var(--nice-space-1, 4px);
|
|
562
|
+
}
|
|
563
|
+
`})]})},Yt=({nodes:t=Dt,links:s=Et,width:l=800,height:r=500,nodeWidth:i=20,nodePadding:v=10,showValues:m=!0,showTooltip:C=!0,onNodeClick:D,onLinkClick:E,title:z,className:p,style:O,testId:$,"data-testid":L,...T})=>{const[N,o]=c.useState(null),u=c.useRef(null),_=c.useMemo(()=>{const I=new Map;t.forEach(g=>I.set(g.id,g));const w=new Set(s.map(g=>g.target)),b=new Set(s.map(g=>g.source)),R=[],a=new Map,j=t.filter(g=>b.has(g.id)&&!w.has(g.id));j.length>0&&(R.push(j.map(g=>g.id)),j.forEach(g=>a.set(g.id,0)));const d=t.filter(g=>b.has(g.id)&&w.has(g.id));d.length>0&&(R.push(d.map(g=>g.id)),d.forEach(g=>a.set(g.id,1)));const S=t.filter(g=>!b.has(g.id)&&w.has(g.id));S.length>0&&(R.push(S.map(g=>g.id)),S.forEach(g=>a.set(g.id,2))),R.length===0&&(R.push(t.map(g=>g.id)),t.forEach(g=>a.set(g.id,0)));const x=new Map;s.forEach(g=>{x.set(g.source,(x.get(g.source)||0)+g.value),x.set(g.target,(x.get(g.target)||0)+g.value)});const P=40,k=l-P*2,H=r-P*2,ee=R.length>1?k/(R.length-1):k,Y=new Map;Math.max(...Array.from(x.values())),R.forEach((g,V)=>{const te=g.reduce((he,F)=>he+(x.get(F)||0),0),ce=(H-(g.length-1)*v)/te;let ae=P;g.forEach(he=>{const h=(x.get(he)||0)*ce,B=P+V*ee;Y.set(he,{x:B,y:ae,height:h}),ae+=h+v})});const q=[],Z=new Map,U=new Map;return s.forEach(g=>{const V=Y.get(g.source),te=Y.get(g.target);if(!V||!te)return;const ce=x.get(g.source)||1;x.get(g.target);const ae=g.value/ce*V.height,he=V.y+(Z.get(g.source)||0),F=te.y+(U.get(g.target)||0);Z.set(g.source,(Z.get(g.source)||0)+ae),U.set(g.target,(U.get(g.target)||0)+ae);const h=V.x+i,B=te.x,f=(B-h)*.5,X=`
|
|
564
|
+
M ${h} ${he}
|
|
565
|
+
C ${h+f} ${he},
|
|
566
|
+
${B-f} ${F},
|
|
567
|
+
${B} ${F}
|
|
568
|
+
L ${B} ${F+ae}
|
|
569
|
+
C ${B-f} ${F+ae},
|
|
570
|
+
${h+f} ${he+ae},
|
|
571
|
+
${h} ${he+ae}
|
|
572
|
+
Z
|
|
573
|
+
`;q.push({path:X,link:g,sourcePos:V,targetPos:te})}),{nodePositions:Y,linkPaths:q,nodeMap:I,nodeValues:x}},[t,s,l,r,i,v]),A=c.useCallback((I,w)=>{const b=u.current?.getBoundingClientRect();b&&C&&o({x:w.clientX-b.left,y:w.clientY-b.top,content:I})},[C]);return e.jsxs("div",{className:`nice-sankey-chart ${p||""}`,style:{width:l,...O},"data-testid":L??$,...T,children:[z&&e.jsx("div",{className:"nice-sankey-title",children:z}),e.jsxs("svg",{ref:u,width:l,height:r,className:"nice-sankey-svg",children:[e.jsx("defs",{children:_.linkPaths.map((I,w)=>e.jsxs("linearGradient",{id:`sankey-gradient-${w}`,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[e.jsx("stop",{offset:"0%",stopColor:_.nodeMap.get(I.link.source)?.color||"var(--nice-color-primary, #3b82f6)"}),e.jsx("stop",{offset:"100%",stopColor:_.nodeMap.get(I.link.target)?.color||"var(--nice-color-error, #ef4444)"})]},w))}),e.jsx("g",{className:"nice-sankey-links",children:_.linkPaths.map((I,w)=>e.jsx("path",{d:I.path,fill:I.link.color||`url(#sankey-gradient-${w})`,fillOpacity:.4,className:"nice-sankey-link",onClick:()=>E?.(I.link),onMouseEnter:b=>A(`${_.nodeMap.get(I.link.source)?.name} → ${_.nodeMap.get(I.link.target)?.name}: ${I.link.value.toLocaleString()}`,b),onMouseLeave:()=>o(null)},w))}),e.jsx("g",{className:"nice-sankey-nodes",children:Array.from(_.nodePositions.entries()).map(([I,w])=>{const b=_.nodeMap.get(I);return b?e.jsxs("g",{children:[e.jsx("rect",{x:w.x,y:w.y,width:i,height:w.height,fill:b.color||"var(--nice-color-primary, #3b82f6)",rx:2,className:"nice-sankey-node",onClick:()=>D?.(b),onMouseEnter:R=>A(`${b.label??b.name??b.id}: ${_.nodeValues.get(I)?.toLocaleString()||0}`,R),onMouseLeave:()=>o(null)}),e.jsxs("text",{x:w.x+i+6,y:w.y+w.height/2,dominantBaseline:"middle",fontSize:"12",fill:"var(--nice-text-primary, #0f172a)",children:[b.label??b.name??b.id,m&&` (${_.nodeValues.get(I)?.toLocaleString()||0})`]})]},I):null})})]}),N&&e.jsx("div",{className:"nice-sankey-tooltip",style:{left:N.x+10,top:N.y-30},children:N.content}),e.jsx("style",{children:`
|
|
574
|
+
.nice-sankey-chart {
|
|
575
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
576
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
577
|
+
border-radius: var(--nice-radius-lg, 8px);
|
|
578
|
+
position: relative;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
.nice-sankey-title {
|
|
582
|
+
padding: var(--nice-space-3, 12px) var(--nice-space-4, 16px);
|
|
583
|
+
font-size: 16px;
|
|
584
|
+
font-weight: 600;
|
|
585
|
+
color: var(--nice-text-primary, #0f172a);
|
|
586
|
+
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
.nice-sankey-link {
|
|
590
|
+
cursor: pointer;
|
|
591
|
+
transition: fill-opacity 0.2s;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
.nice-sankey-link:hover {
|
|
595
|
+
fill-opacity: 0.7;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
.nice-sankey-node {
|
|
599
|
+
cursor: pointer;
|
|
600
|
+
transition: opacity 0.2s;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
.nice-sankey-node:hover {
|
|
604
|
+
opacity: 0.8;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
.nice-sankey-tooltip {
|
|
608
|
+
position: absolute;
|
|
609
|
+
/* audit-allow: token-role — inverted chip like .nice-tooltip: the text colour is the
|
|
610
|
+
fill and the label uses --nice-text-inverse, so the pair flips together. */
|
|
611
|
+
background: var(--nice-text-primary, #0f172a);
|
|
612
|
+
color: var(--nice-text-inverse, #ffffff);
|
|
613
|
+
padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
|
|
614
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
615
|
+
font-size: 12px;
|
|
616
|
+
pointer-events: none;
|
|
617
|
+
z-index: 10;
|
|
618
|
+
white-space: nowrap;
|
|
619
|
+
}
|
|
620
|
+
`})]})},Ft=Object.assign(c.forwardRef((t,s)=>{const{t:l}=de.useNiceTranslation(),{initialData:r,data:i,maxPoints:v=60,updateInterval:m=1e3,fetchData:C,width:D=600,height:E=200,chartType:z="line",color:p="var(--nice-color-primary, #3b82f6)",showGrid:O=!0,showTimeAxis:$=!0,showCurrentValue:L=!0,title:T,valueFormatter:N=G=>G.toFixed(2),timeFormatter:o=G=>new Date(G).toLocaleTimeString(),onDataUpdate:u,paused:_,className:A,style:I,testId:w,"data-testid":b,...R}=t,[a,j]=c.useState(r??i??[]),[d,S]=c.useState(_||!1),x=c.useRef(void 0);c.useEffect(()=>{_!==void 0&&S(_)},[_]),c.useEffect(()=>{if(d||!C)return;const G=async()=>{try{const se=await C();j(ue=>{const ve=[...ue,se].slice(-v);return u?.(ve),ve})}catch(se){console.error("Failed to fetch realtime data:",se)}};return x.current=setInterval(G,m),()=>{x.current&&clearInterval(x.current)}},[d,C,m,v,u]);const P=c.useCallback(G=>{j(se=>{const ue=[...se,G].slice(-v);return u?.(ue),ue})},[v,u]),k=c.useCallback(()=>{j([]),u?.([])},[u]),H=c.useCallback(()=>S(!0),[]),ee=c.useCallback(()=>S(!1),[]);c.useImperativeHandle(s,()=>({addDataPoint:P,clearData:k,pause:H,resume:ee,getData:()=>a}),[P,k,H,ee,a]);const Y={top:20,right:60,bottom:$?40:20,left:50},q=D-Y.left-Y.right,Z=E-Y.top-Y.bottom,U=a.map(G=>G.value),g=U.length?Math.min(...U):0,V=U.length?Math.max(...U):100,ce=(V-g||1)*.1,ae=g-ce,F=V+ce-ae,h=G=>{const se=C?v-1:Math.max(1,a.length-1);return Y.left+G/se*q},B=G=>Y.top+Z-(G-ae)/F*Z,f=a.map((G,se)=>`${h(se)},${B(G.value)}`).join(" "),X=a.length>0?`M ${h(0)},${Y.top+Z} L ${f} L ${h(a.length-1)},${Y.top+Z} Z`:"",fe=a.length>0?a[a.length-1].value:null;return e.jsxs("div",{className:`nice-realtime-chart ${A||""}`,style:{width:D,...I},"data-testid":b??w,...R,children:[e.jsxs("div",{className:"nice-realtime-header",children:[e.jsx("span",{className:"nice-realtime-title",children:T}),e.jsxs("div",{className:"nice-realtime-controls",children:[e.jsxs("span",{className:`nice-realtime-status ${d?"paused":"live"}`,children:[e.jsx("span",{className:"nice-realtime-status-dot"}),e.jsx("span",{children:d?l("charts.paused","Paused"):l("charts.live","Live")})]}),e.jsx("button",{className:`nice-realtime-btn ${d?"paused":""}`,onClick:()=>S(!d),"aria-label":d?l("charts.resume","Resume"):l("charts.pause","Pause"),children:e.jsx(de.NiceIcon,{name:d?"play":"pause",size:14})}),L&&fe!==null&&e.jsx("span",{className:"nice-realtime-value",children:N(fe)})]})]}),e.jsxs("svg",{width:D,height:E,className:"nice-realtime-svg",children:[O&&e.jsx("g",{className:"nice-realtime-grid",children:[0,.25,.5,.75,1].map((G,se)=>{const ue=Y.top+Z*(1-G),ve=ae+F*G;return e.jsxs("g",{children:[e.jsx("line",{x1:Y.left,y1:ue,x2:D-Y.right,y2:ue,stroke:"var(--nice-border-color, #e5e7eb)",strokeDasharray:G===0?void 0:"3"}),e.jsx("text",{x:Y.left-8,y:ue,textAnchor:"end",dominantBaseline:"middle",fontSize:"10",fill:"var(--nice-text-secondary, #6b7280)",children:Math.round(ve).toLocaleString()})]},se)})}),z==="area"&&a.length>0&&e.jsx("path",{d:X,fill:p,fillOpacity:.2}),a.length>1&&e.jsx("polyline",{points:f,fill:"none",stroke:p,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),a.length>0&&e.jsx("circle",{cx:h(a.length-1),cy:B(a[a.length-1].value),r:3,fill:p,className:"nice-realtime-point"}),$&&a.length>0&&e.jsx("g",{className:"nice-realtime-time-axis",children:Array.from(new Set([0,Math.floor(a.length/2),a.length-1].filter(G=>a[G]))).map(G=>e.jsx("text",{x:h(G),y:E-8,textAnchor:"middle",fontSize:"10",fill:"var(--nice-text-secondary, #6b7280)",children:o(a[G].timestamp)},`tx-${G}`))})]}),e.jsx("style",{children:`
|
|
621
|
+
.nice-realtime-chart {
|
|
622
|
+
font-family: inherit;
|
|
623
|
+
color: var(--nice-text-primary, #111827);
|
|
624
|
+
background: var(--nice-bg-elevated, #ffffff);
|
|
625
|
+
border-radius: 8px;
|
|
626
|
+
position: relative;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
.nice-realtime-header {
|
|
630
|
+
display: flex;
|
|
631
|
+
justify-content: space-between;
|
|
632
|
+
align-items: center;
|
|
633
|
+
padding: 12px 16px;
|
|
634
|
+
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
.nice-realtime-title {
|
|
638
|
+
font-size: 14px;
|
|
639
|
+
font-weight: 600;
|
|
640
|
+
color: var(--nice-text-primary, #111827);
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
.nice-realtime-controls {
|
|
644
|
+
display: flex;
|
|
645
|
+
align-items: center;
|
|
646
|
+
gap: 12px;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
.nice-realtime-btn {
|
|
650
|
+
background: none;
|
|
651
|
+
border: none;
|
|
652
|
+
cursor: pointer;
|
|
653
|
+
font-size: 16px;
|
|
654
|
+
padding: 4px;
|
|
655
|
+
font-family: inherit;
|
|
656
|
+
color: inherit;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
.nice-realtime-value {
|
|
660
|
+
font-size: 18px;
|
|
661
|
+
font-weight: 600;
|
|
662
|
+
color: ${p};
|
|
663
|
+
font-variant-numeric: tabular-nums;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
/* Static current-value dot — no pulsing animation (was distracting) */
|
|
667
|
+
|
|
668
|
+
.nice-realtime-status {
|
|
669
|
+
display: inline-flex;
|
|
670
|
+
align-items: center;
|
|
671
|
+
gap: 6px;
|
|
672
|
+
font-size: 11px;
|
|
673
|
+
font-family: inherit;
|
|
674
|
+
color: var(--nice-text-secondary, #6b7280);
|
|
675
|
+
background: var(--nice-bg-secondary, #f3f4f6);
|
|
676
|
+
padding: 2px 10px;
|
|
677
|
+
border-radius: 999px;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
.nice-realtime-status-dot {
|
|
681
|
+
width: 8px;
|
|
682
|
+
height: 8px;
|
|
683
|
+
border-radius: 50%;
|
|
684
|
+
background: var(--nice-color-success, #22c55e);
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
.nice-realtime-status.paused .nice-realtime-status-dot {
|
|
688
|
+
background: var(--nice-color-warning, #f59e0b);
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
.nice-realtime-status.live .nice-realtime-status-dot {
|
|
692
|
+
animation: live-pulse 2s ease-in-out infinite;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
@keyframes live-pulse {
|
|
696
|
+
0%, 100% { opacity: 1; }
|
|
697
|
+
50% { opacity: 0.4; }
|
|
698
|
+
}
|
|
699
|
+
`})]})}),{displayName:"NiceRealtimeChart"}),Ht=({data:t,width:s=600,height:l=400,showLabels:r=!0,showValues:i=!0,onNodeClick:v,drilldownEnabled:m=!0,colors:C=We,tilePadding:D=2,className:E,style:z,testId:p,"data-testid":O,...$})=>{const{t:L}=de.useNiceTranslation(),T=c.useMemo(()=>Array.isArray(t)?{id:"root",name:"Root",value:t.reduce((S,x)=>S+(x.value||0),0),children:t.map((S,x)=>({id:`${x}`,name:S.label??S.name??`Item ${x+1}`,value:S.value,color:S.color}))}:t,[t]),[N,o]=c.useState(T),[u,_]=c.useState([T.name]),[A,I]=c.useState(null),w=c.useRef(null),b=c.useMemo(()=>{const x=N.children||[];if(x.length===0)return[];const P=x.reduce((g,V)=>g+V.value,0),k=x.map(g=>({node:g,area:g.value/P*s*l}));k.sort((g,V)=>V.area-g.area);const H=[];let ee=0,Y=0,q=s,Z=l,U=0;for(;U<k.length;){const g=q<Z;let V=0,te=[];const ce=g?Z:q;for(let F=U;F<k.length;F++){const h=[...te,k[F]],B=h.reduce((X,fe)=>X+fe.area,0),f=R(h,B,ce);if(te.length===0)te=h,V=B;else{const X=R(te,V,ce);if(f<=X)te=h,V=B;else break}}const ae=V/ce;let he=0;te.forEach((F,h)=>{const B=F.area/ae;H.push({node:F.node,x:g?ee:ee+he,y:g?Y+he:Y,w:g?ae:B,h:g?B:ae,color:F.node.color||C[(U+h)%C.length]}),he+=B}),g?(ee+=ae,q-=ae):(Y+=ae,Z-=ae),U+=te.length}return H},[N,s,l,C]);function R(S,x,P){const k=x/P;let H=0;for(const ee of S){const Y=ee.area/k,q=Math.max(k/Y,Y/k);H=Math.max(H,q)}return H}const a=S=>{v?.(S,[...u,S.name]),m&&S.children&&S.children.length>0&&(o(S),_(x=>[...x,S.name]))},j=()=>{if(u.length<=1)return;let S=T;const x=u.slice(0,-1);for(let P=1;P<x.length;P++){const k=S.children?.find(H=>H.name===x[P]);k&&(S=k)}o(S),_(x)},d=(S,x)=>{const P=w.current?.getBoundingClientRect();P&&I({x:x.clientX-P.left,y:x.clientY-P.top,content:S})};return e.jsxs("div",{className:`nice-treemap-chart ${E||""}`,style:{width:s,...z},"data-testid":O??p,...$,children:[e.jsxs("div",{className:"nice-treemap-nav",children:[u.length>1&&e.jsxs("button",{className:"nice-treemap-back",onClick:j,children:[e.jsx(de.NiceIcon,{name:"arrow-left",size:14})," ",L("charts.back","Back")]}),e.jsx("div",{className:"nice-treemap-breadcrumbs",children:u.map((S,x)=>e.jsxs(c.Fragment,{children:[x>0&&e.jsx("span",{className:"nice-treemap-sep",children:"/"}),e.jsx("span",{className:x===u.length-1?"current":"",children:S})]},x))})]}),e.jsx("svg",{ref:w,width:s,height:l,className:"nice-treemap-svg",children:b.map((S,x)=>{const{node:P,x:k,y:H,w:ee,h:Y,color:q}=S,Z=Math.min(14,Math.max(10,Math.min(ee,Y)/6)),U=ee>40&&Y>30;return e.jsxs("g",{onClick:()=>a(P),onMouseEnter:g=>d(`${P.name}: ${P.value.toLocaleString()}`,g),onMouseLeave:()=>I(null),children:[e.jsx("rect",{x:k+D/2,y:H+D/2,width:Math.max(0,ee-D),height:Math.max(0,Y-D),fill:q,rx:4,className:"nice-treemap-tile"}),r&&U&&e.jsx("text",{x:k+ee/2,y:H+Y/2-(i?6:0),textAnchor:"middle",dominantBaseline:"middle",fontSize:Z,fill:"white",fontWeight:"500",style:{pointerEvents:"none"},children:P.name.length>ee/Z+2?P.name.slice(0,Math.floor(ee/Z))+"...":P.name}),i&&U&&e.jsx("text",{x:k+ee/2,y:H+Y/2+10,textAnchor:"middle",dominantBaseline:"middle",fontSize:Z-2,fill:"var(--nice-overlay-light-80, rgba(255, 255, 255, 0.8))",style:{pointerEvents:"none"},children:P.value.toLocaleString()})]},x)})}),A&&e.jsx("div",{className:"nice-treemap-tooltip",style:{left:A.x+10,top:A.y-30},children:A.content}),e.jsx("style",{children:`
|
|
700
|
+
.nice-treemap-chart {
|
|
701
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
702
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
703
|
+
border-radius: var(--nice-radius-lg, 8px);
|
|
704
|
+
position: relative;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
.nice-treemap-nav {
|
|
708
|
+
display: flex;
|
|
709
|
+
align-items: center;
|
|
710
|
+
gap: var(--nice-space-3, 12px);
|
|
711
|
+
padding: var(--nice-space-3, 12px) var(--nice-space-4, 16px);
|
|
712
|
+
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
.nice-treemap-back {
|
|
716
|
+
background: var(--nice-bg-secondary, #f8fafc);
|
|
717
|
+
color: var(--nice-text-primary, #0f172a);
|
|
718
|
+
border: none;
|
|
719
|
+
padding: var(--nice-space-1-5, 6px) var(--nice-space-3, 12px);
|
|
720
|
+
border-radius: var(--nice-radius-md, 6px);
|
|
721
|
+
cursor: pointer;
|
|
722
|
+
font-size: 13px;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
.nice-treemap-back:hover {
|
|
726
|
+
background: var(--nice-border-color, #e5e7eb);
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
.nice-treemap-breadcrumbs {
|
|
730
|
+
display: flex;
|
|
731
|
+
align-items: center;
|
|
732
|
+
gap: var(--nice-space-1, 4px);
|
|
733
|
+
font-size: 13px;
|
|
734
|
+
color: var(--nice-text-secondary, #475569);
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
.nice-treemap-breadcrumbs .current {
|
|
738
|
+
color: var(--nice-text-primary, #0f172a);
|
|
739
|
+
font-weight: 500;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
.nice-treemap-sep {
|
|
743
|
+
color: var(--nice-text-muted, #94a3b8);
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
.nice-treemap-tile {
|
|
747
|
+
cursor: pointer;
|
|
748
|
+
transition: opacity 0.2s, transform 0.1s;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
.nice-treemap-tile:hover {
|
|
752
|
+
opacity: 0.85;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
.nice-treemap-tooltip {
|
|
756
|
+
position: absolute;
|
|
757
|
+
/* audit-allow: token-role — inverted chip like .nice-tooltip: the text colour is the
|
|
758
|
+
fill and the label uses --nice-text-inverse, so the pair flips together. */
|
|
759
|
+
background: var(--nice-text-primary, #0f172a);
|
|
760
|
+
color: var(--nice-text-inverse, #ffffff);
|
|
761
|
+
padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
|
|
762
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
763
|
+
font-size: 12px;
|
|
764
|
+
pointer-events: none;
|
|
765
|
+
z-index: 10;
|
|
766
|
+
white-space: nowrap;
|
|
767
|
+
}
|
|
768
|
+
`})]})};exports.CHART_COLORS=_e;exports.NiceBarGauge=Ke;exports.NiceBullet=Je;exports.NiceChart=Ae;exports.NiceChart$1=He;exports.NiceChartAI=Lt;exports.NiceCircularGauge=Ve;exports.NiceDrillDownChart=Ot;exports.NiceForecastChart=wt;exports.NiceFunnel=nt;exports.NiceHeatMap=ct;exports.NiceLinearGauge=Xe;exports.NiceLiveChart=St;exports.NiceMapChart=Wt;exports.NiceOrganizationChart=xt;exports.NicePieChart=et;exports.NicePolarChart=_t;exports.NiceRangeSelector=jt;exports.NiceRealtimeChart=Ft;exports.NiceSankey=Pe;exports.NiceSankey$1=ot;exports.NiceSankeyChart=Yt;exports.NiceSparkline=vt;exports.NiceStockChart=pt;exports.NiceTreeMap=Oe;exports.NiceTreeMap$1=ht;exports.NiceTreeMapChart=Ht;exports.NiceVectorMap=Be;exports.NiceVectorMap$1=ft;exports.createMockLiveChartSource=It;exports.createSignalRLiveChartSource=Ct;exports.createWebSocketLiveChartSource=At;
|