ml-time-graph 1.7.0 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.de.md CHANGED
@@ -91,7 +91,7 @@ Demo-Galerie zu sehen (`pnpm dev`).
91
91
 
92
92
  ## 🔄 Go-Port & 1:1 Rendering-Parität
93
93
 
94
- Benötigst du serverseitiges Rendering der exakt gleichen Charts? Es gibt einen 1:1 Go-Port dieser Engine unter **[gitlab.com/mlc0911/mlctimegraph/go-time-graph](https://gitlab.com/mlc0911/mlctimegraph/go-time-graph)**.
94
+ Benötigst du serverseitiges Rendering der exakt gleichen Charts? Es gibt einen 1:1 Go-Port dieser Engine unter **[gitlab.com/mlc0911/mlctimegraph/go-time-graph](https://gitlab.com/mlc0911/mlctimegraph/-/tree/main/go-time-graph)**.
95
95
 
96
96
  Sowohl die TypeScript- als auch die Go-Bibliothek:
97
97
  - Verarbeiten das **exakt gleiche JSON-Konfigurationsschema**.
@@ -101,6 +101,36 @@ Sowohl die TypeScript- als auch die Go-Bibliothek:
101
101
 
102
102
  ---
103
103
 
104
+ ## 📜 Versionsverlauf
105
+
106
+ Beide Bibliotheken werden im Gleichschritt unter einer Versionsnummer veröffentlicht —
107
+ deshalb gibt es **ein** Changelog für beide: [CHANGELOG.md](https://gitlab.com/mlc0911/mlctimegraph/-/blob/main/CHANGELOG.md).
108
+
109
+ ---
110
+
111
+ ## 📄 PDF-Ausgabe
112
+
113
+ Die Engine zeichnet kein SVG — sie erzeugt eine Liste von Zeichenbefehlen, und SVG ist ein
114
+ Abnehmer dieser Liste. **[mlctimegraph-pdf](https://gitlab.com/mlc0911/mlctimegraphpdf)** ist der
115
+ zweite: Es geht dieselben Befehle durch und schreibt native PDF-Vektoren. Kein Browser, kein
116
+ SVG-Parsen, kein Headless-Chromium — und es ist dasselbe Diagramm, weil es aus denselben
117
+ Befehlen kommt.
118
+
119
+ Es liest dasselbe JSON, mit dem auch das Diagramm konfiguriert wird:
120
+
121
+ ```bash
122
+ go get gitlab.com/mlc0911/mlctimegraphpdf
123
+ mtg-pdf -in chart.json -out chart.pdf
124
+ ```
125
+
126
+ Noch jung: Version 0.2.0, nicht 1.0, und ein, zwei Fähigkeiten hinter dieser Bibliothek. Was man
127
+ vorher wissen sollte — eine Füllung auf einem *Pfad*, also die Fläche unter einer Linie oder
128
+ einer Treppe, kommt derzeit deckend und ohne Schraffur heraus, weil nur Rechtecke beides
129
+ durchreichen. Linien, Marker, Text, Strichmuster, Kurvengeometrie und rechteckige Füllungen sind
130
+ da.
131
+
132
+ ---
133
+
104
134
  ## Warum schon wieder eine neue Library?
105
135
 
106
136
  Alle Libraries, die ich in der Vergangenheit professionell genutzt habe, haben
package/README.md CHANGED
@@ -91,7 +91,7 @@ library, all live in the demo gallery (`pnpm dev`).
91
91
 
92
92
  ## 🔄 Go Port & 1:1 Rendering Parity
93
93
 
94
- Need server-side rendering of the exact same charts? There is a 1:1 Go port of this engine available at **[gitlab.com/mlc0911/mlctimegraph/go-time-graph](https://gitlab.com/mlc0911/mlctimegraph/go-time-graph)**.
94
+ Need server-side rendering of the exact same charts? There is a 1:1 Go port of this engine available at **[gitlab.com/mlc0911/mlctimegraph/go-time-graph](https://gitlab.com/mlc0911/mlctimegraph/-/tree/main/go-time-graph)**.
95
95
 
96
96
  Both the TypeScript and Go libraries:
97
97
  - Process the **exact same JSON configuration schema**.
@@ -101,6 +101,34 @@ Both the TypeScript and Go libraries:
101
101
 
102
102
  ---
103
103
 
104
+ ## 📜 Release history
105
+
106
+ Both libraries are released in lockstep on one version number, so there is **one**
107
+ changelog for both: [CHANGELOG.md](https://gitlab.com/mlc0911/mlctimegraph/-/blob/main/CHANGELOG.md).
108
+
109
+ ---
110
+
111
+ ## 📄 PDF Output
112
+
113
+ The engine does not draw SVG — it produces a list of draw commands, and SVG is one consumer
114
+ of that list. **[mlctimegraph-pdf](https://gitlab.com/mlc0911/mlctimegraphpdf)** is the second
115
+ one: it walks the same commands and writes native PDF vectors. No browser, no SVG parsing, no
116
+ headless Chromium — and it is the same chart, because it comes from the same commands.
117
+
118
+ It reads the same JSON your chart is configured with:
119
+
120
+ ```bash
121
+ go get gitlab.com/mlc0911/mlctimegraphpdf
122
+ mtg-pdf -in chart.json -out chart.pdf
123
+ ```
124
+
125
+ Early days: it is at 0.2.0, not 1.0, and trails this library by a feature or two. Worth knowing
126
+ before you rely on it — a fill on a *path* (the area under a line or a step) currently renders
127
+ opaque and without its hatch pattern, because only rectangles carry those through. Lines,
128
+ markers, text, dash patterns, curve geometry and rectangular fills are there.
129
+
130
+ ---
131
+
104
132
  ## Why another chart library?
105
133
 
106
134
  Every charting library I relied on professionally eventually switched its license
package/SKILLS.md CHANGED
@@ -32,6 +32,7 @@ mount('#chart', {
32
32
  - `new MLTimeGraph(options)`: The core headless engine when working with options objects directly — use for Node.js SSR, headless testing, or custom render pipelines.
33
33
  - Builders (`GraphBuilder`, etc.): The fluent, imperative chaining API — use when assembling charts dynamically across conditional branches.
34
34
  - 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.
35
+ - 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.
35
36
 
36
37
  ## Package Entry Points
37
38
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { L as LegendOrientation, R as Renderer, M as Marker, a as LegendItem, b as LayoutResult, c as RenderOutput } from './series_renderer-DQXKJttA.js';
2
- export { T as Theme, d as drawMarker, g as getDefaultTheme, r as resetDefaultTheme, s as setDefaultTheme } from './series_renderer-DQXKJttA.js';
1
+ import { L as LegendOrientation, R as Renderer, M as Marker, a as LegendItem, b as LayoutResult, c as RenderOutput } from './series_renderer-COVNvq2x.js';
2
+ export { T as Theme, d as drawMarker, g as getDefaultTheme, r as resetDefaultTheme, s as setDefaultTheme } from './series_renderer-COVNvq2x.js';
3
3
  import { L as LineVariant, A as AnySeries, T as Threshold, H as Highlight, G as Gap, a as GapsConfig, b as Annotation, c as AnnotationBandConfig, D as DrawCommand, d as TimeScale, e as LinearScale, S as SeriesStyle, F as FillSpec, f as TimeSeries, g as HatchVariant, h as ThresholdLabelPosition, P as PointStyleType, i as AnnotationBandItem, j as AggregatedPoint, k as AggregatedSeries, l as DataPoint } from './scale-D6NtEaUB.js';
4
4
  export { m as AggregationConfig, n as AggregationMode, o as DataPointRef, E as EnumMap, p as FillBound, q as FillDirectionType, r as FillRegion, s as FillSide, t as FillStyle, u as GapConfig, v as GapLabel, w as GapRegion, x as GapStyle, y as LineDashStyle, z as LineStyle, M as MarkerStyle, B as SVGLineStyle, C as SensorType, I as SeriesOverlay, J as SeriesOverlayKind, K as SeriesType, N as ShadowStyle, O as ThresholdLabelConfig, Q as getLineStyle, R as resolveDash } from './scale-D6NtEaUB.js';
5
5
 
@@ -1,5 +1,5 @@
1
- import { T as Theme, M as Marker } from './series_renderer-DQXKJttA.js';
2
- export { e as Layout, f as LayoutConfig, b as LayoutResult, h as LegendConfig, a as LegendItem, L as LegendOrientation, R as Renderer, m as measureLegend, i as renderArea, j as renderLegend, k as renderLine, l as renderSeriesMarkers, n as renderSplitLine, o as renderStep, p as renderZonedArea } from './series_renderer-DQXKJttA.js';
1
+ import { T as Theme, M as Marker } from './series_renderer-COVNvq2x.js';
2
+ export { e as Layout, f as LayoutConfig, b as LayoutResult, h as LegendConfig, a as LegendItem, L as LegendOrientation, R as Renderer, m as measureLegend, i as renderArea, j as renderLegend, k as renderLine, l as renderSeriesMarkers, n as renderSplitLine, o as renderStep, p as renderZonedArea, t as toStepData, q as toStepPoints } from './series_renderer-COVNvq2x.js';
3
3
  import { D as DrawCommand, T as Threshold, e as LinearScale, G as Gap, d as TimeScale, g as HatchVariant, H as Highlight, b as Annotation, E as EnumMap, U as BandScale, l as DataPoint, P as PointStyleType, V as Point, j as AggregatedPoint, i as AnnotationBandItem, L as LineVariant, F as FillSpec, x as GapStyle, f as TimeSeries } from './scale-D6NtEaUB.js';
4
4
  export { W as AxisOrientation, X as AxisPosition, Y as BandScaleConfig, Z as CircleParams, _ as Dashstyle_t, $ as DomainScaleConfig, a0 as DrawCircle, a1 as DrawGap, a2 as DrawGapType_t, a3 as DrawGradient, a4 as DrawGroup, a5 as DrawLine, a6 as DrawPath, a7 as DrawRect, a8 as DrawText, a9 as LabelAnchor, aa as LineParams, ab as LinearScaleConfig, ac as PathParams, ad as RectParams, ae as Scale, af as ScaleConfig, ag as TIME_INTERVALS, ah as TextParams, ai as TimeScaleConfig, aj as getHatch } from './scale-D6NtEaUB.js';
5
5
 
package/dist/internals.js CHANGED
@@ -1,4 +1,4 @@
1
- var z=class{};var S=class{static interpolateDataPoint(a,e,t){return {time:a.time+Math.round(t*(e.time-a.time)),value:(a.value??0)+t*((e.value??0)-(a.value??0))}}static interpolateAggregatedPoint(a,e,t){let n=(r,o)=>r!==null&&o!==null?r+t*(o-r):null;return {time:a.time+t*(e.time-a.time),min:n(a.min,e.min),max:n(a.max,e.max),avg:n(a.avg,e.avg),count:Math.round(a.count+t*(e.count-a.count))}}static getRuns(a,e,t=0){let n=[...a].sort((l,i)=>l.time-i.time),r=[],o=[],s=null;for(let l of n){let i=e(l),m=t>0&&s&&l.time-s.time>t;(i||m)&&o.length&&(r.push(o),o=[]),i||o.push(l),s=l;}return o.length&&r.push(o),r}static splitByBoundaries(a,e,t,n){if(a.length===0)return [];if(e.length===0)return [{data:a,zoneIndex:0,zoneLow:Number.NEGATIVE_INFINITY}];let r=[...e].sort((m,u)=>m-u),o=[],s=m=>m<=0?Number.NEGATIVE_INFINITY:r[m-1],l=m=>{let u=0;for(let c=0;c<r.length&&m>=r[c];c++)u=c+1;return u},i=[a[0]];for(let m=1;m<a.length;m++){let u=a[m-1],c=a[m],d=t(u),p=t(c),f;p>d?f=r.filter(b=>b>d&&b<=p):p<d?f=r.filter(b=>b>=p&&b<d).reverse():f=[];let g=d;for(let b of f){let y=(b-d)/(p-d),x=n(u,c,y);i.push(x);let C=l((g+b)/2);o.push({data:i,zoneIndex:C,zoneLow:s(C)}),i=[x],g=b;}(f.length===0||f[f.length-1]!==p)&&i.push(c);}if(i.length>1){let m=t(i[0]),u=t(i[i.length-1]),c=l((m+u)/2);o.push({data:i,zoneIndex:c,zoneLow:s(c)});}return o}static splitByThreshold(a,e,t,n){let r=this.splitByBoundaries(a,[e],t,n),o={above:[],below:[]};for(let s of r)s.zoneIndex===0?o.below.push(s.data):o.above.push(s.data);return o}};var ce=class{static compute(a){let e=a.map(l=>l.value).filter(l=>l!==null).sort((l,i)=>l-i);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((l,i)=>l+i,0)/t,r=t%2===1?e[Math.floor(t/2)]:(e[t/2-1]+e[t/2])/2,o=e.reduce((l,i)=>l+Math.pow(i-n,2),0)/t,s=Math.sqrt(o);return {min:e[0],max:e[t-1],avg:n,mean:n,median:r,stdDev:s,count:t}}static computeInRange(a,e,t){let n=a.filter(r=>r.time>=e&&r.time<=t);return this.compute(n)}};var de={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,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 we={...de};function T(){return we}function Ce(a){let e=a.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 Te(a){let e=a.trim().toLowerCase();return e.startsWith("#")?e.length===9||e.length===5:e.startsWith("rgba(")||e.startsWith("hsla(")}function he(a,e="classic-diagonal",t="rgba(200, 220, 255, 0.3)",n,r=2){let o=n??Ce(t),s=Te(t)?"":' fill-opacity="0.3"';if(e==="none")return `
1
+ var z=class{};var S=class{static interpolateDataPoint(a,e,t){return {time:a.time+Math.round(t*(e.time-a.time)),value:(a.value??0)+t*((e.value??0)-(a.value??0))}}static interpolateAggregatedPoint(a,e,t){let n=(r,o)=>r!==null&&o!==null?r+t*(o-r):null;return {time:a.time+t*(e.time-a.time),min:n(a.min,e.min),max:n(a.max,e.max),avg:n(a.avg,e.avg),count:Math.round(a.count+t*(e.count-a.count))}}static getRuns(a,e,t=0){let n=[...a].sort((l,i)=>l.time-i.time),r=[],o=[],s=null;for(let l of n){let i=e(l),m=t>0&&s&&l.time-s.time>t;(i||m)&&o.length&&(r.push(o),o=[]),i||o.push(l),s=l;}return o.length&&r.push(o),r}static splitByBoundaries(a,e,t,n){if(a.length===0)return [];if(e.length===0)return [{data:a,zoneIndex:0,zoneLow:Number.NEGATIVE_INFINITY}];let r=[...e].sort((m,u)=>m-u),o=[],s=m=>m<=0?Number.NEGATIVE_INFINITY:r[m-1],l=m=>{let u=0;for(let c=0;c<r.length&&m>=r[c];c++)u=c+1;return u},i=[a[0]];for(let m=1;m<a.length;m++){let u=a[m-1],c=a[m],d=t(u),p=t(c),f;p>d?f=r.filter(b=>b>d&&b<=p):p<d?f=r.filter(b=>b>=p&&b<d).reverse():f=[];let g=d;for(let b of f){let y=(b-d)/(p-d),x=n(u,c,y);i.push(x);let C=l((g+b)/2);o.push({data:i,zoneIndex:C,zoneLow:s(C)}),i=[x],g=b;}(f.length===0||f[f.length-1]!==p)&&i.push(c);}if(i.length>1){let m=t(i[0]),u=t(i[i.length-1]),c=l((m+u)/2);o.push({data:i,zoneIndex:c,zoneLow:s(c)});}return o}static splitByThreshold(a,e,t,n){let r=this.splitByBoundaries(a,[e],t,n),o={above:[],below:[]};for(let s of r)s.zoneIndex===0?o.below.push(s.data):o.above.push(s.data);return o}};var ce=class{static compute(a){let e=a.map(l=>l.value).filter(l=>l!==null).sort((l,i)=>l-i);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((l,i)=>l+i,0)/t,r=t%2===1?e[Math.floor(t/2)]:(e[t/2-1]+e[t/2])/2,o=e.reduce((l,i)=>l+Math.pow(i-n,2),0)/t,s=Math.sqrt(o);return {min:e[0],max:e[t-1],avg:n,mean:n,median:r,stdDev:s,count:t}}static computeInRange(a,e,t){let n=a.filter(r=>r.time>=e&&r.time<=t);return this.compute(n)}};var de={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,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 Ce={...de};function T(){return Ce}function Te(a){let e=a.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 Le(a){let e=a.trim().toLowerCase();return e.startsWith("#")?e.length===9||e.length===5:e.startsWith("rgba(")||e.startsWith("hsla(")}function he(a,e="classic-diagonal",t="rgba(200, 220, 255, 0.3)",n,r=2){let o=n??Te(t),s=Le(t)?"":' fill-opacity="0.3"';if(e==="none")return `
2
2
  <pattern id="${a}" 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 S=class{static interpolateDataPoint(a,e,t){return {time:a.time
21
21
  ${c}
22
22
  ${u}
23
23
  </pattern>
24
- `.trim()}var h=new Proxy({},{get:(a,e)=>T()[e],has:(a,e)=>e in T(),ownKeys:()=>Reflect.ownKeys(T()),getOwnPropertyDescriptor:(a,e)=>Reflect.getOwnPropertyDescriptor(T(),e)});function H(a){return {id:a.id,line:{stroke:a.stroke??h.stroke,strokeWidth:a.strokeWidth??h.strokeWidth,smoothing:a.smoothing??false,dashed:a.dashed??false},fill:a.fill??h.areaFillAlpha,markers:{type:a.pointStyle??"none",size:a.pointSize??h.pointSize,stroke:a.stroke??h.stroke,fill:"#ffffff"},shadow:{color:a.shadowColor??"transparent",blur:a.shadowBlur??0,offsetX:a.shadowOffsetX??0,offsetY:a.shadowOffsetY??0}}}function w(a,e,t){let n=[],r=a.reduce((s,l)=>s+l.data.length,0),o=H(t);for(let s=0;s<a.length;s++){let l=a[s];l.data.length>=2?n.push({type:"path",id:t.id?`${t.id}-line-${s}`:void 0,points:l.data.map(i=>({x:e.timeScale.map(i.time),y:e.valueScale.map(i.value)})),stroke:l.color??o.line.stroke,strokeWidth:o.line.strokeWidth,smoothing:o.line.smoothing,dashed:o.line.dashed,shadowColor:o.shadow.color,shadowBlur:o.shadow.blur,shadowOffsetX:o.shadow.offsetX,shadowOffsetY:o.shadow.offsetY,fill:"none"}):l.data.length===1&&r===1&&n.push({type:"circle",cx:e.timeScale.map(l.data[0].time),cy:e.valueScale.map(l.data[0].value),r:Math.max(o.markers.size,o.line.strokeWidth),fill:l.color??o.line.stroke,shadowColor:o.shadow.color,shadowBlur:o.shadow.blur});}return n}function Le(a){let e=[];for(let t of a)e.length===0?e.push(t):e.push({x:t.x,y:e[e.length-1].y},t);return e}function G(a,e,t){let n=[],r=H(t);for(let o=0;o<a.length;o++){let s=a[o];if(s.data.length<2)continue;let l=Le(s.data.map(i=>({x:e.timeScale.map(i.time),y:e.valueScale.map(i.value)})));n.push({type:"path",id:t.id?`${t.id}-line-${o}`:void 0,points:l,stroke:s.color??r.line.stroke,strokeWidth:r.line.strokeWidth,smoothing:false,fill:"none"});}return n}function De(a,e,t,n,r){let o=[],s=H(t);for(let l=0;l<a.length;l++){let i=a[l];if(i.data.length<2)continue;let m=i.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(n(c))})),u=i.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(r(c))})).reverse();o.push({type:"path",id:t.id?`${t.id}-fill-${l}`:void 0,points:[...m,...u],fill:i.color??s.fill,hatch:t.hatch,stroke:"none"});}return o}function N(a,e,t,n){if(a.length<2)return [];let r=S.splitByBoundaries(a,t.boundaries,t.getValue,t.interpolate),o=[];for(let s=0;s<r.length;s++){let l=r[s];if(l.data.length<2)continue;let i=t.getColor(l.zoneIndex);if(!i)continue;let m=l.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(t.yLow(c))})),u=l.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(t.yHigh(c))})).reverse();o.push({type:"path",id:n?.id?`${n.id}-fill-${s}`:void 0,points:[...m,...u],fill:i,hatch:t.getHatch?.(l.zoneIndex),stroke:"none"});}return o}function Me(a,e,t,n){let r=S.splitByThreshold(a,e,s=>s.value,S.interpolateDataPoint),o=[];return n.below&&o.push(...w(r.below.map(s=>({data:s})),t,n.below)),n.above&&o.push(...w(r.above.map(s=>({data:s})),t,n.above)),o}function W(a,e,t,n){let r=H(t);if(!r.markers.type||r.markers.type==="none")return [];let o=[];for(let s=0;s<a.length;s++){let l=a[s],i=e.timeScale.map(l.time),m=e.valueScale.map(l.value),u=n(l),c=t.pointStroke??u,d=t.pointFill??u,p=t.pointStrokeWidth??1.5,f=t.id?`${t.id}-marker-${s}`:void 0;Y(o,f,r.markers.type,i,m,r.markers.size,c,d,p);}return o}function Y(a,e,t,n,r,o,s,l,i){switch(t){case "circle":a.push({type:"circle",cx:n,cy:r,r:o,fill:l,stroke:s,strokeWidth:i,id:e});break;case "square":a.push({type:"rect",x:n-o,y:r-o,w:o*2,h:o*2,fill:l,stroke:s,strokeWidth:i,id:e});break;case "cross":a.push({type:"line",x1:n-o,y1:r-o,x2:n+o,y2:r+o,stroke:s,strokeWidth:i,id:e},{type:"line",x1:n-o,y1:r+o,x2:n+o,y2:r-o,stroke:s,strokeWidth:i,id:e});break;case "diamond":a.push({type:"path",points:[{x:n,y:r-o},{x:n+o,y:r},{x:n,y:r+o},{x:n-o,y:r}],fill:l,stroke:s,strokeWidth:i,id:e});break;case "triangle":a.push({type:"path",points:[{x:n,y:r-o},{x:n+o,y:r+o},{x:n-o,y:r+o}],fill:l,stroke:s,strokeWidth:i,id:e});break;case "star":{let m=[];for(let u=0;u<10;u++){let c=u%2===0?o:o*.5,d=Math.PI/2*3+u*Math.PI/5;m.push({x:n+c*Math.cos(d),y:r+c*Math.sin(d)});}a.push({type:"path",points:m,fill:l,stroke:s,strokeWidth:i,id:e});break}case "arrow":a.push({type:"path",points:[{x:n-o,y:r+o},{x:n,y:r-o},{x:n+o,y:r+o}],stroke:s,strokeWidth:i,fill:"none",id:e});break;case "plus":a.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:s,strokeWidth:i,id:e},{type:"line",x1:n,y1:r-o,x2:n,y2:r+o,stroke:s,strokeWidth:i,id:e});break;case "triangle-down":a.push({type:"path",points:[{x:n,y:r+o},{x:n+o,y:r-o},{x:n-o,y:r-o}],fill:l,stroke:s,strokeWidth:i,id:e});break;case "hexagon":{let m=[];for(let u=0;u<6;u++){let c=u*(Math.PI/3);m.push({x:n+o*Math.cos(c),y:r+o*Math.sin(c)});}a.push({type:"path",points:m,fill:l,stroke:s,strokeWidth:i,id:e});break}case "hourglass":a.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}],fill:l,stroke:s,strokeWidth:i,id:e});break;case "line-horizontal":a.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:s,strokeWidth:i,id:e});break;default:a.push({type:"circle",cx:n,cy:r,r:o,fill:l,stroke:s,strokeWidth:i,id:e});}}var D=12,V=8,X=20,_e=11,Z=18,U=a=>a.length*_e*.6;function $e(a,e="vertical"){if(e==="horizontal"){let n=0;for(let r of a)n+=D+V+U(r.name)+Z;return {width:Math.max(0,n-Z),height:X}}let t=0;for(let n of a)t=Math.max(t,U(n.name));return {width:D+V+t,height:a.length*X}}function Fe(a){let{items:e,x:t,y:n,orientation:r="vertical"}=a,o=[],s=t;return e.forEach((l,i)=>{let m=r==="horizontal"?s:t,u=r==="horizontal"?n:n+i*X;o.push({type:"rect",x:m,y:u,w:D,h:D,fill:l.color,stroke:h.legendStroke,strokeWidth:1},{type:"text",content:l.name,x:m+D+V,y:u+D-2,fontSize:h.legendFont,fill:h.legendText}),r==="horizontal"&&(s+=D+V+U(l.name)+Z);}),{type:"group",cssClass:"chart-legend",commands:o}}function Pe(a){let{xTicks:e,yTicks:t,xRange:n,yRange:r,stroke:o=h.gridStroke,strokeWidth:s=h.gridStrokeWidth,dashed:l=false,opacity:i=h.gridOpacity}=a,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:s,dashed:l,opacity:i});if(e)for(let u of e)m.push({type:"line",x1:u,y1:r[0],x2:u,y2:r[1],stroke:o,strokeWidth:s,dashed:l,opacity:i});return m}var pe=new Map;function We(a,e){return `${a}|${JSON.stringify(e??{})}`}function A(a,e){let t=We(a,e),n=pe.get(t);return n||(n=new Intl.DateTimeFormat(a,e),pe.set(t,n)),n}var M=class{#e;#t;constructor(e){this.#e=[...e.domain],this.#t=[...e.range];}map(e){let t=Number(e),[n,r]=this.#e,[o,s]=this.#t;return r===n?o:o+(t-n)/(r-n)*(s-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]}},k=[{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}],R=class{#e;#t;constructor(e){this.#e=new M({domain:e.domain,range:e.range}),this.#t=e.locale||(typeof navigator<"u"?navigator.language:"en-US");}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 locale(){return this.#t}tickInterval(e,t=3,n=12){let[r,o]=this.#e.domain(),s=o-r;if(s<=0)return {interval:k[0].ms};let l=s/e,i=k[0].ms;for(let c of k)if(c.ms>=l){i=c.ms;break}let m=i,u=Math.round(s/m);for(;u>n&&m<k[k.length-1].ms;){let c=k.findIndex(d=>d.ms===m);m=k[Math.min(c+1,k.length-1)].ms,u=Math.round(s/m);}for(;u<t&&m>k[0].ms;){let c=k.findIndex(d=>d.ms===m);m=k[Math.max(c-1,0)].ms,u=Math.round(s/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,s]=this.#e.domain(),l=[],i=Math.ceil(o/r)*r;for(let m=i;m<=s;m+=r)l.push(m);return l}format(e,t){return A(this.#t,t).format(new Date(e))}},O=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(c=>String(c)===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 s=this.#r*2*Math.abs(r-n),l=Math.abs(r-n)-s,i=r>=n?1:-1,m=l/o;return n+this.#r*Math.abs(r-n)*i+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]),s=Math.abs(e-o);s<n&&(n=s,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 Ae(a){return a==="dotted"?{dash:"dotted"}:a==="dashed"?{dash:"dashed"}:{}}function Re(a){let{thresholds:e,valueScale:t,xRange:n}=a,[r,o]=n,[s,l]=t.range(),i=Math.min(s,l),m=Math.max(s,l),u=[],c=[];for(let d of e){let p=d.color??h.thresholdColor,f=t.map(d.value);d.fill==="above"?u.push({type:"rect",x:r,y:i,w:o-r,h:Math.max(0,f-i),fill:p,hatch:d.fillHatch,opacity:d.fillOpacity??.12,id:d.id?`${d.id}-fill`:void 0}):d.fill==="below"&&u.push({type:"rect",x:r,y:f,w:o-r,h:Math.max(0,m-f),fill:p,hatch:d.fillHatch,opacity:d.fillOpacity??.12,id:d.id?`${d.id}-fill`:void 0});let g=d.line??h.thresholdLine;if(g!=="none"){let b=Ae(g),y={type:"line",x1:r,y1:f,x2:o,y2:f,stroke:p,strokeWidth:1,...b,id:d.id?`${d.id}-line`:void 0};d.shadowColor&&(y.shadowColor=d.shadowColor,y.shadowBlur=d.shadowBlur??4,y.shadowOffsetX=d.shadowOffsetX??0,y.shadowOffsetY=d.shadowOffsetY??2),u.push(y);}if(d.label!==void 0&&d.label!==null&&d.label!==false){let b=typeof d.label=="object"?d.label:void 0,y=typeof d.label=="string"?d.label:b?.text??d.name,x=b?.position??"right";c.push({...Ie(y,x,r,o,f,p,b),id:d.id?`${d.id}-label`:void 0});}}return {inside:u,labels:c}}function Oe(a){let e=Re(a);return [...e.inside,...e.labels]}function Ie(a,e,t,n,r,o,s){let l=(t+n)/2,i={type:"text",content:a,fontSize:h.thresholdFontSize,fill:o},m=s?{...s.rotate!==void 0&&{rotate:s.rotate},...s.textBaseline!==void 0&&{textBaseline:s.textBaseline}}:{};switch(e){case "left":return {...i,...m,x:t+4,y:r-4,anchor:"start"};case "above":return {...i,...m,x:l,y:r-6,anchor:"middle"};case "below":return {...i,...m,x:l,y:r+14,anchor:"middle"};case "center":return {...i,...m,x:l,y:r-4,anchor:"middle"};case "outside-left":return {...i,...m,x:t-6,y:r+3,anchor:"end",textBaseline:m.textBaseline??"middle"};case "outside-right":return {...i,...m,x:n+6,y:r+3,anchor:"start",textBaseline:m.textBaseline??"middle"};default:return {...i,...m,x:n-4,y:r-4,anchor:"end"}}}function je(a){let{gaps:e,timeScale:t,yRange:n,fill:r=h.gapFill,hatch:o,fillOpacity:s=h.gapFillOpacity??.15,stroke:l=h.gapStroke,strokeWidth:i=h.gapStrokeWidth,dashed:m=true,fontSize:u=h.gapFontSize,fontFill:c=h.gapFontColor,labelBaseline:d="middle",labelRotate:p}=a,[f,g]=n,b=[];for(let y of e){let x=t.map(y.startTime),C=t.map(y.endTime),L=y.fill??r,P=y.hatch??o,me=y.fillOpacity??s,ue=y.label??"",Se=y.rotate??p,E=y.labelBaseline??d;if(y.style==="dashed_border"||!y.style?b.push({type:"rect",x,y:f,w:C-x,h:g-f,fill:L,hatch:P,opacity:me,stroke:l,strokeWidth:i,dashed:m}):y.style==="empty"&&b.push({type:"rect",x,y:f,w:C-x,h:g-f,fill:L,hatch:P,opacity:me}),ue){let ke=Be(f,g,E),ve=E==="above"?"top":E==="below"?"bottom":"middle";b.push({type:"text",content:ue,x:(x+C)/2,y:ke,anchor:"middle",fontSize:u,fill:c,textBaseline:ve,rotate:Se});}}return b}function Be(a,e,t){switch(t){case "above":return a-12;case "below":return e+4;default:return (a+e)/2}}function He(a){let{markers:e,timeScale:t,valueScale:n,yRange:r=[0,300]}=a,[o,s]=r,l=[];for(let i of e){let m=t.map(i.time),u=i.color??h.markerColor,c=i.pointStyle??(i.value!==void 0?"circle":"none"),d=i.lineStyle??"full";if(i.value!==void 0){let p=n.map(i.value);if(d==="to-value"?l.push({type:"line",x1:m,y1:s,x2:m,y2:p,stroke:u,strokeWidth:1,dashed:true}):d==="to-top"?l.push({type:"line",x1:m,y1:o,x2:m,y2:p,stroke:u,strokeWidth:1,dashed:true}):d==="full"&&l.push({type:"line",x1:m,y1:o,x2:m,y2:s,stroke:u,strokeWidth:1}),c!=="none"&&Y(l,void 0,c,m,p,h.markerSize,u,u,1.5),i.label){let f=d==="to-value"?p-10:o-6;l.push({type:"text",content:i.label,x:m,y:f,anchor:"middle",fontSize:11,fill:u});}}else d!=="none"&&l.push({type:"line",x1:m,y1:o,x2:m,y2:s,stroke:u,strokeWidth:1}),i.label&&l.push({type:"text",content:i.label,x:m,y:o-6,anchor:"middle",fontSize:11,fill:u});}return l}function Ne(a){let{highlights:e,timeScale:t,yRange:n,height:r}=a,[o,s]=n,l=[];for(let i of e){let m=t.map(i.startTime),u=t.map(i.endTime);l.push({type:"rect",x:m,y:o,w:u-m,h:s-o,fill:i.color??h.highlightColor,opacity:i.opacity??h.highlightOpacity}),i.label&&l.push({type:"text",content:i.label,x:(m+u)/2,y:Ve(i.labelPosition??"top",o,s,r),anchor:"middle",fontSize:h.annotationFontSize,fill:i.color??h.highlightLabelColor,rotate:i.rotate});}return l}function Ve(a,e,t,n){switch(a){case "above":return e-5;case "below":return n!==void 0?n-5:t+14;case "center":return (e+t)/2+4;case "bottom":return t-6;default:return e+14}}function q(a){return a&&a.toString().normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"unnamed"}function Ee(a){let{annotations:e,timeScale:t,valueScales:n}=a,r=[],o=s=>{let l=n.get(s.axis??0)??n.values().next().value;return {x:t.map(s.time),y:l?l.map(s.value):0}};for(let s of e){let l=[],i=m=>l.push(m);switch(s.type){case "line":{let m=o(s.from),u=o(s.to);i({type:"line",x1:m.x,y1:m.y,x2:u.x,y2:u.y,stroke:s.color??h.annotationColor,strokeWidth:s.width??h.annotationWidth,dash:s.dash});break}case "arrow":{let m=o(s.from),u=o(s.to),c=s.color??h.annotationColor,d=s.headSize??h.annotationHead;i({type:"line",x1:m.x,y1:m.y,x2:u.x,y2:u.y,stroke:c,strokeWidth:s.width??h.annotationWidth});let p=Math.hypot(u.x-m.x,u.y-m.y)||1,f=(u.x-m.x)/p,g=(u.y-m.y)/p,b=u.x-f*d,y=u.y-g*d;i({type:"path",points:[{x:u.x,y:u.y},{x:b-g*d*.5,y:y+f*d*.5},{x:b+g*d*.5,y:y-f*d*.5}],fill:c,stroke:"none"});break}case "rect":{let m=o(s.from),u=o(s.to);i({type:"rect",x:Math.min(m.x,u.x),y:Math.min(m.y,u.y),w:Math.abs(u.x-m.x),h:Math.abs(u.y-m.y),fill:s.fill??"none",stroke:s.stroke,opacity:s.opacity});break}case "point":{let m=o(s.at),u=s.color??"#334155",c=s.radius??h.annotationRadius,d=s.shape??"circle";d==="circle"?i({type:"circle",cx:m.x,cy:m.y,r:c,fill:u}):d==="square"?i({type:"rect",x:m.x-c,y:m.y-c,w:c*2,h:c*2,fill:u}):(i({type:"line",x1:m.x-c,y1:m.y-c,x2:m.x+c,y2:m.y+c,stroke:u,strokeWidth:1.5}),i({type:"line",x1:m.x-c,y1:m.y+c,x2:m.x+c,y2:m.y-c,stroke:u,strokeWidth:1.5}));break}case "label":{let m=o(s.at);i({type:"text",content:s.text,x:m.x+(s.dx??0),y:m.y+(s.dy??0),anchor:s.anchor??"middle",fontSize:h.annotationFontSize,fill:s.color??h.annotationColor,rotate:s.rotate});break}}if(s.id&&l.length>0){let m=q(s.id);r.push({type:"group",cssClass:`annotation annotation--${m}`,commands:l});}else r.push(...l);}return r}var K=class a{_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 a({width:e,height:t,margin:{top:20,right:20,bottom:40,left:60}})}};var J=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 h=new Proxy({},{get:(a,e)=>T()[e],has:(a,e)=>e in T(),ownKeys:()=>Reflect.ownKeys(T()),getOwnPropertyDescriptor:(a,e)=>Reflect.getOwnPropertyDescriptor(T(),e)});function H(a){return {id:a.id,line:{stroke:a.stroke??h.stroke,strokeWidth:a.strokeWidth??h.strokeWidth,smoothing:a.smoothing??false,dashed:a.dashed??false},fill:a.fill??h.areaFillAlpha,markers:{type:a.pointStyle??"none",size:a.pointSize??h.pointSize,stroke:a.stroke??h.stroke,fill:"#ffffff"},shadow:{color:a.shadowColor??"transparent",blur:a.shadowBlur??0,offsetX:a.shadowOffsetX??0,offsetY:a.shadowOffsetY??0}}}function w(a,e,t){let n=[],r=a.reduce((s,l)=>s+l.data.length,0),o=H(t);for(let s=0;s<a.length;s++){let l=a[s];l.data.length>=2?n.push({type:"path",id:t.id?`${t.id}-line-${s}`:void 0,points:l.data.map(i=>({x:e.timeScale.map(i.time),y:e.valueScale.map(i.value)})),stroke:l.color??o.line.stroke,strokeWidth:o.line.strokeWidth,smoothing:o.line.smoothing,dashed:o.line.dashed,shadowColor:o.shadow.color,shadowBlur:o.shadow.blur,shadowOffsetX:o.shadow.offsetX,shadowOffsetY:o.shadow.offsetY,fill:"none"}):l.data.length===1&&r===1&&n.push({type:"circle",cx:e.timeScale.map(l.data[0].time),cy:e.valueScale.map(l.data[0].value),r:Math.max(o.markers.size,o.line.strokeWidth),fill:l.color??o.line.stroke,shadowColor:o.shadow.color,shadowBlur:o.shadow.blur});}return n}function pe(a){let e=[];for(let t of a)e.length===0?e.push(t):e.push({x:t.x,y:e[e.length-1].y},t);return e}function De(a){let e=[];for(let t of a)e.length>0&&e.push({...t,value:e[e.length-1].value}),e.push(t);return e}function G(a,e,t){let n=[],r=H(t);for(let o=0;o<a.length;o++){let s=a[o];if(s.data.length<2)continue;let l=pe(s.data.map(i=>({x:e.timeScale.map(i.time),y:e.valueScale.map(i.value)})));n.push({type:"path",id:t.id?`${t.id}-line-${o}`:void 0,points:l,stroke:s.color??r.line.stroke,strokeWidth:r.line.strokeWidth,smoothing:false,fill:"none"});}return n}function Me(a,e,t,n,r){let o=[],s=H(t);for(let l=0;l<a.length;l++){let i=a[l];if(i.data.length<2)continue;let m=i.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(n(c))})),u=i.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(r(c))})).reverse();o.push({type:"path",id:t.id?`${t.id}-fill-${l}`:void 0,points:[...m,...u],fill:i.color??s.fill,hatch:t.hatch,stroke:"none"});}return o}function N(a,e,t,n){if(a.length<2)return [];let r=S.splitByBoundaries(a,t.boundaries,t.getValue,t.interpolate),o=[];for(let s=0;s<r.length;s++){let l=r[s];if(l.data.length<2)continue;let i=t.getColor(l.zoneIndex);if(!i)continue;let m=l.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(t.yLow(c))})),u=l.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(t.yHigh(c))})).reverse();o.push({type:"path",id:n?.id?`${n.id}-fill-${s}`:void 0,points:[...m,...u],fill:i,hatch:t.getHatch?.(l.zoneIndex),stroke:"none"});}return o}function _e(a,e,t,n){let r=S.splitByThreshold(a,e,s=>s.value,S.interpolateDataPoint),o=[];return n.below&&o.push(...w(r.below.map(s=>({data:s})),t,n.below)),n.above&&o.push(...w(r.above.map(s=>({data:s})),t,n.above)),o}function W(a,e,t,n){let r=H(t);if(!r.markers.type||r.markers.type==="none")return [];let o=[];for(let s=0;s<a.length;s++){let l=a[s],i=e.timeScale.map(l.time),m=e.valueScale.map(l.value),u=n(l),c=t.pointStroke??u,d=t.pointFill??u,p=t.pointStrokeWidth??1.5,f=t.id?`${t.id}-marker-${s}`:void 0;Y(o,f,r.markers.type,i,m,r.markers.size,c,d,p);}return o}function Y(a,e,t,n,r,o,s,l,i){switch(t){case "circle":a.push({type:"circle",cx:n,cy:r,r:o,fill:l,stroke:s,strokeWidth:i,id:e});break;case "square":a.push({type:"rect",x:n-o,y:r-o,w:o*2,h:o*2,fill:l,stroke:s,strokeWidth:i,id:e});break;case "cross":a.push({type:"line",x1:n-o,y1:r-o,x2:n+o,y2:r+o,stroke:s,strokeWidth:i,id:e},{type:"line",x1:n-o,y1:r+o,x2:n+o,y2:r-o,stroke:s,strokeWidth:i,id:e});break;case "diamond":a.push({type:"path",points:[{x:n,y:r-o},{x:n+o,y:r},{x:n,y:r+o},{x:n-o,y:r}],fill:l,stroke:s,strokeWidth:i,id:e});break;case "triangle":a.push({type:"path",points:[{x:n,y:r-o},{x:n+o,y:r+o},{x:n-o,y:r+o}],fill:l,stroke:s,strokeWidth:i,id:e});break;case "star":{let m=[];for(let u=0;u<10;u++){let c=u%2===0?o:o*.5,d=Math.PI/2*3+u*Math.PI/5;m.push({x:n+c*Math.cos(d),y:r+c*Math.sin(d)});}a.push({type:"path",points:m,fill:l,stroke:s,strokeWidth:i,id:e});break}case "arrow":a.push({type:"path",points:[{x:n-o,y:r+o},{x:n,y:r-o},{x:n+o,y:r+o}],stroke:s,strokeWidth:i,fill:"none",id:e});break;case "plus":a.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:s,strokeWidth:i,id:e},{type:"line",x1:n,y1:r-o,x2:n,y2:r+o,stroke:s,strokeWidth:i,id:e});break;case "triangle-down":a.push({type:"path",points:[{x:n,y:r+o},{x:n+o,y:r-o},{x:n-o,y:r-o}],fill:l,stroke:s,strokeWidth:i,id:e});break;case "hexagon":{let m=[];for(let u=0;u<6;u++){let c=u*(Math.PI/3);m.push({x:n+o*Math.cos(c),y:r+o*Math.sin(c)});}a.push({type:"path",points:m,fill:l,stroke:s,strokeWidth:i,id:e});break}case "hourglass":a.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}],fill:l,stroke:s,strokeWidth:i,id:e});break;case "line-horizontal":a.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:s,strokeWidth:i,id:e});break;default:a.push({type:"circle",cx:n,cy:r,r:o,fill:l,stroke:s,strokeWidth:i,id:e});}}var D=12,V=8,X=20,$e=11,Z=18,U=a=>a.length*$e*.6;function Fe(a,e="vertical"){if(e==="horizontal"){let n=0;for(let r of a)n+=D+V+U(r.name)+Z;return {width:Math.max(0,n-Z),height:X}}let t=0;for(let n of a)t=Math.max(t,U(n.name));return {width:D+V+t,height:a.length*X}}function Pe(a){let{items:e,x:t,y:n,orientation:r="vertical"}=a,o=[],s=t;return e.forEach((l,i)=>{let m=r==="horizontal"?s:t,u=r==="horizontal"?n:n+i*X;o.push({type:"rect",x:m,y:u,w:D,h:D,fill:l.color,stroke:h.legendStroke,strokeWidth:1},{type:"text",content:l.name,x:m+D+V,y:u+D-2,fontSize:h.legendFont,fill:h.legendText}),r==="horizontal"&&(s+=D+V+U(l.name)+Z);}),{type:"group",cssClass:"chart-legend",commands:o}}function We(a){let{xTicks:e,yTicks:t,xRange:n,yRange:r,stroke:o=h.gridStroke,strokeWidth:s=h.gridStrokeWidth,dashed:l=false,opacity:i=h.gridOpacity}=a,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:s,dashed:l,opacity:i});if(e)for(let u of e)m.push({type:"line",x1:u,y1:r[0],x2:u,y2:r[1],stroke:o,strokeWidth:s,dashed:l,opacity:i});return m}var fe=new Map;function Ae(a,e){return `${a}|${JSON.stringify(e??{})}`}function A(a,e){let t=Ae(a,e),n=fe.get(t);return n||(n=new Intl.DateTimeFormat(a,e),fe.set(t,n)),n}var M=class{#e;#t;constructor(e){this.#e=[...e.domain],this.#t=[...e.range];}map(e){let t=Number(e),[n,r]=this.#e,[o,s]=this.#t;return r===n?o:o+(t-n)/(r-n)*(s-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]}},k=[{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}],R=class{#e;#t;constructor(e){this.#e=new M({domain:e.domain,range:e.range}),this.#t=e.locale||(typeof navigator<"u"?navigator.language:"en-US");}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 locale(){return this.#t}tickInterval(e,t=3,n=12){let[r,o]=this.#e.domain(),s=o-r;if(s<=0)return {interval:k[0].ms};let l=s/e,i=k[0].ms;for(let c of k)if(c.ms>=l){i=c.ms;break}let m=i,u=Math.round(s/m);for(;u>n&&m<k[k.length-1].ms;){let c=k.findIndex(d=>d.ms===m);m=k[Math.min(c+1,k.length-1)].ms,u=Math.round(s/m);}for(;u<t&&m>k[0].ms;){let c=k.findIndex(d=>d.ms===m);m=k[Math.max(c-1,0)].ms,u=Math.round(s/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,s]=this.#e.domain(),l=[],i=Math.ceil(o/r)*r;for(let m=i;m<=s;m+=r)l.push(m);return l}format(e,t){return A(this.#t,t).format(new Date(e))}},O=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(c=>String(c)===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 s=this.#r*2*Math.abs(r-n),l=Math.abs(r-n)-s,i=r>=n?1:-1,m=l/o;return n+this.#r*Math.abs(r-n)*i+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]),s=Math.abs(e-o);s<n&&(n=s,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 Re(a){return a==="dotted"?{dash:"dotted"}:a==="dashed"?{dash:"dashed"}:{}}function Oe(a){let{thresholds:e,valueScale:t,xRange:n}=a,[r,o]=n,[s,l]=t.range(),i=Math.min(s,l),m=Math.max(s,l),u=[],c=[];for(let d of e){let p=d.color??h.thresholdColor,f=t.map(d.value);d.fill==="above"?u.push({type:"rect",x:r,y:i,w:o-r,h:Math.max(0,f-i),fill:p,hatch:d.fillHatch,opacity:d.fillOpacity??.12,id:d.id?`${d.id}-fill`:void 0}):d.fill==="below"&&u.push({type:"rect",x:r,y:f,w:o-r,h:Math.max(0,m-f),fill:p,hatch:d.fillHatch,opacity:d.fillOpacity??.12,id:d.id?`${d.id}-fill`:void 0});let g=d.line??h.thresholdLine;if(g!=="none"){let b=Re(g),y={type:"line",x1:r,y1:f,x2:o,y2:f,stroke:p,strokeWidth:1,...b,id:d.id?`${d.id}-line`:void 0};d.shadowColor&&(y.shadowColor=d.shadowColor,y.shadowBlur=d.shadowBlur??4,y.shadowOffsetX=d.shadowOffsetX??0,y.shadowOffsetY=d.shadowOffsetY??2),u.push(y);}if(d.label!==void 0&&d.label!==null&&d.label!==false){let b=typeof d.label=="object"?d.label:void 0,y=typeof d.label=="string"?d.label:b?.text??d.name,x=b?.position??"right";c.push({...je(y,x,r,o,f,p,b),id:d.id?`${d.id}-label`:void 0});}}return {inside:u,labels:c}}function Ie(a){let e=Oe(a);return [...e.inside,...e.labels]}function je(a,e,t,n,r,o,s){let l=(t+n)/2,i={type:"text",content:a,fontSize:h.thresholdFontSize,fill:o},m=s?{...s.rotate!==void 0&&{rotate:s.rotate},...s.textBaseline!==void 0&&{textBaseline:s.textBaseline}}:{};switch(e){case "left":return {...i,...m,x:t+4,y:r-4,anchor:"start"};case "above":return {...i,...m,x:l,y:r-6,anchor:"middle"};case "below":return {...i,...m,x:l,y:r+14,anchor:"middle"};case "center":return {...i,...m,x:l,y:r-4,anchor:"middle"};case "outside-left":return {...i,...m,x:t-6,y:r+3,anchor:"end",textBaseline:m.textBaseline??"middle"};case "outside-right":return {...i,...m,x:n+6,y:r+3,anchor:"start",textBaseline:m.textBaseline??"middle"};default:return {...i,...m,x:n-4,y:r-4,anchor:"end"}}}function Be(a){let{gaps:e,timeScale:t,yRange:n,fill:r=h.gapFill,hatch:o,fillOpacity:s=h.gapFillOpacity??.15,stroke:l=h.gapStroke,strokeWidth:i=h.gapStrokeWidth,dashed:m=true,fontSize:u=h.gapFontSize,fontFill:c=h.gapFontColor,labelBaseline:d="middle",labelRotate:p}=a,[f,g]=n,b=[];for(let y of e){let x=t.map(y.startTime),C=t.map(y.endTime),L=y.fill??r,P=y.hatch??o,me=y.fillOpacity??s,ue=y.label??"",ke=y.rotate??p,E=y.labelBaseline??d;if(y.style==="dashed_border"||!y.style?b.push({type:"rect",x,y:f,w:C-x,h:g-f,fill:L,hatch:P,opacity:me,stroke:l,strokeWidth:i,dashed:m}):y.style==="empty"&&b.push({type:"rect",x,y:f,w:C-x,h:g-f,fill:L,hatch:P,opacity:me}),ue){let ve=He(f,g,E),we=E==="above"?"top":E==="below"?"bottom":"middle";b.push({type:"text",content:ue,x:(x+C)/2,y:ve,anchor:"middle",fontSize:u,fill:c,textBaseline:we,rotate:ke});}}return b}function He(a,e,t){switch(t){case "above":return a-12;case "below":return e+4;default:return (a+e)/2}}function Ne(a){let{markers:e,timeScale:t,valueScale:n,yRange:r=[0,300]}=a,[o,s]=r,l=[];for(let i of e){let m=t.map(i.time),u=i.color??h.markerColor,c=i.pointStyle??(i.value!==void 0?"circle":"none"),d=i.lineStyle??"full";if(i.value!==void 0){let p=n.map(i.value);if(d==="to-value"?l.push({type:"line",x1:m,y1:s,x2:m,y2:p,stroke:u,strokeWidth:1,dashed:true}):d==="to-top"?l.push({type:"line",x1:m,y1:o,x2:m,y2:p,stroke:u,strokeWidth:1,dashed:true}):d==="full"&&l.push({type:"line",x1:m,y1:o,x2:m,y2:s,stroke:u,strokeWidth:1}),c!=="none"&&Y(l,void 0,c,m,p,h.markerSize,u,u,1.5),i.label){let f=d==="to-value"?p-10:o-6;l.push({type:"text",content:i.label,x:m,y:f,anchor:"middle",fontSize:11,fill:u});}}else d!=="none"&&l.push({type:"line",x1:m,y1:o,x2:m,y2:s,stroke:u,strokeWidth:1}),i.label&&l.push({type:"text",content:i.label,x:m,y:o-6,anchor:"middle",fontSize:11,fill:u});}return l}function Ve(a){let{highlights:e,timeScale:t,yRange:n,height:r}=a,[o,s]=n,l=[];for(let i of e){let m=t.map(i.startTime),u=t.map(i.endTime);l.push({type:"rect",x:m,y:o,w:u-m,h:s-o,fill:i.color??h.highlightColor,opacity:i.opacity??h.highlightOpacity}),i.label&&l.push({type:"text",content:i.label,x:(m+u)/2,y:Ee(i.labelPosition??"top",o,s,r),anchor:"middle",fontSize:h.annotationFontSize,fill:i.color??h.highlightLabelColor,rotate:i.rotate});}return l}function Ee(a,e,t,n){switch(a){case "above":return e-5;case "below":return n!==void 0?n-5:t+14;case "center":return (e+t)/2+4;case "bottom":return t-6;default:return e+14}}function q(a){return a&&a.toString().normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"unnamed"}function ze(a){let{annotations:e,timeScale:t,valueScales:n}=a,r=[],o=s=>{let l=n.get(s.axis??0)??n.values().next().value;return {x:t.map(s.time),y:l?l.map(s.value):0}};for(let s of e){let l=[],i=m=>l.push(m);switch(s.type){case "line":{let m=o(s.from),u=o(s.to);i({type:"line",x1:m.x,y1:m.y,x2:u.x,y2:u.y,stroke:s.color??h.annotationColor,strokeWidth:s.width??h.annotationWidth,dash:s.dash});break}case "arrow":{let m=o(s.from),u=o(s.to),c=s.color??h.annotationColor,d=s.headSize??h.annotationHead;i({type:"line",x1:m.x,y1:m.y,x2:u.x,y2:u.y,stroke:c,strokeWidth:s.width??h.annotationWidth});let p=Math.hypot(u.x-m.x,u.y-m.y)||1,f=(u.x-m.x)/p,g=(u.y-m.y)/p,b=u.x-f*d,y=u.y-g*d;i({type:"path",points:[{x:u.x,y:u.y},{x:b-g*d*.5,y:y+f*d*.5},{x:b+g*d*.5,y:y-f*d*.5}],fill:c,stroke:"none"});break}case "rect":{let m=o(s.from),u=o(s.to);i({type:"rect",x:Math.min(m.x,u.x),y:Math.min(m.y,u.y),w:Math.abs(u.x-m.x),h:Math.abs(u.y-m.y),fill:s.fill??"none",stroke:s.stroke,opacity:s.opacity});break}case "point":{let m=o(s.at),u=s.color??"#334155",c=s.radius??h.annotationRadius,d=s.shape??"circle";d==="circle"?i({type:"circle",cx:m.x,cy:m.y,r:c,fill:u}):d==="square"?i({type:"rect",x:m.x-c,y:m.y-c,w:c*2,h:c*2,fill:u}):(i({type:"line",x1:m.x-c,y1:m.y-c,x2:m.x+c,y2:m.y+c,stroke:u,strokeWidth:1.5}),i({type:"line",x1:m.x-c,y1:m.y+c,x2:m.x+c,y2:m.y-c,stroke:u,strokeWidth:1.5}));break}case "label":{let m=o(s.at);i({type:"text",content:s.text,x:m.x+(s.dx??0),y:m.y+(s.dy??0),anchor:s.anchor??"middle",fontSize:h.annotationFontSize,fill:s.color??h.annotationColor,rotate:s.rotate});break}}if(s.id&&l.length>0){let m=q(s.id);r.push({type:"group",cssClass:`annotation annotation--${m}`,commands:l});}else r.push(...l);}return r}var K=class a{_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 a({width:e,height:t,margin:{top:20,right:20,bottom:40,left:60}})}};var J=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]}};var I={axisColor:h.axisColor,tickColor:h.tickColor,textColor:h.textColor,textSize:h.textSize},j=class{#e;#t;constructor(e){this.#e=new R({domain:e.domain,range:e.xRange,locale:e.locale}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??I).axisColor}get tickColor(){return (this.#t.colors??I).tickColor}get textColor(){return (this.#t.colors??I).textColor}get textSize(){return (this.#t.colors??I).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??I,n=this.#t.y??0,r=[],[o,s]=this.#e.range();r.push({type:"line",x1:o,y1:n,x2:s,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let l of e)r.push({type:"line",x1:l.x,y1:n,x2:l.x,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),r.push({type:"text",content:l.label,x:l.x,y:n+t.textSize+6,anchor:"middle",fontSize:t.textSize,fill:t.textColor});return r}};var B={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function ze(a){return Math.abs(a)>=1e6?`${(a/1e6).toFixed(1)}M`:Math.abs(a)>=1e3?`${(a/1e3).toFixed(1)}k`:Number.isInteger(a)?String(a):a.toFixed(1)}function Ge(a){let e=new Array(a.length).fill(false),t=0;for(;t<a.length;){let n=t;for(;n+1<a.length&&a[n+1].label===a[t].label;)n++;for(let r=t+1;r<n;r++)e[r]=true;t=n+1;}return e}var Q=class{#e;#t;constructor(e){this.#e=new M({domain:e.domain,range:e.range}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??B).axisColor}get tickColor(){return (this.#t.colors??B).tickColor}get textColor(){return (this.#t.colors??B).textColor}get textSize(){return (this.#t.colors??B).textSize}generateTicks(){let e=this.#t.format??ze,t=this.#t.ticks&&this.#t.ticks>0?this.#t.ticks:6,[n,r]=this.#e.domain(),o=Math.min(n,r),s=Math.max(n,r),l=s-o;if(l===0)return [{value:n,position:this.#e.map(n),label:e(n)}];let i=l/t,m=Math.pow(10,Math.floor(Math.log10(i))),u=i/m,c;if(u<=1.5?c=m:u<=3?c=2*m:u<=7?c=5*m:c=10*m,c<=0||!Number.isFinite(c))return [{value:n,position:this.#e.map(n),label:e(n)}];let d=[],p=Math.ceil(o/c)*c;for(let f=p;f<=s;f+=c)d.push({value:f,position:this.#e.map(f),label:e(f)});return d}render(){let e=this.generateTicks(),t=this.#t.colors??B,n=this.#t.x??0,r=this.#t.orientation??"vertical",o=this.#t.position??"left",s=this.#t.suppressLabelsNear??[],l=this.#t.suppressTolerancePx??8,i=u=>s.some(c=>Math.abs(c-u)<=l),m=[];if(r==="vertical"){let[u,c]=this.#e.range();m.push({type:"line",x1:n,y1:u,x2:n,y2:c,stroke:t.axisColor,strokeWidth:t.axisWidth});let d=Ge(e);e.forEach((p,f)=>{let g=i(p.position),b=d[f]?{opacity:0}:{};o==="left"?(m.push({type:"line",x1:n-4,y1:p.position,x2:n,y2:p.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),g||m.push({type:"text",content:p.label,x:n-8,y:p.position+4,anchor:"end",fontSize:11,fill:t.textColor,...b})):(m.push({type:"line",x1:n,y1:p.position,x2:n+4,y2:p.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),g||m.push({type:"text",content:p.label,x:n+8,y:p.position+4,anchor:"start",fontSize:11,fill:t.textColor,...b}));});}else {let[u,c]=this.#e.range();m.push({type:"line",x1:u,y1:n,x2:c,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let d of e)m.push({type:"line",x1:d.position,y1:n,x2:d.position,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),m.push({type:"text",content:d.label,x:d.position,y:n+18,anchor:"middle",fontSize:t.textSize,fill:t.textColor});}return m}};var ee=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 O({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((s,l)=>{let i=Number(s),m=t?e[i]??String(i):String(i),u=this.#e.map(i),c=n?h.palette[l%h.palette.length]:void 0;return {value:i,label:m,y:u,color:c,isGap:o.has(i)}})}colorFor(e){let t=this.#t.indexOf(String(e));if(!(t===-1||!(this.#n.autoColor??true)))return h.palette[t%h.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:11,fill:r.color??h.textColor});return n}map(e){return this.#e.map(e)}isGap(e){return new Set(this.#n.gapValues??[]).has(e)}};var v=class a{#e;#t;static uidcnt=0;#n;constructor(e,t=[]){this.#e=e.id??"series-"+ ++a.uidcnt,this.#t=e.timeScale,this.#n=t;}get id(){return this.#e}get timeScale(){return this.#t}get data(){return this.#n}};var te=class extends v{#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,stroke:e.stroke??h.stroke,strokeWidth:e.strokeWidth??h.strokeWidth,dashed:e.dashed??false,pointStyle:e.pointStyle??"none",pointSize:e.pointSize??h.pointSize,shadowColor:e.shadowColor,shadowBlur:e.shadowBlur,shadowOffsetX:e.shadowOffsetX,shadowOffsetY:e.shadowOffsetY},n=e.pointThreshold??h.pointThreshold,r=e.gapThreshold??h.gapThreshold,o=e.id,s=S.getRuns(this.data,c=>c.value===null,r),l=s.reduce((c,d)=>c+d.length,0);if(l===0)return [];let i={timeScale:this.timeScale,valueScale:e.valueScale},m=s.map(c=>({data:c})),u=[];if(u.push(...w(m,i,{...t,id:o?`${o}-line`:void 0})),t.pointStyle&&t.pointStyle!=="none"&&l<=n)for(let c of s)u.push(...W(c,i,{...t,id:o?`${o}-marker`:void 0},()=>t.stroke));return u}};var ne=class extends v{#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),s=e.map(t[r].value);r===0?n.push({x:o,y:s}):n.push({x:o,y:n[n.length-1].y},{x:o,y:s});}return n}render(){let e=S.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 G(n,t,{stroke:this.#e.stroke??h.stroke,strokeWidth:this.#e.strokeWidth??h.strokeWidth,id:this.id?`${this.id}-line`:void 0})}};var re=class extends v{#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??h.bandFill,n=e.hatch,r=e.avgLine??false,o=e.avgLineColor??h.bandAvgLine,s=e.bandWidth??10,l=[];for(let i of this.data){if(i.min===null||i.max===null)continue;let m=this.timeScale.map(i.time),u=e.valueScale.map(i.max),c=e.valueScale.map(i.min),d=s,p=this.data.indexOf(i);if(l.push({type:"rect",x:m-d/2,y:u,w:d,h:c-u,fill:t,hatch:n,opacity:this.opacity(i.count),id:this.id?`${this.id}-slot-${p}`:void 0}),r&&i.avg!==null){let f=e.valueScale.map(i.avg);l.push({type:"line",x1:m-d/2,y1:f,x2:m+d/2,y2:f,stroke:o,strokeWidth:1,id:this.id?`${this.id}-avg-${p}`:void 0});}}return l}};var oe=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}render(){let e=this.#e,t=e.minColor??h.minColor,n=e.maxColor??h.maxColor,r=e.avgColor??h.avgColor,o=e.avgDashed??true,s=e.smoothing??false,l=e.strokeWidth??h.strokeWidth,i=S.getRuns(this.data,p=>p.min===null||p.max===null||p.avg===null);if(i.length===0)return [];let m={timeScale:this.timeScale,valueScale:e.valueScale},u=[];i.forEach((p,f)=>{p.length<2||(e.fillToMax&&u.push(...N(p,m,{boundaries:[],yLow:g=>g.avg,yHigh:g=>g.max,getValue:g=>g.avg,interpolate:S.interpolateAggregatedPoint,getColor:()=>e.fillToMax,getHatch:()=>e.fillToMaxHatch},{id:this.id?`${this.id}-fillToMax-${f}`:void 0})),e.fillToMin&&u.push(...N(p,m,{boundaries:[],yLow:g=>g.avg,yHigh:g=>g.min,getValue:g=>g.avg,interpolate:S.interpolateAggregatedPoint,getColor:()=>e.fillToMin,getHatch:()=>e.fillToMinHatch},{id:this.id?`${this.id}-fillToMin-${f}`:void 0})));});let c=i.filter(p=>p.length>=2),d=p=>c.map(f=>({data:f.map(g=>({time:g.time,value:p(g)}))}));return u.push(...w(d(p=>p.max),m,{stroke:n,strokeWidth:l,smoothing:s,id:this.id?`${this.id}-max`:void 0}),...w(d(p=>p.min),m,{stroke:t,strokeWidth:l,smoothing:s,id:this.id?`${this.id}-min`:void 0}),...w(d(p=>p.avg),m,{stroke:r,strokeWidth:l,smoothing:s,dashed:o,id:this.id?`${this.id}-avg`:void 0})),u}};var ie=class extends v{#e;#t;constructor(e){super(e,e.data),this.#e=e,this.#t=[...e.zones??[]].sort((t,n)=>t.value-n.value);}#n(e){return e===0?this.#e.baseColor??h.stroke:this.#t[e-1].color}render(){let e=this.#e,t=e.baseColor??h.stroke,n={stroke:t,strokeWidth:e.strokeWidth??h.strokeWidth,smoothing:e.smoothing??false,pointStyle:e.pointStyle??"none",pointSize:e.pointSize??h.pointSize},r=e.gapThreshold??h.gapThreshold,o=e.pointThreshold??h.pointThreshold,s=S.getRuns(this.data,u=>u.value===null,r),l=s.reduce((u,c)=>u+c.length,0);if(l===0)return [];let i={timeScale:this.timeScale,valueScale:e.valueScale},m=[];for(let u of s){if(u.length<2)continue;if(e.fill){let f=e.fill.value,g=S.splitByBoundaries(u,[f],y=>y.value,S.interpolateDataPoint),b=e.valueScale.map(f);for(let y=0;y<g.length;y++){let x=g[y];if(x.data.length<2)continue;let C=x.zoneIndex>0;if(e.fill.side==="above"===C){let L=x.data.map(P=>({x:this.timeScale.map(P.time),y:e.valueScale.map(P.value)}));m.push({type:"path",id:this.id?`${this.id}-fill-${y}`:void 0,points:[...L,{x:L[L.length-1].x,y:b},{x:L[0].x,y:b}],fill:e.fill.color,hatch:e.fill.hatch,stroke:"none"});}}}let c=this.#t.map(f=>f.value),p=S.splitByBoundaries(u,c,f=>f.value,S.interpolateDataPoint).map(f=>({data:f.data,color:this.#n(f.zoneIndex)}));m.push(...w(p,i,{...n,id:this.id?`${this.id}-line`:void 0})),n.pointStyle&&n.pointStyle!=="none"&&l<=o&&m.push(...W(u,i,{...n,id:this.id?`${this.id}-marker`:void 0},f=>{let g=t;for(let b of this.#t)f.value>=b.value&&(g=b.color);return g}));}return m}};var Ye=1,ae=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:s,y:l,height:i}=this.#e,m=[];n&&m.push({type:"rect",x:s[0],y:l,w:s[1]-s[0],h:i,fill:n,opacity:.04,stroke:"#ddd",strokeWidth:.25});for(let u of e){let c=t.map(u.startTime),d=t.map(u.endTime);if(d<s[0]||c>s[1])continue;let p=Math.max(s[0],Math.min(s[1],c)),f=Math.max(s[0],Math.min(s[1],d)),g=Math.max(f-p,Ye);p+g>s[1]&&(p=Math.max(s[0],s[1]-g));let b=p+g/2;if(m.push({type:"rect",x:p,y:l,w:g,h:i,hatch:u.hatch??r,fill:u.fill??"#6b728044",stroke:u.stroke,strokeWidth:u.strokeWidth??0,title:u.title}),u.label){let y=u.labelFontSize??10;m.push({type:"text",content:u.label,x:b,y:this.#t(u.labelBaseline,y),anchor:"middle",fontSize:y,fill:u.labelFill??"#333"});}}if(o){let u=new j({domain:t.domain(),xRange:s,y:l+i+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 se=class{#e;constructor(e){this.#e=e;}render(){let{data:e,valueScale:t,xRange:n,showMin:r=false,showMax:o=false,showAvg:s=true,showMedian:l=false,labelPosition:i="end",lineColor:m=h.statsLineColor,labelColor:u=h.statsLabelColor}=this.#e,c=ce.compute(e),d=[{name:"min",value:c.min,enabled:r},{name:"max",value:c.max,enabled:o},{name:"avg",value:c.avg,enabled:s},{name:"median",value:c.median,enabled:l}],p=[],[f,g]=n;for(let b of d.filter(y=>y.enabled)){let y=t.map(b.value);p.push({type:"line",x1:f,y1:y,x2:g,y2:y,stroke:m,strokeWidth:1});let x=`${b.name}: ${b.value.toFixed(1)}`;(i==="start"||i==="both")&&p.push({type:"text",content:x,x:f+4,y:y-4,anchor:"start",fontSize:10,fill:u}),(i==="end"||i==="both")&&p.push({type:"text",content:x,x:g-4,y:y-4,anchor:"end",fontSize:10,fill:u}),i==="center"&&p.push({type:"text",content:x,x:(f+g)/2,y:y-4,anchor:"middle",fontSize:10,fill:u});}return p}};var _=class{#e;#t;#n;constructor(e){this.#e=e?.locale||(typeof navigator<"u"?navigator.language:"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 A(this.#e,r).format(new Date(e))}catch{for(let r of this.#t)try{return A(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,s=36e5,l=6e4,i={};return r<l?(i.second="2-digit",i.minute="2-digit",i.hour="2-digit"):r<s?(i.minute="2-digit",i.hour="2-digit"):r<o?(i.hour="2-digit",i.minute="2-digit"):r<7*o?(i.weekday="short",i.day="numeric"):r<365*o?(i.month="short",i.day="numeric"):(i.month="short",i.year="numeric"),{...n,...i}}};var $=class a{#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 a({unit:e,decimals:t})}static temperature(e="\xB0C"){return new a({unit:e,decimals:1})}static percentage(){return new a({unit:"%",decimals:0})}};var F=class a{#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 a({map:n,showValue:t})}};var Xe={time:new _,value:new $,enum:new F};function le(a,e){let t=T();return {color:a.color??t.stroke,width:a.width??t.strokeWidth,style:a.style??"solid",smoothing:a.smoothing??false,shape:a.shape??(e.seriesType==="step"?"step":"line"),gapThreshold:a.gapThreshold??t.gapThreshold,opacity:a.opacity??1}}function fe(a){let e=a.style?.line;return e===false?[]:e===void 0?[le({},a)]:Array.isArray(e)?e.map(t=>le(t,a)):[le(e,a)]}function ge(a){let e=a.style?.markers;if(!e?.type||e.type==="none")return;let t=T(),r=(a.style?.line&&!Array.isArray(a.style.line)?a.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 ye(a){let e=a.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 be(a){return a.style?.gap}function xe(a){return a.style?.fill}function Ze(a){return {lines:fe(a),fill:xe(a),markers:ge(a),shadow:ye(a),gap:be(a),id:a.style?.id??a.id}}/*!
27
+ </clipPath>`}get regions(){return [...this.#e]}};var I={axisColor:h.axisColor,tickColor:h.tickColor,textColor:h.textColor,textSize:h.textSize},j=class{#e;#t;constructor(e){this.#e=new R({domain:e.domain,range:e.xRange,locale:e.locale}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??I).axisColor}get tickColor(){return (this.#t.colors??I).tickColor}get textColor(){return (this.#t.colors??I).textColor}get textSize(){return (this.#t.colors??I).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??I,n=this.#t.y??0,r=[],[o,s]=this.#e.range();r.push({type:"line",x1:o,y1:n,x2:s,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let l of e)r.push({type:"line",x1:l.x,y1:n,x2:l.x,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),r.push({type:"text",content:l.label,x:l.x,y:n+t.textSize+6,anchor:"middle",fontSize:t.textSize,fill:t.textColor});return r}};var B={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function Ge(a){return Math.abs(a)>=1e6?`${(a/1e6).toFixed(1)}M`:Math.abs(a)>=1e3?`${(a/1e3).toFixed(1)}k`:Number.isInteger(a)?String(a):a.toFixed(1)}function Ye(a){let e=new Array(a.length).fill(false),t=0;for(;t<a.length;){let n=t;for(;n+1<a.length&&a[n+1].label===a[t].label;)n++;for(let r=t+1;r<n;r++)e[r]=true;t=n+1;}return e}var Q=class{#e;#t;constructor(e){this.#e=new M({domain:e.domain,range:e.range}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??B).axisColor}get tickColor(){return (this.#t.colors??B).tickColor}get textColor(){return (this.#t.colors??B).textColor}get textSize(){return (this.#t.colors??B).textSize}generateTicks(){let e=this.#t.format??Ge,t=this.#t.ticks&&this.#t.ticks>0?this.#t.ticks:6,[n,r]=this.#e.domain(),o=Math.min(n,r),s=Math.max(n,r),l=s-o;if(l===0)return [{value:n,position:this.#e.map(n),label:e(n)}];let i=l/t,m=Math.pow(10,Math.floor(Math.log10(i))),u=i/m,c;if(u<=1.5?c=m:u<=3?c=2*m:u<=7?c=5*m:c=10*m,c<=0||!Number.isFinite(c))return [{value:n,position:this.#e.map(n),label:e(n)}];let d=[],p=Math.ceil(o/c)*c;for(let f=p;f<=s;f+=c)d.push({value:f,position:this.#e.map(f),label:e(f)});return d}render(){let e=this.generateTicks(),t=this.#t.colors??B,n=this.#t.x??0,r=this.#t.orientation??"vertical",o=this.#t.position??"left",s=this.#t.suppressLabelsNear??[],l=this.#t.suppressTolerancePx??8,i=u=>s.some(c=>Math.abs(c-u)<=l),m=[];if(r==="vertical"){let[u,c]=this.#e.range();m.push({type:"line",x1:n,y1:u,x2:n,y2:c,stroke:t.axisColor,strokeWidth:t.axisWidth});let d=Ye(e);e.forEach((p,f)=>{let g=i(p.position),b=d[f]?{opacity:0}:{};o==="left"?(m.push({type:"line",x1:n-4,y1:p.position,x2:n,y2:p.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),g||m.push({type:"text",content:p.label,x:n-8,y:p.position+4,anchor:"end",fontSize:11,fill:t.textColor,...b})):(m.push({type:"line",x1:n,y1:p.position,x2:n+4,y2:p.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),g||m.push({type:"text",content:p.label,x:n+8,y:p.position+4,anchor:"start",fontSize:11,fill:t.textColor,...b}));});}else {let[u,c]=this.#e.range();m.push({type:"line",x1:u,y1:n,x2:c,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let d of e)m.push({type:"line",x1:d.position,y1:n,x2:d.position,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),m.push({type:"text",content:d.label,x:d.position,y:n+18,anchor:"middle",fontSize:t.textSize,fill:t.textColor});}return m}};var ee=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 O({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((s,l)=>{let i=Number(s),m=t?e[i]??String(i):String(i),u=this.#e.map(i),c=n?h.palette[l%h.palette.length]:void 0;return {value:i,label:m,y:u,color:c,isGap:o.has(i)}})}colorFor(e){let t=this.#t.indexOf(String(e));if(!(t===-1||!(this.#n.autoColor??true)))return h.palette[t%h.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:11,fill:r.color??h.textColor});return n}map(e){return this.#e.map(e)}isGap(e){return new Set(this.#n.gapValues??[]).has(e)}};var v=class a{#e;#t;static uidcnt=0;#n;constructor(e,t=[]){this.#e=e.id??"series-"+ ++a.uidcnt,this.#t=e.timeScale,this.#n=t;}get id(){return this.#e}get timeScale(){return this.#t}get data(){return this.#n}};var te=class extends v{#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,stroke:e.stroke??h.stroke,strokeWidth:e.strokeWidth??h.strokeWidth,dashed:e.dashed??false,pointStyle:e.pointStyle??"none",pointSize:e.pointSize??h.pointSize,shadowColor:e.shadowColor,shadowBlur:e.shadowBlur,shadowOffsetX:e.shadowOffsetX,shadowOffsetY:e.shadowOffsetY},n=e.pointThreshold??h.pointThreshold,r=e.gapThreshold??h.gapThreshold,o=e.id,s=S.getRuns(this.data,c=>c.value===null,r),l=s.reduce((c,d)=>c+d.length,0);if(l===0)return [];let i={timeScale:this.timeScale,valueScale:e.valueScale},m=s.map(c=>({data:c})),u=[];if(u.push(...w(m,i,{...t,id:o?`${o}-line`:void 0})),t.pointStyle&&t.pointStyle!=="none"&&l<=n)for(let c of s)u.push(...W(c,i,{...t,id:o?`${o}-marker`:void 0},()=>t.stroke));return u}};var ne=class extends v{#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),s=e.map(t[r].value);r===0?n.push({x:o,y:s}):n.push({x:o,y:n[n.length-1].y},{x:o,y:s});}return n}render(){let e=S.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 G(n,t,{stroke:this.#e.stroke??h.stroke,strokeWidth:this.#e.strokeWidth??h.strokeWidth,id:this.id?`${this.id}-line`:void 0})}};var re=class extends v{#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??h.bandFill,n=e.hatch,r=e.avgLine??false,o=e.avgLineColor??h.bandAvgLine,s=e.bandWidth??10,l=[];for(let i of this.data){if(i.min===null||i.max===null)continue;let m=this.timeScale.map(i.time),u=e.valueScale.map(i.max),c=e.valueScale.map(i.min),d=s,p=this.data.indexOf(i);if(l.push({type:"rect",x:m-d/2,y:u,w:d,h:c-u,fill:t,hatch:n,opacity:this.opacity(i.count),id:this.id?`${this.id}-slot-${p}`:void 0}),r&&i.avg!==null){let f=e.valueScale.map(i.avg);l.push({type:"line",x1:m-d/2,y1:f,x2:m+d/2,y2:f,stroke:o,strokeWidth:1,id:this.id?`${this.id}-avg-${p}`:void 0});}}return l}};var oe=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}render(){let e=this.#e,t=e.minColor??h.minColor,n=e.maxColor??h.maxColor,r=e.avgColor??h.avgColor,o=e.avgDashed??true,s=e.smoothing??false,l=e.strokeWidth??h.strokeWidth,i=S.getRuns(this.data,p=>p.min===null||p.max===null||p.avg===null);if(i.length===0)return [];let m={timeScale:this.timeScale,valueScale:e.valueScale},u=[];i.forEach((p,f)=>{p.length<2||(e.fillToMax&&u.push(...N(p,m,{boundaries:[],yLow:g=>g.avg,yHigh:g=>g.max,getValue:g=>g.avg,interpolate:S.interpolateAggregatedPoint,getColor:()=>e.fillToMax,getHatch:()=>e.fillToMaxHatch},{id:this.id?`${this.id}-fillToMax-${f}`:void 0})),e.fillToMin&&u.push(...N(p,m,{boundaries:[],yLow:g=>g.avg,yHigh:g=>g.min,getValue:g=>g.avg,interpolate:S.interpolateAggregatedPoint,getColor:()=>e.fillToMin,getHatch:()=>e.fillToMinHatch},{id:this.id?`${this.id}-fillToMin-${f}`:void 0})));});let c=i.filter(p=>p.length>=2),d=p=>c.map(f=>({data:f.map(g=>({time:g.time,value:p(g)}))}));return u.push(...w(d(p=>p.max),m,{stroke:n,strokeWidth:l,smoothing:s,id:this.id?`${this.id}-max`:void 0}),...w(d(p=>p.min),m,{stroke:t,strokeWidth:l,smoothing:s,id:this.id?`${this.id}-min`:void 0}),...w(d(p=>p.avg),m,{stroke:r,strokeWidth:l,smoothing:s,dashed:o,id:this.id?`${this.id}-avg`:void 0})),u}};var ie=class extends v{#e;#t;constructor(e){super(e,e.data),this.#e=e,this.#t=[...e.zones??[]].sort((t,n)=>t.value-n.value);}#n(e){return e===0?this.#e.baseColor??h.stroke:this.#t[e-1].color}render(){let e=this.#e,t=e.baseColor??h.stroke,n={stroke:t,strokeWidth:e.strokeWidth??h.strokeWidth,smoothing:e.smoothing??false,pointStyle:e.pointStyle??"none",pointSize:e.pointSize??h.pointSize},r=e.gapThreshold??h.gapThreshold,o=e.pointThreshold??h.pointThreshold,s=S.getRuns(this.data,u=>u.value===null,r),l=s.reduce((u,c)=>u+c.length,0);if(l===0)return [];let i={timeScale:this.timeScale,valueScale:e.valueScale},m=[];for(let u of s){if(u.length<2)continue;if(e.fill){let f=e.fill.value,g=S.splitByBoundaries(u,[f],y=>y.value,S.interpolateDataPoint),b=e.valueScale.map(f);for(let y=0;y<g.length;y++){let x=g[y];if(x.data.length<2)continue;let C=x.zoneIndex>0;if(e.fill.side==="above"===C){let L=x.data.map(P=>({x:this.timeScale.map(P.time),y:e.valueScale.map(P.value)}));m.push({type:"path",id:this.id?`${this.id}-fill-${y}`:void 0,points:[...L,{x:L[L.length-1].x,y:b},{x:L[0].x,y:b}],fill:e.fill.color,hatch:e.fill.hatch,stroke:"none"});}}}let c=this.#t.map(f=>f.value),p=S.splitByBoundaries(u,c,f=>f.value,S.interpolateDataPoint).map(f=>({data:f.data,color:this.#n(f.zoneIndex)}));m.push(...w(p,i,{...n,id:this.id?`${this.id}-line`:void 0})),n.pointStyle&&n.pointStyle!=="none"&&l<=o&&m.push(...W(u,i,{...n,id:this.id?`${this.id}-marker`:void 0},f=>{let g=t;for(let b of this.#t)f.value>=b.value&&(g=b.color);return g}));}return m}};var Xe=1,ae=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:s,y:l,height:i}=this.#e,m=[];n&&m.push({type:"rect",x:s[0],y:l,w:s[1]-s[0],h:i,fill:n,opacity:.04,stroke:"#ddd",strokeWidth:.25});for(let u of e){let c=t.map(u.startTime),d=t.map(u.endTime);if(d<s[0]||c>s[1])continue;let p=Math.max(s[0],Math.min(s[1],c)),f=Math.max(s[0],Math.min(s[1],d)),g=Math.max(f-p,Xe);p+g>s[1]&&(p=Math.max(s[0],s[1]-g));let b=p+g/2;if(m.push({type:"rect",x:p,y:l,w:g,h:i,hatch:u.hatch??r,fill:u.fill??"#6b728044",stroke:u.stroke,strokeWidth:u.strokeWidth??0,title:u.title}),u.label){let y=u.labelFontSize??10;m.push({type:"text",content:u.label,x:b,y:this.#t(u.labelBaseline,y),anchor:"middle",fontSize:y,fill:u.labelFill??"#333"});}}if(o){let u=new j({domain:t.domain(),xRange:s,y:l+i+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 se=class{#e;constructor(e){this.#e=e;}render(){let{data:e,valueScale:t,xRange:n,showMin:r=false,showMax:o=false,showAvg:s=true,showMedian:l=false,labelPosition:i="end",lineColor:m=h.statsLineColor,labelColor:u=h.statsLabelColor}=this.#e,c=ce.compute(e),d=[{name:"min",value:c.min,enabled:r},{name:"max",value:c.max,enabled:o},{name:"avg",value:c.avg,enabled:s},{name:"median",value:c.median,enabled:l}],p=[],[f,g]=n;for(let b of d.filter(y=>y.enabled)){let y=t.map(b.value);p.push({type:"line",x1:f,y1:y,x2:g,y2:y,stroke:m,strokeWidth:1});let x=`${b.name}: ${b.value.toFixed(1)}`;(i==="start"||i==="both")&&p.push({type:"text",content:x,x:f+4,y:y-4,anchor:"start",fontSize:10,fill:u}),(i==="end"||i==="both")&&p.push({type:"text",content:x,x:g-4,y:y-4,anchor:"end",fontSize:10,fill:u}),i==="center"&&p.push({type:"text",content:x,x:(f+g)/2,y:y-4,anchor:"middle",fontSize:10,fill:u});}return p}};var _=class{#e;#t;#n;constructor(e){this.#e=e?.locale||(typeof navigator<"u"?navigator.language:"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 A(this.#e,r).format(new Date(e))}catch{for(let r of this.#t)try{return A(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,s=36e5,l=6e4,i={};return r<l?(i.second="2-digit",i.minute="2-digit",i.hour="2-digit"):r<s?(i.minute="2-digit",i.hour="2-digit"):r<o?(i.hour="2-digit",i.minute="2-digit"):r<7*o?(i.weekday="short",i.day="numeric"):r<365*o?(i.month="short",i.day="numeric"):(i.month="short",i.year="numeric"),{...n,...i}}};var $=class a{#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 a({unit:e,decimals:t})}static temperature(e="\xB0C"){return new a({unit:e,decimals:1})}static percentage(){return new a({unit:"%",decimals:0})}};var F=class a{#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 a({map:n,showValue:t})}};var Ze={time:new _,value:new $,enum:new F};function le(a,e){let t=T();return {color:a.color??t.stroke,width:a.width??t.strokeWidth,style:a.style??"solid",smoothing:a.smoothing??false,shape:a.shape??(e.seriesType==="step"?"step":"line"),gapThreshold:a.gapThreshold??t.gapThreshold,opacity:a.opacity??1}}function ge(a){let e=a.style?.line;return e===false?[]:e===void 0?[le({},a)]:Array.isArray(e)?e.map(t=>le(t,a)):[le(e,a)]}function ye(a){let e=a.style?.markers;if(!e?.type||e.type==="none")return;let t=T(),r=(a.style?.line&&!Array.isArray(a.style.line)?a.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 be(a){let e=a.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 xe(a){return a.style?.gap}function Se(a){return a.style?.fill}function Ue(a){return {lines:ge(a),fill:Se(a),markers:ye(a),shadow:be(a),gap:xe(a),id:a.style?.id??a.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 S=class{static interpolateDataPoint(a,e,t){return {time:a.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{ae as AnnotationBandSeries,O as BandScale,re as BandSeries,J as Clip,ee as EnumAxis,F as EnumFormatter,Xe as Formatters,K as Layout,te as LineSeries,M as LinearScale,oe as MinMaxAvgSeries,z as Renderer,se as StatsOverlay,ne as StepSeries,k as TIME_INTERVALS,j as TimeAxis,_ as TimeFormatter,R as TimeScale,Q as ValueAxis,$ as ValueFormatter,ie as ZonedLineSeries,he as getHatch,$e as measureLegend,Ee as renderAnnotations,De as renderArea,je as renderGaps,Pe as renderGrid,Ne as renderHighlights,Fe as renderLegend,w as renderLine,He as renderMarkers,W as renderSeriesMarkers,Me as renderSplitLine,G as renderStep,Oe as renderThresholds,N as renderZonedArea,xe as resolveFill,be as resolveGap,fe as resolveLines,ge as resolveMarkers,Ze as resolveSeriesStyle,ye as resolveShadow,q as slugify,h as theme};
46
+ */export{ae as AnnotationBandSeries,O as BandScale,re as BandSeries,J as Clip,ee as EnumAxis,F as EnumFormatter,Ze as Formatters,K as Layout,te as LineSeries,M as LinearScale,oe as MinMaxAvgSeries,z as Renderer,se as StatsOverlay,ne as StepSeries,k as TIME_INTERVALS,j as TimeAxis,_ as TimeFormatter,R as TimeScale,Q as ValueAxis,$ as ValueFormatter,ie as ZonedLineSeries,he as getHatch,Fe as measureLegend,ze as renderAnnotations,Me as renderArea,Be as renderGaps,We as renderGrid,Ve as renderHighlights,Pe as renderLegend,w as renderLine,Ne as renderMarkers,W as renderSeriesMarkers,_e as renderSplitLine,G as renderStep,Ie as renderThresholds,N as renderZonedArea,Se as resolveFill,xe as resolveGap,ge as resolveLines,ye as resolveMarkers,Ue as resolveSeriesStyle,be as resolveShadow,q as slugify,h as theme,De as toStepData,pe as toStepPoints};
@@ -341,6 +341,32 @@ declare function renderLine(segments: {
341
341
  data: DataPoint[];
342
342
  color?: string;
343
343
  }[], ctx: RenderingContext, style: SeriesStyle): DrawCommand[];
344
+ /** Render segments as step-functions. */
345
+ /**
346
+ * Punktfolge einer Treppe: vor jeden Punkt kommt die Ecke auf seiner X- und
347
+ * der vorigen Y-Hoehe. Steht hier und nicht nur in renderStep, weil
348
+ * MLTimeGraph seine Pfade selbst zusammenbaut und `style.line.shape: "step"`
349
+ * sonst wirkungslos bliebe -- so war es bis hierher.
350
+ */
351
+ declare function toStepPoints(pts: {
352
+ x: number;
353
+ y: number;
354
+ }[]): {
355
+ x: number;
356
+ y: number;
357
+ }[];
358
+ /**
359
+ * Dieselbe Treppe, aber im *Daten*raum: vor jeden Punkt kommt ein Punkt auf
360
+ * seiner Zeit und dem vorigen Wert. Erst damit wird die Stufe zu Daten, die
361
+ * jeder weitere Schritt -- Zonenteilung an einer Grenze, Flaeche unter der
362
+ * Kurve -- ohne eigenes Wissen ueber Treppen richtig behandelt.
363
+ *
364
+ * In Pixeln (toStepPoints) war die Stufe dafuer zu spaet: die Flaeche wurde
365
+ * aus den rohen Messwerten gebaut und lief als Rampe unter einer Treppe her,
366
+ * und eine Zonengrenze schnitt den senkrechten Sprung an der interpolierten
367
+ * Zeit statt am Zeitstempel des naechsten Wertes.
368
+ */
369
+ declare function toStepData(data: DataPoint[]): DataPoint[];
344
370
  declare function renderStep(segments: {
345
371
  data: DataPoint[];
346
372
  color?: string;
@@ -378,4 +404,4 @@ declare function renderMarkers(points: DataPoint[], ctx: RenderingContext, style
378
404
  declare function drawMarker(// NOSONAR
379
405
  commands: DrawCommand[], id: string | undefined, shape: Exclude<PointStyleType, "none">, x: number, y: number, size: number, stroke: string, fill: string, sw: number): void;
380
406
 
381
- export { type LegendOrientation as L, type Marker as M, Renderer as R, type Theme as T, type LegendItem as a, type LayoutResult as b, type RenderOutput as c, drawMarker as d, Layout as e, type LayoutConfig as f, getDefaultTheme as g, type LegendConfig as h, renderArea as i, renderLegend as j, renderLine as k, renderMarkers as l, measureLegend as m, renderSplitLine as n, renderStep as o, renderZonedArea as p, resetDefaultTheme as r, setDefaultTheme as s };
407
+ export { type LegendOrientation as L, type Marker as M, Renderer as R, type Theme as T, type LegendItem as a, type LayoutResult as b, type RenderOutput as c, drawMarker as d, Layout as e, type LayoutConfig as f, getDefaultTheme as g, type LegendConfig as h, renderArea as i, renderLegend as j, renderLine as k, renderMarkers as l, measureLegend as m, renderSplitLine as n, renderStep as o, renderZonedArea as p, toStepPoints as q, resetDefaultTheme as r, setDefaultTheme as s, toStepData as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ml-time-graph",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "TypeScript library for time-series chart rendering — DOM-free SVG output (works in the browser and on the server).",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",