@scalio-cloud/ui 0.108.0 → 0.110.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 (83) hide show
  1. package/dist/app-kit/ScalioAuditPages.d.ts +37 -0
  2. package/dist/app-kit/ScalioAuditPages.d.ts.map +1 -0
  3. package/dist/app-kit/ScalioBackupSection.d.ts +27 -0
  4. package/dist/app-kit/ScalioBackupSection.d.ts.map +1 -0
  5. package/dist/app-kit/ScalioFactoryReset.d.ts +15 -0
  6. package/dist/app-kit/ScalioFactoryReset.d.ts.map +1 -0
  7. package/dist/app-kit/ScalioInvitePage.d.ts +24 -0
  8. package/dist/app-kit/ScalioInvitePage.d.ts.map +1 -0
  9. package/dist/app-kit/ScalioLicensePanel.d.ts +23 -0
  10. package/dist/app-kit/ScalioLicensePanel.d.ts.map +1 -0
  11. package/dist/app-kit/ScalioLoginPage.d.ts +31 -0
  12. package/dist/app-kit/ScalioLoginPage.d.ts.map +1 -0
  13. package/dist/app-kit/ScalioMailSettings.d.ts +13 -0
  14. package/dist/app-kit/ScalioMailSettings.d.ts.map +1 -0
  15. package/dist/app-kit/ScalioPasswordChangePage.d.ts +21 -0
  16. package/dist/app-kit/ScalioPasswordChangePage.d.ts.map +1 -0
  17. package/dist/app-kit/ScalioProfilePage.d.ts +39 -0
  18. package/dist/app-kit/ScalioProfilePage.d.ts.map +1 -0
  19. package/dist/app-kit/ScalioRoleTenants.d.ts +22 -0
  20. package/dist/app-kit/ScalioRoleTenants.d.ts.map +1 -0
  21. package/dist/app-kit/ScalioSaasUpdatesSection.d.ts +23 -0
  22. package/dist/app-kit/ScalioSaasUpdatesSection.d.ts.map +1 -0
  23. package/dist/app-kit/ScalioSecurityFactors.d.ts +28 -0
  24. package/dist/app-kit/ScalioSecurityFactors.d.ts.map +1 -0
  25. package/dist/app-kit/ScalioSelfTestPage.d.ts +14 -0
  26. package/dist/app-kit/ScalioSelfTestPage.d.ts.map +1 -0
  27. package/dist/app-kit/ScalioSupportCard.d.ts +13 -0
  28. package/dist/app-kit/ScalioSupportCard.d.ts.map +1 -0
  29. package/dist/app-kit/ScalioUsersPage.d.ts +48 -0
  30. package/dist/app-kit/ScalioUsersPage.d.ts.map +1 -0
  31. package/dist/app-kit/_uiReact.d.ts +307 -0
  32. package/dist/app-kit/_uiReact.d.ts.map +1 -0
  33. package/dist/app-kit/index.d.ts +31 -0
  34. package/dist/app-kit/index.d.ts.map +1 -0
  35. package/dist/app-kit/index.js +1128 -0
  36. package/dist/app-kit/index.js.map +1 -0
  37. package/dist/app-kit/index.mjs +1051 -0
  38. package/dist/app-kit/index.mjs.map +1 -0
  39. package/dist/chunk-A7O3P4YV.mjs +457 -0
  40. package/dist/chunk-A7O3P4YV.mjs.map +1 -0
  41. package/dist/config/i18nCheck.d.ts +49 -0
  42. package/dist/config/i18nCheck.d.ts.map +1 -0
  43. package/dist/config/index.d.ts +37 -0
  44. package/dist/config/index.d.ts.map +1 -0
  45. package/dist/config/index.js +268 -0
  46. package/dist/config/index.js.map +1 -0
  47. package/dist/config/index.mjs +234 -0
  48. package/dist/config/index.mjs.map +1 -0
  49. package/dist/config/openapi.d.ts +34 -0
  50. package/dist/config/openapi.d.ts.map +1 -0
  51. package/dist/core/afterLogin.d.ts +6 -0
  52. package/dist/core/afterLogin.d.ts.map +1 -0
  53. package/dist/core/api.d.ts +48 -0
  54. package/dist/core/api.d.ts.map +1 -0
  55. package/dist/core/auditActions.d.ts +17 -0
  56. package/dist/core/auditActions.d.ts.map +1 -0
  57. package/dist/core/datetime.d.ts +18 -0
  58. package/dist/core/datetime.d.ts.map +1 -0
  59. package/dist/core/i18n.d.ts +51 -0
  60. package/dist/core/i18n.d.ts.map +1 -0
  61. package/dist/core/index.d.ts +14 -0
  62. package/dist/core/index.d.ts.map +1 -0
  63. package/dist/core/index.js +509 -0
  64. package/dist/core/index.js.map +1 -0
  65. package/dist/core/index.mjs +39 -0
  66. package/dist/core/index.mjs.map +1 -0
  67. package/dist/core/legal.d.ts +17 -0
  68. package/dist/core/legal.d.ts.map +1 -0
  69. package/dist/core/mailReady.d.ts +12 -0
  70. package/dist/core/mailReady.d.ts.map +1 -0
  71. package/dist/core/passkeys.d.ts +30 -0
  72. package/dist/core/passkeys.d.ts.map +1 -0
  73. package/dist/core/permissions.d.ts +10 -0
  74. package/dist/core/permissions.d.ts.map +1 -0
  75. package/dist/editor/RichTextEditor.d.ts +58 -0
  76. package/dist/editor/RichTextEditor.d.ts.map +1 -0
  77. package/dist/editor/index.d.ts +5 -0
  78. package/dist/editor/index.d.ts.map +1 -0
  79. package/dist/editor/index.js +350 -0
  80. package/dist/editor/index.js.map +1 -0
  81. package/dist/editor/index.mjs +324 -0
  82. package/dist/editor/index.mjs.map +1 -0
  83. package/package.json +68 -3
