@burdenoff/microfe-calendar 2026.1124.2 → 2026.1124.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generated/wspace-operations.d.ts +811 -69
- package/dist/generated/wspace-operations.js +173 -19
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +405 -6
- package/dist/pages/ResourcesPage.js.map +1 -1
- package/dist/translations/en.d.ts +250 -1
- package/dist/v2/CalendarPageV2.js +45 -41
- package/dist/v2/CalendarPageV2.js.map +1 -1
- package/dist/v2/CalendarRoutesV2.js +64 -64
- package/dist/v2/CalendarRoutesV2.js.map +1 -1
- package/dist/v2/data/enums.d.ts +1 -0
- package/dist/v2/data/enums.js +6 -2
- package/dist/v2/data/enums.js.map +1 -1
- package/dist/v2/data/errors.d.ts +5 -0
- package/dist/v2/data/errors.js +6 -2
- package/dist/v2/data/errors.js.map +1 -1
- package/dist/v2/data/normalize.d.ts +31 -3
- package/dist/v2/data/normalize.js +57 -13
- package/dist/v2/data/normalize.js.map +1 -1
- package/dist/v2/data/seriesDateLookup.d.ts +9 -0
- package/dist/v2/data/seriesDateLookup.js +12 -0
- package/dist/v2/data/seriesDateLookup.js.map +1 -0
- package/dist/v2/data/useEventActions.d.ts +9 -3
- package/dist/v2/data/useEventActions.js +239 -186
- package/dist/v2/data/useEventActions.js.map +1 -1
- package/dist/v2/data/useEventForPeek.js +63 -21
- package/dist/v2/data/useEventForPeek.js.map +1 -1
- package/dist/v2/data/useEventsInRangeV2.d.ts +40 -2
- package/dist/v2/data/useEventsInRangeV2.js +76 -47
- package/dist/v2/data/useEventsInRangeV2.js.map +1 -1
- package/dist/v2/day/DayPanel.js +1 -1
- package/dist/v2/day/DayPanel.js.map +1 -1
- package/dist/v2/dialogs/CalendarDialogsV2.js +12 -9
- package/dist/v2/dialogs/CalendarDialogsV2.js.map +1 -1
- package/dist/v2/event/CustomRepeat.d.ts +5 -0
- package/dist/v2/event/CustomRepeat.js +246 -0
- package/dist/v2/event/CustomRepeat.js.map +1 -0
- package/dist/v2/event/EventDetailsTab.d.ts +6 -0
- package/dist/v2/event/EventDetailsTab.js +291 -0
- package/dist/v2/event/EventDetailsTab.js.map +1 -0
- package/dist/v2/event/EventDialog.d.ts +35 -0
- package/dist/v2/event/EventDialog.js +388 -0
- package/dist/v2/event/EventDialog.js.map +1 -0
- package/dist/v2/event/EventDialogs.d.ts +3 -0
- package/dist/v2/event/EventDialogs.js +118 -0
- package/dist/v2/event/EventDialogs.js.map +1 -0
- package/dist/v2/event/EventMoreTab.d.ts +4 -0
- package/dist/v2/event/EventMoreTab.js +215 -0
- package/dist/v2/event/EventMoreTab.js.map +1 -0
- package/dist/v2/event/EventPeopleTab.d.ts +8 -0
- package/dist/v2/event/EventPeopleTab.js +422 -0
- package/dist/v2/event/EventPeopleTab.js.map +1 -0
- package/dist/v2/event/EventPlaceTab.d.ts +6 -0
- package/dist/v2/event/EventPlaceTab.js +264 -0
- package/dist/v2/event/EventPlaceTab.js.map +1 -0
- package/dist/v2/event/FindTimeDialog.d.ts +26 -0
- package/dist/v2/event/FindTimeDialog.js +667 -0
- package/dist/v2/event/FindTimeDialog.js.map +1 -0
- package/dist/v2/event/RepeatField.d.ts +5 -0
- package/dist/v2/event/RepeatField.js +91 -0
- package/dist/v2/event/RepeatField.js.map +1 -0
- package/dist/v2/event/dialogLogic.d.ts +97 -0
- package/dist/v2/event/dialogLogic.js +120 -0
- package/dist/v2/event/dialogLogic.js.map +1 -0
- package/dist/v2/event/dialogModel.d.ts +51 -0
- package/dist/v2/event/dialogModel.js +13 -0
- package/dist/v2/event/dialogModel.js.map +1 -0
- package/dist/v2/event/eventForm.d.ts +235 -0
- package/dist/v2/event/eventForm.js +450 -0
- package/dist/v2/event/eventForm.js.map +1 -0
- package/dist/v2/event/findTime.d.ts +120 -0
- package/dist/v2/event/findTime.js +149 -0
- package/dist/v2/event/findTime.js.map +1 -0
- package/dist/v2/event/findTimeSource.d.ts +102 -0
- package/dist/v2/event/findTimeSource.js +107 -0
- package/dist/v2/event/findTimeSource.js.map +1 -0
- package/dist/v2/event/parts.d.ts +46 -0
- package/dist/v2/event/parts.js +124 -0
- package/dist/v2/event/parts.js.map +1 -0
- package/dist/v2/event/place.d.ts +64 -0
- package/dist/v2/event/place.js +48 -0
- package/dist/v2/event/place.js.map +1 -0
- package/dist/v2/event/repeatWords.d.ts +19 -0
- package/dist/v2/event/repeatWords.js +130 -0
- package/dist/v2/event/repeatWords.js.map +1 -0
- package/dist/v2/event/rrule.d.ts +90 -0
- package/dist/v2/event/rrule.js +368 -0
- package/dist/v2/event/rrule.js.map +1 -0
- package/dist/v2/event/savePlan.d.ts +160 -0
- package/dist/v2/event/savePlan.js +219 -0
- package/dist/v2/event/savePlan.js.map +1 -0
- package/dist/v2/event/useEventData.d.ts +96 -0
- package/dist/v2/event/useEventData.js +229 -0
- package/dist/v2/event/useEventData.js.map +1 -0
- package/dist/v2/event/useEventDialogModel.d.ts +50 -0
- package/dist/v2/event/useEventDialogModel.js +144 -0
- package/dist/v2/event/useEventDialogModel.js.map +1 -0
- package/dist/v2/event/useEventSave.d.ts +57 -0
- package/dist/v2/event/useEventSave.js +276 -0
- package/dist/v2/event/useEventSave.js.map +1 -0
- package/dist/v2/events/eventLook.js +16 -16
- package/dist/v2/events/eventLook.js.map +1 -1
- package/dist/v2/events/eventModel.d.ts +17 -4
- package/dist/v2/events/eventModel.js +46 -34
- package/dist/v2/events/eventModel.js.map +1 -1
- package/dist/v2/events/localChanges.d.ts +4 -1
- package/dist/v2/events/localChanges.js +4 -2
- package/dist/v2/events/localChanges.js.map +1 -1
- package/dist/v2/format.d.ts +2 -0
- package/dist/v2/format.js +4 -0
- package/dist/v2/format.js.map +1 -1
- package/dist/v2/page/CalendarPageContext.d.ts +2 -2
- package/dist/v2/page/CalendarPageContext.js.map +1 -1
- package/dist/v2/page/useCalendarPageModel.js +141 -139
- package/dist/v2/page/useCalendarPageModel.js.map +1 -1
- package/dist/v2/page/viewState.d.ts +9 -1
- package/dist/v2/page/viewState.js +5 -3
- package/dist/v2/page/viewState.js.map +1 -1
- package/dist/v2/peek/EventPeek.js.map +1 -1
- package/dist/v2/peek/PeekEvent.js +210 -204
- package/dist/v2/peek/PeekEvent.js.map +1 -1
- package/dist/v2/rail/CalendarRail.js.map +1 -1
- package/dist/v2/rail/useMonthEventDates.js +1 -1
- package/dist/v2/rail/useMonthEventDates.js.map +1 -1
- package/dist/v2/runs/RunPeek.js.map +1 -1
- package/dist/v2/states/CalendarStates.d.ts +15 -0
- package/dist/v2/states/CalendarStates.js +42 -11
- package/dist/v2/states/CalendarStates.js.map +1 -1
- package/dist/v2/types.d.ts +32 -2
- package/package.json +1 -1
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { EVENT_TYPE_MEETING as e, SCOPE_ALL_EVENTS as t } from "../data/enums.js";
|
|
2
|
+
import { eventRoom as n, isSeriesDate as r, safeWebUrl as i } from "../events/eventModel.js";
|
|
3
|
+
import { eventDays as a } from "../time/calendarTime.js";
|
|
4
|
+
import { addressOf as o, detachedForm as s, endInstant as c, formFromEvent as l, locationIsRoomName as u, movedCancellations as d, rruleOf as f, sameTimes as p, seriesFormOf as m, startInstant as h, videoOf as g } from "./eventForm.js";
|
|
5
|
+
import { videoServiceOf as _ } from "./place.js";
|
|
6
|
+
// src/v2/event/savePlan.ts
|
|
7
|
+
function v(e) {
|
|
8
|
+
return e !== null && (e.releaseBookingIds.length > 0 || e.tags !== null || e.cancels.some((e) => e.dates.length > 0));
|
|
9
|
+
}
|
|
10
|
+
function y(e, t, n) {
|
|
11
|
+
let r = new Set(n.map((e) => e.getTime())), i = t.filter((e) => !r.has(e.getTime()) && (r.add(e.getTime()), !0));
|
|
12
|
+
return i.length > 0 ? [{
|
|
13
|
+
seriesId: e,
|
|
14
|
+
dates: i
|
|
15
|
+
}] : [];
|
|
16
|
+
}
|
|
17
|
+
function b(e, t) {
|
|
18
|
+
return (e?.cancels ?? []).filter((e) => e.seriesId === t).flatMap((e) => e.dates);
|
|
19
|
+
}
|
|
20
|
+
function x(e, t, n) {
|
|
21
|
+
return t ? {
|
|
22
|
+
...e,
|
|
23
|
+
releaseBookingIds: [.../* @__PURE__ */ new Set([...e.releaseBookingIds, ...t.releaseBookingIds])],
|
|
24
|
+
tags: e.tags ?? t.tags,
|
|
25
|
+
cancels: [...e.cancels, ...t.cancels.filter((e) => e.seriesId !== n)]
|
|
26
|
+
} : e;
|
|
27
|
+
}
|
|
28
|
+
function S(e) {
|
|
29
|
+
let t = e.roomId !== null && !e.allDay || e.address.trim() !== "", n = e.videoUrl.trim() !== "";
|
|
30
|
+
return t && n ? "HYBRID" : n ? "ONLINE" : t ? "PHYSICAL" : null;
|
|
31
|
+
}
|
|
32
|
+
function C(e) {
|
|
33
|
+
let t = e.videoUrl.trim();
|
|
34
|
+
return t === "" ? "" : i(t) ?? t;
|
|
35
|
+
}
|
|
36
|
+
function w(e) {
|
|
37
|
+
return e.allDay ? null : e.roomId;
|
|
38
|
+
}
|
|
39
|
+
function T(e) {
|
|
40
|
+
let t = e.trim();
|
|
41
|
+
return t === "" ? void 0 : t;
|
|
42
|
+
}
|
|
43
|
+
function E(t) {
|
|
44
|
+
let n = h(t), r = c(t), i = f(t), a = C(t), o = w(t), s = {
|
|
45
|
+
calendarId: t.calendarId ?? "",
|
|
46
|
+
title: t.title.trim(),
|
|
47
|
+
eventType: e,
|
|
48
|
+
startTime: n.toISOString(),
|
|
49
|
+
endTime: r.toISOString(),
|
|
50
|
+
allDay: t.allDay,
|
|
51
|
+
timezone: t.timeZone,
|
|
52
|
+
visibility: t.visibility
|
|
53
|
+
};
|
|
54
|
+
t.busy || (s.isBusy = !1), T(t.description) && (s.description = t.description), i && (s.isRecurring = !0, s.rrule = i);
|
|
55
|
+
let l = T(t.address);
|
|
56
|
+
l && (s.location = l), a && (s.onlineMeetingUrl = a, s.onlineMeetingProvider = _(a));
|
|
57
|
+
let u = S(t);
|
|
58
|
+
return u && (s.locationType = u), {
|
|
59
|
+
create: s,
|
|
60
|
+
updates: [],
|
|
61
|
+
addGuests: t.guests,
|
|
62
|
+
removeGuests: [],
|
|
63
|
+
cancelBookingId: null,
|
|
64
|
+
releaseBookingIds: [],
|
|
65
|
+
bookRoom: o ? {
|
|
66
|
+
resourceId: o,
|
|
67
|
+
start: n,
|
|
68
|
+
end: r
|
|
69
|
+
} : null,
|
|
70
|
+
addReminders: t.reminders,
|
|
71
|
+
removeReminders: [],
|
|
72
|
+
cancels: [],
|
|
73
|
+
tags: null
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function D(e, t, n) {
|
|
77
|
+
if (e.allDay !== t.allDay) return !0;
|
|
78
|
+
if (e.allDay) {
|
|
79
|
+
let r = a(t, n);
|
|
80
|
+
return r.start !== e.firstDay || r.end !== e.lastDay;
|
|
81
|
+
}
|
|
82
|
+
return h(e).getTime() !== t.start.getTime() || c(e).getTime() !== t.end.getTime();
|
|
83
|
+
}
|
|
84
|
+
function O(e, r, i) {
|
|
85
|
+
let a = l(r, i), s = {}, d = e.title.trim();
|
|
86
|
+
d !== r.title && (s.title = d), e.description !== (r.description ?? "") && (s.description = e.description);
|
|
87
|
+
let p = D(e, r, i);
|
|
88
|
+
p ? (s.startTime = h(e).toISOString(), s.endTime = c(e).toISOString(), s.allDay = e.allDay, s.timezone = e.timeZone) : !e.allDay && e.timeZone !== (r.timeZone ?? i) && (s.timezone = e.timeZone);
|
|
89
|
+
let m = f(e), v = r.isRecurring && m !== null && m !== f(a);
|
|
90
|
+
e.visibility !== r.visibility && (s.visibility = e.visibility), e.busy !== r.isBusy && (s.isBusy = e.busy);
|
|
91
|
+
let y = C(e), b = g(r), x = y !== b.url.trim();
|
|
92
|
+
x && (s.onlineMeetingUrl = y, y && (s.onlineMeetingProvider = _(y)), b.field === "locationUrl" && (s.locationUrl = ""));
|
|
93
|
+
let T = e.address.trim(), E = o(r), O = T !== E.text.trim();
|
|
94
|
+
O && (s[E.field] = T);
|
|
95
|
+
let A = w(e) !== w(a);
|
|
96
|
+
A && s.location === void 0 && u(r) && (s.location = "");
|
|
97
|
+
let j = S(e);
|
|
98
|
+
(x || O || A) && j !== r.locationType && (j !== null || r.locationType !== null) && (s.locationType = j ?? "TBD");
|
|
99
|
+
let M = r.isRecurring ? t : null, N = [];
|
|
100
|
+
v && m && p ? N.push({
|
|
101
|
+
input: s,
|
|
102
|
+
scope: M
|
|
103
|
+
}, {
|
|
104
|
+
input: { rrule: m },
|
|
105
|
+
scope: M
|
|
106
|
+
}) : (v && m && (s.rrule = m), Object.keys(s).length > 0 && N.push({
|
|
107
|
+
input: s,
|
|
108
|
+
scope: M
|
|
109
|
+
}));
|
|
110
|
+
let P = new Set(e.guests.map((e) => e.key)), F = new Set(a.guests.map((e) => e.key)), I = k(e.reminders, a.reminders), L = n(r), R = L && (L.status === "APPROVED" || L.status === "PENDING") ? L : null, z = w(e), B = h(e), V = c(e), H = R !== null && R.resourceId === z && R.start.getTime() === B.getTime() && R.end.getTime() === V.getTime(), U = R !== null && !H, W = z !== null && !H;
|
|
111
|
+
return {
|
|
112
|
+
create: null,
|
|
113
|
+
updates: N,
|
|
114
|
+
addGuests: e.guests.filter((e) => !F.has(e.key)),
|
|
115
|
+
removeGuests: a.guests.filter((e) => !P.has(e.key)),
|
|
116
|
+
cancelBookingId: U ? R.id : null,
|
|
117
|
+
releaseBookingIds: [],
|
|
118
|
+
bookRoom: W ? {
|
|
119
|
+
resourceId: z,
|
|
120
|
+
start: B,
|
|
121
|
+
end: V
|
|
122
|
+
} : null,
|
|
123
|
+
addReminders: I.add,
|
|
124
|
+
removeReminders: I.remove,
|
|
125
|
+
cancels: [],
|
|
126
|
+
tags: null
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function k(e, t) {
|
|
130
|
+
let n = new Set(e.map((e) => e.reminderId).filter(Boolean)), r = t.filter((e) => e.reminderId !== null && !n.has(e.reminderId)), i = [];
|
|
131
|
+
for (let t of e) {
|
|
132
|
+
if (t.reminderId !== null) continue;
|
|
133
|
+
let e = r.findIndex((e) => e.minutesBefore === t.minutesBefore && e.channel === t.channel);
|
|
134
|
+
e >= 0 ? r.splice(e, 1) : i.push(t);
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
add: i,
|
|
138
|
+
remove: r
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function A(e) {
|
|
142
|
+
return e !== null && /(^|[;:\s])COUNT=\d/i.test(e);
|
|
143
|
+
}
|
|
144
|
+
function j(e, t) {
|
|
145
|
+
return e.instanceDate !== null && e.instanceDate.getTime() === t.start.getTime();
|
|
146
|
+
}
|
|
147
|
+
function M(e, t) {
|
|
148
|
+
return j(e, t) || !A(t.rrule);
|
|
149
|
+
}
|
|
150
|
+
function N(e, t, n) {
|
|
151
|
+
let r = {
|
|
152
|
+
seriesId: t.seriesId ?? n.eventId,
|
|
153
|
+
instanceDate: (t.instanceDate ?? t.start).toISOString(),
|
|
154
|
+
title: e.title.trim(),
|
|
155
|
+
description: e.description,
|
|
156
|
+
startTime: h(e).toISOString(),
|
|
157
|
+
endTime: c(e).toISOString()
|
|
158
|
+
};
|
|
159
|
+
return n.metadata && (r.metadata = n.metadata), r;
|
|
160
|
+
}
|
|
161
|
+
function P(e, t, n) {
|
|
162
|
+
let r = m(e.form, e.initial, t, n), i = O(r, t, n), a = l(t, n), o = b(e.carry, t.eventId), s = [];
|
|
163
|
+
return f(r) === f(a) && (s = p(r, a) ? o : d([...t.cancelledDates, ...o], a, r)), {
|
|
164
|
+
kind: "edit",
|
|
165
|
+
eventId: t.eventId,
|
|
166
|
+
plan: x({
|
|
167
|
+
...i,
|
|
168
|
+
cancels: y(t.eventId, s, t.cancelledDates)
|
|
169
|
+
}, e.carry, t.eventId)
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function F(e, t) {
|
|
173
|
+
let { form: n, event: i, row: a } = e;
|
|
174
|
+
if (!i || !a) return {
|
|
175
|
+
kind: "create",
|
|
176
|
+
plan: E(n)
|
|
177
|
+
};
|
|
178
|
+
if (!r(i)) return i.isRecurring ? P(e, a, t) : {
|
|
179
|
+
kind: "edit",
|
|
180
|
+
eventId: i.eventId,
|
|
181
|
+
plan: x(O(n, i, t), e.carry, null)
|
|
182
|
+
};
|
|
183
|
+
let o = e.scope === "later" && j(i, a) ? "all" : e.scope;
|
|
184
|
+
return o === "all" ? P(e, a, t) : o === "this" ? {
|
|
185
|
+
kind: "thisDate",
|
|
186
|
+
input: N(n, i, a),
|
|
187
|
+
form: s(n)
|
|
188
|
+
} : {
|
|
189
|
+
kind: "split",
|
|
190
|
+
seriesId: i.seriesId ?? a.eventId,
|
|
191
|
+
input: {
|
|
192
|
+
startTime: i.start.toISOString(),
|
|
193
|
+
endTime: i.end.toISOString()
|
|
194
|
+
},
|
|
195
|
+
form: s(n)
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function I(e, r, i, a, o, s, c = null) {
|
|
199
|
+
let u = f(e) === f(r), p = O(u ? {
|
|
200
|
+
...e,
|
|
201
|
+
repeat: l(i, s).repeat
|
|
202
|
+
} : e, i, s), m = n(a), h = m && (m.status === "APPROVED" || m.status === "PENDING") ? m.id : null, g = b(c, o.eventId), _ = i.isRecurring ? a.instanceDate : null, v = _ && u ? d([...o.cancelledDates, ...g], r, e, _) : [], S = _ ? g.filter((e) => e.getTime() < _.getTime()) : g, C = i.isRecurring ? t : null;
|
|
203
|
+
return x({
|
|
204
|
+
...p,
|
|
205
|
+
releaseBookingIds: h ? [h] : [],
|
|
206
|
+
cancels: [...y(i.eventId, v, i.cancelledDates), ...y(o.eventId, S, o.cancelledDates)],
|
|
207
|
+
tags: i.tags.length === 0 && o.tags.length > 0 ? {
|
|
208
|
+
eventId: i.eventId,
|
|
209
|
+
input: { tags: o.tags },
|
|
210
|
+
scope: C
|
|
211
|
+
} : null
|
|
212
|
+
}, c, o.eventId);
|
|
213
|
+
}
|
|
214
|
+
function L(e) {
|
|
215
|
+
return e.create === null && e.updates.length === 0 && e.addGuests.length === 0 && e.removeGuests.length === 0 && e.cancelBookingId === null && e.releaseBookingIds.length === 0 && e.bookRoom === null && e.addReminders.length === 0 && e.removeReminders.length === 0 && e.cancels.length === 0 && e.tags === null;
|
|
216
|
+
}
|
|
217
|
+
export { M as canChangeLater, v as carriesWork, A as endsAfterCount, L as isEmptyPlan, j as isFirstDate, O as planEdit, E as planNewEvent, I as planOnNewEvent, F as saveRouteFor, D as timesChanged };
|
|
218
|
+
|
|
219
|
+
//# sourceMappingURL=savePlan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"savePlan.js","names":["carriesWork","carry","item","cancelsOn","seen","cancelled","date","fresh","dates","carriedDates","seriesId","withCarry","plan","planned","locationTypeOf","place","form","video","videoLinkOf","typed","safeWebUrl","roomOf","trimmedOrUndefined","value","text","planNewEvent","start","startInstant","end","endInstant","rrule","rruleOf","room","create","EVENT_TYPE_MEETING","address","videoServiceOf","locationType","timesChanged","event","days","eventDays","calendarTimeZone","planEdit","before","formFromEvent","input","title","moved","ruleChanged","storedVideo","videoOf","videoChanged","storedAddress","addressOf","addressChanged","roomChanged","locationIsRoomName","updateScope","SCOPE_ALL_EVENTS","updates","formKeys","guest","keptKeys","reminders","reminderChanges","booking","eventRoom","active","holds","roomMoves","bookNew","kept","wanted","reminder","free","stored","add","same","endsAfterCount","isFirstDate","row","canChangeLater","modifyInputOf","wholeSeriesRoute","seriesForm","seriesFormOf","facts","own","pending","sameTimes","movedCancellations","saveRouteFor","isSeriesDate","scope","detachedForm","planOnNewEvent","repeatKept","initial","made","held","seriesBooking","from","splitDates","stay","day","isEmptyPlan"],"sources":["../../../src/v2/event/savePlan.ts"],"sourcesContent":["/**\n * What saving the event dialog sends (BOFF-15698 A2, A4), worked out from the form and, for an\n * edit, the event as the service last returned it. Pure.\n *\n * - A new event: `createEvent` with what it takes, then its guests, its room and its reminders,\n * which the service adds one at a time.\n * - An edit sends only what changed, so what the dialog doesn't show (tags, check-in, other\n * apps' fields) is never written over, and a save after a partial failure sends only the rest.\n * - Clearing a field sends an empty string: the service reads a null as \"unchanged\".\n * - A room follows the event: when its booking isn't for the room and the time the form asks\n * for (the time or the room changed, or an earlier save couldn't take the room along), the old\n * booking is cancelled and the room booked again, so the service checks it is free then\n * (changing a booking's times doesn't check). An all-day event holds no room.\n * - A series is changed as a whole on its first date (`ALL_EVENTS`). When its start moves, the\n * service rewrites its rule from the old one, so a new rule with a new start goes in a second\n * update after the first.\n * - Editing one date of a series, the footer asks which events change (`saveRouteFor`, A4):\n * that date on its own, that date and the later ones, or every event.\n * - What a save that stopped part way left undone and the event read back can't show (a\n * series' booking still to let go, tags still to give, dates still to cancel) comes back as a\n * `SaveCarry`, and the next plan sends it with the rest.\n */\nimport type {\n CreateEventInput,\n ModifyRecurringInstanceInput,\n UpdateEventInput,\n UpdateScope,\n} from '../../generated/wspace-types';\nimport { EVENT_TYPE_MEETING, SCOPE_ALL_EVENTS } from '../data/enums';\nimport { eventRoom, isSeriesDate, safeWebUrl } from '../events/eventModel';\nimport { eventDays } from '../time/calendarTime';\nimport type { CalendarEventV2 } from '../types';\nimport {\n addressOf,\n detachedForm,\n endInstant,\n formFromEvent,\n locationIsRoomName,\n movedCancellations,\n rruleOf,\n sameTimes,\n seriesFormOf,\n startInstant,\n videoOf,\n type EventForm,\n type GuestDraft,\n type ReminderDraft,\n} from './eventForm';\nimport { videoServiceOf } from './place';\n\n/**\n * The footer's question when a date of a repeating event is edited (A4): that date on its own,\n * that date and the later ones, or every event in the series.\n */\nexport type ScopeChoice = 'this' | 'later' | 'all';\n\nexport interface RoomBookingPlan {\n resourceId: string;\n start: Date;\n end: Date;\n}\n\n/**\n * Dates to cancel on a series (`cancelRecurringInstance`, A4), as instants of the series as it\n * stands. The service adds each to the series' list on its own, so they go one after another.\n */\nexport interface SeriesCancels {\n seriesId: string;\n dates: Date[];\n}\n\n/** An event's tags, given on their own (`updateEvent`), so one that fails is known. */\nexport interface TagsWrite {\n eventId: string;\n input: UpdateEventInput;\n scope: UpdateScope | null;\n}\n\n/**\n * What a save that stopped part way left undone and the event read back can't show, so a plan\n * made from it again wouldn't send it (A4): the booking a series held for a date made an event\n * of its own (still holding the room), the tags of the series such an event comes without, and a\n * series' dates still to cancel. The dialog keeps it, and the next save sends it with the rest.\n */\nexport interface SaveCarry {\n releaseBookingIds: string[];\n tags: TagsWrite | null;\n cancels: SeriesCancels[];\n}\n\n/** Whether the carry holds anything still to send. */\nexport function carriesWork(carry: SaveCarry | null): boolean {\n return (\n carry !== null &&\n (carry.releaseBookingIds.length > 0 ||\n carry.tags !== null ||\n carry.cancels.some((item) => item.dates.length > 0))\n );\n}\n\n/** `dates` to cancel on `seriesId`, each once and none it has cancelled already. */\nfunction cancelsOn(\n seriesId: string,\n dates: readonly Date[],\n cancelled: readonly Date[]\n): SeriesCancels[] {\n const seen = new Set(cancelled.map((date) => date.getTime()));\n const fresh = dates.filter((date) => {\n if (seen.has(date.getTime())) return false;\n seen.add(date.getTime());\n return true;\n });\n return fresh.length > 0 ? [{ seriesId, dates: fresh }] : [];\n}\n\n/** The dates a carry still has to cancel on `seriesId`. */\nfunction carriedDates(carry: SaveCarry | null, seriesId: string): Date[] {\n return (carry?.cancels ?? [])\n .filter((item) => item.seriesId === seriesId)\n .flatMap((item) => item.dates);\n}\n\n/**\n * The plan with a carry's work added: its bookings to let go and its tags, and its dates on\n * series other than `planned` (whose dates the plan already took in, moving them as it moves\n * the series).\n */\nfunction withCarry(plan: SavePlan, carry: SaveCarry | null, planned: string | null): SavePlan {\n if (!carry) return plan;\n return {\n ...plan,\n releaseBookingIds: [...new Set([...plan.releaseBookingIds, ...carry.releaseBookingIds])],\n tags: plan.tags ?? carry.tags,\n cancels: [...plan.cancels, ...carry.cancels.filter((item) => item.seriesId !== planned)],\n };\n}\n\nexport interface SavePlan {\n /** A new event: what `createEvent` takes. */\n create: CreateEventInput | null;\n /** An edit: the `updateEvent` calls, in order; none when the event itself didn't change. */\n updates: { input: UpdateEventInput; scope: UpdateScope | null }[];\n addGuests: GuestDraft[];\n /** Guests the event has that the form doesn't (each with its `attendeeId`). */\n removeGuests: GuestDraft[];\n /** The booking to cancel first: the room changed, or the event's time did. */\n cancelBookingId: string | null;\n /**\n * Bookings a series held for the date made an event of its own (A4): let go before the room\n * is booked for that event, else the room would be held twice for the same time.\n */\n releaseBookingIds: string[];\n bookRoom: RoomBookingPlan | null;\n addReminders: ReminderDraft[];\n /** Reminders the event has that the form doesn't (each with its `reminderId`). */\n removeReminders: ReminderDraft[];\n /**\n * Series' dates to cancel (A4): a series' cancelled dates where they land after its times\n * moved, or on the new series a split starts, which comes without them; and those a save\n * before couldn't cancel.\n */\n cancels: SeriesCancels[];\n /** The tags of the series an event was made from, which it comes without (A4). */\n tags: TagsWrite | null;\n}\n\n/** Where the event is: a room or an address, a video call, both, or nothing decided. */\nfunction locationTypeOf(form: EventForm): 'PHYSICAL' | 'ONLINE' | 'HYBRID' | null {\n const place = (form.roomId !== null && !form.allDay) || form.address.trim() !== '';\n const video = form.videoUrl.trim() !== '';\n if (place && video) return 'HYBRID';\n if (video) return 'ONLINE';\n return place ? 'PHYSICAL' : null;\n}\n\n/** The link to store: as the browser reads it (https added when it had no scheme). */\nfunction videoLinkOf(form: EventForm): string {\n const typed = form.videoUrl.trim();\n return typed === '' ? '' : (safeWebUrl(typed) ?? typed);\n}\n\n/** The room the form books: none for an all-day event. */\nfunction roomOf(form: EventForm): string | null {\n return form.allDay ? null : form.roomId;\n}\n\nfunction trimmedOrUndefined(text: string): string | undefined {\n const value = text.trim();\n return value === '' ? undefined : value;\n}\n\n/** A new event's plan: always with what `createEvent` takes. */\nexport type NewEventPlan = SavePlan & { create: CreateEventInput };\n\n/** A new event's plan. The form must have a calendar (the dialog checks). */\nexport function planNewEvent(form: EventForm): NewEventPlan {\n const start = startInstant(form);\n const end = endInstant(form);\n const rrule = rruleOf(form);\n const video = videoLinkOf(form);\n const room = roomOf(form);\n const create: CreateEventInput = {\n calendarId: form.calendarId ?? '',\n title: form.title.trim(),\n eventType: EVENT_TYPE_MEETING,\n startTime: start.toISOString(),\n endTime: end.toISOString(),\n allDay: form.allDay,\n timezone: form.timeZone,\n visibility: form.visibility,\n };\n // Busy is the service's default: only \"free\" is sent.\n if (!form.busy) create.isBusy = false;\n const description = trimmedOrUndefined(form.description);\n if (description) create.description = form.description;\n if (rrule) {\n create.isRecurring = true;\n create.rrule = rrule;\n }\n const address = trimmedOrUndefined(form.address);\n if (address) create.location = address;\n if (video) {\n create.onlineMeetingUrl = video;\n create.onlineMeetingProvider = videoServiceOf(video);\n }\n const locationType = locationTypeOf(form);\n if (locationType) create.locationType = locationType;\n return {\n create,\n updates: [],\n addGuests: form.guests,\n removeGuests: [],\n cancelBookingId: null,\n releaseBookingIds: [],\n bookRoom: room ? { resourceId: room, start, end } : null,\n addReminders: form.reminders,\n removeReminders: [],\n cancels: [],\n tags: null,\n };\n}\n\n/** The event's times differ from the form's: a day for an all-day event, else the instants. */\nexport function timesChanged(\n form: EventForm,\n event: CalendarEventV2,\n calendarTimeZone: string\n): boolean {\n if (form.allDay !== event.allDay) return true;\n if (form.allDay) {\n const days = eventDays(event, calendarTimeZone);\n return days.start !== form.firstDay || days.end !== form.lastDay;\n }\n return (\n startInstant(form).getTime() !== event.start.getTime() ||\n endInstant(form).getTime() !== event.end.getTime()\n );\n}\n\n/**\n * An edit's plan: what differs between the form and the event as the service last returned it.\n * A series (on its first date) changes as a whole (`ALL_EVENTS`).\n */\nexport function planEdit(\n form: EventForm,\n event: CalendarEventV2,\n calendarTimeZone: string\n): SavePlan {\n const before = formFromEvent(event, calendarTimeZone);\n const input: UpdateEventInput = {};\n const title = form.title.trim();\n if (title !== event.title) input.title = title;\n if (form.description !== (event.description ?? '')) input.description = form.description;\n\n const moved = timesChanged(form, event, calendarTimeZone);\n if (moved) {\n input.startTime = startInstant(form).toISOString();\n input.endTime = endInstant(form).toISOString();\n input.allDay = form.allDay;\n input.timezone = form.timeZone;\n } else if (!form.allDay && form.timeZone !== (event.timeZone ?? calendarTimeZone)) {\n input.timezone = form.timeZone;\n }\n\n const rrule = rruleOf(form);\n const ruleChanged = event.isRecurring && rrule !== null && rrule !== rruleOf(before);\n if (form.visibility !== event.visibility) input.visibility = form.visibility;\n if (form.busy !== event.isBusy) input.isBusy = form.busy;\n\n const video = videoLinkOf(form);\n const storedVideo = videoOf(event);\n const videoChanged = video !== storedVideo.url.trim();\n if (videoChanged) {\n input.onlineMeetingUrl = video;\n if (video) input.onlineMeetingProvider = videoServiceOf(video);\n // Today's form kept an online event's link in the location link: it moves to the meeting's.\n if (storedVideo.field === 'locationUrl') input.locationUrl = '';\n }\n const address = form.address.trim();\n const storedAddress = addressOf(event);\n const addressChanged = address !== storedAddress.text.trim();\n if (addressChanged) input[storedAddress.field] = address;\n // Where it is follows the place fields, and only when one of them changed: an event's stored\n // kind of place isn't rewritten by an edit that didn't touch them.\n const roomChanged = roomOf(form) !== roomOf(before);\n // A location that was only the room's name goes with the room (views would show it as an\n // address once the booking is gone).\n if (roomChanged && input.location === undefined && locationIsRoomName(event)) input.location = '';\n const locationType = locationTypeOf(form);\n if (\n (videoChanged || addressChanged || roomChanged) &&\n locationType !== event.locationType &&\n (locationType !== null || event.locationType !== null)\n ) {\n input.locationType = locationType ?? 'TBD';\n }\n\n const updateScope: UpdateScope | null = event.isRecurring ? SCOPE_ALL_EVENTS : null;\n const updates: SavePlan['updates'] = [];\n if (ruleChanged && rrule && moved) {\n // The service would write the old rule over a new one that comes with a new start.\n updates.push({ input, scope: updateScope }, { input: { rrule }, scope: updateScope });\n } else {\n if (ruleChanged && rrule) input.rrule = rrule;\n if (Object.keys(input).length > 0) updates.push({ input, scope: updateScope });\n }\n\n const formKeys = new Set(form.guests.map((guest) => guest.key));\n const keptKeys = new Set(before.guests.map((guest) => guest.key));\n const reminders = reminderChanges(form.reminders, before.reminders);\n\n const booking = eventRoom(event);\n const active =\n booking && (booking.status === 'APPROVED' || booking.status === 'PENDING') ? booking : null;\n const room = roomOf(form);\n const start = startInstant(form);\n const end = endInstant(form);\n // The booking is right when it holds the room asked for at the form's time. One at another\n // time (the event moved, or an earlier save moved it but couldn't take the room along) is let\n // go and booked again, as is one for another room.\n const holds =\n active !== null &&\n active.resourceId === room &&\n active.start.getTime() === start.getTime() &&\n active.end.getTime() === end.getTime();\n const roomMoves = active !== null && !holds;\n const bookNew = room !== null && !holds;\n\n return {\n create: null,\n updates,\n addGuests: form.guests.filter((guest) => !keptKeys.has(guest.key)),\n removeGuests: before.guests.filter((guest) => !formKeys.has(guest.key)),\n cancelBookingId: roomMoves ? active.id : null,\n releaseBookingIds: [],\n bookRoom: bookNew ? { resourceId: room, start, end } : null,\n addReminders: reminders.add,\n removeReminders: reminders.remove,\n cancels: [],\n tags: null,\n };\n}\n\n/**\n * Reminders to add and remove. A new one at the same time and on the same channel as one the\n * event has is that one: after a save that stopped part way, the reminders that did save are\n * the event's now, and saving again must not add them twice.\n */\nfunction reminderChanges(\n wanted: readonly ReminderDraft[],\n stored: readonly ReminderDraft[]\n): { add: ReminderDraft[]; remove: ReminderDraft[] } {\n const kept = new Set(wanted.map((reminder) => reminder.reminderId).filter(Boolean));\n const free = stored.filter(\n (reminder) => reminder.reminderId !== null && !kept.has(reminder.reminderId)\n );\n const add: ReminderDraft[] = [];\n for (const reminder of wanted) {\n if (reminder.reminderId !== null) continue;\n const same = free.findIndex(\n (item) => item.minutesBefore === reminder.minutesBefore && item.channel === reminder.channel\n );\n if (same >= 0) free.splice(same, 1);\n else add.push(reminder);\n }\n return { add, remove: free };\n}\n\n// ── Dates of a series (A4) ───────────────────────────────────────────────────\n\n/** How a save goes: what is written first, and what the rest is planned on. */\nexport type SaveRoute =\n /** A new event: `createEvent`, then its guests, reminders and room. */\n | { kind: 'create'; plan: NewEventPlan }\n /** An event changed in place: one that doesn't repeat, or a whole series on its first date. */\n | { kind: 'edit'; eventId: string; plan: SavePlan }\n /**\n * One date of a series changed on its own (\"This event\"): the service makes it an event of\n * its own (`modifyRecurringInstance`), and the rest is planned on that (`planOnNewEvent`).\n */\n | { kind: 'thisDate'; input: ModifyRecurringInstanceInput; form: EventForm }\n /**\n * That date and the later ones (\"This and later\"): the series is split at the date's original\n * start (`updateEvent` with THIS_AND_FUTURE ends the series before it and starts a new one\n * there), and the rest is planned on the new series (`planOnNewEvent`). Splitting at the date\n * itself, not at its new time, keeps the date from staying behind in the old series.\n */\n | { kind: 'split'; seriesId: string; input: UpdateEventInput; form: EventForm };\n\nexport interface SaveFacts {\n form: EventForm;\n /** The form as the dialog opened: for a series' date, at that date. */\n initial: EventForm;\n /** The event as the dialog shows it (a series' date at that date); null for a new one. */\n event: CalendarEventV2 | null;\n /** The stored event behind it: for a series' date, the series at its first date. */\n row: CalendarEventV2 | null;\n scope: ScopeChoice;\n /** What a save before left undone (`SaveCarry`); null when nothing. */\n carry: SaveCarry | null;\n}\n\n/** A rule that ends after a number of times (the service's split would start the count again). */\nexport function endsAfterCount(rrule: string | null): boolean {\n return rrule !== null && /(^|[;:\\s])COUNT=\\d/i.test(rrule);\n}\n\n/** Whether a series' date is its first one (where \"this and later\" is every event). */\nexport function isFirstDate(event: CalendarEventV2, row: CalendarEventV2): boolean {\n return event.instanceDate !== null && event.instanceDate.getTime() === row.start.getTime();\n}\n\n/**\n * Whether \"This and later\" can be offered for a series' date: always on its first date (where\n * it is every event); elsewhere not for a rule that ends after a number of times, which the\n * service's split would count again from the date, making the series longer.\n */\nexport function canChangeLater(event: CalendarEventV2, row: CalendarEventV2): boolean {\n return isFirstDate(event, row) || !endsAfterCount(row.rrule);\n}\n\n/** What `modifyRecurringInstance` takes for a date changed on its own: the date and its times. */\nfunction modifyInputOf(\n form: EventForm,\n event: CalendarEventV2,\n row: CalendarEventV2\n): ModifyRecurringInstanceInput {\n const input: ModifyRecurringInstanceInput = {\n seriesId: event.seriesId ?? row.eventId,\n instanceDate: (event.instanceDate ?? event.start).toISOString(),\n title: form.title.trim(),\n description: form.description,\n startTime: startInstant(form).toISOString(),\n endTime: endInstant(form).toISOString(),\n };\n // Other apps' fields on the series stay with the date (the service keeps its own keys).\n if (row.metadata) input.metadata = row.metadata;\n return input;\n}\n\n/**\n * A change to every event of a series, on the series' own first date: what the person changed\n * at the date they edited moves the series the same way, and its cancelled dates move with it\n * (unless its repeat changed too: they may not be dates of the new rule). Dates a save before\n * couldn't cancel are cancelled with them, where its times put them.\n */\nfunction wholeSeriesRoute(\n facts: SaveFacts,\n row: CalendarEventV2,\n calendarTimeZone: string\n): SaveRoute {\n const seriesForm = seriesFormOf(facts.form, facts.initial, row, calendarTimeZone);\n const plan = planEdit(seriesForm, row, calendarTimeZone);\n const own = formFromEvent(row, calendarTimeZone);\n const pending = carriedDates(facts.carry, row.eventId);\n let dates: Date[] = [];\n if (rruleOf(seriesForm) === rruleOf(own)) {\n dates = sameTimes(seriesForm, own)\n ? pending\n : movedCancellations([...row.cancelledDates, ...pending], own, seriesForm);\n }\n return {\n kind: 'edit',\n eventId: row.eventId,\n plan: withCarry(\n { ...plan, cancels: cancelsOn(row.eventId, dates, row.cancelledDates) },\n facts.carry,\n row.eventId\n ),\n };\n}\n\n/** How saving the dialog goes, by what is edited and the footer's answer. */\nexport function saveRouteFor(facts: SaveFacts, calendarTimeZone: string): SaveRoute {\n const { form, event, row } = facts;\n if (!event || !row) return { kind: 'create', plan: planNewEvent(form) };\n if (!isSeriesDate(event)) {\n // A series with no date to name (its first date was cancelled) changes as a whole.\n if (event.isRecurring) return wholeSeriesRoute(facts, row, calendarTimeZone);\n return {\n kind: 'edit',\n eventId: event.eventId,\n plan: withCarry(planEdit(form, event, calendarTimeZone), facts.carry, null),\n };\n }\n // From the first date, \"this and later\" is every event (a split there would leave the old\n // series empty).\n const scope = facts.scope === 'later' && isFirstDate(event, row) ? 'all' : facts.scope;\n if (scope === 'all') return wholeSeriesRoute(facts, row, calendarTimeZone);\n if (scope === 'this') {\n return { kind: 'thisDate', input: modifyInputOf(form, event, row), form: detachedForm(form) };\n }\n return {\n kind: 'split',\n seriesId: event.seriesId ?? row.eventId,\n input: { startTime: event.start.toISOString(), endTime: event.end.toISOString() },\n form: detachedForm(form),\n };\n}\n\n/**\n * The rest of a save, on the event the service just made from a series (`made`: a date changed\n * on its own, or the later part of a split): what the form holds that it doesn't yet.\n *\n * - Its guests, reminders and room are added to it (the form is `detachedForm`).\n * - A room the series had booked for that date (`date`, the date as the dialog showed it) is let\n * go before the made event books it again, so the room isn't held twice (the made event's own\n * booking would clash with the series' for the same time).\n * - Its repeat is sent only when the person changed it: a split series keeps the service's rule,\n * with its new start.\n * - A date made its own event gets the series' tags back (`modifyRecurringInstance` leaves them\n * behind), in a write of their own.\n * - A split series gets the old one's cancelled dates from the split on (`cancels`), with those\n * a save before couldn't cancel there (`carry`); the old series keeps the ones before it.\n */\nexport function planOnNewEvent(\n form: EventForm,\n initial: EventForm,\n made: CalendarEventV2,\n date: CalendarEventV2,\n row: CalendarEventV2,\n calendarTimeZone: string,\n carry: SaveCarry | null = null\n): SavePlan {\n const repeatKept = rruleOf(form) === rruleOf(initial);\n const base = repeatKept\n ? { ...form, repeat: formFromEvent(made, calendarTimeZone).repeat }\n : form;\n const plan = planEdit(base, made, calendarTimeZone);\n const held = eventRoom(date);\n const seriesBooking =\n held && (held.status === 'APPROVED' || held.status === 'PENDING') ? held.id : null;\n // A split series comes without the old one's cancelled dates from the split on: they are\n // cancelled on it again, where its new times put them (not when its repeat changed). Dates a\n // save before couldn't cancel on the old series go the same way; those before the split (all\n // of them, for a date made its own event) stay the old series' to cancel.\n const pending = carriedDates(carry, row.eventId);\n // Where a split series starts; null for a date made its own event.\n const from = made.isRecurring ? date.instanceDate : null;\n const splitDates =\n from && repeatKept\n ? movedCancellations([...row.cancelledDates, ...pending], initial, form, from)\n : [];\n const stay = from ? pending.filter((day) => day.getTime() < from.getTime()) : pending;\n const scope: UpdateScope | null = made.isRecurring ? SCOPE_ALL_EVENTS : null;\n return withCarry(\n {\n ...plan,\n releaseBookingIds: seriesBooking ? [seriesBooking] : [],\n cancels: [\n ...cancelsOn(made.eventId, splitDates, made.cancelledDates),\n ...cancelsOn(row.eventId, stay, row.cancelledDates),\n ],\n tags:\n made.tags.length === 0 && row.tags.length > 0\n ? { eventId: made.eventId, input: { tags: row.tags }, scope }\n : null,\n },\n carry,\n row.eventId\n );\n}\n\n/** Nothing to send. */\nexport function isEmptyPlan(plan: SavePlan): boolean {\n return (\n plan.create === null &&\n plan.updates.length === 0 &&\n plan.addGuests.length === 0 &&\n plan.removeGuests.length === 0 &&\n plan.cancelBookingId === null &&\n plan.releaseBookingIds.length === 0 &&\n plan.bookRoom === null &&\n plan.addReminders.length === 0 &&\n plan.removeReminders.length === 0 &&\n plan.cancels.length === 0 &&\n plan.tags === null\n );\n}\n"],"mappings":";;;;;;AA2FA,SAAgBA,EAAY,GAAkC;CAC5D,OACEC,MAAU,SACTA,EAAM,kBAAkB,SAAS,KAChCA,EAAM,SAAS,QACfA,EAAM,QAAQ,MAAM,MAASC,EAAK,MAAM,SAAS,CAAC;AAExD;AAGA,SAASC,EACP,GACA,GACA,GACiB;CACjB,IAAMC,IAAO,IAAI,IAAIC,EAAU,KAAK,MAASC,EAAK,QAAQ,CAAC,CAAC,GACtDC,IAAQC,EAAM,QAAQ,MAC1B,CAAIJ,EAAK,IAAIE,EAAK,QAAQ,CAAC,MAC3BF,EAAK,IAAIE,EAAK,QAAQ,CAAC,GAChB,GACR;CACD,OAAOC,EAAM,SAAS,IAAI,CAAC;EAAE;EAAU,OAAOA;CAAM,CAAC,IAAI,CAAC;AAC5D;AAGA,SAASE,EAAa,GAAyB,GAA0B;CACvE,QAAQR,GAAO,WAAW,CAAC,EAAA,CACxB,QAAQ,MAASC,EAAK,aAAaQ,CAAQ,CAAC,CAC5C,SAAS,MAASR,EAAK,KAAK;AACjC;AAOA,SAASS,EAAU,GAAgB,GAAyB,GAAkC;CAE5F,OADKV,IACE;EACL,GAAGW;EACH,mBAAmB,CAAC,mBAAG,IAAI,IAAI,CAAC,GA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AAW,KAClCA,EAAK,aAAa,QAClBA,EAAK,aAAa,WAAW,KAC7BA,EAAK,gBAAgB,WAAW,KAChCA,EAAK,QAAQ,WAAW,KACxBA,EAAK,SAAS;AAElB"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { useApolloClient } from '@apollo/client/react';
|
|
2
|
+
import { CalendarV2EventRoomsQuery } from '../../generated/wspace-operations';
|
|
3
|
+
import { CalendarEventV2 } from '../types';
|
|
4
|
+
import { RoomForEvent } from './place';
|
|
5
|
+
type Client = ReturnType<typeof useApolloClient>;
|
|
6
|
+
type LoadStatus = 'idle' | 'loading' | 'ready' | 'error';
|
|
7
|
+
export type EditedEvent = {
|
|
8
|
+
status: 'none';
|
|
9
|
+
} | {
|
|
10
|
+
status: 'loading';
|
|
11
|
+
} | {
|
|
12
|
+
status: 'missing';
|
|
13
|
+
} | {
|
|
14
|
+
status: 'error';
|
|
15
|
+
error: Error;
|
|
16
|
+
retry: () => void;
|
|
17
|
+
} | {
|
|
18
|
+
status: 'ready';
|
|
19
|
+
/** The event as the dialog edits it: a series' date at that date (A4). */
|
|
20
|
+
event: CalendarEventV2;
|
|
21
|
+
/** The stored event behind it: for a series' date, the series at its first date. */
|
|
22
|
+
row: CalendarEventV2;
|
|
23
|
+
retry: () => void;
|
|
24
|
+
/**
|
|
25
|
+
* After a write the event is read again: until then (or when that fails) `event` is the
|
|
26
|
+
* one read before, fine to show but not to plan a save on.
|
|
27
|
+
*/
|
|
28
|
+
refresh: 'current' | 'loading' | 'failed';
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* The event as the service has it now (never the view's copy, which may carry a move the
|
|
32
|
+
* service hasn't confirmed), read again after every write. With `instanceDate`, a series is
|
|
33
|
+
* edited at that date of it (A4), as the calendar has the date now: a date cancelled or moved
|
|
34
|
+
* since the dialog opened is `missing`, never edited as if it were still there.
|
|
35
|
+
*/
|
|
36
|
+
export declare function useEditedEvent(eventId: string | null, instanceDate?: Date | null): EditedEvent;
|
|
37
|
+
/** The bookings the service's room list holds per room. */
|
|
38
|
+
export declare const ROOM_LIST_BOOKINGS = 5;
|
|
39
|
+
type RawRoom = CalendarV2EventRoomsQuery['getCalendarResources'][number];
|
|
40
|
+
/** What a room has, from its stored features: a list of words, or the names set to true. */
|
|
41
|
+
export declare function featuresOf(value: unknown): string[];
|
|
42
|
+
export declare function toRoomForEvent(raw: RawRoom): RoomForEvent;
|
|
43
|
+
export interface RoomsForEvent {
|
|
44
|
+
rooms: RoomForEvent[];
|
|
45
|
+
status: LoadStatus;
|
|
46
|
+
error: Error | null;
|
|
47
|
+
retry: () => void;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The workspace's rooms with every booking up to `until` known (the end of the time the dialog
|
|
51
|
+
* looks at, rounded up to a UTC day so moving within it reads nothing again).
|
|
52
|
+
*/
|
|
53
|
+
export declare function useRoomsForEvent(until: Date | null, options?: {
|
|
54
|
+
skip?: boolean;
|
|
55
|
+
}): RoomsForEvent;
|
|
56
|
+
export interface MemberIdentity {
|
|
57
|
+
userId: string;
|
|
58
|
+
name: string;
|
|
59
|
+
email: string | null;
|
|
60
|
+
}
|
|
61
|
+
export interface Identities {
|
|
62
|
+
/** Workspace members among the ids asked about; anyone else isn't (or is no longer) one. */
|
|
63
|
+
byUserId: ReadonlyMap<string, MemberIdentity>;
|
|
64
|
+
status: LoadStatus;
|
|
65
|
+
retry: () => void;
|
|
66
|
+
}
|
|
67
|
+
/** Names for these ids: only the workspace's active members come back. */
|
|
68
|
+
export declare function loadIdentities(client: Client, userIds: readonly string[]): Promise<MemberIdentity[]>;
|
|
69
|
+
/** Names for these ids, and which of them are the workspace's members. */
|
|
70
|
+
export declare function useIdentities(userIds: readonly string[]): Identities;
|
|
71
|
+
export interface MemberDirectory {
|
|
72
|
+
members: MemberIdentity[];
|
|
73
|
+
status: LoadStatus;
|
|
74
|
+
retry: () => void;
|
|
75
|
+
}
|
|
76
|
+
/** The workspace's active members, for the guest picker (read once it opens). */
|
|
77
|
+
export declare function useMemberDirectory(enabled: boolean): MemberDirectory;
|
|
78
|
+
export interface TeamMatch {
|
|
79
|
+
id: string;
|
|
80
|
+
name: string;
|
|
81
|
+
memberCount: number;
|
|
82
|
+
}
|
|
83
|
+
export interface TeamSearch {
|
|
84
|
+
teams: TeamMatch[];
|
|
85
|
+
status: LoadStatus;
|
|
86
|
+
}
|
|
87
|
+
/** Teams whose name matches `query` (two letters at least). */
|
|
88
|
+
export declare function useTeamSearch(query: string): TeamSearch;
|
|
89
|
+
/** The most members a team adds at once. */
|
|
90
|
+
export declare const MAX_TEAM_GUESTS = 100;
|
|
91
|
+
/** A team's members' ids (people only), for inviting each. */
|
|
92
|
+
export declare function loadTeamMemberIds(client: Client, groupId: string): Promise<{
|
|
93
|
+
userIds: string[];
|
|
94
|
+
total: number;
|
|
95
|
+
}>;
|
|
96
|
+
export {};
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { CalendarV2EventDocument as e, CalendarV2EventOccurrencesDocument as t, CalendarV2EventRoomsDocument as n, CalendarV2MemberIdentitiesDocument as r, CalendarV2MembersDocument as i, CalendarV2RoomBookingsDocument as a, CalendarV2SearchTeamsDocument as o, CalendarV2TeamMembersDocument as s } from "../../generated/wspace-operations.js";
|
|
2
|
+
import { useCalendar as c } from "../../providers/CalendarProvider.js";
|
|
3
|
+
import { graphQLErrorCode as l } from "../data/errors.js";
|
|
4
|
+
import { useCalendarEventsRevision as u } from "../data/invalidation.js";
|
|
5
|
+
import { occurrenceId as d, parseInstant as f, toCalendarEventV2 as p, toOccurrenceV2 as m } from "../data/normalize.js";
|
|
6
|
+
import { seriesDateQuestion as h } from "../data/seriesDateLookup.js";
|
|
7
|
+
import { useKeyedLoad as g } from "../data/useKeyedLoad.js";
|
|
8
|
+
import { knownUntilOf as _, roomKnownFor as v } from "./place.js";
|
|
9
|
+
import { useMemo as y } from "react";
|
|
10
|
+
import { useApolloClient as b } from "@apollo/client/react";
|
|
11
|
+
// src/v2/event/useEventData.ts
|
|
12
|
+
var x = class extends Error {};
|
|
13
|
+
async function S(e, n, r, i) {
|
|
14
|
+
let a = h(n, r);
|
|
15
|
+
if (!a) return null;
|
|
16
|
+
let o = (await e.query({
|
|
17
|
+
query: t,
|
|
18
|
+
variables: a,
|
|
19
|
+
fetchPolicy: "network-only"
|
|
20
|
+
})).data?.eventsInRangeForCalendars;
|
|
21
|
+
if (!o) throw Error("The series’ dates could not be read");
|
|
22
|
+
let s = d(n.eventId, new Date(r)), c = o.occurrences.find((e) => e.id === s);
|
|
23
|
+
return c ? m(c, i) : null;
|
|
24
|
+
}
|
|
25
|
+
async function C(t, n, r, i) {
|
|
26
|
+
let a = await t.query({
|
|
27
|
+
query: e,
|
|
28
|
+
variables: { id: n },
|
|
29
|
+
fetchPolicy: "network-only"
|
|
30
|
+
}), o = a.data?.event ? p(a.data.event, i) : null;
|
|
31
|
+
if (!o) throw new x("The event could not be found");
|
|
32
|
+
if (r === null) return {
|
|
33
|
+
event: o,
|
|
34
|
+
row: o
|
|
35
|
+
};
|
|
36
|
+
let s = await S(t, o, r, i);
|
|
37
|
+
if (!s) throw new x("That date of the series is not on the calendar");
|
|
38
|
+
return {
|
|
39
|
+
event: s,
|
|
40
|
+
row: o
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function w(e, t) {
|
|
44
|
+
if (!e) return { status: "none" };
|
|
45
|
+
let n = t.error;
|
|
46
|
+
if (n instanceof x || n && l(n) === "NOT_FOUND") return { status: "missing" };
|
|
47
|
+
let r = t.dataKey === e ? t.data : void 0;
|
|
48
|
+
if (r) {
|
|
49
|
+
let e = n ? "failed" : t.loading ? "loading" : "current";
|
|
50
|
+
return {
|
|
51
|
+
status: "ready",
|
|
52
|
+
event: r.event,
|
|
53
|
+
row: r.row,
|
|
54
|
+
retry: t.reload,
|
|
55
|
+
refresh: e
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return n ? {
|
|
59
|
+
status: "error",
|
|
60
|
+
error: n,
|
|
61
|
+
retry: t.reload
|
|
62
|
+
} : { status: "loading" };
|
|
63
|
+
}
|
|
64
|
+
function T(e, t = null) {
|
|
65
|
+
let n = b(), { currentUser: r } = c(), i = r?.id ?? null, a = u(), o = t?.getTime() ?? null, s = e === null ? null : `${e}|${o ?? ""}`;
|
|
66
|
+
return w(s, g(s, () => C(n, e ?? "", o, i), a));
|
|
67
|
+
}
|
|
68
|
+
function E(e) {
|
|
69
|
+
if (e.status !== "APPROVED" && e.status !== "PENDING") return null;
|
|
70
|
+
let t = f(e.startTime), n = f(e.endTime);
|
|
71
|
+
return !t || !n ? null : {
|
|
72
|
+
id: e.id,
|
|
73
|
+
eventId: e.eventId,
|
|
74
|
+
start: t,
|
|
75
|
+
end: n,
|
|
76
|
+
pending: e.status === "PENDING"
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function D(e) {
|
|
80
|
+
return e.flatMap((e) => {
|
|
81
|
+
let t = E(e);
|
|
82
|
+
return t ? [t] : [];
|
|
83
|
+
}).sort((e, t) => e.start.getTime() - t.start.getTime());
|
|
84
|
+
}
|
|
85
|
+
function O(e) {
|
|
86
|
+
return Array.isArray(e) ? e.filter((e) => typeof e == "string" && e.trim() !== "") : e && typeof e == "object" ? Object.entries(e).filter(([, e]) => e === !0).map(([e]) => e) : [];
|
|
87
|
+
}
|
|
88
|
+
function k(e) {
|
|
89
|
+
let t = [
|
|
90
|
+
e.location,
|
|
91
|
+
e.building,
|
|
92
|
+
e.floor
|
|
93
|
+
].map((e) => e?.trim()).filter((e) => !!e), n = e.bookings.filter((e) => e.status === "APPROVED" || e.status === "PENDING"), r = D(n);
|
|
94
|
+
return {
|
|
95
|
+
id: e.id,
|
|
96
|
+
name: e.name,
|
|
97
|
+
place: t.length > 0 ? [...new Set(t)].join(" · ") : null,
|
|
98
|
+
capacity: e.capacity ?? null,
|
|
99
|
+
bookable: e.isBookable,
|
|
100
|
+
needsApproval: e.requireApproval,
|
|
101
|
+
features: O(e.features),
|
|
102
|
+
bufferBefore: Math.max(0, e.bufferBefore),
|
|
103
|
+
bufferAfter: Math.max(0, e.bufferAfter),
|
|
104
|
+
bookings: r,
|
|
105
|
+
knownUntil: n.length < 5 ? null : _(r, 5)
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
async function A(e, t) {
|
|
109
|
+
let r = await e.query({
|
|
110
|
+
query: n,
|
|
111
|
+
fetchPolicy: "network-only"
|
|
112
|
+
});
|
|
113
|
+
if (!r.data) throw Error("The rooms could not be loaded");
|
|
114
|
+
let i = r.data.getCalendarResources.filter((e) => e.isActive).map(k).sort((e, t) => e.name.localeCompare(t.name));
|
|
115
|
+
return t ? Promise.all(i.map(async (n) => {
|
|
116
|
+
if (v(n, t)) return n;
|
|
117
|
+
let r = (await e.query({
|
|
118
|
+
query: a,
|
|
119
|
+
variables: { id: n.id },
|
|
120
|
+
fetchPolicy: "network-only"
|
|
121
|
+
})).data?.getCalendarResource?.bookings;
|
|
122
|
+
if (!r) throw Error("The room’s bookings could not be loaded");
|
|
123
|
+
return {
|
|
124
|
+
...n,
|
|
125
|
+
bookings: D(r),
|
|
126
|
+
knownUntil: null
|
|
127
|
+
};
|
|
128
|
+
})) : i;
|
|
129
|
+
}
|
|
130
|
+
var j = 864e5;
|
|
131
|
+
function M(e, t = {}) {
|
|
132
|
+
let n = b(), r = u(), i = e ? Math.ceil(e.getTime() / j) * j : 0, a = t.skip ? null : `rooms|${i}`, o = g(a, () => A(n, i ? new Date(i) : null), r);
|
|
133
|
+
return {
|
|
134
|
+
rooms: o.data ?? N,
|
|
135
|
+
status: t.skip ? "idle" : o.error ? "error" : o.data && o.dataKey === a ? "ready" : "loading",
|
|
136
|
+
error: o.error,
|
|
137
|
+
retry: o.reload
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
var N = [], P = 100;
|
|
141
|
+
async function F(e, t) {
|
|
142
|
+
let n = [];
|
|
143
|
+
for (let e = 0; e < t.length; e += P) n.push(t.slice(e, e + P));
|
|
144
|
+
return (await Promise.all(n.map((t) => e.query({
|
|
145
|
+
query: r,
|
|
146
|
+
variables: { userIds: t },
|
|
147
|
+
fetchPolicy: "cache-first"
|
|
148
|
+
})))).flatMap((e) => {
|
|
149
|
+
if (!e.data) throw Error("Names could not be loaded");
|
|
150
|
+
return e.data.workspaceMemberIdentities.map((e) => ({
|
|
151
|
+
userId: e.userId,
|
|
152
|
+
name: e.displayName.trim() || e.email?.trim() || e.userId,
|
|
153
|
+
email: e.email?.trim() || null
|
|
154
|
+
}));
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
function I(e) {
|
|
158
|
+
let t = b(), n = y(() => [...new Set(e.filter(Boolean))].sort(), [e]), r = n.length === 0 ? null : n.join("\n"), i = g(r, () => F(t, n));
|
|
159
|
+
return {
|
|
160
|
+
byUserId: y(() => new Map((i.data ?? []).map((e) => [e.userId, e])), [i.data]),
|
|
161
|
+
status: r === null ? "idle" : i.error ? "error" : i.dataKey === r ? "ready" : "loading",
|
|
162
|
+
retry: i.reload
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
var L = 100, R = 10;
|
|
166
|
+
async function z(e, t) {
|
|
167
|
+
let n = [];
|
|
168
|
+
for (let r = 0; r < R; r += 1) {
|
|
169
|
+
let a = (await e.query({
|
|
170
|
+
query: i,
|
|
171
|
+
variables: {
|
|
172
|
+
workspaceId: t,
|
|
173
|
+
pagination: {
|
|
174
|
+
limit: L,
|
|
175
|
+
offset: r * L
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
fetchPolicy: "network-only"
|
|
179
|
+
})).data?.workspaceMembers;
|
|
180
|
+
if (!a) throw Error("The workspace’s members could not be loaded");
|
|
181
|
+
for (let e of a.items) e.status.toLowerCase() === "active" && n.push(e.userId);
|
|
182
|
+
if (!a.hasMore || a.items.length === 0) break;
|
|
183
|
+
}
|
|
184
|
+
return (await F(e, [...new Set(n)])).sort((e, t) => e.name.localeCompare(t.name, void 0, { sensitivity: "base" }));
|
|
185
|
+
}
|
|
186
|
+
function B(e) {
|
|
187
|
+
let t = b(), { workspaceId: n } = c(), r = e && n ? `members|${n}` : null, i = g(r, () => z(t, n ?? ""));
|
|
188
|
+
return {
|
|
189
|
+
members: i.data ?? V,
|
|
190
|
+
status: r === null ? "idle" : i.error ? "error" : i.dataKey === r ? "ready" : "loading",
|
|
191
|
+
retry: i.reload
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
var V = [];
|
|
195
|
+
function H(e) {
|
|
196
|
+
let t = b(), n = e.trim(), r = n.length >= 2 ? `teams|${n.toLowerCase()}` : null, i = g(r, async () => {
|
|
197
|
+
let e = await t.query({
|
|
198
|
+
query: o,
|
|
199
|
+
variables: { query: n },
|
|
200
|
+
fetchPolicy: "network-only"
|
|
201
|
+
});
|
|
202
|
+
if (!e.data) throw Error("Teams could not be searched");
|
|
203
|
+
return e.data.searchGroups.map((e) => ({
|
|
204
|
+
id: e.id,
|
|
205
|
+
name: e.name,
|
|
206
|
+
memberCount: e.memberCount
|
|
207
|
+
}));
|
|
208
|
+
});
|
|
209
|
+
return {
|
|
210
|
+
teams: r !== null && i.dataKey === r ? i.data ?? [] : [],
|
|
211
|
+
status: r === null ? "idle" : i.error ? "error" : i.dataKey === r ? "ready" : "loading"
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
async function U(e, t) {
|
|
215
|
+
let n = (await e.query({
|
|
216
|
+
query: s,
|
|
217
|
+
variables: { groupId: t },
|
|
218
|
+
fetchPolicy: "network-only"
|
|
219
|
+
})).data?.groupMembers;
|
|
220
|
+
if (!n) throw Error("The team’s members could not be loaded");
|
|
221
|
+
let r = n.edges.map((e) => e.node).filter((e) => e.entityType.toLowerCase() === "user").map((e) => e.entityId);
|
|
222
|
+
return {
|
|
223
|
+
userIds: [...new Set(r)].slice(0, 100),
|
|
224
|
+
total: n.totalCount
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
export { O as featuresOf, F as loadIdentities, U as loadTeamMemberIds, k as toRoomForEvent, T as useEditedEvent, I as useIdentities, B as useMemberDirectory, M as useRoomsForEvent, H as useTeamSearch };
|
|
228
|
+
|
|
229
|
+
//# sourceMappingURL=useEventData.js.map
|