@moh-sso/email 0.0.0-stage → 1.3.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 (168) hide show
  1. package/README.md +24 -2
  2. package/dist/_types/apps/clients/src/types/client-role.types.d.ts +6 -0
  3. package/dist/_types/apps/clients/src/types/index.d.ts +2 -0
  4. package/dist/_types/apps/clients/src/types/user-role.types.d.ts +6 -0
  5. package/dist/_types/apps/email/src/api/email.api.d.ts +1465 -0
  6. package/dist/_types/apps/email/src/api/index.d.ts +1 -0
  7. package/dist/_types/apps/email/src/components/email-outbox-actions-menu.component.d.ts +10 -0
  8. package/dist/_types/apps/email/src/components/email-outbox-bulk-actions.component.d.ts +10 -0
  9. package/dist/_types/apps/email/src/components/email-outbox-detail/email-outbox-details-modal.component.d.ts +6 -0
  10. package/dist/_types/apps/email/src/components/email-outbox-filters.component.d.ts +14 -0
  11. package/dist/_types/apps/email/src/components/email-outbox-panel/email-outbox-panel.component.d.ts +6 -0
  12. package/dist/_types/apps/email/src/index.d.ts +5 -0
  13. package/dist/_types/apps/email/src/pages/email-outbox.component.d.ts +1 -0
  14. package/dist/_types/apps/email/src/root.component.d.ts +2 -0
  15. package/dist/_types/apps/email/src/routes.d.ts +2 -0
  16. package/dist/_types/apps/email/src/single-spa.d.ts +1 -0
  17. package/dist/_types/apps/email/src/types/email.types.d.ts +99 -0
  18. package/dist/_types/apps/email/src/types/index.d.ts +1 -0
  19. package/dist/_types/apps/rbac/src/api/health-context.api.d.ts +2482 -0
  20. package/dist/_types/apps/rbac/src/api/index.d.ts +2 -0
  21. package/dist/_types/apps/rbac/src/api/rbac.api.d.ts +10383 -0
  22. package/dist/_types/apps/rbac/src/components/AccessRequestsPanel.d.ts +6 -0
  23. package/dist/_types/apps/rbac/src/components/AuditTrailPanel.d.ts +1 -0
  24. package/dist/_types/apps/rbac/src/components/ChangeRequestsPanel.d.ts +9 -0
  25. package/dist/_types/apps/rbac/src/components/EffectiveAccessPanel.d.ts +1 -0
  26. package/dist/_types/apps/rbac/src/components/GovernanceToolsPanel.d.ts +5 -0
  27. package/dist/_types/apps/rbac/src/components/HealthContextsPanel.d.ts +1 -0
  28. package/dist/_types/apps/rbac/src/components/ImportExportPanel.d.ts +11 -0
  29. package/dist/_types/apps/rbac/src/components/PermissionCatalogPanel.d.ts +12 -0
  30. package/dist/_types/apps/rbac/src/components/PolicySimulatorPanel.d.ts +25 -0
  31. package/dist/_types/apps/rbac/src/components/RoleTemplatesPanel.d.ts +8 -0
  32. package/dist/_types/apps/rbac/src/components/SyncDriftPanel.d.ts +5 -0
  33. package/dist/_types/apps/rbac/src/index.d.ts +5 -0
  34. package/dist/_types/apps/rbac/src/pages/rbac-management.page.d.ts +1 -0
  35. package/dist/_types/apps/rbac/src/root.component.d.ts +2 -0
  36. package/dist/_types/apps/rbac/src/routes.d.ts +2 -0
  37. package/dist/_types/apps/rbac/src/types/health-context.types.d.ts +92 -0
  38. package/dist/_types/apps/rbac/src/types/index.d.ts +2 -0
  39. package/dist/_types/apps/rbac/src/types/rbac.types.d.ts +451 -0
  40. package/dist/_types/apps/users/src/api/index.d.ts +1 -0
  41. package/dist/_types/apps/users/src/api/users.api.d.ts +1799 -0
  42. package/dist/_types/apps/users/src/components/EnableUserModal.d.ts +8 -0
  43. package/dist/_types/apps/users/src/components/ResetPasswordModal.d.ts +8 -0
  44. package/dist/_types/apps/users/src/components/UserFilters.d.ts +12 -0
  45. package/dist/_types/apps/users/src/components/access-control/UserAccessPanel.d.ts +5 -0
  46. package/dist/_types/apps/users/src/components/create-user-panel.d.ts +9 -0
  47. package/dist/_types/apps/users/src/components/useEnableUserModal.d.ts +9 -0
  48. package/dist/_types/apps/users/src/components/useResetPasswordModal.d.ts +9 -0
  49. package/dist/_types/apps/users/src/index.d.ts +6 -0
  50. package/dist/_types/apps/users/src/pages/user-actions-menu.component.d.ts +11 -0
  51. package/dist/_types/apps/users/src/pages/user-bulk-actions.component.d.ts +11 -0
  52. package/dist/_types/apps/users/src/pages/user.component.d.ts +1 -0
  53. package/dist/_types/apps/users/src/root.component.d.ts +2 -0
  54. package/dist/_types/apps/users/src/routes.d.ts +2 -0
  55. package/dist/_types/apps/users/src/types/index.d.ts +1 -0
  56. package/dist/_types/apps/users/src/types/user.types.d.ts +26 -0
  57. package/dist/_types/packages/api/src/api/baseApi.d.ts +2 -0
  58. package/dist/_types/packages/api/src/index.d.ts +1 -0
  59. package/dist/_types/packages/auth/src/api/auth.api.d.ts +531 -0
  60. package/dist/_types/packages/auth/src/api/health-context.api.d.ts +374 -0
  61. package/dist/_types/packages/auth/src/auth/AuthBootstrap.d.ts +1 -0
  62. package/dist/_types/packages/auth/src/auth/HealthContextProvider.d.ts +20 -0
  63. package/dist/_types/packages/auth/src/auth/PermissionGuard.d.ts +10 -0
  64. package/dist/_types/packages/auth/src/auth/auth.selectors.d.ts +896 -0
  65. package/dist/_types/packages/auth/src/auth/auth.slice.d.ts +14 -0
  66. package/dist/_types/packages/auth/src/auth/auth.types.d.ts +61 -0
  67. package/dist/_types/packages/auth/src/auth/login-url.d.ts +2 -0
  68. package/dist/_types/packages/auth/src/auth/permissions.d.ts +58 -0
  69. package/dist/_types/packages/auth/src/auth/rbac.d.ts +8 -0
  70. package/dist/_types/packages/auth/src/auth/system-launch-url.d.ts +9 -0
  71. package/dist/_types/packages/auth/src/auth/useAuthorization.d.ts +14 -0
  72. package/dist/_types/packages/auth/src/index.d.ts +14 -0
  73. package/dist/_types/packages/config/src/appMeta.d.ts +3 -0
  74. package/dist/_types/packages/config/src/index.d.ts +6 -0
  75. package/dist/_types/packages/config/src/lib/constants/api.constants.d.ts +178 -0
  76. package/dist/_types/packages/config/src/lib/constants/document-templates.d.ts +11 -0
  77. package/dist/_types/packages/config/src/lib/errors/errorMessages.d.ts +2 -0
  78. package/dist/_types/packages/config/src/lib/errors/errorSeverity.d.ts +3 -0
  79. package/dist/_types/packages/config/src/lib/errors/errorTypes.d.ts +1 -0
  80. package/dist/_types/packages/microfrontend/src/basename.d.ts +1 -0
  81. package/dist/_types/packages/microfrontend/src/index.d.ts +6 -0
  82. package/dist/_types/packages/microfrontend/src/lifecycle.d.ts +6 -0
  83. package/dist/_types/packages/microfrontend/src/navigation.d.ts +2 -0
  84. package/dist/_types/packages/microfrontend/src/props.d.ts +44 -0
  85. package/dist/_types/packages/microfrontend/src/react-lifecycle.d.ts +11 -0
  86. package/dist/_types/packages/microfrontend/src/routes.d.ts +13 -0
  87. package/dist/_types/packages/state/src/clients/clients.selectors.d.ts +534 -0
  88. package/dist/_types/packages/state/src/clients/clients.slice.d.ts +4 -0
  89. package/dist/_types/packages/state/src/document/documents.selectors.d.ts +1 -0
  90. package/dist/_types/packages/state/src/index.d.ts +29 -0
  91. package/dist/_types/packages/state/src/ui/ui.state.d.ts +1 -0
  92. package/dist/_types/packages/types/src/index.d.ts +6 -0
  93. package/dist/_types/packages/types/src/types/announcement-summary.types.d.ts +16 -0
  94. package/dist/_types/packages/types/src/types/client-role.types.d.ts +6 -0
  95. package/dist/_types/packages/types/src/types/client.types.d.ts +46 -0
  96. package/dist/_types/packages/types/src/types/document-processing.types.d.ts +1 -0
  97. package/dist/_types/packages/types/src/types/notifications.types.d.ts +96 -0
  98. package/dist/_types/packages/types/src/types/system-navigation.types.d.ts +18 -0
  99. package/dist/_types/packages/ui/src/accessibility/index.d.ts +1 -0
  100. package/dist/_types/packages/ui/src/accessibility/useFocusTrap.d.ts +10 -0
  101. package/dist/_types/packages/ui/src/branding/BuildMeta.d.ts +6 -0
  102. package/dist/_types/packages/ui/src/branding/PublicFooter.d.ts +6 -0
  103. package/dist/_types/packages/ui/src/branding/index.d.ts +2 -0
  104. package/dist/_types/packages/ui/src/data-display/DataTablePagination.d.ts +12 -0
  105. package/dist/_types/packages/ui/src/data-display/DataTableShell.d.ts +35 -0
  106. package/dist/_types/packages/ui/src/data-display/RowActionsCell.d.ts +7 -0
  107. package/dist/_types/packages/ui/src/data-display/TableEmptyState.d.ts +8 -0
  108. package/dist/_types/packages/ui/src/data-display/TableStatusTag.d.ts +8 -0
  109. package/dist/_types/packages/ui/src/data-display/index.d.ts +5 -0
  110. package/dist/_types/packages/ui/src/feedback/comingsoon/ComingSoon.d.ts +7 -0
  111. package/dist/_types/packages/ui/src/feedback/emptystate/EmptyState.d.ts +15 -0
  112. package/dist/_types/packages/ui/src/feedback/errorstate/ErrorState.d.ts +14 -0
  113. package/dist/_types/packages/ui/src/feedback/errorstate/MicrofrontendErrorBoundary.d.ts +16 -0
  114. package/dist/_types/packages/ui/src/feedback/index.d.ts +5 -0
  115. package/dist/_types/packages/ui/src/feedback/loadingstate/LoadingState.d.ts +5 -0
  116. package/dist/_types/packages/ui/src/forms/CaseFormsGrid.d.ts +1 -0
  117. package/dist/_types/packages/ui/src/forms/index.d.ts +1 -0
  118. package/dist/_types/packages/ui/src/index.d.ts +16 -0
  119. package/dist/_types/packages/ui/src/layout/PageShell/PageShell.d.ts +9 -0
  120. package/dist/_types/packages/ui/src/layout/SectionCard/SectionCard.d.ts +11 -0
  121. package/dist/_types/packages/ui/src/layout/index.d.ts +2 -0
  122. package/dist/_types/packages/ui/src/navigation/appmenu/AppGridContent.d.ts +12 -0
  123. package/dist/_types/packages/ui/src/navigation/appmenu/AppMenu.component.d.ts +6 -0
  124. package/dist/_types/packages/ui/src/navigation/appmenu/AppMenuItem.component.d.ts +13 -0
  125. package/dist/_types/packages/ui/src/navigation/appmenu/appMenuGroups.d.ts +11 -0
  126. package/dist/_types/packages/ui/src/navigation/breadcrumbs/AppBreadcrumbs.d.ts +12 -0
  127. package/dist/_types/packages/ui/src/navigation/breadcrumbs/BreadcrumbBar.d.ts +10 -0
  128. package/dist/_types/packages/ui/src/navigation/index.d.ts +2 -0
  129. package/dist/_types/packages/ui/src/navigation/sidenav/ClientSideNav.d.ts +14 -0
  130. package/dist/_types/packages/ui/src/notifications/FormInlineAlert.d.ts +7 -0
  131. package/dist/_types/packages/ui/src/notifications/NotificationsPanel.d.ts +14 -0
  132. package/dist/_types/packages/ui/src/notifications/index.d.ts +4 -0
  133. package/dist/_types/packages/ui/src/notifications/toast/ToastProvider.d.ts +20 -0
  134. package/dist/_types/packages/ui/src/notifications/toast/useToast.d.ts +20 -0
  135. package/dist/_types/packages/ui/src/overlays/header-panel/ReusableHeaderPanel.d.ts +17 -0
  136. package/dist/_types/packages/ui/src/overlays/header-panel/header-panel.context.d.ts +23 -0
  137. package/dist/_types/packages/ui/src/overlays/index.d.ts +4 -0
  138. package/dist/_types/packages/ui/src/overlays/modal/ReusableModal.d.ts +20 -0
  139. package/dist/_types/packages/ui/src/overlays/modal/modal.context.d.ts +14 -0
  140. package/dist/_types/packages/ui/src/shell/ExternalAppHeader.d.ts +22 -0
  141. package/dist/_types/packages/ui/src/shell/PublicHeader.component.d.ts +8 -0
  142. package/dist/_types/packages/ui/src/shell/UserHeader.component.d.ts +17 -0
  143. package/dist/_types/packages/ui/src/shell/index.d.ts +5 -0
  144. package/dist/_types/packages/ui/src/theme/ThemeProvider.d.ts +8 -0
  145. package/dist/_types/packages/ui/src/theme/index.d.ts +1 -0
  146. package/dist/_types/packages/ui/src/utils/severity.d.ts +22 -0
  147. package/dist/_types/packages/ui/src/utils/status.d.ts +1 -0
  148. package/dist/api.d.ts +1 -0
  149. package/dist/api.js +36 -0
  150. package/dist/api.js.map +1 -0
  151. package/dist/assets/email-8DfsqBcm.css +1 -0
  152. package/dist/assets/email.api-BFecBvcu.js +115 -0
  153. package/dist/assets/email.api-BFecBvcu.js.map +1 -0
  154. package/dist/assets/root.component-C1na_5E_.js +2034 -0
  155. package/dist/assets/root.component-C1na_5E_.js.map +1 -0
  156. package/dist/index.d.ts +1 -0
  157. package/dist/index.js +41 -0
  158. package/dist/index.js.map +1 -0
  159. package/dist/routes.d.ts +1 -0
  160. package/dist/routes.js +32 -0
  161. package/dist/routes.js.map +1 -0
  162. package/dist/single-spa.d.ts +1 -0
  163. package/dist/single-spa.js +32 -0
  164. package/dist/single-spa.js.map +1 -0
  165. package/dist/types.d.ts +1 -0
  166. package/dist/types.js +25 -0
  167. package/dist/types.js.map +1 -0
  168. package/package.json +62 -4
