ml-time-graph 1.7.2 → 1.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +214 -8
- package/README.de.md +104 -11
- package/README.md +101 -11
- package/SKILLS.md +157 -4
- package/USAGE.md +326 -3
- package/dist/analyze/index.d.ts +54 -1
- package/dist/analyze/index.js +2 -2
- package/dist/index.d.ts +107 -7
- package/dist/index.js +27 -26
- package/dist/interaction/index.d.ts +1 -1
- package/dist/interaction/index.js +1 -1
- package/dist/internals.d.ts +104 -26
- package/dist/internals.js +15 -15
- package/dist/{scale-D6NtEaUB.d.ts → scale-CoTgJ27U.d.ts} +71 -12
- package/dist/{series_renderer-COVNvq2x.d.ts → slug-0lFk9pY7.d.ts} +18 -2
- package/package.json +17 -13
package/dist/index.js
CHANGED
|
@@ -1,49 +1,50 @@
|
|
|
1
|
-
var
|
|
1
|
+
var se=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}})}};function ee(i){return i&&i.toString().normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"unnamed"}var Dt=(()=>{let i=new Array(256);for(let e=0;e<256;e++){let t=e;for(let n=0;n<8;n++)t=t&1?3988292384^t>>>1:t>>>1;i[e]=t>>>0;}return i})();function Fe(i){let e=new TextEncoder().encode(i),t=4294967295;for(let n of e)t=Dt[(t^n)&255]^t>>>8;return (t^4294967295)>>>0}function U(i,e){return e||"s-"+Fe(i??"").toString(16).padStart(8,"0")}var Je=new Map;function Lt(i,e){return `${i}|${JSON.stringify(e??{})}`}function Qe(i,e){let t=Lt(i,e),n=Je.get(t);return n||(n=new Intl.DateTimeFormat(i,e),Je.set(t,n)),n}var Z=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]}},Y=[{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}],te=class{#e;#t;#n;constructor(e){this.#e=new Z({domain:e.domain,range:e.range}),this.#t=e.locale||(typeof navigator<"u"?navigator.language:"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(),s=o-r;if(s<=0)return {interval:Y[0].ms};let a=s/e,l=Y[0].ms;for(let u of Y)if(u.ms>=a){l=u.ms;break}let h=l,m=Math.round(s/h);for(;m>n&&h<Y[Y.length-1].ms;){let u=Y.findIndex(d=>d.ms===h);h=Y[Math.min(u+1,Y.length-1)].ms,m=Math.round(s/h);}for(;m<t&&h>Y[0].ms;){let u=Y.findIndex(d=>d.ms===h);h=Y[Math.max(u-1,0)].ms,m=Math.round(s/h);}return {interval:h}}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(),a=[],l=Math.ceil(o/r)*r;for(let h=l;h<=s;h+=r)a.push(h);return a}format(e,t){let n=this.#n?{...t,timeZone:this.#n}:t;return Qe(this.#t,n).format(new Date(e))}};var Be={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 de={...Be};function Mt(i){de={...de,...i};}function ne(){return de}function Pt(){de={...Be};}function Rt(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 Ft(i){let e=i.trim().toLowerCase();return e.startsWith("#")?e.length===9||e.length===5:e.startsWith("rgba(")||e.startsWith("hsla(")}function je(i,e="classic-diagonal",t="rgba(200, 220, 255, 0.3)",n,r=2){let o=Rt(t),s=Ft(t)?"":' fill-opacity="0.3"';if(e==="none")return `
|
|
2
2
|
<pattern id="${i}" width="10" height="10" patternUnits="userSpaceOnUse">
|
|
3
|
-
<rect width="10" height="10" fill="${
|
|
3
|
+
<rect width="10" height="10" fill="${t}" />
|
|
4
4
|
</pattern>
|
|
5
|
-
`.trim();let a=12,l=12,h="rotate(0)",
|
|
5
|
+
`.trim();let a=12,l=12,h="rotate(0)",m="";switch(e){case "classic-diagonal":a=12,l=12,h="rotate(45)",m=`<line x1="0" y1="0" x2="0" y2="${l}" stroke="${o}" stroke-width="${r}" stroke-linecap="square" />`;break;case "dense-steep":a=6,l=6,h="rotate(30)",m=`<line x1="0" y1="0" x2="0" y2="${l}" stroke="${o}" stroke-width="${r}" stroke-linecap="square" />`;break;case "crosshatch":a=14,l=14,h="rotate(45)",m=`
|
|
6
6
|
<line x1="0" y1="0" x2="0" y2="${l}" stroke="${o}" stroke-width="${r}" stroke-linecap="square" />
|
|
7
7
|
<line x1="0" y1="0" x2="${a}" y2="0" stroke="${o}" stroke-width="${r}" stroke-linecap="square" />
|
|
8
|
-
`;break;case "dots":a=12,l=12,
|
|
8
|
+
`;break;case "dots":a=12,l=12,m=`<circle cx="${a/2}" cy="${l/2}" r="${r*1.2}" fill="${o}" />`;break;case "waves":a=16,l=16,m=`
|
|
9
9
|
<path d="M 0 ${l/2} Q ${a/4} 0, ${a/2} ${l/2} T ${a} ${l/2}" fill="none" stroke="${o}" stroke-width="${r}" stroke-linecap="round" />
|
|
10
|
-
`;break;case "dashed":a=12,l=12,h="rotate(45)",
|
|
10
|
+
`;break;case "dashed":a=12,l=12,h="rotate(45)",m=`<line x1="0" y1="0" x2="0" y2="${l}" stroke="${o}" stroke-width="${r}" stroke-dasharray="3,3" />`;break;case "herringbone":a=16,l=16,m=`
|
|
11
11
|
<path d="M 0 0 L ${a/2} ${l/2} L 0 ${l} M ${a} 0 L ${a/2} ${l/2} L ${a} ${l}" fill="none" stroke="${o}" stroke-width="${r}" stroke-linejoin="round" stroke-linecap="round" />
|
|
12
|
-
`;break;case "brick":a=20,l=20,
|
|
12
|
+
`;break;case "brick":a=20,l=20,m=`
|
|
13
13
|
<path d="M 0 ${l/2} L ${a} ${l/2} M 0 ${l} L ${a} ${l} M ${a/2} 0 L ${a/2} ${l/2} M 0 ${l/2} L 0 ${l}" fill="none" stroke="${o}" stroke-width="${r}" />
|
|
14
|
-
`;break;case "double-stripe":a=16,l=16,h="rotate(45)",
|
|
14
|
+
`;break;case "double-stripe":a=16,l=16,h="rotate(45)",m=`
|
|
15
15
|
<line x1="0" y1="0" x2="0" y2="${l}" stroke="${o}" stroke-width="${r}" stroke-linecap="square" />
|
|
16
16
|
<line x1="${a/2}" y1="0" x2="${a/2}" y2="${l}" stroke="${o}" stroke-width="${r/2}" stroke-linecap="square" />
|
|
17
|
-
`;break;case "honeycomb":a=18,l=32,
|
|
17
|
+
`;break;case "honeycomb":a=18,l=32,m=`
|
|
18
18
|
<path d="M 0 0 L ${a/2} 5 L ${a} 0 M 0 16 L ${a/2} 11 L ${a} 16 M 0 16 L 0 32 M ${a/2} 5 L ${a/2} 11 M ${a} 16 L ${a} 32 M 0 32 L ${a/2} 27 L ${a} 32 M ${a/2} 27 L ${a/2} 32" fill="none" stroke="${o}" stroke-width="${r}" stroke-linejoin="round" stroke-linecap="round" />
|
|
19
|
-
`;break}let
|
|
19
|
+
`;break}let u=`<rect width="${a}" height="${l}" fill="${t}"${s} />`;return `
|
|
20
20
|
<pattern id="${i}" width="${a}" height="${l}" patternTransform="${h}" patternUnits="userSpaceOnUse">
|
|
21
|
-
${m}
|
|
22
21
|
${u}
|
|
22
|
+
${m}
|
|
23
23
|
</pattern>
|
|
24
|
-
`.trim()}function Ft(i,t=2,e=false){return i==="dashed"||!i&&e?{strokeDasharray:"4,4"}:i==="dotted"?{strokeDasharray:"2,4"}:!i||i==="solid"?null:zt(i,t)}function zt(i,t=2){let e=t;switch(i){case "dotted":return {strokeDasharray:`0, ${e*2}`,strokeLinecap:"round"};case "sparse-dots":return {strokeDasharray:`0, ${e*4}`,strokeLinecap:"round"};case "dashed":return {strokeDasharray:`${e*3}, ${e*2}`,strokeLinecap:"butt"};case "long-dash":return {strokeDasharray:`${e*6}, ${e*3}`,strokeLinecap:"butt"};case "dense-dash":return {strokeDasharray:`${e*1.5}, ${e*1.5}`,strokeLinecap:"butt"};case "dash-dot":return {strokeDasharray:`${e*4}, ${e*2}, 0, ${e*2}`,strokeLinecap:"round"};case "dash-dot-dot":return {strokeDasharray:`${e*5}, ${e*2}, 0, ${e*2}, 0, ${e*2}`,strokeLinecap:"round"};case "loose-dash":return {strokeDasharray:`${e*3}, ${e*4}`,strokeLinecap:"butt"};default:return {strokeDasharray:"none",strokeLinecap:"butt"}}}var g=new Proxy({},{get:(i,t)=>Q()[t],has:(i,t)=>t in Q(),ownKeys:()=>Reflect.ownKeys(Q()),getOwnPropertyDescriptor:(i,t)=>Reflect.getOwnPropertyDescriptor(Q(),t)});var ot={axisColor:g.axisColor,tickColor:g.tickColor,textColor:g.textColor,textSize:g.textSize},tt=class{#t;#e;constructor(t){this.#t=new J({domain:t.domain,range:t.xRange,locale:t.locale}),this.#e=t;}get scale(){return this.#t}get axisColor(){return (this.#e.colors??ot).axisColor}get tickColor(){return (this.#e.colors??ot).tickColor}get textColor(){return (this.#e.colors??ot).textColor}get textSize(){return (this.#e.colors??ot).textSize}generateTicks(){let t=this.#e.minTicks??5,e=this.#e.maxTicks??12,r=this.#t.ticks({minTicks:t,maxTicks:e}).map(o=>({time:o,x:this.#t.map(o),label:this.tickLabel(o)}));return this.antiOverlap(r)}tickLabel(t){if(this.#e.format)return this.#e.format(new Date(t));let e=this.#e.minTicks??5,n=this.#e.maxTicks??12,{interval:r}=this.#t.tickInterval((e+n)/2,e,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.#t.format(t,o)}antiOverlap(t){if(t.length<=1)return t;let e=60,n=[t[0]];for(let r=1;r<t.length;r++){let o=n[n.length-1].x;Math.abs(t[r].x-o)>=e&&n.push(t[r]);}return n}render(){let t=this.generateTicks(),e=this.#e.colors??ot,n=this.#e.y??0,r=[],[o,s]=this.#t.range();r.push({type:"line",x1:o,y1:n,x2:s,y2:n,stroke:e.axisColor,strokeWidth:e.axisWidth});for(let a of t)r.push({type:"line",x1:a.x,y1:n,x2:a.x,y2:n+6,stroke:e.tickColor,strokeWidth:e.axisWidth}),r.push({type:"text",content:a.label,x:a.x,y:n+e.textSize+6,anchor:"middle",fontSize:e.textSize,fill:e.textColor});return r}};var st={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function ke(i){return Math.abs(i)>=1e6?`${(i/1e6).toFixed(1)}M`:Math.abs(i)>=1e3?`${(i/1e3).toFixed(1)}k`:Number.isInteger(i)?String(i):i.toFixed(1)}function Te(i){let t=new Array(i.length).fill(false),e=0;for(;e<i.length;){let n=e;for(;n+1<i.length&&i[n+1].label===i[e].label;)n++;for(let r=e+1;r<n;r++)t[r]=true;e=n+1;}return t}var ut=class{#t;#e;constructor(t){this.#t=new X({domain:t.domain,range:t.range}),this.#e=t;}get scale(){return this.#t}get axisColor(){return (this.#e.colors??st).axisColor}get tickColor(){return (this.#e.colors??st).tickColor}get textColor(){return (this.#e.colors??st).textColor}get textSize(){return (this.#e.colors??st).textSize}generateTicks(){let t=this.#e.format??ke,e=this.#e.ticks&&this.#e.ticks>0?this.#e.ticks:6,[n,r]=this.#t.domain(),o=Math.min(n,r),s=Math.max(n,r),a=s-o;if(a===0)return [{value:n,position:this.#t.map(n),label:t(n)}];let l=a/e,h=Math.pow(10,Math.floor(Math.log10(l))),u=l/h,m;if(u<=1.5?m=h:u<=3?m=2*h:u<=7?m=5*h:m=10*h,m<=0||!Number.isFinite(m))return [{value:n,position:this.#t.map(n),label:t(n)}];let d=[],c=Math.ceil(o/m)*m;for(let f=c;f<=s;f+=m)d.push({value:f,position:this.#t.map(f),label:t(f)});return d}render(){let t=this.generateTicks(),e=this.#e.colors??st,n=this.#e.x??0,r=this.#e.orientation??"vertical",o=this.#e.position??"left",s=this.#e.suppressLabelsNear??[],a=this.#e.suppressTolerancePx??8,l=u=>s.some(m=>Math.abs(m-u)<=a),h=[];if(r==="vertical"){let[u,m]=this.#t.range();h.push({type:"line",x1:n,y1:u,x2:n,y2:m,stroke:e.axisColor,strokeWidth:e.axisWidth});let d=Te(t);t.forEach((c,f)=>{let y=l(c.position),x=d[f]?{opacity:0}:{};o==="left"?(h.push({type:"line",x1:n-4,y1:c.position,x2:n,y2:c.position,stroke:e.tickColor,strokeWidth:e.axisWidth}),y||h.push({type:"text",content:c.label,x:n-8,y:c.position+4,anchor:"end",fontSize:11,fill:e.textColor,...x})):(h.push({type:"line",x1:n,y1:c.position,x2:n+4,y2:c.position,stroke:e.tickColor,strokeWidth:e.axisWidth}),y||h.push({type:"text",content:c.label,x:n+8,y:c.position+4,anchor:"start",fontSize:11,fill:e.textColor,...x}));});}else {let[u,m]=this.#t.range();h.push({type:"line",x1:u,y1:n,x2:m,y2:n,stroke:e.axisColor,strokeWidth:e.axisWidth});for(let d of t)h.push({type:"line",x1:d.position,y1:n,x2:d.position,y2:n+6,stroke:e.tickColor,strokeWidth:e.axisWidth}),h.push({type:"text",content:d.label,x:d.position,y:n+18,anchor:"middle",fontSize:e.textSize,fill:e.textColor});}return h}};var G=class{static interpolateDataPoint(i,t,e){return {time:i.time+Math.round(e*(t.time-i.time)),value:(i.value??0)+e*((t.value??0)-(i.value??0))}}static interpolateAggregatedPoint(i,t,e){let n=(r,o)=>r!==null&&o!==null?r+e*(o-r):null;return {time:i.time+e*(t.time-i.time),min:n(i.min,t.min),max:n(i.max,t.max),avg:n(i.avg,t.avg),count:Math.round(i.count+e*(t.count-i.count))}}static getRuns(i,t,e=0){let n=[...i].sort((a,l)=>a.time-l.time),r=[],o=[],s=null;for(let a of n){let l=t(a),h=e>0&&s&&a.time-s.time>e;(l||h)&&o.length&&(r.push(o),o=[]),l||o.push(a),s=a;}return o.length&&r.push(o),r}static splitByBoundaries(i,t,e,n){if(i.length===0)return [];if(t.length===0)return [{data:i,zoneIndex:0,zoneLow:Number.NEGATIVE_INFINITY}];let r=[...t].sort((h,u)=>h-u),o=[],s=h=>h<=0?Number.NEGATIVE_INFINITY:r[h-1],a=h=>{let u=0;for(let m=0;m<r.length&&h>=r[m];m++)u=m+1;return u},l=[i[0]];for(let h=1;h<i.length;h++){let u=i[h-1],m=i[h],d=e(u),c=e(m),f;c>d?f=r.filter(x=>x>d&&x<=c):c<d?f=r.filter(x=>x>=c&&x<d).reverse():f=[];let y=d;for(let x of f){let b=(x-d)/(c-d),v=n(u,m,b);l.push(v);let $=a((y+x)/2);o.push({data:l,zoneIndex:$,zoneLow:s($)}),l=[v],y=x;}(f.length===0||f[f.length-1]!==c)&&l.push(m);}if(l.length>1){let h=e(l[0]),u=e(l[l.length-1]),m=a((h+u)/2);o.push({data:l,zoneIndex:m,zoneLow:s(m)});}return o}static splitByThreshold(i,t,e,n){let r=this.splitByBoundaries(i,[t],e,n),o={above:[],below:[]};for(let s of r)s.zoneIndex===0?o.below.push(s.data):o.above.push(s.data);return o}};function Yt(i,t=6e4){if(i.length<2)return [];let e=[...i].sort((r,o)=>r.time-o.time),n=[];for(let r=1;r<e.length;r++)e[r].time-e[r-1].time>t&&n.push({startTime:e[r-1].time,endTime:e[r].time});return n}function Ce(i,t=83144){let e=t/8.314,n=0,r=0;for(let s of i)s!==null&&(n+=Math.exp(-e/(s+273.15)),r++);if(r===0)return null;let o=n/r;return e/-Math.log(o)-273.15}function qt(i,t,e=83144){let n=new Array(i.length),r=0;for(let o=0;o<i.length;o++){let s=i[o].time,a=s-t;for(;r<o&&i[r].time<a;)r++;let l=i.slice(r,o+1).map(u=>u.value),h=Ce(l,e);n[o]={time:s,value:h,synthetic:true};}return n}function $e(i){let t=0,e=0;for(let o of i)o!==null&&(t+=o,e++);if(e===0)return null;let n=t/e,r=0;for(let o of i){if(o===null)continue;let s=o-n;r+=s*s;}return Math.sqrt(r/e)}function Ae(i){let t=0,e=0;for(let o of i)o!==null&&(t+=o,e++);if(e<2)return null;let n=t/e,r=0;for(let o of i){if(o===null)continue;let s=o-n;r+=s*s;}return Math.sqrt(r/(e-1))}function Xt(i,t,e=false){let n=new Array(i.length),r=0,o=e?Ae:$e;for(let s=0;s<i.length;s++){let a=i[s].time,l=a-t;for(;r<s&&i[r].time<l;)r++;let h=i.slice(r,s+1).map(m=>m.value),u=o(h);n[s]={time:a,value:u,synthetic:true};}return n}function Ut(i){return {id:i.id,line:{stroke:i.stroke??g.stroke,strokeWidth:i.strokeWidth??g.strokeWidth,smoothing:i.smoothing??false,dashed:i.dashed??false},fill:i.fill??g.areaFillAlpha,markers:{type:i.pointStyle??"none",size:i.pointSize??g.pointSize,stroke:i.stroke??g.stroke,fill:"#ffffff"},shadow:{color:i.shadowColor??"transparent",blur:i.shadowBlur??0,offsetX:i.shadowOffsetX??0,offsetY:i.shadowOffsetY??0}}}function mt(i,t,e){let n=[],r=i.reduce((s,a)=>s+a.data.length,0),o=Ut(e);for(let s=0;s<i.length;s++){let a=i[s];a.data.length>=2?n.push({type:"path",id:e.id?`${e.id}-line-${s}`:void 0,points:a.data.map(l=>({x:t.timeScale.map(l.time),y:t.valueScale.map(l.value)})),stroke:a.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"}):a.data.length===1&&r===1&&n.push({type:"circle",cx:t.timeScale.map(a.data[0].time),cy:t.valueScale.map(a.data[0].value),r:Math.max(o.markers.size,o.line.strokeWidth),fill:a.color??o.line.stroke,shadowColor:o.shadow.color,shadowBlur:o.shadow.blur});}return n}function dt(i){let t=[];for(let e of i)t.length>0&&t.push({...e,value:t[t.length-1].value}),t.push(e);return t}function Bt(i,t,e,n){if(i.length<2)return [];let r=G.splitByBoundaries(i,e.boundaries,e.getValue,e.interpolate),o=[];for(let s=0;s<r.length;s++){let a=r[s];if(a.data.length<2)continue;let l=e.getColor(a.zoneIndex);if(!l)continue;let h=a.data.map(m=>({x:t.timeScale.map(m.time),y:t.valueScale.map(e.yLow(m))})),u=a.data.map(m=>({x:t.timeScale.map(m.time),y:t.valueScale.map(e.yHigh(m))})).reverse();o.push({type:"path",id:n?.id?`${n.id}-fill-${s}`:void 0,points:[...h,...u],fill:l,hatch:e.getHatch?.(a.zoneIndex),stroke:"none"});}return o}function Kt(i,t,e,n){let r=Ut(e);if(!r.markers.type||r.markers.type==="none")return [];let o=[];for(let s=0;s<i.length;s++){let a=i[s],l=t.timeScale.map(a.time),h=t.valueScale.map(a.value),u=n(a),m=e.pointStroke??u,d=e.pointFill??u,c=e.pointStrokeWidth??1.5,f=e.id?`${e.id}-marker-${s}`:void 0;ct(o,f,r.markers.type,l,h,r.markers.size,m,d,c);}return o}function ct(i,t,e,n,r,o,s,a,l){switch(e){case "circle":i.push({type:"circle",cx:n,cy:r,r:o,fill:a,stroke:s,strokeWidth:l,id:t});break;case "square":i.push({type:"rect",x:n-o,y:r-o,w:o*2,h:o*2,fill:a,stroke:s,strokeWidth:l,id:t});break;case "cross":i.push({type:"line",x1:n-o,y1:r-o,x2:n+o,y2:r+o,stroke:s,strokeWidth:l,id:t},{type:"line",x1:n-o,y1:r+o,x2:n+o,y2:r-o,stroke:s,strokeWidth:l,id:t});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}],fill:a,stroke:s,strokeWidth:l,id:t});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}],fill:a,stroke:s,strokeWidth:l,id:t});break;case "star":{let h=[];for(let u=0;u<10;u++){let m=u%2===0?o:o*.5,d=Math.PI/2*3+u*Math.PI/5;h.push({x:n+m*Math.cos(d),y:r+m*Math.sin(d)});}i.push({type:"path",points:h,fill:a,stroke:s,strokeWidth:l,id:t});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:s,strokeWidth:l,fill:"none",id:t});break;case "plus":i.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:s,strokeWidth:l,id:t},{type:"line",x1:n,y1:r-o,x2:n,y2:r+o,stroke:s,strokeWidth:l,id:t});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}],fill:a,stroke:s,strokeWidth:l,id:t});break;case "hexagon":{let h=[];for(let u=0;u<6;u++){let m=u*(Math.PI/3);h.push({x:n+o*Math.cos(m),y:r+o*Math.sin(m)});}i.push({type:"path",points:h,fill:a,stroke:s,strokeWidth:l,id:t});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}],fill:a,stroke:s,strokeWidth:l,id:t});break;case "line-horizontal":i.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:s,strokeWidth:l,id:t});break;default:i.push({type:"circle",cx:n,cy:r,r:o,fill:a,stroke:s,strokeWidth:l,id:t});}}var et=class i{#t;#e;static uidcnt=0;#n;constructor(t,e=[]){this.#t=t.id??"series-"+ ++i.uidcnt,this.#e=t.timeScale,this.#n=e;}get id(){return this.#t}get timeScale(){return this.#e}get data(){return this.#n}};var pt=class extends et{#t;constructor(t){super(t,t.data),this.#t=t;}render(){let t=this.#t,e=t.minColor??g.minColor,n=t.maxColor??g.maxColor,r=t.avgColor??g.avgColor,o=t.avgDashed??true,s=t.smoothing??false,a=t.strokeWidth??g.strokeWidth,l=G.getRuns(this.data,c=>c.min===null||c.max===null||c.avg===null);if(l.length===0)return [];let h={timeScale:this.timeScale,valueScale:t.valueScale},u=[];l.forEach((c,f)=>{c.length<2||(t.fillToMax&&u.push(...Bt(c,h,{boundaries:[],yLow:y=>y.avg,yHigh:y=>y.max,getValue:y=>y.avg,interpolate:G.interpolateAggregatedPoint,getColor:()=>t.fillToMax,getHatch:()=>t.fillToMaxHatch},{id:this.id?`${this.id}-fillToMax-${f}`:void 0})),t.fillToMin&&u.push(...Bt(c,h,{boundaries:[],yLow:y=>y.avg,yHigh:y=>y.min,getValue:y=>y.avg,interpolate:G.interpolateAggregatedPoint,getColor:()=>t.fillToMin,getHatch:()=>t.fillToMinHatch},{id:this.id?`${this.id}-fillToMin-${f}`:void 0})));});let m=l.filter(c=>c.length>=2),d=c=>m.map(f=>({data:f.map(y=>({time:y.time,value:c(y)}))}));return u.push(...mt(d(c=>c.max),h,{stroke:n,strokeWidth:a,smoothing:s,id:this.id?`${this.id}-max`:void 0}),...mt(d(c=>c.min),h,{stroke:e,strokeWidth:a,smoothing:s,id:this.id?`${this.id}-min`:void 0}),...mt(d(c=>c.avg),h,{stroke:r,strokeWidth:a,smoothing:s,dashed:o,id:this.id?`${this.id}-avg`:void 0})),u}};var ft=class extends et{#t;constructor(t){super(t,t.data),this.#t=t;}opacity(t){if(!(this.#t.countOpacity??false))return .6;let e=0;for(let n of this.data)n.count>e&&(e=n.count);return e===0?.2:.2+.8*t/e}render(){let t=this.#t,e=t.fill??g.bandFill,n=t.hatch,r=t.avgLine??false,o=t.avgLineColor??g.bandAvgLine,s=t.bandWidth??10,a=[];for(let l of this.data){if(l.min===null||l.max===null)continue;let h=this.timeScale.map(l.time),u=t.valueScale.map(l.max),m=t.valueScale.map(l.min),d=s,c=this.data.indexOf(l);if(a.push({type:"rect",x:h-d/2,y:u,w:d,h:m-u,fill:e,hatch:n,opacity:this.opacity(l.count),id:this.id?`${this.id}-slot-${c}`:void 0}),r&&l.avg!==null){let f=t.valueScale.map(l.avg);a.push({type:"line",x1:h-d/2,y1:f,x2:h+d/2,y2:f,stroke:o,strokeWidth:1,id:this.id?`${this.id}-avg-${c}`:void 0});}}return a}};function De(i){return i==="dotted"?{dash:"dotted"}:i==="dashed"?{dash:"dashed"}:{}}function Zt(i){let{thresholds:t,valueScale:e,xRange:n}=i,[r,o]=n,[s,a]=e.range(),l=Math.min(s,a),h=Math.max(s,a),u=[],m=[];for(let d of t){let c=d.color??g.thresholdColor,f=e.map(d.value);d.fill==="above"?u.push({type:"rect",x:r,y:l,w:o-r,h:Math.max(0,f-l),fill:c,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,h-f),fill:c,hatch:d.fillHatch,opacity:d.fillOpacity??.12,id:d.id?`${d.id}-fill`:void 0});let y=d.line??g.thresholdLine;if(y!=="none"){let x=De(y),b={type:"line",x1:r,y1:f,x2:o,y2:f,stroke:c,strokeWidth:1,...x,id:d.id?`${d.id}-line`:void 0};d.shadowColor&&(b.shadowColor=d.shadowColor,b.shadowBlur=d.shadowBlur??4,b.shadowOffsetX=d.shadowOffsetX??0,b.shadowOffsetY=d.shadowOffsetY??2),u.push(b);}if(d.label!==void 0&&d.label!==null&&d.label!==false){let x=typeof d.label=="object"?d.label:void 0,b=typeof d.label=="string"?d.label:x?.text??d.name,v=x?.position??"right";m.push({...Le(b,v,r,o,f,c,x),id:d.id?`${d.id}-label`:void 0});}}return {inside:u,labels:m}}function Le(i,t,e,n,r,o,s){let a=(e+n)/2,l={type:"text",content:i,fontSize:g.thresholdFontSize,fill:o},h=s?{...s.rotate!==void 0&&{rotate:s.rotate},...s.textBaseline!==void 0&&{textBaseline:s.textBaseline}}:{};switch(t){case "left":return {...l,...h,x:e+4,y:r-4,anchor:"start"};case "above":return {...l,...h,x:a,y:r-6,anchor:"middle"};case "below":return {...l,...h,x:a,y:r+14,anchor:"middle"};case "center":return {...l,...h,x:a,y:r-4,anchor:"middle"};case "outside-left":return {...l,...h,x:e-6,y:r+3,anchor:"end",textBaseline:h.textBaseline??"middle"};case "outside-right":return {...l,...h,x:n+6,y:r+3,anchor:"start",textBaseline:h.textBaseline??"middle"};default:return {...l,...h,x:n-4,y:r-4,anchor:"end"}}}function Jt(i){let{gaps:t,timeScale:e,yRange:n,fill:r=g.gapFill,hatch:o,fillOpacity:s=g.gapFillOpacity??.15,stroke:a=g.gapStroke,strokeWidth:l=g.gapStrokeWidth,dashed:h=true,fontSize:u=g.gapFontSize,fontFill:m=g.gapFontColor,labelBaseline:d="middle",labelRotate:c}=i,[f,y]=n,x=[];for(let b of t){let v=e.map(b.startTime),$=e.map(b.endTime),A=b.fill??r,M=b.hatch??o,V=b.fillOpacity??s,R=b.label??"",w=b.rotate??c,k=b.labelBaseline??d;if(b.style==="dashed_border"||!b.style?x.push({type:"rect",x:v,y:f,w:$-v,h:y-f,fill:A,hatch:M,opacity:V,stroke:a,strokeWidth:l,dashed:h}):b.style==="empty"&&x.push({type:"rect",x:v,y:f,w:$-v,h:y-f,fill:A,hatch:M,opacity:V}),R){let L=Me(f,y,k),P=k==="above"?"top":k==="below"?"bottom":"middle";x.push({type:"text",content:R,x:(v+$)/2,y:L,anchor:"middle",fontSize:u,fill:m,textBaseline:P,rotate:w});}}return x}function Me(i,t,e){switch(e){case "above":return i-12;case "below":return t+4;default:return (i+t)/2}}var Pe=1,gt=class{#t;constructor(t,e,n,r){this.#t={...t,xRange:e,y:n,height:r};}render(){let{items:t,timeScale:e,background:n,hatch:r,showAxis:o,xRange:s,y:a,height:l}=this.#t,h=[];n&&h.push({type:"rect",x:s[0],y:a,w:s[1]-s[0],h:l,fill:n,opacity:.04,stroke:"#ddd",strokeWidth:.25});for(let u of t){let m=e.map(u.startTime),d=e.map(u.endTime);if(d<s[0]||m>s[1])continue;let c=Math.max(s[0],Math.min(s[1],m)),f=Math.max(s[0],Math.min(s[1],d)),y=Math.max(f-c,Pe);c+y>s[1]&&(c=Math.max(s[0],s[1]-y));let x=c+y/2;if(h.push({type:"rect",x:c,y:a,w:y,h:l,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;h.push({type:"text",content:u.label,x,y:this.#e(u.labelBaseline,b),anchor:"middle",fontSize:b,fill:u.labelFill??"#333"});}}if(o){let u=new tt({domain:e.domain(),xRange:s,y:a+l+4});h.push({type:"group",cssClass:"annotation-band-axis",commands:u.render()});}return h}#e(t,e){let{y:n,height:r}=this.#t;switch(t){case "top":return n+e*.9;case "bottom":return n+r-e*.25;default:return n+r/2+e*.35}}};function Qt(i){let{highlights:t,timeScale:e,yRange:n,height:r}=i,[o,s]=n,a=[];for(let l of t){let h=e.map(l.startTime),u=e.map(l.endTime);a.push({type:"rect",x:h,y:o,w:u-h,h:s-o,fill:l.color??g.highlightColor,opacity:l.opacity??g.highlightOpacity}),l.label&&a.push({type:"text",content:l.label,x:(h+u)/2,y:Fe(l.labelPosition??"top",o,s,r),anchor:"middle",fontSize:g.annotationFontSize,fill:l.color??g.highlightLabelColor,rotate:l.rotate});}return a}function Fe(i,t,e,n){switch(i){case "above":return t-5;case "below":return n!==void 0?n-5:e+14;case "center":return (t+e)/2+4;case "bottom":return e-6;default:return t+14}}function te(i){let{markers:t,timeScale:e,valueScale:n,yRange:r=[0,300]}=i,[o,s]=r,a=[];for(let l of t){let h=e.map(l.time),u=l.color??g.markerColor,m=l.pointStyle??(l.value!==void 0?"circle":"none"),d=l.lineStyle??"full";if(l.value!==void 0){let c=n.map(l.value);if(d==="to-value"?a.push({type:"line",x1:h,y1:s,x2:h,y2:c,stroke:u,strokeWidth:1,dashed:true}):d==="to-top"?a.push({type:"line",x1:h,y1:o,x2:h,y2:c,stroke:u,strokeWidth:1,dashed:true}):d==="full"&&a.push({type:"line",x1:h,y1:o,x2:h,y2:s,stroke:u,strokeWidth:1}),m!=="none"&&ct(a,void 0,m,h,c,g.markerSize,u,u,1.5),l.label){let f=d==="to-value"?c-10:o-6;a.push({type:"text",content:l.label,x:h,y:f,anchor:"middle",fontSize:11,fill:u});}}else d!=="none"&&a.push({type:"line",x1:h,y1:o,x2:h,y2:s,stroke:u,strokeWidth:1}),l.label&&a.push({type:"text",content:l.label,x:h,y:o-6,anchor:"middle",fontSize:11,fill:u});}return a}function ee(i){let{annotations:t,timeScale:e,valueScales:n}=i,r=[],o=s=>{let a=n.get(s.axis??0)??n.values().next().value;return {x:e.map(s.time),y:a?a.map(s.value):0}};for(let s of t){let a=[],l=h=>a.push(h);switch(s.type){case "line":{let h=o(s.from),u=o(s.to);l({type:"line",x1:h.x,y1:h.y,x2:u.x,y2:u.y,stroke:s.color??g.annotationColor,strokeWidth:s.width??g.annotationWidth,dash:s.dash});break}case "arrow":{let h=o(s.from),u=o(s.to),m=s.color??g.annotationColor,d=s.headSize??g.annotationHead;l({type:"line",x1:h.x,y1:h.y,x2:u.x,y2:u.y,stroke:m,strokeWidth:s.width??g.annotationWidth});let c=Math.hypot(u.x-h.x,u.y-h.y)||1,f=(u.x-h.x)/c,y=(u.y-h.y)/c,x=u.x-f*d,b=u.y-y*d;l({type:"path",points:[{x:u.x,y:u.y},{x:x-y*d*.5,y:b+f*d*.5},{x:x+y*d*.5,y:b-f*d*.5}],fill:m,stroke:"none"});break}case "rect":{let h=o(s.from),u=o(s.to);l({type:"rect",x:Math.min(h.x,u.x),y:Math.min(h.y,u.y),w:Math.abs(u.x-h.x),h:Math.abs(u.y-h.y),fill:s.fill??"none",stroke:s.stroke,opacity:s.opacity});break}case "point":{let h=o(s.at),u=s.color??"#334155",m=s.radius??g.annotationRadius,d=s.shape??"circle";d==="circle"?l({type:"circle",cx:h.x,cy:h.y,r:m,fill:u}):d==="square"?l({type:"rect",x:h.x-m,y:h.y-m,w:m*2,h:m*2,fill:u}):(l({type:"line",x1:h.x-m,y1:h.y-m,x2:h.x+m,y2:h.y+m,stroke:u,strokeWidth:1.5}),l({type:"line",x1:h.x-m,y1:h.y+m,x2:h.x+m,y2:h.y-m,stroke:u,strokeWidth:1.5}));break}case "label":{let h=o(s.at);l({type:"text",content:s.text,x:h.x+(s.dx??0),y:h.y+(s.dy??0),anchor:s.anchor??"middle",fontSize:g.annotationFontSize,fill:s.color??g.annotationColor,rotate:s.rotate});break}}if(s.id&&a.length>0){let h=it(s.id);r.push({type:"group",cssClass:`annotation annotation--${h}`,commands:a});}else r.push(...a);}return r}var U=12,yt=8,It=20,Be=11,jt=18,Rt=i=>i.length*Be*.6;function ne(i,t="vertical"){if(t==="horizontal"){let n=0;for(let r of i)n+=U+yt+Rt(r.name)+jt;return {width:Math.max(0,n-jt),height:It}}let e=0;for(let n of i)e=Math.max(e,Rt(n.name));return {width:U+yt+e,height:i.length*It}}function ie(i){let{items:t,x:e,y:n,orientation:r="vertical"}=i,o=[],s=e;return t.forEach((a,l)=>{let h=r==="horizontal"?s:e,u=r==="horizontal"?n:n+l*It;o.push({type:"rect",x:h,y:u,w:U,h:U,fill:a.color,stroke:g.legendStroke,strokeWidth:1},{type:"text",content:a.name,x:h+U+yt,y:u+U-2,fontSize:g.legendFont,fill:g.legendText}),r==="horizontal"&&(s+=U+yt+Rt(a.name)+jt);}),{type:"group",cssClass:"chart-legend",commands:o}}function re(i){let{xTicks:t,yTicks:e,xRange:n,yRange:r,stroke:o=g.gridStroke,strokeWidth:s=g.gridStrokeWidth,dashed:a=false,opacity:l=g.gridOpacity}=i,h=[];if(e)for(let u of e)h.push({type:"line",x1:n[0],y1:u,x2:n[1],y2:u,stroke:o,strokeWidth:s,dashed:a,opacity:l});if(t)for(let u of t)h.push({type:"line",x1:u,y1:r[0],x2:u,y2:r[1],stroke:o,strokeWidth:s,dashed:a,opacity:l});return h}function oe(i,t,e){let n=i??t;if(n==="series")return null;if(n==="chartTop")return e.chartTop;if(n==="chartBottom")return e.chartBottom;if(typeof n=="object"&&"threshold"in n){let r=e.thresholds.get(n.threshold);if(!r)throw new Error(`fillSpec region references unknown threshold '${n.threshold}'`);return e.valueScale.map(r.value)}return typeof n=="object"&&"value"in n?e.valueScale.map(n.value):null}function Ie(i){return typeof i=="string"?{color:i}:{color:i.color,hatch:i.hatch}}function se(i,t,e){let n=oe(i.from,"chartBottom",t),r=oe(i.to,"series",t),{color:o,hatch:s}=Ie(i.fill),a={type:"path",fill:o,hatch:s,stroke:"none",...t.idPrefix&&{id:`${t.idPrefix}-fill-r${e}`}};if(n!==null&&r!==null){let c=t.timeScale.range(),f=c[0],y=c[1],x=Math.min(n,r),b=Math.max(n,r);return [{...a,points:[{x:f,y:x},{x:y,y:x},{x:y,y:b},{x:f,y:b}]}]}let l=n??r,h=[],u=je(i,t);if(u===null){let c=t.valueScale.domain();u=(n??r)===t.chartBottom?c[0]:c[1];}let m=ae(i.outer,t),d=t.shape==="step";for(let c of t.runs){if(c.length<2)continue;let f=d?dt(c):c,y=G.splitByThreshold(f,u,b=>b.value??u,G.interpolateDataPoint),x=i.side==="above"?y.above:i.side==="below"?y.below:[...y.above,...y.below];if(m!==null&&i.side){let b=m,v=i.side==="above"?$=>Math.min($,b):$=>Math.max($,b);x=x.map($=>$.map(A=>({...A,value:v(A.value??b)})));}for(let b of x){if(b.length<2)continue;let v=b.map(A=>({x:t.timeScale.map(A.time),y:t.valueScale.map(A.value)})),$=[];for(let A of [...v].reverse()){let M=$[$.length-1];d&&M&&M.x===A.x||$.push({x:A.x,y:l});}h.push({...a,smoothing:d?false:t.smoothing,smoothCount:v.length,points:[...v,...$]});}}return h}function je(i,t){let e=i.from==="series"?i.to:i.from;return ae(e,t)}function ae(i,t){return i===void 0||i==="series"||i==="chartTop"||i==="chartBottom"?null:typeof i=="object"&&"threshold"in i?t.thresholds.get(i.threshold)?.value??null:typeof i=="object"&&"value"in i?i.value:null}function le(i,t){if(typeof i=="string"||!("regions"in i))return se({fill:i},t,0);let e=[];return i.regions.forEach((n,r)=>{e.push(...se(n,t,r));}),e}function he(i,t){let e=new Array(i.length),n=0;for(let r=0;r<i.length;r++){let o=i[r].time,s=o-t;for(;n<r&&i[n].time<s;)n++;let a=0,l=0;for(let h=n;h<=r;h++){let u=i[h].value;u!==null&&(a+=u,l++);}e[r]={time:o,value:l===0?null:a/l,synthetic:true};}return e}function me(i){let t=i.style?.line,e=t&&!Array.isArray(t)?t:void 0;return {color:e?.color??g.stroke,width:e?.width??g.strokeWidth,dash:e?.style,smoothing:e?.smoothing??false}}function ue(i,t,e,n){let r=i.filter(l=>l.value!==null);if(r.length<2)return [];let o=r.map(l=>({x:t.timeScale.map(l.time),y:t.valueScale.map(l.value)})),s=me(e);return [{type:"path",id:t.idPrefix?`${t.idPrefix}-overlay-${n}`:`overlay-${n}`,points:o,stroke:s.color,strokeWidth:s.width,smoothing:s.smoothing,dash:s.dash,fill:"none"}]}function de(i,t){switch(i.kind){case "movingAverage":{i.type;let e=he(t.data,i.window);return ue(e,t,i,"movingAvg")}case "movingMkt":{let e=qt(t.data,i.window,i.activationEnergy);return ue(e,t,i,"movingMkt")}case "limits":{let e=[],n=t.timeScale.range(),r=n[0],o=n[1],s=me(i),a=s.color,l=s.width,h=s.dash??"dashed",u=t.idPrefix?`${t.idPrefix}-`:"";return i.high!==void 0&&e.push({type:"line",id:`${u}overlay-limit-high`,x1:r,y1:t.valueScale.map(i.high),x2:o,y2:t.valueScale.map(i.high),stroke:a,strokeWidth:l,dash:h}),i.low!==void 0&&e.push({type:"line",id:`${u}overlay-limit-low`,x1:r,y1:t.valueScale.map(i.low),x2:o,y2:t.valueScale.map(i.low),stroke:a,strokeWidth:l,dash:h}),e}case "stdDevBand":{let e=i.multiplier??1,n=he(t.data,i.window),r=Xt(t.data,i.window),o=[],s=[];for(let y=0;y<n.length;y++){let x=n[y].value,b=r[y].value;if(x===null||b===null)continue;let v=t.timeScale.map(n[y].time);o.push({x:v,y:t.valueScale.map(x+e*b)}),s.push({x:v,y:t.valueScale.map(x-e*b)});}if(o.length<2)return [];let a=t.idPrefix?`${t.idPrefix}-`:"",l=[],u=(typeof i.style?.fill=="string"||i.style?.fill&&!("regions"in i.style.fill)?i.style.fill:void 0)??"#94a3b833",{color:m,hatch:d}=Re(u);l.push({type:"path",id:`${a}overlay-stdDevBand`,points:[...o,...[...s].reverse()],fill:m,hatch:d,stroke:"none"});let c=i.style?.line,f=c&&!Array.isArray(c)?c:void 0;if(f){let y=n.filter(x=>x.value!==null).map(x=>({x:t.timeScale.map(x.time),y:t.valueScale.map(x.value)}));y.length>=2&&l.push({type:"path",id:`${a}overlay-stdDevBand-mean`,points:y,stroke:f.color??g.stroke,strokeWidth:f.width??1.5,smoothing:f.smoothing,dash:f.style,fill:"none"});}return l}}}function Re(i){return typeof i=="string"?{color:i}:{color:i.color,hatch:i.hatch}}function We(i){if(!i)return {gaps:[],autoDetect:false,minGapMs:6e4};if(Array.isArray(i))return {gaps:i,autoDetect:false,minGapMs:6e4};let t=i.regions??[],e=i.style;return {gaps:t.map(r=>{let o={...e,...r.style},s=o.fill,a,l;return typeof s=="string"?a=s:s&&(a=s.color,l=s.hatch),{startTime:r.startTime,endTime:r.endTime,label:r.label,fill:a,hatch:l,fillOpacity:o.opacity,labelBaseline:o.label?.baseline,rotate:o.label?.rotate,style:o.display==="filled"||o.display==="bridge_line"?void 0:o.display}}),autoDetect:i.autoDetect??false,minGapMs:i.minGapMs??6e4}}function bt(i){return "showAs"in i&&!!i.showAs}var K=class{_layout;_renderer;_locale;_legend;_clipSeries;_markers;_thresholds;_highlights;_gaps;_gapsAutoDetect;_gapsMinGapMs;_annotations;_annotationBands;_disabledAnnotations=new Set;_annotationSeq=0;_axes;_series;readonly_annotationBandHeight=0;_timeScale;_valueScales=new Map;constructor(t={}){this._layout=new nt({width:t.width??800,height:t.height??400,margin:t.margin??{top:20,right:20,bottom:40,left:60}}).compute(),this._renderer=t.renderer,this._locale=t.locale,this._legend=t.legend,this._clipSeries=t.clipSeries??true,this._markers=t.markers??[],this._thresholds=t.thresholds??[],this._highlights=t.highlights??[];let e=We(t.gaps);this._gaps=e.gaps,this._gapsAutoDetect=e.autoDetect,this._gapsMinGapMs=e.minGapMs,this._annotations=t.annotations??[],this._annotationBands=t.annotationBands??[],this._axes=t.axes,this._series=[],t.series&&this.setData(t.series);}getWidth(){return this._layout.totalWidth}getHeight(){return this._layout.totalHeight+this._annotationBandTotalHeight()}get series(){return this._series}_annotationBandTotalHeight(){let t=0;for(let e of this._annotationBands){let n=e.height??12,r=e.spacing??0;(e.showAxis??false)&&(t+=26+r),t+=n+r;}return t}setData(t){this._series=t.filter(e=>Array.isArray(e.data));}addAnnotation(t){let e=t.id??`anno-${++this._annotationSeq}`;return this._annotations.push({...t,id:e}),e}removeAnnotation(t){let e=this._annotations.length;return this._annotations=this._annotations.filter(n=>n.id!==t),this._disabledAnnotations.delete(t),this._annotations.length<e}setAnnotations(t){this._annotations=[...t],this._disabledAnnotations.clear();}clearAnnotations(){this._annotations=[],this._disabledAnnotations.clear();}getAnnotations(){return this._annotations}disableAnnotation(t){this._disabledAnnotations.add(t);}enableAnnotation(t){this._disabledAnnotations.delete(t);}_axisIndexOf(t){return t.yAxisIndex??0}_timesOf(t){return t.data.map(e=>e.time)}_valuesOf(t){if(bt(t)){let e=[];for(let n of t.data)n.min!==null&&e.push(n.min),n.max!==null&&e.push(n.max);return e}return t.data.map(e=>e.value).filter(e=>e!==null)}renderCommands(){if(this._series.length===0)return [];let t=this._legendItems(),e=(this._legend?.show??false)&&t.length>0,n=this._legend?.position??"inside-right",r=this._legend?.orientation??"vertical",o=e?ne(t,r):{width:0},s=this._layout;if(e&&(n==="outside-right"||n==="outside-left")){let p=o.width+16,S={...this._layout.margin};n==="outside-right"?S.right+=p:S.left+=p,s=new nt({width:this._layout.totalWidth,height:this._layout.totalHeight,margin:S}).compute();}let{chartX:a,chartY:l,chartWidth:h,chartHeight:u}=s,m=[a,a+h],d=[l,l+u],c=[];for(let p of this._series)p.data.sort((S,_)=>S.time-_.time);let f=new Map,y=1/0,x=-1/0,b=false;for(let p of this._series){let S=this._axisIndexOf(p),_=f.get(S);_?_.push(p):f.set(S,[p]);for(let D of this._timesOf(p))D<y&&(y=D),D>x&&(x=D),b=true;}if(!b)return [];let v=this._axes?.x?.domain,$=v&&v!=="auto"?v:[y,x];this._timeScale=new J({domain:$,range:m,locale:this._locale});let A=p=>({axisColor:p?.color??g.axisColor,tickColor:p?.color??g.tickColor,textColor:g.textColor,textSize:g.textSize,axisWidth:p?.width??1}),M=new tt({domain:$,xRange:m,y:l+u,locale:this._locale,format:this._axes?.x?.format,maxTicks:this._axes?.x?.ticks?.major,colors:A(this._axes?.x?.axis)});this._valueScales.clear();let V=Array.from(f.keys()).sort((p,S)=>p-S),R,w=0,k=0;for(let p of V){let S=f.get(p),_=1/0,D=-1/0,j=false;for(let N of S)for(let lt of this._valuesOf(N))lt<_&&(_=lt),lt>D&&(D=lt),j=true;if(!j)continue;_===D&&(_-=1,D+=1);let H;this._axes?.y&&this._axes.y.length>p?H=this._axes.y[p]:p===0?H=this._axes?.left:p===1&&(H=this._axes?.right);let At=H?.domain,Z=At&&At!=="auto"?At:[_,D],Ot=new X({domain:Z,range:[l+u,l]});this._valueScales.set(p,Ot);let Nt=this._thresholds.filter(N=>(N.axisIndex??0)===p&&N.label!==void 0&&N.label!==null&&N.label!==false&&N.value>=Math.min(Z[0],Z[1])&&N.value<=Math.max(Z[0],Z[1])).map(N=>Ot.map(N.value)),Dt=H?.position??(p===0?"left":"right"),Lt;if(Dt==="right"){let N=H?.offset??k*50;Lt=a+h+N,k++;}else {let N=H?.offset??w*50;Lt=a-N,w++;}let Et=new ut({domain:Z,range:[l+u,l],x:Lt,position:Dt,format:H?.format,ticks:H?.ticks?.major,colors:A(H?.axis),suppressLabelsNear:Nt.length?Nt:void 0});p===0&&(R=Et),c.push({type:"group",cssClass:`value-axis ${Dt}`,commands:Et.render()});}let L=this._valueScales.get(0)??this._valueScales.get(V[0]);c.push({type:"group",cssClass:"time-axis",commands:M.render()});let P=null,F=this._axes?.x?.grid?.major,W=this._axes?.left?.grid?.major;if(F!==void 0||W!==void 0){let p=F!==false,S=W!==false&&!!R,_=p?M.generateTicks().map(j=>j.x):void 0,D=S?R.generateTicks().map(j=>j.position):void 0;if(_||D){let j=(F&&typeof F=="object"?F:void 0)??(W&&typeof W=="object"?W:void 0);P={type:"group",cssClass:"chart-grid",commands:re({xTicks:_,yTicks:D,xRange:m,yRange:d,stroke:j?.color,opacity:j?.opacity,dashed:j?.style==="dashed"})};}}if(this._highlights.length>0&&c.push({type:"group",cssClass:"highlights",commands:Qt({highlights:this._highlights,timeScale:this._timeScale,yRange:d,height:s.totalHeight})}),this._thresholds.length>0&&L){let p=[],S=[];for(let _ of this._thresholds){let D=_.id??it(_.name),j=this._valueScales.get(_.axisIndex??0)??L,H=Zt({thresholds:[_],valueScale:j,xRange:m});H.inside.length&&p.push({type:"group",cssClass:`threshold threshold--${D}`,id:`threshold-${D}`,commands:H.inside}),H.labels.length&&S.push({type:"group",cssClass:`threshold-label threshold-label--${D}`,commands:H.labels});}p.length&&c.push({type:"group",cssClass:"thresholds",commands:p,clipRect:{x:a,y:l,w:h,h:u}}),S.length&&c.push({type:"group",cssClass:"threshold-labels",commands:S});}let C=this._gaps;if(this._gapsAutoDetect){let p=[];for(let S of this._series)bt(S)||p.push(...Yt(S.data,this._gapsMinGapMs));p.length>0&&(C=[...this._gaps,...p]);}C.length>0&&c.push({type:"group",cssClass:"gaps",commands:Jt({gaps:C,timeScale:this._timeScale,yRange:d})});let I=new Map(this._thresholds.map(p=>[p.id??p.name,p]));for(let p of this._series){if(p.data.length===0)continue;let S=this._valueScales.get(this._axisIndexOf(p));if(!S)continue;let _=it(p.id??p.name);c.push({type:"group",cssClass:`series series--${_}`,id:`series-${_}`,commands:this._renderSeries(p,S,I),...this._clipSeries?{clipRect:{x:a,y:l,w:h,h:u}}:{}});}P&&c.push(P);let z=this._markers.map(p=>({...p}));for(let p of z)if(p.value===void 0&&(p.lineStyle==="to-value"||p.lineStyle==="to-top")){let S=this._series[p.seriesIndex??0];S&&!bt(S)&&S.data.length>=2&&(p.value=this._interpolateValue(p.time,S.data));}if(z.length>0&&L){let p=[];for(let S of z){let _=L,D=this._series[S.seriesIndex??0];D&&(_=this._valueScales.get(this._axisIndexOf(D))??L),p.push(...te({markers:[S],timeScale:this._timeScale,valueScale:_,yRange:d}));}c.push({type:"group",cssClass:"markers",commands:p});}let B=this._annotations.filter(p=>!p.id||!this._disabledAnnotations.has(p.id));if(B.length>0&&c.push({type:"group",cssClass:"annotations",commands:ee({annotations:B,timeScale:this._timeScale,valueScales:this._valueScales})}),this._annotationBands.length>0){let p=l+u+this._layout.margin.bottom,S=0;this._annotationBands.forEach(_=>{let D=_.height??12,j=_.spacing??0,H=p+S;(_.showAxis??false)&&(S+=26+j),S+=D+j,c.push({type:"group",cssClass:"annotation-band",commands:new gt({name:_.name,showAxis:_.showAxis??false,items:_.items,timeScale:this._timeScale,background:_.background,hatch:_.hatch},[a,a+h],H,D).render()});});}if(e&&n!=="separate"){let p,S;n==="inside-right"?(p=a+h-o.width-8,S=l+8):n==="inside-left"?(p=a+8,S=l+8):n==="outside-right"?(p=a+h+16,S=l):(p=8,S=l),c.push(ie({items:t,x:p,y:S,orientation:r}));}let T=this._axes?.left?.label,O=this._axes?.right?.label,E=this._axes?.x?.label;if(T||O||E){let p=[],S=l+u/2,_=this._axes?.left?.labels,D=this._axes?.right?.labels,j=this._axes?.x?.labels;T&&p.push({type:"text",content:T,x:14,y:S,anchor:"middle",fontSize:_?.fontSize??g.axisLabelSize,fill:_?.color??g.axisLabelColor,rotate:-90}),O&&p.push({type:"text",content:O,x:s.totalWidth-14,y:S,anchor:"middle",fontSize:D?.fontSize??g.axisLabelSize,fill:D?.color??g.axisLabelColor,rotate:90}),E&&p.push({type:"text",content:E,x:a+h/2,y:s.totalHeight-6,anchor:"middle",fontSize:j?.fontSize??g.axisLabelSize,fill:j?.color??g.axisLabelColor}),p.length&&c.push({type:"group",cssClass:"axis-labels",commands:p});}return c}_renderSeries(t,e,n){let r=this._timeScale,o={timeScale:r,valueScale:e};if(bt(t)){let w=t.style?.line&&!Array.isArray(t.style.line)?t.style.line:void 0,k=typeof t.style?.fill=="string"?t.style.fill:void 0;return t.showAs==="minmaxavg"?new pt({data:t.data,timeScale:r,valueScale:e,minColor:t.minColor,maxColor:t.maxColor,avgColor:t.avgColor,avgDashed:t.avgDashed,fillToMax:t.fillToMax,fillToMaxHatch:t.fillToMaxHatch,fillToMin:t.fillToMin,fillToMinHatch:t.fillToMinHatch,smoothing:w?.smoothing,strokeWidth:w?.width,id:rt(t.name,t.id)}).render():new ft({data:t.data,timeScale:r,valueScale:e,fill:k??w?.color,avgLine:t.avgLine,countOpacity:t.countOpacity,id:rt(t.name,t.id)}).render()}let s=t,a=t.style?.line&&!Array.isArray(t.style.line)?t.style.line:void 0,l=a?.gapThreshold??g.gapThreshold,h=G.getRuns(t.data,w=>w.value===null,l),u=h.reduce((w,k)=>w+k.length,0);if(u===0)return [];let m=[],d=t.style?.markers,c=t.style?.shadow,f={stroke:a?.color??g.stroke,strokeWidth:a?.width??g.strokeWidth,smoothing:a?.smoothing,dashed:a?.style==="dashed",pointStyle:d?.type,pointSize:d?.size,pointStroke:d?.stroke,pointFill:d?.fill,pointStrokeWidth:d?.strokeWidth,shadowColor:c?.color,shadowBlur:c?.blur,shadowOffsetX:c?.offsetX,shadowOffsetY:c?.offsetY,id:rt(t.name,t.id)},y=t.style?.line,b=((Array.isArray(y)?y[0]:a)?.shape??s.seriesType)==="step",v=t.style?.fill;if(v!==void 0){let w=e.range(),k=Math.min(w[0],w[1]),L=Math.max(w[0],w[1]);m.push(...le(v,{runs:h,timeScale:r,valueScale:e,thresholds:n,chartTop:k,chartBottom:L,smoothing:a?.smoothing,shape:b?"step":"line",idPrefix:t.id}));}let $=s.colorByThresholds??[],A=$.map(w=>n.get(w)).filter(w=>!!w).map(w=>w.value).sort((w,k)=>w-k),M=(w,k,L)=>{let P=L??f.stroke,F=Number.NEGATIVE_INFINITY;for(let W of k){let C=n.get(W);!C||w<C.value||C.value<F||(F=C.value,P=C.color??P);}return P};for(let w of h){let P=function(C){return G.splitByBoundaries(C==="step"?dt(w):w,A,I=>I.value,G.interpolateDataPoint)};if(w.length<2)continue;let k=rt(s.name,s.id),L=new Map,F=C=>{let I=L.get(C);return I||(I=P(C),L.set(C,I)),I},W=(C,I,z)=>{let B=F(C);for(let T=0;T<B.length;T++){let O=B[T];if(O.data.length<2)continue;let E=O.zoneLow;m.push({type:"path",id:k?`${k}-line-${T}${z}`:void 0,points:O.data.map(p=>({x:r.map(p.time),y:e.map(p.value)})),stroke:M(E,$,I.color),strokeWidth:I.width??f.strokeWidth,smoothing:C==="step"?false:I.smoothing??f.smoothing,dash:I.style,opacity:I.opacity,fill:"none",shadowColor:f.shadowColor,shadowBlur:f.shadowBlur,shadowOffsetX:f.shadowOffsetX,shadowOffsetY:f.shadowOffsetY});}};y===false||(Array.isArray(y)?y.forEach((C,I)=>{W(C.shape??(s.seriesType==="step"?"step":"line"),C,`-${I}`);}):W(b?"step":"line",y??{},"")),f.pointStyle&&f.pointStyle!=="none"&&u<=(d?.threshold??g.pointThreshold)&&m.push(...Kt(w,o,f,C=>M(C.value,$)));}let V=t.overlays;if(V&&V.length>0){let w=e.range(),k={data:t.data,timeScale:r,valueScale:e,chartTop:Math.min(w[0],w[1]),chartBottom:Math.max(w[0],w[1]),idPrefix:t.id};for(let L of V)m.push(...de(L,k));}if(t.style?.gap&&h.length>1){let w=e.range(),k=Math.min(w[0],w[1]),L=Math.max(w[0],w[1]),P=t.style.gap,F=P.fill,W,C;typeof F=="string"?W=F:F&&(W=F.color,C=F.hatch);let I=P.opacity??.15,z=P.bridge;for(let B=1;B<h.length;B++){let T=h[B-1][h[B-1].length-1],O=h[B][0],E=r.map(T.time),p=r.map(O.time);if(P.display==="bridge_line"){if(T.value===null||O.value===null)continue;let S=e.map(T.value),_=e.map(O.value);m.push({type:"line",x1:E,y1:S,x2:p,y2:_,stroke:z?.color??(typeof t.style?.line=="object"&&!Array.isArray(t.style.line)?t.style.line.color:void 0)??g.stroke,strokeWidth:z?.width??1.5,dash:z?.style??"dotted"});}else W!==void 0?m.push({type:"rect",x:E,y:k,w:p-E,h:L-k,fill:W,hatch:C,opacity:I,stroke:"none"}):P.display!=="empty"&&m.push({type:"rect",x:E,y:k,w:p-E,h:L-k,stroke:g.gapStroke,strokeWidth:1,dashed:true,fill:"none"});}}return m}_interpolateValue(t,e){for(let n=1;n<e.length;n++){let r=e[n-1],o=e[n];if(!(r.value===null||o.value===null)&&t>=r.time&&t<=o.time){if(o.time===r.time)return r.value;let s=(t-r.time)/(o.time-r.time);return r.value+s*(o.value-r.value)}}}legendItems(){return this._legendItems()}_legendItems(){return this._series.map(t=>{let e=t.style?.line&&!Array.isArray(t.style.line)?t.style.line:void 0,n=t.style?.markers,r=n?.type&&n.type!=="none"&&(n.threshold===void 0||(t.data?.length??0)<=n.threshold);return {name:t.name,color:e?.color??g.stroke,line:e?.style,marker:r?n.type:void 0}})}get renderer(){return this._renderer}get layout(){return this._layout}get timeScale(){return this._timeScale}get valueScales(){return this._valueScales}invertTime(t){return this._timeScale?this._timeScale.invert(t):0}invertValue(t,e=0){let n=this._valueScales.get(e);return n?n.invert(t):0}project(t,e,n=0){let r=this._timeScale?this._timeScale.map(t):0,o=this._valueScales.get(n);return {x:r,y:o?o.map(e):0}}};var xt=class{};function He(i){switch(i){case "top":return "text-top";case "bottom":return "text-bottom";default:return "middle"}}var q=class extends xt{#t="100%";#e="100%";#n;#i=new Map;#r=new Map;#o=new Map;constructor(t){super(),t?.width!==void 0&&(this.#t=t.width),t?.height!==void 0&&(this.#e=t.height),t?.background!==void 0&&(this.#n=t.background);}setBackgroundColor(t){this.#n=t;}render(t){this.#i.clear(),this.#r.clear(),this.#o.clear();let e=t.map(h=>this._toSVG(h));this.#n&&e.unshift(`<rect width="100%" height="100%" fill="${this._esc(this.#n)}" />`);let n=e.join(`
|
|
24
|
+
`.trim()}function Ie(i,e=2,t=false){return i==="dashed"||!i&&t?{strokeDasharray:"4,4"}:i==="dotted"?{strokeDasharray:"2,4"}:!i||i==="solid"?null:et(i,e)}function et(i,e=2){let t=e;switch(i){case "dotted":return {strokeDasharray:`0, ${t*2}`,strokeLinecap:"round"};case "sparse-dots":return {strokeDasharray:`0, ${t*4}`,strokeLinecap:"round"};case "dashed":return {strokeDasharray:`${t*3}, ${t*2}`,strokeLinecap:"butt"};case "long-dash":return {strokeDasharray:`${t*6}, ${t*3}`,strokeLinecap:"butt"};case "dense-dash":return {strokeDasharray:`${t*1.5}, ${t*1.5}`,strokeLinecap:"butt"};case "dash-dot":return {strokeDasharray:`${t*4}, ${t*2}, 0, ${t*2}`,strokeLinecap:"round"};case "dash-dot-dot":return {strokeDasharray:`${t*5}, ${t*2}, 0, ${t*2}, 0, ${t*2}`,strokeLinecap:"round"};case "loose-dash":return {strokeDasharray:`${t*3}, ${t*4}`,strokeLinecap:"butt"};default:return {strokeDasharray:"none",strokeLinecap:"butt"}}}var p=new Proxy({},{get:(i,e)=>ne()[e],has:(i,e)=>e in ne(),ownKeys:()=>Reflect.ownKeys(ne()),getOwnPropertyDescriptor:(i,e)=>Reflect.getOwnPropertyDescriptor(ne(),e)});var ae={axisColor:p.axisColor,tickColor:p.tickColor,textColor:p.textColor,textSize:p.textSize},ie=class{#e;#t;constructor(e){this.#e=new te({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??ae).axisColor}get tickColor(){return (this.#t.colors??ae).tickColor}get textColor(){return (this.#t.colors??ae).textColor}get textSize(){return (this.#t.colors??ae).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??ae,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 a of e)r.push({type:"line",x1:a.x,y1:n,x2:a.x,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),r.push({type:"text",content:a.label,x:a.x,y:n+t.textSize+6,anchor:"middle",fontSize:t.textSize,fill:t.textColor});return r}};var le={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function Bt(i){return Math.abs(i)>=1e6?`${(i/1e6).toFixed(1)}M`:Math.abs(i)>=1e3?`${(i/1e3).toFixed(1)}k`:Number.isInteger(i)?String(i):i.toFixed(1)}function jt(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 ce=class{#e;#t;constructor(e){this.#e=new Z({domain:e.domain,range:e.range}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??le).axisColor}get tickColor(){return (this.#t.colors??le).tickColor}get textColor(){return (this.#t.colors??le).textColor}get textSize(){return (this.#t.colors??le).textSize}generateTicks(){let e=this.#t.format??Bt,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),a=s-o;if(a===0)return [{value:n,position:this.#e.map(n),label:e(n)}];let l=a/t,h=Math.pow(10,Math.floor(Math.log10(l))),m=l/h,u;if(m<=1.5?u=h:m<=3?u=2*h:m<=7?u=5*h:u=10*h,u<=0||!Number.isFinite(u))return [{value:n,position:this.#e.map(n),label:e(n)}];let d=[],c=Math.ceil(o/u)*u;for(let g=c;g<=s;g+=u)d.push({value:g,position:this.#e.map(g),label:e(g)});return d}render(){let e=this.generateTicks(),t=this.#t.colors??le,n=this.#t.x??0,r=this.#t.orientation??"vertical",o=this.#t.position??"left",s=this.#t.suppressLabelsNear??[],a=this.#t.suppressTolerancePx??8,l=m=>s.some(u=>Math.abs(u-m)<=a),h=[];if(r==="vertical"){let[m,u]=this.#e.range();h.push({type:"line",x1:n,y1:m,x2:n,y2:u,stroke:t.axisColor,strokeWidth:t.axisWidth});let d=jt(e);e.forEach((c,g)=>{let y=l(c.position),x=d[g]?{opacity:0}:{};o==="left"?(h.push({type:"line",x1:n-4,y1:c.position,x2:n,y2:c.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),y||h.push({type:"text",content:c.label,x:n-8,y:c.position+4,anchor:"end",fontSize:11,fill:t.textColor,...x})):(h.push({type:"line",x1:n,y1:c.position,x2:n+4,y2:c.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),y||h.push({type:"text",content:c.label,x:n+8,y:c.position+4,anchor:"start",fontSize:11,fill:t.textColor,...x}));});}else {let[m,u]=this.#e.range();h.push({type:"line",x1:m,y1:n,x2:u,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let d of e)h.push({type:"line",x1:d.position,y1:n,x2:d.position,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),h.push({type:"text",content:d.label,x:d.position,y:n+18,anchor:"middle",fontSize:t.textSize,fill:t.textColor});}return h}};var z=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))}}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((a,l)=>a.time-l.time),r=[],o=[],s=null;for(let a of n){let l=e(a),h=t>0&&s&&a.time-s.time>t;(l||h)&&o.length&&(r.push(o),o=[]),l||o.push(a),s=a;}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((h,m)=>h-m),o=[],s=h=>h<=0?Number.NEGATIVE_INFINITY:r[h-1],a=h=>{let m=0;for(let u=0;u<r.length&&h>=r[u];u++)m=u+1;return m},l=[i[0]];for(let h=1;h<i.length;h++){let m=i[h-1],u=i[h],d=t(m),c=t(u),g;c>d?g=r.filter(x=>x>d&&x<=c):c<d?g=r.filter(x=>x>=c&&x<d).reverse():g=[];let y=d;for(let x of g){let k=(x-d)/(c-d),D=n(m,u,k);l.push(D);let R=a((y+x)/2);o.push({data:l,zoneIndex:R,zoneLow:s(R)}),l=[D],y=x;}(g.length===0||g[g.length-1]!==c)&&l.push(u);}if(l.length>1){let h=t(l[0]),m=t(l[l.length-1]),u=a((h+m)/2);o.push({data:l,zoneIndex:u,zoneLow:s(u)});}return o}static splitByThreshold(i,e,t,n){let r=this.splitByBoundaries(i,[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}};function tt(i,e=6e4){if(i.length<2)return [];let t=[...i].sort((r,o)=>r.time-o.time),n=[];for(let r=1;r<t.length;r++)t[r].time-t[r-1].time>e&&n.push({startTime:t[r-1].time,endTime:t[r].time});return n}function It(i,e=83144){let t=e/8.314,n=0,r=0;for(let s of i)s!==null&&(n+=Math.exp(-t/(s+273.15)),r++);if(r===0)return null;let o=n/r;return t/-Math.log(o)-273.15}function nt(i,e,t=83144){let n=new Array(i.length),r=0;for(let o=0;o<i.length;o++){let s=i[o].time,a=s-e;for(;r<o&&i[r].time<a;)r++;let l=i.slice(r,o+1).map(m=>m.value),h=It(l,t);n[o]={time:s,value:h,synthetic:true};}return n}function Ot(i){let e=0,t=0;for(let o of i)o!==null&&(e+=o,t++);if(t===0)return null;let n=e/t,r=0;for(let o of i){if(o===null)continue;let s=o-n;r+=s*s;}return Math.sqrt(r/t)}function Wt(i){let e=0,t=0;for(let o of i)o!==null&&(e+=o,t++);if(t<2)return null;let n=e/t,r=0;for(let o of i){if(o===null)continue;let s=o-n;r+=s*s;}return Math.sqrt(r/(t-1))}function it(i,e,t=false){let n=new Array(i.length),r=0,o=t?Wt:Ot;for(let s=0;s<i.length;s++){let a=i[s].time,l=a-e;for(;r<s&&i[r].time<l;)r++;let h=i.slice(r,s+1).map(u=>u.value),m=o(h);n[s]={time:a,value:m,synthetic:true};}return n}function Oe(i,e){let t=new Array(i.length),n=0;for(let r=0;r<i.length;r++){let o=i[r].time,s=o-e;for(;n<r&&i[n].time<s;)n++;let a=0,l=0;for(let h=n;h<=r;h++){let m=i[h].value;m!==null&&(a+=m,l++);}t[r]={time:o,value:l===0?null:a/l,synthetic:true};}return t}function rt(i,e){let t=new Array(i.length),n=null,r=0;for(let o=0;o<i.length;o++){let s=i[o].time,a=i[o].value;if(a===null){t[o]={time:s,value:n,synthetic:true};continue}if(n===null||e<=0)n=a;else {let l=1-Math.exp(-(s-r)/e);n=a*l+n*(1-l);}r=s,t[o]={time:s,value:n,synthetic:true};}return t}function ot(i){return {id:i.id,line:{stroke:i.stroke??p.stroke,strokeWidth:i.strokeWidth??p.strokeWidth,smoothing:i.smoothing??false,dashed:i.dashed??false},fill:i.fill??p.areaFillAlpha,markers:{type:i.pointStyle??"none",size:i.pointSize??p.pointSize,stroke:i.stroke??p.stroke,fill:"#ffffff"},shadow:{color:i.shadowColor??"transparent",blur:i.shadowBlur??0,offsetX:i.shadowOffsetX??0,offsetY:i.shadowOffsetY??0}}}function pe(i,e,t){let n=[],r=i.reduce((s,a)=>s+a.data.length,0),o=ot(t);for(let s=0;s<i.length;s++){let a=i[s];a.data.length>=2?n.push({type:"path",cssClass:"series-line",id:t.id?`${t.id}-line-${s}`:void 0,points:a.data.map(l=>({x:e.timeScale.map(l.time),y:e.valueScale.map(l.value)})),stroke:a.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"}):a.data.length===1&&r===1&&n.push({type:"circle",cx:e.timeScale.map(a.data[0].time),cy:e.valueScale.map(a.data[0].value),r:Math.max(o.markers.size,o.line.strokeWidth),fill:a.color??o.line.stroke,shadowColor:o.shadow.color,shadowBlur:o.shadow.blur});}return n}function re(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 We(i,e,t,n){if(i.length<2)return [];let r=z.splitByBoundaries(i,t.boundaries,t.getValue,t.interpolate),o=[];for(let s=0;s<r.length;s++){let a=r[s];if(a.data.length<2)continue;let l=t.getColor(a.zoneIndex);if(!l)continue;let h=a.data.map(u=>({x:e.timeScale.map(u.time),y:e.valueScale.map(t.yLow(u))})),m=a.data.map(u=>({x:e.timeScale.map(u.time),y:e.valueScale.map(t.yHigh(u))})).reverse();o.push({type:"path",cssClass:"series-fill",id:n?.id?`${n.id}-fill-${s}`:void 0,points:[...h,...m],fill:l,hatch:t.getHatch?.(a.zoneIndex),stroke:"none"});}return o}function st(i,e,t,n){let r=ot(t);if(!r.markers.type||r.markers.type==="none")return [];let o=[];for(let s=0;s<i.length;s++){let a=i[s],l=e.timeScale.map(a.time),h=e.valueScale.map(a.value),m=n(a),u=t.pointStroke??m,d=t.pointFill??m,c=t.pointStrokeWidth??1.5,g=t.id?`${t.id}-marker-${s}`:void 0;fe(o,g,r.markers.type,l,h,r.markers.size,u,d,c);}return o}function fe(i,e,t,n,r,o,s,a,l){switch(t){case "circle":i.push({type:"circle",cx:n,cy:r,r:o,fill:a,stroke:s,strokeWidth:l,id:e});break;case "square":i.push({type:"rect",x:n-o,y:r-o,w:o*2,h:o*2,fill:a,stroke:s,strokeWidth:l,id:e});break;case "cross":i.push({type:"line",x1:n-o,y1:r-o,x2:n+o,y2:r+o,stroke:s,strokeWidth:l,id:e},{type:"line",x1:n-o,y1:r+o,x2:n+o,y2:r-o,stroke:s,strokeWidth:l,id:e});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:a,stroke:s,strokeWidth:l,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:a,stroke:s,strokeWidth:l,id:e});break;case "star":{let h=[];for(let m=0;m<10;m++){let u=m%2===0?o:o*.5,d=Math.PI/2*3+m*Math.PI/5;h.push({x:n+u*Math.cos(d),y:r+u*Math.sin(d)});}i.push({type:"path",points:h,closed:true,fill:a,stroke:s,strokeWidth:l,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:s,strokeWidth:l,fill:"none",id:e});break;case "plus":i.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:s,strokeWidth:l,id:e},{type:"line",x1:n,y1:r-o,x2:n,y2:r+o,stroke:s,strokeWidth:l,id:e});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:a,stroke:s,strokeWidth:l,id:e});break;case "hexagon":{let h=[];for(let m=0;m<6;m++){let u=m*(Math.PI/3);h.push({x:n+o*Math.cos(u),y:r+o*Math.sin(u)});}i.push({type:"path",points:h,closed:true,fill:a,stroke:s,strokeWidth:l,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:a,stroke:s,strokeWidth:l,id:e});break;case "line-horizontal":i.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:s,strokeWidth:l,id:e});break;default:i.push({type:"circle",cx:n,cy:r,r:o,fill:a,stroke:s,strokeWidth:l,id:e});}}var oe=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 ge=class extends oe{#e;constructor(e){super(e,e.data),this.#e=e;}render(){let e=this.#e,t=e.minColor??p.minColor,n=e.maxColor??p.maxColor,r=e.avgColor??p.avgColor,o=e.avgDashed??true,s=e.smoothing??false,a=e.strokeWidth??p.strokeWidth,l=z.getRuns(this.data,c=>c.min===null||c.max===null||c.avg===null);if(l.length===0)return [];let h={timeScale:this.timeScale,valueScale:e.valueScale},m=[];l.forEach((c,g)=>{c.length<2||(e.fillToMax&&m.push(...We(c,h,{boundaries:[],yLow:y=>y.avg,yHigh:y=>y.max,getValue:y=>y.avg,interpolate:z.interpolateAggregatedPoint,getColor:()=>e.fillToMax,getHatch:()=>e.fillToMaxHatch},{id:this.id?`${this.id}-fillToMax-${g}`:void 0})),e.fillToMin&&m.push(...We(c,h,{boundaries:[],yLow:y=>y.avg,yHigh:y=>y.min,getValue:y=>y.avg,interpolate:z.interpolateAggregatedPoint,getColor:()=>e.fillToMin,getHatch:()=>e.fillToMinHatch},{id:this.id?`${this.id}-fillToMin-${g}`:void 0})));});let u=l.filter(c=>c.length>=2),d=c=>u.map(g=>({data:g.map(y=>({time:y.time,value:c(y)}))}));return m.push(...pe(d(c=>c.max),h,{stroke:n,strokeWidth:a,smoothing:s,id:this.id?`${this.id}-max`:void 0}),...pe(d(c=>c.min),h,{stroke:t,strokeWidth:a,smoothing:s,id:this.id?`${this.id}-min`:void 0}),...pe(d(c=>c.avg),h,{stroke:r,strokeWidth:a,smoothing:s,dashed:o,id:this.id?`${this.id}-avg`:void 0})),m}};var ye=class extends oe{#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??p.bandFill,n=e.hatch,r=e.avgLine??false,o=e.avgLineColor??p.bandAvgLine,s=e.bandWidth??10,a=[];for(let l of this.data){if(l.min===null||l.max===null)continue;let h=this.timeScale.map(l.time),m=e.valueScale.map(l.max),u=e.valueScale.map(l.min),d=s,c=this.data.indexOf(l);if(a.push({type:"rect",x:h-d/2,y:m,w:d,h:u-m,fill:t,hatch:n,opacity:this.opacity(l.count),id:this.id?`${this.id}-slot-${c}`:void 0}),r&&l.avg!==null){let g=e.valueScale.map(l.avg);a.push({type:"line",x1:h-d/2,y1:g,x2:h+d/2,y2:g,stroke:o,strokeWidth:1,id:this.id?`${this.id}-avg-${c}`:void 0});}}return a}};function Ht(i){return i==="dotted"?{dash:"dotted"}:i==="dashed"?{dash:"dashed"}:{}}function at(i){let{thresholds:e,valueScale:t,xRange:n}=i,[r,o]=n,[s,a]=t.range(),l=Math.min(s,a),h=Math.max(s,a),m=[],u=[];for(let d of e){let c=d.color??p.thresholdColor,g=t.map(d.value);d.fill==="above"?m.push({type:"rect",x:r,y:l,w:o-r,h:Math.max(0,g-l),fill:c,hatch:d.fillHatch,opacity:d.fillOpacity??.12,id:d.id?`${d.id}-fill`:void 0}):d.fill==="below"&&m.push({type:"rect",x:r,y:g,w:o-r,h:Math.max(0,h-g),fill:c,hatch:d.fillHatch,opacity:d.fillOpacity??.12,id:d.id?`${d.id}-fill`:void 0});let y=d.line??p.thresholdLine;if(y!=="none"){let x=Ht(y),k={type:"line",x1:r,y1:g,x2:o,y2:g,stroke:c,strokeWidth:1,...x,id:d.id?`${d.id}-line`:void 0};d.shadowColor&&(k.shadowColor=d.shadowColor,k.shadowBlur=d.shadowBlur??4,k.shadowOffsetX=d.shadowOffsetX??0,k.shadowOffsetY=d.shadowOffsetY??2),m.push(k);}if(d.label!==void 0&&d.label!==null&&d.label!==false){let x=typeof d.label=="object"?d.label:void 0,k=typeof d.label=="string"?d.label:x?.text??d.name,D=x?.position??"right";u.push({...Et(k,D,r,o,g,c,x),id:d.id?`${d.id}-label`:void 0});}}return {inside:m,labels:u}}function Et(i,e,t,n,r,o,s){let a=(t+n)/2,l={type:"text",content:i,fontSize:p.thresholdFontSize,fill:o},h=s?{...s.rotate!==void 0&&{rotate:s.rotate},...s.textBaseline!==void 0&&{textBaseline:s.textBaseline}}:{};switch(e){case "left":return {...l,...h,x:t+4,y:r-4,anchor:"start"};case "above":return {...l,...h,x:a,y:r-6,anchor:"middle"};case "below":return {...l,...h,x:a,y:r+14,anchor:"middle"};case "center":return {...l,...h,x:a,y:r-4,anchor:"middle"};case "outside-left":return {...l,...h,x:t-6,y:r+3,anchor:"end",textBaseline:h.textBaseline??"middle"};case "outside-right":return {...l,...h,x:n+6,y:r+3,anchor:"start",textBaseline:h.textBaseline??"middle"};default:return {...l,...h,x:n-4,y:r-4,anchor:"end"}}}function lt(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 be(i){let{ranges:e,timeScale:t,yRange:n,height:r}=i,[o,s]=n,a=[];for(let l of e){let h=t.map(l.startTime),m=t.map(l.endTime);if(l.fill!==void 0&&a.push({type:"rect",x:h,y:o,w:m-h,h:s-o,fill:l.fill,hatch:l.hatch,opacity:l.opacity}),l.edges)for(let u of [h,m])a.push({type:"line",x1:u,y1:o,x2:u,y2:s,stroke:l.edges.stroke,strokeWidth:l.edges.strokeWidth,dash:"dashed"});l.label&&a.push({type:"text",content:l.label,x:(h+m)/2,y:lt(l.labelPosition??"middle",o,s,r),anchor:"middle",fontSize:l.fontSize,fill:l.labelColor,rotate:l.rotate});}return a}function He(i){let{gaps:e,timeScale:t,yRange:n,height:r,fill:o=p.gapFill,hatch:s,fillOpacity:a=p.gapFillOpacity??.15,stroke:l=p.gapStroke,strokeWidth:h=p.gapStrokeWidth,dashed:m=true,fontSize:u=p.gapFontSize,fontFill:d=p.gapFontColor,labelBaseline:c="middle",labelRotate:g}=i;return be({timeScale:t,yRange:n,height:r,ranges:e.map(y=>{let x=y.style??"dashed_border",k=x==="filled"||x==="dashed_border",D=x==="dashed_border"&&m!==false;return {startTime:y.startTime,endTime:y.endTime,...k&&{fill:y.fill??o,hatch:y.hatch??s,opacity:y.fillOpacity??a},...D&&{edges:{stroke:l,strokeWidth:h}},label:y.label,labelPosition:y.labelBaseline??c,labelColor:d,fontSize:u,rotate:y.rotate??g}})})}var Nt=1,xe=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:a,height:l}=this.#e,h=[];n&&h.push({type:"rect",x:s[0],y:a,w:s[1]-s[0],h:l,fill:n,opacity:.04,stroke:"#ddd",strokeWidth:.25});for(let m of e){let u=t.map(m.startTime),d=t.map(m.endTime);if(d<s[0]||u>s[1])continue;let c=Math.max(s[0],Math.min(s[1],u)),g=Math.max(s[0],Math.min(s[1],d)),y=Math.max(g-c,Nt);c+y>s[1]&&(c=Math.max(s[0],s[1]-y));let x=c+y/2;if(h.push({type:"rect",x:c,y:a,w:y,h:l,hatch:m.hatch??r,fill:m.fill??"#6b728044",stroke:m.stroke,strokeWidth:m.strokeWidth??0,title:m.title}),m.label){let k=m.labelFontSize??10;h.push({type:"text",content:m.label,x,y:this.#t(m.labelBaseline,k),anchor:"middle",fontSize:k,fill:m.labelFill??"#333"});}}if(o){let m=new ie({domain:t.domain(),xRange:s,y:a+l+4});h.push({type:"group",cssClass:"annotation-band-axis",commands:m.render()});}return h}#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}}};function ht(i){let{highlights:e,timeScale:t,yRange:n,height:r}=i;return be({timeScale:t,yRange:n,height:r,ranges:e.map(o=>({startTime:o.startTime,endTime:o.endTime,fill:o.color??p.highlightColor,opacity:o.opacity??p.highlightOpacity,label:o.label,labelPosition:o.labelPosition??"top",labelColor:o.color??p.highlightLabelColor,fontSize:p.annotationFontSize,rotate:o.rotate}))})}function mt(i){let{markers:e,timeScale:t,valueScale:n,yRange:r=[0,300]}=i,[o,s]=r,a=[];for(let l of e){let h=t.map(l.time),m=l.color??p.markerColor,u=l.pointStyle??(l.value!==void 0?"circle":"none"),d=l.lineStyle??"full";if(l.value!==void 0){let c=n.map(l.value);if(d==="to-value"?a.push({type:"line",x1:h,y1:s,x2:h,y2:c,stroke:m,strokeWidth:1,dashed:true}):d==="to-top"?a.push({type:"line",x1:h,y1:o,x2:h,y2:c,stroke:m,strokeWidth:1,dashed:true}):d==="full"&&a.push({type:"line",x1:h,y1:o,x2:h,y2:s,stroke:m,strokeWidth:1}),u!=="none"&&fe(a,void 0,u,h,c,p.markerSize,m,m,1.5),l.label){let g=d==="to-value"?c-10:o-6;a.push({type:"text",content:l.label,x:h,y:g,anchor:"middle",fontSize:11,fill:m});}}else d!=="none"&&a.push({type:"line",x1:h,y1:o,x2:h,y2:s,stroke:m,strokeWidth:1}),l.label&&a.push({type:"text",content:l.label,x:h,y:o-6,anchor:"middle",fontSize:11,fill:m});}return a}function ut(i){let{annotations:e,timeScale:t,valueScales:n}=i,r=[],o=s=>{let a=n.get(s.axis??0)??n.values().next().value;return {x:t.map(s.time),y:a?a.map(s.value):0}};for(let s of e){let a=[],l=h=>a.push(h);switch(s.type){case "line":{let h=o(s.from),m=o(s.to);l({type:"line",x1:h.x,y1:h.y,x2:m.x,y2:m.y,stroke:s.color??p.annotationColor,strokeWidth:s.width??p.annotationWidth,dash:s.dash});break}case "arrow":{let h=o(s.from),m=o(s.to),u=s.color??p.annotationColor,d=s.headSize??p.annotationHead;l({type:"line",x1:h.x,y1:h.y,x2:m.x,y2:m.y,stroke:u,strokeWidth:s.width??p.annotationWidth});let c=Math.hypot(m.x-h.x,m.y-h.y)||1,g=(m.x-h.x)/c,y=(m.y-h.y)/c,x=m.x-g*d,k=m.y-y*d;l({type:"path",points:[{x:m.x,y:m.y},{x:x-y*d*.5,y:k+g*d*.5},{x:x+y*d*.5,y:k-g*d*.5}],fill:u,stroke:"none"});break}case "rect":{let h=o(s.from),m=o(s.to);l({type:"rect",x:Math.min(h.x,m.x),y:Math.min(h.y,m.y),w:Math.abs(m.x-h.x),h:Math.abs(m.y-h.y),fill:s.fill??"none",hatch:s.hatch,stroke:s.stroke,opacity:s.opacity});break}case "point":{let h=o(s.at),m=s.color??"#334155",u=s.radius??p.annotationRadius,d=s.shape??"circle";d==="circle"?l({type:"circle",cx:h.x,cy:h.y,r:u,fill:m}):d==="square"?l({type:"rect",x:h.x-u,y:h.y-u,w:u*2,h:u*2,fill:m}):(l({type:"line",x1:h.x-u,y1:h.y-u,x2:h.x+u,y2:h.y+u,stroke:m,strokeWidth:1.5}),l({type:"line",x1:h.x-u,y1:h.y+u,x2:h.x+u,y2:h.y-u,stroke:m,strokeWidth:1.5}));break}case "label":{let h=o(s.at);l({type:"text",content:s.text,x:h.x+(s.dx??0),y:h.y+(s.dy??0),anchor:s.anchor??"middle",fontSize:p.annotationFontSize,fill:s.color??p.annotationColor,rotate:s.rotate});break}}if(s.id&&a.length>0){let h=ee(s.id);r.push({type:"group",cssClass:`annotation annotation--${h}`,commands:a});}else r.push(...a);}return r}var K=12,Se=8,Ee=20,Gt=11,Ne=18,Ge=i=>i.length*Gt*.6;function dt(i,e="vertical"){if(e==="horizontal"){let n=0;for(let r of i)n+=K+Se+Ge(r.name)+Ne;return {width:Math.max(0,n-Ne),height:Ee}}let t=0;for(let n of i)t=Math.max(t,Ge(n.name));return {width:K+Se+t,height:i.length*Ee}}function ct(i){let{items:e,x:t,y:n,orientation:r="vertical"}=i,o=[],s=t;return e.forEach((a,l)=>{let h=r==="horizontal"?s:t,m=r==="horizontal"?n:n+l*Ee;o.push({type:"rect",x:h,y:m,w:K,h:K,fill:a.color,stroke:p.legendStroke,strokeWidth:1},{type:"text",content:a.name,x:h+K+Se,y:m+K-2,fontSize:p.legendFont,fill:p.legendText}),r==="horizontal"&&(s+=K+Se+Ge(a.name)+Ne);}),{type:"group",cssClass:"chart-legend",commands:o}}function pt(i){let{xTicks:e,yTicks:t,xRange:n,yRange:r,stroke:o=p.gridStroke,strokeWidth:s=p.gridStrokeWidth,dashed:a=false,opacity:l=p.gridOpacity}=i,h=[];if(t)for(let m of t)h.push({type:"line",x1:n[0],y1:m,x2:n[1],y2:m,stroke:o,strokeWidth:s,dashed:a,opacity:l});if(e)for(let m of e)h.push({type:"line",x1:m,y1:r[0],x2:m,y2:r[1],stroke:o,strokeWidth:s,dashed:a,opacity:l});return h}function Ve(i){return i!==void 0&&typeof i=="object"&&"series"in i?i.series:null}function ft(i){let e=[...i].sort((n,r)=>n.time-r.time),t=0;return n=>{for(;t>0&&e[t].time>n;)t--;for(;t<e.length-1&&e[t+1].time<=n;)t++;let r=e[t];if(!r||n<r.time)return null;if(r.time===n)return r.value??null;let o=e[t+1];if(!o||n>o.time||r.value===null||o.value===null)return null;let s=o.time-r.time;return s===0?r.value:r.value+(o.value-r.value)*(n-r.time)/s}}function gt(i,e,t){let n=i??e;if(n==="series")return null;if(n==="chartTop")return t.chartTop;if(n==="chartBottom")return t.chartBottom;if(typeof n=="object"&&"threshold"in n){let r=t.thresholds.get(n.threshold);if(!r)throw new Error(`fillSpec region references unknown threshold '${n.threshold}'`);return t.valueScale.map(r.value)}return typeof n=="object"&&"value"in n?t.valueScale.map(n.value):null}function Vt(i){return typeof i=="string"?{color:i}:{color:i.color,hatch:i.hatch}}function yt(i,e,t){let n=gt(i.from,"chartBottom",e),r=gt(i.to,"series",e),{color:o,hatch:s}=Vt(i.fill),a={type:"path",fill:o,hatch:s,stroke:"none",cssClass:"series-fill"},l=x=>e.idPrefix?{id:`${e.idPrefix}-fill-r${t}-${x}`}:{},h=Ve(i.from),m=Ve(i.to);if(h!==null||m!==null){if(!e.fremdeSerie)throw new Error(`fillSpec region references series '${h??m}', but no series lookup was provided`);let x=(R,C,F)=>{let B=R??C,L=Ve(B);if(L!==null){let M=e.fremdeSerie(L);if(!M)throw new Error(`fillSpec region references unknown series '${L}'`);let $=M.shape==="step"?re(M.data):M.data;return {bei:ft($),zeiten:$.map(_=>_.time)}}if(B==="series")return {bei:ft(F),zeiten:F.map(M=>M.time)};let N=ze(B,e),S=e.valueScale.domain(),T=N??(B==="chartBottom"?S[0]:S[1]);return {bei:()=>T,zeiten:[]}},k=e.shape==="step",D=[];for(let R of e.runs){if(R.length<2)continue;let C=k?re(R):R,F=x(i.from,"chartBottom",C),B=x(i.to,"series",C),L=C[0].time,N=C[C.length-1].time,S=[...new Set([...F.zeiten,...B.zeiten,...C.map(_=>_.time)])].filter(_=>_>=L&&_<=N).sort((_,j)=>_-j),T=[],M=[],$=()=>{if(T.length>=2){let _=[...M].reverse();D.push({...a,...l(D.length),smoothing:k?false:e.smoothing,smoothCount:T.length,points:[...T,..._]});}T=[],M=[];};for(let _ of S){let j=F.bei(_),A=B.bei(_);if(j===null||A===null){$();continue}let P=e.timeScale.map(_);T.push({x:P,y:e.valueScale.map(A)}),M.push({x:P,y:e.valueScale.map(j)});}$();}return D}if(n!==null&&r!==null){let x=e.timeScale.range(),k=x[0],D=x[1],R=Math.min(n,r),C=Math.max(n,r);return [{...a,...l(0),points:[{x:k,y:R},{x:D,y:R},{x:D,y:C},{x:k,y:C}]}]}let u=n??r,d=[],c=zt(i,e);if(c===null){let x=e.valueScale.domain();c=(n??r)===e.chartBottom?x[0]:x[1];}let g=ze(i.outer,e),y=e.shape==="step";for(let x of e.runs){if(x.length<2)continue;let k=y?re(x):x,D=z.splitByThreshold(k,c,C=>C.value??c,z.interpolateDataPoint),R=i.side==="above"?D.above:i.side==="below"?D.below:[...D.above,...D.below];if(g!==null&&i.side){let C=g,F=i.side==="above"?B=>Math.min(B,C):B=>Math.max(B,C);R=R.map(B=>B.map(L=>({...L,value:F(L.value??C)})));}for(let C of R){if(C.length<2)continue;let F=C.map(L=>({x:e.timeScale.map(L.time),y:e.valueScale.map(L.value)})),B=[];for(let L of [...F].reverse()){let N=B[B.length-1];y&&N&&N.x===L.x||B.push({x:L.x,y:u});}d.push({...a,...l(d.length),smoothing:y?false:e.smoothing,smoothCount:F.length,points:[...F,...B]});}}return d}function zt(i,e){let t=i.from==="series"?i.to:i.from;return ze(t,e)}function ze(i,e){return i===void 0||i==="series"||i==="chartTop"||i==="chartBottom"?null:typeof i=="object"&&"threshold"in i?e.thresholds.get(i.threshold)?.value??null:typeof i=="object"&&"value"in i?i.value:null}function bt(i,e){if(typeof i=="string"||!("regions"in i))return yt({fill:i},e,0);let t=[];return i.regions.forEach((n,r)=>{t.push(...yt(n,e,r));}),t}function St(i){let e=i.style?.line,t=e&&!Array.isArray(e)?e:void 0;return {color:t?.color??p.stroke,width:t?.width??p.strokeWidth,dash:t?.style,smoothing:t?.smoothing??false}}function xt(i,e,t,n,r){let o=i.filter(h=>h.value!==null);if(o.length<2)return [];let s=o.map(h=>({x:e.timeScale.map(h.time),y:e.valueScale.map(h.value)})),a=St(t);return [{type:"path",cssClass:"series-line",id:e.idPrefix?`${e.idPrefix}-overlay-${r}-${n}`:`overlay-${r}-${n}`,points:s,stroke:a.color,strokeWidth:a.width,smoothing:a.smoothing,dash:a.dash,fill:"none"}]}function wt(i,e,t=0){switch(i.kind){case "movingAverage":{let n=i.type==="exponential"?rt(e.data,i.window):Oe(e.data,i.window);return xt(n,e,i,"movingAvg",t)}case "movingMkt":{let n=nt(e.data,i.window,i.activationEnergy);return xt(n,e,i,"movingMkt",t)}case "limits":{let n=[],r=e.timeScale.range(),o=r[0],s=r[1],a=St(i),l=a.color,h=a.width,m=a.dash??"dashed",u=e.idPrefix?`${e.idPrefix}-overlay-${t}-`:`overlay-${t}-`;return i.high!==void 0&&n.push({type:"line",id:`${u}limit-high`,x1:o,y1:e.valueScale.map(i.high),x2:s,y2:e.valueScale.map(i.high),stroke:l,strokeWidth:h,dash:m}),i.low!==void 0&&n.push({type:"line",id:`${u}limit-low`,x1:o,y1:e.valueScale.map(i.low),x2:s,y2:e.valueScale.map(i.low),stroke:l,strokeWidth:h,dash:m}),n}case "stdDevBand":{let n=i.multiplier??1,r=Oe(e.data,i.window),o=it(e.data,i.window),s=[],a=[];for(let x=0;x<r.length;x++){let k=r[x].value,D=o[x].value;if(k===null||D===null)continue;let R=e.timeScale.map(r[x].time);s.push({x:R,y:e.valueScale.map(k+n*D)}),a.push({x:R,y:e.valueScale.map(k-n*D)});}if(s.length<2)return [];let l=e.idPrefix?`${e.idPrefix}-overlay-${t}-`:`overlay-${t}-`,h=[],u=(typeof i.style?.fill=="string"||i.style?.fill&&!("regions"in i.style.fill)?i.style.fill:void 0)??"#94a3b833",{color:d,hatch:c}=Yt(u);h.push({type:"path",cssClass:"series-fill",id:`${l}stdDevBand`,points:[...s,...[...a].reverse()],fill:d,hatch:c,stroke:"none"});let g=i.style?.line,y=g&&!Array.isArray(g)?g:void 0;if(y){let x=r.filter(k=>k.value!==null).map(k=>({x:e.timeScale.map(k.time),y:e.valueScale.map(k.value)}));x.length>=2&&h.push({type:"path",cssClass:"series-line",id:`${l}stdDevBand-mean`,points:x,stroke:y.color??p.stroke,strokeWidth:y.width??1.5,smoothing:y.smoothing,dash:y.style,fill:"none"});}return h}}}function Yt(i){return typeof i=="string"?{color:i}:{color:i.color,hatch:i.hatch}}function qt(i){if(!i)return {gaps:[],autoDetect:false,minGapMs:6e4};if(Array.isArray(i))return {gaps:i,autoDetect:false,minGapMs:6e4};let e=i.regions??[],t=i.style;return {gaps:e.map(r=>{let o={...t,...r.style},s=o.fill,a,l;return typeof s=="string"?a=s:s&&(a=s.color,l=s.hatch),{startTime:r.startTime,endTime:r.endTime,label:r.label,fill:a,hatch:l,fillOpacity:o.opacity,labelBaseline:o.label?.baseline,rotate:o.label?.rotate,style:o.display==="bridge_line"?void 0:o.display}}),autoDetect:i.autoDetect??false,minGapMs:i.minGapMs??6e4}}function Xt(i,e,t,n){if(n===void 0)return [i,e];let r=typeof n=="number"?n:n.top??0,o=typeof n=="number"?n:n.bottom??0;if(r<=0&&o<=0)return [i,e];let s=t-r-o,a=e-i;if(s<=0||a<=0)return [i,e];let l=a/s;return [i-o*l,e+r*l]}function he(i){return "showAs"in i&&!!i.showAs}var J=class{_layout;_renderer;_locale;_timeZone;_legend;_clipSeries;_markers;_thresholds;_highlights;_gaps;_gapsAutoDetect;_gapsMinGapMs;_annotations;_annotationBands;_disabledAnnotations=new Set;_annotationSeq=0;_axes;_series;readonly_annotationBandHeight=0;_timeScale;_valueScales=new Map;constructor(e={}){this._layout=new se({width:e.width??800,height:e.height??400,margin:e.margin??{top:20,right:20,bottom:40,left:60}}).compute(),this._renderer=e.renderer,this._locale=e.locale,this._timeZone=e.timeZone,this._legend=e.legend,this._clipSeries=e.clipSeries??true,this._markers=e.markers??[],this._thresholds=e.thresholds??[],this._highlights=e.highlights??[];let t=qt(e.gaps);this._gaps=t.gaps,this._gapsAutoDetect=t.autoDetect,this._gapsMinGapMs=t.minGapMs,this._annotations=e.annotations??[],this._annotationBands=e.annotationBands??[],this._axes=e.axes,this._series=[],e.series&&this.setData(e.series);}getWidth(){return this._layout.totalWidth}getHeight(){return this._layout.totalHeight+this._annotationBandTotalHeight()}get series(){return this._series}_annotationBandTotalHeight(){let e=0;for(let t of this._annotationBands){let n=t.height??12,r=t.spacing??0;(t.showAxis??false)&&(e+=26+r),e+=n+r;}return e}setData(e){this._series=e.filter(t=>Array.isArray(t.data));}addAnnotation(e){let t=e.id??`anno-${++this._annotationSeq}`;return this._annotations.push({...e,id:t}),t}removeAnnotation(e){let t=this._annotations.length;return this._annotations=this._annotations.filter(n=>n.id!==e),this._disabledAnnotations.delete(e),this._annotations.length<t}setAnnotations(e){this._annotations=[...e],this._disabledAnnotations.clear();}clearAnnotations(){this._annotations=[],this._disabledAnnotations.clear();}getAnnotations(){return this._annotations}disableAnnotation(e){this._disabledAnnotations.add(e);}enableAnnotation(e){this._disabledAnnotations.delete(e);}_axisIndexOf(e){return e.yAxisIndex??0}_timesOf(e){return e.data.map(t=>t.time)}_valuesOf(e){if(he(e)){let t=[];for(let n of e.data)n.min!==null&&t.push(n.min),n.max!==null&&t.push(n.max);return t}return e.data.map(t=>t.value).filter(t=>t!==null)}renderCommands(){if(this._series.length===0)return [];let e=this._legendItems(),t=(this._legend?.show??false)&&e.length>0,n=this._legend?.position??"inside-right",r=this._legend?.orientation??"vertical",o=t?dt(e,r):{width:0},s=this._layout;if(t&&(n==="outside-right"||n==="outside-left")){let f=o.width+16,w={...this._layout.margin};n==="outside-right"?w.right+=f:w.left+=f,s=new se({width:this._layout.totalWidth,height:this._layout.totalHeight,margin:w}).compute();}let{chartX:a,chartY:l,chartWidth:h,chartHeight:m}=s,u=[a,a+h],d=[l,l+m],c=[];for(let f of this._series)f.data.sort((w,v)=>w.time-v.time);let g=new Map,y=1/0,x=-1/0,k=false;for(let f of this._series){let w=this._axisIndexOf(f),v=g.get(w);v?v.push(f):g.set(w,[f]);for(let I of this._timesOf(f))I<y&&(y=I),I>x&&(x=I),k=true;}if(!k)return [];let D=this._axes?.x?.domain,R=D&&D!=="auto"?D:[y,x];this._timeScale=new te({domain:R,range:u,locale:this._locale,timeZone:this._timeZone});let C=f=>({axisColor:f?.color??p.axisColor,tickColor:f?.color??p.tickColor,textColor:p.textColor,textSize:p.textSize,axisWidth:f?.width??1}),F=new ie({domain:R,xRange:u,y:l+m,locale:this._locale,timeZone:this._timeZone,format:this._axes?.x?.format,maxTicks:this._axes?.x?.ticks?.major,colors:C(this._axes?.x?.axis)});this._valueScales.clear();let B=Array.from(g.keys()).sort((f,w)=>f-w),L,N=0,S=0;for(let f of B){let w=g.get(f),v=1/0,I=-1/0,W=false;for(let V of w)for(let ue of this._valuesOf(V))ue<v&&(v=ue),ue>I&&(I=ue),W=true;if(!W)continue;v===I&&(v-=1,I+=1);let H;this._axes?.y&&this._axes.y.length>f?H=this._axes.y[f]:f===0?H=this._axes?.left:f===1&&(H=this._axes?.right);let Me=H?.domain,Q=Me&&Me!=="auto"?Me:Xt(v,I,m,H?.padding),Ue=new Z({domain:Q,range:[l+m,l]});this._valueScales.set(f,Ue);let Ze=this._thresholds.filter(V=>(V.axisIndex??0)===f&&V.label!==void 0&&V.label!==null&&V.label!==false&&V.value>=Math.min(Q[0],Q[1])&&V.value<=Math.max(Q[0],Q[1])).map(V=>Ue.map(V.value)),Pe=H?.position??(f===0?"left":"right"),Re;if(Pe==="right"){let V=H?.offset??S*50;Re=a+h+V,S++;}else {let V=H?.offset??N*50;Re=a-V,N++;}let Ke=new ce({domain:Q,range:[l+m,l],x:Re,position:Pe,format:H?.format,ticks:H?.ticks?.major,colors:C(H?.axis),suppressLabelsNear:Ze.length?Ze:void 0});f===0&&(L=Ke),c.push({type:"group",cssClass:`value-axis ${Pe}`,commands:Ke.render()});}let T=this._valueScales.get(0)??this._valueScales.get(B[0]);c.push({type:"group",cssClass:"time-axis",commands:F.render()});let M=null,$=this._axes?.x?.grid?.major,_=this._axes?.left?.grid?.major;if($!==void 0||_!==void 0){let f=$!==false,w=_!==false&&!!L,v=f?F.generateTicks().map(W=>W.x):void 0,I=w?L.generateTicks().map(W=>W.position):void 0;if(v||I){let W=($&&typeof $=="object"?$:void 0)??(_&&typeof _=="object"?_:void 0);M={type:"group",cssClass:"chart-grid",commands:pt({xTicks:v,yTicks:I,xRange:u,yRange:d,stroke:W?.color,opacity:W?.opacity,dashed:W?.style==="dashed"})};}}if(this._highlights.length>0&&c.push({type:"group",cssClass:"highlights",commands:ht({highlights:this._highlights,timeScale:this._timeScale,yRange:d,height:s.totalHeight})}),this._thresholds.length>0&&T){let f=[],w=[];for(let v of this._thresholds){let I=v.id??ee(v.name),W=this._valueScales.get(v.axisIndex??0)??T,H=at({thresholds:[v],valueScale:W,xRange:u});H.inside.length&&f.push({type:"group",cssClass:`threshold threshold--${I}`,id:`threshold-${I}`,commands:H.inside}),H.labels.length&&w.push({type:"group",cssClass:`threshold-label threshold-label--${I}`,commands:H.labels});}f.length&&c.push({type:"group",cssClass:"thresholds",commands:f,clipRect:{x:a,y:l,w:h,h:m}}),w.length&&c.push({type:"group",cssClass:"threshold-labels",commands:w});}let j=this._gaps;if(this._gapsAutoDetect){let f=[];for(let w of this._series)he(w)||f.push(...tt(w.data,this._gapsMinGapMs));f.length>0&&(j=[...this._gaps,...f]);}j.length>0&&c.push({type:"group",cssClass:"gaps",commands:He({gaps:j,timeScale:this._timeScale,yRange:d,height:s.totalHeight})});let A=new Map(this._thresholds.map(f=>[f.id??f.name,f]));for(let f of this._series){if(f.data.length===0)continue;let w=this._valueScales.get(this._axisIndexOf(f));if(!w)continue;let v=ee(f.id??f.name);c.push({type:"group",cssClass:`series series--${v}`,id:`series-${v}`,commands:this._renderSeries(f,w,A),...this._clipSeries?{clipRect:{x:a,y:l,w:h,h:m}}:{}});}M&&c.push(M);let P=this._markers.map(f=>({...f}));for(let f of P)if(f.value===void 0&&(f.lineStyle==="to-value"||f.lineStyle==="to-top")){let w=this._series[f.seriesIndex??0];w&&!he(w)&&w.data.length>=2&&(f.value=this._interpolateValue(f.time,w.data));}if(P.length>0&&T){let f=[];for(let w of P){let v=T,I=this._series[w.seriesIndex??0];I&&(v=this._valueScales.get(this._axisIndexOf(I))??T),f.push(...mt({markers:[w],timeScale:this._timeScale,valueScale:v,yRange:d}));}c.push({type:"group",cssClass:"markers",commands:f});}let E=this._annotations.filter(f=>!f.id||!this._disabledAnnotations.has(f.id));if(E.length>0&&c.push({type:"group",cssClass:"annotations",commands:ut({annotations:E,timeScale:this._timeScale,valueScales:this._valueScales})}),this._annotationBands.length>0){let f=l+m+this._layout.margin.bottom,w=0;this._annotationBands.forEach(v=>{let I=v.height??12,W=v.spacing??0,H=f+w;(v.showAxis??false)&&(w+=26+W),w+=I+W,c.push({type:"group",cssClass:"annotation-band",commands:new xe({name:v.name,showAxis:v.showAxis??false,items:v.items,timeScale:this._timeScale,background:v.background,hatch:v.hatch},[a,a+h],H,I).render()});});}if(t&&n!=="separate"){let f,w;n==="inside-right"?(f=a+h-o.width-8,w=l+8):n==="inside-left"?(f=a+8,w=l+8):n==="outside-right"?(f=a+h+16,w=l):(f=8,w=l),c.push(ct({items:e,x:f,y:w,orientation:r}));}let O=this._axes?.left?.label,G=this._axes?.right?.label,q=this._axes?.x?.label;if(O||G||q){let f=[],w=l+m/2,v=this._axes?.left?.labels,I=this._axes?.right?.labels,W=this._axes?.x?.labels;O&&f.push({type:"text",content:O,x:14,y:w,anchor:"middle",fontSize:v?.fontSize??p.axisLabelSize,fill:v?.color??p.axisLabelColor,rotate:-90}),G&&f.push({type:"text",content:G,x:s.totalWidth-14,y:w,anchor:"middle",fontSize:I?.fontSize??p.axisLabelSize,fill:I?.color??p.axisLabelColor,rotate:90}),q&&f.push({type:"text",content:q,x:a+h/2,y:s.totalHeight-6,anchor:"middle",fontSize:W?.fontSize??p.axisLabelSize,fill:W?.color??p.axisLabelColor}),f.length&&c.push({type:"group",cssClass:"axis-labels",commands:f});}return c}_renderSeries(e,t,n){let r=this._timeScale,o={timeScale:r,valueScale:t};if(he(e)){let S=e.style?.line&&!Array.isArray(e.style.line)?e.style.line:void 0,T=typeof e.style?.fill=="string"?e.style.fill:void 0;return e.showAs==="minmaxavg"?new ge({data:e.data,timeScale:r,valueScale:t,minColor:e.minColor,maxColor:e.maxColor,avgColor:e.avgColor,avgDashed:e.avgDashed,fillToMax:e.fillToMax,fillToMaxHatch:e.fillToMaxHatch,fillToMin:e.fillToMin,fillToMinHatch:e.fillToMinHatch,smoothing:S?.smoothing,strokeWidth:S?.width,id:U(e.name,e.id)}).render():new ye({data:e.data,timeScale:r,valueScale:t,fill:T??S?.color,avgLine:e.avgLine,countOpacity:e.countOpacity,id:U(e.name,e.id)}).render()}let s=e,a=e.style?.line&&!Array.isArray(e.style.line)?e.style.line:void 0,l=a?.gapThreshold??p.gapThreshold,h=z.getRuns(e.data,S=>S.value===null,l),m=h.reduce((S,T)=>S+T.length,0);if(m===0)return [];let u=[],d=e.style?.markers,c=e.style?.shadow,g={stroke:a?.color??p.stroke,strokeWidth:a?.width??p.strokeWidth,smoothing:a?.smoothing,dashed:a?.style==="dashed",pointStyle:d?.type,pointSize:d?.size,pointStroke:d?.stroke,pointFill:d?.fill,pointStrokeWidth:d?.strokeWidth,shadowColor:c?.color,shadowBlur:c?.blur,shadowOffsetX:c?.offsetX,shadowOffsetY:c?.offsetY,id:U(e.name,e.id)},y=e.style?.line,k=((Array.isArray(y)?y[0]:a)?.shape??s.seriesType)==="step",D=e.style?.fill;if(D!==void 0){let S=t.range(),T=Math.min(S[0],S[1]),M=Math.max(S[0],S[1]);u.push(...bt(D,{runs:h,timeScale:r,valueScale:t,thresholds:n,chartTop:T,chartBottom:M,smoothing:a?.smoothing,shape:k?"step":"line",fremdeSerie:$=>{let _=this._series.find(G=>(G.id??G.name)===$||G.name===$);if(!_||!("data"in _))return;let j=_.data;if(j.length===0||!("value"in j[0]))return;let A=_.style?.line,P=Array.isArray(A)?A[0]:A,O=(typeof P=="object"&&P!==null?P.shape:void 0)==="step"||_.seriesType==="step";return {data:j,shape:O?"step":"line"}},idPrefix:U(e.name,e.id)}));}let R=s.colorByThresholds??[],C=R.map(S=>n.get(S)).filter(S=>!!S).map(S=>S.value).sort((S,T)=>S-T),F=(S,T,M)=>{let $=M??g.stroke,_=Number.NEGATIVE_INFINITY;for(let j of T){let A=n.get(j);!A||S<A.value||A.value<_||(_=A.value,$=A.color??$);}return $},B=new Map;for(let S of h){let $=function(A){return z.splitByBoundaries(A==="step"?re(S):S,C,P=>P.value,z.interpolateDataPoint)};if(S.length<2)continue;let T=U(s.name,s.id),M=new Map,_=A=>{let P=M.get(A);return P||(P=$(A),M.set(A,P)),P},j=(A,P,E)=>{let O=_(A);for(let G=0;G<O.length;G++){let q=O[G],f=B.get(E)??0;if(B.set(E,f+1),q.data.length<2)continue;let w=q.zoneLow;u.push({type:"path",cssClass:"series-line",id:T?`${T}-line-${f}${E}`:void 0,points:q.data.map(v=>({x:r.map(v.time),y:t.map(v.value)})),stroke:F(w,R,P.color),strokeWidth:P.width??g.strokeWidth,smoothing:A==="step"?false:P.smoothing??g.smoothing,dash:P.style,opacity:P.opacity,fill:"none",shadowColor:g.shadowColor,shadowBlur:g.shadowBlur,shadowOffsetX:g.shadowOffsetX,shadowOffsetY:g.shadowOffsetY});}};y===false||(Array.isArray(y)?y.forEach((A,P)=>{j(A.shape??(s.seriesType==="step"?"step":"line"),A,`-${P}`);}):j(k?"step":"line",y??{},"")),g.pointStyle&&g.pointStyle!=="none"&&m<=(d?.threshold??p.pointThreshold)&&u.push(...st(S,o,g,A=>F(A.value,R)));}let L=e.overlays;if(L&&L.length>0){let S=t.range(),T={data:e.data,timeScale:r,valueScale:t,chartTop:Math.min(S[0],S[1]),chartBottom:Math.max(S[0],S[1]),idPrefix:U(e.name,e.id)};L.forEach((M,$)=>{u.push(...wt(M,T,$));});}if(e.style?.gap&&h.length>1){let S=e.style.gap,T=S.bridge,M=[];for(let $=1;$<h.length;$++){let _=h[$-1][h[$-1].length-1],j=h[$][0];if(S.display==="bridge_line"){if(_.value===null||j.value===null)continue;u.push({type:"line",x1:r.map(_.time),y1:t.map(_.value),x2:r.map(j.time),y2:t.map(j.value),stroke:T?.color??(typeof e.style?.line=="object"&&!Array.isArray(e.style.line)?e.style.line.color:void 0)??p.stroke,strokeWidth:T?.width??1.5,dash:T?.style??"dotted"});}else M.push({startTime:_.time,endTime:j.time});}if(M.length>0){let $=S.display&&S.display!=="bridge_line"?S.display:"dashed_border",_=S.fill,j=typeof _=="string"?_:_?.color,A=t.range();u.push(...He({gaps:M.map(P=>({...P,style:$})),timeScale:r,yRange:[Math.min(A[0],A[1]),Math.max(A[0],A[1])],fill:j,hatch:typeof _=="object"?_.hatch:void 0,fillOpacity:S.opacity??.15,labelBaseline:S.label?.baseline,labelRotate:S.label?.rotate}));}}return u}_interpolateValue(e,t){for(let n=1;n<t.length;n++){let r=t[n-1],o=t[n];if(!(r.value===null||o.value===null)&&e>=r.time&&e<=o.time){if(o.time===r.time)return r.value;let s=(e-r.time)/(o.time-r.time);return r.value+s*(o.value-r.value)}}}legendItems(){return this._legendItems()}_legendItems(){return this._series.map(e=>{let t=e.style?.line&&!Array.isArray(e.style.line)?e.style.line:void 0,n=e.style?.markers,r=n?.type&&n.type!=="none"&&(n.threshold===void 0||(e.data?.length??0)<=n.threshold),o=he(e)?e.avgColor??p.avgColor:p.stroke;return {name:e.name,color:t?.color??o,line:t?.style,marker:r?n.type:void 0}})}get renderer(){return this._renderer}get layout(){return this._layout}get timeScale(){return this._timeScale}get valueScales(){return this._valueScales}invertTime(e){return this._timeScale?this._timeScale.invert(e):0}invertValue(e,t=0){let n=this._valueScales.get(t);return n?n.invert(e):0}project(e,t,n=0){let r=this._timeScale?this._timeScale.map(e):0,o=this._valueScales.get(n);return {x:r,y:o?o.map(t):0}}};var we=class{};var Ye="1.8.3";var Ut=` <!-- MLTimeGraph ${Ye} -->`,_t=1e3;function b(i){return String(Math.round(i*_t)/_t)}function _e(i){return Fe(i).toString(16).padStart(8,"0")}function Zt(i){switch(i){case "top":return "text-top";case "bottom":return "text-bottom";default:return "middle"}}var X=class extends we{#e="100%";#t="100%";#n;#i=new Map;#r=new Map;#o=new Map;constructor(e){super(),e?.width!==void 0&&(this.#e=e.width),e?.height!==void 0&&(this.#t=e.height),e?.background!==void 0&&(this.#n=e.background);}setBackgroundColor(e){this.#n=e;}render(e){this.#i.clear(),this.#r.clear(),this.#o.clear();let t=e.map(h=>this._toSVG(h));this.#n&&t.unshift(`<rect width="100%" height="100%" fill="${this._esc(this.#n)}" />`);let n=t.join(`
|
|
25
25
|
`),r="",o=[];for(let[,h]of this.#i)o.push(h);for(let[,h]of this.#r)o.push(h);for(let[,h]of this.#o)o.push(h);o.length>0&&(r=` <defs>
|
|
26
26
|
${o.join(`
|
|
27
27
|
`)}
|
|
28
28
|
</defs>
|
|
29
|
-
`);let s=typeof this.#
|
|
29
|
+
`);let s=typeof this.#e=="number"?`${this.#e}`:this.#e,a=typeof this.#t=="number"?`${this.#t}`:this.#t,l=typeof this.#e=="number"&&typeof this.#t=="number"?` viewBox="0 0 ${this.#e} ${this.#t}"`:"";return {type:"svg",content:`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${a}"${l}>
|
|
30
|
+
${Ut}
|
|
30
31
|
${r} ${n}
|
|
31
|
-
</svg>`}}_toSVG(
|
|
32
|
-
<feDropShadow dx="${n}" dy="${r}" stdDeviation="${
|
|
33
|
-
</filter>`;return this.#i.set(o,s),o}#h(t,
|
|
34
|
-
<rect x="${
|
|
35
|
-
</clipPath>`);}#
|
|
36
|
-
`);return `<linearGradient id="${
|
|
32
|
+
</svg>`}}_toSVG(e){switch(e.type){case "path":return this._path(e);case "line":return this._line(e);case "rect":return this._rect(e);case "circle":return this._circle(e);case "text":return this.#m(e);case "gradient":return this._gradient(e);case "gap":return this._gap(e);case "group":return this._group(e)}}#l(e,t,n){if(e.length===0)return "";if(!t||e.length<3)return e.map((s,a)=>`${a===0?"M":"L"}${b(s.x)},${b(s.y)}`).join(" ");let r=n!=null&&n<e.length?Math.max(n,2):e.length,o=`M${b(e[0].x)},${b(e[0].y)}`;for(let s=0;s<r-1;s++){let a=e[s-1]??e[s],l=e[s],h=e[s+1],m=e[s+2]&&s+2<r?e[s+2]:h,u=l.x+(h.x-a.x)/6,d=l.y+(h.y-a.y)/6,c=h.x-(m.x-l.x)/6,g=h.y-(m.y-l.y)/6;o+=` C${b(u)},${b(d)} ${b(c)},${b(g)} ${b(h.x)},${b(h.y)}`;}for(let s=r;s<e.length;s++)o+=` L${b(e[s].x)},${b(e[s].y)}`;return o}_hatchPattern(e,t){let n=`hatch-${e}-${_e(t??"")}`;if(this.#o.has(n))return n;let r=je(n,e,t??"rgba(200,220,255,0.3)");return this.#o.set(n,r),n}_path(e){let t=this.#l(e.points,e.smoothing,e.smoothCount)+(e.closed?" Z":""),n=[];if(e.hatch){let s=this._hatchPattern(e.hatch,e.fill);n.push(`fill="url(#${s})"`);}else n.push(`fill="${e.fill?this._esc(e.fill):"none"}"`);e.stroke&&n.push(`stroke="${this._esc(e.stroke)}"`),e.strokeWidth&&n.push(`stroke-width="${b(e.strokeWidth)}"`);let r=this.#a(e.dash,e.dashed,e.strokeWidth);r&&(n.push(`stroke-dasharray="${r.strokeDasharray}"`),r.strokeLinecap&&n.push(`stroke-linecap="${r.strokeLinecap}"`)),e.opacity!==void 0&&n.push(`opacity="${b(e.opacity)}"`),e.cssClass&&n.push(`class="${this._esc(e.cssClass)}"`),e.id&&n.push(`id="${this._esc(e.id)}"`);let o=this.#s(e);return o&&n.push(`filter="url(#${o})"`),`<path d="${t}" ${n.join(" ")} />`}_line(e){let t=[];e.stroke&&t.push(`stroke="${this._esc(e.stroke)}"`),e.strokeWidth&&t.push(`stroke-width="${b(e.strokeWidth)}"`);let n=this.#a(e.dash,e.dashed,e.strokeWidth);n&&(t.push(`stroke-dasharray="${n.strokeDasharray}"`),n.strokeLinecap&&t.push(`stroke-linecap="${n.strokeLinecap}"`)),e.opacity!==void 0&&t.push(`opacity="${b(e.opacity)}"`),e.id&&t.push(`id="${this._esc(e.id)}"`);let r=this.#s(e);return r&&t.push(`filter="url(#${r})"`),`<line x1="${b(e.x1)}" y1="${b(e.y1)}" x2="${b(e.x2)}" y2="${b(e.y2)}" ${t.join(" ")} />`}_rect(e){let t=[];if(e.hatch){let r=this._hatchPattern(e.hatch,e.fill);t.push(`fill="url(#${r})"`);}else e.fill!==void 0&&t.push(`fill="${this._esc(e.fill)}"`);e.stroke&&t.push(`stroke="${this._esc(e.stroke)}"`),e.strokeWidth&&t.push(`stroke-width="${b(e.strokeWidth)}"`),e.opacity!==void 0&&t.push(`opacity="${b(e.opacity)}"`),e.dashed&&t.push('stroke-dasharray="4,4"'),e.id&&t.push(`id="${this._esc(e.id)}"`);let n=this.#s(e);return n&&t.push(`filter="url(#${n})"`),e.title?`<rect x="${b(e.x)}" y="${b(e.y)}" width="${b(e.w)}" height="${b(e.h)}" ${t.join(" ")}><title>${this._esc(e.title)}</title></rect>`:`<rect x="${b(e.x)}" y="${b(e.y)}" width="${b(e.w)}" height="${b(e.h)}" ${t.join(" ")} />`}_circle(e){let t=[];if(e.hatch){let r=this._hatchPattern(e.hatch,e.fill);t.push(`fill="url(#${r})"`);}else e.fill&&t.push(`fill="${this._esc(e.fill)}"`);e.stroke&&t.push(`stroke="${this._esc(e.stroke)}"`),e.strokeWidth&&t.push(`stroke-width="${b(e.strokeWidth)}"`),e.id&&t.push(`id="${this._esc(e.id)}"`);let n=this.#s(e);return n&&t.push(`filter="url(#${n})"`),`<circle cx="${b(e.cx)}" cy="${b(e.cy)}" r="${b(e.r)}" ${t.join(" ")} />`}#a(e,t,n){return Ie(e,n??2,t)}#s(e){if(!e.shadowColor)return null;let t=e.shadowBlur??0,n=e.shadowOffsetX??0,r=e.shadowOffsetY??0;if(!t&&!n&&!r)return null;let o=`shadow-${_e(`${e.shadowColor}|${b(t)}|${b(n)}|${b(r)}`)}`;if(this.#i.has(o))return o;let s=`<filter id="${o}" x="-50%" y="-50%" width="200%" height="200%">
|
|
33
|
+
<feDropShadow dx="${b(n)}" dy="${b(r)}" stdDeviation="${b(t/2)}" flood-color="${this._esc(e.shadowColor)}" />
|
|
34
|
+
</filter>`;return this.#i.set(o,s),o}#h(e,t,n,r,o){this.#r.has(e)||this.#r.set(e,`<clipPath id="${e}">
|
|
35
|
+
<rect x="${b(t)}" y="${b(n)}" width="${b(r)}" height="${b(o)}" />
|
|
36
|
+
</clipPath>`);}#m(e){let t=[];return e.anchor&&t.push(`text-anchor="${e.anchor}"`),e.fontSize&&t.push(`font-size="${b(e.fontSize)}"`),e.fontFamily&&t.push(`font-family="${this._esc(e.fontFamily)}"`),e.fill&&t.push(`fill="${this._esc(e.fill)}"`),e.opacity!=null&&t.push(`opacity="${b(e.opacity)}"`),e.rotate&&t.push(`transform="rotate(${b(e.rotate)} ${b(e.x)} ${b(e.y)})"`),e.textBaseline&&t.push(`dominant-baseline="${Zt(e.textBaseline)}"`),e.id&&t.push(`id="${this._esc(e.id)}"`),`<text x="${b(e.x)}" y="${b(e.y)}" ${t.join(" ")}>${this._esc(e.content)}</text>`}_gradient(e){let t=`grad-${_e(e.stops.map(r=>`${r.offset}:${r.color}`).join("|"))}`,n=e.stops.map(r=>` <stop offset="${r.offset}" stop-color="${this._esc(r.color)}" />`).join(`
|
|
37
|
+
`);return `<linearGradient id="${t}" gradientUnits="userSpaceOnUse">
|
|
37
38
|
${n}
|
|
38
39
|
</linearGradient>
|
|
39
|
-
<path d="${
|
|
40
|
-
<rect x="${
|
|
41
|
-
<text x="${
|
|
42
|
-
</g>`:`<rect x="${
|
|
40
|
+
<path d="${e.points.map(r=>`${b(r.x)},${b(r.y)}`).join(" ")}" fill="url(#${t})" />`}_gap(e){if(e.style==="empty")return "";let t=[`stroke="${this._esc("#999")}"`,'stroke-dasharray="4,4"','fill="none"'];return e.style==="label"&&e.label?`<g class="gap">
|
|
41
|
+
<rect x="${b(e.x1)}" y="${b(e.y1)}" width="${b(e.x2-e.x1)}" height="${b(e.y2-e.y1)}" ${t.join(" ")} />
|
|
42
|
+
<text x="${b(e.x1)}" y="${b(e.y1-4)}" fill="#999" font-size="10">${this._esc(e.label)}</text>
|
|
43
|
+
</g>`:`<rect x="${b(e.x1)}" y="${b(e.y1)}" width="${b(e.x2-e.x1)}" height="${b(e.y2-e.y1)}" ${t.join(" ")} />`}_group(e){let t=null;if(e.clipRect){let{x:l,y:h,w:m,h:u}=e.clipRect;t=`clip-plot-${_e(`${b(l)},${b(h)},${b(m)},${b(u)}`)}`,this.#h(t,l,h,m,u);}let n=e.commands.map(l=>` ${this._toSVG(l).replaceAll(/\n {3}/g,`
|
|
43
44
|
`)}`).join(`
|
|
44
|
-
`),
|
|
45
|
-
${
|
|
46
|
-
</g>`}_esc(t){return t.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""")}};function Oe(i){return typeof requestAnimationFrame=="function"?requestAnimationFrame(i):setTimeout(()=>i(0),16)}function Ne(i){typeof cancelAnimationFrame=="function"?cancelAnimationFrame(i):clearTimeout(i);}function ce(){let i=0,t=false;return {schedule:e=>{t||(t=true,i=Oe(()=>{t=false,e();}));},cancel:()=>{t&&(t=false,Ne(i));}}}var pe="http://www.w3.org/2000/svg";function Ee(i){let t=i.style?.line;return t&&!Array.isArray(t)&&t.color?t.color:g.stroke}function fe(i){return i.replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t])}function Ge(i){if(i.length===0)return "";let t=new Date(i[0].time).toLocaleString(),e=i.map(n=>`<div><span class="mlc-tooltip__name">${fe(n.series.name)}:</span> ${n.value.toFixed(2)}</div>`);return `<div class="mlc-tooltip__time">${fe(t)}</div>${e.join("")}`}function Ve(i,t){if(i.length===0)return;let e=0,n=i.length-1;for(;e<n;){let s=e+n>>1;i[s].time<t?e=s+1:n=s;}let r=i[Math.max(0,e-1)],o=i[e];return Math.abs(r.time-t)<=Math.abs(o.time-t)?r:o}function ze(i){return "value"in i?i.value:i.avg}function at(i,t,e={}){let n=i.querySelector("svg");if(!n)throw new Error("attachTooltip: target has no <svg> child (did you mount the chart first?)");let r=e.format??Ge,o=e.snapRadius??1/0,s=e.className??"mlc-tooltip",a=e.showPicks??true,l=e.pickRadius??5,h=e.picksClassName??"mlc-tooltip-picks",u=document.createElement("div");u.className=s,u.style.position="absolute",u.style.pointerEvents="none",u.style.display="none",getComputedStyle(i).position==="static"&&(i.style.position="relative"),i.appendChild(u);let m=null;a&&(m=document.createElementNS(pe,"g"),m.setAttribute("class",h),m.setAttribute("pointer-events","none"),n.appendChild(m));let d=()=>{m&&m.replaceChildren();},c=t.series.map((A,M)=>({data:A.data.map(R=>({time:R.time,value:ze(R)})).filter(R=>R.value!==null).sort((R,w)=>R.time-w.time),series:A,index:M})),f=ce(),y=null,x=A=>{let M=n.getBoundingClientRect(),V=t.getWidth?.()??M.width,R=(A.clientX-M.left)*V/Math.max(1,M.width);t.getHeight?.()??M.height;let k=t.invertTime(R);if(!Number.isFinite(k)){u.style.display="none";return}let L=[];for(let B of c){let T=Ve(B.data,k);if(!T)continue;let O=t.project(T.time,T.value,B.series.yAxisIndex??0).x,E=t.project(T.time,T.value,B.series.yAxisIndex??0).y;Math.abs(O-R)>o||L.push({seriesIndex:B.index,series:B.series,time:T.time,value:T.value,x:O,y:E});}if(L.length===0){u.style.display="none",d();return}u.innerHTML=r(L);let P=i.getBoundingClientRect(),F=12,W=(A.clientX-M.left)/Math.max(1,M.width),C=(A.clientY-M.top)/Math.max(1,M.height),I=W<.5?`${F}px`:`calc(-100% - ${F}px)`,z=C<.5?`${F}px`:`calc(-100% - ${F}px)`;if(u.style.left=`${A.clientX-P.left}px`,u.style.top=`${A.clientY-P.top}px`,u.style.transform=`translate(${I}, ${z})`,u.style.display="",m){m.replaceChildren();for(let B of L){let T=document.createElementNS(pe,"circle");T.setAttribute("cx",String(B.x)),T.setAttribute("cy",String(B.y)),T.setAttribute("r",String(l)),T.setAttribute("fill","#ffffff"),T.setAttribute("stroke",Ee(B.series)),T.setAttribute("stroke-width","2"),T.setAttribute("class",`${h}__dot`),m.appendChild(T);}}},b=A=>{y=A,f.schedule(()=>{y&&x(y);});},v=()=>{y=null,f.cancel(),u.style.display="none",d();};n.addEventListener("mousemove",b),n.addEventListener("mouseleave",v);let $=false;return ()=>{$||($=true,y=null,f.cancel(),n.removeEventListener("mousemove",b),n.removeEventListener("mouseleave",v),u.remove(),m&&m.remove());}}function Ye(i,t={}){let e=typeof i=="string"?document.querySelector(i):i;if(!e)throw new Error(`mount: target ${typeof i=="string"?`'${i}'`:""} not found`);let{tooltip:n,...r}=t,o=r.width??e.clientWidth??800,s=r.height??350,a=new K({...r,width:o,height:s}),{content:l}=new q().render(a.renderCommands());e.innerHTML=l;let h=e.querySelector("svg");return h&&(h.setAttribute("viewBox",`0 0 ${o} ${a.getHeight()}`),h.setAttribute("width","100%"),h.setAttribute("height",String(a.getHeight()))),n?.show&&at(e,a,n),a}var St=class{_opts;_series=[];_thresholds=[];_annotations=[];_highlights=[];_markers=[];_bands=[];_tooltip;constructor(t,e){this._opts={},t!==void 0&&(this._opts.width=t),e!==void 0&&(this._opts.height=e);}setWidth(t){return this._opts.width=t,this}setHeight(t){return this._opts.height=t,this}setSize(t,e){return this._opts.width=t,this._opts.height=e,this}setMargin(t,e,n,r){return typeof t=="object"?this._opts.margin=t:this._opts.margin={top:t,right:e??0,bottom:n??0,left:r??0},this}setLocale(t){return this._opts.locale=t,this}setAxes(t){return this._opts.axes=t,this}setXAxis(t){return this._opts.axes={...this._opts.axes,x:{...this._opts.axes?.x,...t}},this}setLeftAxis(t){return this._opts.axes={...this._opts.axes,left:{...this._opts.axes?.left,...t}},this}setRightAxis(t){return this._opts.axes={...this._opts.axes,right:{...this._opts.axes?.right,...t}},this}setYAxis(t,e){this._opts.axes??={},this._opts.axes.y??=[];let n=[...this._opts.axes.y];for(;n.length<=t;)n.push({});return n[t]={...n[t],...e},this._opts.axes.y=n,this}setLegend(t,e,n){return typeof t=="object"?this._opts.legend=t:this._opts.legend={show:t,position:e,orientation:n},this}setGaps(t){return this._opts.gaps=t,this}setTooltip(t){return this._tooltip={show:true,...t},this}addSeries(t){return this._series.push(t),this}addSeriesAll(t){return this._series.push(...t),this}addThreshold(t){return this._thresholds.push(t),this}addThresholds(t){return this._thresholds.push(...t),this}addAnnotation(t){return this._annotations.push(t),this}addAnnotations(t){return this._annotations.push(...t),this}addHighlight(t){return this._highlights.push(t),this}addMarker(t){return this._markers.push(t),this}addAnnotationBand(t){return this._bands.push(t),this}clear(t){return (!t||t==="series")&&(this._series=[]),(!t||t==="thresholds")&&(this._thresholds=[]),(!t||t==="annotations")&&(this._annotations=[]),(!t||t==="highlights")&&(this._highlights=[]),(!t||t==="markers")&&(this._markers=[]),(!t||t==="bands")&&(this._bands=[]),this}toOptions(){return {...this._opts,series:this._series.length?this._series:this._opts.series,thresholds:this._thresholds.length?this._thresholds:this._opts.thresholds,annotations:this._annotations.length?this._annotations:this._opts.annotations,highlights:this._highlights.length?this._highlights:this._opts.highlights,markers:this._markers.length?this._markers:this._opts.markers,annotationBands:this._bands.length?this._bands:this._opts.annotationBands}}build(){return new K(this.toOptions())}getSvg(){let t=this.build(),{content:e}=new q().render(t.renderCommands());return e}mount(t){let e=typeof t=="string"?document.querySelector(t):t;if(!e){let s=typeof t=="string"?`'${t}'`:"";throw new Error(`GraphBuilder.mount: target ${s} not found`)}this._opts.width||(this._opts.width=e.clientWidth||800);let n=this.build(),{content:r}=new q().render(n.renderCommands());e.innerHTML=r;let o=e.querySelector("svg");if(o){let s=this._opts.width??800;o.setAttribute("viewBox",`0 0 ${s} ${n.getHeight()}`),o.setAttribute("width","100%"),o.setAttribute("height",String(n.getHeight()));}return this._tooltip?.show&&at(e,n,this._tooltip),n}};var wt=class{_series;constructor(t){this._series={name:t,data:[]};}addPoint(t,e){return this._series.data.push({time:t,value:e}),this}setData(t){return this._series.data=[...t],this}addPoints(t){return this._series.data.push(...t),this}addFloats(t,e){let n=Math.min(t.length,e.length);for(let r=0;r<n;r++)this._series.data.push({time:t[r],value:e[r]});return this}addNullPoint(t){return this._series.data.push({time:t,value:null}),this}setYAxisIndex(t){return this._series.yAxisIndex=t,this}setColor(t){return this._series.style??={},!this._series.style.line||typeof this._series.style.line=="boolean"?this._series.style.line={color:t}:Array.isArray(this._series.style.line)?this._series.style.line.length===0?this._series.style.line=[{color:t}]:this._series.style.line[0].color=t:this._series.style.line.color=t,this}setStyle(t){return this._series.style=t,this}setLineStyle(t,e,n){return this._series.style??={},this._series.style.line={color:t,width:e,style:n},this}setSmoothing(t){return this._series.style??={},!this._series.style.line||typeof this._series.style.line=="boolean"?this._series.style.line={smoothing:t}:Array.isArray(this._series.style.line)?this._series.style.line.length===0?this._series.style.line=[{smoothing:t}]:this._series.style.line[0].smoothing=t:this._series.style.line.smoothing=t,this}setFill(t){return this._series.style??={},this._series.style.fill=t,this}setID(t){return this._series.id=t,this}setColorByThresholds(t){return this._series.colorByThresholds=t,this}build(){return this._series}};var _t=class{_threshold;constructor(t,e){this._threshold={name:t,value:e};}setColor(t){return this._threshold.color=t,this}setLine(t){return this._threshold.line=t,this}setFill(t,e){return this._threshold.fill=t,this._threshold.fillOpacity=e,this}setFillHatch(t){return this._threshold.fillHatch=t,this}setLabel(t,e){return this._threshold.label={text:t,position:e},this}setID(t){return this._threshold.id=t,this}build(){return this._threshold}};var vt=class{_marker;constructor(t){this._marker={time:t};}setValue(t){return this._marker.value=t,this}setLabel(t){return this._marker.label=t,this}setColor(t){return this._marker.color=t,this}setPointStyle(t){return this._marker.pointStyle=t,this}setLineStyle(t){return t==="none"?delete this._marker.lineStyle:this._marker.lineStyle=t,this}setSeriesIndex(t){return this._marker.seriesIndex=t,this}build(){return this._marker}};var kt=class{_highlight;constructor(t,e){this._highlight={startTime:t,endTime:e};}setLabel(t){return this._highlight.label=t,this}setColor(t){return this._highlight.color=t,this}setOpacity(t){return this._highlight.opacity=t,this}setLabelPosition(t){return this._highlight.labelPosition=t,this}setRotate(t){return this._highlight.rotate=t,this}build(){return this._highlight}};var Tt=class{_ann;constructor(t){this._ann={type:t};}setID(t){return this._ann.id=t,this}setTitle(t){return this._ann.title=t,this}setFrom(t,e,n){return this._ann.from={time:t,value:e,axis:n},this}setTo(t,e,n){return this._ann.to={time:t,value:e,axis:n},this}setAt(t,e,n){return this._ann.at={time:t,value:e,axis:n},this}setColor(t){return this._ann.color=t,this}setWidth(t){return this._ann.width=t,this}setDash(t){return this._ann.dash=t,this}setHeadSize(t){return this._ann.headSize=t,this}setFill(t){return this._ann.fill=t,this}setHatch(t){return this._ann.hatch=t,this}setStroke(t){return this._ann.stroke=t,this}setOpacity(t){return this._ann.opacity=t,this}setRadius(t){return this._ann.radius=t,this}setShape(t){return this._ann.shape=t,this}setText(t){return this._ann.text=t,this}setAnchor(t){return this._ann.anchor=t,this}setDx(t){return this._ann.dx=t,this}setDy(t){return this._ann.dy=t,this}setRotate(t){return this._ann.rotate=t,this}build(){return this._ann}};var Ct=class{_band;constructor(t){this._band={name:t,items:[]};}setHeight(t){return this._band.height=t,this}setSpacing(t){return this._band.spacing=t,this}setHatch(t){return this._band.hatch=t,this}setShowAxis(t){return this._band.showAxis=t,this}setShowInLegend(t){return this._band.showInLegend=t,this}setBackground(t){return this._band.background=t,this}addItem(t){return this._band.items.push(t),this}build(){return this._band}},$t=class{_item;constructor(t,e){this._item={startTime:t,endTime:e};}setFill(t){return this._item.fill=t,this}setHatch(t){return this._item.hatch=t,this}setStroke(t){return this._item.stroke=t,this}setStrokeWidth(t){return this._item.strokeWidth=t,this}setLabel(t,e,n,r){return this._item.label=t,e!==void 0&&(this._item.labelFontSize=e),n!==void 0&&(this._item.labelFill=n),r!==void 0&&(this._item.labelBaseline=r),this}build(){return this._item}};function qe(i){let{thresholds:t,colors:e,hatches:n}=i;if(e.length!==t.length+1)throw new Error(`fillBetweenThresholds: expected ${t.length+1} colors for ${t.length} thresholds, got ${e.length}`);if(n!==void 0&&n.length!==e.length)throw new Error(`fillBetweenThresholds: hatches length (${n.length}) must equal colors length (${e.length})`);return {regions:e.map((o,s)=>{let a=n?.[s],l=a?{color:o,hatch:a}:o;return s===0?{to:{threshold:t[0]},fill:l}:s===e.length-1?{from:{threshold:t[t.length-1]},fill:l}:{from:{threshold:t[s-1]},to:{threshold:t[s]},fill:l}})}}function Wt(i){if(!i||typeof i!="object")throw new Error("DataPoint: object expected");let{time:t,value:e,annotation:n}=i;if(typeof t!="number"||Number.isNaN(t))throw new TypeError(`DataPoint: invalid time=${t}`);if(e!==null&&(typeof e!="number"||Number.isNaN(e)))throw new Error(`DataPoint: invalid value=${e}`);return {time:t,value:e,annotation:n&&typeof n=="string"?n:void 0}}function Xe(i){if(Array.isArray(i))return i.map(Wt);if(i&&typeof i=="object"){let t=i,e=t.name,n=t.data,r=t.sensorType,o=t.enumMap,s=t.color,a=t.lineWidth,l=t.smoothing,h=t.seriesType;if(!e||!e.length)throw new Error("Series: name required");if(!Array.isArray(n))throw new Error("Series: data must be an array");let u=s!==void 0||a!==void 0||l!==void 0?{color:s,width:a,smoothing:l}:void 0;return {name:e,data:n.map(Wt),sensorType:r??"numeric",enumMap:o,seriesType:h,...u&&{style:{line:u}}}}throw new Error("parseSeries: object or DataPoint[] expected")}function Ue(i){if(!i||typeof i!="object")throw new Error("parseAggregated: object expected");let t=i,e=t.name,n=t.data,r=t.showAs,o=t.avgLine,s=t.countOpacity,a=t.color;if(!e?.length)throw new Error("AggregatedSeries: name required");if(!Array.isArray(n))throw new Error("AggregatedSeries: data must be an array");return {name:e,data:Ke(n),showAs:r,avgLine:o,countOpacity:s,...a!==void 0&&{style:{line:{color:a},fill:a}}}}function Ke(i){let t=e=>typeof e=="number"?e:null;return i.map(e=>{let n=e;return {time:n.time??0,min:t(n.min),max:t(n.max),avg:t(n.avg),count:typeof n.count=="number"?n.count:0}})}function Ht(i,t,e){return typeof t=="function"?t(i):i[t??e]}function Ze(i,t,e){if(i instanceof Date){let n=i.getTime();if(Number.isNaN(n))throw new TypeError(`toDataPoints: invalid Date at row ${e}`);return n}if(typeof i=="string"){let n=Date.parse(i);if(Number.isNaN(n))throw new TypeError(`toDataPoints: unparsable time string at row ${e}: ${i}`);return n}if(typeof i=="number"&&Number.isFinite(i))return t==="s"||t==="auto"&&Math.abs(i)>=1e8&&Math.abs(i)<1e11?i*1e3:i;throw new TypeError(`toDataPoints: missing or invalid time at row ${e}: ${String(i)}`)}function Je(i,t){if(i==null)return null;if(typeof i=="number")return Number.isNaN(i)?null:i;if(typeof i=="string"){let e=i.trim();if(e==="")return null;let n=Number(e);if(Number.isNaN(n))throw new TypeError(`toDataPoints: value is not a number at row ${t}: ${i}`);return n}throw new TypeError(`toDataPoints: invalid value at row ${t}: ${String(i)}`)}function ge(i,t={}){let e=t.timeUnit??"ms",n=[];for(let r=0;r<i.length;r++){let o=i[r];if(o==null)throw new TypeError(`toDataPoints: empty row at ${r}`);let s=Array.isArray(o),a=s&&t.time===void 0?o[0]:Ht(o,t.time,"time"),l=s&&t.value===void 0?o[1]:Ht(o,t.value,"value"),h={time:Ze(a,e,r),value:Je(l,r)};if(t.annotation!==void 0){let u=Ht(o,t.annotation,"annotation");typeof u=="string"&&u!==""&&(h.annotation=u);}n.push(h);}return (t.sort??true)&&n.sort((r,o)=>r.time-o.time),n}function Qe(i,t,e={}){return {name:i,data:ge(t,e)}}/*!
|
|
45
|
+
`),r=e.cssClass?` class="${this._esc(e.cssClass)}"`:"",o=e.id?` id="${this._esc(e.id)}"`:"",s=e.plotClipId||t,a=s?` clip-path="url(#${this._esc(s)})"`:"";return `<g${r}${o}${a}>
|
|
46
|
+
${n}
|
|
47
|
+
</g>`}_esc(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""")}};function Kt(i){return typeof requestAnimationFrame=="function"?requestAnimationFrame(i):setTimeout(()=>i(0),16)}function Jt(i){typeof cancelAnimationFrame=="function"?cancelAnimationFrame(i):clearTimeout(i);}function kt(){let i=0,e=false;return {schedule:t=>{e||(e=true,i=Kt(()=>{e=false,t();}));},cancel:()=>{e&&(e=false,Jt(i));}}}var vt="http://www.w3.org/2000/svg";function Qt(i){let e=i.style?.line;return e&&!Array.isArray(e)&&e.color?e.color:p.stroke}function Tt(i){return i.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[e])}function en(i){if(i.length===0)return "";let e=new Date(i[0].time).toLocaleString(),t=i.map(n=>`<div><span class="mlc-tooltip__name">${Tt(n.series.name)}:</span> ${n.value.toFixed(2)}</div>`);return `<div class="mlc-tooltip__time">${Tt(e)}</div>${t.join("")}`}function tn(i,e){if(i.length===0)return;let t=0,n=i.length-1;for(;t<n;){let s=t+n>>1;i[s].time<e?t=s+1:n=s;}let r=i[Math.max(0,t-1)],o=i[t];return Math.abs(r.time-e)<=Math.abs(o.time-e)?r:o}function nn(i){return "value"in i?i.value:i.avg}function me(i,e,t={}){let n=i.querySelector("svg");if(!n)throw new Error("attachTooltip: target has no <svg> child (did you mount the chart first?)");let r=t.format??en,o=t.snapRadius??1/0,s=t.className??"mlc-tooltip",a=t.showPicks??true,l=t.pickRadius??5,h=t.picksClassName??"mlc-tooltip-picks",m=document.createElement("div");m.className=s,m.style.position="absolute",m.style.pointerEvents="none",m.style.display="none",getComputedStyle(i).position==="static"&&(i.style.position="relative"),i.appendChild(m);let u=null;a&&(u=document.createElementNS(vt,"g"),u.setAttribute("class",h),u.setAttribute("pointer-events","none"),n.appendChild(u));let d=()=>{u&&u.replaceChildren();},c=e.series.map((C,F)=>({data:C.data.map(L=>({time:L.time,value:nn(L)})).filter(L=>L.value!==null).sort((L,N)=>L.time-N.time),series:C,index:F})),g=kt(),y=null,x=C=>{let F=n.getBoundingClientRect(),B=e.getWidth?.()??F.width,L=(C.clientX-F.left)*B/Math.max(1,F.width);e.getHeight?.()??F.height;let S=e.invertTime(L);if(!Number.isFinite(S)){m.style.display="none";return}let T=[];for(let E of c){let O=tn(E.data,S);if(!O)continue;let G=e.project(O.time,O.value,E.series.yAxisIndex??0).x,q=e.project(O.time,O.value,E.series.yAxisIndex??0).y;Math.abs(G-L)>o||T.push({seriesIndex:E.index,series:E.series,time:O.time,value:O.value,x:G,y:q});}if(T.length===0){m.style.display="none",d();return}m.innerHTML=r(T);let M=i.getBoundingClientRect(),$=12,_=(C.clientX-F.left)/Math.max(1,F.width),j=(C.clientY-F.top)/Math.max(1,F.height),A=_<.5?`${$}px`:`calc(-100% - ${$}px)`,P=j<.5?`${$}px`:`calc(-100% - ${$}px)`;if(m.style.left=`${C.clientX-M.left}px`,m.style.top=`${C.clientY-M.top}px`,m.style.transform=`translate(${A}, ${P})`,m.style.display="",u){u.replaceChildren();for(let E of T){let O=document.createElementNS(vt,"circle");O.setAttribute("cx",String(E.x)),O.setAttribute("cy",String(E.y)),O.setAttribute("r",String(l)),O.setAttribute("fill","#ffffff"),O.setAttribute("stroke",Qt(E.series)),O.setAttribute("stroke-width","2"),O.setAttribute("class",`${h}__dot`),u.appendChild(O);}}},k=C=>{y=C,g.schedule(()=>{y&&x(y);});},D=()=>{y=null,g.cancel(),m.style.display="none",d();};n.addEventListener("mousemove",k),n.addEventListener("mouseleave",D);let R=false;return ()=>{R||(R=true,y=null,g.cancel(),n.removeEventListener("mousemove",k),n.removeEventListener("mouseleave",D),m.remove(),u&&u.remove());}}function rn(i,e={}){let t=typeof i=="string"?document.querySelector(i):i;if(!t)throw new Error(`mount: target ${typeof i=="string"?`'${i}'`:""} not found`);let{tooltip:n,...r}=e,o=r.width??t.clientWidth??800,s=r.height??350,a=new J({...r,width:o,height:s}),{content:l}=new X().render(a.renderCommands());t.innerHTML=l;let h=t.querySelector("svg");return h&&(h.setAttribute("viewBox",`0 0 ${o} ${a.getHeight()}`),h.setAttribute("width","100%"),h.setAttribute("height",String(a.getHeight()))),n?.show&&me(t,a,n),a}var ke=class{_opts;_series=[];_thresholds=[];_annotations=[];_highlights=[];_markers=[];_bands=[];_tooltip;constructor(e,t){this._opts={},e!==void 0&&(this._opts.width=e),t!==void 0&&(this._opts.height=t);}setWidth(e){return this._opts.width=e,this}setHeight(e){return this._opts.height=e,this}setSize(e,t){return this._opts.width=e,this._opts.height=t,this}setMargin(e,t,n,r){return typeof e=="object"?this._opts.margin=e:this._opts.margin={top:e,right:t??0,bottom:n??0,left:r??0},this}setLocale(e){return this._opts.locale=e,this}setAxes(e){return this._opts.axes=e,this}setXAxis(e){return this._opts.axes={...this._opts.axes,x:{...this._opts.axes?.x,...e}},this}setLeftAxis(e){return this._opts.axes={...this._opts.axes,left:{...this._opts.axes?.left,...e}},this}setRightAxis(e){return this._opts.axes={...this._opts.axes,right:{...this._opts.axes?.right,...e}},this}setYAxis(e,t){this._opts.axes??={},this._opts.axes.y??=[];let n=[...this._opts.axes.y];for(;n.length<=e;)n.push({});return n[e]={...n[e],...t},this._opts.axes.y=n,this}setLegend(e,t,n){return typeof e=="object"?this._opts.legend=e:this._opts.legend={show:e,position:t,orientation:n},this}setGaps(e){return this._opts.gaps=e,this}setTooltip(e){return this._tooltip={show:true,...e},this}addSeries(e){return this._series.push(e),this}addSeriesAll(e){return this._series.push(...e),this}addThreshold(e){return this._thresholds.push(e),this}addThresholds(e){return this._thresholds.push(...e),this}addAnnotation(e){return this._annotations.push(e),this}addAnnotations(e){return this._annotations.push(...e),this}addHighlight(e){return this._highlights.push(e),this}addMarker(e){return this._markers.push(e),this}addAnnotationBand(e){return this._bands.push(e),this}clear(e){return (!e||e==="series")&&(this._series=[]),(!e||e==="thresholds")&&(this._thresholds=[]),(!e||e==="annotations")&&(this._annotations=[]),(!e||e==="highlights")&&(this._highlights=[]),(!e||e==="markers")&&(this._markers=[]),(!e||e==="bands")&&(this._bands=[]),this}toOptions(){return {...this._opts,series:this._series.length?this._series:this._opts.series,thresholds:this._thresholds.length?this._thresholds:this._opts.thresholds,annotations:this._annotations.length?this._annotations:this._opts.annotations,highlights:this._highlights.length?this._highlights:this._opts.highlights,markers:this._markers.length?this._markers:this._opts.markers,annotationBands:this._bands.length?this._bands:this._opts.annotationBands}}build(){return new J(this.toOptions())}getSvg(){let e=this.build(),{content:t}=new X().render(e.renderCommands());return t}mount(e){let t=typeof e=="string"?document.querySelector(e):e;if(!t){let s=typeof e=="string"?`'${e}'`:"";throw new Error(`GraphBuilder.mount: target ${s} not found`)}this._opts.width||(this._opts.width=t.clientWidth||800);let n=this.build(),{content:r}=new X().render(n.renderCommands());t.innerHTML=r;let o=t.querySelector("svg");if(o){let s=this._opts.width??800;o.setAttribute("viewBox",`0 0 ${s} ${n.getHeight()}`),o.setAttribute("width","100%"),o.setAttribute("height",String(n.getHeight()));}return this._tooltip?.show&&me(t,n,this._tooltip),n}};var ve=class{_series;constructor(e){this._series={name:e,data:[]};}addPoint(e,t){return this._series.data.push({time:e,value:t}),this}setData(e){return this._series.data=[...e],this}addPoints(e){return this._series.data.push(...e),this}addFloats(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)this._series.data.push({time:e[r],value:t[r]});return this}addNullPoint(e){return this._series.data.push({time:e,value:null}),this}setYAxisIndex(e){return this._series.yAxisIndex=e,this}setColor(e){return this._series.style??={},!this._series.style.line||typeof this._series.style.line=="boolean"?this._series.style.line={color:e}:Array.isArray(this._series.style.line)?this._series.style.line.length===0?this._series.style.line=[{color:e}]:this._series.style.line[0].color=e:this._series.style.line.color=e,this}setStyle(e){return this._series.style=e,this}setLineStyle(e,t,n){return this._series.style??={},this._series.style.line={color:e,width:t,style:n},this}setSmoothing(e){return this._series.style??={},!this._series.style.line||typeof this._series.style.line=="boolean"?this._series.style.line={smoothing:e}:Array.isArray(this._series.style.line)?this._series.style.line.length===0?this._series.style.line=[{smoothing:e}]:this._series.style.line[0].smoothing=e:this._series.style.line.smoothing=e,this}setFill(e){return this._series.style??={},this._series.style.fill=e,this}setID(e){return this._series.id=e,this}setColorByThresholds(e){return this._series.colorByThresholds=e,this}build(){return this._series}};var Te=class{_threshold;constructor(e,t){this._threshold={name:e,value:t};}setColor(e){return this._threshold.color=e,this}setLine(e){return this._threshold.line=e,this}setFill(e,t){return this._threshold.fill=e,this._threshold.fillOpacity=t,this}setFillHatch(e){return this._threshold.fillHatch=e,this}setLabel(e,t){return this._threshold.label={text:e,position:t},this}setID(e){return this._threshold.id=e,this}build(){return this._threshold}};var Ce=class{_marker;constructor(e){this._marker={time:e};}setValue(e){return this._marker.value=e,this}setLabel(e){return this._marker.label=e,this}setColor(e){return this._marker.color=e,this}setPointStyle(e){return this._marker.pointStyle=e,this}setLineStyle(e){return e==="none"?delete this._marker.lineStyle:this._marker.lineStyle=e,this}setSeriesIndex(e){return this._marker.seriesIndex=e,this}build(){return this._marker}};var $e=class{_highlight;constructor(e,t){this._highlight={startTime:e,endTime:t};}setLabel(e){return this._highlight.label=e,this}setColor(e){return this._highlight.color=e,this}setOpacity(e){return this._highlight.opacity=e,this}setLabelPosition(e){return this._highlight.labelPosition=e,this}setRotate(e){return this._highlight.rotate=e,this}build(){return this._highlight}};var Ae=class{_ann;constructor(e){this._ann={type:e};}setID(e){return this._ann.id=e,this}setTitle(e){return this._ann.title=e,this}setFrom(e,t,n){return this._ann.from={time:e,value:t,axis:n},this}setTo(e,t,n){return this._ann.to={time:e,value:t,axis:n},this}setAt(e,t,n){return this._ann.at={time:e,value:t,axis:n},this}setColor(e){return this._ann.color=e,this}setWidth(e){return this._ann.width=e,this}setDash(e){return this._ann.dash=e,this}setHeadSize(e){return this._ann.headSize=e,this}setFill(e){return this._ann.fill=e,this}setHatch(e){return this._ann.hatch=e,this}setStroke(e){return this._ann.stroke=e,this}setOpacity(e){return this._ann.opacity=e,this}setRadius(e){return this._ann.radius=e,this}setShape(e){return this._ann.shape=e,this}setText(e){return this._ann.text=e,this}setAnchor(e){return this._ann.anchor=e,this}setDx(e){return this._ann.dx=e,this}setDy(e){return this._ann.dy=e,this}setRotate(e){return this._ann.rotate=e,this}build(){return this._ann}};var De=class{_band;constructor(e){this._band={name:e,items:[]};}setHeight(e){return this._band.height=e,this}setSpacing(e){return this._band.spacing=e,this}setHatch(e){return this._band.hatch=e,this}setShowAxis(e){return this._band.showAxis=e,this}setShowInLegend(e){return this._band.showInLegend=e,this}setBackground(e){return this._band.background=e,this}addItem(e){return this._band.items.push(e),this}build(){return this._band}},Le=class{_item;constructor(e,t){this._item={startTime:e,endTime:t};}setFill(e){return this._item.fill=e,this}setHatch(e){return this._item.hatch=e,this}setStroke(e){return this._item.stroke=e,this}setStrokeWidth(e){return this._item.strokeWidth=e,this}setLabel(e,t,n,r){return this._item.label=e,t!==void 0&&(this._item.labelFontSize=t),n!==void 0&&(this._item.labelFill=n),r!==void 0&&(this._item.labelBaseline=r),this}build(){return this._item}};function on(i){let{thresholds:e,colors:t,hatches:n}=i;if(t.length!==e.length+1)throw new Error(`fillBetweenThresholds: expected ${e.length+1} colors for ${e.length} thresholds, got ${t.length}`);if(n!==void 0&&n.length!==t.length)throw new Error(`fillBetweenThresholds: hatches length (${n.length}) must equal colors length (${t.length})`);return {regions:t.map((o,s)=>{let a=n?.[s],l=a?{color:o,hatch:a}:o;return s===0?{to:{threshold:e[0]},fill:l}:s===t.length-1?{from:{threshold:e[e.length-1]},fill:l}:{from:{threshold:e[s-1]},to:{threshold:e[s]},fill:l}})}}function qe(i){if(!i||typeof i!="object")throw new Error("DataPoint: object expected");let{time:e,value:t,annotation:n}=i;if(typeof e!="number"||Number.isNaN(e))throw new TypeError(`DataPoint: invalid time=${e}`);if(t!==null&&(typeof t!="number"||Number.isNaN(t)))throw new Error(`DataPoint: invalid value=${t}`);return {time:e,value:t,annotation:n&&typeof n=="string"?n:void 0}}function sn(i){if(Array.isArray(i))return i.map(qe);if(i&&typeof i=="object"){let e=i,t=e.name,n=e.data,r=e.sensorType,o=e.enumMap,s=e.color,a=e.lineWidth,l=e.smoothing,h=e.seriesType;if(!t||!t.length)throw new Error("Series: name required");if(!Array.isArray(n))throw new Error("Series: data must be an array");let m=s!==void 0||a!==void 0||l!==void 0?{color:s,width:a,smoothing:l}:void 0;return {name:t,data:n.map(qe),sensorType:r??"numeric",enumMap:o,seriesType:h,...m&&{style:{line:m}}}}throw new Error("parseSeries: object or DataPoint[] expected")}function an(i){if(!i||typeof i!="object")throw new Error("parseAggregated: object expected");let e=i,t=e.name,n=e.data,r=e.showAs,o=e.avgLine,s=e.countOpacity,a=e.color;if(!t?.length)throw new Error("AggregatedSeries: name required");if(!Array.isArray(n))throw new Error("AggregatedSeries: data must be an array");return {name:t,data:ln(n),showAs:r,avgLine:o,countOpacity:s,...a!==void 0&&{style:{line:{color:a},fill:a}}}}function ln(i){let e=t=>typeof t=="number"?t:null;return i.map(t=>{let n=t;return {time:n.time??0,min:e(n.min),max:e(n.max),avg:e(n.avg),count:typeof n.count=="number"?n.count:0}})}function Xe(i,e,t){return typeof e=="function"?e(i):i[e??t]}function hn(i,e,t){if(i instanceof Date){let n=i.getTime();if(Number.isNaN(n))throw new TypeError(`toDataPoints: invalid Date at row ${t}`);return n}if(typeof i=="string"){let n=Date.parse(i);if(Number.isNaN(n))throw new TypeError(`toDataPoints: unparsable time string at row ${t}: ${i}`);return n}if(typeof i=="number"&&Number.isFinite(i))return e==="s"||e==="auto"&&Math.abs(i)>=1e8&&Math.abs(i)<1e11?i*1e3:i;throw new TypeError(`toDataPoints: missing or invalid time at row ${t}: ${String(i)}`)}function mn(i,e){if(i==null)return null;if(typeof i=="number")return Number.isNaN(i)?null:i;if(typeof i=="string"){let t=i.trim();if(t==="")return null;let n=Number(t);if(Number.isNaN(n))throw new TypeError(`toDataPoints: value is not a number at row ${e}: ${i}`);return n}throw new TypeError(`toDataPoints: invalid value at row ${e}: ${String(i)}`)}function Ct(i,e={}){let t=e.timeUnit??"ms",n=[];for(let r=0;r<i.length;r++){let o=i[r];if(o==null)throw new TypeError(`toDataPoints: empty row at ${r}`);let s=Array.isArray(o),a=s&&e.time===void 0?o[0]:Xe(o,e.time,"time"),l=s&&e.value===void 0?o[1]:Xe(o,e.value,"value"),h={time:hn(a,t,r),value:mn(l,r)};if(e.annotation!==void 0){let m=Xe(o,e.annotation,"annotation");typeof m=="string"&&m!==""&&(h.annotation=m);}n.push(h);}return (e.sort??true)&&n.sort((r,o)=>r.time-o.time),n}function un(i,e,t={}){return {name:i,data:Ct(e,t)}}function $t(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function At(i,e){if(!$t(i)||!$t(e))return e;let t={...i};for(let[n,r]of Object.entries(e))t[n]=At(t[n],r);return t}function dn(...i){let e;for(let t of i)t!==void 0&&(e=At(e,t));return e??{}}/*!
|
|
47
48
|
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
|
48
49
|
* MIT with Attribution: free use incl. commercial requires visible credit to
|
|
49
50
|
* "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
|
|
@@ -62,4 +63,4 @@ ${e}
|
|
|
62
63
|
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
|
63
64
|
* MIT with Attribution: free use incl. commercial must have visible credit to
|
|
64
65
|
* "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
|
|
65
|
-
*/export{
|
|
66
|
+
*/export{De as AnnotationBandBuilder,Le as AnnotationBandItemBuilder,Ae as AnnotationBuilder,ke as GraphBuilder,$e as HighlightBuilder,J as MLTimeGraph,Ce as MarkerBuilder,X as SVGRenderer,Te as ThresholdBuilder,ve as TimeSeriesBuilder,Ye as VERSION,me as attachTooltip,fe as drawMarker,on as fillBetweenThresholds,ne as getDefaultTheme,et as getLineStyle,dn as mergeOptions,rn as mount,an as parseAggregated,qe as parseDataPoint,sn as parseSeries,Pt as resetDefaultTheme,Ie as resolveDash,Mt as setDefaultTheme,ee as slugify,Ct as toDataPoints,un as toSeries};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as DataPoint, D as DrawCommand, d as TimeScale, e as LinearScale } from '../scale-
|
|
1
|
+
import { l as DataPoint, D as DrawCommand, d as TimeScale, e as LinearScale } from '../scale-CoTgJ27U.js';
|
|
2
2
|
|
|
3
3
|
/*!
|
|
4
4
|
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var C=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,
|
|
1
|
+
var C=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,u=p-e*s,c=p+e*(1-s),[b,_]=this._state.originalDomain;c-u>_-b?(u=b,c=_,e=_-b):(u<b&&(c=_-(_-b)*((c-u)/(_-b)),u=b),c>_&&(u=b+(_-b)*((u-b)/(_-b)),c=_)),this._state.domain=[u,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(h,t){return `${h}|${JSON.stringify(t??{})}`}function k(h,t){let n=R(h,t),o=w.get(n);return o||(o=new Intl.DateTimeFormat(h,t),w.set(n,o)),o}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||(typeof navigator<"u"?navigator.language:"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 v(h){let t=1/0,n=-1/0;for(let o=0;o<h.length;o++){let r=h[o];r<t&&(t=r),r>n&&(n=r);}return [t,n]}var M={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 I={...M};function S(){return I}var f=new Proxy({},{get:(h,t)=>S()[t],has:(h,t)=>t in S(),ownKeys:()=>Reflect.ownKeys(S()),getOwnPropertyDescriptor:(h,t)=>Reflect.getOwnPropertyDescriptor(S(),t)});var D=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=v(n),i=v(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=v(n),r=new x({domain:o,range:[0,this._width]}),i=t-this._x;return r.invert(i)}};var T=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(u=>u.value!==null).sort((u,c)=>u.time-c.time),n,o=1/0;for(let u of t){let c=this._timeScale.map(u.time),b=Math.abs(this._mouseX-c);b<o&&(o=b,n=u);}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:10,fill:this._textColor},{type:"text",content:`Value: ${s}`,x:m+8,y:p+32,fontSize:11,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.
|