@moh-sso/report-scheduler 0.0.0-stage → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/README.md +117 -2
  2. package/dist/_types/apps/report-scheduler/src/api/index.d.ts +3418 -0
  3. package/dist/_types/apps/report-scheduler/src/components/RecipientSelect.d.ts +10 -0
  4. package/dist/_types/apps/report-scheduler/src/components/ScheduleFormPanel.d.ts +9 -0
  5. package/dist/_types/apps/report-scheduler/src/components/SchedulerTables.d.ts +33 -0
  6. package/dist/_types/apps/report-scheduler/src/hooks/useSchedulerPermissions.d.ts +9 -0
  7. package/dist/_types/apps/report-scheduler/src/hooks/useSchedulerQueryToasts.d.ts +9 -0
  8. package/dist/_types/apps/report-scheduler/src/index.d.ts +4 -0
  9. package/dist/_types/apps/report-scheduler/src/root.component.d.ts +2 -0
  10. package/dist/_types/apps/report-scheduler/src/routes.d.ts +2 -0
  11. package/dist/_types/apps/report-scheduler/src/single-spa.d.ts +1 -0
  12. package/dist/_types/apps/report-scheduler/src/types/index.d.ts +185 -0
  13. package/dist/_types/apps/report-scheduler/src/utils/report-parameters.d.ts +3 -0
  14. package/dist/_types/apps/report-scheduler/src/utils/scheduler-permissions.d.ts +12 -0
  15. package/dist/_types/packages/api/src/api/baseApi.d.ts +2 -0
  16. package/dist/_types/packages/api/src/index.d.ts +1 -0
  17. package/dist/_types/packages/auth/src/api/auth.api.d.ts +531 -0
  18. package/dist/_types/packages/auth/src/api/health-context.api.d.ts +374 -0
  19. package/dist/_types/packages/auth/src/auth/AuthBootstrap.d.ts +1 -0
  20. package/dist/_types/packages/auth/src/auth/HealthContextProvider.d.ts +20 -0
  21. package/dist/_types/packages/auth/src/auth/PermissionGuard.d.ts +10 -0
  22. package/dist/_types/packages/auth/src/auth/auth.selectors.d.ts +896 -0
  23. package/dist/_types/packages/auth/src/auth/auth.slice.d.ts +14 -0
  24. package/dist/_types/packages/auth/src/auth/auth.types.d.ts +61 -0
  25. package/dist/_types/packages/auth/src/auth/login-url.d.ts +2 -0
  26. package/dist/_types/packages/auth/src/auth/permissions.d.ts +58 -0
  27. package/dist/_types/packages/auth/src/auth/rbac.d.ts +8 -0
  28. package/dist/_types/packages/auth/src/auth/system-launch-url.d.ts +9 -0
  29. package/dist/_types/packages/auth/src/auth/useAuthorization.d.ts +14 -0
  30. package/dist/_types/packages/auth/src/index.d.ts +14 -0
  31. package/dist/_types/packages/config/src/appMeta.d.ts +3 -0
  32. package/dist/_types/packages/config/src/index.d.ts +6 -0
  33. package/dist/_types/packages/config/src/lib/constants/api.constants.d.ts +178 -0
  34. package/dist/_types/packages/config/src/lib/constants/document-templates.d.ts +11 -0
  35. package/dist/_types/packages/config/src/lib/errors/errorMessages.d.ts +2 -0
  36. package/dist/_types/packages/config/src/lib/errors/errorSeverity.d.ts +3 -0
  37. package/dist/_types/packages/config/src/lib/errors/errorTypes.d.ts +1 -0
  38. package/dist/_types/packages/microfrontend/src/basename.d.ts +1 -0
  39. package/dist/_types/packages/microfrontend/src/index.d.ts +6 -0
  40. package/dist/_types/packages/microfrontend/src/lifecycle.d.ts +6 -0
  41. package/dist/_types/packages/microfrontend/src/navigation.d.ts +2 -0
  42. package/dist/_types/packages/microfrontend/src/props.d.ts +44 -0
  43. package/dist/_types/packages/microfrontend/src/react-lifecycle.d.ts +11 -0
  44. package/dist/_types/packages/microfrontend/src/routes.d.ts +13 -0
  45. package/dist/_types/packages/state/src/clients/clients.selectors.d.ts +534 -0
  46. package/dist/_types/packages/state/src/clients/clients.slice.d.ts +4 -0
  47. package/dist/_types/packages/state/src/document/documents.selectors.d.ts +1 -0
  48. package/dist/_types/packages/state/src/index.d.ts +29 -0
  49. package/dist/_types/packages/state/src/ui/ui.state.d.ts +1 -0
  50. package/dist/_types/packages/types/src/index.d.ts +6 -0
  51. package/dist/_types/packages/types/src/types/announcement-summary.types.d.ts +16 -0
  52. package/dist/_types/packages/types/src/types/client-role.types.d.ts +6 -0
  53. package/dist/_types/packages/types/src/types/client.types.d.ts +46 -0
  54. package/dist/_types/packages/types/src/types/document-processing.types.d.ts +1 -0
  55. package/dist/_types/packages/types/src/types/notifications.types.d.ts +96 -0
  56. package/dist/_types/packages/types/src/types/system-navigation.types.d.ts +18 -0
  57. package/dist/_types/packages/ui/src/accessibility/index.d.ts +1 -0
  58. package/dist/_types/packages/ui/src/accessibility/useFocusTrap.d.ts +10 -0
  59. package/dist/_types/packages/ui/src/branding/BuildMeta.d.ts +6 -0
  60. package/dist/_types/packages/ui/src/branding/PublicFooter.d.ts +6 -0
  61. package/dist/_types/packages/ui/src/branding/index.d.ts +2 -0
  62. package/dist/_types/packages/ui/src/data-display/DataTablePagination.d.ts +12 -0
  63. package/dist/_types/packages/ui/src/data-display/DataTableShell.d.ts +35 -0
  64. package/dist/_types/packages/ui/src/data-display/RowActionsCell.d.ts +7 -0
  65. package/dist/_types/packages/ui/src/data-display/TableEmptyState.d.ts +8 -0
  66. package/dist/_types/packages/ui/src/data-display/TableStatusTag.d.ts +8 -0
  67. package/dist/_types/packages/ui/src/data-display/index.d.ts +5 -0
  68. package/dist/_types/packages/ui/src/feedback/comingsoon/ComingSoon.d.ts +7 -0
  69. package/dist/_types/packages/ui/src/feedback/emptystate/EmptyState.d.ts +15 -0
  70. package/dist/_types/packages/ui/src/feedback/errorstate/ErrorState.d.ts +14 -0
  71. package/dist/_types/packages/ui/src/feedback/errorstate/MicrofrontendErrorBoundary.d.ts +16 -0
  72. package/dist/_types/packages/ui/src/feedback/index.d.ts +5 -0
  73. package/dist/_types/packages/ui/src/feedback/loadingstate/LoadingState.d.ts +5 -0
  74. package/dist/_types/packages/ui/src/forms/CaseFormsGrid.d.ts +1 -0
  75. package/dist/_types/packages/ui/src/forms/index.d.ts +1 -0
  76. package/dist/_types/packages/ui/src/index.d.ts +16 -0
  77. package/dist/_types/packages/ui/src/layout/PageShell/PageShell.d.ts +9 -0
  78. package/dist/_types/packages/ui/src/layout/SectionCard/SectionCard.d.ts +11 -0
  79. package/dist/_types/packages/ui/src/layout/index.d.ts +2 -0
  80. package/dist/_types/packages/ui/src/navigation/appmenu/AppGridContent.d.ts +12 -0
  81. package/dist/_types/packages/ui/src/navigation/appmenu/AppMenu.component.d.ts +6 -0
  82. package/dist/_types/packages/ui/src/navigation/appmenu/AppMenuItem.component.d.ts +13 -0
  83. package/dist/_types/packages/ui/src/navigation/appmenu/appMenuGroups.d.ts +11 -0
  84. package/dist/_types/packages/ui/src/navigation/breadcrumbs/AppBreadcrumbs.d.ts +12 -0
  85. package/dist/_types/packages/ui/src/navigation/breadcrumbs/BreadcrumbBar.d.ts +10 -0
  86. package/dist/_types/packages/ui/src/navigation/index.d.ts +2 -0
  87. package/dist/_types/packages/ui/src/navigation/sidenav/ClientSideNav.d.ts +14 -0
  88. package/dist/_types/packages/ui/src/notifications/FormInlineAlert.d.ts +7 -0
  89. package/dist/_types/packages/ui/src/notifications/NotificationsPanel.d.ts +14 -0
  90. package/dist/_types/packages/ui/src/notifications/index.d.ts +4 -0
  91. package/dist/_types/packages/ui/src/notifications/toast/ToastProvider.d.ts +20 -0
  92. package/dist/_types/packages/ui/src/notifications/toast/useToast.d.ts +20 -0
  93. package/dist/_types/packages/ui/src/overlays/header-panel/ReusableHeaderPanel.d.ts +17 -0
  94. package/dist/_types/packages/ui/src/overlays/header-panel/header-panel.context.d.ts +23 -0
  95. package/dist/_types/packages/ui/src/overlays/index.d.ts +4 -0
  96. package/dist/_types/packages/ui/src/overlays/modal/ReusableModal.d.ts +20 -0
  97. package/dist/_types/packages/ui/src/overlays/modal/modal.context.d.ts +14 -0
  98. package/dist/_types/packages/ui/src/shell/ExternalAppHeader.d.ts +22 -0
  99. package/dist/_types/packages/ui/src/shell/PublicHeader.component.d.ts +8 -0
  100. package/dist/_types/packages/ui/src/shell/UserHeader.component.d.ts +17 -0
  101. package/dist/_types/packages/ui/src/shell/index.d.ts +5 -0
  102. package/dist/_types/packages/ui/src/theme/ThemeProvider.d.ts +8 -0
  103. package/dist/_types/packages/ui/src/theme/index.d.ts +1 -0
  104. package/dist/_types/packages/ui/src/utils/severity.d.ts +22 -0
  105. package/dist/_types/packages/ui/src/utils/status.d.ts +1 -0
  106. package/dist/api.d.ts +1 -0
  107. package/dist/api.js +154 -0
  108. package/dist/api.js.map +1 -0
  109. package/dist/assets/report-scheduler-CR8i8OX0.css +1 -0
  110. package/dist/assets/root.component-CObknIW7.js +1411 -0
  111. package/dist/assets/root.component-CObknIW7.js.map +1 -0
  112. package/dist/index.d.ts +1 -0
  113. package/dist/index.js +51 -0
  114. package/dist/index.js.map +1 -0
  115. package/dist/routes.d.ts +1 -0
  116. package/dist/routes.js +33 -0
  117. package/dist/routes.js.map +1 -0
  118. package/dist/single-spa.d.ts +1 -0
  119. package/dist/single-spa.js +32 -0
  120. package/dist/single-spa.js.map +1 -0
  121. package/dist/types.d.ts +1 -0
  122. package/dist/types.js +25 -0
  123. package/dist/types.js.map +1 -0
  124. package/package.json +61 -4
