@taskctrl/canvas-timeline 0.4.5 → 0.5.0

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,8 +1,8 @@
1
- import { jsx as se, jsxs as Ne, Fragment as Nt } from "react/jsx-runtime";
2
- import ge, { useRef as x, useCallback as ie, useEffect as he, forwardRef as fi, useMemo as oe, useState as Ke, useImperativeHandle as mi } from "react";
3
- import { flushSync as gi } from "react-dom";
4
- import pe from "dayjs";
5
- const Ee = {
1
+ import { jsx as se, jsxs as xe, Fragment as $t } from "react/jsx-runtime";
2
+ import me, { useRef as x, useMemo as Q, useCallback as ne, useEffect as he, forwardRef as pi, useState as tt, useImperativeHandle as vi } from "react";
3
+ import { flushSync as bi } from "react-dom";
4
+ import ve from "dayjs";
5
+ const Ce = {
6
6
  primary: "#269bf7",
7
7
  trainColors: {},
8
8
  status: { red: "#EF5350", yellow: "#FBBF24", green: "#31c48d" },
@@ -12,7 +12,7 @@ const Ee = {
12
12
  sidebar: { bg: "#F9FAFB", border: "#E5E7EB", text: "#6c737f" },
13
13
  header: { bg: "#F9FAFB", border: "#E5E7EB", text: "#6c737f" }
14
14
  };
15
- class ut {
15
+ class ft {
16
16
  constructor(e) {
17
17
  Object.defineProperty(this, "visibleTimeStart", {
18
18
  enumerable: !0,
@@ -59,6 +59,11 @@ class ut {
59
59
  configurable: !0,
60
60
  writable: !0,
61
61
  value: void 0
62
+ }), Object.defineProperty(this, "groupHeights", {
63
+ enumerable: !0,
64
+ configurable: !0,
65
+ writable: !0,
66
+ value: void 0
62
67
  }), Object.defineProperty(this, "visibleDuration", {
63
68
  enumerable: !0,
64
69
  configurable: !0,
@@ -69,10 +74,25 @@ class ut {
69
74
  configurable: !0,
70
75
  writable: !0,
71
76
  value: void 0
72
- }), this.visibleTimeStart = e.visibleTimeStart, this.visibleTimeEnd = e.visibleTimeEnd, this.canvasWidth = e.canvasWidth, this.canvasHeight = e.canvasHeight, this.sidebarWidth = e.sidebarWidth, this.lineHeight = e.lineHeight, this.groupCount = e.groupCount, this.buffer = e.buffer, this.scrollTop = e.scrollTop, this.visibleDuration = this.visibleTimeEnd - this.visibleTimeStart, this.pixelsPerMs = this.canvasWidth / this.visibleDuration;
77
+ }), Object.defineProperty(this, "groupYOffsets", {
78
+ enumerable: !0,
79
+ configurable: !0,
80
+ writable: !0,
81
+ value: void 0
82
+ }), this.visibleTimeStart = e.visibleTimeStart, this.visibleTimeEnd = e.visibleTimeEnd, this.canvasWidth = e.canvasWidth, this.canvasHeight = e.canvasHeight, this.sidebarWidth = e.sidebarWidth, this.lineHeight = e.lineHeight, this.groupCount = e.groupCount, this.buffer = e.buffer, this.scrollTop = e.scrollTop, this.groupHeights = e.groupHeights ?? null, this.visibleDuration = this.visibleTimeEnd - this.visibleTimeStart, this.pixelsPerMs = this.canvasWidth / this.visibleDuration, this.groupYOffsets = [], this.recomputeGroupYOffsets();
73
83
  }
74
84
  update(e) {
75
- e.visibleTimeStart !== void 0 && (this.visibleTimeStart = e.visibleTimeStart), e.visibleTimeEnd !== void 0 && (this.visibleTimeEnd = e.visibleTimeEnd), e.canvasWidth !== void 0 && (this.canvasWidth = e.canvasWidth), e.canvasHeight !== void 0 && (this.canvasHeight = e.canvasHeight), e.sidebarWidth !== void 0 && (this.sidebarWidth = e.sidebarWidth), e.lineHeight !== void 0 && (this.lineHeight = e.lineHeight), e.groupCount !== void 0 && (this.groupCount = e.groupCount), e.buffer !== void 0 && (this.buffer = e.buffer), e.scrollTop !== void 0 && (this.scrollTop = e.scrollTop), this.visibleDuration = this.visibleTimeEnd - this.visibleTimeStart, this.pixelsPerMs = this.canvasWidth / this.visibleDuration;
85
+ e.visibleTimeStart !== void 0 && (this.visibleTimeStart = e.visibleTimeStart), e.visibleTimeEnd !== void 0 && (this.visibleTimeEnd = e.visibleTimeEnd), e.canvasWidth !== void 0 && (this.canvasWidth = e.canvasWidth), e.canvasHeight !== void 0 && (this.canvasHeight = e.canvasHeight), e.sidebarWidth !== void 0 && (this.sidebarWidth = e.sidebarWidth), e.lineHeight !== void 0 && (this.lineHeight = e.lineHeight), e.groupCount !== void 0 && (this.groupCount = e.groupCount), e.buffer !== void 0 && (this.buffer = e.buffer), e.scrollTop !== void 0 && (this.scrollTop = e.scrollTop), e.groupHeights !== void 0 && (this.groupHeights = e.groupHeights ?? null), this.visibleDuration = this.visibleTimeEnd - this.visibleTimeStart, this.pixelsPerMs = this.canvasWidth / this.visibleDuration, this.recomputeGroupYOffsets();
86
+ }
87
+ recomputeGroupYOffsets() {
88
+ var t;
89
+ const e = new Array(this.groupCount + 1);
90
+ e[0] = 0;
91
+ for (let n = 0; n < this.groupCount; n++) {
92
+ const o = ((t = this.groupHeights) == null ? void 0 : t[n]) ?? this.lineHeight;
93
+ e[n + 1] = e[n] + o;
94
+ }
95
+ this.groupYOffsets = e;
76
96
  }
77
97
  timeToX(e) {
78
98
  return (e - this.visibleTimeStart) * this.pixelsPerMs;
@@ -81,11 +101,26 @@ class ut {
81
101
  return this.visibleTimeStart + e / this.pixelsPerMs;
82
102
  }
83
103
  yToGroupIndex(e) {
84
- const t = Math.floor((e + this.scrollTop) / this.lineHeight);
85
- return Math.max(0, Math.min(t, this.groupCount - 1));
104
+ if (this.groupCount === 0)
105
+ return 0;
106
+ const t = e + this.scrollTop;
107
+ if (t <= 0)
108
+ return 0;
109
+ if (t >= this.groupYOffsets[this.groupCount])
110
+ return this.groupCount - 1;
111
+ let n = 0, o = this.groupCount - 1;
112
+ for (; n < o; ) {
113
+ const d = n + o >>> 1;
114
+ this.groupYOffsets[d + 1] > t ? o = d : n = d + 1;
115
+ }
116
+ return n;
86
117
  }
87
118
  groupIndexToY(e) {
88
- return e * this.lineHeight - this.scrollTop;
119
+ return e < 0 ? -this.scrollTop : e >= this.groupCount ? (this.groupYOffsets[this.groupCount] ?? 0) - this.scrollTop : this.groupYOffsets[e] - this.scrollTop;
120
+ }
121
+ groupIndexToHeight(e) {
122
+ var t;
123
+ return e < 0 || e >= this.groupCount ? this.lineHeight : ((t = this.groupHeights) == null ? void 0 : t[e]) ?? this.lineHeight;
89
124
  }
90
125
  getBufferBounds() {
91
126
  const e = this.visibleDuration * 1.5;
@@ -95,18 +130,20 @@ class ut {
95
130
  };
96
131
  }
97
132
  getVisibleGroupRange() {
98
- const e = Math.max(0, Math.floor(this.scrollTop / this.lineHeight)), t = Math.ceil(this.canvasHeight / this.lineHeight), n = Math.min(this.groupCount - 1, e + t);
99
- return { firstVisible: e, lastVisible: n };
133
+ if (this.groupCount === 0)
134
+ return { firstVisible: 0, lastVisible: -1 };
135
+ const e = this.yToGroupIndex(0), t = this.yToGroupIndex(this.canvasHeight);
136
+ return { firstVisible: e, lastVisible: t };
100
137
  }
101
138
  isScrollInBuffer(e) {
102
139
  const t = this.visibleDuration * 1.5 * this.pixelsPerMs;
103
140
  return Math.abs(e) < t;
104
141
  }
105
142
  getTotalHeight() {
106
- return this.groupCount * this.lineHeight;
143
+ return this.groupYOffsets[this.groupCount] ?? 0;
107
144
  }
108
145
  }
109
- class pi {
146
+ class yi {
110
147
  constructor() {
111
148
  Object.defineProperty(this, "root", {
112
149
  enumerable: !0,
@@ -116,42 +153,42 @@ class pi {
116
153
  });
117
154
  }
118
155
  buildFromItems(e, t, n) {
119
- const s = e.map((d) => ({
156
+ const o = e.map((d) => ({
120
157
  item: d,
121
158
  start: t(d),
122
159
  end: n(d)
123
160
  }));
124
- this.root = this.buildNode(s);
161
+ this.root = this.buildNode(o);
125
162
  }
126
163
  buildNode(e) {
127
164
  if (e.length === 0)
128
165
  return null;
129
166
  let t = 1 / 0, n = -1 / 0;
130
- for (const c of e)
131
- c.start < t && (t = c.start), c.end > n && (n = c.end);
132
- const s = (t + n) / 2, d = [], a = [], u = [];
133
- for (const c of e)
134
- c.end < s ? d.push(c) : c.start > s ? a.push(c) : u.push(c);
167
+ for (const u of e)
168
+ u.start < t && (t = u.start), u.end > n && (n = u.end);
169
+ const o = (t + n) / 2, d = [], l = [], c = [];
170
+ for (const u of e)
171
+ u.end < o ? d.push(u) : u.start > o ? l.push(u) : c.push(u);
135
172
  return {
136
- center: s,
173
+ center: o,
137
174
  left: this.buildNode(d),
138
- right: this.buildNode(a),
139
- overlapping: u
175
+ right: this.buildNode(l),
176
+ overlapping: c
140
177
  };
141
178
  }
142
179
  query(e, t) {
143
180
  const n = [];
144
181
  return this.queryNode(this.root, e, t, n), n;
145
182
  }
146
- queryNode(e, t, n, s) {
183
+ queryNode(e, t, n, o) {
147
184
  if (e !== null) {
148
185
  for (const d of e.overlapping)
149
- d.start <= n && d.end >= t && s.push(d.item);
150
- t <= e.center && e.left !== null && this.queryNode(e.left, t, n, s), n >= e.center && e.right !== null && this.queryNode(e.right, t, n, s);
186
+ d.start <= n && d.end >= t && o.push(d.item);
187
+ t <= e.center && e.left !== null && this.queryNode(e.left, t, n, o), n >= e.center && e.right !== null && this.queryNode(e.right, t, n, o);
151
188
  }
152
189
  }
153
190
  }
154
- class vi {
191
+ class Ti {
155
192
  constructor(e, t) {
156
193
  Object.defineProperty(this, "lineHeight", {
157
194
  enumerable: !0,
@@ -177,65 +214,65 @@ class vi {
177
214
  }
178
215
  computeLayout(e, t, n) {
179
216
  this.layoutCache = /* @__PURE__ */ new Map(), this.groupMaxStack = /* @__PURE__ */ new Map();
180
- const s = this.lineHeight * this.itemHeightRatio, d = s * 0.6;
217
+ const o = this.lineHeight * this.itemHeightRatio, d = o * 0.6;
181
218
  if (!t) {
182
- for (const u of e) {
183
- const c = (n == null ? void 0 : n.isParent(u.id)) ?? !1;
184
- this.layoutCache.set(u.id, { stackLevel: 0, itemHeight: c ? d : s }), this.groupMaxStack.set(u.group, 0);
219
+ for (const c of e) {
220
+ const u = (n == null ? void 0 : n.isParent(c.id)) ?? !1;
221
+ this.layoutCache.set(c.id, { stackLevel: 0, itemHeight: u ? d : o }), this.groupMaxStack.set(c.group, 0);
185
222
  }
186
223
  return this.layoutCache;
187
224
  }
188
- const a = /* @__PURE__ */ new Map();
189
- for (const u of e) {
190
- let c = a.get(u.group);
191
- c || (c = [], a.set(u.group, c)), c.push(u);
225
+ const l = /* @__PURE__ */ new Map();
226
+ for (const c of e) {
227
+ let u = l.get(c.group);
228
+ u || (u = [], l.set(c.group, u)), u.push(c);
192
229
  }
193
- for (const [u, c] of a)
194
- n ? this.computeHierarchyLayout(c, n, s, d, u) : this.computeFlatLayout(c, s, u);
230
+ for (const [c, u] of l)
231
+ n ? this.computeHierarchyLayout(u, n, o, d, c) : this.computeFlatLayout(u, o, c);
195
232
  return this.layoutCache;
196
233
  }
197
234
  computeFlatLayout(e, t, n) {
198
- e.sort((a, u) => {
199
- const c = a.start_time - u.start_time;
200
- return c !== 0 ? c : u.end_time - u.start_time - (a.end_time - a.start_time);
235
+ e.sort((l, c) => {
236
+ const u = l.start_time - c.start_time;
237
+ return u !== 0 ? u : c.end_time - c.start_time - (l.end_time - l.start_time);
201
238
  });
202
- const s = [];
239
+ const o = [];
203
240
  let d = 0;
204
- for (const a of e) {
205
- let u = -1;
206
- for (let c = 0; c < s.length; c++)
207
- if (s[c] <= a.start_time) {
208
- u = c;
241
+ for (const l of e) {
242
+ let c = -1;
243
+ for (let u = 0; u < o.length; u++)
244
+ if (o[u] <= l.start_time) {
245
+ c = u;
209
246
  break;
210
247
  }
211
- u === -1 ? (u = s.length, s.push(a.end_time)) : s[u] = a.end_time, u > d && (d = u), this.layoutCache.set(a.id, { stackLevel: u, itemHeight: t });
248
+ c === -1 ? (c = o.length, o.push(l.end_time)) : o[c] = l.end_time, c > d && (d = c), this.layoutCache.set(l.id, { stackLevel: c, itemHeight: t });
212
249
  }
213
250
  this.groupMaxStack.set(n, d);
214
251
  }
215
- computeHierarchyLayout(e, t, n, s, d) {
216
- const a = [], u = [];
217
- for (const g of e)
218
- t.isParent(g.id) ? u.push(g) : a.push(g);
219
- a.sort((g, b) => {
220
- const T = g.start_time - b.start_time;
221
- return T !== 0 ? T : b.end_time - b.start_time - (g.end_time - g.start_time);
252
+ computeHierarchyLayout(e, t, n, o, d) {
253
+ const l = [], c = [];
254
+ for (const m of e)
255
+ t.isParent(m.id) ? c.push(m) : l.push(m);
256
+ l.sort((m, b) => {
257
+ const T = m.start_time - b.start_time;
258
+ return T !== 0 ? T : b.end_time - b.start_time - (m.end_time - m.start_time);
222
259
  });
223
- const c = [];
224
- let v = 0;
225
- for (const g of a) {
260
+ const u = [];
261
+ let p = 0;
262
+ for (const m of l) {
226
263
  let b = -1;
227
- for (let T = 0; T < c.length; T++)
228
- if (c[T] <= g.start_time) {
264
+ for (let T = 0; T < u.length; T++)
265
+ if (u[T] <= m.start_time) {
229
266
  b = T;
230
267
  break;
231
268
  }
232
- b === -1 ? (b = c.length, c.push(g.end_time)) : c[b] = g.end_time, b > v && (v = b), this.layoutCache.set(g.id, { stackLevel: b, itemHeight: n });
269
+ b === -1 ? (b = u.length, u.push(m.end_time)) : u[b] = m.end_time, b > p && (p = b), this.layoutCache.set(m.id, { stackLevel: b, itemHeight: n });
233
270
  }
234
- u.sort((g, b) => t.getNestingDepth(b.id) - t.getNestingDepth(g.id));
235
- let k = a.length > 0 ? v + 1 : 0;
236
- for (const g of u)
237
- this.layoutCache.set(g.id, { stackLevel: k, itemHeight: s }), k > v && (v = k), k++;
238
- this.groupMaxStack.set(d, v);
271
+ c.sort((m, b) => t.getNestingDepth(b.id) - t.getNestingDepth(m.id));
272
+ let M = l.length > 0 ? p + 1 : 0;
273
+ for (const m of c)
274
+ this.layoutCache.set(m.id, { stackLevel: M, itemHeight: o }), M > p && (p = M), M++;
275
+ this.groupMaxStack.set(d, p);
239
276
  }
240
277
  getLayout(e) {
241
278
  return this.layoutCache.get(e);
@@ -244,7 +281,7 @@ class vi {
244
281
  return ((this.groupMaxStack.get(e) ?? 0) + 1) * this.lineHeight;
245
282
  }
246
283
  }
247
- class bi {
284
+ class Si {
248
285
  constructor() {
249
286
  Object.defineProperty(this, "parentToChildren", {
250
287
  enumerable: !0,
@@ -280,19 +317,19 @@ class bi {
280
317
  }
281
318
  for (const t of this.childToParent.keys()) {
282
319
  const n = /* @__PURE__ */ new Set();
283
- let s = t;
284
- for (; s !== void 0; ) {
285
- if (n.has(s)) {
320
+ let o = t;
321
+ for (; o !== void 0; ) {
322
+ if (n.has(o)) {
286
323
  const d = this.childToParent.get(t);
287
324
  this.childToParent.delete(t);
288
- const a = this.parentToChildren.get(d);
289
- if (a) {
290
- const u = a.indexOf(t);
291
- u !== -1 && a.splice(u, 1), a.length === 0 && this.parentToChildren.delete(d);
325
+ const l = this.parentToChildren.get(d);
326
+ if (l) {
327
+ const c = l.indexOf(t);
328
+ c !== -1 && l.splice(c, 1), l.length === 0 && this.parentToChildren.delete(d);
292
329
  }
293
330
  break;
294
331
  }
295
- n.add(s), s = this.childToParent.get(s);
332
+ n.add(o), o = this.childToParent.get(o);
296
333
  }
297
334
  }
298
335
  }
@@ -309,9 +346,9 @@ class bi {
309
346
  getDescendants(e) {
310
347
  const t = [], n = [...this.getChildren(e)];
311
348
  for (; n.length > 0; ) {
312
- const s = n.pop();
313
- t.push(s);
314
- const d = this.parentToChildren.get(s);
349
+ const o = n.pop();
350
+ t.push(o);
351
+ const d = this.parentToChildren.get(o);
315
352
  d && n.push(...d);
316
353
  }
317
354
  return t;
@@ -320,31 +357,31 @@ class bi {
320
357
  const t = this.itemMap.get(e);
321
358
  if (!t)
322
359
  return { start: 0, end: 0 };
323
- let n = t.start_time, s = t.end_time;
360
+ let n = t.start_time, o = t.end_time;
324
361
  const d = this.getDescendants(e);
325
- for (const a of d) {
326
- const u = this.itemMap.get(a);
327
- u && (u.start_time < n && (n = u.start_time), u.end_time > s && (s = u.end_time));
362
+ for (const l of d) {
363
+ const c = this.itemMap.get(l);
364
+ c && (c.start_time < n && (n = c.start_time), c.end_time > o && (o = c.end_time));
328
365
  }
329
- return { start: n, end: s };
366
+ return { start: n, end: o };
330
367
  }
331
368
  getNestingDepth(e) {
332
369
  const t = this.depthCache.get(e);
333
370
  if (t !== void 0)
334
371
  return t;
335
- let n = 0, s = this.childToParent.get(e);
336
- for (; s !== void 0; )
337
- n++, s = this.childToParent.get(s);
372
+ let n = 0, o = this.childToParent.get(e);
373
+ for (; o !== void 0; )
374
+ n++, o = this.childToParent.get(o);
338
375
  return this.depthCache.set(e, n), n;
339
376
  }
340
377
  getMoveDelta(e, t) {
341
378
  const n = this.itemMap.get(e);
342
379
  if (!n)
343
380
  return [];
344
- const s = t - n.start_time;
345
- return this.getDescendants(e).map((a) => {
346
- const u = this.itemMap.get(a);
347
- return { itemId: a, newStart: u.start_time + s };
381
+ const o = t - n.start_time;
382
+ return this.getDescendants(e).map((l) => {
383
+ const c = this.itemMap.get(l);
384
+ return { itemId: l, newStart: c.start_time + o };
348
385
  });
349
386
  }
350
387
  getResizeConstraint(e, t) {
@@ -352,78 +389,78 @@ class bi {
352
389
  if (n.length === 0)
353
390
  return t === "left" ? { min: -1 / 0, max: 1 / 0 } : { min: -1 / 0, max: 1 / 0 };
354
391
  if (t === "left") {
355
- let s = 1 / 0;
392
+ let o = 1 / 0;
356
393
  for (const d of n) {
357
- const a = this.itemMap.get(d);
358
- a && a.start_time < s && (s = a.start_time);
394
+ const l = this.itemMap.get(d);
395
+ l && l.start_time < o && (o = l.start_time);
359
396
  }
360
- return { min: -1 / 0, max: s };
397
+ return { min: -1 / 0, max: o };
361
398
  } else {
362
- let s = -1 / 0;
399
+ let o = -1 / 0;
363
400
  for (const d of n) {
364
- const a = this.itemMap.get(d);
365
- a && a.end_time > s && (s = a.end_time);
401
+ const l = this.itemMap.get(d);
402
+ l && l.end_time > o && (o = l.end_time);
366
403
  }
367
- return { min: s, max: 1 / 0 };
404
+ return { min: o, max: 1 / 0 };
368
405
  }
369
406
  }
370
407
  }
371
- function yi(i, e, t, n, s, d) {
372
- const { x: a, y: u, width: c, height: v } = t, k = d.primary;
373
- i.globalAlpha = 0.15, i.fillStyle = k, i.fillRect(a, u, c, v), i.globalAlpha = 1, i.strokeStyle = k, i.lineWidth = 1.5, i.strokeRect(a, u, c, v);
374
- const g = Math.min(v * 0.5, 6), b = u + v / 2;
375
- i.fillStyle = k, i.beginPath(), i.moveTo(a, b), i.lineTo(a + g, b - g), i.lineTo(a + g * 2, b), i.lineTo(a + g, b + g), i.closePath(), i.fill(), i.beginPath(), i.moveTo(a + c, b), i.lineTo(a + c - g, b - g), i.lineTo(a + c - g * 2, b), i.lineTo(a + c - g, b + g), i.closePath(), i.fill();
408
+ function ki(i, e, t, n, o, d) {
409
+ const { x: l, y: c, width: u, height: p } = t, M = d.primary;
410
+ i.globalAlpha = 0.15, i.fillStyle = M, i.fillRect(l, c, u, p), i.globalAlpha = 1, i.strokeStyle = M, i.lineWidth = 1.5, i.strokeRect(l, c, u, p);
411
+ const m = Math.min(p * 0.5, 6), b = c + p / 2;
412
+ i.fillStyle = M, i.beginPath(), i.moveTo(l, b), i.lineTo(l + m, b - m), i.lineTo(l + m * 2, b), i.lineTo(l + m, b + m), i.closePath(), i.fill(), i.beginPath(), i.moveTo(l + u, b), i.lineTo(l + u - m, b - m), i.lineTo(l + u - m * 2, b), i.lineTo(l + u - m, b + m), i.closePath(), i.fill();
376
413
  const T = e.title;
377
- if (T && c > 30) {
414
+ if (T && u > 30) {
378
415
  i.fillStyle = d.item.text, i.font = '500 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif', i.textBaseline = "middle";
379
- const C = i.measureText(T).width, R = c - g * 4 - 4;
380
- if (R > 20) {
381
- const O = C > R ? T.slice(0, Math.floor(T.length * R / C)) + "..." : T;
382
- i.fillText(O, a + c / 2 - Math.min(C, R) / 2, b);
416
+ const H = i.measureText(T).width, O = u - m * 4 - 4;
417
+ if (O > 20) {
418
+ const j = H > O ? T.slice(0, Math.floor(T.length * O / H)) + "..." : T;
419
+ i.fillText(j, l + u / 2 - Math.min(H, O) / 2, b);
383
420
  }
384
421
  }
385
- n.selected && (i.strokeStyle = d.item.selectedRing, i.lineWidth = 2, i.strokeRect(a - 1, u - 1, c + 2, v + 2));
422
+ n.selected && (i.strokeStyle = d.item.selectedRing, i.lineWidth = 2, i.strokeRect(l - 1, c - 1, u + 2, p + 2));
386
423
  }
387
- function je(i, e, t, n, s, d) {
388
- const a = t.xToTime(i), u = /* @__PURE__ */ new Map();
389
- for (let g = 0; g < d.length; g++)
390
- u.set(d[g].id, g);
391
- const c = n.query(a, a);
392
- let v = null, k = -1 / 0;
393
- for (const g of c) {
394
- const b = u.get(g.group);
424
+ function $e(i, e, t, n, o, d) {
425
+ const l = t.xToTime(i), c = /* @__PURE__ */ new Map();
426
+ for (let m = 0; m < d.length; m++)
427
+ c.set(d[m].id, m);
428
+ const u = n.query(l, l);
429
+ let p = null, M = -1 / 0;
430
+ for (const m of u) {
431
+ const b = c.get(m.group);
395
432
  if (b === void 0)
396
433
  continue;
397
- const T = s.getLayout(g.id);
434
+ const T = o.getLayout(m.id);
398
435
  if (!T)
399
436
  continue;
400
- const C = t.timeToX(g.start_time), R = t.timeToX(g.end_time) - C;
401
- if (i < C || i > C + R)
437
+ const H = t.timeToX(m.start_time), O = t.timeToX(m.end_time) - H;
438
+ if (i < H || i > H + O)
402
439
  continue;
403
- const $ = t.groupIndexToY(b) + T.stackLevel * t.lineHeight + (t.lineHeight - T.itemHeight) / 2, S = T.itemHeight;
404
- e < $ || e > $ + S || $ > k && (k = $, v = g);
440
+ const re = t.groupIndexToY(b) + T.stackLevel * t.lineHeight + (t.lineHeight - T.itemHeight) / 2, w = T.itemHeight;
441
+ e < re || e > re + w || re > M && (M = re, p = m);
405
442
  }
406
- return v;
443
+ return p;
407
444
  }
408
- function dt(i, e, t) {
445
+ function mt(i, e, t) {
409
446
  const n = e.yToGroupIndex(i);
410
447
  return t[n] ?? null;
411
448
  }
412
- function Ft(i, e, t, n = 6) {
413
- const s = t.timeToX(e.start_time), d = t.timeToX(e.end_time);
414
- return i - s <= n ? "left" : d - i <= n ? "right" : "body";
449
+ function Bt(i, e, t, n = 6) {
450
+ const o = t.timeToX(e.start_time), d = t.timeToX(e.end_time);
451
+ return i - o <= n ? "left" : d - i <= n ? "right" : "body";
415
452
  }
416
- function ht(i, e, t) {
417
- const n = window.devicePixelRatio || 1, s = Math.round(e * n), d = Math.round(t * n);
418
- (i.width !== s || i.height !== d) && (i.width = s, i.height = d, i.style.width = `${e}px`, i.style.height = `${t}px`);
419
- const a = i.getContext("2d");
420
- return a.setTransform(n, 0, 0, n, 0, 0), a;
453
+ function gt(i, e, t) {
454
+ const n = window.devicePixelRatio || 1, o = Math.round(e * n), d = Math.round(t * n);
455
+ (i.width !== o || i.height !== d) && (i.width = o, i.height = d, i.style.width = `${e}px`, i.style.height = `${t}px`);
456
+ const l = i.getContext("2d");
457
+ return l.setTransform(n, 0, 0, n, 0, 0), l;
421
458
  }
422
- function ft(i, e) {
459
+ function pt(i, e) {
423
460
  const t = window.devicePixelRatio || 1;
424
461
  i.clearRect(0, 0, e.width / t, e.height / t);
425
462
  }
426
- class Ti {
463
+ class wi {
427
464
  constructor(e) {
428
465
  Object.defineProperty(this, "dirty", {
429
466
  enumerable: !0,
@@ -459,101 +496,101 @@ class Ti {
459
496
  }));
460
497
  }
461
498
  }
462
- class Si {
463
- draw(e, t, n, s, d, a, u) {
464
- const { firstVisible: c, lastVisible: v } = t.getVisibleGroupRange();
465
- for (let S = c; S <= v; S++) {
466
- const F = t.groupIndexToY(S), B = n[S];
467
- if (!B)
499
+ class Mi {
500
+ draw(e, t, n, o, d, l, c) {
501
+ const { firstVisible: u, lastVisible: p } = t.getVisibleGroupRange();
502
+ for (let w = u; w <= p; w++) {
503
+ const X = t.groupIndexToY(w), E = t.groupIndexToHeight(w), R = n[w];
504
+ if (!R)
468
505
  continue;
469
- let A;
470
- const Z = a == null ? void 0 : a(B);
471
- Z != null && Z.backgroundColor ? A = Z.backgroundColor : A = S % 2 === 0 ? "#FFFFFF" : s.grid.rowAlt, e.fillStyle = A, e.fillRect(0, F, t.canvasWidth, t.lineHeight), e.strokeStyle = (Z == null ? void 0 : Z.borderBottomColor) ?? s.grid.line, e.lineWidth = 0.5, e.beginPath(), e.moveTo(0, F + t.lineHeight), e.lineTo(t.canvasWidth, F + t.lineHeight), e.stroke();
506
+ let z;
507
+ const B = l == null ? void 0 : l(R);
508
+ B != null && B.backgroundColor ? z = B.backgroundColor : z = w % 2 === 0 ? "#FFFFFF" : o.grid.rowAlt, e.fillStyle = z, e.fillRect(0, X, t.canvasWidth, E), e.strokeStyle = (B == null ? void 0 : B.borderBottomColor) ?? o.grid.line, e.lineWidth = 0.5, e.beginPath(), e.moveTo(0, X + E), e.lineTo(t.canvasWidth, X + E), e.stroke();
472
509
  }
473
- if (u && u.length > 0)
474
- for (const S of u) {
475
- const F = t.timeToX(S.start), B = t.timeToX(S.end);
476
- if (B < 0 || F > t.canvasWidth)
510
+ if (c && c.length > 0)
511
+ for (const w of c) {
512
+ const X = t.timeToX(w.start), E = t.timeToX(w.end);
513
+ if (E < 0 || X > t.canvasWidth)
477
514
  continue;
478
- const A = Math.max(0, F), Z = Math.min(t.canvasWidth, B) - A, ne = S.opacity ?? 0.12, P = parseInt(S.color.slice(1, 3), 16), L = parseInt(S.color.slice(3, 5), 16), q = parseInt(S.color.slice(5, 7), 16);
479
- e.fillStyle = `rgb(${Math.round(P * ne + 255 * (1 - ne))},${Math.round(L * ne + 255 * (1 - ne))},${Math.round(q * ne + 255 * (1 - ne))})`, e.fillRect(A, 0, Z, t.canvasHeight);
515
+ const R = Math.max(0, X), z = Math.min(t.canvasWidth, E) - R, B = w.opacity ?? 0.12, _ = parseInt(w.color.slice(1, 3), 16), G = parseInt(w.color.slice(3, 5), 16), q = parseInt(w.color.slice(5, 7), 16);
516
+ e.fillStyle = `rgb(${Math.round(_ * B + 255 * (1 - B))},${Math.round(G * B + 255 * (1 - B))},${Math.round(q * B + 255 * (1 - B))})`, e.fillRect(R, 0, z, t.canvasHeight);
480
517
  }
481
- const k = t.visibleTimeStart, g = t.visibleTimeEnd, C = 864e5 / (g - k) * t.canvasWidth;
482
- let R = "day";
483
- C < 2 ? R = "month" : C < 8 && (R = "week");
518
+ const M = t.visibleTimeStart, m = t.visibleTimeEnd, H = 864e5 / (m - M) * t.canvasWidth;
519
+ let O = "day";
520
+ H < 2 ? O = "month" : H < 8 && (O = "week");
484
521
  {
485
- let S = pe(k).startOf("day");
486
- const F = pe(g).endOf("day");
487
- let B = null, A = 1, Z = 0;
488
- const ne = [], P = (L) => {
489
- B !== null && (e.fillStyle = B, A !== 1 && (e.globalAlpha = A), e.fillRect(Z, 0, L - Z, t.canvasHeight), A !== 1 && (e.globalAlpha = 1), B = null, A = 1);
522
+ let w = ve(M).startOf("day");
523
+ const X = ve(m).endOf("day");
524
+ let E = null, R = 1, z = 0;
525
+ const B = [], _ = (G) => {
526
+ E !== null && (e.fillStyle = E, R !== 1 && (e.globalAlpha = R), e.fillRect(z, 0, G - z, t.canvasHeight), R !== 1 && (e.globalAlpha = 1), E = null, R = 1);
490
527
  };
491
- for (; S.isBefore(F); ) {
492
- const L = t.timeToX(S.valueOf()), q = S.toDate(), J = d == null ? void 0 : d(q);
493
- let te = null, ue = 1;
528
+ for (; w.isBefore(X); ) {
529
+ const G = t.timeToX(w.valueOf()), q = w.toDate(), J = d == null ? void 0 : d(q);
530
+ let oe = null, ue = 1;
494
531
  if (J != null && J.backgroundColor)
495
- te = J.backgroundColor, ue = J.opacity ?? 1;
532
+ oe = J.backgroundColor, ue = J.opacity ?? 1;
496
533
  else {
497
- const be = S.day();
498
- (be === 0 || be === 6) && (te = s.grid.weekend);
534
+ const ye = w.day();
535
+ (ye === 0 || ye === 6) && (oe = o.grid.weekend);
499
536
  }
500
- J != null && J.borderColor && ne.push({ x: L, color: J.borderColor }), te === B && ue === A || (P(L), te !== null && (B = te, A = ue, Z = L)), S = S.add(1, "day");
537
+ J != null && J.borderColor && B.push({ x: G, color: J.borderColor }), oe === E && ue === R || (_(G), oe !== null && (E = oe, R = ue, z = G)), w = w.add(1, "day");
501
538
  }
502
- B !== null && P(t.timeToX(S.valueOf()));
503
- for (const L of ne)
504
- e.strokeStyle = L.color, e.lineWidth = 0.5, e.beginPath(), e.moveTo(L.x, 0), e.lineTo(L.x, t.canvasHeight), e.stroke();
539
+ E !== null && _(t.timeToX(w.valueOf()));
540
+ for (const G of B)
541
+ e.strokeStyle = G.color, e.lineWidth = 0.5, e.beginPath(), e.moveTo(G.x, 0), e.lineTo(G.x, t.canvasHeight), e.stroke();
505
542
  }
506
- let O = pe(k).startOf(R);
507
- const $ = pe(g).add(1, R);
508
- for (e.strokeStyle = s.grid.line, e.lineWidth = 0.5, e.beginPath(); O.isBefore($); ) {
509
- const S = t.timeToX(O.valueOf());
510
- e.moveTo(S, 0), e.lineTo(S, t.canvasHeight), O = O.add(1, R);
543
+ let j = ve(M).startOf(O);
544
+ const re = ve(m).add(1, O);
545
+ for (e.strokeStyle = o.grid.line, e.lineWidth = 0.5, e.beginPath(); j.isBefore(re); ) {
546
+ const w = t.timeToX(j.valueOf());
547
+ e.moveTo(w, 0), e.lineTo(w, t.canvasHeight), j = j.add(1, O);
511
548
  }
512
- if (e.stroke(), u && u.length > 0)
513
- for (const S of u) {
514
- const F = t.timeToX(S.start), B = t.timeToX(S.end);
515
- if (!(B < 0 || F > t.canvasWidth) && (e.strokeStyle = S.color, e.globalAlpha = 0.4, e.lineWidth = 1, e.beginPath(), F >= 0 && F <= t.canvasWidth && (e.moveTo(F, 0), e.lineTo(F, t.canvasHeight)), B >= 0 && B <= t.canvasWidth && (e.moveTo(B, 0), e.lineTo(B, t.canvasHeight)), e.stroke(), e.globalAlpha = 1, S.label)) {
516
- const A = Math.max(0, F), Z = Math.min(t.canvasWidth, B) - A;
549
+ if (e.stroke(), c && c.length > 0)
550
+ for (const w of c) {
551
+ const X = t.timeToX(w.start), E = t.timeToX(w.end);
552
+ if (!(E < 0 || X > t.canvasWidth) && (e.strokeStyle = w.color, e.globalAlpha = 0.4, e.lineWidth = 1, e.beginPath(), X >= 0 && X <= t.canvasWidth && (e.moveTo(X, 0), e.lineTo(X, t.canvasHeight)), E >= 0 && E <= t.canvasWidth && (e.moveTo(E, 0), e.lineTo(E, t.canvasHeight)), e.stroke(), e.globalAlpha = 1, w.label)) {
553
+ const R = Math.max(0, X), z = Math.min(t.canvasWidth, E) - R;
517
554
  e.save(), e.font = '600 10px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
518
- const ne = e.measureText(S.label).width, P = 6, L = ne + P * 2, q = 18, J = A + (Z - L) / 2, te = 4;
519
- e.fillStyle = S.color, e.globalAlpha = 0.9, e.beginPath(), e.roundRect(J, te, L, q, 3), e.fill(), e.globalAlpha = 1, e.fillStyle = "#FFFFFF", e.textBaseline = "middle", e.fillText(S.label, J + P, te + q / 2), e.restore();
555
+ const B = e.measureText(w.label).width, _ = 6, G = B + _ * 2, q = 18, J = R + (z - G) / 2, oe = 4;
556
+ e.fillStyle = w.color, e.globalAlpha = 0.9, e.beginPath(), e.roundRect(J, oe, G, q, 3), e.fill(), e.globalAlpha = 1, e.fillStyle = "#FFFFFF", e.textBaseline = "middle", e.fillText(w.label, J + _, oe + q / 2), e.restore();
520
557
  }
521
558
  }
522
559
  }
523
560
  }
524
- const Ot = '500 12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
561
+ const Yt = '500 12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
525
562
  function xt(i, e) {
526
563
  return {
527
564
  /**
528
565
  * Draws a filled rounded rectangle.
529
566
  * Default corner radius is 3px.
530
567
  */
531
- roundRect(t, n, s, d, a = 3) {
532
- i.beginPath(), i.roundRect(t, n, s, d, a), i.fill();
568
+ roundRect(t, n, o, d, l = 3) {
569
+ i.beginPath(), i.roundRect(t, n, o, d, l), i.fill();
533
570
  },
534
571
  /**
535
572
  * Draws text at (x, y) using the standard item font.
536
573
  * If maxWidth is provided and the text is too wide, binary-search truncates it
537
574
  * and appends '...' so it fits within maxWidth.
538
575
  */
539
- fillText(t, n, s, d) {
540
- if (i.font = Ot, d !== void 0 && i.measureText(t).width > d) {
541
- let a = 0, u = t.length;
542
- for (; a < u; ) {
543
- const c = Math.ceil((a + u) / 2), v = t.slice(0, c) + "...";
544
- i.measureText(v).width <= d ? a = c : u = c - 1;
576
+ fillText(t, n, o, d) {
577
+ if (i.font = Yt, d !== void 0 && i.measureText(t).width > d) {
578
+ let l = 0, c = t.length;
579
+ for (; l < c; ) {
580
+ const u = Math.ceil((l + c) / 2), p = t.slice(0, u) + "...";
581
+ i.measureText(p).width <= d ? l = u : c = u - 1;
545
582
  }
546
- i.fillText(t.slice(0, a) + "...", n, s);
583
+ i.fillText(t.slice(0, l) + "...", n, o);
547
584
  } else
548
- i.fillText(t, n, s);
585
+ i.fillText(t, n, o);
549
586
  },
550
587
  /**
551
588
  * Creates a 50/50 linear gradient from color1 (0%–50%) to color2 (50%–100%)
552
589
  * spanning the given x position and width.
553
590
  */
554
- gradient(t, n, s, d) {
555
- const a = i.createLinearGradient(t, 0, t + n, 0);
556
- return a.addColorStop(0, s), a.addColorStop(0.5, s), a.addColorStop(0.5, d), a.addColorStop(1, d), a;
591
+ gradient(t, n, o, d) {
592
+ const l = i.createLinearGradient(t, 0, t + n, 0);
593
+ return l.addColorStop(0, o), l.addColorStop(0.5, o), l.addColorStop(0.5, d), l.addColorStop(1, d), l;
557
594
  },
558
595
  /**
559
596
  * Draws a vertical colored bar on the left edge of the item bounds.
@@ -567,124 +604,124 @@ function xt(i, e) {
567
604
  * Supported types: 'check', 'danger-red', 'danger-yellow'.
568
605
  * Default size is 14px.
569
606
  */
570
- icon(t, n, s, d = 14) {
607
+ icon(t, n, o, d = 14) {
571
608
  i.save();
572
- const a = d / 2;
609
+ const l = d / 2;
573
610
  if (t === "check") {
574
- i.fillStyle = "#31c48d", i.beginPath(), i.arc(n + a, s + a, a, 0, Math.PI * 2), i.fill(), i.strokeStyle = "#ffffff", i.lineWidth = d * 0.12, i.beginPath();
575
- const u = n + a, c = s + a;
576
- i.moveTo(u - a * 0.45, c), i.lineTo(u - a * 0.1, c + a * 0.42), i.lineTo(u + a * 0.45, c - a * 0.35), i.stroke();
611
+ i.fillStyle = "#31c48d", i.beginPath(), i.arc(n + l, o + l, l, 0, Math.PI * 2), i.fill(), i.strokeStyle = "#ffffff", i.lineWidth = d * 0.12, i.beginPath();
612
+ const c = n + l, u = o + l;
613
+ i.moveTo(c - l * 0.45, u), i.lineTo(c - l * 0.1, u + l * 0.42), i.lineTo(c + l * 0.45, u - l * 0.35), i.stroke();
577
614
  } else if (t === "danger-red" || t === "danger-yellow") {
578
- const u = t === "danger-red" ? "#EF5350" : "#FBBF24";
579
- i.fillStyle = u, i.beginPath(), i.moveTo(n + a, s), i.lineTo(n + d, s + d), i.lineTo(n, s + d), i.closePath(), i.fill(), i.fillStyle = "#ffffff";
580
- const c = d * 0.12, v = n + a - c / 2;
581
- i.fillRect(v, s + d * 0.35, c, d * 0.35), i.beginPath(), i.arc(n + a, s + d * 0.82, c * 0.7, 0, Math.PI * 2), i.fill();
615
+ const c = t === "danger-red" ? "#EF5350" : "#FBBF24";
616
+ i.fillStyle = c, i.beginPath(), i.moveTo(n + l, o), i.lineTo(n + d, o + d), i.lineTo(n, o + d), i.closePath(), i.fill(), i.fillStyle = "#ffffff";
617
+ const u = d * 0.12, p = n + l - u / 2;
618
+ i.fillRect(p, o + d * 0.35, u, d * 0.35), i.beginPath(), i.arc(n + l, o + d * 0.82, u * 0.7, 0, Math.PI * 2), i.fill();
582
619
  }
583
620
  i.restore();
584
621
  },
585
622
  /**
586
623
  * Draws a pill-shaped badge with centered white text on a colored background.
587
624
  */
588
- badge(t, n, s, d) {
589
- i.save(), i.font = Ot;
590
- const u = i.measureText(t).width, c = 8, k = 12 + 3 * 2, g = u + c * 2, b = k / 2;
591
- i.fillStyle = d, i.beginPath(), i.roundRect(n, s, g, k, b), i.fill(), i.fillStyle = "#ffffff", i.textAlign = "center", i.textBaseline = "middle", i.fillText(t, n + g / 2, s + k / 2), i.restore();
625
+ badge(t, n, o, d) {
626
+ i.save(), i.font = Yt;
627
+ const c = i.measureText(t).width, u = 8, M = 12 + 3 * 2, m = c + u * 2, b = M / 2;
628
+ i.fillStyle = d, i.beginPath(), i.roundRect(n, o, m, M, b), i.fill(), i.fillStyle = "#ffffff", i.textAlign = "center", i.textBaseline = "middle", i.fillText(t, n + m / 2, o + M / 2), i.restore();
592
629
  }
593
630
  };
594
631
  }
595
- class Mi {
596
- draw(e, t, n, s, d, a, u, c, v, k, g, b, T, C) {
597
- const R = (t.visibleTimeEnd - t.visibleTimeStart) * 0.1, O = t.visibleTimeStart - R, $ = t.visibleTimeEnd + R, S = d.query(O, $), F = /* @__PURE__ */ new Map();
598
- for (let P = 0; P < n.length; P++)
599
- F.set(n[P].id, P);
600
- const B = new Set(k), A = /* @__PURE__ */ new Map(), Z = -t.lineHeight, ne = t.canvasHeight + t.lineHeight;
601
- for (const P of S) {
602
- const L = F.get(P.group);
603
- if (L === void 0)
632
+ class Ei {
633
+ draw(e, t, n, o, d, l, c, u, p, M, m, b, T, H) {
634
+ const O = (t.visibleTimeEnd - t.visibleTimeStart) * 0.1, j = t.visibleTimeStart - O, re = t.visibleTimeEnd + O, w = d.query(j, re), X = /* @__PURE__ */ new Map();
635
+ for (let _ = 0; _ < n.length; _++)
636
+ X.set(n[_].id, _);
637
+ const E = new Set(M), R = /* @__PURE__ */ new Map(), z = -t.lineHeight, B = t.canvasHeight + t.lineHeight;
638
+ for (const _ of w) {
639
+ const G = X.get(_.group);
640
+ if (G === void 0)
604
641
  continue;
605
- const q = a.getLayout(P.id);
642
+ const q = l.getLayout(_.id);
606
643
  if (!q)
607
644
  continue;
608
- const te = t.groupIndexToY(L) + q.stackLevel * t.lineHeight + (t.lineHeight - q.itemHeight) / 2, ue = q.itemHeight;
609
- if (te + ue < Z || te > ne)
645
+ const oe = t.groupIndexToY(G) + q.stackLevel * t.lineHeight + (t.lineHeight - q.itemHeight) / 2, ue = q.itemHeight;
646
+ if (oe + ue < z || oe > B)
610
647
  continue;
611
- const be = t.timeToX(P.start_time), Re = t.timeToX(P.end_time) - be, ye = { x: be, y: te, width: Re, height: ue };
612
- A.set(P.id, ye);
613
- const Pe = {
614
- selected: B.has(P.id),
615
- hovered: g === P.id,
648
+ const ye = t.timeToX(_.start_time), Oe = t.timeToX(_.end_time) - ye, Te = { x: ye, y: oe, width: Oe, height: ue };
649
+ R.set(_.id, Te);
650
+ const Xe = {
651
+ selected: E.has(_.id),
652
+ hovered: m === _.id,
616
653
  dragging: !1,
617
- filtered: P.filtered !== !1
654
+ filtered: _.filtered !== !1
618
655
  };
619
656
  e.save();
620
- const xe = xt(e, ye);
621
- let Ce;
622
- T && (C != null && C.isParent(P.id)) ? Ce = T : c && (P.type === "control_area_group" || P.type === "construction_train") ? Ce = c : Ce = u, Ce(e, P, ye, Pe, xe), e.restore();
657
+ const Ve = xt(e, Te);
658
+ let He;
659
+ T && (H != null && H.isParent(_.id)) ? He = T : u && (_.type === "control_area_group" || _.type === "construction_train") ? He = u : He = c, He(e, _, Te, Xe, Ve), e.restore();
623
660
  }
624
661
  if (b && b.length > 0) {
625
- const P = /* @__PURE__ */ new Set();
626
- for (const L of b)
627
- A.has(L.fromItemId) || P.add(L.fromItemId), A.has(L.toItemId) || P.add(L.toItemId);
628
- if (P.size > 0) {
629
- const L = /* @__PURE__ */ new Map();
630
- for (const q of s)
631
- P.has(q.id) && L.set(q.id, q);
632
- for (const [q, J] of L) {
633
- const te = F.get(J.group);
634
- if (te === void 0)
662
+ const _ = /* @__PURE__ */ new Set();
663
+ for (const G of b)
664
+ R.has(G.fromItemId) || _.add(G.fromItemId), R.has(G.toItemId) || _.add(G.toItemId);
665
+ if (_.size > 0) {
666
+ const G = /* @__PURE__ */ new Map();
667
+ for (const q of o)
668
+ _.has(q.id) && G.set(q.id, q);
669
+ for (const [q, J] of G) {
670
+ const oe = X.get(J.group);
671
+ if (oe === void 0)
635
672
  continue;
636
- const ue = a.getLayout(q);
673
+ const ue = l.getLayout(q);
637
674
  if (!ue)
638
675
  continue;
639
- const Re = t.groupIndexToY(te) + ue.stackLevel * t.lineHeight + (t.lineHeight - ue.itemHeight) / 2, ye = t.timeToX(J.start_time), Pe = t.timeToX(J.end_time) - ye;
640
- A.set(q, { x: ye, y: Re, width: Pe, height: ue.itemHeight });
676
+ const Oe = t.groupIndexToY(oe) + ue.stackLevel * t.lineHeight + (t.lineHeight - ue.itemHeight) / 2, Te = t.timeToX(J.start_time), Xe = t.timeToX(J.end_time) - Te;
677
+ R.set(q, { x: Te, y: Oe, width: Xe, height: ue.itemHeight });
641
678
  }
642
679
  }
643
- this.drawDependencies(e, b, A, g, v);
680
+ this.drawDependencies(e, b, R, m, p);
644
681
  }
645
682
  }
646
- drawDependencies(e, t, n, s, d) {
647
- for (const a of t) {
648
- const u = n.get(a.fromItemId), c = n.get(a.toItemId);
649
- if (!u || !c)
683
+ drawDependencies(e, t, n, o, d) {
684
+ for (const l of t) {
685
+ const c = n.get(l.fromItemId), u = n.get(l.toItemId);
686
+ if (!c || !u)
650
687
  continue;
651
- const v = s === a.fromItemId || s === a.toItemId;
652
- e.strokeStyle = v ? d.primary : a.color ?? "#94A3B8", e.lineWidth = v ? 2 : 1.5, e.setLineDash([]);
653
- const k = u.x + u.width, g = u.y + u.height / 2, b = c.x, T = c.y + c.height / 2, C = Math.abs(b - k), R = Math.max(C * 0.4, 30);
654
- e.beginPath(), e.moveTo(k, g), e.bezierCurveTo(k + R, g, b - R, T, b, T), e.stroke();
655
- const O = 6;
656
- e.fillStyle = e.strokeStyle, e.beginPath(), e.moveTo(b, T), e.lineTo(b - O, T - O / 2), e.lineTo(b - O, T + O / 2), e.closePath(), e.fill();
688
+ const p = o === l.fromItemId || o === l.toItemId;
689
+ e.strokeStyle = p ? d.primary : l.color ?? "#94A3B8", e.lineWidth = p ? 2 : 1.5, e.setLineDash([]);
690
+ const M = c.x + c.width, m = c.y + c.height / 2, b = u.x, T = u.y + u.height / 2, H = Math.abs(b - M), O = Math.max(H * 0.4, 30);
691
+ e.beginPath(), e.moveTo(M, m), e.bezierCurveTo(M + O, m, b - O, T, b, T), e.stroke();
692
+ const j = 6;
693
+ e.fillStyle = e.strokeStyle, e.beginPath(), e.moveTo(b, T), e.lineTo(b - j, T - j / 2), e.lineTo(b - j, T + j / 2), e.closePath(), e.fill();
657
694
  }
658
695
  }
659
696
  }
660
- class ki {
661
- draw(e, t, n, s) {
662
- const { cursorX: d, snapX: a, markers: u, interaction: c } = s;
663
- if (u)
664
- for (const v of u) {
665
- const k = t.timeToX(v.date);
666
- if (e.fillStyle = v.color, e.fillRect(k - v.width / 2, 0, v.width, t.canvasHeight), v.label) {
697
+ class Ci {
698
+ draw(e, t, n, o) {
699
+ const { cursorX: d, snapX: l, markers: c, interaction: u } = o;
700
+ if (c)
701
+ for (const p of c) {
702
+ const M = t.timeToX(p.date);
703
+ if (e.fillStyle = p.color, e.fillRect(M - p.width / 2, 0, p.width, t.canvasHeight), p.label) {
667
704
  e.save(), e.font = '500 10px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
668
- const g = e.measureText(v.label).width, b = 8, T = 200, C = Math.min(g + b * 2, T), R = 20, O = k - C / 2, $ = 4;
669
- e.fillStyle = v.color, e.beginPath(), e.roundRect(O, $, C, R, 3), e.fill(), e.fillStyle = "#FFFFFF", e.textBaseline = "middle";
670
- const S = T - b * 2, F = g > S ? v.label.slice(0, Math.floor(v.label.length * S / g)) + "…" : v.label;
671
- e.fillText(F, O + b, $ + R / 2), e.restore();
705
+ const m = e.measureText(p.label).width, b = 8, T = 200, H = Math.min(m + b * 2, T), O = 20, j = M - H / 2, re = 4;
706
+ e.fillStyle = p.color, e.beginPath(), e.roundRect(j, re, H, O, 3), e.fill(), e.fillStyle = "#FFFFFF", e.textBaseline = "middle";
707
+ const w = T - b * 2, X = m > w ? p.label.slice(0, Math.floor(p.label.length * w / m)) + "…" : p.label;
708
+ e.fillText(X, j + b, re + O / 2), e.restore();
672
709
  }
673
710
  }
674
- if (d != null && (e.strokeStyle = n.marker.cursor, e.lineWidth = 1, e.beginPath(), e.moveTo(d, 0), e.lineTo(d, t.canvasHeight), e.stroke()), a != null && (e.strokeStyle = n.primary, e.lineWidth = 1, e.setLineDash([4, 4]), e.beginPath(), e.moveTo(a, 0), e.lineTo(a, t.canvasHeight), e.stroke(), e.setLineDash([])), c) {
675
- c.groupChanged && c.targetGroupY !== void 0 && (e.fillStyle = "rgba(59, 130, 246, 0.08)", e.fillRect(0, c.targetGroupY, t.canvasWidth, t.lineHeight)), e.save(), e.globalAlpha = 0.5;
676
- const v = xt(e, c.bounds);
677
- c.renderer(e, c.item, c.bounds, { selected: !1, hovered: !1, dragging: !0, filtered: !0 }, v), e.restore();
711
+ if (d != null && (e.strokeStyle = n.marker.cursor, e.lineWidth = 1, e.beginPath(), e.moveTo(d, 0), e.lineTo(d, t.canvasHeight), e.stroke()), l != null && (e.strokeStyle = n.primary, e.lineWidth = 1, e.setLineDash([4, 4]), e.beginPath(), e.moveTo(l, 0), e.lineTo(l, t.canvasHeight), e.stroke(), e.setLineDash([])), u) {
712
+ u.groupChanged && u.targetGroupY !== void 0 && (e.fillStyle = "rgba(59, 130, 246, 0.08)", e.fillRect(0, u.targetGroupY, t.canvasWidth, t.lineHeight)), e.save(), e.globalAlpha = 0.5;
713
+ const p = xt(e, u.bounds);
714
+ u.renderer(e, u.item, u.bounds, { selected: !1, hovered: !1, dragging: !0, filtered: !0 }, p), e.restore();
678
715
  }
679
716
  }
680
717
  }
681
- const Wt = 120;
682
- function wi(i) {
718
+ const Lt = 120;
719
+ function Hi(i) {
683
720
  let e = i.deltaY || i.deltaX;
684
- return i.deltaMode === 1 ? e *= 15 : i.deltaMode === 2 && (e *= 800), Math.max(-Wt, Math.min(Wt, e));
721
+ return i.deltaMode === 1 ? e *= 15 : i.deltaMode === 2 && (e *= 800), Math.max(-Lt, Math.min(Lt, e));
685
722
  }
686
- class Ei {
687
- constructor(e, t, n, s, d) {
723
+ class Ii {
724
+ constructor(e, t, n, o, d) {
688
725
  Object.defineProperty(this, "onZoom", {
689
726
  enumerable: !0,
690
727
  configurable: !0,
@@ -710,21 +747,21 @@ class Ei {
710
747
  configurable: !0,
711
748
  writable: !0,
712
749
  value: void 0
713
- }), this.onZoom = e, this.visibleTimeStart = t, this.visibleTimeEnd = n, this.minZoom = s, this.maxZoom = d;
750
+ }), this.onZoom = e, this.visibleTimeStart = t, this.visibleTimeEnd = n, this.minZoom = o, this.maxZoom = d;
714
751
  }
715
752
  updateBounds(e, t) {
716
753
  this.visibleTimeStart = e, this.visibleTimeEnd = t;
717
754
  }
718
755
  handleWheelZoom(e, t) {
719
- const n = wi(e), s = e.ctrlKey ? 10 : e.metaKey ? 3 : 1, d = n > 0 ? 1 + s * n / 500 : 1 / (1 + s * -n / 500), a = this.visibleTimeEnd - this.visibleTimeStart;
720
- let u = Math.round(a * d);
721
- u = Math.max(this.minZoom, Math.min(this.maxZoom, u));
722
- const c = Math.round(this.visibleTimeStart + (a - u) * t), v = c + u;
723
- this.onZoom(c, v);
756
+ const n = Hi(e), o = e.ctrlKey ? 10 : e.metaKey ? 3 : 1, d = n > 0 ? 1 + o * n / 500 : 1 / (1 + o * -n / 500), l = this.visibleTimeEnd - this.visibleTimeStart;
757
+ let c = Math.round(l * d);
758
+ c = Math.max(this.minZoom, Math.min(this.maxZoom, c));
759
+ const u = Math.round(this.visibleTimeStart + (l - c) * t), p = u + c;
760
+ this.onZoom(u, p);
724
761
  }
725
762
  }
726
- const Ci = 4;
727
- class Hi {
763
+ const Ri = 4;
764
+ class Pi {
728
765
  constructor(e) {
729
766
  Object.defineProperty(this, "state", {
730
767
  enumerable: !0,
@@ -743,21 +780,21 @@ class Hi {
743
780
  value: !1
744
781
  }), this.dragSnap = e;
745
782
  }
746
- startInteraction(e, t, n, s) {
783
+ startInteraction(e, t, n, o) {
747
784
  this.state = {
748
785
  item: e,
749
786
  mode: t,
750
787
  startX: n,
751
- startY: s,
788
+ startY: o,
752
789
  currentX: n,
753
- currentY: s,
790
+ currentY: o,
754
791
  deltaX: 0,
755
792
  originalGroup: e.group,
756
793
  currentGroup: e.group
757
794
  }, this.activated = !1;
758
795
  }
759
796
  update(e, t) {
760
- this.state && (this.state.currentX = e, this.state.currentY = t, this.state.deltaX = e - this.state.startX, !this.activated && Math.abs(this.state.deltaX) >= Ci && (this.activated = !0));
797
+ this.state && (this.state.currentX = e, this.state.currentY = t, this.state.deltaX = e - this.state.startX, !this.activated && Math.abs(this.state.deltaX) >= Ri && (this.activated = !0));
761
798
  }
762
799
  setCurrentGroup(e) {
763
800
  this.state && (this.state.currentGroup = e);
@@ -765,14 +802,14 @@ class Hi {
765
802
  endMove(e) {
766
803
  if (!this.state)
767
804
  return null;
768
- const t = this.state.deltaX / e, n = this.state.item.start_time + t, s = Math.round(n / this.dragSnap) * this.dragSnap, d = this.state.currentGroup;
769
- return this.state = null, this.activated = !1, { newStartTime: s, newGroupId: d };
805
+ const t = this.state.deltaX / e, n = this.state.item.start_time + t, o = Math.round(n / this.dragSnap) * this.dragSnap, d = this.state.currentGroup;
806
+ return this.state = null, this.activated = !1, { newStartTime: o, newGroupId: d };
770
807
  }
771
808
  endResize(e) {
772
809
  if (!this.state)
773
810
  return null;
774
- const t = this.state.deltaX / e, n = this.state.mode === "resize-left" ? "left" : "right", d = (n === "left" ? this.state.item.start_time : this.state.item.end_time) + t, a = Math.round(d / this.dragSnap) * this.dragSnap;
775
- return this.state = null, this.activated = !1, { newTime: a, edge: n };
811
+ const t = this.state.deltaX / e, n = this.state.mode === "resize-left" ? "left" : "right", d = (n === "left" ? this.state.item.start_time : this.state.item.end_time) + t, l = Math.round(d / this.dragSnap) * this.dragSnap;
812
+ return this.state = null, this.activated = !1, { newTime: l, edge: n };
776
813
  }
777
814
  cancel() {
778
815
  this.state = null, this.activated = !1;
@@ -791,105 +828,125 @@ class Hi {
791
828
  return this.state !== null;
792
829
  }
793
830
  }
794
- function mt(i, e, t) {
831
+ function vt(i, e, t) {
795
832
  const n = [];
796
- for (const s of i)
797
- s.id !== e && (n.push(t(s.start_time)), n.push(t(s.end_time)));
833
+ for (const o of i)
834
+ o.id !== e && (n.push(t(o.start_time)), n.push(t(o.end_time)));
798
835
  return n;
799
836
  }
800
- function Je(i, e, t, n, s) {
837
+ function it(i, e, t, n, o) {
801
838
  if (e.length === 0)
802
839
  return null;
803
- let d = e[0], a = Math.abs(i - d);
804
- for (let u = 1; u < e.length; u++) {
805
- const c = Math.abs(i - e[u]);
806
- c < a && (a = c, d = e[u]);
840
+ let d = e[0], l = Math.abs(i - d);
841
+ for (let c = 1; c < e.length; c++) {
842
+ const u = Math.abs(i - e[c]);
843
+ u < l && (l = u, d = e[c]);
807
844
  }
808
- return a <= t ? d : null;
845
+ return l <= t ? d : null;
809
846
  }
810
- var zt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
811
- function $t(i) {
847
+ var Vt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
848
+ function Zt(i) {
812
849
  return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
813
850
  }
814
- var Gt = { exports: {} };
851
+ var qt = { exports: {} };
815
852
  (function(i, e) {
816
853
  (function(t, n) {
817
854
  i.exports = n();
818
- })(zt, function() {
855
+ })(Vt, function() {
819
856
  var t = "day";
820
- return function(n, s, d) {
821
- var a = function(v) {
822
- return v.add(4 - v.isoWeekday(), t);
823
- }, u = s.prototype;
824
- u.isoWeekYear = function() {
825
- return a(this).year();
826
- }, u.isoWeek = function(v) {
827
- if (!this.$utils().u(v)) return this.add(7 * (v - this.isoWeek()), t);
828
- var k, g, b, T, C = a(this), R = (k = this.isoWeekYear(), g = this.$u, b = (g ? d.utc : d)().year(k).startOf("year"), T = 4 - b.isoWeekday(), b.isoWeekday() > 4 && (T += 7), b.add(T, t));
829
- return C.diff(R, "week") + 1;
830
- }, u.isoWeekday = function(v) {
831
- return this.$utils().u(v) ? this.day() || 7 : this.day(this.day() % 7 ? v : v - 7);
857
+ return function(n, o, d) {
858
+ var l = function(p) {
859
+ return p.add(4 - p.isoWeekday(), t);
860
+ }, c = o.prototype;
861
+ c.isoWeekYear = function() {
862
+ return l(this).year();
863
+ }, c.isoWeek = function(p) {
864
+ if (!this.$utils().u(p)) return this.add(7 * (p - this.isoWeek()), t);
865
+ var M, m, b, T, H = l(this), O = (M = this.isoWeekYear(), m = this.$u, b = (m ? d.utc : d)().year(M).startOf("year"), T = 4 - b.isoWeekday(), b.isoWeekday() > 4 && (T += 7), b.add(T, t));
866
+ return H.diff(O, "week") + 1;
867
+ }, c.isoWeekday = function(p) {
868
+ return this.$utils().u(p) ? this.day() || 7 : this.day(this.day() % 7 ? p : p - 7);
832
869
  };
833
- var c = u.startOf;
834
- u.startOf = function(v, k) {
835
- var g = this.$utils(), b = !!g.u(k) || k;
836
- return g.p(v) === "isoweek" ? b ? this.date(this.date() - (this.isoWeekday() - 1)).startOf("day") : this.date(this.date() - 1 - (this.isoWeekday() - 1) + 7).endOf("day") : c.bind(this)(v, k);
870
+ var u = c.startOf;
871
+ c.startOf = function(p, M) {
872
+ var m = this.$utils(), b = !!m.u(M) || M;
873
+ return m.p(p) === "isoweek" ? b ? this.date(this.date() - (this.isoWeekday() - 1)).startOf("day") : this.date(this.date() - 1 - (this.isoWeekday() - 1) + 7).endOf("day") : u.bind(this)(p, M);
837
874
  };
838
875
  };
839
876
  });
840
- })(Gt);
841
- var Ii = Gt.exports;
842
- const Ri = /* @__PURE__ */ $t(Ii), Bt = 5;
843
- function Lt({ groups: i, width: e, lineHeight: t, scrollTop: n, canvasHeight: s, theme: d, groupRenderer: a, onScroll: u }) {
844
- var O;
845
- const c = x(null), v = x(!1), k = i.length * t, g = s, b = Math.max(0, Math.floor(n / t) - Bt), T = Math.min(i.length - 1, Math.ceil((n + s) / t) + Bt), C = ie(($) => {
846
- v.current || u($.currentTarget.scrollTop);
877
+ })(qt);
878
+ var Di = qt.exports;
879
+ const Oi = /* @__PURE__ */ Zt(Di), At = 200;
880
+ function jt({ groups: i, width: e, lineHeight: t, groupHeights: n, scrollTop: o, canvasHeight: d, theme: l, groupRenderer: c, onScroll: u }) {
881
+ var X;
882
+ const p = x(null), M = x(!1), m = Q(() => {
883
+ const E = new Array(i.length + 1);
884
+ E[0] = 0;
885
+ for (let R = 0; R < i.length; R++)
886
+ E[R + 1] = E[R] + ((n == null ? void 0 : n[R]) ?? t);
887
+ return E;
888
+ }, [i.length, n, t]), b = m[i.length] ?? 0, T = d, H = ne((E) => {
889
+ if (i.length === 0 || E <= 0)
890
+ return 0;
891
+ if (E >= b)
892
+ return i.length - 1;
893
+ let R = 0, z = i.length - 1;
894
+ for (; R < z; ) {
895
+ const B = R + z >>> 1;
896
+ m[B + 1] > E ? z = B : R = B + 1;
897
+ }
898
+ return R;
899
+ }, [i.length, m, b]), O = H(o - At), j = H(o + d + At), re = ne((E) => {
900
+ M.current || u(E.currentTarget.scrollTop);
847
901
  }, [u]);
848
902
  he(() => {
849
- c.current && (v.current = !0, c.current.scrollTop = n, requestAnimationFrame(() => {
850
- v.current = !1;
903
+ p.current && (M.current = !0, p.current.scrollTop = o, requestAnimationFrame(() => {
904
+ M.current = !1;
851
905
  }));
852
- }, [n]);
853
- const R = [];
854
- for (let $ = b; $ <= T; $++) {
855
- const S = i[$];
856
- S && R.push(se("div", { style: {
906
+ }, [o]);
907
+ const w = [];
908
+ for (let E = O; E <= j; E++) {
909
+ const R = i[E];
910
+ if (!R)
911
+ continue;
912
+ const z = m[E], B = m[E + 1] - z;
913
+ w.push(se("div", { style: {
857
914
  position: "absolute",
858
- top: $ * t,
859
- height: t,
915
+ top: z,
916
+ height: B,
860
917
  width: "100%",
861
918
  overflow: "hidden",
862
919
  display: "flex",
863
920
  alignItems: "stretch",
864
- borderBottom: `1px solid ${((O = d.grid) == null ? void 0 : O.line) ?? "#E5E5E5"}`,
921
+ borderBottom: `1px solid ${((X = l.grid) == null ? void 0 : X.line) ?? "#E5E5E5"}`,
865
922
  boxSizing: "border-box"
866
- }, children: a(S) }, S.id));
923
+ }, children: c(R) }, R.id));
867
924
  }
868
- return se("div", { ref: c, onScroll: C, style: {
925
+ return se("div", { ref: p, onScroll: re, style: {
869
926
  width: e,
870
- height: g,
871
- overflowY: k > s ? "auto" : "hidden",
927
+ height: T,
928
+ overflowY: b > d ? "auto" : "hidden",
872
929
  overflowX: "hidden",
873
930
  position: "relative",
874
- borderRight: `1px solid ${d.sidebar.border}`,
875
- backgroundColor: d.sidebar.bg
876
- }, children: se("div", { style: { height: k, position: "relative" }, children: R }) });
931
+ borderRight: `1px solid ${l.sidebar.border}`,
932
+ backgroundColor: l.sidebar.bg
933
+ }, children: se("div", { style: { height: b, position: "relative" }, children: w }) });
877
934
  }
878
- function Pi(i) {
935
+ function Xi(i) {
879
936
  return null;
880
937
  }
881
- Pi.displayName = "TodayMarker";
882
- function Yt(i) {
938
+ Xi.displayName = "TodayMarker";
939
+ function Gt(i) {
883
940
  return { date: Math.floor(Date.now() / 6e4) * 6e4, color: i.color ?? "#FD7171", width: i.width ?? 6, label: i.label };
884
941
  }
885
- function Di(i) {
942
+ function _i(i) {
886
943
  return i.interval ?? 1e4;
887
944
  }
888
- function Xi(i) {
945
+ function Fi(i) {
889
946
  return null;
890
947
  }
891
- Xi.displayName = "CustomMarker";
892
- function At(i) {
948
+ Fi.displayName = "CustomMarker";
949
+ function Nt(i) {
893
950
  return {
894
951
  date: i.date,
895
952
  color: i.color ?? "#3B82F6",
@@ -897,555 +954,571 @@ function At(i) {
897
954
  label: i.label
898
955
  };
899
956
  }
900
- pe.extend(Ri);
901
- function _i(i) {
957
+ ve.extend(Oi);
958
+ function Wi(i) {
902
959
  return i ? {
903
- ...Ee,
960
+ ...Ce,
904
961
  ...i,
905
- status: { ...Ee.status, ...i.status },
906
- grid: { ...Ee.grid, ...i.grid },
907
- item: { ...Ee.item, ...i.item },
908
- marker: { ...Ee.marker, ...i.marker },
909
- sidebar: { ...Ee.sidebar, ...i.sidebar },
910
- header: { ...Ee.header, ...i.header }
911
- } : Ee;
962
+ status: { ...Ce.status, ...i.status },
963
+ grid: { ...Ce.grid, ...i.grid },
964
+ item: { ...Ce.item, ...i.item },
965
+ marker: { ...Ce.marker, ...i.marker },
966
+ sidebar: { ...Ce.sidebar, ...i.sidebar },
967
+ header: { ...Ce.header, ...i.header }
968
+ } : Ce;
912
969
  }
913
- const jt = 32, Vi = ge.memo(fi(function(e, t) {
914
- const { groups: n, items: s, defaultTimeStart: d, defaultTimeEnd: a, sidebarWidth: u, lineHeight: c, itemHeightRatio: v, stackItems: k, canMove: g, canChangeGroup: b, canResize: T, dragSnap: C, minZoom: R, maxZoom: O, theme: $, dayStyle: S, rowStyle: F, showCursorLine: B, itemRenderer: A, groupRenderer: Z, sidebarGroupRenderer: ne, dependencies: P, highlights: L, onItemClick: q, onItemDoubleClick: J, onItemContextMenu: te, onItemMove: ue, onItemResize: be, moveResizeValidator: Re, onItemHover: ye, onCanvasDoubleClick: Pe, onCanvasContextMenu: xe, onTimeChange: Ce, onZoom: gt, selected: pt = [], rightSidebarWidth: Qe, rightSidebarGroupRenderer: vt, onReady: ze, devBadge: Zt, children: Se } = e, Te = oe(() => _i($), [$]), bt = ie((r, o) => {
915
- for (let h = 0; h < o.length; h++)
916
- if (o[h].id === r)
970
+ const zt = 32, Ui = me.memo(pi(function(e, t) {
971
+ const { groups: n, items: o, defaultTimeStart: d, defaultTimeEnd: l, sidebarWidth: c, lineHeight: u, itemHeightRatio: p, stackItems: M, canMove: m, canChangeGroup: b, canResize: T, dragSnap: H, minZoom: O, maxZoom: j, theme: re, dayStyle: w, rowStyle: X, showCursorLine: E, itemRenderer: R, groupRenderer: z, sidebarGroupRenderer: B, dependencies: _, highlights: G, onItemClick: q, onItemDoubleClick: J, onItemContextMenu: oe, onItemMove: ue, onItemResize: ye, moveResizeValidator: Oe, onItemHover: Te, onCanvasDoubleClick: Xe, onCanvasContextMenu: Ve, onTimeChange: He, onZoom: bt, selected: yt = [], rightSidebarWidth: nt, rightSidebarGroupRenderer: Tt, onReady: Ze, devBadge: Kt, children: ke } = e, Se = Q(() => Wi(re), [re]), St = ne((r, s) => {
972
+ for (let h = 0; h < s.length; h++)
973
+ if (s[h].id === r)
917
974
  return h;
918
975
  return 0;
919
- }, []), qt = pt.join(","), et = oe(() => pt, [qt]), yt = x(null), Tt = x(null), St = x(null), Oe = x(null), Mt = x(null), Ut = x(null), [Kt, Jt] = Ke(800);
976
+ }, []), Jt = yt.join(","), rt = Q(() => yt, [Jt]), kt = x(null), wt = x(null), Mt = x(null), Ye = x(null), Et = x(null), Qt = x(null), [ei, ti] = tt(800);
920
977
  he(() => {
921
- const r = Mt.current;
978
+ const r = Et.current;
922
979
  if (!r)
923
980
  return;
924
- const o = new ResizeObserver((h) => {
981
+ const s = new ResizeObserver((h) => {
925
982
  const f = h[0];
926
- f && Jt(f.contentRect.width);
983
+ f && ti(f.contentRect.width);
927
984
  });
928
- return o.observe(r), () => o.disconnect();
985
+ return s.observe(r), () => s.disconnect();
929
986
  }, []);
930
- const Me = Math.max(0, Kt - u - (Qe ?? 0)), ke = n.length * c, D = x(new ut({
987
+ const we = Math.max(0, ei - c - (nt ?? 0)), Ie = Q(() => {
988
+ const r = new Si();
989
+ return r.rebuild(o), r;
990
+ }, [o]), ot = Q(() => {
991
+ const r = new yi();
992
+ return r.buildFromItems(o, (s) => Ie.getEffectiveSpan(s.id).start, (s) => Ie.getEffectiveSpan(s.id).end), r;
993
+ }, [o, Ie]), Le = Q(() => {
994
+ const r = new Ti(u, p);
995
+ return r.computeLayout(o, M, Ie), r;
996
+ }, [o, u, p, M, Ie]), Re = Q(() => n.map((r) => Le.getGroupHeight(r.id)), [n, Le]), Me = Q(() => Re.reduce((r, s) => r + s, 0), [Re]), F = x(new ft({
931
997
  visibleTimeStart: e.visibleTimeStart ?? d,
932
- visibleTimeEnd: e.visibleTimeEnd ?? a,
933
- canvasWidth: Me,
934
- canvasHeight: ke,
935
- sidebarWidth: u,
936
- lineHeight: c,
998
+ visibleTimeEnd: e.visibleTimeEnd ?? l,
999
+ canvasWidth: we,
1000
+ canvasHeight: Me,
1001
+ sidebarWidth: c,
1002
+ lineHeight: u,
937
1003
  groupCount: n.length,
938
1004
  buffer: e.buffer ?? 3,
939
- scrollTop: 0
940
- })), tt = x(null), We = x(void 0), ve = x(null), He = x(!1), kt = 4, [wt, Qt] = Ke(e.visibleTimeStart ?? d), [Et, ei] = Ke(e.visibleTimeEnd ?? a), [Ct, $e] = Ke(0), Be = x(null), De = ie(() => {
941
- const r = D.current;
942
- Qt(r.visibleTimeStart), ei(r.visibleTimeEnd), $e(r.scrollTop), Be.current = null;
943
- }, []), it = ie(() => {
944
- Be.current === null && (Be.current = setTimeout(De, jt));
945
- }, [De]);
1005
+ scrollTop: 0,
1006
+ groupHeights: Re
1007
+ })), st = x(null), Ae = x(void 0), be = x(null), Pe = x(!1), Ct = 4, [Ht, ii] = tt(e.visibleTimeStart ?? d), [It, ni] = tt(e.visibleTimeEnd ?? l), [Rt, qe] = tt(0), je = x(null), _e = ne(() => {
1008
+ const r = F.current;
1009
+ ii(r.visibleTimeStart), ni(r.visibleTimeEnd), qe(r.scrollTop), je.current = null;
1010
+ }, []), lt = ne(() => {
1011
+ je.current === null && (je.current = setTimeout(_e, zt));
1012
+ }, [_e]);
946
1013
  he(() => () => {
947
- Be.current !== null && clearTimeout(Be.current);
1014
+ je.current !== null && clearTimeout(je.current);
948
1015
  }, []);
949
- const Ie = oe(() => {
950
- const r = new bi();
951
- return r.rebuild(s), r;
952
- }, [s]), nt = oe(() => {
953
- const r = new pi();
954
- return r.buildFromItems(s, (o) => Ie.getEffectiveSpan(o.id).start, (o) => Ie.getEffectiveSpan(o.id).end), r;
955
- }, [s, Ie]), rt = oe(() => {
956
- const r = new vi(c, v);
957
- return r.computeLayout(s, k, Ie), r;
958
- }, [s, c, v, k, Ie]), Ht = oe(() => e.summaryRenderer ? e.summaryRenderer : (r, o, h, f, l) => {
959
- yi(r, o, h, f, l, Te);
960
- }, [e.summaryRenderer, Te]), Xe = oe(() => new Si(), []), _e = oe(() => new Mi(), []), Fe = oe(() => new ki(), []), Q = oe(() => new Hi(C), [C]), Ge = oe(() => {
1016
+ const Pt = Q(() => e.summaryRenderer ? e.summaryRenderer : (r, s, h, f, a) => {
1017
+ ki(r, s, h, f, a, Se);
1018
+ }, [e.summaryRenderer, Se]), Fe = Q(() => new Mi(), []), We = Q(() => new Ei(), []), Be = Q(() => new Ci(), []), ee = Q(() => new Pi(H), [H]), Ue = Q(() => {
961
1019
  const r = [];
962
- return ge.Children.forEach(Se, (o) => {
1020
+ return me.Children.forEach(ke, (s) => {
963
1021
  var f;
964
- if (!ge.isValidElement(o))
1022
+ if (!me.isValidElement(s))
965
1023
  return;
966
- const h = (f = o.type) == null ? void 0 : f.displayName;
967
- h === "TodayMarker" ? r.push(Yt(o.props)) : h === "CustomMarker" && r.push(At(o.props));
1024
+ const h = (f = s.type) == null ? void 0 : f.displayName;
1025
+ h === "TodayMarker" ? r.push(Gt(s.props)) : h === "CustomMarker" && r.push(Nt(s.props));
968
1026
  }), r;
969
- }, [Se]), Ve = oe(() => Ge.map((r) => `${r.date}|${r.color}|${r.width}|${r.label ?? ""}`).join(";"), [Ge]), Le = x(Ge);
970
- Le.current = Ge;
971
- const ot = oe(() => {
1027
+ }, [ke]), Ke = Q(() => Ue.map((r) => `${r.date}|${r.color}|${r.width}|${r.label ?? ""}`).join(";"), [Ue]), Ge = x(Ue);
1028
+ Ge.current = Ue;
1029
+ const at = Q(() => {
972
1030
  let r = 0;
973
- return ge.Children.forEach(Se, (o) => {
1031
+ return me.Children.forEach(ke, (s) => {
974
1032
  var f;
975
- if (!ge.isValidElement(o))
1033
+ if (!me.isValidElement(s))
976
1034
  return;
977
- ((f = o.type) == null ? void 0 : f.displayName) === "TodayMarker" && (r = Di(o.props));
1035
+ ((f = s.type) == null ? void 0 : f.displayName) === "TodayMarker" && (r = _i(s.props));
978
1036
  }), r;
979
- }, [Se]), _ = x({
1037
+ }, [ke]), Y = x({
980
1038
  groups: n,
981
- items: s,
982
- intervalTree: nt,
983
- layoutEngine: rt,
984
- itemRenderer: A,
985
- groupRenderer: Z,
986
- theme: Te,
987
- selected: et,
988
- dependencies: P,
989
- highlights: L,
990
- dayStyle: S,
991
- rowStyle: F,
992
- showCursorLine: B,
993
- canvasWidth: Me,
994
- canvasHeight: ke,
995
- lineHeight: c,
996
- itemHeightRatio: v,
997
- onTimeChange: Ce,
998
- onZoom: gt,
999
- onItemHover: ye,
1039
+ items: o,
1040
+ intervalTree: ot,
1041
+ layoutEngine: Le,
1042
+ itemRenderer: R,
1043
+ groupRenderer: z,
1044
+ theme: Se,
1045
+ selected: rt,
1046
+ dependencies: _,
1047
+ highlights: G,
1048
+ dayStyle: w,
1049
+ rowStyle: X,
1050
+ showCursorLine: E,
1051
+ canvasWidth: we,
1052
+ canvasHeight: Me,
1053
+ lineHeight: u,
1054
+ itemHeightRatio: p,
1055
+ onTimeChange: He,
1056
+ onZoom: bt,
1057
+ onItemHover: Te,
1000
1058
  onItemClick: q,
1001
1059
  onItemDoubleClick: J,
1002
- onItemContextMenu: te,
1060
+ onItemContextMenu: oe,
1003
1061
  onItemMove: ue,
1004
- onItemResize: be,
1005
- onCanvasDoubleClick: Pe,
1006
- onCanvasContextMenu: xe,
1007
- canMove: g,
1062
+ onItemResize: ye,
1063
+ onCanvasDoubleClick: Xe,
1064
+ onCanvasContextMenu: Ve,
1065
+ canMove: m,
1008
1066
  canResize: T,
1009
1067
  canChangeGroup: b,
1010
- dragSnap: C,
1011
- sidebarWidth: u,
1012
- moveResizeValidator: Re,
1013
- summaryRenderer: Ht,
1068
+ dragSnap: H,
1069
+ sidebarWidth: c,
1070
+ moveResizeValidator: Oe,
1071
+ summaryRenderer: Pt,
1014
1072
  hierarchyEngine: Ie
1015
1073
  });
1016
- _.current = {
1074
+ Y.current = {
1017
1075
  groups: n,
1018
- items: s,
1019
- intervalTree: nt,
1020
- layoutEngine: rt,
1021
- itemRenderer: A,
1022
- groupRenderer: Z,
1023
- theme: Te,
1024
- selected: et,
1025
- dependencies: P,
1026
- highlights: L,
1027
- dayStyle: S,
1028
- rowStyle: F,
1029
- showCursorLine: B,
1030
- canvasWidth: Me,
1031
- canvasHeight: ke,
1032
- lineHeight: c,
1033
- itemHeightRatio: v,
1034
- onTimeChange: Ce,
1035
- onZoom: gt,
1036
- onItemHover: ye,
1076
+ items: o,
1077
+ intervalTree: ot,
1078
+ layoutEngine: Le,
1079
+ itemRenderer: R,
1080
+ groupRenderer: z,
1081
+ theme: Se,
1082
+ selected: rt,
1083
+ dependencies: _,
1084
+ highlights: G,
1085
+ dayStyle: w,
1086
+ rowStyle: X,
1087
+ showCursorLine: E,
1088
+ canvasWidth: we,
1089
+ canvasHeight: Me,
1090
+ lineHeight: u,
1091
+ itemHeightRatio: p,
1092
+ onTimeChange: He,
1093
+ onZoom: bt,
1094
+ onItemHover: Te,
1037
1095
  onItemClick: q,
1038
1096
  onItemDoubleClick: J,
1039
- onItemContextMenu: te,
1097
+ onItemContextMenu: oe,
1040
1098
  onItemMove: ue,
1041
- onItemResize: be,
1042
- onCanvasDoubleClick: Pe,
1043
- onCanvasContextMenu: xe,
1044
- canMove: g,
1099
+ onItemResize: ye,
1100
+ onCanvasDoubleClick: Xe,
1101
+ onCanvasContextMenu: Ve,
1102
+ canMove: m,
1045
1103
  canResize: T,
1046
1104
  canChangeGroup: b,
1047
- dragSnap: C,
1048
- sidebarWidth: u,
1049
- moveResizeValidator: Re,
1050
- summaryRenderer: Ht,
1105
+ dragSnap: H,
1106
+ sidebarWidth: c,
1107
+ moveResizeValidator: Oe,
1108
+ summaryRenderer: Pt,
1051
1109
  hierarchyEngine: Ie
1052
1110
  };
1053
- const ti = ie(() => {
1054
- const r = yt.current;
1111
+ const ri = ne(() => {
1112
+ const r = kt.current;
1055
1113
  if (!r)
1056
1114
  return;
1057
- const o = _.current, h = ht(r, o.canvasWidth, o.canvasHeight);
1058
- ft(h, r), Xe.draw(h, D.current, o.groups, o.theme, o.dayStyle, o.rowStyle, o.highlights);
1059
- }, [Xe]), ii = ie(() => {
1060
- const r = Tt.current;
1115
+ const s = Y.current, h = gt(r, s.canvasWidth, s.canvasHeight);
1116
+ pt(h, r), Fe.draw(h, F.current, s.groups, s.theme, s.dayStyle, s.rowStyle, s.highlights);
1117
+ }, [Fe]), oi = ne(() => {
1118
+ const r = wt.current;
1061
1119
  if (!r)
1062
1120
  return;
1063
- const o = _.current, h = ht(r, o.canvasWidth, o.canvasHeight);
1064
- ft(h, r), _e.draw(h, D.current, o.groups, o.items, o.intervalTree, o.layoutEngine, o.itemRenderer, o.groupRenderer, o.theme, o.selected, We.current, o.dependencies, o.summaryRenderer, o.hierarchyEngine);
1065
- }, [_e]), It = ie((r, o, h) => {
1066
- const f = D.current, l = _.current, m = l.canvasWidth / (f.visibleTimeEnd - f.visibleTimeStart), y = o / m, M = [];
1067
- h === "move" ? (M.push(f.timeToX(r.start_time + y)), M.push(f.timeToX(r.end_time + y))) : h === "resize-left" ? M.push(f.timeToX(r.start_time + y)) : M.push(f.timeToX(r.end_time + y));
1068
- const I = (f.visibleTimeEnd - f.visibleTimeStart) * 0.1, X = l.intervalTree.query(f.visibleTimeStart - I, f.visibleTimeEnd + I), z = mt(X, r.id, (re) => f.timeToX(re));
1069
- for (const re of M) {
1070
- const V = Je(re, z, 8, m, l.dragSnap);
1071
- if (V !== null)
1072
- return V;
1121
+ const s = Y.current, h = gt(r, s.canvasWidth, s.canvasHeight);
1122
+ pt(h, r), We.draw(h, F.current, s.groups, s.items, s.intervalTree, s.layoutEngine, s.itemRenderer, s.groupRenderer, s.theme, s.selected, Ae.current, s.dependencies, s.summaryRenderer, s.hierarchyEngine);
1123
+ }, [We]), Dt = ne((r, s, h) => {
1124
+ const f = F.current, a = Y.current, g = a.canvasWidth / (f.visibleTimeEnd - f.visibleTimeStart), y = s / g, k = [];
1125
+ h === "move" ? (k.push(f.timeToX(r.start_time + y)), k.push(f.timeToX(r.end_time + y))) : h === "resize-left" ? k.push(f.timeToX(r.start_time + y)) : k.push(f.timeToX(r.end_time + y));
1126
+ const I = (f.visibleTimeEnd - f.visibleTimeStart) * 0.1, P = a.intervalTree.query(f.visibleTimeStart - I, f.visibleTimeEnd + I), N = vt(P, r.id, (U) => f.timeToX(U));
1127
+ for (const U of k) {
1128
+ const Z = it(U, N, 8, g, a.dragSnap);
1129
+ if (Z !== null)
1130
+ return Z;
1073
1131
  }
1074
- const G = h === "resize-right" ? r.end_time + y : r.start_time + y, H = Math.round(G / l.dragSnap) * l.dragSnap;
1075
- return f.timeToX(H);
1076
- }, []), ni = ie(() => {
1077
- const r = St.current;
1132
+ const te = h === "resize-right" ? r.end_time + y : r.start_time + y, W = Math.round(te / a.dragSnap) * a.dragSnap;
1133
+ return f.timeToX(W);
1134
+ }, []), si = ne(() => {
1135
+ const r = Mt.current;
1078
1136
  if (!r)
1079
1137
  return;
1080
- const o = _.current, h = ht(r, o.canvasWidth, o.canvasHeight);
1081
- ft(h, r);
1082
- const f = D.current, l = Q.getState();
1083
- let m = null;
1084
- if (l) {
1085
- const y = f.timeToX(l.item.start_time), M = f.timeToX(l.item.end_time) - y;
1086
- let I, X;
1087
- l.mode === "resize-left" ? (I = y + l.deltaX, X = M - l.deltaX) : l.mode === "resize-right" ? (I = y, X = M + l.deltaX) : (I = y + l.deltaX, X = M);
1088
- const z = bt(l.currentGroup, o.groups), G = f.groupIndexToY(z), H = l.currentGroup !== l.originalGroup;
1089
- m = {
1090
- item: l.item,
1091
- mode: l.mode,
1092
- bounds: { x: I, y: G + (o.lineHeight - o.lineHeight * o.itemHeightRatio) / 2, width: X, height: o.lineHeight * o.itemHeightRatio },
1093
- renderer: o.itemRenderer,
1094
- targetGroupY: G,
1095
- groupChanged: H
1138
+ const s = Y.current, h = gt(r, s.canvasWidth, s.canvasHeight);
1139
+ pt(h, r);
1140
+ const f = F.current, a = ee.getState();
1141
+ let g = null;
1142
+ if (a) {
1143
+ const y = f.timeToX(a.item.start_time), k = f.timeToX(a.item.end_time) - y;
1144
+ let I, P;
1145
+ a.mode === "resize-left" ? (I = y + a.deltaX, P = k - a.deltaX) : a.mode === "resize-right" ? (I = y, P = k + a.deltaX) : (I = y + a.deltaX, P = k);
1146
+ const N = St(a.currentGroup, s.groups), te = f.groupIndexToY(N), W = a.currentGroup !== a.originalGroup;
1147
+ g = {
1148
+ item: a.item,
1149
+ mode: a.mode,
1150
+ bounds: { x: I, y: te + (s.lineHeight - s.lineHeight * s.itemHeightRatio) / 2, width: P, height: s.lineHeight * s.itemHeightRatio },
1151
+ renderer: s.itemRenderer,
1152
+ targetGroupY: te,
1153
+ groupChanged: W
1096
1154
  };
1097
1155
  }
1098
- Fe.draw(h, f, o.theme, {
1099
- cursorX: o.showCursorLine ? tt.current : null,
1100
- snapX: l ? It(l.item, l.deltaX, l.mode) : null,
1101
- markers: Le.current,
1102
- interaction: m
1156
+ Be.draw(h, f, s.theme, {
1157
+ cursorX: s.showCursorLine ? st.current : null,
1158
+ snapX: a ? Dt(a.item, a.deltaX, a.mode) : null,
1159
+ markers: Ge.current,
1160
+ interaction: g
1103
1161
  });
1104
- }, [Fe, Q, It, bt]), st = x(null);
1105
- st.current || (st.current = new Ti((r) => {
1106
- r.grid && ti(), r.items && ii(), r.overlay && ni();
1162
+ }, [Be, ee, Dt, St]), ut = x(null);
1163
+ ut.current || (ut.current = new wi((r) => {
1164
+ r.grid && ri(), r.items && oi(), r.overlay && si();
1107
1165
  }));
1108
- const E = st.current;
1109
- he(() => () => E.dispose(), [E]), he(() => {
1110
- if (!ot)
1166
+ const C = ut.current;
1167
+ he(() => () => C.dispose(), [C]), he(() => {
1168
+ if (!at)
1111
1169
  return;
1112
1170
  const r = setInterval(() => {
1113
- const o = [];
1114
- ge.Children.forEach(Se, (h) => {
1115
- var l;
1116
- if (!ge.isValidElement(h))
1171
+ const s = [];
1172
+ me.Children.forEach(ke, (h) => {
1173
+ var a;
1174
+ if (!me.isValidElement(h))
1117
1175
  return;
1118
- const f = (l = h.type) == null ? void 0 : l.displayName;
1119
- f === "TodayMarker" ? o.push(Yt(h.props)) : f === "CustomMarker" && o.push(At(h.props));
1120
- }), Le.current = o, E.markDirty("overlay");
1121
- }, ot);
1176
+ const f = (a = h.type) == null ? void 0 : a.displayName;
1177
+ f === "TodayMarker" ? s.push(Gt(h.props)) : f === "CustomMarker" && s.push(Nt(h.props));
1178
+ }), Ge.current = s, C.markDirty("overlay");
1179
+ }, at);
1122
1180
  return () => clearInterval(r);
1123
- }, [ot, Se, E]), he(() => {
1124
- D.current.update({ canvasWidth: Me, canvasHeight: ke, sidebarWidth: u, lineHeight: c, groupCount: n.length }), E.markAllDirty();
1125
- }, [Me, ke, u, c, n.length, E]), he(() => {
1126
- E.markDirty("grid"), E.markDirty("items");
1127
- }, [s, n, et, Te, S, F, nt, rt, E]);
1128
- const Ze = oe(() => {
1181
+ }, [at, ke, C]), he(() => {
1182
+ F.current.update({
1183
+ canvasWidth: we,
1184
+ canvasHeight: Me,
1185
+ sidebarWidth: c,
1186
+ lineHeight: u,
1187
+ groupCount: n.length,
1188
+ groupHeights: Re
1189
+ }), C.markAllDirty();
1190
+ }, [we, Me, c, u, n.length, Re, C]), he(() => {
1191
+ C.markDirty("grid"), C.markDirty("items");
1192
+ }, [o, n, rt, Se, w, X, ot, Le, C]);
1193
+ const Je = Q(() => {
1129
1194
  var r;
1130
- return ((r = e.highlights) == null ? void 0 : r.map((o) => `${o.start}|${o.end}|${o.color}|${o.label ?? ""}|${o.opacity ?? ""}`).join(";")) ?? "";
1131
- }, [e.highlights]), Rt = x(Ze);
1195
+ return ((r = e.highlights) == null ? void 0 : r.map((s) => `${s.start}|${s.end}|${s.color}|${s.label ?? ""}|${s.opacity ?? ""}`).join(";")) ?? "";
1196
+ }, [e.highlights]), Ot = x(Je);
1132
1197
  he(() => {
1133
- Ze !== Rt.current && (Rt.current = Ze, E.markDirty("grid"));
1134
- }, [Ze, E]);
1135
- const Pt = x(Ve);
1198
+ Je !== Ot.current && (Ot.current = Je, C.markDirty("grid"));
1199
+ }, [Je, C]);
1200
+ const Xt = x(Ke);
1136
1201
  he(() => {
1137
- Ve !== Pt.current && (Pt.current = Ve, E.markDirty("overlay"));
1138
- }, [Ve, E]);
1139
- const Dt = x(e.visibleTimeStart), Xt = x(e.visibleTimeEnd);
1140
- e.visibleTimeStart !== void 0 && e.visibleTimeStart !== Dt.current && (Dt.current = e.visibleTimeStart, D.current.update({ visibleTimeStart: e.visibleTimeStart }), E.markAllDirty()), e.visibleTimeEnd !== void 0 && e.visibleTimeEnd !== Xt.current && (Xt.current = e.visibleTimeEnd, D.current.update({ visibleTimeEnd: e.visibleTimeEnd }), E.markAllDirty());
1141
- const Ye = x(null), lt = ie((r) => {
1142
- Ye.current === null && (Ye.current = setTimeout(() => {
1143
- var f, l;
1144
- Ye.current = null;
1145
- const o = D.current, h = _.current;
1146
- r === "zoom" ? (f = h.onZoom) == null || f.call(h, o.visibleTimeStart, o.visibleTimeEnd) : (l = h.onTimeChange) == null || l.call(h, o.visibleTimeStart, o.visibleTimeEnd);
1147
- }, jt));
1202
+ Ke !== Xt.current && (Xt.current = Ke, C.markDirty("overlay"));
1203
+ }, [Ke, C]);
1204
+ const _t = x(e.visibleTimeStart), Ft = x(e.visibleTimeEnd);
1205
+ e.visibleTimeStart !== void 0 && e.visibleTimeStart !== _t.current && (_t.current = e.visibleTimeStart, F.current.update({ visibleTimeStart: e.visibleTimeStart }), C.markAllDirty()), e.visibleTimeEnd !== void 0 && e.visibleTimeEnd !== Ft.current && (Ft.current = e.visibleTimeEnd, F.current.update({ visibleTimeEnd: e.visibleTimeEnd }), C.markAllDirty());
1206
+ const Ne = x(null), ct = ne((r) => {
1207
+ Ne.current === null && (Ne.current = setTimeout(() => {
1208
+ var f, a;
1209
+ Ne.current = null;
1210
+ const s = F.current, h = Y.current;
1211
+ r === "zoom" ? (f = h.onZoom) == null || f.call(h, s.visibleTimeStart, s.visibleTimeEnd) : (a = h.onTimeChange) == null || a.call(h, s.visibleTimeStart, s.visibleTimeEnd);
1212
+ }, zt));
1148
1213
  }, []);
1149
1214
  he(() => () => {
1150
- Ye.current !== null && clearTimeout(Ye.current);
1215
+ Ne.current !== null && clearTimeout(Ne.current);
1151
1216
  }, []);
1152
- const qe = x(null), at = oe(() => new Ei((r, o) => {
1217
+ const Qe = x(null), dt = Q(() => new Ii((r, s) => {
1153
1218
  var h;
1154
- D.current.update({ visibleTimeStart: r, visibleTimeEnd: o }), (h = qe.current) == null || h.updateBounds(r, o), E.markAllDirty(), it(), lt("zoom");
1155
- }, d, a, R, O), []);
1156
- qe.current = at;
1157
- const Ue = ie((r) => {
1158
- const o = D.current, h = o.groupCount * o.lineHeight, f = Math.max(0, h - o.canvasHeight), l = Math.max(0, Math.min(f, o.scrollTop + r));
1159
- l !== o.scrollTop && (o.update({ scrollTop: l }), E.markDirty("grid"), E.markDirty("items"), E.markDirty("overlay"), $e(l));
1160
- }, [E]), Ae = ie((r) => {
1161
- var y, M, I;
1162
- const o = D.current, h = o.canvasWidth / (o.visibleTimeEnd - o.visibleTimeStart), f = r / h, l = o.visibleTimeStart + f, m = o.visibleTimeEnd + f;
1163
- o.update({ visibleTimeStart: l, visibleTimeEnd: m }), (y = qe.current) == null || y.updateBounds(l, m), E.markAllDirty(), gi(() => De()), (I = (M = _.current).onTimeChange) == null || I.call(M, l, m);
1164
- }, [E, De]);
1219
+ F.current.update({ visibleTimeStart: r, visibleTimeEnd: s }), (h = Qe.current) == null || h.updateBounds(r, s), C.markAllDirty(), lt(), ct("zoom");
1220
+ }, d, l, O, j), []);
1221
+ Qe.current = dt;
1222
+ const et = ne((r) => {
1223
+ const s = F.current, h = s.getTotalHeight(), f = Math.max(0, h - s.canvasHeight), a = Math.max(0, Math.min(f, s.scrollTop + r));
1224
+ a !== s.scrollTop && (s.update({ scrollTop: a }), C.markDirty("grid"), C.markDirty("items"), C.markDirty("overlay"), qe(a));
1225
+ }, [C]), ze = ne((r) => {
1226
+ var y, k, I;
1227
+ const s = F.current, h = s.canvasWidth / (s.visibleTimeEnd - s.visibleTimeStart), f = r / h, a = s.visibleTimeStart + f, g = s.visibleTimeEnd + f;
1228
+ s.update({ visibleTimeStart: a, visibleTimeEnd: g }), (y = Qe.current) == null || y.updateBounds(a, g), C.markAllDirty(), bi(() => _e()), (I = (k = Y.current).onTimeChange) == null || I.call(k, a, g);
1229
+ }, [C, _e]);
1165
1230
  he(() => {
1166
- const r = Oe.current;
1231
+ const r = Ye.current;
1167
1232
  if (!r)
1168
1233
  return;
1169
- const o = (h) => {
1234
+ const s = (h) => {
1170
1235
  if (h.ctrlKey || h.metaKey || h.altKey) {
1171
1236
  h.preventDefault();
1172
- const f = r.getBoundingClientRect(), l = (h.clientX - f.left) / f.width;
1173
- at.handleWheelZoom(h, l);
1237
+ const f = r.getBoundingClientRect(), a = (h.clientX - f.left) / f.width;
1238
+ dt.handleWheelZoom(h, a);
1174
1239
  } else if (h.shiftKey)
1175
- h.preventDefault(), Ae(h.deltaY);
1240
+ h.preventDefault(), ze(h.deltaY || h.deltaX);
1176
1241
  else {
1177
1242
  const f = h.deltaX;
1178
- f !== 0 && Math.abs(f) > Math.abs(h.deltaY) ? (h.preventDefault(), Ae(f)) : h.deltaY !== 0 && Ue(h.deltaY);
1243
+ f !== 0 && Math.abs(f) > Math.abs(h.deltaY) ? (h.preventDefault(), ze(f)) : h.deltaY !== 0 && et(h.deltaY);
1179
1244
  }
1180
1245
  };
1181
- return r.addEventListener("wheel", o, { passive: !1 }), () => r.removeEventListener("wheel", o);
1182
- }, [at, Ue, Ae]);
1183
- const we = x({ lastDistance: null, lastCenter: null });
1246
+ return r.addEventListener("wheel", s, { passive: !1 }), () => r.removeEventListener("wheel", s);
1247
+ }, [dt, et, ze]);
1248
+ const Ee = x({ lastDistance: null, lastCenter: null });
1184
1249
  he(() => {
1185
- const r = Oe.current;
1250
+ const r = Ye.current;
1186
1251
  if (!r)
1187
1252
  return;
1188
- const o = (y, M) => Math.abs(y.clientX - M.clientX), h = (y, M, I) => (y.clientX + M.clientX) / 2 - I.left, f = (y) => {
1189
- y.touches.length === 2 && (y.preventDefault(), we.current.lastDistance = o(y.touches[0], y.touches[1]), we.current.lastCenter = null);
1190
- }, l = (y) => {
1191
- var M;
1192
- if (y.touches.length === 2 && we.current.lastDistance !== null) {
1253
+ const s = (y, k) => Math.abs(y.clientX - k.clientX), h = (y, k, I) => (y.clientX + k.clientX) / 2 - I.left, f = (y) => {
1254
+ y.touches.length === 2 && (y.preventDefault(), Ee.current.lastDistance = s(y.touches[0], y.touches[1]), Ee.current.lastCenter = null);
1255
+ }, a = (y) => {
1256
+ var k;
1257
+ if (y.touches.length === 2 && Ee.current.lastDistance !== null) {
1193
1258
  y.preventDefault();
1194
- const I = o(y.touches[0], y.touches[1]), X = r.getBoundingClientRect(), G = h(y.touches[0], y.touches[1], X) / X.width;
1195
- if (I !== 0 && we.current.lastDistance !== 0) {
1196
- const H = we.current.lastDistance / I, re = D.current, V = re.visibleTimeEnd - re.visibleTimeStart;
1197
- let w = V * H;
1198
- w = Math.max(R, Math.min(O, w));
1199
- const p = re.visibleTimeStart + V * G, j = p - w * G, Y = p + w * (1 - G);
1200
- re.update({ visibleTimeStart: j, visibleTimeEnd: Y }), (M = qe.current) == null || M.updateBounds(j, Y), E.markAllDirty(), it(), lt("zoom");
1259
+ const I = s(y.touches[0], y.touches[1]), P = r.getBoundingClientRect(), te = h(y.touches[0], y.touches[1], P) / P.width;
1260
+ if (I !== 0 && Ee.current.lastDistance !== 0) {
1261
+ const W = Ee.current.lastDistance / I, U = F.current, Z = U.visibleTimeEnd - U.visibleTimeStart;
1262
+ let ce = Z * W;
1263
+ ce = Math.max(O, Math.min(j, ce));
1264
+ const $ = U.visibleTimeStart + Z * te, S = $ - ce * te, v = $ + ce * (1 - te);
1265
+ U.update({ visibleTimeStart: S, visibleTimeEnd: v }), (k = Qe.current) == null || k.updateBounds(S, v), C.markAllDirty(), lt(), ct("zoom");
1201
1266
  }
1202
- we.current.lastDistance = I;
1267
+ Ee.current.lastDistance = I;
1203
1268
  }
1204
- }, m = () => {
1205
- we.current.lastDistance = null, we.current.lastCenter = null;
1269
+ }, g = () => {
1270
+ Ee.current.lastDistance = null, Ee.current.lastCenter = null;
1206
1271
  };
1207
- return r.addEventListener("touchstart", f, { passive: !1 }), r.addEventListener("touchmove", l, { passive: !1 }), r.addEventListener("touchend", m), () => {
1208
- r.removeEventListener("touchstart", f), r.removeEventListener("touchmove", l), r.removeEventListener("touchend", m);
1272
+ return r.addEventListener("touchstart", f, { passive: !1 }), r.addEventListener("touchmove", a, { passive: !1 }), r.addEventListener("touchend", g), () => {
1273
+ r.removeEventListener("touchstart", f), r.removeEventListener("touchmove", a), r.removeEventListener("touchend", g);
1209
1274
  };
1210
- }, [E, it, lt]);
1211
- const ri = ie((r) => {
1275
+ }, [C, lt, ct]);
1276
+ const li = ne((r) => {
1212
1277
  var I;
1213
- const o = r.currentTarget, h = o.getBoundingClientRect(), f = r.clientX - h.left, l = r.clientY - h.top;
1214
- if (tt.current = f, ve.current) {
1215
- const X = r.clientX - ve.current.startX, z = r.clientY - ve.current.startY;
1216
- if (!He.current && (Math.abs(X) >= kt || Math.abs(z) >= kt) && (He.current = !0, o.style.cursor = "grabbing", o.setPointerCapture(r.pointerId)), He.current) {
1217
- const G = r.clientX - ve.current.lastX, H = r.clientY - ve.current.lastY;
1218
- ve.current.lastX = r.clientX, ve.current.lastY = r.clientY, Math.abs(G) > 0 && Ae(-G), Math.abs(H) > 0 && Ue(-H);
1278
+ const s = r.currentTarget, h = s.getBoundingClientRect(), f = r.clientX - h.left, a = r.clientY - h.top;
1279
+ if (st.current = f, be.current) {
1280
+ const P = r.clientX - be.current.startX, N = r.clientY - be.current.startY;
1281
+ if (!Pe.current && (Math.abs(P) >= Ct || Math.abs(N) >= Ct) && (Pe.current = !0, s.style.cursor = "grabbing", s.setPointerCapture(r.pointerId)), Pe.current) {
1282
+ const te = r.clientX - be.current.lastX, W = r.clientY - be.current.lastY;
1283
+ be.current.lastX = r.clientX, be.current.lastY = r.clientY, Math.abs(te) > 0 && ze(-te), Math.abs(W) > 0 && et(-W);
1219
1284
  }
1220
1285
  return;
1221
1286
  }
1222
- if (Q.isPending()) {
1223
- if (Q.update(f, l), Q.isActive()) {
1224
- const X = Q.getState();
1225
- if (X && X.mode === "move" && _.current.canChangeGroup) {
1226
- const z = dt(l, D.current, _.current.groups);
1227
- z && Q.setCurrentGroup(z.id);
1287
+ if (ee.isPending()) {
1288
+ if (ee.update(f, a), ee.isActive()) {
1289
+ const P = ee.getState();
1290
+ if (P && P.mode === "move" && Y.current.canChangeGroup) {
1291
+ const N = mt(a, F.current, Y.current.groups);
1292
+ N && ee.setCurrentGroup(N.id);
1228
1293
  }
1229
- E.markDirty("overlay");
1294
+ C.markDirty("overlay");
1230
1295
  }
1231
1296
  return;
1232
1297
  }
1233
- _.current.showCursorLine && E.markDirty("overlay");
1234
- const m = _.current, y = je(f, l, D.current, m.intervalTree, m.layoutEngine, m.groups), M = y == null ? void 0 : y.id;
1235
- if (M !== We.current && (We.current = M, E.markDirty("items"), (I = m.onItemHover) == null || I.call(m, M ?? null, r.nativeEvent)), y) {
1236
- const X = Ft(f, y, D.current), z = m.canResize;
1237
- X === "left" && (z === "left" || z === "both") || X === "right" && (z === "right" || z === "both") ? o.style.cursor = "col-resize" : m.canMove ? o.style.cursor = "grab" : o.style.cursor = "default";
1298
+ Y.current.showCursorLine && C.markDirty("overlay");
1299
+ const g = Y.current, y = $e(f, a, F.current, g.intervalTree, g.layoutEngine, g.groups), k = y == null ? void 0 : y.id;
1300
+ if (k !== Ae.current && (Ae.current = k, C.markDirty("items"), (I = g.onItemHover) == null || I.call(g, k ?? null, r.nativeEvent)), y) {
1301
+ const P = Bt(f, y, F.current), N = g.canResize;
1302
+ P === "left" && (N === "left" || N === "both") || P === "right" && (N === "right" || N === "both") ? s.style.cursor = "col-resize" : g.canMove ? s.style.cursor = "grab" : s.style.cursor = "default";
1238
1303
  } else
1239
- o.style.cursor = "default";
1240
- }, [Q, E, Ae, Ue]), oi = ie((r) => {
1241
- const o = _.current, h = r.currentTarget.getBoundingClientRect(), f = r.clientX - h.left, l = r.clientY - h.top, m = je(f, l, D.current, o.intervalTree, o.layoutEngine, o.groups);
1242
- if (!m) {
1243
- ve.current = { startX: r.clientX, startY: r.clientY, lastX: r.clientX, lastY: r.clientY }, He.current = !1;
1304
+ s.style.cursor = "default";
1305
+ }, [ee, C, ze, et]), ai = ne((r) => {
1306
+ const s = Y.current, h = r.currentTarget.getBoundingClientRect(), f = r.clientX - h.left, a = r.clientY - h.top, g = $e(f, a, F.current, s.intervalTree, s.layoutEngine, s.groups);
1307
+ if (!g) {
1308
+ be.current = { startX: r.clientX, startY: r.clientY, lastX: r.clientX, lastY: r.clientY }, Pe.current = !1;
1244
1309
  return;
1245
1310
  }
1246
- const y = Ft(f, m, D.current), M = o.canResize;
1247
- y === "left" && (M === "left" || M === "both") ? Q.startInteraction(m, "resize-left", f, l) : y === "right" && (M === "right" || M === "both") ? Q.startInteraction(m, "resize-right", f, l) : o.canMove && Q.startInteraction(m, "move", f, l);
1248
- }, [Q]), si = ie((r) => {
1249
- var y, M, I, X, z, G;
1250
- const o = r.currentTarget;
1251
- if (ve.current) {
1252
- const H = He.current;
1253
- if (ve.current = null, He.current = !1, o.style.cursor = "default", H)
1311
+ const y = Bt(f, g, F.current), k = s.canResize;
1312
+ y === "left" && (k === "left" || k === "both") ? ee.startInteraction(g, "resize-left", f, a) : y === "right" && (k === "right" || k === "both") ? ee.startInteraction(g, "resize-right", f, a) : s.canMove && ee.startInteraction(g, "move", f, a);
1313
+ }, [ee]), ui = ne((r) => {
1314
+ var y, k, I, P, N, te;
1315
+ const s = r.currentTarget;
1316
+ if (be.current) {
1317
+ const W = Pe.current;
1318
+ if (be.current = null, Pe.current = !1, s.style.cursor = "default", W)
1254
1319
  return;
1255
1320
  }
1256
- if (Q.isActive()) {
1257
- const H = Q.getState(), re = D.current, V = re.canvasWidth / (re.visibleTimeEnd - re.visibleTimeStart);
1258
- if (H) {
1259
- const w = _.current.moveResizeValidator;
1260
- if (H.mode === "move") {
1261
- const p = Q.endMove(V);
1262
- if (p) {
1263
- const j = D.current, Y = _.current, ae = H.deltaX / V, fe = j.timeToX(H.item.start_time + ae), W = j.timeToX(H.item.end_time + ae), U = (j.visibleTimeEnd - j.visibleTimeStart) * 0.1, ee = Y.intervalTree.query(j.visibleTimeStart - U, j.visibleTimeEnd + U), N = mt(ee, H.item.id, (me) => j.timeToX(me));
1264
- let le = p.newStartTime;
1265
- const K = Je(fe, N, 8, V, Y.dragSnap);
1266
- if (K !== null)
1267
- le = j.xToTime(K);
1321
+ if (ee.isActive()) {
1322
+ const W = ee.getState(), U = F.current, Z = U.canvasWidth / (U.visibleTimeEnd - U.visibleTimeStart);
1323
+ if (W) {
1324
+ const ce = Y.current.moveResizeValidator;
1325
+ if (W.mode === "move") {
1326
+ const $ = ee.endMove(Z);
1327
+ if ($) {
1328
+ const S = F.current, v = Y.current, ge = W.deltaX / Z, L = S.timeToX(W.item.start_time + ge), fe = S.timeToX(W.item.end_time + ge), ae = (S.visibleTimeEnd - S.visibleTimeStart) * 0.1, D = v.intervalTree.query(S.visibleTimeStart - ae, S.visibleTimeEnd + ae), ie = vt(D, W.item.id, (de) => S.timeToX(de));
1329
+ let V = $.newStartTime;
1330
+ const A = it(L, ie, 8, Z, v.dragSnap);
1331
+ if (A !== null)
1332
+ V = S.xToTime(A);
1268
1333
  else {
1269
- const me = Je(W, N, 8, V, Y.dragSnap);
1270
- if (me !== null) {
1271
- const hi = H.item.end_time - H.item.start_time;
1272
- le = j.xToTime(me) - hi;
1334
+ const de = it(fe, ie, 8, Z, v.dragSnap);
1335
+ if (de !== null) {
1336
+ const pe = W.item.end_time - W.item.start_time;
1337
+ V = S.xToTime(de) - pe;
1273
1338
  }
1274
1339
  }
1275
- const ce = w ? w("move", H.item.id, le) : le, de = _.current.hierarchyEngine.getMoveDelta(H.item.id, ce);
1276
- (M = (y = _.current).onItemMove) == null || M.call(y, H.item.id, ce, p.newGroupId, de.length > 0 ? de : void 0);
1340
+ const K = ce ? ce("move", W.item.id, V) : V, le = Y.current.hierarchyEngine.getMoveDelta(W.item.id, K);
1341
+ (k = (y = Y.current).onItemMove) == null || k.call(y, W.item.id, K, $.newGroupId, le.length > 0 ? le : void 0);
1277
1342
  }
1278
1343
  } else {
1279
- const p = Q.endResize(V);
1280
- if (p) {
1281
- const j = D.current, Y = _.current, ae = H.deltaX / V, fe = p.edge === "left" ? H.item.start_time + ae : H.item.end_time + ae, W = j.timeToX(fe), U = (j.visibleTimeEnd - j.visibleTimeStart) * 0.1, ee = Y.intervalTree.query(j.visibleTimeStart - U, j.visibleTimeEnd + U), N = mt(ee, H.item.id, (me) => j.timeToX(me)), le = Je(W, N, 8, V, Y.dragSnap);
1282
- let K = le !== null ? j.xToTime(le) : p.newTime;
1283
- const ce = _.current.hierarchyEngine.getResizeConstraint(H.item.id, p.edge);
1284
- p.edge === "left" && K > ce.max ? K = ce.max : p.edge === "right" && K < ce.min && (K = ce.min);
1285
- const de = w ? w("resize", H.item.id, K, p.edge) : K;
1286
- (X = (I = _.current).onItemResize) == null || X.call(I, H.item.id, de, p.edge);
1344
+ const $ = ee.endResize(Z);
1345
+ if ($) {
1346
+ const S = F.current, v = Y.current, ge = W.deltaX / Z, L = $.edge === "left" ? W.item.start_time + ge : W.item.end_time + ge, fe = S.timeToX(L), ae = (S.visibleTimeEnd - S.visibleTimeStart) * 0.1, D = v.intervalTree.query(S.visibleTimeStart - ae, S.visibleTimeEnd + ae), ie = vt(D, W.item.id, (de) => S.timeToX(de)), V = it(fe, ie, 8, Z, v.dragSnap);
1347
+ let A = V !== null ? S.xToTime(V) : $.newTime;
1348
+ const K = Y.current.hierarchyEngine.getResizeConstraint(W.item.id, $.edge);
1349
+ $.edge === "left" && A > K.max ? A = K.max : $.edge === "right" && A < K.min && (A = K.min);
1350
+ const le = ce ? ce("resize", W.item.id, A, $.edge) : A;
1351
+ (P = (I = Y.current).onItemResize) == null || P.call(I, W.item.id, le, $.edge);
1287
1352
  }
1288
1353
  }
1289
1354
  }
1290
- o.style.cursor = "default", E.markDirty("overlay");
1355
+ s.style.cursor = "default", C.markDirty("overlay");
1291
1356
  return;
1292
1357
  }
1293
- Q.isPending() && Q.cancel();
1294
- const h = o.getBoundingClientRect(), f = r.clientX - h.left, l = r.clientY - h.top, m = je(f, l, D.current, _.current.intervalTree, _.current.layoutEngine, _.current.groups);
1295
- m && ((G = (z = _.current).onItemClick) == null || G.call(z, m.id, r.nativeEvent));
1296
- }, [Q, E]), li = ie((r) => {
1297
- var y, M;
1298
- const o = r.currentTarget.getBoundingClientRect(), h = r.clientX - o.left, f = r.clientY - o.top, l = _.current, m = je(h, f, D.current, l.intervalTree, l.layoutEngine, l.groups);
1299
- if (m)
1300
- (y = l.onItemDoubleClick) == null || y.call(l, m.id, r.nativeEvent);
1358
+ ee.isPending() && ee.cancel();
1359
+ const h = s.getBoundingClientRect(), f = r.clientX - h.left, a = r.clientY - h.top, g = $e(f, a, F.current, Y.current.intervalTree, Y.current.layoutEngine, Y.current.groups);
1360
+ g && ((te = (N = Y.current).onItemClick) == null || te.call(N, g.id, r.nativeEvent));
1361
+ }, [ee, C]), ci = ne((r) => {
1362
+ var y, k;
1363
+ const s = r.currentTarget.getBoundingClientRect(), h = r.clientX - s.left, f = r.clientY - s.top, a = Y.current, g = $e(h, f, F.current, a.intervalTree, a.layoutEngine, a.groups);
1364
+ if (g)
1365
+ (y = a.onItemDoubleClick) == null || y.call(a, g.id, r.nativeEvent);
1301
1366
  else {
1302
- const I = dt(f, D.current, l.groups), X = D.current.xToTime(h);
1303
- I && ((M = l.onCanvasDoubleClick) == null || M.call(l, I.id, X));
1367
+ const I = mt(f, F.current, a.groups), P = F.current.xToTime(h);
1368
+ I && ((k = a.onCanvasDoubleClick) == null || k.call(a, I.id, P));
1304
1369
  }
1305
- }, []), ai = ie((r) => {
1306
- var y, M;
1370
+ }, []), di = ne((r) => {
1371
+ var y, k;
1307
1372
  r.preventDefault();
1308
- const o = r.currentTarget.getBoundingClientRect(), h = r.clientX - o.left, f = r.clientY - o.top, l = _.current, m = je(h, f, D.current, l.intervalTree, l.layoutEngine, l.groups);
1309
- if (m)
1310
- (y = l.onItemContextMenu) == null || y.call(l, m.id, r.nativeEvent);
1373
+ const s = r.currentTarget.getBoundingClientRect(), h = r.clientX - s.left, f = r.clientY - s.top, a = Y.current, g = $e(h, f, F.current, a.intervalTree, a.layoutEngine, a.groups);
1374
+ if (g)
1375
+ (y = a.onItemContextMenu) == null || y.call(a, g.id, r.nativeEvent);
1311
1376
  else {
1312
- const I = dt(f, D.current, l.groups), X = D.current.xToTime(h);
1313
- I && ((M = l.onCanvasContextMenu) == null || M.call(l, I.id, X, r.nativeEvent));
1377
+ const I = mt(f, F.current, a.groups), P = F.current.xToTime(h);
1378
+ I && ((k = a.onCanvasContextMenu) == null || k.call(a, I.id, P, r.nativeEvent));
1314
1379
  }
1315
- }, []), ci = ie(() => {
1316
- var r, o;
1317
- ve.current = null, He.current = !1, tt.current = null, Oe.current && (Oe.current.style.cursor = "default"), We.current !== void 0 && (We.current = void 0, E.markDirty("items"), (o = (r = _.current).onItemHover) == null || o.call(r, null, new PointerEvent("pointerleave"))), _.current.showCursorLine && E.markDirty("overlay");
1318
- }, [E]), ui = oe(() => {
1380
+ }, []), hi = ne(() => {
1381
+ var r, s;
1382
+ be.current = null, Pe.current = !1, st.current = null, Ye.current && (Ye.current.style.cursor = "default"), Ae.current !== void 0 && (Ae.current = void 0, C.markDirty("items"), (s = (r = Y.current).onItemHover) == null || s.call(r, null, new PointerEvent("pointerleave"))), Y.current.showCursorLine && C.markDirty("overlay");
1383
+ }, [C]), fi = Q(() => {
1319
1384
  const r = [];
1320
- return ge.Children.forEach(Se, (o) => {
1385
+ return me.Children.forEach(ke, (s) => {
1321
1386
  var f;
1322
- if (!ge.isValidElement(o))
1387
+ if (!me.isValidElement(s))
1323
1388
  return;
1324
- if (((f = o.type) == null ? void 0 : f.displayName) === "TimelineHeaders") {
1325
- const l = o.props;
1326
- r.push(ge.cloneElement(o, {
1327
- visibleTimeStart: l.visibleTimeStart ?? wt,
1328
- visibleTimeEnd: l.visibleTimeEnd ?? Et,
1329
- canvasWidth: l.canvasWidth ?? Me,
1330
- sidebarWidth: l.sidebarWidth ?? u,
1331
- theme: l.theme ?? Te,
1332
- onZoomToInterval: l.onZoomToInterval ?? ((m, y) => {
1333
- var M, I, X, z;
1334
- D.current.update({ visibleTimeStart: m, visibleTimeEnd: y }), E.markAllDirty(), De(), (I = (M = _.current).onTimeChange) == null || I.call(M, m, y), (z = (X = _.current).onZoom) == null || z.call(X, m, y);
1389
+ if (((f = s.type) == null ? void 0 : f.displayName) === "TimelineHeaders") {
1390
+ const a = s.props;
1391
+ r.push(me.cloneElement(s, {
1392
+ visibleTimeStart: a.visibleTimeStart ?? Ht,
1393
+ visibleTimeEnd: a.visibleTimeEnd ?? It,
1394
+ canvasWidth: a.canvasWidth ?? we,
1395
+ sidebarWidth: a.sidebarWidth ?? c,
1396
+ theme: a.theme ?? Se,
1397
+ onZoomToInterval: a.onZoomToInterval ?? ((g, y) => {
1398
+ var k, I, P, N;
1399
+ F.current.update({ visibleTimeStart: g, visibleTimeEnd: y }), C.markAllDirty(), _e(), (I = (k = Y.current).onTimeChange) == null || I.call(k, g, y), (N = (P = Y.current).onZoom) == null || N.call(P, g, y);
1335
1400
  })
1336
1401
  }));
1337
1402
  }
1338
1403
  }), r;
1339
- }, [Se, wt, Et, Me, u, Te, E, De]), _t = x(!1);
1404
+ }, [ke, Ht, It, we, c, Se, C, _e]), Wt = x(!1);
1340
1405
  he(() => {
1341
- _t.current || (_t.current = !0, E.markAllDirty());
1342
- }, [E]), mi(t, () => ({
1343
- captureToCanvas({ timeStart: r, timeEnd: o, scale: h, sidebarWidth: f }) {
1344
- const l = _.current, m = 28, y = m * 3, M = l.groups.length * l.lineHeight, I = D.current, X = l.canvasWidth / (I.visibleTimeEnd - I.visibleTimeStart), z = o - r, G = Math.max(l.canvasWidth, Math.round(z * X)), H = (f + G) * h, re = (y + M) * h, V = document.createElement("canvas");
1345
- V.width = H, V.height = re;
1346
- const w = V.getContext("2d");
1347
- w.scale(h, h);
1348
- for (let Y = 0; Y < l.groups.length; Y++) {
1349
- const ae = l.groups[Y], fe = y + Y * l.lineHeight;
1350
- if (l.rowStyle) {
1351
- const N = l.rowStyle(ae);
1352
- N != null && N.backgroundColor && (w.fillStyle = N.backgroundColor, w.fillRect(0, fe, f, l.lineHeight));
1406
+ Wt.current || (Wt.current = !0, C.markAllDirty());
1407
+ }, [C]), vi(t, () => ({
1408
+ captureToCanvas({ timeStart: r, timeEnd: s, scale: h, sidebarWidth: f }) {
1409
+ const a = Y.current, g = 28, y = g * 3, k = a.groups.map((L) => a.layoutEngine.getGroupHeight(L.id)), I = [0];
1410
+ for (let L = 0; L < k.length; L++)
1411
+ I.push(I[L] + k[L]);
1412
+ const P = I[k.length], N = F.current, te = a.canvasWidth / (N.visibleTimeEnd - N.visibleTimeStart), W = s - r, U = Math.max(a.canvasWidth, Math.round(W * te)), Z = (f + U) * h, ce = (y + P) * h, $ = document.createElement("canvas");
1413
+ $.width = Z, $.height = ce;
1414
+ const S = $.getContext("2d");
1415
+ S.scale(h, h);
1416
+ for (let L = 0; L < a.groups.length; L++) {
1417
+ const fe = a.groups[L], ae = k[L], D = y + I[L];
1418
+ if (a.rowStyle) {
1419
+ const K = a.rowStyle(fe);
1420
+ K != null && K.backgroundColor && (S.fillStyle = K.backgroundColor, S.fillRect(0, D, f, ae));
1353
1421
  }
1354
- const W = ae.type;
1355
- let U = "400", ee = 8;
1356
- W === "project" ? U = "700" : W === "CAG" ? U = "600" : W === "CA" && (U = "400", ee = 24), w.fillStyle = "#111", w.font = `${U} 12px sans-serif`, w.textBaseline = "middle", w.fillText(ae.title, ee, fe + l.lineHeight / 2, f - ee - 4);
1422
+ const ie = fe.type;
1423
+ let V = "400", A = 8;
1424
+ ie === "project" ? V = "700" : ie === "CAG" ? V = "600" : ie === "CA" && (V = "400", A = 24), S.fillStyle = "#111", S.font = `${V} 12px sans-serif`, S.textBaseline = "middle", S.fillText(fe.title, A, D + ae / 2, f - A - 4);
1357
1425
  }
1358
- const p = (Y, ae, fe) => {
1359
- var ee, N;
1360
- w.fillStyle = ((ee = l.theme.header) == null ? void 0 : ee.bg) ?? "#f5f5f5", w.fillRect(f, Y, G, m), w.strokeStyle = ((N = l.theme.grid) == null ? void 0 : N.line) ?? "#e0e0e0", w.lineWidth = 1, w.strokeRect(f, Y, G, m);
1361
- let W = pe(r).startOf(fe);
1362
- W.valueOf() < r && (W = W.add(1, fe));
1363
- const U = G / (o - r);
1364
- for (; W.valueOf() < o; ) {
1365
- const le = W.add(1, fe), K = f + (W.valueOf() - r) * U, de = f + (Math.min(le.valueOf(), o) - r) * U - K;
1366
- w.beginPath(), w.moveTo(K, Y), w.lineTo(K, Y + m), w.stroke(), w.fillStyle = "#333", w.font = "600 11px sans-serif", w.textBaseline = "middle", w.textAlign = "center", w.fillText(ae(W), K + de / 2, Y + m / 2, de - 4), W = le;
1426
+ const v = (L, fe, ae) => {
1427
+ var V, A;
1428
+ S.fillStyle = ((V = a.theme.header) == null ? void 0 : V.bg) ?? "#f5f5f5", S.fillRect(f, L, U, g), S.strokeStyle = ((A = a.theme.grid) == null ? void 0 : A.line) ?? "#e0e0e0", S.lineWidth = 1, S.strokeRect(f, L, U, g);
1429
+ let D = ve(r).startOf(ae);
1430
+ D.valueOf() < r && (D = D.add(1, ae));
1431
+ const ie = U / (s - r);
1432
+ for (; D.valueOf() < s; ) {
1433
+ const K = D.add(1, ae), le = f + (D.valueOf() - r) * ie, pe = f + (Math.min(K.valueOf(), s) - r) * ie - le;
1434
+ S.beginPath(), S.moveTo(le, L), S.lineTo(le, L + g), S.stroke(), S.fillStyle = "#333", S.font = "600 11px sans-serif", S.textBaseline = "middle", S.textAlign = "center", S.fillText(fe(D), le + pe / 2, L + g / 2, pe - 4), D = K;
1367
1435
  }
1368
- w.textAlign = "start";
1436
+ S.textAlign = "start";
1369
1437
  };
1370
- p(0, (Y) => Y.format("YYYY"), "year"), p(m, (Y) => Y.format("MM"), "month"), p(m * 2, (Y) => String(Y.isoWeek()), "week");
1371
- const j = new ut({
1438
+ v(0, (L) => L.format("YYYY"), "year"), v(g, (L) => L.format("MM"), "month"), v(g * 2, (L) => String(L.isoWeek()), "week");
1439
+ const ge = new ft({
1372
1440
  visibleTimeStart: r,
1373
- visibleTimeEnd: o,
1374
- canvasWidth: G,
1375
- canvasHeight: M,
1441
+ visibleTimeEnd: s,
1442
+ canvasWidth: U,
1443
+ canvasHeight: P,
1376
1444
  sidebarWidth: 0,
1377
- lineHeight: l.lineHeight,
1378
- groupCount: l.groups.length,
1445
+ lineHeight: a.lineHeight,
1446
+ groupCount: a.groups.length,
1379
1447
  buffer: 1,
1380
- scrollTop: 0
1448
+ scrollTop: 0,
1449
+ groupHeights: k
1381
1450
  });
1382
- return w.save(), w.translate(f, y), w.beginPath(), w.rect(0, 0, G, M), w.clip(), Xe.draw(w, j, l.groups, l.theme, l.dayStyle, l.rowStyle, l.highlights), _e.draw(w, j, l.groups, l.items, l.intervalTree, l.layoutEngine, l.itemRenderer, l.groupRenderer, l.theme, l.selected, void 0, l.dependencies, l.summaryRenderer, l.hierarchyEngine), Fe.draw(w, j, l.theme, {
1451
+ return S.save(), S.translate(f, y), S.beginPath(), S.rect(0, 0, U, P), S.clip(), Fe.draw(S, ge, a.groups, a.theme, a.dayStyle, a.rowStyle, a.highlights), We.draw(S, ge, a.groups, a.items, a.intervalTree, a.layoutEngine, a.itemRenderer, a.groupRenderer, a.theme, a.selected, void 0, a.dependencies, a.summaryRenderer, a.hierarchyEngine), Be.draw(S, ge, a.theme, {
1383
1452
  cursorX: null,
1384
1453
  snapX: null,
1385
- markers: Le.current,
1454
+ markers: Ge.current,
1386
1455
  interaction: null
1387
- }), w.restore(), V;
1456
+ }), S.restore(), $;
1388
1457
  }
1389
- }), [Xe, _e, Fe]), he(() => {
1458
+ }), [Fe, We, Be]), he(() => {
1390
1459
  const r = {
1391
- captureToCanvas({ timeStart: o, timeEnd: h, scale: f, sidebarWidth: l }) {
1392
- var fe;
1393
- const m = _.current, y = 28, M = y * 3, I = m.groups.length * m.lineHeight, X = D.current, z = m.canvasWidth / (X.visibleTimeEnd - X.visibleTimeStart), G = h - o, H = Math.max(m.canvasWidth, Math.round(G * z)), re = l + H, V = M + I, w = document.createElement("canvas");
1394
- w.width = re * f, w.height = V * f;
1395
- const p = w.getContext("2d");
1396
- p.scale(f, f), p.fillStyle = "#FFFFFF", p.fillRect(0, 0, re, V), p.save(), p.beginPath(), p.rect(0, 0, l, V), p.clip(), p.fillStyle = "#F9FAFB", p.fillRect(0, 0, l, M), p.strokeStyle = "#E5E7EB", p.lineWidth = 1, p.strokeRect(0, 0, l, M);
1397
- for (let W = 0; W < m.groups.length; W++) {
1398
- const U = m.groups[W], ee = M + W * m.lineHeight, N = (fe = m.rowStyle) == null ? void 0 : fe.call(m, U);
1399
- p.fillStyle = (N == null ? void 0 : N.backgroundColor) ?? (W % 2 === 0 ? "#FFFFFF" : "#F7F7F7"), p.fillRect(0, ee, l, m.lineHeight), p.strokeStyle = "#E5E5E5", p.lineWidth = 0.5, p.beginPath(), p.moveTo(0, ee + m.lineHeight), p.lineTo(l, ee + m.lineHeight), p.stroke();
1400
- const le = U.type ?? "";
1401
- let K = 8, ce = "400", de = 11;
1402
- le === "project" ? (ce = "700", de = 12) : le === "control_area_group" ? ce = "600" : le === "control_area" && (K = 24), p.fillStyle = "#374151", p.font = `${ce} ${de}px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`, p.textBaseline = "middle";
1403
- const me = typeof U.title == "string" ? U.title : String(U.title);
1404
- p.fillText(me, K, ee + m.lineHeight / 2, l - K - 8);
1460
+ captureToCanvas({ timeStart: s, timeEnd: h, scale: f, sidebarWidth: a }) {
1461
+ var ae;
1462
+ const g = Y.current, y = 28, k = y * 3, I = g.groups.map((D) => g.layoutEngine.getGroupHeight(D.id)), P = [0];
1463
+ for (let D = 0; D < I.length; D++)
1464
+ P.push(P[D] + I[D]);
1465
+ const N = P[I.length], te = F.current, W = g.canvasWidth / (te.visibleTimeEnd - te.visibleTimeStart), U = h - s, Z = Math.max(g.canvasWidth, Math.round(U * W)), ce = a + Z, $ = k + N, S = document.createElement("canvas");
1466
+ S.width = ce * f, S.height = $ * f;
1467
+ const v = S.getContext("2d");
1468
+ v.scale(f, f), v.fillStyle = "#FFFFFF", v.fillRect(0, 0, ce, $), v.save(), v.beginPath(), v.rect(0, 0, a, $), v.clip(), v.fillStyle = "#F9FAFB", v.fillRect(0, 0, a, k), v.strokeStyle = "#E5E7EB", v.lineWidth = 1, v.strokeRect(0, 0, a, k);
1469
+ for (let D = 0; D < g.groups.length; D++) {
1470
+ const ie = g.groups[D], V = I[D], A = k + P[D], K = (ae = g.rowStyle) == null ? void 0 : ae.call(g, ie);
1471
+ v.fillStyle = (K == null ? void 0 : K.backgroundColor) ?? (D % 2 === 0 ? "#FFFFFF" : "#F7F7F7"), v.fillRect(0, A, a, V), v.strokeStyle = "#E5E5E5", v.lineWidth = 0.5, v.beginPath(), v.moveTo(0, A + V), v.lineTo(a, A + V), v.stroke();
1472
+ const le = ie.type ?? "";
1473
+ let de = 8, pe = "400", De = 11;
1474
+ le === "project" ? (pe = "700", De = 12) : le === "control_area_group" ? pe = "600" : le === "control_area" && (de = 24), v.fillStyle = "#374151", v.font = `${pe} ${De}px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`, v.textBaseline = "middle";
1475
+ const gi = typeof ie.title == "string" ? ie.title : String(ie.title);
1476
+ v.fillText(gi, de, A + V / 2, a - de - 8);
1405
1477
  }
1406
- p.strokeStyle = "#E5E7EB", p.lineWidth = 1, p.beginPath(), p.moveTo(l, 0), p.lineTo(l, V), p.stroke(), p.restore(), p.save(), p.beginPath(), p.rect(l, 0, H, M), p.clip();
1407
- const j = h - o, Y = [
1478
+ v.strokeStyle = "#E5E7EB", v.lineWidth = 1, v.beginPath(), v.moveTo(a, 0), v.lineTo(a, $), v.stroke(), v.restore(), v.save(), v.beginPath(), v.rect(a, 0, Z, k), v.clip();
1479
+ const ge = h - s, L = [
1408
1480
  { unit: "year", row: 0 },
1409
1481
  { unit: "month", row: 1 },
1410
1482
  { unit: "week", row: 2 }
1411
1483
  ];
1412
- for (const { unit: W, row: U } of Y) {
1413
- const ee = U * y;
1414
- p.fillStyle = "#F9FAFB", p.fillRect(l, ee, H, y);
1415
- let N = pe(o).startOf(W);
1416
- const le = pe(h).add(1, W);
1417
- for (; N.isBefore(le); ) {
1418
- const K = N.add(1, W), ce = l + (N.valueOf() - o) / j * H, de = (K.valueOf() - N.valueOf()) / j * H;
1419
- p.strokeStyle = "#E5E7EB", p.lineWidth = 0.5, p.strokeRect(ce, ee, de, y);
1420
- let me;
1421
- W === "year" ? me = N.format("YYYY") : W === "month" ? me = N.format("MM") : me = `${N.week()}`, p.fillStyle = "#6c737f", p.font = W === "year" ? '600 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif' : '400 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif', p.textBaseline = "middle", p.textAlign = "center", de > 20 && p.fillText(me, ce + de / 2, ee + y / 2), N = K;
1484
+ for (const { unit: D, row: ie } of L) {
1485
+ const V = ie * y;
1486
+ v.fillStyle = "#F9FAFB", v.fillRect(a, V, Z, y);
1487
+ let A = ve(s).startOf(D);
1488
+ const K = ve(h).add(1, D);
1489
+ for (; A.isBefore(K); ) {
1490
+ const le = A.add(1, D), de = a + (A.valueOf() - s) / ge * Z, pe = (le.valueOf() - A.valueOf()) / ge * Z;
1491
+ v.strokeStyle = "#E5E7EB", v.lineWidth = 0.5, v.strokeRect(de, V, pe, y);
1492
+ let De;
1493
+ D === "year" ? De = A.format("YYYY") : D === "month" ? De = A.format("MM") : De = `${A.week()}`, v.fillStyle = "#6c737f", v.font = D === "year" ? '600 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif' : '400 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif', v.textBaseline = "middle", v.textAlign = "center", pe > 20 && v.fillText(De, de + pe / 2, V + y / 2), A = le;
1422
1494
  }
1423
1495
  }
1424
- p.textAlign = "start", p.restore(), p.save(), p.beginPath(), p.rect(l, M, H, I), p.clip(), p.translate(l, M);
1425
- const ae = new ut({
1426
- visibleTimeStart: o,
1496
+ v.textAlign = "start", v.restore(), v.save(), v.beginPath(), v.rect(a, k, Z, N), v.clip(), v.translate(a, k);
1497
+ const fe = new ft({
1498
+ visibleTimeStart: s,
1427
1499
  visibleTimeEnd: h,
1428
- canvasWidth: H,
1429
- canvasHeight: I,
1500
+ canvasWidth: Z,
1501
+ canvasHeight: N,
1430
1502
  sidebarWidth: 0,
1431
- lineHeight: m.lineHeight,
1432
- groupCount: m.groups.length,
1503
+ lineHeight: g.lineHeight,
1504
+ groupCount: g.groups.length,
1433
1505
  buffer: 1,
1434
- scrollTop: 0
1506
+ scrollTop: 0,
1507
+ groupHeights: I
1435
1508
  });
1436
- return Xe.draw(p, ae, m.groups, m.theme, m.dayStyle, m.rowStyle, m.highlights), _e.draw(p, ae, m.groups, m.items, m.intervalTree, m.layoutEngine, m.itemRenderer, m.groupRenderer, m.theme, m.selected, void 0, m.dependencies, m.summaryRenderer, m.hierarchyEngine), Fe.draw(p, ae, m.theme, { cursorX: null, markers: Le.current }), p.restore(), w;
1509
+ return Fe.draw(v, fe, g.groups, g.theme, g.dayStyle, g.rowStyle, g.highlights), We.draw(v, fe, g.groups, g.items, g.intervalTree, g.layoutEngine, g.itemRenderer, g.groupRenderer, g.theme, g.selected, void 0, g.dependencies, g.summaryRenderer, g.hierarchyEngine), Be.draw(v, fe, g.theme, { cursorX: null, markers: Ge.current }), v.restore(), S;
1437
1510
  }
1438
1511
  };
1439
- ze == null || ze(r);
1440
- }, [ze, Xe, _e, Fe]);
1441
- const di = {
1512
+ Ze == null || Ze(r);
1513
+ }, [Ze, Fe, We, Be]);
1514
+ const mi = {
1442
1515
  position: "relative",
1443
- width: Me,
1444
- height: ke,
1516
+ width: we,
1517
+ height: Me,
1445
1518
  overflow: "hidden",
1446
1519
  cursor: "default"
1447
- }, ct = { position: "absolute", top: 0, left: 0 };
1448
- return Ne("div", { ref: Mt, style: { display: "flex", flexDirection: "column", width: "100%", position: "relative" }, children: [Zt ? Ne("div", { style: {
1520
+ }, ht = { position: "absolute", top: 0, left: 0 };
1521
+ return xe("div", { ref: Et, style: { display: "flex", flexDirection: "column", width: "100%", position: "relative" }, children: [Kt ? xe("div", { style: {
1449
1522
  position: "absolute",
1450
1523
  top: 0,
1451
1524
  left: 0,
@@ -1459,28 +1532,28 @@ const jt = 32, Vi = ge.memo(fi(function(e, t) {
1459
1532
  borderBottomRightRadius: 4,
1460
1533
  pointerEvents: "none",
1461
1534
  userSelect: "none"
1462
- }, children: ["v", "0.4.5", " · ", "09:22:40"] }) : null, ui, Ne("div", { ref: Ut, style: { display: "flex", overflow: "hidden" }, children: [se(Lt, { groups: n, width: u, lineHeight: c, scrollTop: Ct, canvasHeight: ke, theme: Te, groupRenderer: ne, onScroll: (r) => {
1463
- D.current.update({ scrollTop: r }), E.markDirty("grid"), E.markDirty("items"), E.markDirty("overlay"), $e(r);
1464
- } }), Ne("div", { ref: Oe, style: di, onPointerMove: ri, onPointerDown: oi, onPointerUp: si, onDoubleClick: li, onContextMenu: ai, onPointerLeave: ci, children: [se("canvas", { ref: yt, style: { ...ct, zIndex: 0 } }), se("canvas", { ref: Tt, style: { ...ct, zIndex: 1 } }), se("canvas", { ref: St, style: { ...ct, zIndex: 2 } })] }), Qe && vt ? se(Lt, { groups: n, width: Qe, lineHeight: c, scrollTop: Ct, canvasHeight: ke, theme: Te, groupRenderer: vt, onScroll: (r) => {
1465
- D.current.update({ scrollTop: r }), E.markDirty("grid"), E.markDirty("items"), E.markDirty("overlay"), $e(r);
1535
+ }, children: ["v", "0.5.0", " · ", "15:09:31"] }) : null, fi, xe("div", { ref: Qt, style: { display: "flex", overflow: "hidden" }, children: [se(jt, { groups: n, width: c, lineHeight: u, groupHeights: Re, scrollTop: Rt, canvasHeight: Me, theme: Se, groupRenderer: B, onScroll: (r) => {
1536
+ F.current.update({ scrollTop: r }), C.markDirty("grid"), C.markDirty("items"), C.markDirty("overlay"), qe(r);
1537
+ } }), xe("div", { ref: Ye, style: mi, onPointerMove: li, onPointerDown: ai, onPointerUp: ui, onDoubleClick: ci, onContextMenu: di, onPointerLeave: hi, children: [se("canvas", { ref: kt, style: { ...ht, zIndex: 0 } }), se("canvas", { ref: wt, style: { ...ht, zIndex: 1 } }), se("canvas", { ref: Mt, style: { ...ht, zIndex: 2 } })] }), nt && Tt ? se(jt, { groups: n, width: nt, lineHeight: u, groupHeights: Re, scrollTop: Rt, canvasHeight: Me, theme: Se, groupRenderer: Tt, onScroll: (r) => {
1538
+ F.current.update({ scrollTop: r }), C.markDirty("grid"), C.markDirty("items"), C.markDirty("overlay"), qe(r);
1466
1539
  } }) : null] })] });
1467
1540
  }));
1468
- function Fi({ children: i, theme: e, className: t, classNames: n, style: s, visibleTimeStart: d, visibleTimeEnd: a, canvasWidth: u, sidebarWidth: c = 0, onZoomToInterval: v }) {
1469
- const k = ge.Children.map(i, (g) => {
1541
+ function Bi({ children: i, theme: e, className: t, classNames: n, style: o, visibleTimeStart: d, visibleTimeEnd: l, canvasWidth: c, sidebarWidth: u = 0, onZoomToInterval: p }) {
1542
+ const M = me.Children.map(i, (m) => {
1470
1543
  var T;
1471
- if (!ge.isValidElement(g))
1472
- return g;
1473
- if (((T = g.type) == null ? void 0 : T.displayName) === "DateHeader") {
1474
- const C = g.props, R = ge.cloneElement(g, {
1475
- visibleTimeStart: C.visibleTimeStart ?? d,
1476
- visibleTimeEnd: C.visibleTimeEnd ?? a,
1477
- canvasWidth: C.canvasWidth ?? u,
1478
- theme: C.theme ?? e,
1479
- onZoomToInterval: C.onIntervalClick ?? C.onZoomToInterval ?? v
1544
+ if (!me.isValidElement(m))
1545
+ return m;
1546
+ if (((T = m.type) == null ? void 0 : T.displayName) === "DateHeader") {
1547
+ const H = m.props, O = me.cloneElement(m, {
1548
+ visibleTimeStart: H.visibleTimeStart ?? d,
1549
+ visibleTimeEnd: H.visibleTimeEnd ?? l,
1550
+ canvasWidth: H.canvasWidth ?? c,
1551
+ theme: H.theme ?? e,
1552
+ onZoomToInterval: H.onIntervalClick ?? H.onZoomToInterval ?? p
1480
1553
  });
1481
- return Ne("div", { style: { display: "flex" }, children: [se("div", { style: { width: c, flexShrink: 0 } }), se("div", { style: { flex: 1, overflow: "hidden" }, children: R })] });
1554
+ return xe("div", { style: { display: "flex" }, children: [se("div", { style: { width: u, flexShrink: 0 } }), se("div", { style: { flex: 1, overflow: "hidden" }, children: O })] });
1482
1555
  }
1483
- return g;
1556
+ return m;
1484
1557
  });
1485
1558
  return se("div", { className: t, style: {
1486
1559
  position: "sticky",
@@ -1491,65 +1564,65 @@ function Fi({ children: i, theme: e, className: t, classNames: n, style: s, visi
1491
1564
  backgroundColor: (e == null ? void 0 : e.header.bg) ?? "#F9FAFB",
1492
1565
  borderTop: `1px solid ${(e == null ? void 0 : e.header.border) ?? "#E5E7EB"}`,
1493
1566
  borderBottom: `1px solid ${(e == null ? void 0 : e.header.border) ?? "#E5E7EB"}`,
1494
- ...s
1495
- }, children: k });
1567
+ ...o
1568
+ }, children: M });
1496
1569
  }
1497
- Fi.displayName = "TimelineHeaders";
1498
- var Vt = { exports: {} };
1570
+ Bi.displayName = "TimelineHeaders";
1571
+ var Ut = { exports: {} };
1499
1572
  (function(i, e) {
1500
1573
  (function(t, n) {
1501
1574
  i.exports = n();
1502
- })(zt, function() {
1575
+ })(Vt, function() {
1503
1576
  var t = "week", n = "year";
1504
- return function(s, d, a) {
1505
- var u = d.prototype;
1506
- u.week = function(c) {
1507
- if (c === void 0 && (c = null), c !== null) return this.add(7 * (c - this.week()), "day");
1508
- var v = this.$locale().yearStart || 1;
1577
+ return function(o, d, l) {
1578
+ var c = d.prototype;
1579
+ c.week = function(u) {
1580
+ if (u === void 0 && (u = null), u !== null) return this.add(7 * (u - this.week()), "day");
1581
+ var p = this.$locale().yearStart || 1;
1509
1582
  if (this.month() === 11 && this.date() > 25) {
1510
- var k = a(this).startOf(n).add(1, n).date(v), g = a(this).endOf(t);
1511
- if (k.isBefore(g)) return 1;
1583
+ var M = l(this).startOf(n).add(1, n).date(p), m = l(this).endOf(t);
1584
+ if (M.isBefore(m)) return 1;
1512
1585
  }
1513
- var b = a(this).startOf(n).date(v).startOf(t).subtract(1, "millisecond"), T = this.diff(b, t, !0);
1514
- return T < 0 ? a(this).startOf("week").week() : Math.ceil(T);
1515
- }, u.weeks = function(c) {
1516
- return c === void 0 && (c = null), this.week(c);
1586
+ var b = l(this).startOf(n).date(p).startOf(t).subtract(1, "millisecond"), T = this.diff(b, t, !0);
1587
+ return T < 0 ? l(this).startOf("week").week() : Math.ceil(T);
1588
+ }, c.weeks = function(u) {
1589
+ return u === void 0 && (u = null), this.week(u);
1517
1590
  };
1518
1591
  };
1519
1592
  });
1520
- })(Vt);
1521
- var Oi = Vt.exports;
1522
- const Wi = /* @__PURE__ */ $t(Oi);
1523
- pe.extend(Wi);
1524
- const Bi = {
1593
+ })(Ut);
1594
+ var Yi = Ut.exports;
1595
+ const Li = /* @__PURE__ */ Zt(Yi);
1596
+ ve.extend(Li);
1597
+ const Ai = {
1525
1598
  year: 30,
1526
1599
  month: 30,
1527
1600
  week: 20,
1528
1601
  day: 15,
1529
1602
  hour: 30
1530
1603
  };
1531
- function Li({ unit: i, visibleTimeStart: e = 0, visibleTimeEnd: t = 0, canvasWidth: n = 0, theme: s, height: d = 28, className: a, labelFormat: u, onIntervalClick: c, minCellWidth: v, onZoomToInterval: k }) {
1532
- const g = oe(() => {
1604
+ function ji({ unit: i, visibleTimeStart: e = 0, visibleTimeEnd: t = 0, canvasWidth: n = 0, theme: o, height: d = 28, className: l, labelFormat: c, onIntervalClick: u, minCellWidth: p, onZoomToInterval: M }) {
1605
+ const m = Q(() => {
1533
1606
  if (!e || !t || !n)
1534
1607
  return [];
1535
- const T = t - e, C = v ?? Bi[i];
1536
- if (C > 0) {
1537
- const S = pe(e).startOf(i);
1538
- if ((S.add(1, i).valueOf() - S.valueOf()) / T * n < C)
1608
+ const T = t - e, H = p ?? Ai[i];
1609
+ if (H > 0) {
1610
+ const w = ve(e).startOf(i);
1611
+ if ((w.add(1, i).valueOf() - w.valueOf()) / T * n < H)
1539
1612
  return [];
1540
1613
  }
1541
- const R = [];
1542
- let O = pe(e).startOf(i).subtract(1, i);
1543
- const $ = pe(t).add(2, i).valueOf();
1544
- for (; O.valueOf() < $; ) {
1545
- const S = O.add(1, i), F = O.valueOf(), B = S.valueOf(), A = (F - e) / T * n, Z = (B - F) / T * n, ne = Yi(O, S, i, u);
1546
- R.push({ start: F, end: B, label: ne, left: A, width: Z }), O = S;
1614
+ const O = [];
1615
+ let j = ve(e).startOf(i).subtract(1, i);
1616
+ const re = ve(t).add(2, i).valueOf();
1617
+ for (; j.valueOf() < re; ) {
1618
+ const w = j.add(1, i), X = j.valueOf(), E = w.valueOf(), R = (X - e) / T * n, z = (E - X) / T * n, B = Gi(j, w, i, c);
1619
+ O.push({ start: X, end: E, label: B, left: R, width: z }), j = w;
1547
1620
  }
1548
- return R;
1549
- }, [e, t, n, i, u, v]), b = ie((T, C) => {
1550
- c ? c(T, C) : k && k(T, C);
1551
- }, [c, k]);
1552
- return g.length === 0 ? null : se("div", { style: { display: "flex", position: "relative", height: d, overflow: "hidden" }, children: g.map((T) => se("div", { className: a, onClick: () => b(T.start, T.end), style: {
1621
+ return O;
1622
+ }, [e, t, n, i, c, p]), b = ne((T, H) => {
1623
+ u ? u(T, H) : M && M(T, H);
1624
+ }, [u, M]);
1625
+ return m.length === 0 ? null : se("div", { style: { display: "flex", position: "relative", height: d, overflow: "hidden" }, children: m.map((T) => se("div", { className: l, onClick: () => b(T.start, T.end), style: {
1553
1626
  position: "absolute",
1554
1627
  left: T.left,
1555
1628
  width: T.width,
@@ -1557,11 +1630,11 @@ function Li({ unit: i, visibleTimeStart: e = 0, visibleTimeEnd: t = 0, canvasWid
1557
1630
  display: "flex",
1558
1631
  alignItems: "center",
1559
1632
  justifyContent: "center",
1560
- borderRight: `1px solid ${(s == null ? void 0 : s.header.border) ?? "#E5E7EB"}`,
1561
- borderBottom: `1px solid ${(s == null ? void 0 : s.header.border) ?? "#E5E7EB"}`,
1633
+ borderRight: `1px solid ${(o == null ? void 0 : o.header.border) ?? "#E5E7EB"}`,
1634
+ borderBottom: `1px solid ${(o == null ? void 0 : o.header.border) ?? "#E5E7EB"}`,
1562
1635
  fontSize: 12,
1563
- color: (s == null ? void 0 : s.header.text) ?? "#6c737f",
1564
- backgroundColor: (s == null ? void 0 : s.header.bg) ?? "#F9FAFB",
1636
+ color: (o == null ? void 0 : o.header.text) ?? "#6c737f",
1637
+ backgroundColor: (o == null ? void 0 : o.header.bg) ?? "#F9FAFB",
1565
1638
  overflow: "hidden",
1566
1639
  whiteSpace: "nowrap",
1567
1640
  cursor: "pointer",
@@ -1570,11 +1643,11 @@ function Li({ unit: i, visibleTimeStart: e = 0, visibleTimeEnd: t = 0, canvasWid
1570
1643
  boxSizing: "border-box"
1571
1644
  }, children: se("span", { children: T.label }) }, T.start)) });
1572
1645
  }
1573
- Li.displayName = "DateHeader";
1574
- function Yi(i, e, t, n, s) {
1575
- return typeof n == "function" ? n(i.toDate(), e.toDate(), t) : typeof n == "string" ? i.format(n) : Ai(i, t);
1646
+ ji.displayName = "DateHeader";
1647
+ function Gi(i, e, t, n, o) {
1648
+ return typeof n == "function" ? n(i.toDate(), e.toDate(), t) : typeof n == "string" ? i.format(n) : Ni(i, t);
1576
1649
  }
1577
- function Ai(i, e) {
1650
+ function Ni(i, e) {
1578
1651
  switch (e) {
1579
1652
  case "year":
1580
1653
  return i.format("YYYY");
@@ -1588,24 +1661,24 @@ function Ai(i, e) {
1588
1661
  return i.format("HH:mm");
1589
1662
  }
1590
1663
  }
1591
- function ji({ width: i, children: e, style: t }) {
1664
+ function zi({ width: i, children: e, style: t }) {
1592
1665
  const n = () => ({ style: { width: i, ...t } });
1593
- return e ? se(Nt, { children: e({ getRootProps: n }) }) : se("div", { style: { width: i } });
1666
+ return e ? se($t, { children: e({ getRootProps: n }) }) : se("div", { style: { width: i } });
1594
1667
  }
1595
- ji.displayName = "SidebarHeader";
1596
- function Ni({ children: i }) {
1597
- return se(Nt, { children: i });
1668
+ zi.displayName = "SidebarHeader";
1669
+ function $i({ children: i }) {
1670
+ return se($t, { children: i });
1598
1671
  }
1599
- Ni.displayName = "CustomHeader";
1672
+ $i.displayName = "CustomHeader";
1600
1673
  export {
1601
- Vi as CanvasTimeline,
1602
- Ni as CustomHeader,
1603
- Xi as CustomMarker,
1604
- Ee as DEFAULT_THEME,
1605
- Li as DateHeader,
1606
- bi as HierarchyEngine,
1607
- ji as SidebarHeader,
1608
- Fi as TimelineHeaders,
1609
- Pi as TodayMarker
1674
+ Ui as CanvasTimeline,
1675
+ $i as CustomHeader,
1676
+ Fi as CustomMarker,
1677
+ Ce as DEFAULT_THEME,
1678
+ ji as DateHeader,
1679
+ Si as HierarchyEngine,
1680
+ zi as SidebarHeader,
1681
+ Bi as TimelineHeaders,
1682
+ Xi as TodayMarker
1610
1683
  };
1611
1684
  //# sourceMappingURL=canvas-timeline.es.js.map