@nice2dev/ui 1.0.11 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/README.md +61 -0
- package/css/legacy-bg-text-aliases.css +83 -0
- package/dist/NiceErrorBoundary-BLTq8mPU.cjs +1 -0
- package/dist/NiceErrorBoundary-Bjw5U31n.js +762 -0
- package/dist/NiceErrorBoundary-DT5XPTeu.cjs +1 -0
- package/dist/NiceErrorBoundary-SqPtbIxK.js +762 -0
- package/dist/NiceForm-CI_vgkD4.cjs +382 -0
- package/dist/NiceForm-CUlhtlHw.js +5357 -0
- package/dist/NiceForm-DTgIGX88.cjs +382 -0
- package/dist/NiceForm-t9zdH8kU.js +5343 -0
- package/dist/NiceForm.css +1 -1
- package/dist/NiceModal-C_t2qqZd.js +95 -0
- package/dist/NiceModal-DQ7u-xVm.cjs +1 -0
- package/dist/NiceModal-FQqBxCij.cjs +1 -0
- package/dist/NiceModal-IkSunDgK.js +95 -0
- package/dist/NiceModuleLifecyclePanel-CCFHxKIu.js +6343 -0
- package/dist/NiceModuleLifecyclePanel-Cj4x54sw.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-D-xBAp1_.js +5228 -0
- package/dist/NiceModuleLifecyclePanel-D8cIOI8I.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel.css +1 -1
- package/dist/NicePagination-BVkkePJU.js +171 -0
- package/dist/NicePagination-DDFkSRr9.js +171 -0
- package/dist/NicePagination-DGHtXqy1.cjs +1 -0
- package/dist/NicePagination-DGd3Hrh9.cjs +1 -0
- package/dist/NicePinCodeInput-BhIABBTV.cjs +419 -0
- package/dist/NicePinCodeInput-CDtodnIM.js +11875 -0
- package/dist/NicePinCodeInput-DytLfqZL.cjs +419 -0
- package/dist/NicePinCodeInput-jMNfPqOx.js +11866 -0
- package/dist/NicePinCodeInput.css +1 -1
- package/dist/NiceSavedQueryPanel-BkYRk5cX.js +6441 -0
- package/dist/NiceSavedQueryPanel-CbR3EDQU.cjs +596 -0
- package/dist/NiceSavedQueryPanel-CmFSi21-.cjs +596 -0
- package/dist/NiceSavedQueryPanel-DJqCNWYZ.js +6446 -0
- package/dist/NiceSavedQueryPanel.css +1 -1
- package/dist/NiceTabs-B-9_mzpc.js +1624 -0
- package/dist/NiceTabs-C4H5un8J.cjs +1 -0
- package/dist/NiceTabs-CHg36waF.cjs +1 -0
- package/dist/NiceTabs-DlsCMth_.js +1622 -0
- package/dist/NiceWindow-BNrA5Dxq.js +1409 -0
- package/dist/NiceWindow-BxGVzUs2.js +1409 -0
- package/dist/NiceWindow-CbzJmurQ.cjs +1 -0
- package/dist/NiceWindow-HhPIzPzs.cjs +1 -0
- package/dist/charts-F_b5-OR8.js +4621 -0
- package/dist/charts-Us8Ep8MJ.cjs +761 -0
- package/dist/charts-e10jGjuF.cjs +759 -0
- package/dist/charts-fO6InNZd.js +4645 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.css +1 -1
- package/dist/charts.mjs +1 -1
- package/dist/core-B-tu8l9M.cjs +96 -0
- package/dist/core-BJ_UNMlX.js +22276 -0
- package/dist/core-CSfXTICE.cjs +96 -0
- package/dist/core-ClmvtMVZ.js +22253 -0
- package/dist/data-branching-B_9C6-hE.cjs +1 -0
- package/dist/data-branching-BmCKIXgr.js +6121 -0
- package/dist/data-branching.cjs +1 -1
- package/dist/data-branching.mjs +1 -1
- package/dist/data.cjs +1 -1
- package/dist/data.d.ts +9 -2
- package/dist/data.mjs +1 -1
- package/dist/devops-BL39OCVh.js +7660 -0
- package/dist/devops-CkuTC7RJ.cjs +17 -0
- package/dist/devops.cjs +1 -1
- package/dist/devops.mjs +1 -1
- package/dist/editors.cjs +1 -1
- package/dist/editors.d.ts +92 -6
- package/dist/editors.mjs +3 -3
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.mjs +2 -2
- package/dist/index-BU6KCDpP.js +57872 -0
- package/dist/index-D7i7sZGV.cjs +5194 -0
- package/dist/index-DHc_KZkF.js +61311 -0
- package/dist/index-drIVMHeC.cjs +5194 -0
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1607 -102
- package/dist/index.mjs +894 -867
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.mjs +24 -24
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.d.ts +309 -70
- package/dist/navigation.mjs +94 -93
- package/dist/no-code-Bb3QFKdm.cjs +332 -0
- package/dist/no-code-snLY0d6I.js +7065 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.mjs +1 -1
- package/dist/overlays.cjs +1 -1
- package/dist/overlays.mjs +33 -33
- package/dist/style.css +7 -0
- package/dist/vendor-DF586kuF.js +271 -0
- package/dist/vendor-DHEorsoy.cjs +1 -0
- package/package.json +10 -5
|
@@ -0,0 +1,759 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),o=require("react"),we=require("./core-CSfXTICE.cjs"),_e=["var(--color-primary, #3b82f6)","var(--color-error, #ef4444)","var(--color-success, #22c55e)","var(--color-warning, #f59e0b)","var(--color-accent, #8b5cf6)","var(--color-accent-pink, #ec4899)","var(--color-info, #06b6d4)","var(--nice-success, #84cc16)"],ke=({series:t,categories:c,width:l=600,height:d=400,title:s,showLegend:b=!0,showGrid:p=!0,axisLabels:C=!0,yAxisLabel:L,xAxisLabel:w,stacked:f,animated:N,zoomable:I,crosshair:S,annotations:M,legendInteractive:i,onDataPointClick:h,exportable:x,className:$,style:g})=>{const v=o.useRef(null),[_,y]=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&&y(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:w?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,H=a?.end??J,Y=H-n,B=o.useMemo(()=>U.map(R=>({...R,data:R.data.slice(n,H)})),[U,n,H]),m=o.useMemo(()=>c?.slice(n,H),[c,n,H]),{minY:P,maxY:F,yTicks:ee}=o.useMemo(()=>{let R;if(f){R=[];for(let k=0;k<Y;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,Y,f]),E=R=>q-(R-P)/(F-P||1)*q,te=R=>(R+.5)/Y*Q,ue=Y>0?Q/Y/(f?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=v.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/Y,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,Y,J,G.left,G.top]),de=o.useCallback(()=>{O(!1),Z.current=null},[]),ge=o.useCallback(()=>{D(null),O(!1),Z.current=null},[]),xe=o.useCallback(()=>{const R=v.current;if(!R)return;const re=new XMLSerializer().serializeToString(R),ae=document.createElement("canvas");ae.width=l,ae.height=d+(b?30:0);const ce=ae.getContext("2d");if(!ce)return;const ie=new Image;ie.onload=()=>{ce.fillStyle="var(--bg-primary, #fff)",ce.fillRect(0,0,ae.width,ae.height),ce.drawImage(ie,0,0);const r=document.createElement("a");r.download="chart.png",r.href=ae.toDataURL("image/png"),r.click()},ie.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(re)},[l,d,b]),fe=d+(b?30:0),ye=B.length>0&&B.every(R=>R.type==="radar"),je=o.useMemo(()=>{if(!ye)return 1;const R=B.flatMap(re=>re.data);return Math.max(1,...R)},[ye,B]);if(ye){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=m?.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:v,viewBox:`0 0 ${l} ${fe}`,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}),p&&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&&m?.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[ve,be]=r(le,oe);return e.jsx("circle",{cx:ve,cy:be,r:3,fill:K,children:e.jsx("title",{children:`${W.name}: ${oe}`})},le)})]},W.name)}),b&&e.jsx("g",{transform:`translate(${G.left}, ${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:[x&&e.jsx("button",{type:"button",className:"nice-chart__export-btn",onClick:xe,title:"Export PNG",children:"📷"}),e.jsxs("svg",{ref:v,viewBox:`0 0 ${l} ${fe}`,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}),p&&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&&m&&m.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}),w&&e.jsx("text",{x:Q/2,y:q+45,textAnchor:"middle",className:"nice-chart__axis-title",children:w}),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"}),M?.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:"var(--nice-text-muted, #9ca3af)",strokeWidth:1,strokeDasharray:"4,2"}),e.jsx("line",{x1:0,y1:u.y,x2:Q,y2:u.y,stroke:"var(--nice-text-muted, #9ca3af)",strokeWidth:1,strokeDasharray:"4,2"})]}),B.map((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(f){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=f?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(Y-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)})]}),b&&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)})})]})]})},He=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[p,C]of Object.entries(c))typeof C=="number"?(l.push(p),d[p]=t.map(L=>Number(L[p])||0)):!s&&(typeof C=="string"||C instanceof Date)&&(s=p);return{categories:s?t.map(p=>String(p[s]||"")):t.map((p,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((p,C)=>({name:p.replace(/([A-Z])/g," $1").replace(/^./,L=>L.toUpperCase()).trim(),data:s[p],type:c==="area"?"area":c==="line"?"line":"bar"})),categories:l}}const Ze=o.forwardRef(function(c,l){const{rawData:d,enableAI:s=!0,aiModel:b,enableAutoType:p=!0,enableInsights:C=!0,dataDescription:L,onChartSuggestion:w,onInsights:f,showAIToolbar:N=!0,showInsightsOnLoad:I=!1,series:S,categories:M,...i}=c,[h,x]=o.useState("bar"),[$,g]=o.useState(null),[v,_]=o.useState([]),[y,u]=o.useState(I),[D,a]=o.useState(null),{t:j}=we.$o(),A=we.ie(),{suggestChartType:O,generateInsights:Z,isLoading:U}=we.wl(),V=s&&A.isConfigured,{series:G,categories:Q}=d?Xe(d,D||h):{series:S||[],categories:M},q=o.useCallback(async()=>{if(!V||!p)return{type:"bar",reason:"Default",config:{}};const B=d||(S?.length?S.flatMap(m=>m.data.map((P,F)=>({[m.name]:P,index:F}))):[]);try{const m=await O(B,L),P={type:m.type,reason:m.reason,config:m.config};return g(P),x(P.type),w?.(P),P}catch{return{type:"bar",reason:"Default fallback",config:{}}}},[V,p,d,S,L,O,w]),J=o.useCallback(async()=>{if(!V||!C)return[];const B=d||(S?.length?S.flatMap(m=>m.data.map((P,F)=>({[m.name]:P,category:M?.[F]||F}))):[]);try{const m=await Z(B,D||h);return _(m),f?.(m),m}catch{return[]}},[V,C,d,S,M,h,D,Z,f]),n=o.useCallback(()=>D||h,[D,h]);o.useEffect(()=>{V&&p&&(d?.length||S?.length)&&q()},[V,p,d,S]),o.useImperativeHandle(l,()=>({getSuggestion:q,generateInsights:J,getCurrentType:n}));const H=[{type:"bar",icon:"📊",label:"Bar"},{type:"line",icon:"📈",label:"Line"},{type:"area",icon:"🏔️",label:"Area"},{type:"pie",icon:"🥧",label:"Pie"},{type:"donut",icon:"🍩",label:"Donut"},{type:"scatter",icon:"⭐",label:"Scatter"}],Y=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:H.filter(B=>["bar","line","area"].includes(B.type)).map(({type:B,icon:m,label:P})=>e.jsx("button",{type:"button",className:`nice-chart-ai__type-btn ${Y===B?"nice-chart-ai__type-btn--active":""}`,onClick:()=>a(B),title:P,children:m},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:()=>{v.length||J(),u(!y)},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})}),y&&v.length>0&&e.jsxs("div",{className:"nice-chart-ai__insights",children:[e.jsxs("div",{className:"nice-chart-ai__insights-header",children:[e.jsxs("h4",{children:["💡 ",j("chartAI.dataInsights","Data Insights")]}),e.jsx("button",{type:"button",className:"nice-chart-ai__insights-close",onClick:()=>u(!1),children:"✕"})]}),e.jsx("ul",{className:"nice-chart-ai__insights-list",children:v.map((B,m)=>e.jsxs("li",{className:"nice-chart-ai__insight",children:[e.jsx("span",{className:"nice-chart-ai__insight-icon",children:"•"}),B]},m))}),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")]})})]}),y&&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()),b=d(l.getMinutes()),p=d(l.getSeconds()),C=l.getMilliseconds().toString().padStart(3,"0");switch(c){case"HH:mm:ss":return`${s}:${b}:${p}`;case"HH:mm":return`${s}:${b}`;case"mm:ss":return`${b}:${p}`;case"ss.SSS":return`${p}.${C}`;case"ISO":return l.toISOString();default:return`${s}:${b}:${p}`}}function Ie(t){if(t.length===0)return null;const c=Math.min(...t),l=Math.max(...t),d=t.reduce((b,p)=>b+p,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:b=600,height:p=400,title:C,showLegend:L=!0,showGrid:w=!0,yAxisLabel:f,xAxisLabel:N,stacked:I,zoomable:S,crosshair:M,annotations:i=[],legendInteractive:h,onDataPointClick:x,exportable:$,showControls:g=!0,showStatus:v=!0,initialPaused:_=!1,onDataReceived:y,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,H]=o.useState(!1),Y=o.useRef([]),B=o.useRef(Date.now()),m=o.useRef(null),P=o.useCallback(()=>{const z=Y.current;z.length!==0&&(Y.current=[],V(X=>{const ne=new Map(X);for(const de of z){const ge=ne.get(de.series);if(!ge)continue;const xe=[...ge,de.value];if(l&&xe.length>c){const fe=xe.length-c;u?.(fe,de.series),xe.splice(0,fe)}ne.set(de.series,xe)}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]),F=o.useCallback(()=>{const z=Date.now();z-B.current>=d&&(P(),B.current=z),m.current=requestAnimationFrame(F)},[d,P]);o.useEffect(()=>(q||(m.current=requestAnimationFrame(F)),()=>{m.current!==null&&(cancelAnimationFrame(m.current),m.current=null)}),[q,F]);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)&&(Y.current.push(ne),y?.(ne))},[q,U,y]);o.useEffect(()=>{if(!s)return;const z=s.subscribe(ee);let X;return s.onStatusChange?X=s.onStatusChange(H):H(!0),s.fetchHistory&&s.fetchHistory(c).then(ne=>{for(const de of ne)Y.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([]),Y.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:[v&&e.jsxs("div",{style:{position:"absolute",top:8,right:8,display:"flex",alignItems:"center",gap:4,fontSize:12,color:n?"var(--color-success, #22c55e)":"var(--color-error, #ef4444)",zIndex:10},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:n?"var(--color-success, #22c55e)":"var(--color-error, #ef4444)"}}),n?"Live":"Disconnected"]}),g&&e.jsx("div",{style:{position:"absolute",top:8,left:8,display:"flex",gap:4,zIndex:10},children:e.jsx("button",{onClick:()=>J(z=>!z),style:{padding:"4px 8px",fontSize:12,border:"1px solid var(--border-color, #ddd)",borderRadius:4,background:q?"var(--warning-bg, #fef3c7)":"var(--bg-primary, #fff)",cursor:"pointer"},title:q?"Resume":"Pause",children:q?"▶":"⏸"})}),a&&ue&&e.jsx("div",{style:{position:"absolute",bottom:50,right:8,background:"var(--nice-overlay-light-90, rgba(255, 255, 255, 0.9))",border:"1px solid var(--border-color, #ddd)",borderRadius:4,padding:8,fontSize:11,zIndex:10},children:Object.entries(ue).map(([z,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:b,height:p,title:C,showLegend:L,showGrid:w,yAxisLabel:f,xAxisLabel:N,stacked:I,zoomable:S,crosshair:M,annotations:te,legendInteractive:h,onDataPointClick:x,exportable:$})]})});Re.displayName="NiceLiveChart";function Ge(t){const{hubConnection:c,eventName:l="DataPoint",subscribeMethod:d="SubscribeToMetrics",historyMethod:s="GetMetricHistory",metricName:b}=t;return{subscribe(p){const C=L=>{p(L)};return c.on(l,C),c.state==="Connected"&&c.invoke(d,b).catch(()=>{}),()=>{c.off(l,C)}},async fetchHistory(p){try{return await c.invoke(s,b,p)}catch{return[]}},onStatusChange(p){const C=()=>p(c.state==="Connected");return c.onclose(()=>p(!1)),c.onreconnected(()=>p(!0)),C(),()=>{}}}}function qe(t){const{url:c,autoReconnect:l=!0,reconnectDelay:d=3e3,parseMessage:s=f=>JSON.parse(f)}=t;let b=null,p=null,C=null,L=null;const w=()=>{b=new WebSocket(c),b.onopen=()=>{p?.(!0)},b.onclose=()=>{p?.(!1),l&&(L=setTimeout(w,d))},b.onerror=()=>{b?.close()},b.onmessage=f=>{try{const N=s(f.data);N&&C&&C(N)}catch{}}};return{subscribe(f){return C=f,w(),()=>{C=null,L&&clearTimeout(L),b?.close(),b=null}},onStatusChange(f){return p=f,()=>{p=null}}}}function Je(t){const{seriesNames:c,interval:l=1e3,generateValue:d=()=>Math.random()*100}=t;let s=null,b=0;return{subscribe(p){return s=setInterval(()=>{for(const C of c)p({series:C,value:d(C,b),timestamp:Date.now()});b++},l),()=>{s&&clearInterval(s)}},onStatusChange(p){return p(!0),()=>{}}}}const pe=["#3b82f6","#ef4444","#22c55e","#f59e0b","#8b5cf6","#ec4899","#06b6d4","#84cc16"],Ke=({data:t,width:c=400,height:l=400,innerRadius:d=0,title:s,showLegend:b=!0,showLabels:p=!0,className:C,style:L})=>{const w=c/2,f=(l-(b?30:0))/2+(s?10:0),N=Math.min(w,f)-40,I=t.reduce((i,h)=>i+h.value,0);let S=-Math.PI/2;const M=t.map((i,h)=>{const x=i.value/(I||1)*Math.PI*2,$=S;S+=x;const g=S,v=($+g)/2,_=w+N*Math.cos($),y=f+N*Math.sin($),u=w+N*Math.cos(g),D=f+N*Math.sin(g),a=x>Math.PI?1:0,j=i.color||pe[h%pe.length];let A;if(d>0){const V=w+d*Math.cos($),G=f+d*Math.sin($),Q=w+d*Math.cos(g),q=f+d*Math.sin(g);A=`M${_},${y} A${N},${N} 0 ${a},1 ${u},${D} L${Q},${q} A${d},${d} 0 ${a},0 ${V},${G} Z`}else A=`M${w},${f} L${_},${y} A${N},${N} 0 ${a},1 ${u},${D} Z`;const O=w+N*.7*Math.cos(v),Z=f+N*.7*Math.sin(v),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:w,y:20,textAnchor:"middle",className:"nice-chart__title",children:s}),M.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}%)`})}),p&&i.pct>=5&&e.jsxs("text",{x:i.labelX,y:i.labelY,textAnchor:"middle",dominantBaseline:"middle",className:"nice-piechart__label",children:[i.pct,"%"]})]},h)),b&&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||pe[h%pe.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:b,showLegend:p=!0,className:C,style:L})=>{const w=l/2,f=(d-(p?30:0))/2+(b?10:0),N=Math.min(w,f)-60,I=c.length,S=s??Math.max(...t.flatMap(x=>x.data),1),M=Math.PI*2/I,i=5,h=(x,$)=>{const g=x*M-Math.PI/2,v=$/S*N;return{x:w+v*Math.cos(g),y:f+v*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:[b&&e.jsx("text",{x:w,y:20,textAnchor:"middle",className:"nice-chart__title",children:b}),Array.from({length:i},(x,$)=>{const g=N*(($+1)/i);return e.jsx("circle",{cx:w,cy:f,r:g,fill:"none",stroke:"var(--border-color, #ddd)",strokeWidth:.5},$)}),c.map((x,$)=>{const g=h($,S),v=h($,S*1.22),_=$*M-Math.PI/2,y=Math.cos(_),u=Math.sin(_),D=y>.2?"start":y<-.2?"end":"middle",a=u>.2?"hanging":u<-.2?"auto":"middle";return e.jsxs("g",{children:[e.jsx("line",{x1:w,y1:f,x2:g.x,y2:g.y,stroke:"var(--border-color, #ddd)",strokeWidth:.5}),e.jsx("text",{x:v.x,y:v.y,textAnchor:D,dominantBaseline:a,className:"nice-chart__axis-label nice-chart__axis-label--polar",children:x})]},$)}),t.map((x,$)=>{const g=x.color||pe[$%pe.length],v=x.data.map((_,y)=>{const u=h(y,_);return`${u.x},${u.y}`}).join(" ");return e.jsxs("g",{children:[e.jsx("polygon",{points:v,fill:x.fill!==!1?g:"none",fillOpacity:.15,stroke:g,strokeWidth:2}),x.data.map((_,y)=>{const u=h(y,_);return e.jsx("circle",{cx:u.x,cy:u.y,r:3,fill:g,children:e.jsx("title",{children:`${x.name} - ${c[y]}: ${_}`})},y)})]},x.name)}),p&&e.jsx("g",{transform:`translate(10, ${d-25})`,children:t.map((x,$)=>e.jsxs("g",{transform:`translate(${$*100}, 0)`,children:[e.jsx("rect",{width:10,height:10,rx:2,fill:x.color||pe[$%pe.length]}),e.jsx("text",{x:14,y:9,className:"nice-chart__legend-text",children:x.name})]},$))})]})})},et=({value:t,min:c=0,max:l=100,width:d=200,height:s=200,startAngle:b=225,endAngle:p=-45,color:C="var(--color-primary, #3b82f6)",trackColor:L,label:w,formatValue:f,ranges:N,className:I,style:S})=>{const M=d/2,i=s/2,h=Math.min(M,i)-20,x=Math.max(0,Math.min(1,(t-c)/(l-c||1))),$=a=>a*Math.PI/180,g=(b-p+360)%360||360,v=a=>({x:M+h*Math.cos($(a)),y:i-h*Math.sin($(a))}),_=(a,j)=>{const A=v(a),O=v(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}`},y=b-x*g,u=v(y);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:_(b,p),fill:"none",stroke:L||"var(--border-color, #e2e8f0)",strokeWidth:12,strokeLinecap:"round"}),x>0&&e.jsx("path",{d:_(b,y),fill:"none",stroke:D,strokeWidth:12,strokeLinecap:"round"}),e.jsx("line",{x1:M,y1:i,x2:u.x,y2:u.y,stroke:"var(--text-primary, #333)",strokeWidth:2,strokeLinecap:"round"}),e.jsx("circle",{cx:M,cy:i,r:4,fill:"var(--text-primary, #333)"}),e.jsx("text",{x:M,y:i+h*.6,textAnchor:"middle",className:"nice-gauge__value",children:f?f(t):t}),w&&e.jsx("text",{x:M,y:i+h*.95,textAnchor:"middle",className:"nice-gauge__label",children:w})]})})},tt=({value:t,min:c=0,max:l=100,width:d=300,height:s=60,orientation:b="horizontal",color:p="var(--color-primary, #3b82f6)",label:C,formatValue:L,ranges:w,showTicks:f=!0,tickCount:N=5,className:I,style:S})=>{const M=b==="horizontal",i=M?d-40:s-40,h=Math.max(0,Math.min(1,(t-c)/(l-c||1))),x=10;let $=p;if(w){for(const v of w)if(t>=v.start&&t<=v.end){$=v.color;break}}const g=Array.from({length:N},(v,_)=>c+(l-c)*(_/(N-1)));return M?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-x/2,width:i,height:x,rx:5,fill:"var(--border-color, #e2e8f0)"}),e.jsx("rect",{x:20,y:s/2-x/2,width:i*h,height:x,rx:5,fill:$}),e.jsx("polygon",{points:`${20+i*h},${s/2-x/2-2} ${20+i*h-5},${s/2-x/2-8} ${20+i*h+5},${s/2-x/2-8}`,fill:"var(--text-primary, #333)"}),f&&g.map((v,_)=>{const y=20+(v-c)/(l-c)*i;return e.jsx("text",{x:y,y:s/2+x/2+12,textAnchor:"middle",className:"nice-gauge__tick",children:v},_)}),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-x/2,y:20,width:x,height:i,rx:5,fill:"var(--border-color, #e2e8f0)"}),e.jsx("rect",{x:d/2-x/2,y:20+i*(1-h),width:x,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:b=225,endAngle:p=-45,formatValue:C,title:L,className:w,style:f})=>{const N=d/2,I=s/2,S=Math.min(N,I)-30,M=Math.min(20,S/(t.length+1)),i=4,h=g=>g*Math.PI/180,x=(b-p+360)%360||360,$=(g,v,_)=>{const y=N+g*Math.cos(h(v)),u=I-g*Math.sin(h(v)),D=N+g*Math.cos(h(_)),a=I-g*Math.sin(h(_)),j=(v-_+360)%360;return`M${y},${u} A${g},${g} 0 ${j>180?1:0},1 ${D},${a}`};return e.jsx("div",{className:`nice-bargauge ${w||""}`,style:f,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,v)=>{const _=S-v*(M+i),y=Math.max(0,Math.min(1,(g.value-c)/(l-c||1))),u=b-y*x,D=g.color||pe[v%pe.length];return e.jsxs("g",{children:[e.jsx("path",{d:$(_,b,p),fill:"none",stroke:"var(--border-color, #e2e8f0)",strokeWidth:M,strokeLinecap:"round"}),y>0&&e.jsx("path",{d:$(_,b,u),fill:"none",stroke:D,strokeWidth:M,strokeLinecap:"round"})]},v)}),e.jsx("g",{children:t.map((g,v)=>e.jsxs("text",{x:N,y:I-((t.length-1)/2-v)*16,textAnchor:"middle",dominantBaseline:"middle",className:"nice-gauge__value",style:{fontSize:12},children:[g.label?`${g.label}: `:"",C?C(g.value):g.value]},v))})]})})},rt=({data:t,width:c=120,height:l=30,type:d="line",color:s="var(--color-primary, #3b82f6)",showMinMax:b,showLastPoint:p=!0,className:C,style:L})=>{if(t.length===0)return null;const w=2,f=Math.min(...t),N=Math.max(...t),I=N-f||1,S=c-w*2,M=l-w*2,i=_=>w+_/(t.length-1||1)*S,h=_=>w+M-(_-f)/I*M;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((y,u)=>e.jsx("rect",{x:w+u/t.length*S,y:h(y),width:_,height:M-(h(y)-w),fill:s,rx:1},u))})}const x=t.map((_,y)=>`${i(y)},${h(_)}`).join(" "),$=t.indexOf(f),g=t.indexOf(N),v=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)},${w+M} ${x} ${i(v)},${w+M}`,fill:s,opacity:.15}),e.jsx("polyline",{points:x,fill:"none",stroke:s,strokeWidth:1.5}),b&&e.jsx("circle",{cx:i($),cy:h(f),r:2,fill:"var(--nice-danger, #ef4444)"}),b&&e.jsx("circle",{cx:i(g),cy:h(N),r:2,fill:"var(--nice-success, #22c55e)"}),p&&e.jsx("circle",{cx:i(v),cy:h(t[v]),r:2,fill:s})]})},at={sm:{width:160,height:22,fontSize:11},md:{width:220,height:32,fontSize:12},lg:{width:320,height:44,fontSize:14}},st=({value:t,target:c,min:l=0,max:d=100,width:s,height:b,color:p="var(--color-primary, #3b82f6)",targetColor:C="var(--color-error, #ef4444)",size:L="md",label:w,labelPlacement:f="top",showValue:N=!1,showTarget:I=!1,formatValue:S=$=>String($),state:M="normal",errorMessage:i,className:h,style:x})=>{const $=at[L],g=s??$.width,v=b??$.height,_=$.fontSize,y=4,u=g-y*2,D=v-y*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=()=>M==="error"?e.jsx("div",{role:"alert",style:{width:g,height:v,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"}):M==="loading"?e.jsx("div",{role:"status","aria-label":"Loading",className:"nice-bullet__skeleton",style:{width:g,height:v,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:v,role:"img","aria-label":typeof w=="string"?w:void 0,children:[e.jsx("rect",{x:y,y,width:u,height:D,rx:3,fill:"var(--border-color, #e2e8f0)"}),e.jsx("rect",{x:y,y:y+D*.2,width:u*a,height:D*.6,rx:2,fill:p}),j!=null&&e.jsx("line",{x1:y+u*j,y1:y+2,x2:y+u*j,y2:y+D-2,stroke:C,strokeWidth:2}),N&&e.jsx("text",{x:y+Math.max(u*a,4),y:v/2,dx:u*a>24?-4:4,textAnchor:u*a>24?"end":"start",dominantBaseline:"middle",fontSize:_,fill:u*a>24?"var(--nice-bg, #fff)":"var(--text-primary)",fontWeight:600,children:S(t)}),I&&j!=null&&e.jsxs("text",{x:y+u*j,y:y-1,textAnchor:"middle",fontSize:_-1,fill:C,fontWeight:600,children:["▼",S(c)]})]});if(f==="none"||!w)return e.jsxs("div",{className:`nice-bullet ${h||""}`,style:x,children:[A(),e.jsx("style",{children:ze})]});const O=f==="top"||f==="bottom",Z=e.jsx("span",{className:"nice-bullet__label",style:{fontSize:_,fontWeight:600,color:"var(--text-primary)",...O?{marginBottom:f==="top"?4:0,marginTop:f==="bottom"?4:0}:{},...f==="left"?{marginRight:8}:{},...f==="right"?{marginLeft:8}:{}},children:w});return e.jsxs("div",{className:`nice-bullet nice-bullet--${f} ${h||""}`,style:{display:"inline-flex",flexDirection:O?"column":"row",alignItems:O?"flex-start":"center",...x},children:[(f==="top"||f==="left")&&Z,A(),(f==="bottom"||f==="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:b=!0,title:p,className:C,style:L})=>{const w={top:p?30:10,bottom:10,x:40},f=c-w.x*2,N=l-w.top-w.bottom,I=d?[...t].reverse():t,S=Math.max(...I.map(i=>i.value),1),M=N/I.length;return e.jsx("div",{className:`nice-funnel ${C||""}`,style:L,children:e.jsxs("svg",{width:c,height:l,children:[p&&e.jsx("text",{x:c/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:p}),I.map((i,h)=>{const x=i.value/S*f,$=h<I.length-1?I[h+1].value/S*f:x*.3,g=w.top+h*M,v=g+M,_=c/2,y=`${_-x/2},${g} ${_+x/2},${g} ${_+$/2},${v} ${_-$/2},${v}`,u=i.color||pe[h%pe.length];return e.jsxs("g",{children:[e.jsx("polygon",{points:y,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+M/2-(b?4:0),textAnchor:"middle",dominantBaseline:"middle",className:"nice-funnel__label",children:i.label}),b&&e.jsx("text",{x:_,y:g+M/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:b=10,title:p,className:C,style:L})=>{const w={top:p?40:20,bottom:20,left:20,right:20},f=l-w.left-w.right,N=d-w.top-w.bottom,I=new Set(c.map(a=>a.source)),S=new Set(c.map(a=>a.target)),M=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)),x=[M,...h.length?[h]:[],i].filter(a=>a.length>0),$=x.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 v=x.map(a=>a.reduce((j,A)=>j+(g.get(A.id)||0),0)+(a.length-1)*b),_=Math.max(...v,1),y=new Map;x.forEach((a,j)=>{const A=w.left+j/($-1||1)*(f-s);let O=0;a.forEach(Z=>{const U=(g.get(Z.id)||0)/_*N;y.set(Z.id,{x:A,y:w.top+O,h:U}),O+=U+b})});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:[p&&e.jsx("text",{x:l/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:p}),c.map((a,j)=>{const A=y.get(a.source),O=y.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,Y=t.find(B=>B.id===a.source)?.color||pe[j%pe.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:Y,fillOpacity:.3,stroke:Y,strokeOpacity:.5,strokeWidth:.5,children:e.jsx("title",{children:`${a.source} → ${a.target}: ${a.value}`})},j)}),t.map((a,j)=>{const A=y.get(a.id);if(!A)return null;const O=a.color||pe[j%pe.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<f/2?A.x+s+4:A.x-4,y:A.y+A.h/2,textAnchor:A.x<f/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:b,width:p=500,height:C=100,step:L=1,formatValue:w,chartColor:f="var(--color-primary, #3b82f6)",className:N,style:I})=>{const S={top:10,bottom:30,left:10,right:10},M=p-S.left-S.right,i=C-S.top-S.bottom,h=y=>S.left+(y-c)/(l-c||1)*M,x=y=>{const u=Math.max(0,Math.min(1,(y-S.left)/M)),D=c+u*(l-c);return Math.round(D/L)*L},$=(y,u)=>{u.preventDefault();const D=u.target.closest("svg");if(!D)return;const a=A=>{const O=D.getBoundingClientRect(),Z=x(A.clientX-O.left);y==="start"?b(Math.min(Z,s),s):b(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:p,height:C,children:[t&&t.length>1&&e.jsx("polygon",{points:`${S.left},${S.top+i} ${t.map((y,u)=>`${S.left+u/(t.length-1)*M},${S.top+i-(y-g)/_*i}`).join(" ")} ${S.left+M},${S.top+i}`,fill:f,opacity:.15}),e.jsx("rect",{x:h(d),y:S.top,width:h(s)-h(d),height:i,fill:f,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+M-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:f,rx:2,cursor:"ew-resize",onPointerDown:y=>$("start",y)}),e.jsx("rect",{x:h(s)-4,y:S.top,width:8,height:i,fill:f,rx:2,cursor:"ew-resize",onPointerDown:y=>$("end",y)}),e.jsx("text",{x:h(d),y:S.top+i+18,textAnchor:"middle",className:"nice-chart__axis-label",children:w?w(d):d}),e.jsx("text",{x:h(s),y:S.top+i+18,textAnchor:"middle",className:"nice-chart__axis-label",children:w?w(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:b,onRegionClick:p,selectedRegionId:C,title:L,showTooltip:w=!0,className:f,style:N})=>{const I=b??Math.max(...t.map(M=>M.value??0),1),S=M=>{const i=a=>[parseInt(a.slice(1,3),16),parseInt(a.slice(3,5),16),parseInt(a.slice(5,7),16)],[h,x,$]=i(s[0]),[g,v,_]=i(s[1]),y=Math.round(h+(g-h)*M),u=Math.round(x+(v-x)*M),D=Math.round($+(_-$)*M);return`rgb(${y},${u},${D})`};return e.jsxs("div",{className:`nice-vectormap ${f||""}`,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(M=>{const i=M.value!=null?Math.max(0,Math.min(1,M.value/I)):0,h=M.value!=null?S(i):"var(--bg-tertiary, #e5e7eb)",x=M.id===C;return e.jsx("path",{d:M.path,fill:h,stroke:x?"var(--color-primary, #3b82f6)":"var(--border-color, #d1d5db)",strokeWidth:x?2:.5,cursor:p?"pointer":void 0,onClick:()=>p?.(M),children:w&&e.jsx("title",{children:`${M.name}${M.value!=null?`: ${M.value}`:""}`})},M.id)})})]})},lt=Object.freeze(Object.defineProperty({__proto__:null,NiceVectorMap:Te},Symbol.toStringTag,{value:"Module"})),dt=`
|
|
7
|
+
.nice-forecast-chart {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
11
|
+
border: 1px solid var(--nice-border-color, #e5e7eb);
|
|
12
|
+
border-radius: var(--nice-radius-lg, 0.5rem);
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.nice-forecast-chart__header {
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
justify-content: space-between;
|
|
20
|
+
padding: 0.75rem 1rem;
|
|
21
|
+
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.nice-forecast-chart__title {
|
|
25
|
+
font-size: 1rem;
|
|
26
|
+
font-weight: 600;
|
|
27
|
+
color: var(--nice-text-primary);
|
|
28
|
+
margin: 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.nice-forecast-chart__actions {
|
|
32
|
+
display: flex;
|
|
33
|
+
gap: 0.5rem;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.nice-forecast-chart__btn {
|
|
37
|
+
display: inline-flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
justify-content: center;
|
|
40
|
+
width: 2rem;
|
|
41
|
+
height: 2rem;
|
|
42
|
+
font-size: 1rem;
|
|
43
|
+
border-radius: var(--nice-radius-md, 0.375rem);
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
transition: all 0.15s ease;
|
|
46
|
+
border: 1px solid var(--nice-border-color, #d1d5db);
|
|
47
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
48
|
+
color: var(--nice-text-secondary);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.nice-forecast-chart__btn:hover {
|
|
52
|
+
background: var(--nice-bg-hover, #f3f4f6);
|
|
53
|
+
color: var(--nice-text-primary);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.nice-forecast-chart__btn:disabled {
|
|
57
|
+
opacity: 0.5;
|
|
58
|
+
cursor: not-allowed;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.nice-forecast-chart__container {
|
|
62
|
+
position: relative;
|
|
63
|
+
width: 100%;
|
|
64
|
+
padding: 1rem;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.nice-forecast-chart__svg {
|
|
68
|
+
width: 100%;
|
|
69
|
+
overflow: visible;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.nice-forecast-chart__grid-line {
|
|
73
|
+
stroke: var(--nice-border-divider, #f3f4f6);
|
|
74
|
+
stroke-width: 1;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.nice-forecast-chart__axis-line {
|
|
78
|
+
stroke: var(--nice-border-color, #e5e7eb);
|
|
79
|
+
stroke-width: 1;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.nice-forecast-chart__axis-label {
|
|
83
|
+
font-size: 0.6875rem;
|
|
84
|
+
fill: var(--nice-text-secondary);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.nice-forecast-chart__axis-title {
|
|
88
|
+
font-size: 0.75rem;
|
|
89
|
+
font-weight: 500;
|
|
90
|
+
fill: var(--nice-text-primary);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.nice-forecast-chart__historical-line {
|
|
94
|
+
fill: none;
|
|
95
|
+
stroke-width: 2;
|
|
96
|
+
stroke-linecap: round;
|
|
97
|
+
stroke-linejoin: round;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.nice-forecast-chart__forecast-line {
|
|
101
|
+
fill: none;
|
|
102
|
+
stroke-width: 2;
|
|
103
|
+
stroke-linecap: round;
|
|
104
|
+
stroke-linejoin: round;
|
|
105
|
+
stroke-dasharray: 6, 4;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.nice-forecast-chart__confidence-band {
|
|
109
|
+
opacity: 0.2;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.nice-forecast-chart__forecast-region {
|
|
113
|
+
fill: var(--nice-bg-secondary, #f9fafb);
|
|
114
|
+
opacity: 0.5;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.nice-forecast-chart__point {
|
|
118
|
+
cursor: pointer;
|
|
119
|
+
transition: r 0.15s ease;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.nice-forecast-chart__point:hover {
|
|
123
|
+
r: 6;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.nice-forecast-chart__annotation-line {
|
|
127
|
+
stroke-dasharray: 4, 2;
|
|
128
|
+
stroke-width: 1;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.nice-forecast-chart__annotation-marker {
|
|
132
|
+
cursor: pointer;
|
|
133
|
+
transition: transform 0.15s ease;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.nice-forecast-chart__annotation-marker:hover {
|
|
137
|
+
transform: scale(1.2);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.nice-forecast-chart__reference-line {
|
|
141
|
+
stroke-width: 1;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.nice-forecast-chart__reference-label {
|
|
145
|
+
font-size: 0.625rem;
|
|
146
|
+
fill: var(--nice-text-secondary);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.nice-forecast-chart__cash-runway {
|
|
150
|
+
pointer-events: none;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.nice-forecast-chart__cash-runway-line {
|
|
154
|
+
stroke: var(--nice-danger, #ef4444);
|
|
155
|
+
stroke-width: 2;
|
|
156
|
+
stroke-dasharray: 8, 4;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.nice-forecast-chart__cash-runway-label-bg {
|
|
160
|
+
fill: var(--nice-danger, #ef4444);
|
|
161
|
+
rx: 4;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.nice-forecast-chart__cash-runway-label {
|
|
165
|
+
font-size: 0.6875rem;
|
|
166
|
+
font-weight: 600;
|
|
167
|
+
fill: var(--nice-bg, #FFFFFF);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.nice-forecast-chart__cash-runway-date {
|
|
171
|
+
font-size: 0.625rem;
|
|
172
|
+
fill: var(--nice-danger, #ef4444);
|
|
173
|
+
font-weight: 500;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.nice-forecast-chart__tooltip {
|
|
177
|
+
position: absolute;
|
|
178
|
+
pointer-events: none;
|
|
179
|
+
z-index: 100;
|
|
180
|
+
padding: 0.75rem;
|
|
181
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
182
|
+
border: 1px solid var(--nice-border-color, #e5e7eb);
|
|
183
|
+
border-radius: var(--nice-radius-lg, 0.5rem);
|
|
184
|
+
box-shadow: 0 4px 12px var(--nice-overlay-10, rgba(0, 0, 0, 0.1));
|
|
185
|
+
font-size: 0.8125rem;
|
|
186
|
+
max-width: 250px;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.nice-forecast-chart__tooltip-date {
|
|
190
|
+
font-weight: 600;
|
|
191
|
+
color: var(--nice-text-primary);
|
|
192
|
+
margin-bottom: 0.5rem;
|
|
193
|
+
padding-bottom: 0.5rem;
|
|
194
|
+
border-bottom: 1px solid var(--nice-border-divider, #f3f4f6);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.nice-forecast-chart__tooltip-item {
|
|
198
|
+
display: flex;
|
|
199
|
+
align-items: center;
|
|
200
|
+
gap: 0.5rem;
|
|
201
|
+
margin-bottom: 0.25rem;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.nice-forecast-chart__tooltip-color {
|
|
205
|
+
width: 10px;
|
|
206
|
+
height: 10px;
|
|
207
|
+
border-radius: var(--nice-radius-sm, 2px);
|
|
208
|
+
flex-shrink: 0;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.nice-forecast-chart__tooltip-label {
|
|
212
|
+
color: var(--nice-text-secondary);
|
|
213
|
+
flex: 1;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.nice-forecast-chart__tooltip-value {
|
|
217
|
+
font-weight: 600;
|
|
218
|
+
color: var(--nice-text-primary);
|
|
219
|
+
font-variant-numeric: tabular-nums;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.nice-forecast-chart__tooltip-confidence {
|
|
223
|
+
font-size: 0.75rem;
|
|
224
|
+
color: var(--nice-text-tertiary);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.nice-forecast-chart__legend {
|
|
228
|
+
display: flex;
|
|
229
|
+
flex-wrap: wrap;
|
|
230
|
+
gap: 1rem;
|
|
231
|
+
padding: 0.75rem 1rem;
|
|
232
|
+
border-top: 1px solid var(--nice-border-color, #e5e7eb);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.nice-forecast-chart__legend-item {
|
|
236
|
+
display: flex;
|
|
237
|
+
align-items: center;
|
|
238
|
+
gap: 0.375rem;
|
|
239
|
+
font-size: 0.8125rem;
|
|
240
|
+
color: var(--nice-text-secondary);
|
|
241
|
+
cursor: pointer;
|
|
242
|
+
user-select: none;
|
|
243
|
+
transition: opacity 0.15s ease;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.nice-forecast-chart__legend-item:hover {
|
|
247
|
+
color: var(--nice-text-primary);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.nice-forecast-chart__legend-item--hidden {
|
|
251
|
+
opacity: 0.4;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.nice-forecast-chart__legend-color {
|
|
255
|
+
width: 16px;
|
|
256
|
+
height: 3px;
|
|
257
|
+
border-radius: var(--nice-radius-xs, 1px);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.nice-forecast-chart__legend-color--dashed {
|
|
261
|
+
background: repeating-linear-gradient(
|
|
262
|
+
90deg,
|
|
263
|
+
currentColor,
|
|
264
|
+
currentColor 4px,
|
|
265
|
+
transparent 4px,
|
|
266
|
+
transparent 6px
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.nice-forecast-chart__empty {
|
|
271
|
+
display: flex;
|
|
272
|
+
align-items: center;
|
|
273
|
+
justify-content: center;
|
|
274
|
+
height: 300px;
|
|
275
|
+
color: var(--nice-text-secondary);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/* Dark mode */
|
|
279
|
+
.dark .nice-forecast-chart {
|
|
280
|
+
background: var(--nice-bg-primary-dark, #111827);
|
|
281
|
+
border-color: var(--nice-border-color-dark, #374151);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.dark .nice-forecast-chart__tooltip {
|
|
285
|
+
background: var(--nice-bg-secondary-dark, #1f2937);
|
|
286
|
+
border-color: var(--nice-border-color-dark, #374151);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.dark .nice-forecast-chart__forecast-region {
|
|
290
|
+
fill: var(--nice-bg-secondary-dark, #1f2937);
|
|
291
|
+
}
|
|
292
|
+
`,Le=["var(--color-primary, #3b82f6)","var(--color-success, #10b981)","var(--color-warning, #f59e0b)","var(--color-error, #ef4444)","var(--color-accent, #8b5cf6)","var(--color-accent-pink, #ec4899)","var(--color-info, #06b6d4)","var(--nice-warning, #f97316)"];function me(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 Me(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:b=[],referenceLines:p=[],forecastStartDate:C,cashRunway:L,xAxis:w,yAxis:f,confidenceBands:N=[{level:95,color:"var(--color-primary, #3b82f6)",opacity:.15}],tooltip:I,legend:S={enabled:!0,position:"bottom",interactive:!0},height:M=350,showForecastRegion:i=!0,lineWidth:h=2,showPoints:x=!1,pointRadius:$=4,enableZoom:g=!1,zoomEnabled:v,animationDuration:_=300,showLegend:y,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:y??S.enabled},[n,H]=o.useState(()=>q.map((r,T)=>({...r,color:r.color??Le[T%Le.length],visible:r.visible!==!1}))),[Y,B]=o.useState(null),[m,P]=o.useState({x:0,y:0}),F=o.useRef(null),ee=o.useRef(null),E={top:20,right:30,bottom:40,left:60},[te,ue]=o.useState({width:600,height:typeof M=="number"?M:350});o.useEffect(()=>{if(!u||!F.current)return;const r=new ResizeObserver(T=>{for(const W of T)ue(k=>({width:W.contentRect.width,height:k.height}))});return r.observe(F.current),()=>r.disconnect()},[u]),o.useEffect(()=>{const r="nice-forecast-chart-styles";if(!document.getElementById(r)){const T=document.createElement("style");T.id=r,T.textContent=dt,document.head.appendChild(T)}},[]);const{xScale:z,yScale: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=>me(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=f?.min??Math.min(...se)*.95,le=f?.max??Math.max(...se)*1.05,ve=te.width-E.left-E.right,be=te.height-E.top-E.bottom,Ne=he=>{const Se=typeof he=="number"?he:he.getTime();return E.left+(Se-k)/(K-k)*ve},$e=he=>E.top+be-(he-oe)/(le-oe)*be,Ye=[...new Set(W)].sort((he,Se)=>he-Se).map(he=>new Date(he));return{xScale:Ne,yScale:$e,allDates:Ye,minY:oe,maxY:le}},[n,te,E,f]),xe=C?me(C):null,fe=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)=>me(k.date).getTime()-me(K.date).getTime());for(let k=1;k<W.length;k++){const K=W[k-1],se=W[k],oe=K.forecast??K.value,le=se.forecast??se.value;if(oe!=null&&le!=null&&oe>r&&le<=r){const ve=(oe-r)/(oe-le),be=me(K.date).getTime(),Ne=me(se.date).getTime(),$e=be+ve*(Ne-be);return new Date($e)}}return null},[L,n]),ye=o.useCallback((r,T)=>{const W=r.filter(k=>k[T]!=null).map(k=>({x:z(me(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(me(K.date)),y:X(K.upperBound)})),k=T.map(K=>({x:z(me(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 ve=le.data.find(be=>me(be.date).getTime()===k.getTime());return{scenario:le,value:ve?.value,forecast:ve?.forecast,lowerBound:ve?.lowerBound,upperBound:ve?.upperBound}}),oe=b.filter(le=>Math.abs(me(le.date).getTime()-k.getTime())<864e5);B({date:k,values:se,annotations:oe}),P({x:r.clientX-T.left+10,y:r.clientY-T.top-10})}else B(null)},[z,ne,n,b,I]),re=o.useCallback(r=>{if(!J.interactive)return;H(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)=>{H(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=>me(K.date).getTime()===r.getTime());return{scenario:W,value:k?.value,forecast:k?.forecast,lowerBound:k?.lowerBound,upperBound:k?.upperBound}});return{date:r,values:T,annotations:b.filter(W=>me(W.date).getTime()===r.getTime())}}}),[n,b,re]),te.width-E.left-E.right;const ae=te.height-E.top-E.bottom,ce=o.useMemo(()=>{const r=f?.tickCount??5,T=[],W=(ge-de)/(r-1);for(let k=0;k<r;k++)T.push(de+W*k);return T},[de,ge,f?.tickCount]),ie=o.useMemo(()=>{const r=w?.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,w?.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:M},children:[e.jsxs("div",{ref:F,className:"nice-forecast-chart__container",children:[e.jsxs("svg",{ref:ee,className:"nice-forecast-chart__svg",width:te.width,height:te.height,onMouseMove:R,onMouseLeave:()=>B(null),children:[f?.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&&xe&&e.jsx("rect",{className:"nice-forecast-chart__forecast-region",x:z(xe),y:E.top,width:te.width-E.right-z(xe),height:ae}),p.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)),fe&&L?.enabled&&e.jsxs("g",{className:"nice-forecast-chart__cash-runway",children:[e.jsx("line",{className:"nice-forecast-chart__cash-runway-line",x1:z(fe),x2:z(fe),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(fe)-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(fe),y:E.top+12,textAnchor:"middle",fill:"var(--nice-bg, #fff)",children:L.label??U.cashRunsOut??"💰 Cash runs out"}),L.showDate!==!1&&e.jsx("text",{className:"nice-forecast-chart__cash-runway-label",x:z(fe),y:E.top+26,textAnchor:"middle",fill:"var(--nice-bg, #fff)",style:{fontSize:"0.625rem",opacity:.9},children:Ce(fe,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=xe?r.data.filter(k=>me(k.date)<xe):r.data.filter(k=>k.value!=null),W=xe?r.data.filter(k=>me(k.date)>=xe):r.data.filter(k=>k.forecast!=null);return e.jsxs("g",{children:[e.jsx("path",{className:"nice-forecast-chart__historical-line",d:ye(T,"value"),stroke:r.color,strokeWidth:h}),e.jsx("path",{className:"nice-forecast-chart__forecast-line",d:ye(W,xe?"value":"forecast"),stroke:r.color,strokeWidth:h}),W.length>0&&r.data.some(k=>k.forecast!=null)&&e.jsx("path",{className:"nice-forecast-chart__forecast-line",d:ye(r.data,"forecast"),stroke:r.color,strokeWidth:h}),x&&r.data.map((k,K)=>{const se=k.value??k.forecast;return se==null?null:e.jsx("circle",{className:"nice-forecast-chart__point",cx:z(me(k.date)),cy:X(se),r:$,fill:r.color,onClick:()=>D?.(k,r)},K)})]},r.id)}),b.map(r=>{const T=z(me(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:f?.format?f.format(r):Me(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:w?.format?w.format(r):Ce(r,V)},r.getTime())),f?.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:f.title})]}),Y&&e.jsxs("div",{className:"nice-forecast-chart__tooltip",style:{left:m.x,top:m.y},children:[e.jsx("div",{className:"nice-forecast-chart__tooltip-date",children:Ce(Y.date,V)}),Y.values.map(r=>{const T=r.value??r.forecast;return T==null?null:e.jsxs("div",{className:"nice-forecast-chart__tooltip-item",children:[e.jsx("span",{className:"nice-forecast-chart__tooltip-color",style:{background:r.scenario.color}}),e.jsx("span",{className:"nice-forecast-chart__tooltip-label",children:r.scenario.name}),e.jsx("span",{className:"nice-forecast-chart__tooltip-value",children:Me(T,V)})]},r.scenario.id)}),Y.values.some(r=>r.lowerBound!=null)&&e.jsxs("div",{className:"nice-forecast-chart__tooltip-confidence",children:[U.confidence??"CI",":"," ",Me(Y.values[0]?.lowerBound??0,V)," –"," ",Me(Y.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)","var(--nice-success, #84cc16)","var(--nice-warning, #f97316)","var(--color-accent, #6366f1)"],We=o.forwardRef((t,c)=>{const{levels:l,initialLevelId:d,chartType:s="bar",width:b=600,height:p=400,showBreadcrumbs:C=!0,showBackButton:L=!0,animationDuration:w=300,onLevelChange:f,onItemClick:N,colors:I=Be,showValues:S=!0,showLegend:M=!0,className:i,style:h,...x}=t,[$,g]=o.useState(d||l[0]?.id),[v,_]=o.useState([d||l[0]?.id]),[y,u]=o.useState(!1),[D,a]=o.useState("in"),j=o.useMemo(()=>l.find(n=>n.id===$),[l,$]),A=o.useCallback(n=>{l.find(Y=>Y.id===n)&&(a("in"),u(!0),setTimeout(()=>{g(n),_(Y=>[...Y,n]),f?.(n,[...v,n]),u(!1)},w/2))},[l,v,w,f]),O=o.useCallback(()=>{if(v.length<=1)return;a("out"),u(!0);const n=v.slice(0,-1),H=n[n.length-1];setTimeout(()=>{g(H),_(n),f?.(H,n),u(!1)},w/2)},[v,w,f]),Z=o.useCallback(()=>{const n=l[0]?.id;n&&(a("out"),u(!0),setTimeout(()=>{g(n),_([n]),f?.(n,[n]),u(!1)},w/2))},[l,w,f]);o.useImperativeHandle(c,()=>({drillDown:A,drillUp:O,resetToRoot:Z,getCurrentLevel:()=>$,getPath:()=>v}),[A,O,Z,$,v]);const U=o.useCallback((n,H)=>{N?.(n,$);const Y=l.find(B=>B.parentId===$&&B.id===n.metadata?.childLevelId);Y&&A(Y.id)},[$,l,A,N]),V=o.useMemo(()=>j?.data.reduce((n,H)=>n+H.value,0)||0,[j]),G=o.useMemo(()=>v.map(n=>l.find(H=>H.id===n)?.label||n),[v,l]),Q=()=>{if(!j)return null;const n=j.data,H=Math.max(...n.map(B=>B.value)),Y=Math.min(40,(p-100)/n.length-8);return e.jsx("div",{className:"nice-drilldown-bars",children:n.map((B,m)=>{const P=B.value/H*100;return e.jsxs("div",{className:"nice-drilldown-bar-row",onClick:()=>U(B,m),children:[e.jsx("span",{className:"nice-drilldown-bar-label",children:B.label||`Item ${m+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[m%I.length],height:Y}})}),S&&e.jsx("span",{className:"nice-drilldown-bar-value",children:B.value.toLocaleString()})]},m)})})},q=()=>{if(!j)return null;const n=j.data,H=b/2,Y=(p-60)/2+30,B=Math.min(H,Y)-40;let m=-90;const P=n.map((F,ee)=>{const E=F.value/V*360,te=m+E,ue=E>180?1:0,z=m*Math.PI/180,X=te*Math.PI/180,ne=H+B*Math.cos(z),de=Y+B*Math.sin(z),ge=H+B*Math.cos(X),xe=Y+B*Math.sin(X),fe=(m+E/2)*Math.PI/180,ye=H+B*.7*Math.cos(fe),je=Y+B*.7*Math.sin(fe),R=`M ${H} ${Y} L ${ne} ${de} A ${B} ${B} 0 ${ue} 1 ${ge} ${xe} Z`;return m=te,{path:R,color:F.color||I[ee%I.length],label:F.label||`Item ${ee+1}`,value:F.value,percentage:(F.value/V*100).toFixed(1),labelX:ye,labelY:je,item:F,index:ee}});return e.jsx("svg",{width:b,height:p-40,className:"nice-drilldown-pie",children:e.jsx("g",{children:P.map((F,ee)=>e.jsxs("g",{onClick:()=>U(F.item,F.index),children:[e.jsx("path",{d:F.path,fill:F.color,stroke:"white",strokeWidth:2,className:"nice-drilldown-pie-slice"}),S&&parseFloat(F.percentage)>5&&e.jsxs("text",{x:F.labelX,y:F.labelY,textAnchor:"middle",dominantBaseline:"middle",fill:"white",fontSize:"12",fontWeight:"600",children:[F.percentage,"%"]})]},ee))})})},J=()=>{if(!j)return null;const n=j.data,H=Math.max(...n.map(m=>m.value)),Y=Math.min(60,(b-100)/n.length-8),B=p-100;return e.jsx("svg",{width:b,height:p-40,className:"nice-drilldown-columns",children:e.jsxs("g",{transform:"translate(50, 20)",children:[[0,.25,.5,.75,1].map((m,P)=>e.jsxs("g",{children:[e.jsx("line",{x1:0,y1:B*(1-m),x2:b-80,y2:B*(1-m),stroke:"var(--nice-border, #e5e7eb)",strokeDasharray:m===0?void 0:"4"}),e.jsx("text",{x:-8,y:B*(1-m),textAnchor:"end",dominantBaseline:"middle",fontSize:"11",fill:"var(--nice-text-secondary, #6b7280)",children:Math.round(H*m).toLocaleString()})]},P)),n.map((m,P)=>{const F=m.value/H*B,ee=P*((b-100)/n.length)+((b-100)/n.length-Y)/2;return e.jsxs("g",{onClick:()=>U(m,P),children:[e.jsx("rect",{x:ee,y:B-F,width:Y,height:F,fill:m.color||I[P%I.length],rx:4,className:"nice-drilldown-column-bar"}),e.jsx("text",{x:ee+Y/2,y:B+16,textAnchor:"middle",fontSize:"11",fill:"var(--nice-text, #374151)",children:(m.label||`${P+1}`).slice(0,10)}),S&&e.jsx("text",{x:ee+Y/2,y:B-F-8,textAnchor:"middle",fontSize:"11",fill:"var(--nice-text, #374151)",fontWeight:"500",children:m.value.toLocaleString()})]},P)})]})})};return e.jsxs("div",{className:`nice-drilldown-chart ${y?`animating ${D}`:""} ${i||""}`,style:{width:b,...h},...x,children:[e.jsxs("div",{className:"nice-drilldown-header",children:[L&&v.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,H)=>e.jsxs(o.Fragment,{children:[H>0&&e.jsx("span",{className:"nice-drilldown-separator",children:"/"}),e.jsx("span",{className:`nice-drilldown-crumb ${H===G.length-1?"active":""}`,onClick:()=>{if(H<G.length-1){const Y=v.slice(0,H+1);_(Y),g(Y[Y.length-1])}},children:n})]},H))})]}),e.jsxs("div",{className:"nice-drilldown-content",style:{height:p-40},children:[s==="bar"&&Q(),s==="pie"&&q(),s==="column"&&J()]}),M&&j&&e.jsx("div",{className:"nice-drilldown-legend",children:j.data.map((n,H)=>e.jsxs("div",{className:"nice-drilldown-legend-item",children:[e.jsx("span",{className:"nice-drilldown-legend-color",style:{backgroundColor:n.color||I[H%I.length]}}),e.jsx("span",{className:"nice-drilldown-legend-label",children:n.label||`Item ${H+1}`})]},H))}),e.jsx("style",{children:`
|
|
293
|
+
.nice-drilldown-chart {
|
|
294
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
295
|
+
background: white;
|
|
296
|
+
border-radius: var(--nice-radius-lg, 8px);
|
|
297
|
+
overflow: hidden;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.nice-drilldown-header {
|
|
301
|
+
display: flex;
|
|
302
|
+
align-items: center;
|
|
303
|
+
gap: var(--nice-space-3, 12px);
|
|
304
|
+
padding: var(--nice-space-3, 12px) var(--nice-space-4, 16px);
|
|
305
|
+
border-bottom: 1px solid var(--border-color, #e5e7eb);
|
|
306
|
+
min-height: 40px;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.nice-drilldown-back {
|
|
310
|
+
background: var(--nice-bg-secondary, #f3f4f6);
|
|
311
|
+
border: none;
|
|
312
|
+
padding: var(--nice-space-1-5, 6px) var(--nice-space-3, 12px);
|
|
313
|
+
border-radius: var(--nice-radius-md, 6px);
|
|
314
|
+
cursor: pointer;
|
|
315
|
+
font-size: 13px;
|
|
316
|
+
color: var(--nice-text, #374151);
|
|
317
|
+
transition: background 0.2s;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.nice-drilldown-back:hover {
|
|
321
|
+
background: var(--nice-border, #e5e7eb);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
.nice-drilldown-breadcrumbs {
|
|
325
|
+
display: flex;
|
|
326
|
+
align-items: center;
|
|
327
|
+
gap: var(--nice-space-1, 4px);
|
|
328
|
+
font-size: 13px;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
.nice-drilldown-separator {
|
|
332
|
+
color: var(--nice-text-muted, #9ca3af);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
.nice-drilldown-crumb {
|
|
336
|
+
color: var(--nice-text-secondary, #6b7280);
|
|
337
|
+
cursor: pointer;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.nice-drilldown-crumb:hover:not(.active) {
|
|
341
|
+
color: var(--nice-primary, #3b82f6);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.nice-drilldown-crumb.active {
|
|
345
|
+
color: var(--nice-text, #111827);
|
|
346
|
+
font-weight: 500;
|
|
347
|
+
cursor: default;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
.nice-drilldown-content {
|
|
351
|
+
padding: var(--nice-space-4, 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: var(--nice-space-2, 8px);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
.nice-drilldown-bar-row {
|
|
374
|
+
display: flex;
|
|
375
|
+
align-items: center;
|
|
376
|
+
gap: var(--nice-space-3, 12px);
|
|
377
|
+
cursor: pointer;
|
|
378
|
+
padding: var(--nice-space-1, 4px) var(--nice-space-2, 8px);
|
|
379
|
+
margin: -4px -8px;
|
|
380
|
+
border-radius: var(--nice-radius-md, 6px);
|
|
381
|
+
transition: background 0.2s;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
.nice-drilldown-bar-row:hover {
|
|
385
|
+
background: var(--nice-bg-secondary, #f9fafb);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
.nice-drilldown-bar-label {
|
|
389
|
+
width: 120px;
|
|
390
|
+
font-size: 13px;
|
|
391
|
+
color: var(--nice-text, #374151);
|
|
392
|
+
overflow: hidden;
|
|
393
|
+
text-overflow: ellipsis;
|
|
394
|
+
white-space: nowrap;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
.nice-drilldown-bar-track {
|
|
398
|
+
flex: 1;
|
|
399
|
+
background: var(--nice-bg-secondary, #f3f4f6);
|
|
400
|
+
border-radius: var(--nice-radius-md, 6px);
|
|
401
|
+
overflow: hidden;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
.nice-drilldown-bar-fill {
|
|
405
|
+
transition: width 0.3s ease;
|
|
406
|
+
border-radius: var(--nice-radius-md, 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: var(--nice-text, #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: var(--nice-space-4, 16px);
|
|
441
|
+
padding: var(--nice-space-3, 12px) var(--nice-space-4, 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: var(--nice-space-1-5, 6px);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
.nice-drilldown-legend-color {
|
|
452
|
+
width: 12px;
|
|
453
|
+
height: 12px;
|
|
454
|
+
border-radius: var(--nice-radius-sm, 3px);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
.nice-drilldown-legend-label {
|
|
458
|
+
font-size: 12px;
|
|
459
|
+
color: var(--nice-text-secondary, #6b7280);
|
|
460
|
+
}
|
|
461
|
+
`})]})});We.displayName="NiceDrillDownChart";const ut=({type:t="choropleth",regions:c=[],bubbles:l=[],width:d=800,height:s=500,viewBox:b="0 0 800 500",colorScale:p=["var(--info-bg, #dbeafe)","var(--color-primary-light, #93c5fd)","var(--color-primary, #3b82f6)","var(--color-primary-active, #1d4ed8)","var(--nice-primary-dark, #1E3A8A)"],minValue:C,maxValue:L,showTooltip:w=!0,showLegend:f=!0,onRegionClick:N,onBubbleClick:I,onRegionHover:S,title:M,mapSvg:i,zoomable:h=!1,className:x,style:$,...g})=>{const[v,_]=o.useState(null),[y,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(m=>m.value),...l.map(m=>m.value)),U=L??Math.max(...c.map(m=>m.value),...l.map(m=>m.value)),V=o.useCallback(m=>{const P=(m-Z)/(U-Z),F=Math.min(Math.floor(P*p.length),p.length-1);return p[Math.max(0,F)]},[Z,U,p]),G=o.useCallback(m=>{if(!w||!v)return;const P=j.current?.getBoundingClientRect();P&&_(F=>F?{...F,x:m.clientX-P.left,y:m.clientY-P.top}:null)},[w,v]),Q=o.useCallback((m,P)=>{const F=j.current?.getBoundingClientRect();F&&w&&_({x:P.clientX-F.left,y:P.clientY-F.top,content:`${m.name}: ${m.value.toLocaleString()}`}),S?.(m)},[w,S]),q=o.useCallback(()=>{_(null),S?.(null)},[S]),J=o.useCallback(m=>{if(!h)return;m.preventDefault();const P=m.deltaY>0?.9:1.1;u(F=>Math.min(Math.max(F*P,.5),4))},[h]),n=o.useCallback(m=>{h&&(A.current=!0,O.current={x:m.clientX-D.x,y:m.clientY-D.y})},[h,D]),H=o.useCallback(()=>{A.current=!1},[]),Y=o.useCallback(m=>{A.current&&a({x:m.clientX-O.current.x,y:m.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 ${x||""}`,style:{width:d,...$},...g,children:[M&&e.jsx("div",{className:"nice-map-title",children:M}),e.jsx("svg",{ref:j,width:d,height:s,viewBox:b,className:"nice-map-svg",onWheel:J,onMouseDown:n,onMouseUp:H,onMouseLeave:H,onMouseMove:m=>{G(m),Y(m)},children:e.jsxs("g",{transform:`translate(${D.x}, ${D.y}) scale(${y})`,children:[i&&e.jsx("g",{dangerouslySetInnerHTML:{__html:i}}),t==="choropleth"&&B.map(m=>e.jsx("path",{d:m.path,fill:m.color||V(m.value),stroke:"var(--nice-bg, #fff)",strokeWidth:1,className:"nice-map-region",onClick:()=>N?.(m),onMouseEnter:P=>Q(m,P),onMouseLeave:q},m.id)),(t==="bubble"||l.length>0)&&l.map(m=>{const P=Math.sqrt((m.value-Z)/(U-Z))*30+5;return e.jsx("circle",{cx:m.lng,cy:m.lat,r:P,fill:m.color||"var(--color-primary, #3b82f6)",fillOpacity:.7,stroke:"var(--nice-bg, #fff)",strokeWidth:1,className:"nice-map-bubble",onClick:()=>I?.(m),onMouseEnter:F=>{const ee=j.current?.getBoundingClientRect();ee&&w&&_({x:F.clientX-ee.left,y:F.clientY-ee.top,content:`${m.label||m.id}: ${m.value.toLocaleString()}`})},onMouseLeave:q,children:m.label&&e.jsxs("title",{children:[m.label,": ",m.value]})},m.id)})]})}),v&&e.jsx("div",{className:"nice-map-tooltip",style:{left:v.x+10,top:v.y-30},children:v.content}),f&&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:p.map((m,P)=>e.jsx("div",{className:"nice-map-legend-item",style:{backgroundColor:m}},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: var(--nice-radius-lg, 8px);
|
|
466
|
+
overflow: hidden;
|
|
467
|
+
position: relative;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
.nice-map-title {
|
|
471
|
+
padding: var(--nice-space-3, 12px) var(--nice-space-4, 16px);
|
|
472
|
+
font-size: 16px;
|
|
473
|
+
font-weight: 600;
|
|
474
|
+
color: var(--nice-text, #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: var(--nice-text, #1f2937);
|
|
510
|
+
color: white;
|
|
511
|
+
padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
|
|
512
|
+
border-radius: var(--nice-radius-sm, 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: var(--nice-space-3, 12px);
|
|
525
|
+
border-radius: var(--nice-radius-md, 6px);
|
|
526
|
+
box-shadow: 0 2px 8px var(--nice-overlay-10, rgba(0, 0, 0, 0.1));
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
.nice-map-legend-title {
|
|
530
|
+
display: block;
|
|
531
|
+
font-size: 11px;
|
|
532
|
+
color: var(--nice-text-secondary, #6b7280);
|
|
533
|
+
margin-bottom: var(--nice-space-1-5, 6px);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
.nice-map-legend-scale {
|
|
537
|
+
display: flex;
|
|
538
|
+
height: 12px;
|
|
539
|
+
border-radius: var(--nice-radius-sm, 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: var(--nice-text-secondary, #6b7280);
|
|
553
|
+
margin-top: var(--nice-space-1, 4px);
|
|
554
|
+
}
|
|
555
|
+
`})]})},xt=({nodes:t,links:c,width:l=800,height:d=500,nodeWidth:s=20,nodePadding:b=10,showValues:p=!0,showTooltip:C=!0,onNodeClick:L,onLinkClick:w,title:f,className:N,style:I,...S})=>{const[M,i]=o.useState(null),h=o.useRef(null),x=o.useMemo(()=>{const g=new Map;t.forEach(n=>g.set(n.id,n));const v=new Set(c.map(n=>n.target)),_=new Set(c.map(n=>n.source)),y=[],u=new Map,D=t.filter(n=>_.has(n.id)&&!v.has(n.id));D.length>0&&(y.push(D.map(n=>n.id)),D.forEach(n=>u.set(n.id,0)));const a=t.filter(n=>_.has(n.id)&&v.has(n.id));a.length>0&&(y.push(a.map(n=>n.id)),a.forEach(n=>u.set(n.id,1)));const j=t.filter(n=>!_.has(n.id)&&v.has(n.id));j.length>0&&(y.push(j.map(n=>n.id)),j.forEach(n=>u.set(n.id,2))),y.length===0&&(y.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=y.length>1?Z/(y.length-1):Z,G=new Map;Math.max(...Array.from(A.values())),y.forEach((n,H)=>{const Y=n.reduce((P,F)=>P+(A.get(F)||0),0),B=(U-(n.length-1)*b)/Y;let m=O;n.forEach(P=>{const ee=(A.get(P)||0)*B,E=O+H*V;G.set(P,{x:E,y:m,height:ee}),m+=ee+b})});const Q=[],q=new Map,J=new Map;return c.forEach(n=>{const H=G.get(n.source),Y=G.get(n.target);if(!H||!Y)return;const B=A.get(n.source)||1;A.get(n.target);const m=n.value/B*H.height,P=H.y+(q.get(n.source)||0),F=Y.y+(J.get(n.target)||0);q.set(n.source,(q.get(n.source)||0)+m),J.set(n.target,(J.get(n.target)||0)+m);const ee=H.x+s,E=Y.x,te=(E-ee)*.5,ue=`
|
|
556
|
+
M ${ee} ${P}
|
|
557
|
+
C ${ee+te} ${P},
|
|
558
|
+
${E-te} ${F},
|
|
559
|
+
${E} ${F}
|
|
560
|
+
L ${E} ${F+m}
|
|
561
|
+
C ${E-te} ${F+m},
|
|
562
|
+
${ee+te} ${P+m},
|
|
563
|
+
${ee} ${P+m}
|
|
564
|
+
Z
|
|
565
|
+
`;Q.push({path:ue,link:n,sourcePos:H,targetPos:Y})}),{nodePositions:G,linkPaths:Q,nodeMap:g,nodeValues:A}},[t,c,l,d,s,b]),$=o.useCallback((g,v)=>{const _=h.current?.getBoundingClientRect();_&&C&&i({x:v.clientX-_.left,y:v.clientY-_.top,content:g})},[C]);return e.jsxs("div",{className:`nice-sankey-chart ${N||""}`,style:{width:l,...I},...S,children:[f&&e.jsx("div",{className:"nice-sankey-title",children:f}),e.jsxs("svg",{ref:h,width:l,height:d,className:"nice-sankey-svg",children:[e.jsx("defs",{children:x.linkPaths.map((g,v)=>e.jsxs("linearGradient",{id:`sankey-gradient-${v}`,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[e.jsx("stop",{offset:"0%",stopColor:x.nodeMap.get(g.link.source)?.color||"var(--color-primary, #3b82f6)"}),e.jsx("stop",{offset:"100%",stopColor:x.nodeMap.get(g.link.target)?.color||"var(--color-error, #ef4444)"})]},v))}),e.jsx("g",{className:"nice-sankey-links",children:x.linkPaths.map((g,v)=>e.jsx("path",{d:g.path,fill:g.link.color||`url(#sankey-gradient-${v})`,fillOpacity:.4,className:"nice-sankey-link",onClick:()=>w?.(g.link),onMouseEnter:_=>$(`${x.nodeMap.get(g.link.source)?.name} → ${x.nodeMap.get(g.link.target)?.name}: ${g.link.value.toLocaleString()}`,_),onMouseLeave:()=>i(null)},v))}),e.jsx("g",{className:"nice-sankey-nodes",children:Array.from(x.nodePositions.entries()).map(([g,v])=>{const _=x.nodeMap.get(g);return _?e.jsxs("g",{children:[e.jsx("rect",{x:v.x,y:v.y,width:s,height:v.height,fill:_.color||"var(--color-primary, #3b82f6)",rx:2,className:"nice-sankey-node",onClick:()=>L?.(_),onMouseEnter:y=>$(`${_.label??_.name??_.id}: ${x.nodeValues.get(g)?.toLocaleString()||0}`,y),onMouseLeave:()=>i(null)}),e.jsxs("text",{x:v.x+s+6,y:v.y+v.height/2,dominantBaseline:"middle",fontSize:"12",fill:"var(--nice-text, #374151)",children:[_.label??_.name??_.id,p&&` (${x.nodeValues.get(g)?.toLocaleString()||0})`]})]},g):null})})]}),M&&e.jsx("div",{className:"nice-sankey-tooltip",style:{left:M.x+10,top:M.y-30},children:M.content}),e.jsx("style",{children:`
|
|
566
|
+
.nice-sankey-chart {
|
|
567
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
568
|
+
background: white;
|
|
569
|
+
border-radius: var(--nice-radius-lg, 8px);
|
|
570
|
+
position: relative;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
.nice-sankey-title {
|
|
574
|
+
padding: var(--nice-space-3, 12px) var(--nice-space-4, 16px);
|
|
575
|
+
font-size: 16px;
|
|
576
|
+
font-weight: 600;
|
|
577
|
+
color: var(--nice-text, #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: var(--nice-text, #1f2937);
|
|
602
|
+
color: white;
|
|
603
|
+
padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
|
|
604
|
+
border-radius: var(--nice-radius-sm, 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:b=1e3,fetchData:p,width:C=600,height:L=200,chartType:w="line",color:f="var(--color-primary, #3b82f6)",showGrid:N=!0,showTimeAxis:I=!0,showCurrentValue:S=!0,title:M,valueFormatter:i=z=>z.toFixed(2),timeFormatter:h=z=>new Date(z).toLocaleTimeString(),onDataUpdate:x,paused:$,className:g,style:v,..._}=t,[y,u]=o.useState(l??d??[]),[D,a]=o.useState($||!1),j=o.useRef();o.useEffect(()=>{$!==void 0&&a($)},[$]),o.useEffect(()=>{if(D||!p)return;const z=async()=>{try{const X=await p();u(ne=>{const de=[...ne,X].slice(-s);return x?.(de),de})}catch(X){console.error("Failed to fetch realtime data:",X)}};return j.current=setInterval(z,b),()=>{j.current&&clearInterval(j.current)}},[D,p,b,s,x]);const A=o.useCallback(z=>{u(X=>{const ne=[...X,z].slice(-s);return x?.(ne),ne})},[s,x]),O=o.useCallback(()=>{u([]),x?.([])},[x]),Z=o.useCallback(()=>a(!0),[]),U=o.useCallback(()=>a(!1),[]);o.useImperativeHandle(c,()=>({addDataPoint:A,clearData:O,pause:Z,resume:U,getData:()=>y}),[A,O,y]);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=y.map(z=>z.value),J=q.length?Math.min(...q):0,n=q.length?Math.max(...q):100,Y=(n-J||1)*.1,B=J-Y,P=n+Y-B,F=z=>{const X=p?s-1:Math.max(1,y.length-1);return V.left+z/X*G},ee=z=>V.top+Q-(z-B)/P*Q,E=y.map((z,X)=>`${F(X)},${ee(z.value)}`).join(" "),te=y.length>0?`M ${F(0)},${V.top+Q} L ${E} L ${F(y.length-1)},${V.top+Q} Z`:"",ue=y.length>0?y[y.length-1].value:null;return e.jsxs("div",{className:`nice-realtime-chart ${g||""}`,style:{width:C,...v},..._,children:[M&&e.jsxs("div",{className:"nice-realtime-header",children:[e.jsx("span",{className:"nice-realtime-title",children:M}),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:"var(--nice-border, #e5e7eb)",strokeDasharray:z===0?void 0:"3"}),e.jsx("text",{x:V.left-8,y:ne,textAnchor:"end",dominantBaseline:"middle",fontSize:"10",fill:"var(--nice-text-secondary, #6b7280)",children:i(de)})]},X)})}),w==="area"&&y.length>0&&e.jsx("path",{d:te,fill:f,fillOpacity:.2}),y.length>1&&e.jsx("polyline",{points:E,fill:"none",stroke:f,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),y.length>0&&e.jsx("circle",{cx:F(y.length-1),cy:ee(y[y.length-1].value),r:4,fill:f,className:"nice-realtime-point"}),I&&y.length>0&&e.jsx("g",{className:"nice-realtime-time-axis",children:[0,Math.floor(y.length/2),y.length-1].filter(z=>y[z]).map(z=>e.jsx("text",{x:F(z),y:L-8,textAnchor:"middle",fontSize:"10",fill:"var(--nice-text-secondary, #6b7280)",children:h(y[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: var(--nice-radius-lg, 8px);
|
|
615
|
+
position: relative;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
.nice-realtime-header {
|
|
619
|
+
display: flex;
|
|
620
|
+
justify-content: space-between;
|
|
621
|
+
align-items: center;
|
|
622
|
+
padding: var(--nice-space-3, 12px) var(--nice-space-4, 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: var(--nice-text, #111827);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
.nice-realtime-controls {
|
|
633
|
+
display: flex;
|
|
634
|
+
align-items: center;
|
|
635
|
+
gap: var(--nice-space-3, 12px);
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
.nice-realtime-btn {
|
|
639
|
+
background: none;
|
|
640
|
+
border: none;
|
|
641
|
+
cursor: pointer;
|
|
642
|
+
font-size: 16px;
|
|
643
|
+
padding: var(--nice-space-1, 4px);
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
.nice-realtime-value {
|
|
647
|
+
font-size: 18px;
|
|
648
|
+
font-weight: 600;
|
|
649
|
+
color: ${f};
|
|
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: var(--nice-space-1-5, 6px);
|
|
670
|
+
font-size: 11px;
|
|
671
|
+
color: var(--nice-text-secondary, #6b7280);
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
.nice-realtime-status-dot {
|
|
675
|
+
width: 8px;
|
|
676
|
+
height: 8px;
|
|
677
|
+
border-radius: var(--nice-radius-full, 50%);
|
|
678
|
+
background: var(--nice-success, #22c55e);
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
.nice-realtime-status.paused .nice-realtime-status-dot {
|
|
682
|
+
background: var(--nice-warning, #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 mt=({data:t,width:c=600,height:l=400,showLabels:d=!0,showValues:s=!0,onNodeClick:b,drilldownEnabled:p=!0,colors:C=Be,tilePadding:L=2,className:w,style:f,...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,M]=o.useState(I),[i,h]=o.useState([I.name]),[x,$]=o.useState(null),g=o.useRef(null),v=o.useMemo(()=>{const j=S.children||[];if(j.length===0)return[];const 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,H=[];const Y=J?Q:G;for(let P=q;P<O.length;P++){const F=[...H,O[P]],ee=F.reduce((te,ue)=>te+ue.area,0),E=_(F,ee,Y);if(H.length===0)H=F,n=ee;else{const te=_(H,n,Y);if(E<=te)H=F,n=ee;else break}}const B=n/Y;let m=0;H.forEach((P,F)=>{const ee=P.area/B;Z.push({node:P.node,x:J?U:U+m,y:J?V+m:V,w:J?B:ee,h:J?ee:B,color:P.node.color||C[(q+F)%C.length]}),m+=ee}),J?(U+=B,G-=B):(V+=B,Q-=B),q+=H.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 y=a=>{b?.(a,[...i,a.name]),p&&a.children&&a.children.length>0&&(M(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)}M(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 ${w||""}`,style:{width:c,...f},...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:v.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:()=>y(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:"var(--nice-overlay-light-80, rgba(255, 255, 255, 0.8))",style:{pointerEvents:"none"},children:A.value.toLocaleString()})]},j)})}),x&&e.jsx("div",{className:"nice-treemap-tooltip",style:{left:x.x+10,top:x.y-30},children:x.content}),e.jsx("style",{children:`
|
|
694
|
+
.nice-treemap-chart {
|
|
695
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
696
|
+
background: white;
|
|
697
|
+
border-radius: var(--nice-radius-lg, 8px);
|
|
698
|
+
position: relative;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
.nice-treemap-nav {
|
|
702
|
+
display: flex;
|
|
703
|
+
align-items: center;
|
|
704
|
+
gap: var(--nice-space-3, 12px);
|
|
705
|
+
padding: var(--nice-space-3, 12px) var(--nice-space-4, 16px);
|
|
706
|
+
border-bottom: 1px solid var(--border-color, #e5e7eb);
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
.nice-treemap-back {
|
|
710
|
+
background: var(--nice-bg-secondary, #f3f4f6);
|
|
711
|
+
border: none;
|
|
712
|
+
padding: var(--nice-space-1-5, 6px) var(--nice-space-3, 12px);
|
|
713
|
+
border-radius: var(--nice-radius-md, 6px);
|
|
714
|
+
cursor: pointer;
|
|
715
|
+
font-size: 13px;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
.nice-treemap-back:hover {
|
|
719
|
+
background: var(--nice-border, #e5e7eb);
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
.nice-treemap-breadcrumbs {
|
|
723
|
+
display: flex;
|
|
724
|
+
align-items: center;
|
|
725
|
+
gap: var(--nice-space-1, 4px);
|
|
726
|
+
font-size: 13px;
|
|
727
|
+
color: var(--nice-text-secondary, #6b7280);
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
.nice-treemap-breadcrumbs .current {
|
|
731
|
+
color: var(--nice-text, #111827);
|
|
732
|
+
font-weight: 500;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
.nice-treemap-sep {
|
|
736
|
+
color: var(--nice-text-muted, #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: var(--nice-text, #1f2937);
|
|
751
|
+
color: white;
|
|
752
|
+
padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
|
|
753
|
+
border-radius: var(--nice-radius-sm, 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:b="top-down",collapsible:p=!0,className:C,style:L,id:w},f)=>{const N=we.Ss(w),[I,S]=o.useState(new Set),M=o.useCallback(x=>{S($=>{const g=new Set($);return g.has(x)?g.delete(x):g.add(x),g})},[]),i=o.useCallback(x=>{l&&s?.(x)},[l,s]),h=o.useCallback(x=>{const $=I.has(x.key),g=x.children&&x.children.length>0;return e.jsxs("li",{className:"nice-org-chart__item",children:[e.jsxs("div",{className:`nice-org-chart__node${d===x.key?" nice-org-chart__node--selected":""}`,onClick:()=>i(x.key),role:l?"button":void 0,children:[c?c(x):e.jsx("span",{children:x.label}),p&&g&&e.jsx("button",{type:"button",className:"nice-org-chart__toggle",onClick:v=>{v.stopPropagation(),M(x.key)},"aria-label":$?"Expand":"Collapse",children:$?"+":"−"})]}),g&&!$&&e.jsx("ul",{className:"nice-org-chart__children",children:x.children.map(v=>h(v))})]},x.key)},[I,d,c,l,p,i,M]);return e.jsx("div",{ref:f,id:N,className:`nice-org-chart nice-org-chart--${b} ${C||""}`,style:L,children:e.jsx("ul",{className:"nice-org-chart__root",children:h(t)})})});Oe.displayName="NiceOrganizationChart";function pt(t,c,l){const d=S=>{const M=S.replace("#","");return[parseInt(M.slice(0,2),16),parseInt(M.slice(2,4),16),parseInt(M.slice(4,6),16)]},[s,b,p]=d(t),[C,L,w]=d(c),f=Math.round(s+(C-s)*l),N=Math.round(b+(L-b)*l),I=Math.round(p+(w-p)*l);return`rgb(${f},${N},${I})`}const Pe=o.forwardRef(({data:t,xLabels:c,yLabels:l,colors:d=["var(--nice-primary-bg, #e0f2fe)","var(--color-primary-active, #1d4ed8)"],onCellClick:s,cellSize:b=40,showValues:p=!0,className:C,style:L,id:w},f)=>{const N=we.Ss(w),{minVal:I,maxVal:S}=o.useMemo(()=>{let i=1/0,h=-1/0;for(const x of t)for(const $ of x)$<i&&(i=$),$>h&&(h=$);return{minVal:i,maxVal:h}},[t]),M=o.useCallback(i=>S===I?.5:(i-I)/(S-I),[I,S]);return e.jsx("div",{ref:f,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((x,$)=>e.jsx("td",{className:"nice-heatmap__cell",style:{background:pt(d[0],d[1],M(x)),width:b,height:b,textAlign:"center",color:M(x)>.6?"var(--bg-primary, #fff)":"var(--bg-tertiary, #333)",cursor:s?"pointer":void 0},onClick:()=>s?.(h,$,x),title:String(x),children:p?x:""},$))]},h))})]})})});Pe.displayName="NiceHeatMap";function ft(t,c){const l=t.reduce((w,f)=>w+f.value,0);if(l===0||t.length===0)return[];const d=[];let{x:s,y:b,w:p,h:C}=c;const L=[...t].sort((w,f)=>f.value-w.value);for(const w of L){const f=w.value/l;if(p>=C){const N=p*f;d.push({x:s,y:b,w:N,h:C,node:w}),s+=N,p-=N}else{const N=C*f;d.push({x:s,y:b,w:p,h:N,node:w}),b+=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)","var(--nice-success, #84cc16)"],Ae=o.forwardRef(({data:t,width:c=600,height:l=400,onNodeClick:d,colors:s=gt,className:b,style:p,id:C},L)=>{const w=we.Ss(C),f=o.useMemo(()=>{const N=t.children??[t];return ft(N,{x:0,y:0,w:c,h:l})},[t,c,l]);return e.jsx("div",{ref:L,id:w,className:`nice-treemap ${b||""}`,style:p,children:e.jsx("svg",{width:c,height:l,className:"nice-treemap__svg",children:f.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:"var(--nice-bg, #fff)",fontSize:Math.min(12,N.w/6),className:"nice-treemap__label",children:N.node.label})]},N.node.key))})})});Ae.displayName="NiceTreeMap";const vt=Object.freeze(Object.defineProperty({__proto__:null,NiceTreeMap:Ae},Symbol.toStringTag,{value:"Module"})),Fe=o.forwardRef(({data:t,type:c="candlestick",showVolume:l=!0,width:d=800,height:s=400,bullColor:b="var(--color-success, #22c55e)",bearColor:p="var(--color-error, #ef4444)",className:C,style:L,id:w},f)=>{const N=we.Ss(w),I={top:20,right:20,bottom:l?80:30,left:60},S=d-I.left-I.right,M=l?50:0,i=s-I.top-I.bottom-M,{minP:h,maxP:x,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),v=u=>I.left+(u+.5)*(S/t.length),_=u=>I.top+i-(u-h)/(x-h||1)*i,y=u=>s-I.bottom-M+M*(1-u/($||1));return e.jsx("div",{ref:f,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*(x-h);return e.jsxs("g",{children:[e.jsx("line",{x1:I.left,x2:d-I.right,y1:_(D),y2:_(D),stroke:"var(--nice-border, #e5e7eb)",strokeDasharray:"2,2"}),e.jsx("text",{x:I.left-4,y:_(D)+4,textAnchor:"end",fontSize:10,fill:"var(--nice-text-secondary, #888)",children:D.toFixed(2)})]},u)}),c==="line"?e.jsx("polyline",{points:t.map((u,D)=>`${v(D)},${_(u.close)}`).join(" "),fill:"none",stroke:b,strokeWidth:1.5}):t.map((u,D)=>{const a=u.close>=u.open,j=a?b:p,A=v(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:v(D)-g/2,y:y(u.volume),width:g,height:s-I.bottom-y(u.volume),fill:a?b:p,opacity:.3},`v${D}`)}),t.map((u,D)=>D%Math.max(1,Math.floor(t.length/8))!==0?null:e.jsx("text",{x:v(D),y:s-I.bottom+M+14,textAnchor:"middle",fontSize:9,fill:"var(--nice-text-secondary, #888)",children:u.date},`l${D}`))]})})});Fe.displayName="NiceStockChart";exports.CHART_COLORS=pe;exports.NiceBarGauge=nt;exports.NiceBullet=st;exports.NiceChart=ke;exports.NiceChart$1=He;exports.NiceChartAI=Ze;exports.NiceCircularGauge=et;exports.NiceDrillDownChart=We;exports.NiceForecastChart=ht;exports.NiceFunnel=ct;exports.NiceHeatMap=Pe;exports.NiceLinearGauge=tt;exports.NiceLiveChart=Re;exports.NiceMapChart=ut;exports.NiceOrganizationChart=Oe;exports.NicePieChart=Ke;exports.NicePolarChart=Qe;exports.NiceRangeSelector=it;exports.NiceRealtimeChart=Ee;exports.NiceSankey=De;exports.NiceSankey$1=ot;exports.NiceSankeyChart=xt;exports.NiceSparkline=rt;exports.NiceStockChart=Fe;exports.NiceTreeMap=Ae;exports.NiceTreeMap$1=vt;exports.NiceTreeMapChart=mt;exports.NiceVectorMap=Te;exports.NiceVectorMap$1=lt;exports.createMockLiveChartSource=Je;exports.createSignalRLiveChartSource=Ge;exports.createWebSocketLiveChartSource=qe;
|