ml-time-graph 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -108,7 +108,10 @@ after-the-fact evaluation is what matters.
108
108
 
109
109
  ## Goals
110
110
 
111
- - ✅ **No browser dependency** — rendering is decoupled from the DOM (SVG string, in the browser and server-side)
111
+ - ✅ **No browser dependency in the renderer** — the chart is an SVG string, in the browser and
112
+ server-side. The optional interaction layer (`ml-time-graph/interaction`: zoom, minimap, tooltip)
113
+ is headless too — it computes state and coordinates, you place the elements. Only `mount()` and
114
+ `attachTooltip()` from the main entry touch a document, and only when you call them.
112
115
  - ✅ **Fully typed** — TypeScript throughout
113
116
  - ✅ **Easy integration** into existing projects
114
117
  - ✅ **i18n-aware** — localized time axes and formatting
@@ -1,4 +1,4 @@
1
- var H=class{static interpolateDataPoint(n,i,t){return {time:n.time+t*(i.time-n.time),value:(n.value??0)+t*((i.value??0)-(n.value??0))}}static interpolateAggregatedPoint(n,i,t){let u=(e,l)=>e!==null&&l!==null?e+t*(l-e):null;return {time:n.time+t*(i.time-n.time),min:u(n.min,i.min),max:u(n.max,i.max),avg:u(n.avg,i.avg),count:Math.round(n.count+t*(i.count-n.count))}}static getRuns(n,i,t=0){let u=[...n].sort((r,o)=>r.time-o.time),e=[],l=[],a=null;for(let r of u){let o=i(r),m=t>0&&a&&r.time-a.time>t;(o||m)&&l.length&&(e.push(l),l=[]),o||l.push(r),a=r;}return l.length&&e.push(l),e}static splitByBoundaries(n,i,t,u){if(n.length===0)return [];if(i.length===0)return [{data:n,zoneIndex:0}];let e=[...i].sort((o,m)=>o-m),l=[],a=o=>{let m=0;for(let s=0;s<e.length&&o>=e[s];s++)m=s+1;return m},r=[n[0]];for(let o=1;o<n.length;o++){let m=n[o-1],s=n[o],h=t(m),g=t(s),d;g>h?d=e.filter(c=>c>h&&c<=g):g<h?d=e.filter(c=>c>=g&&c<h).reverse():d=[];for(let c of d){let p=(c-h)/(g-h),x=u(m,s,p);r.push(x),l.push({data:r,zoneIndex:a((h+c)/2)}),r=[x];}r.push(s);}if(r.length>0){let o=t(r[0]),m=t(r[r.length-1]);l.push({data:r,zoneIndex:a((o+m)/2)});}return l}static splitByThreshold(n,i,t,u){let e=this.splitByBoundaries(n,[i],t,u),l={above:[],below:[]};for(let a of e)a.zoneIndex===0?l.below.push(a.data):l.above.push(a.data);return l}},S={pharma_cold:{limitLow:2,limitHigh:8,activationEnergy:83144},pharma_ambient:{limitLow:15,limitHigh:25,activationEnergy:83144},blood:{limitLow:2,limitHigh:6,activationEnergy:83144},food_chilled:{limitLow:0,limitHigh:4},frozen:{limitLow:-40,limitHigh:-18}},T=8.314462618,w=273.15;function y(n,i,t,u=1){let e=i.filter(f=>f.value!==null&&f.value!==void 0&&!isNaN(f.value)).map(f=>f.value);if(!e.length)return {time:n,min:null,max:null,avg:null,mkt:null,deltaMkt:null,stdDev:null,minutesAboveHigh:t?0:null,minutesBelowLow:t?0:null,count:0};let l=Math.min(...e),a=Math.max(...e),r=e.reduce((f,v)=>f+v,0)/e.length,o=t?0:null,m=t?0:null;if(t)for(let f=0;f<i.length;f++){let v=i[f];if(v.value!==null&&v.value!==void 0){let b=i[f+1],M=(b?b.time-v.time:0)/(1e3*60);v.value>t.limitHigh&&(o+=M),v.value<t.limitLow&&(m+=M);}}let s=0,h=0,g=(t?.activationEnergy??83144)/T;for(let f of e){s+=Math.pow(f-r,2);let v=f+w;h+=Math.exp(-g/v);}let d=s/e.length,c=Math.sqrt(d),p=null,x=null;if(e.length>=u){let f=h/e.length,v=g/-Math.log(f);p=Number((v-w).toFixed(2)),x=Number((p-r).toFixed(2));}return {time:n,min:Number(l.toFixed(2)),max:Number(a.toFixed(2)),avg:Number(r.toFixed(2)),mkt:p,deltaMkt:x,stdDev:Number(c.toFixed(2)),minutesAboveHigh:o!==null?Number(o.toFixed(1)):null,minutesBelowLow:m!==null?Number(m.toFixed(1)):null,count:e.length}}function D(n,i="hourly",t,u,e=1){if(!n.length)return [];let l=i==="hourly"?36e5:i==="daily"?864e5:t??3600*1e3,a=[...n].sort((s,h)=>s.time-h.time),r=[],o=a[0].time,m=[];for(let s of a){for(;s.time-o>=l;)r.push(y(o,m,u,e)),o+=l,m=[];m.push(s);}return r.push(y(o,m,u,e)),r}function E(n,i){let t=Math.min(...i),u=Math.max(...i),e=i.reduce((l,a)=>l+a,0)/i.length;return {time:n,min:t,max:u,avg:e,count:i.length}}function B(n,i=6e4){if(n.length<2)return [];let t=[...n].sort((e,l)=>e.time-l.time),u=[];for(let e=1;e<t.length;e++)t[e].time-t[e-1].time>i&&u.push({startTime:t[e-1].time,endTime:t[e].time});return u}function z(n){let i=[],t=0,u=0,e=0,l=0;for(let a of n)a.count>0&&(e++,a.minutesAboveHigh&&(t+=a.minutesAboveHigh),a.stdDev&&a.stdDev>u&&(u=a.stdDev),a.deltaMkt&&a.deltaMkt>2&&l++);return e===0?[]:(t>120&&i.push({type:"critical",message:`Kritische Gesamtbelastung: Das Produkt war im gesamten Zeitraum insgesamt ${Math.round(t)} Minuten zu warm.`,metric:"Total Excursion Time"}),l>e*.15&&i.push({type:"warning",message:"Frequent thermal shocks detected. The kinetic temperature deviates strongly from the average (possible regular door openings).",metric:"Delta MKT Instability"}),u>4&&i.push({type:"warning",message:`High instability measured. Maximum standard deviation was ${u}\xB0C. The cooling system controls imprecisely.`,metric:"Standard Deviation Peak"}),i)}function I(n,i){if(n.length<=i)return n;let t=[],u=Math.ceil(n.length/i);t.push(n[0]);for(let e=1;e<n.length;e+=u)t.push(n[Math.min(e,n.length-1)]);return t}function C(n,i="hourly",t){let u={limitLow:t.low,limitHigh:t.high,activationEnergy:t.activationEnergy};return D(n,i,t.interval,u,t.minCountForMkt??1)}var P=class{static compute(n){let i=n.map(r=>r.value).filter(r=>r!==null).sort((r,o)=>r-o);if(i.length===0)return {min:NaN,max:NaN,avg:NaN,mean:NaN,median:NaN,stdDev:NaN,count:0};let t=i.length,u=i.reduce((r,o)=>r+o,0)/t,e=t%2===1?i[Math.floor(t/2)]:(i[t/2-1]+i[t/2])/2,l=i.reduce((r,o)=>r+Math.pow(o-u,2),0)/t,a=Math.sqrt(l);return {min:i[0],max:i[t-1],avg:u,mean:u,median:e,stdDev:a,count:t}}static computeInRange(n,i,t){let u=n.filter(e=>e.time>=i&&e.time<=t);return this.compute(u)}};function _(n,i){let t=typeof n=="number"?n:n.mean,u=typeof n=="number"?i??NaN:n.stdDev;return !Number.isFinite(t)||!Number.isFinite(u)||t===0?null:Math.abs(u/t)*100}var q=83144;function k(n,i=83144){let t=i/8.314,u=0,e=0;for(let a of n)a!==null&&(u+=Math.exp(-t/(a+273.15)),e++);if(e===0)return null;let l=u/e;return t/-Math.log(l)-273.15}function R(n,i,t=83144){let u=new Array(n.length),e=0;for(let l=0;l<n.length;l++){let a=n[l].time,r=a-i;for(;e<l&&n[e].time<r;)e++;let o=n.slice(e,l+1).map(s=>s.value),m=k(o,t);u[l]={time:a,value:m,synthetic:true};}return u}function F(n){let i=0,t=0;for(let l of n)l!==null&&(i+=l,t++);if(t===0)return null;let u=i/t,e=0;for(let l of n){if(l===null)continue;let a=l-u;e+=a*a;}return Math.sqrt(e/t)}function L(n){let i=0,t=0;for(let l of n)l!==null&&(i+=l,t++);if(t<2)return null;let u=i/t,e=0;for(let l of n){if(l===null)continue;let a=l-u;e+=a*a;}return Math.sqrt(e/(t-1))}function G(n,i,t=false){let u=new Array(n.length),e=0,l=t?L:F;for(let a=0;a<n.length;a++){let r=n[a].time,o=r-i;for(;e<a&&n[e].time<o;)e++;let m=n.slice(e,a+1).map(h=>h.value),s=l(m);u[a]={time:r,value:s,synthetic:true};}return u}function K(n,i){let{high:t,low:u}=i,e={msAboveHigh:0,msBelowLow:0,globalMax:null,globalMin:null,excursions:[]},l=null;for(let a=0;a<n.length;a++){let r=n[a];if(r.value===null){l&&(e.excursions.push(l),l=null);continue}(e.globalMax===null||r.value>e.globalMax)&&(e.globalMax=r.value),(e.globalMin===null||r.value<e.globalMin)&&(e.globalMin=r.value);let o=t!==void 0&&r.value>t,m=u!==void 0&&r.value<u,s=o?"above":m?"below":null,h=n[a-1];if(h&&h.value!==null&&s!==null){let g=r.time-h.time;s==="above"?e.msAboveHigh+=g:e.msBelowLow+=g;}if(s===null){l&&(e.excursions.push(l),l=null);continue}l&&l.side===s?(l.endTime=r.time,l.durationMs=l.endTime-l.startTime,(s==="above"&&r.value>l.extremum||s==="below"&&r.value<l.extremum)&&(l.extremum=r.value)):(l&&e.excursions.push(l),l={startTime:r.time,endTime:r.time,side:s,extremum:r.value,durationMs:0});}return l&&e.excursions.push(l),e}function O(n){if(n.length===0)return [];let i=new Map;for(let u of n)for(let e of u.data){if(e.value===null)continue;let l=i.get(e.time);l||(l=[],i.set(e.time,l)),l.push({name:u.name,value:e.value});}let t=[];for(let u of [...i.keys()].sort((e,l)=>e-l)){let e=i.get(u);if(e.length===0){t.push({time:u,min:null,max:null,delta:null,minSensor:null,maxSensor:null});continue}let l=e[0],a=e[0];for(let r=1;r<e.length;r++)e[r].value<l.value&&(l=e[r]),e[r].value>a.value&&(a=e[r]);t.push({time:u,min:l.value,max:a.value,delta:e.length<2?null:a.value-l.value,minSensor:l.name,maxSensor:a.name});}return t}function U(n){let i=[];for(let e of n){let l=0,a=0,r=1/0,o=-1/0;for(let m of e.data)m.value!==null&&(l+=m.value,a++,m.value<r&&(r=m.value),m.value>o&&(o=m.value));a!==0&&i.push({name:e.name,mean:l/a,min:r,max:o,count:a});}if(i.length===0)return {sensors:[],hottest:null,coldest:null,meanDelta:null};let t=i[0],u=i[0];for(let e=1;e<i.length;e++)i[e].mean>t.mean&&(t=i[e]),i[e].mean<u.mean&&(u=i[e]);return {sensors:i,hottest:t,coldest:u,meanDelta:t.mean-u.mean}}function N(n){let i=0,t=0,u=0,e=0,l=0;for(let m of n)m.value!==null&&(i++,t+=m.time,u+=m.value,e+=m.time*m.value,l+=m.time*m.time);if(i<2)return null;let a=i*l-t*t;if(a===0)return null;let r=(i*e-t*u)/a,o=(u-r*t)/i;return {slope:r,intercept:o,n:i}}function A(n,i){if(n.length===0)return null;let t=n[n.length-1].time,u=t-i,e=n.filter(l=>l.time>=u&&l.time<=t);return N(e)}function V(n,i){let t=[],u=0;for(let e=0;e<n.length;e++){let l=n[e].time,a=l-i;for(;u<n.length&&n[u].time<a;)u++;let r=N(n.slice(u,e+1));t.push({time:l,fit:r});}return t}function W(n,i,t={}){let u=t.lookbackMs??9e5,e=t.side??"either";if(n.length===0)return null;let l=n[n.length-1];if(l.value===null)return null;let a=A(n,u);if(!a||a.slope===0)return null;let r=a.slope>0&&l.value<i,o=a.slope<0&&l.value>i;if(e==="above"&&!r||e==="below"&&!o||e==="either"&&!r&&!o)return null;let m=(i-a.intercept)/a.slope,s=m-l.time;return s<=0?null:{msUntil:s,eta:m,fit:a,currentValue:l.value}}function Y(n,i={}){let t=i.refTempCelsius??121.11,u=i.zValueKelvin??10,e=0;for(let l=0;l<n.length-1;l++){let a=n[l],r=n[l+1];if(a.value===null||r.value===null)continue;let o=(r.time-a.time)/6e4;if(o<=0)continue;let m=Math.pow(10,(a.value-t)/u),s=Math.pow(10,(r.value-t)/u);e+=(m+s)/2*o;}return e}/*!
1
+ var S=class{static interpolateDataPoint(n,i,t){return {time:n.time+Math.round(t*(i.time-n.time)),value:(n.value??0)+t*((i.value??0)-(n.value??0))}}static interpolateAggregatedPoint(n,i,t){let a=(e,l)=>e!==null&&l!==null?e+t*(l-e):null;return {time:n.time+t*(i.time-n.time),min:a(n.min,i.min),max:a(n.max,i.max),avg:a(n.avg,i.avg),count:Math.round(n.count+t*(i.count-n.count))}}static getRuns(n,i,t=0){let a=[...n].sort((r,o)=>r.time-o.time),e=[],l=[],u=null;for(let r of a){let o=i(r),s=t>0&&u&&r.time-u.time>t;(o||s)&&l.length&&(e.push(l),l=[]),o||l.push(r),u=r;}return l.length&&e.push(l),e}static splitByBoundaries(n,i,t,a){if(n.length===0)return [];if(i.length===0)return [{data:n,zoneIndex:0}];let e=[...i].sort((o,s)=>o-s),l=[],u=o=>{let s=0;for(let m=0;m<e.length&&o>=e[m];m++)s=m+1;return s},r=[n[0]];for(let o=1;o<n.length;o++){let s=n[o-1],m=n[o],f=t(s),g=t(m),d;g>f?d=e.filter(v=>v>f&&v<=g):g<f?d=e.filter(v=>v>=g&&v<f).reverse():d=[];for(let v of d){let x=(v-f)/(g-f),p=a(s,m,x);r.push(p),l.push({data:r,zoneIndex:u((f+v)/2)}),r=[p];}r.push(m);}if(r.length>0){let o=t(r[0]),s=t(r[r.length-1]);l.push({data:r,zoneIndex:u((o+s)/2)});}return l}static splitByThreshold(n,i,t,a){let e=this.splitByBoundaries(n,[i],t,a),l={above:[],below:[]};for(let u of e)u.zoneIndex===0?l.below.push(u.data):l.above.push(u.data);return l}},E={pharma_cold:{limitLow:2,limitHigh:8,activationEnergy:83144},pharma_ambient:{limitLow:15,limitHigh:25,activationEnergy:83144},blood:{limitLow:2,limitHigh:6,activationEnergy:83144},food_chilled:{limitLow:0,limitHigh:4},frozen:{limitLow:-40,limitHigh:-18}},D=8.314462618,y=273.15;function N(n,i,t,a=1){let e=i.filter(h=>h.value!==null&&h.value!==void 0&&!isNaN(h.value)).map(h=>h.value);if(!e.length)return {time:n,min:null,max:null,avg:null,mkt:null,deltaMkt:null,stdDev:null,minutesAboveHigh:t?0:null,minutesBelowLow:t?0:null,count:0};let l=1/0,u=-1/0,r=0;for(let h of e)h<l&&(l=h),h>u&&(u=h),r+=h;let o=r/e.length,s=t?0:null,m=t?0:null;if(t)for(let h=0;h<i.length;h++){let c=i[h];if(c.value!==null&&c.value!==void 0){let M=i[h+1],w=(M?M.time-c.time:0)/(1e3*60);c.value>t.limitHigh&&(s+=w),c.value<t.limitLow&&(m+=w);}}let f=0,g=0,d=(t?.activationEnergy??83144)/D;for(let h of e){f+=Math.pow(h-o,2);let c=h+y;g+=Math.exp(-d/c);}let v=f/e.length,x=Math.sqrt(v),p=null,b=null;if(e.length>=a){let h=g/e.length,c=d/-Math.log(h);p=Number((c-y).toFixed(2)),b=Number((p-o).toFixed(2));}return {time:n,min:Number(l.toFixed(2)),max:Number(u.toFixed(2)),avg:Number(o.toFixed(2)),mkt:p,deltaMkt:b,stdDev:Number(x.toFixed(2)),minutesAboveHigh:s!==null?Number(s.toFixed(1)):null,minutesBelowLow:m!==null?Number(m.toFixed(1)):null,count:e.length}}function k(n,i="hourly",t,a,e=1){if(!n.length)return [];let l=i==="hourly"?36e5:i==="daily"?864e5:t??3600*1e3,u=[...n].sort((m,f)=>m.time-f.time),r=[],o=u[0].time,s=[];for(let m of u){for(;m.time-o>=l;)r.push(N(o,s,a,e)),o+=l,s=[];s.push(m);}return r.push(N(o,s,a,e)),r}function B(n,i){let t=1/0,a=-1/0,e=0;for(let u of i)u<t&&(t=u),u>a&&(a=u),e+=u;let l=e/i.length;return {time:n,min:t,max:a,avg:l,count:i.length}}function z(n,i=6e4){if(n.length<2)return [];let t=[...n].sort((e,l)=>e.time-l.time),a=[];for(let e=1;e<t.length;e++)t[e].time-t[e-1].time>i&&a.push({startTime:t[e-1].time,endTime:t[e].time});return a}function I(n){let i=[],t=0,a=0,e=0,l=0;for(let u of n)u.count>0&&(e++,u.minutesAboveHigh&&(t+=u.minutesAboveHigh),u.stdDev&&u.stdDev>a&&(a=u.stdDev),u.deltaMkt&&u.deltaMkt>2&&l++);return e===0?[]:(t>120&&i.push({type:"critical",message:`Kritische Gesamtbelastung: Das Produkt war im gesamten Zeitraum insgesamt ${Math.round(t)} Minuten zu warm.`,metric:"Total Excursion Time"}),l>e*.15&&i.push({type:"warning",message:"Frequent thermal shocks detected. The kinetic temperature deviates strongly from the average (possible regular door openings).",metric:"Delta MKT Instability"}),a>4&&i.push({type:"warning",message:`High instability measured. Maximum standard deviation was ${a}\xB0C. The cooling system controls imprecisely.`,metric:"Standard Deviation Peak"}),i)}function C(n,i){if(n.length<=i)return n;let t=[],a=Math.ceil(n.length/i);t.push(n[0]);for(let e=1;e<n.length;e+=a)t.push(n[Math.min(e,n.length-1)]);return t}function P(n,i="hourly",t){let a={limitLow:t.low,limitHigh:t.high,activationEnergy:t.activationEnergy};return k(n,i,t.interval,a,t.minCountForMkt??1)}var _=class{static compute(n){let i=n.map(r=>r.value).filter(r=>r!==null).sort((r,o)=>r-o);if(i.length===0)return {min:NaN,max:NaN,avg:NaN,mean:NaN,median:NaN,stdDev:NaN,count:0};let t=i.length,a=i.reduce((r,o)=>r+o,0)/t,e=t%2===1?i[Math.floor(t/2)]:(i[t/2-1]+i[t/2])/2,l=i.reduce((r,o)=>r+Math.pow(o-a,2),0)/t,u=Math.sqrt(l);return {min:i[0],max:i[t-1],avg:a,mean:a,median:e,stdDev:u,count:t}}static computeInRange(n,i,t){let a=n.filter(e=>e.time>=i&&e.time<=t);return this.compute(a)}};function q(n,i){let t=typeof n=="number"?n:n.mean,a=typeof n=="number"?i??NaN:n.stdDev;return !Number.isFinite(t)||!Number.isFinite(a)||t===0?null:Math.abs(a/t)*100}var R=83144;function F(n,i=83144){let t=i/8.314,a=0,e=0;for(let u of n)u!==null&&(a+=Math.exp(-t/(u+273.15)),e++);if(e===0)return null;let l=a/e;return t/-Math.log(l)-273.15}function G(n,i,t=83144){let a=new Array(n.length),e=0;for(let l=0;l<n.length;l++){let u=n[l].time,r=u-i;for(;e<l&&n[e].time<r;)e++;let o=n.slice(e,l+1).map(m=>m.value),s=F(o,t);a[l]={time:u,value:s,synthetic:true};}return a}function L(n){let i=0,t=0;for(let l of n)l!==null&&(i+=l,t++);if(t===0)return null;let a=i/t,e=0;for(let l of n){if(l===null)continue;let u=l-a;e+=u*u;}return Math.sqrt(e/t)}function A(n){let i=0,t=0;for(let l of n)l!==null&&(i+=l,t++);if(t<2)return null;let a=i/t,e=0;for(let l of n){if(l===null)continue;let u=l-a;e+=u*u;}return Math.sqrt(e/(t-1))}function K(n,i,t=false){let a=new Array(n.length),e=0,l=t?A:L;for(let u=0;u<n.length;u++){let r=n[u].time,o=r-i;for(;e<u&&n[e].time<o;)e++;let s=n.slice(e,u+1).map(f=>f.value),m=l(s);a[u]={time:r,value:m,synthetic:true};}return a}function O(n,i){let{high:t,low:a}=i,e={msAboveHigh:0,msBelowLow:0,globalMax:null,globalMin:null,excursions:[]},l=null;for(let u=0;u<n.length;u++){let r=n[u];if(r.value===null){l&&(e.excursions.push(l),l=null);continue}(e.globalMax===null||r.value>e.globalMax)&&(e.globalMax=r.value),(e.globalMin===null||r.value<e.globalMin)&&(e.globalMin=r.value);let o=t!==void 0&&r.value>t,s=a!==void 0&&r.value<a,m=o?"above":s?"below":null,f=n[u-1];if(f&&f.value!==null&&m!==null){let g=r.time-f.time;m==="above"?e.msAboveHigh+=g:e.msBelowLow+=g;}if(m===null){l&&(e.excursions.push(l),l=null);continue}l&&l.side===m?(l.endTime=r.time,l.durationMs=l.endTime-l.startTime,(m==="above"&&r.value>l.extremum||m==="below"&&r.value<l.extremum)&&(l.extremum=r.value)):(l&&e.excursions.push(l),l={startTime:r.time,endTime:r.time,side:m,extremum:r.value,durationMs:0});}return l&&e.excursions.push(l),e}function U(n){if(n.length===0)return [];let i=new Map;for(let a of n)for(let e of a.data){if(e.value===null)continue;let l=i.get(e.time);l||(l=[],i.set(e.time,l)),l.push({name:a.name,value:e.value});}let t=[];for(let a of [...i.keys()].sort((e,l)=>e-l)){let e=i.get(a);if(e.length===0){t.push({time:a,min:null,max:null,delta:null,minSensor:null,maxSensor:null});continue}let l=e[0],u=e[0];for(let r=1;r<e.length;r++)e[r].value<l.value&&(l=e[r]),e[r].value>u.value&&(u=e[r]);t.push({time:a,min:l.value,max:u.value,delta:e.length<2?null:u.value-l.value,minSensor:l.name,maxSensor:u.name});}return t}function V(n){let i=[];for(let e of n){let l=0,u=0,r=1/0,o=-1/0;for(let s of e.data)s.value!==null&&(l+=s.value,u++,s.value<r&&(r=s.value),s.value>o&&(o=s.value));u!==0&&i.push({name:e.name,mean:l/u,min:r,max:o,count:u});}if(i.length===0)return {sensors:[],hottest:null,coldest:null,meanDelta:null};let t=i[0],a=i[0];for(let e=1;e<i.length;e++)i[e].mean>t.mean&&(t=i[e]),i[e].mean<a.mean&&(a=i[e]);return {sensors:i,hottest:t,coldest:a,meanDelta:t.mean-a.mean}}function T(n){let i=0,t=0,a=0,e=0,l=0;for(let s of n)s.value!==null&&(i++,t+=s.time,a+=s.value,e+=s.time*s.value,l+=s.time*s.time);if(i<2)return null;let u=i*l-t*t;if(u===0)return null;let r=(i*e-t*a)/u,o=(a-r*t)/i;return {slope:r,intercept:o,n:i}}function H(n,i){if(n.length===0)return null;let t=n[n.length-1].time,a=t-i,e=n.filter(l=>l.time>=a&&l.time<=t);return T(e)}function W(n,i){let t=[],a=0;for(let e=0;e<n.length;e++){let l=n[e].time,u=l-i;for(;a<n.length&&n[a].time<u;)a++;let r=T(n.slice(a,e+1));t.push({time:l,fit:r});}return t}function Y(n,i,t={}){let a=t.lookbackMs??9e5,e=t.side??"either";if(n.length===0)return null;let l=n[n.length-1];if(l.value===null)return null;let u=H(n,a);if(!u||u.slope===0)return null;let r=u.slope>0&&l.value<i,o=u.slope<0&&l.value>i;if(e==="above"&&!r||e==="below"&&!o||e==="either"&&!r&&!o)return null;let s=(i-u.intercept)/u.slope,m=s-l.time;return m<=0?null:{msUntil:m,eta:s,fit:u,currentValue:l.value}}function Z(n,i={}){let t=i.refTempCelsius??121.11,a=i.zValueKelvin??10,e=0;for(let l=0;l<n.length-1;l++){let u=n[l],r=n[l+1];if(u.value===null||r.value===null)continue;let o=(r.time-u.time)/6e4;if(o<=0)continue;let s=Math.pow(10,(u.value-t)/a),m=Math.pow(10,(r.value-t)/a);e+=(s+m)/2*o;}return e}/*!
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.
@@ -12,4 +12,4 @@ var H=class{static interpolateDataPoint(n,i,t){return {time:n.time+t*(i.time-n.t
12
12
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
13
13
  * MIT with Attribution: free use incl. commercial requires visible credit to
14
14
  * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
15
- */export{q as DEFAULT_ACTIVATION_ENERGY,S as PRODUCT_PROFILES,H as SeriesProcessor,P as StatsAggregator,D as aggregateBySlot,C as aggregateWithStats,z as analyzeLongTermTrends,K as computeLimitExcursions,E as createAggr,A as currentTrend,B as detectGaps,I as downsample,Y as f0Sterilization,U as hotColdSpots,N as linearFit,k as mkt,W as predictTimeToThreshold,R as rollingMkt,G as rollingStdDev,V as rollingTrend,L as sampleStdDev,O as spatialDelta,F as stdDev,_ as varianceCoefficient};
15
+ */export{R as DEFAULT_ACTIVATION_ENERGY,E as PRODUCT_PROFILES,S as SeriesProcessor,_ as StatsAggregator,k as aggregateBySlot,P as aggregateWithStats,I as analyzeLongTermTrends,O as computeLimitExcursions,B as createAggr,H as currentTrend,z as detectGaps,C as downsample,Z as f0Sterilization,V as hotColdSpots,T as linearFit,F as mkt,Y as predictTimeToThreshold,G as rollingMkt,K as rollingStdDev,W as rollingTrend,A as sampleStdDev,U as spatialDelta,L as stdDev,q as varianceCoefficient};
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { e as LegendOrientation, f as Renderer, M as Marker, d as LegendItem, b as LayoutResult, R as RenderOutput, t as theme } from './layout-C_t250fG.js';
2
- import { U as LineVariant, g as AnySeries, aa as Threshold, P as Highlight, I as Gap, N as GapsConfig, d as Annotation, e as AnnotationBandConfig, o as DrawCommand, ad as TimeScale, V as LinearScale, a5 as SeriesStyle, G as FillSpec, af as TimeSeries, O as HatchVariant, ac as ThresholdLabelPosition, _ as PointStyleType, f as AnnotationBandItem, A as AggregatedPoint, a as AggregatedSeries, k as DataPoint } from './scale-DFyECKZq.js';
3
- export { b as AggregationConfig, c as AggregationMode, l as DataPointRef, E as EnumMap, F as FillBound, x as FillDirectionType, y as FillRegion, z as FillSide, H as FillStyle, J as GapConfig, K as GapLabel, L as GapRegion, M as GapStyle, R as LineDashStyle, T as LineStyle, X as MarkerStyle, a2 as SensorType, a3 as SeriesOverlay, a4 as SeriesOverlayKind, a6 as SeriesType, a7 as ShadowStyle, ab as ThresholdLabelConfig } from './scale-DFyECKZq.js';
1
+ import { L as LegendOrientation, R as Renderer, M as Marker, a as LegendItem, b as LayoutResult, c as RenderOutput, t as theme } from './layout-CXwTQBSN.js';
2
+ import { L as LineVariant, A as AnySeries, T as Threshold, H as Highlight, G as Gap, a as GapsConfig, b as Annotation, c as AnnotationBandConfig, D as DrawCommand, d as TimeScale, e as LinearScale, S as SeriesStyle, F as FillSpec, f as TimeSeries, g as HatchVariant, h as ThresholdLabelPosition, P as PointStyleType, i as AnnotationBandItem, j as AggregatedPoint, k as AggregatedSeries, l as DataPoint } from './scale-CWAa8-uO.js';
3
+ export { m as AggregationConfig, n as AggregationMode, o as DataPointRef, E as EnumMap, p as FillBound, q as FillDirectionType, r as FillRegion, s as FillSide, t as FillStyle, u as GapConfig, v as GapLabel, w as GapRegion, x as GapStyle, y as LineDashStyle, z as LineStyle, M as MarkerStyle, B as SensorType, C as SeriesOverlay, I as SeriesOverlayKind, J as SeriesType, K as ShadowStyle, N as ThresholdLabelConfig } from './scale-CWAa8-uO.js';
4
4
 
5
5
  /*!
6
6
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
@@ -188,9 +188,9 @@ declare class MLTimeGraph {
188
188
  private _annotationSeq;
189
189
  private readonly _axes?;
190
190
  private _series;
191
- private _annotationBandHeight;
191
+ private readonly_annotationBandHeight;
192
192
  private _timeScale?;
193
- private _valueScales;
193
+ private readonly _valueScales;
194
194
  /** @param options Chart configuration; every field is optional and has a sensible default. */
195
195
  constructor(options?: MLTimeGraphOptions);
196
196
  getWidth(): number;
@@ -372,7 +372,7 @@ declare function mount(target: HTMLElement | string, options?: MountOptions): ML
372
372
  * `addX` methods, then materialise via `getSvg()` / `mount()` / `build()`.
373
373
  */
