@workiom/frappe-gantt 1.0.21 → 1.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- const A = "year", E = "month", Y = "day", S = "hour", H = "minute", X = "second", W = "millisecond", g = {
1
+ const E = "year", A = "month", H = "day", S = "hour", Y = "minute", X = "second", F = "millisecond", g = {
2
2
  parse_duration(r) {
3
3
  const e = /([0-9]+)(y|m|d|h|min|s|ms)/gm.exec(r);
4
4
  if (e !== null) {
@@ -24,15 +24,15 @@ const A = "year", E = "month", Y = "day", S = "hour", H = "minute", X = "second"
24
24
  if (typeof r == "string") {
25
25
  let i, s;
26
26
  const n = r.split(" ");
27
- i = n[0].split(t).map((a) => parseInt(a, 10)), s = n[1] && n[1].split(e), i[1] = i[1] ? i[1] - 1 : 0;
28
- let o = i;
29
- return s && s.length && (s.length === 4 && (s[3] = "0." + s[3], s[3] = parseFloat(s[3]) * 1e3), o = o.concat(s)), new Date(...o);
27
+ i = n[0].split(t).map((o) => parseInt(o, 10)), s = n[1] && n[1].split(e), i[1] = i[1] ? i[1] - 1 : 0;
28
+ let a = i;
29
+ return s && s.length && (s.length === 4 && (s[3] = "0." + s[3], s[3] = parseFloat(s[3]) * 1e3), a = a.concat(s)), new Date(...a);
30
30
  }
31
31
  },
32
32
  to_string(r, t = !1) {
33
33
  if (!(r instanceof Date))
34
34
  throw new TypeError("Invalid argument type");
35
- const e = this.get_date_values(r).map((n, o) => (o === 1 && (n = n + 1), o === 6 ? L(n + "", 3, "0") : L(n + "", 2, "0"))), i = `${e[0]}-${e[1]}-${e[2]}`, s = `${e[3]}:${e[4]}:${e[5]}.${e[6]}`;
35
+ const e = this.get_date_values(r).map((n, a) => (a === 1 && (n = n + 1), a === 6 ? L(n + "", 3, "0") : L(n + "", 2, "0"))), i = `${e[0]}-${e[1]}-${e[2]}`, s = `${e[3]}:${e[4]}:${e[5]}.${e[6]}`;
36
36
  return i + (t ? " " + s : "");
37
37
  },
38
38
  format(r, t = "YYYY-MM-DD HH:mm:ss.SSS", e = "en") {
@@ -40,39 +40,39 @@ const A = "year", E = "month", Y = "day", S = "hour", H = "minute", X = "second"
40
40
  month: "long"
41
41
  }), s = new Intl.DateTimeFormat(e, {
42
42
  month: "short"
43
- }), n = i.format(r), o = n.charAt(0).toUpperCase() + n.slice(1), a = this.get_date_values(r).map((c) => L(c, 2, 0)), h = {
44
- YYYY: a[0],
45
- MM: L(+a[1] + 1, 2, 0),
46
- DD: a[2],
47
- HH: a[3],
48
- mm: a[4],
49
- ss: a[5],
50
- SSS: a[6],
51
- D: a[2],
52
- MMMM: o,
43
+ }), n = i.format(r), a = n.charAt(0).toUpperCase() + n.slice(1), o = this.get_date_values(r).map((l) => L(l, 2, 0)), d = {
44
+ YYYY: o[0],
45
+ MM: L(+o[1] + 1, 2, 0),
46
+ DD: o[2],
47
+ HH: o[3],
48
+ mm: o[4],
49
+ ss: o[5],
50
+ SSS: o[6],
51
+ D: o[2],
52
+ MMMM: a,
53
53
  MMM: s.format(r)
54
54
  };
55
- let d = t;
55
+ let h = t;
56
56
  const _ = [];
57
- return Object.keys(h).sort((c, p) => p.length - c.length).forEach((c) => {
58
- d.includes(c) && (d = d.replaceAll(c, `$${_.length}`), _.push(h[c]));
59
- }), _.forEach((c, p) => {
60
- d = d.replaceAll(`$${p}`, c);
61
- }), d;
57
+ return Object.keys(d).sort((l, p) => p.length - l.length).forEach((l) => {
58
+ h.includes(l) && (h = h.replaceAll(l, `$${_.length}`), _.push(d[l]));
59
+ }), _.forEach((l, p) => {
60
+ h = h.replaceAll(`$${p}`, l);
61
+ }), h;
62
62
  },
