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