374
374
  declare class GraphBuilder {
375
- private _opts;
375
+ private readonly _opts;
376
376
  private _series;
377
377
  private _thresholds;
378
378
  private _annotations;
@@ -479,7 +479,7 @@ declare class GraphBuilder {
479
479
  * TimeSeriesBuilder simplifies constructing raw TimeSeries datasets.
480
480
  */
481
481
  declare class TimeSeriesBuilder {
482
- private _series;
482
+ private readonly _series;
483
483
  constructor(name: string);
484
484
  /** Appends a value-point to the series. */
485
485
  addPoint(time: number, value: number | null): this;
@@ -527,7 +527,7 @@ declare class TimeSeriesBuilder {
527
527
  * ThresholdBuilder simplifies constructing value boundaries.
528
528
  */
529
529
  declare class ThresholdBuilder {
530
- private _threshold;
530
+ private readonly _threshold;
531
531
  constructor(name: string, value: number);
532
532
  /** Sets the threshold boundary color. */
533
533
  setColor(color: string): this;
@@ -555,7 +555,7 @@ declare class ThresholdBuilder {
555
555
  * MarkerBuilder simplifies constructing vertical pins/markers.
556
556
  */
557
557
  declare class MarkerBuilder {
558
- private _marker;
558
+ private readonly _marker;
559
559
  constructor(time: number);
560
560
  /** Sets the marker value (for point markers). */
561
561
  setValue(v: number): this;
@@ -583,7 +583,7 @@ declare class MarkerBuilder {
583
583
  * HighlightBuilder simplifies constructing highlighted time bands.
584
584
  */
585
585
  declare class HighlightBuilder {
586
- private _highlight;
586
+ private readonly _highlight;
587
587
  constructor(startTime: number, endTime: number);
588
588
  /** Sets the text label. */
589
589
  setLabel(lbl: string): this;
@@ -609,7 +609,7 @@ declare class HighlightBuilder {
609
609
  * AnnotationBuilder simplifies constructing free-form annotations.
610
610
  */
611
611
  declare class AnnotationBuilder {
612
- private _ann;
612
+ private readonly _ann;
613
613
  constructor(typ: "line" | "arrow" | "rect" | "point" | "label");
614
614
  /** Sets a unique identifier. */
615
615
  setID(id: string): this;
@@ -665,7 +665,7 @@ declare class AnnotationBuilder {
665
665
  * AnnotationBandBuilder simplifies constructing annotation bands below the chart.
666
666
  */
667
667
  declare class AnnotationBandBuilder {
668
- private _band;
668
+ private readonly _band;
669
669
  constructor(name: string);
670
670
  /** Sets the band height in pixels. */
671
671
  setHeight(h: number): this;
@@ -688,7 +688,7 @@ declare class AnnotationBandBuilder {
688
688
  * AnnotationBandItemBuilder simplifies constructing annotation band event ranges.
689
689
  */
690
690
  declare class AnnotationBandItemBuilder {
691
- private _item;
691
+ private readonly _item;
692
692
  constructor(startTime: number, endTime: number);
693
693
  /** Sets the fill color. */
694
694
  setFill(fill: string): this;
package/dist/index.js CHANGED
@@ -1,53 +1,49 @@
1
- var nt=class r{_config;constructor(t){this._config=t;}compute(){let{width:t,height:e,margin:n}=this._config;return {totalWidth:t,totalHeight:e,chartWidth:t-n.left-n.right,chartHeight:e-n.top-n.bottom,chartX:n.left,chartY:n.top,margin:n}}static default(t=800,e=400){return new r({width:t,height:e,margin:{top:20,right:20,bottom:40,left:60}})}};function it(r){return r&&r.toString().normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"unnamed"}var U=class{#t;#e;constructor(t){this.#t=[...t.domain],this.#e=[...t.range];}map(t){let e=Number(t),[n,s]=this.#t,[i,o]=this.#e;return s===n?i:i+(e-n)/(s-n)*(o-i)}invert(t){let[e,n]=this.#t,[s,i]=this.#e;return i===s?e:e+(t-s)/(i-s)*(n-e)}domain(){return [...this.#t]}range(){return [...this.#e]}},z=[{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}],J=class{#t;#e;constructor(t){this.#t=new U({domain:t.domain,range:t.range}),this.#e=t.locale||(typeof navigator<"u"?navigator.language:"en-US");}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 locale(){return this.#e}tickInterval(t,e=3,n=12){let[s,i]=this.#t.domain(),o=i-s;if(o<=0)return {interval:z[0].ms};let a=o/t,h=z[0].ms;for(let u of z)if(u.ms>=a){h=u.ms;break}let l=h,d=Math.round(o/l);for(;d>n&&l<z[z.length-1].ms;){let u=z.findIndex(m=>m.ms===l);l=z[Math.min(u+1,z.length-1)].ms,d=Math.round(o/l);}for(;d<e&&l>z[0].ms;){let u=z.findIndex(m=>m.ms===l);l=z[Math.max(u-1,0)].ms,d=Math.round(o/l);}return {interval:l}}ticks(t){let e=t?.minTicks??5,n=t?.maxTicks??12,{interval:s}=this.tickInterval((e+n)/2,e,n),[i,o]=this.#t.domain(),a=[],h=Math.ceil(i/s)*s;for(let l=h;l<=o;l+=s)a.push(l);return a}format(t,e){return new Intl.DateTimeFormat(this.#e,e).format(new Date(t))}};var c={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"]};function At(r,t="classic-diagonal",e="rgba(200, 220, 255, 0.3)",n="#4D88FF",s=2){if(t==="none")return `
2
- <pattern id="${r}" width="10" height="10" patternUnits="userSpaceOnUse">
1
+ var et=class i{_config;constructor(t){this._config=t;}compute(){let{width:t,height:e,margin:n}=this._config;return {totalWidth:t,totalHeight:e,chartWidth:t-n.left-n.right,chartHeight:e-n.top-n.bottom,chartX:n.left,chartY:n.top,margin:n}}static default(t=800,e=400){return new i({width:t,height:e,margin:{top:20,right:20,bottom:40,left:60}})}};function nt(i){return i&&i.toString().normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"unnamed"}var ue=(()=>{let i=new Array(256);for(let t=0;t<256;t++){let e=t;for(let n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;i[t]=e>>>0;}return i})();function ce(i){let t=new TextEncoder().encode(i),e=4294967295;for(let n of t)e=ue[(e^n)&255]^e>>>8;return (e^4294967295)>>>0}function it(i,t){return t||"s-"+ce(i??"").toString(16).padStart(8,"0")}var Wt=new Map;function pe(i,t){return `${i}|${JSON.stringify(t??{})}`}function Rt(i,t){let e=pe(i,t),n=Wt.get(e);return n||(n=new Intl.DateTimeFormat(i,t),Wt.set(e,n)),n}var X=class{#t;#e;constructor(t){this.#t=[...t.domain],this.#e=[...t.range];}map(t){let e=Number(t),[n,o]=this.#t,[r,s]=this.#e;return o===n?r:r+(e-n)/(o-n)*(s-r)}invert(t){let[e,n]=this.#t,[o,r]=this.#e;return r===o?e:e+(t-o)/(r-o)*(n-e)}domain(){return [...this.#t]}range(){return [...this.#e]}},z=[{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}],J=class{#t;#e;constructor(t){this.#t=new X({domain:t.domain,range:t.range}),this.#e=t.locale||(typeof navigator<"u"?navigator.language:"en-US");}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 locale(){return this.#e}tickInterval(t,e=3,n=12){let[o,r]=this.#t.domain(),s=r-o;if(s<=0)return {interval:z[0].ms};let a=s/t,h=z[0].ms;for(let u of z)if(u.ms>=a){h=u.ms;break}let l=h,d=Math.round(s/l);for(;d>n&&l<z[z.length-1].ms;){let u=z.findIndex(m=>m.ms===l);l=z[Math.min(u+1,z.length-1)].ms,d=Math.round(s/l);}for(;d<e&&l>z[0].ms;){let u=z.findIndex(m=>m.ms===l);l=z[Math.max(u-1,0)].ms,d=Math.round(s/l);}return {interval:l}}ticks(t){let e=t?.minTicks??5,n=t?.maxTicks??12,{interval:o}=this.tickInterval((e+n)/2,e,n),[r,s]=this.#t.domain(),a=[],h=Math.ceil(r/o)*o;for(let l=h;l<=s;l+=o)a.push(l);return a}format(t,e){return Rt(this.#e,e).format(new Date(t))}};var p={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"]};function At(i,t="classic-diagonal",e="rgba(200, 220, 255, 0.3)",n="#4D88FF",o=2){if(t==="none")return `
2
+ <pattern id="${i}" width="10" height="10" patternUnits="userSpaceOnUse">
3
3
  <rect width="10" height="10" fill="${e}" />
4
4
  </pattern>
5
- `.trim();let i=12,o=12,a="rotate(0)",h="";switch(t){case "classic-diagonal":i=12,o=12,a="rotate(45)",h=`<line x1="0" y1="0" x2="0" y2="${o}" stroke="${n}" stroke-width="${s}" stroke-linecap="square" />`;break;case "dense-steep":i=6,o=6,a="rotate(30)",h=`<line x1="0" y1="0" x2="0" y2="${o}" stroke="${n}" stroke-width="${s}" stroke-linecap="square" />`;break;case "crosshatch":i=14,o=14,a="rotate(45)",h=`
6
- <line x1="0" y1="0" x2="0" y2="${o}" stroke="${n}" stroke-width="${s}" stroke-linecap="square" />
7
- <line x1="0" y1="0" x2="${i}" y2="0" stroke="${n}" stroke-width="${s}" stroke-linecap="square" />
8
- `;break;case "dots":i=12,o=12,h=`<circle cx="${i/2}" cy="${o/2}" r="${s*1.2}" fill="${n}" />`;break;case "waves":i=16,o=16,h=`
9
- <path d="M 0 ${o/2} Q ${i/4} 0, ${i/2} ${o/2} T ${i} ${o/2}"
10
- fill="none" stroke="${n}" stroke-width="${s}" stroke-linecap="round" />
11
- `;break;case "dashed":i=12,o=12,a="rotate(45)",h=`<line x1="0" y1="0" x2="0" y2="${o}" stroke="${n}" stroke-width="${s}" stroke-dasharray="3,3" />`;break;case "herringbone":i=16,o=16,h=`
12
- <path d="M 0 0 L ${i/2} ${o/2} L 0 ${o} M ${i} 0 L ${i/2} ${o/2} L ${i} ${o}"
13
- fill="none" stroke="${n}" stroke-width="${s}" stroke-linejoin="round" stroke-linecap="round" />
14
- `;break;case "brick":i=20,o=20,h=`
15
- <path d="M 0 ${o/2} L ${i} ${o/2} M 0 ${o} L ${i} ${o} M ${i/2} 0 L ${i/2} ${o/2} M 0 ${o/2} L 0 ${o}"
16
- fill="none" stroke="${n}" stroke-width="${s}" />
17
- `;break;case "double-stripe":i=16,o=16,a="rotate(45)",h=`
18
- <line x1="0" y1="0" x2="0" y2="${o}" stroke="${n}" stroke-width="${s}" stroke-linecap="square" />
19
- <line x1="${i/2}" y1="0" x2="${i/2}" y2="${o}" stroke="${n}" stroke-width="${s/2}" stroke-linecap="square" />
20
- `;break;case "honeycomb":i=18,o=32,h=`
21
- <path d="M 0 0 L ${i/2} 5 L ${i} 0 M 0 16 L ${i/2} 11 L ${i} 16 M 0 16 L 0 32 M ${i/2} 5 L ${i/2} 11 M ${i} 16 L ${i} 32 M 0 32 L ${i/2} 27 L ${i} 32 M ${i/2} 27 L ${i/2} 32"
22
- fill="none" stroke="${n}" stroke-width="${s}" stroke-linejoin="round" stroke-linecap="round" />
23
- `;break}let l=`<rect width="${i}" height="${o}" fill="${e}" />`;return `
24
- <pattern id="${r}" width="${i}" height="${o}" patternTransform="${a}" patternUnits="userSpaceOnUse">
5
+ `.trim();let r=12,s=12,a="rotate(0)",h="";switch(t){case "classic-diagonal":r=12,s=12,a="rotate(45)",h=`<line x1="0" y1="0" x2="0" y2="${s}" stroke="${n}" stroke-width="${o}" stroke-linecap="square" />`;break;case "dense-steep":r=6,s=6,a="rotate(30)",h=`<line x1="0" y1="0" x2="0" y2="${s}" stroke="${n}" stroke-width="${o}" stroke-linecap="square" />`;break;case "crosshatch":r=14,s=14,a="rotate(45)",h=`
6
+ <line x1="0" y1="0" x2="0" y2="${s}" stroke="${n}" stroke-width="${o}" stroke-linecap="square" />
7
+ <line x1="0" y1="0" x2="${r}" y2="0" stroke="${n}" stroke-width="${o}" stroke-linecap="square" />
8
+ `;break;case "dots":r=12,s=12,h=`<circle cx="${r/2}" cy="${s/2}" r="${o*1.2}" fill="${n}" />`;break;case "waves":r=16,s=16,h=`
9
+ <path d="M 0 ${s/2} Q ${r/4} 0, ${r/2} ${s/2} T ${r} ${s/2}" fill="none" stroke="${n}" stroke-width="${o}" stroke-linecap="round" />
10
+ `;break;case "dashed":r=12,s=12,a="rotate(45)",h=`<line x1="0" y1="0" x2="0" y2="${s}" stroke="${n}" stroke-width="${o}" stroke-dasharray="3,3" />`;break;case "herringbone":r=16,s=16,h=`
11
+ <path d="M 0 0 L ${r/2} ${s/2} L 0 ${s} M ${r} 0 L ${r/2} ${s/2} L ${r} ${s}" fill="none" stroke="${n}" stroke-width="${o}" stroke-linejoin="round" stroke-linecap="round" />
12
+ `;break;case "brick":r=20,s=20,h=`
13
+ <path d="M 0 ${s/2} L ${r} ${s/2} M 0 ${s} L ${r} ${s} M ${r/2} 0 L ${r/2} ${s/2} M 0 ${s/2} L 0 ${s}" fill="none" stroke="${n}" stroke-width="${o}" />
14
+ `;break;case "double-stripe":r=16,s=16,a="rotate(45)",h=`
15
+ <line x1="0" y1="0" x2="0" y2="${s}" stroke="${n}" stroke-width="${o}" stroke-linecap="square" />
16
+ <line x1="${r/2}" y1="0" x2="${r/2}" y2="${s}" stroke="${n}" stroke-width="${o/2}" stroke-linecap="square" />
17
+ `;break;case "honeycomb":r=18,s=32,h=`
18
+ <path d="M 0 0 L ${r/2} 5 L ${r} 0 M 0 16 L ${r/2} 11 L ${r} 16 M 0 16 L 0 32 M ${r/2} 5 L ${r/2} 11 M ${r} 16 L ${r} 32 M 0 32 L ${r/2} 27 L ${r} 32 M ${r/2} 27 L ${r/2} 32" fill="none" stroke="${n}" stroke-width="${o}" stroke-linejoin="round" stroke-linecap="round" />
19
+ `;break}let l=`<rect width="${r}" height="${s}" fill="${e}" />`;return `
20
+ <pattern id="${i}" width="${r}" height="${s}" patternTransform="${a}" patternUnits="userSpaceOnUse">
25
21
  ${l}
26
22
  ${h}
27
23
  </pattern>
28
- `.trim()}function Wt(r,t=2){let e=t;switch(r){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 rt={axisColor:c.axisColor,tickColor:c.tickColor,textColor:c.textColor,textSize:c.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??rt).axisColor}get tickColor(){return (this.#e.colors??rt).tickColor}get textColor(){return (this.#e.colors??rt).textColor}get textSize(){return (this.#e.colors??rt).textSize}generateTicks(){let t=this.#e.minTicks??5,e=this.#e.maxTicks??12,s=this.#t.ticks({minTicks:t,maxTicks:e}).map(i=>({time:i,x:this.#t.map(i),label:this.tickLabel(i)}));return this.antiOverlap(s)}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:s}=this.#t.tickInterval((e+n)/2,e,n),i={};return s<6e4?(i.hour="2-digit",i.minute="2-digit",i.second="2-digit"):s<36e5||s<864e5?(i.hour="2-digit",i.minute="2-digit"):s<31536e6?(i.day="numeric",i.month="short",s>=2592e6&&(i.day=void 0,i.month="long")):(i.year="numeric",s<2*31536e6&&(i.month="short")),this.#t.format(t,i)}antiOverlap(t){if(t.length<=1)return t;let e=60,n=[t[0]];for(let s=1;s<t.length;s++){let i=n[n.length-1].x;Math.abs(t[s].x-i)>=e&&n.push(t[s]);}return n}render(){let t=this.generateTicks(),e=this.#e.colors??rt,n=this.#e.y??0,s=[],[i,o]=this.#t.range();s.push({type:"line",x1:i,y1:n,x2:o,y2:n,stroke:e.axisColor,strokeWidth:e.axisWidth});for(let a of t)s.push({type:"line",x1:a.x,y1:n,x2:a.x,y2:n+6,stroke:e.tickColor,strokeWidth:e.axisWidth}),s.push({type:"text",content:a.label,x:a.x,y:n+e.textSize+6,anchor:"middle",fontSize:e.textSize,fill:e.textColor});return s}};var st={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function ae(r){return Math.abs(r)>=1e6?`${(r/1e6).toFixed(1)}M`:Math.abs(r)>=1e3?`${(r/1e3).toFixed(1)}k`:Number.isInteger(r)?String(r):r.toFixed(1)}function le(r){let t=new Array(r.length).fill(false),e=0;for(;e<r.length;){let n=e;for(;n+1<r.length&&r[n+1].label===r[e].label;)n++;for(let s=e+1;s<n;s++)t[s]=true;e=n+1;}return t}var lt=class{#t;#e;constructor(t){this.#t=new U({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??ae,e=6,[n,s]=this.#t.domain(),i=s-n;if(i===0)return [{value:n,position:this.#t.map(n),label:t(n)}];let o=i/e,a=Math.pow(10,Math.floor(Math.log10(o))),h=o/a,l;h<=1.5?l=a:h<=3?l=2*a:h<=7?l=5*a:l=10*a;let d=[],u=Math.ceil(n/l)*l;for(let m=u;m<=s;m+=l)d.push({value:m,position:this.#t.map(m),label:t(m)});return d}render(){let t=this.generateTicks(),e=this.#e.colors??st,n=this.#e.x??0,s=this.#e.orientation??"vertical",i=this.#e.position??"left",o=this.#e.suppressLabelsNear??[],a=this.#e.suppressTolerancePx??8,h=d=>o.some(u=>Math.abs(u-d)<=a),l=[];if(s==="vertical"){let[d,u]=this.#t.range();l.push({type:"line",x1:n,y1:d,x2:n,y2:u,stroke:e.axisColor,strokeWidth:e.axisWidth});let m=le(t);t.forEach((f,p)=>{let y=h(f.position),b=m[p]?{opacity:0}:{};i==="left"?(l.push({type:"line",x1:n-4,y1:f.position,x2:n,y2:f.position,stroke:e.tickColor,strokeWidth:e.axisWidth}),y||l.push({type:"text",content:f.label,x:n-8,y:f.position+4,anchor:"end",fontSize:11,fill:e.textColor,...b})):(l.push({type:"line",x1:n,y1:f.position,x2:n+4,y2:f.position,stroke:e.tickColor,strokeWidth:e.axisWidth}),y||l.push({type:"text",content:f.label,x:n+8,y:f.position+4,anchor:"start",fontSize:11,fill:e.textColor,...b}));});}else {let[d,u]=this.#t.range();l.push({type:"line",x1:d,y1:n,x2:u,y2:n,stroke:e.axisColor,strokeWidth:e.axisWidth});for(let m of t)l.push({type:"line",x1:m.position,y1:n,x2:m.position,y2:n+6,stroke:e.tickColor,strokeWidth:e.axisWidth}),l.push({type:"text",content:m.label,x:m.position,y:n+18,anchor:"middle",fontSize:e.textSize,fill:e.textColor});}return l}};var j=class{static interpolateDataPoint(r,t,e){return {time:r.time+e*(t.time-r.time),value:(r.value??0)+e*((t.value??0)-(r.value??0))}}static interpolateAggregatedPoint(r,t,e){let n=(s,i)=>s!==null&&i!==null?s+e*(i-s):null;return {time:r.time+e*(t.time-r.time),min:n(r.min,t.min),max:n(r.max,t.max),avg:n(r.avg,t.avg),count:Math.round(r.count+e*(t.count-r.count))}}static getRuns(r,t,e=0){let n=[...r].sort((a,h)=>a.time-h.time),s=[],i=[],o=null;for(let a of n){let h=t(a),l=e>0&&o&&a.time-o.time>e;(h||l)&&i.length&&(s.push(i),i=[]),h||i.push(a),o=a;}return i.length&&s.push(i),s}static splitByBoundaries(r,t,e,n){if(r.length===0)return [];if(t.length===0)return [{data:r,zoneIndex:0}];let s=[...t].sort((h,l)=>h-l),i=[],o=h=>{let l=0;for(let d=0;d<s.length&&h>=s[d];d++)l=d+1;return l},a=[r[0]];for(let h=1;h<r.length;h++){let l=r[h-1],d=r[h],u=e(l),m=e(d),f;m>u?f=s.filter(p=>p>u&&p<=m):m<u?f=s.filter(p=>p>=m&&p<u).reverse():f=[];for(let p of f){let y=(p-u)/(m-u),b=n(l,d,y);a.push(b),i.push({data:a,zoneIndex:o((u+p)/2)}),a=[b];}a.push(d);}if(a.length>0){let h=e(a[0]),l=e(a[a.length-1]);i.push({data:a,zoneIndex:o((h+l)/2)});}return i}static splitByThreshold(r,t,e,n){let s=this.splitByBoundaries(r,[t],e,n),i={above:[],below:[]};for(let o of s)o.zoneIndex===0?i.below.push(o.data):i.above.push(o.data);return i}};function Rt(r,t=6e4){if(r.length<2)return [];let e=[...r].sort((s,i)=>s.time-i.time),n=[];for(let s=1;s<e.length;s++)e[s].time-e[s-1].time>t&&n.push({startTime:e[s-1].time,endTime:e[s].time});return n}function he(r,t=83144){let e=t/8.314,n=0,s=0;for(let o of r)o!==null&&(n+=Math.exp(-e/(o+273.15)),s++);if(s===0)return null;let i=n/s;return e/-Math.log(i)-273.15}function Ot(r,t,e=83144){let n=new Array(r.length),s=0;for(let i=0;i<r.length;i++){let o=r[i].time,a=o-t;for(;s<i&&r[s].time<a;)s++;let h=r.slice(s,i+1).map(d=>d.value),l=he(h,e);n[i]={time:o,value:l,synthetic:true};}return n}function de(r){let t=0,e=0;for(let i of r)i!==null&&(t+=i,e++);if(e===0)return null;let n=t/e,s=0;for(let i of r){if(i===null)continue;let o=i-n;s+=o*o;}return Math.sqrt(s/e)}function me(r){let t=0,e=0;for(let i of r)i!==null&&(t+=i,e++);if(e<2)return null;let n=t/e,s=0;for(let i of r){if(i===null)continue;let o=i-n;s+=o*o;}return Math.sqrt(s/(e-1))}function It(r,t,e=false){let n=new Array(r.length),s=0,i=e?me:de;for(let o=0;o<r.length;o++){let a=r[o].time,h=a-t;for(;s<o&&r[s].time<h;)s++;let l=r.slice(s,o+1).map(u=>u.value),d=i(l);n[o]={time:a,value:d,synthetic:true};}return n}function Gt(r){return {id:r.id,line:{stroke:r.stroke??c.stroke,strokeWidth:r.strokeWidth??c.strokeWidth,smoothing:r.smoothing??false,dashed:r.dashed??false},fill:r.fill??c.areaFillAlpha,markers:{type:r.pointStyle??"none",size:r.pointSize??c.pointSize,stroke:r.stroke??c.stroke,fill:"#ffffff"},shadow:{color:r.shadowColor??"transparent",blur:r.shadowBlur??0,offsetX:r.shadowOffsetX??0,offsetY:r.shadowOffsetY??0}}}function ht(r,t,e){let n=[],s=r.reduce((o,a)=>o+a.data.length,0),i=Gt(e);for(let o=0;o<r.length;o++){let a=r[o];a.data.length>=2?n.push({type:"path",id:e.id?`${e.id}-line-${o}`:void 0,points:a.data.map(h=>({x:t.timeScale.map(h.time),y:t.valueScale.map(h.value)})),stroke:a.color??i.line.stroke,strokeWidth:i.line.strokeWidth,smoothing:i.line.smoothing,dashed:i.line.dashed,shadowColor:i.shadow.color,shadowBlur:i.shadow.blur,shadowOffsetX:i.shadow.offsetX,shadowOffsetY:i.shadow.offsetY,fill:"none"}):a.data.length===1&&s===1&&n.push({type:"circle",cx:t.timeScale.map(a.data[0].time),cy:t.valueScale.map(a.data[0].value),r:Math.max(i.markers.size,i.line.strokeWidth),fill:a.color??i.line.stroke,shadowColor:i.shadow.color,shadowBlur:i.shadow.blur});}return n}function Mt(r,t,e,n){if(r.length<2)return [];let s=j.splitByBoundaries(r,e.boundaries,e.getValue,e.interpolate),i=[];for(let o=0;o<s.length;o++){let a=s[o];if(a.data.length<2)continue;let h=e.getColor(a.zoneIndex);if(!h)continue;let l=a.data.map(u=>({x:t.timeScale.map(u.time),y:t.valueScale.map(e.yLow(u))})),d=a.data.map(u=>({x:t.timeScale.map(u.time),y:t.valueScale.map(e.yHigh(u))})).reverse();i.push({type:"path",id:n?.id?`${n.id}-fill-${o}`:void 0,points:[...l,...d],fill:h,hatch:e.getHatch?.(a.zoneIndex),stroke:"none"});}return i}function Et(r,t,e,n){let s=Gt(e);if(!s.markers.type||s.markers.type==="none")return [];let i=[];for(let o=0;o<r.length;o++){let a=r[o],h=t.timeScale.map(a.time),l=t.valueScale.map(a.value),d=n(a),u=e.pointStroke??d,m=e.pointFill??d,f=e.pointStrokeWidth??1.5,p=e.id?`${e.id}-marker-${o}`:void 0;ue(i,p,s.markers.type,h,l,s.markers.size,u,m,f);}return i}function ue(r,t,e,n,s,i,o,a,h){switch(e){case "circle":r.push({type:"circle",cx:n,cy:s,r:i,fill:a,stroke:o,strokeWidth:h,id:t});break;case "square":r.push({type:"rect",x:n-i,y:s-i,w:i*2,h:i*2,fill:a,stroke:o,strokeWidth:h,id:t});break;case "cross":r.push({type:"line",x1:n-i,y1:s-i,x2:n+i,y2:s+i,stroke:o,strokeWidth:h,id:t}),r.push({type:"line",x1:n-i,y1:s+i,x2:n+i,y2:s-i,stroke:o,strokeWidth:h,id:t});break;case "diamond":r.push({type:"path",points:[{x:n,y:s-i},{x:n+i,y:s},{x:n,y:s+i},{x:n-i,y:s}],fill:a,stroke:o,strokeWidth:h,id:t});break;case "triangle":r.push({type:"path",points:[{x:n,y:s-i},{x:n+i,y:s+i},{x:n-i,y:s+i}],fill:a,stroke:o,strokeWidth:h,id:t});break;case "star":{let l=[];for(let d=0;d<10;d++){let u=d%2===0?i:i*.5,m=Math.PI/2*3+d*Math.PI/5;l.push({x:n+u*Math.cos(m),y:s+u*Math.sin(m)});}r.push({type:"path",points:l,fill:a,stroke:o,strokeWidth:h,id:t});break}case "arrow":r.push({type:"path",points:[{x:n-i,y:s+i},{x:n,y:s-i},{x:n+i,y:s+i}],stroke:o,strokeWidth:h,fill:"none",id:t});break;default:r.push({type:"circle",cx:n,cy:s,r:i,fill:a,stroke:o,strokeWidth:h,id:t});}}var et=class r{#t;#e;static uidcnt=0;#n;constructor(t,e=[]){this.#t=t.id??"id"+Date.now+ ++r.uidcnt,this.#e=t.timeScale,this.#n=e;}get id(){return this.#t}get timeScale(){return this.#e}get data(){return this.#n}};var dt=class extends et{#t;constructor(t){super(t,t.data),this.#t=t;}render(){let t=this.#t,e=t.minColor??c.minColor,n=t.maxColor??c.maxColor,s=t.avgColor??c.avgColor,i=t.avgDashed??true,o=t.smoothing??false,a=t.strokeWidth??c.strokeWidth,h=j.getRuns(this.data,u=>u.min===null||u.max===null||u.avg===null);if(h.length===0)return [];let l={timeScale:this.timeScale,valueScale:t.valueScale},d=[];for(let u of h)u.length<2||(t.fillToMax&&d.push(...Mt(u,l,{boundaries:[],yLow:m=>m.avg,yHigh:m=>m.max,getValue:m=>m.avg,interpolate:j.interpolateAggregatedPoint,getColor:()=>t.fillToMax,getHatch:()=>t.fillToMaxHatch},{id:this.id?`${this.id}-fillToMax`:void 0})),t.fillToMin&&d.push(...Mt(u,l,{boundaries:[],yLow:m=>m.avg,yHigh:m=>m.min,getValue:m=>m.avg,interpolate:j.interpolateAggregatedPoint,getColor:()=>t.fillToMin,getHatch:()=>t.fillToMinHatch},{id:this.id?`${this.id}-fillToMin`:void 0})),d.push(...ht([{data:u.map(m=>({time:m.time,value:m.max}))}],l,{stroke:n,strokeWidth:a,smoothing:o,id:this.id?`${this.id}-max`:void 0}),...ht([{data:u.map(m=>({time:m.time,value:m.min}))}],l,{stroke:e,strokeWidth:a,smoothing:o,id:this.id?`${this.id}-min`:void 0}),...ht([{data:u.map(m=>({time:m.time,value:m.avg}))}],l,{stroke:s,strokeWidth:a,smoothing:o,dashed:i,id:this.id?`${this.id}-avg`:void 0})));return d}};var mt=class extends et{#t;constructor(t){super(t,t.data),this.#t=t;}opacity(t){if(!(this.#t.countOpacity??false))return .6;let e=Math.max(...this.data.map(n=>n.count));return e===0?.2:.2+.8*t/e}render(){let t=this.#t,e=t.fill??c.bandFill,n=t.hatch,s=t.avgLine??false,i=t.avgLineColor??c.bandAvgLine,o=t.bandWidth??10,a=[];for(let h of this.data){if(h.min===null||h.max===null)continue;let l=this.timeScale.map(h.time),d=t.valueScale.map(h.max),u=t.valueScale.map(h.min),m=o,f=this.data.indexOf(h);if(a.push({type:"rect",x:l-m/2,y:d,w:m,h:u-d,fill:e,hatch:n,opacity:this.opacity(h.count),id:this.id?`${this.id}-slot-${f}`:void 0}),s&&h.avg!==null){let p=t.valueScale.map(h.avg);a.push({type:"line",x1:l-m/2,y1:p,x2:l+m/2,y2:p,stroke:i,strokeWidth:1,id:this.id?`${this.id}-avg-${f}`:void 0});}}return a}};function ce(r){return r==="dotted"?{dash:"dotted"}:r==="dashed"?{dash:"dashed"}:{}}function Vt(r){let{thresholds:t,valueScale:e,xRange:n}=r,[s,i]=n,[o,a]=e.range(),h=Math.min(o,a),l=Math.max(o,a),d=[],u=[];for(let m of t){let f=m.color??c.thresholdColor,p=e.map(m.value);m.fill==="above"?d.push({type:"rect",x:s,y:h,w:i-s,h:Math.max(0,p-h),fill:f,hatch:m.fillHatch,opacity:m.fillOpacity??.12,id:m.id?`${m.id}-fill`:void 0}):m.fill==="below"&&d.push({type:"rect",x:s,y:p,w:i-s,h:Math.max(0,l-p),fill:f,hatch:m.fillHatch,opacity:m.fillOpacity??.12,id:m.id?`${m.id}-fill`:void 0});let y=m.line??c.thresholdLine;if(y!=="none"){let b=ce(y),S={type:"line",x1:s,y1:p,x2:i,y2:p,stroke:f,strokeWidth:1,...b,id:m.id?`${m.id}-line`:void 0};m.shadowColor&&(S.shadowColor=m.shadowColor,S.shadowBlur=m.shadowBlur??4,S.shadowOffsetX=m.shadowOffsetX??0,S.shadowOffsetY=m.shadowOffsetY??2),d.push(S);}if(m.label!==false){let b=m.label&&typeof m.label=="object"?m.label:void 0,S=typeof m.label=="string"?m.label:b?.text??m.name,w=b?.position??"right";u.push({...pe(S,w,s,i,p,f,b),id:m.id?`${m.id}-label`:void 0});}}return {inside:d,labels:u}}function pe(r,t,e,n,s,i,o){let a=(e+n)/2,h={type:"text",content:r,fontSize:c.thresholdFontSize,fill:i},l=o?{...o.rotate!==void 0&&{rotate:o.rotate},...o.textBaseline!==void 0&&{textBaseline:o.textBaseline}}:{};switch(t){case "left":return {...h,...l,x:e+4,y:s-4,anchor:"start"};case "above":return {...h,...l,x:a,y:s-6,anchor:"middle"};case "below":return {...h,...l,x:a,y:s+14,anchor:"middle"};case "center":return {...h,...l,x:a,y:s-4,anchor:"middle"};case "outside-left":return {...h,...l,x:e-6,y:s+3,anchor:"end",textBaseline:l.textBaseline??"middle"};case "outside-right":return {...h,...l,x:n+6,y:s+3,anchor:"start",textBaseline:l.textBaseline??"middle"};default:return {...h,...l,x:n-4,y:s-4,anchor:"end"}}}function zt(r){let{gaps:t,timeScale:e,yRange:n,fill:s=c.gapFill,hatch:i,fillOpacity:o=c.gapFillOpacity,stroke:a=c.gapStroke,strokeWidth:h=c.gapStrokeWidth,dashed:l=true,fontSize:d=c.gapFontSize,fontFill:u=c.gapFontColor,labelBaseline:m="middle",labelRotate:f}=r,[p,y]=n,b=[];for(let S of t){let w=e.map(S.startTime),G=e.map(S.endTime),P=S.fill??s,R=S.hatch??i,H=S.fillOpacity??o,W=S.label??"",E=S.rotate??f,F=S.labelBaseline??m;if(S.style==="dashed_border"||!S.style?b.push({type:"rect",x:w,y:p,w:G-w,h:y-p,fill:P,hatch:R,opacity:H,stroke:a,strokeWidth:h,dashed:l}):S.style==="empty"&&b.push({type:"rect",x:w,y:p,w:G-w,h:y-p,fill:P,hatch:R,opacity:H}),W){let _=fe(p,y,F),v=F==="above"?"top":F==="below"?"bottom":"middle";b.push({type:"text",content:W,x:(w+G)/2,y:_,anchor:"middle",fontSize:d,fill:u,textBaseline:v,rotate:E});}}return b}function fe(r,t,e){switch(e){case "above":return r-12;case "below":return t+4;default:return (r+t)/2}}var ut=class{#t;constructor(t,e,n,s){this.#t={...t,xRange:e,y:n,height:s};}render(){let{items:t,timeScale:e,background:n,hatch:s,showAxis:i,xRange:o,y:a,height:h}=this.#t,l=[];n&&l.push({type:"rect",x:o[0],y:a,w:o[1]-o[0],h,fill:n,opacity:.04,stroke:"#ddd",strokeWidth:.25});for(let d of t){let u=e.map(d.startTime),m=e.map(d.endTime);if(!(m-u<1)&&(l.push({type:"rect",x:u,y:a,w:m-u,h,hatch:d.hatch??s,fill:d.fill??"#6b728044",stroke:d.stroke,strokeWidth:d.strokeWidth??0}),d.label)){let f=d.labelFontSize??10;l.push({type:"text",content:d.label,x:(u+m)/2,y:this.#e(d.labelBaseline,f),anchor:"middle",fontSize:f,fill:d.labelFill??"#333"});}}if(i){let d=new tt({domain:e.domain(),xRange:o,y:a+h+4});l.push({type:"group",cssClass:"annotation-band-axis",commands:d.render()});}return l}#e(t,e){let{y:n,height:s}=this.#t;switch(t){case "top":return n+e*.9;case "bottom":return n+s-e*.25;default:return n+s/2+e*.35}}};function Nt(r){let{highlights:t,timeScale:e,yRange:n,height:s}=r,[i,o]=n,a=[];for(let h of t){let l=e.map(h.startTime),d=e.map(h.endTime);a.push({type:"rect",x:l,y:i,w:d-l,h:o-i,fill:h.color??c.highlightColor,opacity:h.opacity??c.highlightOpacity}),h.label&&a.push({type:"text",content:h.label,x:(l+d)/2,y:ge(h.labelPosition??"top",i,o,s),anchor:"middle",fontSize:c.annotationFontSize,fill:h.color??c.highlightLabelColor,rotate:h.rotate});}return a}function ge(r,t,e,n){switch(r){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 Yt(r){let{markers:t,timeScale:e,valueScale:n,yRange:s=[0,300]}=r,[i,o]=s,a=[];for(let h of t){let l=e.map(h.time),d=h.color??c.markerColor,u=h.pointStyle??(h.value!==void 0?"circle":"none"),m=h.lineStyle??"full";if(h.value!==void 0){let f=n.map(h.value);if(m==="to-value"?a.push({type:"line",x1:l,y1:o,x2:l,y2:f,stroke:d,strokeWidth:1,dashed:true}):m==="to-top"?a.push({type:"line",x1:l,y1:i,x2:l,y2:f,stroke:d,strokeWidth:1,dashed:true}):m==="full"&&a.push({type:"line",x1:l,y1:i,x2:l,y2:o,stroke:d,strokeWidth:1}),u!=="none"&&ye(a,l,f,d,u),h.label){let p=m==="to-value"?f-10:i-6;a.push({type:"text",content:h.label,x:l,y:p,anchor:"middle",fontSize:11,fill:d});}}else a.push({type:"line",x1:l,y1:i,x2:l,y2:o,stroke:d,strokeWidth:1}),h.label&&a.push({type:"text",content:h.label,x:l,y:i-6,anchor:"middle",fontSize:11,fill:d});}return a}function ye(r,t,e,n,s){let i=c.markerSize;switch(s){case "circle":r.push({type:"circle",cx:t,cy:e,r:i,fill:n});break;case "square":r.push({type:"rect",x:t-i,y:e-i,w:i*2,h:i*2,fill:n});break;case "cross":r.push({type:"line",x1:t-i,y1:e-i,x2:t+i,y2:e+i,stroke:n,strokeWidth:2}),r.push({type:"line",x1:t-i,y1:e+i,x2:t+i,y2:e-i,stroke:n,strokeWidth:2});break;case "arrow":r.push({type:"path",points:[{x:t-i,y:e+i},{x:t,y:e-i},{x:t+i,y:e+i}],stroke:n,strokeWidth:2,fill:"none"});break;case "diamond":r.push({type:"path",points:[{x:t,y:e-i},{x:t+i,y:e},{x:t,y:e+i},{x:t-i,y:e}],fill:n,stroke:"none"});break;case "triangle":r.push({type:"path",points:[{x:t,y:e-i},{x:t+i,y:e+i},{x:t-i,y:e+i}],fill:n,stroke:"none"});break;case "star":{let o=[],a=i*.4;for(let h=0;h<10;h++){let l=h%2===0?i:a,d=Math.PI/2*3+h*Math.PI/5;o.push({x:t+l*Math.cos(d),y:e+l*Math.sin(d)});}r.push({type:"path",points:o,fill:n,stroke:"none"});break}case "plus":r.push({type:"line",x1:t-i,y1:e,x2:t+i,y2:e,stroke:n,strokeWidth:2}),r.push({type:"line",x1:t,y1:e-i,x2:t,y2:e+i,stroke:n,strokeWidth:2});break;case "triangle-down":r.push({type:"path",points:[{x:t,y:e+i},{x:t+i,y:e-i},{x:t-i,y:e-i}],fill:n,stroke:"none"});break;case "hexagon":{let o=[];for(let a=0;a<6;a++){let h=a*(Math.PI/3);o.push({x:t+i*Math.cos(h),y:e+i*Math.sin(h)});}r.push({type:"path",points:o,fill:n,stroke:"none"});break}case "hourglass":r.push({type:"path",points:[{x:t-i,y:e-i},{x:t+i,y:e-i},{x:t-i,y:e+i},{x:t+i,y:e+i}],fill:n,stroke:"none"});break;case "line-horizontal":r.push({type:"line",x1:t-i,y1:e,x2:t+i,y2:e,stroke:n,strokeWidth:2});break}}function Xt(r){let{annotations:t,timeScale:e,valueScales:n}=r,s=[],i=o=>{let a=n.get(o.axis??0)??n.values().next().value;return {x:e.map(o.time),y:a?a.map(o.value):0}};for(let o of t){let a=[],h=l=>a.push(l);switch(o.type){case "line":{let l=i(o.from),d=i(o.to);h({type:"line",x1:l.x,y1:l.y,x2:d.x,y2:d.y,stroke:o.color??c.annotationColor,strokeWidth:o.width??c.annotationWidth,dash:o.dash});break}case "arrow":{let l=i(o.from),d=i(o.to),u=o.color??c.annotationColor,m=o.headSize??c.annotationHead;h({type:"line",x1:l.x,y1:l.y,x2:d.x,y2:d.y,stroke:u,strokeWidth:o.width??c.annotationWidth});let f=Math.hypot(d.x-l.x,d.y-l.y)||1,p=(d.x-l.x)/f,y=(d.y-l.y)/f,b=d.x-p*m,S=d.y-y*m;h({type:"path",points:[{x:d.x,y:d.y},{x:b-y*m*.5,y:S+p*m*.5},{x:b+y*m*.5,y:S-p*m*.5}],fill:u,stroke:"none"});break}case "rect":{let l=i(o.from),d=i(o.to);h({type:"rect",x:Math.min(l.x,d.x),y:Math.min(l.y,d.y),w:Math.abs(d.x-l.x),h:Math.abs(d.y-l.y),fill:o.fill??"none",stroke:o.stroke,opacity:o.opacity});break}case "point":{let l=i(o.at),d=o.color??"#334155",u=o.radius??c.annotationRadius,m=o.shape??"circle";m==="circle"?h({type:"circle",cx:l.x,cy:l.y,r:u,fill:d}):m==="square"?h({type:"rect",x:l.x-u,y:l.y-u,w:u*2,h:u*2,fill:d}):(h({type:"line",x1:l.x-u,y1:l.y-u,x2:l.x+u,y2:l.y+u,stroke:d,strokeWidth:1.5}),h({type:"line",x1:l.x-u,y1:l.y+u,x2:l.x+u,y2:l.y-u,stroke:d,strokeWidth:1.5}));break}case "label":{let l=i(o.at);h({type:"text",content:o.text,x:l.x+(o.dx??0),y:l.y+(o.dy??0),anchor:o.anchor??"middle",fontSize:c.annotationFontSize,fill:o.color??c.annotationColor,rotate:o.rotate});break}}if(o.id&&a.length>0){let l=it(o.id);s.push({type:"group",cssClass:`annotation annotation--${l}`,commands:a});}else s.push(...a);}return s}var K=12,ct=8,Lt=20,be=11,Dt=18,Pt=r=>r.length*be*.6;function qt(r,t="vertical"){if(t==="horizontal"){let n=0;for(let s of r)n+=K+ct+Pt(s.name)+Dt;return {width:Math.max(0,n-Dt),height:Lt}}let e=0;for(let n of r)e=Math.max(e,Pt(n.name));return {width:K+ct+e,height:r.length*Lt}}function Ut(r){let{items:t,x:e,y:n,orientation:s="vertical"}=r,i=[],o=e;return t.forEach((a,h)=>{let l=s==="horizontal"?o:e,d=s==="horizontal"?n:n+h*Lt;i.push({type:"rect",x:l,y:d,w:K,h:K,fill:a.color,stroke:c.legendStroke,strokeWidth:1}),i.push({type:"text",content:a.name,x:l+K+ct,y:d+K-2,fontSize:c.legendFont,fill:c.legendText}),s==="horizontal"&&(o+=K+ct+Pt(a.name)+Dt);}),{type:"group",cssClass:"chart-legend",commands:i}}function Kt(r){let{xTicks:t,yTicks:e,xRange:n,yRange:s,stroke:i=c.gridStroke,strokeWidth:o=c.gridStrokeWidth,dashed:a=false,opacity:h=c.gridOpacity}=r,l=[];if(e)for(let d of e)l.push({type:"line",x1:n[0],y1:d,x2:n[1],y2:d,stroke:i,strokeWidth:o,dashed:a,opacity:h});if(t)for(let d of t)l.push({type:"line",x1:d,y1:s[0],x2:d,y2:s[1],stroke:i,strokeWidth:o,dashed:a,opacity:h});return l}function Zt(r,t,e){let n=r??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 s=e.thresholds.get(n.threshold);if(!s)throw new Error(`fillSpec region references unknown threshold '${n.threshold}'`);return e.valueScale.map(s.value)}return typeof n=="object"&&"value"in n?e.valueScale.map(n.value):null}function xe(r){return typeof r=="string"?{color:r}:{color:r.color,hatch:r.hatch}}function Qt(r,t,e){let n=Zt(r.from,"chartBottom",t),s=Zt(r.to,"series",t),{color:i,hatch:o}=xe(r.fill),a={type:"path",fill:i,hatch:o,stroke:"none",...t.idPrefix&&{id:`${t.idPrefix}-fill-r${e}`}};if(n!==null&&s!==null){let m=t.timeScale.range(),f=m[0],p=m[1],y=Math.min(n,s),b=Math.max(n,s);return [{...a,points:[{x:f,y},{x:p,y},{x:p,y:b},{x:f,y:b}]}]}let h=n??s,l=[],d=Se(r,t);if(d===null){let m=t.valueScale.domain();d=(n??s)===t.chartBottom?m[0]:m[1];}let u=Jt(r.outer,t);for(let m of t.runs){if(m.length<2)continue;let f=j.splitByThreshold(m,d,y=>y.value??d,j.interpolateDataPoint),p=r.side==="above"?f.above:r.side==="below"?f.below:[...f.above,...f.below];if(u!==null&&r.side){let y=r.side==="above"?"below":"above";p=p.flatMap(b=>{if(b.length<2)return [];let S=j.splitByThreshold(b,u,w=>w.value??u,j.interpolateDataPoint);return y==="above"?S.above:S.below});}for(let y of p){if(y.length<2)continue;let b=y.map(w=>({x:t.timeScale.map(w.time),y:t.valueScale.map(w.value)})),S=[...b].reverse().map(w=>({x:w.x,y:h}));l.push({...a,smoothing:t.smoothing,smoothCount:b.length,points:[...b,...S]});}}return l}function Se(r,t){let e=r.from==="series"?r.to:r.from;return Jt(e,t)}function Jt(r,t){return r===void 0||r==="series"||r==="chartTop"||r==="chartBottom"?null:typeof r=="object"&&"threshold"in r?t.thresholds.get(r.threshold)?.value??null:typeof r=="object"&&"value"in r?r.value:null}function te(r,t){if(typeof r=="string"||!("regions"in r))return Qt({fill:r},t,0);let e=[];return r.regions.forEach((n,s)=>{e.push(...Qt(n,t,s));}),e}function ee(r,t){let e=new Array(r.length),n=0;for(let s=0;s<r.length;s++){let i=r[s].time,o=i-t;for(;n<s&&r[n].time<o;)n++;let a=0,h=0;for(let l=n;l<=s;l++){let d=r[l].value;d!==null&&(a+=d,h++);}e[s]={time:i,value:h===0?null:a/h,synthetic:true};}return e}function ie(r){let t=r.style?.line,e=t&&!Array.isArray(t)?t:void 0;return {color:e?.color??c.stroke,width:e?.width??c.strokeWidth,dash:e?.style,smoothing:e?.smoothing??false}}function ne(r,t,e,n){let s=r.filter(h=>h.value!==null);if(s.length<2)return [];let i=s.map(h=>({x:t.timeScale.map(h.time),y:t.valueScale.map(h.value)})),o=ie(e);return [{type:"path",id:t.idPrefix?`${t.idPrefix}-overlay-${n}`:`overlay-${n}`,points:i,stroke:o.color,strokeWidth:o.width,smoothing:o.smoothing,dash:o.dash,fill:"none"}]}function re(r,t){switch(r.kind){case "movingAverage":{r.type;let e=ee(t.data,r.window);return ne(e,t,r,"movingAvg")}case "movingMkt":{let e=Ot(t.data,r.window,r.activationEnergy);return ne(e,t,r,"movingMkt")}case "limits":{let e=[],n=t.timeScale.range(),s=n[0],i=n[1],o=ie(r),a=o.color,h=o.width,l=o.dash??"dashed",d=t.idPrefix?`${t.idPrefix}-`:"";return r.high!==void 0&&e.push({type:"line",id:`${d}overlay-limit-high`,x1:s,y1:t.valueScale.map(r.high),x2:i,y2:t.valueScale.map(r.high),stroke:a,strokeWidth:h,dash:l}),r.low!==void 0&&e.push({type:"line",id:`${d}overlay-limit-low`,x1:s,y1:t.valueScale.map(r.low),x2:i,y2:t.valueScale.map(r.low),stroke:a,strokeWidth:h,dash:l}),e}case "stdDevBand":{let e=r.multiplier??1,n=ee(t.data,r.window),s=It(t.data,r.window),i=[],o=[];for(let y=0;y<n.length;y++){let b=n[y].value,S=s[y].value;if(b===null||S===null)continue;let w=t.timeScale.map(n[y].time);i.push({x:w,y:t.valueScale.map(b+e*S)}),o.push({x:w,y:t.valueScale.map(b-e*S)});}if(i.length<2)return [];let a=t.idPrefix?`${t.idPrefix}-`:"",h=[],d=(typeof r.style?.fill=="string"||r.style?.fill&&!("regions"in r.style.fill)?r.style.fill:void 0)??"#94a3b833",{color:u,hatch:m}=_e(d);h.push({type:"path",id:`${a}overlay-stdDevBand`,points:[...i,...[...o].reverse()],fill:u,hatch:m,stroke:"none"});let f=r.style?.line,p=f&&!Array.isArray(f)?f:void 0;if(p){let y=n.filter(b=>b.value!==null).map(b=>({x:t.timeScale.map(b.time),y:t.valueScale.map(b.value)}));y.length>=2&&h.push({type:"path",id:`${a}overlay-stdDevBand-mean`,points:y,stroke:p.color??c.stroke,strokeWidth:p.width??1.5,smoothing:p.smoothing,dash:p.style,fill:"none"});}return h}}}function _e(r){return typeof r=="string"?{color:r}:{color:r.color,hatch:r.hatch}}function ke(r){if(!r)return {gaps:[],autoDetect:false,minGapMs:6e4};if(Array.isArray(r))return {gaps:r,autoDetect:false,minGapMs:6e4};let t=r.regions??[],e=r.style;return {gaps:t.map(s=>{let i={...e,...s.style},o=i.fill,a,h;return typeof o=="string"?a=o:o&&(a=o.color,h=o.hatch),{startTime:s.startTime,endTime:s.endTime,label:s.label,fill:a,hatch:h,fillOpacity:i.opacity,labelBaseline:i.label?.baseline,rotate:i.label?.rotate,style:i.display==="filled"||i.display==="bridge_line"?void 0:i.display}}),autoDetect:r.autoDetect??false,minGapMs:r.minGapMs??6e4}}function pt(r){return "showAs"in r&&!!r.showAs}var Z=class{_layout;_renderer;_locale;_legend;_markers;_thresholds;_highlights;_gaps;_gapsAutoDetect;_gapsMinGapMs;_annotations;_annotationBands;_disabledAnnotations=new Set;_annotationSeq=0;_axes;_series;_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._markers=t.markers??[],this._thresholds=t.thresholds??[],this._highlights=t.highlights??[];let e=ke(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,s=e.spacing??0;(e.showAxis??false)&&(t+=26+s),t+=n+s;}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(pt(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",s=this._legend?.orientation??"vertical",i=e?qt(t,s):{width:0},o=this._layout;if(e&&(n==="outside-right"||n==="outside-left")){let g=i.width+16,x={...this._layout.margin};n==="outside-right"?x.right+=g:x.left+=g,o=new nt({width:this._layout.totalWidth,height:this._layout.totalHeight,margin:x}).compute();}let{chartX:a,chartY:h,chartWidth:l,chartHeight:d}=o,u=[a,a+l],m=[h,h+d],f=[];for(let g of this._series)g.data.sort((x,k)=>x.time-k.time);let p=new Map,y=1/0,b=-1/0,S=false;for(let g of this._series){let x=this._axisIndexOf(g),k=p.get(x);k?k.push(g):p.set(x,[g]);for(let A of this._timesOf(g))A<y&&(y=A),A>b&&(b=A),S=true;}if(!S)return [];let w=this._axes?.x?.domain,G=w&&w!=="auto"?w:[y,b];this._timeScale=new J({domain:G,range:u,locale:this._locale});let P=g=>({axisColor:g?.color??c.axisColor,tickColor:g?.color??c.tickColor,textColor:c.textColor,textSize:c.textSize,axisWidth:g?.width}),R=new tt({domain:G,xRange:u,y:h+d,locale:this._locale,format:this._axes?.x?.format,maxTicks:this._axes?.x?.ticks?.major,colors:P(this._axes?.x?.axis)});this._valueScales.clear();let H=Array.from(p.keys()).sort((g,x)=>g-x),W,E=0,F=0;for(let g of H){let x=p.get(g),k=1/0,A=-1/0,L=false;for(let I of x)for(let at of this._valuesOf(I))at<k&&(k=at),at>A&&(A=at),L=true;if(!L)continue;let D;this._axes?.y&&this._axes.y.length>g?D=this._axes.y[g]:g===0?D=this._axes?.left:g===1&&(D=this._axes?.right);let Ct=D?.domain,Q=Ct&&Ct!=="auto"?Ct:[k,A],Ft=new U({domain:Q,range:[h+d,h]});this._valueScales.set(g,Ft);let jt=this._thresholds.filter(I=>(I.axisIndex??0)===g&&I.label!==false&&I.value>=Math.min(Q[0],Q[1])&&I.value<=Math.max(Q[0],Q[1])).map(I=>Ft.map(I.value)),Tt=D?.position??(g===0?"left":"right"),$t;if(Tt==="right"){let I=D?.offset!==void 0?D.offset:F*50;$t=a+l+I,F++;}else {let I=D?.offset!==void 0?D.offset:E*50;$t=a-I,E++;}let Ht=new lt({domain:Q,range:[h+d,h],x:$t,position:Tt,format:D?.format,ticks:D?.ticks?.major,colors:P(D?.axis),suppressLabelsNear:jt.length?jt:void 0});g===0&&(W=Ht),f.push({type:"group",cssClass:`value-axis ${Tt}`,commands:Ht.render()});}let _=this._valueScales.get(0)??this._valueScales.get(H[0]);f.push({type:"group",cssClass:"time-axis",commands:R.render()});let v=null,C=this._axes?.x?.grid?.major,M=this._axes?.left?.grid?.major;if(C!==void 0||M!==void 0){let g=C!==false,x=M!==false&&!!W,k=g?R.generateTicks().map(L=>L.x):void 0,A=x?W.generateTicks().map(L=>L.position):void 0;if(k||A){let L=(C&&typeof C=="object"?C:void 0)??(M&&typeof M=="object"?M:void 0);v={type:"group",cssClass:"chart-grid",commands:Kt({xTicks:k,yTicks:A,xRange:u,yRange:m,stroke:L?.color,opacity:L?.opacity,dashed:L?.style==="dashed"})};}}if(this._highlights.length>0&&f.push({type:"group",cssClass:"highlights",commands:Nt({highlights:this._highlights,timeScale:this._timeScale,yRange:m,height:o.totalHeight})}),this._thresholds.length>0&&_){let g=[],x=[];for(let k of this._thresholds){let A=k.id??it(k.name),L=this._valueScales.get(k.axisIndex??0)??_,D=Vt({thresholds:[k],valueScale:L,xRange:u});D.inside.length&&g.push({type:"group",cssClass:`threshold threshold--${A}`,id:`threshold-${A}`,commands:D.inside}),D.labels.length&&x.push({type:"group",cssClass:`threshold-label threshold-label--${A}`,commands:D.labels});}g.length&&f.push({type:"group",cssClass:"thresholds",commands:g,clipRect:{x:a,y:h,w:l,h:d}}),x.length&&f.push({type:"group",cssClass:"threshold-labels",commands:x});}let T=this._gaps;if(this._gapsAutoDetect){let g=[];for(let x of this._series)pt(x)||g.push(...Rt(x.data,this._gapsMinGapMs));g.length>0&&(T=[...this._gaps,...g]);}T.length>0&&f.push({type:"group",cssClass:"gaps",commands:zt({gaps:T,timeScale:this._timeScale,yRange:m})});let $=new Map(this._thresholds.map(g=>[g.name,g]));for(let g of this._series){if(g.data.length===0)continue;let x=this._valueScales.get(this._axisIndexOf(g));if(!x)continue;let k=g.id??it(g.name);f.push({type:"group",cssClass:`series series--${k}`,id:`series-${k}`,commands:this._renderSeries(g,x,$)});}v&&f.push(v);let O=this._markers.map(g=>({...g}));for(let g of O)if(g.value===void 0&&(g.lineStyle==="to-value"||g.lineStyle==="to-top")){let x=this._series[g.seriesIndex??0];x&&!pt(x)&&x.data.length>=2&&(g.value=this._interpolateValue(g.time,x.data));}O.length>0&&_&&f.push({type:"group",cssClass:"markers",commands:Yt({markers:O,timeScale:this._timeScale,valueScale:_,yRange:m})});let N=this._annotations.filter(g=>!g.id||!this._disabledAnnotations.has(g.id));if(N.length>0&&f.push({type:"group",cssClass:"annotations",commands:Xt({annotations:N,timeScale:this._timeScale,valueScales:this._valueScales})}),this._annotationBands.length>0){let g=h+d+this._layout.margin.bottom,x=0;this._annotationBands.forEach(k=>{let A=k.height??12,L=k.spacing??0,D=g+x;(k.showAxis??false)&&(x+=26+L),x+=A+L,f.push({type:"group",cssClass:"annotation-band",commands:new ut({name:k.name,showAxis:k.showAxis??false,items:k.items,timeScale:this._timeScale,background:k.background,hatch:k.hatch},[a,a+l],D,A).render()});});}if(e&&n!=="separate"){let g,x;n==="inside-right"?(g=a+l-i.width-8,x=h+8):n==="inside-left"?(g=a+8,x=h+8):n==="outside-right"?(g=a+l+16,x=h):(g=8,x=h),f.push(Ut({items:t,x:g,y:x,orientation:s}));}let B=this._axes?.left?.label,V=this._axes?.right?.label,q=this._axes?.x?.label;if(B||V||q){let g=[],x=h+d/2,k=this._axes?.left?.labels,A=this._axes?.right?.labels,L=this._axes?.x?.labels;B&&g.push({type:"text",content:B,x:14,y:x,anchor:"middle",fontSize:k?.fontSize??c.axisLabelSize,fill:k?.color??c.axisLabelColor,rotate:-90}),V&&g.push({type:"text",content:V,x:o.totalWidth-14,y:x,anchor:"middle",fontSize:A?.fontSize??c.axisLabelSize,fill:A?.color??c.axisLabelColor,rotate:90}),q&&g.push({type:"text",content:q,x:a+l/2,y:o.totalHeight-6,anchor:"middle",fontSize:L?.fontSize??c.axisLabelSize,fill:L?.color??c.axisLabelColor}),g.length&&f.push({type:"group",cssClass:"axis-labels",commands:g});}return f}_renderSeries(t,e,n){let s=this._timeScale,i={timeScale:s,valueScale:e};if(pt(t)){let _=t.style?.line&&!Array.isArray(t.style.line)?t.style.line:void 0,v=typeof t.style?.fill=="string"?t.style.fill:void 0;return t.showAs==="minmaxavg"?new dt({data:t.data,timeScale:s,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:_?.smoothing,strokeWidth:_?.width,id:t.id}).render():new mt({data:t.data,timeScale:s,valueScale:e,fill:v??_?.color,avgLine:t.avgLine,countOpacity:t.countOpacity,id:t.id}).render()}let o=t,a=t.style?.line&&!Array.isArray(t.style.line)?t.style.line:void 0,h=a?.gapThreshold??c.gapThreshold,l=j.getRuns(t.data,_=>_.value===null,h),d=l.reduce((_,v)=>_+v.length,0);if(d===0)return [];let u=[],m=t.style?.markers,f=t.style?.shadow,p={stroke:a?.color??c.stroke,strokeWidth:a?.width??c.strokeWidth,smoothing:a?.smoothing,dashed:a?.style==="dashed",pointStyle:m?.type,pointSize:m?.size,pointStroke:m?.stroke,pointFill:m?.fill,pointStrokeWidth:m?.strokeWidth,shadowColor:f?.color,shadowBlur:f?.blur,shadowOffsetX:f?.offsetX,shadowOffsetY:f?.offsetY,id:t.id},y=t.style?.line,b=y&&!Array.isArray(y)?y:void 0,S=b?.color,w=b?.width,G=b?.style,P=b?.smoothing,R=t.style?.fill;if(R!==void 0){let _=e.range(),v=Math.min(_[0],_[1]),C=Math.max(_[0],_[1]);u.push(...te(R,{runs:l,timeScale:s,valueScale:e,thresholds:n,chartTop:v,chartBottom:C,smoothing:a?.smoothing,idPrefix:t.id}));}let H=o.colorByThresholds??[],W=H.map(_=>n.get(_)).filter(_=>!!_).map(_=>_.value).sort((_,v)=>_-v),E=(_,v)=>{let C=p.stroke;for(let M of v){let T=n.get(M);T&&_>=T.value&&(C=T.color??C);}return C};for(let _ of l){if(_.length<2)continue;let v=j.splitByBoundaries(_,W,C=>C.value,j.interpolateDataPoint);for(let C=0;C<v.length;C++){let M=v[C];if(M.data.length<2)continue;let T=(M.data[0].value+M.data[M.data.length-1].value)/2,$=o.id,O=M.data.map(B=>({x:s.map(B.time),y:e.map(B.value)})),N=$?`${$}-line-${C}`:void 0;y===false||(y&&Array.isArray(y)?y.forEach((B,V)=>{u.push({type:"path",id:N?`${N}-${V}`:void 0,points:O,stroke:B.color??E(T,H),strokeWidth:B.width??p.strokeWidth,smoothing:B.smoothing??p.smoothing,dash:B.style,opacity:B.opacity,fill:"none",shadowColor:p.shadowColor,shadowBlur:p.shadowBlur,shadowOffsetX:p.shadowOffsetX,shadowOffsetY:p.shadowOffsetY});}):u.push({type:"path",id:N,points:O,stroke:S??E(T,H),strokeWidth:w??p.strokeWidth,smoothing:P??p.smoothing,dash:G,fill:"none",shadowColor:p.shadowColor,shadowBlur:p.shadowBlur,shadowOffsetX:p.shadowOffsetX,shadowOffsetY:p.shadowOffsetY}));}p.pointStyle&&p.pointStyle!=="none"&&d<=(m?.threshold??c.pointThreshold)&&u.push(...Et(_,i,p,C=>E(C.value,H)));}let F=t.overlays;if(F&&F.length>0){let _=e.range(),v={data:t.data,timeScale:s,valueScale:e,chartTop:Math.min(_[0],_[1]),chartBottom:Math.max(_[0],_[1]),idPrefix:t.id};for(let C of F)u.push(...re(C,v));}if(t.style?.gap&&l.length>1){let _=e.range(),v=Math.min(_[0],_[1]),C=Math.max(_[0],_[1]),M=t.style.gap,T=M.fill,$,O;typeof T=="string"?$=T:T&&($=T.color,O=T.hatch);let N=M.opacity??.15,B=M.bridge;for(let V=1;V<l.length;V++){let q=l[V-1][l[V-1].length-1],g=l[V][0],x=s.map(q.time),k=s.map(g.time);if(M.display==="bridge_line"){if(q.value===null||g.value===null)continue;let A=e.map(q.value),L=e.map(g.value);u.push({type:"line",x1:x,y1:A,x2:k,y2:L,stroke:B?.color??(typeof t.style?.line=="object"&&!Array.isArray(t.style.line)?t.style.line.color:void 0)??c.stroke,strokeWidth:B?.width??1.5,dash:B?.style??"dotted"});}else $!==void 0?u.push({type:"rect",x,y:v,w:k-x,h:C-v,fill:$,hatch:O,opacity:N,stroke:"none"}):M.display!=="empty"&&u.push({type:"rect",x,y:v,w:k-x,h:C-v,stroke:c.gapStroke,strokeWidth:1,dashed:true,fill:"none"});}}return u}_interpolateValue(t,e){for(let n=1;n<e.length;n++){let s=e[n-1],i=e[n];if(!(s.value===null||i.value===null)&&t>=s.time&&t<=i.time){let o=(t-s.time)/(i.time-s.time);return s.value+o*(i.value-s.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;return {name:t.name,color:e?.color??c.stroke}})}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 s=this._timeScale?this._timeScale.map(t):0,i=this._valueScales.get(n);return {x:s,y:i?i.map(e):0}}};var ft=class{};var Y=1e3,X=class extends ft{#t="100%";#e="100%";#n;#i=new Map;#r=new Map;#s=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.#s.clear();let e=t.map(l=>this._toSVG(l));this.#n&&e.unshift(`<rect width="100%" height="100%" fill="${this._esc(this.#n)}" />`);let n=e.join(`
29
- `),s="",i=[];for(let[,l]of this.#i)i.push(l);for(let[,l]of this.#r)i.push(l);for(let[,l]of this.#s)i.push(l);i.length>0&&(s=` <defs>
30
- ${i.join(`
24
+ `.trim()}function It(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 rt={axisColor:p.axisColor,tickColor:p.tickColor,textColor:p.textColor,textSize:p.textSize},Q=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??rt).axisColor}get tickColor(){return (this.#e.colors??rt).tickColor}get textColor(){return (this.#e.colors??rt).textColor}get textSize(){return (this.#e.colors??rt).textSize}generateTicks(){let t=this.#e.minTicks??5,e=this.#e.maxTicks??12,o=this.#t.ticks({minTicks:t,maxTicks:e}).map(r=>({time:r,x:this.#t.map(r),label:this.tickLabel(r)}));return this.antiOverlap(o)}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:o}=this.#t.tickInterval((e+n)/2,e,n),r={};return o<6e4?(r.hour="2-digit",r.minute="2-digit",r.second="2-digit"):o<36e5||o<864e5?(r.hour="2-digit",r.minute="2-digit"):o<31536e6?(r.day="numeric",r.month="short",o>=2592e6&&(r.day=void 0,r.month="long")):(r.year="numeric",o<2*31536e6&&(r.month="short")),this.#t.format(t,r)}antiOverlap(t){if(t.length<=1)return t;let e=60,n=[t[0]];for(let o=1;o<t.length;o++){let r=n[n.length-1].x;Math.abs(t[o].x-r)>=e&&n.push(t[o]);}return n}render(){let t=this.generateTicks(),e=this.#e.colors??rt,n=this.#e.y??0,o=[],[r,s]=this.#t.range();o.push({type:"line",x1:r,y1:n,x2:s,y2:n,stroke:e.axisColor,strokeWidth:e.axisWidth});for(let a of t)o.push({type:"line",x1:a.x,y1:n,x2:a.x,y2:n+6,stroke:e.tickColor,strokeWidth:e.axisWidth}),o.push({type:"text",content:a.label,x:a.x,y:n+e.textSize+6,anchor:"middle",fontSize:e.textSize,fill:e.textColor});return o}};var ot={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function fe(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 ge(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 o=e+1;o<n;o++)t[o]=true;e=n+1;}return t}var lt=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??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.format??fe,e=6,[n,o]=this.#t.domain(),r=o-n;if(r===0)return [{value:n,position:this.#t.map(n),label:t(n)}];let s=r/e,a=Math.pow(10,Math.floor(Math.log10(s))),h=s/a,l;h<=1.5?l=a:h<=3?l=2*a:h<=7?l=5*a:l=10*a;let d=[],u=Math.ceil(n/l)*l;for(let m=u;m<=o;m+=l)d.push({value:m,position:this.#t.map(m),label:t(m)});return d}render(){let t=this.generateTicks(),e=this.#e.colors??ot,n=this.#e.x??0,o=this.#e.orientation??"vertical",r=this.#e.position??"left",s=this.#e.suppressLabelsNear??[],a=this.#e.suppressTolerancePx??8,h=d=>s.some(u=>Math.abs(u-d)<=a),l=[];if(o==="vertical"){let[d,u]=this.#t.range();l.push({type:"line",x1:n,y1:d,x2:n,y2:u,stroke:e.axisColor,strokeWidth:e.axisWidth});let m=ge(t);t.forEach((c,f)=>{let y=h(c.position),b=m[f]?{opacity:0}:{};r==="left"?(l.push({type:"line",x1:n-4,y1:c.position,x2:n,y2:c.position,stroke:e.tickColor,strokeWidth:e.axisWidth}),y||l.push({type:"text",content:c.label,x:n-8,y:c.position+4,anchor:"end",fontSize:11,fill:e.textColor,...b})):(l.push({type:"line",x1:n,y1:c.position,x2:n+4,y2:c.position,stroke:e.tickColor,strokeWidth:e.axisWidth}),y||l.push({type:"text",content:c.label,x:n+8,y:c.position+4,anchor:"start",fontSize:11,fill:e.textColor,...b}));});}else {let[d,u]=this.#t.range();l.push({type:"line",x1:d,y1:n,x2:u,y2:n,stroke:e.axisColor,strokeWidth:e.axisWidth});for(let m of t)l.push({type:"line",x1:m.position,y1:n,x2:m.position,y2:n+6,stroke:e.tickColor,strokeWidth:e.axisWidth}),l.push({type:"text",content:m.label,x:m.position,y:n+18,anchor:"middle",fontSize:e.textSize,fill:e.textColor});}return l}};var R=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=(o,r)=>o!==null&&r!==null?o+e*(r-o):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,h)=>a.time-h.time),o=[],r=[],s=null;for(let a of n){let h=t(a),l=e>0&&s&&a.time-s.time>e;(h||l)&&r.length&&(o.push(r),r=[]),h||r.push(a),s=a;}return r.length&&o.push(r),o}static splitByBoundaries(i,t,e,n){if(i.length===0)return [];if(t.length===0)return [{data:i,zoneIndex:0}];let o=[...t].sort((h,l)=>h-l),r=[],s=h=>{let l=0;for(let d=0;d<o.length&&h>=o[d];d++)l=d+1;return l},a=[i[0]];for(let h=1;h<i.length;h++){let l=i[h-1],d=i[h],u=e(l),m=e(d),c;m>u?c=o.filter(f=>f>u&&f<=m):m<u?c=o.filter(f=>f>=m&&f<u).reverse():c=[];for(let f of c){let y=(f-u)/(m-u),b=n(l,d,y);a.push(b),r.push({data:a,zoneIndex:s((u+f)/2)}),a=[b];}a.push(d);}if(a.length>0){let h=e(a[0]),l=e(a[a.length-1]);r.push({data:a,zoneIndex:s((h+l)/2)});}return r}static splitByThreshold(i,t,e,n){let o=this.splitByBoundaries(i,[t],e,n),r={above:[],below:[]};for(let s of o)s.zoneIndex===0?r.below.push(s.data):r.above.push(s.data);return r}};function Gt(i,t=6e4){if(i.length<2)return [];let e=[...i].sort((o,r)=>o.time-r.time),n=[];for(let o=1;o<e.length;o++)e[o].time-e[o-1].time>t&&n.push({startTime:e[o-1].time,endTime:e[o].time});return n}function ye(i,t=83144){let e=t/8.314,n=0,o=0;for(let s of i)s!==null&&(n+=Math.exp(-e/(s+273.15)),o++);if(o===0)return null;let r=n/o;return e/-Math.log(r)-273.15}function Et(i,t,e=83144){let n=new Array(i.length),o=0;for(let r=0;r<i.length;r++){let s=i[r].time,a=s-t;for(;o<r&&i[o].time<a;)o++;let h=i.slice(o,r+1).map(d=>d.value),l=ye(h,e);n[r]={time:s,value:l,synthetic:true};}return n}function be(i){let t=0,e=0;for(let r of i)r!==null&&(t+=r,e++);if(e===0)return null;let n=t/e,o=0;for(let r of i){if(r===null)continue;let s=r-n;o+=s*s;}return Math.sqrt(o/e)}function xe(i){let t=0,e=0;for(let r of i)r!==null&&(t+=r,e++);if(e<2)return null;let n=t/e,o=0;for(let r of i){if(r===null)continue;let s=r-n;o+=s*s;}return Math.sqrt(o/(e-1))}function Vt(i,t,e=false){let n=new Array(i.length),o=0,r=e?xe:be;for(let s=0;s<i.length;s++){let a=i[s].time,h=a-t;for(;o<s&&i[o].time<h;)o++;let l=i.slice(o,s+1).map(u=>u.value),d=r(l);n[s]={time:a,value:d,synthetic:true};}return n}function Nt(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 ht(i,t,e){let n=[],o=i.reduce((s,a)=>s+a.data.length,0),r=Nt(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(h=>({x:t.timeScale.map(h.time),y:t.valueScale.map(h.value)})),stroke:a.color??r.line.stroke,strokeWidth:r.line.strokeWidth,smoothing:r.line.smoothing,dashed:r.line.dashed,shadowColor:r.shadow.color,shadowBlur:r.shadow.blur,shadowOffsetX:r.shadow.offsetX,shadowOffsetY:r.shadow.offsetY,fill:"none"}):a.data.length===1&&o===1&&n.push({type:"circle",cx:t.timeScale.map(a.data[0].time),cy:t.valueScale.map(a.data[0].value),r:Math.max(r.markers.size,r.line.strokeWidth),fill:a.color??r.line.stroke,shadowColor:r.shadow.color,shadowBlur:r.shadow.blur});}return n}function Yt(i){let t=[];for(let e of i)t.length===0?t.push(e):t.push({x:e.x,y:t[t.length-1].y},e);return t}function Mt(i,t,e,n){if(i.length<2)return [];let o=R.splitByBoundaries(i,e.boundaries,e.getValue,e.interpolate),r=[];for(let s=0;s<o.length;s++){let a=o[s];if(a.data.length<2)continue;let h=e.getColor(a.zoneIndex);if(!h)continue;let l=a.data.map(u=>({x:t.timeScale.map(u.time),y:t.valueScale.map(e.yLow(u))})),d=a.data.map(u=>({x:t.timeScale.map(u.time),y:t.valueScale.map(e.yHigh(u))})).reverse();r.push({type:"path",id:n?.id?`${n.id}-fill-${s}`:void 0,points:[...l,...d],fill:h,hatch:e.getHatch?.(a.zoneIndex),stroke:"none"});}return r}function zt(i,t,e,n){let o=Nt(e);if(!o.markers.type||o.markers.type==="none")return [];let r=[];for(let s=0;s<i.length;s++){let a=i[s],h=t.timeScale.map(a.time),l=t.valueScale.map(a.value),d=n(a),u=e.pointStroke??d,m=e.pointFill??d,c=e.pointStrokeWidth??1.5,f=e.id?`${e.id}-marker-${s}`:void 0;Lt(r,f,o.markers.type,h,l,o.markers.size,u,m,c);}return r}function Lt(i,t,e,n,o,r,s,a,h){switch(e){case "circle":i.push({type:"circle",cx:n,cy:o,r,fill:a,stroke:s,strokeWidth:h,id:t});break;case "square":i.push({type:"rect",x:n-r,y:o-r,w:r*2,h:r*2,fill:a,stroke:s,strokeWidth:h,id:t});break;case "cross":i.push({type:"line",x1:n-r,y1:o-r,x2:n+r,y2:o+r,stroke:s,strokeWidth:h,id:t},{type:"line",x1:n-r,y1:o+r,x2:n+r,y2:o-r,stroke:s,strokeWidth:h,id:t});break;case "diamond":i.push({type:"path",points:[{x:n,y:o-r},{x:n+r,y:o},{x:n,y:o+r},{x:n-r,y:o}],fill:a,stroke:s,strokeWidth:h,id:t});break;case "triangle":i.push({type:"path",points:[{x:n,y:o-r},{x:n+r,y:o+r},{x:n-r,y:o+r}],fill:a,stroke:s,strokeWidth:h,id:t});break;case "star":{let l=[];for(let d=0;d<10;d++){let u=d%2===0?r:r*.5,m=Math.PI/2*3+d*Math.PI/5;l.push({x:n+u*Math.cos(m),y:o+u*Math.sin(m)});}i.push({type:"path",points:l,fill:a,stroke:s,strokeWidth:h,id:t});break}case "arrow":i.push({type:"path",points:[{x:n-r,y:o+r},{x:n,y:o-r},{x:n+r,y:o+r}],stroke:s,strokeWidth:h,fill:"none",id:t});break;case "plus":i.push({type:"line",x1:n-r,y1:o,x2:n+r,y2:o,stroke:s,strokeWidth:h,id:t},{type:"line",x1:n,y1:o-r,x2:n,y2:o+r,stroke:s,strokeWidth:h,id:t});break;case "triangle-down":i.push({type:"path",points:[{x:n,y:o+r},{x:n+r,y:o-r},{x:n-r,y:o-r}],fill:a,stroke:s,strokeWidth:h,id:t});break;case "hexagon":{let l=[];for(let d=0;d<6;d++){let u=d*(Math.PI/3);l.push({x:n+r*Math.cos(u),y:o+r*Math.sin(u)});}i.push({type:"path",points:l,fill:a,stroke:s,strokeWidth:h,id:t});break}case "hourglass":i.push({type:"path",points:[{x:n-r,y:o-r},{x:n+r,y:o-r},{x:n-r,y:o+r},{x:n+r,y:o+r}],fill:a,stroke:s,strokeWidth:h,id:t});break;case "line-horizontal":i.push({type:"line",x1:n-r,y1:o,x2:n+r,y2:o,stroke:s,strokeWidth:h,id:t});break;default:i.push({type:"circle",cx:n,cy:o,r,fill:a,stroke:s,strokeWidth:h,id:t});}}var tt=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 dt=class extends tt{#t;constructor(t){super(t,t.data),this.#t=t;}render(){let t=this.#t,e=t.minColor??p.minColor,n=t.maxColor??p.maxColor,o=t.avgColor??p.avgColor,r=t.avgDashed??true,s=t.smoothing??false,a=t.strokeWidth??p.strokeWidth,h=R.getRuns(this.data,c=>c.min===null||c.max===null||c.avg===null);if(h.length===0)return [];let l={timeScale:this.timeScale,valueScale:t.valueScale},d=[];h.forEach((c,f)=>{c.length<2||(t.fillToMax&&d.push(...Mt(c,l,{boundaries:[],yLow:y=>y.avg,yHigh:y=>y.max,getValue:y=>y.avg,interpolate:R.interpolateAggregatedPoint,getColor:()=>t.fillToMax,getHatch:()=>t.fillToMaxHatch},{id:this.id?`${this.id}-fillToMax-${f}`:void 0})),t.fillToMin&&d.push(...Mt(c,l,{boundaries:[],yLow:y=>y.avg,yHigh:y=>y.min,getValue:y=>y.avg,interpolate:R.interpolateAggregatedPoint,getColor:()=>t.fillToMin,getHatch:()=>t.fillToMinHatch},{id:this.id?`${this.id}-fillToMin-${f}`:void 0})));});let u=h.filter(c=>c.length>=2),m=c=>u.map(f=>({data:f.map(y=>({time:y.time,value:c(y)}))}));return d.push(...ht(m(c=>c.max),l,{stroke:n,strokeWidth:a,smoothing:s,id:this.id?`${this.id}-max`:void 0}),...ht(m(c=>c.min),l,{stroke:e,strokeWidth:a,smoothing:s,id:this.id?`${this.id}-min`:void 0}),...ht(m(c=>c.avg),l,{stroke:o,strokeWidth:a,smoothing:s,dashed:r,id:this.id?`${this.id}-avg`:void 0})),d}};var mt=class extends tt{#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??p.bandFill,n=t.hatch,o=t.avgLine??false,r=t.avgLineColor??p.bandAvgLine,s=t.bandWidth??10,a=[];for(let h of this.data){if(h.min===null||h.max===null)continue;let l=this.timeScale.map(h.time),d=t.valueScale.map(h.max),u=t.valueScale.map(h.min),m=s,c=this.data.indexOf(h);if(a.push({type:"rect",x:l-m/2,y:d,w:m,h:u-d,fill:e,hatch:n,opacity:this.opacity(h.count),id:this.id?`${this.id}-slot-${c}`:void 0}),o&&h.avg!==null){let f=t.valueScale.map(h.avg);a.push({type:"line",x1:l-m/2,y1:f,x2:l+m/2,y2:f,stroke:r,strokeWidth:1,id:this.id?`${this.id}-avg-${c}`:void 0});}}return a}};function Se(i){return i==="dotted"?{dash:"dotted"}:i==="dashed"?{dash:"dashed"}:{}}function qt(i){let{thresholds:t,valueScale:e,xRange:n}=i,[o,r]=n,[s,a]=e.range(),h=Math.min(s,a),l=Math.max(s,a),d=[],u=[];for(let m of t){let c=m.color??p.thresholdColor,f=e.map(m.value);m.fill==="above"?d.push({type:"rect",x:o,y:h,w:r-o,h:Math.max(0,f-h),fill:c,hatch:m.fillHatch,opacity:m.fillOpacity??.12,id:m.id?`${m.id}-fill`:void 0}):m.fill==="below"&&d.push({type:"rect",x:o,y:f,w:r-o,h:Math.max(0,l-f),fill:c,hatch:m.fillHatch,opacity:m.fillOpacity??.12,id:m.id?`${m.id}-fill`:void 0});let y=m.line??p.thresholdLine;if(y!=="none"){let b=Se(y),_={type:"line",x1:o,y1:f,x2:r,y2:f,stroke:c,strokeWidth:1,...b,id:m.id?`${m.id}-line`:void 0};m.shadowColor&&(_.shadowColor=m.shadowColor,_.shadowBlur=m.shadowBlur??4,_.shadowOffsetX=m.shadowOffsetX??0,_.shadowOffsetY=m.shadowOffsetY??2),d.push(_);}if(m.label!==false){let b=m.label&&typeof m.label=="object"?m.label:void 0,_=typeof m.label=="string"?m.label:b?.text??m.name,T=b?.position??"right";u.push({..._e(_,T,o,r,f,c,b),id:m.id?`${m.id}-label`:void 0});}}return {inside:d,labels:u}}function _e(i,t,e,n,o,r,s){let a=(e+n)/2,h={type:"text",content:i,fontSize:p.thresholdFontSize,fill:r},l=s?{...s.rotate!==void 0&&{rotate:s.rotate},...s.textBaseline!==void 0&&{textBaseline:s.textBaseline}}:{};switch(t){case "left":return {...h,...l,x:e+4,y:o-4,anchor:"start"};case "above":return {...h,...l,x:a,y:o-6,anchor:"middle"};case "below":return {...h,...l,x:a,y:o+14,anchor:"middle"};case "center":return {...h,...l,x:a,y:o-4,anchor:"middle"};case "outside-left":return {...h,...l,x:e-6,y:o+3,anchor:"end",textBaseline:l.textBaseline??"middle"};case "outside-right":return {...h,...l,x:n+6,y:o+3,anchor:"start",textBaseline:l.textBaseline??"middle"};default:return {...h,...l,x:n-4,y:o-4,anchor:"end"}}}function Xt(i){let{gaps:t,timeScale:e,yRange:n,fill:o=p.gapFill,hatch:r,fillOpacity:s=p.gapFillOpacity,stroke:a=p.gapStroke,strokeWidth:h=p.gapStrokeWidth,dashed:l=true,fontSize:d=p.gapFontSize,fontFill:u=p.gapFontColor,labelBaseline:m="middle",labelRotate:c}=i,[f,y]=n,b=[];for(let _ of t){let T=e.map(_.startTime),N=e.map(_.endTime),P=_.fill??o,L=_.hatch??r,I=_.fillOpacity??s,B=_.label??"",E=_.rotate??c,G=_.labelBaseline??m;if(_.style==="dashed_border"||!_.style?b.push({type:"rect",x:T,y:f,w:N-T,h:y-f,fill:P,hatch:L,opacity:I,stroke:a,strokeWidth:h,dashed:l}):_.style==="empty"&&b.push({type:"rect",x:T,y:f,w:N-T,h:y-f,fill:P,hatch:L,opacity:I}),B){let x=ve(f,y,G),w=G==="above"?"top":G==="below"?"bottom":"middle";b.push({type:"text",content:B,x:(T+N)/2,y:x,anchor:"middle",fontSize:d,fill:u,textBaseline:w,rotate:E});}}return b}function ve(i,t,e){switch(e){case "above":return i-12;case "below":return t+4;default:return (i+t)/2}}var ut=class{#t;constructor(t,e,n,o){this.#t={...t,xRange:e,y:n,height:o};}render(){let{items:t,timeScale:e,background:n,hatch:o,showAxis:r,xRange:s,y:a,height:h}=this.#t,l=[];n&&l.push({type:"rect",x:s[0],y:a,w:s[1]-s[0],h,fill:n,opacity:.04,stroke:"#ddd",strokeWidth:.25});for(let d of t){let u=e.map(d.startTime),m=e.map(d.endTime);if(!(m-u<1)&&(l.push({type:"rect",x:u,y:a,w:m-u,h,hatch:d.hatch??o,fill:d.fill??"#6b728044",stroke:d.stroke,strokeWidth:d.strokeWidth??0}),d.label)){let c=d.labelFontSize??10;l.push({type:"text",content:d.label,x:(u+m)/2,y:this.#e(d.labelBaseline,c),anchor:"middle",fontSize:c,fill:d.labelFill??"#333"});}}if(r){let d=new Q({domain:e.domain(),xRange:s,y:a+h+4});l.push({type:"group",cssClass:"annotation-band-axis",commands:d.render()});}return l}#e(t,e){let{y:n,height:o}=this.#t;switch(t){case "top":return n+e*.9;case "bottom":return n+o-e*.25;default:return n+o/2+e*.35}}};function Ut(i){let{highlights:t,timeScale:e,yRange:n,height:o}=i,[r,s]=n,a=[];for(let h of t){let l=e.map(h.startTime),d=e.map(h.endTime);a.push({type:"rect",x:l,y:r,w:d-l,h:s-r,fill:h.color??p.highlightColor,opacity:h.opacity??p.highlightOpacity}),h.label&&a.push({type:"text",content:h.label,x:(l+d)/2,y:we(h.labelPosition??"top",r,s,o),anchor:"middle",fontSize:p.annotationFontSize,fill:h.color??p.highlightLabelColor,rotate:h.rotate});}return a}function we(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 Kt(i){let{markers:t,timeScale:e,valueScale:n,yRange:o=[0,300]}=i,[r,s]=o,a=[];for(let h of t){let l=e.map(h.time),d=h.color??p.markerColor,u=h.pointStyle??(h.value!==void 0?"circle":"none"),m=h.lineStyle??"full";if(h.value!==void 0){let c=n.map(h.value);if(m==="to-value"?a.push({type:"line",x1:l,y1:s,x2:l,y2:c,stroke:d,strokeWidth:1,dashed:true}):m==="to-top"?a.push({type:"line",x1:l,y1:r,x2:l,y2:c,stroke:d,strokeWidth:1,dashed:true}):m==="full"&&a.push({type:"line",x1:l,y1:r,x2:l,y2:s,stroke:d,strokeWidth:1}),u!=="none"&&Lt(a,void 0,u,l,c,p.markerSize,d,d,1.5),h.label){let f=m==="to-value"?c-10:r-6;a.push({type:"text",content:h.label,x:l,y:f,anchor:"middle",fontSize:11,fill:d});}}else a.push({type:"line",x1:l,y1:r,x2:l,y2:s,stroke:d,strokeWidth:1}),h.label&&a.push({type:"text",content:h.label,x:l,y:r-6,anchor:"middle",fontSize:11,fill:d});}return a}function Zt(i){let{annotations:t,timeScale:e,valueScales:n}=i,o=[],r=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=[],h=l=>a.push(l);switch(s.type){case "line":{let l=r(s.from),d=r(s.to);h({type:"line",x1:l.x,y1:l.y,x2:d.x,y2:d.y,stroke:s.color??p.annotationColor,strokeWidth:s.width??p.annotationWidth,dash:s.dash});break}case "arrow":{let l=r(s.from),d=r(s.to),u=s.color??p.annotationColor,m=s.headSize??p.annotationHead;h({type:"line",x1:l.x,y1:l.y,x2:d.x,y2:d.y,stroke:u,strokeWidth:s.width??p.annotationWidth});let c=Math.hypot(d.x-l.x,d.y-l.y)||1,f=(d.x-l.x)/c,y=(d.y-l.y)/c,b=d.x-f*m,_=d.y-y*m;h({type:"path",points:[{x:d.x,y:d.y},{x:b-y*m*.5,y:_+f*m*.5},{x:b+y*m*.5,y:_-f*m*.5}],fill:u,stroke:"none"});break}case "rect":{let l=r(s.from),d=r(s.to);h({type:"rect",x:Math.min(l.x,d.x),y:Math.min(l.y,d.y),w:Math.abs(d.x-l.x),h:Math.abs(d.y-l.y),fill:s.fill??"none",stroke:s.stroke,opacity:s.opacity});break}case "point":{let l=r(s.at),d=s.color??"#334155",u=s.radius??p.annotationRadius,m=s.shape??"circle";m==="circle"?h({type:"circle",cx:l.x,cy:l.y,r:u,fill:d}):m==="square"?h({type:"rect",x:l.x-u,y:l.y-u,w:u*2,h:u*2,fill:d}):(h({type:"line",x1:l.x-u,y1:l.y-u,x2:l.x+u,y2:l.y+u,stroke:d,strokeWidth:1.5}),h({type:"line",x1:l.x-u,y1:l.y+u,x2:l.x+u,y2:l.y-u,stroke:d,strokeWidth:1.5}));break}case "label":{let l=r(s.at);h({type:"text",content:s.text,x:l.x+(s.dx??0),y:l.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 l=nt(s.id);o.push({type:"group",cssClass:`annotation annotation--${l}`,commands:a});}else o.push(...a);}return o}var U=12,ct=8,Dt=20,ke=11,Pt=18,Bt=i=>i.length*ke*.6;function Jt(i,t="vertical"){if(t==="horizontal"){let n=0;for(let o of i)n+=U+ct+Bt(o.name)+Pt;return {width:Math.max(0,n-Pt),height:Dt}}let e=0;for(let n of i)e=Math.max(e,Bt(n.name));return {width:U+ct+e,height:i.length*Dt}}function Qt(i){let{items:t,x:e,y:n,orientation:o="vertical"}=i,r=[],s=e;return t.forEach((a,h)=>{let l=o==="horizontal"?s:e,d=o==="horizontal"?n:n+h*Dt;r.push({type:"rect",x:l,y:d,w:U,h:U,fill:a.color,stroke:p.legendStroke,strokeWidth:1},{type:"text",content:a.name,x:l+U+ct,y:d+U-2,fontSize:p.legendFont,fill:p.legendText}),o==="horizontal"&&(s+=U+ct+Bt(a.name)+Pt);}),{type:"group",cssClass:"chart-legend",commands:r}}function te(i){let{xTicks:t,yTicks:e,xRange:n,yRange:o,stroke:r=p.gridStroke,strokeWidth:s=p.gridStrokeWidth,dashed:a=false,opacity:h=p.gridOpacity}=i,l=[];if(e)for(let d of e)l.push({type:"line",x1:n[0],y1:d,x2:n[1],y2:d,stroke:r,strokeWidth:s,dashed:a,opacity:h});if(t)for(let d of t)l.push({type:"line",x1:d,y1:o[0],x2:d,y2:o[1],stroke:r,strokeWidth:s,dashed:a,opacity:h});return l}function ee(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 o=e.thresholds.get(n.threshold);if(!o)throw new Error(`fillSpec region references unknown threshold '${n.threshold}'`);return e.valueScale.map(o.value)}return typeof n=="object"&&"value"in n?e.valueScale.map(n.value):null}function Ce(i){return typeof i=="string"?{color:i}:{color:i.color,hatch:i.hatch}}function ne(i,t,e){let n=ee(i.from,"chartBottom",t),o=ee(i.to,"series",t),{color:r,hatch:s}=Ce(i.fill),a={type:"path",fill:r,hatch:s,stroke:"none",...t.idPrefix&&{id:`${t.idPrefix}-fill-r${e}`}};if(n!==null&&o!==null){let m=t.timeScale.range(),c=m[0],f=m[1],y=Math.min(n,o),b=Math.max(n,o);return [{...a,points:[{x:c,y},{x:f,y},{x:f,y:b},{x:c,y:b}]}]}let h=n??o,l=[],d=Te(i,t);if(d===null){let m=t.valueScale.domain();d=(n??o)===t.chartBottom?m[0]:m[1];}let u=ie(i.outer,t);for(let m of t.runs){if(m.length<2)continue;let c=R.splitByThreshold(m,d,y=>y.value??d,R.interpolateDataPoint),f=i.side==="above"?c.above:i.side==="below"?c.below:[...c.above,...c.below];if(u!==null&&i.side){let y=i.side==="above"?"below":"above";f=f.flatMap(b=>{if(b.length<2)return [];let _=R.splitByThreshold(b,u,T=>T.value??u,R.interpolateDataPoint);return y==="above"?_.above:_.below});}for(let y of f){if(y.length<2)continue;let b=y.map(T=>({x:t.timeScale.map(T.time),y:t.valueScale.map(T.value)})),_=[...b].reverse().map(T=>({x:T.x,y:h}));l.push({...a,smoothing:t.smoothing,smoothCount:b.length,points:[...b,..._]});}}return l}function Te(i,t){let e=i.from==="series"?i.to:i.from;return ie(e,t)}function ie(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 re(i,t){if(typeof i=="string"||!("regions"in i))return ne({fill:i},t,0);let e=[];return i.regions.forEach((n,o)=>{e.push(...ne(n,t,o));}),e}function oe(i,t){let e=new Array(i.length),n=0;for(let o=0;o<i.length;o++){let r=i[o].time,s=r-t;for(;n<o&&i[n].time<s;)n++;let a=0,h=0;for(let l=n;l<=o;l++){let d=i[l].value;d!==null&&(a+=d,h++);}e[o]={time:r,value:h===0?null:a/h,synthetic:true};}return e}function ae(i){let t=i.style?.line,e=t&&!Array.isArray(t)?t:void 0;return {color:e?.color??p.stroke,width:e?.width??p.strokeWidth,dash:e?.style,smoothing:e?.smoothing??false}}function se(i,t,e,n){let o=i.filter(h=>h.value!==null);if(o.length<2)return [];let r=o.map(h=>({x:t.timeScale.map(h.time),y:t.valueScale.map(h.value)})),s=ae(e);return [{type:"path",id:t.idPrefix?`${t.idPrefix}-overlay-${n}`:`overlay-${n}`,points:r,stroke:s.color,strokeWidth:s.width,smoothing:s.smoothing,dash:s.dash,fill:"none"}]}function le(i,t){switch(i.kind){case "movingAverage":{i.type;let e=oe(t.data,i.window);return se(e,t,i,"movingAvg")}case "movingMkt":{let e=Et(t.data,i.window,i.activationEnergy);return se(e,t,i,"movingMkt")}case "limits":{let e=[],n=t.timeScale.range(),o=n[0],r=n[1],s=ae(i),a=s.color,h=s.width,l=s.dash??"dashed",d=t.idPrefix?`${t.idPrefix}-`:"";return i.high!==void 0&&e.push({type:"line",id:`${d}overlay-limit-high`,x1:o,y1:t.valueScale.map(i.high),x2:r,y2:t.valueScale.map(i.high),stroke:a,strokeWidth:h,dash:l}),i.low!==void 0&&e.push({type:"line",id:`${d}overlay-limit-low`,x1:o,y1:t.valueScale.map(i.low),x2:r,y2:t.valueScale.map(i.low),stroke:a,strokeWidth:h,dash:l}),e}case "stdDevBand":{let e=i.multiplier??1,n=oe(t.data,i.window),o=Vt(t.data,i.window),r=[],s=[];for(let y=0;y<n.length;y++){let b=n[y].value,_=o[y].value;if(b===null||_===null)continue;let T=t.timeScale.map(n[y].time);r.push({x:T,y:t.valueScale.map(b+e*_)}),s.push({x:T,y:t.valueScale.map(b-e*_)});}if(r.length<2)return [];let a=t.idPrefix?`${t.idPrefix}-`:"",h=[],d=(typeof i.style?.fill=="string"||i.style?.fill&&!("regions"in i.style.fill)?i.style.fill:void 0)??"#94a3b833",{color:u,hatch:m}=$e(d);h.push({type:"path",id:`${a}overlay-stdDevBand`,points:[...r,...[...s].reverse()],fill:u,hatch:m,stroke:"none"});let c=i.style?.line,f=c&&!Array.isArray(c)?c:void 0;if(f){let y=n.filter(b=>b.value!==null).map(b=>({x:t.timeScale.map(b.time),y:t.valueScale.map(b.value)}));y.length>=2&&h.push({type:"path",id:`${a}overlay-stdDevBand-mean`,points:y,stroke:f.color??p.stroke,strokeWidth:f.width??1.5,smoothing:f.smoothing,dash:f.style,fill:"none"});}return h}}}function $e(i){return typeof i=="string"?{color:i}:{color:i.color,hatch:i.hatch}}function Ae(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(o=>{let r={...e,...o.style},s=r.fill,a,h;return typeof s=="string"?a=s:s&&(a=s.color,h=s.hatch),{startTime:o.startTime,endTime:o.endTime,label:o.label,fill:a,hatch:h,fillOpacity:r.opacity,labelBaseline:r.label?.baseline,rotate:r.label?.rotate,style:r.display==="filled"||r.display==="bridge_line"?void 0:r.display}}),autoDetect:i.autoDetect??false,minGapMs:i.minGapMs??6e4}}function pt(i){return "showAs"in i&&!!i.showAs}var K=class{_layout;_renderer;_locale;_legend;_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 et({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._markers=t.markers??[],this._thresholds=t.thresholds??[],this._highlights=t.highlights??[];let e=Ae(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,o=e.spacing??0;(e.showAxis??false)&&(t+=26+o),t+=n+o;}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(pt(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",o=this._legend?.orientation??"vertical",r=e?Jt(t,o):{width:0},s=this._layout;if(e&&(n==="outside-right"||n==="outside-left")){let g=r.width+16,S={...this._layout.margin};n==="outside-right"?S.right+=g:S.left+=g,s=new et({width:this._layout.totalWidth,height:this._layout.totalHeight,margin:S}).compute();}let{chartX:a,chartY:h,chartWidth:l,chartHeight:d}=s,u=[a,a+l],m=[h,h+d],c=[];for(let g of this._series)g.data.sort((S,v)=>S.time-v.time);let f=new Map,y=1/0,b=-1/0,_=false;for(let g of this._series){let S=this._axisIndexOf(g),v=f.get(S);v?v.push(g):f.set(S,[g]);for(let A of this._timesOf(g))A<y&&(y=A),A>b&&(b=A),_=true;}if(!_)return [];let T=this._axes?.x?.domain,N=T&&T!=="auto"?T:[y,b];this._timeScale=new J({domain:N,range:u,locale:this._locale});let P=g=>({axisColor:g?.color??p.axisColor,tickColor:g?.color??p.tickColor,textColor:p.textColor,textSize:p.textSize,axisWidth:g?.width??1}),L=new Q({domain:N,xRange:u,y:h+d,locale:this._locale,format:this._axes?.x?.format,maxTicks:this._axes?.x?.ticks?.major,colors:P(this._axes?.x?.axis)});this._valueScales.clear();let I=Array.from(f.keys()).sort((g,S)=>g-S),B,E=0,G=0;for(let g of I){let S=f.get(g),v=1/0,A=-1/0,M=false;for(let V of S)for(let at of this._valuesOf(V))at<v&&(v=at),at>A&&(A=at),M=true;if(!M)continue;let D;this._axes?.y&&this._axes.y.length>g?D=this._axes.y[g]:g===0?D=this._axes?.left:g===1&&(D=this._axes?.right);let Ct=D?.domain,Z=Ct&&Ct!=="auto"?Ct:[v,A],jt=new X({domain:Z,range:[h+d,h]});this._valueScales.set(g,jt);let Ht=this._thresholds.filter(V=>(V.axisIndex??0)===g&&V.label!==false&&V.value>=Math.min(Z[0],Z[1])&&V.value<=Math.max(Z[0],Z[1])).map(V=>jt.map(V.value)),Tt=D?.position??(g===0?"left":"right"),$t;if(Tt==="right"){let V=D?.offset!==void 0?D.offset:G*50;$t=a+l+V,G++;}else {let V=D?.offset!==void 0?D.offset:E*50;$t=a-V,E++;}let Ot=new lt({domain:Z,range:[h+d,h],x:$t,position:Tt,format:D?.format,ticks:D?.ticks?.major,colors:P(D?.axis),suppressLabelsNear:Ht.length?Ht:void 0});g===0&&(B=Ot),c.push({type:"group",cssClass:`value-axis ${Tt}`,commands:Ot.render()});}let x=this._valueScales.get(0)??this._valueScales.get(I[0]);c.push({type:"group",cssClass:"time-axis",commands:L.render()});let w=null,k=this._axes?.x?.grid?.major,$=this._axes?.left?.grid?.major;if(k!==void 0||$!==void 0){let g=k!==false,S=$!==false&&!!B,v=g?L.generateTicks().map(M=>M.x):void 0,A=S?B.generateTicks().map(M=>M.position):void 0;if(v||A){let M=(k&&typeof k=="object"?k:void 0)??($&&typeof $=="object"?$:void 0);w={type:"group",cssClass:"chart-grid",commands:te({xTicks:v,yTicks:A,xRange:u,yRange:m,stroke:M?.color,opacity:M?.opacity,dashed:M?.style==="dashed"})};}}if(this._highlights.length>0&&c.push({type:"group",cssClass:"highlights",commands:Ut({highlights:this._highlights,timeScale:this._timeScale,yRange:m,height:s.totalHeight})}),this._thresholds.length>0&&x){let g=[],S=[];for(let v of this._thresholds){let A=v.id??nt(v.name),M=this._valueScales.get(v.axisIndex??0)??x,D=qt({thresholds:[v],valueScale:M,xRange:u});D.inside.length&&g.push({type:"group",cssClass:`threshold threshold--${A}`,id:`threshold-${A}`,commands:D.inside}),D.labels.length&&S.push({type:"group",cssClass:`threshold-label threshold-label--${A}`,commands:D.labels});}g.length&&c.push({type:"group",cssClass:"thresholds",commands:g,clipRect:{x:a,y:h,w:l,h:d}}),S.length&&c.push({type:"group",cssClass:"threshold-labels",commands:S});}let H=this._gaps;if(this._gapsAutoDetect){let g=[];for(let S of this._series)pt(S)||g.push(...Gt(S.data,this._gapsMinGapMs));g.length>0&&(H=[...this._gaps,...g]);}H.length>0&&c.push({type:"group",cssClass:"gaps",commands:Xt({gaps:H,timeScale:this._timeScale,yRange:m})});let O=new Map(this._thresholds.map(g=>[g.id??g.name,g]));for(let g of this._series){if(g.data.length===0)continue;let S=this._valueScales.get(this._axisIndexOf(g));if(!S)continue;let v=nt(g.id??g.name);c.push({type:"group",cssClass:`series series--${v}`,id:`series-${v}`,commands:this._renderSeries(g,S,O)});}w&&c.push(w);let Y=this._markers.map(g=>({...g}));for(let g of Y)if(g.value===void 0&&(g.lineStyle==="to-value"||g.lineStyle==="to-top")){let S=this._series[g.seriesIndex??0];S&&!pt(S)&&S.data.length>=2&&(g.value=this._interpolateValue(g.time,S.data));}Y.length>0&&x&&c.push({type:"group",cssClass:"markers",commands:Kt({markers:Y,timeScale:this._timeScale,valueScale:x,yRange:m})});let F=this._annotations.filter(g=>!g.id||!this._disabledAnnotations.has(g.id));if(F.length>0&&c.push({type:"group",cssClass:"annotations",commands:Zt({annotations:F,timeScale:this._timeScale,valueScales:this._valueScales})}),this._annotationBands.length>0){let g=h+d+this._layout.margin.bottom,S=0;this._annotationBands.forEach(v=>{let A=v.height??12,M=v.spacing??0,D=g+S;(v.showAxis??false)&&(S+=26+M),S+=A+M,c.push({type:"group",cssClass:"annotation-band",commands:new ut({name:v.name,showAxis:v.showAxis??false,items:v.items,timeScale:this._timeScale,background:v.background,hatch:v.hatch},[a,a+l],D,A).render()});});}if(e&&n!=="separate"){let g,S;n==="inside-right"?(g=a+l-r.width-8,S=h+8):n==="inside-left"?(g=a+8,S=h+8):n==="outside-right"?(g=a+l+16,S=h):(g=8,S=h),c.push(Qt({items:t,x:g,y:S,orientation:o}));}let C=this._axes?.left?.label,W=this._axes?.right?.label,j=this._axes?.x?.label;if(C||W||j){let g=[],S=h+d/2,v=this._axes?.left?.labels,A=this._axes?.right?.labels,M=this._axes?.x?.labels;C&&g.push({type:"text",content:C,x:14,y:S,anchor:"middle",fontSize:v?.fontSize??p.axisLabelSize,fill:v?.color??p.axisLabelColor,rotate:-90}),W&&g.push({type:"text",content:W,x:s.totalWidth-14,y:S,anchor:"middle",fontSize:A?.fontSize??p.axisLabelSize,fill:A?.color??p.axisLabelColor,rotate:90}),j&&g.push({type:"text",content:j,x:a+l/2,y:s.totalHeight-6,anchor:"middle",fontSize:M?.fontSize??p.axisLabelSize,fill:M?.color??p.axisLabelColor}),g.length&&c.push({type:"group",cssClass:"axis-labels",commands:g});}return c}_renderSeries(t,e,n){let o=this._timeScale,r={timeScale:o,valueScale:e};if(pt(t)){let x=t.style?.line&&!Array.isArray(t.style.line)?t.style.line:void 0,w=typeof t.style?.fill=="string"?t.style.fill:void 0;return t.showAs==="minmaxavg"?new dt({data:t.data,timeScale:o,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:x?.smoothing,strokeWidth:x?.width,id:it(t.name,t.id)}).render():new mt({data:t.data,timeScale:o,valueScale:e,fill:w??x?.color,avgLine:t.avgLine,countOpacity:t.countOpacity,id:it(t.name,t.id)}).render()}let s=t,a=t.style?.line&&!Array.isArray(t.style.line)?t.style.line:void 0,h=a?.gapThreshold??p.gapThreshold,l=R.getRuns(t.data,x=>x.value===null,h),d=l.reduce((x,w)=>x+w.length,0);if(d===0)return [];let u=[],m=t.style?.markers,c=t.style?.shadow,f={stroke:a?.color??p.stroke,strokeWidth:a?.width??p.strokeWidth,smoothing:a?.smoothing,dashed:a?.style==="dashed",pointStyle:m?.type,pointSize:m?.size,pointStroke:m?.stroke,pointFill:m?.fill,pointStrokeWidth:m?.strokeWidth,shadowColor:c?.color,shadowBlur:c?.blur,shadowOffsetX:c?.offsetX,shadowOffsetY:c?.offsetY,id:it(t.name,t.id)},y=t.style?.line,b=y&&!Array.isArray(y)?y:void 0,_=b?.color,T=b?.width,N=b?.style,P=b?.smoothing,L=t.style?.fill;if(L!==void 0){let x=e.range(),w=Math.min(x[0],x[1]),k=Math.max(x[0],x[1]);u.push(...re(L,{runs:l,timeScale:o,valueScale:e,thresholds:n,chartTop:w,chartBottom:k,smoothing:a?.smoothing,idPrefix:t.id}));}let I=s.colorByThresholds??[],B=I.map(x=>n.get(x)).filter(x=>!!x).map(x=>x.value).sort((x,w)=>x-w),E=(x,w,k)=>{let $=k??f.stroke;for(let H of w){let O=n.get(H);O&&x>=O.value&&($=O.color??$);}return $};for(let x of l){if(x.length<2)continue;let w=R.splitByBoundaries(x,B,k=>k.value,R.interpolateDataPoint);for(let k=0;k<w.length;k++){let $=w[k];if($.data.length<2)continue;let H=($.data[0].value+$.data[$.data.length-1].value)/2,O=it(s.name,s.id),Y=$.data.map(j=>({x:o.map(j.time),y:e.map(j.value)})),F=O?`${O}-line-${k}`:void 0,C=(b?.shape??a?.shape)==="step",W=C?Yt(Y):Y;y===false||(y&&Array.isArray(y)?y.forEach((j,g)=>{u.push({type:"path",id:F?`${F}-${g}`:void 0,points:W,stroke:E(H,I,j.color),strokeWidth:j.width??f.strokeWidth,smoothing:C?false:j.smoothing??f.smoothing,dash:j.style,opacity:j.opacity,fill:"none",shadowColor:f.shadowColor,shadowBlur:f.shadowBlur,shadowOffsetX:f.shadowOffsetX,shadowOffsetY:f.shadowOffsetY});}):u.push({type:"path",id:F,points:W,stroke:E(H,I,_),strokeWidth:T??f.strokeWidth,smoothing:C?false:P??f.smoothing,dash:N,fill:"none",shadowColor:f.shadowColor,shadowBlur:f.shadowBlur,shadowOffsetX:f.shadowOffsetX,shadowOffsetY:f.shadowOffsetY}));}f.pointStyle&&f.pointStyle!=="none"&&d<=(m?.threshold??p.pointThreshold)&&u.push(...zt(x,r,f,k=>E(k.value,I)));}let G=t.overlays;if(G&&G.length>0){let x=e.range(),w={data:t.data,timeScale:o,valueScale:e,chartTop:Math.min(x[0],x[1]),chartBottom:Math.max(x[0],x[1]),idPrefix:t.id};for(let k of G)u.push(...le(k,w));}if(t.style?.gap&&l.length>1){let x=e.range(),w=Math.min(x[0],x[1]),k=Math.max(x[0],x[1]),$=t.style.gap,H=$.fill,O,Y;typeof H=="string"?O=H:H&&(O=H.color,Y=H.hatch);let F=$.opacity??.15,C=$.bridge;for(let W=1;W<l.length;W++){let j=l[W-1][l[W-1].length-1],g=l[W][0],S=o.map(j.time),v=o.map(g.time);if($.display==="bridge_line"){if(j.value===null||g.value===null)continue;let A=e.map(j.value),M=e.map(g.value);u.push({type:"line",x1:S,y1:A,x2:v,y2:M,stroke:C?.color??(typeof t.style?.line=="object"&&!Array.isArray(t.style.line)?t.style.line.color:void 0)??p.stroke,strokeWidth:C?.width??1.5,dash:C?.style??"dotted"});}else O!==void 0?u.push({type:"rect",x:S,y:w,w:v-S,h:k-w,fill:O,hatch:Y,opacity:F,stroke:"none"}):$.display!=="empty"&&u.push({type:"rect",x:S,y:w,w:v-S,h:k-w,stroke:p.gapStroke,strokeWidth:1,dashed:true,fill:"none"});}}return u}_interpolateValue(t,e){for(let n=1;n<e.length;n++){let o=e[n-1],r=e[n];if(!(o.value===null||r.value===null)&&t>=o.time&&t<=r.time){let s=(t-o.time)/(r.time-o.time);return o.value+s*(r.value-o.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;return {name:t.name,color:e?.color??p.stroke}})}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 o=this._timeScale?this._timeScale.map(t):0,r=this._valueScales.get(n);return {x:o,y:r?r.map(e):0}}};var ft=class{};function Me(i){switch(i){case "top":return "text-top";case "bottom":return "text-bottom";default:return "middle"}}var q=class extends ft{#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(l=>this._toSVG(l));this.#n&&e.unshift(`<rect width="100%" height="100%" fill="${this._esc(this.#n)}" />`);let n=e.join(`
25
+ `),o="",r=[];for(let[,l]of this.#i)r.push(l);for(let[,l]of this.#r)r.push(l);for(let[,l]of this.#o)r.push(l);r.length>0&&(o=` <defs>
26
+ ${r.join(`
31
27
  `)}
32
28
  </defs>
33
- `);let o=typeof this.#t=="number"?`${this.#t}`:this.#t,a=typeof this.#e=="number"?`${this.#e}`:this.#e,h=typeof this.#t=="number"&&typeof this.#e=="number"?` viewBox="0 0 ${this.#t} ${this.#e}"`:"";return {type:"svg",content:`<svg xmlns="http://www.w3.org/2000/svg" width="${o}" height="${a}"${h}>
34
- ${s} ${n}
35
- </svg>`}}_toSVG(t){switch(t.type){case "path":return this._path(t);case "line":return this._line(t);case "rect":return this._rect(t);case "circle":return this._circle(t);case "text":return this.#d(t);case "gradient":return this._gradient(t);case "gap":return this._gap(t);case "group":return this._group(t)}}#l(t,e,n){if(t.length===0)return "";if(!e||t.length<3)return t.map((a,h)=>`${h===0?"M":"L"}${a.x},${a.y}`).join(" ");let s=n!=null&&n<t.length?Math.max(n,2):t.length,i=a=>Math.round(a*100)/100,o=`M${t[0].x},${t[0].y}`;for(let a=0;a<s-1;a++){let h=t[a-1]??t[a],l=t[a],d=t[a+1],u=t[a+2]&&a+2<s?t[a+2]:d,m=i(l.x+(d.x-h.x)/6),f=i(l.y+(d.y-h.y)/6),p=i(d.x-(u.x-l.x)/6),y=i(d.y-(u.y-l.y)/6);(m=(m*Y|0)/Y,f=(f*Y|0)/Y,p=(p*Y|0)/Y,y=(y*Y|0)/Y),o+=` C${m},${f} ${p},${y} ${d.x},${d.y}`;}for(let a=s;a<t.length;a++)o+=` L${t[a].x},${t[a].y}`;return o}_hatchPattern(t,e){let n=`hatch-${t}-${this._hatchIndex++}`;if(this.#s.has(n))return n;let s=At(n,t,e??"rgba(200,220,255,0.3)");return this.#s.set(n,s),n}_hatchIndex=0;_path(t){let e=this.#l(t.points,t.smoothing,t.smoothCount),n=[];if(t.hatch){let o=this._hatchPattern(t.hatch,t.fill);n.push(`fill="url(#${o})"`);}else n.push(`fill="${t.fill?this._esc(t.fill):"none"}"`);t.stroke&&n.push(`stroke="${this._esc(t.stroke)}"`),t.strokeWidth&&n.push(`stroke-width="${t.strokeWidth}"`);let s=this.#a(t.dash,t.dashed,t.strokeWidth);s&&(n.push(`stroke-dasharray="${s.strokeDasharray}"`),s.strokeLinecap&&n.push(`stroke-linecap="${s.strokeLinecap}"`)),t.opacity!==void 0&&n.push(`opacity="${t.opacity}"`),t.id&&n.push(`id="${this._esc(t.id)}"`);let i=this.#o(t);return i&&n.push(`filter="url(#${i})"`),`<path d="${e}" ${n.join(" ")} />`}_line(t){let e=[];t.stroke&&e.push(`stroke="${this._esc(t.stroke)}"`),t.strokeWidth&&e.push(`stroke-width="${t.strokeWidth}"`);let n=this.#a(t.dash,t.dashed,t.strokeWidth);n&&(e.push(`stroke-dasharray="${n.strokeDasharray}"`),n.strokeLinecap&&e.push(`stroke-linecap="${n.strokeLinecap}"`)),t.opacity!==void 0&&e.push(`opacity="${t.opacity}"`),t.id&&e.push(`id="${this._esc(t.id)}"`);let s=this.#o(t);return s&&e.push(`filter="url(#${s})"`),`<line x1="${t.x1}" y1="${t.y1}" x2="${t.x2}" y2="${t.y2}" ${e.join(" ")} />`}_rect(t){let e=[];if(t.hatch){let s=this._hatchPattern(t.hatch,t.fill);e.push(`fill="url(#${s})"`);}else t.fill!==void 0&&e.push(`fill="${this._esc(t.fill)}"`);t.stroke&&e.push(`stroke="${this._esc(t.stroke)}"`),t.strokeWidth&&e.push(`stroke-width="${t.strokeWidth}"`),t.opacity!==void 0&&e.push(`opacity="${t.opacity}"`),t.dashed&&e.push('stroke-dasharray="4,4"'),t.id&&e.push(`id="${this._esc(t.id)}"`);let n=this.#o(t);return n&&e.push(`filter="url(#${n})"`),`<rect x="${t.x}" y="${t.y}" width="${t.w}" height="${t.h}" ${e.join(" ")} />`}_circle(t){let e=[];if(t.hatch){let s=this._hatchPattern(t.hatch,t.fill);e.push(`fill="url(#${s})"`);}else t.fill&&e.push(`fill="${this._esc(t.fill)}"`);t.stroke&&e.push(`stroke="${this._esc(t.stroke)}"`),t.strokeWidth&&e.push(`stroke-width="${t.strokeWidth}"`),t.id&&e.push(`id="${this._esc(t.id)}"`);let n=this.#o(t);return n&&e.push(`filter="url(#${n})"`),`<circle cx="${t.cx}" cy="${t.cy}" r="${t.r}" ${e.join(" ")} />`}#a(t,e,n){return t==="dashed"||!t&&e?{strokeDasharray:"4,4"}:t==="dotted"?{strokeDasharray:"2,4"}:!t||t==="solid"?null:Wt(t,n??2)}#o(t){if(!t.shadowColor)return null;let e=t.shadowBlur??0,n=t.shadowOffsetX??0,s=t.shadowOffsetY??0;if(!e&&!n&&!s)return null;let i=`shadow_${e}_${n}_${s}`;if(this.#i.has(i))return i;let o=`<filter id="${i}" x="-50%" y="-50%" width="200%" height="200%">
36
- <feDropShadow dx="${n}" dy="${s}" stdDeviation="${e/2}" flood-color="${this._esc(t.shadowColor)}" />
37
- </filter>`;return this.#i.set(i,o),i}#h(t,e,n,s,i){this.#r.has(t)||this.#r.set(t,`<clipPath id="${t}">
38
- <rect x="${e}" y="${n}" width="${s}" height="${i}" />
39
- </clipPath>`);}#d(t){let e=[];return t.anchor&&e.push(`text-anchor="${t.anchor}"`),t.fontSize&&e.push(`font-size="${t.fontSize}"`),t.fontFamily&&e.push(`font-family="${this._esc(t.fontFamily)}"`),t.fill&&e.push(`fill="${this._esc(t.fill)}"`),t.opacity!=null&&e.push(`opacity="${t.opacity}"`),t.rotate&&e.push(`transform="rotate(${t.rotate} ${t.x} ${t.y})"`),t.textBaseline&&e.push(`textBaseline="${t.textBaseline}"`),t.id&&e.push(`id="${this._esc(t.id)}"`),`<text x="${t.x}" y="${t.y}" ${e.join(" ")}>${this._esc(t.content)}</text>`}_gradient(t){let e=`grad-${Math.random().toString(36).slice(2,8)}`,n=t.stops.map(s=>` <stop offset="${s.offset}" stop-color="${this._esc(s.color)}" />`).join(`
29
+ `);let s=typeof this.#t=="number"?`${this.#t}`:this.#t,a=typeof this.#e=="number"?`${this.#e}`:this.#e,h=typeof this.#t=="number"&&typeof this.#e=="number"?` viewBox="0 0 ${this.#t} ${this.#e}"`:"";return {type:"svg",content:`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${a}"${h}>
30
+ ${o} ${n}
31
+ </svg>`}}_toSVG(t){switch(t.type){case "path":return this._path(t);case "line":return this._line(t);case "rect":return this._rect(t);case "circle":return this._circle(t);case "text":return this.#d(t);case "gradient":return this._gradient(t);case "gap":return this._gap(t);case "group":return this._group(t)}}#l(t,e,n){if(t.length===0)return "";if(!e||t.length<3)return t.map((a,h)=>`${h===0?"M":"L"}${a.x},${a.y}`).join(" ");let o=n!=null&&n<t.length?Math.max(n,2):t.length,r=a=>Math.round(a*100)/100,s=`M${t[0].x},${t[0].y}`;for(let a=0;a<o-1;a++){let h=t[a-1]??t[a],l=t[a],d=t[a+1],u=t[a+2]&&a+2<o?t[a+2]:d,m=r(l.x+(d.x-h.x)/6),c=r(l.y+(d.y-h.y)/6),f=r(d.x-(u.x-l.x)/6),y=r(d.y-(u.y-l.y)/6);s+=` C${m},${c} ${f},${y} ${d.x},${d.y}`;}for(let a=o;a<t.length;a++)s+=` L${t[a].x},${t[a].y}`;return s}_hatchPattern(t,e){let n=`hatch-${t}-${this._hatchIndex++}`;if(this.#o.has(n))return n;let o=At(n,t,e??"rgba(200,220,255,0.3)");return this.#o.set(n,o),n}_hatchIndex=0;_path(t){let e=this.#l(t.points,t.smoothing,t.smoothCount),n=[];if(t.hatch){let s=this._hatchPattern(t.hatch,t.fill);n.push(`fill="url(#${s})"`);}else n.push(`fill="${t.fill?this._esc(t.fill):"none"}"`);t.stroke&&n.push(`stroke="${this._esc(t.stroke)}"`),t.strokeWidth&&n.push(`stroke-width="${t.strokeWidth}"`);let o=this.#a(t.dash,t.dashed,t.strokeWidth);o&&(n.push(`stroke-dasharray="${o.strokeDasharray}"`),o.strokeLinecap&&n.push(`stroke-linecap="${o.strokeLinecap}"`)),t.opacity!==void 0&&n.push(`opacity="${t.opacity}"`),t.id&&n.push(`id="${this._esc(t.id)}"`);let r=this.#s(t);return r&&n.push(`filter="url(#${r})"`),`<path d="${e}" ${n.join(" ")} />`}_line(t){let e=[];t.stroke&&e.push(`stroke="${this._esc(t.stroke)}"`),t.strokeWidth&&e.push(`stroke-width="${t.strokeWidth}"`);let n=this.#a(t.dash,t.dashed,t.strokeWidth);n&&(e.push(`stroke-dasharray="${n.strokeDasharray}"`),n.strokeLinecap&&e.push(`stroke-linecap="${n.strokeLinecap}"`)),t.opacity!==void 0&&e.push(`opacity="${t.opacity}"`),t.id&&e.push(`id="${this._esc(t.id)}"`);let o=this.#s(t);return o&&e.push(`filter="url(#${o})"`),`<line x1="${t.x1}" y1="${t.y1}" x2="${t.x2}" y2="${t.y2}" ${e.join(" ")} />`}_rect(t){let e=[];if(t.hatch){let o=this._hatchPattern(t.hatch,t.fill);e.push(`fill="url(#${o})"`);}else t.fill!==void 0&&e.push(`fill="${this._esc(t.fill)}"`);t.stroke&&e.push(`stroke="${this._esc(t.stroke)}"`),t.strokeWidth&&e.push(`stroke-width="${t.strokeWidth}"`),t.opacity!==void 0&&e.push(`opacity="${t.opacity}"`),t.dashed&&e.push('stroke-dasharray="4,4"'),t.id&&e.push(`id="${this._esc(t.id)}"`);let n=this.#s(t);return n&&e.push(`filter="url(#${n})"`),`<rect x="${t.x}" y="${t.y}" width="${t.w}" height="${t.h}" ${e.join(" ")} />`}_circle(t){let e=[];if(t.hatch){let o=this._hatchPattern(t.hatch,t.fill);e.push(`fill="url(#${o})"`);}else t.fill&&e.push(`fill="${this._esc(t.fill)}"`);t.stroke&&e.push(`stroke="${this._esc(t.stroke)}"`),t.strokeWidth&&e.push(`stroke-width="${t.strokeWidth}"`),t.id&&e.push(`id="${this._esc(t.id)}"`);let n=this.#s(t);return n&&e.push(`filter="url(#${n})"`),`<circle cx="${t.cx}" cy="${t.cy}" r="${t.r}" ${e.join(" ")} />`}#a(t,e,n){return t==="dashed"||!t&&e?{strokeDasharray:"4,4"}:t==="dotted"?{strokeDasharray:"2,4"}:!t||t==="solid"?null:It(t,n??2)}#s(t){if(!t.shadowColor)return null;let e=t.shadowBlur??0,n=t.shadowOffsetX??0,o=t.shadowOffsetY??0;if(!e&&!n&&!o)return null;let r=`shadow_${e}_${n}_${o}`;if(this.#i.has(r))return r;let s=`<filter id="${r}" x="-50%" y="-50%" width="200%" height="200%">
32
+ <feDropShadow dx="${n}" dy="${o}" stdDeviation="${e/2}" flood-color="${this._esc(t.shadowColor)}" />
33
+ </filter>`;return this.#i.set(r,s),r}#h(t,e,n,o,r){this.#r.has(t)||this.#r.set(t,`<clipPath id="${t}">
34
+ <rect x="${e}" y="${n}" width="${o}" height="${r}" />
35
+ </clipPath>`);}#d(t){let e=[];return t.anchor&&e.push(`text-anchor="${t.anchor}"`),t.fontSize&&e.push(`font-size="${t.fontSize}"`),t.fontFamily&&e.push(`font-family="${this._esc(t.fontFamily)}"`),t.fill&&e.push(`fill="${this._esc(t.fill)}"`),t.opacity!=null&&e.push(`opacity="${t.opacity}"`),t.rotate&&e.push(`transform="rotate(${t.rotate} ${t.x} ${t.y})"`),t.textBaseline&&e.push(`dominant-baseline="${Me(t.textBaseline)}"`),t.id&&e.push(`id="${this._esc(t.id)}"`),`<text x="${t.x}" y="${t.y}" ${e.join(" ")}>${this._esc(t.content)}</text>`}_gradient(t){let e=`grad-${Math.random().toString(36).slice(2,8)}`,n=t.stops.map(o=>` <stop offset="${o.offset}" stop-color="${this._esc(o.color)}" />`).join(`
40
36
  `);return `<linearGradient id="${e}" gradientUnits="userSpaceOnUse">
41
37
  ${n}
42
38
  </linearGradient>
43
- <path d="${t.points.map(s=>`${s.x},${s.y}`).join(" ")}" fill="url(#${e})" />`}_gap(t){if(t.style==="empty")return "";let e=[`stroke="${this._esc("#999")}"`,'stroke-dasharray="4,4"','fill="none"'];return t.style==="label"&&t.label?`<g class="gap">
39
+ <path d="${t.points.map(o=>`${o.x},${o.y}`).join(" ")}" fill="url(#${e})" />`}_gap(t){if(t.style==="empty")return "";let e=[`stroke="${this._esc("#999")}"`,'stroke-dasharray="4,4"','fill="none"'];return t.style==="label"&&t.label?`<g class="gap">
44
40
  <rect x="${t.x1}" y="${t.y1}" width="${t.x2-t.x1}" height="${t.y2-t.y1}" ${e.join(" ")} />
45
41
  <text x="${t.x1}" y="${t.y1-4}" fill="#999" font-size="10">${this._esc(t.label)}</text>
46
- </g>`:`<rect x="${t.x1}" y="${t.y1}" width="${t.x2-t.x1}" height="${t.y2-t.y1}" ${e.join(" ")} />`}_group(t){t.clipRect&&this.#h("clip-plot",t.clipRect.x,t.clipRect.y,t.clipRect.w,t.clipRect.h);let e=t.commands.map(a=>` ${this._toSVG(a).replace(/\n {3}/g,`
42
+ </g>`:`<rect x="${t.x1}" y="${t.y1}" width="${t.x2-t.x1}" height="${t.y2-t.y1}" ${e.join(" ")} />`}_group(t){t.clipRect&&this.#h("clip-plot",t.clipRect.x,t.clipRect.y,t.clipRect.w,t.clipRect.h);let e=t.commands.map(a=>` ${this._toSVG(a).replaceAll(/\n {3}/g,`
47
43
  `)}`).join(`
48
- `),n=t.cssClass?` class="${this._esc(t.cssClass)}"`:"",s=t.id?` id="${this._esc(t.id)}"`:"",i=t.plotClipId||(t.clipRect?"clip-plot":null),o=i?` clip-path="url(#${this._esc(i)})"`:"";return `<g${n}${s}${o}>
44
+ `),n=t.cssClass?` class="${this._esc(t.cssClass)}"`:"",o=t.id?` id="${this._esc(t.id)}"`:"",r=t.plotClipId||(t.clipRect?"clip-plot":null),s=r?` clip-path="url(#${this._esc(r)})"`:"";return `<g${n}${o}${s}>
49
45
  ${e}
50
- </g>`}_esc(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}};var se="http://www.w3.org/2000/svg";function we(r){let t=r.style?.line;return t&&!Array.isArray(t)&&t.color?t.color:c.stroke}function oe(r){return r.replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[t])}function ve(r){if(r.length===0)return "";let t=new Date(r[0].time).toLocaleString(),e=r.map(n=>`<div><span class="mlc-tooltip__name">${oe(n.series.name)}:</span> ${n.value.toFixed(2)}</div>`);return `<div class="mlc-tooltip__time">${oe(t)}</div>${e.join("")}`}function Ce(r,t){if(r.length===0)return;let e=0,n=r.length-1;for(;e<n;){let o=e+n>>1;r[o].time<t?e=o+1:n=o;}let s=r[Math.max(0,e-1)],i=r[e];return Math.abs(s.time-t)<=Math.abs(i.time-t)?s:i}function Te(r){return "value"in r?r.value:r.avg}function ot(r,t,e={}){let n=r.querySelector("svg");if(!n)throw new Error("attachTooltip: target has no <svg> child (did you mount the chart first?)");let s=e.format??ve,i=e.snapRadius??1/0,o=e.className??"mlc-tooltip",a=e.showPicks??true,h=e.pickRadius??5,l=e.picksClassName??"mlc-tooltip-picks",d=document.createElement("div");d.className=o,d.style.position="absolute",d.style.pointerEvents="none",d.style.display="none",getComputedStyle(r).position==="static"&&(r.style.position="relative"),r.appendChild(d);let u=null;a&&(u=document.createElementNS(se,"g"),u.setAttribute("class",l),u.setAttribute("pointer-events","none"),n.appendChild(u));let m=()=>{u&&u.replaceChildren();},f=t.series.map((S,w)=>({data:S.data.map(P=>({time:P.time,value:Te(P)})).filter(P=>P.value!==null).sort((P,R)=>P.time-R.time),series:S,index:w})),p=S=>{let w=n.getBoundingClientRect(),G=t.getWidth?.()??w.width,P=(S.clientX-w.left)*G/Math.max(1,w.width);t.getHeight?.()??w.height;let H=t.invertTime(P);if(!Number.isFinite(H)){d.style.display="none";return}let W=[];for(let T of f){let $=Ce(T.data,H);if(!$)continue;let O=t.project($.time,$.value,T.series.yAxisIndex??0).x,N=t.project($.time,$.value,T.series.yAxisIndex??0).y;Math.abs(O-P)>i||W.push({seriesIndex:T.index,series:T.series,time:$.time,value:$.value,x:O,y:N});}if(W.length===0){d.style.display="none",m();return}d.innerHTML=s(W);let E=r.getBoundingClientRect(),F=12,_=(S.clientX-w.left)/Math.max(1,w.width),v=(S.clientY-w.top)/Math.max(1,w.height),C=_<.5?`${F}px`:`calc(-100% - ${F}px)`,M=v<.5?`${F}px`:`calc(-100% - ${F}px)`;if(d.style.left=`${S.clientX-E.left}px`,d.style.top=`${S.clientY-E.top}px`,d.style.transform=`translate(${C}, ${M})`,d.style.display="",u){u.replaceChildren();for(let T of W){let $=document.createElementNS(se,"circle");$.setAttribute("cx",String(T.x)),$.setAttribute("cy",String(T.y)),$.setAttribute("r",String(h)),$.setAttribute("fill","#ffffff"),$.setAttribute("stroke",we(T.series)),$.setAttribute("stroke-width","2"),$.setAttribute("class",`${l}__dot`),u.appendChild($);}}},y=()=>{d.style.display="none",m();};n.addEventListener("mousemove",p),n.addEventListener("mouseleave",y);let b=false;return ()=>{b||(b=true,n.removeEventListener("mousemove",p),n.removeEventListener("mouseleave",y),d.remove(),u&&u.remove());}}function $e(r,t={}){let e=typeof r=="string"?document.querySelector(r):r;if(!e)throw new Error(`mount: target ${typeof r=="string"?`'${r}'`:""} not found`);let{tooltip:n,...s}=t,i=s.width??e.clientWidth??800,o=s.height??350,a=new Z({...s,width:i,height:o}),{content:h}=new X().render(a.renderCommands());e.innerHTML=h;let l=e.querySelector("svg");return l&&(l.setAttribute("viewBox",`0 0 ${i} ${a.getHeight()}`),l.setAttribute("width","100%"),l.setAttribute("height",String(a.getHeight()))),n?.show&&ot(e,a,n),a}var gt=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,s){return typeof t=="object"?this._opts.margin=t:this._opts.margin={top:t,right:e??0,bottom:n??0,left:s??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={}),this._opts.axes.y||(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 Z(this.toOptions())}getSvg(){let t=this.build(),{content:e}=new X().render(t.renderCommands());return e}mount(t){let e=typeof t=="string"?document.querySelector(t):t;if(!e)throw new Error(`GraphBuilder.mount: target ${typeof t=="string"?`'${t}'`:""} not found`);this._opts.width||(this._opts.width=e.clientWidth||800);let n=this.build(),{content:s}=new X().render(n.renderCommands());e.innerHTML=s;let i=e.querySelector("svg");if(i){let o=this._opts.width??800;i.setAttribute("viewBox",`0 0 ${o} ${n.getHeight()}`),i.setAttribute("width","100%"),i.setAttribute("height",String(n.getHeight()));}return this._tooltip?.show&&ot(e,n,this._tooltip),n}};var yt=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 s=0;s<n;s++)this._series.data.push({time:t[s],value:e[s]});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={}),!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={}),this._series.style.line={color:t,width:e,style:n},this}setSmoothing(t){return this._series.style||(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={}),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 bt=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 xt=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 St=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 _t=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 kt=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}},wt=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,s){return this._item.label=t,e!==void 0&&(this._item.labelFontSize=e),n!==void 0&&(this._item.labelFill=n),s!==void 0&&(this._item.labelBaseline=s),this}build(){return this._item}};function Ae(r){let{thresholds:t,colors:e,hatches:n}=r;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((i,o)=>{let a=n?.[o],h=a?{color:i,hatch:a}:i;return o===0?{to:{threshold:t[0]},fill:h}:o===e.length-1?{from:{threshold:t[t.length-1]},fill:h}:{from:{threshold:t[o-1]},to:{threshold:t[o]},fill:h}})}}function Bt(r){if(!r||typeof r!="object")throw new Error("DataPoint: object expected");let{time:t,value:e,annotation:n}=r;if(typeof t!="number"||isNaN(t))throw new Error(`DataPoint: invalid time=${t}`);if(e!==null&&(typeof e!="number"||isNaN(e)))throw new Error(`DataPoint: invalid value=${e}`);return {time:t,value:e,annotation:n&&typeof n=="string"?n:void 0}}function Me(r){if(Array.isArray(r))return r.map(Bt);if(r&&typeof r=="object"){let t=r,e=t.name,n=t.data,s=t.sensorType,i=t.enumMap,o=t.color,a=t.lineWidth,h=t.smoothing,l=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 d=o!==void 0||a!==void 0||h!==void 0?{color:o,width:a,smoothing:h}:void 0;return {name:e,data:n.map(Bt),sensorType:s??"numeric",enumMap:i,seriesType:l,...d&&{style:{line:d}}}}throw new Error("parseSeries: object or DataPoint[] expected")}function Le(r){if(!r||typeof r!="object")throw new Error("parseAggregated: object expected");let t=r,e=t.name,n=t.data,s=t.showAs,i=t.avgLine,o=t.countOpacity,a=t.color;if(!e||!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:De(n),showAs:s,avgLine:i,countOpacity:o,...a!==void 0&&{style:{line:{color:a},fill:a}}}}function De(r){let t=e=>typeof e=="number"?e:null;return r.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}})}var vt={...c};function Pe(r){vt={...vt,...r};}function Be(){return vt}function Fe(){vt={...c};}/*!
46
+ </g>`}_esc(t){return t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}};function Le(i){return typeof requestAnimationFrame=="function"?requestAnimationFrame(i):setTimeout(()=>i(0),16)}function De(i){typeof cancelAnimationFrame=="function"?cancelAnimationFrame(i):clearTimeout(i);}function he(){let i=0,t=false;return {schedule:e=>{t||(t=true,i=Le(()=>{t=false,e();}));},cancel:()=>{t&&(t=false,De(i));}}}var de="http://www.w3.org/2000/svg";function Pe(i){let t=i.style?.line;return t&&!Array.isArray(t)&&t.color?t.color:p.stroke}function me(i){return i.replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[t])}function Be(i){if(i.length===0)return "";let t=new Date(i[0].time).toLocaleString(),e=i.map(n=>`<div><span class="mlc-tooltip__name">${me(n.series.name)}:</span> ${n.value.toFixed(2)}</div>`);return `<div class="mlc-tooltip__time">${me(t)}</div>${e.join("")}`}function Fe(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 o=i[Math.max(0,e-1)],r=i[e];return Math.abs(o.time-t)<=Math.abs(r.time-t)?o:r}function je(i){return "value"in i?i.value:i.avg}function st(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 o=e.format??Be,r=e.snapRadius??1/0,s=e.className??"mlc-tooltip",a=e.showPicks??true,h=e.pickRadius??5,l=e.picksClassName??"mlc-tooltip-picks",d=document.createElement("div");d.className=s,d.style.position="absolute",d.style.pointerEvents="none",d.style.display="none",getComputedStyle(i).position==="static"&&(i.style.position="relative"),i.appendChild(d);let u=null;a&&(u=document.createElementNS(de,"g"),u.setAttribute("class",l),u.setAttribute("pointer-events","none"),n.appendChild(u));let m=()=>{u&&u.replaceChildren();},c=t.series.map((P,L)=>({data:P.data.map(B=>({time:B.time,value:je(B)})).filter(B=>B.value!==null).sort((B,E)=>B.time-E.time),series:P,index:L})),f=he(),y=null,b=P=>{let L=n.getBoundingClientRect(),I=t.getWidth?.()??L.width,B=(P.clientX-L.left)*I/Math.max(1,L.width);t.getHeight?.()??L.height;let G=t.invertTime(B);if(!Number.isFinite(G)){d.style.display="none";return}let x=[];for(let F of c){let C=Fe(F.data,G);if(!C)continue;let W=t.project(C.time,C.value,F.series.yAxisIndex??0).x,j=t.project(C.time,C.value,F.series.yAxisIndex??0).y;Math.abs(W-B)>r||x.push({seriesIndex:F.index,series:F.series,time:C.time,value:C.value,x:W,y:j});}if(x.length===0){d.style.display="none",m();return}d.innerHTML=o(x);let w=i.getBoundingClientRect(),k=12,$=(P.clientX-L.left)/Math.max(1,L.width),H=(P.clientY-L.top)/Math.max(1,L.height),O=$<.5?`${k}px`:`calc(-100% - ${k}px)`,Y=H<.5?`${k}px`:`calc(-100% - ${k}px)`;if(d.style.left=`${P.clientX-w.left}px`,d.style.top=`${P.clientY-w.top}px`,d.style.transform=`translate(${O}, ${Y})`,d.style.display="",u){u.replaceChildren();for(let F of x){let C=document.createElementNS(de,"circle");C.setAttribute("cx",String(F.x)),C.setAttribute("cy",String(F.y)),C.setAttribute("r",String(h)),C.setAttribute("fill","#ffffff"),C.setAttribute("stroke",Pe(F.series)),C.setAttribute("stroke-width","2"),C.setAttribute("class",`${l}__dot`),u.appendChild(C);}}},_=P=>{y=P,f.schedule(()=>{y&&b(y);});},T=()=>{y=null,f.cancel(),d.style.display="none",m();};n.addEventListener("mousemove",_),n.addEventListener("mouseleave",T);let N=false;return ()=>{N||(N=true,y=null,f.cancel(),n.removeEventListener("mousemove",_),n.removeEventListener("mouseleave",T),d.remove(),u&&u.remove());}}function He(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,...o}=t,r=o.width??e.clientWidth??800,s=o.height??350,a=new K({...o,width:r,height:s}),{content:h}=new q().render(a.renderCommands());e.innerHTML=h;let l=e.querySelector("svg");return l&&(l.setAttribute("viewBox",`0 0 ${r} ${a.getHeight()}`),l.setAttribute("width","100%"),l.setAttribute("height",String(a.getHeight()))),n?.show&&st(e,a,n),a}var gt=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,o){return typeof t=="object"?this._opts.margin=t:this._opts.margin={top:t,right:e??0,bottom:n??0,left:o??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:o}=new q().render(n.renderCommands());e.innerHTML=o;let r=e.querySelector("svg");if(r){let s=this._opts.width??800;r.setAttribute("viewBox",`0 0 ${s} ${n.getHeight()}`),r.setAttribute("width","100%"),r.setAttribute("height",String(n.getHeight()));}return this._tooltip?.show&&st(e,n,this._tooltip),n}};var yt=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 o=0;o<n;o++)this._series.data.push({time:t[o],value:e[o]});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 bt=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 xt=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 St=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 _t=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 vt=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}},wt=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,o){return this._item.label=t,e!==void 0&&(this._item.labelFontSize=e),n!==void 0&&(this._item.labelFill=n),o!==void 0&&(this._item.labelBaseline=o),this}build(){return this._item}};function Oe(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((r,s)=>{let a=n?.[s],h=a?{color:r,hatch:a}:r;return s===0?{to:{threshold:t[0]},fill:h}:s===e.length-1?{from:{threshold:t[t.length-1]},fill:h}:{from:{threshold:t[s-1]},to:{threshold:t[s]},fill:h}})}}function Ft(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 We(i){if(Array.isArray(i))return i.map(Ft);if(i&&typeof i=="object"){let t=i,e=t.name,n=t.data,o=t.sensorType,r=t.enumMap,s=t.color,a=t.lineWidth,h=t.smoothing,l=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 d=s!==void 0||a!==void 0||h!==void 0?{color:s,width:a,smoothing:h}:void 0;return {name:e,data:n.map(Ft),sensorType:o??"numeric",enumMap:r,seriesType:l,...d&&{style:{line:d}}}}throw new Error("parseSeries: object or DataPoint[] expected")}function Re(i){if(!i||typeof i!="object")throw new Error("parseAggregated: object expected");let t=i,e=t.name,n=t.data,o=t.showAs,r=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:Ie(n),showAs:o,avgLine:r,countOpacity:s,...a!==void 0&&{style:{line:{color:a},fill:a}}}}function Ie(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}})}var kt={...p};function Ge(i){kt={...kt,...i};}function Ee(){return kt}function Ve(){kt={...p};}/*!
51
47
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
52
48
  * MIT with Attribution: free use incl. commercial requires visible credit to
53
49
  * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
@@ -66,4 +62,4 @@ ${e}
66
62
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
67
63
  * MIT with Attribution: free use incl. commercial must have visible credit to
68
64
  * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
69
- */export{kt as AnnotationBandBuilder,wt as AnnotationBandItemBuilder,_t as AnnotationBuilder,gt as GraphBuilder,St as HighlightBuilder,Z as MLTimeGraph,xt as MarkerBuilder,X as SVGRenderer,bt as ThresholdBuilder,yt as TimeSeriesBuilder,ot as attachTooltip,Ae as fillBetweenThresholds,Be as getDefaultTheme,$e as mount,Le as parseAggregated,Bt as parseDataPoint,Me as parseSeries,Fe as resetDefaultTheme,Pe as setDefaultTheme};
65
+ */export{vt as AnnotationBandBuilder,wt as AnnotationBandItemBuilder,_t as AnnotationBuilder,gt as GraphBuilder,St as HighlightBuilder,K as MLTimeGraph,xt as MarkerBuilder,q as SVGRenderer,bt as ThresholdBuilder,yt as TimeSeriesBuilder,st as attachTooltip,Oe as fillBetweenThresholds,Ee as getDefaultTheme,He as mount,Re as parseAggregated,Ft as parseDataPoint,We as parseSeries,Ve as resetDefaultTheme,Ge as setDefaultTheme};
@@ -1,4 +1,4 @@
1
- import { k as DataPoint, o as DrawCommand, ad as TimeScale, V as LinearScale } from '../scale-DFyECKZq.js';
1
+ import { l as DataPoint, D as DrawCommand, d as TimeScale, e as LinearScale } from '../scale-CWAa8-uO.js';
2
2
 
3
3
  /*!
4
4
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
@@ -26,7 +26,7 @@ interface ZoomState {
26
26
  /** Handles mouse/trackpad zoom and pan, with clamping to original data domain. */
27
27
  declare class Zoom {
28
28
  private readonly _config;
29
- private _state;
29
+ private readonly _state;
30
30
  constructor(initialDomain: [number, number], config?: ZoomConfig);
31
31
  get state(): ZoomState;
32
32
  applyZoom(x: number, delta: number, rangeWidth: number): void;
@@ -1,5 +1,5 @@
1
- var f=class{#t;#e;constructor(t){this.#t=[...t.domain],this.#e=[...t.range];}map(t){let n=Number(t),[o,i]=this.#t,[a,r]=this.#e;return i===o?a:a+(n-o)/(i-o)*(r-a)}invert(t){let[n,o]=this.#t,[i,a]=this.#e;return a===i?n:n+(t-i)/(a-i)*(o-n)}domain(){return [...this.#t]}range(){return [...this.#e]}},_=[{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}],y=class{#t;#e;constructor(t){this.#t=new f({domain:t.domain,range:t.range}),this.#e=t.locale||(typeof navigator<"u"?navigator.language:"en-US");}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 locale(){return this.#e}tickInterval(t,n=3,o=12){let[i,a]=this.#t.domain(),r=a-i;if(r<=0)return {interval:_[0].ms};let s=r/t,m=_[0].ms;for(let u of _)if(u.ms>=s){m=u.ms;break}let e=m,l=Math.round(r/e);for(;l>o&&e<_[_.length-1].ms;){let u=_.findIndex(d=>d.ms===e);e=_[Math.min(u+1,_.length-1)].ms,l=Math.round(r/e);}for(;l<n&&e>_[0].ms;){let u=_.findIndex(d=>d.ms===e);e=_[Math.max(u-1,0)].ms,l=Math.round(r/e);}return {interval:e}}ticks(t){let n=t?.minTicks??5,o=t?.maxTicks??12,{interval:i}=this.tickInterval((n+o)/2,n,o),[a,r]=this.#t.domain(),s=[],m=Math.ceil(a/i)*i;for(let e=m;e<=r;e+=i)s.push(e);return s}format(t,n){return new Intl.DateTimeFormat(this.#e,n).format(new Date(t))}};var S=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 i=1+Math.sign(n)*this._config.zoomSpeed;if(i<=0)return;let[a,r]=this._state.domain,s=r-a,m=t/o,e=s/i,l=this._config.minDomainMs??0,u=this._config.maxDomainMs??1/0;e<l&&(e=l),e>u&&(e=u);let d=a+s*m,b=d-e*m,p=d+e*(1-m),[h,c]=this._state.originalDomain;p-b>c-h?(b=h,p=c,e=c-h):(b<h&&(p=c-(c-h)*((p-b)/(c-h)),b=h),p>c&&(b=h+(c-h)*((b-h)/(c-h)),p=c)),this._state.domain=[b,p],this._state.scale=(r-a)/e;}applyPan(t,n){if(!this._config.enabled)return;let[o,i]=this._state.domain,a=i-o,[r,s]=this._state.originalDomain,m=-(t/n)*a,e=o+m,l=i+m;e<r&&(m-=e-r),l>s&&(m-=l-s),this._state.domain=[o+m,i+m];}reset(){this._state.domain=[...this._state.originalDomain],this._state.scale=1,this._state.offset=0;}get enabled(){return this._config.enabled??true}};var g={tooltipBg:"#fff",tooltipBorder:"#cbd5e1",tooltipText:"#1e293b",tooltipSnapRadius:20,minimapStroke:"#94a3b8",minimapBg:"#f8f9fa",minimapBrush:"#3b82f644"};var C=class{_data;_width;_height;_x;_y;_zoom;_stroke;_bgColor;_brushColor;constructor(t){this._data=t.data,this._width=t.width,this._height=t.height,this._x=t.x,this._y=t.y,this._zoom=t.zoom,this._stroke=t.stroke??g.minimapStroke,this._bgColor=t.bgColor??g.minimapBg,this._brushColor=t.brushColor??g.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),i=[Math.min(...n),Math.max(...n)],a=[Math.min(...o),Math.max(...o)],r=new y({domain:i,range:[0,this._width]}),s=new f({domain:a,range:[this._height,0]});t.push({type:"rect",x:this._x,y:this._y,w:this._width,h:this._height,fill:this._bgColor});let m=this._data.map(e=>({x:this._x+r.map(e.time),y:this._y+s.map(e.value)}));if(t.push({type:"path",points:m,smoothing:false,stroke:this._stroke,strokeWidth:1}),this._zoom){let e=this._zoom.state,l=this._x+r.map(e.domain[0]),u=this._x+r.map(e.domain[1]),d=Math.max(2,u-l);t.push({type:"rect",x:l,y:this._y,w:d,h:this._height,fill:this._brushColor});}return t}navigateTo(t){let n=this._data.map(r=>r.time),o=[Math.min(...n),Math.max(...n)],i=new y({domain:o,range:[0,this._width]}),a=t-this._x;return i.invert(a)}};var v=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??g.tooltipSnapRadius,this._bgColor=t.bgColor??g.tooltipBg,this._borderColor=t.borderColor??g.tooltipBorder,this._textColor=t.textColor??g.tooltipText;}compute(){this._timeScale.invert(this._mouseX);let n=[...this._data].filter(p=>p.value!==null).sort((p,h)=>p.time-h.time),o,i=1/0;for(let p of n){let h=this._timeScale.map(p.time),c=Math.abs(this._mouseX-h);c<i&&(i=c,o=p);}if(!o||i>this._snapRadius)return {visible:false,commands:[]};let a=this._timeScale.map(o.time),r=this._valueScale.map(o.value),s=[];s.push({type:"line",x1:a,y1:this._yRange[0],x2:a,y2:this._yRange[1],stroke:"#94a3b8",strokeWidth:1}),s.push({type:"line",x1:this._xRange[0],y1:r,x2:this._xRange[1],y2:r,stroke:"#94a3b8",strokeWidth:1}),s.push({type:"circle",cx:a,cy:r,r:5,fill:"#3b82f6"});let m=new Date(o.time).toLocaleString(),e=o.value.toFixed(2),l=120,u=44,d=a+12,b=r-u-4;return d+l>this._xRange[1]&&(d=a-l-12),b<this._yRange[0]&&(b=r+12),s.push({type:"rect",x:d,y:b,w:l,h:u,fill:this._bgColor,stroke:this._borderColor,strokeWidth:1}),s.push({type:"text",content:m,x:d+8,y:b+16,fontSize:10,fill:this._textColor}),s.push({type:"text",content:`Value: ${e}`,x:d+8,y:b+32,fontSize:11,fill:"#3b82f6"}),{visible:true,commands:s,dataPoint:o,snapX:a}}};/*!
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,r){if(!this._config.enabled)return;let o=1+Math.sign(n)*this._config.zoomSpeed;if(o<=0)return;let[i,a]=this._state.domain,h=a-i,s=t/r,e=h/o,l=this._config.minDomainMs??0,m=this._config.maxDomainMs??1/0;e<l&&(e=l),e>m&&(e=m);let d=i+h*s,u=d-e*s,c=d+e*(1-s),[b,g]=this._state.originalDomain;c-u>g-b?(u=b,c=g,e=g-b):(u<b&&(c=g-(g-b)*((c-u)/(g-b)),u=b),c>g&&(u=b+(g-b)*((u-b)/(g-b)),c=g)),this._state.domain=[u,c],this._state.scale=(a-i)/e;}applyPan(t,n){if(!this._config.enabled)return;let[r,o]=this._state.domain,i=o-r,[a,h]=this._state.originalDomain,s=-(t/n)*i,e=r+s,l=o+s;e<a&&(s-=e-a),l>h&&(s-=l-h),this._state.domain=[r+s,o+s];}reset(){this._state.domain=[...this._state.originalDomain],this._state.scale=1,this._state.offset=0;}get enabled(){return this._config.enabled??true}};var k=new Map;function T(p,t){return `${p}|${JSON.stringify(t??{})}`}function w(p,t){let n=T(p,t),r=k.get(n);return r||(r=new Intl.DateTimeFormat(p,t),k.set(n,r)),r}var y=class{#t;#e;constructor(t){this.#t=[...t.domain],this.#e=[...t.range];}map(t){let n=Number(t),[r,o]=this.#t,[i,a]=this.#e;return o===r?i:i+(n-r)/(o-r)*(a-i)}invert(t){let[n,r]=this.#t,[o,i]=this.#e;return i===o?n:n+(t-o)/(i-o)*(r-n)}domain(){return [...this.#t]}range(){return [...this.#e]}},_=[{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;constructor(t){this.#t=new y({domain:t.domain,range:t.range}),this.#e=t.locale||(typeof navigator<"u"?navigator.language:"en-US");}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 locale(){return this.#e}tickInterval(t,n=3,r=12){let[o,i]=this.#t.domain(),a=i-o;if(a<=0)return {interval:_[0].ms};let h=a/t,s=_[0].ms;for(let m of _)if(m.ms>=h){s=m.ms;break}let e=s,l=Math.round(a/e);for(;l>r&&e<_[_.length-1].ms;){let m=_.findIndex(d=>d.ms===e);e=_[Math.min(m+1,_.length-1)].ms,l=Math.round(a/e);}for(;l<n&&e>_[0].ms;){let m=_.findIndex(d=>d.ms===e);e=_[Math.max(m-1,0)].ms,l=Math.round(a/e);}return {interval:e}}ticks(t){let n=t?.minTicks??5,r=t?.maxTicks??12,{interval:o}=this.tickInterval((n+r)/2,n,r),[i,a]=this.#t.domain(),h=[],s=Math.ceil(i/o)*o;for(let e=s;e<=a;e+=o)h.push(e);return h}format(t,n){return w(this.#e,n).format(new Date(t))}};function S(p){let t=1/0,n=-1/0;for(let r=0;r<p.length;r++){let o=p[r];o<t&&(t=o),o>n&&(n=o);}return [t,n]}var f={tooltipBg:"#fff",tooltipBorder:"#cbd5e1",tooltipText:"#1e293b",tooltipSnapRadius:20,minimapStroke:"#94a3b8",minimapBg:"#f8f9fa",minimapBrush:"#3b82f644"};var v=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),r=this._data.map(e=>e.value).filter(e=>e!==null),o=S(n),i=S(r),a=new x({domain:o,range:[0,this._width]}),h=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+h.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]),d=Math.max(2,m-l);t.push({type:"rect",x:l,y:this._y,w:d,h:this._height,fill:this._brushColor});}return t}navigateTo(t){let n=this._data.map(a=>a.time),r=S(n),o=new x({domain:r,range:[0,this._width]}),i=t-this._x;return o.invert(i)}};var D=class{_mouseX;_mouseY;_timeScale;_valueScale;_data;_xRange;_yRange;_snapRadius;_bgColor;_borderColor;_textColor;constructor(t){this._mouseX=t.mouseX,this._mouseY=t.mouseY,this._timeScale=t.timeScale,this._valueScale=t.valueScale,this._data=t.data,this._xRange=t.xRange,this._yRange=t.yRange,this._snapRadius=t.snapRadius??f.tooltipSnapRadius,this._bgColor=t.bgColor??f.tooltipBg,this._borderColor=t.borderColor??f.tooltipBorder,this._textColor=t.textColor??f.tooltipText;}compute(){let t=[...this._data].filter(u=>u.value!==null).sort((u,c)=>u.time-c.time),n,r=1/0;for(let u of t){let c=this._timeScale.map(u.time),b=Math.abs(this._mouseX-c);b<r&&(r=b,n=u);}if(!n||r>this._snapRadius)return {visible:false,commands:[]};let o=this._timeScale.map(n.time),i=this._valueScale.map(n.value),a=[];a.push({type:"line",x1:o,y1:this._yRange[0],x2:o,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:o,cy:i,r:5,fill:"#3b82f6"});let h=new Date(n.time).toLocaleString(),s=n.value.toFixed(2),e=120,l=44,m=o+12,d=i-l-4;return m+e>this._xRange[1]&&(m=o-e-12),d<this._yRange[0]&&(d=i+12),a.push({type:"rect",x:m,y:d,w:e,h:l,fill:this._bgColor,stroke:this._borderColor,strokeWidth:1},{type:"text",content:h,x:m+8,y:d+16,fontSize:10,fill:this._textColor},{type:"text",content:`Value: ${s}`,x:m+8,y:d+32,fontSize:11,fill:"#3b82f6"}),{visible:true,commands:a,dataPoint:n,snapX:o}}};/*!
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.
5
- */export{C as Minimap,v as Tooltip,S as Zoom};
5
+ */export{v as Minimap,D as Tooltip,C as Zoom};
@@ -1,7 +1,7 @@
1
- import { M as Marker } from './layout-C_t250fG.js';
2
- export { L as Layout, a as LayoutConfig, b as LayoutResult, c as LegendConfig, d as LegendItem, e as LegendOrientation, f as Renderer, m as measureLegend, r as renderLegend, t as theme } from './layout-C_t250fG.js';
3
- import { A as AggregatedPoint, ad as TimeScale, V as LinearScale, _ as PointStyleType, o as DrawCommand, k as DataPoint, aa as Threshold, I as Gap, O as HatchVariant, P as Highlight, d as Annotation, E as EnumMap, B as BandScale, Z as Point, f as AnnotationBandItem, U as LineVariant, G as FillSpec, M as GapStyle, af as TimeSeries } from './scale-DFyECKZq.js';
4
- export { h as AxisOrientation, i as AxisPosition, j as BandScaleConfig, C as CircleParams, D as Dashstyle_t, m as DomainScaleConfig, n as DrawCircle, p as DrawGap, q as DrawGapType_t, r as DrawGradient, s as DrawGroup, t as DrawLine, u as DrawPath, v as DrawRect, w as DrawText, Q as LabelAnchor, S as LineParams, W as LinearScaleConfig, Y as PathParams, $ as RectParams, a0 as Scale, a1 as ScaleConfig, a8 as TIME_INTERVALS, a9 as TextParams, ae as TimeScaleConfig, ag as getHatch } from './scale-DFyECKZq.js';
1
+ import { M as Marker } from './layout-CXwTQBSN.js';
2
+ export { d as Layout, e as LayoutConfig, b as LayoutResult, f as LegendConfig, a as LegendItem, L as LegendOrientation, R as Renderer, m as measureLegend, r as renderLegend, t as theme } from './layout-CXwTQBSN.js';
3
+ import { j as AggregatedPoint, d as TimeScale, e as LinearScale, P as PointStyleType, D as DrawCommand, l as DataPoint, T as Threshold, G as Gap, g as HatchVariant, H as Highlight, b as Annotation, E as EnumMap, O as BandScale, Q as Point, i as AnnotationBandItem, L as LineVariant, F as FillSpec, x as GapStyle, f as TimeSeries } from './scale-CWAa8-uO.js';
4
+ export { R as AxisOrientation, U as AxisPosition, V as BandScaleConfig, W as CircleParams, X as Dashstyle_t, Y as DomainScaleConfig, Z as DrawCircle, _ as DrawGap, $ as DrawGapType_t, a0 as DrawGradient, a1 as DrawGroup, a2 as DrawLine, a3 as DrawPath, a4 as DrawRect, a5 as DrawText, a6 as LabelAnchor, a7 as LineParams, a8 as LinearScaleConfig, a9 as PathParams, aa as RectParams, ab as Scale, ac as ScaleConfig, ad as TIME_INTERVALS, ae as TextParams, af as TimeScaleConfig, ag as getHatch } from './scale-CWAa8-uO.js';
5
5
 
6
6
  /*!
7
7
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
@@ -56,7 +56,6 @@ declare function renderLine(segments: {
56
56
  data: DataPoint[];
57
57
  color?: string;
58
58
  }[], ctx: RenderingContext, style: SeriesStyle): DrawCommand[];
59
- /** Render segments as step-functions. */
60
59
  declare function renderStep(segments: {
61
60
  data: DataPoint[];
62
61
  color?: string;
@@ -70,7 +69,9 @@ declare function renderArea(segments: {
70
69
  * Complex area renderer that splits a run by value boundaries (thresholds)
71
70
  * and renders the resulting zones as separate filled areas.
72
71
  */
73
- declare function renderZonedArea<T>(run: T[], ctx: RenderingContext, options: {
72
+ declare function renderZonedArea<T extends {
73
+ time: number;
74
+ }>(run: T[], ctx: RenderingContext, options: {
74
75
  boundaries: number[];
75
76
  yLow: (p: T) => number;
76
77
  yHigh: (p: T) => number;
@@ -272,7 +273,8 @@ interface AxisColorspec {
272
273
  tickColor: string;
273
274
  textColor: string;
274
275
  textSize: number;
275
- /** Optional stroke-width for the axis baseline + tick marks (px). Default: SVG default (1). */
276
+ /** Stroke-width for the axis baseline + tick marks (px). MLTimeGraph fills
277
+ * in 1 when `axes.*.axis.width` is unset, matching the Go port. */
276
278
  axisWidth?: number;
277
279
  }
278
280
 
@@ -721,11 +723,6 @@ declare class StatsOverlay {
721
723
  render(): DrawCommand[];
722
724
  }
723
725
 
724
- /*!
725
- * MLTimeGraph — Copyright (c) 2026 Michael Lechner
726
- * MIT with Attribution: free use incl. commercial requires visible credit to
727
- * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
728
- */
729
726
  /**
730
727
  * Time formatter with i18n support.
731
728
  * Uses Intl.DateTimeFormat with locale fallback.
package/dist/internals.js CHANGED
@@ -1,34 +1,30 @@
1
- var V=class{};var x=class{static interpolateDataPoint(a,e,t){return {time:a.time+t*(e.time-a.time),value:(a.value??0)+t*((e.value??0)-(a.value??0))}}static interpolateAggregatedPoint(a,e,t){let r=(o,n)=>o!==null&&n!==null?o+t*(n-o):null;return {time:a.time+t*(e.time-a.time),min:r(a.min,e.min),max:r(a.max,e.max),avg:r(a.avg,e.avg),count:Math.round(a.count+t*(e.count-a.count))}}static getRuns(a,e,t=0){let r=[...a].sort((m,s)=>m.time-s.time),o=[],n=[],i=null;for(let m of r){let s=e(m),l=t>0&&i&&m.time-i.time>t;(s||l)&&n.length&&(o.push(n),n=[]),s||n.push(m),i=m;}return n.length&&o.push(n),o}static splitByBoundaries(a,e,t,r){if(a.length===0)return [];if(e.length===0)return [{data:a,zoneIndex:0}];let o=[...e].sort((s,l)=>s-l),n=[],i=s=>{let l=0;for(let u=0;u<o.length&&s>=o[u];u++)l=u+1;return l},m=[a[0]];for(let s=1;s<a.length;s++){let l=a[s-1],u=a[s],d=t(l),c=t(u),f;c>d?f=o.filter(p=>p>d&&p<=c):c<d?f=o.filter(p=>p>=c&&p<d).reverse():f=[];for(let p of f){let b=(p-d)/(c-d),y=r(l,u,b);m.push(y),n.push({data:m,zoneIndex:i((d+p)/2)}),m=[y];}m.push(u);}if(m.length>0){let s=t(m[0]),l=t(m[m.length-1]);n.push({data:m,zoneIndex:i((s+l)/2)});}return n}static splitByThreshold(a,e,t,r){let o=this.splitByBoundaries(a,[e],t,r),n={above:[],below:[]};for(let i of o)i.zoneIndex===0?n.below.push(i.data):n.above.push(i.data);return n}};var me=class{static compute(a){let e=a.map(m=>m.value).filter(m=>m!==null).sort((m,s)=>m-s);if(e.length===0)return {min:NaN,max:NaN,avg:NaN,mean:NaN,median:NaN,stdDev:NaN,count:0};let t=e.length,r=e.reduce((m,s)=>m+s,0)/t,o=t%2===1?e[Math.floor(t/2)]:(e[t/2-1]+e[t/2])/2,n=e.reduce((m,s)=>m+Math.pow(s-r,2),0)/t,i=Math.sqrt(n);return {min:e[0],max:e[t-1],avg:r,mean:r,median:o,stdDev:i,count:t}}static computeInRange(a,e,t){let r=a.filter(o=>o.time>=e&&o.time<=t);return this.compute(r)}};var h={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"]};function ue(a,e="classic-diagonal",t="rgba(200, 220, 255, 0.3)",r="#4D88FF",o=2){if(e==="none")return `
1
+ var N=class{};var x=class{static interpolateDataPoint(a,e,t){return {time:a.time+Math.round(t*(e.time-a.time)),value:(a.value??0)+t*((e.value??0)-(a.value??0))}}static interpolateAggregatedPoint(a,e,t){let n=(o,r)=>o!==null&&r!==null?o+t*(r-o):null;return {time:a.time+t*(e.time-a.time),min:n(a.min,e.min),max:n(a.max,e.max),avg:n(a.avg,e.avg),count:Math.round(a.count+t*(e.count-a.count))}}static getRuns(a,e,t=0){let n=[...a].sort((m,s)=>m.time-s.time),o=[],r=[],i=null;for(let m of n){let s=e(m),l=t>0&&i&&m.time-i.time>t;(s||l)&&r.length&&(o.push(r),r=[]),s||r.push(m),i=m;}return r.length&&o.push(r),o}static splitByBoundaries(a,e,t,n){if(a.length===0)return [];if(e.length===0)return [{data:a,zoneIndex:0}];let o=[...e].sort((s,l)=>s-l),r=[],i=s=>{let l=0;for(let u=0;u<o.length&&s>=o[u];u++)l=u+1;return l},m=[a[0]];for(let s=1;s<a.length;s++){let l=a[s-1],u=a[s],c=t(l),d=t(u),p;d>c?p=o.filter(f=>f>c&&f<=d):d<c?p=o.filter(f=>f>=d&&f<c).reverse():p=[];for(let f of p){let g=(f-c)/(d-c),b=n(l,u,g);m.push(b),r.push({data:m,zoneIndex:i((c+f)/2)}),m=[b];}m.push(u);}if(m.length>0){let s=t(m[0]),l=t(m[m.length-1]);r.push({data:m,zoneIndex:i((s+l)/2)});}return r}static splitByThreshold(a,e,t,n){let o=this.splitByBoundaries(a,[e],t,n),r={above:[],below:[]};for(let i of o)i.zoneIndex===0?r.below.push(i.data):r.above.push(i.data);return r}};var ce=class{static compute(a){let e=a.map(m=>m.value).filter(m=>m!==null).sort((m,s)=>m-s);if(e.length===0)return {min:NaN,max:NaN,avg:NaN,mean:NaN,median:NaN,stdDev:NaN,count:0};let t=e.length,n=e.reduce((m,s)=>m+s,0)/t,o=t%2===1?e[Math.floor(t/2)]:(e[t/2-1]+e[t/2])/2,r=e.reduce((m,s)=>m+Math.pow(s-n,2),0)/t,i=Math.sqrt(r);return {min:e[0],max:e[t-1],avg:n,mean:n,median:o,stdDev:i,count:t}}static computeInRange(a,e,t){let n=a.filter(o=>o.time>=e&&o.time<=t);return this.compute(n)}};var h={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"]};function de(a,e="classic-diagonal",t="rgba(200, 220, 255, 0.3)",n="#4D88FF",o=2){if(e==="none")return `
2
2
  <pattern id="${a}" width="10" height="10" patternUnits="userSpaceOnUse">
3
3
  <rect width="10" height="10" fill="${t}" />
4
4
  </pattern>
5
- `.trim();let n=12,i=12,m="rotate(0)",s="";switch(e){case "classic-diagonal":n=12,i=12,m="rotate(45)",s=`<line x1="0" y1="0" x2="0" y2="${i}" stroke="${r}" stroke-width="${o}" stroke-linecap="square" />`;break;case "dense-steep":n=6,i=6,m="rotate(30)",s=`<line x1="0" y1="0" x2="0" y2="${i}" stroke="${r}" stroke-width="${o}" stroke-linecap="square" />`;break;case "crosshatch":n=14,i=14,m="rotate(45)",s=`
6
- <line x1="0" y1="0" x2="0" y2="${i}" stroke="${r}" stroke-width="${o}" stroke-linecap="square" />
7
- <line x1="0" y1="0" x2="${n}" y2="0" stroke="${r}" stroke-width="${o}" stroke-linecap="square" />
8
- `;break;case "dots":n=12,i=12,s=`<circle cx="${n/2}" cy="${i/2}" r="${o*1.2}" fill="${r}" />`;break;case "waves":n=16,i=16,s=`
9
- <path d="M 0 ${i/2} Q ${n/4} 0, ${n/2} ${i/2} T ${n} ${i/2}"
10
- fill="none" stroke="${r}" stroke-width="${o}" stroke-linecap="round" />
11
- `;break;case "dashed":n=12,i=12,m="rotate(45)",s=`<line x1="0" y1="0" x2="0" y2="${i}" stroke="${r}" stroke-width="${o}" stroke-dasharray="3,3" />`;break;case "herringbone":n=16,i=16,s=`
12
- <path d="M 0 0 L ${n/2} ${i/2} L 0 ${i} M ${n} 0 L ${n/2} ${i/2} L ${n} ${i}"
13
- fill="none" stroke="${r}" stroke-width="${o}" stroke-linejoin="round" stroke-linecap="round" />
14
- `;break;case "brick":n=20,i=20,s=`
15
- <path d="M 0 ${i/2} L ${n} ${i/2} M 0 ${i} L ${n} ${i} M ${n/2} 0 L ${n/2} ${i/2} M 0 ${i/2} L 0 ${i}"
16
- fill="none" stroke="${r}" stroke-width="${o}" />
17
- `;break;case "double-stripe":n=16,i=16,m="rotate(45)",s=`
18
- <line x1="0" y1="0" x2="0" y2="${i}" stroke="${r}" stroke-width="${o}" stroke-linecap="square" />
19
- <line x1="${n/2}" y1="0" x2="${n/2}" y2="${i}" stroke="${r}" stroke-width="${o/2}" stroke-linecap="square" />
20
- `;break;case "honeycomb":n=18,i=32,s=`
21
- <path d="M 0 0 L ${n/2} 5 L ${n} 0 M 0 16 L ${n/2} 11 L ${n} 16 M 0 16 L 0 32 M ${n/2} 5 L ${n/2} 11 M ${n} 16 L ${n} 32 M 0 32 L ${n/2} 27 L ${n} 32 M ${n/2} 27 L ${n/2} 32"
22
- fill="none" stroke="${r}" stroke-width="${o}" stroke-linejoin="round" stroke-linecap="round" />
23
- `;break}let l=`<rect width="${n}" height="${i}" fill="${t}" />`;return `
24
- <pattern id="${a}" width="${n}" height="${i}" patternTransform="${m}" patternUnits="userSpaceOnUse">
5
+ `.trim();let r=12,i=12,m="rotate(0)",s="";switch(e){case "classic-diagonal":r=12,i=12,m="rotate(45)",s=`<line x1="0" y1="0" x2="0" y2="${i}" stroke="${n}" stroke-width="${o}" stroke-linecap="square" />`;break;case "dense-steep":r=6,i=6,m="rotate(30)",s=`<line x1="0" y1="0" x2="0" y2="${i}" stroke="${n}" stroke-width="${o}" stroke-linecap="square" />`;break;case "crosshatch":r=14,i=14,m="rotate(45)",s=`
6
+ <line x1="0" y1="0" x2="0" y2="${i}" stroke="${n}" stroke-width="${o}" stroke-linecap="square" />
7
+ <line x1="0" y1="0" x2="${r}" y2="0" stroke="${n}" stroke-width="${o}" stroke-linecap="square" />
8
+ `;break;case "dots":r=12,i=12,s=`<circle cx="${r/2}" cy="${i/2}" r="${o*1.2}" fill="${n}" />`;break;case "waves":r=16,i=16,s=`
9
+ <path d="M 0 ${i/2} Q ${r/4} 0, ${r/2} ${i/2} T ${r} ${i/2}" fill="none" stroke="${n}" stroke-width="${o}" stroke-linecap="round" />
10
+ `;break;case "dashed":r=12,i=12,m="rotate(45)",s=`<line x1="0" y1="0" x2="0" y2="${i}" stroke="${n}" stroke-width="${o}" stroke-dasharray="3,3" />`;break;case "herringbone":r=16,i=16,s=`
11
+ <path d="M 0 0 L ${r/2} ${i/2} L 0 ${i} M ${r} 0 L ${r/2} ${i/2} L ${r} ${i}" fill="none" stroke="${n}" stroke-width="${o}" stroke-linejoin="round" stroke-linecap="round" />
12
+ `;break;case "brick":r=20,i=20,s=`
13
+ <path d="M 0 ${i/2} L ${r} ${i/2} M 0 ${i} L ${r} ${i} M ${r/2} 0 L ${r/2} ${i/2} M 0 ${i/2} L 0 ${i}" fill="none" stroke="${n}" stroke-width="${o}" />
14
+ `;break;case "double-stripe":r=16,i=16,m="rotate(45)",s=`
15
+ <line x1="0" y1="0" x2="0" y2="${i}" stroke="${n}" stroke-width="${o}" stroke-linecap="square" />
16
+ <line x1="${r/2}" y1="0" x2="${r/2}" y2="${i}" stroke="${n}" stroke-width="${o/2}" stroke-linecap="square" />
17
+ `;break;case "honeycomb":r=18,i=32,s=`
18
+ <path d="M 0 0 L ${r/2} 5 L ${r} 0 M 0 16 L ${r/2} 11 L ${r} 16 M 0 16 L 0 32 M ${r/2} 5 L ${r/2} 11 M ${r} 16 L ${r} 32 M 0 32 L ${r/2} 27 L ${r} 32 M ${r/2} 27 L ${r/2} 32" fill="none" stroke="${n}" stroke-width="${o}" stroke-linejoin="round" stroke-linecap="round" />
19
+ `;break}let l=`<rect width="${r}" height="${i}" fill="${t}" />`;return `
20
+ <pattern id="${a}" width="${r}" height="${i}" patternTransform="${m}" patternUnits="userSpaceOnUse">
25
21
  ${l}
26
22
  ${s}
27
23
  </pattern>
28
- `.trim()}function I(a){return {id:a.id,line:{stroke:a.stroke??h.stroke,strokeWidth:a.strokeWidth??h.strokeWidth,smoothing:a.smoothing??false,dashed:a.dashed??false},fill:a.fill??h.areaFillAlpha,markers:{type:a.pointStyle??"none",size:a.pointSize??h.pointSize,stroke:a.stroke??h.stroke,fill:"#ffffff"},shadow:{color:a.shadowColor??"transparent",blur:a.shadowBlur??0,offsetX:a.shadowOffsetX??0,offsetY:a.shadowOffsetY??0}}}function w(a,e,t){let r=[],o=a.reduce((i,m)=>i+m.data.length,0),n=I(t);for(let i=0;i<a.length;i++){let m=a[i];m.data.length>=2?r.push({type:"path",id:t.id?`${t.id}-line-${i}`:void 0,points:m.data.map(s=>({x:e.timeScale.map(s.time),y:e.valueScale.map(s.value)})),stroke:m.color??n.line.stroke,strokeWidth:n.line.strokeWidth,smoothing:n.line.smoothing,dashed:n.line.dashed,shadowColor:n.shadow.color,shadowBlur:n.shadow.blur,shadowOffsetX:n.shadow.offsetX,shadowOffsetY:n.shadow.offsetY,fill:"none"}):m.data.length===1&&o===1&&r.push({type:"circle",cx:e.timeScale.map(m.data[0].time),cy:e.valueScale.map(m.data[0].value),r:Math.max(n.markers.size,n.line.strokeWidth),fill:m.color??n.line.stroke,shadowColor:n.shadow.color,shadowBlur:n.shadow.blur});}return r}function E(a,e,t){let r=[],o=I(t);for(let n=0;n<a.length;n++){let i=a[n];if(i.data.length<2)continue;let m=[];for(let s=0;s<i.data.length;s++){let l=e.timeScale.map(i.data[s].time),u=e.valueScale.map(i.data[s].value);s===0?m.push({x:l,y:u}):(m.push({x:l,y:m[m.length-1].y}),m.push({x:l,y:u}));}r.push({type:"path",id:t.id?`${t.id}-line-${n}`:void 0,points:m,stroke:i.color??o.line.stroke,strokeWidth:o.line.strokeWidth,smoothing:false,fill:"none"});}return r}function xe(a,e,t,r,o){let n=[],i=I(t);for(let m=0;m<a.length;m++){let s=a[m];if(s.data.length<2)continue;let l=s.data.map(d=>({x:e.timeScale.map(d.time),y:e.valueScale.map(r(d))})),u=s.data.map(d=>({x:e.timeScale.map(d.time),y:e.valueScale.map(o(d))})).reverse();n.push({type:"path",id:t.id?`${t.id}-fill-${m}`:void 0,points:[...l,...u],fill:s.color??i.fill,hatch:t.hatch,stroke:"none"});}return n}function B(a,e,t,r){if(a.length<2)return [];let o=x.splitByBoundaries(a,t.boundaries,t.getValue,t.interpolate),n=[];for(let i=0;i<o.length;i++){let m=o[i];if(m.data.length<2)continue;let s=t.getColor(m.zoneIndex);if(!s)continue;let l=m.data.map(d=>({x:e.timeScale.map(d.time),y:e.valueScale.map(t.yLow(d))})),u=m.data.map(d=>({x:e.timeScale.map(d.time),y:e.valueScale.map(t.yHigh(d))})).reverse();n.push({type:"path",id:r?.id?`${r.id}-fill-${i}`:void 0,points:[...l,...u],fill:s,hatch:t.getHatch?.(m.zoneIndex),stroke:"none"});}return n}function Se(a,e,t,r){let o=x.splitByThreshold(a,e,i=>i.value,x.interpolateDataPoint),n=[];return r.below&&n.push(...w(o.below.map(i=>({data:i})),t,r.below)),r.above&&n.push(...w(o.above.map(i=>({data:i})),t,r.above)),n}function P(a,e,t,r){let o=I(t);if(!o.markers.type||o.markers.type==="none")return [];let n=[];for(let i=0;i<a.length;i++){let m=a[i],s=e.timeScale.map(m.time),l=e.valueScale.map(m.value),u=r(m),d=t.pointStroke??u,c=t.pointFill??u,f=t.pointStrokeWidth??1.5,p=t.id?`${t.id}-marker-${i}`:void 0;ke(n,p,o.markers.type,s,l,o.markers.size,d,c,f);}return n}function ke(a,e,t,r,o,n,i,m,s){switch(t){case "circle":a.push({type:"circle",cx:r,cy:o,r:n,fill:m,stroke:i,strokeWidth:s,id:e});break;case "square":a.push({type:"rect",x:r-n,y:o-n,w:n*2,h:n*2,fill:m,stroke:i,strokeWidth:s,id:e});break;case "cross":a.push({type:"line",x1:r-n,y1:o-n,x2:r+n,y2:o+n,stroke:i,strokeWidth:s,id:e}),a.push({type:"line",x1:r-n,y1:o+n,x2:r+n,y2:o-n,stroke:i,strokeWidth:s,id:e});break;case "diamond":a.push({type:"path",points:[{x:r,y:o-n},{x:r+n,y:o},{x:r,y:o+n},{x:r-n,y:o}],fill:m,stroke:i,strokeWidth:s,id:e});break;case "triangle":a.push({type:"path",points:[{x:r,y:o-n},{x:r+n,y:o+n},{x:r-n,y:o+n}],fill:m,stroke:i,strokeWidth:s,id:e});break;case "star":{let l=[];for(let u=0;u<10;u++){let d=u%2===0?n:n*.5,c=Math.PI/2*3+u*Math.PI/5;l.push({x:r+d*Math.cos(c),y:o+d*Math.sin(c)});}a.push({type:"path",points:l,fill:m,stroke:i,strokeWidth:s,id:e});break}case "arrow":a.push({type:"path",points:[{x:r-n,y:o+n},{x:r,y:o-n},{x:r+n,y:o+n}],stroke:i,strokeWidth:s,fill:"none",id:e});break;default:a.push({type:"circle",cx:r,cy:o,r:n,fill:m,stroke:i,strokeWidth:s,id:e});}}var T=12,H=8,N=20,ve=11,G=18,Y=a=>a.length*ve*.6;function we(a,e="vertical"){if(e==="horizontal"){let r=0;for(let o of a)r+=T+H+Y(o.name)+G;return {width:Math.max(0,r-G),height:N}}let t=0;for(let r of a)t=Math.max(t,Y(r.name));return {width:T+H+t,height:a.length*N}}function Ce(a){let{items:e,x:t,y:r,orientation:o="vertical"}=a,n=[],i=t;return e.forEach((m,s)=>{let l=o==="horizontal"?i:t,u=o==="horizontal"?r:r+s*N;n.push({type:"rect",x:l,y:u,w:T,h:T,fill:m.color,stroke:h.legendStroke,strokeWidth:1}),n.push({type:"text",content:m.name,x:l+T+H,y:u+T-2,fontSize:h.legendFont,fill:h.legendText}),o==="horizontal"&&(i+=T+H+Y(m.name)+G);}),{type:"group",cssClass:"chart-legend",commands:n}}function Te(a){let{xTicks:e,yTicks:t,xRange:r,yRange:o,stroke:n=h.gridStroke,strokeWidth:i=h.gridStrokeWidth,dashed:m=false,opacity:s=h.gridOpacity}=a,l=[];if(t)for(let u of t)l.push({type:"line",x1:r[0],y1:u,x2:r[1],y2:u,stroke:n,strokeWidth:i,dashed:m,opacity:s});if(e)for(let u of e)l.push({type:"line",x1:u,y1:o[0],x2:u,y2:o[1],stroke:n,strokeWidth:i,dashed:m,opacity:s});return l}var L=class{#e;#t;constructor(e){this.#e=[...e.domain],this.#t=[...e.range];}map(e){let t=Number(e),[r,o]=this.#e,[n,i]=this.#t;return o===r?n:n+(t-r)/(o-r)*(i-n)}invert(e){let[t,r]=this.#e,[o,n]=this.#t;return n===o?t:t+(e-o)/(n-o)*(r-t)}domain(){return [...this.#e]}range(){return [...this.#t]}},k=[{label:"second",ms:1e3},{label:"2_seconds",ms:2e3},{label:"5_seconds",ms:5e3},{label:"10_seconds",ms:1e4},{label:"30_seconds",ms:3e4},{label:"minute",ms:6e4},{label:"5_minutes",ms:3e5},{label:"15_minutes",ms:9e5},{label:"30_minutes",ms:18e5},{label:"hour",ms:36e5},{label:"3_hours",ms:108e5},{label:"6_hours",ms:216e5},{label:"day",ms:864e5},{label:"week",ms:6048e5},{label:"month",ms:2592e6},{label:"3_months",ms:7776e6},{label:"6_months",ms:15552e6},{label:"year",ms:31536e6},{label:"2_years",ms:63072e6},{label:"5_years",ms:15768e7}],R=class{#e;#t;constructor(e){this.#e=new L({domain:e.domain,range:e.range}),this.#t=e.locale||(typeof navigator<"u"?navigator.language:"en-US");}map(e){return this.#e.map(Number(e))}invert(e){return this.#e.invert(e)}domain(){return this.#e.domain()}range(){return this.#e.range()}get locale(){return this.#t}tickInterval(e,t=3,r=12){let[o,n]=this.#e.domain(),i=n-o;if(i<=0)return {interval:k[0].ms};let m=i/e,s=k[0].ms;for(let d of k)if(d.ms>=m){s=d.ms;break}let l=s,u=Math.round(i/l);for(;u>r&&l<k[k.length-1].ms;){let d=k.findIndex(c=>c.ms===l);l=k[Math.min(d+1,k.length-1)].ms,u=Math.round(i/l);}for(;u<t&&l>k[0].ms;){let d=k.findIndex(c=>c.ms===l);l=k[Math.max(d-1,0)].ms,u=Math.round(i/l);}return {interval:l}}ticks(e){let t=e?.minTicks??5,r=e?.maxTicks??12,{interval:o}=this.tickInterval((t+r)/2,t,r),[n,i]=this.#e.domain(),m=[],s=Math.ceil(n/o)*o;for(let l=s;l<=i;l+=o)m.push(l);return m}format(e,t){return new Intl.DateTimeFormat(this.#t,t).format(new Date(e))}},A=class{#e;#t;#n;#r;constructor(e){this.#e=[...e.domain],this.#t=[...e.range],this.#n=e.paddingInner??.1,this.#r=e.paddingOuter??.05;}get step(){let[e,t]=this.#t,r=this.#e.length;return r<=1?Math.abs(t-e):Math.abs(t-e)*(1-this.#r*2)/r+Math.abs(t-e)*this.#n*2/r}get bandwidth(){let[e,t]=this.#t,r=this.#e.length;if(r<=1)return Math.abs(t-e)*(1-this.#r*2);let o=this.#r*2*Math.abs(t-e);return (Math.abs(t-e)-o)/r*(1-this.#n)}map(e){let t=this.#e.findIndex(d=>String(d)===String(e));if(t===-1)return this.#t[0];let[r,o]=this.#t,n=this.#e.length;if(n<=1)return (r+o)/2;let i=this.#r*2*Math.abs(o-r),m=Math.abs(o-r)-i,s=o>=r?1:-1,l=m/n;return r+this.#r*Math.abs(o-r)*s+t*l}invert(e){let t=0,r=1/0;for(let o=0;o<this.#e.length;o++){let n=this.map(this.#e[o]),i=Math.abs(e-n);i<r&&(r=i,t=o);}return this.#e[t]}domain(){return this.#e.length===0?["",""]:[this.#e[0],this.#e[this.#e.length-1]]}range(){return [...this.#t]}positions(){let e=new Map;for(let t of this.#e)e.set(t,this.map(t));return e}};function Le(a){return a==="dotted"?{dash:"dotted"}:a==="dashed"?{dash:"dashed"}:{}}function Me(a){let{thresholds:e,valueScale:t,xRange:r}=a,[o,n]=r,[i,m]=t.range(),s=Math.min(i,m),l=Math.max(i,m),u=[],d=[];for(let c of e){let f=c.color??h.thresholdColor,p=t.map(c.value);c.fill==="above"?u.push({type:"rect",x:o,y:s,w:n-o,h:Math.max(0,p-s),fill:f,hatch:c.fillHatch,opacity:c.fillOpacity??.12,id:c.id?`${c.id}-fill`:void 0}):c.fill==="below"&&u.push({type:"rect",x:o,y:p,w:n-o,h:Math.max(0,l-p),fill:f,hatch:c.fillHatch,opacity:c.fillOpacity??.12,id:c.id?`${c.id}-fill`:void 0});let b=c.line??h.thresholdLine;if(b!=="none"){let y=Le(b),g={type:"line",x1:o,y1:p,x2:n,y2:p,stroke:f,strokeWidth:1,...y,id:c.id?`${c.id}-line`:void 0};c.shadowColor&&(g.shadowColor=c.shadowColor,g.shadowBlur=c.shadowBlur??4,g.shadowOffsetX=c.shadowOffsetX??0,g.shadowOffsetY=c.shadowOffsetY??2),u.push(g);}if(c.label!==false){let y=c.label&&typeof c.label=="object"?c.label:void 0,g=typeof c.label=="string"?c.label:y?.text??c.name,S=y?.position??"right";d.push({..._e(g,S,o,n,p,f,y),id:c.id?`${c.id}-label`:void 0});}}return {inside:u,labels:d}}function De(a){let e=Me(a);return [...e.inside,...e.labels]}function _e(a,e,t,r,o,n,i){let m=(t+r)/2,s={type:"text",content:a,fontSize:h.thresholdFontSize,fill:n},l=i?{...i.rotate!==void 0&&{rotate:i.rotate},...i.textBaseline!==void 0&&{textBaseline:i.textBaseline}}:{};switch(e){case "left":return {...s,...l,x:t+4,y:o-4,anchor:"start"};case "above":return {...s,...l,x:m,y:o-6,anchor:"middle"};case "below":return {...s,...l,x:m,y:o+14,anchor:"middle"};case "center":return {...s,...l,x:m,y:o-4,anchor:"middle"};case "outside-left":return {...s,...l,x:t-6,y:o+3,anchor:"end",textBaseline:l.textBaseline??"middle"};case "outside-right":return {...s,...l,x:r+6,y:o+3,anchor:"start",textBaseline:l.textBaseline??"middle"};default:return {...s,...l,x:r-4,y:o-4,anchor:"end"}}}function $e(a){let{gaps:e,timeScale:t,yRange:r,fill:o=h.gapFill,hatch:n,fillOpacity:i=h.gapFillOpacity??.15,stroke:m=h.gapStroke,strokeWidth:s=h.gapStrokeWidth,dashed:l=true,fontSize:u=h.gapFontSize,fontFill:d=h.gapFontColor,labelBaseline:c="middle",labelRotate:f}=a,[p,b]=r,y=[];for(let g of e){let S=t.map(g.startTime),$=t.map(g.endTime),C=g.fill??o,F=g.hatch??n,se=g.fillOpacity??i,le=g.label??"",ge=g.rotate??f,z=g.labelBaseline??c;if(g.style==="dashed_border"||!g.style?y.push({type:"rect",x:S,y:p,w:$-S,h:b-p,fill:C,hatch:F,opacity:se,stroke:m,strokeWidth:s,dashed:l}):g.style==="empty"&&y.push({type:"rect",x:S,y:p,w:$-S,h:b-p,fill:C,hatch:F,opacity:se}),le){let ye=Fe(p,b,z),be=z==="above"?"top":z==="below"?"bottom":"middle";y.push({type:"text",content:le,x:(S+$)/2,y:ye,anchor:"middle",fontSize:u,fill:d,textBaseline:be,rotate:ge});}}return y}function Fe(a,e,t){switch(t){case "above":return a-12;case "below":return e+4;default:return (a+e)/2}}function Pe(a){let{markers:e,timeScale:t,valueScale:r,yRange:o=[0,300]}=a,[n,i]=o,m=[];for(let s of e){let l=t.map(s.time),u=s.color??h.markerColor,d=s.pointStyle??(s.value!==void 0?"circle":"none"),c=s.lineStyle??"full";if(s.value!==void 0){let f=r.map(s.value);if(c==="to-value"?m.push({type:"line",x1:l,y1:i,x2:l,y2:f,stroke:u,strokeWidth:1,dashed:true}):c==="to-top"?m.push({type:"line",x1:l,y1:n,x2:l,y2:f,stroke:u,strokeWidth:1,dashed:true}):c==="full"&&m.push({type:"line",x1:l,y1:n,x2:l,y2:i,stroke:u,strokeWidth:1}),d!=="none"&&Re(m,l,f,u,d),s.label){let p=c==="to-value"?f-10:n-6;m.push({type:"text",content:s.label,x:l,y:p,anchor:"middle",fontSize:11,fill:u});}}else m.push({type:"line",x1:l,y1:n,x2:l,y2:i,stroke:u,strokeWidth:1}),s.label&&m.push({type:"text",content:s.label,x:l,y:n-6,anchor:"middle",fontSize:11,fill:u});}return m}function Re(a,e,t,r,o){let n=h.markerSize;switch(o){case "circle":a.push({type:"circle",cx:e,cy:t,r:n,fill:r});break;case "square":a.push({type:"rect",x:e-n,y:t-n,w:n*2,h:n*2,fill:r});break;case "cross":a.push({type:"line",x1:e-n,y1:t-n,x2:e+n,y2:t+n,stroke:r,strokeWidth:2}),a.push({type:"line",x1:e-n,y1:t+n,x2:e+n,y2:t-n,stroke:r,strokeWidth:2});break;case "arrow":a.push({type:"path",points:[{x:e-n,y:t+n},{x:e,y:t-n},{x:e+n,y:t+n}],stroke:r,strokeWidth:2,fill:"none"});break;case "diamond":a.push({type:"path",points:[{x:e,y:t-n},{x:e+n,y:t},{x:e,y:t+n},{x:e-n,y:t}],fill:r,stroke:"none"});break;case "triangle":a.push({type:"path",points:[{x:e,y:t-n},{x:e+n,y:t+n},{x:e-n,y:t+n}],fill:r,stroke:"none"});break;case "star":{let i=[],m=n*.4;for(let s=0;s<10;s++){let l=s%2===0?n:m,u=Math.PI/2*3+s*Math.PI/5;i.push({x:e+l*Math.cos(u),y:t+l*Math.sin(u)});}a.push({type:"path",points:i,fill:r,stroke:"none"});break}case "plus":a.push({type:"line",x1:e-n,y1:t,x2:e+n,y2:t,stroke:r,strokeWidth:2}),a.push({type:"line",x1:e,y1:t-n,x2:e,y2:t+n,stroke:r,strokeWidth:2});break;case "triangle-down":a.push({type:"path",points:[{x:e,y:t+n},{x:e+n,y:t-n},{x:e-n,y:t-n}],fill:r,stroke:"none"});break;case "hexagon":{let i=[];for(let m=0;m<6;m++){let s=m*(Math.PI/3);i.push({x:e+n*Math.cos(s),y:t+n*Math.sin(s)});}a.push({type:"path",points:i,fill:r,stroke:"none"});break}case "hourglass":a.push({type:"path",points:[{x:e-n,y:t-n},{x:e+n,y:t-n},{x:e-n,y:t+n},{x:e+n,y:t+n}],fill:r,stroke:"none"});break;case "line-horizontal":a.push({type:"line",x1:e-n,y1:t,x2:e+n,y2:t,stroke:r,strokeWidth:2});break}}function Ae(a){let{highlights:e,timeScale:t,yRange:r,height:o}=a,[n,i]=r,m=[];for(let s of e){let l=t.map(s.startTime),u=t.map(s.endTime);m.push({type:"rect",x:l,y:n,w:u-l,h:i-n,fill:s.color??h.highlightColor,opacity:s.opacity??h.highlightOpacity}),s.label&&m.push({type:"text",content:s.label,x:(l+u)/2,y:We(s.labelPosition??"top",n,i,o),anchor:"middle",fontSize:h.annotationFontSize,fill:s.color??h.highlightLabelColor,rotate:s.rotate});}return m}function We(a,e,t,r){switch(a){case "above":return e-5;case "below":return r!==void 0?r-5:t+14;case "center":return (e+t)/2+4;case "bottom":return t-6;default:return e+14}}function X(a){return a&&a.toString().normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"unnamed"}function je(a){let{annotations:e,timeScale:t,valueScales:r}=a,o=[],n=i=>{let m=r.get(i.axis??0)??r.values().next().value;return {x:t.map(i.time),y:m?m.map(i.value):0}};for(let i of e){let m=[],s=l=>m.push(l);switch(i.type){case "line":{let l=n(i.from),u=n(i.to);s({type:"line",x1:l.x,y1:l.y,x2:u.x,y2:u.y,stroke:i.color??h.annotationColor,strokeWidth:i.width??h.annotationWidth,dash:i.dash});break}case "arrow":{let l=n(i.from),u=n(i.to),d=i.color??h.annotationColor,c=i.headSize??h.annotationHead;s({type:"line",x1:l.x,y1:l.y,x2:u.x,y2:u.y,stroke:d,strokeWidth:i.width??h.annotationWidth});let f=Math.hypot(u.x-l.x,u.y-l.y)||1,p=(u.x-l.x)/f,b=(u.y-l.y)/f,y=u.x-p*c,g=u.y-b*c;s({type:"path",points:[{x:u.x,y:u.y},{x:y-b*c*.5,y:g+p*c*.5},{x:y+b*c*.5,y:g-p*c*.5}],fill:d,stroke:"none"});break}case "rect":{let l=n(i.from),u=n(i.to);s({type:"rect",x:Math.min(l.x,u.x),y:Math.min(l.y,u.y),w:Math.abs(u.x-l.x),h:Math.abs(u.y-l.y),fill:i.fill??"none",stroke:i.stroke,opacity:i.opacity});break}case "point":{let l=n(i.at),u=i.color??"#334155",d=i.radius??h.annotationRadius,c=i.shape??"circle";c==="circle"?s({type:"circle",cx:l.x,cy:l.y,r:d,fill:u}):c==="square"?s({type:"rect",x:l.x-d,y:l.y-d,w:d*2,h:d*2,fill:u}):(s({type:"line",x1:l.x-d,y1:l.y-d,x2:l.x+d,y2:l.y+d,stroke:u,strokeWidth:1.5}),s({type:"line",x1:l.x-d,y1:l.y+d,x2:l.x+d,y2:l.y-d,stroke:u,strokeWidth:1.5}));break}case "label":{let l=n(i.at);s({type:"text",content:i.text,x:l.x+(i.dx??0),y:l.y+(i.dy??0),anchor:i.anchor??"middle",fontSize:h.annotationFontSize,fill:i.color??h.annotationColor,rotate:i.rotate});break}}if(i.id&&m.length>0){let l=X(i.id);o.push({type:"group",cssClass:`annotation annotation--${l}`,commands:m});}else o.push(...m);}return o}var U=class a{_config;constructor(e){this._config=e;}compute(){let{width:e,height:t,margin:r}=this._config;return {totalWidth:e,totalHeight:t,chartWidth:e-r.left-r.right,chartHeight:t-r.top-r.bottom,chartX:r.left,chartY:r.top,margin:r}}static default(e=800,t=400){return new a({width:e,height:t,margin:{top:20,right:20,bottom:40,left:60}})}};var Z=class{#e;constructor(){this.#e=[];}add(e){this.#e.push(e);}clear(){this.#e=[];}isInside(e,t){return this.#e.length===0?true:this.#e.some(r=>e>=r.x&&e<=r.x+r.width&&t>=r.y&&t<=r.y+r.height)}toSVGClipPath(e="clip"){if(this.#e.length===0)return "";let t=this.#e.map(r=>`<rect x="${r.x}" y="${r.y}" width="${r.width}" height="${r.height}" />`).join(`
24
+ `.trim()}function B(a){return {id:a.id,line:{stroke:a.stroke??h.stroke,strokeWidth:a.strokeWidth??h.strokeWidth,smoothing:a.smoothing??false,dashed:a.dashed??false},fill:a.fill??h.areaFillAlpha,markers:{type:a.pointStyle??"none",size:a.pointSize??h.pointSize,stroke:a.stroke??h.stroke,fill:"#ffffff"},shadow:{color:a.shadowColor??"transparent",blur:a.shadowBlur??0,offsetX:a.shadowOffsetX??0,offsetY:a.shadowOffsetY??0}}}function w(a,e,t){let n=[],o=a.reduce((i,m)=>i+m.data.length,0),r=B(t);for(let i=0;i<a.length;i++){let m=a[i];m.data.length>=2?n.push({type:"path",id:t.id?`${t.id}-line-${i}`:void 0,points:m.data.map(s=>({x:e.timeScale.map(s.time),y:e.valueScale.map(s.value)})),stroke:m.color??r.line.stroke,strokeWidth:r.line.strokeWidth,smoothing:r.line.smoothing,dashed:r.line.dashed,shadowColor:r.shadow.color,shadowBlur:r.shadow.blur,shadowOffsetX:r.shadow.offsetX,shadowOffsetY:r.shadow.offsetY,fill:"none"}):m.data.length===1&&o===1&&n.push({type:"circle",cx:e.timeScale.map(m.data[0].time),cy:e.valueScale.map(m.data[0].value),r:Math.max(r.markers.size,r.line.strokeWidth),fill:m.color??r.line.stroke,shadowColor:r.shadow.color,shadowBlur:r.shadow.blur});}return n}function ve(a){let e=[];for(let t of a)e.length===0?e.push(t):e.push({x:t.x,y:e[e.length-1].y},t);return e}function G(a,e,t){let n=[],o=B(t);for(let r=0;r<a.length;r++){let i=a[r];if(i.data.length<2)continue;let m=ve(i.data.map(s=>({x:e.timeScale.map(s.time),y:e.valueScale.map(s.value)})));n.push({type:"path",id:t.id?`${t.id}-line-${r}`:void 0,points:m,stroke:i.color??o.line.stroke,strokeWidth:o.line.strokeWidth,smoothing:false,fill:"none"});}return n}function we(a,e,t,n,o){let r=[],i=B(t);for(let m=0;m<a.length;m++){let s=a[m];if(s.data.length<2)continue;let l=s.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(n(c))})),u=s.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(o(c))})).reverse();r.push({type:"path",id:t.id?`${t.id}-fill-${m}`:void 0,points:[...l,...u],fill:s.color??i.fill,hatch:t.hatch,stroke:"none"});}return r}function H(a,e,t,n){if(a.length<2)return [];let o=x.splitByBoundaries(a,t.boundaries,t.getValue,t.interpolate),r=[];for(let i=0;i<o.length;i++){let m=o[i];if(m.data.length<2)continue;let s=t.getColor(m.zoneIndex);if(!s)continue;let l=m.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(t.yLow(c))})),u=m.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(t.yHigh(c))})).reverse();r.push({type:"path",id:n?.id?`${n.id}-fill-${i}`:void 0,points:[...l,...u],fill:s,hatch:t.getHatch?.(m.zoneIndex),stroke:"none"});}return r}function Ce(a,e,t,n){let o=x.splitByThreshold(a,e,i=>i.value,x.interpolateDataPoint),r=[];return n.below&&r.push(...w(o.below.map(i=>({data:i})),t,n.below)),n.above&&r.push(...w(o.above.map(i=>({data:i})),t,n.above)),r}function P(a,e,t,n){let o=B(t);if(!o.markers.type||o.markers.type==="none")return [];let r=[];for(let i=0;i<a.length;i++){let m=a[i],s=e.timeScale.map(m.time),l=e.valueScale.map(m.value),u=n(m),c=t.pointStroke??u,d=t.pointFill??u,p=t.pointStrokeWidth??1.5,f=t.id?`${t.id}-marker-${i}`:void 0;z(r,f,o.markers.type,s,l,o.markers.size,c,d,p);}return r}function z(a,e,t,n,o,r,i,m,s){switch(t){case "circle":a.push({type:"circle",cx:n,cy:o,r,fill:m,stroke:i,strokeWidth:s,id:e});break;case "square":a.push({type:"rect",x:n-r,y:o-r,w:r*2,h:r*2,fill:m,stroke:i,strokeWidth:s,id:e});break;case "cross":a.push({type:"line",x1:n-r,y1:o-r,x2:n+r,y2:o+r,stroke:i,strokeWidth:s,id:e},{type:"line",x1:n-r,y1:o+r,x2:n+r,y2:o-r,stroke:i,strokeWidth:s,id:e});break;case "diamond":a.push({type:"path",points:[{x:n,y:o-r},{x:n+r,y:o},{x:n,y:o+r},{x:n-r,y:o}],fill:m,stroke:i,strokeWidth:s,id:e});break;case "triangle":a.push({type:"path",points:[{x:n,y:o-r},{x:n+r,y:o+r},{x:n-r,y:o+r}],fill:m,stroke:i,strokeWidth:s,id:e});break;case "star":{let l=[];for(let u=0;u<10;u++){let c=u%2===0?r:r*.5,d=Math.PI/2*3+u*Math.PI/5;l.push({x:n+c*Math.cos(d),y:o+c*Math.sin(d)});}a.push({type:"path",points:l,fill:m,stroke:i,strokeWidth:s,id:e});break}case "arrow":a.push({type:"path",points:[{x:n-r,y:o+r},{x:n,y:o-r},{x:n+r,y:o+r}],stroke:i,strokeWidth:s,fill:"none",id:e});break;case "plus":a.push({type:"line",x1:n-r,y1:o,x2:n+r,y2:o,stroke:i,strokeWidth:s,id:e},{type:"line",x1:n,y1:o-r,x2:n,y2:o+r,stroke:i,strokeWidth:s,id:e});break;case "triangle-down":a.push({type:"path",points:[{x:n,y:o+r},{x:n+r,y:o-r},{x:n-r,y:o-r}],fill:m,stroke:i,strokeWidth:s,id:e});break;case "hexagon":{let l=[];for(let u=0;u<6;u++){let c=u*(Math.PI/3);l.push({x:n+r*Math.cos(c),y:o+r*Math.sin(c)});}a.push({type:"path",points:l,fill:m,stroke:i,strokeWidth:s,id:e});break}case "hourglass":a.push({type:"path",points:[{x:n-r,y:o-r},{x:n+r,y:o-r},{x:n-r,y:o+r},{x:n+r,y:o+r}],fill:m,stroke:i,strokeWidth:s,id:e});break;case "line-horizontal":a.push({type:"line",x1:n-r,y1:o,x2:n+r,y2:o,stroke:i,strokeWidth:s,id:e});break;default:a.push({type:"circle",cx:n,cy:o,r,fill:m,stroke:i,strokeWidth:s,id:e});}}var T=12,V=8,Y=20,Te=11,X=18,Z=a=>a.length*Te*.6;function Le(a,e="vertical"){if(e==="horizontal"){let n=0;for(let o of a)n+=T+V+Z(o.name)+X;return {width:Math.max(0,n-X),height:Y}}let t=0;for(let n of a)t=Math.max(t,Z(n.name));return {width:T+V+t,height:a.length*Y}}function De(a){let{items:e,x:t,y:n,orientation:o="vertical"}=a,r=[],i=t;return e.forEach((m,s)=>{let l=o==="horizontal"?i:t,u=o==="horizontal"?n:n+s*Y;r.push({type:"rect",x:l,y:u,w:T,h:T,fill:m.color,stroke:h.legendStroke,strokeWidth:1},{type:"text",content:m.name,x:l+T+V,y:u+T-2,fontSize:h.legendFont,fill:h.legendText}),o==="horizontal"&&(i+=T+V+Z(m.name)+X);}),{type:"group",cssClass:"chart-legend",commands:r}}function Me(a){let{xTicks:e,yTicks:t,xRange:n,yRange:o,stroke:r=h.gridStroke,strokeWidth:i=h.gridStrokeWidth,dashed:m=false,opacity:s=h.gridOpacity}=a,l=[];if(t)for(let u of t)l.push({type:"line",x1:n[0],y1:u,x2:n[1],y2:u,stroke:r,strokeWidth:i,dashed:m,opacity:s});if(e)for(let u of e)l.push({type:"line",x1:u,y1:o[0],x2:u,y2:o[1],stroke:r,strokeWidth:i,dashed:m,opacity:s});return l}var he=new Map;function _e(a,e){return `${a}|${JSON.stringify(e??{})}`}function A(a,e){let t=_e(a,e),n=he.get(t);return n||(n=new Intl.DateTimeFormat(a,e),he.set(t,n)),n}var L=class{#e;#t;constructor(e){this.#e=[...e.domain],this.#t=[...e.range];}map(e){let t=Number(e),[n,o]=this.#e,[r,i]=this.#t;return o===n?r:r+(t-n)/(o-n)*(i-r)}invert(e){let[t,n]=this.#e,[o,r]=this.#t;return r===o?t:t+(e-o)/(r-o)*(n-t)}domain(){return [...this.#e]}range(){return [...this.#t]}},k=[{label:"second",ms:1e3},{label:"2_seconds",ms:2e3},{label:"5_seconds",ms:5e3},{label:"10_seconds",ms:1e4},{label:"30_seconds",ms:3e4},{label:"minute",ms:6e4},{label:"5_minutes",ms:3e5},{label:"15_minutes",ms:9e5},{label:"30_minutes",ms:18e5},{label:"hour",ms:36e5},{label:"3_hours",ms:108e5},{label:"6_hours",ms:216e5},{label:"day",ms:864e5},{label:"week",ms:6048e5},{label:"month",ms:2592e6},{label:"3_months",ms:7776e6},{label:"6_months",ms:15552e6},{label:"year",ms:31536e6},{label:"2_years",ms:63072e6},{label:"5_years",ms:15768e7}],R=class{#e;#t;constructor(e){this.#e=new L({domain:e.domain,range:e.range}),this.#t=e.locale||(typeof navigator<"u"?navigator.language:"en-US");}map(e){return this.#e.map(Number(e))}invert(e){return this.#e.invert(e)}domain(){return this.#e.domain()}range(){return this.#e.range()}get locale(){return this.#t}tickInterval(e,t=3,n=12){let[o,r]=this.#e.domain(),i=r-o;if(i<=0)return {interval:k[0].ms};let m=i/e,s=k[0].ms;for(let c of k)if(c.ms>=m){s=c.ms;break}let l=s,u=Math.round(i/l);for(;u>n&&l<k[k.length-1].ms;){let c=k.findIndex(d=>d.ms===l);l=k[Math.min(c+1,k.length-1)].ms,u=Math.round(i/l);}for(;u<t&&l>k[0].ms;){let c=k.findIndex(d=>d.ms===l);l=k[Math.max(c-1,0)].ms,u=Math.round(i/l);}return {interval:l}}ticks(e){let t=e?.minTicks??5,n=e?.maxTicks??12,{interval:o}=this.tickInterval((t+n)/2,t,n),[r,i]=this.#e.domain(),m=[],s=Math.ceil(r/o)*o;for(let l=s;l<=i;l+=o)m.push(l);return m}format(e,t){return A(this.#t,t).format(new Date(e))}},W=class{#e;#t;#n;#r;constructor(e){this.#e=[...e.domain],this.#t=[...e.range],this.#n=e.paddingInner??.1,this.#r=e.paddingOuter??.05;}get step(){let[e,t]=this.#t,n=this.#e.length;return n<=1?Math.abs(t-e):Math.abs(t-e)*(1-this.#r*2)/n+Math.abs(t-e)*this.#n*2/n}get bandwidth(){let[e,t]=this.#t,n=this.#e.length;if(n<=1)return Math.abs(t-e)*(1-this.#r*2);let o=this.#r*2*Math.abs(t-e);return (Math.abs(t-e)-o)/n*(1-this.#n)}map(e){let t=this.#e.findIndex(c=>String(c)===String(e));if(t===-1)return this.#t[0];let[n,o]=this.#t,r=this.#e.length;if(r<=1)return (n+o)/2;let i=this.#r*2*Math.abs(o-n),m=Math.abs(o-n)-i,s=o>=n?1:-1,l=m/r;return n+this.#r*Math.abs(o-n)*s+t*l}invert(e){let t=0,n=1/0;for(let o=0;o<this.#e.length;o++){let r=this.map(this.#e[o]),i=Math.abs(e-r);i<n&&(n=i,t=o);}return this.#e[t]}domain(){return this.#e.length===0?["",""]:[this.#e[0],this.#e[this.#e.length-1]]}range(){return [...this.#t]}positions(){let e=new Map;for(let t of this.#e)e.set(t,this.map(t));return e}};function $e(a){return a==="dotted"?{dash:"dotted"}:a==="dashed"?{dash:"dashed"}:{}}function Fe(a){let{thresholds:e,valueScale:t,xRange:n}=a,[o,r]=n,[i,m]=t.range(),s=Math.min(i,m),l=Math.max(i,m),u=[],c=[];for(let d of e){let p=d.color??h.thresholdColor,f=t.map(d.value);d.fill==="above"?u.push({type:"rect",x:o,y:s,w:r-o,h:Math.max(0,f-s),fill:p,hatch:d.fillHatch,opacity:d.fillOpacity??.12,id:d.id?`${d.id}-fill`:void 0}):d.fill==="below"&&u.push({type:"rect",x:o,y:f,w:r-o,h:Math.max(0,l-f),fill:p,hatch:d.fillHatch,opacity:d.fillOpacity??.12,id:d.id?`${d.id}-fill`:void 0});let g=d.line??h.thresholdLine;if(g!=="none"){let b=$e(g),y={type:"line",x1:o,y1:f,x2:r,y2:f,stroke:p,strokeWidth:1,...b,id:d.id?`${d.id}-line`:void 0};d.shadowColor&&(y.shadowColor=d.shadowColor,y.shadowBlur=d.shadowBlur??4,y.shadowOffsetX=d.shadowOffsetX??0,y.shadowOffsetY=d.shadowOffsetY??2),u.push(y);}if(d.label!==false){let b=d.label&&typeof d.label=="object"?d.label:void 0,y=typeof d.label=="string"?d.label:b?.text??d.name,S=b?.position??"right";c.push({...Ae(y,S,o,r,f,p,b),id:d.id?`${d.id}-label`:void 0});}}return {inside:u,labels:c}}function Pe(a){let e=Fe(a);return [...e.inside,...e.labels]}function Ae(a,e,t,n,o,r,i){let m=(t+n)/2,s={type:"text",content:a,fontSize:h.thresholdFontSize,fill:r},l=i?{...i.rotate!==void 0&&{rotate:i.rotate},...i.textBaseline!==void 0&&{textBaseline:i.textBaseline}}:{};switch(e){case "left":return {...s,...l,x:t+4,y:o-4,anchor:"start"};case "above":return {...s,...l,x:m,y:o-6,anchor:"middle"};case "below":return {...s,...l,x:m,y:o+14,anchor:"middle"};case "center":return {...s,...l,x:m,y:o-4,anchor:"middle"};case "outside-left":return {...s,...l,x:t-6,y:o+3,anchor:"end",textBaseline:l.textBaseline??"middle"};case "outside-right":return {...s,...l,x:n+6,y:o+3,anchor:"start",textBaseline:l.textBaseline??"middle"};default:return {...s,...l,x:n-4,y:o-4,anchor:"end"}}}function Re(a){let{gaps:e,timeScale:t,yRange:n,fill:o=h.gapFill,hatch:r,fillOpacity:i=h.gapFillOpacity??.15,stroke:m=h.gapStroke,strokeWidth:s=h.gapStrokeWidth,dashed:l=true,fontSize:u=h.gapFontSize,fontFill:c=h.gapFontColor,labelBaseline:d="middle",labelRotate:p}=a,[f,g]=n,b=[];for(let y of e){let S=t.map(y.startTime),$=t.map(y.endTime),C=y.fill??o,F=y.hatch??r,me=y.fillOpacity??i,ue=y.label??"",xe=y.rotate??p,E=y.labelBaseline??d;if(y.style==="dashed_border"||!y.style?b.push({type:"rect",x:S,y:f,w:$-S,h:g-f,fill:C,hatch:F,opacity:me,stroke:m,strokeWidth:s,dashed:l}):y.style==="empty"&&b.push({type:"rect",x:S,y:f,w:$-S,h:g-f,fill:C,hatch:F,opacity:me}),ue){let Se=We(f,g,E),ke=E==="above"?"top":E==="below"?"bottom":"middle";b.push({type:"text",content:ue,x:(S+$)/2,y:Se,anchor:"middle",fontSize:u,fill:c,textBaseline:ke,rotate:xe});}}return b}function We(a,e,t){switch(t){case "above":return a-12;case "below":return e+4;default:return (a+e)/2}}function Oe(a){let{markers:e,timeScale:t,valueScale:n,yRange:o=[0,300]}=a,[r,i]=o,m=[];for(let s of e){let l=t.map(s.time),u=s.color??h.markerColor,c=s.pointStyle??(s.value!==void 0?"circle":"none"),d=s.lineStyle??"full";if(s.value!==void 0){let p=n.map(s.value);if(d==="to-value"?m.push({type:"line",x1:l,y1:i,x2:l,y2:p,stroke:u,strokeWidth:1,dashed:true}):d==="to-top"?m.push({type:"line",x1:l,y1:r,x2:l,y2:p,stroke:u,strokeWidth:1,dashed:true}):d==="full"&&m.push({type:"line",x1:l,y1:r,x2:l,y2:i,stroke:u,strokeWidth:1}),c!=="none"&&z(m,void 0,c,l,p,h.markerSize,u,u,1.5),s.label){let f=d==="to-value"?p-10:r-6;m.push({type:"text",content:s.label,x:l,y:f,anchor:"middle",fontSize:11,fill:u});}}else m.push({type:"line",x1:l,y1:r,x2:l,y2:i,stroke:u,strokeWidth:1}),s.label&&m.push({type:"text",content:s.label,x:l,y:r-6,anchor:"middle",fontSize:11,fill:u});}return m}function je(a){let{highlights:e,timeScale:t,yRange:n,height:o}=a,[r,i]=n,m=[];for(let s of e){let l=t.map(s.startTime),u=t.map(s.endTime);m.push({type:"rect",x:l,y:r,w:u-l,h:i-r,fill:s.color??h.highlightColor,opacity:s.opacity??h.highlightOpacity}),s.label&&m.push({type:"text",content:s.label,x:(l+u)/2,y:Ie(s.labelPosition??"top",r,i,o),anchor:"middle",fontSize:h.annotationFontSize,fill:s.color??h.highlightLabelColor,rotate:s.rotate});}return m}function Ie(a,e,t,n){switch(a){case "above":return e-5;case "below":return n!==void 0?n-5:t+14;case "center":return (e+t)/2+4;case "bottom":return t-6;default:return e+14}}function U(a){return a&&a.toString().normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"unnamed"}function Be(a){let{annotations:e,timeScale:t,valueScales:n}=a,o=[],r=i=>{let m=n.get(i.axis??0)??n.values().next().value;return {x:t.map(i.time),y:m?m.map(i.value):0}};for(let i of e){let m=[],s=l=>m.push(l);switch(i.type){case "line":{let l=r(i.from),u=r(i.to);s({type:"line",x1:l.x,y1:l.y,x2:u.x,y2:u.y,stroke:i.color??h.annotationColor,strokeWidth:i.width??h.annotationWidth,dash:i.dash});break}case "arrow":{let l=r(i.from),u=r(i.to),c=i.color??h.annotationColor,d=i.headSize??h.annotationHead;s({type:"line",x1:l.x,y1:l.y,x2:u.x,y2:u.y,stroke:c,strokeWidth:i.width??h.annotationWidth});let p=Math.hypot(u.x-l.x,u.y-l.y)||1,f=(u.x-l.x)/p,g=(u.y-l.y)/p,b=u.x-f*d,y=u.y-g*d;s({type:"path",points:[{x:u.x,y:u.y},{x:b-g*d*.5,y:y+f*d*.5},{x:b+g*d*.5,y:y-f*d*.5}],fill:c,stroke:"none"});break}case "rect":{let l=r(i.from),u=r(i.to);s({type:"rect",x:Math.min(l.x,u.x),y:Math.min(l.y,u.y),w:Math.abs(u.x-l.x),h:Math.abs(u.y-l.y),fill:i.fill??"none",stroke:i.stroke,opacity:i.opacity});break}case "point":{let l=r(i.at),u=i.color??"#334155",c=i.radius??h.annotationRadius,d=i.shape??"circle";d==="circle"?s({type:"circle",cx:l.x,cy:l.y,r:c,fill:u}):d==="square"?s({type:"rect",x:l.x-c,y:l.y-c,w:c*2,h:c*2,fill:u}):(s({type:"line",x1:l.x-c,y1:l.y-c,x2:l.x+c,y2:l.y+c,stroke:u,strokeWidth:1.5}),s({type:"line",x1:l.x-c,y1:l.y+c,x2:l.x+c,y2:l.y-c,stroke:u,strokeWidth:1.5}));break}case "label":{let l=r(i.at);s({type:"text",content:i.text,x:l.x+(i.dx??0),y:l.y+(i.dy??0),anchor:i.anchor??"middle",fontSize:h.annotationFontSize,fill:i.color??h.annotationColor,rotate:i.rotate});break}}if(i.id&&m.length>0){let l=U(i.id);o.push({type:"group",cssClass:`annotation annotation--${l}`,commands:m});}else o.push(...m);}return o}var q=class a{_config;constructor(e){this._config=e;}compute(){let{width:e,height:t,margin:n}=this._config;return {totalWidth:e,totalHeight:t,chartWidth:e-n.left-n.right,chartHeight:t-n.top-n.bottom,chartX:n.left,chartY:n.top,margin:n}}static default(e=800,t=400){return new a({width:e,height:t,margin:{top:20,right:20,bottom:40,left:60}})}};var K=class{#e;constructor(){this.#e=[];}add(e){this.#e.push(e);}clear(){this.#e=[];}isInside(e,t){return this.#e.length===0?true:this.#e.some(n=>e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height)}toSVGClipPath(e="clip"){if(this.#e.length===0)return "";let t=this.#e.map(n=>`<rect x="${n.x}" y="${n.y}" width="${n.width}" height="${n.height}" />`).join(`
29
25
  `);return `<clipPath id="${e}">
30
26
  ${t}
31
- </clipPath>`}get regions(){return [...this.#e]}};var W={axisColor:h.axisColor,tickColor:h.tickColor,textColor:h.textColor,textSize:h.textSize},j=class{#e;#t;constructor(e){this.#e=new R({domain:e.domain,range:e.xRange,locale:e.locale}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??W).axisColor}get tickColor(){return (this.#t.colors??W).tickColor}get textColor(){return (this.#t.colors??W).textColor}get textSize(){return (this.#t.colors??W).textSize}generateTicks(){let e=this.#t.minTicks??5,t=this.#t.maxTicks??12,o=this.#e.ticks({minTicks:e,maxTicks:t}).map(n=>({time:n,x:this.#e.map(n),label:this.tickLabel(n)}));return this.antiOverlap(o)}tickLabel(e){if(this.#t.format)return this.#t.format(new Date(e));let t=this.#t.minTicks??5,r=this.#t.maxTicks??12,{interval:o}=this.#e.tickInterval((t+r)/2,t,r),n={};return o<6e4?(n.hour="2-digit",n.minute="2-digit",n.second="2-digit"):o<36e5||o<864e5?(n.hour="2-digit",n.minute="2-digit"):o<31536e6?(n.day="numeric",n.month="short",o>=2592e6&&(n.day=void 0,n.month="long")):(n.year="numeric",o<2*31536e6&&(n.month="short")),this.#e.format(e,n)}antiOverlap(e){if(e.length<=1)return e;let t=60,r=[e[0]];for(let o=1;o<e.length;o++){let n=r[r.length-1].x;Math.abs(e[o].x-n)>=t&&r.push(e[o]);}return r}render(){let e=this.generateTicks(),t=this.#t.colors??W,r=this.#t.y??0,o=[],[n,i]=this.#e.range();o.push({type:"line",x1:n,y1:r,x2:i,y2:r,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let m of e)o.push({type:"line",x1:m.x,y1:r,x2:m.x,y2:r+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),o.push({type:"text",content:m.label,x:m.x,y:r+t.textSize+6,anchor:"middle",fontSize:t.textSize,fill:t.textColor});return o}};var O={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function Oe(a){return Math.abs(a)>=1e6?`${(a/1e6).toFixed(1)}M`:Math.abs(a)>=1e3?`${(a/1e3).toFixed(1)}k`:Number.isInteger(a)?String(a):a.toFixed(1)}function Ie(a){let e=new Array(a.length).fill(false),t=0;for(;t<a.length;){let r=t;for(;r+1<a.length&&a[r+1].label===a[t].label;)r++;for(let o=t+1;o<r;o++)e[o]=true;t=r+1;}return e}var q=class{#e;#t;constructor(e){this.#e=new L({domain:e.domain,range:e.range}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??O).axisColor}get tickColor(){return (this.#t.colors??O).tickColor}get textColor(){return (this.#t.colors??O).textColor}get textSize(){return (this.#t.colors??O).textSize}generateTicks(){let e=this.#t.format??Oe,t=6,[r,o]=this.#e.domain(),n=o-r;if(n===0)return [{value:r,position:this.#e.map(r),label:e(r)}];let i=n/t,m=Math.pow(10,Math.floor(Math.log10(i))),s=i/m,l;s<=1.5?l=m:s<=3?l=2*m:s<=7?l=5*m:l=10*m;let u=[],d=Math.ceil(r/l)*l;for(let c=d;c<=o;c+=l)u.push({value:c,position:this.#e.map(c),label:e(c)});return u}render(){let e=this.generateTicks(),t=this.#t.colors??O,r=this.#t.x??0,o=this.#t.orientation??"vertical",n=this.#t.position??"left",i=this.#t.suppressLabelsNear??[],m=this.#t.suppressTolerancePx??8,s=u=>i.some(d=>Math.abs(d-u)<=m),l=[];if(o==="vertical"){let[u,d]=this.#e.range();l.push({type:"line",x1:r,y1:u,x2:r,y2:d,stroke:t.axisColor,strokeWidth:t.axisWidth});let c=Ie(e);e.forEach((f,p)=>{let b=s(f.position),y=c[p]?{opacity:0}:{};n==="left"?(l.push({type:"line",x1:r-4,y1:f.position,x2:r,y2:f.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),b||l.push({type:"text",content:f.label,x:r-8,y:f.position+4,anchor:"end",fontSize:11,fill:t.textColor,...y})):(l.push({type:"line",x1:r,y1:f.position,x2:r+4,y2:f.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),b||l.push({type:"text",content:f.label,x:r+8,y:f.position+4,anchor:"start",fontSize:11,fill:t.textColor,...y}));});}else {let[u,d]=this.#e.range();l.push({type:"line",x1:u,y1:r,x2:d,y2:r,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let c of e)l.push({type:"line",x1:c.position,y1:r,x2:c.position,y2:r+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),l.push({type:"text",content:c.label,x:c.position,y:r+18,anchor:"middle",fontSize:t.textSize,fill:t.textColor});}return l}};var K=class{#e;#t;#n;constructor(e){let t=Object.keys(e.enumMap).map(Number).sort((r,o)=>r-o).map(String);this.#t=t,this.#e=new A({domain:t,range:e.range}),this.#n=e;}get scale(){return this.#e}generateTicks(){let{enumMap:e,showLabels:t=true,autoColor:r=true,gapValues:o}=this.#n,n=new Set(o??[]);return this.#t.map((i,m)=>{let s=Number(i),l=t?e[s]??String(s):String(s),u=this.#e.map(s),d=r?h.palette[m%h.palette.length]:void 0;return {value:s,label:l,y:u,color:d,isGap:n.has(s)}})}colorFor(e){let t=this.#t.indexOf(String(e));if(!(t===-1||!(this.#n.autoColor??true)))return h.palette[t%h.palette.length]}render(){let e=this.generateTicks(),t=this.#n.x??0,r=[];for(let o of e)o.isGap||r.push({type:"text",content:o.label,x:t,y:o.y+4,anchor:"end",fontSize:11,fill:o.color??h.textColor});return r}map(e){return this.#e.map(e)}isGap(e){return new Set(this.#n.gapValues??[]).has(e)}};var v=class a{#e;#t;static uidcnt=0;#n;constructor(e,t=[]){this.#e=e.id??"id"+Date.now+ ++a.uidcnt,this.#t=e.timeScale,this.#n=t;}get id(){return this.#e}get timeScale(){return this.#t}get data(){return this.#n}};var Q=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}points(){let e=this.#e.valueScale;return this.data.filter(t=>t.value!==null).map(t=>({x:this.timeScale.map(t.time),y:e.map(t.value),time:t.time})).sort((t,r)=>t.x-r.x)}render(){let e=this.#e,t={smoothing:e.smoothing??false,stroke:e.stroke??h.stroke,strokeWidth:e.strokeWidth??h.strokeWidth,dashed:e.dashed??false,pointStyle:e.pointStyle??"none",pointSize:e.pointSize??h.pointSize,shadowColor:e.shadowColor,shadowBlur:e.shadowBlur,shadowOffsetX:e.shadowOffsetX,shadowOffsetY:e.shadowOffsetY},r=e.pointThreshold??h.pointThreshold,o=e.gapThreshold??h.gapThreshold,n=e.id,i=x.getRuns(this.data,d=>d.value===null,o),m=i.reduce((d,c)=>d+c.length,0);if(m===0)return [];let s={timeScale:this.timeScale,valueScale:e.valueScale},l=i.map(d=>({data:d})),u=[];if(u.push(...w(l,s,{...t,id:n?`${n}-line`:void 0})),t.pointStyle&&t.pointStyle!=="none"&&m<=r)for(let d of i)u.push(...P(d,s,{...t,id:n?`${n}-marker`:void 0},()=>t.stroke));return u}};var J=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}points(){let e=this.#e.valueScale,t=[...this.data].filter(o=>o.value!==null).sort((o,n)=>o.time-n.time),r=[];for(let o=0;o<t.length;o++){let n=this.timeScale.map(t[o].time),i=e.map(t[o].value);o===0?r.push({x:n,y:i}):(r.push({x:n,y:r[r.length-1].y}),r.push({x:n,y:i}));}return r}render(){let e=x.getRuns(this.data,o=>o.value===null);if(e.length===0)return [];let t={timeScale:this.timeScale,valueScale:this.#e.valueScale},r=e.map(o=>({data:o}));return E(r,t,{stroke:this.#e.stroke??h.stroke,strokeWidth:this.#e.strokeWidth??h.strokeWidth,id:this.id?`${this.id}-line`:void 0})}};var ee=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}opacity(e){if(!(this.#e.countOpacity??false))return .6;let t=Math.max(...this.data.map(r=>r.count));return t===0?.2:.2+.8*e/t}render(){let e=this.#e,t=e.fill??h.bandFill,r=e.hatch,o=e.avgLine??false,n=e.avgLineColor??h.bandAvgLine,i=e.bandWidth??10,m=[];for(let s of this.data){if(s.min===null||s.max===null)continue;let l=this.timeScale.map(s.time),u=e.valueScale.map(s.max),d=e.valueScale.map(s.min),c=i,f=this.data.indexOf(s);if(m.push({type:"rect",x:l-c/2,y:u,w:c,h:d-u,fill:t,hatch:r,opacity:this.opacity(s.count),id:this.id?`${this.id}-slot-${f}`:void 0}),o&&s.avg!==null){let p=e.valueScale.map(s.avg);m.push({type:"line",x1:l-c/2,y1:p,x2:l+c/2,y2:p,stroke:n,strokeWidth:1,id:this.id?`${this.id}-avg-${f}`:void 0});}}return m}};var te=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}render(){let e=this.#e,t=e.minColor??h.minColor,r=e.maxColor??h.maxColor,o=e.avgColor??h.avgColor,n=e.avgDashed??true,i=e.smoothing??false,m=e.strokeWidth??h.strokeWidth,s=x.getRuns(this.data,d=>d.min===null||d.max===null||d.avg===null);if(s.length===0)return [];let l={timeScale:this.timeScale,valueScale:e.valueScale},u=[];for(let d of s)d.length<2||(e.fillToMax&&u.push(...B(d,l,{boundaries:[],yLow:c=>c.avg,yHigh:c=>c.max,getValue:c=>c.avg,interpolate:x.interpolateAggregatedPoint,getColor:()=>e.fillToMax,getHatch:()=>e.fillToMaxHatch},{id:this.id?`${this.id}-fillToMax`:void 0})),e.fillToMin&&u.push(...B(d,l,{boundaries:[],yLow:c=>c.avg,yHigh:c=>c.min,getValue:c=>c.avg,interpolate:x.interpolateAggregatedPoint,getColor:()=>e.fillToMin,getHatch:()=>e.fillToMinHatch},{id:this.id?`${this.id}-fillToMin`:void 0})),u.push(...w([{data:d.map(c=>({time:c.time,value:c.max}))}],l,{stroke:r,strokeWidth:m,smoothing:i,id:this.id?`${this.id}-max`:void 0}),...w([{data:d.map(c=>({time:c.time,value:c.min}))}],l,{stroke:t,strokeWidth:m,smoothing:i,id:this.id?`${this.id}-min`:void 0}),...w([{data:d.map(c=>({time:c.time,value:c.avg}))}],l,{stroke:o,strokeWidth:m,smoothing:i,dashed:n,id:this.id?`${this.id}-avg`:void 0})));return u}};var ne=class extends v{#e;#t;constructor(e){super(e,e.data),this.#e=e,this.#t=[...e.zones??[]].sort((t,r)=>t.value-r.value);}#n(e){return e===0?this.#e.baseColor??h.stroke:this.#t[e-1].color}render(){let e=this.#e,t=e.baseColor??h.stroke,r={stroke:t,strokeWidth:e.strokeWidth??h.strokeWidth,smoothing:e.smoothing??false,pointStyle:e.pointStyle??"none",pointSize:e.pointSize??h.pointSize},o=e.gapThreshold??h.gapThreshold,n=e.pointThreshold??h.pointThreshold,i=x.getRuns(this.data,u=>u.value===null,o),m=i.reduce((u,d)=>u+d.length,0);if(m===0)return [];let s={timeScale:this.timeScale,valueScale:e.valueScale},l=[];for(let u of i){if(u.length<2)continue;if(e.fill){let p=e.fill.value,b=x.splitByBoundaries(u,[p],g=>g.value,x.interpolateDataPoint),y=e.valueScale.map(p);for(let g=0;g<b.length;g++){let S=b[g],$=(S.data[0].value+S.data[S.data.length-1].value)/2;if(e.fill.side==="above"==$>=p){let C=S.data.map(F=>({x:this.timeScale.map(F.time),y:e.valueScale.map(F.value)}));l.push({type:"path",id:this.id?`${this.id}-fill-${g}`:void 0,points:[...C,{x:C[C.length-1].x,y},{x:C[0].x,y}],fill:e.fill.color,hatch:e.fill.hatch,stroke:"none"});}}}let d=this.#t.map(p=>p.value),f=x.splitByBoundaries(u,d,p=>p.value,x.interpolateDataPoint).map(p=>({data:p.data,color:this.#n(p.zoneIndex)}));l.push(...w(f,s,{...r,id:this.id?`${this.id}-line`:void 0})),r.pointStyle&&r.pointStyle!=="none"&&m<=n&&l.push(...P(u,s,{...r,id:this.id?`${this.id}-marker`:void 0},p=>{let b=t;for(let y of this.#t)p.value>=y.value&&(b=y.color);return b}));}return l}};var re=class{#e;constructor(e,t,r,o){this.#e={...e,xRange:t,y:r,height:o};}render(){let{items:e,timeScale:t,background:r,hatch:o,showAxis:n,xRange:i,y:m,height:s}=this.#e,l=[];r&&l.push({type:"rect",x:i[0],y:m,w:i[1]-i[0],h:s,fill:r,opacity:.04,stroke:"#ddd",strokeWidth:.25});for(let u of e){let d=t.map(u.startTime),c=t.map(u.endTime);if(!(c-d<1)&&(l.push({type:"rect",x:d,y:m,w:c-d,h:s,hatch:u.hatch??o,fill:u.fill??"#6b728044",stroke:u.stroke,strokeWidth:u.strokeWidth??0}),u.label)){let f=u.labelFontSize??10;l.push({type:"text",content:u.label,x:(d+c)/2,y:this.#t(u.labelBaseline,f),anchor:"middle",fontSize:f,fill:u.labelFill??"#333"});}}if(n){let u=new j({domain:t.domain(),xRange:i,y:m+s+4});l.push({type:"group",cssClass:"annotation-band-axis",commands:u.render()});}return l}#t(e,t){let{y:r,height:o}=this.#e;switch(e){case "top":return r+t*.9;case "bottom":return r+o-t*.25;default:return r+o/2+t*.35}}};var oe=class{#e;constructor(e){this.#e=e;}render(){let{data:e,valueScale:t,xRange:r,showMin:o=false,showMax:n=false,showAvg:i=true,showMedian:m=false,labelPosition:s="end",lineColor:l=h.statsLineColor,labelColor:u=h.statsLabelColor}=this.#e,d=me.compute(e),c=[{name:"min",value:d.min,enabled:o},{name:"max",value:d.max,enabled:n},{name:"avg",value:d.avg,enabled:i},{name:"median",value:d.median,enabled:m}],f=[],[p,b]=r;for(let y of c.filter(g=>g.enabled)){let g=t.map(y.value);f.push({type:"line",x1:p,y1:g,x2:b,y2:g,stroke:l,strokeWidth:1});let S=`${y.name}: ${y.value.toFixed(1)}`;(s==="start"||s==="both")&&f.push({type:"text",content:S,x:p+4,y:g-4,anchor:"start",fontSize:10,fill:u}),(s==="end"||s==="both")&&f.push({type:"text",content:S,x:b-4,y:g-4,anchor:"end",fontSize:10,fill:u}),s==="center"&&f.push({type:"text",content:S,x:(p+b)/2,y:g-4,anchor:"middle",fontSize:10,fill:u});}return f}};var M=class{#e;#t;#n;constructor(e){this.#e=e?.locale||(typeof navigator<"u"?navigator.language:"en-US"),this.#t=e?.fallbackLocales??["en-US"],this.#n=e?.autoFormat??true;}format(e,t,r){try{let o=this.#n&&r?this.#r(e,r,t):t;return new Intl.DateTimeFormat(this.#e,o).format(new Date(e))}catch{for(let o of this.#t)try{return new Intl.DateTimeFormat(o,t).format(new Date(e))}catch{}return new Date(e).toISOString()}}formatRange(e,t){let r=this.format(e),o=this.format(t);return `${r} \u2014 ${o}`}#r(e,t,r){let o=Math.abs(e-t),n=864e5,i=36e5,m=6e4,s={};return o<m?(s.second="2-digit",s.minute="2-digit",s.hour="2-digit"):o<i?(s.minute="2-digit",s.hour="2-digit"):o<n?(s.hour="2-digit",s.minute="2-digit"):o<7*n?(s.weekday="short",s.day="numeric"):o<365*n?(s.month="short",s.day="numeric"):(s.month="short",s.year="numeric"),{...r,...s}}};var D=class a{#e;#t;_compact;#n;constructor(e){this.#e=e?.unit??"",this.#t=e?.decimals??1,this._compact=e?.compact??false,this.#n=e?.custom;}format(e){if(this.#n)return this.#n(e);let t;return this._compact&&Math.abs(e)>=1e6?t=`${(e/1e6).toFixed(this.#t)}M`:this._compact&&Math.abs(e)>=1e3?t=`${(e/1e3).toFixed(this.#t)}k`:t=e.toFixed(this.#t),this.#e?`${t}${this.#e}`:t}formatRange(e,t){return `${this.format(e)} \u2014 ${this.format(t)}`}static unit(e,t=1){return new a({unit:e,decimals:t})}static temperature(e="\xB0C"){return new a({unit:e,decimals:1})}static percentage(){return new a({unit:"%",decimals:0})}};var _=class a{#e;#t;#n;constructor(e){this.#e=e?.map??{},this.#t=e?.fallback??(t=>String(t)),this.#n=e?.showValue??false;}format(e){let t=this.#e[e]??this.#t(e);return this.#n?`(${e}) ${t}`:t}has(e){return e in this.#e}labels(){return Object.values(this.#e)}values(){return Object.keys(this.#e).map(Number)}static fromLabels(e,t=false){let r={};return e.forEach((o,n)=>{r[n]=o;}),new a({map:r,showValue:t})}};var Be={time:new M,value:new D,enum:new _};var He={...h};function ie(){return He}function ae(a,e){let t=ie();return {color:a.color??t.stroke,width:a.width??t.strokeWidth,style:a.style??"solid",smoothing:a.smoothing??false,shape:a.shape??(e.seriesType==="step"?"step":"line"),gapThreshold:a.gapThreshold??t.gapThreshold,opacity:a.opacity??1}}function ce(a){let e=a.style?.line;return e===false?[]:e===void 0?[ae({},a)]:Array.isArray(e)?e.map(t=>ae(t,a)):[ae(e,a)]}function de(a){let e=a.style?.markers;if(!e?.type||e.type==="none")return;let t=ie(),o=(a.style?.line&&!Array.isArray(a.style.line)?a.style.line.color:void 0)??t.stroke;return {type:e.type,size:e.size??t.pointSize,stroke:e.stroke??o,fill:e.fill??"#ffffff",strokeWidth:e.strokeWidth??1,threshold:e.threshold}}function he(a){let e=a.style?.shadow;if(!(!e?.color||e.color==="transparent"||e.color==="none"))return {color:e.color,blur:e.blur??4,offsetX:e.offsetX??0,offsetY:e.offsetY??0}}function pe(a){return a.style?.gap}function fe(a){return a.style?.fill}function ze(a){return {lines:ce(a),fill:fe(a),markers:de(a),shadow:he(a),gap:pe(a),id:a.style?.id??a.id}}/*!
27
+ </clipPath>`}get regions(){return [...this.#e]}};var O={axisColor:h.axisColor,tickColor:h.tickColor,textColor:h.textColor,textSize:h.textSize},j=class{#e;#t;constructor(e){this.#e=new R({domain:e.domain,range:e.xRange,locale:e.locale}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??O).axisColor}get tickColor(){return (this.#t.colors??O).tickColor}get textColor(){return (this.#t.colors??O).textColor}get textSize(){return (this.#t.colors??O).textSize}generateTicks(){let e=this.#t.minTicks??5,t=this.#t.maxTicks??12,o=this.#e.ticks({minTicks:e,maxTicks:t}).map(r=>({time:r,x:this.#e.map(r),label:this.tickLabel(r)}));return this.antiOverlap(o)}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:o}=this.#e.tickInterval((t+n)/2,t,n),r={};return o<6e4?(r.hour="2-digit",r.minute="2-digit",r.second="2-digit"):o<36e5||o<864e5?(r.hour="2-digit",r.minute="2-digit"):o<31536e6?(r.day="numeric",r.month="short",o>=2592e6&&(r.day=void 0,r.month="long")):(r.year="numeric",o<2*31536e6&&(r.month="short")),this.#e.format(e,r)}antiOverlap(e){if(e.length<=1)return e;let t=60,n=[e[0]];for(let o=1;o<e.length;o++){let r=n[n.length-1].x;Math.abs(e[o].x-r)>=t&&n.push(e[o]);}return n}render(){let e=this.generateTicks(),t=this.#t.colors??O,n=this.#t.y??0,o=[],[r,i]=this.#e.range();o.push({type:"line",x1:r,y1:n,x2:i,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let m of e)o.push({type:"line",x1:m.x,y1:n,x2:m.x,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),o.push({type:"text",content:m.label,x:m.x,y:n+t.textSize+6,anchor:"middle",fontSize:t.textSize,fill:t.textColor});return o}};var I={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function He(a){return Math.abs(a)>=1e6?`${(a/1e6).toFixed(1)}M`:Math.abs(a)>=1e3?`${(a/1e3).toFixed(1)}k`:Number.isInteger(a)?String(a):a.toFixed(1)}function Ve(a){let e=new Array(a.length).fill(false),t=0;for(;t<a.length;){let n=t;for(;n+1<a.length&&a[n+1].label===a[t].label;)n++;for(let o=t+1;o<n;o++)e[o]=true;t=n+1;}return e}var J=class{#e;#t;constructor(e){this.#e=new L({domain:e.domain,range:e.range}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??I).axisColor}get tickColor(){return (this.#t.colors??I).tickColor}get textColor(){return (this.#t.colors??I).textColor}get textSize(){return (this.#t.colors??I).textSize}generateTicks(){let e=this.#t.format??He,t=6,[n,o]=this.#e.domain(),r=o-n;if(r===0)return [{value:n,position:this.#e.map(n),label:e(n)}];let i=r/t,m=Math.pow(10,Math.floor(Math.log10(i))),s=i/m,l;s<=1.5?l=m:s<=3?l=2*m:s<=7?l=5*m:l=10*m;let u=[],c=Math.ceil(n/l)*l;for(let d=c;d<=o;d+=l)u.push({value:d,position:this.#e.map(d),label:e(d)});return u}render(){let e=this.generateTicks(),t=this.#t.colors??I,n=this.#t.x??0,o=this.#t.orientation??"vertical",r=this.#t.position??"left",i=this.#t.suppressLabelsNear??[],m=this.#t.suppressTolerancePx??8,s=u=>i.some(c=>Math.abs(c-u)<=m),l=[];if(o==="vertical"){let[u,c]=this.#e.range();l.push({type:"line",x1:n,y1:u,x2:n,y2:c,stroke:t.axisColor,strokeWidth:t.axisWidth});let d=Ve(e);e.forEach((p,f)=>{let g=s(p.position),b=d[f]?{opacity:0}:{};r==="left"?(l.push({type:"line",x1:n-4,y1:p.position,x2:n,y2:p.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),g||l.push({type:"text",content:p.label,x:n-8,y:p.position+4,anchor:"end",fontSize:11,fill:t.textColor,...b})):(l.push({type:"line",x1:n,y1:p.position,x2:n+4,y2:p.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),g||l.push({type:"text",content:p.label,x:n+8,y:p.position+4,anchor:"start",fontSize:11,fill:t.textColor,...b}));});}else {let[u,c]=this.#e.range();l.push({type:"line",x1:u,y1:n,x2:c,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let d of e)l.push({type:"line",x1:d.position,y1:n,x2:d.position,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),l.push({type:"text",content:d.label,x:d.position,y:n+18,anchor:"middle",fontSize:t.textSize,fill:t.textColor});}return l}};var Q=class{#e;#t;#n;constructor(e){let t=Object.keys(e.enumMap).map(Number).sort((n,o)=>n-o).map(String);this.#t=t,this.#e=new W({domain:t,range:e.range}),this.#n=e;}get scale(){return this.#e}generateTicks(){let{enumMap:e,showLabels:t=true,autoColor:n=true,gapValues:o}=this.#n,r=new Set(o??[]);return this.#t.map((i,m)=>{let s=Number(i),l=t?e[s]??String(s):String(s),u=this.#e.map(s),c=n?h.palette[m%h.palette.length]:void 0;return {value:s,label:l,y:u,color:c,isGap:r.has(s)}})}colorFor(e){let t=this.#t.indexOf(String(e));if(!(t===-1||!(this.#n.autoColor??true)))return h.palette[t%h.palette.length]}render(){let e=this.generateTicks(),t=this.#n.x??0,n=[];for(let o of e)o.isGap||n.push({type:"text",content:o.label,x:t,y:o.y+4,anchor:"end",fontSize:11,fill:o.color??h.textColor});return n}map(e){return this.#e.map(e)}isGap(e){return new Set(this.#n.gapValues??[]).has(e)}};var v=class a{#e;#t;static uidcnt=0;#n;constructor(e,t=[]){this.#e=e.id??"series-"+ ++a.uidcnt,this.#t=e.timeScale,this.#n=t;}get id(){return this.#e}get timeScale(){return this.#t}get data(){return this.#n}};var ee=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}points(){let e=this.#e.valueScale;return this.data.filter(t=>t.value!==null).map(t=>({x:this.timeScale.map(t.time),y:e.map(t.value),time:t.time})).sort((t,n)=>t.x-n.x)}render(){let e=this.#e,t={smoothing:e.smoothing??false,stroke:e.stroke??h.stroke,strokeWidth:e.strokeWidth??h.strokeWidth,dashed:e.dashed??false,pointStyle:e.pointStyle??"none",pointSize:e.pointSize??h.pointSize,shadowColor:e.shadowColor,shadowBlur:e.shadowBlur,shadowOffsetX:e.shadowOffsetX,shadowOffsetY:e.shadowOffsetY},n=e.pointThreshold??h.pointThreshold,o=e.gapThreshold??h.gapThreshold,r=e.id,i=x.getRuns(this.data,c=>c.value===null,o),m=i.reduce((c,d)=>c+d.length,0);if(m===0)return [];let s={timeScale:this.timeScale,valueScale:e.valueScale},l=i.map(c=>({data:c})),u=[];if(u.push(...w(l,s,{...t,id:r?`${r}-line`:void 0})),t.pointStyle&&t.pointStyle!=="none"&&m<=n)for(let c of i)u.push(...P(c,s,{...t,id:r?`${r}-marker`:void 0},()=>t.stroke));return u}};var te=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}points(){let e=this.#e.valueScale,t=[...this.data].filter(o=>o.value!==null).sort((o,r)=>o.time-r.time),n=[];for(let o=0;o<t.length;o++){let r=this.timeScale.map(t[o].time),i=e.map(t[o].value);o===0?n.push({x:r,y:i}):n.push({x:r,y:n[n.length-1].y},{x:r,y:i});}return n}render(){let e=x.getRuns(this.data,o=>o.value===null);if(e.length===0)return [];let t={timeScale:this.timeScale,valueScale:this.#e.valueScale},n=e.map(o=>({data:o}));return G(n,t,{stroke:this.#e.stroke??h.stroke,strokeWidth:this.#e.strokeWidth??h.strokeWidth,id:this.id?`${this.id}-line`:void 0})}};var ne=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}opacity(e){if(!(this.#e.countOpacity??false))return .6;let t=0;for(let n of this.data)n.count>t&&(t=n.count);return t===0?.2:.2+.8*e/t}render(){let e=this.#e,t=e.fill??h.bandFill,n=e.hatch,o=e.avgLine??false,r=e.avgLineColor??h.bandAvgLine,i=e.bandWidth??10,m=[];for(let s of this.data){if(s.min===null||s.max===null)continue;let l=this.timeScale.map(s.time),u=e.valueScale.map(s.max),c=e.valueScale.map(s.min),d=i,p=this.data.indexOf(s);if(m.push({type:"rect",x:l-d/2,y:u,w:d,h:c-u,fill:t,hatch:n,opacity:this.opacity(s.count),id:this.id?`${this.id}-slot-${p}`:void 0}),o&&s.avg!==null){let f=e.valueScale.map(s.avg);m.push({type:"line",x1:l-d/2,y1:f,x2:l+d/2,y2:f,stroke:r,strokeWidth:1,id:this.id?`${this.id}-avg-${p}`:void 0});}}return m}};var re=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}render(){let e=this.#e,t=e.minColor??h.minColor,n=e.maxColor??h.maxColor,o=e.avgColor??h.avgColor,r=e.avgDashed??true,i=e.smoothing??false,m=e.strokeWidth??h.strokeWidth,s=x.getRuns(this.data,p=>p.min===null||p.max===null||p.avg===null);if(s.length===0)return [];let l={timeScale:this.timeScale,valueScale:e.valueScale},u=[];s.forEach((p,f)=>{p.length<2||(e.fillToMax&&u.push(...H(p,l,{boundaries:[],yLow:g=>g.avg,yHigh:g=>g.max,getValue:g=>g.avg,interpolate:x.interpolateAggregatedPoint,getColor:()=>e.fillToMax,getHatch:()=>e.fillToMaxHatch},{id:this.id?`${this.id}-fillToMax-${f}`:void 0})),e.fillToMin&&u.push(...H(p,l,{boundaries:[],yLow:g=>g.avg,yHigh:g=>g.min,getValue:g=>g.avg,interpolate:x.interpolateAggregatedPoint,getColor:()=>e.fillToMin,getHatch:()=>e.fillToMinHatch},{id:this.id?`${this.id}-fillToMin-${f}`:void 0})));});let c=s.filter(p=>p.length>=2),d=p=>c.map(f=>({data:f.map(g=>({time:g.time,value:p(g)}))}));return u.push(...w(d(p=>p.max),l,{stroke:n,strokeWidth:m,smoothing:i,id:this.id?`${this.id}-max`:void 0}),...w(d(p=>p.min),l,{stroke:t,strokeWidth:m,smoothing:i,id:this.id?`${this.id}-min`:void 0}),...w(d(p=>p.avg),l,{stroke:o,strokeWidth:m,smoothing:i,dashed:r,id:this.id?`${this.id}-avg`:void 0})),u}};var oe=class extends v{#e;#t;constructor(e){super(e,e.data),this.#e=e,this.#t=[...e.zones??[]].sort((t,n)=>t.value-n.value);}#n(e){return e===0?this.#e.baseColor??h.stroke:this.#t[e-1].color}render(){let e=this.#e,t=e.baseColor??h.stroke,n={stroke:t,strokeWidth:e.strokeWidth??h.strokeWidth,smoothing:e.smoothing??false,pointStyle:e.pointStyle??"none",pointSize:e.pointSize??h.pointSize},o=e.gapThreshold??h.gapThreshold,r=e.pointThreshold??h.pointThreshold,i=x.getRuns(this.data,u=>u.value===null,o),m=i.reduce((u,c)=>u+c.length,0);if(m===0)return [];let s={timeScale:this.timeScale,valueScale:e.valueScale},l=[];for(let u of i){if(u.length<2)continue;if(e.fill){let f=e.fill.value,g=x.splitByBoundaries(u,[f],y=>y.value,x.interpolateDataPoint),b=e.valueScale.map(f);for(let y=0;y<g.length;y++){let S=g[y],$=(S.data[0].value+S.data[S.data.length-1].value)/2;if(e.fill.side==="above"==$>=f){let C=S.data.map(F=>({x:this.timeScale.map(F.time),y:e.valueScale.map(F.value)}));l.push({type:"path",id:this.id?`${this.id}-fill-${y}`:void 0,points:[...C,{x:C[C.length-1].x,y:b},{x:C[0].x,y:b}],fill:e.fill.color,hatch:e.fill.hatch,stroke:"none"});}}}let c=this.#t.map(f=>f.value),p=x.splitByBoundaries(u,c,f=>f.value,x.interpolateDataPoint).map(f=>({data:f.data,color:this.#n(f.zoneIndex)}));l.push(...w(p,s,{...n,id:this.id?`${this.id}-line`:void 0})),n.pointStyle&&n.pointStyle!=="none"&&m<=r&&l.push(...P(u,s,{...n,id:this.id?`${this.id}-marker`:void 0},f=>{let g=t;for(let b of this.#t)f.value>=b.value&&(g=b.color);return g}));}return l}};var ie=class{#e;constructor(e,t,n,o){this.#e={...e,xRange:t,y:n,height:o};}render(){let{items:e,timeScale:t,background:n,hatch:o,showAxis:r,xRange:i,y:m,height:s}=this.#e,l=[];n&&l.push({type:"rect",x:i[0],y:m,w:i[1]-i[0],h:s,fill:n,opacity:.04,stroke:"#ddd",strokeWidth:.25});for(let u of e){let c=t.map(u.startTime),d=t.map(u.endTime);if(!(d-c<1)&&(l.push({type:"rect",x:c,y:m,w:d-c,h:s,hatch:u.hatch??o,fill:u.fill??"#6b728044",stroke:u.stroke,strokeWidth:u.strokeWidth??0}),u.label)){let p=u.labelFontSize??10;l.push({type:"text",content:u.label,x:(c+d)/2,y:this.#t(u.labelBaseline,p),anchor:"middle",fontSize:p,fill:u.labelFill??"#333"});}}if(r){let u=new j({domain:t.domain(),xRange:i,y:m+s+4});l.push({type:"group",cssClass:"annotation-band-axis",commands:u.render()});}return l}#t(e,t){let{y:n,height:o}=this.#e;switch(e){case "top":return n+t*.9;case "bottom":return n+o-t*.25;default:return n+o/2+t*.35}}};var ae=class{#e;constructor(e){this.#e=e;}render(){let{data:e,valueScale:t,xRange:n,showMin:o=false,showMax:r=false,showAvg:i=true,showMedian:m=false,labelPosition:s="end",lineColor:l=h.statsLineColor,labelColor:u=h.statsLabelColor}=this.#e,c=ce.compute(e),d=[{name:"min",value:c.min,enabled:o},{name:"max",value:c.max,enabled:r},{name:"avg",value:c.avg,enabled:i},{name:"median",value:c.median,enabled:m}],p=[],[f,g]=n;for(let b of d.filter(y=>y.enabled)){let y=t.map(b.value);p.push({type:"line",x1:f,y1:y,x2:g,y2:y,stroke:l,strokeWidth:1});let S=`${b.name}: ${b.value.toFixed(1)}`;(s==="start"||s==="both")&&p.push({type:"text",content:S,x:f+4,y:y-4,anchor:"start",fontSize:10,fill:u}),(s==="end"||s==="both")&&p.push({type:"text",content:S,x:g-4,y:y-4,anchor:"end",fontSize:10,fill:u}),s==="center"&&p.push({type:"text",content:S,x:(f+g)/2,y:y-4,anchor:"middle",fontSize:10,fill:u});}return p}};var D=class{#e;#t;#n;constructor(e){this.#e=e?.locale||(typeof navigator<"u"?navigator.language:"en-US"),this.#t=e?.fallbackLocales??["en-US"],this.#n=e?.autoFormat??true;}format(e,t,n){try{let o=this.#n&&n?this.#r(e,n,t):t;return A(this.#e,o).format(new Date(e))}catch{for(let o of this.#t)try{return A(o,t).format(new Date(e))}catch{}return new Date(e).toISOString()}}formatRange(e,t){let n=this.format(e),o=this.format(t);return `${n} \u2014 ${o}`}#r(e,t,n){let o=Math.abs(e-t),r=864e5,i=36e5,m=6e4,s={};return o<m?(s.second="2-digit",s.minute="2-digit",s.hour="2-digit"):o<i?(s.minute="2-digit",s.hour="2-digit"):o<r?(s.hour="2-digit",s.minute="2-digit"):o<7*r?(s.weekday="short",s.day="numeric"):o<365*r?(s.month="short",s.day="numeric"):(s.month="short",s.year="numeric"),{...n,...s}}};var M=class a{#e;#t;_compact;#n;constructor(e){this.#e=e?.unit??"",this.#t=e?.decimals??1,this._compact=e?.compact??false,this.#n=e?.custom;}format(e){if(this.#n)return this.#n(e);let t;return this._compact&&Math.abs(e)>=1e6?t=`${(e/1e6).toFixed(this.#t)}M`:this._compact&&Math.abs(e)>=1e3?t=`${(e/1e3).toFixed(this.#t)}k`:t=e.toFixed(this.#t),this.#e?`${t}${this.#e}`:t}formatRange(e,t){return `${this.format(e)} \u2014 ${this.format(t)}`}static unit(e,t=1){return new a({unit:e,decimals:t})}static temperature(e="\xB0C"){return new a({unit:e,decimals:1})}static percentage(){return new a({unit:"%",decimals:0})}};var _=class a{#e;#t;#n;constructor(e){this.#e=e?.map??{},this.#t=e?.fallback??(t=>String(t)),this.#n=e?.showValue??false;}format(e){let t=this.#e[e]??this.#t(e);return this.#n?`(${e}) ${t}`:t}has(e){return e in this.#e}labels(){return Object.values(this.#e)}values(){return Object.keys(this.#e).map(Number)}static fromLabels(e,t=false){let n={};return e.forEach((o,r)=>{n[r]=o;}),new a({map:n,showValue:t})}};var Ee={time:new D,value:new M,enum:new _};var Ne={...h};function se(){return Ne}function le(a,e){let t=se();return {color:a.color??t.stroke,width:a.width??t.strokeWidth,style:a.style??"solid",smoothing:a.smoothing??false,shape:a.shape??(e.seriesType==="step"?"step":"line"),gapThreshold:a.gapThreshold??t.gapThreshold,opacity:a.opacity??1}}function pe(a){let e=a.style?.line;return e===false?[]:e===void 0?[le({},a)]:Array.isArray(e)?e.map(t=>le(t,a)):[le(e,a)]}function fe(a){let e=a.style?.markers;if(!e?.type||e.type==="none")return;let t=se(),o=(a.style?.line&&!Array.isArray(a.style.line)?a.style.line.color:void 0)??t.stroke;return {type:e.type,size:e.size??t.pointSize,stroke:e.stroke??o,fill:e.fill??"#ffffff",strokeWidth:e.strokeWidth??1,threshold:e.threshold}}function ge(a){let e=a.style?.shadow;if(!(!e?.color||e.color==="transparent"||e.color==="none"))return {color:e.color,blur:e.blur??4,offsetX:e.offsetX??0,offsetY:e.offsetY??0}}function ye(a){return a.style?.gap}function be(a){return a.style?.fill}function Ge(a){return {lines:pe(a),fill:be(a),markers:fe(a),shadow:ge(a),gap:ye(a),id:a.style?.id??a.id}}/*!
32
28
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
33
29
  * MIT with Attribution: free use incl. commercial requires visible credit to
34
30
  * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
@@ -47,4 +43,4 @@ var V=class{};var x=class{static interpolateDataPoint(a,e,t){return {time:a.time
47
43
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
48
44
  * MIT with Attribution: free use incl. commercial must have visible credit to
49
45
  * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
50
- */export{re as AnnotationBandSeries,A as BandScale,ee as BandSeries,Z as Clip,K as EnumAxis,_ as EnumFormatter,Be as Formatters,U as Layout,Q as LineSeries,L as LinearScale,te as MinMaxAvgSeries,V as Renderer,oe as StatsOverlay,J as StepSeries,k as TIME_INTERVALS,j as TimeAxis,M as TimeFormatter,R as TimeScale,q as ValueAxis,D as ValueFormatter,ne as ZonedLineSeries,ue as getHatch,we as measureLegend,je as renderAnnotations,xe as renderArea,$e as renderGaps,Te as renderGrid,Ae as renderHighlights,Ce as renderLegend,w as renderLine,Pe as renderMarkers,P as renderSeriesMarkers,Se as renderSplitLine,E as renderStep,De as renderThresholds,B as renderZonedArea,fe as resolveFill,pe as resolveGap,ce as resolveLines,de as resolveMarkers,ze as resolveSeriesStyle,he as resolveShadow,X as slugify,h as theme};
46
+ */export{ie as AnnotationBandSeries,W as BandScale,ne as BandSeries,K as Clip,Q as EnumAxis,_ as EnumFormatter,Ee as Formatters,q as Layout,ee as LineSeries,L as LinearScale,re as MinMaxAvgSeries,N as Renderer,ae as StatsOverlay,te as StepSeries,k as TIME_INTERVALS,j as TimeAxis,D as TimeFormatter,R as TimeScale,J as ValueAxis,M as ValueFormatter,oe as ZonedLineSeries,de as getHatch,Le as measureLegend,Be as renderAnnotations,we as renderArea,Re as renderGaps,Me as renderGrid,je as renderHighlights,De as renderLegend,w as renderLine,Oe as renderMarkers,P as renderSeriesMarkers,Ce as renderSplitLine,G as renderStep,Pe as renderThresholds,H as renderZonedArea,be as resolveFill,ye as resolveGap,pe as resolveLines,fe as resolveMarkers,Ge as resolveSeriesStyle,ge as resolveShadow,U as slugify,h as theme};
@@ -1,4 +1,4 @@
1
- import { o as DrawCommand, s as DrawGroup, _ as PointStyleType } from './scale-DFyECKZq.js';
1
+ import { D as DrawCommand, a1 as DrawGroup, P as PointStyleType } from './scale-CWAa8-uO.js';
2
2
 
3
3
  /** Output format type for the renderer (SVG string, Canvas, or nothing). */
4
4
  type RenderType = "svg" | "canvas" | "none";
@@ -243,4 +243,4 @@ declare class Layout {
243
243
  static default(width?: number, height?: number): Layout;
244
244
  }
245
245
 
246
- export { Layout as L, type Marker as M, type RenderOutput as R, type LayoutConfig as a, type LayoutResult as b, type LegendConfig as c, type LegendItem as d, type LegendOrientation as e, Renderer as f, measureLegend as m, renderLegend as r, theme as t };
246
+ export { type LegendOrientation as L, type Marker as M, Renderer as R, type LegendItem as a, type LayoutResult as b, type RenderOutput as c, Layout as d, type LayoutConfig as e, type LegendConfig as f, measureLegend as m, renderLegend as r, theme as t };
@@ -129,6 +129,11 @@ interface DrawText {
129
129
  opacity?: number;
130
130
  /** Rotation in degrees, around (x, y). Used e.g. for vertical axis labels. */
131
131
  rotate?: number;
132
+ /** Wird als SVG-Attribut `dominant-baseline` ausgegeben. Achtung: nur
133
+ * "middle" ist dort ein gueltiger Wert -- "top"/"bottom" fallen im Browser
134
+ * auf "auto" zurueck. Der Go-Port reicht sie genauso durch; eine echte
135
+ * Abbildung (top -> text-top, bottom -> text-bottom) waere eine Aenderung
136
+ * in beiden Bibliotheken samt neuer Go-Golden. */
132
137
  textBaseline?: "top" | "middle" | "bottom";
133
138
  /** Optional SVG `id` attribute for this element. */
134
139
  id?: string;
@@ -745,11 +750,6 @@ interface AnnotationBandConfig {
745
750
  items: AnnotationBandItem[];
746
751
  }
747
752
 
748
- /*!
749
- * MLTimeGraph — Copyright (c) 2026 Michael Lechner
750
- * MIT with Attribution: free use incl. commercial requires visible credit to
751
- * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
752
- */
753
753
  /** Base scale interface – maps data values to pixel coordinates */
754
754
  interface ScaleConfig {
755
755
  /** Pixel range (output domain). Defaults to [0, width] or [0, height] */
@@ -847,4 +847,4 @@ declare class BandScale implements Scale {
847
847
  positions(): Map<string, number>;
848
848
  }
849
849
 
850
- export { type RectParams as $, type AggregatedPoint as A, BandScale as B, type CircleParams as C, type Dashstyle_t as D, type EnumMap as E, type FillBound as F, type FillSpec as G, type FillStyle as H, type Gap as I, type GapConfig as J, type GapLabel as K, type GapRegion as L, type GapStyle as M, type GapsConfig as N, type HatchVariant as O, type Highlight as P, type LabelAnchor as Q, type LineDashStyle as R, type LineParams as S, type LineStyle as T, type LineVariant as U, LinearScale as V, type LinearScaleConfig as W, type MarkerStyle as X, type PathParams as Y, type Point as Z, type PointStyleType as _, type AggregatedSeries as a, type Scale as a0, type ScaleConfig as a1, type SensorType as a2, type SeriesOverlay as a3, type SeriesOverlayKind as a4, type SeriesStyle as a5, type SeriesType as a6, type ShadowStyle as a7, TIME_INTERVALS as a8, type TextParams as a9, type Threshold as aa, type ThresholdLabelConfig as ab, type ThresholdLabelPosition as ac, TimeScale as ad, type TimeScaleConfig as ae, type TimeSeries as af, getHatch as ag, type AggregationConfig as b, type AggregationMode as c, type Annotation as d, type AnnotationBandConfig as e, type AnnotationBandItem as f, type AnySeries as g, type AxisOrientation as h, type AxisPosition as i, type BandScaleConfig as j, type DataPoint as k, type DataPointRef as l, type DomainScaleConfig as m, type DrawCircle as n, type DrawCommand as o, type DrawGap as p, type DrawGapType_t as q, type DrawGradient as r, type DrawGroup as s, type DrawLine as t, type DrawPath as u, type DrawRect as v, type DrawText as w, type FillDirectionType as x, type FillRegion as y, type FillSide as z };
850
+ export { type DrawGapType_t as $, type AnySeries as A, type SensorType as B, type SeriesOverlay as C, type DrawCommand as D, type EnumMap as E, type FillSpec as F, type Gap as G, type Highlight as H, type SeriesOverlayKind as I, type SeriesType as J, type ShadowStyle as K, type LineVariant as L, type MarkerStyle as M, type ThresholdLabelConfig as N, BandScale as O, type PointStyleType as P, type Point as Q, type AxisOrientation as R, type SeriesStyle as S, type Threshold as T, type AxisPosition as U, type BandScaleConfig as V, type CircleParams as W, type Dashstyle_t as X, type DomainScaleConfig as Y, type DrawCircle as Z, type DrawGap as _, type GapsConfig as a, type DrawGradient as a0, type DrawGroup as a1, type DrawLine as a2, type DrawPath as a3, type DrawRect as a4, type DrawText as a5, type LabelAnchor as a6, type LineParams as a7, type LinearScaleConfig as a8, type PathParams as a9, type RectParams as aa, type Scale as ab, type ScaleConfig as ac, TIME_INTERVALS as ad, type TextParams as ae, type TimeScaleConfig as af, getHatch as ag, type Annotation as b, type AnnotationBandConfig as c, TimeScale as d, LinearScale as e, type TimeSeries as f, type HatchVariant as g, type ThresholdLabelPosition as h, type AnnotationBandItem as i, type AggregatedPoint as j, type AggregatedSeries as k, type DataPoint as l, type AggregationConfig as m, type AggregationMode as n, type DataPointRef as o, type FillBound as p, type FillDirectionType as q, type FillRegion as r, type FillSide as s, type FillStyle as t, type GapConfig as u, type GapLabel as v, type GapRegion as w, type GapStyle as x, type LineDashStyle as y, type LineStyle as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ml-time-graph",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "TypeScript library for time-series chart rendering — DOM-free SVG output (works in the browser and on the server).",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
@@ -33,12 +33,6 @@
33
33
  "API_DESIGN.md",
34
34
  "LICENSE"
35
35
  ],
36
- "scripts": {
37
- "build": "tsup",
38
- "test": "vitest run",
39
- "typecheck": "tsc --noEmit",
40
- "prepublishOnly": "tsup"
41
- },
42
36
  "keywords": [
43
37
  "chart",
44
38
  "time-series",
@@ -52,7 +46,7 @@
52
46
  "mkt"
53
47
  ],
54
48
  "devDependencies": {
55
- "ml-time-analyze": "workspace:*"
49
+ "ml-time-analyze": "0.1.1"
56
50
  },
57
51
  "author": "Michael Lechner",
58
52
  "license": "SEE LICENSE IN LICENSE",
@@ -67,5 +61,10 @@
67
61
  },
68
62
  "engines": {
69
63
  "node": ">=18"
64
+ },
65
+ "scripts": {
66
+ "build": "tsup",
67
+ "test": "vitest run",
68
+ "typecheck": "tsc --noEmit"
70
69
  }
71
- }
70
+ }