@ziix/calendar 0.1.1 → 0.1.3

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,44 +1,65 @@
1
1
  import C from "dayjs";
2
- import O from "dayjs/plugin/utc";
3
- import k from "dayjs/plugin/timezone";
4
- C.extend(O);
5
- C.extend(k);
6
- function b(p, t) {
7
- const e = C(p);
2
+ import _ from "dayjs/plugin/utc";
3
+ import X from "dayjs/plugin/timezone";
4
+ C.extend(_);
5
+ C.extend(X);
6
+ function b(u, t) {
7
+ const e = C(u);
8
8
  return t ? e.tz(t) : e;
9
9
  }
10
- function $(p) {
11
- return p ? C().tz(p) : C();
10
+ function Y(u) {
11
+ return u ? C().tz(u) : C();
12
12
  }
13
- function R(p) {
14
- const t = p.split(":"), e = Number(t[0]) || 0, i = Number(t[1]) || 0;
15
- return e * 60 + i;
13
+ function L(u) {
14
+ const t = u.split(":"), e = Number(t[0]) || 0, s = Number(t[1]) || 0;
15
+ return e * 60 + s;
16
16
  }
17
- function A(p) {
18
- const t = Math.floor(p / 60), e = p % 60;
17
+ function I(u) {
18
+ const t = Math.floor(u / 60), e = u % 60;
19
19
  return `${String(t).padStart(2, "0")}:${String(e).padStart(2, "0")}`;
20
20
  }
21
- function f(p) {
22
- return p.hour() * 60 + p.minute();
21
+ function g(u) {
22
+ return u.hour() * 60 + u.minute();
23
23
  }
24
- function L(p, t, e, i) {
25
- return new Intl.DateTimeFormat(e, { ...t, timeZone: i }).format(p.toDate());
24
+ function A(u, t, e, s) {
25
+ return new Intl.DateTimeFormat(e, { ...t, timeZone: s }).format(u.toDate());
26
26
  }
27
- function N(p = {}) {
28
- const t = R(p.min ?? "00:00"), e = R(p.max ?? "24:00"), i = p.duration ?? 15, n = p.labelInterval ?? 60, s = Math.max(0, e - t), o = i > 0 ? Math.ceil(s / i) : 0;
29
- return { min: t, max: e, duration: i, labelInterval: n, slots: o, totalMinutes: s };
27
+ function P(u, t) {
28
+ const e = [];
29
+ for (const s of t) {
30
+ if (!(s.daysOfWeek ?? [0, 1, 2, 3, 4, 5, 6]).includes(u)) continue;
31
+ const n = L(s.startTime ?? "00:00"), o = L(s.endTime ?? "24:00");
32
+ o > n && e.push([n, o]);
33
+ }
34
+ return e;
30
35
  }
31
- class _ {
36
+ function R(u, t, e) {
37
+ const s = u.map((r) => [Math.max(r[0], t), Math.min(r[1], e)]).filter((r) => r[1] > r[0]).sort((r, c) => r[0] - c[0]), i = [];
38
+ for (const r of s) {
39
+ const c = i[i.length - 1];
40
+ c && r[0] <= c[1] ? c[1] = Math.max(c[1], r[1]) : i.push([r[0], r[1]]);
41
+ }
42
+ const n = [];
43
+ let o = t;
44
+ for (const r of i)
45
+ r[0] > o && n.push([o, r[0]]), o = r[1];
46
+ return o < e && n.push([o, e]), n;
47
+ }
48
+ function F(u = {}) {
49
+ const t = L(u.min ?? "00:00"), e = L(u.max ?? "24:00"), s = u.duration ?? 15, i = u.labelInterval ?? 60, n = Math.max(0, e - t), o = s > 0 ? Math.ceil(n / s) : 0;
50
+ return { min: t, max: e, duration: s, labelInterval: i, slots: o, totalMinutes: n };
51
+ }
52
+ class V {
32
53
  constructor(t) {
33
54
  this.tz = t, this.map = /* @__PURE__ */ new Map();
34
55
  }
35
56
  normalize(t) {
36
- const e = b(t.start, this.tz), i = t.end ? b(t.end, this.tz) : e.add(30, "minute");
57
+ const e = b(t.start, this.tz), s = t.end ? b(t.end, this.tz) : e.add(30, "minute");
37
58
  return {
38
59
  id: String(t.id),
39
60
  title: t.title ?? "",
40
61
  start: e,
41
- end: i,
62
+ end: s,
42
63
  resourceId: t.resourceId != null ? String(t.resourceId) : null,
43
64
  allDay: !!t.allDay,
44
65
  color: t.color,
@@ -51,8 +72,8 @@ class _ {
51
72
  set(t) {
52
73
  this.map.clear();
53
74
  for (const e of t) {
54
- const i = this.normalize(e);
55
- this.map.set(i.id, i);
75
+ const s = this.normalize(e);
76
+ this.map.set(s.id, s);
56
77
  }
57
78
  }
58
79
  add(t) {
@@ -72,22 +93,25 @@ class _ {
72
93
  * Events overlapping [start, end). When `resourceId` is supplied (including
73
94
  * `null` for unassigned), only events on that resource are returned.
74
95
  */
75
- inRange(t, e, i) {
76
- return this.all().filter((n) => i !== void 0 && n.resourceId !== i ? !1 : n.start.isBefore(e) && n.end.isAfter(t));
96
+ inRange(t, e, s) {
97
+ return this.all().filter((i) => s !== void 0 && i.resourceId !== s ? !1 : i.start.isBefore(e) && i.end.isAfter(t));
77
98
  }
78
99
  }
79
- class X {
100
+ class W {
80
101
  constructor(t = "group", e = "order") {
81
102
  this.groupField = t, this.orderField = e, this.list = [];
82
103
  }
83
104
  normalize(t) {
84
- const e = t[this.groupField], i = t[this.orderField];
105
+ const e = t[this.groupField], s = t[this.orderField], i = /* @__PURE__ */ new Set(["id", "title", "group", "order", "businessHours", "extendedProps", this.groupField, this.orderField]), n = {};
106
+ for (const o of Object.keys(t))
107
+ i.has(o) || (n[o] = t[o]);
85
108
  return {
86
109
  id: String(t.id),
87
110
  title: t.title ?? "",
88
111
  group: e != null ? String(e) : null,
89
- order: typeof i == "number" ? i : 0,
90
- extendedProps: t.extendedProps ?? {},
112
+ order: typeof s == "number" ? s : 0,
113
+ businessHours: Array.isArray(t.businessHours) ? t.businessHours : [],
114
+ extendedProps: { ...n, ...t.extendedProps ?? {} },
91
115
  raw: t
92
116
  };
93
117
  }
@@ -115,22 +139,22 @@ class X {
115
139
  */
116
140
  grouped() {
117
141
  const t = [], e = /* @__PURE__ */ new Map();
118
- for (const i of this.ordered()) {
119
- let n = e.get(i.group);
120
- n === void 0 && (n = t.length, e.set(i.group, n), t.push({ group: i.group, resources: [] })), t[n].resources.push(i);
142
+ for (const s of this.ordered()) {
143
+ let i = e.get(s.group);
144
+ i === void 0 && (i = t.length, e.set(s.group, i), t.push({ group: s.group, resources: [] })), t[i].resources.push(s);
121
145
  }
122
146
  return t;
123
147
  }
124
148
  }
125
- function I(p) {
126
- const t = [...p].sort(
149
+ function $(u) {
150
+ const t = [...u].sort(
127
151
  (o, r) => o.start.valueOf() - r.start.valueOf() || r.end.valueOf() - o.end.valueOf()
128
152
  ), e = [];
129
- let i = [], n = -1 / 0;
130
- const s = () => {
131
- if (i.length === 0) return;
153
+ let s = [], i = -1 / 0;
154
+ const n = () => {
155
+ if (s.length === 0) return;
132
156
  const o = [];
133
- for (const c of i) {
157
+ for (const c of s) {
134
158
  let a = !1;
135
159
  for (const l of o)
136
160
  if (l[l.length - 1].end.valueOf() <= c.start.valueOf()) {
@@ -143,44 +167,44 @@ function I(p) {
143
167
  o.forEach((c, a) => {
144
168
  for (const l of c)
145
169
  e.push({ event: l, col: a, cols: r, left: a / r, width: 1 / r });
146
- }), i = [], n = -1 / 0;
170
+ }), s = [], i = -1 / 0;
147
171
  };
148
172
  for (const o of t)
149
- i.length > 0 && o.start.valueOf() >= n && s(), i.push(o), n = Math.max(n, o.end.valueOf());
150
- return s(), e;
173
+ s.length > 0 && o.start.valueOf() >= i && n(), s.push(o), i = Math.max(i, o.end.valueOf());
174
+ return n(), e;
151
175
  }
152
- function w(p, t) {
153
- const e = t.threshold ?? 4, i = p.clientX, n = p.clientY;
154
- let s = !1;
176
+ function w(u, t) {
177
+ const e = t.threshold ?? 4, s = u.clientX, i = u.clientY;
178
+ let n = !1;
155
179
  const o = (c) => {
156
- var u, g;
157
- const a = c, l = a.clientX - i, d = a.clientY - n;
158
- !s && Math.hypot(l, d) < e || (s || (s = !0, (u = t.onStart) == null || u.call(t, a)), (g = t.onMove) == null || g.call(t, { dx: l, dy: d, moved: !0, event: a }));
180
+ var p, m;
181
+ const a = c, l = a.clientX - s, d = a.clientY - i;
182
+ !n && Math.hypot(l, d) < e || (n || (n = !0, (p = t.onStart) == null || p.call(t, a)), (m = t.onMove) == null || m.call(t, { dx: l, dy: d, moved: !0, event: a }));
159
183
  }, r = (c) => {
160
184
  var l;
161
185
  window.removeEventListener("pointermove", o), window.removeEventListener("pointerup", r), window.removeEventListener("pointercancel", r);
162
186
  const a = c;
163
187
  (l = t.onEnd) == null || l.call(t, {
164
- dx: a.clientX - i,
165
- dy: a.clientY - n,
166
- moved: s,
188
+ dx: a.clientX - s,
189
+ dy: a.clientY - i,
190
+ moved: n,
167
191
  event: a
168
192
  });
169
193
  };
170
194
  window.addEventListener("pointermove", o), window.addEventListener("pointerup", r), window.addEventListener("pointercancel", r);
171
195
  }
172
- function x(p, t) {
173
- return t <= 0 ? p : Math.round(p / t) * t;
196
+ function x(u, t) {
197
+ return t <= 0 ? u : Math.round(u / t) * t;
174
198
  }
175
- function h(p, t) {
176
- const e = document.createElement(p);
199
+ function h(u, t) {
200
+ const e = document.createElement(u);
177
201
  return e.className = t, e;
178
202
  }
179
- function m(p, t, e) {
180
- return Math.max(t, Math.min(e, p));
203
+ function f(u, t, e) {
204
+ return Math.max(t, Math.min(e, u));
181
205
  }
182
206
  const E = 24;
183
- class F {
207
+ class q {
184
208
  constructor(t, e) {
185
209
  this.cal = t, this.root = e, this.nowLine = null;
186
210
  }
@@ -198,7 +222,7 @@ class F {
198
222
  return { start: t.startOf("day"), end: t.endOf("day") };
199
223
  }
200
224
  title() {
201
- return L(
225
+ return A(
202
226
  this.cal.date,
203
227
  { weekday: "long", day: "numeric", month: "long", year: "numeric" },
204
228
  this.localeTag(),
@@ -212,13 +236,19 @@ class F {
212
236
  e.style.height = `${this.contentHeight}px`;
213
237
  for (let i = t.min; i <= t.max; i += t.labelInterval) {
214
238
  const n = h("div", "zc-axis-label");
215
- n.style.top = `${(i - t.min) * this.pxPerMinute}px`, n.textContent = A(i), e.appendChild(n);
239
+ n.style.top = `${(i - t.min) * this.pxPerMinute}px`, n.textContent = I(i), e.appendChild(n);
216
240
  }
217
241
  this.content = h("div", "zc-col"), this.content.style.height = `${this.contentHeight}px`;
218
242
  for (let i = 0; i <= t.slots; i++) {
219
243
  const n = h("div", "zc-slot-line");
220
244
  i * t.duration % t.labelInterval === 0 && n.classList.add("zc-slot-major"), n.style.top = `${i * E}px`, this.content.appendChild(n);
221
245
  }
246
+ const s = this.cal.businessHours;
247
+ if (s.length)
248
+ for (const [i, n] of R(P(this.cal.date.day(), s), t.min, t.max)) {
249
+ const o = h("div", "zc-nonbusiness-fill");
250
+ o.style.top = `${(i - t.min) * this.pxPerMinute}px`, o.style.height = `${(n - i) * this.pxPerMinute}px`, this.content.appendChild(o);
251
+ }
222
252
  this.grid.appendChild(e), this.grid.appendChild(this.content), this.root.appendChild(this.grid), this.bindSelect(), this.renderEvents();
223
253
  }
224
254
  /** Events to lay out in this column. Subclasses scope this by resource. */
@@ -228,11 +258,11 @@ class F {
228
258
  }
229
259
  renderEvents() {
230
260
  if (!this.content) return;
231
- this.content.querySelectorAll(".zc-event").forEach((i) => i.remove());
232
- const t = this.cal.axis, e = I(this.eventsFor());
233
- for (const i of e) {
234
- const n = i.event, s = f(n.start), o = f(n.end) || t.max, r = m(s, t.min, t.max), c = m(o, t.min, t.max), a = (r - t.min) * this.pxPerMinute, l = Math.max(E - 2, (c - r) * this.pxPerMinute), d = h("div", "zc-event");
235
- d.dataset.eventId = n.id, d.style.top = `${a}px`, d.style.height = `${l}px`, d.style.left = `calc(${i.left * 100}% + 2px)`, d.style.width = `calc(${i.width * 100}% - 4px)`, n.color && d.style.setProperty("--zc-event-bg", n.color), n.textColor && d.style.setProperty("--zc-event-fg", n.textColor), d.appendChild(this.cal.renderEventContent(n)), this.bindBar(d, n), this.content.appendChild(d), this.cal.fireEventMount(n, d);
261
+ this.content.querySelectorAll(".zc-event").forEach((s) => s.remove());
262
+ const t = this.cal.axis, e = $(this.eventsFor());
263
+ for (const s of e) {
264
+ const i = s.event, n = g(i.start), o = g(i.end) || t.max, r = f(n, t.min, t.max), c = f(o, t.min, t.max), a = (r - t.min) * this.pxPerMinute, l = Math.max(E - 2, (c - r) * this.pxPerMinute), d = h("div", "zc-event");
265
+ d.dataset.eventId = i.id, d.style.top = `${a}px`, d.style.height = `${l}px`, d.style.left = `calc(${s.left * 100}% + 2px)`, d.style.width = `calc(${s.width * 100}% - 4px)`, i.color && d.style.setProperty("--zc-event-bg", i.color), i.textColor && d.style.setProperty("--zc-event-fg", i.textColor), d.appendChild(this.cal.renderEventContent(i)), this.bindBar(d, i), this.content.appendChild(d), this.cal.fireEventMount(i, d);
236
266
  }
237
267
  this.renderNowIndicator();
238
268
  }
@@ -247,46 +277,46 @@ class F {
247
277
  /** Wire click, drag-move and resize on an event bar (or just click if read-only). */
248
278
  bindBar(t, e) {
249
279
  if (this.cal.bindContextMenu(t, e), !this.cal.editable) {
250
- t.addEventListener("click", (n) => this.cal.fireEventClick(e, t, n));
280
+ t.addEventListener("click", (i) => this.cal.fireEventClick(e, t, i));
251
281
  return;
252
282
  }
253
283
  t.style.cursor = "move";
254
- const i = h("div", "zc-resize-handle zc-resize-s");
255
- t.appendChild(i), i.addEventListener("pointerdown", (n) => this.beginResize(n, t, e)), t.addEventListener("pointerdown", (n) => {
256
- if (n.button !== 0 || n.target.closest(".zc-resize-handle")) return;
257
- n.preventDefault();
258
- const s = this.cal.axis, o = e.end.diff(e.start, "minute"), r = f(e.start), c = this.minuteAtY(n.clientY), a = (l) => m(
259
- x(r + (this.minuteAtY(l) - c), s.duration),
260
- s.min,
261
- s.max - o
284
+ const s = h("div", "zc-resize-handle zc-resize-s");
285
+ t.appendChild(s), s.addEventListener("pointerdown", (i) => this.beginResize(i, t, e)), t.addEventListener("pointerdown", (i) => {
286
+ if (i.button !== 0 || i.target.closest(".zc-resize-handle")) return;
287
+ i.preventDefault();
288
+ const n = this.cal.axis, o = e.end.diff(e.start, "minute"), r = g(e.start), c = this.minuteAtY(i.clientY), a = (l) => f(
289
+ x(r + (this.minuteAtY(l) - c), n.duration),
290
+ n.min,
291
+ n.max - o
262
292
  );
263
- w(n, {
293
+ w(i, {
264
294
  onStart: () => t.classList.add("zc-dragging"),
265
295
  onMove: ({ event: l }) => {
266
- t.style.top = `${(a(l.clientY) - s.min) * this.pxPerMinute}px`;
296
+ t.style.top = `${(a(l.clientY) - n.min) * this.pxPerMinute}px`;
267
297
  },
268
298
  onEnd: ({ moved: l, event: d }) => {
269
299
  if (t.classList.remove("zc-dragging"), !l) {
270
300
  this.cal.fireEventClick(e, t, d);
271
301
  return;
272
302
  }
273
- const u = this.timeAt(a(d.clientY));
274
- this.cal.commitEventChange(e, u, u.add(o, "minute"), e.resourceId);
303
+ const p = this.timeAt(a(d.clientY));
304
+ this.cal.commitEventChange(e, p, p.add(o, "minute"), e.resourceId);
275
305
  }
276
306
  });
277
307
  });
278
308
  }
279
- beginResize(t, e, i) {
309
+ beginResize(t, e, s) {
280
310
  if (t.button !== 0) return;
281
311
  t.stopPropagation(), t.preventDefault();
282
- const n = this.cal.axis, s = f(i.start), o = (r) => m(x(this.minuteAtY(r), n.duration), s + n.duration, n.max);
312
+ const i = this.cal.axis, n = g(s.start), o = (r) => f(x(this.minuteAtY(r), i.duration), n + i.duration, i.max);
283
313
  w(t, {
284
314
  onStart: () => e.classList.add("zc-dragging"),
285
315
  onMove: ({ event: r }) => {
286
- e.style.height = `${(o(r.clientY) - s) * this.pxPerMinute}px`;
316
+ e.style.height = `${(o(r.clientY) - n) * this.pxPerMinute}px`;
287
317
  },
288
318
  onEnd: ({ moved: r, event: c }) => {
289
- e.classList.remove("zc-dragging"), r && this.cal.commitEventChange(i, i.start, this.timeAt(o(c.clientY)), i.resourceId);
319
+ e.classList.remove("zc-dragging"), r && this.cal.commitEventChange(s, s.start, this.timeAt(o(c.clientY)), s.resourceId);
290
320
  }
291
321
  });
292
322
  }
@@ -294,37 +324,37 @@ class F {
294
324
  !this.cal.selectable || !this.content || this.content.addEventListener("pointerdown", (t) => {
295
325
  if (t.button !== 0 || t.target.closest(".zc-event")) return;
296
326
  t.preventDefault();
297
- const e = this.cal.axis, i = m(x(this.minuteAtY(t.clientY), e.duration), e.min, e.max), n = h("div", "zc-select-box");
298
- this.content.appendChild(n);
299
- const s = (o) => {
300
- const r = m(x(this.minuteAtY(o), e.duration), e.min, e.max), c = Math.min(i, r), a = Math.max(i, r);
301
- n.style.top = `${(c - e.min) * this.pxPerMinute}px`, n.style.height = `${(a - c) * this.pxPerMinute}px`;
327
+ const e = this.cal.axis, s = f(x(this.minuteAtY(t.clientY), e.duration), e.min, e.max), i = h("div", "zc-select-box");
328
+ this.content.appendChild(i);
329
+ const n = (o) => {
330
+ const r = f(x(this.minuteAtY(o), e.duration), e.min, e.max), c = Math.min(s, r), a = Math.max(s, r);
331
+ i.style.top = `${(c - e.min) * this.pxPerMinute}px`, i.style.height = `${(a - c) * this.pxPerMinute}px`;
302
332
  };
303
333
  w(t, {
304
- onMove: ({ event: o }) => s(o.clientY),
334
+ onMove: ({ event: o }) => n(o.clientY),
305
335
  onEnd: ({ moved: o, event: r }) => {
306
- if (n.remove(), !o) return;
307
- const c = m(x(this.minuteAtY(r.clientY), e.duration), e.min, e.max);
308
- let a = Math.min(i, c), l = Math.max(i, c);
336
+ if (i.remove(), !o) return;
337
+ const c = f(x(this.minuteAtY(r.clientY), e.duration), e.min, e.max);
338
+ let a = Math.min(s, c), l = Math.max(s, c);
309
339
  l <= a && (l = Math.min(a + e.duration, e.max)), !(l <= a) && this.cal.commitSelect(this.timeAt(a), this.timeAt(l), null, r);
310
340
  }
311
341
  });
312
342
  });
313
343
  }
314
344
  renderNowIndicator() {
315
- var n;
316
- if ((n = this.nowLine) == null || n.remove(), this.nowLine = null, !this.cal.options.nowIndicator || !this.content) return;
345
+ var i;
346
+ if ((i = this.nowLine) == null || i.remove(), this.nowLine = null, !this.cal.options.nowIndicator || !this.content) return;
317
347
  const t = this.cal.now();
318
348
  if (!t.isSame(this.cal.date, "day")) return;
319
- const e = this.cal.axis, i = f(t);
320
- i < e.min || i > e.max || (this.nowLine = h("div", "zc-now-indicator"), this.nowLine.style.top = `${(i - e.min) * this.pxPerMinute}px`, this.content.appendChild(this.nowLine));
349
+ const e = this.cal.axis, s = g(t);
350
+ s < e.min || s > e.max || (this.nowLine = h("div", "zc-now-indicator"), this.nowLine.style.top = `${(s - e.min) * this.pxPerMinute}px`, this.content.appendChild(this.nowLine));
321
351
  }
322
352
  unmount() {
323
353
  var t;
324
354
  (t = this.grid) == null || t.remove(), this.grid = void 0, this.content = void 0, this.nowLine = null;
325
355
  }
326
356
  }
327
- class V {
357
+ class G {
328
358
  constructor(t, e) {
329
359
  this.cal = t, this.root = e, this.nowLine = null, this.cols = [];
330
360
  }
@@ -342,7 +372,7 @@ class V {
342
372
  return { start: t.startOf("day"), end: t.endOf("day") };
343
373
  }
344
374
  title() {
345
- return L(
375
+ return A(
346
376
  this.cal.date,
347
377
  { weekday: "long", day: "numeric", month: "long", year: "numeric" },
348
378
  this.localeTag(),
@@ -352,28 +382,28 @@ class V {
352
382
  // ---- mount ---------------------------------------------------------------
353
383
  mount() {
354
384
  this.rootEl = h("div", "zc-rg");
355
- const t = this.cal.resources.grouped(), e = t.flatMap((s) => s.resources), i = t.length > 1 || t.some((s) => s.group !== null);
356
- this.rootEl.appendChild(this.buildHead(t, i));
357
- const n = h("div", "zc-rg-canvas");
358
- n.style.height = `${this.contentHeight}px`, n.appendChild(this.buildAxis()), this.colsEl = h("div", "zc-rg-cols"), this.cols = [];
359
- for (const s of e) {
385
+ const t = this.cal.resources.grouped(), e = t.flatMap((n) => n.resources), s = t.length > 1 || t.some((n) => n.group !== null);
386
+ this.rootEl.appendChild(this.buildHead(t, s));
387
+ const i = h("div", "zc-rg-canvas");
388
+ i.style.height = `${this.contentHeight}px`, i.appendChild(this.buildAxis()), this.colsEl = h("div", "zc-rg-cols"), this.cols = [];
389
+ for (const n of e) {
360
390
  const o = h("div", "zc-rg-col");
361
- o.dataset.resourceId = s.id, this.buildSlotLines(o), this.bindColSelect(o, s), this.colsEl.appendChild(o), this.cols.push({ resource: s, content: o });
391
+ o.dataset.resourceId = n.id, this.buildSlotLines(o), this.buildNonBusiness(o, n), this.bindColSelect(o, n), this.colsEl.appendChild(o), this.cols.push({ resource: n, content: o });
362
392
  }
363
- n.appendChild(this.colsEl), this.rootEl.appendChild(n), this.root.appendChild(this.rootEl), this.renderEvents();
393
+ i.appendChild(this.colsEl), this.rootEl.appendChild(i), this.root.appendChild(this.rootEl), this.renderEvents();
364
394
  }
365
395
  buildHead(t, e) {
366
396
  var r, c;
367
- const i = h("div", "zc-rg-head"), n = h("div", "zc-rg-corner");
368
- i.appendChild(n);
369
- const s = h("div", "zc-rg-head-cols");
397
+ const s = h("div", "zc-rg-head"), i = h("div", "zc-rg-corner");
398
+ s.appendChild(i);
399
+ const n = h("div", "zc-rg-head-cols");
370
400
  if (e) {
371
401
  const a = h("div", "zc-rg-group-row");
372
402
  for (const l of t) {
373
403
  const d = h("div", "zc-rg-group-band");
374
404
  d.style.flex = `${l.resources.length} 1 0`, d.textContent = l.group ?? "", a.appendChild(d);
375
405
  }
376
- s.appendChild(a);
406
+ n.appendChild(a);
377
407
  }
378
408
  const o = h("div", "zc-rg-label-row");
379
409
  for (const a of t.flatMap((l) => l.resources)) {
@@ -382,46 +412,55 @@ class V {
382
412
  const d = (c = (r = this.cal.options).renderResource) == null ? void 0 : c.call(r, a);
383
413
  d != null ? typeof d == "string" ? l.innerHTML = d : l.appendChild(d) : l.textContent = a.title, o.appendChild(l);
384
414
  }
385
- return s.appendChild(o), i.appendChild(s), i;
415
+ return n.appendChild(o), s.appendChild(n), s;
386
416
  }
387
417
  buildAxis() {
388
418
  const t = h("div", "zc-axis zc-rg-axis");
389
419
  t.style.height = `${this.contentHeight}px`;
390
420
  const e = this.cal.axis;
391
- for (let i = e.min; i <= e.max; i += e.labelInterval) {
392
- const n = h("div", "zc-axis-label");
393
- n.style.top = `${(i - e.min) * this.pxPerMinute}px`, n.textContent = A(i), t.appendChild(n);
421
+ for (let s = e.min; s <= e.max; s += e.labelInterval) {
422
+ const i = h("div", "zc-axis-label");
423
+ i.style.top = `${(s - e.min) * this.pxPerMinute}px`, i.textContent = I(s), t.appendChild(i);
394
424
  }
395
425
  return t;
396
426
  }
427
+ buildNonBusiness(t, e) {
428
+ const s = e.businessHours.length ? e.businessHours : this.cal.businessHours;
429
+ if (!s.length) return;
430
+ const i = this.cal.axis;
431
+ for (const [n, o] of R(P(this.cal.date.day(), s), i.min, i.max)) {
432
+ const r = h("div", "zc-nonbusiness-fill");
433
+ r.style.top = `${(n - i.min) * this.pxPerMinute}px`, r.style.height = `${(o - n) * this.pxPerMinute}px`, t.appendChild(r);
434
+ }
435
+ }
397
436
  buildSlotLines(t) {
398
437
  const e = this.cal.axis;
399
- for (let i = 0; i <= e.slots; i++) {
400
- const n = h("div", "zc-slot-line");
401
- i * e.duration % e.labelInterval === 0 && n.classList.add("zc-slot-major"), n.style.top = `${i * E}px`, t.appendChild(n);
438
+ for (let s = 0; s <= e.slots; s++) {
439
+ const i = h("div", "zc-slot-line");
440
+ s * e.duration % e.labelInterval === 0 && i.classList.add("zc-slot-major"), i.style.top = `${s * E}px`, t.appendChild(i);
402
441
  }
403
442
  }
404
443
  // ---- events --------------------------------------------------------------
405
444
  renderEvents() {
406
445
  if (!this.colsEl) return;
407
446
  const t = this.range(), e = this.cal.axis;
408
- for (const { resource: i, content: n } of this.cols) {
409
- n.querySelectorAll(".zc-event").forEach((o) => o.remove());
410
- const s = I(this.cal.events.inRange(t.start, t.end, i.id));
411
- for (const o of s) {
412
- const r = o.event, c = f(r.start), a = f(r.end) || e.max, l = m(c, e.min, e.max), d = m(a, e.min, e.max), u = (l - e.min) * this.pxPerMinute, g = Math.max(E - 2, (d - l) * this.pxPerMinute), v = h("div", "zc-event");
413
- v.dataset.eventId = r.id, v.style.top = `${u}px`, v.style.height = `${g}px`, v.style.left = `calc(${o.left * 100}% + 2px)`, v.style.width = `calc(${o.width * 100}% - 4px)`, r.color && v.style.setProperty("--zc-event-bg", r.color), r.textColor && v.style.setProperty("--zc-event-fg", r.textColor), v.appendChild(this.cal.renderEventContent(r)), this.bindBar(v, r), n.appendChild(v), this.cal.fireEventMount(r, v);
447
+ for (const { resource: s, content: i } of this.cols) {
448
+ i.querySelectorAll(".zc-event").forEach((o) => o.remove());
449
+ const n = $(this.cal.events.inRange(t.start, t.end, s.id));
450
+ for (const o of n) {
451
+ const r = o.event, c = g(r.start), a = g(r.end) || e.max, l = f(c, e.min, e.max), d = f(a, e.min, e.max), p = (l - e.min) * this.pxPerMinute, m = Math.max(E - 2, (d - l) * this.pxPerMinute), v = h("div", "zc-event");
452
+ v.dataset.eventId = r.id, v.style.top = `${p}px`, v.style.height = `${m}px`, v.style.left = `calc(${o.left * 100}% + 2px)`, v.style.width = `calc(${o.width * 100}% - 4px)`, r.color && v.style.setProperty("--zc-event-bg", r.color), r.textColor && v.style.setProperty("--zc-event-fg", r.textColor), v.appendChild(this.cal.renderEventContent(r)), this.bindBar(v, r), i.appendChild(v), this.cal.fireEventMount(r, v);
414
453
  }
415
454
  }
416
455
  this.renderNowIndicator();
417
456
  }
418
457
  renderNowIndicator() {
419
- var n;
420
- if ((n = this.nowLine) == null || n.remove(), this.nowLine = null, !this.cal.options.nowIndicator || !this.colsEl) return;
458
+ var i;
459
+ if ((i = this.nowLine) == null || i.remove(), this.nowLine = null, !this.cal.options.nowIndicator || !this.colsEl) return;
421
460
  const t = this.cal.now();
422
461
  if (!t.isSame(this.cal.date, "day")) return;
423
- const e = this.cal.axis, i = f(t);
424
- i < e.min || i > e.max || (this.nowLine = h("div", "zc-now-indicator zc-rg-now"), this.nowLine.style.top = `${(i - e.min) * this.pxPerMinute}px`, this.colsEl.appendChild(this.nowLine));
462
+ const e = this.cal.axis, s = g(t);
463
+ s < e.min || s > e.max || (this.nowLine = h("div", "zc-now-indicator zc-rg-now"), this.nowLine.style.top = `${(s - e.min) * this.pxPerMinute}px`, this.colsEl.appendChild(this.nowLine));
425
464
  }
426
465
  // ---- interaction ---------------------------------------------------------
427
466
  timeAt(t) {
@@ -433,75 +472,87 @@ class V {
433
472
  }
434
473
  /** The resource column under the pointer (bar ignored for hit-testing). */
435
474
  resourceIdAt(t, e) {
436
- const i = e.style.pointerEvents;
475
+ const s = e.style.pointerEvents;
437
476
  e.style.pointerEvents = "none";
438
- const n = document.elementFromPoint(t.clientX, t.clientY);
439
- e.style.pointerEvents = i;
440
- const s = n == null ? void 0 : n.closest(".zc-rg-col[data-resource-id]");
441
- return s ? s.dataset.resourceId ?? null : void 0;
477
+ const i = document.elementFromPoint(t.clientX, t.clientY);
478
+ e.style.pointerEvents = s;
479
+ const n = i == null ? void 0 : i.closest(".zc-rg-col[data-resource-id]");
480
+ return n ? n.dataset.resourceId ?? null : void 0;
481
+ }
482
+ highlightCol(t, e) {
483
+ var n;
484
+ this.clearHighlight();
485
+ const s = e.style.pointerEvents;
486
+ e.style.pointerEvents = "none";
487
+ const i = document.elementFromPoint(t.clientX, t.clientY);
488
+ e.style.pointerEvents = s, (n = i == null ? void 0 : i.closest(".zc-rg-col[data-resource-id]")) == null || n.classList.add("zc-drop-target");
489
+ }
490
+ clearHighlight() {
491
+ var t;
492
+ (t = this.colsEl) == null || t.querySelectorAll(".zc-drop-target").forEach((e) => e.classList.remove("zc-drop-target"));
442
493
  }
443
494
  bindBar(t, e) {
444
495
  if (this.cal.bindContextMenu(t, e), !this.cal.editable) {
445
- t.addEventListener("click", (n) => this.cal.fireEventClick(e, t, n));
496
+ t.addEventListener("click", (i) => this.cal.fireEventClick(e, t, i));
446
497
  return;
447
498
  }
448
499
  t.style.cursor = "move";
449
- const i = h("div", "zc-resize-handle zc-resize-s");
450
- t.appendChild(i), i.addEventListener("pointerdown", (n) => this.beginResize(n, t, e)), t.addEventListener("pointerdown", (n) => {
451
- if (n.button !== 0 || n.target.closest(".zc-resize-handle")) return;
452
- n.preventDefault();
453
- const s = this.cal.axis, o = e.end.diff(e.start, "minute"), r = f(e.start), c = this.minuteAtY(n.clientY), a = (l) => m(
454
- x(r + (this.minuteAtY(l) - c), s.duration),
455
- s.min,
456
- s.max - o
500
+ const s = h("div", "zc-resize-handle zc-resize-s");
501
+ t.appendChild(s), s.addEventListener("pointerdown", (i) => this.beginResize(i, t, e)), t.addEventListener("pointerdown", (i) => {
502
+ if (i.button !== 0 || i.target.closest(".zc-resize-handle")) return;
503
+ i.preventDefault();
504
+ const n = this.cal.axis, o = e.end.diff(e.start, "minute"), r = g(e.start), c = this.minuteAtY(i.clientY), a = (l) => f(
505
+ x(r + (this.minuteAtY(l) - c), n.duration),
506
+ n.min,
507
+ n.max - o
457
508
  );
458
- w(n, {
509
+ w(i, {
459
510
  onStart: () => t.classList.add("zc-dragging"),
460
511
  onMove: ({ event: l }) => {
461
- t.style.top = `${(a(l.clientY) - s.min) * this.pxPerMinute}px`;
512
+ t.style.top = `${(a(l.clientY) - n.min) * this.pxPerMinute}px`, this.highlightCol(l, t);
462
513
  },
463
514
  onEnd: ({ moved: l, event: d }) => {
464
- if (t.classList.remove("zc-dragging"), !l) {
515
+ if (t.classList.remove("zc-dragging"), this.clearHighlight(), !l) {
465
516
  this.cal.fireEventClick(e, t, d);
466
517
  return;
467
518
  }
468
- const u = this.timeAt(a(d.clientY)), g = this.resourceIdAt(d, t) ?? e.resourceId;
469
- this.cal.commitEventChange(e, u, u.add(o, "minute"), g);
519
+ const p = this.timeAt(a(d.clientY)), m = this.resourceIdAt(d, t) ?? e.resourceId;
520
+ this.cal.commitEventChange(e, p, p.add(o, "minute"), m);
470
521
  }
471
522
  });
472
523
  });
473
524
  }
474
- beginResize(t, e, i) {
525
+ beginResize(t, e, s) {
475
526
  if (t.button !== 0) return;
476
527
  t.stopPropagation(), t.preventDefault();
477
- const n = this.cal.axis, s = f(i.start), o = (r) => m(x(this.minuteAtY(r), n.duration), s + n.duration, n.max);
528
+ const i = this.cal.axis, n = g(s.start), o = (r) => f(x(this.minuteAtY(r), i.duration), n + i.duration, i.max);
478
529
  w(t, {
479
530
  onStart: () => e.classList.add("zc-dragging"),
480
531
  onMove: ({ event: r }) => {
481
- e.style.height = `${(o(r.clientY) - s) * this.pxPerMinute}px`;
532
+ e.style.height = `${(o(r.clientY) - n) * this.pxPerMinute}px`;
482
533
  },
483
534
  onEnd: ({ moved: r, event: c }) => {
484
- e.classList.remove("zc-dragging"), r && this.cal.commitEventChange(i, i.start, this.timeAt(o(c.clientY)), i.resourceId);
535
+ e.classList.remove("zc-dragging"), r && this.cal.commitEventChange(s, s.start, this.timeAt(o(c.clientY)), s.resourceId);
485
536
  }
486
537
  });
487
538
  }
488
539
  bindColSelect(t, e) {
489
- this.cal.selectable && t.addEventListener("pointerdown", (i) => {
490
- if (i.button !== 0 || i.target.closest(".zc-event")) return;
491
- i.preventDefault();
492
- const n = this.cal.axis, s = m(x(this.minuteAtY(i.clientY), n.duration), n.min, n.max), o = h("div", "zc-select-box zc-rg-select");
540
+ this.cal.selectable && t.addEventListener("pointerdown", (s) => {
541
+ if (s.button !== 0 || s.target.closest(".zc-event")) return;
542
+ s.preventDefault();
543
+ const i = this.cal.axis, n = f(x(this.minuteAtY(s.clientY), i.duration), i.min, i.max), o = h("div", "zc-select-box zc-rg-select");
493
544
  t.appendChild(o);
494
545
  const r = (c) => {
495
- const a = m(x(this.minuteAtY(c), n.duration), n.min, n.max), l = Math.min(s, a), d = Math.max(s, a);
496
- o.style.top = `${(l - n.min) * this.pxPerMinute}px`, o.style.height = `${(d - l) * this.pxPerMinute}px`;
546
+ const a = f(x(this.minuteAtY(c), i.duration), i.min, i.max), l = Math.min(n, a), d = Math.max(n, a);
547
+ o.style.top = `${(l - i.min) * this.pxPerMinute}px`, o.style.height = `${(d - l) * this.pxPerMinute}px`;
497
548
  };
498
- w(i, {
549
+ w(s, {
499
550
  onMove: ({ event: c }) => r(c.clientY),
500
551
  onEnd: ({ moved: c, event: a }) => {
501
552
  if (o.remove(), !c) return;
502
- const l = m(x(this.minuteAtY(a.clientY), n.duration), n.min, n.max);
503
- let d = Math.min(s, l), u = Math.max(s, l);
504
- u <= d && (u = Math.min(d + n.duration, n.max)), !(u <= d) && this.cal.commitSelect(this.timeAt(d), this.timeAt(u), e, a);
553
+ const l = f(x(this.minuteAtY(a.clientY), i.duration), i.min, i.max);
554
+ let d = Math.min(n, l), p = Math.max(n, l);
555
+ p <= d && (p = Math.min(d + i.duration, i.max)), !(p <= d) && this.cal.commitSelect(this.timeAt(d), this.timeAt(p), e, a);
505
556
  }
506
557
  });
507
558
  });
@@ -511,14 +562,14 @@ class V {
511
562
  (t = this.rootEl) == null || t.remove(), this.rootEl = void 0, this.colsEl = void 0, this.nowLine = null, this.cols = [];
512
563
  }
513
564
  }
514
- const T = 38, H = 26, G = 48, Y = 4, U = 90, W = 14;
515
- class q {
565
+ const B = 38, D = 26, U = 48, k = 4, j = 90, Z = 14;
566
+ class J {
516
567
  constructor(t, e) {
517
568
  this.cal = t, this.root = e;
518
569
  }
519
570
  // ---- geometry ------------------------------------------------------------
520
571
  get pxPerMinute() {
521
- return U / 60;
572
+ return j / 60;
522
573
  }
523
574
  get width() {
524
575
  return this.cal.axis.totalMinutes * this.pxPerMinute;
@@ -531,7 +582,7 @@ class q {
531
582
  return { start: t.startOf("day"), end: t.endOf("day") };
532
583
  }
533
584
  title() {
534
- return L(
585
+ return A(
535
586
  this.cal.date,
536
587
  { weekday: "long", day: "numeric", month: "long", year: "numeric" },
537
588
  this.localeTag(),
@@ -544,92 +595,110 @@ class q {
544
595
  const t = (e = this.cal.options.resourceArea) == null ? void 0 : e.columns;
545
596
  return t && t.length ? t : [{ field: "title", header: "" }];
546
597
  }
547
- applyWidth(t, e, i = !0) {
598
+ applyWidth(t, e, s = !0) {
548
599
  if (e != null) {
549
- const n = typeof e == "number" ? `${e}px` : e;
550
- t.style.flex = `0 0 ${n}`, t.style.width = n;
551
- } else i && (t.style.flex = "1 1 0");
600
+ const i = typeof e == "number" ? `${e}px` : e;
601
+ t.style.flex = `0 0 ${i}`, t.style.width = i;
602
+ } else s && (t.style.flex = "1 1 0");
552
603
  }
553
604
  // ---- mount ---------------------------------------------------------------
554
605
  mount() {
555
- var s, o;
606
+ var n, o;
556
607
  this.rootEl = h("div", "zc-timeline");
557
608
  const t = h("div", "zc-tl-resource-area");
558
- this.applyWidth(t, ((s = this.cal.options.resourceArea) == null ? void 0 : s.width) ?? "25%", !1), ((o = this.cal.options.resourceArea) == null ? void 0 : o.width) == null && (t.style.flex = "0 0 25%");
609
+ this.applyWidth(t, ((n = this.cal.options.resourceArea) == null ? void 0 : n.width) ?? "25%", !1), ((o = this.cal.options.resourceArea) == null ? void 0 : o.width) == null && (t.style.flex = "0 0 25%");
559
610
  const e = h("div", "zc-tl-resource-head");
560
- e.style.height = `${T}px`;
611
+ e.style.height = `${B}px`;
561
612
  for (const r of this.columns()) {
562
613
  const c = h("div", "zc-tl-col-head");
563
614
  this.applyWidth(c, r.width), c.textContent = r.header ?? "", e.appendChild(c);
564
615
  }
565
616
  this.resourceBody = h("div", "zc-tl-resource-body"), this.resourceRows = h("div", "zc-tl-resource-rows"), this.resourceBody.appendChild(this.resourceRows), t.append(e, this.resourceBody);
566
- const i = h("div", "zc-tl-time-area");
567
- this.timeHead = h("div", "zc-tl-time-head"), this.timeHead.style.height = `${T}px`, this.buildAxisHeader(this.timeHead), this.timeBody = h("div", "zc-tl-time-body");
568
- const n = h("div", "zc-tl-time-canvas");
569
- n.style.width = `${this.width}px`, this.overlay = h("div", "zc-tl-overlay"), this.buildOverlayLines(this.overlay), this.rowsEl = h("div", "zc-tl-rows"), n.append(this.overlay, this.rowsEl), this.timeBody.appendChild(n), i.append(this.timeHead, this.timeBody), this.rootEl.append(t, i), this.root.appendChild(this.rootEl), this.onScroll = () => {
617
+ const s = h("div", "zc-tl-time-area");
618
+ this.timeHead = h("div", "zc-tl-time-head"), this.timeHead.style.height = `${B}px`, this.buildAxisHeader(this.timeHead), this.timeBody = h("div", "zc-tl-time-body");
619
+ const i = h("div", "zc-tl-time-canvas");
620
+ i.style.width = `${this.width}px`, this.overlay = h("div", "zc-tl-overlay"), this.buildOverlayLines(this.overlay), this.rowsEl = h("div", "zc-tl-rows"), i.append(this.overlay, this.rowsEl), this.timeBody.appendChild(i), s.append(this.timeHead, this.timeBody), this.rootEl.append(t, s), this.root.appendChild(this.rootEl), this.onScroll = () => {
570
621
  this.resourceBody && this.timeBody && (this.resourceBody.scrollTop = this.timeBody.scrollTop), this.timeHead && this.timeBody && (this.timeHead.scrollLeft = this.timeBody.scrollLeft);
571
622
  }, this.timeBody.addEventListener("scroll", this.onScroll, { passive: !0 }), this.relayout();
572
623
  }
573
624
  buildAxisHeader(t) {
574
625
  const e = h("div", "zc-tl-axis");
575
626
  e.style.width = `${this.width}px`;
576
- const i = this.cal.axis;
577
- for (let n = i.min; n <= i.max; n += i.labelInterval) {
578
- const s = h("div", "zc-tl-axis-label");
579
- s.style.left = `${(n - i.min) * this.pxPerMinute}px`, s.textContent = A(n), e.appendChild(s);
627
+ const s = this.cal.axis;
628
+ for (let i = s.min; i <= s.max; i += s.labelInterval) {
629
+ const n = h("div", "zc-tl-axis-label");
630
+ n.style.left = `${(i - s.min) * this.pxPerMinute}px`, n.textContent = I(i), e.appendChild(n);
580
631
  }
581
632
  t.appendChild(e);
582
633
  }
583
634
  buildOverlayLines(t) {
584
635
  const e = this.cal.axis;
585
- for (let i = e.min; i <= e.max; i += e.labelInterval) {
586
- const n = h("div", "zc-tl-vline");
587
- n.style.left = `${(i - e.min) * this.pxPerMinute}px`, t.appendChild(n);
636
+ for (let s = e.min; s <= e.max; s += e.labelInterval) {
637
+ const i = h("div", "zc-tl-vline");
638
+ i.style.left = `${(s - e.min) * this.pxPerMinute}px`, t.appendChild(i);
588
639
  }
589
640
  }
590
641
  // ---- layout (rows + events) ---------------------------------------------
591
642
  renderEvents() {
592
643
  this.relayout();
593
644
  }
645
+ /** Re-render only the resource-area cells, leaving event bars untouched. */
646
+ renderResources() {
647
+ this.resourceRows && this.resourceRows.querySelectorAll(".zc-tl-resource-row[data-resource-id]").forEach((t) => {
648
+ const e = this.cal.resources.get(t.dataset.resourceId ?? "");
649
+ if (e) {
650
+ t.innerHTML = "";
651
+ for (const s of this.columns()) {
652
+ const i = h("div", "zc-tl-col-cell");
653
+ this.applyWidth(i, s.width), this.fillResourceCell(i, s, e), t.appendChild(i);
654
+ }
655
+ }
656
+ });
657
+ }
594
658
  /** Rebuild rows in both panes from the current resources + events. */
595
659
  relayout() {
596
660
  if (!this.resourceRows || !this.rowsEl) return;
597
661
  this.resourceRows.innerHTML = "", this.rowsEl.innerHTML = "";
598
- const t = this.range(), e = this.cal.resources.grouped(), i = e.length > 1 || e.some((n) => n.group !== null);
599
- for (const n of e) {
600
- i && n.group !== null && this.appendGroupRow(n.group);
601
- for (const s of n.resources) {
602
- const o = this.cal.events.inRange(t.start, t.end, s.id);
603
- this.appendResourceRow(s, o);
662
+ const t = this.range(), e = this.cal.resources.grouped(), s = e.length > 1 || e.some((i) => i.group !== null);
663
+ for (const i of e) {
664
+ s && i.group !== null && this.appendGroupRow(i.group);
665
+ for (const n of i.resources) {
666
+ const o = this.cal.events.inRange(t.start, t.end, n.id);
667
+ this.appendResourceRow(n, o);
604
668
  }
605
669
  }
606
670
  this.renderNowIndicator();
607
671
  }
608
672
  appendGroupRow(t) {
609
673
  const e = h("div", "zc-tl-resource-row zc-tl-group-row");
610
- e.style.height = `${H}px`, e.textContent = t, this.resourceRows.appendChild(e);
611
- const i = h("div", "zc-tl-row zc-tl-group-spacer");
612
- i.style.height = `${H}px`, this.rowsEl.appendChild(i);
674
+ e.style.height = `${D}px`, e.textContent = t, this.resourceRows.appendChild(e);
675
+ const s = h("div", "zc-tl-row zc-tl-group-spacer");
676
+ s.style.height = `${D}px`, this.rowsEl.appendChild(s);
613
677
  }
614
678
  appendResourceRow(t, e) {
615
- const i = I(e), n = i.reduce((d, u) => Math.max(d, u.cols), 1), s = this.cal.options.eventMinHeight ?? G, o = n * s + 2 * Y, r = s, c = h("div", "zc-tl-resource-row");
679
+ const s = $(e), i = s.reduce((p, m) => Math.max(p, m.cols), 1), n = this.cal.options.eventMinHeight ?? U, o = i * n + 2 * k, r = n, c = h("div", "zc-tl-resource-row");
616
680
  c.style.height = `${o}px`, c.dataset.resourceId = t.id;
617
- for (const d of this.columns()) {
618
- const u = h("div", "zc-tl-col-cell");
619
- this.applyWidth(u, d.width), this.fillResourceCell(u, d, t), c.appendChild(u);
681
+ for (const p of this.columns()) {
682
+ const m = h("div", "zc-tl-col-cell");
683
+ this.applyWidth(m, p.width), this.fillResourceCell(m, p, t), c.appendChild(m);
620
684
  }
621
685
  this.resourceRows.appendChild(c);
622
686
  const a = h("div", "zc-tl-row");
623
687
  a.style.height = `${o}px`, a.dataset.resourceId = t.id;
624
- const l = this.cal.axis;
625
- for (const d of i) {
626
- const u = d.event, g = f(u.start);
627
- let v = f(u.end);
628
- v <= g && (v = l.max);
629
- const z = m(g, l.min, l.max), S = m(v, l.min, l.max);
630
- if (S <= l.min || z >= l.max) continue;
631
- const P = (z - l.min) * this.pxPerMinute, B = Math.max(W, (S - z) * this.pxPerMinute), D = Y + d.col * r, y = h("div", "zc-event zc-tl-event");
632
- y.dataset.eventId = u.id, y.style.left = `${P}px`, y.style.width = `${Math.min(B, this.width - P)}px`, y.style.top = `${D}px`, y.style.height = `${r - 2}px`, u.color && y.style.setProperty("--zc-event-bg", u.color), u.textColor && y.style.setProperty("--zc-event-fg", u.textColor), y.appendChild(this.cal.renderEventContent(u)), this.bindBar(y, u), a.appendChild(y), this.cal.fireEventMount(u, y);
688
+ const l = this.cal.axis, d = t.businessHours.length ? t.businessHours : this.cal.businessHours;
689
+ if (d.length)
690
+ for (const [p, m] of R(P(this.cal.date.day(), d), l.min, l.max)) {
691
+ const v = h("div", "zc-nonbusiness-fill");
692
+ v.style.left = `${(p - l.min) * this.pxPerMinute}px`, v.style.width = `${(m - p) * this.pxPerMinute}px`, a.appendChild(v);
693
+ }
694
+ for (const p of s) {
695
+ const m = p.event, v = g(m.start);
696
+ let z = g(m.end);
697
+ z <= v && (z = l.max);
698
+ const S = f(v, l.min, l.max), H = f(z, l.min, l.max);
699
+ if (H <= l.min || S >= l.max) continue;
700
+ const T = (S - l.min) * this.pxPerMinute, O = Math.max(Z, (H - S) * this.pxPerMinute), N = k + p.col * r, y = h("div", "zc-event zc-tl-event");
701
+ y.dataset.eventId = m.id, y.style.left = `${T}px`, y.style.width = `${Math.min(O, this.width - T)}px`, y.style.top = `${N}px`, y.style.height = `${r - 2}px`, m.color && y.style.setProperty("--zc-event-bg", m.color), m.textColor && y.style.setProperty("--zc-event-fg", m.textColor), y.appendChild(this.cal.renderEventContent(m)), this.bindBar(y, m), a.appendChild(y), this.cal.fireEventMount(m, y);
633
702
  }
634
703
  this.bindRowSelect(a, t), this.rowsEl.appendChild(a);
635
704
  }
@@ -643,14 +712,14 @@ class q {
643
712
  }
644
713
  /** The resource row currently under the pointer (bar ignored for hit-testing). */
645
714
  rowAt(t, e) {
646
- const i = e.style.pointerEvents;
715
+ const s = e.style.pointerEvents;
647
716
  e.style.pointerEvents = "none";
648
- const n = document.elementFromPoint(t.clientX, t.clientY);
649
- return e.style.pointerEvents = i, (n == null ? void 0 : n.closest(".zc-tl-row[data-resource-id]")) ?? null;
717
+ const i = document.elementFromPoint(t.clientX, t.clientY);
718
+ return e.style.pointerEvents = s, (i == null ? void 0 : i.closest(".zc-tl-row[data-resource-id]")) ?? null;
650
719
  }
651
720
  highlightRow(t, e) {
652
- var i;
653
- this.clearHighlight(), (i = this.rowAt(t, e)) == null || i.classList.add("zc-drop-target");
721
+ var s;
722
+ this.clearHighlight(), (s = this.rowAt(t, e)) == null || s.classList.add("zc-drop-target");
654
723
  }
655
724
  clearHighlight() {
656
725
  var t;
@@ -658,108 +727,108 @@ class q {
658
727
  }
659
728
  bindBar(t, e) {
660
729
  if (this.cal.bindContextMenu(t, e), !this.cal.editable) {
661
- t.addEventListener("click", (s) => this.cal.fireEventClick(e, t, s));
730
+ t.addEventListener("click", (n) => this.cal.fireEventClick(e, t, n));
662
731
  return;
663
732
  }
664
733
  t.style.cursor = "move";
665
- const i = h("div", "zc-resize-handle zc-resize-w"), n = h("div", "zc-resize-handle zc-resize-e");
666
- t.append(i, n), i.addEventListener("pointerdown", (s) => this.beginResize(s, t, e, "start")), n.addEventListener("pointerdown", (s) => this.beginResize(s, t, e, "end")), t.addEventListener("pointerdown", (s) => {
667
- if (s.button !== 0 || s.target.closest(".zc-resize-handle")) return;
668
- s.preventDefault();
669
- const o = this.cal.axis, r = e.end.diff(e.start, "minute"), c = f(e.start), a = this.minuteAtX(s.clientX), l = (d) => m(
734
+ const s = h("div", "zc-resize-handle zc-resize-w"), i = h("div", "zc-resize-handle zc-resize-e");
735
+ t.append(s, i), s.addEventListener("pointerdown", (n) => this.beginResize(n, t, e, "start")), i.addEventListener("pointerdown", (n) => this.beginResize(n, t, e, "end")), t.addEventListener("pointerdown", (n) => {
736
+ if (n.button !== 0 || n.target.closest(".zc-resize-handle")) return;
737
+ n.preventDefault();
738
+ const o = this.cal.axis, r = e.end.diff(e.start, "minute"), c = g(e.start), a = this.minuteAtX(n.clientX), l = (d) => f(
670
739
  x(c + (this.minuteAtX(d) - a), o.duration),
671
740
  o.min,
672
741
  o.max - r
673
742
  );
674
- w(s, {
743
+ w(n, {
675
744
  onStart: () => t.classList.add("zc-dragging"),
676
745
  onMove: ({ event: d }) => {
677
746
  t.style.left = `${(l(d.clientX) - o.min) * this.pxPerMinute}px`, this.highlightRow(d, t);
678
747
  },
679
- onEnd: ({ moved: d, event: u }) => {
748
+ onEnd: ({ moved: d, event: p }) => {
680
749
  if (t.classList.remove("zc-dragging"), this.clearHighlight(), !d) {
681
- this.cal.fireEventClick(e, t, u);
750
+ this.cal.fireEventClick(e, t, p);
682
751
  return;
683
752
  }
684
- const g = this.rowAt(u, t), v = g ? g.dataset.resourceId ?? null : e.resourceId, z = this.timeAt(l(u.clientX));
753
+ const m = this.rowAt(p, t), v = m ? m.dataset.resourceId ?? null : e.resourceId, z = this.timeAt(l(p.clientX));
685
754
  this.cal.commitEventChange(e, z, z.add(r, "minute"), v);
686
755
  }
687
756
  });
688
757
  });
689
758
  }
690
- beginResize(t, e, i, n) {
759
+ beginResize(t, e, s, i) {
691
760
  if (t.button !== 0) return;
692
761
  t.stopPropagation(), t.preventDefault();
693
- const s = this.cal.axis, o = (r) => m(x(this.minuteAtX(r), s.duration), s.min, s.max);
762
+ const n = this.cal.axis, o = (r) => f(x(this.minuteAtX(r), n.duration), n.min, n.max);
694
763
  w(t, {
695
764
  onStart: () => e.classList.add("zc-dragging"),
696
765
  onMove: ({ event: r }) => {
697
766
  const c = o(r.clientX);
698
- if (n === "end") {
699
- const a = Math.max(c, f(i.start) + s.duration);
700
- e.style.width = `${(a - f(i.start)) * this.pxPerMinute}px`;
767
+ if (i === "end") {
768
+ const a = Math.max(c, g(s.start) + n.duration);
769
+ e.style.width = `${(a - g(s.start)) * this.pxPerMinute}px`;
701
770
  } else {
702
- const a = Math.min(c, f(i.end) - s.duration);
703
- e.style.left = `${(a - s.min) * this.pxPerMinute}px`, e.style.width = `${(f(i.end) - a) * this.pxPerMinute}px`;
771
+ const a = Math.min(c, g(s.end) - n.duration);
772
+ e.style.left = `${(a - n.min) * this.pxPerMinute}px`, e.style.width = `${(g(s.end) - a) * this.pxPerMinute}px`;
704
773
  }
705
774
  },
706
775
  onEnd: ({ moved: r, event: c }) => {
707
776
  if (e.classList.remove("zc-dragging"), !r) return;
708
777
  const a = o(c.clientX);
709
- if (n === "end") {
710
- const l = Math.max(a, f(i.start) + s.duration);
711
- this.cal.commitEventChange(i, i.start, this.timeAt(l), i.resourceId);
778
+ if (i === "end") {
779
+ const l = Math.max(a, g(s.start) + n.duration);
780
+ this.cal.commitEventChange(s, s.start, this.timeAt(l), s.resourceId);
712
781
  } else {
713
- const l = Math.min(a, f(i.end) - s.duration);
714
- this.cal.commitEventChange(i, this.timeAt(l), i.end, i.resourceId);
782
+ const l = Math.min(a, g(s.end) - n.duration);
783
+ this.cal.commitEventChange(s, this.timeAt(l), s.end, s.resourceId);
715
784
  }
716
785
  }
717
786
  });
718
787
  }
719
788
  bindRowSelect(t, e) {
720
- this.cal.selectable && t.addEventListener("pointerdown", (i) => {
721
- if (i.button !== 0 || i.target.closest(".zc-event")) return;
722
- i.preventDefault();
723
- const n = this.cal.axis, s = m(x(this.minuteAtX(i.clientX), n.duration), n.min, n.max), o = h("div", "zc-select-box zc-tl-select");
789
+ this.cal.selectable && t.addEventListener("pointerdown", (s) => {
790
+ if (s.button !== 0 || s.target.closest(".zc-event")) return;
791
+ s.preventDefault();
792
+ const i = this.cal.axis, n = f(x(this.minuteAtX(s.clientX), i.duration), i.min, i.max), o = h("div", "zc-select-box zc-tl-select");
724
793
  t.appendChild(o);
725
794
  const r = (c) => {
726
- const a = m(x(this.minuteAtX(c), n.duration), n.min, n.max), l = Math.min(s, a), d = Math.max(s, a);
727
- o.style.left = `${(l - n.min) * this.pxPerMinute}px`, o.style.width = `${(d - l) * this.pxPerMinute}px`;
795
+ const a = f(x(this.minuteAtX(c), i.duration), i.min, i.max), l = Math.min(n, a), d = Math.max(n, a);
796
+ o.style.left = `${(l - i.min) * this.pxPerMinute}px`, o.style.width = `${(d - l) * this.pxPerMinute}px`;
728
797
  };
729
- w(i, {
798
+ w(s, {
730
799
  onMove: ({ event: c }) => r(c.clientX),
731
800
  onEnd: ({ moved: c, event: a }) => {
732
801
  if (o.remove(), !c) return;
733
- const l = m(x(this.minuteAtX(a.clientX), n.duration), n.min, n.max);
734
- let d = Math.min(s, l), u = Math.max(s, l);
735
- u <= d && (u = Math.min(d + n.duration, n.max)), !(u <= d) && this.cal.commitSelect(this.timeAt(d), this.timeAt(u), e, a);
802
+ const l = f(x(this.minuteAtX(a.clientX), i.duration), i.min, i.max);
803
+ let d = Math.min(n, l), p = Math.max(n, l);
804
+ p <= d && (p = Math.min(d + i.duration, i.max)), !(p <= d) && this.cal.commitSelect(this.timeAt(d), this.timeAt(p), e, a);
736
805
  }
737
806
  });
738
807
  });
739
808
  }
740
- fillResourceCell(t, e, i) {
809
+ fillResourceCell(t, e, s) {
741
810
  if (e.render) {
742
- const s = e.render(i);
743
- typeof s == "string" ? t.innerHTML = s : t.appendChild(s);
811
+ const n = e.render(s);
812
+ typeof n == "string" ? t.innerHTML = n : t.appendChild(n);
744
813
  return;
745
814
  }
746
815
  if ((e.field === "title" || !e.field) && this.cal.options.renderResource) {
747
- const s = this.cal.options.renderResource(i);
748
- typeof s == "string" ? t.innerHTML = s : t.appendChild(s);
816
+ const n = this.cal.options.renderResource(s);
817
+ typeof n == "string" ? t.innerHTML = n : t.appendChild(n);
749
818
  return;
750
819
  }
751
- const n = e.field ? i.raw[e.field] : i.title;
752
- t.textContent = n != null ? String(n) : "";
820
+ const i = e.field ? s.raw[e.field] : s.title;
821
+ t.textContent = i != null ? String(i) : "";
753
822
  }
754
823
  renderNowIndicator() {
755
- var s, o;
756
- if ((o = (s = this.overlay) == null ? void 0 : s.querySelector(".zc-tl-now")) == null || o.remove(), !this.cal.options.nowIndicator || !this.overlay) return;
824
+ var n, o;
825
+ if ((o = (n = this.overlay) == null ? void 0 : n.querySelector(".zc-tl-now")) == null || o.remove(), !this.cal.options.nowIndicator || !this.overlay) return;
757
826
  const t = this.cal.now();
758
827
  if (!t.isSame(this.cal.date, "day")) return;
759
- const e = this.cal.axis, i = f(t);
760
- if (i < e.min || i > e.max) return;
761
- const n = h("div", "zc-tl-now");
762
- n.style.left = `${(i - e.min) * this.pxPerMinute}px`, this.overlay.appendChild(n);
828
+ const e = this.cal.axis, s = g(t);
829
+ if (s < e.min || s > e.max) return;
830
+ const i = h("div", "zc-tl-now");
831
+ i.style.left = `${(s - e.min) * this.pxPerMinute}px`, this.overlay.appendChild(i);
763
832
  }
764
833
  unmount() {
765
834
  var t, e;
@@ -770,13 +839,13 @@ const M = {
770
839
  code: "en",
771
840
  buttons: { today: "Today", prev: "‹", next: "›" },
772
841
  ariaLabels: { today: "Today", prev: "Previous", next: "Next" }
773
- }, j = { start: "", center: "title", end: "today prev next" };
774
- class Q {
842
+ }, K = { start: "", center: "title", end: "today prev next" };
843
+ class it {
775
844
  constructor(t, e = {}) {
776
- this.viewImpl = null, this.bodyEl = null, this.titleEl = null, this.el = t, this.options = e, this.events = new _(e.timezone), this.resources = new X(
845
+ this.viewImpl = null, this.bodyEl = null, this.titleEl = null, this.resourceRenderScheduled = !1, this.el = t, this.options = e, this.events = new V(e.timezone), this.resources = new W(
777
846
  e.resourceGroupField ?? "group",
778
847
  e.resourceOrder ?? "order"
779
- ), this._view = e.view ?? "day", this._date = e.date ? b(e.date, e.timezone) : $(e.timezone), Array.isArray(e.resources) && this.resources.set(e.resources), Array.isArray(e.events) && this.events.set(e.events);
848
+ ), this._view = e.view ?? "day", this._date = e.date ? b(e.date, e.timezone) : Y(e.timezone), Array.isArray(e.resources) && this.resources.set(e.resources), Array.isArray(e.events) && this.events.set(e.events);
780
849
  }
781
850
  // ---- derived state -------------------------------------------------------
782
851
  get tz() {
@@ -789,7 +858,7 @@ class Q {
789
858
  return this._view;
790
859
  }
791
860
  get axis() {
792
- return N(this.options.slot);
861
+ return F(this.options.slot);
793
862
  }
794
863
  get locale() {
795
864
  const t = this.options.locale;
@@ -817,6 +886,11 @@ class Q {
817
886
  getView() {
818
887
  return { type: this._view, activeStart: this.activeStart, activeEnd: this.activeEnd };
819
888
  }
889
+ /** Default business hours (normalised to an array). */
890
+ get businessHours() {
891
+ const t = this.options.businessHours;
892
+ return t ? Array.isArray(t) ? t : [t] : [];
893
+ }
820
894
  isDayClosed() {
821
895
  const t = this.options.dayClosed;
822
896
  return t === void 0 ? !1 : typeof t == "function" ? t(this._date) : t;
@@ -828,7 +902,7 @@ class Q {
828
902
  return this.options.selectable === !0;
829
903
  }
830
904
  now() {
831
- return $(this.tz);
905
+ return Y(this.tz);
832
906
  }
833
907
  // ---- lifecycle -----------------------------------------------------------
834
908
  render() {
@@ -844,11 +918,11 @@ class Q {
844
918
  if (!e) throw new Error("[@ziix/calendar] render() must run before a view is created");
845
919
  switch (t) {
846
920
  case "day":
847
- return new F(this, e);
921
+ return new q(this, e);
848
922
  case "resource-day":
849
- return new V(this, e);
923
+ return new G(this, e);
850
924
  case "timeline":
851
- return new q(this, e);
925
+ return new J(this, e);
852
926
  default:
853
927
  throw new Error(`[@ziix/calendar] unknown view: ${String(t)}`);
854
928
  }
@@ -879,21 +953,21 @@ class Q {
879
953
  typeof this.options.resources == "function" && (await this.refetchResources(), this.mountView()), await this.refetchEvents();
880
954
  }
881
955
  async refetchResources() {
882
- var i;
956
+ var s;
883
957
  const t = this.options.resources;
884
958
  if (typeof t != "function") return;
885
- const e = (i = this.viewImpl) == null ? void 0 : i.range();
959
+ const e = (s = this.viewImpl) == null ? void 0 : s.range();
886
960
  e && this.resources.set(await t(e));
887
961
  }
888
962
  async refetchEvents() {
889
- var i, n, s, o;
890
- const t = this.options.events, e = (i = this.viewImpl) == null ? void 0 : i.range();
891
- typeof t == "function" && e && this.events.set(await t(e)), (s = (n = this.options).onEventsSet) == null || s.call(n, this.events.all()), (o = this.viewImpl) == null || o.renderEvents();
963
+ var s, i, n, o;
964
+ const t = this.options.events, e = (s = this.viewImpl) == null ? void 0 : s.range();
965
+ typeof t == "function" && e && this.events.set(await t(e)), (n = (i = this.options).onEventsSet) == null || n.call(i, this.events.all()), (o = this.viewImpl) == null || o.renderEvents();
892
966
  }
893
967
  addEvent(t) {
894
- var i;
968
+ var s;
895
969
  const e = this.events.add(t);
896
- return (i = this.viewImpl) == null || i.renderEvents(), this.handle(e);
970
+ return (s = this.viewImpl) == null || s.renderEvents(), this.handle(e);
897
971
  }
898
972
  getEventById(t) {
899
973
  const e = this.events.get(t);
@@ -909,17 +983,27 @@ class Q {
909
983
  const e = this.resources.get(t);
910
984
  return e ? this.resourceHandle(e) : null;
911
985
  }
986
+ /**
987
+ * Coalesce resource-area re-renders: many setExtendedProp calls in a row (e.g.
988
+ * pushing work hours / punch-ins for every resource) collapse into a single
989
+ * cell update on the next microtask, and event bars are never rebuilt — so the
990
+ * timeline doesn't flicker.
991
+ */
992
+ scheduleResourceRender() {
993
+ this.resourceRenderScheduled || (this.resourceRenderScheduled = !0, queueMicrotask(() => {
994
+ var t, e;
995
+ this.resourceRenderScheduled = !1, (t = this.viewImpl) != null && t.renderResources ? this.viewImpl.renderResources() : (e = this.viewImpl) == null || e.renderEvents();
996
+ }));
997
+ }
912
998
  resourceHandle(t) {
913
999
  return {
914
1000
  id: t.id,
915
1001
  resource: t,
916
- setExtendedProp: (e, i) => {
917
- var n;
918
- t.extendedProps[e] = i, (n = this.viewImpl) == null || n.renderEvents();
1002
+ setExtendedProp: (e, s) => {
1003
+ t.extendedProps[e] = s, this.scheduleResourceRender();
919
1004
  },
920
- setProp: (e, i) => {
921
- var n;
922
- e === "title" ? t.title = i : t.group = i, (n = this.viewImpl) == null || n.renderEvents();
1005
+ setProp: (e, s) => {
1006
+ e === "title" ? t.title = s : t.group = s, this.scheduleResourceRender();
923
1007
  }
924
1008
  };
925
1009
  }
@@ -931,45 +1015,45 @@ class Q {
931
1015
  var e;
932
1016
  this.events.remove(t.id), (e = this.viewImpl) == null || e.renderEvents();
933
1017
  },
934
- setExtendedProp: (e, i) => {
935
- var n;
936
- t.extendedProps[e] = i, (n = this.viewImpl) == null || n.renderEvents();
1018
+ setExtendedProp: (e, s) => {
1019
+ var i;
1020
+ t.extendedProps[e] = s, (i = this.viewImpl) == null || i.renderEvents();
937
1021
  }
938
1022
  };
939
1023
  }
940
1024
  // ---- rendering helpers used by views ------------------------------------
941
1025
  /** Build the inner body of an event, honouring the `renderEvent` hook. */
942
1026
  renderEventContent(t) {
943
- var n, s;
1027
+ var i, n;
944
1028
  const e = document.createElement("div");
945
1029
  e.className = "zc-event-main";
946
- const i = (s = (n = this.options).renderEvent) == null ? void 0 : s.call(n, t);
947
- return i != null ? typeof i == "string" ? e.innerHTML = i : e.appendChild(i) : e.appendChild(this.defaultEventContent(t)), e;
1030
+ const s = (n = (i = this.options).renderEvent) == null ? void 0 : n.call(i, t);
1031
+ return s != null ? typeof s == "string" ? e.innerHTML = s : e.appendChild(s) : e.appendChild(this.defaultEventContent(t)), e;
948
1032
  }
949
1033
  defaultEventContent(t) {
950
1034
  const e = document.createElement("div");
951
1035
  e.className = "zc-event-default";
952
- const i = document.createElement("span");
953
- i.className = "zc-event-time";
954
- const n = this.options.timeFormat ?? { hour: "2-digit", minute: "2-digit", hour12: !1 };
955
- i.textContent = L(t.start, n, this.locale.intl ?? this.locale.code, this.tz);
956
1036
  const s = document.createElement("span");
957
- return s.className = "zc-event-title", s.textContent = t.title, e.append(i, s), e;
1037
+ s.className = "zc-event-time";
1038
+ const i = this.options.timeFormat ?? { hour: "2-digit", minute: "2-digit", hour12: !1 };
1039
+ s.textContent = A(t.start, i, this.locale.intl ?? this.locale.code, this.tz);
1040
+ const n = document.createElement("span");
1041
+ return n.className = "zc-event-title", n.textContent = t.title, e.append(s, n), e;
958
1042
  }
959
1043
  // ---- callback dispatch (called by views) --------------------------------
960
- fireEventClick(t, e, i) {
961
- var n, s;
962
- (s = (n = this.options).onEventClick) == null || s.call(n, { event: t, el: e, jsEvent: i });
1044
+ fireEventClick(t, e, s) {
1045
+ var i, n;
1046
+ (n = (i = this.options).onEventClick) == null || n.call(i, { event: t, el: e, jsEvent: s });
963
1047
  }
964
1048
  fireEventMount(t, e) {
965
- var i, n;
966
- (n = (i = this.options).onEventMount) == null || n.call(i, { event: t, el: e });
1049
+ var s, i;
1050
+ (i = (s = this.options).onEventMount) == null || i.call(s, { event: t, el: e });
967
1051
  }
968
1052
  /** Attach a right-click handler to an event bar when `onEventContextMenu` is set. */
969
1053
  bindContextMenu(t, e) {
970
- const i = this.options.onEventContextMenu;
971
- i && t.addEventListener("contextmenu", (n) => {
972
- n.preventDefault(), i({ event: e, el: t, jsEvent: n });
1054
+ const s = this.options.onEventContextMenu;
1055
+ s && t.addEventListener("contextmenu", (i) => {
1056
+ i.preventDefault(), s({ event: e, el: t, jsEvent: i });
973
1057
  });
974
1058
  }
975
1059
  /** Whether events are allowed to overlap on the same resource (default true). */
@@ -977,9 +1061,9 @@ class Q {
977
1061
  const t = this.options.eventOverlap;
978
1062
  return t === void 0 ? !0 : typeof t == "function" ? t() : t;
979
1063
  }
980
- hasCollision(t, e, i, n) {
1064
+ hasCollision(t, e, s, i) {
981
1065
  return this.events.all().some(
982
- (s) => s.id !== t.id && s.resourceId === n && s.start.isBefore(i) && s.end.isAfter(e)
1066
+ (n) => n.id !== t.id && n.resourceId === i && n.start.isBefore(s) && n.end.isAfter(e)
983
1067
  );
984
1068
  }
985
1069
  /**
@@ -987,65 +1071,65 @@ class Q {
987
1071
  * re-render, and fire `onEventChange`. Returns false (and reverts the live
988
1072
  * preview by re-rendering) when the move is rejected.
989
1073
  */
990
- commitEventChange(t, e, i, n) {
991
- var c, a, l, d, u;
992
- if (t.start.isSame(e) && t.end.isSame(i) && t.resourceId === n)
1074
+ commitEventChange(t, e, s, i) {
1075
+ var c, a, l, d, p;
1076
+ if (t.start.isSame(e) && t.end.isSame(s) && t.resourceId === i)
993
1077
  return (c = this.viewImpl) == null || c.renderEvents(), !1;
994
- if (!this.allowsOverlap() && this.hasCollision(t, e, i, n))
1078
+ if (!this.allowsOverlap() && this.hasCollision(t, e, s, i))
995
1079
  return (a = this.viewImpl) == null || a.renderEvents(), !1;
996
1080
  const o = { ...t };
997
- t.start = e, t.end = i, t.resourceId = n, (l = this.viewImpl) == null || l.renderEvents();
1081
+ t.start = e, t.end = s, t.resourceId = i, (l = this.viewImpl) == null || l.renderEvents();
998
1082
  const r = () => {
999
- var g;
1000
- t.start = o.start, t.end = o.end, t.resourceId = o.resourceId, (g = this.viewImpl) == null || g.renderEvents();
1083
+ var m;
1084
+ t.start = o.start, t.end = o.end, t.resourceId = o.resourceId, (m = this.viewImpl) == null || m.renderEvents();
1001
1085
  };
1002
- return (u = (d = this.options).onEventChange) == null || u.call(d, { event: t, oldEvent: o, revert: r }), !0;
1086
+ return (p = (d = this.options).onEventChange) == null || p.call(d, { event: t, oldEvent: o, revert: r }), !0;
1003
1087
  }
1004
1088
  /** Gate a drag-selection on `selectAllow`, then fire `onSelect`. */
1005
- commitSelect(t, e, i, n) {
1006
- var s, o;
1007
- return this.options.selectAllow && !this.options.selectAllow({ start: t, end: e, resource: i }) ? !1 : ((o = (s = this.options).onSelect) == null || o.call(s, { start: t, end: e, resource: i, jsEvent: n }), !0);
1089
+ commitSelect(t, e, s, i) {
1090
+ var n, o;
1091
+ return this.options.selectAllow && !this.options.selectAllow({ start: t, end: e, resource: s }) ? !1 : ((o = (n = this.options).onSelect) == null || o.call(n, { start: t, end: e, resource: s, jsEvent: i }), !0);
1008
1092
  }
1009
1093
  // ---- toolbar -------------------------------------------------------------
1010
1094
  renderToolbar() {
1011
1095
  if (this.options.toolbar === !1) return;
1012
- const t = this.options.toolbar ?? j, e = document.createElement("div");
1096
+ const t = this.options.toolbar ?? K, e = document.createElement("div");
1013
1097
  e.className = "zc-toolbar";
1014
- for (const i of ["start", "center", "end"]) {
1015
- const n = document.createElement("div");
1016
- n.className = `zc-toolbar-section zc-toolbar-${i}`;
1017
- const s = t[i];
1018
- if (s)
1019
- for (const o of s.split(/\s+/).filter(Boolean)) {
1098
+ for (const s of ["start", "center", "end"]) {
1099
+ const i = document.createElement("div");
1100
+ i.className = `zc-toolbar-section zc-toolbar-${s}`;
1101
+ const n = t[s];
1102
+ if (n)
1103
+ for (const o of n.split(/\s+/).filter(Boolean)) {
1020
1104
  const r = o.split(",").filter(Boolean);
1021
1105
  if (r.length === 1 && r[0] === "title") {
1022
- n.appendChild(this.renderToolbarToken("title"));
1106
+ i.appendChild(this.renderToolbarToken("title"));
1023
1107
  continue;
1024
1108
  }
1025
1109
  const c = document.createElement("div");
1026
1110
  c.className = "zc-btn-group";
1027
1111
  for (const a of r) c.appendChild(this.renderToolbarToken(a));
1028
- n.appendChild(c);
1112
+ i.appendChild(c);
1029
1113
  }
1030
- e.appendChild(n);
1114
+ e.appendChild(i);
1031
1115
  }
1032
1116
  this.el.appendChild(e);
1033
1117
  }
1034
1118
  renderToolbarToken(t) {
1035
- var s;
1119
+ var n;
1036
1120
  if (t === "title")
1037
1121
  return this.titleEl = document.createElement("h2"), this.titleEl.className = "zc-title", this.titleEl;
1038
1122
  const e = document.createElement("button");
1039
1123
  e.type = "button", e.className = "zc-btn", e.dataset.zcButton = t;
1040
- const i = this.locale.buttons ?? {}, n = this.locale.ariaLabels ?? {};
1124
+ const s = this.locale.buttons ?? {}, i = this.locale.ariaLabels ?? {};
1041
1125
  if (t === "today")
1042
- e.textContent = i.today ?? "Today", n.today && e.setAttribute("aria-label", n.today), e.onclick = () => this.today();
1126
+ e.textContent = s.today ?? "Today", i.today && e.setAttribute("aria-label", i.today), e.onclick = () => this.today();
1043
1127
  else if (t === "prev")
1044
- e.textContent = i.prev ?? "‹", e.setAttribute("aria-label", n.prev ?? "Previous"), e.onclick = () => this.prev();
1128
+ e.textContent = s.prev ?? "‹", e.setAttribute("aria-label", i.prev ?? "Previous"), e.onclick = () => this.prev();
1045
1129
  else if (t === "next")
1046
- e.textContent = i.next ?? "›", e.setAttribute("aria-label", n.next ?? "Next"), e.onclick = () => this.next();
1130
+ e.textContent = s.next ?? "›", e.setAttribute("aria-label", i.next ?? "Next"), e.onclick = () => this.next();
1047
1131
  else {
1048
- const o = (s = this.options.buttons) == null ? void 0 : s[t];
1132
+ const o = (n = this.options.buttons) == null ? void 0 : n[t];
1049
1133
  if (o) {
1050
1134
  if (o.icon) {
1051
1135
  const r = document.createElement("span");
@@ -1062,22 +1146,22 @@ class Q {
1062
1146
  this.titleEl && (this.titleEl.textContent = ((t = this.viewImpl) == null ? void 0 : t.title()) ?? "");
1063
1147
  }
1064
1148
  emitDatesSet() {
1065
- var e, i, n;
1149
+ var e, s, i;
1066
1150
  const t = (e = this.viewImpl) == null ? void 0 : e.range();
1067
- t && ((n = (i = this.options).onDatesSet) == null || n.call(i, { start: t.start, end: t.end, view: this._view }));
1151
+ t && ((i = (s = this.options).onDatesSet) == null || i.call(s, { start: t.start, end: t.end, view: this._view }));
1068
1152
  }
1069
1153
  }
1070
1154
  export {
1071
- Q as Calendar,
1072
- _ as EventStore,
1073
- X as ResourceStore,
1074
- N as buildAxis,
1075
- f as dayMinutes,
1076
- L as intlFormat,
1077
- A as minutesToTime,
1078
- $ as nowTz,
1079
- I as packEvents,
1080
- R as timeToMinutes,
1155
+ it as Calendar,
1156
+ V as EventStore,
1157
+ W as ResourceStore,
1158
+ F as buildAxis,
1159
+ g as dayMinutes,
1160
+ A as intlFormat,
1161
+ I as minutesToTime,
1162
+ Y as nowTz,
1163
+ $ as packEvents,
1164
+ L as timeToMinutes,
1081
1165
  b as toTz
1082
1166
  };
1083
1167
  //# sourceMappingURL=ziix-calendar.js.map