@losting/timeline
Advanced tools
Comparing version 3.0.1 to 3.0.2
@@ -7,3 +7,3 @@ var Ft = Object.defineProperty; | ||
}; | ||
var f = (a, t, s) => (gt(a, t, "read from private field"), s ? s.call(a) : t.get(a)), T = (a, t, s) => { | ||
var f = (a, t, s) => (gt(a, t, "read from private field"), s ? s.call(a) : t.get(a)), F = (a, t, s) => { | ||
if (t.has(a)) | ||
@@ -39,3 +39,3 @@ throw TypeError("Cannot add the same private member more than once"); | ||
})(Ot, function() { | ||
var s = 1e3, r = 6e4, l = 36e5, g = "millisecond", $ = "second", p = "minute", v = "hour", x = "day", b = "week", D = "month", F = "quarter", _ = "year", W = "date", Q = "Invalid Date", ft = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, K = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, lt = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(o) { | ||
var s = 1e3, r = 6e4, l = 36e5, g = "millisecond", $ = "second", p = "minute", v = "hour", x = "day", b = "week", Y = "month", S = "quarter", _ = "year", W = "date", Q = "Invalid Date", ft = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, K = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, lt = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(o) { | ||
var n = ["th", "st", "nd", "rd"], e = o % 100; | ||
@@ -52,3 +52,3 @@ return "[" + o + (n[(e - 20) % 10] || n[e] || n[0]) + "]"; | ||
return -o(e, n); | ||
var h = 12 * (e.year() - n.year()) + (e.month() - n.month()), i = n.clone().add(h, D), u = e - i < 0, c = n.clone().add(h + (u ? -1 : 1), D); | ||
var h = 12 * (e.year() - n.year()) + (e.month() - n.month()), i = n.clone().add(h, Y), u = e - i < 0, c = n.clone().add(h + (u ? -1 : 1), Y); | ||
return +(-(h + (e - i) / (u ? i - c : c - i)) || 0); | ||
@@ -58,3 +58,3 @@ }, a: function(o) { | ||
}, p: function(o) { | ||
return { M: D, y: _, w: b, d: x, D: W, h: v, m: p, s: $, ms: g, Q: F }[o] || String(o || "").toLowerCase().replace(/s$/, ""); | ||
return { M: Y, y: _, w: b, d: x, D: W, h: v, m: p, s: $, ms: g, Q: S }[o] || String(o || "").toLowerCase().replace(/s$/, ""); | ||
}, u: function(o) { | ||
@@ -139,11 +139,11 @@ return o === void 0; | ||
return d.w(i.toDate()[U].apply(i.toDate("s"), (u ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(C)), i); | ||
}, M = this.$W, S = this.$M, z = this.$D, E = "set" + (this.$u ? "UTC" : ""); | ||
}, M = this.$W, T = this.$M, z = this.$D, E = "set" + (this.$u ? "UTC" : ""); | ||
switch (c) { | ||
case _: | ||
return u ? m(1, 0) : m(31, 11); | ||
case D: | ||
return u ? m(1, S) : m(0, S + 1); | ||
case Y: | ||
return u ? m(1, T) : m(0, T + 1); | ||
case b: | ||
var R = this.$locale().weekStart || 0, q = (M < R ? M + 7 : M) - R; | ||
return m(u ? z - q : z + (6 - q), S); | ||
return m(u ? z - q : z + (6 - q), T); | ||
case x: | ||
@@ -164,4 +164,4 @@ case W: | ||
}, n.$set = function(e, h) { | ||
var i, u = d.p(e), c = "set" + (this.$u ? "UTC" : ""), m = (i = {}, i[x] = c + "Date", i[W] = c + "Date", i[D] = c + "Month", i[_] = c + "FullYear", i[v] = c + "Hours", i[p] = c + "Minutes", i[$] = c + "Seconds", i[g] = c + "Milliseconds", i)[u], w = u === x ? this.$D + (h - this.$W) : h; | ||
if (u === D || u === _) { | ||
var i, u = d.p(e), c = "set" + (this.$u ? "UTC" : ""), m = (i = {}, i[x] = c + "Date", i[W] = c + "Date", i[Y] = c + "Month", i[_] = c + "FullYear", i[v] = c + "Hours", i[p] = c + "Minutes", i[$] = c + "Seconds", i[g] = c + "Milliseconds", i)[u], w = u === x ? this.$D + (h - this.$W) : h; | ||
if (u === Y || u === _) { | ||
var M = this.clone().set(W, 1); | ||
@@ -179,8 +179,8 @@ M.$d[m](w), M.init(), this.$d = M.set(W, Math.min(this.$D, M.daysInMonth())).$d; | ||
e = Number(e); | ||
var c = d.p(h), m = function(S) { | ||
var c = d.p(h), m = function(T) { | ||
var z = y(u); | ||
return d.w(z.date(z.date() + Math.round(S * e)), u); | ||
return d.w(z.date(z.date() + Math.round(T * e)), u); | ||
}; | ||
if (c === D) | ||
return this.set(D, this.$M + e); | ||
if (c === Y) | ||
return this.set(Y, this.$M + e); | ||
if (c === _) | ||
@@ -200,3 +200,3 @@ return this.set(_, this.$y + e); | ||
return i.invalidDate || Q; | ||
var u = e || "YYYY-MM-DDTHH:mm:ssZ", c = d.z(this), m = this.$H, w = this.$m, M = this.$M, S = i.weekdays, z = i.months, E = function(C, I, mt, it) { | ||
var u = e || "YYYY-MM-DDTHH:mm:ssZ", c = d.z(this), m = this.$H, w = this.$m, M = this.$M, T = i.weekdays, z = i.months, E = function(C, I, mt, it) { | ||
return C && (C[I] || C(h, u)) || mt[I].slice(0, it); | ||
@@ -208,3 +208,3 @@ }, R = function(C) { | ||
return mt ? it.toLowerCase() : it; | ||
}, U = { YY: String(this.$y).slice(-2), YYYY: d.s(this.$y, 4, "0"), M: M + 1, MM: d.s(M + 1, 2, "0"), MMM: E(i.monthsShort, M, z, 3), MMMM: E(z, M), D: this.$D, DD: d.s(this.$D, 2, "0"), d: String(this.$W), dd: E(i.weekdaysMin, this.$W, S, 2), ddd: E(i.weekdaysShort, this.$W, S, 3), dddd: S[this.$W], H: String(m), HH: d.s(m, 2, "0"), h: R(1), hh: R(2), a: q(m, w, !0), A: q(m, w, !1), m: String(w), mm: d.s(w, 2, "0"), s: String(this.$s), ss: d.s(this.$s, 2, "0"), SSS: d.s(this.$ms, 3, "0"), Z: c }; | ||
}, U = { YY: String(this.$y).slice(-2), YYYY: d.s(this.$y, 4, "0"), M: M + 1, MM: d.s(M + 1, 2, "0"), MMM: E(i.monthsShort, M, z, 3), MMMM: E(z, M), D: this.$D, DD: d.s(this.$D, 2, "0"), d: String(this.$W), dd: E(i.weekdaysMin, this.$W, T, 2), ddd: E(i.weekdaysShort, this.$W, T, 3), dddd: T[this.$W], H: String(m), HH: d.s(m, 2, "0"), h: R(1), hh: R(2), a: q(m, w, !0), A: q(m, w, !1), m: String(w), mm: d.s(w, 2, "0"), s: String(this.$s), ss: d.s(this.$s, 2, "0"), SSS: d.s(this.$ms, 3, "0"), Z: c }; | ||
return u.replace(K, function(C, I) { | ||
@@ -216,6 +216,6 @@ return I || U[C] || c.replace(":", ""); | ||
}, n.diff = function(e, h, i) { | ||
var u, c = d.p(h), m = y(e), w = (m.utcOffset() - this.utcOffset()) * r, M = this - m, S = d.m(this, m); | ||
return S = (u = {}, u[_] = S / 12, u[D] = S, u[F] = S / 3, u[b] = (M - w) / 6048e5, u[x] = (M - w) / 864e5, u[v] = M / l, u[p] = M / r, u[$] = M / s, u)[c] || M, i ? S : d.a(S); | ||
var u, c = d.p(h), m = y(e), w = (m.utcOffset() - this.utcOffset()) * r, M = this - m, T = d.m(this, m); | ||
return T = (u = {}, u[_] = T / 12, u[Y] = T, u[S] = T / 3, u[b] = (M - w) / 6048e5, u[x] = (M - w) / 864e5, u[v] = M / l, u[p] = M / r, u[$] = M / s, u)[c] || M, i ? T : d.a(T); | ||
}, n.daysInMonth = function() { | ||
return this.endOf(D).$D; | ||
return this.endOf(Y).$D; | ||
}, n.$locale = function() { | ||
@@ -240,3 +240,3 @@ return j[this.$L]; | ||
}(), pt = et.prototype; | ||
return y.prototype = pt, [["$ms", g], ["$s", $], ["$m", p], ["$H", v], ["$W", x], ["$M", D], ["$y", _], ["$D", W]].forEach(function(o) { | ||
return y.prototype = pt, [["$ms", g], ["$s", $], ["$m", p], ["$H", v], ["$W", x], ["$M", Y], ["$y", _], ["$D", W]].forEach(function(o) { | ||
pt[o[1]] = function(n) { | ||
@@ -268,4 +268,4 @@ return this.$g(n, o[0], o[1]); | ||
return `rgba(${l[0]}, ${l[1]}, ${l[2]}, ${t})`; | ||
}, Wt = ({ xCenterPoint: a, cfg: t, timePerPixel: s, timeSpacing: r, currentTime: l, $canvas: g, screenScaleCount: $, scaleHeight: p, startTime: v, drawLine: x, drawText: b, drawArea: D }) => { | ||
const F = ({ space: _, scaleFormat: W, bgFormat: Q, currentFormat: ft }) => { | ||
}, Wt = ({ xCenterPoint: a, cfg: t, timePerPixel: s, timeSpacing: r, currentTime: l, $canvas: g, screenScaleCount: $, scaleHeight: p, startTime: v, drawLine: x, drawText: b, drawArea: Y }) => { | ||
const S = ({ space: _, scaleFormat: W, bgFormat: Q, currentFormat: ft }) => { | ||
b({ | ||
@@ -299,3 +299,3 @@ x: g.width - a / 10, | ||
color: t.pointColor | ||
}), D({ | ||
}), Y({ | ||
startX: a - 50, | ||
@@ -314,3 +314,3 @@ startY: 4, | ||
}; | ||
r < 100 ? F({ space: 10, scaleFormat: "mm:ss:SSS", bgFormat: "YYYY/MM/DD", currentFormat: "HH:mm:ss:SSS" }) : r < 1e3 ? F({ space: 10, scaleFormat: "mm:ss", bgFormat: "YYYY/MM/DD", currentFormat: "HH:mm:ss:SSS" }) : r < 1e4 ? F({ space: 10, scaleFormat: "mm:ss", bgFormat: "YYYY/MM/DD", currentFormat: "HH:mm:ss" }) : r < 6e4 ? F({ space: 12, scaleFormat: "HH:mm:ss", bgFormat: "YYYY/MM/DD", currentFormat: "HH:mm:ss" }) : r < 6e5 ? F({ space: 10, scaleFormat: "HH:mm:ss", bgFormat: "YYYY/MM/DD", currentFormat: "HH:mm:ss" }) : r < 36e5 ? F({ space: 12, scaleFormat: "MM/DD HH:mm", bgFormat: "YYYY/MM", currentFormat: "MM/DD HH:mm:ss" }) : r < 864e5 ? F({ space: 12, scaleFormat: "MM/DD HH:mm", bgFormat: "YYYY/MM", currentFormat: "YYYY/MM/DD HH:mm" }) : r < 6048e5 ? F({ space: 10, scaleFormat: "YYYY/MM/DD", bgFormat: "YYYY", currentFormat: "YYYY/MM/DD" }) : F({ space: 10, scaleFormat: "YYYY/MM/DD", bgFormat: "YYYY", currentFormat: "YYYY/MM/DD" }); | ||
r < 100 ? S({ space: 10, scaleFormat: "mm:ss:SSS", bgFormat: "YYYY/MM/DD", currentFormat: "HH:mm:ss:SSS" }) : r < 1e3 ? S({ space: 10, scaleFormat: "mm:ss", bgFormat: "YYYY/MM/DD", currentFormat: "HH:mm:ss:SSS" }) : r < 1e4 ? S({ space: 10, scaleFormat: "mm:ss", bgFormat: "YYYY/MM/DD", currentFormat: "HH:mm:ss" }) : r < 6e4 ? S({ space: 12, scaleFormat: "HH:mm:ss", bgFormat: "YYYY/MM/DD", currentFormat: "HH:mm:ss" }) : r < 6e5 ? S({ space: 10, scaleFormat: "HH:mm:ss", bgFormat: "YYYY/MM/DD", currentFormat: "HH:mm:ss" }) : r < 36e5 ? S({ space: 12, scaleFormat: "MM/DD HH:mm", bgFormat: "YYYY/MM", currentFormat: "MM/DD HH:mm:ss" }) : r < 864e5 ? S({ space: 12, scaleFormat: "MM/DD HH:mm", bgFormat: "YYYY/MM", currentFormat: "YYYY/MM/DD HH:mm" }) : r < 6048e5 ? S({ space: 10, scaleFormat: "YYYY/MM/DD", bgFormat: "YYYY", currentFormat: "YYYY/MM/DD" }) : S({ space: 10, scaleFormat: "YYYY/MM/DD", bgFormat: "YYYY", currentFormat: "YYYY/MM/DD" }); | ||
}, Pt = { | ||
@@ -331,22 +331,22 @@ fill: !0, | ||
}; | ||
var Z, O, A, Y, X, N, nt, Dt, rt, wt, at, xt, ot, yt, ht, bt, ct, St, G, vt, B, st, ut, Tt; | ||
var Z, O, A, D, X, N, nt, Dt, rt, wt, at, xt, ot, yt, ht, bt, ct, St, G, vt, B, st, ut, Tt; | ||
class zt { | ||
constructor(t, s) { | ||
// 拖拽 | ||
T(this, nt); | ||
F(this, nt); | ||
// 缩放 | ||
T(this, rt); | ||
F(this, rt); | ||
// 父元素size变化 | ||
T(this, at); | ||
F(this, at); | ||
// 清空画布 | ||
T(this, ot); | ||
F(this, ot); | ||
// 绘制比例尺 | ||
T(this, ht); | ||
F(this, ht); | ||
// 绘制线条 | ||
T(this, ct); | ||
F(this, ct); | ||
// 绘制文字 | ||
T(this, G); | ||
F(this, G); | ||
// 绘制区域 | ||
T(this, B); | ||
T(this, ut); | ||
F(this, B); | ||
F(this, ut); | ||
V(this, "$canvas"); | ||
@@ -356,10 +356,10 @@ V(this, "ctx"); | ||
V(this, "cfg"); | ||
T(this, Z, Ht()); | ||
T(this, O, 0); | ||
T(this, A, void 0); | ||
T(this, Y, void 0); | ||
F(this, Z, Ht()); | ||
F(this, O, 0); | ||
F(this, A, void 0); | ||
F(this, D, void 0); | ||
// 刻度高度 | ||
T(this, X, void 0); | ||
F(this, X, void 0); | ||
// 是否在拖拽中 | ||
T(this, N, !1); | ||
F(this, N, !1); | ||
if (!t) | ||
@@ -372,7 +372,7 @@ throw new Error("canvas Element Or Element ID is required!"); | ||
if (r) { | ||
const D = this.$canvas.parentElement; | ||
this.$canvasParent = D, this.$canvas.width = D.clientWidth, this.$canvas.height = D.clientHeight, new ResizeObserver(Mt(H(this, at, xt).bind(this), 200)).observe(D); | ||
const Y = this.$canvas.parentElement; | ||
this.$canvasParent = Y, this.$canvas.width = Y.clientWidth, this.$canvas.height = Y.clientHeight, new ResizeObserver(Mt(H(this, at, xt).bind(this), 200)).observe(Y); | ||
} else | ||
l && (this.$canvas.width = l), g && (this.$canvas.height = g); | ||
L(this, Y, p[$]), v != null && v.long && (v != null && v.short) ? L(this, X, v) : L(this, X, { | ||
L(this, D, p[$]), v != null && v.long && (v != null && v.short) ? L(this, X, v) : L(this, X, { | ||
long: this.$canvas.height / 3, | ||
@@ -391,3 +391,3 @@ // 1/3高度 | ||
L(this, O, t || Date.now()), L(this, A, s || []); | ||
const l = Math.ceil(this.$canvas.width / this.cfg.scaleSpacing), g = l * f(this, Y), $ = f(this, O) - g / 2, p = f(this, O) + g / 2, v = this.$canvas.width / 2, x = g / this.$canvas.width; | ||
const l = Math.ceil(this.$canvas.width / this.cfg.scaleSpacing), g = l * f(this, D), $ = f(this, O) - g / 2, p = f(this, O) + g / 2, v = this.$canvas.width / 2, x = g / this.$canvas.width; | ||
H(this, ot, yt).call(this), H(this, B, st).call(this, { | ||
@@ -400,7 +400,7 @@ startX: 0, | ||
}), f(this, A).forEach((b) => { | ||
const D = b.startTime < $ ? 0 : Math.floor((b.startTime - $) / x), F = b.endTime > p ? this.$canvas.width : Math.floor((b.endTime - $) / x); | ||
H(this, B, st).call(this, { | ||
startX: D, | ||
const Y = b.startTime <= $ ? 0 : Math.round((b.startTime - $) / x), S = b.endTime >= p ? this.$canvas.width : Math.round((b.endTime - $) / x); | ||
Y < this.$canvas.width && S > 0 && H(this, B, st).call(this, { | ||
startX: Y, | ||
startY: 0, | ||
endX: F, | ||
endX: S, | ||
endY: this.$canvas.height, | ||
@@ -415,3 +415,3 @@ bgColor: b.bgColor || this.cfg.areaBgColor | ||
scaleHeight: f(this, X), | ||
timeSpacing: f(this, Y), | ||
timeSpacing: f(this, D), | ||
currentTime: f(this, O), | ||
@@ -436,3 +436,3 @@ $canvas: this.$canvas, | ||
} | ||
Z = new WeakMap(), O = new WeakMap(), A = new WeakMap(), Y = new WeakMap(), X = new WeakMap(), N = new WeakMap(), nt = new WeakSet(), Dt = function(t) { | ||
Z = new WeakMap(), O = new WeakMap(), A = new WeakMap(), D = new WeakMap(), X = new WeakMap(), N = new WeakMap(), nt = new WeakSet(), Dt = function(t) { | ||
L(this, N, !0); | ||
@@ -444,3 +444,3 @@ let s = 0, r = f(this, O); | ||
const v = p - t.offsetX; | ||
r = Math.round(f(this, O) - f(this, Y) / this.cfg.scaleSpacing * (v - s)), s = v, this.draw({ | ||
r = Math.round(f(this, O) - f(this, D) / this.cfg.scaleSpacing * (v - s)), s = v, this.draw({ | ||
currentTime: r, | ||
@@ -458,8 +458,8 @@ areas: f(this, A), | ||
t.preventDefault(); | ||
const s = this.cfg.timeSpacingList.findIndex((r) => r === f(this, Y)); | ||
t.deltaY < 0 && s > 0 ? (L(this, Y, this.cfg.timeSpacingList[s - 1]), this.draw({ | ||
const s = this.cfg.timeSpacingList.findIndex((r) => r === f(this, D)); | ||
t.deltaY < 0 && s > 0 ? (L(this, D, this.cfg.timeSpacingList[s - 1]), this.draw({ | ||
currentTime: f(this, O), | ||
areas: f(this, A), | ||
_privateFlag: !0 | ||
})) : t.deltaY > 0 && s < this.cfg.timeSpacingList.length - 1 && (L(this, Y, this.cfg.timeSpacingList[s + 1]), this.draw({ | ||
})) : t.deltaY > 0 && s < this.cfg.timeSpacingList.length - 1 && (L(this, D, this.cfg.timeSpacingList[s + 1]), this.draw({ | ||
currentTime: f(this, O), | ||
@@ -484,3 +484,3 @@ areas: f(this, A), | ||
}, ht = new WeakSet(), bt = function() { | ||
const t = () => f(this, Y) < 1e3 ? `${f(this, Y)}ms` : f(this, Y) < 6e4 ? `${Math.round(f(this, Y) / 100) / 10}sec` : f(this, Y) < 36e5 ? `${Math.round(f(this, Y) / 100 / 60) / 10}min` : f(this, Y) < 864e5 ? `${Math.round(f(this, Y) / 100 / 60 / 60) / 10}hours` : f(this, Y) < 6048e5 ? `${Math.round(f(this, Y) / 100 / 60 / 60 / 24) / 10}days` : `${Math.round(f(this, Y) / 100 / 60 / 60 / 24 / 7) / 10}weeks`; | ||
const t = () => f(this, D) < 1e3 ? `${f(this, D)}ms` : f(this, D) < 6e4 ? `${Math.round(f(this, D) / 100) / 10}sec` : f(this, D) < 36e5 ? `${Math.round(f(this, D) / 100 / 60) / 10}min` : f(this, D) < 864e5 ? `${Math.round(f(this, D) / 100 / 60 / 60) / 10}hours` : f(this, D) < 6048e5 ? `${Math.round(f(this, D) / 100 / 60 / 60 / 24) / 10}days` : `${Math.round(f(this, D) / 100 / 60 / 60 / 24 / 7) / 10}weeks`; | ||
H(this, G, vt).call(this, { | ||
@@ -487,0 +487,0 @@ x: this.cfg.scaleSpacing + 12, |
@@ -1,1 +0,1 @@ | ||
var $timeline=function(){var J,_,P,w,U,Z,it,xt,st,bt,nt,St,rt,Tt,at,Ft,ot,Ct,G,Dt,R,mt,ht,Ht;"use strict";var Pt=Object.defineProperty;var kt=(M,p,y)=>p in M?Pt(M,p,{enumerable:!0,configurable:!0,writable:!0,value:y}):M[p]=y;var et=(M,p,y)=>(kt(M,typeof p!="symbol"?p+"":p,y),y),Yt=(M,p,y)=>{if(!p.has(M))throw TypeError("Cannot "+y)};var u=(M,p,y)=>(Yt(M,p,"read from private field"),y?y.call(M):p.get(M)),H=(M,p,y)=>{if(p.has(M))throw TypeError("Cannot add the same private member more than once");p instanceof WeakSet?p.add(M):p.set(M,y)},A=(M,p,y,V)=>(Yt(M,p,"write to private field"),V?V.call(M,y):p.set(M,y),y);var E=(M,p,y)=>(Yt(M,p,"access private method"),y);function M(l){return{all:l=l||new Map,on:function(n,r){var s=l.get(n);s?s.push(r):l.set(n,[r])},off:function(n,r){var s=l.get(n);s&&(r?s.splice(s.indexOf(r)>>>0,1):l.set(n,[]))},emit:function(n,r){var s=l.get(n);s&&s.slice().map(function(f){f(r)}),(s=l.get("*"))&&s.slice().map(function(f){f(n,r)})}}}var p=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function y(l){return l&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l}var V={exports:{}};(function(l,n){(function(r,s){l.exports=s()})(p,function(){var r=1e3,s=6e4,f=36e5,g="millisecond",$="second",Y="minute",v="hour",S="day",F="week",x="month",O="quarter",W="year",z="date",ct="Invalid Date",$t=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,ut=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,vt={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(a){var i=["th","st","nd","rd"],t=a%100;return"["+a+(i[(t-20)%10]||i[t]||i[0])+"]"}},I=function(a,i,t){var o=String(a);return!o||o.length>=i?a:""+Array(i+1-o.length).join(t)+a},Q={s:I,z:function(a){var i=-a.utcOffset(),t=Math.abs(i),o=Math.floor(t/60),e=t%60;return(i<=0?"+":"-")+I(o,2,"0")+":"+I(e,2,"0")},m:function a(i,t){if(i.date()<t.date())return-a(t,i);var o=12*(t.year()-i.year())+(t.month()-i.month()),e=i.clone().add(o,x),c=t-e<0,h=i.clone().add(o+(c?-1:1),x);return+(-(o+(t-e)/(c?e-h:h-e))||0)},a:function(a){return a<0?Math.ceil(a)||0:Math.floor(a)},p:function(a){return{M:x,y:W,w:F,d:S,D:z,h:v,m:Y,s:$,ms:g,Q:O}[a]||String(a||"").toLowerCase().replace(/s$/,"")},u:function(a){return a===void 0}},j="en",B={};B[j]=vt;var pt=function(a){return a instanceof lt},ft=function a(i,t,o){var e;if(!i)return j;if(typeof i=="string"){var c=i.toLowerCase();B[c]&&(e=c),t&&(B[c]=t,e=c);var h=i.split("-");if(!e&&h.length>1)return a(h[0])}else{var m=i.name;B[m]=i,e=m}return!o&&e&&(j=e),e||!o&&j},T=function(a,i){if(pt(a))return a.clone();var t=typeof i=="object"?i:{};return t.date=a,t.args=arguments,new lt(t)},d=Q;d.l=ft,d.i=pt,d.w=function(a,i){return T(a,{locale:i.$L,utc:i.$u,x:i.$x,$offset:i.$offset})};var lt=function(){function a(t){this.$L=ft(t.locale,null,!0),this.parse(t)}var i=a.prototype;return i.parse=function(t){this.$d=function(o){var e=o.date,c=o.utc;if(e===null)return new Date(NaN);if(d.u(e))return new Date;if(e instanceof Date)return new Date(e);if(typeof e=="string"&&!/Z$/i.test(e)){var h=e.match($t);if(h){var m=h[2]-1||0,b=(h[7]||"0").substring(0,3);return c?new Date(Date.UTC(h[1],m,h[3]||1,h[4]||0,h[5]||0,h[6]||0,b)):new Date(h[1],m,h[3]||1,h[4]||0,h[5]||0,h[6]||0,b)}}return new Date(e)}(t),this.$x=t.x||{},this.init()},i.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},i.$utils=function(){return d},i.isValid=function(){return this.$d.toString()!==ct},i.isSame=function(t,o){var e=T(t);return this.startOf(o)<=e&&e<=this.endOf(o)},i.isAfter=function(t,o){return T(t)<this.startOf(o)},i.isBefore=function(t,o){return this.endOf(o)<T(t)},i.$g=function(t,o,e){return d.u(t)?this[o]:this.set(e,t)},i.unix=function(){return Math.floor(this.valueOf()/1e3)},i.valueOf=function(){return this.$d.getTime()},i.startOf=function(t,o){var e=this,c=!!d.u(o)||o,h=d.p(t),m=function(q,L){var N=d.w(e.$u?Date.UTC(e.$y,L,q):new Date(e.$y,L,q),e);return c?N:N.endOf(S)},b=function(q,L){return d.w(e.toDate()[q].apply(e.toDate("s"),(c?[0,0,0,0]:[23,59,59,999]).slice(L)),e)},D=this.$W,C=this.$M,X=this.$D,k="set"+(this.$u?"UTC":"");switch(h){case W:return c?m(1,0):m(31,11);case x:return c?m(1,C):m(0,C+1);case F:var K=this.$locale().weekStart||0,tt=(D<K?D+7:D)-K;return m(c?X-tt:X+(6-tt),C);case S:case z:return b(k+"Hours",0);case v:return b(k+"Minutes",1);case Y:return b(k+"Seconds",2);case $:return b(k+"Milliseconds",3);default:return this.clone()}},i.endOf=function(t){return this.startOf(t,!1)},i.$set=function(t,o){var e,c=d.p(t),h="set"+(this.$u?"UTC":""),m=(e={},e[S]=h+"Date",e[z]=h+"Date",e[x]=h+"Month",e[W]=h+"FullYear",e[v]=h+"Hours",e[Y]=h+"Minutes",e[$]=h+"Seconds",e[g]=h+"Milliseconds",e)[c],b=c===S?this.$D+(o-this.$W):o;if(c===x||c===W){var D=this.clone().set(z,1);D.$d[m](b),D.init(),this.$d=D.set(z,Math.min(this.$D,D.daysInMonth())).$d}else m&&this.$d[m](b);return this.init(),this},i.set=function(t,o){return this.clone().$set(t,o)},i.get=function(t){return this[d.p(t)]()},i.add=function(t,o){var e,c=this;t=Number(t);var h=d.p(o),m=function(C){var X=T(c);return d.w(X.date(X.date()+Math.round(C*t)),c)};if(h===x)return this.set(x,this.$M+t);if(h===W)return this.set(W,this.$y+t);if(h===S)return m(1);if(h===F)return m(7);var b=(e={},e[Y]=s,e[v]=f,e[$]=r,e)[h]||1,D=this.$d.getTime()+t*b;return d.w(D,this)},i.subtract=function(t,o){return this.add(-1*t,o)},i.format=function(t){var o=this,e=this.$locale();if(!this.isValid())return e.invalidDate||ct;var c=t||"YYYY-MM-DDTHH:mm:ssZ",h=d.z(this),m=this.$H,b=this.$m,D=this.$M,C=e.weekdays,X=e.months,k=function(L,N,Mt,dt){return L&&(L[N]||L(o,c))||Mt[N].slice(0,dt)},K=function(L){return d.s(m%12||12,L,"0")},tt=e.meridiem||function(L,N,Mt){var dt=L<12?"AM":"PM";return Mt?dt.toLowerCase():dt},q={YY:String(this.$y).slice(-2),YYYY:d.s(this.$y,4,"0"),M:D+1,MM:d.s(D+1,2,"0"),MMM:k(e.monthsShort,D,X,3),MMMM:k(X,D),D:this.$D,DD:d.s(this.$D,2,"0"),d:String(this.$W),dd:k(e.weekdaysMin,this.$W,C,2),ddd:k(e.weekdaysShort,this.$W,C,3),dddd:C[this.$W],H:String(m),HH:d.s(m,2,"0"),h:K(1),hh:K(2),a:tt(m,b,!0),A:tt(m,b,!1),m:String(b),mm:d.s(b,2,"0"),s:String(this.$s),ss:d.s(this.$s,2,"0"),SSS:d.s(this.$ms,3,"0"),Z:h};return c.replace(ut,function(L,N){return N||q[L]||h.replace(":","")})},i.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},i.diff=function(t,o,e){var c,h=d.p(o),m=T(t),b=(m.utcOffset()-this.utcOffset())*s,D=this-m,C=d.m(this,m);return C=(c={},c[W]=C/12,c[x]=C,c[O]=C/3,c[F]=(D-b)/6048e5,c[S]=(D-b)/864e5,c[v]=D/f,c[Y]=D/s,c[$]=D/r,c)[h]||D,e?C:d.a(C)},i.daysInMonth=function(){return this.endOf(x).$D},i.$locale=function(){return B[this.$L]},i.locale=function(t,o){if(!t)return this.$L;var e=this.clone(),c=ft(t,o,!0);return c&&(e.$L=c),e},i.clone=function(){return d.w(this.$d,this)},i.toDate=function(){return new Date(this.valueOf())},i.toJSON=function(){return this.isValid()?this.toISOString():null},i.toISOString=function(){return this.$d.toISOString()},i.toString=function(){return this.$d.toUTCString()},a}(),yt=lt.prototype;return T.prototype=yt,[["$ms",g],["$s",$],["$m",Y],["$H",v],["$W",S],["$M",x],["$y",W],["$D",z]].forEach(function(a){yt[a[1]]=function(i){return this.$g(i,a[0],a[1])}}),T.extend=function(a,i){return a.$i||(a(i,lt,T),a.$i=!0),T},T.locale=ft,T.isDayjs=pt,T.unix=function(a){return T(1e3*a)},T.en=B[j],T.Ls=B,T.p={},T})})(V);var Ot=V.exports;const Lt=y(Ot),gt=(l,n="MM/DD HH:mm")=>Lt(l).format(n),wt=(l,n)=>{let r,s=0;return(...f)=>{const g=Date.now(),$=g-s;!s||$>=n?(s=g,l.apply(void 0,f)):r||(r=setTimeout(()=>{s=g,l.apply(void 0,f),r=null},n-$))}},_t=(l,n)=>{const r=document.createElement("canvas");r.width=r.height=1;const s=r.getContext("2d");s.fillStyle=l,s.fillRect(0,0,1,1);const f=s.getImageData(0,0,1,1).data;return`rgba(${f[0]}, ${f[1]}, ${f[2]}, ${n})`},Et=({xCenterPoint:l,cfg:n,timePerPixel:r,timeSpacing:s,currentTime:f,$canvas:g,screenScaleCount:$,scaleHeight:Y,startTime:v,drawLine:S,drawText:F,drawArea:x})=>{const O=({space:W,scaleFormat:z,bgFormat:ct,currentFormat:$t})=>{F({x:g.width-l/10,y:6,text:gt(f,ct),fontSize:`${g.height-5}px`,align:"right",baseLine:"top",color:n.bgTextColor});const ut=v%s,vt=ut/r;for(let I=0;I<$;I++){const Q=I*n.scaleSpacing-vt-n.pointWidth/2,j=v+I*s-ut;if(j%(s*W)===0){S({x:Q,y:Y.long}),F({x:Q,y:g.height-Y.long-5,text:gt(j,z),baseLine:"bottom"});continue}S({x:Q,y:Y.short})}S({x:l-n.pointWidth/2,y:g.height,width:n.pointWidth,color:n.pointColor}),x({startX:l-50,startY:4,endX:l+50,endY:18,bgColor:n.pointColor}),F({x:l,y:6,text:gt(f,$t),align:"center",baseLine:"top"})};s<100?O({space:10,scaleFormat:"mm:ss:SSS",bgFormat:"YYYY/MM/DD",currentFormat:"HH:mm:ss:SSS"}):s<1e3?O({space:10,scaleFormat:"mm:ss",bgFormat:"YYYY/MM/DD",currentFormat:"HH:mm:ss:SSS"}):s<1e4?O({space:10,scaleFormat:"mm:ss",bgFormat:"YYYY/MM/DD",currentFormat:"HH:mm:ss"}):s<6e4?O({space:12,scaleFormat:"HH:mm:ss",bgFormat:"YYYY/MM/DD",currentFormat:"HH:mm:ss"}):s<6e5?O({space:10,scaleFormat:"HH:mm:ss",bgFormat:"YYYY/MM/DD",currentFormat:"HH:mm:ss"}):s<36e5?O({space:12,scaleFormat:"MM/DD HH:mm",bgFormat:"YYYY/MM",currentFormat:"MM/DD HH:mm:ss"}):s<864e5?O({space:12,scaleFormat:"MM/DD HH:mm",bgFormat:"YYYY/MM",currentFormat:"YYYY/MM/DD HH:mm"}):s<6048e5?O({space:10,scaleFormat:"YYYY/MM/DD",bgFormat:"YYYY",currentFormat:"YYYY/MM/DD"}):O({space:10,scaleFormat:"YYYY/MM/DD",bgFormat:"YYYY",currentFormat:"YYYY/MM/DD"})},At={fill:!0,width:1e3,height:60,bgColor:"rgba(0,0,0,0.5)",areaBgColor:"#ffffff55",textColor:"#ffffff",scaleColor:"#ffffff",pointColor:"#00aeec",pointWidth:3,scaleSpacing:7,fps:60,zoom:3,timeSpacingList:[10,100,1e3,1e4,6e4,6e5,36e5,864e5,6048e5]};class Wt{constructor(n,r){H(this,it);H(this,st);H(this,nt);H(this,rt);H(this,at);H(this,ot);H(this,G);H(this,R);H(this,ht);et(this,"$canvas");et(this,"ctx");et(this,"$canvasParent");et(this,"cfg");H(this,J,M());H(this,_,0);H(this,P,void 0);H(this,w,void 0);H(this,U,void 0);H(this,Z,!1);if(!n)throw new Error("canvas Element Or Element ID is required!");typeof n=="string"?this.$canvas=document.querySelector(n):this.$canvas=n,this.ctx=this.$canvas.getContext("2d"),this.cfg={...At,...r};const{fill:s,width:f,height:g,zoom:$,timeSpacingList:Y,scaleHeight:v,textColor:S,bgTextColor:F}=this.cfg;if(F||(this.cfg.bgTextColor=_t(S,.18)),$<0||$>=Y.length||$%1!==0)throw new Error(`zoom must be 0 ~ ${Y.length-1}, and must be an integer`);if(s){const x=this.$canvas.parentElement;this.$canvasParent=x,this.$canvas.width=x.clientWidth,this.$canvas.height=x.clientHeight,new ResizeObserver(wt(E(this,nt,St).bind(this),200)).observe(x)}else f&&(this.$canvas.width=f),g&&(this.$canvas.height=g);A(this,w,Y[$]),v!=null&&v.long&&(v!=null&&v.short)?A(this,U,v):A(this,U,{long:this.$canvas.height/3,medium:this.$canvas.height/6,short:this.$canvas.height/10}),this.draw(),this.$canvas.addEventListener("wheel",E(this,st,bt).bind(this),{passive:!1}),this.$canvas.addEventListener("mousedown",E(this,it,xt).bind(this))}draw({currentTime:n,areas:r,_privateFlag:s}={}){if(u(this,Z)&&!s)return;A(this,_,n||Date.now()),A(this,P,r||[]);const f=Math.ceil(this.$canvas.width/this.cfg.scaleSpacing),g=f*u(this,w),$=u(this,_)-g/2,Y=u(this,_)+g/2,v=this.$canvas.width/2,S=g/this.$canvas.width;E(this,rt,Tt).call(this),E(this,R,mt).call(this,{startX:0,startY:0,endX:this.$canvas.width,endY:this.$canvas.height,bgColor:this.cfg.bgColor}),u(this,P).forEach(F=>{const x=F.startTime<$?0:Math.floor((F.startTime-$)/S),O=F.endTime>Y?this.$canvas.width:Math.floor((F.endTime-$)/S);E(this,R,mt).call(this,{startX:x,startY:0,endX:O,endY:this.$canvas.height,bgColor:F.bgColor||this.cfg.areaBgColor})}),Et.bind(this)({xCenterPoint:v,screenScaleCount:f,startTime:$,timePerPixel:S,scaleHeight:u(this,U),timeSpacing:u(this,w),currentTime:u(this,_),$canvas:this.$canvas,cfg:this.cfg,drawLine:E(this,ot,Ct).bind(this),drawText:E(this,G,Dt).bind(this),drawArea:E(this,R,mt).bind(this)}),E(this,at,Ft).call(this)}getCurrentTime(){return u(this,_)}on(n,r){u(this,J).on(n,r)}off(n,r){u(this,J).off(n,r)}}return J=new WeakMap,_=new WeakMap,P=new WeakMap,w=new WeakMap,U=new WeakMap,Z=new WeakMap,it=new WeakSet,xt=function(n){A(this,Z,!0);let r=0,s=u(this,_);const f=wt(({offsetX:Y})=>{if(!u(this,Z))return;const v=Y-n.offsetX;s=Math.round(u(this,_)-u(this,w)/this.cfg.scaleSpacing*(v-r)),r=v,this.draw({currentTime:s,areas:u(this,P),_privateFlag:!0})},1e3/this.cfg.fps),g=({offsetX:Y,offsetY:v})=>{(Y<3||Y>this.$canvas.width-3||v<3||v>this.$canvas.height-3)&&(this.$canvas.removeEventListener("mousemove",f),this.$canvas.removeEventListener("mousemove",g))},$=()=>{this.$canvas.removeEventListener("mousemove",f),this.$canvas.removeEventListener("mousemove",g),document.removeEventListener("mouseup",$),A(this,Z,!1),E(this,ht,Ht).call(this,"dragged",s)};this.$canvas.addEventListener("mousemove",f),this.$canvas.addEventListener("mousemove",g),document.addEventListener("mouseup",$)},st=new WeakSet,bt=function(n){n.preventDefault();const r=this.cfg.timeSpacingList.findIndex(s=>s===u(this,w));n.deltaY<0&&r>0?(A(this,w,this.cfg.timeSpacingList[r-1]),this.draw({currentTime:u(this,_),areas:u(this,P),_privateFlag:!0})):n.deltaY>0&&r<this.cfg.timeSpacingList.length-1&&(A(this,w,this.cfg.timeSpacingList[r+1]),this.draw({currentTime:u(this,_),areas:u(this,P),_privateFlag:!0}))},nt=new WeakSet,St=function(){this.$canvasParent&&(this.$canvas.width=this.$canvasParent.clientWidth,this.$canvas.height=this.$canvasParent.clientHeight,this.cfg.scaleHeight||A(this,U,{long:this.$canvas.height/3,medium:this.$canvas.height/6,short:this.$canvas.height/10}),this.draw({currentTime:u(this,_),areas:u(this,P)}))},rt=new WeakSet,Tt=function(){this.ctx.clearRect(0,0,this.$canvas.width,this.$canvas.height)},at=new WeakSet,Ft=function(){const n=()=>u(this,w)<1e3?`${u(this,w)}ms`:u(this,w)<6e4?`${Math.round(u(this,w)/100)/10}sec`:u(this,w)<36e5?`${Math.round(u(this,w)/100/60)/10}min`:u(this,w)<864e5?`${Math.round(u(this,w)/100/60/60)/10}hours`:u(this,w)<6048e5?`${Math.round(u(this,w)/100/60/60/24)/10}days`:`${Math.round(u(this,w)/100/60/60/24/7)/10}weeks`;E(this,G,Dt).call(this,{x:this.cfg.scaleSpacing+12,y:9,text:n(),align:"left",baseLine:"middle"}),this.ctx.beginPath(),this.ctx.moveTo(5,6),this.ctx.lineTo(5,10),this.ctx.lineTo(this.cfg.scaleSpacing+6,10),this.ctx.lineTo(this.cfg.scaleSpacing+6,6),this.ctx.strokeStyle=this.cfg.scaleColor,this.ctx.lineWidth=1.5,this.ctx.stroke()},ot=new WeakSet,Ct=function({x:n,y:r,width:s=1,color:f=this.cfg.scaleColor}){this.ctx.beginPath(),this.ctx.moveTo(n,this.$canvas.height),this.ctx.lineTo(n,this.$canvas.height-r),this.ctx.closePath(),this.ctx.strokeStyle=f,this.ctx.lineWidth=s,this.ctx.stroke()},G=new WeakSet,Dt=function({x:n,y:r,text:s,color:f=this.cfg.textColor,fontSize:g="11px",align:$="center",baseLine:Y="alphabetic"}){this.ctx.beginPath(),this.ctx.font=`${g} Arial`,this.ctx.fillStyle=f,this.ctx.textAlign=$,this.ctx.textBaseline=Y,this.ctx.fillText(s,n,r)},R=new WeakSet,mt=function({startX:n,startY:r,endX:s,endY:f,bgColor:g}){this.ctx.beginPath(),this.ctx.rect(n,r,s-n,f-r),this.ctx.fillStyle=g,this.ctx.fill()},ht=new WeakSet,Ht=function(...n){u(this,J).emit(...n)},Wt}(); | ||
var $timeline=function(){var J,_,P,w,U,Z,it,xt,st,bt,nt,St,rt,Tt,at,Ft,ot,Ct,G,Dt,R,mt,ht,Ht;"use strict";var Pt=Object.defineProperty;var kt=(M,p,x)=>p in M?Pt(M,p,{enumerable:!0,configurable:!0,writable:!0,value:x}):M[p]=x;var et=(M,p,x)=>(kt(M,typeof p!="symbol"?p+"":p,x),x),Yt=(M,p,x)=>{if(!p.has(M))throw TypeError("Cannot "+x)};var u=(M,p,x)=>(Yt(M,p,"read from private field"),x?x.call(M):p.get(M)),O=(M,p,x)=>{if(p.has(M))throw TypeError("Cannot add the same private member more than once");p instanceof WeakSet?p.add(M):p.set(M,x)},A=(M,p,x,V)=>(Yt(M,p,"write to private field"),V?V.call(M,x):p.set(M,x),x);var E=(M,p,x)=>(Yt(M,p,"access private method"),x);function M(l){return{all:l=l||new Map,on:function(n,r){var s=l.get(n);s?s.push(r):l.set(n,[r])},off:function(n,r){var s=l.get(n);s&&(r?s.splice(s.indexOf(r)>>>0,1):l.set(n,[]))},emit:function(n,r){var s=l.get(n);s&&s.slice().map(function(f){f(r)}),(s=l.get("*"))&&s.slice().map(function(f){f(n,r)})}}}var p=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function x(l){return l&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l}var V={exports:{}};(function(l,n){(function(r,s){l.exports=s()})(p,function(){var r=1e3,s=6e4,f=36e5,g="millisecond",$="second",Y="minute",v="hour",S="day",F="week",y="month",C="quarter",W="year",z="date",ct="Invalid Date",$t=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,ut=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,vt={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(a){var i=["th","st","nd","rd"],t=a%100;return"["+a+(i[(t-20)%10]||i[t]||i[0])+"]"}},I=function(a,i,t){var o=String(a);return!o||o.length>=i?a:""+Array(i+1-o.length).join(t)+a},Q={s:I,z:function(a){var i=-a.utcOffset(),t=Math.abs(i),o=Math.floor(t/60),e=t%60;return(i<=0?"+":"-")+I(o,2,"0")+":"+I(e,2,"0")},m:function a(i,t){if(i.date()<t.date())return-a(t,i);var o=12*(t.year()-i.year())+(t.month()-i.month()),e=i.clone().add(o,y),c=t-e<0,h=i.clone().add(o+(c?-1:1),y);return+(-(o+(t-e)/(c?e-h:h-e))||0)},a:function(a){return a<0?Math.ceil(a)||0:Math.floor(a)},p:function(a){return{M:y,y:W,w:F,d:S,D:z,h:v,m:Y,s:$,ms:g,Q:C}[a]||String(a||"").toLowerCase().replace(/s$/,"")},u:function(a){return a===void 0}},j="en",B={};B[j]=vt;var pt=function(a){return a instanceof lt},ft=function a(i,t,o){var e;if(!i)return j;if(typeof i=="string"){var c=i.toLowerCase();B[c]&&(e=c),t&&(B[c]=t,e=c);var h=i.split("-");if(!e&&h.length>1)return a(h[0])}else{var m=i.name;B[m]=i,e=m}return!o&&e&&(j=e),e||!o&&j},T=function(a,i){if(pt(a))return a.clone();var t=typeof i=="object"?i:{};return t.date=a,t.args=arguments,new lt(t)},d=Q;d.l=ft,d.i=pt,d.w=function(a,i){return T(a,{locale:i.$L,utc:i.$u,x:i.$x,$offset:i.$offset})};var lt=function(){function a(t){this.$L=ft(t.locale,null,!0),this.parse(t)}var i=a.prototype;return i.parse=function(t){this.$d=function(o){var e=o.date,c=o.utc;if(e===null)return new Date(NaN);if(d.u(e))return new Date;if(e instanceof Date)return new Date(e);if(typeof e=="string"&&!/Z$/i.test(e)){var h=e.match($t);if(h){var m=h[2]-1||0,b=(h[7]||"0").substring(0,3);return c?new Date(Date.UTC(h[1],m,h[3]||1,h[4]||0,h[5]||0,h[6]||0,b)):new Date(h[1],m,h[3]||1,h[4]||0,h[5]||0,h[6]||0,b)}}return new Date(e)}(t),this.$x=t.x||{},this.init()},i.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},i.$utils=function(){return d},i.isValid=function(){return this.$d.toString()!==ct},i.isSame=function(t,o){var e=T(t);return this.startOf(o)<=e&&e<=this.endOf(o)},i.isAfter=function(t,o){return T(t)<this.startOf(o)},i.isBefore=function(t,o){return this.endOf(o)<T(t)},i.$g=function(t,o,e){return d.u(t)?this[o]:this.set(e,t)},i.unix=function(){return Math.floor(this.valueOf()/1e3)},i.valueOf=function(){return this.$d.getTime()},i.startOf=function(t,o){var e=this,c=!!d.u(o)||o,h=d.p(t),m=function(q,L){var N=d.w(e.$u?Date.UTC(e.$y,L,q):new Date(e.$y,L,q),e);return c?N:N.endOf(S)},b=function(q,L){return d.w(e.toDate()[q].apply(e.toDate("s"),(c?[0,0,0,0]:[23,59,59,999]).slice(L)),e)},D=this.$W,H=this.$M,X=this.$D,k="set"+(this.$u?"UTC":"");switch(h){case W:return c?m(1,0):m(31,11);case y:return c?m(1,H):m(0,H+1);case F:var K=this.$locale().weekStart||0,tt=(D<K?D+7:D)-K;return m(c?X-tt:X+(6-tt),H);case S:case z:return b(k+"Hours",0);case v:return b(k+"Minutes",1);case Y:return b(k+"Seconds",2);case $:return b(k+"Milliseconds",3);default:return this.clone()}},i.endOf=function(t){return this.startOf(t,!1)},i.$set=function(t,o){var e,c=d.p(t),h="set"+(this.$u?"UTC":""),m=(e={},e[S]=h+"Date",e[z]=h+"Date",e[y]=h+"Month",e[W]=h+"FullYear",e[v]=h+"Hours",e[Y]=h+"Minutes",e[$]=h+"Seconds",e[g]=h+"Milliseconds",e)[c],b=c===S?this.$D+(o-this.$W):o;if(c===y||c===W){var D=this.clone().set(z,1);D.$d[m](b),D.init(),this.$d=D.set(z,Math.min(this.$D,D.daysInMonth())).$d}else m&&this.$d[m](b);return this.init(),this},i.set=function(t,o){return this.clone().$set(t,o)},i.get=function(t){return this[d.p(t)]()},i.add=function(t,o){var e,c=this;t=Number(t);var h=d.p(o),m=function(H){var X=T(c);return d.w(X.date(X.date()+Math.round(H*t)),c)};if(h===y)return this.set(y,this.$M+t);if(h===W)return this.set(W,this.$y+t);if(h===S)return m(1);if(h===F)return m(7);var b=(e={},e[Y]=s,e[v]=f,e[$]=r,e)[h]||1,D=this.$d.getTime()+t*b;return d.w(D,this)},i.subtract=function(t,o){return this.add(-1*t,o)},i.format=function(t){var o=this,e=this.$locale();if(!this.isValid())return e.invalidDate||ct;var c=t||"YYYY-MM-DDTHH:mm:ssZ",h=d.z(this),m=this.$H,b=this.$m,D=this.$M,H=e.weekdays,X=e.months,k=function(L,N,Mt,dt){return L&&(L[N]||L(o,c))||Mt[N].slice(0,dt)},K=function(L){return d.s(m%12||12,L,"0")},tt=e.meridiem||function(L,N,Mt){var dt=L<12?"AM":"PM";return Mt?dt.toLowerCase():dt},q={YY:String(this.$y).slice(-2),YYYY:d.s(this.$y,4,"0"),M:D+1,MM:d.s(D+1,2,"0"),MMM:k(e.monthsShort,D,X,3),MMMM:k(X,D),D:this.$D,DD:d.s(this.$D,2,"0"),d:String(this.$W),dd:k(e.weekdaysMin,this.$W,H,2),ddd:k(e.weekdaysShort,this.$W,H,3),dddd:H[this.$W],H:String(m),HH:d.s(m,2,"0"),h:K(1),hh:K(2),a:tt(m,b,!0),A:tt(m,b,!1),m:String(b),mm:d.s(b,2,"0"),s:String(this.$s),ss:d.s(this.$s,2,"0"),SSS:d.s(this.$ms,3,"0"),Z:h};return c.replace(ut,function(L,N){return N||q[L]||h.replace(":","")})},i.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},i.diff=function(t,o,e){var c,h=d.p(o),m=T(t),b=(m.utcOffset()-this.utcOffset())*s,D=this-m,H=d.m(this,m);return H=(c={},c[W]=H/12,c[y]=H,c[C]=H/3,c[F]=(D-b)/6048e5,c[S]=(D-b)/864e5,c[v]=D/f,c[Y]=D/s,c[$]=D/r,c)[h]||D,e?H:d.a(H)},i.daysInMonth=function(){return this.endOf(y).$D},i.$locale=function(){return B[this.$L]},i.locale=function(t,o){if(!t)return this.$L;var e=this.clone(),c=ft(t,o,!0);return c&&(e.$L=c),e},i.clone=function(){return d.w(this.$d,this)},i.toDate=function(){return new Date(this.valueOf())},i.toJSON=function(){return this.isValid()?this.toISOString():null},i.toISOString=function(){return this.$d.toISOString()},i.toString=function(){return this.$d.toUTCString()},a}(),yt=lt.prototype;return T.prototype=yt,[["$ms",g],["$s",$],["$m",Y],["$H",v],["$W",S],["$M",y],["$y",W],["$D",z]].forEach(function(a){yt[a[1]]=function(i){return this.$g(i,a[0],a[1])}}),T.extend=function(a,i){return a.$i||(a(i,lt,T),a.$i=!0),T},T.locale=ft,T.isDayjs=pt,T.unix=function(a){return T(1e3*a)},T.en=B[j],T.Ls=B,T.p={},T})})(V);var Ot=V.exports;const Lt=x(Ot),gt=(l,n="MM/DD HH:mm")=>Lt(l).format(n),wt=(l,n)=>{let r,s=0;return(...f)=>{const g=Date.now(),$=g-s;!s||$>=n?(s=g,l.apply(void 0,f)):r||(r=setTimeout(()=>{s=g,l.apply(void 0,f),r=null},n-$))}},_t=(l,n)=>{const r=document.createElement("canvas");r.width=r.height=1;const s=r.getContext("2d");s.fillStyle=l,s.fillRect(0,0,1,1);const f=s.getImageData(0,0,1,1).data;return`rgba(${f[0]}, ${f[1]}, ${f[2]}, ${n})`},Et=({xCenterPoint:l,cfg:n,timePerPixel:r,timeSpacing:s,currentTime:f,$canvas:g,screenScaleCount:$,scaleHeight:Y,startTime:v,drawLine:S,drawText:F,drawArea:y})=>{const C=({space:W,scaleFormat:z,bgFormat:ct,currentFormat:$t})=>{F({x:g.width-l/10,y:6,text:gt(f,ct),fontSize:`${g.height-5}px`,align:"right",baseLine:"top",color:n.bgTextColor});const ut=v%s,vt=ut/r;for(let I=0;I<$;I++){const Q=I*n.scaleSpacing-vt-n.pointWidth/2,j=v+I*s-ut;if(j%(s*W)===0){S({x:Q,y:Y.long}),F({x:Q,y:g.height-Y.long-5,text:gt(j,z),baseLine:"bottom"});continue}S({x:Q,y:Y.short})}S({x:l-n.pointWidth/2,y:g.height,width:n.pointWidth,color:n.pointColor}),y({startX:l-50,startY:4,endX:l+50,endY:18,bgColor:n.pointColor}),F({x:l,y:6,text:gt(f,$t),align:"center",baseLine:"top"})};s<100?C({space:10,scaleFormat:"mm:ss:SSS",bgFormat:"YYYY/MM/DD",currentFormat:"HH:mm:ss:SSS"}):s<1e3?C({space:10,scaleFormat:"mm:ss",bgFormat:"YYYY/MM/DD",currentFormat:"HH:mm:ss:SSS"}):s<1e4?C({space:10,scaleFormat:"mm:ss",bgFormat:"YYYY/MM/DD",currentFormat:"HH:mm:ss"}):s<6e4?C({space:12,scaleFormat:"HH:mm:ss",bgFormat:"YYYY/MM/DD",currentFormat:"HH:mm:ss"}):s<6e5?C({space:10,scaleFormat:"HH:mm:ss",bgFormat:"YYYY/MM/DD",currentFormat:"HH:mm:ss"}):s<36e5?C({space:12,scaleFormat:"MM/DD HH:mm",bgFormat:"YYYY/MM",currentFormat:"MM/DD HH:mm:ss"}):s<864e5?C({space:12,scaleFormat:"MM/DD HH:mm",bgFormat:"YYYY/MM",currentFormat:"YYYY/MM/DD HH:mm"}):s<6048e5?C({space:10,scaleFormat:"YYYY/MM/DD",bgFormat:"YYYY",currentFormat:"YYYY/MM/DD"}):C({space:10,scaleFormat:"YYYY/MM/DD",bgFormat:"YYYY",currentFormat:"YYYY/MM/DD"})},At={fill:!0,width:1e3,height:60,bgColor:"rgba(0,0,0,0.5)",areaBgColor:"#ffffff55",textColor:"#ffffff",scaleColor:"#ffffff",pointColor:"#00aeec",pointWidth:3,scaleSpacing:7,fps:60,zoom:3,timeSpacingList:[10,100,1e3,1e4,6e4,6e5,36e5,864e5,6048e5]};class Wt{constructor(n,r){O(this,it);O(this,st);O(this,nt);O(this,rt);O(this,at);O(this,ot);O(this,G);O(this,R);O(this,ht);et(this,"$canvas");et(this,"ctx");et(this,"$canvasParent");et(this,"cfg");O(this,J,M());O(this,_,0);O(this,P,void 0);O(this,w,void 0);O(this,U,void 0);O(this,Z,!1);if(!n)throw new Error("canvas Element Or Element ID is required!");typeof n=="string"?this.$canvas=document.querySelector(n):this.$canvas=n,this.ctx=this.$canvas.getContext("2d"),this.cfg={...At,...r};const{fill:s,width:f,height:g,zoom:$,timeSpacingList:Y,scaleHeight:v,textColor:S,bgTextColor:F}=this.cfg;if(F||(this.cfg.bgTextColor=_t(S,.18)),$<0||$>=Y.length||$%1!==0)throw new Error(`zoom must be 0 ~ ${Y.length-1}, and must be an integer`);if(s){const y=this.$canvas.parentElement;this.$canvasParent=y,this.$canvas.width=y.clientWidth,this.$canvas.height=y.clientHeight,new ResizeObserver(wt(E(this,nt,St).bind(this),200)).observe(y)}else f&&(this.$canvas.width=f),g&&(this.$canvas.height=g);A(this,w,Y[$]),v!=null&&v.long&&(v!=null&&v.short)?A(this,U,v):A(this,U,{long:this.$canvas.height/3,medium:this.$canvas.height/6,short:this.$canvas.height/10}),this.draw(),this.$canvas.addEventListener("wheel",E(this,st,bt).bind(this),{passive:!1}),this.$canvas.addEventListener("mousedown",E(this,it,xt).bind(this))}draw({currentTime:n,areas:r,_privateFlag:s}={}){if(u(this,Z)&&!s)return;A(this,_,n||Date.now()),A(this,P,r||[]);const f=Math.ceil(this.$canvas.width/this.cfg.scaleSpacing),g=f*u(this,w),$=u(this,_)-g/2,Y=u(this,_)+g/2,v=this.$canvas.width/2,S=g/this.$canvas.width;E(this,rt,Tt).call(this),E(this,R,mt).call(this,{startX:0,startY:0,endX:this.$canvas.width,endY:this.$canvas.height,bgColor:this.cfg.bgColor}),u(this,P).forEach(F=>{const y=F.startTime<=$?0:Math.round((F.startTime-$)/S),C=F.endTime>=Y?this.$canvas.width:Math.round((F.endTime-$)/S);y<this.$canvas.width&&C>0&&E(this,R,mt).call(this,{startX:y,startY:0,endX:C,endY:this.$canvas.height,bgColor:F.bgColor||this.cfg.areaBgColor})}),Et.bind(this)({xCenterPoint:v,screenScaleCount:f,startTime:$,timePerPixel:S,scaleHeight:u(this,U),timeSpacing:u(this,w),currentTime:u(this,_),$canvas:this.$canvas,cfg:this.cfg,drawLine:E(this,ot,Ct).bind(this),drawText:E(this,G,Dt).bind(this),drawArea:E(this,R,mt).bind(this)}),E(this,at,Ft).call(this)}getCurrentTime(){return u(this,_)}on(n,r){u(this,J).on(n,r)}off(n,r){u(this,J).off(n,r)}}return J=new WeakMap,_=new WeakMap,P=new WeakMap,w=new WeakMap,U=new WeakMap,Z=new WeakMap,it=new WeakSet,xt=function(n){A(this,Z,!0);let r=0,s=u(this,_);const f=wt(({offsetX:Y})=>{if(!u(this,Z))return;const v=Y-n.offsetX;s=Math.round(u(this,_)-u(this,w)/this.cfg.scaleSpacing*(v-r)),r=v,this.draw({currentTime:s,areas:u(this,P),_privateFlag:!0})},1e3/this.cfg.fps),g=({offsetX:Y,offsetY:v})=>{(Y<3||Y>this.$canvas.width-3||v<3||v>this.$canvas.height-3)&&(this.$canvas.removeEventListener("mousemove",f),this.$canvas.removeEventListener("mousemove",g))},$=()=>{this.$canvas.removeEventListener("mousemove",f),this.$canvas.removeEventListener("mousemove",g),document.removeEventListener("mouseup",$),A(this,Z,!1),E(this,ht,Ht).call(this,"dragged",s)};this.$canvas.addEventListener("mousemove",f),this.$canvas.addEventListener("mousemove",g),document.addEventListener("mouseup",$)},st=new WeakSet,bt=function(n){n.preventDefault();const r=this.cfg.timeSpacingList.findIndex(s=>s===u(this,w));n.deltaY<0&&r>0?(A(this,w,this.cfg.timeSpacingList[r-1]),this.draw({currentTime:u(this,_),areas:u(this,P),_privateFlag:!0})):n.deltaY>0&&r<this.cfg.timeSpacingList.length-1&&(A(this,w,this.cfg.timeSpacingList[r+1]),this.draw({currentTime:u(this,_),areas:u(this,P),_privateFlag:!0}))},nt=new WeakSet,St=function(){this.$canvasParent&&(this.$canvas.width=this.$canvasParent.clientWidth,this.$canvas.height=this.$canvasParent.clientHeight,this.cfg.scaleHeight||A(this,U,{long:this.$canvas.height/3,medium:this.$canvas.height/6,short:this.$canvas.height/10}),this.draw({currentTime:u(this,_),areas:u(this,P)}))},rt=new WeakSet,Tt=function(){this.ctx.clearRect(0,0,this.$canvas.width,this.$canvas.height)},at=new WeakSet,Ft=function(){const n=()=>u(this,w)<1e3?`${u(this,w)}ms`:u(this,w)<6e4?`${Math.round(u(this,w)/100)/10}sec`:u(this,w)<36e5?`${Math.round(u(this,w)/100/60)/10}min`:u(this,w)<864e5?`${Math.round(u(this,w)/100/60/60)/10}hours`:u(this,w)<6048e5?`${Math.round(u(this,w)/100/60/60/24)/10}days`:`${Math.round(u(this,w)/100/60/60/24/7)/10}weeks`;E(this,G,Dt).call(this,{x:this.cfg.scaleSpacing+12,y:9,text:n(),align:"left",baseLine:"middle"}),this.ctx.beginPath(),this.ctx.moveTo(5,6),this.ctx.lineTo(5,10),this.ctx.lineTo(this.cfg.scaleSpacing+6,10),this.ctx.lineTo(this.cfg.scaleSpacing+6,6),this.ctx.strokeStyle=this.cfg.scaleColor,this.ctx.lineWidth=1.5,this.ctx.stroke()},ot=new WeakSet,Ct=function({x:n,y:r,width:s=1,color:f=this.cfg.scaleColor}){this.ctx.beginPath(),this.ctx.moveTo(n,this.$canvas.height),this.ctx.lineTo(n,this.$canvas.height-r),this.ctx.closePath(),this.ctx.strokeStyle=f,this.ctx.lineWidth=s,this.ctx.stroke()},G=new WeakSet,Dt=function({x:n,y:r,text:s,color:f=this.cfg.textColor,fontSize:g="11px",align:$="center",baseLine:Y="alphabetic"}){this.ctx.beginPath(),this.ctx.font=`${g} Arial`,this.ctx.fillStyle=f,this.ctx.textAlign=$,this.ctx.textBaseline=Y,this.ctx.fillText(s,n,r)},R=new WeakSet,mt=function({startX:n,startY:r,endX:s,endY:f,bgColor:g}){this.ctx.beginPath(),this.ctx.rect(n,r,s-n,f-r),this.ctx.fillStyle=g,this.ctx.fill()},ht=new WeakSet,Ht=function(...n){u(this,J).emit(...n)},Wt}(); |
@@ -1,1 +0,1 @@ | ||
(function($,d){typeof exports=="object"&&typeof module<"u"?module.exports=d():typeof define=="function"&&define.amd?define(d):($=typeof globalThis<"u"?globalThis:$||self,$.$timeline=d())})(this,function(){var J,_,P,w,U,Z,it,xt,st,bt,nt,St,rt,Tt,at,Ft,ot,Ct,G,Dt,R,mt,ht,Ht;"use strict";var Pt=Object.defineProperty;var kt=($,d,y)=>d in $?Pt($,d,{enumerable:!0,configurable:!0,writable:!0,value:y}):$[d]=y;var et=($,d,y)=>(kt($,typeof d!="symbol"?d+"":d,y),y),Yt=($,d,y)=>{if(!d.has($))throw TypeError("Cannot "+y)};var u=($,d,y)=>(Yt($,d,"read from private field"),y?y.call($):d.get($)),H=($,d,y)=>{if(d.has($))throw TypeError("Cannot add the same private member more than once");d instanceof WeakSet?d.add($):d.set($,y)},A=($,d,y,V)=>(Yt($,d,"write to private field"),V?V.call($,y):d.set($,y),y);var E=($,d,y)=>(Yt($,d,"access private method"),y);function $(l){return{all:l=l||new Map,on:function(n,r){var s=l.get(n);s?s.push(r):l.set(n,[r])},off:function(n,r){var s=l.get(n);s&&(r?s.splice(s.indexOf(r)>>>0,1):l.set(n,[]))},emit:function(n,r){var s=l.get(n);s&&s.slice().map(function(f){f(r)}),(s=l.get("*"))&&s.slice().map(function(f){f(n,r)})}}}var d=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function y(l){return l&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l}var V={exports:{}};(function(l,n){(function(r,s){l.exports=s()})(d,function(){var r=1e3,s=6e4,f=36e5,v="millisecond",p="second",Y="minute",M="hour",S="day",F="week",x="month",O="quarter",W="year",z="date",ct="Invalid Date",$t=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,ut=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,vt={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(a){var i=["th","st","nd","rd"],t=a%100;return"["+a+(i[(t-20)%10]||i[t]||i[0])+"]"}},I=function(a,i,t){var o=String(a);return!o||o.length>=i?a:""+Array(i+1-o.length).join(t)+a},Q={s:I,z:function(a){var i=-a.utcOffset(),t=Math.abs(i),o=Math.floor(t/60),e=t%60;return(i<=0?"+":"-")+I(o,2,"0")+":"+I(e,2,"0")},m:function a(i,t){if(i.date()<t.date())return-a(t,i);var o=12*(t.year()-i.year())+(t.month()-i.month()),e=i.clone().add(o,x),c=t-e<0,h=i.clone().add(o+(c?-1:1),x);return+(-(o+(t-e)/(c?e-h:h-e))||0)},a:function(a){return a<0?Math.ceil(a)||0:Math.floor(a)},p:function(a){return{M:x,y:W,w:F,d:S,D:z,h:M,m:Y,s:p,ms:v,Q:O}[a]||String(a||"").toLowerCase().replace(/s$/,"")},u:function(a){return a===void 0}},j="en",B={};B[j]=vt;var pt=function(a){return a instanceof lt},ft=function a(i,t,o){var e;if(!i)return j;if(typeof i=="string"){var c=i.toLowerCase();B[c]&&(e=c),t&&(B[c]=t,e=c);var h=i.split("-");if(!e&&h.length>1)return a(h[0])}else{var g=i.name;B[g]=i,e=g}return!o&&e&&(j=e),e||!o&&j},T=function(a,i){if(pt(a))return a.clone();var t=typeof i=="object"?i:{};return t.date=a,t.args=arguments,new lt(t)},m=Q;m.l=ft,m.i=pt,m.w=function(a,i){return T(a,{locale:i.$L,utc:i.$u,x:i.$x,$offset:i.$offset})};var lt=function(){function a(t){this.$L=ft(t.locale,null,!0),this.parse(t)}var i=a.prototype;return i.parse=function(t){this.$d=function(o){var e=o.date,c=o.utc;if(e===null)return new Date(NaN);if(m.u(e))return new Date;if(e instanceof Date)return new Date(e);if(typeof e=="string"&&!/Z$/i.test(e)){var h=e.match($t);if(h){var g=h[2]-1||0,b=(h[7]||"0").substring(0,3);return c?new Date(Date.UTC(h[1],g,h[3]||1,h[4]||0,h[5]||0,h[6]||0,b)):new Date(h[1],g,h[3]||1,h[4]||0,h[5]||0,h[6]||0,b)}}return new Date(e)}(t),this.$x=t.x||{},this.init()},i.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},i.$utils=function(){return m},i.isValid=function(){return this.$d.toString()!==ct},i.isSame=function(t,o){var e=T(t);return this.startOf(o)<=e&&e<=this.endOf(o)},i.isAfter=function(t,o){return T(t)<this.startOf(o)},i.isBefore=function(t,o){return this.endOf(o)<T(t)},i.$g=function(t,o,e){return m.u(t)?this[o]:this.set(e,t)},i.unix=function(){return Math.floor(this.valueOf()/1e3)},i.valueOf=function(){return this.$d.getTime()},i.startOf=function(t,o){var e=this,c=!!m.u(o)||o,h=m.p(t),g=function(q,L){var N=m.w(e.$u?Date.UTC(e.$y,L,q):new Date(e.$y,L,q),e);return c?N:N.endOf(S)},b=function(q,L){return m.w(e.toDate()[q].apply(e.toDate("s"),(c?[0,0,0,0]:[23,59,59,999]).slice(L)),e)},D=this.$W,C=this.$M,X=this.$D,k="set"+(this.$u?"UTC":"");switch(h){case W:return c?g(1,0):g(31,11);case x:return c?g(1,C):g(0,C+1);case F:var K=this.$locale().weekStart||0,tt=(D<K?D+7:D)-K;return g(c?X-tt:X+(6-tt),C);case S:case z:return b(k+"Hours",0);case M:return b(k+"Minutes",1);case Y:return b(k+"Seconds",2);case p:return b(k+"Milliseconds",3);default:return this.clone()}},i.endOf=function(t){return this.startOf(t,!1)},i.$set=function(t,o){var e,c=m.p(t),h="set"+(this.$u?"UTC":""),g=(e={},e[S]=h+"Date",e[z]=h+"Date",e[x]=h+"Month",e[W]=h+"FullYear",e[M]=h+"Hours",e[Y]=h+"Minutes",e[p]=h+"Seconds",e[v]=h+"Milliseconds",e)[c],b=c===S?this.$D+(o-this.$W):o;if(c===x||c===W){var D=this.clone().set(z,1);D.$d[g](b),D.init(),this.$d=D.set(z,Math.min(this.$D,D.daysInMonth())).$d}else g&&this.$d[g](b);return this.init(),this},i.set=function(t,o){return this.clone().$set(t,o)},i.get=function(t){return this[m.p(t)]()},i.add=function(t,o){var e,c=this;t=Number(t);var h=m.p(o),g=function(C){var X=T(c);return m.w(X.date(X.date()+Math.round(C*t)),c)};if(h===x)return this.set(x,this.$M+t);if(h===W)return this.set(W,this.$y+t);if(h===S)return g(1);if(h===F)return g(7);var b=(e={},e[Y]=s,e[M]=f,e[p]=r,e)[h]||1,D=this.$d.getTime()+t*b;return m.w(D,this)},i.subtract=function(t,o){return this.add(-1*t,o)},i.format=function(t){var o=this,e=this.$locale();if(!this.isValid())return e.invalidDate||ct;var c=t||"YYYY-MM-DDTHH:mm:ssZ",h=m.z(this),g=this.$H,b=this.$m,D=this.$M,C=e.weekdays,X=e.months,k=function(L,N,Mt,dt){return L&&(L[N]||L(o,c))||Mt[N].slice(0,dt)},K=function(L){return m.s(g%12||12,L,"0")},tt=e.meridiem||function(L,N,Mt){var dt=L<12?"AM":"PM";return Mt?dt.toLowerCase():dt},q={YY:String(this.$y).slice(-2),YYYY:m.s(this.$y,4,"0"),M:D+1,MM:m.s(D+1,2,"0"),MMM:k(e.monthsShort,D,X,3),MMMM:k(X,D),D:this.$D,DD:m.s(this.$D,2,"0"),d:String(this.$W),dd:k(e.weekdaysMin,this.$W,C,2),ddd:k(e.weekdaysShort,this.$W,C,3),dddd:C[this.$W],H:String(g),HH:m.s(g,2,"0"),h:K(1),hh:K(2),a:tt(g,b,!0),A:tt(g,b,!1),m:String(b),mm:m.s(b,2,"0"),s:String(this.$s),ss:m.s(this.$s,2,"0"),SSS:m.s(this.$ms,3,"0"),Z:h};return c.replace(ut,function(L,N){return N||q[L]||h.replace(":","")})},i.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},i.diff=function(t,o,e){var c,h=m.p(o),g=T(t),b=(g.utcOffset()-this.utcOffset())*s,D=this-g,C=m.m(this,g);return C=(c={},c[W]=C/12,c[x]=C,c[O]=C/3,c[F]=(D-b)/6048e5,c[S]=(D-b)/864e5,c[M]=D/f,c[Y]=D/s,c[p]=D/r,c)[h]||D,e?C:m.a(C)},i.daysInMonth=function(){return this.endOf(x).$D},i.$locale=function(){return B[this.$L]},i.locale=function(t,o){if(!t)return this.$L;var e=this.clone(),c=ft(t,o,!0);return c&&(e.$L=c),e},i.clone=function(){return m.w(this.$d,this)},i.toDate=function(){return new Date(this.valueOf())},i.toJSON=function(){return this.isValid()?this.toISOString():null},i.toISOString=function(){return this.$d.toISOString()},i.toString=function(){return this.$d.toUTCString()},a}(),yt=lt.prototype;return T.prototype=yt,[["$ms",v],["$s",p],["$m",Y],["$H",M],["$W",S],["$M",x],["$y",W],["$D",z]].forEach(function(a){yt[a[1]]=function(i){return this.$g(i,a[0],a[1])}}),T.extend=function(a,i){return a.$i||(a(i,lt,T),a.$i=!0),T},T.locale=ft,T.isDayjs=pt,T.unix=function(a){return T(1e3*a)},T.en=B[j],T.Ls=B,T.p={},T})})(V);var Ot=V.exports;const Lt=y(Ot),gt=(l,n="MM/DD HH:mm")=>Lt(l).format(n),wt=(l,n)=>{let r,s=0;return(...f)=>{const v=Date.now(),p=v-s;!s||p>=n?(s=v,l.apply(void 0,f)):r||(r=setTimeout(()=>{s=v,l.apply(void 0,f),r=null},n-p))}},_t=(l,n)=>{const r=document.createElement("canvas");r.width=r.height=1;const s=r.getContext("2d");s.fillStyle=l,s.fillRect(0,0,1,1);const f=s.getImageData(0,0,1,1).data;return`rgba(${f[0]}, ${f[1]}, ${f[2]}, ${n})`},Et=({xCenterPoint:l,cfg:n,timePerPixel:r,timeSpacing:s,currentTime:f,$canvas:v,screenScaleCount:p,scaleHeight:Y,startTime:M,drawLine:S,drawText:F,drawArea:x})=>{const O=({space:W,scaleFormat:z,bgFormat:ct,currentFormat:$t})=>{F({x:v.width-l/10,y:6,text:gt(f,ct),fontSize:`${v.height-5}px`,align:"right",baseLine:"top",color:n.bgTextColor});const ut=M%s,vt=ut/r;for(let I=0;I<p;I++){const Q=I*n.scaleSpacing-vt-n.pointWidth/2,j=M+I*s-ut;if(j%(s*W)===0){S({x:Q,y:Y.long}),F({x:Q,y:v.height-Y.long-5,text:gt(j,z),baseLine:"bottom"});continue}S({x:Q,y:Y.short})}S({x:l-n.pointWidth/2,y:v.height,width:n.pointWidth,color:n.pointColor}),x({startX:l-50,startY:4,endX:l+50,endY:18,bgColor:n.pointColor}),F({x:l,y:6,text:gt(f,$t),align:"center",baseLine:"top"})};s<100?O({space:10,scaleFormat:"mm:ss:SSS",bgFormat:"YYYY/MM/DD",currentFormat:"HH:mm:ss:SSS"}):s<1e3?O({space:10,scaleFormat:"mm:ss",bgFormat:"YYYY/MM/DD",currentFormat:"HH:mm:ss:SSS"}):s<1e4?O({space:10,scaleFormat:"mm:ss",bgFormat:"YYYY/MM/DD",currentFormat:"HH:mm:ss"}):s<6e4?O({space:12,scaleFormat:"HH:mm:ss",bgFormat:"YYYY/MM/DD",currentFormat:"HH:mm:ss"}):s<6e5?O({space:10,scaleFormat:"HH:mm:ss",bgFormat:"YYYY/MM/DD",currentFormat:"HH:mm:ss"}):s<36e5?O({space:12,scaleFormat:"MM/DD HH:mm",bgFormat:"YYYY/MM",currentFormat:"MM/DD HH:mm:ss"}):s<864e5?O({space:12,scaleFormat:"MM/DD HH:mm",bgFormat:"YYYY/MM",currentFormat:"YYYY/MM/DD HH:mm"}):s<6048e5?O({space:10,scaleFormat:"YYYY/MM/DD",bgFormat:"YYYY",currentFormat:"YYYY/MM/DD"}):O({space:10,scaleFormat:"YYYY/MM/DD",bgFormat:"YYYY",currentFormat:"YYYY/MM/DD"})},At={fill:!0,width:1e3,height:60,bgColor:"rgba(0,0,0,0.5)",areaBgColor:"#ffffff55",textColor:"#ffffff",scaleColor:"#ffffff",pointColor:"#00aeec",pointWidth:3,scaleSpacing:7,fps:60,zoom:3,timeSpacingList:[10,100,1e3,1e4,6e4,6e5,36e5,864e5,6048e5]};class Wt{constructor(n,r){H(this,it);H(this,st);H(this,nt);H(this,rt);H(this,at);H(this,ot);H(this,G);H(this,R);H(this,ht);et(this,"$canvas");et(this,"ctx");et(this,"$canvasParent");et(this,"cfg");H(this,J,$());H(this,_,0);H(this,P,void 0);H(this,w,void 0);H(this,U,void 0);H(this,Z,!1);if(!n)throw new Error("canvas Element Or Element ID is required!");typeof n=="string"?this.$canvas=document.querySelector(n):this.$canvas=n,this.ctx=this.$canvas.getContext("2d"),this.cfg={...At,...r};const{fill:s,width:f,height:v,zoom:p,timeSpacingList:Y,scaleHeight:M,textColor:S,bgTextColor:F}=this.cfg;if(F||(this.cfg.bgTextColor=_t(S,.18)),p<0||p>=Y.length||p%1!==0)throw new Error(`zoom must be 0 ~ ${Y.length-1}, and must be an integer`);if(s){const x=this.$canvas.parentElement;this.$canvasParent=x,this.$canvas.width=x.clientWidth,this.$canvas.height=x.clientHeight,new ResizeObserver(wt(E(this,nt,St).bind(this),200)).observe(x)}else f&&(this.$canvas.width=f),v&&(this.$canvas.height=v);A(this,w,Y[p]),M!=null&&M.long&&(M!=null&&M.short)?A(this,U,M):A(this,U,{long:this.$canvas.height/3,medium:this.$canvas.height/6,short:this.$canvas.height/10}),this.draw(),this.$canvas.addEventListener("wheel",E(this,st,bt).bind(this),{passive:!1}),this.$canvas.addEventListener("mousedown",E(this,it,xt).bind(this))}draw({currentTime:n,areas:r,_privateFlag:s}={}){if(u(this,Z)&&!s)return;A(this,_,n||Date.now()),A(this,P,r||[]);const f=Math.ceil(this.$canvas.width/this.cfg.scaleSpacing),v=f*u(this,w),p=u(this,_)-v/2,Y=u(this,_)+v/2,M=this.$canvas.width/2,S=v/this.$canvas.width;E(this,rt,Tt).call(this),E(this,R,mt).call(this,{startX:0,startY:0,endX:this.$canvas.width,endY:this.$canvas.height,bgColor:this.cfg.bgColor}),u(this,P).forEach(F=>{const x=F.startTime<p?0:Math.floor((F.startTime-p)/S),O=F.endTime>Y?this.$canvas.width:Math.floor((F.endTime-p)/S);E(this,R,mt).call(this,{startX:x,startY:0,endX:O,endY:this.$canvas.height,bgColor:F.bgColor||this.cfg.areaBgColor})}),Et.bind(this)({xCenterPoint:M,screenScaleCount:f,startTime:p,timePerPixel:S,scaleHeight:u(this,U),timeSpacing:u(this,w),currentTime:u(this,_),$canvas:this.$canvas,cfg:this.cfg,drawLine:E(this,ot,Ct).bind(this),drawText:E(this,G,Dt).bind(this),drawArea:E(this,R,mt).bind(this)}),E(this,at,Ft).call(this)}getCurrentTime(){return u(this,_)}on(n,r){u(this,J).on(n,r)}off(n,r){u(this,J).off(n,r)}}return J=new WeakMap,_=new WeakMap,P=new WeakMap,w=new WeakMap,U=new WeakMap,Z=new WeakMap,it=new WeakSet,xt=function(n){A(this,Z,!0);let r=0,s=u(this,_);const f=wt(({offsetX:Y})=>{if(!u(this,Z))return;const M=Y-n.offsetX;s=Math.round(u(this,_)-u(this,w)/this.cfg.scaleSpacing*(M-r)),r=M,this.draw({currentTime:s,areas:u(this,P),_privateFlag:!0})},1e3/this.cfg.fps),v=({offsetX:Y,offsetY:M})=>{(Y<3||Y>this.$canvas.width-3||M<3||M>this.$canvas.height-3)&&(this.$canvas.removeEventListener("mousemove",f),this.$canvas.removeEventListener("mousemove",v))},p=()=>{this.$canvas.removeEventListener("mousemove",f),this.$canvas.removeEventListener("mousemove",v),document.removeEventListener("mouseup",p),A(this,Z,!1),E(this,ht,Ht).call(this,"dragged",s)};this.$canvas.addEventListener("mousemove",f),this.$canvas.addEventListener("mousemove",v),document.addEventListener("mouseup",p)},st=new WeakSet,bt=function(n){n.preventDefault();const r=this.cfg.timeSpacingList.findIndex(s=>s===u(this,w));n.deltaY<0&&r>0?(A(this,w,this.cfg.timeSpacingList[r-1]),this.draw({currentTime:u(this,_),areas:u(this,P),_privateFlag:!0})):n.deltaY>0&&r<this.cfg.timeSpacingList.length-1&&(A(this,w,this.cfg.timeSpacingList[r+1]),this.draw({currentTime:u(this,_),areas:u(this,P),_privateFlag:!0}))},nt=new WeakSet,St=function(){this.$canvasParent&&(this.$canvas.width=this.$canvasParent.clientWidth,this.$canvas.height=this.$canvasParent.clientHeight,this.cfg.scaleHeight||A(this,U,{long:this.$canvas.height/3,medium:this.$canvas.height/6,short:this.$canvas.height/10}),this.draw({currentTime:u(this,_),areas:u(this,P)}))},rt=new WeakSet,Tt=function(){this.ctx.clearRect(0,0,this.$canvas.width,this.$canvas.height)},at=new WeakSet,Ft=function(){const n=()=>u(this,w)<1e3?`${u(this,w)}ms`:u(this,w)<6e4?`${Math.round(u(this,w)/100)/10}sec`:u(this,w)<36e5?`${Math.round(u(this,w)/100/60)/10}min`:u(this,w)<864e5?`${Math.round(u(this,w)/100/60/60)/10}hours`:u(this,w)<6048e5?`${Math.round(u(this,w)/100/60/60/24)/10}days`:`${Math.round(u(this,w)/100/60/60/24/7)/10}weeks`;E(this,G,Dt).call(this,{x:this.cfg.scaleSpacing+12,y:9,text:n(),align:"left",baseLine:"middle"}),this.ctx.beginPath(),this.ctx.moveTo(5,6),this.ctx.lineTo(5,10),this.ctx.lineTo(this.cfg.scaleSpacing+6,10),this.ctx.lineTo(this.cfg.scaleSpacing+6,6),this.ctx.strokeStyle=this.cfg.scaleColor,this.ctx.lineWidth=1.5,this.ctx.stroke()},ot=new WeakSet,Ct=function({x:n,y:r,width:s=1,color:f=this.cfg.scaleColor}){this.ctx.beginPath(),this.ctx.moveTo(n,this.$canvas.height),this.ctx.lineTo(n,this.$canvas.height-r),this.ctx.closePath(),this.ctx.strokeStyle=f,this.ctx.lineWidth=s,this.ctx.stroke()},G=new WeakSet,Dt=function({x:n,y:r,text:s,color:f=this.cfg.textColor,fontSize:v="11px",align:p="center",baseLine:Y="alphabetic"}){this.ctx.beginPath(),this.ctx.font=`${v} Arial`,this.ctx.fillStyle=f,this.ctx.textAlign=p,this.ctx.textBaseline=Y,this.ctx.fillText(s,n,r)},R=new WeakSet,mt=function({startX:n,startY:r,endX:s,endY:f,bgColor:v}){this.ctx.beginPath(),this.ctx.rect(n,r,s-n,f-r),this.ctx.fillStyle=v,this.ctx.fill()},ht=new WeakSet,Ht=function(...n){u(this,J).emit(...n)},Wt}); | ||
(function($,d){typeof exports=="object"&&typeof module<"u"?module.exports=d():typeof define=="function"&&define.amd?define(d):($=typeof globalThis<"u"?globalThis:$||self,$.$timeline=d())})(this,function(){var J,_,P,w,U,Z,it,xt,st,bt,nt,St,rt,Tt,at,Ft,ot,Ct,G,Dt,R,mt,ht,Ht;"use strict";var Pt=Object.defineProperty;var kt=($,d,x)=>d in $?Pt($,d,{enumerable:!0,configurable:!0,writable:!0,value:x}):$[d]=x;var et=($,d,x)=>(kt($,typeof d!="symbol"?d+"":d,x),x),Yt=($,d,x)=>{if(!d.has($))throw TypeError("Cannot "+x)};var u=($,d,x)=>(Yt($,d,"read from private field"),x?x.call($):d.get($)),O=($,d,x)=>{if(d.has($))throw TypeError("Cannot add the same private member more than once");d instanceof WeakSet?d.add($):d.set($,x)},A=($,d,x,V)=>(Yt($,d,"write to private field"),V?V.call($,x):d.set($,x),x);var E=($,d,x)=>(Yt($,d,"access private method"),x);function $(l){return{all:l=l||new Map,on:function(n,r){var s=l.get(n);s?s.push(r):l.set(n,[r])},off:function(n,r){var s=l.get(n);s&&(r?s.splice(s.indexOf(r)>>>0,1):l.set(n,[]))},emit:function(n,r){var s=l.get(n);s&&s.slice().map(function(f){f(r)}),(s=l.get("*"))&&s.slice().map(function(f){f(n,r)})}}}var d=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function x(l){return l&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l}var V={exports:{}};(function(l,n){(function(r,s){l.exports=s()})(d,function(){var r=1e3,s=6e4,f=36e5,v="millisecond",p="second",Y="minute",M="hour",S="day",F="week",y="month",C="quarter",W="year",z="date",ct="Invalid Date",$t=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,ut=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,vt={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(a){var i=["th","st","nd","rd"],t=a%100;return"["+a+(i[(t-20)%10]||i[t]||i[0])+"]"}},I=function(a,i,t){var o=String(a);return!o||o.length>=i?a:""+Array(i+1-o.length).join(t)+a},Q={s:I,z:function(a){var i=-a.utcOffset(),t=Math.abs(i),o=Math.floor(t/60),e=t%60;return(i<=0?"+":"-")+I(o,2,"0")+":"+I(e,2,"0")},m:function a(i,t){if(i.date()<t.date())return-a(t,i);var o=12*(t.year()-i.year())+(t.month()-i.month()),e=i.clone().add(o,y),c=t-e<0,h=i.clone().add(o+(c?-1:1),y);return+(-(o+(t-e)/(c?e-h:h-e))||0)},a:function(a){return a<0?Math.ceil(a)||0:Math.floor(a)},p:function(a){return{M:y,y:W,w:F,d:S,D:z,h:M,m:Y,s:p,ms:v,Q:C}[a]||String(a||"").toLowerCase().replace(/s$/,"")},u:function(a){return a===void 0}},j="en",B={};B[j]=vt;var pt=function(a){return a instanceof lt},ft=function a(i,t,o){var e;if(!i)return j;if(typeof i=="string"){var c=i.toLowerCase();B[c]&&(e=c),t&&(B[c]=t,e=c);var h=i.split("-");if(!e&&h.length>1)return a(h[0])}else{var g=i.name;B[g]=i,e=g}return!o&&e&&(j=e),e||!o&&j},T=function(a,i){if(pt(a))return a.clone();var t=typeof i=="object"?i:{};return t.date=a,t.args=arguments,new lt(t)},m=Q;m.l=ft,m.i=pt,m.w=function(a,i){return T(a,{locale:i.$L,utc:i.$u,x:i.$x,$offset:i.$offset})};var lt=function(){function a(t){this.$L=ft(t.locale,null,!0),this.parse(t)}var i=a.prototype;return i.parse=function(t){this.$d=function(o){var e=o.date,c=o.utc;if(e===null)return new Date(NaN);if(m.u(e))return new Date;if(e instanceof Date)return new Date(e);if(typeof e=="string"&&!/Z$/i.test(e)){var h=e.match($t);if(h){var g=h[2]-1||0,b=(h[7]||"0").substring(0,3);return c?new Date(Date.UTC(h[1],g,h[3]||1,h[4]||0,h[5]||0,h[6]||0,b)):new Date(h[1],g,h[3]||1,h[4]||0,h[5]||0,h[6]||0,b)}}return new Date(e)}(t),this.$x=t.x||{},this.init()},i.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},i.$utils=function(){return m},i.isValid=function(){return this.$d.toString()!==ct},i.isSame=function(t,o){var e=T(t);return this.startOf(o)<=e&&e<=this.endOf(o)},i.isAfter=function(t,o){return T(t)<this.startOf(o)},i.isBefore=function(t,o){return this.endOf(o)<T(t)},i.$g=function(t,o,e){return m.u(t)?this[o]:this.set(e,t)},i.unix=function(){return Math.floor(this.valueOf()/1e3)},i.valueOf=function(){return this.$d.getTime()},i.startOf=function(t,o){var e=this,c=!!m.u(o)||o,h=m.p(t),g=function(q,L){var N=m.w(e.$u?Date.UTC(e.$y,L,q):new Date(e.$y,L,q),e);return c?N:N.endOf(S)},b=function(q,L){return m.w(e.toDate()[q].apply(e.toDate("s"),(c?[0,0,0,0]:[23,59,59,999]).slice(L)),e)},D=this.$W,H=this.$M,X=this.$D,k="set"+(this.$u?"UTC":"");switch(h){case W:return c?g(1,0):g(31,11);case y:return c?g(1,H):g(0,H+1);case F:var K=this.$locale().weekStart||0,tt=(D<K?D+7:D)-K;return g(c?X-tt:X+(6-tt),H);case S:case z:return b(k+"Hours",0);case M:return b(k+"Minutes",1);case Y:return b(k+"Seconds",2);case p:return b(k+"Milliseconds",3);default:return this.clone()}},i.endOf=function(t){return this.startOf(t,!1)},i.$set=function(t,o){var e,c=m.p(t),h="set"+(this.$u?"UTC":""),g=(e={},e[S]=h+"Date",e[z]=h+"Date",e[y]=h+"Month",e[W]=h+"FullYear",e[M]=h+"Hours",e[Y]=h+"Minutes",e[p]=h+"Seconds",e[v]=h+"Milliseconds",e)[c],b=c===S?this.$D+(o-this.$W):o;if(c===y||c===W){var D=this.clone().set(z,1);D.$d[g](b),D.init(),this.$d=D.set(z,Math.min(this.$D,D.daysInMonth())).$d}else g&&this.$d[g](b);return this.init(),this},i.set=function(t,o){return this.clone().$set(t,o)},i.get=function(t){return this[m.p(t)]()},i.add=function(t,o){var e,c=this;t=Number(t);var h=m.p(o),g=function(H){var X=T(c);return m.w(X.date(X.date()+Math.round(H*t)),c)};if(h===y)return this.set(y,this.$M+t);if(h===W)return this.set(W,this.$y+t);if(h===S)return g(1);if(h===F)return g(7);var b=(e={},e[Y]=s,e[M]=f,e[p]=r,e)[h]||1,D=this.$d.getTime()+t*b;return m.w(D,this)},i.subtract=function(t,o){return this.add(-1*t,o)},i.format=function(t){var o=this,e=this.$locale();if(!this.isValid())return e.invalidDate||ct;var c=t||"YYYY-MM-DDTHH:mm:ssZ",h=m.z(this),g=this.$H,b=this.$m,D=this.$M,H=e.weekdays,X=e.months,k=function(L,N,Mt,dt){return L&&(L[N]||L(o,c))||Mt[N].slice(0,dt)},K=function(L){return m.s(g%12||12,L,"0")},tt=e.meridiem||function(L,N,Mt){var dt=L<12?"AM":"PM";return Mt?dt.toLowerCase():dt},q={YY:String(this.$y).slice(-2),YYYY:m.s(this.$y,4,"0"),M:D+1,MM:m.s(D+1,2,"0"),MMM:k(e.monthsShort,D,X,3),MMMM:k(X,D),D:this.$D,DD:m.s(this.$D,2,"0"),d:String(this.$W),dd:k(e.weekdaysMin,this.$W,H,2),ddd:k(e.weekdaysShort,this.$W,H,3),dddd:H[this.$W],H:String(g),HH:m.s(g,2,"0"),h:K(1),hh:K(2),a:tt(g,b,!0),A:tt(g,b,!1),m:String(b),mm:m.s(b,2,"0"),s:String(this.$s),ss:m.s(this.$s,2,"0"),SSS:m.s(this.$ms,3,"0"),Z:h};return c.replace(ut,function(L,N){return N||q[L]||h.replace(":","")})},i.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},i.diff=function(t,o,e){var c,h=m.p(o),g=T(t),b=(g.utcOffset()-this.utcOffset())*s,D=this-g,H=m.m(this,g);return H=(c={},c[W]=H/12,c[y]=H,c[C]=H/3,c[F]=(D-b)/6048e5,c[S]=(D-b)/864e5,c[M]=D/f,c[Y]=D/s,c[p]=D/r,c)[h]||D,e?H:m.a(H)},i.daysInMonth=function(){return this.endOf(y).$D},i.$locale=function(){return B[this.$L]},i.locale=function(t,o){if(!t)return this.$L;var e=this.clone(),c=ft(t,o,!0);return c&&(e.$L=c),e},i.clone=function(){return m.w(this.$d,this)},i.toDate=function(){return new Date(this.valueOf())},i.toJSON=function(){return this.isValid()?this.toISOString():null},i.toISOString=function(){return this.$d.toISOString()},i.toString=function(){return this.$d.toUTCString()},a}(),yt=lt.prototype;return T.prototype=yt,[["$ms",v],["$s",p],["$m",Y],["$H",M],["$W",S],["$M",y],["$y",W],["$D",z]].forEach(function(a){yt[a[1]]=function(i){return this.$g(i,a[0],a[1])}}),T.extend=function(a,i){return a.$i||(a(i,lt,T),a.$i=!0),T},T.locale=ft,T.isDayjs=pt,T.unix=function(a){return T(1e3*a)},T.en=B[j],T.Ls=B,T.p={},T})})(V);var Ot=V.exports;const Lt=x(Ot),gt=(l,n="MM/DD HH:mm")=>Lt(l).format(n),wt=(l,n)=>{let r,s=0;return(...f)=>{const v=Date.now(),p=v-s;!s||p>=n?(s=v,l.apply(void 0,f)):r||(r=setTimeout(()=>{s=v,l.apply(void 0,f),r=null},n-p))}},_t=(l,n)=>{const r=document.createElement("canvas");r.width=r.height=1;const s=r.getContext("2d");s.fillStyle=l,s.fillRect(0,0,1,1);const f=s.getImageData(0,0,1,1).data;return`rgba(${f[0]}, ${f[1]}, ${f[2]}, ${n})`},Et=({xCenterPoint:l,cfg:n,timePerPixel:r,timeSpacing:s,currentTime:f,$canvas:v,screenScaleCount:p,scaleHeight:Y,startTime:M,drawLine:S,drawText:F,drawArea:y})=>{const C=({space:W,scaleFormat:z,bgFormat:ct,currentFormat:$t})=>{F({x:v.width-l/10,y:6,text:gt(f,ct),fontSize:`${v.height-5}px`,align:"right",baseLine:"top",color:n.bgTextColor});const ut=M%s,vt=ut/r;for(let I=0;I<p;I++){const Q=I*n.scaleSpacing-vt-n.pointWidth/2,j=M+I*s-ut;if(j%(s*W)===0){S({x:Q,y:Y.long}),F({x:Q,y:v.height-Y.long-5,text:gt(j,z),baseLine:"bottom"});continue}S({x:Q,y:Y.short})}S({x:l-n.pointWidth/2,y:v.height,width:n.pointWidth,color:n.pointColor}),y({startX:l-50,startY:4,endX:l+50,endY:18,bgColor:n.pointColor}),F({x:l,y:6,text:gt(f,$t),align:"center",baseLine:"top"})};s<100?C({space:10,scaleFormat:"mm:ss:SSS",bgFormat:"YYYY/MM/DD",currentFormat:"HH:mm:ss:SSS"}):s<1e3?C({space:10,scaleFormat:"mm:ss",bgFormat:"YYYY/MM/DD",currentFormat:"HH:mm:ss:SSS"}):s<1e4?C({space:10,scaleFormat:"mm:ss",bgFormat:"YYYY/MM/DD",currentFormat:"HH:mm:ss"}):s<6e4?C({space:12,scaleFormat:"HH:mm:ss",bgFormat:"YYYY/MM/DD",currentFormat:"HH:mm:ss"}):s<6e5?C({space:10,scaleFormat:"HH:mm:ss",bgFormat:"YYYY/MM/DD",currentFormat:"HH:mm:ss"}):s<36e5?C({space:12,scaleFormat:"MM/DD HH:mm",bgFormat:"YYYY/MM",currentFormat:"MM/DD HH:mm:ss"}):s<864e5?C({space:12,scaleFormat:"MM/DD HH:mm",bgFormat:"YYYY/MM",currentFormat:"YYYY/MM/DD HH:mm"}):s<6048e5?C({space:10,scaleFormat:"YYYY/MM/DD",bgFormat:"YYYY",currentFormat:"YYYY/MM/DD"}):C({space:10,scaleFormat:"YYYY/MM/DD",bgFormat:"YYYY",currentFormat:"YYYY/MM/DD"})},At={fill:!0,width:1e3,height:60,bgColor:"rgba(0,0,0,0.5)",areaBgColor:"#ffffff55",textColor:"#ffffff",scaleColor:"#ffffff",pointColor:"#00aeec",pointWidth:3,scaleSpacing:7,fps:60,zoom:3,timeSpacingList:[10,100,1e3,1e4,6e4,6e5,36e5,864e5,6048e5]};class Wt{constructor(n,r){O(this,it);O(this,st);O(this,nt);O(this,rt);O(this,at);O(this,ot);O(this,G);O(this,R);O(this,ht);et(this,"$canvas");et(this,"ctx");et(this,"$canvasParent");et(this,"cfg");O(this,J,$());O(this,_,0);O(this,P,void 0);O(this,w,void 0);O(this,U,void 0);O(this,Z,!1);if(!n)throw new Error("canvas Element Or Element ID is required!");typeof n=="string"?this.$canvas=document.querySelector(n):this.$canvas=n,this.ctx=this.$canvas.getContext("2d"),this.cfg={...At,...r};const{fill:s,width:f,height:v,zoom:p,timeSpacingList:Y,scaleHeight:M,textColor:S,bgTextColor:F}=this.cfg;if(F||(this.cfg.bgTextColor=_t(S,.18)),p<0||p>=Y.length||p%1!==0)throw new Error(`zoom must be 0 ~ ${Y.length-1}, and must be an integer`);if(s){const y=this.$canvas.parentElement;this.$canvasParent=y,this.$canvas.width=y.clientWidth,this.$canvas.height=y.clientHeight,new ResizeObserver(wt(E(this,nt,St).bind(this),200)).observe(y)}else f&&(this.$canvas.width=f),v&&(this.$canvas.height=v);A(this,w,Y[p]),M!=null&&M.long&&(M!=null&&M.short)?A(this,U,M):A(this,U,{long:this.$canvas.height/3,medium:this.$canvas.height/6,short:this.$canvas.height/10}),this.draw(),this.$canvas.addEventListener("wheel",E(this,st,bt).bind(this),{passive:!1}),this.$canvas.addEventListener("mousedown",E(this,it,xt).bind(this))}draw({currentTime:n,areas:r,_privateFlag:s}={}){if(u(this,Z)&&!s)return;A(this,_,n||Date.now()),A(this,P,r||[]);const f=Math.ceil(this.$canvas.width/this.cfg.scaleSpacing),v=f*u(this,w),p=u(this,_)-v/2,Y=u(this,_)+v/2,M=this.$canvas.width/2,S=v/this.$canvas.width;E(this,rt,Tt).call(this),E(this,R,mt).call(this,{startX:0,startY:0,endX:this.$canvas.width,endY:this.$canvas.height,bgColor:this.cfg.bgColor}),u(this,P).forEach(F=>{const y=F.startTime<=p?0:Math.round((F.startTime-p)/S),C=F.endTime>=Y?this.$canvas.width:Math.round((F.endTime-p)/S);y<this.$canvas.width&&C>0&&E(this,R,mt).call(this,{startX:y,startY:0,endX:C,endY:this.$canvas.height,bgColor:F.bgColor||this.cfg.areaBgColor})}),Et.bind(this)({xCenterPoint:M,screenScaleCount:f,startTime:p,timePerPixel:S,scaleHeight:u(this,U),timeSpacing:u(this,w),currentTime:u(this,_),$canvas:this.$canvas,cfg:this.cfg,drawLine:E(this,ot,Ct).bind(this),drawText:E(this,G,Dt).bind(this),drawArea:E(this,R,mt).bind(this)}),E(this,at,Ft).call(this)}getCurrentTime(){return u(this,_)}on(n,r){u(this,J).on(n,r)}off(n,r){u(this,J).off(n,r)}}return J=new WeakMap,_=new WeakMap,P=new WeakMap,w=new WeakMap,U=new WeakMap,Z=new WeakMap,it=new WeakSet,xt=function(n){A(this,Z,!0);let r=0,s=u(this,_);const f=wt(({offsetX:Y})=>{if(!u(this,Z))return;const M=Y-n.offsetX;s=Math.round(u(this,_)-u(this,w)/this.cfg.scaleSpacing*(M-r)),r=M,this.draw({currentTime:s,areas:u(this,P),_privateFlag:!0})},1e3/this.cfg.fps),v=({offsetX:Y,offsetY:M})=>{(Y<3||Y>this.$canvas.width-3||M<3||M>this.$canvas.height-3)&&(this.$canvas.removeEventListener("mousemove",f),this.$canvas.removeEventListener("mousemove",v))},p=()=>{this.$canvas.removeEventListener("mousemove",f),this.$canvas.removeEventListener("mousemove",v),document.removeEventListener("mouseup",p),A(this,Z,!1),E(this,ht,Ht).call(this,"dragged",s)};this.$canvas.addEventListener("mousemove",f),this.$canvas.addEventListener("mousemove",v),document.addEventListener("mouseup",p)},st=new WeakSet,bt=function(n){n.preventDefault();const r=this.cfg.timeSpacingList.findIndex(s=>s===u(this,w));n.deltaY<0&&r>0?(A(this,w,this.cfg.timeSpacingList[r-1]),this.draw({currentTime:u(this,_),areas:u(this,P),_privateFlag:!0})):n.deltaY>0&&r<this.cfg.timeSpacingList.length-1&&(A(this,w,this.cfg.timeSpacingList[r+1]),this.draw({currentTime:u(this,_),areas:u(this,P),_privateFlag:!0}))},nt=new WeakSet,St=function(){this.$canvasParent&&(this.$canvas.width=this.$canvasParent.clientWidth,this.$canvas.height=this.$canvasParent.clientHeight,this.cfg.scaleHeight||A(this,U,{long:this.$canvas.height/3,medium:this.$canvas.height/6,short:this.$canvas.height/10}),this.draw({currentTime:u(this,_),areas:u(this,P)}))},rt=new WeakSet,Tt=function(){this.ctx.clearRect(0,0,this.$canvas.width,this.$canvas.height)},at=new WeakSet,Ft=function(){const n=()=>u(this,w)<1e3?`${u(this,w)}ms`:u(this,w)<6e4?`${Math.round(u(this,w)/100)/10}sec`:u(this,w)<36e5?`${Math.round(u(this,w)/100/60)/10}min`:u(this,w)<864e5?`${Math.round(u(this,w)/100/60/60)/10}hours`:u(this,w)<6048e5?`${Math.round(u(this,w)/100/60/60/24)/10}days`:`${Math.round(u(this,w)/100/60/60/24/7)/10}weeks`;E(this,G,Dt).call(this,{x:this.cfg.scaleSpacing+12,y:9,text:n(),align:"left",baseLine:"middle"}),this.ctx.beginPath(),this.ctx.moveTo(5,6),this.ctx.lineTo(5,10),this.ctx.lineTo(this.cfg.scaleSpacing+6,10),this.ctx.lineTo(this.cfg.scaleSpacing+6,6),this.ctx.strokeStyle=this.cfg.scaleColor,this.ctx.lineWidth=1.5,this.ctx.stroke()},ot=new WeakSet,Ct=function({x:n,y:r,width:s=1,color:f=this.cfg.scaleColor}){this.ctx.beginPath(),this.ctx.moveTo(n,this.$canvas.height),this.ctx.lineTo(n,this.$canvas.height-r),this.ctx.closePath(),this.ctx.strokeStyle=f,this.ctx.lineWidth=s,this.ctx.stroke()},G=new WeakSet,Dt=function({x:n,y:r,text:s,color:f=this.cfg.textColor,fontSize:v="11px",align:p="center",baseLine:Y="alphabetic"}){this.ctx.beginPath(),this.ctx.font=`${v} Arial`,this.ctx.fillStyle=f,this.ctx.textAlign=p,this.ctx.textBaseline=Y,this.ctx.fillText(s,n,r)},R=new WeakSet,mt=function({startX:n,startY:r,endX:s,endY:f,bgColor:v}){this.ctx.beginPath(),this.ctx.rect(n,r,s-n,f-r),this.ctx.fillStyle=v,this.ctx.fill()},ht=new WeakSet,Ht=function(...n){u(this,J).emit(...n)},Wt}); |
{ | ||
"name": "@losting/timeline", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "Canvas timeline supports zooming, dragging, infinite scrolling, and custom control levels.", | ||
@@ -18,3 +18,3 @@ "type": "module", | ||
"dist", | ||
"types", | ||
"types/timeline.d.ts", | ||
"README.md", | ||
@@ -21,0 +21,0 @@ "example/demo.png", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
78162
9
708