@mintplayer/web-components 2.3.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,59 @@
1
- import { unsafeCSS as W, LitElement as B, html as U } from "lit";
2
- import { L as O } from "../chunks/live-announcer-Bi0orG4n.mjs";
3
- import { D as N, d as h, t as M, k as I, r as S, m as $, l as H, g as V } from "../chunks/color-CyamnJnn.mjs";
4
- function q(g = {}) {
5
- const e = { ...N, ...g };
1
+ import { unsafeCSS as Q, LitElement as ee, html as A, nothing as G } from "lit";
2
+ import { L as te } from "../chunks/live-announcer-Bi0orG4n.mjs";
3
+ import { D as se, q as R, d as h, u as x, i as S, t as j, o as ne, s as O, w as D, v as T, p as W, j as ie } from "../chunks/id-D5QCG603.mjs";
4
+ import { O as re } from "../chunks/overlay-controller-DPt13i8p.mjs";
5
+ function X(u, e = []) {
6
+ for (const t of u) {
7
+ if (R(t)) {
8
+ X(t.children, e);
9
+ continue;
10
+ }
11
+ for (const s of t.events ?? [])
12
+ e.push(s.resourceId ? s : { ...s, resourceId: t.id });
13
+ }
14
+ return e;
15
+ }
16
+ function q(u, e) {
17
+ const t = X(e);
18
+ if (t.length === 0) return u;
19
+ const s = /* @__PURE__ */ new Map();
20
+ for (const i of t) s.set(i.id, i);
21
+ const n = [];
22
+ for (const i of u)
23
+ s.has(i.id) && n.push(i.id), s.set(i.id, i);
24
+ return n.length > 0 && console.warn(
25
+ `[mp-scheduler] ${n.length} event id(s) appear in both the "events" input and under a resource; the "events" entry wins. Ids: ${n.join(", ")}`
26
+ ), [...s.values()];
27
+ }
28
+ function oe(u, e, t) {
29
+ const s = new Set(e), n = (i) => {
30
+ for (const r of i)
31
+ R(r) && (t.has(r.id) || (t.add(r.id), r.collapsed && s.add(r.id)), n(r.children));
32
+ };
33
+ return n(u), s;
34
+ }
35
+ function Z(u, e = /* @__PURE__ */ new Map()) {
36
+ for (const t of u)
37
+ R(t) ? Z(t.children, e) : e.set(t.id, t);
38
+ return e;
39
+ }
40
+ function ae(u) {
41
+ const e = /* @__PURE__ */ new Map();
42
+ for (const t of u) {
43
+ const s = t.resourceId ?? null, n = e.get(s);
44
+ n ? n.push(t) : e.set(s, [t]);
45
+ }
46
+ return e;
47
+ }
48
+ function le(u = {}) {
49
+ const e = { ...se, ...u };
6
50
  return {
7
51
  view: e.initialView,
8
52
  date: e.initialDate,
9
53
  events: [],
54
+ eventsByResource: /* @__PURE__ */ new Map(),
55
+ resourceById: /* @__PURE__ */ new Map(),
56
+ resolvedPermissions: {},
10
57
  resources: [],
11
58
  options: e,
12
59
  selectedEvent: null,
@@ -26,9 +73,9 @@ function q(g = {}) {
26
73
  focusedDate: null
27
74
  };
28
75
  }
29
- class Y {
76
+ class de {
30
77
  constructor(e = {}) {
31
- this.listeners = /* @__PURE__ */ new Set(), this.state = q(e);
78
+ this.listeners = /* @__PURE__ */ new Set(), this.warnedUnassignedIds = /* @__PURE__ */ new Set(), this.flatEventsInput = [], this.seededGroupIds = /* @__PURE__ */ new Set(), this.state = le(e);
32
79
  }
33
80
  /**
34
81
  * Get current state
@@ -40,8 +87,26 @@ class Y {
40
87
  * Update state with partial update or updater function
41
88
  */
42
89
  setState(e) {
43
- const t = typeof e == "function" ? e(this.state) : e;
44
- this.state = { ...this.state, ...t }, this.notifyListeners();
90
+ const t = typeof e == "function" ? e(this.state) : e, s = { ...this.state, ...t };
91
+ (s.events !== this.state.events || !this.state.eventsByResource) && (s.eventsByResource = ae(s.events)), (s.resources !== this.state.resources || !this.state.resourceById) && (s.resourceById = Z(s.resources)), this.state = s, this.warnUnassignedEvents(), this.notifyListeners();
92
+ }
93
+ /**
94
+ * `options.requireEventResource` is a DEVELOPMENT signal, not a filter: the
95
+ * event still renders in the bucket row, because hiding data a consumer handed
96
+ * us is the trap this whole area exists to avoid. One warning per id, so a
97
+ * drag that re-renders sixty times a second cannot flood the console.
98
+ */
99
+ warnUnassignedEvents() {
100
+ if (!this.state.options.requireEventResource) return;
101
+ const e = (this.state.eventsByResource?.get(null) ?? []).filter(
102
+ (t) => !this.warnedUnassignedIds.has(t.id)
103
+ );
104
+ if (e.length !== 0) {
105
+ for (const t of e) this.warnedUnassignedIds.add(t.id);
106
+ console.warn(
107
+ `[mp-scheduler] requireEventResource is set, but ${e.length} event(s) have no resourceId. They render in the "(No resource)" row. Ids: ` + e.map((t) => t.id).join(", ")
108
+ );
109
+ }
45
110
  }
46
111
  /**
47
112
  * Subscribe to state changes
@@ -70,40 +135,58 @@ class Y {
70
135
  this.setState({ date: e });
71
136
  }
72
137
  /**
73
- * Set events
138
+ * Set events. The stored `events` is the MERGE of this input and any events
139
+ * authored under resources — every view reads that one list.
74
140
  */
75
141
  setEvents(e) {
76
- this.setState({ events: e });
142
+ this.flatEventsInput = e, this.setState((t) => ({
143
+ events: q(e, t.resources)
144
+ }));
77
145
  }
78
146
  /**
79
- * Add an event
147
+ * Add an event. Lands in the single store regardless of whether it carries a
148
+ * `resourceId`, so a timeline-created event is no longer invisible.
80
149
  */
81
150
  addEvent(e) {
82
- this.setState((t) => ({
151
+ this.flatEventsInput = [...this.flatEventsInput, e], this.setState((t) => ({
83
152
  events: [...t.events, e]
84
153
  }));
85
154
  }
86
155
  /**
87
- * Update an event
156
+ * Update an event. One store, so no double-write: a move across resource rows
157
+ * is now a `resourceId` reassignment rather than a splice between two arrays.
88
158
  */
89
159
  updateEvent(e) {
90
- this.setState((t) => ({
160
+ this.flatEventsInput = this.flatEventsInput.map(
161
+ (t) => t.id === e.id ? e : t
162
+ ), this.setState((t) => ({
91
163
  events: t.events.map((s) => s.id === e.id ? e : s)
92
164
  }));
93
165
  }
94
166
  /**
95
- * Remove an event
167
+ * Remove an event. Previously filtered the flat list only, so a
168
+ * resource-nested event removed through the public API kept rendering.
96
169
  */
97
170
  removeEvent(e) {
98
- this.setState((t) => ({
171
+ this.flatEventsInput = this.flatEventsInput.filter((t) => t.id !== e), this.setState((t) => ({
99
172
  events: t.events.filter((s) => s.id !== e)
100
173
  }));
101
174
  }
102
175
  /**
103
- * Set resources
176
+ * Set resources. Re-merges so events authored under the new tree become
177
+ * visible in every view, and honours each group's authored `collapsed` flag
178
+ * (previously declared on the model and read by nothing).
104
179
  */
105
180
  setResources(e) {
106
- this.setState({ resources: e });
181
+ this.setState((t) => ({
182
+ resources: e,
183
+ events: q(this.flatEventsInput, e),
184
+ collapsedGroups: oe(
185
+ e,
186
+ t.collapsedGroups,
187
+ this.seededGroupIds
188
+ )
189
+ }));
107
190
  }
108
191
  /**
109
192
  * Toggle resource group collapse
@@ -291,12 +374,12 @@ class Y {
291
374
  this.setState({ focusedDate: e });
292
375
  }
293
376
  }
294
- function P(g, e, t = "24h") {
295
- const s = h.formatTime(g.start, t), n = h.formatTime(g.end, t), i = g.start.toLocaleDateString(void 0, { weekday: "long", month: "short", day: "numeric" }), o = [`${g.title}, ${s}–${n}`, i];
296
- return e && o.push(`on ${e}`), o.join(", ");
377
+ function z(u, e, t) {
378
+ const s = t.timeFormat ?? "24h", n = h.formatTime(u.start, s), i = h.formatTime(u.end, s), r = u.start.toLocaleDateString(t.locale, { weekday: "long", month: "short", day: "numeric" }), o = [`${u.title}, ${n}–${i}`, r];
379
+ return e && o.push(S(x(t.messages).eventOnResource, { resource: e })), o.join(", ");
297
380
  }
298
- function k(g) {
299
- const { selectionAnchor: e, selectionExtent: t, selectionResourceId: s } = g;
381
+ function K(u) {
382
+ const { selectionAnchor: e, selectionExtent: t, selectionResourceId: s } = u;
300
383
  if (!e || !t) return null;
301
384
  const n = Math.min(e.start.getTime(), t.start.getTime()), i = Math.max(e.end.getTime(), t.end.getTime());
302
385
  return {
@@ -305,32 +388,51 @@ function k(g) {
305
388
  resourceId: s
306
389
  };
307
390
  }
308
- function R(g, e, t = null) {
309
- const s = k(e);
310
- return !s || s.resourceId && t && s.resourceId !== t ? !1 : g.start.getTime() < s.end.getTime() && g.end.getTime() > s.start.getTime();
391
+ function U(u, e, t = null) {
392
+ const s = K(e);
393
+ return !s || s.resourceId && t && s.resourceId !== t ? !1 : u.start.getTime() < s.end.getTime() && u.end.getTime() > s.start.getTime();
311
394
  }
312
- function G(g, e = "24h", t = null) {
313
- const s = g.start.toLocaleDateString(void 0, {
395
+ function ce(u, e, t = null) {
396
+ const s = u.start.toLocaleDateString(e.locale, {
314
397
  weekday: "long",
315
398
  month: "short",
316
399
  day: "numeric"
317
- }), n = h.formatTime(g.start, e), i = [`${s}, ${n}`];
400
+ }), n = h.formatTime(u.start, e.timeFormat ?? "24h"), i = [`${s}, ${n}`];
318
401
  return t && i.push(t), i.join(", ");
319
402
  }
320
- function _(g, e, t = "24h") {
321
- const s = k(g);
322
- if (!s) return "";
323
- const n = `${h.formatTime(s.start, t)} ${s.start.toLocaleDateString(void 0, { weekday: "short", month: "short", day: "numeric" })}`, i = `${h.formatTime(s.end, t)} ${s.end.toLocaleDateString(void 0, { weekday: "short", month: "short", day: "numeric" })}`, o = e * 1e3, r = Math.max(1, Math.round((s.end.getTime() - s.start.getTime()) / o));
324
- return `Selection: ${n} to ${i}, ${r} slot${r === 1 ? "" : "s"}`;
403
+ function he(u, e) {
404
+ const t = K(u);
405
+ if (!t) return "";
406
+ const { options: s } = u, n = s.timeFormat ?? "24h", i = { weekday: "short", month: "short", day: "numeric" }, r = `${h.formatTime(t.start, n)} ${t.start.toLocaleDateString(s.locale, i)}`, o = `${h.formatTime(t.end, n)} ${t.end.toLocaleDateString(s.locale, i)}`, a = e * 1e3, l = Math.max(1, Math.round((t.end.getTime() - t.start.getTime()) / a)), d = x(s.messages);
407
+ return S(d.selection, {
408
+ start: r,
409
+ end: o,
410
+ count: l,
411
+ slots: l === 1 ? d.slotSingular : d.slotPlural
412
+ });
325
413
  }
326
- function X(g, e, t = "24h") {
327
- const s = g.toLocaleDateString(void 0, { weekday: "short", month: "short", day: "numeric" });
328
- return `Moved to ${h.formatTime(g, t)}–${h.formatTime(e, t)}, ${s}`;
414
+ function ue(u, e, t) {
415
+ const s = t.timeFormat ?? "24h", n = u.toLocaleDateString(t.locale, { weekday: "short", month: "short", day: "numeric" });
416
+ return S(x(t.messages).movedTo, {
417
+ start: h.formatTime(u, s),
418
+ end: h.formatTime(e, s),
419
+ day: n
420
+ });
329
421
  }
330
- function j(g, e, t, s = "24h") {
331
- return `Resized ${t} edge to ${h.formatTime(g, s)}–${h.formatTime(e, s)}`;
422
+ function pe(u, e, t, s) {
423
+ const n = s.timeFormat ?? "24h", i = x(s.messages);
424
+ return S(i.resizedEdge, {
425
+ edge: t === "start" ? i.startEdge : i.endEdge,
426
+ start: h.formatTime(u, n),
427
+ end: h.formatTime(e, n)
428
+ });
332
429
  }
333
- class x {
430
+ const ve = 40, me = 20;
431
+ function _(u, e) {
432
+ const [t = 0, s = 0, n = 0] = e.split(":").map(Number), i = new Date(u);
433
+ return i.setHours(0, 0, 0, 0), i.setSeconds(t * 3600 + s * 60 + n), i;
434
+ }
435
+ class $ {
334
436
  constructor(e, t) {
335
437
  this.container = e, this.state = t;
336
438
  }
@@ -349,6 +451,47 @@ class x {
349
451
  /**
350
452
  * Helper to create an element with classes
351
453
  */
454
+ /**
455
+ * Vertical geometry for one day-part in a time-grid column, in px.
456
+ *
457
+ * The single source of truth for BOTH committed event boxes and drag ghosts —
458
+ * they drifted apart before, which is how the ghost ended up measuring from a
459
+ * different origin than the box it was previewing.
460
+ *
461
+ * Measures from `slotMinTime`, NOT from midnight: the column's first row is
462
+ * the `slotMinTime` slot, so a midnight origin displaced every box by the
463
+ * whole hidden window (with `slotMinTime: '08:00'` a 09:00 event landed ~640px
464
+ * too low). The part is also clipped to `[slotMinTime, slotMaxTime]` on its own
465
+ * day, so a middle part of a multi-day span renders as the full visible window
466
+ * rather than 24h worth of pixels.
467
+ *
468
+ * Returns `null` when the part falls entirely outside the visible window —
469
+ * callers skip it rather than drawing a zero-height box.
470
+ */
471
+ /**
472
+ * Apply an event's fill + contrast text colour to its box.
473
+ *
474
+ * One place, so a resource's colour reaches EVERY view — week/day/month/year
475
+ * previously had no route from an event to its resource, which is why
476
+ * `Resource.color`/`eventColor` sat in the model unread.
477
+ */
478
+ applyEventColors(e, t) {
479
+ const s = j(
480
+ t,
481
+ this.state.resourceById,
482
+ this.state.options.defaultEventColor
483
+ );
484
+ e.style.backgroundColor = s, e.style.color = t.textColor ?? ne(s);
485
+ }
486
+ partGeometry(e, t, s) {
487
+ const n = s.slotDuration ?? 1800, i = _(e, s.slotMinTime ?? "00:00:00"), r = _(e, s.slotMaxTime ?? "24:00:00"), o = Math.max(e.getTime(), i.getTime()), a = Math.min(t.getTime(), r.getTime());
488
+ if (a <= o) return null;
489
+ const l = ve / (n * 1e3);
490
+ return {
491
+ top: (o - i.getTime()) * l,
492
+ height: Math.max((a - o) * l, me)
493
+ };
494
+ }
352
495
  createElement(e, ...t) {
353
496
  const s = document.createElement(e);
354
497
  return t.length > 0 && s.classList.add(...t), s;
@@ -365,6 +508,40 @@ class x {
365
508
  */
366
509
  clearContainer() {
367
510
  this.container.innerHTML = "";
511
+ for (const e of [
512
+ "role",
513
+ "aria-label",
514
+ "aria-describedby",
515
+ "aria-multiselectable",
516
+ "aria-rowcount"
517
+ ])
518
+ this.container.removeAttribute(e);
519
+ this.container.classList.remove(
520
+ "scheduler-week-view",
521
+ "scheduler-day-view",
522
+ "scheduler-month-view",
523
+ "scheduler-year-view",
524
+ "scheduler-timeline-view"
525
+ );
526
+ }
527
+ /**
528
+ * Append the start/end resize handles for an event part. The handle strip
529
+ * is the pointer hit zone the drag machine targets via
530
+ * closest('.resize-handle'); the glyph inside it is a purely decorative
531
+ * affordance revealed by the .selected class — never focusable, the
532
+ * keyboard resize path lives on the event element (move-mode).
533
+ * Position classes are per-view: ['top','bottom'] for time grids,
534
+ * ['left','right'] for the timeline.
535
+ */
536
+ appendResizeHandles(e, t, [s, n] = ["top", "bottom"]) {
537
+ const i = this.state.resolvedPermissions;
538
+ t.isStart && O("resizeEventStart", { permissions: i, event: t.event }) && e.appendChild(this.createResizeHandle(s, "start")), t.isEnd && O("resizeEventEnd", { permissions: i, event: t.event }) && e.appendChild(this.createResizeHandle(n, "end"));
539
+ }
540
+ createResizeHandle(e, t) {
541
+ const s = this.createElement("div", "resize-handle", e);
542
+ this.setData(s, { handle: t });
543
+ const n = this.createElement("span", "resize-glyph");
544
+ return n.setAttribute("aria-hidden", "true"), s.appendChild(n), s;
368
545
  }
369
546
  /**
370
547
  * Retrofit the ARIA grid chain onto a rendered view (wc-aria PRD step 5.7):
@@ -380,9 +557,9 @@ class x {
380
557
  */
381
558
  applyGridRoles(e) {
382
559
  const t = this.container;
383
- t.getAttribute("role") !== "grid" && t.setAttribute("role", "grid");
384
- const s = (n, i) => t.querySelectorAll(n).forEach((o) => {
385
- o.hasAttribute("role") || o.setAttribute("role", i);
560
+ t.getAttribute("role") !== "grid" && t.setAttribute("role", "grid"), t.setAttribute("aria-describedby", "scheduler-kbd-grid"), e.multiselectable && t.setAttribute("aria-multiselectable", "true");
561
+ const s = (n, i) => t.querySelectorAll(n).forEach((r) => {
562
+ r.hasAttribute("role") || r.setAttribute("role", i);
386
563
  });
387
564
  e.columnHeaderRow && s(e.columnHeaderRow, "row"), e.columnHeaders && s(e.columnHeaders, "columnheader"), (e.presentation ?? []).forEach((n) => s(n, "presentation")), e.rows && s(e.rows, "row"), e.cells && s(e.cells, "gridcell");
388
565
  }
@@ -391,7 +568,7 @@ class x {
391
568
  this.container.querySelectorAll(".today").forEach((e) => e.setAttribute("aria-current", "date"));
392
569
  }
393
570
  }
394
- class A extends x {
571
+ class N extends $ {
395
572
  constructor() {
396
573
  super(...arguments), this.monthCards = /* @__PURE__ */ new Map();
397
574
  }
@@ -400,8 +577,8 @@ class A extends x {
400
577
  const { date: e, options: t } = this.state, s = h.getYearMonths(e), n = this.createElement("div", "scheduler-year-grid");
401
578
  this.monthCards.clear();
402
579
  for (const i of s) {
403
- const o = this.createMonthCard(i);
404
- n.appendChild(o);
580
+ const r = this.createMonthCard(i);
581
+ n.appendChild(r);
405
582
  }
406
583
  this.container.appendChild(n), this.applyGridRoles({ rows: ".scheduler-year-grid" }), this.markToday(), this.updateMonthCardFocus();
407
584
  }
@@ -414,29 +591,29 @@ class A extends x {
414
591
  return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}`;
415
592
  }
416
593
  createMonthCard(e) {
417
- const { events: t, options: s } = this.state, n = this.createElement("div", "scheduler-year-month"), i = A.monthKey(e);
418
- n.setAttribute("role", "gridcell"), n.setAttribute("tabindex", "-1"), n.setAttribute("aria-selected", "false"), n.id = `scheduler-cell-y-${i}`, this.setData(n, { month: e.toISOString() }), this.monthCards.set(i, n);
419
- const o = this.createElement("div", "scheduler-year-month-header");
420
- o.textContent = h.getMonthName(e, s.locale), o.setAttribute("role", "button"), o.setAttribute("tabindex", "0"), this.setData(o, { month: e.toISOString() }), n.appendChild(o);
421
- const r = this.createElement("div", "scheduler-mini-month"), a = h.getMonthWeeks(e, s.firstDayOfWeek), l = a[0];
422
- for (const m of l) {
423
- const v = this.createElement("div", "scheduler-mini-day", "header");
424
- v.textContent = h.getDayName(m, s.locale, "narrow"), v.style.fontWeight = "600", v.style.color = "#666", r.appendChild(v);
425
- }
426
- const d = h.getMonthStart(e), c = h.getMonthEnd(e), u = M.filterByRange(t, d, c), p = /* @__PURE__ */ new Set();
427
- for (const m of u) {
428
- const v = new Date(m.start);
429
- for (v.setHours(0, 0, 0, 0); v <= m.end; )
430
- p.add(v.toISOString().split("T")[0]), v.setDate(v.getDate() + 1);
431
- }
432
- for (const m of a)
433
- for (const v of m) {
434
- const f = this.createElement("div", "scheduler-mini-day");
435
- f.textContent = String(v.getDate()), this.setData(f, { date: v.toISOString() }), h.isSameMonth(v, e) || f.classList.add("other-month"), h.isToday(v) && f.classList.add("today");
436
- const b = v.toISOString().split("T")[0];
437
- p.has(b) && f.classList.add("has-events"), r.appendChild(f);
594
+ const { events: t, options: s } = this.state, n = this.createElement("div", "scheduler-year-month"), i = N.monthKey(e);
595
+ n.setAttribute("role", "gridcell"), n.setAttribute("tabindex", "-1"), n.id = `scheduler-cell-y-${i}`, this.setData(n, { month: e.toISOString() }), this.monthCards.set(i, n);
596
+ const r = this.createElement("div", "scheduler-year-month-header");
597
+ r.textContent = h.getMonthName(e, s.locale), r.setAttribute("role", "button"), r.setAttribute("tabindex", "0"), this.setData(r, { month: e.toISOString() }), n.appendChild(r);
598
+ const o = this.createElement("div", "scheduler-mini-month"), a = h.getMonthWeeks(e, s.firstDayOfWeek), l = a[0];
599
+ for (const v of l) {
600
+ const f = this.createElement("div", "scheduler-mini-day", "header");
601
+ f.textContent = h.getDayName(v, s.locale, "narrow"), f.style.fontWeight = "600", f.style.color = "#666", o.appendChild(f);
602
+ }
603
+ const d = h.getMonthStart(e), c = h.getMonthEnd(e), p = D.filterByRange(t, d, c), m = /* @__PURE__ */ new Set();
604
+ for (const v of p) {
605
+ const f = new Date(v.start);
606
+ for (f.setHours(0, 0, 0, 0); f <= v.end; )
607
+ m.add(f.toISOString().split("T")[0]), f.setDate(f.getDate() + 1);
608
+ }
609
+ for (const v of a)
610
+ for (const f of v) {
611
+ const g = this.createElement("div", "scheduler-mini-day");
612
+ g.textContent = String(f.getDate()), this.setData(g, { date: f.toISOString() }), h.isSameMonth(f, e) || g.classList.add("other-month"), h.isToday(f) && g.classList.add("today");
613
+ const y = f.toISOString().split("T")[0];
614
+ m.has(y) && g.classList.add("has-events"), o.appendChild(g);
438
615
  }
439
- return n.appendChild(r), n;
616
+ return n.appendChild(o), n;
440
617
  }
441
618
  /**
442
619
  * Apply roving tabindex based on `state.focusedDate`'s month. Year-view's
@@ -446,10 +623,10 @@ class A extends x {
446
623
  updateMonthCardFocus() {
447
624
  const e = this.state.focusedDate;
448
625
  let t = !1;
449
- const s = e ? A.monthKey(e) : null;
626
+ const s = e ? N.monthKey(e) : null;
450
627
  for (const [n, i] of this.monthCards) {
451
- const o = n === s;
452
- i.setAttribute("tabindex", o ? "0" : "-1"), i.setAttribute("aria-selected", o ? "true" : "false"), o && (t = !0);
628
+ const r = n === s;
629
+ i.setAttribute("tabindex", r ? "0" : "-1"), i.removeAttribute("aria-selected"), r && (t = !0);
453
630
  }
454
631
  t || this.monthCards.values().next().value?.setAttribute("tabindex", "0");
455
632
  }
@@ -465,28 +642,28 @@ class A extends x {
465
642
  this.monthCards.clear(), this.clearContainer();
466
643
  }
467
644
  }
468
- class T extends x {
645
+ class P extends $ {
469
646
  constructor() {
470
647
  super(...arguments), this.dayCells = /* @__PURE__ */ new Map();
471
648
  }
472
649
  render() {
473
650
  this.clearContainer(), this.container.classList.add("scheduler-month-view");
474
651
  const { date: e, options: t } = this.state, s = h.getMonthWeeks(e, t.firstDayOfWeek), n = this.createElement("div", "scheduler-day-headers"), i = s[0];
475
- for (const r of i) {
652
+ for (const o of i) {
476
653
  const a = this.createElement("div", "scheduler-day-header");
477
- a.textContent = h.getDayName(r, t.locale), n.appendChild(a);
654
+ a.textContent = h.getDayName(o, t.locale), n.appendChild(a);
478
655
  }
479
656
  this.container.appendChild(n);
480
- const o = this.createElement("div", "scheduler-month-grid");
481
- for (const r of s) {
657
+ const r = this.createElement("div", "scheduler-month-grid");
658
+ for (const o of s) {
482
659
  const a = this.createElement("div", "scheduler-month-week");
483
- for (const l of r) {
660
+ for (const l of o) {
484
661
  const d = this.createDayCell(l);
485
662
  a.appendChild(d);
486
663
  }
487
- o.appendChild(a);
664
+ r.appendChild(a);
488
665
  }
489
- this.container.appendChild(o), this.renderEvents(), this.updateDayCellFocus(), this.applyGridRoles({
666
+ this.container.appendChild(r), this.renderEvents(), this.updateDayCellFocus(), this.applyGridRoles({
490
667
  columnHeaderRow: ":scope > .scheduler-day-headers",
491
668
  columnHeaders: ".scheduler-day-headers > .scheduler-day-header",
492
669
  presentation: [".scheduler-month-grid"],
@@ -505,12 +682,12 @@ class T extends x {
505
682
  createDayCell(e) {
506
683
  const { date: t } = this.state, s = this.createElement("div", "scheduler-month-day");
507
684
  h.isSameMonth(e, t) || s.classList.add("other-month"), h.isToday(e) && s.classList.add("today");
508
- const n = T.dayKey(e);
509
- s.setAttribute("role", "gridcell"), s.setAttribute("tabindex", "-1"), s.setAttribute("aria-selected", "false"), s.id = `scheduler-cell-m-${n}`;
685
+ const n = P.dayKey(e);
686
+ s.setAttribute("role", "gridcell"), s.setAttribute("tabindex", "-1"), s.id = `scheduler-cell-m-${n}`;
510
687
  const i = this.createElement("div", "day-number");
511
688
  i.textContent = String(e.getDate()), s.appendChild(i);
512
- const o = this.createElement("div", "month-events");
513
- return s.appendChild(o), this.dayCells.set(n, s), this.setData(s, { date: n }), s;
689
+ const r = this.createElement("div", "month-events");
690
+ return s.appendChild(r), this.dayCells.set(n, s), this.setData(s, { date: n }), s;
514
691
  }
515
692
  /**
516
693
  * Apply roving tabindex based on `state.focusedDate`. The grid must always
@@ -520,41 +697,44 @@ class T extends x {
520
697
  updateDayCellFocus() {
521
698
  const e = this.state.focusedDate;
522
699
  let t = !1;
523
- const s = e ? T.dayKey(e) : null;
700
+ const s = e ? P.dayKey(e) : null;
524
701
  for (const [n, i] of this.dayCells) {
525
- const o = n === s;
526
- i.setAttribute("tabindex", o ? "0" : "-1"), i.setAttribute("aria-selected", o ? "true" : "false"), o && (t = !0);
702
+ const r = n === s;
703
+ i.setAttribute("tabindex", r ? "0" : "-1"), i.removeAttribute("aria-selected"), r && (t = !0);
527
704
  }
528
705
  t || (Array.from(this.dayCells.values()).find((i) => i.classList.contains("today") && !i.classList.contains("other-month")) || Array.from(this.dayCells.values()).find((i) => !i.classList.contains("other-month")) || this.dayCells.values().next().value)?.setAttribute("tabindex", "0");
529
706
  }
530
707
  renderEvents() {
531
708
  const { date: e, events: t, options: s } = this.state;
532
709
  h.getMonthStart(e), h.getMonthEnd(e);
533
- const n = h.getMonthWeeks(e, s.firstDayOfWeek), i = n[0][0], o = n[n.length - 1][6];
534
- o.setHours(23, 59, 59, 999);
535
- const r = M.filterByRange(t, i, o), a = /* @__PURE__ */ new Map();
536
- for (const d of r) {
537
- const c = new Date(d.start), u = new Date(d.end), p = new Date(c);
538
- for (p.setHours(0, 0, 0, 0); p <= u; ) {
539
- const m = T.dayKey(p);
540
- a.has(m) || a.set(m, []), a.get(m).push(d), p.setDate(p.getDate() + 1);
710
+ const n = h.getMonthWeeks(e, s.firstDayOfWeek), i = n[0][0], r = n[n.length - 1][6];
711
+ r.setHours(23, 59, 59, 999);
712
+ const o = D.filterByRange(t, i, r), a = /* @__PURE__ */ new Map();
713
+ for (const d of o) {
714
+ const c = new Date(d.start), p = new Date(d.end), m = new Date(c);
715
+ for (m.setHours(0, 0, 0, 0); m <= p; ) {
716
+ const v = P.dayKey(m);
717
+ a.has(v) || a.set(v, []), a.get(v).push(d), m.setDate(m.getDate() + 1);
541
718
  }
542
719
  }
543
- const l = typeof s.dayMaxEvents == "number" ? s.dayMaxEvents : 3;
720
+ const l = typeof s.dayMaxEvents == "number" ? s.dayMaxEvents : s.dayMaxEvents === !1 ? Number.POSITIVE_INFINITY : 3;
544
721
  for (const [d, c] of a) {
545
- const u = this.dayCells.get(d);
546
- if (!u) continue;
547
- const p = u.querySelector(".month-events");
722
+ const p = this.dayCells.get(d);
548
723
  if (!p) continue;
549
- p.innerHTML = "";
550
- const m = c.slice(0, l), v = c.length - m.length;
551
- for (const f of m) {
552
- const b = this.createElement("div", "scheduler-month-event");
553
- b.textContent = f.title, b.style.backgroundColor = f.color ?? "#3788d8", b.style.color = f.textColor ?? I(f.color ?? "#3788d8"), b.setAttribute("role", "button"), b.setAttribute("tabindex", "0"), b.setAttribute("aria-label", P(f, null, this.state.options.timeFormat)), this.setData(b, { eventId: f.id }), p.appendChild(b);
724
+ const m = p.querySelector(".month-events");
725
+ if (!m) continue;
726
+ m.innerHTML = "";
727
+ const v = c.slice(0, l), f = c.length - v.length;
728
+ for (const g of v) {
729
+ const y = this.createElement("div", "scheduler-month-event");
730
+ y.textContent = g.title, this.applyEventColors(y, g), y.setAttribute("role", "button"), y.setAttribute("tabindex", "0"), y.setAttribute("aria-label", z(g, null, this.state.options)), this.setData(y, { eventId: g.id }), m.appendChild(y);
554
731
  }
555
- if (v > 0) {
556
- const f = this.createElement("div", "scheduler-more-link");
557
- f.textContent = `+${v} more`, f.setAttribute("role", "button"), f.setAttribute("tabindex", "0"), this.setData(f, { date: d }), p.appendChild(f);
732
+ if (f > 0) {
733
+ const g = this.createElement("div", "scheduler-more-link");
734
+ g.textContent = S(
735
+ x(this.state.options.messages).moreEvents,
736
+ { count: f }
737
+ ), g.setAttribute("role", "button"), g.setAttribute("tabindex", "0"), this.setData(g, { date: d }), m.appendChild(g);
558
738
  }
559
739
  }
560
740
  }
@@ -573,7 +753,15 @@ class T extends x {
573
753
  this.dayCells.clear(), this.clearContainer();
574
754
  }
575
755
  }
576
- class J extends x {
756
+ function Y(u, e) {
757
+ const t = new Date(u.start);
758
+ t.setHours(0, 0, 0, 0);
759
+ const s = u.start.getTime() - t.getTime(), n = u.end.getTime() - u.start.getTime(), i = new Date(e);
760
+ i.setHours(0, 0, 0, 0);
761
+ const r = i.getTime() + s;
762
+ return { start: new Date(r), end: new Date(r + n) };
763
+ }
764
+ class ge extends $ {
577
765
  constructor() {
578
766
  super(...arguments), this.dayColumns = [], this.eventElements = /* @__PURE__ */ new Map(), this.slotElements = /* @__PURE__ */ new Map();
579
767
  }
@@ -584,13 +772,13 @@ class J extends x {
584
772
  for (const d of s) {
585
773
  const c = this.createElement("div", "scheduler-day-header");
586
774
  h.isToday(d) && c.classList.add("today");
587
- const u = this.createElement("div", "day-name");
588
- u.textContent = h.getDayName(d, t.locale);
589
- const p = this.createElement("div", "day-number");
590
- p.textContent = String(d.getDate()), c.appendChild(u), c.appendChild(p), n.appendChild(c);
775
+ const p = this.createElement("div", "day-name");
776
+ p.textContent = h.getDayName(d, t.locale);
777
+ const m = this.createElement("div", "day-number");
778
+ m.textContent = String(d.getDate()), c.appendChild(p), c.appendChild(m), n.appendChild(c);
591
779
  }
592
780
  this.container.appendChild(n);
593
- const o = this.createElement("div", "scheduler-time-grid"), r = this.createElement("div", "scheduler-time-gutter"), a = h.getTimeSlots(
781
+ const r = this.createElement("div", "scheduler-time-grid"), o = this.createElement("div", "scheduler-time-gutter"), a = h.getTimeSlots(
594
782
  s[0],
595
783
  t.slotDuration,
596
784
  t.slotMinTime,
@@ -598,43 +786,30 @@ class J extends x {
598
786
  );
599
787
  for (const d of a) {
600
788
  const c = this.createElement("div", "scheduler-time-slot-label");
601
- c.textContent = h.formatTime(d.start, t.timeFormat), r.appendChild(c);
789
+ c.textContent = h.formatTime(d.start, t.timeFormat), o.appendChild(c);
602
790
  }
603
- o.appendChild(r);
791
+ r.appendChild(o);
604
792
  const l = this.createElement("div", "scheduler-days-container");
605
793
  this.dayColumns = [];
606
794
  for (let d = 0; d < s.length; d++) {
607
- const c = s[d], u = this.createElement("div", "scheduler-day-column");
608
- this.setData(u, { dayIndex: d });
609
- for (let m = 0; m < a.length; m++) {
610
- const v = a[m], f = new Date(c);
611
- f.setHours(
612
- v.start.getHours(),
613
- v.start.getMinutes(),
614
- 0,
615
- 0
616
- );
617
- const b = new Date(c);
618
- b.setHours(
619
- v.end.getHours(),
620
- v.end.getMinutes(),
621
- 0,
622
- 0
623
- );
624
- const y = this.createElement("div", "scheduler-time-slot");
625
- y.setAttribute("role", "gridcell"), y.setAttribute("tabindex", "-1"), y.setAttribute("aria-selected", "false"), y.id = `scheduler-cell-w-${d}-${m}`, this.setData(y, {
795
+ const c = s[d], p = this.createElement("div", "scheduler-day-column");
796
+ this.setData(p, { dayIndex: d });
797
+ for (let v = 0; v < a.length; v++) {
798
+ const f = a[v], { start: g, end: y } = Y(f, c), w = this.createElement("div", "scheduler-time-slot");
799
+ w.setAttribute("role", "gridcell"), w.setAttribute("tabindex", "-1"), w.setAttribute("aria-selected", "false"), w.id = `scheduler-cell-w-${d}-${v}`, this.setData(w, {
626
800
  dayIndex: d,
627
- slotIndex: m,
628
- start: f.toISOString(),
629
- end: b.toISOString()
801
+ slotIndex: v,
802
+ start: g.toISOString(),
803
+ end: y.toISOString()
630
804
  });
631
- const w = `${d}-${m}`;
632
- this.slotElements.set(w, y), u.appendChild(y);
805
+ const E = `${d}-${v}`;
806
+ this.slotElements.set(E, w), p.appendChild(w);
633
807
  }
634
- const p = this.createElement("div", "scheduler-events-container");
635
- u.appendChild(p), this.dayColumns.push(u), l.appendChild(u);
808
+ const m = this.createElement("div", "scheduler-events-container");
809
+ p.appendChild(m), this.dayColumns.push(p), l.appendChild(p);
636
810
  }
637
- o.appendChild(l), this.container.appendChild(o), this.renderEvents(), this.updateCellFocusAndSelection(), this.renderNowIndicator(s, a), this.applyGridRoles({
811
+ r.appendChild(l), this.container.appendChild(r), this.renderEvents(), this.updateCellFocusAndSelection(), this.renderNowIndicator(s, a), this.applyGridRoles({
812
+ multiselectable: !0,
638
813
  columnHeaderRow: ":scope > .scheduler-day-headers",
639
814
  columnHeaders: ".scheduler-day-headers > .scheduler-day-header",
640
815
  presentation: [
@@ -672,11 +847,11 @@ class J extends x {
672
847
  let t = !1, s = null;
673
848
  for (const [, n] of this.slotElements) {
674
849
  s || (s = n);
675
- const i = n.dataset.start, o = n.dataset.end;
676
- if (!i || !o) continue;
677
- const r = { start: new Date(i), end: new Date(o) }, a = !!e && r.start.getTime() === e.start.getTime();
850
+ const i = n.dataset.start, r = n.dataset.end;
851
+ if (!i || !r) continue;
852
+ const o = { start: new Date(i), end: new Date(r) }, a = !!e && o.start.getTime() === e.start.getTime();
678
853
  n.setAttribute("tabindex", a ? "0" : "-1");
679
- const l = R(r, this.state, null);
854
+ const l = U(o, this.state, null);
680
855
  n.setAttribute("aria-selected", l ? "true" : "false"), n.classList.toggle("selected", l), a && (t = !0);
681
856
  }
682
857
  !t && s && s.setAttribute("tabindex", "0");
@@ -685,101 +860,87 @@ class J extends x {
685
860
  return e.slotDuration !== t.slotDuration || e.timeFormat !== t.timeFormat || e.firstDayOfWeek !== t.firstDayOfWeek || e.slotMinTime !== t.slotMinTime || e.slotMaxTime !== t.slotMaxTime || e.locale !== t.locale;
686
861
  }
687
862
  renderEvents() {
688
- const { date: e, events: t, options: s } = this.state, n = h.getWeekDays(e, s.firstDayOfWeek), i = n[0], o = new Date(n[6]);
689
- o.setHours(23, 59, 59, 999);
690
- const r = M.filterByRange(t, i, o), a = [];
691
- for (const c of r) {
692
- const { parts: u } = M.splitInParts(c);
693
- a.push(...u);
694
- }
695
- const l = M.filterPartsByRange(a, i, o), d = M.getTimelinedParts(l);
863
+ const { date: e, events: t, options: s } = this.state, n = h.getWeekDays(e, s.firstDayOfWeek), i = n[0], r = new Date(n[6]);
864
+ r.setHours(23, 59, 59, 999);
865
+ const o = D.filterByRange(t, i, r), a = [];
866
+ for (const c of o) {
867
+ const { parts: p } = D.splitInParts(c);
868
+ a.push(...p);
869
+ }
870
+ const l = D.filterPartsByRange(a, i, r), d = D.getTimelinedParts(l);
696
871
  this.eventElements.forEach((c) => c.remove()), this.eventElements.clear();
697
- for (const { part: c, trackIndex: u, totalTracks: p, colspan: m } of d) {
872
+ for (const { part: c, trackIndex: p, totalTracks: m, colspan: v } of d) {
698
873
  if (!c.event) continue;
699
- const v = n.findIndex((w) => h.isSameDay(w, c.start));
700
- if (v === -1) continue;
701
- const b = this.dayColumns[v].querySelector(".scheduler-events-container");
702
- if (!b) continue;
703
- const y = this.createEventElement(
874
+ const f = n.findIndex((E) => h.isSameDay(E, c.start));
875
+ if (f === -1) continue;
876
+ const y = this.dayColumns[f].querySelector(".scheduler-events-container");
877
+ if (!y) continue;
878
+ const w = this.createEventElement(
704
879
  c,
705
- u,
706
880
  p,
707
881
  m,
882
+ v,
708
883
  s.slotDuration ?? 1800
709
884
  );
710
- b.appendChild(y), this.eventElements.set(c.id, y);
885
+ y.appendChild(w), this.eventElements.set(c.id, w);
711
886
  }
712
887
  }
713
888
  createEventElement(e, t, s, n, i) {
714
- const o = e.event, r = this.createElement("div", "scheduler-event"), a = this.state.selectedEvent?.id === o.id;
715
- this.state.keyboardMoveEventId, o.id, r.setAttribute("role", "button"), r.setAttribute("tabindex", "0"), r.setAttribute(
889
+ const r = e.event, o = this.createElement("div", "scheduler-event"), a = this.state.selectedEvent?.id === r.id;
890
+ this.state.keyboardMoveEventId, r.id, o.setAttribute("role", "button"), o.setAttribute("tabindex", "0"), o.setAttribute(
716
891
  "aria-label",
717
- P(o, null, this.state.options.timeFormat)
718
- ), r.setAttribute("aria-pressed", a ? "true" : "false"), a && r.classList.add("selected");
719
- const l = new Date(e.start);
720
- l.setHours(0, 0, 0, 0);
721
- const d = (e.start.getTime() - l.getTime()) / (1e3 * 60), u = (e.end.getTime() - l.getTime()) / (1e3 * 60) - d, p = i / 60, m = d / p * 40, v = Math.max(u / p * 40, 20), f = t / s * 100, b = n / s * 100;
722
- r.style.top = `${m}px`, r.style.height = `${v}px`, r.style.left = `${f}%`, r.style.width = `calc(${b}% - 2px)`, r.style.backgroundColor = o.color ?? "#3788d8", r.style.color = o.textColor ?? I(o.color ?? "#3788d8"), this.setData(r, { eventId: o.id });
723
- const y = this.createElement("div", "event-title");
724
- y.textContent = o.title, r.appendChild(y);
725
- const w = this.createElement("div", "event-time");
726
- if (w.textContent = `${h.formatTime(e.start, this.state.options.timeFormat)} - ${h.formatTime(e.end, this.state.options.timeFormat)}`, r.appendChild(w), o.resizable !== !1) {
727
- if (e.isStart) {
728
- const E = this.createElement("div", "resize-handle", "top");
729
- this.setData(E, { handle: "start" }), r.appendChild(E);
730
- }
731
- if (e.isEnd) {
732
- const E = this.createElement("div", "resize-handle", "bottom");
733
- this.setData(E, { handle: "end" }), r.appendChild(E);
734
- }
735
- }
736
- return r;
892
+ z(r, null, this.state.options)
893
+ ), o.setAttribute("aria-pressed", a ? "true" : "false"), o.setAttribute("aria-describedby", "scheduler-kbd-event"), a && o.classList.add("selected");
894
+ const l = this.partGeometry(e.start, e.end, {
895
+ ...this.state.options,
896
+ slotDuration: i
897
+ }), { top: d, height: c } = l ?? { top: 0, height: 0 }, p = t / s * 100, m = n / s * 100;
898
+ o.style.top = `${d}px`, o.style.height = `${c}px`, o.style.left = `${p}%`, o.style.width = `calc(${m}% - 2px)`, this.applyEventColors(o, r), this.setData(o, { eventId: r.id });
899
+ const v = this.createElement("div", "event-content"), f = this.createElement("div", "event-title");
900
+ f.textContent = r.title, v.appendChild(f);
901
+ const g = this.createElement("div", "event-time");
902
+ return g.textContent = `${h.formatTime(e.start, this.state.options.timeFormat)} - ${h.formatTime(e.end, this.state.options.timeFormat)}`, v.appendChild(g), o.appendChild(v), this.appendResizeHandles(o, e), o;
737
903
  }
904
+ /**
905
+ * Dashed ghost showing where the dragged/created range will land — ONE box per
906
+ * day it spans, mirroring how a committed multi-day event splits into parts.
907
+ * A single box measured from the start day's midnight produced a ~2900px-tall
908
+ * box hanging out of the first column for a 3-day range.
909
+ */
738
910
  renderPreviewEvent() {
739
- const e = this.container.querySelector(".scheduler-event.preview");
740
- e && e.remove();
741
- const { previewEvent: t, options: s, date: n } = this.state;
742
- if (!t) return;
743
- const o = h.getWeekDays(n, s.firstDayOfWeek).findIndex((b) => h.isSameDay(b, t.start));
744
- if (o === -1) return;
745
- const a = this.dayColumns[o]?.querySelector(".scheduler-events-container");
746
- if (!a) return;
747
- const l = this.createElement("div", "scheduler-event", "preview"), d = new Date(t.start);
748
- d.setHours(0, 0, 0, 0);
749
- const c = (t.start.getTime() - d.getTime()) / (1e3 * 60), p = (t.end.getTime() - d.getTime()) / (1e3 * 60) - c, m = (s.slotDuration ?? 1800) / 60, v = c / m * 40, f = Math.max(p / m * 40, 20);
750
- l.style.top = `${v}px`, l.style.height = `${f}px`, l.style.left = "0", l.style.width = "100%", a.appendChild(l);
911
+ this.container.querySelectorAll(".scheduler-event.preview").forEach((r) => r.remove());
912
+ const { previewEvent: e, options: t, date: s } = this.state;
913
+ if (!e) return;
914
+ const n = h.getWeekDays(s, t.firstDayOfWeek), { parts: i } = D.splitInParts(e);
915
+ for (const r of i) {
916
+ const o = n.findIndex((c) => h.isSameDay(c, r.start));
917
+ if (o === -1) continue;
918
+ const a = this.dayColumns[o]?.querySelector(".scheduler-events-container");
919
+ if (!a) continue;
920
+ const l = this.partGeometry(r.start, r.end, t);
921
+ if (!l) continue;
922
+ const d = this.createElement("div", "scheduler-event", "preview");
923
+ r.isStart || d.classList.add("preview-continues-before"), r.isEnd || d.classList.add("preview-continues-after"), d.style.top = `${l.top}px`, d.style.height = `${l.height}px`, d.style.left = "0", d.style.width = "100%", a.appendChild(d);
924
+ }
751
925
  }
752
926
  updateGreyedSlots() {
753
927
  const { dragState: e, previewEvent: t, options: s, date: n } = this.state;
754
- if (this.slotElements.forEach((r) => r.classList.remove("greyed")), !e || !t) return;
755
- const i = h.getWeekDays(n, s.firstDayOfWeek), o = h.getTimeSlots(
928
+ if (this.slotElements.forEach((o) => o.classList.remove("greyed")), !e || !t) return;
929
+ const i = h.getWeekDays(n, s.firstDayOfWeek), r = h.getTimeSlots(
756
930
  i[0],
757
931
  s.slotDuration,
758
932
  s.slotMinTime,
759
933
  s.slotMaxTime
760
934
  );
761
- for (let r = 0; r < i.length; r++) {
762
- const a = i[r];
763
- if (!(!h.isSameDay(a, t.start) && !h.isSameDay(a, t.end)))
764
- for (let l = 0; l < o.length; l++) {
765
- const d = o[l], c = new Date(a);
766
- c.setHours(
767
- d.start.getHours(),
768
- d.start.getMinutes(),
769
- 0,
770
- 0
771
- );
772
- const u = new Date(a);
773
- if (u.setHours(
774
- d.end.getHours(),
775
- d.end.getMinutes(),
776
- 0,
777
- 0
778
- ), c < t.end && u > t.start) {
779
- const p = `${r}-${l}`, m = this.slotElements.get(p);
780
- m && m.classList.add("greyed");
781
- }
935
+ for (let o = 0; o < i.length; o++) {
936
+ const a = i[o];
937
+ for (let l = 0; l < r.length; l++) {
938
+ const d = r[l], { start: c, end: p } = Y(d, a);
939
+ if (c < t.end && p > t.start) {
940
+ const m = `${o}-${l}`, v = this.slotElements.get(m);
941
+ v && v.classList.add("greyed");
782
942
  }
943
+ }
783
944
  }
784
945
  }
785
946
  renderNowIndicator(e, t) {
@@ -788,32 +949,32 @@ class J extends x {
788
949
  if (n === -1) return;
789
950
  const i = this.dayColumns[n];
790
951
  if (!i) return;
791
- const o = new Date(s);
792
- o.setHours(0, 0, 0, 0);
793
- const r = (s.getTime() - o.getTime()) / (1e3 * 60), a = (this.state.options.slotDuration ?? 1800) / 60, l = r / a * 40, d = this.createElement("div", "scheduler-now-indicator");
952
+ const r = new Date(s);
953
+ r.setHours(0, 0, 0, 0);
954
+ const o = (s.getTime() - r.getTime()) / (1e3 * 60), a = (this.state.options.slotDuration ?? 1800) / 60, l = o / a * 40, d = this.createElement("div", "scheduler-now-indicator");
794
955
  d.style.top = `${l}px`, i.appendChild(d);
795
956
  }
796
957
  updateNowIndicator() {
797
958
  if (!this.state.options.nowIndicator) return;
798
- const { date: e, options: t } = this.state, s = h.getWeekDays(e, t.firstDayOfWeek), n = /* @__PURE__ */ new Date(), i = s.findIndex((u) => h.isSameDay(u, n));
959
+ const { date: e, options: t } = this.state, s = h.getWeekDays(e, t.firstDayOfWeek), n = /* @__PURE__ */ new Date(), i = s.findIndex((p) => h.isSameDay(p, n));
799
960
  if (i === -1) return;
800
- const o = this.dayColumns[i];
801
- if (!o) return;
802
- const r = o.querySelector(".scheduler-now-indicator"), a = new Date(n);
961
+ const r = this.dayColumns[i];
962
+ if (!r) return;
963
+ const o = r.querySelector(".scheduler-now-indicator"), a = new Date(n);
803
964
  a.setHours(0, 0, 0, 0);
804
965
  const l = (n.getTime() - a.getTime()) / (1e3 * 60), d = (t.slotDuration ?? 1800) / 60, c = l / d * 40;
805
- if (r)
806
- r.style.top = `${c}px`;
966
+ if (o)
967
+ o.style.top = `${c}px`;
807
968
  else {
808
- const u = this.createElement("div", "scheduler-now-indicator");
809
- u.style.top = `${c}px`, o.appendChild(u);
969
+ const p = this.createElement("div", "scheduler-now-indicator");
970
+ p.style.top = `${c}px`, r.appendChild(p);
810
971
  }
811
972
  }
812
973
  destroy() {
813
974
  this.eventElements.clear(), this.slotElements.clear(), this.dayColumns = [], this.clearContainer();
814
975
  }
815
976
  }
816
- class Z extends x {
977
+ class fe extends $ {
817
978
  constructor() {
818
979
  super(...arguments), this.eventsContainer = null, this.slotElements = /* @__PURE__ */ new Map(), this.dayColumn = null;
819
980
  }
@@ -823,38 +984,39 @@ class Z extends x {
823
984
  n.style.width = "var(--scheduler-time-gutter-width)", s.appendChild(n);
824
985
  const i = this.createElement("div", "scheduler-day-header");
825
986
  h.isToday(e) && i.classList.add("today");
826
- const o = this.createElement("div", "day-name");
827
- o.textContent = h.getDayName(e, t.locale);
828
- const r = this.createElement("div", "day-number");
829
- r.textContent = String(e.getDate());
987
+ const r = this.createElement("div", "day-name");
988
+ r.textContent = h.getDayName(e, t.locale);
989
+ const o = this.createElement("div", "day-number");
990
+ o.textContent = String(e.getDate());
830
991
  const a = this.createElement("div", "month-year");
831
992
  a.textContent = h.formatDate(e, t.locale, {
832
993
  month: "long",
833
994
  year: "numeric"
834
- }), a.style.fontSize = "12px", a.style.color = "#666", i.appendChild(o), i.appendChild(r), i.appendChild(a), s.appendChild(i), this.container.appendChild(s);
995
+ }), a.style.fontSize = "12px", a.style.color = "#666", i.appendChild(r), i.appendChild(o), i.appendChild(a), s.appendChild(i), this.container.appendChild(s);
835
996
  const l = this.createElement("div", "scheduler-time-grid"), d = this.createElement("div", "scheduler-time-gutter"), c = h.getTimeSlots(
836
997
  e,
837
998
  t.slotDuration,
838
999
  t.slotMinTime,
839
1000
  t.slotMaxTime
840
1001
  );
841
- for (const m of c) {
842
- const v = this.createElement("div", "scheduler-time-slot-label");
843
- v.textContent = h.formatTime(m.start, t.timeFormat), d.appendChild(v);
1002
+ for (const v of c) {
1003
+ const f = this.createElement("div", "scheduler-time-slot-label");
1004
+ f.textContent = h.formatTime(v.start, t.timeFormat), d.appendChild(f);
844
1005
  }
845
1006
  l.appendChild(d);
846
- const u = this.createElement("div", "scheduler-days-container");
1007
+ const p = this.createElement("div", "scheduler-days-container");
847
1008
  this.dayColumn = this.createElement("div", "scheduler-day-column");
848
- const p = this.dayColumn;
849
- for (let m = 0; m < c.length; m++) {
850
- const v = c[m], f = this.createElement("div", "scheduler-time-slot");
851
- f.setAttribute("role", "gridcell"), f.setAttribute("tabindex", "-1"), f.setAttribute("aria-selected", "false"), f.id = `scheduler-cell-d-${m}`, this.setData(f, {
852
- slotIndex: m,
853
- start: v.start.toISOString(),
854
- end: v.end.toISOString()
855
- }), this.slotElements.set(m, f), p.appendChild(f);
856
- }
857
- this.eventsContainer = this.createElement("div", "scheduler-events-container"), p.appendChild(this.eventsContainer), u.appendChild(p), l.appendChild(u), this.container.appendChild(l), this.renderEvents(), this.updateCellFocusAndSelection(), h.isToday(e) && t.nowIndicator && this.renderNowIndicator(p), this.applyGridRoles({
1009
+ const m = this.dayColumn;
1010
+ for (let v = 0; v < c.length; v++) {
1011
+ const f = c[v], g = this.createElement("div", "scheduler-time-slot");
1012
+ g.setAttribute("role", "gridcell"), g.setAttribute("tabindex", "-1"), g.setAttribute("aria-selected", "false"), g.id = `scheduler-cell-d-${v}`, this.setData(g, {
1013
+ slotIndex: v,
1014
+ start: f.start.toISOString(),
1015
+ end: f.end.toISOString()
1016
+ }), this.slotElements.set(v, g), m.appendChild(g);
1017
+ }
1018
+ this.eventsContainer = this.createElement("div", "scheduler-events-container"), m.appendChild(this.eventsContainer), p.appendChild(m), l.appendChild(p), this.container.appendChild(l), this.renderEvents(), this.updateCellFocusAndSelection(), h.isToday(e) && t.nowIndicator && this.renderNowIndicator(m), this.applyGridRoles({
1019
+ multiselectable: !0,
858
1020
  columnHeaderRow: ":scope > .scheduler-day-headers",
859
1021
  columnHeaders: ".scheduler-day-headers > .scheduler-day-header",
860
1022
  presentation: [
@@ -881,11 +1043,11 @@ class Z extends x {
881
1043
  let t = !1, s = null;
882
1044
  for (const [, n] of this.slotElements) {
883
1045
  s || (s = n);
884
- const i = n.dataset.start, o = n.dataset.end;
885
- if (!i || !o) continue;
886
- const r = { start: new Date(i), end: new Date(o) }, a = !!e && r.start.getTime() === e.start.getTime();
1046
+ const i = n.dataset.start, r = n.dataset.end;
1047
+ if (!i || !r) continue;
1048
+ const o = { start: new Date(i), end: new Date(r) }, a = !!e && o.start.getTime() === e.start.getTime();
887
1049
  n.setAttribute("tabindex", a ? "0" : "-1");
888
- const l = R(r, this.state, null);
1050
+ const l = U(o, this.state, null);
889
1051
  n.setAttribute("aria-selected", l ? "true" : "false"), n.classList.toggle("selected", l), a && (t = !0);
890
1052
  }
891
1053
  !t && s && s.setAttribute("tabindex", "0");
@@ -897,61 +1059,52 @@ class Z extends x {
897
1059
  n.setHours(0, 0, 0, 0);
898
1060
  const i = new Date(e);
899
1061
  i.setHours(23, 59, 59, 999);
900
- const o = M.filterByRange(t, n, i), r = [];
901
- for (const l of o) {
902
- const { parts: d } = M.splitInParts(l), c = M.filterPartsByRange(d, n, i);
903
- r.push(...c);
1062
+ const r = D.filterByRange(t, n, i), o = [];
1063
+ for (const l of r) {
1064
+ const { parts: d } = D.splitInParts(l), c = D.filterPartsByRange(d, n, i);
1065
+ o.push(...c);
904
1066
  }
905
- const a = M.getTimelinedParts(r);
906
- for (const { part: l, trackIndex: d, totalTracks: c, colspan: u } of a) {
1067
+ const a = D.getTimelinedParts(o);
1068
+ for (const { part: l, trackIndex: d, totalTracks: c, colspan: p } of a) {
907
1069
  if (!l.event) continue;
908
- const p = this.createEventElement(
1070
+ const m = this.createEventElement(
909
1071
  l,
910
1072
  d,
911
1073
  c,
912
- u,
1074
+ p,
913
1075
  s.slotDuration ?? 1800
914
1076
  );
915
- this.eventsContainer.appendChild(p);
1077
+ this.eventsContainer.appendChild(m);
916
1078
  }
917
1079
  }
918
1080
  createEventElement(e, t, s, n, i) {
919
- const o = e.event, r = this.createElement("div", "scheduler-event"), a = this.state.selectedEvent?.id === o.id;
920
- this.state.keyboardMoveEventId, o.id, r.setAttribute("role", "button"), r.setAttribute("tabindex", "0"), r.setAttribute(
1081
+ const r = e.event, o = this.createElement("div", "scheduler-event"), a = this.state.selectedEvent?.id === r.id;
1082
+ this.state.keyboardMoveEventId, r.id, o.setAttribute("role", "button"), o.setAttribute("tabindex", "0"), o.setAttribute(
921
1083
  "aria-label",
922
- P(o, null, this.state.options.timeFormat)
923
- ), r.setAttribute("aria-pressed", a ? "true" : "false"), a && r.classList.add("selected");
924
- const l = new Date(e.start);
925
- l.setHours(0, 0, 0, 0);
926
- const d = (e.start.getTime() - l.getTime()) / (1e3 * 60), u = (e.end.getTime() - l.getTime()) / (1e3 * 60) - d, p = i / 60, m = d / p * 40, v = Math.max(u / p * 40, 20), f = t / s * 100, b = n / s * 100;
927
- r.style.top = `${m}px`, r.style.height = `${v}px`, r.style.left = `${f}%`, r.style.width = `calc(${b}% - 2px)`, r.style.backgroundColor = o.color ?? "#3788d8", r.style.color = o.textColor ?? I(o.color ?? "#3788d8"), this.setData(r, { eventId: o.id });
928
- const y = this.createElement("div", "event-title");
929
- y.textContent = o.title, r.appendChild(y);
930
- const w = this.createElement("div", "event-time");
931
- if (w.textContent = `${h.formatTime(e.start, this.state.options.timeFormat)} - ${h.formatTime(e.end, this.state.options.timeFormat)}`, r.appendChild(w), o.resizable !== !1) {
932
- if (e.isStart) {
933
- const E = this.createElement("div", "resize-handle", "top");
934
- this.setData(E, { handle: "start" }), r.appendChild(E);
935
- }
936
- if (e.isEnd) {
937
- const E = this.createElement("div", "resize-handle", "bottom");
938
- this.setData(E, { handle: "end" }), r.appendChild(E);
939
- }
940
- }
941
- return r;
1084
+ z(r, null, this.state.options)
1085
+ ), o.setAttribute("aria-pressed", a ? "true" : "false"), o.setAttribute("aria-describedby", "scheduler-kbd-event"), a && o.classList.add("selected");
1086
+ const l = this.partGeometry(e.start, e.end, {
1087
+ ...this.state.options,
1088
+ slotDuration: i
1089
+ }), { top: d, height: c } = l ?? { top: 0, height: 0 }, p = t / s * 100, m = n / s * 100;
1090
+ o.style.top = `${d}px`, o.style.height = `${c}px`, o.style.left = `${p}%`, o.style.width = `calc(${m}% - 2px)`, this.applyEventColors(o, r), this.setData(o, { eventId: r.id });
1091
+ const v = this.createElement("div", "event-content"), f = this.createElement("div", "event-title");
1092
+ f.textContent = r.title, v.appendChild(f);
1093
+ const g = this.createElement("div", "event-time");
1094
+ return g.textContent = `${h.formatTime(e.start, this.state.options.timeFormat)} - ${h.formatTime(e.end, this.state.options.timeFormat)}`, v.appendChild(g), o.appendChild(v), this.appendResizeHandles(o, e), o;
942
1095
  }
943
1096
  renderNowIndicator(e) {
944
1097
  const t = /* @__PURE__ */ new Date(), s = new Date(t);
945
1098
  s.setHours(0, 0, 0, 0);
946
- const n = (t.getTime() - s.getTime()) / (1e3 * 60), i = (this.state.options.slotDuration ?? 1800) / 60, o = n / i * 40, r = this.createElement("div", "scheduler-now-indicator");
947
- r.style.top = `${o}px`, e.appendChild(r);
1099
+ const n = (t.getTime() - s.getTime()) / (1e3 * 60), i = (this.state.options.slotDuration ?? 1800) / 60, r = n / i * 40, o = this.createElement("div", "scheduler-now-indicator");
1100
+ o.style.top = `${r}px`, e.appendChild(o);
948
1101
  }
949
1102
  updateNowIndicator() {
950
1103
  if (!this.dayColumn || !this.state.options.nowIndicator || !h.isToday(this.state.date)) return;
951
1104
  const e = this.dayColumn.querySelector(".scheduler-now-indicator"), t = /* @__PURE__ */ new Date(), s = new Date(t);
952
1105
  s.setHours(0, 0, 0, 0);
953
- const n = (t.getTime() - s.getTime()) / (1e3 * 60), i = (this.state.options.slotDuration ?? 1800) / 60, o = n / i * 40;
954
- e ? e.style.top = `${o}px` : this.renderNowIndicator(this.dayColumn);
1106
+ const n = (t.getTime() - s.getTime()) / (1e3 * 60), i = (this.state.options.slotDuration ?? 1800) / 60, r = n / i * 40;
1107
+ e ? e.style.top = `${r}px` : this.renderNowIndicator(this.dayColumn);
955
1108
  }
956
1109
  update(e) {
957
1110
  const t = this.state.date.getTime() !== e.date.getTime(), s = this.optionsRequireRerender(this.state.options, e.options);
@@ -966,86 +1119,164 @@ class Z extends x {
966
1119
  }
967
1120
  updateGreyedSlots() {
968
1121
  const { dragState: e, previewEvent: t, options: s, date: n } = this.state;
969
- if (this.slotElements.forEach((o) => o.classList.remove("greyed")), !e || !t || !h.isSameDay(n, t.start)) return;
1122
+ if (this.slotElements.forEach((r) => r.classList.remove("greyed")), !e || !t) return;
970
1123
  const i = h.getTimeSlots(
971
1124
  n,
972
1125
  s.slotDuration,
973
1126
  s.slotMinTime,
974
1127
  s.slotMaxTime
975
1128
  );
976
- for (let o = 0; o < i.length; o++) {
977
- const r = i[o];
978
- if (r.start < t.end && r.end > t.start) {
979
- const a = this.slotElements.get(o);
1129
+ for (let r = 0; r < i.length; r++) {
1130
+ const o = i[r];
1131
+ if (o.start < t.end && o.end > t.start) {
1132
+ const a = this.slotElements.get(r);
980
1133
  a && a.classList.add("greyed");
981
1134
  }
982
1135
  }
983
1136
  }
1137
+ /**
1138
+ * Dashed ghost for the day currently shown. A multi-day range contributes at
1139
+ * most one part here, but it must still be CLIPPED to this day rather than
1140
+ * skipped: bailing unless the range *started* today meant dragging in from
1141
+ * yesterday drew no feedback at all.
1142
+ */
984
1143
  renderPreviewEvent() {
985
1144
  if (!this.eventsContainer) return;
986
- const e = this.eventsContainer.querySelector(".scheduler-event.preview");
987
- e && e.remove();
988
- const { previewEvent: t, options: s, date: n } = this.state;
989
- if (!t || !h.isSameDay(n, t.start)) return;
990
- const i = this.createElement("div", "scheduler-event", "preview"), o = new Date(t.start);
991
- o.setHours(0, 0, 0, 0);
992
- const r = (t.start.getTime() - o.getTime()) / (1e3 * 60), l = (t.end.getTime() - o.getTime()) / (1e3 * 60) - r, d = (s.slotDuration ?? 1800) / 60, c = r / d * 40, u = Math.max(l / d * 40, 20);
993
- i.style.top = `${c}px`, i.style.height = `${u}px`, i.style.left = "0", i.style.width = "100%", this.eventsContainer.appendChild(i);
1145
+ this.eventsContainer.querySelectorAll(".scheduler-event.preview").forEach((a) => a.remove());
1146
+ const { previewEvent: e, options: t, date: s } = this.state;
1147
+ if (!e) return;
1148
+ const { parts: n } = D.splitInParts(e), i = n.find((a) => h.isSameDay(s, a.start));
1149
+ if (!i) return;
1150
+ const r = this.partGeometry(i.start, i.end, t);
1151
+ if (!r) return;
1152
+ const o = this.createElement("div", "scheduler-event", "preview");
1153
+ i.isStart || o.classList.add("preview-continues-before"), i.isEnd || o.classList.add("preview-continues-after"), o.style.top = `${r.top}px`, o.style.height = `${r.height}px`, o.style.left = "0", o.style.width = "100%", this.eventsContainer.appendChild(o);
994
1154
  }
995
1155
  destroy() {
996
1156
  this.eventsContainer = null, this.dayColumn = null, this.slotElements.clear(), this.clearContainer();
997
1157
  }
998
1158
  }
999
- class Q extends x {
1159
+ const L = "__mp-unassigned__";
1160
+ class ye extends $ {
1000
1161
  constructor() {
1001
- super(...arguments), this.rowElements = /* @__PURE__ */ new Map(), this.slotWidth = 50;
1162
+ super(...arguments), this.rowElements = /* @__PURE__ */ new Map(), this.pendingFocusKey = null;
1163
+ }
1164
+ /**
1165
+ * Slot width in px. Read from `--scheduler-slot-width` so consumers can shorten
1166
+ * a default week (48 slots x 7 days x 50px = 16,800px); falls back to 50.
1167
+ */
1168
+ get slotWidth() {
1169
+ const e = getComputedStyle(this.container).getPropertyValue("--scheduler-slot-width").trim(), t = Number.parseFloat(e);
1170
+ return Number.isFinite(t) && t > 0 ? t : 50;
1171
+ }
1172
+ /**
1173
+ * Track geometry for the timeline, in px, from the CSS custom properties so a
1174
+ * consumer can retune density without forking the view.
1175
+ *
1176
+ * The timeline is the one view where vertical space is NOT the time axis —
1177
+ * time runs horizontally and the panel scrolls — so an event's height carries
1178
+ * no information. Overlapping events therefore STACK at a constant height and
1179
+ * grow their resource row, instead of dividing a fixed 40px row between them
1180
+ * the way week/day must (there, height IS duration).
1181
+ */
1182
+ get trackMetrics() {
1183
+ const e = getComputedStyle(this.container), t = (s, n) => {
1184
+ const i = Number.parseFloat(e.getPropertyValue(s).trim());
1185
+ return Number.isFinite(i) && i >= 0 ? i : n;
1186
+ };
1187
+ return {
1188
+ height: t("--scheduler-timeline-event-height", 28),
1189
+ gap: t("--scheduler-timeline-track-gap", 2),
1190
+ padding: t("--scheduler-timeline-row-padding", 2)
1191
+ };
1002
1192
  }
1003
1193
  render() {
1004
- this.clearContainer(), this.container.classList.add("scheduler-timeline-view");
1005
- const { date: e, options: t, resources: s, collapsedGroups: n } = this.state, i = h.getWeekDays(e, t.firstDayOfWeek), r = S.flatten(s, n).filter((y) => y.visible).length + 1, a = this.createElement("div", "scheduler-timeline");
1006
- a.setAttribute("role", "grid"), a.setAttribute(
1194
+ this.captureActionFocus(), this.clearContainer(), this.container.classList.add("scheduler-timeline-view");
1195
+ const { date: e, options: t, resources: s, collapsedGroups: n } = this.state, i = h.getWeekDays(e, t.firstDayOfWeek), r = T.flatten(s, n), o = this.hasUnassignedRow(this.state), a = r.filter((b) => b.visible).length + 2 + (o ? 1 : 0), l = this.createElement("div", "scheduler-timeline");
1196
+ l.setAttribute("role", "grid"), l.setAttribute(
1007
1197
  "aria-label",
1008
- `Resource timeline for week starting ${h.formatDateWithWeekday(i[0], t.locale)}`
1009
- ), a.setAttribute("aria-rowcount", String(r));
1010
- const l = this.createElement("div", "scheduler-timeline-header");
1011
- l.setAttribute("role", "row"), l.setAttribute("aria-rowindex", "1");
1012
- const d = this.createElement("div", "scheduler-resource-header");
1013
- d.setAttribute("role", "columnheader"), d.textContent = "Resources", l.appendChild(d);
1014
- const c = this.createElement("div", "scheduler-timeline-slots-header");
1015
- for (const y of i) {
1016
- const E = h.getTimeSlots(
1017
- y,
1198
+ S(x(t.messages).timelineGridLabel, {
1199
+ date: h.formatDateWithWeekday(i[0], t.locale)
1200
+ })
1201
+ ), l.setAttribute("aria-rowcount", String(a)), l.setAttribute("aria-describedby", "scheduler-kbd-grid"), l.setAttribute("aria-multiselectable", "true");
1202
+ const d = this.createElement("div", "scheduler-timeline-header");
1203
+ d.setAttribute("role", "row"), d.setAttribute("aria-rowindex", "1");
1204
+ const c = this.createElement("div", "scheduler-resource-header");
1205
+ c.setAttribute("role", "columnheader"), c.textContent = x(this.state.options.messages).resourcesHeader, d.appendChild(c);
1206
+ const p = this.createElement("div", "scheduler-timeline-slots-header");
1207
+ for (const b of i) {
1208
+ const F = h.getTimeSlots(
1209
+ b,
1018
1210
  t.slotDuration,
1019
1211
  t.slotMinTime,
1020
1212
  t.slotMaxTime
1021
- ).length, D = this.createElement("div", "scheduler-timeline-slot-header");
1022
- D.setAttribute("role", "columnheader"), D.style.width = `${E * this.slotWidth}px`, D.textContent = h.formatDateWithWeekday(y, t.locale), D.style.borderBottom = "1px solid var(--scheduler-border-color)", c.appendChild(D);
1023
- }
1024
- l.appendChild(c), a.appendChild(l);
1025
- const u = this.createElement("div", "scheduler-timeline-header"), p = this.createElement("div", "scheduler-resource-header");
1026
- p.style.borderBottom = "1px solid var(--scheduler-border-color)", u.appendChild(p);
1027
- const m = this.createElement("div", "scheduler-timeline-slots-header");
1028
- for (const y of i) {
1029
- const w = h.getTimeSlots(
1030
- y,
1213
+ ).length, C = this.createElement("div", "scheduler-timeline-slot-header");
1214
+ C.setAttribute("role", "columnheader"), C.style.width = `${F * this.slotWidth}px`, C.textContent = h.formatDateWithWeekday(b, t.locale), C.style.borderBottom = "1px solid var(--scheduler-border-color)", p.appendChild(C);
1215
+ }
1216
+ d.appendChild(p);
1217
+ const m = this.createElement("div", "scheduler-timeline-head");
1218
+ m.appendChild(d), l.appendChild(m);
1219
+ const v = this.createElement("div", "scheduler-timeline-header");
1220
+ v.setAttribute("role", "row");
1221
+ const f = this.createElement("div", "scheduler-resource-header");
1222
+ f.style.borderBottom = "1px solid var(--scheduler-border-color)", v.appendChild(f);
1223
+ const g = this.createElement("div", "scheduler-timeline-slots-header");
1224
+ g.setAttribute("role", "presentation");
1225
+ for (const b of i) {
1226
+ const M = h.getTimeSlots(
1227
+ b,
1031
1228
  t.slotDuration,
1032
1229
  t.slotMinTime,
1033
1230
  t.slotMaxTime
1034
1231
  );
1035
- for (const E of w) {
1036
- const D = this.createElement("div", "scheduler-timeline-slot-header");
1037
- D.setAttribute("role", "columnheader"), D.style.width = `${this.slotWidth}px`, D.textContent = h.formatTime(E.start, t.timeFormat), D.style.fontSize = "10px", m.appendChild(D);
1232
+ for (const F of M) {
1233
+ const C = this.createElement("div", "scheduler-timeline-slot-header");
1234
+ C.setAttribute("role", "columnheader"), C.style.width = `${this.slotWidth}px`, C.textContent = h.formatTime(F.start, t.timeFormat), C.style.fontSize = "10px", g.appendChild(C);
1038
1235
  }
1039
1236
  }
1040
- u.appendChild(m), a.appendChild(u);
1041
- const v = this.createElement("div", "scheduler-timeline-body"), f = S.flatten(s, n);
1042
- let b = 2;
1043
- for (const y of f) {
1044
- if (!y.visible) continue;
1045
- const w = this.createResourceRow(y, i);
1046
- w.setAttribute("aria-rowindex", String(b)), v.appendChild(w), b++;
1237
+ v.appendChild(g), m.appendChild(v);
1238
+ const y = this.createElement("div", "scheduler-timeline-body"), w = T.flatten(s, n);
1239
+ let E = 2;
1240
+ for (const b of w) {
1241
+ if (!b.visible) continue;
1242
+ const M = this.createResourceRow(b, i);
1243
+ M.setAttribute("aria-rowindex", String(E)), y.appendChild(M), E++;
1047
1244
  }
1048
- a.appendChild(v), this.container.appendChild(a), this.renderEvents(i), this.updateCellFocusAndSelection();
1245
+ if (o) {
1246
+ const b = this.createUnassignedRow(i);
1247
+ b.setAttribute("aria-rowindex", String(E)), y.appendChild(b), E++;
1248
+ }
1249
+ if (l.appendChild(y), this.container.appendChild(l), w.length === 0 && !o) {
1250
+ const b = this.createElement("div", "scheduler-timeline-empty");
1251
+ b.textContent = x(t.messages).noResources, y.appendChild(b);
1252
+ }
1253
+ const k = this.createAddBar();
1254
+ k && this.container.appendChild(k), this.renderEvents(i), this.updateCellFocusAndSelection(), this.restoreActionFocus();
1255
+ }
1256
+ /**
1257
+ * Focus key of an action control: what it does plus which row it belongs to.
1258
+ * Stable across a rebuild (unlike DOM position), and unique per control.
1259
+ */
1260
+ actionFocusKey(e) {
1261
+ const t = e.dataset.action;
1262
+ return t ? [t, e.dataset.parentId ?? "", e.dataset.resourceId ?? ""].join("|") : null;
1263
+ }
1264
+ /**
1265
+ * Remember which action control the user was on, if any, before a rebuild.
1266
+ * `activeElement` of the shadow root — the host's `document.activeElement` is
1267
+ * the `<mp-scheduler>` element itself, not the button inside it.
1268
+ */
1269
+ captureActionFocus() {
1270
+ const t = this.container.getRootNode().activeElement;
1271
+ this.pendingFocusKey = t && this.container.contains(t) ? this.actionFocusKey(t) : null;
1272
+ }
1273
+ restoreActionFocus() {
1274
+ const e = this.pendingFocusKey;
1275
+ if (this.pendingFocusKey = null, !e) return;
1276
+ const t = Array.from(
1277
+ this.container.querySelectorAll("[data-action]")
1278
+ ).find((n) => this.actionFocusKey(n) === e), s = this.container.querySelector(".scheduler-add-button");
1279
+ (t ?? s)?.focus();
1049
1280
  }
1050
1281
  /**
1051
1282
  * Apply roving tabindex + aria-selected + `.selected` class to each
@@ -1055,30 +1286,36 @@ class Q extends x {
1055
1286
  updateCellFocusAndSelection() {
1056
1287
  const e = this.state.focusedCell, t = this.state.focusedResourceId, s = this.container.querySelectorAll(".scheduler-timeline-slot");
1057
1288
  let n = !1, i = null;
1058
- s.forEach((o) => {
1059
- i || (i = o);
1060
- const r = o.dataset.start, a = o.dataset.end, l = o.dataset.resourceId ?? null;
1061
- if (!r || !a) return;
1062
- const d = { start: new Date(r), end: new Date(a) }, c = !!e && d.start.getTime() === e.start.getTime() && t === l;
1063
- o.setAttribute("tabindex", c ? "0" : "-1");
1064
- const u = R(d, this.state, l);
1065
- o.setAttribute("aria-selected", u ? "true" : "false"), o.classList.toggle("selected", u), c && (n = !0);
1289
+ s.forEach((r) => {
1290
+ i || (i = r);
1291
+ const o = r.dataset.start, a = r.dataset.end, l = r.dataset.resourceId ?? null;
1292
+ if (!o || !a) return;
1293
+ const d = { start: new Date(o), end: new Date(a) }, c = !!e && d.start.getTime() === e.start.getTime() && t === l;
1294
+ r.setAttribute("tabindex", c ? "0" : "-1");
1295
+ const p = U(d, this.state, l);
1296
+ r.setAttribute("aria-selected", p ? "true" : "false"), r.classList.toggle("selected", p), c && (n = !0);
1066
1297
  }), !n && i && i.setAttribute("tabindex", "0");
1067
1298
  }
1068
1299
  createResourceRow(e, t) {
1069
1300
  const { options: s } = this.state, n = this.createElement("div", "scheduler-timeline-row");
1070
- n.setAttribute("role", "row"), $(e.item) && n.classList.add("group");
1301
+ n.setAttribute("role", "row"), R(e.item) && n.classList.add("group");
1071
1302
  const i = this.createElement("div", "scheduler-resource-cell");
1072
- if (i.setAttribute("role", "rowheader"), i.style.paddingLeft = `${8 + e.depth * 16}px`, $(e.item)) {
1303
+ if (i.setAttribute("role", "rowheader"), i.style.paddingLeft = `${8 + e.depth * 16}px`, R(e.item)) {
1073
1304
  const a = this.createElement("button", "expand-toggle");
1074
1305
  a.type = "button";
1075
1306
  const l = this.state.collapsedGroups.has(e.item.id);
1076
- a.textContent = l ? "▶" : "▼", a.setAttribute("aria-expanded", String(!l)), a.setAttribute("aria-label", `${l ? "Expand" : "Collapse"} ${e.item.title}`), this.setData(a, { groupId: e.item.id }), i.appendChild(a);
1307
+ a.textContent = l ? "▶" : "▼", a.setAttribute("aria-expanded", String(!l)), a.setAttribute(
1308
+ "aria-label",
1309
+ S(
1310
+ x(this.state.options.messages)[l ? "expandGroup" : "collapseGroup"],
1311
+ { title: e.item.title }
1312
+ )
1313
+ ), this.setData(a, { groupId: e.item.id }), i.appendChild(a);
1077
1314
  }
1078
- const o = this.createElement("span");
1079
- o.textContent = e.item.title, i.appendChild(o), n.appendChild(i);
1080
- const r = this.createElement("div", "scheduler-timeline-slots");
1081
- r.setAttribute("role", "presentation");
1315
+ const r = this.createElement("span", "resource-title");
1316
+ r.textContent = e.item.title, i.appendChild(r), this.appendResourceActions(i, e.item), n.appendChild(i);
1317
+ const o = this.createElement("div", "scheduler-timeline-slots");
1318
+ o.setAttribute("role", "presentation");
1082
1319
  for (const a of t) {
1083
1320
  const l = h.getTimeSlots(
1084
1321
  a,
@@ -1092,76 +1329,270 @@ class Q extends x {
1092
1329
  resourceId: e.item.id,
1093
1330
  start: d.start.toISOString(),
1094
1331
  end: d.end.toISOString()
1095
- }), r.appendChild(c);
1332
+ }), o.appendChild(c);
1096
1333
  }
1097
1334
  }
1098
- if (H(e.item)) {
1335
+ if (W(e.item)) {
1099
1336
  const a = this.createElement("div", "scheduler-timeline-events");
1100
- a.setAttribute("role", "gridcell"), r.appendChild(a);
1337
+ a.setAttribute("role", "gridcell"), o.appendChild(a);
1101
1338
  }
1102
- return n.appendChild(r), this.rowElements.set(e.item.id, n), n;
1339
+ return n.appendChild(o), this.rowElements.set(e.item.id, n), n;
1340
+ }
1341
+ /**
1342
+ * Whether the synthetic bucket row renders: only when something is actually
1343
+ * unassigned, so a fully-assigned timeline shows no phantom row.
1344
+ */
1345
+ hasUnassignedRow(e) {
1346
+ return (e.eventsByResource.get(null) ?? []).length > 0;
1347
+ }
1348
+ /** True when the capability is granted for the whole scheduler. */
1349
+ can(e) {
1350
+ return O(e, { permissions: this.state.resolvedPermissions });
1351
+ }
1352
+ /**
1353
+ * Per-row resource actions, rendered into the pinned rowheader cell.
1354
+ *
1355
+ * A denied action is ABSENT, not disabled: `createResource`/`createGroup`/
1356
+ * `updateResource`/`deleteResource` are all off by default, so the ordinary
1357
+ * scheduler shows none of this and only an app that manages its own resource
1358
+ * tree opts in. (A permanently-disabled button is noise for sighted users and
1359
+ * a broken promise for AT — the same rule mp-file-manager follows.)
1360
+ *
1361
+ * Every name carries the row title. N buttons all called "Add" is the classic
1362
+ * failure of a tree like this: a screen-reader user hears the same name on
1363
+ * every row and cannot tell which group they are adding to. Depth stays out of
1364
+ * it entirely — `aria-level` is invalid on these roles, so nesting is conveyed
1365
+ * by the name and the indent, not by an attribute axe flags.
1366
+ */
1367
+ appendResourceActions(e, t) {
1368
+ const s = x(this.state.options.messages), n = this.createElement("div", "scheduler-resource-actions");
1369
+ R(t) && (this.can("createResource") && n.appendChild(
1370
+ this.createResourceAction(
1371
+ "add-resource",
1372
+ "+",
1373
+ S(s.addResourceToGroup, { title: t.title }),
1374
+ { parentId: t.id }
1375
+ )
1376
+ ), this.can("createGroup") && n.appendChild(
1377
+ this.createResourceAction(
1378
+ "add-group",
1379
+ "⊞",
1380
+ S(s.addGroupToGroup, { title: t.title }),
1381
+ { parentId: t.id }
1382
+ )
1383
+ )), this.can("updateResource") && n.appendChild(this.createColorSwatch(t, s.resourceColor)), this.can("deleteResource") && n.appendChild(
1384
+ this.createResourceAction(
1385
+ "delete-resource",
1386
+ "×",
1387
+ S(s.removeResource, { title: t.title }),
1388
+ { resourceId: t.id }
1389
+ )
1390
+ ), n.childElementCount > 0 && e.appendChild(n);
1391
+ }
1392
+ /**
1393
+ * One icon button. The glyph is `aria-hidden` and the name lives on the
1394
+ * button, so the accessible name is the localized sentence rather than "+".
1395
+ */
1396
+ createResourceAction(e, t, s, n) {
1397
+ const i = this.createElement("button", "scheduler-resource-action");
1398
+ i.type = "button", i.setAttribute("aria-label", s), i.title = s, this.setData(i, { action: e, ...n });
1399
+ const r = this.createElement("span", "action-glyph");
1400
+ return r.setAttribute("aria-hidden", "true"), r.textContent = t, i.appendChild(r), i;
1401
+ }
1402
+ /**
1403
+ * Native `<input type="color">` for the resource's colour — the recolour half
1404
+ * of R7. Native because it is keyboard-operable, localized and screen-reader
1405
+ * labelled by the platform for free; a custom swatch grid would have to
1406
+ * re-earn all three.
1407
+ *
1408
+ * It edits whichever field actually drives the rendered events: `eventColor`
1409
+ * wins over `color` in `resolveEventColor`, so writing `color` on a resource
1410
+ * that has an `eventColor` would look like the control did nothing.
1411
+ */
1412
+ createColorSwatch(e, t) {
1413
+ const s = e, n = s.eventColor ? "eventColor" : "color", i = s.eventColor ?? e.color, r = this.createElement("input", "scheduler-resource-color");
1414
+ return r.type = "color", r.setAttribute("aria-label", S(t, { title: e.title })), r.title = r.getAttribute("aria-label") ?? "", i && /^#[0-9a-f]{6}$/i.test(i) && (r.value = i), this.setData(r, { action: "set-resource-color", resourceId: e.id, field: n }), r;
1415
+ }
1416
+ /**
1417
+ * Root-level "Add resource" / "Add group" bar, pinned to the bottom of the
1418
+ * frozen resource column (the spreadsheet/Jira idiom: creation lives at the
1419
+ * end of the list, in the column the new row will appear in).
1420
+ *
1421
+ * Deliberately a sibling of the grid, not a row inside it: a row whose only
1422
+ * content is buttons has to fake a rowheader, inflates `aria-rowcount`, and
1423
+ * puts Tab stops inside a roving-tabindex grid. Outside, it is just a toolbar.
1424
+ */
1425
+ createAddBar() {
1426
+ const e = this.can("createResource"), t = this.can("createGroup");
1427
+ if (!e && !t) return null;
1428
+ const s = x(this.state.options.messages), n = this.createElement("div", "scheduler-timeline-addbar");
1429
+ if (n.setAttribute("role", "toolbar"), n.setAttribute("aria-label", s.addResourceBarLabel), e) {
1430
+ const i = this.createElement("button", "scheduler-add-button");
1431
+ i.type = "button", i.textContent = s.addResource, this.setData(i, { action: "add-resource" }), n.appendChild(i);
1432
+ }
1433
+ if (t) {
1434
+ const i = this.createElement("button", "scheduler-add-button");
1435
+ i.type = "button", i.textContent = s.addGroup, this.setData(i, { action: "add-group" }), n.appendChild(i);
1436
+ }
1437
+ return n;
1438
+ }
1439
+ /**
1440
+ * The "(No resource)" bucket row.
1441
+ *
1442
+ * Structurally identical to a resource row so keyboard nav, roving tabindex and
1443
+ * the grid ARIA chain all treat it as one more row — but its slots carry NO
1444
+ * `data-resource-id`, so a create-drag started here produces an unassigned
1445
+ * event rather than inventing membership of a resource that doesn't exist.
1446
+ */
1447
+ createUnassignedRow(e) {
1448
+ const { options: t } = this.state, s = this.createElement("div", "scheduler-timeline-row", "unassigned");
1449
+ s.setAttribute("role", "row");
1450
+ const n = this.createElement("div", "scheduler-resource-cell");
1451
+ n.setAttribute("role", "rowheader"), n.style.paddingLeft = "8px";
1452
+ const i = this.createElement("span");
1453
+ i.textContent = x(t.messages).unassignedResource, n.appendChild(i), s.appendChild(n);
1454
+ const r = this.createElement("div", "scheduler-timeline-slots");
1455
+ r.setAttribute("role", "presentation");
1456
+ for (const a of e) {
1457
+ const l = h.getTimeSlots(
1458
+ a,
1459
+ t.slotDuration,
1460
+ t.slotMinTime,
1461
+ t.slotMaxTime
1462
+ );
1463
+ for (const d of l) {
1464
+ const c = this.createElement("div", "scheduler-timeline-slot");
1465
+ c.setAttribute("role", "gridcell"), c.setAttribute("tabindex", "-1"), c.setAttribute("aria-selected", "false"), c.id = `scheduler-cell-t-${L}-${d.start.getTime()}`, c.style.width = `${this.slotWidth}px`, this.setData(c, {
1466
+ start: d.start.toISOString(),
1467
+ end: d.end.toISOString()
1468
+ }), r.appendChild(c);
1469
+ }
1470
+ }
1471
+ const o = this.createElement("div", "scheduler-timeline-events");
1472
+ return o.setAttribute("role", "gridcell"), r.appendChild(o), s.appendChild(r), this.rowElements.set(L, s), s;
1103
1473
  }
1104
1474
  renderEvents(e) {
1105
- const { events: t, resources: s, options: n, collapsedGroups: i } = this.state, o = e[0], r = new Date(e[6]);
1106
- r.setHours(23, 59, 59, 999);
1107
- const d = h.getTimeSlots(
1475
+ const { resources: t, options: s } = this.state, n = e[0], i = new Date(e[6]);
1476
+ i.setHours(23, 59, 59, 999);
1477
+ const a = h.getTimeSlots(
1108
1478
  e[0],
1109
- n.slotDuration,
1110
- n.slotMinTime,
1111
- n.slotMaxTime
1112
- ).length * 7 * this.slotWidth, c = S.getAllResources(s);
1113
- for (const u of c) {
1114
- const p = this.rowElements.get(u.id);
1479
+ s.slotDuration,
1480
+ s.slotMinTime,
1481
+ s.slotMaxTime
1482
+ ).length * 7 * this.slotWidth, l = [
1483
+ ...T.getAllResources(t).map((d) => ({
1484
+ resourceId: d.id,
1485
+ title: d.title
1486
+ })),
1487
+ ...this.rowElements.has(L) ? [
1488
+ {
1489
+ resourceId: null,
1490
+ title: x(s.messages).unassignedResource
1491
+ }
1492
+ ] : []
1493
+ ];
1494
+ for (const { resourceId: d, title: c } of l) {
1495
+ const p = this.rowElements.get(d ?? L);
1115
1496
  if (!p) continue;
1116
1497
  const m = p.querySelector(".scheduler-timeline-events");
1117
1498
  if (!m) continue;
1118
1499
  m.innerHTML = "";
1119
- const f = (u.events ?? []).filter(
1120
- (y) => y.start < r && y.end > o
1121
- ).map((y) => ({
1122
- id: y.id,
1123
- event: y,
1124
- start: y.start,
1125
- end: y.end,
1500
+ const f = (this.state.eventsByResource.get(d) ?? []).filter(
1501
+ (b) => b.start < i && b.end > n
1502
+ ).map((b) => ({
1503
+ id: b.id,
1504
+ event: b,
1505
+ start: b.start,
1506
+ end: b.end,
1126
1507
  isStart: !0,
1127
1508
  isEnd: !0,
1128
1509
  dayIndex: 0,
1129
1510
  totalDays: 1
1130
- })), b = M.getTimelinedParts(f);
1131
- for (const { part: y, trackIndex: w, totalTracks: E, colspan: D } of b) {
1132
- if (!y.event) continue;
1133
- const K = this.createEventElement(
1134
- y.event,
1135
- w,
1136
- E,
1137
- D,
1138
- o,
1139
- d,
1140
- n.slotDuration ?? 1800,
1141
- u.title
1511
+ })), g = D.getTimelinedParts(f), y = g.reduce((b, M) => Math.max(b, M.totalTracks), 1), { height: w, gap: E, padding: k } = this.trackMetrics;
1512
+ p.style.minHeight = `${y * w + (y - 1) * E + 2 * k}px`;
1513
+ for (const { part: b, trackIndex: M } of g) {
1514
+ if (!b.event) continue;
1515
+ const F = this.createEventElement(
1516
+ b.event,
1517
+ M,
1518
+ n,
1519
+ a,
1520
+ s.slotDuration ?? 1800,
1521
+ c
1142
1522
  );
1143
- m.appendChild(K);
1523
+ m.appendChild(F);
1144
1524
  }
1145
1525
  }
1146
1526
  }
1147
- createEventElement(e, t, s, n, i, o, r, a = null) {
1148
- const l = this.createElement("div", "scheduler-timeline-event"), d = this.state.selectedEvent?.id === e.id;
1149
- this.state.keyboardMoveEventId, e.id, l.setAttribute("role", "button"), l.setAttribute("tabindex", "0"), l.setAttribute(
1527
+ createEventElement(e, t, s, n, i, r = null) {
1528
+ const o = this.createElement("div", "scheduler-timeline-event"), a = this.state.selectedEvent?.id === e.id;
1529
+ this.state.keyboardMoveEventId, e.id, o.setAttribute("role", "button"), o.setAttribute("tabindex", "0"), o.setAttribute(
1150
1530
  "aria-label",
1151
- P(e, a, this.state.options.timeFormat)
1152
- ), l.setAttribute("aria-pressed", d ? "true" : "false"), d && l.classList.add("selected");
1153
- const c = Math.max(e.start.getTime(), i.getTime()), u = i.getTime() + 10080 * 60 * 1e3, p = Math.min(e.end.getTime(), u), m = c - i.getTime(), v = p - c, f = u - i.getTime(), b = m / f * o, y = Math.max(v / f * o, 20), w = t / s * 100, E = n / s * 100;
1154
- return l.style.left = `${b}px`, l.style.width = `${y}px`, l.style.top = `${w}%`, l.style.height = `${E}%`, l.style.backgroundColor = e.color ?? "#3788d8", l.style.color = e.textColor ?? I(e.color ?? "#3788d8"), this.setData(l, { eventId: e.id }), l.textContent = e.title, l;
1531
+ z(e, r, this.state.options)
1532
+ ), o.setAttribute("aria-pressed", a ? "true" : "false"), o.setAttribute("aria-describedby", "scheduler-kbd-event"), a && o.classList.add("selected");
1533
+ const l = Math.max(e.start.getTime(), s.getTime()), d = s.getTime() + 10080 * 60 * 1e3, c = Math.min(e.end.getTime(), d), p = l - s.getTime(), m = c - l, v = d - s.getTime(), f = p / v * n, g = Math.max(m / v * n, 20), { height: y, gap: w, padding: E } = this.trackMetrics;
1534
+ o.style.left = `${f}px`, o.style.width = `${g}px`, o.style.top = `${E + t * (y + w)}px`, o.style.height = `${y}px`, this.applyEventColors(o, e), this.setData(o, { eventId: e.id });
1535
+ const k = this.createElement("div", "event-content"), b = this.createElement("div", "event-title");
1536
+ return b.textContent = e.title, k.appendChild(b), o.appendChild(k), this.appendResizeHandles(
1537
+ o,
1538
+ {
1539
+ id: e.id,
1540
+ event: e,
1541
+ start: e.start,
1542
+ end: e.end,
1543
+ isStart: e.start.getTime() >= s.getTime(),
1544
+ isEnd: e.end.getTime() <= d,
1545
+ dayIndex: 0,
1546
+ totalDays: 1
1547
+ },
1548
+ ["left", "right"]
1549
+ ), o;
1550
+ }
1551
+ /**
1552
+ * Dashed ghost showing where the event will land. Mirrors
1553
+ * week-view.renderPreviewEvent for the horizontal axis.
1554
+ *
1555
+ * Gated on `previewEvent` alone — NOT on `dragState`, which only the pointer
1556
+ * drag path writes. Keyboard move-mode sets `previewEvent` with no
1557
+ * `dragState`, so requiring it hid the ghost from keyboard users on this
1558
+ * view while week/day showed it.
1559
+ */
1560
+ renderPreviewEvent(e) {
1561
+ this.container.querySelector(".scheduler-timeline-event.preview")?.remove();
1562
+ const { dragState: t, previewEvent: s, options: n } = this.state;
1563
+ if (!s) return;
1564
+ const i = t?.event?.id ?? this.state.keyboardMoveEventId, r = i ? this.state.events.find((w) => w.id === i) : void 0, o = s.resourceId ?? // `?? UNASSIGNED_ROW_ID`, not `?? undefined`: an event in the bucket row is
1565
+ // legitimately resource-less and still deserves a ghost.
1566
+ (r ? r.resourceId ?? L : void 0) ?? // A CREATE drag has no source event and no resource on the preview either,
1567
+ // so fall back to the row the gesture is happening in. Without this a
1568
+ // create-drag on a timeline row showed no ghost at all.
1569
+ this.state.selectionResourceId ?? this.state.focusedResourceId ?? void 0;
1570
+ if (!o) return;
1571
+ const l = this.rowElements.get(o)?.querySelector(".scheduler-timeline-events");
1572
+ if (!l) return;
1573
+ const c = h.getTimeSlots(
1574
+ e[0],
1575
+ n.slotDuration,
1576
+ n.slotMinTime,
1577
+ n.slotMaxTime
1578
+ ).length * 7 * this.slotWidth, p = e[0], m = p.getTime() + 10080 * 60 * 1e3, v = Math.max(s.start.getTime(), p.getTime()), f = Math.min(s.end.getTime(), m), g = m - p.getTime(), y = this.createElement("div", "scheduler-timeline-event", "preview");
1579
+ if (y.style.left = `${(v - p.getTime()) / g * c}px`, y.style.width = `${Math.max((f - v) / g * c, 20)}px`, i) {
1580
+ const w = Array.from(
1581
+ l.querySelectorAll(".scheduler-timeline-event:not(.preview)")
1582
+ ).find((E) => E.dataset.eventId === i);
1583
+ w && (y.style.top = w.style.top, y.style.height = w.style.height);
1584
+ }
1585
+ l.appendChild(y);
1155
1586
  }
1156
1587
  update(e) {
1157
- const t = this.state.date.getTime() !== e.date.getTime(), s = this.optionsRequireRerender(this.state.options, e.options);
1158
- if (this.state = e, t || s) {
1588
+ const t = this.state.date.getTime() !== e.date.getTime(), s = this.optionsRequireRerender(this.state.options, e.options), n = this.state.resources !== e.resources || this.state.collapsedGroups !== e.collapsedGroups || this.state.resolvedPermissions !== e.resolvedPermissions || this.hasUnassignedRow(this.state) !== this.hasUnassignedRow(e);
1589
+ if (this.state = e, t || s || n) {
1159
1590
  this.render();
1160
1591
  return;
1161
1592
  }
1162
1593
  this.updateGreyedSlots();
1163
- const n = h.getWeekDays(e.date, e.options.firstDayOfWeek);
1164
- this.renderEvents(n), this.updateCellFocusAndSelection();
1594
+ const i = h.getWeekDays(e.date, e.options.firstDayOfWeek);
1595
+ this.renderEvents(i), this.renderPreviewEvent(i), this.updateCellFocusAndSelection();
1165
1596
  }
1166
1597
  optionsRequireRerender(e, t) {
1167
1598
  return e.slotDuration !== t.slotDuration || e.timeFormat !== t.timeFormat || e.firstDayOfWeek !== t.firstDayOfWeek || e.slotMinTime !== t.slotMinTime || e.slotMaxTime !== t.slotMaxTime || e.locale !== t.locale;
@@ -1169,15 +1600,25 @@ class Q extends x {
1169
1600
  updateGreyedSlots() {
1170
1601
  const { dragState: e, previewEvent: t } = this.state, s = this.container.querySelectorAll(".scheduler-timeline-slot");
1171
1602
  s.forEach((n) => n.classList.remove("greyed")), !(!e || !t) && s.forEach((n) => {
1172
- const i = new Date(n.dataset.start ?? ""), o = new Date(n.dataset.end ?? "");
1173
- i < t.end && o > t.start && n.classList.add("greyed");
1603
+ const i = new Date(n.dataset.start ?? ""), r = new Date(n.dataset.end ?? "");
1604
+ i < t.end && r > t.start && n.classList.add("greyed");
1174
1605
  });
1175
1606
  }
1176
1607
  destroy() {
1177
1608
  this.rowElements.clear(), this.clearContainer();
1178
1609
  }
1179
1610
  }
1180
- const ee = W(`:host {
1611
+ const be = Q(`@charset "UTF-8";
1612
+ /* Layering ladder. Nothing between :host and the events establishes a
1613
+ stacking context, so every one of these competes in ONE shared context
1614
+ across the whole shadow root — a selected event in one day column is
1615
+ compared directly against the now-indicator in another, and against the
1616
+ sticky header. Keep them here, in order, rather than scattering magic
1617
+ numbers: the preview ghost silently disappearing behind a selected event
1618
+ is exactly what an undocumented ladder buys you.
1619
+ SCSS vars (not custom properties) on purpose — these compile away, so the
1620
+ ladder stays internal instead of becoming consumer-overridable API. */
1621
+ :host {
1181
1622
  display: block;
1182
1623
  height: 100%;
1183
1624
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
@@ -1193,12 +1634,41 @@ const ee = W(`:host {
1193
1634
  --scheduler-greyed-slot-bg: rgba(0, 0, 0, 0.1);
1194
1635
  --scheduler-column-min-width: 120px;
1195
1636
  --scheduler-touch-hold-duration: 500ms;
1637
+ /* Timeline slot width. Was hard-coded at 50px in TS, which made a default week
1638
+ 16,800px wide; consumers can now shorten it. */
1639
+ --scheduler-slot-width: 50px;
1640
+ /* Timeline track geometry. Time runs horizontally there, so an event's height
1641
+ is free to be constant and overlapping events stack downwards, growing the
1642
+ resource row — see TimelineView.trackMetrics. */
1643
+ --scheduler-timeline-event-height: 28px;
1644
+ --scheduler-timeline-track-gap: 2px;
1645
+ --scheduler-timeline-row-padding: 2px;
1646
+ /* Pinned resource column. Capped so it can never swallow the grid on a narrow
1647
+ viewport (AG Grid applies the same guard by auto-unpinning). */
1648
+ --scheduler-resource-column-width: min(200px, calc(100% - 50px));
1649
+ --scheduler-resize-glyph-size: 14px;
1650
+ --scheduler-resize-glyph-color: var(--bs-body-color, #212529);
1651
+ --scheduler-resize-glyph-bg: var(--bs-body-bg, #fff);
1196
1652
  }
1197
1653
 
1198
1654
  * {
1199
1655
  box-sizing: border-box;
1200
1656
  }
1201
1657
 
1658
+ /* Off-screen but readable by AT — carries the aria-describedby keymap
1659
+ instructions (never applied to focusable elements). */
1660
+ .visually-hidden {
1661
+ position: absolute;
1662
+ width: 1px;
1663
+ height: 1px;
1664
+ margin: -1px;
1665
+ padding: 0;
1666
+ overflow: hidden;
1667
+ clip-path: inset(50%);
1668
+ white-space: nowrap;
1669
+ border: 0;
1670
+ }
1671
+
1202
1672
  .scheduler-container {
1203
1673
  display: flex;
1204
1674
  flex-direction: column;
@@ -1209,17 +1679,44 @@ const ee = W(`:host {
1209
1679
  background: var(--bs-body-bg);
1210
1680
  }
1211
1681
 
1212
- /* Header */
1682
+ /* Header — wraps as GROUPS when narrow ([data-narrow], set by a
1683
+ ResizeObserver on component width): nav + view switcher share the first
1684
+ row(s), the title takes a full-width row, so no control ever leaves reach
1685
+ and the title never word-wraps (PRD D9). */
1213
1686
  .scheduler-header {
1214
1687
  display: flex;
1215
1688
  align-items: center;
1216
1689
  justify-content: space-between;
1690
+ flex-wrap: wrap;
1691
+ gap: 8px;
1217
1692
  padding: 8px 12px;
1218
1693
  background: var(--scheduler-header-bg);
1219
1694
  border-bottom: 1px solid var(--scheduler-border-color);
1220
1695
  flex-shrink: 0;
1221
1696
  }
1222
1697
 
1698
+ .scheduler-header[data-narrow] {
1699
+ justify-content: center;
1700
+ }
1701
+
1702
+ .scheduler-header[data-narrow] .scheduler-nav {
1703
+ order: 1;
1704
+ }
1705
+
1706
+ .scheduler-header[data-narrow] .scheduler-view-switcher {
1707
+ order: 2;
1708
+ flex-wrap: wrap;
1709
+ justify-content: center;
1710
+ }
1711
+
1712
+ .scheduler-header[data-narrow] .scheduler-title {
1713
+ order: 3;
1714
+ flex-basis: 100%;
1715
+ text-align: center;
1716
+ overflow: hidden;
1717
+ text-overflow: ellipsis;
1718
+ }
1719
+
1223
1720
  .scheduler-nav {
1224
1721
  display: flex;
1225
1722
  align-items: center;
@@ -1242,6 +1739,9 @@ const ee = W(`:host {
1242
1739
  .scheduler-title {
1243
1740
  font-size: 18px;
1244
1741
  font-weight: 600;
1742
+ /* Never word-wrap the period title — multi-line titles distorted the whole
1743
+ header on phones; narrow mode compacts the text instead. */
1744
+ white-space: nowrap;
1245
1745
  }
1246
1746
 
1247
1747
  .scheduler-view-switcher {
@@ -1268,20 +1768,9 @@ const ee = W(`:host {
1268
1768
  border-color: var(--bs-primary);
1269
1769
  }
1270
1770
 
1271
- /* Main content area */
1272
- .scheduler-body {
1273
- display: flex;
1274
- flex: 1;
1275
- overflow: hidden;
1276
- }
1277
-
1278
- .scheduler-sidebar {
1279
- width: var(--scheduler-time-gutter-width);
1280
- flex-shrink: 0;
1281
- border-right: 1px solid var(--scheduler-border-color);
1282
- background: var(--scheduler-header-bg);
1283
- }
1284
-
1771
+ /* Main content area — the single scroller for every view.
1772
+ (\`.scheduler-body\` / \`.scheduler-sidebar\` / \`.scheduler-grid\` rules lived here
1773
+ with no producer in any view; removed rather than left to mislead.) */
1285
1774
  .scheduler-content {
1286
1775
  flex: 1;
1287
1776
  overflow: auto;
@@ -1289,11 +1778,6 @@ const ee = W(`:host {
1289
1778
  }
1290
1779
 
1291
1780
  /* Week/Day View Grid */
1292
- .scheduler-grid {
1293
- display: grid;
1294
- min-width: 100%;
1295
- }
1296
-
1297
1781
  .scheduler-day-headers {
1298
1782
  display: flex;
1299
1783
  border-bottom: 1px solid var(--scheduler-border-color);
@@ -1344,6 +1828,11 @@ const ee = W(`:host {
1344
1828
  flex-shrink: 0;
1345
1829
  border-right: 1px solid var(--scheduler-border-color);
1346
1830
  background: var(--scheduler-header-bg);
1831
+ /* Pin the time labels while the week scrolls horizontally — same defect the
1832
+ timeline's resource column had. Background is already opaque. */
1833
+ position: sticky;
1834
+ left: 0;
1835
+ z-index: 7;
1347
1836
  }
1348
1837
 
1349
1838
  .scheduler-time-slot-label {
@@ -1397,7 +1886,9 @@ const ee = W(`:host {
1397
1886
  .scheduler-time-slot:focus {
1398
1887
  outline: 2px solid var(--bs-primary);
1399
1888
  outline-offset: -2px;
1400
- z-index: 1;
1889
+ /* Above the events overlay — including a SELECTED event, which would
1890
+ otherwise hide the focus ring of the slot beneath it. */
1891
+ z-index: 6;
1401
1892
  }
1402
1893
 
1403
1894
  /* Events */
@@ -1415,14 +1906,29 @@ const ee = W(`:host {
1415
1906
  border-radius: var(--scheduler-event-border-radius);
1416
1907
  padding: 2px 4px;
1417
1908
  font-size: 12px;
1418
- overflow: hidden;
1909
+ /* The box stays unclipped so the selected-state resize handles/glyphs can
1910
+ straddle the top/bottom edges; text clipping lives on .event-content. */
1911
+ overflow: visible;
1419
1912
  cursor: pointer;
1420
1913
  pointer-events: auto;
1421
1914
  border-left: 3px solid rgba(0, 0, 0, 0.2);
1422
1915
  }
1423
1916
 
1917
+ .scheduler-event .event-content,
1918
+ .scheduler-timeline-event .event-content {
1919
+ height: 100%;
1920
+ overflow: hidden;
1921
+ }
1922
+
1923
+ .scheduler-timeline-event .event-title {
1924
+ white-space: nowrap;
1925
+ overflow: hidden;
1926
+ text-overflow: ellipsis;
1927
+ }
1928
+
1424
1929
  /* Prevent browser from handling touch gestures on events (enables drag) */
1425
- .scheduler-event:not(.preview) {
1930
+ .scheduler-event:not(.preview),
1931
+ .scheduler-timeline-event:not(.preview) {
1426
1932
  touch-action: none;
1427
1933
  -ms-touch-action: none;
1428
1934
  }
@@ -1431,8 +1937,23 @@ const ee = W(`:host {
1431
1937
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
1432
1938
  }
1433
1939
 
1940
+ /* Focus indicator independent of the .selected box-shadow — selection can be
1941
+ driven externally, so focus needs its own visible signal (audit MAJOR).
1942
+ Inset like the slot outlines so it isn't clipped by scroll containers. */
1943
+ .scheduler-event:focus-visible,
1944
+ .scheduler-timeline-event:focus-visible,
1945
+ .scheduler-month-event:focus-visible,
1946
+ .scheduler-month-day:focus-visible,
1947
+ .scheduler-year-month:focus-visible {
1948
+ outline: 2px solid var(--bs-primary);
1949
+ outline-offset: -2px;
1950
+ }
1951
+
1434
1952
  .scheduler-event.selected {
1435
1953
  box-shadow: 0 0 0 3px var(--bs-body-color);
1954
+ /* Raise above sibling events so the straddling handles win pointer hits.
1955
+ At most one event is selected. See the ladder at the top of this file. */
1956
+ z-index: 2;
1436
1957
  }
1437
1958
 
1438
1959
  .scheduler-event .event-title {
@@ -1447,19 +1968,40 @@ const ee = W(`:host {
1447
1968
  opacity: 0.8;
1448
1969
  }
1449
1970
 
1971
+ /* A range spanning several days renders one ghost per day. Drop the border on
1972
+ the midnight seams so the set reads as ONE range instead of N events. */
1973
+ .scheduler-event.preview.preview-continues-before,
1974
+ .scheduler-timeline-event.preview.preview-continues-before {
1975
+ border-top-color: transparent;
1976
+ }
1977
+
1978
+ .scheduler-event.preview.preview-continues-after,
1979
+ .scheduler-timeline-event.preview.preview-continues-after {
1980
+ border-bottom-color: transparent;
1981
+ }
1982
+
1450
1983
  .scheduler-event.preview {
1451
1984
  background: var(--scheduler-preview-bg);
1452
1985
  border: 2px dashed var(--bs-primary);
1453
1986
  pointer-events: none;
1987
+ /* MUST out-rank the source event in every state (normal, selected,
1988
+ dragging) — an equal z-index would leave it relying on the preview being
1989
+ appended last, which breaks the moment a view reorders its update(). */
1990
+ z-index: 4;
1454
1991
  }
1455
1992
 
1456
- /* Resize handles */
1993
+ /* Resize handles — invisible 8px strips on every resizable event (the
1994
+ long-standing mouse hit zone). On the SELECTED event they grow to a
1995
+ WCAG-2.5.8-sized strip centered on the edge (half outside the box) and
1996
+ reveal the round glyph, which is the documented touch affordance. */
1457
1997
  .scheduler-event .resize-handle {
1458
1998
  position: absolute;
1459
1999
  left: 0;
1460
2000
  right: 0;
1461
2001
  height: 8px;
1462
2002
  cursor: ns-resize;
2003
+ touch-action: none;
2004
+ -ms-touch-action: none;
1463
2005
  }
1464
2006
 
1465
2007
  .scheduler-event .resize-handle.top {
@@ -1470,6 +2012,55 @@ const ee = W(`:host {
1470
2012
  bottom: 0;
1471
2013
  }
1472
2014
 
2015
+ .scheduler-event.selected .resize-handle {
2016
+ height: 24px;
2017
+ }
2018
+
2019
+ .scheduler-event.selected .resize-handle.top {
2020
+ top: -12px;
2021
+ }
2022
+
2023
+ .scheduler-event.selected .resize-handle.bottom {
2024
+ bottom: -12px;
2025
+ }
2026
+
2027
+ @media (pointer: coarse) {
2028
+ .scheduler-event.selected .resize-handle {
2029
+ height: 44px;
2030
+ }
2031
+ .scheduler-event.selected .resize-handle.top {
2032
+ top: -22px;
2033
+ }
2034
+ .scheduler-event.selected .resize-handle.bottom {
2035
+ bottom: -22px;
2036
+ }
2037
+ }
2038
+ /* Decorative resize glyph, revealed by selection. Never focusable and
2039
+ aria-hidden — the keyboard resize path is move-mode on the event itself.
2040
+ Border + background only, so forced-colors mode keeps it visible. */
2041
+ .scheduler-event .resize-glyph,
2042
+ .scheduler-timeline-event .resize-glyph {
2043
+ position: absolute;
2044
+ top: 50%;
2045
+ left: 50%;
2046
+ width: var(--scheduler-resize-glyph-size);
2047
+ height: var(--scheduler-resize-glyph-size);
2048
+ transform: translate(-50%, -50%);
2049
+ border: 2px solid var(--scheduler-resize-glyph-color);
2050
+ border-radius: 50%;
2051
+ background: var(--scheduler-resize-glyph-bg);
2052
+ opacity: 0;
2053
+ visibility: hidden;
2054
+ transition: opacity 0.15s ease;
2055
+ pointer-events: none;
2056
+ }
2057
+
2058
+ .scheduler-event.selected .resize-glyph,
2059
+ .scheduler-timeline-event.selected .resize-glyph {
2060
+ opacity: 1;
2061
+ visibility: visible;
2062
+ }
2063
+
1473
2064
  /* Now indicator */
1474
2065
  .scheduler-now-indicator {
1475
2066
  position: absolute;
@@ -1499,8 +2090,20 @@ const ee = W(`:host {
1499
2090
 
1500
2091
  .scheduler-month-grid {
1501
2092
  display: grid;
1502
- grid-template-columns: repeat(7, 1fr);
1503
- grid-auto-rows: minmax(100px, 1fr);
2093
+ /* \`minmax(min, 1fr)\` + \`min-width: fit-content\`, NOT a bare \`1fr\`.
2094
+ The day-name header row is the same \`.scheduler-day-headers\` week view uses,
2095
+ whose cells are \`flex: 1 0 var(--scheduler-column-min-width)\` — so below
2096
+ 7 x that width the header row grows past the panel while a \`1fr\` grid kept
2097
+ shrinking, and the two column sets visibly disagreed (at 900px: 120px
2098
+ headers over 75px cells). Both now share one minimum and overflow together,
2099
+ which is also what makes the month view horizontally scrollable instead of
2100
+ illegibly narrow on a phone. */
2101
+ grid-template-columns: repeat(7, minmax(var(--scheduler-column-min-width), 1fr));
2102
+ min-width: fit-content;
2103
+ /* 120px, not 100px: a day number plus three 24px chips and the "+N more" link
2104
+ needs the room, and a chip clipped by \`overflow: hidden\` is a target the
2105
+ user cannot hit at all. */
2106
+ grid-auto-rows: minmax(120px, 1fr);
1504
2107
  height: 100%;
1505
2108
  }
1506
2109
 
@@ -1535,7 +2138,16 @@ const ee = W(`:host {
1535
2138
  gap: 2px;
1536
2139
  }
1537
2140
 
2141
+ /* 24px tall with 24px of clear spacing between chips: WCAG 2.2 SC 2.5.8. These
2142
+ were 20.5px with a 20.6px safe-click diameter, which axe reports as a serious
2143
+ target-size failure — it only surfaces on the month view, so the page-load
2144
+ audit (week view) never saw it. The month row grows to fit (grid-auto-rows
2145
+ below), so three chips plus the "+N more" link still fit a cell. */
1538
2146
  .scheduler-month-event {
2147
+ display: flex;
2148
+ align-items: center;
2149
+ min-height: 24px;
2150
+ margin-bottom: 2px;
1539
2151
  padding: 2px 4px;
1540
2152
  border-radius: 2px;
1541
2153
  font-size: 11px;
@@ -1546,12 +2158,149 @@ const ee = W(`:host {
1546
2158
  }
1547
2159
 
1548
2160
  .scheduler-more-link {
2161
+ display: flex;
2162
+ align-items: center;
2163
+ min-height: 24px;
1549
2164
  font-size: 11px;
1550
2165
  color: var(--bs-primary);
1551
2166
  cursor: pointer;
1552
2167
  margin-top: 2px;
1553
2168
  }
1554
2169
 
2170
+ .scheduler-more-link:focus-visible {
2171
+ outline: 2px solid var(--bs-primary);
2172
+ outline-offset: 1px;
2173
+ }
2174
+
2175
+ /* Day popover (month view). \`position: fixed\` coordinates are written by the
2176
+ OverlayController, so this element must stay a top-level child of the shadow
2177
+ root — nothing above it may introduce transform/filter/contain, which would
2178
+ make that ancestor the containing block and shift the panel. */
2179
+ .scheduler-day-popover {
2180
+ position: fixed;
2181
+ z-index: 20;
2182
+ min-width: 220px;
2183
+ max-width: min(320px, 90vw);
2184
+ max-height: 60vh;
2185
+ overflow-y: auto;
2186
+ padding: 8px;
2187
+ border: 1px solid var(--scheduler-border-color);
2188
+ border-radius: 6px;
2189
+ background: var(--bs-body-bg, #fff);
2190
+ box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
2191
+ }
2192
+
2193
+ .scheduler-day-popover .popover-head {
2194
+ display: flex;
2195
+ align-items: flex-start;
2196
+ justify-content: space-between;
2197
+ gap: 8px;
2198
+ margin-bottom: 6px;
2199
+ }
2200
+
2201
+ .scheduler-day-popover .popover-date {
2202
+ font-weight: 600;
2203
+ }
2204
+
2205
+ .scheduler-day-popover .popover-count,
2206
+ .scheduler-day-popover .popover-empty {
2207
+ font-size: 12px;
2208
+ color: var(--bs-secondary-color, #6c757d);
2209
+ }
2210
+
2211
+ .scheduler-day-popover .popover-empty {
2212
+ margin: 4px 0 8px;
2213
+ }
2214
+
2215
+ .scheduler-day-popover .popover-close {
2216
+ width: 24px;
2217
+ height: 24px;
2218
+ flex: 0 0 auto;
2219
+ display: flex;
2220
+ align-items: center;
2221
+ justify-content: center;
2222
+ padding: 0;
2223
+ border: 1px solid transparent;
2224
+ border-radius: 4px;
2225
+ background: transparent;
2226
+ color: inherit;
2227
+ font: inherit;
2228
+ cursor: pointer;
2229
+ }
2230
+
2231
+ .scheduler-day-popover .popover-events {
2232
+ list-style: none;
2233
+ margin: 0 0 8px;
2234
+ padding: 0;
2235
+ display: flex;
2236
+ flex-direction: column;
2237
+ gap: 2px;
2238
+ }
2239
+
2240
+ .scheduler-day-popover .popover-event {
2241
+ display: flex;
2242
+ align-items: center;
2243
+ gap: 8px;
2244
+ width: 100%;
2245
+ min-height: 28px;
2246
+ padding: 4px 6px;
2247
+ border: 1px solid transparent;
2248
+ border-radius: 4px;
2249
+ background: transparent;
2250
+ color: inherit;
2251
+ font: inherit;
2252
+ text-align: left;
2253
+ cursor: pointer;
2254
+ }
2255
+
2256
+ .scheduler-day-popover .popover-event:hover {
2257
+ background: var(--bs-secondary-bg, rgba(0, 0, 0, 0.08));
2258
+ }
2259
+
2260
+ /* A colour chip, NOT the only carrier of identity — the title next to it says
2261
+ which event this is (WCAG 1.4.1). */
2262
+ .scheduler-day-popover .popover-event-swatch {
2263
+ width: 10px;
2264
+ height: 10px;
2265
+ flex: 0 0 auto;
2266
+ border-radius: 2px;
2267
+ }
2268
+
2269
+ .scheduler-day-popover .popover-event-title {
2270
+ overflow: hidden;
2271
+ text-overflow: ellipsis;
2272
+ white-space: nowrap;
2273
+ }
2274
+
2275
+ .scheduler-day-popover .popover-actions {
2276
+ display: flex;
2277
+ flex-wrap: wrap;
2278
+ gap: 4px;
2279
+ }
2280
+
2281
+ .scheduler-day-popover .popover-action {
2282
+ min-height: 28px;
2283
+ padding: 4px 10px;
2284
+ border: 1px solid var(--scheduler-border-color);
2285
+ border-radius: 4px;
2286
+ background: var(--bs-body-bg);
2287
+ color: inherit;
2288
+ font: inherit;
2289
+ font-size: 12px;
2290
+ cursor: pointer;
2291
+ }
2292
+
2293
+ .scheduler-day-popover .popover-action.primary {
2294
+ background: var(--bs-primary);
2295
+ border-color: var(--bs-primary);
2296
+ color: #fff;
2297
+ }
2298
+
2299
+ .scheduler-day-popover button:focus-visible {
2300
+ outline: 2px solid var(--bs-primary);
2301
+ outline-offset: 1px;
2302
+ }
2303
+
1555
2304
  /* Year View */
1556
2305
  .scheduler-year-grid {
1557
2306
  display: grid;
@@ -1621,34 +2370,64 @@ const ee = W(`:host {
1621
2370
  color: var(--bs-secondary-color);
1622
2371
  }
1623
2372
 
1624
- /* Timeline View */
2373
+ /* Timeline View
2374
+ ONE scroller: \`.scheduler-content\` (same as week view). The timeline grows to
2375
+ its content width via \`min-width: fit-content\` and the header/column pin with
2376
+ \`position: sticky\`, so horizontal and vertical scrolling both happen on the
2377
+ element the component already treats as its scroller — which is what makes
2378
+ touch-pan, \`.scroll-blocked\` and the styled scrollbars work here at all.
2379
+ Previously \`.scheduler-timeline-body\` had its own \`overflow: auto\`, trapping
2380
+ the overflow in a nested scroller nothing knew about, while the header strip
2381
+ clipped ~16,800px of labels with no scroll sync. */
1625
2382
  .scheduler-timeline {
1626
2383
  display: flex;
1627
2384
  flex-direction: column;
1628
- height: 100%;
2385
+ min-height: 100%;
2386
+ min-width: fit-content;
2387
+ }
2388
+
2389
+ /* The grid claims the full scrollport height so its rows fill the panel. With
2390
+ the add bar below it that sums to more than 100% and every timeline gets a
2391
+ permanent vertical scrollbar, so drop the claim when the bar is present. */
2392
+ .scheduler-timeline:has(+ .scheduler-timeline-addbar) {
2393
+ min-height: auto;
2394
+ }
2395
+
2396
+ .scheduler-timeline-head {
2397
+ position: sticky;
2398
+ top: 0;
2399
+ z-index: 10;
2400
+ min-width: fit-content;
2401
+ background: var(--scheduler-header-bg);
1629
2402
  }
1630
2403
 
1631
2404
  .scheduler-timeline-header {
1632
2405
  display: flex;
1633
2406
  border-bottom: 1px solid var(--scheduler-border-color);
1634
2407
  background: var(--scheduler-header-bg);
1635
- position: sticky;
1636
- top: 0;
1637
- z-index: 10;
2408
+ min-width: fit-content;
1638
2409
  }
1639
2410
 
1640
2411
  .scheduler-resource-header {
1641
- width: 200px;
2412
+ width: var(--scheduler-resource-column-width);
2413
+ max-width: var(--scheduler-resource-column-width);
1642
2414
  flex-shrink: 0;
1643
2415
  padding: 8px;
1644
2416
  border-right: 1px solid var(--scheduler-border-color);
1645
2417
  font-weight: 600;
2418
+ /* Pinned on BOTH axes: inside the sticky header block, so it stays put
2419
+ horizontally as the grid scrolls and vertically with the header. */
2420
+ position: sticky;
2421
+ left: 0;
2422
+ z-index: 7;
2423
+ background: var(--scheduler-header-bg);
1646
2424
  }
1647
2425
 
1648
2426
  .scheduler-timeline-slots-header {
1649
2427
  display: flex;
1650
- flex: 1;
1651
- overflow: hidden;
2428
+ /* NOT flex: 1 — it must size to its content so the header travels with the
2429
+ grid instead of shrinking and clipping it. */
2430
+ flex: 0 0 auto;
1652
2431
  }
1653
2432
 
1654
2433
  .scheduler-timeline-slot-header {
@@ -1662,14 +2441,30 @@ const ee = W(`:host {
1662
2441
  .scheduler-timeline-body {
1663
2442
  display: flex;
1664
2443
  flex-direction: column;
1665
- flex: 1;
1666
- overflow: auto;
2444
+ /* No \`overflow: auto\` and no \`flex: 1\`: this must NOT be a scroller, or the
2445
+ horizontal overflow is trapped here instead of reaching .scheduler-content. */
2446
+ flex: 0 0 auto;
2447
+ min-width: fit-content;
2448
+ }
2449
+
2450
+ .scheduler-timeline-empty {
2451
+ padding: 16px;
2452
+ color: var(--bs-secondary-color, #6c757d);
2453
+ /* Sticky-left so the message stays readable while the grid scrolls, and
2454
+ narrow enough not to stretch the (already very wide) timeline. */
2455
+ position: sticky;
2456
+ left: 0;
2457
+ width: var(--scheduler-resource-column-width);
1667
2458
  }
1668
2459
 
1669
2460
  .scheduler-timeline-row {
1670
2461
  display: flex;
1671
2462
  border-bottom: 1px solid var(--scheduler-border-color);
1672
2463
  min-height: 40px;
2464
+ /* Required: this is the sticky resource cell's containing block, so without it
2465
+ the pinned column only travels one viewport-width. Also stops row borders,
2466
+ .group backgrounds and .selected highlights ending at the viewport edge. */
2467
+ min-width: fit-content;
1673
2468
  }
1674
2469
 
1675
2470
  .scheduler-timeline-row.group {
@@ -1677,14 +2472,37 @@ const ee = W(`:host {
1677
2472
  font-weight: 600;
1678
2473
  }
1679
2474
 
2475
+ .scheduler-timeline-row.group .scheduler-resource-cell {
2476
+ /* Sticky cells are transparent by default — a group row must keep its own
2477
+ tint or slots slide visibly underneath the pinned column. */
2478
+ background: var(--scheduler-header-bg);
2479
+ }
2480
+
1680
2481
  .scheduler-resource-cell {
1681
- width: 200px;
2482
+ width: var(--scheduler-resource-column-width);
2483
+ max-width: var(--scheduler-resource-column-width);
1682
2484
  flex-shrink: 0;
1683
2485
  padding: 8px;
1684
2486
  border-right: 1px solid var(--scheduler-border-color);
1685
2487
  display: flex;
1686
2488
  align-items: center;
1687
2489
  gap: 8px;
2490
+ /* Pinned left while the grid scrolls horizontally. Needs an opaque background
2491
+ for the same reason as above. */
2492
+ position: sticky;
2493
+ left: 0;
2494
+ z-index: 7;
2495
+ background: var(--bs-body-bg);
2496
+ }
2497
+
2498
+ .scheduler-resource-cell .resource-title {
2499
+ /* Ellipsis rather than wrap: the row is a fixed 40px and the action buttons
2500
+ must not be pushed out of the pinned column by a long title. */
2501
+ flex: 1 1 auto;
2502
+ min-width: 0;
2503
+ overflow: hidden;
2504
+ text-overflow: ellipsis;
2505
+ white-space: nowrap;
1688
2506
  }
1689
2507
 
1690
2508
  .scheduler-resource-cell .expand-toggle {
@@ -1694,11 +2512,106 @@ const ee = W(`:host {
1694
2512
  display: flex;
1695
2513
  align-items: center;
1696
2514
  justify-content: center;
2515
+ flex: 0 0 auto;
2516
+ }
2517
+
2518
+ /* Row actions. Hidden affordances were rejected: revealing these on hover only
2519
+ would leave them undiscoverable on touch, where there is no hover. */
2520
+ .scheduler-resource-actions {
2521
+ display: flex;
2522
+ align-items: center;
2523
+ gap: 2px;
2524
+ flex: 0 0 auto;
2525
+ margin-left: auto;
2526
+ }
2527
+
2528
+ .scheduler-resource-action {
2529
+ /* 24x24 = WCAG 2.2 SC 2.5.8 minimum target size. The glyph is smaller; the
2530
+ button is not. */
2531
+ width: 24px;
2532
+ height: 24px;
2533
+ display: flex;
2534
+ align-items: center;
2535
+ justify-content: center;
2536
+ padding: 0;
2537
+ cursor: pointer;
2538
+ border: 1px solid transparent;
2539
+ border-radius: 4px;
2540
+ background: transparent;
2541
+ color: inherit;
2542
+ font: inherit;
2543
+ line-height: 1;
2544
+ }
2545
+
2546
+ .scheduler-resource-action:hover {
2547
+ background: var(--bs-secondary-bg, rgba(0, 0, 0, 0.08));
2548
+ }
2549
+
2550
+ .scheduler-resource-action .action-glyph {
2551
+ font-size: 14px;
2552
+ pointer-events: none;
2553
+ }
2554
+
2555
+ .scheduler-resource-color {
2556
+ /* A native colour input is ~44px wide by default and would eat the column. */
2557
+ width: 24px;
2558
+ height: 24px;
2559
+ padding: 0;
2560
+ border: 1px solid var(--scheduler-border-color);
2561
+ border-radius: 4px;
2562
+ background: transparent;
2563
+ cursor: pointer;
2564
+ flex: 0 0 auto;
2565
+ }
2566
+
2567
+ /* Root-level creation bar, pinned to the foot of the frozen resource column.
2568
+ \`left: 0\` as well as \`bottom: 0\` so it tracks the column, not the grid, while
2569
+ the timeline scrolls horizontally. */
2570
+ .scheduler-timeline-addbar {
2571
+ position: sticky;
2572
+ bottom: 0;
2573
+ left: 0;
2574
+ z-index: 7;
2575
+ display: flex;
2576
+ flex-wrap: wrap;
2577
+ gap: 4px;
2578
+ width: var(--scheduler-resource-column-width);
2579
+ padding: 4px 8px;
2580
+ border-top: 1px solid var(--scheduler-border-color);
2581
+ background: var(--scheduler-header-bg);
2582
+ }
2583
+
2584
+ .scheduler-add-button {
2585
+ min-height: 24px;
2586
+ padding: 2px 8px;
2587
+ cursor: pointer;
2588
+ border: 1px solid var(--scheduler-border-color);
2589
+ border-radius: 4px;
2590
+ background: var(--bs-body-bg);
2591
+ color: inherit;
2592
+ font: inherit;
2593
+ font-size: 12px;
2594
+ }
2595
+
2596
+ .scheduler-add-button:hover {
2597
+ background: var(--bs-secondary-bg, rgba(0, 0, 0, 0.08));
2598
+ }
2599
+
2600
+ /* One focus ring for every control in the resource column. \`.expand-toggle\` had
2601
+ none at all — Bootstrap's focus-ring utilities do not cross the shadow
2602
+ boundary, so a keyboard user tabbing onto it saw nothing. */
2603
+ .scheduler-resource-cell .expand-toggle:focus-visible,
2604
+ .scheduler-resource-action:focus-visible,
2605
+ .scheduler-resource-color:focus-visible,
2606
+ .scheduler-add-button:focus-visible {
2607
+ outline: 2px solid var(--bs-primary);
2608
+ outline-offset: 1px;
1697
2609
  }
1698
2610
 
1699
2611
  .scheduler-timeline-slots {
1700
2612
  display: flex;
1701
- flex: 1;
2613
+ /* Explicit rather than relying on \`min-width: auto\` to push past the row box. */
2614
+ flex: 0 0 auto;
1702
2615
  position: relative;
1703
2616
  }
1704
2617
 
@@ -1720,7 +2633,7 @@ const ee = W(`:host {
1720
2633
  .scheduler-timeline-slot:focus {
1721
2634
  outline: 2px solid var(--bs-primary);
1722
2635
  outline-offset: -2px;
1723
- z-index: 1;
2636
+ z-index: 6;
1724
2637
  }
1725
2638
 
1726
2639
  .scheduler-timeline-events {
@@ -1734,20 +2647,74 @@ const ee = W(`:host {
1734
2647
 
1735
2648
  .scheduler-timeline-event {
1736
2649
  position: absolute;
1737
- height: calc(100% - 4px);
1738
- top: 2px;
2650
+ /* top/height come from the track stack (set inline per event); the fallbacks
2651
+ here only apply to the drag ghost before it copies its source's band. */
2652
+ height: var(--scheduler-timeline-event-height);
2653
+ top: var(--scheduler-timeline-row-padding);
1739
2654
  border-radius: var(--scheduler-event-border-radius);
1740
2655
  padding: 2px 6px;
1741
2656
  font-size: 12px;
1742
- overflow: hidden;
2657
+ /* Unclipped so the selected-state handles/glyphs straddle the left/right
2658
+ edges; title clipping lives on .event-content (same as .scheduler-event). */
2659
+ overflow: visible;
1743
2660
  cursor: pointer;
1744
2661
  pointer-events: auto;
1745
2662
  }
1746
2663
 
1747
2664
  .scheduler-timeline-event.selected {
1748
2665
  box-shadow: 0 0 0 3px var(--bs-body-color);
2666
+ z-index: 2;
2667
+ }
2668
+
2669
+ .scheduler-timeline-event.preview {
2670
+ background: var(--scheduler-preview-bg);
2671
+ border: 2px dashed var(--bs-primary);
2672
+ pointer-events: none;
2673
+ z-index: 4;
2674
+ }
2675
+
2676
+ /* Horizontal resize handles — timeline counterpart of the week/day strips. */
2677
+ .scheduler-timeline-event .resize-handle {
2678
+ position: absolute;
2679
+ top: 0;
2680
+ bottom: 0;
2681
+ width: 8px;
2682
+ cursor: ew-resize;
2683
+ touch-action: none;
2684
+ -ms-touch-action: none;
2685
+ }
2686
+
2687
+ .scheduler-timeline-event .resize-handle.left {
2688
+ left: 0;
2689
+ }
2690
+
2691
+ .scheduler-timeline-event .resize-handle.right {
2692
+ right: 0;
2693
+ }
2694
+
2695
+ .scheduler-timeline-event.selected .resize-handle {
2696
+ width: 24px;
2697
+ }
2698
+
2699
+ .scheduler-timeline-event.selected .resize-handle.left {
2700
+ left: -12px;
2701
+ }
2702
+
2703
+ .scheduler-timeline-event.selected .resize-handle.right {
2704
+ right: -12px;
1749
2705
  }
1750
2706
 
2707
+ @media (pointer: coarse) {
2708
+ .scheduler-timeline-event.selected .resize-handle {
2709
+ width: 44px;
2710
+ }
2711
+ .scheduler-timeline-event.selected .resize-handle.left {
2712
+ left: -22px;
2713
+ }
2714
+ .scheduler-timeline-event.selected .resize-handle.right {
2715
+ right: -22px;
2716
+ }
2717
+ }
1751
2718
  /* Loading state */
1752
2719
  .scheduler-loading {
1753
2720
  display: flex;
@@ -1791,7 +2758,10 @@ const ee = W(`:host {
1791
2758
  .scheduler-event.touch-hold-active {
1792
2759
  transform: scale(1.02);
1793
2760
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
1794
- z-index: 100;
2761
+ /* Was 100, which painted a held event over the sticky day-header row (they
2762
+ share one scroller and one stacking context). It only needs to out-rank
2763
+ other events; the preview still goes above it. */
2764
+ z-index: 3;
1795
2765
  touch-action: none;
1796
2766
  -ms-touch-action: none;
1797
2767
  }
@@ -1850,18 +2820,19 @@ const ee = W(`:host {
1850
2820
 
1851
2821
  @media (prefers-reduced-motion: reduce) {
1852
2822
  .scheduler-event,
1853
- .scheduler-timeline-event {
2823
+ .scheduler-timeline-event,
2824
+ .resize-glyph {
1854
2825
  animation: none !important;
1855
2826
  transition: none !important;
1856
2827
  }
1857
- }`), L = {
2828
+ }`), V = {
1858
2829
  dragThreshold: 5,
1859
2830
  minDurationMs: 1800 * 1e3
1860
2831
  // 30 minutes
1861
2832
  };
1862
- class te {
2833
+ class we {
1863
2834
  constructor(e = {}) {
1864
- this.config = { ...L, ...e };
2835
+ this.config = { ...V, ...e };
1865
2836
  }
1866
2837
  /**
1867
2838
  * Calculate the preview event position based on drag state.
@@ -1896,15 +2867,19 @@ class te {
1896
2867
  ), n = new Date(
1897
2868
  Math.max(e.end.getTime(), t.end.getTime())
1898
2869
  );
1899
- return { start: s, end: n };
2870
+ return {
2871
+ start: s,
2872
+ end: n,
2873
+ ...e.resourceId ? { resourceId: e.resourceId } : {}
2874
+ };
1900
2875
  }
1901
2876
  /**
1902
2877
  * Calculate preview for moving an existing event.
1903
2878
  * Preserves event duration, applies offset from drag start.
1904
2879
  */
1905
2880
  calculateMovePreview(e, t, s) {
1906
- const n = t.start.getTime() - e.start.getTime(), i = s.end.getTime() - s.start.getTime(), o = new Date(s.start.getTime() + n), r = new Date(o.getTime() + i);
1907
- return { start: o, end: r };
2881
+ const n = t.start.getTime() - e.start.getTime(), i = s.end.getTime() - s.start.getTime(), r = new Date(s.start.getTime() + n), o = new Date(r.getTime() + i);
2882
+ return { start: r, end: o };
1908
2883
  }
1909
2884
  /**
1910
2885
  * Calculate preview for resizing event start.
@@ -1929,36 +2904,36 @@ class te {
1929
2904
  return { start: t.start, end: n };
1930
2905
  }
1931
2906
  }
1932
- function C(g) {
2907
+ function H(u) {
1933
2908
  return {
1934
2909
  pointerId: 0,
1935
2910
  pointerType: "mouse",
1936
- clientX: g.clientX,
1937
- clientY: g.clientY,
1938
- originalEvent: g,
1939
- target: g.target,
2911
+ clientX: u.clientX,
2912
+ clientY: u.clientY,
2913
+ originalEvent: u,
2914
+ target: u.target,
1940
2915
  isPrimary: !0
1941
2916
  };
1942
2917
  }
1943
- function F(g) {
1944
- const e = g.touches[0] || g.changedTouches[0];
2918
+ function B(u) {
2919
+ const e = u.touches[0] || u.changedTouches[0];
1945
2920
  return e ? {
1946
2921
  pointerId: e.identifier,
1947
2922
  pointerType: "touch",
1948
2923
  clientX: e.clientX,
1949
2924
  clientY: e.clientY,
1950
- originalEvent: g,
2925
+ originalEvent: u,
1951
2926
  target: e.target,
1952
2927
  isPrimary: e.identifier === 0
1953
2928
  } : null;
1954
2929
  }
1955
- function z(g, e) {
1956
- const t = e.x - g.x, s = e.y - g.y;
2930
+ function J(u, e) {
2931
+ const t = e.x - u.x, s = e.y - u.y;
1957
2932
  return Math.sqrt(t * t + s * s);
1958
2933
  }
1959
- class se {
2934
+ class Ee {
1960
2935
  constructor(e = {}) {
1961
- this.state = { phase: "idle" }, this.config = { ...L, ...e }, this.previewCalculator = new te(this.config);
2936
+ this.state = { phase: "idle" }, this.config = { ...V, ...e }, this.previewCalculator = new we(this.config);
1962
2937
  }
1963
2938
  /**
1964
2939
  * Get current state (read-only).
@@ -2051,20 +3026,20 @@ class se {
2051
3026
  transitionFromIdle(e) {
2052
3027
  if (e.type !== "POINTER_DOWN")
2053
3028
  return this.state;
2054
- const { target: t, position: s, slot: n, slotElement: i, immediate: o } = e, r = this.getOperationType(t);
2055
- if (!r)
3029
+ const { target: t, position: s, slot: n, slotElement: i, immediate: r } = e, o = this.getOperationType(t);
3030
+ if (!o)
2056
3031
  return this.state;
2057
3032
  const a = t.event ?? null;
2058
3033
  if (a && a.draggable === !1)
2059
3034
  return this.state;
2060
- if (o) {
3035
+ if (r) {
2061
3036
  let l = n;
2062
- if (!l && a && r === "move" && (l = {
3037
+ if (!l && a && (l = {
2063
3038
  start: a.start,
2064
3039
  end: a.end
2065
3040
  }), l) {
2066
3041
  const d = this.previewCalculator.calculatePreview(
2067
- r,
3042
+ o,
2068
3043
  l,
2069
3044
  l,
2070
3045
  a
@@ -2072,7 +3047,7 @@ class se {
2072
3047
  if (d)
2073
3048
  return {
2074
3049
  phase: "active",
2075
- operationType: r,
3050
+ operationType: o,
2076
3051
  event: a,
2077
3052
  startSlot: l,
2078
3053
  currentSlot: l,
@@ -2083,7 +3058,7 @@ class se {
2083
3058
  }
2084
3059
  return {
2085
3060
  phase: "pending",
2086
- operationType: r,
3061
+ operationType: o,
2087
3062
  event: a,
2088
3063
  startPosition: s,
2089
3064
  startSlot: n,
@@ -2097,7 +3072,7 @@ class se {
2097
3072
  if (this.state.phase !== "pending") return this.state;
2098
3073
  switch (e.type) {
2099
3074
  case "POINTER_MOVE":
2100
- return z(
3075
+ return J(
2101
3076
  this.state.startPosition,
2102
3077
  e.position
2103
3078
  ) < this.config.dragThreshold ? this.state : this.activateDrag(e.slot);
@@ -2215,9 +3190,9 @@ class se {
2215
3190
  } : { start: /* @__PURE__ */ new Date(), end: /* @__PURE__ */ new Date() };
2216
3191
  }
2217
3192
  }
2218
- class ne {
3193
+ class xe {
2219
3194
  constructor(e, t = {}) {
2220
- this.pendingUpdate = null, this.latestPointer = null, this.getSlotAtPosition = null, this.stateManager = e, this.config = { ...L, ...t }, this.stateMachine = new se(this.config);
3195
+ this.pendingUpdate = null, this.latestPointer = null, this.getSlotAtPosition = null, this.stateManager = e, this.config = { ...V, ...t }, this.stateMachine = new Ee(this.config);
2221
3196
  }
2222
3197
  /**
2223
3198
  * Set the function used to get a slot at a position.
@@ -2308,7 +3283,7 @@ class ne {
2308
3283
  */
2309
3284
  createEventFromResult(e) {
2310
3285
  return {
2311
- id: V(),
3286
+ id: ie(),
2312
3287
  title: "New Event",
2313
3288
  start: e.preview.start,
2314
3289
  end: e.preview.end,
@@ -2361,8 +3336,8 @@ class ne {
2361
3336
  this.pendingUpdate !== null && (cancelAnimationFrame(this.pendingUpdate), this.pendingUpdate = null), this.latestPointer = null;
2362
3337
  }
2363
3338
  }
2364
- const ie = 600, oe = 10;
2365
- class re {
3339
+ const De = 600, Se = 10;
3340
+ class Ce {
2366
3341
  constructor(e, t) {
2367
3342
  this.touchHoldTimer = null, this.touchStartPosition = null, this.isTouchDragMode = !1, this.touchHoldTarget = null, this.touchHoldPointer = null, this.isPanMode = !1, this.panStartPosition = null, this.panStartScroll = null, this.panStartedOnEvent = !1, this.savedBodyStyles = null, this.config = e, this.callbacks = t, this.boundHandleMouseDown = this.handleMouseDown.bind(this), this.boundHandleMouseMove = this.handleMouseMove.bind(this), this.boundHandleMouseUp = this.handleMouseUp.bind(this), this.boundHandleClick = this.handleClick.bind(this), this.boundHandleDblClick = this.handleDblClick.bind(this), this.boundHandleTouchStart = this.handleTouchStart.bind(this), this.boundHandleTouchMove = this.handleTouchMove.bind(this), this.boundHandleTouchEnd = this.handleTouchEnd.bind(this), this.boundHandleTouchCancel = this.handleTouchCancel.bind(this);
2368
3343
  }
@@ -2396,19 +3371,23 @@ class re {
2396
3371
  analyzeTarget(e) {
2397
3372
  const t = e.closest(".resize-handle");
2398
3373
  if (t) {
2399
- const o = t.closest(".scheduler-event")?.dataset.eventId, r = o ? this.config.getEventById(o) : null;
2400
- if (r)
3374
+ const r = t.closest(
3375
+ ".scheduler-event, .scheduler-timeline-event"
3376
+ )?.dataset.eventId, o = r ? this.config.getEventById(r) : null;
3377
+ if (o)
2401
3378
  return {
2402
3379
  type: "resize-handle",
2403
- event: r,
3380
+ event: o,
2404
3381
  resizeHandle: t.dataset.handle
2405
3382
  };
2406
3383
  }
2407
- const s = e.closest(".scheduler-event:not(.preview)");
3384
+ const s = e.closest(
3385
+ ".scheduler-event:not(.preview), .scheduler-timeline-event:not(.preview)"
3386
+ );
2408
3387
  if (s) {
2409
- const i = s.dataset.eventId, o = i ? this.config.getEventById(i) : null;
2410
- if (o)
2411
- return { type: "event", event: o };
3388
+ const i = s.dataset.eventId, r = i ? this.config.getEventById(i) : null;
3389
+ if (r)
3390
+ return { type: "event", event: r };
2412
3391
  }
2413
3392
  const n = e.closest(
2414
3393
  ".scheduler-time-slot, .scheduler-timeline-slot"
@@ -2418,23 +3397,23 @@ class re {
2418
3397
  // Mouse event handlers
2419
3398
  handleMouseDown(e) {
2420
3399
  if (!this.config.isEditable()) return;
2421
- const t = C(e), s = this.analyzeTarget(t.target);
3400
+ const t = H(e), s = this.analyzeTarget(t.target);
2422
3401
  s.type !== "none" && (s.type === "slot" && !this.config.isSelectable() || (e.preventDefault(), this.callbacks.onPointerDown(t, s)));
2423
3402
  }
2424
3403
  handleMouseMove(e) {
2425
- const t = C(e);
3404
+ const t = H(e);
2426
3405
  this.callbacks.onPointerMove(t);
2427
3406
  }
2428
3407
  handleMouseUp(e) {
2429
- const t = C(e);
3408
+ const t = H(e);
2430
3409
  this.callbacks.onPointerUp(t);
2431
3410
  }
2432
3411
  handleClick(e) {
2433
- const t = C(e), s = this.analyzeTarget(t.target);
3412
+ const t = H(e), s = this.analyzeTarget(t.target);
2434
3413
  s.type === "event" || s.type === "resize-handle" || this.callbacks.onClick(t, s);
2435
3414
  }
2436
3415
  handleDblClick(e) {
2437
- const t = C(e), s = this.analyzeTarget(t.target);
3416
+ const t = H(e), s = this.analyzeTarget(t.target);
2438
3417
  this.callbacks.onDoubleClick(t, s);
2439
3418
  }
2440
3419
  // Touch event handlers
@@ -2444,38 +3423,42 @@ class re {
2444
3423
  this.cancelTouchHold();
2445
3424
  return;
2446
3425
  }
2447
- const t = F(e);
3426
+ const t = B(e);
2448
3427
  if (!t) return;
2449
3428
  const s = this.analyzeTarget(t.target);
2450
3429
  if (s.type === "none" || s.type === "slot" && !this.config.isSelectable()) return;
2451
3430
  this.touchStartPosition = { x: t.clientX, y: t.clientY }, this.touchHoldTarget = t.target, this.touchHoldPointer = t, this.panStartedOnEvent = s.type === "event" || s.type === "resize-handle";
2452
3431
  const n = this, i = e.target;
2453
- i.addEventListener("touchmove", function(r) {
2454
- n.handleTouchMove(r);
2455
- }, { passive: !1 }), i.addEventListener("touchend", function(r) {
2456
- n.handleTouchEnd(r);
2457
- }), i.addEventListener("touchcancel", function(r) {
2458
- n.handleTouchCancel(r);
2459
- }), this.addTouchFeedback(t.target, "pending");
2460
- const o = this.config.touchHoldDuration ?? ie;
3432
+ if (i.addEventListener("touchmove", function(o) {
3433
+ n.handleTouchMove(o);
3434
+ }, { passive: !1 }), i.addEventListener("touchend", function(o) {
3435
+ n.handleTouchEnd(o);
3436
+ }), i.addEventListener("touchcancel", function(o) {
3437
+ n.handleTouchCancel(o);
3438
+ }), s.type === "resize-handle" && s.event && this.config.isEventSelected?.(s.event.id)) {
3439
+ this.activateTouchDragMode(t, s);
3440
+ return;
3441
+ }
3442
+ this.addTouchFeedback(t.target, "pending");
3443
+ const r = this.config.touchHoldDuration ?? De;
2461
3444
  this.touchHoldTimer = setTimeout(() => {
2462
3445
  this.activateTouchDragMode(t, s);
2463
- }, o);
3446
+ }, r);
2464
3447
  }
2465
3448
  handleTouchMove(e) {
2466
3449
  if (e.touches.length !== 1) {
2467
3450
  this.cancelTouchHold(), this.exitPanMode();
2468
3451
  return;
2469
3452
  }
2470
- const t = F(e);
3453
+ const t = B(e);
2471
3454
  if (t) {
2472
3455
  if (this.isPanMode) {
2473
3456
  e.preventDefault(), this.performPan(t.clientX, t.clientY);
2474
3457
  return;
2475
3458
  }
2476
3459
  if (this.touchHoldTimer && this.touchStartPosition) {
2477
- const s = this.config.touchMoveThreshold ?? oe;
2478
- if (z(this.touchStartPosition, {
3460
+ const s = this.config.touchMoveThreshold ?? Se;
3461
+ if (J(this.touchStartPosition, {
2479
3462
  x: t.clientX,
2480
3463
  y: t.clientY
2481
3464
  }) > s) {
@@ -2489,7 +3472,7 @@ class re {
2489
3472
  }
2490
3473
  }
2491
3474
  handleTouchEnd(e) {
2492
- const t = F(e);
3475
+ const t = B(e);
2493
3476
  if (this.isPanMode) {
2494
3477
  this.exitPanMode();
2495
3478
  return;
@@ -2570,20 +3553,22 @@ class re {
2570
3553
  e && e.classList.remove("scroll-blocked");
2571
3554
  }
2572
3555
  }
2573
- class ae {
3556
+ class Me {
2574
3557
  constructor(e) {
2575
3558
  this.host = e;
2576
3559
  }
2577
3560
  /**
2578
- * Emit a scheduler custom event.
2579
- * The event will bubble up through the DOM.
3561
+ * Emit a scheduler custom event. `composed` as well as `bubbles`: without it
3562
+ * the event stops at the shadow boundary of any component the scheduler is
3563
+ * nested inside, so a wrapper-of-a-wrapper never sees it.
2580
3564
  */
2581
3565
  emit(e) {
2582
3566
  const { type: t, ...s } = e;
2583
3567
  this.host.dispatchEvent(
2584
3568
  new CustomEvent(t, {
2585
3569
  detail: s,
2586
- bubbles: !0
3570
+ bubbles: !0,
3571
+ composed: !0
2587
3572
  })
2588
3573
  );
2589
3574
  }
@@ -2640,13 +3625,61 @@ class ae {
2640
3625
  emitSelectionChange(e, t, s, n) {
2641
3626
  this.emit({ type: "selection-change", selectedEvent: e, range: t, view: s, resourceId: n });
2642
3627
  }
3628
+ /**
3629
+ * Emit a `resource-create` or `group-create` *request*. Same controlled
3630
+ * contract as `event-create`: the scheduler never edits its own `resources`
3631
+ * input, so the consumer decides the id, title and placement. `parentId` is
3632
+ * the group to insert into — absent means root level.
3633
+ */
3634
+ emitResourceCreate(e, t, s, n) {
3635
+ this.emit({
3636
+ type: e === "group" ? "group-create" : "resource-create",
3637
+ parentId: n,
3638
+ view: t,
3639
+ originalEvent: s
3640
+ });
3641
+ }
3642
+ /**
3643
+ * Emit a `resource-update` request carrying only the changed fields, so the
3644
+ * consumer can apply them without diffing.
3645
+ */
3646
+ emitResourceUpdate(e, t, s) {
3647
+ this.emit({ type: "resource-update", resource: e, changes: t, originalEvent: s });
3648
+ }
3649
+ /**
3650
+ * Emit a `resource-delete` request.
3651
+ */
3652
+ emitResourceDelete(e, t) {
3653
+ this.emit({ type: "resource-delete", resource: e, originalEvent: t });
3654
+ }
2643
3655
  }
2644
- class le extends B {
3656
+ class I extends ee {
2645
3657
  constructor() {
2646
- super(), this.currentView = null, this.currentViewType = null, this.contentContainer = null, this.inputHandler = null, this.previousView = null, this.previousDate = null, this.previousSelectedEventId = null, this.previousRangeKey = "__init__", this.pendingDragUpdate = null, this.latestDragState = null, this.nowIndicatorTimer = null, this.liveAnnouncer = new O(this), this.previousIsLoading = null, this.keyboardMove = null, this.stateManager = new Y(), this.eventEmitter = new ae(this), this.dragManager = new ne(this.stateManager), this.dragManager.setSlotResolver((e, t) => this.getSlotAtPosition(e, t)), this.boundHandleKeyDown = this.handleKeyDown.bind(this), this.boundHandleFocusIn = this.handleFocusIn.bind(this), this.stateManager.subscribe((e) => this.onStateChange(e));
3658
+ super(), this.currentView = null, this.currentViewType = null, this.contentContainer = null, this.inputHandler = null, this.previousView = null, this.previousDate = null, this.previousSelectedEventId = null, this.previousRangeKey = "__init__", this.pendingDragUpdate = null, this.latestDragState = null, this.nowIndicatorTimer = null, this.liveAnnouncer = new te(this), this.popoverDate = null, this.popoverAnchorKey = null, this.dayPopover = new re(this, {
3659
+ anchor: () => this.popoverAnchorCell(),
3660
+ // Same element as the anchor: the day cell IS the trigger. Spelling it out
3661
+ // means focus returns to the day even when the popover was opened without
3662
+ // anything focused (a programmatic open, or a click on a `tabindex="-1"`
3663
+ // cell that some paths do not focus) instead of falling to <body>.
3664
+ trigger: () => this.popoverAnchorCell(),
3665
+ panel: () => this.shadowRoot?.querySelector(".scheduler-day-popover") ?? null,
3666
+ // The first EVENT, or failing that the first action — not `'first'`, which
3667
+ // is the close button in the header: opening a dialog with focus on "close"
3668
+ // means the user's first Enter dismisses what they just asked to see.
3669
+ initialFocus: () => {
3670
+ const e = this.shadowRoot?.querySelector(".scheduler-day-popover");
3671
+ return e?.querySelector(".popover-event") ?? e?.querySelector(".popover-action") ?? null;
3672
+ },
3673
+ modal: !1,
3674
+ // Dismissal comes from the controller (Escape via the dismiss stack, outside
3675
+ // mousedown), so mirror it into our own state or the panel stays rendered.
3676
+ onClose: () => {
3677
+ this.popoverDate = null, this.popoverAnchorKey = null, this.requestUpdate();
3678
+ }
3679
+ }), this.headerResizeObserver = null, this.headerIsNarrow = !1, this.previousIsLoading = null, this.edgeScrollFrame = null, this.edgeScrollVector = { x: 0, y: 0 }, this.edgeScrollPointer = null, this.lastEventActivation = null, this.keyboardMove = null, this.stateManager = new de(), this.eventEmitter = new Me(this), this.dragManager = new xe(this.stateManager), this.dragManager.setSlotResolver((e, t) => this.getSlotAtPosition(e, t)), this.boundHandleKeyDown = this.handleKeyDown.bind(this), this.boundHandleFocusIn = this.handleFocusIn.bind(this), this.boundHandleValueChange = this.handleValueChange.bind(this), this.boundRepositionPopover = () => this.dayPopover.position(), this.stateManager.subscribe((e) => this.onStateChange(e));
2647
3680
  }
2648
3681
  static {
2649
- this.styles = [ee];
3682
+ this.styles = [be];
2650
3683
  }
2651
3684
  static get observedAttributes() {
2652
3685
  return [
@@ -2657,15 +3690,14 @@ class le extends B {
2657
3690
  "first-day-of-week",
2658
3691
  "slot-duration",
2659
3692
  "time-format",
2660
- "editable",
2661
- "selectable"
3693
+ "readonly"
2662
3694
  ];
2663
3695
  }
2664
3696
  connectedCallback() {
2665
- super.connectedCallback(), this.inputHandler && this.inputHandler.attach(), this.addEventListener("keydown", this.boundHandleKeyDown), this.startNowIndicatorTimer();
3697
+ super.connectedCallback(), this.inputHandler && this.inputHandler.attach(), this.syncPermissions(), this.addEventListener("keydown", this.boundHandleKeyDown), this.startNowIndicatorTimer();
2666
3698
  }
2667
3699
  disconnectedCallback() {
2668
- this.inputHandler?.detach(), this.removeEventListener("keydown", this.boundHandleKeyDown), this.shadowRoot?.removeEventListener("focusin", this.boundHandleFocusIn), this.currentView?.destroy(), this.dragManager.destroy(), this.stopNowIndicatorTimer(), this.pendingDragUpdate !== null && (cancelAnimationFrame(this.pendingDragUpdate), this.pendingDragUpdate = null), this.latestDragState = null, super.disconnectedCallback();
3700
+ this.inputHandler?.detach(), this.removeEventListener("keydown", this.boundHandleKeyDown), this.shadowRoot?.removeEventListener("focusin", this.boundHandleFocusIn), this.shadowRoot?.removeEventListener("change", this.boundHandleValueChange), this.currentView?.destroy(), this.dragManager.destroy(), this.stopNowIndicatorTimer(), this.headerResizeObserver?.disconnect(), this.headerResizeObserver = null, this.stopEdgeScroll(), this.pendingDragUpdate !== null && (cancelAnimationFrame(this.pendingDragUpdate), this.pendingDragUpdate = null), this.latestDragState = null, super.disconnectedCallback();
2669
3701
  }
2670
3702
  attributeChangedCallback(e, t, s) {
2671
3703
  if (super.attributeChangedCallback(e, t, s), t !== s)
@@ -2693,11 +3725,8 @@ class le extends B {
2693
3725
  case "time-format":
2694
3726
  s && (s === "12h" || s === "24h") && this.stateManager.setOptions({ timeFormat: s });
2695
3727
  break;
2696
- case "editable":
2697
- this.stateManager.setOptions({ editable: s !== "false" });
2698
- break;
2699
- case "selectable":
2700
- this.stateManager.setOptions({ selectable: s !== "false" });
3728
+ case "readonly":
3729
+ this.syncPermissions();
2701
3730
  break;
2702
3731
  }
2703
3732
  }
@@ -2716,6 +3745,21 @@ class le extends B {
2716
3745
  set date(e) {
2717
3746
  this.stateManager.setDate(e);
2718
3747
  }
3748
+ /**
3749
+ * Coarse read-only switch, outranking `options.permissions` entirely.
3750
+ *
3751
+ * Property and attribute are the same state, deliberately: a JS consumer
3752
+ * writes `el.readonly = true`, a plain-HTML or SSR consumer writes the
3753
+ * attribute, and a framework wrapper can bridge whichever it has. Absence is
3754
+ * editable; `readonly="false"` opts back out so the attribute can be rendered
3755
+ * unconditionally with a computed value.
3756
+ */
3757
+ get readonly() {
3758
+ return this.hasAttribute("readonly") && this.getAttribute("readonly") !== "false";
3759
+ }
3760
+ set readonly(e) {
3761
+ e ? this.setAttribute("readonly", "") : this.removeAttribute("readonly");
3762
+ }
2719
3763
  get events() {
2720
3764
  return this.stateManager.getState().events;
2721
3765
  }
@@ -2732,7 +3776,7 @@ class le extends B {
2732
3776
  return this.stateManager.getState().options;
2733
3777
  }
2734
3778
  set options(e) {
2735
- this.stateManager.setOptions(e);
3779
+ this.stateManager.setOptions(e), this.syncPermissions();
2736
3780
  }
2737
3781
  get selectedEvent() {
2738
3782
  return this.stateManager.getState().selectedEvent;
@@ -2757,7 +3801,18 @@ class le extends B {
2757
3801
  this.stateManager.gotoDate(e);
2758
3802
  }
2759
3803
  changeView(e) {
2760
- this.stateManager.setView(e), this.liveAnnouncer.announce(`View changed to ${e}.`);
3804
+ this.stateManager.setView(e), this.liveAnnouncer.announce(this.msg("viewChanged", { view: this.viewLabel(e) }));
3805
+ }
3806
+ /** Localized display name of a view (also the view-switcher button text). */
3807
+ viewLabel(e) {
3808
+ const t = {
3809
+ year: "viewYear",
3810
+ month: "viewMonth",
3811
+ week: "viewWeek",
3812
+ day: "viewDay",
3813
+ timeline: "viewTimeline"
3814
+ };
3815
+ return this.msg(t[e]);
2761
3816
  }
2762
3817
  /**
2763
3818
  * Clear the time-range selection and the focused-cell selection. Public
@@ -2769,41 +3824,223 @@ class le extends B {
2769
3824
  this.stateManager.clearSelection();
2770
3825
  }
2771
3826
  addEvent(e) {
2772
- this.stateManager.addEvent(e), this.liveAnnouncer.announce(`Event ${e.title} added.`);
3827
+ this.stateManager.addEvent(e), this.liveAnnouncer.announce(this.msg("eventAdded", { title: e.title }));
2773
3828
  }
2774
3829
  updateEvent(e) {
2775
- this.stateManager.updateEvent(e), this.liveAnnouncer.announce(`Event ${e.title} updated.`);
3830
+ this.stateManager.updateEvent(e), this.liveAnnouncer.announce(this.msg("eventUpdated", { title: e.title }));
2776
3831
  }
2777
3832
  removeEvent(e) {
2778
3833
  const t = this.getEventById(e);
2779
- this.stateManager.removeEvent(e), t && this.liveAnnouncer.announce(`Event ${t.title} removed.`);
3834
+ this.stateManager.removeEvent(e), t && this.liveAnnouncer.announce(this.msg("eventRemoved", { title: t.title }));
2780
3835
  }
2781
3836
  getEventById(e) {
2782
- return this.events.find((t) => t.id === e) ?? null;
3837
+ return this.stateManager.getState().events.find((t) => t.id === e) ?? null;
2783
3838
  }
2784
3839
  refetchEvents() {
2785
3840
  this.currentView?.update(this.stateManager.getState());
2786
3841
  }
3842
+ /**
3843
+ * Localized string lookup: options.messages overrides merged onto the
3844
+ * English defaults, with {placeholder} interpolation.
3845
+ */
3846
+ msg(e, t) {
3847
+ return S(
3848
+ x(this.stateManager.getState().options.messages)[e],
3849
+ t
3850
+ );
3851
+ }
2787
3852
  // ============================================
2788
3853
  // Rendering
2789
3854
  // ============================================
2790
3855
  render() {
2791
- return U`
3856
+ return A`
2792
3857
  <div class="scheduler-container">
2793
3858
  <header class="scheduler-header"></header>
2794
3859
  <div class="scheduler-content"></div>
2795
3860
  </div>
3861
+ <div id="scheduler-kbd-grid" class="visually-hidden">
3862
+ ${this.msg(this.can("createEvent") || this.can("selectRange") ? "gridInstructions" : "gridInstructionsReadOnly")}
3863
+ </div>
3864
+ <div id="scheduler-kbd-event" class="visually-hidden">
3865
+ ${this.msg(
3866
+ this.can("moveEvent") || this.can("resizeEventStart") || this.can("resizeEventEnd") || this.can("deleteEvent") ? "eventInstructions" : "eventInstructionsReadOnly"
3867
+ )}
3868
+ </div>
3869
+ ${this.renderDayPopover()}
2796
3870
  ${this.liveAnnouncer.template()}
2797
3871
  `;
2798
3872
  }
3873
+ /**
3874
+ * Day popover for the month view: the day's events plus the two things a user
3875
+ * wants from a date they just clicked — create here, or open the day.
3876
+ *
3877
+ * A sibling of `.scheduler-container`, NOT a child of `.scheduler-content`:
3878
+ * the panel is `position: fixed`, so any ancestor with `transform`, `filter`
3879
+ * or `contain` would silently become its containing block and the coordinates
3880
+ * the OverlayController computes would be wrong. Keep it out here.
3881
+ *
3882
+ * `role="dialog"` with `modal: false` and no `aria-modal`: the month grid
3883
+ * behind it stays perfectly usable, and claiming modality would hide a page
3884
+ * that is still visible. It emits NO new event types — activating an entry
3885
+ * is `event-selected`, "New event" is `event-create`, "Show day" is the same
3886
+ * drill the "+N more" link used to do.
3887
+ */
3888
+ renderDayPopover() {
3889
+ const e = this.popoverDate;
3890
+ if (!e) return G;
3891
+ const { options: t } = this.stateManager.getState(), s = this.eventsOnDay(e), n = h.formatDateWithWeekday(e, t.locale);
3892
+ return A`
3893
+ <div
3894
+ class="scheduler-day-popover"
3895
+ role="dialog"
3896
+ aria-label=${this.msg("dayPopoverLabel", { date: n })}
3897
+ >
3898
+ <div class="popover-head">
3899
+ <div>
3900
+ <div class="popover-date">${n}</div>
3901
+ <div class="popover-count">
3902
+ ${this.msg("dayPopoverCount", {
3903
+ count: s.length,
3904
+ events: this.msg(s.length === 1 ? "eventSingular" : "eventPlural")
3905
+ })}
3906
+ </div>
3907
+ </div>
3908
+ <button
3909
+ type="button"
3910
+ class="popover-close"
3911
+ aria-label=${this.msg("closePopover")}
3912
+ @click=${() => this.closeDayPopover()}
3913
+ >
3914
+ <span aria-hidden="true">×</span>
3915
+ </button>
3916
+ </div>
3917
+ ${s.length === 0 ? A`<p class="popover-empty">${this.msg("dayPopoverEmpty")}</p>` : A`
3918
+ <ul class="popover-events">
3919
+ ${s.map(
3920
+ (i) => A`
3921
+ <li>
3922
+ <button
3923
+ type="button"
3924
+ class="popover-event"
3925
+ aria-label=${z(i, null, t)}
3926
+ @click=${(r) => this.selectFromPopover(i, r)}
3927
+ >
3928
+ <span
3929
+ class="popover-event-swatch"
3930
+ aria-hidden="true"
3931
+ style=${`background:${j(
3932
+ i,
3933
+ this.stateManager.getState().resourceById,
3934
+ t.defaultEventColor
3935
+ )}`}
3936
+ ></span>
3937
+ <span class="popover-event-title">${i.title}</span>
3938
+ </button>
3939
+ </li>
3940
+ `
3941
+ )}
3942
+ </ul>
3943
+ `}
3944
+ <div class="popover-actions">
3945
+ ${this.can("createEvent") ? A`<button
3946
+ type="button"
3947
+ class="popover-action primary"
3948
+ @click=${(i) => this.createFromPopover(i)}
3949
+ >
3950
+ ${this.msg("newEvent")}
3951
+ </button>` : G}
3952
+ <button
3953
+ type="button"
3954
+ class="popover-action"
3955
+ @click=${() => this.showDayFromPopover()}
3956
+ >
3957
+ ${this.msg("showDay")}
3958
+ </button>
3959
+ </div>
3960
+ </div>
3961
+ `;
3962
+ }
3963
+ /**
3964
+ * The day cell the popover hangs off, resolved by date key on every call.
3965
+ * The month view rebuilds its cells imperatively, so a cached element would
3966
+ * be detached the moment anything re-renders while the popover is open.
3967
+ */
3968
+ popoverAnchorCell() {
3969
+ return this.popoverAnchorKey ? this.shadowRoot?.querySelector(
3970
+ `#scheduler-cell-m-${this.popoverAnchorKey}`
3971
+ ) ?? null : null;
3972
+ }
3973
+ /** Every event overlapping the given local day, in start order. */
3974
+ eventsOnDay(e) {
3975
+ const t = new Date(e);
3976
+ t.setHours(0, 0, 0, 0);
3977
+ const s = new Date(t);
3978
+ return s.setDate(s.getDate() + 1), this.stateManager.getState().events.filter((n) => n.start < s && n.end > t).sort((n, i) => n.start.getTime() - i.start.getTime());
3979
+ }
3980
+ /**
3981
+ * Open the day popover for `day`. Anchored on the day cell resolved LAZILY by
3982
+ * date key: the views rebuild their DOM imperatively, so a captured element
3983
+ * reference would be detached by the next render while the popover is open.
3984
+ */
3985
+ async openDayPopover(e) {
3986
+ this.popoverDate = new Date(e), this.popoverAnchorKey = P.dayKey(this.popoverDate), this.requestUpdate(), await this.dayPopover.open(), this.contentContainer?.addEventListener("scroll", this.boundRepositionPopover, {
3987
+ passive: !0
3988
+ });
3989
+ }
3990
+ closeDayPopover() {
3991
+ this.contentContainer?.removeEventListener("scroll", this.boundRepositionPopover), this.dayPopover.close(), this.popoverDate = null, this.popoverAnchorKey = null, this.requestUpdate();
3992
+ }
3993
+ selectFromPopover(e, t) {
3994
+ this.closeDayPopover(), this.stateManager.setSelectedEvent(e), this.eventEmitter.emitEventSelected(e, t);
3995
+ }
3996
+ createFromPopover(e) {
3997
+ const t = this.popoverDate;
3998
+ if (!t) return;
3999
+ const s = new Date(t);
4000
+ s.setHours(0, 0, 0, 0);
4001
+ const n = new Date(s);
4002
+ if (n.setDate(n.getDate() + 1), this.closeDayPopover(), !this.can("createEvent") || !this.allowsCreateAt({ start: s, end: n })) {
4003
+ this.announceDenied();
4004
+ return;
4005
+ }
4006
+ this.eventEmitter.emitEventCreate(
4007
+ { start: s, end: n },
4008
+ this.stateManager.getState().view,
4009
+ e
4010
+ );
4011
+ }
4012
+ showDayFromPopover() {
4013
+ const e = this.popoverDate;
4014
+ e && (this.closeDayPopover(), this.stateManager.setDate(new Date(e)), this.stateManager.setView("day"));
4015
+ }
4016
+ /**
4017
+ * Route a "+N more" activation through `options.moreLinkBehavior`. Returns the
4018
+ * date to drill to when the caller should navigate, or null when the behaviour
4019
+ * has already been handled here.
4020
+ */
4021
+ handleMoreLink(e) {
4022
+ const t = this.parseDayKey(e), s = this.stateManager.getState().options.moreLinkBehavior ?? "popover";
4023
+ if (typeof s == "function") {
4024
+ s({ date: t, events: this.eventsOnDay(t) });
4025
+ return;
4026
+ }
4027
+ if (s === "popover") {
4028
+ this.openDayPopover(t);
4029
+ return;
4030
+ }
4031
+ this.stateManager.setDate(t), this.stateManager.setView("day");
4032
+ }
2799
4033
  firstUpdated() {
2800
4034
  const e = this.shadowRoot.querySelector(".scheduler-header");
2801
- this.contentContainer = this.shadowRoot.querySelector(".scheduler-content"), this.populateHeader(e), this.inputHandler = new re(
4035
+ this.contentContainer = this.shadowRoot.querySelector(".scheduler-content"), this.populateHeader(e), this.observeHeaderWidth(e), this.inputHandler = new Ce(
2802
4036
  {
2803
4037
  shadowRoot: this.shadowRoot,
2804
4038
  getEventById: (t) => this.getEventById(t),
2805
- isEditable: () => this.stateManager.getState().options.editable ?? !0,
2806
- isSelectable: () => this.stateManager.getState().options.selectable ?? !0
4039
+ // Pointer gestures ask the same resolver the keyboard paths and the
4040
+ // affordance rendering use, so all three can never disagree.
4041
+ isEditable: () => this.can("createEvent") || this.can("moveEvent") || this.can("resizeEventStart") || this.can("resizeEventEnd"),
4042
+ isSelectable: () => this.can("selectRange") || this.can("createEvent"),
4043
+ isEventSelected: (t) => this.stateManager.getState().selectedEvent?.id === t
2807
4044
  },
2808
4045
  {
2809
4046
  onPointerDown: (t, s, n) => this.handlePointerDown(t, s, n),
@@ -2813,58 +4050,52 @@ class le extends B {
2813
4050
  onDoubleClick: (t, s) => this.handleDoubleClick(t, s),
2814
4051
  getScrollContainer: () => this.contentContainer
2815
4052
  }
2816
- ), this.inputHandler.attach(), this.shadowRoot.addEventListener("focusin", this.boundHandleFocusIn), this.renderView();
4053
+ ), this.inputHandler.attach(), this.shadowRoot.addEventListener("focusin", this.boundHandleFocusIn), this.shadowRoot.addEventListener("change", this.boundHandleValueChange), this.renderView();
2817
4054
  }
2818
4055
  populateHeader(e) {
2819
4056
  const t = document.createElement("nav");
2820
- t.className = "scheduler-nav", t.setAttribute("aria-label", "Scheduler navigation");
4057
+ t.className = "scheduler-nav", t.setAttribute("aria-label", this.msg("navLabel"));
2821
4058
  const s = document.createElement("button");
2822
- s.type = "button", s.textContent = "‹", s.setAttribute("aria-label", "Previous period"), s.title = "Previous", s.addEventListener("click", () => this.prev());
4059
+ s.type = "button", s.textContent = "‹", s.setAttribute("aria-label", this.msg("previousPeriod")), s.title = this.msg("previousPeriod"), s.addEventListener("click", () => this.prev());
2823
4060
  const n = document.createElement("button");
2824
- n.type = "button", n.textContent = "›", n.setAttribute("aria-label", "Next period"), n.title = "Next", n.addEventListener("click", () => this.next());
4061
+ n.type = "button", n.textContent = "›", n.setAttribute("aria-label", this.msg("nextPeriod")), n.title = this.msg("nextPeriod"), n.addEventListener("click", () => this.next());
2825
4062
  const i = document.createElement("button");
2826
- i.type = "button", i.textContent = "Today", i.setAttribute("aria-label", "Jump to today"), i.addEventListener("click", () => this.today()), t.appendChild(s), t.appendChild(n), t.appendChild(i);
2827
- const o = document.createElement("div");
2828
- o.className = "scheduler-title", o.setAttribute("aria-live", "polite"), o.setAttribute("aria-atomic", "true"), this.updateTitle(o);
4063
+ i.type = "button", i.textContent = this.msg("today"), i.setAttribute("aria-label", this.msg("jumpToToday")), i.addEventListener("click", () => this.today()), t.appendChild(s), t.appendChild(n), t.appendChild(i);
2829
4064
  const r = document.createElement("div");
2830
- r.className = "scheduler-view-switcher", r.setAttribute("role", "group"), r.setAttribute("aria-label", "Switch view");
2831
- const a = [
2832
- { key: "year", label: "Year" },
2833
- { key: "month", label: "Month" },
2834
- { key: "week", label: "Week" },
2835
- { key: "day", label: "Day" },
2836
- { key: "timeline", label: "Timeline" }
2837
- ];
2838
- for (const { key: l, label: d } of a) {
2839
- const c = document.createElement("button");
2840
- c.type = "button", c.textContent = d, c.dataset.view = l;
2841
- const u = l === this.view;
2842
- c.setAttribute("aria-pressed", String(u)), u && c.classList.add("active"), c.addEventListener("click", () => this.changeView(l)), r.appendChild(c);
4065
+ r.className = "scheduler-title", r.setAttribute("aria-live", "polite"), r.setAttribute("aria-atomic", "true"), this.updateTitle(r);
4066
+ const o = document.createElement("div");
4067
+ o.className = "scheduler-view-switcher", o.setAttribute("role", "group"), o.setAttribute("aria-label", this.msg("switchView"));
4068
+ const a = ["year", "month", "week", "day", "timeline"];
4069
+ for (const l of a) {
4070
+ const d = document.createElement("button");
4071
+ d.type = "button", d.textContent = this.viewLabel(l), d.dataset.view = l;
4072
+ const c = l === this.view;
4073
+ d.setAttribute("aria-pressed", String(c)), c && d.classList.add("active"), d.addEventListener("click", () => this.changeView(l)), o.appendChild(d);
2843
4074
  }
2844
- e.appendChild(t), e.appendChild(o), e.appendChild(r);
4075
+ e.appendChild(t), e.appendChild(r), e.appendChild(o);
2845
4076
  }
2846
4077
  updateTitle(e) {
2847
4078
  const t = e ?? this.shadowRoot.querySelector(".scheduler-title");
2848
4079
  if (!t) return;
2849
- const s = this.stateManager.getState(), { date: n, view: i, options: o } = s;
2850
- let r = "";
4080
+ const s = this.stateManager.getState(), { date: n, view: i, options: r } = s;
4081
+ let o = "";
2851
4082
  switch (i) {
2852
4083
  case "year":
2853
- r = n.getFullYear().toString();
4084
+ o = n.getFullYear().toString();
2854
4085
  break;
2855
4086
  case "month":
2856
- r = h.formatDate(n, o.locale, {
4087
+ o = h.formatDate(n, r.locale, {
2857
4088
  month: "long",
2858
4089
  year: "numeric"
2859
4090
  });
2860
4091
  break;
2861
4092
  case "week":
2862
4093
  case "timeline": {
2863
- const a = h.getWeekStart(n, o.firstDayOfWeek), l = h.addDays(a, 6);
2864
- r = `${h.formatDate(a, o.locale, {
4094
+ const a = h.getWeekStart(n, r.firstDayOfWeek), l = h.addDays(a, 6);
4095
+ o = `${h.formatDate(a, r.locale, {
2865
4096
  month: "short",
2866
4097
  day: "numeric"
2867
- })} - ${h.formatDate(l, o.locale, {
4098
+ })} - ${h.formatDate(l, r.locale, {
2868
4099
  month: "short",
2869
4100
  day: "numeric",
2870
4101
  year: "numeric"
@@ -2872,7 +4103,7 @@ class le extends B {
2872
4103
  break;
2873
4104
  }
2874
4105
  case "day":
2875
- r = h.formatDate(n, o.locale, {
4106
+ o = h.formatDate(n, r.locale, {
2876
4107
  weekday: "long",
2877
4108
  month: "long",
2878
4109
  day: "numeric",
@@ -2880,7 +4111,23 @@ class le extends B {
2880
4111
  });
2881
4112
  break;
2882
4113
  }
2883
- t.textContent = r;
4114
+ t.textContent = o;
4115
+ }
4116
+ static {
4117
+ this.NARROW_HEADER_WIDTH = 560;
4118
+ }
4119
+ /**
4120
+ * Component-width (not viewport) driven narrow mode — the scheduler can sit
4121
+ * in a pane far narrower than the screen (splitter/dock). CSS keys the
4122
+ * wrapped layout off [data-narrow]; the title text swap needs JS anyway.
4123
+ */
4124
+ observeHeaderWidth(e) {
4125
+ typeof ResizeObserver > "u" || (this.headerResizeObserver = new ResizeObserver((t) => {
4126
+ const n = (t[0]?.contentRect.width ?? e.clientWidth) < I.NARROW_HEADER_WIDTH;
4127
+ n !== this.headerIsNarrow && (this.headerIsNarrow = n, requestAnimationFrame(() => {
4128
+ e.toggleAttribute("data-narrow", n);
4129
+ }));
4130
+ }), this.headerResizeObserver.observe(e));
2884
4131
  }
2885
4132
  renderView() {
2886
4133
  if (!this.contentContainer) return;
@@ -2888,19 +4135,19 @@ class le extends B {
2888
4135
  const e = this.stateManager.getState();
2889
4136
  switch (e.view) {
2890
4137
  case "year":
2891
- this.currentView = new A(this.contentContainer, e), this.currentViewType = "year";
4138
+ this.currentView = new N(this.contentContainer, e), this.currentViewType = "year";
2892
4139
  break;
2893
4140
  case "month":
2894
- this.currentView = new T(this.contentContainer, e), this.currentViewType = "month";
4141
+ this.currentView = new P(this.contentContainer, e), this.currentViewType = "month";
2895
4142
  break;
2896
4143
  case "week":
2897
- this.currentView = new J(this.contentContainer, e), this.currentViewType = "week";
4144
+ this.currentView = new ge(this.contentContainer, e), this.currentViewType = "week";
2898
4145
  break;
2899
4146
  case "day":
2900
- this.currentView = new Z(this.contentContainer, e), this.currentViewType = "day";
4147
+ this.currentView = new fe(this.contentContainer, e), this.currentViewType = "day";
2901
4148
  break;
2902
4149
  case "timeline":
2903
- this.currentView = new Q(this.contentContainer, e), this.currentViewType = "timeline";
4150
+ this.currentView = new ye(this.contentContainer, e), this.currentViewType = "timeline";
2904
4151
  break;
2905
4152
  }
2906
4153
  this.currentView?.render();
@@ -2909,16 +4156,16 @@ class le extends B {
2909
4156
  // State Change Handling
2910
4157
  // ============================================
2911
4158
  onStateChange(e) {
2912
- e.isLoading !== this.previousIsLoading && (this.previousIsLoading !== null && this.liveAnnouncer.announce(e.isLoading ? "Loading events." : "Events loaded."), this.previousIsLoading = e.isLoading), this.detectAndEmitChanges(e), this.updateUI(e);
4159
+ e.isLoading !== this.previousIsLoading && (this.previousIsLoading !== null && this.liveAnnouncer.announce(this.msg(e.isLoading ? "loadingEvents" : "eventsLoaded")), this.previousIsLoading = e.isLoading), this.detectAndEmitChanges(e), this.updateUI(e);
2913
4160
  }
2914
4161
  detectAndEmitChanges(e) {
2915
- const t = this.previousView !== null && this.previousView !== e.view, s = this.previousDate !== null && this.previousDate.getTime() !== e.date.getTime(), n = e.selectedEvent?.id ?? null, i = k(e), o = i ? `${i.start.getTime()}-${i.end.getTime()}-${e.selectionResourceId ?? ""}` : null, r = this.previousSelectedEventId !== n || this.previousRangeKey !== o;
2916
- (t || s) && this.eventEmitter.emitViewChange(e.view, e.date), r && this.eventEmitter.emitSelectionChange(
4162
+ const t = this.previousView !== null && this.previousView !== e.view, s = this.previousDate !== null && this.previousDate.getTime() !== e.date.getTime(), n = e.selectedEvent?.id ?? null, i = K(e), r = i ? `${i.start.getTime()}-${i.end.getTime()}-${e.selectionResourceId ?? ""}` : null, o = this.previousSelectedEventId !== n || this.previousRangeKey !== r;
4163
+ (t || s) && this.eventEmitter.emitViewChange(e.view, e.date), o && this.eventEmitter.emitSelectionChange(
2917
4164
  e.selectedEvent,
2918
4165
  i,
2919
4166
  e.view,
2920
4167
  e.selectionResourceId ?? void 0
2921
- ), this.previousView = e.view, this.previousDate = new Date(e.date), this.previousSelectedEventId = n, this.previousRangeKey = o;
4168
+ ), this.previousView = e.view, this.previousDate = new Date(e.date), this.previousSelectedEventId = n, this.previousRangeKey = r;
2922
4169
  }
2923
4170
  updateUI(e) {
2924
4171
  this.updateTitle(), this.shadowRoot.querySelectorAll(".scheduler-view-switcher button").forEach((s) => {
@@ -2940,15 +4187,72 @@ class le extends B {
2940
4187
  this.dragManager.handlePointerDown(e, t, s);
2941
4188
  }
2942
4189
  handlePointerMove(e) {
2943
- this.dragManager.handlePointerMove(e);
4190
+ this.dragManager.handlePointerMove(e), this.updateEdgeScroll(e);
2944
4191
  }
2945
4192
  handlePointerUp(e) {
4193
+ this.stopEdgeScroll();
2946
4194
  const t = this.dragManager.handlePointerUp(e);
2947
4195
  t && this.handleDragComplete(t, e.originalEvent);
2948
4196
  }
4197
+ static {
4198
+ this.EDGE_SCROLL_ZONE_PX = 40;
4199
+ }
4200
+ static {
4201
+ this.EDGE_SCROLL_MAX_PX = 18;
4202
+ }
4203
+ /**
4204
+ * Scroll the grid when a drag reaches the edge of the viewport.
4205
+ *
4206
+ * Without this, a drag can only ever reach what is already on screen — and
4207
+ * since the timeline is now genuinely wider than the viewport (7 days x 48
4208
+ * slots), "drag an event to next Thursday" became impossible rather than
4209
+ * merely awkward. Both axes, because the timeline scrolls horizontally and the
4210
+ * time grids vertically.
4211
+ *
4212
+ * Speed ramps with how deep into the edge zone the pointer is, the way every
4213
+ * drag-and-drop implementation does it: a constant rate is either too slow to
4214
+ * be useful or too fast to aim. Each frame re-feeds the pointer to the drag
4215
+ * machine so the preview keeps tracking the slot under the cursor while the
4216
+ * grid moves beneath it.
4217
+ */
4218
+ updateEdgeScroll(e) {
4219
+ const t = this.contentContainer;
4220
+ if (!t || !this.dragManager.isDragging()) {
4221
+ this.stopEdgeScroll();
4222
+ return;
4223
+ }
4224
+ const s = t.getBoundingClientRect(), n = I.EDGE_SCROLL_ZONE_PX, i = I.EDGE_SCROLL_MAX_PX, r = (o, a, l) => o < a + n ? -Math.min(1, (a + n - o) / n) * i : o > l - n ? Math.min(1, (o - (l - n)) / n) * i : 0;
4225
+ if (this.edgeScrollVector = {
4226
+ x: r(e.clientX, s.left, s.right),
4227
+ y: r(e.clientY, s.top, s.bottom)
4228
+ }, this.edgeScrollPointer = e, this.edgeScrollVector.x === 0 && this.edgeScrollVector.y === 0) {
4229
+ this.stopEdgeScroll();
4230
+ return;
4231
+ }
4232
+ this.edgeScrollFrame === null && this.scheduleEdgeScroll();
4233
+ }
4234
+ scheduleEdgeScroll() {
4235
+ this.edgeScrollFrame = requestAnimationFrame(() => {
4236
+ this.edgeScrollFrame = null;
4237
+ const e = this.contentContainer, t = this.edgeScrollPointer;
4238
+ if (!e || !t || !this.dragManager.isDragging()) return;
4239
+ const s = e.scrollLeft, n = e.scrollTop;
4240
+ e.scrollLeft = s + this.edgeScrollVector.x, e.scrollTop = n + this.edgeScrollVector.y, !(e.scrollLeft === s && e.scrollTop === n) && (this.dragManager.handlePointerMove(t), this.scheduleEdgeScroll());
4241
+ });
4242
+ }
4243
+ stopEdgeScroll() {
4244
+ this.edgeScrollFrame !== null && (cancelAnimationFrame(this.edgeScrollFrame), this.edgeScrollFrame = null), this.edgeScrollVector = { x: 0, y: 0 }, this.edgeScrollPointer = null;
4245
+ }
4246
+ static {
4247
+ this.DBLCLICK_WINDOW_MS = 500;
4248
+ }
4249
+ registerEventActivation(e, t) {
4250
+ const s = Date.now(), n = this.lastEventActivation;
4251
+ this.lastEventActivation = { eventId: e.id, time: s }, n && n.eventId === e.id && s - n.time < I.DBLCLICK_WINDOW_MS && (this.lastEventActivation = null, this.eventEmitter.emitEventDblClick(e, t));
4252
+ }
2949
4253
  handleDragComplete(e, t) {
2950
4254
  if (e.wasClick) {
2951
- e.event && (this.stateManager.setSelectedEvent(e.event), this.eventEmitter.emitEventSelected(e.event, t));
4255
+ e.event && (this.stateManager.setSelectedEvent(e.event), this.eventEmitter.emitEventSelected(e.event, t), this.registerEventActivation(e.event, t));
2952
4256
  return;
2953
4257
  }
2954
4258
  switch (e.type) {
@@ -2982,7 +4286,9 @@ class le extends B {
2982
4286
  }
2983
4287
  }
2984
4288
  handleClick(e, t) {
2985
- const s = e.target, n = s.closest(".expand-toggle");
4289
+ const s = e.target;
4290
+ if (this.handleResourceAction(s, e.originalEvent)) return;
4291
+ const n = s.closest(".expand-toggle");
2986
4292
  if (n) {
2987
4293
  const a = n.dataset.groupId;
2988
4294
  if (a) {
@@ -2990,24 +4296,88 @@ class le extends B {
2990
4296
  return;
2991
4297
  }
2992
4298
  }
2993
- const i = s.closest("[data-date]");
4299
+ const i = s.closest(".scheduler-more-link");
2994
4300
  if (i) {
2995
4301
  const a = i.dataset.date;
2996
- a && this.eventEmitter.emitDateClick(new Date(a), e.originalEvent);
4302
+ if (a) {
4303
+ this.handleMoreLink(a);
4304
+ return;
4305
+ }
4306
+ }
4307
+ const r = s.closest("[data-date]");
4308
+ if (r) {
4309
+ const a = r.dataset.date;
4310
+ if (a) {
4311
+ const l = this.parseDayKey(a);
4312
+ if (this.eventEmitter.emitDateClick(l, e.originalEvent), s.closest(".day-number")) {
4313
+ this.stateManager.setDate(l), this.stateManager.setView("day");
4314
+ return;
4315
+ }
4316
+ if (this.stateManager.getState().options.dayClickAction === "popover") {
4317
+ this.openDayPopover(l);
4318
+ return;
4319
+ }
4320
+ }
2997
4321
  }
2998
4322
  const o = s.closest(
2999
4323
  ".scheduler-year-month-header"
3000
4324
  );
3001
4325
  if (o) {
3002
4326
  const a = o.dataset.month;
3003
- a && (this.stateManager.setDate(new Date(a)), this.stateManager.setView("month"));
4327
+ a && (this.stateManager.setDate(this.parseDayKey(a)), this.stateManager.setView("month"));
3004
4328
  }
3005
- const r = s.closest(".scheduler-more-link");
3006
- if (r) {
3007
- const a = r.dataset.date;
3008
- a && (this.stateManager.setDate(new Date(a)), this.stateManager.setView("day"));
4329
+ t.type === "event" && t.event && (this.stateManager.setSelectedEvent(t.event), this.registerEventActivation(t.event, e.originalEvent));
4330
+ }
4331
+ /**
4332
+ * Route a click on a resource-tree action button to its request event.
4333
+ * Returns true when the click was one of ours and must not fall through.
4334
+ *
4335
+ * Every branch re-checks the capability rather than trusting that the button
4336
+ * exists: state can change between render and click, and a request the
4337
+ * consumer has switched off must not reach them.
4338
+ */
4339
+ handleResourceAction(e, t) {
4340
+ const s = e.closest("[data-action]");
4341
+ if (!s) return !1;
4342
+ const { action: n, parentId: i, resourceId: r } = s.dataset, o = this.stateManager.getState().view;
4343
+ switch (n) {
4344
+ case "add-resource":
4345
+ return this.can("createResource") && this.eventEmitter.emitResourceCreate("resource", o, t, i), !0;
4346
+ case "add-group":
4347
+ return this.can("createGroup") && this.eventEmitter.emitResourceCreate("group", o, t, i), !0;
4348
+ case "delete-resource": {
4349
+ const a = r ? this.findResourceOrGroup(r) : null;
4350
+ return a && this.can("deleteResource") && this.eventEmitter.emitResourceDelete(a, t), !0;
4351
+ }
4352
+ // The colour input reports through `change`, not `click` — a click merely
4353
+ // opens the platform picker, so swallow it here and let handleValueChange
4354
+ // emit once the user has actually chosen.
4355
+ case "set-resource-color":
4356
+ return !0;
3009
4357
  }
3010
- t.type === "event" && t.event && this.stateManager.setSelectedEvent(t.event);
4358
+ return !1;
4359
+ }
4360
+ /**
4361
+ * `change` from a resource control. Delegated on the shadow root because the
4362
+ * views build their DOM imperatively and are rebuilt on every render — a
4363
+ * per-element listener would have to be re-attached each time. `change` does
4364
+ * not compose, so this listener is the only one that can see it.
4365
+ */
4366
+ handleValueChange(e) {
4367
+ const t = e.composedPath?.()[0] ?? e.target;
4368
+ if (!t || t.dataset.action !== "set-resource-color" || !this.can("updateResource")) return;
4369
+ const { resourceId: s, field: n } = t.dataset, i = s ? this.findResourceOrGroup(s) : null;
4370
+ if (!i) return;
4371
+ const r = t.value;
4372
+ this.eventEmitter.emitResourceUpdate(
4373
+ i,
4374
+ n === "eventColor" ? { eventColor: r } : { color: r },
4375
+ e
4376
+ );
4377
+ }
4378
+ /** Resolve a resource or group by id from the current `resources` input. */
4379
+ findResourceOrGroup(e) {
4380
+ return T.findById(this.stateManager.getState().resources, e) ?? null;
3011
4381
  }
3012
4382
  handleDoubleClick(e, t) {
3013
4383
  t.type === "event" && t.event && this.eventEmitter.emitEventDblClick(t.event, e.originalEvent);
@@ -3029,11 +4399,15 @@ class le extends B {
3029
4399
  return;
3030
4400
  const i = this.getEventById(n);
3031
4401
  i && this.stateManager.getState().selectedEvent?.id !== i.id && (this.stateManager.setSelectedEvent(i), this.eventEmitter.emitEventSelected(i, e), requestAnimationFrame(() => {
3032
- const o = `[data-event-id="${this.cssEscape(i.id)}"]`;
3033
- this.shadowRoot?.querySelector(o)?.focus({ preventScroll: !0 });
4402
+ const r = `[data-event-id="${this.cssEscape(i.id)}"]`;
4403
+ this.shadowRoot?.querySelector(r)?.focus({ preventScroll: !0 });
3034
4404
  }));
3035
4405
  }
3036
4406
  handleKeyDown(e) {
4407
+ if (this.dayPopover.isOpen) {
4408
+ e.key === "Escape" && (e.preventDefault(), e.stopPropagation(), this.closeDayPopover());
4409
+ return;
4410
+ }
3037
4411
  if (this.keyboardMove) {
3038
4412
  this.handleKeyboardMove(e);
3039
4413
  return;
@@ -3057,11 +4431,11 @@ class le extends B {
3057
4431
  if (!e) return !1;
3058
4432
  if (e.classList.contains("scheduler-more-link")) {
3059
4433
  const t = e.dataset.date;
3060
- return t ? (this.stateManager.setDate(new Date(t)), this.stateManager.setView("day"), !0) : !1;
4434
+ return t ? (this.handleMoreLink(t), !0) : !1;
3061
4435
  }
3062
4436
  if (e.classList.contains("scheduler-year-month-header")) {
3063
4437
  const t = e.dataset.month;
3064
- return t ? (this.stateManager.setDate(new Date(t)), this.stateManager.setView("month"), !0) : !1;
4438
+ return t ? (this.stateManager.setDate(this.parseDayKey(t)), this.stateManager.setView("month"), !0) : !1;
3065
4439
  }
3066
4440
  return !1;
3067
4441
  }
@@ -3084,16 +4458,87 @@ class le extends B {
3084
4458
  }
3085
4459
  return !1;
3086
4460
  }
4461
+ /**
4462
+ * Resolve a capability against `readonly`, `options.permissions` and any
4463
+ * per-event override.
4464
+ *
4465
+ * A boolean lookup, deliberately: it runs on every pointer-down and on every
4466
+ * render that decides whether to draw an affordance.
4467
+ */
4468
+ can(e, t) {
4469
+ const { options: s } = this.stateManager.getState();
4470
+ return O(e, {
4471
+ permissions: this.effectivePermissions(s),
4472
+ event: t ?? null
4473
+ });
4474
+ }
4475
+ /** Recompute the resolved table onto state so views can gate affordances. */
4476
+ syncPermissions() {
4477
+ const { options: e } = this.stateManager.getState();
4478
+ this.stateManager.setState({
4479
+ resolvedPermissions: this.effectivePermissions(e)
4480
+ });
4481
+ }
4482
+ /**
4483
+ * The effective permission table: the `readonly` host attribute outranks
4484
+ * everything, then `options.permissions`. Per-capability defaults are applied
4485
+ * inside `resolveCapability`, so an unspecified capability keeps its documented
4486
+ * default rather than being treated as denied.
4487
+ */
4488
+ effectivePermissions(e) {
4489
+ if (this.readonly) return !1;
4490
+ const t = e.permissions;
4491
+ return t === !1 ? !1 : typeof t == "object" && t !== null ? t : {};
4492
+ }
4493
+ /**
4494
+ * The one optional consumer predicate, for data-dependent create rules.
4495
+ *
4496
+ * Evaluated ONLY at commit points (this call site, drag completion, Enter) —
4497
+ * never per cell and never per pointer-move, so a consumer callback can't land
4498
+ * on the render path. Slot greying is deliberately not driven by it.
4499
+ */
4500
+ allowsCreateAt(e, t) {
4501
+ const { permissions: s } = this.stateManager.getState().options;
4502
+ return typeof s != "object" || s === null ? !0 : s.canCreateAt?.(e, t) ?? !0;
4503
+ }
4504
+ /** Enter move mode only if the event may actually be moved or resized. */
4505
+ tryEnterEventMoveMode(e) {
4506
+ const t = this.can("moveEvent", e), s = this.can("resizeEventStart", e) || this.can("resizeEventEnd", e);
4507
+ if (!t && !s) {
4508
+ this.announceDenied();
4509
+ return;
4510
+ }
4511
+ this.enterEventMoveMode(e);
4512
+ }
4513
+ /**
4514
+ * Announce a refused command. Silence on a keypress reads as a broken widget,
4515
+ * so denial gets its own polite message rather than nothing.
4516
+ */
4517
+ announceDenied() {
4518
+ this.liveAnnouncer.announce(this.msg("actionNotAllowed"));
4519
+ }
3087
4520
  handleEventKeyDown(e) {
3088
4521
  const s = this.stateManager.getState().selectedEvent;
3089
4522
  if (s)
3090
4523
  switch (e.key) {
4524
+ // M is the canonical move-mode key across the workspace (tile-manager,
4525
+ // dock); Enter is kept for back-compat (screen-reader programme D4).
4526
+ case "m":
4527
+ case "M": {
4528
+ if (e.altKey || e.ctrlKey || e.metaKey) break;
4529
+ e.preventDefault(), this.tryEnterEventMoveMode(s);
4530
+ return;
4531
+ }
3091
4532
  case "Enter":
3092
- e.preventDefault(), this.enterEventMoveMode(s);
4533
+ e.preventDefault(), this.tryEnterEventMoveMode(s);
3093
4534
  return;
3094
4535
  case "Delete":
3095
4536
  case "Backspace":
3096
- e.preventDefault(), this.eventEmitter.emitEventDelete(s);
4537
+ if (e.preventDefault(), !this.can("deleteEvent", s)) {
4538
+ this.announceDenied();
4539
+ return;
4540
+ }
4541
+ this.eventEmitter.emitEventDelete(s);
3097
4542
  return;
3098
4543
  case "Escape":
3099
4544
  e.preventDefault(), this.focusFocusedCell();
@@ -3117,12 +4562,12 @@ class le extends B {
3117
4562
  return c !== 0 ? c : l.id.localeCompare(d.id);
3118
4563
  }), i = n.findIndex((l) => l.id === e.id);
3119
4564
  if (i < 0) return;
3120
- const o = n[i + t];
3121
- if (!o) return;
3122
- const r = this.shadowRoot;
4565
+ const r = n[i + t];
3123
4566
  if (!r) return;
3124
- r.querySelector(
3125
- `[data-event-id="${this.cssEscape(o.id)}"]`
4567
+ const o = this.shadowRoot;
4568
+ if (!o) return;
4569
+ o.querySelector(
4570
+ `[data-event-id="${this.cssEscape(r.id)}"]`
3126
4571
  )?.focus({ preventScroll: !1 });
3127
4572
  }
3128
4573
  handleCellKeyDown(e) {
@@ -3206,6 +4651,14 @@ class le extends B {
3206
4651
  case "Enter":
3207
4652
  e.preventDefault(), this.commitFocusedDateAsCreate(e, "day");
3208
4653
  return;
4654
+ // Space, not Enter: Enter already means "create for this day" and taking
4655
+ // it would remove the only keyboard create path in this view.
4656
+ case " ": {
4657
+ e.preventDefault();
4658
+ const t = this.stateManager.getState().focusedDate;
4659
+ t && this.openDayPopover(t);
4660
+ return;
4661
+ }
3209
4662
  }
3210
4663
  }
3211
4664
  /**
@@ -3228,9 +4681,15 @@ class le extends B {
3228
4681
  case "ArrowDown":
3229
4682
  e.preventDefault(), this.moveFocusedDateByMonths(3);
3230
4683
  return;
3231
- case "Enter":
3232
- e.preventDefault(), this.commitFocusedDateAsCreate(e, "month");
4684
+ // Drill into the month, matching what clicking the month header does.
4685
+ // Enter used to emit a MONTH-SPANNING event-create here, which no consumer
4686
+ // could reasonably want from a year overview.
4687
+ case "Enter": {
4688
+ e.preventDefault();
4689
+ const t = this.stateManager.getState().focusedDate;
4690
+ t && (this.stateManager.setDate(new Date(t)), this.stateManager.setView("month"));
3233
4691
  return;
4692
+ }
3234
4693
  }
3235
4694
  }
3236
4695
  /**
@@ -3242,7 +4701,7 @@ class le extends B {
3242
4701
  const e = this.shadowRoot?.activeElement;
3243
4702
  if (!e) return;
3244
4703
  const t = e.dataset.date ?? e.dataset.month;
3245
- t && this.stateManager.setFocusedDate(new Date(t));
4704
+ t && this.stateManager.setFocusedDate(this.parseDayKey(t));
3246
4705
  }
3247
4706
  moveFocusedDateByDays(e) {
3248
4707
  const t = this.stateManager.getState(), s = t.focusedDate ?? t.date, n = new Date(s);
@@ -3273,8 +4732,8 @@ class le extends B {
3273
4732
  scrollAndFocusDateCell(e) {
3274
4733
  const t = this.stateManager.getState(), s = this.shadowRoot;
3275
4734
  if (!s) return;
3276
- const n = `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}`, i = t.view === "year" ? `scheduler-cell-y-${n}` : `scheduler-cell-m-${n}-${String(e.getDate()).padStart(2, "0")}`, o = s.getElementById(i);
3277
- o && (o.focus({ preventScroll: !0 }), typeof o.scrollIntoView == "function" && o.scrollIntoView({ block: "nearest", inline: "nearest" }));
4735
+ const n = `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}`, i = t.view === "year" ? `scheduler-cell-y-${n}` : `scheduler-cell-m-${n}-${String(e.getDate()).padStart(2, "0")}`, r = s.getElementById(i);
4736
+ r && (r.focus({ preventScroll: !0 }), typeof r.scrollIntoView == "function" && r.scrollIntoView({ block: "nearest", inline: "nearest" }));
3278
4737
  }
3279
4738
  /**
3280
4739
  * Emit `event-create` covering the focused day (month view) or focused
@@ -3286,9 +4745,13 @@ class le extends B {
3286
4745
  if (!n) return;
3287
4746
  const i = new Date(n);
3288
4747
  i.setHours(0, 0, 0, 0);
3289
- const o = new Date(i);
3290
- t === "day" ? o.setDate(o.getDate() + 1) : o.setMonth(o.getMonth() + 1), this.eventEmitter.emitEventCreate(
3291
- { start: i, end: o },
4748
+ const r = new Date(i);
4749
+ if (t === "day" ? r.setDate(r.getDate() + 1) : r.setMonth(r.getMonth() + 1), !this.can("createEvent") || !this.allowsCreateAt({ start: i, end: r })) {
4750
+ this.announceDenied();
4751
+ return;
4752
+ }
4753
+ this.eventEmitter.emitEventCreate(
4754
+ { start: i, end: r },
3292
4755
  s.view,
3293
4756
  e
3294
4757
  );
@@ -3296,17 +4759,17 @@ class le extends B {
3296
4759
  moveCellByTime(e, t) {
3297
4760
  const s = this.stateManager.getState(), n = s.focusedCell;
3298
4761
  if (!n) return;
3299
- const i = (s.options.slotDuration ?? 1800) * 1e3, o = new Date(n.start.getTime() + e * i), r = new Date(o.getTime() + i);
3300
- this.cellIsWithinView(o, s) && this.commitFocusMove({ start: o, end: r }, s.focusedResourceId, t);
4762
+ const i = (s.options.slotDuration ?? 1800) * 1e3, r = new Date(n.start.getTime() + e * i), o = new Date(r.getTime() + i);
4763
+ this.cellIsWithinView(r, s) && this.commitFocusMove({ start: r, end: o }, s.focusedResourceId, t);
3301
4764
  }
3302
4765
  /** Week view ArrowLeft/Right: ±1 day, same time-of-day. No-op on day view. */
3303
4766
  moveCellByDay(e, t) {
3304
4767
  const s = this.stateManager.getState(), n = s.focusedCell;
3305
4768
  if (!n || s.view !== "week") return;
3306
- const i = (s.options.slotDuration ?? 1800) * 1e3, o = new Date(n.start);
3307
- o.setDate(o.getDate() + e);
3308
- const r = new Date(o.getTime() + i);
3309
- this.cellIsWithinView(o, s) && this.commitFocusMove({ start: o, end: r }, null, t);
4769
+ const i = (s.options.slotDuration ?? 1800) * 1e3, r = new Date(n.start);
4770
+ r.setDate(r.getDate() + e);
4771
+ const o = new Date(r.getTime() + i);
4772
+ this.cellIsWithinView(r, s) && this.commitFocusMove({ start: r, end: o }, null, t);
3310
4773
  }
3311
4774
  /** Timeline ArrowUp/Down: ±1 resource, same time-of-day. PRD D1: cross-resource
3312
4775
  * Shift+Arrow is intentionally ignored (resource is categorical). */
@@ -3321,32 +4784,32 @@ class le extends B {
3321
4784
  if (!n) return;
3322
4785
  const i = new Date(n.start);
3323
4786
  i.setHours(0, 0, 0, 0);
3324
- const o = h.getTimeSlots(
4787
+ const r = h.getTimeSlots(
3325
4788
  i,
3326
4789
  s.options.slotDuration,
3327
4790
  s.options.slotMinTime,
3328
4791
  s.options.slotMaxTime
3329
- ), r = e === "start" ? o[0] : o[o.length - 1];
3330
- r && this.commitFocusMove(r, s.focusedResourceId, t);
4792
+ ), o = e === "start" ? r[0] : r[r.length - 1];
4793
+ o && this.commitFocusMove(o, s.focusedResourceId, t);
3331
4794
  }
3332
4795
  moveCellToViewExtreme(e, t) {
3333
4796
  const s = this.stateManager.getState();
3334
4797
  let n = null, i = s.focusedResourceId;
3335
4798
  switch (s.view) {
3336
4799
  case "day": {
3337
- const o = h.getTimeSlots(s.date, s.options.slotDuration, s.options.slotMinTime, s.options.slotMaxTime);
3338
- n = e === "start" ? o[0] : o[o.length - 1];
4800
+ const r = h.getTimeSlots(s.date, s.options.slotDuration, s.options.slotMinTime, s.options.slotMaxTime);
4801
+ n = e === "start" ? r[0] : r[r.length - 1];
3339
4802
  break;
3340
4803
  }
3341
4804
  case "week": {
3342
- const o = h.getWeekDays(s.date, s.options.firstDayOfWeek), r = e === "start" ? o[0] : o[6], a = h.getTimeSlots(r, s.options.slotDuration, s.options.slotMinTime, s.options.slotMaxTime);
4805
+ const r = h.getWeekDays(s.date, s.options.firstDayOfWeek), o = e === "start" ? r[0] : r[6], a = h.getTimeSlots(o, s.options.slotDuration, s.options.slotMinTime, s.options.slotMaxTime);
3343
4806
  n = e === "start" ? a[0] : a[a.length - 1];
3344
4807
  break;
3345
4808
  }
3346
4809
  case "timeline": {
3347
- const r = S.flatten(s.resources, s.collapsedGroups).filter((c) => c.visible && H(c.item));
3348
- if (r.length === 0) return;
3349
- i = e === "start" ? r[0].item.id : r[r.length - 1].item.id;
4810
+ const o = T.flatten(s.resources, s.collapsedGroups).filter((c) => c.visible && W(c.item));
4811
+ if (o.length === 0) return;
4812
+ i = e === "start" ? o[0].item.id : o[o.length - 1].item.id;
3350
4813
  const a = h.getWeekDays(s.date, s.options.firstDayOfWeek), l = e === "start" ? a[0] : a[6], d = h.getTimeSlots(l, s.options.slotDuration, s.options.slotMinTime, s.options.slotMaxTime);
3351
4814
  n = e === "start" ? d[0] : d[d.length - 1];
3352
4815
  break;
@@ -3363,14 +4826,14 @@ class le extends B {
3363
4826
  const t = this.stateManager.getState(), s = t.focusedCell, n = t.date;
3364
4827
  if (e > 0 ? this.next() : this.prev(), !s) return;
3365
4828
  const i = this.stateManager.getState();
3366
- let o;
4829
+ let r;
3367
4830
  if (i.view === "day")
3368
- o = new Date(i.date), o.setHours(s.start.getHours(), s.start.getMinutes(), s.start.getSeconds(), 0);
4831
+ r = new Date(i.date), r.setHours(s.start.getHours(), s.start.getMinutes(), s.start.getSeconds(), 0);
3369
4832
  else {
3370
- const l = h.getWeekDays(n, t.options.firstDayOfWeek), d = h.getWeekDays(i.date, i.options.firstDayOfWeek), c = l.findIndex((p) => h.isSameDay(p, s.start)), u = d[Math.max(0, c)] ?? d[0];
3371
- o = new Date(u), o.setHours(s.start.getHours(), s.start.getMinutes(), s.start.getSeconds(), 0);
4833
+ const l = h.getWeekDays(n, t.options.firstDayOfWeek), d = h.getWeekDays(i.date, i.options.firstDayOfWeek), c = l.findIndex((m) => h.isSameDay(m, s.start)), p = d[Math.max(0, c)] ?? d[0];
4834
+ r = new Date(p), r.setHours(s.start.getHours(), s.start.getMinutes(), s.start.getSeconds(), 0);
3372
4835
  }
3373
- const r = (i.options.slotDuration ?? 1800) * 1e3, a = { start: o, end: new Date(o.getTime() + r) };
4836
+ const o = (i.options.slotDuration ?? 1800) * 1e3, a = { start: r, end: new Date(r.getTime() + o) };
3374
4837
  this.commitFocusMove(a, t.focusedResourceId, !1);
3375
4838
  }
3376
4839
  /**
@@ -3382,12 +4845,12 @@ class le extends B {
3382
4845
  const n = this.stateManager.getState(), i = n.options.slotDuration ?? 1800;
3383
4846
  if (s) {
3384
4847
  this.stateManager.extendSelection(e, t), this.stateManager.setFocusedCell(e, t, !1);
3385
- const o = this.stateManager.getState();
3386
- this.liveAnnouncer.announce(_(o, i, n.options.timeFormat));
4848
+ const r = this.stateManager.getState();
4849
+ this.liveAnnouncer.announce(he(r, i));
3387
4850
  } else {
3388
4851
  this.stateManager.setFocusedCell(e, t, !0);
3389
- const o = this.getResourceTitle(t);
3390
- this.liveAnnouncer.announce(G(e, n.options.timeFormat, o));
4852
+ const r = this.getResourceTitle(t);
4853
+ this.liveAnnouncer.announce(ce(e, n.options, r));
3391
4854
  }
3392
4855
  this.scrollAndFocusCell(e, t);
3393
4856
  }
@@ -3407,21 +4870,21 @@ class le extends B {
3407
4870
  }
3408
4871
  }
3409
4872
  parseTimeOnDay(e, t) {
3410
- const [s, n, i] = (t ?? "00:00:00").split(":").map(Number), o = new Date(e);
3411
- return o.setHours(0, 0, 0, 0), o.setSeconds((s ?? 0) * 3600 + (n ?? 0) * 60 + (i ?? 0)), o;
4873
+ const [s, n, i] = (t ?? "00:00:00").split(":").map(Number), r = new Date(e);
4874
+ return r.setHours(0, 0, 0, 0), r.setSeconds((s ?? 0) * 3600 + (n ?? 0) * 60 + (i ?? 0)), r;
3412
4875
  }
3413
4876
  adjacentResource(e, t, s) {
3414
- const i = S.flatten(s.resources, s.collapsedGroups).filter((a) => a.visible && H(a.item));
4877
+ const i = T.flatten(s.resources, s.collapsedGroups).filter((a) => a.visible && W(a.item));
3415
4878
  if (i.length === 0) return null;
3416
4879
  if (!e) return i[0].item.id;
3417
- const o = i.findIndex((a) => a.item.id === e);
3418
- if (o < 0) return i[0].item.id;
3419
- const r = o + t;
3420
- return r < 0 || r >= i.length ? null : i[r].item.id;
4880
+ const r = i.findIndex((a) => a.item.id === e);
4881
+ if (r < 0) return i[0].item.id;
4882
+ const o = r + t;
4883
+ return o < 0 || o >= i.length ? null : i[o].item.id;
3421
4884
  }
3422
4885
  getResourceTitle(e) {
3423
4886
  if (!e) return null;
3424
- for (const t of S.getAllResources(this.stateManager.getState().resources))
4887
+ for (const t of T.getAllResources(this.stateManager.getState().resources))
3425
4888
  if (t.id === e) return t.title;
3426
4889
  return null;
3427
4890
  }
@@ -3433,14 +4896,28 @@ class le extends B {
3433
4896
  scrollAndFocusCell(e, t) {
3434
4897
  const s = e.start.toISOString(), n = this.shadowRoot;
3435
4898
  if (!n) return;
3436
- const i = t ? `.scheduler-timeline-slot[data-resource-id="${this.cssEscape(t)}"][data-start="${s}"]` : `.scheduler-time-slot[data-start="${s}"]`, o = n.querySelector(i);
3437
- o && (o.focus({ preventScroll: !0 }), typeof o.scrollIntoView == "function" && o.scrollIntoView({ block: "nearest", inline: "nearest" }));
4899
+ const i = t ? `.scheduler-timeline-slot[data-resource-id="${this.cssEscape(t)}"][data-start="${s}"]` : `.scheduler-time-slot[data-start="${s}"]`, r = n.querySelector(i);
4900
+ r && (r.focus({ preventScroll: !0 }), typeof r.scrollIntoView == "function" && r.scrollIntoView({ block: "nearest", inline: "nearest" }));
3438
4901
  }
3439
4902
  /** Re-focus whatever cell the keyboard model currently considers focused. */
3440
4903
  focusFocusedCell() {
3441
4904
  const e = this.stateManager.getState();
3442
4905
  e.focusedCell && this.scrollAndFocusCell(e.focusedCell, e.focusedResourceId);
3443
4906
  }
4907
+ /**
4908
+ * Parse a `YYYY-MM-DD` day key as a LOCAL date.
4909
+ *
4910
+ * `new Date('2026-07-31')` is parsed per spec as UTC midnight, so in every
4911
+ * timezone west of UTC it lands on the previous local day — month view writes
4912
+ * these keys from local components, so Enter on Jul 31 in New York emitted
4913
+ * `event-create` for Jul 30 and focus restoration missed the cell entirely.
4914
+ * Full ISO strings (year view's `data-month`) round-trip fine and still work
4915
+ * through this function.
4916
+ */
4917
+ parseDayKey(e) {
4918
+ const t = /^(\d{4})-(\d{2})-(\d{2})$/.exec(e);
4919
+ return t ? new Date(Number(t[1]), Number(t[2]) - 1, Number(t[3])) : new Date(e);
4920
+ }
3444
4921
  cssEscape(e) {
3445
4922
  return typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e.replace(/[^a-zA-Z0-9_-]/g, (t) => `\\${t}`);
3446
4923
  }
@@ -3452,22 +4929,27 @@ class le extends B {
3452
4929
  * whether/when to clear the selection.
3453
4930
  */
3454
4931
  createEventFromCellOrSelection(e) {
3455
- const t = this.stateManager.getState(), s = k(t);
3456
- let n, i, o;
4932
+ const t = this.stateManager.getState(), s = K(t);
4933
+ let n, i, r;
3457
4934
  if (s)
3458
- n = s.start, i = s.end, o = t.selectionResourceId ?? void 0;
4935
+ n = s.start, i = s.end, r = t.selectionResourceId ?? void 0;
3459
4936
  else if (t.focusedCell)
3460
- n = t.focusedCell.start, i = t.focusedCell.end, o = t.focusedResourceId ?? void 0;
4937
+ n = t.focusedCell.start, i = t.focusedCell.end, r = t.focusedResourceId ?? void 0;
3461
4938
  else
3462
4939
  return;
4940
+ if (!this.can("createEvent") || !this.allowsCreateAt({ start: n, end: i }, r)) {
4941
+ this.announceDenied();
4942
+ return;
4943
+ }
3463
4944
  this.eventEmitter.emitEventCreate(
3464
4945
  { start: n, end: i },
3465
4946
  t.view,
3466
4947
  e,
3467
- o
3468
- ), this.liveAnnouncer.announce(
3469
- `Selection committed: ${h.formatTime(n, t.options.timeFormat)}–${h.formatTime(i, t.options.timeFormat)}.`
3470
- );
4948
+ r
4949
+ ), this.liveAnnouncer.announce(this.msg("selectionCommitted", {
4950
+ start: h.formatTime(n, t.options.timeFormat),
4951
+ end: h.formatTime(i, t.options.timeFormat)
4952
+ }));
3471
4953
  }
3472
4954
  /**
3473
4955
  * Enter keyboard event-move mode. Captures the working copy and a snapshot
@@ -3495,7 +4977,7 @@ class le extends B {
3495
4977
  });
3496
4978
  const s = this.minutesPerSlot();
3497
4979
  this.liveAnnouncer.announce(
3498
- `Move mode for ${e.title}. Arrow keys nudge by ${s} minutes; Shift with arrow keys resizes the end edge; Alt with Shift resizes the start edge; Enter commits, Escape cancels.`
4980
+ this.msg("moveModeEntered", { title: e.title, minutes: s })
3499
4981
  ), requestAnimationFrame(() => {
3500
4982
  const n = `[data-event-id="${this.cssEscape(e.id)}"]`;
3501
4983
  this.shadowRoot?.querySelector(n)?.focus({ preventScroll: !0 });
@@ -3520,19 +5002,19 @@ class le extends B {
3520
5002
  e.preventDefault(), this.commitEventMoveMode();
3521
5003
  return;
3522
5004
  }
3523
- const t = this.stateManager.getState().view, s = t === "timeline", n = this.minutesPerSlot() * 60 * 1e3, i = e.shiftKey, o = e.altKey;
5005
+ const t = this.stateManager.getState().view, s = t === "timeline", n = this.minutesPerSlot() * 60 * 1e3, i = e.shiftKey, r = e.altKey;
3524
5006
  switch (e.key) {
3525
5007
  case "ArrowUp":
3526
- e.preventDefault(), s ? !i && !o && this.nudgeKeyboardMoveResource(-1) : i && o ? this.resizeKeyboardMoveEdge("start", -n) : i ? this.resizeKeyboardMoveEdge("end", -n) : this.nudgeKeyboardMove(-n);
5008
+ e.preventDefault(), s ? !i && !r && this.nudgeKeyboardMoveResource(-1) : i && r ? this.resizeKeyboardMoveEdge("start", -n) : i ? this.resizeKeyboardMoveEdge("end", -n) : this.nudgeKeyboardMove(-n);
3527
5009
  return;
3528
5010
  case "ArrowDown":
3529
- e.preventDefault(), s ? !i && !o && this.nudgeKeyboardMoveResource(1) : i && o ? this.resizeKeyboardMoveEdge("start", +n) : i ? this.resizeKeyboardMoveEdge("end", +n) : this.nudgeKeyboardMove(+n);
5011
+ e.preventDefault(), s ? !i && !r && this.nudgeKeyboardMoveResource(1) : i && r ? this.resizeKeyboardMoveEdge("start", +n) : i ? this.resizeKeyboardMoveEdge("end", +n) : this.nudgeKeyboardMove(+n);
3530
5012
  return;
3531
5013
  case "ArrowLeft":
3532
- e.preventDefault(), s ? i && o ? this.resizeKeyboardMoveEdge("start", -n) : i ? this.resizeKeyboardMoveEdge("end", -n) : this.nudgeKeyboardMove(-n) : t === "week" && (i && o ? this.resizeKeyboardMoveEdge("start", -864e5) : i ? this.resizeKeyboardMoveEdge("end", -864e5) : this.nudgeKeyboardMove(-864e5));
5014
+ e.preventDefault(), s ? i && r ? this.resizeKeyboardMoveEdge("start", -n) : i ? this.resizeKeyboardMoveEdge("end", -n) : this.nudgeKeyboardMove(-n) : t === "week" && (i && r ? this.resizeKeyboardMoveEdge("start", -864e5) : i ? this.resizeKeyboardMoveEdge("end", -864e5) : this.nudgeKeyboardMove(-864e5));
3533
5015
  return;
3534
5016
  case "ArrowRight":
3535
- e.preventDefault(), s ? i && o ? this.resizeKeyboardMoveEdge("start", +n) : i ? this.resizeKeyboardMoveEdge("end", +n) : this.nudgeKeyboardMove(+n) : t === "week" && (i && o ? this.resizeKeyboardMoveEdge("start", 864e5) : i ? this.resizeKeyboardMoveEdge("end", 864e5) : this.nudgeKeyboardMove(864e5));
5017
+ e.preventDefault(), s ? i && r ? this.resizeKeyboardMoveEdge("start", +n) : i ? this.resizeKeyboardMoveEdge("end", +n) : this.nudgeKeyboardMove(+n) : t === "week" && (i && r ? this.resizeKeyboardMoveEdge("start", 864e5) : i ? this.resizeKeyboardMoveEdge("end", 864e5) : this.nudgeKeyboardMove(864e5));
3536
5018
  return;
3537
5019
  }
3538
5020
  }
@@ -3544,7 +5026,7 @@ class le extends B {
3544
5026
  nudgeKeyboardMove(e) {
3545
5027
  if (!this.keyboardMove) return;
3546
5028
  const t = new Date(this.keyboardMove.workingStart.getTime() + e), s = new Date(this.keyboardMove.workingEnd.getTime() + e);
3547
- this.keyboardMove.workingStart = t, this.keyboardMove.workingEnd = s, this.applyKeyboardMovePreview(), this.liveAnnouncer.announce(X(t, s, this.stateManager.getState().options.timeFormat));
5029
+ this.keyboardMove.workingStart = t, this.keyboardMove.workingEnd = s, this.applyKeyboardMovePreview(), this.liveAnnouncer.announce(ue(t, s, this.stateManager.getState().options));
3548
5030
  }
3549
5031
  /** Walk to the next/previous resource (timeline only). Updates the preview's resourceId. */
3550
5032
  nudgeKeyboardMoveResource(e) {
@@ -3553,7 +5035,7 @@ class le extends B {
3553
5035
  if (!t) return;
3554
5036
  this.keyboardMove.workingResourceId = t, this.applyKeyboardMovePreview();
3555
5037
  const s = this.getResourceTitle(t) ?? t;
3556
- this.liveAnnouncer.announce(`Moved to resource ${s}.`);
5038
+ this.liveAnnouncer.announce(this.msg("movedToResource", { resource: s }));
3557
5039
  }
3558
5040
  /**
3559
5041
  * Resize one edge of the working event. Clamps to a minimum duration of
@@ -3561,12 +5043,17 @@ class le extends B {
3561
5043
  */
3562
5044
  resizeKeyboardMoveEdge(e, t) {
3563
5045
  if (!this.keyboardMove) return;
3564
- const s = this.minutesPerSlot() * 60 * 1e3;
3565
- let n = this.keyboardMove.workingStart, i = this.keyboardMove.workingEnd;
5046
+ const s = this.getEventById(this.keyboardMove.eventId);
5047
+ if (!this.can(e === "start" ? "resizeEventStart" : "resizeEventEnd", s)) {
5048
+ this.announceDenied();
5049
+ return;
5050
+ }
5051
+ const n = this.minutesPerSlot() * 60 * 1e3;
5052
+ let i = this.keyboardMove.workingStart, r = this.keyboardMove.workingEnd;
3566
5053
  if (e === "end") {
3567
- if (i = new Date(i.getTime() + t), i.getTime() - n.getTime() < s) return;
3568
- } else if (n = new Date(n.getTime() + t), i.getTime() - n.getTime() < s) return;
3569
- this.keyboardMove.workingStart = n, this.keyboardMove.workingEnd = i, this.applyKeyboardMovePreview(), this.liveAnnouncer.announce(j(n, i, e, this.stateManager.getState().options.timeFormat));
5054
+ if (r = new Date(r.getTime() + t), r.getTime() - i.getTime() < n) return;
5055
+ } else if (i = new Date(i.getTime() + t), r.getTime() - i.getTime() < n) return;
5056
+ this.keyboardMove.workingStart = i, this.keyboardMove.workingEnd = r, this.applyKeyboardMovePreview(), this.liveAnnouncer.announce(pe(i, r, e, this.stateManager.getState().options));
3570
5057
  }
3571
5058
  /** Mirror keyboardMove.working* into state.previewEvent so views render the destination,
3572
5059
  * then scroll the destination into view so the sighted-keyboard user can see it (PRD D6). */
@@ -3583,7 +5070,7 @@ class le extends B {
3583
5070
  const i = this.shadowRoot;
3584
5071
  if (!i) return;
3585
5072
  i.querySelector(`[data-event-id="${this.cssEscape(e)}"]`)?.focus({ preventScroll: !0 });
3586
- const r = t.toISOString(), a = n ? `.scheduler-timeline-slot[data-resource-id="${this.cssEscape(n)}"][data-start="${r}"]` : `.scheduler-time-slot[data-start="${r}"]`, l = i.querySelector(a);
5073
+ const o = t.toISOString(), a = n ? `.scheduler-timeline-slot[data-resource-id="${this.cssEscape(n)}"][data-start="${o}"]` : `.scheduler-time-slot[data-start="${o}"]`, l = i.querySelector(a);
3587
5074
  l && typeof l.scrollIntoView == "function" && l.scrollIntoView({ block: "nearest", inline: "nearest" });
3588
5075
  });
3589
5076
  }
@@ -3597,7 +5084,7 @@ class le extends B {
3597
5084
  end: this.keyboardMove.workingEnd,
3598
5085
  ...this.keyboardMove.workingResourceId ? { resourceId: this.keyboardMove.workingResourceId } : {}
3599
5086
  };
3600
- this.stateManager.updateEvent(t), this.eventEmitter.emitEventUpdate(t, e, new CustomEvent("keyboard-move")), this.liveAnnouncer.announce("Move committed.");
5087
+ this.stateManager.updateEvent(t), this.eventEmitter.emitEventUpdate(t, e, new CustomEvent("keyboard-move")), this.liveAnnouncer.announce(this.msg("moveCommitted"));
3601
5088
  }
3602
5089
  this.keyboardMove = null, this.stateManager.setState({ keyboardMoveEventId: null, previewEvent: null }), requestAnimationFrame(() => {
3603
5090
  const t = `[data-event-id="${this.cssEscape(e?.id ?? "")}"]`;
@@ -3606,7 +5093,7 @@ class le extends B {
3606
5093
  }
3607
5094
  cancelEventMoveMode() {
3608
5095
  const e = this.keyboardMove?.eventId ?? null;
3609
- this.keyboardMove = null, this.stateManager.setState({ keyboardMoveEventId: null, previewEvent: null }), this.liveAnnouncer.announce("Move cancelled."), e && requestAnimationFrame(() => {
5096
+ this.keyboardMove = null, this.stateManager.setState({ keyboardMoveEventId: null, previewEvent: null }), this.liveAnnouncer.announce(this.msg("moveCancelled")), e && requestAnimationFrame(() => {
3610
5097
  const t = `[data-event-id="${this.cssEscape(e)}"]`;
3611
5098
  this.shadowRoot?.querySelector(t)?.focus({ preventScroll: !1 });
3612
5099
  });
@@ -3633,22 +5120,25 @@ class le extends B {
3633
5120
  }
3634
5121
  getSlotFromElement(e) {
3635
5122
  const t = e.dataset.start, s = e.dataset.end;
3636
- return !t || !s ? null : {
5123
+ if (!t || !s) return null;
5124
+ const n = e.dataset.resourceId;
5125
+ return {
3637
5126
  start: new Date(t),
3638
- end: new Date(s)
5127
+ end: new Date(s),
5128
+ ...n ? { resourceId: n } : {}
3639
5129
  };
3640
5130
  }
3641
5131
  }
3642
- typeof customElements < "u" && !customElements.get("mp-scheduler") && customElements.define("mp-scheduler", le);
5132
+ typeof customElements < "u" && !customElements.get("mp-scheduler") && customElements.define("mp-scheduler", I);
3643
5133
  export {
3644
- x as BaseView,
3645
- Z as DayView,
3646
- T as MonthView,
3647
- le as MpScheduler,
3648
- Y as SchedulerStateManager,
3649
- Q as TimelineView,
3650
- J as WeekView,
3651
- A as YearView,
3652
- q as createInitialState,
3653
- ee as schedulerStyles
5134
+ $ as BaseView,
5135
+ fe as DayView,
5136
+ P as MonthView,
5137
+ I as MpScheduler,
5138
+ de as SchedulerStateManager,
5139
+ ye as TimelineView,
5140
+ ge as WeekView,
5141
+ N as YearView,
5142
+ le as createInitialState,
5143
+ be as schedulerStyles
3654
5144
  };