ml-time-graph 1.17.1 → 1.18.0

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.
@@ -1,4 +1,4 @@
1
- import { D as DataPoint, a as DrawCommand, T as TimeScale, L as LinearScale } from '../types-D7tmWwH9.js';
1
+ import { D as DataPoint, a as DrawCommand, T as TimeScale, L as LinearScale } from '../types-CNIUKrmy.js';
2
2
 
3
3
  /*!
4
4
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
@@ -123,7 +123,6 @@ interface TooltipResult {
123
123
  /** Computes tooltip visibility and renders crosshair + value box at the nearest data point. */
124
124
  declare class Tooltip {
125
125
  private readonly _mouseX;
126
- private readonly _mouseY;
127
126
  private readonly _timeScale;
128
127
  private readonly _valueScale;
129
128
  private readonly _data;
@@ -1,4 +1,4 @@
1
- var v=class{_config;_state;constructor(t,n){this._config={enabled:n?.enabled??true,zoomSpeed:n?.zoomSpeed??.1,minDomainMs:n?.minDomainMs??0,maxDomainMs:n?.maxDomainMs??365*24*60*60*1e3},this._state={domain:[...t],originalDomain:[...t],scale:1,offset:0};}get state(){return {...this._state,domain:[...this._state.domain]}}applyZoom(t,n,o){if(!this._config.enabled)return;let r=1+Math.sign(n)*this._config.zoomSpeed;if(r<=0)return;let[i,a]=this._state.domain,d=a-i,s=t/o,e=d/r,l=this._config.minDomainMs??0,m=this._config.maxDomainMs??1/0;e<l&&(e=l),e>m&&(e=m);let p=i+d*s,h=p-e*s,c=p+e*(1-s),[b,_]=this._state.originalDomain;c-h>_-b?(h=b,c=_,e=_-b):(h<b&&(c=_-(_-b)*((c-h)/(_-b)),h=b),c>_&&(h=b+(_-b)*((h-b)/(_-b)),c=_)),this._state.domain=[h,c],this._state.scale=(a-i)/e;}applyPan(t,n){if(!this._config.enabled)return;let[o,r]=this._state.domain,i=r-o,[a,d]=this._state.originalDomain,s=-(t/n)*i,e=o+s,l=r+s;e<a&&(s-=e-a),l>d&&(s-=l-d),this._state.domain=[o+s,r+s];}reset(){this._state.domain=[...this._state.originalDomain],this._state.scale=1,this._state.offset=0;}get enabled(){return this._config.enabled??true}};var w=new Map;function R(u,t){return `${u}|${JSON.stringify(t??{})}`}function k(u,t){let n=R(u,t),o=w.get(n);return o||(o=new Intl.DateTimeFormat(u,t),w.set(n,o)),o}function M(){return typeof navigator<"u"?navigator.language:void 0}var y=class{#t;#e;constructor(t){this.#t=[...t.domain],this.#e=[...t.range];}map(t){let n=Number(t),[o,r]=this.#t,[i,a]=this.#e;return r===o?i:i+(n-o)/(r-o)*(a-i)}invert(t){let[n,o]=this.#t,[r,i]=this.#e;return i===r?n:n+(t-r)/(i-r)*(o-n)}domain(){return [...this.#t]}range(){return [...this.#e]}},g=[{label:"second",ms:1e3},{label:"2_seconds",ms:2e3},{label:"5_seconds",ms:5e3},{label:"10_seconds",ms:1e4},{label:"30_seconds",ms:3e4},{label:"minute",ms:6e4},{label:"5_minutes",ms:3e5},{label:"15_minutes",ms:9e5},{label:"30_minutes",ms:18e5},{label:"hour",ms:36e5},{label:"3_hours",ms:108e5},{label:"6_hours",ms:216e5},{label:"day",ms:864e5},{label:"week",ms:6048e5},{label:"month",ms:2592e6},{label:"3_months",ms:7776e6},{label:"6_months",ms:15552e6},{label:"year",ms:31536e6},{label:"2_years",ms:63072e6},{label:"5_years",ms:15768e7}],x=class{#t;#e;#n;constructor(t){this.#t=new y({domain:t.domain,range:t.range}),this.#e=t.locale||(M()??"en-US"),this.#n=t.timeZone;}map(t){return this.#t.map(Number(t))}invert(t){return this.#t.invert(t)}domain(){return this.#t.domain()}range(){return this.#t.range()}get timeZone(){return this.#n}get locale(){return this.#e}tickInterval(t,n=3,o=12){let[r,i]=this.#t.domain(),a=i-r;if(a<=0)return {interval:g[0].ms};let d=a/t,s=g[0].ms;for(let m of g)if(m.ms>=d){s=m.ms;break}let e=s,l=Math.round(a/e);for(;l>o&&e<g[g.length-1].ms;){let m=g.findIndex(p=>p.ms===e);e=g[Math.min(m+1,g.length-1)].ms,l=Math.round(a/e);}for(;l<n&&e>g[0].ms;){let m=g.findIndex(p=>p.ms===e);e=g[Math.max(m-1,0)].ms,l=Math.round(a/e);}return {interval:e}}ticks(t){let n=t?.minTicks??5,o=t?.maxTicks??12,{interval:r}=this.tickInterval((n+o)/2,n,o),[i,a]=this.#t.domain(),d=[],s=Math.ceil(i/r)*r;for(let e=s;e<=a;e+=r)d.push(e);return d}format(t,n){let o=this.#n?{...n,timeZone:this.#n}:n;return k(this.#e,o).format(new Date(t))}};function T(u){let t=1/0,n=-1/0;for(let o=0;o<u.length;o++){let r=u[o];r<t&&(t=r),r>n&&(n=r);}return [t,n]}var L={fontFamily:"Liberation Sans, Arial, Helvetica, sans-serif",stroke:"#4285f4",strokeWidth:2,pointSize:4,pointThreshold:100,gapThreshold:0,fill:"none",hatch:null,bandFill:"#4285f4",bandOpacity:.6,bandAvgLine:"#e53e3e",minColor:"#3b82f6",maxColor:"#ef4444",avgColor:"#64748b",areaFillAlpha:"4285f433",axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:11,axisLabelColor:"#444",axisLabelSize:12,gridStroke:"#e2e8f0",gridStrokeWidth:1,gridOpacity:1,legendStroke:"#ccc",legendText:"#333",legendFont:11,annotationColor:"#334155",annotationWidth:1.5,annotationHead:9,annotationRadius:4,annotationFontSize:11,markerFontSize:11,statFontSize:10,tooltipTimeFontSize:10,tooltipValueFontSize:11,thresholdColor:"#666",thresholdLine:"dashed",thresholdFillOpacity:.12,thresholdFontSize:10,highlightColor:"#fbbf24",highlightOpacity:.2,highlightLabelColor:"#92400e",markerColor:"#f59e0b",markerSize:5,gapFill:"#fff",gapStroke:"#ccc",gapStrokeWidth:1,gapFontColor:"#999",gapFontSize:10,gapFillOpacity:.15,tooltipBg:"#fff",tooltipBorder:"#cbd5e1",tooltipText:"#1e293b",tooltipValue:"#3b82f6",tooltipCrosshair:"#94a3b8",tooltipSnapRadius:20,statsLineColor:"#94a3b8",statsLabelColor:"#64748b",minimapStroke:"#94a3b8",minimapBg:"#f8f9fa",minimapBrush:"#3b82f644",palette:["#4285f4","#ea4335","#22c55e","#fbbc05","#9334ea","#12b5e5","#fb923c","#6366f1"]};var F={...L};function S(){return F}var f=new Proxy({},{get:(u,t)=>S()[t],has:(u,t)=>t in S(),ownKeys:()=>Reflect.ownKeys(S()),getOwnPropertyDescriptor:(u,t)=>Reflect.getOwnPropertyDescriptor(S(),t)});var C=class{_data;_width;_height;_x;_y;_zoom;_stroke;_bgColor;_brushColor;constructor(t){this._data=t.data,this._width=t.width,this._height=t.height,this._x=t.x,this._y=t.y,this._zoom=t.zoom,this._stroke=t.stroke??f.minimapStroke,this._bgColor=t.bgColor??f.minimapBg,this._brushColor=t.brushColor??f.minimapBrush;}render(){if(this._data.length===0)return [];let t=[],n=this._data.map(e=>e.time),o=this._data.map(e=>e.value).filter(e=>e!==null),r=T(n),i=T(o),a=new x({domain:r,range:[0,this._width]}),d=new y({domain:i,range:[this._height,0]});t.push({type:"rect",x:this._x,y:this._y,w:this._width,h:this._height,fill:this._bgColor});let s=this._data.map(e=>({x:this._x+a.map(e.time),y:this._y+d.map(e.value)}));if(t.push({type:"path",points:s,smoothing:false,stroke:this._stroke,strokeWidth:1}),this._zoom){let e=this._zoom.state,l=this._x+a.map(e.domain[0]),m=this._x+a.map(e.domain[1]),p=Math.max(2,m-l);t.push({type:"rect",x:l,y:this._y,w:p,h:this._height,fill:this._brushColor});}return t}navigateTo(t){let n=this._data.map(a=>a.time),o=T(n),r=new x({domain:o,range:[0,this._width]}),i=t-this._x;return r.invert(i)}};var D=class{_mouseX;_mouseY;_timeScale;_valueScale;_data;_xRange;_yRange;_snapRadius;_bgColor;_borderColor;_textColor;constructor(t){this._mouseX=t.mouseX,this._mouseY=t.mouseY,this._timeScale=t.timeScale,this._valueScale=t.valueScale,this._data=t.data,this._xRange=t.xRange,this._yRange=t.yRange,this._snapRadius=t.snapRadius??f.tooltipSnapRadius,this._bgColor=t.bgColor??f.tooltipBg,this._borderColor=t.borderColor??f.tooltipBorder,this._textColor=t.textColor??f.tooltipText;}compute(){let t=[...this._data].filter(h=>h.value!==null).sort((h,c)=>h.time-c.time),n,o=1/0;for(let h of t){let c=this._timeScale.map(h.time),b=Math.abs(this._mouseX-c);b<o&&(o=b,n=h);}if(!n||o>this._snapRadius)return {visible:false,commands:[]};let r=this._timeScale.map(n.time),i=this._valueScale.map(n.value),a=[];a.push({type:"line",x1:r,y1:this._yRange[0],x2:r,y2:this._yRange[1],stroke:"#94a3b8",strokeWidth:1},{type:"line",x1:this._xRange[0],y1:i,x2:this._xRange[1],y2:i,stroke:"#94a3b8",strokeWidth:1},{type:"circle",cx:r,cy:i,r:5,fill:"#3b82f6"});let d=new Date(n.time).toLocaleString(),s=n.value.toFixed(2),e=120,l=44,m=r+12,p=i-l-4;return m+e>this._xRange[1]&&(m=r-e-12),p<this._yRange[0]&&(p=i+12),a.push({type:"rect",x:m,y:p,w:e,h:l,fill:this._bgColor,stroke:this._borderColor,strokeWidth:1},{type:"text",content:d,x:m+8,y:p+16,fontSize:f.tooltipTimeFontSize,fill:this._textColor},{type:"text",content:`Value: ${s}`,x:m+8,y:p+32,fontSize:f.tooltipValueFontSize,fill:"#3b82f6"}),{visible:true,commands:a,dataPoint:n,snapX:r}}};/*!
1
+ var v=class{_config;_state;constructor(t,n){this._config={enabled:n?.enabled??true,zoomSpeed:n?.zoomSpeed??.1,minDomainMs:n?.minDomainMs??0,maxDomainMs:n?.maxDomainMs??365*24*60*60*1e3},this._state={domain:[...t],originalDomain:[...t],scale:1,offset:0};}get state(){return {...this._state,domain:[...this._state.domain]}}applyZoom(t,n,o){if(!this._config.enabled)return;let r=1+Math.sign(n)*this._config.zoomSpeed;if(r<=0)return;let[i,a]=this._state.domain,d=a-i,s=t/o,e=d/r,l=this._config.minDomainMs??0,m=this._config.maxDomainMs??1/0;e<l&&(e=l),e>m&&(e=m);let p=i+d*s,h=p-e*s,c=p+e*(1-s),[b,_]=this._state.originalDomain;c-h>_-b?(h=b,c=_,e=_-b):(h<b&&(c=_-(_-b)*((c-h)/(_-b)),h=b),c>_&&(h=b+(_-b)*((h-b)/(_-b)),c=_)),this._state.domain=[h,c],this._state.scale=(a-i)/e;}applyPan(t,n){if(!this._config.enabled)return;let[o,r]=this._state.domain,i=r-o,[a,d]=this._state.originalDomain,s=-(t/n)*i,e=o+s,l=r+s;e<a&&(s-=e-a),l>d&&(s-=l-d),this._state.domain=[o+s,r+s];}reset(){this._state.domain=[...this._state.originalDomain],this._state.scale=1,this._state.offset=0;}get enabled(){return this._config.enabled??true}};var w=new Map;function R(u,t){return `${u}|${JSON.stringify(t??{})}`}function k(u,t){let n=R(u,t),o=w.get(n);return o||(o=new Intl.DateTimeFormat(u,t),w.set(n,o)),o}function M(){return typeof navigator<"u"?navigator.language:void 0}var y=class{#t;#e;constructor(t){this.#t=[...t.domain],this.#e=[...t.range];}map(t){let n=Number(t),[o,r]=this.#t,[i,a]=this.#e;return r===o?i:i+(n-o)/(r-o)*(a-i)}invert(t){let[n,o]=this.#t,[r,i]=this.#e;return i===r?n:n+(t-r)/(i-r)*(o-n)}domain(){return [...this.#t]}range(){return [...this.#e]}},g=[{label:"second",ms:1e3},{label:"2_seconds",ms:2e3},{label:"5_seconds",ms:5e3},{label:"10_seconds",ms:1e4},{label:"30_seconds",ms:3e4},{label:"minute",ms:6e4},{label:"5_minutes",ms:3e5},{label:"15_minutes",ms:9e5},{label:"30_minutes",ms:18e5},{label:"hour",ms:36e5},{label:"3_hours",ms:108e5},{label:"6_hours",ms:216e5},{label:"day",ms:864e5},{label:"week",ms:6048e5},{label:"month",ms:2592e6},{label:"3_months",ms:7776e6},{label:"6_months",ms:15552e6},{label:"year",ms:31536e6},{label:"2_years",ms:63072e6},{label:"5_years",ms:15768e7}],x=class{#t;#e;#n;constructor(t){this.#t=new y({domain:t.domain,range:t.range}),this.#e=t.locale||(M()??"en-US"),this.#n=t.timeZone;}map(t){return this.#t.map(Number(t))}invert(t){return this.#t.invert(t)}domain(){return this.#t.domain()}range(){return this.#t.range()}get timeZone(){return this.#n}get locale(){return this.#e}tickInterval(t,n=3,o=12){let[r,i]=this.#t.domain(),a=i-r;if(a<=0)return {interval:g[0].ms};let d=a/t,s=g[0].ms;for(let m of g)if(m.ms>=d){s=m.ms;break}let e=s,l=Math.round(a/e);for(;l>o&&e<g[g.length-1].ms;){let m=g.findIndex(p=>p.ms===e);e=g[Math.min(m+1,g.length-1)].ms,l=Math.round(a/e);}for(;l<n&&e>g[0].ms;){let m=g.findIndex(p=>p.ms===e);e=g[Math.max(m-1,0)].ms,l=Math.round(a/e);}return {interval:e}}ticks(t){let n=t?.minTicks??5,o=t?.maxTicks??12,{interval:r}=this.tickInterval((n+o)/2,n,o),[i,a]=this.#t.domain(),d=[],s=Math.ceil(i/r)*r;for(let e=s;e<=a;e+=r)d.push(e);return d}format(t,n){let o=this.#n?{...n,timeZone:this.#n}:n;return k(this.#e,o).format(new Date(t))}};function T(u){let t=1/0,n=-1/0;for(let o=0;o<u.length;o++){let r=u[o];r<t&&(t=r),r>n&&(n=r);}return [t,n]}var L={fontFamily:"Liberation Sans, Arial, Helvetica, sans-serif",stroke:"#4285f4",strokeWidth:2,pointSize:4,pointThreshold:100,gapThreshold:0,fill:"none",hatch:null,bandFill:"#4285f4",bandOpacity:.6,bandAvgLine:"#e53e3e",minColor:"#3b82f6",maxColor:"#ef4444",avgColor:"#64748b",areaFillAlpha:"4285f433",axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:11,axisLabelColor:"#444",axisLabelSize:12,gridStroke:"#e2e8f0",gridStrokeWidth:1,gridOpacity:1,legendStroke:"#ccc",legendText:"#333",legendFont:11,annotationColor:"#334155",annotationWidth:1.5,annotationHead:9,annotationRadius:4,annotationFontSize:11,markerFontSize:11,statFontSize:10,tooltipTimeFontSize:10,tooltipValueFontSize:11,thresholdColor:"#666",thresholdLine:"dashed",thresholdFillOpacity:.12,thresholdFontSize:10,highlightColor:"#fbbf24",highlightOpacity:.2,highlightLabelColor:"#92400e",markerColor:"#f59e0b",markerSize:5,gapFill:"#fff",gapStroke:"#ccc",gapStrokeWidth:1,gapFontColor:"#999",gapFontSize:10,gapFillOpacity:.15,tooltipBg:"#fff",tooltipBorder:"#cbd5e1",tooltipText:"#1e293b",tooltipValue:"#3b82f6",tooltipCrosshair:"#94a3b8",tooltipSnapRadius:20,statsLineColor:"#94a3b8",statsLabelColor:"#64748b",minimapStroke:"#94a3b8",minimapBg:"#f8f9fa",minimapBrush:"#3b82f644",palette:["#4285f4","#ea4335","#22c55e","#fbbc05","#9334ea","#12b5e5","#fb923c","#6366f1"]};var F={...L};function S(){return F}var f=new Proxy({},{get:(u,t)=>S()[t],has:(u,t)=>t in S(),ownKeys:()=>Reflect.ownKeys(S()),getOwnPropertyDescriptor:(u,t)=>Reflect.getOwnPropertyDescriptor(S(),t)});var C=class{_data;_width;_height;_x;_y;_zoom;_stroke;_bgColor;_brushColor;constructor(t){this._data=t.data,this._width=t.width,this._height=t.height,this._x=t.x,this._y=t.y,this._zoom=t.zoom,this._stroke=t.stroke??f.minimapStroke,this._bgColor=t.bgColor??f.minimapBg,this._brushColor=t.brushColor??f.minimapBrush;}render(){if(this._data.length===0)return [];let t=[],n=this._data.map(e=>e.time),o=this._data.map(e=>e.value).filter(e=>e!==null),r=T(n),i=T(o),a=new x({domain:r,range:[0,this._width]}),d=new y({domain:i,range:[this._height,0]});t.push({type:"rect",x:this._x,y:this._y,w:this._width,h:this._height,fill:this._bgColor});let s=this._data.map(e=>({x:this._x+a.map(e.time),y:this._y+d.map(e.value)}));if(t.push({type:"path",points:s,smoothing:false,stroke:this._stroke,strokeWidth:1}),this._zoom){let e=this._zoom.state,l=this._x+a.map(e.domain[0]),m=this._x+a.map(e.domain[1]),p=Math.max(2,m-l);t.push({type:"rect",x:l,y:this._y,w:p,h:this._height,fill:this._brushColor});}return t}navigateTo(t){let n=this._data.map(a=>a.time),o=T(n),r=new x({domain:o,range:[0,this._width]}),i=t-this._x;return r.invert(i)}};var D=class{_mouseX;_timeScale;_valueScale;_data;_xRange;_yRange;_snapRadius;_bgColor;_borderColor;_textColor;constructor(t){this._mouseX=t.mouseX,this._timeScale=t.timeScale,this._valueScale=t.valueScale,this._data=t.data,this._xRange=t.xRange,this._yRange=t.yRange,this._snapRadius=t.snapRadius??f.tooltipSnapRadius,this._bgColor=t.bgColor??f.tooltipBg,this._borderColor=t.borderColor??f.tooltipBorder,this._textColor=t.textColor??f.tooltipText;}compute(){let t=[...this._data].filter(h=>h.value!==null).sort((h,c)=>h.time-c.time),n,o=1/0;for(let h of t){let c=this._timeScale.map(h.time),b=Math.abs(this._mouseX-c);b<o&&(o=b,n=h);}if(!n||o>this._snapRadius)return {visible:false,commands:[]};let r=this._timeScale.map(n.time),i=this._valueScale.map(n.value),a=[];a.push({type:"line",x1:r,y1:this._yRange[0],x2:r,y2:this._yRange[1],stroke:"#94a3b8",strokeWidth:1},{type:"line",x1:this._xRange[0],y1:i,x2:this._xRange[1],y2:i,stroke:"#94a3b8",strokeWidth:1},{type:"circle",cx:r,cy:i,r:5,fill:"#3b82f6"});let d=new Date(n.time).toLocaleString(),s=n.value.toFixed(2),e=120,l=44,m=r+12,p=i-l-4;return m+e>this._xRange[1]&&(m=r-e-12),p<this._yRange[0]&&(p=i+12),a.push({type:"rect",x:m,y:p,w:e,h:l,fill:this._bgColor,stroke:this._borderColor,strokeWidth:1},{type:"text",content:d,x:m+8,y:p+16,fontSize:f.tooltipTimeFontSize,fill:this._textColor},{type:"text",content:`Value: ${s}`,x:m+8,y:p+32,fontSize:f.tooltipValueFontSize,fill:"#3b82f6"}),{visible:true,commands:a,dataPoint:n,snapX:r}}};/*!
2
2
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
3
3
  * MIT with Attribution: free use incl. commercial requires visible credit to
4
4
  * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
@@ -1,7 +1,7 @@
1
- import { k as Theme, t as RenderingContext, F as FlatSeriesStyle, T as TextMetrics, f as Marker } from './marker_renderer-VcAK5as0.js';
2
- export { u as Layout, v as LayoutConfig, a as LayoutResult, w as LegendConfig, L as LegendItem, e as LegendOrientation, R as Renderer, x as measureLegend, y as renderLegend, z as renderSeriesMarkers, q as slugify } from './marker_renderer-VcAK5as0.js';
3
- import { D as DataPoint, a as DrawCommand, t as AggregatedPoint, k as HatchVariant, f as Threshold, L as LinearScale, g as Gap, T as TimeScale, R as RangeLabelPosition, aa as GapBand, H as Highlight, i as Annotation, ab as LineParams, ac as PathParams, ad as RectParams, ae as CircleParams, af as TextParams, ag as GapParams, d as DrawGroup, z as AxisOrientation, A as AxisPosition, _ as MovingAverageType, ah as Point, E as EnumMap, ai as BandScale, S as SmoothingType, P as PointStyleType, r as AnnotationBandItem, c as LineVariant, X as LineShape, F as FillSpec, V as GapStyle, m as TimeSeries } from './types-D7tmWwH9.js';
4
- export { aj as BandScaleConfig, ak as Dashstyle_t, al as DomainScaleConfig, am as DrawCircle, an as DrawGap, ao as DrawGapType_t, ap as DrawLine, aq as DrawPath, ar as DrawRect, as as DrawText, q as LabelAnchor, at as LinearScaleConfig, au as Scale, av as ScaleConfig, aw as TIME_INTERVALS, ax as TimeScaleConfig, ay as getHatch } from './types-D7tmWwH9.js';
1
+ import { k as Theme, t as RenderingContext, F as FlatSeriesStyle, T as TextMetrics, f as Marker } from './marker_renderer-BZMcTbHC.js';
2
+ export { u as Layout, v as LayoutConfig, a as LayoutResult, w as LegendConfig, L as LegendItem, e as LegendOrientation, R as Renderer, x as measureLegend, y as renderLegend, z as renderSeriesMarkers, q as slugify } from './marker_renderer-BZMcTbHC.js';
3
+ import { D as DataPoint, a as DrawCommand, t as AggregatedPoint, k as HatchVariant, f as Threshold, L as LinearScale, g as Gap, T as TimeScale, R as RangeLabelPosition, ab as GapBand, H as Highlight, i as Annotation, ac as LineParams, ad as PathParams, ae as RectParams, af as CircleParams, ag as TextParams, ah as GapParams, d as DrawGroup, z as AxisOrientation, A as AxisPosition, _ as MovingAverageType, ai as Point, E as EnumMap, aj as BandScale, S as SmoothingType, P as PointStyleType, r as AnnotationBandItem, c as LineVariant, X as LineShape, F as FillSpec, V as GapStyle, m as TimeSeries } from './types-CNIUKrmy.js';
4
+ export { ak as BandScaleConfig, al as Dashstyle_t, am as DomainScaleConfig, an as DrawCircle, ao as DrawGap, ap as DrawGapType_t, aq as DrawLine, ar as DrawPath, as as DrawRect, at as DrawText, q as LabelAnchor, au as LinearScaleConfig, av as Scale, aw as ScaleConfig, ax as TIME_INTERVALS, ay as TimeScaleConfig, az as getHatch } from './types-CNIUKrmy.js';
5
5
  import { DataPoint as DataPoint$1 } from './analyze/index.js';
6
6
 
7
7
  /*!
package/dist/internals.js CHANGED
@@ -1,4 +1,4 @@
1
- var Z=class{};var T=class{static interpolateDataPoint(i,e,t){return {time:i.time+Math.round(t*(e.time-i.time)),value:(i.value??0)+t*((e.value??0)-(i.value??0)),synthetic:true}}static interpolateAggregatedPoint(i,e,t){let n=(r,o)=>r!==null&&o!==null?r+t*(o-r):null;return {time:i.time+t*(e.time-i.time),min:n(i.min,e.min),max:n(i.max,e.max),avg:n(i.avg,e.avg),count:Math.round(i.count+t*(e.count-i.count))}}static getRuns(i,e,t=0){let n=[...i].sort((s,a)=>s.time-a.time),r=[],o=[],l=null;for(let s of n){let a=e(s),m=t>0&&l&&s.time-l.time>t;(a||m)&&o.length&&(r.push(o),o=[]),a||o.push(s),l=s;}return o.length&&r.push(o),r}static splitByBoundaries(i,e,t,n){if(i.length===0)return [];if(e.length===0)return [{data:i,zoneIndex:0,zoneLow:Number.NEGATIVE_INFINITY}];let r=[...e].sort((m,u)=>m-u),o=[],l=m=>m<=0?Number.NEGATIVE_INFINITY:r[m-1],s=m=>{let u=0;for(let d=0;d<r.length&&m>=r[d];d++)u=d+1;return u},a=[i[0]];for(let m=1;m<i.length;m++){let u=i[m-1],d=i[m],h=t(u),p=t(d),c;p>h?c=r.filter(y=>y>h&&y<=p):p<h?c=r.filter(y=>y>=p&&y<h).reverse():c=[];let g=h;for(let y of c){let b=(y-h)/(p-h),x=n(u,d,b);a.push(x);let S=s((g+y)/2);o.push({data:a,zoneIndex:S,zoneLow:l(S)}),a=[x],g=y;}(c.length===0||c[c.length-1]!==p)&&a.push(d);}if(a.length>1||i.length===1){let m=t(a[0]),u=t(a[a.length-1]),d=s((m+u)/2);o.push({data:a,zoneIndex:d,zoneLow:l(d)});}return o}static splitByThreshold(i,e,t,n){let r=this.splitByBoundaries(i,[e],t,n),o={above:[],below:[]};for(let l of r)l.zoneIndex===0?o.below.push(l.data):o.above.push(l.data);return o}};var be=class{static compute(i){let e=i.map(s=>s.value).filter(s=>s!==null).sort((s,a)=>s-a);if(e.length===0)return {min:NaN,max:NaN,avg:NaN,mean:NaN,median:NaN,stdDev:NaN,count:0};let t=e.length,n=e.reduce((s,a)=>s+a,0)/t,r=t%2===1?e[Math.floor(t/2)]:(e[t/2-1]+e[t/2])/2,o=e.reduce((s,a)=>s+Math.pow(a-n,2),0)/t,l=Math.sqrt(o);return {min:e[0],max:e[t-1],avg:n,mean:n,median:r,stdDev:l,count:t}}static computeInRange(i,e,t){let n=i.filter(r=>r.time>=e&&r.time<=t);return this.compute(n)}};function K(i){let e=[];for(let t of i)e.length===0?e.push(t):e.push({x:t.x,y:e[e.length-1].y},t);return e}function $e(i){let e=[];for(let t of i)e.length>0&&e.push({...t,value:e[e.length-1].value}),e.push(t);return e}function _(i){return {id:i.id,line:{stroke:i.stroke??f.stroke,strokeWidth:i.strokeWidth??f.strokeWidth,smoothing:i.smoothing??false,smoothingType:i.smoothingType,dashed:i.dashed??false},fill:i.fill??f.areaFillAlpha,markers:{type:i.pointStyle??"none",size:i.pointSize??f.pointSize,stroke:i.stroke??f.stroke,fill:"#ffffff"},shadow:{color:i.shadowColor??"transparent",blur:i.shadowBlur??0,offsetX:i.shadowOffsetX??0,offsetY:i.shadowOffsetY??0}}}function Fe(i,e,t,n){let r=T.splitByThreshold(i,e,l=>l.value,T.interpolateDataPoint),o=[];return n.below&&o.push(...M(r.below.map(l=>({data:l})),t,n.below)),n.above&&o.push(...M(r.above.map(l=>({data:l})),t,n.above)),o}function M(i,e,t){let n=[],r=_(t);for(let o=0;o<i.length;o++){let l=i[o];l.data.length>=2?n.push({type:"path",cssClass:"series-line",id:t.id?`${t.id}-line-${o}`:void 0,points:l.data.map(s=>({x:e.timeScale.map(s.time),y:e.valueScale.map(s.value)})),stroke:l.color??r.line.stroke,strokeWidth:r.line.strokeWidth,smoothing:r.line.smoothing,smoothingType:r.line.smoothingType,dashed:r.line.dashed,shadowColor:r.shadow.color,shadowBlur:r.shadow.blur,shadowOffsetX:r.shadow.offsetX,shadowOffsetY:r.shadow.offsetY,fill:"none"}):l.data.length===1&&n.push({type:"circle",id:t.id?`${t.id}-dot-${o}`:void 0,cx:e.timeScale.map(l.data[0].time),cy:e.valueScale.map(l.data[0].value),r:Math.max(r.markers.size,r.line.strokeWidth),fill:l.color??r.line.stroke,shadowColor:r.shadow.color,shadowBlur:r.shadow.blur});}return n}function q(i,e,t){let n=[],r=_(t);for(let o=0;o<i.length;o++){let l=i[o];if(l.data.length<2)continue;let s=K(l.data.map(a=>({x:e.timeScale.map(a.time),y:e.valueScale.map(a.value)})));n.push({type:"path",cssClass:"series-line",id:t.id?`${t.id}-line-${o}`:void 0,points:s,stroke:l.color??r.line.stroke,strokeWidth:r.line.strokeWidth,smoothing:false,fill:"none"});}return n}function We(i,e,t,n,r){let o=[],l=_(t);for(let s=0;s<i.length;s++){let a=i[s];if(a.data.length<2)continue;let m=a.data.map(d=>({x:e.timeScale.map(d.time),y:e.valueScale.map(n(d))})),u=a.data.map(d=>({x:e.timeScale.map(d.time),y:e.valueScale.map(r(d))})).reverse();o.push({type:"path",cssClass:"series-fill",id:t.id?`${t.id}-fill-${s}`:void 0,points:[...m,...u],fill:a.color??l.fill,hatch:t.hatch,stroke:"none"});}return o}function J(i,e,t,n){if(i.length<2)return [];let r=T.splitByBoundaries(i,t.boundaries,t.getValue,t.interpolate),o=[];for(let l=0;l<r.length;l++){let s=r[l];if(s.data.length<2)continue;let a=t.getColor(s.zoneIndex);if(!a)continue;let m=s.data.map(d=>({x:e.timeScale.map(d.time),y:e.valueScale.map(t.yLow(d))})),u=s.data.map(d=>({x:e.timeScale.map(d.time),y:e.valueScale.map(t.yHigh(d))})).reverse();o.push({type:"path",cssClass:"series-fill",id:n?.id?`${n.id}-fill-${l}`:void 0,points:[...m,...u],fill:a,hatch:t.getHatch?.(s.zoneIndex),stroke:"none",...n?.smoothing?{smoothing:true,smoothingType:n.smoothingType,smoothCount:s.data.length,smoothTail:s.data.length}:{}});}return o}function Q(i,e,t,n){let r=_(t);if(!r.markers.type||r.markers.type==="none")return [];let o=[];for(let l=0;l<i.length;l++){let s=i[l],a=e.timeScale.map(s.time),m=e.valueScale.map(s.value),u=n(s),d=t.pointStroke??u,h=t.pointFill??u,p=t.pointStrokeWidth??1.5,c=t.id?`${t.id}-marker-${l}`:void 0;ee(o,c,r.markers.type,a,m,r.markers.size,d,h,p);}return o.length===0?[]:[{type:"group",cssClass:"series-markers",sharedStyles:true,commands:o}]}function ee(i,e,t,n,r,o,l,s,a){let m=u=>e===void 0?void 0:`${e}-${u}`;switch(t){case "circle":i.push({type:"circle",cx:n,cy:r,r:o,fill:s,stroke:l,strokeWidth:a,id:e});break;case "square":i.push({type:"rect",x:n-o,y:r-o,w:o*2,h:o*2,fill:s,stroke:l,strokeWidth:a,id:e});break;case "cross":i.push({type:"line",x1:n-o,y1:r-o,x2:n+o,y2:r+o,stroke:l,strokeWidth:a,id:e},{type:"line",x1:n-o,y1:r+o,x2:n+o,y2:r-o,stroke:l,strokeWidth:a,id:m(2)});break;case "diamond":i.push({type:"path",points:[{x:n,y:r-o},{x:n+o,y:r},{x:n,y:r+o},{x:n-o,y:r}],closed:true,fill:s,stroke:l,strokeWidth:a,id:e});break;case "triangle":i.push({type:"path",points:[{x:n,y:r-o},{x:n+o,y:r+o},{x:n-o,y:r+o}],closed:true,fill:s,stroke:l,strokeWidth:a,id:e});break;case "star":{let u=[];for(let d=0;d<10;d++){let h=d%2===0?o:o*.5,p=Math.PI/2*3+d*Math.PI/5;u.push({x:n+h*Math.cos(p),y:r+h*Math.sin(p)});}i.push({type:"path",points:u,closed:true,fill:s,stroke:l,strokeWidth:a,id:e});break}case "arrow":i.push({type:"path",points:[{x:n-o,y:r+o},{x:n,y:r-o},{x:n+o,y:r+o}],stroke:l,strokeWidth:a,fill:"none",id:e});break;case "plus":i.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:l,strokeWidth:a,id:e},{type:"line",x1:n,y1:r-o,x2:n,y2:r+o,stroke:l,strokeWidth:a,id:m(2)});break;case "triangle-down":i.push({type:"path",points:[{x:n,y:r+o},{x:n+o,y:r-o},{x:n-o,y:r-o}],closed:true,fill:s,stroke:l,strokeWidth:a,id:e});break;case "hexagon":{let u=[];for(let d=0;d<6;d++){let h=d*(Math.PI/3);u.push({x:n+o*Math.cos(h),y:r+o*Math.sin(h)});}i.push({type:"path",points:u,closed:true,fill:s,stroke:l,strokeWidth:a,id:e});break}case "hourglass":i.push({type:"path",points:[{x:n-o,y:r-o},{x:n+o,y:r-o},{x:n-o,y:r+o},{x:n+o,y:r+o}],closed:true,fill:s,stroke:l,strokeWidth:a,id:e});break;case "line-horizontal":i.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:l,strokeWidth:a,id:e});break;default:i.push({type:"circle",cx:n,cy:r,r:o,fill:s,stroke:l,strokeWidth:a,id:e});}}var je=[[32,126,"278,278,355,556,556,889,667,191,333,333,389,584,278,333,278,278,556,556,556,556,556,556,556,556,556,556,278,278,584,584,584,556,1015,667,667,722,722,667,611,778,722,278,500,667,556,833,722,778,667,778,722,667,611,722,667,944,667,667,611,278,278,278,469,556,333,556,556,500,556,556,278,556,556,222,222,500,222,833,556,556,556,556,333,500,278,556,500,722,500,500,500,334,260,334,584"],[160,255,"278,333,556,556,556,556,260,556,333,737,370,556,584,333,737,552,400,549,333,333,333,576,537,333,333,333,365,556,834,834,834,611,667,667,667,667,667,667,1000,722,667,667,667,667,278,278,278,278,722,722,778,778,778,778,778,584,778,722,722,722,722,667,667,611,556,556,556,556,556,556,889,500,556,556,556,556,278,278,278,278,556,556,556,556,556,556,556,549,611,556,556,556,556,500,556,500"]],xe=.6,Oe=(()=>{let i=new Map;for(let[e,,t]of je){let n=t.split(",");for(let r=0;r<n.length;r++)i.set(e+r,Number(n[r])/1e3);}return i})();function Se(i){return Oe.get(i)??xe}var j=(i,e)=>{let t=0;for(let n of i)t+=Se(n.codePointAt(0)??0);return t*e};var ke={fontFamily:"Liberation Sans, Arial, Helvetica, sans-serif",stroke:"#4285f4",strokeWidth:2,pointSize:4,pointThreshold:100,gapThreshold:0,fill:"none",hatch:null,bandFill:"#4285f4",bandOpacity:.6,bandAvgLine:"#e53e3e",minColor:"#3b82f6",maxColor:"#ef4444",avgColor:"#64748b",areaFillAlpha:"4285f433",axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:11,axisLabelColor:"#444",axisLabelSize:12,gridStroke:"#e2e8f0",gridStrokeWidth:1,gridOpacity:1,legendStroke:"#ccc",legendText:"#333",legendFont:11,annotationColor:"#334155",annotationWidth:1.5,annotationHead:9,annotationRadius:4,annotationFontSize:11,markerFontSize:11,statFontSize:10,tooltipTimeFontSize:10,tooltipValueFontSize:11,thresholdColor:"#666",thresholdLine:"dashed",thresholdFillOpacity:.12,thresholdFontSize:10,highlightColor:"#fbbf24",highlightOpacity:.2,highlightLabelColor:"#92400e",markerColor:"#f59e0b",markerSize:5,gapFill:"#fff",gapStroke:"#ccc",gapStrokeWidth:1,gapFontColor:"#999",gapFontSize:10,gapFillOpacity:.15,tooltipBg:"#fff",tooltipBorder:"#cbd5e1",tooltipText:"#1e293b",tooltipValue:"#3b82f6",tooltipCrosshair:"#94a3b8",tooltipSnapRadius:20,statsLineColor:"#94a3b8",statsLabelColor:"#64748b",minimapStroke:"#94a3b8",minimapBg:"#f8f9fa",minimapBrush:"#3b82f644",palette:["#4285f4","#ea4335","#22c55e","#fbbc05","#9334ea","#12b5e5","#fb923c","#6366f1"]};var Ie={...ke};function L(){return Ie}function Ee(i){let e=i.trim();if(e.startsWith("#"))return e.length===9?e.slice(0,7):e.length===5?e.slice(0,4):e;if(e.toLowerCase().startsWith("rgba(")){let n=e.slice(5,e.lastIndexOf(")")).split(",");if(n.length===4)return `rgb(${n[0].trim()}, ${n[1].trim()}, ${n[2].trim()})`}return e}function He(i){let e=i.trim().toLowerCase();return e.startsWith("#")?e.length===9||e.length===5:e.startsWith("rgba(")||e.startsWith("hsla(")}function Te(i,e="classic-diagonal",t="rgba(200, 220, 255, 0.3)",n,r=2){let o=n??Ee(t),l=He(t)?"":' fill-opacity="0.3"';if(e==="none")return `
1
+ var Z=class{};var T=class{static interpolateDataPoint(i,e,t){return {time:i.time+Math.round(t*(e.time-i.time)),value:(i.value??0)+t*((e.value??0)-(i.value??0)),synthetic:true}}static interpolateAggregatedPoint(i,e,t){let n=(r,o)=>r!==null&&o!==null?r+t*(o-r):null;return {time:i.time+t*(e.time-i.time),min:n(i.min,e.min),max:n(i.max,e.max),avg:n(i.avg,e.avg),count:Math.round(i.count+t*(e.count-i.count))}}static getRuns(i,e,t=0){let n=[...i].sort((s,a)=>s.time-a.time),r=[],o=[],l=null;for(let s of n){let a=e(s),m=t>0&&l&&s.time-l.time>t;(a||m)&&o.length&&(r.push(o),o=[]),a||o.push(s),l=s;}return o.length&&r.push(o),r}static splitByBoundaries(i,e,t,n){if(i.length===0)return [];if(e.length===0)return [{data:i,zoneIndex:0,zoneLow:Number.NEGATIVE_INFINITY}];let r=[...e].sort((m,u)=>m-u),o=[],l=m=>m<=0?Number.NEGATIVE_INFINITY:r[m-1],s=m=>{let u=0;for(let d=0;d<r.length&&m>=r[d];d++)u=d+1;return u},a=[i[0]];for(let m=1;m<i.length;m++){let u=i[m-1],d=i[m],p=t(u),c=t(d),h;c>p?h=r.filter(y=>y>p&&y<=c):c<p?h=r.filter(y=>y>=c&&y<p).reverse():h=[];let g=p;for(let y of h){let b=(y-p)/(c-p),x=n(u,d,b);a.push(x);let S=s((g+y)/2);o.push({data:a,zoneIndex:S,zoneLow:l(S)}),a=[x],g=y;}(h.length===0||h[h.length-1]!==c)&&a.push(d);}if(a.length>1||i.length===1){let m=t(a[0]),u=t(a[a.length-1]),d=s((m+u)/2);o.push({data:a,zoneIndex:d,zoneLow:l(d)});}return o}static splitByThreshold(i,e,t,n){let r=this.splitByBoundaries(i,[e],t,n),o={above:[],below:[]};for(let l of r)l.zoneIndex===0?o.below.push(l.data):o.above.push(l.data);return o}};var be=class{static compute(i){let e=i.map(s=>s.value).filter(s=>s!==null).sort((s,a)=>s-a);if(e.length===0)return {min:NaN,max:NaN,avg:NaN,mean:NaN,median:NaN,stdDev:NaN,count:0};let t=e.length,n=e.reduce((s,a)=>s+a,0)/t,r=t%2===1?e[Math.floor(t/2)]:(e[t/2-1]+e[t/2])/2,o=e.reduce((s,a)=>s+Math.pow(a-n,2),0)/t,l=Math.sqrt(o);return {min:e[0],max:e[t-1],avg:n,mean:n,median:r,stdDev:l,count:t}}static computeInRange(i,e,t){let n=i.filter(r=>r.time>=e&&r.time<=t);return this.compute(n)}};function K(i){let e=[];for(let t of i)e.length===0?e.push(t):e.push({x:t.x,y:e[e.length-1].y},t);return e}function $e(i){let e=[];for(let t of i)e.length>0&&e.push({...t,value:e[e.length-1].value}),e.push(t);return e}function _(i){return {id:i.id,line:{stroke:i.stroke??f.stroke,strokeWidth:i.strokeWidth??f.strokeWidth,smoothing:i.smoothing??false,smoothingType:i.smoothingType,dashed:i.dashed??false},fill:i.fill??f.areaFillAlpha,markers:{type:i.pointStyle??"none",size:i.pointSize??f.pointSize,stroke:i.stroke??f.stroke,fill:"#ffffff"},shadow:{color:i.shadowColor??"transparent",blur:i.shadowBlur??0,offsetX:i.shadowOffsetX??0,offsetY:i.shadowOffsetY??0}}}function Fe(i,e,t,n){let r=T.splitByThreshold(i,e,l=>l.value,T.interpolateDataPoint),o=[];return n.below&&o.push(...L(r.below.map(l=>({data:l})),t,n.below)),n.above&&o.push(...L(r.above.map(l=>({data:l})),t,n.above)),o}function L(i,e,t){let n=[],r=_(t);for(let o=0;o<i.length;o++){let l=i[o];l.data.length>=2?n.push({type:"path",cssClass:"series-line",id:t.id?`${t.id}-line-${o}`:void 0,points:l.data.map(s=>({x:e.timeScale.map(s.time),y:e.valueScale.map(s.value)})),stroke:l.color??r.line.stroke,strokeWidth:r.line.strokeWidth,smoothing:r.line.smoothing,smoothingType:r.line.smoothingType,dashed:r.line.dashed,shadowColor:r.shadow.color,shadowBlur:r.shadow.blur,shadowOffsetX:r.shadow.offsetX,shadowOffsetY:r.shadow.offsetY,fill:"none"}):l.data.length===1&&n.push({type:"circle",id:t.id?`${t.id}-dot-${o}`:void 0,cx:e.timeScale.map(l.data[0].time),cy:e.valueScale.map(l.data[0].value),r:Math.max(r.markers.size,r.line.strokeWidth),fill:l.color??r.line.stroke,shadowColor:r.shadow.color,shadowBlur:r.shadow.blur});}return n}function q(i,e,t){let n=[],r=_(t);for(let o=0;o<i.length;o++){let l=i[o];if(l.data.length<2)continue;let s=K(l.data.map(a=>({x:e.timeScale.map(a.time),y:e.valueScale.map(a.value)})));n.push({type:"path",cssClass:"series-line",id:t.id?`${t.id}-line-${o}`:void 0,points:s,stroke:l.color??r.line.stroke,strokeWidth:r.line.strokeWidth,smoothing:false,fill:"none"});}return n}function We(i,e,t,n,r){let o=[],l=_(t);for(let s=0;s<i.length;s++){let a=i[s];if(a.data.length<2)continue;let m=a.data.map(d=>({x:e.timeScale.map(d.time),y:e.valueScale.map(n(d))})),u=a.data.map(d=>({x:e.timeScale.map(d.time),y:e.valueScale.map(r(d))})).reverse();o.push({type:"path",cssClass:"series-fill",id:t.id?`${t.id}-fill-${s}`:void 0,points:[...m,...u],fill:a.color??l.fill,hatch:t.hatch,stroke:"none"});}return o}function J(i,e,t,n){if(i.length<2)return [];let r=T.splitByBoundaries(i,t.boundaries,t.getValue,t.interpolate),o=[];for(let l=0;l<r.length;l++){let s=r[l];if(s.data.length<2)continue;let a=t.getColor(s.zoneIndex);if(!a)continue;let m=s.data.map(d=>({x:e.timeScale.map(d.time),y:e.valueScale.map(t.yLow(d))})),u=s.data.map(d=>({x:e.timeScale.map(d.time),y:e.valueScale.map(t.yHigh(d))})).reverse();o.push({type:"path",cssClass:"series-fill",id:n?.id?`${n.id}-fill-${l}`:void 0,points:[...m,...u],fill:a,hatch:t.getHatch?.(s.zoneIndex),stroke:"none",...n?.smoothing?{smoothing:true,smoothingType:n.smoothingType,smoothCount:s.data.length,smoothTail:s.data.length}:{}});}return o}function Q(i,e,t,n){let r=_(t);if(!r.markers.type||r.markers.type==="none")return [];let o=[];for(let l=0;l<i.length;l++){let s=i[l],a=e.timeScale.map(s.time),m=e.valueScale.map(s.value),u=n(s),d=t.pointStroke??u,p=t.pointFill??u,c=t.pointStrokeWidth??1.5,h=t.id?`${t.id}-marker-${l}`:void 0;ee(o,h,r.markers.type,a,m,r.markers.size,d,p,c);}return o.length===0?[]:[{type:"group",cssClass:"series-markers",sharedStyles:true,commands:o}]}function ee(i,e,t,n,r,o,l,s,a){let m=u=>e===void 0?void 0:`${e}-${u}`;switch(t){case "circle":i.push({type:"circle",cx:n,cy:r,r:o,fill:s,stroke:l,strokeWidth:a,id:e});break;case "square":i.push({type:"rect",x:n-o,y:r-o,w:o*2,h:o*2,fill:s,stroke:l,strokeWidth:a,id:e});break;case "cross":i.push({type:"line",x1:n-o,y1:r-o,x2:n+o,y2:r+o,stroke:l,strokeWidth:a,id:e},{type:"line",x1:n-o,y1:r+o,x2:n+o,y2:r-o,stroke:l,strokeWidth:a,id:m(2)});break;case "diamond":i.push({type:"path",points:[{x:n,y:r-o},{x:n+o,y:r},{x:n,y:r+o},{x:n-o,y:r}],closed:true,fill:s,stroke:l,strokeWidth:a,id:e});break;case "triangle":i.push({type:"path",points:[{x:n,y:r-o},{x:n+o,y:r+o},{x:n-o,y:r+o}],closed:true,fill:s,stroke:l,strokeWidth:a,id:e});break;case "star":{let u=[];for(let d=0;d<10;d++){let p=d%2===0?o:o*.5,c=Math.PI/2*3+d*Math.PI/5;u.push({x:n+p*Math.cos(c),y:r+p*Math.sin(c)});}i.push({type:"path",points:u,closed:true,fill:s,stroke:l,strokeWidth:a,id:e});break}case "arrow":i.push({type:"path",points:[{x:n-o,y:r+o},{x:n,y:r-o},{x:n+o,y:r+o}],stroke:l,strokeWidth:a,fill:"none",id:e});break;case "plus":i.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:l,strokeWidth:a,id:e},{type:"line",x1:n,y1:r-o,x2:n,y2:r+o,stroke:l,strokeWidth:a,id:m(2)});break;case "triangle-down":i.push({type:"path",points:[{x:n,y:r+o},{x:n+o,y:r-o},{x:n-o,y:r-o}],closed:true,fill:s,stroke:l,strokeWidth:a,id:e});break;case "hexagon":{let u=[];for(let d=0;d<6;d++){let p=d*(Math.PI/3);u.push({x:n+o*Math.cos(p),y:r+o*Math.sin(p)});}i.push({type:"path",points:u,closed:true,fill:s,stroke:l,strokeWidth:a,id:e});break}case "hourglass":i.push({type:"path",points:[{x:n-o,y:r-o},{x:n+o,y:r-o},{x:n-o,y:r+o},{x:n+o,y:r+o}],closed:true,fill:s,stroke:l,strokeWidth:a,id:e});break;case "line-horizontal":i.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:l,strokeWidth:a,id:e});break;default:i.push({type:"circle",cx:n,cy:r,r:o,fill:s,stroke:l,strokeWidth:a,id:e});}}var je=[[32,126,"278,278,355,556,556,889,667,191,333,333,389,584,278,333,278,278,556,556,556,556,556,556,556,556,556,556,278,278,584,584,584,556,1015,667,667,722,722,667,611,778,722,278,500,667,556,833,722,778,667,778,722,667,611,722,667,944,667,667,611,278,278,278,469,556,333,556,556,500,556,556,278,556,556,222,222,500,222,833,556,556,556,556,333,500,278,556,500,722,500,500,500,334,260,334,584"],[160,255,"278,333,556,556,556,556,260,556,333,737,370,556,584,333,737,552,400,549,333,333,333,576,537,333,333,333,365,556,834,834,834,611,667,667,667,667,667,667,1000,722,667,667,667,667,278,278,278,278,722,722,778,778,778,778,778,584,778,722,722,722,722,667,667,611,556,556,556,556,556,556,889,500,556,556,556,556,278,278,278,278,556,556,556,556,556,556,556,549,611,556,556,556,556,500,556,500"]],xe=.6,Oe=(()=>{let i=new Map;for(let[e,,t]of je){let n=t.split(",");for(let r=0;r<n.length;r++)i.set(e+r,Number(n[r])/1e3);}return i})();function Se(i){return Oe.get(i)??xe}var j=(i,e)=>{let t=0;for(let n of i)t+=Se(n.codePointAt(0)??0);return t*e};var ke={fontFamily:"Liberation Sans, Arial, Helvetica, sans-serif",stroke:"#4285f4",strokeWidth:2,pointSize:4,pointThreshold:100,gapThreshold:0,fill:"none",hatch:null,bandFill:"#4285f4",bandOpacity:.6,bandAvgLine:"#e53e3e",minColor:"#3b82f6",maxColor:"#ef4444",avgColor:"#64748b",areaFillAlpha:"4285f433",axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:11,axisLabelColor:"#444",axisLabelSize:12,gridStroke:"#e2e8f0",gridStrokeWidth:1,gridOpacity:1,legendStroke:"#ccc",legendText:"#333",legendFont:11,annotationColor:"#334155",annotationWidth:1.5,annotationHead:9,annotationRadius:4,annotationFontSize:11,markerFontSize:11,statFontSize:10,tooltipTimeFontSize:10,tooltipValueFontSize:11,thresholdColor:"#666",thresholdLine:"dashed",thresholdFillOpacity:.12,thresholdFontSize:10,highlightColor:"#fbbf24",highlightOpacity:.2,highlightLabelColor:"#92400e",markerColor:"#f59e0b",markerSize:5,gapFill:"#fff",gapStroke:"#ccc",gapStrokeWidth:1,gapFontColor:"#999",gapFontSize:10,gapFillOpacity:.15,tooltipBg:"#fff",tooltipBorder:"#cbd5e1",tooltipText:"#1e293b",tooltipValue:"#3b82f6",tooltipCrosshair:"#94a3b8",tooltipSnapRadius:20,statsLineColor:"#94a3b8",statsLabelColor:"#64748b",minimapStroke:"#94a3b8",minimapBg:"#f8f9fa",minimapBrush:"#3b82f644",palette:["#4285f4","#ea4335","#22c55e","#fbbc05","#9334ea","#12b5e5","#fb923c","#6366f1"]};var Ie={...ke};function D(){return Ie}function Ee(i){let e=i.trim();if(e.startsWith("#"))return e.length===9?e.slice(0,7):e.length===5?e.slice(0,4):e;if(e.toLowerCase().startsWith("rgba(")){let n=e.slice(5,e.lastIndexOf(")")).split(",");if(n.length===4)return `rgb(${n[0].trim()}, ${n[1].trim()}, ${n[2].trim()})`}return e}function He(i){let e=i.trim().toLowerCase();return e.startsWith("#")?e.length===9||e.length===5:e.startsWith("rgba(")||e.startsWith("hsla(")}function Te(i,e="classic-diagonal",t="rgba(200, 220, 255, 0.3)",n,r=2){let o=n??Ee(t),l=He(t)?"":' fill-opacity="0.3"';if(e==="none")return `
2
2
  <pattern id="${i}" width="10" height="10" patternUnits="userSpaceOnUse">
3
3
  <rect width="10" height="10" fill="${t}" />
4
4
  </pattern>
@@ -21,10 +21,10 @@ var Z=class{};var T=class{static interpolateDataPoint(i,e,t){return {time:i.time
21
21
  ${d}
22
22
  ${u}
23
23
  </pattern>
24
- `.trim()}var f=new Proxy({},{get:(i,e)=>L()[e],has:(i,e)=>e in L(),ownKeys:()=>Reflect.ownKeys(L()),getOwnPropertyDescriptor:(i,e)=>Reflect.getOwnPropertyDescriptor(L(),e)});var O=class i{#e=[];get commands(){return [...this.#e]}get length(){return this.#e.length}line(e){return this.#e.push({type:"line",...e}),this}path(e){return this.#e.push({type:"path",...e}),this}rect(e){return this.#e.push({type:"rect",...e}),this}circle(e){return this.#e.push({type:"circle",...e}),this}text(e){return this.#e.push({type:"text",...e}),this}gap(e){return this.#e.push({type:"gap",...e}),this}push(...e){return this.#e.push(...e),this}group(e,t){let n=new i;return t(n),n.length===0?this:(this.#e.push({type:"group",...e,commands:n.commands}),this)}toGroup(e={}){return {type:"group",...e,commands:this.commands}}};var ze="#ffffff",Ge="#cccccc",Ve=6,Ne=.85,D=12,N=8,I=20,Xe=11,V=18,te=(i,e)=>e(i,Xe);function we(i,e,t){let n=s=>D+N+te(s.name,e);if(t===void 0){let s=i.reduce((a,m)=>a+n(m)+V,0)-V;return [{items:i,breite:Math.max(0,s)}]}let r=[],o=[],l=0;for(let s of i){let a=n(s),m=o.length===0?a:l+V+a;o.length>0&&m>t?(r.push({items:o,breite:l}),o=[s],l=a):(o=[...o,s],l=m);}return o.length>0&&r.push({items:o,breite:l}),r}function ve(i,e="vertical",t=j,n){if(e==="horizontal"){let o=we(i,t,n);return {width:o.reduce((l,s)=>Math.max(l,s.breite),0),height:o.length*I}}let r=0;for(let o of i)r=Math.max(r,te(o.name,t));return {width:D+N+r,height:i.length*I}}function Ye(i){let{items:e,x:t,y:n,orientation:r="vertical",metrics:o=j,maxBreite:l,box:s,itemClass:a}=i,m=new O;if(s&&e.length>0){let h=ve(e,r,o,l),c=((r==="horizontal"?h.height/I:e.length)-1)*I+D,g=s.padding??Ve,y=s.stroke??Ge;m.rect({x:t-g,y:n-g,w:h.width+2*g,h:c+2*g,fill:s.fill??ze,...y==="none"?{}:{stroke:y,strokeWidth:s.strokeWidth??1},opacity:s.opacity??Ne});}let u=r==="horizontal"?we(e,o,l):e.map(h=>({items:[h],breite:0})),d=new Map;return u.forEach((h,p)=>{let c=t;for(let g of h.items)d.set(g,{x:c,y:n+p*I}),c+=D+N+te(g.name,o)+V;}),e.forEach(h=>{let p=d.get(h)??{x:t,y:n},c=p.x,g=p.y,y=["legend-item"];h.id&&y.push(`legend-item--${h.id}`),a&&y.push(a),m.group({cssClass:y.join(" "),...h.id?{id:`legend-${h.id}`}:{}},b=>{b.rect({x:c,y:g,w:D,h:D,fill:h.color,stroke:f.legendStroke,strokeWidth:1}).text({content:h.name,x:c+D+N,y:g+D-2,fontSize:f.legendFont,fill:f.legendText});});}),m.toGroup({cssClass:"chart-legend"})}function Ue(i){let{xTicks:e,yTicks:t,xRange:n,yRange:r,stroke:o=f.gridStroke,strokeWidth:l=f.gridStrokeWidth,dashed:s=false,opacity:a=f.gridOpacity}=i,m=[];if(t)for(let u of t)m.push({type:"line",x1:n[0],y1:u,x2:n[1],y2:u,stroke:o,strokeWidth:l,dashed:s,opacity:a});if(e)for(let u of e)m.push({type:"line",x1:u,y1:r[0],x2:u,y2:r[1],stroke:o,strokeWidth:l,dashed:s,opacity:a});return m}var Ce=new Map;function Ze(i,e){return `${i}|${JSON.stringify(e??{})}`}function B(i,e){let t=Ze(i,e),n=Ce.get(t);return n||(n=new Intl.DateTimeFormat(i,e),Ce.set(t,n)),n}function X(){return typeof navigator<"u"?navigator.language:void 0}var A=class{#e;#t;constructor(e){this.#e=[...e.domain],this.#t=[...e.range];}map(e){let t=Number(e),[n,r]=this.#e,[o,l]=this.#t;return r===n?o:o+(t-n)/(r-n)*(l-o)}invert(e){let[t,n]=this.#e,[r,o]=this.#t;return o===r?t:t+(e-r)/(o-r)*(n-t)}domain(){return [...this.#e]}range(){return [...this.#t]}},w=[{label:"second",ms:1e3},{label:"2_seconds",ms:2e3},{label:"5_seconds",ms:5e3},{label:"10_seconds",ms:1e4},{label:"30_seconds",ms:3e4},{label:"minute",ms:6e4},{label:"5_minutes",ms:3e5},{label:"15_minutes",ms:9e5},{label:"30_minutes",ms:18e5},{label:"hour",ms:36e5},{label:"3_hours",ms:108e5},{label:"6_hours",ms:216e5},{label:"day",ms:864e5},{label:"week",ms:6048e5},{label:"month",ms:2592e6},{label:"3_months",ms:7776e6},{label:"6_months",ms:15552e6},{label:"year",ms:31536e6},{label:"2_years",ms:63072e6},{label:"5_years",ms:15768e7}],E=class{#e;#t;#n;constructor(e){this.#e=new A({domain:e.domain,range:e.range}),this.#t=e.locale||(X()??"en-US"),this.#n=e.timeZone;}map(e){return this.#e.map(Number(e))}invert(e){return this.#e.invert(e)}domain(){return this.#e.domain()}range(){return this.#e.range()}get timeZone(){return this.#n}get locale(){return this.#t}tickInterval(e,t=3,n=12){let[r,o]=this.#e.domain(),l=o-r;if(l<=0)return {interval:w[0].ms};let s=l/e,a=w[0].ms;for(let d of w)if(d.ms>=s){a=d.ms;break}let m=a,u=Math.round(l/m);for(;u>n&&m<w[w.length-1].ms;){let d=w.findIndex(h=>h.ms===m);m=w[Math.min(d+1,w.length-1)].ms,u=Math.round(l/m);}for(;u<t&&m>w[0].ms;){let d=w.findIndex(h=>h.ms===m);m=w[Math.max(d-1,0)].ms,u=Math.round(l/m);}return {interval:m}}ticks(e){let t=e?.minTicks??5,n=e?.maxTicks??12,{interval:r}=this.tickInterval((t+n)/2,t,n),[o,l]=this.#e.domain(),s=[],a=Math.ceil(o/r)*r;for(let m=a;m<=l;m+=r)s.push(m);return s}format(e,t){let n=this.#n?{...t,timeZone:this.#n}:t;return B(this.#t,n).format(new Date(e))}},H=class{#e;#t;#n;#r;constructor(e){this.#e=[...e.domain],this.#t=[...e.range],this.#n=e.paddingInner??.1,this.#r=e.paddingOuter??.05;}get step(){let[e,t]=this.#t,n=this.#e.length;return n<=1?Math.abs(t-e):Math.abs(t-e)*(1-this.#r*2)/n+Math.abs(t-e)*this.#n*2/n}get bandwidth(){let[e,t]=this.#t,n=this.#e.length;if(n<=1)return Math.abs(t-e)*(1-this.#r*2);let r=this.#r*2*Math.abs(t-e);return (Math.abs(t-e)-r)/n*(1-this.#n)}map(e){let t=this.#e.findIndex(d=>String(d)===String(e));if(t===-1)return this.#t[0];let[n,r]=this.#t,o=this.#e.length;if(o<=1)return (n+r)/2;let l=this.#r*2*Math.abs(r-n),s=Math.abs(r-n)-l,a=r>=n?1:-1,m=s/o;return n+this.#r*Math.abs(r-n)*a+t*m}invert(e){let t=0,n=1/0;for(let r=0;r<this.#e.length;r++){let o=this.map(this.#e[r]),l=Math.abs(e-o);l<n&&(n=l,t=r);}return this.#e[t]}domain(){return this.#e.length===0?["",""]:[this.#e[0],this.#e[this.#e.length-1]]}range(){return [...this.#t]}positions(){let e=new Map;for(let t of this.#e)e.set(t,this.map(t));return e}};function ne(i){return i&&i.toString().normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"unnamed"}function Ke(i){return i==="dotted"?{dash:"dotted"}:i==="dashed"?{dash:"dashed"}:{}}function qe(i){let{thresholds:e,valueScale:t,xRange:n}=i,[r,o]=n,[l,s]=t.range(),a=Math.min(l,s),m=Math.max(l,s),u=[],d=[];for(let h of e){let p=h.color??f.thresholdColor,c=t.map(h.value);h.fill==="above"?u.push({type:"rect",x:r,y:a,w:o-r,h:Math.max(0,c-a),fill:p,hatch:h.fillHatch,opacity:h.fillOpacity??.12,id:h.id?`${h.id}-fill`:void 0}):h.fill==="below"&&u.push({type:"rect",x:r,y:c,w:o-r,h:Math.max(0,m-c),fill:p,hatch:h.fillHatch,opacity:h.fillOpacity??.12,id:h.id?`${h.id}-fill`:void 0});let g=h.line??f.thresholdLine;if(g!=="none"){let S=Ke(g),k={type:"line",x1:r,y1:c,x2:o,y2:c,stroke:p,strokeWidth:1,...S,id:h.id?`${h.id}-line`:void 0};h.shadowColor&&(k.shadowColor=h.shadowColor,k.shadowBlur=h.shadowBlur??4,k.shadowOffsetX=h.shadowOffsetX??0,k.shadowOffsetY=h.shadowOffsetY??2),u.push(k);}let[y,b]=t.domain();if(h.value>=Math.min(y,b)&&h.value<=Math.max(y,b)&&h.label!==void 0&&h.label!==null&&h.label!==false){let S=typeof h.label=="object"?h.label:void 0,k=typeof h.label=="string"?h.label:S?.text??h.name,v=S?.position??"right",W=et(k,v,r,o,c,p,S);d.push({...W,y:Qe(W.y,Math.min(l,s),Math.max(l,s),f.thresholdFontSize),id:h.id?`${h.id}-label`:void 0});}}return {inside:u,labels:d}}function Je(i){let e=qe(i);return [...e.inside,...e.labels]}function Qe(i,e,t,n){return Math.max(e+n,Math.min(t-n/2,i))}function et(i,e,t,n,r,o,l){let s=(t+n)/2,a={type:"text",content:i,fontSize:f.thresholdFontSize,fill:o},m=l?{...l.rotate!==void 0&&{rotate:l.rotate},...l.textBaseline!==void 0&&{textBaseline:l.textBaseline}}:{};switch(e){case "left":return {...a,...m,x:t+4,y:r-4,anchor:"start"};case "above":return {...a,...m,x:s,y:r-6,anchor:"middle"};case "below":return {...a,...m,x:s,y:r+14,anchor:"middle"};case "center":return {...a,...m,x:s,y:r-4,anchor:"middle"};case "outside-left":return {...a,...m,x:t-6,y:r+3,anchor:"end",textBaseline:m.textBaseline??"middle"};case "outside-right":return {...a,...m,x:n+6,y:r+3,anchor:"start",textBaseline:m.textBaseline??"middle"};default:return {...a,...m,x:n-4,y:r-4,anchor:"end"}}}function Me(i,e,t,n){switch(i){case "above":return e-5;case "below":return n!==void 0?n-5:t+14;case "center":case "middle":return (e+t)/2+4;case "bottom":return t-6;default:return e+14}}function Y(i){let{ranges:e,timeScale:t,yRange:n,height:r,metrics:o=j}=i,[l,s]=n,a=[],[m,u]=t.range(),d=Math.min(m,u),h=Math.max(m,u),p=c=>Math.max(d,Math.min(h,c));for(let c of e){let g=p(t.map(c.startTime)),y=p(t.map(c.endTime));if(c.fill!==void 0&&a.push({type:"rect",x:g,y:l,w:y-g,h:s-l,fill:c.fill,hatch:c.hatch,opacity:c.opacity}),c.edges)for(let b of [g,y])a.push({type:"line",x1:b,y1:l,x2:b,y2:s,stroke:c.edges.stroke,strokeWidth:c.edges.strokeWidth,dash:"dashed"});if(c.label){let b=c.labelPosition??"middle",x=c.rotate,S=true;if(x==="auto"){let k=b!=="above"&&b!=="below",v=o(c.label,c.fontSize??11);x=k&&v>Math.abs(y-g)-4?-90:void 0,S=x===void 0||v<=Math.abs(s-l)-4;}S&&a.push({type:"text",content:c.label,x:(g+y)/2,y:Me(b,l,s,r),anchor:"middle",fontSize:c.fontSize,fill:c.labelColor,rotate:x});}}return a}function tt(i){let{gaps:e,timeScale:t,yRange:n,height:r,fill:o=f.gapFill,hatch:l,fillOpacity:s=f.gapFillOpacity??.15,stroke:a=f.gapStroke,strokeWidth:m=f.gapStrokeWidth,dashed:u=true,fontSize:d=f.gapFontSize,fontFill:h=f.gapFontColor,labelBaseline:p="middle",labelRotate:c,metrics:g,band:y}=i,b=()=>{if(!y)return [];let x=y.height??6,[S,k]=n,v=Math.max(S,k);return e.map(W=>{let ge=t.map(W.startTime),ye=t.map(W.endTime);return {type:"rect",x:Math.min(ge,ye),y:v-x+(y.offset??0),w:Math.abs(ye-ge),h:x,fill:y.fill??a,opacity:y.opacity??.75}})};return Y({timeScale:t,yRange:n,height:r,metrics:g,ranges:e.map(x=>{let S=x.style??"dashed_border",k=S==="filled"||S==="dashed_border",v=S==="dashed_border"&&u!==false;return {startTime:x.startTime,endTime:x.endTime,...k&&{fill:x.fill??o,hatch:x.hatch??l,opacity:x.fillOpacity??s},...v&&{edges:{stroke:a,strokeWidth:m}},label:x.label,labelPosition:x.labelBaseline??p,labelColor:h,fontSize:d,rotate:x.rotate??c}})}).concat(b())}function nt(i){let{markers:e,timeScale:t,valueScale:n,yRange:r=[0,300]}=i,[o,l]=r,s=[];for(let a of e){let m=t.map(a.time),u=a.color??f.markerColor,d=a.pointStyle??(a.value!==void 0?"circle":"none"),h=a.lineStyle??"full";if(a.value!==void 0){let p=n.map(a.value);if(h==="to-value"?s.push({type:"line",x1:m,y1:l,x2:m,y2:p,stroke:u,strokeWidth:1,dashed:true}):h==="to-top"?s.push({type:"line",x1:m,y1:o,x2:m,y2:p,stroke:u,strokeWidth:1,dashed:true}):h==="full"&&s.push({type:"line",x1:m,y1:o,x2:m,y2:l,stroke:u,strokeWidth:1}),d!=="none"&&ee(s,void 0,d,m,p,f.markerSize,u,u,1.5),a.label){let c=h==="to-value"?p-10:o-6;s.push({type:"text",content:a.label,x:m,y:c,anchor:"middle",fontSize:f.markerFontSize,fill:u});}}else h!=="none"&&s.push({type:"line",x1:m,y1:o,x2:m,y2:l,stroke:u,strokeWidth:1}),a.label&&s.push({type:"text",content:a.label,x:m,y:o-6,anchor:"middle",fontSize:f.markerFontSize,fill:u});}return s}function rt(i){let{highlights:e,timeScale:t,yRange:n,height:r}=i;return Y({metrics:i.metrics,timeScale:t,yRange:n,height:r,ranges:e.map(o=>({startTime:o.startTime,endTime:o.endTime,fill:o.color??f.highlightColor,opacity:o.opacity??f.highlightOpacity,label:o.label,labelPosition:o.labelPosition??"top",labelColor:o.color??f.highlightLabelColor,fontSize:f.annotationFontSize,rotate:o.rotate}))})}function ot(i,e,t){let n=(o,[l,s])=>o>=Math.min(l,s)&&o<=Math.max(l,s);if(!n(i.time,e.domain()))return false;if(i.value===void 0||!t)return true;let r=t.get(i.axis??0)??t.values().next().value;return !r||n(i.value,r.domain())}function it(i){let{annotations:e,timeScale:t,valueScales:n,plot:r}=i,o=[],l=a=>!r||ot(a,t,n),s=a=>{let m=n.get(a.axis??0)??n.values().next().value;return {x:t.map(a.time),y:m?m.map(a.value):0}};for(let a of e){let m=[],u=p=>m.push(p);if((a.type==="point"||a.type==="label")&&!l(a.at))continue;let d=r!==void 0&&(a.type==="line"||a.type==="arrow"||a.type==="rect")&&!(l(a.from)&&l(a.to)),h=d?{clipRect:r}:{};switch(a.type){case "line":{let p=s(a.from),c=s(a.to);u({type:"line",x1:p.x,y1:p.y,x2:c.x,y2:c.y,stroke:a.color??f.annotationColor,strokeWidth:a.width??f.annotationWidth,dash:a.dash});break}case "arrow":{let p=s(a.from),c=s(a.to),g=a.color??f.annotationColor,y=a.headSize??f.annotationHead;u({type:"line",x1:p.x,y1:p.y,x2:c.x,y2:c.y,stroke:g,strokeWidth:a.width??f.annotationWidth});let b=Math.hypot(c.x-p.x,c.y-p.y)||1,x=(c.x-p.x)/b,S=(c.y-p.y)/b,k=c.x-x*y,v=c.y-S*y;u({type:"path",points:[{x:c.x,y:c.y},{x:k-S*y*.5,y:v+x*y*.5},{x:k+S*y*.5,y:v-x*y*.5}],fill:g,stroke:"none"});break}case "rect":{let p=s(a.from),c=s(a.to);u({type:"rect",x:Math.min(p.x,c.x),y:Math.min(p.y,c.y),w:Math.abs(c.x-p.x),h:Math.abs(c.y-p.y),fill:a.fill??"none",hatch:a.hatch,stroke:a.stroke,opacity:a.opacity});break}case "point":{let p=s(a.at),c=a.color??"#334155",g=a.radius??f.annotationRadius,y=a.shape??"circle";y==="circle"?u({type:"circle",cx:p.x,cy:p.y,r:g,fill:c}):y==="square"?u({type:"rect",x:p.x-g,y:p.y-g,w:g*2,h:g*2,fill:c}):(u({type:"line",x1:p.x-g,y1:p.y-g,x2:p.x+g,y2:p.y+g,stroke:c,strokeWidth:1.5}),u({type:"line",x1:p.x-g,y1:p.y+g,x2:p.x+g,y2:p.y-g,stroke:c,strokeWidth:1.5}));break}case "label":{let p=s(a.at);u({type:"text",content:a.text,x:p.x+(a.dx??0),y:p.y+(a.dy??0),anchor:a.anchor??at(p.x+(a.dx??0),a.text,i),fontSize:f.annotationFontSize,fill:a.color??f.annotationColor,rotate:a.rotate});break}}if(a.id&&m.length>0){let p=ne(a.id);o.push({type:"group",cssClass:`annotation annotation--${p}`,...h,commands:m});}else d&&m.length>0?o.push({type:"group",cssClass:"annotation",...h,commands:m}):o.push(...m);}return o}function at(i,e,t){let{metrics:n,timeScale:r}=t;if(!n)return "middle";let[o,l]=r.range(),s=n(e,f.annotationFontSize)/2;return i-s<o?"start":i+s>l?"end":"middle"}var re=class i{_config;constructor(e){this._config=e;}compute(){let{width:e,height:t,margin:n}=this._config;return {totalWidth:e,totalHeight:t,chartWidth:e-n.left-n.right,chartHeight:t-n.top-n.bottom,chartX:n.left,chartY:n.top,margin:n}}static default(e=800,t=400){return new i({width:e,height:t,margin:{top:20,right:20,bottom:40,left:60}})}};var oe=class{#e;constructor(){this.#e=[];}add(e){this.#e.push(e);}clear(){this.#e=[];}isInside(e,t){return this.#e.length===0?true:this.#e.some(n=>e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height)}toSVGClipPath(e="clip"){if(this.#e.length===0)return "";let t=this.#e.map(n=>`<rect x="${n.x}" y="${n.y}" width="${n.width}" height="${n.height}" />`).join(`
24
+ `.trim()}var f=new Proxy({},{get:(i,e)=>D()[e],has:(i,e)=>e in D(),ownKeys:()=>Reflect.ownKeys(D()),getOwnPropertyDescriptor:(i,e)=>Reflect.getOwnPropertyDescriptor(D(),e)});var O=class i{#e=[];get commands(){return [...this.#e]}get length(){return this.#e.length}line(e){return this.#e.push({type:"line",...e}),this}path(e){return this.#e.push({type:"path",...e}),this}rect(e){return this.#e.push({type:"rect",...e}),this}circle(e){return this.#e.push({type:"circle",...e}),this}text(e){return this.#e.push({type:"text",...e}),this}gap(e){return this.#e.push({type:"gap",...e}),this}push(...e){return this.#e.push(...e),this}group(e,t){let n=new i;return t(n),n.length===0?this:(this.#e.push({type:"group",...e,commands:n.commands}),this)}toGroup(e={}){return {type:"group",...e,commands:this.commands}}};var ze="#ffffff",Ge="#cccccc",Ve=6,Ne=.85,C=12,N=8,I=20,Xe=11,V=18,te=(i,e)=>e(i,Xe);function we(i,e,t){let n=s=>C+N+te(s.name,e);if(t===void 0){let s=i.reduce((a,m)=>a+n(m)+V,0)-V;return [{items:i,breite:Math.max(0,s)}]}let r=[],o=[],l=0;for(let s of i){let a=n(s),m=o.length===0?a:l+V+a;o.length>0&&m>t?(r.push({items:o,breite:l}),o=[s],l=a):(o=[...o,s],l=m);}return o.length>0&&r.push({items:o,breite:l}),r}function ve(i,e="vertical",t=j,n){if(e==="horizontal"){let o=we(i,t,n);return {width:o.reduce((l,s)=>Math.max(l,s.breite),0),height:o.length*I}}let r=0;for(let o of i)r=Math.max(r,te(o.name,t));return {width:C+N+r,height:i.length*I}}function Ye(i){let{items:e,x:t,y:n,orientation:r="vertical",metrics:o=j,maxBreite:l,box:s,itemClass:a}=i,m=new O;if(s&&e.length>0){let c=ve(e,r,o,l),g=((r==="horizontal"?c.height/I:e.length)-1)*I+C,y=s.padding??Ve,b=s.stroke??Ge;m.rect({x:t-y,y:n-y,w:c.width+2*y,h:g+2*y,fill:s.fill??ze,...b==="none"?{}:{stroke:b,strokeWidth:s.strokeWidth??1},opacity:s.opacity??Ne});}let u=r==="horizontal"?we(e,o,l):e.map(c=>({items:[c],breite:0})),d=new Map;u.forEach((c,h)=>{let g=t;for(let y of c.items)d.set(y,{x:g,y:n+h*I}),g+=C+N+te(y.name,o)+V;});let p=e.some(c=>c.line!==void 0&&c.line!=="solid");return e.forEach(c=>{let h=d.get(c)??{x:t,y:n},g=h.x,y=h.y,b=["legend-item"];c.id&&b.push(`legend-item--${c.id}`),a&&b.push(a),m.group({cssClass:b.join(" "),...c.id?{id:`legend-${c.id}`}:{}},x=>{p?x.line({x1:g,y1:y+C/2,x2:g+C,y2:y+C/2,stroke:c.color,strokeWidth:Ue(c.width),...c.line&&c.line!=="solid"?{dash:c.line}:{}}):x.rect({x:g,y,w:C,h:C,fill:c.color,stroke:f.legendStroke,strokeWidth:1}),x.text({content:c.name,x:g+C+N,y:y+C-2,fontSize:f.legendFont,fill:f.legendText});});}),m.toGroup({cssClass:"chart-legend"})}function Ue(i){return Math.min(Math.max(i??2,1.5),3)}function Ze(i){let{xTicks:e,yTicks:t,xRange:n,yRange:r,stroke:o=f.gridStroke,strokeWidth:l=f.gridStrokeWidth,dashed:s=false,opacity:a=f.gridOpacity}=i,m=[];if(t)for(let u of t)m.push({type:"line",x1:n[0],y1:u,x2:n[1],y2:u,stroke:o,strokeWidth:l,dashed:s,opacity:a});if(e)for(let u of e)m.push({type:"line",x1:u,y1:r[0],x2:u,y2:r[1],stroke:o,strokeWidth:l,dashed:s,opacity:a});return m}var Ce=new Map;function Ke(i,e){return `${i}|${JSON.stringify(e??{})}`}function B(i,e){let t=Ke(i,e),n=Ce.get(t);return n||(n=new Intl.DateTimeFormat(i,e),Ce.set(t,n)),n}function X(){return typeof navigator<"u"?navigator.language:void 0}var A=class{#e;#t;constructor(e){this.#e=[...e.domain],this.#t=[...e.range];}map(e){let t=Number(e),[n,r]=this.#e,[o,l]=this.#t;return r===n?o:o+(t-n)/(r-n)*(l-o)}invert(e){let[t,n]=this.#e,[r,o]=this.#t;return o===r?t:t+(e-r)/(o-r)*(n-t)}domain(){return [...this.#e]}range(){return [...this.#t]}},w=[{label:"second",ms:1e3},{label:"2_seconds",ms:2e3},{label:"5_seconds",ms:5e3},{label:"10_seconds",ms:1e4},{label:"30_seconds",ms:3e4},{label:"minute",ms:6e4},{label:"5_minutes",ms:3e5},{label:"15_minutes",ms:9e5},{label:"30_minutes",ms:18e5},{label:"hour",ms:36e5},{label:"3_hours",ms:108e5},{label:"6_hours",ms:216e5},{label:"day",ms:864e5},{label:"week",ms:6048e5},{label:"month",ms:2592e6},{label:"3_months",ms:7776e6},{label:"6_months",ms:15552e6},{label:"year",ms:31536e6},{label:"2_years",ms:63072e6},{label:"5_years",ms:15768e7}],E=class{#e;#t;#n;constructor(e){this.#e=new A({domain:e.domain,range:e.range}),this.#t=e.locale||(X()??"en-US"),this.#n=e.timeZone;}map(e){return this.#e.map(Number(e))}invert(e){return this.#e.invert(e)}domain(){return this.#e.domain()}range(){return this.#e.range()}get timeZone(){return this.#n}get locale(){return this.#t}tickInterval(e,t=3,n=12){let[r,o]=this.#e.domain(),l=o-r;if(l<=0)return {interval:w[0].ms};let s=l/e,a=w[0].ms;for(let d of w)if(d.ms>=s){a=d.ms;break}let m=a,u=Math.round(l/m);for(;u>n&&m<w[w.length-1].ms;){let d=w.findIndex(p=>p.ms===m);m=w[Math.min(d+1,w.length-1)].ms,u=Math.round(l/m);}for(;u<t&&m>w[0].ms;){let d=w.findIndex(p=>p.ms===m);m=w[Math.max(d-1,0)].ms,u=Math.round(l/m);}return {interval:m}}ticks(e){let t=e?.minTicks??5,n=e?.maxTicks??12,{interval:r}=this.tickInterval((t+n)/2,t,n),[o,l]=this.#e.domain(),s=[],a=Math.ceil(o/r)*r;for(let m=a;m<=l;m+=r)s.push(m);return s}format(e,t){let n=this.#n?{...t,timeZone:this.#n}:t;return B(this.#t,n).format(new Date(e))}},H=class{#e;#t;#n;#r;constructor(e){this.#e=[...e.domain],this.#t=[...e.range],this.#n=e.paddingInner??.1,this.#r=e.paddingOuter??.05;}get step(){let[e,t]=this.#t,n=this.#e.length;return n<=1?Math.abs(t-e):Math.abs(t-e)*(1-this.#r*2)/n+Math.abs(t-e)*this.#n*2/n}get bandwidth(){let[e,t]=this.#t,n=this.#e.length;if(n<=1)return Math.abs(t-e)*(1-this.#r*2);let r=this.#r*2*Math.abs(t-e);return (Math.abs(t-e)-r)/n*(1-this.#n)}map(e){let t=this.#e.findIndex(d=>String(d)===String(e));if(t===-1)return this.#t[0];let[n,r]=this.#t,o=this.#e.length;if(o<=1)return (n+r)/2;let l=this.#r*2*Math.abs(r-n),s=Math.abs(r-n)-l,a=r>=n?1:-1,m=s/o;return n+this.#r*Math.abs(r-n)*a+t*m}invert(e){let t=0,n=1/0;for(let r=0;r<this.#e.length;r++){let o=this.map(this.#e[r]),l=Math.abs(e-o);l<n&&(n=l,t=r);}return this.#e[t]}domain(){return this.#e.length===0?["",""]:[this.#e[0],this.#e[this.#e.length-1]]}range(){return [...this.#t]}positions(){let e=new Map;for(let t of this.#e)e.set(t,this.map(t));return e}};function ne(i){return i&&i.toString().normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"unnamed"}function qe(i){return i==="dotted"?{dash:"dotted"}:i==="dashed"?{dash:"dashed"}:{}}function Je(i){let{thresholds:e,valueScale:t,xRange:n}=i,[r,o]=n,[l,s]=t.range(),a=Math.min(l,s),m=Math.max(l,s),u=[],d=[];for(let p of e){let c=p.color??f.thresholdColor,h=t.map(p.value);p.fill==="above"?u.push({type:"rect",x:r,y:a,w:o-r,h:Math.max(0,h-a),fill:c,hatch:p.fillHatch,opacity:p.fillOpacity??.12,id:p.id?`${p.id}-fill`:void 0}):p.fill==="below"&&u.push({type:"rect",x:r,y:h,w:o-r,h:Math.max(0,m-h),fill:c,hatch:p.fillHatch,opacity:p.fillOpacity??.12,id:p.id?`${p.id}-fill`:void 0});let g=p.line??f.thresholdLine;if(g!=="none"){let S=qe(g),k={type:"line",x1:r,y1:h,x2:o,y2:h,stroke:c,strokeWidth:1,...S,id:p.id?`${p.id}-line`:void 0};p.shadowColor&&(k.shadowColor=p.shadowColor,k.shadowBlur=p.shadowBlur??4,k.shadowOffsetX=p.shadowOffsetX??0,k.shadowOffsetY=p.shadowOffsetY??2),u.push(k);}let[y,b]=t.domain();if(p.value>=Math.min(y,b)&&p.value<=Math.max(y,b)&&p.label!==void 0&&p.label!==null&&p.label!==false){let S=typeof p.label=="object"?p.label:void 0,k=typeof p.label=="string"?p.label:S?.text??p.name,v=S?.position??"right",W=tt(k,v,r,o,h,c,S);d.push({...W,y:et(W.y,Math.min(l,s),Math.max(l,s),f.thresholdFontSize),id:p.id?`${p.id}-label`:void 0});}}return {inside:u,labels:d}}function Qe(i){let e=Je(i);return [...e.inside,...e.labels]}function et(i,e,t,n){return Math.max(e+n,Math.min(t-n/2,i))}function tt(i,e,t,n,r,o,l){let s=(t+n)/2,a={type:"text",content:i,fontSize:f.thresholdFontSize,fill:o},m=l?{...l.rotate!==void 0&&{rotate:l.rotate},...l.textBaseline!==void 0&&{textBaseline:l.textBaseline}}:{};switch(e){case "left":return {...a,...m,x:t+4,y:r-4,anchor:"start"};case "above":return {...a,...m,x:s,y:r-6,anchor:"middle"};case "below":return {...a,...m,x:s,y:r+14,anchor:"middle"};case "center":return {...a,...m,x:s,y:r-4,anchor:"middle"};case "outside-left":return {...a,...m,x:t-6,y:r+3,anchor:"end",textBaseline:m.textBaseline??"middle"};case "outside-right":return {...a,...m,x:n+6,y:r+3,anchor:"start",textBaseline:m.textBaseline??"middle"};default:return {...a,...m,x:n-4,y:r-4,anchor:"end"}}}function Me(i,e,t,n){switch(i){case "above":return e-5;case "below":return n!==void 0?n-5:t+14;case "center":case "middle":return (e+t)/2+4;case "bottom":return t-6;default:return e+14}}function Y(i){let{ranges:e,timeScale:t,yRange:n,height:r,metrics:o=j}=i,[l,s]=n,a=[],[m,u]=t.range(),d=Math.min(m,u),p=Math.max(m,u),c=h=>Math.max(d,Math.min(p,h));for(let h of e){let g=c(t.map(h.startTime)),y=c(t.map(h.endTime));if(h.fill!==void 0&&a.push({type:"rect",x:g,y:l,w:y-g,h:s-l,fill:h.fill,hatch:h.hatch,opacity:h.opacity}),h.edges)for(let b of [g,y])a.push({type:"line",x1:b,y1:l,x2:b,y2:s,stroke:h.edges.stroke,strokeWidth:h.edges.strokeWidth,dash:"dashed"});if(h.label){let b=h.labelPosition??"middle",x=h.rotate,S=true;if(x==="auto"){let k=b!=="above"&&b!=="below",v=o(h.label,h.fontSize??11);x=k&&v>Math.abs(y-g)-4?-90:void 0,S=x===void 0||v<=Math.abs(s-l)-4;}S&&a.push({type:"text",content:h.label,x:(g+y)/2,y:Me(b,l,s,r),anchor:"middle",fontSize:h.fontSize,fill:h.labelColor,rotate:x});}}return a}function nt(i){let{gaps:e,timeScale:t,yRange:n,height:r,fill:o=f.gapFill,hatch:l,fillOpacity:s=f.gapFillOpacity??.15,stroke:a=f.gapStroke,strokeWidth:m=f.gapStrokeWidth,dashed:u=true,fontSize:d=f.gapFontSize,fontFill:p=f.gapFontColor,labelBaseline:c="middle",labelRotate:h,metrics:g,band:y}=i,b=()=>{if(!y)return [];let x=y.height??6,[S,k]=n,v=Math.max(S,k);return e.map(W=>{let ge=t.map(W.startTime),ye=t.map(W.endTime);return {type:"rect",x:Math.min(ge,ye),y:v-x+(y.offset??0),w:Math.abs(ye-ge),h:x,fill:y.fill??a,opacity:y.opacity??.75}})};return Y({timeScale:t,yRange:n,height:r,metrics:g,ranges:e.map(x=>{let S=x.style??"dashed_border",k=S==="filled"||S==="dashed_border",v=S==="dashed_border"&&u!==false;return {startTime:x.startTime,endTime:x.endTime,...k&&{fill:x.fill??o,hatch:x.hatch??l,opacity:x.fillOpacity??s},...v&&{edges:{stroke:a,strokeWidth:m}},label:x.label,labelPosition:x.labelBaseline??c,labelColor:p,fontSize:d,rotate:x.rotate??h}})}).concat(b())}function rt(i){let{markers:e,timeScale:t,valueScale:n,yRange:r=[0,300]}=i,[o,l]=r,s=[];for(let a of e){let m=t.map(a.time),u=a.color??f.markerColor,d=a.pointStyle??(a.value!==void 0?"circle":"none"),p=a.lineStyle??"full";if(a.value!==void 0){let c=n.map(a.value);if(p==="to-value"?s.push({type:"line",x1:m,y1:l,x2:m,y2:c,stroke:u,strokeWidth:1,dashed:true}):p==="to-top"?s.push({type:"line",x1:m,y1:o,x2:m,y2:c,stroke:u,strokeWidth:1,dashed:true}):p==="full"&&s.push({type:"line",x1:m,y1:o,x2:m,y2:l,stroke:u,strokeWidth:1}),d!=="none"&&ee(s,void 0,d,m,c,f.markerSize,u,u,1.5),a.label){let h=p==="to-value"?c-10:o-6;s.push({type:"text",content:a.label,x:m,y:h,anchor:"middle",fontSize:f.markerFontSize,fill:u});}}else p!=="none"&&s.push({type:"line",x1:m,y1:o,x2:m,y2:l,stroke:u,strokeWidth:1}),a.label&&s.push({type:"text",content:a.label,x:m,y:o-6,anchor:"middle",fontSize:f.markerFontSize,fill:u});}return s}function ot(i){let{highlights:e,timeScale:t,yRange:n,height:r}=i;return Y({metrics:i.metrics,timeScale:t,yRange:n,height:r,ranges:e.map(o=>({startTime:o.startTime,endTime:o.endTime,fill:o.color??f.highlightColor,opacity:o.opacity??f.highlightOpacity,label:o.label,labelPosition:o.labelPosition??"top",labelColor:o.color??f.highlightLabelColor,fontSize:f.annotationFontSize,rotate:o.rotate}))})}function it(i,e,t){let n=(o,[l,s])=>o>=Math.min(l,s)&&o<=Math.max(l,s);if(!n(i.time,e.domain()))return false;if(i.value===void 0||!t)return true;let r=t.get(i.axis??0)??t.values().next().value;return !r||n(i.value,r.domain())}function at(i){let{annotations:e,timeScale:t,valueScales:n,plot:r}=i,o=[],l=a=>!r||it(a,t,n),s=a=>{let m=n.get(a.axis??0)??n.values().next().value;return {x:t.map(a.time),y:m?m.map(a.value):0}};for(let a of e){let m=[],u=c=>m.push(c);if((a.type==="point"||a.type==="label")&&!l(a.at))continue;let d=r!==void 0&&(a.type==="line"||a.type==="arrow"||a.type==="rect")&&!(l(a.from)&&l(a.to)),p=d?{clipRect:r}:{};switch(a.type){case "line":{let c=s(a.from),h=s(a.to);u({type:"line",x1:c.x,y1:c.y,x2:h.x,y2:h.y,stroke:a.color??f.annotationColor,strokeWidth:a.width??f.annotationWidth,dash:a.dash});break}case "arrow":{let c=s(a.from),h=s(a.to),g=a.color??f.annotationColor,y=a.headSize??f.annotationHead;u({type:"line",x1:c.x,y1:c.y,x2:h.x,y2:h.y,stroke:g,strokeWidth:a.width??f.annotationWidth});let b=Math.hypot(h.x-c.x,h.y-c.y)||1,x=(h.x-c.x)/b,S=(h.y-c.y)/b,k=h.x-x*y,v=h.y-S*y;u({type:"path",points:[{x:h.x,y:h.y},{x:k-S*y*.5,y:v+x*y*.5},{x:k+S*y*.5,y:v-x*y*.5}],fill:g,stroke:"none"});break}case "rect":{let c=s(a.from),h=s(a.to);u({type:"rect",x:Math.min(c.x,h.x),y:Math.min(c.y,h.y),w:Math.abs(h.x-c.x),h:Math.abs(h.y-c.y),fill:a.fill??"none",hatch:a.hatch,stroke:a.stroke,opacity:a.opacity});break}case "point":{let c=s(a.at),h=a.color??"#334155",g=a.radius??f.annotationRadius,y=a.shape??"circle";y==="circle"?u({type:"circle",cx:c.x,cy:c.y,r:g,fill:h}):y==="square"?u({type:"rect",x:c.x-g,y:c.y-g,w:g*2,h:g*2,fill:h}):(u({type:"line",x1:c.x-g,y1:c.y-g,x2:c.x+g,y2:c.y+g,stroke:h,strokeWidth:1.5}),u({type:"line",x1:c.x-g,y1:c.y+g,x2:c.x+g,y2:c.y-g,stroke:h,strokeWidth:1.5}));break}case "label":{let c=s(a.at);u({type:"text",content:a.text,x:c.x+(a.dx??0),y:c.y+(a.dy??0),anchor:a.anchor??st(c.x+(a.dx??0),a.text,i),fontSize:f.annotationFontSize,fill:a.color??f.annotationColor,rotate:a.rotate});break}}if(a.id&&m.length>0){let c=ne(a.id);o.push({type:"group",cssClass:`annotation annotation--${c}`,...p,commands:m});}else d&&m.length>0?o.push({type:"group",cssClass:"annotation",...p,commands:m}):o.push(...m);}return o}function st(i,e,t){let{metrics:n,timeScale:r}=t;if(!n)return "middle";let[o,l]=r.range(),s=n(e,f.annotationFontSize)/2;return i-s<o?"start":i+s>l?"end":"middle"}var re=class i{_config;constructor(e){this._config=e;}compute(){let{width:e,height:t,margin:n}=this._config;return {totalWidth:e,totalHeight:t,chartWidth:e-n.left-n.right,chartHeight:t-n.top-n.bottom,chartX:n.left,chartY:n.top,margin:n}}static default(e=800,t=400){return new i({width:e,height:t,margin:{top:20,right:20,bottom:40,left:60}})}};var oe=class{#e;constructor(){this.#e=[];}add(e){this.#e.push(e);}clear(){this.#e=[];}isInside(e,t){return this.#e.length===0?true:this.#e.some(n=>e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height)}toSVGClipPath(e="clip"){if(this.#e.length===0)return "";let t=this.#e.map(n=>`<rect x="${n.x}" y="${n.y}" width="${n.width}" height="${n.height}" />`).join(`
25
25
  `);return `<clipPath id="${e}">
26
26
  ${t}
27
- </clipPath>`}get regions(){return [...this.#e]}};function U(i,e){if(e<=0||i.length<2)return [];let t=[];for(let n=0;n<i.length-1;n++){let r=i[n],o=i[n+1];for(let l=1;l<=e;l++)t.push(r+(o-r)*l/(e+1));}return t}var z={axisColor:f.axisColor,tickColor:f.tickColor,textColor:f.textColor,textSize:f.textSize},G=class{#e;#t;constructor(e){this.#e=new E({domain:e.domain,range:e.xRange,locale:e.locale,timeZone:e.timeZone}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??z).axisColor}get tickColor(){return (this.#t.colors??z).tickColor}get textColor(){return (this.#t.colors??z).textColor}get textSize(){return (this.#t.colors??z).textSize}generateTicks(){let e=this.#t.minTicks??5,t=this.#t.maxTicks??12,r=this.#e.ticks({minTicks:e,maxTicks:t}).map(o=>({time:o,x:this.#e.map(o),label:this.tickLabel(o)}));return this.antiOverlap(r)}tickLabel(e){if(this.#t.format)return this.#t.format(new Date(e));let t=this.#t.minTicks??5,n=this.#t.maxTicks??12,{interval:r}=this.#e.tickInterval((t+n)/2,t,n),o={};return r<6e4?(o.hour="2-digit",o.minute="2-digit",o.second="2-digit"):r<36e5||r<864e5?(o.hour="2-digit",o.minute="2-digit"):r<31536e6?(o.day="numeric",o.month="short",r>=2592e6&&(o.day=void 0,o.month="long")):(o.year="numeric",r<2*31536e6&&(o.month="short")),this.#e.format(e,o)}antiOverlap(e){if(e.length<=1)return e;let t=60,n=[e[0]];for(let r=1;r<e.length;r++){let o=n[n.length-1].x;Math.abs(e[r].x-o)>=t&&n.push(e[r]);}return n}render(){let e=this.generateTicks(),t=this.#t.colors??z,n=this.#t.y??0,r=[],[o,l]=this.#e.range();r.push({type:"line",x1:o,y1:n,x2:l,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let s of this.generateMinorTicks())r.push({type:"line",x1:s,y1:n,x2:s,y2:n+3,stroke:t.tickColor,strokeWidth:t.axisWidth});for(let s of e)r.push({type:"line",x1:s.x,y1:n,x2:s.x,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),r.push({type:"text",content:s.label,x:this.#n(s.x,s.label,t.textSize),y:n+t.textSize+6,anchor:"middle",fontSize:t.textSize,fill:t.textColor});return r}generateMinorTicks(){return U(this.generateTicks().map(e=>e.x),this.#t.minorTicks??0)}#n(e,t,n){let r=this.#t.gesamtbreite,o=this.#t.metrics;if(r===void 0||o===void 0)return e;let l=o(t,n)/2;return Math.max(l+2,Math.min(r-l-2,e))}};var P={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function ie(i,e){let t=n=>e===void 0||e>=n;return Math.abs(i)>=1e6&&t(1e5)?`${(i/1e6).toFixed(1)}M`:Math.abs(i)>=1e3&&t(100)?`${(i/1e3).toFixed(1)}k`:Number.isInteger(i)?String(i):i.toFixed(1)}function st(i){let e=new Array(i.length).fill(false),t=0;for(;t<i.length;){let n=t;for(;n+1<i.length&&i[n+1].label===i[t].label;)n++;for(let r=t+1;r<n;r++)e[r]=true;t=n+1;}return e}var ae=class{#e;#t;constructor(e){this.#e=new A({domain:e.domain,range:e.range}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??P).axisColor}get tickColor(){return (this.#t.colors??P).tickColor}get textColor(){return (this.#t.colors??P).textColor}get textSize(){return (this.#t.colors??P).textSize}generateTicks(){let e=this.#t.tickValues;if(e&&e.length>0){let g=this.#t.format??ie;return e.map(y=>({value:y,position:this.#e.map(y),label:g(y)}))}let t=this.#t.format??ie,n=this.#t.ticks&&this.#t.ticks>0?this.#t.ticks:6,[r,o]=this.#e.domain(),l=Math.min(r,o),s=Math.max(r,o),a=s-l;if(a===0)return [{value:r,position:this.#e.map(r),label:t(r)}];let m=a/n,u=Math.pow(10,Math.floor(Math.log10(m))),d=m/u,h;if(d<=1.5?h=u:d<=3?h=2*u:d<=7?h=5*u:h=10*u,h<=0||!Number.isFinite(h))return [{value:r,position:this.#e.map(r),label:t(r)}];this.#t.format||(t=g=>ie(g,h));let p=[],c=Math.ceil(l/h)*h;for(let g=c;g<=s;g+=h)p.push({value:g,position:this.#e.map(g),label:t(g)});return p}generateMinorTicks(){return U(this.generateTicks().map(e=>e.position),this.#t.minorTicks??0)}render(){let e=this.generateTicks(),t=this.#t.colors??P,n=this.#t.x??0,r=this.#t.orientation??"vertical",o=this.#t.position??"left",l=this.#t.suppressLabelsNear??[],s=this.#t.suppressTolerancePx??8,a=d=>l.some(h=>Math.abs(h-d)<=s),m=[];if(r==="vertical"){let[d,h]=this.#e.range();m.push({type:"line",x1:n,y1:d,x2:n,y2:h,stroke:t.axisColor,strokeWidth:t.axisWidth});let p=st(e);e.forEach((c,g)=>{let y=a(c.position),b=p[g]?{opacity:0}:{};o==="left"?(m.push({type:"line",x1:n-4,y1:c.position,x2:n,y2:c.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),y||m.push({type:"text",content:c.label,x:this.#n(n-8,c.label,"end"),y:c.position+4,anchor:"end",fontSize:t.textSize,fill:t.textColor,...b})):(m.push({type:"line",x1:n,y1:c.position,x2:n+4,y2:c.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),y||m.push({type:"text",content:c.label,x:this.#n(n+8,c.label,"start"),y:c.position+4,anchor:"start",fontSize:t.textSize,fill:t.textColor,...b}));});}else {let[d,h]=this.#e.range();m.push({type:"line",x1:d,y1:n,x2:h,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let p of e)m.push({type:"line",x1:p.position,y1:n,x2:p.position,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),m.push({type:"text",content:p.label,x:p.position,y:n+18,anchor:"middle",fontSize:t.textSize,fill:t.textColor});}let u=(this.#t.orientation??"vertical")==="vertical";for(let d of this.generateMinorTicks())m.push(u?{type:"line",x1:o==="right"?n:n-2,y1:d,x2:o==="right"?n+2:n,y2:d,stroke:t.tickColor,strokeWidth:t.axisWidth}:{type:"line",x1:d,y1:n,x2:d,y2:n+3,stroke:t.tickColor,strokeWidth:t.axisWidth});return m}#n(e,t,n){let r=this.#t.gesamtbreite,o=this.#t.metrics;if(r===void 0||o===void 0)return e;let l=o(t,(this.#t.colors??P).textSize);return n==="end"?Math.max(l+2,Math.min(r-2,e)):Math.min(r-l-2,Math.max(2,e))}};var se=class i{#e;#t;#n;#r;#a;#o;#i;constructor(e){this.#e=[...e.data].sort((t,n)=>t.time-n.time),this.#t=e.windowSize,this.#n=e.type??"simple",this.#r=e.timeScale,this.#a=e.valueScale,this.#o=e.stroke??"#e53e3e",this.#i=e.strokeWidth??2;}static simple(e,t){let n=[...e].filter(o=>o.value!==null).sort((o,l)=>o.time-l.time),r=[];for(let o=0;o<n.length;o++){let l=Math.max(0,o-t+1),s=n.slice(l,o+1),a=s.reduce((m,u)=>m+u.value,0)/s.length;r.push({time:n[o].time,value:a});}return r}static exponential(e,t){let n=[...e].filter(s=>s.value!==null).sort((s,a)=>s.time-a.time);if(n.length===0)return [];let r=2/(t+1),o=[],l=n[0].value;o.push({time:n[0].time,value:l});for(let s=1;s<n.length;s++)l=n[s].value*r+l*(1-r),o.push({time:n[s].time,value:l});return o}points(){return (this.#n==="exponential"?i.exponential(this.#e,this.#t):i.simple(this.#e,this.#t)).map(t=>({x:this.#r.map(t.time),y:this.#a.map(t.value)}))}render(){let e=this.points();return e.length<2?e.map(t=>({type:"circle",cx:t.x,cy:t.y,r:this.#i,fill:this.#o})):[{type:"path",points:e,smoothing:true,stroke:this.#o,strokeWidth:this.#i}]}};var le=class{#e;#t;#n;constructor(e){let t=Object.keys(e.enumMap).map(Number).sort((n,r)=>n-r).map(String);this.#t=t,this.#e=new H({domain:t,range:e.range}),this.#n=e;}get scale(){return this.#e}generateTicks(){let{enumMap:e,showLabels:t=true,autoColor:n=true,gapValues:r}=this.#n,o=new Set(r??[]);return this.#t.map((l,s)=>{let a=Number(l),m=t?e[a]??String(a):String(a),u=this.#e.map(a),d=n?f.palette[s%f.palette.length]:void 0;return {value:a,label:m,y:u,color:d,isGap:o.has(a)}})}colorFor(e){let t=this.#t.indexOf(String(e));if(!(t===-1||!(this.#n.autoColor??true)))return f.palette[t%f.palette.length]}render(){let e=this.generateTicks(),t=this.#n.x??0,n=[];for(let r of e)r.isGap||n.push({type:"text",content:r.label,x:t,y:r.y+4,anchor:"end",fontSize:f.textSize,fill:r.color??f.textColor});return n}map(e){return this.#e.map(e)}isGap(e){return new Set(this.#n.gapValues??[]).has(e)}};var C=class i{#e;#t;static uidcnt=0;#n;constructor(e,t=[]){this.#e=e.id??"series-"+ ++i.uidcnt,this.#t=e.timeScale,this.#n=t;}get id(){return this.#e}get timeScale(){return this.#t}get data(){return this.#n}};var me=class extends C{#e;constructor(e){super(e,e.data),this.#e=e;}points(){let e=this.#e.valueScale;return this.data.filter(t=>t.value!==null).map(t=>({x:this.timeScale.map(t.time),y:e.map(t.value),time:t.time})).sort((t,n)=>t.x-n.x)}render(){let e=this.#e,t={smoothing:e.smoothing??false,smoothingType:e.smoothingType,stroke:e.stroke??f.stroke,strokeWidth:e.strokeWidth??f.strokeWidth,dashed:e.dashed??false,pointStyle:e.pointStyle??"none",pointSize:e.pointSize??f.pointSize,shadowColor:e.shadowColor,shadowBlur:e.shadowBlur,shadowOffsetX:e.shadowOffsetX,shadowOffsetY:e.shadowOffsetY},n=e.pointThreshold??f.pointThreshold,r=e.gapThreshold??f.gapThreshold,o=e.id,l=T.getRuns(this.data,d=>d.value===null,r),s=l.reduce((d,h)=>d+h.length,0);if(s===0)return [];let a={timeScale:this.timeScale,valueScale:e.valueScale},m=l.map(d=>({data:d})),u=[];return u.push(...M(m,a,{...t,id:o?`${o}-line`:void 0})),t.pointStyle&&t.pointStyle!=="none"&&s<=n&&u.push(...Q(l.flat(),a,{...t,id:o?`${o}-marker`:void 0},()=>t.stroke)),u}};var ue=class extends C{#e;constructor(e){super(e,e.data),this.#e=e;}points(){let e=this.#e.valueScale,t=[...this.data].filter(r=>r.value!==null).sort((r,o)=>r.time-o.time),n=[];for(let r=0;r<t.length;r++){let o=this.timeScale.map(t[r].time),l=e.map(t[r].value);r===0?n.push({x:o,y:l}):n.push({x:o,y:n[n.length-1].y},{x:o,y:l});}return n}render(){let e=T.getRuns(this.data,r=>r.value===null);if(e.length===0)return [];let t={timeScale:this.timeScale,valueScale:this.#e.valueScale},n=e.map(r=>({data:r}));return q(n,t,{stroke:this.#e.stroke??f.stroke,strokeWidth:this.#e.strokeWidth??f.strokeWidth,id:this.id?`${this.id}-line`:void 0})}};var ce=class extends C{#e;constructor(e){super(e,e.data),this.#e=e;}opacity(e){if(!(this.#e.countOpacity??false))return .6;let t=0;for(let n of this.data)n.count>t&&(t=n.count);return t===0?.2:.2+.8*e/t}render(){let e=this.#e,t=e.fill??f.bandFill,n=e.hatch,r=e.avgLine??false,o=e.avgLineColor??f.bandAvgLine,l=e.bandWidth??10,s=[];for(let a of this.data){if(a.min===null||a.max===null)continue;let m=this.timeScale.map(a.time),u=e.valueScale.map(a.max),d=e.valueScale.map(a.min),h=l,p=this.data.indexOf(a);if(s.push({type:"rect",x:m-h/2,y:u,w:h,h:d-u,fill:t,hatch:n,opacity:this.opacity(a.count),id:this.id?`${this.id}-slot-${p}`:void 0}),r&&a.avg!==null){let c=e.valueScale.map(a.avg);s.push({type:"line",x1:m-h/2,y1:c,x2:m+h/2,y2:c,stroke:o,strokeWidth:1,id:this.id?`${this.id}-avg-${p}`:void 0});}}return s}};function Le(i,e,t,n,r,o,l){return J(i,e,{boundaries:[],yLow:s=>s.avg,yHigh:t,getValue:s=>s.avg,interpolate:T.interpolateAggregatedPoint,getColor:()=>n,getHatch:()=>r},{id:o,...l})}var he=class extends C{#e;constructor(e){super(e,e.data),this.#e=e;}render(){let e=this.#e,t=e.minColor??f.minColor,n=e.maxColor??f.maxColor,r=e.avgColor??f.avgColor,o=e.avgDashed??true,l=e.smoothing??false,s=e.smoothingType,a=e.strokeWidth??f.strokeWidth,m=T.getRuns(this.data,c=>c.min===null||c.max===null||c.avg===null);if(m.length===0)return [];let u={timeScale:this.timeScale,valueScale:e.valueScale},d=[];m.forEach((c,g)=>{if(c.length<2)return;let y=b=>this.id?`${this.id}-${b}-${g}`:void 0;if(e.fillToMax){let b=Le(c,u,x=>x.max,e.fillToMax,e.fillToMaxHatch,y("fillToMax"),{smoothing:l,smoothingType:s});d.push(...b);}if(e.fillToMin){let b=Le(c,u,x=>x.min,e.fillToMin,e.fillToMinHatch,y("fillToMin"),{smoothing:l,smoothingType:s});d.push(...b);}});let h=m.filter(c=>c.length>=2),p=(c,g,y,b=false)=>M(h.map(x=>({data:x.map(S=>({time:S.time,value:c(S)}))})),u,{stroke:g,strokeWidth:a,smoothing:l,smoothingType:s,dashed:b,id:this.id?`${this.id}-${y}`:void 0});return d.push(...p(c=>c.max,n,"max"),...p(c=>c.min,t,"min"),...p(c=>c.avg,r,"avg",o)),d}};var lt=1,de=class{#e;constructor(e,t,n,r){this.#e={...e,xRange:t,y:n,height:r};}render(){let{items:e,timeScale:t,background:n,hatch:r,showAxis:o,xRange:l,y:s,height:a}=this.#e,m=[];n&&m.push({type:"rect",x:l[0],y:s,w:l[1]-l[0],h:a,fill:n,opacity:.04,stroke:"#ddd",strokeWidth:.25});for(let u of e){let d=t.map(u.startTime),h=t.map(u.endTime);if(h<l[0]||d>l[1])continue;let p=Math.max(l[0],Math.min(l[1],d)),c=Math.max(l[0],Math.min(l[1],h)),g=Math.max(c-p,lt);p+g>l[1]&&(p=Math.max(l[0],l[1]-g));let y=p+g/2;if(m.push({type:"rect",x:p,y:s,w:g,h:a,hatch:u.hatch??r,fill:u.fill??"#6b728044",stroke:u.stroke,strokeWidth:u.strokeWidth??0,title:u.title}),u.label){let b=u.labelFontSize??10;m.push({type:"text",content:u.label,x:y,y:this.#t(u.labelBaseline,b),anchor:"middle",fontSize:b,fill:u.labelFill??"#333"});}}if(o){let u=new G({domain:t.domain(),xRange:l,y:s+a+4});m.push({type:"group",cssClass:"annotation-band-axis",commands:u.render()});}return m}#t(e,t){let{y:n,height:r}=this.#e;switch(e){case "top":return n+t*.9;case "bottom":return n+r-t*.25;default:return n+r/2+t*.35}}};var pe=class{#e;constructor(e){this.#e=e;}render(){let{data:e,valueScale:t,xRange:n,showMin:r=false,showMax:o=false,showAvg:l=true,showMedian:s=false,labelPosition:a="end",lineColor:m=f.statsLineColor,labelColor:u=f.statsLabelColor}=this.#e,d=be.compute(e),h=[{name:"min",value:d.min,enabled:r},{name:"max",value:d.max,enabled:o},{name:"avg",value:d.avg,enabled:l},{name:"median",value:d.median,enabled:s}],p=[],[c,g]=n;for(let y of h.filter(b=>b.enabled)){let b=t.map(y.value);p.push({type:"line",x1:c,y1:b,x2:g,y2:b,stroke:m,strokeWidth:1});let x=`${y.name}: ${y.value.toFixed(1)}`;(a==="start"||a==="both")&&p.push({type:"text",content:x,x:c+4,y:b-4,anchor:"start",fontSize:f.statFontSize,fill:u}),(a==="end"||a==="both")&&p.push({type:"text",content:x,x:g-4,y:b-4,anchor:"end",fontSize:f.statFontSize,fill:u}),a==="center"&&p.push({type:"text",content:x,x:(c+g)/2,y:b-4,anchor:"middle",fontSize:f.statFontSize,fill:u});}return p}};var R=class{#e;#t;#n;constructor(e){this.#e=e?.locale||(X()??"en-US"),this.#t=e?.fallbackLocales??["en-US"],this.#n=e?.autoFormat??true;}format(e,t,n){try{let r=this.#n&&n?this.#r(e,n,t):t;return B(this.#e,r).format(new Date(e))}catch{for(let r of this.#t)try{return B(r,t).format(new Date(e))}catch{}return new Date(e).toISOString()}}formatRange(e,t){let n=this.format(e),r=this.format(t);return `${n} \u2014 ${r}`}#r(e,t,n){let r=Math.abs(e-t),o=864e5,l=36e5,s=6e4,a={};return r<s?(a.second="2-digit",a.minute="2-digit",a.hour="2-digit"):r<l?(a.minute="2-digit",a.hour="2-digit"):r<o?(a.hour="2-digit",a.minute="2-digit"):r<7*o?(a.weekday="short",a.day="numeric"):r<365*o?(a.month="short",a.day="numeric"):(a.month="short",a.year="numeric"),{...n,...a}}};var $=class i{#e;#t;_compact;#n;constructor(e){this.#e=e?.unit??"",this.#t=e?.decimals??1,this._compact=e?.compact??false,this.#n=e?.custom;}format(e){if(this.#n)return this.#n(e);let t;return this._compact&&Math.abs(e)>=1e6?t=`${(e/1e6).toFixed(this.#t)}M`:this._compact&&Math.abs(e)>=1e3?t=`${(e/1e3).toFixed(this.#t)}k`:t=e.toFixed(this.#t),this.#e?`${t}${this.#e}`:t}formatRange(e,t){return `${this.format(e)} \u2014 ${this.format(t)}`}static unit(e,t=1){return new i({unit:e,decimals:t})}static temperature(e="\xB0C"){return new i({unit:e,decimals:1})}static percentage(){return new i({unit:"%",decimals:0})}};var F=class i{#e;#t;#n;constructor(e){this.#e=e?.map??{},this.#t=e?.fallback??(t=>String(t)),this.#n=e?.showValue??false;}format(e){let t=this.#e[e]??this.#t(e);return this.#n?`(${e}) ${t}`:t}has(e){return e in this.#e}labels(){return Object.values(this.#e)}values(){return Object.keys(this.#e).map(Number)}static fromLabels(e,t=false){let n={};return e.forEach((r,o)=>{n[o]=r;}),new i({map:n,showValue:t})}};var mt={time:new R,value:new $,enum:new F};function fe(i,e){let t=L();return {color:i.color??t.stroke,width:i.width??t.strokeWidth,style:i.style??"solid",smoothing:i.smoothing??false,smoothingType:i.smoothingType,shape:i.shape??(e.seriesType==="step"?"step":"line"),gapThreshold:i.gapThreshold??t.gapThreshold,opacity:i.opacity??1}}function De(i){let e=i.style?.line;return e===false?[]:e===void 0?[fe({},i)]:Array.isArray(e)?e.map(t=>fe(t,i)):[fe(e,i)]}function _e(i){let e=i.style?.markers;if(!e?.type||e.type==="none")return;let t=L(),r=(i.style?.line&&!Array.isArray(i.style.line)?i.style.line.color:void 0)??t.stroke;return {type:e.type,size:e.size??t.pointSize,stroke:e.stroke??r,fill:e.fill??"#ffffff",strokeWidth:e.strokeWidth??1,threshold:e.threshold}}function Ae(i){let e=i.style?.shadow;if(!(!e?.color||e.color==="transparent"||e.color==="none"))return {color:e.color,blur:e.blur??4,offsetX:e.offsetX??0,offsetY:e.offsetY??0}}function Pe(i){return i.style?.gap}function Re(i){return i.style?.fill}function ut(i){return {lines:De(i),fill:Re(i),markers:_e(i),shadow:Ae(i),gap:Pe(i),id:i.style?.id??i.id}}/*!
27
+ </clipPath>`}get regions(){return [...this.#e]}};function U(i,e){if(e<=0||i.length<2)return [];let t=[];for(let n=0;n<i.length-1;n++){let r=i[n],o=i[n+1];for(let l=1;l<=e;l++)t.push(r+(o-r)*l/(e+1));}return t}var z={axisColor:f.axisColor,tickColor:f.tickColor,textColor:f.textColor,textSize:f.textSize},G=class{#e;#t;constructor(e){this.#e=new E({domain:e.domain,range:e.xRange,locale:e.locale,timeZone:e.timeZone}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??z).axisColor}get tickColor(){return (this.#t.colors??z).tickColor}get textColor(){return (this.#t.colors??z).textColor}get textSize(){return (this.#t.colors??z).textSize}generateTicks(){let e=this.#t.minTicks??5,t=this.#t.maxTicks??12,r=this.#e.ticks({minTicks:e,maxTicks:t}).map(o=>({time:o,x:this.#e.map(o),label:this.tickLabel(o)}));return this.antiOverlap(r)}tickLabel(e){if(this.#t.format)return this.#t.format(new Date(e));let t=this.#t.minTicks??5,n=this.#t.maxTicks??12,{interval:r}=this.#e.tickInterval((t+n)/2,t,n),o={};return r<6e4?(o.hour="2-digit",o.minute="2-digit",o.second="2-digit"):r<36e5||r<864e5?(o.hour="2-digit",o.minute="2-digit"):r<31536e6?(o.day="numeric",o.month="short",r>=2592e6&&(o.day=void 0,o.month="long")):(o.year="numeric",r<2*31536e6&&(o.month="short")),this.#e.format(e,o)}antiOverlap(e){if(e.length<=1)return e;let t=60,n=[e[0]];for(let r=1;r<e.length;r++){let o=n[n.length-1].x;Math.abs(e[r].x-o)>=t&&n.push(e[r]);}return n}render(){let e=this.generateTicks(),t=this.#t.colors??z,n=this.#t.y??0,r=[],[o,l]=this.#e.range();r.push({type:"line",x1:o,y1:n,x2:l,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let s of this.generateMinorTicks())r.push({type:"line",x1:s,y1:n,x2:s,y2:n+3,stroke:t.tickColor,strokeWidth:t.axisWidth});for(let s of e)r.push({type:"line",x1:s.x,y1:n,x2:s.x,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),r.push({type:"text",content:s.label,x:this.#n(s.x,s.label,t.textSize),y:n+t.textSize+6,anchor:"middle",fontSize:t.textSize,fill:t.textColor});return r}generateMinorTicks(){return U(this.generateTicks().map(e=>e.x),this.#t.minorTicks??0)}#n(e,t,n){let r=this.#t.gesamtbreite,o=this.#t.metrics;if(r===void 0||o===void 0)return e;let l=o(t,n)/2;return Math.max(l+2,Math.min(r-l-2,e))}};var P={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function ie(i,e){let t=n=>e===void 0||e>=n;return Math.abs(i)>=1e6&&t(1e5)?`${(i/1e6).toFixed(1)}M`:Math.abs(i)>=1e3&&t(100)?`${(i/1e3).toFixed(1)}k`:Number.isInteger(i)?String(i):i.toFixed(1)}function lt(i){let e=new Array(i.length).fill(false),t=0;for(;t<i.length;){let n=t;for(;n+1<i.length&&i[n+1].label===i[t].label;)n++;for(let r=t+1;r<n;r++)e[r]=true;t=n+1;}return e}var ae=class{#e;#t;constructor(e){this.#e=new A({domain:e.domain,range:e.range}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??P).axisColor}get tickColor(){return (this.#t.colors??P).tickColor}get textColor(){return (this.#t.colors??P).textColor}get textSize(){return (this.#t.colors??P).textSize}generateTicks(){let e=this.#t.tickValues;if(e&&e.length>0){let g=this.#t.format??ie;return e.map(y=>({value:y,position:this.#e.map(y),label:g(y)}))}let t=this.#t.format??ie,n=this.#t.ticks&&this.#t.ticks>0?this.#t.ticks:6,[r,o]=this.#e.domain(),l=Math.min(r,o),s=Math.max(r,o),a=s-l;if(a===0)return [{value:r,position:this.#e.map(r),label:t(r)}];let m=a/n,u=Math.pow(10,Math.floor(Math.log10(m))),d=m/u,p;if(d<=1.5?p=u:d<=3?p=2*u:d<=7?p=5*u:p=10*u,p<=0||!Number.isFinite(p))return [{value:r,position:this.#e.map(r),label:t(r)}];this.#t.format||(t=g=>ie(g,p));let c=[],h=Math.ceil(l/p)*p;for(let g=h;g<=s;g+=p)c.push({value:g,position:this.#e.map(g),label:t(g)});return c}generateMinorTicks(){return U(this.generateTicks().map(e=>e.position),this.#t.minorTicks??0)}render(){let e=this.generateTicks(),t=this.#t.colors??P,n=this.#t.x??0,r=this.#t.orientation??"vertical",o=this.#t.position??"left",l=this.#t.suppressLabelsNear??[],s=this.#t.suppressTolerancePx??8,a=d=>l.some(p=>Math.abs(p-d)<=s),m=[];if(r==="vertical"){let[d,p]=this.#e.range();m.push({type:"line",x1:n,y1:d,x2:n,y2:p,stroke:t.axisColor,strokeWidth:t.axisWidth});let c=lt(e);e.forEach((h,g)=>{let y=a(h.position),b=c[g]?{opacity:0}:{};o==="left"?(m.push({type:"line",x1:n-4,y1:h.position,x2:n,y2:h.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),y||m.push({type:"text",content:h.label,x:this.#n(n-8,h.label,"end"),y:h.position+4,anchor:"end",fontSize:t.textSize,fill:t.textColor,...b})):(m.push({type:"line",x1:n,y1:h.position,x2:n+4,y2:h.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),y||m.push({type:"text",content:h.label,x:this.#n(n+8,h.label,"start"),y:h.position+4,anchor:"start",fontSize:t.textSize,fill:t.textColor,...b}));});}else {let[d,p]=this.#e.range();m.push({type:"line",x1:d,y1:n,x2:p,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let c of e)m.push({type:"line",x1:c.position,y1:n,x2:c.position,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),m.push({type:"text",content:c.label,x:c.position,y:n+18,anchor:"middle",fontSize:t.textSize,fill:t.textColor});}let u=(this.#t.orientation??"vertical")==="vertical";for(let d of this.generateMinorTicks())m.push(u?{type:"line",x1:o==="right"?n:n-2,y1:d,x2:o==="right"?n+2:n,y2:d,stroke:t.tickColor,strokeWidth:t.axisWidth}:{type:"line",x1:d,y1:n,x2:d,y2:n+3,stroke:t.tickColor,strokeWidth:t.axisWidth});return m}#n(e,t,n){let r=this.#t.gesamtbreite,o=this.#t.metrics;if(r===void 0||o===void 0)return e;let l=o(t,(this.#t.colors??P).textSize);return n==="end"?Math.max(l+2,Math.min(r-2,e)):Math.min(r-l-2,Math.max(2,e))}};var se=class i{#e;#t;#n;#r;#a;#o;#i;constructor(e){this.#e=[...e.data].sort((t,n)=>t.time-n.time),this.#t=e.windowSize,this.#n=e.type??"simple",this.#r=e.timeScale,this.#a=e.valueScale,this.#o=e.stroke??"#e53e3e",this.#i=e.strokeWidth??2;}static simple(e,t){let n=[...e].filter(o=>o.value!==null).sort((o,l)=>o.time-l.time),r=[];for(let o=0;o<n.length;o++){let l=Math.max(0,o-t+1),s=n.slice(l,o+1),a=s.reduce((m,u)=>m+u.value,0)/s.length;r.push({time:n[o].time,value:a});}return r}static exponential(e,t){let n=[...e].filter(s=>s.value!==null).sort((s,a)=>s.time-a.time);if(n.length===0)return [];let r=2/(t+1),o=[],l=n[0].value;o.push({time:n[0].time,value:l});for(let s=1;s<n.length;s++)l=n[s].value*r+l*(1-r),o.push({time:n[s].time,value:l});return o}points(){return (this.#n==="exponential"?i.exponential(this.#e,this.#t):i.simple(this.#e,this.#t)).map(t=>({x:this.#r.map(t.time),y:this.#a.map(t.value)}))}render(){let e=this.points();return e.length<2?e.map(t=>({type:"circle",cx:t.x,cy:t.y,r:this.#i,fill:this.#o})):[{type:"path",points:e,smoothing:true,stroke:this.#o,strokeWidth:this.#i}]}};var le=class{#e;#t;#n;constructor(e){let t=Object.keys(e.enumMap).map(Number).sort((n,r)=>n-r).map(String);this.#t=t,this.#e=new H({domain:t,range:e.range}),this.#n=e;}get scale(){return this.#e}generateTicks(){let{enumMap:e,showLabels:t=true,autoColor:n=true,gapValues:r}=this.#n,o=new Set(r??[]);return this.#t.map((l,s)=>{let a=Number(l),m=t?e[a]??String(a):String(a),u=this.#e.map(a),d=n?f.palette[s%f.palette.length]:void 0;return {value:a,label:m,y:u,color:d,isGap:o.has(a)}})}colorFor(e){let t=this.#t.indexOf(String(e));if(!(t===-1||!(this.#n.autoColor??true)))return f.palette[t%f.palette.length]}render(){let e=this.generateTicks(),t=this.#n.x??0,n=[];for(let r of e)r.isGap||n.push({type:"text",content:r.label,x:t,y:r.y+4,anchor:"end",fontSize:f.textSize,fill:r.color??f.textColor});return n}map(e){return this.#e.map(e)}isGap(e){return new Set(this.#n.gapValues??[]).has(e)}};var M=class i{#e;#t;static uidcnt=0;#n;constructor(e,t=[]){this.#e=e.id??"series-"+ ++i.uidcnt,this.#t=e.timeScale,this.#n=t;}get id(){return this.#e}get timeScale(){return this.#t}get data(){return this.#n}};var me=class extends M{#e;constructor(e){super(e,e.data),this.#e=e;}points(){let e=this.#e.valueScale;return this.data.filter(t=>t.value!==null).map(t=>({x:this.timeScale.map(t.time),y:e.map(t.value),time:t.time})).sort((t,n)=>t.x-n.x)}render(){let e=this.#e,t={smoothing:e.smoothing??false,smoothingType:e.smoothingType,stroke:e.stroke??f.stroke,strokeWidth:e.strokeWidth??f.strokeWidth,dashed:e.dashed??false,pointStyle:e.pointStyle??"none",pointSize:e.pointSize??f.pointSize,shadowColor:e.shadowColor,shadowBlur:e.shadowBlur,shadowOffsetX:e.shadowOffsetX,shadowOffsetY:e.shadowOffsetY},n=e.pointThreshold??f.pointThreshold,r=e.gapThreshold??f.gapThreshold,o=e.id,l=T.getRuns(this.data,d=>d.value===null,r),s=l.reduce((d,p)=>d+p.length,0);if(s===0)return [];let a={timeScale:this.timeScale,valueScale:e.valueScale},m=l.map(d=>({data:d})),u=[];return u.push(...L(m,a,{...t,id:o?`${o}-line`:void 0})),t.pointStyle&&t.pointStyle!=="none"&&s<=n&&u.push(...Q(l.flat(),a,{...t,id:o?`${o}-marker`:void 0},()=>t.stroke)),u}};var ue=class extends M{#e;constructor(e){super(e,e.data),this.#e=e;}points(){let e=this.#e.valueScale,t=[...this.data].filter(r=>r.value!==null).sort((r,o)=>r.time-o.time),n=[];for(let r=0;r<t.length;r++){let o=this.timeScale.map(t[r].time),l=e.map(t[r].value);r===0?n.push({x:o,y:l}):n.push({x:o,y:n[n.length-1].y},{x:o,y:l});}return n}render(){let e=T.getRuns(this.data,r=>r.value===null);if(e.length===0)return [];let t={timeScale:this.timeScale,valueScale:this.#e.valueScale},n=e.map(r=>({data:r}));return q(n,t,{stroke:this.#e.stroke??f.stroke,strokeWidth:this.#e.strokeWidth??f.strokeWidth,id:this.id?`${this.id}-line`:void 0})}};var ce=class extends M{#e;constructor(e){super(e,e.data),this.#e=e;}opacity(e){if(!(this.#e.countOpacity??false))return .6;let t=0;for(let n of this.data)n.count>t&&(t=n.count);return t===0?.2:.2+.8*e/t}render(){let e=this.#e,t=e.fill??f.bandFill,n=e.hatch,r=e.avgLine??false,o=e.avgLineColor??f.bandAvgLine,l=e.bandWidth??10,s=[];for(let a of this.data){if(a.min===null||a.max===null)continue;let m=this.timeScale.map(a.time),u=e.valueScale.map(a.max),d=e.valueScale.map(a.min),p=l,c=this.data.indexOf(a);if(s.push({type:"rect",x:m-p/2,y:u,w:p,h:d-u,fill:t,hatch:n,opacity:this.opacity(a.count),id:this.id?`${this.id}-slot-${c}`:void 0}),r&&a.avg!==null){let h=e.valueScale.map(a.avg);s.push({type:"line",x1:m-p/2,y1:h,x2:m+p/2,y2:h,stroke:o,strokeWidth:1,id:this.id?`${this.id}-avg-${c}`:void 0});}}return s}};function Le(i,e,t,n,r,o,l){return J(i,e,{boundaries:[],yLow:s=>s.avg,yHigh:t,getValue:s=>s.avg,interpolate:T.interpolateAggregatedPoint,getColor:()=>n,getHatch:()=>r},{id:o,...l})}var he=class extends M{#e;constructor(e){super(e,e.data),this.#e=e;}render(){let e=this.#e,t=e.minColor??f.minColor,n=e.maxColor??f.maxColor,r=e.avgColor??f.avgColor,o=e.avgDashed??true,l=e.smoothing??false,s=e.smoothingType,a=e.strokeWidth??f.strokeWidth,m=T.getRuns(this.data,h=>h.min===null||h.max===null||h.avg===null);if(m.length===0)return [];let u={timeScale:this.timeScale,valueScale:e.valueScale},d=[];m.forEach((h,g)=>{if(h.length<2)return;let y=b=>this.id?`${this.id}-${b}-${g}`:void 0;if(e.fillToMax){let b=Le(h,u,x=>x.max,e.fillToMax,e.fillToMaxHatch,y("fillToMax"),{smoothing:l,smoothingType:s});d.push(...b);}if(e.fillToMin){let b=Le(h,u,x=>x.min,e.fillToMin,e.fillToMinHatch,y("fillToMin"),{smoothing:l,smoothingType:s});d.push(...b);}});let p=m.filter(h=>h.length>=2),c=(h,g,y,b=false)=>L(p.map(x=>({data:x.map(S=>({time:S.time,value:h(S)}))})),u,{stroke:g,strokeWidth:a,smoothing:l,smoothingType:s,dashed:b,id:this.id?`${this.id}-${y}`:void 0});return d.push(...c(h=>h.max,n,"max"),...c(h=>h.min,t,"min"),...c(h=>h.avg,r,"avg",o)),d}};var mt=1,de=class{#e;constructor(e,t,n,r){this.#e={...e,xRange:t,y:n,height:r};}render(){let{items:e,timeScale:t,background:n,hatch:r,showAxis:o,xRange:l,y:s,height:a}=this.#e,m=[];n&&m.push({type:"rect",x:l[0],y:s,w:l[1]-l[0],h:a,fill:n,opacity:.04,stroke:"#ddd",strokeWidth:.25});for(let u of e){let d=t.map(u.startTime),p=t.map(u.endTime);if(p<l[0]||d>l[1])continue;let c=Math.max(l[0],Math.min(l[1],d)),h=Math.max(l[0],Math.min(l[1],p)),g=Math.max(h-c,mt);c+g>l[1]&&(c=Math.max(l[0],l[1]-g));let y=c+g/2;if(m.push({type:"rect",x:c,y:s,w:g,h:a,hatch:u.hatch??r,fill:u.fill??"#6b728044",stroke:u.stroke,strokeWidth:u.strokeWidth??0,title:u.title}),u.label){let b=u.labelFontSize??10;m.push({type:"text",content:u.label,x:y,y:this.#t(u.labelBaseline,b),anchor:"middle",fontSize:b,fill:u.labelFill??"#333"});}}if(o){let u=new G({domain:t.domain(),xRange:l,y:s+a+4});m.push({type:"group",cssClass:"annotation-band-axis",commands:u.render()});}return m}#t(e,t){let{y:n,height:r}=this.#e;switch(e){case "top":return n+t*.9;case "bottom":return n+r-t*.25;default:return n+r/2+t*.35}}};var pe=class{#e;constructor(e){this.#e=e;}render(){let{data:e,valueScale:t,xRange:n,showMin:r=false,showMax:o=false,showAvg:l=true,showMedian:s=false,labelPosition:a="end",lineColor:m=f.statsLineColor,labelColor:u=f.statsLabelColor}=this.#e,d=be.compute(e),p=[{name:"min",value:d.min,enabled:r},{name:"max",value:d.max,enabled:o},{name:"avg",value:d.avg,enabled:l},{name:"median",value:d.median,enabled:s}],c=[],[h,g]=n;for(let y of p.filter(b=>b.enabled)){let b=t.map(y.value);c.push({type:"line",x1:h,y1:b,x2:g,y2:b,stroke:m,strokeWidth:1});let x=`${y.name}: ${y.value.toFixed(1)}`;(a==="start"||a==="both")&&c.push({type:"text",content:x,x:h+4,y:b-4,anchor:"start",fontSize:f.statFontSize,fill:u}),(a==="end"||a==="both")&&c.push({type:"text",content:x,x:g-4,y:b-4,anchor:"end",fontSize:f.statFontSize,fill:u}),a==="center"&&c.push({type:"text",content:x,x:(h+g)/2,y:b-4,anchor:"middle",fontSize:f.statFontSize,fill:u});}return c}};var R=class{#e;#t;#n;constructor(e){this.#e=e?.locale||(X()??"en-US"),this.#t=e?.fallbackLocales??["en-US"],this.#n=e?.autoFormat??true;}format(e,t,n){try{let r=this.#n&&n?this.#r(e,n,t):t;return B(this.#e,r).format(new Date(e))}catch{for(let r of this.#t)try{return B(r,t).format(new Date(e))}catch{}return new Date(e).toISOString()}}formatRange(e,t){let n=this.format(e),r=this.format(t);return `${n} \u2014 ${r}`}#r(e,t,n){let r=Math.abs(e-t),o=864e5,l=36e5,s=6e4,a={};return r<s?(a.second="2-digit",a.minute="2-digit",a.hour="2-digit"):r<l?(a.minute="2-digit",a.hour="2-digit"):r<o?(a.hour="2-digit",a.minute="2-digit"):r<7*o?(a.weekday="short",a.day="numeric"):r<365*o?(a.month="short",a.day="numeric"):(a.month="short",a.year="numeric"),{...n,...a}}};var $=class i{#e;#t;_compact;#n;constructor(e){this.#e=e?.unit??"",this.#t=e?.decimals??1,this._compact=e?.compact??false,this.#n=e?.custom;}format(e){if(this.#n)return this.#n(e);let t;return this._compact&&Math.abs(e)>=1e6?t=`${(e/1e6).toFixed(this.#t)}M`:this._compact&&Math.abs(e)>=1e3?t=`${(e/1e3).toFixed(this.#t)}k`:t=e.toFixed(this.#t),this.#e?`${t}${this.#e}`:t}formatRange(e,t){return `${this.format(e)} \u2014 ${this.format(t)}`}static unit(e,t=1){return new i({unit:e,decimals:t})}static temperature(e="\xB0C"){return new i({unit:e,decimals:1})}static percentage(){return new i({unit:"%",decimals:0})}};var F=class i{#e;#t;#n;constructor(e){this.#e=e?.map??{},this.#t=e?.fallback??(t=>String(t)),this.#n=e?.showValue??false;}format(e){let t=this.#e[e]??this.#t(e);return this.#n?`(${e}) ${t}`:t}has(e){return e in this.#e}labels(){return Object.values(this.#e)}values(){return Object.keys(this.#e).map(Number)}static fromLabels(e,t=false){let n={};return e.forEach((r,o)=>{n[o]=r;}),new i({map:n,showValue:t})}};var ut={time:new R,value:new $,enum:new F};function fe(i,e){let t=D();return {color:i.color??t.stroke,width:i.width??t.strokeWidth,style:i.style??"solid",smoothing:i.smoothing??false,smoothingType:i.smoothingType,shape:i.shape??(e.seriesType==="step"?"step":"line"),gapThreshold:i.gapThreshold??t.gapThreshold,opacity:i.opacity??1}}function De(i){let e=i.style?.line;return e===false?[]:e===void 0?[fe({},i)]:Array.isArray(e)?e.map(t=>fe(t,i)):[fe(e,i)]}function _e(i){let e=i.style?.markers;if(!e?.type||e.type==="none")return;let t=D(),r=(i.style?.line&&!Array.isArray(i.style.line)?i.style.line.color:void 0)??t.stroke;return {type:e.type,size:e.size??t.pointSize,stroke:e.stroke??r,fill:e.fill??"#ffffff",strokeWidth:e.strokeWidth??1,threshold:e.threshold}}function Ae(i){let e=i.style?.shadow;if(!(!e?.color||e.color==="transparent"||e.color==="none"))return {color:e.color,blur:e.blur??4,offsetX:e.offsetX??0,offsetY:e.offsetY??0}}function Pe(i){return i.style?.gap}function Re(i){return i.style?.fill}function ct(i){return {lines:De(i),fill:Re(i),markers:_e(i),shadow:Ae(i),gap:Pe(i),id:i.style?.id??i.id}}/*!
28
28
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
29
29
  * MIT with Attribution: free use incl. commercial requires visible credit to
30
30
  * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
@@ -43,4 +43,4 @@ var Z=class{};var T=class{static interpolateDataPoint(i,e,t){return {time:i.time
43
43
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
44
44
  * MIT with Attribution: free use incl. commercial must have visible credit to
45
45
  * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
46
- */export{de as AnnotationBandSeries,H as BandScale,ce as BandSeries,oe as Clip,O as CommandBuilder,le as EnumAxis,F as EnumFormatter,mt as Formatters,re as Layout,me as LineSeries,A as LinearScale,he as MinMaxAvgSeries,se as MovingAvg,Z as Renderer,pe as StatsOverlay,ue as StepSeries,w as TIME_INTERVALS,G as TimeAxis,R as TimeFormatter,E as TimeScale,ae as ValueAxis,$ as ValueFormatter,Te as getHatch,ve as measureLegend,it as renderAnnotations,We as renderArea,tt as renderGaps,Ue as renderGrid,rt as renderHighlights,Ye as renderLegend,M as renderLine,nt as renderMarkers,Q as renderSeriesMarkers,Fe as renderSplitLine,q as renderStep,Je as renderThresholds,J as renderZonedArea,Re as resolveFill,Pe as resolveGap,De as resolveLines,_e as resolveMarkers,ut as resolveSeriesStyle,Ae as resolveShadow,ne as slugify,f as theme,$e as toStepData,K as toStepPoints};
46
+ */export{de as AnnotationBandSeries,H as BandScale,ce as BandSeries,oe as Clip,O as CommandBuilder,le as EnumAxis,F as EnumFormatter,ut as Formatters,re as Layout,me as LineSeries,A as LinearScale,he as MinMaxAvgSeries,se as MovingAvg,Z as Renderer,pe as StatsOverlay,ue as StepSeries,w as TIME_INTERVALS,G as TimeAxis,R as TimeFormatter,E as TimeScale,ae as ValueAxis,$ as ValueFormatter,Te as getHatch,ve as measureLegend,at as renderAnnotations,We as renderArea,nt as renderGaps,Ze as renderGrid,ot as renderHighlights,Ye as renderLegend,L as renderLine,rt as renderMarkers,Q as renderSeriesMarkers,Fe as renderSplitLine,q as renderStep,Qe as renderThresholds,J as renderZonedArea,Re as resolveFill,Pe as resolveGap,De as resolveLines,_e as resolveMarkers,ct as resolveSeriesStyle,Ae as resolveShadow,ne as slugify,f as theme,$e as toStepData,K as toStepPoints};
@@ -1,4 +1,4 @@
1
- import { a as DrawCommand, b as LineDashStyle, c as LineVariant, P as PointStyleType, d as DrawGroup, M as MarkerLineStyle, G as GridLayer, A as AxisPosition, e as AnySeries, f as Threshold, H as Highlight, g as Gap, h as GapsConfig, i as Annotation, j as AnnotationBandConfig, T as TimeScale, L as LinearScale, S as SmoothingType, k as HatchVariant, D as DataPoint } from './types-D7tmWwH9.js';
1
+ import { a as DrawCommand, b as LineDashStyle, c as LineVariant, P as PointStyleType, d as DrawGroup, M as MarkerLineStyle, G as GridLayer, A as AxisPosition, e as AnySeries, f as Threshold, H as Highlight, g as Gap, h as GapsConfig, i as Annotation, j as AnnotationBandConfig, T as TimeScale, L as LinearScale, S as SmoothingType, k as HatchVariant, D as DataPoint } from './types-CNIUKrmy.js';
2
2
 
3
3
  /** Output format type for the renderer (SVG string, Canvas, or nothing). */
4
4
  type RenderType = "svg" | "canvas" | "none";
@@ -474,6 +474,13 @@ interface YAxisConfig {
474
474
  offset?: number;
475
475
  /** Rotated label drawn next to the axis. */
476
476
  label?: string;
477
+ /**
478
+ * Distance in px from the axis line outwards to the centre of the rotated
479
+ * title. Set, it replaces the automatic placement (no lane search, no
480
+ * fallback lane); other titles on the same side avoid it. Unset, the
481
+ * library finds the place itself.
482
+ */
483
+ labelOffset?: number;
477
484
  /** Override the value domain. `'auto'` lets the chart compute it from data. */
478
485
  domain?: [number, number] | "auto";
479
486
  /**
@@ -686,6 +693,16 @@ interface MLTimeGraphOptions {
686
693
  * Stable across renders as long as you pass the same prefix.
687
694
  */
688
695
  idPrefix?: string;
696
+ /**
697
+ * Prefix for every CSS class the chart writes: `classPrefix: 'mltg'` gives
698
+ * `mltg-series`, `mltg-time-axis`, `mltg-series--pump`. For a host page
699
+ * whose stylesheet uses the same words (`.series { … }`) -- its rules would
700
+ * otherwise reach into the chart. The same for all charts of an app, unlike
701
+ * `idPrefix`. Your own `legend.itemClass` stays as you wrote it. Pass the
702
+ * same prefix to `SVGRenderer({ classPrefix })` for the few classes the
703
+ * renderer writes itself.
704
+ */
705
+ classPrefix?: string;
689
706
  /** Locale for i18n (e.g. 'de-DE') */
690
707
  locale?: string;
691
708
  /**
@@ -823,7 +840,6 @@ interface RenderingContext {
823
840
 
824
841
  /** Render point markers for segments. */
825
842
  declare function renderMarkers(points: DataPoint[], ctx: RenderingContext, style: FlatSeriesStyle, getColor: (p: DataPoint) => string): DrawCommand[];
826
- declare function drawMarker(// NOSONAR
827
- commands: DrawCommand[], id: string | undefined, shape: Exclude<PointStyleType, "none">, x: number, y: number, size: number, stroke: string, fill: string, sw: number): void;
843
+ declare function drawMarker(commands: DrawCommand[], id: string | undefined, shape: Exclude<PointStyleType, "none">, x: number, y: number, size: number, stroke: string, fill: string, sw: number): void;
828
844
 
829
845
  export { type AxesConfig as A, type FlatSeriesStyle as F, type GridLineStyle as G, type LegendItem as L, type MLTimeGraphOptions as M, Renderer as R, type TextMetrics as T, type XAxisConfig as X, type YAxisConfig as Y, type LayoutResult as a, type Margin as b, type LegendOptions as c, type LegendPosition as d, type LegendOrientation as e, type Marker as f, type RenderOutput as g, type AxisLabelsStyle as h, type AxisStyle as i, type GridStyle as j, type Theme as k, type TickConfig as l, drawMarker as m, estimateMetrics as n, getDefaultTheme as o, liberationMetrics as p, slugify as q, resetDefaultTheme as r, setDefaultTheme as s, type RenderingContext as t, Layout as u, type LayoutConfig as v, type LegendConfig as w, measureLegend as x, renderLegend as y, renderMarkers as z };
@@ -682,6 +682,21 @@ interface GapStyle {
682
682
  style?: SolidDashStyle;
683
683
  };
684
684
  }
685
+ /**
686
+ * `GapStyle` as it applies to ONE series (`series.style.gap`).
687
+ *
688
+ * Identical except for `label`: on a series it styles a text the series
689
+ * never has itself -- the text only comes from `gaps.regions[].label`
690
+ * (I-20260923-03).
691
+ */
692
+ interface SeriesGapStyle extends Omit<GapStyle, "label"> {
693
+ /**
694
+ * @deprecated A series has no gap text to style; set the label style
695
+ * chart-wide on `gaps.style.label`, next to the regions that carry the
696
+ * text. Will be removed before 2.0; `warnings()` reports it.
697
+ */
698
+ label?: GapLabel;
699
+ }
685
700
  /** A manually-declared gap region. */
686
701
  interface GapRegion {
687
702
  startTime: number;
@@ -821,7 +836,7 @@ interface SeriesStyle {
821
836
  /** Drop-shadow for line + markers. */
822
837
  shadow?: ShadowStyle;
823
838
  /** Per-series override for the gap rendering. */
824
- gap?: GapStyle;
839
+ gap?: SeriesGapStyle;
825
840
  }
826
841
 
827
842
  /*!
@@ -949,6 +964,20 @@ interface TimeSeries {
949
964
  id?: string;
950
965
  /** Luecken je Reihe -- etwa `atEnd: false` fuer einen Melder, der absichtlich schweigt. */
951
966
  gaps?: SeriesGaps;
967
+ /**
968
+ * Hold the last value until the end of the time axis (or `gaps.atEnd.now`):
969
+ * for a sensor that reports only on change (a door contact), whose state
970
+ * holds between reports. Without it the line ends at the last report and
971
+ * looks like an outage. `{ maxAgeMs }` holds at most that long.
972
+ *
973
+ * Only the line and its fill are extended; point markers, the tooltip,
974
+ * statistics and the value axis still see the real readings. A series with
975
+ * `holdToEnd` gets no `gaps.atEnd` region. A trailing `value: null` ends
976
+ * the line on purpose and is not held.
977
+ */
978
+ holdToEnd?: boolean | {
979
+ maxAgeMs?: number;
980
+ };
952
981
  }
953
982
  /** Aggregated series: min/max/avg per slot. */
954
983
  interface AggregatedSeries {
@@ -1214,4 +1243,4 @@ interface AnnotationBandConfig {
1214
1243
  items: AnnotationBandItem[];
1215
1244
  }
1216
1245
 
1217
- export { type SVGLineStyle as $, type AxisPosition as A, type DataPointRef as B, type FillBound as C, type DataPoint as D, type EnumMap as E, type FillSpec as F, type GridLayer as G, type Highlight as H, type FillRegion as I, type FillSide as J, type FillStyle as K, LinearScale as L, type MarkerLineStyle as M, type FillWhere as N, type GapConfig as O, type PointStyleType as P, type GapLabel as Q, type RangeLabelPosition as R, type SmoothingType as S, TimeScale as T, type GapRegion as U, type GapStyle as V, type GapsAtEnd as W, type LineShape as X, type LineStyle as Y, type MarkerStyle as Z, type MovingAverageType as _, type DrawCommand as a, type SensorType as a0, type SeriesGaps as a1, type SeriesOverlay as a2, type SeriesOverlayKind as a3, type SeriesType as a4, type ShadowStyle as a5, type SolidDashStyle as a6, type ThresholdLabelConfig as a7, getLineStyle as a8, resolveDash as a9, type GapBand as aa, type LineParams as ab, type PathParams as ac, type RectParams as ad, type CircleParams as ae, type TextParams as af, type GapParams as ag, type Point as ah, BandScale as ai, type BandScaleConfig as aj, type Dashstyle_t as ak, type DomainScaleConfig as al, type DrawCircle as am, type DrawGap as an, type DrawGapType_t$1 as ao, type DrawLine as ap, type DrawPath as aq, type DrawRect as ar, type DrawText as as, type LinearScaleConfig as at, type Scale as au, type ScaleConfig as av, TIME_INTERVALS as aw, type TimeScaleConfig as ax, getHatch as ay, type LineDashStyle as b, type LineVariant as c, type DrawGroup as d, type AnySeries as e, type Threshold as f, type Gap as g, type GapsConfig as h, type Annotation as i, type AnnotationBandConfig as j, type HatchVariant as k, type SeriesStyle as l, type TimeSeries as m, type ThresholdFill as n, type ThresholdLabelPosition as o, type AnnotationPointShape as p, type LabelAnchor as q, type AnnotationBandItem as r, type TextBaseline as s, type AggregatedPoint as t, type AggregatedSeries as u, type AggregatedShowAs as v, type AggregationConfig as w, type AggregationMode as x, type AnnotationKind as y, type AxisOrientation as z };
1246
+ export { type SVGLineStyle as $, type AxisPosition as A, type DataPointRef as B, type FillBound as C, type DataPoint as D, type EnumMap as E, type FillSpec as F, type GridLayer as G, type Highlight as H, type FillRegion as I, type FillSide as J, type FillStyle as K, LinearScale as L, type MarkerLineStyle as M, type FillWhere as N, type GapConfig as O, type PointStyleType as P, type GapLabel as Q, type RangeLabelPosition as R, type SmoothingType as S, TimeScale as T, type GapRegion as U, type GapStyle as V, type GapsAtEnd as W, type LineShape as X, type LineStyle as Y, type MarkerStyle as Z, type MovingAverageType as _, type DrawCommand as a, type SensorType as a0, type SeriesGapStyle as a1, type SeriesGaps as a2, type SeriesOverlay as a3, type SeriesOverlayKind as a4, type SeriesType as a5, type ShadowStyle as a6, type SolidDashStyle as a7, type ThresholdLabelConfig as a8, getLineStyle as a9, resolveDash as aa, type GapBand as ab, type LineParams as ac, type PathParams as ad, type RectParams as ae, type CircleParams as af, type TextParams as ag, type GapParams as ah, type Point as ai, BandScale as aj, type BandScaleConfig as ak, type Dashstyle_t as al, type DomainScaleConfig as am, type DrawCircle as an, type DrawGap as ao, type DrawGapType_t$1 as ap, type DrawLine as aq, type DrawPath as ar, type DrawRect as as, type DrawText as at, type LinearScaleConfig as au, type Scale as av, type ScaleConfig as aw, TIME_INTERVALS as ax, type TimeScaleConfig as ay, getHatch as az, type LineDashStyle as b, type LineVariant as c, type DrawGroup as d, type AnySeries as e, type Threshold as f, type Gap as g, type GapsConfig as h, type Annotation as i, type AnnotationBandConfig as j, type HatchVariant as k, type SeriesStyle as l, type TimeSeries as m, type ThresholdFill as n, type ThresholdLabelPosition as o, type AnnotationPointShape as p, type LabelAnchor as q, type AnnotationBandItem as r, type TextBaseline as s, type AggregatedPoint as t, type AggregatedSeries as u, type AggregatedShowAs as v, type AggregationConfig as w, type AggregationMode as x, type AnnotationKind as y, type AxisOrientation as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ml-time-graph",
3
- "version": "1.17.1",
3
+ "version": "1.18.0",
4
4
  "description": "TypeScript library for time-series charts with rich contextual annotation — telemetry, sensors, metrics, logs, finance. DOM-free SVG output, identical in the browser and on the server.",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
@@ -27,6 +27,7 @@
27
27
  "files": [
28
28
  "dist",
29
29
  "docs",
30
+ "skills",
30
31
  "SKILLS.md",
31
32
  "README.md",
32
33
  "README.de.md",
@@ -76,6 +77,6 @@
76
77
  "scripts": {
77
78
  "build": "tsup",
78
79
  "test": "vitest run",
79
- "typecheck": "tsc --noEmit"
80
+ "typecheck": "node ../../scripts/tsc7.mjs --noEmit"
80
81
  }
81
82
  }
@@ -0,0 +1,113 @@
1
+ ---
2
+ name: ml-time-graph
3
+ description: Build time-series charts with ml-time-graph (TypeScript, SVG as a string without DOM) and its Go port go-time-graph — thresholds and zone colouring, data gaps, annotations, several value axes, legends, tooltips, server-side and PDF rendering, and the Svelte 5 components in ml-time-graph-svelte. Use when writing or changing code that imports ml-time-graph, ml-time-graph-svelte or go-time-graph, or when sensor or measurement data over time has to become a chart.
4
+ ---
5
+
6
+ # ml-time-graph
7
+
8
+ MLTimeGraph is a TypeScript library for visualizing any time-series measurement data (telemetry, physical sensors, system metrics, logs, finance, laboratory or process measurements). Its standout capability is rich contextual annotation — turning raw curves into explanatory records with free-form annotations (arrows, labels, callout rects in data coordinates), time-range highlights, status/phase bands, and threshold zones. It has a single defining architectural property: it generates SVG as a pure string without touching the DOM — the exact same call runs identically in the browser and on the server.
9
+
10
+ For the exhaustive reference, see `USAGE.md` in the package root ([USAGE.md](../../USAGE.md)); the task-by-task
11
+ details are in `reference/` next to this file (index below).
12
+
13
+ ## Shortest Path to a Visible Chart
14
+
15
+ ```ts
16
+ import { mount } from 'ml-time-graph';
17
+
18
+ mount('#chart', {
19
+ width: 800,
20
+ height: 400,
21
+ series: [
22
+ {
23
+ name: 'Temperature',
24
+ data: [
25
+ { time: 1704067200000, value: 21.5 },
26
+ { time: 1704070800000, value: 22.8 },
27
+ { time: 1704074400000, value: 20.3 },
28
+ ],
29
+ style: { line: { color: '#ef4444' } },
30
+ },
31
+ ],
32
+ });
33
+ ```
34
+
35
+ ### The data does not look like that
36
+
37
+ `{ time, value }` is what the chart wants, not what you have. Convert instead of rebuilding —
38
+ tuples, a REST payload in Unix seconds, a CSV export of strings, a nested document:
39
+
40
+ ```ts
41
+ import { toSeries } from 'ml-time-graph';
42
+
43
+ toSeries('Temperature', tuples) // [[1704067200000, 21.5], …]
44
+ toSeries('Temperature', rows, { time: 'ts', value: 'val', timeUnit: 's' })
45
+ ```
46
+
47
+ Missing readings (`null`, `undefined`, `NaN`, `''`) become gaps. A string that is not a number
48
+ throws and names the row — silently dropping it would turn a broken export into a plausible
49
+ chart.
50
+
51
+ ### The same options in every chart
52
+
53
+ Dimensions, axes, legend, colours repeat across reports. Put them underneath instead of copying
54
+ them:
55
+
56
+ ```ts
57
+ import { mergeOptions, MLTimeGraph } from 'ml-time-graph';
58
+
59
+ new MLTimeGraph(mergeOptions(houseTheme, readings)); // the later layer wins
60
+ ```
61
+
62
+ Objects merge, everything else is replaced — arrays included, so a theme carrying one line
63
+ style does not turn one curve into two. `{ ...a, ...b }` is **not** the same: the spread is
64
+ shallow and an `axes` in `b` drops `a`'s grid and ticks. Server-side the same rule is
65
+ `graph-cli -with theme.json`, stackable.
66
+
67
+ ## When to Use What
68
+
69
+ - `mount(target, options)`: The declarative browser shortcut when a DOM element or selector exists — measures container width, renders SVG, and injects markup in one call.
70
+ - `new MLTimeGraph(options)`: The core headless engine when working with options objects directly — use for Node.js SSR, headless testing, or custom render pipelines.
71
+ - Builders (`GraphBuilder`, etc.): The fluent, imperative chaining API — use when assembling charts dynamically across conditional branches.
72
+ - Go port (`go-time-graph`): The 1:1 server-side Go implementation (`gitlab.com/mlc0911/mlctimegraph/go-time-graph`) — use when rendering charts in Go backends or microservices without a Node runtime.
73
+ - PDF output (`mlctimegraph-pdf`): A second consumer of the same draw commands (`gitlab.com/mlc0911/mlctimegraphpdf`) — writes native PDF vectors without a browser. Early (0.2.0); a fill on a path is still opaque and unhatched there.
74
+
75
+ ## Package Entry Points
76
+
77
+ - `ml-time-graph`: Core chart rendering API — `mount`, `MLTimeGraph`, `SVGRenderer`, `GraphBuilder`, `attachTooltip`, input adapters (`toSeries`, `toDataPoints`), options layering (`mergeOptions`), types, and legend helpers (`resolveDash`, `getLineStyle`, `drawMarker`).
78
+ - `ml-time-graph/analyze`: Pure-math statistics companion — `aggregateBySlot`, `downsample` (LTTB), `detectGaps`, `rollingMkt`, `rollingStdDev`, `computeLimitExcursions`, `StatsAggregator`.
79
+ - `ml-time-graph/interaction`: Headless interaction primitives — `Zoom`, `Minimap`, and coordinate-based interaction state management.
80
+ - `ml-time-graph/internals`: Low-level building blocks for custom renderers — `DrawCommand` model, base `Renderer`, layout engine, scales, and axis renderers.
81
+ - `ml-time-graph-svelte` (separate package, same version): Svelte 5 components `<TimeGraph>` and `<Legend>` — container width, `autoMargin`, tooltip and keyboard, hiding, zoom, `syncTime` for dashboards, dark mode, export, print. `tooltip={false}` drops only the tooltip box. Its README is the manual.
82
+
83
+ ## Tasks — read the matching reference file
84
+
85
+ | Task | File |
86
+ | --- | --- |
87
+ | Several series, a second or third value axis, `axisGroups`, axis titles and `labelOffset`, margins, grid, minor ticks, time zone | [reference/axes.md](reference/axes.md) |
88
+ | Threshold lines and zone colouring, filled areas between curve and threshold or between two series, `where`, `divergenceExcursions` | [reference/thresholds-and-fills.md](reference/thresholds-and-fills.md) |
89
+ | Missing data (`value: null`), gap regions and labels, `gaps.atEnd` for a device that went quiet, `holdToEnd` for a sensor that reports only on change | [reference/gaps.md](reference/gaps.md) |
90
+ | Arrows, labels and rectangles in data coordinates, time-range highlights, status bands, markers | [reference/annotations-and-markers.md](reference/annotations-and-markers.md) |
91
+ | Legend placement, a clickable legend, a panel behind it, line patterns in the swatches | [reference/legend.md](reference/legend.md) |
92
+ | Smoothing (which spline), aggregated min/max/avg series, moving average and other overlays | [reference/series-styles.md](reference/series-styles.md) |
93
+ | Draw commands, tooltips and `pointsAt`, server-side rendering, CSS classes, `idPrefix`, `classPrefix` | [reference/rendering.md](reference/rendering.md) |
94
+ | Svelte 5 components (`ml-time-graph-svelte`) | [reference/svelte.md](reference/svelte.md) |
95
+
96
+ ## Traps (Read Before Coding)
97
+
98
+ - **Timestamps are numbers, not Date objects:** `time` is always milliseconds since Unix epoch (`number`). Passing a `Date` object fails typechecking or evaluates to `NaN`.
99
+ - **Margins are fixed unless you measure them:** The chart draws into `margin` (default `{ top: 20, right: 20, bottom: 40, left: 60 }`). A right Y-axis or a formatted unit (`120.5 °C`) does not fit into `right: 20`, and a clipped number is a wrong number (`120` clipped to `20`). Use `margin: autoMargin(options)` — it measures the labels the chart actually draws (no DOM, a few ms) — or set the margins yourself.
100
+ - **Something you configured does not show up — ask `chart.warnings()`.** Drawing never throws for a threshold name with a typo, a fill bound naming an unknown series, `side` where it is ignored, two series sharing an id, or a deprecated field; it just leaves the thing out. `warnings()` (Go: `Warnings()`, same texts) lists exactly these. Thresholds are found by `id`, and by `name` only when they have no `id`.
101
+ - **`resolveDash()` vs `getLineStyle()`:** `dashed` and `dotted` predate the scalable dash table and keep fixed SVG patterns (`"4,4"` and `"2,4"`) in the renderer for backwards compatibility. `getLineStyle()` returns the scalable table (`"6, 4"` for width 2). Anyone rendering custom legend swatches must call `resolveDash(variant, width)` so the swatch matches what is actually drawn.
102
+ - **Markers do not inherit `line.width`:** `style.markers` carries its own pen — `strokeWidth`, `stroke`, `fill`. That is usually what you want (a 10 px line with 10 px marker outlines is a blob), but it means a marker stays hairline-thin when the line gets thick, and nothing tells you. Set `markers.strokeWidth` explicitly whenever `line.width` leaves the default.
103
+ - **Marker suppression at threshold:** `style.markers.threshold` (and default `theme.pointThreshold = 100`) hides point markers when series sample count exceeds it to prevent visual crowding. Crucially, `chart.legendItems()` also omits the `marker` property when points are suppressed, because a symbol in the legend missing from the curve states something untrue.
104
+ - **A built-in legend carries no behaviour, but it is reachable.** Until 1.12.0 this entry said a
105
+ built-in legend was "non-interactive" and that toggling meant `position: 'separate'` and drawing
106
+ it yourself. That is no longer true: every entry is its own group with the same stable key as its
107
+ series (`#legend-<id>` → `#series-<id>`), and `legend.itemClass` adds your own hook. The library
108
+ still ships no click handler — you write one, and one on the chart is enough. `'separate'` remains
109
+ the way when the legend belongs in HTML, or needs to do more than toggle.
110
+ - **An annotation's `dash` takes a variant, not a pattern:** the type is `'dashed' | 'dotted'`. A raw SVG pattern like `'5,5'` is not rejected — it draws a solid line, in both libraries.
111
+ - **One option is still accepted and does nothing:** `series.sensorType` is in the types and the parser reads it, but no renderer acts on it — in either library. Setting it to `'enum'` does not label the axis; that is `series.enumMap`, which 1.10.0 wired up. Since 1.17.1 it is marked **deprecated** and will be removed before 2.0; so is the flat gap style `'label'` (use `'empty'` with a `label`), which `warnings()` reports. Until 1.10.0 this list also held `ticks.minor`, `grid.minor` and `enumMap` itself: three fields the types promised and both renderers swallowed. Since 1.18 `warnings()` reports `sensorType` too (any value but `"numeric"`, which `parseJSON` sets itself).
112
+ - **CSS classes are not namespaced:** the chart uses plain names like `.series` and `.time-axis`. Inline the SVG into a page whose stylesheet has a `.series` rule and that rule applies to the chart. Scope your own selectors, and suspect the host page when an embedded chart looks wrong but the standalone file does not.
113
+ - **Hatch lines adapt to fill colour:** Hatch patterns inherit the opaque colour of the area they belong to (`opaqueColor(fill)`), while the backdrop stays translucent. An earlier default drew fixed blue lines (`#4D88FF`), which falsely signaled an extra state on incident charts where colour is semantic.