@moh-sso/clients 0.0.0-stage → 1.4.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 (142) hide show
  1. package/README.md +25 -2
  2. package/dist/_types/apps/clients/src/api/clientRoles.api.d.ts +539 -0
  3. package/dist/_types/apps/clients/src/api/clients.api.d.ts +1035 -0
  4. package/dist/_types/apps/clients/src/api/index.d.ts +2 -0
  5. package/dist/_types/apps/clients/src/api/onboarding.api.d.ts +544 -0
  6. package/dist/_types/apps/clients/src/components/ClientFilters.d.ts +17 -0
  7. package/dist/_types/apps/clients/src/components/EnableClientModal.d.ts +9 -0
  8. package/dist/_types/apps/clients/src/components/client-form-panel.d.ts +9 -0
  9. package/dist/_types/apps/clients/src/components/client-onboarding-panel.d.ts +5 -0
  10. package/dist/_types/apps/clients/src/components/onboarding-draft.d.ts +18 -0
  11. package/dist/_types/apps/clients/src/components/roles/client-roles-panel.d.ts +6 -0
  12. package/dist/_types/apps/clients/src/components/roles/create-client-role-form.d.ts +6 -0
  13. package/dist/_types/apps/clients/src/components/useEnableClientModal.d.ts +9 -0
  14. package/dist/_types/apps/clients/src/components/user-client-roles-panel.d.ts +5 -0
  15. package/dist/_types/apps/clients/src/index.d.ts +7 -0
  16. package/dist/_types/apps/clients/src/pages/client-actions-menu.component.d.ts +8 -0
  17. package/dist/_types/apps/clients/src/pages/client-bulk-actions.component.d.ts +9 -0
  18. package/dist/_types/apps/clients/src/pages/client.component.d.ts +1 -0
  19. package/dist/_types/apps/clients/src/root.component.d.ts +2 -0
  20. package/dist/_types/apps/clients/src/routes.d.ts +2 -0
  21. package/dist/_types/apps/clients/src/single-spa.d.ts +1 -0
  22. package/dist/_types/apps/clients/src/types/client-role.types.d.ts +6 -0
  23. package/dist/_types/apps/clients/src/types/index.d.ts +2 -0
  24. package/dist/_types/apps/clients/src/types/user-role.types.d.ts +6 -0
  25. package/dist/_types/apps/rbac/src/api/health-context.api.d.ts +2482 -0
  26. package/dist/_types/apps/rbac/src/api/index.d.ts +2 -0
  27. package/dist/_types/apps/rbac/src/api/rbac.api.d.ts +10383 -0
  28. package/dist/_types/apps/rbac/src/types/health-context.types.d.ts +92 -0
  29. package/dist/_types/apps/rbac/src/types/index.d.ts +2 -0
  30. package/dist/_types/apps/rbac/src/types/rbac.types.d.ts +451 -0
  31. package/dist/_types/packages/api/src/api/baseApi.d.ts +2 -0
  32. package/dist/_types/packages/api/src/index.d.ts +1 -0
  33. package/dist/_types/packages/auth/src/api/auth.api.d.ts +531 -0
  34. package/dist/_types/packages/auth/src/api/health-context.api.d.ts +374 -0
  35. package/dist/_types/packages/auth/src/auth/AuthBootstrap.d.ts +1 -0
  36. package/dist/_types/packages/auth/src/auth/HealthContextProvider.d.ts +20 -0
  37. package/dist/_types/packages/auth/src/auth/PermissionGuard.d.ts +10 -0
  38. package/dist/_types/packages/auth/src/auth/auth.selectors.d.ts +896 -0
  39. package/dist/_types/packages/auth/src/auth/auth.slice.d.ts +14 -0
  40. package/dist/_types/packages/auth/src/auth/auth.types.d.ts +61 -0
  41. package/dist/_types/packages/auth/src/auth/login-url.d.ts +2 -0
  42. package/dist/_types/packages/auth/src/auth/permissions.d.ts +58 -0
  43. package/dist/_types/packages/auth/src/auth/rbac.d.ts +8 -0
  44. package/dist/_types/packages/auth/src/auth/system-launch-url.d.ts +9 -0
  45. package/dist/_types/packages/auth/src/auth/useAuthorization.d.ts +14 -0
  46. package/dist/_types/packages/auth/src/index.d.ts +14 -0
  47. package/dist/_types/packages/config/src/appMeta.d.ts +3 -0
  48. package/dist/_types/packages/config/src/index.d.ts +6 -0
  49. package/dist/_types/packages/config/src/lib/constants/api.constants.d.ts +178 -0
  50. package/dist/_types/packages/config/src/lib/constants/document-templates.d.ts +11 -0
  51. package/dist/_types/packages/config/src/lib/errors/errorMessages.d.ts +2 -0
  52. package/dist/_types/packages/config/src/lib/errors/errorSeverity.d.ts +3 -0
  53. package/dist/_types/packages/config/src/lib/errors/errorTypes.d.ts +1 -0
  54. package/dist/_types/packages/microfrontend/src/basename.d.ts +1 -0
  55. package/dist/_types/packages/microfrontend/src/index.d.ts +6 -0
  56. package/dist/_types/packages/microfrontend/src/lifecycle.d.ts +6 -0
  57. package/dist/_types/packages/microfrontend/src/navigation.d.ts +2 -0
  58. package/dist/_types/packages/microfrontend/src/props.d.ts +44 -0
  59. package/dist/_types/packages/microfrontend/src/react-lifecycle.d.ts +11 -0
  60. package/dist/_types/packages/microfrontend/src/routes.d.ts +13 -0
  61. package/dist/_types/packages/state/src/clients/clients.selectors.d.ts +534 -0
  62. package/dist/_types/packages/state/src/clients/clients.slice.d.ts +4 -0
  63. package/dist/_types/packages/state/src/document/documents.selectors.d.ts +1 -0
  64. package/dist/_types/packages/state/src/index.d.ts +29 -0
  65. package/dist/_types/packages/state/src/ui/ui.state.d.ts +1 -0
  66. package/dist/_types/packages/types/src/index.d.ts +6 -0
  67. package/dist/_types/packages/types/src/types/announcement-summary.types.d.ts +16 -0
  68. package/dist/_types/packages/types/src/types/client-role.types.d.ts +6 -0
  69. package/dist/_types/packages/types/src/types/client.types.d.ts +46 -0
  70. package/dist/_types/packages/types/src/types/document-processing.types.d.ts +1 -0
  71. package/dist/_types/packages/types/src/types/notifications.types.d.ts +96 -0
  72. package/dist/_types/packages/types/src/types/system-navigation.types.d.ts +18 -0
  73. package/dist/_types/packages/ui/src/accessibility/index.d.ts +1 -0
  74. package/dist/_types/packages/ui/src/accessibility/useFocusTrap.d.ts +10 -0
  75. package/dist/_types/packages/ui/src/branding/BuildMeta.d.ts +6 -0
  76. package/dist/_types/packages/ui/src/branding/PublicFooter.d.ts +6 -0
  77. package/dist/_types/packages/ui/src/branding/index.d.ts +2 -0
  78. package/dist/_types/packages/ui/src/data-display/DataTablePagination.d.ts +12 -0
  79. package/dist/_types/packages/ui/src/data-display/DataTableShell.d.ts +35 -0
  80. package/dist/_types/packages/ui/src/data-display/RowActionsCell.d.ts +7 -0
  81. package/dist/_types/packages/ui/src/data-display/TableEmptyState.d.ts +8 -0
  82. package/dist/_types/packages/ui/src/data-display/TableStatusTag.d.ts +8 -0
  83. package/dist/_types/packages/ui/src/data-display/index.d.ts +5 -0
  84. package/dist/_types/packages/ui/src/feedback/comingsoon/ComingSoon.d.ts +7 -0
  85. package/dist/_types/packages/ui/src/feedback/emptystate/EmptyState.d.ts +15 -0
  86. package/dist/_types/packages/ui/src/feedback/errorstate/ErrorState.d.ts +14 -0
  87. package/dist/_types/packages/ui/src/feedback/errorstate/MicrofrontendErrorBoundary.d.ts +16 -0
  88. package/dist/_types/packages/ui/src/feedback/index.d.ts +5 -0
  89. package/dist/_types/packages/ui/src/feedback/loadingstate/LoadingState.d.ts +5 -0
  90. package/dist/_types/packages/ui/src/forms/CaseFormsGrid.d.ts +1 -0
  91. package/dist/_types/packages/ui/src/forms/index.d.ts +1 -0
  92. package/dist/_types/packages/ui/src/index.d.ts +16 -0
  93. package/dist/_types/packages/ui/src/layout/PageShell/PageShell.d.ts +9 -0
  94. package/dist/_types/packages/ui/src/layout/SectionCard/SectionCard.d.ts +11 -0
  95. package/dist/_types/packages/ui/src/layout/index.d.ts +2 -0
  96. package/dist/_types/packages/ui/src/navigation/appmenu/AppGridContent.d.ts +12 -0
  97. package/dist/_types/packages/ui/src/navigation/appmenu/AppMenu.component.d.ts +6 -0
  98. package/dist/_types/packages/ui/src/navigation/appmenu/AppMenuItem.component.d.ts +13 -0
  99. package/dist/_types/packages/ui/src/navigation/appmenu/appMenuGroups.d.ts +11 -0
  100. package/dist/_types/packages/ui/src/navigation/breadcrumbs/AppBreadcrumbs.d.ts +12 -0
  101. package/dist/_types/packages/ui/src/navigation/breadcrumbs/BreadcrumbBar.d.ts +10 -0
  102. package/dist/_types/packages/ui/src/navigation/index.d.ts +2 -0
  103. package/dist/_types/packages/ui/src/navigation/sidenav/ClientSideNav.d.ts +14 -0
  104. package/dist/_types/packages/ui/src/notifications/FormInlineAlert.d.ts +7 -0
  105. package/dist/_types/packages/ui/src/notifications/NotificationsPanel.d.ts +14 -0
  106. package/dist/_types/packages/ui/src/notifications/index.d.ts +4 -0
  107. package/dist/_types/packages/ui/src/notifications/toast/ToastProvider.d.ts +20 -0
  108. package/dist/_types/packages/ui/src/notifications/toast/useToast.d.ts +20 -0
  109. package/dist/_types/packages/ui/src/overlays/header-panel/ReusableHeaderPanel.d.ts +17 -0
  110. package/dist/_types/packages/ui/src/overlays/header-panel/header-panel.context.d.ts +23 -0
  111. package/dist/_types/packages/ui/src/overlays/index.d.ts +4 -0
  112. package/dist/_types/packages/ui/src/overlays/modal/ReusableModal.d.ts +20 -0
  113. package/dist/_types/packages/ui/src/overlays/modal/modal.context.d.ts +14 -0
  114. package/dist/_types/packages/ui/src/shell/ExternalAppHeader.d.ts +22 -0
  115. package/dist/_types/packages/ui/src/shell/PublicHeader.component.d.ts +8 -0
  116. package/dist/_types/packages/ui/src/shell/UserHeader.component.d.ts +17 -0
  117. package/dist/_types/packages/ui/src/shell/index.d.ts +5 -0
  118. package/dist/_types/packages/ui/src/theme/ThemeProvider.d.ts +8 -0
  119. package/dist/_types/packages/ui/src/theme/index.d.ts +1 -0
  120. package/dist/_types/packages/ui/src/utils/severity.d.ts +22 -0
  121. package/dist/_types/packages/ui/src/utils/status.d.ts +1 -0
  122. package/dist/api.d.ts +1 -0
  123. package/dist/api.js +38 -0
  124. package/dist/api.js.map +1 -0
  125. package/dist/assets/clients-DjhOVsFS.css +1 -0
  126. package/dist/assets/clients.api-DqQdrhve.js +169 -0
  127. package/dist/assets/clients.api-DqQdrhve.js.map +1 -0
  128. package/dist/assets/root.component-WxWhdR-e.js +1132 -0
  129. package/dist/assets/root.component-WxWhdR-e.js.map +1 -0
  130. package/dist/index.d.ts +1 -0
  131. package/dist/index.js +811 -0
  132. package/dist/index.js.map +1 -0
  133. package/dist/routes.d.ts +1 -0
  134. package/dist/routes.js +32 -0
  135. package/dist/routes.js.map +1 -0
  136. package/dist/single-spa.d.ts +1 -0
  137. package/dist/single-spa.js +32 -0
  138. package/dist/single-spa.js.map +1 -0
  139. package/dist/types.d.ts +1 -0
  140. package/dist/types.js +25 -0
  141. package/dist/types.js.map +1 -0
  142. package/package.json +64 -4