@@ -0,0 +1,2034 @@
1
+ import { jsx as n, jsxs as l, Fragment as ue } from "react/jsx-runtime";
2
+ import { Tile as xe, Stack as K, Form as rt, Button as A, TextInput as v, MultiSelect as Oe, Checkbox as le, Select as lt, SelectItem as dt, TextArea as Be, Tag as Se, Loading as ct, OverflowMenu as mt, OverflowMenuItem as Ce, Search as ut, Dropdown as pt, InlineLoading as Le, DataTable as yt, Table as ht, TableHead as Rt, TableRow as $e, TableSelectAll as gt, TableHeader as bt, TableBody as ft, TableCell as de, TableSelectRow as Tt, Pagination as St } from "@carbon/react";
3
+ import { TrashCan as _t, Add as vt } from "@carbon/react/icons";
4
+ import { useId as Ct, useRef as $t, useState as u, useMemo as Z, useEffect as Ut } from "react";
5
+ import { h as It, f as qt, c as xt, b as Lt, g as At, u as Pt } from "./email.api-BFecBvcu.js";
6
+ import { useToast as Fe, useHeaderPanel as Et, useModal as Nt, PageShell as Mt, ErrorState as Dt } from "@moh-sso/ui";
7
+ import { baseApi as Pe } from "@moh-sso/api";
8
+ import { useAvailableHealthContexts as Gt } from "@moh-sso/auth";
9
+ import "react-redux";
10
+ import { API as x } from "@moh-sso/config";
11
+ const o = "/admin/rbac", wt = Pe.injectEndpoints({
12
+ endpoints: (t) => ({
13
+ registerRbacSystem: t.mutation({
14
+ query: (e) => ({ url: `${o}/systems`, method: "POST", body: e }),
15
+ transformResponse: (e) => e.data,
16
+ invalidatesTags: [{ type: "RbacSystem", id: "LIST" }]
17
+ }),
18
+ listRbacSystems: t.query({
19
+ query: () => `${o}/systems`,
20
+ transformResponse: (e) => e.data,
21
+ providesTags: [{ type: "RbacSystem", id: "LIST" }]
22
+ }),
23
+ getRbacSystem: t.query({
24
+ query: (e) => `${o}/systems/${encodeURIComponent(e)}`,
25
+ transformResponse: (e) => e.data,
26
+ providesTags: (e, a, s) => [{ type: "RbacSystem", id: s }]
27
+ }),
28
+ updateRbacSystem: t.mutation({
29
+ query: ({ clientId: e, data: a }) => ({
30
+ url: `${o}/systems/${encodeURIComponent(e)}`,
31
+ method: "PUT",
32
+ body: a
33
+ }),
34
+ transformResponse: (e) => e.data,
35
+ invalidatesTags: (e, a, { clientId: s }) => [
36
+ { type: "RbacSystem", id: "LIST" },
37
+ { type: "RbacSystem", id: s }
38
+ ]
39
+ }),
40
+ transitionRbacSystem: t.mutation({
41
+ query: ({ clientId: e, ...a }) => ({
42
+ url: `${o}/systems/${encodeURIComponent(e)}/lifecycle`,
43
+ method: "POST",
44
+ body: a
45
+ }),
46
+ transformResponse: (e) => e.data,
47
+ invalidatesTags: (e, a, { clientId: s }) => [
48
+ { type: "RbacSystem", id: "LIST" },
49
+ { type: "RbacSystem", id: s },
50
+ { type: "RbacAudit", id: "LIST" }
51
+ ]
52
+ }),
53
+ listRbacPermissions: t.query({
54
+ query: () => `${o}/permissions`,
55
+ transformResponse: (e) => e.data,
56
+ providesTags: [{ type: "RbacPermission", id: "LIST" }]
57
+ }),
58
+ updateRbacPermissionMetadata: t.mutation({
59
+ query: ({ permissionKey: e, data: a }) => ({
60
+ url: `${o}/permissions/${encodeURIComponent(e)}`,
61
+ method: "PUT",
62
+ body: a
63
+ }),
64
+ transformResponse: (e) => e.data,
65
+ invalidatesTags: [{ type: "RbacPermission", id: "LIST" }]
66
+ }),
67
+ listSystemRoles: t.query({
68
+ query: (e) => `${o}/systems/${encodeURIComponent(e)}/roles`,
69
+ transformResponse: (e) => e.data,
70
+ providesTags: (e, a, s) => [{ type: "RbacSystem", id: s }]
71
+ }),
72
+ createSystemRole: t.mutation(
73
+ {
74
+ query: ({ clientId: e, data: a }) => ({
75
+ url: `${o}/systems/${encodeURIComponent(e)}/roles`,
76
+ method: "POST",
77
+ body: a
78
+ }),
79
+ transformResponse: (e) => e.data,
80
+ invalidatesTags: (e, a, { clientId: s }) => [{ type: "RbacSystem", id: s }]
81
+ }
82
+ ),
83
+ updateSystemRole: t.mutation({
84
+ query: ({ roleId: e, data: a }) => ({
85
+ url: `${o}/roles/${encodeURIComponent(e)}`,
86
+ method: "PUT",
87
+ body: a
88
+ }),
89
+ transformResponse: (e) => e.data,
90
+ invalidatesTags: (e, a, { clientId: s }) => [{ type: "RbacSystem", id: s }]
91
+ }),
92
+ deleteSystemRole: t.mutation({
93
+ query: ({ roleId: e }) => ({
94
+ url: `${o}/roles/${encodeURIComponent(e)}`,
95
+ method: "DELETE"
96
+ }),
97
+ invalidatesTags: (e, a, { clientId: s }) => [{ type: "RbacSystem", id: s }]
98
+ }),
99
+ getRoleUsage: t.query({
100
+ query: (e) => `${o}/roles/${encodeURIComponent(e)}/usage`,
101
+ transformResponse: (e) => e.data
102
+ }),
103
+ copyRolePermissions: t.mutation({
104
+ query: ({ roleId: e, data: a }) => ({
105
+ url: `${o}/roles/${encodeURIComponent(e)}/copy-permissions`,
106
+ method: "POST",
107
+ body: a
108
+ }),
109
+ transformResponse: (e) => e.data,
110
+ invalidatesTags: (e, a, { clientId: s }) => [{ type: "RbacSystem", id: s }]
111
+ }),
112
+ assignSystemRolePermission: t.mutation({
113
+ query: ({ roleId: e, data: a }) => ({
114
+ url: `${o}/roles/${encodeURIComponent(e)}/permissions`,
115
+ method: "POST",
116
+ body: a
117
+ }),
118
+ invalidatesTags: (e, a, { clientId: s }) => [{ type: "RbacSystem", id: s }]
119
+ }),
120
+ removeSystemRolePermission: t.mutation({
121
+ query: ({ roleId: e, permissionKey: a }) => ({
122
+ url: `${o}/roles/${encodeURIComponent(e)}/permissions/${encodeURIComponent(a)}`,
123
+ method: "DELETE"
124
+ }),
125
+ invalidatesTags: (e, a, { clientId: s }) => [{ type: "RbacSystem", id: s }]
126
+ }),
127
+ listRealmRolePermissions: t.query({
128
+ query: () => `${o}/realm-roles`,
129
+ transformResponse: (e) => e.data,
130
+ providesTags: [{ type: "RbacRealmRole", id: "LIST" }]
131
+ }),
132
+ listRbacGroups: t.query({
133
+ query: () => `${o}/groups`,
134
+ transformResponse: (e) => e.data,
135
+ providesTags: [{ type: "RbacGroup", id: "LIST" }]
136
+ }),
137
+ getRbacGroup: t.query({
138
+ query: (e) => `${o}/groups/${encodeURIComponent(e)}`,
139
+ transformResponse: (e) => e.data,
140
+ providesTags: (e, a, s) => [{ type: "RbacGroup", id: s }]
141
+ }),
142
+ listRbacGroupMembers: t.query({
143
+ query: (e) => `${o}/groups/${encodeURIComponent(e)}/members`,
144
+ transformResponse: (e) => e.data,
145
+ providesTags: (e, a, s) => [{ type: "RbacGroup", id: `${s}:members` }]
146
+ }),
147
+ upsertRbacGroup: t.mutation({
148
+ query: (e) => ({
149
+ url: `${o}/groups`,
150
+ method: "POST",
151
+ body: e
152
+ }),
153
+ transformResponse: (e) => e.data,
154
+ invalidatesTags: [
155
+ { type: "RbacGroup", id: "LIST" },
156
+ { type: "RbacAudit", id: "LIST" }
157
+ ]
158
+ }),
159
+ addRbacGroupMember: t.mutation({
160
+ query: ({ groupId: e, data: a }) => ({
161
+ url: `${o}/groups/${encodeURIComponent(e)}/members`,
162
+ method: "POST",
163
+ body: a
164
+ }),
165
+ transformResponse: (e) => e.data,
166
+ invalidatesTags: (e, a, { groupId: s, data: r }) => [
167
+ { type: "RbacGroup", id: s },
168
+ { type: "RbacGroup", id: `${s}:members` },
169
+ { type: "RbacGroup", id: "LIST" },
170
+ { type: "RbacAudit", id: "LIST" },
171
+ { type: "User", id: r.userId }
172
+ ]
173
+ }),
174
+ removeRbacGroupMember: t.mutation({
175
+ query: ({ groupId: e, userId: a }) => ({
176
+ url: `${o}/groups/${encodeURIComponent(e)}/members/${encodeURIComponent(a)}`,
177
+ method: "DELETE"
178
+ }),
179
+ transformResponse: (e) => e.data,
180
+ invalidatesTags: (e, a, { groupId: s, userId: r }) => [
181
+ { type: "RbacGroup", id: s },
182
+ { type: "RbacGroup", id: `${s}:members` },
183
+ { type: "RbacGroup", id: "LIST" },
184
+ { type: "RbacAudit", id: "LIST" },
185
+ { type: "User", id: r }
186
+ ]
187
+ }),
188
+ syncRbacGroupMembers: t.mutation({
189
+ query: (e) => ({
190
+ url: `${o}/groups/${encodeURIComponent(e)}/sync-members`,
191
+ method: "POST"
192
+ }),
193
+ transformResponse: (e) => e.data,
194
+ invalidatesTags: (e, a, s) => [
195
+ { type: "RbacGroup", id: s },
196
+ { type: "RbacGroup", id: `${s}:members` },
197
+ { type: "RbacGroup", id: "LIST" },
198
+ { type: "RbacAudit", id: "LIST" }
199
+ ]
200
+ }),
201
+ replaceRbacGroupMembers: t.mutation({
202
+ query: ({ groupId: e, data: a }) => ({
203
+ url: `${o}/groups/${encodeURIComponent(e)}/members`,
204
+ method: "PUT",
205
+ body: a
206
+ }),
207
+ invalidatesTags: (e, a, { groupId: s }) => [
208
+ { type: "RbacGroup", id: s },
209
+ { type: "RbacGroup", id: "LIST" },
210
+ { type: "RbacAudit", id: "LIST" }
211
+ ]
212
+ }),
213
+ assignGroupPermission: t.mutation(
214
+ {
215
+ query: ({ groupId: e, data: a }) => ({
216
+ url: `${o}/groups/${encodeURIComponent(e)}/permissions`,
217
+ method: "POST",
218
+ body: a
219
+ }),
220
+ invalidatesTags: (e, a, { groupId: s }) => [
221
+ { type: "RbacGroup", id: s },
222
+ { type: "RbacGroup", id: "LIST" }
223
+ ]
224
+ }
225
+ ),
226
+ removeGroupPermission: t.mutation({
227
+ query: ({ groupId: e, permissionKey: a }) => ({
228
+ url: `${o}/groups/${encodeURIComponent(e)}/permissions/${encodeURIComponent(a)}`,
229
+ method: "DELETE"
230
+ }),
231
+ invalidatesTags: (e, a, { groupId: s }) => [
232
+ { type: "RbacGroup", id: s },
233
+ { type: "RbacGroup", id: "LIST" }
234
+ ]
235
+ }),
236
+ assignGroupRealmRole: t.mutation({
237
+ query: ({ groupId: e, data: a }) => ({
238
+ url: `${o}/groups/${encodeURIComponent(e)}/realm-roles`,
239
+ method: "POST",
240
+ body: a
241
+ }),
242
+ invalidatesTags: (e, a, { groupId: s }) => [
243
+ { type: "RbacGroup", id: s },
244
+ { type: "RbacGroup", id: "LIST" }
245
+ ]
246
+ }),
247
+ removeGroupRealmRole: t.mutation({
248
+ query: ({ groupId: e, realmRole: a }) => ({
249
+ url: `${o}/groups/${encodeURIComponent(e)}/realm-roles/${encodeURIComponent(a)}`,
250
+ method: "DELETE"
251
+ }),
252
+ invalidatesTags: (e, a, { groupId: s }) => [
253
+ { type: "RbacGroup", id: s },
254
+ { type: "RbacGroup", id: "LIST" }
255
+ ]
256
+ }),
257
+ assignGroupSystemRole: t.mutation({
258
+ query: ({ groupId: e, data: a }) => ({
259
+ url: `${o}/groups/${encodeURIComponent(e)}/system-roles`,
260
+ method: "POST",
261
+ body: a
262
+ }),
263
+ invalidatesTags: (e, a, { groupId: s }) => [
264
+ { type: "RbacGroup", id: s },
265
+ { type: "RbacGroup", id: "LIST" }
266
+ ]
267
+ }),
268
+ removeGroupSystemRole: t.mutation({
269
+ query: ({ groupId: e, clientId: a, roleName: s }) => ({
270
+ url: `${o}/groups/${encodeURIComponent(e)}/system-roles/${encodeURIComponent(a)}/${encodeURIComponent(s)}`,
271
+ method: "DELETE"
272
+ }),
273
+ invalidatesTags: (e, a, { groupId: s }) => [
274
+ { type: "RbacGroup", id: s },
275
+ { type: "RbacGroup", id: "LIST" }
276
+ ]
277
+ }),
278
+ getRealmRoleUsage: t.query({
279
+ query: (e) => `${o}/realm-roles/${encodeURIComponent(e)}/usage`,
280
+ transformResponse: (e) => e.data
281
+ }),
282
+ assignRealmRolePermission: t.mutation({
283
+ query: ({ realmRole: e, data: a }) => ({
284
+ url: `${o}/realm-roles/${encodeURIComponent(e)}/permissions`,
285
+ method: "POST",
286
+ body: a
287
+ }),
288
+ invalidatesTags: [{ type: "RbacRealmRole", id: "LIST" }]
289
+ }),
290
+ removeRealmRolePermission: t.mutation(
291
+ {
292
+ query: ({ realmRole: e, permissionKey: a }) => ({
293
+ url: `${o}/realm-roles/${encodeURIComponent(e)}/permissions/${encodeURIComponent(a)}`,
294
+ method: "DELETE"
295
+ }),
296
+ invalidatesTags: [{ type: "RbacRealmRole", id: "LIST" }]
297
+ }
298
+ ),
299
+ addSystemAccessRole: t.mutation({
300
+ query: ({ clientId: e, data: a }) => ({
301
+ url: `${o}/systems/${encodeURIComponent(e)}/access-roles`,
302
+ method: "POST",
303
+ body: a
304
+ }),
305
+ invalidatesTags: (e, a, { clientId: s }) => [{ type: "RbacSystem", id: s }]
306
+ }),
307
+ removeSystemAccessRole: t.mutation({
308
+ query: ({ clientId: e, roleName: a, force: s }) => ({
309
+ url: `${o}/systems/${encodeURIComponent(e)}/access-roles/${encodeURIComponent(a)}${s ? "?force=true" : ""}`,
310
+ method: "DELETE"
311
+ }),
312
+ invalidatesTags: (e, a, { clientId: s }) => [{ type: "RbacSystem", id: s }]
313
+ }),
314
+ getRbacDrift: t.query({
315
+ query: () => `${o}/drift`,
316
+ transformResponse: (e) => e.data,
317
+ providesTags: [{ type: "RbacSystem", id: "DRIFT" }]
318
+ }),
319
+ previewRbacRealmExportDrift: t.mutation({
320
+ query: (e) => ({
321
+ url: `${o}/drift/realm-export`,
322
+ method: "POST",
323
+ body: e
324
+ }),
325
+ transformResponse: (e) => e.data
326
+ }),
327
+ previewRbacSync: t.mutation({
328
+ query: (e) => ({
329
+ url: `${o}/sync/preview`,
330
+ method: "POST",
331
+ body: e
332
+ }),
333
+ transformResponse: (e) => e.data
334
+ }),
335
+ applyRbacSync: t.mutation({
336
+ query: (e) => ({
337
+ url: `${o}/sync/apply`,
338
+ method: "POST",
339
+ body: e
340
+ }),
341
+ transformResponse: (e) => e.data,
342
+ invalidatesTags: [
343
+ { type: "RbacSystem", id: "LIST" },
344
+ { type: "RbacSystem", id: "DRIFT" },
345
+ { type: "RbacRealmRole", id: "LIST" }
346
+ ]
347
+ }),
348
+ getRbacEffectiveAccess: t.query({
349
+ query: ({ userId: e = "lookup", username: a, email: s }) => {
350
+ const r = new URLSearchParams();
351
+ a && r.set("username", a), s && r.set("email", s);
352
+ const f = r.toString();
353
+ return `${o}/effective-access/users/${encodeURIComponent(e)}${f ? `?${f}` : ""}`;
354
+ },
355
+ transformResponse: (e) => e.data
356
+ }),
357
+ getAssignableUserAccess: t.query({
358
+ query: () => `${o}/user-access/assignable`,
359
+ transformResponse: (e) => e.data,
360
+ providesTags: [{ type: "RbacSystem", id: "USER_ACCESS_ASSIGNABLE" }]
361
+ }),
362
+ getUserAccessProfile: t.query({
363
+ query: (e) => `${o}/user-access/users/${encodeURIComponent(e)}`,
364
+ transformResponse: (e) => e.data,
365
+ providesTags: (e, a, s) => [
366
+ { type: "RbacSystem", id: "USER_ACCESS_ASSIGNABLE" },
367
+ { type: "User", id: s },
368
+ { type: "UserClientRole", id: `LIST-${s}` }
369
+ ]
370
+ }),
371
+ updateUserAccess: t.mutation({
372
+ query: ({ userId: e, data: a }) => ({
373
+ url: `${o}/user-access/users/${encodeURIComponent(e)}`,
374
+ method: "PUT",
375
+ body: a
376
+ }),
377
+ transformResponse: (e) => e.data,
378
+ invalidatesTags: (e, a, { userId: s }) => [
379
+ { type: "User", id: s },
380
+ { type: "User", id: "LIST" },
381
+ { type: "UserClientRole", id: `LIST-${s}` },
382
+ { type: "RbacAudit", id: "LIST" }
383
+ ]
384
+ }),
385
+ previewRbacChange: t.mutation({
386
+ query: (e) => ({ url: `${o}/changes/preview`, method: "POST", body: e }),
387
+ transformResponse: (e) => e.data
388
+ }),
389
+ exportRbacSeed: t.query({
390
+ query: () => `${o}/export`,
391
+ transformResponse: (e) => e.data
392
+ }),
393
+ previewRbacImport: t.mutation({
394
+ query: (e) => ({ url: `${o}/import/preview`, method: "POST", body: e }),
395
+ transformResponse: (e) => e.data
396
+ }),
397
+ applyRbacImport: t.mutation({
398
+ query: (e) => ({ url: `${o}/import/apply`, method: "POST", body: e }),
399
+ transformResponse: (e) => e.data,
400
+ invalidatesTags: [{ type: "RbacSystem", id: "LIST" }]
401
+ }),
402
+ listRbacAuditEvents: t.query({
403
+ query: (e) => {
404
+ const a = new URLSearchParams();
405
+ e?.actor && a.set("actor", e.actor), e?.systemClientId && a.set("systemClientId", e.systemClientId), e?.roleName && a.set("roleName", e.roleName), e?.permissionKey && a.set("permissionKey", e.permissionKey), e?.action && a.set("action", e.action), e?.from && a.set("from", e.from), e?.to && a.set("to", e.to), e?.limit && a.set("limit", String(e.limit));
406
+ const s = a.toString();
407
+ return `${o}/audit${s ? `?${s}` : ""}`;
408
+ },
409
+ transformResponse: (e) => e.data,
410
+ providesTags: [{ type: "RbacAudit", id: "LIST" }]
411
+ }),
412
+ listRbacRoleTemplates: t.query({
413
+ query: () => `${o}/role-templates`,
414
+ transformResponse: (e) => e.data
415
+ }),
416
+ createRoleFromTemplate: t.mutation({
417
+ query: ({ clientId: e, data: a }) => ({
418
+ url: `${o}/systems/${encodeURIComponent(e)}/roles/from-template`,
419
+ method: "POST",
420
+ body: a
421
+ }),
422
+ transformResponse: (e) => e.data,
423
+ invalidatesTags: (e, a, { clientId: s }) => [{ type: "RbacSystem", id: s }]
424
+ }),
425
+ bulkAssignPermission: t.mutation({
426
+ query: (e) => ({ url: `${o}/bulk/assign-permission`, method: "POST", body: e }),
427
+ invalidatesTags: [{ type: "RbacSystem", id: "LIST" }]
428
+ }),
429
+ bulkRemovePermission: t.mutation({
430
+ query: (e) => ({ url: `${o}/bulk/remove-permission`, method: "POST", body: e }),
431
+ invalidatesTags: [{ type: "RbacSystem", id: "LIST" }]
432
+ }),
433
+ listAccessRequests: t.query({
434
+ query: () => `${o}/access-requests`,
435
+ transformResponse: (e) => e.data,
436
+ providesTags: [{ type: "RbacAccessRequest", id: "LIST" }]
437
+ }),
438
+ createAccessRequest: t.mutation({
439
+ query: (e) => ({ url: "/access-requests", method: "POST", body: e }),
440
+ transformResponse: (e) => e.data,
441
+ invalidatesTags: [{ type: "RbacAccessRequest", id: "LIST" }]
442
+ }),
443
+ decideAccessRequest: t.mutation({
444
+ query: ({ id: e, decision: a, data: s }) => ({
445
+ url: `${o}/access-requests/${encodeURIComponent(e)}/${a}`,
446
+ method: "POST",
447
+ body: s ?? {}
448
+ }),
449
+ transformResponse: (e) => e.data,
450
+ invalidatesTags: [
451
+ { type: "RbacAccessRequest", id: "LIST" },
452
+ { type: "RbacAudit", id: "LIST" }
453
+ ]
454
+ }),
455
+ listChangeRequests: t.query({
456
+ query: () => `${o}/change-requests`,
457
+ transformResponse: (e) => e.data,
458
+ providesTags: [{ type: "RbacChangeRequest", id: "LIST" }]
459
+ }),
460
+ createChangeRequest: t.mutation({
461
+ query: (e) => ({ url: `${o}/change-requests`, method: "POST", body: e }),
462
+ transformResponse: (e) => e.data,
463
+ invalidatesTags: [{ type: "RbacChangeRequest", id: "LIST" }]
464
+ }),
465
+ decideChangeRequest: t.mutation({
466
+ query: ({ id: e, decision: a, data: s }) => ({
467
+ url: `${o}/change-requests/${encodeURIComponent(e)}/${a}`,
468
+ method: "POST",
469
+ body: s ?? {}
470
+ }),
471
+ transformResponse: (e) => e.data,
472
+ invalidatesTags: [
473
+ { type: "RbacChangeRequest", id: "LIST" },
474
+ { type: "RbacAudit", id: "LIST" }
475
+ ]
476
+ }),
477
+ simulateRbacAccess: t.mutation({
478
+ query: (e) => ({ url: `${o}/simulate`, method: "POST", body: e }),
479
+ transformResponse: (e) => e.data
480
+ })
481
+ })
482
+ }), {
483
+ useApplyRbacSyncMutation: Ia,
484
+ useApplyRbacImportMutation: qa,
485
+ useAddSystemAccessRoleMutation: xa,
486
+ useAddRbacGroupMemberMutation: La,
487
+ useAssignGroupPermissionMutation: Aa,
488
+ useAssignGroupRealmRoleMutation: Pa,
489
+ useAssignGroupSystemRoleMutation: Ea,
490
+ useAssignRealmRolePermissionMutation: Na,
491
+ useAssignSystemRolePermissionMutation: Ma,
492
+ useBulkAssignPermissionMutation: Da,
493
+ useBulkRemovePermissionMutation: Ga,
494
+ useCopyRolePermissionsMutation: wa,
495
+ useCreateAccessRequestMutation: ka,
496
+ useCreateChangeRequestMutation: Ha,
497
+ useCreateRoleFromTemplateMutation: Oa,
498
+ useCreateSystemRoleMutation: Ba,
499
+ useDecideAccessRequestMutation: ja,
500
+ useDecideChangeRequestMutation: Fa,
501
+ useDeleteSystemRoleMutation: Qa,
502
+ useExportRbacSeedQuery: za,
503
+ useGetRbacDriftQuery: Va,
504
+ useGetRbacEffectiveAccessQuery: Ka,
505
+ useGetRbacGroupQuery: Ya,
506
+ useGetAssignableUserAccessQuery: Ja,
507
+ useGetUserAccessProfileQuery: Wa,
508
+ useGetRealmRoleUsageQuery: Xa,
509
+ useGetRoleUsageQuery: Za,
510
+ useListAccessRequestsQuery: es,
511
+ useListChangeRequestsQuery: ts,
512
+ useListRbacAuditEventsQuery: as,
513
+ useGetRbacSystemQuery: ss,
514
+ useListRbacPermissionsQuery: ns,
515
+ useListRbacGroupMembersQuery: is,
516
+ useListRbacGroupsQuery: kt,
517
+ useListRbacRoleTemplatesQuery: os,
518
+ useListRbacSystemsQuery: rs,
519
+ useListRealmRolePermissionsQuery: ls,
520
+ useListSystemRolesQuery: ds,
521
+ usePreviewRbacChangeMutation: cs,
522
+ usePreviewRbacImportMutation: ms,
523
+ usePreviewRbacRealmExportDriftMutation: us,
524
+ usePreviewRbacSyncMutation: ps,
525
+ useRemoveGroupPermissionMutation: ys,
526
+ useRemoveRbacGroupMemberMutation: hs,
527
+ useRemoveGroupRealmRoleMutation: Rs,
528
+ useRemoveGroupSystemRoleMutation: gs,
529
+ useRemoveRealmRolePermissionMutation: bs,
530
+ useRemoveSystemAccessRoleMutation: fs,
531
+ useRemoveSystemRolePermissionMutation: Ts,
532
+ useSimulateRbacAccessMutation: Ss,
533
+ useSyncRbacGroupMembersMutation: _s,
534
+ useUpdateUserAccessMutation: vs,
535
+ useUpdateRbacPermissionMetadataMutation: Cs,
536
+ useUpdateRbacSystemMutation: $s,
537
+ useRegisterRbacSystemMutation: Us,
538
+ useTransitionRbacSystemMutation: Is,
539
+ useUpdateSystemRoleMutation: qs,
540
+ useUpsertRbacGroupMutation: xs,
541
+ useReplaceRbacGroupMembersMutation: Ls
542
+ } = wt, L = "/admin/health-contexts", Ht = Pe.injectEndpoints({
543
+ endpoints: (t) => ({
544
+ listHealthContexts: t.query({
545
+ query: (e) => {
546
+ const a = new URLSearchParams();
547
+ e?.includeDisabled && a.set("includeDisabled", "true"), e?.type && a.set("type", e.type);
548
+ const s = a.toString();
549
+ return `${L}${s ? `?${s}` : ""}`;
550
+ },
551
+ transformResponse: (e) => e.data,
552
+ providesTags: [{ type: "HealthContext", id: "LIST" }]
553
+ }),
554
+ createHealthContext: t.mutation({
555
+ query: (e) => ({ url: L, method: "POST", body: e }),
556
+ transformResponse: (e) => e.data,
557
+ invalidatesTags: [{ type: "HealthContext", id: "LIST" }]
558
+ }),
559
+ updateHealthContext: t.mutation({
560
+ query: ({ contextId: e, body: a }) => ({
561
+ url: `${L}/${encodeURIComponent(e)}`,
562
+ method: "PUT",
563
+ body: a
564
+ }),
565
+ transformResponse: (e) => e.data,
566
+ invalidatesTags: (e, a, { contextId: s }) => [
567
+ { type: "HealthContext", id: "LIST" },
568
+ { type: "HealthContext", id: s }
569
+ ]
570
+ }),
571
+ deleteHealthContext: t.mutation({
572
+ query: (e) => ({
573
+ url: `${L}/${encodeURIComponent(e)}`,
574
+ method: "DELETE"
575
+ }),
576
+ invalidatesTags: [{ type: "HealthContext", id: "LIST" }]
577
+ }),
578
+ listHealthContextAliases: t.query({
579
+ query: (e) => `${L}/${encodeURIComponent(e)}/aliases`,
580
+ transformResponse: (e) => e.data,
581
+ providesTags: (e, a, s) => [
582
+ { type: "HealthContext", id: `${s}:aliases` }
583
+ ]
584
+ }),
585
+ upsertHealthContextAlias: t.mutation({
586
+ query: ({ contextId: e, ...a }) => ({
587
+ url: `${L}/${encodeURIComponent(e)}/aliases`,
588
+ method: "PUT",
589
+ body: a
590
+ }),
591
+ transformResponse: (e) => e.data,
592
+ invalidatesTags: (e, a, { contextId: s }) => [
593
+ { type: "HealthContext", id: `${s}:aliases` }
594
+ ]
595
+ }),
596
+ deleteHealthContextAlias: t.mutation({
597
+ query: ({ contextId: e, aliasId: a }) => ({
598
+ url: `${L}/${encodeURIComponent(e)}/aliases/${encodeURIComponent(a)}`,
599
+ method: "DELETE"
600
+ }),
601
+ invalidatesTags: (e, a, { contextId: s }) => [
602
+ { type: "HealthContext", id: `${s}:aliases` }
603
+ ]
604
+ }),
605
+ listUserHealthContexts: t.query({
606
+ query: (e) => `/admin/users/${encodeURIComponent(e)}/health-contexts`,
607
+ transformResponse: (e) => e.data,
608
+ providesTags: (e, a, s) => [
609
+ { type: "HealthContext", id: `user:${s}` }
610
+ ]
611
+ }),
612
+ replaceUserHealthContexts: t.mutation({
613
+ query: ({ targetId: e, assignments: a }) => ({
614
+ url: `/admin/users/${encodeURIComponent(e)}/health-contexts`,
615
+ method: "PUT",
616
+ body: { assignments: a }
617
+ }),
618
+ invalidatesTags: (e, a, { targetId: s }) => [
619
+ { type: "HealthContext", id: `user:${s}` }
620
+ ]
621
+ }),
622
+ listGroupHealthContexts: t.query({
623
+ query: (e) => `/admin/rbac/groups/${encodeURIComponent(e)}/health-contexts`,
624
+ transformResponse: (e) => e.data,
625
+ providesTags: (e, a, s) => [
626
+ { type: "HealthContext", id: `group:${s}` }
627
+ ]
628
+ }),
629
+ replaceGroupHealthContexts: t.mutation({
630
+ query: ({ targetId: e, assignments: a }) => ({
631
+ url: `/admin/rbac/groups/${encodeURIComponent(e)}/health-contexts`,
632
+ method: "PUT",
633
+ body: { assignments: a }
634
+ }),
635
+ invalidatesTags: (e, a, { targetId: s }) => [
636
+ { type: "HealthContext", id: `group:${s}` }
637
+ ]
638
+ }),
639
+ getHealthContextDrift: t.query({
640
+ query: () => `${L}/drift`,
641
+ transformResponse: (e) => e.data,
642
+ providesTags: [{ type: "HealthContext", id: "DRIFT" }]
643
+ }),
644
+ previewHealthContextSync: t.mutation({
645
+ query: (e) => ({
646
+ url: `${L}/sync/preview`,
647
+ method: "POST",
648
+ body: e
649
+ }),
650
+ transformResponse: (e) => e.data
651
+ }),
652
+ applyHealthContextSync: t.mutation({
653
+ query: (e) => ({
654
+ url: `${L}/sync/apply`,
655
+ method: "POST",
656
+ body: e
657
+ }),
658
+ transformResponse: (e) => e.data,
659
+ invalidatesTags: [
660
+ { type: "HealthContext", id: "DRIFT" },
661
+ { type: "HealthContext", id: "LIST" }
662
+ ]
663
+ })
664
+ })
665
+ }), {
666
+ useApplyHealthContextSyncMutation: As,
667
+ useCreateHealthContextMutation: Ps,
668
+ useDeleteHealthContextAliasMutation: Es,
669
+ useDeleteHealthContextMutation: Ns,
670
+ useListGroupHealthContextsQuery: Ms,
671
+ useGetHealthContextDriftQuery: Ds,
672
+ useListHealthContextAliasesQuery: Gs,
673
+ useListHealthContextsQuery: ws,
674
+ useListUserHealthContextsQuery: ks,
675
+ useReplaceGroupHealthContextsMutation: Hs,
676
+ useReplaceUserHealthContextsMutation: Os,
677
+ usePreviewHealthContextSyncMutation: Bs,
678
+ useUpdateHealthContextMutation: js,
679
+ useUpsertHealthContextAliasMutation: Fs
680
+ } = Ht, fe = (t) => {
681
+ const e = t.enabled ?? t.isActive ?? !1;
682
+ return {
683
+ ...t,
684
+ enabled: e,
685
+ isActive: t.isActive ?? e,
686
+ realmRoles: t.realmRoles ?? [],
687
+ clientRoles: t.clientRoles ?? {}
688
+ };
689
+ }, Ot = (t) => ({
690
+ username: t.username,
691
+ email: t.email,
692
+ first_name: t.firstName,
693
+ last_name: t.lastName,
694
+ enabled: t.enabled,
695
+ email_verified: t.emailVerified,
696
+ realm_roles: t.realmRoles,
697
+ client_roles: t.clientRoles
698
+ }), Bt = (t) => ({
699
+ email: t.email,
700
+ first_name: t.firstName,
701
+ last_name: t.lastName,
702
+ enabled: t.enabled,
703
+ email_verified: t.emailVerified,
704
+ realm_roles: t.realmRoles,
705
+ client_roles: t.clientRoles
706
+ }), jt = Pe.injectEndpoints({
707
+ endpoints: (t) => ({
708
+ /* --------------------------------
709
+ * List users
710
+ * -------------------------------- */
711
+ listUsers: t.query({
712
+ query: () => ({
713
+ url: x.admin.users.list(),
714
+ credentials: "include"
715
+ }),
716
+ transformResponse: (e) => e.data.map(fe),
717
+ providesTags: (e) => e ? [
718
+ ...e.map((a) => ({ type: "User", id: a.id })),
719
+ { type: "User", id: "LIST" }
720
+ ] : [{ type: "User", id: "LIST" }]
721
+ }),
722
+ /* --------------------------------
723
+ * Get single user
724
+ * -------------------------------- */
725
+ getUser: t.query({
726
+ query: (e) => ({
727
+ url: x.admin.users.byId(e),
728
+ credentials: "include"
729
+ }),
730
+ transformResponse: (e) => fe(e.data),
731
+ providesTags: (e, a, s) => [{ type: "User", id: s }]
732
+ }),
733
+ /* --------------------------------
734
+ * Create user
735
+ * -------------------------------- */
736
+ createUser: t.mutation({
737
+ query: (e) => ({
738
+ url: x.admin.users.create(),
739
+ method: "POST",
740
+ body: Ot(e),
741
+ credentials: "include"
742
+ }),
743
+ transformResponse: (e) => fe(e.data),
744
+ invalidatesTags: [{ type: "User", id: "LIST" }]
745
+ }),
746
+ /* --------------------------------
747
+ * Update user
748
+ * -------------------------------- */
749
+ updateUser: t.mutation({
750
+ query: ({ id: e, data: a }) => ({
751
+ url: x.admin.users.update(e),
752
+ method: "PUT",
753
+ body: Bt(a),
754
+ credentials: "include"
755
+ }),
756
+ transformResponse: (e) => fe(e.data),
757
+ invalidatesTags: (e, a, { id: s }) => [
758
+ { type: "User", id: s },
759
+ { type: "User", id: "LIST" }
760
+ ]
761
+ }),
762
+ /* --------------------------------
763
+ * Reset password
764
+ * -------------------------------- */
765
+ resetUserPassword: t.mutation({
766
+ query: (e) => ({
767
+ url: x.admin.users.passwordResetEmail(e),
768
+ method: "POST",
769
+ credentials: "include"
770
+ }),
771
+ transformResponse: () => {
772
+ },
773
+ invalidatesTags: (e, a, s) => [{ type: "User", id: s }]
774
+ }),
775
+ /* --------------------------------
776
+ * Delete user
777
+ * -------------------------------- */
778
+ deleteUser: t.mutation({
779
+ query: (e) => ({
780
+ url: x.admin.users.delete(e),
781
+ method: "DELETE",
782
+ credentials: "include"
783
+ }),
784
+ transformResponse: () => {
785
+ },
786
+ invalidatesTags: (e, a, s) => [
787
+ { type: "User", id: s },
788
+ { type: "User", id: "LIST" }
789
+ ]
790
+ }),
791
+ /* --------------------------------
792
+ * Enable / Disable user
793
+ * -------------------------------- */
794
+ toggleUser: t.mutation({
795
+ query: ({ id: e, enabled: a }) => ({
796
+ url: x.admin.users.toggle(e),
797
+ method: "PATCH",
798
+ body: { enabled: a },
799
+ credentials: "include"
800
+ }),
801
+ transformResponse: () => {
802
+ },
803
+ invalidatesTags: (e, a, { id: s }) => [
804
+ { type: "User", id: s },
805
+ { type: "User", id: "LIST" }
806
+ ]
807
+ }),
808
+ /* --------------------------------
809
+ * Get user client roles (ADMIN)
810
+ * GET /admin/users/:id/client-roles
811
+ * -------------------------------- */
812
+ getUserClientRoles: t.query({
813
+ query: (e) => ({
814
+ url: `${x.admin.base}/users/${e}/client-roles`,
815
+ credentials: "include"
816
+ }),
817
+ transformResponse: (e) => e.data,
818
+ providesTags: (e, a, s) => e ? [
819
+ ...e.map((r) => ({
820
+ type: "UserClientRole",
821
+ id: `${s}-${r.id}`
822
+ })),
823
+ { type: "UserClientRole", id: `LIST-${s}` }
824
+ ] : [{ type: "UserClientRole", id: `LIST-${s}` }]
825
+ }),
826
+ /* --------------------------------
827
+ * Get user client roles for a client (ADMIN)
828
+ * -------------------------------- */
829
+ getUserClientRolesForClient: t.query({
830
+ query: ({ userId: e, clientId: a }) => ({
831
+ url: x.admin.users.clientRoles.list(e, a),
832
+ credentials: "include"
833
+ }),
834
+ transformResponse: (e) => e.data,
835
+ providesTags: (e, a, { userId: s, clientId: r }) => [
836
+ { type: "UserClientRole", id: `${s}-${r}` }
837
+ ]
838
+ }),
839
+ /* --------------------------------
840
+ * Update user client roles (ADMIN – bulk)
841
+ * -------------------------------- */
842
+ updateUserClientRoles: t.mutation({
843
+ query: ({ userId: e, clientId: a, clientUuid: s, roles: r }) => ({
844
+ url: x.admin.users.clientRoles.update(e),
845
+ method: "PUT",
846
+ body: {
847
+ clientId: a,
848
+ clientUuid: s,
849
+ roles: r
850
+ },
851
+ credentials: "include"
852
+ }),
853
+ invalidatesTags: (e, a, { userId: s, clientUuid: r }) => [
854
+ {
855
+ type: "UserClientRole",
856
+ id: `${s}-${r}`
857
+ },
858
+ { type: "UserClientRole", id: `LIST-${s}` },
859
+ { type: "User", id: s },
860
+ { type: "User", id: "LIST" }
861
+ ]
862
+ })
863
+ })
864
+ }), {
865
+ useListUsersQuery: Qs,
866
+ useGetUserQuery: zs,
867
+ useCreateUserMutation: Vs,
868
+ useUpdateUserMutation: Ks,
869
+ useResetUserPasswordMutation: Ys,
870
+ useDeleteUserMutation: Js,
871
+ useToggleUserMutation: Ws,
872
+ useGetUserClientRolesQuery: Xs,
873
+ useGetUserClientRolesForClientQuery: Zs,
874
+ useUpdateUserClientRolesMutation: en
875
+ } = jt, k = "MOH Integrated Health Portal", ce = "http://localhost:3000/admin/home", Ue = "http://localhost:9000/api/v1/auth/login", Ft = 10 * 1024 * 1024, Qt = [
876
+ { value: "", label: "Choose a template" },
877
+ { value: "welcome", label: "Welcome" },
878
+ { value: "notification", label: "Notification" },
879
+ { value: "weekly-summary", label: "Weekly summary" },
880
+ { value: "admin-alert", label: "Admin alert" },
881
+ { value: "document-processed", label: "Document processed" },
882
+ { value: "document-failed", label: "Document failed" },
883
+ { value: "password-reset", label: "Password reset" },
884
+ { value: "verify-email", label: "Verify email" }
885
+ ];
886
+ function Ae(t) {
887
+ return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.trim());
888
+ }
889
+ function je(t) {
890
+ return t.split(",").map((e) => e.trim()).filter(Boolean).map((e) => ({ email: e }));
891
+ }
892
+ function Te(t) {
893
+ return t.split(",").map((a) => a.trim()).filter(Boolean).some((a) => !Ae(a));
894
+ }
895
+ function zt(t) {
896
+ if (typeof t == "object" && t !== null && "data" in t && typeof t.data == "object" && t.data !== null) {
897
+ const e = t.data;
898
+ if (typeof e.error?.message == "string" && e.error.message.trim())
899
+ return e.error.message;
900
+ if (typeof e.message == "string" && e.message.trim())
901
+ return e.message;
902
+ }
903
+ }
904
+ function Vt(t, e) {
905
+ return t.trim() || e.trim();
906
+ }
907
+ function Kt(t) {
908
+ return !t || t <= 0 ? "" : t < 1024 ? `${t} B` : t < 1024 * 1024 ? `${(t / 1024).toFixed(1)} KB` : `${(t / (1024 * 1024)).toFixed(1)} MB`;
909
+ }
910
+ function Yt(t) {
911
+ return new Promise((e, a) => {
912
+ const s = new FileReader();
913
+ s.onerror = () => a(new Error("Unable to read attachment file.")), s.onload = () => {
914
+ const r = String(s.result ?? ""), [, f = r] = r.split(",");
915
+ e(f);
916
+ }, s.readAsDataURL(t);
917
+ });
918
+ }
919
+ function Jt(t) {
920
+ return t.map(({ file_size: e, source: a, id: s, ...r }) => ({
921
+ ...r,
922
+ content_id: r.content_id?.trim() || void 0,
923
+ content_type: r.content_type?.trim() || void 0,
924
+ path: r.path?.trim() || void 0,
925
+ data_base64: r.data_base64?.trim() || void 0
926
+ }));
927
+ }
928
+ function Wt(t) {
929
+ for (const e of t) {
930
+ const a = !!e.path?.trim(), s = !!e.data_base64?.trim();
931
+ if (!e.file_name.trim())
932
+ return "Every attachment must have a file name.";
933
+ if (a === s)
934
+ return "Each attachment must provide exactly one of path or data_base64.";
935
+ }
936
+ return "";
937
+ }
938
+ function Xt(t) {
939
+ const e = Vt(t.recipientName, t.recipient);
940
+ switch (t.templateName) {
941
+ case "welcome":
942
+ return {
943
+ Name: e,
944
+ Platform: k,
945
+ LoginURL: Ue
946
+ };
947
+ case "password-reset":
948
+ return {
949
+ Name: e,
950
+ Platform: k,
951
+ ResetURL: `${Ue}?reset=true`,
952
+ ExpiresIn: "30 minutes"
953
+ };
954
+ case "verify-email":
955
+ return {
956
+ Name: e,
957
+ Platform: k,
958
+ VerifyURL: `${Ue}?verify=true`
959
+ };
960
+ case "notification":
961
+ return {
962
+ Subject: t.subject.trim(),
963
+ Heading: t.subject.trim(),
964
+ Message: t.message.trim(),
965
+ ActionURL: ce,
966
+ ActionLabel: "Open Dashboard",
967
+ Platform: k
968
+ };
969
+ case "document-processed":
970
+ return {
971
+ Name: e,
972
+ Platform: k,
973
+ DocumentName: t.subject.trim() || "Uploaded document",
974
+ DocumentType: "Document",
975
+ ActionURL: ce
976
+ };
977
+ case "document-failed":
978
+ return {
979
+ Name: e,
980
+ Platform: k,
981
+ DocumentName: t.subject.trim() || "Uploaded document",
982
+ Reason: t.message.trim(),
983
+ ActionURL: ce
984
+ };
985
+ case "weekly-summary":
986
+ return {
987
+ Name: e,
988
+ Platform: k,
989
+ Period: "Current week",
990
+ Summary: t.message.trim(),
991
+ ActionURL: ce
992
+ };
993
+ case "admin-alert":
994
+ return {
995
+ Platform: k,
996
+ Message: t.message.trim(),
997
+ Details: t.subject.trim(),
998
+ ActionURL: ce
999
+ };
1000
+ default:
1001
+ return;
1002
+ }
1003
+ }
1004
+ const Zt = ({ onSuccess: t }) => {
1005
+ const e = Fe(), a = Ct(), s = $t(0), [r, f] = u(""), [$, g] = u(""), [H, O] = u([]), [D, ee] = u([]), [te, P] = u(!1), [E, B] = u(""), [T, q] = u(""), [S, ae] = u(""), [N, G] = u(""), [j, se] = u(""), [Y, ne] = u(!1), [h, pe] = u(!1), [_, ie] = u(""), [oe, ye] = u(""), [U, he] = u("queue"), [F, Q] = u([]), [d, b] = u(""), [J, z] = u(""), [w, re] = u(""), [M, y] = u(!1), [I, R] = u(""), [V, Ee] = u(!1), [Qe, ze] = It(), [Ve, Ke] = qt(), {
1006
+ data: Ne = [],
1007
+ isLoading: Ye,
1008
+ isError: Me
1009
+ } = kt(), De = Gt(), c = ze.isLoading || Ke.isLoading, Ge = Z(
1010
+ () => Ne.filter((i) => i.enabled).map((i) => ({
1011
+ id: i.id,
1012
+ text: i.displayName || i.path || i.name
1013
+ })),
1014
+ [Ne]
1015
+ ), we = Z(
1016
+ () => De.filter((i) => i.enabled).map((i) => ({
1017
+ id: i.id,
1018
+ text: `${i.name} (${i.contextType.toLowerCase()})`
1019
+ })),
1020
+ [De]
1021
+ ), W = r.trim().length > 0, _e = H.length > 0, Re = D.length > 0, Je = V && W && !Ae(r), ge = V && !W && !_e && !Re, We = V && S.trim().length === 0, Xe = V && N.trim().length === 0, Ze = V && h && _ === "", et = V && E.trim().length > 0 && Te(E), tt = V && T.trim().length > 0 && Te(T), ve = Wt(F), at = Z(() => (W || _e || Re) && (!W || Ae(r)) && S.trim().length > 0 && N.trim().length > 0 && (!h || _ !== "") && !Te(E) && !Te(T) && !ve && !c, [
1022
+ r,
1023
+ W,
1024
+ _e,
1025
+ Re,
1026
+ S,
1027
+ N,
1028
+ E,
1029
+ T,
1030
+ h,
1031
+ _,
1032
+ ve,
1033
+ c
1034
+ ]), ke = () => {
1035
+ f(""), g(""), O([]), ee([]), P(!1), B(""), q(""), ae(""), G(""), se(""), ne(!1), pe(!1), ie(""), ye(""), Q([]), b(""), z(""), re(""), y(!1), R(""), Ee(!1);
1036
+ }, st = async (i) => {
1037
+ if (!i?.length)
1038
+ return;
1039
+ const m = [];
1040
+ for (const p of Array.from(i)) {
1041
+ if (p.size > Ft) {
1042
+ e.error({
1043
+ title: "Attachment too large",
1044
+ subtitle: `${p.name} is larger than 10 MB.`
1045
+ });
1046
+ continue;
1047
+ }
1048
+ try {
1049
+ m.push({
1050
+ id: `${a}-attachment-${s.current++}`,
1051
+ source: "file",
1052
+ file_name: p.name,
1053
+ content_type: p.type || "application/octet-stream",
1054
+ data_base64: await Yt(p),
1055
+ file_size: p.size,
1056
+ inline: !1
1057
+ });
1058
+ } catch {
1059
+ e.error({
1060
+ title: "Attachment failed",
1061
+ subtitle: `Unable to read ${p.name}.`
1062
+ });
1063
+ }
1064
+ }
1065
+ m.length > 0 && Q((p) => [...p, ...m]);
1066
+ }, nt = () => {
1067
+ const i = d.trim(), m = w.trim();
1068
+ if (!i || !m) {
1069
+ e.error({
1070
+ title: "Missing path attachment details",
1071
+ subtitle: "Provide both a file name and a server-side path."
1072
+ });
1073
+ return;
1074
+ }
1075
+ Q((p) => [
1076
+ ...p,
1077
+ {
1078
+ id: `path-${Date.now()}`,
1079
+ source: "path",
1080
+ file_name: i,
1081
+ content_type: J.trim() || void 0,
1082
+ path: m,
1083
+ inline: M,
1084
+ content_id: M && I.trim() || void 0
1085
+ }
1086
+ ]), b(""), z(""), re(""), y(!1), R("");
1087
+ }, it = (i) => {
1088
+ Q((m) => m.filter((p) => p.id !== i));
1089
+ }, He = (i, m) => {
1090
+ Q(
1091
+ (p) => p.map(
1092
+ (be) => be.id === i ? {
1093
+ ...be,
1094
+ ...m,
1095
+ content_id: m.inline === !1 ? void 0 : m.content_id ?? be.content_id
1096
+ } : be
1097
+ )
1098
+ );
1099
+ }, ot = () => {
1100
+ const i = h && _ ? Xt({
1101
+ templateName: _,
1102
+ recipientName: $,
1103
+ recipient: r,
1104
+ subject: S,
1105
+ message: N
1106
+ }) : void 0;
1107
+ return {
1108
+ to: W ? [
1109
+ {
1110
+ name: $.trim() || void 0,
1111
+ email: r.trim()
1112
+ }
1113
+ ] : void 0,
1114
+ to_groups: H.length > 0 ? H : void 0,
1115
+ to_health_contexts: D.length > 0 ? D : void 0,
1116
+ include_health_context_descendants: D.length > 0 ? te : void 0,
1117
+ cc: E.trim() ? je(E) : void 0,
1118
+ bcc: T.trim() ? je(T) : void 0,
1119
+ subject: S.trim(),
1120
+ text_body: N.trim(),
1121
+ html_body: !h && Y && j.trim() ? j.trim() : void 0,
1122
+ template_name: h && _ ? _ : void 0,
1123
+ template_data: i,
1124
+ scheduled_at: U === "queue" && oe ? new Date(oe).toISOString() : void 0,
1125
+ metadata: {
1126
+ source: "admin-email-panel",
1127
+ delivery_mode: U,
1128
+ template_name: h ? _ : ""
1129
+ },
1130
+ attachments: F.length > 0 ? Jt(F) : void 0
1131
+ };
1132
+ };
1133
+ return /* @__PURE__ */ n("div", { className: "email-panel", children: /* @__PURE__ */ n(xe, { className: "email-panel__tile", children: /* @__PURE__ */ l(K, { gap: 6, children: [
1134
+ /* @__PURE__ */ l("div", { className: "email-panel__header", children: [
1135
+ /* @__PURE__ */ n("h2", { className: "email-panel__title", children: "Send email" }),
1136
+ /* @__PURE__ */ n("p", { className: "email-panel__description", children: "Send immediately through SMTP or queue the message for background delivery and retries. You can also use one of the default email templates." })
1137
+ ] }),
1138
+ /* @__PURE__ */ n(rt, { onSubmit: async (i) => {
1139
+ if (i.preventDefault(), Ee(!0), !at) {
1140
+ e.error({
1141
+ title: "Missing or invalid fields",
1142
+ subtitle: ve || "Please provide a valid recipient email, subject, message, valid CC/BCC emails, and a template if enabled."
1143
+ });
1144
+ return;
1145
+ }
1146
+ try {
1147
+ const m = ot();
1148
+ U === "send" ? (await Qe(m).unwrap(), e.success({
1149
+ title: "Email sent",
1150
+ subtitle: h ? `Sent using the ${_} template.` : "The email was delivered through the SMTP service."
1151
+ })) : (await Ve(m).unwrap(), e.success({
1152
+ title: "Email queued",
1153
+ subtitle: h ? `Queued using the ${_} template.` : "The background email worker will process it shortly."
1154
+ })), ke(), t?.();
1155
+ } catch (m) {
1156
+ e.error({
1157
+ title: U === "send" ? "Failed to send email" : "Failed to queue email",
1158
+ subtitle: zt(m) ?? "Please check the email service logs and try again."
1159
+ });
1160
+ }
1161
+ }, className: "email-form", children: /* @__PURE__ */ l(K, { gap: 5, children: [
1162
+ /* @__PURE__ */ l("div", { className: "email-form__mode", children: [
1163
+ /* @__PURE__ */ n(
1164
+ A,
1165
+ {
1166
+ type: "button",
1167
+ kind: U === "queue" ? "primary" : "tertiary",
1168
+ size: "sm",
1169
+ disabled: c,
1170
+ onClick: () => he("queue"),
1171
+ children: "Queue email"
1172
+ }
1173
+ ),
1174
+ /* @__PURE__ */ n(
1175
+ A,
1176
+ {
1177
+ type: "button",
1178
+ kind: U === "send" ? "primary" : "tertiary",
1179
+ size: "sm",
1180
+ disabled: c,
1181
+ onClick: () => he("send"),
1182
+ children: "Send now"
1183
+ }
1184
+ )
1185
+ ] }),
1186
+ /* @__PURE__ */ l("div", { className: "email-form__section", children: [
1187
+ /* @__PURE__ */ n("h3", { className: "email-form__section-title", children: "Recipient" }),
1188
+ /* @__PURE__ */ l(K, { gap: 4, children: [
1189
+ /* @__PURE__ */ n(
1190
+ v,
1191
+ {
1192
+ id: "recipient-name",
1193
+ labelText: "Recipient name",
1194
+ value: $,
1195
+ onChange: (i) => g(i.target.value),
1196
+ placeholder: "Optional name",
1197
+ disabled: c
1198
+ }
1199
+ ),
1200
+ /* @__PURE__ */ n(
1201
+ v,
1202
+ {
1203
+ id: "recipient",
1204
+ type: "email",
1205
+ labelText: "Recipient email",
1206
+ value: r,
1207
+ onChange: (i) => f(i.target.value),
1208
+ placeholder: "user@example.com",
1209
+ invalid: Je || ge,
1210
+ invalidText: ge ? "Enter a recipient email or select at least one group or health context." : "Enter a valid recipient email address",
1211
+ disabled: c
1212
+ }
1213
+ ),
1214
+ /* @__PURE__ */ n(
1215
+ Oe,
1216
+ {
1217
+ id: "recipient-groups",
1218
+ titleText: "Recipient groups",
1219
+ label: Me ? "Unable to load groups" : "Select groups",
1220
+ items: Ge,
1221
+ itemToString: (i) => i?.text ?? "",
1222
+ selectedItems: Ge.filter((i) => H.includes(i.id)),
1223
+ disabled: c || Ye || Me,
1224
+ invalid: ge,
1225
+ invalidText: "Enter a recipient email or select at least one group or health context.",
1226
+ onChange: ({ selectedItems: i }) => O((i ?? []).map((m) => m.id))
1227
+ }
1228
+ ),
1229
+ /* @__PURE__ */ n(
1230
+ Oe,
1231
+ {
1232
+ id: "recipient-health-contexts",
1233
+ titleText: "Recipient health contexts",
1234
+ label: "Select health contexts",
1235
+ items: we,
1236
+ itemToString: (i) => i?.text ?? "",
1237
+ selectedItems: we.filter(
1238
+ (i) => D.includes(i.id)
1239
+ ),
1240
+ disabled: c,
1241
+ invalid: ge,
1242
+ invalidText: "Enter a recipient email or select at least one group or health context.",
1243
+ onChange: ({ selectedItems: i }) => ee((i ?? []).map((m) => m.id))
1244
+ }
1245
+ ),
1246
+ Re ? /* @__PURE__ */ n(
1247
+ le,
1248
+ {
1249
+ id: "recipient-health-context-descendants",
1250
+ labelText: "Include users assigned to descendant health contexts",
1251
+ checked: te,
1252
+ onChange: (i, { checked: m }) => P(!!m),
1253
+ disabled: c
1254
+ }
1255
+ ) : null,
1256
+ /* @__PURE__ */ n(
1257
+ v,
1258
+ {
1259
+ id: "cc",
1260
+ type: "text",
1261
+ labelText: "CC",
1262
+ value: E,
1263
+ onChange: (i) => B(i.target.value),
1264
+ placeholder: "Optional, comma-separated emails",
1265
+ invalid: et,
1266
+ invalidText: "One or more CC email addresses are invalid",
1267
+ disabled: c
1268
+ }
1269
+ ),
1270
+ /* @__PURE__ */ n(
1271
+ v,
1272
+ {
1273
+ id: "bcc",
1274
+ type: "text",
1275
+ labelText: "BCC",
1276
+ value: T,
1277
+ onChange: (i) => q(i.target.value),
1278
+ placeholder: "Optional, comma-separated emails",
1279
+ invalid: tt,
1280
+ invalidText: "One or more BCC email addresses are invalid",
1281
+ disabled: c
1282
+ }
1283
+ )
1284
+ ] })
1285
+ ] }),
1286
+ /* @__PURE__ */ l("div", { className: "email-form__section", children: [
1287
+ /* @__PURE__ */ n("h3", { className: "email-form__section-title", children: "Template" }),
1288
+ /* @__PURE__ */ l(K, { gap: 4, children: [
1289
+ /* @__PURE__ */ n(
1290
+ le,
1291
+ {
1292
+ id: "use-template",
1293
+ labelText: "Use default template",
1294
+ checked: h,
1295
+ disabled: c,
1296
+ onChange: (i, m) => {
1297
+ const p = !!m.checked;
1298
+ pe(p), p ? (ne(!1), se("")) : ie("");
1299
+ }
1300
+ }
1301
+ ),
1302
+ h && /* @__PURE__ */ n(
1303
+ lt,
1304
+ {
1305
+ id: "template-name",
1306
+ labelText: "Default template",
1307
+ value: _,
1308
+ invalid: Ze,
1309
+ invalidText: "Choose a template",
1310
+ disabled: c,
1311
+ onChange: (i) => ie(i.target.value),
1312
+ children: Qt.map((i) => /* @__PURE__ */ n(
1313
+ dt,
1314
+ {
1315
+ value: i.value,
1316
+ text: i.label
1317
+ },
1318
+ i.value || "empty"
1319
+ ))
1320
+ }
1321
+ )
1322
+ ] })
1323
+ ] }),
1324
+ /* @__PURE__ */ l("div", { className: "email-form__section", children: [
1325
+ /* @__PURE__ */ n("h3", { className: "email-form__section-title", children: "Message" }),
1326
+ /* @__PURE__ */ l(K, { gap: 4, children: [
1327
+ /* @__PURE__ */ n(
1328
+ v,
1329
+ {
1330
+ id: "subject",
1331
+ labelText: "Subject",
1332
+ value: S,
1333
+ onChange: (i) => ae(i.target.value),
1334
+ placeholder: "Email subject",
1335
+ invalid: We,
1336
+ invalidText: "Subject is required",
1337
+ disabled: c,
1338
+ required: !0
1339
+ }
1340
+ ),
1341
+ /* @__PURE__ */ n(
1342
+ Be,
1343
+ {
1344
+ id: "message",
1345
+ labelText: h ? "Template message / content" : "Plain text message",
1346
+ helperText: h ? "This content is mapped into the selected template." : void 0,
1347
+ value: N,
1348
+ onChange: (i) => G(i.target.value),
1349
+ placeholder: "Write your message here",
1350
+ rows: 7,
1351
+ invalid: Xe,
1352
+ invalidText: "Message is required",
1353
+ disabled: c,
1354
+ required: !0
1355
+ }
1356
+ ),
1357
+ !h && /* @__PURE__ */ l(ue, { children: [
1358
+ /* @__PURE__ */ n(
1359
+ le,
1360
+ {
1361
+ id: "use-html-body",
1362
+ labelText: "Add HTML body",
1363
+ checked: Y,
1364
+ disabled: c,
1365
+ onChange: (i, m) => ne(!!m.checked)
1366
+ }
1367
+ ),
1368
+ Y && /* @__PURE__ */ n(
1369
+ Be,
1370
+ {
1371
+ id: "html-body",
1372
+ labelText: "HTML body",
1373
+ value: j,
1374
+ onChange: (i) => se(i.target.value),
1375
+ placeholder: "<p>Hello...</p>",
1376
+ rows: 7,
1377
+ disabled: c
1378
+ }
1379
+ )
1380
+ ] })
1381
+ ] })
1382
+ ] }),
1383
+ U === "queue" && /* @__PURE__ */ l("div", { className: "email-form__section", children: [
1384
+ /* @__PURE__ */ n("h3", { className: "email-form__section-title", children: "Scheduling" }),
1385
+ /* @__PURE__ */ n(
1386
+ v,
1387
+ {
1388
+ id: "scheduled-at",
1389
+ type: "datetime-local",
1390
+ labelText: "Scheduled time",
1391
+ helperText: "Optional. Leave empty to queue immediately.",
1392
+ value: oe,
1393
+ onChange: (i) => ye(i.target.value),
1394
+ disabled: c
1395
+ }
1396
+ )
1397
+ ] }),
1398
+ /* @__PURE__ */ l("div", { className: "email-form__section", children: [
1399
+ /* @__PURE__ */ n("h3", { className: "email-form__section-title", children: "Attachments" }),
1400
+ /* @__PURE__ */ l(K, { gap: 4, children: [
1401
+ /* @__PURE__ */ n("div", { className: "email-form__attachment-upload", children: /* @__PURE__ */ n(
1402
+ v,
1403
+ {
1404
+ id: "email-attachment-file",
1405
+ type: "file",
1406
+ labelText: "Upload files",
1407
+ helperText: "Files are sent as base64 payloads. Maximum 10 MB per file.",
1408
+ multiple: !0,
1409
+ disabled: c,
1410
+ onChange: (i) => {
1411
+ st(i.target.files), i.currentTarget.value = "";
1412
+ }
1413
+ }
1414
+ ) }),
1415
+ /* @__PURE__ */ l("div", { className: "email-form__path-attachment", children: [
1416
+ /* @__PURE__ */ n(
1417
+ v,
1418
+ {
1419
+ id: "email-path-attachment-name",
1420
+ labelText: "Server path attachment file name",
1421
+ value: d,
1422
+ onChange: (i) => b(i.target.value),
1423
+ placeholder: "report.pdf",
1424
+ disabled: c
1425
+ }
1426
+ ),
1427
+ /* @__PURE__ */ n(
1428
+ v,
1429
+ {
1430
+ id: "email-path-attachment-content-type",
1431
+ labelText: "Content type",
1432
+ value: J,
1433
+ onChange: (i) => z(i.target.value),
1434
+ placeholder: "application/pdf",
1435
+ disabled: c
1436
+ }
1437
+ ),
1438
+ /* @__PURE__ */ n(
1439
+ v,
1440
+ {
1441
+ id: "email-path-attachment-path",
1442
+ labelText: "Server path",
1443
+ value: w,
1444
+ onChange: (i) => re(i.target.value),
1445
+ placeholder: "/data/uploads/report.pdf",
1446
+ disabled: c
1447
+ }
1448
+ ),
1449
+ /* @__PURE__ */ n(
1450
+ le,
1451
+ {
1452
+ id: "email-path-attachment-inline",
1453
+ labelText: "Inline",
1454
+ checked: M,
1455
+ disabled: c,
1456
+ onChange: (i, m) => y(!!m.checked)
1457
+ }
1458
+ ),
1459
+ M && /* @__PURE__ */ n(
1460
+ v,
1461
+ {
1462
+ id: "email-path-attachment-content-id",
1463
+ labelText: "Content ID",
1464
+ value: I,
1465
+ onChange: (i) => R(i.target.value),
1466
+ placeholder: "logo",
1467
+ disabled: c
1468
+ }
1469
+ ),
1470
+ /* @__PURE__ */ n(
1471
+ A,
1472
+ {
1473
+ type: "button",
1474
+ kind: "tertiary",
1475
+ size: "sm",
1476
+ disabled: c || !d.trim() || !w.trim(),
1477
+ onClick: nt,
1478
+ children: "Add path attachment"
1479
+ }
1480
+ )
1481
+ ] }),
1482
+ F.length === 0 ? /* @__PURE__ */ n("p", { className: "email-form__attachment-empty", children: "No attachments added." }) : /* @__PURE__ */ n("ul", { className: "email-form__attachments", children: F.map((i) => /* @__PURE__ */ l("li", { className: "email-form__attachment", children: [
1483
+ /* @__PURE__ */ l("div", { className: "email-form__attachment-main", children: [
1484
+ /* @__PURE__ */ n("strong", { children: i.file_name }),
1485
+ /* @__PURE__ */ l("span", { children: [
1486
+ i.content_type || "application/octet-stream",
1487
+ i.file_size ? ` · ${Kt(i.file_size)}` : ""
1488
+ ] }),
1489
+ /* @__PURE__ */ n(Se, { type: i.source === "file" ? "blue" : "purple", size: "sm", children: i.source === "file" ? "File" : "Path" })
1490
+ ] }),
1491
+ /* @__PURE__ */ l("div", { className: "email-form__attachment-meta", children: [
1492
+ /* @__PURE__ */ n(
1493
+ le,
1494
+ {
1495
+ id: `email-attachment-inline-${i.id}`,
1496
+ labelText: "Inline",
1497
+ checked: !!i.inline,
1498
+ disabled: c,
1499
+ onChange: (m, p) => He(i.id, {
1500
+ inline: !!p.checked
1501
+ })
1502
+ }
1503
+ ),
1504
+ i.inline && /* @__PURE__ */ n(
1505
+ v,
1506
+ {
1507
+ id: `email-attachment-content-id-${i.id}`,
1508
+ labelText: "Content ID",
1509
+ value: i.content_id ?? "",
1510
+ disabled: c,
1511
+ onChange: (m) => He(i.id, {
1512
+ content_id: m.target.value
1513
+ })
1514
+ }
1515
+ ),
1516
+ /* @__PURE__ */ n(
1517
+ A,
1518
+ {
1519
+ type: "button",
1520
+ kind: "ghost",
1521
+ size: "sm",
1522
+ renderIcon: _t,
1523
+ iconDescription: "Remove attachment",
1524
+ disabled: c,
1525
+ onClick: () => it(i.id),
1526
+ children: "Remove"
1527
+ }
1528
+ )
1529
+ ] })
1530
+ ] }, i.id)) })
1531
+ ] })
1532
+ ] }),
1533
+ /* @__PURE__ */ l("div", { className: "email-form__actions", children: [
1534
+ /* @__PURE__ */ n(A, { type: "submit", disabled: c, children: c ? U === "send" ? "Sending..." : "Queueing..." : U === "send" ? "Send email" : "Queue email" }),
1535
+ /* @__PURE__ */ n(A, { type: "button", kind: "secondary", disabled: c, onClick: ke, children: "Clear" })
1536
+ ] }),
1537
+ c && /* @__PURE__ */ n(ct, { small: !0, withOverlay: !1 })
1538
+ ] }) })
1539
+ ] }) }) });
1540
+ };
1541
+ function me(t) {
1542
+ if (!t) return "—";
1543
+ const e = new Date(t);
1544
+ return Number.isNaN(e.getTime()) ? "—" : e.toLocaleString();
1545
+ }
1546
+ function ea(t) {
1547
+ if (!t) return "—";
1548
+ try {
1549
+ return JSON.stringify(t, null, 2);
1550
+ } catch {
1551
+ return "Unable to display JSON data.";
1552
+ }
1553
+ }
1554
+ function ta(t) {
1555
+ return t?.message?.to?.map((e) => e.email).join(", ") || "—";
1556
+ }
1557
+ function aa(t) {
1558
+ return t?.message?.cc?.map((e) => e.email).join(", ") || "—";
1559
+ }
1560
+ function sa(t) {
1561
+ return t?.message?.bcc?.map((e) => e.email).join(", ") || "—";
1562
+ }
1563
+ function na(t) {
1564
+ return t?.message?.subject || "—";
1565
+ }
1566
+ function ia(t) {
1567
+ return t?.message?.html_body || t?.message?.text_body || "No message body available.";
1568
+ }
1569
+ function C({ label: t, children: e }) {
1570
+ return /* @__PURE__ */ l("div", { className: "email-details__item", children: [
1571
+ /* @__PURE__ */ n("dt", { className: "email-details__label", children: t }),
1572
+ /* @__PURE__ */ n("dd", { className: "email-details__value", children: e })
1573
+ ] });
1574
+ }
1575
+ function oa({ email: t }) {
1576
+ return /* @__PURE__ */ l(K, { gap: 5, children: [
1577
+ /* @__PURE__ */ l("dl", { className: "email-details", children: [
1578
+ /* @__PURE__ */ n(C, { label: "Subject", children: na(t) }),
1579
+ /* @__PURE__ */ n(C, { label: "To", children: ta(t) }),
1580
+ t.message?.cc?.length ? /* @__PURE__ */ n(C, { label: "CC", children: aa(t) }) : null,
1581
+ t.message?.bcc?.length ? /* @__PURE__ */ n(C, { label: "BCC", children: sa(t) }) : null,
1582
+ /* @__PURE__ */ n(C, { label: "Status", children: /* @__PURE__ */ n(Se, { type: ra(t.status), children: t.status }) }),
1583
+ /* @__PURE__ */ l(C, { label: "Attempts", children: [
1584
+ t.attempts ?? 0,
1585
+ "/",
1586
+ t.max_attempts ?? "—"
1587
+ ] }),
1588
+ /* @__PURE__ */ n(C, { label: "Scheduled at", children: me(t.scheduled_at) }),
1589
+ /* @__PURE__ */ n(C, { label: "Locked at", children: me(t.locked_at) }),
1590
+ /* @__PURE__ */ n(C, { label: "Sent at", children: me(t.sent_at) }),
1591
+ /* @__PURE__ */ n(C, { label: "Created at", children: me(t.created_at) }),
1592
+ /* @__PURE__ */ n(C, { label: "Updated at", children: me(t.updated_at) }),
1593
+ t.message?.template_name ? /* @__PURE__ */ n(C, { label: "Template", children: /* @__PURE__ */ n(Se, { type: "blue", children: t.message.template_name }) }) : null
1594
+ ] }),
1595
+ t.message?.template_data ? /* @__PURE__ */ l("section", { className: "email-details__section", children: [
1596
+ /* @__PURE__ */ n("h4", { className: "email-details__section-title", children: "Template data" }),
1597
+ /* @__PURE__ */ n("pre", { className: "email-details__json", children: ea(t.message.template_data) })
1598
+ ] }) : null,
1599
+ t.last_error && /* @__PURE__ */ l("section", { className: "email-details__section", children: [
1600
+ /* @__PURE__ */ n("h4", { className: "email-details__section-title", children: "Last error" }),
1601
+ /* @__PURE__ */ n("pre", { className: "email-outbox-page__error", children: t.last_error })
1602
+ ] }),
1603
+ t.message?.attachments?.length ? /* @__PURE__ */ l("section", { className: "email-details__section", children: [
1604
+ /* @__PURE__ */ n("h4", { className: "email-details__section-title", children: "Attachments" }),
1605
+ /* @__PURE__ */ n("ul", { className: "email-details__attachments", children: t.message.attachments.map((e, a) => /* @__PURE__ */ l("li", { children: [
1606
+ /* @__PURE__ */ n("strong", { children: e.file_name || "Attachment" }),
1607
+ e.content_type ? /* @__PURE__ */ l("span", { children: [
1608
+ " · ",
1609
+ e.content_type
1610
+ ] }) : null,
1611
+ e.inline ? /* @__PURE__ */ n("span", { children: " · inline" }) : null,
1612
+ e.content_id ? /* @__PURE__ */ l("span", { children: [
1613
+ " · cid:",
1614
+ e.content_id
1615
+ ] }) : null,
1616
+ e.path ? /* @__PURE__ */ n("div", { children: e.path }) : null
1617
+ ] }, `${e.file_name}-${a}`)) })
1618
+ ] }) : null,
1619
+ /* @__PURE__ */ l("section", { className: "email-details__section", children: [
1620
+ /* @__PURE__ */ n("h4", { className: "email-details__section-title", children: "Message" }),
1621
+ /* @__PURE__ */ n("pre", { className: "email-outbox-page__body", children: ia(t) })
1622
+ ] })
1623
+ ] });
1624
+ }
1625
+ function ra(t) {
1626
+ switch (t) {
1627
+ case "SENT":
1628
+ return "green";
1629
+ case "FAILED":
1630
+ return "red";
1631
+ case "PROCESSING":
1632
+ return "blue";
1633
+ case "RETRY":
1634
+ return "magenta";
1635
+ case "PENDING":
1636
+ return "gray";
1637
+ default:
1638
+ return "cool-gray";
1639
+ }
1640
+ }
1641
+ function la({
1642
+ email: t,
1643
+ isMutating: e = !1,
1644
+ onView: a,
1645
+ onRetry: s,
1646
+ onDelete: r
1647
+ }) {
1648
+ const f = t.status === "FAILED" || t.status === "RETRY";
1649
+ return /* @__PURE__ */ l(mt, { size: "sm", flipped: !0, children: [
1650
+ /* @__PURE__ */ n(Ce, { itemText: "View details", onClick: a }),
1651
+ f && /* @__PURE__ */ n(Ce, { itemText: "Retry", onClick: s, disabled: e }),
1652
+ /* @__PURE__ */ n(
1653
+ Ce,
1654
+ {
1655
+ itemText: "Delete",
1656
+ onClick: r,
1657
+ disabled: e,
1658
+ isDelete: !0,
1659
+ hasDivider: !0
1660
+ }
1661
+ )
1662
+ ] });
1663
+ }
1664
+ function da({
1665
+ search: t,
1666
+ status: e,
1667
+ statusOptions: a,
1668
+ onSearchChange: s,
1669
+ onStatusChange: r,
1670
+ onReset: f
1671
+ }) {
1672
+ const $ = [...a];
1673
+ return /* @__PURE__ */ l("div", { className: "email-outbox-filter-grid", children: [
1674
+ /* @__PURE__ */ n(
1675
+ ut,
1676
+ {
1677
+ id: "email-outbox-search",
1678
+ labelText: "Search emails",
1679
+ placeholder: "Search by subject, recipient, status, or ID...",
1680
+ value: t,
1681
+ onChange: (g) => s(g.target.value)
1682
+ }
1683
+ ),
1684
+ /* @__PURE__ */ n(
1685
+ pt,
1686
+ {
1687
+ id: "email-status-filter",
1688
+ titleText: "Status",
1689
+ label: "Status",
1690
+ items: $,
1691
+ itemToString: (g) => g?.label ?? "",
1692
+ selectedItem: $.find((g) => g.id === e),
1693
+ onChange: ({ selectedItem: g }) => {
1694
+ g && r(g.id);
1695
+ }
1696
+ }
1697
+ ),
1698
+ /* @__PURE__ */ n(A, { kind: "ghost", onClick: f, children: "Clear filters" })
1699
+ ] });
1700
+ }
1701
+ function ca({
1702
+ emails: t,
1703
+ loadingAction: e,
1704
+ onRetry: a,
1705
+ onDelete: s
1706
+ }) {
1707
+ if (t.length === 0) return null;
1708
+ const r = !!e;
1709
+ return /* @__PURE__ */ l("div", { className: "email-outbox-bulk-actions", children: [
1710
+ /* @__PURE__ */ l("strong", { children: [
1711
+ t.length,
1712
+ " selected"
1713
+ ] }),
1714
+ /* @__PURE__ */ l("div", { className: "email-outbox-bulk-actions__buttons", children: [
1715
+ r && /* @__PURE__ */ n(Le, { description: "Processing…" }),
1716
+ /* @__PURE__ */ n(A, { size: "sm", kind: "secondary", disabled: r, onClick: a, children: "Retry" }),
1717
+ /* @__PURE__ */ n(A, { size: "sm", kind: "danger--tertiary", disabled: r, onClick: s, children: "Delete" })
1718
+ ] })
1719
+ ] });
1720
+ }
1721
+ const ma = [
1722
+ { id: "all", label: "All emails" },
1723
+ { id: "pending", label: "Pending" },
1724
+ { id: "processing", label: "Processing" },
1725
+ { id: "sent", label: "Sent" },
1726
+ { id: "failed", label: "Failed" },
1727
+ { id: "retry", label: "Retry" }
1728
+ ], ua = [
1729
+ { key: "subject", header: "Subject" },
1730
+ { key: "to", header: "Recipient" },
1731
+ { key: "status", header: "Status" },
1732
+ { key: "attempts", header: "Attempts" },
1733
+ { key: "scheduledAt", header: "Scheduled" },
1734
+ { key: "sentAt", header: "Sent" },
1735
+ { key: "createdAt", header: "Created" },
1736
+ { key: "actions", header: "" },
1737
+ { key: "raw", header: "" }
1738
+ // hidden
1739
+ ];
1740
+ function Ie(t) {
1741
+ if (!t) return "—";
1742
+ const e = new Date(t);
1743
+ return Number.isNaN(e.getTime()) ? "—" : e.toLocaleString();
1744
+ }
1745
+ function pa(t) {
1746
+ switch (t) {
1747
+ case "SENT":
1748
+ return "green";
1749
+ case "FAILED":
1750
+ return "red";
1751
+ case "PROCESSING":
1752
+ return "blue";
1753
+ case "RETRY":
1754
+ return "magenta";
1755
+ case "PENDING":
1756
+ return "gray";
1757
+ default:
1758
+ return "cool-gray";
1759
+ }
1760
+ }
1761
+ function qe(t) {
1762
+ return t?.message?.to?.map((e) => e.email).join(", ") || "—";
1763
+ }
1764
+ function X(t) {
1765
+ return t?.message?.subject || "—";
1766
+ }
1767
+ function ya(t) {
1768
+ return t === "all" ? "ALL" : t.toUpperCase();
1769
+ }
1770
+ function ha() {
1771
+ const { openPanel: t, closePanel: e } = Et(), { openModal: a, closeModal: s } = Nt(), r = Fe(), [f, $] = u(null), [g, H] = u("all"), [O, D] = u(""), [ee, te] = u(1), [P, E] = u(20), B = (ee - 1) * P, T = ya(g), q = xt(
1772
+ {
1773
+ limit: P,
1774
+ offset: B
1775
+ },
1776
+ {
1777
+ skip: T !== "ALL"
1778
+ }
1779
+ ), S = Lt(
1780
+ {
1781
+ status: T,
1782
+ limit: P,
1783
+ offset: B
1784
+ },
1785
+ {
1786
+ skip: T === "ALL"
1787
+ }
1788
+ ), [ae] = At(), [N] = Pt(), G = Z(() => T === "ALL" ? q.data ?? [] : S.data ?? [], [T, q.data, S.data]), j = q.isLoading || S.isLoading, se = q.isFetching || S.isFetching, Y = q.isError || S.isError, ne = q.error || S.error;
1789
+ Ut(() => {
1790
+ te(1);
1791
+ }, [g, O]);
1792
+ const h = Z(() => {
1793
+ const d = O.trim().toLowerCase();
1794
+ return d ? G.filter((b) => {
1795
+ const J = X(b).toLowerCase(), z = qe(b).toLowerCase(), w = b.status?.toLowerCase() ?? "";
1796
+ return J.includes(d) || z.includes(d) || w.includes(d) || b.id.toLowerCase().includes(d);
1797
+ }) : G;
1798
+ }, [G, O]), pe = Z(() => h.map((d) => ({
1799
+ id: d.id,
1800
+ subject: X(d),
1801
+ to: qe(d),
1802
+ status: d.status,
1803
+ attempts: `${d.attempts ?? 0}/${d.max_attempts ?? "—"}`,
1804
+ scheduledAt: Ie(d.scheduled_at),
1805
+ sentAt: Ie(d.sent_at),
1806
+ createdAt: Ie(d.created_at),
1807
+ actions: "",
1808
+ raw: d
1809
+ })), [h]), _ = () => {
1810
+ if (T === "ALL") {
1811
+ q.refetch();
1812
+ return;
1813
+ }
1814
+ S.refetch();
1815
+ }, ie = () => {
1816
+ t({
1817
+ title: "Send email",
1818
+ content: /* @__PURE__ */ n(
1819
+ Zt,
1820
+ {
1821
+ onSuccess: () => {
1822
+ e(), _();
1823
+ }
1824
+ }
1825
+ ),
1826
+ size: "md"
1827
+ });
1828
+ }, oe = async (d) => {
1829
+ try {
1830
+ await ae(d.id).unwrap(), r.success({
1831
+ title: "Email re-queued",
1832
+ subtitle: X(d)
1833
+ });
1834
+ } catch {
1835
+ r.error({
1836
+ title: "Retry failed",
1837
+ subtitle: "Please check the email worker logs and try again."
1838
+ });
1839
+ }
1840
+ }, ye = async (d) => {
1841
+ try {
1842
+ await N(d.id).unwrap(), s(), r.success({
1843
+ title: "Email deleted",
1844
+ subtitle: X(d)
1845
+ });
1846
+ } catch {
1847
+ r.error({
1848
+ title: "Delete failed",
1849
+ subtitle: "Please try again."
1850
+ });
1851
+ }
1852
+ }, U = (d) => {
1853
+ a({
1854
+ title: "Email details",
1855
+ onClose: s,
1856
+ content: /* @__PURE__ */ n(oa, { email: d }),
1857
+ size: "lg",
1858
+ secondaryAction: {
1859
+ label: "Close",
1860
+ onClick: s
1861
+ }
1862
+ });
1863
+ }, he = (d) => {
1864
+ a({
1865
+ title: "Delete email record",
1866
+ onClose: s,
1867
+ content: /* @__PURE__ */ l("p", { children: [
1868
+ "Delete email record ",
1869
+ /* @__PURE__ */ n("strong", { children: X(d) }),
1870
+ "?"
1871
+ ] }),
1872
+ primaryAction: {
1873
+ label: "Delete",
1874
+ kind: "danger",
1875
+ onClick: () => {
1876
+ ye(d);
1877
+ }
1878
+ },
1879
+ secondaryAction: {
1880
+ label: "Cancel",
1881
+ onClick: s
1882
+ }
1883
+ });
1884
+ }, F = async (d) => {
1885
+ try {
1886
+ $("delete"), await Promise.all(d.map((b) => N(b.id).unwrap())), s(), r.success({
1887
+ title: "Emails deleted",
1888
+ subtitle: `${d.length} email record(s) deleted.`
1889
+ });
1890
+ } catch {
1891
+ r.error({
1892
+ title: "Delete failed",
1893
+ subtitle: "Some emails could not be deleted."
1894
+ });
1895
+ } finally {
1896
+ $(null);
1897
+ }
1898
+ }, Q = (d) => {
1899
+ a({
1900
+ title: "Delete email records",
1901
+ onClose: s,
1902
+ content: /* @__PURE__ */ l("p", { children: [
1903
+ "Delete ",
1904
+ /* @__PURE__ */ n("strong", { children: d.length }),
1905
+ " selected email record(s)?"
1906
+ ] }),
1907
+ primaryAction: {
1908
+ label: "Delete",
1909
+ kind: "danger",
1910
+ onClick: () => {
1911
+ F(d);
1912
+ }
1913
+ },
1914
+ secondaryAction: {
1915
+ label: "Cancel",
1916
+ onClick: s
1917
+ }
1918
+ });
1919
+ };
1920
+ return /* @__PURE__ */ n(ue, { children: /* @__PURE__ */ n("div", { className: "email-outbox-page__content", children: /* @__PURE__ */ n(
1921
+ Mt,
1922
+ {
1923
+ title: "Email Outbox",
1924
+ subtitle: "View, filter, retry, and delete queued email records.",
1925
+ actions: /* @__PURE__ */ l(ue, { children: [
1926
+ se && !j && /* @__PURE__ */ n(Le, { description: "Refreshing emails…" }),
1927
+ /* @__PURE__ */ n(A, { renderIcon: vt, onClick: ie, disabled: j || Y, children: "Send email" })
1928
+ ] }),
1929
+ children: j ? /* @__PURE__ */ n(Le, { description: "Loading emails…" }) : Y ? /* @__PURE__ */ n(
1930
+ Dt,
1931
+ {
1932
+ title: "Failed to load emails",
1933
+ description: ne?.data?.message ?? "Failed to load emails",
1934
+ primaryAction: { label: "Retry", onClick: _ }
1935
+ }
1936
+ ) : /* @__PURE__ */ l(ue, { children: [
1937
+ /* @__PURE__ */ n(xe, { className: "email-outbox-page__filter-tile", children: /* @__PURE__ */ n(
1938
+ da,
1939
+ {
1940
+ search: O,
1941
+ status: g,
1942
+ statusOptions: ma,
1943
+ onSearchChange: D,
1944
+ onStatusChange: H,
1945
+ onReset: () => {
1946
+ D(""), H("all");
1947
+ }
1948
+ }
1949
+ ) }),
1950
+ /* @__PURE__ */ l(xe, { className: "email-outbox-page__table-tile", children: [
1951
+ /* @__PURE__ */ n(yt, { rows: pe, headers: ua, children: ({ rows: d, headers: b, getHeaderProps: J, getRowProps: z, getSelectionProps: w, selectedRows: re }) => {
1952
+ const M = re.map(
1953
+ (y) => y.cells.find((I) => I.info.header === "raw")?.value
1954
+ );
1955
+ return /* @__PURE__ */ l(ue, { children: [
1956
+ /* @__PURE__ */ n(
1957
+ ca,
1958
+ {
1959
+ emails: M,
1960
+ loadingAction: f,
1961
+ onRetry: async () => {
1962
+ try {
1963
+ $("retry"), await Promise.all(
1964
+ M.map((y) => ae(y.id).unwrap())
1965
+ ), r.success({
1966
+ title: "Emails re-queued",
1967
+ subtitle: `${M.length} email(s) re-queued.`
1968
+ });
1969
+ } catch {
1970
+ r.error({
1971
+ title: "Retry failed",
1972
+ subtitle: "Some emails could not be re-queued."
1973
+ });
1974
+ } finally {
1975
+ $(null);
1976
+ }
1977
+ },
1978
+ onDelete: async () => {
1979
+ Q(M);
1980
+ }
1981
+ }
1982
+ ),
1983
+ /* @__PURE__ */ l(ht, { children: [
1984
+ /* @__PURE__ */ n(Rt, { children: /* @__PURE__ */ l($e, { children: [
1985
+ /* @__PURE__ */ n(gt, { ...w() }),
1986
+ b.filter((y) => y.key !== "raw").map((y) => /* @__PURE__ */ n(bt, { ...J({ header: y }), children: y.header }))
1987
+ ] }) }),
1988
+ /* @__PURE__ */ n(ft, { children: d.length === 0 ? /* @__PURE__ */ n($e, { children: /* @__PURE__ */ n(de, { colSpan: b.length, children: /* @__PURE__ */ n("div", { className: "email-outbox-page__empty-table", children: "No emails found." }) }) }) : d.map((y) => {
1989
+ const I = y.cells.find((R) => R.info.header === "raw")?.value;
1990
+ return /* @__PURE__ */ l($e, { ...z({ row: y }), children: [
1991
+ /* @__PURE__ */ n(Tt, { ...w({ row: y }) }),
1992
+ y.cells.map((R) => R.info.header === "raw" ? null : R.info.header === "subject" ? /* @__PURE__ */ n(de, { children: /* @__PURE__ */ l("div", { className: "email-outbox-page__table-title", children: [
1993
+ /* @__PURE__ */ n("strong", { children: X(I) }),
1994
+ /* @__PURE__ */ n("span", { className: "email-outbox-page__recipient-preview", children: qe(I) })
1995
+ ] }) }, R.id) : R.info.header === "status" ? /* @__PURE__ */ n(de, { children: /* @__PURE__ */ n(Se, { type: pa(String(R.value)), children: String(R.value) }) }, R.id) : R.info.header === "actions" ? /* @__PURE__ */ n(de, { children: y.isSelected && /* @__PURE__ */ n(
1996
+ la,
1997
+ {
1998
+ email: I,
1999
+ isMutating: !!f,
2000
+ onView: () => U(I),
2001
+ onRetry: () => oe(I),
2002
+ onDelete: () => he(I)
2003
+ }
2004
+ ) }, R.id) : /* @__PURE__ */ n(de, { children: R.value || "—" }, R.id))
2005
+ ] });
2006
+ }) })
2007
+ ] })
2008
+ ] });
2009
+ } }),
2010
+ /* @__PURE__ */ n(
2011
+ St,
2012
+ {
2013
+ page: ee,
2014
+ pageSize: P,
2015
+ pageSizes: [10, 20, 50, 100],
2016
+ totalItems: G.length < P ? B + G.length : B + P + 1,
2017
+ onChange: ({ page: d, pageSize: b }) => {
2018
+ te(d), E(b);
2019
+ }
2020
+ }
2021
+ )
2022
+ ] })
2023
+ ] })
2024
+ }
2025
+ ) }) });
2026
+ }
2027
+ function tn(t) {
2028
+ return /* @__PURE__ */ n("div", { className: "moh-microfrontend-root", children: /* @__PURE__ */ n(ha, {}) });
2029
+ }
2030
+ export {
2031
+ ha as E,
2032
+ tn as a
2033
+ };
2034
+ //# sourceMappingURL=root.component-C1na_5E_.js.map