diff --git a/demos/months.html b/demos/months.html index 4eb6d117..97ff8bce 100644 --- a/demos/months.html +++ b/demos/months.html @@ -10,29 +10,32 @@ \ No newline at end of file diff --git a/demos/timezones-dst.html b/demos/timezones-dst.html index 85d5a18f..0933c018 100644 --- a/demos/timezones-dst.html +++ b/demos/timezones-dst.html @@ -7,32 +7,44 @@ \ No newline at end of file diff --git a/dist/uPlot.cjs.js b/dist/uPlot.cjs.js index 224318f0..53e3dca6 100644 --- a/dist/uPlot.cjs.js +++ b/dist/uPlot.cjs.js @@ -943,8 +943,23 @@ const subs = { s: d => d.getSeconds(), // 374 fff: d => zeroPad3(d.getMilliseconds()), + + /* + // this really only makes sense for DateZoned + // -05:00 + tzo: d => { + let o = d.getTimezoneOffset(); + let s = o > 0 ? '-' : '+'; + o = abs(o); + let hh = zeroPad2(floor(o / 60)); + let mm = zeroPad2(o % 60); + return `${s}${hh}:${mm}`; + } + */ }; +// export const iso8601 = fmtDate('{YYYY}-{MM}-{DD}T{HH}:{mm}:{ss}.{fff}{tzo}'); + function fmtDate(tpl, names) { names = names || engNames; let parts = []; @@ -966,22 +981,254 @@ function fmtDate(tpl, names) { const localTz = new Intl.DateTimeFormat().resolvedOptions().timeZone; -// https://stackoverflow.com/questions/15141762/how-to-initialize-a-javascript-date-to-a-particular-time-zone/53652131#53652131 -function tzDate(date, tz) { - let date2; +function tzDate(dateOrTs, tz) { + if (tz == null || tz == localTz) + return typeof dateOrTs == 'number' ? new Date(dateOrTs) : dateOrTs; - // perf optimization - if (tz == 'UTC' || tz == 'Etc/UTC') - date2 = new Date(+date + date.getTimezoneOffset() * 6e4); - else if (tz == localTz) - date2 = date; - else { - date2 = new Date(date.toLocaleString('en-US', {timeZone: tz})); - date2.setMilliseconds(date.getMilliseconds()); + let d = new DateZoned(dateOrTs); + d.setTimeZone(tz); + return d; +} + +const twoDigit = '2-digit'; + +const fmtrOpts = { + weekday: "short", + year: 'numeric', + month: twoDigit, + day: twoDigit, + hour: twoDigit, + minute: twoDigit, + second: twoDigit, + fractionalSecondDigits: 3, + timeZoneName: 'longOffset', +}; + +/* +// this might be a bit easier to parse to avoid negative .slice() offsets +new Intl.DateTimeFormat('en-US', { + hour12: false, + timeZone: 'Europe/London', + year: 'numeric', + month: '2-digit', + day: '2-digit', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + timeZoneName: 'longOffset', + weekday: 'short', + fractionalSecondDigits: 3, +}).format(new Date()); + +// Tue, 07/22/2025, 07:02:37.043 GMT+01:00 +*/ + +const tzFmt = {}; + +function getFormatter(tz) { + if (tzFmt[tz] == null) + tzFmt[tz] = new Intl.DateTimeFormat("sv", {...fmtrOpts, timeZone: tz}).format; + + return tzFmt[tz]; +} + +class DateZoned extends Date { + tz = null; + #utc = false; + // sön, 1972-10-15 17:25:23,434 GMT+01:00 + #str = null; + + constructor(...args) { + super(...args); + + if (args[0] instanceof DateZoned) { + this.tz = args[0].tz; + this.#str = args[0].#str; + this.#utc = args[0].#utc; + } + } + + #get(utcMeth, locMeth, fr, to, add = 0) { + let s = this.#str; + return this.#utc ? utcMeth.call(this) : s == null ? locMeth.call(this) : Number(s.slice(fr,to)) + add; + } + + setTimeZone(tz) { + this.tz = tz; + + if (tz == 'UTC' || tz == 'Etc/UTC') + this.#utc = true; + else { + let fmt = getFormatter(tz); + let f = fmt(this); + + if (f.endsWith('GMT')) + f += '+00:00'; + + this.#str = f; + } + } + + getFullYear() { + return this.#get(this.getUTCFullYear, super.getFullYear, -33, -29); + } + + getMonth() { + return this.#get(this.getUTCMonth, super.getMonth, -28, -26, -1); + } + + getDate() { + return this.#get(this.getUTCDate, super.getDate, -25, -23); + } + + getHours() { + return this.#get(this.getUTCHours, super.getHours, -22, -20); + } + + getMinutes() { + return this.#get(this.getUTCMinutes, super.getMinutes, -19, -17); + } + + getSeconds() { + return this.#get(this.getUTCSeconds, super.getSeconds, -16, -14); + } + + getMilliseconds() { + return this.#get(this.getUTCMilliseconds, super.getMilliseconds, -13, -10); + } + + getDay() { + let s = this.#str; + return this.#utc ? this.getUTCDay() : s == null ? super.getDay() : ( + s[0] == 's' ? 0 : // sön + s[0] == 'm' ? 1 : // mån + s[1] == 'i' ? 2 : // tis + s[0] == 'o' ? 3 : // ons + s[1] == 'o' ? 4 : // tors + s[0] == 'f' ? 5 : // fre + s[0] == 'l' ? 6 : // lör + -1 + ); + } + + getTimezoneOffset() { + let s = this.#str; + return this.#utc ? 0 : s == null ? super.getTimezoneOffset() : (60 * Number(s.slice(-5,-3)) + Number(s.slice(-2))) * (s.at(-6) == '-' ? -1 : 1); + } +} + +function getDayOfYear(date) { + let y = date.getFullYear(); + let m = date.getMonth() + 1; + let d = date.getDate(); + + // https://stackoverflow.com/a/27790471 + return --m*31-(m>1?(1054267675>>m*3-6&7)-(y&3||!(y%25)&&y&15?0:1):0)+d; +} + +// these can be done through just incrRoundDn of 1e3 or 60 * 1e3 +// export const PERIOD_SECOND = 0; +// export const PERIOD_MINUTE = 1; + +// this might be needed for tzs where DST is not whole hours? +// otherwise incrRoundDn of 3600 * 1e3 +// export const PERIOD_HOUR = 2; + +// thse need special handling due to day length changing due to DST +const PERIOD_DAY = 3; +const PERIOD_MONTH = 4; +const PERIOD_YEAR = 5; +// export const PERIOD_WEEK; + +// get start of period, requires DateZoned and period const +function floorSOP(dz, per) { + let ts = dz.getTime(); + + // initial guess (assumes no DST) + let ts2 = ts - ( + dz.getMilliseconds() + + dz.getSeconds() * 1e3 + + dz.getMinutes() * 60 * 1e3 + + dz.getHours() * 3600 * 1e3 + + ( + ( + per == PERIOD_MONTH ? dz.getDate() - 1: + per == PERIOD_YEAR ? getDayOfYear(dz) - 1: + 0 + ) + * 24 * 3600 * 1e3 + ) + ); + + // if (ts2 == ts) + // return dz; + + let dz2 = new DateZoned(ts2); + dz2.setTimeZone(dz.tz); + + let h2 = dz2.getHours(); + + // we want hours to be 0 + if (h2 > 0) { + let dstAdj = h2 > 12 ? 24 - h2 : -h2; + dz2 = new DateZoned(ts2 + dstAdj * 3600 * 1e3); + dz2.setTimeZone(dz.tz); } - return date2; + return dz2; +} + +// tweaks the time by +/- 1hr to make sure it lands on 12am +// used for correcting optimistically-computed ticks from adding fixed increments +// export function sopNear(dz, per) {} + +/* +let fmt = fmtDate('{YYYY}-{MM}-{DD}T{HH}:{mm}:{ss}.{fff}{tzo}'); + +{ + let d = new DateZoned(1554274800000); // post-roll date + d.setTimeZone('Europe/London'); + let sod = getSOP(d, PERIOD_DAY); + console.log(sod.getTime() / 1e3); + console.log(fmt(sod)); +} + +{ + let d = new DateZoned(1554274800000); // post-roll date + d.setTimeZone('America/Chicago'); + let sod = getSOP(d, PERIOD_DAY); + console.log(sod.getTime() / 1e3); + console.log(fmt(sod)); +} + +{ + let d = new DateZoned(1554004800000); // few hours after london spring forward + d.setTimeZone('Europe/London'); + let sod = getSOP(d, PERIOD_DAY); + console.log(sod.getTime() / 1e3); + console.log(fmt(sod)); +} + +{ + let d = new DateZoned(1572156000000); // few hours after london fall back + d.setTimeZone('Europe/London'); + let sod = getSOP(d, PERIOD_DAY); + console.log(sod.getTime() / 1e3); + console.log(fmt(sod)); } +*/ + + +/* +TODO: + +2024 - leap year + start of year before feb vs after + start of month in dst fwd month / bwd month + start of day in dst fwd day / bwd day + +Australia/Darwin +*/ //export const series = []; @@ -1102,78 +1349,129 @@ function genTimeStuffs(ms) { let splits = []; let isYr = foundIncr >= y; let isMo = foundIncr >= mo && foundIncr < y; + let isDays = foundIncr >= d && foundIncr < mo; + let isHours = foundIncr > h && foundIncr < d; // get the timezone-adjusted date let minDate = tzDate(scaleMin); let minDateTs = roundDec(minDate * ms, 3); // get ts of 12am (this lands us at or before the original scaleMin) - let minMin = mkDate(minDate.getFullYear(), isYr ? 0 : minDate.getMonth(), isMo || isYr ? 1 : minDate.getDate()); + let minMin = floorSOP(minDate, isYr || isMo ? PERIOD_YEAR : isDays ? PERIOD_MONTH : PERIOD_DAY); // should we do PERIOD_HOUR? let minMinTs = roundDec(minMin * ms, 3); - if (isMo || isYr) { - let moIncr = isMo ? foundIncr / mo : 0; - let yrIncr = isYr ? foundIncr / y : 0; - // let tzOffset = scaleMin - minDateTs; // needed? - let split = minDateTs == minMinTs ? minDateTs : roundDec(mkDate(minMin.getFullYear() + yrIncr, minMin.getMonth() + moIncr, 1) * ms, 3); - let splitDate = new Date(round(split / ms)); - let baseYear = splitDate.getFullYear(); - let baseMonth = splitDate.getMonth(); + if (isDays) { + let incrDays = foundIncr / d; - for (let i = 0; split <= scaleMax; i++) { - let next = mkDate(baseYear + yrIncr * i, baseMonth + moIncr * i, 1); - let offs = next - tzDate(roundDec(next * ms, 3)); + // incrs to add to month baseline + let skip = floor((minDate.getDate() - 1) / incrDays); + let split = minMinTs + (foundIncr * skip); - split = roundDec((+next + offs) * ms, 3); + do { + let date = tzDate(split); + // adjust for DST misses + let hour = date.getHours(); + if (hour != 0) { + split += hour > 12 ? h : -h; + date = tzDate(split); + } + + // rolled over into next month onto non-divisible incr, reset baseline + if ((date.getDate() - 1) % incrDays > 0) { + date = floorSOP(date, PERIOD_MONTH); + split = date.getTime() * ms; - if (split <= scaleMax) + // make sure we're not rendering a collision between 31 and 1 + if (split - splits[splits.length - 1] < foundIncr * 0.7) + splits.pop(); + } + + if (split > scaleMax) + break; + + if (split >= scaleMin) splits.push(split); - } - } - else { - let incr0 = foundIncr >= d ? d : foundIncr; - let tzOffset = floor(scaleMin) - floor(minDateTs); - let split = minMinTs + tzOffset + incrRoundUp(minDateTs - minMinTs, incr0); - splits.push(split); - let date0 = tzDate(split); + split += foundIncr; + } while (1); + } + else if (isMo || isYr) { + let subIncrs = 1; + let subIncrDays = 1; + let periodType = 0; + let periodMin = 0; + + if (isMo) { + subIncrs = foundIncr / mo; + subIncrDays = 32; + periodType = PERIOD_MONTH; + periodMin = minDate.getMonth(); + } + else if (isYr) { + subIncrs = foundIncr / y; + subIncrDays = 366; + periodType = PERIOD_YEAR; + periodMin = minDate.getYear(); + } - let prevHour = date0.getHours() + (date0.getMinutes() / m) + (date0.getSeconds() / h); - let incrHours = foundIncr / h; + foundIncr = subIncrs * subIncrDays * d; - let minSpace = self.axes[axisIdx]._space; - let pctSpace = foundSpace / minSpace; + let skip = floor(periodMin / subIncrDays); + let split = minMinTs + (foundIncr * skip); - while (1) { - split = roundDec(split + foundIncr, ms == 1 ? 0 : 3); + do { + let date = floorSOP(tzDate(split), periodType); + split = date.getTime() * ms; if (split > scaleMax) break; - if (incrHours > 1) { - let expectedHour = floor(roundDec(prevHour + incrHours, 6)) % 24; - let splitDate = tzDate(split); - let actualHour = splitDate.getHours(); + if (split >= scaleMin) + splits.push(split); - let dstShift = actualHour - expectedHour; + split += foundIncr; + } while (1); + } + else if (isHours) { + let incrHours = foundIncr / h; - if (dstShift > 1) - dstShift = -1; + let skip = floor(minDate.getHours() / incrHours); + let split = minMinTs + (foundIncr * skip); - split -= dstShift * h; + do { + let date = tzDate(split); - prevHour = (prevHour + incrHours) % 24; + // adjust for DST misses + let hour = date.getHours(); + if (hour % incrHours > 0) { + let hour2 = tzDate(split + h).getHours(); + split += hour2 % incrHours == 0 ? h : -h; + } - // add a tick only if it's further than 70% of the min allowed label spacing - let prevSplit = splits[splits.length - 1]; - let pctIncr = roundDec((split - prevSplit) / foundIncr, 3); + if (split > scaleMax) + break; - if (pctIncr * pctSpace >= .7) - splits.push(split); - } - else + if (split >= scaleMin) splits.push(split); - } + + split += foundIncr; + // expect = (expect + incrHours) % 24; + } while (1); + } + else { + let split = minMinTs + incrRoundUp(minDateTs - minMinTs, foundIncr); + + do { + if (split > scaleMax) + break; + + if (split >= scaleMin) + splits.push(split); + + split += foundIncr; + } while (1); + + splits.push(split); } return splits; @@ -1262,10 +1560,6 @@ function timeAxisVal(tzDate, dateTpl) { return (self, splits, axisIdx, foundSpace, foundIncr) => splits.map(split => stamp(tzDate(split))); } -function mkDate(y, m, d) { - return new Date(y, m, d); -} - function timeSeriesStamp(stampCfg, fmtDate) { return fmtDate(stampCfg); } diff --git a/dist/uPlot.d.ts b/dist/uPlot.d.ts index b711e935..357dc5c3 100644 --- a/dist/uPlot.d.ts +++ b/dist/uPlot.d.ts @@ -150,8 +150,8 @@ declare class uPlot { /** creates an efficient formatter for Date objects from a template string, e.g. {YYYY}-{MM}-{DD} */ static fmtDate(tpl: string, names?: uPlot.DateNames): (date: Date) => string; - /** converts a Date into new Date that's time-adjusted for the given IANA Time Zone Name */ - static tzDate(date: Date, tzName: string): Date; + /** converts a Date or ms timestamp into new Date that's time-adjusted for the given IANA Time Zone Name */ + static tzDate(dateOrTs: Date | number, tzName: string): DateZoned; /** outerJoins multiple data tables on table[0] values */ static join(tables: uPlot.AlignedData[], nullModes?: uPlot.JoinNullMode[][]): uPlot.AlignedData; @@ -228,6 +228,14 @@ declare namespace uPlot { ...yValues: ((number | null | undefined)[] | TypedArray)[], ] + export class DateZoned extends Date { + tz: string; + #utc: boolean; + // sön, 1972-10-15 17:25:23,434 GMT+01:00 + #str: string; + setTimeZone: (tzName: string) => void; + } + export interface DateNames { /** long month names */ MMMM: string[]; @@ -329,7 +337,7 @@ declare namespace uPlot { export type DateFormatterFactory = (tpl: string) => (date: Date) => string; - export type LocalDateFromUnix = (ts: number) => Date; + export type LocalDateFromUnix = (ts: number) => DateZoned; export const enum DrawOrderKey { Axes = 'axes', diff --git a/dist/uPlot.esm.js b/dist/uPlot.esm.js index 674a044e..cd134a20 100644 --- a/dist/uPlot.esm.js +++ b/dist/uPlot.esm.js @@ -941,8 +941,23 @@ const subs = { s: d => d.getSeconds(), // 374 fff: d => zeroPad3(d.getMilliseconds()), + + /* + // this really only makes sense for DateZoned + // -05:00 + tzo: d => { + let o = d.getTimezoneOffset(); + let s = o > 0 ? '-' : '+'; + o = abs(o); + let hh = zeroPad2(floor(o / 60)); + let mm = zeroPad2(o % 60); + return `${s}${hh}:${mm}`; + } + */ }; +// export const iso8601 = fmtDate('{YYYY}-{MM}-{DD}T{HH}:{mm}:{ss}.{fff}{tzo}'); + function fmtDate(tpl, names) { names = names || engNames; let parts = []; @@ -964,22 +979,254 @@ function fmtDate(tpl, names) { const localTz = new Intl.DateTimeFormat().resolvedOptions().timeZone; -// https://stackoverflow.com/questions/15141762/how-to-initialize-a-javascript-date-to-a-particular-time-zone/53652131#53652131 -function tzDate(date, tz) { - let date2; +function tzDate(dateOrTs, tz) { + if (tz == null || tz == localTz) + return typeof dateOrTs == 'number' ? new Date(dateOrTs) : dateOrTs; - // perf optimization - if (tz == 'UTC' || tz == 'Etc/UTC') - date2 = new Date(+date + date.getTimezoneOffset() * 6e4); - else if (tz == localTz) - date2 = date; - else { - date2 = new Date(date.toLocaleString('en-US', {timeZone: tz})); - date2.setMilliseconds(date.getMilliseconds()); + let d = new DateZoned(dateOrTs); + d.setTimeZone(tz); + return d; +} + +const twoDigit = '2-digit'; + +const fmtrOpts = { + weekday: "short", + year: 'numeric', + month: twoDigit, + day: twoDigit, + hour: twoDigit, + minute: twoDigit, + second: twoDigit, + fractionalSecondDigits: 3, + timeZoneName: 'longOffset', +}; + +/* +// this might be a bit easier to parse to avoid negative .slice() offsets +new Intl.DateTimeFormat('en-US', { + hour12: false, + timeZone: 'Europe/London', + year: 'numeric', + month: '2-digit', + day: '2-digit', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + timeZoneName: 'longOffset', + weekday: 'short', + fractionalSecondDigits: 3, +}).format(new Date()); + +// Tue, 07/22/2025, 07:02:37.043 GMT+01:00 +*/ + +const tzFmt = {}; + +function getFormatter(tz) { + if (tzFmt[tz] == null) + tzFmt[tz] = new Intl.DateTimeFormat("sv", {...fmtrOpts, timeZone: tz}).format; + + return tzFmt[tz]; +} + +class DateZoned extends Date { + tz = null; + #utc = false; + // sön, 1972-10-15 17:25:23,434 GMT+01:00 + #str = null; + + constructor(...args) { + super(...args); + + if (args[0] instanceof DateZoned) { + this.tz = args[0].tz; + this.#str = args[0].#str; + this.#utc = args[0].#utc; + } + } + + #get(utcMeth, locMeth, fr, to, add = 0) { + let s = this.#str; + return this.#utc ? utcMeth.call(this) : s == null ? locMeth.call(this) : Number(s.slice(fr,to)) + add; + } + + setTimeZone(tz) { + this.tz = tz; + + if (tz == 'UTC' || tz == 'Etc/UTC') + this.#utc = true; + else { + let fmt = getFormatter(tz); + let f = fmt(this); + + if (f.endsWith('GMT')) + f += '+00:00'; + + this.#str = f; + } + } + + getFullYear() { + return this.#get(this.getUTCFullYear, super.getFullYear, -33, -29); + } + + getMonth() { + return this.#get(this.getUTCMonth, super.getMonth, -28, -26, -1); + } + + getDate() { + return this.#get(this.getUTCDate, super.getDate, -25, -23); + } + + getHours() { + return this.#get(this.getUTCHours, super.getHours, -22, -20); + } + + getMinutes() { + return this.#get(this.getUTCMinutes, super.getMinutes, -19, -17); + } + + getSeconds() { + return this.#get(this.getUTCSeconds, super.getSeconds, -16, -14); + } + + getMilliseconds() { + return this.#get(this.getUTCMilliseconds, super.getMilliseconds, -13, -10); + } + + getDay() { + let s = this.#str; + return this.#utc ? this.getUTCDay() : s == null ? super.getDay() : ( + s[0] == 's' ? 0 : // sön + s[0] == 'm' ? 1 : // mån + s[1] == 'i' ? 2 : // tis + s[0] == 'o' ? 3 : // ons + s[1] == 'o' ? 4 : // tors + s[0] == 'f' ? 5 : // fre + s[0] == 'l' ? 6 : // lör + -1 + ); + } + + getTimezoneOffset() { + let s = this.#str; + return this.#utc ? 0 : s == null ? super.getTimezoneOffset() : (60 * Number(s.slice(-5,-3)) + Number(s.slice(-2))) * (s.at(-6) == '-' ? -1 : 1); + } +} + +function getDayOfYear(date) { + let y = date.getFullYear(); + let m = date.getMonth() + 1; + let d = date.getDate(); + + // https://stackoverflow.com/a/27790471 + return --m*31-(m>1?(1054267675>>m*3-6&7)-(y&3||!(y%25)&&y&15?0:1):0)+d; +} + +// these can be done through just incrRoundDn of 1e3 or 60 * 1e3 +// export const PERIOD_SECOND = 0; +// export const PERIOD_MINUTE = 1; + +// this might be needed for tzs where DST is not whole hours? +// otherwise incrRoundDn of 3600 * 1e3 +// export const PERIOD_HOUR = 2; + +// thse need special handling due to day length changing due to DST +const PERIOD_DAY = 3; +const PERIOD_MONTH = 4; +const PERIOD_YEAR = 5; +// export const PERIOD_WEEK; + +// get start of period, requires DateZoned and period const +function floorSOP(dz, per) { + let ts = dz.getTime(); + + // initial guess (assumes no DST) + let ts2 = ts - ( + dz.getMilliseconds() + + dz.getSeconds() * 1e3 + + dz.getMinutes() * 60 * 1e3 + + dz.getHours() * 3600 * 1e3 + + ( + ( + per == PERIOD_MONTH ? dz.getDate() - 1: + per == PERIOD_YEAR ? getDayOfYear(dz) - 1: + 0 + ) + * 24 * 3600 * 1e3 + ) + ); + + // if (ts2 == ts) + // return dz; + + let dz2 = new DateZoned(ts2); + dz2.setTimeZone(dz.tz); + + let h2 = dz2.getHours(); + + // we want hours to be 0 + if (h2 > 0) { + let dstAdj = h2 > 12 ? 24 - h2 : -h2; + dz2 = new DateZoned(ts2 + dstAdj * 3600 * 1e3); + dz2.setTimeZone(dz.tz); } - return date2; + return dz2; +} + +// tweaks the time by +/- 1hr to make sure it lands on 12am +// used for correcting optimistically-computed ticks from adding fixed increments +// export function sopNear(dz, per) {} + +/* +let fmt = fmtDate('{YYYY}-{MM}-{DD}T{HH}:{mm}:{ss}.{fff}{tzo}'); + +{ + let d = new DateZoned(1554274800000); // post-roll date + d.setTimeZone('Europe/London'); + let sod = getSOP(d, PERIOD_DAY); + console.log(sod.getTime() / 1e3); + console.log(fmt(sod)); +} + +{ + let d = new DateZoned(1554274800000); // post-roll date + d.setTimeZone('America/Chicago'); + let sod = getSOP(d, PERIOD_DAY); + console.log(sod.getTime() / 1e3); + console.log(fmt(sod)); +} + +{ + let d = new DateZoned(1554004800000); // few hours after london spring forward + d.setTimeZone('Europe/London'); + let sod = getSOP(d, PERIOD_DAY); + console.log(sod.getTime() / 1e3); + console.log(fmt(sod)); +} + +{ + let d = new DateZoned(1572156000000); // few hours after london fall back + d.setTimeZone('Europe/London'); + let sod = getSOP(d, PERIOD_DAY); + console.log(sod.getTime() / 1e3); + console.log(fmt(sod)); } +*/ + + +/* +TODO: + +2024 - leap year + start of year before feb vs after + start of month in dst fwd month / bwd month + start of day in dst fwd day / bwd day + +Australia/Darwin +*/ //export const series = []; @@ -1100,78 +1347,129 @@ function genTimeStuffs(ms) { let splits = []; let isYr = foundIncr >= y; let isMo = foundIncr >= mo && foundIncr < y; + let isDays = foundIncr >= d && foundIncr < mo; + let isHours = foundIncr > h && foundIncr < d; // get the timezone-adjusted date let minDate = tzDate(scaleMin); let minDateTs = roundDec(minDate * ms, 3); // get ts of 12am (this lands us at or before the original scaleMin) - let minMin = mkDate(minDate.getFullYear(), isYr ? 0 : minDate.getMonth(), isMo || isYr ? 1 : minDate.getDate()); + let minMin = floorSOP(minDate, isYr || isMo ? PERIOD_YEAR : isDays ? PERIOD_MONTH : PERIOD_DAY); // should we do PERIOD_HOUR? let minMinTs = roundDec(minMin * ms, 3); - if (isMo || isYr) { - let moIncr = isMo ? foundIncr / mo : 0; - let yrIncr = isYr ? foundIncr / y : 0; - // let tzOffset = scaleMin - minDateTs; // needed? - let split = minDateTs == minMinTs ? minDateTs : roundDec(mkDate(minMin.getFullYear() + yrIncr, minMin.getMonth() + moIncr, 1) * ms, 3); - let splitDate = new Date(round(split / ms)); - let baseYear = splitDate.getFullYear(); - let baseMonth = splitDate.getMonth(); + if (isDays) { + let incrDays = foundIncr / d; - for (let i = 0; split <= scaleMax; i++) { - let next = mkDate(baseYear + yrIncr * i, baseMonth + moIncr * i, 1); - let offs = next - tzDate(roundDec(next * ms, 3)); + // incrs to add to month baseline + let skip = floor((minDate.getDate() - 1) / incrDays); + let split = minMinTs + (foundIncr * skip); - split = roundDec((+next + offs) * ms, 3); + do { + let date = tzDate(split); + // adjust for DST misses + let hour = date.getHours(); + if (hour != 0) { + split += hour > 12 ? h : -h; + date = tzDate(split); + } + + // rolled over into next month onto non-divisible incr, reset baseline + if ((date.getDate() - 1) % incrDays > 0) { + date = floorSOP(date, PERIOD_MONTH); + split = date.getTime() * ms; - if (split <= scaleMax) + // make sure we're not rendering a collision between 31 and 1 + if (split - splits[splits.length - 1] < foundIncr * 0.7) + splits.pop(); + } + + if (split > scaleMax) + break; + + if (split >= scaleMin) splits.push(split); - } - } - else { - let incr0 = foundIncr >= d ? d : foundIncr; - let tzOffset = floor(scaleMin) - floor(minDateTs); - let split = minMinTs + tzOffset + incrRoundUp(minDateTs - minMinTs, incr0); - splits.push(split); - let date0 = tzDate(split); + split += foundIncr; + } while (1); + } + else if (isMo || isYr) { + let subIncrs = 1; + let subIncrDays = 1; + let periodType = 0; + let periodMin = 0; + + if (isMo) { + subIncrs = foundIncr / mo; + subIncrDays = 32; + periodType = PERIOD_MONTH; + periodMin = minDate.getMonth(); + } + else if (isYr) { + subIncrs = foundIncr / y; + subIncrDays = 366; + periodType = PERIOD_YEAR; + periodMin = minDate.getYear(); + } - let prevHour = date0.getHours() + (date0.getMinutes() / m) + (date0.getSeconds() / h); - let incrHours = foundIncr / h; + foundIncr = subIncrs * subIncrDays * d; - let minSpace = self.axes[axisIdx]._space; - let pctSpace = foundSpace / minSpace; + let skip = floor(periodMin / subIncrDays); + let split = minMinTs + (foundIncr * skip); - while (1) { - split = roundDec(split + foundIncr, ms == 1 ? 0 : 3); + do { + let date = floorSOP(tzDate(split), periodType); + split = date.getTime() * ms; if (split > scaleMax) break; - if (incrHours > 1) { - let expectedHour = floor(roundDec(prevHour + incrHours, 6)) % 24; - let splitDate = tzDate(split); - let actualHour = splitDate.getHours(); + if (split >= scaleMin) + splits.push(split); - let dstShift = actualHour - expectedHour; + split += foundIncr; + } while (1); + } + else if (isHours) { + let incrHours = foundIncr / h; - if (dstShift > 1) - dstShift = -1; + let skip = floor(minDate.getHours() / incrHours); + let split = minMinTs + (foundIncr * skip); - split -= dstShift * h; + do { + let date = tzDate(split); - prevHour = (prevHour + incrHours) % 24; + // adjust for DST misses + let hour = date.getHours(); + if (hour % incrHours > 0) { + let hour2 = tzDate(split + h).getHours(); + split += hour2 % incrHours == 0 ? h : -h; + } - // add a tick only if it's further than 70% of the min allowed label spacing - let prevSplit = splits[splits.length - 1]; - let pctIncr = roundDec((split - prevSplit) / foundIncr, 3); + if (split > scaleMax) + break; - if (pctIncr * pctSpace >= .7) - splits.push(split); - } - else + if (split >= scaleMin) splits.push(split); - } + + split += foundIncr; + // expect = (expect + incrHours) % 24; + } while (1); + } + else { + let split = minMinTs + incrRoundUp(minDateTs - minMinTs, foundIncr); + + do { + if (split > scaleMax) + break; + + if (split >= scaleMin) + splits.push(split); + + split += foundIncr; + } while (1); + + splits.push(split); } return splits; @@ -1260,10 +1558,6 @@ function timeAxisVal(tzDate, dateTpl) { return (self, splits, axisIdx, foundSpace, foundIncr) => splits.map(split => stamp(tzDate(split))); } -function mkDate(y, m, d) { - return new Date(y, m, d); -} - function timeSeriesStamp(stampCfg, fmtDate) { return fmtDate(stampCfg); } diff --git a/dist/uPlot.iife.js b/dist/uPlot.iife.js index b72a7a65..8f462a04 100644 --- a/dist/uPlot.iife.js +++ b/dist/uPlot.iife.js @@ -944,8 +944,23 @@ var uPlot = (function () { s: d => d.getSeconds(), // 374 fff: d => zeroPad3(d.getMilliseconds()), + + /* + // this really only makes sense for DateZoned + // -05:00 + tzo: d => { + let o = d.getTimezoneOffset(); + let s = o > 0 ? '-' : '+'; + o = abs(o); + let hh = zeroPad2(floor(o / 60)); + let mm = zeroPad2(o % 60); + return `${s}${hh}:${mm}`; + } + */ }; + // export const iso8601 = fmtDate('{YYYY}-{MM}-{DD}T{HH}:{mm}:{ss}.{fff}{tzo}'); + function fmtDate(tpl, names) { names = names || engNames; let parts = []; @@ -967,22 +982,254 @@ var uPlot = (function () { const localTz = new Intl.DateTimeFormat().resolvedOptions().timeZone; - // https://stackoverflow.com/questions/15141762/how-to-initialize-a-javascript-date-to-a-particular-time-zone/53652131#53652131 - function tzDate(date, tz) { - let date2; + function tzDate(dateOrTs, tz) { + if (tz == null || tz == localTz) + return typeof dateOrTs == 'number' ? new Date(dateOrTs) : dateOrTs; - // perf optimization - if (tz == 'UTC' || tz == 'Etc/UTC') - date2 = new Date(+date + date.getTimezoneOffset() * 6e4); - else if (tz == localTz) - date2 = date; - else { - date2 = new Date(date.toLocaleString('en-US', {timeZone: tz})); - date2.setMilliseconds(date.getMilliseconds()); + let d = new DateZoned(dateOrTs); + d.setTimeZone(tz); + return d; + } + + const twoDigit = '2-digit'; + + const fmtrOpts = { + weekday: "short", + year: 'numeric', + month: twoDigit, + day: twoDigit, + hour: twoDigit, + minute: twoDigit, + second: twoDigit, + fractionalSecondDigits: 3, + timeZoneName: 'longOffset', + }; + + /* + // this might be a bit easier to parse to avoid negative .slice() offsets + new Intl.DateTimeFormat('en-US', { + hour12: false, + timeZone: 'Europe/London', + year: 'numeric', + month: '2-digit', + day: '2-digit', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + timeZoneName: 'longOffset', + weekday: 'short', + fractionalSecondDigits: 3, + }).format(new Date()); + + // Tue, 07/22/2025, 07:02:37.043 GMT+01:00 + */ + + const tzFmt = {}; + + function getFormatter(tz) { + if (tzFmt[tz] == null) + tzFmt[tz] = new Intl.DateTimeFormat("sv", {...fmtrOpts, timeZone: tz}).format; + + return tzFmt[tz]; + } + + class DateZoned extends Date { + tz = null; + #utc = false; + // sön, 1972-10-15 17:25:23,434 GMT+01:00 + #str = null; + + constructor(...args) { + super(...args); + + if (args[0] instanceof DateZoned) { + this.tz = args[0].tz; + this.#str = args[0].#str; + this.#utc = args[0].#utc; + } + } + + #get(utcMeth, locMeth, fr, to, add = 0) { + let s = this.#str; + return this.#utc ? utcMeth.call(this) : s == null ? locMeth.call(this) : Number(s.slice(fr,to)) + add; + } + + setTimeZone(tz) { + this.tz = tz; + + if (tz == 'UTC' || tz == 'Etc/UTC') + this.#utc = true; + else { + let fmt = getFormatter(tz); + let f = fmt(this); + + if (f.endsWith('GMT')) + f += '+00:00'; + + this.#str = f; + } + } + + getFullYear() { + return this.#get(this.getUTCFullYear, super.getFullYear, -33, -29); + } + + getMonth() { + return this.#get(this.getUTCMonth, super.getMonth, -28, -26, -1); + } + + getDate() { + return this.#get(this.getUTCDate, super.getDate, -25, -23); + } + + getHours() { + return this.#get(this.getUTCHours, super.getHours, -22, -20); + } + + getMinutes() { + return this.#get(this.getUTCMinutes, super.getMinutes, -19, -17); + } + + getSeconds() { + return this.#get(this.getUTCSeconds, super.getSeconds, -16, -14); + } + + getMilliseconds() { + return this.#get(this.getUTCMilliseconds, super.getMilliseconds, -13, -10); + } + + getDay() { + let s = this.#str; + return this.#utc ? this.getUTCDay() : s == null ? super.getDay() : ( + s[0] == 's' ? 0 : // sön + s[0] == 'm' ? 1 : // mån + s[1] == 'i' ? 2 : // tis + s[0] == 'o' ? 3 : // ons + s[1] == 'o' ? 4 : // tors + s[0] == 'f' ? 5 : // fre + s[0] == 'l' ? 6 : // lör + -1 + ); + } + + getTimezoneOffset() { + let s = this.#str; + return this.#utc ? 0 : s == null ? super.getTimezoneOffset() : (60 * Number(s.slice(-5,-3)) + Number(s.slice(-2))) * (s.at(-6) == '-' ? -1 : 1); + } + } + + function getDayOfYear(date) { + let y = date.getFullYear(); + let m = date.getMonth() + 1; + let d = date.getDate(); + + // https://stackoverflow.com/a/27790471 + return --m*31-(m>1?(1054267675>>m*3-6&7)-(y&3||!(y%25)&&y&15?0:1):0)+d; + } + + // these can be done through just incrRoundDn of 1e3 or 60 * 1e3 + // export const PERIOD_SECOND = 0; + // export const PERIOD_MINUTE = 1; + + // this might be needed for tzs where DST is not whole hours? + // otherwise incrRoundDn of 3600 * 1e3 + // export const PERIOD_HOUR = 2; + + // thse need special handling due to day length changing due to DST + const PERIOD_DAY = 3; + const PERIOD_MONTH = 4; + const PERIOD_YEAR = 5; + // export const PERIOD_WEEK; + + // get start of period, requires DateZoned and period const + function floorSOP(dz, per) { + let ts = dz.getTime(); + + // initial guess (assumes no DST) + let ts2 = ts - ( + dz.getMilliseconds() + + dz.getSeconds() * 1e3 + + dz.getMinutes() * 60 * 1e3 + + dz.getHours() * 3600 * 1e3 + + ( + ( + per == PERIOD_MONTH ? dz.getDate() - 1: + per == PERIOD_YEAR ? getDayOfYear(dz) - 1: + 0 + ) + * 24 * 3600 * 1e3 + ) + ); + + // if (ts2 == ts) + // return dz; + + let dz2 = new DateZoned(ts2); + dz2.setTimeZone(dz.tz); + + let h2 = dz2.getHours(); + + // we want hours to be 0 + if (h2 > 0) { + let dstAdj = h2 > 12 ? 24 - h2 : -h2; + dz2 = new DateZoned(ts2 + dstAdj * 3600 * 1e3); + dz2.setTimeZone(dz.tz); } - return date2; + return dz2; + } + + // tweaks the time by +/- 1hr to make sure it lands on 12am + // used for correcting optimistically-computed ticks from adding fixed increments + // export function sopNear(dz, per) {} + + /* + let fmt = fmtDate('{YYYY}-{MM}-{DD}T{HH}:{mm}:{ss}.{fff}{tzo}'); + + { + let d = new DateZoned(1554274800000); // post-roll date + d.setTimeZone('Europe/London'); + let sod = getSOP(d, PERIOD_DAY); + console.log(sod.getTime() / 1e3); + console.log(fmt(sod)); + } + + { + let d = new DateZoned(1554274800000); // post-roll date + d.setTimeZone('America/Chicago'); + let sod = getSOP(d, PERIOD_DAY); + console.log(sod.getTime() / 1e3); + console.log(fmt(sod)); + } + + { + let d = new DateZoned(1554004800000); // few hours after london spring forward + d.setTimeZone('Europe/London'); + let sod = getSOP(d, PERIOD_DAY); + console.log(sod.getTime() / 1e3); + console.log(fmt(sod)); + } + + { + let d = new DateZoned(1572156000000); // few hours after london fall back + d.setTimeZone('Europe/London'); + let sod = getSOP(d, PERIOD_DAY); + console.log(sod.getTime() / 1e3); + console.log(fmt(sod)); } + */ + + + /* + TODO: + + 2024 - leap year + start of year before feb vs after + start of month in dst fwd month / bwd month + start of day in dst fwd day / bwd day + + Australia/Darwin + */ //export const series = []; @@ -1103,78 +1350,129 @@ var uPlot = (function () { let splits = []; let isYr = foundIncr >= y; let isMo = foundIncr >= mo && foundIncr < y; + let isDays = foundIncr >= d && foundIncr < mo; + let isHours = foundIncr > h && foundIncr < d; // get the timezone-adjusted date let minDate = tzDate(scaleMin); let minDateTs = roundDec(minDate * ms, 3); // get ts of 12am (this lands us at or before the original scaleMin) - let minMin = mkDate(minDate.getFullYear(), isYr ? 0 : minDate.getMonth(), isMo || isYr ? 1 : minDate.getDate()); + let minMin = floorSOP(minDate, isYr || isMo ? PERIOD_YEAR : isDays ? PERIOD_MONTH : PERIOD_DAY); // should we do PERIOD_HOUR? let minMinTs = roundDec(minMin * ms, 3); - if (isMo || isYr) { - let moIncr = isMo ? foundIncr / mo : 0; - let yrIncr = isYr ? foundIncr / y : 0; - // let tzOffset = scaleMin - minDateTs; // needed? - let split = minDateTs == minMinTs ? minDateTs : roundDec(mkDate(minMin.getFullYear() + yrIncr, minMin.getMonth() + moIncr, 1) * ms, 3); - let splitDate = new Date(round(split / ms)); - let baseYear = splitDate.getFullYear(); - let baseMonth = splitDate.getMonth(); + if (isDays) { + let incrDays = foundIncr / d; - for (let i = 0; split <= scaleMax; i++) { - let next = mkDate(baseYear + yrIncr * i, baseMonth + moIncr * i, 1); - let offs = next - tzDate(roundDec(next * ms, 3)); + // incrs to add to month baseline + let skip = floor((minDate.getDate() - 1) / incrDays); + let split = minMinTs + (foundIncr * skip); - split = roundDec((+next + offs) * ms, 3); + do { + let date = tzDate(split); + // adjust for DST misses + let hour = date.getHours(); + if (hour != 0) { + split += hour > 12 ? h : -h; + date = tzDate(split); + } + + // rolled over into next month onto non-divisible incr, reset baseline + if ((date.getDate() - 1) % incrDays > 0) { + date = floorSOP(date, PERIOD_MONTH); + split = date.getTime() * ms; - if (split <= scaleMax) + // make sure we're not rendering a collision between 31 and 1 + if (split - splits[splits.length - 1] < foundIncr * 0.7) + splits.pop(); + } + + if (split > scaleMax) + break; + + if (split >= scaleMin) splits.push(split); - } - } - else { - let incr0 = foundIncr >= d ? d : foundIncr; - let tzOffset = floor(scaleMin) - floor(minDateTs); - let split = minMinTs + tzOffset + incrRoundUp(minDateTs - minMinTs, incr0); - splits.push(split); - let date0 = tzDate(split); + split += foundIncr; + } while (1); + } + else if (isMo || isYr) { + let subIncrs = 1; + let subIncrDays = 1; + let periodType = 0; + let periodMin = 0; + + if (isMo) { + subIncrs = foundIncr / mo; + subIncrDays = 32; + periodType = PERIOD_MONTH; + periodMin = minDate.getMonth(); + } + else if (isYr) { + subIncrs = foundIncr / y; + subIncrDays = 366; + periodType = PERIOD_YEAR; + periodMin = minDate.getYear(); + } - let prevHour = date0.getHours() + (date0.getMinutes() / m) + (date0.getSeconds() / h); - let incrHours = foundIncr / h; + foundIncr = subIncrs * subIncrDays * d; - let minSpace = self.axes[axisIdx]._space; - let pctSpace = foundSpace / minSpace; + let skip = floor(periodMin / subIncrDays); + let split = minMinTs + (foundIncr * skip); - while (1) { - split = roundDec(split + foundIncr, ms == 1 ? 0 : 3); + do { + let date = floorSOP(tzDate(split), periodType); + split = date.getTime() * ms; if (split > scaleMax) break; - if (incrHours > 1) { - let expectedHour = floor(roundDec(prevHour + incrHours, 6)) % 24; - let splitDate = tzDate(split); - let actualHour = splitDate.getHours(); + if (split >= scaleMin) + splits.push(split); - let dstShift = actualHour - expectedHour; + split += foundIncr; + } while (1); + } + else if (isHours) { + let incrHours = foundIncr / h; - if (dstShift > 1) - dstShift = -1; + let skip = floor(minDate.getHours() / incrHours); + let split = minMinTs + (foundIncr * skip); - split -= dstShift * h; + do { + let date = tzDate(split); - prevHour = (prevHour + incrHours) % 24; + // adjust for DST misses + let hour = date.getHours(); + if (hour % incrHours > 0) { + let hour2 = tzDate(split + h).getHours(); + split += hour2 % incrHours == 0 ? h : -h; + } - // add a tick only if it's further than 70% of the min allowed label spacing - let prevSplit = splits[splits.length - 1]; - let pctIncr = roundDec((split - prevSplit) / foundIncr, 3); + if (split > scaleMax) + break; - if (pctIncr * pctSpace >= .7) - splits.push(split); - } - else + if (split >= scaleMin) splits.push(split); - } + + split += foundIncr; + // expect = (expect + incrHours) % 24; + } while (1); + } + else { + let split = minMinTs + incrRoundUp(minDateTs - minMinTs, foundIncr); + + do { + if (split > scaleMax) + break; + + if (split >= scaleMin) + splits.push(split); + + split += foundIncr; + } while (1); + + splits.push(split); } return splits; @@ -1263,10 +1561,6 @@ var uPlot = (function () { return (self, splits, axisIdx, foundSpace, foundIncr) => splits.map(split => stamp(tzDate(split))); } - function mkDate(y, m, d) { - return new Date(y, m, d); - } - function timeSeriesStamp(stampCfg, fmtDate) { return fmtDate(stampCfg); } diff --git a/dist/uPlot.iife.min.js b/dist/uPlot.iife.min.js index d402fd70..afcfb38c 100644 --- a/dist/uPlot.iife.min.js +++ b/dist/uPlot.iife.min.js @@ -1,2 +1,2 @@ /*! https://github.com/leeoniya/uPlot (v1.6.32) */ -var uPlot=function(){"use strict";function l(l,e,t,n){let i;t=t||0;let o=2147483647>=(n=n||e.length-1);for(;n-t>1;)i=o?t+n>>1:b((t+n)/2),l>e[i]?t=i:n=i;return l-e[t]>e[n]-l?n:t}function e(l){return(e,t,n)=>{let i=-1,o=-1;for(let o=t;n>=o;o++)if(l(e[o])){i=o;break}for(let i=n;i>=t;i--)if(l(e[i])){o=i;break}return[i,o]}}const t=l=>null!=l,n=l=>null!=l&&l>0,i=e(t),o=e(n);function s(l,e,t,n){2==t&&(n=!0);let i=T(l),o=T(e);l==e&&(-1==i?(l*=t,e/=t):(l/=t,e*=t));let s=10==t?E:z,r=1==i?b:k,u=1==o?k:b,a=s(_(l)),f=s(_(e)),c=r(a),h=u(f),d=S(t,c),p=S(t,h);return 10==t&&(0>c&&(d=B(d,-c)),0>h&&(p=B(p,-h))),n?(l=d*i,e=p*o):(l=V(l,S(t,b(a)),!1),e=j(e,S(t,b(f)),!1)),[l,e]}function r(l,e,t,n){let i=s(l,e,t,n);return 0==l&&(i[0]=0),0==e&&(i[1]=0),i}const u=.1,a={mode:3,pad:u},f={pad:0,soft:null,mode:0},c={min:f,max:f};function h(l,e,t,n){return el(t)?p(l,e,t):(f.pad=t,f.soft=n?0:null,f.mode=n?3:0,p(l,e,c))}function d(l,e){return null==l?e:l}function p(l,e,t){let n=t.min,i=t.max,o=d(n.pad,0),s=d(i.pad,0),r=d(n.hard,-P),u=d(i.hard,P),a=d(n.soft,P),f=d(i.soft,-P),c=d(n.mode,0),h=d(i.mode,0),p=e-l,m=E(p),g=M(_(l),_(e)),x=E(g),w=_(x-m);(1e-24>p||w>10)&&(p=0,0!=l&&0!=e||(p=1e-24,2==c&&a!=P&&(o=0),2==h&&f!=-P&&(s=0)));let v=p||g||1e3,k=E(v),T=S(10,b(k)),z=B(V(l-v*(0==p?0==l?.1:1:o),T/10),24),D=a>l||1!=c&&(3!=c||z>a)&&(2!=c||a>z)?P:a,A=M(r,D>z&&l>=D?D:y(D,z)),W=B(j(e+v*(0==p?0==e?.1:1:s),T/10),24),R=e>f||1!=h&&(3!=h||f>W)&&(2!=h||W>f)?-P:f,Y=y(u,W>R&&R>=e?R:M(R,W));return A==Y&&0==A&&(Y=100),[A,Y]}const m=new Intl.NumberFormat,g=l=>m.format(l),x=Math,w=x.PI,_=x.abs,b=x.floor,v=x.round,k=x.ceil,y=x.min,M=x.max,S=x.pow,T=x.sign,E=x.log10,z=x.log2,D=(l,e=1)=>x.asinh(l/e),P=1/0;function A(l){return 1+(0|E((l^l>>31)-(l>>31)))}function W(l,e,t){return y(M(l,e),t)}function R(l){return"function"==typeof l}function Y(l){return R(l)?l:()=>l}const C=l=>l,H=(l,e)=>e,F=()=>null,G=()=>!0,I=(l,e)=>l==e,L=/\.\d*?(?=9{6,}|0{6,})/gm,O=l=>{if(Q(l)||U.has(l))return l;const e=""+l,t=e.match(L);if(null==t)return l;let n=t[0].length-1;if(-1!=e.indexOf("e-")){let[l,t]=e.split("e");return+`${O(l)}e${t}`}return B(l,n)};function N(l,e,t=!0){return t?O(B(O(l/e))*e):B(l/e)*e}function j(l,e,t=!0){return t?O(k(O(l/e))*e):k(l/e)*e}function V(l,e,t=!0){return t?O(b(O(l/e))*e):b(l/e)*e}function B(l,e=0){if(Q(l))return l;let t=10**e;return v(l*t*(1+Number.EPSILON))/t}const U=new Map;function $(l){return((""+l).split(".")[1]||"").length}function J(l,e,t,n){let i=[],o=n.map($);for(let s=e;t>s;s++){let e=_(s),t=B(S(l,s),e);for(let r=0;n.length>r;r++){let u=10==l?+`${n[r]}e${s}`:n[r]*t,a=(0>s?e:0)+(o[r]>s?o[r]:0),f=10==l?u:B(u,a);i.push(f),U.set(f,a)}}return i}const q={},K=[],X=[null,null],Z=Array.isArray,Q=Number.isInteger;function ll(l){return"string"==typeof l}function el(l){let e=!1;if(null!=l){let t=l.constructor;e=null==t||t==Object}return e}function tl(l){return null!=l&&"object"==typeof l}const nl=Object.getPrototypeOf(Uint8Array),il="__proto__";function ol(l,e=el){let t;if(Z(l)){let n=l.find((l=>null!=l));if(Z(n)||e(n)){t=Array(l.length);for(let n=0;l.length>n;n++)t[n]=ol(l[n],e)}else t=l.slice()}else if(l instanceof nl)t=l.slice();else if(e(l)){t={};for(let n in l)n!=il&&(t[n]=ol(l[n],e))}else t=l;return t}function sl(l){let e=arguments;for(let t=1;e.length>t;t++){let n=e[t];for(let e in n)e!=il&&(el(l[e])?sl(l[e],ol(n[e])):l[e]=ol(n[e]))}return l}function rl(l,e,t){for(let n,i=0,o=-1;e.length>i;i++){let s=e[i];if(s>o){for(n=s-1;n>=0&&null==l[n];)l[n--]=null;for(n=s+1;t>n&&null==l[n];)l[o=n++]=null}}}const ul="undefined"==typeof queueMicrotask?l=>Promise.resolve().then(l):queueMicrotask,al="width",fl="height",cl="top",hl="bottom",dl="left",pl="right",ml="#000",gl=ml+"0",xl="mousemove",wl="mousedown",_l="mouseup",bl="mouseenter",vl="mouseleave",kl="dblclick",yl="change",Ml="dppxchange",Sl="--",Tl="u-off",El="u-label",zl="undefined"!=typeof window,Dl=zl?document:null,Pl=zl?window:null;let Al,Wl;function Rl(l,e){if(null!=e){let t=l.classList;!t.contains(e)&&t.add(e)}}function Yl(l,e){let t=l.classList;t.contains(e)&&t.remove(e)}function Cl(l,e,t){l.style[e]=t+"px"}function Hl(l,e,t,n){let i=Dl.createElement(l);return null!=e&&Rl(i,e),null!=t&&t.insertBefore(i,n),i}function Fl(l,e){return Hl("div",l,e)}const Gl=new WeakMap;function Il(l,e,t,n,i){let o="translate("+e+"px,"+t+"px)";o!=Gl.get(l)&&(l.style.transform=o,Gl.set(l,o),0>e||0>t||e>n||t>i?Rl(l,Tl):Yl(l,Tl))}const Ll=new WeakMap;function Ol(l,e,t){let n=e+t;n!=Ll.get(l)&&(Ll.set(l,n),l.style.background=e,l.style.borderColor=t)}const Nl=new WeakMap;function jl(l,e,t,n){let i=e+""+t;i!=Nl.get(l)&&(Nl.set(l,i),l.style.height=t+"px",l.style.width=e+"px",l.style.marginLeft=n?-e/2+"px":0,l.style.marginTop=n?-t/2+"px":0)}const Vl={passive:!0},Bl={...Vl,capture:!0};function Ul(l,e,t,n){e.addEventListener(l,t,n?Bl:Vl)}function $l(l,e,t){e.removeEventListener(l,t,Vl)}zl&&function l(){let e=devicePixelRatio;Al!=e&&(Al=e,Wl&&$l(yl,Wl,l),Wl=matchMedia(`(min-resolution: ${Al-.001}dppx) and (max-resolution: ${Al+.001}dppx)`),Ul(yl,Wl,l),Pl.dispatchEvent(new CustomEvent(Ml)))}();const Jl=["January","February","March","April","May","June","July","August","September","October","November","December"],ql=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function Kl(l){return l.slice(0,3)}const Xl=ql.map(Kl),Zl=Jl.map(Kl),Ql={MMMM:Jl,MMM:Zl,WWWW:ql,WWW:Xl};function le(l){return(10>l?"0":"")+l}const ee={YYYY:l=>l.getFullYear(),YY:l=>(l.getFullYear()+"").slice(2),MMMM:(l,e)=>e.MMMM[l.getMonth()],MMM:(l,e)=>e.MMM[l.getMonth()],MM:l=>le(l.getMonth()+1),M:l=>l.getMonth()+1,DD:l=>le(l.getDate()),D:l=>l.getDate(),WWWW:(l,e)=>e.WWWW[l.getDay()],WWW:(l,e)=>e.WWW[l.getDay()],HH:l=>le(l.getHours()),H:l=>l.getHours(),h:l=>{let e=l.getHours();return 0==e?12:e>12?e-12:e},AA:l=>12>l.getHours()?"AM":"PM",aa:l=>12>l.getHours()?"am":"pm",a:l=>12>l.getHours()?"a":"p",mm:l=>le(l.getMinutes()),m:l=>l.getMinutes(),ss:l=>le(l.getSeconds()),s:l=>l.getSeconds(),fff:l=>function(l){return(10>l?"00":100>l?"0":"")+l}(l.getMilliseconds())};function te(l,e){e=e||Ql;let t,n=[],i=/\{([a-z]+)\}|[^{]+/gi;for(;t=i.exec(l);)n.push("{"==t[0][0]?ee[t[1]]:t[0]);return l=>{let t="";for(let i=0;n.length>i;i++)t+="string"==typeof n[i]?n[i]:n[i](l,e);return t}}const ne=(new Intl.DateTimeFormat).resolvedOptions().timeZone,ie=l=>l%1==0,oe=[1,2,2.5,5],se=J(10,-32,0,oe),re=J(10,0,32,oe),ue=re.filter(ie),ae=se.concat(re),fe="{YYYY}",ce="\n"+fe,he="{M}/{D}",de="\n"+he,pe=de+"/{YY}",me="{aa}",ge="{h}:{mm}"+me,xe="\n"+ge,we=":{ss}",_e=null;function be(l){let e=1e3*l,t=60*e,n=60*t,i=24*n,o=30*i,s=365*i;return[(1==l?J(10,0,3,oe).filter(ie):J(10,-3,0,oe)).concat([e,5*e,10*e,15*e,30*e,t,5*t,10*t,15*t,30*t,n,2*n,3*n,4*n,6*n,8*n,12*n,i,2*i,3*i,4*i,5*i,6*i,7*i,8*i,9*i,10*i,15*i,o,2*o,3*o,4*o,6*o,s,2*s,5*s,10*s,25*s,50*s,100*s]),[[s,fe,_e,_e,_e,_e,_e,_e,1],[28*i,"{MMM}",ce,_e,_e,_e,_e,_e,1],[i,he,ce,_e,_e,_e,_e,_e,1],[n,"{h}"+me,pe,_e,de,_e,_e,_e,1],[t,ge,pe,_e,de,_e,_e,_e,1],[e,we,pe+" "+ge,_e,de+" "+ge,_e,xe,_e,1],[l,we+".{fff}",pe+" "+ge,_e,de+" "+ge,_e,xe,_e,1]],function(e){return(r,u,a,f,c,h)=>{let d=[],p=c>=s,m=c>=o&&s>c,g=e(a),x=B(g*l,3),w=De(g.getFullYear(),p?0:g.getMonth(),m||p?1:g.getDate()),_=B(w*l,3);if(m||p){let t=m?c/o:0,n=p?c/s:0,i=x==_?x:B(De(w.getFullYear()+n,w.getMonth()+t,1)*l,3),r=new Date(v(i/l)),u=r.getFullYear(),a=r.getMonth();for(let o=0;f>=i;o++){let s=De(u+n*o,a+t*o,1),r=s-e(B(s*l,3));i=B((+s+r)*l,3),i>f||d.push(i)}}else{let o=i>c?c:i,s=_+(b(a)-b(x))+j(x-_,o);d.push(s);let p=e(s),m=p.getHours()+p.getMinutes()/t+p.getSeconds()/n,g=c/n,w=h/r.axes[u]._space;for(;s=B(s+c,1==l?0:3),f>=s;)if(g>1){let l=b(B(m+g,6))%24,t=e(s).getHours()-l;t>1&&(t=-1),s-=t*n,m=(m+g)%24,.7>B((s-d[d.length-1])/c,3)*w||d.push(s)}else d.push(s)}return d}}]}const[ve,ke,ye]=be(1),[Me,Se,Te]=be(.001);function Ee(l,e){return l.map((l=>l.map(((t,n)=>0==n||8==n||null==t?t:e(1==n||0==l[8]?t:l[1]+t)))))}function ze(l,e){return(t,n,i,o,s)=>{let r,u,a,f,c,h,d=e.find((l=>s>=l[0]))||e[e.length-1];return n.map((e=>{let t=l(e),n=t.getFullYear(),i=t.getMonth(),o=t.getDate(),s=t.getHours(),p=t.getMinutes(),m=t.getSeconds(),g=n!=r&&d[2]||i!=u&&d[3]||o!=a&&d[4]||s!=f&&d[5]||p!=c&&d[6]||m!=h&&d[7]||d[1];return r=n,u=i,a=o,f=s,c=p,h=m,g(t)}))}}function De(l,e,t){return new Date(l,e,t)}function Pe(l,e){return e(l)}function Ae(l,e){return(t,n,i,o)=>null==o?Sl:e(l(n))}J(2,-53,53,[1]);const We={show:!0,live:!0,isolate:!1,mount:()=>{},markers:{show:!0,width:2,stroke:function(l,e){let t=l.series[e];return t.width?t.stroke(l,e):t.points.width?t.points.stroke(l,e):null},fill:function(l,e){return l.series[e].fill(l,e)},dash:"solid"},idx:null,idxs:null,values:[]},Re=[0,0];function Ye(l,e,t,n=!0){return l=>{0==l.button&&(!n||l.target==e)&&t(l)}}function Ce(l,e,t,n=!0){return l=>{(!n||l.target==e)&&t(l)}}const He={show:!0,x:!0,y:!0,lock:!1,move:function(l,e,t){return Re[0]=e,Re[1]=t,Re},points:{one:!1,show:function(l,e){let t=l.cursor.points,n=Fl(),i=t.size(l,e);Cl(n,al,i),Cl(n,fl,i);let o=i/-2;Cl(n,"marginLeft",o),Cl(n,"marginTop",o);let s=t.width(l,e,i);return s&&Cl(n,"borderWidth",s),n},size:function(l,e){return l.series[e].points.size},width:0,stroke:function(l,e){let t=l.series[e].points;return t._stroke||t._fill},fill:function(l,e){let t=l.series[e].points;return t._fill||t._stroke}},bind:{mousedown:Ye,mouseup:Ye,click:Ye,dblclick:Ye,mousemove:Ce,mouseleave:Ce,mouseenter:Ce},drag:{setScale:!0,x:!0,y:!1,dist:0,uni:null,click:(l,e)=>{e.stopPropagation(),e.stopImmediatePropagation()},_x:!1,_y:!1},focus:{dist:(l,e,t,n,i)=>n-i,prox:-1,bias:0},hover:{skip:[void 0],prox:null,bias:0},left:-10,top:-10,idx:null,dataIdx:null,idxs:null,event:null},Fe={show:!0,stroke:"rgba(0,0,0,0.07)",width:2},Ge=sl({},Fe,{filter:H}),Ie=sl({},Ge,{size:10}),Le=sl({},Fe,{show:!1}),Oe='12px system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',Ne="bold "+Oe,je={show:!0,scale:"x",stroke:ml,space:50,gap:5,alignTo:1,size:50,labelGap:0,labelSize:30,labelFont:Ne,side:2,grid:Ge,ticks:Ie,border:Le,font:Oe,lineGap:1.5,rotate:0},Ve={show:!0,scale:"x",auto:!1,sorted:1,min:P,max:-P,idxs:[]};function Be(l,e){return e.map((l=>null==l?"":g(l)))}function Ue(l,e,t,n,i,o,s){let r=[],u=U.get(i)||0;for(let l=t=s?t:B(j(t,i),u);n>=l;l=B(l+i,u))r.push(Object.is(l,-0)?0:l);return r}function $e(e,t,n,i,o){const s=[],r=e.scales[e.axes[t].scale].log,u=b((10==r?E:z)(n));o=S(r,u),10==r&&(o=ae[l(o,ae)]);let a=n,f=o*r;10==r&&(f=ae[l(f,ae)]);do{s.push(a),a+=o,10!=r||U.has(a)||(a=B(a,U.get(o))),f>a||(f=(o=a)*r,10==r&&(f=ae[l(f,ae)]))}while(i>=a);return s}function Je(l,e,t,n,i){let o=l.scales[l.axes[e].scale].asinh,s=n>o?$e(l,e,M(o,t),n,i):[o],r=0>n||t>0?[]:[0];return(-o>t?$e(l,e,M(o,-n),-t,i):[o]).reverse().map((l=>-l)).concat(r,s)}const qe=/./,Ke=/[12357]/,Xe=/[125]/,Ze=/1/,Qe=(l,e,t,n)=>l.map(((l,i)=>4==e&&0==l||i%n==0&&t.test(l.toExponential()[0>l?1:0])?l:null));function lt(l,e,t){let n=l.axes[t],i=n.scale,o=l.scales[i],s=l.valToPos,r=n._space,u=s(10,i),a=s(9,i)-ul)return Qe(e.slice().reverse(),o.distr,a,k(r/l)).reverse()}return Qe(e,o.distr,a,1)}function et(l,e,t){let n=l.axes[t],i=n.scale,o=n._space,s=l.valToPos,r=_(s(1,i)-s(2,i));return o>r?Qe(e.slice().reverse(),3,qe,k(o/r)).reverse():e}function tt(l,e,t,n){return null==n?Sl:null==e?"":g(e)}const nt={show:!0,scale:"y",stroke:ml,space:30,gap:5,alignTo:1,size:50,labelGap:0,labelSize:30,labelFont:Ne,side:3,grid:Ge,ticks:Ie,border:Le,font:Oe,lineGap:1.5,rotate:0},it={scale:null,auto:!0,sorted:0,min:P,max:-P},ot=(l,e,t,n,i)=>i,st={show:!0,auto:!0,sorted:0,gaps:ot,alpha:1,facets:[sl({},it,{scale:"x"}),sl({},it,{scale:"y"})]},rt={scale:"y",auto:!0,sorted:0,show:!0,spanGaps:!1,gaps:ot,alpha:1,points:{show:function(l,e){let{scale:t,idxs:n}=l.series[0],i=l._data[0],o=l.valToPos(i[n[0]],t,!0),s=l.valToPos(i[n[1]],t,!0);return _(s-o)/(l.series[e].points.space*l.pxRatio)>=n[1]-n[0]},filter:null},values:null,min:P,max:-P,idxs:[],path:null,clip:null};function ut(l,e,t){return t/10}const at={time:!0,auto:!0,distr:1,log:10,asinh:1,min:null,max:null,dir:1,ori:0},ft=sl({},at,{time:!1,ori:1}),ct={};function ht(l){let e=ct[l];return e||(e={key:l,plots:[],sub(l){e.plots.push(l)},unsub(l){e.plots=e.plots.filter((e=>e!=l))},pub(l,t,n,i,o,s,r){for(let u=0;e.plots.length>u;u++)e.plots[u]!=t&&e.plots[u].pub(l,t,n,i,o,s,r)}},null!=l&&(ct[l]=e)),e}function dt(l,e,t){const n=l.mode,i=l.series[e],o=2==n?l._data[e]:l._data,s=l.scales,r=l.bbox;let u=o[0],a=2==n?o[1]:o[e],f=2==n?s[i.facets[0].scale]:s[l.series[0].scale],c=2==n?s[i.facets[1].scale]:s[i.scale],h=r.left,d=r.top,p=r.width,m=r.height,g=l.valToPosH,x=l.valToPosV;return 0==f.ori?t(i,u,a,f,c,g,x,h,d,p,m,vt,yt,St,Et,Dt):t(i,u,a,f,c,x,g,d,h,m,p,kt,Mt,Tt,zt,Pt)}function pt(l,e){let t=0,n=0,i=d(l.bands,K);for(let l=0;i.length>l;l++){let o=i[l];o.series[0]==e?t=o.dir:o.series[1]==e&&(n|=1==o.dir?1:2)}return[t,1==n?-1:2==n?1:3==n?2:0]}function mt(l,e,t,n,i){let o=l.series[e],s=l.scales[2==l.mode?o.facets[1].scale:o.scale];return-1==i?s.min:1==i?s.max:3==s.distr?1==s.dir?s.min:s.max:0}function gt(l,e,t,n,i,o){return dt(l,e,((l,e,s,r,u,a,f,c,h,d,p)=>{let m=l.pxRound;const g=0==r.ori?yt:Mt;let x,w;1==r.dir*(0==r.ori?1:-1)?(x=t,w=n):(x=n,w=t);let _=m(a(e[x],r,d,c)),b=m(f(s[x],u,p,h)),v=m(a(e[w],r,d,c)),k=m(f(1==o?u.max:u.min,u,p,h)),y=new Path2D(i);return g(y,v,k),g(y,_,k),g(y,_,b),y}))}function xt(l,e,t,n,i,o){let s=null;if(l.length>0){s=new Path2D;const r=0==e?St:Tt;let u=t;for(let e=0;l.length>e;e++){let t=l[e];if(t[1]>t[0]){let l=t[0]-u;l>0&&r(s,u,n,l,n+o),u=t[1]}}let a=t+i-u,f=10;a>0&&r(s,u,n-f/2,a,n+o+f)}return s}function wt(l,e,t,n,i,o,s){let r=[],u=l.length;for(let a=1==i?t:n;a>=t&&n>=a;a+=i)if(null===e[a]){let f=a,c=a;if(1==i)for(;++a<=n&&null===e[a];)c=a;else for(;--a>=t&&null===e[a];)c=a;let h=o(l[f]),d=c==f?h:o(l[c]),p=f-i;h=s>0||0>p||p>=u?h:o(l[p]);let m=c+i;d=0>s||0>m||m>=u?d:o(l[m]),h>d||r.push([h,d])}return r}function _t(l){return 0==l?C:1==l?v:e=>N(e,l)}function bt(l){let e=0==l?vt:kt,t=0==l?(l,e,t,n,i,o)=>{l.arcTo(e,t,n,i,o)}:(l,e,t,n,i,o)=>{l.arcTo(t,e,i,n,o)},n=0==l?(l,e,t,n,i)=>{l.rect(e,t,n,i)}:(l,e,t,n,i)=>{l.rect(t,e,i,n)};return(l,i,o,s,r,u=0,a=0)=>{0==u&&0==a?n(l,i,o,s,r):(u=y(u,s/2,r/2),a=y(a,s/2,r/2),e(l,i+u,o),t(l,i+s,o,i+s,o+r,u),t(l,i+s,o+r,i,o+r,a),t(l,i,o+r,i,o,a),t(l,i,o,i+s,o,u),l.closePath())}}const vt=(l,e,t)=>{l.moveTo(e,t)},kt=(l,e,t)=>{l.moveTo(t,e)},yt=(l,e,t)=>{l.lineTo(e,t)},Mt=(l,e,t)=>{l.lineTo(t,e)},St=bt(0),Tt=bt(1),Et=(l,e,t,n,i,o)=>{l.arc(e,t,n,i,o)},zt=(l,e,t,n,i,o)=>{l.arc(t,e,n,i,o)},Dt=(l,e,t,n,i,o,s)=>{l.bezierCurveTo(e,t,n,i,o,s)},Pt=(l,e,t,n,i,o,s)=>{l.bezierCurveTo(t,e,i,n,s,o)};function At(){return(l,e,t,n,i)=>{let{pxRatio:o}=l;return dt(l,e,((e,s,r,u,a,f,c,h,d,p,m)=>{let g,x,{pxRound:_,points:b}=e;0==u.ori?(g=vt,x=Et):(g=kt,x=zt);const v=B(b.width*o,3);let k=(b.size-b.width)/2*o,y=B(2*k,3),M=new Path2D,S=new Path2D,{left:T,top:E,width:z,height:D}=l.bbox;St(S,T-y,E-y,z+2*y,D+2*y);const P=l=>{if(null!=r[l]){let e=_(f(s[l],u,p,h)),t=_(c(r[l],a,m,d));g(M,e+k,t),x(M,e,t,k,0,2*w)}};if(i)i.forEach(P);else for(let l=t;n>=l;l++)P(l);return{stroke:v>0?M:null,fill:M,clip:S,flags:3}}))}}function Wt(l){return(e,t,n,i,o,s)=>{n!=i&&(o!=n&&s!=n&&l(e,t,n),o!=i&&s!=i&&l(e,t,i),l(e,t,s))}}const Rt=Wt(yt),Yt=Wt(Mt);function Ct(l){const e=d(l?.alignGaps,0);return(l,t,n,o)=>dt(l,t,((s,r,u,a,f,c,h,d,p,m,g)=>{[n,o]=i(u,n,o);let x,w,_=s.pxRound,b=l=>_(c(l,a,m,d)),v=l=>_(h(l,f,g,p));0==a.ori?(x=yt,w=Rt):(x=Mt,w=Yt);const k=a.dir*(0==a.ori?1:-1),y={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:1},M=y.stroke;let S=!1;if(o-n<4*m)for(let l=1==k?n:o;l>=n&&o>=l;l+=k){let e=u[l];null===e?S=!0:null!=e&&x(M,b(r[l]),v(e))}else{let e,t,i,s=e=>l.posToVal(e,a.key,!0),f=null,c=null,h=b(r[1==k?n:o]),d=b(r[n]),p=b(r[o]),m=s(1==k?d+1:p-1);for(let l=1==k?n:o;l>=n&&o>=l;l+=k){let n=r[l],i=(1==k?m>n:n>m)?h:b(n),o=u[l];i==h?null!=o?(t=o,null==f?(x(M,i,v(t)),e=f=c=t):f>t?f=t:t>c&&(c=t)):null===o&&(S=!0):(null!=f&&w(M,h,v(f),v(c),v(e),v(t)),null!=o?(t=o,x(M,i,v(t)),f=c=e=t):(f=c=null,null===o&&(S=!0)),h=i,m=s(h+k))}null!=f&&f!=c&&i!=h&&w(M,h,v(f),v(c),v(e),v(t))}let[T,E]=pt(l,t);if(null!=s.fill||0!=T){let e=y.fill=new Path2D(M),i=v(s.fillTo(l,t,s.min,s.max,T)),u=b(r[n]),a=b(r[o]);-1==k&&([a,u]=[u,a]),x(e,a,i),x(e,u,i)}if(!s.spanGaps){let i=[];S&&i.push(...wt(r,u,n,o,k,b,e)),y.gaps=i=s.gaps(l,t,n,o,i),y.clip=xt(i,a.ori,d,p,m,g)}return 0!=E&&(y.band=2==E?[gt(l,t,n,o,M,-1),gt(l,t,n,o,M,1)]:gt(l,t,n,o,M,E)),y}))}function Ht(l,e,t,n,i,o,s=P){if(l.length>1){let r=null;for(let u=0,a=1/0;l.length>u;u++)if(void 0!==e[u]){if(null!=r){let e=_(l[u]-l[r]);a>e&&(a=e,s=_(t(l[u],n,i,o)-t(l[r],n,i,o)))}r=u}}return s}function Ft(l,e,t,n,i){const o=l.length;if(2>o)return null;const s=new Path2D;if(t(s,l[0],e[0]),2==o)n(s,l[1],e[1]);else{let t=Array(o),n=Array(o-1),r=Array(o-1),u=Array(o-1);for(let t=0;o-1>t;t++)r[t]=e[t+1]-e[t],u[t]=l[t+1]-l[t],n[t]=r[t]/u[t];t[0]=n[0];for(let l=1;o-1>l;l++)0===n[l]||0===n[l-1]||n[l-1]>0!=n[l]>0?t[l]=0:(t[l]=3*(u[l-1]+u[l])/((2*u[l]+u[l-1])/n[l-1]+(u[l]+2*u[l-1])/n[l]),isFinite(t[l])||(t[l]=0));t[o-1]=n[o-2];for(let n=0;o-1>n;n++)i(s,l[n]+u[n]/3,e[n]+t[n]*u[n]/3,l[n+1]-u[n]/3,e[n+1]-t[n+1]*u[n]/3,l[n+1],e[n+1])}return s}const Gt=new Set;function It(){for(let l of Gt)l.syncRect(!0)}zl&&(Ul("resize",Pl,It),Ul("scroll",Pl,It,!0),Ul(Ml,Pl,(()=>{Qt.pxRatio=Al})));const Lt=Ct(),Ot=At();function Nt(l,e,t,n){return(n?[l[0],l[1]].concat(l.slice(2)):[l[0]].concat(l.slice(1))).map(((l,n)=>jt(l,n,e,t)))}function jt(l,e,t,n){return sl({},0==e?t:n,l)}function Vt(l,e,t){return null==e?X:[e,t]}const Bt=Vt;function Ut(l,e,t){return null==e?X:h(e,t,u,!0)}function $t(l,e,t,n){return null==e?X:s(e,t,l.scales[n].log,!0)}const Jt=$t;function qt(l,e,t,n){return null==e?X:r(e,t,l.scales[n].log,!0)}const Kt=qt;function Xt(e,t,n,i,o){let s=M(A(e),A(t)),r=t-e,u=l(o/i*r,n);do{let l=n[u],e=i*l/r;if(e>=o&&17>=s+(5>l?U.get(l):0))return[l,e]}while(++u(t=v((n=+i)*e))+"px")),t,n]}function Qt(e,f,c){let p=e.pxRatio??Al;function m(l){p=g.pxRatio=l??Al,yl.forEach((l=>function(l,e){l.show&&[l.font,l.labelFont].forEach((l=>{let t=B(l[2]*e,1);l[0]=l[0].replace(/[0-9.]+px/,t+"px"),l[1]=t}))}(l,p))),yt(g.width,g.height,!0)}const g={mode:d(e.mode,1),pxRatio:p,setPxRatio:m};g.setPxRatio=m;const b=g.mode;function T(l,e,t,n){let i=e.valToPct(l);return n+t*(-1==e.dir?1-i:i)}function z(l,e,t,n){let i=e.valToPct(l);return n+t*(-1==e.dir?i:1-i)}function A(l,e,t,n){return 0==e.ori?T(l,e,t,n):z(l,e,t,n)}g.valToPosH=T,g.valToPosV=z;let C=!1;g.status=0;const L=g.root=Fl("uplot");null!=e.id&&(L.id=e.id),Rl(L,e.class),e.title&&(Fl("u-title",L).textContent=e.title);const O=Hl("canvas"),j=g.ctx=O.getContext("2d"),V=Fl("u-wrap",L);Ul("click",V,(l=>{l.target===Q&&(jn!=In||Vn!=Ln)&&Qn.click(g,l)}),!0);const J=g.under=Fl("u-under",V);V.appendChild(O);const Q=g.over=Fl("u-over",V),nl=+d((e=ol(e)).pxAlign,1),il=_t(nl);(e.plugins||[]).forEach((l=>{l.opts&&(e=l.opts(g,e)||e)}));const rl=e.ms||.001,ml=g.series=1==b?Nt(e.series||[],Ve,rt,!1):function(l,e){return l.map(((l,t)=>0==t?{}:sl({},e,l)))}(e.series||[null],st),yl=g.axes=Nt(e.axes||[],je,nt,!0),zl=g.scales={},Wl=g.bands=e.bands||[];Wl.forEach((l=>{l.fill=Y(l.fill||null),l.dir=d(l.dir,-1)}));const Gl=2==b?ml[1].facets[0].scale:ml[0].scale,Ll={axes:function(){for(let l=0;yl.length>l;l++){let e=yl[l];if(!e.show||!e._show)continue;let t,n,i=e.side,o=i%2,s=e.stroke(g,l),r=0==i||3==i?-1:1,[u,a]=e._found;if(null!=e.label){let f=v((e._lpos+e.labelGap*r)*p);bn(e.labelFont[0],s,"center",2==i?cl:hl),j.save(),1==o?(t=n=0,j.translate(f,v(ct+pt/2)),j.rotate((3==i?-w:w)/2)):(t=v(ot+dt/2),n=f);let c=R(e.label)?e.label(g,l,u,a):e.label;j.fillText(c,t,n),j.restore()}if(0==a)continue;let f=zl[e.scale],c=0==o?dt:pt,h=0==o?ot:ct,d=e._splits,m=2==f.distr?d.map((l=>mn[l])):d,x=2==f.distr?mn[d[1]]-mn[d[0]]:u,_=e.ticks,b=e.border,k=_.show?_.size:0,y=v(k*p),M=v((2==e.alignTo?e._size-k-e.gap:e.gap)*p),S=e._rotate*-w/180,T=il(e._pos*p),E=T+(y+M)*r;n=0==o?E:0,t=1==o?E:0,bn(e.font[0],s,1==e.align?dl:2==e.align?pl:S>0?dl:0>S?pl:0==o?"center":3==i?pl:dl,S||1==o?"middle":2==i?cl:hl);let z=e.font[1]*e.lineGap,D=d.map((l=>il(A(l,f,c,h)))),P=e._values;for(let l=0;P.length>l;l++){let e=P[l];if(null!=e){0==o?t=D[l]:n=D[l],e=""+e;let i=-1==e.indexOf("\n")?[e]:e.split(/\n/gm);for(let l=0;i.length>l;l++){let e=i[l];S?(j.save(),j.translate(t,n+l*z),j.rotate(S),j.fillText(e,0,0),j.restore()):j.fillText(e,t,n+l*z)}}}_.show&&Dn(D,_.filter(g,m,l,a,x),o,i,T,y,B(_.width*p,3),_.stroke(g,l),_.dash,_.cap);let W=e.grid;W.show&&Dn(D,W.filter(g,m,l,a,x),o,0==o?2:1,0==o?ct:ot,0==o?pt:dt,B(W.width*p,3),W.stroke(g,l),W.dash,W.cap),b.show&&Dn([T],[1],0==o?1:0,0==o?1:2,1==o?ct:ot,1==o?pt:dt,B(b.width*p,3),b.stroke(g,l),b.dash,b.cap)}Ci("drawAxes")},series:function(){if(ln>0){let l=ml.some((l=>l._focus))&&pn!=zt.alpha;l&&(j.globalAlpha=pn=zt.alpha),ml.forEach(((l,e)=>{if(e>0&&l.show&&(yn(e,!1),yn(e,!0),null==l._paths)){let t=pn;pn!=l.alpha&&(j.globalAlpha=pn=l.alpha);let n=2==b?[0,f[e][0].length-1]:function(l){let e=W(en-1,0,ln-1),t=W(tn+1,0,ln-1);for(;null==l[e]&&e>0;)e--;for(;null==l[t]&&ln-1>t;)t++;return[e,t]}(f[e]);l._paths=l.paths(g,e,n[0],n[1]),pn!=t&&(j.globalAlpha=pn=t)}})),ml.forEach(((l,e)=>{if(e>0&&l.show){let t=pn;pn!=l.alpha&&(j.globalAlpha=pn=l.alpha),null!=l._paths&&Mn(e,!1);{let t=null!=l._paths?l._paths.gaps:null,n=l.points.show(g,e,en,tn,t),i=l.points.filter(g,e,n,t);(n||i)&&(l.points._paths=l.points.paths(g,e,en,tn,i),Mn(e,!0))}pn!=t&&(j.globalAlpha=pn=t),Ci("drawSeries",e)}})),l&&(j.globalAlpha=pn=1)}}},Nl=(e.drawOrder||["axes","series"]).map((l=>Ll[l]));function Vl(l){const e=3==l.distr?e=>E(e>0?e:l.clamp(g,e,l.min,l.max,l.key)):4==l.distr?e=>D(e,l.asinh):100==l.distr?e=>l.fwd(e):l=>l;return t=>{let n=e(t),{_min:i,_max:o}=l;return(n-i)/(o-i)}}function Bl(l){let t=zl[l];if(null==t){let n=(e.scales||q)[l]||q;if(null!=n.from){Bl(n.from);let e=sl({},zl[n.from],n,{key:l});e.valToPct=Vl(e),zl[l]=e}else{t=zl[l]=sl({},l==Gl?at:ft,n),t.key=l;let e=t.time,i=t.range,o=Z(i);if((l!=Gl||2==b&&!e)&&(!o||null!=i[0]&&null!=i[1]||(i={min:null==i[0]?a:{mode:1,hard:i[0],soft:i[0]},max:null==i[1]?a:{mode:1,hard:i[1],soft:i[1]}},o=!1),!o&&el(i))){let l=i;i=(e,t,n)=>null==t?X:h(t,n,l)}t.range=Y(i||(e?Bt:l==Gl?3==t.distr?Jt:4==t.distr?Kt:Vt:3==t.distr?$t:4==t.distr?qt:Ut)),t.auto=Y(!o&&t.auto),t.clamp=Y(t.clamp||ut),t._min=t._max=null,t.valToPct=Vl(t)}}}Bl("x"),Bl("y"),1==b&&ml.forEach((l=>{Bl(l.scale)})),yl.forEach((l=>{Bl(l.scale)}));for(let l in e.scales)Bl(l);const Jl=zl[Gl],ql=Jl.distr;let Kl,Xl;0==Jl.ori?(Rl(L,"u-hz"),Kl=T,Xl=z):(Rl(L,"u-vt"),Kl=z,Xl=T);const Zl={};for(let l in zl){let e=zl[l];null==e.min&&null==e.max||(Zl[l]={min:e.min,max:e.max},e.min=e.max=null)}const Ql=e.tzDate||(l=>new Date(v(l/rl))),le=e.fmtDate||te,ee=1==rl?ye(Ql):Te(Ql),ne=ze(Ql,Ee(1==rl?ke:Se,le)),ie=Ae(Ql,Pe("{YYYY}-{MM}-{DD} {h}:{mm}{aa}",le)),oe=[],se=g.legend=sl({},We,e.legend),re=g.cursor=sl({},He,{drag:{y:2==b}},e.cursor),fe=se.show,ce=re.show,he=se.markers;let de,pe,me;se.idxs=oe,he.width=Y(he.width),he.dash=Y(he.dash),he.stroke=Y(he.stroke),he.fill=Y(he.fill);let ge,xe=[],we=[],_e=!1,be={};if(se.live){const l=ml[1]?ml[1].values:null;_e=null!=l,ge=_e?l(g,1,0):{_:0};for(let l in ge)be[l]=Sl}if(fe)if(de=Hl("table","u-legend",L),me=Hl("tbody",null,de),se.mount(g,de),_e){pe=Hl("thead",null,de,me);let l=Hl("tr",null,pe);for(var De in Hl("th",null,l),ge)Hl("th",El,l).textContent=De}else Rl(de,"u-inline"),se.live&&Rl(de,"u-live");const Re={show:!0},Ye={show:!1},Ce=new Map;function Fe(l,e,t,n=!0){const i=Ce.get(e)||{},o=re.bind[l](g,e,t,n);o&&(Ul(l,e,i[l]=o),Ce.set(e,i))}function Ge(l,e){const t=Ce.get(e)||{};for(let n in t)null!=l&&n!=l||($l(n,e,t[n]),delete t[n]);null==l&&Ce.delete(e)}let Ie=0,Le=0,Oe=0,Ne=0,qe=0,Ke=0,Xe=qe,Ze=Ke,Qe=Oe,it=Ne,ot=0,ct=0,dt=0,pt=0;g.bbox={};let gt=!1,xt=!1,wt=!1,bt=!1,vt=!1,kt=!1;function yt(l,e,t){(t||l!=g.width||e!=g.height)&&Mt(l,e),Wn(!1),wt=!0,xt=!0,qn()}function Mt(l,e){g.width=Ie=Oe=l,g.height=Le=Ne=e,qe=Ke=0,function(){let l=!1,e=!1,t=!1,n=!1;yl.forEach((i=>{if(i.show&&i._show){let{side:o,_size:s}=i,r=s+(null!=i.label?i.labelSize:0);r>0&&(o%2?(Oe-=r,3==o?(qe+=r,n=!0):t=!0):(Ne-=r,0==o?(Ke+=r,l=!0):e=!0))}})),Ht[0]=l,Ht[1]=t,Ht[2]=e,Ht[3]=n,Oe-=Qt[1]+Qt[3],qe+=Qt[3],Ne-=Qt[2]+Qt[0],Ke+=Qt[0]}(),function(){let l=qe+Oe,e=Ke+Ne,t=qe,n=Ke;function i(i,o){switch(i){case 1:return l+=o,l-o;case 2:return e+=o,e-o;case 3:return t-=o,t+o;case 0:return n-=o,n+o}}yl.forEach((l=>{if(l.show&&l._show){let e=l.side;l._pos=i(e,l._size),null!=l.label&&(l._lpos=i(e,l.labelSize))}}))}();let t=g.bbox;ot=t.left=N(qe*p,.5),ct=t.top=N(Ke*p,.5),dt=t.width=N(Oe*p,.5),pt=t.height=N(Ne*p,.5)}const St=3;if(g.setSize=function({width:l,height:e}){yt(l,e)},null==re.dataIdx){let l=re.hover,e=l.skip=new Set(l.skip??[]);e.add(void 0);let t=l.prox=Y(l.prox),n=l.bias??=0;re.dataIdx=(l,i,o,s)=>{if(0==i)return o;let r=o,u=t(l,i,o,s)??P,a=u>=0&&P>u,c=0==Jl.ori?Oe:Ne,h=re.left,d=f[0],p=f[i];if(e.has(p[o])){r=null;let l,t=null,i=null;if(0==n||-1==n)for(l=o;null==t&&l-- >0;)e.has(p[l])||(t=l);if(0==n||1==n)for(l=o;null==i&&l++e?e>u||(r=i):l>u||(r=t)}else r=null==i?t:null==t||o-t>i-o?i:t}else a&&_(h-Kl(d[o],Jl,c,0))>u&&(r=null);return r}}const Tt=l=>{re.event=l};re.idxs=oe,re._lock=!1;let Et=re.points;Et.show=Y(Et.show),Et.size=Y(Et.size),Et.stroke=Y(Et.stroke),Et.width=Y(Et.width),Et.fill=Y(Et.fill);const zt=g.focus=sl({},e.focus||{alpha:.3},re.focus),Dt=zt.prox>=0,Pt=Dt&&Et.one;let At=[],Wt=[],Rt=[];function Yt(l,e){let t=Et.show(g,e);if(t instanceof HTMLElement)return Rl(t,"u-cursor-pt"),Rl(t,l.class),Il(t,-10,-10,Oe,Ne),Q.insertBefore(t,At[e]),t}function Ct(l,e){if(1==b||e>0){let e=1==b&&zl[l.scale].time,t=l.value;l.value=e?ll(t)?Ae(Ql,Pe(t,le)):t||ie:t||tt,l.label=l.label||(e?"Time":"Value")}if(Pt||e>0){l.width=null==l.width?1:l.width,l.paths=l.paths||Lt||F,l.fillTo=Y(l.fillTo||mt),l.pxAlign=+d(l.pxAlign,nl),l.pxRound=_t(l.pxAlign),l.stroke=Y(l.stroke||null),l.fill=Y(l.fill||null),l._stroke=l._fill=l._paths=l._focus=null;let e=function(l){return B(1*(3+2*(l||1)),3)}(M(1,l.width)),t=l.points=sl({},{size:e,width:M(1,.2*e),stroke:l.stroke,space:2*e,paths:Ot,_stroke:null,_fill:null},l.points);t.show=Y(t.show),t.filter=Y(t.filter),t.fill=Y(t.fill),t.stroke=Y(t.stroke),t.paths=Y(t.paths),t.pxAlign=l.pxAlign}if(fe){let t=function(l,e){if(0==e&&(_e||!se.live||2==b))return X;let t=[],n=Hl("tr","u-series",me,me.childNodes[e]);Rl(n,l.class),l.show||Rl(n,Tl);let i=Hl("th",null,n);if(he.show){let l=Fl("u-marker",i);if(e>0){let t=he.width(g,e);t&&(l.style.border=t+"px "+he.dash(g,e)+" "+he.stroke(g,e)),l.style.background=he.fill(g,e)}}let o=Fl(El,i);for(var s in l.label instanceof HTMLElement?o.appendChild(l.label):o.textContent=l.label,e>0&&(he.show||(o.style.color=l.width>0?he.stroke(g,e):he.fill(g,e)),Fe("click",i,(e=>{if(re._lock)return;Tt(e);let t=ml.indexOf(l);if((e.ctrlKey||e.metaKey)!=se.isolate){let l=ml.some(((l,e)=>e>0&&e!=t&&l.show));ml.forEach(((e,n)=>{n>0&&si(n,l?n==t?Re:Ye:Re,!0,Fi.setSeries)}))}else si(t,{show:!l.show},!0,Fi.setSeries)}),!1),Dt&&Fe(bl,i,(e=>{re._lock||(Tt(e),si(ml.indexOf(l),fi,!0,Fi.setSeries))}),!1)),ge){let l=Hl("td","u-value",n);l.textContent="--",t.push(l)}return[n,t]}(l,e);xe.splice(e,0,t[0]),we.splice(e,0,t[1]),se.values.push(null)}if(ce){oe.splice(e,0,null);let t=null;Pt?0==e&&(t=Yt(l,e)):e>0&&(t=Yt(l,e)),At.splice(e,0,t),Wt.splice(e,0,0),Rt.splice(e,0,0)}Ci("addSeries",e)}g.addSeries=function(l,e){e=null==e?ml.length:e,l=1==b?jt(l,e,Ve,rt):jt(l,e,{},st),ml.splice(e,0,l),Ct(ml[e],e)},g.delSeries=function(l){if(ml.splice(l,1),fe){se.values.splice(l,1),we.splice(l,1);let e=xe.splice(l,1)[0];Ge(null,e.firstChild),e.remove()}ce&&(oe.splice(l,1),At.splice(l,1)[0].remove(),Wt.splice(l,1),Rt.splice(l,1)),Ci("delSeries",l)};const Ht=[!1,!1,!1,!1];function Ft(l,e,t){let[n,i,o,s]=t,r=e%2,u=0;return 0==r&&(s||i)&&(u=0==e&&!n||2==e&&!o?v(je.size/3):0),1==r&&(n||o)&&(u=1==e&&!i||3==e&&!s?v(nt.size/2):0),u}const It=g.padding=(e.padding||[Ft,Ft,Ft,Ft]).map((l=>Y(d(l,Ft)))),Qt=g._padding=It.map(((l,e)=>l(g,e,Ht,0)));let ln,en=null,tn=null;const nn=1==b?ml[0].idxs:null;let on,sn,rn,un,an,fn,cn,hn,dn,pn,mn=null,gn=!1;function xn(l,e){if(g.data=g._data=f=null==l?[]:l,2==b){ln=0;for(let l=1;ml.length>l;l++)ln+=f[l][0].length}else{0==f.length&&(g.data=g._data=f=[[]]),mn=f[0],ln=mn.length;let l=f;if(2==ql){l=f.slice();let e=l[0]=Array(ln);for(let l=0;ln>l;l++)e[l]=l}g._data=f=l}if(Wn(!0),Ci("setData"),2==ql&&(wt=!0),!1!==e){let l=Jl;l.auto(g,gn)?wn():oi(Gl,l.min,l.max),bt=bt||re.left>=0,kt=!0,qn()}}function wn(){let l,e;gn=!0,1==b&&(ln>0?(en=nn[0]=0,tn=nn[1]=ln-1,l=f[0][en],e=f[0][tn],2==ql?(l=en,e=tn):l==e&&(3==ql?[l,e]=s(l,l,Jl.log,!1):4==ql?[l,e]=r(l,l,Jl.log,!1):Jl.time?e=l+v(86400/rl):[l,e]=h(l,e,u,!0))):(en=nn[0]=l=null,tn=nn[1]=e=null)),oi(Gl,l,e)}function _n(l,e,t,n,i,o){l??=gl,t??=K,n??="butt",i??=gl,o??="round",l!=on&&(j.strokeStyle=on=l),i!=sn&&(j.fillStyle=sn=i),e!=rn&&(j.lineWidth=rn=e),o!=an&&(j.lineJoin=an=o),n!=fn&&(j.lineCap=fn=n),t!=un&&j.setLineDash(un=t)}function bn(l,e,t,n){e!=sn&&(j.fillStyle=sn=e),l!=cn&&(j.font=cn=l),t!=hn&&(j.textAlign=hn=t),n!=dn&&(j.textBaseline=dn=n)}function vn(l,e,s,r,u=0){if(r.length>0&&l.auto(g,gn)&&(null==e||null==e.min)){let e=d(en,0),a=d(tn,r.length-1),f=null==s.min?function(l,e,s,r=0,u=!1){let a=u?o:i,f=u?n:t;[e,s]=a(l,e,s);let c=l[e],h=l[e];if(e>-1)if(1==r)c=l[e],h=l[s];else if(-1==r)c=l[s],h=l[e];else for(let t=e;s>=t;t++){let e=l[t];f(e)&&(c>e?c=e:e>h&&(h=e))}return[c??P,h??-P]}(r,e,a,u,3==l.distr):[s.min,s.max];l.min=y(l.min,s.min=f[0]),l.max=M(l.max,s.max=f[1])}}g.setData=xn;const kn={min:null,max:null};function yn(l,e){let t=e?ml[l].points:ml[l];t._stroke=t.stroke(g,l),t._fill=t.fill(g,l)}function Mn(l,e){let t=e?ml[l].points:ml[l],{stroke:n,fill:i,clip:o,flags:s,_stroke:r=t._stroke,_fill:u=t._fill,_width:a=t.width}=t._paths;a=B(a*p,3);let c=null,h=a%2/2;e&&null==u&&(u=a>0?"#fff":r);let m=1==t.pxAlign&&h>0;if(m&&j.translate(h,h),!e){let l=ot-a/2,e=ct-a/2,t=dt+a,n=pt+a;c=new Path2D,c.rect(l,e,t,n)}e?Tn(r,a,t.dash,t.cap,u,n,i,s,o):function(l,e,t,n,i,o,s,r,u,a,c){let h=!1;0!=u&&Wl.forEach(((p,m)=>{if(p.series[0]==l){let l,x=ml[p.series[1]],w=f[p.series[1]],_=(x._paths||q).band;Z(_)&&(_=1==p.dir?_[0]:_[1]);let b=null;x.show&&_&&function(l,e,t){for(e=d(e,0),t=d(t,l.length-1);t>=e;){if(null!=l[e])return!0;e++}return!1}(w,en,tn)?(b=p.fill(g,m)||o,l=x._paths.clip):_=null,Tn(e,t,n,i,b,s,r,u,a,c,l,_),h=!0}})),h||Tn(e,t,n,i,o,s,r,u,a,c)}(l,r,a,t.dash,t.cap,u,n,i,s,c,o),m&&j.translate(-h,-h)}const Sn=3;function Tn(l,e,t,n,i,o,s,r,u,a,f,c){_n(l,e,t,n,i),(u||a||c)&&(j.save(),u&&j.clip(u),a&&j.clip(a)),c?(r&Sn)==Sn?(j.clip(c),f&&j.clip(f),zn(i,s),En(l,o,e)):2&r?(zn(i,s),j.clip(c),En(l,o,e)):1&r&&(j.save(),j.clip(c),f&&j.clip(f),zn(i,s),j.restore(),En(l,o,e)):(zn(i,s),En(l,o,e)),(u||a||c)&&j.restore()}function En(l,e,t){t>0&&(e instanceof Map?e.forEach(((l,e)=>{j.strokeStyle=on=e,j.stroke(l)})):null!=e&&l&&j.stroke(e))}function zn(l,e){e instanceof Map?e.forEach(((l,e)=>{j.fillStyle=sn=e,j.fill(l)})):null!=e&&l&&j.fill(e)}function Dn(l,e,t,n,i,o,s,r,u,a){let f=s%2/2;1==nl&&j.translate(f,f),_n(r,s,u,a,r),j.beginPath();let c,h,d,p,m=i+(0==n||3==n?-o:o);0==t?(h=i,p=m):(c=i,d=m);for(let n=0;l.length>n;n++)null!=e[n]&&(0==t?c=d=l[n]:h=p=l[n],j.moveTo(c,h),j.lineTo(d,p));j.stroke(),1==nl&&j.translate(-f,-f)}function Pn(l){let e=!0;return yl.forEach(((t,n)=>{if(!t.show)return;let i=zl[t.scale];if(null==i.min)return void(t._show&&(e=!1,t._show=!1,Wn(!1)));t._show||(e=!1,t._show=!0,Wn(!1));let o=t.side,s=o%2,{min:r,max:u}=i,[a,f]=function(l,e,t,n){let i,o=yl[l];if(n>0){let s=o._space=o.space(g,l,e,t,n);i=Xt(e,t,o._incrs=o.incrs(g,l,e,t,n,s),n,s)}else i=[0,0];return o._found=i}(n,r,u,0==s?Oe:Ne);if(0==f)return;let c=t._splits=t.splits(g,n,r,u,a,f,2==i.distr),h=2==i.distr?c.map((l=>mn[l])):c,d=2==i.distr?mn[c[1]]-mn[c[0]]:a,p=t._values=t.values(g,t.filter(g,h,n,f,d),n,f,d);t._rotate=2==o?t.rotate(g,p,n,f):0;let m=t._size;t._size=k(t.size(g,p,n,l)),null!=m&&t._size!=m&&(e=!1)})),e}function An(l){let e=!0;return It.forEach(((t,n)=>{let i=t(g,n,Ht,l);i!=Qt[n]&&(e=!1),Qt[n]=i})),e}function Wn(l){ml.forEach(((e,t)=>{t>0&&(e._paths=null,l&&(1==b?(e.min=null,e.max=null):e.facets.forEach((l=>{l.min=null,l.max=null}))))}))}let Rn,Yn,Cn,Hn,Fn,Gn,In,Ln,On,Nn,jn,Vn,Bn=!1,Un=!1,$n=[];function Jn(){Un=!1;for(let l=0;$n.length>l;l++)Ci(...$n[l]);$n.length=0}function qn(){Bn||(ul(Kn),Bn=!0)}function Kn(){if(gt&&(function(){for(let l in zl){let e=zl[l];null==Zl[l]&&(null==e.min||null!=Zl[Gl]&&e.auto(g,gn))&&(Zl[l]=kn)}for(let l in zl){let e=zl[l];null==Zl[l]&&null!=e.from&&null!=Zl[e.from]&&(Zl[l]=kn)}null!=Zl[Gl]&&Wn(!0);let e={};for(let l in Zl){let t=Zl[l];if(null!=t){let n=e[l]=ol(zl[l],tl);if(null!=t.min)sl(n,t);else if(l!=Gl||2==b)if(0==ln&&null==n.from){let e=n.range(g,null,null,l);n.min=e[0],n.max=e[1]}else n.min=P,n.max=-P}}if(ln>0){ml.forEach(((t,n)=>{if(1==b){let i=t.scale,o=Zl[i];if(null==o)return;let s=e[i];if(0==n){let e=s.range(g,s.min,s.max,i);s.min=e[0],s.max=e[1],en=l(s.min,f[0]),tn=l(s.max,f[0]),tn-en>1&&(s.min>f[0][en]&&en++,f[0][tn]>s.max&&tn--),t.min=mn[en],t.max=mn[tn]}else t.show&&t.auto&&vn(s,o,t,f[n],t.sorted);t.idxs[0]=en,t.idxs[1]=tn}else if(n>0&&t.show&&t.auto){let[l,i]=t.facets,o=l.scale,s=i.scale,[r,u]=f[n],a=e[o],c=e[s];null!=a&&vn(a,Zl[o],l,r,l.sorted),null!=c&&vn(c,Zl[s],i,u,i.sorted),t.min=i.min,t.max=i.max}}));for(let l in e){let t=e[l],n=Zl[l];if(null==t.from&&(null==n||null==n.min)){let e=t.range(g,t.min==P?null:t.min,t.max==-P?null:t.max,l);t.min=e[0],t.max=e[1]}}}for(let l in e){let t=e[l];if(null!=t.from){let n=e[t.from];if(null==n.min)t.min=t.max=null;else{let e=t.range(g,n.min,n.max,l);t.min=e[0],t.max=e[1]}}}let t={},n=!1;for(let l in e){let i=e[l],o=zl[l];if(o.min!=i.min||o.max!=i.max){o.min=i.min,o.max=i.max;let e=o.distr;o._min=3==e?E(o.min):4==e?D(o.min,o.asinh):100==e?o.fwd(o.min):o.min,o._max=3==e?E(o.max):4==e?D(o.max,o.asinh):100==e?o.fwd(o.max):o.max,t[l]=n=!0}}if(n){ml.forEach(((l,e)=>{2==b?e>0&&t.y&&(l._paths=null):t[l.scale]&&(l._paths=null)}));for(let l in t)wt=!0,Ci("setScale",l);ce&&re.left>=0&&(bt=kt=!0)}for(let l in Zl)Zl[l]=null}(),gt=!1),wt&&(function(){let l=!1,e=0;for(;!l;){e++;let t=Pn(e),n=An(e);l=e==St||t&&n,l||(Mt(g.width,g.height),xt=!0)}}(),wt=!1),xt){if(Cl(J,dl,qe),Cl(J,cl,Ke),Cl(J,al,Oe),Cl(J,fl,Ne),Cl(Q,dl,qe),Cl(Q,cl,Ke),Cl(Q,al,Oe),Cl(Q,fl,Ne),Cl(V,al,Ie),Cl(V,fl,Le),O.width=v(Ie*p),O.height=v(Le*p),yl.forEach((({_el:l,_show:e,_size:t,_pos:n,side:i})=>{if(null!=l)if(e){let e=i%2==1;Cl(l,e?"left":"top",n-(3===i||0===i?t:0)),Cl(l,e?"width":"height",t),Cl(l,e?"top":"left",e?Ke:qe),Cl(l,e?"height":"width",e?Ne:Oe),Yl(l,Tl)}else Rl(l,Tl)})),on=sn=rn=an=fn=cn=hn=dn=un=null,pn=1,bi(!0),qe!=Xe||Ke!=Ze||Oe!=Qe||Ne!=it){Wn(!1);let l=Oe/Qe,e=Ne/it;if(ce&&!bt&&re.left>=0){re.left*=l,re.top*=e,Cn&&Il(Cn,v(re.left),0,Oe,Ne),Hn&&Il(Hn,0,v(re.top),Oe,Ne);for(let t=0;At.length>t;t++){let n=At[t];null!=n&&(Wt[t]*=l,Rt[t]*=e,Il(n,k(Wt[t]),k(Rt[t]),Oe,Ne))}}if(ti.show&&!vt&&ti.left>=0&&ti.width>0){ti.left*=l,ti.width*=l,ti.top*=e,ti.height*=e;for(let l in yi)Cl(ni,l,ti[l])}Xe=qe,Ze=Ke,Qe=Oe,it=Ne}Ci("setSize"),xt=!1}Ie>0&&Le>0&&(j.clearRect(0,0,O.width,O.height),Ci("drawClear"),Nl.forEach((l=>l())),Ci("draw")),ti.show&&vt&&(ii(ti),vt=!1),ce&&bt&&(wi(null,!0,!1),bt=!1),se.show&&se.live&&kt&&(gi(),kt=!1),C||(C=!0,g.status=1,Ci("ready")),gn=!1,Bn=!1}function Xn(e,t){let n=zl[e];if(null==n.from){if(0==ln){let l=n.range(g,t.min,t.max,e);t.min=l[0],t.max=l[1]}if(t.min>t.max){let l=t.min;t.min=t.max,t.max=l}if(ln>1&&null!=t.min&&null!=t.max&&1e-16>t.max-t.min)return;e==Gl&&2==n.distr&&ln>0&&(t.min=l(t.min,f[0]),t.max=l(t.max,f[0]),t.min==t.max&&t.max++),Zl[e]=t,gt=!0,qn()}}g.batch=function(l,e=!1){Bn=!0,Un=e,l(g),Kn(),e&&$n.length>0&&queueMicrotask(Jn)},g.redraw=(l,e)=>{wt=e||!1,!1!==l?oi(Gl,Jl.min,Jl.max):qn()},g.setScale=Xn;let Zn=!1;const Qn=re.drag;let li=Qn.x,ei=Qn.y;ce&&(re.x&&(Rn=Fl("u-cursor-x",Q)),re.y&&(Yn=Fl("u-cursor-y",Q)),0==Jl.ori?(Cn=Rn,Hn=Yn):(Cn=Yn,Hn=Rn),jn=re.left,Vn=re.top);const ti=g.select=sl({show:!0,over:!0,left:0,width:0,top:0,height:0},e.select),ni=ti.show?Fl("u-select",ti.over?Q:J):null;function ii(l,e){if(ti.show){for(let e in l)ti[e]=l[e],e in yi&&Cl(ni,e,l[e]);!1!==e&&Ci("setSelect")}}function oi(l,e,t){Xn(l,{min:e,max:t})}function si(l,e,t,n){null!=e.focus&&function(l){if(l!=ai){let e=null==l,t=1!=zt.alpha;ml.forEach(((n,i)=>{if(1==b||i>0){let o=e||0==i||i==l;n._focus=e?null:o,t&&function(l,e){ml[l].alpha=e,ce&&null!=At[l]&&(At[l].style.opacity=e),fe&&xe[l]&&(xe[l].style.opacity=e)}(i,o?1:zt.alpha)}})),ai=l,t&&qn()}}(l),null!=e.show&&ml.forEach(((t,n)=>{0>=n||l!=n&&null!=l||(t.show=e.show,function(l){if(ml[l].show)fe&&Yl(xe[l],Tl);else if(fe&&Rl(xe[l],Tl),ce){let e=Pt?At[0]:At[l];null!=e&&Il(e,-10,-10,Oe,Ne)}}(n),2==b?(oi(t.facets[0].scale,null,null),oi(t.facets[1].scale,null,null)):oi(t.scale,null,null),qn())})),!1!==t&&Ci("setSeries",l,e),n&&Li("setSeries",g,l,e)}let ri,ui,ai;g.setSelect=ii,g.setSeries=si,g.addBand=function(l,e){l.fill=Y(l.fill||null),l.dir=d(l.dir,-1),Wl.splice(e=null==e?Wl.length:e,0,l)},g.setBand=function(l,e){sl(Wl[l],e)},g.delBand=function(l){null==l?Wl.length=0:Wl.splice(l,1)};const fi={focus:!0};function ci(l,e,t){let n=zl[e];t&&(l=l/p-(1==n.ori?Ke:qe));let i=Oe;1==n.ori&&(i=Ne,l=i-l),-1==n.dir&&(l=i-l);let o=n._min,s=o+l/i*(n._max-o),r=n.distr;return 3==r?S(10,s):4==r?((l,e=1)=>x.sinh(l)*e)(s,n.asinh):100==r?n.bwd(s):s}function hi(l,e){Cl(ni,dl,ti.left=l),Cl(ni,al,ti.width=e)}function di(l,e){Cl(ni,cl,ti.top=l),Cl(ni,fl,ti.height=e)}fe&&Dt&&Fe(vl,de,(l=>{re._lock||(Tt(l),null!=ai&&si(null,fi,!0,Fi.setSeries))})),g.valToIdx=e=>l(e,f[0]),g.posToIdx=function(e,t){return l(ci(e,Gl,t),f[0],en,tn)},g.posToVal=ci,g.valToPos=(l,e,t)=>0==zl[e].ori?T(l,zl[e],t?dt:Oe,t?ot:0):z(l,zl[e],t?pt:Ne,t?ct:0),g.setCursor=(l,e,t)=>{jn=l.left,Vn=l.top,wi(null,e,t)};let pi=0==Jl.ori?hi:di,mi=1==Jl.ori?hi:di;function gi(l,e){if(null!=l&&(l.idxs?l.idxs.forEach(((l,e)=>{oe[e]=l})):(l=>void 0===l)(l.idx)||oe.fill(l.idx),se.idx=oe[0]),fe&&se.live){for(let l=0;ml.length>l;l++)(l>0||1==b&&!_e)&&xi(l,oe[l]);!function(){if(fe&&se.live)for(let l=2==b?1:0;ml.length>l;l++){if(0==l&&_e)continue;let e=se.values[l],t=0;for(let n in e)we[l][t++].firstChild.nodeValue=e[n]}}()}kt=!1,!1!==e&&Ci("setLegend")}function xi(l,e){let t,n=ml[l],i=0==l&&2==ql?mn:f[l];_e?t=n.values(g,l,e)??be:(t=n.value(g,null==e?null:i[e],l,e),t=null==t?be:{_:t}),se.values[l]=t}function wi(e,t,n){let i;On=jn,Nn=Vn,[jn,Vn]=re.move(g,jn,Vn),re.left=jn,re.top=Vn,ce&&(Cn&&Il(Cn,v(jn),0,Oe,Ne),Hn&&Il(Hn,0,v(Vn),Oe,Ne)),ri=P,ui=null;let o=0==Jl.ori?Oe:Ne,s=1==Jl.ori?Oe:Ne;if(0>jn||0==ln||en>tn){i=re.idx=null;for(let l=0;ml.length>l;l++){let e=At[l];null!=e&&Il(e,-10,-10,Oe,Ne)}Dt&&si(null,fi,!0,null==e&&Fi.setSeries),se.live&&(oe.fill(i),kt=!0)}else{let e,t,n;1==b&&(e=0==Jl.ori?jn:Vn,t=ci(e,Gl),i=re.idx=l(t,f[0],en,tn),n=Kl(f[0][i],Jl,o,0));let r=-10,u=-10,a=0,c=0,h=!0,d="",p="";for(let l=2==b?1:0;ml.length>l;l++){let e=ml[l],m=oe[l],x=null==m?null:1==b?f[l][m]:f[l][1][m],w=re.dataIdx(g,l,i,t),v=null==w?null:1==b?f[l][w]:f[l][1][w];if(kt=kt||v!=x||w!=m,oe[l]=w,l>0&&e.show){let t=null==w?-10:w==i?n:Kl(1==b?f[0][w]:f[l][0][w],Jl,o,0),m=null==v?-10:Xl(v,1==b?zl[e.scale]:zl[e.facets[1].scale],s,0);if(Dt&&null!=v){let t=1==Jl.ori?jn:Vn,n=_(zt.dist(g,l,w,m,t));if(ri>n){let i=zt.bias;if(0!=i){let o=ci(t,e.scale),s=0>o?-1:1;s!=(0>v?-1:1)||(1==s?1==i?o>v:v>o:1==i?v>o:o>v)||(ri=n,ui=l)}else ri=n,ui=l}}if(kt||Pt){let e,n;0==Jl.ori?(e=t,n=m):(e=m,n=t);let i,o,s,f,x,w,_=!0,b=Et.bbox;if(null!=b){_=!1;let e=b(g,l);s=e.left,f=e.top,i=e.width,o=e.height}else s=e,f=n,i=o=Et.size(g,l);if(w=Et.fill(g,l),x=Et.stroke(g,l),Pt)l!=ui||ri>zt.prox||(r=s,u=f,a=i,c=o,h=_,d=w,p=x);else{let e=At[l];null!=e&&(Wt[l]=s,Rt[l]=f,jl(e,i,o,_),Ol(e,w,x),Il(e,k(s),k(f),Oe,Ne))}}}}if(Pt){let l=zt.prox;if(kt||(null==ai?l>=ri:ri>l||ui!=ai)){let l=At[0];null!=l&&(Wt[0]=r,Rt[0]=u,jl(l,a,c,h),Ol(l,d,p),Il(l,k(r),k(u),Oe,Ne))}}}if(ti.show&&Zn)if(null!=e){let[l,t]=Fi.scales,[n,i]=Fi.match,[r,u]=e.cursor.sync.scales,a=e.cursor.drag;if(li=a._x,ei=a._y,li||ei){let a,f,c,h,d,{left:p,top:m,width:g,height:x}=e.select,w=e.scales[r].ori,b=e.posToVal,v=null!=l&&n(l,r),k=null!=t&&i(t,u);v&&li?(0==w?(a=p,f=g):(a=m,f=x),c=zl[l],h=Kl(b(a,r),c,o,0),d=Kl(b(a+f,r),c,o,0),pi(y(h,d),_(d-h))):pi(0,o),k&&ei?(1==w?(a=p,f=g):(a=m,f=x),c=zl[t],h=Xl(b(a,u),c,s,0),d=Xl(b(a+f,u),c,s,0),mi(y(h,d),_(d-h))):mi(0,s)}else Mi()}else{let l=_(On-Fn),e=_(Nn-Gn);if(1==Jl.ori){let t=l;l=e,e=t}li=Qn.x&&l>=Qn.dist,ei=Qn.y&&e>=Qn.dist;let t,n,i=Qn.uni;null!=i?li&&ei&&(li=l>=i,ei=e>=i,li||ei||(e>l?ei=!0:li=!0)):Qn.x&&Qn.y&&(li||ei)&&(li=ei=!0),li&&(0==Jl.ori?(t=In,n=jn):(t=Ln,n=Vn),pi(y(t,n),_(n-t)),ei||mi(0,s)),ei&&(1==Jl.ori?(t=In,n=jn):(t=Ln,n=Vn),mi(y(t,n),_(n-t)),li||pi(0,o)),li||ei||(pi(0,0),mi(0,0))}if(Qn._x=li,Qn._y=ei,null==e){if(n){if(null!=Gi){let[l,e]=Fi.scales;Fi.values[0]=null!=l?ci(0==Jl.ori?jn:Vn,l):null,Fi.values[1]=null!=e?ci(1==Jl.ori?jn:Vn,e):null}Li(xl,g,jn,Vn,Oe,Ne,i)}if(Dt){let l=n&&Fi.setSeries,e=zt.prox;null==ai?ri>e||si(ui,fi,!0,l):ri>e?si(null,fi,!0,l):ui!=ai&&si(ui,fi,!0,l)}}kt&&(se.idx=i,gi()),!1!==t&&Ci("setCursor")}g.setLegend=gi;let _i=null;function bi(l=!1){l?_i=null:(_i=Q.getBoundingClientRect(),Ci("syncRect",_i))}function vi(l,e,t,n,i,o){re._lock||Zn&&null!=l&&0==l.movementX&&0==l.movementY||(ki(l,e,t,n,i,o,0,!1,null!=l),null!=l?wi(null,!0,!0):wi(e,!0,!1))}function ki(l,e,t,n,i,o,s,r,u){if(null==_i&&bi(!1),Tt(l),null!=l)t=l.clientX-_i.left,n=l.clientY-_i.top;else{if(0>t||0>n)return jn=-10,void(Vn=-10);let[l,s]=Fi.scales,r=e.cursor.sync,[u,a]=r.values,[f,c]=r.scales,[h,d]=Fi.match,p=e.axes[0].side%2==1,m=0==Jl.ori?Oe:Ne,g=1==Jl.ori?Oe:Ne,x=p?o:i,w=p?i:o,_=p?n:t,b=p?t:n;if(t=null!=f?h(l,f)?A(u,zl[l],m,0):-10:m*(_/x),n=null!=c?d(s,c)?A(a,zl[s],g,0):-10:g*(b/w),1==Jl.ori){let l=t;t=n,n=l}}!u||null!=e&&e.cursor.event.type!=xl||(t>1&&Oe-1>t||(t=N(t,Oe)),n>1&&Ne-1>n||(n=N(n,Ne))),r?(Fn=t,Gn=n,[In,Ln]=re.move(g,t,n)):(jn=t,Vn=n)}Object.defineProperty(g,"rect",{get:()=>(null==_i&&bi(!1),_i)});const yi={width:0,height:0,left:0,top:0};function Mi(){ii(yi,!1)}let Si,Ti,Ei,zi;function Di(l,e,t,n,i,o){Zn=!0,li=ei=Qn._x=Qn._y=!1,ki(l,e,t,n,i,o,0,!0,!1),null!=l&&(Fe(_l,Dl,Pi,!1),Li(wl,g,In,Ln,Oe,Ne,null));let{left:s,top:r,width:u,height:a}=ti;Si=s,Ti=r,Ei=u,zi=a}function Pi(l,e,t,n,i,o){Zn=Qn._x=Qn._y=!1,ki(l,e,t,n,i,o,0,!1,!0);let{left:s,top:r,width:u,height:a}=ti,f=u>0||a>0,c=Si!=s||Ti!=r||Ei!=u||zi!=a;if(f&&c&&ii(ti),Qn.setScale&&f&&c){let l=s,e=u,t=r,n=a;if(1==Jl.ori&&(l=r,e=a,t=s,n=u),li&&oi(Gl,ci(l,Gl),ci(l+e,Gl)),ei)for(let l in zl){let e=zl[l];l!=Gl&&null==e.from&&e.min!=P&&oi(l,ci(t+n,l),ci(t,l))}Mi()}else re.lock&&(re._lock=!re._lock,wi(e,!0,null!=l));null!=l&&(Ge(_l,Dl),Li(_l,g,jn,Vn,Oe,Ne,null))}function Ai(l){re._lock||(Tt(l),wn(),Mi(),null!=l&&Li(kl,g,jn,Vn,Oe,Ne,null))}function Wi(){m()}Ul(Ml,Pl,Wi);const Ri={};Ri.mousedown=Di,Ri.mousemove=vi,Ri.mouseup=Pi,Ri.dblclick=Ai,Ri.setSeries=(l,e,t,n)=>{-1!=(t=(0,Fi.match[2])(g,e,t))&&si(t,n,!0,!1)},ce&&(Fe(wl,Q,Di),Fe(xl,Q,vi),Fe(bl,Q,(l=>{Tt(l),bi(!1)})),Fe(vl,Q,(function(l){if(re._lock)return;Tt(l);let e=Zn;if(Zn){let l,e,t=!0,n=!0,i=10;0==Jl.ori?(l=li,e=ei):(l=ei,e=li),l&&e&&(t=i>=jn||jn>=Oe-i,n=i>=Vn||Vn>=Ne-i),l&&t&&(jn=In>jn?0:Oe),e&&n&&(Vn=Ln>Vn?0:Ne),wi(null,!0,!0),Zn=!1}jn=-10,Vn=-10,oe.fill(null),wi(null,!0,!0),e&&(Zn=e)})),Fe(kl,Q,Ai),Gt.add(g),g.syncRect=bi);const Yi=g.hooks=e.hooks||{};function Ci(l,e,t){Un?$n.push([l,e,t]):l in Yi&&Yi[l].forEach((l=>{l.call(null,g,e,t)}))}(e.plugins||[]).forEach((l=>{for(let e in l.hooks)Yi[e]=(Yi[e]||[]).concat(l.hooks[e])}));const Hi=(l,e,t)=>t,Fi=sl({key:null,setSeries:!1,filters:{pub:G,sub:G},scales:[Gl,ml[1]?ml[1].scale:null],match:[I,I,Hi],values:[null,null]},re.sync);2==Fi.match.length&&Fi.match.push(Hi),re.sync=Fi;const Gi=Fi.key,Ii=ht(Gi);function Li(l,e,t,n,i,o,s){Fi.filters.pub(l,e,t,n,i,o,s)&&Ii.pub(l,e,t,n,i,o,s)}function Oi(){Ci("init",e,f),xn(f||e.data,!1),Zl[Gl]?Xn(Gl,Zl[Gl]):wn(),vt=ti.show&&(ti.width>0||ti.height>0),bt=kt=!0,yt(e.width,e.height)}return Ii.sub(g),g.pub=function(l,e,t,n,i,o,s){Fi.filters.sub(l,e,t,n,i,o,s)&&Ri[l](null,e,t,n,i,o,s)},g.destroy=function(){Ii.unsub(g),Gt.delete(g),Ce.clear(),$l(Ml,Pl,Wi),L.remove(),de?.remove(),Ci("destroy")},ml.forEach(Ct),yl.forEach((function(l,e){if(l._show=l.show,l.show){let t=zl[l.scale];null==t&&(l.scale=l.side%2?ml[1].scale:Gl,t=zl[l.scale]);let n=t.time;l.size=Y(l.size),l.space=Y(l.space),l.rotate=Y(l.rotate),Z(l.incrs)&&l.incrs.forEach((l=>{!U.has(l)&&U.set(l,$(l))})),l.incrs=Y(l.incrs||(2==t.distr?ue:n?1==rl?ve:Me:ae)),l.splits=Y(l.splits||(n&&1==t.distr?ee:3==t.distr?$e:4==t.distr?Je:Ue)),l.stroke=Y(l.stroke),l.grid.stroke=Y(l.grid.stroke),l.ticks.stroke=Y(l.ticks.stroke),l.border.stroke=Y(l.border.stroke);let i=l.values;l.values=Z(i)&&!Z(i[0])?Y(i):n?Z(i)?ze(Ql,Ee(i,le)):ll(i)?function(l,e){let t=te(e);return(e,n)=>n.map((e=>t(l(e))))}(Ql,i):i||ne:i||Be,l.filter=Y(l.filter||(3>t.distr||10!=t.log?3==t.distr&&2==t.log?et:H:lt)),l.font=Zt(l.font,p),l.labelFont=Zt(l.labelFont,p),l._size=l.size(g,null,e,0),l._space=l._rotate=l._incrs=l._found=l._splits=l._values=null,l._size>0&&(Ht[e]=!0,l._el=Fl("u-axis",V))}})),c?c instanceof HTMLElement?(c.appendChild(L),Oi()):c(g,Oi):Oi(),g}Qt.assign=sl,Qt.fmtNum=g,Qt.rangeNum=h,Qt.rangeLog=s,Qt.rangeAsinh=r,Qt.orient=dt,Qt.pxRatio=Al,Qt.join=function(l,e){if(function(l){let e=l[0][0],t=e.length;for(let n=1;l.length>n;n++){let i=l[n][0];if(i.length!=t)return!1;if(i!=e)for(let l=0;t>l;l++)if(i[l]!=e[l])return!1}return!0}(l)){let e=l[0].slice();for(let t=1;l.length>t;t++)e.push(...l[t].slice(1));return function(l,e=100){const t=l.length;if(1>=t)return!0;let n=0,i=t-1;for(;i>=n&&null==l[n];)n++;for(;i>=n&&null==l[i];)i--;if(n>=i)return!0;const o=M(1,b((i-n+1)/e));for(let e=l[n],t=n+o;i>=t;t+=o){const n=l[t];if(null!=n){if(e>=n)return!1;e=n}}return!0}(e[0])||(e=function(l){let e=l[0],t=e.length,n=Array(t);for(let l=0;n.length>l;l++)n[l]=l;n.sort(((l,t)=>e[l]-e[t]));let i=[];for(let e=0;l.length>e;e++){let o=l[e],s=Array(t);for(let l=0;t>l;l++)s[l]=o[n[l]];i.push(s)}return i}(e)),e}let t=new Set;for(let e=0;l.length>e;e++){let n=l[e][0],i=n.length;for(let l=0;i>l;l++)t.add(n[l])}let n=[Array.from(t).sort(((l,e)=>l-e))],i=n[0].length,o=new Map;for(let l=0;i>l;l++)o.set(n[0][l],l);for(let t=0;l.length>t;t++){let s=l[t],r=s[0];for(let l=1;s.length>l;l++){let u=s[l],a=Array(i).fill(void 0),f=e?e[t][l]:1,c=[];for(let l=0;u.length>l;l++){let e=u[l],t=o.get(r[l]);null===e?0!=f&&(a[t]=e,2==f&&c.push(t)):a[t]=e}rl(a,c,i),n.push(a)}}return n},Qt.fmtDate=te,Qt.tzDate=function(l,e){let t;return"UTC"==e||"Etc/UTC"==e?t=new Date(+l+6e4*l.getTimezoneOffset()):e==ne?t=l:(t=new Date(l.toLocaleString("en-US",{timeZone:e})),t.setMilliseconds(l.getMilliseconds())),t},Qt.sync=ht;{Qt.addGap=function(l,e,t){let n=l[l.length-1];n&&n[0]==e?n[1]=t:l.push([e,t])},Qt.clipGaps=xt;let l=Qt.paths={points:At};l.linear=Ct,l.stepped=function(l){const e=d(l.align,1),t=d(l.ascDesc,!1),n=d(l.alignGaps,0),o=d(l.extend,!1);return(l,s,r,u)=>{let{pxRatio:a}=l;return dt(l,s,((f,c,h,d,p,m,g,x,w,_,b)=>{[r,u]=i(h,r,u);let v=f.pxRound,{left:k,width:y}=l.bbox,M=l=>v(m(l,d,_,x)),S=l=>v(g(l,p,b,w)),T=0==d.ori?yt:Mt;const E={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:1},z=E.stroke,D=d.dir*(0==d.ori?1:-1);let P=S(h[1==D?r:u]),A=M(c[1==D?r:u]),W=A,R=A;o&&-1==e&&(R=k,T(z,R,P)),T(z,A,P);for(let l=1==D?r:u;l>=r&&u>=l;l+=D){let t=h[l];if(null==t)continue;let n=M(c[l]),i=S(t);1==e?T(z,n,P):T(z,W,i),T(z,n,i),P=i,W=n}let Y=W;o&&1==e&&(Y=k+y,T(z,Y,P));let[C,H]=pt(l,s);if(null!=f.fill||0!=C){let e=E.fill=new Path2D(z),t=S(f.fillTo(l,s,f.min,f.max,C));T(e,Y,t),T(e,R,t)}if(!f.spanGaps){let i=[];i.push(...wt(c,h,r,u,D,M,n));let o=f.width*a/2,p=t||1==e?o:-o,m=t||-1==e?-o:o;i.forEach((l=>{l[0]+=p,l[1]+=m})),E.gaps=i=f.gaps(l,s,r,u,i),E.clip=xt(i,d.ori,x,w,_,b)}return 0!=H&&(E.band=2==H?[gt(l,s,r,u,z,-1),gt(l,s,r,u,z,1)]:gt(l,s,r,u,z,H)),E}))}},l.bars=function(l){const e=d((l=l||q).size,[.6,P,1]),t=l.align||0,n=l.gap||0;let i=l.radius;i=null==i?[0,0]:"number"==typeof i?[i,0]:i;const o=Y(i),s=1-e[0],r=d(e[1],P),u=d(e[2],1),a=d(l.disp,q),f=d(l.each,(()=>{})),{fill:c,stroke:h}=a;return(l,e,i,p)=>{let{pxRatio:m}=l;return dt(l,e,((g,x,w,_,v,k,S,T,E,z,D)=>{let P,A,R=g.pxRound,Y=t,H=n*m,F=r*m,G=u*m;0==_.ori?[P,A]=o(l,e):[A,P]=o(l,e);const I=_.dir*(0==_.ori?1:-1);let L,O,N,j=0==_.ori?St:Tt,V=0==_.ori?f:(l,e,t,n,i,o,s)=>{f(l,e,t,i,n,s,o)},B=d(l.bands,K).find((l=>l.series[0]==e)),U=g.fillTo(l,e,g.min,g.max,null!=B?B.dir:0),$=R(S(U,v,D,E)),J=z,q=R(g.width*m),X=!1,Z=null,Q=null,ll=null,el=null;null==c||0!=q&&null==h||(X=!0,Z=c.values(l,e,i,p),Q=new Map,new Set(Z).forEach((l=>{null!=l&&Q.set(l,new Path2D)})),q>0&&(ll=h.values(l,e,i,p),el=new Map,new Set(ll).forEach((l=>{null!=l&&el.set(l,new Path2D)}))));let{x0:tl,size:nl}=a;if(null!=tl&&null!=nl){Y=1,x=tl.values(l,e,i,p),2==tl.unit&&(x=x.map((e=>l.posToVal(T+e*z,_.key,!0))));let t=nl.values(l,e,i,p);O=2==nl.unit?t[0]*z:k(t[0],_,z,T)-k(0,_,z,T),J=Ht(x,w,k,_,z,T,J),N=J-O+H}else J=Ht(x,w,k,_,z,T,J),N=J*s+H,O=J-N;1>N&&(N=0),O/2>q||(q=0),5>N&&(R=C);let il=N>0;O=R(W(J-N-(il?q:0),G,F)),L=(0==Y?O/2:Y==I?0:O)-Y*I*((0==Y?H/2:0)+(il?q/2:0));const ol={stroke:null,fill:null,clip:null,band:null,gaps:null,flags:0},sl=X?null:new Path2D;let rl=null;if(null!=B)rl=l.data[B.series[1]];else{let{y0:t,y1:n}=a;null!=t&&null!=n&&(w=n.values(l,e,i,p),rl=t.values(l,e,i,p))}let ul=P*O,al=A*O;for(let t=1==I?i:p;t>=i&&p>=t;t+=I){let n=w[t];if(null==n)continue;if(null!=rl){let l=rl[t]??0;if(n-l==0)continue;$=S(l,v,D,E)}let i=k(2!=_.distr||null!=a?x[t]:t,_,z,T),o=S(d(n,U),v,D,E),s=R(i-L),r=R(M(o,$)),u=R(y(o,$)),f=r-u;if(null!=n){let i=0>n?al:ul,o=0>n?ul:al;X?(q>0&&null!=ll[t]&&j(el.get(ll[t]),s,u+b(q/2),O,M(0,f-q),i,o),null!=Z[t]&&j(Q.get(Z[t]),s,u+b(q/2),O,M(0,f-q),i,o)):j(sl,s,u+b(q/2),O,M(0,f-q),i,o),V(l,e,t,s-q/2,u,O+q,f)}}return q>0?ol.stroke=X?el:sl:X||(ol._fill=0==g.width?g._fill:g._stroke??g._fill,ol.width=0),ol.fill=X?Q:sl,ol}))}},l.spline=function(l){return function(l,e){const t=d(e?.alignGaps,0);return(e,n,o,s)=>dt(e,n,((r,u,a,f,c,h,d,p,m,g,x)=>{[o,s]=i(a,o,s);let w,_,b,v=r.pxRound,k=l=>v(h(l,f,g,p)),y=l=>v(d(l,c,x,m));0==f.ori?(w=vt,b=yt,_=Dt):(w=kt,b=Mt,_=Pt);const M=f.dir*(0==f.ori?1:-1);let S=k(u[1==M?o:s]),T=S,E=[],z=[];for(let l=1==M?o:s;l>=o&&s>=l;l+=M)if(null!=a[l]){let e=k(u[l]);E.push(T=e),z.push(y(a[l]))}const D={stroke:l(E,z,w,b,_,v),fill:null,clip:null,band:null,gaps:null,flags:1},P=D.stroke;let[A,W]=pt(e,n);if(null!=r.fill||0!=A){let l=D.fill=new Path2D(P),t=y(r.fillTo(e,n,r.min,r.max,A));b(l,T,t),b(l,S,t)}if(!r.spanGaps){let l=[];l.push(...wt(u,a,o,s,M,k,t)),D.gaps=l=r.gaps(e,n,o,s,l),D.clip=xt(l,f.ori,p,m,g,x)}return 0!=W&&(D.band=2==W?[gt(e,n,o,s,P,-1),gt(e,n,o,s,P,1)]:gt(e,n,o,s,P,W)),D}))}(Ft,l)}}return Qt}(); +var uPlot=function(){"use strict";function e(e,t,l,n){let i;l=l||0;let s=2147483647>=(n=n||t.length-1);for(;n-l>1;)i=s?l+n>>1:_((l+n)/2),e>t[i]?l=i:n=i;return e-t[l]>t[n]-e?n:l}function t(e){return(t,l,n)=>{let i=-1,s=-1;for(let s=l;n>=s;s++)if(e(t[s])){i=s;break}for(let i=n;i>=l;i--)if(e(t[i])){s=i;break}return[i,s]}}const l=e=>null!=e,n=e=>null!=e&&e>0,i=t(l),s=t(n);function o(e,t,l,n){2==l&&(n=!0);let i=S(e),s=S(t);e==t&&(-1==i?(e*=l,t/=l):(e/=l,t*=l));let o=10==l?z:D,r=1==i?_:k,u=1==s?k:_,a=o(b(e)),f=o(b(t)),c=r(a),h=u(f),p=T(l,c),d=T(l,h);return 10==l&&(0>c&&(p=V(p,-c)),0>h&&(d=V(d,-h))),n?(e=p*i,t=d*s):(e=j(e,T(l,_(a)),!1),t=N(t,T(l,_(f)),!1)),[e,t]}function r(e,t,l,n){let i=o(e,t,l,n);return 0==e&&(i[0]=0),0==t&&(i[1]=0),i}const u=.1,a={mode:3,pad:u},f={pad:0,soft:null,mode:0},c={min:f,max:f};function h(e,t,l,n){return te(l)?d(e,t,l):(f.pad=l,f.soft=n?0:null,f.mode=n?3:0,d(e,t,c))}function p(e,t){return null==e?t:e}function d(e,t,l){let n=l.min,i=l.max,s=p(n.pad,0),o=p(i.pad,0),r=p(n.hard,-P),u=p(i.hard,P),a=p(n.soft,P),f=p(i.soft,-P),c=p(n.mode,0),h=p(i.mode,0),d=t-e,m=z(d),g=M(b(e),b(t)),x=z(g),w=b(x-m);(1e-24>d||w>10)&&(d=0,0!=e&&0!=t||(d=1e-24,2==c&&a!=P&&(s=0),2==h&&f!=-P&&(o=0)));let v=d||g||1e3,k=z(v),S=T(10,_(k)),D=V(j(e-v*(0==d?0==e?.1:1:s),S/10),24),E=a>e||1!=c&&(3!=c||D>a)&&(2!=c||a>D)?P:a,A=M(r,E>D&&e>=E?E:y(E,D)),C=V(N(t+v*(0==d?0==t?.1:1:o),S/10),24),W=t>f||1!=h&&(3!=h||f>C)&&(2!=h||C>f)?-P:f,Y=y(u,C>W&&W>=t?W:M(W,C));return A==Y&&0==A&&(Y=100),[A,Y]}const m=new Intl.NumberFormat,g=e=>m.format(e),x=Math,w=x.PI,b=x.abs,_=x.floor,v=x.round,k=x.ceil,y=x.min,M=x.max,T=x.pow,S=x.sign,z=x.log10,D=x.log2,E=(e,t=1)=>x.asinh(e/t),P=1/0;function A(e){return 1+(0|z((e^e>>31)-(e>>31)))}function C(e,t,l){return y(M(e,t),l)}function W(e){return"function"==typeof e}function Y(e){return W(e)?e:()=>e}const H=e=>e,R=(e,t)=>t,F=()=>null,G=()=>!0,I=(e,t)=>e==t,O=/\.\d*?(?=9{6,}|0{6,})/gm,L=e=>{if(Q(e)||B.has(e))return e;const t=""+e,l=t.match(O);if(null==l)return e;let n=l[0].length-1;if(-1!=t.indexOf("e-")){let[e,l]=t.split("e");return+`${L(e)}e${l}`}return V(e,n)};function U(e,t,l=!0){return l?L(V(L(e/t))*t):V(e/t)*t}function N(e,t,l=!0){return l?L(k(L(e/t))*t):k(e/t)*t}function j(e,t,l=!0){return l?L(_(L(e/t))*t):_(e/t)*t}function V(e,t=0){if(Q(e))return e;let l=10**t;return v(e*l*(1+Number.EPSILON))/l}const B=new Map;function Z(e){return((""+e).split(".")[1]||"").length}function $(e,t,l,n){let i=[],s=n.map(Z);for(let o=t;l>o;o++){let t=b(o),l=V(T(e,o),t);for(let r=0;n.length>r;r++){let u=10==e?+`${n[r]}e${o}`:n[r]*l,a=(0>o?t:0)+(s[r]>o?s[r]:0),f=10==e?u:V(u,a);i.push(f),B.set(f,a)}}return i}const J={},q=[],K=[null,null],X=Array.isArray,Q=Number.isInteger;function ee(e){return"string"==typeof e}function te(e){let t=!1;if(null!=e){let l=e.constructor;t=null==l||l==Object}return t}function le(e){return null!=e&&"object"==typeof e}const ne=Object.getPrototypeOf(Uint8Array),ie="__proto__";function se(e,t=te){let l;if(X(e)){let n=e.find((e=>null!=e));if(X(n)||t(n)){l=Array(e.length);for(let n=0;e.length>n;n++)l[n]=se(e[n],t)}else l=e.slice()}else if(e instanceof ne)l=e.slice();else if(t(e)){l={};for(let n in e)n!=ie&&(l[n]=se(e[n],t))}else l=e;return l}function oe(e){let t=arguments;for(let l=1;t.length>l;l++){let n=t[l];for(let t in n)t!=ie&&(te(e[t])?oe(e[t],se(n[t])):e[t]=se(n[t]))}return e}function re(e,t,l){for(let n,i=0,s=-1;t.length>i;i++){let o=t[i];if(o>s){for(n=o-1;n>=0&&null==e[n];)e[n--]=null;for(n=o+1;l>n&&null==e[n];)e[s=n++]=null}}}const ue="undefined"==typeof queueMicrotask?e=>Promise.resolve().then(e):queueMicrotask,ae="width",fe="height",ce="top",he="bottom",pe="left",de="right",me="#000",ge=me+"0",xe="mousemove",we="mousedown",be="mouseup",_e="mouseenter",ve="mouseleave",ke="dblclick",ye="change",Me="dppxchange",Te="--",Se="u-off",ze="u-label",De="undefined"!=typeof window,Ee=De?document:null,Pe=De?window:null;let Ae,Ce;function We(e,t){if(null!=t){let l=e.classList;!l.contains(t)&&l.add(t)}}function Ye(e,t){let l=e.classList;l.contains(t)&&l.remove(t)}function He(e,t,l){e.style[t]=l+"px"}function Re(e,t,l,n){let i=Ee.createElement(e);return null!=t&&We(i,t),null!=l&&l.insertBefore(i,n),i}function Fe(e,t){return Re("div",e,t)}const Ge=new WeakMap;function Ie(e,t,l,n,i){let s="translate("+t+"px,"+l+"px)";s!=Ge.get(e)&&(e.style.transform=s,Ge.set(e,s),0>t||0>l||t>n||l>i?We(e,Se):Ye(e,Se))}const Oe=new WeakMap;function Le(e,t,l){let n=t+l;n!=Oe.get(e)&&(Oe.set(e,n),e.style.background=t,e.style.borderColor=l)}const Ue=new WeakMap;function Ne(e,t,l,n){let i=t+""+l;i!=Ue.get(e)&&(Ue.set(e,i),e.style.height=l+"px",e.style.width=t+"px",e.style.marginLeft=n?-t/2+"px":0,e.style.marginTop=n?-l/2+"px":0)}const je={passive:!0},Ve={...je,capture:!0};function Be(e,t,l,n){t.addEventListener(e,l,n?Ve:je)}function Ze(e,t,l){t.removeEventListener(e,l,je)}De&&function e(){let t=devicePixelRatio;Ae!=t&&(Ae=t,Ce&&Ze(ye,Ce,e),Ce=matchMedia(`(min-resolution: ${Ae-.001}dppx) and (max-resolution: ${Ae+.001}dppx)`),Be(ye,Ce,e),Pe.dispatchEvent(new CustomEvent(Me)))}();const $e=["January","February","March","April","May","June","July","August","September","October","November","December"],Je=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function qe(e){return e.slice(0,3)}const Ke=Je.map(qe),Xe=$e.map(qe),Qe={MMMM:$e,MMM:Xe,WWWW:Je,WWW:Ke};function et(e){return(10>e?"0":"")+e}const tt={YYYY:e=>e.getFullYear(),YY:e=>(e.getFullYear()+"").slice(2),MMMM:(e,t)=>t.MMMM[e.getMonth()],MMM:(e,t)=>t.MMM[e.getMonth()],MM:e=>et(e.getMonth()+1),M:e=>e.getMonth()+1,DD:e=>et(e.getDate()),D:e=>e.getDate(),WWWW:(e,t)=>t.WWWW[e.getDay()],WWW:(e,t)=>t.WWW[e.getDay()],HH:e=>et(e.getHours()),H:e=>e.getHours(),h:e=>{let t=e.getHours();return 0==t?12:t>12?t-12:t},AA:e=>12>e.getHours()?"AM":"PM",aa:e=>12>e.getHours()?"am":"pm",a:e=>12>e.getHours()?"a":"p",mm:e=>et(e.getMinutes()),m:e=>e.getMinutes(),ss:e=>et(e.getSeconds()),s:e=>e.getSeconds(),fff:e=>function(e){return(10>e?"00":100>e?"0":"")+e}(e.getMilliseconds())};function lt(e,t){t=t||Qe;let l,n=[],i=/\{([a-z]+)\}|[^{]+/gi;for(;l=i.exec(e);)n.push("{"==l[0][0]?tt[l[1]]:l[0]);return e=>{let l="";for(let i=0;n.length>i;i++)l+="string"==typeof n[i]?n[i]:n[i](e,t);return l}}const nt=(new Intl.DateTimeFormat).resolvedOptions().timeZone,it="2-digit",st={weekday:"short",year:"numeric",month:it,day:it,hour:it,minute:it,second:it,fractionalSecondDigits:3,timeZoneName:"longOffset"},ot={};class rt extends Date{tz=null;#e=!1;#t=null;constructor(...e){super(...e),e[0]instanceof rt&&(this.tz=e[0].tz,this.#t=e[0].#t,this.#e=e[0].#e)}#l(e,t,l,n,i=0){let s=this.#t;return this.#e?e.call(this):null==s?t.call(this):+s.slice(l,n)+i}setTimeZone(e){if(this.tz=e,"UTC"==e||"Etc/UTC"==e)this.#e=!0;else{let t=function(e){return null==ot[e]&&(ot[e]=new Intl.DateTimeFormat("sv",{...st,timeZone:e}).format),ot[e]}(e),l=t(this);l.endsWith("GMT")&&(l+="+00:00"),this.#t=l}}getFullYear(){return this.#l(this.getUTCFullYear,super.getFullYear,-33,-29)}getMonth(){return this.#l(this.getUTCMonth,super.getMonth,-28,-26,-1)}getDate(){return this.#l(this.getUTCDate,super.getDate,-25,-23)}getHours(){return this.#l(this.getUTCHours,super.getHours,-22,-20)}getMinutes(){return this.#l(this.getUTCMinutes,super.getMinutes,-19,-17)}getSeconds(){return this.#l(this.getUTCSeconds,super.getSeconds,-16,-14)}getMilliseconds(){return this.#l(this.getUTCMilliseconds,super.getMilliseconds,-13,-10)}getDay(){let e=this.#t;return this.#e?this.getUTCDay():null==e?super.getDay():"s"==e[0]?0:"m"==e[0]?1:"i"==e[1]?2:"o"==e[0]?3:"o"==e[1]?4:"f"==e[0]?5:"l"==e[0]?6:-1}getTimezoneOffset(){let e=this.#t;return this.#e?0:null==e?super.getTimezoneOffset():(60*+e.slice(-5,-3)+ +e.slice(-2))*("-"==e.at(-6)?-1:1)}}const ut=4,at=5;function ft(e,t){let l=e.getTime()-(e.getMilliseconds()+1e3*e.getSeconds()+6e4*e.getMinutes()+36e5*e.getHours()+864e5*(t==ut?e.getDate()-1:t==at?function(e){let t=e.getFullYear(),l=e.getMonth()+1;return 31*--l-(l>1?(1054267675>>3*l-6&7)-(3&t||!(t%25)&&15&t?0:1):0)+e.getDate()}(e)-1:0)),n=new rt(l);n.setTimeZone(e.tz);let i=n.getHours();return i>0&&(n=new rt(l+36e5*(i>12?24-i:-i)),n.setTimeZone(e.tz)),n}const ct=e=>e%1==0,ht=[1,2,2.5,5],pt=$(10,-32,0,ht),dt=$(10,0,32,ht),mt=dt.filter(ct),gt=pt.concat(dt),xt="{YYYY}",wt="\n"+xt,bt="{M}/{D}",_t="\n"+bt,vt=_t+"/{YY}",kt="{aa}",yt="{h}:{mm}"+kt,Mt="\n"+yt,Tt=":{ss}",St=null;function zt(e){let t=1e3*e,l=60*t,n=60*l,i=24*n,s=30*i,o=365*i;return[(1==e?$(10,0,3,ht).filter(ct):$(10,-3,0,ht)).concat([t,5*t,10*t,15*t,30*t,l,5*l,10*l,15*l,30*l,n,2*n,3*n,4*n,6*n,8*n,12*n,i,2*i,3*i,4*i,5*i,6*i,7*i,8*i,9*i,10*i,15*i,s,2*s,3*s,4*s,6*s,o,2*o,5*o,10*o,25*o,50*o,100*o]),[[o,xt,St,St,St,St,St,St,1],[28*i,"{MMM}",wt,St,St,St,St,St,1],[i,bt,wt,St,St,St,St,St,1],[n,"{h}"+kt,vt,St,_t,St,St,St,1],[l,yt,vt,St,_t,St,St,St,1],[t,Tt,vt+" "+yt,St,_t+" "+yt,St,Mt,St,1],[e,Tt+".{fff}",vt+" "+yt,St,_t+" "+yt,St,Mt,St,1]],function(t){return(l,r,u,a,f)=>{let c=[],h=f>=o,p=f>=s&&o>f,d=f>=i&&s>f,m=f>n&&i>f,g=t(u),x=V(g*e,3),w=V(ft(g,h||p?at:d?ut:3)*e,3);if(d){let l=f/i,s=w+f*_((g.getDate()-1)/l);for(;;){let i=t(s),o=i.getHours();if(0!=o&&(s+=o>12?n:-n,i=t(s)),(i.getDate()-1)%l>0&&(i=ft(i,ut),s=i.getTime()*e,.7*f>s-c[c.length-1]&&c.pop()),s>a)break;u>s||c.push(s),s+=f}}else if(p||h){let l=1,n=1,r=0,d=0;p?(l=f/s,n=32,r=ut,d=g.getMonth()):h&&(l=f/o,n=366,r=at,d=g.getYear());let m=w+(f=l*n*i)*_(d/n);for(;m=ft(t(m),r).getTime()*e,m<=a;)u>m||c.push(m),m+=f}else if(m){let e=f/n,l=w+f*_(g.getHours()/e);for(;t(l).getHours()%e>0&&(l+=t(l+n).getHours()%e==0?n:-n),l<=a;)u>l||c.push(l),l+=f}else{let e=w+N(x-w,f);for(;e<=a;)u>e||c.push(e),e+=f;c.push(e)}return c}}]}const[Dt,Et,Pt]=zt(1),[At,Ct,Wt]=zt(.001);function Yt(e,t){return e.map((e=>e.map(((l,n)=>0==n||8==n||null==l?l:t(1==n||0==e[8]?l:e[1]+l)))))}function Ht(e,t){return(l,n,i,s,o)=>{let r,u,a,f,c,h,p=t.find((e=>o>=e[0]))||t[t.length-1];return n.map((t=>{let l=e(t),n=l.getFullYear(),i=l.getMonth(),s=l.getDate(),o=l.getHours(),d=l.getMinutes(),m=l.getSeconds(),g=n!=r&&p[2]||i!=u&&p[3]||s!=a&&p[4]||o!=f&&p[5]||d!=c&&p[6]||m!=h&&p[7]||p[1];return r=n,u=i,a=s,f=o,c=d,h=m,g(l)}))}}function Rt(e,t){return t(e)}function Ft(e,t){return(l,n,i,s)=>null==s?Te:t(e(n))}$(2,-53,53,[1]);const Gt={show:!0,live:!0,isolate:!1,mount:()=>{},markers:{show:!0,width:2,stroke:function(e,t){let l=e.series[t];return l.width?l.stroke(e,t):l.points.width?l.points.stroke(e,t):null},fill:function(e,t){return e.series[t].fill(e,t)},dash:"solid"},idx:null,idxs:null,values:[]},It=[0,0];function Ot(e,t,l,n=!0){return e=>{0==e.button&&(!n||e.target==t)&&l(e)}}function Lt(e,t,l,n=!0){return e=>{(!n||e.target==t)&&l(e)}}const Ut={show:!0,x:!0,y:!0,lock:!1,move:function(e,t,l){return It[0]=t,It[1]=l,It},points:{one:!1,show:function(e,t){let l=e.cursor.points,n=Fe(),i=l.size(e,t);He(n,ae,i),He(n,fe,i);let s=i/-2;He(n,"marginLeft",s),He(n,"marginTop",s);let o=l.width(e,t,i);return o&&He(n,"borderWidth",o),n},size:function(e,t){return e.series[t].points.size},width:0,stroke:function(e,t){let l=e.series[t].points;return l._stroke||l._fill},fill:function(e,t){let l=e.series[t].points;return l._fill||l._stroke}},bind:{mousedown:Ot,mouseup:Ot,click:Ot,dblclick:Ot,mousemove:Lt,mouseleave:Lt,mouseenter:Lt},drag:{setScale:!0,x:!0,y:!1,dist:0,uni:null,click:(e,t)=>{t.stopPropagation(),t.stopImmediatePropagation()},_x:!1,_y:!1},focus:{dist:(e,t,l,n,i)=>n-i,prox:-1,bias:0},hover:{skip:[void 0],prox:null,bias:0},left:-10,top:-10,idx:null,dataIdx:null,idxs:null,event:null},Nt={show:!0,stroke:"rgba(0,0,0,0.07)",width:2},jt=oe({},Nt,{filter:R}),Vt=oe({},jt,{size:10}),Bt=oe({},Nt,{show:!1}),Zt='12px system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',$t="bold "+Zt,Jt={show:!0,scale:"x",stroke:me,space:50,gap:5,alignTo:1,size:50,labelGap:0,labelSize:30,labelFont:$t,side:2,grid:jt,ticks:Vt,border:Bt,font:Zt,lineGap:1.5,rotate:0},qt={show:!0,scale:"x",auto:!1,sorted:1,min:P,max:-P,idxs:[]};function Kt(e,t){return t.map((e=>null==e?"":g(e)))}function Xt(e,t,l,n,i,s,o){let r=[],u=B.get(i)||0;for(let e=l=o?l:V(N(l,i),u);n>=e;e=V(e+i,u))r.push(Object.is(e,-0)?0:e);return r}function Qt(t,l,n,i,s){const o=[],r=t.scales[t.axes[l].scale].log,u=_((10==r?z:D)(n));s=T(r,u),10==r&&(s=gt[e(s,gt)]);let a=n,f=s*r;10==r&&(f=gt[e(f,gt)]);do{o.push(a),a+=s,10!=r||B.has(a)||(a=V(a,B.get(s))),f>a||(f=(s=a)*r,10==r&&(f=gt[e(f,gt)]))}while(i>=a);return o}function el(e,t,l,n,i){let s=e.scales[e.axes[t].scale].asinh,o=n>s?Qt(e,t,M(s,l),n,i):[s],r=0>n||l>0?[]:[0];return(-s>l?Qt(e,t,M(s,-n),-l,i):[s]).reverse().map((e=>-e)).concat(r,o)}const tl=/./,ll=/[12357]/,nl=/[125]/,il=/1/,sl=(e,t,l,n)=>e.map(((e,i)=>4==t&&0==e||i%n==0&&l.test(e.toExponential()[0>e?1:0])?e:null));function ol(e,t,l){let n=e.axes[l],i=n.scale,s=e.scales[i],o=e.valToPos,r=n._space,u=o(10,i),a=o(9,i)-ue)return sl(t.slice().reverse(),s.distr,a,k(r/e)).reverse()}return sl(t,s.distr,a,1)}function rl(e,t,l){let n=e.axes[l],i=n.scale,s=n._space,o=e.valToPos,r=b(o(1,i)-o(2,i));return s>r?sl(t.slice().reverse(),3,tl,k(s/r)).reverse():t}function ul(e,t,l,n){return null==n?Te:null==t?"":g(t)}const al={show:!0,scale:"y",stroke:me,space:30,gap:5,alignTo:1,size:50,labelGap:0,labelSize:30,labelFont:$t,side:3,grid:jt,ticks:Vt,border:Bt,font:Zt,lineGap:1.5,rotate:0},fl={scale:null,auto:!0,sorted:0,min:P,max:-P},cl=(e,t,l,n,i)=>i,hl={show:!0,auto:!0,sorted:0,gaps:cl,alpha:1,facets:[oe({},fl,{scale:"x"}),oe({},fl,{scale:"y"})]},pl={scale:"y",auto:!0,sorted:0,show:!0,spanGaps:!1,gaps:cl,alpha:1,points:{show:function(e,t){let{scale:l,idxs:n}=e.series[0],i=e._data[0],s=e.valToPos(i[n[0]],l,!0),o=e.valToPos(i[n[1]],l,!0);return b(o-s)/(e.series[t].points.space*e.pxRatio)>=n[1]-n[0]},filter:null},values:null,min:P,max:-P,idxs:[],path:null,clip:null};function dl(e,t,l){return l/10}const ml={time:!0,auto:!0,distr:1,log:10,asinh:1,min:null,max:null,dir:1,ori:0},gl=oe({},ml,{time:!1,ori:1}),xl={};function wl(e){let t=xl[e];return t||(t={key:e,plots:[],sub(e){t.plots.push(e)},unsub(e){t.plots=t.plots.filter((t=>t!=e))},pub(e,l,n,i,s,o,r){for(let u=0;t.plots.length>u;u++)t.plots[u]!=l&&t.plots[u].pub(e,l,n,i,s,o,r)}},null!=e&&(xl[e]=t)),t}function bl(e,t,l){const n=e.mode,i=e.series[t],s=2==n?e._data[t]:e._data,o=e.scales,r=e.bbox;let u=s[0],a=2==n?s[1]:s[t],f=2==n?o[i.facets[0].scale]:o[e.series[0].scale],c=2==n?o[i.facets[1].scale]:o[i.scale],h=r.left,p=r.top,d=r.width,m=r.height,g=e.valToPosH,x=e.valToPosV;return 0==f.ori?l(i,u,a,f,c,g,x,h,p,d,m,zl,El,Al,Wl,Hl):l(i,u,a,f,c,x,g,p,h,m,d,Dl,Pl,Cl,Yl,Rl)}function _l(e,t){let l=0,n=0,i=p(e.bands,q);for(let e=0;i.length>e;e++){let s=i[e];s.series[0]==t?l=s.dir:s.series[1]==t&&(n|=1==s.dir?1:2)}return[l,1==n?-1:2==n?1:3==n?2:0]}function vl(e,t,l,n,i){let s=e.series[t],o=e.scales[2==e.mode?s.facets[1].scale:s.scale];return-1==i?o.min:1==i?o.max:3==o.distr?1==o.dir?o.min:o.max:0}function kl(e,t,l,n,i,s){return bl(e,t,((e,t,o,r,u,a,f,c,h,p,d)=>{let m=e.pxRound;const g=0==r.ori?El:Pl;let x,w;1==r.dir*(0==r.ori?1:-1)?(x=l,w=n):(x=n,w=l);let b=m(a(t[x],r,p,c)),_=m(f(o[x],u,d,h)),v=m(a(t[w],r,p,c)),k=m(f(1==s?u.max:u.min,u,d,h)),y=new Path2D(i);return g(y,v,k),g(y,b,k),g(y,b,_),y}))}function yl(e,t,l,n,i,s){let o=null;if(e.length>0){o=new Path2D;const r=0==t?Al:Cl;let u=l;for(let t=0;e.length>t;t++){let l=e[t];if(l[1]>l[0]){let e=l[0]-u;e>0&&r(o,u,n,e,n+s),u=l[1]}}let a=l+i-u,f=10;a>0&&r(o,u,n-f/2,a,n+s+f)}return o}function Ml(e,t,l,n,i,s,o){let r=[],u=e.length;for(let a=1==i?l:n;a>=l&&n>=a;a+=i)if(null===t[a]){let f=a,c=a;if(1==i)for(;++a<=n&&null===t[a];)c=a;else for(;--a>=l&&null===t[a];)c=a;let h=s(e[f]),p=c==f?h:s(e[c]),d=f-i;h=o>0||0>d||d>=u?h:s(e[d]);let m=c+i;p=0>o||0>m||m>=u?p:s(e[m]),h>p||r.push([h,p])}return r}function Tl(e){return 0==e?H:1==e?v:t=>U(t,e)}function Sl(e){let t=0==e?zl:Dl,l=0==e?(e,t,l,n,i,s)=>{e.arcTo(t,l,n,i,s)}:(e,t,l,n,i,s)=>{e.arcTo(l,t,i,n,s)},n=0==e?(e,t,l,n,i)=>{e.rect(t,l,n,i)}:(e,t,l,n,i)=>{e.rect(l,t,i,n)};return(e,i,s,o,r,u=0,a=0)=>{0==u&&0==a?n(e,i,s,o,r):(u=y(u,o/2,r/2),a=y(a,o/2,r/2),t(e,i+u,s),l(e,i+o,s,i+o,s+r,u),l(e,i+o,s+r,i,s+r,a),l(e,i,s+r,i,s,a),l(e,i,s,i+o,s,u),e.closePath())}}const zl=(e,t,l)=>{e.moveTo(t,l)},Dl=(e,t,l)=>{e.moveTo(l,t)},El=(e,t,l)=>{e.lineTo(t,l)},Pl=(e,t,l)=>{e.lineTo(l,t)},Al=Sl(0),Cl=Sl(1),Wl=(e,t,l,n,i,s)=>{e.arc(t,l,n,i,s)},Yl=(e,t,l,n,i,s)=>{e.arc(l,t,n,i,s)},Hl=(e,t,l,n,i,s,o)=>{e.bezierCurveTo(t,l,n,i,s,o)},Rl=(e,t,l,n,i,s,o)=>{e.bezierCurveTo(l,t,i,n,o,s)};function Fl(){return(e,t,l,n,i)=>{let{pxRatio:s}=e;return bl(e,t,((t,o,r,u,a,f,c,h,p,d,m)=>{let g,x,{pxRound:b,points:_}=t;0==u.ori?(g=zl,x=Wl):(g=Dl,x=Yl);const v=V(_.width*s,3);let k=(_.size-_.width)/2*s,y=V(2*k,3),M=new Path2D,T=new Path2D,{left:S,top:z,width:D,height:E}=e.bbox;Al(T,S-y,z-y,D+2*y,E+2*y);const P=e=>{if(null!=r[e]){let t=b(f(o[e],u,d,h)),l=b(c(r[e],a,m,p));g(M,t+k,l),x(M,t,l,k,0,2*w)}};if(i)i.forEach(P);else for(let e=l;n>=e;e++)P(e);return{stroke:v>0?M:null,fill:M,clip:T,flags:3}}))}}function Gl(e){return(t,l,n,i,s,o)=>{n!=i&&(s!=n&&o!=n&&e(t,l,n),s!=i&&o!=i&&e(t,l,i),e(t,l,o))}}const Il=Gl(El),Ol=Gl(Pl);function Ll(e){const t=p(e?.alignGaps,0);return(e,l,n,s)=>bl(e,l,((o,r,u,a,f,c,h,p,d,m,g)=>{[n,s]=i(u,n,s);let x,w,b=o.pxRound,_=e=>b(c(e,a,m,p)),v=e=>b(h(e,f,g,d));0==a.ori?(x=El,w=Il):(x=Pl,w=Ol);const k=a.dir*(0==a.ori?1:-1),y={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:1},M=y.stroke;let T=!1;if(s-n<4*m)for(let e=1==k?n:s;e>=n&&s>=e;e+=k){let t=u[e];null===t?T=!0:null!=t&&x(M,_(r[e]),v(t))}else{let t,l,i,o=t=>e.posToVal(t,a.key,!0),f=null,c=null,h=_(r[1==k?n:s]),p=_(r[n]),d=_(r[s]),m=o(1==k?p+1:d-1);for(let e=1==k?n:s;e>=n&&s>=e;e+=k){let n=r[e],i=(1==k?m>n:n>m)?h:_(n),s=u[e];i==h?null!=s?(l=s,null==f?(x(M,i,v(l)),t=f=c=l):f>l?f=l:l>c&&(c=l)):null===s&&(T=!0):(null!=f&&w(M,h,v(f),v(c),v(t),v(l)),null!=s?(l=s,x(M,i,v(l)),f=c=t=l):(f=c=null,null===s&&(T=!0)),h=i,m=o(h+k))}null!=f&&f!=c&&i!=h&&w(M,h,v(f),v(c),v(t),v(l))}let[S,z]=_l(e,l);if(null!=o.fill||0!=S){let t=y.fill=new Path2D(M),i=v(o.fillTo(e,l,o.min,o.max,S)),u=_(r[n]),a=_(r[s]);-1==k&&([a,u]=[u,a]),x(t,a,i),x(t,u,i)}if(!o.spanGaps){let i=[];T&&i.push(...Ml(r,u,n,s,k,_,t)),y.gaps=i=o.gaps(e,l,n,s,i),y.clip=yl(i,a.ori,p,d,m,g)}return 0!=z&&(y.band=2==z?[kl(e,l,n,s,M,-1),kl(e,l,n,s,M,1)]:kl(e,l,n,s,M,z)),y}))}function Ul(e,t,l,n,i,s,o=P){if(e.length>1){let r=null;for(let u=0,a=1/0;e.length>u;u++)if(void 0!==t[u]){if(null!=r){let t=b(e[u]-e[r]);a>t&&(a=t,o=b(l(e[u],n,i,s)-l(e[r],n,i,s)))}r=u}}return o}function Nl(e,t,l,n,i){const s=e.length;if(2>s)return null;const o=new Path2D;if(l(o,e[0],t[0]),2==s)n(o,e[1],t[1]);else{let l=Array(s),n=Array(s-1),r=Array(s-1),u=Array(s-1);for(let l=0;s-1>l;l++)r[l]=t[l+1]-t[l],u[l]=e[l+1]-e[l],n[l]=r[l]/u[l];l[0]=n[0];for(let e=1;s-1>e;e++)0===n[e]||0===n[e-1]||n[e-1]>0!=n[e]>0?l[e]=0:(l[e]=3*(u[e-1]+u[e])/((2*u[e]+u[e-1])/n[e-1]+(u[e]+2*u[e-1])/n[e]),isFinite(l[e])||(l[e]=0));l[s-1]=n[s-2];for(let n=0;s-1>n;n++)i(o,e[n]+u[n]/3,t[n]+l[n]*u[n]/3,e[n+1]-u[n]/3,t[n+1]-l[n+1]*u[n]/3,e[n+1],t[n+1])}return o}const jl=new Set;function Vl(){for(let e of jl)e.syncRect(!0)}De&&(Be("resize",Pe,Vl),Be("scroll",Pe,Vl,!0),Be(Me,Pe,(()=>{on.pxRatio=Ae})));const Bl=Ll(),Zl=Fl();function $l(e,t,l,n){return(n?[e[0],e[1]].concat(e.slice(2)):[e[0]].concat(e.slice(1))).map(((e,n)=>Jl(e,n,t,l)))}function Jl(e,t,l,n){return oe({},0==t?l:n,e)}function ql(e,t,l){return null==t?K:[t,l]}const Kl=ql;function Xl(e,t,l){return null==t?K:h(t,l,u,!0)}function Ql(e,t,l,n){return null==t?K:o(t,l,e.scales[n].log,!0)}const en=Ql;function tn(e,t,l,n){return null==t?K:r(t,l,e.scales[n].log,!0)}const ln=tn;function nn(t,l,n,i,s){let o=M(A(t),A(l)),r=l-t,u=e(s/i*r,n);do{let e=n[u],t=i*e/r;if(t>=s&&17>=o+(5>e?B.get(e):0))return[e,t]}while(++u(l=v((n=+i)*t))+"px")),l,n]}function on(t,f,c){let d=t.pxRatio??Ae;function m(e){d=g.pxRatio=e??Ae,ye.forEach((e=>function(e,t){e.show&&[e.font,e.labelFont].forEach((e=>{let l=V(e[2]*t,1);e[0]=e[0].replace(/[0-9.]+px/,l+"px"),e[1]=l}))}(e,d))),kl(g.width,g.height,!0)}const g={mode:p(t.mode,1),pxRatio:d,setPxRatio:m};g.setPxRatio=m;const _=g.mode;function S(e,t,l,n){let i=t.valToPct(e);return n+l*(-1==t.dir?1-i:i)}function D(e,t,l,n){let i=t.valToPct(e);return n+l*(-1==t.dir?i:1-i)}function A(e,t,l,n){return 0==t.ori?S(e,t,l,n):D(e,t,l,n)}g.valToPosH=S,g.valToPosV=D;let H=!1;g.status=0;const O=g.root=Fe("uplot");null!=t.id&&(O.id=t.id),We(O,t.class),t.title&&(Fe("u-title",O).textContent=t.title);const L=Re("canvas"),N=g.ctx=L.getContext("2d"),j=Fe("u-wrap",O);Be("click",j,(e=>{e.target===Q&&(Nn!=In||jn!=On)&&Qn.click(g,e)}),!0);const $=g.under=Fe("u-under",j);j.appendChild(L);const Q=g.over=Fe("u-over",j),ne=+p((t=se(t)).pxAlign,1),ie=Tl(ne);(t.plugins||[]).forEach((e=>{e.opts&&(t=e.opts(g,t)||t)}));const re=t.ms||.001,me=g.series=1==_?$l(t.series||[],qt,pl,!1):function(e,t){return e.map(((e,l)=>0==l?{}:oe({},t,e)))}(t.series||[null],hl),ye=g.axes=$l(t.axes||[],Jt,al,!0),De=g.scales={},Ce=g.bands=t.bands||[];Ce.forEach((e=>{e.fill=Y(e.fill||null),e.dir=p(e.dir,-1)}));const Ge=2==_?me[1].facets[0].scale:me[0].scale,Oe={axes:function(){for(let e=0;ye.length>e;e++){let t=ye[e];if(!t.show||!t._show)continue;let l,n,i=t.side,s=i%2,o=t.stroke(g,e),r=0==i||3==i?-1:1,[u,a]=t._found;if(null!=t.label){let f=v((t._lpos+t.labelGap*r)*d);_n(t.labelFont[0],o,"center",2==i?ce:he),N.save(),1==s?(l=n=0,N.translate(f,v(ll+il/2)),N.rotate((3==i?-w:w)/2)):(l=v(tl+nl/2),n=f);let c=W(t.label)?t.label(g,e,u,a):t.label;N.fillText(c,l,n),N.restore()}if(0==a)continue;let f=De[t.scale],c=0==s?nl:il,h=0==s?tl:ll,p=t._splits,m=2==f.distr?p.map((e=>mn[e])):p,x=2==f.distr?mn[p[1]]-mn[p[0]]:u,b=t.ticks,_=t.border,k=b.show?b.size:0,y=v(k*d),M=v((2==t.alignTo?t._size-k-t.gap:t.gap)*d),T=t._rotate*-w/180,S=ie(t._pos*d),z=S+(y+M)*r;n=0==s?z:0,l=1==s?z:0,_n(t.font[0],o,1==t.align?pe:2==t.align?de:T>0?pe:0>T?de:0==s?"center":3==i?de:pe,T||1==s?"middle":2==i?ce:he);let D=t.font[1]*t.lineGap,E=p.map((e=>ie(A(e,f,c,h)))),P=t._values;for(let e=0;P.length>e;e++){let t=P[e];if(null!=t){0==s?l=E[e]:n=E[e],t=""+t;let i=-1==t.indexOf("\n")?[t]:t.split(/\n/gm);for(let e=0;i.length>e;e++){let t=i[e];T?(N.save(),N.translate(l,n+e*D),N.rotate(T),N.fillText(t,0,0),N.restore()):N.fillText(t,l,n+e*D)}}}b.show&&En(E,b.filter(g,m,e,a,x),s,i,S,y,V(b.width*d,3),b.stroke(g,e),b.dash,b.cap);let C=t.grid;C.show&&En(E,C.filter(g,m,e,a,x),s,0==s?2:1,0==s?ll:tl,0==s?il:nl,V(C.width*d,3),C.stroke(g,e),C.dash,C.cap),_.show&&En([S],[1],0==s?1:0,0==s?1:2,1==s?ll:tl,1==s?il:nl,V(_.width*d,3),_.stroke(g,e),_.dash,_.cap)}Hi("drawAxes")},series:function(){if(Ol>0){let e=me.some((e=>e._focus))&&dn!=Dl.alpha;e&&(N.globalAlpha=dn=Dl.alpha),me.forEach(((e,t)=>{if(t>0&&e.show&&(yn(t,!1),yn(t,!0),null==e._paths)){let l=dn;dn!=e.alpha&&(N.globalAlpha=dn=e.alpha);let n=2==_?[0,f[t][0].length-1]:function(e){let t=C(Ll-1,0,Ol-1),l=C(Ul+1,0,Ol-1);for(;null==e[t]&&t>0;)t--;for(;null==e[l]&&Ol-1>l;)l++;return[t,l]}(f[t]);e._paths=e.paths(g,t,n[0],n[1]),dn!=l&&(N.globalAlpha=dn=l)}})),me.forEach(((e,t)=>{if(t>0&&e.show){let l=dn;dn!=e.alpha&&(N.globalAlpha=dn=e.alpha),null!=e._paths&&Mn(t,!1);{let l=null!=e._paths?e._paths.gaps:null,n=e.points.show(g,t,Ll,Ul,l),i=e.points.filter(g,t,n,l);(n||i)&&(e.points._paths=e.points.paths(g,t,Ll,Ul,i),Mn(t,!0))}dn!=l&&(N.globalAlpha=dn=l),Hi("drawSeries",t)}})),e&&(N.globalAlpha=dn=1)}}},Ue=(t.drawOrder||["axes","series"]).map((e=>Oe[e]));function je(e){const t=3==e.distr?t=>z(t>0?t:e.clamp(g,t,e.min,e.max,e.key)):4==e.distr?t=>E(t,e.asinh):100==e.distr?t=>e.fwd(t):e=>e;return l=>{let n=t(l),{_min:i,_max:s}=e;return(n-i)/(s-i)}}function Ve(e){let l=De[e];if(null==l){let n=(t.scales||J)[e]||J;if(null!=n.from){Ve(n.from);let t=oe({},De[n.from],n,{key:e});t.valToPct=je(t),De[e]=t}else{l=De[e]=oe({},e==Ge?ml:gl,n),l.key=e;let t=l.time,i=l.range,s=X(i);if((e!=Ge||2==_&&!t)&&(!s||null!=i[0]&&null!=i[1]||(i={min:null==i[0]?a:{mode:1,hard:i[0],soft:i[0]},max:null==i[1]?a:{mode:1,hard:i[1],soft:i[1]}},s=!1),!s&&te(i))){let e=i;i=(t,l,n)=>null==l?K:h(l,n,e)}l.range=Y(i||(t?Kl:e==Ge?3==l.distr?en:4==l.distr?ln:ql:3==l.distr?Ql:4==l.distr?tn:Xl)),l.auto=Y(!s&&l.auto),l.clamp=Y(l.clamp||dl),l._min=l._max=null,l.valToPct=je(l)}}}Ve("x"),Ve("y"),1==_&&me.forEach((e=>{Ve(e.scale)})),ye.forEach((e=>{Ve(e.scale)}));for(let e in t.scales)Ve(e);const $e=De[Ge],Je=$e.distr;let qe,Ke;0==$e.ori?(We(O,"u-hz"),qe=S,Ke=D):(We(O,"u-vt"),qe=D,Ke=S);const Xe={};for(let e in De){let t=De[e];null==t.min&&null==t.max||(Xe[e]={min:t.min,max:t.max},t.min=t.max=null)}const Qe=t.tzDate||(e=>new Date(v(e/re))),et=t.fmtDate||lt,tt=1==re?Pt(Qe):Wt(Qe),nt=Ht(Qe,Yt(1==re?Et:Ct,et)),it=Ft(Qe,Rt("{YYYY}-{MM}-{DD} {h}:{mm}{aa}",et)),st=[],ot=g.legend=oe({},Gt,t.legend),rt=g.cursor=oe({},Ut,{drag:{y:2==_}},t.cursor),ut=ot.show,at=rt.show,ft=ot.markers;let ct,ht,pt;ot.idxs=st,ft.width=Y(ft.width),ft.dash=Y(ft.dash),ft.stroke=Y(ft.stroke),ft.fill=Y(ft.fill);let dt,xt=[],wt=[],bt=!1,_t={};if(ot.live){const e=me[1]?me[1].values:null;bt=null!=e,dt=bt?e(g,1,0):{_:0};for(let e in dt)_t[e]=Te}if(ut)if(ct=Re("table","u-legend",O),pt=Re("tbody",null,ct),ot.mount(g,ct),bt){ht=Re("thead",null,ct,pt);let e=Re("tr",null,ht);for(var vt in Re("th",null,e),dt)Re("th",ze,e).textContent=vt}else We(ct,"u-inline"),ot.live&&We(ct,"u-live");const kt={show:!0},yt={show:!1},Mt=new Map;function Tt(e,t,l,n=!0){const i=Mt.get(t)||{},s=rt.bind[e](g,t,l,n);s&&(Be(e,t,i[e]=s),Mt.set(t,i))}function St(e,t){const l=Mt.get(t)||{};for(let n in l)null!=e&&n!=e||(Ze(n,t,l[n]),delete l[n]);null==e&&Mt.delete(t)}let zt=0,It=0,Ot=0,Lt=0,Nt=0,jt=0,Vt=Nt,Bt=jt,Zt=Ot,$t=Lt,tl=0,ll=0,nl=0,il=0;g.bbox={};let sl=!1,fl=!1,cl=!1,xl=!1,bl=!1,_l=!1;function kl(e,t,l){(l||e!=g.width||t!=g.height)&&yl(e,t),Cn(!1),cl=!0,fl=!0,Jn()}function yl(e,t){g.width=zt=Ot=e,g.height=It=Lt=t,Nt=jt=0,function(){let e=!1,t=!1,l=!1,n=!1;ye.forEach((i=>{if(i.show&&i._show){let{side:s,_size:o}=i,r=o+(null!=i.label?i.labelSize:0);r>0&&(s%2?(Ot-=r,3==s?(Nt+=r,n=!0):l=!0):(Lt-=r,0==s?(jt+=r,e=!0):t=!0))}})),Rl[0]=e,Rl[1]=l,Rl[2]=t,Rl[3]=n,Ot-=Il[1]+Il[3],Nt+=Il[3],Lt-=Il[2]+Il[0],jt+=Il[0]}(),function(){let e=Nt+Ot,t=jt+Lt,l=Nt,n=jt;function i(i,s){switch(i){case 1:return e+=s,e-s;case 2:return t+=s,t-s;case 3:return l-=s,l+s;case 0:return n-=s,n+s}}ye.forEach((e=>{if(e.show&&e._show){let t=e.side;e._pos=i(t,e._size),null!=e.label&&(e._lpos=i(t,e.labelSize))}}))}();let l=g.bbox;tl=l.left=U(Nt*d,.5),ll=l.top=U(jt*d,.5),nl=l.width=U(Ot*d,.5),il=l.height=U(Lt*d,.5)}const Ml=3;if(g.setSize=function({width:e,height:t}){kl(e,t)},null==rt.dataIdx){let e=rt.hover,t=e.skip=new Set(e.skip??[]);t.add(void 0);let l=e.prox=Y(e.prox),n=e.bias??=0;rt.dataIdx=(e,i,s,o)=>{if(0==i)return s;let r=s,u=l(e,i,s,o)??P,a=u>=0&&P>u,c=0==$e.ori?Ot:Lt,h=rt.left,p=f[0],d=f[i];if(t.has(d[s])){r=null;let e,l=null,i=null;if(0==n||-1==n)for(e=s;null==l&&e-- >0;)t.has(d[e])||(l=e);if(0==n||1==n)for(e=s;null==i&&e++t?t>u||(r=i):e>u||(r=l)}else r=null==i?l:null==l||s-l>i-s?i:l}else a&&b(h-qe(p[s],$e,c,0))>u&&(r=null);return r}}const Sl=e=>{rt.event=e};rt.idxs=st,rt._lock=!1;let zl=rt.points;zl.show=Y(zl.show),zl.size=Y(zl.size),zl.stroke=Y(zl.stroke),zl.width=Y(zl.width),zl.fill=Y(zl.fill);const Dl=g.focus=oe({},t.focus||{alpha:.3},rt.focus),El=Dl.prox>=0,Pl=El&&zl.one;let Al=[],Cl=[],Wl=[];function Yl(e,t){let l=zl.show(g,t);if(l instanceof HTMLElement)return We(l,"u-cursor-pt"),We(l,e.class),Ie(l,-10,-10,Ot,Lt),Q.insertBefore(l,Al[t]),l}function Hl(e,t){if(1==_||t>0){let t=1==_&&De[e.scale].time,l=e.value;e.value=t?ee(l)?Ft(Qe,Rt(l,et)):l||it:l||ul,e.label=e.label||(t?"Time":"Value")}if(Pl||t>0){e.width=null==e.width?1:e.width,e.paths=e.paths||Bl||F,e.fillTo=Y(e.fillTo||vl),e.pxAlign=+p(e.pxAlign,ne),e.pxRound=Tl(e.pxAlign),e.stroke=Y(e.stroke||null),e.fill=Y(e.fill||null),e._stroke=e._fill=e._paths=e._focus=null;let t=function(e){return V(1*(3+2*(e||1)),3)}(M(1,e.width)),l=e.points=oe({},{size:t,width:M(1,.2*t),stroke:e.stroke,space:2*t,paths:Zl,_stroke:null,_fill:null},e.points);l.show=Y(l.show),l.filter=Y(l.filter),l.fill=Y(l.fill),l.stroke=Y(l.stroke),l.paths=Y(l.paths),l.pxAlign=e.pxAlign}if(ut){let l=function(e,t){if(0==t&&(bt||!ot.live||2==_))return K;let l=[],n=Re("tr","u-series",pt,pt.childNodes[t]);We(n,e.class),e.show||We(n,Se);let i=Re("th",null,n);if(ft.show){let e=Fe("u-marker",i);if(t>0){let l=ft.width(g,t);l&&(e.style.border=l+"px "+ft.dash(g,t)+" "+ft.stroke(g,t)),e.style.background=ft.fill(g,t)}}let s=Fe(ze,i);for(var o in e.label instanceof HTMLElement?s.appendChild(e.label):s.textContent=e.label,t>0&&(ft.show||(s.style.color=e.width>0?ft.stroke(g,t):ft.fill(g,t)),Tt("click",i,(t=>{if(rt._lock)return;Sl(t);let l=me.indexOf(e);if((t.ctrlKey||t.metaKey)!=ot.isolate){let e=me.some(((e,t)=>t>0&&t!=l&&e.show));me.forEach(((t,n)=>{n>0&&oi(n,e?n==l?kt:yt:kt,!0,Fi.setSeries)}))}else oi(l,{show:!e.show},!0,Fi.setSeries)}),!1),El&&Tt(_e,i,(t=>{rt._lock||(Sl(t),oi(me.indexOf(e),fi,!0,Fi.setSeries))}),!1)),dt){let e=Re("td","u-value",n);e.textContent="--",l.push(e)}return[n,l]}(e,t);xt.splice(t,0,l[0]),wt.splice(t,0,l[1]),ot.values.push(null)}if(at){st.splice(t,0,null);let l=null;Pl?0==t&&(l=Yl(e,t)):t>0&&(l=Yl(e,t)),Al.splice(t,0,l),Cl.splice(t,0,0),Wl.splice(t,0,0)}Hi("addSeries",t)}g.addSeries=function(e,t){t=null==t?me.length:t,e=1==_?Jl(e,t,qt,pl):Jl(e,t,{},hl),me.splice(t,0,e),Hl(me[t],t)},g.delSeries=function(e){if(me.splice(e,1),ut){ot.values.splice(e,1),wt.splice(e,1);let t=xt.splice(e,1)[0];St(null,t.firstChild),t.remove()}at&&(st.splice(e,1),Al.splice(e,1)[0].remove(),Cl.splice(e,1),Wl.splice(e,1)),Hi("delSeries",e)};const Rl=[!1,!1,!1,!1];function Fl(e,t,l){let[n,i,s,o]=l,r=t%2,u=0;return 0==r&&(o||i)&&(u=0==t&&!n||2==t&&!s?v(Jt.size/3):0),1==r&&(n||s)&&(u=1==t&&!i||3==t&&!o?v(al.size/2):0),u}const Gl=g.padding=(t.padding||[Fl,Fl,Fl,Fl]).map((e=>Y(p(e,Fl)))),Il=g._padding=Gl.map(((e,t)=>e(g,t,Rl,0)));let Ol,Ll=null,Ul=null;const Nl=1==_?me[0].idxs:null;let Vl,on,rn,un,an,fn,cn,hn,pn,dn,mn=null,gn=!1;function xn(e,t){if(g.data=g._data=f=null==e?[]:e,2==_){Ol=0;for(let e=1;me.length>e;e++)Ol+=f[e][0].length}else{0==f.length&&(g.data=g._data=f=[[]]),mn=f[0],Ol=mn.length;let e=f;if(2==Je){e=f.slice();let t=e[0]=Array(Ol);for(let e=0;Ol>e;e++)t[e]=e}g._data=f=e}if(Cn(!0),Hi("setData"),2==Je&&(cl=!0),!1!==t){let e=$e;e.auto(g,gn)?wn():si(Ge,e.min,e.max),xl=xl||rt.left>=0,_l=!0,Jn()}}function wn(){let e,t;gn=!0,1==_&&(Ol>0?(Ll=Nl[0]=0,Ul=Nl[1]=Ol-1,e=f[0][Ll],t=f[0][Ul],2==Je?(e=Ll,t=Ul):e==t&&(3==Je?[e,t]=o(e,e,$e.log,!1):4==Je?[e,t]=r(e,e,$e.log,!1):$e.time?t=e+v(86400/re):[e,t]=h(e,t,u,!0))):(Ll=Nl[0]=e=null,Ul=Nl[1]=t=null)),si(Ge,e,t)}function bn(e,t,l,n,i,s){e??=ge,l??=q,n??="butt",i??=ge,s??="round",e!=Vl&&(N.strokeStyle=Vl=e),i!=on&&(N.fillStyle=on=i),t!=rn&&(N.lineWidth=rn=t),s!=an&&(N.lineJoin=an=s),n!=fn&&(N.lineCap=fn=n),l!=un&&N.setLineDash(un=l)}function _n(e,t,l,n){t!=on&&(N.fillStyle=on=t),e!=cn&&(N.font=cn=e),l!=hn&&(N.textAlign=hn=l),n!=pn&&(N.textBaseline=pn=n)}function vn(e,t,o,r,u=0){if(r.length>0&&e.auto(g,gn)&&(null==t||null==t.min)){let t=p(Ll,0),a=p(Ul,r.length-1),f=null==o.min?function(e,t,o,r=0,u=!1){let a=u?s:i,f=u?n:l;[t,o]=a(e,t,o);let c=e[t],h=e[t];if(t>-1)if(1==r)c=e[t],h=e[o];else if(-1==r)c=e[o],h=e[t];else for(let l=t;o>=l;l++){let t=e[l];f(t)&&(c>t?c=t:t>h&&(h=t))}return[c??P,h??-P]}(r,t,a,u,3==e.distr):[o.min,o.max];e.min=y(e.min,o.min=f[0]),e.max=M(e.max,o.max=f[1])}}g.setData=xn;const kn={min:null,max:null};function yn(e,t){let l=t?me[e].points:me[e];l._stroke=l.stroke(g,e),l._fill=l.fill(g,e)}function Mn(e,t){let l=t?me[e].points:me[e],{stroke:n,fill:i,clip:s,flags:o,_stroke:r=l._stroke,_fill:u=l._fill,_width:a=l.width}=l._paths;a=V(a*d,3);let c=null,h=a%2/2;t&&null==u&&(u=a>0?"#fff":r);let m=1==l.pxAlign&&h>0;if(m&&N.translate(h,h),!t){let e=tl-a/2,t=ll-a/2,l=nl+a,n=il+a;c=new Path2D,c.rect(e,t,l,n)}t?Sn(r,a,l.dash,l.cap,u,n,i,o,s):function(e,t,l,n,i,s,o,r,u,a,c){let h=!1;0!=u&&Ce.forEach(((d,m)=>{if(d.series[0]==e){let e,x=me[d.series[1]],w=f[d.series[1]],b=(x._paths||J).band;X(b)&&(b=1==d.dir?b[0]:b[1]);let _=null;x.show&&b&&function(e,t,l){for(t=p(t,0),l=p(l,e.length-1);l>=t;){if(null!=e[t])return!0;t++}return!1}(w,Ll,Ul)?(_=d.fill(g,m)||s,e=x._paths.clip):b=null,Sn(t,l,n,i,_,o,r,u,a,c,e,b),h=!0}})),h||Sn(t,l,n,i,s,o,r,u,a,c)}(e,r,a,l.dash,l.cap,u,n,i,o,c,s),m&&N.translate(-h,-h)}const Tn=3;function Sn(e,t,l,n,i,s,o,r,u,a,f,c){bn(e,t,l,n,i),(u||a||c)&&(N.save(),u&&N.clip(u),a&&N.clip(a)),c?(r&Tn)==Tn?(N.clip(c),f&&N.clip(f),Dn(i,o),zn(e,s,t)):2&r?(Dn(i,o),N.clip(c),zn(e,s,t)):1&r&&(N.save(),N.clip(c),f&&N.clip(f),Dn(i,o),N.restore(),zn(e,s,t)):(Dn(i,o),zn(e,s,t)),(u||a||c)&&N.restore()}function zn(e,t,l){l>0&&(t instanceof Map?t.forEach(((e,t)=>{N.strokeStyle=Vl=t,N.stroke(e)})):null!=t&&e&&N.stroke(t))}function Dn(e,t){t instanceof Map?t.forEach(((e,t)=>{N.fillStyle=on=t,N.fill(e)})):null!=t&&e&&N.fill(t)}function En(e,t,l,n,i,s,o,r,u,a){let f=o%2/2;1==ne&&N.translate(f,f),bn(r,o,u,a,r),N.beginPath();let c,h,p,d,m=i+(0==n||3==n?-s:s);0==l?(h=i,d=m):(c=i,p=m);for(let n=0;e.length>n;n++)null!=t[n]&&(0==l?c=p=e[n]:h=d=e[n],N.moveTo(c,h),N.lineTo(p,d));N.stroke(),1==ne&&N.translate(-f,-f)}function Pn(e){let t=!0;return ye.forEach(((l,n)=>{if(!l.show)return;let i=De[l.scale];if(null==i.min)return void(l._show&&(t=!1,l._show=!1,Cn(!1)));l._show||(t=!1,l._show=!0,Cn(!1));let s=l.side,o=s%2,{min:r,max:u}=i,[a,f]=function(e,t,l,n){let i,s=ye[e];if(n>0){let o=s._space=s.space(g,e,t,l,n);i=nn(t,l,s._incrs=s.incrs(g,e,t,l,n,o),n,o)}else i=[0,0];return s._found=i}(n,r,u,0==o?Ot:Lt);if(0==f)return;let c=l._splits=l.splits(g,n,r,u,a,f,2==i.distr),h=2==i.distr?c.map((e=>mn[e])):c,p=2==i.distr?mn[c[1]]-mn[c[0]]:a,d=l._values=l.values(g,l.filter(g,h,n,f,p),n,f,p);l._rotate=2==s?l.rotate(g,d,n,f):0;let m=l._size;l._size=k(l.size(g,d,n,e)),null!=m&&l._size!=m&&(t=!1)})),t}function An(e){let t=!0;return Gl.forEach(((l,n)=>{let i=l(g,n,Rl,e);i!=Il[n]&&(t=!1),Il[n]=i})),t}function Cn(e){me.forEach(((t,l)=>{l>0&&(t._paths=null,e&&(1==_?(t.min=null,t.max=null):t.facets.forEach((e=>{e.min=null,e.max=null}))))}))}let Wn,Yn,Hn,Rn,Fn,Gn,In,On,Ln,Un,Nn,jn,Vn=!1,Bn=!1,Zn=[];function $n(){Bn=!1;for(let e=0;Zn.length>e;e++)Hi(...Zn[e]);Zn.length=0}function Jn(){Vn||(ue(qn),Vn=!0)}function qn(){if(sl&&(function(){for(let e in De){let t=De[e];null==Xe[e]&&(null==t.min||null!=Xe[Ge]&&t.auto(g,gn))&&(Xe[e]=kn)}for(let e in De){let t=De[e];null==Xe[e]&&null!=t.from&&null!=Xe[t.from]&&(Xe[e]=kn)}null!=Xe[Ge]&&Cn(!0);let t={};for(let e in Xe){let l=Xe[e];if(null!=l){let n=t[e]=se(De[e],le);if(null!=l.min)oe(n,l);else if(e!=Ge||2==_)if(0==Ol&&null==n.from){let t=n.range(g,null,null,e);n.min=t[0],n.max=t[1]}else n.min=P,n.max=-P}}if(Ol>0){me.forEach(((l,n)=>{if(1==_){let i=l.scale,s=Xe[i];if(null==s)return;let o=t[i];if(0==n){let t=o.range(g,o.min,o.max,i);o.min=t[0],o.max=t[1],Ll=e(o.min,f[0]),Ul=e(o.max,f[0]),Ul-Ll>1&&(o.min>f[0][Ll]&&Ll++,f[0][Ul]>o.max&&Ul--),l.min=mn[Ll],l.max=mn[Ul]}else l.show&&l.auto&&vn(o,s,l,f[n],l.sorted);l.idxs[0]=Ll,l.idxs[1]=Ul}else if(n>0&&l.show&&l.auto){let[e,i]=l.facets,s=e.scale,o=i.scale,[r,u]=f[n],a=t[s],c=t[o];null!=a&&vn(a,Xe[s],e,r,e.sorted),null!=c&&vn(c,Xe[o],i,u,i.sorted),l.min=i.min,l.max=i.max}}));for(let e in t){let l=t[e],n=Xe[e];if(null==l.from&&(null==n||null==n.min)){let t=l.range(g,l.min==P?null:l.min,l.max==-P?null:l.max,e);l.min=t[0],l.max=t[1]}}}for(let e in t){let l=t[e];if(null!=l.from){let n=t[l.from];if(null==n.min)l.min=l.max=null;else{let t=l.range(g,n.min,n.max,e);l.min=t[0],l.max=t[1]}}}let l={},n=!1;for(let e in t){let i=t[e],s=De[e];if(s.min!=i.min||s.max!=i.max){s.min=i.min,s.max=i.max;let t=s.distr;s._min=3==t?z(s.min):4==t?E(s.min,s.asinh):100==t?s.fwd(s.min):s.min,s._max=3==t?z(s.max):4==t?E(s.max,s.asinh):100==t?s.fwd(s.max):s.max,l[e]=n=!0}}if(n){me.forEach(((e,t)=>{2==_?t>0&&l.y&&(e._paths=null):l[e.scale]&&(e._paths=null)}));for(let e in l)cl=!0,Hi("setScale",e);at&&rt.left>=0&&(xl=_l=!0)}for(let e in Xe)Xe[e]=null}(),sl=!1),cl&&(function(){let e=!1,t=0;for(;!e;){t++;let l=Pn(t),n=An(t);e=t==Ml||l&&n,e||(yl(g.width,g.height),fl=!0)}}(),cl=!1),fl){if(He($,pe,Nt),He($,ce,jt),He($,ae,Ot),He($,fe,Lt),He(Q,pe,Nt),He(Q,ce,jt),He(Q,ae,Ot),He(Q,fe,Lt),He(j,ae,zt),He(j,fe,It),L.width=v(zt*d),L.height=v(It*d),ye.forEach((({_el:e,_show:t,_size:l,_pos:n,side:i})=>{if(null!=e)if(t){let t=i%2==1;He(e,t?"left":"top",n-(3===i||0===i?l:0)),He(e,t?"width":"height",l),He(e,t?"top":"left",t?jt:Nt),He(e,t?"height":"width",t?Lt:Ot),Ye(e,Se)}else We(e,Se)})),Vl=on=rn=an=fn=cn=hn=pn=un=null,dn=1,_i(!0),Nt!=Vt||jt!=Bt||Ot!=Zt||Lt!=$t){Cn(!1);let e=Ot/Zt,t=Lt/$t;if(at&&!xl&&rt.left>=0){rt.left*=e,rt.top*=t,Hn&&Ie(Hn,v(rt.left),0,Ot,Lt),Rn&&Ie(Rn,0,v(rt.top),Ot,Lt);for(let l=0;Al.length>l;l++){let n=Al[l];null!=n&&(Cl[l]*=e,Wl[l]*=t,Ie(n,k(Cl[l]),k(Wl[l]),Ot,Lt))}}if(li.show&&!bl&&li.left>=0&&li.width>0){li.left*=e,li.width*=e,li.top*=t,li.height*=t;for(let e in yi)He(ni,e,li[e])}Vt=Nt,Bt=jt,Zt=Ot,$t=Lt}Hi("setSize"),fl=!1}zt>0&&It>0&&(N.clearRect(0,0,L.width,L.height),Hi("drawClear"),Ue.forEach((e=>e())),Hi("draw")),li.show&&bl&&(ii(li),bl=!1),at&&xl&&(wi(null,!0,!1),xl=!1),ot.show&&ot.live&&_l&&(gi(),_l=!1),H||(H=!0,g.status=1,Hi("ready")),gn=!1,Vn=!1}function Kn(t,l){let n=De[t];if(null==n.from){if(0==Ol){let e=n.range(g,l.min,l.max,t);l.min=e[0],l.max=e[1]}if(l.min>l.max){let e=l.min;l.min=l.max,l.max=e}if(Ol>1&&null!=l.min&&null!=l.max&&1e-16>l.max-l.min)return;t==Ge&&2==n.distr&&Ol>0&&(l.min=e(l.min,f[0]),l.max=e(l.max,f[0]),l.min==l.max&&l.max++),Xe[t]=l,sl=!0,Jn()}}g.batch=function(e,t=!1){Vn=!0,Bn=t,e(g),qn(),t&&Zn.length>0&&queueMicrotask($n)},g.redraw=(e,t)=>{cl=t||!1,!1!==e?si(Ge,$e.min,$e.max):Jn()},g.setScale=Kn;let Xn=!1;const Qn=rt.drag;let ei=Qn.x,ti=Qn.y;at&&(rt.x&&(Wn=Fe("u-cursor-x",Q)),rt.y&&(Yn=Fe("u-cursor-y",Q)),0==$e.ori?(Hn=Wn,Rn=Yn):(Hn=Yn,Rn=Wn),Nn=rt.left,jn=rt.top);const li=g.select=oe({show:!0,over:!0,left:0,width:0,top:0,height:0},t.select),ni=li.show?Fe("u-select",li.over?Q:$):null;function ii(e,t){if(li.show){for(let t in e)li[t]=e[t],t in yi&&He(ni,t,e[t]);!1!==t&&Hi("setSelect")}}function si(e,t,l){Kn(e,{min:t,max:l})}function oi(e,t,l,n){null!=t.focus&&function(e){if(e!=ai){let t=null==e,l=1!=Dl.alpha;me.forEach(((n,i)=>{if(1==_||i>0){let s=t||0==i||i==e;n._focus=t?null:s,l&&function(e,t){me[e].alpha=t,at&&null!=Al[e]&&(Al[e].style.opacity=t),ut&&xt[e]&&(xt[e].style.opacity=t)}(i,s?1:Dl.alpha)}})),ai=e,l&&Jn()}}(e),null!=t.show&&me.forEach(((l,n)=>{0>=n||e!=n&&null!=e||(l.show=t.show,function(e){if(me[e].show)ut&&Ye(xt[e],Se);else if(ut&&We(xt[e],Se),at){let t=Pl?Al[0]:Al[e];null!=t&&Ie(t,-10,-10,Ot,Lt)}}(n),2==_?(si(l.facets[0].scale,null,null),si(l.facets[1].scale,null,null)):si(l.scale,null,null),Jn())})),!1!==l&&Hi("setSeries",e,t),n&&Oi("setSeries",g,e,t)}let ri,ui,ai;g.setSelect=ii,g.setSeries=oi,g.addBand=function(e,t){e.fill=Y(e.fill||null),e.dir=p(e.dir,-1),Ce.splice(t=null==t?Ce.length:t,0,e)},g.setBand=function(e,t){oe(Ce[e],t)},g.delBand=function(e){null==e?Ce.length=0:Ce.splice(e,1)};const fi={focus:!0};function ci(e,t,l){let n=De[t];l&&(e=e/d-(1==n.ori?jt:Nt));let i=Ot;1==n.ori&&(i=Lt,e=i-e),-1==n.dir&&(e=i-e);let s=n._min,o=s+e/i*(n._max-s),r=n.distr;return 3==r?T(10,o):4==r?((e,t=1)=>x.sinh(e)*t)(o,n.asinh):100==r?n.bwd(o):o}function hi(e,t){He(ni,pe,li.left=e),He(ni,ae,li.width=t)}function pi(e,t){He(ni,ce,li.top=e),He(ni,fe,li.height=t)}ut&&El&&Tt(ve,ct,(e=>{rt._lock||(Sl(e),null!=ai&&oi(null,fi,!0,Fi.setSeries))})),g.valToIdx=t=>e(t,f[0]),g.posToIdx=function(t,l){return e(ci(t,Ge,l),f[0],Ll,Ul)},g.posToVal=ci,g.valToPos=(e,t,l)=>0==De[t].ori?S(e,De[t],l?nl:Ot,l?tl:0):D(e,De[t],l?il:Lt,l?ll:0),g.setCursor=(e,t,l)=>{Nn=e.left,jn=e.top,wi(null,t,l)};let di=0==$e.ori?hi:pi,mi=1==$e.ori?hi:pi;function gi(e,t){if(null!=e&&(e.idxs?e.idxs.forEach(((e,t)=>{st[t]=e})):(e=>void 0===e)(e.idx)||st.fill(e.idx),ot.idx=st[0]),ut&&ot.live){for(let e=0;me.length>e;e++)(e>0||1==_&&!bt)&&xi(e,st[e]);!function(){if(ut&&ot.live)for(let e=2==_?1:0;me.length>e;e++){if(0==e&&bt)continue;let t=ot.values[e],l=0;for(let n in t)wt[e][l++].firstChild.nodeValue=t[n]}}()}_l=!1,!1!==t&&Hi("setLegend")}function xi(e,t){let l,n=me[e],i=0==e&&2==Je?mn:f[e];bt?l=n.values(g,e,t)??_t:(l=n.value(g,null==t?null:i[t],e,t),l=null==l?_t:{_:l}),ot.values[e]=l}function wi(t,l,n){let i;Ln=Nn,Un=jn,[Nn,jn]=rt.move(g,Nn,jn),rt.left=Nn,rt.top=jn,at&&(Hn&&Ie(Hn,v(Nn),0,Ot,Lt),Rn&&Ie(Rn,0,v(jn),Ot,Lt)),ri=P,ui=null;let s=0==$e.ori?Ot:Lt,o=1==$e.ori?Ot:Lt;if(0>Nn||0==Ol||Ll>Ul){i=rt.idx=null;for(let e=0;me.length>e;e++){let t=Al[e];null!=t&&Ie(t,-10,-10,Ot,Lt)}El&&oi(null,fi,!0,null==t&&Fi.setSeries),ot.live&&(st.fill(i),_l=!0)}else{let t,l,n;1==_&&(t=0==$e.ori?Nn:jn,l=ci(t,Ge),i=rt.idx=e(l,f[0],Ll,Ul),n=qe(f[0][i],$e,s,0));let r=-10,u=-10,a=0,c=0,h=!0,p="",d="";for(let e=2==_?1:0;me.length>e;e++){let t=me[e],m=st[e],x=null==m?null:1==_?f[e][m]:f[e][1][m],w=rt.dataIdx(g,e,i,l),v=null==w?null:1==_?f[e][w]:f[e][1][w];if(_l=_l||v!=x||w!=m,st[e]=w,e>0&&t.show){let l=null==w?-10:w==i?n:qe(1==_?f[0][w]:f[e][0][w],$e,s,0),m=null==v?-10:Ke(v,1==_?De[t.scale]:De[t.facets[1].scale],o,0);if(El&&null!=v){let l=1==$e.ori?Nn:jn,n=b(Dl.dist(g,e,w,m,l));if(ri>n){let i=Dl.bias;if(0!=i){let s=ci(l,t.scale),o=0>s?-1:1;o!=(0>v?-1:1)||(1==o?1==i?s>v:v>s:1==i?v>s:s>v)||(ri=n,ui=e)}else ri=n,ui=e}}if(_l||Pl){let t,n;0==$e.ori?(t=l,n=m):(t=m,n=l);let i,s,o,f,x,w,b=!0,_=zl.bbox;if(null!=_){b=!1;let t=_(g,e);o=t.left,f=t.top,i=t.width,s=t.height}else o=t,f=n,i=s=zl.size(g,e);if(w=zl.fill(g,e),x=zl.stroke(g,e),Pl)e!=ui||ri>Dl.prox||(r=o,u=f,a=i,c=s,h=b,p=w,d=x);else{let t=Al[e];null!=t&&(Cl[e]=o,Wl[e]=f,Ne(t,i,s,b),Le(t,w,x),Ie(t,k(o),k(f),Ot,Lt))}}}}if(Pl){let e=Dl.prox;if(_l||(null==ai?e>=ri:ri>e||ui!=ai)){let e=Al[0];null!=e&&(Cl[0]=r,Wl[0]=u,Ne(e,a,c,h),Le(e,p,d),Ie(e,k(r),k(u),Ot,Lt))}}}if(li.show&&Xn)if(null!=t){let[e,l]=Fi.scales,[n,i]=Fi.match,[r,u]=t.cursor.sync.scales,a=t.cursor.drag;if(ei=a._x,ti=a._y,ei||ti){let a,f,c,h,p,{left:d,top:m,width:g,height:x}=t.select,w=t.scales[r].ori,_=t.posToVal,v=null!=e&&n(e,r),k=null!=l&&i(l,u);v&&ei?(0==w?(a=d,f=g):(a=m,f=x),c=De[e],h=qe(_(a,r),c,s,0),p=qe(_(a+f,r),c,s,0),di(y(h,p),b(p-h))):di(0,s),k&&ti?(1==w?(a=d,f=g):(a=m,f=x),c=De[l],h=Ke(_(a,u),c,o,0),p=Ke(_(a+f,u),c,o,0),mi(y(h,p),b(p-h))):mi(0,o)}else Mi()}else{let e=b(Ln-Fn),t=b(Un-Gn);if(1==$e.ori){let l=e;e=t,t=l}ei=Qn.x&&e>=Qn.dist,ti=Qn.y&&t>=Qn.dist;let l,n,i=Qn.uni;null!=i?ei&&ti&&(ei=e>=i,ti=t>=i,ei||ti||(t>e?ti=!0:ei=!0)):Qn.x&&Qn.y&&(ei||ti)&&(ei=ti=!0),ei&&(0==$e.ori?(l=In,n=Nn):(l=On,n=jn),di(y(l,n),b(n-l)),ti||mi(0,o)),ti&&(1==$e.ori?(l=In,n=Nn):(l=On,n=jn),mi(y(l,n),b(n-l)),ei||di(0,s)),ei||ti||(di(0,0),mi(0,0))}if(Qn._x=ei,Qn._y=ti,null==t){if(n){if(null!=Gi){let[e,t]=Fi.scales;Fi.values[0]=null!=e?ci(0==$e.ori?Nn:jn,e):null,Fi.values[1]=null!=t?ci(1==$e.ori?Nn:jn,t):null}Oi(xe,g,Nn,jn,Ot,Lt,i)}if(El){let e=n&&Fi.setSeries,t=Dl.prox;null==ai?ri>t||oi(ui,fi,!0,e):ri>t?oi(null,fi,!0,e):ui!=ai&&oi(ui,fi,!0,e)}}_l&&(ot.idx=i,gi()),!1!==l&&Hi("setCursor")}g.setLegend=gi;let bi=null;function _i(e=!1){e?bi=null:(bi=Q.getBoundingClientRect(),Hi("syncRect",bi))}function vi(e,t,l,n,i,s){rt._lock||Xn&&null!=e&&0==e.movementX&&0==e.movementY||(ki(e,t,l,n,i,s,0,!1,null!=e),null!=e?wi(null,!0,!0):wi(t,!0,!1))}function ki(e,t,l,n,i,s,o,r,u){if(null==bi&&_i(!1),Sl(e),null!=e)l=e.clientX-bi.left,n=e.clientY-bi.top;else{if(0>l||0>n)return Nn=-10,void(jn=-10);let[e,o]=Fi.scales,r=t.cursor.sync,[u,a]=r.values,[f,c]=r.scales,[h,p]=Fi.match,d=t.axes[0].side%2==1,m=0==$e.ori?Ot:Lt,g=1==$e.ori?Ot:Lt,x=d?s:i,w=d?i:s,b=d?n:l,_=d?l:n;if(l=null!=f?h(e,f)?A(u,De[e],m,0):-10:m*(b/x),n=null!=c?p(o,c)?A(a,De[o],g,0):-10:g*(_/w),1==$e.ori){let e=l;l=n,n=e}}!u||null!=t&&t.cursor.event.type!=xe||(l>1&&Ot-1>l||(l=U(l,Ot)),n>1&&Lt-1>n||(n=U(n,Lt))),r?(Fn=l,Gn=n,[In,On]=rt.move(g,l,n)):(Nn=l,jn=n)}Object.defineProperty(g,"rect",{get:()=>(null==bi&&_i(!1),bi)});const yi={width:0,height:0,left:0,top:0};function Mi(){ii(yi,!1)}let Ti,Si,zi,Di;function Ei(e,t,l,n,i,s){Xn=!0,ei=ti=Qn._x=Qn._y=!1,ki(e,t,l,n,i,s,0,!0,!1),null!=e&&(Tt(be,Ee,Pi,!1),Oi(we,g,In,On,Ot,Lt,null));let{left:o,top:r,width:u,height:a}=li;Ti=o,Si=r,zi=u,Di=a}function Pi(e,t,l,n,i,s){Xn=Qn._x=Qn._y=!1,ki(e,t,l,n,i,s,0,!1,!0);let{left:o,top:r,width:u,height:a}=li,f=u>0||a>0,c=Ti!=o||Si!=r||zi!=u||Di!=a;if(f&&c&&ii(li),Qn.setScale&&f&&c){let e=o,t=u,l=r,n=a;if(1==$e.ori&&(e=r,t=a,l=o,n=u),ei&&si(Ge,ci(e,Ge),ci(e+t,Ge)),ti)for(let e in De){let t=De[e];e!=Ge&&null==t.from&&t.min!=P&&si(e,ci(l+n,e),ci(l,e))}Mi()}else rt.lock&&(rt._lock=!rt._lock,wi(t,!0,null!=e));null!=e&&(St(be,Ee),Oi(be,g,Nn,jn,Ot,Lt,null))}function Ai(e){rt._lock||(Sl(e),wn(),Mi(),null!=e&&Oi(ke,g,Nn,jn,Ot,Lt,null))}function Ci(){m()}Be(Me,Pe,Ci);const Wi={};Wi.mousedown=Ei,Wi.mousemove=vi,Wi.mouseup=Pi,Wi.dblclick=Ai,Wi.setSeries=(e,t,l,n)=>{-1!=(l=(0,Fi.match[2])(g,t,l))&&oi(l,n,!0,!1)},at&&(Tt(we,Q,Ei),Tt(xe,Q,vi),Tt(_e,Q,(e=>{Sl(e),_i(!1)})),Tt(ve,Q,(function(e){if(rt._lock)return;Sl(e);let t=Xn;if(Xn){let e,t,l=!0,n=!0,i=10;0==$e.ori?(e=ei,t=ti):(e=ti,t=ei),e&&t&&(l=i>=Nn||Nn>=Ot-i,n=i>=jn||jn>=Lt-i),e&&l&&(Nn=In>Nn?0:Ot),t&&n&&(jn=On>jn?0:Lt),wi(null,!0,!0),Xn=!1}Nn=-10,jn=-10,st.fill(null),wi(null,!0,!0),t&&(Xn=t)})),Tt(ke,Q,Ai),jl.add(g),g.syncRect=_i);const Yi=g.hooks=t.hooks||{};function Hi(e,t,l){Bn?Zn.push([e,t,l]):e in Yi&&Yi[e].forEach((e=>{e.call(null,g,t,l)}))}(t.plugins||[]).forEach((e=>{for(let t in e.hooks)Yi[t]=(Yi[t]||[]).concat(e.hooks[t])}));const Ri=(e,t,l)=>l,Fi=oe({key:null,setSeries:!1,filters:{pub:G,sub:G},scales:[Ge,me[1]?me[1].scale:null],match:[I,I,Ri],values:[null,null]},rt.sync);2==Fi.match.length&&Fi.match.push(Ri),rt.sync=Fi;const Gi=Fi.key,Ii=wl(Gi);function Oi(e,t,l,n,i,s,o){Fi.filters.pub(e,t,l,n,i,s,o)&&Ii.pub(e,t,l,n,i,s,o)}function Li(){Hi("init",t,f),xn(f||t.data,!1),Xe[Ge]?Kn(Ge,Xe[Ge]):wn(),bl=li.show&&(li.width>0||li.height>0),xl=_l=!0,kl(t.width,t.height)}return Ii.sub(g),g.pub=function(e,t,l,n,i,s,o){Fi.filters.sub(e,t,l,n,i,s,o)&&Wi[e](null,t,l,n,i,s,o)},g.destroy=function(){Ii.unsub(g),jl.delete(g),Mt.clear(),Ze(Me,Pe,Ci),O.remove(),ct?.remove(),Hi("destroy")},me.forEach(Hl),ye.forEach((function(e,t){if(e._show=e.show,e.show){let l=De[e.scale];null==l&&(e.scale=e.side%2?me[1].scale:Ge,l=De[e.scale]);let n=l.time;e.size=Y(e.size),e.space=Y(e.space),e.rotate=Y(e.rotate),X(e.incrs)&&e.incrs.forEach((e=>{!B.has(e)&&B.set(e,Z(e))})),e.incrs=Y(e.incrs||(2==l.distr?mt:n?1==re?Dt:At:gt)),e.splits=Y(e.splits||(n&&1==l.distr?tt:3==l.distr?Qt:4==l.distr?el:Xt)),e.stroke=Y(e.stroke),e.grid.stroke=Y(e.grid.stroke),e.ticks.stroke=Y(e.ticks.stroke),e.border.stroke=Y(e.border.stroke);let i=e.values;e.values=X(i)&&!X(i[0])?Y(i):n?X(i)?Ht(Qe,Yt(i,et)):ee(i)?function(e,t){let l=lt(t);return(t,n)=>n.map((t=>l(e(t))))}(Qe,i):i||nt:i||Kt,e.filter=Y(e.filter||(3>l.distr||10!=l.log?3==l.distr&&2==l.log?rl:R:ol)),e.font=sn(e.font,d),e.labelFont=sn(e.labelFont,d),e._size=e.size(g,null,t,0),e._space=e._rotate=e._incrs=e._found=e._splits=e._values=null,e._size>0&&(Rl[t]=!0,e._el=Fe("u-axis",j))}})),c?c instanceof HTMLElement?(c.appendChild(O),Li()):c(g,Li):Li(),g}on.assign=oe,on.fmtNum=g,on.rangeNum=h,on.rangeLog=o,on.rangeAsinh=r,on.orient=bl,on.pxRatio=Ae,on.join=function(e,t){if(function(e){let t=e[0][0],l=t.length;for(let n=1;e.length>n;n++){let i=e[n][0];if(i.length!=l)return!1;if(i!=t)for(let e=0;l>e;e++)if(i[e]!=t[e])return!1}return!0}(e)){let t=e[0].slice();for(let l=1;e.length>l;l++)t.push(...e[l].slice(1));return function(e,t=100){const l=e.length;if(1>=l)return!0;let n=0,i=l-1;for(;i>=n&&null==e[n];)n++;for(;i>=n&&null==e[i];)i--;if(n>=i)return!0;const s=M(1,_((i-n+1)/t));for(let t=e[n],l=n+s;i>=l;l+=s){const n=e[l];if(null!=n){if(t>=n)return!1;t=n}}return!0}(t[0])||(t=function(e){let t=e[0],l=t.length,n=Array(l);for(let e=0;n.length>e;e++)n[e]=e;n.sort(((e,l)=>t[e]-t[l]));let i=[];for(let t=0;e.length>t;t++){let s=e[t],o=Array(l);for(let e=0;l>e;e++)o[e]=s[n[e]];i.push(o)}return i}(t)),t}let l=new Set;for(let t=0;e.length>t;t++){let n=e[t][0],i=n.length;for(let e=0;i>e;e++)l.add(n[e])}let n=[Array.from(l).sort(((e,t)=>e-t))],i=n[0].length,s=new Map;for(let e=0;i>e;e++)s.set(n[0][e],e);for(let l=0;e.length>l;l++){let o=e[l],r=o[0];for(let e=1;o.length>e;e++){let u=o[e],a=Array(i).fill(void 0),f=t?t[l][e]:1,c=[];for(let e=0;u.length>e;e++){let t=u[e],l=s.get(r[e]);null===t?0!=f&&(a[l]=t,2==f&&c.push(l)):a[l]=t}re(a,c,i),n.push(a)}}return n},on.fmtDate=lt,on.tzDate=function(e,t){if(null==t||t==nt)return"number"==typeof e?new Date(e):e;let l=new rt(e);return l.setTimeZone(t),l},on.sync=wl;{on.addGap=function(e,t,l){let n=e[e.length-1];n&&n[0]==t?n[1]=l:e.push([t,l])},on.clipGaps=yl;let e=on.paths={points:Fl};e.linear=Ll,e.stepped=function(e){const t=p(e.align,1),l=p(e.ascDesc,!1),n=p(e.alignGaps,0),s=p(e.extend,!1);return(e,o,r,u)=>{let{pxRatio:a}=e;return bl(e,o,((f,c,h,p,d,m,g,x,w,b,_)=>{[r,u]=i(h,r,u);let v=f.pxRound,{left:k,width:y}=e.bbox,M=e=>v(m(e,p,b,x)),T=e=>v(g(e,d,_,w)),S=0==p.ori?El:Pl;const z={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:1},D=z.stroke,E=p.dir*(0==p.ori?1:-1);let P=T(h[1==E?r:u]),A=M(c[1==E?r:u]),C=A,W=A;s&&-1==t&&(W=k,S(D,W,P)),S(D,A,P);for(let e=1==E?r:u;e>=r&&u>=e;e+=E){let l=h[e];if(null==l)continue;let n=M(c[e]),i=T(l);1==t?S(D,n,P):S(D,C,i),S(D,n,i),P=i,C=n}let Y=C;s&&1==t&&(Y=k+y,S(D,Y,P));let[H,R]=_l(e,o);if(null!=f.fill||0!=H){let t=z.fill=new Path2D(D),l=T(f.fillTo(e,o,f.min,f.max,H));S(t,Y,l),S(t,W,l)}if(!f.spanGaps){let i=[];i.push(...Ml(c,h,r,u,E,M,n));let s=f.width*a/2,d=l||1==t?s:-s,m=l||-1==t?-s:s;i.forEach((e=>{e[0]+=d,e[1]+=m})),z.gaps=i=f.gaps(e,o,r,u,i),z.clip=yl(i,p.ori,x,w,b,_)}return 0!=R&&(z.band=2==R?[kl(e,o,r,u,D,-1),kl(e,o,r,u,D,1)]:kl(e,o,r,u,D,R)),z}))}},e.bars=function(e){const t=p((e=e||J).size,[.6,P,1]),l=e.align||0,n=e.gap||0;let i=e.radius;i=null==i?[0,0]:"number"==typeof i?[i,0]:i;const s=Y(i),o=1-t[0],r=p(t[1],P),u=p(t[2],1),a=p(e.disp,J),f=p(e.each,(()=>{})),{fill:c,stroke:h}=a;return(e,t,i,d)=>{let{pxRatio:m}=e;return bl(e,t,((g,x,w,b,v,k,T,S,z,D,E)=>{let P,A,W=g.pxRound,Y=l,R=n*m,F=r*m,G=u*m;0==b.ori?[P,A]=s(e,t):[A,P]=s(e,t);const I=b.dir*(0==b.ori?1:-1);let O,L,U,N=0==b.ori?Al:Cl,j=0==b.ori?f:(e,t,l,n,i,s,o)=>{f(e,t,l,i,n,o,s)},V=p(e.bands,q).find((e=>e.series[0]==t)),B=g.fillTo(e,t,g.min,g.max,null!=V?V.dir:0),Z=W(T(B,v,E,z)),$=D,J=W(g.width*m),K=!1,X=null,Q=null,ee=null,te=null;null==c||0!=J&&null==h||(K=!0,X=c.values(e,t,i,d),Q=new Map,new Set(X).forEach((e=>{null!=e&&Q.set(e,new Path2D)})),J>0&&(ee=h.values(e,t,i,d),te=new Map,new Set(ee).forEach((e=>{null!=e&&te.set(e,new Path2D)}))));let{x0:le,size:ne}=a;if(null!=le&&null!=ne){Y=1,x=le.values(e,t,i,d),2==le.unit&&(x=x.map((t=>e.posToVal(S+t*D,b.key,!0))));let l=ne.values(e,t,i,d);L=2==ne.unit?l[0]*D:k(l[0],b,D,S)-k(0,b,D,S),$=Ul(x,w,k,b,D,S,$),U=$-L+R}else $=Ul(x,w,k,b,D,S,$),U=$*o+R,L=$-U;1>U&&(U=0),L/2>J||(J=0),5>U&&(W=H);let ie=U>0;L=W(C($-U-(ie?J:0),G,F)),O=(0==Y?L/2:Y==I?0:L)-Y*I*((0==Y?R/2:0)+(ie?J/2:0));const se={stroke:null,fill:null,clip:null,band:null,gaps:null,flags:0},oe=K?null:new Path2D;let re=null;if(null!=V)re=e.data[V.series[1]];else{let{y0:l,y1:n}=a;null!=l&&null!=n&&(w=n.values(e,t,i,d),re=l.values(e,t,i,d))}let ue=P*L,ae=A*L;for(let l=1==I?i:d;l>=i&&d>=l;l+=I){let n=w[l];if(null==n)continue;if(null!=re){let e=re[l]??0;if(n-e==0)continue;Z=T(e,v,E,z)}let i=k(2!=b.distr||null!=a?x[l]:l,b,D,S),s=T(p(n,B),v,E,z),o=W(i-O),r=W(M(s,Z)),u=W(y(s,Z)),f=r-u;if(null!=n){let i=0>n?ae:ue,s=0>n?ue:ae;K?(J>0&&null!=ee[l]&&N(te.get(ee[l]),o,u+_(J/2),L,M(0,f-J),i,s),null!=X[l]&&N(Q.get(X[l]),o,u+_(J/2),L,M(0,f-J),i,s)):N(oe,o,u+_(J/2),L,M(0,f-J),i,s),j(e,t,l,o-J/2,u,L+J,f)}}return J>0?se.stroke=K?te:oe:K||(se._fill=0==g.width?g._fill:g._stroke??g._fill,se.width=0),se.fill=K?Q:oe,se}))}},e.spline=function(e){return function(e,t){const l=p(t?.alignGaps,0);return(t,n,s,o)=>bl(t,n,((r,u,a,f,c,h,p,d,m,g,x)=>{[s,o]=i(a,s,o);let w,b,_,v=r.pxRound,k=e=>v(h(e,f,g,d)),y=e=>v(p(e,c,x,m));0==f.ori?(w=zl,_=El,b=Hl):(w=Dl,_=Pl,b=Rl);const M=f.dir*(0==f.ori?1:-1);let T=k(u[1==M?s:o]),S=T,z=[],D=[];for(let e=1==M?s:o;e>=s&&o>=e;e+=M)if(null!=a[e]){let t=k(u[e]);z.push(S=t),D.push(y(a[e]))}const E={stroke:e(z,D,w,_,b,v),fill:null,clip:null,band:null,gaps:null,flags:1},P=E.stroke;let[A,C]=_l(t,n);if(null!=r.fill||0!=A){let e=E.fill=new Path2D(P),l=y(r.fillTo(t,n,r.min,r.max,A));_(e,S,l),_(e,T,l)}if(!r.spanGaps){let e=[];e.push(...Ml(u,a,s,o,M,k,l)),E.gaps=e=r.gaps(t,n,s,o,e),E.clip=yl(e,f.ori,d,m,g,x)}return 0!=C&&(E.band=2==C?[kl(t,n,s,o,P,-1),kl(t,n,s,o,P,1)]:kl(t,n,s,o,P,C)),E}))}(Nl,e)}}return on}(); diff --git a/package.json b/package.json index 9fec6a50..217f0fa9 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,6 @@ "homepage": "https://github.com/leeoniya/uPlot#readme", "devDependencies": { "@rollup/plugin-terser": "^0.4.4", - "rollup": "^4.35.0" + "rollup": "^4.46.2" } } diff --git a/src/fmtDate.js b/src/fmtDate.js index 2bc31af0..97a98d02 100644 --- a/src/fmtDate.js +++ b/src/fmtDate.js @@ -1,6 +1,7 @@ import { FEAT_TIME, } from './feats'; +import { abs, floor } from './utils'; const months = [ "January", @@ -105,8 +106,23 @@ const subs = { s: d => d.getSeconds(), // 374 fff: d => zeroPad3(d.getMilliseconds()), + + /* + // this really only makes sense for DateZoned + // -05:00 + tzo: d => { + let o = d.getTimezoneOffset(); + let s = o > 0 ? '-' : '+'; + o = abs(o); + let hh = zeroPad2(floor(o / 60)); + let mm = zeroPad2(o % 60); + return `${s}${hh}:${mm}`; + } + */ }; +// export const iso8601 = fmtDate('{YYYY}-{MM}-{DD}T{HH}:{mm}:{ss}.{fff}{tzo}'); + export function fmtDate(tpl, names) { names = names || engNames; let parts = []; @@ -128,19 +144,255 @@ export function fmtDate(tpl, names) { const localTz = new Intl.DateTimeFormat().resolvedOptions().timeZone; -// https://stackoverflow.com/questions/15141762/how-to-initialize-a-javascript-date-to-a-particular-time-zone/53652131#53652131 -export function tzDate(date, tz) { - let date2; - - // perf optimization - if (tz == 'UTC' || tz == 'Etc/UTC') - date2 = new Date(+date + date.getTimezoneOffset() * 6e4); - else if (tz == localTz) - date2 = date; - else { - date2 = new Date(date.toLocaleString('en-US', {timeZone: tz})); - date2.setMilliseconds(date.getMilliseconds()); +export function tzDate(dateOrTs, tz) { + if (tz == null || tz == localTz) + return typeof dateOrTs == 'number' ? new Date(dateOrTs) : dateOrTs; + + let d = new DateZoned(dateOrTs); + d.setTimeZone(tz); + return d; +} + +const twoDigit = '2-digit'; + +const fmtrOpts = { + weekday: "short", + year: 'numeric', + month: twoDigit, + day: twoDigit, + hour: twoDigit, + minute: twoDigit, + second: twoDigit, + fractionalSecondDigits: 3, + timeZoneName: 'longOffset', +}; + +/* +// this might be a bit easier to parse to avoid negative .slice() offsets +new Intl.DateTimeFormat('en-US', { + hour12: false, + timeZone: 'Europe/London', + year: 'numeric', + month: '2-digit', + day: '2-digit', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + timeZoneName: 'longOffset', + weekday: 'short', + fractionalSecondDigits: 3, +}).format(new Date()); + +// Tue, 07/22/2025, 07:02:37.043 GMT+01:00 +*/ + +const tzFmt = {}; + +function getFormatter(tz) { + if (tzFmt[tz] == null) + tzFmt[tz] = new Intl.DateTimeFormat("sv", {...fmtrOpts, timeZone: tz}).format; + + return tzFmt[tz]; +} + +export class DateZoned extends Date { + tz = null; + #utc = false; + // sön, 1972-10-15 17:25:23,434 GMT+01:00 + #str = null; + + constructor(...args) { + super(...args); + + if (args[0] instanceof DateZoned) { + this.tz = args[0].tz; + this.#str = args[0].#str; + this.#utc = args[0].#utc; + } + } + + #get(utcMeth, locMeth, fr, to, add = 0) { + let s = this.#str; + return this.#utc ? utcMeth.call(this) : s == null ? locMeth.call(this) : Number(s.slice(fr,to)) + add; + } + + setTimeZone(tz) { + this.tz = tz; + + if (tz == 'UTC' || tz == 'Etc/UTC') + this.#utc = true; + else { + let fmt = getFormatter(tz); + let f = fmt(this); + + if (f.endsWith('GMT')) + f += '+00:00'; + + this.#str = f; + } + } + + getFullYear() { + return this.#get(this.getUTCFullYear, super.getFullYear, -33, -29); + } + + getMonth() { + return this.#get(this.getUTCMonth, super.getMonth, -28, -26, -1); + } + + getDate() { + return this.#get(this.getUTCDate, super.getDate, -25, -23); + } + + getHours() { + return this.#get(this.getUTCHours, super.getHours, -22, -20); + } + + getMinutes() { + return this.#get(this.getUTCMinutes, super.getMinutes, -19, -17); + } + + getSeconds() { + return this.#get(this.getUTCSeconds, super.getSeconds, -16, -14); + } + + getMilliseconds() { + return this.#get(this.getUTCMilliseconds, super.getMilliseconds, -13, -10); + } + + getDay() { + let s = this.#str; + return this.#utc ? this.getUTCDay() : s == null ? super.getDay() : ( + s[0] == 's' ? 0 : // sön + s[0] == 'm' ? 1 : // mån + s[1] == 'i' ? 2 : // tis + s[0] == 'o' ? 3 : // ons + s[1] == 'o' ? 4 : // tors + s[0] == 'f' ? 5 : // fre + s[0] == 'l' ? 6 : // lör + -1 + ); + } + + getTimezoneOffset() { + let s = this.#str; + return this.#utc ? 0 : s == null ? super.getTimezoneOffset() : (60 * Number(s.slice(-5,-3)) + Number(s.slice(-2))) * (s.at(-6) == '-' ? -1 : 1); + } +} + +function getDayOfYear(date) { + let y = date.getFullYear(); + let m = date.getMonth() + 1; + let d = date.getDate(); + + // https://stackoverflow.com/a/27790471 + return --m*31-(m>1?(1054267675>>m*3-6&7)-(y&3||!(y%25)&&y&15?0:1):0)+d; +} + +function leapYear(year) { + return ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0); +} + +// these can be done through just incrRoundDn of 1e3 or 60 * 1e3 +// export const PERIOD_SECOND = 0; +// export const PERIOD_MINUTE = 1; + +// this might be needed for tzs where DST is not whole hours? +// otherwise incrRoundDn of 3600 * 1e3 +// export const PERIOD_HOUR = 2; + +// thse need special handling due to day length changing due to DST +export const PERIOD_DAY = 3; +export const PERIOD_MONTH = 4; +export const PERIOD_YEAR = 5; +// export const PERIOD_WEEK; + +// get start of period, requires DateZoned and period const +export function floorSOP(dz, per) { + let ts = dz.getTime(); + + // initial guess (assumes no DST) + let ts2 = ts - ( + dz.getMilliseconds() + + dz.getSeconds() * 1e3 + + dz.getMinutes() * 60 * 1e3 + + dz.getHours() * 3600 * 1e3 + + ( + ( + per == PERIOD_MONTH ? dz.getDate() - 1: + per == PERIOD_YEAR ? getDayOfYear(dz) - 1: + 0 + ) + * 24 * 3600 * 1e3 + ) + ); + + // if (ts2 == ts) + // return dz; + + let dz2 = new DateZoned(ts2); + dz2.setTimeZone(dz.tz); + + let h2 = dz2.getHours(); + + // we want hours to be 0 + if (h2 > 0) { + let dstAdj = h2 > 12 ? 24 - h2 : -h2; + dz2 = new DateZoned(ts2 + dstAdj * 3600 * 1e3); + dz2.setTimeZone(dz.tz); } - return date2; -} \ No newline at end of file + return dz2; +} + +// tweaks the time by +/- 1hr to make sure it lands on 12am +// used for correcting optimistically-computed ticks from adding fixed increments +// export function sopNear(dz, per) {} + +/* +let fmt = fmtDate('{YYYY}-{MM}-{DD}T{HH}:{mm}:{ss}.{fff}{tzo}'); + +{ + let d = new DateZoned(1554274800000); // post-roll date + d.setTimeZone('Europe/London'); + let sod = getSOP(d, PERIOD_DAY); + console.log(sod.getTime() / 1e3); + console.log(fmt(sod)); +} + +{ + let d = new DateZoned(1554274800000); // post-roll date + d.setTimeZone('America/Chicago'); + let sod = getSOP(d, PERIOD_DAY); + console.log(sod.getTime() / 1e3); + console.log(fmt(sod)); +} + +{ + let d = new DateZoned(1554004800000); // few hours after london spring forward + d.setTimeZone('Europe/London'); + let sod = getSOP(d, PERIOD_DAY); + console.log(sod.getTime() / 1e3); + console.log(fmt(sod)); +} + +{ + let d = new DateZoned(1572156000000); // few hours after london fall back + d.setTimeZone('Europe/London'); + let sod = getSOP(d, PERIOD_DAY); + console.log(sod.getTime() / 1e3); + console.log(fmt(sod)); +} +*/ + + +/* +TODO: + +2024 - leap year + start of year before feb vs after + start of month in dst fwd month / bwd month + start of day in dst fwd day / bwd day + +Australia/Darwin +*/ \ No newline at end of file diff --git a/src/opts.js b/src/opts.js index cf347693..71bbd685 100644 --- a/src/opts.js +++ b/src/opts.js @@ -39,7 +39,7 @@ import { setStylePx, } from './dom'; -import { fmtDate } from './fmtDate'; +import { DateZoned, fmtDate, floorSOP, PERIOD_DAY, PERIOD_MONTH, PERIOD_YEAR } from './fmtDate'; //export const series = []; @@ -160,78 +160,129 @@ function genTimeStuffs(ms) { let splits = []; let isYr = foundIncr >= y; let isMo = foundIncr >= mo && foundIncr < y; + let isDays = foundIncr >= d && foundIncr < mo; + let isHours = foundIncr > h && foundIncr < d // get the timezone-adjusted date let minDate = tzDate(scaleMin); let minDateTs = roundDec(minDate * ms, 3); // get ts of 12am (this lands us at or before the original scaleMin) - let minMin = mkDate(minDate.getFullYear(), isYr ? 0 : minDate.getMonth(), isMo || isYr ? 1 : minDate.getDate()); + let minMin = floorSOP(minDate, isYr || isMo ? PERIOD_YEAR : isDays ? PERIOD_MONTH : PERIOD_DAY); // should we do PERIOD_HOUR? let minMinTs = roundDec(minMin * ms, 3); - if (isMo || isYr) { - let moIncr = isMo ? foundIncr / mo : 0; - let yrIncr = isYr ? foundIncr / y : 0; - // let tzOffset = scaleMin - minDateTs; // needed? - let split = minDateTs == minMinTs ? minDateTs : roundDec(mkDate(minMin.getFullYear() + yrIncr, minMin.getMonth() + moIncr, 1) * ms, 3); - let splitDate = new Date(round(split / ms)); - let baseYear = splitDate.getFullYear(); - let baseMonth = splitDate.getMonth(); + if (isDays) { + let incrDays = foundIncr / d; - for (let i = 0; split <= scaleMax; i++) { - let next = mkDate(baseYear + yrIncr * i, baseMonth + moIncr * i, 1); - let offs = next - tzDate(roundDec(next * ms, 3)); + // incrs to add to month baseline + let skip = floor((minDate.getDate() - 1) / incrDays); + let split = minMinTs + (foundIncr * skip); - split = roundDec((+next + offs) * ms, 3); + do { + let date = tzDate(split); + // adjust for DST misses + let hour = date.getHours(); + if (hour != 0) { + split += hour > 12 ? h : -h; + date = tzDate(split); + } + + // rolled over into next month onto non-divisible incr, reset baseline + if ((date.getDate() - 1) % incrDays > 0) { + date = floorSOP(date, PERIOD_MONTH); + split = date.getTime() * ms; - if (split <= scaleMax) + // make sure we're not rendering a collision between 31 and 1 + if (split - splits[splits.length - 1] < foundIncr * 0.7) + splits.pop(); + } + + if (split > scaleMax) + break; + + if (split >= scaleMin) splits.push(split); - } - } - else { - let incr0 = foundIncr >= d ? d : foundIncr; - let tzOffset = floor(scaleMin) - floor(minDateTs); - let split = minMinTs + tzOffset + incrRoundUp(minDateTs - minMinTs, incr0); - splits.push(split); - let date0 = tzDate(split); + split += foundIncr; + } while (1); + } + else if (isMo || isYr) { + let subIncrs = 1; + let subIncrDays = 1; + let periodType = 0; + let periodMin = 0; + + if (isMo) { + subIncrs = foundIncr / mo; + subIncrDays = 32; + periodType = PERIOD_MONTH; + periodMin = minDate.getMonth(); + } + else if (isYr) { + subIncrs = foundIncr / y; + subIncrDays = 366; + periodType = PERIOD_YEAR; + periodMin = minDate.getYear(); + } - let prevHour = date0.getHours() + (date0.getMinutes() / m) + (date0.getSeconds() / h); - let incrHours = foundIncr / h; + foundIncr = subIncrs * subIncrDays * d; - let minSpace = self.axes[axisIdx]._space; - let pctSpace = foundSpace / minSpace; + let skip = floor(periodMin / subIncrDays); + let split = minMinTs + (foundIncr * skip); - while (1) { - split = roundDec(split + foundIncr, ms == 1 ? 0 : 3); + do { + let date = floorSOP(tzDate(split), periodType); + split = date.getTime() * ms; if (split > scaleMax) break; - if (incrHours > 1) { - let expectedHour = floor(roundDec(prevHour + incrHours, 6)) % 24; - let splitDate = tzDate(split); - let actualHour = splitDate.getHours(); + if (split >= scaleMin) + splits.push(split); + + split += foundIncr; + } while (1); + } + else if (isHours) { + let incrHours = foundIncr / h; - let dstShift = actualHour - expectedHour; + let skip = floor(minDate.getHours() / incrHours); + let split = minMinTs + (foundIncr * skip); - if (dstShift > 1) - dstShift = -1; + do { + let date = tzDate(split); - split -= dstShift * h; + // adjust for DST misses + let hour = date.getHours(); + if (hour % incrHours > 0) { + let hour2 = tzDate(split + h).getHours(); + split += hour2 % incrHours == 0 ? h : -h; + } - prevHour = (prevHour + incrHours) % 24; + if (split > scaleMax) + break; - // add a tick only if it's further than 70% of the min allowed label spacing - let prevSplit = splits[splits.length - 1]; - let pctIncr = roundDec((split - prevSplit) / foundIncr, 3); + if (split >= scaleMin) + splits.push(split); - if (pctIncr * pctSpace >= .7) - splits.push(split); - } - else + split += foundIncr; + // expect = (expect + incrHours) % 24; + } while (1); + } + else { + let split = minMinTs + incrRoundUp(minDateTs - minMinTs, foundIncr); + + do { + if (split > scaleMax) + break; + + if (split >= scaleMin) splits.push(split); - } + + split += foundIncr; + } while (1); + + splits.push(split); } return splits;