@nice2dev/ui 1.0.8 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/NiceErrorBoundary-B5nF-OVn.cjs +1 -0
- package/dist/NiceErrorBoundary-BZEHCXNM.cjs +1 -0
- package/dist/NiceErrorBoundary-D6jw6wwD.js +762 -0
- package/dist/NiceErrorBoundary-D75yr_WE.js +762 -0
- package/dist/NiceForm-BgR-m8T9.cjs +382 -0
- package/dist/NiceForm-CKoJA6NG.js +5131 -0
- package/dist/NiceForm-D7xnpnRJ.cjs +382 -0
- package/dist/NiceForm-DYKciCeR.js +5131 -0
- package/dist/NiceForm.css +1 -0
- package/dist/NiceModal-1QX7NhyH.js +95 -0
- package/dist/NiceModal-Br3J9jOV.cjs +1 -0
- package/dist/NiceModal-CAwsKVQ2.cjs +1 -0
- package/dist/NiceModal-DVAsBzHP.js +95 -0
- package/dist/NiceModuleLifecyclePanel-C9xMSjOF.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-CMrPbSw9.js +5249 -0
- package/dist/NiceModuleLifecyclePanel-D3azLDdj.js +5249 -0
- package/dist/NiceModuleLifecyclePanel-DEfAIhFf.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel.css +1 -0
- package/dist/NicePagination-CbB5P1N_.js +171 -0
- package/dist/NicePagination-DbE-uOkl.js +171 -0
- package/dist/NicePagination-DlealakT.cjs +1 -0
- package/dist/NicePagination-UGjzvRUS.cjs +1 -0
- package/dist/NicePinCodeInput-B8cI8zu8.js +11830 -0
- package/dist/NicePinCodeInput-BmRO9HSQ.js +11830 -0
- package/dist/NicePinCodeInput-D91uvVsF.cjs +419 -0
- package/dist/NicePinCodeInput-SGQaHvpE.cjs +419 -0
- package/dist/NicePinCodeInput.css +1 -1
- package/dist/NiceSavedQueryPanel-7nZe46t8.cjs +596 -0
- package/dist/NiceSavedQueryPanel-BSGzs7Oc.js +6449 -0
- package/dist/NiceSavedQueryPanel-CZ5bYOe_.js +6449 -0
- package/dist/NiceSavedQueryPanel-Ce2s060j.cjs +596 -0
- package/dist/NiceTabs-BeaxZzAO.js +1636 -0
- package/dist/NiceTabs-DcbYFIWR.cjs +1 -0
- package/dist/NiceTabs-DvOmxKyQ.cjs +1 -0
- package/dist/NiceTabs-DzLHzwuA.js +1636 -0
- package/dist/NiceWindow-Bga9fOkg.js +1409 -0
- package/dist/NiceWindow-CVgkxcCz.cjs +1 -0
- package/dist/NiceWindow-CxWTj5xH.cjs +1 -0
- package/dist/NiceWindow-DeC83yfE.js +1409 -0
- package/dist/charts-BAS21jkC.js +4621 -0
- package/dist/charts-BcvKWYUl.cjs +759 -0
- package/dist/charts-DShUbWrP.cjs +759 -0
- package/dist/charts-DZvmvfhM.js +4621 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.d.ts +42 -45
- package/dist/charts.mjs +1 -1
- package/dist/core-B4b1BmHt.js +22177 -0
- package/dist/core-C2ZmWe_u.cjs +96 -0
- package/dist/core-CjmLbclt.cjs +96 -0
- package/dist/core-Da43q-pO.js +22094 -0
- package/dist/data-branching-CJlrg8qf.cjs +1 -0
- package/dist/data-branching-DCUwI53s.js +6121 -0
- package/dist/data-branching.cjs +1 -1
- package/dist/data-branching.d.ts +1 -38
- package/dist/data-branching.mjs +1 -1
- package/dist/data.cjs +1 -1
- package/dist/data.d.ts +206 -192
- package/dist/data.mjs +1 -1
- package/dist/devops-CXynFG3X.cjs +17 -0
- package/dist/devops-D0TfzV5B.js +7660 -0
- package/dist/devops.cjs +1 -1
- package/dist/devops.d.ts +1 -38
- package/dist/devops.mjs +1 -1
- package/dist/editors.cjs +1 -1
- package/dist/editors.d.ts +311 -393
- package/dist/editors.mjs +61 -64
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.d.ts +3 -44
- package/dist/feedback.mjs +11 -10
- package/dist/index-B8wxZ8Ps.cjs +5192 -0
- package/dist/index-DlHlXz8e.js +57319 -0
- package/dist/index-Dx726U90.cjs +5192 -0
- package/dist/index-pAuGTbuB.js +57319 -0
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +2249 -11141
- package/dist/index.mjs +880 -1018
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.d.ts +7 -39
- package/dist/lazy.mjs +24 -24
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.d.ts +151 -216
- package/dist/navigation.mjs +52 -46
- package/dist/no-code-B5bzduNP.cjs +332 -0
- package/dist/no-code-D8RJ7lx0.js +7064 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.d.ts +1 -38
- package/dist/no-code.mjs +1 -1
- package/dist/overlays.cjs +1 -1
- package/dist/overlays.d.ts +13 -45
- package/dist/overlays.mjs +243 -233
- package/package.json +5 -3
|
@@ -0,0 +1,759 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),o=require("react"),Me=require("./core-CjmLbclt.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)","#84cc16"],ke=({series:t,categories:c,width:l=600,height:d=400,title:s,showLegend:v=!0,showGrid:m=!0,axisLabels:C=!0,yAxisLabel:L,xAxisLabel:M,stacked:p,animated:N,zoomable:I,crosshair:S,annotations:w,legendInteractive:i,onDataPointClick:h,exportable:f,className:$,style:g})=>{const y=o.useRef(null),[_,b]=o.useState(new Set),[u,D]=o.useState(null),[a,j]=o.useState(null),[A,O]=o.useState(!1),Z=o.useRef(null),U=o.useMemo(()=>t.filter(R=>!_.has(R.name)),[t,_]),V=o.useCallback(R=>{i&&b(re=>{const ae=new Set(re);return ae.has(R)?ae.delete(R):ae.add(R),ae})},[i]),G={top:s?40:20,right:20,bottom:M?60:40,left:L?60:50},Q=l-G.left-G.right,q=d-G.top-G.bottom,J=U[0]?.data.length??t[0]?.data.length??0,n=a?.start??0,F=a?.end??J,H=F-n,B=o.useMemo(()=>U.map(R=>({...R,data:R.data.slice(n,F)})),[U,n,F]),x=o.useMemo(()=>c?.slice(n,F),[c,n,F]),{minY:P,maxY:Y,yTicks:ee}=o.useMemo(()=>{let R;if(p){R=[];for(let k=0;k<H;k++)R.push(B.reduce((K,se)=>K+(se.data[k]||0),0))}else R=B.flatMap(k=>k.data);R.length===0&&(R=[0]);const re=Math.min(0,...R),ae=Math.max(0,...R),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,H,p]),E=R=>q-(R-P)/(Y-P||1)*q,te=R=>(R+.5)/H*Q,ue=H>0?Q/H/(p?1.5:Math.max(U.length,1)*1.5):20,z=o.useCallback(R=>{if(!I)return;R.preventDefault();const re=a??{start:0,end:J},ae=re.end-re.start,ce=(re.start+re.end)/2,ie=R.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]),X=o.useCallback(R=>{I&&(O(!0),Z.current={x:R.clientX,range:a??{start:0,end:J}})},[I,a,J]),ne=o.useCallback(R=>{const re=y.current?.getBoundingClientRect();if(re&&D({x:R.clientX-re.left-G.left,y:R.clientY-re.top-G.top}),A&&Z.current&&I){const ae=R.clientX-Z.current.x,ce=Q/H,ie=-Math.round(ae/ce),r=Z.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})}},[A,I,Q,H,J,G.left,G.top]),de=o.useCallback(()=>{O(!1),Z.current=null},[]),ge=o.useCallback(()=>{D(null),O(!1),Z.current=null},[]),fe=o.useCallback(()=>{const R=y.current;if(!R)return;const re=new XMLSerializer().serializeToString(R),ae=document.createElement("canvas");ae.width=l,ae.height=d+(v?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)},[l,d,v]),pe=d+(v?30:0),be=B.length>0&&B.every(R=>R.type==="radar"),je=o.useMemo(()=>{if(!be)return 1;const R=B.flatMap(re=>re.data);return Math.max(1,...R)},[be,B]);if(be){const R=l/2,re=(d-G.top-G.bottom)/2+G.top,ae=Math.min(Q,d-G.top-G.bottom)/2-10,ce=x?.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[R+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:y,viewBox:`0 0 ${l} ${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:l/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(`${R+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:R,y1:re,x2:K,y2:se,className:"nice-chart__grid-line"},k)}),C&&x?.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:N?"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[ye,ve]=r(le,oe);return e.jsx("circle",{cx:ye,cy:ve,r:3,fill:K,children:e.jsx("title",{children:`${W.name}: ${oe}`})},le)})]},W.name)}),v&&e.jsx("g",{transform:`translate(${G.left}, ${d})`,children:t.map((W,k)=>{const K=k*120,se=_.has(W.name);return e.jsxs("g",{transform:`translate(${K}, 10)`,style:i?{cursor:"pointer"}:void 0,onClick:()=>V(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:[f&&e.jsx("button",{type:"button",className:"nice-chart__export-btn",onClick:fe,title:"Export PNG",children:"📷"}),e.jsxs("svg",{ref:y,viewBox:`0 0 ${l} ${pe}`,preserveAspectRatio:"xMidYMid meet",width:"100%",height:"100%",style:{display:"block",maxWidth:"100%",maxHeight:"100%"},className:"nice-chart__svg",onWheel:z,onMouseDown:X,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(R=>e.jsx("line",{x1:0,y1:E(R),x2:Q,y2:E(R),className:"nice-chart__grid-line"},`grid-${R}`)),C&&ee.map(R=>e.jsx("text",{x:-8,y:E(R)+4,textAnchor:"end",className:"nice-chart__axis-label",children:R},`ylabel-${R}`)),C&&x&&x.map((R,re)=>e.jsx("text",{x:te(re),y:q+20,textAnchor:"middle",className:"nice-chart__axis-label",children:R},re)),L&&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:L}),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"}),w?.map((R,re)=>{if(R.type==="line"){const ae=E(R.value);return e.jsxs("g",{children:[e.jsx("line",{x1:0,y1:ae,x2:Q,y2:ae,stroke:R.color||"var(--color-error, #ef4444)",strokeWidth:1.5,strokeDasharray:R.dash||"6,3"}),R.label&&e.jsx("text",{x:Q+4,y:ae+4,className:"nice-chart__annotation-label",fill:R.color||"var(--color-error, #ef4444)",children:R.label})]},re)}return e.jsx("text",{x:te(R.value),y:-4,textAnchor:"middle",className:"nice-chart__annotation-label",fill:R.color||"var(--text-muted, #6b7280)",children:R.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:"#9ca3af",strokeWidth:1,strokeDasharray:"4,2"}),e.jsx("line",{x1:0,y1:u.y,x2:Q,y2:u.y,stroke:"#9ca3af",strokeWidth:1,strokeDasharray:"4,2"})]}),B.map((R,re)=>{const ae=R.color||_e[re%_e.length],ce=R.type||"bar";if(ce==="bar")return e.jsx("g",{className:N?"nice-chart__series nice-chart__series--bar nice-chart__series--anim":"nice-chart__series nice-chart__series--bar",children:R.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=E(se+r),k=E(se)-W}else W=E(Math.max(0,r)),k=Math.abs(E(r)-E(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 ${E(0)}px`,...h?{cursor:"pointer"}:{}},onClick:h?()=>h(R.name,n+T,r):void 0,children:e.jsx("title",{children:`${R.name}: ${r}`})},T)})},R.name);if(ce==="scatter")return e.jsx("g",{className:N?"nice-chart__series nice-chart__series--scatter nice-chart__series--anim":"nice-chart__series nice-chart__series--scatter",children:R.data.map((r,T)=>e.jsx("circle",{cx:te(T),cy:E(r),r:5,fill:ae,fillOpacity:.7,stroke:ae,strokeWidth:1.5,style:h?{cursor:"pointer"}:void 0,onClick:h?()=>h(R.name,n+T,r):void 0,children:e.jsx("title",{children:`${R.name}: ${r}`})},T))},R.name);const ie=R.data.map((r,T)=>`${te(T)},${E(r)}`);return e.jsxs("g",{className:N?`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)},${E(0)} ${ie.join(" ")} ${te(H-1)},${E(0)}`,fill:ae,opacity:.15}),e.jsx("polyline",{points:ie.join(" "),fill:"none",stroke:ae,strokeWidth:2,className:N?"nice-chart__line":void 0}),R.data.map((r,T)=>e.jsx("circle",{cx:te(T),cy:E(r),r:3,fill:ae,style:h?{cursor:"pointer"}:void 0,onClick:h?()=>h(R.name,n+T,r):void 0,children:e.jsx("title",{children:`${R.name}: ${r}`})},T))]},R.name)})]}),v&&e.jsx("g",{transform:`translate(${G.left}, ${d})`,children:t.map((R,re)=>{const ae=re*120,ce=_.has(R.name);return e.jsxs("g",{transform:`translate(${ae}, 10)`,style:i?{cursor:"pointer"}:void 0,onClick:()=>V(R.name),opacity:ce?.35:1,children:[e.jsx("rect",{width:12,height:12,rx:2,fill:R.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:R.name})]},R.name)})})]})]})},Fe=Object.freeze(Object.defineProperty({__proto__:null,NiceChart:ke},Symbol.toStringTag,{value:"Module"}));function Ve(t){if(!t.length)return{categories:[],numericFields:[],sampleValues:{}};const c=t[0],l=[],d={};let s=null;for(const[m,C]of Object.entries(c))typeof C=="number"?(l.push(m),d[m]=t.map(L=>Number(L[m])||0)):!s&&(typeof C=="string"||C instanceof Date)&&(s=m);return{categories:s?t.map(m=>String(m[s]||"")):t.map((m,C)=>`Item ${C+1}`),numericFields:l,sampleValues:d}}function Xe(t,c){const{categories:l,numericFields:d,sampleValues:s}=Ve(t);return{series:d.map((m,C)=>({name:m.replace(/([A-Z])/g," $1").replace(/^./,L=>L.toUpperCase()).trim(),data:s[m],type:c==="area"?"area":c==="line"?"line":"bar"})),categories:l}}const Ze=o.forwardRef(function(c,l){const{rawData:d,enableAI:s=!0,aiModel:v,enableAutoType:m=!0,enableInsights:C=!0,dataDescription:L,onChartSuggestion:M,onInsights:p,showAIToolbar:N=!0,showInsightsOnLoad:I=!1,series:S,categories:w,...i}=c,[h,f]=o.useState("bar"),[$,g]=o.useState(null),[y,_]=o.useState([]),[b,u]=o.useState(I),[D,a]=o.useState(null),{t:j}=Me.Wo(),A=Me.ie(),{suggestChartType:O,generateInsights:Z,isLoading:U}=Me.dl(),V=s&&A.isConfigured,{series:G,categories:Q}=d?Xe(d,D||h):{series:S||[],categories:w},q=o.useCallback(async()=>{if(!V||!m)return{type:"bar",reason:"Default",config:{}};const B=d||(S?.length?S.flatMap(x=>x.data.map((P,Y)=>({[x.name]:P,index:Y}))):[]);try{const x=await O(B,L),P={type:x.type,reason:x.reason,config:x.config};return g(P),f(P.type),M?.(P),P}catch{return{type:"bar",reason:"Default fallback",config:{}}}},[V,m,d,S,L,O,M]),J=o.useCallback(async()=>{if(!V||!C)return[];const B=d||(S?.length?S.flatMap(x=>x.data.map((P,Y)=>({[x.name]:P,category:w?.[Y]||Y}))):[]);try{const x=await Z(B,D||h);return _(x),p?.(x),x}catch{return[]}},[V,C,d,S,w,h,D,Z,p]),n=o.useCallback(()=>D||h,[D,h]);o.useEffect(()=>{V&&m&&(d?.length||S?.length)&&q()},[V,m,d,S]),o.useImperativeHandle(l,()=>({getSuggestion:q,generateInsights:J,getCurrentType:n}));const F=[{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"}],H=D||h;return e.jsxs("div",{className:"nice-chart-ai","data-testid":c["data-testid"],children:[N&&V&&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,")"]})]}),U&&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:F.filter(B=>["bar","line","area"].includes(B.type)).map(({type:B,icon:x,label:P})=>e.jsx("button",{type:"button",className:`nice-chart-ai__type-btn ${H===B?"nice-chart-ai__type-btn--active":""}`,onClick:()=>a(B),title:P,children:x},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:U,title:j("chartAI.autoDetect","Auto-detect best chart type"),children:["🔮 ",j("chartAI.auto","Auto")]}),C&&e.jsxs("button",{type:"button",className:"nice-chart-ai__insights-btn",onClick:()=>{y.length||J(),u(!b)},disabled:U,title:j("chartAI.showInsights","Show data insights"),children:["💡 ",j("chartAI.insights","Insights")]})]})]}),e.jsx("div",{className:"nice-chart-ai__chart-wrapper",children:e.jsx(ke,{series:G,categories:Q,...i})}),b&&y.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:y.map((B,x)=>e.jsxs("li",{className:"nice-chart-ai__insight",children:[e.jsx("span",{className:"nice-chart-ai__insight-icon",children:"•"}),B]},x))}),e.jsx("div",{className:"nice-chart-ai__insights-footer",children:e.jsxs("button",{type:"button",className:"nice-chart-ai__refresh",onClick:()=>J(),disabled:U,children:["🔄 ",j("chartAI.refresh","Refresh")]})})]}),b&&U&&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 l=t?typeof t=="number"?new Date(t):new Date(t):new Date,d=L=>L.toString().padStart(2,"0"),s=d(l.getHours()),v=d(l.getMinutes()),m=d(l.getSeconds()),C=l.getMilliseconds().toString().padStart(3,"0");switch(c){case"HH:mm:ss":return`${s}:${v}:${m}`;case"HH:mm":return`${s}:${v}`;case"mm:ss":return`${v}:${m}`;case"ss.SSS":return`${m}.${C}`;case"ISO":return l.toISOString();default:return`${s}:${v}:${m}`}}function Ie(t){if(t.length===0)return null;const c=Math.min(...t),l=Math.max(...t),d=t.reduce((v,m)=>v+m,0)/t.length,s=t[t.length-1];return{min:c,max:l,avg:d,current:s,count:t.length}}const Re=o.forwardRef(({series:t,maxPoints:c=100,slidingWindow:l=!0,refreshRate:d=16,dataSource:s,width:v=600,height:m=400,title:C,showLegend:L=!0,showGrid:M=!0,yAxisLabel:p,xAxisLabel:N,stacked:I,zoomable:S,crosshair:w,annotations:i=[],legendInteractive:h,onDataPointClick:f,exportable:$,showControls:g=!0,showStatus:y=!0,initialPaused:_=!1,onDataReceived:b,onDataDropped:u,timeFormat:D="HH:mm:ss",showStats:a,thresholds:j=[],className:A,style:O},Z)=>{const[U,V]=o.useState(()=>{const z=new Map;for(const X of t)z.set(X.name,X.initialData?.slice()??[]);return z}),[G,Q]=o.useState([]),[q,J]=o.useState(_),[n,F]=o.useState(!1),H=o.useRef([]),B=o.useRef(Date.now()),x=o.useRef(null),P=o.useCallback(()=>{const z=H.current;z.length!==0&&(H.current=[],V(X=>{const ne=new Map(X);for(const de of z){const ge=ne.get(de.series);if(!ge)continue;const fe=[...ge,de.value];if(l&&fe.length>c){const pe=fe.length-c;u?.(pe,de.series),fe.splice(0,pe)}ne.set(de.series,fe)}return ne}),z.length>0&&Q(X=>{const ne=[...X];for(const de of z){const ge=de.category??Ue(de.timestamp,D);ne.push(ge)}return l&&ne.length>c&&ne.splice(0,ne.length-c),ne}))},[l,c,D,u]),Y=o.useCallback(()=>{const z=Date.now();z-B.current>=d&&(P(),B.current=z),x.current=requestAnimationFrame(Y)},[d,P]);o.useEffect(()=>(q||(x.current=requestAnimationFrame(Y)),()=>{x.current!==null&&(cancelAnimationFrame(x.current),x.current=null)}),[q,Y]);const ee=o.useCallback(z=>{if(q)return;const X="points"in z?z.points:[z];for(const ne of X)U.has(ne.series)&&(H.current.push(ne),b?.(ne))},[q,U,b]);o.useEffect(()=>{if(!s)return;const z=s.subscribe(ee);let X;return s.onStatusChange?X=s.onStatusChange(F):F(!0),s.fetchHistory&&s.fetchHistory(c).then(ne=>{for(const de of ne)H.current.push(de);P()}),()=>{z(),X?.()}},[s,ee,c,P]);const E=o.useMemo(()=>t.map(z=>({name:z.name,color:z.color,type:z.type,data:U.get(z.name)??[]})),[t,U]),te=o.useMemo(()=>{const z=[...i];for(const X of j)z.push({type:"line",value:X.value,color:X.color,label:X.label,dash:X.style==="dashed"?"5,5":X.style==="dotted"?"2,2":void 0});return z},[i,j]);o.useImperativeHandle(Z,()=>({pause(){J(!0)},resume(){J(!1)},isPaused(){return q},clear(){V(z=>{const X=new Map(z);for(const ne of X.keys())X.set(ne,[]);return X}),Q([]),H.current=[]},addPoint(z){ee(z)},addPoints(z){ee({points:z})},getData(z){return U.get(z)??[]},getCategories(){return G},exportData(){return{series:E,categories:G}},getStats(z){const X=U.get(z);return X?Ie(X):null}}),[q,U,G,E,ee]);const ue=o.useMemo(()=>{if(!a)return null;const z={};for(const[X,ne]of U)z[X]=Ie(ne);return z},[a,U]);return e.jsxs("div",{className:A,style:{position:"relative",...O},children:[y&&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:"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,X])=>X?e.jsxs("div",{style:{marginBottom:4},children:[e.jsx("strong",{children:z}),e.jsxs("div",{children:["Min: ",X.min.toFixed(2)," | Max: ",X.max.toFixed(2)]}),e.jsxs("div",{children:["Avg: ",X.avg.toFixed(2)," | Now: ",X.current.toFixed(2)]})]},z):null)}),e.jsx(ke,{series:E,categories:G,width:v,height:m,title:C,showLegend:L,showGrid:M,yAxisLabel:p,xAxisLabel:N,stacked:I,zoomable:S,crosshair:w,annotations:te,legendInteractive:h,onDataPointClick:f,exportable:$})]})});Re.displayName="NiceLiveChart";function Ge(t){const{hubConnection:c,eventName:l="DataPoint",subscribeMethod:d="SubscribeToMetrics",historyMethod:s="GetMetricHistory",metricName:v}=t;return{subscribe(m){const C=L=>{m(L)};return c.on(l,C),c.state==="Connected"&&c.invoke(d,v).catch(()=>{}),()=>{c.off(l,C)}},async fetchHistory(m){try{return await c.invoke(s,v,m)}catch{return[]}},onStatusChange(m){const C=()=>m(c.state==="Connected");return c.onclose(()=>m(!1)),c.onreconnected(()=>m(!0)),C(),()=>{}}}}function qe(t){const{url:c,autoReconnect:l=!0,reconnectDelay:d=3e3,parseMessage:s=p=>JSON.parse(p)}=t;let v=null,m=null,C=null,L=null;const M=()=>{v=new WebSocket(c),v.onopen=()=>{m?.(!0)},v.onclose=()=>{m?.(!1),l&&(L=setTimeout(M,d))},v.onerror=()=>{v?.close()},v.onmessage=p=>{try{const N=s(p.data);N&&C&&C(N)}catch{}}};return{subscribe(p){return C=p,M(),()=>{C=null,L&&clearTimeout(L),v?.close(),v=null}},onStatusChange(p){return m=p,()=>{m=null}}}}function Je(t){const{seriesNames:c,interval:l=1e3,generateValue:d=()=>Math.random()*100}=t;let s=null,v=0;return{subscribe(m){return s=setInterval(()=>{for(const C of c)m({series:C,value:d(C,v),timestamp:Date.now()});v++},l),()=>{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:l=400,innerRadius:d=0,title:s,showLegend:v=!0,showLabels:m=!0,className:C,style:L})=>{const M=c/2,p=(l-(v?30:0))/2+(s?10:0),N=Math.min(M,p)-40,I=t.reduce((i,h)=>i+h.value,0);let S=-Math.PI/2;const w=t.map((i,h)=>{const f=i.value/(I||1)*Math.PI*2,$=S;S+=f;const g=S,y=($+g)/2,_=M+N*Math.cos($),b=p+N*Math.sin($),u=M+N*Math.cos(g),D=p+N*Math.sin(g),a=f>Math.PI?1:0,j=i.color||me[h%me.length];let A;if(d>0){const V=M+d*Math.cos($),G=p+d*Math.sin($),Q=M+d*Math.cos(g),q=p+d*Math.sin(g);A=`M${_},${b} A${N},${N} 0 ${a},1 ${u},${D} L${Q},${q} A${d},${d} 0 ${a},0 ${V},${G} Z`}else A=`M${M},${p} L${_},${b} A${N},${N} 0 ${a},1 ${u},${D} Z`;const O=M+N*.7*Math.cos(y),Z=p+N*.7*Math.sin(y),U=I>0?Math.round(i.value/I*100):0;return{...i,path:A,labelX:O,labelY:Z,pct:U,color:j}});return e.jsx("div",{className:`nice-piechart ${C||""}`,style:L,children:e.jsxs("svg",{viewBox:`0 0 ${c} ${l}`,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}),w.map((i,h)=>e.jsxs("g",{children:[e.jsx("path",{d:i.path,fill:i.color,stroke:"var(--bg-primary, #fff)",strokeWidth:2,children:e.jsx("title",{children:`${i.label}: ${i.value} (${i.pct}%)`})}),m&&i.pct>=5&&e.jsxs("text",{x:i.labelX,y:i.labelY,textAnchor:"middle",dominantBaseline:"middle",className:"nice-piechart__label",children:[i.pct,"%"]})]},h)),v&&e.jsx("g",{transform:`translate(10, ${l-25})`,children:t.map((i,h)=>e.jsxs("g",{transform:`translate(${h*100}, 0)`,children:[e.jsx("rect",{width:10,height:10,rx:2,fill:i.color||me[h%me.length]}),e.jsx("text",{x:14,y:9,className:"nice-chart__legend-text",children:i.label})]},h))})]})})},Qe=({series:t,categories:c,width:l=400,height:d=400,maxValue:s,title:v,showLegend:m=!0,className:C,style:L})=>{const M=l/2,p=(d-(m?30:0))/2+(v?10:0),N=Math.min(M,p)-60,I=c.length,S=s??Math.max(...t.flatMap(f=>f.data),1),w=Math.PI*2/I,i=5,h=(f,$)=>{const g=f*w-Math.PI/2,y=$/S*N;return{x:M+y*Math.cos(g),y:p+y*Math.sin(g)}};return e.jsx("div",{className:`nice-polarchart ${C||""}`,style:L,children:e.jsxs("svg",{width:l,height:d,className:"nice-polarchart__svg",children:[v&&e.jsx("text",{x:M,y:20,textAnchor:"middle",className:"nice-chart__title",children:v}),Array.from({length:i},(f,$)=>{const g=N*(($+1)/i);return e.jsx("circle",{cx:M,cy:p,r:g,fill:"none",stroke:"var(--border-color, #ddd)",strokeWidth:.5},$)}),c.map((f,$)=>{const g=h($,S),y=h($,S*1.22),_=$*w-Math.PI/2,b=Math.cos(_),u=Math.sin(_),D=b>.2?"start":b<-.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:y.x,y:y.y,textAnchor:D,dominantBaseline:a,className:"nice-chart__axis-label nice-chart__axis-label--polar",children:f})]},$)}),t.map((f,$)=>{const g=f.color||me[$%me.length],y=f.data.map((_,b)=>{const u=h(b,_);return`${u.x},${u.y}`}).join(" ");return e.jsxs("g",{children:[e.jsx("polygon",{points:y,fill:f.fill!==!1?g:"none",fillOpacity:.15,stroke:g,strokeWidth:2}),f.data.map((_,b)=>{const u=h(b,_);return e.jsx("circle",{cx:u.x,cy:u.y,r:3,fill:g,children:e.jsx("title",{children:`${f.name} - ${c[b]}: ${_}`})},b)})]},f.name)}),m&&e.jsx("g",{transform:`translate(10, ${d-25})`,children:t.map((f,$)=>e.jsxs("g",{transform:`translate(${$*100}, 0)`,children:[e.jsx("rect",{width:10,height:10,rx:2,fill:f.color||me[$%me.length]}),e.jsx("text",{x:14,y:9,className:"nice-chart__legend-text",children:f.name})]},$))})]})})},et=({value:t,min:c=0,max:l=100,width:d=200,height:s=200,startAngle:v=225,endAngle:m=-45,color:C="var(--color-primary, #3b82f6)",trackColor:L,label:M,formatValue:p,ranges:N,className:I,style:S})=>{const w=d/2,i=s/2,h=Math.min(w,i)-20,f=Math.max(0,Math.min(1,(t-c)/(l-c||1))),$=a=>a*Math.PI/180,g=(v-m+360)%360||360,y=a=>({x:w+h*Math.cos($(a)),y:i-h*Math.sin($(a))}),_=(a,j)=>{const A=y(a),O=y(j),U=(a-j+360)%360>180?1:0;return`M${A.x},${A.y} A${h},${h} 0 ${U},1 ${O.x},${O.y}`},b=v-f*g,u=y(b);let D=C;if(N){for(const a of N)if(t>=a.start&&t<=a.end){D=a.color;break}}return e.jsx("div",{className:`nice-gauge nice-gauge--circular ${I||""}`,style:S,children:e.jsxs("svg",{width:d,height:s,children:[e.jsx("path",{d:_(v,m),fill:"none",stroke:L||"var(--border-color, #e2e8f0)",strokeWidth:12,strokeLinecap:"round"}),f>0&&e.jsx("path",{d:_(v,b),fill:"none",stroke:D,strokeWidth:12,strokeLinecap:"round"}),e.jsx("line",{x1:w,y1:i,x2:u.x,y2:u.y,stroke:"var(--text-primary, #333)",strokeWidth:2,strokeLinecap:"round"}),e.jsx("circle",{cx:w,cy:i,r:4,fill:"var(--text-primary, #333)"}),e.jsx("text",{x:w,y:i+h*.6,textAnchor:"middle",className:"nice-gauge__value",children:p?p(t):t}),M&&e.jsx("text",{x:w,y:i+h*.95,textAnchor:"middle",className:"nice-gauge__label",children:M})]})})},tt=({value:t,min:c=0,max:l=100,width:d=300,height:s=60,orientation:v="horizontal",color:m="var(--color-primary, #3b82f6)",label:C,formatValue:L,ranges:M,showTicks:p=!0,tickCount:N=5,className:I,style:S})=>{const w=v==="horizontal",i=w?d-40:s-40,h=Math.max(0,Math.min(1,(t-c)/(l-c||1))),f=10;let $=m;if(M){for(const y of M)if(t>=y.start&&t<=y.end){$=y.color;break}}const g=Array.from({length:N},(y,_)=>c+(l-c)*(_/(N-1)));return w?e.jsx("div",{className:`nice-gauge nice-gauge--linear ${I||""}`,style:S,children:e.jsxs("svg",{width:d,height:s,children:[e.jsx("text",{x:20+i*h,y:14,textAnchor:"middle",className:"nice-gauge__value",style:{fontSize:12},children:L?L(t):t}),e.jsx("rect",{x:20,y:s/2-f/2,width:i,height:f,rx:5,fill:"var(--border-color, #e2e8f0)"}),e.jsx("rect",{x:20,y:s/2-f/2,width:i*h,height:f,rx:5,fill:$}),e.jsx("polygon",{points:`${20+i*h},${s/2-f/2-2} ${20+i*h-5},${s/2-f/2-8} ${20+i*h+5},${s/2-f/2-8}`,fill:"var(--text-primary, #333)"}),p&&g.map((y,_)=>{const b=20+(y-c)/(l-c)*i;return e.jsx("text",{x:b,y:s/2+f/2+12,textAnchor:"middle",className:"nice-gauge__tick",children:y},_)}),C&&e.jsx("text",{x:d/2,y:s-2,textAnchor:"middle",className:"nice-gauge__label",children:C})]})}):e.jsx("div",{className:`nice-gauge nice-gauge--linear nice-gauge--vertical ${I||""}`,style:S,children:e.jsxs("svg",{width:d,height:s,children:[e.jsx("rect",{x:d/2-f/2,y:20,width:f,height:i,rx:5,fill:"var(--border-color, #e2e8f0)"}),e.jsx("rect",{x:d/2-f/2,y:20+i*(1-h),width:f,height:i*h,rx:5,fill:$}),e.jsx("text",{x:d/2,y:14,textAnchor:"middle",className:"nice-gauge__value",children:L?L(t):t}),C&&e.jsx("text",{x:d/2,y:s-4,textAnchor:"middle",className:"nice-gauge__label",children:C})]})})},nt=({items:t,min:c=0,max:l=100,width:d=300,height:s=300,startAngle:v=225,endAngle:m=-45,formatValue:C,title:L,className:M,style:p})=>{const N=d/2,I=s/2,S=Math.min(N,I)-30,w=Math.min(20,S/(t.length+1)),i=4,h=g=>g*Math.PI/180,f=(v-m+360)%360||360,$=(g,y,_)=>{const b=N+g*Math.cos(h(y)),u=I-g*Math.sin(h(y)),D=N+g*Math.cos(h(_)),a=I-g*Math.sin(h(_)),j=(y-_+360)%360;return`M${b},${u} A${g},${g} 0 ${j>180?1:0},1 ${D},${a}`};return e.jsx("div",{className:`nice-bargauge ${M||""}`,style:p,children:e.jsxs("svg",{width:d,height:s,children:[L&&e.jsx("text",{x:N,y:20,textAnchor:"middle",className:"nice-chart__title",children:L}),t.map((g,y)=>{const _=S-y*(w+i),b=Math.max(0,Math.min(1,(g.value-c)/(l-c||1))),u=v-b*f,D=g.color||me[y%me.length];return e.jsxs("g",{children:[e.jsx("path",{d:$(_,v,m),fill:"none",stroke:"var(--border-color, #e2e8f0)",strokeWidth:w,strokeLinecap:"round"}),b>0&&e.jsx("path",{d:$(_,v,u),fill:"none",stroke:D,strokeWidth:w,strokeLinecap:"round"})]},y)}),e.jsx("g",{children:t.map((g,y)=>e.jsxs("text",{x:N,y:I-((t.length-1)/2-y)*16,textAnchor:"middle",dominantBaseline:"middle",className:"nice-gauge__value",style:{fontSize:12},children:[g.label?`${g.label}: `:"",C?C(g.value):g.value]},y))})]})})},rt=({data:t,width:c=120,height:l=30,type:d="line",color:s="var(--color-primary, #3b82f6)",showMinMax:v,showLastPoint:m=!0,className:C,style:L})=>{if(t.length===0)return null;const M=2,p=Math.min(...t),N=Math.max(...t),I=N-p||1,S=c-M*2,w=l-M*2,i=_=>M+_/(t.length-1||1)*S,h=_=>M+w-(_-p)/I*w;if(d==="bar"){const _=Math.max(1,S/t.length-1);return e.jsx("svg",{width:c,height:l,className:`nice-sparkline ${C||""}`,style:L,children:t.map((b,u)=>e.jsx("rect",{x:M+u/t.length*S,y:h(b),width:_,height:w-(h(b)-M),fill:s,rx:1},u))})}const f=t.map((_,b)=>`${i(b)},${h(_)}`).join(" "),$=t.indexOf(p),g=t.indexOf(N),y=t.length-1;return e.jsxs("svg",{width:c,height:l,className:`nice-sparkline ${C||""}`,style:L,children:[d==="area"&&e.jsx("polygon",{points:`${i(0)},${M+w} ${f} ${i(y)},${M+w}`,fill:s,opacity:.15}),e.jsx("polyline",{points:f,fill:"none",stroke:s,strokeWidth:1.5}),v&&e.jsx("circle",{cx:i($),cy:h(p),r:2,fill:"#ef4444"}),v&&e.jsx("circle",{cx:i(g),cy:h(N),r:2,fill:"#22c55e"}),m&&e.jsx("circle",{cx:i(y),cy:h(t[y]),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:l=0,max:d=100,width:s,height:v,color:m="var(--color-primary, #3b82f6)",targetColor:C="var(--color-error, #ef4444)",size:L="md",label:M,labelPlacement:p="top",showValue:N=!1,showTarget:I=!1,formatValue:S=$=>String($),state:w="normal",errorMessage:i,className:h,style:f})=>{const $=at[L],g=s??$.width,y=v??$.height,_=$.fontSize,b=4,u=g-b*2,D=y-b*2,a=Math.max(0,Math.min(1,(t-l)/(d-l||1))),j=c!=null?Math.max(0,Math.min(1,(c-l)/(d-l||1))):null,A=()=>w==="error"?e.jsx("div",{role:"alert",style:{width:g,height:y,display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed var(--color-error, #ef4444)",borderRadius:4,color:"var(--color-error, #ef4444)",fontSize:_,padding:"0 8px",boxSizing:"border-box"},children:i??"Error"}):w==="loading"?e.jsx("div",{role:"status","aria-label":"Loading",className:"nice-bullet__skeleton",style:{width:g,height:y,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:y,role:"img","aria-label":typeof M=="string"?M:void 0,children:[e.jsx("rect",{x:b,y:b,width:u,height:D,rx:3,fill:"var(--border-color, #e2e8f0)"}),e.jsx("rect",{x:b,y:b+D*.2,width:u*a,height:D*.6,rx:2,fill:m}),j!=null&&e.jsx("line",{x1:b+u*j,y1:b+2,x2:b+u*j,y2:b+D-2,stroke:C,strokeWidth:2}),N&&e.jsx("text",{x:b+Math.max(u*a,4),y:y/2,dx:u*a>24?-4:4,textAnchor:u*a>24?"end":"start",dominantBaseline:"middle",fontSize:_,fill:u*a>24?"#fff":"var(--text-primary)",fontWeight:600,children:S(t)}),I&&j!=null&&e.jsxs("text",{x:b+u*j,y:b-1,textAnchor:"middle",fontSize:_-1,fill:C,fontWeight:600,children:["▼",S(c)]})]});if(p==="none"||!M)return e.jsxs("div",{className:`nice-bullet ${h||""}`,style:f,children:[A(),e.jsx("style",{children:ze})]});const O=p==="top"||p==="bottom",Z=e.jsx("span",{className:"nice-bullet__label",style:{fontSize:_,fontWeight:600,color:"var(--text-primary)",...O?{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:O?"column":"row",alignItems:O?"flex-start":"center",...f},children:[(p==="top"||p==="left")&&Z,A(),(p==="bottom"||p==="right")&&Z,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:l=300,inverted:d,showLabels:s=!0,showValues:v=!0,title:m,className:C,style:L})=>{const M={top:m?30:10,bottom:10,x:40},p=c-M.x*2,N=l-M.top-M.bottom,I=d?[...t].reverse():t,S=Math.max(...I.map(i=>i.value),1),w=N/I.length;return e.jsx("div",{className:`nice-funnel ${C||""}`,style:L,children:e.jsxs("svg",{width:c,height:l,children:[m&&e.jsx("text",{x:c/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:m}),I.map((i,h)=>{const f=i.value/S*p,$=h<I.length-1?I[h+1].value/S*p:f*.3,g=M.top+h*w,y=g+w,_=c/2,b=`${_-f/2},${g} ${_+f/2},${g} ${_+$/2},${y} ${_-$/2},${y}`,u=i.color||me[h%me.length];return e.jsxs("g",{children:[e.jsx("polygon",{points:b,fill:u,stroke:"var(--bg-primary, #fff)",strokeWidth:1,children:e.jsx("title",{children:`${i.label}: ${i.value}`})}),s&&e.jsx("text",{x:_,y:g+w/2-(v?4:0),textAnchor:"middle",dominantBaseline:"middle",className:"nice-funnel__label",children:i.label}),v&&e.jsx("text",{x:_,y:g+w/2+10,textAnchor:"middle",dominantBaseline:"middle",className:"nice-funnel__value",children:i.value})]},h)})]})})},De=({nodes:t,links:c,width:l=600,height:d=400,nodeWidth:s=20,nodePadding:v=10,title:m,className:C,style:L})=>{const M={top:m?40:20,bottom:20,left:20,right:20},p=l-M.left-M.right,N=d-M.top-M.bottom,I=new Set(c.map(a=>a.source)),S=new Set(c.map(a=>a.target)),w=t.filter(a=>I.has(a.id)&&!S.has(a.id)),i=t.filter(a=>S.has(a.id)),h=t.filter(a=>I.has(a.id)&&S.has(a.id)),f=[w,...h.length?[h]:[],i].filter(a=>a.length>0),$=f.length,g=new Map;t.forEach(a=>{const j=c.filter(O=>O.source===a.id).reduce((O,Z)=>O+Z.value,0),A=c.filter(O=>O.target===a.id).reduce((O,Z)=>O+Z.value,0);g.set(a.id,Math.max(j,A))});const y=f.map(a=>a.reduce((j,A)=>j+(g.get(A.id)||0),0)+(a.length-1)*v),_=Math.max(...y,1),b=new Map;f.forEach((a,j)=>{const A=M.left+j/($-1||1)*(p-s);let O=0;a.forEach(Z=>{const U=(g.get(Z.id)||0)/_*N;b.set(Z.id,{x:A,y:M.top+O,h:U}),O+=U+v})});const u=new Map,D=new Map;return t.forEach(a=>{u.set(a.id,0),D.set(a.id,0)}),e.jsx("div",{className:`nice-sankey ${C||""}`,style:L,children:e.jsxs("svg",{width:l,height:d,children:[m&&e.jsx("text",{x:l/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:m}),c.map((a,j)=>{const A=b.get(a.source),O=b.get(a.target);if(!A||!O)return null;const Z=u.get(a.source)||0,U=D.get(a.target)||0,V=a.value/_*N;u.set(a.source,Z+V),D.set(a.target,U+V);const G=A.x+s,Q=A.y+Z,q=O.x,J=O.y+U,n=(G+q)/2,H=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+V} C${n},${J+V} ${n},${Q+V} ${G},${Q+V} Z`,fill:H,fillOpacity:.3,stroke:H,strokeOpacity:.5,strokeWidth:.5,children:e.jsx("title",{children:`${a.source} → ${a.target}: ${a.value}`})},j)}),t.map((a,j)=>{const A=b.get(a.id);if(!A)return null;const O=a.color||me[j%me.length];return e.jsxs("g",{children:[e.jsx("rect",{x:A.x,y:A.y,width:s,height:Math.max(A.h,2),fill:O,rx:2}),e.jsx("text",{x:A.x<p/2?A.x+s+4:A.x-4,y:A.y+A.h/2,textAnchor:A.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:l,start:d,end:s,onChange:v,width:m=500,height:C=100,step:L=1,formatValue:M,chartColor:p="var(--color-primary, #3b82f6)",className:N,style:I})=>{const S={top:10,bottom:30,left:10,right:10},w=m-S.left-S.right,i=C-S.top-S.bottom,h=b=>S.left+(b-c)/(l-c||1)*w,f=b=>{const u=Math.max(0,Math.min(1,(b-S.left)/w)),D=c+u*(l-c);return Math.round(D/L)*L},$=(b,u)=>{u.preventDefault();const D=u.target.closest("svg");if(!D)return;const a=A=>{const O=D.getBoundingClientRect(),Z=f(A.clientX-O.left);b==="start"?v(Math.min(Z,s),s):v(d,Math.max(Z,d))},j=()=>{document.removeEventListener("pointermove",a),document.removeEventListener("pointerup",j)};document.addEventListener("pointermove",a),document.addEventListener("pointerup",j)},g=t?Math.min(...t):0,_=(t?Math.max(...t):1)-g||1;return e.jsx("div",{className:`nice-rangeselector ${N||""}`,style:I,children:e.jsxs("svg",{width:m,height:C,children:[t&&t.length>1&&e.jsx("polygon",{points:`${S.left},${S.top+i} ${t.map((b,u)=>`${S.left+u/(t.length-1)*w},${S.top+i-(b-g)/_*i}`).join(" ")} ${S.left+w},${S.top+i}`,fill:p,opacity:.15}),e.jsx("rect",{x:h(d),y:S.top,width:h(s)-h(d),height:i,fill:p,opacity:.1}),e.jsx("rect",{x:S.left,y:S.top,width:h(d)-S.left,height:i,fill:"var(--bg-secondary, #f5f5f5)",opacity:.6}),e.jsx("rect",{x:h(s),y:S.top,width:S.left+w-h(s),height:i,fill:"var(--bg-secondary, #f5f5f5)",opacity:.6}),e.jsx("rect",{x:h(d)-4,y:S.top,width:8,height:i,fill:p,rx:2,cursor:"ew-resize",onPointerDown:b=>$("start",b)}),e.jsx("rect",{x:h(s)-4,y:S.top,width:8,height:i,fill:p,rx:2,cursor:"ew-resize",onPointerDown:b=>$("end",b)}),e.jsx("text",{x:h(d),y:S.top+i+18,textAnchor:"middle",className:"nice-chart__axis-label",children:M?M(d):d}),e.jsx("text",{x:h(s),y:S.top+i+18,textAnchor:"middle",className:"nice-chart__axis-label",children:M?M(s):s})]})})},Te=({regions:t,width:c=600,height:l=400,viewBox:d="0 0 1000 600",colorRange:s=["var(--info-bg, #dbeafe)","var(--color-primary-active, #1d4ed8)"],maxValue:v,onRegionClick:m,selectedRegionId:C,title:L,showTooltip:M=!0,className:p,style:N})=>{const I=v??Math.max(...t.map(w=>w.value??0),1),S=w=>{const i=a=>[parseInt(a.slice(1,3),16),parseInt(a.slice(3,5),16),parseInt(a.slice(5,7),16)],[h,f,$]=i(s[0]),[g,y,_]=i(s[1]),b=Math.round(h+(g-h)*w),u=Math.round(f+(y-f)*w),D=Math.round($+(_-$)*w);return`rgb(${b},${u},${D})`};return e.jsxs("div",{className:`nice-vectormap ${p||""}`,style:N,children:[L&&e.jsx("div",{className:"nice-vectormap__title",children:L}),e.jsx("svg",{width:c,height:l,viewBox:d,children:t.map(w=>{const i=w.value!=null?Math.max(0,Math.min(1,w.value/I)):0,h=w.value!=null?S(i):"var(--bg-tertiary, #e5e7eb)",f=w.id===C;return e.jsx("path",{d:w.path,fill:h,stroke:f?"var(--color-primary, #3b82f6)":"var(--border-color, #d1d5db)",strokeWidth:f?2:.5,cursor:m?"pointer":void 0,onClick:()=>m?.(w),children:M&&e.jsx("title",{children:`${w.name}${w.value!=null?`: ${w.value}`:""}`})},w.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: 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: 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: #ef4444;
|
|
155
|
+
stroke-width: 2;
|
|
156
|
+
stroke-dasharray: 8, 4;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.nice-forecast-chart__cash-runway-label-bg {
|
|
160
|
+
fill: #ef4444;
|
|
161
|
+
rx: 4;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.nice-forecast-chart__cash-runway-label {
|
|
165
|
+
font-size: 0.6875rem;
|
|
166
|
+
font-weight: 600;
|
|
167
|
+
fill: #ffffff;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.nice-forecast-chart__cash-runway-date {
|
|
171
|
+
font-size: 0.625rem;
|
|
172
|
+
fill: #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: 0.5rem;
|
|
184
|
+
box-shadow: 0 4px 12px 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: 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: 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)","#f97316"];function xe(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 we(t,c="pl-PL"){return new Intl.NumberFormat(c,{minimumFractionDigits:0,maximumFractionDigits:2}).format(t)}const ht=o.forwardRef(function(c,l){const{scenarios:d,data:s,annotations:v=[],referenceLines:m=[],forecastStartDate:C,cashRunway:L,xAxis:M,yAxis:p,confidenceBands:N=[{level:95,color:"var(--color-primary, #3b82f6)",opacity:.15}],tooltip:I,legend:S={enabled:!0,position:"bottom",interactive:!0},height:w=350,showForecastRegion:i=!0,lineWidth:h=2,showPoints:f=!1,pointRadius:$=4,enableZoom:g=!1,zoomEnabled:y,animationDuration:_=300,showLegend:b,responsive:u=!0,onPointClick:D,onAnnotationClick:a,onScenarioToggle:j,onViewportChange:A,size:O="medium",disabled:Z=!1,labels:U={},locale:V="pl-PL",className:G,style:Q}=c,q=d&&d.length>0?d:s?[{id:"default",name:"Series",data:s}]:[],J={...S,enabled:b??S.enabled},[n,F]=o.useState(()=>q.map((r,T)=>({...r,color:r.color??Le[T%Le.length],visible:r.visible!==!1}))),[H,B]=o.useState(null),[x,P]=o.useState({x:0,y:0}),Y=o.useRef(null),ee=o.useRef(null),E={top:20,right:30,bottom:40,left:60},[te,ue]=o.useState({width:600,height:typeof w=="number"?w:350});o.useEffect(()=>{if(!u||!Y.current)return;const r=new ResizeObserver(T=>{for(const W of T)ue(k=>({width:W.contentRect.width,height:k.height}))});return r.observe(Y.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:X,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=>xe(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,ye=te.width-E.left-E.right,ve=te.height-E.top-E.bottom,Ne=he=>{const Se=typeof he=="number"?he:he.getTime();return E.left+(Se-k)/(K-k)*ye},$e=he=>E.top+ve-(he-oe)/(le-oe)*ve,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,E,p]),fe=C?xe(C):null,pe=o.useMemo(()=>{if(!L?.enabled)return null;const r=L.threshold??0,T=L.scenarioId?n.find(k=>k.id===L.scenarioId&&k.visible!==!1):n.find(k=>k.visible!==!1);if(!T)return null;const W=T.data.sort((k,K)=>xe(k.date).getTime()-xe(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 ye=(oe-r)/(oe-le),ve=xe(K.date).getTime(),Ne=xe(se.date).getTime(),$e=ve+ye*(Ne-ve);return new Date($e)}}return null},[L,n]),be=o.useCallback((r,T)=>{const W=r.filter(k=>k[T]!=null).map(k=>({x:z(xe(k.date)),y:X(k[T])}));return W.length===0?"":`M ${W.map(k=>`${k.x},${k.y}`).join(" L ")}`},[z,X]),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(xe(K.date)),y:X(K.upperBound)})),k=T.map(K=>({x:z(xe(K.date)),y:X(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,X]),R=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 ye=le.data.find(ve=>xe(ve.date).getTime()===k.getTime());return{scenario:le,value:ye?.value,forecast:ye?.forecast,lowerBound:ye?.lowerBound,upperBound:ye?.upperBound}}),oe=v.filter(le=>Math.abs(xe(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,v,I]),re=o.useCallback(r=>{if(!J.interactive)return;F(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(l,()=>({getScenarios:()=>n,updateScenario:(r,T)=>{F(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=>xe(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:v.filter(W=>xe(W.date).getTime()===r.getTime())}}}),[n,v,re]),te.width-E.left-E.right;const ae=te.height-E.top-E.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:U.noData??"No data available"})}):e.jsxs("div",{className:`nice-forecast-chart ${G??""}`,style:{...Q,height:w},children:[e.jsxs("div",{ref:Y,className:"nice-forecast-chart__container",children:[e.jsxs("svg",{ref:ee,className:"nice-forecast-chart__svg",width:te.width,height:te.height,onMouseMove:R,onMouseLeave:()=>B(null),children:[p?.showGrid!==!1&&ce.map(r=>e.jsx("line",{className:"nice-forecast-chart__grid-line",x1:E.left,x2:te.width-E.right,y1:X(r),y2:X(r)},r)),i&&fe&&e.jsx("rect",{className:"nice-forecast-chart__forecast-region",x:z(fe),y:E.top,width:te.width-E.right-z(fe),height:ae}),m.map(r=>e.jsxs("g",{children:[e.jsx("line",{className:"nice-forecast-chart__reference-line",x1:E.left,x2:te.width-E.right,y1:X(r.value),y2:X(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-E.right-4,y:X(r.value)-4,textAnchor:"end",children:r.label})]},r.id)),pe&&L?.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:E.top,y2:te.height-E.bottom,stroke:L.color??"var(--color-error, #ef4444)"}),L.showLabel!==!1&&e.jsxs(e.Fragment,{children:[e.jsx("rect",{className:"nice-forecast-chart__cash-runway-label-bg",x:z(pe)-60,y:E.top-2,width:120,height:L.showDate!==!1?32:20,fill:L.color??"var(--color-error, #ef4444)",rx:4}),e.jsx("text",{className:"nice-forecast-chart__cash-runway-label",x:z(pe),y:E.top+12,textAnchor:"middle",fill:"#ffffff",children:L.label??U.cashRunsOut??"💰 Cash runs out"}),L.showDate!==!1&&e.jsx("text",{className:"nice-forecast-chart__cash-runway-label",x:z(pe),y:E.top+26,textAnchor:"middle",fill:"#ffffff",style:{fontSize:"0.625rem",opacity:.9},children:Ce(pe,V)})]})]}),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=fe?r.data.filter(k=>xe(k.date)<fe):r.data.filter(k=>k.value!=null),W=fe?r.data.filter(k=>xe(k.date)>=fe):r.data.filter(k=>k.forecast!=null);return e.jsxs("g",{children:[e.jsx("path",{className:"nice-forecast-chart__historical-line",d:be(T,"value"),stroke:r.color,strokeWidth:h}),e.jsx("path",{className:"nice-forecast-chart__forecast-line",d:be(W,fe?"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:be(r.data,"forecast"),stroke:r.color,strokeWidth:h}),f&&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(xe(k.date)),cy:X(se),r:$,fill:r.color,onClick:()=>D?.(k,r)},K)})]},r.id)}),v.map(r=>{const T=z(xe(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:E.top,y2:te.height-E.bottom,stroke:r.color??"var(--text-muted, #9ca3af)"}),e.jsx("circle",{cx:T,cy:E.top+10,r:8,fill:r.color??"var(--text-muted, #9ca3af)"}),e.jsx("text",{x:T,y:E.top+14,textAnchor:"middle",fill:"white",fontSize:"10",children:r.icon??"!"})]},r.id)}),e.jsx("line",{className:"nice-forecast-chart__axis-line",x1:E.left,x2:E.left,y1:E.top,y2:te.height-E.bottom}),e.jsx("line",{className:"nice-forecast-chart__axis-line",x1:E.left,x2:te.width-E.right,y1:te.height-E.bottom,y2:te.height-E.bottom}),ce.map(r=>e.jsx("text",{className:"nice-forecast-chart__axis-label",x:E.left-8,y:X(r)+4,textAnchor:"end",children:p?.format?p.format(r):we(r,V)},r)),ie.map(r=>e.jsx("text",{className:"nice-forecast-chart__axis-label",x:z(r),y:te.height-E.bottom+16,textAnchor:"middle",children:M?.format?M.format(r):Ce(r,V)},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})]}),H&&e.jsxs("div",{className:"nice-forecast-chart__tooltip",style:{left:x.x,top:x.y},children:[e.jsx("div",{className:"nice-forecast-chart__tooltip-date",children:Ce(H.date,V)}),H.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:we(T,V)})]},r.scenario.id)}),H.values.some(r=>r.lowerBound!=null)&&e.jsxs("div",{className:"nice-forecast-chart__tooltip-confidence",children:[U.confidence??"CI",":"," ",we(H.values[0]?.lowerBound??0,V)," –"," ",we(H.values[0]?.upperBound??0,V)]})]})]}),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)","#84cc16","#f97316","var(--color-accent, #6366f1)"],We=o.forwardRef((t,c)=>{const{levels:l,initialLevelId:d,chartType:s="bar",width:v=600,height:m=400,showBreadcrumbs:C=!0,showBackButton:L=!0,animationDuration:M=300,onLevelChange:p,onItemClick:N,colors:I=Be,showValues:S=!0,showLegend:w=!0,className:i,style:h,...f}=t,[$,g]=o.useState(d||l[0]?.id),[y,_]=o.useState([d||l[0]?.id]),[b,u]=o.useState(!1),[D,a]=o.useState("in"),j=o.useMemo(()=>l.find(n=>n.id===$),[l,$]),A=o.useCallback(n=>{l.find(H=>H.id===n)&&(a("in"),u(!0),setTimeout(()=>{g(n),_(H=>[...H,n]),p?.(n,[...y,n]),u(!1)},M/2))},[l,y,M,p]),O=o.useCallback(()=>{if(y.length<=1)return;a("out"),u(!0);const n=y.slice(0,-1),F=n[n.length-1];setTimeout(()=>{g(F),_(n),p?.(F,n),u(!1)},M/2)},[y,M,p]),Z=o.useCallback(()=>{const n=l[0]?.id;n&&(a("out"),u(!0),setTimeout(()=>{g(n),_([n]),p?.(n,[n]),u(!1)},M/2))},[l,M,p]);o.useImperativeHandle(c,()=>({drillDown:A,drillUp:O,resetToRoot:Z,getCurrentLevel:()=>$,getPath:()=>y}),[A,O,Z,$,y]);const U=o.useCallback((n,F)=>{N?.(n,$);const H=l.find(B=>B.parentId===$&&B.id===n.metadata?.childLevelId);H&&A(H.id)},[$,l,A,N]),V=o.useMemo(()=>j?.data.reduce((n,F)=>n+F.value,0)||0,[j]),G=o.useMemo(()=>y.map(n=>l.find(F=>F.id===n)?.label||n),[y,l]),Q=()=>{if(!j)return null;const n=j.data,F=Math.max(...n.map(B=>B.value)),H=Math.min(40,(m-100)/n.length-8);return e.jsx("div",{className:"nice-drilldown-bars",children:n.map((B,x)=>{const P=B.value/F*100;return e.jsxs("div",{className:"nice-drilldown-bar-row",onClick:()=>U(B,x),children:[e.jsx("span",{className:"nice-drilldown-bar-label",children:B.label||`Item ${x+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[x%I.length],height:H}})}),S&&e.jsx("span",{className:"nice-drilldown-bar-value",children:B.value.toLocaleString()})]},x)})})},q=()=>{if(!j)return null;const n=j.data,F=v/2,H=(m-60)/2+30,B=Math.min(F,H)-40;let x=-90;const P=n.map((Y,ee)=>{const E=Y.value/V*360,te=x+E,ue=E>180?1:0,z=x*Math.PI/180,X=te*Math.PI/180,ne=F+B*Math.cos(z),de=H+B*Math.sin(z),ge=F+B*Math.cos(X),fe=H+B*Math.sin(X),pe=(x+E/2)*Math.PI/180,be=F+B*.7*Math.cos(pe),je=H+B*.7*Math.sin(pe),R=`M ${F} ${H} L ${ne} ${de} A ${B} ${B} 0 ${ue} 1 ${ge} ${fe} Z`;return x=te,{path:R,color:Y.color||I[ee%I.length],label:Y.label||`Item ${ee+1}`,value:Y.value,percentage:(Y.value/V*100).toFixed(1),labelX:be,labelY:je,item:Y,index:ee}});return e.jsx("svg",{width:v,height:m-40,className:"nice-drilldown-pie",children:e.jsx("g",{children:P.map((Y,ee)=>e.jsxs("g",{onClick:()=>U(Y.item,Y.index),children:[e.jsx("path",{d:Y.path,fill:Y.color,stroke:"white",strokeWidth:2,className:"nice-drilldown-pie-slice"}),S&&parseFloat(Y.percentage)>5&&e.jsxs("text",{x:Y.labelX,y:Y.labelY,textAnchor:"middle",dominantBaseline:"middle",fill:"white",fontSize:"12",fontWeight:"600",children:[Y.percentage,"%"]})]},ee))})})},J=()=>{if(!j)return null;const n=j.data,F=Math.max(...n.map(x=>x.value)),H=Math.min(60,(v-100)/n.length-8),B=m-100;return e.jsx("svg",{width:v,height:m-40,className:"nice-drilldown-columns",children:e.jsxs("g",{transform:"translate(50, 20)",children:[[0,.25,.5,.75,1].map((x,P)=>e.jsxs("g",{children:[e.jsx("line",{x1:0,y1:B*(1-x),x2:v-80,y2:B*(1-x),stroke:"#e5e7eb",strokeDasharray:x===0?void 0:"4"}),e.jsx("text",{x:-8,y:B*(1-x),textAnchor:"end",dominantBaseline:"middle",fontSize:"11",fill:"#6b7280",children:Math.round(F*x).toLocaleString()})]},P)),n.map((x,P)=>{const Y=x.value/F*B,ee=P*((v-100)/n.length)+((v-100)/n.length-H)/2;return e.jsxs("g",{onClick:()=>U(x,P),children:[e.jsx("rect",{x:ee,y:B-Y,width:H,height:Y,fill:x.color||I[P%I.length],rx:4,className:"nice-drilldown-column-bar"}),e.jsx("text",{x:ee+H/2,y:B+16,textAnchor:"middle",fontSize:"11",fill:"#374151",children:(x.label||`${P+1}`).slice(0,10)}),S&&e.jsx("text",{x:ee+H/2,y:B-Y-8,textAnchor:"middle",fontSize:"11",fill:"#374151",fontWeight:"500",children:x.value.toLocaleString()})]},P)})]})})};return e.jsxs("div",{className:`nice-drilldown-chart ${b?`animating ${D}`:""} ${i||""}`,style:{width:v,...h},...f,children:[e.jsxs("div",{className:"nice-drilldown-header",children:[L&&y.length>1&&e.jsx("button",{className:"nice-drilldown-back",onClick:O,children:"← Wstecz"}),C&&e.jsx("div",{className:"nice-drilldown-breadcrumbs",children:G.map((n,F)=>e.jsxs(o.Fragment,{children:[F>0&&e.jsx("span",{className:"nice-drilldown-separator",children:"/"}),e.jsx("span",{className:`nice-drilldown-crumb ${F===G.length-1?"active":""}`,onClick:()=>{if(F<G.length-1){const H=y.slice(0,F+1);_(H),g(H[H.length-1])}},children:n})]},F))})]}),e.jsxs("div",{className:"nice-drilldown-content",style:{height:m-40},children:[s==="bar"&&Q(),s==="pie"&&q(),s==="column"&&J()]}),w&&j&&e.jsx("div",{className:"nice-drilldown-legend",children:j.data.map((n,F)=>e.jsxs("div",{className:"nice-drilldown-legend-item",children:[e.jsx("span",{className:"nice-drilldown-legend-color",style:{backgroundColor:n.color||I[F%I.length]}}),e.jsx("span",{className:"nice-drilldown-legend-label",children:n.label||`Item ${F+1}`})]},F))}),e.jsx("style",{children:`
|
|
293
|
+
.nice-drilldown-chart {
|
|
294
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
295
|
+
background: white;
|
|
296
|
+
border-radius: 8px;
|
|
297
|
+
overflow: hidden;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.nice-drilldown-header {
|
|
301
|
+
display: flex;
|
|
302
|
+
align-items: center;
|
|
303
|
+
gap: 12px;
|
|
304
|
+
padding: 12px 16px;
|
|
305
|
+
border-bottom: 1px solid var(--border-color, #e5e7eb);
|
|
306
|
+
min-height: 40px;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.nice-drilldown-back {
|
|
310
|
+
background: #f3f4f6;
|
|
311
|
+
border: none;
|
|
312
|
+
padding: 6px 12px;
|
|
313
|
+
border-radius: 6px;
|
|
314
|
+
cursor: pointer;
|
|
315
|
+
font-size: 13px;
|
|
316
|
+
color: #374151;
|
|
317
|
+
transition: background 0.2s;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.nice-drilldown-back:hover {
|
|
321
|
+
background: #e5e7eb;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
.nice-drilldown-breadcrumbs {
|
|
325
|
+
display: flex;
|
|
326
|
+
align-items: center;
|
|
327
|
+
gap: 4px;
|
|
328
|
+
font-size: 13px;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
.nice-drilldown-separator {
|
|
332
|
+
color: #9ca3af;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
.nice-drilldown-crumb {
|
|
336
|
+
color: #6b7280;
|
|
337
|
+
cursor: pointer;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.nice-drilldown-crumb:hover:not(.active) {
|
|
341
|
+
color: #3b82f6;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.nice-drilldown-crumb.active {
|
|
345
|
+
color: #111827;
|
|
346
|
+
font-weight: 500;
|
|
347
|
+
cursor: default;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
.nice-drilldown-content {
|
|
351
|
+
padding: 16px;
|
|
352
|
+
transition: opacity 0.15s, transform 0.15s;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
.nice-drilldown-chart.animating .nice-drilldown-content {
|
|
356
|
+
opacity: 0;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
.nice-drilldown-chart.animating.in .nice-drilldown-content {
|
|
360
|
+
transform: translateX(20px);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
.nice-drilldown-chart.animating.out .nice-drilldown-content {
|
|
364
|
+
transform: translateX(-20px);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
.nice-drilldown-bars {
|
|
368
|
+
display: flex;
|
|
369
|
+
flex-direction: column;
|
|
370
|
+
gap: 8px;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
.nice-drilldown-bar-row {
|
|
374
|
+
display: flex;
|
|
375
|
+
align-items: center;
|
|
376
|
+
gap: 12px;
|
|
377
|
+
cursor: pointer;
|
|
378
|
+
padding: 4px 8px;
|
|
379
|
+
margin: -4px -8px;
|
|
380
|
+
border-radius: 6px;
|
|
381
|
+
transition: background 0.2s;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
.nice-drilldown-bar-row:hover {
|
|
385
|
+
background: #f9fafb;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
.nice-drilldown-bar-label {
|
|
389
|
+
width: 120px;
|
|
390
|
+
font-size: 13px;
|
|
391
|
+
color: #374151;
|
|
392
|
+
overflow: hidden;
|
|
393
|
+
text-overflow: ellipsis;
|
|
394
|
+
white-space: nowrap;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
.nice-drilldown-bar-track {
|
|
398
|
+
flex: 1;
|
|
399
|
+
background: #f3f4f6;
|
|
400
|
+
border-radius: 6px;
|
|
401
|
+
overflow: hidden;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
.nice-drilldown-bar-fill {
|
|
405
|
+
transition: width 0.3s ease;
|
|
406
|
+
border-radius: 6px;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
.nice-drilldown-bar-value {
|
|
410
|
+
width: 80px;
|
|
411
|
+
text-align: right;
|
|
412
|
+
font-size: 13px;
|
|
413
|
+
font-weight: 500;
|
|
414
|
+
color: #111827;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
.nice-drilldown-pie-slice {
|
|
418
|
+
cursor: pointer;
|
|
419
|
+
transition: transform 0.2s, opacity 0.2s;
|
|
420
|
+
transform-origin: center;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
.nice-drilldown-pie-slice:hover {
|
|
424
|
+
opacity: 0.85;
|
|
425
|
+
transform: scale(1.02);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
.nice-drilldown-column-bar {
|
|
429
|
+
cursor: pointer;
|
|
430
|
+
transition: opacity 0.2s;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
.nice-drilldown-column-bar:hover {
|
|
434
|
+
opacity: 0.8;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
.nice-drilldown-legend {
|
|
438
|
+
display: flex;
|
|
439
|
+
flex-wrap: wrap;
|
|
440
|
+
gap: 16px;
|
|
441
|
+
padding: 12px 16px;
|
|
442
|
+
border-top: 1px solid var(--border-color, #e5e7eb);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
.nice-drilldown-legend-item {
|
|
446
|
+
display: flex;
|
|
447
|
+
align-items: center;
|
|
448
|
+
gap: 6px;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
.nice-drilldown-legend-color {
|
|
452
|
+
width: 12px;
|
|
453
|
+
height: 12px;
|
|
454
|
+
border-radius: 3px;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
.nice-drilldown-legend-label {
|
|
458
|
+
font-size: 12px;
|
|
459
|
+
color: #6b7280;
|
|
460
|
+
}
|
|
461
|
+
`})]})});We.displayName="NiceDrillDownChart";const ut=({type:t="choropleth",regions:c=[],bubbles:l=[],width:d=800,height:s=500,viewBox:v="0 0 800 500",colorScale:m=["var(--info-bg, #dbeafe)","var(--color-primary-light, #93c5fd)","var(--color-primary, #3b82f6)","var(--color-primary-active, #1d4ed8)","#1e3a8a"],minValue:C,maxValue:L,showTooltip:M=!0,showLegend:p=!0,onRegionClick:N,onBubbleClick:I,onRegionHover:S,title:w,mapSvg:i,zoomable:h=!1,className:f,style:$,...g})=>{const[y,_]=o.useState(null),[b,u]=o.useState(1),[D,a]=o.useState({x:0,y:0}),j=o.useRef(null),A=o.useRef(!1),O=o.useRef({x:0,y:0}),Z=C??Math.min(...c.map(x=>x.value),...l.map(x=>x.value)),U=L??Math.max(...c.map(x=>x.value),...l.map(x=>x.value)),V=o.useCallback(x=>{const P=(x-Z)/(U-Z),Y=Math.min(Math.floor(P*m.length),m.length-1);return m[Math.max(0,Y)]},[Z,U,m]),G=o.useCallback(x=>{if(!M||!y)return;const P=j.current?.getBoundingClientRect();P&&_(Y=>Y?{...Y,x:x.clientX-P.left,y:x.clientY-P.top}:null)},[M,y]),Q=o.useCallback((x,P)=>{const Y=j.current?.getBoundingClientRect();Y&&M&&_({x:P.clientX-Y.left,y:P.clientY-Y.top,content:`${x.name}: ${x.value.toLocaleString()}`}),S?.(x)},[M,S]),q=o.useCallback(()=>{_(null),S?.(null)},[S]),J=o.useCallback(x=>{if(!h)return;x.preventDefault();const P=x.deltaY>0?.9:1.1;u(Y=>Math.min(Math.max(Y*P,.5),4))},[h]),n=o.useCallback(x=>{h&&(A.current=!0,O.current={x:x.clientX-D.x,y:x.clientY-D.y})},[h,D]),F=o.useCallback(()=>{A.current=!1},[]),H=o.useCallback(x=>{A.current&&a({x:x.clientX-O.current.x,y:x.clientY-O.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 ${f||""}`,style:{width:d,...$},...g,children:[w&&e.jsx("div",{className:"nice-map-title",children:w}),e.jsx("svg",{ref:j,width:d,height:s,viewBox:v,className:"nice-map-svg",onWheel:J,onMouseDown:n,onMouseUp:F,onMouseLeave:F,onMouseMove:x=>{G(x),H(x)},children:e.jsxs("g",{transform:`translate(${D.x}, ${D.y}) scale(${b})`,children:[i&&e.jsx("g",{dangerouslySetInnerHTML:{__html:i}}),t==="choropleth"&&B.map(x=>e.jsx("path",{d:x.path,fill:x.color||V(x.value),stroke:"#fff",strokeWidth:1,className:"nice-map-region",onClick:()=>N?.(x),onMouseEnter:P=>Q(x,P),onMouseLeave:q},x.id)),(t==="bubble"||l.length>0)&&l.map(x=>{const P=Math.sqrt((x.value-Z)/(U-Z))*30+5;return e.jsx("circle",{cx:x.lng,cy:x.lat,r:P,fill:x.color||"var(--color-primary, #3b82f6)",fillOpacity:.7,stroke:"#fff",strokeWidth:1,className:"nice-map-bubble",onClick:()=>I?.(x),onMouseEnter:Y=>{const ee=j.current?.getBoundingClientRect();ee&&M&&_({x:Y.clientX-ee.left,y:Y.clientY-ee.top,content:`${x.label||x.id}: ${x.value.toLocaleString()}`})},onMouseLeave:q,children:x.label&&e.jsxs("title",{children:[x.label,": ",x.value]})},x.id)})]})}),y&&e.jsx("div",{className:"nice-map-tooltip",style:{left:y.x+10,top:y.y-30},children:y.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((x,P)=>e.jsx("div",{className:"nice-map-legend-item",style:{backgroundColor:x}},P))}),e.jsxs("div",{className:"nice-map-legend-labels",children:[e.jsx("span",{children:Z.toLocaleString()}),e.jsx("span",{children:U.toLocaleString()})]})]}),e.jsx("style",{children:`
|
|
462
|
+
.nice-map-chart {
|
|
463
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
464
|
+
background: white;
|
|
465
|
+
border-radius: 8px;
|
|
466
|
+
overflow: hidden;
|
|
467
|
+
position: relative;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
.nice-map-title {
|
|
471
|
+
padding: 12px 16px;
|
|
472
|
+
font-size: 16px;
|
|
473
|
+
font-weight: 600;
|
|
474
|
+
color: #111827;
|
|
475
|
+
border-bottom: 1px solid var(--border-color, #e5e7eb);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
.nice-map-svg {
|
|
479
|
+
display: block;
|
|
480
|
+
cursor: grab;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
.nice-map-svg:active {
|
|
484
|
+
cursor: grabbing;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
.nice-map-region {
|
|
488
|
+
cursor: pointer;
|
|
489
|
+
transition: opacity 0.2s, stroke-width 0.2s;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
.nice-map-region:hover {
|
|
493
|
+
opacity: 0.8;
|
|
494
|
+
stroke-width: 2;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
.nice-map-bubble {
|
|
498
|
+
cursor: pointer;
|
|
499
|
+
transition: transform 0.2s, opacity 0.2s;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
.nice-map-bubble:hover {
|
|
503
|
+
opacity: 1;
|
|
504
|
+
transform: scale(1.1);
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
.nice-map-tooltip {
|
|
508
|
+
position: absolute;
|
|
509
|
+
background: #1f2937;
|
|
510
|
+
color: white;
|
|
511
|
+
padding: 6px 10px;
|
|
512
|
+
border-radius: 4px;
|
|
513
|
+
font-size: 12px;
|
|
514
|
+
pointer-events: none;
|
|
515
|
+
z-index: 10;
|
|
516
|
+
white-space: nowrap;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
.nice-map-legend {
|
|
520
|
+
position: absolute;
|
|
521
|
+
right: 16px;
|
|
522
|
+
bottom: 16px;
|
|
523
|
+
background: white;
|
|
524
|
+
padding: 12px;
|
|
525
|
+
border-radius: 6px;
|
|
526
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
.nice-map-legend-title {
|
|
530
|
+
display: block;
|
|
531
|
+
font-size: 11px;
|
|
532
|
+
color: #6b7280;
|
|
533
|
+
margin-bottom: 6px;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
.nice-map-legend-scale {
|
|
537
|
+
display: flex;
|
|
538
|
+
height: 12px;
|
|
539
|
+
border-radius: 2px;
|
|
540
|
+
overflow: hidden;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
.nice-map-legend-item {
|
|
544
|
+
flex: 1;
|
|
545
|
+
min-width: 24px;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
.nice-map-legend-labels {
|
|
549
|
+
display: flex;
|
|
550
|
+
justify-content: space-between;
|
|
551
|
+
font-size: 10px;
|
|
552
|
+
color: #6b7280;
|
|
553
|
+
margin-top: 4px;
|
|
554
|
+
}
|
|
555
|
+
`})]})},ft=({nodes:t,links:c,width:l=800,height:d=500,nodeWidth:s=20,nodePadding:v=10,showValues:m=!0,showTooltip:C=!0,onNodeClick:L,onLinkClick:M,title:p,className:N,style:I,...S})=>{const[w,i]=o.useState(null),h=o.useRef(null),f=o.useMemo(()=>{const g=new Map;t.forEach(n=>g.set(n.id,n));const y=new Set(c.map(n=>n.target)),_=new Set(c.map(n=>n.source)),b=[],u=new Map,D=t.filter(n=>_.has(n.id)&&!y.has(n.id));D.length>0&&(b.push(D.map(n=>n.id)),D.forEach(n=>u.set(n.id,0)));const a=t.filter(n=>_.has(n.id)&&y.has(n.id));a.length>0&&(b.push(a.map(n=>n.id)),a.forEach(n=>u.set(n.id,1)));const j=t.filter(n=>!_.has(n.id)&&y.has(n.id));j.length>0&&(b.push(j.map(n=>n.id)),j.forEach(n=>u.set(n.id,2))),b.length===0&&(b.push(t.map(n=>n.id)),t.forEach(n=>u.set(n.id,0)));const A=new Map;c.forEach(n=>{A.set(n.source,(A.get(n.source)||0)+n.value),A.set(n.target,(A.get(n.target)||0)+n.value)});const O=40,Z=l-O*2,U=d-O*2,V=b.length>1?Z/(b.length-1):Z,G=new Map;Math.max(...Array.from(A.values())),b.forEach((n,F)=>{const H=n.reduce((P,Y)=>P+(A.get(Y)||0),0),B=(U-(n.length-1)*v)/H;let x=O;n.forEach(P=>{const ee=(A.get(P)||0)*B,E=O+F*V;G.set(P,{x:E,y:x,height:ee}),x+=ee+v})});const Q=[],q=new Map,J=new Map;return c.forEach(n=>{const F=G.get(n.source),H=G.get(n.target);if(!F||!H)return;const B=A.get(n.source)||1;A.get(n.target);const x=n.value/B*F.height,P=F.y+(q.get(n.source)||0),Y=H.y+(J.get(n.target)||0);q.set(n.source,(q.get(n.source)||0)+x),J.set(n.target,(J.get(n.target)||0)+x);const ee=F.x+s,E=H.x,te=(E-ee)*.5,ue=`
|
|
556
|
+
M ${ee} ${P}
|
|
557
|
+
C ${ee+te} ${P},
|
|
558
|
+
${E-te} ${Y},
|
|
559
|
+
${E} ${Y}
|
|
560
|
+
L ${E} ${Y+x}
|
|
561
|
+
C ${E-te} ${Y+x},
|
|
562
|
+
${ee+te} ${P+x},
|
|
563
|
+
${ee} ${P+x}
|
|
564
|
+
Z
|
|
565
|
+
`;Q.push({path:ue,link:n,sourcePos:F,targetPos:H})}),{nodePositions:G,linkPaths:Q,nodeMap:g,nodeValues:A}},[t,c,l,d,s,v]),$=o.useCallback((g,y)=>{const _=h.current?.getBoundingClientRect();_&&C&&i({x:y.clientX-_.left,y:y.clientY-_.top,content:g})},[C]);return e.jsxs("div",{className:`nice-sankey-chart ${N||""}`,style:{width:l,...I},...S,children:[p&&e.jsx("div",{className:"nice-sankey-title",children:p}),e.jsxs("svg",{ref:h,width:l,height:d,className:"nice-sankey-svg",children:[e.jsx("defs",{children:f.linkPaths.map((g,y)=>e.jsxs("linearGradient",{id:`sankey-gradient-${y}`,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[e.jsx("stop",{offset:"0%",stopColor:f.nodeMap.get(g.link.source)?.color||"var(--color-primary, #3b82f6)"}),e.jsx("stop",{offset:"100%",stopColor:f.nodeMap.get(g.link.target)?.color||"var(--color-error, #ef4444)"})]},y))}),e.jsx("g",{className:"nice-sankey-links",children:f.linkPaths.map((g,y)=>e.jsx("path",{d:g.path,fill:g.link.color||`url(#sankey-gradient-${y})`,fillOpacity:.4,className:"nice-sankey-link",onClick:()=>M?.(g.link),onMouseEnter:_=>$(`${f.nodeMap.get(g.link.source)?.name} → ${f.nodeMap.get(g.link.target)?.name}: ${g.link.value.toLocaleString()}`,_),onMouseLeave:()=>i(null)},y))}),e.jsx("g",{className:"nice-sankey-nodes",children:Array.from(f.nodePositions.entries()).map(([g,y])=>{const _=f.nodeMap.get(g);return _?e.jsxs("g",{children:[e.jsx("rect",{x:y.x,y:y.y,width:s,height:y.height,fill:_.color||"var(--color-primary, #3b82f6)",rx:2,className:"nice-sankey-node",onClick:()=>L?.(_),onMouseEnter:b=>$(`${_.label??_.name??_.id}: ${f.nodeValues.get(g)?.toLocaleString()||0}`,b),onMouseLeave:()=>i(null)}),e.jsxs("text",{x:y.x+s+6,y:y.y+y.height/2,dominantBaseline:"middle",fontSize:"12",fill:"#374151",children:[_.label??_.name??_.id,m&&` (${f.nodeValues.get(g)?.toLocaleString()||0})`]})]},g):null})})]}),w&&e.jsx("div",{className:"nice-sankey-tooltip",style:{left:w.x+10,top:w.y-30},children:w.content}),e.jsx("style",{children:`
|
|
566
|
+
.nice-sankey-chart {
|
|
567
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
568
|
+
background: white;
|
|
569
|
+
border-radius: 8px;
|
|
570
|
+
position: relative;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
.nice-sankey-title {
|
|
574
|
+
padding: 12px 16px;
|
|
575
|
+
font-size: 16px;
|
|
576
|
+
font-weight: 600;
|
|
577
|
+
color: #111827;
|
|
578
|
+
border-bottom: 1px solid var(--border-color, #e5e7eb);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
.nice-sankey-link {
|
|
582
|
+
cursor: pointer;
|
|
583
|
+
transition: fill-opacity 0.2s;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
.nice-sankey-link:hover {
|
|
587
|
+
fill-opacity: 0.7;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
.nice-sankey-node {
|
|
591
|
+
cursor: pointer;
|
|
592
|
+
transition: opacity 0.2s;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
.nice-sankey-node:hover {
|
|
596
|
+
opacity: 0.8;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
.nice-sankey-tooltip {
|
|
600
|
+
position: absolute;
|
|
601
|
+
background: #1f2937;
|
|
602
|
+
color: white;
|
|
603
|
+
padding: 6px 10px;
|
|
604
|
+
border-radius: 4px;
|
|
605
|
+
font-size: 12px;
|
|
606
|
+
pointer-events: none;
|
|
607
|
+
z-index: 10;
|
|
608
|
+
white-space: nowrap;
|
|
609
|
+
}
|
|
610
|
+
`})]})},Ee=o.forwardRef((t,c)=>{const{initialData:l,data:d,maxPoints:s=60,updateInterval:v=1e3,fetchData:m,width:C=600,height:L=200,chartType:M="line",color:p="var(--color-primary, #3b82f6)",showGrid:N=!0,showTimeAxis:I=!0,showCurrentValue:S=!0,title:w,valueFormatter:i=z=>z.toFixed(2),timeFormatter:h=z=>new Date(z).toLocaleTimeString(),onDataUpdate:f,paused:$,className:g,style:y,..._}=t,[b,u]=o.useState(l??d??[]),[D,a]=o.useState($||!1),j=o.useRef();o.useEffect(()=>{$!==void 0&&a($)},[$]),o.useEffect(()=>{if(D||!m)return;const z=async()=>{try{const X=await m();u(ne=>{const de=[...ne,X].slice(-s);return f?.(de),de})}catch(X){console.error("Failed to fetch realtime data:",X)}};return j.current=setInterval(z,v),()=>{j.current&&clearInterval(j.current)}},[D,m,v,s,f]);const A=o.useCallback(z=>{u(X=>{const ne=[...X,z].slice(-s);return f?.(ne),ne})},[s,f]),O=o.useCallback(()=>{u([]),f?.([])},[f]),Z=o.useCallback(()=>a(!0),[]),U=o.useCallback(()=>a(!1),[]);o.useImperativeHandle(c,()=>({addDataPoint:A,clearData:O,pause:Z,resume:U,getData:()=>b}),[A,O,b]);const V={top:20,right:60,bottom:I?40:20,left:50},G=C-V.left-V.right,Q=L-V.top-V.bottom,q=b.map(z=>z.value),J=q.length?Math.min(...q):0,n=q.length?Math.max(...q):100,H=(n-J||1)*.1,B=J-H,P=n+H-B,Y=z=>{const X=m?s-1:Math.max(1,b.length-1);return V.left+z/X*G},ee=z=>V.top+Q-(z-B)/P*Q,E=b.map((z,X)=>`${Y(X)},${ee(z.value)}`).join(" "),te=b.length>0?`M ${Y(0)},${V.top+Q} L ${E} L ${Y(b.length-1)},${V.top+Q} Z`:"",ue=b.length>0?b[b.length-1].value:null;return e.jsxs("div",{className:`nice-realtime-chart ${g||""}`,style:{width:C,...y},..._,children:[w&&e.jsxs("div",{className:"nice-realtime-header",children:[e.jsx("span",{className:"nice-realtime-title",children:w}),e.jsxs("div",{className:"nice-realtime-controls",children:[e.jsx("button",{className:`nice-realtime-btn ${D?"paused":""}`,onClick:()=>a(!D),children:D?"▶️":"⏸️"}),S&&ue!==null&&e.jsx("span",{className:"nice-realtime-value",children:i(ue)})]})]}),e.jsxs("svg",{width:C,height:L,className:"nice-realtime-svg",children:[N&&e.jsx("g",{className:"nice-realtime-grid",children:[0,.25,.5,.75,1].map((z,X)=>{const ne=V.top+Q*(1-z),de=B+P*z;return e.jsxs("g",{children:[e.jsx("line",{x1:V.left,y1:ne,x2:C-V.right,y2:ne,stroke:"#e5e7eb",strokeDasharray:z===0?void 0:"3"}),e.jsx("text",{x:V.left-8,y:ne,textAnchor:"end",dominantBaseline:"middle",fontSize:"10",fill:"#6b7280",children:i(de)})]},X)})}),M==="area"&&b.length>0&&e.jsx("path",{d:te,fill:p,fillOpacity:.2}),b.length>1&&e.jsx("polyline",{points:E,fill:"none",stroke:p,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),b.length>0&&e.jsx("circle",{cx:Y(b.length-1),cy:ee(b[b.length-1].value),r:4,fill:p,className:"nice-realtime-point"}),I&&b.length>0&&e.jsx("g",{className:"nice-realtime-time-axis",children:[0,Math.floor(b.length/2),b.length-1].filter(z=>b[z]).map(z=>e.jsx("text",{x:Y(z),y:L-8,textAnchor:"middle",fontSize:"10",fill:"#6b7280",children:h(b[z].timestamp)},z))})]}),e.jsxs("div",{className:`nice-realtime-status ${D?"paused":"live"}`,children:[e.jsx("span",{className:"nice-realtime-status-dot"}),e.jsx("span",{children:D?"Wstrzymano":"Na żywo"})]}),e.jsx("style",{children:`
|
|
611
|
+
.nice-realtime-chart {
|
|
612
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
613
|
+
background: white;
|
|
614
|
+
border-radius: 8px;
|
|
615
|
+
position: relative;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
.nice-realtime-header {
|
|
619
|
+
display: flex;
|
|
620
|
+
justify-content: space-between;
|
|
621
|
+
align-items: center;
|
|
622
|
+
padding: 12px 16px;
|
|
623
|
+
border-bottom: 1px solid var(--border-color, #e5e7eb);
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
.nice-realtime-title {
|
|
627
|
+
font-size: 14px;
|
|
628
|
+
font-weight: 600;
|
|
629
|
+
color: #111827;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
.nice-realtime-controls {
|
|
633
|
+
display: flex;
|
|
634
|
+
align-items: center;
|
|
635
|
+
gap: 12px;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
.nice-realtime-btn {
|
|
639
|
+
background: none;
|
|
640
|
+
border: none;
|
|
641
|
+
cursor: pointer;
|
|
642
|
+
font-size: 16px;
|
|
643
|
+
padding: 4px;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
.nice-realtime-value {
|
|
647
|
+
font-size: 18px;
|
|
648
|
+
font-weight: 600;
|
|
649
|
+
color: ${p};
|
|
650
|
+
font-variant-numeric: tabular-nums;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
.nice-realtime-point {
|
|
654
|
+
animation: realtime-pulse 1s ease-out infinite;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
@keyframes realtime-pulse {
|
|
658
|
+
0% { opacity: 1; transform: scale(1); }
|
|
659
|
+
50% { opacity: 0.5; transform: scale(1.5); }
|
|
660
|
+
100% { opacity: 1; transform: scale(1); }
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
.nice-realtime-status {
|
|
664
|
+
position: absolute;
|
|
665
|
+
bottom: 8px;
|
|
666
|
+
right: 8px;
|
|
667
|
+
display: flex;
|
|
668
|
+
align-items: center;
|
|
669
|
+
gap: 6px;
|
|
670
|
+
font-size: 11px;
|
|
671
|
+
color: #6b7280;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
.nice-realtime-status-dot {
|
|
675
|
+
width: 8px;
|
|
676
|
+
height: 8px;
|
|
677
|
+
border-radius: 50%;
|
|
678
|
+
background: #22c55e;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
.nice-realtime-status.paused .nice-realtime-status-dot {
|
|
682
|
+
background: #f59e0b;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
.nice-realtime-status.live .nice-realtime-status-dot {
|
|
686
|
+
animation: live-pulse 2s ease-in-out infinite;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
@keyframes live-pulse {
|
|
690
|
+
0%, 100% { opacity: 1; }
|
|
691
|
+
50% { opacity: 0.4; }
|
|
692
|
+
}
|
|
693
|
+
`})]})});Ee.displayName="NiceRealtimeChart";const xt=({data:t,width:c=600,height:l=400,showLabels:d=!0,showValues:s=!0,onNodeClick:v,drilldownEnabled:m=!0,colors:C=Be,tilePadding:L=2,className:M,style:p,...N})=>{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,w]=o.useState(I),[i,h]=o.useState([I.name]),[f,$]=o.useState(null),g=o.useRef(null),y=o.useMemo(()=>{const j=S.children||[];if(j.length===0)return[];const A=j.reduce((J,n)=>J+n.value,0),O=j.map(J=>({node:J,area:J.value/A*c*l}));O.sort((J,n)=>n.area-J.area);const Z=[];let U=0,V=0,G=c,Q=l,q=0;for(;q<O.length;){const J=G<Q;let n=0,F=[];const H=J?Q:G;for(let P=q;P<O.length;P++){const Y=[...F,O[P]],ee=Y.reduce((te,ue)=>te+ue.area,0),E=_(Y,ee,H);if(F.length===0)F=Y,n=ee;else{const te=_(F,n,H);if(E<=te)F=Y,n=ee;else break}}const B=n/H;let x=0;F.forEach((P,Y)=>{const ee=P.area/B;Z.push({node:P.node,x:J?U:U+x,y:J?V+x:V,w:J?B:ee,h:J?ee:B,color:P.node.color||C[(q+Y)%C.length]}),x+=ee}),J?(U+=B,G-=B):(V+=B,Q-=B),q+=F.length}return Z},[S,c,l,C]);function _(a,j,A){const O=j/A;let Z=0;for(const U of a){const V=U.area/O,G=Math.max(O/V,V/O);Z=Math.max(Z,G)}return Z}const b=a=>{v?.(a,[...i,a.name]),m&&a.children&&a.children.length>0&&(w(a),h(j=>[...j,a.name]))},u=()=>{if(i.length<=1)return;let a=I;const j=i.slice(0,-1);for(let A=1;A<j.length;A++){const O=a.children?.find(Z=>Z.name===j[A]);O&&(a=O)}w(a),h(j)},D=(a,j)=>{const A=g.current?.getBoundingClientRect();A&&$({x:j.clientX-A.left,y:j.clientY-A.top,content:a})};return e.jsxs("div",{className:`nice-treemap-chart ${M||""}`,style:{width:c,...p},...N,children:[e.jsxs("div",{className:"nice-treemap-nav",children:[i.length>1&&e.jsx("button",{className:"nice-treemap-back",onClick:u,children:"← Wstecz"}),e.jsx("div",{className:"nice-treemap-breadcrumbs",children:i.map((a,j)=>e.jsxs(o.Fragment,{children:[j>0&&e.jsx("span",{className:"nice-treemap-sep",children:"/"}),e.jsx("span",{className:j===i.length-1?"current":"",children:a})]},j))})]}),e.jsx("svg",{ref:g,width:c,height:l,className:"nice-treemap-svg",children:y.map((a,j)=>{const{node:A,x:O,y:Z,w:U,h:V,color:G}=a,Q=Math.min(14,Math.max(10,Math.min(U,V)/6)),q=U>40&&V>30;return e.jsxs("g",{onClick:()=>b(A),onMouseEnter:J=>D(`${A.name}: ${A.value.toLocaleString()}`,J),onMouseLeave:()=>$(null),children:[e.jsx("rect",{x:O+L/2,y:Z+L/2,width:Math.max(0,U-L),height:Math.max(0,V-L),fill:G,rx:4,className:"nice-treemap-tile"}),d&&q&&e.jsx("text",{x:O+U/2,y:Z+V/2-(s?6:0),textAnchor:"middle",dominantBaseline:"middle",fontSize:Q,fill:"white",fontWeight:"500",style:{pointerEvents:"none"},children:A.name.length>U/Q+2?A.name.slice(0,Math.floor(U/Q))+"...":A.name}),s&&q&&e.jsx("text",{x:O+U/2,y:Z+V/2+10,textAnchor:"middle",dominantBaseline:"middle",fontSize:Q-2,fill:"rgba(255,255,255,0.8)",style:{pointerEvents:"none"},children:A.value.toLocaleString()})]},j)})}),f&&e.jsx("div",{className:"nice-treemap-tooltip",style:{left:f.x+10,top:f.y-30},children:f.content}),e.jsx("style",{children:`
|
|
694
|
+
.nice-treemap-chart {
|
|
695
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
696
|
+
background: white;
|
|
697
|
+
border-radius: 8px;
|
|
698
|
+
position: relative;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
.nice-treemap-nav {
|
|
702
|
+
display: flex;
|
|
703
|
+
align-items: center;
|
|
704
|
+
gap: 12px;
|
|
705
|
+
padding: 12px 16px;
|
|
706
|
+
border-bottom: 1px solid var(--border-color, #e5e7eb);
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
.nice-treemap-back {
|
|
710
|
+
background: #f3f4f6;
|
|
711
|
+
border: none;
|
|
712
|
+
padding: 6px 12px;
|
|
713
|
+
border-radius: 6px;
|
|
714
|
+
cursor: pointer;
|
|
715
|
+
font-size: 13px;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
.nice-treemap-back:hover {
|
|
719
|
+
background: #e5e7eb;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
.nice-treemap-breadcrumbs {
|
|
723
|
+
display: flex;
|
|
724
|
+
align-items: center;
|
|
725
|
+
gap: 4px;
|
|
726
|
+
font-size: 13px;
|
|
727
|
+
color: #6b7280;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
.nice-treemap-breadcrumbs .current {
|
|
731
|
+
color: #111827;
|
|
732
|
+
font-weight: 500;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
.nice-treemap-sep {
|
|
736
|
+
color: #9ca3af;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
.nice-treemap-tile {
|
|
740
|
+
cursor: pointer;
|
|
741
|
+
transition: opacity 0.2s, transform 0.1s;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
.nice-treemap-tile:hover {
|
|
745
|
+
opacity: 0.85;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
.nice-treemap-tooltip {
|
|
749
|
+
position: absolute;
|
|
750
|
+
background: #1f2937;
|
|
751
|
+
color: white;
|
|
752
|
+
padding: 6px 10px;
|
|
753
|
+
border-radius: 4px;
|
|
754
|
+
font-size: 12px;
|
|
755
|
+
pointer-events: none;
|
|
756
|
+
z-index: 10;
|
|
757
|
+
white-space: nowrap;
|
|
758
|
+
}
|
|
759
|
+
`})]})},Oe=o.forwardRef(({data:t,renderNode:c,selectable:l,selectedKey:d,onSelect:s,direction:v="top-down",collapsible:m=!0,className:C,style:L,id:M},p)=>{const N=Me.cs(M),[I,S]=o.useState(new Set),w=o.useCallback(f=>{S($=>{const g=new Set($);return g.has(f)?g.delete(f):g.add(f),g})},[]),i=o.useCallback(f=>{l&&s?.(f)},[l,s]),h=o.useCallback(f=>{const $=I.has(f.key),g=f.children&&f.children.length>0;return e.jsxs("li",{className:"nice-org-chart__item",children:[e.jsxs("div",{className:`nice-org-chart__node${d===f.key?" nice-org-chart__node--selected":""}`,onClick:()=>i(f.key),role:l?"button":void 0,children:[c?c(f):e.jsx("span",{children:f.label}),m&&g&&e.jsx("button",{type:"button",className:"nice-org-chart__toggle",onClick:y=>{y.stopPropagation(),w(f.key)},"aria-label":$?"Expand":"Collapse",children:$?"+":"−"})]}),g&&!$&&e.jsx("ul",{className:"nice-org-chart__children",children:f.children.map(y=>h(y))})]},f.key)},[I,d,c,l,m,i,w]);return e.jsx("div",{ref:p,id:N,className:`nice-org-chart nice-org-chart--${v} ${C||""}`,style:L,children:e.jsx("ul",{className:"nice-org-chart__root",children:h(t)})})});Oe.displayName="NiceOrganizationChart";function mt(t,c,l){const d=S=>{const w=S.replace("#","");return[parseInt(w.slice(0,2),16),parseInt(w.slice(2,4),16),parseInt(w.slice(4,6),16)]},[s,v,m]=d(t),[C,L,M]=d(c),p=Math.round(s+(C-s)*l),N=Math.round(v+(L-v)*l),I=Math.round(m+(M-m)*l);return`rgb(${p},${N},${I})`}const Pe=o.forwardRef(({data:t,xLabels:c,yLabels:l,colors:d=["#e0f2fe","var(--color-primary-active, #1d4ed8)"],onCellClick:s,cellSize:v=40,showValues:m=!0,className:C,style:L,id:M},p)=>{const N=Me.cs(M),{minVal:I,maxVal:S}=o.useMemo(()=>{let i=1/0,h=-1/0;for(const f of t)for(const $ of f)$<i&&(i=$),$>h&&(h=$);return{minVal:i,maxVal:h}},[t]),w=o.useCallback(i=>S===I?.5:(i-I)/(S-I),[I,S]);return e.jsx("div",{ref:p,id:N,className:`nice-heatmap ${C||""}`,style:L,children:e.jsxs("table",{className:"nice-heatmap__table",children:[c&&e.jsx("thead",{children:e.jsxs("tr",{children:[l&&e.jsx("th",{}),c.map((i,h)=>e.jsx("th",{className:"nice-heatmap__header",children:i},h))]})}),e.jsx("tbody",{children:t.map((i,h)=>e.jsxs("tr",{children:[l&&e.jsx("th",{className:"nice-heatmap__row-label",children:l[h]}),i.map((f,$)=>e.jsx("td",{className:"nice-heatmap__cell",style:{background:mt(d[0],d[1],w(f)),width:v,height:v,textAlign:"center",color:w(f)>.6?"var(--bg-primary, #fff)":"var(--bg-tertiary, #333)",cursor:s?"pointer":void 0},onClick:()=>s?.(h,$,f),title:String(f),children:m?f:""},$))]},h))})]})})});Pe.displayName="NiceHeatMap";function pt(t,c){const l=t.reduce((M,p)=>M+p.value,0);if(l===0||t.length===0)return[];const d=[];let{x:s,y:v,w:m,h:C}=c;const L=[...t].sort((M,p)=>p.value-M.value);for(const M of L){const p=M.value/l;if(m>=C){const N=m*p;d.push({x:s,y:v,w:N,h:C,node:M}),s+=N,m-=N}else{const N=C*p;d.push({x:s,y:v,w:m,h:N,node:M}),v+=N,C-=N}}return d}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)","#84cc16"],Ae=o.forwardRef(({data:t,width:c=600,height:l=400,onNodeClick:d,colors:s=gt,className:v,style:m,id:C},L)=>{const M=Me.cs(C),p=o.useMemo(()=>{const N=t.children??[t];return pt(N,{x:0,y:0,w:c,h:l})},[t,c,l]);return e.jsx("div",{ref:L,id:M,className:`nice-treemap ${v||""}`,style:m,children:e.jsx("svg",{width:c,height:l,className:"nice-treemap__svg",children:p.map((N,I)=>e.jsxs("g",{onClick:()=>d?.(N.node),style:{cursor:d?"pointer":void 0},children:[e.jsx("rect",{x:N.x,y:N.y,width:Math.max(N.w-1,0),height:Math.max(N.h-1,0),fill:N.node.color??s[I%s.length],rx:2}),N.w>40&&N.h>20&&e.jsx("text",{x:N.x+N.w/2,y:N.y+N.h/2,textAnchor:"middle",dominantBaseline:"central",fill:"#fff",fontSize:Math.min(12,N.w/6),className:"nice-treemap__label",children:N.node.label})]},N.node.key))})})});Ae.displayName="NiceTreeMap";const yt=Object.freeze(Object.defineProperty({__proto__:null,NiceTreeMap:Ae},Symbol.toStringTag,{value:"Module"})),Ye=o.forwardRef(({data:t,type:c="candlestick",showVolume:l=!0,width:d=800,height:s=400,bullColor:v="var(--color-success, #22c55e)",bearColor:m="var(--color-error, #ef4444)",className:C,style:L,id:M},p)=>{const N=Me.cs(M),I={top:20,right:20,bottom:l?80:30,left:60},S=d-I.left-I.right,w=l?50:0,i=s-I.top-I.bottom-w,{minP:h,maxP:f,maxVol:$}=o.useMemo(()=>{let u=1/0,D=-1/0,a=0;for(const j of t)j.low<u&&(u=j.low),j.high>D&&(D=j.high),j.volume&&j.volume>a&&(a=j.volume);return{minP:u,maxP:D,maxVol:a}},[t]),g=Math.max(1,S/t.length*.7),y=u=>I.left+(u+.5)*(S/t.length),_=u=>I.top+i-(u-h)/(f-h||1)*i,b=u=>s-I.bottom-w+w*(1-u/($||1));return e.jsx("div",{ref:p,id:N,className:`nice-stock-chart ${C||""}`,style:L,children:e.jsxs("svg",{width:d,height:s,className:"nice-stock-chart__svg",children:[[0,.25,.5,.75,1].map(u=>{const D=h+u*(f-h);return e.jsxs("g",{children:[e.jsx("line",{x1:I.left,x2:d-I.right,y1:_(D),y2:_(D),stroke:"#e5e7eb",strokeDasharray:"2,2"}),e.jsx("text",{x:I.left-4,y:_(D)+4,textAnchor:"end",fontSize:10,fill:"#888",children:D.toFixed(2)})]},u)}),c==="line"?e.jsx("polyline",{points:t.map((u,D)=>`${y(D)},${_(u.close)}`).join(" "),fill:"none",stroke:v,strokeWidth:1.5}):t.map((u,D)=>{const a=u.close>=u.open,j=a?v:m,A=y(D);if(c==="ohlc")return e.jsxs("g",{children:[e.jsx("line",{x1:A,x2:A,y1:_(u.high),y2:_(u.low),stroke:j,strokeWidth:1}),e.jsx("line",{x1:A-g/2,x2:A,y1:_(u.open),y2:_(u.open),stroke:j,strokeWidth:1.5}),e.jsx("line",{x1:A,x2:A+g/2,y1:_(u.close),y2:_(u.close),stroke:j,strokeWidth:1.5})]},D);const O=_(Math.max(u.open,u.close)),Z=_(Math.min(u.open,u.close));return e.jsxs("g",{children:[e.jsx("line",{x1:A,x2:A,y1:_(u.high),y2:_(u.low),stroke:j,strokeWidth:1}),e.jsx("rect",{x:A-g/2,y:O,width:g,height:Math.max(Z-O,1),fill:a?"transparent":j,stroke:j,strokeWidth:1})]},D)}),l&&t.map((u,D)=>{if(!u.volume)return null;const a=u.close>=u.open;return e.jsx("rect",{x:y(D)-g/2,y:b(u.volume),width:g,height:s-I.bottom-b(u.volume),fill:a?v:m,opacity:.3},`v${D}`)}),t.map((u,D)=>D%Math.max(1,Math.floor(t.length/8))!==0?null:e.jsx("text",{x:y(D),y:s-I.bottom+w+14,textAnchor:"middle",fontSize:9,fill:"#888",children:u.date},`l${D}`))]})})});Ye.displayName="NiceStockChart";exports.CHART_COLORS=me;exports.NiceBarGauge=nt;exports.NiceBullet=st;exports.NiceChart=ke;exports.NiceChart$1=Fe;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=ft;exports.NiceSparkline=rt;exports.NiceStockChart=Ye;exports.NiceTreeMap=Ae;exports.NiceTreeMap$1=yt;exports.NiceTreeMapChart=xt;exports.NiceVectorMap=Te;exports.NiceVectorMap$1=lt;exports.createMockLiveChartSource=Je;exports.createSignalRLiveChartSource=Ge;exports.createWebSocketLiveChartSource=qe;
|