@burdenoff/microfe-calendar 2026.1123.3 → 2026.1124.2

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.
Files changed (251) hide show
  1. package/dist/components/AgendaView.js.map +1 -1
  2. package/dist/generated/wspace-operations.d.ts +785 -0
  3. package/dist/generated/wspace-operations.js +250 -84
  4. package/dist/generated/wspace-operations.js.map +1 -1
  5. package/dist/generated/wspace-types.d.ts +1243 -10
  6. package/dist/hooks/useSafePermissions.js.map +1 -1
  7. package/dist/index.d.ts +1 -0
  8. package/dist/providers/CalendarProvider.d.ts +3 -1
  9. package/dist/providers/CalendarProvider.js +12 -10
  10. package/dist/providers/CalendarProvider.js.map +1 -1
  11. package/dist/translations/en.d.ts +351 -0
  12. package/dist/types/index.d.ts +9 -0
  13. package/dist/v2/CalendarPageV2.js +92 -14
  14. package/dist/v2/CalendarPageV2.js.map +1 -1
  15. package/dist/v2/colors.d.ts +23 -0
  16. package/dist/v2/colors.js +92 -0
  17. package/dist/v2/colors.js.map +1 -0
  18. package/dist/v2/data/enums.d.ts +6 -0
  19. package/dist/v2/data/enums.js +10 -0
  20. package/dist/v2/data/enums.js.map +1 -0
  21. package/dist/v2/data/errors.d.ts +4 -0
  22. package/dist/v2/data/errors.js +17 -0
  23. package/dist/v2/data/errors.js.map +1 -0
  24. package/dist/v2/data/invalidation.js +19 -0
  25. package/dist/v2/data/invalidation.js.map +1 -0
  26. package/dist/v2/data/normalize.js +181 -16
  27. package/dist/v2/data/normalize.js.map +1 -1
  28. package/dist/v2/data/serialWrites.d.ts +17 -0
  29. package/dist/v2/data/serialWrites.js +21 -0
  30. package/dist/v2/data/serialWrites.js.map +1 -0
  31. package/dist/v2/data/useCalendarsV2.d.ts +10 -1
  32. package/dist/v2/data/useCalendarsV2.js +68 -16
  33. package/dist/v2/data/useCalendarsV2.js.map +1 -1
  34. package/dist/v2/data/useEventActions.d.ts +49 -0
  35. package/dist/v2/data/useEventActions.js +399 -0
  36. package/dist/v2/data/useEventActions.js.map +1 -0
  37. package/dist/v2/data/useEventForPeek.d.ts +17 -0
  38. package/dist/v2/data/useEventForPeek.js +29 -0
  39. package/dist/v2/data/useEventForPeek.js.map +1 -0
  40. package/dist/v2/data/useEventSearchV2.d.ts +15 -0
  41. package/dist/v2/data/useEventSearchV2.js +80 -0
  42. package/dist/v2/data/useEventSearchV2.js.map +1 -0
  43. package/dist/v2/data/useEventsInRangeV2.js +78 -0
  44. package/dist/v2/data/useEventsInRangeV2.js.map +1 -0
  45. package/dist/v2/data/useFreeBusy.d.ts +5 -0
  46. package/dist/v2/data/useFreeBusy.js +83 -0
  47. package/dist/v2/data/useFreeBusy.js.map +1 -0
  48. package/dist/v2/data/useKeyedLoad.js +47 -0
  49. package/dist/v2/data/useKeyedLoad.js.map +1 -0
  50. package/dist/v2/data/useRoomsV2.d.ts +28 -0
  51. package/dist/v2/data/useRoomsV2.js +45 -0
  52. package/dist/v2/data/useRoomsV2.js.map +1 -0
  53. package/dist/v2/day/DayPanel.d.ts +6 -0
  54. package/dist/v2/day/DayPanel.js +215 -0
  55. package/dist/v2/day/DayPanel.js.map +1 -0
  56. package/dist/v2/day/daySummary.d.ts +37 -0
  57. package/dist/v2/day/daySummary.js +37 -0
  58. package/dist/v2/day/daySummary.js.map +1 -0
  59. package/dist/v2/dialogs/CalendarDialogsV2.d.ts +1 -0
  60. package/dist/v2/dialogs/CalendarDialogsV2.js +17 -0
  61. package/dist/v2/dialogs/CalendarDialogsV2.js.map +1 -0
  62. package/dist/v2/dialogs/ShortcutsDialog.d.ts +4 -0
  63. package/dist/v2/dialogs/ShortcutsDialog.js +42 -0
  64. package/dist/v2/dialogs/ShortcutsDialog.js.map +1 -0
  65. package/dist/v2/events/eventLook.d.ts +46 -0
  66. package/dist/v2/events/eventLook.js +35 -0
  67. package/dist/v2/events/eventLook.js.map +1 -0
  68. package/dist/v2/events/eventModel.d.ts +92 -0
  69. package/dist/v2/events/eventModel.js +116 -0
  70. package/dist/v2/events/eventModel.js.map +1 -0
  71. package/dist/v2/events/localChanges.d.ts +4 -0
  72. package/dist/v2/events/localChanges.js +23 -0
  73. package/dist/v2/events/localChanges.js.map +1 -0
  74. package/dist/v2/format.d.ts +67 -0
  75. package/dist/v2/format.js +112 -0
  76. package/dist/v2/format.js.map +1 -0
  77. package/dist/v2/grid/AllDayRow.d.ts +20 -0
  78. package/dist/v2/grid/AllDayRow.js +94 -0
  79. package/dist/v2/grid/AllDayRow.js.map +1 -0
  80. package/dist/v2/grid/EventBlock.d.ts +21 -0
  81. package/dist/v2/grid/EventBlock.js +112 -0
  82. package/dist/v2/grid/EventBlock.js.map +1 -0
  83. package/dist/v2/grid/GridParts.d.ts +40 -0
  84. package/dist/v2/grid/GridParts.js +210 -0
  85. package/dist/v2/grid/GridParts.js.map +1 -0
  86. package/dist/v2/grid/QuickCreate.d.ts +1 -0
  87. package/dist/v2/grid/QuickCreate.js +175 -0
  88. package/dist/v2/grid/QuickCreate.js.map +1 -0
  89. package/dist/v2/grid/TimeGrid.d.ts +1 -0
  90. package/dist/v2/grid/TimeGrid.js +188 -0
  91. package/dist/v2/grid/TimeGrid.js.map +1 -0
  92. package/dist/v2/grid/geometry.d.ts +72 -0
  93. package/dist/v2/grid/geometry.js +85 -0
  94. package/dist/v2/grid/geometry.js.map +1 -0
  95. package/dist/v2/grid/layout.d.ts +24 -0
  96. package/dist/v2/grid/layout.js +77 -0
  97. package/dist/v2/grid/layout.js.map +1 -0
  98. package/dist/v2/grid/useGridDrag.d.ts +42 -0
  99. package/dist/v2/grid/useGridDrag.js +181 -0
  100. package/dist/v2/grid/useGridDrag.js.map +1 -0
  101. package/dist/v2/grid/useSlotCursor.d.ts +32 -0
  102. package/dist/v2/grid/useSlotCursor.js +57 -0
  103. package/dist/v2/grid/useSlotCursor.js.map +1 -0
  104. package/dist/v2/grid/workingHours.d.ts +21 -0
  105. package/dist/v2/grid/workingHours.js +101 -0
  106. package/dist/v2/grid/workingHours.js.map +1 -0
  107. package/dist/v2/hooks/useAvailableHeight.d.ts +2 -0
  108. package/dist/v2/hooks/useAvailableHeight.js +25 -0
  109. package/dist/v2/hooks/useAvailableHeight.js.map +1 -0
  110. package/dist/v2/hooks/useCalendarShortcuts.d.ts +9 -0
  111. package/dist/v2/hooks/useCalendarShortcuts.js +60 -0
  112. package/dist/v2/hooks/useCalendarShortcuts.js.map +1 -0
  113. package/dist/v2/hooks/useDebouncedValue.d.ts +1 -0
  114. package/dist/v2/hooks/useDebouncedValue.js +12 -0
  115. package/dist/v2/hooks/useDebouncedValue.js.map +1 -0
  116. package/dist/v2/hooks/useMediaQuery.d.ts +5 -0
  117. package/dist/v2/hooks/useMediaQuery.js +17 -0
  118. package/dist/v2/hooks/useMediaQuery.js.map +1 -0
  119. package/dist/v2/hooks/useNow.d.ts +2 -0
  120. package/dist/v2/hooks/useNow.js +31 -0
  121. package/dist/v2/hooks/useNow.js.map +1 -0
  122. package/dist/v2/limits.d.ts +6 -0
  123. package/dist/v2/limits.js +5 -0
  124. package/dist/v2/limits.js.map +1 -0
  125. package/dist/v2/list/EventListRow.d.ts +10 -0
  126. package/dist/v2/list/EventListRow.js +109 -0
  127. package/dist/v2/list/EventListRow.js.map +1 -0
  128. package/dist/v2/list/ListViewV2.d.ts +16 -0
  129. package/dist/v2/list/ListViewV2.js +96 -0
  130. package/dist/v2/list/ListViewV2.js.map +1 -0
  131. package/dist/v2/month/MonthView.d.ts +1 -0
  132. package/dist/v2/month/MonthView.js +328 -0
  133. package/dist/v2/month/MonthView.js.map +1 -0
  134. package/dist/v2/month/monthLayout.d.ts +39 -0
  135. package/dist/v2/month/monthLayout.js +29 -0
  136. package/dist/v2/month/monthLayout.js.map +1 -0
  137. package/dist/v2/page/CalendarChrome.d.ts +2 -0
  138. package/dist/v2/page/CalendarChrome.js +295 -0
  139. package/dist/v2/page/CalendarChrome.js.map +1 -0
  140. package/dist/v2/page/CalendarPageContext.d.ts +92 -0
  141. package/dist/v2/page/CalendarPageContext.js +11 -0
  142. package/dist/v2/page/CalendarPageContext.js.map +1 -0
  143. package/dist/v2/page/pageHelpers.d.ts +19 -0
  144. package/dist/v2/page/pageHelpers.js +39 -0
  145. package/dist/v2/page/pageHelpers.js.map +1 -0
  146. package/dist/v2/page/useCalendarPageModel.d.ts +2 -0
  147. package/dist/v2/page/useCalendarPageModel.js +198 -0
  148. package/dist/v2/page/useCalendarPageModel.js.map +1 -0
  149. package/dist/v2/page/viewState.d.ts +70 -0
  150. package/dist/v2/page/viewState.js +47 -0
  151. package/dist/v2/page/viewState.js.map +1 -0
  152. package/dist/v2/peek/EventPeek.d.ts +2 -0
  153. package/dist/v2/peek/EventPeek.js +92 -0
  154. package/dist/v2/peek/EventPeek.js.map +1 -0
  155. package/dist/v2/peek/PeekEvent.d.ts +4 -0
  156. package/dist/v2/peek/PeekEvent.js +443 -0
  157. package/dist/v2/peek/PeekEvent.js.map +1 -0
  158. package/dist/v2/peek/PeekParts.d.ts +14 -0
  159. package/dist/v2/peek/PeekParts.js +75 -0
  160. package/dist/v2/peek/PeekParts.js.map +1 -0
  161. package/dist/v2/prefs/calendarPrefs.d.ts +2 -2
  162. package/dist/v2/prefs/calendarPrefs.js +35 -34
  163. package/dist/v2/prefs/calendarPrefs.js.map +1 -1
  164. package/dist/v2/rail/CalendarRail.d.ts +3 -0
  165. package/dist/v2/rail/CalendarRail.js +258 -0
  166. package/dist/v2/rail/CalendarRail.js.map +1 -0
  167. package/dist/v2/rail/railStatus.d.ts +54 -0
  168. package/dist/v2/rail/railStatus.js +84 -0
  169. package/dist/v2/rail/railStatus.js.map +1 -0
  170. package/dist/v2/rail/syncWords.d.ts +10 -0
  171. package/dist/v2/rail/syncWords.js +75 -0
  172. package/dist/v2/rail/syncWords.js.map +1 -0
  173. package/dist/v2/rail/useMonthEventDates.d.ts +4 -0
  174. package/dist/v2/rail/useMonthEventDates.js +30 -0
  175. package/dist/v2/rail/useMonthEventDates.js.map +1 -0
  176. package/dist/v2/routes.js +4 -1
  177. package/dist/v2/routes.js.map +1 -1
  178. package/dist/v2/runs/RunPeek.d.ts +2 -0
  179. package/dist/v2/runs/RunPeek.js +382 -0
  180. package/dist/v2/runs/RunPeek.js.map +1 -0
  181. package/dist/v2/runs/RunPills.d.ts +28 -0
  182. package/dist/v2/runs/RunPills.js +179 -0
  183. package/dist/v2/runs/RunPills.js.map +1 -0
  184. package/dist/v2/runs/RunRows.d.ts +21 -0
  185. package/dist/v2/runs/RunRows.js +140 -0
  186. package/dist/v2/runs/RunRows.js.map +1 -0
  187. package/dist/v2/runs/RunsNotices.d.ts +1 -0
  188. package/dist/v2/runs/RunsNotices.js +37 -0
  189. package/dist/v2/runs/RunsNotices.js.map +1 -0
  190. package/dist/v2/runs/RunsSwitch.d.ts +1 -0
  191. package/dist/v2/runs/RunsSwitch.js +54 -0
  192. package/dist/v2/runs/RunsSwitch.js.map +1 -0
  193. package/dist/v2/runs/WorkflowRunsLayer.d.ts +4 -0
  194. package/dist/v2/runs/WorkflowRunsLayer.js +82 -0
  195. package/dist/v2/runs/WorkflowRunsLayer.js.map +1 -0
  196. package/dist/v2/runs/runAccess.d.ts +37 -0
  197. package/dist/v2/runs/runAccess.js +14 -0
  198. package/dist/v2/runs/runAccess.js.map +1 -0
  199. package/dist/v2/runs/runLayout.d.ts +76 -0
  200. package/dist/v2/runs/runLayout.js +129 -0
  201. package/dist/v2/runs/runLayout.js.map +1 -0
  202. package/dist/v2/runs/runLinks.d.ts +32 -0
  203. package/dist/v2/runs/runLinks.js +50 -0
  204. package/dist/v2/runs/runLinks.js.map +1 -0
  205. package/dist/v2/runs/runModel.d.ts +97 -0
  206. package/dist/v2/runs/runModel.js +132 -0
  207. package/dist/v2/runs/runModel.js.map +1 -0
  208. package/dist/v2/runs/runPeekState.d.ts +53 -0
  209. package/dist/v2/runs/runPeekState.js +62 -0
  210. package/dist/v2/runs/runPeekState.js.map +1 -0
  211. package/dist/v2/runs/runTypes.d.ts +60 -0
  212. package/dist/v2/runs/runWords.d.ts +23 -0
  213. package/dist/v2/runs/runWords.js +83 -0
  214. package/dist/v2/runs/runWords.js.map +1 -0
  215. package/dist/v2/runs/runsLayerContext.d.ts +26 -0
  216. package/dist/v2/runs/runsLayerContext.js +33 -0
  217. package/dist/v2/runs/runsLayerContext.js.map +1 -0
  218. package/dist/v2/runs/useRunHrefs.d.ts +10 -0
  219. package/dist/v2/runs/useRunHrefs.js +60 -0
  220. package/dist/v2/runs/useRunHrefs.js.map +1 -0
  221. package/dist/v2/runs/useRunLabels.d.ts +6 -0
  222. package/dist/v2/runs/useRunLabels.js +27 -0
  223. package/dist/v2/runs/useRunLabels.js.map +1 -0
  224. package/dist/v2/runs/useRunsAccess.d.ts +2 -0
  225. package/dist/v2/runs/useRunsAccess.js +14 -0
  226. package/dist/v2/runs/useRunsAccess.js.map +1 -0
  227. package/dist/v2/runs/useWorkflowRuns.d.ts +61 -0
  228. package/dist/v2/runs/useWorkflowRuns.js +119 -0
  229. package/dist/v2/runs/useWorkflowRuns.js.map +1 -0
  230. package/dist/v2/search/SearchResults.d.ts +1 -0
  231. package/dist/v2/search/SearchResults.js +88 -0
  232. package/dist/v2/search/SearchResults.js.map +1 -0
  233. package/dist/v2/search/searchModel.d.ts +20 -0
  234. package/dist/v2/search/searchModel.js +22 -0
  235. package/dist/v2/search/searchModel.js.map +1 -0
  236. package/dist/v2/state/calendarV2Store.d.ts +4 -1
  237. package/dist/v2/state/calendarV2Store.js +3 -1
  238. package/dist/v2/state/calendarV2Store.js.map +1 -1
  239. package/dist/v2/state/useCalendarV2Navigation.d.ts +1 -0
  240. package/dist/v2/state/useCalendarV2Navigation.js +4 -1
  241. package/dist/v2/state/useCalendarV2Navigation.js.map +1 -1
  242. package/dist/v2/states/CalendarStates.d.ts +18 -0
  243. package/dist/v2/states/CalendarStates.js +122 -0
  244. package/dist/v2/states/CalendarStates.js.map +1 -0
  245. package/dist/v2/styles.d.ts +32 -0
  246. package/dist/v2/styles.js +10 -0
  247. package/dist/v2/styles.js.map +1 -0
  248. package/dist/v2/time/calendarTime.js +121 -35
  249. package/dist/v2/time/calendarTime.js.map +1 -1
  250. package/dist/v2/types.d.ts +22 -2
  251. package/package.json +1 -1
