@nice2dev/ui 1.0.12 → 1.0.15
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 +28 -0
- package/README.md +53 -36
- package/css/legacy-bg-text-aliases.css +83 -0
- package/dist/NiceErrorBoundary-BLTq8mPU.cjs +1 -0
- package/dist/NiceErrorBoundary-Bjw5U31n.js +762 -0
- package/dist/NiceErrorBoundary-CH8SBcSZ.js +762 -0
- package/dist/NiceErrorBoundary-CaVVPLh4.cjs +1 -0
- package/dist/NiceForm-CUlhtlHw.js +5357 -0
- package/dist/NiceForm-DTgIGX88.cjs +382 -0
- package/dist/NiceForm-Dbciuo4w.cjs +382 -0
- package/dist/NiceForm-Jf-ufPZz.js +5357 -0
- package/dist/NiceForm.css +1 -1
- package/dist/NiceModal-Bf1Q1VNL.cjs +1 -0
- package/dist/NiceModal-C_t2qqZd.js +95 -0
- package/dist/NiceModal-DrywdSv3.js +95 -0
- package/dist/NiceModal-FQqBxCij.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-CCFHxKIu.js +6343 -0
- package/dist/NiceModuleLifecyclePanel-CDX38sEx.js +6343 -0
- package/dist/NiceModuleLifecyclePanel-D8cIOI8I.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-xLrOv8nL.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel.css +1 -1
- package/dist/NicePagination-Aj63sKV3.js +171 -0
- package/dist/NicePagination-BVkkePJU.js +171 -0
- package/dist/NicePagination-DGd3Hrh9.cjs +1 -0
- package/dist/NicePagination-DNjVutBJ.cjs +1 -0
- package/dist/NicePinCodeInput-B_0RCKQN.cjs +419 -0
- package/dist/NicePinCodeInput-CDtodnIM.js +11875 -0
- package/dist/NicePinCodeInput-Dffu701_.js +11875 -0
- package/dist/NicePinCodeInput-DytLfqZL.cjs +419 -0
- package/dist/NicePinCodeInput.css +1 -1
- package/dist/NiceSavedQueryPanel-4l-V9dGK.js +6446 -0
- package/dist/NiceSavedQueryPanel-B5TjD_Sb.cjs +596 -0
- package/dist/NiceSavedQueryPanel-CbR3EDQU.cjs +596 -0
- package/dist/NiceSavedQueryPanel-DJqCNWYZ.js +6446 -0
- package/dist/NiceTabs-B-9_mzpc.js +1624 -0
- package/dist/NiceTabs-CHg36waF.cjs +1 -0
- package/dist/NiceTabs-CbKhMxbC.cjs +1 -0
- package/dist/NiceTabs-HXphGn1B.js +1624 -0
- package/dist/NiceWindow-BxGVzUs2.js +1409 -0
- package/dist/NiceWindow-Ceb0mZ_0.js +1409 -0
- package/dist/NiceWindow-DXpnFZ0E.cjs +1 -0
- package/dist/NiceWindow-HhPIzPzs.cjs +1 -0
- package/dist/charts-BPJefcE8.js +4645 -0
- package/dist/charts-Dr6QyMiv.cjs +761 -0
- package/dist/charts-Us8Ep8MJ.cjs +761 -0
- package/dist/charts-fO6InNZd.js +4645 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.mjs +1 -1
- package/dist/core-B-tu8l9M.cjs +96 -0
- package/dist/core-BJ_UNMlX.js +22276 -0
- package/dist/core-DJ4NPp2B.js +22316 -0
- package/dist/core-DPY4m7vb.cjs +96 -0
- package/dist/data.cjs +1 -1
- package/dist/data.d.ts +7 -0
- package/dist/data.mjs +1 -1
- package/dist/editors.cjs +1 -1
- package/dist/editors.mjs +3 -3
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.mjs +2 -2
- package/dist/index-B-9lbtwJ.cjs +5194 -0
- package/dist/index-BNy9Nn0X.js +61422 -0
- package/dist/index-DHc_KZkF.js +61311 -0
- package/dist/index-drIVMHeC.cjs +5194 -0
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1209 -67
- package/dist/index.mjs +887 -871
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.mjs +3 -3
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.d.ts +309 -70
- package/dist/navigation.mjs +92 -91
- package/dist/overlays.cjs +1 -1
- package/dist/overlays.mjs +36 -36
- package/dist/style.css +7 -0
- package/package.json +9 -5
|
@@ -0,0 +1,761 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),o=require("react"),Me=require("./core-DPY4m7vb.cjs"),_e=["var(--color-primary, #3b82f6)","var(--color-error, #ef4444)","var(--color-success, #22c55e)","var(--color-warning, #f59e0b)","var(--color-accent, #8b5cf6)","var(--color-accent-pink, #ec4899)","var(--color-info, #06b6d4)","var(--nice-success, #84cc16)"],we=({series:t,categories:c,width:i=600,height:l=400,title:s,showLegend:b=!0,showGrid:m=!0,axisLabels:A=!0,yAxisLabel:R,xAxisLabel:M,stacked:p,animated:w,zoomable:I,crosshair:S,annotations:N,legendInteractive:d,onDataPointClick:h,exportable:x,className:$,style:g})=>{const v=o.useRef(null),[y,_]=o.useState(new Set),[u,L]=o.useState(null),[a,j]=o.useState(null),[C,E]=o.useState(!1),U=o.useRef(null),V=o.useMemo(()=>t.filter(D=>!y.has(D.name)),[t,y]),H=o.useCallback(D=>{d&&_(re=>{const ae=new Set(re);return ae.has(D)?ae.delete(D):ae.add(D),ae})},[d]),G={top:s?40:20,right:20,bottom:M?60:40,left:R?60:50},Q=i-G.left-G.right,q=l-G.top-G.bottom,J=V[0]?.data.length??t[0]?.data.length??0,n=a?.start??0,X=a?.end??J,Y=X-n,B=o.useMemo(()=>V.map(D=>({...D,data:D.data.slice(n,X)})),[V,n,X]),f=o.useMemo(()=>c?.slice(n,X),[c,n,X]),{minY:P,maxY:F,yTicks:ee}=o.useMemo(()=>{let D;if(p){D=[];for(let k=0;k<Y;k++)D.push(B.reduce((K,se)=>K+(se.data[k]||0),0))}else D=B.flatMap(k=>k.data);D.length===0&&(D=[0]);const re=Math.min(0,...D),ae=Math.max(0,...D),ce=ae-re||1,ie=Math.pow(10,Math.floor(Math.log10(ce)))||1,r=Math.floor(re/ie)*ie,T=Math.ceil(ae/ie)*ie,W=[];for(let k=r;k<=T;k+=ie)W.push(Math.round(k*1e6)/1e6);return W.length<2&&W.push(T),{minY:r,maxY:T,yTicks:W}},[B,Y,p]),O=D=>q-(D-P)/(F-P||1)*q,te=D=>(D+.5)/Y*Q,ue=Y>0?Q/Y/(p?1.5:Math.max(V.length,1)*1.5):20,z=o.useCallback(D=>{if(!I)return;D.preventDefault();const re=a??{start:0,end:J},ae=re.end-re.start,ce=(re.start+re.end)/2,ie=D.deltaY>0?1.2:.8,r=Math.max(2,Math.min(J,Math.round(ae*ie))),T=Math.max(0,Math.round(ce-r/2)),W=Math.min(J,T+r);j({start:T,end:W})},[I,a,J]),Z=o.useCallback(D=>{I&&(E(!0),U.current={x:D.clientX,range:a??{start:0,end:J}})},[I,a,J]),ne=o.useCallback(D=>{const re=v.current?.getBoundingClientRect();if(re&&L({x:D.clientX-re.left-G.left,y:D.clientY-re.top-G.top}),C&&U.current&&I){const ae=D.clientX-U.current.x,ce=Q/Y,ie=-Math.round(ae/ce),r=U.current.range,T=r.end-r.start;let W=r.start+ie;W<0&&(W=0),W+T>J&&(W=J-T),j({start:W,end:W+T})}},[C,I,Q,Y,J,G.left,G.top]),de=o.useCallback(()=>{E(!1),U.current=null},[]),ge=o.useCallback(()=>{L(null),E(!1),U.current=null},[]),xe=o.useCallback(()=>{const D=v.current;if(!D)return;const re=new XMLSerializer().serializeToString(D),ae=document.createElement("canvas");ae.width=i,ae.height=l+(b?30:0);const ce=ae.getContext("2d");if(!ce)return;const ie=new Image;ie.onload=()=>{ce.fillStyle="var(--bg-primary, #fff)",ce.fillRect(0,0,ae.width,ae.height),ce.drawImage(ie,0,0);const r=document.createElement("a");r.download="chart.png",r.href=ae.toDataURL("image/png"),r.click()},ie.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(re)},[i,l,b]),pe=l+(b?30:0),ye=B.length>0&&B.every(D=>D.type==="radar"),je=o.useMemo(()=>{if(!ye)return 1;const D=B.flatMap(re=>re.data);return Math.max(1,...D)},[ye,B]);if(ye){const D=i/2,re=(l-G.top-G.bottom)/2+G.top,ae=Math.min(Q,l-G.top-G.bottom)/2-10,ce=f?.length??B[0]?.data.length??0,ie=W=>W/ce*Math.PI*2-Math.PI/2,r=(W,k)=>{const K=k/je*ae;return[D+Math.cos(ie(W))*K,re+Math.sin(ie(W))*K]},T=4;return e.jsx("div",{className:`nice-chart nice-chart--radar ${$||""}`,style:g,children:e.jsxs("svg",{ref:v,viewBox:`0 0 ${i} ${pe}`,preserveAspectRatio:"xMidYMid meet",width:"100%",height:"100%",className:"nice-chart__svg",style:{display:"block",maxWidth:"100%",maxHeight:"100%"},children:[s&&e.jsx("text",{x:i/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:s}),m&&Array.from({length:T},(W,k)=>{const K=(k+1)/T*ae,se=[];for(let oe=0;oe<ce;oe++)se.push(`${D+Math.cos(ie(oe))*K},${re+Math.sin(ie(oe))*K}`);return e.jsx("polygon",{points:se.join(" "),fill:"none",className:"nice-chart__grid-line"},k)}),Array.from({length:ce},(W,k)=>{const[K,se]=r(k,je);return e.jsx("line",{x1:D,y1:re,x2:K,y2:se,className:"nice-chart__grid-line"},k)}),A&&f?.map((W,k)=>{const[K,se]=r(k,je*1.12);return e.jsx("text",{x:K,y:se,textAnchor:"middle",dominantBaseline:"middle",className:"nice-chart__axis-label",children:W},k)}),B.map((W,k)=>{const K=W.color||_e[k%_e.length],se=W.data.map((oe,le)=>r(le,oe).join(",")).join(" ");return e.jsxs("g",{className:w?"nice-chart__series nice-chart__series--radar nice-chart__series--anim":"nice-chart__series nice-chart__series--radar",children:[e.jsx("polygon",{points:se,fill:K,fillOpacity:.2,stroke:K,strokeWidth:2}),W.data.map((oe,le)=>{const[ve,be]=r(le,oe);return e.jsx("circle",{cx:ve,cy:be,r:3,fill:K,children:e.jsx("title",{children:`${W.name}: ${oe}`})},le)})]},W.name)}),b&&e.jsx("g",{transform:`translate(${G.left}, ${l})`,children:t.map((W,k)=>{const K=k*120,se=y.has(W.name);return e.jsxs("g",{transform:`translate(${K}, 10)`,style:d?{cursor:"pointer"}:void 0,onClick:()=>H(W.name),opacity:se?.35:1,children:[e.jsx("rect",{width:12,height:12,rx:2,fill:W.color||_e[k%_e.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 ${$||""}`,style:g,children:[x&&e.jsx("button",{type:"button",className:"nice-chart__export-btn",onClick:xe,title:"Export PNG",children:"📷"}),e.jsxs("svg",{ref:v,viewBox:`0 0 ${i} ${pe}`,preserveAspectRatio:"xMidYMid meet",width:"100%",height:"100%",style:{display:"block",maxWidth:"100%",maxHeight:"100%"},className:"nice-chart__svg",onWheel:z,onMouseDown:Z,onMouseMove:ne,onMouseUp:de,onMouseLeave:ge,children:[e.jsxs("g",{transform:`translate(${G.left},${G.top})`,children:[s&&e.jsx("text",{x:Q/2,y:-10,textAnchor:"middle",className:"nice-chart__title",children:s}),m&&ee.map(D=>e.jsx("line",{x1:0,y1:O(D),x2:Q,y2:O(D),className:"nice-chart__grid-line"},`grid-${D}`)),A&&ee.map(D=>e.jsx("text",{x:-8,y:O(D)+4,textAnchor:"end",className:"nice-chart__axis-label",children:D},`ylabel-${D}`)),A&&f&&f.map((D,re)=>e.jsx("text",{x:te(re),y:q+20,textAnchor:"middle",className:"nice-chart__axis-label",children:D},re)),R&&e.jsx("text",{x:-G.left+14,y:q/2,textAnchor:"middle",transform:`rotate(-90, -${G.left-14}, ${q/2})`,className:"nice-chart__axis-title",children:R}),M&&e.jsx("text",{x:Q/2,y:q+45,textAnchor:"middle",className:"nice-chart__axis-title",children:M}),e.jsx("line",{x1:0,y1:0,x2:0,y2:q,className:"nice-chart__axis"}),e.jsx("line",{x1:0,y1:q,x2:Q,y2:q,className:"nice-chart__axis"}),N?.map((D,re)=>{if(D.type==="line"){const ae=O(D.value);return e.jsxs("g",{children:[e.jsx("line",{x1:0,y1:ae,x2:Q,y2:ae,stroke:D.color||"var(--color-error, #ef4444)",strokeWidth:1.5,strokeDasharray:D.dash||"6,3"}),D.label&&e.jsx("text",{x:Q+4,y:ae+4,className:"nice-chart__annotation-label",fill:D.color||"var(--color-error, #ef4444)",children:D.label})]},re)}return e.jsx("text",{x:te(D.value),y:-4,textAnchor:"middle",className:"nice-chart__annotation-label",fill:D.color||"var(--text-muted, #6b7280)",children:D.label},re)}),S&&u&&u.x>=0&&u.x<=Q&&u.y>=0&&u.y<=q&&e.jsxs(e.Fragment,{children:[e.jsx("line",{x1:u.x,y1:0,x2:u.x,y2:q,stroke:"var(--nice-text-muted, #9ca3af)",strokeWidth:1,strokeDasharray:"4,2"}),e.jsx("line",{x1:0,y1:u.y,x2:Q,y2:u.y,stroke:"var(--nice-text-muted, #9ca3af)",strokeWidth:1,strokeDasharray:"4,2"})]}),B.map((D,re)=>{const ae=D.color||_e[re%_e.length],ce=D.type||"bar";if(ce==="bar")return e.jsx("g",{className:w?"nice-chart__series nice-chart__series--bar nice-chart__series--anim":"nice-chart__series nice-chart__series--bar",children:D.data.map((r,T)=>{let W,k;if(p){const se=B.slice(0,re).reduce((oe,le)=>oe+(le.data[T]||0),0);W=O(se+r),k=O(se)-W}else W=O(Math.max(0,r)),k=Math.abs(O(r)-O(0));const K=p?te(T)-ue/2:te(T)-B.length*ue/2+re*ue;return e.jsx("rect",{x:K,y:W,width:ue*.9,height:Math.max(0,k),fill:ae,rx:2,style:{transformOrigin:`${K+ue*.9/2}px ${O(0)}px`,...h?{cursor:"pointer"}:{}},onClick:h?()=>h(D.name,n+T,r):void 0,children:e.jsx("title",{children:`${D.name}: ${r}`})},T)})},D.name);if(ce==="scatter")return e.jsx("g",{className:w?"nice-chart__series nice-chart__series--scatter nice-chart__series--anim":"nice-chart__series nice-chart__series--scatter",children:D.data.map((r,T)=>e.jsx("circle",{cx:te(T),cy:O(r),r:5,fill:ae,fillOpacity:.7,stroke:ae,strokeWidth:1.5,style:h?{cursor:"pointer"}:void 0,onClick:h?()=>h(D.name,n+T,r):void 0,children:e.jsx("title",{children:`${D.name}: ${r}`})},T))},D.name);const ie=D.data.map((r,T)=>`${te(T)},${O(r)}`);return e.jsxs("g",{className:w?`nice-chart__series nice-chart__series--${ce} nice-chart__series--anim`:`nice-chart__series nice-chart__series--${ce}`,children:[ce==="area"&&e.jsx("polygon",{points:`${te(0)},${O(0)} ${ie.join(" ")} ${te(Y-1)},${O(0)}`,fill:ae,opacity:.15}),e.jsx("polyline",{points:ie.join(" "),fill:"none",stroke:ae,strokeWidth:2,className:w?"nice-chart__line":void 0}),D.data.map((r,T)=>e.jsx("circle",{cx:te(T),cy:O(r),r:3,fill:ae,style:h?{cursor:"pointer"}:void 0,onClick:h?()=>h(D.name,n+T,r):void 0,children:e.jsx("title",{children:`${D.name}: ${r}`})},T))]},D.name)})]}),b&&e.jsx("g",{transform:`translate(${G.left}, ${l})`,children:t.map((D,re)=>{const ae=re*120,ce=y.has(D.name);return e.jsxs("g",{transform:`translate(${ae}, 10)`,style:d?{cursor:"pointer"}:void 0,onClick:()=>H(D.name),opacity:ce?.35:1,children:[e.jsx("rect",{width:12,height:12,rx:2,fill:D.color||_e[re%_e.length]}),e.jsx("text",{x:16,y:10,className:"nice-chart__legend-text",style:ce?{textDecoration:"line-through"}:void 0,children:D.name})]},D.name)})})]})]})},Ye=Object.freeze(Object.defineProperty({__proto__:null,NiceChart:we},Symbol.toStringTag,{value:"Module"}));function Ve(t){if(!t.length)return{categories:[],numericFields:[],sampleValues:{}};const c=t[0],i=[],l={};let s=null;for(const[m,A]of Object.entries(c))typeof A=="number"?(i.push(m),l[m]=t.map(R=>Number(R[m])||0)):!s&&(typeof A=="string"||A instanceof Date)&&(s=m);return{categories:s?t.map(m=>String(m[s]||"")):t.map((m,A)=>`Item ${A+1}`),numericFields:i,sampleValues:l}}function Xe(t,c){const{categories:i,numericFields:l,sampleValues:s}=Ve(t);return{series:l.map((m,A)=>({name:m.replace(/([A-Z])/g," $1").replace(/^./,R=>R.toUpperCase()).trim(),data:s[m],type:c==="area"?"area":c==="line"?"line":"bar"})),categories:i}}const Ze=o.forwardRef(function(c,i){const{rawData:l,enableAI:s=!0,aiModel:b,enableAutoType:m=!0,enableInsights:A=!0,dataDescription:R,onChartSuggestion:M,onInsights:p,showAIToolbar:w=!0,showInsightsOnLoad:I=!1,series:S,categories:N,...d}=c,[h,x]=o.useState("bar"),[$,g]=o.useState(null),[v,y]=o.useState([]),[_,u]=o.useState(I),[L,a]=o.useState(null),{t:j}=Me.$o(),C=Me.ie(),{suggestChartType:E,generateInsights:U,isLoading:V}=Me.Cl(),H=s&&C.isConfigured,{series:G,categories:Q}=l?Xe(l,L||h):{series:S||[],categories:N},q=o.useCallback(async()=>{if(!H||!m)return{type:"bar",reason:"Default",config:{}};const B=l||(S?.length?S.flatMap(f=>f.data.map((P,F)=>({[f.name]:P,index:F}))):[]);try{const f=await E(B,R),P={type:f.type,reason:f.reason,config:f.config};return g(P),x(P.type),M?.(P),P}catch{return{type:"bar",reason:"Default fallback",config:{}}}},[H,m,l,S,R,E,M]),J=o.useCallback(async()=>{if(!H||!A)return[];const B=l||(S?.length?S.flatMap(f=>f.data.map((P,F)=>({[f.name]:P,category:N?.[F]||F}))):[]);try{const f=await U(B,L||h);return y(f),p?.(f),f}catch{return[]}},[H,A,l,S,N,h,L,U,p]),n=o.useCallback(()=>L||h,[L,h]);o.useEffect(()=>{H&&m&&(l?.length||S?.length)&&q()},[H,m,l,S]),o.useImperativeHandle(i,()=>({getSuggestion:q,generateInsights:J,getCurrentType:n}));const X=[{type:"bar",icon:"📊",label:"Bar"},{type:"line",icon:"📈",label:"Line"},{type:"area",icon:"🏔️",label:"Area"},{type:"pie",icon:"🥧",label:"Pie"},{type:"donut",icon:"🍩",label:"Donut"},{type:"scatter",icon:"⭐",label:"Scatter"}],Y=L||h;return e.jsxs("div",{className:"nice-chart-ai","data-testid":c["data-testid"],children:[w&&H&&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"}),$&&e.jsxs("div",{className:"nice-chart-ai__suggestion",children:[e.jsx("span",{className:"nice-chart-ai__suggestion-icon",children:"💡"}),e.jsxs("span",{className:"nice-chart-ai__suggestion-text",children:[j("chartAI.suggestedType","Suggested:")," ",$.type]}),e.jsxs("span",{className:"nice-chart-ai__suggestion-reason",title:$.reason,children:["(",$.reason,")"]})]}),V&&e.jsx("span",{className:"nice-chart-ai__loading",children:j("chartAI.analyzing","Analyzing...")})]}),e.jsx("div",{className:"nice-chart-ai__toolbar-center",children:e.jsx("div",{className:"nice-chart-ai__type-selector",children:X.filter(B=>["bar","line","area"].includes(B.type)).map(({type:B,icon:f,label:P})=>e.jsx("button",{type:"button",className:`nice-chart-ai__type-btn ${Y===B?"nice-chart-ai__type-btn--active":""}`,onClick:()=>a(B),title:P,children:f},B))})}),e.jsxs("div",{className:"nice-chart-ai__toolbar-right",children:[e.jsxs("button",{type:"button",className:"nice-chart-ai__auto-btn",onClick:()=>q(),disabled:V,title:j("chartAI.autoDetect","Auto-detect best chart type"),children:["🔮 ",j("chartAI.auto","Auto")]}),A&&e.jsxs("button",{type:"button",className:"nice-chart-ai__insights-btn",onClick:()=>{v.length||J(),u(!_)},disabled:V,title:j("chartAI.showInsights","Show data insights"),children:["💡 ",j("chartAI.insights","Insights")]})]})]}),e.jsx("div",{className:"nice-chart-ai__chart-wrapper",children:e.jsx(we,{series:G,categories:Q,...d})}),_&&v.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:["💡 ",j("chartAI.dataInsights","Data Insights")]}),e.jsx("button",{type:"button",className:"nice-chart-ai__insights-close",onClick:()=>u(!1),children:"✕"})]}),e.jsx("ul",{className:"nice-chart-ai__insights-list",children:v.map((B,f)=>e.jsxs("li",{className:"nice-chart-ai__insight",children:[e.jsx("span",{className:"nice-chart-ai__insight-icon",children:"•"}),B]},f))}),e.jsx("div",{className:"nice-chart-ai__insights-footer",children:e.jsxs("button",{type:"button",className:"nice-chart-ai__refresh",onClick:()=>J(),disabled:V,children:["🔄 ",j("chartAI.refresh","Refresh")]})})]}),_&&V&&e.jsx("div",{className:"nice-chart-ai__insights nice-chart-ai__insights--loading",children:e.jsxs("div",{className:"nice-chart-ai__loading-content",children:[e.jsx("span",{className:"nice-chart-ai__spinner"}),j("chartAI.generatingInsights","Generating insights...")]})})]})});function Ue(t,c){const i=t?typeof t=="number"?new Date(t):new Date(t):new Date,l=R=>R.toString().padStart(2,"0"),s=l(i.getHours()),b=l(i.getMinutes()),m=l(i.getSeconds()),A=i.getMilliseconds().toString().padStart(3,"0");switch(c){case"HH:mm:ss":return`${s}:${b}:${m}`;case"HH:mm":return`${s}:${b}`;case"mm:ss":return`${b}:${m}`;case"ss.SSS":return`${m}.${A}`;case"ISO":return i.toISOString();default:return`${s}:${b}:${m}`}}function Ie(t){if(t.length===0)return null;const c=Math.min(...t),i=Math.max(...t),l=t.reduce((b,m)=>b+m,0)/t.length,s=t[t.length-1];return{min:c,max:i,avg:l,current:s,count:t.length}}const Re=o.forwardRef(({series:t,maxPoints:c=100,slidingWindow:i=!0,refreshRate:l=16,dataSource:s,width:b=600,height:m=400,title:A,showLegend:R=!0,showGrid:M=!0,yAxisLabel:p,xAxisLabel:w,stacked:I,zoomable:S,crosshair:N,annotations:d=[],legendInteractive:h,onDataPointClick:x,exportable:$,showControls:g=!0,showStatus:v=!0,initialPaused:y=!1,onDataReceived:_,onDataDropped:u,timeFormat:L="HH:mm:ss",showStats:a,thresholds:j=[],className:C,style:E},U)=>{const[V,H]=o.useState(()=>{const z=new Map;for(const Z of t)z.set(Z.name,Z.initialData?.slice()??[]);return z}),[G,Q]=o.useState([]),[q,J]=o.useState(y),[n,X]=o.useState(!1),Y=o.useRef([]),B=o.useRef(Date.now()),f=o.useRef(null),P=o.useCallback(()=>{const z=Y.current;z.length!==0&&(Y.current=[],H(Z=>{const ne=new Map(Z);for(const de of z){const ge=ne.get(de.series);if(!ge)continue;const xe=[...ge,de.value];if(i&&xe.length>c){const pe=xe.length-c;u?.(pe,de.series),xe.splice(0,pe)}ne.set(de.series,xe)}return ne}),z.length>0&&Q(Z=>{const ne=[...Z];for(const de of z){const ge=de.category??Ue(de.timestamp,L);ne.push(ge)}return i&&ne.length>c&&ne.splice(0,ne.length-c),ne}))},[i,c,L,u]),F=o.useCallback(()=>{const z=Date.now();z-B.current>=l&&(P(),B.current=z),f.current=requestAnimationFrame(F)},[l,P]);o.useEffect(()=>(q||(f.current=requestAnimationFrame(F)),()=>{f.current!==null&&(cancelAnimationFrame(f.current),f.current=null)}),[q,F]);const ee=o.useCallback(z=>{if(q)return;const Z="points"in z?z.points:[z];for(const ne of Z)V.has(ne.series)&&(Y.current.push(ne),_?.(ne))},[q,V,_]);o.useEffect(()=>{if(!s)return;const z=s.subscribe(ee);let Z;return s.onStatusChange?Z=s.onStatusChange(X):X(!0),s.fetchHistory&&s.fetchHistory(c).then(ne=>{for(const de of ne)Y.current.push(de);P()}),()=>{z(),Z?.()}},[s,ee,c,P]);const O=o.useMemo(()=>t.map(z=>({name:z.name,color:z.color,type:z.type,data:V.get(z.name)??[]})),[t,V]),te=o.useMemo(()=>{const z=[...d];for(const Z of j)z.push({type:"line",value:Z.value,color:Z.color,label:Z.label,dash:Z.style==="dashed"?"5,5":Z.style==="dotted"?"2,2":void 0});return z},[d,j]);o.useImperativeHandle(U,()=>({pause(){J(!0)},resume(){J(!1)},isPaused(){return q},clear(){H(z=>{const Z=new Map(z);for(const ne of Z.keys())Z.set(ne,[]);return Z}),Q([]),Y.current=[]},addPoint(z){ee(z)},addPoints(z){ee({points:z})},getData(z){return V.get(z)??[]},getCategories(){return G},exportData(){return{series:O,categories:G}},getStats(z){const Z=V.get(z);return Z?Ie(Z):null}}),[q,V,G,O,ee]);const ue=o.useMemo(()=>{if(!a)return null;const z={};for(const[Z,ne]of V)z[Z]=Ie(ne);return z},[a,V]);return e.jsxs("div",{className:C,style:{position:"relative",...E},children:[v&&e.jsxs("div",{style:{position:"absolute",top:8,right:8,display:"flex",alignItems:"center",gap:4,fontSize:12,color:n?"var(--color-success, #22c55e)":"var(--color-error, #ef4444)",zIndex:10},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:n?"var(--color-success, #22c55e)":"var(--color-error, #ef4444)"}}),n?"Live":"Disconnected"]}),g&&e.jsx("div",{style:{position:"absolute",top:8,left:8,display:"flex",gap:4,zIndex:10},children:e.jsx("button",{onClick:()=>J(z=>!z),style:{padding:"4px 8px",fontSize:12,border:"1px solid var(--border-color, #ddd)",borderRadius:4,background:q?"var(--warning-bg, #fef3c7)":"var(--bg-primary, #fff)",cursor:"pointer"},title:q?"Resume":"Pause",children:q?"▶":"⏸"})}),a&&ue&&e.jsx("div",{style:{position:"absolute",bottom:50,right:8,background:"var(--nice-overlay-light-90, rgba(255, 255, 255, 0.9))",border:"1px solid var(--border-color, #ddd)",borderRadius:4,padding:8,fontSize:11,zIndex:10},children:Object.entries(ue).map(([z,Z])=>Z?e.jsxs("div",{style:{marginBottom:4},children:[e.jsx("strong",{children:z}),e.jsxs("div",{children:["Min: ",Z.min.toFixed(2)," | Max: ",Z.max.toFixed(2)]}),e.jsxs("div",{children:["Avg: ",Z.avg.toFixed(2)," | Now: ",Z.current.toFixed(2)]})]},z):null)}),e.jsx(we,{series:O,categories:G,width:b,height:m,title:A,showLegend:R,showGrid:M,yAxisLabel:p,xAxisLabel:w,stacked:I,zoomable:S,crosshair:N,annotations:te,legendInteractive:h,onDataPointClick:x,exportable:$})]})});Re.displayName="NiceLiveChart";function Ge(t){const{hubConnection:c,eventName:i="DataPoint",subscribeMethod:l="SubscribeToMetrics",historyMethod:s="GetMetricHistory",metricName:b}=t;return{subscribe(m){const A=R=>{m(R)};return c.on(i,A),c.state==="Connected"&&c.invoke(l,b).catch(()=>{}),()=>{c.off(i,A)}},async fetchHistory(m){try{return await c.invoke(s,b,m)}catch{return[]}},onStatusChange(m){const A=()=>m(c.state==="Connected");return c.onclose(()=>m(!1)),c.onreconnected(()=>m(!0)),A(),()=>{}}}}function qe(t){const{url:c,autoReconnect:i=!0,reconnectDelay:l=3e3,parseMessage:s=p=>JSON.parse(p)}=t;let b=null,m=null,A=null,R=null;const M=()=>{b=new WebSocket(c),b.onopen=()=>{m?.(!0)},b.onclose=()=>{m?.(!1),i&&(R=setTimeout(M,l))},b.onerror=()=>{b?.close()},b.onmessage=p=>{try{const w=s(p.data);w&&A&&A(w)}catch{}}};return{subscribe(p){return A=p,M(),()=>{A=null,R&&clearTimeout(R),b?.close(),b=null}},onStatusChange(p){return m=p,()=>{m=null}}}}function Je(t){const{seriesNames:c,interval:i=1e3,generateValue:l=()=>Math.random()*100}=t;let s=null,b=0;return{subscribe(m){return s=setInterval(()=>{for(const A of c)m({series:A,value:l(A,b),timestamp:Date.now()});b++},i),()=>{s&&clearInterval(s)}},onStatusChange(m){return m(!0),()=>{}}}}const me=["#3b82f6","#ef4444","#22c55e","#f59e0b","#8b5cf6","#ec4899","#06b6d4","#84cc16"],Ke=({data:t,width:c=400,height:i=400,innerRadius:l=0,title:s,showLegend:b=!0,showLabels:m=!0,className:A,style:R})=>{const M=c/2,p=(i-(b?30:0))/2+(s?10:0),w=Math.min(M,p)-40,I=t.reduce((d,h)=>d+h.value,0);let S=-Math.PI/2;const N=t.map((d,h)=>{const x=d.value/(I||1)*Math.PI*2,$=S;S+=x;const g=S,v=($+g)/2,y=M+w*Math.cos($),_=p+w*Math.sin($),u=M+w*Math.cos(g),L=p+w*Math.sin(g),a=x>Math.PI?1:0,j=d.color||me[h%me.length];let C;if(l>0){const H=M+l*Math.cos($),G=p+l*Math.sin($),Q=M+l*Math.cos(g),q=p+l*Math.sin(g);C=`M${y},${_} A${w},${w} 0 ${a},1 ${u},${L} L${Q},${q} A${l},${l} 0 ${a},0 ${H},${G} Z`}else C=`M${M},${p} L${y},${_} A${w},${w} 0 ${a},1 ${u},${L} Z`;const E=M+w*.7*Math.cos(v),U=p+w*.7*Math.sin(v),V=I>0?Math.round(d.value/I*100):0;return{...d,path:C,labelX:E,labelY:U,pct:V,color:j}});return e.jsx("div",{className:`nice-piechart ${A||""}`,style:R,children:e.jsxs("svg",{viewBox:`0 0 ${c} ${i}`,preserveAspectRatio:"xMidYMid meet",width:"100%",height:"100%",style:{display:"block",maxWidth:"100%",maxHeight:"100%"},className:"nice-piechart__svg",children:[s&&e.jsx("text",{x:M,y:20,textAnchor:"middle",className:"nice-chart__title",children:s}),N.map((d,h)=>e.jsxs("g",{children:[e.jsx("path",{d:d.path,fill:d.color,stroke:"var(--bg-primary, #fff)",strokeWidth:2,children:e.jsx("title",{children:`${d.label}: ${d.value} (${d.pct}%)`})}),m&&d.pct>=5&&e.jsxs("text",{x:d.labelX,y:d.labelY,textAnchor:"middle",dominantBaseline:"middle",className:"nice-piechart__label",children:[d.pct,"%"]})]},h)),b&&e.jsx("g",{transform:`translate(10, ${i-25})`,children:t.map((d,h)=>e.jsxs("g",{transform:`translate(${h*100}, 0)`,children:[e.jsx("rect",{width:10,height:10,rx:2,fill:d.color||me[h%me.length]}),e.jsx("text",{x:14,y:9,className:"nice-chart__legend-text",children:d.label})]},h))})]})})},Qe=({series:t,categories:c,width:i=400,height:l=400,maxValue:s,title:b,showLegend:m=!0,className:A,style:R})=>{const M=i/2,p=(l-(m?30:0))/2+(b?10:0),w=Math.min(M,p)-60,I=c.length,S=s??Math.max(...t.flatMap(x=>x.data),1),N=Math.PI*2/I,d=5,h=(x,$)=>{const g=x*N-Math.PI/2,v=$/S*w;return{x:M+v*Math.cos(g),y:p+v*Math.sin(g)}};return e.jsx("div",{className:`nice-polarchart ${A||""}`,style:R,children:e.jsxs("svg",{width:i,height:l,className:"nice-polarchart__svg",children:[b&&e.jsx("text",{x:M,y:20,textAnchor:"middle",className:"nice-chart__title",children:b}),Array.from({length:d},(x,$)=>{const g=w*(($+1)/d);return e.jsx("circle",{cx:M,cy:p,r:g,fill:"none",stroke:"var(--border-color, #ddd)",strokeWidth:.5},$)}),c.map((x,$)=>{const g=h($,S),v=h($,S*1.22),y=$*N-Math.PI/2,_=Math.cos(y),u=Math.sin(y),L=_>.2?"start":_<-.2?"end":"middle",a=u>.2?"hanging":u<-.2?"auto":"middle";return e.jsxs("g",{children:[e.jsx("line",{x1:M,y1:p,x2:g.x,y2:g.y,stroke:"var(--border-color, #ddd)",strokeWidth:.5}),e.jsx("text",{x:v.x,y:v.y,textAnchor:L,dominantBaseline:a,className:"nice-chart__axis-label nice-chart__axis-label--polar",children:x})]},$)}),t.map((x,$)=>{const g=x.color||me[$%me.length],v=x.data.map((y,_)=>{const u=h(_,y);return`${u.x},${u.y}`}).join(" ");return e.jsxs("g",{children:[e.jsx("polygon",{points:v,fill:x.fill!==!1?g:"none",fillOpacity:.15,stroke:g,strokeWidth:2}),x.data.map((y,_)=>{const u=h(_,y);return e.jsx("circle",{cx:u.x,cy:u.y,r:3,fill:g,children:e.jsx("title",{children:`${x.name} - ${c[_]}: ${y}`})},_)})]},x.name)}),m&&e.jsx("g",{transform:`translate(10, ${l-25})`,children:t.map((x,$)=>e.jsxs("g",{transform:`translate(${$*100}, 0)`,children:[e.jsx("rect",{width:10,height:10,rx:2,fill:x.color||me[$%me.length]}),e.jsx("text",{x:14,y:9,className:"nice-chart__legend-text",children:x.name})]},$))})]})})},et=({value:t,min:c=0,max:i=100,width:l=200,height:s=200,startAngle:b=225,endAngle:m=-45,color:A="var(--color-primary, #3b82f6)",trackColor:R,label:M,formatValue:p,ranges:w,className:I,style:S})=>{const N=l/2,d=s/2,h=Math.min(N,d)-20,x=Math.max(0,Math.min(1,(t-c)/(i-c||1))),$=a=>a*Math.PI/180,g=(b-m+360)%360||360,v=a=>({x:N+h*Math.cos($(a)),y:d-h*Math.sin($(a))}),y=(a,j)=>{const C=v(a),E=v(j),V=(a-j+360)%360>180?1:0;return`M${C.x},${C.y} A${h},${h} 0 ${V},1 ${E.x},${E.y}`},_=b-x*g,u=v(_);let L=A;if(w){for(const a of w)if(t>=a.start&&t<=a.end){L=a.color;break}}return e.jsx("div",{className:`nice-gauge nice-gauge--circular ${I||""}`,style:S,children:e.jsxs("svg",{width:l,height:s,children:[e.jsx("path",{d:y(b,m),fill:"none",stroke:R||"var(--border-color, #e2e8f0)",strokeWidth:12,strokeLinecap:"round"}),x>0&&e.jsx("path",{d:y(b,_),fill:"none",stroke:L,strokeWidth:12,strokeLinecap:"round"}),e.jsx("line",{x1:N,y1:d,x2:u.x,y2:u.y,stroke:"var(--text-primary, #333)",strokeWidth:2,strokeLinecap:"round"}),e.jsx("circle",{cx:N,cy:d,r:4,fill:"var(--text-primary, #333)"}),e.jsx("text",{x:N,y:d+h*.6,textAnchor:"middle",className:"nice-gauge__value",children:p?p(t):t}),M&&e.jsx("text",{x:N,y:d+h*.95,textAnchor:"middle",className:"nice-gauge__label",children:M})]})})},tt=({value:t,min:c=0,max:i=100,width:l=300,height:s=60,orientation:b="horizontal",color:m="var(--color-primary, #3b82f6)",label:A,formatValue:R,ranges:M,showTicks:p=!0,tickCount:w=5,className:I,style:S})=>{const N=b==="horizontal",d=N?l-40:s-40,h=Math.max(0,Math.min(1,(t-c)/(i-c||1))),x=10;let $=m;if(M){for(const v of M)if(t>=v.start&&t<=v.end){$=v.color;break}}const g=Array.from({length:w},(v,y)=>c+(i-c)*(y/(w-1)));return N?e.jsx("div",{className:`nice-gauge nice-gauge--linear ${I||""}`,style:S,children:e.jsxs("svg",{width:l,height:s,children:[e.jsx("text",{x:20+d*h,y:14,textAnchor:"middle",className:"nice-gauge__value",style:{fontSize:12},children:R?R(t):t}),e.jsx("rect",{x:20,y:s/2-x/2,width:d,height:x,rx:5,fill:"var(--border-color, #e2e8f0)"}),e.jsx("rect",{x:20,y:s/2-x/2,width:d*h,height:x,rx:5,fill:$}),e.jsx("polygon",{points:`${20+d*h},${s/2-x/2-2} ${20+d*h-5},${s/2-x/2-8} ${20+d*h+5},${s/2-x/2-8}`,fill:"var(--text-primary, #333)"}),p&&g.map((v,y)=>{const _=20+(v-c)/(i-c)*d;return e.jsx("text",{x:_,y:s/2+x/2+12,textAnchor:"middle",className:"nice-gauge__tick",children:v},y)}),A&&e.jsx("text",{x:l/2,y:s-2,textAnchor:"middle",className:"nice-gauge__label",children:A})]})}):e.jsx("div",{className:`nice-gauge nice-gauge--linear nice-gauge--vertical ${I||""}`,style:S,children:e.jsxs("svg",{width:l,height:s,children:[e.jsx("rect",{x:l/2-x/2,y:20,width:x,height:d,rx:5,fill:"var(--border-color, #e2e8f0)"}),e.jsx("rect",{x:l/2-x/2,y:20+d*(1-h),width:x,height:d*h,rx:5,fill:$}),e.jsx("text",{x:l/2,y:14,textAnchor:"middle",className:"nice-gauge__value",children:R?R(t):t}),A&&e.jsx("text",{x:l/2,y:s-4,textAnchor:"middle",className:"nice-gauge__label",children:A})]})})},nt=({items:t,min:c=0,max:i=100,width:l=300,height:s=300,startAngle:b=225,endAngle:m=-45,formatValue:A,title:R,className:M,style:p})=>{const w=l/2,I=s/2,S=Math.min(w,I)-30,N=Math.min(20,S/(t.length+1)),d=4,h=g=>g*Math.PI/180,x=(b-m+360)%360||360,$=(g,v,y)=>{const _=w+g*Math.cos(h(v)),u=I-g*Math.sin(h(v)),L=w+g*Math.cos(h(y)),a=I-g*Math.sin(h(y)),j=(v-y+360)%360;return`M${_},${u} A${g},${g} 0 ${j>180?1:0},1 ${L},${a}`};return e.jsx("div",{className:`nice-bargauge ${M||""}`,style:p,children:e.jsxs("svg",{width:l,height:s,children:[R&&e.jsx("text",{x:w,y:20,textAnchor:"middle",className:"nice-chart__title",children:R}),t.map((g,v)=>{const y=S-v*(N+d),_=Math.max(0,Math.min(1,(g.value-c)/(i-c||1))),u=b-_*x,L=g.color||me[v%me.length];return e.jsxs("g",{children:[e.jsx("path",{d:$(y,b,m),fill:"none",stroke:"var(--border-color, #e2e8f0)",strokeWidth:N,strokeLinecap:"round"}),_>0&&e.jsx("path",{d:$(y,b,u),fill:"none",stroke:L,strokeWidth:N,strokeLinecap:"round"})]},v)}),e.jsx("g",{children:t.map((g,v)=>e.jsxs("text",{x:w,y:I-((t.length-1)/2-v)*16,textAnchor:"middle",dominantBaseline:"middle",className:"nice-gauge__value",style:{fontSize:12},children:[g.label?`${g.label}: `:"",A?A(g.value):g.value]},v))})]})})},rt=({data:t,width:c=120,height:i=30,type:l="line",color:s="var(--color-primary, #3b82f6)",showMinMax:b,showLastPoint:m=!0,className:A,style:R})=>{if(t.length===0)return null;const M=2,p=Math.min(...t),w=Math.max(...t),I=w-p||1,S=c-M*2,N=i-M*2,d=y=>M+y/(t.length-1||1)*S,h=y=>M+N-(y-p)/I*N;if(l==="bar"){const y=Math.max(1,S/t.length-1);return e.jsx("svg",{width:c,height:i,className:`nice-sparkline ${A||""}`,style:R,children:t.map((_,u)=>e.jsx("rect",{x:M+u/t.length*S,y:h(_),width:y,height:N-(h(_)-M),fill:s,rx:1},u))})}const x=t.map((y,_)=>`${d(_)},${h(y)}`).join(" "),$=t.indexOf(p),g=t.indexOf(w),v=t.length-1;return e.jsxs("svg",{width:c,height:i,className:`nice-sparkline ${A||""}`,style:R,children:[l==="area"&&e.jsx("polygon",{points:`${d(0)},${M+N} ${x} ${d(v)},${M+N}`,fill:s,opacity:.15}),e.jsx("polyline",{points:x,fill:"none",stroke:s,strokeWidth:1.5}),b&&e.jsx("circle",{cx:d($),cy:h(p),r:2,fill:"var(--nice-danger, #ef4444)"}),b&&e.jsx("circle",{cx:d(g),cy:h(w),r:2,fill:"var(--nice-success, #22c55e)"}),m&&e.jsx("circle",{cx:d(v),cy:h(t[v]),r:2,fill:s})]})},at={sm:{width:160,height:22,fontSize:11},md:{width:220,height:32,fontSize:12},lg:{width:320,height:44,fontSize:14}},st=({value:t,target:c,min:i=0,max:l=100,width:s,height:b,color:m="var(--color-primary, #3b82f6)",targetColor:A="var(--color-error, #ef4444)",size:R="md",label:M,labelPlacement:p="top",showValue:w=!1,showTarget:I=!1,formatValue:S=$=>String($),state:N="normal",errorMessage:d,className:h,style:x})=>{const $=at[R],g=s??$.width,v=b??$.height,y=$.fontSize,_=4,u=g-_*2,L=I&&c!=null?y+4:_,a=I&&c!=null?v+(L-_):v,j=a-L-_,C=Math.max(0,Math.min(1,(t-i)/(l-i||1))),E=c!=null?Math.max(0,Math.min(1,(c-i)/(l-i||1))):null,U=()=>N==="error"?e.jsx("div",{role:"alert",style:{width:g,height:a,display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed var(--color-error, #ef4444)",borderRadius:4,color:"var(--color-error, #ef4444)",fontSize:y,padding:"0 8px",boxSizing:"border-box"},children:d??"Error"}):N==="loading"?e.jsx("div",{role:"status","aria-label":"Loading",className:"nice-bullet__skeleton",style:{width:g,height:a,borderRadius:4,background:"linear-gradient(90deg, var(--bg-tertiary, #e5e7eb) 25%, var(--bg-secondary, #f3f4f6) 50%, var(--bg-tertiary, #e5e7eb) 75%)",backgroundSize:"200% 100%",animation:"nice-bullet-shimmer 1.4s linear infinite"}}):e.jsxs("svg",{width:g,height:a,role:"img","aria-label":typeof M=="string"?M:void 0,children:[e.jsx("rect",{x:_,y:L,width:u,height:j,rx:3,fill:"var(--border-color, #e2e8f0)"}),e.jsx("rect",{x:_,y:L+j*.2,width:u*C,height:j*.6,rx:2,fill:m}),E!=null&&e.jsx("line",{x1:_+u*E,y1:L+2,x2:_+u*E,y2:L+j-2,stroke:A,strokeWidth:2}),w&&e.jsx("text",{x:_+Math.max(u*C,4),y:L+j/2,dx:u*C>24?-4:4,textAnchor:u*C>24?"end":"start",dominantBaseline:"middle",fontSize:y,fill:u*C>24?"var(--text-on-primary, #ffffff)":"var(--text-primary)",fontWeight:600,children:S(t)}),I&&E!=null&&e.jsxs("text",{x:_+u*E,y:L-2,textAnchor:"middle",fontSize:y-1,fill:A,fontWeight:600,children:["▼",S(c)]})]});if(p==="none"||!M)return e.jsxs("div",{className:`nice-bullet ${h||""}`,style:x,children:[U(),e.jsx("style",{children:ze})]});const V=p==="top"||p==="bottom",H=e.jsx("span",{className:"nice-bullet__label",style:{fontSize:y,fontWeight:600,color:"var(--text-primary)",...V?{marginBottom:p==="top"?4:0,marginTop:p==="bottom"?4:0}:{},...p==="left"?{marginRight:8}:{},...p==="right"?{marginLeft:8}:{}},children:M});return e.jsxs("div",{className:`nice-bullet nice-bullet--${p} ${h||""}`,style:{display:"inline-flex",flexDirection:V?"column":"row",alignItems:V?"flex-start":"center",...x},children:[(p==="top"||p==="left")&&H,U(),(p==="bottom"||p==="right")&&H,e.jsx("style",{children:ze})]})},ze=`
|
|
2
|
+
@keyframes nice-bullet-shimmer {
|
|
3
|
+
0% { background-position: 200% 0; }
|
|
4
|
+
100% { background-position: -200% 0; }
|
|
5
|
+
}
|
|
6
|
+
`,ct=({data:t,width:c=400,height:i=300,inverted:l,showLabels:s=!0,showValues:b=!0,title:m,className:A,style:R})=>{const M={top:m?30:10,bottom:10,x:40},p=c-M.x*2,w=i-M.top-M.bottom,I=l?[...t].reverse():t,S=Math.max(...I.map(d=>d.value),1),N=w/I.length;return e.jsx("div",{className:`nice-funnel ${A||""}`,style:R,children:e.jsxs("svg",{width:c,height:i,children:[m&&e.jsx("text",{x:c/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:m}),I.map((d,h)=>{const x=d.value/S*p,$=h<I.length-1?I[h+1].value/S*p:x*.3,g=M.top+h*N,v=g+N,y=c/2,_=`${y-x/2},${g} ${y+x/2},${g} ${y+$/2},${v} ${y-$/2},${v}`,u=d.color||me[h%me.length];return e.jsxs("g",{children:[e.jsx("polygon",{points:_,fill:u,stroke:"var(--bg-primary, #fff)",strokeWidth:1,children:e.jsx("title",{children:`${d.label}: ${d.value}`})}),s&&e.jsx("text",{x:y,y:g+N/2-(b?4:0),textAnchor:"middle",dominantBaseline:"middle",className:"nice-funnel__label",children:d.label}),b&&e.jsx("text",{x:y,y:g+N/2+10,textAnchor:"middle",dominantBaseline:"middle",className:"nice-funnel__value",children:d.value})]},h)})]})})},De=({nodes:t,links:c,width:i=600,height:l=400,nodeWidth:s=20,nodePadding:b=10,title:m,className:A,style:R})=>{const M={top:m?40:20,bottom:20,left:20,right:20},p=i-M.left-M.right,w=l-M.top-M.bottom,I=new Set(c.map(a=>a.source)),S=new Set(c.map(a=>a.target)),N=t.filter(a=>I.has(a.id)&&!S.has(a.id)),d=t.filter(a=>S.has(a.id)),h=t.filter(a=>I.has(a.id)&&S.has(a.id)),x=[N,...h.length?[h]:[],d].filter(a=>a.length>0),$=x.length,g=new Map;t.forEach(a=>{const j=c.filter(E=>E.source===a.id).reduce((E,U)=>E+U.value,0),C=c.filter(E=>E.target===a.id).reduce((E,U)=>E+U.value,0);g.set(a.id,Math.max(j,C))});const v=x.map(a=>a.reduce((j,C)=>j+(g.get(C.id)||0),0)+(a.length-1)*b),y=Math.max(...v,1),_=new Map;x.forEach((a,j)=>{const C=M.left+j/($-1||1)*(p-s);let E=0;a.forEach(U=>{const V=(g.get(U.id)||0)/y*w;_.set(U.id,{x:C,y:M.top+E,h:V}),E+=V+b})});const u=new Map,L=new Map;return t.forEach(a=>{u.set(a.id,0),L.set(a.id,0)}),e.jsx("div",{className:`nice-sankey ${A||""}`,style:R,children:e.jsxs("svg",{width:i,height:l,children:[m&&e.jsx("text",{x:i/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:m}),c.map((a,j)=>{const C=_.get(a.source),E=_.get(a.target);if(!C||!E)return null;const U=u.get(a.source)||0,V=L.get(a.target)||0,H=a.value/y*w;u.set(a.source,U+H),L.set(a.target,V+H);const G=C.x+s,Q=C.y+U,q=E.x,J=E.y+V,n=(G+q)/2,Y=t.find(B=>B.id===a.source)?.color||me[j%me.length];return e.jsx("path",{d:`M${G},${Q} C${n},${Q} ${n},${J} ${q},${J} L${q},${J+H} C${n},${J+H} ${n},${Q+H} ${G},${Q+H} Z`,fill:Y,fillOpacity:.3,stroke:Y,strokeOpacity:.5,strokeWidth:.5,children:e.jsx("title",{children:`${a.source} → ${a.target}: ${a.value}`})},j)}),t.map((a,j)=>{const C=_.get(a.id);if(!C)return null;const E=a.color||me[j%me.length];return e.jsxs("g",{children:[e.jsx("rect",{x:C.x,y:C.y,width:s,height:Math.max(C.h,2),fill:E,rx:2}),e.jsx("text",{x:C.x<p/2?C.x+s+4:C.x-4,y:C.y+C.h/2,textAnchor:C.x<p/2?"start":"end",dominantBaseline:"middle",className:"nice-chart__legend-text",children:a.label})]},a.id)})]})})},ot=Object.freeze(Object.defineProperty({__proto__:null,NiceSankey:De},Symbol.toStringTag,{value:"Module"})),it=({data:t,min:c,max:i,start:l,end:s,onChange:b,width:m=500,height:A=100,step:R=1,formatValue:M,chartColor:p="var(--color-primary, #3b82f6)",className:w,style:I})=>{const S={top:10,bottom:30,left:10,right:10},N=m-S.left-S.right,d=A-S.top-S.bottom,h=_=>S.left+(_-c)/(i-c||1)*N,x=_=>{const u=Math.max(0,Math.min(1,(_-S.left)/N)),L=c+u*(i-c);return Math.round(L/R)*R},$=(_,u)=>{u.preventDefault();const L=u.target.closest("svg");if(!L)return;const a=C=>{const E=L.getBoundingClientRect(),U=x(C.clientX-E.left);_==="start"?b(Math.min(U,s),s):b(l,Math.max(U,l))},j=()=>{document.removeEventListener("pointermove",a),document.removeEventListener("pointerup",j)};document.addEventListener("pointermove",a),document.addEventListener("pointerup",j)},g=t?Math.min(...t):0,y=(t?Math.max(...t):1)-g||1;return e.jsx("div",{className:`nice-rangeselector ${w||""}`,style:I,children:e.jsxs("svg",{width:m,height:A,children:[t&&t.length>1&&e.jsx("polygon",{points:`${S.left},${S.top+d} ${t.map((_,u)=>`${S.left+u/(t.length-1)*N},${S.top+d-(_-g)/y*d}`).join(" ")} ${S.left+N},${S.top+d}`,fill:p,opacity:.15}),e.jsx("rect",{x:h(l),y:S.top,width:h(s)-h(l),height:d,fill:p,opacity:.1}),e.jsx("rect",{x:S.left,y:S.top,width:h(l)-S.left,height:d,fill:"var(--bg-secondary, #f5f5f5)",opacity:.6}),e.jsx("rect",{x:h(s),y:S.top,width:S.left+N-h(s),height:d,fill:"var(--bg-secondary, #f5f5f5)",opacity:.6}),e.jsx("rect",{x:h(l)-4,y:S.top,width:8,height:d,fill:p,rx:2,cursor:"ew-resize",onPointerDown:_=>$("start",_)}),e.jsx("rect",{x:h(s)-4,y:S.top,width:8,height:d,fill:p,rx:2,cursor:"ew-resize",onPointerDown:_=>$("end",_)}),e.jsx("text",{x:h(l),y:S.top+d+18,textAnchor:"middle",className:"nice-chart__axis-label",children:M?M(l):l}),e.jsx("text",{x:h(s),y:S.top+d+18,textAnchor:"middle",className:"nice-chart__axis-label",children:M?M(s):s})]})})},Te=({regions:t,width:c=600,height:i=400,viewBox:l="0 0 1000 600",colorRange:s=["var(--info-bg, #dbeafe)","var(--color-primary-active, #1d4ed8)"],maxValue:b,onRegionClick:m,selectedRegionId:A,title:R,showTooltip:M=!0,className:p,style:w})=>{const I=b??Math.max(...t.map(N=>N.value??0),1),S=N=>{const d=a=>[parseInt(a.slice(1,3),16),parseInt(a.slice(3,5),16),parseInt(a.slice(5,7),16)],[h,x,$]=d(s[0]),[g,v,y]=d(s[1]),_=Math.round(h+(g-h)*N),u=Math.round(x+(v-x)*N),L=Math.round($+(y-$)*N);return`rgb(${_},${u},${L})`};return e.jsxs("div",{className:`nice-vectormap ${p||""}`,style:w,children:[R&&e.jsx("div",{className:"nice-vectormap__title",children:R}),e.jsx("svg",{width:c,height:i,viewBox:l,children:t.map(N=>{const d=N.value!=null?Math.max(0,Math.min(1,N.value/I)):0,h=N.value!=null?S(d):"var(--bg-tertiary, #e5e7eb)",x=N.id===A;return e.jsx("path",{d:N.path,fill:h,stroke:x?"var(--color-primary, #3b82f6)":"var(--border-color, #d1d5db)",strokeWidth:x?2:.5,cursor:m?"pointer":void 0,onClick:()=>m?.(N),children:M&&e.jsx("title",{children:`${N.name}${N.value!=null?`: ${N.value}`:""}`})},N.id)})})]})},lt=Object.freeze(Object.defineProperty({__proto__:null,NiceVectorMap:Te},Symbol.toStringTag,{value:"Module"})),dt=`
|
|
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
|
+
`,Le=["var(--color-primary, #3b82f6)","var(--color-success, #10b981)","var(--color-warning, #f59e0b)","var(--color-error, #ef4444)","var(--color-accent, #8b5cf6)","var(--color-accent-pink, #ec4899)","var(--color-info, #06b6d4)","var(--nice-warning, #f97316)"];function fe(t){return t instanceof Date?t:new Date(t)}function Ce(t,c="pl-PL"){return t.toLocaleDateString(c,{year:"numeric",month:"short",day:"numeric"})}function ke(t,c="pl-PL"){return new Intl.NumberFormat(c,{minimumFractionDigits:0,maximumFractionDigits:2}).format(t)}const ht=o.forwardRef(function(c,i){const{scenarios:l,data:s,annotations:b=[],referenceLines:m=[],forecastStartDate:A,cashRunway:R,xAxis:M,yAxis:p,confidenceBands:w=[{level:95,color:"var(--color-primary, #3b82f6)",opacity:.15}],tooltip:I,legend:S={enabled:!0,position:"bottom",interactive:!0},height:N=350,showForecastRegion:d=!0,lineWidth:h=2,showPoints:x=!1,pointRadius:$=4,enableZoom:g=!1,zoomEnabled:v,animationDuration:y=300,showLegend:_,responsive:u=!0,onPointClick:L,onAnnotationClick:a,onScenarioToggle:j,onViewportChange:C,size:E="medium",disabled:U=!1,labels:V={},locale:H="pl-PL",className:G,style:Q}=c,q=l&&l.length>0?l:s?[{id:"default",name:"Series",data:s}]:[],J={...S,enabled:_??S.enabled},[n,X]=o.useState(()=>q.map((r,T)=>({...r,color:r.color??Le[T%Le.length],visible:r.visible!==!1}))),[Y,B]=o.useState(null),[f,P]=o.useState({x:0,y:0}),F=o.useRef(null),ee=o.useRef(null),O={top:20,right:30,bottom:40,left:60},[te,ue]=o.useState({width:600,height:typeof N=="number"?N:350});o.useEffect(()=>{if(!u||!F.current)return;const r=new ResizeObserver(T=>{for(const W of T)ue(k=>({width:W.contentRect.width,height:k.height}))});return r.observe(F.current),()=>r.disconnect()},[u]),o.useEffect(()=>{const r="nice-forecast-chart-styles";if(!document.getElementById(r)){const T=document.createElement("style");T.id=r,T.textContent=dt,document.head.appendChild(T)}},[]);const{xScale:z,yScale:Z,allDates:ne,minY:de,maxY:ge}=o.useMemo(()=>{const T=n.filter(he=>he.visible!==!1).flatMap(he=>he.data);if(T.length===0)return{xScale:()=>0,yScale:()=>0,allDates:[],minY:0,maxY:100};const W=T.map(he=>fe(he.date).getTime()),k=Math.min(...W),K=Math.max(...W),se=T.flatMap(he=>[he.value,he.forecast,he.lowerBound,he.upperBound]).filter(he=>he!=null),oe=p?.min??Math.min(...se)*.95,le=p?.max??Math.max(...se)*1.05,ve=te.width-O.left-O.right,be=te.height-O.top-O.bottom,Ne=he=>{const Se=typeof he=="number"?he:he.getTime();return O.left+(Se-k)/(K-k)*ve},$e=he=>O.top+be-(he-oe)/(le-oe)*be,He=[...new Set(W)].sort((he,Se)=>he-Se).map(he=>new Date(he));return{xScale:Ne,yScale:$e,allDates:He,minY:oe,maxY:le}},[n,te,O,p]),xe=A?fe(A):null,pe=o.useMemo(()=>{if(!R?.enabled)return null;const r=R.threshold??0,T=R.scenarioId?n.find(k=>k.id===R.scenarioId&&k.visible!==!1):n.find(k=>k.visible!==!1);if(!T)return null;const W=T.data.sort((k,K)=>fe(k.date).getTime()-fe(K.date).getTime());for(let k=1;k<W.length;k++){const K=W[k-1],se=W[k],oe=K.forecast??K.value,le=se.forecast??se.value;if(oe!=null&&le!=null&&oe>r&&le<=r){const ve=(oe-r)/(oe-le),be=fe(K.date).getTime(),Ne=fe(se.date).getTime(),$e=be+ve*(Ne-be);return new Date($e)}}return null},[R,n]),ye=o.useCallback((r,T)=>{const W=r.filter(k=>k[T]!=null).map(k=>({x:z(fe(k.date)),y:Z(k[T])}));return W.length===0?"":`M ${W.map(k=>`${k.x},${k.y}`).join(" L ")}`},[z,Z]),je=o.useCallback(r=>{const T=r.filter(K=>K.lowerBound!=null&&K.upperBound!=null);if(T.length===0)return"";const W=T.map(K=>({x:z(fe(K.date)),y:Z(K.upperBound)})),k=T.map(K=>({x:z(fe(K.date)),y:Z(K.lowerBound)})).reverse();return`M ${W.map(K=>`${K.x},${K.y}`).join(" L ")} L ${k.map(K=>`${K.x},${K.y}`).join(" L ")} Z`},[z,Z]),D=o.useCallback(r=>{if(!ee.current||I?.enabled===!1)return;const T=ee.current.getBoundingClientRect(),W=r.clientX-T.left;r.clientY-T.top;let k=null,K=1/0;for(const se of ne){const oe=z(se),le=Math.abs(oe-W);le<K&&(K=le,k=se)}if(k&&K<50){const se=n.filter(le=>le.visible!==!1).map(le=>{const ve=le.data.find(be=>fe(be.date).getTime()===k.getTime());return{scenario:le,value:ve?.value,forecast:ve?.forecast,lowerBound:ve?.lowerBound,upperBound:ve?.upperBound}}),oe=b.filter(le=>Math.abs(fe(le.date).getTime()-k.getTime())<864e5);B({date:k,values:se,annotations:oe}),P({x:r.clientX-T.left+10,y:r.clientY-T.top-10})}else B(null)},[z,ne,n,b,I]),re=o.useCallback(r=>{if(!J.interactive)return;X(W=>W.map(k=>k.id===r?{...k,visible:!k.visible}:k));const T=n.find(W=>W.id===r);T&&j?.(r,!T.visible)},[J.interactive,n,j]);o.useImperativeHandle(i,()=>({getScenarios:()=>n,updateScenario:(r,T)=>{X(W=>W.map(k=>k.id===r?{...k,data:T}:k))},toggleScenario:re,setZoomRange:()=>{},resetZoom:()=>{},exportImage:r=>{if(!ee.current)return null;const T=ee.current,k=new XMLSerializer().serializeToString(T);return`data:image/svg+xml;base64,${btoa(k)}`},getDataAtDate:r=>{const T=n.filter(W=>W.visible!==!1).map(W=>{const k=W.data.find(K=>fe(K.date).getTime()===r.getTime());return{scenario:W,value:k?.value,forecast:k?.forecast,lowerBound:k?.lowerBound,upperBound:k?.upperBound}});return{date:r,values:T,annotations:b.filter(W=>fe(W.date).getTime()===r.getTime())}}}),[n,b,re]),te.width-O.left-O.right;const ae=te.height-O.top-O.bottom,ce=o.useMemo(()=>{const r=p?.tickCount??5,T=[],W=(ge-de)/(r-1);for(let k=0;k<r;k++)T.push(de+W*k);return T},[de,ge,p?.tickCount]),ie=o.useMemo(()=>{const r=M?.tickCount??6;if(ne.length===0)return[];const T=Math.max(1,Math.floor(ne.length/(r-1)));return ne.filter((W,k)=>k%T===0||k===ne.length-1)},[ne,M?.tickCount]);return n.length===0||n.every(r=>r.data.length===0)?e.jsx("div",{className:`nice-forecast-chart ${G??""}`,style:Q,children:e.jsx("div",{className:"nice-forecast-chart__empty",children:V.noData??"No data available"})}):e.jsxs("div",{className:`nice-forecast-chart ${G??""}`,style:{...Q,height:N},children:[e.jsxs("div",{ref:F,className:"nice-forecast-chart__container",children:[e.jsxs("svg",{ref:ee,className:"nice-forecast-chart__svg",width:te.width,height:te.height,onMouseMove:D,onMouseLeave:()=>B(null),children:[p?.showGrid!==!1&&ce.map(r=>e.jsx("line",{className:"nice-forecast-chart__grid-line",x1:O.left,x2:te.width-O.right,y1:Z(r),y2:Z(r)},r)),d&&xe&&e.jsx("rect",{className:"nice-forecast-chart__forecast-region",x:z(xe),y:O.top,width:te.width-O.right-z(xe),height:ae}),m.map(r=>e.jsxs("g",{children:[e.jsx("line",{className:"nice-forecast-chart__reference-line",x1:O.left,x2:te.width-O.right,y1:Z(r.value),y2:Z(r.value),stroke:r.color??"var(--text-muted, #9ca3af)",strokeDasharray:r.dashArray??"4,2"}),r.label&&e.jsx("text",{className:"nice-forecast-chart__reference-label",x:te.width-O.right-4,y:Z(r.value)-4,textAnchor:"end",children:r.label})]},r.id)),pe&&R?.enabled&&e.jsxs("g",{className:"nice-forecast-chart__cash-runway",children:[e.jsx("line",{className:"nice-forecast-chart__cash-runway-line",x1:z(pe),x2:z(pe),y1:O.top,y2:te.height-O.bottom,stroke:R.color??"var(--color-error, #ef4444)"}),R.showLabel!==!1&&e.jsxs(e.Fragment,{children:[e.jsx("rect",{className:"nice-forecast-chart__cash-runway-label-bg",x:z(pe)-60,y:O.top-2,width:120,height:R.showDate!==!1?32:20,fill:R.color??"var(--color-error, #ef4444)",rx:4}),e.jsx("text",{className:"nice-forecast-chart__cash-runway-label",x:z(pe),y:O.top+12,textAnchor:"middle",fill:"var(--nice-bg, #fff)",children:R.label??V.cashRunsOut??"💰 Cash runs out"}),R.showDate!==!1&&e.jsx("text",{className:"nice-forecast-chart__cash-runway-label",x:z(pe),y:O.top+26,textAnchor:"middle",fill:"var(--nice-bg, #fff)",style:{fontSize:"0.625rem",opacity:.9},children:Ce(pe,H)})]})]}),n.filter(r=>r.visible!==!1&&r.showConfidenceBand).map(r=>e.jsx("path",{className:"nice-forecast-chart__confidence-band",d:je(r.data),fill:r.color},`band-${r.id}`)),n.filter(r=>r.visible!==!1).map(r=>{const T=xe?r.data.filter(k=>fe(k.date)<xe):r.data.filter(k=>k.value!=null),W=xe?r.data.filter(k=>fe(k.date)>=xe):r.data.filter(k=>k.forecast!=null);return e.jsxs("g",{children:[e.jsx("path",{className:"nice-forecast-chart__historical-line",d:ye(T,"value"),stroke:r.color,strokeWidth:h}),e.jsx("path",{className:"nice-forecast-chart__forecast-line",d:ye(W,xe?"value":"forecast"),stroke:r.color,strokeWidth:h}),W.length>0&&r.data.some(k=>k.forecast!=null)&&e.jsx("path",{className:"nice-forecast-chart__forecast-line",d:ye(r.data,"forecast"),stroke:r.color,strokeWidth:h}),x&&r.data.map((k,K)=>{const se=k.value??k.forecast;return se==null?null:e.jsx("circle",{className:"nice-forecast-chart__point",cx:z(fe(k.date)),cy:Z(se),r:$,fill:r.color,onClick:()=>L?.(k,r)},K)})]},r.id)}),b.map(r=>{const T=z(fe(r.date));return e.jsxs("g",{className:"nice-forecast-chart__annotation-marker",onClick:()=>a?.(r),children:[r.showLine!==!1&&e.jsx("line",{className:"nice-forecast-chart__annotation-line",x1:T,x2:T,y1:O.top,y2:te.height-O.bottom,stroke:r.color??"var(--text-muted, #9ca3af)"}),e.jsx("circle",{cx:T,cy:O.top+10,r:8,fill:r.color??"var(--text-muted, #9ca3af)"}),e.jsx("text",{x:T,y:O.top+14,textAnchor:"middle",fill:"white",fontSize:"10",children:r.icon??"!"})]},r.id)}),e.jsx("line",{className:"nice-forecast-chart__axis-line",x1:O.left,x2:O.left,y1:O.top,y2:te.height-O.bottom}),e.jsx("line",{className:"nice-forecast-chart__axis-line",x1:O.left,x2:te.width-O.right,y1:te.height-O.bottom,y2:te.height-O.bottom}),ce.map(r=>e.jsx("text",{className:"nice-forecast-chart__axis-label",x:O.left-8,y:Z(r)+4,textAnchor:"end",children:p?.format?p.format(r):ke(r,H)},r)),ie.map(r=>e.jsx("text",{className:"nice-forecast-chart__axis-label",x:z(r),y:te.height-O.bottom+16,textAnchor:"middle",children:M?.format?M.format(r):Ce(r,H)},r.getTime())),p?.title&&e.jsx("text",{className:"nice-forecast-chart__axis-title",x:15,y:te.height/2,textAnchor:"middle",transform:`rotate(-90, 15, ${te.height/2})`,children:p.title})]}),Y&&e.jsxs("div",{className:"nice-forecast-chart__tooltip",style:{left:f.x,top:f.y},children:[e.jsx("div",{className:"nice-forecast-chart__tooltip-date",children:Ce(Y.date,H)}),Y.values.map(r=>{const T=r.value??r.forecast;return T==null?null:e.jsxs("div",{className:"nice-forecast-chart__tooltip-item",children:[e.jsx("span",{className:"nice-forecast-chart__tooltip-color",style:{background:r.scenario.color}}),e.jsx("span",{className:"nice-forecast-chart__tooltip-label",children:r.scenario.name}),e.jsx("span",{className:"nice-forecast-chart__tooltip-value",children:ke(T,H)})]},r.scenario.id)}),Y.values.some(r=>r.lowerBound!=null)&&e.jsxs("div",{className:"nice-forecast-chart__tooltip-confidence",children:[V.confidence??"CI",":"," ",ke(Y.values[0]?.lowerBound??0,H)," –"," ",ke(Y.values[0]?.upperBound??0,H)]})]})]}),J.enabled&&e.jsx("div",{className:"nice-forecast-chart__legend",children:n.map(r=>e.jsxs("div",{className:`nice-forecast-chart__legend-item ${r.visible===!1?"nice-forecast-chart__legend-item--hidden":""}`,onClick:()=>re(r.id),children:[e.jsx("span",{className:`nice-forecast-chart__legend-color ${r.isBase?"":"nice-forecast-chart__legend-color--dashed"}`,style:{background:r.color}}),r.name]},r.id))})]})}),Be=["var(--color-primary, #3b82f6)","var(--color-error, #ef4444)","var(--color-success, #22c55e)","var(--color-warning, #f59e0b)","var(--color-accent, #8b5cf6)","var(--color-accent-pink, #ec4899)","var(--color-info, #06b6d4)","var(--nice-success, #84cc16)","var(--nice-warning, #f97316)","var(--color-accent, #6366f1)"],We=o.forwardRef((t,c)=>{const{levels:i,initialLevelId:l,chartType:s="bar",width:b=600,height:m=400,showBreadcrumbs:A=!0,showBackButton:R=!0,animationDuration:M=300,onLevelChange:p,onItemClick:w,colors:I=Be,showValues:S=!0,showLegend:N=!0,className:d,style:h,...x}=t,[$,g]=o.useState(l||i[0]?.id),[v,y]=o.useState([l||i[0]?.id]),[_,u]=o.useState(!1),[L,a]=o.useState("in"),j=o.useMemo(()=>i.find(n=>n.id===$),[i,$]),C=o.useCallback(n=>{i.find(Y=>Y.id===n)&&(a("in"),u(!0),setTimeout(()=>{g(n),y(Y=>[...Y,n]),p?.(n,[...v,n]),u(!1)},M/2))},[i,v,M,p]),E=o.useCallback(()=>{if(v.length<=1)return;a("out"),u(!0);const n=v.slice(0,-1),X=n[n.length-1];setTimeout(()=>{g(X),y(n),p?.(X,n),u(!1)},M/2)},[v,M,p]),U=o.useCallback(()=>{const n=i[0]?.id;n&&(a("out"),u(!0),setTimeout(()=>{g(n),y([n]),p?.(n,[n]),u(!1)},M/2))},[i,M,p]);o.useImperativeHandle(c,()=>({drillDown:C,drillUp:E,resetToRoot:U,getCurrentLevel:()=>$,getPath:()=>v}),[C,E,U,$,v]);const V=o.useCallback((n,X)=>{w?.(n,$);const Y=i.find(B=>B.parentId===$&&B.id===n.metadata?.childLevelId);Y&&C(Y.id)},[$,i,C,w]),H=o.useMemo(()=>j?.data.reduce((n,X)=>n+X.value,0)||0,[j]),G=o.useMemo(()=>v.map(n=>i.find(X=>X.id===n)?.label||n),[v,i]),Q=()=>{if(!j)return null;const n=j.data,X=Math.max(...n.map(B=>B.value)),Y=Math.min(40,(m-100)/n.length-8);return e.jsx("div",{className:"nice-drilldown-bars",children:n.map((B,f)=>{const P=B.value/X*100;return e.jsxs("div",{className:"nice-drilldown-bar-row",onClick:()=>V(B,f),children:[e.jsx("span",{className:"nice-drilldown-bar-label",children:B.label||`Item ${f+1}`}),e.jsx("div",{className:"nice-drilldown-bar-track",children:e.jsx("div",{className:"nice-drilldown-bar-fill",style:{width:`${P}%`,backgroundColor:B.color||I[f%I.length],height:Y}})}),S&&e.jsx("span",{className:"nice-drilldown-bar-value",children:B.value.toLocaleString()})]},f)})})},q=()=>{if(!j)return null;const n=j.data,X=b/2,Y=(m-60)/2+30,B=Math.min(X,Y)-40;let f=-90;const P=n.map((F,ee)=>{const O=F.value/H*360,te=f+O,ue=O>180?1:0,z=f*Math.PI/180,Z=te*Math.PI/180,ne=X+B*Math.cos(z),de=Y+B*Math.sin(z),ge=X+B*Math.cos(Z),xe=Y+B*Math.sin(Z),pe=(f+O/2)*Math.PI/180,ye=X+B*.7*Math.cos(pe),je=Y+B*.7*Math.sin(pe),D=`M ${X} ${Y} L ${ne} ${de} A ${B} ${B} 0 ${ue} 1 ${ge} ${xe} Z`;return f=te,{path:D,color:F.color||I[ee%I.length],label:F.label||`Item ${ee+1}`,value:F.value,percentage:(F.value/H*100).toFixed(1),labelX:ye,labelY:je,item:F,index:ee}});return e.jsx("svg",{width:b,height:m-40,className:"nice-drilldown-pie",children:e.jsx("g",{children:P.map((F,ee)=>e.jsxs("g",{onClick:()=>V(F.item,F.index),children:[e.jsx("path",{d:F.path,fill:F.color,stroke:"white",strokeWidth:2,className:"nice-drilldown-pie-slice"}),S&&parseFloat(F.percentage)>5&&e.jsxs("text",{x:F.labelX,y:F.labelY,textAnchor:"middle",dominantBaseline:"middle",fill:"white",fontSize:"12",fontWeight:"600",children:[F.percentage,"%"]})]},ee))})})},J=()=>{if(!j)return null;const n=j.data,X=Math.max(...n.map(f=>f.value)),Y=Math.min(60,(b-100)/n.length-8),B=m-100;return e.jsx("svg",{width:b,height:m-40,className:"nice-drilldown-columns",children:e.jsxs("g",{transform:"translate(50, 20)",children:[[0,.25,.5,.75,1].map((f,P)=>e.jsxs("g",{children:[e.jsx("line",{x1:0,y1:B*(1-f),x2:b-80,y2:B*(1-f),stroke:"var(--border-color, #e5e7eb)",strokeDasharray:f===0?void 0:"4"}),e.jsx("text",{x:-8,y:B*(1-f),textAnchor:"end",dominantBaseline:"middle",fontSize:"11",fill:"var(--text-secondary, #6b7280)",children:Math.round(X*f).toLocaleString()})]},P)),n.map((f,P)=>{const F=f.value/X*B,ee=P*((b-100)/n.length)+((b-100)/n.length-Y)/2;return e.jsxs("g",{onClick:()=>V(f,P),children:[e.jsx("rect",{x:ee,y:B-F,width:Y,height:F,fill:f.color||I[P%I.length],rx:4,className:"nice-drilldown-column-bar"}),e.jsx("text",{x:ee+Y/2,y:B+16,textAnchor:"middle",fontSize:"11",fill:"var(--text-primary, #374151)",children:(f.label||`${P+1}`).slice(0,10)}),S&&e.jsx("text",{x:ee+Y/2,y:B-F-8,textAnchor:"middle",fontSize:"11",fill:"var(--text-primary, #374151)",fontWeight:"500",children:f.value.toLocaleString()})]},P)})]})})};return e.jsxs("div",{className:`nice-drilldown-chart ${_?`animating ${L}`:""} ${d||""}`,style:{width:b,...h},...x,children:[e.jsxs("div",{className:"nice-drilldown-header",children:[R&&v.length>1&&e.jsx("button",{className:"nice-drilldown-back",onClick:E,children:"← Wstecz"}),A&&e.jsx("div",{className:"nice-drilldown-breadcrumbs",children:G.map((n,X)=>e.jsxs(o.Fragment,{children:[X>0&&e.jsx("span",{className:"nice-drilldown-separator",children:"/"}),e.jsx("span",{className:`nice-drilldown-crumb ${X===G.length-1?"active":""}`,onClick:()=>{if(X<G.length-1){const Y=v.slice(0,X+1);y(Y),g(Y[Y.length-1])}},children:n})]},X))})]}),e.jsxs("div",{className:"nice-drilldown-content",style:{height:m-40},children:[s==="bar"&&Q(),s==="pie"&&q(),s==="column"&&J()]}),N&&j&&e.jsx("div",{className:"nice-drilldown-legend",children:j.data.map((n,X)=>e.jsxs("div",{className:"nice-drilldown-legend-item",children:[e.jsx("span",{className:"nice-drilldown-legend-color",style:{backgroundColor:n.color||I[X%I.length]}}),e.jsx("span",{className:"nice-drilldown-legend-label",children:n.label||`Item ${X+1}`})]},X))}),e.jsx("style",{children:`
|
|
293
|
+
.nice-drilldown-chart {
|
|
294
|
+
font-family: inherit;
|
|
295
|
+
color: var(--text-primary, #111827);
|
|
296
|
+
background: var(--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(--border-color, #e5e7eb);
|
|
307
|
+
min-height: 40px;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.nice-drilldown-back {
|
|
311
|
+
background: var(--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(--text-primary, #374151);
|
|
319
|
+
transition: background 0.2s;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.nice-drilldown-back:hover {
|
|
323
|
+
background: var(--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(--text-muted, #9ca3af);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
.nice-drilldown-crumb {
|
|
339
|
+
color: var(--text-secondary, #6b7280);
|
|
340
|
+
cursor: pointer;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
.nice-drilldown-crumb:hover:not(.active) {
|
|
344
|
+
color: var(--color-primary, #3b82f6);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.nice-drilldown-crumb.active {
|
|
348
|
+
color: var(--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(--hover-bg, #f9fafb);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
.nice-drilldown-bar-label {
|
|
392
|
+
width: 120px;
|
|
393
|
+
font-size: 13px;
|
|
394
|
+
font-family: inherit;
|
|
395
|
+
color: var(--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(--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(--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(--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(--text-secondary, #6b7280);
|
|
466
|
+
}
|
|
467
|
+
`})]})});We.displayName="NiceDrillDownChart";const ut=({type:t="choropleth",regions:c=[],bubbles:i=[],width:l=800,height:s=500,viewBox:b="0 0 800 500",colorScale:m=["var(--info-bg, #dbeafe)","var(--color-primary-light, #93c5fd)","var(--color-primary, #3b82f6)","var(--color-primary-active, #1d4ed8)","var(--nice-primary-dark, #1E3A8A)"],minValue:A,maxValue:R,showTooltip:M=!0,showLegend:p=!0,onRegionClick:w,onBubbleClick:I,onRegionHover:S,title:N,mapSvg:d,zoomable:h=!1,className:x,style:$,...g})=>{const[v,y]=o.useState(null),[_,u]=o.useState(1),[L,a]=o.useState({x:0,y:0}),j=o.useRef(null),C=o.useRef(!1),E=o.useRef({x:0,y:0}),U=A??Math.min(...c.map(f=>f.value),...i.map(f=>f.value)),V=R??Math.max(...c.map(f=>f.value),...i.map(f=>f.value)),H=o.useCallback(f=>{const P=(f-U)/(V-U),F=Math.min(Math.floor(P*m.length),m.length-1);return m[Math.max(0,F)]},[U,V,m]),G=o.useCallback(f=>{if(!M||!v)return;const P=j.current?.getBoundingClientRect();P&&y(F=>F?{...F,x:f.clientX-P.left,y:f.clientY-P.top}:null)},[M,v]),Q=o.useCallback((f,P)=>{const F=j.current?.getBoundingClientRect();F&&M&&y({x:P.clientX-F.left,y:P.clientY-F.top,content:`${f.name}: ${f.value.toLocaleString()}`}),S?.(f)},[M,S]),q=o.useCallback(()=>{y(null),S?.(null)},[S]),J=o.useCallback(f=>{if(!h)return;f.preventDefault();const P=f.deltaY>0?.9:1.1;u(F=>Math.min(Math.max(F*P,.5),4))},[h]),n=o.useCallback(f=>{h&&(C.current=!0,E.current={x:f.clientX-L.x,y:f.clientY-L.y})},[h,L]),X=o.useCallback(()=>{C.current=!1},[]),Y=o.useCallback(f=>{C.current&&a({x:f.clientX-E.current.x,y:f.clientY-E.current.y})},[]),B=o.useMemo(()=>c.length>0?c:[{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"}],[c]);return e.jsxs("div",{className:`nice-map-chart ${x||""}`,style:{width:l,...$},...g,children:[N&&e.jsx("div",{className:"nice-map-title",children:N}),e.jsx("svg",{ref:j,width:l,height:s,viewBox:b,className:"nice-map-svg",onWheel:J,onMouseDown:n,onMouseUp:X,onMouseLeave:X,onMouseMove:f=>{G(f),Y(f)},children:e.jsxs("g",{transform:`translate(${L.x}, ${L.y}) scale(${_})`,children:[d&&e.jsx("g",{dangerouslySetInnerHTML:{__html:d}}),t==="choropleth"&&B.map(f=>e.jsx("path",{d:f.path,fill:f.color||H(f.value),stroke:"var(--nice-bg, #fff)",strokeWidth:1,className:"nice-map-region",onClick:()=>w?.(f),onMouseEnter:P=>Q(f,P),onMouseLeave:q},f.id)),(t==="bubble"||i.length>0)&&i.map(f=>{const P=Math.sqrt((f.value-U)/(V-U))*30+5;return e.jsx("circle",{cx:f.lng,cy:f.lat,r:P,fill:f.color||"var(--color-primary, #3b82f6)",fillOpacity:.7,stroke:"var(--nice-bg, #fff)",strokeWidth:1,className:"nice-map-bubble",onClick:()=>I?.(f),onMouseEnter:F=>{const ee=j.current?.getBoundingClientRect();ee&&M&&y({x:F.clientX-ee.left,y:F.clientY-ee.top,content:`${f.label||f.id}: ${f.value.toLocaleString()}`})},onMouseLeave:q,children:f.label&&e.jsxs("title",{children:[f.label,": ",f.value]})},f.id)})]})}),v&&e.jsx("div",{className:"nice-map-tooltip",style:{left:v.x+10,top:v.y-30},children:v.content}),p&&e.jsxs("div",{className:"nice-map-legend",children:[e.jsx("span",{className:"nice-map-legend-title",children:"Wartość"}),e.jsx("div",{className:"nice-map-legend-scale",children:m.map((f,P)=>e.jsx("div",{className:"nice-map-legend-item",style:{backgroundColor:f}},P))}),e.jsxs("div",{className:"nice-map-legend-labels",children:[e.jsx("span",{children:U.toLocaleString()}),e.jsx("span",{children:V.toLocaleString()})]})]}),e.jsx("style",{children:`
|
|
468
|
+
.nice-map-chart {
|
|
469
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
470
|
+
background: white;
|
|
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, #111827);
|
|
481
|
+
border-bottom: 1px solid var(--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
|
+
background: var(--nice-text, #1f2937);
|
|
516
|
+
color: white;
|
|
517
|
+
padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
|
|
518
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
519
|
+
font-size: 12px;
|
|
520
|
+
pointer-events: none;
|
|
521
|
+
z-index: 10;
|
|
522
|
+
white-space: nowrap;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
.nice-map-legend {
|
|
526
|
+
position: absolute;
|
|
527
|
+
right: 16px;
|
|
528
|
+
bottom: 16px;
|
|
529
|
+
background: white;
|
|
530
|
+
padding: var(--nice-space-3, 12px);
|
|
531
|
+
border-radius: var(--nice-radius-md, 6px);
|
|
532
|
+
box-shadow: 0 2px 8px var(--nice-overlay-10, rgba(0, 0, 0, 0.1));
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
.nice-map-legend-title {
|
|
536
|
+
display: block;
|
|
537
|
+
font-size: 11px;
|
|
538
|
+
color: var(--nice-text-secondary, #6b7280);
|
|
539
|
+
margin-bottom: var(--nice-space-1-5, 6px);
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
.nice-map-legend-scale {
|
|
543
|
+
display: flex;
|
|
544
|
+
height: 12px;
|
|
545
|
+
border-radius: var(--nice-radius-sm, 2px);
|
|
546
|
+
overflow: hidden;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
.nice-map-legend-item {
|
|
550
|
+
flex: 1;
|
|
551
|
+
min-width: 24px;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
.nice-map-legend-labels {
|
|
555
|
+
display: flex;
|
|
556
|
+
justify-content: space-between;
|
|
557
|
+
font-size: 10px;
|
|
558
|
+
color: var(--nice-text-secondary, #6b7280);
|
|
559
|
+
margin-top: var(--nice-space-1, 4px);
|
|
560
|
+
}
|
|
561
|
+
`})]})},xt=({nodes:t,links:c,width:i=800,height:l=500,nodeWidth:s=20,nodePadding:b=10,showValues:m=!0,showTooltip:A=!0,onNodeClick:R,onLinkClick:M,title:p,className:w,style:I,...S})=>{const[N,d]=o.useState(null),h=o.useRef(null),x=o.useMemo(()=>{const g=new Map;t.forEach(n=>g.set(n.id,n));const v=new Set(c.map(n=>n.target)),y=new Set(c.map(n=>n.source)),_=[],u=new Map,L=t.filter(n=>y.has(n.id)&&!v.has(n.id));L.length>0&&(_.push(L.map(n=>n.id)),L.forEach(n=>u.set(n.id,0)));const a=t.filter(n=>y.has(n.id)&&v.has(n.id));a.length>0&&(_.push(a.map(n=>n.id)),a.forEach(n=>u.set(n.id,1)));const j=t.filter(n=>!y.has(n.id)&&v.has(n.id));j.length>0&&(_.push(j.map(n=>n.id)),j.forEach(n=>u.set(n.id,2))),_.length===0&&(_.push(t.map(n=>n.id)),t.forEach(n=>u.set(n.id,0)));const C=new Map;c.forEach(n=>{C.set(n.source,(C.get(n.source)||0)+n.value),C.set(n.target,(C.get(n.target)||0)+n.value)});const E=40,U=i-E*2,V=l-E*2,H=_.length>1?U/(_.length-1):U,G=new Map;Math.max(...Array.from(C.values())),_.forEach((n,X)=>{const Y=n.reduce((P,F)=>P+(C.get(F)||0),0),B=(V-(n.length-1)*b)/Y;let f=E;n.forEach(P=>{const ee=(C.get(P)||0)*B,O=E+X*H;G.set(P,{x:O,y:f,height:ee}),f+=ee+b})});const Q=[],q=new Map,J=new Map;return c.forEach(n=>{const X=G.get(n.source),Y=G.get(n.target);if(!X||!Y)return;const B=C.get(n.source)||1;C.get(n.target);const f=n.value/B*X.height,P=X.y+(q.get(n.source)||0),F=Y.y+(J.get(n.target)||0);q.set(n.source,(q.get(n.source)||0)+f),J.set(n.target,(J.get(n.target)||0)+f);const ee=X.x+s,O=Y.x,te=(O-ee)*.5,ue=`
|
|
562
|
+
M ${ee} ${P}
|
|
563
|
+
C ${ee+te} ${P},
|
|
564
|
+
${O-te} ${F},
|
|
565
|
+
${O} ${F}
|
|
566
|
+
L ${O} ${F+f}
|
|
567
|
+
C ${O-te} ${F+f},
|
|
568
|
+
${ee+te} ${P+f},
|
|
569
|
+
${ee} ${P+f}
|
|
570
|
+
Z
|
|
571
|
+
`;Q.push({path:ue,link:n,sourcePos:X,targetPos:Y})}),{nodePositions:G,linkPaths:Q,nodeMap:g,nodeValues:C}},[t,c,i,l,s,b]),$=o.useCallback((g,v)=>{const y=h.current?.getBoundingClientRect();y&&A&&d({x:v.clientX-y.left,y:v.clientY-y.top,content:g})},[A]);return e.jsxs("div",{className:`nice-sankey-chart ${w||""}`,style:{width:i,...I},...S,children:[p&&e.jsx("div",{className:"nice-sankey-title",children:p}),e.jsxs("svg",{ref:h,width:i,height:l,className:"nice-sankey-svg",children:[e.jsx("defs",{children:x.linkPaths.map((g,v)=>e.jsxs("linearGradient",{id:`sankey-gradient-${v}`,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[e.jsx("stop",{offset:"0%",stopColor:x.nodeMap.get(g.link.source)?.color||"var(--color-primary, #3b82f6)"}),e.jsx("stop",{offset:"100%",stopColor:x.nodeMap.get(g.link.target)?.color||"var(--color-error, #ef4444)"})]},v))}),e.jsx("g",{className:"nice-sankey-links",children:x.linkPaths.map((g,v)=>e.jsx("path",{d:g.path,fill:g.link.color||`url(#sankey-gradient-${v})`,fillOpacity:.4,className:"nice-sankey-link",onClick:()=>M?.(g.link),onMouseEnter:y=>$(`${x.nodeMap.get(g.link.source)?.name} → ${x.nodeMap.get(g.link.target)?.name}: ${g.link.value.toLocaleString()}`,y),onMouseLeave:()=>d(null)},v))}),e.jsx("g",{className:"nice-sankey-nodes",children:Array.from(x.nodePositions.entries()).map(([g,v])=>{const y=x.nodeMap.get(g);return y?e.jsxs("g",{children:[e.jsx("rect",{x:v.x,y:v.y,width:s,height:v.height,fill:y.color||"var(--color-primary, #3b82f6)",rx:2,className:"nice-sankey-node",onClick:()=>R?.(y),onMouseEnter:_=>$(`${y.label??y.name??y.id}: ${x.nodeValues.get(g)?.toLocaleString()||0}`,_),onMouseLeave:()=>d(null)}),e.jsxs("text",{x:v.x+s+6,y:v.y+v.height/2,dominantBaseline:"middle",fontSize:"12",fill:"var(--nice-text, #374151)",children:[y.label??y.name??y.id,m&&` (${x.nodeValues.get(g)?.toLocaleString()||0})`]})]},g):null})})]}),N&&e.jsx("div",{className:"nice-sankey-tooltip",style:{left:N.x+10,top:N.y-30},children:N.content}),e.jsx("style",{children:`
|
|
572
|
+
.nice-sankey-chart {
|
|
573
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
574
|
+
background: white;
|
|
575
|
+
border-radius: var(--nice-radius-lg, 8px);
|
|
576
|
+
position: relative;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
.nice-sankey-title {
|
|
580
|
+
padding: var(--nice-space-3, 12px) var(--nice-space-4, 16px);
|
|
581
|
+
font-size: 16px;
|
|
582
|
+
font-weight: 600;
|
|
583
|
+
color: var(--nice-text, #111827);
|
|
584
|
+
border-bottom: 1px solid var(--border-color, #e5e7eb);
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
.nice-sankey-link {
|
|
588
|
+
cursor: pointer;
|
|
589
|
+
transition: fill-opacity 0.2s;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
.nice-sankey-link:hover {
|
|
593
|
+
fill-opacity: 0.7;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
.nice-sankey-node {
|
|
597
|
+
cursor: pointer;
|
|
598
|
+
transition: opacity 0.2s;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
.nice-sankey-node:hover {
|
|
602
|
+
opacity: 0.8;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
.nice-sankey-tooltip {
|
|
606
|
+
position: absolute;
|
|
607
|
+
background: var(--nice-text, #1f2937);
|
|
608
|
+
color: white;
|
|
609
|
+
padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
|
|
610
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
611
|
+
font-size: 12px;
|
|
612
|
+
pointer-events: none;
|
|
613
|
+
z-index: 10;
|
|
614
|
+
white-space: nowrap;
|
|
615
|
+
}
|
|
616
|
+
`})]})},Ee=o.forwardRef((t,c)=>{const{initialData:i,data:l,maxPoints:s=60,updateInterval:b=1e3,fetchData:m,width:A=600,height:R=200,chartType:M="line",color:p="var(--color-primary, #3b82f6)",showGrid:w=!0,showTimeAxis:I=!0,showCurrentValue:S=!0,title:N,valueFormatter:d=z=>z.toFixed(2),timeFormatter:h=z=>new Date(z).toLocaleTimeString(),onDataUpdate:x,paused:$,className:g,style:v,...y}=t,[_,u]=o.useState(i??l??[]),[L,a]=o.useState($||!1),j=o.useRef();o.useEffect(()=>{$!==void 0&&a($)},[$]),o.useEffect(()=>{if(L||!m)return;const z=async()=>{try{const Z=await m();u(ne=>{const de=[...ne,Z].slice(-s);return x?.(de),de})}catch(Z){console.error("Failed to fetch realtime data:",Z)}};return j.current=setInterval(z,b),()=>{j.current&&clearInterval(j.current)}},[L,m,b,s,x]);const C=o.useCallback(z=>{u(Z=>{const ne=[...Z,z].slice(-s);return x?.(ne),ne})},[s,x]),E=o.useCallback(()=>{u([]),x?.([])},[x]),U=o.useCallback(()=>a(!0),[]),V=o.useCallback(()=>a(!1),[]);o.useImperativeHandle(c,()=>({addDataPoint:C,clearData:E,pause:U,resume:V,getData:()=>_}),[C,E,_]);const H={top:20,right:60,bottom:I?40:20,left:50},G=A-H.left-H.right,Q=R-H.top-H.bottom,q=_.map(z=>z.value),J=q.length?Math.min(...q):0,n=q.length?Math.max(...q):100,Y=(n-J||1)*.1,B=J-Y,P=n+Y-B,F=z=>{const Z=m?s-1:Math.max(1,_.length-1);return H.left+z/Z*G},ee=z=>H.top+Q-(z-B)/P*Q,O=_.map((z,Z)=>`${F(Z)},${ee(z.value)}`).join(" "),te=_.length>0?`M ${F(0)},${H.top+Q} L ${O} L ${F(_.length-1)},${H.top+Q} Z`:"",ue=_.length>0?_[_.length-1].value:null;return e.jsxs("div",{className:`nice-realtime-chart ${g||""}`,style:{width:A,...v},...y,children:[e.jsxs("div",{className:"nice-realtime-header",children:[e.jsx("span",{className:"nice-realtime-title",children:N}),e.jsxs("div",{className:"nice-realtime-controls",children:[e.jsxs("span",{className:`nice-realtime-status ${L?"paused":"live"}`,children:[e.jsx("span",{className:"nice-realtime-status-dot"}),e.jsx("span",{children:L?"Wstrzymano":"Na żywo"})]}),e.jsx("button",{className:`nice-realtime-btn ${L?"paused":""}`,onClick:()=>a(!L),children:L?"▶️":"⏸️"}),S&&ue!==null&&e.jsx("span",{className:"nice-realtime-value",children:d(ue)})]})]}),e.jsxs("svg",{width:A,height:R,className:"nice-realtime-svg",children:[w&&e.jsx("g",{className:"nice-realtime-grid",children:[0,.25,.5,.75,1].map((z,Z)=>{const ne=H.top+Q*(1-z),de=B+P*z;return e.jsxs("g",{children:[e.jsx("line",{x1:H.left,y1:ne,x2:A-H.right,y2:ne,stroke:"var(--border-color, #e5e7eb)",strokeDasharray:z===0?void 0:"3"}),e.jsx("text",{x:H.left-8,y:ne,textAnchor:"end",dominantBaseline:"middle",fontSize:"10",fill:"var(--text-secondary, #6b7280)",children:Math.round(de).toLocaleString()})]},Z)})}),M==="area"&&_.length>0&&e.jsx("path",{d:te,fill:p,fillOpacity:.2}),_.length>1&&e.jsx("polyline",{points:O,fill:"none",stroke:p,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),_.length>0&&e.jsx("circle",{cx:F(_.length-1),cy:ee(_[_.length-1].value),r:3,fill:p,className:"nice-realtime-point"}),I&&_.length>0&&e.jsx("g",{className:"nice-realtime-time-axis",children:Array.from(new Set([0,Math.floor(_.length/2),_.length-1].filter(z=>_[z]))).map(z=>e.jsx("text",{x:F(z),y:R-8,textAnchor:"middle",fontSize:"10",fill:"var(--text-secondary, #6b7280)",children:h(_[z].timestamp)},`tx-${z}`))})]}),e.jsx("style",{children:`
|
|
617
|
+
.nice-realtime-chart {
|
|
618
|
+
font-family: inherit;
|
|
619
|
+
color: var(--text-primary, #111827);
|
|
620
|
+
background: var(--bg-elevated, #ffffff);
|
|
621
|
+
border-radius: 8px;
|
|
622
|
+
position: relative;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
.nice-realtime-header {
|
|
626
|
+
display: flex;
|
|
627
|
+
justify-content: space-between;
|
|
628
|
+
align-items: center;
|
|
629
|
+
padding: 12px 16px;
|
|
630
|
+
border-bottom: 1px solid var(--border-color, #e5e7eb);
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
.nice-realtime-title {
|
|
634
|
+
font-size: 14px;
|
|
635
|
+
font-weight: 600;
|
|
636
|
+
color: var(--text-primary, #111827);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
.nice-realtime-controls {
|
|
640
|
+
display: flex;
|
|
641
|
+
align-items: center;
|
|
642
|
+
gap: 12px;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
.nice-realtime-btn {
|
|
646
|
+
background: none;
|
|
647
|
+
border: none;
|
|
648
|
+
cursor: pointer;
|
|
649
|
+
font-size: 16px;
|
|
650
|
+
padding: 4px;
|
|
651
|
+
font-family: inherit;
|
|
652
|
+
color: inherit;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
.nice-realtime-value {
|
|
656
|
+
font-size: 18px;
|
|
657
|
+
font-weight: 600;
|
|
658
|
+
color: ${p};
|
|
659
|
+
font-variant-numeric: tabular-nums;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
/* Static current-value dot — no pulsing animation (was distracting) */
|
|
663
|
+
|
|
664
|
+
.nice-realtime-status {
|
|
665
|
+
display: inline-flex;
|
|
666
|
+
align-items: center;
|
|
667
|
+
gap: 6px;
|
|
668
|
+
font-size: 11px;
|
|
669
|
+
font-family: inherit;
|
|
670
|
+
color: var(--text-secondary, #6b7280);
|
|
671
|
+
background: var(--bg-secondary, #f3f4f6);
|
|
672
|
+
padding: 2px 10px;
|
|
673
|
+
border-radius: 999px;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
.nice-realtime-status-dot {
|
|
677
|
+
width: 8px;
|
|
678
|
+
height: 8px;
|
|
679
|
+
border-radius: 50%;
|
|
680
|
+
background: var(--color-success, #22c55e);
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
.nice-realtime-status.paused .nice-realtime-status-dot {
|
|
684
|
+
background: var(--color-warning, #f59e0b);
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
.nice-realtime-status.live .nice-realtime-status-dot {
|
|
688
|
+
animation: live-pulse 2s ease-in-out infinite;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
@keyframes live-pulse {
|
|
692
|
+
0%, 100% { opacity: 1; }
|
|
693
|
+
50% { opacity: 0.4; }
|
|
694
|
+
}
|
|
695
|
+
`})]})});Ee.displayName="NiceRealtimeChart";const ft=({data:t,width:c=600,height:i=400,showLabels:l=!0,showValues:s=!0,onNodeClick:b,drilldownEnabled:m=!0,colors:A=Be,tilePadding:R=2,className:M,style:p,...w})=>{const I=o.useMemo(()=>Array.isArray(t)?{id:"root",name:"Root",value:t.reduce((a,j)=>a+(j.value||0),0),children:t.map((a,j)=>({id:`${j}`,name:a.label??a.name??`Item ${j+1}`,value:a.value,color:a.color}))}:t,[t]),[S,N]=o.useState(I),[d,h]=o.useState([I.name]),[x,$]=o.useState(null),g=o.useRef(null),v=o.useMemo(()=>{const j=S.children||[];if(j.length===0)return[];const C=j.reduce((J,n)=>J+n.value,0),E=j.map(J=>({node:J,area:J.value/C*c*i}));E.sort((J,n)=>n.area-J.area);const U=[];let V=0,H=0,G=c,Q=i,q=0;for(;q<E.length;){const J=G<Q;let n=0,X=[];const Y=J?Q:G;for(let P=q;P<E.length;P++){const F=[...X,E[P]],ee=F.reduce((te,ue)=>te+ue.area,0),O=y(F,ee,Y);if(X.length===0)X=F,n=ee;else{const te=y(X,n,Y);if(O<=te)X=F,n=ee;else break}}const B=n/Y;let f=0;X.forEach((P,F)=>{const ee=P.area/B;U.push({node:P.node,x:J?V:V+f,y:J?H+f:H,w:J?B:ee,h:J?ee:B,color:P.node.color||A[(q+F)%A.length]}),f+=ee}),J?(V+=B,G-=B):(H+=B,Q-=B),q+=X.length}return U},[S,c,i,A]);function y(a,j,C){const E=j/C;let U=0;for(const V of a){const H=V.area/E,G=Math.max(E/H,H/E);U=Math.max(U,G)}return U}const _=a=>{b?.(a,[...d,a.name]),m&&a.children&&a.children.length>0&&(N(a),h(j=>[...j,a.name]))},u=()=>{if(d.length<=1)return;let a=I;const j=d.slice(0,-1);for(let C=1;C<j.length;C++){const E=a.children?.find(U=>U.name===j[C]);E&&(a=E)}N(a),h(j)},L=(a,j)=>{const C=g.current?.getBoundingClientRect();C&&$({x:j.clientX-C.left,y:j.clientY-C.top,content:a})};return e.jsxs("div",{className:`nice-treemap-chart ${M||""}`,style:{width:c,...p},...w,children:[e.jsxs("div",{className:"nice-treemap-nav",children:[d.length>1&&e.jsx("button",{className:"nice-treemap-back",onClick:u,children:"← Wstecz"}),e.jsx("div",{className:"nice-treemap-breadcrumbs",children:d.map((a,j)=>e.jsxs(o.Fragment,{children:[j>0&&e.jsx("span",{className:"nice-treemap-sep",children:"/"}),e.jsx("span",{className:j===d.length-1?"current":"",children:a})]},j))})]}),e.jsx("svg",{ref:g,width:c,height:i,className:"nice-treemap-svg",children:v.map((a,j)=>{const{node:C,x:E,y:U,w:V,h:H,color:G}=a,Q=Math.min(14,Math.max(10,Math.min(V,H)/6)),q=V>40&&H>30;return e.jsxs("g",{onClick:()=>_(C),onMouseEnter:J=>L(`${C.name}: ${C.value.toLocaleString()}`,J),onMouseLeave:()=>$(null),children:[e.jsx("rect",{x:E+R/2,y:U+R/2,width:Math.max(0,V-R),height:Math.max(0,H-R),fill:G,rx:4,className:"nice-treemap-tile"}),l&&q&&e.jsx("text",{x:E+V/2,y:U+H/2-(s?6:0),textAnchor:"middle",dominantBaseline:"middle",fontSize:Q,fill:"white",fontWeight:"500",style:{pointerEvents:"none"},children:C.name.length>V/Q+2?C.name.slice(0,Math.floor(V/Q))+"...":C.name}),s&&q&&e.jsx("text",{x:E+V/2,y:U+H/2+10,textAnchor:"middle",dominantBaseline:"middle",fontSize:Q-2,fill:"var(--nice-overlay-light-80, rgba(255, 255, 255, 0.8))",style:{pointerEvents:"none"},children:C.value.toLocaleString()})]},j)})}),x&&e.jsx("div",{className:"nice-treemap-tooltip",style:{left:x.x+10,top:x.y-30},children:x.content}),e.jsx("style",{children:`
|
|
696
|
+
.nice-treemap-chart {
|
|
697
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
698
|
+
background: white;
|
|
699
|
+
border-radius: var(--nice-radius-lg, 8px);
|
|
700
|
+
position: relative;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
.nice-treemap-nav {
|
|
704
|
+
display: flex;
|
|
705
|
+
align-items: center;
|
|
706
|
+
gap: var(--nice-space-3, 12px);
|
|
707
|
+
padding: var(--nice-space-3, 12px) var(--nice-space-4, 16px);
|
|
708
|
+
border-bottom: 1px solid var(--border-color, #e5e7eb);
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
.nice-treemap-back {
|
|
712
|
+
background: var(--nice-bg-secondary, #f3f4f6);
|
|
713
|
+
border: none;
|
|
714
|
+
padding: var(--nice-space-1-5, 6px) var(--nice-space-3, 12px);
|
|
715
|
+
border-radius: var(--nice-radius-md, 6px);
|
|
716
|
+
cursor: pointer;
|
|
717
|
+
font-size: 13px;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
.nice-treemap-back:hover {
|
|
721
|
+
background: var(--nice-border, #e5e7eb);
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
.nice-treemap-breadcrumbs {
|
|
725
|
+
display: flex;
|
|
726
|
+
align-items: center;
|
|
727
|
+
gap: var(--nice-space-1, 4px);
|
|
728
|
+
font-size: 13px;
|
|
729
|
+
color: var(--nice-text-secondary, #6b7280);
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
.nice-treemap-breadcrumbs .current {
|
|
733
|
+
color: var(--nice-text, #111827);
|
|
734
|
+
font-weight: 500;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
.nice-treemap-sep {
|
|
738
|
+
color: var(--nice-text-muted, #9ca3af);
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
.nice-treemap-tile {
|
|
742
|
+
cursor: pointer;
|
|
743
|
+
transition: opacity 0.2s, transform 0.1s;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
.nice-treemap-tile:hover {
|
|
747
|
+
opacity: 0.85;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
.nice-treemap-tooltip {
|
|
751
|
+
position: absolute;
|
|
752
|
+
background: var(--nice-text, #1f2937);
|
|
753
|
+
color: white;
|
|
754
|
+
padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
|
|
755
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
756
|
+
font-size: 12px;
|
|
757
|
+
pointer-events: none;
|
|
758
|
+
z-index: 10;
|
|
759
|
+
white-space: nowrap;
|
|
760
|
+
}
|
|
761
|
+
`})]})},Oe=o.forwardRef(({data:t,renderNode:c,selectable:i,selectedKey:l,onSelect:s,direction:b="top-down",collapsible:m=!0,className:A,style:R,id:M},p)=>{const w=Me.ks(M),[I,S]=o.useState(new Set),N=o.useCallback(x=>{S($=>{const g=new Set($);return g.has(x)?g.delete(x):g.add(x),g})},[]),d=o.useCallback(x=>{i&&s?.(x)},[i,s]),h=o.useCallback(x=>{const $=I.has(x.key),g=x.children&&x.children.length>0;return e.jsxs("li",{className:"nice-org-chart__item",children:[e.jsxs("div",{className:`nice-org-chart__node${l===x.key?" nice-org-chart__node--selected":""}`,onClick:()=>d(x.key),role:i?"button":void 0,children:[c?c(x):e.jsx("span",{children:x.label}),m&&g&&e.jsx("button",{type:"button",className:"nice-org-chart__toggle",onClick:v=>{v.stopPropagation(),N(x.key)},"aria-label":$?"Expand":"Collapse",children:$?"+":"−"})]}),g&&!$&&e.jsx("ul",{className:"nice-org-chart__children",children:x.children.map(v=>h(v))})]},x.key)},[I,l,c,i,m,d,N]);return e.jsx("div",{ref:p,id:w,className:`nice-org-chart nice-org-chart--${b} ${A||""}`,style:R,children:e.jsx("ul",{className:"nice-org-chart__root",children:h(t)})})});Oe.displayName="NiceOrganizationChart";function mt(t,c,i){const l=S=>{const N=S.replace("#","");return[parseInt(N.slice(0,2),16),parseInt(N.slice(2,4),16),parseInt(N.slice(4,6),16)]},[s,b,m]=l(t),[A,R,M]=l(c),p=Math.round(s+(A-s)*i),w=Math.round(b+(R-b)*i),I=Math.round(m+(M-m)*i);return`rgb(${p},${w},${I})`}const Pe=o.forwardRef(({data:t,xLabels:c,yLabels:i,colors:l=["var(--nice-primary-bg, #e0f2fe)","var(--color-primary-active, #1d4ed8)"],onCellClick:s,cellSize:b=40,showValues:m=!0,className:A,style:R,id:M},p)=>{const w=Me.ks(M),{minVal:I,maxVal:S}=o.useMemo(()=>{let d=1/0,h=-1/0;for(const x of t)for(const $ of x)$<d&&(d=$),$>h&&(h=$);return{minVal:d,maxVal:h}},[t]),N=o.useCallback(d=>S===I?.5:(d-I)/(S-I),[I,S]);return e.jsx("div",{ref:p,id:w,className:`nice-heatmap ${A||""}`,style:R,children:e.jsxs("table",{className:"nice-heatmap__table",children:[c&&e.jsx("thead",{children:e.jsxs("tr",{children:[i&&e.jsx("th",{}),c.map((d,h)=>e.jsx("th",{className:"nice-heatmap__header",children:d},h))]})}),e.jsx("tbody",{children:t.map((d,h)=>e.jsxs("tr",{children:[i&&e.jsx("th",{className:"nice-heatmap__row-label",children:i[h]}),d.map((x,$)=>e.jsx("td",{className:"nice-heatmap__cell",style:{background:mt(l[0],l[1],N(x)),width:b,height:b,textAlign:"center",color:N(x)>.6?"var(--bg-primary, #fff)":"var(--bg-tertiary, #333)",cursor:s?"pointer":void 0},onClick:()=>s?.(h,$,x),title:String(x),children:m?x:""},$))]},h))})]})})});Pe.displayName="NiceHeatMap";function pt(t,c){const i=t.reduce((M,p)=>M+p.value,0);if(i===0||t.length===0)return[];const l=[];let{x:s,y:b,w:m,h:A}=c;const R=[...t].sort((M,p)=>p.value-M.value);for(const M of R){const p=M.value/i;if(m>=A){const w=m*p;l.push({x:s,y:b,w,h:A,node:M}),s+=w,m-=w}else{const w=A*p;l.push({x:s,y:b,w:m,h:w,node:M}),b+=w,A-=w}}return l}const gt=["var(--color-primary, #3b82f6)","var(--color-success, #10b981)","var(--color-warning, #f59e0b)","var(--color-error, #ef4444)","var(--color-accent, #8b5cf6)","var(--color-info, #06b6d4)","var(--color-accent-pink, #ec4899)","var(--nice-success, #84cc16)"],Ae=o.forwardRef(({data:t,width:c=600,height:i=400,onNodeClick:l,colors:s=gt,className:b,style:m,id:A},R)=>{const M=Me.ks(A),p=o.useMemo(()=>{const w=t.children??[t];return pt(w,{x:0,y:0,w:c,h:i})},[t,c,i]);return e.jsx("div",{ref:R,id:M,className:`nice-treemap ${b||""}`,style:m,children:e.jsx("svg",{width:c,height:i,className:"nice-treemap__svg",children:p.map((w,I)=>e.jsxs("g",{onClick:()=>l?.(w.node),style:{cursor:l?"pointer":void 0},children:[e.jsx("rect",{x:w.x,y:w.y,width:Math.max(w.w-1,0),height:Math.max(w.h-1,0),fill:w.node.color??s[I%s.length],rx:2}),w.w>40&&w.h>20&&e.jsx("text",{x:w.x+w.w/2,y:w.y+w.h/2,textAnchor:"middle",dominantBaseline:"central",fill:"var(--nice-bg, #fff)",fontSize:Math.min(12,w.w/6),className:"nice-treemap__label",children:w.node.label})]},w.node.key))})})});Ae.displayName="NiceTreeMap";const vt=Object.freeze(Object.defineProperty({__proto__:null,NiceTreeMap:Ae},Symbol.toStringTag,{value:"Module"})),Fe=o.forwardRef(({data:t,type:c="candlestick",showVolume:i=!0,width:l=800,height:s=400,bullColor:b="var(--color-success, #22c55e)",bearColor:m="var(--color-error, #ef4444)",className:A,style:R,id:M},p)=>{const w=Me.ks(M),I={top:20,right:20,bottom:i?80:30,left:60},S=l-I.left-I.right,N=i?50:0,d=s-I.top-I.bottom-N,{minP:h,maxP:x,maxVol:$}=o.useMemo(()=>{let u=1/0,L=-1/0,a=0;for(const j of t)j.low<u&&(u=j.low),j.high>L&&(L=j.high),j.volume&&j.volume>a&&(a=j.volume);return{minP:u,maxP:L,maxVol:a}},[t]),g=Math.max(1,S/t.length*.7),v=u=>I.left+(u+.5)*(S/t.length),y=u=>I.top+d-(u-h)/(x-h||1)*d,_=u=>s-I.bottom-N+N*(1-u/($||1));return e.jsx("div",{ref:p,id:w,className:`nice-stock-chart ${A||""}`,style:R,children:e.jsxs("svg",{width:l,height:s,className:"nice-stock-chart__svg",children:[[0,.25,.5,.75,1].map(u=>{const L=h+u*(x-h);return e.jsxs("g",{children:[e.jsx("line",{x1:I.left,x2:l-I.right,y1:y(L),y2:y(L),stroke:"var(--nice-border, #e5e7eb)",strokeDasharray:"2,2"}),e.jsx("text",{x:I.left-4,y:y(L)+4,textAnchor:"end",fontSize:10,fill:"var(--nice-text-secondary, #888)",children:L.toFixed(2)})]},u)}),c==="line"?e.jsx("polyline",{points:t.map((u,L)=>`${v(L)},${y(u.close)}`).join(" "),fill:"none",stroke:b,strokeWidth:1.5}):t.map((u,L)=>{const a=u.close>=u.open,j=a?b:m,C=v(L);if(c==="ohlc")return e.jsxs("g",{children:[e.jsx("line",{x1:C,x2:C,y1:y(u.high),y2:y(u.low),stroke:j,strokeWidth:1}),e.jsx("line",{x1:C-g/2,x2:C,y1:y(u.open),y2:y(u.open),stroke:j,strokeWidth:1.5}),e.jsx("line",{x1:C,x2:C+g/2,y1:y(u.close),y2:y(u.close),stroke:j,strokeWidth:1.5})]},L);const E=y(Math.max(u.open,u.close)),U=y(Math.min(u.open,u.close));return e.jsxs("g",{children:[e.jsx("line",{x1:C,x2:C,y1:y(u.high),y2:y(u.low),stroke:j,strokeWidth:1}),e.jsx("rect",{x:C-g/2,y:E,width:g,height:Math.max(U-E,1),fill:a?"transparent":j,stroke:j,strokeWidth:1})]},L)}),i&&t.map((u,L)=>{if(!u.volume)return null;const a=u.close>=u.open;return e.jsx("rect",{x:v(L)-g/2,y:_(u.volume),width:g,height:s-I.bottom-_(u.volume),fill:a?b:m,opacity:.3},`v${L}`)}),t.map((u,L)=>L%Math.max(1,Math.floor(t.length/8))!==0?null:e.jsx("text",{x:v(L),y:s-I.bottom+N+14,textAnchor:"middle",fontSize:9,fill:"var(--nice-text-secondary, #888)",children:u.date},`l${L}`))]})})});Fe.displayName="NiceStockChart";exports.CHART_COLORS=me;exports.NiceBarGauge=nt;exports.NiceBullet=st;exports.NiceChart=we;exports.NiceChart$1=Ye;exports.NiceChartAI=Ze;exports.NiceCircularGauge=et;exports.NiceDrillDownChart=We;exports.NiceForecastChart=ht;exports.NiceFunnel=ct;exports.NiceHeatMap=Pe;exports.NiceLinearGauge=tt;exports.NiceLiveChart=Re;exports.NiceMapChart=ut;exports.NiceOrganizationChart=Oe;exports.NicePieChart=Ke;exports.NicePolarChart=Qe;exports.NiceRangeSelector=it;exports.NiceRealtimeChart=Ee;exports.NiceSankey=De;exports.NiceSankey$1=ot;exports.NiceSankeyChart=xt;exports.NiceSparkline=rt;exports.NiceStockChart=Fe;exports.NiceTreeMap=Ae;exports.NiceTreeMap$1=vt;exports.NiceTreeMapChart=ft;exports.NiceVectorMap=Te;exports.NiceVectorMap$1=lt;exports.createMockLiveChartSource=Je;exports.createSignalRLiveChartSource=Ge;exports.createWebSocketLiveChartSource=qe;
|