@@ -0,0 +1,1128 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/app-kit/index.ts
31
+ var app_kit_exports = {};
32
+ __export(app_kit_exports, {
33
+ ScalioAuditHeader: () => ScalioAuditHeader,
34
+ ScalioAuditPage: () => ScalioAuditPage,
35
+ ScalioBackupSection: () => ScalioBackupSection,
36
+ ScalioFactoryReset: () => ScalioFactoryReset,
37
+ ScalioInvitePage: () => ScalioInvitePage,
38
+ ScalioJobsPage: () => ScalioJobsPage,
39
+ ScalioLicensePanel: () => ScalioLicensePanel,
40
+ ScalioLoginPage: () => ScalioLoginPage,
41
+ ScalioMailSettings: () => ScalioMailSettings,
42
+ ScalioMaintenanceBanner: () => ScalioMaintenanceBanner,
43
+ ScalioPasswordChangePage: () => ScalioPasswordChangePage,
44
+ ScalioProfilePage: () => ScalioProfilePage,
45
+ ScalioRoleTenants: () => ScalioRoleTenants,
46
+ ScalioSaasUpdateBanner: () => ScalioSaasUpdateBanner,
47
+ ScalioSaasUpdatesSection: () => ScalioSaasUpdatesSection,
48
+ ScalioSecurityFactors: () => ScalioSecurityFactors,
49
+ ScalioSelfTestPage: () => ScalioSelfTestPage,
50
+ ScalioSupportCard: () => ScalioSupportCard,
51
+ ScalioUsersPage: () => ScalioUsersPage
52
+ });
53
+ module.exports = __toCommonJS(app_kit_exports);
54
+
55
+ // src/app-kit/ScalioSecurityFactors.tsx
56
+ var import_react2 = require("react");
57
+ var import_sonner = require("sonner");
58
+
59
+ // src/app-kit/_uiReact.ts
60
+ var import_react = __toESM(require("@scalio-cloud/ui/react"));
61
+ var {
62
+ AuditLog,
63
+ AuditNav,
64
+ AuthHeader,
65
+ AuthLayout,
66
+ AuthMessage,
67
+ BackupPanel,
68
+ FactoryReset,
69
+ JobsPanel,
70
+ LanguageChoice,
71
+ LicensePanel,
72
+ LoginPage,
73
+ MailTransport,
74
+ MaintenanceNotice,
75
+ MicrosoftConnection,
76
+ PageHeader,
77
+ PasswordChange,
78
+ PasswordPolicySelect,
79
+ ProfileIdentity,
80
+ ProfileSection,
81
+ RoleAdmin,
82
+ RoleSourceSettings,
83
+ SaasUpdatesPanel,
84
+ SecurityFactors,
85
+ SelfTestPanel,
86
+ SettingsLayout,
87
+ SettingsSection,
88
+ SupportConnection,
89
+ ThemeChoice,
90
+ TimezoneChoice,
91
+ UpdateBanner,
92
+ UserAdmin,
93
+ accountArea,
94
+ accountGroups,
95
+ auditApi,
96
+ backupApi,
97
+ customerAccessProps,
98
+ factoryResetApi,
99
+ jobsApi,
100
+ labelsFor,
101
+ licenseApi,
102
+ mailApi,
103
+ rolesApi,
104
+ saasUpdatesApi,
105
+ securityApi,
106
+ selftestApi,
107
+ supportApi,
108
+ usersApi
109
+ } = import_react.default;
110
+
111
+ // src/app-kit/ScalioSecurityFactors.tsx
112
+ var import_jsx_runtime = require("react/jsx-runtime");
113
+ var defaultNotify = (text, tone) => {
114
+ if (tone === "error") import_sonner.toast.error(text);
115
+ else import_sonner.toast.success(text);
116
+ };
117
+ function ScalioSecurityFactors({
118
+ api,
119
+ product,
120
+ lang,
121
+ email,
122
+ qr,
123
+ confirm,
124
+ formatApiErrorDetail,
125
+ startRegistration,
126
+ browserSupportsWebAuthn,
127
+ onMfaChange,
128
+ className = "mt-8 pt-6 border-t border-border"
129
+ }) {
130
+ const client = (0, import_react2.useMemo)(
131
+ () => securityApi(api, { startRegistration, browserSupportsWebAuthn }),
132
+ [api, startRegistration, browserSupportsWebAuthn]
133
+ );
134
+ const formatError = (e) => {
135
+ const err = e;
136
+ return formatApiErrorDetail(err?.response?.data?.detail) || err?.message || "";
137
+ };
138
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
139
+ SecurityFactors,
140
+ {
141
+ client,
142
+ lang,
143
+ product,
144
+ email,
145
+ qr,
146
+ notify: defaultNotify,
147
+ confirm,
148
+ formatError,
149
+ className,
150
+ onMfaChange
151
+ }
152
+ );
153
+ }
154
+
155
+ // src/app-kit/ScalioPasswordChangePage.tsx
156
+ var import_sonner2 = require("sonner");
157
+ var import_jsx_runtime2 = require("react/jsx-runtime");
158
+ function ScalioPasswordChangePage({
159
+ api,
160
+ brand,
161
+ legalUrl,
162
+ email,
163
+ lang,
164
+ onLangChange,
165
+ t,
166
+ minLength = 12,
167
+ onPasswordChanged,
168
+ onLogout
169
+ }) {
170
+ const change = async (current, next) => {
171
+ const { data } = await api.post("/auth/change-password", {
172
+ current_password: current,
173
+ new_password: next
174
+ });
175
+ return data;
176
+ };
177
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AuthLayout, { legalUrl, brand, lang, onLangChange, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "space-y-4", "data-testid": "password-change-required", children: [
178
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
179
+ AuthHeader,
180
+ {
181
+ eyebrow: email,
182
+ title: t("Choose your password"),
183
+ subtitle: t("You signed in with a start password. Choose your own password to continue.")
184
+ }
185
+ ),
186
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
187
+ PasswordChange,
188
+ {
189
+ onSubmit: change,
190
+ minLength,
191
+ lang,
192
+ onDone: () => {
193
+ import_sonner2.toast.success(t("Password changed."));
194
+ onPasswordChanged();
195
+ }
196
+ }
197
+ ),
198
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
199
+ "button",
200
+ {
201
+ type: "button",
202
+ onClick: onLogout,
203
+ "data-testid": "password-change-logout",
204
+ className: "w-full h-9 text-xs font-bold uppercase tracking-wider text-muted-foreground hover:text-foreground",
205
+ children: t("Sign out")
206
+ }
207
+ )
208
+ ] }) });
209
+ }
210
+
211
+ // src/app-kit/ScalioProfilePage.tsx
212
+ var import_react5 = require("react");
213
+ var import_sonner3 = require("sonner");
214
+ var import_lucide_react = require("lucide-react");
215
+
216
+ // src/core/api.ts
217
+ var import_axios = __toESM(require("axios"));
218
+
219
+ // src/core/i18n.tsx
220
+ var import_react3 = __toESM(require("react"));
221
+ function N_(text) {
222
+ return text;
223
+ }
224
+
225
+ // src/core/permissions.ts
226
+ function can(user, permission) {
227
+ if (!user) return false;
228
+ if (user.role === "admin") return true;
229
+ return Array.isArray(user.permissions) && user.permissions.includes(permission);
230
+ }
231
+
232
+ // src/core/mailReady.ts
233
+ function mailReady(settings) {
234
+ if (!settings || !settings.provider || settings.provider === "off") return false;
235
+ if (settings.provider === "default") return Boolean(settings.default && settings.default.available);
236
+ return true;
237
+ }
238
+
239
+ // src/core/legal.ts
240
+ var import_react4 = require("react");
241
+
242
+ // src/app-kit/ScalioProfilePage.tsx
243
+ var import_jsx_runtime3 = require("react/jsx-runtime");
244
+ var FIELD_CLASS = "mt-1 w-full h-10 px-3 bg-background border border-input rounded-sm text-sm focus:outline-none focus:ring-1 focus:ring-ring focus:border-ring transition-colors";
245
+ var LABEL_CLASS = "text-[11px] font-bold uppercase tracking-widest text-muted-foreground";
246
+ var PRIMARY_CLASS = "inline-flex h-10 items-center justify-center gap-2 px-4 bg-primary text-primary-foreground rounded-sm text-xs font-bold uppercase tracking-wider hover:bg-primary/90 transition-colors disabled:opacity-60";
247
+ var MS_LINK_ERRORS = {
248
+ linked_elsewhere: N_("This Microsoft account belongs to another account here. Ask an administrator."),
249
+ already_linked: N_("Your account is already linked with Microsoft."),
250
+ failed: N_("Linking with Microsoft failed. Please try again.")
251
+ };
252
+ function ScalioProfilePage({
253
+ api,
254
+ apiBaseUrl,
255
+ user,
256
+ updateUser,
257
+ lang,
258
+ setLang,
259
+ t,
260
+ theme,
261
+ setTheme,
262
+ formatApiErrorDetail,
263
+ roleLabels,
264
+ languageEndpoint = "/auth/language",
265
+ minPasswordLength = 12,
266
+ securityFactors
267
+ }) {
268
+ const L = labelsFor(lang);
269
+ const P = L.profile_;
270
+ const [name, setName] = (0, import_react5.useState)(user?.name || "");
271
+ const [savingName, setSavingName] = (0, import_react5.useState)(false);
272
+ const [ssoOn, setSsoOn] = (0, import_react5.useState)(false);
273
+ const saved = () => {
274
+ import_sonner3.toast.success(P.saved);
275
+ };
276
+ const errorText = (e) => {
277
+ const err = e;
278
+ return formatApiErrorDetail(err?.response?.data?.detail) || err?.message || t("Something went wrong. Please try again.");
279
+ };
280
+ const defaultRoles = {
281
+ admin: t("Administrator"),
282
+ operator: t("Operator"),
283
+ editor: t("Editor"),
284
+ reader: t("Reader")
285
+ };
286
+ const resolvedRoles = roleLabels ?? defaultRoles;
287
+ const roleName = user?.role && resolvedRoles[user.role] || t("Reader");
288
+ (0, import_react5.useEffect)(() => {
289
+ api.get("/auth/scalio/status").then((r) => setSsoOn(Boolean(r.data?.enabled))).catch(() => setSsoOn(false));
290
+ if (typeof window === "undefined") return;
291
+ const result = new URLSearchParams(window.location.search).get("microsoft");
292
+ if (!result) return;
293
+ window.history.replaceState(null, "", window.location.pathname);
294
+ if (result === "linked") {
295
+ import_sonner3.toast.success(t("Your Microsoft account is linked."));
296
+ api.get("/auth/me").then((r) => updateUser(r.data)).catch(() => null);
297
+ } else {
298
+ import_sonner3.toast.error(t(MS_LINK_ERRORS[result] ?? MS_LINK_ERRORS.failed));
299
+ }
300
+ }, []);
301
+ const unlinkMicrosoft = async () => {
302
+ try {
303
+ await api.delete("/auth/scalio/link");
304
+ if (user) updateUser({ ...user, microsoft: false });
305
+ import_sonner3.toast.success(t("The Microsoft link was removed."));
306
+ } catch (err) {
307
+ import_sonner3.toast.error(errorText(err));
308
+ }
309
+ };
310
+ const chooseLang = async (nextLang) => {
311
+ setLang(nextLang);
312
+ try {
313
+ const { data } = await api.post(languageEndpoint, {
314
+ language: nextLang
315
+ });
316
+ if (user) updateUser({ ...user, language: data?.language ?? nextLang });
317
+ saved();
318
+ if (data?.language_sync && typeof window !== "undefined") {
319
+ window.location.assign(
320
+ `${apiBaseUrl.replace(/\/api$/, "")}${data.language_sync}?next=${encodeURIComponent("/profile")}`
321
+ );
322
+ }
323
+ } catch (err) {
324
+ if (languageEndpoint === "/auth/preferences") {
325
+ import_sonner3.toast.error(errorText(err));
326
+ } else {
327
+ saved();
328
+ }
329
+ }
330
+ };
331
+ const saveName = async (e) => {
332
+ e.preventDefault();
333
+ setSavingName(true);
334
+ try {
335
+ const { data } = await api.put("/auth/profile", { name });
336
+ updateUser(data);
337
+ import_sonner3.toast.success(t("Profile saved"));
338
+ } catch (err) {
339
+ import_sonner3.toast.error(errorText(err));
340
+ } finally {
341
+ setSavingName(false);
342
+ }
343
+ };
344
+ const chooseTz = async (tz) => {
345
+ try {
346
+ await api.post("/auth/preferences", { timezone: tz });
347
+ if (user) updateUser({ ...user, timezone: tz });
348
+ saved();
349
+ } catch (err) {
350
+ import_sonner3.toast.error(errorText(err));
351
+ }
352
+ };
353
+ const changePassword = async (current, next) => {
354
+ await api.post("/auth/change-password", { current_password: current, new_password: next });
355
+ };
356
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { "data-testid": "profile-page", className: "space-y-6", children: [
357
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
358
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h1", { className: "font-display font-black uppercase tracking-tight text-3xl sm:text-4xl", children: L.profile }),
359
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "text-sm text-muted-foreground", children: P.subtitle })
360
+ ] }),
361
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
362
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ProfileSection, { id: "account", lang, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ProfileIdentity, { name: user?.name, email: user?.email, role: roleName, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("form", { onSubmit: saveName, className: "flex flex-col sm:flex-row sm:items-end gap-3", children: [
363
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex-1", children: [
364
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("label", { className: LABEL_CLASS, htmlFor: "profile-name", children: t("Name") }),
365
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
366
+ "input",
367
+ {
368
+ id: "profile-name",
369
+ className: FIELD_CLASS,
370
+ value: name,
371
+ onChange: (e) => setName(e.target.value),
372
+ required: true,
373
+ maxLength: 120,
374
+ autoComplete: "name",
375
+ "data-testid": "profile-name-input"
376
+ }
377
+ )
378
+ ] }),
379
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
380
+ "button",
381
+ {
382
+ type: "submit",
383
+ className: PRIMARY_CLASS,
384
+ disabled: savingName || !name.trim() || name.trim() === user?.name,
385
+ "data-testid": "profile-save-btn",
386
+ children: [
387
+ savingName && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react.Loader2, { className: "w-4 h-4 animate-spin" }),
388
+ t("Save")
389
+ ]
390
+ }
391
+ )
392
+ ] }) }) }),
393
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ProfileSection, { id: "appearance", lang, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
394
+ ThemeChoice,
395
+ {
396
+ theme,
397
+ onChange: (m) => {
398
+ setTheme(m);
399
+ saved();
400
+ },
401
+ lang
402
+ }
403
+ ) }),
404
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(ProfileSection, { id: "language", lang, children: [
405
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(LanguageChoice, { lang, onChange: chooseLang }),
406
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TimezoneChoice, { value: user?.timezone || "", onChange: chooseTz, lang })
407
+ ] }),
408
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(ProfileSection, { id: "security", lang, testId: "change-password-section", children: [
409
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
410
+ PasswordChange,
411
+ {
412
+ onSubmit: changePassword,
413
+ onDone: () => import_sonner3.toast.success(t("Password changed. Other devices have been signed out.")),
414
+ minLength: minPasswordLength,
415
+ lang
416
+ }
417
+ ),
418
+ securityFactors
419
+ ] }),
420
+ (ssoOn || user?.microsoft) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ProfileSection, { id: "connections", lang, testId: "connections-section", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
421
+ MicrosoftConnection,
422
+ {
423
+ linked: Boolean(user?.microsoft),
424
+ canUnlink: Boolean(user?.has_password),
425
+ lang,
426
+ onLink: () => window.location.assign(`${apiBaseUrl}/auth/scalio/login?link=1`),
427
+ onUnlink: unlinkMicrosoft
428
+ }
429
+ ) })
430
+ ] })
431
+ ] });
432
+ }
433
+
434
+ // src/app-kit/ScalioUsersPage.tsx
435
+ var import_react6 = require("react");
436
+ var import_react_router_dom = require("react-router-dom");
437
+ var import_sonner4 = require("sonner");
438
+ var import_jsx_runtime4 = require("react/jsx-runtime");
439
+ function roleLabel(name, lang) {
440
+ if (name && typeof name === "object") {
441
+ return (lang === "en" ? name.en || name.de : name.de || name.en) || "";
442
+ }
443
+ return name;
444
+ }
445
+ function ScalioUsersPage({
446
+ api,
447
+ user,
448
+ lang,
449
+ t,
450
+ confirm,
451
+ formatApiErrorDetail,
452
+ defaultRole = "reader",
453
+ customers,
454
+ emptyCustomersHint,
455
+ renderEntraTab
456
+ }) {
457
+ const L = labelsFor(lang);
458
+ const [params] = (0, import_react_router_dom.useSearchParams)();
459
+ const { area } = (0, import_react_router_dom.useParams)();
460
+ const navigate = (0, import_react_router_dom.useNavigate)();
461
+ const usersClient = (0, import_react6.useMemo)(() => usersApi(api), [api]);
462
+ const rolesClient = (0, import_react6.useMemo)(() => rolesApi(api), [api]);
463
+ const [rows, setRows] = (0, import_react6.useState)([]);
464
+ const [ssoOn, setSsoOn] = (0, import_react6.useState)(false);
465
+ const [mailOn, setMailOn] = (0, import_react6.useState)(false);
466
+ const [roles, setRoles] = (0, import_react6.useState)([]);
467
+ const [policy, setPolicy] = (0, import_react6.useState)(null);
468
+ const load = (0, import_react6.useCallback)(() => {
469
+ api.get("/users").then((r) => setRows(r.data)).catch(() => setRows([]));
470
+ rolesClient.list().then(setRoles).catch(() => setRoles([]));
471
+ api.get("/users/login-policy").then((r) => setPolicy(r.data)).catch(() => setPolicy(null));
472
+ api.get("/auth/scalio/status").then((r) => setSsoOn(Boolean(r.data?.enabled))).catch(() => setSsoOn(false));
473
+ api.get("/mail/settings").then((r) => setMailOn(mailReady(r.data))).catch(() => setMailOn(false));
474
+ }, [api, rolesClient]);
475
+ (0, import_react6.useEffect)(() => {
476
+ load();
477
+ }, [load]);
478
+ const fail = (e) => {
479
+ const err = e;
480
+ if (err?.licenseShown) return;
481
+ import_sonner4.toast.error(err?.response?.data?.detail ? formatApiErrorDetail(err.response.data.detail) : t("The action failed."));
482
+ };
483
+ const savePolicy = async (value) => {
484
+ if (value !== "local" && !await confirm({
485
+ title: value === "off" ? t("Turn off sign-in with a password?") : t("Only the emergency administrator with a password?"),
486
+ text: value === "off" ? t(
487
+ "From now on, everybody signs in with Microsoft. Passwords and passkeys no longer work. If Microsoft is unreachable, FORCE_LOCAL_LOGIN=true in the environment brings them back."
488
+ ) : t(
489
+ "From now on, everybody signs in with Microsoft, except the administrators marked as emergency administrator."
490
+ ),
491
+ action: t("Save")
492
+ })) {
493
+ return;
494
+ }
495
+ try {
496
+ const { data } = await api.put("/users/login-policy", { value });
497
+ setPolicy(data);
498
+ import_sonner4.toast.success(t("Saved"));
499
+ } catch (e) {
500
+ fail(e);
501
+ }
502
+ };
503
+ if (user?.role !== "admin") {
504
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "text-sm text-muted-foreground", children: t("Only administrators can manage users.") });
505
+ }
506
+ const pending = rows.filter((u) => u.access_pending).length;
507
+ const emergencyCount = rows.filter(
508
+ (u) => u.emergency_admin && u.role === "admin" && u.has_password && !u.access_pending
509
+ ).length;
510
+ const active = accountArea(area);
511
+ if (!area) {
512
+ const old = params.get("tab");
513
+ const target = old === "signIn" ? "sign-in" : old && ["roles", "entra"].includes(old) ? old : "users";
514
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_router_dom.Navigate, { to: `/accounts/${target}`, replace: true });
515
+ }
516
+ const notify2 = (text, tone) => {
517
+ if (tone === "error") import_sonner4.toast.error(text);
518
+ else import_sonner4.toast.success(text);
519
+ };
520
+ const formatErr = (e) => {
521
+ const err = e;
522
+ return err?.response?.data?.detail ? formatApiErrorDetail(err.response.data.detail) : t("The action failed.");
523
+ };
524
+ const groups = accountGroups({ lang }).map(
525
+ (g) => ({
526
+ ...g,
527
+ items: g.items.map(
528
+ (it) => it.id === "users" ? {
529
+ ...it,
530
+ hint: t("Who can use this app and what they may do"),
531
+ label: pending > 0 ? `${it.label} (${pending})` : it.label
532
+ } : it
533
+ )
534
+ })
535
+ );
536
+ const extraCustomerProps = customers ? customerAccessProps({
537
+ customers,
538
+ lang,
539
+ emptyHint: emptyCustomersHint ?? t("No customers yet. Add them under Settings, Tenants.")
540
+ }) : {};
541
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { "data-testid": "users-page", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
542
+ SettingsLayout,
543
+ {
544
+ groups,
545
+ active,
546
+ title: active === "users" ? L.accountTabs.users : void 0,
547
+ root: L.accounts,
548
+ link: import_react_router_dom.NavLink,
549
+ onSelect: (it) => navigate(it.to),
550
+ lang,
551
+ search: false,
552
+ testId: "accounts-layout",
553
+ children: [
554
+ active === "users" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
555
+ UserAdmin,
556
+ {
557
+ client: usersClient,
558
+ me: user.id,
559
+ lang,
560
+ canLock: true,
561
+ onChange: load,
562
+ roles: roles.map((r) => ({ value: r.id, label: roleLabel(r.name, lang) })),
563
+ defaultRole,
564
+ signInModes: mailOn ? ["microsoft", "password", "invite"] : ["microsoft", "password"],
565
+ microsoftEnabled: ssoOn,
566
+ ...extraCustomerProps,
567
+ notify: notify2,
568
+ confirm,
569
+ formatError: formatErr
570
+ }
571
+ ),
572
+ active === "roles" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
573
+ RoleAdmin,
574
+ {
575
+ client: rolesClient,
576
+ lang,
577
+ onChange: load,
578
+ currentRole: user.role,
579
+ notify: notify2,
580
+ confirm,
581
+ formatError: formatErr
582
+ }
583
+ ),
584
+ active === "entra" && renderEntraTab?.(load),
585
+ active === "signIn" && policy && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { "data-testid": "login-policy-card", className: "bg-card border border-border rounded-sm px-4 py-3", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
586
+ PasswordPolicySelect,
587
+ {
588
+ value: policy.value,
589
+ emergencyCount,
590
+ forced: policy.forced,
591
+ onChange: savePolicy,
592
+ lang,
593
+ testId: "login-policy"
594
+ }
595
+ ) })
596
+ ]
597
+ }
598
+ ) });
599
+ }
600
+
601
+ // src/app-kit/ScalioLoginPage.tsx
602
+ var import_react7 = require("react");
603
+ var import_react_router_dom2 = require("react-router-dom");
604
+ var import_jsx_runtime5 = require("react/jsx-runtime");
605
+ function ScalioLoginPage({
606
+ api,
607
+ apiBase,
608
+ auth,
609
+ appName,
610
+ brand,
611
+ lang,
612
+ onLangChange,
613
+ legalUrl,
614
+ passkeys = false,
615
+ clearSessionKeys = [],
616
+ afterLoginTo = "/",
617
+ onSignedIn
618
+ }) {
619
+ const navigate = (0, import_react_router_dom2.useNavigate)();
620
+ (0, import_react7.useEffect)(() => {
621
+ if (clearSessionKeys.length === 0) return;
622
+ try {
623
+ for (const key of clearSessionKeys) {
624
+ sessionStorage.removeItem(key);
625
+ }
626
+ } catch {
627
+ }
628
+ }, [clearSessionKeys]);
629
+ const handleSignedIn = (0, import_react7.useCallback)(() => {
630
+ if (onSignedIn) onSignedIn();
631
+ else navigate(afterLoginTo, { replace: true });
632
+ }, [onSignedIn, navigate, afterLoginTo]);
633
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
634
+ LoginPage,
635
+ {
636
+ api,
637
+ apiBase,
638
+ auth,
639
+ appName,
640
+ brand,
641
+ lang,
642
+ onLangChange,
643
+ legalUrl,
644
+ passkeys,
645
+ onSignedIn: handleSignedIn
646
+ }
647
+ );
648
+ }
649
+
650
+ // src/app-kit/ScalioInvitePage.tsx
651
+ var import_react8 = require("react");
652
+ var import_react_router_dom3 = require("react-router-dom");
653
+ var import_lucide_react2 = require("lucide-react");
654
+ var import_jsx_runtime6 = require("react/jsx-runtime");
655
+ var FIELD_CLASS2 = "mt-1 w-full h-11 px-3 bg-background border border-input rounded-sm text-sm focus:outline-none focus:ring-1 focus:ring-ring";
656
+ var LABEL_CLASS2 = "text-[11px] font-bold uppercase tracking-widest text-muted-foreground";
657
+ function ScalioInvitePage({
658
+ api,
659
+ brand,
660
+ welcomeTitle,
661
+ legalUrl,
662
+ lang,
663
+ onLangChange,
664
+ t,
665
+ formatApiErrorDetail,
666
+ onAuthenticated,
667
+ redirectTo = "/"
668
+ }) {
669
+ const navigate = (0, import_react_router_dom3.useNavigate)();
670
+ const [token] = (0, import_react8.useState)(() => typeof window !== "undefined" ? window.location.hash.replace(/^#/, "") : "");
671
+ const [info, setInfo] = (0, import_react8.useState)(null);
672
+ const [invalid, setInvalid] = (0, import_react8.useState)(false);
673
+ const [pw, setPw] = (0, import_react8.useState)("");
674
+ const [pw2, setPw2] = (0, import_react8.useState)("");
675
+ const [error, setError] = (0, import_react8.useState)("");
676
+ const [busy, setBusy] = (0, import_react8.useState)(false);
677
+ (0, import_react8.useEffect)(() => {
678
+ if (!token) {
679
+ setInvalid(true);
680
+ return;
681
+ }
682
+ api.get(`/auth/invite/${encodeURIComponent(token)}`).then((r) => setInfo(r.data)).catch(() => setInvalid(true));
683
+ }, [api, token]);
684
+ const submit = async (e) => {
685
+ e.preventDefault();
686
+ setError("");
687
+ if (pw !== pw2) {
688
+ setError(t("The passwords do not match."));
689
+ return;
690
+ }
691
+ setBusy(true);
692
+ try {
693
+ const { data } = await api.post(`/auth/invite/${encodeURIComponent(token)}`, { password: pw });
694
+ onAuthenticated(data.user);
695
+ if (typeof window !== "undefined") {
696
+ window.history.replaceState(null, "", "/invite");
697
+ }
698
+ navigate(redirectTo, { replace: true });
699
+ } catch (err) {
700
+ const eObj = err;
701
+ setError(formatApiErrorDetail(eObj?.response?.data?.detail) || eObj?.message || t("The action failed."));
702
+ } finally {
703
+ setBusy(false);
704
+ }
705
+ };
706
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AuthLayout, { legalUrl, brand, lang, onLangChange, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "space-y-4", "data-testid": "invite-page", children: [
707
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
708
+ AuthHeader,
709
+ {
710
+ eyebrow: info?.email,
711
+ title: welcomeTitle,
712
+ subtitle: t("Choose your password to finish the invitation.")
713
+ }
714
+ ),
715
+ invalid && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AuthMessage, { kind: "error", testId: "invite-invalid", children: t("This invitation is no longer valid. Ask an administrator for a new one.") }),
716
+ !invalid && !info && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react2.Loader2, { className: "w-5 h-5 animate-spin text-primary" }),
717
+ info && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("form", { onSubmit: submit, className: "space-y-3", children: [
718
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "block", children: [
719
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: LABEL_CLASS2, children: t("New password") }),
720
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
721
+ "input",
722
+ {
723
+ type: "password",
724
+ autoComplete: "new-password",
725
+ className: FIELD_CLASS2,
726
+ value: pw,
727
+ onChange: (e) => setPw(e.target.value),
728
+ "data-testid": "invite-password"
729
+ }
730
+ )
731
+ ] }),
732
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "block", children: [
733
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: LABEL_CLASS2, children: t("Repeat password") }),
734
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
735
+ "input",
736
+ {
737
+ type: "password",
738
+ autoComplete: "new-password",
739
+ className: FIELD_CLASS2,
740
+ value: pw2,
741
+ onChange: (e) => setPw2(e.target.value),
742
+ "data-testid": "invite-password2"
743
+ }
744
+ )
745
+ ] }),
746
+ error && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AuthMessage, { kind: "error", testId: "invite-error", children: error }),
747
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
748
+ "button",
749
+ {
750
+ type: "submit",
751
+ disabled: busy,
752
+ "data-testid": "invite-submit",
753
+ className: "w-full h-11 flex items-center justify-center gap-2 bg-primary text-primary-foreground rounded-sm text-sm font-bold uppercase tracking-wider hover:bg-primary/90 disabled:opacity-60",
754
+ children: [
755
+ busy && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react2.Loader2, { className: "w-4 h-4 animate-spin" }),
756
+ t("Save password and sign in")
757
+ ]
758
+ }
759
+ )
760
+ ] })
761
+ ] }) });
762
+ }
763
+
764
+ // src/app-kit/ScalioAuditPages.tsx
765
+ var import_react9 = require("react");
766
+ var import_react_router_dom4 = require("react-router-dom");
767
+ var import_sonner5 = require("sonner");
768
+ var import_jsx_runtime7 = require("react/jsx-runtime");
769
+ var defaultNotify2 = (text, tone) => {
770
+ if (tone === "error") import_sonner5.toast.error(text);
771
+ else import_sonner5.toast.success(text);
772
+ };
773
+ function ScalioAuditHeader({ lang, t }) {
774
+ const L = labelsFor(lang);
775
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "space-y-3", children: [
776
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(PageHeader, { title: L.auditLog, subtitle: t("Who changed what, and the background jobs of this installation") }),
777
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(AuditNav, { link: import_react_router_dom4.NavLink, lang })
778
+ ] });
779
+ }
780
+ function ScalioAuditPage({
781
+ api,
782
+ user,
783
+ lang,
784
+ t,
785
+ actionLabel,
786
+ storageKey
787
+ }) {
788
+ const client = (0, import_react9.useMemo)(() => auditApi(api), [api]);
789
+ if (!can(user, "audit.view")) return null;
790
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { "data-testid": "audit-page", className: "space-y-5", children: [
791
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ScalioAuditHeader, { lang, t }),
792
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(AuditLog, { client, lang, notify: defaultNotify2, actionLabel, storageKey })
793
+ ] });
794
+ }
795
+ function ScalioJobsPage({ api, user, lang, t, confirm }) {
796
+ const client = (0, import_react9.useMemo)(() => jobsApi(api), [api]);
797
+ if (!can(user, "audit.view")) return null;
798
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { "data-testid": "jobs-page", className: "space-y-5", children: [
799
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ScalioAuditHeader, { lang, t }),
800
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
801
+ JobsPanel,
802
+ {
803
+ client,
804
+ lang,
805
+ canRun: can(user, "jobs.run"),
806
+ link: import_react_router_dom4.Link,
807
+ confirm,
808
+ notify: defaultNotify2
809
+ }
810
+ )
811
+ ] });
812
+ }
813
+
814
+ // src/app-kit/ScalioSelfTestPage.tsx
815
+ var import_react10 = require("react");
816
+ var import_react_router_dom5 = require("react-router-dom");
817
+ var import_sonner6 = require("sonner");
818
+ var import_jsx_runtime8 = require("react/jsx-runtime");
819
+ function ScalioSelfTestPage({ api, user, lang, t }) {
820
+ const [on, setOn] = (0, import_react10.useState)(null);
821
+ const client = (0, import_react10.useMemo)(() => selftestApi(api), [api]);
822
+ (0, import_react10.useEffect)(() => {
823
+ api.get("/e2e/status").then((r) => setOn(Boolean(r.data?.enabled))).catch(() => setOn(false));
824
+ }, [api]);
825
+ if (user?.role !== "admin" || on === false) return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_router_dom5.Navigate, { to: "/", replace: true });
826
+ if (on === null) return null;
827
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { "data-testid": "selftest-page", className: "space-y-5", children: [
828
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(PageHeader, { eyebrow: t("Tests"), title: t("E2E self-check"), subtitle: t("Self-check of this test instance") }),
829
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
830
+ SelfTestPanel,
831
+ {
832
+ client,
833
+ lang,
834
+ notify: (text, tone) => tone === "error" ? import_sonner6.toast.error(text) : import_sonner6.toast.success(text)
835
+ }
836
+ )
837
+ ] });
838
+ }
839
+
840
+ // src/app-kit/ScalioBackupSection.tsx
841
+ var import_react11 = require("react");
842
+ var import_react_router_dom6 = require("react-router-dom");
843
+ var import_sonner7 = require("sonner");
844
+ var import_jsx_runtime9 = require("react/jsx-runtime");
845
+ var notify = (text, tone) => {
846
+ if (tone === "error") import_sonner7.toast.error(text);
847
+ else import_sonner7.toast.success(text);
848
+ };
849
+ function ScalioBackupSection({
850
+ api,
851
+ lang,
852
+ t,
853
+ onSignIn,
854
+ withDataOnLabel,
855
+ description,
856
+ accountTo = "/profile"
857
+ }) {
858
+ const client = (0, import_react11.useMemo)(() => backupApi(api), [api]);
859
+ const labels = (0, import_react11.useMemo)(
860
+ () => withDataOnLabel ? { backup: { withDataOn: withDataOnLabel } } : void 0,
861
+ [withDataOnLabel]
862
+ );
863
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
864
+ SettingsSection,
865
+ {
866
+ id: "backup",
867
+ title: t("Backup"),
868
+ testId: "backup-card",
869
+ description: description ?? t("Encrypted export and import, e.g. to move to another instance. After a move the tenants are connected again."),
870
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
871
+ BackupPanel,
872
+ {
873
+ client,
874
+ lang,
875
+ labels,
876
+ accountTo,
877
+ link: import_react_router_dom6.Link,
878
+ notify,
879
+ onSignIn
880
+ }
881
+ )
882
+ }
883
+ );
884
+ }
885
+ function ScalioMaintenanceBanner({ api, lang }) {
886
+ const client = (0, import_react11.useMemo)(() => backupApi(api), [api]);
887
+ const [on, setOn] = (0, import_react11.useState)(false);
888
+ (0, import_react11.useEffect)(() => {
889
+ const show = () => setOn(true);
890
+ window.addEventListener("scalio-maintenance", show);
891
+ return () => window.removeEventListener("scalio-maintenance", show);
892
+ }, []);
893
+ return on ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(MaintenanceNotice, { client, lang }) : null;
894
+ }
895
+
896
+ // src/app-kit/ScalioSaasUpdatesSection.tsx
897
+ var import_react12 = require("react");
898
+ var import_sonner8 = require("sonner");
899
+ var import_jsx_runtime10 = require("react/jsx-runtime");
900
+ function ScalioSaasUpdateBanner({ api, lang, onOpen }) {
901
+ const client = (0, import_react12.useMemo)(() => saasUpdatesApi(api), [api]);
902
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(UpdateBanner, { client, lang, onOpen });
903
+ }
904
+ function ScalioSaasUpdatesSection({
905
+ api,
906
+ lang,
907
+ t,
908
+ admin = true
909
+ }) {
910
+ const client = (0, import_react12.useMemo)(() => saasUpdatesApi(api), [api]);
911
+ const notify2 = (0, import_react12.useMemo)(
912
+ () => (msg, tone) => tone === "error" ? import_sonner8.toast.error(msg) : import_sonner8.toast.success(msg),
913
+ []
914
+ );
915
+ const [prerelease, setPrerelease] = (0, import_react12.useState)(false);
916
+ (0, import_react12.useEffect)(() => {
917
+ let alive = true;
918
+ client.state().then((d) => {
919
+ if (alive) setPrerelease(Boolean(d?.prerelease?.opt_in));
920
+ }).catch(() => {
921
+ });
922
+ return () => {
923
+ alive = false;
924
+ };
925
+ }, [client]);
926
+ const onPrereleaseChange = async (on, opts) => {
927
+ await api.put("/saas-updates/prerelease-error-reports", { enabled: Boolean(on && opts?.errorReports) });
928
+ const d = await client.act("prerelease", { enabled: Boolean(on) });
929
+ setPrerelease(d?.prerelease ? Boolean(d.prerelease.opt_in) : Boolean(on));
930
+ };
931
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
932
+ SettingsSection,
933
+ {
934
+ id: "updates",
935
+ title: t("Updates"),
936
+ description: t("New versions from Scalio, your maintenance window and the deadline"),
937
+ testId: "saas-updates-card",
938
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
939
+ SaasUpdatesPanel,
940
+ {
941
+ client,
942
+ lang,
943
+ notify: notify2,
944
+ admin,
945
+ prerelease,
946
+ onPrereleaseChange
947
+ }
948
+ )
949
+ }
950
+ );
951
+ }
952
+
953
+ // src/app-kit/ScalioSupportCard.tsx
954
+ var import_react13 = require("react");
955
+ var import_jsx_runtime11 = require("react/jsx-runtime");
956
+ function ScalioSupportCard({ api, lang, t }) {
957
+ const client = (0, import_react13.useMemo)(() => supportApi(api), [api]);
958
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SettingsSection, { id: "support", title: t("Support connection"), testId: "support-connection-card", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SupportConnection, { client, lang }) });
959
+ }
960
+
961
+ // src/app-kit/ScalioMailSettings.tsx
962
+ var import_react14 = require("react");
963
+ var import_sonner9 = require("sonner");
964
+ var import_jsx_runtime12 = require("react/jsx-runtime");
965
+ var defaultNotify3 = (text, tone) => {
966
+ if (tone === "error") import_sonner9.toast.error(text);
967
+ else import_sonner9.toast.success(text);
968
+ };
969
+ function ScalioMailSettings({
970
+ api,
971
+ lang,
972
+ formatApiErrorDetail
973
+ }) {
974
+ const client = (0, import_react14.useMemo)(() => mailApi(api), [api]);
975
+ const formatError = (e) => {
976
+ const err = e;
977
+ return formatApiErrorDetail(err?.response?.data?.detail) || err?.message || "";
978
+ };
979
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(MailTransport, { client, lang, notify: defaultNotify3, formatError });
980
+ }
981
+
982
+ // src/app-kit/ScalioLicensePanel.tsx
983
+ var import_react15 = require("react");
984
+ var import_sonner10 = require("sonner");
985
+ var import_jsx_runtime13 = require("react/jsx-runtime");
986
+ var defaultNotify4 = (text, tone) => {
987
+ if (tone === "error") import_sonner10.toast.error(text);
988
+ else import_sonner10.toast.success(text);
989
+ };
990
+ function ScalioLicensePanel({
991
+ api,
992
+ product,
993
+ lang,
994
+ kindLabel,
995
+ featureLabel,
996
+ confirm,
997
+ formatApiErrorDetail,
998
+ noFeatures
999
+ }) {
1000
+ const client = (0, import_react15.useMemo)(() => licenseApi(api), [api]);
1001
+ const formatError = (e) => {
1002
+ const err = e;
1003
+ return formatApiErrorDetail(err?.response?.data?.detail) || err?.message || "";
1004
+ };
1005
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1006
+ LicensePanel,
1007
+ {
1008
+ client,
1009
+ lang,
1010
+ product,
1011
+ kindLabel,
1012
+ featureLabel,
1013
+ noFeatures,
1014
+ notify: defaultNotify4,
1015
+ confirm,
1016
+ formatError
1017
+ }
1018
+ );
1019
+ }
1020
+
1021
+ // src/app-kit/ScalioFactoryReset.tsx
1022
+ var import_react16 = require("react");
1023
+ var import_react_router_dom7 = require("react-router-dom");
1024
+ var import_sonner11 = require("sonner");
1025
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1026
+ var defaultNotify5 = (text, tone) => {
1027
+ if (tone === "error") import_sonner11.toast.error(text);
1028
+ else import_sonner11.toast.success(text);
1029
+ };
1030
+ function ScalioFactoryReset({
1031
+ api,
1032
+ lang,
1033
+ formatApiErrorDetail,
1034
+ accountTo = "/profile",
1035
+ backupTo = "/settings/backup"
1036
+ }) {
1037
+ const client = (0, import_react16.useMemo)(() => factoryResetApi(api), [api]);
1038
+ const formatError = (e) => {
1039
+ const err = e;
1040
+ return formatApiErrorDetail(err?.response?.data?.detail) || err?.message || "";
1041
+ };
1042
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1043
+ FactoryReset,
1044
+ {
1045
+ client,
1046
+ lang,
1047
+ accountTo,
1048
+ backupTo,
1049
+ link: import_react_router_dom7.Link,
1050
+ notify: defaultNotify5,
1051
+ formatError
1052
+ }
1053
+ );
1054
+ }
1055
+
1056
+ // src/app-kit/ScalioRoleTenants.tsx
1057
+ var import_react17 = require("react");
1058
+ var import_sonner12 = require("sonner");
1059
+ var import_jsx_runtime15 = require("react/jsx-runtime");
1060
+ var defaultNotify6 = (text, tone) => {
1061
+ if (tone === "error") import_sonner12.toast.error(text);
1062
+ else import_sonner12.toast.success(text);
1063
+ };
1064
+ function ScalioRoleTenants({
1065
+ api,
1066
+ apiBaseUrl,
1067
+ lang,
1068
+ t,
1069
+ confirm,
1070
+ formatApiErrorDetail,
1071
+ onChange
1072
+ }) {
1073
+ const [source, setSource] = (0, import_react17.useState)(null);
1074
+ const [ssoOn, setSsoOn] = (0, import_react17.useState)(false);
1075
+ const load = (0, import_react17.useCallback)(() => {
1076
+ api.get("/users/role-source").then((r) => setSource(r.data)).catch(() => setSource(null));
1077
+ api.get("/auth/scalio/status").then((r) => setSsoOn(Boolean(r.data?.enabled))).catch(() => setSsoOn(false));
1078
+ }, [api]);
1079
+ (0, import_react17.useEffect)(() => {
1080
+ load();
1081
+ }, [load]);
1082
+ if (!source) return null;
1083
+ const save = async ({ source: value, tenants }) => {
1084
+ await api.put("/users/role-source", { source: value, tenants });
1085
+ load();
1086
+ onChange?.();
1087
+ };
1088
+ const formatError = (e) => {
1089
+ const err = e;
1090
+ return err?.response?.data?.detail ? formatApiErrorDetail(err.response.data.detail) : t("The action failed.");
1091
+ };
1092
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "bg-card border border-border rounded-sm px-4 py-3", "data-testid": "role-tenants", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1093
+ RoleSourceSettings,
1094
+ {
1095
+ lang,
1096
+ tenants: true,
1097
+ confirm,
1098
+ onSave: save,
1099
+ consentUrl: ssoOn ? `${apiBaseUrl}/auth/scalio/consent` : void 0,
1100
+ value: { source: source.source, values: source.values, tenants: source.tenants },
1101
+ notify: defaultNotify6,
1102
+ formatError
1103
+ }
1104
+ ) });
1105
+ }
1106
+ // Annotate the CommonJS export names for ESM import in node:
1107
+ 0 && (module.exports = {
1108
+ ScalioAuditHeader,
1109
+ ScalioAuditPage,
1110
+ ScalioBackupSection,
1111
+ ScalioFactoryReset,
1112
+ ScalioInvitePage,
1113
+ ScalioJobsPage,
1114
+ ScalioLicensePanel,
1115
+ ScalioLoginPage,
1116
+ ScalioMailSettings,
1117
+ ScalioMaintenanceBanner,
1118
+ ScalioPasswordChangePage,
1119
+ ScalioProfilePage,
1120
+ ScalioRoleTenants,
1121
+ ScalioSaasUpdateBanner,
1122
+ ScalioSaasUpdatesSection,
1123
+ ScalioSecurityFactors,
1124
+ ScalioSelfTestPage,
1125
+ ScalioSupportCard,
1126
+ ScalioUsersPage
1127
+ });
1128
+ //# sourceMappingURL=index.js.map