dhtmlx-gantt
Version:
An open source JavaScript Gantt chart that helps you illustrate a project schedule in a nice-looking chart.
1,090 lines (1,084 loc) • 756 kB
JavaScript
/** @license
dhtmlxGantt v.9.1.1 Standard
This version of dhtmlxGantt is distributed under GPL 2.0 license and can be legally used in GPL projects.
To use dhtmlxGantt in non-GPL projects (and get Pro version of the product), please obtain Individual, Commercial, Enterprise or Ultimate license on our site https://dhtmlx.com/docs/products/dhtmlxGantt/#licensing or contact us at info@dhtmlx.com
(c) XB Software
*/
function Y(t) {
var n = 0, e = 0, i = 0, a = 0;
if (t.getBoundingClientRect) {
var s = t.getBoundingClientRect(), r = document.body, o = document.documentElement || document.body.parentNode || document.body, l = window.pageYOffset || o.scrollTop || r.scrollTop, d = window.pageXOffset || o.scrollLeft || r.scrollLeft, c = o.clientTop || r.clientTop || 0, u = o.clientLeft || r.clientLeft || 0;
n = s.top + l - c, e = s.left + d - u, i = document.body.offsetWidth - s.right, a = document.body.offsetHeight - s.bottom;
} else {
for (; t; ) n += parseInt(t.offsetTop, 10), e += parseInt(t.offsetLeft, 10), t = t.offsetParent;
i = document.body.offsetWidth - t.offsetWidth - e, a = document.body.offsetHeight - t.offsetHeight - n;
}
return { y: Math.round(n), x: Math.round(e), width: t.offsetWidth, height: t.offsetHeight, right: Math.round(i), bottom: Math.round(a) };
}
function Nn(t) {
var n = !1, e = !1;
if (window.getComputedStyle) {
var i = window.getComputedStyle(t, null);
n = i.display, e = i.visibility;
} else t.currentStyle && (n = t.currentStyle.display, e = t.currentStyle.visibility);
return n != "none" && e != "hidden";
}
function Ln(t) {
return !isNaN(t.getAttribute("tabindex")) && 1 * t.getAttribute("tabindex") >= 0;
}
function Rn(t) {
return !{ a: !0, area: !0 }[t.nodeName.loLowerCase()] || !!t.getAttribute("href");
}
function Pn(t) {
return !{ input: !0, select: !0, textarea: !0, button: !0, object: !0 }[t.nodeName.toLowerCase()] || !t.hasAttribute("disabled");
}
function Pt(t) {
for (var n = t.querySelectorAll(["a[href]", "area[href]", "input", "select", "textarea", "button", "iframe", "object", "embed", "[tabindex]", "[contenteditable]"].join(", ")), e = Array.prototype.slice.call(n, 0), i = 0; i < e.length; i++) e[i].$position = i;
for (e.sort(function(s, r) {
return s.tabIndex === 0 && r.tabIndex !== 0 ? 1 : s.tabIndex !== 0 && r.tabIndex === 0 ? -1 : s.tabIndex === r.tabIndex ? s.$position - r.$position : s.tabIndex < r.tabIndex ? -1 : 1;
}), i = 0; i < e.length; i++) {
var a = e[i];
(Ln(a) || Pn(a) || Rn(a)) && Nn(a) || (e.splice(i, 1), i--);
}
return e;
}
function tn() {
var t = document.createElement("div");
t.style.cssText = "visibility:hidden;position:absolute;left:-1000px;width:100px;padding:0px;margin:0px;height:110px;min-height:100px;overflow-y:scroll;", document.body.appendChild(t);
var n = t.offsetWidth - t.clientWidth;
return document.body.removeChild(t), Math.max(n, 15);
}
function Q(t) {
if (!t) return "";
var n = t.className || "";
return n.baseVal && (n = n.baseVal), n.indexOf || (n = ""), ke(n);
}
function Ct(t, n) {
n && t.className.indexOf(n) === -1 && (t.className += " " + n);
}
function Jt(t, n) {
n = n.split(" ");
for (var e = 0; e < n.length; e++) {
var i = new RegExp("\\s?\\b" + n[e] + "\\b(?![-_.])", "");
t.className = t.className.replace(i, "");
}
}
function De(t) {
return typeof t == "string" ? document.getElementById(t) || document.querySelector(t) || document.body : t || document.body;
}
var jt;
function en(t, n) {
jt || (jt = document.createElement("div")), jt.innerHTML = n;
var e = jt.firstChild;
return t.appendChild(e), e;
}
function nn(t) {
t && t.parentNode && t.parentNode.removeChild(t);
}
function an(t, n) {
for (var e = t.childNodes, i = e.length, a = [], s = 0; s < i; s++) {
var r = e[s];
r.className && r.className.indexOf(n) !== -1 && a.push(r);
}
return a;
}
function xt(t) {
var n;
return t.tagName ? n = t : (n = (t = t || window.event).target || t.srcElement).shadowRoot && t.composedPath && (n = t.composedPath()[0]), n;
}
function it(t, n) {
if (n) {
for (var e = xt(t); e; ) {
if (e.getAttribute && e.getAttribute(n)) return e;
e = e.parentNode || e.host;
}
return null;
}
}
function ke(t) {
return (String.prototype.trim || function() {
return this.replace(/^\s+|\s+$/g, "");
}).apply(t);
}
function vt(t, n, e) {
var i = xt(t), a = "";
for (e === void 0 && (e = !0); i; ) {
if (a = Q(i)) {
var s = a.indexOf(n);
if (s >= 0) {
if (!e) return i;
var r = s === 0 || !ke(a.charAt(s - 1)), o = s + n.length >= a.length || !ke(a.charAt(s + n.length));
if (r && o) return i;
}
}
i = i.parentNode;
}
return null;
}
function rt(t, n) {
var r;
const e = document.documentElement, i = Y(n), { clientX: a, clientY: s } = ((r = t.touches) == null ? void 0 : r[0]) ?? t;
return { x: a + e.scrollLeft - e.clientLeft - i.x + n.scrollLeft, y: s + e.scrollTop - e.clientTop - i.y + n.scrollTop };
}
function sn(t, n) {
const e = Y(t), i = Y(n);
return { x: e.x - i.x, y: e.y - i.y };
}
function K(t, n) {
if (!t || !n) return !1;
for (; t && t != n; ) t = t.parentNode;
return t === n;
}
function ht(t, n) {
if (t.closest) return t.closest(n);
if (t.matches || t.msMatchesSelector || t.webkitMatchesSelector) {
var e = t;
if (!document.documentElement.contains(e)) return null;
do {
if ((e.matches || e.msMatchesSelector || e.webkitMatchesSelector).call(e, n)) return e;
e = e.parentElement || e.parentNode;
} while (e !== null && e.nodeType === 1);
return null;
}
return console.error("Your browser is not supported"), null;
}
function rn(t) {
for (; t; ) {
if (t.offsetWidth > 0 && t.offsetHeight > 0) return t;
t = t.parentElement;
}
return null;
}
function on() {
return document.head.createShadowRoot || document.head.attachShadow;
}
function ye() {
var t = document.activeElement;
return t.shadowRoot && (t = t.shadowRoot.activeElement), t === document.body && document.getSelection && (t = document.getSelection().focusNode || document.body), t;
}
function yt(t) {
if (!t || !on()) return document.body;
for (; t.parentNode && (t = t.parentNode); ) if (t instanceof ShadowRoot) return t.host;
return document.body;
}
const ln = Object.freeze(Object.defineProperty({ __proto__: null, addClassName: Ct, closest: ht, getActiveElement: ye, getChildNodes: an, getClassName: Q, getClosestSizedElement: rn, getFocusableNodes: Pt, getNodePosition: Y, getRelativeEventPosition: rt, getRelativeNodePosition: sn, getRootNode: yt, getScrollSize: tn, getTargetNode: xt, hasClass: function(t, n) {
return "classList" in t ? t.classList.contains(n) : new RegExp("\\b" + n + "\\b").test(t.className);
}, hasShadowParent: function(t) {
return !!yt(t);
}, insertNode: en, isChildOf: K, isShadowDomSupported: on, locateAttribute: it, locateClassName: vt, removeClassName: Jt, removeNode: nn, toNode: De }, Symbol.toStringTag, { value: "Module" })), tt = typeof window < "u" ? window : global;
let Hn = class {
constructor(t) {
this._mouseDown = !1, this._touchStarts = !1, this._touchActive = !1, this._longTapTimer = !1, this._gantt = t, this._domEvents = t._createDomEventScope();
}
attach(t, n, e) {
const i = this._gantt, a = t.getViewPort();
this._originPosition = tt.getComputedStyle(a).display, this._restoreOriginPosition = () => {
a.style.position = this._originPosition;
}, this._originPosition === "static" && (a.style.position = "relative");
const s = i.$services.getService("state");
s.registerProvider("clickDrag", () => ({ autoscroll: !1 }));
let r = null;
const o = () => {
r && (this._mouseDown = !0, t.setStart(i.copy(r)), t.setPosition(i.copy(r)), t.setEnd(i.copy(r)), r = null);
};
this._domEvents.attach(a, "mousedown", (f) => {
u(f);
});
const l = yt(i.$root) || document.body;
function d(f) {
return f.changedTouches && f.changedTouches[0] || f;
}
this._domEvents.attach(l, "mouseup", (f) => {
h(f);
}), this._domEvents.attach(a, "mousemove", (f) => {
_(f);
}), this._domEvents.attach(a, "touchstart", (f) => {
this._touchStarts = !0, this._longTapTimer = setTimeout(() => {
this._touchStarts && (u(d(f)), this._touchStarts = !1, this._touchActive = !0);
}, this._gantt.config.touch_drag);
}), this._domEvents.attach(l, "touchend", (f) => {
this._touchStarts = !1, this._touchActive = !1, clearTimeout(this._longTapTimer), h(d(f));
}), this._domEvents.attach(a, "touchmove", (f) => {
if (this._touchActive) {
let y = c();
if (y && i.utils.dom.closest(f.target, y)) return;
_(d(f)), f.preventDefault();
} else this._touchStarts = !1, clearTimeout(this._longTapTimer);
});
const c = () => {
let f = ".gantt_task_line, .gantt_task_link";
return e !== void 0 && (f = e instanceof Array ? e.join(", ") : e), f;
}, u = (f) => {
r = null;
let y = c();
y && i.utils.dom.closest(f.target, y) || (s.registerProvider("clickDrag", () => ({ autoscroll: this._mouseDown })), n && f[n] !== !0 || (r = this._getCoordinates(f, t)));
}, h = (f) => {
if (r = null, (!n || f[n] === !0) && this._mouseDown === !0) {
this._mouseDown = !1;
const y = this._getCoordinates(f, t);
t.dragEnd(y);
}
}, _ = (f) => {
if (n && f[n] !== !0) return;
const y = this._gantt.ext.clickDrag, v = (this._gantt.config.drag_timeline || {}).useKey;
if (y && v && !n && f[v]) return;
let b = null;
if (!this._mouseDown && r) return b = this._getCoordinates(f, t), void (Math.abs(r.relative.left - b.relative.left) > 5 && o());
this._mouseDown === !0 && (b = this._getCoordinates(f, t), t.setEnd(b), t.render());
};
}
detach() {
const t = this._gantt;
this._domEvents.detachAll(), this._restoreOriginPosition && this._restoreOriginPosition(), t.$services.getService("state").unregisterProvider("clickDrag");
}
destructor() {
this.detach();
}
_getCoordinates(t, n) {
const e = n.getViewPort(), i = e.getBoundingClientRect(), { clientX: a, clientY: s } = t;
return { absolute: { left: a, top: s }, relative: { left: a - i.left + e.scrollLeft, top: s - i.top + e.scrollTop } };
}
};
var dn = function() {
this._silent_mode = !1, this.listeners = {};
};
dn.prototype = { _silentStart: function() {
this._silent_mode = !0;
}, _silentEnd: function() {
this._silent_mode = !1;
} };
function lt(t) {
var n = new dn();
t.attachEvent = function(e, i, a) {
e = "ev_" + e.toLowerCase(), n.listeners[e] || (n.listeners[e] = function(r) {
var o = {}, l = 0, d = function() {
var c = !0;
for (var u in o) {
var h = o[u].apply(r, arguments);
c = c && h;
}
return c;
};
return d.addEvent = function(c, u) {
if (typeof c == "function") {
var h;
if (u && u.id ? h = u.id : (h = l, l++), u && u.once) {
var _ = c;
c = function() {
_(), d.removeEvent(h);
};
}
return o[h] = c, h;
}
return !1;
}, d.removeEvent = function(c) {
delete o[c];
}, d.clear = function() {
o = {};
}, d;
}(this)), a && a.thisObject && (i = i.bind(a.thisObject));
var s = e + ":" + n.listeners[e].addEvent(i, a);
return a && a.id && (s = a.id), s;
}, t.attachAll = function(e) {
this.attachEvent("listen_all", e);
}, t.callEvent = function(e, i) {
if (n._silent_mode) return !0;
var a = "ev_" + e.toLowerCase(), s = n.listeners;
return s.ev_listen_all && s.ev_listen_all.apply(this, [e].concat(i)), !s[a] || s[a].apply(this, i);
}, t.checkEvent = function(e) {
return !!n.listeners["ev_" + e.toLowerCase()];
}, t.detachEvent = function(e) {
if (e) {
var i = n.listeners;
for (var a in i) i[a].removeEvent(e);
var s = e.split(":");
if (i = n.listeners, s.length === 2) {
var r = s[0], o = s[1];
i[r] && i[r].removeEvent(o);
}
}
}, t.detachAllEvents = function() {
for (var e in n.listeners) n.listeners[e].clear();
};
}
var Me = { second: 1, minute: 60, hour: 3600, day: 86400, week: 604800, month: 2592e3, quarter: 7776e3, year: 31536e3 };
function qt(t) {
return Me[t] || Me.hour;
}
function bt(t, n) {
if (t.forEach) t.forEach(n);
else for (var e = t.slice(), i = 0; i < e.length; i++) n(e[i], i);
}
function On(t, n) {
if (t.find) return t.find(n);
for (var e = 0; e < t.length; e++) if (n(t[e], e)) return t[e];
}
function Wt(t, n) {
if (t.includes) return t.includes(n);
for (var e = 0; e < t.length; e++) if (t[e] === n) return !0;
return !1;
}
function be(t) {
return Array.isArray ? Array.isArray(t) : t && t.length !== void 0 && t.pop && t.push;
}
function et(t) {
return !(!t || typeof t != "object") && !!(t.getFullYear && t.getMonth && t.getDate);
}
function $t(t) {
return et(t) && !isNaN(t.getTime());
}
function xe(t, n) {
var e, i = function() {
i.$cancelTimeout(), i.$pending = !0;
var a = Array.prototype.slice.call(arguments);
e = setTimeout(function() {
t.apply(this, a), i.$pending = !1;
}, n);
};
return i.$pending = !1, i.$cancelTimeout = function() {
clearTimeout(e), i.$pending = !1;
}, i.$execute = function() {
var a = Array.prototype.slice.call(arguments);
t.apply(this, a), i.$cancelTimeout();
}, i;
}
function st(t, n) {
return Ne(t) && !Ne(n) && (t = "0"), t;
}
function Ne(t) {
return t === 0;
}
function Tt(t, n) {
for (var e, i, a, s = 0, r = t.length - 1; s <= r; ) if (i = +t[e = Math.floor((s + r) / 2)], a = +t[e - 1], i < n) s = e + 1;
else {
if (!(i > n)) {
for (; +t[e] == +t[e + 1]; ) e++;
return e;
}
if (!isNaN(a) && a < n) return e - 1;
r = e - 1;
}
return t.length - 1;
}
class Bn {
constructor(n, e, i) {
var a;
this._el = document.createElement("div"), this.defaultRender = (s, r) => {
this._el || (this._el = document.createElement("div"));
const o = this._el, l = Math.min(s.relative.top, r.relative.top), d = Math.max(s.relative.top, r.relative.top), c = Math.min(s.relative.left, r.relative.left), u = Math.max(s.relative.left, r.relative.left);
if (this._singleRow) {
const h = this._getTaskPositionByTop(this._startPoint.relative.top);
o.style.height = h.height + "px", o.style.top = h.top + "px";
} else o.style.height = Math.abs(d - l) + "px", o.style.top = l + "px";
return o.style.width = Math.abs(u - c) + "px", o.style.left = c + "px", o;
}, this._gantt = e, this._view = i, this._viewPort = n.viewPort, this._el.classList.add(n.className), typeof n.callback == "function" && (this._callback = n.callback), this.render = () => {
let s;
s = n.render ? n.render(this._startPoint, this._endPoint) : this.defaultRender(this._startPoint, this._endPoint), s !== this._el && (this._el && this._el.parentNode && this._el.parentNode.removeChild(this._el), this._el = s), n.className !== "" && this._el.classList.add(n.className), this.draw();
}, (a = this._viewPort).attachEvent && a.detachEvent || lt(this._viewPort), this._singleRow = n.singleRow, this._useRequestAnimationFrame = n.useRequestAnimationFrame;
}
draw() {
if (this._useRequestAnimationFrame) return requestAnimationFrame(() => {
this._viewPort.appendChild(this.getElement());
});
this._viewPort.appendChild(this.getElement());
}
clear() {
if (this._useRequestAnimationFrame) return requestAnimationFrame(() => {
this._el.parentNode && this._viewPort.removeChild(this._el);
});
this._el.parentNode && this._viewPort.removeChild(this._el);
}
getElement() {
return this._el;
}
getViewPort() {
return this._viewPort;
}
setStart(n) {
const e = this._gantt;
this._startPoint = n, this._startDate = e.dateFromPos(this._startPoint.relative.left), this._viewPort.callEvent("onBeforeDrag", [this._startPoint]);
}
setEnd(n) {
const e = this._gantt;
if (this._endPoint = n, this._singleRow) {
const i = this._getTaskPositionByTop(this._startPoint.relative.top);
this._endPoint.relative.top = i.top;
}
this._endDate = e.dateFromPos(this._endPoint.relative.left), this._startPoint.relative.left > this._endPoint.relative.left && (this._positionPoint = { relative: { left: this._endPoint.relative.left, top: this._positionPoint.relative.top }, absolute: { left: this._endPoint.absolute.left, top: this._positionPoint.absolute.top } }), this._startPoint.relative.top > this._endPoint.relative.top && (this._positionPoint = { relative: { left: this._positionPoint.relative.left, top: this._endPoint.relative.top }, absolute: { left: this._positionPoint.absolute.left, top: this._endPoint.absolute.top } }), this._viewPort.callEvent("onDrag", [this._startPoint, this._endPoint]);
}
setPosition(n) {
this._positionPoint = n;
}
dragEnd(n) {
const e = this._gantt;
n.relative.left < 0 && (n.relative.left = 0), this._viewPort.callEvent("onBeforeDragEnd", [this._startPoint, n]), this.setEnd(n), this._endDate = this._endDate || e.getState().max_date, this._startDate.valueOf() > this._endDate.valueOf() && ([this._startDate, this._endDate] = [this._endDate, this._startDate]), this.clear();
const i = e.getTaskByTime(this._startDate, this._endDate), a = this._getTasksByTop(this._startPoint.relative.top, this._endPoint.relative.top);
this._viewPort.callEvent("onDragEnd", [this._startPoint, this._endPoint]), this._callback && this._callback(this._startPoint, this._endPoint, this._startDate, this._endDate, i, a);
}
getInBounds() {
return this._singleRow;
}
_getTasksByTop(n, e) {
const i = this._gantt;
let a = n, s = e;
n > e && (a = e, s = n);
const r = this._getTaskPositionByTop(a).index, o = this._getTaskPositionByTop(s).index, l = [];
for (let d = r; d <= o; d++)
i.getTaskByIndex(d) && l.push(i.getTaskByIndex(d));
return l;
}
_getTaskPositionByTop(n) {
const e = this._gantt, i = this._view, a = i.getItemIndexByTopPosition(n), s = e.getTaskByIndex(a);
if (s) {
const r = i.getItemHeight(s.id);
return { top: i.getItemTop(s.id) || 0, height: r || 0, index: a };
}
{
const r = i.getTotalHeight();
return { top: n > r ? r : 0, height: e.config.row_height, index: n > r ? e.getTaskCount() : 0 };
}
}
}
let se = !1;
class Kt {
constructor(n) {
this._mouseDown = !1, this._calculateDirectionVector = () => {
if (this._trace.length >= 10) {
const e = this._trace.slice(this._trace.length - 10), i = [];
for (let s = 1; s < e.length; s++) i.push({ x: e[s].x - e[s - 1].x, y: e[s].y - e[s - 1].y });
const a = { x: 0, y: 0 };
return i.forEach((s) => {
a.x += s.x, a.y += s.y;
}), { magnitude: Math.sqrt(a.x * a.x + a.y * a.y), angleDegrees: 180 * Math.atan2(Math.abs(a.y), Math.abs(a.x)) / Math.PI };
}
return null;
}, this._applyDndReadyStyles = () => {
this._timeline.$task.classList.add("gantt_timeline_move_available");
}, this._clearDndReadyStyles = () => {
this._timeline.$task.classList.remove("gantt_timeline_move_available");
}, this._getScrollPosition = (e) => {
const i = this._gantt;
return { x: i.$ui.getView(e.$config.scrollX).getScrollState().position, y: i.$ui.getView(e.$config.scrollY).getScrollState().position };
}, this._countNewScrollPosition = (e) => {
const i = this._calculateDirectionVector();
let a = this._startPoint.x - e.x, s = this._startPoint.y - e.y;
return i && (i.angleDegrees < 15 ? s = 0 : i.angleDegrees > 75 && (a = 0)), { x: this._scrollState.x + a, y: this._scrollState.y + s };
}, this._setScrollPosition = (e, i) => {
const a = this._gantt;
requestAnimationFrame(() => {
a.scrollLayoutCell(e.$id, i.x, i.y);
});
}, this._stopDrag = (e) => {
const i = this._gantt;
if (this._trace = [], i.$root.classList.remove("gantt_noselect"), this._originalReadonly !== void 0 && this._mouseDown && (i.config.readonly = this._originalReadonly, i.config.drag_timeline && i.config.drag_timeline.render && i.render()), this._originAutoscroll !== void 0 && (i.config.autoscroll = this._originAutoscroll), i.config.drag_timeline) {
const { useKey: a } = i.config.drag_timeline;
if (a && e[a] !== !0) return;
}
this._mouseDown = !1, se = !1;
}, this._startDrag = (e) => {
const i = this._gantt;
this._originAutoscroll = i.config.autoscroll, i.config.autoscroll = !1, se = !0, i.$root.classList.add("gantt_noselect"), this._originalReadonly = i.config.readonly, i.config.readonly = !0, i.config.drag_timeline && i.config.drag_timeline.render && i.render(), this._trace = [], this._mouseDown = !0;
const { x: a, y: s } = this._getScrollPosition(this._timeline);
this._scrollState = { x: a, y: s }, this._startPoint = { x: e.clientX, y: e.clientY }, this._trace.push(this._startPoint);
}, this._gantt = n, this._domEvents = n._createDomEventScope(), this._trace = [];
}
static create(n) {
return new Kt(n);
}
static _isDragInProgress() {
return se;
}
destructor() {
this._domEvents.detachAll();
}
attach(n) {
this._timeline = n;
const e = this._gantt;
this._domEvents.attach(n.$task, "mousedown", (i) => {
if (!e.config.drag_timeline) return;
const { useKey: a, ignore: s, enabled: r } = e.config.drag_timeline;
if (r === !1) return;
let o = ".gantt_task_line, .gantt_task_link";
s !== void 0 && (o = s instanceof Array ? s.join(", ") : s), o && e.utils.dom.closest(i.target, o) || a && i[a] !== !0 || this._startDrag(i);
}), this._domEvents.attach(document, "keydown", (i) => {
if (!e.config.drag_timeline) return;
const { useKey: a } = e.config.drag_timeline;
a && i[a] === !0 && this._applyDndReadyStyles();
}), this._domEvents.attach(document, "keyup", (i) => {
if (!e.config.drag_timeline) return;
const { useKey: a } = e.config.drag_timeline;
a && i[a] === !1 && (this._clearDndReadyStyles(), this._stopDrag(i));
}), this._domEvents.attach(document, "mouseup", (i) => {
this._stopDrag(i);
}), this._domEvents.attach(e.$root, "mouseup", (i) => {
this._stopDrag(i);
}), this._domEvents.attach(document, "mouseleave", (i) => {
this._stopDrag(i);
}), this._domEvents.attach(e.$root, "mouseleave", (i) => {
this._stopDrag(i);
}), this._domEvents.attach(e.$root, "mousemove", (i) => {
if (!e.config.drag_timeline) return;
const { useKey: a } = e.config.drag_timeline;
if (a && i[a] !== !0) return;
const s = this._gantt.ext.clickDrag, r = (this._gantt.config.click_drag || {}).useKey;
if ((!s || !r || a || !i[r]) && this._mouseDown === !0) {
this._trace.push({ x: i.clientX, y: i.clientY });
const o = this._countNewScrollPosition({ x: i.clientX, y: i.clientY });
this._setScrollPosition(n, o), this._scrollState = o, this._startPoint = { x: i.clientX, y: i.clientY };
}
});
}
}
var re, zn = {}.constructor.toString();
function X(t) {
var n, e;
if (t && typeof t == "object") switch (!0) {
case et(t):
e = new Date(t);
break;
case be(t):
for (e = new Array(t.length), n = 0; n < t.length; n++) e[n] = X(t[n]);
break;
default:
if (function(i) {
return i.constructor.toString() !== zn;
}(t)) e = Object.create(t);
else {
if (function(i) {
return i.$$typeof && i.$$typeof.toString().includes("react.");
}(t)) return e = t;
e = {};
}
for (n in t) Object.prototype.hasOwnProperty.apply(t, [n]) && (e[n] = X(t[n]));
}
return e || t;
}
function R(t, n, e) {
for (var i in n) (t[i] === void 0 || e) && (t[i] = n[i]);
return t;
}
function q(t) {
return t !== void 0;
}
function ot() {
return re || (re = (/* @__PURE__ */ new Date()).valueOf()), ++re;
}
function B(t, n) {
return t.bind ? t.bind(n) : function() {
return t.apply(n, arguments);
};
}
function cn(t, n, e, i) {
t.addEventListener ? t.addEventListener(n, e, i !== void 0 && i) : t.attachEvent && t.attachEvent("on" + n, e);
}
function un(t, n, e, i) {
t.removeEventListener ? t.removeEventListener(n, e, i !== void 0 && i) : t.detachEvent && t.detachEvent("on" + n, e);
}
const jn = Object.freeze(Object.defineProperty({ __proto__: null, bind: B, copy: X, defined: q, event: cn, eventRemove: un, mixin: R, uid: ot }, Symbol.toStringTag, { value: "Module" }));
function Xt(t) {
var n = t.date;
return t.$services, { getSum: function(e, i, a) {
a === void 0 && (a = e.length - 1), i === void 0 && (i = 0);
for (var s = 0, r = i; r <= a; r++) s += e[r];
return s;
}, setSumWidth: function(e, i, a, s) {
var r = i.width;
s === void 0 && (s = r.length - 1), a === void 0 && (a = 0);
var o = s - a + 1;
if (!(a > r.length - 1 || o <= 0 || s > r.length - 1)) {
var l = e - this.getSum(r, a, s);
this.adjustSize(l, r, a, s), this.adjustSize(-l, r, s + 1), i.full_width = this.getSum(r);
}
}, splitSize: function(e, i) {
for (var a = [], s = 0; s < i; s++) a[s] = 0;
return this.adjustSize(e, a), a;
}, adjustSize: function(e, i, a, s) {
a || (a = 0), s === void 0 && (s = i.length - 1);
for (var r = s - a + 1, o = this.getSum(i, a, s), l = a; l <= s; l++) {
var d = Math.floor(e * (o ? i[l] / o : 1 / r));
o -= i[l], e -= d, r--, i[l] += d;
}
i[i.length - 1] += e;
}, sortScales: function(e) {
function i(s, r) {
var o = new Date(1970, 0, 1);
return n.add(o, r, s) - o;
}
e.sort(function(s, r) {
return i(s.unit, s.step) < i(r.unit, r.step) ? 1 : i(s.unit, s.step) > i(r.unit, r.step) ? -1 : 0;
});
for (var a = 0; a < e.length; a++) e[a].index = a;
}, _prepareScaleObject: function(e) {
var i = e.format;
return i || (i = e.template || e.date || "%d %M"), typeof i == "string" && (i = t.date.date_to_str(i)), { unit: e.unit || "day", step: e.step || 1, format: i, css: e.css, projection: e.projection || null, column_width: e.column_width || null };
}, primaryScale: function(e) {
const i = (e || t.config).scales[0], a = { unit: i.unit, step: i.step, template: i.template, format: i.format, date: i.date, css: i.css || t.templates.scale_cell_class, projection: i.projection || null, column_width: i.column_width || null };
return this._prepareScaleObject(a);
}, getAdditionalScales: function(e) {
return (e || t.config).scales.slice(1).map((function(i) {
return this._prepareScaleObject(i);
}).bind(this));
}, prepareConfigs: function(e, i, a, s, r, o, l) {
for (var d = this.splitSize(s, e.length), c = a, u = [], h = e.length - 1; h >= 0; h--) {
var _ = h == e.length - 1, f = this.initScaleConfig(e[h], r, o);
_ && this.processIgnores(f), _ && f.column_width && (c = f.column_width * (f.display_count || f.count)), this.initColSizes(f, i, c, d[h]), this.limitVisibleRange(f), _ && (c = f.full_width), u.unshift(f);
}
for (h = 0; h < u.length - 1; h++) this.alineScaleColumns(u[u.length - 1], u[h]);
for (h = 0; h < u.length; h++) l && this.reverseScale(u[h]), this.setPosSettings(u[h]);
return u;
}, reverseScale: function(e) {
e.width = e.width.reverse(), e.trace_x = e.trace_x.reverse();
var i = e.trace_indexes;
e.trace_indexes = {}, e.trace_index_transition = {}, e.rtl = !0;
for (var a = 0; a < e.trace_x.length; a++) e.trace_indexes[e.trace_x[a].valueOf()] = a, e.trace_index_transition[i[e.trace_x[a].valueOf()]] = a;
return e;
}, setPosSettings: function(e) {
for (var i = 0, a = e.trace_x.length; i < a; i++) e.left.push((e.width[i - 1] || 0) + (e.left[i - 1] || 0));
}, _ignore_time_config: function(e, i) {
if (t.config.skip_off_time) {
for (var a = !0, s = e, r = 0; r < i.step; r++) r && (s = n.add(e, r, i.unit)), a = a && !this.isWorkTime(s, i.unit);
return a;
}
return !1;
}, processIgnores: function(e) {
e.ignore_x = {}, e.display_count = e.count;
}, initColSizes: function(e, i, a, s) {
var r = a;
e.height = s;
var o = e.display_count === void 0 ? e.count : e.display_count;
o || (o = 1);
const l = !isNaN(1 * e.column_width) && 1 * e.column_width > 0;
if (l) {
const h = 1 * e.column_width;
e.col_width = h, r = h * o;
} else e.col_width = Math.floor(r / o), i && e.col_width < i && (e.col_width = i, r = e.col_width * o);
e.width = [];
for (var d = e.ignore_x || {}, c = 0; c < e.trace_x.length; c++) if (d[e.trace_x[c].valueOf()] || e.display_count == e.count) e.width[c] = l ? e.col_width : 0;
else {
var u = 1;
e.unit == "month" && (u = Math.round((n.add(e.trace_x[c], e.step, e.unit) - e.trace_x[c]) / 864e5)), e.width[c] = u;
}
l || this.adjustSize(r - this.getSum(e.width), e.width), e.full_width = this.getSum(e.width);
}, initScaleConfig: function(e, i, a) {
var s = R({ count: 0, col_width: 0, full_width: 0, height: 0, width: [], left: [], trace_x: [], trace_indexes: {}, min_date: new Date(i), max_date: new Date(a) }, e);
return this.eachColumn(e.unit, e.step, i, a, function(r) {
s.count++, s.trace_x.push(new Date(r)), s.trace_indexes[r.valueOf()] = s.trace_x.length - 1;
}), s.trace_x_ascending = s.trace_x.slice(), s;
}, iterateScales: function(e, i, a, s, r) {
for (var o = i.trace_x, l = e.trace_x, d = a || 0, c = s || l.length - 1, u = 0, h = 1; h < o.length; h++) {
var _ = e.trace_indexes[+o[h]];
_ !== void 0 && _ <= c && (r && r.apply(this, [u, h, d, _]), d = _, u = h);
}
}, alineScaleColumns: function(e, i, a, s) {
this.iterateScales(e, i, a, s, function(r, o, l, d) {
var c = this.getSum(e.width, l, d - 1);
this.getSum(i.width, r, o - 1) != c && this.setSumWidth(c, i, r, o - 1);
});
}, eachColumn: function(e, i, a, s, r) {
var o = new Date(a), l = new Date(s);
n[e + "_start"] && (o = n[e + "_start"](o));
var d = new Date(o);
for (+d >= +l && (l = n.add(d, i, e)); +d < +l; ) {
r.call(this, new Date(d));
var c = d.getTimezoneOffset();
d = n.add(d, i, e), d = t._correct_dst_change(d, c, i, e), n[e + "_start"] && (d = n[e + "_start"](d));
}
}, limitVisibleRange: function(e) {
var i = e.trace_x, a = e.width.length - 1, s = 0;
if (+i[0] < +e.min_date && a != 0) {
var r = Math.floor(e.width[0] * ((i[1] - e.min_date) / (i[1] - i[0])));
s += e.width[0] - r, e.width[0] = r, i[0] = new Date(e.min_date);
}
var o = i.length - 1, l = i[o], d = n.add(l, e.step, e.unit);
if (+d > +e.max_date && o > 0 && (r = e.width[o] - Math.floor(e.width[o] * ((d - e.max_date) / (d - l))), s += e.width[o] - r, e.width[o] = r), s) {
for (var c = this.getSum(e.width), u = 0, h = 0; h < e.width.length; h++) {
var _ = Math.floor(s * (e.width[h] / c));
e.width[h] += _, u += _;
}
this.adjustSize(s - u, e.width);
}
} };
}
function Wn(t) {
(function() {
var n = [];
function e() {
return !!n.length;
}
function i(d) {
setTimeout(function() {
e() || t.$destroyed || t.focus();
}, 1);
}
function a(d) {
t.eventRemove(d, "keydown", r), t.event(d, "keydown", r), n.push(d);
}
function s() {
var d = n.pop();
d && t.eventRemove(d, "keydown", r), i();
}
function r(d) {
var c = d.currentTarget;
c == n[n.length - 1] && t.$keyboardNavigation.trapFocus(c, d);
}
function o() {
a(t.getLightbox());
}
t.attachEvent("onLightbox", o), t.attachEvent("onAfterLightbox", s), t.attachEvent("onLightboxChange", function() {
s(), o();
}), t.attachEvent("onAfterQuickInfo", function() {
i();
}), t.attachEvent("onMessagePopup", function(d) {
l = t.utils.dom.getActiveElement(), a(d);
}), t.attachEvent("onAfterMessagePopup", function() {
s(), setTimeout(function() {
l && l.focus && (l.focus(), l = null);
}, 1);
});
var l = null;
t.$keyboardNavigation.isModal = e;
})();
}
class Fn {
constructor(n) {
this.show = (e, i) => {
i === void 0 ? this._showForTask(e) : this._showAtCoordinates(e, i);
}, this.hide = (e) => {
const i = this._gantt, a = this._quickInfoBox;
this._quickInfoBoxId = 0;
const s = this._quickInfoTask;
if (this._quickInfoTask = null, a && a.parentNode) {
if (i.config.quick_info_detached) return i.callEvent("onAfterQuickInfo", [s]), a.parentNode.removeChild(a);
a.className += " gantt_qi_hidden", a.style.right === "auto" ? a.style.left = "-350px" : a.style.right = "-350px", e && (a.style.left = a.style.right = "", a.parentNode.removeChild(a)), i.callEvent("onAfterQuickInfo", [s]);
}
}, this.getNode = () => this._quickInfoBox ? this._quickInfoBox : null, this.setContainer = (e) => {
e && (this._container = typeof e == "string" ? document.getElementById(e) : e);
}, this.setContent = (e) => {
const i = this._gantt, a = { taskId: null, header: { title: "", date: "" }, content: "", buttons: i.config.quickinfo_buttons };
e || (e = a), e.taskId || (e.taskId = a.taskId), e.header || (e.header = a.header), e.header.title || (e.header.title = a.header.title), e.header.date || (e.header.date = a.header.date), e.content || (e.content = a.content), e.buttons || (e.buttons = a.buttons);
let s = this.getNode();
s || (s = this._createQuickInfoElement()), e.taskId && (this._quickInfoBoxId = e.taskId);
const r = s.querySelector(".gantt_cal_qi_title"), o = r.querySelector(".gantt_cal_qi_tcontent"), l = r.querySelector(".gantt_cal_qi_tdate"), d = s.querySelector(".gantt_cal_qi_content"), c = s.querySelector(".gantt_cal_qi_controls");
i._waiAria.quickInfoHeader(s, [e.header.title, e.header.date].join(" ")), o.innerHTML = e.header.title, l.innerHTML = e.header.date, e.header.title || e.header.date ? r.style.display = "" : r.style.display = "none", d.innerHTML = e.content;
const u = e.buttons;
u.length ? c.style.display = "" : c.style.display = "none";
let h = "";
for (let _ = 0; _ < u.length; _++) {
const f = i._waiAria.quickInfoButtonAttrString(i.locale.labels[u[_]]);
h += `<div class="gantt_qi_big_icon ${u[_]} dhx_gantt_${u[_]}" title="${i.locale.labels[u[_]]}" ${f}>
<div class='dhx_menu_icon dhx_gantt_icon ${u[_]} gantt_menu_icon dhx_gantt_${u[_]}'></div>
<div>${i.locale.labels[u[_]]}</div>
</div>`;
}
c.innerHTML = h, i.eventRemove(s, "click", this._qiButtonClickHandler), i.eventRemove(s, "keypress", this._qiKeyPressHandler), i.event(s, "click", this._qiButtonClickHandler), i.event(s, "keypress", this._qiKeyPressHandler);
}, this._qiButtonClickHandler = (e) => {
this._qi_button_click(e.target);
}, this._qiKeyPressHandler = (e) => {
const i = e.which;
i !== 13 && i !== 32 || setTimeout(() => {
this._qi_button_click(e.target);
}, 1);
}, this._gantt = n;
}
_showAtCoordinates(n, e) {
this.hide(!0), this._quickInfoBoxId = 0, this._quickInfoTask = null, this._quickInfoBox || (this._createQuickInfoElement(), this.setContent()), this._appendAtCoordinates(n, e), this._gantt.callEvent("onQuickInfo", [null]);
}
_showForTask(n) {
const e = this._gantt;
if (n === this._quickInfoBoxId && e.utils.dom.isChildOf(this._quickInfoBox, document.body) || !e.config.show_quick_info) return;
this.hide(!0);
const i = this._getContainer(), a = this._get_event_counter_part(n, 6, i.xViewport, i.yViewport);
a && (this._quickInfoBox = this._init_quick_info(n), this._quickInfoTask = n, this._quickInfoBox.className = this._prepare_quick_info_classname(n), this._fill_quick_data(n), this._show_quick_info(a, 6), e.callEvent("onQuickInfo", [n]));
}
_get_event_counter_part(n, e, i, a) {
const s = this._gantt;
let r = s.getTaskNode(n);
if (!r && (r = s.getTaskRowNode(n), !r)) return null;
let o = 0;
const l = e + r.offsetTop + r.offsetHeight;
let d = r;
if (s.utils.dom.isChildOf(d, i)) for (; d && d !== i; ) o += d.offsetLeft, d = d.offsetParent;
const c = s.getScrollState();
return d ? { left: o, top: l, dx: o + r.offsetWidth / 2 - c.x > i.offsetWidth / 2 ? 1 : 0, dy: l + r.offsetHeight / 2 - c.y > a.offsetHeight / 2 ? 1 : 0, width: r.offsetWidth, height: r.offsetHeight } : null;
}
_createQuickInfoElement() {
const n = this._gantt, e = document.createElement("div");
e.className += "gantt_cal_quick_info", n._waiAria.quickInfoAttr(e);
var i = `
<div class="gantt_cal_qi_tcontrols">
<a class="gantt_cal_qi_close_btn dhx_gantt_icon dhx_gantt_icon_close"></a>
</div>
<div class="gantt_cal_qi_title" ${n._waiAria.quickInfoHeaderAttrString()}>
<div class="gantt_cal_qi_tcontent"></div>
<div class="gantt_cal_qi_tdate"></div>
</div>
<div class="gantt_cal_qi_content"></div>`;
if (i += '<div class="gantt_cal_qi_controls">', i += "</div>", e.innerHTML = i, n.config.quick_info_detached) {
const a = this._getContainer();
n.event(a.parent, "scroll", () => {
this.hide();
});
}
return this._quickInfoBox = e, e;
}
_init_quick_info(n) {
const e = this._gantt, i = e.getTask(n);
return typeof this._quickInfoReadonly == "boolean" && e.isReadonly(i) !== this._quickInfoReadonly && (this.hide(!0), this._quickInfoBox = null), this._quickInfoReadonly = e.isReadonly(i), this._quickInfoBox || (this._quickInfoBox = this._createQuickInfoElement()), this._quickInfoBox;
}
_prepare_quick_info_classname(n) {
const e = this._gantt, i = e.getTask(n);
let a = `gantt_cal_quick_info gantt_${e.getTaskType(i)}`;
const s = e.templates.quick_info_class(i.start_date, i.end_date, i);
return s && (a += " " + s), a;
}
_fill_quick_data(n) {
const e = this._gantt, i = e.getTask(n);
this._quickInfoBoxId = n;
let a = [];
if (this._quickInfoReadonly) {
const s = e.config.quickinfo_buttons, r = { icon_delete: !0, icon_edit: !0 };
for (let o = 0; o < s.length; o++) this._quickInfoReadonly && r[s[o]] || a.push(s[o]);
} else a = e.config.quickinfo_buttons;
this.setContent({ header: { title: e.templates.quick_info_title(i.start_date, i.end_date, i), date: e.templates.quick_info_date(i.start_date, i.end_date, i) }, content: e.templates.quick_info_content(i.start_date, i.end_date, i), buttons: a });
}
_appendAtCoordinates(n, e) {
const i = this._quickInfoBox, a = this._getContainer();
i.parentNode && i.parentNode.nodeName.toLowerCase() !== "#document-fragment" || a.parent.appendChild(i), i.style.left = n + "px", i.style.top = e + "px";
}
_show_quick_info(n, e) {
const i = this._gantt, a = this._quickInfoBox;
if (i.config.quick_info_detached) {
const s = this._getContainer();
a.parentNode && a.parentNode.nodeName.toLowerCase() !== "#document-fragment" || s.parent.appendChild(a);
const r = a.offsetWidth, o = a.offsetHeight, l = i.getScrollState(), d = s.xViewport, c = s.yViewport, u = d.offsetWidth + l.x - r, h = n.top - l.y + o;
let _ = n.top;
h > c.offsetHeight / 2 && (_ = n.top - (o + n.height + 2 * e), _ < l.y && h <= c.offsetHeight && (_ = n.top)), _ < l.y && (_ = l.y);
const f = Math.min(Math.max(l.x, n.left - n.dx * (r - n.width)), u), y = _;
this._appendAtCoordinates(f, y);
} else a.style.top = "20px", n.dx === 1 ? (a.style.right = "auto", a.style.left = "-300px", setTimeout(() => {
a.style.left = "10px";
}, 1)) : (a.style.left = "auto", a.style.right = "-300px", setTimeout(() => {
a.style.right = "10px";
}, 1)), a.className += " gantt_qi_" + (n.dx === 1 ? "left" : "right"), i.$root.appendChild(a);
}
_qi_button_click(n) {
const e = this._gantt, i = this._quickInfoBox;
if (!n || n === i) return;
if (n.closest(".gantt_cal_qi_close_btn")) return void this.hide();
const a = n.className;
if (a.indexOf("_icon") !== -1) {
const s = this._quickInfoBoxId;
e.$click.buttons[a.split(" ")[1].replace("icon_", "")](s);
} else this._qi_button_click(n.parentNode);
}
_getContainer() {
const n = this._gantt;
let e = this._container ? this._container : n.$task_data;
return e && e.offsetHeight && e.offsetWidth ? { parent: e, xViewport: n.$task, yViewport: n.$task_data } : (e = this._container ? this._container : n.$grid_data, e && e.offsetHeight && e.offsetWidth ? { parent: e, xViewport: n.$grid, yViewport: n.$grid_data } : { parent: this._container ? this._container : n.$layout, xViewport: n.$layout, yViewport: n.$layout });
}
}
function ae(t, n) {
t = t || cn, n = n || un;
var e = [], i = { attach: function(a, s, r, o) {
e.push({ element: a, event: s, callback: r, capture: o }), t(a, s, r, o);
}, detach: function(a, s, r, o) {
n(a, s, r, o);
for (var l = 0; l < e.length; l++) {
var d = e[l];
d.element === a && d.event === s && d.callback === r && d.capture === o && (e.splice(l, 1), l--);
}
}, detachAll: function() {
for (var a = e.slice(), s = 0; s < a.length; s++) {
var r = a[s];
i.detach(r.element, r.event, r.callback, r.capture), i.detach(r.element, r.event, r.callback, void 0), i.detach(r.element, r.event, r.callback, !1), i.detach(r.element, r.event, r.callback, !0);
}
e.splice(0, e.length);
}, extend: function() {
return ae(this.event, this.eventRemove);
} };
return i;
}
class Vn {
constructor(n) {
this._gantt = n;
}
getNode() {
const n = this._gantt;
return this._tooltipNode || (this._tooltipNode = document.createElement("div"), this._tooltipNode.className = "gantt_tooltip", n._waiAria.tooltipAttr(this._tooltipNode)), this._tooltipNode;
}
setViewport(n) {
return this._root = n, this;
}
show(n, e) {
const i = this._gantt, a = document.body, s = this.getNode();
if (K(s, a) || (this.hide(), s.style.top = s.style.top || "0px", s.style.left = s.style.left || "0px", a.appendChild(s)), this._isLikeMouseEvent(n)) {
const r = this._calculateTooltipPosition(n);
e = r.top, n = r.left;
}
return s.style.top = e + "px", s.style.left = n + "px", i._waiAria.tooltipVisibleAttr(s), this;
}
hide() {
const n = this._gantt, e = this.getNode();
return e && e.parentNode && e.parentNode.removeChild(e), n._waiAria.tooltipHiddenAttr(e), this;
}
setContent(n) {
return this.getNode().innerHTML = n, this;
}
_isLikeMouseEvent(n) {
return !(!n || typeof n != "object") && "clientX" in n && "clientY" in n;
}
_getViewPort() {
return this._root || document.body;
}
_calculateTooltipPosition(n) {
const e = this._gantt, i = this._getViewPortSize(), a = this.getNode(), s = { top: 0, left: 0, width: a.offsetWidth, height: a.offsetHeight, bottom: 0, right: 0 }, r = e.config.tooltip_offset_x, o = e.config.tooltip_offset_y, l = document.body, d = rt(n, l), c = Y(l);
d.y += c.y, s.top = d.y, s.left = d.x, s.top += o, s.left += r, s.bottom = s.top + s.height, s.right = s.left + s.width;
const u = window.scrollY + l.scrollTop;
return s.top < i.top - u ? (s.top = i.top, s.bottom = s.top + s.height) : s.bottom > i.bottom && (s.bottom = i.bottom, s.top = s.bottom - s.height), s.left < i.left ? (s.left = i.left, s.right = i.left + s.width) : s.right > i.right && (s.right = i.right, s.left = s.right - s.width), d.x >= s.left && d.x <= s.right && (s.left = d.x - s.width - r, s.right = s.left + s.width), d.y >= s.top && d.y <= s.bottom && (s.top = d.y - s.height - o, s.bottom = s.top + s.height), s.left < 0 && (s.left = 0), s.right < 0 && (s.right = 0), s;
}
_getViewPortSize() {
const n = this._gantt, e = this._getViewPort();
let i, a = e, s = window.scrollY + document.body.scrollTop, r = window.scrollX + document.body.scrollLeft;
return e === n.$task_data ? (a = n.$task, s = 0, r = 0, i = Y(n.$task)) : i = Y(a), { left: i.x + r, top: i.y + s, width: i.width, height: i.height, bottom: i.y + i.height + s, right: i.x + i.width + r };
}
}
class Un {
constructor(n) {
this._listeners = {}, this.tooltip = new Vn(n), this._gantt = n, this._domEvents = ae(), this._initDelayedFunctions();
}
destructor() {
this.tooltip.hide(), this._domEvents.detachAll();
}
hideTooltip() {
this.delayHide();
}
attach(n) {
let e = document.body;
const i = this._gantt;
n.global || (e = i.$root);
let a = null;
const s = (r) => {
const o = xt(r), l = ht(o, n.selector);
if (K(o, this.tooltip.getNode())) return;
const d = () => {
a = l, n.onmouseenter(r, l);
};
a ? l && l === a ? n.onmousemove(r, l) : (n.onmouseleave(r, a), a = null, l && l !== a && d()) : l && d();
};
this.detach(n.selector), this._domEvents.attach(e, "mousemove", s), this._listeners[n.selector] = { node: e, handler: s };
}
detach(n) {
const e = this._listeners[n];
e && this._domEvents.detach(e.node, "mousemove", e.handler);
}
tooltipFor(n) {
const e = (i) => {
let a = i;
return document.createEventObject && !document.createEvent && (a = document.createEventObject(i)), a;
};
this._initDelayedFunctions(), this.attach({ selector: n.selector, global: n.global, onmouseenter: (i, a) => {
const s = n.html(i, a);
s && this.delayShow(e(i), s);
}, onmousemove: (i, a) => {
const s = n.html(i, a);
s ? this.delayShow(e(i), s) : (this.delayShow.$cancelTimeout(), this.delayHide());
}, onmouseleave: () => {
this.delayShow.$cancelTimeout(), this.delayHide();
} });
}
_initDelayedFunctions() {
const n = this._gantt;
this.delayShow && this.delayShow.$cancelTimeout(), this.delayHide && this.delayHide.$cancelTimeout(), this.tooltip.hide(), this.delayShow = xe((e, i) => {
n.callEvent("onBeforeTooltip", [e]) === !1 ? this.tooltip.hide() : (this.tooltip.setContent(i), this.tooltip.show(e));
}, n.config.tooltip_timeout || 1), this.delayHide = xe(() => {
this.delayShow.$cancelTimeout(), this.tooltip.hide();
}, n.config.tooltip_hide_timeout || 1);
}
}
const Le = { onBeforeUndo: "onAfterUndo", onBeforeRedo: "onAfterRedo" }, Re = ["onTaskDragStart", "onAfterTaskUpdate", "onAfterParentExpand", "onAfterTaskDelete", "onBeforeBatchUpdate"];
class qn {
constructor(n, e) {
this._batchAction = null, this._batchMode = !1, this._ignore = !1, this._ignoreMoveEvents = !1, this._initialTasks = {}, this._initialLinks = {}, this._nestedTasks = {}, this._nestedLinks = {}, this._undo = n, this._gantt = e, this._attachEvents();
}
store(n, e, i = !1) {
return e === this._gantt.config.undo_types.task ? this._storeTask(n, i) : e === this._gantt.config.undo_types.link && this._storeLink(n, i);
}
isMoveEventsIgnored() {
return this._ignoreMoveEvents;
}
toggleIgnoreMoveEvents(n) {
this._ignoreMoveEvents = n || !1;
}
startIgnore() {
this._ignore = !0;
}
stopIgnore() {
this._ignore = !1;
}
startBatchAction() {
this._timeout || (this._timeout = setTimeout(() => {
this.stopBatchAction(), this._timeout = null;
}, 10)), this._ignore || this._batchMode || (this._batchMode = !0, this._batchAction = this._undo.action.create());
}
stopBatchAction() {
if (this._ignore) return;
const n = this._undo;
this._batchAction && n.logAction(this._batchAction), this._batchMode = !1, this._batchAction = null;
}
onTaskAdded(n) {
this._ignore || this._storeTaskCommand(n, this._undo.command.type.add);
}
onTaskUpdated(n) {
this._ignore || this._storeTaskCommand(n, this._undo.command.type.update);
}
onTaskMoved(n) {
this._ignore || (n.$local_index = this._gantt.getTaskIndex(n.id), this._storeEntityCommand(n, this.getInitialTask(n.id), this._undo.command.type.move, this._undo.command.entity.task));
}
onTaskDeleted(n) {
if (!this._ignore) {
if (this._storeTaskCommand(n, this._undo.command.type.remove), this._nestedTasks[n.id]) {
const e = this._nestedTasks[n.id];
for (let i = 0; i < e.length; i++) this._storeTaskCommand(e[i], this._undo.command.type.remove);
}
if (this._nestedLinks[n.id]) {
const e = this._nestedLinks[n.id];
for (let i = 0; i < e.length; i++) this._storeLinkCommand(e[i], this._undo.command.type.remove);
}
}
}
onLinkAdded(n) {
this._ignore || this._storeLinkCommand(n, this._undo.command.type.add);
}
onLinkUpdated(n) {
this._ignore || this._storeLinkCommand(n, this._undo.command.type.update);
}
onLinkDeleted(n) {
this._ignore || this._storeLinkCommand(n, this._undo.command.type.remove);
}
setNestedTasks(n, e) {
const i = this._gantt;
let a = null;
const s = [];
let r = this._getLinks(i.getTask(n));
for (let d = 0; d < e.length; d++) a = this.setInitialTask(e[d]), r = r.concat(this._getLinks(a)), s.push(a);
const o = {};
for (let d = 0; d < r.length; d++) o[r[d]] = !0;
const l = [];
for (const d in o) l.push(this.setInitialLink(d));
this._nestedTasks[n] = s, this._nestedLinks[n] = l;
}
setInitialTask(n, e) {
const i = this._gantt;
if (e || !this._initialTasks[n] || !this._batchMode) {
const a = i.copy(i.getTask(n));
a.$index = i.getGlobalTaskIndex(n), a.$local_index = i.getTaskIndex(n), this.setInitialTaskObject(n, a);
}
return this._initialTasks[n];
}
getInitialTask(n) {
return this._initialTasks[n];
}
clearInitialTasks() {
this._initialTasks = {};
}
se