@nice2dev/ui 1.1.9 → 1.2.0
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 +150 -0
- package/README.md +27 -34
- package/dist/NiceButton-5tWvfXKl.cjs +1 -0
- package/dist/NiceButton-DHSgQT1_.js +112 -0
- package/dist/NiceCodeEditor-B8At55f5.js +1179 -0
- package/dist/NiceCodeEditor-BJSEzhcY.cjs +260 -0
- package/dist/NiceCodeEditor-BfkH1bsZ.cjs +260 -0
- package/dist/NiceCodeEditor-CduGYggj.js +1179 -0
- package/dist/NiceColorPicker-CdUnhM-A.cjs +1 -0
- package/dist/NiceColorPicker-DCgmE-3H.cjs +1 -0
- package/dist/NiceColorPicker-DK30kJgy.js +486 -0
- package/dist/NiceColorPicker-DpXwnDwL.js +598 -0
- package/dist/NiceColorPicker-DtPFxDKM.cjs +1 -0
- package/dist/NiceColorPicker-bNJBAU_c.js +598 -0
- package/dist/NiceConfirmDialog-B7aNRL2K.cjs +1 -0
- package/dist/NiceConfirmDialog-BdhWenrO.js +81 -0
- package/dist/NiceDataGrid-BOCJr6XF.js +2217 -0
- package/dist/NiceDataGrid-BV5Oh-gy.cjs +10 -0
- package/dist/NiceDataGrid-CVYEo_nv.cjs +10 -0
- package/dist/NiceDataGrid-D-rm4lu8.js +2217 -0
- package/dist/NiceDataGrid-Dd7SI-M6.cjs +10 -0
- package/dist/NiceDataGrid-DjZchXYG.js +2217 -0
- package/dist/NiceDocumentViewer-BgcgLWJ3.cjs +180 -0
- package/dist/NiceDocumentViewer-sukmGhRx.js +672 -0
- package/dist/NiceForm-BCEXovJR.cjs +1 -0
- package/dist/NiceForm-D7oyWHXg.js +4820 -0
- package/dist/NiceForm-DUhxXArr.js +4817 -0
- package/dist/NiceForm-DVc0Xoly.js +4819 -0
- package/dist/NiceForm-qD_RKPYz.cjs +1 -0
- package/dist/NiceForm-uCeVmTrD.cjs +1 -0
- package/dist/NiceGantt-4UBd4uJ8.cjs +1 -0
- package/dist/NiceGantt-B_1lwEsp.js +328 -0
- package/dist/NiceHtmlEditor-BYk1roA4.cjs +10 -0
- package/dist/NiceHtmlEditor-Bce9Vwe1.cjs +10 -0
- package/dist/NiceHtmlEditor-C5kLeF9H.cjs +10 -0
- package/dist/NiceHtmlEditor-CFVMIC5L.js +848 -0
- package/dist/NiceHtmlEditor-CGRgcu2h.js +848 -0
- package/dist/NiceHtmlEditor-mWebBmy1.js +849 -0
- package/dist/NiceLoginForm-BHyDY7br.cjs +1 -0
- package/dist/NiceLoginForm-BTuQ0eKk.cjs +1 -0
- package/dist/NiceLoginForm-BuxFY2Rk.js +750 -0
- package/dist/NiceLoginForm-o1A-TBcp.js +736 -0
- package/dist/NiceLoginForm.css +1 -0
- package/dist/NiceMention-CA7CL5BI.js +11263 -0
- package/dist/NiceMention-CHcKRl-L.cjs +430 -0
- package/dist/NiceMention-DJD0BLcp.js +11269 -0
- package/dist/NiceMention-DcaUEMSg.cjs +430 -0
- package/dist/NiceMention-Dds9GQzk.cjs +430 -0
- package/dist/NiceMention-DlLXWddO.js +11268 -0
- package/dist/NiceMention.css +1 -1
- package/dist/NiceModal-C4p8a82e.cjs +1 -0
- package/dist/NiceModal-Dr1e3nQZ.cjs +1 -0
- package/dist/NiceModal-TNlkaL_i.js +85 -0
- package/dist/NiceModal-sihGCfDy.js +95 -0
- package/dist/NiceModuleLifecyclePanel-BWbKdVC_.js +7054 -0
- package/dist/NiceModuleLifecyclePanel-CZHIzvkE.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-Du7G3-RG.js +7053 -0
- package/dist/NiceModuleLifecyclePanel-OC9YK2kG.js +7052 -0
- package/dist/NiceModuleLifecyclePanel-_OcfDmtC.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-js1p7LIY.cjs +1 -0
- package/dist/NicePagination-8XsBbMNx.js +165 -0
- package/dist/NicePagination-CkOoXf0f.js +165 -0
- package/dist/NicePagination-D44waj9o.cjs +1 -0
- package/dist/NicePagination-D7lek1G7.cjs +1 -0
- package/dist/NicePagination-DdxH8KMG.js +179 -0
- package/dist/NicePagination-OjTEfZJE.cjs +1 -0
- package/dist/NicePivotGrid-B2YHP3Z6.js +1183 -0
- package/dist/NicePivotGrid-BJRSciWl.js +1183 -0
- package/dist/NicePivotGrid-BtVUWiud.cjs +152 -0
- package/dist/NicePivotGrid-CS1dPmNI.cjs +152 -0
- package/dist/NicePivotGrid-D2AxqDzJ.js +1183 -0
- package/dist/NicePivotGrid-DxQ6Py9D.cjs +152 -0
- package/dist/NiceSavedQueryPanel-B5HhqlAI.cjs +586 -0
- package/dist/NiceSavedQueryPanel-C0A-eoYN.js +5142 -0
- package/dist/NiceSavedQueryPanel-CMStDOKe.js +5125 -0
- package/dist/NiceSavedQueryPanel-D2i34e_b.cjs +586 -0
- package/dist/NiceSavedQueryPanel-ZrilZRtf.cjs +586 -0
- package/dist/NiceSavedQueryPanel-mPO2THs7.js +5142 -0
- package/dist/NiceSavedQueryPanel.css +1 -1
- package/dist/NiceScheduler-7gP7vcLy.cjs +5 -0
- package/dist/NiceScheduler-Cy7F9tgH.js +1693 -0
- package/dist/NiceScheduler-DquRUZxD.cjs +5 -0
- package/dist/NiceScheduler-KSzaUQxC.js +1693 -0
- package/dist/NiceScheduler-O3AwmdGG.cjs +5 -0
- package/dist/NiceScheduler-l8N4yCWd.js +1716 -0
- package/dist/NiceSelect-BCbWtu1v.js +433 -0
- package/dist/NiceSelect-BqtiQbfD.cjs +1 -0
- package/dist/NiceSelect-DZB1Rs9x.js +435 -0
- package/dist/NiceSelect-tMz9QQUs.cjs +1 -0
- package/dist/NiceStreamDashboard.doc-74KUXya1.cjs +8 -0
- package/dist/NiceStreamDashboard.doc-k8PQfCM0.js +32 -0
- package/dist/NiceWindow-BEov3s9F.js +2094 -0
- package/dist/NiceWindow-BU1Ce7gS.js +1623 -0
- package/dist/NiceWindow-CDt6PCEg.cjs +1 -0
- package/dist/NiceWindow-jjdE6vGy.cjs +1 -0
- package/dist/NiceWindow.css +1 -1
- package/dist/charts-C047IMVn.cjs +768 -0
- package/dist/charts-C44vJber.cjs +768 -0
- package/dist/charts-CCXSb3xk.js +4752 -0
- package/dist/charts-CqETcUhH.js +4752 -0
- package/dist/charts-DouiiHOT.cjs +768 -0
- package/dist/charts-XVlDwU0y.js +4732 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.mjs +8 -8
- package/dist/core-BL-KmGYC.js +795 -0
- package/dist/core-BxiH7vkV.cjs +1 -0
- package/dist/core-Chg-oYCr.cjs +1 -0
- package/dist/core-CxBnKAhs.cjs +1 -0
- package/dist/core-DMV6_SEE.js +795 -0
- package/dist/core-D_LRh59n.js +795 -0
- package/dist/data-branching-Km4lc8P_.cjs +1 -0
- package/dist/data-branching-YQtJJEtn.js +6273 -0
- package/dist/data-branching-oEH04O3i.js +6273 -0
- package/dist/data-branching-wmsbLNfa.cjs +1 -0
- package/dist/data-branching.cjs +1 -1
- package/dist/data-branching.mjs +1 -1
- package/dist/data.cjs +1 -1
- package/dist/data.d.ts +2 -53
- package/dist/data.mjs +3 -3
- package/dist/devops-Bt6EsfPa.cjs +17 -0
- package/dist/devops-CnZQ1rU5.js +8312 -0
- package/dist/devops-D5yIDM3e.js +8312 -0
- package/dist/devops-rVpB0ZAX.cjs +17 -0
- package/dist/devops.cjs +1 -1
- package/dist/devops.mjs +1 -1
- package/dist/editors.cjs +1 -1
- package/dist/editors.d.ts +8 -26
- package/dist/editors.mjs +55 -54
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.d.ts +5 -0
- package/dist/feedback.mjs +3 -3
- package/dist/index.cjs +290 -290
- package/dist/index.css +1 -1
- package/dist/index.d.ts +239 -234
- package/dist/index.mjs +20262 -19440
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.mjs +29 -29
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.d.ts +4 -4
- package/dist/navigation.mjs +69 -69
- package/dist/no-code-4GtIBr6f.js +7503 -0
- package/dist/no-code-6WyYb3hL.cjs +331 -0
- package/dist/no-code-BH5oVFC6.js +8186 -0
- package/dist/no-code-Bdwh1vyS.cjs +332 -0
- package/dist/no-code-CnHG5_Vn.js +8186 -0
- package/dist/no-code-DMKlg1Zl.cjs +331 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.css +1 -1
- package/dist/no-code.d.ts +25 -18
- package/dist/no-code.mjs +3 -3
- package/dist/overlays.cjs +1 -1
- package/dist/overlays.d.ts +24 -24
- package/dist/overlays.mjs +24 -490
- package/dist/pickerCommons-0vyK1Knv.js +547 -0
- package/dist/pickerCommons-31hyz1gs.js +1122 -0
- package/dist/pickerCommons-BFbItm8o.cjs +1 -0
- package/dist/pickerCommons-BHirHJyn.js +548 -0
- package/dist/pickerCommons-BifIkPdk.cjs +1 -0
- package/dist/pickerCommons-Bt8JIaTN.cjs +1 -0
- package/dist/pickerCommons.css +1 -1
- package/dist/style.css +10 -7
- package/package.json +5 -7
- package/css/legacy-bg-text-aliases.css +0 -87
|
@@ -0,0 +1,768 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),le=require("@nice2dev/ui-core"),s=require("react"),Ye=require("@nice2dev/i18n"),Ne=["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)"],we=({series:n,categories:i,width:m=600,height:a=400,title:o,showLegend:b=!0,showGrid:j=!0,axisLabels:C=!0,yAxisLabel:z,xAxisLabel:k,stacked:g,animated:N,zoomable:D,crosshair:A,annotations:M,legendInteractive:d,onDataPointClick:l,exportable:x,className:I,style:v})=>{const $=s.useRef(null),[_,R]=s.useState(new Set),[r,T]=s.useState(null),[u,w]=s.useState(null),[y,P]=s.useState(!1),H=s.useRef(null),X=s.useMemo(()=>n.filter(c=>!_.has(c.name)),[n,_]),Z=s.useCallback(c=>{d&&R(F=>{const J=new Set(F);return J.has(c)?J.delete(c):J.add(c),J})},[d]),B={top:o?40:20,right:20,bottom:k?60:40,left:z?60:50},U=m-B.left-B.right,V=a-B.top-B.bottom,G=X[0]?.data.length??n[0]?.data.length??0,p=u?.start??0,re=u?.end??G,te=re-p,K=s.useMemo(()=>X.map(c=>({...c,data:c.data.slice(p,re)})),[X,p,re]),q=s.useMemo(()=>i?.slice(p,re),[i,p,re]),{minY:ae,maxY:O,yTicks:f}=s.useMemo(()=>{let c;if(g){c=[];for(let S=0;S<te;S++)c.push(K.reduce((Q,oe)=>Q+(oe.data[S]||0),0))}else c=K.flatMap(S=>S.data);c.length===0&&(c=[0]);const F=Math.min(0,...c),J=Math.max(0,...c),se=J-F||1,ne=Math.pow(10,Math.floor(Math.log10(se)))||1,t=Math.floor(F/ne)*ne;let E=Math.ceil(J/ne)*ne;const W=[];for(let S=t;S<=E;S+=ne)W.push(Math.round(S*1e6)/1e6);return W.length<2&&(E=t+ne,W.push(Math.round(E*1e6)/1e6)),{minY:t,maxY:E,yTicks:W}},[K,te,g]),h=c=>V-(c-ae)/(O-ae||1)*V,L=c=>(c+.5)/te*U,ee=te>0?U/te/(g?1.5:Math.max(X.length,1)*1.5):20,ce=s.useCallback(c=>{if(!D)return;c.preventDefault();const F=u??{start:0,end:G},J=F.end-F.start,se=(F.start+F.end)/2,ne=c.deltaY>0?1.2:.8,t=Math.max(2,Math.min(G,Math.round(J*ne))),E=Math.max(0,Math.round(se-t/2)),W=Math.min(G,E+t);w({start:E,end:W})},[D,u,G]),Y=s.useCallback(c=>{D&&(P(!0),H.current={x:c.clientX,range:u??{start:0,end:G}})},[D,u,G]),ie=s.useCallback(c=>{const F=$.current?.getBoundingClientRect();if(F&&T({x:c.clientX-F.left-B.left,y:c.clientY-F.top-B.top}),y&&H.current&&D){const J=c.clientX-H.current.x,se=U/te,ne=-Math.round(J/se),t=H.current.range,E=t.end-t.start;let W=t.start+ne;W<0&&(W=0),W+E>G&&(W=G-E),w({start:W,end:W+E})}},[y,D,U,te,G,B.left,B.top]),he=s.useCallback(()=>{P(!1),H.current=null},[]),ve=s.useCallback(()=>{T(null),P(!1),H.current=null},[]),xe=s.useCallback(()=>{const c=$.current;if(!c)return;const F=new XMLSerializer().serializeToString(c),J=document.createElement("canvas");J.width=m,J.height=a+(b?30:0);const se=J.getContext("2d");if(!se)return;const ne=new Image;ne.onload=()=>{se.fillStyle=le.resolveCssColor("var(--nice-bg-primary, #fff)",se.canvas),se.fillRect(0,0,J.width,J.height),se.drawImage(ne,0,0);const t=document.createElement("a");t.download="chart.png",t.href=J.toDataURL("image/png"),t.click()},ne.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(F)},[m,a,b]),me=a+(b?30:0),ye=K.length>0&&K.every(c=>c.type==="radar"),be=s.useMemo(()=>{if(!ye)return 1;const c=K.flatMap(F=>F.data);return Math.max(1,...c)},[ye,K]);if(ye){const c=m/2,F=(a-B.top-B.bottom)/2+B.top,J=Math.min(U,a-B.top-B.bottom)/2-10,se=q?.length??K[0]?.data.length??0,ne=W=>W/se*Math.PI*2-Math.PI/2,t=(W,S)=>{const Q=S/be*J;return[c+Math.cos(ne(W))*Q,F+Math.sin(ne(W))*Q]},E=4;return e.jsx("div",{className:`nice-chart nice-chart--radar ${I||""}`,style:v,children:e.jsxs("svg",{ref:$,viewBox:`0 0 ${m} ${me}`,preserveAspectRatio:"xMidYMid meet",width:"100%",height:"100%",className:"nice-chart__svg",style:{display:"block",maxWidth:"100%",maxHeight:"100%"},children:[o&&e.jsx("text",{x:m/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:o}),j&&Array.from({length:E},(W,S)=>{const Q=(S+1)/E*J,oe=[];for(let de=0;de<se;de++)oe.push(`${c+Math.cos(ne(de))*Q},${F+Math.sin(ne(de))*Q}`);return e.jsx("polygon",{points:oe.join(" "),fill:"none",className:"nice-chart__grid-line"},S)}),Array.from({length:se},(W,S)=>{const[Q,oe]=t(S,be);return e.jsx("line",{x1:c,y1:F,x2:Q,y2:oe,className:"nice-chart__grid-line"},S)}),C&&q?.map((W,S)=>{const[Q,oe]=t(S,be*1.12);return e.jsx("text",{x:Q,y:oe,textAnchor:"middle",dominantBaseline:"middle",className:"nice-chart__axis-label",children:W},S)}),K.map((W,S)=>{const Q=W.color||Ne[S%Ne.length],oe=W.data.map((de,ue)=>t(ue,de).join(",")).join(" ");return e.jsxs("g",{className:N?"nice-chart__series nice-chart__series--radar nice-chart__series--anim":"nice-chart__series nice-chart__series--radar",children:[e.jsx("polygon",{points:oe,fill:Q,fillOpacity:.2,stroke:Q,strokeWidth:2}),W.data.map((de,ue)=>{const[_e,je]=t(ue,de);return e.jsx("circle",{cx:_e,cy:je,r:3,fill:Q,children:e.jsx("title",{children:`${W.name}: ${de}`})},ue)})]},W.name)}),b&&e.jsx("g",{transform:`translate(${B.left}, ${a})`,children:n.map((W,S)=>{const Q=S*120,oe=_.has(W.name);return e.jsxs("g",{transform:`translate(${Q}, 10)`,style:d?{cursor:"pointer"}:void 0,onClick:()=>Z(W.name),opacity:oe?.35:1,children:[e.jsx("rect",{width:12,height:12,rx:2,fill:W.color||Ne[S%Ne.length]}),e.jsx("text",{x:16,y:10,className:"nice-chart__legend-text",children:W.name})]},W.name)})})]})})}return e.jsxs("div",{className:`nice-chart ${I||""}`,style:v,children:[x&&e.jsx("button",{type:"button",className:"nice-chart__export-btn",onClick:xe,title:"Export PNG","aria-label":"Export PNG",children:e.jsx(le.NiceIcon,{name:"camera",size:16})}),e.jsxs("svg",{ref:$,viewBox:`0 0 ${m} ${me}`,preserveAspectRatio:"xMidYMid meet",width:"100%",height:"100%",style:{display:"block",maxWidth:"100%",maxHeight:"100%"},className:"nice-chart__svg",onWheel:ce,onMouseDown:Y,onMouseMove:ie,onMouseUp:he,onMouseLeave:ve,children:[e.jsxs("g",{transform:`translate(${B.left},${B.top})`,children:[o&&e.jsx("text",{x:U/2,y:-10,textAnchor:"middle",className:"nice-chart__title",children:o}),j&&f.map(c=>e.jsx("line",{x1:0,y1:h(c),x2:U,y2:h(c),className:"nice-chart__grid-line"},`grid-${c}`)),C&&f.map(c=>e.jsx("text",{x:-8,y:h(c)+4,textAnchor:"end",className:"nice-chart__axis-label",children:c},`ylabel-${c}`)),C&&q&&q.map((c,F)=>e.jsx("text",{x:L(F),y:V+20,textAnchor:"middle",className:"nice-chart__axis-label",children:c},F)),z&&e.jsx("text",{x:-B.left+14,y:V/2,textAnchor:"middle",transform:`rotate(-90, -${B.left-14}, ${V/2})`,className:"nice-chart__axis-title",children:z}),k&&e.jsx("text",{x:U/2,y:V+45,textAnchor:"middle",className:"nice-chart__axis-title",children:k}),e.jsx("line",{x1:0,y1:0,x2:0,y2:V,className:"nice-chart__axis"}),e.jsx("line",{x1:0,y1:V,x2:U,y2:V,className:"nice-chart__axis"}),M?.map((c,F)=>{if(c.type==="line"){const J=h(c.value);return e.jsxs("g",{children:[e.jsx("line",{x1:0,y1:J,x2:U,y2:J,stroke:c.color||"var(--nice-color-error, #ef4444)",strokeWidth:1.5,strokeDasharray:c.dash||"6,3"}),c.label&&e.jsx("text",{x:U+4,y:J+4,className:"nice-chart__annotation-label",fill:c.color||"var(--nice-color-error, #ef4444)",children:c.label})]},F)}return e.jsx("text",{x:L(c.value),y:-4,textAnchor:"middle",className:"nice-chart__annotation-label",fill:c.color||"var(--nice-text-muted, #6b7280)",children:c.label},F)}),A&&r&&r.x>=0&&r.x<=U&&r.y>=0&&r.y<=V&&e.jsxs(e.Fragment,{children:[e.jsx("line",{x1:r.x,y1:0,x2:r.x,y2:V,stroke:"var(--nice-text-muted, #9ca3af)",strokeWidth:1,strokeDasharray:"4,2"}),e.jsx("line",{x1:0,y1:r.y,x2:U,y2:r.y,stroke:"var(--nice-text-muted, #9ca3af)",strokeWidth:1,strokeDasharray:"4,2"})]}),K.map((c,F)=>{const J=c.color||Ne[F%Ne.length],se=c.type||"bar";if(se==="bar")return e.jsx("g",{className:N?"nice-chart__series nice-chart__series--bar nice-chart__series--anim":"nice-chart__series nice-chart__series--bar",children:c.data.map((t,E)=>{let W,S;if(g){const oe=K.slice(0,F).reduce((de,ue)=>de+(ue.data[E]||0),0);W=h(oe+t),S=h(oe)-W}else W=h(Math.max(0,t)),S=Math.abs(h(t)-h(0));const Q=g?L(E)-ee/2:L(E)-K.length*ee/2+F*ee;return e.jsx("rect",{x:Q,y:W,width:ee*.9,height:Math.max(0,S),fill:J,rx:2,style:{transformOrigin:`${Q+ee*.9/2}px ${h(0)}px`,...l?{cursor:"pointer"}:{}},onClick:l?()=>l(c.name,p+E,t):void 0,children:e.jsx("title",{children:`${c.name}: ${t}`})},E)})},c.name);if(se==="scatter")return e.jsx("g",{className:N?"nice-chart__series nice-chart__series--scatter nice-chart__series--anim":"nice-chart__series nice-chart__series--scatter",children:c.data.map((t,E)=>e.jsx("circle",{cx:L(E),cy:h(t),r:5,fill:J,fillOpacity:.7,stroke:J,strokeWidth:1.5,style:l?{cursor:"pointer"}:void 0,onClick:l?()=>l(c.name,p+E,t):void 0,children:e.jsx("title",{children:`${c.name}: ${t}`})},E))},c.name);const ne=c.data.map((t,E)=>`${L(E)},${h(t)}`);return e.jsxs("g",{className:N?`nice-chart__series nice-chart__series--${se} nice-chart__series--anim`:`nice-chart__series nice-chart__series--${se}`,children:[se==="area"&&te>0&&e.jsx("polygon",{points:`${L(0)},${h(0)} ${ne.join(" ")} ${L(te-1)},${h(0)}`,fill:J,opacity:.15}),e.jsx("polyline",{points:ne.join(" "),fill:"none",stroke:J,strokeWidth:2,className:N?"nice-chart__line":void 0}),c.data.map((t,E)=>e.jsx("circle",{cx:L(E),cy:h(t),r:3,fill:J,style:l?{cursor:"pointer"}:void 0,onClick:l?()=>l(c.name,p+E,t):void 0,children:e.jsx("title",{children:`${c.name}: ${t}`})},E))]},c.name)})]}),b&&e.jsx("g",{transform:`translate(${B.left}, ${a})`,children:n.map((c,F)=>{const J=F*120,se=_.has(c.name);return e.jsxs("g",{transform:`translate(${J}, 10)`,style:d?{cursor:"pointer"}:void 0,onClick:()=>Z(c.name),opacity:se?.35:1,children:[e.jsx("rect",{width:12,height:12,rx:2,fill:c.color||Ne[F%Ne.length]}),e.jsx("text",{x:16,y:10,className:"nice-chart__legend-text",style:se?{textDecoration:"line-through"}:void 0,children:c.name})]},c.name)})})]})]})},Ve=Object.freeze(Object.defineProperty({__proto__:null,NiceChart:we},Symbol.toStringTag,{value:"Module"})),Xe=({value:n,min:i=0,max:m=100,width:a=200,height:o=200,startAngle:b=225,endAngle:j=-45,color:C="var(--nice-color-primary, #3b82f6)",trackColor:z,label:k,formatValue:g,ranges:N,className:D,style:A})=>{const M=a/2,d=o/2,l=Math.min(M,d)-20,x=Math.max(0,Math.min(1,(n-i)/(m-i||1))),I=u=>u*Math.PI/180,v=(b-j+360)%360||360,$=u=>({x:M+l*Math.cos(I(u)),y:d-l*Math.sin(I(u))}),_=(u,w)=>{const y=$(u),P=$(w),X=(u-w+360)%360>180?1:0;return`M${y.x},${y.y} A${l},${l} 0 ${X},1 ${P.x},${P.y}`},R=b-x*v,r=$(R);let T=C;if(N){for(const u of N)if(n>=u.start&&n<=u.end){T=u.color;break}}return e.jsx("div",{className:`nice-gauge nice-gauge--circular ${D||""}`,style:A,children:e.jsxs("svg",{width:a,height:o,children:[e.jsx("path",{d:_(b,j),fill:"none",stroke:z||"var(--nice-border-color, #e2e8f0)",strokeWidth:12,strokeLinecap:"round"}),x>0&&e.jsx("path",{d:_(b,R),fill:"none",stroke:T,strokeWidth:12,strokeLinecap:"round"}),e.jsx("line",{x1:M,y1:d,x2:r.x,y2:r.y,stroke:"var(--nice-text-primary, #333)",strokeWidth:2,strokeLinecap:"round"}),e.jsx("circle",{cx:M,cy:d,r:4,fill:"var(--nice-text-primary, #333)"}),e.jsx("text",{x:M,y:d+l*.6,textAnchor:"middle",className:"nice-gauge__value",children:g?g(n):n}),k&&e.jsx("text",{x:M,y:d+l*.95,textAnchor:"middle",className:"nice-gauge__label",children:k})]})})},Ze=({value:n,min:i=0,max:m=100,width:a=300,height:o=60,orientation:b="horizontal",color:j="var(--nice-color-primary, #3b82f6)",label:C,formatValue:z,ranges:k,showTicks:g=!0,tickCount:N=5,className:D,style:A})=>{const M=b==="horizontal",d=M?a-40:o-40,l=Math.max(0,Math.min(1,(n-i)/(m-i||1))),x=10;let I=j;if(k){for(const $ of k)if(n>=$.start&&n<=$.end){I=$.color;break}}const v=Array.from({length:N},($,_)=>i+(m-i)*(_/(N-1)));return M?e.jsx("div",{className:`nice-gauge nice-gauge--linear ${D||""}`,style:A,children:e.jsxs("svg",{width:a,height:o,children:[e.jsx("text",{x:20+d*l,y:14,textAnchor:"middle",className:"nice-gauge__value",style:{fontSize:12},children:z?z(n):n}),e.jsx("rect",{x:20,y:o/2-x/2,width:d,height:x,rx:5,fill:"var(--nice-border-color, #e2e8f0)"}),e.jsx("rect",{x:20,y:o/2-x/2,width:d*l,height:x,rx:5,fill:I}),e.jsx("polygon",{points:`${20+d*l},${o/2-x/2-2} ${20+d*l-5},${o/2-x/2-8} ${20+d*l+5},${o/2-x/2-8}`,fill:"var(--nice-text-primary, #333)"}),g&&v.map(($,_)=>{const R=20+($-i)/(m-i)*d;return e.jsx("text",{x:R,y:o/2+x/2+12,textAnchor:"middle",className:"nice-gauge__tick",children:$},_)}),C&&e.jsx("text",{x:a/2,y:o-2,textAnchor:"middle",className:"nice-gauge__label",children:C})]})}):e.jsx("div",{className:`nice-gauge nice-gauge--linear nice-gauge--vertical ${D||""}`,style:A,children:e.jsxs("svg",{width:a,height:o,children:[e.jsx("rect",{x:a/2-x/2,y:20,width:x,height:d,rx:5,fill:"var(--nice-border-color, #e2e8f0)"}),e.jsx("rect",{x:a/2-x/2,y:20+d*(1-l),width:x,height:d*l,rx:5,fill:I}),e.jsx("text",{x:a/2,y:14,textAnchor:"middle",className:"nice-gauge__value",children:z?z(n):n}),C&&e.jsx("text",{x:a/2,y:o-4,textAnchor:"middle",className:"nice-gauge__label",children:C})]})})},ge=["#3b82f6","#ef4444","#22c55e","#f59e0b","#8b5cf6","#ec4899","#06b6d4","#84cc16"],Ue=({items:n,min:i=0,max:m=100,width:a=300,height:o=300,startAngle:b=225,endAngle:j=-45,formatValue:C,title:z,className:k,style:g})=>{const N=a/2,D=o/2,A=Math.min(N,D)-30,M=Math.min(20,A/(n.length+1)),d=4,l=v=>v*Math.PI/180,x=(b-j+360)%360||360,I=(v,$,_)=>{const R=N+v*Math.cos(l($)),r=D-v*Math.sin(l($)),T=N+v*Math.cos(l(_)),u=D-v*Math.sin(l(_)),w=($-_+360)%360;return`M${R},${r} A${v},${v} 0 ${w>180?1:0},1 ${T},${u}`};return e.jsx("div",{className:`nice-bargauge ${k||""}`,style:g,children:e.jsxs("svg",{width:a,height:o,children:[z&&e.jsx("text",{x:N,y:20,textAnchor:"middle",className:"nice-chart__title",children:z}),n.map((v,$)=>{const _=A-$*(M+d),R=Math.max(0,Math.min(1,(v.value-i)/(m-i||1))),r=b-R*x,T=v.color||ge[$%ge.length];return e.jsxs("g",{children:[e.jsx("path",{d:I(_,b,j),fill:"none",stroke:"var(--nice-border-color, #e2e8f0)",strokeWidth:M,strokeLinecap:"round"}),R>0&&e.jsx("path",{d:I(_,b,r),fill:"none",stroke:T,strokeWidth:M,strokeLinecap:"round"})]},$)}),e.jsx("g",{children:n.map((v,$)=>e.jsxs("text",{x:N,y:D-((n.length-1)/2-$)*16,textAnchor:"middle",dominantBaseline:"middle",className:"nice-gauge__value",style:{fontSize:12},children:[v.label?`${v.label}: `:"",C?C(v.value):v.value]},$))})]})})},Ge={sm:{width:160,height:22,fontSize:11},md:{width:220,height:32,fontSize:12},lg:{width:320,height:44,fontSize:14}},qe=({value:n,target:i,min:m=0,max:a=100,width:o,height:b,color:j="var(--nice-color-primary, #3b82f6)",targetColor:C="var(--nice-color-error, #ef4444)",size:z="md",label:k,labelPlacement:g="top",showValue:N=!1,showTarget:D=!1,formatValue:A=I=>String(I),state:M="normal",errorMessage:d,className:l,style:x})=>{const I=Ge[z],v=o??I.width,$=b??I.height,_=I.fontSize,R=4,r=v-R*2,T=D&&i!=null?_+4:R,u=D&&i!=null?$+(T-R):$,w=u-T-R,y=Math.max(0,Math.min(1,(n-m)/(a-m||1))),P=i!=null?Math.max(0,Math.min(1,(i-m)/(a-m||1))):null,H=()=>M==="error"?e.jsx("div",{role:"alert",style:{width:v,height:u,display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed var(--nice-color-error, #ef4444)",borderRadius:4,color:"var(--nice-color-error, #ef4444)",fontSize:_,padding:"0 8px",boxSizing:"border-box"},children:d??"Error"}):M==="loading"?e.jsx("div",{role:"status","aria-label":"Loading",className:"nice-bullet__skeleton",style:{width:v,height:u,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:v,height:u,role:"img","aria-label":typeof k=="string"?k:void 0,children:[e.jsx("rect",{x:R,y:T,width:r,height:w,rx:3,fill:"var(--nice-border-color, #e2e8f0)"}),e.jsx("rect",{x:R,y:T+w*.2,width:r*y,height:w*.6,rx:2,fill:j}),P!=null&&e.jsx("line",{x1:R+r*P,y1:T+2,x2:R+r*P,y2:T+w-2,stroke:C,strokeWidth:2}),N&&e.jsx("text",{x:R+Math.max(r*y,4),y:T+w/2,dx:r*y>24?-4:4,textAnchor:r*y>24?"end":"start",dominantBaseline:"middle",fontSize:_,fill:r*y>24?"var(--nice-color-white, #ffffff)":"var(--nice-text-primary)",fontWeight:600,children:A(n)}),D&&P!=null&&e.jsx("text",{x:R+r*P,y:T-2,textAnchor:"middle",fontSize:_-1,fill:C,fontWeight:600,children:A(i)})]});if(g==="none"||!k)return e.jsxs("div",{className:`nice-bullet ${l||""}`,style:x,children:[H(),e.jsx("style",{children:Ae})]});const X=g==="top"||g==="bottom",Z=e.jsx("span",{className:"nice-bullet__label",style:{fontSize:_,fontWeight:600,color:"var(--nice-text-primary)",...X?{marginBottom:g==="top"?4:0,marginTop:g==="bottom"?4:0}:{},...g==="left"?{marginRight:8}:{},...g==="right"?{marginLeft:8}:{}},children:k});return e.jsxs("div",{className:`nice-bullet nice-bullet--${g} ${l||""}`,style:{display:"inline-flex",flexDirection:X?"column":"row",alignItems:X?"flex-start":"center",...x},children:[(g==="top"||g==="left")&&Z,H(),(g==="bottom"||g==="right")&&Z,e.jsx("style",{children:Ae})]})},Ae=`
|
|
2
|
+
@keyframes nice-bullet-shimmer {
|
|
3
|
+
0% { background-position: 200% 0; }
|
|
4
|
+
100% { background-position: -200% 0; }
|
|
5
|
+
}
|
|
6
|
+
`,Je=({data:n,width:i=400,height:m=400,innerRadius:a=0,title:o,showLegend:b=!0,showLabels:j=!0,className:C,style:z})=>{const k=i/2,g=(m-(b?30:0))/2+(o?10:0),N=Math.min(k,g)-40,D=n.reduce((d,l)=>d+l.value,0);let A=-Math.PI/2;const M=n.map((d,l)=>{const x=d.value/(D||1)*Math.PI*2,I=A;A+=x;const v=A,$=(I+v)/2,_=k+N*Math.cos(I),R=g+N*Math.sin(I),r=k+N*Math.cos(v),T=g+N*Math.sin(v),u=x>Math.PI?1:0,w=d.color||ge[l%ge.length],y=x>=Math.PI*2-1e-9;let P;if(y){const B=(U,V)=>`M${k-U},${g} A${U},${U} 0 1,${V} ${k+U},${g} A${U},${U} 0 1,${V} ${k-U},${g} Z`;P=a>0?`${B(N,1)} ${B(a,0)}`:B(N,1)}else if(a>0){const B=k+a*Math.cos(I),U=g+a*Math.sin(I),V=k+a*Math.cos(v),G=g+a*Math.sin(v);P=`M${_},${R} A${N},${N} 0 ${u},1 ${r},${T} L${V},${G} A${a},${a} 0 ${u},0 ${B},${U} Z`}else P=`M${k},${g} L${_},${R} A${N},${N} 0 ${u},1 ${r},${T} Z`;const H=y?k:k+N*.7*Math.cos($),X=y?g:g+N*.7*Math.sin($),Z=D>0?Math.round(d.value/D*100):0;return{...d,path:P,labelX:H,labelY:X,pct:Z,color:w}});return e.jsx("div",{className:`nice-piechart ${C||""}`,style:z,children:e.jsxs("svg",{viewBox:`0 0 ${i} ${m}`,preserveAspectRatio:"xMidYMid meet",width:"100%",height:"100%",style:{display:"block",maxWidth:"100%",maxHeight:"100%"},className:"nice-piechart__svg",children:[o&&e.jsx("text",{x:k,y:20,textAnchor:"middle",className:"nice-chart__title",children:o}),M.map((d,l)=>e.jsxs("g",{children:[e.jsx("path",{d:d.path,fill:d.color,stroke:"var(--nice-bg-primary, #fff)",strokeWidth:2,children:e.jsx("title",{children:`${d.label}: ${d.value} (${d.pct}%)`})}),j&&d.pct>=5&&e.jsxs("text",{x:d.labelX,y:d.labelY,textAnchor:"middle",dominantBaseline:"middle",className:"nice-piechart__label",children:[d.pct,"%"]})]},l)),b&&e.jsx("g",{transform:`translate(10, ${m-25})`,children:n.map((d,l)=>e.jsxs("g",{transform:`translate(${l*100}, 0)`,children:[e.jsx("rect",{width:10,height:10,rx:2,fill:d.color||ge[l%ge.length]}),e.jsx("text",{x:14,y:9,className:"nice-chart__legend-text",children:d.label})]},l))})]})})},Ke=({data:n,width:i=400,height:m=300,inverted:a,showLabels:o=!0,showValues:b=!0,title:j,className:C,style:z})=>{const k={top:j?30:10,bottom:10,x:40},g=i-k.x*2,N=m-k.top-k.bottom,D=a?[...n].reverse():n,A=Math.max(...D.map(d=>d.value),1),M=N/D.length;return e.jsx("div",{className:`nice-funnel ${C||""}`,style:z,children:e.jsxs("svg",{width:i,height:m,children:[j&&e.jsx("text",{x:i/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:j}),D.map((d,l)=>{const x=d.value/A*g,I=l<D.length-1?D[l+1].value/A*g:x*.3,v=k.top+l*M,$=v+M,_=i/2,R=`${_-x/2},${v} ${_+x/2},${v} ${_+I/2},${$} ${_-I/2},${$}`,r=d.color||ge[l%ge.length];return e.jsxs("g",{children:[e.jsx("polygon",{points:R,fill:r,stroke:"var(--nice-bg-primary, #fff)",strokeWidth:1,children:e.jsx("title",{children:`${d.label}: ${d.value}`})}),o&&e.jsx("text",{x:_,y:v+M/2-(b?4:0),textAnchor:"middle",dominantBaseline:"middle",className:"nice-funnel__label",children:d.label}),b&&e.jsx("text",{x:_,y:v+M/2+10,textAnchor:"middle",dominantBaseline:"middle",className:"nice-funnel__value",children:d.value})]},l)})]})})};function Qe(n,i,m){const a=A=>{const M=A.replace("#","");return[parseInt(M.slice(0,2),16),parseInt(M.slice(2,4),16),parseInt(M.slice(4,6),16)]},[o,b,j]=a(n),[C,z,k]=a(i),g=Math.round(o+(C-o)*m),N=Math.round(b+(z-b)*m),D=Math.round(j+(k-j)*m);return`rgb(${g},${N},${D})`}const Le=s.forwardRef(({data:n,xLabels:i,yLabels:m,colors:a=["var(--nice-primary-bg, #e0f2fe)","var(--nice-color-primary-active, #1d4ed8)"],onCellClick:o,cellSize:b=40,showValues:j=!0,className:C,style:z,id:k},g)=>{const N=le.useControlId(k),{minVal:D,maxVal:A}=s.useMemo(()=>{let d=1/0,l=-1/0;for(const x of n)for(const I of x)I<d&&(d=I),I>l&&(l=I);return{minVal:d,maxVal:l}},[n]),M=s.useCallback(d=>A===D?.5:(d-D)/(A-D),[D,A]);return e.jsx("div",{ref:g,id:N,className:`nice-heatmap ${C||""}`,style:z,children:e.jsxs("table",{className:"nice-heatmap__table",children:[i&&e.jsx("thead",{children:e.jsxs("tr",{children:[m&&e.jsx("th",{}),i.map((d,l)=>e.jsx("th",{className:"nice-heatmap__header",children:d},l))]})}),e.jsx("tbody",{children:n.map((d,l)=>e.jsxs("tr",{children:[m&&e.jsx("th",{className:"nice-heatmap__row-label",children:m[l]}),d.map((x,I)=>e.jsx("td",{className:"nice-heatmap__cell",style:{background:Qe(a[0],a[1],M(x)),width:b,height:b,textAlign:"center",color:M(x)>.6?"var(--nice-color-white, #fff)":"var(--nice-text-primary, #333)",cursor:o?"pointer":void 0},onClick:()=>o?.(l,I,x),title:String(x),children:j?x:""},I))]},l))})]})})});Le.displayName="NiceHeatMap";const De=({nodes:n,links:i,width:m=600,height:a=400,nodeWidth:o=20,nodePadding:b=10,title:j,className:C,style:z})=>{const k={top:j?40:20,bottom:20,left:20,right:20},g=m-k.left-k.right,N=a-k.top-k.bottom,D=new Set(i.map(u=>u.source)),A=new Set(i.map(u=>u.target)),M=n.filter(u=>D.has(u.id)&&!A.has(u.id)),d=n.filter(u=>A.has(u.id)),l=n.filter(u=>D.has(u.id)&&A.has(u.id)),x=[M,...l.length?[l]:[],d].filter(u=>u.length>0),I=x.length,v=new Map;n.forEach(u=>{const w=i.filter(P=>P.source===u.id).reduce((P,H)=>P+H.value,0),y=i.filter(P=>P.target===u.id).reduce((P,H)=>P+H.value,0);v.set(u.id,Math.max(w,y))});const $=x.map(u=>u.reduce((w,y)=>w+(v.get(y.id)||0),0)+(u.length-1)*b),_=Math.max(...$,1),R=new Map;x.forEach((u,w)=>{const y=k.left+w/(I-1||1)*(g-o);let P=0;u.forEach(H=>{const X=(v.get(H.id)||0)/_*N;R.set(H.id,{x:y,y:k.top+P,h:X}),P+=X+b})});const r=new Map,T=new Map;return n.forEach(u=>{r.set(u.id,0),T.set(u.id,0)}),e.jsx("div",{className:`nice-sankey ${C||""}`,style:z,children:e.jsxs("svg",{width:m,height:a,children:[j&&e.jsx("text",{x:m/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:j}),i.map((u,w)=>{const y=R.get(u.source),P=R.get(u.target);if(!y||!P)return null;const H=r.get(u.source)||0,X=T.get(u.target)||0,Z=u.value/_*N;r.set(u.source,H+Z),T.set(u.target,X+Z);const B=y.x+o,U=y.y+H,V=P.x,G=P.y+X,p=(B+V)/2,te=n.find(K=>K.id===u.source)?.color||ge[w%ge.length];return e.jsx("path",{d:`M${B},${U} C${p},${U} ${p},${G} ${V},${G} L${V},${G+Z} C${p},${G+Z} ${p},${U+Z} ${B},${U+Z} Z`,fill:te,fillOpacity:.3,stroke:te,strokeOpacity:.5,strokeWidth:.5,children:e.jsx("title",{children:`${u.source} → ${u.target}: ${u.value}`})},w)}),n.map((u,w)=>{const y=R.get(u.id);if(!y)return null;const P=u.color||ge[w%ge.length];return e.jsxs("g",{children:[e.jsx("rect",{x:y.x,y:y.y,width:o,height:Math.max(y.h,2),fill:P,rx:2}),e.jsx("text",{x:y.x<g/2?y.x+o+4:y.x-4,y:y.y+y.h/2,textAnchor:y.x<g/2?"start":"end",dominantBaseline:"middle",className:"nice-chart__legend-text",children:u.label})]},u.id)})]})})},et=Object.freeze(Object.defineProperty({__proto__:null,NiceSankey:De},Symbol.toStringTag,{value:"Module"}));function tt(n,i){const m=n.reduce((k,g)=>k+g.value,0);if(m===0||n.length===0)return[];const a=[];let{x:o,y:b,w:j,h:C}=i;const z=[...n].sort((k,g)=>g.value-k.value);for(const k of z){const g=k.value/m;if(j>=C){const N=j*g;a.push({x:o,y:b,w:N,h:C,node:k}),o+=N,j-=N}else{const N=C*g;a.push({x:o,y:b,w:j,h:N,node:k}),b+=N,C-=N}}return a}const nt=["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)"],Ie=s.forwardRef(({data:n,width:i=600,height:m=400,onNodeClick:a,colors:o=nt,className:b,style:j,id:C},z)=>{const k=le.useControlId(C),g=s.useMemo(()=>{const N=n.children??[n];return tt(N,{x:0,y:0,w:i,h:m})},[n,i,m]);return e.jsx("div",{ref:z,id:k,className:`nice-treemap ${b||""}`,style:j,children:e.jsx("svg",{width:i,height:m,className:"nice-treemap__svg",children:g.map((N,D)=>e.jsxs("g",{onClick:()=>a?.(N.node),style:{cursor:a?"pointer":void 0},children:[e.jsx("rect",{x:N.x,y:N.y,width:Math.max(N.w-1,0),height:Math.max(N.h-1,0),fill:N.node.color??o[D%o.length],rx:2}),N.w>40&&N.h>20&&e.jsx("text",{x:N.x+N.w/2,y:N.y+N.h/2,textAnchor:"middle",dominantBaseline:"central",fill:"var(--nice-color-white, #fff)",fontSize:Math.min(12,N.w/6),className:"nice-treemap__label",children:N.node.label})]},N.node.key))})})});Ie.displayName="NiceTreeMap";const rt=Object.freeze(Object.defineProperty({__proto__:null,NiceTreeMap:Ie},Symbol.toStringTag,{value:"Module"})),Te=({regions:n,width:i=600,height:m=400,viewBox:a="0 0 1000 600",colorRange:o=["#dbeafe","#1d4ed8"],maxValue:b,onRegionClick:j,selectedRegionId:C,title:z,showTooltip:k=!0,className:g,style:N})=>{const D=b??Math.max(...n.map(M=>M.value??0),1),A=M=>{const d=u=>[parseInt(u.slice(1,3),16),parseInt(u.slice(3,5),16),parseInt(u.slice(5,7),16)],[l,x,I]=d(o[0]),[v,$,_]=d(o[1]),R=Math.round(l+(v-l)*M),r=Math.round(x+($-x)*M),T=Math.round(I+(_-I)*M);return`rgb(${R},${r},${T})`};return e.jsxs("div",{className:`nice-vectormap ${g||""}`,style:N,children:[z&&e.jsx("div",{className:"nice-vectormap__title",children:z}),e.jsx("svg",{width:i,height:m,viewBox:a,children:n.map(M=>{const d=M.value!=null?Math.max(0,Math.min(1,M.value/D)):0,l=M.value!=null?A(d):"var(--nice-bg-tertiary, #e5e7eb)",x=M.id===C;return e.jsx("path",{d:M.path,fill:l,stroke:x?"var(--nice-color-primary, #3b82f6)":"var(--nice-border-color, #d1d5db)",strokeWidth:x?2:.5,cursor:j?"pointer":void 0,onClick:()=>j?.(M),children:k&&e.jsx("title",{children:`${M.name}${M.value!=null?`: ${M.value}`:""}`})},M.id)})})]})},at=Object.freeze(Object.defineProperty({__proto__:null,NiceVectorMap:Te},Symbol.toStringTag,{value:"Module"})),Be=s.forwardRef(({data:n,renderNode:i,selectable:m,selectedKey:a,onSelect:o,direction:b="top-down",collapsible:j=!0,className:C,style:z,id:k},g)=>{const N=le.useControlId(k),[D,A]=s.useState(new Set),M=s.useCallback(x=>{A(I=>{const v=new Set(I);return v.has(x)?v.delete(x):v.add(x),v})},[]),d=s.useCallback(x=>{m&&o?.(x)},[m,o]),l=s.useCallback(x=>{const I=D.has(x.key),v=x.children&&x.children.length>0;return e.jsxs("li",{className:"nice-org-chart__item",children:[e.jsxs("div",{className:`nice-org-chart__node${a===x.key?" nice-org-chart__node--selected":""}`,onClick:()=>d(x.key),role:m?"button":void 0,children:[i?i(x):e.jsx("span",{children:x.label}),j&&v&&e.jsx("button",{type:"button",className:"nice-org-chart__toggle",onClick:$=>{$.stopPropagation(),M(x.key)},"aria-label":I?"Expand":"Collapse",children:e.jsx(le.NiceIcon,{name:I?"plus":"minus",size:14})})]}),v&&!I&&e.jsx("ul",{className:"nice-org-chart__children",children:x.children.map($=>l($))})]},x.key)},[D,a,i,m,j,d,M]);return e.jsx("div",{ref:g,id:N,className:`nice-org-chart nice-org-chart--${b} ${C||""}`,style:z,children:e.jsx("ul",{className:"nice-org-chart__root",children:l(n)})})});Be.displayName="NiceOrganizationChart";const Ee=s.forwardRef(({data:n,type:i="candlestick",showVolume:m=!0,width:a=800,height:o=400,bullColor:b="var(--nice-color-success, #22c55e)",bearColor:j="var(--nice-color-error, #ef4444)",className:C,style:z,id:k},g)=>{const N=le.useControlId(k),D={top:20,right:20,bottom:m?80:30,left:60},A=a-D.left-D.right,M=m?50:0,d=o-D.top-D.bottom-M,{minP:l,maxP:x,maxVol:I}=s.useMemo(()=>{let r=1/0,T=-1/0,u=0;for(const w of n)w.low<r&&(r=w.low),w.high>T&&(T=w.high),w.volume&&w.volume>u&&(u=w.volume);return{minP:r,maxP:T,maxVol:u}},[n]),v=Math.max(1,A/n.length*.7),$=r=>D.left+(r+.5)*(A/n.length),_=r=>D.top+d-(r-l)/(x-l||1)*d,R=r=>o-D.bottom-M+M*(1-r/(I||1));return e.jsx("div",{ref:g,id:N,className:`nice-stock-chart ${C||""}`,style:z,children:e.jsxs("svg",{width:a,height:o,className:"nice-stock-chart__svg",children:[[0,.25,.5,.75,1].map(r=>{const T=l+r*(x-l);return e.jsxs("g",{children:[e.jsx("line",{x1:D.left,x2:a-D.right,y1:_(T),y2:_(T),stroke:"var(--nice-border, #e5e7eb)",strokeDasharray:"2,2"}),e.jsx("text",{x:D.left-4,y:_(T)+4,textAnchor:"end",fontSize:10,fill:"var(--nice-text-secondary, #888)",children:T.toFixed(2)})]},r)}),i==="line"?e.jsx("polyline",{points:n.map((r,T)=>`${$(T)},${_(r.close)}`).join(" "),fill:"none",stroke:b,strokeWidth:1.5}):n.map((r,T)=>{const u=r.close>=r.open,w=u?b:j,y=$(T);if(i==="ohlc")return e.jsxs("g",{children:[e.jsx("line",{x1:y,x2:y,y1:_(r.high),y2:_(r.low),stroke:w,strokeWidth:1}),e.jsx("line",{x1:y-v/2,x2:y,y1:_(r.open),y2:_(r.open),stroke:w,strokeWidth:1.5}),e.jsx("line",{x1:y,x2:y+v/2,y1:_(r.close),y2:_(r.close),stroke:w,strokeWidth:1.5})]},T);const P=_(Math.max(r.open,r.close)),H=_(Math.min(r.open,r.close));return e.jsxs("g",{children:[e.jsx("line",{x1:y,x2:y,y1:_(r.high),y2:_(r.low),stroke:w,strokeWidth:1}),e.jsx("rect",{x:y-v/2,y:P,width:v,height:Math.max(H-P,1),fill:u?"transparent":w,stroke:w,strokeWidth:1})]},T)}),m&&n.map((r,T)=>{if(!r.volume)return null;const u=r.close>=r.open;return e.jsx("rect",{x:$(T)-v/2,y:R(r.volume),width:v,height:o-D.bottom-R(r.volume),fill:u?b:j,opacity:.3},`v${T}`)}),n.map((r,T)=>T%Math.max(1,Math.floor(n.length/8))!==0?null:e.jsx("text",{x:$(T),y:o-D.bottom+M+14,textAnchor:"middle",fontSize:9,fill:"var(--nice-text-secondary, #888)",children:r.date},`l${T}`))]})})});Ee.displayName="NiceStockChart";const ct=({data:n,width:i=120,height:m=30,type:a="line",color:o="var(--nice-color-primary, #3b82f6)",showMinMax:b,showLastPoint:j=!0,className:C,style:z})=>{if(n.length===0)return null;const k=2,g=Math.min(...n),N=Math.max(...n),D=N-g||1,A=i-k*2,M=m-k*2,d=_=>k+_/(n.length-1||1)*A,l=_=>k+M-(_-g)/D*M;if(a==="bar"){const _=Math.max(1,A/n.length-1);return e.jsx("svg",{width:i,height:m,className:`nice-sparkline ${C||""}`,style:z,children:n.map((R,r)=>e.jsx("rect",{x:k+r/n.length*A,y:l(R),width:_,height:M-(l(R)-k),fill:o,rx:1},r))})}const x=n.map((_,R)=>`${d(R)},${l(_)}`).join(" "),I=n.indexOf(g),v=n.indexOf(N),$=n.length-1;return e.jsxs("svg",{width:i,height:m,className:`nice-sparkline ${C||""}`,style:z,children:[a==="area"&&e.jsx("polygon",{points:`${d(0)},${k+M} ${x} ${d($)},${k+M}`,fill:o,opacity:.15}),e.jsx("polyline",{points:x,fill:"none",stroke:o,strokeWidth:1.5}),b&&e.jsx("circle",{cx:d(I),cy:l(g),r:2,fill:"var(--nice-danger, #ef4444)"}),b&&e.jsx("circle",{cx:d(v),cy:l(N),r:2,fill:"var(--nice-success, #22c55e)"}),j&&e.jsx("circle",{cx:d($),cy:l(n[$]),r:2,fill:o})]})},st=({series:n,categories:i,width:m=400,height:a=400,maxValue:o,title:b,showLegend:j=!0,className:C,style:z})=>{const k=m/2,g=(a-(j?30:0))/2+(b?10:0),N=Math.min(k,g)-60,D=i.length,A=o??Math.max(...n.flatMap(x=>x.data),1),M=Math.PI*2/D,d=5,l=(x,I)=>{const v=x*M-Math.PI/2,$=I/A*N;return{x:k+$*Math.cos(v),y:g+$*Math.sin(v)}};return e.jsx("div",{className:`nice-polarchart ${C||""}`,style:z,children:e.jsxs("svg",{width:m,height:a,className:"nice-polarchart__svg",children:[b&&e.jsx("text",{x:k,y:20,textAnchor:"middle",className:"nice-chart__title",children:b}),Array.from({length:d},(x,I)=>{const v=N*((I+1)/d);return e.jsx("circle",{cx:k,cy:g,r:v,fill:"none",stroke:"var(--nice-border-color, #ddd)",strokeWidth:.5},I)}),i.map((x,I)=>{const v=l(I,A),$=l(I,A*1.22),_=I*M-Math.PI/2,R=Math.cos(_),r=Math.sin(_),T=R>.2?"start":R<-.2?"end":"middle",u=r>.2?"hanging":r<-.2?"auto":"middle";return e.jsxs("g",{children:[e.jsx("line",{x1:k,y1:g,x2:v.x,y2:v.y,stroke:"var(--nice-border-color, #ddd)",strokeWidth:.5}),e.jsx("text",{x:$.x,y:$.y,textAnchor:T,dominantBaseline:u,className:"nice-chart__axis-label nice-chart__axis-label--polar",children:x})]},I)}),n.map((x,I)=>{const v=x.color||ge[I%ge.length],$=x.data.map((_,R)=>{const r=l(R,_);return`${r.x},${r.y}`}).join(" ");return e.jsxs("g",{children:[e.jsx("polygon",{points:$,fill:x.fill!==!1?v:"none",fillOpacity:.15,stroke:v,strokeWidth:2}),x.data.map((_,R)=>{const r=l(R,_);return e.jsx("circle",{cx:r.x,cy:r.y,r:3,fill:v,children:e.jsx("title",{children:`${x.name} - ${i[R]}: ${_}`})},R)})]},x.name)}),j&&e.jsx("g",{transform:`translate(10, ${a-25})`,children:n.map((x,I)=>e.jsxs("g",{transform:`translate(${I*100}, 0)`,children:[e.jsx("rect",{width:10,height:10,rx:2,fill:x.color||ge[I%ge.length]}),e.jsx("text",{x:14,y:9,className:"nice-chart__legend-text",children:x.name})]},I))})]})})},it=({data:n,min:i,max:m,start:a,end:o,onChange:b,width:j=500,height:C=100,step:z=1,formatValue:k,chartColor:g="var(--nice-color-primary, #3b82f6)",className:N,style:D})=>{const A={top:10,bottom:30,left:10,right:10},M=j-A.left-A.right,d=C-A.top-A.bottom,l=R=>A.left+(R-i)/(m-i||1)*M,x=R=>{const r=Math.max(0,Math.min(1,(R-A.left)/M)),T=i+r*(m-i);return Math.round(T/z)*z},I=(R,r)=>{r.preventDefault();const T=r.target.closest("svg");if(!T)return;const u=y=>{const P=T.getBoundingClientRect(),H=x(y.clientX-P.left);R==="start"?b(Math.min(H,o),o):b(a,Math.max(H,a))},w=()=>{document.removeEventListener("pointermove",u),document.removeEventListener("pointerup",w)};document.addEventListener("pointermove",u),document.addEventListener("pointerup",w)},v=n?Math.min(...n):0,_=(n?Math.max(...n):1)-v||1;return e.jsx("div",{className:`nice-rangeselector ${N||""}`,style:D,children:e.jsxs("svg",{width:j,height:C,children:[n&&n.length>1&&e.jsx("polygon",{points:`${A.left},${A.top+d} ${n.map((R,r)=>`${A.left+r/(n.length-1)*M},${A.top+d-(R-v)/_*d}`).join(" ")} ${A.left+M},${A.top+d}`,fill:g,opacity:.15}),e.jsx("rect",{x:l(a),y:A.top,width:l(o)-l(a),height:d,fill:g,opacity:.1}),e.jsx("rect",{x:A.left,y:A.top,width:l(a)-A.left,height:d,fill:"var(--nice-bg-secondary, #f5f5f5)",opacity:.6}),e.jsx("rect",{x:l(o),y:A.top,width:A.left+M-l(o),height:d,fill:"var(--nice-bg-secondary, #f5f5f5)",opacity:.6}),e.jsx("rect",{x:l(a)-4,y:A.top,width:8,height:d,fill:g,rx:2,cursor:"ew-resize",onPointerDown:R=>I("start",R)}),e.jsx("rect",{x:l(o)-4,y:A.top,width:8,height:d,fill:g,rx:2,cursor:"ew-resize",onPointerDown:R=>I("end",R)}),e.jsx("text",{x:l(a),y:A.top+d+18,textAnchor:"middle",className:"nice-chart__axis-label",children:k?k(a):a}),e.jsx("text",{x:l(o),y:A.top+d+18,textAnchor:"middle",className:"nice-chart__axis-label",children:k?k(o):o})]})})},ot=`
|
|
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
|
+
`,ze=["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 pe(n){return n instanceof Date?n:new Date(n)}function Ce(n,i="pl-PL"){return n.toLocaleDateString(i,{year:"numeric",month:"short",day:"numeric"})}function Me(n,i="pl-PL"){return new Intl.NumberFormat(i,{minimumFractionDigits:0,maximumFractionDigits:2}).format(n)}const lt=s.forwardRef(function(i,m){const{scenarios:a,data:o,annotations:b=[],referenceLines:j=[],forecastStartDate:C,cashRunway:z,xAxis:k,yAxis:g,confidenceBands:N=[{level:95,color:"var(--nice-color-primary, #3b82f6)",opacity:.15}],tooltip:D,legend:A={enabled:!0,position:"bottom",interactive:!0},height:M=350,showForecastRegion:d=!0,lineWidth:l=2,showPoints:x=!1,pointRadius:I=4,enableZoom:v=!1,zoomEnabled:$,animationDuration:_=300,showLegend:R,responsive:r=!0,onPointClick:T,onAnnotationClick:u,onScenarioToggle:w,onViewportChange:y,size:P="medium",disabled:H=!1,labels:X={},locale:Z="pl-PL",className:B,style:U}=i,V=a&&a.length>0?a:o?[{id:"default",name:"Series",data:o}]:[],G={...A,enabled:R??A.enabled},[p,re]=s.useState(()=>V.map((t,E)=>({...t,color:t.color??ze[E%ze.length],visible:t.visible!==!1}))),[te,K]=s.useState(null),[q,ae]=s.useState({x:0,y:0}),O=s.useRef(null),f=s.useRef(null),h={top:20,right:30,bottom:40,left:60},[L,ee]=s.useState({width:600,height:typeof M=="number"?M:350});s.useEffect(()=>{if(!r||!O.current)return;const t=new ResizeObserver(E=>{for(const W of E)ee(S=>({width:W.contentRect.width,height:S.height}))});return t.observe(O.current),()=>t.disconnect()},[r]),s.useEffect(()=>{const t="nice-forecast-chart-styles";if(!document.getElementById(t)){const E=document.createElement("style");E.id=t,E.textContent=ot,document.head.appendChild(E)}},[]);const{xScale:ce,yScale:Y,allDates:ie,minY:he,maxY:ve}=s.useMemo(()=>{const E=p.filter(fe=>fe.visible!==!1).flatMap(fe=>fe.data);if(E.length===0)return{xScale:()=>0,yScale:()=>0,allDates:[],minY:0,maxY:100};const W=E.map(fe=>pe(fe.date).getTime()),S=Math.min(...W),Q=Math.max(...W),oe=E.flatMap(fe=>[fe.value,fe.forecast,fe.lowerBound,fe.upperBound]).filter(fe=>fe!=null),de=g?.min??Math.min(...oe)*.95,ue=g?.max??Math.max(...oe)*1.05,_e=L.width-h.left-h.right,je=L.height-h.top-h.bottom,ke=fe=>{const Se=typeof fe=="number"?fe:fe.getTime();return h.left+(Se-S)/(Q-S)*_e},$e=fe=>h.top+je-(fe-de)/(ue-de)*je,He=[...new Set(W)].sort((fe,Se)=>fe-Se).map(fe=>new Date(fe));return{xScale:ke,yScale:$e,allDates:He,minY:de,maxY:ue}},[p,L,h,g]),xe=C?pe(C):null,me=s.useMemo(()=>{if(!z?.enabled)return null;const t=z.threshold??0,E=z.scenarioId?p.find(S=>S.id===z.scenarioId&&S.visible!==!1):p.find(S=>S.visible!==!1);if(!E)return null;const W=E.data.sort((S,Q)=>pe(S.date).getTime()-pe(Q.date).getTime());for(let S=1;S<W.length;S++){const Q=W[S-1],oe=W[S],de=Q.forecast??Q.value,ue=oe.forecast??oe.value;if(de!=null&&ue!=null&&de>t&&ue<=t){const _e=(de-t)/(de-ue),je=pe(Q.date).getTime(),ke=pe(oe.date).getTime(),$e=je+_e*(ke-je);return new Date($e)}}return null},[z,p]),ye=s.useCallback((t,E)=>{const W=t.filter(S=>S[E]!=null).map(S=>({x:ce(pe(S.date)),y:Y(S[E])}));return W.length===0?"":`M ${W.map(S=>`${S.x},${S.y}`).join(" L ")}`},[ce,Y]),be=s.useCallback(t=>{const E=t.filter(Q=>Q.lowerBound!=null&&Q.upperBound!=null);if(E.length===0)return"";const W=E.map(Q=>({x:ce(pe(Q.date)),y:Y(Q.upperBound)})),S=E.map(Q=>({x:ce(pe(Q.date)),y:Y(Q.lowerBound)})).reverse();return`M ${W.map(Q=>`${Q.x},${Q.y}`).join(" L ")} L ${S.map(Q=>`${Q.x},${Q.y}`).join(" L ")} Z`},[ce,Y]),c=s.useCallback(t=>{if(!f.current||D?.enabled===!1)return;const E=f.current.getBoundingClientRect(),W=t.clientX-E.left;t.clientY-E.top;let S=null,Q=1/0;for(const oe of ie){const de=ce(oe),ue=Math.abs(de-W);ue<Q&&(Q=ue,S=oe)}if(S&&Q<50){const oe=p.filter(ue=>ue.visible!==!1).map(ue=>{const _e=ue.data.find(je=>pe(je.date).getTime()===S.getTime());return{scenario:ue,value:_e?.value,forecast:_e?.forecast,lowerBound:_e?.lowerBound,upperBound:_e?.upperBound}}),de=b.filter(ue=>Math.abs(pe(ue.date).getTime()-S.getTime())<864e5);K({date:S,values:oe,annotations:de}),ae({x:t.clientX-E.left+10,y:t.clientY-E.top-10})}else K(null)},[ce,ie,p,b,D]),F=s.useCallback(t=>{if(!G.interactive)return;re(W=>W.map(S=>S.id===t?{...S,visible:!S.visible}:S));const E=p.find(W=>W.id===t);E&&w?.(t,!E.visible)},[G.interactive,p,w]);s.useImperativeHandle(m,()=>({getScenarios:()=>p,updateScenario:(t,E)=>{re(W=>W.map(S=>S.id===t?{...S,data:E}:S))},toggleScenario:F,setZoomRange:()=>{},resetZoom:()=>{},exportImage:t=>{if(!f.current)return null;const E=f.current,S=new XMLSerializer().serializeToString(E);return`data:image/svg+xml;base64,${btoa(S)}`},getDataAtDate:t=>{const E=p.filter(W=>W.visible!==!1).map(W=>{const S=W.data.find(Q=>pe(Q.date).getTime()===t.getTime());return{scenario:W,value:S?.value,forecast:S?.forecast,lowerBound:S?.lowerBound,upperBound:S?.upperBound}});return{date:t,values:E,annotations:b.filter(W=>pe(W.date).getTime()===t.getTime())}}}),[p,b,F]),L.width-h.left-h.right;const J=L.height-h.top-h.bottom,se=s.useMemo(()=>{const t=g?.tickCount??5,E=[],W=(ve-he)/(t-1);for(let S=0;S<t;S++)E.push(he+W*S);return E},[he,ve,g?.tickCount]),ne=s.useMemo(()=>{const t=k?.tickCount??6;if(ie.length===0)return[];const E=Math.max(1,Math.floor(ie.length/(t-1)));return ie.filter((W,S)=>S%E===0||S===ie.length-1)},[ie,k?.tickCount]);return p.length===0||p.every(t=>t.data.length===0)?e.jsx("div",{className:`nice-forecast-chart ${B??""}`,style:U,children:e.jsx("div",{className:"nice-forecast-chart__empty",children:X.noData??"No data available"})}):e.jsxs("div",{className:`nice-forecast-chart ${B??""}`,style:{...U,height:M},children:[e.jsxs("div",{ref:O,className:"nice-forecast-chart__container",children:[e.jsxs("svg",{ref:f,className:"nice-forecast-chart__svg",width:L.width,height:L.height,onMouseMove:c,onMouseLeave:()=>K(null),children:[g?.showGrid!==!1&&se.map(t=>e.jsx("line",{className:"nice-forecast-chart__grid-line",x1:h.left,x2:L.width-h.right,y1:Y(t),y2:Y(t)},t)),d&&xe&&e.jsx("rect",{className:"nice-forecast-chart__forecast-region",x:ce(xe),y:h.top,width:L.width-h.right-ce(xe),height:J}),j.map(t=>e.jsxs("g",{children:[e.jsx("line",{className:"nice-forecast-chart__reference-line",x1:h.left,x2:L.width-h.right,y1:Y(t.value),y2:Y(t.value),stroke:t.color??"var(--nice-text-muted, #9ca3af)",strokeDasharray:t.dashArray??"4,2"}),t.label&&e.jsx("text",{className:"nice-forecast-chart__reference-label",x:L.width-h.right-4,y:Y(t.value)-4,textAnchor:"end",children:t.label})]},t.id)),me&&z?.enabled&&e.jsxs("g",{className:"nice-forecast-chart__cash-runway",children:[e.jsx("line",{className:"nice-forecast-chart__cash-runway-line",x1:ce(me),x2:ce(me),y1:h.top,y2:L.height-h.bottom,stroke:z.color??"var(--nice-color-error, #ef4444)"}),z.showLabel!==!1&&e.jsxs(e.Fragment,{children:[e.jsx("rect",{className:"nice-forecast-chart__cash-runway-label-bg",x:ce(me)-60,y:h.top-2,width:120,height:z.showDate!==!1?32:20,fill:z.color??"var(--nice-color-error, #ef4444)",rx:4}),e.jsx("text",{className:"nice-forecast-chart__cash-runway-label",x:ce(me),y:h.top+12,textAnchor:"middle",fill:"var(--nice-color-white, #fff)",children:z.label??X.cashRunsOut??"Cash runs out"}),z.showDate!==!1&&e.jsx("text",{className:"nice-forecast-chart__cash-runway-label",x:ce(me),y:h.top+26,textAnchor:"middle",fill:"var(--nice-color-white, #fff)",style:{fontSize:"0.625rem",opacity:.9},children:Ce(me,Z)})]})]}),p.filter(t=>t.visible!==!1&&t.showConfidenceBand).map(t=>e.jsx("path",{className:"nice-forecast-chart__confidence-band",d:be(t.data),fill:t.color},`band-${t.id}`)),p.filter(t=>t.visible!==!1).map(t=>{const E=xe?t.data.filter(S=>pe(S.date)<xe):t.data.filter(S=>S.value!=null),W=xe?t.data.filter(S=>pe(S.date)>=xe):t.data.filter(S=>S.forecast!=null);return e.jsxs("g",{children:[e.jsx("path",{className:"nice-forecast-chart__historical-line",d:ye(E,"value"),stroke:t.color,strokeWidth:l}),e.jsx("path",{className:"nice-forecast-chart__forecast-line",d:ye(W,xe?"value":"forecast"),stroke:t.color,strokeWidth:l}),W.length>0&&t.data.some(S=>S.forecast!=null)&&e.jsx("path",{className:"nice-forecast-chart__forecast-line",d:ye(t.data,"forecast"),stroke:t.color,strokeWidth:l}),x&&t.data.map((S,Q)=>{const oe=S.value??S.forecast;return oe==null?null:e.jsx("circle",{className:"nice-forecast-chart__point",cx:ce(pe(S.date)),cy:Y(oe),r:I,fill:t.color,onClick:()=>T?.(S,t)},Q)})]},t.id)}),b.map(t=>{const E=ce(pe(t.date));return e.jsxs("g",{className:"nice-forecast-chart__annotation-marker",onClick:()=>u?.(t),children:[t.showLine!==!1&&e.jsx("line",{className:"nice-forecast-chart__annotation-line",x1:E,x2:E,y1:h.top,y2:L.height-h.bottom,stroke:t.color??"var(--nice-text-muted, #9ca3af)"}),e.jsx("circle",{cx:E,cy:h.top+10,r:8,fill:t.color??"var(--nice-text-muted, #9ca3af)"}),e.jsx("text",{x:E,y:h.top+14,textAnchor:"middle",fill:"white",fontSize:"10",children:t.icon??"!"})]},t.id)}),e.jsx("line",{className:"nice-forecast-chart__axis-line",x1:h.left,x2:h.left,y1:h.top,y2:L.height-h.bottom}),e.jsx("line",{className:"nice-forecast-chart__axis-line",x1:h.left,x2:L.width-h.right,y1:L.height-h.bottom,y2:L.height-h.bottom}),se.map(t=>e.jsx("text",{className:"nice-forecast-chart__axis-label",x:h.left-8,y:Y(t)+4,textAnchor:"end",children:g?.format?g.format(t):Me(t,Z)},t)),ne.map(t=>e.jsx("text",{className:"nice-forecast-chart__axis-label",x:ce(t),y:L.height-h.bottom+16,textAnchor:"middle",children:k?.format?k.format(t):Ce(t,Z)},t.getTime())),g?.title&&e.jsx("text",{className:"nice-forecast-chart__axis-title",x:15,y:L.height/2,textAnchor:"middle",transform:`rotate(-90, 15, ${L.height/2})`,children:g.title})]}),te&&e.jsxs("div",{className:"nice-forecast-chart__tooltip",style:{left:q.x,top:q.y},children:[e.jsx("div",{className:"nice-forecast-chart__tooltip-date",children:Ce(te.date,Z)}),te.values.map(t=>{const E=t.value??t.forecast;return E==null?null:e.jsxs("div",{className:"nice-forecast-chart__tooltip-item",children:[e.jsx("span",{className:"nice-forecast-chart__tooltip-color",style:{background:t.scenario.color}}),e.jsx("span",{className:"nice-forecast-chart__tooltip-label",children:t.scenario.name}),e.jsx("span",{className:"nice-forecast-chart__tooltip-value",children:Me(E,Z)})]},t.scenario.id)}),te.values.some(t=>t.lowerBound!=null)&&e.jsxs("div",{className:"nice-forecast-chart__tooltip-confidence",children:[X.confidence??"CI",":"," ",Me(te.values[0]?.lowerBound??0,Z)," –"," ",Me(te.values[0]?.upperBound??0,Z)]})]})]}),G.enabled&&e.jsx("div",{className:"nice-forecast-chart__legend",children:p.map(t=>e.jsxs("div",{className:`nice-forecast-chart__legend-item ${t.visible===!1?"nice-forecast-chart__legend-item--hidden":""}`,onClick:()=>F(t.id),children:[e.jsx("span",{className:`nice-forecast-chart__legend-color ${t.isBase?"":"nice-forecast-chart__legend-color--dashed"}`,style:{background:t.color}}),t.name]},t.id))})]})});function dt(n,i){const m=n?typeof n=="number"?new Date(n):new Date(n):new Date,a=z=>z.toString().padStart(2,"0"),o=a(m.getHours()),b=a(m.getMinutes()),j=a(m.getSeconds()),C=m.getMilliseconds().toString().padStart(3,"0");switch(i){case"HH:mm:ss":return`${o}:${b}:${j}`;case"HH:mm":return`${o}:${b}`;case"mm:ss":return`${b}:${j}`;case"ss.SSS":return`${j}.${C}`;case"ISO":return m.toISOString();default:return`${o}:${b}:${j}`}}function Re(n){if(n.length===0)return null;const i=Math.min(...n),m=Math.max(...n),a=n.reduce((b,j)=>b+j,0)/n.length,o=n[n.length-1];return{min:i,max:m,avg:a,current:o,count:n.length}}const Oe=s.forwardRef(({series:n,maxPoints:i=100,slidingWindow:m=!0,refreshRate:a=16,dataSource:o,width:b=600,height:j=400,title:C,showLegend:z=!0,showGrid:k=!0,yAxisLabel:g,xAxisLabel:N,stacked:D,zoomable:A,crosshair:M,annotations:d=[],legendInteractive:l,onDataPointClick:x,exportable:I,showControls:v=!0,showStatus:$=!0,initialPaused:_=!1,onDataReceived:R,onDataDropped:r,timeFormat:T="HH:mm:ss",showStats:u,thresholds:w=[],className:y,style:P},H)=>{const[X,Z]=s.useState(()=>{const c=new Map;for(const F of n)c.set(F.name,F.initialData?.slice()??[]);return c}),[B,U]=s.useState([]),{t:V}=le.useNiceTranslation(),[G,p]=s.useState(_),[re,te]=s.useState(!1),K=s.useRef([]),q=s.useRef(Date.now()),ae=s.useRef(null),O=s.useRef(new Map),f=s.useRef(0),h=JSON.stringify(n.map(c=>c.name)),L=s.useMemo(()=>new Set(JSON.parse(h)),[h]),ee=s.useRef(G),ce=s.useRef(R),Y=s.useRef(r);s.useEffect(()=>{ee.current=G,ce.current=R,Y.current=r});const ie=s.useRef(null);ie.current===null&&(ie.current=new Map(n.map(c=>[c.name,c.initialData?.length??0])));const he=s.useCallback(()=>{const c=K.current;if(c.length===0)return;K.current=[];const F=ie.current??new Map,J=[];for(const ne of c){const t=F.get(ne.series);t!==void 0&&(m&&t+1>i?(J.push([ne.series,t+1-i]),F.set(ne.series,i)):F.set(ne.series,t+1))}Z(ne=>{const t=new Map(ne);for(const E of c){const W=t.get(E.series);if(!W)continue;const S=[...W,E.value];m&&S.length>i&&S.splice(0,S.length-i),t.set(E.series,S)}return t});for(const[ne,t]of J)Y.current?.(t,ne);const se=[];for(const ne of c){if(!L.has(ne.series))continue;const t=(O.current.get(ne.series)??0)+1;O.current.set(ne.series,t),t>f.current&&(f.current=t,se.push(ne.category??dt(ne.timestamp,T)))}se.length>0&&U(ne=>{const t=[...ne,...se];return m&&t.length>i&&t.splice(0,t.length-i),t})},[m,i,T,L]),ve=s.useCallback(()=>{const c=Date.now();c-q.current>=a&&(he(),q.current=c),ae.current=requestAnimationFrame(ve)},[a,he]);s.useEffect(()=>(G||(ae.current=requestAnimationFrame(ve)),()=>{ae.current!==null&&(cancelAnimationFrame(ae.current),ae.current=null)}),[G,ve]);const xe=s.useCallback(c=>{if(ee.current)return;const F="points"in c?c.points:[c];for(const J of F)L.has(J.series)&&(K.current.push(J),ce.current?.(J))},[L]);s.useEffect(()=>{if(!o)return;const c=o.subscribe(xe);let F;return o.onStatusChange?F=o.onStatusChange(te):te(!0),o.fetchHistory&&o.fetchHistory(i).then(J=>{for(const se of J)K.current.push(se);he()}),()=>{c(),F?.()}},[o,xe,i,he]);const me=s.useMemo(()=>n.map(c=>({name:c.name,color:c.color,type:c.type,data:X.get(c.name)??[]})),[n,X]),ye=s.useMemo(()=>{const c=[...d];for(const F of w)c.push({type:"line",value:F.value,color:F.color,label:F.label,dash:F.style==="dashed"?"5,5":F.style==="dotted"?"2,2":void 0});return c},[d,w]);s.useImperativeHandle(H,()=>({pause(){p(!0)},resume(){p(!1)},isPaused(){return G},clear(){Z(F=>{const J=new Map(F);for(const se of J.keys())J.set(se,[]);return J}),U([]),O.current=new Map,f.current=0,K.current=[];const c=ie.current;if(c)for(const F of c.keys())c.set(F,0)},addPoint(c){xe(c)},addPoints(c){xe({points:c})},getData(c){return X.get(c)??[]},getCategories(){return B},exportData(){return{series:me,categories:B}},getStats(c){const F=X.get(c);return F?Re(F):null}}),[G,X,B,me,xe]);const be=s.useMemo(()=>{if(!u)return null;const c={};for(const[F,J]of X)c[F]=Re(J);return c},[u,X]);return e.jsxs("div",{className:y,style:{position:"relative",...P},children:[$&&e.jsxs("div",{style:{position:"absolute",top:8,right:8,display:"flex",alignItems:"center",gap:4,fontSize:12,color:re?"var(--nice-color-success, #22c55e)":"var(--nice-color-error, #ef4444)",zIndex:10},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:re?"var(--nice-color-success, #22c55e)":"var(--nice-color-error, #ef4444)"}}),re?V("charts.live","Live"):V("charts.disconnected","Disconnected")]}),v&&e.jsx("div",{style:{position:"absolute",top:8,left:8,display:"flex",gap:4,zIndex:10},children:e.jsx("button",{onClick:()=>p(c=>!c),style:{padding:"4px 8px",fontSize:12,border:"1px solid var(--nice-border-color, #ddd)",borderRadius:4,background:G?"var(--nice-warning-bg, #fef3c7)":"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",cursor:"pointer"},title:G?V("charts.resume","Resume"):V("charts.pause","Pause"),"aria-label":G?V("charts.resume","Resume"):V("charts.pause","Pause"),children:e.jsx(le.NiceIcon,{name:G?"play":"pause",size:14})})}),u&&be&&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(be).map(([c,F])=>F?e.jsxs("div",{style:{marginBottom:4},children:[e.jsx("strong",{children:c}),e.jsxs("div",{children:[V("charts.stats.min","Min"),": ",F.min.toFixed(2)," |"," ",V("charts.stats.max","Max"),": ",F.max.toFixed(2)]}),e.jsxs("div",{children:[V("charts.stats.avg","Avg"),": ",F.avg.toFixed(2)," |"," ",V("charts.stats.now","Now"),": ",F.current.toFixed(2)]})]},c):null)}),e.jsx(we,{series:me,categories:B,width:b,height:j,title:C,showLegend:z,showGrid:k,yAxisLabel:g,xAxisLabel:N,stacked:D,zoomable:A,crosshair:M,annotations:ye,legendInteractive:l,onDataPointClick:x,exportable:I})]})});Oe.displayName="NiceLiveChart";function ht(n){const{hubConnection:i,eventName:m="DataPoint",subscribeMethod:a="SubscribeToMetrics",historyMethod:o="GetMetricHistory",metricName:b}=n;return{subscribe(j){const C=z=>{j(z)};return i.on(m,C),i.state==="Connected"&&i.invoke(a,b).catch(()=>{}),()=>{i.off(m,C)}},async fetchHistory(j){try{return await i.invoke(o,b,j)}catch{return[]}},onStatusChange(j){const C=()=>j(i.state==="Connected");return i.onclose(()=>j(!1)),i.onreconnected(()=>j(!0)),C(),()=>{}}}}function ut(n){const{url:i,autoReconnect:m=!0,reconnectDelay:a=3e3,parseMessage:o=g=>JSON.parse(g)}=n;let b=null,j=null,C=null,z=null;const k=()=>{b=new WebSocket(i),b.onopen=()=>{j?.(!0)},b.onclose=()=>{j?.(!1),m&&(z=setTimeout(k,a))},b.onerror=()=>{b?.close()},b.onmessage=g=>{try{const N=o(g.data);N&&C&&C(N)}catch{}}};return{subscribe(g){return C=g,k(),()=>{C=null,z&&clearTimeout(z),b?.close(),b=null}},onStatusChange(g){return j=g,()=>{j=null}}}}function ft(n){const{seriesNames:i,interval:m=1e3,generateValue:a=()=>Math.random()*100}=n;let o=null,b=0;return{subscribe(j){return o=setInterval(()=>{for(const C of i)j({series:C,value:a(C,b),timestamp:Date.now()});b++},m),()=>{o&&clearInterval(o)}},onStatusChange(j){return j(!0),()=>{}}}}function xt(n){if(!n.length)return{categories:[],numericFields:[],sampleValues:{}};const i=n[0],m=[],a={};let o=null;for(const[j,C]of Object.entries(i))typeof C=="number"?(m.push(j),a[j]=n.map(z=>Number(z[j])||0)):!o&&(typeof C=="string"||C instanceof Date)&&(o=j);return{categories:o?n.map(j=>String(j[o]||"")):n.map((j,C)=>`Item ${C+1}`),numericFields:m,sampleValues:a}}function mt(n,i){const{categories:m,numericFields:a,sampleValues:o}=xt(n);return{series:a.map((j,C)=>({name:j.replace(/([A-Z])/g," $1").replace(/^./,z=>z.toUpperCase()).trim(),data:o[j],type:i==="area"?"area":i==="line"?"line":"bar"})),categories:m}}const pt=s.forwardRef(function(i,m){const{rawData:a,enableAI:o=!0,aiModel:b,enableAutoType:j=!0,enableInsights:C=!0,dataDescription:z,onChartSuggestion:k,onInsights:g,showAIToolbar:N=!0,showInsightsOnLoad:D=!1,series:A,categories:M,...d}=i,[l,x]=s.useState("bar"),[I,v]=s.useState(null),[$,_]=s.useState([]),[R,r]=s.useState(D),[T,u]=s.useState(null),{t:w}=Ye.useNiceTranslation(),y=le.useNiceAI(),{suggestChartType:P,generateInsights:H,isLoading:X}=le.useChartSuggestion(),Z=o&&y.isConfigured,{series:B,categories:U}=a?mt(a,T||l):{series:A||[],categories:M},V=s.useCallback(async()=>{if(!Z||!j)return{type:"bar",reason:"Default",config:{}};const K=a||(A?.length?A.flatMap(q=>q.data.map((ae,O)=>({[q.name]:ae,index:O}))):[]);try{const q=await P(K,z),ae={type:q.type,reason:q.reason,config:q.config};return v(ae),x(ae.type),k?.(ae),ae}catch{return{type:"bar",reason:"Default fallback",config:{}}}},[Z,j,a,A,z,P,k]),G=s.useCallback(async()=>{if(!Z||!C)return[];const K=a||(A?.length?A.flatMap(q=>q.data.map((ae,O)=>({[q.name]:ae,category:M?.[O]||O}))):[]);try{const q=await H(K,T||l);return _(q),g?.(q),q}catch{return[]}},[Z,C,a,A,M,l,T,H,g]),p=s.useCallback(()=>T||l,[T,l]);s.useEffect(()=>{Z&&j&&(a?.length||A?.length)&&V()},[Z,j,a,A]),s.useImperativeHandle(m,()=>({getSuggestion:V,generateInsights:G,getCurrentType:p}));const re=[{type:"bar",icon:"bar-chart",label:"Bar"},{type:"line",icon:"line-chart",label:"Line"},{type:"area",icon:"area-chart",label:"Area"},{type:"pie",icon:"pie-chart",label:"Pie"},{type:"donut",icon:"donut-chart",label:"Donut"},{type:"scatter",icon:"scatter-chart",label:"Scatter"}],te=T||l;return e.jsxs("div",{className:"nice-chart-ai","data-testid":i["data-testid"],children:[N&&Z&&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:"AI"}),I&&e.jsxs("div",{className:"nice-chart-ai__suggestion",children:[e.jsx("span",{className:"nice-chart-ai__suggestion-icon",children:e.jsx(le.NiceIcon,{name:"lightbulb",size:14})}),e.jsxs("span",{className:"nice-chart-ai__suggestion-text",children:[w("chartAI.suggestedType","Suggested:")," ",I.type]}),e.jsxs("span",{className:"nice-chart-ai__suggestion-reason",title:I.reason,children:["(",I.reason,")"]})]}),X&&e.jsx("span",{className:"nice-chart-ai__loading",children:w("chartAI.analyzing","Analyzing...")})]}),e.jsx("div",{className:"nice-chart-ai__toolbar-center",children:e.jsx("div",{className:"nice-chart-ai__type-selector",children:re.filter(K=>["bar","line","area"].includes(K.type)).map(({type:K,icon:q,label:ae})=>e.jsx("button",{type:"button",className:`nice-chart-ai__type-btn ${te===K?"nice-chart-ai__type-btn--active":""}`,onClick:()=>u(K),title:ae,children:e.jsx(le.NiceIcon,{name:q,size:16})},K))})}),e.jsxs("div",{className:"nice-chart-ai__toolbar-right",children:[e.jsxs("button",{type:"button",className:"nice-chart-ai__auto-btn",onClick:()=>V(),disabled:X,title:w("chartAI.autoDetect","Auto-detect best chart type"),children:[e.jsx(le.NiceIcon,{name:"zap",size:14})," ",w("chartAI.auto","Auto")]}),C&&e.jsxs("button",{type:"button",className:"nice-chart-ai__insights-btn",onClick:()=>{$.length||G(),r(!R)},disabled:X,title:w("chartAI.showInsights","Show data insights"),children:[e.jsx(le.NiceIcon,{name:"lightbulb",size:14})," ",w("chartAI.insights","Insights")]})]})]}),e.jsx("div",{className:"nice-chart-ai__chart-wrapper",children:e.jsx(we,{series:B,categories:U,...d})}),R&&$.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(le.NiceIcon,{name:"lightbulb",size:14})," ",w("chartAI.dataInsights","Data Insights")]}),e.jsx("button",{type:"button",className:"nice-chart-ai__insights-close",onClick:()=>r(!1),"aria-label":w("chartAI.close","Close"),children:e.jsx(le.NiceIcon,{name:"close",size:14})})]}),e.jsx("ul",{className:"nice-chart-ai__insights-list",children:$.map((K,q)=>e.jsxs("li",{className:"nice-chart-ai__insight",children:[e.jsx("span",{className:"nice-chart-ai__insight-icon",children:"•"}),K]},q))}),e.jsx("div",{className:"nice-chart-ai__insights-footer",children:e.jsxs("button",{type:"button",className:"nice-chart-ai__refresh",onClick:()=>G(),disabled:X,children:[e.jsx(le.NiceIcon,{name:"refresh",size:14})," ",w("chartAI.refresh","Refresh")]})})]}),R&&X&&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"}),w("chartAI.generatingInsights","Generating insights...")]})})]})}),gt=[],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)"],Pe=s.forwardRef((n,i)=>{const{t:m}=le.useNiceTranslation(),{levels:a=gt,initialLevelId:o,levelId:b,chartType:j="bar",width:C=600,height:z=400,showBreadcrumbs:k=!0,showBackButton:g=!0,animationDuration:N=300,onLevelChange:D,onItemClick:A,colors:M=We,showValues:d=!0,showLegend:l=!0,className:x,style:I,...v}=n,$=b!==void 0,[_,R]=s.useState(o||a[0]?.id),[r,T]=s.useState([o||a[0]?.id]),u=s.useCallback(O=>{const f=[];let h=a.find(L=>L.id===O);for(;h&&!f.includes(h.id);){f.unshift(h.id);const L=h.parentId;h=L?a.find(ee=>ee.id===L):void 0}return f.length>0?f:[O]},[a]),w=b??_,y=s.useMemo(()=>b!==void 0?u(b):r,[b,r,u]),[P,H]=s.useState(!1),[X,Z]=s.useState("in"),B=s.useMemo(()=>a.find(O=>O.id===w),[a,w]),U=s.useCallback(O=>{a.find(h=>h.id===O)&&(Z("in"),H(!0),setTimeout(()=>{$||(R(O),T(h=>[...h,O])),D?.(O,$?u(O):[...y,O]),H(!1)},N/2))},[a,y,N,D,$,u]),V=s.useCallback(()=>{if(y.length<=1)return;Z("out"),H(!0);const O=y.slice(0,-1),f=O[O.length-1];setTimeout(()=>{$||(R(f),T(O)),D?.(f,O),H(!1)},N/2)},[y,N,D,$]),G=s.useCallback(()=>{const O=a[0]?.id;O&&(Z("out"),H(!0),setTimeout(()=>{$||(R(O),T([O])),D?.(O,[O]),H(!1)},N/2))},[a,N,D,$]);s.useImperativeHandle(i,()=>({drillDown:U,drillUp:V,resetToRoot:G,getCurrentLevel:()=>w,getPath:()=>y}),[U,V,G,w,y]);const p=s.useCallback((O,f)=>{A?.(O,w);const h=a.find(L=>L.parentId===w&&L.id===O.metadata?.childLevelId);h&&U(h.id)},[w,a,U,A]),re=s.useMemo(()=>B?.data.reduce((O,f)=>O+f.value,0)||0,[B]),te=s.useMemo(()=>y.map(O=>a.find(f=>f.id===O)?.label||O),[y,a]),K=()=>{if(!B)return null;const O=B.data,f=Math.max(...O.map(L=>L.value)),h=Math.min(40,(z-100)/O.length-8);return e.jsx("div",{className:"nice-drilldown-bars",children:O.map((L,ee)=>{const ce=L.value/f*100;return e.jsxs("div",{className:"nice-drilldown-bar-row",onClick:()=>p(L,ee),children:[e.jsx("span",{className:"nice-drilldown-bar-label",children:L.label||`Item ${ee+1}`}),e.jsx("div",{className:"nice-drilldown-bar-track",children:e.jsx("div",{className:"nice-drilldown-bar-fill",style:{width:`${ce}%`,backgroundColor:L.color||M[ee%M.length],height:h}})}),d&&e.jsx("span",{className:"nice-drilldown-bar-value",children:L.value.toLocaleString()})]},ee)})})},q=()=>{if(!B)return null;const O=B.data,f=C/2,h=(z-60)/2+30,L=Math.min(f,h)-40;let ee=-90;const ce=O.map((Y,ie)=>{const he=Y.value/re*360,ve=ee+he,xe=he>180?1:0,me=ee*Math.PI/180,ye=ve*Math.PI/180,be=f+L*Math.cos(me),c=h+L*Math.sin(me),F=f+L*Math.cos(ye),J=h+L*Math.sin(ye),se=(ee+he/2)*Math.PI/180,ne=f+L*.7*Math.cos(se),t=h+L*.7*Math.sin(se),E=`M ${f} ${h} L ${be} ${c} A ${L} ${L} 0 ${xe} 1 ${F} ${J} Z`;return ee=ve,{path:E,color:Y.color||M[ie%M.length],label:Y.label||`Item ${ie+1}`,value:Y.value,percentage:(Y.value/re*100).toFixed(1),labelX:ne,labelY:t,item:Y,index:ie}});return e.jsx("svg",{width:C,height:z-40,className:"nice-drilldown-pie",children:e.jsx("g",{children:ce.map((Y,ie)=>e.jsxs("g",{onClick:()=>p(Y.item,Y.index),children:[e.jsx("path",{d:Y.path,fill:Y.color,stroke:"white",strokeWidth:2,className:"nice-drilldown-pie-slice"}),d&&parseFloat(Y.percentage)>5&&e.jsxs("text",{x:Y.labelX,y:Y.labelY,textAnchor:"middle",dominantBaseline:"middle",fill:"white",fontSize:"12",fontWeight:"600",children:[Y.percentage,"%"]})]},ie))})})},ae=()=>{if(!B)return null;const O=B.data,f=Math.max(...O.map(ee=>ee.value)),h=Math.min(60,(C-100)/O.length-8),L=z-100;return e.jsx("svg",{width:C,height:z-40,className:"nice-drilldown-columns",children:e.jsxs("g",{transform:"translate(50, 20)",children:[[0,.25,.5,.75,1].map((ee,ce)=>e.jsxs("g",{children:[e.jsx("line",{x1:0,y1:L*(1-ee),x2:C-80,y2:L*(1-ee),stroke:"var(--nice-border-color, #e5e7eb)",strokeDasharray:ee===0?void 0:"4"}),e.jsx("text",{x:-8,y:L*(1-ee),textAnchor:"end",dominantBaseline:"middle",fontSize:"11",fill:"var(--nice-text-secondary, #6b7280)",children:Math.round(f*ee).toLocaleString()})]},ce)),O.map((ee,ce)=>{const Y=ee.value/f*L,ie=ce*((C-100)/O.length)+((C-100)/O.length-h)/2;return e.jsxs("g",{onClick:()=>p(ee,ce),children:[e.jsx("rect",{x:ie,y:L-Y,width:h,height:Y,fill:ee.color||M[ce%M.length],rx:4,className:"nice-drilldown-column-bar"}),e.jsx("text",{x:ie+h/2,y:L+16,textAnchor:"middle",fontSize:"11",fill:"var(--nice-text-primary, #374151)",children:(ee.label||`${ce+1}`).slice(0,10)}),d&&e.jsx("text",{x:ie+h/2,y:L-Y-8,textAnchor:"middle",fontSize:"11",fill:"var(--nice-text-primary, #374151)",fontWeight:"500",children:ee.value.toLocaleString()})]},ce)})]})})};return e.jsxs("div",{className:`nice-drilldown-chart ${P?`animating ${X}`:""} ${x||""}`,style:{width:C,...I},...v,children:[e.jsxs("div",{className:"nice-drilldown-header",children:[g&&y.length>1&&e.jsxs("button",{className:"nice-drilldown-back",onClick:V,children:[e.jsx(le.NiceIcon,{name:"arrow-left",size:14})," ",m("charts.back","Back")]}),k&&e.jsx("div",{className:"nice-drilldown-breadcrumbs",children:te.map((O,f)=>e.jsxs(s.Fragment,{children:[f>0&&e.jsx("span",{className:"nice-drilldown-separator",children:"/"}),e.jsx("span",{className:`nice-drilldown-crumb ${f===te.length-1?"active":""}`,onClick:()=>{if(f<te.length-1){const h=y.slice(0,f+1),L=h[h.length-1];$||(T(h),R(L)),D?.(L,h)}},children:O})]},f))})]}),e.jsxs("div",{className:"nice-drilldown-content",style:{height:z-40},children:[j==="bar"&&K(),j==="pie"&&q(),j==="column"&&ae()]}),l&&B&&e.jsx("div",{className:"nice-drilldown-legend",children:B.data.map((O,f)=>e.jsxs("div",{className:"nice-drilldown-legend-item",children:[e.jsx("span",{className:"nice-drilldown-legend-color",style:{backgroundColor:O.color||M[f%M.length]}}),e.jsx("span",{className:"nice-drilldown-legend-label",children:O.label||`Item ${f+1}`})]},f))}),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
|
+
`})]})});Pe.displayName="NiceDrillDownChart";const vt=["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)"],yt=({type:n="choropleth",regions:i=[],bubbles:m=[],width:a=800,height:o=500,viewBox:b="0 0 800 500",colorScale:j,colorRange:C,minValue:z,maxValue:k,showTooltip:g=!0,showLegend:N=!0,onRegionClick:D,onBubbleClick:A,onRegionHover:M,title:d,mapSvg:l,zoomable:x=!1,className:I,style:v,...$})=>{const _=j??C??vt,{t:R}=le.useNiceTranslation(),[r,T]=s.useState(null),[u,w]=s.useState(1),[y,P]=s.useState({x:0,y:0}),H=s.useRef(null),X=s.useRef(!1),Z=s.useRef({x:0,y:0}),B=z??Math.min(...i.map(f=>f.value),...m.map(f=>f.value)),U=k??Math.max(...i.map(f=>f.value),...m.map(f=>f.value)),V=s.useCallback(f=>{const h=(f-B)/(U-B),L=Math.min(Math.floor(h*_.length),_.length-1);return _[Math.max(0,L)]},[B,U,_]),G=s.useCallback(f=>{if(!g||!r)return;const h=H.current?.getBoundingClientRect();h&&T(L=>L?{...L,x:f.clientX-h.left,y:f.clientY-h.top}:null)},[g,r]),p=s.useCallback((f,h)=>{const L=H.current?.getBoundingClientRect();L&&g&&T({x:h.clientX-L.left,y:h.clientY-L.top,content:`${f.name}: ${f.value.toLocaleString()}`}),M?.(f)},[g,M]),re=s.useCallback(()=>{T(null),M?.(null)},[M]),te=s.useCallback(f=>{if(!x)return;f.preventDefault();const h=f.deltaY>0?.9:1.1;w(L=>Math.min(Math.max(L*h,.5),4))},[x]),K=s.useCallback(f=>{x&&(X.current=!0,Z.current={x:f.clientX-y.x,y:f.clientY-y.y})},[x,y]),q=s.useCallback(()=>{X.current=!1},[]),ae=s.useCallback(f=>{X.current&&P({x:f.clientX-Z.current.x,y:f.clientY-Z.current.y})},[]),O=s.useMemo(()=>i.length>0?i:[{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"}],[i]);return e.jsxs("div",{className:`nice-map-chart ${I||""}`,style:{width:a,...v},...$,children:[d&&e.jsx("div",{className:"nice-map-title",children:d}),e.jsx("svg",{ref:H,width:a,height:o,viewBox:b,className:"nice-map-svg",onWheel:te,onMouseDown:K,onMouseUp:q,onMouseLeave:q,onMouseMove:f=>{G(f),ae(f)},children:e.jsxs("g",{transform:`translate(${y.x}, ${y.y}) scale(${u})`,children:[l&&e.jsx("g",{dangerouslySetInnerHTML:{__html:l}}),n==="choropleth"&&O.map(f=>e.jsx("path",{d:f.path,fill:f.color||V(f.value),stroke:"var(--nice-bg-primary, #ffffff)",strokeWidth:1,className:"nice-map-region",onClick:()=>D?.(f),onMouseEnter:h=>p(f,h),onMouseLeave:re},f.id)),(n==="bubble"||m.length>0)&&m.map(f=>{const h=Math.sqrt((f.value-B)/(U-B))*30+5;return e.jsx("circle",{cx:f.lng,cy:f.lat,r:h,fill:f.color||"var(--nice-color-primary, #3b82f6)",fillOpacity:.7,stroke:"var(--nice-bg-primary, #ffffff)",strokeWidth:1,className:"nice-map-bubble",onClick:()=>A?.(f),onMouseEnter:L=>{const ee=H.current?.getBoundingClientRect();ee&&g&&T({x:L.clientX-ee.left,y:L.clientY-ee.top,content:`${f.label||f.id}: ${f.value.toLocaleString()}`})},onMouseLeave:re,children:f.label&&e.jsxs("title",{children:[f.label,": ",f.value]})},f.id)})]})}),r&&e.jsx("div",{className:"nice-map-tooltip",style:{left:r.x+10,top:r.y-30},children:r.content}),N&&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:_.map((f,h)=>e.jsx("div",{className:"nice-map-legend-item",style:{backgroundColor:f}},h))}),e.jsxs("div",{className:"nice-map-legend-labels",children:[e.jsx("span",{children:B.toLocaleString()}),e.jsx("span",{children:U.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
|
+
`})]})},bt=({nodes:n,links:i,width:m=800,height:a=500,nodeWidth:o=20,nodePadding:b=10,showValues:j=!0,showTooltip:C=!0,onNodeClick:z,onLinkClick:k,title:g,className:N,style:D,...A})=>{const[M,d]=s.useState(null),l=s.useRef(null),x=s.useMemo(()=>{const v=new Map;n.forEach(p=>v.set(p.id,p));const $=new Set(i.map(p=>p.target)),_=new Set(i.map(p=>p.source)),R=[],r=new Map,T=n.filter(p=>_.has(p.id)&&!$.has(p.id));T.length>0&&(R.push(T.map(p=>p.id)),T.forEach(p=>r.set(p.id,0)));const u=n.filter(p=>_.has(p.id)&&$.has(p.id));u.length>0&&(R.push(u.map(p=>p.id)),u.forEach(p=>r.set(p.id,1)));const w=n.filter(p=>!_.has(p.id)&&$.has(p.id));w.length>0&&(R.push(w.map(p=>p.id)),w.forEach(p=>r.set(p.id,2))),R.length===0&&(R.push(n.map(p=>p.id)),n.forEach(p=>r.set(p.id,0)));const y=new Map;i.forEach(p=>{y.set(p.source,(y.get(p.source)||0)+p.value),y.set(p.target,(y.get(p.target)||0)+p.value)});const P=40,H=m-P*2,X=a-P*2,Z=R.length>1?H/(R.length-1):H,B=new Map;Math.max(...Array.from(y.values())),R.forEach((p,re)=>{const te=p.reduce((ae,O)=>ae+(y.get(O)||0),0),K=(X-(p.length-1)*b)/te;let q=P;p.forEach(ae=>{const f=(y.get(ae)||0)*K,h=P+re*Z;B.set(ae,{x:h,y:q,height:f}),q+=f+b})});const U=[],V=new Map,G=new Map;return i.forEach(p=>{const re=B.get(p.source),te=B.get(p.target);if(!re||!te)return;const K=y.get(p.source)||1;y.get(p.target);const q=p.value/K*re.height,ae=re.y+(V.get(p.source)||0),O=te.y+(G.get(p.target)||0);V.set(p.source,(V.get(p.source)||0)+q),G.set(p.target,(G.get(p.target)||0)+q);const f=re.x+o,h=te.x,L=(h-f)*.5,ee=`
|
|
564
|
+
M ${f} ${ae}
|
|
565
|
+
C ${f+L} ${ae},
|
|
566
|
+
${h-L} ${O},
|
|
567
|
+
${h} ${O}
|
|
568
|
+
L ${h} ${O+q}
|
|
569
|
+
C ${h-L} ${O+q},
|
|
570
|
+
${f+L} ${ae+q},
|
|
571
|
+
${f} ${ae+q}
|
|
572
|
+
Z
|
|
573
|
+
`;U.push({path:ee,link:p,sourcePos:re,targetPos:te})}),{nodePositions:B,linkPaths:U,nodeMap:v,nodeValues:y}},[n,i,m,a,o,b]),I=s.useCallback((v,$)=>{const _=l.current?.getBoundingClientRect();_&&C&&d({x:$.clientX-_.left,y:$.clientY-_.top,content:v})},[C]);return e.jsxs("div",{className:`nice-sankey-chart ${N||""}`,style:{width:m,...D},...A,children:[g&&e.jsx("div",{className:"nice-sankey-title",children:g}),e.jsxs("svg",{ref:l,width:m,height:a,className:"nice-sankey-svg",children:[e.jsx("defs",{children:x.linkPaths.map((v,$)=>e.jsxs("linearGradient",{id:`sankey-gradient-${$}`,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[e.jsx("stop",{offset:"0%",stopColor:x.nodeMap.get(v.link.source)?.color||"var(--nice-color-primary, #3b82f6)"}),e.jsx("stop",{offset:"100%",stopColor:x.nodeMap.get(v.link.target)?.color||"var(--nice-color-error, #ef4444)"})]},$))}),e.jsx("g",{className:"nice-sankey-links",children:x.linkPaths.map((v,$)=>e.jsx("path",{d:v.path,fill:v.link.color||`url(#sankey-gradient-${$})`,fillOpacity:.4,className:"nice-sankey-link",onClick:()=>k?.(v.link),onMouseEnter:_=>I(`${x.nodeMap.get(v.link.source)?.name} → ${x.nodeMap.get(v.link.target)?.name}: ${v.link.value.toLocaleString()}`,_),onMouseLeave:()=>d(null)},$))}),e.jsx("g",{className:"nice-sankey-nodes",children:Array.from(x.nodePositions.entries()).map(([v,$])=>{const _=x.nodeMap.get(v);return _?e.jsxs("g",{children:[e.jsx("rect",{x:$.x,y:$.y,width:o,height:$.height,fill:_.color||"var(--nice-color-primary, #3b82f6)",rx:2,className:"nice-sankey-node",onClick:()=>z?.(_),onMouseEnter:R=>I(`${_.label??_.name??_.id}: ${x.nodeValues.get(v)?.toLocaleString()||0}`,R),onMouseLeave:()=>d(null)}),e.jsxs("text",{x:$.x+o+6,y:$.y+$.height/2,dominantBaseline:"middle",fontSize:"12",fill:"var(--nice-text-primary, #0f172a)",children:[_.label??_.name??_.id,j&&` (${x.nodeValues.get(v)?.toLocaleString()||0})`]})]},v):null})})]}),M&&e.jsx("div",{className:"nice-sankey-tooltip",style:{left:M.x+10,top:M.y-30},children:M.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
|
+
`})]})},Fe=s.forwardRef((n,i)=>{const{t:m}=le.useNiceTranslation(),{initialData:a,data:o,maxPoints:b=60,updateInterval:j=1e3,fetchData:C,width:z=600,height:k=200,chartType:g="line",color:N="var(--nice-color-primary, #3b82f6)",showGrid:D=!0,showTimeAxis:A=!0,showCurrentValue:M=!0,title:d,valueFormatter:l=Y=>Y.toFixed(2),timeFormatter:x=Y=>new Date(Y).toLocaleTimeString(),onDataUpdate:I,paused:v,className:$,style:_,...R}=n,[r,T]=s.useState(a??o??[]),[u,w]=s.useState(v||!1),y=s.useRef(void 0);s.useEffect(()=>{v!==void 0&&w(v)},[v]),s.useEffect(()=>{if(u||!C)return;const Y=async()=>{try{const ie=await C();T(he=>{const ve=[...he,ie].slice(-b);return I?.(ve),ve})}catch(ie){console.error("Failed to fetch realtime data:",ie)}};return y.current=setInterval(Y,j),()=>{y.current&&clearInterval(y.current)}},[u,C,j,b,I]);const P=s.useCallback(Y=>{T(ie=>{const he=[...ie,Y].slice(-b);return I?.(he),he})},[b,I]),H=s.useCallback(()=>{T([]),I?.([])},[I]),X=s.useCallback(()=>w(!0),[]),Z=s.useCallback(()=>w(!1),[]);s.useImperativeHandle(i,()=>({addDataPoint:P,clearData:H,pause:X,resume:Z,getData:()=>r}),[P,H,r]);const B={top:20,right:60,bottom:A?40:20,left:50},U=z-B.left-B.right,V=k-B.top-B.bottom,G=r.map(Y=>Y.value),p=G.length?Math.min(...G):0,re=G.length?Math.max(...G):100,K=(re-p||1)*.1,q=p-K,O=re+K-q,f=Y=>{const ie=C?b-1:Math.max(1,r.length-1);return B.left+Y/ie*U},h=Y=>B.top+V-(Y-q)/O*V,L=r.map((Y,ie)=>`${f(ie)},${h(Y.value)}`).join(" "),ee=r.length>0?`M ${f(0)},${B.top+V} L ${L} L ${f(r.length-1)},${B.top+V} Z`:"",ce=r.length>0?r[r.length-1].value:null;return e.jsxs("div",{className:`nice-realtime-chart ${$||""}`,style:{width:z,..._},...R,children:[e.jsxs("div",{className:"nice-realtime-header",children:[e.jsx("span",{className:"nice-realtime-title",children:d}),e.jsxs("div",{className:"nice-realtime-controls",children:[e.jsxs("span",{className:`nice-realtime-status ${u?"paused":"live"}`,children:[e.jsx("span",{className:"nice-realtime-status-dot"}),e.jsx("span",{children:u?m("charts.paused","Paused"):m("charts.live","Live")})]}),e.jsx("button",{className:`nice-realtime-btn ${u?"paused":""}`,onClick:()=>w(!u),"aria-label":u?m("charts.resume","Resume"):m("charts.pause","Pause"),children:e.jsx(le.NiceIcon,{name:u?"play":"pause",size:14})}),M&&ce!==null&&e.jsx("span",{className:"nice-realtime-value",children:l(ce)})]})]}),e.jsxs("svg",{width:z,height:k,className:"nice-realtime-svg",children:[D&&e.jsx("g",{className:"nice-realtime-grid",children:[0,.25,.5,.75,1].map((Y,ie)=>{const he=B.top+V*(1-Y),ve=q+O*Y;return e.jsxs("g",{children:[e.jsx("line",{x1:B.left,y1:he,x2:z-B.right,y2:he,stroke:"var(--nice-border-color, #e5e7eb)",strokeDasharray:Y===0?void 0:"3"}),e.jsx("text",{x:B.left-8,y:he,textAnchor:"end",dominantBaseline:"middle",fontSize:"10",fill:"var(--nice-text-secondary, #6b7280)",children:Math.round(ve).toLocaleString()})]},ie)})}),g==="area"&&r.length>0&&e.jsx("path",{d:ee,fill:N,fillOpacity:.2}),r.length>1&&e.jsx("polyline",{points:L,fill:"none",stroke:N,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),r.length>0&&e.jsx("circle",{cx:f(r.length-1),cy:h(r[r.length-1].value),r:3,fill:N,className:"nice-realtime-point"}),A&&r.length>0&&e.jsx("g",{className:"nice-realtime-time-axis",children:Array.from(new Set([0,Math.floor(r.length/2),r.length-1].filter(Y=>r[Y]))).map(Y=>e.jsx("text",{x:f(Y),y:k-8,textAnchor:"middle",fontSize:"10",fill:"var(--nice-text-secondary, #6b7280)",children:x(r[Y].timestamp)},`tx-${Y}`))})]}),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: ${N};
|
|
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
|
+
`})]})});Fe.displayName="NiceRealtimeChart";const _t=({data:n,width:i=600,height:m=400,showLabels:a=!0,showValues:o=!0,onNodeClick:b,drilldownEnabled:j=!0,colors:C=We,tilePadding:z=2,className:k,style:g,...N})=>{const{t:D}=le.useNiceTranslation(),A=s.useMemo(()=>Array.isArray(n)?{id:"root",name:"Root",value:n.reduce((w,y)=>w+(y.value||0),0),children:n.map((w,y)=>({id:`${y}`,name:w.label??w.name??`Item ${y+1}`,value:w.value,color:w.color}))}:n,[n]),[M,d]=s.useState(A),[l,x]=s.useState([A.name]),[I,v]=s.useState(null),$=s.useRef(null),_=s.useMemo(()=>{const y=M.children||[];if(y.length===0)return[];const P=y.reduce((p,re)=>p+re.value,0),H=y.map(p=>({node:p,area:p.value/P*i*m}));H.sort((p,re)=>re.area-p.area);const X=[];let Z=0,B=0,U=i,V=m,G=0;for(;G<H.length;){const p=U<V;let re=0,te=[];const K=p?V:U;for(let O=G;O<H.length;O++){const f=[...te,H[O]],h=f.reduce((ee,ce)=>ee+ce.area,0),L=R(f,h,K);if(te.length===0)te=f,re=h;else{const ee=R(te,re,K);if(L<=ee)te=f,re=h;else break}}const q=re/K;let ae=0;te.forEach((O,f)=>{const h=O.area/q;X.push({node:O.node,x:p?Z:Z+ae,y:p?B+ae:B,w:p?q:h,h:p?h:q,color:O.node.color||C[(G+f)%C.length]}),ae+=h}),p?(Z+=q,U-=q):(B+=q,V-=q),G+=te.length}return X},[M,i,m,C]);function R(w,y,P){const H=y/P;let X=0;for(const Z of w){const B=Z.area/H,U=Math.max(H/B,B/H);X=Math.max(X,U)}return X}const r=w=>{b?.(w,[...l,w.name]),j&&w.children&&w.children.length>0&&(d(w),x(y=>[...y,w.name]))},T=()=>{if(l.length<=1)return;let w=A;const y=l.slice(0,-1);for(let P=1;P<y.length;P++){const H=w.children?.find(X=>X.name===y[P]);H&&(w=H)}d(w),x(y)},u=(w,y)=>{const P=$.current?.getBoundingClientRect();P&&v({x:y.clientX-P.left,y:y.clientY-P.top,content:w})};return e.jsxs("div",{className:`nice-treemap-chart ${k||""}`,style:{width:i,...g},...N,children:[e.jsxs("div",{className:"nice-treemap-nav",children:[l.length>1&&e.jsxs("button",{className:"nice-treemap-back",onClick:T,children:[e.jsx(le.NiceIcon,{name:"arrow-left",size:14})," ",D("charts.back","Back")]}),e.jsx("div",{className:"nice-treemap-breadcrumbs",children:l.map((w,y)=>e.jsxs(s.Fragment,{children:[y>0&&e.jsx("span",{className:"nice-treemap-sep",children:"/"}),e.jsx("span",{className:y===l.length-1?"current":"",children:w})]},y))})]}),e.jsx("svg",{ref:$,width:i,height:m,className:"nice-treemap-svg",children:_.map((w,y)=>{const{node:P,x:H,y:X,w:Z,h:B,color:U}=w,V=Math.min(14,Math.max(10,Math.min(Z,B)/6)),G=Z>40&&B>30;return e.jsxs("g",{onClick:()=>r(P),onMouseEnter:p=>u(`${P.name}: ${P.value.toLocaleString()}`,p),onMouseLeave:()=>v(null),children:[e.jsx("rect",{x:H+z/2,y:X+z/2,width:Math.max(0,Z-z),height:Math.max(0,B-z),fill:U,rx:4,className:"nice-treemap-tile"}),a&&G&&e.jsx("text",{x:H+Z/2,y:X+B/2-(o?6:0),textAnchor:"middle",dominantBaseline:"middle",fontSize:V,fill:"white",fontWeight:"500",style:{pointerEvents:"none"},children:P.name.length>Z/V+2?P.name.slice(0,Math.floor(Z/V))+"...":P.name}),o&&G&&e.jsx("text",{x:H+Z/2,y:X+B/2+10,textAnchor:"middle",dominantBaseline:"middle",fontSize:V-2,fill:"var(--nice-overlay-light-80, rgba(255, 255, 255, 0.8))",style:{pointerEvents:"none"},children:P.value.toLocaleString()})]},y)})}),I&&e.jsx("div",{className:"nice-treemap-tooltip",style:{left:I.x+10,top:I.y-30},children:I.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=ge;exports.NiceBarGauge=Ue;exports.NiceBullet=qe;exports.NiceChart=we;exports.NiceChart$1=Ve;exports.NiceChartAI=pt;exports.NiceCircularGauge=Xe;exports.NiceDrillDownChart=Pe;exports.NiceForecastChart=lt;exports.NiceFunnel=Ke;exports.NiceHeatMap=Le;exports.NiceLinearGauge=Ze;exports.NiceLiveChart=Oe;exports.NiceMapChart=yt;exports.NiceOrganizationChart=Be;exports.NicePieChart=Je;exports.NicePolarChart=st;exports.NiceRangeSelector=it;exports.NiceRealtimeChart=Fe;exports.NiceSankey=De;exports.NiceSankey$1=et;exports.NiceSankeyChart=bt;exports.NiceSparkline=ct;exports.NiceStockChart=Ee;exports.NiceTreeMap=Ie;exports.NiceTreeMap$1=rt;exports.NiceTreeMapChart=_t;exports.NiceVectorMap=Te;exports.NiceVectorMap$1=at;exports.createMockLiveChartSource=ft;exports.createSignalRLiveChartSource=ht;exports.createWebSocketLiveChartSource=ut;
|