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