@@ -0,0 +1,1132 @@
1
+ import { jsxs as o, jsx as e, Fragment as q } from "react/jsx-runtime";
2
+ import { Stack as w, Dropdown as ae, Button as f, InlineLoading as _, TextInput as A, Tile as le, DataTable as ce, Table as ue, TableHead as pe, TableRow as W, TableHeader as he, TableBody as ge, TableCell as X, OverflowMenu as be, OverflowMenuItem as te, Tag as oe, FormGroup as J, TextArea as Q, Select as we, SelectItem as Te, Checkbox as Z, Form as ke, ButtonSet as xe, TableSelectAll as Ue, TableSelectRow as Ie } from "@carbon/react";
3
+ import { useAuthorization as Re } from "@moh-sso/auth";
4
+ import { useState as C, useEffect as me, useMemo as ie } from "react";
5
+ import { useModal as fe, useToast as Y, useHeaderPanel as ve, FormInlineAlert as K, DataTableShell as Se, TableStatusTag as De, RowActionsCell as Ee, DataTablePagination as Oe, ErrorState as Ae } from "@moh-sso/ui";
6
+ import { baseApi as Pe } from "@moh-sso/api";
7
+ import { API as Le } from "@moh-sso/config";
8
+ import { b as Ne, g as Fe, e as $e, u as Me, j as je, h as ze, i as Be } from "./clients.api-DqQdrhve.js";
9
+ function _e({
10
+ onReset: n,
11
+ status: t,
12
+ type: i,
13
+ statusOptions: l,
14
+ typeOptions: d,
15
+ onStatusChange: u,
16
+ onTypeChange: m
17
+ }) {
18
+ return /* @__PURE__ */ o(w, { orientation: "horizontal", gap: 5, className: "client-filters", children: [
19
+ /* @__PURE__ */ e(
20
+ ae,
21
+ {
22
+ id: "client-status-filter",
23
+ titleText: "Status",
24
+ label: "Status",
25
+ items: [...l],
26
+ selectedItem: l.find((r) => r.id === t),
27
+ itemToString: (r) => r?.label ?? "",
28
+ className: "client-filters__field--status",
29
+ onChange: ({ selectedItem: r }) => {
30
+ u(r?.id);
31
+ }
32
+ }
33
+ ),
34
+ /* @__PURE__ */ e(
35
+ ae,
36
+ {
37
+ id: "client-type-filter",
38
+ titleText: "Type",
39
+ label: "Type",
40
+ items: [...d],
41
+ selectedItem: d.find((r) => r.id === i),
42
+ itemToString: (r) => r?.label ?? "",
43
+ className: "client-filters__field--type",
44
+ onChange: ({ selectedItem: r }) => {
45
+ m(r?.id);
46
+ }
47
+ }
48
+ ),
49
+ /* @__PURE__ */ e(f, { kind: "ghost", size: "md", onClick: n, children: "Clear filters" })
50
+ ] });
51
+ }
52
+ const qe = ({
53
+ clientName: n,
54
+ enabled: t,
55
+ onConfirm: i,
56
+ onCancel: l
57
+ }) => {
58
+ const [d, u] = C(!1);
59
+ async function m() {
60
+ try {
61
+ u(!0), await i();
62
+ } finally {
63
+ u(!1);
64
+ }
65
+ }
66
+ return /* @__PURE__ */ o("div", { className: "client-confirm-modal", children: [
67
+ /* @__PURE__ */ o("p", { children: [
68
+ "Are you sure you want to ",
69
+ /* @__PURE__ */ e("strong", { children: t ? "disable" : "enable" }),
70
+ " the client",
71
+ /* @__PURE__ */ o("strong", { children: [
72
+ " ",
73
+ n
74
+ ] }),
75
+ "?"
76
+ ] }),
77
+ /* @__PURE__ */ e("p", { className: "client-confirm-modal__description", children: t ? "This client will no longer be able to authenticate or access applications." : "This client will regain access to authenticate and use assigned applications." }),
78
+ d && /* @__PURE__ */ e(_, { description: t ? "Disabling client…" : "Enabling client…" }),
79
+ /* @__PURE__ */ o("div", { className: "client-confirm-modal__actions", children: [
80
+ /* @__PURE__ */ e(f, { kind: "secondary", onClick: l, disabled: d, children: "Cancel" }),
81
+ /* @__PURE__ */ e(f, { kind: t ? "danger" : "primary", onClick: m, disabled: d, children: t ? "Disable client" : "Enable client" })
82
+ ] })
83
+ ] });
84
+ };
85
+ function Ve() {
86
+ const { openModal: n, closeModal: t } = fe();
87
+ function i({ clientName: l, enabled: d, onConfirm: u }) {
88
+ n({
89
+ title: d ? "Disable client" : "Enable client",
90
+ size: "sm",
91
+ content: /* @__PURE__ */ e(
92
+ qe,
93
+ {
94
+ clientName: l,
95
+ enabled: d,
96
+ onConfirm: async () => {
97
+ await u(), t();
98
+ },
99
+ onCancel: t
100
+ }
101
+ ),
102
+ onClose: t
103
+ });
104
+ }
105
+ return { openEnableClientModal: i };
106
+ }
107
+ const ne = (n) => `${Le.clients.list()}/onboarding/${n}`, He = Pe.injectEndpoints({
108
+ endpoints: (n) => ({
109
+ onboardingContext: n.query({
110
+ query: () => ({ url: ne("context"), credentials: "include" }),
111
+ transformResponse: (t) => t.data
112
+ }),
113
+ previewOnboarding: n.mutation({
114
+ query: (t) => ({
115
+ url: ne("preview"),
116
+ method: "POST",
117
+ body: { spec: t },
118
+ credentials: "include"
119
+ }),
120
+ transformResponse: (t) => t.data
121
+ }),
122
+ applyOnboarding: n.mutation({
123
+ query: (t) => ({ url: ne("apply"), method: "POST", body: t, credentials: "include" }),
124
+ transformResponse: (t) => t.data,
125
+ invalidatesTags: [{ type: "Client", id: "LIST" }]
126
+ })
127
+ })
128
+ }), {
129
+ useOnboardingContextQuery: Je,
130
+ usePreviewOnboardingMutation: Ke,
131
+ useApplyOnboardingMutation: Qe
132
+ } = He, re = (n) => ({
133
+ version: 1,
134
+ clientId: "",
135
+ name: "",
136
+ description: "",
137
+ owner: "",
138
+ supportEmail: "",
139
+ profile: "public-web",
140
+ environment: n,
141
+ rootUrl: "",
142
+ redirectUris: [],
143
+ logoutUris: [],
144
+ webOrigins: [],
145
+ launcher: !1
146
+ });
147
+ function Ce(n) {
148
+ const t = JSON.parse(n);
149
+ if (!t || typeof t != "object" || Array.isArray(t))
150
+ throw new Error("Choose an onboarding draft, not a realm export.");
151
+ const i = t, l = re("");
152
+ if (Object.keys(i).some((d) => !Object.hasOwn(l, d)) || i.version !== 1)
153
+ throw new Error(
154
+ "Unsupported document. Import a version 1 onboarding draft without credentials."
155
+ );
156
+ for (const d of [
157
+ "clientId",
158
+ "name",
159
+ "description",
160
+ "owner",
161
+ "supportEmail",
162
+ "profile",
163
+ "environment",
164
+ "rootUrl"
165
+ ])
166
+ if (typeof i[d] != "string") throw new Error(`Invalid ${d} in onboarding draft.`);
167
+ for (const d of ["redirectUris", "logoutUris", "webOrigins"])
168
+ if (!Array.isArray(i[d]) || !i[d].every((u) => typeof u == "string"))
169
+ throw new Error(`Invalid ${d} in onboarding draft.`);
170
+ if (typeof i.launcher != "boolean") throw new Error("Invalid launcher setting.");
171
+ return i;
172
+ }
173
+ function Ye(n) {
174
+ return JSON.stringify(Ce(JSON.stringify(n)), null, 2);
175
+ }
176
+ function Ge({ clientUuid: n, onSuccess: t }) {
177
+ const i = Y(), [l, d] = C(""), [u, m] = C(""), [r, { isLoading: s }] = Ne(), v = !!l.trim();
178
+ return /* @__PURE__ */ o(w, { gap: 3, children: [
179
+ /* @__PURE__ */ e(
180
+ A,
181
+ {
182
+ id: "role-name",
183
+ labelText: "Role name",
184
+ helperText: "Format: resource:action (e.g. users:view)",
185
+ value: l,
186
+ onChange: (p) => {
187
+ d(p.target.value);
188
+ }
189
+ }
190
+ ),
191
+ /* @__PURE__ */ e(
192
+ A,
193
+ {
194
+ id: "role-description",
195
+ labelText: "Description (optional)",
196
+ value: u,
197
+ onChange: (p) => {
198
+ m(p.target.value);
199
+ }
200
+ }
201
+ ),
202
+ /* @__PURE__ */ e(f, { kind: "primary", size: "sm", disabled: !v || s, onClick: async () => {
203
+ if (v)
204
+ try {
205
+ await r({
206
+ clientUuid: n,
207
+ payload: {
208
+ role: l.trim(),
209
+ description: u.trim() || void 0
210
+ }
211
+ }).unwrap(), i.success("Role created", `Role "${l}" added`), d(""), m(""), t?.();
212
+ } catch {
213
+ i.error("Failed to create role", "Please try again");
214
+ }
215
+ }, children: s ? /* @__PURE__ */ e(_, { description: "Creating…" }) : "Add role" })
216
+ ] });
217
+ }
218
+ const We = [
219
+ { key: "name", header: "Role" },
220
+ { key: "description", header: "Description" },
221
+ { key: "actions", header: "" },
222
+ { key: "roleName", header: "" }
223
+ ];
224
+ function ye({ clientUuid: n, clientId: t }) {
225
+ const i = Y(), { openModal: l, closeModal: d } = fe(), { data: u = [], isLoading: m } = Fe(n), [r, { isLoading: s }] = $e(), v = async (p) => {
226
+ try {
227
+ await r({ clientUuid: n, roleName: p }).unwrap(), d(), i.success("Role deleted", `"${p}" was removed`);
228
+ } catch {
229
+ i.error("Failed to delete role", "Please try again");
230
+ }
231
+ }, k = (p) => {
232
+ l({
233
+ title: "Delete client role",
234
+ onClose: d,
235
+ content: /* @__PURE__ */ o("p", { children: [
236
+ "Are you sure you want to delete the role ",
237
+ /* @__PURE__ */ e("strong", { children: p }),
238
+ "?"
239
+ ] }),
240
+ primaryAction: {
241
+ label: s ? "Deleting..." : "Delete role",
242
+ kind: "danger",
243
+ disabled: s,
244
+ onClick: () => {
245
+ v(p);
246
+ }
247
+ },
248
+ secondaryAction: {
249
+ label: "Cancel",
250
+ onClick: d
251
+ }
252
+ });
253
+ };
254
+ return m ? /* @__PURE__ */ e(_, { description: "Loading roles…" }) : /* @__PURE__ */ o(w, { gap: 6, children: [
255
+ /* @__PURE__ */ e(le, { children: /* @__PURE__ */ o(w, { gap: 4, children: [
256
+ /* @__PURE__ */ e("strong", { children: "Add role" }),
257
+ /* @__PURE__ */ e(Ge, { clientUuid: n })
258
+ ] }) }),
259
+ /* @__PURE__ */ e(le, { children: /* @__PURE__ */ e(
260
+ ce,
261
+ {
262
+ rows: u.map((p) => ({
263
+ id: p.id,
264
+ name: p.name.replace(`${t}:`, ""),
265
+ roleName: p.name,
266
+ description: p.description ?? "—"
267
+ })),
268
+ headers: We,
269
+ children: ({ rows: p, headers: x, getHeaderProps: y, getRowProps: P }) => /* @__PURE__ */ o(ue, { children: [
270
+ /* @__PURE__ */ e(pe, { children: /* @__PURE__ */ e(W, { children: x.filter((g) => g.key !== "roleName").map((g) => /* @__PURE__ */ e(he, { ...y({ header: g }), children: g.header })) }) }),
271
+ /* @__PURE__ */ e(ge, { children: p.map((g) => /* @__PURE__ */ e(W, { ...P({ row: g }), children: g.cells.map((R) => R.info.header === "roleName" ? null : R.info.header === "actions" ? /* @__PURE__ */ e(X, { children: /* @__PURE__ */ e(be, { size: "sm", children: /* @__PURE__ */ e(
272
+ te,
273
+ {
274
+ itemText: "Delete",
275
+ isDelete: !0,
276
+ onClick: () => {
277
+ const S = g.cells.find(
278
+ (D) => D.info.header === "roleName"
279
+ )?.value;
280
+ typeof S == "string" && k(S);
281
+ }
282
+ }
283
+ ) }) }, R.id) : /* @__PURE__ */ e(X, { children: R.value }, R.id)) })) })
284
+ ] })
285
+ }
286
+ ) })
287
+ ] });
288
+ }
289
+ function G(n, t = !1) {
290
+ if (t && typeof n == "object" && n && "status" in n) {
291
+ const i = n, l = i.originalStatus ?? i.status;
292
+ if (l === 404)
293
+ return "The backend does not provide the onboarding API. Update and restart the backend from the same release as this frontend, then retry.";
294
+ if (l === 401) return "Your session has expired. Sign in again to onboard an application.";
295
+ if (l === 403) return "You need permission to manage clients to onboard an application.";
296
+ if (i.data?.error?.code === "ENVIRONMENT_MISMATCH")
297
+ return "This deployment is connected to a realm for a different environment. Configure the matching identity realm before onboarding clients.";
298
+ if (i.status === "FETCH_ERROR")
299
+ return "Cannot reach the onboarding API. Check the backend connection, then retry.";
300
+ }
301
+ if (typeof n == "object" && n && "data" in n) {
302
+ const i = n.data;
303
+ if (i?.error?.message) return i.error.message;
304
+ }
305
+ return n instanceof Error ? n.message : "Unable to complete this step. Please try again.";
306
+ }
307
+ function Xe(n) {
308
+ const t = n?.attributes;
309
+ return n ? {
310
+ ...re(t?.["portal.onboarding.environment"] ?? ""),
311
+ clientId: n.clientId,
312
+ name: n.name,
313
+ description: n.description ?? "",
314
+ profile: t?.["portal.onboarding.profile"] ?? "public-web",
315
+ owner: t?.["portal.owner"] ?? "",
316
+ supportEmail: t?.["portal.supportEmail"] ?? "",
317
+ rootUrl: n.rootUrl ?? "",
318
+ redirectUris: n.redirectUris,
319
+ webOrigins: n.webOrigins ?? [],
320
+ logoutUris: (t?.["post.logout.redirect.uris"] ?? "").split("##").filter(Boolean),
321
+ launcher: t?.["portal.system"] === "true"
322
+ } : re("");
323
+ }
324
+ function Ze({
325
+ initialClient: n,
326
+ onSuccess: t
327
+ }) {
328
+ const {
329
+ data: i,
330
+ error: l,
331
+ isLoading: d,
332
+ isFetching: u,
333
+ refetch: m
334
+ } = Je(), [r, s] = C(() => Xe(n)), [v, k] = C(0), [p, x] = C(""), [y, P] = C(null), [g, R] = C(
335
+ null
336
+ ), [S, D] = C(!1), [M, { isLoading: z }] = Ke(), [U, { isLoading: L }] = Qe(), c = Y(), { closePanel: E } = ve(), $ = r.environment || i?.environment || "", j = { ...r, environment: $ }, h = (a, b) => {
337
+ s((I) => ({ ...I, [a]: b })), P(null), D(!1), x("");
338
+ }, N = () => {
339
+ const a = new Blob([Ye(j)], { type: "application/json" }), b = URL.createObjectURL(a), I = document.createElement("a");
340
+ I.href = b, I.download = `${j.clientId || "application"}-onboarding.json`, I.click(), URL.revokeObjectURL(b);
341
+ }, B = async () => {
342
+ try {
343
+ x(""), P(await M(j).unwrap()), D(!1), k(2);
344
+ } catch (a) {
345
+ x(G(a));
346
+ }
347
+ }, V = async () => {
348
+ if (!(!y || !S))
349
+ try {
350
+ x("");
351
+ const a = await U({ spec: j, reviewToken: y.reviewToken }).unwrap();
352
+ R(a), c.success(
353
+ "Client provisioned",
354
+ "Configuration verified. Complete integration checks before enabling."
355
+ );
356
+ } catch (a) {
357
+ x(G(a)), P(null), D(!1), k(1);
358
+ }
359
+ };
360
+ return d ? /* @__PURE__ */ e(_, { description: "Loading this environment…" }) : l || !i ? /* @__PURE__ */ o(w, { gap: 5, children: [
361
+ /* @__PURE__ */ e(
362
+ K,
363
+ {
364
+ title: "Client onboarding unavailable",
365
+ subtitle: G(l, !0)
366
+ }
367
+ ),
368
+ /* @__PURE__ */ e(f, { kind: "tertiary", disabled: u, onClick: () => {
369
+ m();
370
+ }, children: u ? "Retrying…" : "Retry onboarding" })
371
+ ] }) : g ? /* @__PURE__ */ o(w, { gap: 5, children: [
372
+ /* @__PURE__ */ e("h3", { children: "Application configured" }),
373
+ /* @__PURE__ */ e(oe, { type: "gray", children: "Disabled pending integration checks" }),
374
+ /* @__PURE__ */ e("p", { children: g.message }),
375
+ /* @__PURE__ */ o("dl", { children: [
376
+ /* @__PURE__ */ e("dt", { children: "Client ID" }),
377
+ /* @__PURE__ */ e("dd", { children: g.client.clientId }),
378
+ /* @__PURE__ */ e("dt", { children: "Issuer" }),
379
+ /* @__PURE__ */ e("dd", { children: g.issuer }),
380
+ /* @__PURE__ */ e("dt", { children: "Environment" }),
381
+ /* @__PURE__ */ o("dd", { children: [
382
+ i.environment,
383
+ " · ",
384
+ i.realm
385
+ ] })
386
+ ] }),
387
+ /* @__PURE__ */ e("p", { children: j.profile === "public-web" ? "This public client does not use a secret." : "Retrieve or rotate this client's secret privately through this realm's Keycloak administration. Secrets are never included in onboarding drafts." }),
388
+ /* @__PURE__ */ e("p", { children: "Test sign-in, token validation and logout. Configure portal access roles in RBAC if this application has a launcher entry, then enable the client from Clients." }),
389
+ /* @__PURE__ */ o("details", { children: [
390
+ /* @__PURE__ */ e("summary", { children: "Configure client roles (optional)" }),
391
+ /* @__PURE__ */ e(ye, { clientUuid: g.client.id, clientId: g.client.clientId })
392
+ ] }),
393
+ /* @__PURE__ */ o(w, { orientation: "horizontal", gap: 3, children: [
394
+ /* @__PURE__ */ e(f, { kind: "secondary", onClick: N, children: "Export onboarding draft" }),
395
+ /* @__PURE__ */ e(f, { onClick: t ?? E, children: "Done" })
396
+ ] })
397
+ ] }) : /* @__PURE__ */ e("div", { className: "client-onboarding", children: /* @__PURE__ */ o(w, { gap: 5, children: [
398
+ /* @__PURE__ */ o("div", { children: [
399
+ /* @__PURE__ */ e(oe, { type: i.environment === "production" ? "red" : "blue", children: i.environment }),
400
+ /* @__PURE__ */ e("span", { children: i.realm })
401
+ ] }),
402
+ /* @__PURE__ */ e("ol", { className: "client-onboarding__steps", "aria-label": "Onboarding progress", children: ["Application", "URLs & access", "Review"].map((a, b) => /* @__PURE__ */ o("li", { "aria-current": v === b ? "step" : void 0, children: [
403
+ b + 1,
404
+ ". ",
405
+ a
406
+ ] }, a)) }),
407
+ p && /* @__PURE__ */ e(K, { title: "Review required", subtitle: p }),
408
+ n?.enabled && /* @__PURE__ */ e(
409
+ K,
410
+ {
411
+ title: "Disable this client first",
412
+ subtitle: "Active integrations cannot be changed through onboarding. Disable the client from Clients before reviewing an update."
413
+ }
414
+ ),
415
+ v === 0 && /* @__PURE__ */ o(q, { children: [
416
+ /* @__PURE__ */ e(J, { legendText: "Register an application", children: /* @__PURE__ */ o(w, { gap: 4, children: [
417
+ /* @__PURE__ */ e("label", { htmlFor: "onboarding-import", children: "Import a draft from another environment" }),
418
+ /* @__PURE__ */ e(
419
+ "input",
420
+ {
421
+ id: "onboarding-import",
422
+ type: "file",
423
+ accept: ".json,application/json",
424
+ onChange: async (a) => {
425
+ const b = a.target.files?.[0];
426
+ if (b) {
427
+ try {
428
+ if (b.size > 65536) throw new Error("Choose a draft smaller than 64 KB.");
429
+ s(Ce(await b.text())), P(null), D(!1), x("");
430
+ } catch (I) {
431
+ x(G(I));
432
+ }
433
+ a.target.value = "";
434
+ }
435
+ }
436
+ }
437
+ ),
438
+ /* @__PURE__ */ e(
439
+ A,
440
+ {
441
+ id: "onboarding-client-id",
442
+ labelText: "Client ID",
443
+ helperText: "Use the same ID across environments.",
444
+ value: r.clientId,
445
+ disabled: !!n,
446
+ onChange: (a) => h("clientId", a.target.value)
447
+ }
448
+ ),
449
+ /* @__PURE__ */ e(
450
+ A,
451
+ {
452
+ id: "onboarding-name",
453
+ labelText: "Application name",
454
+ value: r.name,
455
+ onChange: (a) => h("name", a.target.value)
456
+ }
457
+ ),
458
+ /* @__PURE__ */ e(
459
+ Q,
460
+ {
461
+ id: "onboarding-description",
462
+ labelText: "Description",
463
+ value: r.description,
464
+ onChange: (a) => h("description", a.target.value)
465
+ }
466
+ ),
467
+ /* @__PURE__ */ e(
468
+ A,
469
+ {
470
+ id: "onboarding-owner",
471
+ labelText: "Application owner or team",
472
+ value: r.owner,
473
+ onChange: (a) => h("owner", a.target.value)
474
+ }
475
+ ),
476
+ /* @__PURE__ */ e(
477
+ A,
478
+ {
479
+ id: "onboarding-support",
480
+ type: "email",
481
+ labelText: "Support email",
482
+ value: r.supportEmail,
483
+ onChange: (a) => h("supportEmail", a.target.value)
484
+ }
485
+ ),
486
+ /* @__PURE__ */ e(
487
+ we,
488
+ {
489
+ id: "onboarding-profile",
490
+ labelText: "Client profile",
491
+ value: r.profile,
492
+ disabled: !!n,
493
+ onChange: (a) => {
494
+ const b = a.target.value;
495
+ h("profile", b), b === "service" && s((I) => ({
496
+ ...I,
497
+ profile: b,
498
+ rootUrl: "",
499
+ redirectUris: [],
500
+ logoutUris: [],
501
+ webOrigins: [],
502
+ launcher: !1
503
+ }));
504
+ },
505
+ children: i.profiles.map((a) => /* @__PURE__ */ e(Te, { value: a.id, text: a.name }, a.id))
506
+ }
507
+ )
508
+ ] }) }),
509
+ /* @__PURE__ */ e(
510
+ f,
511
+ {
512
+ disabled: !r.clientId || !r.name || !r.owner || !r.supportEmail,
513
+ onClick: () => k(1),
514
+ children: "Continue"
515
+ }
516
+ )
517
+ ] }),
518
+ v === 1 && /* @__PURE__ */ o(q, { children: [
519
+ $ !== i.environment ? /* @__PURE__ */ e(
520
+ K,
521
+ {
522
+ title: `Draft belongs to ${$}`,
523
+ subtitle: `Review every URL for ${i.environment}, then select “Use this environment” before previewing.`
524
+ }
525
+ ) : /* @__PURE__ */ o("p", { children: [
526
+ "Review all addresses for ",
527
+ /* @__PURE__ */ e("strong", { children: i.environment }),
528
+ ". Callbacks and logout URLs must be exact. HTTPS is required outside development/test loopback."
529
+ ] }),
530
+ $ !== i.environment && /* @__PURE__ */ e(f, { kind: "secondary", onClick: () => h("environment", i.environment), children: "Use this environment" }),
531
+ r.profile !== "service" && /* @__PURE__ */ o(w, { gap: 4, children: [
532
+ /* @__PURE__ */ e(
533
+ A,
534
+ {
535
+ id: "onboarding-root",
536
+ labelText: "Application URL",
537
+ value: r.rootUrl,
538
+ onChange: (a) => h("rootUrl", a.target.value)
539
+ }
540
+ ),
541
+ [
542
+ ["redirectUris", "Sign-in callback URLs"],
543
+ ["logoutUris", "Post-logout URLs"],
544
+ ["webOrigins", "Allowed browser origins"]
545
+ ].map(([a, b]) => /* @__PURE__ */ e(
546
+ Q,
547
+ {
548
+ id: `onboarding-${a}`,
549
+ labelText: b,
550
+ helperText: "One exact address per line. No wildcards.",
551
+ value: r[a].join(`
552
+ `),
553
+ onChange: (I) => h(
554
+ a,
555
+ I.target.value.split(`
556
+ `).map((ee) => ee.trim()).filter(Boolean)
557
+ )
558
+ },
559
+ a
560
+ )),
561
+ /* @__PURE__ */ e(
562
+ Z,
563
+ {
564
+ id: "onboarding-launcher",
565
+ labelText: "Register an external portal launcher entry",
566
+ checked: r.launcher,
567
+ onChange: (a, { checked: b }) => h("launcher", b)
568
+ }
569
+ ),
570
+ /* @__PURE__ */ e("p", { children: "Launcher registration does not grant access. Configure access roles, approve and activate the portal application separately in RBAC." })
571
+ ] }),
572
+ r.profile === "service" && /* @__PURE__ */ e("p", { children: "This profile enables client credentials only. It has no browser redirects, user scopes or automatic application-role grants." }),
573
+ /* @__PURE__ */ o(w, { orientation: "horizontal", gap: 3, children: [
574
+ /* @__PURE__ */ e(f, { kind: "secondary", onClick: () => k(0), children: "Back" }),
575
+ /* @__PURE__ */ e(
576
+ f,
577
+ {
578
+ disabled: z || L || $ !== i.environment || n?.enabled,
579
+ onClick: B,
580
+ children: z ? "Validating…" : "Validate & preview"
581
+ }
582
+ )
583
+ ] })
584
+ ] }),
585
+ v === 2 && y && /* @__PURE__ */ o(q, { children: [
586
+ /* @__PURE__ */ e("h3", { children: y.operation === "update" ? "Review configuration changes" : "Review new client" }),
587
+ /* @__PURE__ */ o("dl", { children: [
588
+ /* @__PURE__ */ e("dt", { children: "Target" }),
589
+ /* @__PURE__ */ o("dd", { children: [
590
+ i.environment,
591
+ " · ",
592
+ y.realm
593
+ ] }),
594
+ /* @__PURE__ */ e("dt", { children: "Issuer" }),
595
+ /* @__PURE__ */ e("dd", { children: y.issuer }),
596
+ /* @__PURE__ */ e("dt", { children: "Client ID" }),
597
+ /* @__PURE__ */ e("dd", { children: r.clientId }),
598
+ /* @__PURE__ */ e("dt", { children: "Profile" }),
599
+ /* @__PURE__ */ e("dd", { children: r.profile }),
600
+ /* @__PURE__ */ e("dt", { children: "Sign-in method" }),
601
+ /* @__PURE__ */ e("dd", { children: r.profile === "service" ? "Client credentials" : "Authorization code with S256 PKCE" }),
602
+ /* @__PURE__ */ e("dt", { children: "Application owner" }),
603
+ /* @__PURE__ */ o("dd", { children: [
604
+ r.owner,
605
+ " · ",
606
+ r.supportEmail
607
+ ] }),
608
+ r.profile !== "service" && /* @__PURE__ */ o(q, { children: [
609
+ /* @__PURE__ */ e("dt", { children: "Sign-in callbacks" }),
610
+ /* @__PURE__ */ e("dd", { children: r.redirectUris.map((a) => /* @__PURE__ */ e("div", { children: a }, a)) }),
611
+ /* @__PURE__ */ e("dt", { children: "Post-logout addresses" }),
612
+ /* @__PURE__ */ e("dd", { children: r.logoutUris.map((a) => /* @__PURE__ */ e("div", { children: a }, a)) }),
613
+ /* @__PURE__ */ e("dt", { children: "Browser origins" }),
614
+ /* @__PURE__ */ e("dd", { children: r.webOrigins.map((a) => /* @__PURE__ */ e("div", { children: a }, a)) })
615
+ ] }),
616
+ /* @__PURE__ */ e("dt", { children: "Portal launcher" }),
617
+ /* @__PURE__ */ e("dd", { children: r.launcher ? "Register for separate access mapping and activation" : "Authentication only" }),
618
+ /* @__PURE__ */ e("dt", { children: "State after provisioning" }),
619
+ /* @__PURE__ */ e("dd", { children: "Disabled" })
620
+ ] }),
621
+ y.existing && /* @__PURE__ */ o("details", { children: [
622
+ /* @__PURE__ */ e("summary", { children: "Current configuration" }),
623
+ /* @__PURE__ */ e("pre", { children: JSON.stringify(y.existing, null, 2) })
624
+ ] }),
625
+ /* @__PURE__ */ o("details", { children: [
626
+ /* @__PURE__ */ e("summary", { children: "Advanced configuration to apply" }),
627
+ /* @__PURE__ */ e("pre", { children: JSON.stringify(y.client, null, 2) })
628
+ ] }),
629
+ /* @__PURE__ */ e(
630
+ Z,
631
+ {
632
+ id: "onboarding-reviewed",
633
+ labelText: `I reviewed these URLs and settings for ${i.environment}.`,
634
+ checked: S,
635
+ onChange: (a, { checked: b }) => D(b)
636
+ }
637
+ ),
638
+ /* @__PURE__ */ o(w, { orientation: "horizontal", gap: 3, children: [
639
+ /* @__PURE__ */ e(f, { kind: "secondary", disabled: L, onClick: () => k(1), children: "Back" }),
640
+ /* @__PURE__ */ e(f, { disabled: !S || L, onClick: V, children: L ? "Provisioning…" : "Provision disabled client" })
641
+ ] })
642
+ ] }),
643
+ !g && /* @__PURE__ */ e(f, { kind: "ghost", disabled: L, onClick: N, children: "Export onboarding draft" })
644
+ ] }) });
645
+ }
646
+ const se = (n) => ({
647
+ id: n?.id ?? "",
648
+ clientId: n?.clientId ?? "",
649
+ name: n?.name ?? "",
650
+ description: n?.description ?? "",
651
+ publicClient: n?.publicClient ?? !1,
652
+ enabled: n?.enabled ?? !0,
653
+ rootUrl: n?.rootUrl ?? "",
654
+ baseUrl: n?.baseUrl ?? "",
655
+ redirectUrisText: (n?.redirectUris ?? []).join(`
656
+ `),
657
+ webOriginsText: (n?.webOrigins ?? []).join(`
658
+ `),
659
+ icon: n?.icon ?? ""
660
+ });
661
+ function de(n) {
662
+ return n.mode === "create" || n.initialClient?.attributes?.["portal.onboarding.profile"] ? /* @__PURE__ */ e(Ze, { initialClient: n.initialClient, onSuccess: n.onSuccess }) : /* @__PURE__ */ e(en, { ...n });
663
+ }
664
+ function en({ mode: n, initialClient: t, onSuccess: i }) {
665
+ const l = Y(), [d, u] = C(null), m = n === "edit" ? t?.id : d?.id, r = n === "edit" ? t?.clientId : d?.clientId, [s, v] = C(() => se(t)), [k, p] = C(null), [x, { isLoading: y }] = Me(), [P, { isLoading: g }] = je(), R = y || g;
666
+ me(() => {
667
+ v(se(t)), u(null), p(null);
668
+ }, [t, n]);
669
+ const S = (c) => c.split(`
670
+ `).map((E) => E.trim()).filter(Boolean), D = () => ({
671
+ name: s.name.trim(),
672
+ description: s.description?.trim() || void 0,
673
+ icon: s.icon?.trim() || void 0,
674
+ publicClient: s.publicClient,
675
+ enabled: s.enabled,
676
+ rootUrl: s.rootUrl?.trim() || void 0,
677
+ baseUrl: s.baseUrl?.trim() || void 0,
678
+ redirectUris: S(s.redirectUrisText),
679
+ webOrigins: S(s.webOriginsText)
680
+ }), M = /^[a-z0-9-]+$/.test(s.clientId), z = ie(() => !(!s.name.trim() || n === "create" && (!s.clientId.trim() || !M)), [s, n, M]), U = (c, E) => {
681
+ v(($) => ({ ...$, [c]: E }));
682
+ }, L = async () => {
683
+ if (!(!z || R)) {
684
+ p(null);
685
+ try {
686
+ if (n === "create") {
687
+ const c = await x({
688
+ clientId: s.clientId.toLowerCase().trim(),
689
+ ...D()
690
+ }).unwrap();
691
+ u(c), l.success("Client created", `Client "${s.name}" was created`);
692
+ } else
693
+ await P({
694
+ id: s.id,
695
+ data: D()
696
+ }).unwrap(), l.success("Client updated", `Changes to "${s.name}" saved`);
697
+ i?.();
698
+ } catch (c) {
699
+ const E = nn(
700
+ c,
701
+ n === "create" ? "Failed to create client" : "Failed to update client"
702
+ );
703
+ p(E), l.error("Operation failed", "Please review the form and try again");
704
+ }
705
+ }
706
+ };
707
+ return /* @__PURE__ */ e(ke, { children: /* @__PURE__ */ o(w, { gap: 7, children: [
708
+ k && /* @__PURE__ */ e(K, { title: "Unable to save client", subtitle: k }),
709
+ /* @__PURE__ */ e(J, { legendText: "Client details", children: /* @__PURE__ */ o(w, { gap: 4, children: [
710
+ /* @__PURE__ */ e(
711
+ A,
712
+ {
713
+ id: "clientId",
714
+ labelText: "Client ID",
715
+ helperText: n === "create" ? "Lowercase letters, numbers, and dashes only" : "Client ID cannot be changed",
716
+ required: !0,
717
+ disabled: n === "edit",
718
+ value: s.clientId,
719
+ invalid: n === "create" && s.clientId.length > 0 && !M,
720
+ invalidText: "Only lowercase letters, numbers, and dashes allowed",
721
+ onChange: (c) => {
722
+ U("clientId", c.target.value.toLowerCase());
723
+ }
724
+ }
725
+ ),
726
+ /* @__PURE__ */ e(
727
+ A,
728
+ {
729
+ id: "name",
730
+ labelText: "Client name",
731
+ required: !0,
732
+ value: s.name,
733
+ onChange: (c) => {
734
+ U("name", c.target.value);
735
+ }
736
+ }
737
+ ),
738
+ /* @__PURE__ */ e(
739
+ Q,
740
+ {
741
+ id: "description",
742
+ labelText: "Description",
743
+ value: s.description,
744
+ onChange: (c) => {
745
+ U("description", c.target.value);
746
+ }
747
+ }
748
+ ),
749
+ /* @__PURE__ */ e(
750
+ A,
751
+ {
752
+ id: "icon",
753
+ labelText: "Icon (optional)",
754
+ value: s.icon,
755
+ onChange: (c) => {
756
+ U("icon", c.target.value);
757
+ }
758
+ }
759
+ )
760
+ ] }) }),
761
+ /* @__PURE__ */ e(J, { legendText: "URLs & redirects", children: /* @__PURE__ */ o(w, { gap: 4, children: [
762
+ /* @__PURE__ */ e(
763
+ A,
764
+ {
765
+ id: "rootUrl",
766
+ labelText: "Root URL",
767
+ value: s.rootUrl,
768
+ onChange: (c) => {
769
+ U("rootUrl", c.target.value);
770
+ }
771
+ }
772
+ ),
773
+ /* @__PURE__ */ e(
774
+ A,
775
+ {
776
+ id: "baseUrl",
777
+ labelText: "Base URL",
778
+ value: s.baseUrl,
779
+ onChange: (c) => {
780
+ U("baseUrl", c.target.value);
781
+ }
782
+ }
783
+ ),
784
+ /* @__PURE__ */ e(
785
+ Q,
786
+ {
787
+ id: "redirectUris",
788
+ labelText: "Redirect URIs",
789
+ helperText: "One per line",
790
+ value: s.redirectUrisText,
791
+ onChange: (c) => {
792
+ U("redirectUrisText", c.target.value);
793
+ }
794
+ }
795
+ ),
796
+ /* @__PURE__ */ e(
797
+ Q,
798
+ {
799
+ id: "webOrigins",
800
+ labelText: "Web origins",
801
+ helperText: "One per line",
802
+ value: s.webOriginsText,
803
+ onChange: (c) => {
804
+ U("webOriginsText", c.target.value);
805
+ }
806
+ }
807
+ )
808
+ ] }) }),
809
+ /* @__PURE__ */ e(J, { legendText: "Access & security", children: /* @__PURE__ */ o(w, { gap: 4, children: [
810
+ /* @__PURE__ */ e(
811
+ Z,
812
+ {
813
+ id: "publicClient",
814
+ labelText: "Public client (no client secret)",
815
+ checked: s.publicClient,
816
+ onChange: (c, { checked: E }) => {
817
+ U("publicClient", E);
818
+ }
819
+ }
820
+ ),
821
+ /* @__PURE__ */ e(
822
+ Z,
823
+ {
824
+ id: "enabled",
825
+ labelText: "Client enabled",
826
+ checked: s.enabled,
827
+ onChange: (c, { checked: E }) => {
828
+ U("enabled", E);
829
+ }
830
+ }
831
+ )
832
+ ] }) }),
833
+ /* @__PURE__ */ e(w, { orientation: "horizontal", gap: 3, children: /* @__PURE__ */ e(f, { kind: "primary", disabled: !z || R, onClick: L, children: R ? /* @__PURE__ */ e(
834
+ _,
835
+ {
836
+ description: n === "create" ? "Creating client…" : "Updating client…"
837
+ }
838
+ ) : n === "create" ? "Create client" : "Save changes" }) }),
839
+ m && r && /* @__PURE__ */ e(J, { legendText: "Client roles", children: /* @__PURE__ */ e(ye, { clientUuid: m, clientId: r }) })
840
+ ] }) });
841
+ }
842
+ function nn(n, t) {
843
+ if (typeof n != "object" || n === null)
844
+ return t;
845
+ const i = "data" in n ? n.data : void 0;
846
+ if (typeof i == "object" && i !== null && "message" in i) {
847
+ const l = i.message;
848
+ if (typeof l == "string" && l.trim() !== "")
849
+ return l;
850
+ }
851
+ return "message" in n && typeof n.message == "string" && n.message.trim() !== "" ? n.message : t;
852
+ }
853
+ function tn({ client: n, onEdit: t, onToggleStatus: i }) {
854
+ const l = (u) => {
855
+ u.stopPropagation(), t();
856
+ }, d = (u) => {
857
+ u.stopPropagation(), i();
858
+ };
859
+ return /* @__PURE__ */ o(
860
+ be,
861
+ {
862
+ size: "sm",
863
+ flipped: !0,
864
+ onClick: (u) => {
865
+ u.stopPropagation();
866
+ },
867
+ children: [
868
+ /* @__PURE__ */ e(te, { itemText: "Edit client", hasDivider: !0, onClick: l }),
869
+ /* @__PURE__ */ e(
870
+ te,
871
+ {
872
+ itemText: n.enabled ? "Disable client" : "Enable client",
873
+ isDelete: n.enabled,
874
+ onClick: d
875
+ }
876
+ )
877
+ ]
878
+ }
879
+ );
880
+ }
881
+ function rn({ clients: n, loadingAction: t, onEnable: i, onDisable: l }) {
882
+ if (n.length === 0) return null;
883
+ const d = n.every((m) => m.enabled), u = n.every((m) => !m.enabled);
884
+ return /* @__PURE__ */ o(xe, { className: "client-bulk-actions", children: [
885
+ /* @__PURE__ */ e(f, { kind: "secondary", disabled: d || t !== null, onClick: i, children: t === "enable" ? /* @__PURE__ */ e(_, { description: "Enabling…" }) : `Enable (${n.length})` }),
886
+ /* @__PURE__ */ e(f, { kind: "danger", disabled: u || t !== null, onClick: l, children: t === "disable" ? /* @__PURE__ */ e(_, { description: "Disabling…" }) : `Disable (${n.length})` })
887
+ ] });
888
+ }
889
+ const an = [
890
+ { id: "all", label: "All" },
891
+ { id: "enabled", label: "Enabled" },
892
+ { id: "disabled", label: "Disabled" }
893
+ ], ln = [
894
+ { id: "all", label: "All" },
895
+ { id: "public", label: "Public" },
896
+ { id: "confidential", label: "Confidential" }
897
+ ], on = [
898
+ { key: "name", header: "Name" },
899
+ { key: "clientId", header: "Client ID" },
900
+ { key: "type", header: "Type" },
901
+ { key: "status", header: "Status" },
902
+ { key: "actions", header: "" },
903
+ { key: "raw", header: "" }
904
+ // hidden
905
+ ];
906
+ function sn() {
907
+ const { openPanel: n, closePanel: t } = ve(), { openEnableClientModal: i } = Ve(), l = Y(), { can: d } = Re(), [u, m] = C(null), [r, s] = C(""), [v, k] = C("all"), [p, x] = C("all"), [y, P] = C(1), [g, R] = C(10), { data: S = [], isLoading: D, isError: M, error: z, refetch: U } = ze(), [L] = Be();
908
+ me(() => {
909
+ P(1);
910
+ }, [v, p, r]);
911
+ const c = ie(() => {
912
+ const h = r.trim().toLowerCase();
913
+ return S.filter((N) => !(h && ![N.name, N.clientId].some(
914
+ (B) => B?.toLowerCase().includes(h)
915
+ ) || v === "enabled" && !N.enabled || v === "disabled" && N.enabled || p === "public" && !N.publicClient || p === "confidential" && N.publicClient));
916
+ }, [S, v, p, r]), $ = ie(() => {
917
+ const h = (y - 1) * g;
918
+ return c.slice(h, h + g);
919
+ }, [c, y, g]).map((h) => ({
920
+ id: h.id,
921
+ name: h.name,
922
+ clientId: h.clientId,
923
+ type: h.publicClient ? "Public" : "Confidential",
924
+ status: h.enabled ? "Enabled" : "Disabled",
925
+ actions: "",
926
+ raw: h
927
+ })), j = () => {
928
+ s(""), k("all"), x("all");
929
+ };
930
+ return /* @__PURE__ */ e(
931
+ Se,
932
+ {
933
+ title: "Clients",
934
+ description: "Registered applications and services integrated with the platform.",
935
+ topContent: d("clients:write") ? /* @__PURE__ */ e(
936
+ f,
937
+ {
938
+ onClick: () => n({
939
+ title: "Onboard application",
940
+ content: /* @__PURE__ */ e(de, { mode: "create", onSuccess: t }),
941
+ size: "md"
942
+ }),
943
+ children: "Onboard application"
944
+ }
945
+ ) : void 0,
946
+ rows: $,
947
+ headers: on,
948
+ getRowId: (h) => h.id,
949
+ isLoading: D,
950
+ loadingDescription: "Loading clients…",
951
+ tableState: M ? /* @__PURE__ */ e(
952
+ Ae,
953
+ {
954
+ title: "Failed to load clients",
955
+ description: dn(z, "Failed to load clients"),
956
+ primaryAction: { label: "Retry", onClick: U }
957
+ }
958
+ ) : void 0,
959
+ searchValue: r,
960
+ onSearch: s,
961
+ searchPlaceholder: "Search clients by name or client ID",
962
+ resultsDescription: !D && !M ? `${c.length} of ${S.length} clients` : void 0,
963
+ emptyActions: /* @__PURE__ */ e(f, { kind: "ghost", onClick: j, children: "Clear filters" }),
964
+ emptyTitle: "No clients found",
965
+ emptyDescription: "No clients match the selected filters.",
966
+ filters: /* @__PURE__ */ e(
967
+ _e,
968
+ {
969
+ onReset: j,
970
+ status: v,
971
+ type: p,
972
+ statusOptions: an,
973
+ typeOptions: ln,
974
+ onStatusChange: k,
975
+ onTypeChange: x
976
+ }
977
+ ),
978
+ children: ({ rows: h, headers: N }) => /* @__PURE__ */ o(q, { children: [
979
+ /* @__PURE__ */ e(ce, { rows: h, headers: N, children: ({ rows: B, headers: V, getHeaderProps: a, getRowProps: b, getSelectionProps: I, selectedRows: ee }) => {
980
+ const H = ee.map(
981
+ (T) => T.cells.find((O) => O.info.header === "raw")?.value
982
+ );
983
+ return /* @__PURE__ */ o(q, { children: [
984
+ /* @__PURE__ */ e(
985
+ rn,
986
+ {
987
+ clients: H,
988
+ loadingAction: u,
989
+ onEnable: async () => {
990
+ try {
991
+ m("enable"), await Promise.all(
992
+ H.map(
993
+ (T) => L({
994
+ id: T.id,
995
+ enabled: !0
996
+ }).unwrap()
997
+ )
998
+ ), l.success({
999
+ title: "Clients enabled",
1000
+ subtitle: `${H.length} client(s) enabled.`
1001
+ });
1002
+ } catch {
1003
+ l.error({
1004
+ title: "Enable failed",
1005
+ subtitle: "Some clients could not be enabled."
1006
+ });
1007
+ } finally {
1008
+ m(null);
1009
+ }
1010
+ },
1011
+ onDisable: async () => {
1012
+ try {
1013
+ m("disable"), await Promise.all(
1014
+ H.map(
1015
+ (T) => L({
1016
+ id: T.id,
1017
+ enabled: !1
1018
+ }).unwrap()
1019
+ )
1020
+ ), l.warning({
1021
+ title: "Clients disabled",
1022
+ subtitle: `${H.length} client(s) disabled.`
1023
+ });
1024
+ } catch {
1025
+ l.error({
1026
+ title: "Disable failed",
1027
+ subtitle: "Some clients could not be disabled."
1028
+ });
1029
+ } finally {
1030
+ m(null);
1031
+ }
1032
+ }
1033
+ }
1034
+ ),
1035
+ /* @__PURE__ */ o(ue, { children: [
1036
+ /* @__PURE__ */ e(pe, { children: /* @__PURE__ */ o(W, { children: [
1037
+ /* @__PURE__ */ e(Ue, { ...I() }),
1038
+ V.filter((T) => T.key !== "raw").map((T) => /* @__PURE__ */ e(he, { ...a({ header: T }), children: T.header }))
1039
+ ] }) }),
1040
+ /* @__PURE__ */ e(ge, { children: B.map((T) => {
1041
+ const O = T.cells.find((F) => F.info.header === "raw")?.value;
1042
+ return /* @__PURE__ */ o(W, { ...b({ row: T }), children: [
1043
+ /* @__PURE__ */ e(Ie, { ...I({ row: T }) }),
1044
+ T.cells.map((F) => F.info.header === "raw" ? null : F.info.header === "status" ? /* @__PURE__ */ e(X, { children: /* @__PURE__ */ e(
1045
+ De,
1046
+ {
1047
+ status: String(F.value),
1048
+ kind: O.enabled ? "green" : "red"
1049
+ }
1050
+ ) }, F.id) : F.info.header === "actions" ? /* @__PURE__ */ e(Ee, { children: /* @__PURE__ */ e(
1051
+ tn,
1052
+ {
1053
+ client: O,
1054
+ onEdit: () => {
1055
+ n({
1056
+ title: "Edit client",
1057
+ content: /* @__PURE__ */ e(
1058
+ de,
1059
+ {
1060
+ mode: "edit",
1061
+ initialClient: O,
1062
+ onSuccess: t
1063
+ },
1064
+ `edit-client-${O.id}`
1065
+ ),
1066
+ size: "md"
1067
+ });
1068
+ },
1069
+ onToggleStatus: () => {
1070
+ i({
1071
+ clientName: O.name,
1072
+ enabled: O.enabled,
1073
+ onConfirm: async () => {
1074
+ try {
1075
+ await L({
1076
+ id: O.id,
1077
+ enabled: !O.enabled
1078
+ }).unwrap(), l.success({
1079
+ title: "Client updated",
1080
+ subtitle: `${O.name} updated successfully.`
1081
+ });
1082
+ } catch {
1083
+ l.error({
1084
+ title: "Update failed",
1085
+ subtitle: `Failed to update ${O.name}.`
1086
+ });
1087
+ }
1088
+ }
1089
+ });
1090
+ }
1091
+ }
1092
+ ) }, F.id) : /* @__PURE__ */ e(X, { children: F.value }, F.id))
1093
+ ] });
1094
+ }) })
1095
+ ] })
1096
+ ] });
1097
+ } }),
1098
+ /* @__PURE__ */ e(
1099
+ Oe,
1100
+ {
1101
+ page: y,
1102
+ pageSize: g,
1103
+ totalItems: c.length,
1104
+ onChange: ({ page: B, pageSize: V }) => {
1105
+ P(B), R(V);
1106
+ }
1107
+ }
1108
+ )
1109
+ ] })
1110
+ }
1111
+ );
1112
+ }
1113
+ function dn(n, t) {
1114
+ if (typeof n != "object" || n === null)
1115
+ return t;
1116
+ const i = "data" in n ? n.data : void 0;
1117
+ if (typeof i == "object" && i !== null && "message" in i) {
1118
+ const l = i.message;
1119
+ if (typeof l == "string" && l.trim() !== "")
1120
+ return l;
1121
+ }
1122
+ return "message" in n && typeof n.message == "string" && n.message.trim() !== "" ? n.message : t;
1123
+ }
1124
+ function vn(n) {
1125
+ return /* @__PURE__ */ e("div", { className: "moh-microfrontend-root", children: /* @__PURE__ */ e(sn, {}) });
1126
+ }
1127
+ export {
1128
+ vn as C,
1129
+ de as a,
1130
+ sn as b
1131
+ };
1132
+ //# sourceMappingURL=root.component-WxWhdR-e.js.map