@umriss-ui/schedule 0.3.16 → 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.
package/dist/schedule.js CHANGED
@@ -1,204 +1,297 @@
1
1
  import "./schedule.css";
2
- var fs = Object.defineProperty;
3
- var ps = (o, t, e) => t in o ? fs(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
4
- var f = (o, t, e) => ps(o, typeof t != "symbol" ? t + "" : t, e);
5
- import { jsxs as z, Fragment as Ot, jsx as k } from "react/jsx-runtime";
6
- import { useContext as Be, createContext as Ne, useRef as G, useEffect as K, forwardRef as ms, useState as ut, useId as gs, useLayoutEffect as ft, useImperativeHandle as ks, useSyncExternalStore as ys, useMemo as X } from "react";
7
- import { toWorkingTimeClamped as U, resolveColours as vs, removedIntervals as ws, localOffset as $t, MINUTE as V, calendarFrom as tt, toWallClock as j, DAY as q, timeStep as bs, workingTimeTicks as Ms, HOUR as xt, LinearScale as Ts, subscribeTheme as Is } from "@umriss-ui/charts";
8
- import { useFormats as Gt, useWording as gt, AngleGlyph as Cs, VisuallyHidden as me } from "@umriss-ui/core";
9
- const $e = Ne(null), xe = Ne(null);
10
- function Ge() {
11
- return Be(xe);
12
- }
13
- function Ss(o) {
14
- const t = Be($e);
2
+ var rs = Object.defineProperty;
3
+ var as = (o, t, e) => t in o ? rs(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
4
+ var f = (o, t, e) => as(o, typeof t != "symbol" ? t + "" : t, e);
5
+ import { localOffset as Pt, toWorkingTimeClamped as H, DAY as U, MINUTE as q, timeStep as ls, workingTimeTicks as ds, calendarFrom as et, toWallClock as j, HOUR as Bt, LinearScale as hs, resolveColours as cs, removedIntervals as us, subscribeTheme as fs, Echoes as ps } from "@umriss-ui/charts";
6
+ import { createContext as Fe, useContext as Oe, useRef as G, useEffect as W, forwardRef as Ee, useId as ms, useState as tt, useLayoutEffect as it, useImperativeHandle as gs, useSyncExternalStore as Re, useMemo as X, createElement as ks } from "react";
7
+ import { jsxs as K, Fragment as Dt, jsx as k } from "react/jsx-runtime";
8
+ import { useFormats as xt, useWording as mt, AngleGlyph as ys, VisuallyHidden as he } from "@umriss-ui/core";
9
+ function nt(o) {
10
+ return { from: o.from - (o.leadIn ?? 0), to: o.to + (o.leadOut ?? 0) };
11
+ }
12
+ function $t(o, t) {
13
+ return (o.leaves ?? "leadOut") === "main" ? t.to : t.to + (t.leadOut ?? 0);
14
+ }
15
+ function Gt(o, t) {
16
+ return (o.arrives ?? "leadIn") === "main" ? t.from : t.from - (t.leadIn ?? 0);
17
+ }
18
+ function ce(o, t) {
19
+ if (t.kind === "place" || t.subtask !== o.id) return o;
20
+ switch (t.kind) {
21
+ case "move":
22
+ case "stretch":
23
+ return { ...o, from: t.from, to: t.to };
24
+ case "leadIn":
25
+ return { ...o, leadIn: t.leadIn };
26
+ case "leadOut":
27
+ return { ...o, leadOut: t.leadOut };
28
+ case "lane":
29
+ return { ...o, lane: t.lane };
30
+ }
31
+ }
32
+ function po(o, t) {
33
+ return {
34
+ id: t,
35
+ task: o.task,
36
+ lane: o.lane,
37
+ from: o.from,
38
+ to: o.to,
39
+ ...o.leadIn === void 0 ? {} : { leadIn: o.leadIn },
40
+ ...o.leadOut === void 0 ? {} : { leadOut: o.leadOut }
41
+ };
42
+ }
43
+ function Ht(o) {
44
+ const t = [], e = /* @__PURE__ */ new Map();
45
+ o.forEach((s, n) => {
46
+ const { from: i, to: r } = nt(s);
47
+ if (!(i < r)) return;
48
+ const a = e.get(s.lane) ?? [];
49
+ a.push({ subtask: s, index: n, from: i, to: r }), e.set(s.lane, a);
50
+ });
51
+ for (const [s, n] of e) {
52
+ n.sort((i, r) => i.from - r.from || i.index - r.index);
53
+ for (let i = 0; i < n.length; i++) {
54
+ const r = n[i];
55
+ for (let a = i + 1; a < n.length; a++) {
56
+ const d = n[a];
57
+ if (d.from >= r.to) break;
58
+ t.push({ lane: s, first: r.subtask.id, second: d.subtask.id, from: d.from, to: Math.min(r.to, d.to) });
59
+ }
60
+ }
61
+ }
62
+ return t;
63
+ }
64
+ function vs(o) {
65
+ const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map();
66
+ for (const s of o) {
67
+ const n = nt(s), i = e.get(s.lane) ?? [];
68
+ let r = 0;
69
+ if (n.from < n.to) {
70
+ for (const a of i) n.from < a.to && a.from < n.to && r++;
71
+ i.push(n);
72
+ }
73
+ e.set(s.lane, i), t.set(s.id, r);
74
+ }
75
+ return t;
76
+ }
77
+ function Yt(o, t) {
78
+ const e = new Map(o.map((n) => [n.id, n])), s = [];
79
+ for (const n of t) {
80
+ const i = e.get(n.from), r = e.get(n.to);
81
+ if (i === void 0 || r === void 0) continue;
82
+ const a = $t(n, i), d = Gt(n, r), h = a + n.lag - d;
83
+ h > 0 && s.push({ dependency: n.id, departure: a, arrival: d, shortBy: h });
84
+ }
85
+ return s;
86
+ }
87
+ function Ne(o, t) {
88
+ const e = [];
89
+ for (const s of o) {
90
+ const n = nt(s);
91
+ for (const i of t)
92
+ i.lane !== s.lane || !(n.from < i.to && i.from < n.to) || e.push({ subtask: s.id, blocked: i.id, lane: i.lane, from: Math.max(n.from, i.from), to: Math.min(n.to, i.to) });
93
+ }
94
+ return e;
95
+ }
96
+ function mo(o, t, e = []) {
97
+ return {
98
+ overlaps: Ht(o),
99
+ violatedDependencies: Yt(o, t),
100
+ inBlockedTime: Ne(o, e)
101
+ };
102
+ }
103
+ function go(o, t, e) {
104
+ if (e.kind === "place") return [];
105
+ const s = new Map(o.map((d) => [d.id, ce(d, e)])), n = /* @__PURE__ */ new Map();
106
+ for (const d of t) {
107
+ const h = n.get(d.from) ?? [];
108
+ h.push(d), n.set(d.from, h);
109
+ }
110
+ const i = /* @__PURE__ */ new Map(), r = [e.subtask];
111
+ let a = (o.length + 1) * (t.length + 1);
112
+ for (; r.length > 0 && a-- > 0; ) {
113
+ const d = r.shift(), h = s.get(d);
114
+ if (h !== void 0)
115
+ for (const l of n.get(d) ?? []) {
116
+ if (l.to === e.subtask) continue;
117
+ const c = s.get(l.to);
118
+ if (c === void 0) continue;
119
+ const p = $t(l, h) + l.lag - Gt(l, c);
120
+ if (!(p > 0)) continue;
121
+ const m = { kind: "move", subtask: c.id, from: c.from + p, to: c.to + p };
122
+ s.set(c.id, ce(c, m)), i.set(c.id, m), r.push(c.id);
123
+ }
124
+ }
125
+ return [...i.values()];
126
+ }
127
+ function ws(o, t) {
128
+ const { step: e, offset: s } = typeof t == "number" ? { step: t, offset: 0 } : t;
129
+ if (!(e > 0) || !Number.isFinite(o)) return o;
130
+ const n = Pt(o) + s;
131
+ return n + Math.round((o - n) / e) * e;
132
+ }
133
+ function ko(o, t, e) {
134
+ return e === 0 || !Number.isFinite(e) ? [] : o.filter((s) => s.task === t).map((s) => ({ kind: "move", subtask: s.id, from: s.from + e, to: s.to + e }));
135
+ }
136
+ function gt(o) {
137
+ let t = !1, e = !1, s = !1, n = !1;
138
+ for (const i of o ?? [])
139
+ i === "provisional" ? (t = !0, e = !1) : i === "fixed" ? (e = !0, t = !1) : i === "muted" ? s = !0 : i === "open" && (n = !0);
140
+ return { dashed: t, hatched: e, muted: s, open: n };
141
+ }
142
+ const Pe = Fe(null), Be = Fe(null);
143
+ function xe() {
144
+ return Oe(Be);
145
+ }
146
+ function bs(o) {
147
+ const t = Oe(Pe);
15
148
  if (t === null)
16
149
  throw new Error(`@umriss-ui/schedule: <${o}> must be used inside a <Schedule>.`);
17
150
  return t;
18
151
  }
19
- function Ht(o, t, e, n, s) {
20
- const i = Ss(o), r = G(null);
21
- K(() => (r.current = e(i, t), () => {
22
- r.current !== null && s(i, r.current), r.current = null;
23
- }), [i]), K(() => {
24
- r.current !== null && n(i, r.current, t);
152
+ function zt(o, t, e, s, n) {
153
+ const i = bs(o), r = G(null);
154
+ W(() => (r.current = e(i, t), () => {
155
+ r.current !== null && n(i, r.current), r.current = null;
156
+ }), [i]), W(() => {
157
+ r.current !== null && s(i, r.current, t);
25
158
  });
26
159
  }
27
- function Ls(o) {
28
- Ht("Lane", o, (t, e) => t.registerLane(e), (t, e, n) => t.updateLane(e, n), (t, e) => t.unregisterLane(e));
29
- }
30
- function As(o) {
31
- Ht("LaneGroup", o, (t, e) => t.registerGroup(e), (t, e, n) => t.updateGroup(e, n), (t, e) => t.unregisterGroup(e));
160
+ function Ms(o) {
161
+ zt("Lane", o, (t, e) => t.registerLane(e), (t, e, s) => t.updateLane(e, s), (t, e) => t.unregisterLane(e));
32
162
  }
33
- function Yt(o, t) {
34
- Ht(o, t, (e, n) => e.registerLayer(n), (e, n, s) => e.updateLayer(n, s), (e, n) => e.unregisterLayer(n));
163
+ function Ts(o) {
164
+ zt("LaneGroup", o, (t, e) => t.registerGroup(e), (t, e, s) => t.updateGroup(e, s), (t, e) => t.unregisterGroup(e));
35
165
  }
36
- function kt(o) {
37
- let t = !1, e = !1, n = !1, s = !1;
38
- for (const i of o ?? [])
39
- i === "provisional" ? (t = !0, e = !1) : i === "fixed" ? (e = !0, t = !1) : i === "muted" ? n = !0 : i === "open" && (s = !0);
40
- return { dashed: t, hatched: e, muted: n, open: s };
166
+ function Kt(o, t) {
167
+ zt(o, t, (e, s) => e.registerLayer(s), (e, s, n) => e.updateLayer(s, n), (e, s) => e.unregisterLayer(s));
41
168
  }
42
- const Ds = 24, _s = 4, Fs = 3, Lt = 4;
43
- function ge(o) {
44
- const { lanes: t, groups: e, collapsed: n, laneHeight: s } = o, i = new Map(e.map((g) => [g.id, g])), r = (g) => g !== void 0 && i.has(g) ? g : void 0, a = /* @__PURE__ */ new Map(), l = (g) => {
45
- const I = [];
169
+ const Is = 24, Ss = 4, Ls = 3, St = 4;
170
+ function ue(o) {
171
+ const { lanes: t, groups: e, collapsed: s, laneHeight: n } = o, i = new Map(e.map((g) => [g.id, g])), r = (g) => g !== void 0 && i.has(g) ? g : void 0, a = /* @__PURE__ */ new Map(), d = (g) => {
172
+ const T = [];
46
173
  let S = r(g.parent);
47
- const R = /* @__PURE__ */ new Set();
48
- for (; S !== void 0 && !R.has(S); )
49
- R.add(S), I.unshift(S), S = r(i.get(S).parent);
50
- return I;
174
+ const E = /* @__PURE__ */ new Set();
175
+ for (; S !== void 0 && !E.has(S); )
176
+ E.add(S), T.unshift(S), S = r(i.get(S).parent);
177
+ return T;
51
178
  }, h = /* @__PURE__ */ new Map();
52
179
  for (const g of t) {
53
- const I = l(g);
54
- h.set(g.id, I);
55
- for (const S of I) {
56
- const R = a.get(S) ?? [];
57
- R.push(g.id), a.set(S, R);
180
+ const T = d(g);
181
+ h.set(g.id, T);
182
+ for (const S of T) {
183
+ const E = a.get(S) ?? [];
184
+ E.push(g.id), a.set(S, E);
58
185
  }
59
186
  }
60
- const d = [], u = /* @__PURE__ */ new Map();
187
+ const l = [], c = /* @__PURE__ */ new Map();
61
188
  let p = [], m = null, y = 0;
62
- const C = (g) => (d.push({ ...g, top: y }), y += g.height, d.length - 1), A = (g) => g.find((I) => n.has(I)), D = () => {
189
+ const I = (g) => (l.push({ ...g, top: y }), y += g.height, l.length - 1), A = (g) => g.find((T) => s.has(T)), C = () => {
63
190
  if (m === null) return;
64
- const { row: g, lanes: I } = m, S = d[g], R = Math.max(S.height, I.length * _s + 2 * Lt);
65
- d[g] = { ...S, height: R }, y += R - S.height;
66
- const O = R - 2 * Lt, H = Math.max(Fs, Math.floor(O / I.length));
67
- I.forEach((nt, ct) => {
68
- const Z = h.get(nt) ?? [];
69
- u.set(nt, {
70
- top: S.top + Lt + ct * H,
71
- height: H,
191
+ const { row: g, lanes: T } = m, S = l[g], E = Math.max(S.height, T.length * Ss + 2 * St);
192
+ l[g] = { ...S, height: E }, y += E - S.height;
193
+ const D = E - 2 * St, P = Math.max(Ls, Math.floor(D / T.length));
194
+ T.forEach((ot, kt) => {
195
+ const ct = h.get(ot) ?? [];
196
+ c.set(ot, {
197
+ top: S.top + St + kt * P,
198
+ height: P,
72
199
  miniature: !0,
73
- group: Z[Z.length - 1]
200
+ group: ct[ct.length - 1]
74
201
  });
75
202
  }), m = null;
76
203
  };
77
204
  for (const g of t) {
78
- const I = (h.get(g.id) ?? []).filter((O) => (a.get(O) ?? []).length > 0), S = A(I);
205
+ const T = (h.get(g.id) ?? []).filter((D) => (a.get(D) ?? []).length > 0), S = A(T);
79
206
  if (m !== null && S === m.group) {
80
207
  m.lanes.push(g.id);
81
208
  continue;
82
209
  }
83
- D();
84
- const R = I.filter((O, H) => p[H] === O).length;
85
- p = p.slice(0, R);
86
- for (const O of I.slice(R)) {
87
- if (p.push(O), O === S) break;
88
- C({
210
+ C();
211
+ const E = T.filter((D, P) => p[P] === D).length;
212
+ p = p.slice(0, E);
213
+ for (const D of T.slice(E)) {
214
+ if (p.push(D), D === S) break;
215
+ I({
89
216
  kind: "groupHead",
90
217
  lane: void 0,
91
- group: O,
218
+ group: D,
92
219
  depth: p.length - 1,
93
220
  within: [...p],
94
- lanes: (a.get(O) ?? []).length,
95
- height: Ds
221
+ lanes: (a.get(D) ?? []).length,
222
+ height: Is
96
223
  });
97
224
  }
98
225
  if (S !== void 0) {
99
- const O = I.indexOf(S), H = C({
226
+ const D = T.indexOf(S), P = I({
100
227
  kind: "miniature",
101
228
  lane: void 0,
102
229
  group: S,
103
- depth: O,
104
- within: I.slice(0, O + 1),
230
+ depth: D,
231
+ within: T.slice(0, D + 1),
105
232
  lanes: (a.get(S) ?? []).length,
106
- height: s
233
+ height: n
107
234
  });
108
- m = { group: S, row: H, lanes: [g.id] };
235
+ m = { group: S, row: P, lanes: [g.id] };
109
236
  continue;
110
237
  }
111
- C({ kind: "lane", lane: g.id, group: I[I.length - 1], depth: I.length, within: I, lanes: 1, height: s }), u.set(g.id, {
112
- top: d[d.length - 1].top,
113
- height: s,
238
+ I({ kind: "lane", lane: g.id, group: T[T.length - 1], depth: T.length, within: T, lanes: 1, height: n }), c.set(g.id, {
239
+ top: l[l.length - 1].top,
240
+ height: n,
114
241
  miniature: !1,
115
- group: I[I.length - 1]
242
+ group: T[T.length - 1]
116
243
  });
117
244
  }
118
- return D(), { rows: d, slots: u, height: y };
245
+ return C(), { rows: l, slots: c, height: y };
119
246
  }
120
- function Os(o, t) {
247
+ function As(o, t) {
121
248
  if (t.size === 0) return o;
122
249
  const e = /* @__PURE__ */ new Set();
123
- for (const n of o) t.has(n) || e.add(n);
250
+ for (const s of o) t.has(s) || e.add(s);
124
251
  return e;
125
252
  }
126
- function et(o, t) {
253
+ function st(o, t) {
127
254
  if (t < 0 || t >= o.height) return null;
128
- let e = 0, n = o.rows.length - 1;
129
- for (; e <= n; ) {
130
- const s = e + n >> 1, i = o.rows[s];
131
- if (t < i.top) n = s - 1;
132
- else if (t >= i.top + i.height) e = s + 1;
255
+ let e = 0, s = o.rows.length - 1;
256
+ for (; e <= s; ) {
257
+ const n = e + s >> 1, i = o.rows[n];
258
+ if (t < i.top) s = n - 1;
259
+ else if (t >= i.top + i.height) e = n + 1;
133
260
  else return i;
134
261
  }
135
262
  return null;
136
263
  }
137
- function Kt(o, t) {
264
+ function Vt(o, t) {
138
265
  return o.slots.get(t) ?? null;
139
266
  }
140
- function Es(o, t) {
141
- const e = et(o, t);
267
+ function Cs(o, t) {
268
+ const e = st(o, t);
142
269
  if (e === null) return null;
143
270
  if (e.kind === "lane") return e.lane ?? null;
144
271
  if (e.kind === "groupHead") return null;
145
- for (const [n, s] of o.slots)
146
- if (s.miniature && t >= s.top && t < s.top + s.height) return n;
272
+ for (const [s, n] of o.slots)
273
+ if (n.miniature && t >= n.top && t < n.top + n.height) return s;
147
274
  return null;
148
275
  }
149
- function st(o) {
150
- return { from: o.from - (o.leadIn ?? 0), to: o.to + (o.leadOut ?? 0) };
151
- }
152
- function zt(o, t) {
153
- return (o.leaves ?? "leadOut") === "main" ? t.to : t.to + (t.leadOut ?? 0);
154
- }
155
- function Ut(o, t) {
156
- return (o.arrives ?? "leadIn") === "main" ? t.from : t.from - (t.leadIn ?? 0);
157
- }
158
- function ke(o, t) {
159
- if (t.kind === "place" || t.subtask !== o.id) return o;
160
- switch (t.kind) {
161
- case "move":
162
- case "stretch":
163
- return { ...o, from: t.from, to: t.to };
164
- case "leadIn":
165
- return { ...o, leadIn: t.leadIn };
166
- case "leadOut":
167
- return { ...o, leadOut: t.leadOut };
168
- case "lane":
169
- return { ...o, lane: t.lane };
170
- }
171
- }
172
- function fo(o, t) {
173
- return {
174
- id: t,
175
- task: o.task,
176
- lane: o.lane,
177
- from: o.from,
178
- to: o.to,
179
- ...o.leadIn === void 0 ? {} : { leadIn: o.leadIn },
180
- ...o.leadOut === void 0 ? {} : { leadOut: o.leadOut }
181
- };
182
- }
183
- const Rs = 6, He = 3, rt = 2, ye = 3, ve = 3;
276
+ const _s = 6, $e = 3, rt = 2, fe = 3, pe = 3;
184
277
  function N(o, t) {
185
- return Math.round(o.scale.toPx(U(t, o.calendar)));
278
+ return Math.round(o.scale.toPx(H(t, o.calendar)));
186
279
  }
187
280
  function dt(o, t) {
188
- const e = Kt(o.rows, t);
281
+ const e = Vt(o.rows, t);
189
282
  return e === null ? null : { ...e, top: e.top - o.scrollY };
190
283
  }
191
- function we(o, t) {
192
- return Es(o.rows, t + o.scrollY);
284
+ function me(o, t) {
285
+ return Cs(o.rows, t + o.scrollY);
193
286
  }
194
- function Ye(o, t, e, n, s) {
195
- const i = n.miniature ? 0 : Rs, r = n.miniature ? 0 : ve * ye, a = Math.max(n.miniature ? 1 : 4, n.height - 2 * i - r), l = n.top - o.scrollY + Math.floor((n.height - a) / 2), h = st(t);
287
+ function Ge(o, t, e, s, n) {
288
+ const i = s.miniature ? 0 : _s, r = s.miniature ? 0 : pe * fe, a = Math.max(s.miniature ? 1 : 4, s.height - 2 * i - r), d = s.top - o.scrollY + Math.floor((s.height - a) / 2), h = nt(t);
196
289
  return {
197
290
  subtask: t,
198
291
  lane: e,
199
- miniature: n.miniature,
200
- depth: s,
201
- y: l + (n.miniature ? 0 : Math.min(s, ve) * ye),
292
+ miniature: s.miniature,
293
+ depth: n,
294
+ y: d + (s.miniature ? 0 : Math.min(n, pe) * fe),
202
295
  height: a,
203
296
  outerFrom: N(o, h.from),
204
297
  mainFrom: N(o, t.from),
@@ -206,118 +299,683 @@ function Ye(o, t, e, n, s) {
206
299
  outerTo: N(o, h.to)
207
300
  };
208
301
  }
209
- function Ke(o, t, e) {
302
+ function He(o, t, e) {
210
303
  if (e < o.y || e > o.y + o.height) return null;
211
- const n = Math.max(0, (6 - (o.outerTo - o.outerFrom)) / 2);
212
- return t < o.outerFrom - n || t > o.outerTo + n ? null : t < o.mainFrom ? "leadIn" : t > o.mainTo ? "leadOut" : "main";
304
+ const s = Math.max(0, (6 - (o.outerTo - o.outerFrom)) / 2);
305
+ return t < o.outerFrom - s || t > o.outerTo + s ? null : t < o.mainFrom ? "leadIn" : t > o.mainTo ? "leadOut" : "main";
213
306
  }
214
- function Ps(o, t, e, n = 5) {
307
+ function Ds(o, t, e, s = 5) {
215
308
  if (e < o.y || e > o.y + o.height) return null;
216
- const s = Math.abs(t - o.mainFrom), i = Math.abs(t - o.mainTo);
217
- return Math.min(s, i) > n ? null : s <= i ? "from" : "to";
309
+ const n = Math.abs(t - o.mainFrom), i = Math.abs(t - o.mainTo);
310
+ return Math.min(n, i) > s ? null : n <= i ? "from" : "to";
218
311
  }
219
- function Et(o, t, e) {
312
+ function Ft(o, t, e) {
220
313
  return o.outerTo >= 0 && o.outerFrom <= t && o.y + o.height >= 0 && o.y <= e;
221
314
  }
222
- const Bs = 64;
223
- function Ns(o, t) {
315
+ const Fs = 64;
316
+ function Os(o, t) {
224
317
  if (o.miniature) return null;
225
- const e = kt(o.subtask.appearance).hatched ? rt + He + 1 : 0, n = Math.max(o.mainFrom + e, 0), s = Math.min(o.mainTo - e, t) - n;
226
- return s < Bs ? null : { x: n, width: s, y: o.y, height: o.height };
318
+ const e = gt(o.subtask.appearance).hatched ? rt + $e + 1 : 0, s = Math.max(o.mainFrom + e, 0), n = Math.min(o.mainTo - e, t) - s;
319
+ return n < Fs ? null : { x: s, width: n, y: o.y, height: o.height };
227
320
  }
228
- const $s = 10;
229
- function be(o, t, e) {
230
- const n = Math.round(t.y + t.height / 2);
231
- return o === "centre" || e.y === t.y ? n : Math.round(e.y > t.y ? t.y + t.height - 1 : t.y + 1);
321
+ const Es = 10;
322
+ function ge(o, t, e) {
323
+ const s = Math.round(t.y + t.height / 2);
324
+ return o === "centre" || e.y === t.y ? s : Math.round(e.y > t.y ? t.y + t.height - 1 : t.y + 1);
232
325
  }
233
- function Rt(o, t, e, n, s) {
234
- const i = t.route ?? s.route, r = t.attach ?? s.attach, a = t.ends ?? s.ends, l = N(o, zt(t, e.subtask)), h = N(o, Ut(t, n.subtask)), d = be(r, e, n), u = be(r, n, e);
326
+ function Ot(o, t, e, s, n) {
327
+ const i = t.route ?? n.route, r = t.attach ?? n.attach, a = t.ends ?? n.ends, d = N(o, $t(t, e.subtask)), h = N(o, Gt(t, s.subtask)), l = ge(r, e, s), c = ge(r, s, e);
235
328
  if (i === "straight")
236
- return { dependency: t, kind: i, ends: a, x1: l, y1: d, x2: h, y2: u, c1x: l, c2x: h, points: [l, d, h, u] };
329
+ return { dependency: t, kind: i, ends: a, x1: d, y1: l, x2: h, y2: c, c1x: d, c2x: h, points: [d, l, h, c] };
237
330
  if (i === "orthogonal") {
238
- const A = l + $s, D = d === u ? A : Math.round((A + h) / 2);
239
- return { dependency: t, kind: i, ends: a, x1: l, y1: d, x2: h, y2: u, c1x: l, c2x: h, points: d === u ? [l, d, h, u] : [l, d, D, d, D, u, h, u] };
331
+ const A = d + Es, C = l === c ? A : Math.round((A + h) / 2);
332
+ return { dependency: t, kind: i, ends: a, x1: d, y1: l, x2: h, y2: c, c1x: d, c2x: h, points: l === c ? [d, l, h, c] : [d, l, C, l, C, c, h, c] };
240
333
  }
241
- const p = Math.max(14, Math.abs(h - l) / 2), m = l + p, y = h - p, C = [];
334
+ const p = Math.max(14, Math.abs(h - d) / 2), m = d + p, y = h - p, I = [];
242
335
  for (let A = 0; A <= 16; A++) {
243
- const D = A / 16, g = 1 - D;
244
- C.push(
245
- g * g * g * l + 3 * g * g * D * m + 3 * g * D * D * y + D * D * D * h,
246
- g * g * g * d + 3 * g * g * D * d + 3 * g * D * D * u + D * D * D * u
336
+ const C = A / 16, g = 1 - C;
337
+ I.push(
338
+ g * g * g * d + 3 * g * g * C * m + 3 * g * C * C * y + C * C * C * h,
339
+ g * g * g * l + 3 * g * g * C * l + 3 * g * C * C * c + C * C * C * c
247
340
  );
248
341
  }
249
- return { dependency: t, kind: "curve", ends: a, x1: l, y1: d, x2: h, y2: u, c1x: m, c2x: y, points: C };
342
+ return { dependency: t, kind: "curve", ends: a, x1: d, y1: l, x2: h, y2: c, c1x: m, c2x: y, points: I };
343
+ }
344
+ function Rs(o, t, e) {
345
+ let s = 1 / 0;
346
+ const n = o.points;
347
+ for (let i = 0; i + 3 < n.length; i += 2) {
348
+ const r = n[i], a = n[i + 1], d = n[i + 2], h = n[i + 3], l = d - r, c = h - a, p = l * l + c * c, m = p === 0 ? 0 : Math.max(0, Math.min(1, ((t - r) * l + (e - a) * c) / p));
349
+ s = Math.min(s, Math.hypot(t - (r + m * l), e - (a + m * c)));
350
+ }
351
+ return s;
352
+ }
353
+ const Ye = [], Ns = 56;
354
+ function Ps(o, t = Ns) {
355
+ return o > 0 ? Math.min(U, Math.max(15 * q, ls(o * t, 1))) : 15 * q;
356
+ }
357
+ function Bs(o, t, e = Ye) {
358
+ const [s, n] = ze(o, e);
359
+ return ds(e, s, n, t, Pt(s)).filter(
360
+ (i) => i.workingTime >= o[0] && i.workingTime <= o[1]
361
+ );
250
362
  }
251
- function xs(o, t, e) {
252
- let n = 1 / 0;
253
- const s = o.points;
254
- for (let i = 0; i + 3 < s.length; i += 2) {
255
- const r = s[i], a = s[i + 1], l = s[i + 2], h = s[i + 3], d = l - r, u = h - a, p = d * d + u * u, m = p === 0 ? 0 : Math.max(0, Math.min(1, ((t - r) * d + (e - a) * u) / p));
256
- n = Math.min(n, Math.hypot(t - (r + m * d), e - (a + m * u)));
363
+ function xs(o, t = Ye) {
364
+ const [e, s] = ze(o, t), n = [], i = new Date(e);
365
+ for (i.setHours(0, 0, 0, 0); i.getTime() < s && n.length < 400; ) {
366
+ const r = i.getTime();
367
+ i.setDate(i.getDate() + 1);
368
+ const a = i.getTime();
369
+ n.push({
370
+ start: r,
371
+ end: a,
372
+ from: H(r, t),
373
+ to: H(a, t)
374
+ });
257
375
  }
258
376
  return n;
259
377
  }
260
- function Wt(o) {
261
- const t = [], e = /* @__PURE__ */ new Map();
262
- o.forEach((n, s) => {
263
- const { from: i, to: r } = st(n);
264
- if (!(i < r)) return;
265
- const a = e.get(n.lane) ?? [];
266
- a.push({ subtask: n, index: s, from: i, to: r }), e.set(n.lane, a);
267
- });
268
- for (const [n, s] of e) {
269
- s.sort((i, r) => i.from - r.from || i.index - r.index);
270
- for (let i = 0; i < s.length; i++) {
271
- const r = s[i];
272
- for (let a = i + 1; a < s.length; a++) {
273
- const l = s[a];
274
- if (l.from >= r.to) break;
275
- t.push({ lane: n, first: r.subtask.id, second: l.subtask.id, from: l.from, to: Math.min(r.to, l.to) });
378
+ const Lt = [1, 2, 7, 14, 28];
379
+ function $s(o, t) {
380
+ return Lt.find((e) => e * o >= t) ?? Lt[Lt.length - 1];
381
+ }
382
+ function At(o, t) {
383
+ return ((Math.round((o - Pt(o)) / U) - 4) % t + t) % t === 0;
384
+ }
385
+ function Gs(o, t, e, s) {
386
+ const n = o[1] - o[0];
387
+ if (!(n > 0)) return [o[0], o[1]];
388
+ const i = Math.min(s.max, Math.max(s.min, n * e)), r = (t - o[0]) / n, a = t - r * i;
389
+ return [a, a + i];
390
+ }
391
+ function Hs(o, t) {
392
+ return [o[0] + t, o[1] + t];
393
+ }
394
+ function ze(o, t) {
395
+ const e = et(t);
396
+ if (e.intervals.length === 0) return [o[0], o[1]];
397
+ const s = (n) => Math.max(0, Math.min(e.total, n));
398
+ return [j(s(o[0]), e), j(s(o[1]), e)];
399
+ }
400
+ const pt = 44;
401
+ class Ys {
402
+ constructor(t) {
403
+ f(this, "options", {
404
+ laneHeight: pt,
405
+ calendar: [],
406
+ zoomLimits: { min: Bt, max: 28 * U },
407
+ snap: "ticks",
408
+ intents: [],
409
+ now: null,
410
+ route: "curve",
411
+ attach: "centre",
412
+ ends: "dot"
413
+ });
414
+ f(this, "domain", [0, U]);
415
+ f(this, "scrollY", 0);
416
+ f(this, "width", 0);
417
+ f(this, "height", 0);
418
+ /* What is laid out from top to bottom (`rows.ts`). It is derived here and
419
+ not in the data, because a row's height comes from a view option; every y
420
+ in the package reads it. */
421
+ f(this, "rows", ue({ lanes: [], groups: [], collapsed: /* @__PURE__ */ new Set(), laneHeight: pt }));
422
+ /** The folded groups, as the scene holds them. */
423
+ f(this, "collapsed", /* @__PURE__ */ new Set());
424
+ /** The groups a gesture in flight holds open. Dropped when it ends; the
425
+ caller's list never learns of it. */
426
+ f(this, "openForGesture", /* @__PURE__ */ new Set());
427
+ f(this, "boxes", []);
428
+ f(this, "boxById", /* @__PURE__ */ new Map());
429
+ f(this, "paths", []);
430
+ this.data = t;
431
+ }
432
+ /** Takes new options; a new calendar keeps the wall-clock span in view. */
433
+ setOptions(t) {
434
+ const e = t.calendar !== this.options.calendar, s = this.options.calendar;
435
+ if (this.options = t, e) {
436
+ const n = et(s), i = (r) => {
437
+ const a = n.intervals.length === 0 ? r : Math.max(0, Math.min(n.total, r));
438
+ return H(j(a, n), t.calendar) + (r - a);
439
+ };
440
+ this.domain = [i(this.domain[0]), i(this.domain[1])];
441
+ }
442
+ }
443
+ /** Puts a span of two wall-clock instants in view. */
444
+ showWall(t) {
445
+ this.domain = [H(t[0], this.options.calendar), H(t[1], this.options.calendar)];
446
+ }
447
+ viewport() {
448
+ return {
449
+ scale: new hs(this.domain, [0, this.width]),
450
+ calendar: this.options.calendar,
451
+ laneHeight: this.options.laneHeight,
452
+ scrollY: this.scrollY,
453
+ rows: this.rows
454
+ };
455
+ }
456
+ maxScroll() {
457
+ return Math.max(0, this.rows.height - this.height);
458
+ }
459
+ /** The lowest y that still lies on a lane. */
460
+ lanesBottom() {
461
+ return this.rows.height - this.scrollY - 1;
462
+ }
463
+ /** The fine band's step at the current zoom. */
464
+ step() {
465
+ const t = this.domain[1] - this.domain[0];
466
+ return Ps(this.width > 0 ? t / this.width : t);
467
+ }
468
+ /** Lays the rows out, clamps the scroll, and lays the data out anew. */
469
+ layout() {
470
+ this.rows = ue({
471
+ lanes: this.data.lanes,
472
+ groups: this.data.groups,
473
+ collapsed: As(this.collapsed, this.openForGesture),
474
+ laneHeight: this.options.laneHeight
475
+ }), this.scrollY = Math.max(0, Math.min(this.maxScroll(), this.scrollY));
476
+ const t = this.viewport();
477
+ this.boxes = [], this.boxById = /* @__PURE__ */ new Map();
478
+ for (const e of this.data.subtasks) {
479
+ const s = Vt(this.rows, e.lane);
480
+ if (s === null) continue;
481
+ const n = Ge(t, e, e.lane, s, this.data.depth.get(e.id) ?? 0);
482
+ this.boxes.push(n), this.boxById.set(e.id, n);
483
+ }
484
+ this.paths = [];
485
+ for (const e of this.data.dependencies) {
486
+ const s = this.boxById.get(e.from), n = this.boxById.get(e.to);
487
+ s === void 0 || n === void 0 || this.paths.push(Ot(t, e, s, n, this.options));
488
+ }
489
+ }
490
+ /** The days of the coarse band and the ticks of the fine band, in pixels. */
491
+ bands() {
492
+ const t = this.step();
493
+ if (this.width <= 0) return { days: [], ticks: [], step: t };
494
+ const e = this.viewport().scale, s = this.options.calendar;
495
+ return {
496
+ days: xs(this.domain, s).map((n) => {
497
+ const i = Math.round(e.toPx(n.from));
498
+ return { start: n.start, x: i, width: Math.round(e.toPx(n.to)) - i };
499
+ }),
500
+ ticks: Bs(this.domain, t, s).map((n) => ({ wallClock: n.wallClock, x: Math.round(e.toPx(n.workingTime)) })),
501
+ step: t
502
+ };
503
+ }
504
+ /** The now line's x, or null where there is none or it lies outside the plot. */
505
+ nowX() {
506
+ const t = this.options.now;
507
+ if (t === null || this.width <= 0) return null;
508
+ const e = Math.round(this.viewport().scale.toPx(H(t, this.options.calendar)));
509
+ return e >= 0 && e <= this.width ? e : null;
510
+ }
511
+ hitAt(t, e) {
512
+ for (let r = this.boxes.length - 1; r >= 0; r--) {
513
+ const a = this.boxes[r], d = He(a, t, e);
514
+ if (d !== null) return { kind: "subtask", subtask: a.subtask, part: d };
515
+ }
516
+ let s = null, n = 4;
517
+ for (const r of this.paths) {
518
+ const a = Rs(r, t, e);
519
+ a <= n && (n = a, s = r);
520
+ }
521
+ if (s !== null) return { kind: "dependency", dependency: s.dependency };
522
+ const i = me(this.viewport(), e);
523
+ return i !== null ? { kind: "lane", lane: i } : { kind: "nothing" };
524
+ }
525
+ /** The wall-clock time at a plot x; within the calendar's extent. */
526
+ timeAt(t) {
527
+ const e = this.viewport().scale.fromPx(t), s = et(this.options.calendar);
528
+ return s.intervals.length === 0 ? e : j(Math.max(0, Math.min(s.total, e)), s);
529
+ }
530
+ /** The lane at a y, strips included: what the pointer is ON.
531
+
532
+ One line, and it stays a line of its own: it is one of the three
533
+ questions this object answers about a y - this one, `dropLaneIdAt` and
534
+ `foldedGroupAt` - and a caller that reached through `viewport()` for it
535
+ would be depending on the layout rather than asking the view. */
536
+ laneIdAt(t) {
537
+ return me(this.viewport(), t);
538
+ }
539
+ /** The lane a DROP at this y would land on.
540
+
541
+ A **Miniature** is no drop target. A strip is three pixels of a lane's
542
+ whole day, and a drop aimed at one would be a guess; resting over the
543
+ group opens it for the gesture instead, and then there is a real lane to
544
+ aim at. Hover, the tooltip and selection do read a strip - they cost
545
+ nothing if they are a pixel out. */
546
+ dropLaneIdAt(t) {
547
+ const e = st(this.rows, t + this.scrollY);
548
+ return e === null || e.kind !== "lane" ? null : e.lane ?? null;
549
+ }
550
+ /** The folded group a y lies over, or null. */
551
+ foldedGroupAt(t) {
552
+ const e = st(this.rows, t + this.scrollY);
553
+ return e !== null && e.kind === "miniature" ? e.group ?? null : null;
554
+ }
555
+ /** Pans by pixels. Says what moved: the span through time, the lanes, or
556
+ neither - a scroll through the lanes is no news about the time. */
557
+ pan(t, e) {
558
+ const s = this.domain[0], n = this.scrollY, i = this.domain[1] - s;
559
+ this.width > 0 && t !== 0 && (this.domain = Hs(this.domain, t / this.width * i)), this.scrollY = Math.max(0, Math.min(this.maxScroll(), this.scrollY + e));
560
+ const r = this.domain[0] !== s;
561
+ return { moved: r || this.scrollY !== n, time: r };
562
+ }
563
+ /** Zooms around a plot x; says whether the span changed. */
564
+ zoomAt(t, e) {
565
+ if (this.width <= 0 || !Number.isFinite(e)) return !1;
566
+ const s = this.domain, n = this.viewport().scale.fromPx(t);
567
+ return this.domain = Gs(this.domain, n, e, this.options.zoomLimits), s[0] !== this.domain[0] || s[1] !== this.domain[1];
568
+ }
569
+ }
570
+ const zs = "_root_1892z_4 _text_r8i8z_23", Ks = "_corner_1892z_19", Vs = "_dayBand_1892z_23", Ws = "_tickBand_1892z_24", Us = "_day_1892z_23", Xs = "_dayLabel_1892z_50", qs = "_tick_1892z_24", js = "_tickLabel_1892z_71", Js = "_headers_1892z_79", Zs = "_header_1892z_79", Qs = "_headerLabel_1892z_97", tn = "_headerCount_1892z_134", en = "_chevron_1892z_143", sn = "_plot_1892z_201", nn = "_focusRing_1892z_208", on = "_layer_1892z_226", rn = "_grip_1892z_235", an = "_ghostLabel_1892z_245", ln = "_finding_1892z_258", dn = "_refusal_1892z_266", hn = "_tooltip_1892z_270", cn = "_tooltipHead_1892z_289", un = "_tooltipTimes_1892z_294", fn = "_now_1892z_303", pn = "_barLabel_1892z_317", mn = "_barLabelText_1892z_330", v = {
571
+ root: zs,
572
+ corner: Ks,
573
+ dayBand: Vs,
574
+ tickBand: Ws,
575
+ day: Us,
576
+ dayLabel: Xs,
577
+ tick: qs,
578
+ tickLabel: js,
579
+ headers: Js,
580
+ header: Zs,
581
+ headerLabel: Qs,
582
+ headerCount: tn,
583
+ chevron: en,
584
+ plot: sn,
585
+ focusRing: nn,
586
+ layer: on,
587
+ grip: rn,
588
+ ghostLabel: an,
589
+ finding: ln,
590
+ refusal: dn,
591
+ tooltip: hn,
592
+ tooltipHead: cn,
593
+ tooltipTimes: un,
594
+ now: fn,
595
+ barLabel: pn,
596
+ barLabelText: mn
597
+ };
598
+ function Ke() {
599
+ const o = mt();
600
+ return (t) => {
601
+ const e = Math.round(t / q), s = Math.floor(e / 60), n = e % 60;
602
+ return [s > 0 ? o.hoursShort(s) : "", n > 0 || s === 0 ? o.minutesShort(n) : ""].filter(Boolean).join(" ");
603
+ };
604
+ }
605
+ function gn({ target: o, lane: t }) {
606
+ const e = xt(), s = mt(), n = Ke(), i = (c) => e.time(new Date(c), !1);
607
+ if (o.kind === "subtask") {
608
+ const { subtask: c, task: p } = o, m = [
609
+ (p == null ? void 0 : p.name) ?? c.task,
610
+ c.name ?? c.id,
611
+ `${e.dateShort(new Date(c.from))} ${s.scheduleGhostTimes(i(c.from), i(c.to))}`,
612
+ ...o.overlapping.map((y) => s.scheduleOverlapWith(y.name ?? y.id)),
613
+ ...o.violatedDependencies.map((y) => s.scheduleViolatedBy(n(y.shortBy))),
614
+ ...o.blocked.map((y) => s.scheduleInBlockedTime(y.label))
615
+ ];
616
+ return /* @__PURE__ */ K(Dt, { children: [
617
+ t,
618
+ `, ${m.join(", ")}`
619
+ ] });
620
+ }
621
+ const { dependency: r, task: a, from: d, to: h, violated: l } = o;
622
+ return [
623
+ (a == null ? void 0 : a.name) ?? (a == null ? void 0 : a.id) ?? r.id,
624
+ `${s.scheduleDependency} ${n(r.lag)}`,
625
+ s.scheduleRoute((d == null ? void 0 : d.name) ?? r.from, (h == null ? void 0 : h.name) ?? r.to),
626
+ ...l === void 0 ? [] : [s.scheduleViolatedBy(n(l.shortBy))]
627
+ ].join(", ");
628
+ }
629
+ function kn({ target: o }) {
630
+ const t = xt(), e = mt(), s = (l) => t.time(new Date(l), !1), n = Ke();
631
+ if (o.kind === "subtask") {
632
+ const { subtask: l, task: c } = o;
633
+ return /* @__PURE__ */ K(Dt, { children: [
634
+ /* @__PURE__ */ k("span", { className: v.tooltipHead, children: (c == null ? void 0 : c.name) ?? l.task }),
635
+ /* @__PURE__ */ k("span", { children: l.name ?? l.id }),
636
+ /* @__PURE__ */ k("span", { className: v.tooltipTimes, children: e.scheduleGhostTimes(s(l.from), s(l.to)) }),
637
+ (l.leadIn ?? 0) > 0 && /* @__PURE__ */ k("span", { children: `${e.scheduleLeadIn} ${n(l.leadIn)}` }),
638
+ (l.leadOut ?? 0) > 0 && /* @__PURE__ */ k("span", { children: `${e.scheduleLeadOut} ${n(l.leadOut)}` }),
639
+ o.overlapping.map((p) => /* @__PURE__ */ k("span", { className: v.finding, children: e.scheduleOverlapWith(p.name ?? p.id) }, p.id)),
640
+ o.violatedDependencies.map((p) => /* @__PURE__ */ k("span", { className: v.finding, children: e.scheduleViolatedBy(n(p.shortBy)) }, p.dependency)),
641
+ o.blocked.map((p) => /* @__PURE__ */ k("span", { className: v.finding, children: e.scheduleInBlockedTime(p.label) }, p.id))
642
+ ] });
643
+ }
644
+ const { dependency: i, task: r, from: a, to: d, violated: h } = o;
645
+ return /* @__PURE__ */ K(Dt, { children: [
646
+ /* @__PURE__ */ k("span", { className: v.tooltipHead, children: (r == null ? void 0 : r.name) ?? (r == null ? void 0 : r.id) ?? i.id }),
647
+ /* @__PURE__ */ k("span", { children: e.scheduleRoute((a == null ? void 0 : a.name) ?? i.from, (d == null ? void 0 : d.name) ?? i.to) }),
648
+ /* @__PURE__ */ k("span", { children: `${e.scheduleDependency} ${n(i.lag)}` }),
649
+ h !== void 0 && /* @__PURE__ */ k("span", { className: v.finding, children: e.scheduleViolatedBy(n(h.shortBy)) })
650
+ ] });
651
+ }
652
+ const yn = [], ke = { min: Bt, max: 28 * U }, vn = [], ye = 20, Ct = 44, wn = Ee(function(t, e) {
653
+ var de;
654
+ const {
655
+ scene: s,
656
+ ariaLabel: n,
657
+ height: i = 400,
658
+ laneHeight: r = pt,
659
+ headerWidth: a = 160,
660
+ calendar: d = vn,
661
+ zoomLimits: h,
662
+ snap: l = "ticks",
663
+ intents: c = yn,
664
+ onIntent: p,
665
+ canMoveTo: m,
666
+ onInteraction: y,
667
+ selectedTask: I,
668
+ onSelectedTaskChange: A,
669
+ placing: C,
670
+ route: g = "curve",
671
+ attach: T = "centre",
672
+ ends: S = "dot",
673
+ label: E,
674
+ tooltip: D,
675
+ now: P,
676
+ className: ot,
677
+ style: kt,
678
+ children: ct
679
+ } = t, yt = ms(), Ut = `${yt}-summary`, Xt = G(null), qt = G(null), jt = G(null), Jt = G(null), Y = xt(), x = mt(), Zt = (h == null ? void 0 : h.min) ?? ke.min, Qt = (h == null ? void 0 : h.max) ?? ke.max, te = typeof l == "object" ? l.step : null, ee = typeof l == "object" ? l.offset : null, se = typeof l == "object" ? null : l, [Ze, Qe] = tt(() => Date.now());
680
+ W(() => {
681
+ if (P !== !0) return;
682
+ const u = setInterval(() => Qe(Date.now()), q);
683
+ return () => clearInterval(u);
684
+ }, [P]);
685
+ const ne = P === !0 ? Ze : typeof P == "number" ? P : null;
686
+ it(() => {
687
+ const u = se ?? { step: te ?? 0, offset: ee ?? 0 };
688
+ s.setOptions({ laneHeight: r, calendar: d, zoomLimits: { min: Zt, max: Qt }, snap: u, intents: c, now: ne, route: g, attach: T, ends: S });
689
+ }, [s, r, d, Zt, Qt, se, te, ee, c, ne, g, T, S]), W(() => {
690
+ s.setHandlers({ onIntent: p, canMoveTo: m, onInteraction: y, onSelectedTaskChange: A });
691
+ }, [s, p, m, y, A]), gs(
692
+ e,
693
+ () => ({
694
+ positionAt: (u, w) => s.positionAt(u, w),
695
+ clientPointOf: (u, w) => s.clientPointOf(u, w),
696
+ visibleDomain: () => s.visibleDomain()
697
+ }),
698
+ [s]
699
+ ), W(() => {
700
+ s.setControlledTask(I);
701
+ }, [s, I]), W(() => {
702
+ s.setPlacing(C ?? null);
703
+ }, [s, C]), W(() => {
704
+ const u = Xt.current, w = qt.current, L = jt.current, R = Jt.current;
705
+ if (!u || !w || !L || !R) return;
706
+ s.bind(u, w, L, R);
707
+ const _ = w.getBoundingClientRect();
708
+ s.resize(_.width, _.height);
709
+ const F = new ResizeObserver((O) => {
710
+ var ut;
711
+ const $ = (ut = O[O.length - 1]) == null ? void 0 : ut.contentRect;
712
+ $ !== void 0 && s.resize($.width, $.height);
713
+ });
714
+ F.observe(w);
715
+ const B = (O) => s.wheel(O);
716
+ u.addEventListener("wheel", B, { passive: !1 });
717
+ const z = (O) => {
718
+ O.key === "Escape" && s.cancelEdit() && O.preventDefault();
719
+ };
720
+ return window.addEventListener("keydown", z), () => {
721
+ window.removeEventListener("keydown", z), u.removeEventListener("wheel", B), F.disconnect(), s.unbind();
722
+ };
723
+ }, [s]);
724
+ const b = Re(s.subscribe, s.getSnapshot, s.getServerSnapshot), ts = (u, w) => {
725
+ const L = new Date(u);
726
+ return w >= 200 ? Y.dateLong(L) : w >= 84 ? Y.date(L) : w >= Ct ? Y.dateShort(L) : "";
727
+ }, es = b.days.reduce((u, w) => Math.max(u, w.width), 0), J = $s(es, Ct), oe = b.step >= U ? J : 1, M = b.ghost, Z = b.spoken, vt = b.summary, ie = (u) => `${Y.dateShort(new Date(u))} ${Y.time(new Date(u), !1)}`, wt = (u) => `${yt}-row-${encodeURIComponent(u.key)}`, ss = X(() => {
728
+ const u = /* @__PURE__ */ new Map();
729
+ for (const w of b.headers)
730
+ for (const L of w.within)
731
+ w.kind === "groupHead" && L === w.group || u.set(L, [...u.get(L) ?? [], wt(w)]);
732
+ return u;
733
+ }, [b.headers, yt]), re = G(null);
734
+ it(() => {
735
+ var F;
736
+ const u = re.current;
737
+ if (u === null) return;
738
+ let w = !0;
739
+ const L = () => {
740
+ if (!w) return;
741
+ const B = [...u.querySelectorAll("[data-lane-count]")];
742
+ for (const O of B) O.hidden = !1;
743
+ const z = B.some((O) => {
744
+ const $ = O.previousElementSibling;
745
+ if (!($ instanceof HTMLElement)) return !1;
746
+ const ut = parseFloat(getComputedStyle($).lineHeight);
747
+ return $.scrollWidth > $.clientWidth || $.clientHeight > ut * 1.5;
748
+ });
749
+ for (const O of B) O.hidden = z;
750
+ };
751
+ L(), (F = document.fonts) == null || F.ready.then(L);
752
+ const R = new ResizeObserver(L);
753
+ R.observe(u);
754
+ const _ = new MutationObserver(L);
755
+ return _.observe(u, { childList: !0, characterData: !0, subtree: !0 }), () => {
756
+ w = !1, R.disconnect(), _.disconnect();
757
+ };
758
+ }, []);
759
+ const ns = X(() => new Set((M == null ? void 0 : M.refusedLanes) ?? []), [M == null ? void 0 : M.refusedLanes]), ae = G(null), [bt, os] = tt({ x: 0, y: 0, at: "" }), Mt = M === null ? "" : `${M.x}:${M.y}:${M.from}:${M.to}:${M.overlap}:${M.violated}:${M.refused}:${M.blocked}`;
760
+ it(() => {
761
+ const u = ae.current;
762
+ if (M === null || u === null) return;
763
+ const w = 4, L = M.y - u.offsetHeight - w, R = M.y + M.height + w, _ = {
764
+ x: Math.max(2, Math.min(M.x, b.width - u.offsetWidth - 2)),
765
+ y: L >= 2 ? L : Math.min(R, b.height - u.offsetHeight - 2),
766
+ at: Mt
767
+ };
768
+ os((F) => F.x === _.x && F.y === _.y && F.at === _.at ? F : _);
769
+ }, [M, Mt, b.width, b.height]);
770
+ const le = G(null), [Tt, is] = tt({ x: 0, y: 0, at: "" }), V = b.tooltip, It = V === null ? "" : `${V.x}:${V.y}:${V.target.kind}`;
771
+ return it(() => {
772
+ const u = le.current;
773
+ if (V === null || u === null) return;
774
+ const w = 12, L = (_, F, B) => {
775
+ const z = _ + w, O = _ - w - F, $ = z + F <= B - 4 || O < 4 ? z : O;
776
+ return Math.max(4, Math.min($, B - F - 4));
777
+ }, R = {
778
+ x: L(V.x, u.offsetWidth, b.width),
779
+ y: L(V.y, u.offsetHeight, b.height),
780
+ at: It
781
+ };
782
+ is((_) => _.x === R.x && _.y === R.y && _.at === R.at ? _ : R);
783
+ }, [V, It, b.width, b.height]), /* @__PURE__ */ K(Pe.Provider, { value: s, children: [
784
+ /* @__PURE__ */ K(
785
+ "div",
786
+ {
787
+ ref: Xt,
788
+ role: "figure",
789
+ "aria-label": n,
790
+ className: ot ? `${v.root} ${ot}` : v.root,
791
+ style: { height: `${i}px`, gridTemplateColumns: `min(${a}px, 40%) minmax(0, 1fr)`, ...kt },
792
+ children: [
793
+ /* @__PURE__ */ k("div", { className: v.corner }),
794
+ /* @__PURE__ */ k("div", { className: v.dayBand, "aria-hidden": "true", "data-schedule-days": "", "data-schedule-clip": "day band", children: b.days.map((u, w) => {
795
+ var B;
796
+ const L = J === 1 || w === 0 || At(u.start, J), R = J === 1 ? u.x + u.width : ((B = b.days.slice(w + 1).find((z) => At(z.start, J))) == null ? void 0 : B.x) ?? b.width, _ = Math.max(0, -u.x), F = Math.min(R, b.width) - Math.max(u.x, 0);
797
+ return /* @__PURE__ */ k("span", { className: v.day, style: { left: `${u.x}px`, width: `${L ? R - u.x : u.width}px` }, children: /* @__PURE__ */ k("span", { className: v.dayLabel, "data-schedule-overlay": "day label", style: { marginLeft: `${_}px` }, children: L ? ts(u.start, J === 1 ? F : Math.min(F, Ct)) : "" }) }, u.start);
798
+ }) }),
799
+ /* @__PURE__ */ k("div", { ref: re, className: v.headers, "data-schedule-headers": "", children: /* @__PURE__ */ k("div", { className: v.headerRun, style: { transform: `translateY(${-b.scrollY}px)` }, children: b.headers.map((u) => /* @__PURE__ */ K(
800
+ "div",
801
+ {
802
+ id: wt(u),
803
+ className: v.header,
804
+ style: { height: `${u.height}px`, paddingLeft: `calc(var(--u-space-3) + ${u.depth} * var(--u-space-3))` },
805
+ "data-lane": u.lane,
806
+ "data-group": u.group,
807
+ "data-row": u.kind,
808
+ "data-schedule-clip": `header ${u.kind}`,
809
+ "data-refused": u.lane !== void 0 && ns.has(u.lane) ? "" : void 0,
810
+ children: [
811
+ u.kind !== "lane" && u.group !== void 0 && /* @__PURE__ */ k(
812
+ "button",
813
+ {
814
+ type: "button",
815
+ className: v.chevron,
816
+ "data-schedule-overlay": "fold control",
817
+ "aria-expanded": u.collapsed === !1,
818
+ "aria-controls": (ss.get(u.group) ?? [wt(u)]).join(" "),
819
+ "aria-label": `${u.collapsed === !0 ? x.scheduleUnfoldGroup : x.scheduleFoldGroup}: ${typeof u.label == "string" ? u.label : u.group}`,
820
+ onClick: () => s.toggleGroup(u.group),
821
+ children: /* @__PURE__ */ k(ys, { size: 9, "data-open": u.collapsed === !1 ? "" : void 0 })
822
+ }
823
+ ),
824
+ /* @__PURE__ */ k("span", { className: v.headerLabel, "data-schedule-overlay": "header label", children: u.label }),
825
+ u.kind !== "lane" && /* @__PURE__ */ k("span", { className: v.headerCount, "data-schedule-overlay": "lane count", "data-lane-count": u.lanes, children: x.scheduleLaneCount(u.lanes) })
826
+ ]
827
+ },
828
+ u.key
829
+ )) }) }),
830
+ /* @__PURE__ */ K(
831
+ "div",
832
+ {
833
+ ref: qt,
834
+ className: v.plot,
835
+ "data-schedule-plot": "",
836
+ "data-schedule-clip": "plot",
837
+ style: { cursor: b.cursor },
838
+ tabIndex: 0,
839
+ role: "application",
840
+ "aria-roledescription": x.scheduleRoleDescription,
841
+ "aria-label": n,
842
+ "aria-describedby": Ut,
843
+ onKeyDown: (u) => {
844
+ s.key(u.nativeEvent) && u.preventDefault();
845
+ },
846
+ onFocus: (u) => s.focus(bn(u.currentTarget)),
847
+ onBlur: () => s.blur(),
848
+ onPointerDown: (u) => s.pointerDown(u.nativeEvent),
849
+ onPointerMove: (u) => s.pointerMove(u.nativeEvent),
850
+ onPointerUp: (u) => s.pointerUp(u.nativeEvent),
851
+ onPointerCancel: (u) => s.pointerCancel(u.nativeEvent),
852
+ onPointerLeave: () => s.pointerLeave(),
853
+ onContextMenu: (u) => s.contextMenu(u.nativeEvent),
854
+ onDragOver: (u) => s.dragOver(u.nativeEvent),
855
+ onDrop: (u) => s.drop(u.nativeEvent),
856
+ onDragLeave: (u) => {
857
+ const w = u.nativeEvent.relatedTarget;
858
+ (!(w instanceof Node) || !u.currentTarget.contains(w)) && s.dragLeave();
859
+ },
860
+ children: [
861
+ /* @__PURE__ */ k("canvas", { ref: jt, className: v.layer, "aria-hidden": "true" }),
862
+ /* @__PURE__ */ k("canvas", { ref: Jt, className: v.layer, "aria-hidden": "true" }),
863
+ b.grips.map((u) => /* @__PURE__ */ k(
864
+ "span",
865
+ {
866
+ "data-grip": u.kind,
867
+ "data-schedule-overlay": `${u.kind} grip`,
868
+ "aria-hidden": "true",
869
+ className: v.grip,
870
+ style: { left: `${u.x}px`, top: `${u.y}px`, height: `${u.height}px` }
871
+ },
872
+ u.kind
873
+ )),
874
+ E !== void 0 && b.bars.map((u) => /* @__PURE__ */ k(
875
+ "span",
876
+ {
877
+ className: v.barLabel,
878
+ "data-bar-label": u.subtask.id,
879
+ "data-schedule-overlay": "bar label",
880
+ "data-schedule-may-cover": "",
881
+ "data-on": u.dark ? "dark" : "light",
882
+ style: { left: `${u.x}px`, top: `${u.y}px`, width: `${u.width}px`, height: `${u.height}px` },
883
+ children: /* @__PURE__ */ k("span", { className: v.barLabelText, children: E(u.subtask) })
884
+ },
885
+ u.subtask.id
886
+ )),
887
+ D !== !1 && b.tooltip !== null && /* @__PURE__ */ k(
888
+ "span",
889
+ {
890
+ ref: le,
891
+ role: "tooltip",
892
+ className: v.tooltip,
893
+ "data-schedule-tooltip": "",
894
+ "data-schedule-overlay": "tooltip",
895
+ style: {
896
+ left: `${Tt.x}px`,
897
+ top: `${Tt.y}px`,
898
+ visibility: Tt.at === It ? void 0 : "hidden"
899
+ },
900
+ children: typeof D == "function" ? D(b.tooltip.target) : /* @__PURE__ */ k(kn, { target: b.tooltip.target })
901
+ }
902
+ ),
903
+ M !== null && /* @__PURE__ */ K(
904
+ "span",
905
+ {
906
+ ref: ae,
907
+ className: v.ghostLabel,
908
+ "data-ghost": "",
909
+ "data-schedule-overlay": "ghost label",
910
+ "data-findings": [M.overlap ? "overlap" : "", M.violated ? "violated-dependency" : ""].filter(Boolean).join(" "),
911
+ "data-refused": M.refused ? "" : void 0,
912
+ "data-blocked": M.blocked ? "" : void 0,
913
+ style: {
914
+ left: `${bt.x}px`,
915
+ top: `${bt.y}px`,
916
+ visibility: bt.at === Mt ? void 0 : "hidden"
917
+ },
918
+ children: [
919
+ x.scheduleGhostTimes(Y.time(new Date(M.from), !1), Y.time(new Date(M.to), !1)),
920
+ M.refused && /* @__PURE__ */ k("span", { className: v.refusal, children: x.scheduleLaneRefused }),
921
+ M.blocked && /* @__PURE__ */ k("span", { className: v.refusal, children: x.scheduleBlockedTime }),
922
+ M.overlap && /* @__PURE__ */ k("span", { className: v.finding, children: x.scheduleOverlap }),
923
+ M.violated && /* @__PURE__ */ k("span", { className: v.finding, children: x.scheduleViolatedDependency })
924
+ ]
925
+ }
926
+ ),
927
+ /* @__PURE__ */ k("span", { className: v.focusRing, "aria-hidden": "true" })
928
+ ]
929
+ }
930
+ ),
931
+ /* @__PURE__ */ k("div", { className: v.corner }),
932
+ /* @__PURE__ */ K("div", { className: v.tickBand, "aria-hidden": "true", "data-schedule-ticks": "", "data-schedule-clip": "time band", children: [
933
+ b.now !== null && /* @__PURE__ */ k("span", { className: v.now, "data-now": "", "data-schedule-overlay": "now mark", style: { left: `${b.now}px` } }),
934
+ b.ticks.map((u) => /* @__PURE__ */ k("span", { className: v.tick, style: { left: `${u.x}px` }, children: u.x >= ye && u.x <= b.width - ye && (oe === 1 || At(u.wallClock, oe)) && /* @__PURE__ */ k("span", { className: v.tickLabel, "data-schedule-overlay": "time label", children: b.step >= U ? Y.dateShort(new Date(u.wallClock)) : Y.time(new Date(u.wallClock), !1) }) }, u.wallClock))
935
+ ] }),
936
+ /* @__PURE__ */ k(he, { "aria-live": "polite", children: Z !== null && /* @__PURE__ */ k(
937
+ gn,
938
+ {
939
+ target: Z.target,
940
+ lane: Z.lane === null ? null : ((de = s.data.lanes.find((u) => u.id === Z.lane)) == null ? void 0 : de.label) ?? Z.lane
941
+ },
942
+ Z.count
943
+ ) }),
944
+ /* @__PURE__ */ k(he, { id: Ut, children: `${x.scheduleSummary({ ...vt, from: ie(vt.from), to: ie(vt.to) })} ${x.scheduleKeyHelp}` })
945
+ ]
276
946
  }
277
- }
947
+ ),
948
+ ct
949
+ ] });
950
+ });
951
+ function bn(o) {
952
+ try {
953
+ return o.matches(":focus-visible");
954
+ } catch {
955
+ return !0;
278
956
  }
279
- return t;
280
957
  }
281
- function Gs(o) {
282
- const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map();
283
- for (const n of o) {
284
- const s = st(n), i = e.get(n.lane) ?? [];
285
- let r = 0;
286
- if (s.from < s.to) {
287
- for (const a of i) s.from < a.to && a.from < s.to && r++;
288
- i.push(s);
289
- }
290
- e.set(n.lane, i), t.set(n.id, r);
291
- }
292
- return t;
958
+ function Mn({ id: o, label: t }) {
959
+ const e = xe(), s = X(() => ({ id: o, label: t ?? o, ...e === null ? {} : { parent: e } }), [o, t, e]);
960
+ return Ms(s), null;
293
961
  }
294
- function Xt(o, t) {
295
- const e = new Map(o.map((s) => [s.id, s])), n = [];
296
- for (const s of t) {
297
- const i = e.get(s.from), r = e.get(s.to);
298
- if (i === void 0 || r === void 0) continue;
299
- const a = zt(s, i), l = Ut(s, r), h = a + s.lag - l;
300
- h > 0 && n.push({ dependency: s.id, departure: a, arrival: l, shortBy: h });
301
- }
302
- return n;
962
+ function Tn({ id: o, label: t, children: e }) {
963
+ const s = xe(), n = X(() => ({ id: o, label: t ?? o, ...s === null ? {} : { parent: s } }), [o, t, s]);
964
+ return Ts(n), /* @__PURE__ */ k(Be.Provider, { value: o, children: e });
303
965
  }
304
- function ze(o, t) {
305
- const e = [];
306
- for (const n of o) {
307
- const s = st(n);
308
- for (const i of t)
309
- i.lane !== n.lane || !(s.from < i.to && i.from < s.to) || e.push({ subtask: n.id, blocked: i.id, lane: i.lane, from: Math.max(s.from, i.from), to: Math.min(s.to, i.to) });
310
- }
311
- return e;
966
+ function In({ data: o, tasks: t }) {
967
+ const e = X(() => ({ kind: "subtasks", data: o, tasks: t }), [o, t]);
968
+ return Kt("Subtasks", e), null;
312
969
  }
313
- function po(o, t, e = []) {
314
- return {
315
- overlaps: Wt(o),
316
- violatedDependencies: Xt(o, t),
317
- inBlockedTime: ze(o, e)
318
- };
970
+ function Sn({ data: o }) {
971
+ const t = X(() => ({ kind: "dependencies", data: o }), [o]);
972
+ return Kt("Dependencies", t), null;
973
+ }
974
+ function Ln({ data: o }) {
975
+ const t = X(() => ({ kind: "blocked", data: o }), [o]);
976
+ return Kt("BlockedTimes", t), null;
319
977
  }
320
- class Hs {
978
+ class An {
321
979
  /** `changed` is called after every registration change. */
322
980
  constructor(t) {
323
981
  f(this, "nextId", 1);
@@ -381,14 +1039,14 @@ class Hs {
381
1039
  rebuild() {
382
1040
  if (!this.dirty) return !1;
383
1041
  this.dirty = !1;
384
- const t = (e) => [...e.keys()].sort((n, s) => n - s).map((n) => e.get(n));
385
- this.lanes = t(this.laneEntries), this.groups = t(this.groupEntries), this.laneIndex = new Map(this.lanes.map((e, n) => [e.id, n])), this.layers = t(this.layerEntries), this.subtasks = [], this.dependencies = [], this.blocked = [], this.tasks = /* @__PURE__ */ new Map();
1042
+ const t = (e) => [...e.keys()].sort((s, n) => s - n).map((s) => e.get(s));
1043
+ this.lanes = t(this.laneEntries), this.groups = t(this.groupEntries), this.laneIndex = new Map(this.lanes.map((e, s) => [e.id, s])), this.layers = t(this.layerEntries), this.subtasks = [], this.dependencies = [], this.blocked = [], this.tasks = /* @__PURE__ */ new Map();
386
1044
  for (const e of this.layers)
387
1045
  if (e.kind === "subtasks") {
388
1046
  this.subtasks.push(...e.data);
389
- for (const n of e.tasks) this.tasks.set(n.id, n);
1047
+ for (const s of e.tasks) this.tasks.set(s.id, s);
390
1048
  } else e.kind === "dependencies" ? this.dependencies.push(...e.data) : this.blocked.push(...e.data);
391
- return this.subtaskById = new Map(this.subtasks.map((e) => [e.id, e])), this.overlaps = Wt(this.subtasks), this.violatedById = new Map(Xt(this.subtasks, this.dependencies).map((e) => [e.dependency, e])), this.depth = Gs(this.subtasks), this.inBlocked = ze(this.subtasks, this.blocked), !0;
1049
+ return this.subtaskById = new Map(this.subtasks.map((e) => [e.id, e])), this.overlaps = Ht(this.subtasks), this.violatedById = new Map(Yt(this.subtasks, this.dependencies).map((e) => [e.dependency, e])), this.depth = vs(this.subtasks), this.inBlocked = Ne(this.subtasks, this.blocked), !0;
392
1050
  }
393
1051
  /** The task a dependency belongs to: its departing subtask's. */
394
1052
  taskOfDependency(t) {
@@ -399,22 +1057,22 @@ class Hs {
399
1057
  data knows about it - its task, and the findings it stands in. */
400
1058
  tooltipTargetFor(t) {
401
1059
  if (t.kind === "subtask") {
402
- const s = t.subtask.id, i = this.overlaps.filter((l) => l.first === s || l.second === s).map((l) => this.subtaskById.get(l.first === s ? l.second : l.first)).filter((l) => l !== void 0), r = this.dependencies.filter((l) => l.from === s || l.to === s).map((l) => this.violatedById.get(l.id)).filter((l) => l !== void 0), a = this.inBlocked.filter((l) => l.subtask === s).map((l) => this.blocked.find((h) => h.id === l.blocked)).filter((l) => l !== void 0);
1060
+ const n = t.subtask.id, i = this.overlaps.filter((d) => d.first === n || d.second === n).map((d) => this.subtaskById.get(d.first === n ? d.second : d.first)).filter((d) => d !== void 0), r = this.dependencies.filter((d) => d.from === n || d.to === n).map((d) => this.violatedById.get(d.id)).filter((d) => d !== void 0), a = this.inBlocked.filter((d) => d.subtask === n).map((d) => this.blocked.find((h) => h.id === d.blocked)).filter((d) => d !== void 0);
403
1061
  return { kind: "subtask", subtask: t.subtask, task: this.tasks.get(t.subtask.task), overlapping: i, violatedDependencies: r, blocked: a };
404
1062
  }
405
1063
  if (t.kind !== "dependency") return null;
406
- const e = t.dependency, n = this.taskOfDependency(e);
1064
+ const e = t.dependency, s = this.taskOfDependency(e);
407
1065
  return {
408
1066
  kind: "dependency",
409
1067
  dependency: e,
410
- task: n !== null ? this.tasks.get(n) : void 0,
1068
+ task: s !== null ? this.tasks.get(s) : void 0,
411
1069
  from: this.subtaskById.get(e.from),
412
1070
  to: this.subtaskById.get(e.to),
413
1071
  violated: this.violatedById.get(e.id)
414
1072
  };
415
1073
  }
416
1074
  }
417
- const Ys = {
1075
+ const Cn = {
418
1076
  line: "var(--u-hairline)",
419
1077
  lineStrong: "var(--u-hairline-strong)",
420
1078
  text: "var(--u-color-text)",
@@ -428,7 +1086,7 @@ const Ys = {
428
1086
  /* What text and marks take ON a filled bar - the same token the bar labels
429
1087
  use in CSS, so a cap and the label beside it are one colour. */
430
1088
  onAccent: "var(--u-color-on-accent)"
431
- }, Ue = {
1089
+ }, Ve = {
432
1090
  line: "GrayText",
433
1091
  lineStrong: "CanvasText",
434
1092
  text: "CanvasText",
@@ -438,22 +1096,22 @@ const Ys = {
438
1096
  active: "Highlight",
439
1097
  now: "GrayText",
440
1098
  onAccent: "Canvas"
441
- }, Ks = (o) => o ? Ue : Ys, zs = () => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(forced-colors: active)").matches;
442
- function Us(o, t) {
443
- const e = zs(), n = {};
444
- for (const r of t.tasks.values()) n[`task:${r.id}`] = e ? Ue.text : r.color;
445
- const s = vs(o, { ...Ks(e), ...n }), i = /* @__PURE__ */ new Map();
446
- for (const r of t.tasks.values()) i.set(r.id, s[`task:${r.id}`] ?? r.color);
1099
+ }, _n = (o) => o ? Ve : Cn, Dn = () => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(forced-colors: active)").matches;
1100
+ function Fn(o, t) {
1101
+ const e = Dn(), s = {};
1102
+ for (const r of t.tasks.values()) s[`task:${r.id}`] = e ? Ve.text : r.color;
1103
+ const n = cs(o, { ..._n(e), ...s }), i = /* @__PURE__ */ new Map();
1104
+ for (const r of t.tasks.values()) i.set(r.id, n[`task:${r.id}`] ?? r.color);
447
1105
  return {
448
- line: s.line,
449
- lineStrong: s.lineStrong,
450
- text: s.text,
451
- muted: s.muted,
452
- alarm: s.alarm,
453
- surface: s.surface,
454
- active: s.active,
455
- now: s.now,
456
- onAccent: s.onAccent,
1106
+ line: n.line,
1107
+ lineStrong: n.lineStrong,
1108
+ text: n.text,
1109
+ muted: n.muted,
1110
+ alarm: n.alarm,
1111
+ surface: n.surface,
1112
+ active: n.active,
1113
+ now: n.now,
1114
+ onAccent: n.onAccent,
457
1115
  tasks: i,
458
1116
  forced: e
459
1117
  };
@@ -462,9 +1120,9 @@ function lt(o) {
462
1120
  const t = o.match(/[\d.]+/g);
463
1121
  return t === null || t.length < 3 ? null : [Number(t[0]), Number(t[1]), Number(t[2])];
464
1122
  }
465
- function Me(o) {
1123
+ function ve(o) {
466
1124
  const t = lt(o);
467
- return t === null ? 0 : Xe(We(t));
1125
+ return t === null ? 0 : Ue(We(t));
468
1126
  }
469
1127
  function We(o) {
470
1128
  return o.map((t) => {
@@ -472,296 +1130,290 @@ function We(o) {
472
1130
  return e <= 0.04045 ? e / 12.92 : ((e + 0.055) / 1.055) ** 2.4;
473
1131
  });
474
1132
  }
475
- function Xe([o, t, e]) {
1133
+ function Ue([o, t, e]) {
476
1134
  return 0.2126 * o + 0.7152 * t + 0.0722 * e;
477
1135
  }
478
- function Te(o, t) {
479
- const e = Me(o), n = Me(t);
480
- return (Math.max(e, n) + 0.05) / (Math.min(e, n) + 0.05);
1136
+ function we(o, t) {
1137
+ const e = ve(o), s = ve(t);
1138
+ return (Math.max(e, s) + 0.05) / (Math.min(e, s) + 0.05);
481
1139
  }
482
- function Ie(o, t, e) {
1140
+ function be(o, t, e) {
483
1141
  if (o === null) return null;
484
- const n = typeof window > "u" ? 1 : window.devicePixelRatio || 1, s = Math.round(t * n), i = Math.round(e * n);
485
- o.width !== s && (o.width = s), o.height !== i && (o.height = i);
1142
+ const s = typeof window > "u" ? 1 : window.devicePixelRatio || 1, n = Math.round(t * s), i = Math.round(e * s);
1143
+ o.width !== n && (o.width = n), o.height !== i && (o.height = i);
486
1144
  const r = o.getContext("2d");
487
- return r === null ? null : (r.setTransform(n, 0, 0, n, 0, 0), r.clearRect(0, 0, t, e), r);
1145
+ return r === null ? null : (r.setTransform(s, 0, 0, s, 0, 0), r.clearRect(0, 0, t, e), r);
488
1146
  }
489
- function Ws(o, t) {
490
- const { data: e, view: n } = t, s = n.viewport();
491
- qs(o, t, s);
492
- for (const i of e.blocked) on(o, t, s, i);
493
- Zs(o, t);
1147
+ function On(o, t) {
1148
+ const { data: e, view: s } = t, n = s.viewport();
1149
+ Pn(o, t, n);
1150
+ for (const i of e.blocked) Kn(o, t, n, i);
1151
+ Bn(o, t);
494
1152
  for (const i of e.layers) {
495
1153
  if (i.kind === "blocked") continue;
496
1154
  const r = new Set(i.data);
497
1155
  if (i.kind === "dependencies")
498
- for (const a of n.paths) r.has(a.dependency) && Pt(o, t, a, !1);
1156
+ for (const a of s.paths) r.has(a.dependency) && Et(o, t, a, !1);
499
1157
  else
500
- for (const a of n.boxes) r.has(a.subtask) && je(o, t, a, 1);
1158
+ for (const a of s.boxes) r.has(a.subtask) && qe(o, t, a, 1);
501
1159
  }
502
- for (const i of e.overlaps) Nt(o, t, s, i);
503
- for (const i of e.inBlocked) Nt(o, t, s, i);
504
- nn(o, t, s), ln(o, t);
1160
+ for (const i of e.overlaps) Nt(o, t, n, i);
1161
+ for (const i of e.inBlocked) Nt(o, t, n, i);
1162
+ zn(o, t, n), Un(o, t);
505
1163
  }
506
- function Xs(o, t) {
507
- const { view: e, hover: n } = t, s = e.viewport();
1164
+ function En(o, t) {
1165
+ const { view: e, hover: s } = t, n = e.viewport();
508
1166
  if (t.ghost === null) {
509
- if (n.kind === "subtask") {
510
- const u = e.boxById.get(n.subtask.id);
511
- u !== void 0 && rn(o, t, u);
512
- } else if (n.kind === "dependency") {
513
- const u = e.paths.find((p) => p.dependency === n.dependency);
514
- u !== void 0 && Pt(o, t, u, !0);
1167
+ if (s.kind === "subtask") {
1168
+ const c = e.boxById.get(s.subtask.id);
1169
+ c !== void 0 && Vn(o, t, c);
1170
+ } else if (s.kind === "dependency") {
1171
+ const c = e.paths.find((p) => p.dependency === s.dependency);
1172
+ c !== void 0 && Et(o, t, c, !0);
515
1173
  }
516
1174
  return;
517
1175
  }
518
- const i = t.ghost, { ghost: r, overlaps: a, violated: l } = i;
519
- Vs(o, t, s, i.refusedLanes);
520
- const h = Ve(s, r);
1176
+ const i = t.ghost, { ghost: r, overlaps: a, violated: d } = i;
1177
+ Rn(o, t, n, i.refusedLanes);
1178
+ const h = Xe(n, r);
521
1179
  if (h === null) return;
522
- for (const u of a) Nt(o, t, s, u);
523
- const d = new Set(l.map((u) => u.dependency));
524
- for (const u of t.data.dependencies) {
525
- if (u.from !== r.id && u.to !== r.id) continue;
526
- const p = e.boxById.get(u.from === r.id ? u.to : u.from);
1180
+ for (const c of a) Nt(o, t, n, c);
1181
+ const l = new Set(d.map((c) => c.dependency));
1182
+ for (const c of t.data.dependencies) {
1183
+ if (c.from !== r.id && c.to !== r.id) continue;
1184
+ const p = e.boxById.get(c.from === r.id ? c.to : c.from);
527
1185
  if (p === void 0) continue;
528
- const m = u.from === r.id ? Rt(s, u, h, p, e.options) : Rt(s, u, p, h, e.options);
529
- Pt(o, t, m, !0, d.has(u.id));
1186
+ const m = c.from === r.id ? Ot(n, c, h, p, e.options) : Ot(n, c, p, h, e.options);
1187
+ Et(o, t, m, !0, l.has(c.id));
530
1188
  }
531
- je(o, { ...t, selectedTask: null }, h, 0.55), o.strokeStyle = t.colours.text, o.lineWidth = 1, o.setLineDash([3, 2]), o.strokeRect(h.outerFrom + 0.5, h.y + 0.5, Math.max(1, h.outerTo - h.outerFrom - 1), h.height - 1), o.setLineDash([]), i.tether !== null && js(o, t, h, i.tether);
1189
+ qe(o, { ...t, selectedTask: null }, h, 0.55), o.strokeStyle = t.colours.text, o.lineWidth = 1, o.setLineDash([3, 2]), o.strokeRect(h.outerFrom + 0.5, h.y + 0.5, Math.max(1, h.outerTo - h.outerFrom - 1), h.height - 1), o.setLineDash([]), i.tether !== null && Nn(o, t, h, i.tether);
532
1190
  }
533
- function Vs(o, t, e, n) {
534
- if (n.size === 0) return;
535
- const { width: s, height: i } = t.view;
536
- for (const r of n) {
1191
+ function Rn(o, t, e, s) {
1192
+ if (s.size === 0) return;
1193
+ const { width: n, height: i } = t.view;
1194
+ for (const r of s) {
537
1195
  const a = dt(e, r);
538
1196
  if (a === null) continue;
539
- const { top: l, height: h } = a;
540
- l + h < 0 || l > i || (o.globalAlpha = 0.6, o.fillStyle = t.colours.surface, o.fillRect(0, l, s, h), o.globalAlpha = 1, Ze(o, 0, l, s, h, t.colours.muted, 0.7, qe, 1));
541
- }
542
- }
543
- function js(o, t, e, n) {
544
- const s = Math.max(e.outerFrom, Math.min(e.outerTo, n.x)), i = Math.max(e.y, Math.min(e.y + e.height, n.y));
545
- Math.hypot(n.x - s, n.y - i) < 2 || (o.strokeStyle = t.colours.text, o.lineWidth = 1, o.setLineDash([2, 3]), o.beginPath(), o.moveTo(s + 0.5, i + 0.5), o.lineTo(n.x + 0.5, n.y + 0.5), o.stroke(), o.setLineDash([]));
546
- }
547
- function Ve(o, t) {
548
- const e = Kt(o.rows, t.lane);
549
- return e === null ? null : Ye(o, t, t.lane, e, 0);
550
- }
551
- function qs(o, t, e) {
552
- const { view: n, colours: s, bands: i } = t, { width: r, height: a } = n;
553
- o.lineWidth = 1, o.strokeStyle = s.line, o.beginPath();
554
- for (const d of i.ticks)
555
- o.moveTo(d.x + 0.5, 0), o.lineTo(d.x + 0.5, a);
556
- for (const d of e.rows.rows) {
557
- const u = d.top + d.height - e.scrollY - 0.5;
558
- u < 0 || u > a || (o.moveTo(0, u), o.lineTo(r, u));
559
- }
560
- const l = [...e.rows.slots.values()].filter((d) => d.miniature).sort((d, u) => d.top - u.top);
561
- l.forEach((d, u) => {
562
- const p = l[u + 1];
563
- if (p === void 0 || p.top !== d.top + d.height || p.group === d.group) return;
564
- const m = d.top + d.height - e.scrollY - 0.5;
1197
+ const { top: d, height: h } = a;
1198
+ d + h < 0 || d > i || (o.globalAlpha = 0.6, o.fillStyle = t.colours.surface, o.fillRect(0, d, n, h), o.globalAlpha = 1, Je(o, 0, d, n, h, t.colours.muted, 0.7, je, 1));
1199
+ }
1200
+ }
1201
+ function Nn(o, t, e, s) {
1202
+ const n = Math.max(e.outerFrom, Math.min(e.outerTo, s.x)), i = Math.max(e.y, Math.min(e.y + e.height, s.y));
1203
+ Math.hypot(s.x - n, s.y - i) < 2 || (o.strokeStyle = t.colours.text, o.lineWidth = 1, o.setLineDash([2, 3]), o.beginPath(), o.moveTo(n + 0.5, i + 0.5), o.lineTo(s.x + 0.5, s.y + 0.5), o.stroke(), o.setLineDash([]));
1204
+ }
1205
+ function Xe(o, t) {
1206
+ const e = Vt(o.rows, t.lane);
1207
+ return e === null ? null : Ge(o, t, t.lane, e, 0);
1208
+ }
1209
+ function Pn(o, t, e) {
1210
+ const { view: s, colours: n, bands: i } = t, { width: r, height: a } = s;
1211
+ o.lineWidth = 1, o.strokeStyle = n.line, o.beginPath();
1212
+ for (const l of i.ticks)
1213
+ o.moveTo(l.x + 0.5, 0), o.lineTo(l.x + 0.5, a);
1214
+ for (const l of e.rows.rows) {
1215
+ const c = l.top + l.height - e.scrollY - 0.5;
1216
+ c < 0 || c > a || (o.moveTo(0, c), o.lineTo(r, c));
1217
+ }
1218
+ const d = [...e.rows.slots.values()].filter((l) => l.miniature).sort((l, c) => l.top - c.top);
1219
+ d.forEach((l, c) => {
1220
+ const p = d[c + 1];
1221
+ if (p === void 0 || p.top !== l.top + l.height || p.group === l.group) return;
1222
+ const m = l.top + l.height - e.scrollY - 0.5;
565
1223
  m < 0 || m > a || (o.moveTo(0, m), o.lineTo(r, m));
566
- }), o.stroke(), o.strokeStyle = s.lineStrong, o.beginPath();
567
- for (const d of i.days)
568
- o.moveTo(d.x + 0.5, 0), o.lineTo(d.x + 0.5, a);
1224
+ }), o.stroke(), o.strokeStyle = n.lineStrong, o.beginPath();
1225
+ for (const l of i.days)
1226
+ o.moveTo(l.x + 0.5, 0), o.lineTo(l.x + 0.5, a);
569
1227
  o.stroke();
570
- const h = ws(n.options.calendar);
1228
+ const h = us(s.options.calendar);
571
1229
  if (h.length > 0) {
572
- o.strokeStyle = s.muted, o.setLineDash([2, 3]), o.beginPath();
573
- for (const d of h) {
574
- const u = Math.round(e.scale.toPx(d.workingTime)) + 0.5;
575
- u < 0 || u > r || (o.moveTo(u, 0), o.lineTo(u, a));
1230
+ o.strokeStyle = n.muted, o.setLineDash([2, 3]), o.beginPath();
1231
+ for (const l of h) {
1232
+ const c = Math.round(e.scale.toPx(l.workingTime)) + 0.5;
1233
+ c < 0 || c > r || (o.moveTo(c, 0), o.lineTo(c, a));
576
1234
  }
577
1235
  o.stroke(), o.setLineDash([]);
578
1236
  }
579
1237
  }
580
- function Zs(o, t) {
1238
+ function Bn(o, t) {
581
1239
  const e = t.view.nowX();
582
1240
  e !== null && (o.fillStyle = t.colours.now, o.fillRect(e, 0, 2, t.view.height));
583
1241
  }
584
- function Js(o, t, e, n) {
585
- const s = ht(t.colours, t, e.subtask.task, e.subtask.id);
586
- o.fillStyle = s;
1242
+ function xn(o, t, e, s) {
1243
+ const n = ht(t.colours, t, e.subtask.task, e.subtask.id);
1244
+ o.fillStyle = n;
587
1245
  for (const [i, r] of [
588
1246
  [e.outerFrom, e.mainFrom],
589
1247
  [e.mainTo, e.outerTo]
590
1248
  ])
591
- r <= i || (o.globalAlpha = 0.28 * n, o.fillRect(i, e.y, r - i, e.height));
592
- o.globalAlpha = n, o.fillRect(e.mainFrom, e.y, Math.max(1, e.mainTo - e.mainFrom), e.height), o.globalAlpha = 1;
1249
+ r <= i || (o.globalAlpha = 0.28 * s, o.fillRect(i, e.y, r - i, e.height));
1250
+ o.globalAlpha = s, o.fillRect(e.mainFrom, e.y, Math.max(1, e.mainTo - e.mainFrom), e.height), o.globalAlpha = 1;
593
1251
  }
594
- function Vt(o, t, e) {
1252
+ function Wt(o, t, e) {
595
1253
  if (o.dashed) return { fill: null, onDark: !1 };
596
- const n = o.muted ? Qs(t, e.surface, 0.5) : t;
597
- return { fill: n, onDark: Te(n, e.onAccent) > Te(n, e.text) };
1254
+ const s = o.muted ? $n(t, e.surface, 0.5) : t;
1255
+ return { fill: s, onDark: we(s, e.onAccent) > we(s, e.text) };
598
1256
  }
599
- function Qs(o, t, e) {
600
- const n = lt(o), s = lt(t);
601
- if (n === null || s === null) return o;
602
- const i = (r) => Math.round(n[r] + (s[r] - n[r]) * e);
1257
+ function $n(o, t, e) {
1258
+ const s = lt(o), n = lt(t);
1259
+ if (s === null || n === null) return o;
1260
+ const i = (r) => Math.round(s[r] + (n[r] - s[r]) * e);
603
1261
  return `rgb(${i(0)}, ${i(1)}, ${i(2)})`;
604
1262
  }
605
- function Ce(o, t) {
1263
+ function Me(o, t) {
606
1264
  const e = lt(o);
607
1265
  if (e === null || t === 0) return o;
608
- const n = We(e), s = Xe(n), [i, r, a] = n.map((l) => {
609
- const h = l + (s - l) * t, d = h <= 31308e-7 ? h * 12.92 : 1.055 * h ** (1 / 2.4) - 0.055;
610
- return Math.round(Math.min(1, Math.max(0, d)) * 255);
1266
+ const s = We(e), n = Ue(s), [i, r, a] = s.map((d) => {
1267
+ const h = d + (n - d) * t, l = h <= 31308e-7 ? h * 12.92 : 1.055 * h ** (1 / 2.4) - 0.055;
1268
+ return Math.round(Math.min(1, Math.max(0, l)) * 255);
611
1269
  });
612
1270
  return `rgb(${i}, ${r}, ${a})`;
613
1271
  }
614
- function ht(o, t, e, n) {
615
- const s = (e === null ? void 0 : o.tasks.get(e)) ?? o.muted;
616
- return t.selectedTask === null ? s : e !== t.selectedTask ? o.forced ? o.muted : Ce(s, 1) : o.forced || t.selectedSubtask === null || n === null || n === t.selectedSubtask ? s : Ce(s, 0.5);
1272
+ function ht(o, t, e, s) {
1273
+ const n = (e === null ? void 0 : o.tasks.get(e)) ?? o.muted;
1274
+ return t.selectedTask === null ? n : e !== t.selectedTask ? o.forced ? o.muted : Me(n, 1) : o.forced || t.selectedSubtask === null || s === null || s === t.selectedSubtask ? n : Me(n, 0.5);
617
1275
  }
618
- const tn = 2;
619
- function je(o, t, e, n) {
620
- const { view: s, colours: i } = t;
621
- if (!Et(e, s.width, s.height)) return;
1276
+ const Gn = 2;
1277
+ function qe(o, t, e, s) {
1278
+ const { view: n, colours: i } = t;
1279
+ if (!Ft(e, n.width, n.height)) return;
622
1280
  if (e.miniature) {
623
- Js(o, t, e, n);
1281
+ xn(o, t, e, s);
624
1282
  return;
625
1283
  }
626
- const r = kt(e.subtask.appearance), a = ht(i, t, e.subtask.task, e.subtask.id), l = Vt(r, a, i), h = e.y, d = e.height, u = Math.max(1, e.mainTo - e.mainFrom), p = l.onDark ? i.onAccent : i.text;
1284
+ const r = gt(e.subtask.appearance), a = ht(i, t, e.subtask.task, e.subtask.id), d = Wt(r, a, i), h = e.y, l = e.height, c = Math.max(1, e.mainTo - e.mainFrom), p = d.onDark ? i.onAccent : i.text;
627
1285
  o.lineWidth = 1, o.fillStyle = a, o.strokeStyle = a;
628
- for (const [y, C] of [
1286
+ for (const [y, I] of [
629
1287
  [e.outerFrom, e.mainFrom],
630
1288
  [e.mainTo, e.outerTo]
631
1289
  ])
632
- C <= y || (o.globalAlpha = 0.28 * n, o.fillRect(y, h, C - y, d), o.globalAlpha = n, o.strokeRect(y + 0.5, h + 0.5, C - y - 1, d - 1));
633
- l.fill !== null && (o.globalAlpha = n, o.fillStyle = l.fill, o.fillRect(e.mainFrom, h, u, d));
1290
+ I <= y || (o.globalAlpha = 0.28 * s, o.fillRect(y, h, I - y, l), o.globalAlpha = s, o.strokeRect(y + 0.5, h + 0.5, I - y - 1, l - 1));
1291
+ d.fill !== null && (o.globalAlpha = s, o.fillStyle = d.fill, o.fillRect(e.mainFrom, h, c, l));
634
1292
  const m = e.subtask.progress;
635
1293
  if (m !== void 0) {
636
- const y = Math.min(4, Math.max(2, Math.round(d / 6))), C = h + d - y - tn, A = Math.round(u * Math.max(0, Math.min(1, m)));
637
- o.fillStyle = l.fill === null ? a : p, o.globalAlpha = 0.3 * n, o.fillRect(e.mainFrom, C, u, y), o.globalAlpha = n, A > 0 && o.fillRect(e.mainFrom, C, A, y);
1294
+ const y = Math.min(4, Math.max(2, Math.round(l / 6))), I = h + l - y - Gn, A = Math.round(c * Math.max(0, Math.min(1, m)));
1295
+ o.fillStyle = d.fill === null ? a : p, o.globalAlpha = 0.3 * s, o.fillRect(e.mainFrom, I, c, y), o.globalAlpha = s, A > 0 && o.fillRect(e.mainFrom, I, A, y);
638
1296
  }
639
1297
  if (r.hatched) {
640
- const y = Math.max(1, Math.min(He, Math.floor((u - 2 * rt) / 3))), C = u >= 4 * y ? rt : 0, A = d >= 4 * rt ? rt : 0;
641
- o.globalAlpha = n, o.fillStyle = p, o.fillRect(e.mainFrom + C, h + A, y, d - 2 * A), o.fillRect(e.mainTo - C - y, h + A, y, d - 2 * A);
1298
+ const y = Math.max(1, Math.min($e, Math.floor((c - 2 * rt) / 3))), I = c >= 4 * y ? rt : 0, A = l >= 4 * rt ? rt : 0;
1299
+ o.globalAlpha = s, o.fillStyle = p, o.fillRect(e.mainFrom + I, h + A, y, l - 2 * A), o.fillRect(e.mainTo - I - y, h + A, y, l - 2 * A);
642
1300
  }
643
- r.open && sn(o, e, h, d, i.surface, s.width), r.dashed && (o.globalAlpha = n, o.strokeStyle = a, o.setLineDash([4, 3]), o.strokeRect(e.mainFrom + 0.5, h + 0.5, u - 1, d - 1), o.setLineDash([])), o.globalAlpha = 1, e.depth > 0 && n === 1 && (o.strokeStyle = i.surface, o.strokeRect(e.outerFrom - 0.5, h - 0.5, e.outerTo - e.outerFrom + 1, d + 1));
1301
+ r.open && Yn(o, e, h, l, i.surface, n.width), r.dashed && (o.globalAlpha = s, o.strokeStyle = a, o.setLineDash([4, 3]), o.strokeRect(e.mainFrom + 0.5, h + 0.5, c - 1, l - 1), o.setLineDash([])), o.globalAlpha = 1, e.depth > 0 && s === 1 && (o.strokeStyle = i.surface, o.strokeRect(e.outerFrom - 0.5, h - 0.5, e.outerTo - e.outerFrom + 1, l + 1));
644
1302
  }
645
- const qe = 6, en = 16;
646
- function Ze(o, t, e, n, s, i, r, a, l) {
647
- o.save(), o.beginPath(), o.rect(t, e, n, s), o.clip(), o.globalAlpha = 0.5 * r, o.strokeStyle = i, o.lineWidth = l, o.beginPath();
648
- for (let h = t - s; h < t + n + s; h += a)
649
- o.moveTo(h, e + s), o.lineTo(h + s, e);
1303
+ const je = 6, Hn = 16;
1304
+ function Je(o, t, e, s, n, i, r, a, d) {
1305
+ o.save(), o.beginPath(), o.rect(t, e, s, n), o.clip(), o.globalAlpha = 0.5 * r, o.strokeStyle = i, o.lineWidth = d, o.beginPath();
1306
+ for (let h = t - n; h < t + s + n; h += a)
1307
+ o.moveTo(h, e + n), o.lineTo(h + n, e);
650
1308
  o.stroke(), o.restore();
651
1309
  }
652
- function sn(o, t, e, n, s, i) {
653
- const r = t.mainFrom < 0, a = t.mainTo > i, l = Math.max(1, Math.min(t.mainTo, i) - Math.max(t.mainFrom, 0)), h = Math.min(en, l);
654
- r && Se(o, 0, h, e, n, s, 1), a && Se(o, i, -h, e, n, s, 1);
1310
+ function Yn(o, t, e, s, n, i) {
1311
+ const r = t.mainFrom < 0, a = t.mainTo > i, d = Math.max(1, Math.min(t.mainTo, i) - Math.max(t.mainFrom, 0)), h = Math.min(Hn, d);
1312
+ r && Te(o, 0, h, e, s, n, 1), a && Te(o, i, -h, e, s, n, 1);
655
1313
  }
656
- function Se(o, t, e, n, s, i, r) {
1314
+ function Te(o, t, e, s, n, i, r) {
657
1315
  const a = o.createLinearGradient(t, 0, t + e, 0);
658
- a.addColorStop(0, Le(i, r)), a.addColorStop(1, Le(i, 0)), o.globalAlpha = 1, o.fillStyle = a, o.fillRect(Math.min(t, t + e), n, Math.abs(e), s);
1316
+ a.addColorStop(0, Ie(i, r)), a.addColorStop(1, Ie(i, 0)), o.globalAlpha = 1, o.fillStyle = a, o.fillRect(Math.min(t, t + e), s, Math.abs(e), n);
659
1317
  }
660
- function Le(o, t) {
1318
+ function Ie(o, t) {
661
1319
  const e = lt(o);
662
1320
  return e === null ? o : `rgba(${e[0]}, ${e[1]}, ${e[2]}, ${t})`;
663
1321
  }
664
- function Pt(o, t, e, n, s) {
665
- const { data: i, colours: r } = t, a = i.taskOfDependency(e.dependency), l = s ?? i.violatedById.has(e.dependency.id), h = a !== null && a === t.selectedTask, d = l ? r.alarm : ht(r, t, a, null);
666
- if (o.strokeStyle = d, o.fillStyle = d, o.lineWidth = n || h ? 2 : 1.25, o.setLineDash(l ? [4, 3] : []), o.beginPath(), o.moveTo(e.x1, e.y1), e.kind === "curve")
1322
+ function Et(o, t, e, s, n) {
1323
+ const { data: i, colours: r } = t, a = i.taskOfDependency(e.dependency), d = n ?? i.violatedById.has(e.dependency.id), h = a !== null && a === t.selectedTask, l = d ? r.alarm : ht(r, t, a, null);
1324
+ if (o.strokeStyle = l, o.fillStyle = l, o.lineWidth = s || h ? 2 : 1.25, o.setLineDash(d ? [4, 3] : []), o.beginPath(), o.moveTo(e.x1, e.y1), e.kind === "curve")
667
1325
  o.bezierCurveTo(e.c1x, e.y1, e.c2x, e.y2, e.x2, e.y2);
668
1326
  else
669
- for (let u = 2; u + 1 < e.points.length; u += 2) o.lineTo(e.points[u], e.points[u + 1]);
1327
+ for (let c = 2; c + 1 < e.points.length; c += 2) o.lineTo(e.points[c], e.points[c + 1]);
670
1328
  if (o.stroke(), o.setLineDash([]), e.ends === "dot")
671
- for (const [u, p] of [
1329
+ for (const [c, p] of [
672
1330
  [e.x1, e.y1],
673
1331
  [e.x2, e.y2]
674
1332
  ])
675
- o.beginPath(), o.arc(u, p, l ? 3 : 2.5, 0, Math.PI * 2), o.fill();
1333
+ o.beginPath(), o.arc(c, p, d ? 3 : 2.5, 0, Math.PI * 2), o.fill();
676
1334
  }
677
- function nn(o, t, e) {
678
- const { data: n } = t;
679
- if (n.violatedById.size !== 0)
680
- for (const s of n.violatedById.values()) {
681
- const i = n.dependencies.find((u) => u.id === s.dependency), r = i === void 0 ? void 0 : n.subtaskById.get(i.to);
1335
+ function zn(o, t, e) {
1336
+ const { data: s } = t;
1337
+ if (s.violatedById.size !== 0)
1338
+ for (const n of s.violatedById.values()) {
1339
+ const i = s.dependencies.find((c) => c.id === n.dependency), r = i === void 0 ? void 0 : s.subtaskById.get(i.to);
682
1340
  if (r === void 0) continue;
683
1341
  const a = dt(e, r.lane);
684
1342
  if (a === null || !a.miniature) continue;
685
- const l = et(e.rows, a.top + e.scrollY);
686
- if (l === null) continue;
687
- const h = N(e, s.arrival), d = Math.max(h + 2, N(e, s.arrival + s.shortBy));
688
- Bt(o, t, h, d, l.top - e.scrollY + 1, 3);
1343
+ const d = st(e.rows, a.top + e.scrollY);
1344
+ if (d === null) continue;
1345
+ const h = N(e, n.arrival), l = Math.max(h + 2, N(e, n.arrival + n.shortBy));
1346
+ Rt(o, t, h, l, d.top - e.scrollY + 1, 3);
689
1347
  }
690
1348
  }
691
- function Bt(o, t, e, n, s, i) {
1349
+ function Rt(o, t, e, s, n, i) {
692
1350
  if (!t.colours.forced) {
693
- o.fillStyle = t.colours.alarm, o.fillRect(e, s, n - e, i);
1351
+ o.fillStyle = t.colours.alarm, o.fillRect(e, n, s - e, i);
694
1352
  return;
695
1353
  }
696
- o.strokeStyle = t.colours.alarm, o.lineWidth = i, o.setLineDash([4, 3]), o.beginPath(), o.moveTo(e, s + i / 2), o.lineTo(n, s + i / 2), o.stroke(), o.setLineDash([]);
1354
+ o.strokeStyle = t.colours.alarm, o.lineWidth = i, o.setLineDash([4, 3]), o.beginPath(), o.moveTo(e, n + i / 2), o.lineTo(s, n + i / 2), o.stroke(), o.setLineDash([]);
697
1355
  }
698
- function on(o, t, e, n) {
699
- const s = dt(e, n.lane);
700
- if (s === null || s.top + s.height < 0 || s.top > t.view.height) return;
701
- const i = Math.max(0, N(e, n.from)), r = Math.min(t.view.width, N(e, n.to));
702
- r <= i || (o.globalAlpha = 0.1, o.fillStyle = t.colours.muted, o.fillRect(i, s.top, r - i, s.height), o.globalAlpha = 1, Ze(o, i, s.top, r - i, s.height, t.colours.muted, 0.7, qe, 1));
1356
+ function Kn(o, t, e, s) {
1357
+ const n = dt(e, s.lane);
1358
+ if (n === null || n.top + n.height < 0 || n.top > t.view.height) return;
1359
+ const i = Math.max(0, N(e, s.from)), r = Math.min(t.view.width, N(e, s.to));
1360
+ r <= i || (o.globalAlpha = 0.1, o.fillStyle = t.colours.muted, o.fillRect(i, n.top, r - i, n.height), o.globalAlpha = 1, Je(o, i, n.top, r - i, n.height, t.colours.muted, 0.7, je, 1));
703
1361
  }
704
- function Nt(o, t, e, n) {
705
- const s = dt(e, n.lane);
706
- if (s === null) return;
707
- const i = N(e, n.from), r = Math.max(i + 2, N(e, n.to));
708
- if (o.fillStyle = t.colours.alarm, o.globalAlpha = 0.14, o.fillRect(i, s.top + 1, r - i, Math.max(1, s.height - 2)), o.globalAlpha = 1, Bt(o, t, i, r, s.top + 1, Math.min(3, Math.max(1, s.height - 1))), s.miniature) {
709
- const a = et(e.rows, s.top + e.scrollY);
710
- a !== null && Bt(o, t, i, r, a.top - e.scrollY + 1, 3);
1362
+ function Nt(o, t, e, s) {
1363
+ const n = dt(e, s.lane);
1364
+ if (n === null) return;
1365
+ const i = N(e, s.from), r = Math.max(i + 2, N(e, s.to));
1366
+ if (o.fillStyle = t.colours.alarm, o.globalAlpha = 0.14, o.fillRect(i, n.top + 1, r - i, Math.max(1, n.height - 2)), o.globalAlpha = 1, Rt(o, t, i, r, n.top + 1, Math.min(3, Math.max(1, n.height - 1))), n.miniature) {
1367
+ const a = st(e.rows, n.top + e.scrollY);
1368
+ a !== null && Rt(o, t, i, r, a.top - e.scrollY + 1, 3);
711
1369
  }
712
1370
  }
713
- function rn(o, t, e) {
714
- const { colours: n } = t, s = kt(e.subtask.appearance), i = Vt(s, ht(n, t, e.subtask.task, e.subtask.id), n);
715
- if (n.forced) {
716
- o.strokeStyle = n.active, o.lineWidth = 2, o.strokeRect(e.outerFrom - 2, e.y - 2, Math.max(1, e.outerTo - e.outerFrom) + 4, e.height + 4);
1371
+ function Vn(o, t, e) {
1372
+ const { colours: s } = t, n = gt(e.subtask.appearance), i = Wt(n, ht(s, t, e.subtask.task, e.subtask.id), s);
1373
+ if (s.forced) {
1374
+ o.strokeStyle = s.active, o.lineWidth = 2, o.strokeRect(e.outerFrom - 2, e.y - 2, Math.max(1, e.outerTo - e.outerFrom) + 4, e.height + 4);
717
1375
  return;
718
1376
  }
719
- o.globalAlpha = an, o.fillStyle = i.onDark ? n.onAccent : n.text, o.fillRect(e.outerFrom, e.y, Math.max(1, e.outerTo - e.outerFrom), e.height), o.globalAlpha = 1;
1377
+ o.globalAlpha = Wn, o.fillStyle = i.onDark ? s.onAccent : s.text, o.fillRect(e.outerFrom, e.y, Math.max(1, e.outerTo - e.outerFrom), e.height), o.globalAlpha = 1;
720
1378
  }
721
- const an = 0.2;
722
- function ln(o, t) {
1379
+ const Wn = 0.2;
1380
+ function Un(o, t) {
723
1381
  const e = t.selectedTask;
724
1382
  if (e !== null) {
725
1383
  o.strokeStyle = t.colours.text;
726
- for (const n of t.view.boxes) {
727
- if (n.subtask.task !== e) continue;
728
- const s = n.subtask.id === t.selectedSubtask;
729
- o.lineWidth = s ? 2 : 1;
730
- const i = s ? 1 : 0.5;
731
- o.strokeRect(n.outerFrom - i, n.y - i, n.outerTo - n.outerFrom + 2 * i, n.height + 2 * i);
1384
+ for (const s of t.view.boxes) {
1385
+ if (s.subtask.task !== e) continue;
1386
+ const n = s.subtask.id === t.selectedSubtask;
1387
+ o.lineWidth = n ? 2 : 1;
1388
+ const i = n ? 1 : 0.5;
1389
+ o.strokeRect(s.outerFrom - i, s.y - i, s.outerTo - s.outerFrom + 2 * i, s.height + 2 * i);
732
1390
  }
733
1391
  }
734
1392
  }
735
- const pt = 32, dn = 18;
736
- function Ae(o, t) {
737
- if (!(t > 2 * pt)) return 0;
738
- const e = pt - o, n = o - (t - pt), s = Math.max(e, n);
739
- if (s <= 0) return 0;
740
- const i = Math.min(1, s / pt), r = dn * i * i;
1393
+ const ft = 32, Xn = 18;
1394
+ function Se(o, t) {
1395
+ if (!(t > 2 * ft)) return 0;
1396
+ const e = ft - o, s = o - (t - ft), n = Math.max(e, s);
1397
+ if (n <= 0) return 0;
1398
+ const i = Math.min(1, n / ft), r = Xn * i * i;
741
1399
  return e > 0 ? -r : r;
742
1400
  }
743
1401
  function at(o, t, e) {
744
- const n = (s, i) => {
745
- const r = st(s);
746
- return s.lane === i.lane && r.from < i.to && i.from < r.to;
1402
+ const s = (n, i) => {
1403
+ const r = nt(n);
1404
+ return n.lane === i.lane && r.from < i.to && i.from < r.to;
747
1405
  };
748
- return e.some((s) => n(o, s) && !(t !== null && n(t, s)));
1406
+ return e.some((n) => s(o, n) && !(t !== null && s(t, n)));
749
1407
  }
750
- function hn(o, t, e, n) {
751
- const s = /* @__PURE__ */ new Set();
752
- if (n === void 0) return s;
1408
+ function qn(o, t, e, s) {
1409
+ const n = /* @__PURE__ */ new Set();
1410
+ if (s === void 0) return n;
753
1411
  for (const i of o)
754
- i !== e && (n(t, i) || s.add(i));
755
- return s;
756
- }
757
- function cn(o, t) {
758
- const { step: e, offset: n } = typeof t == "number" ? { step: t, offset: 0 } : t;
759
- if (!(e > 0) || !Number.isFinite(o)) return o;
760
- const s = $t(o) + n;
761
- return s + Math.round((o - s) / e) * e;
1412
+ i !== e && (s(t, i) || n.add(i));
1413
+ return n;
762
1414
  }
763
- const De = "\0placing", _e = /* @__PURE__ */ new Set();
764
- function At(o) {
1415
+ const Le = "\0placing", Ae = /* @__PURE__ */ new Set();
1416
+ function _t(o) {
765
1417
  switch (o.kind) {
766
1418
  case "subtask":
767
1419
  return `subtask:${o.subtask.id}:${o.part}`;
@@ -773,8 +1425,8 @@ function At(o) {
773
1425
  return "nothing";
774
1426
  }
775
1427
  }
776
- const Fe = 3, un = 10, fn = 600;
777
- class pn {
1428
+ const Ce = 3, jn = 10, Jn = 600;
1429
+ class Zn {
778
1430
  constructor(t) {
779
1431
  f(this, "gesture", { kind: "none" });
780
1432
  f(this, "touches", /* @__PURE__ */ new Map());
@@ -835,45 +1487,45 @@ class pn {
835
1487
  ghostSummary() {
836
1488
  const t = this.gesture;
837
1489
  if (t.kind !== "edit" && t.kind !== "place") return null;
838
- const e = Ve(this.host.view.viewport(), t.ghost);
1490
+ const e = Xe(this.host.view.viewport(), t.ghost);
839
1491
  if (e === null) return null;
840
- const n = this.ghostFindings(t.ghost, this.ghostHome(t)), s = t.kind === "edit" && (t.mode === "leadIn" || t.mode === "leadOut"), i = s ? st(t.ghost) : t.ghost;
1492
+ const s = this.ghostFindings(t.ghost, this.ghostHome(t)), n = t.kind === "edit" && (t.mode === "leadIn" || t.mode === "leadOut"), i = n ? nt(t.ghost) : t.ghost;
841
1493
  return {
842
1494
  refused: this.refused,
843
1495
  refusedLanes: [...t.refused],
844
1496
  blocked: this.blocked,
845
- x: s ? e.outerFrom : e.mainFrom,
1497
+ x: n ? e.outerFrom : e.mainFrom,
846
1498
  y: e.y,
847
1499
  height: e.height,
848
1500
  from: i.from,
849
1501
  to: i.to,
850
- overlap: n.overlaps.length > 0,
851
- violated: n.violated.length > 0
1502
+ overlap: s.overlaps.length > 0,
1503
+ violated: s.violated.length > 0
852
1504
  };
853
1505
  }
854
1506
  /* ---------------------------------------------------------------- */
855
1507
  /* Pointer */
856
1508
  /* ---------------------------------------------------------------- */
857
1509
  local(t, e) {
858
- var s;
859
- const n = (s = this.host.plotElement()) == null ? void 0 : s.getBoundingClientRect();
860
- return { x: t - ((n == null ? void 0 : n.left) ?? 0), y: e - ((n == null ? void 0 : n.top) ?? 0) };
1510
+ var n;
1511
+ const s = (n = this.host.plotElement()) == null ? void 0 : n.getBoundingClientRect();
1512
+ return { x: t - ((s == null ? void 0 : s.left) ?? 0), y: e - ((s == null ? void 0 : s.top) ?? 0) };
861
1513
  }
862
- report(t, e, n, s, i, r) {
863
- var l, h;
1514
+ report(t, e, s, n, i, r) {
1515
+ var d, h;
864
1516
  const a = this.host.view;
865
- (h = (l = this.host.handlers()).onInteraction) == null || h.call(l, { type: t, hit: e, clientX: n, clientY: s, time: a.timeAt(i), lane: a.laneIdAt(r) });
1517
+ (h = (d = this.host.handlers()).onInteraction) == null || h.call(d, { type: t, hit: e, clientX: s, clientY: n, time: a.timeAt(i), lane: a.laneIdAt(r) });
866
1518
  }
867
1519
  pointerDown(t) {
868
- var a, l, h, d, u;
869
- const { x: e, y: n } = this.local(t.clientX, t.clientY);
870
- if (t.pointerType === "touch" && (this.touches.set(t.pointerId, { x: e, y: n }), this.touches.size >= 2)) {
1520
+ var a, d, h, l, c;
1521
+ const { x: e, y: s } = this.local(t.clientX, t.clientY);
1522
+ if (t.pointerType === "touch" && (this.touches.set(t.pointerId, { x: e, y: s }), this.touches.size >= 2)) {
871
1523
  this.gesture.kind !== "pinch" && (this.cancelEdit(), this.gesture = { kind: "pinch", distance: this.touchDistance() });
872
1524
  return;
873
1525
  }
874
1526
  if (t.button !== 0) return;
875
- const s = (h = (l = (a = t.target) == null ? void 0 : a.closest) == null ? void 0 : l.call(a, "[data-grip]")) == null ? void 0 : h.getAttribute("data-grip"), i = this.host.selectedSubtask(), r = i !== null ? this.host.data.subtaskById.get(i) ?? null : null;
876
- t.pointerType === "touch" ? this.gesture = { kind: "pending", pointerId: t.pointerId, x0: e, y0: n, mode: "pan", subtask: null } : (s === "leadIn" || s === "leadOut") && r !== null ? this.gesture = { kind: "pending", pointerId: t.pointerId, x0: e, y0: n, mode: s, subtask: r } : this.gesture = { kind: "pending", pointerId: t.pointerId, x0: e, y0: n, ...this.modeAt(e, n) }, (u = (d = this.host.plotElement()) == null ? void 0 : d.setPointerCapture) == null || u.call(d, t.pointerId);
1527
+ const n = (h = (d = (a = t.target) == null ? void 0 : a.closest) == null ? void 0 : d.call(a, "[data-grip]")) == null ? void 0 : h.getAttribute("data-grip"), i = this.host.selectedSubtask(), r = i !== null ? this.host.data.subtaskById.get(i) ?? null : null;
1528
+ t.pointerType === "touch" ? this.gesture = { kind: "pending", pointerId: t.pointerId, x0: e, y0: s, mode: "pan", subtask: null } : (n === "leadIn" || n === "leadOut") && r !== null ? this.gesture = { kind: "pending", pointerId: t.pointerId, x0: e, y0: s, mode: n, subtask: r } : this.gesture = { kind: "pending", pointerId: t.pointerId, x0: e, y0: s, ...this.modeAt(e, s) }, (c = (l = this.host.plotElement()) == null ? void 0 : l.setPointerCapture) == null || c.call(l, t.pointerId);
877
1529
  }
878
1530
  /** A drag over a folded group: resting on one opens it for the GESTURE.
879
1531
 
@@ -883,13 +1535,13 @@ class pn {
883
1535
  never written to and no change is reported, because the application did
884
1536
  not fold anything (ADR-0025). */
885
1537
  restOver(t) {
886
- var s;
887
- const e = this.host.view, n = e.foldedGroupAt(t);
888
- n !== ((s = this.resting) == null ? void 0 : s.group) && (this.stopResting(), n !== null && (this.resting = {
889
- group: n,
1538
+ var n;
1539
+ const e = this.host.view, s = e.foldedGroupAt(t);
1540
+ s !== ((n = this.resting) == null ? void 0 : n.group) && (this.stopResting(), s !== null && (this.resting = {
1541
+ group: s,
890
1542
  timer: setTimeout(() => {
891
- this.resting = null, e.openForGesture = /* @__PURE__ */ new Set([...e.openForGesture, n]), this.host.viewChanged();
892
- }, fn)
1543
+ this.resting = null, e.openForGesture = /* @__PURE__ */ new Set([...e.openForGesture, s]), this.host.viewChanged();
1544
+ }, Jn)
893
1545
  }));
894
1546
  }
895
1547
  stopResting() {
@@ -911,69 +1563,69 @@ class pn {
911
1563
  lane is open. Asked at a drop, where the answer has to be current; while
912
1564
  a drag runs, the held set answers instead. */
913
1565
  allowed(t, e) {
914
- var n, s;
915
- return ((s = (n = this.host.handlers()).canMoveTo) == null ? void 0 : s.call(n, t, e)) ?? !0;
1566
+ var s, n;
1567
+ return ((n = (s = this.host.handlers()).canMoveTo) == null ? void 0 : n.call(s, t, e)) ?? !0;
916
1568
  }
917
1569
  /** The lanes this work may not go to, for the gesture that is beginning. A
918
1570
  gesture that cannot change a lane at all asks nothing: the intents the
919
1571
  caller handles decide whether the question exists. */
920
1572
  askRefused(t, e) {
921
- if (!this.host.view.options.intents.includes(e === null ? "place" : "lane")) return _e;
922
- const n = this.host.data.lanes.map((s) => s.id);
923
- return hn(n, t, e, this.host.handlers().canMoveTo);
1573
+ if (!this.host.view.options.intents.includes(e === null ? "place" : "lane")) return Ae;
1574
+ const s = this.host.data.lanes.map((n) => n.id);
1575
+ return qn(s, t, e, this.host.handlers().canMoveTo);
924
1576
  }
925
1577
  /** What a press at a point would start, given the intents the caller handles. */
926
1578
  modeAt(t, e) {
927
- const n = this.host.view, s = n.options.intents;
928
- for (let i = n.boxes.length - 1; i >= 0; i--) {
929
- const r = n.boxes[i];
930
- if (s.includes("stretch")) {
931
- const a = Ps(r, t, e);
1579
+ const s = this.host.view, n = s.options.intents;
1580
+ for (let i = s.boxes.length - 1; i >= 0; i--) {
1581
+ const r = s.boxes[i];
1582
+ if (n.includes("stretch")) {
1583
+ const a = Ds(r, t, e);
932
1584
  if (a !== null) return { mode: a === "from" ? "stretch-from" : "stretch-to", subtask: r.subtask };
933
1585
  }
934
- if (Ke(r, t, e) !== null)
935
- return s.includes("move") || s.includes("lane") ? { mode: "move", subtask: r.subtask } : { mode: "pan", subtask: r.subtask };
1586
+ if (He(r, t, e) !== null)
1587
+ return n.includes("move") || n.includes("lane") ? { mode: "move", subtask: r.subtask } : { mode: "pan", subtask: r.subtask };
936
1588
  }
937
1589
  return { mode: "pan", subtask: null };
938
1590
  }
939
1591
  pointerMove(t) {
940
- const { x: e, y: n } = this.local(t.clientX, t.clientY);
941
- if (t.pointerType === "touch" && this.touches.has(t.pointerId) && (this.touches.set(t.pointerId, { x: e, y: n }), this.gesture.kind === "pinch")) {
1592
+ const { x: e, y: s } = this.local(t.clientX, t.clientY);
1593
+ if (t.pointerType === "touch" && this.touches.has(t.pointerId) && (this.touches.set(t.pointerId, { x: e, y: s }), this.gesture.kind === "pinch")) {
942
1594
  const r = this.touchDistance();
943
1595
  r > 0 && this.gesture.distance > 0 && this.host.view.zoomAt(this.touchCentre(), this.gesture.distance / r) && this.host.viewMoved(!0), this.gesture = { kind: "pinch", distance: r };
944
1596
  return;
945
1597
  }
946
- const s = this.gesture;
947
- if (s.kind === "pending" && s.pointerId === t.pointerId) {
948
- if (Math.hypot(e - s.x0, n - s.y0) < (t.pointerType === "touch" ? un : Fe)) return;
949
- if (s.mode === "pan" || s.subtask === null)
950
- this.gesture = { kind: "pan", pointerId: s.pointerId, lastX: s.x0, lastY: s.y0 }, this.setCursor("grabbing");
1598
+ const n = this.gesture;
1599
+ if (n.kind === "pending" && n.pointerId === t.pointerId) {
1600
+ if (Math.hypot(e - n.x0, s - n.y0) < (t.pointerType === "touch" ? jn : Ce)) return;
1601
+ if (n.mode === "pan" || n.subtask === null)
1602
+ this.gesture = { kind: "pan", pointerId: n.pointerId, lastX: n.x0, lastY: n.y0 }, this.setCursor("grabbing");
951
1603
  else {
952
- const r = this.host.view.viewport().scale.fromPx(s.x0);
1604
+ const r = this.host.view.viewport().scale.fromPx(n.x0);
953
1605
  this.gesture = {
954
1606
  kind: "edit",
955
- pointerId: s.pointerId,
956
- mode: s.mode,
957
- subtask: s.subtask,
1607
+ pointerId: n.pointerId,
1608
+ mode: n.mode,
1609
+ subtask: n.subtask,
958
1610
  t0: r,
959
- ghost: s.subtask,
1611
+ ghost: n.subtask,
960
1612
  /* Asked here, once, and drawn from the first frame of the drag: the
961
1613
  lanes that are closed are marked before the pointer reaches one. */
962
- refused: s.mode === "move" ? this.askRefused(s.subtask, s.subtask.lane) : _e
963
- }, this.setCursor(s.mode === "move" ? "grabbing" : "ew-resize");
1614
+ refused: n.mode === "move" ? this.askRefused(n.subtask, n.subtask.lane) : Ae
1615
+ }, this.setCursor(n.mode === "move" ? "grabbing" : "ew-resize");
964
1616
  }
965
1617
  }
966
1618
  const i = this.gesture;
967
1619
  if (i.kind === "pan" && i.pointerId === t.pointerId) {
968
- const r = this.host.view.pan(i.lastX - e, i.lastY - n);
969
- r.moved && this.host.viewMoved(r.time), this.gesture = { ...i, lastX: e, lastY: n };
1620
+ const r = this.host.view.pan(i.lastX - e, i.lastY - s);
1621
+ r.moved && this.host.viewMoved(r.time), this.gesture = { ...i, lastX: e, lastY: s };
970
1622
  return;
971
1623
  }
972
1624
  if (i.kind === "edit" && i.pointerId === t.pointerId) {
973
- this.lastClient = { x: t.clientX, y: t.clientY }, this.dragPoint = { x: e, y: n }, this.restOver(n), this.gesture = { ...i, ghost: this.heldGhost(i, e, n) }, this.setCursor(this.refused || this.blocked ? "not-allowed" : i.mode === "move" ? "grabbing" : "ew-resize"), this.host.interactionChanged(), this.autoPan();
1625
+ this.lastClient = { x: t.clientX, y: t.clientY }, this.dragPoint = { x: e, y: s }, this.restOver(s), this.gesture = { ...i, ghost: this.heldGhost(i, e, s) }, this.setCursor(this.refused || this.blocked ? "not-allowed" : i.mode === "move" ? "grabbing" : "ew-resize"), this.host.interactionChanged(), this.autoPan();
974
1626
  return;
975
1627
  }
976
- i.kind === "none" && (this.byKeyboard = !1, this.hoverAt(t.clientX, t.clientY, e, n));
1628
+ i.kind === "none" && (this.byKeyboard = !1, this.hoverAt(t.clientX, t.clientY, e, s));
977
1629
  }
978
1630
  pointerUp(t) {
979
1631
  var i, r;
@@ -982,18 +1634,18 @@ class pn {
982
1634
  this.touches.size === 1 && a !== void 0 ? this.gesture = { kind: "pan", pointerId: a[0], lastX: a[1].x, lastY: a[1].y } : this.touches.size === 0 && (this.gesture = { kind: "none" });
983
1635
  return;
984
1636
  }
985
- const e = this.gesture, { x: n, y: s } = this.local(t.clientX, t.clientY);
1637
+ const e = this.gesture, { x: s, y: n } = this.local(t.clientX, t.clientY);
986
1638
  if (e.kind === "pending" && e.pointerId === t.pointerId)
987
- this.gesture = { kind: "none" }, this.click(t.clientX, t.clientY, n, s);
1639
+ this.gesture = { kind: "none" }, this.click(t.clientX, t.clientY, s, n);
988
1640
  else if (e.kind === "pan" && e.pointerId === t.pointerId)
989
- this.gesture = { kind: "none" }, this.setCursor("default"), this.hoverAt(t.clientX, t.clientY, n, s);
1641
+ this.gesture = { kind: "none" }, this.setCursor("default"), this.hoverAt(t.clientX, t.clientY, s, n);
990
1642
  else if (e.kind === "edit" && e.pointerId === t.pointerId) {
991
1643
  this.stopAutoPan(), this.closeGestureFolds(), this.gesture = { kind: "none" };
992
- const a = e.ghost.lane === e.subtask.lane || this.allowed(e.subtask, e.ghost.lane), l = this.intentsOf(e.subtask, e.ghost, e.mode).filter(
1644
+ const a = e.ghost.lane === e.subtask.lane || this.allowed(e.subtask, e.ghost.lane), d = this.intentsOf(e.subtask, e.ghost, e.mode).filter(
993
1645
  (h) => a || h.kind !== "lane"
994
1646
  );
995
1647
  this.refused = !1, this.blocked = !1, this.cursor = "default", this.host.interactionChanged();
996
- for (const h of l) (r = (i = this.host.handlers()).onIntent) == null || r.call(i, h);
1648
+ for (const h of d) (r = (i = this.host.handlers()).onIntent) == null || r.call(i, h);
997
1649
  }
998
1650
  }
999
1651
  /** While a drag is in flight near an edge, pans along once per frame and
@@ -1005,17 +1657,17 @@ class pn {
1005
1657
  this.panFrame = 0;
1006
1658
  const e = this.gesture;
1007
1659
  if (e.kind !== "edit" && e.kind !== "place") return;
1008
- const n = this.host.view, { x: s, y: i } = this.local(this.lastClient.x, this.lastClient.y), r = Ae(s, n.width), a = Ae(i, n.height);
1660
+ const s = this.host.view, { x: n, y: i } = this.local(this.lastClient.x, this.lastClient.y), r = Se(n, s.width), a = Se(i, s.height);
1009
1661
  if (r === 0 && a === 0) return;
1010
- const l = n.pan(r, a);
1011
- if (l.moved) {
1012
- if (this.dragPoint = { x: s, y: i }, e.kind === "edit")
1013
- this.gesture = { ...e, ghost: this.heldGhost(e, s, i) };
1662
+ const d = s.pan(r, a);
1663
+ if (d.moved) {
1664
+ if (this.dragPoint = { x: n, y: i }, e.kind === "edit")
1665
+ this.gesture = { ...e, ghost: this.heldGhost(e, n, i) };
1014
1666
  else {
1015
- const h = this.placeGhost(e.item, s, i, e.refused);
1667
+ const h = this.placeGhost(e.item, n, i, e.refused);
1016
1668
  this.refused = h.refused, this.blocked = h.blocked, this.gesture = { ...e, ghost: h.ghost ?? e.ghost };
1017
1669
  }
1018
- this.host.viewMoved(l.time), this.panFrame = requestAnimationFrame(t);
1670
+ this.host.viewMoved(d.time), this.panFrame = requestAnimationFrame(t);
1019
1671
  }
1020
1672
  };
1021
1673
  this.panFrame = requestAnimationFrame(t);
@@ -1032,8 +1684,8 @@ class pn {
1032
1684
  times would be a lie. Nothing is reported: no interaction happened. */
1033
1685
  refreshHover() {
1034
1686
  if (!this.idle || this.hoverKey === "nothing" || this.byKeyboard) return;
1035
- const { x: t, y: e } = this.hoverPoint, n = this.host.view.hitAt(t, e);
1036
- this.hover = n, this.hoverKey = At(n);
1687
+ const { x: t, y: e } = this.hoverPoint, s = this.host.view.hitAt(t, e);
1688
+ this.hover = s, this.hoverKey = _t(s);
1037
1689
  }
1038
1690
  pointerLeave() {
1039
1691
  this.gesture.kind !== "none" || this.byKeyboard || this.setHover({ kind: "nothing" }, "nothing");
@@ -1046,19 +1698,19 @@ class pn {
1046
1698
  contextMenu(t) {
1047
1699
  if (this.host.handlers().onInteraction === void 0) return;
1048
1700
  t.preventDefault();
1049
- const { x: e, y: n } = this.local(t.clientX, t.clientY);
1050
- this.report("contextmenu", this.host.view.hitAt(e, n), t.clientX, t.clientY, e, n);
1701
+ const { x: e, y: s } = this.local(t.clientX, t.clientY);
1702
+ this.report("contextmenu", this.host.view.hitAt(e, s), t.clientX, t.clientY, e, s);
1051
1703
  }
1052
1704
  /** The wheel, as every scrolling area has it (schedule-refinement 02):
1053
1705
  vertical scrolls the lanes, and lets the page scroll on once they are at
1054
1706
  their end; Ctrl or ⌘ zooms - a trackpad pinch arrives as a wheel with
1055
1707
  Ctrl -; horizontal or Shift pans through time. */
1056
1708
  wheel(t) {
1057
- const e = this.host.view, n = Math.max(0, Math.min(e.width, this.local(t.clientX, t.clientY).x)), s = t.deltaMode === 1 ? 16 : t.deltaMode === 2 ? e.height : 1, i = t.deltaX * s, r = t.deltaY * s;
1709
+ const e = this.host.view, s = Math.max(0, Math.min(e.width, this.local(t.clientX, t.clientY).x)), n = t.deltaMode === 1 ? 16 : t.deltaMode === 2 ? e.height : 1, i = t.deltaX * n, r = t.deltaY * n;
1058
1710
  if (t.ctrlKey || t.metaKey) {
1059
1711
  t.preventDefault();
1060
1712
  const h = Math.abs(r) < 50 ? 0.01 : 15e-4;
1061
- e.zoomAt(n, Math.exp(r * h)) && this.host.viewMoved(!0);
1713
+ e.zoomAt(s, Math.exp(r * h)) && this.host.viewMoved(!0);
1062
1714
  return;
1063
1715
  }
1064
1716
  if (Math.abs(i) > Math.abs(r) || t.shiftKey) {
@@ -1070,26 +1722,26 @@ class pn {
1070
1722
  const a = r > 0 ? e.maxScroll() - e.scrollY : e.scrollY;
1071
1723
  if (r === 0 || a <= 0) return;
1072
1724
  t.preventDefault();
1073
- const l = e.pan(0, r);
1074
- l.moved && this.host.viewMoved(l.time);
1725
+ const d = e.pan(0, r);
1726
+ d.moved && this.host.viewMoved(d.time);
1075
1727
  }
1076
- click(t, e, n, s) {
1077
- const i = this.host.view.hitAt(n, s), r = i.kind === "subtask" ? i.subtask.task : i.kind === "dependency" ? this.host.data.taskOfDependency(i.dependency) : null;
1078
- this.host.select(r, i.kind === "subtask" ? i.subtask.id : null), this.report("click", i, t, e, n, s);
1728
+ click(t, e, s, n) {
1729
+ const i = this.host.view.hitAt(s, n), r = i.kind === "subtask" ? i.subtask.task : i.kind === "dependency" ? this.host.data.taskOfDependency(i.dependency) : null;
1730
+ this.host.select(r, i.kind === "subtask" ? i.subtask.id : null), this.report("click", i, t, e, s, n);
1079
1731
  }
1080
- hoverAt(t, e, n, s) {
1081
- const i = this.host.view.hitAt(n, s), r = At(i), { mode: a } = this.modeAt(n, s);
1082
- if (this.setCursor(a === "move" ? "grab" : a === "stretch-from" || a === "stretch-to" ? "ew-resize" : "default"), this.hoverPoint = { x: n, y: s }, r === this.hoverKey) {
1732
+ hoverAt(t, e, s, n) {
1733
+ const i = this.host.view.hitAt(s, n), r = _t(i), { mode: a } = this.modeAt(s, n);
1734
+ if (this.setCursor(a === "move" ? "grab" : a === "stretch-from" || a === "stretch-to" ? "ew-resize" : "default"), this.hoverPoint = { x: s, y: n }, r === this.hoverKey) {
1083
1735
  (i.kind === "subtask" || i.kind === "dependency") && this.host.interactionChanged();
1084
1736
  return;
1085
1737
  }
1086
- this.setHover(i, r), this.report("hover", i, t, e, n, s);
1738
+ this.setHover(i, r), this.report("hover", i, t, e, s, n);
1087
1739
  }
1088
1740
  /** The keyboard sets the hover: drawn, and its tooltip shown, as the
1089
1741
  pointer's would be - and reported to nobody, since `onInteraction`
1090
1742
  speaks of pointer positions. `nothing` hands the hover back. */
1091
1743
  setKeyboardHover(t, e) {
1092
- this.byKeyboard = t.kind !== "nothing", this.hoverPoint = e, this.hover = t, this.hoverKey = At(t), this.host.interactionChanged();
1744
+ this.byKeyboard = t.kind !== "nothing", this.hoverPoint = e, this.hover = t, this.hoverKey = _t(t), this.host.interactionChanged();
1093
1745
  }
1094
1746
  setHover(t, e) {
1095
1747
  e !== this.hoverKey && (this.hoverKey = e, this.hover = t, this.host.interactionChanged());
@@ -1112,10 +1764,10 @@ class pn {
1112
1764
  dragging and handles the place intent, the drop is accepted and a ghost
1113
1765
  shows where the work would land. */
1114
1766
  dragOver(t, e) {
1115
- const n = this.host.view;
1116
- if (e === null || !n.options.intents.includes("place")) return;
1117
- const { x: s, y: i } = this.local(t.clientX, t.clientY);
1118
- if (n.laneIdAt(i) === null && n.foldedGroupAt(i) === null) {
1767
+ const s = this.host.view;
1768
+ if (e === null || !s.options.intents.includes("place")) return;
1769
+ const { x: n, y: i } = this.local(t.clientX, t.clientY);
1770
+ if (s.laneIdAt(i) === null && s.foldedGroupAt(i) === null) {
1119
1771
  this.clearPlacing();
1120
1772
  return;
1121
1773
  }
@@ -1125,34 +1777,34 @@ class pn {
1125
1777
  pointer is not over one either, the rule is asked about an item
1126
1778
  whose own lane is empty - which is the truth of it: `canMoveTo`
1127
1779
  is asked ABOUT a lane, and the one this item is on is none. */
1128
- this.askRefused(this.askedFor(e, this.onLane(i) ?? "", s), null)
1129
- ), a = this.placeGhost(e, s, i, r);
1780
+ this.askRefused(this.askedFor(e, this.onLane(i) ?? "", n), null)
1781
+ ), a = this.placeGhost(e, n, i, r);
1130
1782
  this.refused = a.refused, this.blocked = a.blocked, this.setCursor(a.refused || a.blocked ? "not-allowed" : "default");
1131
- const l = this.gesture.kind === "place" ? this.gesture.ghost : null, h = a.ghost ?? (a.refused || a.blocked ? l : null);
1132
- t.dataTransfer !== null && (t.dataTransfer.dropEffect = h === null ? "none" : "copy"), h !== null && (this.lastClient = { x: t.clientX, y: t.clientY }, this.dragPoint = { x: s, y: i }, this.gesture = { kind: "place", ghost: h, item: e, refused: r }, this.host.interactionChanged(), this.autoPan());
1783
+ const d = this.gesture.kind === "place" ? this.gesture.ghost : null, h = a.ghost ?? (a.refused || a.blocked ? d : null);
1784
+ t.dataTransfer !== null && (t.dataTransfer.dropEffect = h === null ? "none" : "copy"), h !== null && (this.lastClient = { x: t.clientX, y: t.clientY }, this.dragPoint = { x: n, y: i }, this.gesture = { kind: "place", ghost: h, item: e, refused: r }, this.host.interactionChanged(), this.autoPan());
1133
1785
  }
1134
1786
  /** The ghost of a drag from outside at a point on the plot: none off the
1135
1787
  lanes, none where the caller refuses that lane and none where it would
1136
1788
  cover blocked time - which the answer says apart, because they mean
1137
1789
  different things to the drag. */
1138
- placeGhost(t, e, n, s) {
1139
- const i = this.onLane(n);
1790
+ placeGhost(t, e, s, n) {
1791
+ const i = this.onLane(s);
1140
1792
  if (i === null) return { ghost: null, refused: !1, blocked: !1 };
1141
- if (s.has(i)) return { ghost: null, refused: !0, blocked: !1 };
1142
- const r = { ...this.askedFor(t, i, e), id: De };
1793
+ if (n.has(i)) return { ghost: null, refused: !0, blocked: !1 };
1794
+ const r = { ...this.askedFor(t, i, e), id: Le };
1143
1795
  return at(r, null, this.host.data.blocked) ? { ghost: null, refused: !1, blocked: !0 } : { ghost: r, refused: !1, blocked: !1 };
1144
1796
  }
1145
1797
  /** The dragged item as a subtask, under the caller's key for it - not the
1146
1798
  internal sentinel: the rule is asked about the thing the application says
1147
1799
  it is dragging, and the ghost only afterwards takes the sentinel. */
1148
- askedFor(t, e, n) {
1149
- const s = this.snapInside(this.host.view.timeAt(n), this.snapStep());
1800
+ askedFor(t, e, s) {
1801
+ const n = this.snapInside(this.host.view.timeAt(s), this.snapStep());
1150
1802
  return {
1151
1803
  id: t.item,
1152
1804
  task: t.task,
1153
1805
  lane: e,
1154
- from: s,
1155
- to: s + t.duration,
1806
+ from: n,
1807
+ to: n + t.duration,
1156
1808
  ...t.leadIn === void 0 ? {} : { leadIn: t.leadIn },
1157
1809
  ...t.leadOut === void 0 ? {} : { leadOut: t.leadOut }
1158
1810
  };
@@ -1164,17 +1816,17 @@ class pn {
1164
1816
  const e = this.gesture;
1165
1817
  if (e.kind !== "place") return;
1166
1818
  t.preventDefault();
1167
- const { ghost: n, item: s } = e;
1168
- if (this.stopAutoPan(), this.closeGestureFolds(), this.gesture = { kind: "none" }, this.refused = !1, this.blocked = !1, this.cursor = "default", this.host.interactionChanged(), !this.allowed({ ...n, id: s.item }, n.lane)) return;
1819
+ const { ghost: s, item: n } = e;
1820
+ if (this.stopAutoPan(), this.closeGestureFolds(), this.gesture = { kind: "none" }, this.refused = !1, this.blocked = !1, this.cursor = "default", this.host.interactionChanged(), !this.allowed({ ...s, id: n.item }, s.lane)) return;
1169
1821
  const i = {
1170
1822
  kind: "place",
1171
- item: s.item,
1172
- task: n.task,
1173
- lane: n.lane,
1174
- from: n.from,
1175
- to: n.to,
1176
- ...n.leadIn === void 0 ? {} : { leadIn: n.leadIn },
1177
- ...n.leadOut === void 0 ? {} : { leadOut: n.leadOut }
1823
+ item: n.item,
1824
+ task: s.task,
1825
+ lane: s.lane,
1826
+ from: s.from,
1827
+ to: s.to,
1828
+ ...s.leadIn === void 0 ? {} : { leadIn: s.leadIn },
1829
+ ...s.leadOut === void 0 ? {} : { leadOut: s.leadOut }
1178
1830
  };
1179
1831
  (a = (r = this.host.handlers()).onIntent) == null || a.call(r, i);
1180
1832
  }
@@ -1196,52 +1848,52 @@ class pn {
1196
1848
  put the work into blocked time it did not already cover, the ghost where
1197
1849
  it last stood. It is held, not clamped: a pointer carried on past the
1198
1850
  blocked time takes the ghost along again. */
1199
- heldGhost(t, e, n) {
1200
- const s = this.ghostFor(t, e, n);
1201
- return this.blocked = at(s, t.subtask, this.host.data.blocked), this.blocked ? t.ghost : s;
1851
+ heldGhost(t, e, s) {
1852
+ const n = this.ghostFor(t, e, s);
1853
+ return this.blocked = at(n, t.subtask, this.host.data.blocked), this.blocked ? t.ghost : n;
1202
1854
  }
1203
- ghostFor(t, e, n) {
1204
- const s = this.host.view, i = t.subtask, r = this.snapStep(), a = s.options.intents, l = this.snapInside(s.timeAt(e), r);
1855
+ ghostFor(t, e, s) {
1856
+ const n = this.host.view, i = t.subtask, r = this.snapStep(), a = n.options.intents, d = this.snapInside(n.timeAt(e), r);
1205
1857
  switch (t.mode) {
1206
1858
  case "move": {
1207
1859
  let h = i.from;
1208
- const d = s.viewport().scale, u = d.fromPx(e) - t.t0;
1209
- a.includes("move") && Math.abs(u * d.m) >= Fe && (h = this.shifted(i.from, u, r));
1860
+ const l = n.viewport().scale, c = l.fromPx(e) - t.t0;
1861
+ a.includes("move") && Math.abs(c * l.m) >= Ce && (h = this.shifted(i.from, c, r));
1210
1862
  let p = t.ghost.lane;
1211
1863
  if (a.includes("lane")) {
1212
- const m = this.onLane(n) ?? p;
1864
+ const m = this.onLane(s) ?? p;
1213
1865
  this.refused = t.refused.has(m), this.refused || (p = m);
1214
1866
  } else
1215
1867
  this.refused = !1;
1216
1868
  return { ...i, from: h, to: h + (i.to - i.from), lane: p };
1217
1869
  }
1218
1870
  case "stretch-from":
1219
- return { ...i, from: Math.min(l, i.to - Math.max(r.step, V)) };
1871
+ return { ...i, from: Math.min(d, i.to - Math.max(r.step, q)) };
1220
1872
  case "stretch-to":
1221
- return { ...i, to: Math.max(l, i.from + Math.max(r.step, V)) };
1873
+ return { ...i, to: Math.max(d, i.from + Math.max(r.step, q)) };
1222
1874
  case "leadIn":
1223
- return { ...i, leadIn: Math.max(0, i.from - l) };
1875
+ return { ...i, leadIn: Math.max(0, i.from - d) };
1224
1876
  case "leadOut":
1225
- return { ...i, leadOut: Math.max(0, l - i.to) };
1877
+ return { ...i, leadOut: Math.max(0, d - i.to) };
1226
1878
  }
1227
1879
  }
1228
1880
  /** A time moved by an amount of WORKING time and snapped: a drag moves
1229
1881
  a start this way, and a key by one step of the raster - one arithmetic,
1230
1882
  so a key proposes exactly what a drag of that length would. */
1231
- shifted(t, e, n) {
1232
- const s = tt(this.host.view.options.calendar), i = U(t, s) + e, r = s.intervals.length === 0 ? i : j(Math.max(0, Math.min(s.total, i)), s);
1233
- return this.snapInside(r, n);
1883
+ shifted(t, e, s) {
1884
+ const n = et(this.host.view.options.calendar), i = H(t, n) + e, r = n.intervals.length === 0 ? i : j(Math.max(0, Math.min(n.total, i)), n);
1885
+ return this.snapInside(r, s);
1234
1886
  }
1235
1887
  /** Snapped - and, where the raster lands in time the calendar removes, moved
1236
1888
  on to the seam, where time counts again. An intent never asks for a time
1237
1889
  nobody works. */
1238
1890
  snapInside(t, e) {
1239
- const n = cn(t, e), s = tt(this.host.view.options.calendar);
1240
- return s.intervals.length === 0 ? n : j(U(n, s), s);
1891
+ const s = ws(t, e), n = et(this.host.view.options.calendar);
1892
+ return n.intervals.length === 0 ? s : j(H(s, n), n);
1241
1893
  }
1242
- intentsOf(t, e, n) {
1243
- const s = [], i = this.host.view.options.intents, r = t.id;
1244
- return n === "move" ? (e.from !== t.from && i.includes("move") && s.push({ kind: "move", subtask: r, from: e.from, to: e.to }), e.lane !== t.lane && i.includes("lane") && s.push({ kind: "lane", subtask: r, lane: e.lane })) : n === "stretch-from" || n === "stretch-to" ? (e.from !== t.from || e.to !== t.to) && s.push({ kind: "stretch", subtask: r, from: e.from, to: e.to }) : n === "leadIn" ? (e.leadIn ?? 0) !== (t.leadIn ?? 0) && s.push({ kind: "leadIn", subtask: r, leadIn: e.leadIn ?? 0 }) : (e.leadOut ?? 0) !== (t.leadOut ?? 0) && s.push({ kind: "leadOut", subtask: r, leadOut: e.leadOut ?? 0 }), s;
1894
+ intentsOf(t, e, s) {
1895
+ const n = [], i = this.host.view.options.intents, r = t.id;
1896
+ return s === "move" ? (e.from !== t.from && i.includes("move") && n.push({ kind: "move", subtask: r, from: e.from, to: e.to }), e.lane !== t.lane && i.includes("lane") && n.push({ kind: "lane", subtask: r, lane: e.lane })) : s === "stretch-from" || s === "stretch-to" ? (e.from !== t.from || e.to !== t.to) && n.push({ kind: "stretch", subtask: r, from: e.from, to: e.to }) : s === "leadIn" ? (e.leadIn ?? 0) !== (t.leadIn ?? 0) && n.push({ kind: "leadIn", subtask: r, leadIn: e.leadIn ?? 0 }) : (e.leadOut ?? 0) !== (t.leadOut ?? 0) && n.push({ kind: "leadOut", subtask: r, leadOut: e.leadOut ?? 0 }), n;
1245
1897
  }
1246
1898
  /** The lane the ghost came from - the only other lane a drag can touch. */
1247
1899
  ghostHome(t) {
@@ -1257,34 +1909,34 @@ class pn {
1257
1909
  keeps a plan of hundreds of tasks fluid while a drag runs, since this is
1258
1910
  computed on every pointer movement. */
1259
1911
  ghostFindings(t, e) {
1260
- const n = this.host.data, s = (d) => d.lane === t.lane || d.lane === e, r = [...n.subtasks.filter((d) => d.id !== t.id && s(d)), t], a = (d) => d.first === t.id || d.second === t.id, l = n.dependencies.filter((d) => d.from === t.id || d.to === t.id), h = t.id === De ? n.subtasks : n.subtasks.map((d) => d.id === t.id ? t : d);
1261
- return { overlaps: Wt(r).filter(a), violated: Xt(h, l) };
1912
+ const s = this.host.data, n = (l) => l.lane === t.lane || l.lane === e, r = [...s.subtasks.filter((l) => l.id !== t.id && n(l)), t], a = (l) => l.first === t.id || l.second === t.id, d = s.dependencies.filter((l) => l.from === t.id || l.to === t.id), h = t.id === Le ? s.subtasks : s.subtasks.map((l) => l.id === t.id ? t : l);
1913
+ return { overlaps: Ht(r).filter(a), violated: Yt(h, d) };
1262
1914
  }
1263
1915
  }
1264
- function mn(o, t) {
1916
+ function Qn(o, t) {
1265
1917
  const e = /* @__PURE__ */ new Map();
1266
- for (const n of t) {
1267
- const s = o.slots.get(n.lane), i = s === void 0 ? null : et(o, s.top);
1918
+ for (const s of t) {
1919
+ const n = o.slots.get(s.lane), i = n === void 0 ? null : st(o, n.top);
1268
1920
  if (i === null) continue;
1269
1921
  const r = o.rows.indexOf(i);
1270
- e.set(r, [...e.get(r) ?? [], n]);
1922
+ e.set(r, [...e.get(r) ?? [], s]);
1271
1923
  }
1272
- return [...e.entries()].sort(([n], [s]) => n - s).map(([, n]) => n.sort((s, i) => s.from - i.from || s.to - i.to));
1924
+ return [...e.entries()].sort(([s], [n]) => s - n).map(([, s]) => s.sort((n, i) => n.from - i.from || n.to - i.to));
1273
1925
  }
1274
- const Oe = (o, t) => t < o.from ? o.from - t : t > o.to ? t - o.to : 0;
1275
- function gn(o, t, e, n) {
1926
+ const _e = (o, t) => t < o.from ? o.from - t : t > o.to ? t - o.to : 0;
1927
+ function to(o, t, e, s) {
1276
1928
  var h;
1277
- let s = -1, i = -1;
1278
- for (let d = 0; d < o.length && t !== null && s < 0; d++)
1279
- i = o[d].findIndex((u) => u.id === t), i >= 0 && (s = d);
1280
- if (s < 0) {
1281
- for (const d of o) {
1282
- const u = d.find((p) => p.to > n[0] && p.from < n[1]);
1283
- if (u !== void 0) return u;
1929
+ let n = -1, i = -1;
1930
+ for (let l = 0; l < o.length && t !== null && n < 0; l++)
1931
+ i = o[l].findIndex((c) => c.id === t), i >= 0 && (n = l);
1932
+ if (n < 0) {
1933
+ for (const l of o) {
1934
+ const c = l.find((p) => p.to > s[0] && p.from < s[1]);
1935
+ if (c !== void 0) return c;
1284
1936
  }
1285
1937
  return ((h = o[0]) == null ? void 0 : h[0]) ?? null;
1286
1938
  }
1287
- const r = o[s], a = r[i], l = (n[1] - n[0]) / 10;
1939
+ const r = o[n], a = r[i], d = (s[1] - s[0]) / 10;
1288
1940
  switch (e) {
1289
1941
  case "next":
1290
1942
  return r[i + 1] ?? a;
@@ -1295,30 +1947,30 @@ function gn(o, t, e, n) {
1295
1947
  case "last":
1296
1948
  return r[r.length - 1];
1297
1949
  case "pageNext":
1298
- return r.find((d, u) => u > i && d.from >= a.from + l) ?? r[r.length - 1];
1950
+ return r.find((l, c) => c > i && l.from >= a.from + d) ?? r[r.length - 1];
1299
1951
  case "pagePrevious":
1300
- for (let d = i - 1; d >= 0; d--) if (r[d].from <= a.from - l) return r[d];
1952
+ for (let l = i - 1; l >= 0; l--) if (r[l].from <= a.from - d) return r[l];
1301
1953
  return r[0];
1302
1954
  case "up":
1303
1955
  case "down": {
1304
- const d = o[e === "up" ? s - 1 : s + 1];
1305
- if (d === void 0) return a;
1306
- const u = (a.from + a.to) / 2;
1307
- return d.reduce((p, m) => Oe(m, u) < Oe(p, u) ? m : p);
1956
+ const l = o[e === "up" ? n - 1 : n + 1];
1957
+ if (l === void 0) return a;
1958
+ const c = (a.from + a.to) / 2;
1959
+ return l.reduce((p, m) => _e(m, c) < _e(p, c) ? m : p);
1308
1960
  }
1309
1961
  }
1310
1962
  }
1311
- function kn(o, t, e, n) {
1963
+ function eo(o, t, e, s) {
1312
1964
  if (e.kind === "dependency") {
1313
- const i = o.find((a) => a.id === e.id), r = i === void 0 ? void 0 : n === "out" ? i.to : i.from;
1965
+ const i = o.find((a) => a.id === e.id), r = i === void 0 ? void 0 : s === "out" ? i.to : i.from;
1314
1966
  return r !== void 0 && t.has(r) ? { kind: "subtask", id: r } : e;
1315
1967
  }
1316
- const s = o.find(
1317
- (i) => (n === "out" ? i.from : i.to) === e.id && t.has(n === "out" ? i.to : i.from)
1968
+ const n = o.find(
1969
+ (i) => (s === "out" ? i.from : i.to) === e.id && t.has(s === "out" ? i.to : i.from)
1318
1970
  );
1319
- return s === void 0 ? e : { kind: "dependency", id: s.id };
1971
+ return n === void 0 ? e : { kind: "dependency", id: n.id };
1320
1972
  }
1321
- const yn = 150, vn = {
1973
+ const so = 150, no = {
1322
1974
  ArrowRight: "next",
1323
1975
  ArrowLeft: "previous",
1324
1976
  ArrowUp: "up",
@@ -1328,7 +1980,7 @@ const yn = 150, vn = {
1328
1980
  PageDown: "pageNext",
1329
1981
  PageUp: "pagePrevious"
1330
1982
  };
1331
- class wn {
1983
+ class oo {
1332
1984
  constructor(t) {
1333
1985
  f(this, "spoken", null);
1334
1986
  f(this, "timer", null);
@@ -1353,33 +2005,33 @@ class wn {
1353
2005
  key(t) {
1354
2006
  const e = this.host.gestures;
1355
2007
  if (t.metaKey || !e.idle) return !1;
1356
- const n = t.key.toLowerCase() === "t" && !t.ctrlKey && !t.altKey;
1357
- if (t.key === "]" || t.key === "[" || n) {
2008
+ const s = t.key.toLowerCase() === "t" && !t.ctrlKey && !t.altKey;
2009
+ if (t.key === "]" || t.key === "[" || s) {
1358
2010
  const i = this.active();
1359
2011
  if (i === null) return !1;
1360
- const r = this.host.data, a = n ? !t.shiftKey : t.key === "]";
1361
- return this.show(kn(r.dependencies, r.subtaskById, i, a ? "out" : "back")), !0;
2012
+ const r = this.host.data, a = s ? !t.shiftKey : t.key === "]";
2013
+ return this.show(eo(r.dependencies, r.subtaskById, i, a ? "out" : "back")), !0;
1362
2014
  }
1363
2015
  if (t.ctrlKey) return !1;
1364
2016
  if (t.altKey) return this.edit(t);
1365
2017
  if (t.key === "Escape")
1366
2018
  return e.byKeyboard ? (this.blur(), !0) : !1;
1367
2019
  if (t.key === "Enter" || t.key === " ") return this.select();
1368
- const s = t.shiftKey ? void 0 : vn[t.key];
1369
- return s === void 0 ? !1 : (this.walk(s), !0);
2020
+ const n = t.shiftKey ? void 0 : no[t.key];
2021
+ return n === void 0 ? !1 : (this.walk(n), !0);
1370
2022
  }
1371
2023
  walk(t) {
1372
- var l;
1373
- const { data: e, view: n } = this.host, s = this.active(), i = s === null ? null : s.kind === "subtask" ? s.id : ((l = e.dependencies.find((h) => h.id === s.id)) == null ? void 0 : l.from) ?? null;
1374
- let r = mn(n.rows, e.subtasks);
2024
+ var d;
2025
+ const { data: e, view: s } = this.host, n = this.active(), i = n === null ? null : n.kind === "subtask" ? n.id : ((d = e.dependencies.find((h) => h.id === n.id)) == null ? void 0 : d.from) ?? null;
2026
+ let r = Qn(s.rows, e.subtasks);
1375
2027
  if (i === null) {
1376
- const h = r.filter((d) => {
1377
- const u = n.boxById.get(d[0].id);
1378
- return u !== void 0 && u.y + u.height > 0 && u.y < n.height;
2028
+ const h = r.filter((l) => {
2029
+ const c = s.boxById.get(l[0].id);
2030
+ return c !== void 0 && c.y + c.height > 0 && c.y < s.height;
1379
2031
  });
1380
2032
  h.length > 0 && (r = h);
1381
2033
  }
1382
- const a = gn(r, i, t, this.host.visibleDomain());
2034
+ const a = to(r, i, t, this.host.visibleDomain());
1383
2035
  a !== null && this.show({ kind: "subtask", id: a.id });
1384
2036
  }
1385
2037
  /** Space and Enter select as a click does: the whole task, and the subtask. */
@@ -1392,325 +2044,124 @@ class wn {
1392
2044
  }
1393
2045
  /** Alt+←/→ proposes a move by one step of the raster, Alt+Shift+←/→ a new
1394
2046
  end - the intents a drag of that length reports (ADR-0023), and only
1395
- where the caller handles them. Nothing is applied here. */
1396
- edit(t) {
1397
- var u, p;
1398
- const e = this.host.gestures.hover, n = t.key === "ArrowRight" ? 1 : t.key === "ArrowLeft" ? -1 : 0;
1399
- if (n === 0) return !1;
1400
- if (e.kind !== "subtask") return !0;
1401
- const s = e.subtask, i = this.host.gestures, r = this.host.view.options.intents, a = i.snapStep(), l = a.step > 0 ? a : { step: this.host.view.step(), offset: 0 }, h = this.host.data.blocked;
1402
- let d = null;
1403
- if (!t.shiftKey && r.includes("move")) {
1404
- const m = (C) => ({ ...s, from: C, to: C + (s.to - s.from) });
1405
- let y = s.from;
1406
- for (let C = 0; C < 1e3; C++) {
1407
- const A = i.shifted(y, n * l.step, l);
1408
- if (A === y || (y = A, !at(m(y), s, h))) break;
1409
- }
1410
- y !== s.from && !at(m(y), s, h) && (d = { kind: "move", subtask: s.id, from: y, to: m(y).to });
1411
- } else if (t.shiftKey && r.includes("stretch")) {
1412
- const m = Math.max(i.shifted(s.to, n * l.step, l), s.from + Math.max(l.step, V));
1413
- m !== s.to && !at({ ...s, to: m }, s, h) && (d = { kind: "stretch", subtask: s.id, from: s.from, to: m });
1414
- }
1415
- return i.byKeyboard = !0, d !== null && ((p = (u = this.host.handlers()).onIntent) == null || p.call(u, d)), this.scheduleReadout(), !0;
1416
- }
1417
- /** The keys stand on this target: brought into view, drawn as the hover. */
1418
- show(t, e = !0) {
1419
- const n = this.hitOf(t);
1420
- if (n === null) return;
1421
- e && this.reveal(t);
1422
- const s = this.bounds(t);
1423
- if (s === null) return;
1424
- const { view: i } = this.host, r = (a, l) => Math.max(0, Math.min(l, a));
1425
- this.host.gestures.setKeyboardHover(n, {
1426
- x: (r(s.x0, i.width) + r(s.x1, i.width)) / 2,
1427
- y: (r(s.y0, i.height) + r(s.y1, i.height)) / 2
1428
- }), e && this.scheduleReadout();
1429
- }
1430
- hitOf(t) {
1431
- const e = this.host.data;
1432
- if (t.kind === "subtask") {
1433
- const s = e.subtaskById.get(t.id);
1434
- return s === void 0 ? null : { kind: "subtask", subtask: s, part: "main" };
1435
- }
1436
- const n = e.dependencies.find((s) => s.id === t.id);
1437
- return n === void 0 ? null : { kind: "dependency", dependency: n };
1438
- }
1439
- /** Where a target lies on the plot: a subtask's bar, or the span between
1440
- the two bars a dependency joins. */
1441
- bounds(t) {
1442
- const e = this.host.view, n = (a) => e.boxById.get(a);
1443
- if (t.kind === "subtask") {
1444
- const a = n(t.id);
1445
- return a === void 0 ? null : { x0: a.outerFrom, x1: a.outerTo, y0: a.y, y1: a.y + a.height };
1446
- }
1447
- const s = this.host.data.dependencies.find((a) => a.id === t.id), i = s === void 0 ? void 0 : n(s.from), r = s === void 0 ? void 0 : n(s.to);
1448
- return i === void 0 || r === void 0 ? null : {
1449
- x0: Math.min(i.mainTo, r.mainFrom),
1450
- x1: Math.max(i.mainTo, r.mainFrom),
1451
- y0: Math.min(i.y, r.y),
1452
- y1: Math.max(i.y + i.height, r.y + r.height)
1453
- };
1454
- }
1455
- /** Pans and scrolls just enough to bring a target into view, with a margin
1456
- at the side it came in from; a target wider than the view shows its
1457
- start. As a drag at the edge pans along, the keys do. */
1458
- reveal(t) {
1459
- const e = this.bounds(t), n = this.host.view;
1460
- if (e === null || n.width <= 0) return;
1461
- const s = Math.min(24, n.width / 10), i = e.x0 < 0 ? e.x0 - s : e.x1 > n.width ? Math.max(0, Math.min(e.x1 - n.width + s, e.x0 - s)) : 0, r = e.y0 < 0 ? e.y0 : e.y1 > n.height ? Math.min(e.y1 - n.height, e.y0) : 0;
1462
- if (i === 0 && r === 0) return;
1463
- const a = n.pan(i, r);
1464
- a.moved && this.host.viewMoved(a.time);
1465
- }
1466
- /** After the data or the view changed: the keys' target is read anew by its
1467
- id - its new times, its new place -, and dropped where it is gone. */
1468
- refresh() {
1469
- const t = this.active();
1470
- !this.host.gestures.byKeyboard || t === null || (this.hitOf(t) === null || this.bounds(t) === null ? this.blur() : this.show(t, !1));
1471
- }
1472
- /** The readout, written once the keys rest - and only while they still hold
1473
- the hover: a pointer that took it over in the pause is not spoken for. */
1474
- scheduleReadout() {
1475
- this.timer !== null && clearTimeout(this.timer), this.timer = setTimeout(() => {
1476
- var n;
1477
- this.timer = null;
1478
- const t = this.host.gestures.hover;
1479
- if (!this.host.gestures.byKeyboard) return;
1480
- const e = this.host.data.tooltipTargetFor(t);
1481
- e !== null && (this.spoken = { target: e, lane: t.kind === "subtask" ? t.subtask.lane : null, count: (((n = this.spoken) == null ? void 0 : n.count) ?? 0) + 1 }, this.host.spokenChanged());
1482
- }, yn);
1483
- }
1484
- /** Unmount: no readout after it. */
1485
- stop() {
1486
- this.timer !== null && clearTimeout(this.timer), this.timer = null;
1487
- }
1488
- }
1489
- const Je = [], bn = 56;
1490
- function Mn(o, t = bn) {
1491
- return o > 0 ? Math.min(q, Math.max(15 * V, bs(o * t, 1))) : 15 * V;
1492
- }
1493
- function Tn(o, t, e = Je) {
1494
- const [n, s] = Qe(o, e);
1495
- return Ms(e, n, s, t, $t(n)).filter(
1496
- (i) => i.workingTime >= o[0] && i.workingTime <= o[1]
1497
- );
1498
- }
1499
- function In(o, t = Je) {
1500
- const [e, n] = Qe(o, t), s = [], i = new Date(e);
1501
- for (i.setHours(0, 0, 0, 0); i.getTime() < n && s.length < 400; ) {
1502
- const r = i.getTime();
1503
- i.setDate(i.getDate() + 1);
1504
- const a = i.getTime();
1505
- s.push({
1506
- start: r,
1507
- end: a,
1508
- from: U(r, t),
1509
- to: U(a, t)
1510
- });
1511
- }
1512
- return s;
1513
- }
1514
- const Dt = [1, 2, 7, 14, 28];
1515
- function Cn(o, t) {
1516
- return Dt.find((e) => e * o >= t) ?? Dt[Dt.length - 1];
1517
- }
1518
- function _t(o, t) {
1519
- return ((Math.round((o - $t(o)) / q) - 4) % t + t) % t === 0;
1520
- }
1521
- function Sn(o, t, e, n) {
1522
- const s = o[1] - o[0];
1523
- if (!(s > 0)) return [o[0], o[1]];
1524
- const i = Math.min(n.max, Math.max(n.min, s * e)), r = (t - o[0]) / s, a = t - r * i;
1525
- return [a, a + i];
1526
- }
1527
- function Ln(o, t) {
1528
- return [o[0] + t, o[1] + t];
1529
- }
1530
- function Qe(o, t) {
1531
- const e = tt(t);
1532
- if (e.intervals.length === 0) return [o[0], o[1]];
1533
- const n = (s) => Math.max(0, Math.min(e.total, s));
1534
- return [j(n(o[0]), e), j(n(o[1]), e)];
1535
- }
1536
- const mt = 44;
1537
- class An {
1538
- constructor(t) {
1539
- f(this, "options", {
1540
- laneHeight: mt,
1541
- calendar: [],
1542
- zoomLimits: { min: xt, max: 28 * q },
1543
- snap: "ticks",
1544
- intents: [],
1545
- now: null,
1546
- route: "curve",
1547
- attach: "centre",
1548
- ends: "dot"
1549
- });
1550
- f(this, "domain", [0, q]);
1551
- f(this, "scrollY", 0);
1552
- f(this, "width", 0);
1553
- f(this, "height", 0);
1554
- /* What is laid out from top to bottom (`rows.ts`). It is derived here and
1555
- not in the data, because a row's height comes from a view option; every y
1556
- in the package reads it. */
1557
- f(this, "rows", ge({ lanes: [], groups: [], collapsed: /* @__PURE__ */ new Set(), laneHeight: mt }));
1558
- /** The folded groups, as the scene holds them. */
1559
- f(this, "collapsed", /* @__PURE__ */ new Set());
1560
- /** The groups a gesture in flight holds open. Dropped when it ends; the
1561
- caller's list never learns of it. */
1562
- f(this, "openForGesture", /* @__PURE__ */ new Set());
1563
- f(this, "boxes", []);
1564
- f(this, "boxById", /* @__PURE__ */ new Map());
1565
- f(this, "paths", []);
1566
- this.data = t;
1567
- }
1568
- /** Takes new options; an initial domain in wall-clock time puts the view
1569
- there, and a new calendar keeps the wall-clock span in view. */
1570
- setOptions(t, e) {
1571
- const n = t.calendar !== this.options.calendar, s = this.options.calendar;
1572
- if (this.options = t, e !== null)
1573
- this.domain = [U(e[0], t.calendar), U(e[1], t.calendar)];
1574
- else if (n) {
1575
- const i = tt(s), r = (a) => {
1576
- const l = i.intervals.length === 0 ? a : Math.max(0, Math.min(i.total, a));
1577
- return U(j(l, i), t.calendar) + (a - l);
1578
- };
1579
- this.domain = [r(this.domain[0]), r(this.domain[1])];
1580
- }
1581
- }
1582
- viewport() {
1583
- return {
1584
- scale: new Ts(this.domain, [0, this.width]),
1585
- calendar: this.options.calendar,
1586
- laneHeight: this.options.laneHeight,
1587
- scrollY: this.scrollY,
1588
- rows: this.rows
1589
- };
1590
- }
1591
- maxScroll() {
1592
- return Math.max(0, this.rows.height - this.height);
1593
- }
1594
- /** The lowest y that still lies on a lane. */
1595
- lanesBottom() {
1596
- return this.rows.height - this.scrollY - 1;
1597
- }
1598
- /** The fine band's step at the current zoom. */
1599
- step() {
1600
- const t = this.domain[1] - this.domain[0];
1601
- return Mn(this.width > 0 ? t / this.width : t);
1602
- }
1603
- /** Lays the rows out, clamps the scroll, and lays the data out anew. */
1604
- layout() {
1605
- this.rows = ge({
1606
- lanes: this.data.lanes,
1607
- groups: this.data.groups,
1608
- collapsed: Os(this.collapsed, this.openForGesture),
1609
- laneHeight: this.options.laneHeight
1610
- }), this.scrollY = Math.max(0, Math.min(this.maxScroll(), this.scrollY));
1611
- const t = this.viewport();
1612
- this.boxes = [], this.boxById = /* @__PURE__ */ new Map();
1613
- for (const e of this.data.subtasks) {
1614
- const n = Kt(this.rows, e.lane);
1615
- if (n === null) continue;
1616
- const s = Ye(t, e, e.lane, n, this.data.depth.get(e.id) ?? 0);
1617
- this.boxes.push(s), this.boxById.set(e.id, s);
1618
- }
1619
- this.paths = [];
1620
- for (const e of this.data.dependencies) {
1621
- const n = this.boxById.get(e.from), s = this.boxById.get(e.to);
1622
- n === void 0 || s === void 0 || this.paths.push(Rt(t, e, n, s, this.options));
2047
+ where the caller handles them. Nothing is applied here. */
2048
+ edit(t) {
2049
+ var c, p;
2050
+ const e = this.host.gestures.hover, s = t.key === "ArrowRight" ? 1 : t.key === "ArrowLeft" ? -1 : 0;
2051
+ if (s === 0) return !1;
2052
+ if (e.kind !== "subtask") return !0;
2053
+ const n = e.subtask, i = this.host.gestures, r = this.host.view.options.intents, a = i.snapStep(), d = a.step > 0 ? a : { step: this.host.view.step(), offset: 0 }, h = this.host.data.blocked;
2054
+ let l = null;
2055
+ if (!t.shiftKey && r.includes("move")) {
2056
+ const m = (I) => ({ ...n, from: I, to: I + (n.to - n.from) });
2057
+ let y = n.from;
2058
+ for (let I = 0; I < 1e3; I++) {
2059
+ const A = i.shifted(y, s * d.step, d);
2060
+ if (A === y || (y = A, !at(m(y), n, h))) break;
2061
+ }
2062
+ y !== n.from && !at(m(y), n, h) && (l = { kind: "move", subtask: n.id, from: y, to: m(y).to });
2063
+ } else if (t.shiftKey && r.includes("stretch")) {
2064
+ const m = Math.max(i.shifted(n.to, s * d.step, d), n.from + Math.max(d.step, q));
2065
+ m !== n.to && !at({ ...n, to: m }, n, h) && (l = { kind: "stretch", subtask: n.id, from: n.from, to: m });
1623
2066
  }
2067
+ return i.byKeyboard = !0, l !== null && ((p = (c = this.host.handlers()).onIntent) == null || p.call(c, l)), this.scheduleReadout(), !0;
1624
2068
  }
1625
- /** The days of the coarse band and the ticks of the fine band, in pixels. */
1626
- bands() {
1627
- const t = this.step();
1628
- if (this.width <= 0) return { days: [], ticks: [], step: t };
1629
- const e = this.viewport().scale, n = this.options.calendar;
1630
- return {
1631
- days: In(this.domain, n).map((s) => {
1632
- const i = Math.round(e.toPx(s.from));
1633
- return { start: s.start, x: i, width: Math.round(e.toPx(s.to)) - i };
1634
- }),
1635
- ticks: Tn(this.domain, t, n).map((s) => ({ wallClock: s.wallClock, x: Math.round(e.toPx(s.workingTime)) })),
1636
- step: t
1637
- };
1638
- }
1639
- /** The now line's x, or null where there is none or it lies outside the plot. */
1640
- nowX() {
1641
- const t = this.options.now;
1642
- if (t === null || this.width <= 0) return null;
1643
- const e = Math.round(this.viewport().scale.toPx(U(t, this.options.calendar)));
1644
- return e >= 0 && e <= this.width ? e : null;
2069
+ /** The keys stand on this target: brought into view, drawn as the hover. */
2070
+ show(t, e = !0) {
2071
+ const s = this.hitOf(t);
2072
+ if (s === null) return;
2073
+ e && this.reveal(t);
2074
+ const n = this.bounds(t);
2075
+ if (n === null) return;
2076
+ const { view: i } = this.host, r = (a, d) => Math.max(0, Math.min(d, a));
2077
+ this.host.gestures.setKeyboardHover(s, {
2078
+ x: (r(n.x0, i.width) + r(n.x1, i.width)) / 2,
2079
+ y: (r(n.y0, i.height) + r(n.y1, i.height)) / 2
2080
+ }), e && this.scheduleReadout();
1645
2081
  }
1646
- hitAt(t, e) {
1647
- for (let r = this.boxes.length - 1; r >= 0; r--) {
1648
- const a = this.boxes[r], l = Ke(a, t, e);
1649
- if (l !== null) return { kind: "subtask", subtask: a.subtask, part: l };
1650
- }
1651
- let n = null, s = 4;
1652
- for (const r of this.paths) {
1653
- const a = xs(r, t, e);
1654
- a <= s && (s = a, n = r);
2082
+ hitOf(t) {
2083
+ const e = this.host.data;
2084
+ if (t.kind === "subtask") {
2085
+ const n = e.subtaskById.get(t.id);
2086
+ return n === void 0 ? null : { kind: "subtask", subtask: n, part: "main" };
1655
2087
  }
1656
- if (n !== null) return { kind: "dependency", dependency: n.dependency };
1657
- const i = we(this.viewport(), e);
1658
- return i !== null ? { kind: "lane", lane: i } : { kind: "nothing" };
1659
- }
1660
- /** The wall-clock time at a plot x; within the calendar's extent. */
1661
- timeAt(t) {
1662
- const e = this.viewport().scale.fromPx(t), n = tt(this.options.calendar);
1663
- return n.intervals.length === 0 ? e : j(Math.max(0, Math.min(n.total, e)), n);
2088
+ const s = e.dependencies.find((n) => n.id === t.id);
2089
+ return s === void 0 ? null : { kind: "dependency", dependency: s };
1664
2090
  }
1665
- /** The lane at a y, strips included: what the pointer is ON.
1666
-
1667
- One line, and it stays a line of its own: it is one of the three
1668
- questions this object answers about a y - this one, `dropLaneIdAt` and
1669
- `foldedGroupAt` - and a caller that reached through `viewport()` for it
1670
- would be depending on the layout rather than asking the view. */
1671
- laneIdAt(t) {
1672
- return we(this.viewport(), t);
2091
+ /** Where a target lies on the plot: a subtask's bar, or the span between
2092
+ the two bars a dependency joins. */
2093
+ bounds(t) {
2094
+ const e = this.host.view, s = (a) => e.boxById.get(a);
2095
+ if (t.kind === "subtask") {
2096
+ const a = s(t.id);
2097
+ return a === void 0 ? null : { x0: a.outerFrom, x1: a.outerTo, y0: a.y, y1: a.y + a.height };
2098
+ }
2099
+ const n = this.host.data.dependencies.find((a) => a.id === t.id), i = n === void 0 ? void 0 : s(n.from), r = n === void 0 ? void 0 : s(n.to);
2100
+ return i === void 0 || r === void 0 ? null : {
2101
+ x0: Math.min(i.mainTo, r.mainFrom),
2102
+ x1: Math.max(i.mainTo, r.mainFrom),
2103
+ y0: Math.min(i.y, r.y),
2104
+ y1: Math.max(i.y + i.height, r.y + r.height)
2105
+ };
1673
2106
  }
1674
- /** The lane a DROP at this y would land on.
1675
-
1676
- A **Miniature** is no drop target. A strip is three pixels of a lane's
1677
- whole day, and a drop aimed at one would be a guess; resting over the
1678
- group opens it for the gesture instead, and then there is a real lane to
1679
- aim at. Hover, the tooltip and selection do read a strip - they cost
1680
- nothing if they are a pixel out. */
1681
- dropLaneIdAt(t) {
1682
- const e = et(this.rows, t + this.scrollY);
1683
- return e === null || e.kind !== "lane" ? null : e.lane ?? null;
2107
+ /** Pans and scrolls just enough to bring a target into view, with a margin
2108
+ at the side it came in from; a target wider than the view shows its
2109
+ start. As a drag at the edge pans along, the keys do. */
2110
+ reveal(t) {
2111
+ const e = this.bounds(t), s = this.host.view;
2112
+ if (e === null || s.width <= 0) return;
2113
+ const n = Math.min(24, s.width / 10), i = e.x0 < 0 ? e.x0 - n : e.x1 > s.width ? Math.max(0, Math.min(e.x1 - s.width + n, e.x0 - n)) : 0, r = e.y0 < 0 ? e.y0 : e.y1 > s.height ? Math.min(e.y1 - s.height, e.y0) : 0;
2114
+ if (i === 0 && r === 0) return;
2115
+ const a = s.pan(i, r);
2116
+ a.moved && this.host.viewMoved(a.time);
1684
2117
  }
1685
- /** The folded group a y lies over, or null. */
1686
- foldedGroupAt(t) {
1687
- const e = et(this.rows, t + this.scrollY);
1688
- return e !== null && e.kind === "miniature" ? e.group ?? null : null;
2118
+ /** After the data or the view changed: the keys' target is read anew by its
2119
+ id - its new times, its new place -, and dropped where it is gone. */
2120
+ refresh() {
2121
+ const t = this.active();
2122
+ !this.host.gestures.byKeyboard || t === null || (this.hitOf(t) === null || this.bounds(t) === null ? this.blur() : this.show(t, !1));
1689
2123
  }
1690
- /** Pans by pixels. Says what moved: the span through time, the lanes, or
1691
- neither - a scroll through the lanes is no news about the time. */
1692
- pan(t, e) {
1693
- const n = this.domain[0], s = this.scrollY, i = this.domain[1] - n;
1694
- this.width > 0 && t !== 0 && (this.domain = Ln(this.domain, t / this.width * i)), this.scrollY = Math.max(0, Math.min(this.maxScroll(), this.scrollY + e));
1695
- const r = this.domain[0] !== n;
1696
- return { moved: r || this.scrollY !== s, time: r };
2124
+ /** The readout, written once the keys rest - and only while they still hold
2125
+ the hover: a pointer that took it over in the pause is not spoken for. */
2126
+ scheduleReadout() {
2127
+ this.timer !== null && clearTimeout(this.timer), this.timer = setTimeout(() => {
2128
+ var s;
2129
+ this.timer = null;
2130
+ const t = this.host.gestures.hover;
2131
+ if (!this.host.gestures.byKeyboard) return;
2132
+ const e = this.host.data.tooltipTargetFor(t);
2133
+ e !== null && (this.spoken = { target: e, lane: t.kind === "subtask" ? t.subtask.lane : null, count: (((s = this.spoken) == null ? void 0 : s.count) ?? 0) + 1 }, this.host.spokenChanged());
2134
+ }, so);
1697
2135
  }
1698
- /** Zooms around a plot x; says whether the span changed. */
1699
- zoomAt(t, e) {
1700
- if (this.width <= 0 || !Number.isFinite(e)) return !1;
1701
- const n = this.domain, s = this.viewport().scale.fromPx(t);
1702
- return this.domain = Sn(this.domain, s, e, this.options.zoomLimits), n[0] !== this.domain[0] || n[1] !== this.domain[1];
2136
+ /** Unmount: no readout after it. */
2137
+ stop() {
2138
+ this.timer !== null && clearTimeout(this.timer), this.timer = null;
1703
2139
  }
1704
2140
  }
1705
- const Ee = {
2141
+ const Q = (o) => JSON.stringify([o.domain ?? null, [...o.folded ?? []].sort()]);
2142
+ function io(o, t) {
2143
+ if (t.size === 0 || o.folded === void 0) return o;
2144
+ const e = o.folded.filter((s) => t.has(s));
2145
+ return e.length === o.folded.length ? o : { ...o.domain ? { domain: o.domain } : {}, ...e.length ? { folded: e } : {} };
2146
+ }
2147
+ function ro(o, t, e = (s) => s) {
2148
+ if (o.length === 0) return null;
2149
+ let s = 1 / 0, n = -1 / 0;
2150
+ for (const a of o)
2151
+ s = Math.min(s, a.from - (a.leadIn ?? 0)), n = Math.max(n, a.to + (a.leadOut ?? 0));
2152
+ s = e(s), n = e(n);
2153
+ const i = Math.min(t.max, Math.max(t.min, n - s)), r = (s + n) / 2;
2154
+ return [r - i / 2, r + i / 2];
2155
+ }
2156
+ const De = {
1706
2157
  width: 0,
1707
2158
  height: 0,
1708
- laneHeight: mt,
2159
+ laneHeight: pt,
1709
2160
  scrollY: 0,
1710
2161
  headers: [],
1711
2162
  days: [],
1712
2163
  ticks: [],
1713
- step: xt,
2164
+ step: Bt,
1714
2165
  ghost: null,
1715
2166
  grips: [],
1716
2167
  cursor: "default",
@@ -1720,10 +2171,10 @@ const Ee = {
1720
2171
  spoken: null,
1721
2172
  summary: { lanes: 0, subtasks: 0, from: 0, to: 0, overlaps: 0, violated: 0, blocked: 0 }
1722
2173
  };
1723
- class Dn {
1724
- constructor() {
1725
- f(this, "data", new Hs(() => this.viewChanged()));
1726
- f(this, "view", new An(this.data));
2174
+ class ao {
2175
+ constructor(t = {}) {
2176
+ f(this, "data", new An(() => this.viewChanged()));
2177
+ f(this, "view", new Ys(this.data));
1727
2178
  f(this, "gestures");
1728
2179
  f(this, "keys");
1729
2180
  f(this, "handlersNow", {});
@@ -1731,11 +2182,24 @@ class Dn {
1731
2182
  f(this, "controlledTask");
1732
2183
  f(this, "ownTask", null);
1733
2184
  f(this, "selected", null);
1734
- /** Which **Lane group**s are folded. Controlled where the caller passes a
1735
- list, kept here otherwise - the shape `selectedTask` has. Folding changes
1736
- the view and not the plan, so it is no **Intent** (ADR-0025). */
1737
- f(this, "controlledCollapsed");
1738
- f(this, "ownCollapsed", []);
2185
+ /** Which **Lane group**s are folded. Folding changes the view and not the
2186
+ plan, so it is no **Intent** (ADR-0025). */
2187
+ f(this, "folded");
2188
+ /** The span the view names, in wall-clock time - null while it names none
2189
+ and the schedule shows the subtasks' extent. */
2190
+ f(this, "domainInView");
2191
+ /** Whether the extent has been put in view since the view stopped naming a
2192
+ span. Once, and not after every change of the data: a bar the planner
2193
+ dragged past the end must not make the whole plan jump. */
2194
+ f(this, "fitted", !1);
2195
+ /** The view as `useSchedule` reads it - a new object only when its content
2196
+ changed. */
2197
+ f(this, "viewNow");
2198
+ f(this, "viewListeners", /* @__PURE__ */ new Set());
2199
+ /** Whether the planner, a setter or a view handed in has changed the view
2200
+ yet. Until then a change is the start losing the groups no LaneGroup
2201
+ declares - where the schedule starts, not a change to report. */
2202
+ f(this, "actedOn", !1);
1739
2203
  f(this, "root", null);
1740
2204
  f(this, "plot", null);
1741
2205
  f(this, "dataCanvas", null);
@@ -1744,7 +2208,7 @@ class Dn {
1744
2208
  f(this, "frame", 0);
1745
2209
  f(this, "domainFrame", 0);
1746
2210
  f(this, "unsubscribeTheme", null);
1747
- f(this, "snapshot", Ee);
2211
+ f(this, "snapshot", De);
1748
2212
  f(this, "listeners", /* @__PURE__ */ new Set());
1749
2213
  /* ---------------------------------------------------------------- */
1750
2214
  /* Registration and options */
@@ -1758,11 +2222,34 @@ class Dn {
1758
2222
  f(this, "registerLayer", (t) => this.data.registerLayer(t));
1759
2223
  f(this, "updateLayer", (t, e) => this.data.updateLayer(t, e));
1760
2224
  f(this, "unregisterLayer", (t) => this.data.unregisterLayer(t));
2225
+ /* ---------------------------------------------------------------- */
2226
+ /* The view (ADR-0047) */
2227
+ /* ---------------------------------------------------------------- */
2228
+ f(this, "subscribeView", (t) => (this.viewListeners.add(t), () => {
2229
+ this.viewListeners.delete(t);
2230
+ }));
2231
+ f(this, "getView", () => this.viewNow);
2232
+ /** Puts a span of two wall-clock instants in view; null shows the
2233
+ subtasks' extent. */
2234
+ f(this, "setDomain", (t) => {
2235
+ this.domainFrame !== 0 && cancelAnimationFrame(this.domainFrame), this.domainFrame = 0, this.actedOn = !0, this.domainInView = t === null ? null : [t[0], t[1]], t === null ? this.fitted = !1 : this.view.showWall(t), this.viewChanged();
2236
+ });
2237
+ /** Folds or unfolds one group. */
2238
+ f(this, "toggleGroup", (t) => {
2239
+ const e = this.viewNow.folded ?? [];
2240
+ this.actedOn = !0, this.folded = e.includes(t) ? e.filter((s) => s !== t) : [...e, t], this.viewChanged();
2241
+ });
2242
+ f(this, "foldAll", () => {
2243
+ this.actedOn = !0, this.folded = this.data.groups.map((t) => t.id), this.viewChanged();
2244
+ });
2245
+ f(this, "unfoldAll", () => {
2246
+ this.actedOn = !0, this.folded = [], this.viewChanged();
2247
+ });
1761
2248
  f(this, "subscribe", (t) => (this.listeners.add(t), () => {
1762
2249
  this.listeners.delete(t);
1763
2250
  }));
1764
2251
  f(this, "getSnapshot", () => this.snapshot);
1765
- f(this, "getServerSnapshot", () => Ee);
2252
+ f(this, "getServerSnapshot", () => De);
1766
2253
  /* ---------------------------------------------------------------- */
1767
2254
  /* Gestures, as the component hands them in */
1768
2255
  /* ---------------------------------------------------------------- */
@@ -1780,33 +2267,36 @@ class Dn {
1780
2267
  f(this, "key", (t) => this.keys.key(t));
1781
2268
  f(this, "focus", (t) => this.keys.focus(t));
1782
2269
  f(this, "blur", () => this.keys.blur());
1783
- this.gestures = new pn({
2270
+ this.folded = t.folded ?? [], this.domainInView = t.domain ?? null, this.domainInView !== null && this.view.showWall(this.domainInView), this.viewNow = this.currentView(), this.gestures = new Zn({
1784
2271
  data: this.data,
1785
2272
  view: this.view,
1786
2273
  plotElement: () => this.plot,
1787
2274
  handlers: () => this.handlersNow,
1788
2275
  selectedSubtask: () => this.selected,
1789
- select: (t, e) => this.select(t, e),
2276
+ select: (e, s) => this.select(e, s),
1790
2277
  viewChanged: () => this.viewChanged(),
1791
- viewMoved: (t) => {
1792
- this.viewChanged(), t && this.reportDomain();
2278
+ viewMoved: (e) => {
2279
+ this.viewChanged(), e && this.reportDomain();
1793
2280
  },
1794
2281
  interactionChanged: () => this.interactionChanged()
1795
- }), this.keys = new wn({
2282
+ }), this.keys = new oo({
1796
2283
  data: this.data,
1797
2284
  view: this.view,
1798
2285
  gestures: this.gestures,
1799
2286
  handlers: () => this.handlersNow,
1800
2287
  visibleDomain: () => this.visibleDomain(),
1801
- select: (t, e) => this.select(t, e),
1802
- viewMoved: (t) => {
1803
- this.viewChanged(), t && this.reportDomain();
2288
+ select: (e, s) => this.select(e, s),
2289
+ viewMoved: (e) => {
2290
+ this.viewChanged(), e && this.reportDomain();
1804
2291
  },
1805
2292
  spokenChanged: () => this.publish()
1806
2293
  });
1807
2294
  }
1808
- setOptions(t, e) {
1809
- this.view.setOptions(t, e), this.viewChanged();
2295
+ get acted() {
2296
+ return this.actedOn;
2297
+ }
2298
+ setOptions(t) {
2299
+ this.view.setOptions(t), this.viewChanged();
1810
2300
  }
1811
2301
  setHandlers(t) {
1812
2302
  this.handlersNow = t;
@@ -1815,23 +2305,33 @@ class Dn {
1815
2305
  setPlacing(t) {
1816
2306
  this.placing = t, t === null && this.gestures.clearPlacing();
1817
2307
  }
1818
- /** `undefined`: the scene keeps the folded groups itself. */
1819
- setCollapsedGroups(t) {
1820
- t !== this.controlledCollapsed && (this.controlledCollapsed = t, this.viewChanged());
2308
+ /** Goes to a view handed in; what it leaves out goes back to its default. */
2309
+ applyView(t) {
2310
+ Q(t) !== Q(this.viewNow) && (this.actedOn = !0, this.folded = t.folded ?? [], this.setDomain(t.domain ?? null));
1821
2311
  }
1822
- /** The uncontrolled starting point, taken once. */
1823
- setDefaultCollapsedGroups(t) {
1824
- this.ownCollapsed = t, this.viewChanged();
2312
+ currentView() {
2313
+ return io(
2314
+ { ...this.domainInView === null ? {} : { domain: this.domainInView }, ...this.folded.length > 0 ? { folded: this.folded } : {} },
2315
+ new Set(this.data.groups.map((t) => t.id))
2316
+ );
1825
2317
  }
1826
- get collapsedGroups() {
1827
- return this.controlledCollapsed ?? this.ownCollapsed;
2318
+ publishView() {
2319
+ const t = this.currentView();
2320
+ if (Q(t) !== Q(this.viewNow)) {
2321
+ this.viewNow = t;
2322
+ for (const e of this.viewListeners) e();
2323
+ }
1828
2324
  }
1829
- /** Folds or unfolds one group. The caller's list is never written to: where
1830
- the state is controlled, only the report goes out. */
1831
- toggleGroup(t) {
1832
- var s, i;
1833
- const e = this.collapsedGroups, n = e.includes(t) ? e.filter((r) => r !== t) : [...e, t];
1834
- this.controlledCollapsed === void 0 && (this.ownCollapsed = n), (i = (s = this.handlersNow).onCollapsedGroupsChange) == null || i.call(s, n), this.viewChanged();
2325
+ /** The subtasks' extent within the zoom limits, while the view names no
2326
+ span - and the local day of today while there is no work to show. */
2327
+ fit() {
2328
+ const t = this.view.options.calendar, e = ro(this.data.subtasks, this.view.options.zoomLimits, (n) => H(n, t));
2329
+ if (e !== null) {
2330
+ this.view.domain = e, this.fitted = !0;
2331
+ return;
2332
+ }
2333
+ const s = /* @__PURE__ */ new Date();
2334
+ s.setHours(0, 0, 0, 0), this.view.showWall([s.getTime(), s.getTime() + U]);
1835
2335
  }
1836
2336
  /** `undefined`: the scene keeps the selection itself. */
1837
2337
  setControlledTask(t) {
@@ -1848,15 +2348,15 @@ class Dn {
1848
2348
  return t !== void 0 && t.task === this.selectedTask ? t.id : null;
1849
2349
  }
1850
2350
  select(t, e) {
1851
- var s, i;
1852
- const n = t !== this.selectedTask || e !== this.selected;
1853
- this.selected = e, t !== this.selectedTask && this.controlledTask === void 0 && (this.ownTask = t), n && ((i = (s = this.handlersNow).onSelectedTaskChange) == null || i.call(s, t, e)), this.interactionChanged();
2351
+ var n, i;
2352
+ const s = t !== this.selectedTask || e !== this.selected;
2353
+ this.selected = e, t !== this.selectedTask && this.controlledTask === void 0 && (this.ownTask = t), s && ((i = (n = this.handlersNow).onSelectedTaskChange) == null || i.call(n, t, e)), this.interactionChanged();
1854
2354
  }
1855
2355
  /* ---------------------------------------------------------------- */
1856
2356
  /* DOM binding */
1857
2357
  /* ---------------------------------------------------------------- */
1858
- bind(t, e, n, s) {
1859
- this.root = t, this.plot = e, this.dataCanvas = n, this.overlayCanvas = s, this.unsubscribeTheme = Is(() => {
2358
+ bind(t, e, s, n) {
2359
+ this.root = t, this.plot = e, this.dataCanvas = s, this.overlayCanvas = n, this.unsubscribeTheme = fs(() => {
1860
2360
  this.colours = null, this.requestDraw();
1861
2361
  }), this.viewChanged();
1862
2362
  }
@@ -1865,21 +2365,21 @@ class Dn {
1865
2365
  this.gestures.cancelEdit(), this.keys.stop(), (t = this.unsubscribeTheme) == null || t.call(this), this.unsubscribeTheme = null, this.frame !== 0 && cancelAnimationFrame(this.frame), this.domainFrame !== 0 && cancelAnimationFrame(this.domainFrame), this.frame = this.domainFrame = 0, this.root = this.plot = this.dataCanvas = this.overlayCanvas = null;
1866
2366
  }
1867
2367
  resize(t, e) {
1868
- const n = Math.max(0, Math.round(t)), s = Math.max(0, Math.round(e));
1869
- n === this.view.width && s === this.view.height || (this.view.width = n, this.view.height = s, this.viewChanged());
2368
+ const s = Math.max(0, Math.round(t)), n = Math.max(0, Math.round(e));
2369
+ s === this.view.width && n === this.view.height || (this.view.width = s, this.view.height = n, this.viewChanged());
1870
2370
  }
1871
2371
  /* ---------------------------------------------------------------- */
1872
2372
  /* Changes */
1873
2373
  /* ---------------------------------------------------------------- */
1874
2374
  viewChanged() {
1875
- this.view.collapsed = new Set(this.collapsedGroups), this.data.rebuild() && (this.colours = null, this.selected !== null && !this.data.subtaskById.has(this.selected) && (this.selected = null)), this.view.layout(), this.gestures.refreshHover(), this.keys.refresh(), this.interactionChanged();
2375
+ this.view.collapsed = new Set(this.folded), this.data.rebuild() && (this.colours = null, this.selected !== null && !this.data.subtaskById.has(this.selected) && (this.selected = null)), this.domainInView === null && !this.fitted && this.fit(), this.publishView(), this.view.layout(), this.gestures.refreshHover(), this.keys.refresh(), this.interactionChanged();
1876
2376
  }
1877
2377
  interactionChanged() {
1878
2378
  this.publish(), this.requestDraw();
1879
2379
  }
1880
2380
  publish() {
1881
- const t = this.view, e = this.selected !== null ? t.boxById.get(this.selected) : void 0, n = [];
1882
- e !== void 0 && !e.miniature && !this.gestures.editing && e.subtask.task === this.selectedTask && (t.options.intents.includes("leadIn") && n.push({ kind: "leadIn", x: e.outerFrom, y: e.y, height: e.height }), t.options.intents.includes("leadOut") && n.push({ kind: "leadOut", x: e.outerTo, y: e.y, height: e.height })), this.snapshot = {
2381
+ const t = this.view, e = this.selected !== null ? t.boxById.get(this.selected) : void 0, s = [];
2382
+ e !== void 0 && !e.miniature && !this.gestures.editing && e.subtask.task === this.selectedTask && (t.options.intents.includes("leadIn") && s.push({ kind: "leadIn", x: e.outerFrom, y: e.y, height: e.height }), t.options.intents.includes("leadOut") && s.push({ kind: "leadOut", x: e.outerTo, y: e.y, height: e.height })), this.snapshot = {
1883
2383
  width: t.width,
1884
2384
  height: t.height,
1885
2385
  laneHeight: t.options.laneHeight,
@@ -1887,7 +2387,7 @@ class Dn {
1887
2387
  headers: this.headers(),
1888
2388
  ...t.bands(),
1889
2389
  ghost: this.gestures.ghostSummary(),
1890
- grips: n,
2390
+ grips: s,
1891
2391
  cursor: this.gestures.cursor,
1892
2392
  tooltip: this.tooltip(),
1893
2393
  now: t.nowX(),
@@ -1895,25 +2395,25 @@ class Dn {
1895
2395
  spoken: this.keys.spoken,
1896
2396
  summary: this.summary()
1897
2397
  };
1898
- for (const s of this.listeners) s();
2398
+ for (const n of this.listeners) n();
1899
2399
  }
1900
2400
  /** One header per row, with what it says and where it sits. The scroll is
1901
2401
  not taken off here: the header column is moved as a whole, as it always
1902
2402
  was, so that a header and its row cannot drift apart by a rounding. */
1903
2403
  headers() {
1904
- const t = new Map(this.data.lanes.map((s) => [s.id, s.label])), e = new Map(this.data.groups.map((s) => [s.id, s.label])), n = new Set(this.collapsedGroups);
1905
- return this.view.rows.rows.map((s) => ({
1906
- key: s.lane ?? s.group ?? "",
1907
- kind: s.kind,
1908
- lane: s.lane,
1909
- group: s.group,
1910
- label: (s.lane !== void 0 ? t.get(s.lane) : e.get(s.group ?? "")) ?? s.lane ?? s.group ?? "",
1911
- depth: s.depth,
1912
- within: s.within,
1913
- lanes: s.lanes,
1914
- collapsed: s.group === void 0 ? void 0 : n.has(s.group),
1915
- top: s.top,
1916
- height: s.height
2404
+ const t = new Map(this.data.lanes.map((n) => [n.id, n.label])), e = new Map(this.data.groups.map((n) => [n.id, n.label])), s = new Set(this.folded);
2405
+ return this.view.rows.rows.map((n) => ({
2406
+ key: n.lane ?? n.group ?? "",
2407
+ kind: n.kind,
2408
+ lane: n.lane,
2409
+ group: n.group,
2410
+ label: (n.lane !== void 0 ? t.get(n.lane) : e.get(n.group ?? "")) ?? n.lane ?? n.group ?? "",
2411
+ depth: n.depth,
2412
+ within: n.within,
2413
+ lanes: n.lanes,
2414
+ collapsed: n.group === void 0 ? void 0 : s.has(n.group),
2415
+ top: n.top,
2416
+ height: n.height
1917
2417
  }));
1918
2418
  }
1919
2419
  /** The bars a label could stand in: the visible part of every main time,
@@ -1923,27 +2423,27 @@ class Dn {
1923
2423
  const t = this.view;
1924
2424
  if (t.width <= 0) return [];
1925
2425
  const e = this.colours;
1926
- return t.boxes.flatMap((n) => {
1927
- if (!Et(n, t.width, t.height)) return [];
1928
- const s = Ns(n, t.width);
1929
- if (s === null) return [];
1930
- const i = e === null ? !0 : Vt(
1931
- kt(n.subtask.appearance),
1932
- ht(e, { selectedTask: this.selectedTask, selectedSubtask: this.selectedSubtask }, n.subtask.task, n.subtask.id),
2426
+ return t.boxes.flatMap((s) => {
2427
+ if (!Ft(s, t.width, t.height)) return [];
2428
+ const n = Os(s, t.width);
2429
+ if (n === null) return [];
2430
+ const i = e === null ? !0 : Wt(
2431
+ gt(s.subtask.appearance),
2432
+ ht(e, { selectedTask: this.selectedTask, selectedSubtask: this.selectedSubtask }, s.subtask.task, s.subtask.id),
1933
2433
  e
1934
2434
  ).onDark;
1935
- return [{ subtask: n.subtask, ...s, dark: i }];
2435
+ return [{ subtask: s.subtask, ...n, dark: i }];
1936
2436
  });
1937
2437
  }
1938
2438
  /** The findings count the whole plan - an overlap out of view is still one
1939
2439
  to know of -, the subtasks only what is in view. */
1940
2440
  summary() {
1941
- const t = this.view, [e, n] = this.visibleDomain();
2441
+ const t = this.view, [e, s] = this.visibleDomain();
1942
2442
  return {
1943
2443
  lanes: this.data.lanes.length,
1944
- subtasks: t.boxes.filter((s) => Et(s, t.width, t.height)).length,
2444
+ subtasks: t.boxes.filter((n) => Ft(n, t.width, t.height)).length,
1945
2445
  from: e,
1946
- to: n,
2446
+ to: s,
1947
2447
  overlaps: this.data.overlaps.length,
1948
2448
  violated: this.data.violatedById.size,
1949
2449
  blocked: this.data.inBlocked.length
@@ -1954,45 +2454,39 @@ class Dn {
1954
2454
  if (!this.gestures.idle) return null;
1955
2455
  const e = this.data.tooltipTargetFor(t);
1956
2456
  if (e === null) return null;
1957
- const { x: n, y: s } = this.gestures.hoverPoint;
1958
- return { target: e, x: n, y: s };
2457
+ const { x: s, y: n } = this.gestures.hoverPoint;
2458
+ return { target: e, x: s, y: n };
1959
2459
  }
1960
2460
  /** The visible span, as two wall-clock instants. */
1961
2461
  visibleDomain() {
1962
- const t = tt(this.view.options.calendar), e = (n) => t.intervals.length === 0 ? n : j(Math.max(0, Math.min(t.total, n)), t);
2462
+ const t = et(this.view.options.calendar), e = (s) => t.intervals.length === 0 ? s : j(Math.max(0, Math.min(t.total, s)), t);
1963
2463
  return [e(this.view.domain[0]), e(this.view.domain[1])];
1964
2464
  }
1965
- /** Reported once per frame, however many wheel steps a planner turns - and
1966
- only for their gestures: a span handed in from outside is not news to the
1967
- caller who handed it in, and reporting it would let two schedules
1968
- synchronised with each other feed one another for ever. */
2465
+ /** A pan or zoom of the planner's goes into the view once per frame,
2466
+ however many wheel steps they turn. */
1969
2467
  reportDomain() {
1970
- var t, e;
1971
- if (typeof requestAnimationFrame != "function") {
1972
- (e = (t = this.handlersNow).onDomainChange) == null || e.call(t, this.visibleDomain());
1973
- return;
1974
- }
1975
- this.domainFrame === 0 && (this.domainFrame = requestAnimationFrame(() => {
1976
- var n, s;
1977
- this.domainFrame = 0, (s = (n = this.handlersNow).onDomainChange) == null || s.call(n, this.visibleDomain());
1978
- }));
2468
+ const t = () => {
2469
+ this.domainFrame = 0, this.actedOn = !0, this.domainInView = this.visibleDomain(), this.publishView();
2470
+ };
2471
+ if (typeof requestAnimationFrame != "function") return t();
2472
+ this.domainFrame === 0 && (this.domainFrame = requestAnimationFrame(t));
1979
2473
  }
1980
2474
  /** The time and the lane at a client point, or null outside the plot. */
1981
2475
  positionAt(t, e) {
1982
2476
  var r;
1983
- const n = (r = this.plot) == null ? void 0 : r.getBoundingClientRect();
1984
- if (n === void 0) return null;
1985
- const s = t - n.left, i = e - n.top;
1986
- return s < 0 || i < 0 || s > n.width || i > n.height ? null : { time: this.view.timeAt(s), lane: this.view.laneIdAt(i) };
2477
+ const s = (r = this.plot) == null ? void 0 : r.getBoundingClientRect();
2478
+ if (s === void 0) return null;
2479
+ const n = t - s.left, i = e - s.top;
2480
+ return n < 0 || i < 0 || n > s.width || i > s.height ? null : { time: this.view.timeAt(n), lane: this.view.laneIdAt(i) };
1987
2481
  }
1988
2482
  /** The client point of a time, on a lane's middle where one is named, or
1989
2483
  null while the schedule is not on screen. */
1990
2484
  clientPointOf(t, e) {
1991
2485
  var a;
1992
- const n = (a = this.plot) == null ? void 0 : a.getBoundingClientRect();
1993
- if (n === void 0) return null;
1994
- const s = this.view.viewport(), i = e === void 0 ? null : dt(s, e), r = i === null ? 0 : i.top + i.height / 2;
1995
- return { x: n.left + N(s, t), y: n.top + r };
2486
+ const s = (a = this.plot) == null ? void 0 : a.getBoundingClientRect();
2487
+ if (s === void 0) return null;
2488
+ const n = this.view.viewport(), i = e === void 0 ? null : dt(n, e), r = i === null ? 0 : i.top + i.height / 2;
2489
+ return { x: s.left + N(n, t), y: s.top + r };
1996
2490
  }
1997
2491
  requestDraw() {
1998
2492
  this.frame !== 0 || this.dataCanvas === null || typeof requestAnimationFrame != "function" || (this.frame = requestAnimationFrame(() => {
@@ -2001,9 +2495,9 @@ class Dn {
2001
2495
  }
2002
2496
  draw() {
2003
2497
  if (this.root === null) return;
2004
- this.colours === null && (this.colours = Us(this.root, this.data), this.publish());
2005
- const { width: t, height: e } = this.view, n = Ie(this.dataCanvas, t, e), s = Ie(this.overlayCanvas, t, e);
2006
- if (n === null || s === null || t === 0) return;
2498
+ this.colours === null && (this.colours = Fn(this.root, this.data), this.publish());
2499
+ const { width: t, height: e } = this.view, s = be(this.dataCanvas, t, e), n = be(this.overlayCanvas, t, e);
2500
+ if (s === null || n === null || t === 0) return;
2007
2501
  const i = {
2008
2502
  data: this.data,
2009
2503
  view: this.view,
@@ -2014,473 +2508,49 @@ class Dn {
2014
2508
  hover: this.gestures.hover,
2015
2509
  ghost: this.gestures.ghostDrawing()
2016
2510
  };
2017
- Ws(n, i), Xs(s, i);
2018
- }
2019
- }
2020
- const _n = "_root_1892z_4 _text_r8i8z_23", Fn = "_corner_1892z_19", On = "_dayBand_1892z_23", En = "_tickBand_1892z_24", Rn = "_day_1892z_23", Pn = "_dayLabel_1892z_50", Bn = "_tick_1892z_24", Nn = "_tickLabel_1892z_71", $n = "_headers_1892z_79", xn = "_header_1892z_79", Gn = "_headerLabel_1892z_97", Hn = "_headerCount_1892z_134", Yn = "_chevron_1892z_143", Kn = "_plot_1892z_201", zn = "_focusRing_1892z_208", Un = "_layer_1892z_226", Wn = "_grip_1892z_235", Xn = "_ghostLabel_1892z_245", Vn = "_finding_1892z_258", jn = "_refusal_1892z_266", qn = "_tooltip_1892z_270", Zn = "_tooltipHead_1892z_289", Jn = "_tooltipTimes_1892z_294", Qn = "_now_1892z_303", to = "_barLabel_1892z_317", eo = "_barLabelText_1892z_330", w = {
2021
- root: _n,
2022
- corner: Fn,
2023
- dayBand: On,
2024
- tickBand: En,
2025
- day: Rn,
2026
- dayLabel: Pn,
2027
- tick: Bn,
2028
- tickLabel: Nn,
2029
- headers: $n,
2030
- header: xn,
2031
- headerLabel: Gn,
2032
- headerCount: Hn,
2033
- chevron: Yn,
2034
- plot: Kn,
2035
- focusRing: zn,
2036
- layer: Un,
2037
- grip: Wn,
2038
- ghostLabel: Xn,
2039
- finding: Vn,
2040
- refusal: jn,
2041
- tooltip: qn,
2042
- tooltipHead: Zn,
2043
- tooltipTimes: Jn,
2044
- now: Qn,
2045
- barLabel: to,
2046
- barLabelText: eo
2047
- };
2048
- function ts() {
2049
- const o = gt();
2050
- return (t) => {
2051
- const e = Math.round(t / V), n = Math.floor(e / 60), s = e % 60;
2052
- return [n > 0 ? o.hoursShort(n) : "", s > 0 || n === 0 ? o.minutesShort(s) : ""].filter(Boolean).join(" ");
2053
- };
2054
- }
2055
- function so({ target: o, lane: t }) {
2056
- const e = Gt(), n = gt(), s = ts(), i = (u) => e.time(new Date(u), !1);
2057
- if (o.kind === "subtask") {
2058
- const { subtask: u, task: p } = o, m = [
2059
- (p == null ? void 0 : p.name) ?? u.task,
2060
- u.name ?? u.id,
2061
- `${e.dateShort(new Date(u.from))} ${n.scheduleGhostTimes(i(u.from), i(u.to))}`,
2062
- ...o.overlapping.map((y) => n.scheduleOverlapWith(y.name ?? y.id)),
2063
- ...o.violatedDependencies.map((y) => n.scheduleViolatedBy(s(y.shortBy))),
2064
- ...o.blocked.map((y) => n.scheduleInBlockedTime(y.label))
2065
- ];
2066
- return /* @__PURE__ */ z(Ot, { children: [
2067
- t,
2068
- `, ${m.join(", ")}`
2069
- ] });
2070
- }
2071
- const { dependency: r, task: a, from: l, to: h, violated: d } = o;
2072
- return [
2073
- (a == null ? void 0 : a.name) ?? (a == null ? void 0 : a.id) ?? r.id,
2074
- `${n.scheduleDependency} ${s(r.lag)}`,
2075
- n.scheduleRoute((l == null ? void 0 : l.name) ?? r.from, (h == null ? void 0 : h.name) ?? r.to),
2076
- ...d === void 0 ? [] : [n.scheduleViolatedBy(s(d.shortBy))]
2077
- ].join(", ");
2078
- }
2079
- function no({ target: o }) {
2080
- const t = Gt(), e = gt(), n = (d) => t.time(new Date(d), !1), s = ts();
2081
- if (o.kind === "subtask") {
2082
- const { subtask: d, task: u } = o;
2083
- return /* @__PURE__ */ z(Ot, { children: [
2084
- /* @__PURE__ */ k("span", { className: w.tooltipHead, children: (u == null ? void 0 : u.name) ?? d.task }),
2085
- /* @__PURE__ */ k("span", { children: d.name ?? d.id }),
2086
- /* @__PURE__ */ k("span", { className: w.tooltipTimes, children: e.scheduleGhostTimes(n(d.from), n(d.to)) }),
2087
- (d.leadIn ?? 0) > 0 && /* @__PURE__ */ k("span", { children: `${e.scheduleLeadIn} ${s(d.leadIn)}` }),
2088
- (d.leadOut ?? 0) > 0 && /* @__PURE__ */ k("span", { children: `${e.scheduleLeadOut} ${s(d.leadOut)}` }),
2089
- o.overlapping.map((p) => /* @__PURE__ */ k("span", { className: w.finding, children: e.scheduleOverlapWith(p.name ?? p.id) }, p.id)),
2090
- o.violatedDependencies.map((p) => /* @__PURE__ */ k("span", { className: w.finding, children: e.scheduleViolatedBy(s(p.shortBy)) }, p.dependency)),
2091
- o.blocked.map((p) => /* @__PURE__ */ k("span", { className: w.finding, children: e.scheduleInBlockedTime(p.label) }, p.id))
2092
- ] });
2093
- }
2094
- const { dependency: i, task: r, from: a, to: l, violated: h } = o;
2095
- return /* @__PURE__ */ z(Ot, { children: [
2096
- /* @__PURE__ */ k("span", { className: w.tooltipHead, children: (r == null ? void 0 : r.name) ?? (r == null ? void 0 : r.id) ?? i.id }),
2097
- /* @__PURE__ */ k("span", { children: e.scheduleRoute((a == null ? void 0 : a.name) ?? i.from, (l == null ? void 0 : l.name) ?? i.to) }),
2098
- /* @__PURE__ */ k("span", { children: `${e.scheduleDependency} ${s(i.lag)}` }),
2099
- h !== void 0 && /* @__PURE__ */ k("span", { className: w.finding, children: e.scheduleViolatedBy(s(h.shortBy)) })
2100
- ] });
2101
- }
2102
- const oo = [], Re = { min: xt, max: 28 * q }, io = [], Pe = 20, Ft = 44, mo = ms(function(t, e) {
2103
- var fe;
2104
- const {
2105
- ariaLabel: n,
2106
- initialDomain: s,
2107
- height: i = 400,
2108
- laneHeight: r = mt,
2109
- headerWidth: a = 160,
2110
- calendar: l = io,
2111
- zoomLimits: h,
2112
- snap: d = "ticks",
2113
- intents: u = oo,
2114
- onIntent: p,
2115
- canMoveTo: m,
2116
- onInteraction: y,
2117
- selectedTask: C,
2118
- onSelectedTaskChange: A,
2119
- collapsedGroups: D,
2120
- defaultCollapsedGroups: g,
2121
- onCollapsedGroupsChange: I,
2122
- onDomainChange: S,
2123
- placing: R,
2124
- route: O = "curve",
2125
- attach: H = "centre",
2126
- ends: nt = "dot",
2127
- label: ct,
2128
- tooltip: Z,
2129
- now: ot,
2130
- className: jt,
2131
- style: es,
2132
- children: ss
2133
- } = t, [v] = ut(() => new Dn()), yt = gs(), qt = `${yt}-summary`, Zt = G(null), Jt = G(null), Qt = G(null), te = G(null), Y = Gt(), x = gt(), [vt, wt] = s, ee = (h == null ? void 0 : h.min) ?? Re.min, se = (h == null ? void 0 : h.max) ?? Re.max, ne = G(null), oe = typeof d == "object" ? d.step : null, ie = typeof d == "object" ? d.offset : null, re = typeof d == "object" ? null : d, [ns, os] = ut(() => Date.now());
2134
- K(() => {
2135
- if (ot !== !0) return;
2136
- const c = setInterval(() => os(Date.now()), V);
2137
- return () => clearInterval(c);
2138
- }, [ot]);
2139
- const ae = ot === !0 ? ns : typeof ot == "number" ? ot : null;
2140
- ft(() => {
2141
- const c = `${vt}|${wt}`, b = ne.current !== c;
2142
- ne.current = c;
2143
- const L = re ?? { step: oe ?? 0, offset: ie ?? 0 };
2144
- v.setOptions(
2145
- { laneHeight: r, calendar: l, zoomLimits: { min: ee, max: se }, snap: L, intents: u, now: ae, route: O, attach: H, ends: nt },
2146
- b ? [vt, wt] : null
2147
- );
2148
- }, [v, vt, wt, r, l, ee, se, re, oe, ie, u, ae, O, H, nt]), K(() => {
2149
- v.setHandlers({ onIntent: p, canMoveTo: m, onInteraction: y, onSelectedTaskChange: A, onCollapsedGroupsChange: I, onDomainChange: S });
2150
- }, [v, p, m, y, A, I, S]);
2151
- const is = G(g);
2152
- K(() => {
2153
- const c = is.current;
2154
- c !== void 0 && v.setDefaultCollapsedGroups(c);
2155
- }, [v]), K(() => {
2156
- v.setCollapsedGroups(D);
2157
- }, [v, D]), ks(
2158
- e,
2159
- () => ({
2160
- positionAt: (c, b) => v.positionAt(c, b),
2161
- clientPointOf: (c, b) => v.clientPointOf(c, b),
2162
- visibleDomain: () => v.visibleDomain()
2163
- }),
2164
- [v]
2165
- ), K(() => {
2166
- v.setControlledTask(C);
2167
- }, [v, C]), K(() => {
2168
- v.setPlacing(R ?? null);
2169
- }, [v, R]), K(() => {
2170
- const c = Zt.current, b = Jt.current, L = Qt.current, E = te.current;
2171
- if (!c || !b || !L || !E) return;
2172
- v.bind(c, b, L, E);
2173
- const _ = b.getBoundingClientRect();
2174
- v.resize(_.width, _.height);
2175
- const F = new ResizeObserver(($) => {
2176
- var pe;
2177
- const it = (pe = $[$.length - 1]) == null ? void 0 : pe.contentRect;
2178
- it !== void 0 && v.resize(it.width, it.height);
2179
- });
2180
- F.observe(b);
2181
- const P = ($) => v.wheel($);
2182
- c.addEventListener("wheel", P, { passive: !1 });
2183
- const B = ($) => {
2184
- $.key === "Escape" && v.cancelEdit() && $.preventDefault();
2185
- };
2186
- return window.addEventListener("keydown", B), () => {
2187
- window.removeEventListener("keydown", B), c.removeEventListener("wheel", P), F.disconnect(), v.unbind();
2188
- };
2189
- }, [v]);
2190
- const M = ys(v.subscribe, v.getSnapshot, v.getServerSnapshot), rs = (c, b) => {
2191
- const L = new Date(c);
2192
- return b >= 200 ? Y.dateLong(L) : b >= 84 ? Y.date(L) : b >= Ft ? Y.dateShort(L) : "";
2193
- }, as = M.days.reduce((c, b) => Math.max(c, b.width), 0), J = Cn(as, Ft), le = M.step >= q ? J : 1, T = M.ghost, Q = M.spoken, bt = M.summary, de = (c) => `${Y.dateShort(new Date(c))} ${Y.time(new Date(c), !1)}`, Mt = (c) => `${yt}-row-${encodeURIComponent(c.key)}`, ls = X(() => {
2194
- const c = /* @__PURE__ */ new Map();
2195
- for (const b of M.headers)
2196
- for (const L of b.within)
2197
- b.kind === "groupHead" && L === b.group || c.set(L, [...c.get(L) ?? [], Mt(b)]);
2198
- return c;
2199
- }, [M.headers, yt]), he = G(null), ds = `${M.width}|${M.headers.map((c) => `${c.key}:${c.kind}:${typeof c.label == "string" ? c.label : ""}`).join("|")}`;
2200
- ft(() => {
2201
- var L;
2202
- let c = !0;
2203
- const b = () => {
2204
- var F;
2205
- if (!c) return;
2206
- const E = [...((F = he.current) == null ? void 0 : F.querySelectorAll("[data-lane-count]")) ?? []];
2207
- for (const P of E) P.hidden = !1;
2208
- const _ = E.some((P) => {
2209
- const B = P.previousElementSibling;
2210
- if (!(B instanceof HTMLElement)) return !1;
2211
- const $ = parseFloat(getComputedStyle(B).lineHeight);
2212
- return B.scrollWidth > B.clientWidth || B.clientHeight > $ * 1.5;
2213
- });
2214
- for (const P of E) P.hidden = _;
2215
- };
2216
- return b(), (L = document.fonts) == null || L.ready.then(b), () => {
2217
- c = !1;
2218
- };
2219
- }, [ds]);
2220
- const hs = X(() => new Set((T == null ? void 0 : T.refusedLanes) ?? []), [T == null ? void 0 : T.refusedLanes]), ce = G(null), [Tt, cs] = ut({ x: 0, y: 0, at: "" }), It = T === null ? "" : `${T.x}:${T.y}:${T.from}:${T.to}:${T.overlap}:${T.violated}:${T.refused}:${T.blocked}`;
2221
- ft(() => {
2222
- const c = ce.current;
2223
- if (T === null || c === null) return;
2224
- const b = 4, L = T.y - c.offsetHeight - b, E = T.y + T.height + b, _ = {
2225
- x: Math.max(2, Math.min(T.x, M.width - c.offsetWidth - 2)),
2226
- y: L >= 2 ? L : Math.min(E, M.height - c.offsetHeight - 2),
2227
- at: It
2511
+ On(s, i), En(n, i);
2512
+ }
2513
+ }
2514
+ function yo(o = {}) {
2515
+ const { initialView: t, onViewChange: e } = o, [s] = tt(() => new ao(t)), [n] = tt(() => new ps()), [i] = tt(() => {
2516
+ const c = Ee((p, m) => ks(wn, { ...p, scene: s, ref: m }));
2517
+ return c.displayName = "Schedule", {
2518
+ Schedule: c,
2519
+ Lane: Mn,
2520
+ LaneGroup: Tn,
2521
+ Subtasks: In,
2522
+ Dependencies: Sn,
2523
+ BlockedTimes: Ln,
2524
+ setDomain: s.setDomain,
2525
+ toggleGroup: s.toggleGroup,
2526
+ foldAll: s.foldAll,
2527
+ unfoldAll: s.unfoldAll
2228
2528
  };
2229
- cs((F) => F.x === _.x && F.y === _.y && F.at === _.at ? F : _);
2230
- }, [T, It, M.width, M.height]);
2231
- const ue = G(null), [Ct, us] = ut({ x: 0, y: 0, at: "" }), W = M.tooltip, St = W === null ? "" : `${W.x}:${W.y}:${W.target.kind}`;
2232
- return ft(() => {
2233
- const c = ue.current;
2234
- if (W === null || c === null) return;
2235
- const b = 12, L = (_, F, P) => {
2236
- const B = _ + b, $ = _ - b - F, it = B + F <= P - 4 || $ < 4 ? B : $;
2237
- return Math.max(4, Math.min(it, P - F - 4));
2238
- }, E = {
2239
- x: L(W.x, c.offsetWidth, M.width),
2240
- y: L(W.y, c.offsetHeight, M.height),
2241
- at: St
2242
- };
2243
- us((_) => _.x === E.x && _.y === E.y && _.at === E.at ? _ : E);
2244
- }, [W, St, M.width, M.height]), /* @__PURE__ */ z($e.Provider, { value: v, children: [
2245
- /* @__PURE__ */ z(
2246
- "div",
2247
- {
2248
- ref: Zt,
2249
- role: "figure",
2250
- "aria-label": n,
2251
- className: jt ? `${w.root} ${jt}` : w.root,
2252
- style: { height: `${i}px`, gridTemplateColumns: `min(${a}px, 40%) minmax(0, 1fr)`, ...es },
2253
- children: [
2254
- /* @__PURE__ */ k("div", { className: w.corner }),
2255
- /* @__PURE__ */ k("div", { className: w.dayBand, "aria-hidden": "true", "data-schedule-days": "", "data-schedule-clip": "day band", children: M.days.map((c, b) => {
2256
- var P;
2257
- const L = J === 1 || b === 0 || _t(c.start, J), E = J === 1 ? c.x + c.width : ((P = M.days.slice(b + 1).find((B) => _t(B.start, J))) == null ? void 0 : P.x) ?? M.width, _ = Math.max(0, -c.x), F = Math.min(E, M.width) - Math.max(c.x, 0);
2258
- return /* @__PURE__ */ k("span", { className: w.day, style: { left: `${c.x}px`, width: `${L ? E - c.x : c.width}px` }, children: /* @__PURE__ */ k("span", { className: w.dayLabel, "data-schedule-overlay": "day label", style: { marginLeft: `${_}px` }, children: L ? rs(c.start, J === 1 ? F : Math.min(F, Ft)) : "" }) }, c.start);
2259
- }) }),
2260
- /* @__PURE__ */ k("div", { ref: he, className: w.headers, "data-schedule-headers": "", children: /* @__PURE__ */ k("div", { className: w.headerRun, style: { transform: `translateY(${-M.scrollY}px)` }, children: M.headers.map((c) => /* @__PURE__ */ z(
2261
- "div",
2262
- {
2263
- id: Mt(c),
2264
- className: w.header,
2265
- style: { height: `${c.height}px`, paddingLeft: `calc(var(--u-space-3) + ${c.depth} * var(--u-space-3))` },
2266
- "data-lane": c.lane,
2267
- "data-group": c.group,
2268
- "data-row": c.kind,
2269
- "data-schedule-clip": `header ${c.kind}`,
2270
- "data-refused": c.lane !== void 0 && hs.has(c.lane) ? "" : void 0,
2271
- children: [
2272
- c.kind !== "lane" && c.group !== void 0 && /* @__PURE__ */ k(
2273
- "button",
2274
- {
2275
- type: "button",
2276
- className: w.chevron,
2277
- "data-schedule-overlay": "fold control",
2278
- "aria-expanded": c.collapsed === !1,
2279
- "aria-controls": (ls.get(c.group) ?? [Mt(c)]).join(" "),
2280
- "aria-label": `${c.collapsed === !0 ? x.scheduleUnfoldGroup : x.scheduleFoldGroup}: ${typeof c.label == "string" ? c.label : c.group}`,
2281
- onClick: () => v.toggleGroup(c.group),
2282
- children: /* @__PURE__ */ k(Cs, { size: 9, "data-open": c.collapsed === !1 ? "" : void 0 })
2283
- }
2284
- ),
2285
- /* @__PURE__ */ k("span", { className: w.headerLabel, "data-schedule-overlay": "header label", children: c.label }),
2286
- c.kind !== "lane" && /* @__PURE__ */ k("span", { className: w.headerCount, "data-schedule-overlay": "lane count", "data-lane-count": c.lanes, children: x.scheduleLaneCount(c.lanes) })
2287
- ]
2288
- },
2289
- c.key
2290
- )) }) }),
2291
- /* @__PURE__ */ z(
2292
- "div",
2293
- {
2294
- ref: Jt,
2295
- className: w.plot,
2296
- "data-schedule-plot": "",
2297
- "data-schedule-clip": "plot",
2298
- style: { cursor: M.cursor },
2299
- tabIndex: 0,
2300
- role: "application",
2301
- "aria-roledescription": x.scheduleRoleDescription,
2302
- "aria-label": n,
2303
- "aria-describedby": qt,
2304
- onKeyDown: (c) => {
2305
- v.key(c.nativeEvent) && c.preventDefault();
2306
- },
2307
- onFocus: (c) => v.focus(ro(c.currentTarget)),
2308
- onBlur: () => v.blur(),
2309
- onPointerDown: (c) => v.pointerDown(c.nativeEvent),
2310
- onPointerMove: (c) => v.pointerMove(c.nativeEvent),
2311
- onPointerUp: (c) => v.pointerUp(c.nativeEvent),
2312
- onPointerCancel: (c) => v.pointerCancel(c.nativeEvent),
2313
- onPointerLeave: () => v.pointerLeave(),
2314
- onContextMenu: (c) => v.contextMenu(c.nativeEvent),
2315
- onDragOver: (c) => v.dragOver(c.nativeEvent),
2316
- onDrop: (c) => v.drop(c.nativeEvent),
2317
- onDragLeave: (c) => {
2318
- const b = c.nativeEvent.relatedTarget;
2319
- (!(b instanceof Node) || !c.currentTarget.contains(b)) && v.dragLeave();
2320
- },
2321
- children: [
2322
- /* @__PURE__ */ k("canvas", { ref: Qt, className: w.layer, "aria-hidden": "true" }),
2323
- /* @__PURE__ */ k("canvas", { ref: te, className: w.layer, "aria-hidden": "true" }),
2324
- M.grips.map((c) => /* @__PURE__ */ k(
2325
- "span",
2326
- {
2327
- "data-grip": c.kind,
2328
- "data-schedule-overlay": `${c.kind} grip`,
2329
- "aria-hidden": "true",
2330
- className: w.grip,
2331
- style: { left: `${c.x}px`, top: `${c.y}px`, height: `${c.height}px` }
2332
- },
2333
- c.kind
2334
- )),
2335
- ct !== void 0 && M.bars.map((c) => /* @__PURE__ */ k(
2336
- "span",
2337
- {
2338
- className: w.barLabel,
2339
- "data-bar-label": c.subtask.id,
2340
- "data-schedule-overlay": "bar label",
2341
- "data-schedule-may-cover": "",
2342
- "data-on": c.dark ? "dark" : "light",
2343
- style: { left: `${c.x}px`, top: `${c.y}px`, width: `${c.width}px`, height: `${c.height}px` },
2344
- children: /* @__PURE__ */ k("span", { className: w.barLabelText, children: ct(c.subtask) })
2345
- },
2346
- c.subtask.id
2347
- )),
2348
- Z !== !1 && M.tooltip !== null && /* @__PURE__ */ k(
2349
- "span",
2350
- {
2351
- ref: ue,
2352
- role: "tooltip",
2353
- className: w.tooltip,
2354
- "data-schedule-tooltip": "",
2355
- "data-schedule-overlay": "tooltip",
2356
- style: {
2357
- left: `${Ct.x}px`,
2358
- top: `${Ct.y}px`,
2359
- visibility: Ct.at === St ? void 0 : "hidden"
2360
- },
2361
- children: typeof Z == "function" ? Z(M.tooltip.target) : /* @__PURE__ */ k(no, { target: M.tooltip.target })
2362
- }
2363
- ),
2364
- T !== null && /* @__PURE__ */ z(
2365
- "span",
2366
- {
2367
- ref: ce,
2368
- className: w.ghostLabel,
2369
- "data-ghost": "",
2370
- "data-schedule-overlay": "ghost label",
2371
- "data-findings": [T.overlap ? "overlap" : "", T.violated ? "violated-dependency" : ""].filter(Boolean).join(" "),
2372
- "data-refused": T.refused ? "" : void 0,
2373
- "data-blocked": T.blocked ? "" : void 0,
2374
- style: {
2375
- left: `${Tt.x}px`,
2376
- top: `${Tt.y}px`,
2377
- visibility: Tt.at === It ? void 0 : "hidden"
2378
- },
2379
- children: [
2380
- x.scheduleGhostTimes(Y.time(new Date(T.from), !1), Y.time(new Date(T.to), !1)),
2381
- T.refused && /* @__PURE__ */ k("span", { className: w.refusal, children: x.scheduleLaneRefused }),
2382
- T.blocked && /* @__PURE__ */ k("span", { className: w.refusal, children: x.scheduleBlockedTime }),
2383
- T.overlap && /* @__PURE__ */ k("span", { className: w.finding, children: x.scheduleOverlap }),
2384
- T.violated && /* @__PURE__ */ k("span", { className: w.finding, children: x.scheduleViolatedDependency })
2385
- ]
2386
- }
2387
- ),
2388
- /* @__PURE__ */ k("span", { className: w.focusRing, "aria-hidden": "true" })
2389
- ]
2390
- }
2391
- ),
2392
- /* @__PURE__ */ k("div", { className: w.corner }),
2393
- /* @__PURE__ */ z("div", { className: w.tickBand, "aria-hidden": "true", "data-schedule-ticks": "", "data-schedule-clip": "time band", children: [
2394
- M.now !== null && /* @__PURE__ */ k("span", { className: w.now, "data-now": "", "data-schedule-overlay": "now mark", style: { left: `${M.now}px` } }),
2395
- M.ticks.map((c) => /* @__PURE__ */ k("span", { className: w.tick, style: { left: `${c.x}px` }, children: c.x >= Pe && c.x <= M.width - Pe && (le === 1 || _t(c.wallClock, le)) && /* @__PURE__ */ k("span", { className: w.tickLabel, "data-schedule-overlay": "time label", children: M.step >= q ? Y.dateShort(new Date(c.wallClock)) : Y.time(new Date(c.wallClock), !1) }) }, c.wallClock))
2396
- ] }),
2397
- /* @__PURE__ */ k(me, { "aria-live": "polite", children: Q !== null && /* @__PURE__ */ k(
2398
- so,
2399
- {
2400
- target: Q.target,
2401
- lane: Q.lane === null ? null : ((fe = v.data.lanes.find((c) => c.id === Q.lane)) == null ? void 0 : fe.label) ?? Q.lane
2402
- },
2403
- Q.count
2404
- ) }),
2405
- /* @__PURE__ */ k(me, { id: qt, children: `${x.scheduleSummary({ ...bt, from: de(bt.from), to: de(bt.to) })} ${x.scheduleKeyHelp}` })
2406
- ]
2407
- }
2408
- ),
2409
- ss
2410
- ] });
2411
- });
2412
- function ro(o) {
2413
- try {
2414
- return o.matches(":focus-visible");
2415
- } catch {
2416
- return !0;
2417
- }
2418
- }
2419
- function go({ id: o, label: t }) {
2420
- const e = Ge(), n = X(() => ({ id: o, label: t ?? o, ...e === null ? {} : { parent: e } }), [o, t, e]);
2421
- return Ls(n), null;
2422
- }
2423
- function ko({ id: o, label: t, children: e }) {
2424
- const n = Ge(), s = X(() => ({ id: o, label: t ?? o, ...n === null ? {} : { parent: n } }), [o, t, n]);
2425
- return As(s), /* @__PURE__ */ k(xe.Provider, { value: o, children: e });
2426
- }
2427
- function yo({ data: o, tasks: t }) {
2428
- const e = X(() => ({ kind: "subtasks", data: o, tasks: t }), [o, t]);
2429
- return Yt("Subtasks", e), null;
2430
- }
2431
- function vo({ data: o }) {
2432
- const t = X(() => ({ kind: "dependencies", data: o }), [o]);
2433
- return Yt("Dependencies", t), null;
2434
- }
2435
- function wo({ data: o }) {
2436
- const t = X(() => ({ kind: "blocked", data: o }), [o]);
2437
- return Yt("BlockedTimes", t), null;
2438
- }
2439
- function bo(o, t, e) {
2440
- if (e.kind === "place") return [];
2441
- const n = new Map(o.map((l) => [l.id, ke(l, e)])), s = /* @__PURE__ */ new Map();
2442
- for (const l of t) {
2443
- const h = s.get(l.from) ?? [];
2444
- h.push(l), s.set(l.from, h);
2445
- }
2446
- const i = /* @__PURE__ */ new Map(), r = [e.subtask];
2447
- let a = (o.length + 1) * (t.length + 1);
2448
- for (; r.length > 0 && a-- > 0; ) {
2449
- const l = r.shift(), h = n.get(l);
2450
- if (h !== void 0)
2451
- for (const d of s.get(l) ?? []) {
2452
- if (d.to === e.subtask) continue;
2453
- const u = n.get(d.to);
2454
- if (u === void 0) continue;
2455
- const p = zt(d, h) + d.lag - Ut(d, u);
2456
- if (!(p > 0)) continue;
2457
- const m = { kind: "move", subtask: u.id, from: u.from + p, to: u.to + p };
2458
- n.set(u.id, ke(u, m)), i.set(u.id, m), r.push(u.id);
2459
- }
2460
- }
2461
- return [...i.values()];
2462
- }
2463
- function Mo(o, t, e) {
2464
- return e === 0 || !Number.isFinite(e) ? [] : o.filter((n) => n.task === t).map((n) => ({ kind: "move", subtask: n.id, from: n.from + e, to: n.to + e }));
2529
+ }), r = Re(s.subscribeView, s.getView, s.getView), a = t === void 0 ? null : Q(t), d = G(a);
2530
+ it(() => {
2531
+ if (t === void 0 || a === null || a === d.current) return;
2532
+ d.current = a;
2533
+ const c = n.has(a);
2534
+ n.handed(a), c || s.applyView(t);
2535
+ }, [a]);
2536
+ const h = Q(r), l = G(h);
2537
+ return W(() => {
2538
+ l.current !== h && (l.current = h, s.acted && (n.reported(h), e == null || e(r)));
2539
+ }, [h]), X(() => ({ ...i, view: r }), [i, r]);
2465
2540
  }
2466
2541
  export {
2467
- wo as BlockedTimes,
2468
- vo as Dependencies,
2469
- go as Lane,
2470
- ko as LaneGroup,
2471
- mo as Schedule,
2472
- yo as Subtasks,
2473
- ke as applyIntent,
2474
- Ut as arrival,
2475
- zt as departure,
2476
- po as findings,
2477
- ze as inBlockedTime,
2478
- st as occupied,
2479
- Wt as overlaps,
2480
- kt as resolveAppearance,
2481
- bo as ripple,
2482
- Mo as shiftTask,
2483
- cn as snapTime,
2484
- fo as subtaskFromPlace,
2485
- Xt as violatedDependencies
2542
+ ce as applyIntent,
2543
+ Gt as arrival,
2544
+ $t as departure,
2545
+ mo as findings,
2546
+ Ne as inBlockedTime,
2547
+ nt as occupied,
2548
+ Ht as overlaps,
2549
+ gt as resolveAppearance,
2550
+ go as ripple,
2551
+ ko as shiftTask,
2552
+ ws as snapTime,
2553
+ po as subtaskFromPlace,
2554
+ yo as useSchedule,
2555
+ Yt as violatedDependencies
2486
2556
  };