@workiom/frappe-gantt 1.0.5 → 1.0.7

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 M = "year", D = "month", T = "day", L = "hour", Y = "minute", A = "second", H = "millisecond", d = {
1
+ const M = "year", D = "month", L = "day", T = "hour", Y = "minute", A = "second", H = "millisecond", c = {
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 M = "year", D = "month", T = "day", L = "hour", Y = "minute", A = "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((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);
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);
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, a) => (a === 1 && (n = n + 1), a === 6 ? v(n + "", 3, "0") : v(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, o) => (o === 1 && (n = n + 1), o === 6 ? v(n + "", 3, "0") : v(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 M = "year", D = "month", T = "day", L = "hour", Y = "minute", A = "second"
40
40
  month: "long"
41
41
  }), s = new Intl.DateTimeFormat(e, {
42
42
  month: "short"
43
- }), n = i.format(r), a = n.charAt(0).toUpperCase() + n.slice(1), o = this.get_date_values(r).map((l) => v(l, 2, 0)), h = {
44
- YYYY: o[0],
45
- MM: v(+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,
43
+ }), n = i.format(r), o = n.charAt(0).toUpperCase() + n.slice(1), a = this.get_date_values(r).map((l) => v(l, 2, 0)), h = {
44
+ YYYY: a[0],
45
+ MM: v(+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,
53
53
  MMM: s.format(r)
54
54
  };
55
- let _ = t;
56
- const g = [];
57
- return Object.keys(h).sort((l, c) => c.length - l.length).forEach((l) => {
58
- _.includes(l) && (_ = _.replaceAll(l, `$${g.length}`), g.push(h[l]));
59
- }), g.forEach((l, c) => {
60
- _ = _.replaceAll(`$${c}`, l);
61
- }), _;
55
+ let d = t;
56
+ const _ = [];
57
+ return Object.keys(h).sort((l, p) => p.length - l.length).forEach((l) => {
58
+ d.includes(l) && (d = d.replaceAll(l, `$${_.length}`), _.push(h[l]));
59
+ }), _.forEach((l, p) => {
60
+ d = d.replaceAll(`$${p}`, l);
61
+ }), d;
62
62
  },
63
63
  diff(r, t, e = "day") {
64
- let i, s, n, a, o, h, _;
65
- i = r - t + (t.getTimezoneOffset() - r.getTimezoneOffset()) * 6e4, s = i / 1e3, a = s / 60, n = a / 60, o = n / 24;
66
- let g = r.getFullYear() - t.getFullYear(), l = r.getMonth() - t.getMonth();
67
- return l += o % 30 / 30, h = g * 12 + l, r.getDate() < t.getDate() && h--, _ = h / 12, e.endsWith("s") || (e += "s"), Math.round(
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(), l = r.getMonth() - t.getMonth();
67
+ return l += a % 30 / 30, h = _ * 12 + l, r.getDate() < t.getDate() && h--, d = h / 12, e.endsWith("s") || (e += "s"), Math.round(
68
68
  {
69
69
  milliseconds: i,
70
70
  seconds: s,
71
- minutes: a,
71
+ minutes: o,
72
72
  hours: n,
73
- days: o,
73
+ days: a,
74
74
  months: h,
75
- years: _
75
+ years: d
76
76
  }[e] * 100
77
77
  ) / 100;
78
78
  },
@@ -88,8 +88,8 @@ const M = "year", D = "month", T = "day", L = "hour", Y = "minute", A = "second"
88
88
  const i = [
89
89
  r.getFullYear() + (e === M ? t : 0),
90
90
  r.getMonth() + (e === D ? t : 0),
91
- r.getDate() + (e === T ? t : 0),
92
- r.getHours() + (e === L ? t : 0),
91
+ r.getDate() + (e === L ? t : 0),
92
+ r.getHours() + (e === T ? t : 0),
93
93
  r.getMinutes() + (e === Y ? t : 0),
94
94
  r.getSeconds() + (e === A ? t : 0),
95
95
  r.getMilliseconds() + (e === H ? t : 0)
@@ -100,22 +100,22 @@ const M = "year", D = "month", T = "day", L = "hour", Y = "minute", A = "second"
100
100
  const e = {
101
101
  [M]: 6,
102
102
  [D]: 5,
103
- [T]: 4,
104
- [L]: 3,
103
+ [L]: 4,
104
+ [T]: 3,
105
105
  [Y]: 2,
106
106
  [A]: 1,
107
107
  [H]: 0
108
108
  };
109
109
  function i(n) {
110
- const a = e[t];
111
- return e[n] <= a;
110
+ const o = e[t];
111
+ return e[n] <= o;
112
112
  }
113
113
  const s = [
114
114
  r.getFullYear(),
115
115
  i(M) ? 0 : r.getMonth(),
116
116
  i(D) ? 1 : r.getDate(),
117
- i(T) ? 0 : r.getHours(),
118
- i(L) ? 0 : r.getMinutes(),
117
+ i(L) ? 0 : r.getHours(),
118
+ i(T) ? 0 : r.getMinutes(),
119
119
  i(Y) ? 0 : r.getSeconds(),
120
120
  i(A) ? 0 : r.getMilliseconds()
121
121
  ];
@@ -161,7 +161,7 @@ const M = "year", D = "month", T = "day", L = "hour", Y = "minute", A = "second"
161
161
  function v(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 p(r, t) {
164
+ function u(r, t) {
165
165
  return typeof r == "string" ? (t || document).querySelector(r) : r || null;
166
166
  }
167
167
  function f(r, t) {
@@ -171,16 +171,16 @@ function f(r, t) {
171
171
  return e;
172
172
  }
173
173
  function E(r, t, e, i) {
174
- const s = W(r, t, e, i);
174
+ const s = z(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 W(r, t, e, i, s = "0.4s", n = "0.1s") {
181
- const a = r.querySelector("animate");
182
- if (a)
183
- return p.attr(a, {
180
+ function z(r, t, e, i, s = "0.4s", n = "0.1s") {
181
+ const o = r.querySelector("animate");
182
+ if (o)
183
+ return u.attr(o, {
184
184
  attributeName: t,
185
185
  from: e,
186
186
  to: i,
@@ -188,7 +188,7 @@ function W(r, t, e, i, s = "0.4s", n = "0.1s") {
188
188
  begin: "click + " + n
189
189
  // artificial click
190
190
  }), r;
191
- const o = f("animate", {
191
+ const a = f("animate", {
192
192
  attributeName: t,
193
193
  from: e,
194
194
  to: i,
@@ -197,11 +197,11 @@ function W(r, t, e, i, s = "0.4s", n = "0.1s") {
197
197
  calcMode: "spline",
198
198
  values: e + ";" + i,
199
199
  keyTimes: "0; 1",
200
- keySplines: C("ease-out")
200
+ keySplines: W("ease-out")
201
201
  });
202
- return r.appendChild(o), r;
202
+ return r.appendChild(a), r;
203
203
  }
204
- function C(r) {
204
+ function W(r) {
205
205
  return {
206
206
  ease: ".25 .1 .25 1",
207
207
  linear: "0 0 1 1",
@@ -210,37 +210,40 @@ function C(r) {
210
210
  "ease-in-out": ".42 0 .58 1"
211
211
  }[r];
212
212
  }
213
- p.on = (r, t, e, i) => {
214
- i ? p.delegate(r, t, e, i) : (i = e, p.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
- p.off = (r, t, e) => {
216
+ u.off = (r, t, e) => {
217
217
  r.removeEventListener(t, e);
218
218
  };
219
- p.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
- p.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
- p.closest = (r, t) => t ? t.matches(r) ? t : p.closest(r, t.parentNode) : null;
231
- p.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
- p.attr(r, i, t[i]);
236
+ u.attr(r, i, t[i]);
237
237
  return;
238
238
  }
239
239
  r.setAttribute(t, e);
240
240
  };
241
- class q {
241
+ class C {
242
242
  constructor(t, e, i) {
243
- this.gantt = t, this.from_task = e, this.to_task = i, this.calculate_path(), this.draw();
243
+ this.gantt = t, this.from_task = e, this.to_task = i, this.is_critical = this.check_critical_path(), this.calculate_path(), this.draw();
244
+ }
245
+ check_critical_path() {
246
+ return this.gantt.options.critical_path ? this.from_task.task._is_critical === !0 && this.to_task.task._is_critical === !0 : !1;
244
247
  }
245
248
  calculate_path() {
246
249
  let t = this.from_task.$bar.getX() + this.from_task.$bar.getWidth() / 2;
@@ -249,33 +252,33 @@ class q {
249
252
  t -= 10;
250
253
  t -= 10;
251
254
  let i = this.gantt.config.header_height + this.gantt.options.bar_height + (this.gantt.options.padding + this.gantt.options.bar_height) * this.from_task.task._index + this.gantt.options.padding / 2, s = this.to_task.$bar.getX() - 13, n = this.gantt.config.header_height + this.gantt.options.bar_height / 2 + (this.gantt.options.padding + this.gantt.options.bar_height) * this.to_task.task._index + this.gantt.options.padding / 2;
252
- const a = this.from_task.task._index > this.to_task.task._index;
253
- let o = this.gantt.options.arrow_curve;
254
- const h = a ? 1 : 0;
255
- let _ = a ? -o : o;
255
+ const o = this.from_task.task._index > this.to_task.task._index;
256
+ let a = this.gantt.options.arrow_curve;
257
+ const h = o ? 1 : 0;
258
+ let d = o ? -a : a;
256
259
  if (this.to_task.$bar.getX() <= this.from_task.$bar.getX() + this.gantt.options.padding) {
257
- let g = this.gantt.options.padding / 2 - o;
258
- g < 0 && (g = 0, o = this.gantt.options.padding / 2, _ = a ? -o : o);
259
- const l = this.to_task.$bar.getY() + this.to_task.$bar.getHeight() / 2 - _, c = this.to_task.$bar.getX() - this.gantt.options.padding;
260
+ let _ = this.gantt.options.padding / 2 - a;
261
+ _ < 0 && (_ = 0, a = this.gantt.options.padding / 2, d = o ? -a : a);
262
+ const l = this.to_task.$bar.getY() + this.to_task.$bar.getHeight() / 2 - d, p = this.to_task.$bar.getX() - this.gantt.options.padding;
260
263
  this.path = `
261
264
  M ${t} ${i}
262
- v ${g}
263
- a ${o} ${o} 0 0 1 ${-o} ${o}
264
- H ${c}
265
- a ${o} ${o} 0 0 ${h} ${-o} ${_}
265
+ v ${_}
266
+ a ${a} ${a} 0 0 1 ${-a} ${a}
267
+ H ${p}
268
+ a ${a} ${a} 0 0 ${h} ${-a} ${d}
266
269
  V ${l}
267
- a ${o} ${o} 0 0 ${h} ${o} ${_}
270
+ a ${a} ${a} 0 0 ${h} ${a} ${d}
268
271
  L ${s} ${n}
269
272
  m -5 -5
270
273
  l 5 5
271
274
  l -5 5`;
272
275
  } else {
273
- s < t + o && (o = s - t);
274
- let g = a ? n + o : n - o;
276
+ s < t + a && (a = s - t);
277
+ let _ = o ? n + a : n - a;
275
278
  this.path = `
276
279
  M ${t} ${i}
277
- V ${g}
278
- a ${o} ${o} 0 0 ${h} ${o} ${o}
280
+ V ${_}
281
+ a ${a} ${a} 0 0 ${h} ${a} ${a}
279
282
  L ${s} ${n}
280
283
  m -5 -5
281
284
  l 5 5
@@ -286,14 +289,15 @@ class q {
286
289
  this.element = f("path", {
287
290
  d: this.path,
288
291
  "data-from": this.from_task.task.id,
289
- "data-to": this.to_task.task.id
292
+ "data-to": this.to_task.task.id,
293
+ class: this.is_critical ? "arrow-critical" : ""
290
294
  });
291
295
  }
292
296
  update() {
293
297
  this.calculate_path(), this.element.setAttribute("d", this.path);
294
298
  }
295
299
  }
296
- class F {
300
+ class q {
297
301
  constructor(t, e) {
298
302
  this.set_defaults(t, e), this.prepare_wrappers(), this.prepare_helpers(), this.refresh();
299
303
  }
@@ -301,7 +305,7 @@ class F {
301
305
  this.bar_group.innerHTML = "", this.handle_group.innerHTML = "", this.task.custom_class ? this.group.classList.add(this.task.custom_class) : this.group.classList = ["bar-wrapper"], this.prepare_values(), this.draw(), this.bind();
302
306
  }
303
307
  set_defaults(t, e) {
304
- this.action_completed = !1, this.gantt = t, this.task = e, this.name = this.name || "";
308
+ 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;
305
309
  }
306
310
  prepare_wrappers() {
307
311
  this.group = f("g", {
@@ -316,7 +320,7 @@ class F {
316
320
  });
317
321
  }
318
322
  prepare_values() {
319
- this.invalid = this.task.invalid, this.height = this.gantt.options.bar_height, this.image_size = this.height - 5, this.task._start = new Date(this.task.start), this.task._end = new Date(this.task.end), this.compute_x(), this.compute_y(), this.compute_duration(), this.corner_radius = this.gantt.options.bar_corner_radius, this.width = this.gantt.config.column_width * this.duration, (!this.task.progress || this.task.progress < 0) && (this.task.progress = 0), this.task.progress > 100 && (this.task.progress = 100);
323
+ this.invalid = this.task.invalid, this.height = this.gantt.options.bar_height, this.image_size = this.height - 5, (!this.task._start || !(this.task._start instanceof Date)) && (this.task._start = new Date(this.task.start)), (!this.task._end || !(this.task._end instanceof Date)) && (this.task._end = new Date(this.task.end)), this.compute_x(), this.compute_y(), this.compute_duration(), this.corner_radius = this.gantt.options.bar_corner_radius, this.width = this.gantt.config.column_width * this.duration, (!this.task.progress || this.task.progress < 0) && (this.task.progress = 0), this.task.progress > 100 && (this.task.progress = 100);
320
324
  }
321
325
  prepare_helpers() {
322
326
  SVGElement.prototype.getX = function() {
@@ -335,7 +339,7 @@ class F {
335
339
  this.compute_expected_progress(), this.expected_progress_width = this.gantt.options.column_width * this.duration * (this.expected_progress / 100) || 0;
336
340
  }
337
341
  draw() {
338
- 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();
342
+ 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();
339
343
  }
340
344
  draw_bar() {
341
345
  this.$bar = f("rect", {
@@ -380,7 +384,7 @@ class F {
380
384
  class: "bar-progress",
381
385
  append_to: this.bar_group
382
386
  }), this.task.color_progress && (this.$bar_progress.style.fill = this.task.color_progress);
383
- const e = d.diff(
387
+ const e = c.diff(
384
388
  this.task._start,
385
389
  this.gantt.gantt_start,
386
390
  this.gantt.config.unit
@@ -393,15 +397,15 @@ class F {
393
397
  this.$date_highlight = i, this.gantt.$lower_header.prepend(this.$date_highlight), E(this.$bar_progress, "width", 0, this.progress_width);
394
398
  }
395
399
  calculate_progress_width() {
396
- const t = this.$bar.getWidth(), e = this.x + t, i = this.gantt.config.ignored_positions.reduce((h, _) => h + (_ >= this.x && _ < e), 0) * this.gantt.config.column_width;
400
+ 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;
397
401
  let s = (t - i) * this.task.progress / 100;
398
- const n = this.x + s, a = this.gantt.config.ignored_positions.reduce((h, _) => h + (_ >= this.x && _ < n), 0) * this.gantt.config.column_width;
399
- s += a;
400
- let o = this.gantt.get_ignored_region(
402
+ 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;
403
+ s += o;
404
+ let a = this.gantt.get_ignored_region(
401
405
  this.x + s
402
406
  );
403
- for (; o.length; )
404
- s += this.gantt.config.column_width, o = this.gantt.get_ignored_region(
407
+ for (; a.length; )
408
+ s += this.gantt.config.column_width, a = this.gantt.get_ignored_region(
405
409
  this.x + s
406
410
  );
407
411
  return this.progress_width = s, s;
@@ -446,6 +450,51 @@ class F {
446
450
  append_to: this.bar_group
447
451
  });
448
452
  }
453
+ draw_add_task_icon() {
454
+ this.icon_size = 20, this.icon_padding = 5;
455
+ let i;
456
+ if (this.gantt.options.task_add_icon_position === "before")
457
+ i = this.x - 20 - 5;
458
+ else if (this.gantt.options.task_add_icon_position === "after")
459
+ i = this.x + this.$bar.getWidth() + 5;
460
+ else
461
+ return;
462
+ const s = this.y + (this.height - 20) / 2;
463
+ this.$add_icon_group = f("g", {
464
+ class: "add-task-icon hide",
465
+ append_to: this.handle_group
466
+ }), this.$add_icon_circle = f("circle", {
467
+ cx: i + 20 / 2,
468
+ cy: s + 20 / 2,
469
+ r: 20 / 2,
470
+ class: "add-task-icon-bg",
471
+ append_to: this.$add_icon_group
472
+ }), this.$add_icon_vertical = f("line", {
473
+ x1: i + 20 / 2,
474
+ y1: s + 5,
475
+ x2: i + 20 / 2,
476
+ y2: s + 20 - 5,
477
+ class: "add-task-icon-plus",
478
+ append_to: this.$add_icon_group
479
+ }), this.$add_icon_horizontal = f("line", {
480
+ x1: i + 5,
481
+ y1: s + 20 / 2,
482
+ x2: i + 20 - 5,
483
+ y2: s + 20 / 2,
484
+ class: "add-task-icon-plus",
485
+ append_to: this.$add_icon_group
486
+ }), u.on(this.$add_icon_group, "mousedown", (n) => {
487
+ n.stopPropagation();
488
+ }), u.on(this.$add_icon_group, "mouseup", (n) => {
489
+ n.stopPropagation();
490
+ }), u.on(this.$add_icon_group, "click", (n) => {
491
+ n.stopPropagation(), this.gantt.trigger_event("task_add", [this.task]);
492
+ }), u.on(this.$add_icon_group, "mouseenter", (n) => {
493
+ 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();
494
+ }), u.on(this.$add_icon_group, "mouseleave", () => {
495
+ this.is_hovering_icon = !1, this.$add_icon_group.classList.remove("active"), this.is_hovering_bar || this.$add_icon_group.classList.add("hide");
496
+ });
497
+ }
449
498
  draw_resize_handles() {
450
499
  if (this.invalid || this.gantt.options.readonly) return;
451
500
  const t = this.$bar, e = 3;
@@ -482,25 +531,25 @@ class F {
482
531
  }), this.handles.push(this.$handle_progress);
483
532
  }
484
533
  for (let i of this.handles)
485
- p.on(i, "mouseenter", () => i.classList.add("active")), p.on(i, "mouseleave", () => i.classList.remove("active"));
534
+ u.on(i, "mouseenter", () => i.classList.add("active")), u.on(i, "mouseleave", () => i.classList.remove("active"));
486
535
  }
487
536
  bind() {
488
537
  this.invalid || this.setup_click_event();
489
538
  }
490
539
  setup_click_event() {
491
540
  let t = this.task.id;
492
- p.on(this.group, "mouseover", (s) => {
541
+ u.on(this.group, "mouseover", (s) => {
493
542
  this.gantt.trigger_event("hover", [
494
543
  this.task,
495
544
  s.screenX,
496
545
  s.screenY,
497
546
  s
498
547
  ]);
499
- }), this.gantt.options.popup_on === "click" && p.on(this.group, "mouseup", (s) => {
548
+ }), this.gantt.options.popup_on === "click" && u.on(this.group, "mouseup", (s) => {
500
549
  const n = s.offsetX || s.layerX;
501
550
  if (this.$handle_progress) {
502
- const a = +this.$handle_progress.getAttribute("cx");
503
- if (a > n - 1 && a < n + 1 || this.gantt.bar_being_dragged) return;
551
+ const o = +this.$handle_progress.getAttribute("cx");
552
+ if (o > n - 1 && o < n + 1 || this.gantt.bar_being_dragged) return;
504
553
  }
505
554
  this.gantt.show_popup({
506
555
  x: s.offsetX || s.layerX,
@@ -510,7 +559,7 @@ class F {
510
559
  });
511
560
  });
512
561
  let e;
513
- p.on(this.group, "mouseenter", (s) => {
562
+ u.on(this.group, "mouseenter", (s) => {
514
563
  e = setTimeout(() => {
515
564
  this.gantt.options.popup_on === "hover" && this.gantt.show_popup({
516
565
  x: s.offsetX || s.layerX,
@@ -518,17 +567,21 @@ class F {
518
567
  task: this.task,
519
568
  target: this.$bar
520
569
  }), this.gantt.$container.querySelector(`.highlight-${t}`).classList.remove("hide");
521
- }, 200);
522
- }), p.on(this.group, "mouseleave", () => {
570
+ }, 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"));
571
+ }), u.on(this.group, "mouseleave", () => {
523
572
  var s, n;
524
- clearTimeout(e), this.gantt.options.popup_on === "hover" && ((n = (s = this.gantt.popup) == null ? void 0 : s.hide) == null || n.call(s)), this.gantt.$container.querySelector(`.highlight-${t}`).classList.add("hide");
525
- }), p.on(this.group, "click", () => {
573
+ clearTimeout(e), this.gantt.options.popup_on === "hover" && ((n = (s = this.gantt.popup) == null ? void 0 : s.hide) == null || n.call(s)), this.gantt.$container.querySelector(`.highlight-${t}`).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(() => {
574
+ this.is_hovering_icon || this.$add_icon_group.classList.add("hide");
575
+ }, 200));
576
+ }), u.on(this.group, "mousedown", () => {
577
+ this.is_dragging = !0, this.hide_add_icon();
578
+ }), u.on(this.group, "click", () => {
526
579
  this.gantt.trigger_event("click", [this.task]);
527
- }), p.on(this.group, "dblclick", (s) => {
580
+ }), u.on(this.group, "dblclick", (s) => {
528
581
  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]));
529
582
  });
530
583
  let i = !1;
531
- p.on(this.group, "touchstart", (s) => {
584
+ u.on(this.group, "touchstart", (s) => {
532
585
  if (!i)
533
586
  return i = !0, setTimeout(function() {
534
587
  i = !1;
@@ -543,25 +596,25 @@ class F {
543
596
  return;
544
597
  this.update_attr(i, "x", t), this.x = t, this.$date_highlight.style.left = t + "px";
545
598
  }
546
- e > 0 && (this.update_attr(i, "width", e), this.$date_highlight.style.width = e + "px"), this.update_label_position(), this.update_handle_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();
599
+ 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();
547
600
  }
548
601
  validate_dependency_constraints(t, e = null) {
549
602
  const i = this.task.dependencies_type || this.gantt.options.dependencies_type;
550
603
  if (i === "fixed")
551
- return this.task.dependencies.map((g) => this.gantt.get_bar(g).$bar.getX()).reduce((g, l) => g && t >= l, !0);
552
- const s = t / this.gantt.config.column_width, n = d.add(
604
+ return this.task.dependencies.map((_) => this.gantt.get_bar(_).$bar.getX()).reduce((_, l) => _ && t >= l, !0);
605
+ const s = t / this.gantt.config.column_width, n = c.add(
553
606
  this.gantt.gantt_start,
554
607
  s * this.gantt.config.step,
555
608
  this.gantt.config.unit
556
- ), o = (e || this.$bar.getWidth()) / this.gantt.config.column_width, h = d.add(
609
+ ), a = (e || this.$bar.getWidth()) / this.gantt.config.column_width, h = c.add(
557
610
  n,
558
- o * this.gantt.config.step,
611
+ a * this.gantt.config.step,
559
612
  this.gantt.config.unit
560
613
  );
561
- for (const _ of this.task.dependencies) {
562
- const g = this.gantt.get_bar(_);
563
- if (!g) continue;
564
- const l = g.task;
614
+ for (const d of this.task.dependencies) {
615
+ const _ = this.gantt.get_bar(d);
616
+ if (!_) continue;
617
+ const l = _.task;
565
618
  switch (i) {
566
619
  case "finish-to-start":
567
620
  if (n < l._end)
@@ -584,9 +637,9 @@ class F {
584
637
  return !0;
585
638
  }
586
639
  update_label_position_on_horizontal_scroll({ x: t, sx: e }) {
587
- const i = this.gantt.$container, s = this.group.querySelector(".bar-label"), n = this.group.querySelector(".bar-img") || "", a = this.bar_group.querySelector(".img_mask") || "";
588
- let o = this.$bar.getX() + this.$bar.getWidth(), h = s.getX() + t, _ = n && n.getX() + t || 0, g = n && n.getBBox().width + 7 || 7, l = h + s.getBBox().width + 7, c = e + i.clientWidth / 2;
589
- s.classList.contains("big") || (l < o && t > 0 && l < c || h - g > this.$bar.getX() && t < 0 && l > c) && (s.setAttribute("x", h), n && (n.setAttribute("x", _), a.setAttribute("x", _)));
640
+ const i = this.gantt.$container, s = this.group.querySelector(".bar-label"), n = this.group.querySelector(".bar-img") || "", o = this.bar_group.querySelector(".img_mask") || "";
641
+ let a = this.$bar.getX() + this.$bar.getWidth(), h = s.getX() + t, d = n && n.getX() + t || 0, _ = n && n.getBBox().width + 7 || 7, l = h + s.getBBox().width + 7, p = e + i.clientWidth / 2;
642
+ s.classList.contains("big") || (l < a && t > 0 && l < p || h - _ > this.$bar.getX() && t < 0 && l > p) && (s.setAttribute("x", h), n && (n.setAttribute("x", d), o.setAttribute("x", d)));
590
643
  }
591
644
  date_changed() {
592
645
  let t = !1;
@@ -594,7 +647,7 @@ class F {
594
647
  Number(this.task._start) !== Number(e) && (t = !0, this.task._start = e), Number(this.task._end) !== Number(i) && (t = !0, this.task._end = i), t && this.gantt.trigger_event("date_change", [
595
648
  this.task,
596
649
  e,
597
- d.add(i, -1, "second")
650
+ c.add(i, -1, "second")
598
651
  ]);
599
652
  }
600
653
  progress_changed() {
@@ -604,16 +657,16 @@ class F {
604
657
  ]);
605
658
  }
606
659
  set_action_completed() {
607
- this.action_completed = !0, setTimeout(() => this.action_completed = !1, 1e3);
660
+ this.action_completed = !0, setTimeout(() => this.action_completed = !1, 1e3), this.is_dragging = !1, this.$add_icon_group && this.is_hovering_bar && this.$add_icon_group.classList.remove("hide");
608
661
  }
609
662
  compute_start_end_date() {
610
663
  const t = this.$bar, e = t.getX() / this.gantt.config.column_width;
611
- let i = d.add(
664
+ let i = c.add(
612
665
  this.gantt.gantt_start,
613
666
  e * this.gantt.config.step,
614
667
  this.gantt.config.unit
615
668
  );
616
- const s = t.getWidth() / this.gantt.config.column_width, n = d.add(
669
+ const s = t.getWidth() / this.gantt.config.column_width, n = c.add(
617
670
  i,
618
671
  s * this.gantt.config.step,
619
672
  this.gantt.config.unit
@@ -628,11 +681,11 @@ class F {
628
681
  return parseInt(e / i * 100, 10);
629
682
  }
630
683
  compute_expected_progress() {
631
- this.expected_progress = d.diff(d.today(), this.task._start, "hour") / this.gantt.config.step, this.expected_progress = (this.expected_progress < this.duration ? this.expected_progress : this.duration) * 100 / this.duration;
684
+ this.expected_progress = c.diff(c.today(), this.task._start, "hour") / this.gantt.config.step, this.expected_progress = (this.expected_progress < this.duration ? this.expected_progress : this.duration) * 100 / this.duration;
632
685
  }
633
686
  compute_x() {
634
687
  const { column_width: t } = this.gantt.config, e = this.task._start, i = this.gantt.gantt_start;
635
- let n = d.diff(e, i, this.gantt.config.unit) / this.gantt.config.step * t;
688
+ let n = c.diff(e, i, this.gantt.config.unit) / this.gantt.config.step * t;
636
689
  this.x = n;
637
690
  }
638
691
  compute_y() {
@@ -644,10 +697,10 @@ class F {
644
697
  e++, !this.gantt.config.ignored_dates.find(
645
698
  (s) => s.getTime() === i.getTime()
646
699
  ) && (!this.gantt.config.ignored_function || !this.gantt.config.ignored_function(i)) && t++;
647
- this.task.actual_duration = t, this.task.ignored_duration = e - t, this.duration = d.convert_scales(
700
+ this.task.actual_duration = t, this.task.ignored_duration = e - t, this.duration = c.convert_scales(
648
701
  e + "d",
649
702
  this.gantt.config.unit
650
- ) / this.gantt.config.step, this.actual_duration_raw = d.convert_scales(
703
+ ) / this.gantt.config.step, this.actual_duration_raw = c.convert_scales(
651
704
  t + "d",
652
705
  this.gantt.config.unit
653
706
  ) / this.gantt.config.step, this.ignored_duration_raw = this.duration - this.actual_duration_raw;
@@ -669,14 +722,14 @@ class F {
669
722
  }
670
723
  update_label_position() {
671
724
  const t = this.bar_group.querySelector(".img_mask") || "", e = this.$bar, i = this.group.querySelector(".bar-label"), s = this.group.querySelector(".bar-img");
672
- let n = 5, a = this.image_size + 10;
673
- const o = i.getBBox().width, h = e.getWidth();
674
- o > h ? (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(
725
+ let n = 5, o = this.image_size + 10;
726
+ const a = i.getBBox().width, h = e.getWidth();
727
+ 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(
675
728
  "x",
676
- e.getX() + h / 2 + a
729
+ e.getX() + h / 2 + o
677
730
  )) : i.setAttribute(
678
731
  "x",
679
- e.getX() + h / 2 - o / 2
732
+ e.getX() + h / 2 - a / 2
680
733
  ));
681
734
  }
682
735
  update_handle_position() {
@@ -686,13 +739,29 @@ class F {
686
739
  const e = this.group.querySelector(".handle.progress");
687
740
  e && e.setAttribute("cx", this.$bar_progress.getEndX());
688
741
  }
742
+ update_add_icon_position() {
743
+ if (!this.$add_icon_group) return;
744
+ const t = this.icon_size, e = this.icon_padding;
745
+ let i;
746
+ if (this.gantt.options.task_add_icon_position === "before")
747
+ i = this.x - t - e;
748
+ else if (this.gantt.options.task_add_icon_position === "after")
749
+ i = this.x + this.$bar.getWidth() + e;
750
+ else
751
+ return;
752
+ const s = this.y + (this.height - t) / 2;
753
+ this.$add_icon_circle.setAttribute("cx", i + t / 2), this.$add_icon_circle.setAttribute("cy", s + t / 2), this.$add_icon_vertical.setAttribute("x1", i + t / 2), this.$add_icon_vertical.setAttribute("y1", s + 5), this.$add_icon_vertical.setAttribute("x2", i + t / 2), this.$add_icon_vertical.setAttribute("y2", s + t - 5), this.$add_icon_horizontal.setAttribute("x1", i + 5), this.$add_icon_horizontal.setAttribute("y1", s + t / 2), this.$add_icon_horizontal.setAttribute("x2", i + t - 5), this.$add_icon_horizontal.setAttribute("y2", s + t / 2);
754
+ }
755
+ hide_add_icon() {
756
+ this.$add_icon_group && this.$add_icon_group.classList.add("hide");
757
+ }
689
758
  update_arrow_position() {
690
759
  this.arrows = this.arrows || [];
691
760
  for (let t of this.arrows)
692
761
  t.update();
693
762
  }
694
763
  }
695
- class O {
764
+ class F {
696
765
  constructor(t, e, i) {
697
766
  this.parent = t, this.popup_func = e, this.gantt = i, this.make();
698
767
  }
@@ -710,18 +779,18 @@ class O {
710
779
  task: i,
711
780
  chart: this.gantt,
712
781
  get_title: () => this.title,
713
- set_title: (a) => this.title.innerHTML = a,
782
+ set_title: (o) => this.title.innerHTML = o,
714
783
  get_subtitle: () => this.subtitle,
715
- set_subtitle: (a) => this.subtitle.innerHTML = a,
784
+ set_subtitle: (o) => this.subtitle.innerHTML = o,
716
785
  get_details: () => this.details,
717
- set_details: (a) => this.details.innerHTML = a,
718
- add_action: (a, o) => {
786
+ set_details: (o) => this.details.innerHTML = o,
787
+ add_action: (o, a) => {
719
788
  let h = this.gantt.create_el({
720
789
  classes: "action-btn",
721
790
  type: "button",
722
791
  append_to: this.actions
723
792
  });
724
- typeof a == "function" && (a = a(i)), h.innerHTML = a, h.onclick = (_) => o(i, this.gantt, _);
793
+ typeof o == "function" && (o = o(i)), h.innerHTML = o, h.onclick = (d) => a(i, this.gantt, d);
725
794
  }
726
795
  });
727
796
  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"));
@@ -734,9 +803,9 @@ function S(r) {
734
803
  const t = r.getFullYear();
735
804
  return t - t % 10 + "";
736
805
  }
737
- function I(r, t, e) {
738
- let i = d.add(r, 6, "day"), s = i.getMonth() !== r.getMonth() ? "D MMM" : "D", n = !t || r.getMonth() !== t.getMonth() ? "D MMM" : "D";
739
- return `${d.format(r, n, e)} - ${d.format(i, s, e)}`;
806
+ function O(r, t, e) {
807
+ let i = c.add(r, 6, "day"), s = i.getMonth() !== r.getMonth() ? "D MMM" : "D", n = !t || r.getMonth() !== t.getMonth() ? "D MMM" : "D";
808
+ return `${c.format(r, n, e)} - ${c.format(i, s, e)}`;
740
809
  }
741
810
  const y = [
742
811
  {
@@ -745,7 +814,7 @@ const y = [
745
814
  step: "1h",
746
815
  date_format: "YYYY-MM-DD HH:",
747
816
  lower_text: "HH",
748
- upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? d.format(r, "D MMMM", e) : "",
817
+ upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? c.format(r, "D MMMM", e) : "",
749
818
  upper_text_frequency: 24
750
819
  },
751
820
  {
@@ -754,7 +823,7 @@ const y = [
754
823
  step: "6h",
755
824
  date_format: "YYYY-MM-DD HH:",
756
825
  lower_text: "HH",
757
- upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? d.format(r, "D MMM", e) : "",
826
+ upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? c.format(r, "D MMM", e) : "",
758
827
  upper_text_frequency: 4
759
828
  },
760
829
  {
@@ -763,7 +832,7 @@ const y = [
763
832
  step: "12h",
764
833
  date_format: "YYYY-MM-DD HH:",
765
834
  lower_text: "HH",
766
- upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? r.getMonth() !== r.getMonth() ? d.format(r, "D MMM", e) : d.format(r, "D", e) : "",
835
+ upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? r.getMonth() !== r.getMonth() ? c.format(r, "D MMM", e) : c.format(r, "D", e) : "",
767
836
  upper_text_frequency: 2
768
837
  },
769
838
  {
@@ -771,8 +840,8 @@ const y = [
771
840
  padding: "7d",
772
841
  date_format: "YYYY-MM-DD",
773
842
  step: "1d",
774
- lower_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? d.format(r, "D", e) : "",
775
- upper_text: (r, t, e) => !t || r.getMonth() !== t.getMonth() ? d.format(r, "MMMM", e) : "",
843
+ lower_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? c.format(r, "D", e) : "",
844
+ upper_text: (r, t, e) => !t || r.getMonth() !== t.getMonth() ? c.format(r, "MMMM", e) : "",
776
845
  thick_line: (r) => r.getDay() === 1
777
846
  },
778
847
  {
@@ -781,8 +850,8 @@ const y = [
781
850
  step: "7d",
782
851
  date_format: "YYYY-MM-DD",
783
852
  column_width: 140,
784
- lower_text: I,
785
- upper_text: (r, t, e) => !t || r.getMonth() !== t.getMonth() ? d.format(r, "MMMM", e) : "",
853
+ lower_text: O,
854
+ upper_text: (r, t, e) => !t || r.getMonth() !== t.getMonth() ? c.format(r, "MMMM", e) : "",
786
855
  thick_line: (r) => r.getDate() >= 1 && r.getDate() <= 7,
787
856
  upper_text_frequency: 4
788
857
  },
@@ -793,7 +862,7 @@ const y = [
793
862
  column_width: 120,
794
863
  date_format: "YYYY-MM",
795
864
  lower_text: "MMMM",
796
- upper_text: (r, t, e) => !t || r.getFullYear() !== t.getFullYear() ? d.format(r, "YYYY", e) : "",
865
+ upper_text: (r, t, e) => !t || r.getFullYear() !== t.getFullYear() ? c.format(r, "YYYY", e) : "",
797
866
  thick_line: (r) => r.getMonth() % 3 === 0,
798
867
  snap_at: "7d"
799
868
  },
@@ -807,13 +876,14 @@ const y = [
807
876
  lower_text: "YYYY",
808
877
  snap_at: "30d"
809
878
  }
810
- ], z = {
879
+ ], I = {
811
880
  arrow_curve: 5,
812
881
  auto_move_label: !1,
813
882
  bar_corner_radius: 3,
814
883
  bar_height: 30,
815
884
  container_height: "auto",
816
885
  column_width: null,
886
+ critical_path: !1,
817
887
  date_format: "YYYY-MM-DD HH:mm",
818
888
  dependencies_type: "fixed",
819
889
  upper_header_height: 45,
@@ -828,12 +898,12 @@ const y = [
828
898
  padding: 18,
829
899
  popup: (r) => {
830
900
  r.set_title(r.task.name), r.task.description ? r.set_subtitle(r.task.description) : r.set_subtitle("");
831
- const t = d.format(
901
+ const t = c.format(
832
902
  r.task._start,
833
903
  "MMM D",
834
904
  r.chart.options.language
835
- ), e = d.format(
836
- d.add(r.task._end, -1, "second"),
905
+ ), e = c.format(
906
+ c.add(r.task._end, -1, "second"),
837
907
  "MMM D",
838
908
  r.chart.options.language
839
909
  );
@@ -847,13 +917,14 @@ const y = [
847
917
  readonly: !1,
848
918
  scroll_to: "today",
849
919
  show_expected_progress: !1,
920
+ task_add_icon_position: null,
850
921
  today_button: !0,
851
922
  view_mode: "Day",
852
923
  view_mode_select: !1,
853
924
  view_modes: y,
854
925
  is_weekend: (r) => r.getDay() === 0 || r.getDay() === 6
855
926
  };
856
- class B {
927
+ class j {
857
928
  constructor(t, e, i) {
858
929
  this.setup_wrapper(t), this.setup_options(i), this.setup_tasks(e), this.change_view_mode(), this.bind_events();
859
930
  }
@@ -897,7 +968,7 @@ class B {
897
968
  ), s;
898
969
  }
899
970
  return i;
900
- }), t.view_mode = t.view_modes[0]), this.options = { ...z, ...t };
971
+ }), t.view_mode = t.view_modes[0]), this.options = { ...I, ...t };
901
972
  const e = {
902
973
  "grid-height": "container_height",
903
974
  "bar-height": "bar_height",
@@ -936,24 +1007,24 @@ class B {
936
1007
  return console.error(
937
1008
  `task "${e.id}" doesn't have a start date`
938
1009
  ), !1;
939
- if (e._start = d.parse(e.start), e.end === void 0 && e.duration !== void 0 && (e.end = e._start, e.duration.split(" ").forEach((o) => {
940
- let { duration: h, scale: _ } = d.parse_duration(o);
941
- e.end = d.add(e.end, h, _);
1010
+ if (e._start = c.parse(e.start), e.end === void 0 && e.duration !== void 0 && (e.end = e._start, e.duration.split(" ").forEach((a) => {
1011
+ let { duration: h, scale: d } = c.parse_duration(a);
1012
+ e.end = c.add(e.end, h, d);
942
1013
  })), !e.end)
943
1014
  return console.error(`task "${e.id}" doesn't have an end date`), !1;
944
- if (e._end = d.parse(e.end), d.diff(e._end, e._start, "year") < 0)
1015
+ if (e._end = c.parse(e.end), c.diff(e._end, e._start, "year") < 0)
945
1016
  return console.error(
946
1017
  `start of task can't be after end of task: in task "${e.id}"`
947
1018
  ), !1;
948
- if (d.diff(e._end, e._start, "year") > 10)
1019
+ if (c.diff(e._end, e._start, "year") > 10)
949
1020
  return console.error(
950
1021
  `the duration of task "${e.id}" is too long (above ten years)`
951
1022
  ), !1;
952
- if (e._index = i, d.get_date_values(e._end).slice(3).every((a) => a === 0) && (e._end = d.add(e._end, 24, "hour")), typeof e.dependencies == "string" || !e.dependencies) {
953
- let a = [];
954
- e.dependencies && (a = e.dependencies.split(",").map((o) => o.trim().replaceAll(" ", "_")).filter((o) => o)), e.dependencies = a;
1023
+ if (e._index = i, c.get_date_values(e._end).slice(3).every((o) => o === 0) && (e._end = c.add(e._end, 24, "hour")), typeof e.dependencies == "string" || !e.dependencies) {
1024
+ let o = [];
1025
+ e.dependencies && (o = e.dependencies.split(",").map((a) => a.trim().replaceAll(" ", "_")).filter((a) => a)), e.dependencies = o;
955
1026
  }
956
- return e.id ? typeof e.id == "string" ? e.id = e.id.replaceAll(" ", "_") : e.id = `${e.id}` : e.id = j(e), e;
1027
+ return e.id ? typeof e.id == "string" ? e.id = e.id.replaceAll(" ", "_") : e.id = `${e.id}` : e.id = B(e), e;
957
1028
  }).filter((e) => e), this.setup_dependencies();
958
1029
  }
959
1030
  setup_dependencies() {
@@ -975,7 +1046,7 @@ class B {
975
1046
  e && (i = this.$container.scrollLeft, s = this.options.scroll_to, this.options.scroll_to = null), this.options.view_mode = t.name, this.config.view_mode = t, this.update_view_scale(t), this.setup_dates(e), this.render(), e && (this.$container.scrollLeft = i, this.options.scroll_to = s), this.trigger_event("view_change", [t]);
976
1047
  }
977
1048
  update_view_scale(t) {
978
- let { duration: e, scale: i } = d.parse_duration(t.step);
1049
+ let { duration: e, scale: i } = c.parse_duration(t.step);
979
1050
  this.config.step = e, this.config.unit = i, this.config.column_width = this.options.column_width || t.column_width || 45, this.$container.style.setProperty(
980
1051
  "--gv-column-width",
981
1052
  this.config.column_width + "px"
@@ -989,13 +1060,13 @@ class B {
989
1060
  this.tasks.length || (e = /* @__PURE__ */ new Date(), i = /* @__PURE__ */ new Date());
990
1061
  for (let s of this.tasks)
991
1062
  (!e || s._start < e) && (e = s._start), (!i || s._end > i) && (i = s._end);
992
- if (e = d.start_of(e, this.config.unit), i = d.start_of(i, this.config.unit), !t)
1063
+ if (e = c.start_of(e, this.config.unit), i = c.start_of(i, this.config.unit), !t)
993
1064
  if (this.options.infinite_padding)
994
- this.gantt_start = d.add(
1065
+ this.gantt_start = c.add(
995
1066
  e,
996
1067
  -this.config.extend_by_units * 3,
997
1068
  this.config.unit
998
- ), this.gantt_end = d.add(
1069
+ ), this.gantt_end = c.add(
999
1070
  i,
1000
1071
  this.config.extend_by_units * 3,
1001
1072
  this.config.unit
@@ -1006,13 +1077,13 @@ class B {
1006
1077
  this.config.view_mode.padding
1007
1078
  ]);
1008
1079
  let [s, n] = this.config.view_mode.padding.map(
1009
- d.parse_duration
1080
+ c.parse_duration
1010
1081
  );
1011
- this.gantt_start = d.add(
1082
+ this.gantt_start = c.add(
1012
1083
  e,
1013
1084
  -s.duration,
1014
1085
  s.scale
1015
- ), this.gantt_end = d.add(
1086
+ ), this.gantt_end = c.add(
1016
1087
  i,
1017
1088
  n.duration,
1018
1089
  n.scale
@@ -1023,7 +1094,7 @@ class B {
1023
1094
  setup_date_values() {
1024
1095
  let t = this.gantt_start;
1025
1096
  for (this.dates = [t]; t < this.gantt_end; )
1026
- t = d.add(
1097
+ t = c.add(
1027
1098
  t,
1028
1099
  this.config.step,
1029
1100
  this.config.unit
@@ -1070,7 +1141,7 @@ class B {
1070
1141
  height: e,
1071
1142
  class: "grid-background",
1072
1143
  append_to: this.$svg
1073
- }), p.attr(this.$svg, {
1144
+ }), u.attr(this.$svg, {
1074
1145
  height: e,
1075
1146
  width: "100%"
1076
1147
  }), this.grid_height = e, this.options.container_height === "auto" && (this.$container.style.height = e + "px");
@@ -1129,25 +1200,25 @@ class B {
1129
1200
  class: "lines_layer",
1130
1201
  append_to: this.layers.grid
1131
1202
  }), n = this.config.header_height;
1132
- const a = this.dates.length * this.config.column_width, o = this.options.bar_height + this.options.padding;
1203
+ const o = this.dates.length * this.config.column_width, a = this.options.bar_height + this.options.padding;
1133
1204
  if (this.options.lines !== "vertical")
1134
- for (let h = this.config.header_height; h < this.grid_height; h += o)
1205
+ for (let h = this.config.header_height; h < this.grid_height; h += a)
1135
1206
  f("line", {
1136
1207
  x1: 0,
1137
- y1: n + o,
1138
- x2: a,
1139
- y2: n + o,
1208
+ y1: n + a,
1209
+ x2: o,
1210
+ y2: n + a,
1140
1211
  class: "row-line",
1141
1212
  append_to: s
1142
- }), n += o;
1213
+ }), n += a;
1143
1214
  if (this.options.lines !== "horizontal")
1144
1215
  for (let h of this.dates) {
1145
- let _ = "tick";
1146
- this.config.view_mode.thick_line && this.config.view_mode.thick_line(h) && (_ += " thick"), f("path", {
1216
+ let d = "tick";
1217
+ this.config.view_mode.thick_line && this.config.view_mode.thick_line(h) && (d += " thick"), f("path", {
1147
1218
  d: `M ${t} ${e} v ${i}`,
1148
- class: _,
1219
+ class: d,
1149
1220
  append_to: this.layers.grid
1150
- }), this.view_is("month") ? t += d.get_days_in_month(h) * this.config.column_width / 30 : this.view_is("year") ? t += d.get_days_in_year(h) * this.config.column_width / 365 : t += this.config.column_width;
1221
+ }), this.view_is("month") ? t += c.get_days_in_month(h) * this.config.column_width / 30 : this.view_is("year") ? t += c.get_days_in_year(h) * this.config.column_width / 365 : t += this.config.column_width;
1151
1222
  }
1152
1223
  }
1153
1224
  highlight_holidays() {
@@ -1158,43 +1229,43 @@ class B {
1158
1229
  i === "weekend" && (i = this.options.is_weekend);
1159
1230
  let s;
1160
1231
  if (typeof i == "object") {
1161
- let n = i.find((a) => typeof a == "function");
1232
+ let n = i.find((o) => typeof o == "function");
1162
1233
  if (n && (s = n), this.options.holidays.name) {
1163
- let a = /* @__PURE__ */ new Date(i.date + " ");
1164
- i = (o) => a.getTime() === o.getTime(), t[a] = i.name;
1234
+ let o = /* @__PURE__ */ new Date(i.date + " ");
1235
+ i = (a) => o.getTime() === a.getTime(), t[o] = i.name;
1165
1236
  } else
1166
- i = (a) => this.options.holidays[e].filter((o) => typeof o != "function").map((o) => {
1167
- if (o.name) {
1168
- let h = /* @__PURE__ */ new Date(o.date + " ");
1169
- return t[h] = o.name, h.getTime();
1237
+ i = (o) => this.options.holidays[e].filter((a) => typeof a != "function").map((a) => {
1238
+ if (a.name) {
1239
+ let h = /* @__PURE__ */ new Date(a.date + " ");
1240
+ return t[h] = a.name, h.getTime();
1170
1241
  }
1171
- return (/* @__PURE__ */ new Date(o + " ")).getTime();
1172
- }).includes(a.getTime());
1242
+ return (/* @__PURE__ */ new Date(a + " ")).getTime();
1243
+ }).includes(o.getTime());
1173
1244
  }
1174
1245
  for (let n = new Date(this.gantt_start); n <= this.gantt_end; n.setDate(n.getDate() + 1))
1175
1246
  if (!(this.config.ignored_dates.find(
1176
- (a) => a.getTime() == n.getTime()
1247
+ (o) => o.getTime() == n.getTime()
1177
1248
  ) || this.config.ignored_function && this.config.ignored_function(n)) && (i(n) || s && s(n))) {
1178
- const a = d.diff(
1249
+ const o = c.diff(
1179
1250
  n,
1180
1251
  this.gantt_start,
1181
1252
  this.config.unit
1182
- ) / this.config.step * this.config.column_width, o = this.grid_height - this.config.header_height, h = d.format(n, "YYYY-MM-DD", this.options.language).replace(" ", "_");
1253
+ ) / this.config.step * this.config.column_width, a = this.grid_height - this.config.header_height, h = c.format(n, "YYYY-MM-DD", this.options.language).replace(" ", "_");
1183
1254
  if (t[n]) {
1184
- let _ = this.create_el({
1255
+ let d = this.create_el({
1185
1256
  classes: "holiday-label label_" + h,
1186
1257
  append_to: this.$extras
1187
1258
  });
1188
- _.textContent = t[n];
1259
+ d.textContent = t[n];
1189
1260
  }
1190
1261
  f("rect", {
1191
- x: Math.round(a),
1262
+ x: Math.round(o),
1192
1263
  y: this.config.header_height,
1193
- width: this.config.column_width / d.convert_scales(
1264
+ width: this.config.column_width / c.convert_scales(
1194
1265
  this.config.view_mode.step,
1195
1266
  "day"
1196
1267
  ),
1197
- height: o,
1268
+ height: a,
1198
1269
  class: "holiday-highlight " + h,
1199
1270
  style: `fill: ${e};`,
1200
1271
  append_to: this.layers.grid
@@ -1212,7 +1283,7 @@ class B {
1212
1283
  if (!t) return;
1213
1284
  const [e, i] = t;
1214
1285
  i.classList.add("current-date-highlight");
1215
- const n = d.diff(
1286
+ const n = c.diff(
1216
1287
  /* @__PURE__ */ new Date(),
1217
1288
  this.gantt_start,
1218
1289
  this.config.unit
@@ -1246,8 +1317,8 @@ class B {
1246
1317
  (n) => n.getTime() == i.getTime()
1247
1318
  ) && (!this.config.ignored_function || !this.config.ignored_function(i)))
1248
1319
  continue;
1249
- let s = d.convert_scales(
1250
- d.diff(i, this.gantt_start) + "d",
1320
+ let s = c.convert_scales(
1321
+ c.diff(i, this.gantt_start) + "d",
1251
1322
  this.config.unit
1252
1323
  ) / this.config.step;
1253
1324
  this.config.ignored_positions.push(s * this.config.column_width), f("rect", {
@@ -1264,10 +1335,10 @@ class B {
1264
1335
  this.config.view_mode
1265
1336
  );
1266
1337
  }
1267
- create_el({ left: t, top: e, width: i, height: s, id: n, classes: a, append_to: o, type: h }) {
1268
- let _ = document.createElement(h || "div");
1269
- for (let g of a.split(" ")) _.classList.add(g);
1270
- return _.style.top = e + "px", _.style.left = t + "px", n && (_.id = n), i && (_.style.width = i + "px"), s && (_.style.height = s + "px"), o && o.appendChild(_), _;
1338
+ create_el({ left: t, top: e, width: i, height: s, id: n, classes: o, append_to: a, type: h }) {
1339
+ let d = document.createElement(h || "div");
1340
+ for (let _ of o.split(" ")) d.classList.add(_);
1341
+ 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;
1271
1342
  }
1272
1343
  make_dates() {
1273
1344
  this.get_dates_to_draw().forEach((t, e) => {
@@ -1304,11 +1375,11 @@ class B {
1304
1375
  let i = e ? e.date : null;
1305
1376
  this.config.column_width;
1306
1377
  const s = e ? e.x + e.column_width : 0;
1307
- let n = this.config.view_mode.upper_text, a = this.config.view_mode.lower_text;
1308
- return n ? typeof n == "string" && (this.config.view_mode.upper_text = (o) => d.format(o, n, this.options.language)) : this.config.view_mode.upper_text = () => "", a ? typeof a == "string" && (this.config.view_mode.lower_text = (o) => d.format(o, a, this.options.language)) : this.config.view_mode.lower_text = () => "", {
1378
+ let n = this.config.view_mode.upper_text, o = this.config.view_mode.lower_text;
1379
+ return n ? typeof n == "string" && (this.config.view_mode.upper_text = (a) => c.format(a, n, this.options.language)) : this.config.view_mode.upper_text = () => "", o ? typeof o == "string" && (this.config.view_mode.lower_text = (a) => c.format(a, o, this.options.language)) : this.config.view_mode.lower_text = () => "", {
1309
1380
  date: t,
1310
1381
  formatted_date: k(
1311
- d.format(
1382
+ c.format(
1312
1383
  t,
1313
1384
  this.config.date_format,
1314
1385
  this.options.language
@@ -1332,18 +1403,18 @@ class B {
1332
1403
  }
1333
1404
  make_bars() {
1334
1405
  this.bars = this.tasks.map((t) => {
1335
- const e = new F(this, t);
1406
+ const e = new q(this, t);
1336
1407
  return this.layers.bar.appendChild(e.group), e;
1337
1408
  });
1338
1409
  }
1339
1410
  make_arrows() {
1340
- this.arrows = [];
1411
+ this.arrows = [], this.options.critical_path && this.calculate_critical_path();
1341
1412
  for (let t of this.tasks) {
1342
1413
  let e = [];
1343
1414
  e = t.dependencies.map((i) => {
1344
1415
  const s = this.get_task(i);
1345
1416
  if (!s) return;
1346
- const n = new q(
1417
+ const n = new C(
1347
1418
  this,
1348
1419
  this.bars[s._index],
1349
1420
  // from_task
@@ -1354,6 +1425,50 @@ class B {
1354
1425
  }).filter(Boolean), this.arrows = this.arrows.concat(e);
1355
1426
  }
1356
1427
  }
1428
+ calculate_critical_path() {
1429
+ this.tasks.forEach((n) => n._is_critical = !1);
1430
+ const t = {};
1431
+ this.tasks.forEach((n) => {
1432
+ t[n.id] = { es: 0, ef: 0, ls: 0, lf: 0 };
1433
+ });
1434
+ const e = (n) => {
1435
+ if (t[n.id].ef > 0) return t[n.id];
1436
+ let o = 0;
1437
+ n.dependencies && n.dependencies.length > 0 && n.dependencies.forEach((h) => {
1438
+ const d = this.get_task(h);
1439
+ if (d) {
1440
+ const _ = e(d);
1441
+ o = Math.max(o, _.ef);
1442
+ }
1443
+ }), t[n.id].es = o;
1444
+ const a = c.diff(n._end, n._start, "hour") / 24;
1445
+ return t[n.id].ef = o + a, t[n.id];
1446
+ };
1447
+ this.tasks.forEach((n) => e(n));
1448
+ const i = Math.max(...Object.values(t).map((n) => n.ef)), s = (n) => {
1449
+ if (t[n.id].ls > 0 || t[n.id].lf > 0)
1450
+ return t[n.id];
1451
+ const o = this.tasks.filter(
1452
+ (d) => d.dependencies && d.dependencies.includes(n.id)
1453
+ );
1454
+ let a = i;
1455
+ o.length > 0 && o.forEach((d) => {
1456
+ const _ = s(d);
1457
+ a = Math.min(a, _.ls);
1458
+ });
1459
+ const h = c.diff(n._end, n._start, "hour") / 24;
1460
+ return t[n.id].lf = a, t[n.id].ls = a - h, t[n.id];
1461
+ };
1462
+ this.tasks.forEach((n) => s(n)), this.tasks.forEach((n) => {
1463
+ const o = t[n.id], a = o.ls - o.es;
1464
+ n._is_critical = Math.abs(a) < 0.01;
1465
+ });
1466
+ }
1467
+ update_arrow_critical_path() {
1468
+ this.arrows.forEach((t) => {
1469
+ t.from_task.task._is_critical === !0 && t.to_task.task._is_critical === !0 ? t.element.classList.add("arrow-critical") : t.element.classList.remove("arrow-critical");
1470
+ });
1471
+ }
1357
1472
  map_arrows_on_bars() {
1358
1473
  for (let t of this.bars)
1359
1474
  t.arrows = this.arrows.filter((e) => e.from_task.task.id === t.task.id || e.to_task.task.id === t.task.id);
@@ -1364,8 +1479,8 @@ class B {
1364
1479
  }
1365
1480
  set_scroll_position(t) {
1366
1481
  if (this.options.infinite_padding && (!t || t === "start")) {
1367
- let [a, ...o] = this.get_start_end_positions();
1368
- this.$container.scrollLeft = a;
1482
+ let [o, ...a] = this.get_start_end_positions();
1483
+ this.$container.scrollLeft = o;
1369
1484
  return;
1370
1485
  }
1371
1486
  if (!t || t === "start")
@@ -1375,9 +1490,9 @@ class B {
1375
1490
  else {
1376
1491
  if (t === "today")
1377
1492
  return this.scroll_current();
1378
- typeof t == "string" && (t = d.parse(t));
1493
+ typeof t == "string" && (t = c.parse(t));
1379
1494
  }
1380
- const i = d.diff(
1495
+ const i = c.diff(
1381
1496
  t,
1382
1497
  this.gantt_start,
1383
1498
  this.config.unit
@@ -1385,7 +1500,7 @@ class B {
1385
1500
  this.$container.scrollTo({
1386
1501
  left: i - this.config.column_width / 6,
1387
1502
  behavior: "smooth"
1388
- }), this.$current && this.$current.classList.remove("current-upper"), this.current_date = d.add(
1503
+ }), this.$current && this.$current.classList.remove("current-upper"), this.current_date = c.add(
1389
1504
  this.gantt_start,
1390
1505
  this.$container.scrollLeft / this.config.column_width,
1391
1506
  this.config.unit
@@ -1395,9 +1510,9 @@ class B {
1395
1510
  null,
1396
1511
  this.options.language
1397
1512
  ), n = this.upperTexts.find(
1398
- (a) => a.textContent === s
1513
+ (o) => o.textContent === s
1399
1514
  );
1400
- this.current_date = d.add(
1515
+ this.current_date = c.add(
1401
1516
  this.gantt_start,
1402
1517
  (this.$container.scrollLeft + n.clientWidth) / this.config.column_width,
1403
1518
  this.config.unit
@@ -1405,7 +1520,7 @@ class B {
1405
1520
  this.current_date,
1406
1521
  null,
1407
1522
  this.options.language
1408
- ), n = this.upperTexts.find((a) => a.textContent === s), n.classList.add("current-upper"), this.$current = n;
1523
+ ), n = this.upperTexts.find((o) => o.textContent === s), n.classList.add("current-upper"), this.$current = n;
1409
1524
  }
1410
1525
  scroll_current() {
1411
1526
  let t = this.get_closest_date();
@@ -1416,7 +1531,7 @@ class B {
1416
1531
  if (t < this.gantt_start || t > this.gantt_end) return null;
1417
1532
  let e = /* @__PURE__ */ new Date(), i = this.$container.querySelector(
1418
1533
  ".date_" + k(
1419
- d.format(
1534
+ c.format(
1420
1535
  e,
1421
1536
  this.config.date_format,
1422
1537
  this.options.language
@@ -1424,9 +1539,9 @@ class B {
1424
1539
  )
1425
1540
  ), s = 0;
1426
1541
  for (; !i && s < this.config.step; )
1427
- e = d.add(e, -1, this.config.unit), i = this.$container.querySelector(
1542
+ e = c.add(e, -1, this.config.unit), i = this.$container.querySelector(
1428
1543
  ".date_" + k(
1429
- d.format(
1544
+ c.format(
1430
1545
  e,
1431
1546
  this.config.date_format,
1432
1547
  this.options.language
@@ -1435,7 +1550,7 @@ class B {
1435
1550
  ), s++;
1436
1551
  return [
1437
1552
  /* @__PURE__ */ new Date(
1438
- d.format(
1553
+ c.format(
1439
1554
  e,
1440
1555
  this.config.date_format,
1441
1556
  this.options.language
@@ -1445,7 +1560,7 @@ class B {
1445
1560
  ];
1446
1561
  }
1447
1562
  bind_grid_click() {
1448
- p.on(
1563
+ u.on(
1449
1564
  this.$container,
1450
1565
  "click",
1451
1566
  ".grid-row, .grid-header, .ignored-bar, .holiday-highlight",
@@ -1474,64 +1589,64 @@ class B {
1474
1589
  get_start_end_positions() {
1475
1590
  if (!this.bars.length) return [0, 0, 0];
1476
1591
  let { x: t, width: e } = this.bars[0].group.getBBox(), i = t, s = t, n = t + e;
1477
- return Array.prototype.forEach.call(this.bars, function({ group: a }, o) {
1478
- let { x: h, width: _ } = a.getBBox();
1479
- h < i && (i = h), h > s && (s = h), h + _ > n && (n = h + _);
1592
+ return Array.prototype.forEach.call(this.bars, function({ group: o }, a) {
1593
+ let { x: h, width: d } = o.getBBox();
1594
+ h < i && (i = h), h > s && (s = h), h + d > n && (n = h + d);
1480
1595
  }), [i, s, n];
1481
1596
  }
1482
1597
  bind_bar_events() {
1483
- let t = !1, e = 0, i = 0, s = !1, n = !1, a = null, o = [];
1598
+ let t = !1, e = 0, i = 0, s = !1, n = !1, o = null, a = [];
1484
1599
  this.bar_being_dragged = null;
1485
1600
  const h = () => t || s || n;
1486
- this.$svg.onclick = (g) => {
1487
- g.target.classList.contains("grid-row") && this.unselect_all();
1601
+ this.$svg.onclick = (_) => {
1602
+ _.target.classList.contains("grid-row") && this.unselect_all();
1488
1603
  };
1489
- let _ = 0;
1490
- if (p.on(this.$svg, "mousemove", ".bar-wrapper, .handle", (g) => {
1491
- this.bar_being_dragged === !1 && Math.abs((g.offsetX || g.layerX) - _) > 10 && (this.bar_being_dragged = !0);
1492
- }), p.on(this.$svg, "mousedown", ".bar-wrapper, .handle", (g, l) => {
1493
- const c = p.closest(".bar-wrapper", l);
1494
- 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 = g.offsetX || g.layerX, a = c.getAttribute("data-id");
1495
- const $ = this.get_bar(a).task.dependencies_type || this.options.dependencies_type;
1604
+ let d = 0;
1605
+ if (u.on(this.$svg, "mousemove", ".bar-wrapper, .handle", (_) => {
1606
+ this.bar_being_dragged === !1 && Math.abs((_.offsetX || _.layerX) - d) > 10 && (this.bar_being_dragged = !0);
1607
+ }), u.on(this.$svg, "mousedown", ".bar-wrapper, .handle", (_, l) => {
1608
+ const p = u.closest(".bar-wrapper", l);
1609
+ 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, o = p.getAttribute("data-id");
1610
+ const $ = this.get_bar(o).task.dependencies_type || this.options.dependencies_type;
1496
1611
  let m;
1497
1612
  this.options.move_dependencies && $ === "fixed" ? m = [
1498
- a,
1499
- ...this.get_all_dependent_tasks(a)
1500
- ] : m = [a], o = m.map((x) => this.get_bar(x)), this.bar_being_dragged = !1, _ = e, o.forEach((x) => {
1613
+ o,
1614
+ ...this.get_all_dependent_tasks(o)
1615
+ ] : m = [o], a = m.map((x) => this.get_bar(x)), this.bar_being_dragged = !1, d = e, a.forEach((x) => {
1501
1616
  const w = x.$bar;
1502
1617
  w.ox = w.getX(), w.oy = w.getY(), w.owidth = w.getWidth(), w.finaldx = 0;
1503
1618
  });
1504
1619
  }), this.options.infinite_padding) {
1505
- let g = !1;
1506
- p.on(this.$container, "mousewheel", (l) => {
1507
- let c = this.$container.scrollWidth / 2;
1508
- if (!g && l.currentTarget.scrollLeft <= c) {
1509
- let u = l.currentTarget.scrollLeft;
1510
- g = !0, this.gantt_start = d.add(
1620
+ let _ = !1;
1621
+ u.on(this.$container, "mousewheel", (l) => {
1622
+ let p = this.$container.scrollWidth / 2;
1623
+ if (!_ && l.currentTarget.scrollLeft <= p) {
1624
+ let g = l.currentTarget.scrollLeft;
1625
+ _ = !0, this.gantt_start = c.add(
1511
1626
  this.gantt_start,
1512
1627
  -this.config.extend_by_units,
1513
1628
  this.config.unit
1514
- ), this.setup_date_values(), this.render(), l.currentTarget.scrollLeft = u + this.config.column_width * this.config.extend_by_units, setTimeout(() => g = !1, 300);
1629
+ ), this.setup_date_values(), this.render(), l.currentTarget.scrollLeft = g + this.config.column_width * this.config.extend_by_units, setTimeout(() => _ = !1, 300);
1515
1630
  }
1516
- if (!g && l.currentTarget.scrollWidth - (l.currentTarget.scrollLeft + l.currentTarget.clientWidth) <= c) {
1517
- let u = l.currentTarget.scrollLeft;
1518
- g = !0, this.gantt_end = d.add(
1631
+ if (!_ && l.currentTarget.scrollWidth - (l.currentTarget.scrollLeft + l.currentTarget.clientWidth) <= p) {
1632
+ let g = l.currentTarget.scrollLeft;
1633
+ _ = !0, this.gantt_end = c.add(
1519
1634
  this.gantt_end,
1520
1635
  this.config.extend_by_units,
1521
1636
  this.config.unit
1522
- ), this.setup_date_values(), this.render(), l.currentTarget.scrollLeft = u, setTimeout(() => g = !1, 300);
1637
+ ), this.setup_date_values(), this.render(), l.currentTarget.scrollLeft = g, setTimeout(() => _ = !1, 300);
1523
1638
  }
1524
1639
  });
1525
1640
  }
1526
- p.on(this.$container, "scroll", (g) => {
1641
+ u.on(this.$container, "scroll", (_) => {
1527
1642
  let l = [];
1528
- const c = this.bars.map(
1643
+ const p = this.bars.map(
1529
1644
  ({ group: b }) => b.getAttribute("data-id")
1530
1645
  );
1531
- let u;
1532
- i && (u = g.currentTarget.scrollLeft - i), this.current_date = d.add(
1646
+ let g;
1647
+ i && (g = _.currentTarget.scrollLeft - i), this.current_date = c.add(
1533
1648
  this.gantt_start,
1534
- g.currentTarget.scrollLeft / this.config.column_width * this.config.step,
1649
+ _.currentTarget.scrollLeft / this.config.column_width * this.config.step,
1535
1650
  this.config.unit
1536
1651
  );
1537
1652
  let $ = this.config.view_mode.upper_text(
@@ -1541,9 +1656,9 @@ class B {
1541
1656
  ), m = this.upperTexts.find(
1542
1657
  (b) => b.textContent === $
1543
1658
  );
1544
- this.current_date = d.add(
1659
+ this.current_date = c.add(
1545
1660
  this.gantt_start,
1546
- (g.currentTarget.scrollLeft + m.clientWidth) / this.config.column_width * this.config.step,
1661
+ (_.currentTarget.scrollLeft + m.clientWidth) / this.config.column_width * this.config.step,
1547
1662
  this.config.unit
1548
1663
  ), $ = this.config.view_mode.upper_text(
1549
1664
  this.current_date,
@@ -1551,143 +1666,162 @@ class B {
1551
1666
  this.options.language
1552
1667
  ), m = this.upperTexts.find(
1553
1668
  (b) => b.textContent === $
1554
- ), m !== this.$current && (this.$current && this.$current.classList.remove("current-upper"), m.classList.add("current-upper"), this.$current = m), i = g.currentTarget.scrollLeft;
1669
+ ), m !== this.$current && (this.$current && this.$current.classList.remove("current-upper"), m.classList.add("current-upper"), this.$current = m), i = _.currentTarget.scrollLeft;
1555
1670
  let [x, w, X] = this.get_start_end_positions();
1556
1671
  i > X + 100 ? (this.$adjust.innerHTML = "&larr;", this.$adjust.classList.remove("hide"), this.$adjust.onclick = () => {
1557
1672
  this.$container.scrollTo({
1558
1673
  left: w,
1559
1674
  behavior: "smooth"
1560
1675
  });
1561
- }) : i + g.currentTarget.offsetWidth < x - 100 ? (this.$adjust.innerHTML = "&rarr;", this.$adjust.classList.remove("hide"), this.$adjust.onclick = () => {
1676
+ }) : i + _.currentTarget.offsetWidth < x - 100 ? (this.$adjust.innerHTML = "&rarr;", this.$adjust.classList.remove("hide"), this.$adjust.onclick = () => {
1562
1677
  this.$container.scrollTo({
1563
1678
  left: x,
1564
1679
  behavior: "smooth"
1565
1680
  });
1566
- }) : this.$adjust.classList.add("hide"), u && (l = c.map((b) => this.get_bar(b)), this.options.auto_move_label && l.forEach((b) => {
1681
+ }) : this.$adjust.classList.add("hide"), g && (l = p.map((b) => this.get_bar(b)), this.options.auto_move_label && l.forEach((b) => {
1567
1682
  b.update_label_position_on_horizontal_scroll({
1568
- x: u,
1569
- sx: g.currentTarget.scrollLeft
1683
+ x: g,
1684
+ sx: _.currentTarget.scrollLeft
1570
1685
  });
1571
1686
  }));
1572
- }), p.on(this.$svg, "mousemove", (g) => {
1687
+ }), u.on(this.$svg, "mousemove", (_) => {
1573
1688
  if (!h()) return;
1574
- const l = (g.offsetX || g.layerX) - e;
1575
- o.forEach((c) => {
1576
- const u = c.$bar;
1577
- u.finaldx = this.get_snap_position(l, u.ox), this.hide_popup(), s ? a === c.task.id ? c.update_bar_position({
1578
- x: u.ox + u.finaldx,
1579
- width: u.owidth - u.finaldx
1580
- }) : c.update_bar_position({
1581
- x: u.ox + u.finaldx
1582
- }) : n ? a === c.task.id && c.update_bar_position({
1583
- width: u.owidth + u.finaldx
1584
- }) : t && !this.options.readonly && !this.options.readonly_dates && c.update_bar_position({ x: u.ox + u.finaldx });
1689
+ const l = (_.offsetX || _.layerX) - e;
1690
+ a.forEach((p) => {
1691
+ const g = p.$bar;
1692
+ g.finaldx = this.get_snap_position(l, g.ox), this.hide_popup(), s ? o === p.task.id ? p.update_bar_position({
1693
+ x: g.ox + g.finaldx,
1694
+ width: g.owidth - g.finaldx
1695
+ }) : p.update_bar_position({
1696
+ x: g.ox + g.finaldx
1697
+ }) : n ? o === p.task.id && p.update_bar_position({
1698
+ width: g.owidth + g.finaldx
1699
+ }) : t && !this.options.readonly && !this.options.readonly_dates && p.update_bar_position({ x: g.ox + g.finaldx });
1585
1700
  });
1586
1701
  }), document.addEventListener("mouseup", () => {
1587
- var g, l, c;
1588
- t = !1, s = !1, n = !1, (c = (l = (g = this.$container.querySelector(".visible")) == null ? void 0 : g.classList) == null ? void 0 : l.remove) == null || c.call(l, "visible");
1589
- }), p.on(this.$svg, "mouseup", (g) => {
1590
- this.bar_being_dragged = null, o.forEach((c) => {
1591
- c.$bar.finaldx && (c.date_changed(), c.compute_progress(), c.set_action_completed());
1702
+ var _, l, p;
1703
+ t = !1, s = !1, n = !1, (p = (l = (_ = this.$container.querySelector(".visible")) == null ? void 0 : _.classList) == null ? void 0 : l.remove) == null || p.call(l, "visible");
1704
+ }), u.on(this.$svg, "mouseup", (_) => {
1705
+ this.bar_being_dragged = null;
1706
+ const l = [];
1707
+ a.forEach((g) => {
1708
+ g.$bar.finaldx && (g.date_changed(), g.compute_progress(), g.set_action_completed(), l.push({
1709
+ task: g.task,
1710
+ start: g.task._start,
1711
+ end: c.add(g.task._end, -1, "second")
1712
+ }));
1713
+ });
1714
+ const p = this.get_bar(o);
1715
+ if (p && p.$bar.finaldx) {
1716
+ const g = this.update_dependent_tasks_by_type(p);
1717
+ l.push(...g);
1718
+ }
1719
+ this.options.critical_path && a.some((g) => g.$bar.finaldx) && (this.calculate_critical_path(), this.update_arrow_critical_path()), l.length > 0 && l.forEach(({ task: g, start: $, end: m }) => {
1720
+ this.trigger_event("after_date_change", [g, $, m]);
1592
1721
  });
1593
- const l = this.get_bar(a);
1594
- l && l.$bar.finaldx && this.update_dependent_tasks_by_type(l);
1595
1722
  }), this.bind_bar_progress();
1596
1723
  }
1597
1724
  bind_bar_progress() {
1598
1725
  let t = 0, e = null, i = null, s = null, n = null;
1599
- p.on(this.$svg, "mousedown", ".handle.progress", (o, h) => {
1600
- e = !0, t = o.offsetX || o.layerX;
1601
- const g = p.closest(".bar-wrapper", h).getAttribute("data-id");
1602
- i = this.get_bar(g), 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();
1726
+ u.on(this.$svg, "mousedown", ".handle.progress", (a, h) => {
1727
+ e = !0, t = a.offsetX || a.layerX;
1728
+ const _ = u.closest(".bar-wrapper", h).getAttribute("data-id");
1729
+ 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();
1603
1730
  });
1604
- const a = this.config.ignored_positions.map((o) => [
1605
- o,
1606
- o + this.config.column_width
1731
+ const o = this.config.ignored_positions.map((a) => [
1732
+ a,
1733
+ a + this.config.column_width
1607
1734
  ]);
1608
- p.on(this.$svg, "mousemove", (o) => {
1735
+ u.on(this.$svg, "mousemove", (a) => {
1609
1736
  if (!e) return;
1610
- let h = o.offsetX || o.layerX;
1737
+ let h = a.offsetX || a.layerX;
1611
1738
  if (h > t) {
1612
- let l = a.find(
1613
- ([c, u]) => h >= c && h < u
1739
+ let l = o.find(
1740
+ ([p, g]) => h >= p && h < g
1614
1741
  );
1615
1742
  for (; l; )
1616
- h = l[1], l = a.find(
1617
- ([c, u]) => h >= c && h < u
1743
+ h = l[1], l = o.find(
1744
+ ([p, g]) => h >= p && h < g
1618
1745
  );
1619
1746
  } else {
1620
- let l = a.find(
1621
- ([c, u]) => h > c && h <= u
1747
+ let l = o.find(
1748
+ ([p, g]) => h > p && h <= g
1622
1749
  );
1623
1750
  for (; l; )
1624
- h = l[0], l = a.find(
1625
- ([c, u]) => h > c && h <= u
1751
+ h = l[0], l = o.find(
1752
+ ([p, g]) => h > p && h <= g
1626
1753
  );
1627
1754
  }
1628
- let g = h - t;
1629
- console.log(s), g > s.max_dx && (g = s.max_dx), g < s.min_dx && (g = s.min_dx), s.setAttribute("width", s.owidth + g), p.attr(i.$handle_progress, "cx", s.getEndX()), s.finaldx = g;
1630
- }), p.on(this.$svg, "mouseup", () => {
1755
+ let _ = h - t;
1756
+ console.log(s), _ > 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 = _;
1757
+ }), u.on(this.$svg, "mouseup", () => {
1631
1758
  e = !1, s && s.finaldx && (s.finaldx = 0, i.progress_changed(), i.set_action_completed(), i = null, s = null, n = null);
1632
1759
  });
1633
1760
  }
1634
1761
  get_all_dependent_tasks(t) {
1635
1762
  let e = [], i = [t];
1636
1763
  for (; i.length; ) {
1637
- const s = i.reduce((n, a) => (n = n.concat(this.dependency_map[a]), n), []);
1764
+ const s = i.reduce((n, o) => (n = n.concat(this.dependency_map[o]), n), []);
1638
1765
  e = e.concat(s), i = s.filter((n) => !i.includes(n));
1639
1766
  }
1640
1767
  return e.filter(Boolean);
1641
1768
  }
1642
1769
  update_dependent_tasks_by_type(t) {
1643
- if ((t.task.dependencies_type || this.options.dependencies_type) === "fixed") return;
1644
- (this.dependency_map[t.task.id] || []).forEach((s) => {
1645
- const n = this.get_bar(s);
1646
- if (!n) return;
1647
- const a = n.task, o = a.dependencies_type || this.options.dependencies_type;
1648
- let h, _;
1649
- const g = d.diff(a._end, a._start, "hour");
1650
- let l = !1;
1651
- switch (o) {
1770
+ const e = t.task.dependencies_type || this.options.dependencies_type, i = [];
1771
+ return e === "fixed" || (this.dependency_map[t.task.id] || []).forEach((n) => {
1772
+ const o = this.get_bar(n);
1773
+ if (!o) return;
1774
+ const a = o.task, h = a.dependencies_type || this.options.dependencies_type;
1775
+ let d, _;
1776
+ const l = c.diff(a._end, a._start, "hour");
1777
+ let p = !1;
1778
+ switch (h) {
1652
1779
  case "finish-to-start":
1653
- t.task._end > a._start && (h = new Date(t.task._end), _ = d.add(h, g, "hour"), l = !0);
1780
+ t.task._end > a._start && (d = new Date(t.task._end), _ = c.add(d, l, "hour"), p = !0);
1654
1781
  break;
1655
1782
  case "start-to-start":
1656
- t.task._start > a._start && (h = new Date(t.task._start), _ = d.add(h, g, "hour"), l = !0);
1783
+ t.task._start > a._start && (d = new Date(t.task._start), _ = c.add(d, l, "hour"), p = !0);
1657
1784
  break;
1658
1785
  case "finish-to-finish":
1659
- t.task._end > a._end && (_ = new Date(t.task._end), h = d.add(_, -g, "hour"), l = !0);
1786
+ t.task._end > a._end && (_ = new Date(t.task._end), d = c.add(_, -l, "hour"), p = !0);
1660
1787
  break;
1661
1788
  case "start-to-finish":
1662
- t.task._start > a._end && (_ = new Date(t.task._start), h = d.add(_, -g, "hour"), l = !0);
1789
+ t.task._start > a._end && (_ = new Date(t.task._start), d = c.add(_, -l, "hour"), p = !0);
1663
1790
  break;
1664
1791
  default:
1665
1792
  return;
1666
1793
  }
1667
- l && (a._start = h, a._end = _, n.compute_x(), n.compute_duration(), n.update_bar_position({
1668
- x: n.x,
1669
- width: n.width
1794
+ if (!p) return;
1795
+ a._start = d, a._end = _, o.compute_x(), o.compute_duration(), o.update_bar_position({
1796
+ x: o.x,
1797
+ width: o.width
1670
1798
  }), this.trigger_event("date_change", [
1671
1799
  a,
1672
- h,
1673
- d.add(_, -1, "second")
1674
- ]), this.update_dependent_tasks_by_type(n));
1675
- });
1800
+ d,
1801
+ c.add(_, -1, "second")
1802
+ ]), i.push({
1803
+ task: a,
1804
+ start: d,
1805
+ end: c.add(_, -1, "second")
1806
+ });
1807
+ const g = this.update_dependent_tasks_by_type(o);
1808
+ i.push(...g);
1809
+ }), i;
1676
1810
  }
1677
1811
  get_snap_position(t, e) {
1678
1812
  let i = 1;
1679
1813
  const s = this.options.snap_at || this.config.view_mode.snap_at || "1d";
1680
1814
  if (s !== "unit") {
1681
- const { duration: g, scale: l } = d.parse_duration(s);
1682
- i = d.convert_scales(this.config.view_mode.step, l) / g;
1815
+ const { duration: _, scale: l } = c.parse_duration(s);
1816
+ i = c.convert_scales(this.config.view_mode.step, l) / _;
1683
1817
  }
1684
1818
  const n = t % (this.config.column_width / i);
1685
- let a = t - n + (n < this.config.column_width / i * 2 ? 0 : this.config.column_width / i), o = e + a;
1686
- const h = a > 0 ? 1 : -1;
1687
- let _ = this.get_ignored_region(o, h);
1688
- for (; _.length; )
1689
- o += this.config.column_width * h, _ = this.get_ignored_region(o, h), _.length || (o -= this.config.column_width * h);
1690
- return o - e;
1819
+ let o = t - n + (n < this.config.column_width / i * 2 ? 0 : this.config.column_width / i), a = e + o;
1820
+ const h = o > 0 ? 1 : -1;
1821
+ let d = this.get_ignored_region(a, h);
1822
+ for (; d.length; )
1823
+ a += this.config.column_width * h, d = this.get_ignored_region(a, h), d.length || (a -= this.config.column_width * h);
1824
+ return a - e;
1691
1825
  }
1692
1826
  get_ignored_region(t, e = 1) {
1693
1827
  return e === 1 ? this.config.ignored_positions.filter((i) => t > i && t <= i + this.config.column_width) : this.config.ignored_positions.filter(
@@ -1707,7 +1841,7 @@ class B {
1707
1841
  return this.bars.find((e) => e.task.id === t);
1708
1842
  }
1709
1843
  show_popup(t) {
1710
- this.options.popup !== !1 && (this.popup || (this.popup = new O(
1844
+ this.options.popup !== !1 && (this.popup || (this.popup = new F(
1711
1845
  this.$popup_wrapper,
1712
1846
  this.options.popup,
1713
1847
  this
@@ -1736,11 +1870,11 @@ class B {
1736
1870
  * @memberof Gantt
1737
1871
  */
1738
1872
  clear() {
1739
- var t, e, i, s, n, a, o, h, _, g;
1740
- 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.$current_highlight) == null ? void 0 : n.remove) == null || a.call(n), (h = (o = this.$extras) == null ? void 0 : o.remove) == null || h.call(o), (g = (_ = this.popup) == null ? void 0 : _.hide) == null || g.call(_);
1873
+ var t, e, i, s, n, o, a, h, d, _;
1874
+ 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.$current_highlight) == null ? void 0 : n.remove) == null || o.call(n), (h = (a = this.$extras) == null ? void 0 : a.remove) == null || h.call(a), (_ = (d = this.popup) == null ? void 0 : d.hide) == null || _.call(d);
1741
1875
  }
1742
1876
  }
1743
- B.VIEW_MODE = {
1877
+ j.VIEW_MODE = {
1744
1878
  HOUR: y[0],
1745
1879
  QUARTER_DAY: y[1],
1746
1880
  HALF_DAY: y[2],
@@ -1749,12 +1883,12 @@ B.VIEW_MODE = {
1749
1883
  MONTH: y[5],
1750
1884
  YEAR: y[6]
1751
1885
  };
1752
- function j(r) {
1886
+ function B(r) {
1753
1887
  return r.name + "_" + Math.random().toString(36).slice(2, 12);
1754
1888
  }
1755
1889
  function k(r) {
1756
1890
  return r.replaceAll(" ", "_").replaceAll(":", "_").replaceAll(".", "_");
1757
1891
  }
1758
1892
  export {
1759
- B as default
1893
+ j as default
1760
1894
  };