@@ -1,8 +1,9 @@
1
- import { isCalendarV2View as e, viewForName as t } from "../routes.js";
2
- import { isWeekStart as n } from "../time/calendarTime.js";
3
- import { canonicalTimeZone as r } from "@burdenoff/fe-libs/ui";
1
+ import { MAX_LISTED_CALENDARS as e } from "../limits.js";
2
+ import { isCalendarV2View as t, viewForName as n } from "../routes.js";
3
+ import { isWeekStart as r } from "../time/calendarTime.js";
4
+ import { canonicalTimeZone as i } from "@burdenoff/fe-libs/ui";
4
5
  // src/v2/prefs/calendarPrefs.ts
5
- var i = "calendar", a = 1440, o = 40320, s = Object.freeze({
6
+ var a = "calendar", o = e, s = 1440, c = 40320, l = Object.freeze({
6
7
  timeZone: null,
7
8
  hourCycle: "h23",
8
9
  weekStart: 1,
@@ -15,57 +16,57 @@ var i = "calendar", a = 1440, o = 40320, s = Object.freeze({
15
16
  hiddenCalendarIds: [],
16
17
  runsLayer: !1
17
18
  });
18
- function c(e) {
19
+ function u(e) {
19
20
  return typeof e == "object" && !!e && !Array.isArray(e);
20
21
  }
21
- function l(e, t, n) {
22
+ function d(e, t, n) {
22
23
  return typeof e == "number" && Number.isInteger(e) && e >= t && e <= n;
23
24
  }
24
- function u(e) {
25
+ function f(e) {
25
26
  if (!Array.isArray(e)) return;
26
27
  let t = e.filter((e) => typeof e == "string" && e.trim() !== "");
27
- return [...new Set(t)].sort().slice(0, 200);
28
+ return [...new Set(t)].sort().slice(0, o);
28
29
  }
29
- function d(t) {
30
- if (!c(t)) return {};
31
- let i = {};
32
- if (t.timeZone === null) i.timeZone = null;
33
- else if (typeof t.timeZone == "string") {
34
- let e = r(t.timeZone);
35
- e && (i.timeZone = e);
30
+ function p(e) {
31
+ if (!u(e)) return {};
32
+ let n = {};
33
+ if (e.timeZone === null) n.timeZone = null;
34
+ else if (typeof e.timeZone == "string") {
35
+ let t = i(e.timeZone);
36
+ t && (n.timeZone = t);
36
37
  }
37
- (t.hourCycle === "h23" || t.hourCycle === "h12") && (i.hourCycle = t.hourCycle), n(t.weekStart) && (i.weekStart = t.weekStart), typeof t.showWeekends == "boolean" && (i.showWeekends = t.showWeekends), e(t.defaultView) && (i.defaultView = t.defaultView), l(t.defaultDuration, 5, 1440) && (i.defaultDuration = t.defaultDuration), t.defaultReminder === null ? i.defaultReminder = null : l(t.defaultReminder, 0, 40320) && (i.defaultReminder = t.defaultReminder), typeof t.dimPast == "boolean" && (i.dimPast = t.dimPast), typeof t.showDeclined == "boolean" && (i.showDeclined = t.showDeclined);
38
- let a = u(t.hiddenCalendarIds);
39
- return a && (i.hiddenCalendarIds = a), typeof t.runsLayer == "boolean" && (i.runsLayer = t.runsLayer), i;
38
+ (e.hourCycle === "h23" || e.hourCycle === "h12") && (n.hourCycle = e.hourCycle), r(e.weekStart) && (n.weekStart = e.weekStart), typeof e.showWeekends == "boolean" && (n.showWeekends = e.showWeekends), t(e.defaultView) && (n.defaultView = e.defaultView), d(e.defaultDuration, 5, 1440) && (n.defaultDuration = e.defaultDuration), e.defaultReminder === null ? n.defaultReminder = null : d(e.defaultReminder, 0, 40320) && (n.defaultReminder = e.defaultReminder), typeof e.dimPast == "boolean" && (n.dimPast = e.dimPast), typeof e.showDeclined == "boolean" && (n.showDeclined = e.showDeclined);
39
+ let a = f(e.hiddenCalendarIds);
40
+ return a && (n.hiddenCalendarIds = a), typeof e.runsLayer == "boolean" && (n.runsLayer = e.runsLayer), n;
40
41
  }
41
- function f(e) {
42
+ function m(e) {
42
43
  return {
43
- ...s,
44
+ ...l,
44
45
  ...e,
45
- hiddenCalendarIds: [...e.hiddenCalendarIds ?? s.hiddenCalendarIds]
46
+ hiddenCalendarIds: [...e.hiddenCalendarIds ?? l.hiddenCalendarIds]
46
47
  };
47
48
  }
48
- function p(e) {
49
- return f(d(e));
49
+ function h(e) {
50
+ return m(p(e));
50
51
  }
51
- function m(e, n) {
52
- let i = c(e) && c(e.state) ? e.state : null;
53
- if (!i) return null;
54
- let a = {}, o = t(typeof i.currentView == "string" ? i.currentView : null);
55
- if (o && (a.defaultView = o), typeof i.selectedTimeZone == "string") {
56
- let e = r(i.selectedTimeZone);
57
- e && e !== r(n) && (a.timeZone = e);
52
+ function g(e, t) {
53
+ let r = u(e) && u(e.state) ? e.state : null;
54
+ if (!r) return null;
55
+ let a = {}, o = n(typeof r.currentView == "string" ? r.currentView : null);
56
+ if (o && (a.defaultView = o), typeof r.selectedTimeZone == "string") {
57
+ let e = i(r.selectedTimeZone);
58
+ e && e !== i(t) && (a.timeZone = e);
58
59
  }
59
- let s = u(i.visibleCalendars) ?? [];
60
+ let s = f(r.visibleCalendars) ?? [];
60
61
  return Object.keys(a).length === 0 && s.length === 0 ? null : {
61
62
  prefs: a,
62
63
  visibleCalendarIds: s
63
64
  };
64
65
  }
65
- function h(e, t) {
66
+ function _(e, t) {
66
67
  let n = new Set(e);
67
- return t.some((e) => n.has(e)) ? u(t.filter((e) => !n.has(e))) ?? [] : [];
68
+ return t.some((e) => n.has(e)) ? f(t.filter((e) => !n.has(e))) ?? [] : [];
68
69
  }
69
- export { i as CALENDAR_PREFS_KEY, s as DEFAULT_CALENDAR_PREFS, a as MAX_DEFAULT_DURATION, o as MAX_DEFAULT_REMINDER, h as hiddenFromVisible, d as parseCalendarPrefs, m as readLegacyCalendarState, p as toStoredPrefs, f as withDefaults };
70
+ export { a as CALENDAR_PREFS_KEY, l as DEFAULT_CALENDAR_PREFS, s as MAX_DEFAULT_DURATION, c as MAX_DEFAULT_REMINDER, o as MAX_HIDDEN_CALENDARS, _ as hiddenFromVisible, p as parseCalendarPrefs, g as readLegacyCalendarState, h as toStoredPrefs, m as withDefaults };
70
71
 
71
72
  //# sourceMappingURL=calendarPrefs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"calendarPrefs.js","names":["CALENDAR_PREFS_KEY","MAX_DEFAULT_DURATION","MAX_DEFAULT_REMINDER","DEFAULT_CALENDAR_PREFS","isRecord","value","isWholeNumberWithin","min","max","parseCalendarIds","ids","id","parseCalendarPrefs","prefs","zone","canonicalTimeZone","isWeekStart","isCalendarV2View","hidden","withDefaults","toStoredPrefs","readLegacyCalendarState","state","stored","opening","viewForName","deviceTimeZone","visibleCalendarIds","hiddenFromVisible","visible","visibleIds","allCalendarIds"],"sources":["../../../src/v2/prefs/calendarPrefs.ts"],"sourcesContent":["/**\n * The person's calendar settings (BOFF-15698 B3, operator decision 6): kept on their account\n * under the `calendar` key of global-auth-svc's preferences, so they follow the person across\n * devices and workspaces.\n *\n * `updateMyPreferences` merges the keys it is given into the stored ones one level deep, so\n * the whole `calendar` object is always written (`toStoredPrefs`); a partial write would drop\n * the keys it leaves out. Everything read back is checked (`parseCalendarPrefs`): a value that\n * isn't valid falls back to its default instead of breaking the calendar.\n */\nimport { canonicalTimeZone, type HourCycle, type WeekStart } from '@burdenoff/fe-libs/ui';\nimport { isCalendarV2View, viewForName } from '../routes';\nimport { isWeekStart } from '../time/calendarTime';\nimport type { CalendarV2View } from '../types';\n\n/** The key the settings live under in the account's preferences. */\nexport const CALENDAR_PREFS_KEY = 'calendar';\n\n/** The most hidden calendars kept (the calendars query lists at most 200). */\nexport const MAX_HIDDEN_CALENDARS = 200;\n/** Event lengths a person can default to, in minutes. */\nexport const MIN_DEFAULT_DURATION = 5;\nexport const MAX_DEFAULT_DURATION = 24 * 60;\n/** The earliest a default reminder can fire: four weeks before. */\nexport const MAX_DEFAULT_REMINDER = 4 * 7 * 24 * 60;\n\nexport interface CalendarPrefs {\n /** The IANA zone the calendar shows; null follows this device. */\n timeZone: string | null;\n /** `h23` 24-hour clock (the default), `h12` 12-hour. */\n hourCycle: HourCycle;\n /** 1 Monday (the default), 0 Sunday, 6 Saturday. */\n weekStart: WeekStart;\n showWeekends: boolean;\n /** The view the calendar opens on. */\n defaultView: CalendarV2View;\n /** Minutes a new event lasts. */\n defaultDuration: number;\n /** Minutes before an event its reminder fires; null for none. */\n defaultReminder: number | null;\n /** Fade events that have ended. */\n dimPast: boolean;\n /** Show events the person declined. */\n showDeclined: boolean;\n /** Calendars unticked in the rail. */\n hiddenCalendarIds: string[];\n /** The Workflow runs layer (decision 1: off until turned on). */\n runsLayer: boolean;\n}\n\nexport const DEFAULT_CALENDAR_PREFS: Readonly<CalendarPrefs> = Object.freeze({\n timeZone: null,\n hourCycle: 'h23',\n weekStart: 1,\n showWeekends: true,\n defaultView: 'week',\n defaultDuration: 60,\n defaultReminder: 10,\n dimPast: true,\n showDeclined: false,\n hiddenCalendarIds: [],\n runsLayer: false,\n});\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction isWholeNumberWithin(value: unknown, min: number, max: number): value is number {\n return typeof value === 'number' && Number.isInteger(value) && value >= min && value <= max;\n}\n\n/** The hidden calendar ids from a stored value: strings, no blanks or repeats, sorted. */\nfunction parseCalendarIds(value: unknown): string[] | undefined {\n if (!Array.isArray(value)) return undefined;\n const ids = value.filter((id): id is string => typeof id === 'string' && id.trim() !== '');\n return [...new Set(ids)].sort().slice(0, MAX_HIDDEN_CALENDARS);\n}\n\n/**\n * The valid settings in a stored value (anything else, or a value that isn't an object, gives\n * nothing). A time zone is kept as today's IANA name.\n */\nexport function parseCalendarPrefs(value: unknown): Partial<CalendarPrefs> {\n if (!isRecord(value)) return {};\n const prefs: Partial<CalendarPrefs> = {};\n if (value.timeZone === null) prefs.timeZone = null;\n else if (typeof value.timeZone === 'string') {\n const zone = canonicalTimeZone(value.timeZone);\n if (zone) prefs.timeZone = zone;\n }\n if (value.hourCycle === 'h23' || value.hourCycle === 'h12') prefs.hourCycle = value.hourCycle;\n if (isWeekStart(value.weekStart)) prefs.weekStart = value.weekStart;\n if (typeof value.showWeekends === 'boolean') prefs.showWeekends = value.showWeekends;\n if (isCalendarV2View(value.defaultView)) prefs.defaultView = value.defaultView;\n if (isWholeNumberWithin(value.defaultDuration, MIN_DEFAULT_DURATION, MAX_DEFAULT_DURATION)) {\n prefs.defaultDuration = value.defaultDuration;\n }\n if (value.defaultReminder === null) prefs.defaultReminder = null;\n else if (isWholeNumberWithin(value.defaultReminder, 0, MAX_DEFAULT_REMINDER)) {\n prefs.defaultReminder = value.defaultReminder;\n }\n if (typeof value.dimPast === 'boolean') prefs.dimPast = value.dimPast;\n if (typeof value.showDeclined === 'boolean') prefs.showDeclined = value.showDeclined;\n const hidden = parseCalendarIds(value.hiddenCalendarIds);\n if (hidden) prefs.hiddenCalendarIds = hidden;\n if (typeof value.runsLayer === 'boolean') prefs.runsLayer = value.runsLayer;\n return prefs;\n}\n\n/** Complete settings: `prefs` over the defaults. */\nexport function withDefaults(prefs: Partial<CalendarPrefs>): CalendarPrefs {\n return {\n ...DEFAULT_CALENDAR_PREFS,\n ...prefs,\n hiddenCalendarIds: [...(prefs.hiddenCalendarIds ?? DEFAULT_CALENDAR_PREFS.hiddenCalendarIds)],\n };\n}\n\n/** The settings as stored: every key, checked, so a write never drops one. */\nexport function toStoredPrefs(prefs: CalendarPrefs): CalendarPrefs {\n return withDefaults(parseCalendarPrefs(prefs));\n}\n\n/** Whether two complete settings say the same. */\nexport function samePrefs(a: CalendarPrefs, b: CalendarPrefs): boolean {\n return JSON.stringify(toStoredPrefs(a)) === JSON.stringify(toStoredPrefs(b));\n}\n\n/**\n * Today's calendar keeps a few settings on the device (`burdenoff-calendar-storage`, the\n * zustand store of the pages every other product shows). What the redesign takes from it the\n * first time the account has no calendar settings.\n */\nexport interface LegacyCalendarState {\n prefs: Partial<CalendarPrefs>;\n /**\n * The calendars ticked there (empty: all of them). The redesign keeps the unticked ones\n * instead, so these become hidden ids once the calendar list is known.\n */\n visibleCalendarIds: string[];\n}\n\n/**\n * Reads today's stored calendar state (`{ state: { currentView, selectedTimeZone,\n * visibleCalendars } }`). The last view used becomes the opening view (Year → Month,\n * Timeline → Week, Agenda → List). The zone is kept only when it isn't this device's: today's\n * store saves the device's zone even when nobody picked one, and keeping that would stop the\n * calendar following the device. Null when there is nothing to take.\n */\nexport function readLegacyCalendarState(\n stored: unknown,\n deviceTimeZone: string\n): LegacyCalendarState | null {\n const state = isRecord(stored) && isRecord(stored.state) ? stored.state : null;\n if (!state) return null;\n const prefs: Partial<CalendarPrefs> = {};\n const opening = viewForName(typeof state.currentView === 'string' ? state.currentView : null);\n if (opening) prefs.defaultView = opening;\n if (typeof state.selectedTimeZone === 'string') {\n const zone = canonicalTimeZone(state.selectedTimeZone);\n if (zone && zone !== canonicalTimeZone(deviceTimeZone)) prefs.timeZone = zone;\n }\n const visibleCalendarIds = parseCalendarIds(state.visibleCalendars) ?? [];\n if (Object.keys(prefs).length === 0 && visibleCalendarIds.length === 0) return null;\n return { prefs, visibleCalendarIds };\n}\n\n/**\n * The calendars to hide so that only `visibleIds` show, from all the person's calendars.\n * Nothing is hidden when `visibleIds` is empty (today's store reads that as \"all\") or names\n * none of the calendars (they were all removed since).\n */\nexport function hiddenFromVisible(\n visibleIds: readonly string[],\n allCalendarIds: readonly string[]\n): string[] {\n const visible = new Set(visibleIds);\n if (!allCalendarIds.some((id) => visible.has(id))) return [];\n return parseCalendarIds(allCalendarIds.filter((id) => !visible.has(id))) ?? [];\n}\n"],"mappings":";;;;AAgBA,IAAaA,IAAqB,YAMrBC,IAAuB,MAEvBC,IAAuB,OA0BvBC,IAAkD,OAAO,OAAO;CAC3E,UAAU;CACV,WAAW;CACX,WAAW;CACX,cAAc;CACd,aAAa;CACb,iBAAiB;CACjB,iBAAiB;CACjB,SAAS;CACT,cAAc;CACd,mBAAmB,CAAC;CACpB,WAAW;AACb,CAAC;AAED,SAASC,EAAS,GAAkD;CAClE,OAAO,OAAOC,KAAU,cAAYA,KAAkB,CAAC,MAAM,QAAQA,CAAK;AAC5E;AAEA,SAASC,EAAoB,GAAgB,GAAa,GAA8B;CACtF,OAAO,OAAOD,KAAU,YAAY,OAAO,UAAUA,CAAK,KAAKA,KAASE,KAAOF,KAASG;AAC1F;AA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AAO;EACL,GAAGhB;EACH,GAAGU;EACH,mBAAmB,CAAC,GAAIA,EAAM,qBAAqBV,EAAuB,iBAAkB;CAC9F;AACF;AAGA,SAAgBiB,EAAc,GAAqC;CACjE,OAAOD,EAAaP,EAAmBC,CAAK,CAAC;AAC/C;AA4BA,SAAgBQ,EACd,GACA,GAC4B;CAC5B,IAAMC,IAAQlB,EAASmB,CAAM,KAAKnB,EAASmB,EAAO,KAAK,IAAIA,EAAO,QAAQ;CAC1E,IAAI,CAACD,GAAO,OAAO;CACnB,IAAMT,IAAgC,CAAC,GACjCW,IAAUC,EAAY,OAAOH,EAAM,eAAgB,WAAWA,EAAM,cAAc,IAAI;CAE5F,IADIE,MAAS,EAAM,cAAcA,IAC7B,OAAOF,EAAM,oBAAqB,UAAU;EAC9C,IAAMR,IAAOC,EAAkBO,EAAM,gBAAgB;EACrD,AAAIR,KAAQA,MAASC,EAAkBW,CAAc,MAAG,EAAM,WAAWZ;CAC3E;CACA,IAAMa,IAAqBlB,EAAiBa,EAAM,gBAAgB,KAAK,CAAC;CAExE,OADI,OAAO,KAAKT,CAAK,CAAC,CAAC,WAAW,KAAKc,EAAmB,WAAW,IAAU,OACxE;EAAE;EAAO;CAAmB;AACrC;AAOA,SAAgBC,EACd,GACA,GACU;CACV,IAAMC,IAAU,IAAI,IAAIC,CAAU;CAElC,OADKC,EAAe,MAAM,MAAOF,EAAQ,IAAIlB,CAAE,CAAC,IACzCF,EAAiBsB,EAAe,QAAQ,MAAO,CAACF,EAAQ,IAAIlB,CAAE,CAAC,CAAC,KAAK,CAAC,IADnB,CAAC;AAE7D"}
1
+ {"version":3,"file":"calendarPrefs.js","names":["CALENDAR_PREFS_KEY","MAX_HIDDEN_CALENDARS","MAX_LISTED_CALENDARS","MAX_DEFAULT_DURATION","MAX_DEFAULT_REMINDER","DEFAULT_CALENDAR_PREFS","isRecord","value","isWholeNumberWithin","min","max","parseCalendarIds","ids","id","parseCalendarPrefs","prefs","zone","canonicalTimeZone","isWeekStart","isCalendarV2View","hidden","withDefaults","toStoredPrefs","readLegacyCalendarState","state","stored","opening","viewForName","deviceTimeZone","visibleCalendarIds","hiddenFromVisible","visible","visibleIds","allCalendarIds"],"sources":["../../../src/v2/prefs/calendarPrefs.ts"],"sourcesContent":["/**\n * The person's calendar settings (BOFF-15698 B3, operator decision 6): kept on their account\n * under the `calendar` key of global-auth-svc's preferences, so they follow the person across\n * devices and workspaces.\n *\n * `updateMyPreferences` merges the keys it is given into the stored ones one level deep, so\n * the whole `calendar` object is always written (`toStoredPrefs`); a partial write would drop\n * the keys it leaves out. Everything read back is checked (`parseCalendarPrefs`): a value that\n * isn't valid falls back to its default instead of breaking the calendar.\n */\nimport { canonicalTimeZone, type HourCycle, type WeekStart } from '@burdenoff/fe-libs/ui';\nimport { MAX_LISTED_CALENDARS } from '../limits';\nimport { isCalendarV2View, viewForName } from '../routes';\nimport { isWeekStart } from '../time/calendarTime';\nimport type { CalendarV2View } from '../types';\n\n/** The key the settings live under in the account's preferences. */\nexport const CALENDAR_PREFS_KEY = 'calendar';\n\n/** The most hidden calendars kept: as many as the calendar lists. */\nexport const MAX_HIDDEN_CALENDARS = MAX_LISTED_CALENDARS;\n/** Event lengths a person can default to, in minutes. */\nexport const MIN_DEFAULT_DURATION = 5;\nexport const MAX_DEFAULT_DURATION = 24 * 60;\n/** The earliest a default reminder can fire: four weeks before. */\nexport const MAX_DEFAULT_REMINDER = 4 * 7 * 24 * 60;\n\nexport interface CalendarPrefs {\n /** The IANA zone the calendar shows; null follows this device. */\n timeZone: string | null;\n /** `h23` 24-hour clock (the default), `h12` 12-hour. */\n hourCycle: HourCycle;\n /** 1 Monday (the default), 0 Sunday, 6 Saturday. */\n weekStart: WeekStart;\n showWeekends: boolean;\n /** The view the calendar opens on. */\n defaultView: CalendarV2View;\n /** Minutes a new event lasts. */\n defaultDuration: number;\n /** Minutes before an event its reminder fires; null for none. */\n defaultReminder: number | null;\n /** Fade events that have ended. */\n dimPast: boolean;\n /** Show events the person declined. */\n showDeclined: boolean;\n /** Calendars unticked in the rail. */\n hiddenCalendarIds: string[];\n /** The Workflow runs layer (decision 1: off until turned on). */\n runsLayer: boolean;\n}\n\nexport const DEFAULT_CALENDAR_PREFS: Readonly<CalendarPrefs> = Object.freeze({\n timeZone: null,\n hourCycle: 'h23',\n weekStart: 1,\n showWeekends: true,\n defaultView: 'week',\n defaultDuration: 60,\n defaultReminder: 10,\n dimPast: true,\n showDeclined: false,\n hiddenCalendarIds: [],\n runsLayer: false,\n});\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction isWholeNumberWithin(value: unknown, min: number, max: number): value is number {\n return typeof value === 'number' && Number.isInteger(value) && value >= min && value <= max;\n}\n\n/** The hidden calendar ids from a stored value: strings, no blanks or repeats, sorted. */\nfunction parseCalendarIds(value: unknown): string[] | undefined {\n if (!Array.isArray(value)) return undefined;\n const ids = value.filter((id): id is string => typeof id === 'string' && id.trim() !== '');\n return [...new Set(ids)].sort().slice(0, MAX_HIDDEN_CALENDARS);\n}\n\n/**\n * The valid settings in a stored value (anything else, or a value that isn't an object, gives\n * nothing). A time zone is kept as today's IANA name.\n */\nexport function parseCalendarPrefs(value: unknown): Partial<CalendarPrefs> {\n if (!isRecord(value)) return {};\n const prefs: Partial<CalendarPrefs> = {};\n if (value.timeZone === null) prefs.timeZone = null;\n else if (typeof value.timeZone === 'string') {\n const zone = canonicalTimeZone(value.timeZone);\n if (zone) prefs.timeZone = zone;\n }\n if (value.hourCycle === 'h23' || value.hourCycle === 'h12') prefs.hourCycle = value.hourCycle;\n if (isWeekStart(value.weekStart)) prefs.weekStart = value.weekStart;\n if (typeof value.showWeekends === 'boolean') prefs.showWeekends = value.showWeekends;\n if (isCalendarV2View(value.defaultView)) prefs.defaultView = value.defaultView;\n if (isWholeNumberWithin(value.defaultDuration, MIN_DEFAULT_DURATION, MAX_DEFAULT_DURATION)) {\n prefs.defaultDuration = value.defaultDuration;\n }\n if (value.defaultReminder === null) prefs.defaultReminder = null;\n else if (isWholeNumberWithin(value.defaultReminder, 0, MAX_DEFAULT_REMINDER)) {\n prefs.defaultReminder = value.defaultReminder;\n }\n if (typeof value.dimPast === 'boolean') prefs.dimPast = value.dimPast;\n if (typeof value.showDeclined === 'boolean') prefs.showDeclined = value.showDeclined;\n const hidden = parseCalendarIds(value.hiddenCalendarIds);\n if (hidden) prefs.hiddenCalendarIds = hidden;\n if (typeof value.runsLayer === 'boolean') prefs.runsLayer = value.runsLayer;\n return prefs;\n}\n\n/** Complete settings: `prefs` over the defaults. */\nexport function withDefaults(prefs: Partial<CalendarPrefs>): CalendarPrefs {\n return {\n ...DEFAULT_CALENDAR_PREFS,\n ...prefs,\n hiddenCalendarIds: [...(prefs.hiddenCalendarIds ?? DEFAULT_CALENDAR_PREFS.hiddenCalendarIds)],\n };\n}\n\n/** The settings as stored: every key, checked, so a write never drops one. */\nexport function toStoredPrefs(prefs: CalendarPrefs): CalendarPrefs {\n return withDefaults(parseCalendarPrefs(prefs));\n}\n\n/** Whether two complete settings say the same. */\nexport function samePrefs(a: CalendarPrefs, b: CalendarPrefs): boolean {\n return JSON.stringify(toStoredPrefs(a)) === JSON.stringify(toStoredPrefs(b));\n}\n\n/**\n * Today's calendar keeps a few settings on the device (`burdenoff-calendar-storage`, the\n * zustand store of the pages every other product shows). What the redesign takes from it the\n * first time the account has no calendar settings.\n */\nexport interface LegacyCalendarState {\n prefs: Partial<CalendarPrefs>;\n /**\n * The calendars ticked there (empty: all of them). The redesign keeps the unticked ones\n * instead, so these become hidden ids once the calendar list is known.\n */\n visibleCalendarIds: string[];\n}\n\n/**\n * Reads today's stored calendar state (`{ state: { currentView, selectedTimeZone,\n * visibleCalendars } }`). The last view used becomes the opening view (Year → Month,\n * Timeline → Week, Agenda → List). The zone is kept only when it isn't this device's: today's\n * store saves the device's zone even when nobody picked one, and keeping that would stop the\n * calendar following the device. Null when there is nothing to take.\n */\nexport function readLegacyCalendarState(\n stored: unknown,\n deviceTimeZone: string\n): LegacyCalendarState | null {\n const state = isRecord(stored) && isRecord(stored.state) ? stored.state : null;\n if (!state) return null;\n const prefs: Partial<CalendarPrefs> = {};\n const opening = viewForName(typeof state.currentView === 'string' ? state.currentView : null);\n if (opening) prefs.defaultView = opening;\n if (typeof state.selectedTimeZone === 'string') {\n const zone = canonicalTimeZone(state.selectedTimeZone);\n if (zone && zone !== canonicalTimeZone(deviceTimeZone)) prefs.timeZone = zone;\n }\n const visibleCalendarIds = parseCalendarIds(state.visibleCalendars) ?? [];\n if (Object.keys(prefs).length === 0 && visibleCalendarIds.length === 0) return null;\n return { prefs, visibleCalendarIds };\n}\n\n/**\n * The calendars to hide so that only `visibleIds` show, from all the person's calendars.\n * Nothing is hidden when `visibleIds` is empty (today's store reads that as \"all\") or names\n * none of the calendars (they were all removed since).\n */\nexport function hiddenFromVisible(\n visibleIds: readonly string[],\n allCalendarIds: readonly string[]\n): string[] {\n const visible = new Set(visibleIds);\n if (!allCalendarIds.some((id) => visible.has(id))) return [];\n return parseCalendarIds(allCalendarIds.filter((id) => !visible.has(id))) ?? [];\n}\n"],"mappings":";;;;;AAiBA,IAAaA,IAAqB,YAGrBC,IAAuBC,GAGvBC,IAAuB,MAEvBC,IAAuB,OA0BvBC,IAAkD,OAAO,OAAO;CAC3E,UAAU;CACV,WAAW;CACX,WAAW;CACX,cAAc;CACd,aAAa;CACb,iBAAiB;CACjB,iBAAiB;CACjB,SAAS;CACT,cAAc;CACd,mBAAmB,CAAC;CACpB,WAAW;AACb,CAAC;AAED,SAASC,EAAS,GAAkD;CAClE,OAAO,OAAOC,KAAU,cAAYA,KAAkB,CAAC,MAAM,QAAQA,CAAK;AAC5E;AAEA,SAASC,EAAoB,GAAgB,GAAa,GAA8B;CACtF,OAAO,OAAOD,KAAU,YAAY,OAAO,UAAUA,CAAK,KAAKA,KAASE,KAAOF,KAASG;AAC1F;AAGA,SAASC,EAAiB,GAAsC;CAC9D,IAAI,CAAC,M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CAAC,GAAIA,EAAM,qBAAqBV,EAAuB,iBAAkB;CAC9F;AACF;AAGA,SAAgBiB,EAAc,GAAqC;CACjE,OAAOD,EAAaP,EAAmBC,CAAK,CAAC;AAC/C;AA4BA,SAAgBQ,EACd,GACA,GAC4B;CAC5B,IAAMC,IAAQlB,EAASmB,CAAM,KAAKnB,EAASmB,EAAO,KAAK,IAAIA,EAAO,QAAQ;CAC1E,IAAI,CAACD,GAAO,OAAO;CACnB,IAAMT,IAAgC,CAAC,GACjCW,IAAUC,EAAY,OAAOH,EAAM,eAAgB,WAAWA,EAAM,cAAc,IAAI;CAE5F,IADIE,MAAS,EAAM,cAAcA,IAC7B,OAAOF,EAAM,oBAAqB,UAAU;EAC9C,IAAMR,IAAOC,EAAkBO,EAAM,gBAAgB;EACrD,AAAIR,KAAQA,MAASC,EAAkBW,CAAc,MAAG,EAAM,WAAWZ;CAC3E;CACA,IAAMa,IAAqBlB,EAAiBa,EAAM,gBAAgB,KAAK,CAAC;CAExE,OADI,OAAO,KAAKT,CAAK,CAAC,CAAC,WAAW,KAAKc,EAAmB,WAAW,IAAU,OACxE;EAAE;EAAO;CAAmB;AACrC;AAOA,SAAgBC,EACd,GACA,GACU;CACV,IAAMC,IAAU,IAAI,IAAIC,CAAU;CAElC,OADKC,EAAe,MAAM,MAAOF,EAAQ,IAAIlB,CAAE,CAAC,IACzCF,EAAiBsB,EAAe,QAAQ,MAAO,CAACF,EAAQ,IAAIlB,CAAE,CAAC,CAAC,KAAK,CAAC,IADnB,CAAC;AAE7D"}
@@ -0,0 +1,3 @@
1
+ export declare function CalendarRail(): import('react').JSX.Element;
2
+ /** Phones: the rail in a sheet. */
3
+ export declare function RailSheet(): import('react').JSX.Element | null;
@@ -0,0 +1,258 @@
1
+ import { calendarHueStyle as e } from "../colors.js";
2
+ import { useCalendarPage as t } from "../page/CalendarPageContext.js";
3
+ import { useCalendarV2Store as n } from "../state/calendarV2Store.js";
4
+ import { startOfDayInZone as r } from "../time/calendarTime.js";
5
+ import { FOCUS_RING as i, ICON_BUTTON as a, OVERLINE as o } from "../styles.js";
6
+ import { RoomChip as s } from "../day/DayPanel.js";
7
+ import { WorkflowRunsSwitch as c } from "../runs/RunsSwitch.js";
8
+ import { roomNow as l } from "./railStatus.js";
9
+ import { calendarSubline as u } from "./syncWords.js";
10
+ import { useMonthEventDates as d } from "./useMonthEventDates.js";
11
+ import { useState as f } from "react";
12
+ import { Building2 as p, Check as m, ChevronDown as h, ChevronRight as g, Plus as _, RefreshCw as v } from "lucide-react";
13
+ import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
14
+ import { ActionMenu as S, BottomSheet as C, BottomSheetContent as w, BottomSheetDescription as T, BottomSheetTitle as E, MiniMonth as D, addDays as O, monthOf as k } from "@burdenoff/fe-libs/ui";
15
+ import { cn as A } from "@burdenoff/fe-libs/utils";
16
+ // src/v2/rail/CalendarRail.tsx
17
+ var j = 5;
18
+ function M({ id: e, title: t, action: n, children: r }) {
19
+ let [a, s] = f(!0), c = `calendar-rail-${e}`;
20
+ return /* @__PURE__ */ x("section", {
21
+ "aria-labelledby": c,
22
+ className: "flex flex-col gap-1",
23
+ children: [/* @__PURE__ */ x("div", {
24
+ className: "flex items-center gap-1",
25
+ children: [/* @__PURE__ */ x("button", {
26
+ type: "button",
27
+ id: c,
28
+ "aria-expanded": a,
29
+ onClick: () => s((e) => !e),
30
+ className: A("flex flex-1 items-center gap-1.5 rounded-sm py-1 text-start", o, i),
31
+ children: [a ? /* @__PURE__ */ b(h, {
32
+ className: "size-3",
33
+ "aria-hidden": "true"
34
+ }) : /* @__PURE__ */ b(g, {
35
+ className: "size-3 rtl:rotate-180",
36
+ "aria-hidden": "true"
37
+ }), t]
38
+ }), n]
39
+ }), a ? /* @__PURE__ */ b("div", {
40
+ className: "flex flex-col gap-0.5",
41
+ children: r
42
+ }) : null]
43
+ });
44
+ }
45
+ function N({ calendar: r }) {
46
+ let a = t(), { tr: o } = a, s = n((e) => e.toggleCalendar), c = n((e) => e.setHiddenCalendars), l = !a.hiddenCalendarIds.has(r.id), d = u(a, r), f = [{
47
+ id: "only",
48
+ label: o("calendar.v2.showOnly", "Show only this one"),
49
+ onSelect: () => c(a.calendars.filter((e) => e.id !== r.id).map((e) => e.id))
50
+ }];
51
+ return r.sync?.provider === "ICS_URL" && f.push({
52
+ id: "check",
53
+ label: o("calendar.v2.checkNow", "Check for changes now"),
54
+ icon: v,
55
+ onSelect: () => void a.actions.checkSyncNow(r)
56
+ }), r.section === "mine" ? f.push({
57
+ id: "share",
58
+ label: o("calendar.v2.shareMenu", "Share…"),
59
+ onSelect: () => a.nav.openDialog("share")
60
+ }, {
61
+ id: "settings",
62
+ label: o("calendar.v2.calendarSettings", "Calendar settings"),
63
+ onSelect: () => a.nav.openDialog("settings")
64
+ }) : f.push({
65
+ id: "manage",
66
+ label: o("calendar.v2.subscribeShare", "Subscribe & share"),
67
+ onSelect: () => a.nav.openDialog("share")
68
+ }), /* @__PURE__ */ x("div", {
69
+ className: "group flex items-center gap-1 rounded-md hover:bg-bg-sunken",
70
+ style: e(a.hueOf(r.id)),
71
+ children: [/* @__PURE__ */ x("button", {
72
+ type: "button",
73
+ role: "checkbox",
74
+ "aria-checked": l,
75
+ onClick: () => s(r.id),
76
+ className: A("flex min-w-0 flex-1 items-start gap-2.5 rounded-md px-1.5 py-1.5 text-start", i),
77
+ children: [/* @__PURE__ */ b("span", {
78
+ "aria-hidden": "true",
79
+ className: A("mt-0.5 grid size-4 shrink-0 place-items-center rounded-[4px] border-2 border-[var(--cal-hue)]", l ? "bg-[var(--cal-hue)] text-bg-surface" : "bg-transparent"),
80
+ children: l ? /* @__PURE__ */ b(m, {
81
+ className: "size-3",
82
+ strokeWidth: 3,
83
+ "aria-hidden": "true"
84
+ }) : null
85
+ }), /* @__PURE__ */ x("span", {
86
+ className: "flex min-w-0 flex-col",
87
+ children: [/* @__PURE__ */ b("b", {
88
+ className: "truncate text-sm font-medium text-text-primary",
89
+ children: r.name
90
+ }), /* @__PURE__ */ b("small", {
91
+ className: A("truncate text-xs", d.tone === "bad" ? "font-medium text-status-error-text" : d.tone === "warn" ? "text-status-warning-text" : "text-text-secondary"),
92
+ children: d.text
93
+ })]
94
+ })]
95
+ }), /* @__PURE__ */ b(S, {
96
+ items: f,
97
+ placement: "row",
98
+ label: o("calendar.v2.optionsFor", "Options for {{name}}", { name: r.name }),
99
+ className: "opacity-70 group-hover:opacity-100 focus-visible:opacity-100"
100
+ })]
101
+ });
102
+ }
103
+ function P() {
104
+ let { nav: e } = t();
105
+ return /* @__PURE__ */ b(F, {}, k(e.date));
106
+ }
107
+ function F() {
108
+ let e = t(), { nav: n, timeZone: r } = e, [i, a] = f(() => k(n.date)), o = d(e, i), s = n.view === "month" ? null : {
109
+ start: e.days[0] ?? n.date,
110
+ end: e.days[e.days.length - 1] ?? n.date
111
+ };
112
+ return /* @__PURE__ */ b(D, {
113
+ month: i,
114
+ onMonthChange: a,
115
+ size: "sm",
116
+ value: n.date,
117
+ range: s,
118
+ eventDates: o ?? void 0,
119
+ weekStartsOn: e.prefs.weekStart,
120
+ today: e.today,
121
+ timeZone: r,
122
+ locale: e.format.locale,
123
+ onSelect: (t) => {
124
+ n.goTo({ date: t }), e.setRailSheetOpen(!1);
125
+ }
126
+ });
127
+ }
128
+ function I({ label: e, onClick: t }) {
129
+ return /* @__PURE__ */ b("button", {
130
+ type: "button",
131
+ className: a,
132
+ "aria-label": e,
133
+ title: e,
134
+ onClick: t,
135
+ children: /* @__PURE__ */ b(_, { "aria-hidden": "true" })
136
+ });
137
+ }
138
+ function L() {
139
+ let e = t(), { tr: n, nav: r } = e, i = e.calendars.filter((e) => e.section === "mine"), a = e.calendars.filter((e) => e.section === "other");
140
+ return /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ x(M, {
141
+ id: "mine",
142
+ title: n("calendar.v2.myCalendars", "My calendars"),
143
+ action: /* @__PURE__ */ b(I, {
144
+ label: n("calendar.v2.newCalendar", "New calendar"),
145
+ onClick: () => r.openDialog("settings")
146
+ }),
147
+ children: [i.map((e) => /* @__PURE__ */ b(N, { calendar: e }, e.id)), e.calendarsStatus === "ready" && i.length === 0 ? /* @__PURE__ */ b("p", {
148
+ className: "px-1.5 text-sm text-text-secondary",
149
+ children: n("calendar.v2.noCalendars", "No calendars yet.")
150
+ }) : null]
151
+ }), /* @__PURE__ */ b(M, {
152
+ id: "other",
153
+ title: n("calendar.v2.otherCalendars", "Other calendars"),
154
+ action: /* @__PURE__ */ b(I, {
155
+ label: n("calendar.v2.addCalendar", "Add a calendar"),
156
+ onClick: () => r.openDialog("share")
157
+ }),
158
+ children: a.length > 0 ? a.map((e) => /* @__PURE__ */ b(N, { calendar: e }, e.id)) : /* @__PURE__ */ b("p", {
159
+ className: "px-1.5 text-sm text-text-secondary",
160
+ children: n("calendar.v2.otherEmpty", "Calendars you follow by link, and teammates’ calendars shared with you, show here.")
161
+ })
162
+ })] });
163
+ }
164
+ function R({ room: e }) {
165
+ let n = t(), { tr: a } = n, o = r(O(n.today, 1), n.timeZone), c = [e.capacity ? a("calendar.v2.seats", "{{count}} seats", { count: e.capacity }) : null, e.place].filter(Boolean).join(" · ");
166
+ return /* @__PURE__ */ x("button", {
167
+ type: "button",
168
+ onClick: () => n.nav.openDialog("rooms"),
169
+ className: A("flex items-center gap-2 rounded-md px-1.5 py-1.5 text-start hover:bg-bg-sunken", i),
170
+ children: [
171
+ /* @__PURE__ */ b("span", {
172
+ "aria-hidden": "true",
173
+ className: "grid size-6 shrink-0 place-items-center rounded-md bg-bg-sunken text-text-secondary",
174
+ children: /* @__PURE__ */ b(p, { className: "size-3.5" })
175
+ }),
176
+ /* @__PURE__ */ x("span", {
177
+ className: "flex min-w-0 flex-1 flex-col",
178
+ children: [/* @__PURE__ */ b("b", {
179
+ className: "truncate text-sm font-medium text-text-primary",
180
+ children: e.name
181
+ }), /* @__PURE__ */ b("small", {
182
+ className: "truncate text-xs text-text-secondary",
183
+ children: c
184
+ })]
185
+ }),
186
+ /* @__PURE__ */ b(s, { state: l(e, n.now, o) })
187
+ ]
188
+ });
189
+ }
190
+ function z() {
191
+ let e = t(), { tr: n } = e, { rooms: r, status: a } = e.rooms, o;
192
+ return o = a === "error" ? /* @__PURE__ */ b("p", {
193
+ className: "px-1.5 text-sm text-text-secondary",
194
+ children: n("calendar.v2.roomsFailed", "Couldn’t load the rooms.")
195
+ }) : r.length === 0 ? /* @__PURE__ */ b("p", {
196
+ className: "px-1.5 text-sm text-text-secondary",
197
+ children: a === "loading" ? n("calendar.v2.loadingRooms", "Loading rooms…") : n("calendar.v2.noRooms", "No rooms yet.")
198
+ }) : r.slice(0, j).map((e) => /* @__PURE__ */ b(R, { room: e }, e.id)), /* @__PURE__ */ x(M, {
199
+ id: "rooms",
200
+ title: n("calendar.v2.rooms", "Rooms"),
201
+ children: [o, /* @__PURE__ */ x("button", {
202
+ type: "button",
203
+ onClick: () => e.nav.openDialog("rooms"),
204
+ className: A("mt-0.5 inline-flex items-center gap-1 self-start rounded-sm px-1.5 text-xs font-semibold text-text-link hover:underline", i),
205
+ children: [n("calendar.v2.seeRooms", "See all rooms and equipment"), /* @__PURE__ */ b(g, {
206
+ className: "size-3 rtl:rotate-180",
207
+ "aria-hidden": "true"
208
+ })]
209
+ })]
210
+ });
211
+ }
212
+ function B() {
213
+ let { tr: e } = t();
214
+ return /* @__PURE__ */ b(M, {
215
+ id: "layers",
216
+ title: e("calendar.v2.alsoShow", "Also show"),
217
+ children: /* @__PURE__ */ b(c, {})
218
+ });
219
+ }
220
+ function V() {
221
+ return /* @__PURE__ */ x("div", {
222
+ className: "flex flex-col gap-4",
223
+ children: [
224
+ /* @__PURE__ */ b(P, {}),
225
+ /* @__PURE__ */ b(L, {}),
226
+ /* @__PURE__ */ b(z, {}),
227
+ /* @__PURE__ */ b(B, {})
228
+ ]
229
+ });
230
+ }
231
+ function H() {
232
+ let e = t(), { tr: n } = e;
233
+ if (!e.compact) return null;
234
+ let r = e.calendars.filter((t) => !e.hiddenCalendarIds.has(t.id)).length;
235
+ return /* @__PURE__ */ b(C, {
236
+ open: e.railSheetOpen,
237
+ onOpenChange: e.setRailSheetOpen,
238
+ children: /* @__PURE__ */ x(w, {
239
+ className: "max-h-[88dvh] gap-0 p-0",
240
+ children: [/* @__PURE__ */ x("div", {
241
+ className: "border-b border-border-subtle px-4 py-3",
242
+ children: [/* @__PURE__ */ b(E, {
243
+ className: "text-base font-bold text-text-primary",
244
+ children: n("calendar.v2.calendars", "Calendars")
245
+ }), /* @__PURE__ */ b(T, {
246
+ className: "text-xs text-text-secondary",
247
+ children: r === 1 ? n("calendar.v2.calendarsShownOne", "1 calendar shown") : n("calendar.v2.calendarsShown", "{{count}} calendars shown", { count: r })
248
+ })]
249
+ }), /* @__PURE__ */ b("div", {
250
+ className: "min-h-0 overflow-y-auto p-4",
251
+ children: /* @__PURE__ */ b(V, {})
252
+ })]
253
+ })
254
+ });
255
+ }
256
+ export { V as CalendarRail, H as RailSheet };
257
+
258
+ //# sourceMappingURL=CalendarRail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CalendarRail.js","names":["_Fragment","RAIL_ROOMS","Section","open","setOpen","useState","headingId","id","value","cn","OVERLINE","FOCUS_RING","ChevronDown","ChevronRight","title","action","CalendarRow","page","useCalendarPage","toggleCalendar","useCalendarV2Store","state","setHiddenCalendars","shown","calendar","sub","calendarSubline","menu","tr","item","RefreshCw","calendarHueStyle","Check","ActionMenu","RailMonth","RailMiniMonth","monthOf","nav","month","setMonth","eventDates","useMonthEventDates","band","MiniMonth","AddButton","ICON_BUTTON","label","Plus","CalendarSections","mine","other","Fragment","RoomRow","tomorrow","startOfDayInZone","addDays","details","room","Building2","RoomChip","roomNow","RoomsSection","content","status","rooms","LayersSection","WorkflowRunsSwitch","CalendarRail","RailSheet","BottomSheet","BottomSheetContent","BottomSheetTitle","BottomSheetDescription"],"sources":["../../../src/v2/rail/CalendarRail.tsx"],"sourcesContent":["/**\n * The rail (BOFF-15698 A1): a mini month (the shown days banded, days with events dotted), My\n * calendars (colour toggles, ⋯), Other calendars (followed by link, shared with you; a stopped\n * sync in red with its reason), Rooms (their state now; they open Rooms & resources) and the\n * Workflow runs switch (B5, `WorkflowRunsSwitch`). A column on wide screens; a sheet on phones\n * (`RailSheet`).\n */\nimport { useState, type ReactNode } from 'react';\nimport { Building2, Check, ChevronDown, ChevronRight, Plus, RefreshCw } from 'lucide-react';\nimport {\n ActionMenu,\n addDays,\n BottomSheet,\n BottomSheetContent,\n BottomSheetDescription,\n BottomSheetTitle,\n MiniMonth,\n monthOf,\n type ActionMenuItem,\n type DateRange,\n} from '@burdenoff/fe-libs/ui';\nimport { cn } from '@burdenoff/fe-libs/utils';\nimport { calendarHueStyle } from '../colors';\nimport { useCalendarPage } from '../page/CalendarPageContext';\nimport { useCalendarV2Store } from '../state/calendarV2Store';\nimport { startOfDayInZone } from '../time/calendarTime';\nimport { FOCUS_RING, ICON_BUTTON, OVERLINE } from '../styles';\nimport type { RoomV2 } from '../data/useRoomsV2';\nimport type { CalendarV2 } from '../types';\nimport { RoomChip } from '../day/DayPanel';\nimport { WorkflowRunsSwitch } from '../runs/RunsSwitch';\nimport { roomNow } from './railStatus';\nimport { calendarSubline } from './syncWords';\nimport { useMonthEventDates } from './useMonthEventDates';\n\n/** Rooms listed in the rail before \"See all rooms\". */\nconst RAIL_ROOMS = 5;\n\nfunction Section({\n id,\n title,\n action,\n children,\n}: {\n id: string;\n title: string;\n action?: ReactNode;\n children: ReactNode;\n}) {\n const [open, setOpen] = useState(true);\n const headingId = `calendar-rail-${id}`;\n return (\n <section aria-labelledby={headingId} className=\"flex flex-col gap-1\">\n <div className=\"flex items-center gap-1\">\n <button\n type=\"button\"\n id={headingId}\n aria-expanded={open}\n onClick={() => setOpen((value) => !value)}\n className={cn(\n 'flex flex-1 items-center gap-1.5 rounded-sm py-1 text-start',\n OVERLINE,\n FOCUS_RING\n )}\n >\n {open ? (\n <ChevronDown className=\"size-3\" aria-hidden=\"true\" />\n ) : (\n <ChevronRight className=\"size-3 rtl:rotate-180\" aria-hidden=\"true\" />\n )}\n {title}\n </button>\n {action}\n </div>\n {open ? <div className=\"flex flex-col gap-0.5\">{children}</div> : null}\n </section>\n );\n}\n\nfunction CalendarRow({ calendar }: { calendar: CalendarV2 }) {\n const page = useCalendarPage();\n const { tr } = page;\n const toggleCalendar = useCalendarV2Store((state) => state.toggleCalendar);\n const setHiddenCalendars = useCalendarV2Store((state) => state.setHiddenCalendars);\n const shown = !page.hiddenCalendarIds.has(calendar.id);\n const sub = calendarSubline(page, calendar);\n const menu: ActionMenuItem[] = [\n {\n id: 'only',\n label: tr('calendar.v2.showOnly', 'Show only this one'),\n onSelect: () =>\n setHiddenCalendars(\n page.calendars.filter((item) => item.id !== calendar.id).map((item) => item.id)\n ),\n },\n ];\n if (calendar.sync?.provider === 'ICS_URL') {\n menu.push({\n id: 'check',\n label: tr('calendar.v2.checkNow', 'Check for changes now'),\n icon: RefreshCw,\n onSelect: () => void page.actions.checkSyncNow(calendar),\n });\n }\n if (calendar.section === 'mine') {\n menu.push(\n {\n id: 'share',\n label: tr('calendar.v2.shareMenu', 'Share…'),\n onSelect: () => page.nav.openDialog('share'),\n },\n {\n id: 'settings',\n label: tr('calendar.v2.calendarSettings', 'Calendar settings'),\n onSelect: () => page.nav.openDialog('settings'),\n }\n );\n } else {\n menu.push({\n id: 'manage',\n label: tr('calendar.v2.subscribeShare', 'Subscribe & share'),\n onSelect: () => page.nav.openDialog('share'),\n });\n }\n return (\n <div\n className=\"group flex items-center gap-1 rounded-md hover:bg-bg-sunken\"\n style={calendarHueStyle(page.hueOf(calendar.id))}\n >\n <button\n type=\"button\"\n role=\"checkbox\"\n aria-checked={shown}\n onClick={() => toggleCalendar(calendar.id)}\n className={cn(\n 'flex min-w-0 flex-1 items-start gap-2.5 rounded-md px-1.5 py-1.5 text-start',\n FOCUS_RING\n )}\n >\n <span\n aria-hidden=\"true\"\n className={cn(\n 'mt-0.5 grid size-4 shrink-0 place-items-center rounded-[4px] border-2 border-[var(--cal-hue)]',\n shown ? 'bg-[var(--cal-hue)] text-bg-surface' : 'bg-transparent'\n )}\n >\n {shown ? <Check className=\"size-3\" strokeWidth={3} aria-hidden=\"true\" /> : null}\n </span>\n <span className=\"flex min-w-0 flex-col\">\n <b className=\"truncate text-sm font-medium text-text-primary\">{calendar.name}</b>\n <small\n className={cn(\n 'truncate text-xs',\n sub.tone === 'bad'\n ? 'font-medium text-status-error-text'\n : sub.tone === 'warn'\n ? 'text-status-warning-text'\n : 'text-text-secondary'\n )}\n >\n {sub.text}\n </small>\n </span>\n </button>\n <ActionMenu\n items={menu}\n placement=\"row\"\n label={tr('calendar.v2.optionsFor', 'Options for {{name}}', { name: calendar.name })}\n className=\"opacity-70 group-hover:opacity-100 focus-visible:opacity-100\"\n />\n </div>\n );\n}\n\n/** The mini month: the shown days banded, days with events dotted; a day opens it. */\n/** The mini month starts again at the views' month whenever that changes. */\nfunction RailMonth() {\n const { nav } = useCalendarPage();\n return <RailMiniMonth key={monthOf(nav.date)} />;\n}\n\nfunction RailMiniMonth() {\n const page = useCalendarPage();\n const { nav, timeZone } = page;\n const [month, setMonth] = useState(() => monthOf(nav.date));\n const eventDates = useMonthEventDates(page, month);\n const band: DateRange | null =\n nav.view === 'month'\n ? null\n : { start: page.days[0] ?? nav.date, end: page.days[page.days.length - 1] ?? nav.date };\n return (\n <MiniMonth\n month={month}\n onMonthChange={setMonth}\n size=\"sm\"\n value={nav.date}\n range={band}\n eventDates={eventDates ?? undefined}\n weekStartsOn={page.prefs.weekStart}\n today={page.today}\n timeZone={timeZone}\n locale={page.format.locale}\n onSelect={(date) => {\n nav.goTo({ date });\n page.setRailSheetOpen(false);\n }}\n />\n );\n}\n\n/** A section's \"+\" button. */\nfunction AddButton({ label, onClick }: { label: string; onClick: () => void }) {\n return (\n <button\n type=\"button\"\n className={ICON_BUTTON}\n aria-label={label}\n title={label}\n onClick={onClick}\n >\n <Plus aria-hidden=\"true\" />\n </button>\n );\n}\n\nfunction CalendarSections() {\n const page = useCalendarPage();\n const { tr, nav } = page;\n const mine = page.calendars.filter((calendar) => calendar.section === 'mine');\n const other = page.calendars.filter((calendar) => calendar.section === 'other');\n return (\n <>\n <Section\n id=\"mine\"\n title={tr('calendar.v2.myCalendars', 'My calendars')}\n action={\n <AddButton\n label={tr('calendar.v2.newCalendar', 'New calendar')}\n onClick={() => nav.openDialog('settings')}\n />\n }\n >\n {mine.map((calendar) => (\n <CalendarRow key={calendar.id} calendar={calendar} />\n ))}\n {page.calendarsStatus === 'ready' && mine.length === 0 ? (\n <p className=\"px-1.5 text-sm text-text-secondary\">\n {tr('calendar.v2.noCalendars', 'No calendars yet.')}\n </p>\n ) : null}\n </Section>\n <Section\n id=\"other\"\n title={tr('calendar.v2.otherCalendars', 'Other calendars')}\n action={\n <AddButton\n label={tr('calendar.v2.addCalendar', 'Add a calendar')}\n onClick={() => nav.openDialog('share')}\n />\n }\n >\n {other.length > 0 ? (\n other.map((calendar) => <CalendarRow key={calendar.id} calendar={calendar} />)\n ) : (\n <p className=\"px-1.5 text-sm text-text-secondary\">\n {tr(\n 'calendar.v2.otherEmpty',\n 'Calendars you follow by link, and teammates’ calendars shared with you, show here.'\n )}\n </p>\n )}\n </Section>\n </>\n );\n}\n\nfunction RoomRow({ room }: { room: RoomV2 }) {\n const page = useCalendarPage();\n const { tr } = page;\n const tomorrow = startOfDayInZone(addDays(page.today, 1), page.timeZone);\n const details = [\n room.capacity ? tr('calendar.v2.seats', '{{count}} seats', { count: room.capacity }) : null,\n room.place,\n ]\n .filter(Boolean)\n .join(' · ');\n return (\n <button\n type=\"button\"\n onClick={() => page.nav.openDialog('rooms')}\n className={cn(\n 'flex items-center gap-2 rounded-md px-1.5 py-1.5 text-start hover:bg-bg-sunken',\n FOCUS_RING\n )}\n >\n <span\n aria-hidden=\"true\"\n className=\"grid size-6 shrink-0 place-items-center rounded-md bg-bg-sunken text-text-secondary\"\n >\n <Building2 className=\"size-3.5\" />\n </span>\n <span className=\"flex min-w-0 flex-1 flex-col\">\n <b className=\"truncate text-sm font-medium text-text-primary\">{room.name}</b>\n <small className=\"truncate text-xs text-text-secondary\">{details}</small>\n </span>\n <RoomChip state={roomNow(room, page.now, tomorrow)} />\n </button>\n );\n}\n\nfunction RoomsSection() {\n const page = useCalendarPage();\n const { tr } = page;\n const { rooms, status } = page.rooms;\n let content;\n if (status === 'error') {\n content = (\n <p className=\"px-1.5 text-sm text-text-secondary\">\n {tr('calendar.v2.roomsFailed', 'Couldn’t load the rooms.')}\n </p>\n );\n } else if (rooms.length === 0) {\n content = (\n <p className=\"px-1.5 text-sm text-text-secondary\">\n {status === 'loading'\n ? tr('calendar.v2.loadingRooms', 'Loading rooms…')\n : tr('calendar.v2.noRooms', 'No rooms yet.')}\n </p>\n );\n } else {\n content = rooms.slice(0, RAIL_ROOMS).map((room) => <RoomRow key={room.id} room={room} />);\n }\n return (\n <Section id=\"rooms\" title={tr('calendar.v2.rooms', 'Rooms')}>\n {content}\n <button\n type=\"button\"\n onClick={() => page.nav.openDialog('rooms')}\n className={cn(\n 'mt-0.5 inline-flex items-center gap-1 self-start rounded-sm px-1.5 text-xs font-semibold text-text-link hover:underline',\n FOCUS_RING\n )}\n >\n {tr('calendar.v2.seeRooms', 'See all rooms and equipment')}\n <ChevronRight className=\"size-3 rtl:rotate-180\" aria-hidden=\"true\" />\n </button>\n </Section>\n );\n}\n\n/** The Workflow runs layer's switch (B5). */\nfunction LayersSection() {\n const { tr } = useCalendarPage();\n return (\n <Section id=\"layers\" title={tr('calendar.v2.alsoShow', 'Also show')}>\n <WorkflowRunsSwitch />\n </Section>\n );\n}\n\nexport function CalendarRail() {\n return (\n <div className=\"flex flex-col gap-4\">\n <RailMonth />\n <CalendarSections />\n <RoomsSection />\n <LayersSection />\n </div>\n );\n}\n\n/** Phones: the rail in a sheet. */\nexport function RailSheet() {\n const page = useCalendarPage();\n const { tr } = page;\n if (!page.compact) return null;\n const shown = page.calendars.filter(\n (calendar) => !page.hiddenCalendarIds.has(calendar.id)\n ).length;\n return (\n <BottomSheet open={page.railSheetOpen} onOpenChange={page.setRailSheetOpen}>\n <BottomSheetContent className=\"max-h-[88dvh] gap-0 p-0\">\n <div className=\"border-b border-border-subtle px-4 py-3\">\n <BottomSheetTitle className=\"text-base font-bold text-text-primary\">\n {tr('calendar.v2.calendars', 'Calendars')}\n </BottomSheetTitle>\n <BottomSheetDescription className=\"text-xs text-text-secondary\">\n {shown === 1\n ? tr('calendar.v2.calendarsShownOne', '1 calendar shown')\n : tr('calendar.v2.calendarsShown', '{{count}} calendars shown', { count: shown })}\n </BottomSheetDescription>\n </div>\n <div className=\"min-h-0 overflow-y-auto p-4\">\n <CalendarRail />\n </div>\n </BottomSheetContent>\n </BottomSheet>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoCA,IAAMC,IAAa;AAEnB,SAASC,EAAQ,EACf,OACA,UACA,WACA,eAMC;CACD,IAAM,CAACC,GAAMC,KAAWC,EAAS,EAAI,GAC/BC,IAAY,iBAAiBC;CACnC,OACE,kBAAC,WAAD;EAAS,mBAAiBD;EAAW,WAAU;EAA/C,UAAA,CACE,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,kBAAC,UAAD;IACE,MAAK;IACL,IAAIA;IACJ,iBAAeH;IACf,eAAeC,GAAS,MAAU,CAACI,CAAK;IACxC,WAAWC,EACT,+DACAC,GACAC,CACF;IATF,UAAA,CAWGR,IACC,kBAACS,GAAD;KAAa,WAAU;KAAS,eAAY;IAAQ,CAAA,IAEpD,kBAACC,GAAD;KAAc,WAAU;KAAwB,eAAY;IAAQ,CAAA,GAErEC,CACK;GACP,CAAA,GAAAC,CACE;EACJ,CAAA,GAAAZ,IAAO,kBAAC,OAAD;GAAK,WAAU;GAAyB;EAAc,CAAA,IAAI,IAC3D;;AAEb;AAEA,SAASa,EAAY,EAAE,eAAsC;CAC3D,IAAMC,IAAOC,EAAgB,GACvB,EAAE,UAAOD,GACTE,IAAiBC,GAAoB,MAAUC,E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,8BAA8B,6BAA6B,EAAE,OAAOL,EAAM,CAAC;IAC5D,CAAA,CACrB;GACL,CAAA,GAAA,kBAAC,OAAD;IAAK,WAAU;IACb,UAAA,kBAAC4C,GAAD,CAAe,CAAA;GACZ,CAAA,CACa;;CACT,CAAA;AAEjB"}
@@ -0,0 +1,54 @@
1
+ import { DateValue, MonthValue } from '@burdenoff/fe-libs/ui';
2
+ import { eventDays } from '../time/calendarTime';
3
+ import { CalendarV2 } from '../types';
4
+ export type SyncLineKind =
5
+ /** Refreshing as it should: "Subscribed by link · every hour". */
6
+ 'ok'
7
+ /** 1–2 failed refreshes in a row: yellow, "Couldn't refresh at 09:00 · trying hourly". */
8
+ | 'retrying'
9
+ /** The last refresh took more than 5 s: yellow, "The link answers slowly". */
10
+ | 'slow'
11
+ /** 3+ failures (ERROR) or the link is gone (DISCONNECTED): red "Sync stopped" + the reason. */
12
+ | 'stopped'
13
+ /** Paused by someone. */
14
+ | 'paused';
15
+ export type SyncReason = 'needsSignIn' | 'linkGone' | 'notCalendar' | 'unreachable' | 'tooLarge' | 'other';
16
+ export interface SyncLine {
17
+ kind: SyncLineKind;
18
+ /** Why a sync stopped or is retrying. */
19
+ reason: SyncReason | null;
20
+ /** When the last refresh was tried (for "Couldn't refresh at 09:00"). */
21
+ at: Date | null;
22
+ }
23
+ /** The sync line of a calendar kept in step with an outside one; null for any other. */
24
+ export declare function syncLine(calendar: Pick<CalendarV2, 'sync'>): SyncLine | null;
25
+ /** A booking of a room: when, and whether it is waiting for approval. */
26
+ export interface RoomBookingSpan {
27
+ start: Date;
28
+ end: Date;
29
+ }
30
+ export type RoomNow = {
31
+ kind: 'paused';
32
+ } | {
33
+ kind: 'busy';
34
+ until: Date;
35
+ } | {
36
+ kind: 'free';
37
+ until: Date | null;
38
+ };
39
+ /**
40
+ * A room's state now: paused (not bookable), busy until a booking ends, free until the next one
41
+ * starts today, or free for the rest of the day (`until` null). `endOfToday` is the next
42
+ * midnight on the calendar's clock.
43
+ */
44
+ export declare function roomNow(room: {
45
+ bookable: boolean;
46
+ bookings: readonly RoomBookingSpan[];
47
+ }, now: Date, endOfToday: Date): RoomNow;
48
+ /** The first and last day of a month. */
49
+ export declare function monthBounds(month: MonthValue): {
50
+ first: DateValue;
51
+ last: DateValue;
52
+ };
53
+ /** The days of `month` that `events` touch, on the clock of `timeZone`. */
54
+ export declare function eventDatesInMonth(events: readonly Parameters<typeof eventDays>[0][], month: MonthValue, timeZone: string): Set<DateValue>;
@@ -0,0 +1,84 @@
1
+ import { eventDays as e } from "../time/calendarTime.js";
2
+ import { addDays as t, addMonths as n } from "@burdenoff/fe-libs/ui";
3
+ // src/v2/rail/railStatus.ts
4
+ function r(e) {
5
+ switch (e) {
6
+ case null: return null;
7
+ case "NEEDS_SIGN_IN": return "needsSignIn";
8
+ case "LINK_GONE": return "linkGone";
9
+ case "NOT_A_CALENDAR": return "notCalendar";
10
+ case "UNREACHABLE":
11
+ case "TIMED_OUT":
12
+ case "SERVER_ERROR":
13
+ case "TOO_MANY_REDIRECTS":
14
+ case "BLOCKED_ADDRESS": return "unreachable";
15
+ case "TOO_LARGE":
16
+ case "TOO_COMPLEX": return "tooLarge";
17
+ default: return "other";
18
+ }
19
+ }
20
+ function i(e) {
21
+ let t = e.sync;
22
+ if (!t) return null;
23
+ let n = r(t.lastProblem);
24
+ return t.status === "DISCONNECTED" ? {
25
+ kind: "stopped",
26
+ reason: n ?? "linkGone",
27
+ at: t.lastSyncAt
28
+ } : t.status === "ERROR" ? {
29
+ kind: "stopped",
30
+ reason: n ?? "other",
31
+ at: t.lastSyncAt
32
+ } : t.status === "PAUSED" || !t.enabled ? {
33
+ kind: "paused",
34
+ reason: null,
35
+ at: null
36
+ } : n && t.consecutiveFailures > 0 ? {
37
+ kind: "retrying",
38
+ reason: n,
39
+ at: t.lastSyncAt
40
+ } : t.slow ? {
41
+ kind: "slow",
42
+ reason: null,
43
+ at: t.lastSyncAt
44
+ } : {
45
+ kind: "ok",
46
+ reason: null,
47
+ at: t.lastSuccessAt
48
+ };
49
+ }
50
+ function a(e, t, n) {
51
+ if (!e.bookable) return { kind: "paused" };
52
+ let r = t.getTime(), i = [...e.bookings].sort((e, t) => e.start.getTime() - t.start.getTime()), a = i.filter((e) => e.start.getTime() <= r && e.end.getTime() > r);
53
+ if (a.length > 0) {
54
+ let e = Math.max(...a.map((e) => e.end.getTime()));
55
+ for (let t of i) t.start.getTime() <= e && t.end.getTime() > e && (e = t.end.getTime());
56
+ return {
57
+ kind: "busy",
58
+ until: new Date(e)
59
+ };
60
+ }
61
+ let o = i.find((e) => e.start.getTime() > r && e.start.getTime() < n.getTime());
62
+ return {
63
+ kind: "free",
64
+ until: o ? o.start : null
65
+ };
66
+ }
67
+ function o(e) {
68
+ let r = `${e}-01`;
69
+ return {
70
+ first: r,
71
+ last: t(n(r, 1), -1)
72
+ };
73
+ }
74
+ function s(n, r, i) {
75
+ let { first: a, last: s } = o(r), c = /* @__PURE__ */ new Set();
76
+ for (let r of n) {
77
+ let n = e(r, i), o = n.end > s ? s : n.end;
78
+ for (let e = n.start < a ? a : n.start; e <= o; e = t(e, 1)) c.add(e);
79
+ }
80
+ return c;
81
+ }
82
+ export { s as eventDatesInMonth, o as monthBounds, a as roomNow, i as syncLine };
83
+
84
+ //# sourceMappingURL=railStatus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"railStatus.js","names":["reasonOf","problem","syncLine","sync","calendar","reason","roomNow","room","at","now","sorted","a","b","current","until","booking","next","endOfToday","monthBounds","first","month","addDays","addMonths","eventDatesInMonth","dates","event","events","span","eventDays","timeZone","end","last","day"],"sources":["../../../src/v2/rail/railStatus.ts"],"sourcesContent":["/**\n * What the rail says about a calendar's sync and a room's day (BOFF-15698 A1, §6 B1's table),\n * and which days of its mini month have events. Pure: the words are chosen by the rail from the\n * `kind`.\n */\nimport { addDays, addMonths, type DateValue, type MonthValue } from '@burdenoff/fe-libs/ui';\nimport { eventDays } from '../time/calendarTime';\nimport type { CalendarV2 } from '../types';\n\nexport type SyncLineKind =\n /** Refreshing as it should: \"Subscribed by link · every hour\". */\n | 'ok'\n /** 1–2 failed refreshes in a row: yellow, \"Couldn't refresh at 09:00 · trying hourly\". */\n | 'retrying'\n /** The last refresh took more than 5 s: yellow, \"The link answers slowly\". */\n | 'slow'\n /** 3+ failures (ERROR) or the link is gone (DISCONNECTED): red \"Sync stopped\" + the reason. */\n | 'stopped'\n /** Paused by someone. */\n | 'paused';\n\nexport type SyncReason =\n 'needsSignIn' | 'linkGone' | 'notCalendar' | 'unreachable' | 'tooLarge' | 'other';\n\nexport interface SyncLine {\n kind: SyncLineKind;\n /** Why a sync stopped or is retrying. */\n reason: SyncReason | null;\n /** When the last refresh was tried (for \"Couldn't refresh at 09:00\"). */\n at: Date | null;\n}\n\nfunction reasonOf(problem: string | null): SyncReason | null {\n switch (problem) {\n case null:\n return null;\n case 'NEEDS_SIGN_IN':\n return 'needsSignIn';\n case 'LINK_GONE':\n return 'linkGone';\n case 'NOT_A_CALENDAR':\n return 'notCalendar';\n case 'UNREACHABLE':\n case 'TIMED_OUT':\n case 'SERVER_ERROR':\n case 'TOO_MANY_REDIRECTS':\n case 'BLOCKED_ADDRESS':\n return 'unreachable';\n case 'TOO_LARGE':\n case 'TOO_COMPLEX':\n return 'tooLarge';\n default:\n return 'other';\n }\n}\n\n/** The sync line of a calendar kept in step with an outside one; null for any other. */\nexport function syncLine(calendar: Pick<CalendarV2, 'sync'>): SyncLine | null {\n const sync = calendar.sync;\n if (!sync) return null;\n const reason = reasonOf(sync.lastProblem);\n if (sync.status === 'DISCONNECTED') {\n return { kind: 'stopped', reason: reason ?? 'linkGone', at: sync.lastSyncAt };\n }\n if (sync.status === 'ERROR')\n return { kind: 'stopped', reason: reason ?? 'other', at: sync.lastSyncAt };\n if (sync.status === 'PAUSED' || !sync.enabled) return { kind: 'paused', reason: null, at: null };\n if (reason && sync.consecutiveFailures > 0) {\n return { kind: 'retrying', reason, at: sync.lastSyncAt };\n }\n if (sync.slow) return { kind: 'slow', reason: null, at: sync.lastSyncAt };\n return { kind: 'ok', reason: null, at: sync.lastSuccessAt };\n}\n\n/** A booking of a room: when, and whether it is waiting for approval. */\nexport interface RoomBookingSpan {\n start: Date;\n end: Date;\n}\n\nexport type RoomNow =\n { kind: 'paused' } | { kind: 'busy'; until: Date } | { kind: 'free'; until: Date | null };\n\n/**\n * A room's state now: paused (not bookable), busy until a booking ends, free until the next one\n * starts today, or free for the rest of the day (`until` null). `endOfToday` is the next\n * midnight on the calendar's clock.\n */\nexport function roomNow(\n room: { bookable: boolean; bookings: readonly RoomBookingSpan[] },\n now: Date,\n endOfToday: Date\n): RoomNow {\n if (!room.bookable) return { kind: 'paused' };\n const at = now.getTime();\n const sorted = [...room.bookings].sort((a, b) => a.start.getTime() - b.start.getTime());\n const current = sorted.filter((b) => b.start.getTime() <= at && b.end.getTime() > at);\n if (current.length > 0) {\n // Back-to-back bookings keep it busy until the last of them ends.\n let until = Math.max(...current.map((b) => b.end.getTime()));\n for (const booking of sorted) {\n if (booking.start.getTime() <= until && booking.end.getTime() > until)\n until = booking.end.getTime();\n }\n return { kind: 'busy', until: new Date(until) };\n }\n const next = sorted.find(\n (b) => b.start.getTime() > at && b.start.getTime() < endOfToday.getTime()\n );\n return { kind: 'free', until: next ? next.start : null };\n}\n\n/** The first and last day of a month. */\nexport function monthBounds(month: MonthValue): { first: DateValue; last: DateValue } {\n const first = `${month}-01`;\n return { first, last: addDays(addMonths(first, 1), -1) };\n}\n\n/** The days of `month` that `events` touch, on the clock of `timeZone`. */\nexport function eventDatesInMonth(\n events: readonly Parameters<typeof eventDays>[0][],\n month: MonthValue,\n timeZone: string\n): Set<DateValue> {\n const { first, last } = monthBounds(month);\n const dates = new Set<DateValue>();\n for (const event of events) {\n const span = eventDays(event, timeZone);\n const end = span.end > last ? last : span.end;\n for (let day = span.start < first ? first : span.start; day <= end; day = addDays(day, 1)) {\n dates.add(day);\n }\n }\n return dates;\n}\n"],"mappings":";;;AAgCA,SAASA,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