@nice2dev/ui-diagrams 1.0.5 → 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.
@@ -0,0 +1,287 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),N=require("react"),ge=require("./index-Gq4eeeO7.cjs"),be=["#3b82f6","#ef4444","#22c55e","#f59e0b","#8b5cf6","#ec4899","#06b6d4","#84cc16"],je=({series:t,categories:h,width:l=600,height:s=400,title:n,showLegend:g=!0,showGrid:f=!0,yAxisLabel:$,xAxisLabel:v,stacked:p,zoomable:w,crosshair:m,annotations:y,legendInteractive:j,onDataPointClick:b,exportable:r,className:d,style:i})=>{var xe,me;const S=N.useRef(null),[_,A]=N.useState(new Set),[x,D]=N.useState(null),[o,T]=N.useState(null),[c,P]=N.useState(!1),I=N.useRef(null),O=N.useMemo(()=>t.filter(k=>!_.has(k.name)),[t,_]),U=N.useCallback(k=>{j&&A(X=>{const E=new Set(X);return E.has(k)?E.delete(k):E.add(k),E})},[j]),L={top:n?40:20,right:20,bottom:v?60:40,left:$?60:50},Z=l-L.left-L.right,F=s-L.top-L.bottom,q=((xe=O[0])==null?void 0:xe.data.length)??((me=t[0])==null?void 0:me.data.length)??0,V=(o==null?void 0:o.start)??0,ie=(o==null?void 0:o.end)??q,K=ie-V,te=N.useMemo(()=>O.map(k=>({...k,data:k.data.slice(V,ie)})),[O,V,ie]),C=N.useMemo(()=>h==null?void 0:h.slice(V,ie),[h,V,ie]),{minY:W,maxY:ae,yTicks:G}=N.useMemo(()=>{let k;if(p){k=[];for(let B=0;B<K;B++)k.push(te.reduce((ne,he)=>ne+(he.data[B]||0),0))}else k=te.flatMap(B=>B.data);k.length===0&&(k=[0]);const X=Math.min(0,...k),E=Math.max(0,...k),re=E-X||1,a=Math.pow(10,Math.floor(Math.log10(re)))||1,M=Math.floor(X/a)*a,z=Math.ceil(E/a)*a,u=[];for(let B=M;B<=z;B+=a)u.push(Math.round(B*1e6)/1e6);return u.length<2&&u.push(z),{minY:M,maxY:z,yTicks:u}},[te,K,p]),H=k=>F-(k-W)/(ae-W||1)*F,Q=k=>(k+.5)/K*Z,fe=K>0?Z/K/(p?1.5:Math.max(O.length,1)*1.5):20,pe=N.useCallback(k=>{if(!w)return;k.preventDefault();const X=o??{start:0,end:q},E=X.end-X.start,re=(X.start+X.end)/2,a=k.deltaY>0?1.2:.8,M=Math.max(2,Math.min(q,Math.round(E*a))),z=Math.max(0,Math.round(re-M/2)),u=Math.min(q,z+M);T({start:z,end:u})},[w,o,q]),de=N.useCallback(k=>{w&&(P(!0),I.current={x:k.clientX,range:o??{start:0,end:q}})},[w,o,q]),R=N.useCallback(k=>{var E;const X=(E=S.current)==null?void 0:E.getBoundingClientRect();if(X&&D({x:k.clientX-X.left-L.left,y:k.clientY-X.top-L.top}),c&&I.current&&w){const re=k.clientX-I.current.x,a=Z/K,M=-Math.round(re/a),z=I.current.range,u=z.end-z.start;let B=z.start+M;B<0&&(B=0),B+u>q&&(B=q-u),T({start:B,end:B+u})}},[c,w,Z,K,q,L.left,L.top]),Y=N.useCallback(()=>{P(!1),I.current=null},[]),J=N.useCallback(()=>{D(null),P(!1),I.current=null},[]),ue=N.useCallback(()=>{const k=S.current;if(!k)return;const X=new XMLSerializer().serializeToString(k),E=document.createElement("canvas");E.width=l,E.height=s+(g?30:0);const re=E.getContext("2d");if(!re)return;const a=new Image;a.onload=()=>{re.fillStyle="#fff",re.fillRect(0,0,E.width,E.height),re.drawImage(a,0,0);const M=document.createElement("a");M.download="chart.png",M.href=E.toDataURL("image/png"),M.click()},a.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(X)},[l,s,g]);return e.jsxs("div",{className:`nice-chart ${d||""}`,style:i,children:[r&&e.jsx("button",{type:"button",className:"nice-chart__export-btn",onClick:ue,title:"Export PNG",children:"📷"}),e.jsxs("svg",{ref:S,width:l,height:s+(g?30:0),className:"nice-chart__svg",onWheel:pe,onMouseDown:de,onMouseMove:R,onMouseUp:Y,onMouseLeave:J,children:[e.jsxs("g",{transform:`translate(${L.left},${L.top})`,children:[n&&e.jsx("text",{x:Z/2,y:-10,textAnchor:"middle",className:"nice-chart__title",children:n}),f&&G.map(k=>e.jsxs("g",{children:[e.jsx("line",{x1:0,y1:H(k),x2:Z,y2:H(k),className:"nice-chart__grid-line"}),e.jsx("text",{x:-8,y:H(k)+4,textAnchor:"end",className:"nice-chart__axis-label",children:k})]},k)),C&&C.map((k,X)=>e.jsx("text",{x:Q(X),y:F+20,textAnchor:"middle",className:"nice-chart__axis-label",children:k},X)),$&&e.jsx("text",{x:-L.left+14,y:F/2,textAnchor:"middle",transform:`rotate(-90, -${L.left-14}, ${F/2})`,className:"nice-chart__axis-title",children:$}),v&&e.jsx("text",{x:Z/2,y:F+45,textAnchor:"middle",className:"nice-chart__axis-title",children:v}),e.jsx("line",{x1:0,y1:0,x2:0,y2:F,className:"nice-chart__axis"}),e.jsx("line",{x1:0,y1:F,x2:Z,y2:F,className:"nice-chart__axis"}),y==null?void 0:y.map((k,X)=>{if(k.type==="line"){const E=H(k.value);return e.jsxs("g",{children:[e.jsx("line",{x1:0,y1:E,x2:Z,y2:E,stroke:k.color||"#ef4444",strokeWidth:1.5,strokeDasharray:k.dash||"6,3"}),k.label&&e.jsx("text",{x:Z+4,y:E+4,className:"nice-chart__annotation-label",fill:k.color||"#ef4444",children:k.label})]},X)}return e.jsx("text",{x:Q(k.value),y:-4,textAnchor:"middle",className:"nice-chart__annotation-label",fill:k.color||"#6b7280",children:k.label},X)}),m&&x&&x.x>=0&&x.x<=Z&&x.y>=0&&x.y<=F&&e.jsxs(e.Fragment,{children:[e.jsx("line",{x1:x.x,y1:0,x2:x.x,y2:F,stroke:"#9ca3af",strokeWidth:1,strokeDasharray:"4,2"}),e.jsx("line",{x1:0,y1:x.y,x2:Z,y2:x.y,stroke:"#9ca3af",strokeWidth:1,strokeDasharray:"4,2"})]}),te.map((k,X)=>{const E=k.color||be[X%be.length],re=k.type||"bar";if(re==="bar")return e.jsx("g",{children:k.data.map((M,z)=>{let u,B;if(p){const he=te.slice(0,X).reduce((le,se)=>le+(se.data[z]||0),0);u=H(he+M),B=H(he)-u}else u=H(Math.max(0,M)),B=Math.abs(H(M)-H(0));const ne=p?Q(z)-fe/2:Q(z)-te.length*fe/2+X*fe;return e.jsx("rect",{x:ne,y:u,width:fe*.9,height:Math.max(0,B),fill:E,rx:2,style:b?{cursor:"pointer"}:void 0,onClick:b?()=>b(k.name,V+z,M):void 0,children:e.jsx("title",{children:`${k.name}: ${M}`})},z)})},k.name);const a=k.data.map((M,z)=>`${Q(z)},${H(M)}`);return e.jsxs("g",{children:[re==="area"&&e.jsx("polygon",{points:`${Q(0)},${H(0)} ${a.join(" ")} ${Q(K-1)},${H(0)}`,fill:E,opacity:.15}),e.jsx("polyline",{points:a.join(" "),fill:"none",stroke:E,strokeWidth:2}),k.data.map((M,z)=>e.jsx("circle",{cx:Q(z),cy:H(M),r:3,fill:E,style:b?{cursor:"pointer"}:void 0,onClick:b?()=>b(k.name,V+z,M):void 0,children:e.jsx("title",{children:`${k.name}: ${M}`})},z))]},k.name)})]}),g&&e.jsx("g",{transform:`translate(${L.left}, ${s})`,children:t.map((k,X)=>{const E=X*120,re=_.has(k.name);return e.jsxs("g",{transform:`translate(${E}, 10)`,style:j?{cursor:"pointer"}:void 0,onClick:()=>U(k.name),opacity:re?.35:1,children:[e.jsx("rect",{width:12,height:12,rx:2,fill:k.color||be[X%be.length]}),e.jsx("text",{x:16,y:10,className:"nice-chart__legend-text",style:re?{textDecoration:"line-through"}:void 0,children:k.name})]},k.name)})})]})]})},Re=Object.freeze(Object.defineProperty({__proto__:null,NiceChart:je},Symbol.toStringTag,{value:"Module"}));function Be(t){if(!t.length)return{categories:[],numericFields:[],sampleValues:{}};const h=t[0],l=[],s={};let n=null;for(const[g,f]of Object.entries(h))typeof f=="number"?(l.push(g),s[g]=t.map($=>Number($[g])||0)):!n&&(typeof f=="string"||f instanceof Date)&&(n=g);return{categories:n?t.map(g=>String(g[n]||"")):t.map((g,f)=>`Item ${f+1}`),numericFields:l,sampleValues:s}}function Te(t,h){const{categories:l,numericFields:s,sampleValues:n}=Be(t);return{series:s.map((g,f)=>({name:g.replace(/([A-Z])/g," $1").replace(/^./,$=>$.toUpperCase()).trim(),data:n[g],type:h==="area"?"area":h==="line"?"line":"bar"})),categories:l}}N.forwardRef(function(t,h){const{rawData:l,enableAI:s=!0,aiModel:n,enableAutoType:g=!0,enableInsights:f=!0,dataDescription:$,onChartSuggestion:v,onInsights:p,showAIToolbar:w=!0,showInsightsOnLoad:m=!1,series:y,categories:j,...b}=t,[r,d]=N.useState("bar"),[i,S]=N.useState(null),[_,A]=N.useState([]),[x,D]=N.useState(m),[o,T]=N.useState(null),{t:c}=ge.a(),P=ge.ue(),{suggestChartType:I,generateInsights:O,isLoading:U}=ge.fi$1(),L=s&&P.isConfigured,{series:Z,categories:F}=l?Te(l,o||r):{series:y||[],categories:j},q=N.useCallback(async()=>{if(!L||!g)return{type:"bar",reason:"Default",config:{}};const C=l||(y!=null&&y.length?y.flatMap(W=>W.data.map((ae,G)=>({[W.name]:ae,index:G}))):[]);try{const W=await I(C,$),ae={type:W.type,reason:W.reason,config:W.config};return S(ae),d(ae.type),v==null||v(ae),ae}catch{return{type:"bar",reason:"Default fallback",config:{}}}},[L,g,l,y,$,I,v]),V=N.useCallback(async()=>{if(!L||!f)return[];const C=l||(y!=null&&y.length?y.flatMap(W=>W.data.map((ae,G)=>({[W.name]:ae,category:(j==null?void 0:j[G])||G}))):[]);try{const W=await O(C,o||r);return A(W),p==null||p(W),W}catch{return[]}},[L,f,l,y,j,r,o,O,p]),ie=N.useCallback(()=>o||r,[o,r]);N.useEffect(()=>{L&&g&&(l!=null&&l.length||y!=null&&y.length)&&q()},[L,g,l,y]),N.useImperativeHandle(h,()=>({getSuggestion:q,generateInsights:V,getCurrentType:ie}));const K=[{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"}],te=o||r;return e.jsxs("div",{className:"nice-chart-ai","data-testid":t["data-testid"],children:[w&&L&&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:[c("chartAI.suggestedType","Suggested:")," ",i.type]}),e.jsxs("span",{className:"nice-chart-ai__suggestion-reason",title:i.reason,children:["(",i.reason,")"]})]}),U&&e.jsx("span",{className:"nice-chart-ai__loading",children:c("chartAI.analyzing","Analyzing...")})]}),e.jsx("div",{className:"nice-chart-ai__toolbar-center",children:e.jsx("div",{className:"nice-chart-ai__type-selector",children:K.filter(C=>["bar","line","area"].includes(C.type)).map(({type:C,icon:W,label:ae})=>e.jsx("button",{type:"button",className:`nice-chart-ai__type-btn ${te===C?"nice-chart-ai__type-btn--active":""}`,onClick:()=>T(C),title:ae,children:W},C))})}),e.jsxs("div",{className:"nice-chart-ai__toolbar-right",children:[e.jsxs("button",{type:"button",className:"nice-chart-ai__auto-btn",onClick:()=>q(),disabled:U,title:c("chartAI.autoDetect","Auto-detect best chart type"),children:["🔮 ",c("chartAI.auto","Auto")]}),f&&e.jsxs("button",{type:"button",className:"nice-chart-ai__insights-btn",onClick:()=>{_.length||V(),D(!x)},disabled:U,title:c("chartAI.showInsights","Show data insights"),children:["💡 ",c("chartAI.insights","Insights")]})]})]}),e.jsx("div",{className:"nice-chart-ai__chart-wrapper",children:e.jsx(je,{series:Z,categories:F,...b})}),x&&_.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:["💡 ",c("chartAI.dataInsights","Data Insights")]}),e.jsx("button",{type:"button",className:"nice-chart-ai__insights-close",onClick:()=>D(!1),children:"✕"})]}),e.jsx("ul",{className:"nice-chart-ai__insights-list",children:_.map((C,W)=>e.jsxs("li",{className:"nice-chart-ai__insight",children:[e.jsx("span",{className:"nice-chart-ai__insight-icon",children:"•"}),C]},W))}),e.jsx("div",{className:"nice-chart-ai__insights-footer",children:e.jsxs("button",{type:"button",className:"nice-chart-ai__refresh",onClick:()=>V(),disabled:U,children:["🔄 ",c("chartAI.refresh","Refresh")]})})]}),x&&U&&e.jsx("div",{className:"nice-chart-ai__insights nice-chart-ai__insights--loading",children:e.jsxs("div",{className:"nice-chart-ai__loading-content",children:[e.jsx("span",{className:"nice-chart-ai__spinner"}),c("chartAI.generatingInsights","Generating insights...")]})})]})});function Pe(t,h){const l=t?typeof t=="number"?new Date(t):new Date(t):new Date,s=v=>v.toString().padStart(2,"0"),n=s(l.getHours()),g=s(l.getMinutes()),f=s(l.getSeconds()),$=l.getMilliseconds().toString().padStart(3,"0");switch(h){case"HH:mm:ss":return`${n}:${g}:${f}`;case"HH:mm":return`${n}:${g}`;case"mm:ss":return`${g}:${f}`;case"ss.SSS":return`${f}.${$}`;case"ISO":return l.toISOString();default:return`${n}:${g}:${f}`}}function Me(t){if(t.length===0)return null;const h=Math.min(...t),l=Math.max(...t),s=t.reduce((g,f)=>g+f,0)/t.length,n=t[t.length-1];return{min:h,max:l,avg:s,current:n,count:t.length}}const Se=N.forwardRef(({series:t,maxPoints:h=100,slidingWindow:l=!0,refreshRate:s=16,dataSource:n,width:g=600,height:f=400,title:$,showLegend:v=!0,showGrid:p=!0,yAxisLabel:w,xAxisLabel:m,stacked:y,zoomable:j,crosshair:b,annotations:r=[],legendInteractive:d,onDataPointClick:i,exportable:S,showControls:_=!0,showStatus:A=!0,initialPaused:x=!1,onDataReceived:D,onDataDropped:o,timeFormat:T="HH:mm:ss",showStats:c,thresholds:P=[],className:I,style:O},U)=>{const[L,Z]=N.useState(()=>{var Y;const R=new Map;for(const J of t)R.set(J.name,((Y=J.initialData)==null?void 0:Y.slice())??[]);return R}),[F,q]=N.useState([]),[V,ie]=N.useState(x),[K,te]=N.useState(!1),C=N.useRef([]),W=N.useRef(Date.now()),ae=N.useRef(null),G=N.useCallback(()=>{const R=C.current;R.length!==0&&(C.current=[],Z(Y=>{const J=new Map(Y);for(const ue of R){const xe=J.get(ue.series);if(!xe)continue;const me=[...xe,ue.value];if(l&&me.length>h){const k=me.length-h;o==null||o(k,ue.series),me.splice(0,k)}J.set(ue.series,me)}return J}),R.length>0&&q(Y=>{const J=[...Y];for(const ue of R){const xe=ue.category??Pe(ue.timestamp,T);J.push(xe)}return l&&J.length>h&&J.splice(0,J.length-h),J}))},[l,h,T,o]),H=N.useCallback(()=>{const R=Date.now();R-W.current>=s&&(G(),W.current=R),ae.current=requestAnimationFrame(H)},[s,G]);N.useEffect(()=>(V||(ae.current=requestAnimationFrame(H)),()=>{ae.current!==null&&(cancelAnimationFrame(ae.current),ae.current=null)}),[V,H]);const Q=N.useCallback(R=>{if(V)return;const Y="points"in R?R.points:[R];for(const J of Y)L.has(J.series)&&(C.current.push(J),D==null||D(J))},[V,L,D]);N.useEffect(()=>{if(!n)return;const R=n.subscribe(Q);let Y;return n.onStatusChange?Y=n.onStatusChange(te):te(!0),n.fetchHistory&&n.fetchHistory(h).then(J=>{for(const ue of J)C.current.push(ue);G()}),()=>{R(),Y==null||Y()}},[n,Q,h,G]);const fe=N.useMemo(()=>t.map(R=>({name:R.name,color:R.color,type:R.type,data:L.get(R.name)??[]})),[t,L]),pe=N.useMemo(()=>{const R=[...r];for(const Y of P)R.push({type:"line",value:Y.value,color:Y.color,label:Y.label,dash:Y.style==="dashed"?"5,5":Y.style==="dotted"?"2,2":void 0});return R},[r,P]);N.useImperativeHandle(U,()=>({pause(){ie(!0)},resume(){ie(!1)},isPaused(){return V},clear(){Z(R=>{const Y=new Map(R);for(const J of Y.keys())Y.set(J,[]);return Y}),q([]),C.current=[]},addPoint(R){Q(R)},addPoints(R){Q({points:R})},getData(R){return L.get(R)??[]},getCategories(){return F},exportData(){return{series:fe,categories:F}},getStats(R){const Y=L.get(R);return Y?Me(Y):null}}),[V,L,F,fe,Q]);const de=N.useMemo(()=>{if(!c)return null;const R={};for(const[Y,J]of L)R[Y]=Me(J);return R},[c,L]);return e.jsxs("div",{className:I,style:{position:"relative",...O},children:[A&&e.jsxs("div",{style:{position:"absolute",top:8,right:8,display:"flex",alignItems:"center",gap:4,fontSize:12,color:K?"#22c55e":"#ef4444",zIndex:10},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:K?"#22c55e":"#ef4444"}}),K?"Live":"Disconnected"]}),_&&e.jsx("div",{style:{position:"absolute",top:8,left:8,display:"flex",gap:4,zIndex:10},children:e.jsx("button",{onClick:()=>ie(R=>!R),style:{padding:"4px 8px",fontSize:12,border:"1px solid #ddd",borderRadius:4,background:V?"#fef3c7":"#fff",cursor:"pointer"},title:V?"Resume":"Pause",children:V?"▶":"⏸"})}),c&&de&&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(de).map(([R,Y])=>Y?e.jsxs("div",{style:{marginBottom:4},children:[e.jsx("strong",{children:R}),e.jsxs("div",{children:["Min: ",Y.min.toFixed(2)," | Max: ",Y.max.toFixed(2)]}),e.jsxs("div",{children:["Avg: ",Y.avg.toFixed(2)," | Now: ",Y.current.toFixed(2)]})]},R):null)}),e.jsx(je,{series:fe,categories:F,width:g,height:f,title:$,showLegend:v,showGrid:p,yAxisLabel:w,xAxisLabel:m,stacked:y,zoomable:j,crosshair:b,annotations:pe,legendInteractive:d,onDataPointClick:i,exportable:S})]})});Se.displayName="NiceLiveChart";const oe=["#3b82f6","#ef4444","#22c55e","#f59e0b","#8b5cf6","#ec4899","#06b6d4","#84cc16"],We=({data:t,width:h=400,height:l=400,innerRadius:s=0,title:n,showLegend:g=!0,showLabels:f=!0,className:$,style:v})=>{const p=h/2,w=(l-(g?30:0))/2+(n?10:0),m=Math.min(p,w)-40,y=t.reduce((r,d)=>r+d.value,0);let j=-Math.PI/2;const b=t.map((r,d)=>{const i=r.value/(y||1)*Math.PI*2,S=j;j+=i;const _=j,A=(S+_)/2,x=p+m*Math.cos(S),D=w+m*Math.sin(S),o=p+m*Math.cos(_),T=w+m*Math.sin(_),c=i>Math.PI?1:0,P=r.color||oe[d%oe.length];let I;if(s>0){const Z=p+s*Math.cos(S),F=w+s*Math.sin(S),q=p+s*Math.cos(_),V=w+s*Math.sin(_);I=`M${x},${D} A${m},${m} 0 ${c},1 ${o},${T} L${q},${V} A${s},${s} 0 ${c},0 ${Z},${F} Z`}else I=`M${p},${w} L${x},${D} A${m},${m} 0 ${c},1 ${o},${T} Z`;const O=p+m*.7*Math.cos(A),U=w+m*.7*Math.sin(A),L=y>0?Math.round(r.value/y*100):0;return{...r,path:I,labelX:O,labelY:U,pct:L,color:P}});return e.jsx("div",{className:`nice-piechart ${$||""}`,style:v,children:e.jsxs("svg",{width:h,height:l,className:"nice-piechart__svg",children:[n&&e.jsx("text",{x:p,y:20,textAnchor:"middle",className:"nice-chart__title",children:n}),b.map((r,d)=>e.jsxs("g",{children:[e.jsx("path",{d:r.path,fill:r.color,stroke:"var(--bg-primary, #fff)",strokeWidth:2,children:e.jsx("title",{children:`${r.label}: ${r.value} (${r.pct}%)`})}),f&&r.pct>=5&&e.jsxs("text",{x:r.labelX,y:r.labelY,textAnchor:"middle",dominantBaseline:"middle",className:"nice-piechart__label",children:[r.pct,"%"]})]},d)),g&&e.jsx("g",{transform:`translate(10, ${l-25})`,children:t.map((r,d)=>e.jsxs("g",{transform:`translate(${d*100}, 0)`,children:[e.jsx("rect",{width:10,height:10,rx:2,fill:r.color||oe[d%oe.length]}),e.jsx("text",{x:14,y:9,className:"nice-chart__legend-text",children:r.label})]},d))})]})})},Oe=({series:t,categories:h,width:l=400,height:s=400,maxValue:n,title:g,showLegend:f=!0,className:$,style:v})=>{const p=l/2,w=(s-(f?30:0))/2+(g?10:0),m=Math.min(p,w)-40,y=h.length,j=n??Math.max(...t.flatMap(i=>i.data),1),b=Math.PI*2/y,r=5,d=(i,S)=>{const _=i*b-Math.PI/2,A=S/j*m;return{x:p+A*Math.cos(_),y:w+A*Math.sin(_)}};return e.jsx("div",{className:`nice-polarchart ${$||""}`,style:v,children:e.jsxs("svg",{width:l,height:s,className:"nice-polarchart__svg",children:[g&&e.jsx("text",{x:p,y:20,textAnchor:"middle",className:"nice-chart__title",children:g}),Array.from({length:r},(i,S)=>{const _=m*((S+1)/r);return e.jsx("circle",{cx:p,cy:w,r:_,fill:"none",stroke:"var(--border-color, #ddd)",strokeWidth:.5},S)}),h.map((i,S)=>{const _=d(S,j),A=d(S,j*1.12);return e.jsxs("g",{children:[e.jsx("line",{x1:p,y1:w,x2:_.x,y2:_.y,stroke:"var(--border-color, #ddd)",strokeWidth:.5}),e.jsx("text",{x:A.x,y:A.y,textAnchor:"middle",dominantBaseline:"middle",className:"nice-chart__axis-label",children:i})]},S)}),t.map((i,S)=>{const _=i.color||oe[S%oe.length],A=i.data.map((x,D)=>{const o=d(D,x);return`${o.x},${o.y}`}).join(" ");return e.jsxs("g",{children:[e.jsx("polygon",{points:A,fill:i.fill!==!1?_:"none",fillOpacity:.15,stroke:_,strokeWidth:2}),i.data.map((x,D)=>{const o=d(D,x);return e.jsx("circle",{cx:o.x,cy:o.y,r:3,fill:_,children:e.jsx("title",{children:`${i.name} - ${h[D]}: ${x}`})},D)})]},i.name)}),f&&e.jsx("g",{transform:`translate(10, ${s-25})`,children:t.map((i,S)=>e.jsxs("g",{transform:`translate(${S*100}, 0)`,children:[e.jsx("rect",{width:10,height:10,rx:2,fill:i.color||oe[S%oe.length]}),e.jsx("text",{x:14,y:9,className:"nice-chart__legend-text",children:i.name})]},S))})]})})},Ye=({value:t,min:h=0,max:l=100,width:s=200,height:n=200,startAngle:g=225,endAngle:f=-45,color:$="#3b82f6",trackColor:v,label:p,formatValue:w,ranges:m,className:y,style:j})=>{const b=s/2,r=n/2,d=Math.min(b,r)-20,i=Math.max(0,Math.min(1,(t-h)/(l-h||1))),S=c=>c*Math.PI/180,_=(g-f+360)%360||360,A=c=>({x:b+d*Math.cos(S(c)),y:r-d*Math.sin(S(c))}),x=(c,P)=>{const I=A(c),O=A(P),U=(c-P+360)%360>180?1:0;return`M${I.x},${I.y} A${d},${d} 0 ${U},1 ${O.x},${O.y}`},D=g-i*_,o=A(D);let T=$;if(m){for(const c of m)if(t>=c.start&&t<=c.end){T=c.color;break}}return e.jsx("div",{className:`nice-gauge nice-gauge--circular ${y||""}`,style:j,children:e.jsxs("svg",{width:s,height:n,children:[e.jsx("path",{d:x(g,f),fill:"none",stroke:v||"var(--border-color, #e2e8f0)",strokeWidth:12,strokeLinecap:"round"}),i>0&&e.jsx("path",{d:x(g,D),fill:"none",stroke:T,strokeWidth:12,strokeLinecap:"round"}),e.jsx("line",{x1:b,y1:r,x2:o.x,y2:o.y,stroke:"var(--text-primary, #333)",strokeWidth:2,strokeLinecap:"round"}),e.jsx("circle",{cx:b,cy:r,r:4,fill:"var(--text-primary, #333)"}),e.jsx("text",{x:b,y:r+d*.35,textAnchor:"middle",className:"nice-gauge__value",children:w?w(t):t}),p&&e.jsx("text",{x:b,y:r+d*.55,textAnchor:"middle",className:"nice-gauge__label",children:p})]})})},Ee=({value:t,min:h=0,max:l=100,width:s=300,height:n=60,orientation:g="horizontal",color:f="#3b82f6",label:$,formatValue:v,ranges:p,showTicks:w=!0,tickCount:m=5,className:y,style:j})=>{const b=g==="horizontal",r=b?s-40:n-40,d=Math.max(0,Math.min(1,(t-h)/(l-h||1))),i=10;let S=f;if(p){for(const A of p)if(t>=A.start&&t<=A.end){S=A.color;break}}const _=Array.from({length:m},(A,x)=>h+(l-h)*(x/(m-1)));return b?e.jsx("div",{className:`nice-gauge nice-gauge--linear ${y||""}`,style:j,children:e.jsxs("svg",{width:s,height:n,children:[$&&e.jsx("text",{x:s/2,y:14,textAnchor:"middle",className:"nice-gauge__label",children:$}),e.jsx("rect",{x:20,y:n/2-i/2,width:r,height:i,rx:5,fill:"var(--border-color, #e2e8f0)"}),e.jsx("rect",{x:20,y:n/2-i/2,width:r*d,height:i,rx:5,fill:S}),e.jsx("polygon",{points:`${20+r*d},${n/2-i/2-2} ${20+r*d-5},${n/2-i/2-10} ${20+r*d+5},${n/2-i/2-10}`,fill:"var(--text-primary, #333)"}),e.jsx("text",{x:20+r*d,y:n/2-i/2-12,textAnchor:"middle",className:"nice-gauge__value",style:{fontSize:11},children:v?v(t):t}),w&&_.map((A,x)=>{const D=20+(A-h)/(l-h)*r;return e.jsx("text",{x:D,y:n/2+i/2+14,textAnchor:"middle",className:"nice-gauge__tick",children:A},x)})]})}):e.jsx("div",{className:`nice-gauge nice-gauge--linear nice-gauge--vertical ${y||""}`,style:j,children:e.jsxs("svg",{width:s,height:n,children:[e.jsx("rect",{x:s/2-i/2,y:20,width:i,height:r,rx:5,fill:"var(--border-color, #e2e8f0)"}),e.jsx("rect",{x:s/2-i/2,y:20+r*(1-d),width:i,height:r*d,rx:5,fill:S}),e.jsx("text",{x:s/2,y:14,textAnchor:"middle",className:"nice-gauge__value",children:v?v(t):t}),$&&e.jsx("text",{x:s/2,y:n-4,textAnchor:"middle",className:"nice-gauge__label",children:$})]})})},Fe=({items:t,min:h=0,max:l=100,width:s=300,height:n=300,startAngle:g=225,endAngle:f=-45,formatValue:$,title:v,className:p,style:w})=>{const m=s/2,y=n/2,j=Math.min(m,y)-30,b=Math.min(20,j/(t.length+1)),r=4,d=_=>_*Math.PI/180,i=(g-f+360)%360||360,S=(_,A,x)=>{const D=m+_*Math.cos(d(A)),o=y-_*Math.sin(d(A)),T=m+_*Math.cos(d(x)),c=y-_*Math.sin(d(x)),P=(A-x+360)%360;return`M${D},${o} A${_},${_} 0 ${P>180?1:0},1 ${T},${c}`};return e.jsx("div",{className:`nice-bargauge ${p||""}`,style:w,children:e.jsxs("svg",{width:s,height:n,children:[v&&e.jsx("text",{x:m,y:20,textAnchor:"middle",className:"nice-chart__title",children:v}),t.map((_,A)=>{const x=j-A*(b+r),D=Math.max(0,Math.min(1,(_.value-h)/(l-h||1))),o=g-D*i,T=_.color||oe[A%oe.length];return e.jsxs("g",{children:[e.jsx("path",{d:S(x,g,f),fill:"none",stroke:"var(--border-color, #e2e8f0)",strokeWidth:b,strokeLinecap:"round"}),D>0&&e.jsx("path",{d:S(x,g,o),fill:"none",stroke:T,strokeWidth:b,strokeLinecap:"round"})]},A)}),e.jsx("g",{children:t.map((_,A)=>e.jsxs("text",{x:m,y:y-((t.length-1)/2-A)*16,textAnchor:"middle",dominantBaseline:"middle",className:"nice-gauge__value",style:{fontSize:12},children:[_.label?`${_.label}: `:"",$?$(_.value):_.value]},A))})]})})},Ve=({data:t,width:h=120,height:l=30,type:s="line",color:n="#3b82f6",showMinMax:g,showLastPoint:f=!0,className:$,style:v})=>{if(t.length===0)return null;const p=2,w=Math.min(...t),m=Math.max(...t),y=m-w||1,j=h-p*2,b=l-p*2,r=x=>p+x/(t.length-1||1)*j,d=x=>p+b-(x-w)/y*b;if(s==="bar"){const x=Math.max(1,j/t.length-1);return e.jsx("svg",{width:h,height:l,className:`nice-sparkline ${$||""}`,style:v,children:t.map((D,o)=>e.jsx("rect",{x:p+o/t.length*j,y:d(D),width:x,height:b-(d(D)-p),fill:n,rx:1},o))})}const i=t.map((x,D)=>`${r(D)},${d(x)}`).join(" "),S=t.indexOf(w),_=t.indexOf(m),A=t.length-1;return e.jsxs("svg",{width:h,height:l,className:`nice-sparkline ${$||""}`,style:v,children:[s==="area"&&e.jsx("polygon",{points:`${r(0)},${p+b} ${i} ${r(A)},${p+b}`,fill:n,opacity:.15}),e.jsx("polyline",{points:i,fill:"none",stroke:n,strokeWidth:1.5}),g&&e.jsx("circle",{cx:r(S),cy:d(w),r:2,fill:"#ef4444"}),g&&e.jsx("circle",{cx:r(_),cy:d(m),r:2,fill:"#22c55e"}),f&&e.jsx("circle",{cx:r(A),cy:d(t[A]),r:2,fill:n})]})},He=({value:t,target:h,min:l=0,max:s=100,width:n=200,height:g=30,color:f="#3b82f6",targetColor:$="#ef4444",className:v,style:p})=>{const w=n-8,m=g-8,y=Math.max(0,Math.min(1,(t-l)/(s-l||1))),j=h!=null?Math.max(0,Math.min(1,(h-l)/(s-l||1))):null;return e.jsxs("svg",{width:n,height:g,className:`nice-bullet ${v||""}`,style:p,children:[e.jsx("rect",{x:4,y:4,width:w,height:m,rx:3,fill:"var(--border-color, #e2e8f0)"}),e.jsx("rect",{x:4,y:4+m*.2,width:w*y,height:m*.6,rx:2,fill:f}),j!=null&&e.jsx("line",{x1:4+w*j,y1:6,x2:4+w*j,y2:4+m-2,stroke:$,strokeWidth:2})]})},Xe=({data:t,width:h=400,height:l=300,inverted:s,showLabels:n=!0,showValues:g=!0,title:f,className:$,style:v})=>{const p={top:f?30:10,bottom:10,x:40},w=h-p.x*2,m=l-p.top-p.bottom,y=s?[...t].reverse():t,j=Math.max(...y.map(r=>r.value),1),b=m/y.length;return e.jsx("div",{className:`nice-funnel ${$||""}`,style:v,children:e.jsxs("svg",{width:h,height:l,children:[f&&e.jsx("text",{x:h/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:f}),y.map((r,d)=>{const i=r.value/j*w,S=d<y.length-1?y[d+1].value/j*w:i*.3,_=p.top+d*b,A=_+b,x=h/2,D=`${x-i/2},${_} ${x+i/2},${_} ${x+S/2},${A} ${x-S/2},${A}`,o=r.color||oe[d%oe.length];return e.jsxs("g",{children:[e.jsx("polygon",{points:D,fill:o,stroke:"var(--bg-primary, #fff)",strokeWidth:1,children:e.jsx("title",{children:`${r.label}: ${r.value}`})}),n&&e.jsx("text",{x,y:_+b/2-(g?4:0),textAnchor:"middle",dominantBaseline:"middle",className:"nice-funnel__label",children:r.label}),g&&e.jsx("text",{x,y:_+b/2+10,textAnchor:"middle",dominantBaseline:"middle",className:"nice-funnel__value",children:r.value})]},d)})]})})},Ae=({nodes:t,links:h,width:l=600,height:s=400,nodeWidth:n=20,nodePadding:g=10,title:f,className:$,style:v})=>{const p={top:f?40:20,bottom:20,left:20,right:20},w=l-p.left-p.right,m=s-p.top-p.bottom,y=new Set(h.map(c=>c.source)),j=new Set(h.map(c=>c.target)),b=t.filter(c=>y.has(c.id)&&!j.has(c.id)),r=t.filter(c=>j.has(c.id)),d=t.filter(c=>y.has(c.id)&&j.has(c.id)),i=[b,...d.length?[d]:[],r].filter(c=>c.length>0),S=i.length,_=new Map;t.forEach(c=>{const P=h.filter(O=>O.source===c.id).reduce((O,U)=>O+U.value,0),I=h.filter(O=>O.target===c.id).reduce((O,U)=>O+U.value,0);_.set(c.id,Math.max(P,I))});const A=i.map(c=>c.reduce((P,I)=>P+(_.get(I.id)||0),0)+(c.length-1)*g),x=Math.max(...A,1),D=new Map;i.forEach((c,P)=>{const I=p.left+P/(S-1||1)*(w-n);let O=0;c.forEach(U=>{const L=(_.get(U.id)||0)/x*m;D.set(U.id,{x:I,y:p.top+O,h:L}),O+=L+g})});const o=new Map,T=new Map;return t.forEach(c=>{o.set(c.id,0),T.set(c.id,0)}),e.jsx("div",{className:`nice-sankey ${$||""}`,style:v,children:e.jsxs("svg",{width:l,height:s,children:[f&&e.jsx("text",{x:l/2,y:20,textAnchor:"middle",className:"nice-chart__title",children:f}),h.map((c,P)=>{var C;const I=D.get(c.source),O=D.get(c.target);if(!I||!O)return null;const U=o.get(c.source)||0,L=T.get(c.target)||0,Z=c.value/x*m;o.set(c.source,U+Z),T.set(c.target,L+Z);const F=I.x+n,q=I.y+U,V=O.x,ie=O.y+L,K=(F+V)/2,te=((C=t.find(W=>W.id===c.source))==null?void 0:C.color)||oe[P%oe.length];return e.jsx("path",{d:`M${F},${q} C${K},${q} ${K},${ie} ${V},${ie} L${V},${ie+Z} C${K},${ie+Z} ${K},${q+Z} ${F},${q+Z} Z`,fill:te,fillOpacity:.3,stroke:te,strokeOpacity:.5,strokeWidth:.5,children:e.jsx("title",{children:`${c.source} → ${c.target}: ${c.value}`})},P)}),t.map((c,P)=>{const I=D.get(c.id);if(!I)return null;const O=c.color||oe[P%oe.length];return e.jsxs("g",{children:[e.jsx("rect",{x:I.x,y:I.y,width:n,height:Math.max(I.h,2),fill:O,rx:2}),e.jsx("text",{x:I.x<w/2?I.x+n+4:I.x-4,y:I.y+I.h/2,textAnchor:I.x<w/2?"start":"end",dominantBaseline:"middle",className:"nice-chart__legend-text",children:c.label})]},c.id)})]})})},Ze=Object.freeze(Object.defineProperty({__proto__:null,NiceSankey:Ae},Symbol.toStringTag,{value:"Module"})),Ge=({data:t,min:h,max:l,start:s,end:n,onChange:g,width:f=500,height:$=100,step:v=1,formatValue:p,chartColor:w="#3b82f6",className:m,style:y})=>{const j={top:10,bottom:30,left:10,right:10},b=f-j.left-j.right,r=$-j.top-j.bottom,d=x=>j.left+(x-h)/(l-h||1)*b,i=x=>{const D=Math.max(0,Math.min(1,(x-j.left)/b)),o=h+D*(l-h);return Math.round(o/v)*v},S=(x,D)=>{D.preventDefault();const o=D.target.closest("svg");if(!o)return;const T=P=>{const I=o.getBoundingClientRect(),O=i(P.clientX-I.left);x==="start"?g(Math.min(O,n),n):g(s,Math.max(O,s))},c=()=>{document.removeEventListener("pointermove",T),document.removeEventListener("pointerup",c)};document.addEventListener("pointermove",T),document.addEventListener("pointerup",c)},_=t?Math.min(...t):0,A=(t?Math.max(...t):1)-_||1;return e.jsx("div",{className:`nice-rangeselector ${m||""}`,style:y,children:e.jsxs("svg",{width:f,height:$,children:[t&&t.length>1&&e.jsx("polygon",{points:`${j.left},${j.top+r} ${t.map((x,D)=>`${j.left+D/(t.length-1)*b},${j.top+r-(x-_)/A*r}`).join(" ")} ${j.left+b},${j.top+r}`,fill:w,opacity:.15}),e.jsx("rect",{x:d(s),y:j.top,width:d(n)-d(s),height:r,fill:w,opacity:.1}),e.jsx("rect",{x:j.left,y:j.top,width:d(s)-j.left,height:r,fill:"var(--bg-secondary, #f5f5f5)",opacity:.6}),e.jsx("rect",{x:d(n),y:j.top,width:j.left+b-d(n),height:r,fill:"var(--bg-secondary, #f5f5f5)",opacity:.6}),e.jsx("rect",{x:d(s)-4,y:j.top,width:8,height:r,fill:w,rx:2,cursor:"ew-resize",onPointerDown:x=>S("start",x)}),e.jsx("rect",{x:d(n)-4,y:j.top,width:8,height:r,fill:w,rx:2,cursor:"ew-resize",onPointerDown:x=>S("end",x)}),e.jsx("text",{x:d(s),y:j.top+r+18,textAnchor:"middle",className:"nice-chart__axis-label",children:p?p(s):s}),e.jsx("text",{x:d(n),y:j.top+r+18,textAnchor:"middle",className:"nice-chart__axis-label",children:p?p(n):n})]})})},Ce=({regions:t,width:h=600,height:l=400,viewBox:s="0 0 1000 600",colorRange:n=["#dbeafe","#1d4ed8"],maxValue:g,onRegionClick:f,selectedRegionId:$,title:v,showTooltip:p=!0,className:w,style:m})=>{const y=g??Math.max(...t.map(b=>b.value??0),1),j=b=>{const r=c=>[parseInt(c.slice(1,3),16),parseInt(c.slice(3,5),16),parseInt(c.slice(5,7),16)],[d,i,S]=r(n[0]),[_,A,x]=r(n[1]),D=Math.round(d+(_-d)*b),o=Math.round(i+(A-i)*b),T=Math.round(S+(x-S)*b);return`rgb(${D},${o},${T})`};return e.jsxs("div",{className:`nice-vectormap ${w||""}`,style:m,children:[v&&e.jsx("div",{className:"nice-vectormap__title",children:v}),e.jsx("svg",{width:h,height:l,viewBox:s,children:t.map(b=>{const r=b.value!=null?Math.max(0,Math.min(1,b.value/y)):0,d=b.value!=null?j(r):"var(--bg-tertiary, #e5e7eb)",i=b.id===$;return e.jsx("path",{d:b.path,fill:d,stroke:i?"var(--color-primary, #3b82f6)":"var(--border-color, #d1d5db)",strokeWidth:i?2:.5,cursor:f?"pointer":void 0,onClick:()=>f==null?void 0:f(b),children:p&&e.jsx("title",{children:`${b.name}${b.value!=null?`: ${b.value}`:""}`})},b.id)})})]})},Ue=Object.freeze(Object.defineProperty({__proto__:null,NiceVectorMap:Ce},Symbol.toStringTag,{value:"Module"})),qe=`
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 ce(t){return t instanceof Date?t:new Date(t)}function Ne(t,h="pl-PL"){return t.toLocaleDateString(h,{year:"numeric",month:"short",day:"numeric"})}function _e(t,h="pl-PL"){return new Intl.NumberFormat(h,{minimumFractionDigits:0,maximumFractionDigits:2}).format(t)}N.forwardRef(function(t,h){var E,re;const{scenarios:l,annotations:s=[],referenceLines:n=[],forecastStartDate:g,cashRunway:f,xAxis:$,yAxis:v,confidenceBands:p=[{level:95,color:"#3b82f6",opacity:.15}],tooltip:w,legend:m={enabled:!0,position:"bottom",interactive:!0},height:y=350,showForecastRegion:j=!0,lineWidth:b=2,showPoints:r=!1,pointRadius:d=4,enableZoom:i=!1,animationDuration:S=300,responsive:_=!0,onPointClick:A,onAnnotationClick:x,onScenarioToggle:D,onViewportChange:o,size:T="medium",disabled:c=!1,labels:P={},locale:I="pl-PL",className:O,style:U}=t,[L,Z]=N.useState(()=>l.map((a,M)=>({...a,color:a.color??$e[M%$e.length],visible:a.visible!==!1}))),[F,q]=N.useState(null),[V,ie]=N.useState({x:0,y:0}),K=N.useRef(null),te=N.useRef(null),C={top:20,right:30,bottom:40,left:60},[W,ae]=N.useState({width:600,height:typeof y=="number"?y:350});N.useEffect(()=>{if(!_||!K.current)return;const a=new ResizeObserver(M=>{for(const z of M)ae(u=>({width:z.contentRect.width,height:u.height}))});return a.observe(K.current),()=>a.disconnect()},[_]),N.useEffect(()=>{const a="nice-forecast-chart-styles";if(!document.getElementById(a)){const M=document.createElement("style");M.id=a,M.textContent=qe,document.head.appendChild(M)}},[]);const{xScale:G,yScale:H,allDates:Q,minY:fe,maxY:pe}=N.useMemo(()=>{const a=L.filter(ee=>ee.visible!==!1).flatMap(ee=>ee.data);if(a.length===0)return{xScale:()=>0,yScale:()=>0,allDates:[],minY:0,maxY:100};const M=a.map(ee=>ce(ee.date).getTime()),z=Math.min(...M),u=Math.max(...M),B=a.flatMap(ee=>[ee.value,ee.forecast,ee.lowerBound,ee.upperBound]).filter(ee=>ee!=null),ne=(v==null?void 0:v.min)??Math.min(...B)*.95,he=(v==null?void 0:v.max)??Math.max(...B)*1.05,le=W.width-C.left-C.right,se=W.height-C.top-C.bottom,ye=ee=>{const ke=typeof ee=="number"?ee:ee.getTime();return C.left+(ke-z)/(u-z)*le},ve=ee=>C.top+se-(ee-ne)/(he-ne)*se,we=[...new Set(M)].sort((ee,ke)=>ee-ke).map(ee=>new Date(ee));return{xScale:ye,yScale:ve,allDates:we,minY:ne,maxY:he}},[L,W,C,v]),de=g?ce(g):null,R=N.useMemo(()=>{if(!(f!=null&&f.enabled))return null;const a=f.threshold??0,M=f.scenarioId?L.find(u=>u.id===f.scenarioId&&u.visible!==!1):L.find(u=>u.visible!==!1);if(!M)return null;const z=M.data.sort((u,B)=>ce(u.date).getTime()-ce(B.date).getTime());for(let u=1;u<z.length;u++){const B=z[u-1],ne=z[u],he=B.forecast??B.value,le=ne.forecast??ne.value;if(he!=null&&le!=null&&he>a&&le<=a){const se=(he-a)/(he-le),ye=ce(B.date).getTime(),ve=ce(ne.date).getTime(),we=ye+se*(ve-ye);return new Date(we)}}return null},[f,L]),Y=N.useCallback((a,M)=>{const z=a.filter(u=>u[M]!=null).map(u=>({x:G(ce(u.date)),y:H(u[M])}));return z.length===0?"":`M ${z.map(u=>`${u.x},${u.y}`).join(" L ")}`},[G,H]),J=N.useCallback(a=>{const M=a.filter(B=>B.lowerBound!=null&&B.upperBound!=null);if(M.length===0)return"";const z=M.map(B=>({x:G(ce(B.date)),y:H(B.upperBound)})),u=M.map(B=>({x:G(ce(B.date)),y:H(B.lowerBound)})).reverse();return`M ${z.map(B=>`${B.x},${B.y}`).join(" L ")} L ${u.map(B=>`${B.x},${B.y}`).join(" L ")} Z`},[G,H]),ue=N.useCallback(a=>{if(!te.current||(w==null?void 0:w.enabled)===!1)return;const M=te.current.getBoundingClientRect(),z=a.clientX-M.left;a.clientY-M.top;let u=null,B=1/0;for(const ne of Q){const he=G(ne),le=Math.abs(he-z);le<B&&(B=le,u=ne)}if(u&&B<50){const ne=L.filter(le=>le.visible!==!1).map(le=>{const se=le.data.find(ye=>ce(ye.date).getTime()===u.getTime());return{scenario:le,value:se==null?void 0:se.value,forecast:se==null?void 0:se.forecast,lowerBound:se==null?void 0:se.lowerBound,upperBound:se==null?void 0:se.upperBound}}),he=s.filter(le=>Math.abs(ce(le.date).getTime()-u.getTime())<864e5);q({date:u,values:ne,annotations:he}),ie({x:a.clientX-M.left+10,y:a.clientY-M.top-10})}else q(null)},[G,Q,L,s,w]),xe=N.useCallback(a=>{if(!m.interactive)return;Z(z=>z.map(u=>u.id===a?{...u,visible:!u.visible}:u));const M=L.find(z=>z.id===a);M&&(D==null||D(a,!M.visible))},[m.interactive,L,D]);N.useImperativeHandle(h,()=>({getScenarios:()=>L,updateScenario:(a,M)=>{Z(z=>z.map(u=>u.id===a?{...u,data:M}:u))},toggleScenario:xe,setZoomRange:()=>{},resetZoom:()=>{},exportImage:a=>{if(!te.current)return null;const M=te.current,z=new XMLSerializer().serializeToString(M);return`data:image/svg+xml;base64,${btoa(z)}`},getDataAtDate:a=>{const M=L.filter(z=>z.visible!==!1).map(z=>{const u=z.data.find(B=>ce(B.date).getTime()===a.getTime());return{scenario:z,value:u==null?void 0:u.value,forecast:u==null?void 0:u.forecast,lowerBound:u==null?void 0:u.lowerBound,upperBound:u==null?void 0:u.upperBound}});return{date:a,values:M,annotations:s.filter(z=>ce(z.date).getTime()===a.getTime())}}}),[L,s,xe]),W.width-C.left-C.right;const me=W.height-C.top-C.bottom,k=N.useMemo(()=>{const a=(v==null?void 0:v.tickCount)??5,M=[],z=(pe-fe)/(a-1);for(let u=0;u<a;u++)M.push(fe+z*u);return M},[fe,pe,v==null?void 0:v.tickCount]),X=N.useMemo(()=>{const a=($==null?void 0:$.tickCount)??6;if(Q.length===0)return[];const M=Math.max(1,Math.floor(Q.length/(a-1)));return Q.filter((z,u)=>u%M===0||u===Q.length-1)},[Q,$==null?void 0:$.tickCount]);return L.length===0||L.every(a=>a.data.length===0)?e.jsx("div",{className:`nice-forecast-chart ${O??""}`,style:U,children:e.jsx("div",{className:"nice-forecast-chart__empty",children:P.noData??"No data available"})}):e.jsxs("div",{className:`nice-forecast-chart ${O??""}`,style:{...U,height:y},children:[e.jsxs("div",{ref:K,className:"nice-forecast-chart__container",children:[e.jsxs("svg",{ref:te,className:"nice-forecast-chart__svg",width:W.width,height:W.height,onMouseMove:ue,onMouseLeave:()=>q(null),children:[(v==null?void 0:v.showGrid)!==!1&&k.map(a=>e.jsx("line",{className:"nice-forecast-chart__grid-line",x1:C.left,x2:W.width-C.right,y1:H(a),y2:H(a)},a)),j&&de&&e.jsx("rect",{className:"nice-forecast-chart__forecast-region",x:G(de),y:C.top,width:W.width-C.right-G(de),height:me}),n.map(a=>e.jsxs("g",{children:[e.jsx("line",{className:"nice-forecast-chart__reference-line",x1:C.left,x2:W.width-C.right,y1:H(a.value),y2:H(a.value),stroke:a.color??"#9ca3af",strokeDasharray:a.dashArray??"4,2"}),a.label&&e.jsx("text",{className:"nice-forecast-chart__reference-label",x:W.width-C.right-4,y:H(a.value)-4,textAnchor:"end",children:a.label})]},a.id)),R&&(f==null?void 0:f.enabled)&&e.jsxs("g",{className:"nice-forecast-chart__cash-runway",children:[e.jsx("line",{className:"nice-forecast-chart__cash-runway-line",x1:G(R),x2:G(R),y1:C.top,y2:W.height-C.bottom,stroke:f.color??"#ef4444"}),f.showLabel!==!1&&e.jsxs(e.Fragment,{children:[e.jsx("rect",{className:"nice-forecast-chart__cash-runway-label-bg",x:G(R)-60,y:C.top-2,width:120,height:f.showDate!==!1?32:20,fill:f.color??"#ef4444",rx:4}),e.jsx("text",{className:"nice-forecast-chart__cash-runway-label",x:G(R),y:C.top+12,textAnchor:"middle",fill:"#ffffff",children:f.label??P.cashRunsOut??"💰 Cash runs out"}),f.showDate!==!1&&e.jsx("text",{className:"nice-forecast-chart__cash-runway-label",x:G(R),y:C.top+26,textAnchor:"middle",fill:"#ffffff",style:{fontSize:"0.625rem",opacity:.9},children:Ne(R,I)})]})]}),L.filter(a=>a.visible!==!1&&a.showConfidenceBand).map(a=>e.jsx("path",{className:"nice-forecast-chart__confidence-band",d:J(a.data),fill:a.color},`band-${a.id}`)),L.filter(a=>a.visible!==!1).map(a=>{const M=de?a.data.filter(u=>ce(u.date)<de):a.data.filter(u=>u.value!=null),z=de?a.data.filter(u=>ce(u.date)>=de):a.data.filter(u=>u.forecast!=null);return e.jsxs("g",{children:[e.jsx("path",{className:"nice-forecast-chart__historical-line",d:Y(M,"value"),stroke:a.color,strokeWidth:b}),e.jsx("path",{className:"nice-forecast-chart__forecast-line",d:Y(z,de?"value":"forecast"),stroke:a.color,strokeWidth:b}),z.length>0&&a.data.some(u=>u.forecast!=null)&&e.jsx("path",{className:"nice-forecast-chart__forecast-line",d:Y(a.data,"forecast"),stroke:a.color,strokeWidth:b}),r&&a.data.map((u,B)=>{const ne=u.value??u.forecast;return ne==null?null:e.jsx("circle",{className:"nice-forecast-chart__point",cx:G(ce(u.date)),cy:H(ne),r:d,fill:a.color,onClick:()=>A==null?void 0:A(u,a)},B)})]},a.id)}),s.map(a=>{const M=G(ce(a.date));return e.jsxs("g",{className:"nice-forecast-chart__annotation-marker",onClick:()=>x==null?void 0:x(a),children:[a.showLine!==!1&&e.jsx("line",{className:"nice-forecast-chart__annotation-line",x1:M,x2:M,y1:C.top,y2:W.height-C.bottom,stroke:a.color??"#9ca3af"}),e.jsx("circle",{cx:M,cy:C.top+10,r:8,fill:a.color??"#9ca3af"}),e.jsx("text",{x:M,y:C.top+14,textAnchor:"middle",fill:"white",fontSize:"10",children:a.icon??"!"})]},a.id)}),e.jsx("line",{className:"nice-forecast-chart__axis-line",x1:C.left,x2:C.left,y1:C.top,y2:W.height-C.bottom}),e.jsx("line",{className:"nice-forecast-chart__axis-line",x1:C.left,x2:W.width-C.right,y1:W.height-C.bottom,y2:W.height-C.bottom}),k.map(a=>e.jsx("text",{className:"nice-forecast-chart__axis-label",x:C.left-8,y:H(a)+4,textAnchor:"end",children:v!=null&&v.format?v.format(a):_e(a,I)},a)),X.map(a=>e.jsx("text",{className:"nice-forecast-chart__axis-label",x:G(a),y:W.height-C.bottom+16,textAnchor:"middle",children:$!=null&&$.format?$.format(a):Ne(a,I)},a.getTime())),(v==null?void 0:v.title)&&e.jsx("text",{className:"nice-forecast-chart__axis-title",x:15,y:W.height/2,textAnchor:"middle",transform:`rotate(-90, 15, ${W.height/2})`,children:v.title})]}),F&&e.jsxs("div",{className:"nice-forecast-chart__tooltip",style:{left:V.x,top:V.y},children:[e.jsx("div",{className:"nice-forecast-chart__tooltip-date",children:Ne(F.date,I)}),F.values.map(a=>{const M=a.value??a.forecast;return M==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:_e(M,I)})]},a.scenario.id)}),F.values.some(a=>a.lowerBound!=null)&&e.jsxs("div",{className:"nice-forecast-chart__tooltip-confidence",children:[P.confidence??"CI",":"," ",_e(((E=F.values[0])==null?void 0:E.lowerBound)??0,I)," –"," ",_e(((re=F.values[0])==null?void 0:re.upperBound)??0,I)]})]})]}),m.enabled&&e.jsx("div",{className:"nice-forecast-chart__legend",children:L.map(a=>e.jsxs("div",{className:`nice-forecast-chart__legend-item ${a.visible===!1?"nice-forecast-chart__legend-item--hidden":""}`,onClick:()=>xe(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))})]})});const Ie=N.forwardRef(({data:t,renderNode:h,selectable:l,selectedKey:s,onSelect:n,direction:g="top-down",collapsible:f=!0,className:$,style:v,id:p},w)=>{const m=ge.ys(p),[y,j]=N.useState(new Set),b=N.useCallback(i=>{j(S=>{const _=new Set(S);return _.has(i)?_.delete(i):_.add(i),_})},[]),r=N.useCallback(i=>{l&&(n==null||n(i))},[l,n]),d=N.useCallback(i=>{const S=y.has(i.key),_=i.children&&i.children.length>0;return e.jsxs("li",{className:"nice-org-chart__item",children:[e.jsxs("div",{className:`nice-org-chart__node${s===i.key?" nice-org-chart__node--selected":""}`,onClick:()=>r(i.key),role:l?"button":void 0,children:[h?h(i):e.jsx("span",{children:i.label}),f&&_&&e.jsx("button",{type:"button",className:"nice-org-chart__toggle",onClick:A=>{A.stopPropagation(),b(i.key)},"aria-label":S?"Expand":"Collapse",children:S?"+":"−"})]}),_&&!S&&e.jsx("ul",{className:"nice-org-chart__children",children:i.children.map(A=>d(A))})]},i.key)},[y,s,h,l,f,r,b]);return e.jsx("div",{ref:w,id:m,className:`nice-org-chart nice-org-chart--${g} ${$||""}`,style:v,children:e.jsx("ul",{className:"nice-org-chart__root",children:d(t)})})});Ie.displayName="NiceOrganizationChart";function Je(t,h,l){const s=j=>{const b=j.replace("#","");return[parseInt(b.slice(0,2),16),parseInt(b.slice(2,4),16),parseInt(b.slice(4,6),16)]},[n,g,f]=s(t),[$,v,p]=s(h),w=Math.round(n+($-n)*l),m=Math.round(g+(v-g)*l),y=Math.round(f+(p-f)*l);return`rgb(${w},${m},${y})`}const ze=N.forwardRef(({data:t,xLabels:h,yLabels:l,colors:s=["#e0f2fe","#1d4ed8"],onCellClick:n,cellSize:g=40,showValues:f=!0,className:$,style:v,id:p},w)=>{const m=ge.ys(p),{minVal:y,maxVal:j}=N.useMemo(()=>{let r=1/0,d=-1/0;for(const i of t)for(const S of i)S<r&&(r=S),S>d&&(d=S);return{minVal:r,maxVal:d}},[t]),b=N.useCallback(r=>j===y?.5:(r-y)/(j-y),[y,j]);return e.jsx("div",{ref:w,id:m,className:`nice-heatmap ${$||""}`,style:v,children:e.jsxs("table",{className:"nice-heatmap__table",children:[h&&e.jsx("thead",{children:e.jsxs("tr",{children:[l&&e.jsx("th",{}),h.map((r,d)=>e.jsx("th",{className:"nice-heatmap__header",children:r},d))]})}),e.jsx("tbody",{children:t.map((r,d)=>e.jsxs("tr",{children:[l&&e.jsx("th",{className:"nice-heatmap__row-label",children:l[d]}),r.map((i,S)=>e.jsx("td",{className:"nice-heatmap__cell",style:{background:Je(s[0],s[1],b(i)),width:g,height:g,textAlign:"center",color:b(i)>.6?"#fff":"#333",cursor:n?"pointer":void 0},onClick:()=>n==null?void 0:n(d,S,i),title:String(i),children:f?i:""},S))]},d))})]})})});ze.displayName="NiceHeatMap";function Ke(t,h){const l=t.reduce((p,w)=>p+w.value,0);if(l===0||t.length===0)return[];const s=[];let{x:n,y:g,w:f,h:$}=h;const v=[...t].sort((p,w)=>w.value-p.value);for(const p of v){const w=p.value/l;if(f>=$){const m=f*w;s.push({x:n,y:g,w:m,h:$,node:p}),n+=m,f-=m}else{const m=$*w;s.push({x:n,y:g,w:f,h:m,node:p}),g+=m,$-=m}}return s}const Qe=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#06b6d4","#ec4899","#84cc16"],De=N.forwardRef(({data:t,width:h=600,height:l=400,onNodeClick:s,colors:n=Qe,className:g,style:f,id:$},v)=>{const p=ge.ys($),w=N.useMemo(()=>{const m=t.children??[t];return Ke(m,{x:0,y:0,w:h,h:l})},[t,h,l]);return e.jsx("div",{ref:v,id:p,className:`nice-treemap ${g||""}`,style:f,children:e.jsx("svg",{width:h,height:l,className:"nice-treemap__svg",children:w.map((m,y)=>e.jsxs("g",{onClick:()=>s==null?void 0:s(m.node),style:{cursor:s?"pointer":void 0},children:[e.jsx("rect",{x:m.x,y:m.y,width:Math.max(m.w-1,0),height:Math.max(m.h-1,0),fill:m.node.color??n[y%n.length],rx:2}),m.w>40&&m.h>20&&e.jsx("text",{x:m.x+m.w/2,y:m.y+m.h/2,textAnchor:"middle",dominantBaseline:"central",fill:"#fff",fontSize:Math.min(12,m.w/6),className:"nice-treemap__label",children:m.node.label})]},m.node.key))})})});De.displayName="NiceTreeMap";const Le=N.forwardRef(({data:t,type:h="candlestick",showVolume:l=!0,width:s=800,height:n=400,bullColor:g="#22c55e",bearColor:f="#ef4444",className:$,style:v,id:p},w)=>{const m=ge.ys(p),y={top:20,right:20,bottom:l?80:30,left:60},j=s-y.left-y.right,b=l?50:0,r=n-y.top-y.bottom-b,{minP:d,maxP:i,maxVol:S}=N.useMemo(()=>{let o=1/0,T=-1/0,c=0;for(const P of t)P.low<o&&(o=P.low),P.high>T&&(T=P.high),P.volume&&P.volume>c&&(c=P.volume);return{minP:o,maxP:T,maxVol:c}},[t]),_=Math.max(1,j/t.length*.7),A=o=>y.left+(o+.5)*(j/t.length),x=o=>y.top+r-(o-d)/(i-d||1)*r,D=o=>n-y.bottom-b+b*(1-o/(S||1));return e.jsx("div",{ref:w,id:m,className:`nice-stock-chart ${$||""}`,style:v,children:e.jsxs("svg",{width:s,height:n,className:"nice-stock-chart__svg",children:[[0,.25,.5,.75,1].map(o=>{const T=d+o*(i-d);return e.jsxs("g",{children:[e.jsx("line",{x1:y.left,x2:s-y.right,y1:x(T),y2:x(T),stroke:"#e5e7eb",strokeDasharray:"2,2"}),e.jsx("text",{x:y.left-4,y:x(T)+4,textAnchor:"end",fontSize:10,fill:"#888",children:T.toFixed(2)})]},o)}),h==="line"?e.jsx("polyline",{points:t.map((o,T)=>`${A(T)},${x(o.close)}`).join(" "),fill:"none",stroke:g,strokeWidth:1.5}):t.map((o,T)=>{const c=o.close>=o.open,P=c?g:f,I=A(T);if(h==="ohlc")return e.jsxs("g",{children:[e.jsx("line",{x1:I,x2:I,y1:x(o.high),y2:x(o.low),stroke:P,strokeWidth:1}),e.jsx("line",{x1:I-_/2,x2:I,y1:x(o.open),y2:x(o.open),stroke:P,strokeWidth:1.5}),e.jsx("line",{x1:I,x2:I+_/2,y1:x(o.close),y2:x(o.close),stroke:P,strokeWidth:1.5})]},T);const O=x(Math.max(o.open,o.close)),U=x(Math.min(o.open,o.close));return e.jsxs("g",{children:[e.jsx("line",{x1:I,x2:I,y1:x(o.high),y2:x(o.low),stroke:P,strokeWidth:1}),e.jsx("rect",{x:I-_/2,y:O,width:_,height:Math.max(U-O,1),fill:c?"transparent":P,stroke:P,strokeWidth:1})]},T)}),l&&t.map((o,T)=>{if(!o.volume)return null;const c=o.close>=o.open;return e.jsx("rect",{x:A(T)-_/2,y:D(o.volume),width:_,height:n-y.bottom-D(o.volume),fill:c?g:f,opacity:.3},`v${T}`)}),t.map((o,T)=>T%Math.max(1,Math.floor(t.length/8))!==0?null:e.jsx("text",{x:A(T),y:n-y.bottom+b+14,textAnchor:"middle",fontSize:9,fill:"#888",children:o.date},`l${T}`))]})})});Le.displayName="NiceStockChart";exports.C=oe;exports.N=Fe;exports.a=He;exports.b=je;exports.d=Ye;exports.f=Xe;exports.g=ze;exports.h=Ee;exports.i=Se;exports.j=Ie;exports.k=We;exports.l=Oe;exports.m=Ge;exports.n=Ae;exports.o=Ve;exports.p=Le;exports.q=De;exports.r=Ce;exports.v=Re;exports.w=Ze;exports.x=Ue;