@@ -0,0 +1,1411 @@
1
+ import { jsxs as i, jsx as e, Fragment as H } from "react/jsx-runtime";
2
+ import { useRef as Ue, useEffect as Te, useState as g, useMemo as ke, useId as Ke, Fragment as We } from "react";
3
+ import { useToast as Ee, useHeaderPanel as Ye, PageShell as Ze } from "@moh-sso/ui";
4
+ import { FilterableMultiSelect as Je, Button as R, Select as B, SelectItem as c, TextInput as $, InlineLoading as G, TableCell as w, OverflowMenu as Xe, OverflowMenuItem as he, Table as et, TableHead as tt, TableRow as Re, TableExpandHeader as rt, TableHeader as at, TableBody as it, TableExpandRow as lt, TableExpandedRow as nt, Pagination as ot, Tag as Be, Tile as W, Tabs as st, TabList as dt, Tab as we, TabPanels as ct, TabPanel as Ce, Modal as ut } from "@carbon/react";
5
+ import { useGetSchedulerRecipientOptionsQuery as ht, useGetReportSchedulerModuleQuery as He, useGetHealthBIReportsQuery as qe, useCreateReportScheduleMutation as pt, useUpdateReportScheduleMutation as mt, usePreviewReportRecipientsMutation as gt, useGetHealthBIReportParametersQuery as vt, useGetHealthBIReportQuery as yt, useGetReportSchedulerOverviewQuery as ft, useGetReportSchedulesQuery as bt, useGetReportExecutionsQuery as xt, useGetPortalReportsQuery as St, useDeleteReportScheduleMutation as _t, usePauseReportScheduleMutation as Rt, useResumeReportScheduleMutation as wt, useDuplicateReportScheduleMutation as Ct, useRunReportScheduleNowMutation as Nt, useRetryReportExecutionMutation as Tt, useGetReportExecutionQuery as kt } from "../api.js";
6
+ import { PERMISSIONS as Q, useAuthorization as Et } from "@moh-sso/auth";
7
+ function De(t) {
8
+ const a = Ee(), n = Ue(/* @__PURE__ */ new Set());
9
+ Te(() => {
10
+ const y = /* @__PURE__ */ new Set();
11
+ for (const p of t)
12
+ p.active && (y.add(p.id), n.current.has(p.id) || a[p.kind]({ title: p.title, subtitle: p.subtitle }));
13
+ n.current = y;
14
+ }, [t, a]);
15
+ }
16
+ function Dt(t, a) {
17
+ const n = {};
18
+ for (const y of t) {
19
+ if (y.metadata?.noDefault && !y.metadata?.hideNone) continue;
20
+ const p = y.defaultValue !== void 0 ? y.defaultValue : y.metadata?.defaultValue;
21
+ p != null && (n[y.name] = p);
22
+ }
23
+ return { ...n, ...a };
24
+ }
25
+ function ze(t) {
26
+ return t == null ? "" : Array.isArray(t) ? t.join(", ") : String(t);
27
+ }
28
+ function Ne({
29
+ kind: t,
30
+ label: a,
31
+ selected: n,
32
+ onChange: y,
33
+ disabled: p
34
+ }) {
35
+ const [d, C] = g(""), [s, _] = g("");
36
+ Te(() => {
37
+ const m = setTimeout(() => _(d.trim()), 250);
38
+ return () => clearTimeout(m);
39
+ }, [d]);
40
+ const o = ht({
41
+ kind: t,
42
+ search: s || void 0,
43
+ selected: n.length ? JSON.stringify(n.map((m) => m.value)) : void 0
44
+ }), [S, E] = g({});
45
+ Te(() => {
46
+ o.currentData && E((m) => o.currentData?.every((u) => m[u.id]?.label === u.label) ? m : {
47
+ ...m,
48
+ ...Object.fromEntries((o.currentData ?? []).map((u) => [u.id, u]))
49
+ });
50
+ }, [o.currentData]);
51
+ const f = ke(() => {
52
+ const m = new Map(n.map((u) => [u.id, S[u.id] ?? u]));
53
+ for (const u of o.currentData ?? []) m.set(u.id, u);
54
+ return [...m.values()];
55
+ }, [n, o.currentData, S]), h = f.filter(
56
+ (m) => n.some((u) => u.id === m.id)
57
+ );
58
+ return De([
59
+ {
60
+ id: `recipients-${t}`,
61
+ active: o.isError,
62
+ kind: "error",
63
+ title: `Unable to load ${a.toLowerCase()}`,
64
+ subtitle: "Retry the recipient lookup or try again later."
65
+ }
66
+ ]), /* @__PURE__ */ i("div", { className: "report-scheduler__recipient-select", children: [
67
+ /* @__PURE__ */ e(
68
+ Je,
69
+ {
70
+ id: `report-recipients-${t}`,
71
+ titleText: a,
72
+ placeholder: o.isFetching ? "Loading options…" : "Type to search and select",
73
+ items: f,
74
+ selectedItems: h,
75
+ itemToString: (m) => m?.label ?? "",
76
+ selectionFeedback: "fixed",
77
+ autoAlign: !0,
78
+ disabled: p,
79
+ onInputValueChange: ({ inputValue: m }) => C(m ?? ""),
80
+ onChange: ({ selectedItems: m }) => y(m ?? []),
81
+ helperText: t === "group" ? "Group members receive the report by email." : t === "portal" ? "Selected users receive the report in their portal inbox." : "Select registered users to receive the report by email."
82
+ }
83
+ ),
84
+ o.isError && /* @__PURE__ */ e(
85
+ R,
86
+ {
87
+ type: "button",
88
+ kind: "ghost",
89
+ size: "sm",
90
+ disabled: o.isFetching,
91
+ onClick: () => {
92
+ o.refetch();
93
+ },
94
+ children: "Retry lookup"
95
+ }
96
+ ),
97
+ !o.isFetching && !o.isError && o.currentData?.length === 0 && /* @__PURE__ */ e("p", { className: "report-scheduler__recipient-hint", children: "No matching recipients. Try another search." })
98
+ ] });
99
+ }
100
+ function Pt(t, a) {
101
+ const n = a && t(Q.reportSchedulerRead);
102
+ return {
103
+ read: n,
104
+ create: n && t(Q.reportSchedulerCreate),
105
+ update: n && t(Q.reportSchedulerUpdate),
106
+ delete: n && t(Q.reportSchedulerDelete),
107
+ execute: n && t(Q.reportSchedulerExecute),
108
+ history: n && t(Q.reportSchedulerHistory),
109
+ manage: n && t(Q.reportSchedulerManage)
110
+ };
111
+ }
112
+ function Oe(t, a) {
113
+ switch (a) {
114
+ case "run":
115
+ return t.execute;
116
+ case "pause":
117
+ case "resume":
118
+ return t.update;
119
+ case "duplicate":
120
+ return t.create;
121
+ case "delete":
122
+ return t.delete;
123
+ default:
124
+ return !1;
125
+ }
126
+ }
127
+ function Pe() {
128
+ const { can: t, hasSystem: a } = Et();
129
+ return Pt(t, a("data-statistics"));
130
+ }
131
+ const It = [
132
+ ["current_day", "Current day"],
133
+ ["previous_day", "Previous day"],
134
+ ["current_week", "Current week"],
135
+ ["previous_week", "Previous week"],
136
+ ["current_epi_week", "Current epi week"],
137
+ ["previous_epi_week", "Previous epi week"],
138
+ ["current_month", "Current month"],
139
+ ["previous_month", "Previous month"],
140
+ ["current_quarter", "Current quarter"],
141
+ ["previous_quarter", "Previous quarter"],
142
+ ["current_year", "Current year"],
143
+ ["previous_year", "Previous year"]
144
+ ], Ft = (t) => t.split(",").map((a) => a.trim()).filter(Boolean), $t = (t) => {
145
+ if (typeof t == "string" || typeof t == "number")
146
+ return { value: String(t), label: String(t) };
147
+ if (t && typeof t == "object") {
148
+ const a = t, n = a.value ?? a.id ?? a.code ?? a.name, y = a.label ?? a.name ?? a.displayName ?? n;
149
+ if (n !== void 0) return { value: String(n), label: String(y ?? n) };
150
+ }
151
+ };
152
+ function At(t) {
153
+ const a = Pe();
154
+ return (t.initialSchedule ? a.update : a.create) ? /* @__PURE__ */ e(Lt, { ...t }) : /* @__PURE__ */ i("div", { children: [
155
+ /* @__PURE__ */ i("p", { children: [
156
+ "You do not have permission to ",
157
+ t.initialSchedule ? "edit" : "create",
158
+ " report schedules."
159
+ ] }),
160
+ /* @__PURE__ */ e(R, { kind: "secondary", onClick: t.onCancel, children: "Close" })
161
+ ] });
162
+ }
163
+ function Lt({
164
+ initialSchedule: t,
165
+ currentUserId: a,
166
+ onSuccess: n,
167
+ onCancel: y
168
+ }) {
169
+ const p = t?.id, d = He(), C = qe(), [s, _] = pt(), [o, S] = mt(), [E, f] = gt(), [h, m] = g(t?.healthBiReportId ?? ""), [u, x] = g(t?.reportName ?? ""), [M, N] = g(t?.frequency ?? "monthly"), [T, D] = g(t?.timing?.timeOfDay ?? "08:00"), [re, me] = g(t?.timing?.weekday ?? 1), [ae, ge] = g(t?.timing?.dayOfMonth ?? 1), [ie, ve] = g(
170
+ t?.periodStrategy ?? "previous_month"
171
+ ), [le, A] = g(t?.outputFormat ?? "pdf"), [z, L] = g(
172
+ t?.outputConfig?.fileNamePrefix ?? ""
173
+ ), V = (r) => ({
174
+ id: `${r.type}:${r.value}`,
175
+ type: r.type,
176
+ value: r.value,
177
+ label: r.value
178
+ }), [O, Y] = g(
179
+ () => (t?.recipients ?? []).filter((r) => r.deliveryChannel === "email" && r.type !== "group").map(V)
180
+ ), [Z, ne] = g(
181
+ () => (t?.recipients ?? []).filter((r) => r.deliveryChannel === "email" && r.type === "group").map(V)
182
+ ), [P, J] = g(
183
+ () => (t?.recipients ?? []).filter((r) => r.deliveryChannel === "portal").map(V)
184
+ ), [b, oe] = g(""), [X, ye] = g(
185
+ t?.healthContext?.district ?? ""
186
+ ), [l, k] = g(
187
+ t?.healthContext?.facility ?? ""
188
+ ), [se, fe] = g(
189
+ t?.parameters ?? {}
190
+ ), Fe = Ee(), j = vt(h, { skip: !h }), ee = yt(h, { skip: !h }), I = ee.currentData, te = j.currentData, be = ke(
191
+ () => Dt(te ?? [], se),
192
+ [te, se]
193
+ ), de = I?.supportedFormats ?? [], $e = I?.metadata?.periodStrategies, K = It.filter(
194
+ ([r]) => $e === void 0 || $e.includes(r)
195
+ ), Ae = t?.healthBiReportId === h, xe = K.some(([r]) => r === ie) ? ie : Ae ? "" : K.find(([r]) => r.startsWith("previous_"))?.[0] ?? K[0]?.[0] ?? "", ce = de.includes(le) ? le : Ae ? "" : de[0] ?? "", Le = K.some(([r]) => r === xe), Me = de.includes(ce);
196
+ De([
197
+ {
198
+ id: `configuration-${h}`,
199
+ active: ee.isError || j.isError,
200
+ kind: "error",
201
+ title: "Unable to load report configuration",
202
+ subtitle: "Select the report again to retry."
203
+ },
204
+ {
205
+ id: `periods-${h}`,
206
+ active: !!I && K.length === 0,
207
+ kind: "warning",
208
+ title: "This report does not support scheduled reporting periods",
209
+ subtitle: "Choose another Health BI report."
210
+ }
211
+ ]);
212
+ const Se = ke(() => {
213
+ const r = [
214
+ ...O.map((v) => ({
215
+ type: v.type,
216
+ value: v.value,
217
+ deliveryChannel: "email"
218
+ })),
219
+ ...Ft(b).map((v) => ({
220
+ type: "email",
221
+ value: v,
222
+ deliveryChannel: "email"
223
+ })),
224
+ ...Z.map((v) => ({
225
+ type: "group",
226
+ value: v.value,
227
+ deliveryChannel: "email"
228
+ })),
229
+ ...P.map((v) => ({
230
+ type: "user",
231
+ value: v.value,
232
+ deliveryChannel: "portal"
233
+ }))
234
+ ];
235
+ return [
236
+ ...new Map(
237
+ r.map((v) => [`${v.type}:${v.value}:${v.deliveryChannel}`, v])
238
+ ).values()
239
+ ];
240
+ }, [O, b, Z, P]), Ge = () => {
241
+ const r = C.data?.find((v) => v.id === h);
242
+ if (!(!r || !I || !Le || !Me))
243
+ return {
244
+ healthBiReportId: r.id,
245
+ reportName: u.trim() || r.name,
246
+ frequency: M,
247
+ timezone: "Africa/Kampala",
248
+ periodStrategy: xe,
249
+ parameters: be,
250
+ outputFormat: ce,
251
+ outputConfig: {
252
+ format: ce,
253
+ deliveryMode: "attachment",
254
+ fileNamePrefix: z.trim()
255
+ },
256
+ timing: { timeOfDay: T, weekday: re, dayOfMonth: ae },
257
+ healthContext: {
258
+ ...d.data?.healthContext,
259
+ district: X || d.data?.healthContext.district,
260
+ facility: l || d.data?.healthContext.facility
261
+ },
262
+ recipients: Se,
263
+ enabled: p ? t?.enabled ?? !0 : !0
264
+ };
265
+ }, Ve = async () => {
266
+ const r = Ge();
267
+ if (r)
268
+ try {
269
+ p ? await o({ id: p, body: r }).unwrap() : await s(r).unwrap(), n();
270
+ } catch {
271
+ Fe.error(
272
+ "Unable to save the report schedule",
273
+ "Review timing, parameters, health scope, and recipients."
274
+ );
275
+ }
276
+ }, je = async () => {
277
+ try {
278
+ await E(Se).unwrap();
279
+ } catch {
280
+ Fe.error("Unable to resolve recipients", "Check the recipient details and try again.");
281
+ }
282
+ };
283
+ return /* @__PURE__ */ i(
284
+ "form",
285
+ {
286
+ className: "report-scheduler__form",
287
+ onSubmit: (r) => {
288
+ r.preventDefault(), Ve();
289
+ },
290
+ children: [
291
+ /* @__PURE__ */ i("div", { className: "report-scheduler__grid", children: [
292
+ /* @__PURE__ */ i(
293
+ B,
294
+ {
295
+ id: "report-scheduler-report",
296
+ labelText: "Health BI report",
297
+ value: h,
298
+ onChange: (r) => {
299
+ const v = r.target.value;
300
+ m(v), fe({});
301
+ const U = C.data?.find((ue) => ue.id === v);
302
+ U && !p && x(U.name);
303
+ },
304
+ children: [
305
+ /* @__PURE__ */ e(c, { value: "", text: "Select a report" }),
306
+ (C.data ?? []).map((r) => /* @__PURE__ */ e(c, { value: r.id, text: r.name }, r.id))
307
+ ]
308
+ }
309
+ ),
310
+ /* @__PURE__ */ e(
311
+ $,
312
+ {
313
+ id: "report-scheduler-name",
314
+ labelText: "Schedule name",
315
+ value: u,
316
+ onChange: (r) => x(r.target.value)
317
+ }
318
+ ),
319
+ /* @__PURE__ */ i(
320
+ B,
321
+ {
322
+ id: "report-scheduler-frequency",
323
+ labelText: "Frequency",
324
+ value: M,
325
+ onChange: (r) => N(r.target.value),
326
+ children: [
327
+ /* @__PURE__ */ e(c, { value: "daily", text: "Daily" }),
328
+ /* @__PURE__ */ e(c, { value: "weekly", text: "Weekly" }),
329
+ /* @__PURE__ */ e(c, { value: "monthly", text: "Monthly" }),
330
+ /* @__PURE__ */ e(c, { value: "quarterly", text: "Quarterly" }),
331
+ /* @__PURE__ */ e(c, { value: "annual", text: "Annually" })
332
+ ]
333
+ }
334
+ ),
335
+ /* @__PURE__ */ e(
336
+ $,
337
+ {
338
+ id: "report-scheduler-time",
339
+ type: "time",
340
+ labelText: "Run time",
341
+ value: T,
342
+ onChange: (r) => D(r.target.value)
343
+ }
344
+ ),
345
+ M === "weekly" && /* @__PURE__ */ i(
346
+ B,
347
+ {
348
+ id: "report-scheduler-weekday",
349
+ labelText: "Day of week",
350
+ value: String(re),
351
+ onChange: (r) => me(Number(r.target.value)),
352
+ children: [
353
+ /* @__PURE__ */ e(c, { value: "1", text: "Monday" }),
354
+ /* @__PURE__ */ e(c, { value: "2", text: "Tuesday" }),
355
+ /* @__PURE__ */ e(c, { value: "3", text: "Wednesday" }),
356
+ /* @__PURE__ */ e(c, { value: "4", text: "Thursday" }),
357
+ /* @__PURE__ */ e(c, { value: "5", text: "Friday" }),
358
+ /* @__PURE__ */ e(c, { value: "6", text: "Saturday" }),
359
+ /* @__PURE__ */ e(c, { value: "7", text: "Sunday" })
360
+ ]
361
+ }
362
+ ),
363
+ (M === "monthly" || M === "quarterly" || M === "annual") && /* @__PURE__ */ e(
364
+ $,
365
+ {
366
+ id: "report-scheduler-day",
367
+ type: "number",
368
+ min: 1,
369
+ max: 31,
370
+ labelText: "Day of month",
371
+ value: String(ae),
372
+ onChange: (r) => ge(Number(r.target.value))
373
+ }
374
+ ),
375
+ /* @__PURE__ */ i(
376
+ B,
377
+ {
378
+ id: "report-scheduler-period",
379
+ labelText: "Reporting period",
380
+ value: xe,
381
+ onChange: (r) => ve(r.target.value),
382
+ children: [
383
+ /* @__PURE__ */ e(c, { value: "", text: "Select a supported reporting period" }),
384
+ K.map(([r, v]) => /* @__PURE__ */ e(c, { value: r, text: v }, r))
385
+ ]
386
+ }
387
+ ),
388
+ /* @__PURE__ */ i(
389
+ B,
390
+ {
391
+ id: "report-scheduler-format",
392
+ labelText: "Output format",
393
+ value: ce,
394
+ onChange: (r) => A(r.target.value),
395
+ children: [
396
+ /* @__PURE__ */ e(c, { value: "", text: "Select an output format" }),
397
+ de.map((r) => /* @__PURE__ */ e(c, { value: r.toLowerCase(), text: r.toUpperCase() }, r))
398
+ ]
399
+ }
400
+ ),
401
+ /* @__PURE__ */ e(
402
+ $,
403
+ {
404
+ id: "report-file-name-prefix",
405
+ labelText: "File name prefix",
406
+ helperText: "Optional prefix for generated report files",
407
+ value: z,
408
+ onChange: (r) => L(r.target.value)
409
+ }
410
+ )
411
+ ] }),
412
+ I && /* @__PURE__ */ i("section", { className: "report-scheduler__context", "aria-label": "Selected report details", children: [
413
+ /* @__PURE__ */ e("h3", { children: I.name }),
414
+ I.category && /* @__PURE__ */ e("p", { children: I.category }),
415
+ I.description && /* @__PURE__ */ e("p", { children: I.description })
416
+ ] }),
417
+ ee.isFetching && /* @__PURE__ */ e(G, { description: "Loading report capabilities…" }),
418
+ j.isFetching && /* @__PURE__ */ e(G, { description: "Loading report parameters…" }),
419
+ (te ?? []).length > 0 && /* @__PURE__ */ i("div", { className: "report-scheduler__parameters", children: [
420
+ /* @__PURE__ */ e("h3", { children: "Report parameters" }),
421
+ /* @__PURE__ */ e("p", { children: "Defaults from the selected report are filled in below. You can adjust them before saving." }),
422
+ /* @__PURE__ */ e("div", { className: "report-scheduler__grid", children: (te ?? []).map((r) => {
423
+ const v = (r.options ?? []).map($t).filter((F) => !!F), U = ze(be[r.name]);
424
+ U && v.length > 0 && !v.some((F) => F.value === U) && v.push({ value: U, label: U });
425
+ const ue = `${r.label || r.name}${r.required ? " *" : ""}`;
426
+ return v.length > 0 ? /* @__PURE__ */ i(
427
+ B,
428
+ {
429
+ id: `report-parameter-${r.name}`,
430
+ labelText: ue,
431
+ required: r.required,
432
+ value: U,
433
+ onChange: (F) => fe((_e) => ({
434
+ ..._e,
435
+ [r.name]: F.target.value
436
+ })),
437
+ children: [
438
+ /* @__PURE__ */ e(c, { value: "", text: "Select an option" }),
439
+ v.map((F) => /* @__PURE__ */ e(c, { value: F.value, text: F.label }, F.value))
440
+ ]
441
+ },
442
+ r.name
443
+ ) : /* @__PURE__ */ e(
444
+ $,
445
+ {
446
+ id: `report-parameter-${r.name}`,
447
+ labelText: ue,
448
+ required: r.required,
449
+ helperText: r.description,
450
+ value: ze(be[r.name]),
451
+ onChange: (F) => fe((_e) => ({
452
+ ..._e,
453
+ [r.name]: F.target.value
454
+ }))
455
+ },
456
+ r.name
457
+ );
458
+ }) })
459
+ ] }),
460
+ h && te?.length === 0 && !j.isFetching && /* @__PURE__ */ e("p", { children: "This report has no additional parameters. Reporting period and health scope are applied when it runs." }),
461
+ /* @__PURE__ */ i("div", { className: "report-scheduler__parameters", children: [
462
+ /* @__PURE__ */ e("h3", { children: "Health scope" }),
463
+ /* @__PURE__ */ i("div", { className: "report-scheduler__grid", children: [
464
+ /* @__PURE__ */ e(
465
+ $,
466
+ {
467
+ id: "report-health-district",
468
+ labelText: "District",
469
+ helperText: d.data?.healthContext.district ? "Restricted by your signed-in health context" : "Optional district UID or name",
470
+ value: X || d.data?.healthContext.district || "",
471
+ disabled: !!d.data?.healthContext.district,
472
+ onChange: (r) => ye(r.target.value)
473
+ }
474
+ ),
475
+ /* @__PURE__ */ e(
476
+ $,
477
+ {
478
+ id: "report-health-facility",
479
+ labelText: "Facility",
480
+ helperText: d.data?.healthContext.facility ? "Restricted by your signed-in health context" : "Optional facility UID or name",
481
+ value: l || d.data?.healthContext.facility || "",
482
+ disabled: !!d.data?.healthContext.facility,
483
+ onChange: (r) => k(r.target.value)
484
+ }
485
+ )
486
+ ] })
487
+ ] }),
488
+ /* @__PURE__ */ i("div", { className: "report-scheduler__parameters", children: [
489
+ /* @__PURE__ */ e("h3", { children: "Recipients" }),
490
+ /* @__PURE__ */ i("div", { className: "report-scheduler__grid", children: [
491
+ /* @__PURE__ */ e(
492
+ Ne,
493
+ {
494
+ kind: "email",
495
+ label: "Email recipients",
496
+ selected: O,
497
+ onChange: (r) => {
498
+ f.reset(), Y(r);
499
+ },
500
+ disabled: _.isLoading || S.isLoading
501
+ }
502
+ ),
503
+ /* @__PURE__ */ e(
504
+ Ne,
505
+ {
506
+ kind: "group",
507
+ label: "Recipient groups",
508
+ selected: Z,
509
+ onChange: (r) => {
510
+ f.reset(), ne(r);
511
+ },
512
+ disabled: _.isLoading || S.isLoading
513
+ }
514
+ ),
515
+ /* @__PURE__ */ e(
516
+ Ne,
517
+ {
518
+ kind: "portal",
519
+ label: "Portal recipients",
520
+ selected: P,
521
+ onChange: (r) => {
522
+ f.reset(), J(r);
523
+ },
524
+ disabled: _.isLoading || S.isLoading
525
+ }
526
+ ),
527
+ /* @__PURE__ */ e(
528
+ $,
529
+ {
530
+ id: "report-external-email-recipients",
531
+ type: "email",
532
+ multiple: !0,
533
+ labelText: "Additional email addresses",
534
+ helperText: "Optional addresses outside the portal, separated by commas",
535
+ value: b,
536
+ onChange: (r) => {
537
+ f.reset(), oe(r.target.value);
538
+ }
539
+ }
540
+ )
541
+ ] }),
542
+ /* @__PURE__ */ i("div", { className: "report-scheduler__actions", children: [
543
+ /* @__PURE__ */ e(
544
+ R,
545
+ {
546
+ kind: "tertiary",
547
+ size: "sm",
548
+ disabled: !Se.length || f.isLoading,
549
+ type: "button",
550
+ onClick: () => {
551
+ je();
552
+ },
553
+ children: "Preview recipients"
554
+ }
555
+ ),
556
+ a && /* @__PURE__ */ e(
557
+ R,
558
+ {
559
+ kind: "ghost",
560
+ size: "sm",
561
+ type: "button",
562
+ onClick: () => {
563
+ f.reset(), P.some((r) => r.value === a) || J([
564
+ ...P,
565
+ {
566
+ id: `user:${a}`,
567
+ type: "user",
568
+ value: a,
569
+ label: "Me"
570
+ }
571
+ ]);
572
+ },
573
+ children: "Deliver to my portal"
574
+ }
575
+ ),
576
+ f.data && /* @__PURE__ */ i("span", { children: [
577
+ f.data.emailCount,
578
+ " email · ",
579
+ f.data.portalCount,
580
+ " portal"
581
+ ] })
582
+ ] })
583
+ ] }),
584
+ /* @__PURE__ */ i("div", { className: "report-scheduler__actions", children: [
585
+ /* @__PURE__ */ e(R, { kind: "secondary", type: "button", onClick: y, children: "Cancel" }),
586
+ /* @__PURE__ */ e(
587
+ R,
588
+ {
589
+ type: "submit",
590
+ disabled: !h || !I || ee.isFetching || ee.isError || j.isFetching || j.isError || !Le || !Me || _.isLoading || S.isLoading || !d.data?.healthBiEnabled,
591
+ children: _.isLoading || S.isLoading ? "Saving…" : p ? "Save changes" : "Create schedule"
592
+ }
593
+ )
594
+ ] })
595
+ ]
596
+ }
597
+ );
598
+ }
599
+ const pe = (t) => t.replace(/[_-]/g, " ").replace(/^./, (a) => a.toUpperCase()), Mt = new Intl.DateTimeFormat("en-GB", {
600
+ dateStyle: "medium",
601
+ timeStyle: "short",
602
+ timeZone: "Africa/Kampala"
603
+ }), q = (t) => {
604
+ if (!t) return "—";
605
+ const a = new Date(t);
606
+ return Number.isNaN(a.getTime()) ? "—" : Mt.format(a);
607
+ };
608
+ function Qe({ status: t }) {
609
+ const a = t === "completed" || t === "enabled" ? "green" : t === "failed" ? "red" : t === "retrying" ? "warm-gray" : ["queued", "generating", "polling", "delivering"].includes(t) ? "blue" : "gray";
610
+ return /* @__PURE__ */ e(Be, { type: a, size: "sm", children: pe(t) });
611
+ }
612
+ function Ie({
613
+ label: t,
614
+ headers: a,
615
+ rows: n,
616
+ rowKey: y,
617
+ renderRow: p,
618
+ expansion: d,
619
+ empty: C
620
+ }) {
621
+ const s = Ke(), [_, o] = g({ page: 1, pageSize: 10 }), S = Math.min(_.page, Math.max(1, Math.ceil(n.length / _.pageSize))), E = n.slice((S - 1) * _.pageSize, S * _.pageSize);
622
+ return /* @__PURE__ */ i("div", { className: "report-scheduler__table-container", children: [
623
+ /* @__PURE__ */ e(
624
+ "div",
625
+ {
626
+ className: "report-scheduler__table-scroll",
627
+ role: "region",
628
+ "aria-label": `${t}, scroll to see all columns`,
629
+ tabIndex: 0,
630
+ children: /* @__PURE__ */ i(et, { "aria-label": t, size: "lg", useZebraStyles: !0, children: [
631
+ /* @__PURE__ */ e(tt, { children: /* @__PURE__ */ i(Re, { children: [
632
+ d && /* @__PURE__ */ e(rt, { id: s, "aria-label": "Execution details" }),
633
+ a.map((f) => /* @__PURE__ */ e(at, { children: f }, f))
634
+ ] }) }),
635
+ /* @__PURE__ */ i(it, { children: [
636
+ E.map((f) => {
637
+ const h = y(f);
638
+ if (!d) return /* @__PURE__ */ e(Re, { children: p(f) }, h);
639
+ const m = d.selectedId === h, u = `${s}-${h}`;
640
+ return /* @__PURE__ */ i(We, { children: [
641
+ /* @__PURE__ */ e(
642
+ lt,
643
+ {
644
+ expandHeader: s,
645
+ "aria-label": `${m ? "Collapse" : "Expand"} execution details for ${d.label(f)}`,
646
+ "aria-controls": u,
647
+ isExpanded: m,
648
+ onExpand: () => d.onToggle(m ? void 0 : h),
649
+ children: p(f)
650
+ }
651
+ ),
652
+ /* @__PURE__ */ e(nt, { id: u, colSpan: a.length + 1, children: m && d.content })
653
+ ] }, h);
654
+ }),
655
+ !n.length && /* @__PURE__ */ e(Re, { children: /* @__PURE__ */ e(w, { colSpan: a.length + (d ? 1 : 0), children: /* @__PURE__ */ e("div", { className: "report-scheduler__empty", children: C }) }) })
656
+ ] })
657
+ ] })
658
+ }
659
+ ),
660
+ n.length > 0 && /* @__PURE__ */ e(
661
+ ot,
662
+ {
663
+ page: S,
664
+ pageSize: _.pageSize,
665
+ pageSizes: [10, 20, 50],
666
+ totalItems: n.length,
667
+ itemsPerPageText: "Rows per page",
668
+ onChange: ({ page: f, pageSize: h }) => {
669
+ o({ page: f, pageSize: h }), d?.onToggle(void 0);
670
+ }
671
+ }
672
+ ),
673
+ /* @__PURE__ */ e("p", { className: "report-scheduler__table-note", children: "Up to 100 recent records. All times are in East Africa Time (Kampala)." })
674
+ ] });
675
+ }
676
+ function zt({
677
+ rows: t,
678
+ access: a,
679
+ busy: n,
680
+ pending: y,
681
+ onEdit: p,
682
+ onAction: d,
683
+ empty: C
684
+ }) {
685
+ return /* @__PURE__ */ e(
686
+ Ie,
687
+ {
688
+ label: "Scheduled reports",
689
+ headers: ["Report", "Recurrence", "Reporting period", "Status", "Next run · EAT", "Actions"],
690
+ rows: t,
691
+ rowKey: (s) => s.id,
692
+ empty: C,
693
+ renderRow: (s) => /* @__PURE__ */ i(H, { children: [
694
+ /* @__PURE__ */ i(w, { children: [
695
+ /* @__PURE__ */ e("strong", { children: s.reportName }),
696
+ /* @__PURE__ */ e("span", { className: "report-scheduler__cell-secondary", children: s.outputFormat.toUpperCase() })
697
+ ] }),
698
+ /* @__PURE__ */ i(w, { children: [
699
+ pe(s.frequency),
700
+ /* @__PURE__ */ i("span", { className: "report-scheduler__cell-secondary", children: [
701
+ s.timing?.timeOfDay || "08:00",
702
+ " · ",
703
+ s.timezone
704
+ ] })
705
+ ] }),
706
+ /* @__PURE__ */ e(w, { children: pe(s.periodStrategy) }),
707
+ /* @__PURE__ */ e(w, { children: /* @__PURE__ */ e(Qe, { status: s.enabled ? "enabled" : "paused" }) }),
708
+ /* @__PURE__ */ e(w, { children: s.enabled ? s.nextRunAt ? q(s.nextRunAt) : "Calculating…" : "Paused" }),
709
+ /* @__PURE__ */ e(w, { children: /* @__PURE__ */ i("div", { className: "report-scheduler__row-actions", children: [
710
+ a.execute && /* @__PURE__ */ e(
711
+ R,
712
+ {
713
+ kind: "ghost",
714
+ size: "sm",
715
+ disabled: n,
716
+ "aria-label": `Run ${s.reportName} now`,
717
+ onClick: () => d("run", s),
718
+ children: y?.id === s.id && y.action === "run" ? "Starting…" : "Run now"
719
+ }
720
+ ),
721
+ (a.update || a.create || a.delete) && /* @__PURE__ */ i(Xe, { flipped: !0, ariaLabel: `Actions for ${s.reportName}`, children: [
722
+ a.update && /* @__PURE__ */ e(
723
+ he,
724
+ {
725
+ itemText: "Edit schedule",
726
+ disabled: n,
727
+ onClick: () => p(s)
728
+ }
729
+ ),
730
+ a.update && /* @__PURE__ */ e(
731
+ he,
732
+ {
733
+ itemText: s.enabled ? "Pause schedule" : "Resume schedule",
734
+ disabled: n,
735
+ onClick: () => d(s.enabled ? "pause" : "resume", s)
736
+ }
737
+ ),
738
+ a.create && /* @__PURE__ */ e(
739
+ he,
740
+ {
741
+ itemText: "Duplicate schedule",
742
+ disabled: n,
743
+ onClick: () => d("duplicate", s)
744
+ }
745
+ ),
746
+ a.delete && /* @__PURE__ */ e(
747
+ he,
748
+ {
749
+ itemText: "Delete schedule",
750
+ isDelete: !0,
751
+ hasDivider: !0,
752
+ disabled: n,
753
+ onClick: () => d("delete", s)
754
+ }
755
+ )
756
+ ] })
757
+ ] }) })
758
+ ] })
759
+ }
760
+ );
761
+ }
762
+ function Ot({
763
+ rows: t,
764
+ schedules: a,
765
+ onDetails: n,
766
+ onRetry: y,
767
+ retrying: p,
768
+ canRetry: d,
769
+ selectedId: C,
770
+ expandedDetails: s,
771
+ empty: _
772
+ }) {
773
+ return /* @__PURE__ */ e(
774
+ Ie,
775
+ {
776
+ label: "Execution history",
777
+ expansion: {
778
+ selectedId: C,
779
+ onToggle: n,
780
+ label: (o) => a.find((S) => S.id === o.scheduleId)?.reportName || o.reportId,
781
+ content: s
782
+ },
783
+ headers: ["Report", "Status", "Scheduled · EAT", "Attempts", "Format", "Actions"],
784
+ rows: t,
785
+ rowKey: (o) => o.id,
786
+ empty: _,
787
+ renderRow: (o) => /* @__PURE__ */ i(H, { children: [
788
+ /* @__PURE__ */ i(w, { children: [
789
+ /* @__PURE__ */ e("strong", { children: a.find((S) => S.id === o.scheduleId)?.reportName || o.reportId }),
790
+ /* @__PURE__ */ i("span", { className: "report-scheduler__cell-secondary", children: [
791
+ pe(o.triggerType),
792
+ " run"
793
+ ] }),
794
+ o.errorMessage && /* @__PURE__ */ e("span", { className: "report-scheduler__cell-error", children: o.errorMessage })
795
+ ] }),
796
+ /* @__PURE__ */ i(w, { children: [
797
+ /* @__PURE__ */ e(Qe, { status: o.status }),
798
+ o.nextRetryAt && /* @__PURE__ */ i("span", { className: "report-scheduler__cell-secondary", children: [
799
+ "Retry: ",
800
+ q(o.nextRetryAt)
801
+ ] })
802
+ ] }),
803
+ /* @__PURE__ */ e(w, { children: q(o.scheduledFor || o.createdAt) }),
804
+ /* @__PURE__ */ i(w, { children: [
805
+ o.generationAttempts,
806
+ " / ",
807
+ o.maxGenerationAttempts
808
+ ] }),
809
+ /* @__PURE__ */ e(w, { children: o.outputFormat.toUpperCase() }),
810
+ /* @__PURE__ */ e(w, { children: /* @__PURE__ */ e("div", { className: "report-scheduler__row-actions", children: d && o.status === "failed" && o.scheduleId && /* @__PURE__ */ e(
811
+ R,
812
+ {
813
+ kind: "ghost",
814
+ size: "sm",
815
+ disabled: p,
816
+ "aria-label": `Retry ${o.reportId}`,
817
+ onClick: () => y(o.id),
818
+ children: "Retry"
819
+ }
820
+ ) }) })
821
+ ] })
822
+ }
823
+ );
824
+ }
825
+ function Ut({ rows: t, empty: a }) {
826
+ return /* @__PURE__ */ e(
827
+ Ie,
828
+ {
829
+ label: "Delivered reports",
830
+ headers: ["Report", "File", "Delivered · EAT", "Actions"],
831
+ rows: t,
832
+ rowKey: (n) => n.deliveryId,
833
+ empty: a,
834
+ renderRow: (n) => /* @__PURE__ */ i(H, { children: [
835
+ /* @__PURE__ */ e(w, { children: /* @__PURE__ */ e("strong", { children: n.reportName }) }),
836
+ /* @__PURE__ */ e(w, { children: n.artifact.fileName }),
837
+ /* @__PURE__ */ e(w, { children: q(n.deliveredAt) }),
838
+ /* @__PURE__ */ e(w, { children: n.artifact.downloadUrl ? /* @__PURE__ */ e(
839
+ R,
840
+ {
841
+ kind: "ghost",
842
+ size: "sm",
843
+ href: n.artifact.downloadUrl,
844
+ "aria-label": `Download ${n.artifact.fileName}`,
845
+ children: "Download"
846
+ }
847
+ ) : /* @__PURE__ */ e("span", { className: "report-scheduler__cell-secondary", children: "Unavailable" }) })
848
+ ] })
849
+ }
850
+ );
851
+ }
852
+ function Kt(t) {
853
+ return Pe().read ? /* @__PURE__ */ e(Bt, { ...t }) : /* @__PURE__ */ e("p", { children: "You do not have permission to access Report Scheduler." });
854
+ }
855
+ function Bt(t) {
856
+ const a = Pe(), n = t.auth?.user && typeof t.auth.user == "object" && "id" in t.auth.user ? String(t.auth.user.id ?? "") : "", [y, p] = g("schedules"), d = y === "executions" && !a.history ? "schedules" : y, C = a.history ? ["schedules", "executions", "inbox"] : ["schedules", "inbox"], [s, _] = g(""), [o, S] = g("all"), [E, f] = g(""), [h, m] = g("all"), u = He(), x = ft(void 0, {
857
+ skip: !a.history,
858
+ pollingInterval: 3e4
859
+ }), M = qe(void 0, {
860
+ skip: !(a.create || a.update)
861
+ }), N = bt({
862
+ limit: 100,
863
+ search: s.trim() || void 0,
864
+ enabled: o === "all" ? void 0 : o === "enabled"
865
+ }), T = xt(
866
+ {
867
+ limit: 100,
868
+ search: E.trim() || void 0,
869
+ status: h === "all" ? void 0 : h
870
+ },
871
+ { skip: !a.history, pollingInterval: 3e4 }
872
+ ), D = St(100, {
873
+ pollingInterval: d === "inbox" ? 3e4 : 0,
874
+ refetchOnMountOrArgChange: !0
875
+ }), [re] = _t(), [me] = Rt(), [ae] = wt(), [ge] = Ct(), [ie] = Nt(), [ve, le] = Tt(), [A, z] = g(), [L, V] = g(), [O, Y] = g(), { openPanel: Z, closePanel: ne } = Ye(), P = Ee(), J = Ue(0), b = kt(A ?? "", {
876
+ skip: !a.history || !A || d !== "executions",
877
+ pollingInterval: 15e3
878
+ }), oe = (l) => {
879
+ (l ? a.update : a.create) && (J.current += 1, Z({
880
+ title: l ? "Edit schedule" : "Create schedule",
881
+ size: "lg",
882
+ content: /* @__PURE__ */ e(
883
+ At,
884
+ {
885
+ initialSchedule: l,
886
+ currentUserId: n,
887
+ onCancel: ne,
888
+ onSuccess: () => {
889
+ P.success(l ? "Report schedule updated" : "Report schedule created"), ne(), N.refetch();
890
+ }
891
+ },
892
+ J.current
893
+ )
894
+ }));
895
+ }, X = async (l, k) => {
896
+ if (L || !Oe(a, l)) return !1;
897
+ V({ id: k.id, action: l });
898
+ try {
899
+ l === "pause" && await me(k.id).unwrap(), l === "resume" && await ae(k.id).unwrap(), l === "duplicate" && await ge(k.id).unwrap(), l === "run" && await ie(k.id).unwrap(), l === "delete" && await re(k.id).unwrap();
900
+ const se = {
901
+ run: "Report execution started.",
902
+ pause: "Schedule paused.",
903
+ resume: "Schedule resumed.",
904
+ duplicate: "Schedule duplicated.",
905
+ delete: "Schedule deleted."
906
+ };
907
+ return P.success(se[l]), await N.refetch(), await D.refetch(), a.history && await Promise.all([T.refetch(), x.refetch()]), l === "run" && a.history && p("executions"), !0;
908
+ } catch {
909
+ return P.error(`Unable to ${l} this schedule`, "Please try again."), !1;
910
+ } finally {
911
+ V(void 0);
912
+ }
913
+ }, ye = async (l) => {
914
+ if (!(!a.execute || !a.history))
915
+ try {
916
+ const k = A === l;
917
+ await ve(l).unwrap(), z(l), P.success("Execution retry started"), await Promise.all([T.refetch(), x.refetch()]), k && await b.refetch();
918
+ } catch {
919
+ P.error("Unable to retry this execution", "Please try again.");
920
+ }
921
+ };
922
+ return De([
923
+ {
924
+ id: "module",
925
+ active: u.isError,
926
+ kind: "error",
927
+ title: "Report Scheduler is unavailable",
928
+ subtitle: "Please try again or contact your portal administrator."
929
+ },
930
+ {
931
+ id: "datawarehouse-report-browser",
932
+ active: !!u.data && !u.data.healthBiEnabled,
933
+ kind: "warning",
934
+ title: "Health BI is not configured",
935
+ subtitle: "Contact your portal administrator to connect Health BI."
936
+ },
937
+ {
938
+ id: "catalogue",
939
+ active: (a.create || a.update) && M.isError && !!u.data?.healthBiEnabled,
940
+ kind: "error",
941
+ title: "Unable to load Health BI reports"
942
+ },
943
+ {
944
+ id: "worker",
945
+ active: a.history && !!x.data && !x.data.workerHealthy,
946
+ kind: "warning",
947
+ title: "Scheduler worker needs attention",
948
+ subtitle: x.data?.workerLastCycleError || "The scheduler has not reported a healthy cycle recently."
949
+ },
950
+ {
951
+ id: "schedules",
952
+ active: d === "schedules" && N.isError && !u.isError,
953
+ kind: "error",
954
+ title: "Unable to load schedules",
955
+ subtitle: "Use Refresh schedules to try again."
956
+ },
957
+ {
958
+ id: "executions",
959
+ active: d === "executions" && T.isError && !u.isError,
960
+ kind: "error",
961
+ title: "Unable to load execution history",
962
+ subtitle: "Use Refresh history to try again."
963
+ },
964
+ {
965
+ id: "inbox",
966
+ active: d === "inbox" && D.isError && !u.isError,
967
+ kind: "error",
968
+ title: "Unable to load delivered reports",
969
+ subtitle: "Use Refresh inbox to try again."
970
+ },
971
+ {
972
+ id: `detail-${A}`,
973
+ active: d === "executions" && !!A && b.isError,
974
+ kind: "error",
975
+ title: "Unable to load execution details"
976
+ },
977
+ {
978
+ id: "overview",
979
+ active: a.history && x.isError && !u.isError,
980
+ kind: "error",
981
+ title: "Unable to load scheduler health"
982
+ }
983
+ ]), u.isLoading ? /* @__PURE__ */ e(G, { description: "Loading Report Scheduler…" }) : /* @__PURE__ */ e("div", { className: "moh-microfrontend-root report-scheduler", children: /* @__PURE__ */ i(
984
+ Ze,
985
+ {
986
+ title: "Report Scheduler",
987
+ subtitle: "Schedule Health BI reports and deliver them by email or through the portal.",
988
+ children: [
989
+ a.history && /* @__PURE__ */ i(H, { children: [
990
+ /* @__PURE__ */ i("section", { className: "report-scheduler__health", "aria-label": "Scheduler health", children: [
991
+ /* @__PURE__ */ i("div", { className: "report-scheduler__health-bar", children: [
992
+ /* @__PURE__ */ i("div", { className: "report-scheduler__health-title", children: [
993
+ /* @__PURE__ */ e("h2", { children: "Scheduler health" }),
994
+ /* @__PURE__ */ e(
995
+ Be,
996
+ {
997
+ type: x.data ? x.data.workerHealthy ? "green" : "red" : "gray",
998
+ size: "sm",
999
+ children: x.data ? x.data.workerHealthy ? "Healthy" : "Attention required" : "Unavailable"
1000
+ }
1001
+ )
1002
+ ] }),
1003
+ /* @__PURE__ */ i("span", { className: "report-scheduler__health-heartbeat", children: [
1004
+ "Last heartbeat:",
1005
+ " ",
1006
+ x.data?.workerLastHeartbeatAt ? q(x.data.workerLastHeartbeatAt) : "Not recorded"
1007
+ ] })
1008
+ ] }),
1009
+ /* @__PURE__ */ i("details", { className: "report-scheduler__health-details", children: [
1010
+ /* @__PURE__ */ e("summary", { children: "View health details" }),
1011
+ /* @__PURE__ */ i("div", { className: "report-scheduler__status-grid", children: [
1012
+ /* @__PURE__ */ i("div", { children: [
1013
+ /* @__PURE__ */ e("strong", { children: "Execution states" }),
1014
+ /* @__PURE__ */ e("p", { children: (x.data?.executionStatuses ?? []).map((l) => `${l.status}: ${l.count}`).join(" · ") || "No executions" })
1015
+ ] }),
1016
+ /* @__PURE__ */ i("div", { children: [
1017
+ /* @__PURE__ */ e("strong", { children: "Delivery states" }),
1018
+ /* @__PURE__ */ e("p", { children: (x.data?.deliveryStatuses ?? []).map((l) => `${l.status}: ${l.count}`).join(" · ") || "No deliveries" })
1019
+ ] })
1020
+ ] })
1021
+ ] })
1022
+ ] }),
1023
+ /* @__PURE__ */ i("div", { className: "report-scheduler__summary", children: [
1024
+ /* @__PURE__ */ i(W, { children: [
1025
+ /* @__PURE__ */ e("strong", { children: x.data?.enabledSchedules ?? "—" }),
1026
+ /* @__PURE__ */ e("span", { children: "Enabled schedules" })
1027
+ ] }),
1028
+ /* @__PURE__ */ i(W, { children: [
1029
+ /* @__PURE__ */ e("strong", { children: x.data?.executions24h ?? "—" }),
1030
+ /* @__PURE__ */ e("span", { children: "Executions · 24h" }),
1031
+ /* @__PURE__ */ i("small", { children: [
1032
+ x.data?.failed24h ?? "—",
1033
+ " failed ·",
1034
+ " ",
1035
+ x.data?.retryingNow ?? "—",
1036
+ " retrying now"
1037
+ ] })
1038
+ ] }),
1039
+ /* @__PURE__ */ i(W, { children: [
1040
+ /* @__PURE__ */ e("strong", { children: x.data ? `${Math.round(x.data.successRate24h)}%` : "—" }),
1041
+ /* @__PURE__ */ e("span", { children: "Success rate · 24h" }),
1042
+ /* @__PURE__ */ i("small", { children: [
1043
+ x.data?.deliveryFailures24h ?? "—",
1044
+ " delivery failures · 24h"
1045
+ ] })
1046
+ ] })
1047
+ ] })
1048
+ ] }),
1049
+ /* @__PURE__ */ e("section", { className: "report-scheduler__workspace", "aria-label": "Report scheduler views", children: /* @__PURE__ */ i(
1050
+ st,
1051
+ {
1052
+ selectedIndex: C.indexOf(d),
1053
+ onChange: ({ selectedIndex: l }) => {
1054
+ p(C[l]), C[l] === "inbox" && D.refetch();
1055
+ },
1056
+ children: [
1057
+ /* @__PURE__ */ e(dt, { "aria-label": "Report scheduler views", contained: !0, children: [
1058
+ /* @__PURE__ */ e(we, { children: "Scheduled reports" }, "schedules"),
1059
+ ...a.history ? [/* @__PURE__ */ e(we, { children: "Execution history" }, "executions")] : [],
1060
+ /* @__PURE__ */ e(we, { children: "Delivered to me" }, "inbox")
1061
+ ] }),
1062
+ /* @__PURE__ */ e(ct, { children: [
1063
+ /* @__PURE__ */ e(Ce, { className: "report-scheduler__tab-panel", children: /* @__PURE__ */ i(W, { children: [
1064
+ /* @__PURE__ */ i("div", { className: "report-scheduler__heading-row", children: [
1065
+ /* @__PURE__ */ e("h2", { children: "Scheduled reports" }),
1066
+ a.create && /* @__PURE__ */ e(
1067
+ R,
1068
+ {
1069
+ size: "sm",
1070
+ disabled: !!L || !u.data?.healthBiEnabled,
1071
+ onClick: () => oe(),
1072
+ children: "Create schedule"
1073
+ }
1074
+ )
1075
+ ] }),
1076
+ /* @__PURE__ */ i("div", { className: "report-scheduler__filters", children: [
1077
+ /* @__PURE__ */ e(
1078
+ $,
1079
+ {
1080
+ id: "report-schedule-search",
1081
+ labelText: "Search schedules",
1082
+ placeholder: "Report or Health BI ID",
1083
+ value: s,
1084
+ onChange: (l) => _(l.target.value)
1085
+ }
1086
+ ),
1087
+ /* @__PURE__ */ i(
1088
+ B,
1089
+ {
1090
+ id: "report-schedule-enabled",
1091
+ labelText: "Schedule state",
1092
+ value: o,
1093
+ onChange: (l) => S(l.target.value),
1094
+ children: [
1095
+ /* @__PURE__ */ e(c, { value: "all", text: "All schedules" }),
1096
+ /* @__PURE__ */ e(c, { value: "enabled", text: "Enabled" }),
1097
+ /* @__PURE__ */ e(c, { value: "paused", text: "Paused" })
1098
+ ]
1099
+ }
1100
+ )
1101
+ ] }),
1102
+ /* @__PURE__ */ i("div", { className: "report-scheduler__table-tools", children: [
1103
+ /* @__PURE__ */ e("span", { children: "Manage report timing and delivery." }),
1104
+ /* @__PURE__ */ i("div", { children: [
1105
+ (s.trim() || o !== "all") && /* @__PURE__ */ e(
1106
+ R,
1107
+ {
1108
+ kind: "ghost",
1109
+ size: "sm",
1110
+ onClick: () => {
1111
+ _(""), S("all");
1112
+ },
1113
+ children: "Clear filters"
1114
+ }
1115
+ ),
1116
+ /* @__PURE__ */ e(
1117
+ R,
1118
+ {
1119
+ kind: "ghost",
1120
+ size: "sm",
1121
+ disabled: N.isFetching,
1122
+ onClick: () => {
1123
+ N.refetch();
1124
+ },
1125
+ children: N.isFetching ? "Refreshing…" : "Refresh schedules"
1126
+ }
1127
+ )
1128
+ ] })
1129
+ ] }),
1130
+ N.isLoading && /* @__PURE__ */ e(G, { description: "Loading schedules…" }),
1131
+ !N.isLoading && (!N.isError || !!N.data?.length) && /* @__PURE__ */ e(
1132
+ zt,
1133
+ {
1134
+ rows: N.data ?? [],
1135
+ access: a,
1136
+ busy: !!L,
1137
+ pending: L,
1138
+ onEdit: oe,
1139
+ onAction: (l, k) => {
1140
+ Oe(a, l) && (l === "delete" ? Y(k) : X(l, k));
1141
+ },
1142
+ empty: /* @__PURE__ */ i(H, { children: [
1143
+ /* @__PURE__ */ e("strong", { children: s.trim() || o !== "all" ? "No matching schedules" : "No schedules yet" }),
1144
+ /* @__PURE__ */ e("p", { children: s.trim() || o !== "all" ? "Try another search or clear your filters." : a.create ? "Create a schedule to start delivering reports automatically." : "No report schedules are available for your account." })
1145
+ ] })
1146
+ },
1147
+ `${s}:${o}`
1148
+ )
1149
+ ] }) }, "schedules"),
1150
+ ...a.history ? [
1151
+ /* @__PURE__ */ e(Ce, { className: "report-scheduler__tab-panel", children: /* @__PURE__ */ i(W, { children: [
1152
+ /* @__PURE__ */ e("h2", { children: "Execution history" }),
1153
+ /* @__PURE__ */ i("div", { className: "report-scheduler__filters", children: [
1154
+ /* @__PURE__ */ e(
1155
+ $,
1156
+ {
1157
+ id: "report-execution-search",
1158
+ labelText: "Search executions",
1159
+ placeholder: "Report name or report ID",
1160
+ value: E,
1161
+ onChange: (l) => {
1162
+ f(l.target.value), z(void 0);
1163
+ }
1164
+ }
1165
+ ),
1166
+ /* @__PURE__ */ i(
1167
+ B,
1168
+ {
1169
+ id: "report-execution-status",
1170
+ labelText: "Execution status",
1171
+ value: h,
1172
+ onChange: (l) => {
1173
+ m(l.target.value), z(void 0);
1174
+ },
1175
+ children: [
1176
+ /* @__PURE__ */ e(c, { value: "all", text: "All statuses" }),
1177
+ /* @__PURE__ */ e(c, { value: "queued", text: "Queued" }),
1178
+ /* @__PURE__ */ e(c, { value: "generating", text: "Generating" }),
1179
+ /* @__PURE__ */ e(c, { value: "polling", text: "Polling" }),
1180
+ /* @__PURE__ */ e(c, { value: "delivering", text: "Delivering" }),
1181
+ /* @__PURE__ */ e(c, { value: "retrying", text: "Retrying" }),
1182
+ /* @__PURE__ */ e(c, { value: "completed", text: "Completed" }),
1183
+ /* @__PURE__ */ e(c, { value: "failed", text: "Failed" }),
1184
+ /* @__PURE__ */ e(c, { value: "cancelled", text: "Cancelled" })
1185
+ ]
1186
+ }
1187
+ )
1188
+ ] }),
1189
+ /* @__PURE__ */ i("div", { className: "report-scheduler__table-tools", children: [
1190
+ /* @__PURE__ */ e("span", { children: "Updates automatically every 30 seconds." }),
1191
+ /* @__PURE__ */ i("div", { children: [
1192
+ (E.trim() || h !== "all") && /* @__PURE__ */ e(
1193
+ R,
1194
+ {
1195
+ kind: "ghost",
1196
+ size: "sm",
1197
+ onClick: () => {
1198
+ f(""), m("all"), z(void 0);
1199
+ },
1200
+ children: "Clear filters"
1201
+ }
1202
+ ),
1203
+ /* @__PURE__ */ e(
1204
+ R,
1205
+ {
1206
+ kind: "ghost",
1207
+ size: "sm",
1208
+ disabled: T.isFetching,
1209
+ onClick: () => {
1210
+ T.refetch();
1211
+ },
1212
+ children: T.isFetching ? "Refreshing…" : "Refresh history"
1213
+ }
1214
+ )
1215
+ ] })
1216
+ ] }),
1217
+ T.isLoading && /* @__PURE__ */ e(G, { description: "Loading executions…" }),
1218
+ !T.isLoading && (!T.isError || !!T.data?.length) && /* @__PURE__ */ e(
1219
+ Ot,
1220
+ {
1221
+ rows: T.data ?? [],
1222
+ schedules: N.data ?? [],
1223
+ selectedId: A,
1224
+ onDetails: (l) => z(l),
1225
+ expandedDetails: A && /* @__PURE__ */ i(
1226
+ "div",
1227
+ {
1228
+ className: "report-scheduler__execution-detail",
1229
+ role: "region",
1230
+ "aria-label": "Execution details",
1231
+ children: [
1232
+ /* @__PURE__ */ e("h3", { children: "Execution details" }),
1233
+ b.isFetching && /* @__PURE__ */ e(G, { description: "Loading execution details…" }),
1234
+ b.isError && /* @__PURE__ */ e(
1235
+ R,
1236
+ {
1237
+ kind: "ghost",
1238
+ size: "sm",
1239
+ disabled: b.isFetching,
1240
+ onClick: () => {
1241
+ b.refetch();
1242
+ },
1243
+ children: "Reload execution details"
1244
+ }
1245
+ ),
1246
+ b.currentData && /* @__PURE__ */ i(H, { children: [
1247
+ /* @__PURE__ */ i("div", { className: "report-scheduler__detail-grid", children: [
1248
+ /* @__PURE__ */ i("span", { children: [
1249
+ /* @__PURE__ */ e("strong", { children: "Status" }),
1250
+ /* @__PURE__ */ e("br", {}),
1251
+ b.currentData.execution.status
1252
+ ] }),
1253
+ /* @__PURE__ */ i("span", { children: [
1254
+ /* @__PURE__ */ e("strong", { children: "Generation attempts" }),
1255
+ /* @__PURE__ */ e("br", {}),
1256
+ b.currentData.execution.generationAttempts,
1257
+ "/",
1258
+ b.currentData.execution.maxGenerationAttempts
1259
+ ] }),
1260
+ /* @__PURE__ */ i("span", { children: [
1261
+ /* @__PURE__ */ e("strong", { children: "Period" }),
1262
+ /* @__PURE__ */ e("br", {}),
1263
+ b.currentData.execution.resolvedPeriod ? `${b.currentData.execution.resolvedPeriod.strategy}: ${q(b.currentData.execution.resolvedPeriod.start)} – ${q(b.currentData.execution.resolvedPeriod.end)}` : "—"
1264
+ ] }),
1265
+ /* @__PURE__ */ i("span", { children: [
1266
+ /* @__PURE__ */ e("strong", { children: "Health scope" }),
1267
+ /* @__PURE__ */ e("br", {}),
1268
+ b.currentData.schedule?.healthContext.facility || b.currentData.schedule?.healthContext.district || b.currentData.schedule?.healthContext.level || "National"
1269
+ ] })
1270
+ ] }),
1271
+ b.currentData.artifacts.length > 0 && /* @__PURE__ */ i("div", { className: "report-scheduler__detail-section", children: [
1272
+ /* @__PURE__ */ e("h3", { children: "Artifacts" }),
1273
+ b.currentData.artifacts.map(
1274
+ (l) => /* @__PURE__ */ i(
1275
+ "div",
1276
+ {
1277
+ className: "report-scheduler__detail-row",
1278
+ children: [
1279
+ /* @__PURE__ */ e("span", { children: l.fileName }),
1280
+ l.downloadUrl && /* @__PURE__ */ e(
1281
+ R,
1282
+ {
1283
+ kind: "ghost",
1284
+ size: "sm",
1285
+ href: l.downloadUrl,
1286
+ children: "Download"
1287
+ }
1288
+ )
1289
+ ]
1290
+ },
1291
+ l.id
1292
+ )
1293
+ )
1294
+ ] }),
1295
+ /* @__PURE__ */ i("div", { className: "report-scheduler__detail-section", children: [
1296
+ /* @__PURE__ */ e("h3", { children: "Deliveries" }),
1297
+ b.currentData.deliveries.map(
1298
+ (l) => /* @__PURE__ */ i(
1299
+ "div",
1300
+ {
1301
+ className: "report-scheduler__detail-row",
1302
+ children: [
1303
+ /* @__PURE__ */ i("div", { children: [
1304
+ /* @__PURE__ */ e("strong", { children: l.deliveryChannel }),
1305
+ " ·",
1306
+ " ",
1307
+ l.recipientValue,
1308
+ /* @__PURE__ */ i("p", { children: [
1309
+ l.status,
1310
+ " · attempts ",
1311
+ l.attempts,
1312
+ "/",
1313
+ l.maxAttempts
1314
+ ] }),
1315
+ l.lastError && /* @__PURE__ */ e("small", { className: "report-scheduler__error", children: l.lastError })
1316
+ ] }),
1317
+ l.nextRetryAt && /* @__PURE__ */ e("small", { children: q(l.nextRetryAt) })
1318
+ ]
1319
+ },
1320
+ l.id
1321
+ )
1322
+ ),
1323
+ !b.currentData.deliveries.length && /* @__PURE__ */ e("p", { children: "No recipient deliveries recorded." })
1324
+ ] })
1325
+ ] })
1326
+ ]
1327
+ }
1328
+ ),
1329
+ onRetry: (l) => {
1330
+ ye(l);
1331
+ },
1332
+ canRetry: a.execute,
1333
+ retrying: le.isLoading,
1334
+ empty: /* @__PURE__ */ i(H, { children: [
1335
+ /* @__PURE__ */ e("strong", { children: E.trim() || h !== "all" ? "No matching executions" : "No executions yet" }),
1336
+ /* @__PURE__ */ e("p", { children: E.trim() || h !== "all" ? "Try another search or clear your filters." : "Run a schedule to see its progress and delivery results here." })
1337
+ ] })
1338
+ },
1339
+ `${E}:${h}`
1340
+ )
1341
+ ] }) }, "executions")
1342
+ ] : [],
1343
+ /* @__PURE__ */ e(Ce, { className: "report-scheduler__tab-panel", children: /* @__PURE__ */ i(W, { children: [
1344
+ /* @__PURE__ */ i("div", { className: "report-scheduler__heading-row", children: [
1345
+ /* @__PURE__ */ e("h2", { children: "Delivered to me" }),
1346
+ /* @__PURE__ */ e(
1347
+ R,
1348
+ {
1349
+ kind: "ghost",
1350
+ size: "sm",
1351
+ disabled: D.isFetching,
1352
+ onClick: () => {
1353
+ D.refetch();
1354
+ },
1355
+ children: "Refresh inbox"
1356
+ }
1357
+ )
1358
+ ] }),
1359
+ D.isLoading && /* @__PURE__ */ e(G, { description: "Loading delivered reports…" }),
1360
+ !D.isLoading && (!D.isError || !!D.data?.length) && /* @__PURE__ */ e(
1361
+ Ut,
1362
+ {
1363
+ rows: D.data ?? [],
1364
+ empty: /* @__PURE__ */ i(H, { children: [
1365
+ /* @__PURE__ */ e("strong", { children: "No delivered reports yet" }),
1366
+ /* @__PURE__ */ i("p", { children: [
1367
+ "Only reports delivered to your signed-in account’s portal inbox appear here.",
1368
+ " ",
1369
+ a.create || a.update ? "In a schedule’s recipients, select your account under Portal recipients or choose “Deliver to my portal”." : "Ask the schedule owner to include your account as a portal recipient.",
1370
+ " ",
1371
+ a.history ? "Email-only deliveries appear in Execution history." : "Email-only deliveries are sent to email inboxes."
1372
+ ] })
1373
+ ] })
1374
+ }
1375
+ )
1376
+ ] }) }, "inbox")
1377
+ ] })
1378
+ ]
1379
+ }
1380
+ ) }),
1381
+ /* @__PURE__ */ e(
1382
+ ut,
1383
+ {
1384
+ open: a.delete && !!O,
1385
+ danger: !0,
1386
+ size: "sm",
1387
+ modalHeading: "Delete schedule?",
1388
+ primaryButtonText: L?.action === "delete" ? "Deleting…" : "Delete schedule",
1389
+ secondaryButtonText: "Cancel",
1390
+ primaryButtonDisabled: !!L,
1391
+ onRequestClose: () => {
1392
+ L || Y(void 0);
1393
+ },
1394
+ onRequestSubmit: async () => {
1395
+ !a.delete || !O || await X("delete", O) && Y(void 0);
1396
+ },
1397
+ children: /* @__PURE__ */ i("p", { children: [
1398
+ "Delete ",
1399
+ /* @__PURE__ */ e("strong", { children: O?.reportName }),
1400
+ "? Future runs will stop. Existing execution history and delivered reports will remain available."
1401
+ ] })
1402
+ }
1403
+ )
1404
+ ]
1405
+ }
1406
+ ) });
1407
+ }
1408
+ export {
1409
+ Kt as R
1410
+ };
1411
+ //# sourceMappingURL=root.component-CObknIW7.js.map