63
63
  diff(r, t, e = "day") {
64
- let i, s, n, o, a, h, d;
65
- i = r - t + (t.getTimezoneOffset() - r.getTimezoneOffset()) * 6e4, s = i / 1e3, o = s / 60, n = o / 60, a = n / 24;
66
- let _ = r.getFullYear() - t.getFullYear(), c = r.getMonth() - t.getMonth();
67
- return c += a % 30 / 30, h = _ * 12 + c, r.getDate() < t.getDate() && h--, d = h / 12, e.endsWith("s") || (e += "s"), Math.round(
64
+ let i, s, n, a, o, d, h;
65
+ i = r - t + (t.getTimezoneOffset() - r.getTimezoneOffset()) * 6e4, s = i / 1e3, a = s / 60, n = a / 60, o = n / 24;
66
+ let _ = r.getFullYear() - t.getFullYear(), l = r.getMonth() - t.getMonth();
67
+ return l += o % 30 / 30, d = _ * 12 + l, r.getDate() < t.getDate() && d--, h = d / 12, e.endsWith("s") || (e += "s"), Math.round(
68
68
  {
69
69
  milliseconds: i,
70
70
  seconds: s,
71
- minutes: o,
71
+ minutes: a,
72
72
  hours: n,
73
- days: a,
74
- months: h,
75
- years: d
73
+ days: o,
74
+ months: d,
75
+ years: h
76
76
  }[e] * 100
77
77
  ) / 100;
78
78
  },
@@ -86,37 +86,37 @@ const A = "year", E = "month", Y = "day", S = "hour", H = "minute", X = "second"
86
86
  add(r, t, e) {
87
87
  t = parseInt(t, 10);
88
88
  const i = [
89
- r.getFullYear() + (e === A ? t : 0),
90
- r.getMonth() + (e === E ? t : 0),
91
- r.getDate() + (e === Y ? t : 0),
89
+ r.getFullYear() + (e === E ? t : 0),
90
+ r.getMonth() + (e === A ? t : 0),
91
+ r.getDate() + (e === H ? t : 0),
92
92
  r.getHours() + (e === S ? t : 0),
93
- r.getMinutes() + (e === H ? t : 0),
93
+ r.getMinutes() + (e === Y ? t : 0),
94
94
  r.getSeconds() + (e === X ? t : 0),
95
- r.getMilliseconds() + (e === W ? t : 0)
95
+ r.getMilliseconds() + (e === F ? t : 0)
96
96
  ];
97
97
  return new Date(...i);
98
98
  },
99
99
  start_of(r, t) {
100
100
  const e = {
101
- [A]: 6,
102
- [E]: 5,
103
- [Y]: 4,
101
+ [E]: 6,
102
+ [A]: 5,
103
+ [H]: 4,
104
104
  [S]: 3,
105
- [H]: 2,
105
+ [Y]: 2,
106
106
  [X]: 1,
107
- [W]: 0
107
+ [F]: 0
108
108
  };
109
109
  function i(n) {
110
- const o = e[t];
111
- return e[n] <= o;
110
+ const a = e[t];
111
+ return e[n] <= a;
112
112
  }
113
113
  const s = [
114
114
  r.getFullYear(),
115
- i(A) ? 0 : r.getMonth(),
116
- i(E) ? 1 : r.getDate(),
117
- i(Y) ? 0 : r.getHours(),
115
+ i(E) ? 0 : r.getMonth(),
116
+ i(A) ? 1 : r.getDate(),
117
+ i(H) ? 0 : r.getHours(),
118
118
  i(S) ? 0 : r.getMinutes(),
119
- i(H) ? 0 : r.getSeconds(),
119
+ i(Y) ? 0 : r.getSeconds(),
120
120
  i(X) ? 0 : r.getMilliseconds()
121
121
  ];
122
122
  return new Date(...s);
@@ -161,26 +161,26 @@ const A = "year", E = "month", Y = "day", S = "hour", H = "minute", X = "second"
161
161
  function L(r, t, e) {
162
162
  return r = r + "", t = t >> 0, e = String(typeof e < "u" ? e : " "), r.length > t ? String(r) : (t = t - r.length, t > e.length && (e += e.repeat(t / e.length)), e.slice(0, t) + String(r));
163
163
  }
164
- function m(r, t) {
164
+ function u(r, t) {
165
165
  return typeof r == "string" ? (t || document).querySelector(r) : r || null;
166
166
  }
167
- function w(r, t) {
167
+ function $(r, t) {
168
168
  const e = document.createElementNS("http://www.w3.org/2000/svg", r);
169
169
  for (let i in t)
170
170
  i === "append_to" ? t.append_to.appendChild(e) : i === "innerHTML" ? e.innerHTML = t.innerHTML : i === "clipPath" ? e.setAttribute("clip-path", "url(#" + t[i] + ")") : e.setAttribute(i, t[i]);
171
171
  return e;
172
172
  }
173
173
  function z(r, t, e, i) {
174
- const s = B(r, t, e, i);
174
+ const s = R(r, t, e, i);
175
175
  if (s === r) {
176
176
  const n = document.createEvent("HTMLEvents");
177
177
  n.initEvent("click", !0, !0), n.eventName = "click", s.dispatchEvent(n);
178
178
  }
179
179
  }
180
- function B(r, t, e, i, s = "0.4s", n = "0.1s") {
181
- const o = r.querySelector("animate");
182
- if (o)
183
- return m.attr(o, {
180
+ function R(r, t, e, i, s = "0.4s", n = "0.1s") {
181
+ const a = r.querySelector("animate");
182
+ if (a)
183
+ return u.attr(a, {
184
184
  attributeName: t,
185
185
  from: e,
186
186
  to: i,
@@ -188,7 +188,7 @@ function B(r, t, e, i, s = "0.4s", n = "0.1s") {
188
188
  begin: "click + " + n
189
189
  // artificial click
190
190
  }), r;
191
- const a = w("animate", {
191
+ const o = $("animate", {
192
192
  attributeName: t,
193
193
  from: e,
194
194
  to: i,
@@ -199,7 +199,7 @@ function B(r, t, e, i, s = "0.4s", n = "0.1s") {
199
199
  keyTimes: "0; 1",
200
200
  keySplines: G("ease-out")
201
201
  });
202
- return r.appendChild(a), r;
202
+ return r.appendChild(o), r;
203
203
  }
204
204
  function G(r) {
205
205
  return {
@@ -210,30 +210,30 @@ function G(r) {
210
210
  "ease-in-out": ".42 0 .58 1"
211
211
  }[r];
212
212
  }
213
- m.on = (r, t, e, i) => {
214
- i ? m.delegate(r, t, e, i) : (i = e, m.bind(r, t, i));
213
+ u.on = (r, t, e, i) => {
214
+ i ? u.delegate(r, t, e, i) : (i = e, u.bind(r, t, i));
215
215
  };
216
- m.off = (r, t, e) => {
216
+ u.off = (r, t, e) => {
217
217
  r.removeEventListener(t, e);
218
218
  };
219
- m.bind = (r, t, e) => {
219
+ u.bind = (r, t, e) => {
220
220
  t.split(/\s+/).forEach(function(i) {
221
221
  r.addEventListener(i, e);
222
222
  });
223
223
  };
224
- m.delegate = (r, t, e, i) => {
224
+ u.delegate = (r, t, e, i) => {
225
225
  r.addEventListener(t, function(s) {
226
226
  const n = s.target.closest(e);
227
227
  n && (s.delegatedTarget = n, i.call(this, s, n));
228
228
  });
229
229
  };
230
- m.closest = (r, t) => t ? t.matches(r) ? t : m.closest(r, t.parentNode) : null;
231
- m.attr = (r, t, e) => {
230
+ u.closest = (r, t) => t ? t.matches(r) ? t : u.closest(r, t.parentNode) : null;
231
+ u.attr = (r, t, e) => {
232
232
  if (!e && typeof t == "string")
233
233
  return r.getAttribute(t);
234
234
  if (typeof t == "object") {
235
235
  for (let i in t)
236
- m.attr(r, i, t[i]);
236
+ u.attr(r, i, t[i]);
237
237
  return;
238
238
  }
239
239
  r.setAttribute(t, e);
@@ -241,92 +241,92 @@ m.attr = (r, t, e) => {
241
241
  function I(r, t, e, i, s = "downstream") {
242
242
  if (i === "none" || e === 0) return /* @__PURE__ */ new Map();
243
243
  ["upstream", "downstream", "both"].includes(s) || (console.warn(`[frappe-gantt] compute_dependency_shifts: unknown direction "${s}", falling back to "downstream"`), s = "downstream");
244
- const n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
245
- for (const h of r)
246
- h._has_no_dates || (n.set(h.id, h), o.set(h.id, []), a.set(h.id, []));
247
- for (const h of r)
248
- if (!h._has_no_dates)
249
- for (const d of h.dependencies || []) {
250
- if (!n.has(d.id)) continue;
251
- const _ = d.type || "finish-to-start";
252
- o.get(h.id).push({ id: d.id, type: _ }), a.get(d.id).push({ id: h.id, type: _ });
244
+ const n = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
245
+ for (const d of r)
246
+ d._has_no_dates || (n.set(d.id, d), a.set(d.id, []), o.set(d.id, []));
247
+ for (const d of r)
248
+ if (!d._has_no_dates)
249
+ for (const h of d.dependencies || []) {
250
+ if (!n.has(h.id)) continue;
251
+ const _ = h.type || "finish-to-start";
252
+ a.get(d.id).push({ id: h.id, type: _ }), o.get(h.id).push({ id: d.id, type: _ });
253
253
  }
254
- return i === "maintain_buffer_all" || i === "maintain_buffer_downstream" ? q(t, e, o, a, s === "both", s === "upstream") : i === "consume_buffer" ? R(t, e, n, o, a, s) : /* @__PURE__ */ new Map();
254
+ return i === "maintain_buffer_all" || i === "maintain_buffer_downstream" ? q(t, e, a, o, s === "both", s === "upstream") : i === "consume_buffer" ? U(t, e, n, a, o, s) : /* @__PURE__ */ new Map();
255
255
  }
256
256
  function q(r, t, e, i, s, n) {
257
- const o = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set([r]), h = [], d = (_) => {
258
- for (const { id: c } of _)
259
- a.has(c) || (a.add(c), h.push(c));
257
+ const a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([r]), d = [], h = (_) => {
258
+ for (const { id: l } of _)
259
+ o.has(l) || (o.add(l), d.push(l));
260
260
  };
261
- for (n && !s ? d(e.get(r) || []) : (d(i.get(r) || []), s && d(e.get(r) || [])); h.length > 0; ) {
262
- const _ = h.shift();
263
- o.set(_, t), n && !s ? d(e.get(_) || []) : (d(i.get(_) || []), s && d(e.get(_) || []));
261
+ for (n && !s ? h(e.get(r) || []) : (h(i.get(r) || []), s && h(e.get(r) || [])); d.length > 0; ) {
262
+ const _ = d.shift();
263
+ a.set(_, t), n && !s ? h(e.get(_) || []) : (h(i.get(_) || []), s && h(e.get(_) || []));
264
264
  }
265
- return o;
265
+ return a;
266
266
  }
267
- function R(r, t, e, i, s, n) {
268
- const o = /* @__PURE__ */ new Map();
269
- for (const [l] of e)
270
- o.set(l, (i.get(l) || []).length);
271
- const a = [], h = [];
272
- for (const [l, f] of o)
273
- f === 0 && h.push(l);
274
- for (; h.length > 0; ) {
275
- const l = h.shift();
276
- a.push(l);
277
- for (const { id: f } of s.get(l) || []) {
278
- const u = o.get(f) - 1;
279
- o.set(f, u), u === 0 && h.push(f);
267
+ function U(r, t, e, i, s, n) {
268
+ const a = /* @__PURE__ */ new Map();
269
+ for (const [c] of e)
270
+ a.set(c, (i.get(c) || []).length);
271
+ const o = [], d = [];
272
+ for (const [c, m] of a)
273
+ m === 0 && d.push(c);
274
+ for (; d.length > 0; ) {
275
+ const c = d.shift();
276
+ o.push(c);
277
+ for (const { id: m } of s.get(c) || []) {
278
+ const f = a.get(m) - 1;
279
+ a.set(m, f), f === 0 && d.push(m);
280
280
  }
281
281
  }
282
- const d = /* @__PURE__ */ new Map([[r, 0]]), _ = (l) => e.get(l)._start.getTime() + (d.get(l) || 0), c = (l) => e.get(l)._end.getTime() + (d.get(l) || 0);
282
+ const h = /* @__PURE__ */ new Map([[r, 0]]), _ = (c) => e.get(c)._start.getTime() + (h.get(c) || 0), l = (c) => e.get(c)._end.getTime() + (h.get(c) || 0);
283
283
  if (n === "downstream" || n === "both")
284
- for (const l of a) {
285
- if (l === r) continue;
286
- let f = 0;
287
- for (const { id: u, type: b } of i.get(l) || []) {
288
- const y = F(u, l, b, _, c);
289
- y > f && (f = y);
284
+ for (const c of o) {
285
+ if (c === r) continue;
286
+ let m = 0;
287
+ for (const { id: f, type: w } of i.get(c) || []) {
288
+ const y = W(f, c, w, _, l);
289
+ y > m && (m = y);
290
290
  }
291
- f > 0 && d.set(l, (d.get(l) || 0) + f);
291
+ m > 0 && h.set(c, (h.get(c) || 0) + m);
292
292
  }
293
293
  if (n === "upstream" || n === "both")
294
- for (let l = a.length - 1; l >= 0; l--) {
295
- const f = a[l];
296
- if (f === r) continue;
297
- let u = 0;
298
- for (const { id: b, type: y } of s.get(f) || []) {
299
- const k = F(f, b, y, _, c);
300
- if (k > 0) {
301
- const $ = -k;
302
- $ < u && (u = $);
294
+ for (let c = o.length - 1; c >= 0; c--) {
295
+ const m = o[c];
296
+ if (m === r) continue;
297
+ let f = 0;
298
+ for (const { id: w, type: y } of s.get(m) || []) {
299
+ const x = W(m, w, y, _, l);
300
+ if (x > 0) {
301
+ const b = -x;
302
+ b < f && (f = b);
303
303
  }
304
304
  }
305
- u < 0 && d.set(f, (d.get(f) || 0) + u);
305
+ f < 0 && h.set(m, (h.get(m) || 0) + f);
306
306
  }
307
307
  const p = /* @__PURE__ */ new Map();
308
- for (const [l, f] of d)
309
- l !== r && f !== 0 && p.set(l, f);
308
+ for (const [c, m] of h)
309
+ c !== r && m !== 0 && p.set(c, m);
310
310
  return p;
311
311
  }
312
- function F(r, t, e, i, s) {
313
- const n = i(r), o = s(r), a = i(t), h = s(t);
312
+ function W(r, t, e, i, s) {
313
+ const n = i(r), a = s(r), o = i(t), d = s(t);
314
314
  switch (e) {
315
315
  case "finish-to-start":
316
- return o > a ? o - a : 0;
316
+ return a > o ? a - o : 0;
317
317
  case "start-to-start":
318
- return n > a ? n - a : 0;
318
+ return n > o ? n - o : 0;
319
319
  case "finish-to-finish":
320
- return o > h ? o - h : 0;
320
+ return a > d ? a - d : 0;
321
321
  case "start-to-finish":
322
- return n > h ? n - h : 0;
322
+ return n > d ? n - d : 0;
323
323
  default:
324
- return o > a ? o - a : 0;
324
+ return a > o ? a - o : 0;
325
325
  }
326
326
  }
327
- class U {
327
+ class Q {
328
328
  constructor(t, e, i, s) {
329
- this.gantt = t, this.from_task = e, this.to_task = i, this.dependency_type = s, this.is_critical = this.check_critical_path(), this.is_invalid = this.check_invalid_dependency(), this.is_hovered = !1, this.calculate_path(), this.draw();
329
+ this.gantt = t, this.from_task = e, this.to_task = i, this.dependency_type = s, this.is_critical = this.check_critical_path(), this.is_invalid = this.check_invalid_dependency(), this.is_hovered = !1, this.is_active = !1, this.calculate_path(), this.draw();
330
330
  }
331
331
  check_critical_path() {
332
332
  return this.gantt.options.critical_path ? this.from_task.task._is_critical === !0 && this.to_task.task._is_critical === !0 : !1;
@@ -346,128 +346,185 @@ class U {
346
346
  return !1;
347
347
  }
348
348
  calculate_path() {
349
- const t = this.gantt.options, e = this.gantt.config, i = t.arrow_curve, s = t.padding, n = this.from_task.$bar.getX() + this.from_task.$bar.getWidth(), o = this.from_task.$bar.getX(), a = this.to_task.$bar.getX() + this.to_task.$bar.getWidth(), h = this.to_task.$bar.getX(), d = (l) => e.header_height + t.bar_height / 2 + (t.padding + t.bar_height) * l.task._index + t.padding / 2, _ = d(this.from_task), c = d(this.to_task), p = (_ + c) / 2;
349
+ const t = this.gantt.options, e = this.gantt.config, i = t.arrow_curve, s = t.padding, n = this.from_task.$bar.getX() + this.from_task.$bar.getWidth(), a = this.from_task.$bar.getX(), o = this.to_task.$bar.getX() + this.to_task.$bar.getWidth(), d = this.to_task.$bar.getX(), h = (c) => e.header_height + t.bar_height / 2 + (t.padding + t.bar_height) * c.task._index + t.padding / 2, _ = h(this.from_task), l = h(this.to_task), p = (_ + l) / 2;
350
350
  switch (this.dependency_type) {
351
351
  case "finish-to-start":
352
352
  this.path = this._path_finish_to_start(
353
353
  n,
354
- o,
355
354
  a,
356
- h,
355
+ o,
356
+ d,
357
357
  _,
358
- c,
358
+ l,
359
359
  p,
360
360
  s,
361
361
  i
362
- );
362
+ ), this.label_pos = { x: d, y: l, side: "left" };
363
363
  break;
364
364
  case "start-to-start":
365
365
  this.path = this._path_start_to_start(
366
- o,
367
- h,
366
+ a,
367
+ d,
368
368
  _,
369
- c,
369
+ l,
370
370
  s,
371
371
  i
372
- );
372
+ ), this.label_pos = { x: d, y: l, side: "left" };
373
373
  break;
374
374
  case "finish-to-finish":
375
375
  this.path = this._path_finish_to_finish(
376
376
  n,
377
- a,
377
+ o,
378
378
  _,
379
- c,
379
+ l,
380
380
  s,
381
381
  i
382
- );
382
+ ), this.label_pos = { x: o, y: l, side: "right" };
383
383
  break;
384
384
  case "start-to-finish":
385
385
  this.path = this._path_start_to_finish(
386
- o,
387
386
  a,
387
+ o,
388
388
  _,
389
- c,
389
+ l,
390
390
  p,
391
391
  s,
392
392
  i
393
- );
393
+ ), this.label_pos = { x: o, y: l, side: "right" };
394
394
  break;
395
395
  default:
396
396
  this.path = this._path_finish_to_start(
397
397
  n,
398
- o,
399
398
  a,
400
- h,
399
+ o,
400
+ d,
401
401
  _,
402
- c,
402
+ l,
403
403
  p,
404
404
  s,
405
405
  i
406
- );
406
+ ), this.label_pos = { x: d, y: l, side: "left" };
407
407
  }
408
408
  }
409
- _path_finish_to_start(t, e, i, s, n, o, a, h, d) {
410
- const _ = t + h;
409
+ _path_finish_to_start(t, e, i, s, n, a, o, d, h) {
410
+ const _ = t + d, l = a < n;
411
411
  if (_ < s)
412
- return `
413
- M ${t} ${n}
414
- H ${_ - d}
415
- a ${d} ${d} 0 0 1 ${d} ${d}
416
- V ${o - d}
417
- a ${d} ${d} 0 0 0 ${d} ${d}
418
- H ${s}
419
- m -5 -5 l 5 5 l -5 5`;
420
- const c = s - h;
421
- return `
412
+ return l ? `
413
+ M ${t} ${n}
414
+ H ${_ - h}
415
+ a ${h} ${h} 0 0 0 ${h} ${-h}
416
+ V ${a + h}
417
+ a ${h} ${h} 0 0 1 ${h} ${-h}
418
+ H ${s}
419
+ m -5 -5 l 5 5 l -5 5` : `
420
+ M ${t} ${n}
421
+ H ${_ - h}
422
+ a ${h} ${h} 0 0 1 ${h} ${h}
423
+ V ${a - h}
424
+ a ${h} ${h} 0 0 0 ${h} ${h}
425
+ H ${s}
426
+ m -5 -5 l 5 5 l -5 5`;
427
+ const p = s - d;
428
+ return l ? `
429
+ M ${t} ${n}
430
+ H ${_ - h}
431
+ a ${h} ${h} 0 0 0 ${h} ${-h}
432
+ V ${o + h}
433
+ a ${h} ${h} 0 0 0 ${-h} ${-h}
434
+ H ${p + h}
435
+ a ${h} ${h} 0 0 1 ${-h} ${-h}
436
+ V ${a + h}
437
+ a ${h} ${h} 0 0 1 ${h} ${-h}
438
+ H ${s}
439
+ m -5 -5 l 5 5 l -5 5` : `
422
440
  M ${t} ${n}
423
- H ${_ - d}
424
- a ${d} ${d} 0 0 1 ${d} ${d}
425
- V ${a - d}
426
- a ${d} ${d} 0 0 1 ${-d} ${d}
427
- H ${c + d}
428
- a ${d} ${d} 0 0 0 ${-d} ${d}
429
- V ${o - d}
430
- a ${d} ${d} 0 0 0 ${d} ${d}
441
+ H ${_ - h}
442
+ a ${h} ${h} 0 0 1 ${h} ${h}
443
+ V ${o - h}
444
+ a ${h} ${h} 0 0 1 ${-h} ${h}
445
+ H ${p + h}
446
+ a ${h} ${h} 0 0 0 ${-h} ${h}
447
+ V ${a - h}
448
+ a ${h} ${h} 0 0 0 ${h} ${h}
431
449
  H ${s}
432
450
  m -5 -5 l 5 5 l -5 5`;
433
451
  }
434
- _path_start_to_start(t, e, i, s, n, o) {
435
- const a = Math.min(t, e) - n;
436
- return `
452
+ _path_start_to_start(t, e, i, s, n, a) {
453
+ const o = Math.min(t, e) - n;
454
+ return s < i ? `
437
455
  M ${t} ${i}
438
- H ${a + o}
439
- a ${o} ${o} 0 0 0 ${-o} ${o}
440
- V ${s - o}
441
- a ${o} ${o} 0 0 0 ${o} ${o}
456
+ H ${o + a}
457
+ a ${a} ${a} 0 0 1 ${-a} ${-a}
458
+ V ${s + a}
459
+ a ${a} ${a} 0 0 1 ${a} ${-a}
460
+ H ${e}
461
+ m -5 -5 l 5 5 l -5 5` : `
462
+ M ${t} ${i}
463
+ H ${o + a}
464
+ a ${a} ${a} 0 0 0 ${-a} ${a}
465
+ V ${s - a}
466
+ a ${a} ${a} 0 0 0 ${a} ${a}
442
467
  H ${e}
443
468
  m -5 -5 l 5 5 l -5 5`;
444
469
  }
445
- _path_finish_to_finish(t, e, i, s, n, o) {
446
- const a = Math.max(t, e) + n;
447
- return `
470
+ _path_finish_to_finish(t, e, i, s, n, a) {
471
+ const o = Math.max(t, e) + n;
472
+ return s < i ? `
448
473
  M ${t} ${i}
449
- H ${a - o}
450
- a ${o} ${o} 0 0 1 ${o} ${o}
451
- V ${s - o}
452
- a ${o} ${o} 0 0 1 ${-o} ${o}
474
+ H ${o - a}
475
+ a ${a} ${a} 0 0 0 ${a} ${-a}
476
+ V ${s + a}
477
+ a ${a} ${a} 0 0 0 ${-a} ${-a}
453
478
  H ${e}
454
- m 5 -5 l -5 5 l 5 5`;
455
- }
456
- _path_start_to_finish(t, e, i, s, n, o, a) {
457
- const h = t - o, d = e + o;
458
- return `
479
+ m 5 -5 l -5 5 l 5 5` : `
459
480
  M ${t} ${i}
460
- H ${h + a}
461
- a ${a} ${a} 0 0 0 ${-a} ${a}
462
- V ${n - a}
463
- a ${a} ${a} 0 0 0 ${a} ${a}
464
- H ${d - a}
481
+ H ${o - a}
465
482
  a ${a} ${a} 0 0 1 ${a} ${a}
466
483
  V ${s - a}
467
484
  a ${a} ${a} 0 0 1 ${-a} ${a}
468
485
  H ${e}
469
486
  m 5 -5 l -5 5 l 5 5`;
470
487
  }
488
+ _path_start_to_finish(t, e, i, s, n, a, o) {
489
+ const d = t - a, h = e + a, _ = s < i;
490
+ return h < d + 2 * o ? _ ? `
491
+ M ${t} ${i}
492
+ H ${d + o}
493
+ a ${o} ${o} 0 0 1 ${-o} ${-o}
494
+ V ${s + o}
495
+ a ${o} ${o} 0 0 0 ${-o} ${-o}
496
+ H ${e}
497
+ m 5 -5 l -5 5 l 5 5` : `
498
+ M ${t} ${i}
499
+ H ${d + o}
500
+ a ${o} ${o} 0 0 0 ${-o} ${o}
501
+ V ${s - o}
502
+ a ${o} ${o} 0 0 1 ${-o} ${o}
503
+ H ${e}
504
+ m 5 -5 l -5 5 l 5 5` : _ ? `
505
+ M ${t} ${i}
506
+ H ${d + o}
507
+ a ${o} ${o} 0 0 1 ${-o} ${-o}
508
+ V ${n + o}
509
+ a ${o} ${o} 0 0 1 ${o} ${-o}
510
+ H ${h - o}
511
+ a ${o} ${o} 0 0 0 ${o} ${-o}
512
+ V ${s + o}
513
+ a ${o} ${o} 0 0 0 ${-o} ${-o}
514
+ H ${e}
515
+ m 5 -5 l -5 5 l 5 5` : `
516
+ M ${t} ${i}
517
+ H ${d + o}
518
+ a ${o} ${o} 0 0 0 ${-o} ${o}
519
+ V ${n - o}
520
+ a ${o} ${o} 0 0 0 ${o} ${o}
521
+ H ${h - o}
522
+ a ${o} ${o} 0 0 1 ${o} ${o}
523
+ V ${s - o}
524
+ a ${o} ${o} 0 0 1 ${-o} ${o}
525
+ H ${e}
526
+ m 5 -5 l -5 5 l 5 5`;
527
+ }
471
528
  _get_connected_bars() {
472
529
  const t = this.from_task.task.id, e = this.to_task.task.id;
473
530
  return Array.from(
@@ -478,12 +535,12 @@ class U {
478
535
  }
479
536
  draw() {
480
537
  let t = "";
481
- this.is_invalid ? t = "arrow-invalid" : this.is_critical && (t = "arrow-critical"), this.element = w("path", {
538
+ this.is_invalid ? t = "arrow-invalid" : this.is_critical && (t = "arrow-critical"), this.element = $("path", {
482
539
  d: this.path,
483
540
  "data-from": this.from_task.task.id,
484
541
  "data-to": this.to_task.task.id,
485
542
  class: t
486
- }), this.hit_element = w("path", {
543
+ }), this.hit_element = $("path", {
487
544
  d: this.path,
488
545
  stroke: "transparent",
489
546
  "stroke-width": 15,
@@ -495,21 +552,72 @@ class U {
495
552
  this._get_connected_bars().forEach((i) => {
496
553
  const s = i.querySelector(".bar");
497
554
  s && s.classList.add(e);
498
- });
555
+ }), this._show_label();
499
556
  }), this.hit_element.addEventListener("mouseleave", () => {
500
557
  this.is_hovered = !1, this.element.classList.remove("arrow-hover"), this._get_connected_bars().forEach((e) => {
501
558
  const i = e.querySelector(".bar");
502
- i && i.classList.remove("bar-arrow-hover", "bar-arrow-critical", "bar-arrow-invalid");
503
- });
559
+ i && (i.classList.remove("bar-arrow-hover"), this.is_active || i.classList.remove("bar-arrow-critical", "bar-arrow-invalid"));
560
+ }), !this.is_active && !this.is_hovered && this._hide_label();
561
+ }), this.hit_element.addEventListener("click", (e) => {
562
+ e.stopPropagation(), this.is_active ? this.gantt.set_active_arrow(null) : this.gantt.set_active_arrow(this);
563
+ });
564
+ }
565
+ _get_type_abbr() {
566
+ return {
567
+ "finish-to-start": "FS",
568
+ "start-to-start": "SS",
569
+ "finish-to-finish": "FF",
570
+ "start-to-finish": "SF"
571
+ }[this.dependency_type] || "FS";
572
+ }
573
+ _show_label() {
574
+ if (this.label_element) return;
575
+ const t = this._get_type_abbr(), e = 21, i = 20, { x: s, y: n, side: a } = this.label_pos, o = a === "left" ? s - 10 - e / 2 : s + 10 + e / 2, d = n;
576
+ this.label_element = $("g", { class: "arrow-type-label" });
577
+ const h = $("rect", {
578
+ x: o - e / 2,
579
+ y: d - i / 2,
580
+ width: e,
581
+ height: i,
582
+ rx: 3
583
+ }), _ = $("text", {
584
+ x: o,
585
+ y: d,
586
+ "dominant-baseline": "middle",
587
+ "text-anchor": "middle"
588
+ });
589
+ _.textContent = t, this.label_element.appendChild(h), this.label_element.appendChild(_), this.label_element.addEventListener("mouseenter", () => {
590
+ this.hit_element.dispatchEvent(new MouseEvent("mouseenter", { bubbles: !1 }));
591
+ }), this.label_element.addEventListener("mouseleave", () => {
592
+ this.hit_element.dispatchEvent(new MouseEvent("mouseleave", { bubbles: !1 }));
593
+ }), this.label_element.addEventListener("click", (l) => {
594
+ l.stopPropagation(), this.hit_element.dispatchEvent(new MouseEvent("click", { bubbles: !1 }));
595
+ }), this.gantt.layers.arrow.appendChild(this.label_element);
596
+ }
597
+ _hide_label() {
598
+ this.label_element && (this.label_element.remove(), this.label_element = null);
599
+ }
600
+ activate() {
601
+ this.is_active = !0, this.element.classList.add("arrow-active"), this._show_label();
602
+ const t = this.is_invalid ? "bar-arrow-invalid" : this.is_critical ? "bar-arrow-critical" : "bar-arrow-active";
603
+ this._get_connected_bars().forEach((e) => {
604
+ const i = e.querySelector(".bar");
605
+ i && i.classList.add(t);
606
+ });
607
+ }
608
+ deactivate() {
609
+ this.is_active = !1, this.element.classList.remove("arrow-active"), this._hide_label(), this._get_connected_bars().forEach((t) => {
610
+ const e = t.querySelector(".bar");
611
+ e && e.classList.remove("bar-arrow-active", "bar-arrow-critical", "bar-arrow-invalid");
504
612
  });
505
613
  }
506
614
  update() {
507
615
  this.calculate_path(), this.element.setAttribute("d", this.path), this.hit_element.setAttribute("d", this.path), this.is_invalid = this.check_invalid_dependency();
508
616
  let t = "";
509
- this.is_invalid ? t = "arrow-invalid" : this.is_critical && (t = "arrow-critical"), this.is_hovered && (t += " arrow-hover"), this.element.setAttribute("class", t.trim());
617
+ this.is_invalid ? t = "arrow-invalid" : this.is_critical && (t = "arrow-critical"), this.is_hovered && (t += " arrow-hover"), this.is_active && (t += " arrow-active"), this.element.setAttribute("class", t.trim());
510
618
  }
511
619
  }
512
- class Q {
620
+ class K {
513
621
  constructor(t, e) {
514
622
  this.set_defaults(t, e), this.prepare_wrappers(), this.prepare_helpers(), this.refresh();
515
623
  }
@@ -520,13 +628,13 @@ class Q {
520
628
  this.action_completed = !1, this.gantt = t, this.task = e, this.name = this.name || "", this.is_dragging = !1, this.is_hovering_bar = !1, this.is_hovering_icon = !1, this.add_icon_hide_timeout = null;
521
629
  }
522
630
  prepare_wrappers() {
523
- this.group = w("g", {
631
+ this.group = $("g", {
524
632
  class: "bar-wrapper" + (this.task.custom_class ? " " + this.task.custom_class : ""),
525
633
  "data-id": this.task.id
526
- }), this.bar_group = w("g", {
634
+ }), this.bar_group = $("g", {
527
635
  class: "bar-group",
528
636
  append_to: this.group
529
- }), this.handle_group = w("g", {
637
+ }), this.handle_group = $("g", {
530
638
  class: "handle-group",
531
639
  append_to: this.group
532
640
  });
@@ -551,10 +659,10 @@ class Q {
551
659
  this.compute_expected_progress(), this.expected_progress_width = this.gantt.options.column_width * this.duration * (this.expected_progress / 100) || 0;
552
660
  }
553
661
  draw() {
554
- this.draw_bar(), this.draw_progress_bar(), this.gantt.options.show_expected_progress && (this.prepare_expected_progress_values(), this.draw_expected_progress_bar()), this.draw_label(), this.draw_resize_handles(), this.task.thumbnail && this.draw_thumbnail(), this.gantt.options.task_add_icon_position && this.draw_add_task_icon();
662
+ this.draw_bar(), this.draw_progress_bar(), this.gantt.options.show_expected_progress && (this.prepare_expected_progress_values(), this.draw_expected_progress_bar()), this.draw_label(), this.draw_resize_handles(), this.task.thumbnail && this.draw_thumbnail(), this.gantt.options.task_add_icon_position && this.draw_add_task_icon(), this.draw_connector_circles();
555
663
  }
556
664
  draw_bar() {
557
- this.$bar = w("rect", {
665
+ this.$bar = $("rect", {
558
666
  x: this.x,
559
667
  y: this.y,
560
668
  width: this.width,
@@ -566,7 +674,7 @@ class Q {
566
674
  }), this.task.color && (this.$bar.style.fill = this.task.color), z(this.$bar, "width", 0, this.width), this.invalid && this.$bar.classList.add("bar-invalid");
567
675
  }
568
676
  draw_expected_progress_bar() {
569
- this.invalid || (this.$expected_bar_progress = w("rect", {
677
+ this.invalid || (this.$expected_bar_progress = $("rect", {
570
678
  x: this.x,
571
679
  y: this.y,
572
680
  width: this.expected_progress_width,
@@ -586,7 +694,7 @@ class Q {
586
694
  if (this.invalid) return;
587
695
  this.progress_width = this.calculate_progress_width();
588
696
  let t = this.corner_radius;
589
- /^((?!chrome|android).)*safari/i.test(navigator.userAgent) || (t = this.corner_radius + 2), this.$bar_progress = w("rect", {
697
+ /^((?!chrome|android).)*safari/i.test(navigator.userAgent) || (t = this.corner_radius + 2), this.$bar_progress = $("rect", {
590
698
  x: this.x,
591
699
  y: this.y,
592
700
  width: this.progress_width,
@@ -610,15 +718,15 @@ class Q {
610
718
  this.$date_highlight = i, this.gantt.$lower_header.prepend(this.$date_highlight), z(this.$bar_progress, "width", 0, this.progress_width);
611
719
  }
612
720
  calculate_progress_width() {
613
- const t = this.$bar.getWidth(), e = this.x + t, i = this.gantt.config.ignored_positions.reduce((h, d) => h + (d >= this.x && d < e), 0) * this.gantt.config.column_width;
721
+ const t = this.$bar.getWidth(), e = this.x + t, i = this.gantt.config.ignored_positions.reduce((d, h) => d + (h >= this.x && h < e), 0) * this.gantt.config.column_width;
614
722
  let s = (t - i) * this.task.progress / 100;
615
- const n = this.x + s, o = this.gantt.config.ignored_positions.reduce((h, d) => h + (d >= this.x && d < n), 0) * this.gantt.config.column_width;
616
- s += o;
617
- let a = this.gantt.get_ignored_region(
723
+ const n = this.x + s, a = this.gantt.config.ignored_positions.reduce((d, h) => d + (h >= this.x && h < n), 0) * this.gantt.config.column_width;
724
+ s += a;
725
+ let o = this.gantt.get_ignored_region(
618
726
  this.x + s
619
727
  );
620
- for (; a.length; )
621
- s += this.gantt.config.column_width, a = this.gantt.get_ignored_region(
728
+ for (; o.length; )
729
+ s += this.gantt.config.column_width, o = this.gantt.get_ignored_region(
622
730
  this.x + s
623
731
  );
624
732
  return this.progress_width = s, s;
@@ -627,7 +735,7 @@ class Q {
627
735
  let t = this.x + this.$bar.getWidth() / 2;
628
736
  this.task.thumbnail && (t = this.x + this.image_size + 5);
629
737
  const e = this.gantt.options.task_column.enabled ? "" : this.task.name;
630
- this.$bar_label = w("text", {
738
+ this.$bar_label = $("text", {
631
739
  x: t,
632
740
  y: this.y + this.height / 2,
633
741
  innerHTML: e,
@@ -637,9 +745,9 @@ class Q {
637
745
  }
638
746
  draw_thumbnail() {
639
747
  let t = 10, e = 2, i, s;
640
- i = w("defs", {
748
+ i = $("defs", {
641
749
  append_to: this.bar_group
642
- }), w("rect", {
750
+ }), $("rect", {
643
751
  id: "rect_" + this.task.id,
644
752
  x: this.x + t,
645
753
  y: this.y + e,
@@ -648,13 +756,13 @@ class Q {
648
756
  rx: "15",
649
757
  class: "img_mask",
650
758
  append_to: i
651
- }), s = w("clipPath", {
759
+ }), s = $("clipPath", {
652
760
  id: "clip_" + this.task.id,
653
761
  append_to: i
654
- }), w("use", {
762
+ }), $("use", {
655
763
  href: "#rect_" + this.task.id,
656
764
  append_to: s
657
- }), w("image", {
765
+ }), $("image", {
658
766
  x: this.x + t,
659
767
  y: this.y + e,
660
768
  width: this.image_size,
@@ -675,38 +783,38 @@ class Q {
675
783
  else
676
784
  return;
677
785
  const s = this.y + (this.height - 20) / 2;
678
- this.$add_icon_group = w("g", {
786
+ this.$add_icon_group = $("g", {
679
787
  class: "add-task-icon hide",
680
788
  append_to: this.handle_group
681
- }), this.$add_icon_circle = w("circle", {
789
+ }), this.$add_icon_circle = $("circle", {
682
790
  cx: i + 20 / 2,
683
791
  cy: s + 20 / 2,
684
792
  r: 20 / 2,
685
793
  class: "add-task-icon-bg",
686
794
  append_to: this.$add_icon_group
687
- }), this.$add_icon_vertical = w("line", {
795
+ }), this.$add_icon_vertical = $("line", {
688
796
  x1: i + 20 / 2,
689
797
  y1: s + 5,
690
798
  x2: i + 20 / 2,
691
799
  y2: s + 20 - 5,
692
800
  class: "add-task-icon-plus",
693
801
  append_to: this.$add_icon_group
694
- }), this.$add_icon_horizontal = w("line", {
802
+ }), this.$add_icon_horizontal = $("line", {
695
803
  x1: i + 5,
696
804
  y1: s + 20 / 2,
697
805
  x2: i + 20 - 5,
698
806
  y2: s + 20 / 2,
699
807
  class: "add-task-icon-plus",
700
808
  append_to: this.$add_icon_group
701
- }), m.on(this.$add_icon_group, "mousedown", (n) => {
809
+ }), u.on(this.$add_icon_group, "mousedown", (n) => {
702
810
  n.stopPropagation();
703
- }), m.on(this.$add_icon_group, "mouseup", (n) => {
811
+ }), u.on(this.$add_icon_group, "mouseup", (n) => {
704
812
  n.stopPropagation();
705
- }), m.on(this.$add_icon_group, "click", (n) => {
813
+ }), u.on(this.$add_icon_group, "click", (n) => {
706
814
  n.stopPropagation(), this.gantt.trigger_event("task_add", [this.task]);
707
- }), m.on(this.$add_icon_group, "mouseenter", (n) => {
815
+ }), u.on(this.$add_icon_group, "mouseenter", (n) => {
708
816
  this.is_hovering_icon = !0, this.add_icon_hide_timeout && (clearTimeout(this.add_icon_hide_timeout), this.add_icon_hide_timeout = null), this.$add_icon_group.classList.add("active"), this.$add_icon_group.classList.remove("hide"), n.stopPropagation();
709
- }), m.on(this.$add_icon_group, "mouseleave", () => {
817
+ }), u.on(this.$add_icon_group, "mouseleave", () => {
710
818
  this.is_hovering_icon = !1, this.$add_icon_group.classList.remove("active"), this.is_hovering_bar || this.$add_icon_group.classList.add("hide");
711
819
  });
712
820
  }
@@ -714,7 +822,7 @@ class Q {
714
822
  if (this.invalid || this.gantt.options.readonly) return;
715
823
  const t = this.$bar, e = 8;
716
824
  if (this.handles = [], this.gantt.options.readonly_dates || (this.handles.push(
717
- w("rect", {
825
+ $("rect", {
718
826
  x: t.getEndX() - e,
719
827
  y: t.getY() + (this.height - this.height * 0.8) / 2,
720
828
  width: e,
@@ -725,7 +833,7 @@ class Q {
725
833
  append_to: this.handle_group
726
834
  })
727
835
  ), this.handles.push(
728
- w("rect", {
836
+ $("rect", {
729
837
  x: t.getX() - e,
730
838
  y: t.getY() + (this.height - this.height * 0.8) / 2,
731
839
  width: e,
@@ -737,7 +845,7 @@ class Q {
737
845
  })
738
846
  )), !this.gantt.options.readonly_progress) {
739
847
  const i = this.$bar_progress;
740
- this.$handle_progress = w("circle", {
848
+ this.$handle_progress = $("circle", {
741
849
  cx: i.getEndX(),
742
850
  cy: i.getY() + i.getHeight() / 2,
743
851
  r: 4.5,
@@ -746,14 +854,38 @@ class Q {
746
854
  }), this.handles.push(this.$handle_progress);
747
855
  }
748
856
  for (let i of this.handles)
749
- m.on(i, "mouseenter", () => i.classList.add("active")), m.on(i, "mouseleave", () => i.classList.remove("active"));
857
+ u.on(i, "mouseenter", () => i.classList.add("active")), u.on(i, "mouseleave", () => i.classList.remove("active"));
858
+ }
859
+ draw_connector_circles() {
860
+ if (this.$connector_start = null, this.$connector_end = null, !this.gantt.options.allow_dependency_creation || this.gantt.options.readonly) return;
861
+ const t = this.gantt.options.isRTL, e = this.y + this.height / 2, i = t ? this.x + this.width : this.x, s = t ? this.x : this.x + this.width;
862
+ this.$connector_start = $("circle", {
863
+ class: "connector-circle connector-start",
864
+ "data-endpoint": "start",
865
+ cx: i,
866
+ cy: e,
867
+ r: 4,
868
+ append_to: this.handle_group
869
+ }), this.$connector_end = $("circle", {
870
+ class: "connector-circle connector-end",
871
+ "data-endpoint": "end",
872
+ cx: s,
873
+ cy: e,
874
+ r: 4,
875
+ append_to: this.handle_group
876
+ });
877
+ }
878
+ update_connector_circles() {
879
+ if (!this.$connector_start) return;
880
+ const t = this.gantt.options.isRTL, e = this.$bar.getX(), i = this.$bar.getWidth(), s = this.y + this.height / 2, n = t ? e + i : e, a = t ? e : e + i;
881
+ this.$connector_start.setAttribute("cx", n), this.$connector_start.setAttribute("cy", s), this.$connector_end.setAttribute("cx", a), this.$connector_end.setAttribute("cy", s);
750
882
  }
751
883
  bind() {
752
884
  this.invalid || this.setup_click_event();
753
885
  }
754
886
  unbind() {
755
887
  this.invalid || this.group && this.event_listeners && (this.event_listeners.forEach(({ event: t, handler: e }) => {
756
- m.off(this.group, t, e);
888
+ u.off(this.group, t, e);
757
889
  }), this.event_listeners = []);
758
890
  }
759
891
  setup_click_event() {
@@ -767,21 +899,21 @@ class Q {
767
899
  p
768
900
  ]);
769
901
  };
770
- if (m.on(this.group, "mouseover", e), this.event_listeners.push({ event: "mouseover", handler: e }), this.gantt.options.popup_on === "click") {
771
- const p = (l) => {
772
- const f = l.offsetX || l.layerX;
902
+ if (u.on(this.group, "mouseover", e), this.event_listeners.push({ event: "mouseover", handler: e }), this.gantt.options.popup_on === "click") {
903
+ const p = (c) => {
904
+ const m = c.offsetX || c.layerX;
773
905
  if (this.$handle_progress) {
774
- const u = +this.$handle_progress.getAttribute("cx");
775
- if (u > f - 1 && u < f + 1 || this.gantt.bar_being_dragged) return;
906
+ const f = +this.$handle_progress.getAttribute("cx");
907
+ if (f > m - 1 && f < m + 1 || this.gantt.bar_being_dragged) return;
776
908
  }
777
909
  this.gantt.show_popup({
778
- x: l.offsetX || l.layerX,
779
- y: l.offsetY || l.layerY,
910
+ x: c.offsetX || c.layerX,
911
+ y: c.offsetY || c.layerY,
780
912
  task: this.task,
781
913
  target: this.$bar
782
914
  });
783
915
  };
784
- m.on(this.group, "click", p), this.event_listeners.push({ event: "click", handler: p });
916
+ u.on(this.group, "click", p), this.event_listeners.push({ event: "click", handler: p });
785
917
  }
786
918
  let i;
787
919
  const s = (p) => {
@@ -792,56 +924,56 @@ class Q {
792
924
  task: this.task,
793
925
  target: this.$bar
794
926
  });
795
- const l = this.gantt.$container.querySelector(`.highlight-${CSS.escape(t)}`);
796
- l && l.classList.remove("hide");
927
+ const c = this.gantt.$container.querySelector(`.highlight-${CSS.escape(t)}`);
928
+ c && c.classList.remove("hide");
797
929
  }, 200), this.$add_icon_group && (this.is_hovering_bar = !0, this.add_icon_hide_timeout && (clearTimeout(this.add_icon_hide_timeout), this.add_icon_hide_timeout = null), this.is_dragging || this.$add_icon_group.classList.remove("hide"));
798
930
  };
799
- m.on(this.group, "mouseenter", s), this.event_listeners.push({ event: "mouseenter", handler: s });
931
+ u.on(this.group, "mouseenter", s), this.event_listeners.push({ event: "mouseenter", handler: s });
800
932
  const n = () => {
801
- var l, f;
802
- clearTimeout(i), this.gantt.options.popup_on === "hover" && ((f = (l = this.gantt.popup) == null ? void 0 : l.hide) == null || f.call(l));
933
+ var c, m;
934
+ clearTimeout(i), this.gantt.options.popup_on === "hover" && ((m = (c = this.gantt.popup) == null ? void 0 : c.hide) == null || m.call(c));
803
935
  const p = this.gantt.$container.querySelector(`.highlight-${CSS.escape(t)}`);
804
936
  p && p.classList.add("hide"), this.$add_icon_group && (this.is_hovering_bar = !1, this.add_icon_hide_timeout && clearTimeout(this.add_icon_hide_timeout), this.add_icon_hide_timeout = setTimeout(() => {
805
937
  this.is_hovering_icon || this.$add_icon_group.classList.add("hide");
806
938
  }, 200));
807
939
  };
808
- m.on(this.group, "mouseleave", n), this.event_listeners.push({ event: "mouseleave", handler: n });
809
- const o = () => {
940
+ u.on(this.group, "mouseleave", n), this.event_listeners.push({ event: "mouseleave", handler: n });
941
+ const a = () => {
810
942
  this.is_dragging = !0, this.hide_add_icon();
811
943
  };
812
- m.on(this.group, "mousedown", o), this.event_listeners.push({ event: "mousedown", handler: o });
813
- const a = () => {
944
+ u.on(this.group, "mousedown", a), this.event_listeners.push({ event: "mousedown", handler: a });
945
+ const o = () => {
814
946
  setTimeout(() => {
815
947
  this.gantt.bar_being_dragged !== !0 && (this.is_dragging = !1, this.$add_icon_group && this.is_hovering_bar && this.$add_icon_group.classList.remove("hide"));
816
948
  }, 0);
817
949
  };
818
- m.on(this.group, "mouseup", a), this.event_listeners.push({ event: "mouseup", handler: a });
819
- const h = () => {
950
+ u.on(this.group, "mouseup", o), this.event_listeners.push({ event: "mouseup", handler: o });
951
+ const d = () => {
820
952
  this.action_completed || this.gantt.bar_being_dragged || this.gantt.trigger_event("click", [this.task]);
821
953
  };
822
- m.on(this.group, "click", h), this.event_listeners.push({ event: "click", handler: h });
823
- const d = () => {
954
+ u.on(this.group, "click", d), this.event_listeners.push({ event: "click", handler: d });
955
+ const h = () => {
824
956
  this.action_completed || (this.group.classList.remove("active"), this.gantt.popup && this.gantt.popup.parent.classList.remove("hide"), this.gantt.trigger_event("double_click", [this.task]));
825
957
  };
826
- m.on(this.group, "dblclick", d), this.event_listeners.push({ event: "dblclick", handler: d });
958
+ u.on(this.group, "dblclick", h), this.event_listeners.push({ event: "dblclick", handler: h });
827
959
  let _ = !1;
828
- const c = (p) => {
960
+ const l = (p) => {
829
961
  if (!_)
830
962
  return _ = !0, setTimeout(function() {
831
963
  _ = !1;
832
964
  }, 300), !1;
833
965
  p.preventDefault(), !this.action_completed && (this.group.classList.remove("active"), this.gantt.popup && this.gantt.popup.parent.classList.remove("hide"), this.gantt.trigger_event("double_click", [this.task]));
834
966
  };
835
- m.on(this.group, "touchstart", c), this.event_listeners.push({ event: "touchstart", handler: c });
967
+ u.on(this.group, "touchstart", l), this.event_listeners.push({ event: "touchstart", handler: l });
836
968
  }
837
969
  update_bar_position({ x: t = null, width: e = null }) {
838
970
  const i = this.$bar;
839
- t && (this.update_attr(i, "x", t), this.x = t, this.$date_highlight.style.left = t + "px"), e > 0 && (this.update_attr(i, "width", e), this.$date_highlight.style.width = e + "px"), this.update_label_position(), this.update_handle_position(), this.update_add_icon_position(), this.date_changed(), this.compute_duration(), this.gantt.options.show_expected_progress && this.update_expected_progressbar_position(), this.update_progressbar_position(), this.update_arrow_position();
971
+ t && (this.update_attr(i, "x", t), this.x = t, this.$date_highlight.style.left = t + "px"), e > 0 && (this.update_attr(i, "width", e), this.$date_highlight.style.width = e + "px"), this.update_label_position(), this.update_handle_position(), this.update_add_icon_position(), this.date_changed(), this.compute_duration(), this.gantt.options.show_expected_progress && this.update_expected_progressbar_position(), this.update_progressbar_position(), this.update_arrow_position(), this.update_connector_circles();
840
972
  }
841
973
  update_label_position_on_horizontal_scroll({ x: t, sx: e }) {
842
- const i = this.gantt.$container, s = this.group.querySelector(".bar-label"), n = this.group.querySelector(".bar-img") || "", o = this.bar_group.querySelector(".img_mask") || "";
843
- let a = this.$bar.getX() + this.$bar.getWidth(), h = s.getX() + t, d = n && n.getX() + t || 0, _ = n && n.getBBox().width + 7 || 7, c = h + s.getBBox().width + 7, p = e + i.clientWidth / 2;
844
- s.classList.contains("big") || (c < a && t > 0 && c < p || h - _ > this.$bar.getX() && t < 0 && c > p) && (s.setAttribute("x", h), n && (n.setAttribute("x", d), o.setAttribute("x", d)));
974
+ const i = this.gantt.$container, s = this.group.querySelector(".bar-label"), n = this.group.querySelector(".bar-img") || "", a = this.bar_group.querySelector(".img_mask") || "";
975
+ let o = this.$bar.getX() + this.$bar.getWidth(), d = s.getX() + t, h = n && n.getX() + t || 0, _ = n && n.getBBox().width + 7 || 7, l = d + s.getBBox().width + 7, p = e + i.clientWidth / 2;
976
+ s.classList.contains("big") || (l < o && t > 0 && l < p || d - _ > this.$bar.getX() && t < 0 && l > p) && (s.setAttribute("x", d), n && (n.setAttribute("x", h), a.setAttribute("x", h)));
845
977
  }
846
978
  date_changed() {
847
979
  let t = !1;
@@ -924,14 +1056,14 @@ class Q {
924
1056
  }
925
1057
  update_label_position() {
926
1058
  const t = this.bar_group.querySelector(".img_mask") || "", e = this.$bar, i = this.group.querySelector(".bar-label"), s = this.group.querySelector(".bar-img");
927
- let n = 5, o = this.image_size + 10;
928
- const a = i.getBBox().width, h = e.getWidth();
929
- a > h ? (i.classList.add("big"), s ? (s.setAttribute("x", e.getEndX() + n), t.setAttribute("x", e.getEndX() + n), i.setAttribute("x", e.getEndX() + o)) : i.setAttribute("x", e.getEndX() + n)) : (i.classList.remove("big"), s ? (s.setAttribute("x", e.getX() + n), t.setAttribute("x", e.getX() + n), i.setAttribute(
1059
+ let n = 5, a = this.image_size + 10;
1060
+ const o = i.getBBox().width, d = e.getWidth();
1061
+ o > d ? (i.classList.add("big"), s ? (s.setAttribute("x", e.getEndX() + n), t.setAttribute("x", e.getEndX() + n), i.setAttribute("x", e.getEndX() + a)) : i.setAttribute("x", e.getEndX() + n)) : (i.classList.remove("big"), s ? (s.setAttribute("x", e.getX() + n), t.setAttribute("x", e.getX() + n), i.setAttribute(
930
1062
  "x",
931
- e.getX() + h / 2 + o
1063
+ e.getX() + d / 2 + a
932
1064
  )) : i.setAttribute(
933
1065
  "x",
934
- e.getX() + h / 2 - a / 2
1066
+ e.getX() + d / 2 - o / 2
935
1067
  ));
936
1068
  }
937
1069
  update_handle_position() {
@@ -963,7 +1095,7 @@ class Q {
963
1095
  t.update();
964
1096
  }
965
1097
  }
966
- class K {
1098
+ class J {
967
1099
  constructor(t, e, i) {
968
1100
  this.parent = t, this.popup_func = e, this.gantt = i, this.make();
969
1101
  }
@@ -981,18 +1113,18 @@ class K {
981
1113
  task: i,
982
1114
  chart: this.gantt,
983
1115
  get_title: () => this.title,
984
- set_title: (o) => this.title.innerHTML = o,
1116
+ set_title: (a) => this.title.innerHTML = a,
985
1117
  get_subtitle: () => this.subtitle,
986
- set_subtitle: (o) => this.subtitle.innerHTML = o,
1118
+ set_subtitle: (a) => this.subtitle.innerHTML = a,
987
1119
  get_details: () => this.details,
988
- set_details: (o) => this.details.innerHTML = o,
989
- add_action: (o, a) => {
990
- let h = this.gantt.create_el({
1120
+ set_details: (a) => this.details.innerHTML = a,
1121
+ add_action: (a, o) => {
1122
+ let d = this.gantt.create_el({
991
1123
  classes: "action-btn",
992
1124
  type: "button",
993
1125
  append_to: this.actions
994
1126
  });
995
- typeof o == "function" && (o = o(i)), h.innerHTML = o, h.onclick = (d) => a(i, this.gantt, d);
1127
+ typeof a == "function" && (a = a(i)), d.innerHTML = a, d.onclick = (h) => o(i, this.gantt, h);
996
1128
  }
997
1129
  });
998
1130
  n !== !1 && (n && (this.parent.innerHTML = n), this.actions.innerHTML === "" ? this.actions.remove() : this.parent.appendChild(this.actions), this.parent.style.left = t + 10 + "px", this.parent.style.top = e - 10 + "px", this.parent.classList.remove("hide"));
@@ -1005,11 +1137,11 @@ function C(r) {
1005
1137
  const t = r.getFullYear();
1006
1138
  return t - t % 10 + "";
1007
1139
  }
1008
- function J(r, t, e) {
1140
+ function Z(r, t, e) {
1009
1141
  let i = g.add(r, 6, "day"), s = i.getMonth() !== r.getMonth() ? "D MMM" : "D", n = !t || r.getMonth() !== t.getMonth() ? "D MMM" : "D";
1010
1142
  return `${g.format(r, n, e)} - ${g.format(i, s, e)}`;
1011
1143
  }
1012
- const x = [
1144
+ const k = [
1013
1145
  {
1014
1146
  name: "Hour",
1015
1147
  padding: "7d",
@@ -1052,7 +1184,7 @@ const x = [
1052
1184
  step: "7d",
1053
1185
  date_format: "YYYY-MM-DD",
1054
1186
  column_width: 140,
1055
- lower_text: J,
1187
+ lower_text: Z,
1056
1188
  upper_text: (r, t, e) => !t || r.getMonth() !== t.getMonth() ? g.format(r, "MMMM", e) : "",
1057
1189
  thick_line: (r) => r.getDate() >= 1 && r.getDate() <= 7,
1058
1190
  upper_text_frequency: 4
@@ -1078,7 +1210,8 @@ const x = [
1078
1210
  lower_text: "YYYY",
1079
1211
  snap_at: "30d"
1080
1212
  }
1081
- ], Z = {
1213
+ ], B = {
1214
+ allow_dependency_creation: !0,
1082
1215
  arrow_curve: 5,
1083
1216
  auto_move_label: !1,
1084
1217
  bar_corner_radius: 3,
@@ -1125,7 +1258,7 @@ const x = [
1125
1258
  today_button: !0,
1126
1259
  view_mode: "Day",
1127
1260
  view_mode_select: !1,
1128
- view_modes: x,
1261
+ view_modes: k,
1129
1262
  is_weekend: (r) => r.getDay() === 0 || r.getDay() === 6,
1130
1263
  task_column: {
1131
1264
  enabled: !1,
@@ -1156,7 +1289,7 @@ class tt {
1156
1289
  throw new TypeError(
1157
1290
  "Frappe Gantt only supports usage of a string CSS selector, HTML DOM element or SVG DOM element for the 'element' parameter"
1158
1291
  );
1159
- e ? (this.$svg = e, this.$svg.classList.add("gantt")) : this.$svg = w("svg", {
1292
+ e ? (this.$svg = e, this.$svg.classList.add("gantt")) : this.$svg = $("svg", {
1160
1293
  append_to: i,
1161
1294
  class: "gantt"
1162
1295
  }), this.$wrapper = this.create_el({
@@ -1177,15 +1310,15 @@ class tt {
1177
1310
  var i;
1178
1311
  this.original_options = t, t != null && t.view_modes && (t.view_modes = t.view_modes.map((s) => {
1179
1312
  if (typeof s == "string") {
1180
- const n = x.find(
1181
- (o) => o.name === s
1313
+ const n = k.find(
1314
+ (a) => a.name === s
1182
1315
  );
1183
1316
  return n || console.error(
1184
1317
  `The view mode "${s}" is not predefined in Frappe Gantt. Please define the view mode object instead.`
1185
1318
  ), n;
1186
1319
  }
1187
1320
  return s;
1188
- }), t.view_mode = t.view_modes[0]), this.options = { ...Z, ...t };
1321
+ }), t.view_mode = t.view_modes[0]), this.options = { ...B, ...t };
1189
1322
  const e = {
1190
1323
  "grid-height": "container_height",
1191
1324
  "bar-height": "bar_height",
@@ -1246,9 +1379,9 @@ class tt {
1246
1379
  return console.error(`task "${e.id}" doesn't have an end date`), !1;
1247
1380
  }
1248
1381
  if (!e._has_no_dates) {
1249
- if (e._start = g.parse(e.start), e.end === void 0 && e.duration !== void 0 && (e.end = e._start, e.duration.split(" ").forEach((h) => {
1250
- let { duration: d, scale: _ } = g.parse_duration(h);
1251
- e.end = g.add(e.end, d, _);
1382
+ if (e._start = g.parse(e.start), e.end === void 0 && e.duration !== void 0 && (e.end = e._start, e.duration.split(" ").forEach((d) => {
1383
+ let { duration: h, scale: _ } = g.parse_duration(d);
1384
+ e.end = g.add(e.end, h, _);
1252
1385
  })), e._end = g.parse(e.end), g.diff(e._end, e._start, "year") < 0)
1253
1386
  return console.error(
1254
1387
  `start of task can't be after end of task: in task "${e.id}"`
@@ -1257,7 +1390,7 @@ class tt {
1257
1390
  return console.error(
1258
1391
  `the duration of task "${e.id}" is too long (above ten years)`
1259
1392
  ), !1;
1260
- e._index = i, g.get_date_values(e._end).slice(3).every((a) => a === 0) && (e._end = g.add(e._end, 24, "hour"));
1393
+ e._index = i, g.get_date_values(e._end).slice(3).every((o) => o === 0) && (e._end = g.add(e._end, 24, "hour"));
1261
1394
  }
1262
1395
  return (typeof e.dependencies == "string" || Array.isArray(e.dependencies) && e.dependencies.some((n) => typeof n == "string")) && console.warn(`[frappe-gantt] Task "${e.id}": dependencies must be an array of {id, type?} objects. String format is no longer supported.`), Array.isArray(e.dependencies) || (e.dependencies = []), e.dependencies = e.dependencies.filter((n) => n && typeof n.id == "string").map((n) => ({ ...n, id: n.id.replaceAll(" ", "_") })), e.id ? typeof e.id == "string" ? e.id = e.id.replaceAll(" ", "_") : e.id = `${e.id}` : e.id = et(e), e;
1263
1396
  }).filter((e) => e).map((e, i) => (e._index = i, e)), this.setup_dependencies();
@@ -1272,9 +1405,9 @@ class tt {
1272
1405
  this.setup_tasks(t), this.change_view_mode(this.options.view_mode, e);
1273
1406
  }
1274
1407
  update_task(t, e) {
1275
- let i = this.tasks.find((o) => o.id === t), s = this.bars[i._index];
1408
+ let i = this.tasks.find((a) => a.id === t), s = this.bars[i._index];
1276
1409
  const n = e.dependencies !== void 0;
1277
- Object.assign(i, e), n && (Array.isArray(i.dependencies) || (i.dependencies = []), i.dependencies = i.dependencies.filter((o) => o && typeof o.id == "string").map((o) => ({ ...o, id: o.id.replaceAll(" ", "_") })), this.setup_dependencies(), this.layers.arrow.innerHTML = "", this.make_arrows(), this.map_arrows_on_bars()), s.refresh();
1410
+ Object.assign(i, e), n && (Array.isArray(i.dependencies) || (i.dependencies = []), i.dependencies = i.dependencies.filter((a) => a && typeof a.id == "string").map((a) => ({ ...a, id: a.id.replaceAll(" ", "_") })), this.setup_dependencies(), this.layers.arrow.innerHTML = "", this.make_arrows(), this.map_arrows_on_bars()), s.refresh();
1278
1411
  }
1279
1412
  change_view_mode(t = this.options.view_mode, e = !1) {
1280
1413
  typeof t == "string" && (t = this.options.view_modes.find((n) => n.name === t));
@@ -1337,7 +1470,7 @@ class tt {
1337
1470
  ), this.dates.push(t);
1338
1471
  }
1339
1472
  bind_events() {
1340
- this.bind_grid_click(), this.bind_holiday_labels(), this.bind_bar_events(), this.bind_task_column_resize(), this.bind_task_column_scroll();
1473
+ this.bind_grid_click(), this.bind_holiday_labels(), this.bind_bar_events(), this.bind_task_column_resize(), this.bind_task_column_scroll(), this.options.allow_dependency_creation && this.bind_dependency_linking();
1341
1474
  }
1342
1475
  render() {
1343
1476
  this.clear(), this.setup_layers(), this.make_grid(), this.make_dates(), this.make_grid_extras(), this.make_bars(), this.make_arrows(), this.map_arrows_on_bars(), this.set_dimensions(), this.set_scroll_position(this.options.scroll_to);
@@ -1346,11 +1479,14 @@ class tt {
1346
1479
  this.layers = {};
1347
1480
  const t = ["grid", "arrow", "progress", "bar"];
1348
1481
  for (let e of t)
1349
- this.layers[e] = w("g", {
1482
+ this.layers[e] = $("g", {
1350
1483
  class: e,
1351
1484
  append_to: this.$svg
1352
1485
  });
1353
- this.$extras = this.create_el({
1486
+ this.options.allow_dependency_creation && (this.layers.linking = $("g", {
1487
+ class: "linking",
1488
+ append_to: this.$svg
1489
+ })), this.$extras = this.create_el({
1354
1490
  classes: "extras",
1355
1491
  append_to: this.$container
1356
1492
  }), this.$adjust = this.create_el({
@@ -1370,23 +1506,23 @@ class tt {
1370
1506
  this.config.header_height + this.options.padding + (this.options.bar_height + this.options.padding) * this.tasks.length - 10,
1371
1507
  this.options.container_height !== "auto" ? this.options.container_height : 0
1372
1508
  );
1373
- w("rect", {
1509
+ $("rect", {
1374
1510
  x: 0,
1375
1511
  y: 0,
1376
1512
  width: t,
1377
1513
  height: e,
1378
1514
  class: "grid-background",
1379
1515
  append_to: this.$svg
1380
- }), m.attr(this.$svg, {
1516
+ }), u.attr(this.$svg, {
1381
1517
  height: e,
1382
1518
  width: "100%"
1383
1519
  }), this.grid_height = e, this.options.container_height === "auto" && (this.$container.style.height = e + "px");
1384
1520
  }
1385
1521
  make_grid_rows() {
1386
- const t = w("g", { append_to: this.layers.grid }), e = this.dates.length * this.config.column_width, i = this.options.bar_height + this.options.padding;
1522
+ const t = $("g", { append_to: this.layers.grid }), e = this.dates.length * this.config.column_width, i = this.options.bar_height + this.options.padding;
1387
1523
  this.config.header_height;
1388
1524
  for (let s = this.config.header_height; s < this.grid_height; s += i)
1389
- w("rect", {
1525
+ $("rect", {
1390
1526
  x: 0,
1391
1527
  y: s,
1392
1528
  width: e,
@@ -1431,12 +1567,12 @@ class tt {
1431
1567
  }
1432
1568
  }
1433
1569
  make_task_column() {
1434
- var i, s, n, o, a, h, d, _, c, p;
1570
+ var i, s, n, a, o, d, h, _, l, p;
1435
1571
  if ((i = this.$task_column) == null || i.remove(), !((s = this.options.task_column) != null && s.enabled)) {
1436
- (o = (n = this.$wrapper) == null ? void 0 : n.classList) == null || o.remove("has-task-column");
1572
+ (a = (n = this.$wrapper) == null ? void 0 : n.classList) == null || a.remove("has-task-column");
1437
1573
  return;
1438
1574
  }
1439
- (h = (a = this.$wrapper) == null ? void 0 : a.classList) == null || h.add("has-task-column"), this.$task_column = this.create_el({
1575
+ (d = (o = this.$wrapper) == null ? void 0 : o.classList) == null || d.add("has-task-column"), this.$task_column = this.create_el({
1440
1576
  classes: "task-column",
1441
1577
  append_to: this.$wrapper
1442
1578
  }), this.$wrapper.insertBefore(this.$task_column, this.$container), this.$task_column_header = this.create_el({
@@ -1456,47 +1592,47 @@ class tt {
1456
1592
  ), this.$container.style.setProperty(
1457
1593
  "--gv-task-column-content-height",
1458
1594
  e + "px"
1459
- ), this.tasks.forEach((l) => {
1460
- const f = this.options.bar_height + this.options.padding, u = this.create_el({
1595
+ ), this.tasks.forEach((c) => {
1596
+ const m = this.options.bar_height + this.options.padding, f = this.create_el({
1461
1597
  classes: "task-row",
1462
1598
  append_to: this.$task_column_content
1463
1599
  });
1464
- if (u.style.top = l._index * f - 1 + "px", u.style.height = f + "px", this.options.task_column.content && typeof this.options.task_column.content == "function") {
1465
- const b = this.options.task_column.content(l);
1466
- typeof b == "string" ? u.innerHTML = b : b instanceof HTMLElement && u.appendChild(b);
1600
+ if (f.style.top = c._index * m - 1 + "px", f.style.height = m + "px", this.options.task_column.content && typeof this.options.task_column.content == "function") {
1601
+ const w = this.options.task_column.content(c);
1602
+ typeof w == "string" ? f.innerHTML = w : w instanceof HTMLElement && f.appendChild(w);
1467
1603
  } else
1468
- u.textContent = l.name, u.title = l.name;
1469
- u.setAttribute("data-task-id", l.id);
1604
+ f.textContent = c.name, f.title = c.name;
1605
+ f.setAttribute("data-task-id", c.id);
1470
1606
  }), this.$task_column.style.width = this.options.task_column.width + "px", this.$task_column_resize_handle = this.create_el({
1471
1607
  classes: "task-column-resize-handle",
1472
1608
  append_to: this.$task_column
1473
- }), this.options.isRTL ? (_ = (d = this.$wrapper) == null ? void 0 : d.classList) == null || _.add("rtl") : (p = (c = this.$wrapper) == null ? void 0 : c.classList) == null || p.remove("rtl");
1609
+ }), this.options.isRTL ? (_ = (h = this.$wrapper) == null ? void 0 : h.classList) == null || _.add("rtl") : (p = (l = this.$wrapper) == null ? void 0 : l.classList) == null || p.remove("rtl");
1474
1610
  }
1475
1611
  make_grid_ticks() {
1476
1612
  if (this.options.lines === "none") return;
1477
- let t = 0, e = this.config.header_height, i = this.grid_height - this.config.header_height, s = w("g", {
1613
+ let t = 0, e = this.config.header_height, i = this.grid_height - this.config.header_height, s = $("g", {
1478
1614
  class: "lines_layer",
1479
1615
  append_to: this.layers.grid
1480
1616
  }), n = this.config.header_height;
1481
- const o = this.dates.length * this.config.column_width, a = this.options.bar_height + this.options.padding;
1617
+ const a = this.dates.length * this.config.column_width, o = this.options.bar_height + this.options.padding;
1482
1618
  if (this.options.lines !== "vertical")
1483
- for (let h = this.config.header_height; h < this.grid_height; h += a)
1484
- w("line", {
1619
+ for (let d = this.config.header_height; d < this.grid_height; d += o)
1620
+ $("line", {
1485
1621
  x1: 0,
1486
- y1: n + a,
1487
- x2: o,
1488
- y2: n + a,
1622
+ y1: n + o,
1623
+ x2: a,
1624
+ y2: n + o,
1489
1625
  class: "row-line",
1490
1626
  append_to: s
1491
- }), n += a;
1627
+ }), n += o;
1492
1628
  if (this.options.lines !== "horizontal")
1493
- for (let h of this.dates) {
1494
- let d = "tick";
1495
- this.config.view_mode.thick_line && this.config.view_mode.thick_line(h) && (d += " thick"), w("path", {
1629
+ for (let d of this.dates) {
1630
+ let h = "tick";
1631
+ this.config.view_mode.thick_line && this.config.view_mode.thick_line(d) && (h += " thick"), $("path", {
1496
1632
  d: `M ${t} ${e} v ${i}`,
1497
- class: d,
1633
+ class: h,
1498
1634
  append_to: this.layers.grid
1499
- }), this.view_is("month") ? t += g.get_days_in_month(h) * this.config.column_width / 30 : this.view_is("year") ? t += g.get_days_in_year(h) * this.config.column_width / 365 : t += this.config.column_width;
1635
+ }), this.view_is("month") ? t += g.get_days_in_month(d) * this.config.column_width / 30 : this.view_is("year") ? t += g.get_days_in_year(d) * this.config.column_width / 365 : t += this.config.column_width;
1500
1636
  }
1501
1637
  }
1502
1638
  highlight_holidays() {
@@ -1507,44 +1643,44 @@ class tt {
1507
1643
  i === "weekend" && (i = this.options.is_weekend);
1508
1644
  let s;
1509
1645
  if (typeof i == "object") {
1510
- let n = i.find((o) => typeof o == "function");
1646
+ let n = i.find((a) => typeof a == "function");
1511
1647
  if (n && (s = n), this.options.holidays.name) {
1512
- let o = /* @__PURE__ */ new Date(i.date + " ");
1513
- i = (a) => o.getTime() === a.getTime(), t[o] = i.name;
1648
+ let a = /* @__PURE__ */ new Date(i.date + " ");
1649
+ i = (o) => a.getTime() === o.getTime(), t[a] = i.name;
1514
1650
  } else
1515
- i = (o) => this.options.holidays[e].filter((a) => typeof a != "function").map((a) => {
1516
- if (a.name) {
1517
- let h = /* @__PURE__ */ new Date(a.date + " ");
1518
- return t[h] = a.name, h.getTime();
1651
+ i = (a) => this.options.holidays[e].filter((o) => typeof o != "function").map((o) => {
1652
+ if (o.name) {
1653
+ let d = /* @__PURE__ */ new Date(o.date + " ");
1654
+ return t[d] = o.name, d.getTime();
1519
1655
  }
1520
- return (/* @__PURE__ */ new Date(a + " ")).getTime();
1521
- }).includes(o.getTime());
1656
+ return (/* @__PURE__ */ new Date(o + " ")).getTime();
1657
+ }).includes(a.getTime());
1522
1658
  }
1523
1659
  for (let n = new Date(this.gantt_start); n <= this.gantt_end; n.setDate(n.getDate() + 1))
1524
1660
  if (!(this.config.ignored_dates.find(
1525
- (o) => o.getTime() == n.getTime()
1661
+ (a) => a.getTime() == n.getTime()
1526
1662
  ) || this.config.ignored_function && this.config.ignored_function(n)) && (i(n) || s && s(n))) {
1527
- const o = g.diff(
1663
+ const a = g.diff(
1528
1664
  n,
1529
1665
  this.gantt_start,
1530
1666
  this.config.unit
1531
- ) / this.config.step * this.config.column_width, a = this.grid_height - this.config.header_height, h = g.format(n, "YYYY-MM-DD", this.options.language).replace(" ", "_");
1667
+ ) / this.config.step * this.config.column_width, o = this.grid_height - this.config.header_height, d = g.format(n, "YYYY-MM-DD", this.options.language).replace(" ", "_");
1532
1668
  if (t[n]) {
1533
- let d = this.create_el({
1534
- classes: "holiday-label label_" + h,
1669
+ let h = this.create_el({
1670
+ classes: "holiday-label label_" + d,
1535
1671
  append_to: this.$extras
1536
1672
  });
1537
- d.textContent = t[n];
1673
+ h.textContent = t[n];
1538
1674
  }
1539
- w("rect", {
1540
- x: Math.round(o),
1675
+ $("rect", {
1676
+ x: Math.round(a),
1541
1677
  y: this.config.header_height,
1542
1678
  width: this.config.column_width / g.convert_scales(
1543
1679
  this.config.view_mode.step,
1544
1680
  "day"
1545
1681
  ),
1546
- height: a,
1547
- class: "holiday-highlight " + h,
1682
+ height: o,
1683
+ class: "holiday-highlight " + d,
1548
1684
  style: `fill: ${e};`,
1549
1685
  append_to: this.layers.grid
1550
1686
  });
@@ -1599,7 +1735,7 @@ class tt {
1599
1735
  g.diff(i, this.gantt_start) + "d",
1600
1736
  this.config.unit
1601
1737
  ) / this.config.step;
1602
- this.config.ignored_positions.push(s * this.config.column_width), w("rect", {
1738
+ this.config.ignored_positions.push(s * this.config.column_width), $("rect", {
1603
1739
  x: s * this.config.column_width,
1604
1740
  y: this.config.header_height,
1605
1741
  width: this.config.column_width,
@@ -1613,10 +1749,10 @@ class tt {
1613
1749
  this.config.view_mode
1614
1750
  );
1615
1751
  }
1616
- create_el({ left: t, top: e, width: i, height: s, id: n, classes: o, append_to: a, type: h }) {
1617
- let d = document.createElement(h || "div");
1618
- for (let _ of o.split(" ")) d.classList.add(_);
1619
- return d.style.top = e + "px", d.style.left = t + "px", n && (d.id = n), i && (d.style.width = i + "px"), s && (d.style.height = s + "px"), a && a.appendChild(d), d;
1752
+ create_el({ left: t, top: e, width: i, height: s, id: n, classes: a, append_to: o, type: d }) {
1753
+ let h = document.createElement(d || "div");
1754
+ for (let _ of a.split(" ")) h.classList.add(_);
1755
+ return h.style.top = e + "px", h.style.left = t + "px", n && (h.id = n), i && (h.style.width = i + "px"), s && (h.style.height = s + "px"), o && o.appendChild(h), h;
1620
1756
  }
1621
1757
  make_dates() {
1622
1758
  this.get_dates_to_draw().forEach((t, e) => {
@@ -1653,8 +1789,8 @@ class tt {
1653
1789
  let i = e ? e.date : null;
1654
1790
  this.config.column_width;
1655
1791
  const s = e ? e.x + e.column_width : 0;
1656
- let n = this.config.view_mode.upper_text, o = this.config.view_mode.lower_text;
1657
- return n ? typeof n == "string" && (this.config.view_mode.upper_text = (a) => g.format(a, n, this.options.language)) : this.config.view_mode.upper_text = () => "", o ? typeof o == "string" && (this.config.view_mode.lower_text = (a) => g.format(a, o, this.options.language)) : this.config.view_mode.lower_text = () => "", {
1792
+ let n = this.config.view_mode.upper_text, a = this.config.view_mode.lower_text;
1793
+ return n ? typeof n == "string" && (this.config.view_mode.upper_text = (o) => g.format(o, n, this.options.language)) : this.config.view_mode.upper_text = () => "", a ? typeof a == "string" && (this.config.view_mode.lower_text = (o) => g.format(o, a, this.options.language)) : this.config.view_mode.lower_text = () => "", {
1658
1794
  date: t,
1659
1795
  formatted_date: D(
1660
1796
  g.format(
@@ -1683,26 +1819,26 @@ class tt {
1683
1819
  this.bars = this.tasks.map((t) => {
1684
1820
  if (t._has_no_dates)
1685
1821
  return null;
1686
- const e = new Q(this, t);
1822
+ const e = new K(this, t);
1687
1823
  return this.layers.bar.appendChild(e.group), e;
1688
1824
  }).filter((t) => t !== null);
1689
1825
  }
1690
1826
  make_arrows() {
1691
- this.arrows = [], this.options.critical_path && this.calculate_critical_path();
1827
+ this.arrows = [], this.active_arrow = null, this.options.critical_path && this.calculate_critical_path();
1692
1828
  for (let t of this.tasks) {
1693
1829
  let e = [];
1694
1830
  e = t.dependencies.map((i) => {
1695
1831
  const s = this.get_task(i.id);
1696
1832
  if (!s) return;
1697
- const n = this.bars[s._index], o = this.bars[t._index];
1698
- if (!n || !o) return;
1699
- const a = i.type || this.options.dependencies_type || "finish-to-start", h = new U(
1833
+ const n = this.bars[s._index], a = this.bars[t._index];
1834
+ if (!n || !a) return;
1835
+ const o = i.type || this.options.dependencies_type || "finish-to-start", d = new Q(
1700
1836
  this,
1701
1837
  n,
1702
- o,
1703
- a
1838
+ a,
1839
+ o
1704
1840
  );
1705
- return this.layers.arrow.appendChild(h.element), this.layers.arrow.appendChild(h.hit_element), h;
1841
+ return this.layers.arrow.appendChild(d.element), this.layers.arrow.appendChild(d.hit_element), d;
1706
1842
  }).filter(Boolean), this.arrows = this.arrows.concat(e);
1707
1843
  }
1708
1844
  }
@@ -1714,35 +1850,35 @@ class tt {
1714
1850
  });
1715
1851
  const e = (n) => {
1716
1852
  if (t[n.id].ef > 0) return t[n.id];
1717
- let o = 0;
1718
- n.dependencies && n.dependencies.length > 0 && n.dependencies.forEach((h) => {
1719
- const d = this.get_task(h.id);
1720
- if (d) {
1721
- const _ = e(d);
1722
- o = Math.max(o, _.ef);
1853
+ let a = 0;
1854
+ n.dependencies && n.dependencies.length > 0 && n.dependencies.forEach((d) => {
1855
+ const h = this.get_task(d.id);
1856
+ if (h) {
1857
+ const _ = e(h);
1858
+ a = Math.max(a, _.ef);
1723
1859
  }
1724
- }), t[n.id].es = o;
1725
- const a = g.diff(n._end, n._start, "hour") / 24;
1726
- return t[n.id].ef = o + a, t[n.id];
1860
+ }), t[n.id].es = a;
1861
+ const o = g.diff(n._end, n._start, "hour") / 24;
1862
+ return t[n.id].ef = a + o, t[n.id];
1727
1863
  };
1728
1864
  this.tasks.forEach((n) => e(n));
1729
1865
  const i = Math.max(...Object.values(t).map((n) => n.ef)), s = (n) => {
1730
1866
  if (t[n.id].ls > 0 || t[n.id].lf > 0)
1731
1867
  return t[n.id];
1732
- const o = this.tasks.filter(
1733
- (d) => d.dependencies && d.dependencies.some((_) => _.id === n.id)
1868
+ const a = this.tasks.filter(
1869
+ (h) => h.dependencies && h.dependencies.some((_) => _.id === n.id)
1734
1870
  );
1735
- let a = i;
1736
- o.length > 0 && o.forEach((d) => {
1737
- const _ = s(d);
1738
- a = Math.min(a, _.ls);
1871
+ let o = i;
1872
+ a.length > 0 && a.forEach((h) => {
1873
+ const _ = s(h);
1874
+ o = Math.min(o, _.ls);
1739
1875
  });
1740
- const h = g.diff(n._end, n._start, "hour") / 24;
1741
- return t[n.id].lf = a, t[n.id].ls = a - h, t[n.id];
1876
+ const d = g.diff(n._end, n._start, "hour") / 24;
1877
+ return t[n.id].lf = o, t[n.id].ls = o - d, t[n.id];
1742
1878
  };
1743
1879
  this.tasks.forEach((n) => s(n)), this.tasks.forEach((n) => {
1744
- const o = t[n.id], a = o.ls - o.es;
1745
- n._is_critical = Math.abs(a) < 0.01;
1880
+ const a = t[n.id], o = a.ls - a.es;
1881
+ n._is_critical = Math.abs(o) < 0.01;
1746
1882
  });
1747
1883
  }
1748
1884
  update_arrow_critical_path() {
@@ -1760,8 +1896,8 @@ class tt {
1760
1896
  }
1761
1897
  set_scroll_position(t) {
1762
1898
  if (this.options.infinite_padding && (!t || t === "start")) {
1763
- let [o, ...a] = this.get_start_end_positions();
1764
- this.$container.scrollLeft = o;
1899
+ let [a, ...o] = this.get_start_end_positions();
1900
+ this.$container.scrollLeft = a;
1765
1901
  return;
1766
1902
  }
1767
1903
  if (!t || t === "start")
@@ -1791,7 +1927,7 @@ class tt {
1791
1927
  null,
1792
1928
  this.options.language
1793
1929
  ), n = this.upperTexts.find(
1794
- (o) => o.textContent === s
1930
+ (a) => a.textContent === s
1795
1931
  );
1796
1932
  this.current_date = g.add(
1797
1933
  this.gantt_start,
@@ -1801,7 +1937,7 @@ class tt {
1801
1937
  this.current_date,
1802
1938
  null,
1803
1939
  this.options.language
1804
- ), n = this.upperTexts.find((o) => o.textContent === s), n.classList.add("current-upper"), this.$current = n;
1940
+ ), n = this.upperTexts.find((a) => a.textContent === s), n.classList.add("current-upper"), this.$current = n;
1805
1941
  }
1806
1942
  scroll_current() {
1807
1943
  let t = this.get_closest_date();
@@ -1841,29 +1977,32 @@ class tt {
1841
1977
  ];
1842
1978
  }
1843
1979
  bind_grid_click() {
1844
- m.on(
1980
+ u.on(
1845
1981
  this.$container,
1846
1982
  "click",
1847
1983
  ".grid-row, .grid-header, .ignored-bar, .holiday-highlight",
1848
1984
  (t, e) => {
1849
- if (e && e.classList.contains("grid-row")) {
1985
+ if (e && (e.classList.contains("grid-row") || e.classList.contains("ignored-bar") || e.classList.contains("holiday-highlight"))) {
1850
1986
  const i = this.$svg, s = i.createSVGPoint();
1851
1987
  s.x = t.clientX, s.y = t.clientY;
1852
- const n = s.matrixTransform(i.getScreenCTM().inverse()), o = this.options.bar_height + this.options.padding, a = Math.floor((n.y - this.config.header_height) / o), h = this.tasks[a];
1853
- if (h && h._has_no_dates) {
1854
- const d = n.x / this.config.column_width, _ = Math.floor(d * this.config.step), c = g.add(
1988
+ const n = s.matrixTransform(i.getScreenCTM().inverse()), a = this.options.bar_height + this.options.padding, o = Math.floor((n.y - this.config.header_height) / a), d = this.tasks[o];
1989
+ if (d && d._has_no_dates) {
1990
+ const h = n.x / this.config.column_width, _ = Math.floor(h * this.config.step), l = g.add(
1855
1991
  this.gantt_start,
1856
1992
  _,
1857
1993
  this.config.unit
1858
1994
  );
1859
- h._start = c, h._end = g.add(c, 1, "day"), h.start = c, h.end = h._end, delete h._has_no_dates, this.refresh(this.tasks, !0), this.trigger_event("date_change", [
1860
- h,
1861
- h._start,
1862
- h._end
1995
+ if (this.config.ignored_function)
1996
+ for (; this.config.ignored_function(l); )
1997
+ l = g.add(l, 1, "day");
1998
+ d._start = l, d._end = g.add(l, 1, "day"), d.start = l, d.end = d._end, delete d._has_no_dates, this.refresh(this.tasks, !0), this.trigger_event("date_change", [
1999
+ d,
2000
+ d._start,
2001
+ d._end
1863
2002
  ]), this.trigger_event("after_date_change", [
1864
- h,
1865
- h._start,
1866
- h._end
2003
+ d,
2004
+ d._start,
2005
+ d._end
1867
2006
  ]);
1868
2007
  return;
1869
2008
  }
@@ -1892,146 +2031,147 @@ class tt {
1892
2031
  get_start_end_positions() {
1893
2032
  if (!this.bars.length) return [0, 0, 0];
1894
2033
  let { x: t, width: e } = this.bars[0].group.getBBox(), i = t, s = t, n = t + e;
1895
- return Array.prototype.forEach.call(this.bars, function({ group: o }, a) {
1896
- let { x: h, width: d } = o.getBBox();
1897
- h < i && (i = h), h > s && (s = h), h + d > n && (n = h + d);
2034
+ return Array.prototype.forEach.call(this.bars, function({ group: a }, o) {
2035
+ let { x: d, width: h } = a.getBBox();
2036
+ d < i && (i = d), d > s && (s = d), d + h > n && (n = d + h);
1898
2037
  }), [i, s, n];
1899
2038
  }
1900
2039
  bind_bar_events() {
1901
- let t = !1, e = 0, i = 0, s = !1, n = !1, o = null, a = [];
1902
- this.bar_being_dragged = null;
1903
- const h = () => t || s || n;
2040
+ let t = !1, e = 0, i = 0, s = !1, n = !1, a = null, o = [];
2041
+ this.bar_being_dragged = null, this.active_arrow = null;
2042
+ const d = () => t || s || n;
1904
2043
  this.$svg.onclick = (_) => {
1905
2044
  _.target.classList.contains("grid-row") && this.unselect_all();
1906
- };
1907
- let d = 0;
1908
- if (m.on(this.$svg, "mousemove", ".bar-wrapper, .handle", (_) => {
1909
- this.bar_being_dragged === !1 && Math.abs((_.offsetX || _.layerX) - d) > 10 && (this.bar_being_dragged = !0);
1910
- }), m.on(this.$svg, "mousedown", ".bar-wrapper, .handle", (_, c) => {
1911
- const p = m.closest(".bar-wrapper", c);
1912
- c.classList.contains("left") ? (s = !0, c.classList.add("visible")) : c.classList.contains("right") ? (n = !0, c.classList.add("visible")) : c.classList.contains("bar-wrapper") && (t = !0), this.popup && this.popup.hide(), e = _.offsetX || _.layerX, o = p.getAttribute("data-id"), a = [this.get_bar(o)], this.bar_being_dragged = !1, d = e, a.forEach((l) => {
1913
- const f = l.$bar;
1914
- f.ox = f.getX(), f.oy = f.getY(), f.owidth = f.getWidth(), f.finaldx = 0;
2045
+ }, this._document_click_handler || (this._document_click_handler = () => this.set_active_arrow(null), document.addEventListener("click", this._document_click_handler));
2046
+ let h = 0;
2047
+ if (u.on(this.$svg, "mousemove", ".bar-wrapper, .handle", (_) => {
2048
+ this.bar_being_dragged === !1 && Math.abs((_.offsetX || _.layerX) - h) > 10 && (this.bar_being_dragged = !0);
2049
+ }), u.on(this.$svg, "mousedown", ".bar-wrapper, .handle", (_, l) => {
2050
+ if (_.target.classList.contains("connector-circle")) return;
2051
+ const p = u.closest(".bar-wrapper", l);
2052
+ l.classList.contains("left") ? (s = !0, l.classList.add("visible")) : l.classList.contains("right") ? (n = !0, l.classList.add("visible")) : l.classList.contains("bar-wrapper") && (t = !0), this.popup && this.popup.hide(), e = _.offsetX || _.layerX, a = p.getAttribute("data-id"), o = [this.get_bar(a)], this.bar_being_dragged = !1, h = e, o.forEach((c) => {
2053
+ const m = c.$bar;
2054
+ m.ox = m.getX(), m.oy = m.getY(), m.owidth = m.getWidth(), m.finaldx = 0;
1915
2055
  });
1916
2056
  }), this.options.infinite_padding) {
1917
2057
  let _ = !1;
1918
- m.on(this.$container, "mousewheel", (c) => {
2058
+ u.on(this.$container, "mousewheel", (l) => {
1919
2059
  let p = this.$container.scrollWidth / 2;
1920
- if (!_ && c.currentTarget.scrollLeft <= p) {
1921
- let l = c.currentTarget.scrollLeft;
2060
+ if (!_ && l.currentTarget.scrollLeft <= p) {
2061
+ let c = l.currentTarget.scrollLeft;
1922
2062
  _ = !0, this.gantt_start = g.add(
1923
2063
  this.gantt_start,
1924
2064
  -this.config.extend_by_units,
1925
2065
  this.config.unit
1926
- ), this.setup_date_values(), this.render(), c.currentTarget.scrollLeft = l + this.config.column_width * this.config.extend_by_units, setTimeout(() => _ = !1, 300);
2066
+ ), this.setup_date_values(), this.render(), l.currentTarget.scrollLeft = c + this.config.column_width * this.config.extend_by_units, setTimeout(() => _ = !1, 300);
1927
2067
  }
1928
- if (!_ && c.currentTarget.scrollWidth - (c.currentTarget.scrollLeft + c.currentTarget.clientWidth) <= p) {
1929
- let l = c.currentTarget.scrollLeft;
2068
+ if (!_ && l.currentTarget.scrollWidth - (l.currentTarget.scrollLeft + l.currentTarget.clientWidth) <= p) {
2069
+ let c = l.currentTarget.scrollLeft;
1930
2070
  _ = !0, this.gantt_end = g.add(
1931
2071
  this.gantt_end,
1932
2072
  this.config.extend_by_units,
1933
2073
  this.config.unit
1934
- ), this.setup_date_values(), this.render(), c.currentTarget.scrollLeft = l, setTimeout(() => _ = !1, 300);
2074
+ ), this.setup_date_values(), this.render(), l.currentTarget.scrollLeft = c, setTimeout(() => _ = !1, 300);
1935
2075
  }
1936
2076
  });
1937
2077
  }
1938
- m.on(this.$container, "scroll", (_) => {
2078
+ u.on(this.$container, "scroll", (_) => {
1939
2079
  this.$task_column && !this._syncing_scroll && (this._syncing_scroll = !0, this.$task_column.scrollTop = _.currentTarget.scrollTop, requestAnimationFrame(() => {
1940
2080
  this._syncing_scroll = !1;
1941
2081
  }));
1942
- let c = [];
2082
+ let l = [];
1943
2083
  const p = this.bars.map(
1944
- ({ group: $ }) => $.getAttribute("data-id")
2084
+ ({ group: b }) => b.getAttribute("data-id")
1945
2085
  );
1946
- let l;
1947
- i && (l = _.currentTarget.scrollLeft - i), this.current_date = g.add(
2086
+ let c;
2087
+ i && (c = _.currentTarget.scrollLeft - i), this.current_date = g.add(
1948
2088
  this.gantt_start,
1949
2089
  _.currentTarget.scrollLeft / this.config.column_width * this.config.step,
1950
2090
  this.config.unit
1951
2091
  );
1952
- let f = this.config.view_mode.upper_text(
2092
+ let m = this.config.view_mode.upper_text(
1953
2093
  this.current_date,
1954
2094
  null,
1955
2095
  this.options.language
1956
- ), u = this.upperTexts.find(
1957
- ($) => $.textContent === f
2096
+ ), f = this.upperTexts.find(
2097
+ (b) => b.textContent === m
1958
2098
  );
1959
2099
  this.current_date = g.add(
1960
2100
  this.gantt_start,
1961
- (_.currentTarget.scrollLeft + u.clientWidth) / this.config.column_width * this.config.step,
2101
+ (_.currentTarget.scrollLeft + f.clientWidth) / this.config.column_width * this.config.step,
1962
2102
  this.config.unit
1963
- ), f = this.config.view_mode.upper_text(
2103
+ ), m = this.config.view_mode.upper_text(
1964
2104
  this.current_date,
1965
2105
  null,
1966
2106
  this.options.language
1967
- ), u = this.upperTexts.find(
1968
- ($) => $.textContent === f
1969
- ), u !== this.$current && (this.$current && this.$current.classList.remove("current-upper"), u.classList.add("current-upper"), this.$current = u), i = _.currentTarget.scrollLeft;
1970
- let [b, y, k] = this.get_start_end_positions();
1971
- i > k + 100 ? (this.$adjust.innerHTML = "&larr;", this.$adjust.classList.remove("hide"), this.$adjust.onclick = () => {
2107
+ ), f = this.upperTexts.find(
2108
+ (b) => b.textContent === m
2109
+ ), f !== this.$current && (this.$current && this.$current.classList.remove("current-upper"), f.classList.add("current-upper"), this.$current = f), i = _.currentTarget.scrollLeft;
2110
+ let [w, y, x] = this.get_start_end_positions();
2111
+ i > x + 100 ? (this.$adjust.innerHTML = "&larr;", this.$adjust.classList.remove("hide"), this.$adjust.onclick = () => {
1972
2112
  this.$container.scrollTo({
1973
2113
  left: y,
1974
2114
  behavior: "smooth"
1975
2115
  });
1976
- }) : i + _.currentTarget.offsetWidth < b - 100 ? (this.$adjust.innerHTML = "&rarr;", this.$adjust.classList.remove("hide"), this.$adjust.onclick = () => {
2116
+ }) : i + _.currentTarget.offsetWidth < w - 100 ? (this.$adjust.innerHTML = "&rarr;", this.$adjust.classList.remove("hide"), this.$adjust.onclick = () => {
1977
2117
  this.$container.scrollTo({
1978
- left: b,
2118
+ left: w,
1979
2119
  behavior: "smooth"
1980
2120
  });
1981
- }) : this.$adjust.classList.add("hide"), l && (c = p.map(($) => this.get_bar($)), this.options.auto_move_label && c.forEach(($) => {
1982
- $.update_label_position_on_horizontal_scroll({
1983
- x: l,
2121
+ }) : this.$adjust.classList.add("hide"), c && (l = p.map((b) => this.get_bar(b)), this.options.auto_move_label && l.forEach((b) => {
2122
+ b.update_label_position_on_horizontal_scroll({
2123
+ x: c,
1984
2124
  sx: _.currentTarget.scrollLeft
1985
2125
  });
1986
2126
  }));
1987
- }), m.on(this.$svg, "mousemove", (_) => {
1988
- if (!h()) return;
1989
- const c = (_.offsetX || _.layerX) - e;
1990
- a.forEach((p) => {
1991
- const l = p.$bar;
1992
- l.finaldx = this.get_snap_position(c, l.ox), this.hide_popup(), s ? o === p.task.id ? p.update_bar_position({
1993
- x: l.ox + l.finaldx,
1994
- width: l.owidth - l.finaldx
2127
+ }), u.on(this.$svg, "mousemove", (_) => {
2128
+ if (!d()) return;
2129
+ const l = (_.offsetX || _.layerX) - e;
2130
+ o.forEach((p) => {
2131
+ const c = p.$bar;
2132
+ c.finaldx = this.get_snap_position(l, c.ox), this.hide_popup(), s ? a === p.task.id ? p.update_bar_position({
2133
+ x: c.ox + c.finaldx,
2134
+ width: c.owidth - c.finaldx
1995
2135
  }) : p.update_bar_position({
1996
- x: l.ox + l.finaldx
1997
- }) : n ? o === p.task.id && p.update_bar_position({
1998
- width: l.owidth + l.finaldx
1999
- }) : t && !this.options.readonly && !this.options.readonly_dates && p.update_bar_position({ x: l.ox + l.finaldx });
2136
+ x: c.ox + c.finaldx
2137
+ }) : n ? a === p.task.id && p.update_bar_position({
2138
+ width: c.owidth + c.finaldx
2139
+ }) : t && !this.options.readonly && !this.options.readonly_dates && p.update_bar_position({ x: c.ox + c.finaldx });
2000
2140
  });
2001
2141
  }), document.addEventListener("mouseup", () => {
2002
- var p, l, f;
2142
+ var p, c, m;
2003
2143
  const _ = this.bar_being_dragged === !0;
2004
2144
  this.bar_being_dragged = null;
2005
- const c = [];
2006
- if (a.forEach((u) => {
2007
- if (!u.$bar.finaldx) {
2008
- _ && u.set_action_completed();
2145
+ const l = [];
2146
+ if (o.forEach((f) => {
2147
+ if (!f.$bar.finaldx) {
2148
+ _ && f.set_action_completed();
2009
2149
  return;
2010
2150
  }
2011
- u.date_changed(), u.compute_progress(), u.set_action_completed(), c.push({
2012
- task: u.task,
2013
- start: u.task._start,
2014
- end: g.add(u.task._end, -1, "second")
2151
+ f.date_changed(), f.compute_progress(), f.set_action_completed(), l.push({
2152
+ task: f.task,
2153
+ start: f.task._start,
2154
+ end: g.add(f.task._end, -1, "second")
2015
2155
  });
2016
- }), this.options.critical_path && a.some((u) => u.$bar.finaldx) && (this.calculate_critical_path(), this.update_arrow_critical_path()), c.length > 0 && this.options.dependency_shifting !== "none") {
2017
- const u = this.options.dependency_shifting;
2018
- let b;
2019
- s ? b = u === "maintain_buffer_downstream" ? "none" : "upstream" : n ? b = "downstream" : b = u === "maintain_buffer_downstream" ? "downstream" : "both", c.forEach(({ task: y }) => {
2020
- if (b === "none") return;
2021
- const k = a.find((T) => T.task.id === y.id);
2022
- if (!k || !k.$bar.finaldx) return;
2023
- const $ = k.$bar.finaldx / this.config.column_width, P = this.config.unit === "hour" ? 36e5 : this.config.unit === "day" ? 864e5 : this.config.unit === "month" ? 30 * 864e5 : this.config.unit === "year" ? 365 * 864e5 : 864e5, O = $ * this.config.step * P;
2156
+ }), this.options.critical_path && o.some((f) => f.$bar.finaldx) && (this.calculate_critical_path(), this.update_arrow_critical_path()), l.length > 0 && this.options.dependency_shifting !== "none") {
2157
+ const f = this.options.dependency_shifting;
2158
+ let w;
2159
+ s ? w = f === "maintain_buffer_downstream" ? "none" : "upstream" : n ? w = "downstream" : w = f === "maintain_buffer_downstream" ? "downstream" : "both", l.forEach(({ task: y }) => {
2160
+ if (w === "none") return;
2161
+ const x = o.find((T) => T.task.id === y.id);
2162
+ if (!x || !x.$bar.finaldx) return;
2163
+ const b = x.$bar.finaldx / this.config.column_width, V = this.config.unit === "hour" ? 36e5 : this.config.unit === "day" ? 864e5 : this.config.unit === "month" ? 30 * 864e5 : this.config.unit === "year" ? 365 * 864e5 : 864e5, P = b * this.config.step * V;
2024
2164
  I(
2025
2165
  this.tasks,
2026
2166
  y.id,
2027
- O,
2167
+ P,
2028
2168
  this.options.dependency_shifting,
2029
- b
2169
+ w
2030
2170
  ).forEach((T, N) => {
2031
2171
  const v = this.get_bar(N);
2032
2172
  if (!v) return;
2033
- const M = v.task, j = new Date(M._start.getTime() + T), V = g.diff(j, this.gantt_start, this.config.unit) / this.config.step * this.config.column_width;
2034
- v.update_bar_position({ x: V }), v.update_arrow_position(), this.trigger_event("after_date_change", [
2173
+ const M = v.task, O = new Date(M._start.getTime() + T), j = g.diff(O, this.gantt_start, this.config.unit) / this.config.step * this.config.column_width;
2174
+ v.update_bar_position({ x: j }), v.update_arrow_position(), this.trigger_event("after_date_change", [
2035
2175
  M,
2036
2176
  M._start,
2037
2177
  g.add(M._end, -1, "second")
@@ -2039,37 +2179,37 @@ class tt {
2039
2179
  });
2040
2180
  });
2041
2181
  }
2042
- c.length > 0 && c.forEach(({ task: u, start: b, end: y }) => {
2043
- this.trigger_event("after_date_change", [u, b, y]);
2044
- }), a.forEach((u) => {
2045
- u.$bar.finaldx = 0;
2046
- }), t = !1, s = !1, n = !1, (f = (l = (p = this.$container.querySelector(".visible")) == null ? void 0 : p.classList) == null ? void 0 : l.remove) == null || f.call(l, "visible");
2182
+ l.length > 0 && l.forEach(({ task: f, start: w, end: y }) => {
2183
+ this.trigger_event("after_date_change", [f, w, y]);
2184
+ }), o.forEach((f) => {
2185
+ f.$bar.finaldx = 0;
2186
+ }), t = !1, s = !1, n = !1, (m = (c = (p = this.$container.querySelector(".visible")) == null ? void 0 : p.classList) == null ? void 0 : c.remove) == null || m.call(c, "visible");
2047
2187
  }), this.bind_bar_progress();
2048
2188
  }
2049
2189
  bind_task_column_resize() {
2050
2190
  if (!this.$task_column_resize_handle) return;
2051
2191
  let t = !1, e = 0, i = 0;
2052
2192
  const s = 100, n = 600;
2053
- m.on(this.$task_column_resize_handle, "mousedown", (o) => {
2054
- t = !0, e = o.clientX, i = this.options.task_column.width, this.$task_column.classList.add("resizing"), o.preventDefault();
2055
- }), m.on(document, "mousemove", (o) => {
2193
+ u.on(this.$task_column_resize_handle, "mousedown", (a) => {
2194
+ t = !0, e = a.clientX, i = this.options.task_column.width, this.$task_column.classList.add("resizing"), a.preventDefault();
2195
+ }), u.on(document, "mousemove", (a) => {
2056
2196
  if (!t) return;
2057
- let a = o.clientX - e;
2058
- this.options.isRTL && (a = -a);
2059
- let h = i + a;
2060
- h = Math.max(s, Math.min(n, h)), this.options.task_column.width = h, this.$task_column.style.width = h + "px", this.$wrapper.style.setProperty(
2197
+ let o = a.clientX - e;
2198
+ this.options.isRTL && (o = -o);
2199
+ let d = i + o;
2200
+ d = Math.max(s, Math.min(n, d)), this.options.task_column.width = d, this.$task_column.style.width = d + "px", this.$wrapper.style.setProperty(
2061
2201
  "--gv-task-column-width",
2062
- h + "px"
2202
+ d + "px"
2063
2203
  ), this.$container.style.setProperty(
2064
2204
  "--gv-task-column-width",
2065
- h + "px"
2066
- ), this.trigger_event("task_column_resize", [h]);
2067
- }), m.on(document, "mouseup", () => {
2205
+ d + "px"
2206
+ ), this.trigger_event("task_column_resize", [d]);
2207
+ }), u.on(document, "mouseup", () => {
2068
2208
  t && (t = !1, this.$task_column.classList.remove("resizing"), this.trigger_event("task_after_column_resize", [this.options.task_column.width]));
2069
2209
  });
2070
2210
  }
2071
2211
  bind_task_column_scroll() {
2072
- this.$task_column && m.on(this.$task_column, "scroll", (t) => {
2212
+ this.$task_column && u.on(this.$task_column, "scroll", (t) => {
2073
2213
  this._syncing_scroll || (this._syncing_scroll = !0, this.$container.scrollTop = t.currentTarget.scrollTop, requestAnimationFrame(() => {
2074
2214
  this._syncing_scroll = !1;
2075
2215
  }));
@@ -2077,45 +2217,143 @@ class tt {
2077
2217
  }
2078
2218
  bind_bar_progress() {
2079
2219
  let t = 0, e = null, i = null, s = null, n = null;
2080
- m.on(this.$svg, "mousedown", ".handle.progress", (a, h) => {
2081
- e = !0, t = a.offsetX || a.layerX;
2082
- const _ = m.closest(".bar-wrapper", h).getAttribute("data-id");
2220
+ u.on(this.$svg, "mousedown", ".handle.progress", (o, d) => {
2221
+ e = !0, t = o.offsetX || o.layerX;
2222
+ const _ = u.closest(".bar-wrapper", d).getAttribute("data-id");
2083
2223
  i = this.get_bar(_), s = i.$bar_progress, n = i.$bar, s.finaldx = 0, s.owidth = s.getWidth(), s.min_dx = -s.owidth, s.max_dx = n.getWidth() - s.getWidth();
2084
2224
  });
2085
- const o = this.config.ignored_positions.map((a) => [
2086
- a,
2087
- a + this.config.column_width
2225
+ const a = this.config.ignored_positions.map((o) => [
2226
+ o,
2227
+ o + this.config.column_width
2088
2228
  ]);
2089
- m.on(this.$svg, "mousemove", (a) => {
2229
+ u.on(this.$svg, "mousemove", (o) => {
2090
2230
  if (!e) return;
2091
- let h = a.offsetX || a.layerX;
2092
- if (h > t) {
2093
- let c = o.find(
2094
- ([p, l]) => h >= p && h < l
2231
+ let d = o.offsetX || o.layerX;
2232
+ if (d > t) {
2233
+ let l = a.find(
2234
+ ([p, c]) => d >= p && d < c
2095
2235
  );
2096
- for (; c; )
2097
- h = c[1], c = o.find(
2098
- ([p, l]) => h >= p && h < l
2236
+ for (; l; )
2237
+ d = l[1], l = a.find(
2238
+ ([p, c]) => d >= p && d < c
2099
2239
  );
2100
2240
  } else {
2101
- let c = o.find(
2102
- ([p, l]) => h > p && h <= l
2241
+ let l = a.find(
2242
+ ([p, c]) => d > p && d <= c
2103
2243
  );
2104
- for (; c; )
2105
- h = c[0], c = o.find(
2106
- ([p, l]) => h > p && h <= l
2244
+ for (; l; )
2245
+ d = l[0], l = a.find(
2246
+ ([p, c]) => d > p && d <= c
2107
2247
  );
2108
2248
  }
2109
- let _ = h - t;
2110
- console.log(s), _ > s.max_dx && (_ = s.max_dx), _ < s.min_dx && (_ = s.min_dx), s.setAttribute("width", s.owidth + _), m.attr(i.$handle_progress, "cx", s.getEndX()), s.finaldx = _;
2111
- }), m.on(this.$svg, "mouseup", () => {
2249
+ let _ = d - t;
2250
+ _ > s.max_dx && (_ = s.max_dx), _ < s.min_dx && (_ = s.min_dx), s.setAttribute("width", s.owidth + _), u.attr(i.$handle_progress, "cx", s.getEndX()), s.finaldx = _;
2251
+ }), u.on(this.$svg, "mouseup", () => {
2112
2252
  e = !1, s && s.finaldx && (s.finaldx = 0, i.progress_changed(), i.set_action_completed(), i = null, s = null, n = null);
2113
2253
  });
2114
2254
  }
2255
+ bind_dependency_linking() {
2256
+ this.is_linking = !1, this.linking_source_bar = null, this.linking_source_endpoint = null, this.linking_temp_line = null, this.linking_snap_badge = null, u.on(this.$svg, "mousedown", ".connector-circle", (t, e) => {
2257
+ const i = u.closest(".bar-wrapper", e);
2258
+ if (!i) return;
2259
+ const s = i.getAttribute("data-id"), n = this.get_bar(s);
2260
+ if (!n) return;
2261
+ this.is_linking = !0, this.linking_source_bar = n, this.linking_source_endpoint = e.getAttribute("data-endpoint");
2262
+ const a = parseFloat(e.getAttribute("cx")), o = parseFloat(e.getAttribute("cy"));
2263
+ this.linking_temp_line = $("line", {
2264
+ x1: a,
2265
+ y1: o,
2266
+ x2: a,
2267
+ y2: o,
2268
+ class: "linking-temp-line",
2269
+ append_to: this.layers.linking
2270
+ });
2271
+ }), u.on(this.$svg, "mousemove", (t) => {
2272
+ if (!this.is_linking || !this.linking_temp_line) return;
2273
+ const e = this.$svg.createSVGPoint();
2274
+ e.x = t.clientX, e.y = t.clientY;
2275
+ const i = e.matrixTransform(this.$svg.getScreenCTM().inverse());
2276
+ this.linking_temp_line.setAttribute("x2", i.x), this.linking_temp_line.setAttribute("y2", i.y);
2277
+ }), u.on(this.$svg, "mouseover", ".connector-circle", (t, e) => {
2278
+ if (!this.is_linking) return;
2279
+ const i = u.closest(".bar-wrapper", e);
2280
+ if (!(!i || i.getAttribute("data-id") === this.linking_source_bar.task.id) && (e.setAttribute("r", "9"), this.linking_temp_line && this.linking_temp_line.classList.add("snap"), !this.linking_snap_badge)) {
2281
+ const n = e.getAttribute("data-endpoint"), a = this._resolve_dependency_type(
2282
+ this.linking_source_endpoint,
2283
+ n
2284
+ ), o = { "finish-to-start": "FS", "start-to-start": "SS", "finish-to-finish": "FF", "start-to-finish": "SF" }[a] || "FS", d = parseFloat(e.getAttribute("cx")), h = parseFloat(e.getAttribute("cy"));
2285
+ this.linking_snap_badge = $("text", {
2286
+ x: d + 12,
2287
+ y: h - 10,
2288
+ class: "linking-snap-badge",
2289
+ append_to: this.layers.linking
2290
+ }), this.linking_snap_badge.textContent = o;
2291
+ }
2292
+ }), u.on(this.$svg, "mouseout", ".connector-circle", (t, e) => {
2293
+ this.is_linking && (e.setAttribute("r", "4"), this.linking_temp_line && this.linking_temp_line.classList.remove("snap"), this.linking_snap_badge && (this.linking_snap_badge.remove(), this.linking_snap_badge = null));
2294
+ }), u.on(this.$svg, "mouseup", ".connector-circle", (t, e) => {
2295
+ if (!this.is_linking) return;
2296
+ const i = u.closest(".bar-wrapper", e);
2297
+ if (!i) return;
2298
+ const s = i.getAttribute("data-id");
2299
+ if (s !== this.linking_source_bar.task.id) {
2300
+ const n = this.get_bar(s), a = e.getAttribute("data-endpoint");
2301
+ n && this._commit_dependency(n, a);
2302
+ }
2303
+ }), document.addEventListener("mouseup", () => {
2304
+ this.is_linking && this._cancel_linking();
2305
+ }), document.addEventListener("keydown", (t) => {
2306
+ if ((t.key === "Delete" || t.key === "Backspace") && this.active_arrow) {
2307
+ const e = t.target.tagName;
2308
+ if (e === "INPUT" || e === "TEXTAREA" || t.target.isContentEditable) return;
2309
+ t.preventDefault(), this.delete_dependency(this.active_arrow);
2310
+ }
2311
+ });
2312
+ }
2313
+ _resolve_dependency_type(t, e) {
2314
+ return t === "end" && e === "start" ? "finish-to-start" : t === "start" && e === "start" ? "start-to-start" : t === "end" && e === "end" ? "finish-to-finish" : t === "start" && e === "end" ? "start-to-finish" : "finish-to-start";
2315
+ }
2316
+ _commit_dependency(t, e) {
2317
+ var l;
2318
+ const i = this.linking_source_bar.task, s = t.task, n = this._resolve_dependency_type(
2319
+ this.linking_source_endpoint,
2320
+ e
2321
+ ), a = s.dependencies.find((p) => p.id === i.id), o = a ? a.type || this.options.dependencies_type || "finish-to-start" : null, d = s.dependencies.filter(
2322
+ (p) => p.id !== i.id
2323
+ );
2324
+ if (o === n) {
2325
+ this.update_task(s.id, { dependencies: d }), this.options.on_dependency_delete && this.options.on_dependency_delete(i, s, n);
2326
+ return;
2327
+ }
2328
+ const h = (l = i.dependencies) == null ? void 0 : l.find((p) => p.id === s.id);
2329
+ if (h) {
2330
+ const p = h.type || this.options.dependencies_type || "finish-to-start";
2331
+ this.update_task(i.id, {
2332
+ dependencies: i.dependencies.filter((c) => c.id !== s.id)
2333
+ }), this.options.on_dependency_delete && this.options.on_dependency_delete(s, i, p);
2334
+ }
2335
+ const _ = [...d, { id: i.id, type: n }];
2336
+ this.update_task(s.id, { dependencies: _ }), a ? this.options.on_dependency_changed && this.options.on_dependency_changed(
2337
+ i,
2338
+ s,
2339
+ o,
2340
+ n
2341
+ ) : this.options.on_dependency_create && this.options.on_dependency_create(i, s, n);
2342
+ }
2343
+ _cancel_linking() {
2344
+ this.linking_temp_line && (this.linking_temp_line.remove(), this.linking_temp_line = null), this.linking_snap_badge && (this.linking_snap_badge.remove(), this.linking_snap_badge = null), this.$svg.querySelectorAll('.connector-circle[r="9"]').forEach((t) => t.setAttribute("r", "4")), this.is_linking = !1, this.linking_source_bar = null, this.linking_source_endpoint = null;
2345
+ }
2346
+ delete_dependency(t) {
2347
+ const e = t.from_task.task, i = t.to_task.task, s = t.dependency_type, n = i.dependencies.filter((a) => {
2348
+ const o = a.type || this.options.dependencies_type || "finish-to-start";
2349
+ return !(a.id === e.id && o === s);
2350
+ });
2351
+ this.set_active_arrow(null), this.update_task(i.id, { dependencies: n }), this.options.on_dependency_delete && this.options.on_dependency_delete(e, i, s);
2352
+ }
2115
2353
  get_all_dependent_tasks(t) {
2116
2354
  let e = [], i = [t];
2117
2355
  for (; i.length; ) {
2118
- const s = i.reduce((n, o) => (n = n.concat(this.dependency_map[o]), n), []);
2356
+ const s = i.reduce((n, a) => (n = n.concat(this.dependency_map[a]), n), []);
2119
2357
  e = e.concat(s), i = s.filter((n) => !i.includes(n));
2120
2358
  }
2121
2359
  return e.filter(Boolean);
@@ -2124,22 +2362,25 @@ class tt {
2124
2362
  let i = 1;
2125
2363
  const s = this.options.snap_at || this.config.view_mode.snap_at || "1d";
2126
2364
  if (s !== "unit") {
2127
- const { duration: _, scale: c } = g.parse_duration(s);
2128
- i = g.convert_scales(this.config.view_mode.step, c) / _;
2365
+ const { duration: _, scale: l } = g.parse_duration(s);
2366
+ i = g.convert_scales(this.config.view_mode.step, l) / _;
2129
2367
  }
2130
2368
  const n = t % (this.config.column_width / i);
2131
- let o = t - n + (n < this.config.column_width / i * 2 ? 0 : this.config.column_width / i), a = e + o;
2132
- const h = o > 0 ? 1 : -1;
2133
- let d = this.get_ignored_region(a, h);
2134
- for (; d.length; )
2135
- a += this.config.column_width * h, d = this.get_ignored_region(a, h), d.length || (a -= this.config.column_width * h);
2136
- return a - e;
2369
+ let a = t - n + (n < this.config.column_width / i * 2 ? 0 : this.config.column_width / i), o = e + a;
2370
+ const d = a > 0 ? 1 : -1;
2371
+ let h = this.get_ignored_region(o, d);
2372
+ for (; h.length; )
2373
+ o += this.config.column_width * d, h = this.get_ignored_region(o, d), h.length || (o -= this.config.column_width * d);
2374
+ return o - e;
2137
2375
  }
2138
2376
  get_ignored_region(t, e = 1) {
2139
2377
  return e === 1 ? this.config.ignored_positions.filter((i) => t > i && t <= i + this.config.column_width) : this.config.ignored_positions.filter(
2140
2378
  (i) => t >= i && t < i + this.config.column_width
2141
2379
  );
2142
2380
  }
2381
+ set_active_arrow(t) {
2382
+ this.active_arrow !== t && (this.active_arrow && this.active_arrow.deactivate(), this.active_arrow = t, t && (t.activate(), this.options.on_arrow_click && this.options.on_arrow_click(t.from_task.task, t.to_task.task)));
2383
+ }
2143
2384
  unselect_all() {
2144
2385
  this.popup && this.popup.parent.classList.add("hide"), this.$container.querySelectorAll(".date-range-highlight").forEach((t) => t.classList.add("hide"));
2145
2386
  }
@@ -2153,7 +2394,7 @@ class tt {
2153
2394
  return this.bars.find((e) => e.task.id === t);
2154
2395
  }
2155
2396
  show_popup(t) {
2156
- this.options.popup !== !1 && (this.popup || (this.popup = new K(
2397
+ this.options.popup !== !1 && (this.popup || (this.popup = new J(
2157
2398
  this.$popup_wrapper,
2158
2399
  this.options.popup,
2159
2400
  this
@@ -2182,18 +2423,18 @@ class tt {
2182
2423
  * @memberof Gantt
2183
2424
  */
2184
2425
  clear() {
2185
- var t, e, i, s, n, o, a, h, d, _, c, p, l, f, u, b;
2186
- this.$svg.innerHTML = "", (e = (t = this.$header) == null ? void 0 : t.remove) == null || e.call(t), (s = (i = this.$side_header) == null ? void 0 : i.remove) == null || s.call(i), (o = (n = this.$task_column) == null ? void 0 : n.remove) == null || o.call(n), (h = (a = this.$current_highlight) == null ? void 0 : a.remove) == null || h.call(a), (_ = (d = this.$extras) == null ? void 0 : d.remove) == null || _.call(d), (p = (c = this.popup) == null ? void 0 : c.hide) == null || p.call(c), (f = (l = this.$wrapper) == null ? void 0 : l.classList) == null || f.remove("has-task-column"), (b = (u = this.$wrapper) == null ? void 0 : u.classList) == null || b.remove("rtl");
2426
+ var t, e, i, s, n, a, o, d, h, _, l, p, c, m, f, w;
2427
+ this.$svg.innerHTML = "", (e = (t = this.$header) == null ? void 0 : t.remove) == null || e.call(t), (s = (i = this.$side_header) == null ? void 0 : i.remove) == null || s.call(i), (a = (n = this.$task_column) == null ? void 0 : n.remove) == null || a.call(n), (d = (o = this.$current_highlight) == null ? void 0 : o.remove) == null || d.call(o), (_ = (h = this.$extras) == null ? void 0 : h.remove) == null || _.call(h), (p = (l = this.popup) == null ? void 0 : l.hide) == null || p.call(l), (m = (c = this.$wrapper) == null ? void 0 : c.classList) == null || m.remove("has-task-column"), (w = (f = this.$wrapper) == null ? void 0 : f.classList) == null || w.remove("rtl");
2187
2428
  }
2188
2429
  }
2189
2430
  tt.VIEW_MODE = {
2190
- HOUR: x[0],
2191
- QUARTER_DAY: x[1],
2192
- HALF_DAY: x[2],
2193
- DAY: x[3],
2194
- WEEK: x[4],
2195
- MONTH: x[5],
2196
- YEAR: x[6]
2431
+ HOUR: k[0],
2432
+ QUARTER_DAY: k[1],
2433
+ HALF_DAY: k[2],
2434
+ DAY: k[3],
2435
+ WEEK: k[4],
2436
+ MONTH: k[5],
2437
+ YEAR: k[6]
2197
2438
  };
2198
2439
  function et(r) {
2199
2440
  return r.name + "_" + Math.random().toString(36).slice(2, 12);