@nocios/crudify-ui 3.0.20 → 3.0.22

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.
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@ import { default as default2 } from "@nocios/crudify-browser";
3
3
  export * from "@nocios/crudify-browser";
4
4
 
5
5
  // src/components/CrudifyLogin/index.tsx
6
- import { Box as Box6, Typography as Typography6 } from "@mui/material";
6
+ import { Box as Box7, Typography as Typography6 } from "@mui/material";
7
7
 
8
8
  // src/components/CrudifyLogin/context/I18nProvider.tsx
9
9
  import { createContext, useContext, useMemo } from "react";
@@ -391,7 +391,7 @@ var useLoginState = () => {
391
391
  };
392
392
 
393
393
  // src/providers/SessionProvider.tsx
394
- import { createContext as createContext4, useContext as useContext4, useMemo as useMemo2 } from "react";
394
+ import { createContext as createContext5, useContext as useContext5, useMemo as useMemo2 } from "react";
395
395
 
396
396
  // src/hooks/useSession.ts
397
397
  import { useState as useState3, useEffect as useEffect4, useCallback } from "react";
@@ -1047,10 +1047,147 @@ var isTokenExpired = (token) => {
1047
1047
  }
1048
1048
  };
1049
1049
 
1050
+ // src/components/GlobalNotificationProvider.tsx
1051
+ import { useState as useState4, createContext as createContext4, useContext as useContext4, useCallback as useCallback2, useEffect as useEffect5 } from "react";
1052
+ import { Snackbar, Alert, Box, Portal } from "@mui/material";
1053
+ import { v4 as uuidv4 } from "uuid";
1054
+ import { jsx as jsx4, jsxs } from "react/jsx-runtime";
1055
+ var GlobalNotificationContext = createContext4(null);
1056
+ var GlobalNotificationProvider = ({
1057
+ children,
1058
+ maxNotifications = 5,
1059
+ defaultAutoHideDuration = 6e3,
1060
+ position = { vertical: "top", horizontal: "right" },
1061
+ enabled = false
1062
+ // ✅ Por defecto DESACTIVADO
1063
+ }) => {
1064
+ const [notifications, setNotifications] = useState4([]);
1065
+ const showNotification = useCallback2(
1066
+ (message, severity = "info", options) => {
1067
+ if (!enabled) {
1068
+ return "";
1069
+ }
1070
+ const id = uuidv4();
1071
+ const newNotification = {
1072
+ id,
1073
+ message,
1074
+ severity,
1075
+ autoHideDuration: options?.autoHideDuration ?? defaultAutoHideDuration,
1076
+ persistent: options?.persistent ?? false
1077
+ };
1078
+ setNotifications((prev) => {
1079
+ const updatedNotifications = prev.length >= maxNotifications ? prev.slice(-(maxNotifications - 1)) : prev;
1080
+ return [...updatedNotifications, newNotification];
1081
+ });
1082
+ return id;
1083
+ },
1084
+ [maxNotifications, defaultAutoHideDuration, enabled]
1085
+ );
1086
+ const hideNotification = useCallback2((id) => {
1087
+ setNotifications((prev) => prev.filter((notification) => notification.id !== id));
1088
+ }, []);
1089
+ const clearAllNotifications = useCallback2(() => {
1090
+ setNotifications([]);
1091
+ }, []);
1092
+ const value = {
1093
+ showNotification,
1094
+ hideNotification,
1095
+ clearAllNotifications
1096
+ };
1097
+ return /* @__PURE__ */ jsxs(GlobalNotificationContext.Provider, { value, children: [
1098
+ children,
1099
+ enabled && /* @__PURE__ */ jsx4(Portal, { children: /* @__PURE__ */ jsx4(
1100
+ Box,
1101
+ {
1102
+ sx: {
1103
+ position: "fixed",
1104
+ zIndex: 9999,
1105
+ [position.vertical]: position.vertical === "top" ? 24 : 24,
1106
+ [position.horizontal]: position.horizontal === "right" ? 24 : position.horizontal === "left" ? 24 : "50%",
1107
+ ...position.horizontal === "center" && {
1108
+ transform: "translateX(-50%)"
1109
+ },
1110
+ display: "flex",
1111
+ flexDirection: position.vertical === "top" ? "column" : "column-reverse",
1112
+ gap: 1,
1113
+ maxWidth: "400px",
1114
+ width: "auto"
1115
+ },
1116
+ children: notifications.map((notification) => /* @__PURE__ */ jsx4(NotificationItem, { notification, onClose: () => hideNotification(notification.id) }, notification.id))
1117
+ }
1118
+ ) })
1119
+ ] });
1120
+ };
1121
+ var NotificationItem = ({ notification, onClose }) => {
1122
+ const [open, setOpen] = useState4(true);
1123
+ const handleClose = useCallback2(
1124
+ (_event, reason) => {
1125
+ if (reason === "clickaway") return;
1126
+ setOpen(false);
1127
+ setTimeout(onClose, 300);
1128
+ },
1129
+ [onClose]
1130
+ );
1131
+ useEffect5(() => {
1132
+ if (!notification.persistent && notification.autoHideDuration) {
1133
+ const timer = setTimeout(() => {
1134
+ handleClose();
1135
+ }, notification.autoHideDuration);
1136
+ return () => clearTimeout(timer);
1137
+ }
1138
+ }, [notification.autoHideDuration, notification.persistent, handleClose]);
1139
+ return /* @__PURE__ */ jsx4(
1140
+ Snackbar,
1141
+ {
1142
+ open,
1143
+ onClose: handleClose,
1144
+ sx: {
1145
+ position: "relative",
1146
+ "& .MuiSnackbarContent-root": {
1147
+ minWidth: "auto"
1148
+ }
1149
+ },
1150
+ TransitionProps: {
1151
+ enter: true,
1152
+ exit: true
1153
+ },
1154
+ children: /* @__PURE__ */ jsx4(
1155
+ Alert,
1156
+ {
1157
+ variant: "filled",
1158
+ severity: notification.severity,
1159
+ onClose: handleClose,
1160
+ sx: {
1161
+ width: "100%",
1162
+ minWidth: "280px",
1163
+ maxWidth: "400px",
1164
+ wordBreak: "break-word"
1165
+ },
1166
+ children: /* @__PURE__ */ jsx4("span", { dangerouslySetInnerHTML: { __html: notification.message } })
1167
+ }
1168
+ )
1169
+ }
1170
+ );
1171
+ };
1172
+ var useGlobalNotification = () => {
1173
+ const context = useContext4(GlobalNotificationContext);
1174
+ if (!context) {
1175
+ throw new Error("useGlobalNotification debe ser usado dentro de un GlobalNotificationProvider");
1176
+ }
1177
+ return context;
1178
+ };
1179
+
1050
1180
  // src/providers/SessionProvider.tsx
1051
- import { Fragment, jsx as jsx4, jsxs } from "react/jsx-runtime";
1052
- var SessionContext = createContext4(void 0);
1053
- function SessionProvider({ children, options = {}, config: propConfig }) {
1181
+ import { Fragment, jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
1182
+ var SessionContext = createContext5(void 0);
1183
+ function SessionProvider({
1184
+ children,
1185
+ options = {},
1186
+ config: propConfig,
1187
+ showNotifications = false,
1188
+ // ✅ Por defecto DESACTIVADO
1189
+ notificationOptions = {}
1190
+ }) {
1054
1191
  const sessionHook = useSession(options);
1055
1192
  const resolvedConfig = useMemo2(() => {
1056
1193
  let publicApiKey;
@@ -1143,35 +1280,41 @@ function SessionProvider({ children, options = {}, config: propConfig }) {
1143
1280
  sessionData,
1144
1281
  config: resolvedConfig
1145
1282
  };
1146
- return /* @__PURE__ */ jsx4(SessionContext.Provider, { value: contextValue, children });
1283
+ const notificationConfig = {
1284
+ enabled: showNotifications,
1285
+ maxNotifications: notificationOptions.maxNotifications || 5,
1286
+ defaultAutoHideDuration: notificationOptions.defaultAutoHideDuration || 6e3,
1287
+ position: notificationOptions.position || { vertical: "top", horizontal: "right" }
1288
+ };
1289
+ return /* @__PURE__ */ jsx5(GlobalNotificationProvider, { ...notificationConfig, children: /* @__PURE__ */ jsx5(SessionContext.Provider, { value: contextValue, children }) });
1147
1290
  }
1148
1291
  function useSessionContext() {
1149
- const context = useContext4(SessionContext);
1292
+ const context = useContext5(SessionContext);
1150
1293
  if (context === void 0) {
1151
1294
  throw new Error("useSessionContext must be used within a SessionProvider");
1152
1295
  }
1153
1296
  return context;
1154
1297
  }
1155
- function ProtectedRoute({ children, fallback = /* @__PURE__ */ jsx4("div", { children: "Please log in to access this content" }), redirectTo }) {
1298
+ function ProtectedRoute({ children, fallback = /* @__PURE__ */ jsx5("div", { children: "Please log in to access this content" }), redirectTo }) {
1156
1299
  const { isAuthenticated, isLoading, isInitialized } = useSessionContext();
1157
1300
  if (!isInitialized || isLoading) {
1158
- return /* @__PURE__ */ jsx4("div", { children: "Loading..." });
1301
+ return /* @__PURE__ */ jsx5("div", { children: "Loading..." });
1159
1302
  }
1160
1303
  if (!isAuthenticated) {
1161
1304
  if (redirectTo) {
1162
1305
  redirectTo();
1163
1306
  return null;
1164
1307
  }
1165
- return /* @__PURE__ */ jsx4(Fragment, { children: fallback });
1308
+ return /* @__PURE__ */ jsx5(Fragment, { children: fallback });
1166
1309
  }
1167
- return /* @__PURE__ */ jsx4(Fragment, { children });
1310
+ return /* @__PURE__ */ jsx5(Fragment, { children });
1168
1311
  }
1169
1312
  function SessionDebugInfo() {
1170
1313
  const session = useSessionContext();
1171
1314
  if (!session.isInitialized) {
1172
- return /* @__PURE__ */ jsx4("div", { children: "Session not initialized" });
1315
+ return /* @__PURE__ */ jsx5("div", { children: "Session not initialized" });
1173
1316
  }
1174
- return /* @__PURE__ */ jsxs(
1317
+ return /* @__PURE__ */ jsxs2(
1175
1318
  "div",
1176
1319
  {
1177
1320
  style: {
@@ -1183,49 +1326,49 @@ function SessionDebugInfo() {
1183
1326
  fontFamily: "monospace"
1184
1327
  },
1185
1328
  children: [
1186
- /* @__PURE__ */ jsx4("h4", { children: "Session Debug Info" }),
1187
- /* @__PURE__ */ jsxs("div", { children: [
1188
- /* @__PURE__ */ jsx4("strong", { children: "Authenticated:" }),
1329
+ /* @__PURE__ */ jsx5("h4", { children: "Session Debug Info" }),
1330
+ /* @__PURE__ */ jsxs2("div", { children: [
1331
+ /* @__PURE__ */ jsx5("strong", { children: "Authenticated:" }),
1189
1332
  " ",
1190
1333
  session.isAuthenticated ? "Yes" : "No"
1191
1334
  ] }),
1192
- /* @__PURE__ */ jsxs("div", { children: [
1193
- /* @__PURE__ */ jsx4("strong", { children: "Loading:" }),
1335
+ /* @__PURE__ */ jsxs2("div", { children: [
1336
+ /* @__PURE__ */ jsx5("strong", { children: "Loading:" }),
1194
1337
  " ",
1195
1338
  session.isLoading ? "Yes" : "No"
1196
1339
  ] }),
1197
- /* @__PURE__ */ jsxs("div", { children: [
1198
- /* @__PURE__ */ jsx4("strong", { children: "Error:" }),
1340
+ /* @__PURE__ */ jsxs2("div", { children: [
1341
+ /* @__PURE__ */ jsx5("strong", { children: "Error:" }),
1199
1342
  " ",
1200
1343
  session.error || "None"
1201
1344
  ] }),
1202
- session.tokens && /* @__PURE__ */ jsxs(Fragment, { children: [
1203
- /* @__PURE__ */ jsxs("div", { children: [
1204
- /* @__PURE__ */ jsx4("strong", { children: "Access Token:" }),
1345
+ session.tokens && /* @__PURE__ */ jsxs2(Fragment, { children: [
1346
+ /* @__PURE__ */ jsxs2("div", { children: [
1347
+ /* @__PURE__ */ jsx5("strong", { children: "Access Token:" }),
1205
1348
  " ",
1206
1349
  session.tokens.accessToken.substring(0, 20),
1207
1350
  "..."
1208
1351
  ] }),
1209
- /* @__PURE__ */ jsxs("div", { children: [
1210
- /* @__PURE__ */ jsx4("strong", { children: "Refresh Token:" }),
1352
+ /* @__PURE__ */ jsxs2("div", { children: [
1353
+ /* @__PURE__ */ jsx5("strong", { children: "Refresh Token:" }),
1211
1354
  " ",
1212
1355
  session.tokens.refreshToken.substring(0, 20),
1213
1356
  "..."
1214
1357
  ] }),
1215
- /* @__PURE__ */ jsxs("div", { children: [
1216
- /* @__PURE__ */ jsx4("strong", { children: "Access Expires In:" }),
1358
+ /* @__PURE__ */ jsxs2("div", { children: [
1359
+ /* @__PURE__ */ jsx5("strong", { children: "Access Expires In:" }),
1217
1360
  " ",
1218
1361
  Math.round(session.expiresIn / 1e3 / 60),
1219
1362
  " minutes"
1220
1363
  ] }),
1221
- /* @__PURE__ */ jsxs("div", { children: [
1222
- /* @__PURE__ */ jsx4("strong", { children: "Refresh Expires In:" }),
1364
+ /* @__PURE__ */ jsxs2("div", { children: [
1365
+ /* @__PURE__ */ jsx5("strong", { children: "Refresh Expires In:" }),
1223
1366
  " ",
1224
1367
  Math.round(session.refreshExpiresIn / 1e3 / 60 / 60),
1225
1368
  " hours"
1226
1369
  ] }),
1227
- /* @__PURE__ */ jsxs("div", { children: [
1228
- /* @__PURE__ */ jsx4("strong", { children: "Expiring Soon:" }),
1370
+ /* @__PURE__ */ jsxs2("div", { children: [
1371
+ /* @__PURE__ */ jsx5("strong", { children: "Expiring Soon:" }),
1229
1372
  " ",
1230
1373
  session.isExpiringSoon ? "Yes" : "No"
1231
1374
  ] })
@@ -1236,8 +1379,8 @@ function SessionDebugInfo() {
1236
1379
  }
1237
1380
 
1238
1381
  // src/components/CrudifyLogin/Forms/LoginForm.tsx
1239
- import { useEffect as useEffect5, useRef } from "react";
1240
- import { Typography, TextField, Button, Box, CircularProgress, Alert, Link } from "@mui/material";
1382
+ import { useEffect as useEffect6, useRef } from "react";
1383
+ import { Typography, TextField, Button, Box as Box2, CircularProgress, Alert as Alert2, Link } from "@mui/material";
1241
1384
 
1242
1385
  // src/utils/errorHandler.ts
1243
1386
  var ERROR_CODES = {
@@ -1509,14 +1652,158 @@ function handleCrudifyError(error) {
1509
1652
  ];
1510
1653
  }
1511
1654
 
1655
+ // src/utils/errorTranslation.ts
1656
+ var ERROR_TRANSLATION_HIERARCHY = [
1657
+ "errors.{category}.{code}",
1658
+ // errors.auth.INVALID_CREDENTIALS
1659
+ "errors.{code}",
1660
+ // errors.INVALID_CREDENTIALS
1661
+ "login.{code}",
1662
+ // login.INVALID_CREDENTIALS (legacy)
1663
+ "error.{code}",
1664
+ // error.INVALID_CREDENTIALS (singular)
1665
+ "messages.{code}",
1666
+ // messages.INVALID_CREDENTIALS
1667
+ "{code}"
1668
+ // INVALID_CREDENTIALS (direct)
1669
+ ];
1670
+ var ERROR_CATEGORY_MAP = {
1671
+ // Authentication errors
1672
+ "INVALID_CREDENTIALS": "auth",
1673
+ "UNAUTHORIZED": "auth",
1674
+ "INVALID_API_KEY": "auth",
1675
+ "USER_NOT_FOUND": "auth",
1676
+ "USER_NOT_ACTIVE": "auth",
1677
+ "NO_PERMISSION": "auth",
1678
+ "SESSION_EXPIRED": "auth",
1679
+ // Data errors
1680
+ "ITEM_NOT_FOUND": "data",
1681
+ "NOT_FOUND": "data",
1682
+ "IN_USE": "data",
1683
+ "DUPLICATE_ENTRY": "data",
1684
+ // Validation errors
1685
+ "FIELD_ERROR": "validation",
1686
+ "BAD_REQUEST": "validation",
1687
+ "INVALID_EMAIL": "validation",
1688
+ "INVALID_CODE": "validation",
1689
+ "REQUIRED_FIELD": "validation",
1690
+ // System errors
1691
+ "INTERNAL_SERVER_ERROR": "system",
1692
+ "DATABASE_CONNECTION_ERROR": "system",
1693
+ "INVALID_CONFIGURATION": "system",
1694
+ "UNKNOWN_OPERATION": "system",
1695
+ "TIMEOUT_ERROR": "system",
1696
+ "NETWORK_ERROR": "system",
1697
+ // Rate limiting
1698
+ "TOO_MANY_REQUESTS": "rate_limit"
1699
+ };
1700
+ var DEFAULT_ERROR_MESSAGES = {
1701
+ "INVALID_CREDENTIALS": "Invalid username or password",
1702
+ "UNAUTHORIZED": "You are not authorized to perform this action",
1703
+ "USER_NOT_FOUND": "User not found",
1704
+ "ITEM_NOT_FOUND": "Item not found",
1705
+ "FIELD_ERROR": "Invalid field value",
1706
+ "INTERNAL_SERVER_ERROR": "An internal error occurred",
1707
+ "NETWORK_ERROR": "Network connection error",
1708
+ "TIMEOUT_ERROR": "Request timeout",
1709
+ "UNKNOWN_OPERATION": "Unknown operation",
1710
+ "INVALID_EMAIL": "Invalid email format",
1711
+ "INVALID_CODE": "Invalid code",
1712
+ "TOO_MANY_REQUESTS": "Too many requests, please try again later"
1713
+ };
1714
+ function translateErrorCode(errorCode, config) {
1715
+ const { translateFn, currentLanguage, enableDebug } = config;
1716
+ if (enableDebug) {
1717
+ console.log(`\u{1F50D} [ErrorTranslation] Translating error code: ${errorCode} (lang: ${currentLanguage || "unknown"})`);
1718
+ }
1719
+ const normalizedCode = errorCode.toUpperCase();
1720
+ const category = ERROR_CATEGORY_MAP[normalizedCode];
1721
+ const translationKeys = ERROR_TRANSLATION_HIERARCHY.map((pattern) => {
1722
+ return pattern.replace("{category}", category || "general").replace("{code}", normalizedCode);
1723
+ });
1724
+ if (enableDebug) {
1725
+ console.log(`\u{1F511} [ErrorTranslation] Searching keys:`, translationKeys);
1726
+ }
1727
+ for (const key of translationKeys) {
1728
+ const translated = translateFn(key);
1729
+ if (translated && translated !== key) {
1730
+ if (enableDebug) {
1731
+ console.log(`\u2705 [ErrorTranslation] Found translation at key: ${key} = "${translated}"`);
1732
+ }
1733
+ return translated;
1734
+ }
1735
+ }
1736
+ const defaultMessage = DEFAULT_ERROR_MESSAGES[normalizedCode];
1737
+ if (defaultMessage) {
1738
+ if (enableDebug) {
1739
+ console.log(`\u{1F504} [ErrorTranslation] Using default message: "${defaultMessage}"`);
1740
+ }
1741
+ return defaultMessage;
1742
+ }
1743
+ const friendlyCode = normalizedCode.replace(/_/g, " ").toLowerCase().replace(/\b\w/g, (l) => l.toUpperCase());
1744
+ if (enableDebug) {
1745
+ console.log(`\u26A0\uFE0F [ErrorTranslation] No translation found, using friendly code: "${friendlyCode}"`);
1746
+ }
1747
+ return friendlyCode;
1748
+ }
1749
+ function translateErrorCodes(errorCodes, config) {
1750
+ return errorCodes.map((code) => translateErrorCode(code, config));
1751
+ }
1752
+ function translateError(error, config) {
1753
+ const { enableDebug } = config;
1754
+ if (enableDebug) {
1755
+ console.log(`\u{1F50D} [ErrorTranslation] Translating error:`, error);
1756
+ }
1757
+ if (error.message && !error.message.includes("Error:") && error.message.length > 0) {
1758
+ if (enableDebug) {
1759
+ console.log(`\u2705 [ErrorTranslation] Using API message: "${error.message}"`);
1760
+ }
1761
+ return error.message;
1762
+ }
1763
+ const translatedCode = translateErrorCode(error.code, config);
1764
+ if (error.field) {
1765
+ return `${error.field}: ${translatedCode}`;
1766
+ }
1767
+ return translatedCode;
1768
+ }
1769
+ function createErrorTranslator(translateFn, options = {}) {
1770
+ const config = {
1771
+ translateFn,
1772
+ currentLanguage: options.currentLanguage,
1773
+ enableDebug: options.enableDebug || false
1774
+ };
1775
+ return {
1776
+ translateErrorCode: (code) => translateErrorCode(code, config),
1777
+ translateErrorCodes: (codes) => translateErrorCodes(codes, config),
1778
+ translateError: (error) => translateError(error, config),
1779
+ // Método de conveniencia para errores de API
1780
+ translateApiError: (apiResponse) => {
1781
+ if (apiResponse?.data?.response?.status) {
1782
+ return translateErrorCode(apiResponse.data.response.status, config);
1783
+ }
1784
+ if (apiResponse?.status) {
1785
+ return translateErrorCode(apiResponse.status, config);
1786
+ }
1787
+ if (apiResponse?.code) {
1788
+ return translateErrorCode(apiResponse.code, config);
1789
+ }
1790
+ return "Unknown error";
1791
+ }
1792
+ };
1793
+ }
1794
+
1512
1795
  // src/components/CrudifyLogin/Forms/LoginForm.tsx
1513
- import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
1796
+ import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
1514
1797
  var LoginForm = ({ onScreenChange, onExternalNavigate, onLoginSuccess, onError, redirectUrl = "/" }) => {
1515
- const { crudify: crudify6 } = useCrudify();
1798
+ const { crudify: crudify7 } = useCrudify();
1516
1799
  const { state, updateFormData, setFieldError, clearErrors, setLoading } = useLoginState();
1517
1800
  const { login: sessionLogin } = useSessionContext();
1518
- const { t } = useTranslation();
1801
+ const { t, i18n } = useTranslation();
1519
1802
  const usernameInputRef = useRef(null);
1803
+ const errorTranslator = createErrorTranslator(t, {
1804
+ currentLanguage: i18n?.language,
1805
+ enableDebug: process.env.NODE_ENV === "development"
1806
+ });
1520
1807
  const getRedirectUrl = () => {
1521
1808
  if (state.searchParams.redirect) {
1522
1809
  try {
@@ -1529,27 +1816,18 @@ var LoginForm = ({ onScreenChange, onExternalNavigate, onLoginSuccess, onError,
1529
1816
  }
1530
1817
  return redirectUrl || "/";
1531
1818
  };
1532
- useEffect5(() => {
1819
+ useEffect6(() => {
1533
1820
  const timer = setTimeout(() => {
1534
1821
  if (usernameInputRef.current) usernameInputRef.current.focus();
1535
1822
  }, 100);
1536
1823
  return () => clearTimeout(timer);
1537
1824
  }, []);
1538
- const translateError = (parsedError) => {
1539
- const possibleKeys = [
1540
- `errors.auth.${parsedError.code}`,
1541
- `errors.data.${parsedError.code}`,
1542
- `errors.system.${parsedError.code}`,
1543
- `errors.${parsedError.code}`,
1544
- `login.${parsedError.code.toLowerCase()}`
1545
- ];
1546
- for (const key of possibleKeys) {
1547
- const translated = t(key);
1548
- if (translated !== key) {
1549
- return translated;
1550
- }
1551
- }
1552
- return parsedError.message || t("error.unknown");
1825
+ const translateError2 = (parsedError) => {
1826
+ return errorTranslator.translateError({
1827
+ code: parsedError.code,
1828
+ message: parsedError.message,
1829
+ field: parsedError.field
1830
+ });
1553
1831
  };
1554
1832
  const handleLogin = async () => {
1555
1833
  if (state.loading) return;
@@ -1579,7 +1857,7 @@ var LoginForm = ({ onScreenChange, onExternalNavigate, onLoginSuccess, onError,
1579
1857
  } catch (error) {
1580
1858
  setLoading(false);
1581
1859
  const parsedErrors = handleCrudifyError(error);
1582
- const translatedErrors = parsedErrors.map(translateError);
1860
+ const translatedErrors = parsedErrors.map(translateError2);
1583
1861
  setFieldError("global", translatedErrors);
1584
1862
  if (onError) {
1585
1863
  onError(translatedErrors.join(", "));
@@ -1590,10 +1868,10 @@ var LoginForm = ({ onScreenChange, onExternalNavigate, onLoginSuccess, onError,
1590
1868
  const parsedErrors = handleCrudifyError(response);
1591
1869
  parsedErrors.forEach((error) => {
1592
1870
  if (error.field) {
1593
- setFieldError(error.field, translateError(error));
1871
+ setFieldError(error.field, translateError2(error));
1594
1872
  } else {
1595
1873
  const currentGlobalErrors = state.errors.global || [];
1596
- setFieldError("global", [...currentGlobalErrors, translateError(error)]);
1874
+ setFieldError("global", [...currentGlobalErrors, translateError2(error)]);
1597
1875
  }
1598
1876
  });
1599
1877
  };
@@ -1607,9 +1885,9 @@ var LoginForm = ({ onScreenChange, onExternalNavigate, onLoginSuccess, onError,
1607
1885
  handleLogin();
1608
1886
  }
1609
1887
  };
1610
- return /* @__PURE__ */ jsxs2(Fragment2, { children: [
1611
- /* @__PURE__ */ jsxs2(
1612
- Box,
1888
+ return /* @__PURE__ */ jsxs3(Fragment2, { children: [
1889
+ /* @__PURE__ */ jsxs3(
1890
+ Box2,
1613
1891
  {
1614
1892
  component: "form",
1615
1893
  noValidate: true,
@@ -1617,8 +1895,8 @@ var LoginForm = ({ onScreenChange, onExternalNavigate, onLoginSuccess, onError,
1617
1895
  onKeyDown: handleKeyDown,
1618
1896
  sx: { width: "100%", display: "flex", flexDirection: "column", gap: 2 },
1619
1897
  children: [
1620
- /* @__PURE__ */ jsxs2(Box, { sx: { mb: 1 }, children: [
1621
- /* @__PURE__ */ jsx5(
1898
+ /* @__PURE__ */ jsxs3(Box2, { sx: { mb: 1 }, children: [
1899
+ /* @__PURE__ */ jsx6(
1622
1900
  Typography,
1623
1901
  {
1624
1902
  variant: "body2",
@@ -1628,7 +1906,7 @@ var LoginForm = ({ onScreenChange, onExternalNavigate, onLoginSuccess, onError,
1628
1906
  children: t("login.usernameOrEmailLabel")
1629
1907
  }
1630
1908
  ),
1631
- /* @__PURE__ */ jsx5(
1909
+ /* @__PURE__ */ jsx6(
1632
1910
  TextField,
1633
1911
  {
1634
1912
  fullWidth: true,
@@ -1647,8 +1925,8 @@ var LoginForm = ({ onScreenChange, onExternalNavigate, onLoginSuccess, onError,
1647
1925
  }
1648
1926
  )
1649
1927
  ] }),
1650
- /* @__PURE__ */ jsxs2(Box, { sx: { mb: 1 }, children: [
1651
- /* @__PURE__ */ jsx5(
1928
+ /* @__PURE__ */ jsxs3(Box2, { sx: { mb: 1 }, children: [
1929
+ /* @__PURE__ */ jsx6(
1652
1930
  Typography,
1653
1931
  {
1654
1932
  variant: "body2",
@@ -1658,7 +1936,7 @@ var LoginForm = ({ onScreenChange, onExternalNavigate, onLoginSuccess, onError,
1658
1936
  children: t("login.passwordLabel")
1659
1937
  }
1660
1938
  ),
1661
- /* @__PURE__ */ jsx5(
1939
+ /* @__PURE__ */ jsx6(
1662
1940
  TextField,
1663
1941
  {
1664
1942
  fullWidth: true,
@@ -1676,7 +1954,7 @@ var LoginForm = ({ onScreenChange, onExternalNavigate, onLoginSuccess, onError,
1676
1954
  }
1677
1955
  )
1678
1956
  ] }),
1679
- state.config.loginActions?.includes("forgotPassword") && /* @__PURE__ */ jsx5(Box, { sx: { display: "flex", justifyContent: "flex-end", alignItems: "center" }, children: /* @__PURE__ */ jsx5(
1957
+ state.config.loginActions?.includes("forgotPassword") && /* @__PURE__ */ jsx6(Box2, { sx: { display: "flex", justifyContent: "flex-end", alignItems: "center" }, children: /* @__PURE__ */ jsx6(
1680
1958
  Link,
1681
1959
  {
1682
1960
  sx: { cursor: "pointer" },
@@ -1688,15 +1966,15 @@ var LoginForm = ({ onScreenChange, onExternalNavigate, onLoginSuccess, onError,
1688
1966
  children: t("login.forgotPasswordLink")
1689
1967
  }
1690
1968
  ) }),
1691
- /* @__PURE__ */ jsx5(Button, { disabled: state.loading, type: "submit", fullWidth: true, variant: "contained", color: "primary", sx: { mt: 1, mb: 2 }, children: state.loading ? /* @__PURE__ */ jsx5(CircularProgress, { size: 20 }) : t("login.loginButton") })
1969
+ /* @__PURE__ */ jsx6(Button, { disabled: state.loading, type: "submit", fullWidth: true, variant: "contained", color: "primary", sx: { mt: 1, mb: 2 }, children: state.loading ? /* @__PURE__ */ jsx6(CircularProgress, { size: 20 }) : t("login.loginButton") })
1692
1970
  ]
1693
1971
  }
1694
1972
  ),
1695
- /* @__PURE__ */ jsx5(Box, { children: state.errors.global && state.errors.global.length > 0 && state.errors.global.map((error, index) => /* @__PURE__ */ jsx5(Alert, { variant: "filled", sx: { mt: 2 }, severity: "error", children: /* @__PURE__ */ jsx5("div", { children: error }) }, index)) }),
1696
- state.config.loginActions?.includes("createUser") && /* @__PURE__ */ jsxs2(Typography, { variant: "body2", align: "center", sx: { color: "text.secondary", mt: 3 }, children: [
1973
+ /* @__PURE__ */ jsx6(Box2, { children: state.errors.global && state.errors.global.length > 0 && state.errors.global.map((error, index) => /* @__PURE__ */ jsx6(Alert2, { variant: "filled", sx: { mt: 2 }, severity: "error", children: /* @__PURE__ */ jsx6("div", { children: error }) }, index)) }),
1974
+ state.config.loginActions?.includes("createUser") && /* @__PURE__ */ jsxs3(Typography, { variant: "body2", align: "center", sx: { color: "text.secondary", mt: 3 }, children: [
1697
1975
  t("login.noAccountPrompt"),
1698
1976
  " ",
1699
- /* @__PURE__ */ jsx5(
1977
+ /* @__PURE__ */ jsx6(
1700
1978
  Link,
1701
1979
  {
1702
1980
  sx: { cursor: "pointer" },
@@ -1716,19 +1994,19 @@ var LoginForm = ({ onScreenChange, onExternalNavigate, onLoginSuccess, onError,
1716
1994
  var LoginForm_default = LoginForm;
1717
1995
 
1718
1996
  // src/components/CrudifyLogin/Forms/ForgotPasswordForm.tsx
1719
- import { useState as useState4 } from "react";
1720
- import { Typography as Typography2, TextField as TextField2, Button as Button2, Box as Box2, CircularProgress as CircularProgress2, Alert as Alert2, Link as Link2 } from "@mui/material";
1721
- import { Fragment as Fragment3, jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
1997
+ import { useState as useState5 } from "react";
1998
+ import { Typography as Typography2, TextField as TextField2, Button as Button2, Box as Box3, CircularProgress as CircularProgress2, Alert as Alert3, Link as Link2 } from "@mui/material";
1999
+ import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
1722
2000
  var ForgotPasswordForm = ({ onScreenChange, onError }) => {
1723
- const { crudify: crudify6 } = useCrudify();
1724
- const [email, setEmail] = useState4("");
1725
- const [loading, setLoading] = useState4(false);
1726
- const [errors, setErrors] = useState4([]);
1727
- const [helperTextEmail, setHelperTextEmail] = useState4(null);
1728
- const [emailSent, setEmailSent] = useState4(false);
1729
- const [codeAlreadyExists, setCodeAlreadyExists] = useState4(false);
2001
+ const { crudify: crudify7 } = useCrudify();
2002
+ const [email, setEmail] = useState5("");
2003
+ const [loading, setLoading] = useState5(false);
2004
+ const [errors, setErrors] = useState5([]);
2005
+ const [helperTextEmail, setHelperTextEmail] = useState5(null);
2006
+ const [emailSent, setEmailSent] = useState5(false);
2007
+ const [codeAlreadyExists, setCodeAlreadyExists] = useState5(false);
1730
2008
  const { t } = useTranslation();
1731
- const translateError = (parsedError) => {
2009
+ const translateError2 = (parsedError) => {
1732
2010
  const possibleKeys = [
1733
2011
  `errors.auth.${parsedError.code}`,
1734
2012
  `errors.data.${parsedError.code}`,
@@ -1749,7 +2027,7 @@ var ForgotPasswordForm = ({ onScreenChange, onError }) => {
1749
2027
  return emailRegex.test(email2);
1750
2028
  };
1751
2029
  const handleSubmit = async () => {
1752
- if (loading || !crudify6) return;
2030
+ if (loading || !crudify7) return;
1753
2031
  setErrors([]);
1754
2032
  setHelperTextEmail(null);
1755
2033
  if (!email) {
@@ -1763,7 +2041,7 @@ var ForgotPasswordForm = ({ onScreenChange, onError }) => {
1763
2041
  setLoading(true);
1764
2042
  try {
1765
2043
  const data = [{ operation: "requestPasswordReset", data: { email } }];
1766
- const response = await crudify6.transaction(data);
2044
+ const response = await crudify7.transaction(data);
1767
2045
  if (response.success) {
1768
2046
  if (response.data && response.data.existingCodeValid) {
1769
2047
  setCodeAlreadyExists(true);
@@ -1772,12 +2050,12 @@ var ForgotPasswordForm = ({ onScreenChange, onError }) => {
1772
2050
  }
1773
2051
  } else {
1774
2052
  const parsedErrors = handleCrudifyError(response);
1775
- const translatedErrors = parsedErrors.map(translateError);
2053
+ const translatedErrors = parsedErrors.map(translateError2);
1776
2054
  setErrors(translatedErrors);
1777
2055
  }
1778
2056
  } catch (error) {
1779
2057
  const parsedErrors = handleCrudifyError(error);
1780
- const translatedErrors = parsedErrors.map(translateError);
2058
+ const translatedErrors = parsedErrors.map(translateError2);
1781
2059
  setErrors(translatedErrors);
1782
2060
  if (onError) {
1783
2061
  onError(translatedErrors.join(", "));
@@ -1805,23 +2083,23 @@ var ForgotPasswordForm = ({ onScreenChange, onError }) => {
1805
2083
  onScreenChange?.("checkCode", { email });
1806
2084
  };
1807
2085
  if (emailSent || codeAlreadyExists) {
1808
- return /* @__PURE__ */ jsx6(Fragment3, { children: /* @__PURE__ */ jsxs3(Box2, { sx: { width: "100%", display: "flex", flexDirection: "column", gap: 2, textAlign: "center" }, children: [
1809
- /* @__PURE__ */ jsxs3(Box2, { sx: { mb: 2 }, children: [
1810
- /* @__PURE__ */ jsx6(Typography2, { variant: "h5", component: "h1", sx: { mb: 1, fontWeight: 600 }, children: codeAlreadyExists ? t("forgotPassword.codeAlreadyExistsMessage") : t("forgotPassword.emailSentMessage") }),
1811
- /* @__PURE__ */ jsx6(Typography2, { variant: "body2", sx: { color: codeAlreadyExists ? "success.main" : "grey.600" }, children: codeAlreadyExists ? t("forgotPassword.checkEmailInstructions") : t("forgotPassword.checkEmailInstructions") })
2086
+ return /* @__PURE__ */ jsx7(Fragment3, { children: /* @__PURE__ */ jsxs4(Box3, { sx: { width: "100%", display: "flex", flexDirection: "column", gap: 2, textAlign: "center" }, children: [
2087
+ /* @__PURE__ */ jsxs4(Box3, { sx: { mb: 2 }, children: [
2088
+ /* @__PURE__ */ jsx7(Typography2, { variant: "h5", component: "h1", sx: { mb: 1, fontWeight: 600 }, children: codeAlreadyExists ? t("forgotPassword.codeAlreadyExistsMessage") : t("forgotPassword.emailSentMessage") }),
2089
+ /* @__PURE__ */ jsx7(Typography2, { variant: "body2", sx: { color: codeAlreadyExists ? "success.main" : "grey.600" }, children: codeAlreadyExists ? t("forgotPassword.checkEmailInstructions") : t("forgotPassword.checkEmailInstructions") })
1812
2090
  ] }),
1813
- /* @__PURE__ */ jsx6(Button2, { type: "button", onClick: handleGoToCheckCode, fullWidth: true, variant: "contained", color: "primary", sx: { mt: 2, mb: 2 }, children: t("forgotPassword.enterCodeLink") }),
1814
- /* @__PURE__ */ jsx6(Box2, { sx: { display: "flex", justifyContent: "center", alignItems: "center" }, children: /* @__PURE__ */ jsx6(Link2, { sx: { cursor: "pointer" }, onClick: handleBack, variant: "body2", color: "secondary", children: t("common.back") }) })
2091
+ /* @__PURE__ */ jsx7(Button2, { type: "button", onClick: handleGoToCheckCode, fullWidth: true, variant: "contained", color: "primary", sx: { mt: 2, mb: 2 }, children: t("forgotPassword.enterCodeLink") }),
2092
+ /* @__PURE__ */ jsx7(Box3, { sx: { display: "flex", justifyContent: "center", alignItems: "center" }, children: /* @__PURE__ */ jsx7(Link2, { sx: { cursor: "pointer" }, onClick: handleBack, variant: "body2", color: "secondary", children: t("common.back") }) })
1815
2093
  ] }) });
1816
2094
  }
1817
- return /* @__PURE__ */ jsxs3(Fragment3, { children: [
1818
- /* @__PURE__ */ jsxs3(Box2, { component: "form", noValidate: true, sx: { width: "100%", display: "flex", flexDirection: "column", gap: 2 }, children: [
1819
- /* @__PURE__ */ jsxs3(Box2, { sx: { mb: 2 }, children: [
1820
- /* @__PURE__ */ jsx6(Typography2, { variant: "h5", component: "h1", sx: { mb: 1, fontWeight: 600 }, children: t("forgotPassword.title") }),
1821
- /* @__PURE__ */ jsx6(Typography2, { variant: "body2", sx: { color: "grey.600" }, children: t("forgotPassword.instructions") })
2095
+ return /* @__PURE__ */ jsxs4(Fragment3, { children: [
2096
+ /* @__PURE__ */ jsxs4(Box3, { component: "form", noValidate: true, sx: { width: "100%", display: "flex", flexDirection: "column", gap: 2 }, children: [
2097
+ /* @__PURE__ */ jsxs4(Box3, { sx: { mb: 2 }, children: [
2098
+ /* @__PURE__ */ jsx7(Typography2, { variant: "h5", component: "h1", sx: { mb: 1, fontWeight: 600 }, children: t("forgotPassword.title") }),
2099
+ /* @__PURE__ */ jsx7(Typography2, { variant: "body2", sx: { color: "grey.600" }, children: t("forgotPassword.instructions") })
1822
2100
  ] }),
1823
- /* @__PURE__ */ jsxs3(Box2, { sx: { mb: 1 }, children: [
1824
- /* @__PURE__ */ jsx6(
2101
+ /* @__PURE__ */ jsxs4(Box3, { sx: { mb: 1 }, children: [
2102
+ /* @__PURE__ */ jsx7(
1825
2103
  Typography2,
1826
2104
  {
1827
2105
  variant: "body2",
@@ -1831,7 +2109,7 @@ var ForgotPasswordForm = ({ onScreenChange, onError }) => {
1831
2109
  children: t("forgotPassword.emailLabel")
1832
2110
  }
1833
2111
  ),
1834
- /* @__PURE__ */ jsx6(
2112
+ /* @__PURE__ */ jsx7(
1835
2113
  TextField2,
1836
2114
  {
1837
2115
  fullWidth: true,
@@ -1849,39 +2127,39 @@ var ForgotPasswordForm = ({ onScreenChange, onError }) => {
1849
2127
  }
1850
2128
  )
1851
2129
  ] }),
1852
- /* @__PURE__ */ jsx6(Button2, { disabled: loading, type: "button", onClick: handleSubmit, fullWidth: true, variant: "contained", color: "primary", sx: { mt: 2, mb: 2 }, children: loading ? /* @__PURE__ */ jsx6(CircularProgress2, { size: 20 }) : t("forgotPassword.sendCodeButton") }),
1853
- /* @__PURE__ */ jsxs3(Box2, { sx: { display: "flex", justifyContent: "center", alignItems: "center", gap: 2 }, children: [
1854
- /* @__PURE__ */ jsx6(Link2, { sx: { cursor: "pointer" }, onClick: handleBack, variant: "body2", color: "secondary", children: t("common.back") }),
1855
- /* @__PURE__ */ jsx6(Typography2, { variant: "body2", sx: { color: "grey.400" }, children: "\u2022" }),
1856
- /* @__PURE__ */ jsx6(Link2, { sx: { cursor: "pointer" }, onClick: handleGoToCheckCode, variant: "body2", color: "secondary", children: t("login.alreadyHaveCodeLink") })
2130
+ /* @__PURE__ */ jsx7(Button2, { disabled: loading, type: "button", onClick: handleSubmit, fullWidth: true, variant: "contained", color: "primary", sx: { mt: 2, mb: 2 }, children: loading ? /* @__PURE__ */ jsx7(CircularProgress2, { size: 20 }) : t("forgotPassword.sendCodeButton") }),
2131
+ /* @__PURE__ */ jsxs4(Box3, { sx: { display: "flex", justifyContent: "center", alignItems: "center", gap: 2 }, children: [
2132
+ /* @__PURE__ */ jsx7(Link2, { sx: { cursor: "pointer" }, onClick: handleBack, variant: "body2", color: "secondary", children: t("common.back") }),
2133
+ /* @__PURE__ */ jsx7(Typography2, { variant: "body2", sx: { color: "grey.400" }, children: "\u2022" }),
2134
+ /* @__PURE__ */ jsx7(Link2, { sx: { cursor: "pointer" }, onClick: handleGoToCheckCode, variant: "body2", color: "secondary", children: t("login.alreadyHaveCodeLink") })
1857
2135
  ] })
1858
2136
  ] }),
1859
- /* @__PURE__ */ jsx6(Box2, { children: errors.length > 0 && errors.map((error, index) => /* @__PURE__ */ jsx6(Alert2, { variant: "filled", sx: { mt: 2 }, severity: "error", children: error }, index)) })
2137
+ /* @__PURE__ */ jsx7(Box3, { children: errors.length > 0 && errors.map((error, index) => /* @__PURE__ */ jsx7(Alert3, { variant: "filled", sx: { mt: 2 }, severity: "error", children: error }, index)) })
1860
2138
  ] });
1861
2139
  };
1862
2140
  var ForgotPasswordForm_default = ForgotPasswordForm;
1863
2141
 
1864
2142
  // src/components/CrudifyLogin/Forms/ResetPasswordForm.tsx
1865
- import { useState as useState5, useEffect as useEffect6 } from "react";
1866
- import { Typography as Typography3, TextField as TextField3, Button as Button3, Box as Box3, CircularProgress as CircularProgress3, Alert as Alert3, Link as Link3 } from "@mui/material";
1867
- import { Fragment as Fragment4, jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
2143
+ import { useState as useState6, useEffect as useEffect7 } from "react";
2144
+ import { Typography as Typography3, TextField as TextField3, Button as Button3, Box as Box4, CircularProgress as CircularProgress3, Alert as Alert4, Link as Link3 } from "@mui/material";
2145
+ import { Fragment as Fragment4, jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
1868
2146
  var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess }) => {
1869
- const { crudify: crudify6 } = useCrudify();
1870
- const [newPassword, setNewPassword] = useState5("");
1871
- const [confirmPassword, setConfirmPassword] = useState5("");
1872
- const [loading, setLoading] = useState5(false);
1873
- const [errors, setErrors] = useState5([]);
1874
- const [helperTextNewPassword, setHelperTextNewPassword] = useState5(null);
1875
- const [helperTextConfirmPassword, setHelperTextConfirmPassword] = useState5(null);
1876
- const [email, setEmail] = useState5("");
1877
- const [code, setCode] = useState5("");
1878
- const [fromCodeVerification, setFromCodeVerification] = useState5(false);
1879
- const [validatingCode, setValidatingCode] = useState5(true);
1880
- const [codeValidated, setCodeValidated] = useState5(false);
1881
- const [pendingValidation, setPendingValidation] = useState5(null);
1882
- const [isValidating, setIsValidating] = useState5(false);
2147
+ const { crudify: crudify7 } = useCrudify();
2148
+ const [newPassword, setNewPassword] = useState6("");
2149
+ const [confirmPassword, setConfirmPassword] = useState6("");
2150
+ const [loading, setLoading] = useState6(false);
2151
+ const [errors, setErrors] = useState6([]);
2152
+ const [helperTextNewPassword, setHelperTextNewPassword] = useState6(null);
2153
+ const [helperTextConfirmPassword, setHelperTextConfirmPassword] = useState6(null);
2154
+ const [email, setEmail] = useState6("");
2155
+ const [code, setCode] = useState6("");
2156
+ const [fromCodeVerification, setFromCodeVerification] = useState6(false);
2157
+ const [validatingCode, setValidatingCode] = useState6(true);
2158
+ const [codeValidated, setCodeValidated] = useState6(false);
2159
+ const [pendingValidation, setPendingValidation] = useState6(null);
2160
+ const [isValidating, setIsValidating] = useState6(false);
1883
2161
  const { t } = useTranslation();
1884
- const translateError = (parsedError) => {
2162
+ const translateError2 = (parsedError) => {
1885
2163
  const possibleKeys = [
1886
2164
  `errors.auth.${parsedError.code}`,
1887
2165
  `errors.data.${parsedError.code}`,
@@ -1904,7 +2182,7 @@ var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess
1904
2182
  }
1905
2183
  return searchParams[key] || null;
1906
2184
  };
1907
- useEffect6(() => {
2185
+ useEffect7(() => {
1908
2186
  if (!searchParams) {
1909
2187
  return;
1910
2188
  }
@@ -1946,9 +2224,9 @@ var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess
1946
2224
  setErrors([t("resetPassword.invalidCode")]);
1947
2225
  setValidatingCode(false);
1948
2226
  setTimeout(() => onScreenChange?.("forgotPassword"), 3e3);
1949
- }, [searchParams, crudify6, t, onScreenChange]);
1950
- useEffect6(() => {
1951
- if (crudify6 && pendingValidation && !isValidating) {
2227
+ }, [searchParams, crudify7, t, onScreenChange]);
2228
+ useEffect7(() => {
2229
+ if (crudify7 && pendingValidation && !isValidating) {
1952
2230
  setIsValidating(true);
1953
2231
  const validateCode = async (emailToValidate, codeToValidate) => {
1954
2232
  try {
@@ -1958,7 +2236,7 @@ var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess
1958
2236
  data: { email: emailToValidate, codePassword: codeToValidate }
1959
2237
  }
1960
2238
  ];
1961
- const response = await crudify6.transaction(data);
2239
+ const response = await crudify7.transaction(data);
1962
2240
  if (response.data && Array.isArray(response.data)) {
1963
2241
  const validationResult = response.data[0];
1964
2242
  if (validationResult && validationResult.response && validationResult.response.status === "OK") {
@@ -1970,13 +2248,13 @@ var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess
1970
2248
  setCodeValidated(true);
1971
2249
  } else {
1972
2250
  const parsedErrors = handleCrudifyError(response);
1973
- const translatedErrors = parsedErrors.map(translateError);
2251
+ const translatedErrors = parsedErrors.map(translateError2);
1974
2252
  setErrors(translatedErrors);
1975
2253
  setTimeout(() => onScreenChange?.("forgotPassword"), 3e3);
1976
2254
  }
1977
2255
  } catch (error) {
1978
2256
  const parsedErrors = handleCrudifyError(error);
1979
- const translatedErrors = parsedErrors.map(translateError);
2257
+ const translatedErrors = parsedErrors.map(translateError2);
1980
2258
  setErrors(translatedErrors);
1981
2259
  setTimeout(() => onScreenChange?.("forgotPassword"), 3e3);
1982
2260
  } finally {
@@ -1987,7 +2265,7 @@ var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess
1987
2265
  };
1988
2266
  validateCode(pendingValidation.email, pendingValidation.code);
1989
2267
  }
1990
- }, [crudify6, pendingValidation, t, onScreenChange]);
2268
+ }, [crudify7, pendingValidation, t, onScreenChange]);
1991
2269
  const validatePassword = (password) => {
1992
2270
  if (password.length < 8) {
1993
2271
  return t("resetPassword.passwordTooShort");
@@ -1995,7 +2273,7 @@ var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess
1995
2273
  return null;
1996
2274
  };
1997
2275
  const handleSubmit = async () => {
1998
- if (loading || !crudify6) return;
2276
+ if (loading || !crudify7) return;
1999
2277
  setErrors([]);
2000
2278
  setHelperTextNewPassword(null);
2001
2279
  setHelperTextConfirmPassword(null);
@@ -2026,7 +2304,7 @@ var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess
2026
2304
  data: { email, codePassword: code, newPassword }
2027
2305
  }
2028
2306
  ];
2029
- const response = await crudify6.transaction(data);
2307
+ const response = await crudify7.transaction(data);
2030
2308
  if (response.success) {
2031
2309
  setErrors([]);
2032
2310
  setTimeout(() => {
@@ -2034,12 +2312,12 @@ var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess
2034
2312
  }, 1e3);
2035
2313
  } else {
2036
2314
  const parsedErrors = handleCrudifyError(response);
2037
- const translatedErrors = parsedErrors.map(translateError);
2315
+ const translatedErrors = parsedErrors.map(translateError2);
2038
2316
  setErrors(translatedErrors);
2039
2317
  }
2040
2318
  } catch (error) {
2041
2319
  const parsedErrors = handleCrudifyError(error);
2042
- const translatedErrors = parsedErrors.map(translateError);
2320
+ const translatedErrors = parsedErrors.map(translateError2);
2043
2321
  setErrors(translatedErrors);
2044
2322
  if (onError) {
2045
2323
  onError(translatedErrors.join(", "));
@@ -2055,19 +2333,19 @@ var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess
2055
2333
  }
2056
2334
  };
2057
2335
  if (validatingCode) {
2058
- return /* @__PURE__ */ jsx7(Box3, { sx: { display: "flex", justifyContent: "center", alignItems: "center", minHeight: "300px" }, children: /* @__PURE__ */ jsx7(CircularProgress3, {}) });
2336
+ return /* @__PURE__ */ jsx8(Box4, { sx: { display: "flex", justifyContent: "center", alignItems: "center", minHeight: "300px" }, children: /* @__PURE__ */ jsx8(CircularProgress3, {}) });
2059
2337
  }
2060
2338
  if (!codeValidated) {
2061
- return /* @__PURE__ */ jsx7(Box3, { children: errors.length > 0 && errors.map((error, index) => /* @__PURE__ */ jsx7(Alert3, { variant: "filled", sx: { mt: 2 }, severity: "error", children: error }, index)) });
2339
+ return /* @__PURE__ */ jsx8(Box4, { children: errors.length > 0 && errors.map((error, index) => /* @__PURE__ */ jsx8(Alert4, { variant: "filled", sx: { mt: 2 }, severity: "error", children: error }, index)) });
2062
2340
  }
2063
- return /* @__PURE__ */ jsxs4(Fragment4, { children: [
2064
- /* @__PURE__ */ jsxs4(Box3, { component: "form", noValidate: true, sx: { width: "100%", display: "flex", flexDirection: "column", gap: 2 }, children: [
2065
- /* @__PURE__ */ jsxs4(Box3, { sx: { mb: 2 }, children: [
2066
- /* @__PURE__ */ jsx7(Typography3, { variant: "h5", component: "h1", sx: { mb: 1, fontWeight: 600 }, children: t("resetPassword.title") }),
2067
- /* @__PURE__ */ jsx7(Typography3, { variant: "body2", sx: { color: "grey.600" }, children: t("resetPassword.instructions") })
2341
+ return /* @__PURE__ */ jsxs5(Fragment4, { children: [
2342
+ /* @__PURE__ */ jsxs5(Box4, { component: "form", noValidate: true, sx: { width: "100%", display: "flex", flexDirection: "column", gap: 2 }, children: [
2343
+ /* @__PURE__ */ jsxs5(Box4, { sx: { mb: 2 }, children: [
2344
+ /* @__PURE__ */ jsx8(Typography3, { variant: "h5", component: "h1", sx: { mb: 1, fontWeight: 600 }, children: t("resetPassword.title") }),
2345
+ /* @__PURE__ */ jsx8(Typography3, { variant: "body2", sx: { color: "grey.600" }, children: t("resetPassword.instructions") })
2068
2346
  ] }),
2069
- /* @__PURE__ */ jsxs4(Box3, { sx: { mb: 1 }, children: [
2070
- /* @__PURE__ */ jsx7(
2347
+ /* @__PURE__ */ jsxs5(Box4, { sx: { mb: 1 }, children: [
2348
+ /* @__PURE__ */ jsx8(
2071
2349
  Typography3,
2072
2350
  {
2073
2351
  variant: "body2",
@@ -2077,7 +2355,7 @@ var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess
2077
2355
  children: t("resetPassword.newPasswordLabel")
2078
2356
  }
2079
2357
  ),
2080
- /* @__PURE__ */ jsx7(
2358
+ /* @__PURE__ */ jsx8(
2081
2359
  TextField3,
2082
2360
  {
2083
2361
  fullWidth: true,
@@ -2095,8 +2373,8 @@ var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess
2095
2373
  }
2096
2374
  )
2097
2375
  ] }),
2098
- /* @__PURE__ */ jsxs4(Box3, { sx: { mb: 1 }, children: [
2099
- /* @__PURE__ */ jsx7(
2376
+ /* @__PURE__ */ jsxs5(Box4, { sx: { mb: 1 }, children: [
2377
+ /* @__PURE__ */ jsx8(
2100
2378
  Typography3,
2101
2379
  {
2102
2380
  variant: "body2",
@@ -2106,7 +2384,7 @@ var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess
2106
2384
  children: t("resetPassword.confirmPasswordLabel")
2107
2385
  }
2108
2386
  ),
2109
- /* @__PURE__ */ jsx7(
2387
+ /* @__PURE__ */ jsx8(
2110
2388
  TextField3,
2111
2389
  {
2112
2390
  fullWidth: true,
@@ -2124,25 +2402,25 @@ var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess
2124
2402
  }
2125
2403
  )
2126
2404
  ] }),
2127
- /* @__PURE__ */ jsx7(Button3, { disabled: loading, type: "button", onClick: handleSubmit, fullWidth: true, variant: "contained", color: "primary", sx: { mt: 2, mb: 2 }, children: loading ? /* @__PURE__ */ jsx7(CircularProgress3, { size: 20 }) : t("resetPassword.resetPasswordButton") }),
2128
- /* @__PURE__ */ jsx7(Box3, { sx: { display: "flex", justifyContent: "center", alignItems: "center" }, children: /* @__PURE__ */ jsx7(Link3, { sx: { cursor: "pointer" }, onClick: handleBack, variant: "body2", color: "secondary", children: t("common.back") }) })
2405
+ /* @__PURE__ */ jsx8(Button3, { disabled: loading, type: "button", onClick: handleSubmit, fullWidth: true, variant: "contained", color: "primary", sx: { mt: 2, mb: 2 }, children: loading ? /* @__PURE__ */ jsx8(CircularProgress3, { size: 20 }) : t("resetPassword.resetPasswordButton") }),
2406
+ /* @__PURE__ */ jsx8(Box4, { sx: { display: "flex", justifyContent: "center", alignItems: "center" }, children: /* @__PURE__ */ jsx8(Link3, { sx: { cursor: "pointer" }, onClick: handleBack, variant: "body2", color: "secondary", children: t("common.back") }) })
2129
2407
  ] }),
2130
- /* @__PURE__ */ jsx7(Box3, { children: errors.length > 0 && errors.map((error, index) => /* @__PURE__ */ jsx7(Alert3, { variant: "filled", sx: { mt: 2 }, severity: "error", children: error }, index)) })
2408
+ /* @__PURE__ */ jsx8(Box4, { children: errors.length > 0 && errors.map((error, index) => /* @__PURE__ */ jsx8(Alert4, { variant: "filled", sx: { mt: 2 }, severity: "error", children: error }, index)) })
2131
2409
  ] });
2132
2410
  };
2133
2411
  var ResetPasswordForm_default = ResetPasswordForm;
2134
2412
 
2135
2413
  // src/components/CrudifyLogin/Forms/CheckCodeForm.tsx
2136
- import { useState as useState6, useEffect as useEffect7 } from "react";
2137
- import { Typography as Typography4, TextField as TextField4, Button as Button4, Box as Box4, CircularProgress as CircularProgress4, Alert as Alert4, Link as Link4 } from "@mui/material";
2138
- import { Fragment as Fragment5, jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
2414
+ import { useState as useState7, useEffect as useEffect8 } from "react";
2415
+ import { Typography as Typography4, TextField as TextField4, Button as Button4, Box as Box5, CircularProgress as CircularProgress4, Alert as Alert5, Link as Link4 } from "@mui/material";
2416
+ import { Fragment as Fragment5, jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
2139
2417
  var CheckCodeForm = ({ onScreenChange, onError, searchParams }) => {
2140
- const { crudify: crudify6 } = useCrudify();
2141
- const [code, setCode] = useState6("");
2142
- const [loading, setLoading] = useState6(false);
2143
- const [errors, setErrors] = useState6([]);
2144
- const [helperTextCode, setHelperTextCode] = useState6(null);
2145
- const [email, setEmail] = useState6("");
2418
+ const { crudify: crudify7 } = useCrudify();
2419
+ const [code, setCode] = useState7("");
2420
+ const [loading, setLoading] = useState7(false);
2421
+ const [errors, setErrors] = useState7([]);
2422
+ const [helperTextCode, setHelperTextCode] = useState7(null);
2423
+ const [email, setEmail] = useState7("");
2146
2424
  const { t } = useTranslation();
2147
2425
  const getParam = (key) => {
2148
2426
  if (!searchParams) return null;
@@ -2151,7 +2429,7 @@ var CheckCodeForm = ({ onScreenChange, onError, searchParams }) => {
2151
2429
  }
2152
2430
  return searchParams[key] || null;
2153
2431
  };
2154
- const translateError = (parsedError) => {
2432
+ const translateError2 = (parsedError) => {
2155
2433
  const possibleKeys = [
2156
2434
  `errors.auth.${parsedError.code}`,
2157
2435
  `errors.data.${parsedError.code}`,
@@ -2167,7 +2445,7 @@ var CheckCodeForm = ({ onScreenChange, onError, searchParams }) => {
2167
2445
  }
2168
2446
  return parsedError.message || t("error.unknown");
2169
2447
  };
2170
- useEffect7(() => {
2448
+ useEffect8(() => {
2171
2449
  const emailParam = getParam("email");
2172
2450
  if (emailParam) {
2173
2451
  setEmail(emailParam);
@@ -2176,7 +2454,7 @@ var CheckCodeForm = ({ onScreenChange, onError, searchParams }) => {
2176
2454
  }
2177
2455
  }, [searchParams, onScreenChange]);
2178
2456
  const handleSubmit = async () => {
2179
- if (loading || !crudify6) return;
2457
+ if (loading || !crudify7) return;
2180
2458
  setErrors([]);
2181
2459
  setHelperTextCode(null);
2182
2460
  if (!code) {
@@ -2195,18 +2473,18 @@ var CheckCodeForm = ({ onScreenChange, onError, searchParams }) => {
2195
2473
  data: { email, codePassword: code }
2196
2474
  }
2197
2475
  ];
2198
- const response = await crudify6.transaction(data);
2476
+ const response = await crudify7.transaction(data);
2199
2477
  if (response.success) {
2200
2478
  onScreenChange?.("resetPassword", { email, code, fromCodeVerification: "true" });
2201
2479
  } else {
2202
2480
  const parsedErrors = handleCrudifyError(response);
2203
- const translatedErrors = parsedErrors.map(translateError);
2481
+ const translatedErrors = parsedErrors.map(translateError2);
2204
2482
  setErrors(translatedErrors);
2205
2483
  setLoading(false);
2206
2484
  }
2207
2485
  } catch (error) {
2208
2486
  const parsedErrors = handleCrudifyError(error);
2209
- const translatedErrors = parsedErrors.map(translateError);
2487
+ const translatedErrors = parsedErrors.map(translateError2);
2210
2488
  setErrors(translatedErrors);
2211
2489
  setLoading(false);
2212
2490
  if (onError) {
@@ -2221,14 +2499,14 @@ var CheckCodeForm = ({ onScreenChange, onError, searchParams }) => {
2221
2499
  const value = event.target.value.replace(/\D/g, "").slice(0, 6);
2222
2500
  setCode(value);
2223
2501
  };
2224
- return /* @__PURE__ */ jsxs5(Fragment5, { children: [
2225
- /* @__PURE__ */ jsxs5(Box4, { component: "form", noValidate: true, sx: { width: "100%", display: "flex", flexDirection: "column", gap: 2 }, children: [
2226
- /* @__PURE__ */ jsxs5(Box4, { sx: { mb: 2 }, children: [
2227
- /* @__PURE__ */ jsx8(Typography4, { variant: "h5", component: "h1", sx: { mb: 1, fontWeight: 600 }, children: t("checkCode.title") }),
2228
- /* @__PURE__ */ jsx8(Typography4, { variant: "body2", sx: { color: "grey.600" }, children: t("checkCode.instructions") })
2502
+ return /* @__PURE__ */ jsxs6(Fragment5, { children: [
2503
+ /* @__PURE__ */ jsxs6(Box5, { component: "form", noValidate: true, sx: { width: "100%", display: "flex", flexDirection: "column", gap: 2 }, children: [
2504
+ /* @__PURE__ */ jsxs6(Box5, { sx: { mb: 2 }, children: [
2505
+ /* @__PURE__ */ jsx9(Typography4, { variant: "h5", component: "h1", sx: { mb: 1, fontWeight: 600 }, children: t("checkCode.title") }),
2506
+ /* @__PURE__ */ jsx9(Typography4, { variant: "body2", sx: { color: "grey.600" }, children: t("checkCode.instructions") })
2229
2507
  ] }),
2230
- /* @__PURE__ */ jsxs5(Box4, { sx: { mb: 1 }, children: [
2231
- /* @__PURE__ */ jsx8(
2508
+ /* @__PURE__ */ jsxs6(Box5, { sx: { mb: 1 }, children: [
2509
+ /* @__PURE__ */ jsx9(
2232
2510
  Typography4,
2233
2511
  {
2234
2512
  variant: "body2",
@@ -2238,7 +2516,7 @@ var CheckCodeForm = ({ onScreenChange, onError, searchParams }) => {
2238
2516
  children: t("checkCode.codeLabel")
2239
2517
  }
2240
2518
  ),
2241
- /* @__PURE__ */ jsx8(
2519
+ /* @__PURE__ */ jsx9(
2242
2520
  TextField4,
2243
2521
  {
2244
2522
  fullWidth: true,
@@ -2259,7 +2537,7 @@ var CheckCodeForm = ({ onScreenChange, onError, searchParams }) => {
2259
2537
  }
2260
2538
  )
2261
2539
  ] }),
2262
- /* @__PURE__ */ jsx8(
2540
+ /* @__PURE__ */ jsx9(
2263
2541
  Button4,
2264
2542
  {
2265
2543
  disabled: loading || code.length !== 6,
@@ -2269,25 +2547,25 @@ var CheckCodeForm = ({ onScreenChange, onError, searchParams }) => {
2269
2547
  variant: "contained",
2270
2548
  color: "primary",
2271
2549
  sx: { mt: 2, mb: 2 },
2272
- children: loading ? /* @__PURE__ */ jsx8(CircularProgress4, { size: 20 }) : t("checkCode.verifyButton")
2550
+ children: loading ? /* @__PURE__ */ jsx9(CircularProgress4, { size: 20 }) : t("checkCode.verifyButton")
2273
2551
  }
2274
2552
  ),
2275
- /* @__PURE__ */ jsx8(Box4, { sx: { display: "flex", justifyContent: "center", alignItems: "center" }, children: /* @__PURE__ */ jsx8(Link4, { sx: { cursor: "pointer" }, onClick: handleBack, variant: "body2", color: "secondary", children: t("common.back") }) })
2553
+ /* @__PURE__ */ jsx9(Box5, { sx: { display: "flex", justifyContent: "center", alignItems: "center" }, children: /* @__PURE__ */ jsx9(Link4, { sx: { cursor: "pointer" }, onClick: handleBack, variant: "body2", color: "secondary", children: t("common.back") }) })
2276
2554
  ] }),
2277
- /* @__PURE__ */ jsx8(Box4, { children: errors.length > 0 && errors.map((error, index) => /* @__PURE__ */ jsx8(Alert4, { sx: { mt: 2 }, severity: "error", children: error }, index)) })
2555
+ /* @__PURE__ */ jsx9(Box5, { children: errors.length > 0 && errors.map((error, index) => /* @__PURE__ */ jsx9(Alert5, { sx: { mt: 2 }, severity: "error", children: error }, index)) })
2278
2556
  ] });
2279
2557
  };
2280
2558
  var CheckCodeForm_default = CheckCodeForm;
2281
2559
 
2282
2560
  // src/components/CrudifyLogin/components/CrudifyInitializer.tsx
2283
- import { Box as Box5, CircularProgress as CircularProgress5, Alert as Alert5, Typography as Typography5 } from "@mui/material";
2284
- import { Fragment as Fragment6, jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
2561
+ import { Box as Box6, CircularProgress as CircularProgress5, Alert as Alert6, Typography as Typography5 } from "@mui/material";
2562
+ import { Fragment as Fragment6, jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
2285
2563
  var CrudifyInitializer = ({ children, fallback }) => {
2286
2564
  const { isLoading, error, isInitialized } = useCrudify();
2287
2565
  const { t } = useTranslation();
2288
2566
  if (isLoading) {
2289
- return fallback || /* @__PURE__ */ jsxs6(
2290
- Box5,
2567
+ return fallback || /* @__PURE__ */ jsxs7(
2568
+ Box6,
2291
2569
  {
2292
2570
  sx: {
2293
2571
  display: "flex",
@@ -2298,14 +2576,14 @@ var CrudifyInitializer = ({ children, fallback }) => {
2298
2576
  gap: 2
2299
2577
  },
2300
2578
  children: [
2301
- /* @__PURE__ */ jsx9(CircularProgress5, {}),
2302
- /* @__PURE__ */ jsx9(Typography5, { variant: "body2", color: "text.secondary", children: t("login.initializing") !== "login.initializing" ? t("login.initializing") : "Initializing..." })
2579
+ /* @__PURE__ */ jsx10(CircularProgress5, {}),
2580
+ /* @__PURE__ */ jsx10(Typography5, { variant: "body2", color: "text.secondary", children: t("login.initializing") !== "login.initializing" ? t("login.initializing") : "Initializing..." })
2303
2581
  ]
2304
2582
  }
2305
2583
  );
2306
2584
  }
2307
2585
  if (error) {
2308
- return /* @__PURE__ */ jsx9(Alert5, { severity: "error", sx: { mt: 2 }, children: /* @__PURE__ */ jsxs6(Typography5, { variant: "body2", children: [
2586
+ return /* @__PURE__ */ jsx10(Alert6, { severity: "error", sx: { mt: 2 }, children: /* @__PURE__ */ jsxs7(Typography5, { variant: "body2", children: [
2309
2587
  t("login.initializationError") !== "login.initializationError" ? t("login.initializationError") : "Initialization error",
2310
2588
  ":",
2311
2589
  " ",
@@ -2313,13 +2591,13 @@ var CrudifyInitializer = ({ children, fallback }) => {
2313
2591
  ] }) });
2314
2592
  }
2315
2593
  if (!isInitialized) {
2316
- return /* @__PURE__ */ jsx9(Alert5, { severity: "warning", sx: { mt: 2 }, children: /* @__PURE__ */ jsx9(Typography5, { variant: "body2", children: t("login.notInitialized") !== "login.notInitialized" ? t("login.notInitialized") : "System not initialized" }) });
2594
+ return /* @__PURE__ */ jsx10(Alert6, { severity: "warning", sx: { mt: 2 }, children: /* @__PURE__ */ jsx10(Typography5, { variant: "body2", children: t("login.notInitialized") !== "login.notInitialized" ? t("login.notInitialized") : "System not initialized" }) });
2317
2595
  }
2318
- return /* @__PURE__ */ jsx9(Fragment6, { children });
2596
+ return /* @__PURE__ */ jsx10(Fragment6, { children });
2319
2597
  };
2320
2598
 
2321
2599
  // src/components/CrudifyLogin/index.tsx
2322
- import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
2600
+ import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
2323
2601
  var CrudifyLoginInternal = ({
2324
2602
  onScreenChange,
2325
2603
  onExternalNavigate,
@@ -2349,11 +2627,11 @@ var CrudifyLoginInternal = ({
2349
2627
  };
2350
2628
  switch (state.currentScreen) {
2351
2629
  case "forgotPassword":
2352
- return /* @__PURE__ */ jsx10(ForgotPasswordForm_default, { ...commonProps });
2630
+ return /* @__PURE__ */ jsx11(ForgotPasswordForm_default, { ...commonProps });
2353
2631
  case "checkCode":
2354
- return /* @__PURE__ */ jsx10(CheckCodeForm_default, { ...commonProps, searchParams: state.searchParams });
2632
+ return /* @__PURE__ */ jsx11(CheckCodeForm_default, { ...commonProps, searchParams: state.searchParams });
2355
2633
  case "resetPassword":
2356
- return /* @__PURE__ */ jsx10(
2634
+ return /* @__PURE__ */ jsx11(
2357
2635
  ResetPasswordForm_default,
2358
2636
  {
2359
2637
  ...commonProps,
@@ -2364,11 +2642,11 @@ var CrudifyLoginInternal = ({
2364
2642
  }
2365
2643
  );
2366
2644
  default:
2367
- return /* @__PURE__ */ jsx10(LoginForm_default, { ...commonProps, onLoginSuccess });
2645
+ return /* @__PURE__ */ jsx11(LoginForm_default, { ...commonProps, onLoginSuccess });
2368
2646
  }
2369
2647
  };
2370
- return /* @__PURE__ */ jsxs7(CrudifyInitializer, { children: [
2371
- /* @__PURE__ */ jsx10(Box6, { sx: { display: "flex", justifyContent: "center", mb: 3 }, children: /* @__PURE__ */ jsx10(
2648
+ return /* @__PURE__ */ jsxs8(CrudifyInitializer, { children: [
2649
+ /* @__PURE__ */ jsx11(Box7, { sx: { display: "flex", justifyContent: "center", mb: 3 }, children: /* @__PURE__ */ jsx11(
2372
2650
  "img",
2373
2651
  {
2374
2652
  src: config.logo || "/nocios-default.png",
@@ -2384,7 +2662,7 @@ var CrudifyLoginInternal = ({
2384
2662
  }
2385
2663
  }
2386
2664
  ) }),
2387
- config.appName && /* @__PURE__ */ jsx10(
2665
+ config.appName && /* @__PURE__ */ jsx11(
2388
2666
  Typography6,
2389
2667
  {
2390
2668
  variant: "h6",
@@ -2409,13 +2687,13 @@ var CrudifyLogin = ({
2409
2687
  ...props
2410
2688
  }) => {
2411
2689
  const { config } = useSessionContext();
2412
- return /* @__PURE__ */ jsx10(I18nProvider, { translations, translationsUrl, language, children: /* @__PURE__ */ jsx10(CrudifyProvider, { config, children: /* @__PURE__ */ jsx10(LoginStateProvider, { config, initialScreen, autoReadFromCookies, children: /* @__PURE__ */ jsx10(CrudifyLoginInternal, { ...props }) }) }) });
2690
+ return /* @__PURE__ */ jsx11(I18nProvider, { translations, translationsUrl, language, children: /* @__PURE__ */ jsx11(CrudifyProvider, { config, children: /* @__PURE__ */ jsx11(LoginStateProvider, { config, initialScreen, autoReadFromCookies, children: /* @__PURE__ */ jsx11(CrudifyLoginInternal, { ...props }) }) }) });
2413
2691
  };
2414
2692
  var CrudifyLogin_default = CrudifyLogin;
2415
2693
 
2416
2694
  // src/components/UserProfile/UserProfileDisplay.tsx
2417
2695
  import {
2418
- Box as Box7,
2696
+ Box as Box8,
2419
2697
  Card,
2420
2698
  CardContent,
2421
2699
  Typography as Typography7,
@@ -2423,7 +2701,7 @@ import {
2423
2701
  Avatar,
2424
2702
  Divider,
2425
2703
  CircularProgress as CircularProgress6,
2426
- Alert as Alert6,
2704
+ Alert as Alert7,
2427
2705
  List,
2428
2706
  ListItem,
2429
2707
  ListItemText,
@@ -2444,25 +2722,25 @@ import {
2444
2722
  } from "@mui/icons-material";
2445
2723
 
2446
2724
  // src/hooks/useUserProfile.ts
2447
- import { useState as useState7, useEffect as useEffect8, useCallback as useCallback2, useRef as useRef2 } from "react";
2725
+ import { useState as useState8, useEffect as useEffect9, useCallback as useCallback3, useRef as useRef2 } from "react";
2448
2726
  import crudify3 from "@nocios/crudify-browser";
2449
2727
  var useUserProfile = (options = {}) => {
2450
2728
  const { autoFetch = true, retryOnError = false, maxRetries = 3 } = options;
2451
- const [userProfile, setUserProfile] = useState7(null);
2452
- const [loading, setLoading] = useState7(false);
2453
- const [error, setError] = useState7(null);
2454
- const [extendedData, setExtendedData] = useState7({});
2729
+ const [userProfile, setUserProfile] = useState8(null);
2730
+ const [loading, setLoading] = useState8(false);
2731
+ const [error, setError] = useState8(null);
2732
+ const [extendedData, setExtendedData] = useState8({});
2455
2733
  const abortControllerRef = useRef2(null);
2456
2734
  const mountedRef = useRef2(true);
2457
2735
  const requestIdRef = useRef2(0);
2458
2736
  const retryCountRef = useRef2(0);
2459
- const clearProfile = useCallback2(() => {
2737
+ const clearProfile = useCallback3(() => {
2460
2738
  setUserProfile(null);
2461
2739
  setError(null);
2462
2740
  setLoading(false);
2463
2741
  setExtendedData({});
2464
2742
  }, []);
2465
- const refreshProfile = useCallback2(async () => {
2743
+ const refreshProfile = useCallback3(async () => {
2466
2744
  const userEmail = getCurrentUserEmail();
2467
2745
  if (!userEmail) {
2468
2746
  if (mountedRef.current) {
@@ -2563,12 +2841,12 @@ var useUserProfile = (options = {}) => {
2563
2841
  }
2564
2842
  }
2565
2843
  }, [retryOnError, maxRetries]);
2566
- useEffect8(() => {
2844
+ useEffect9(() => {
2567
2845
  if (autoFetch) {
2568
2846
  refreshProfile();
2569
2847
  }
2570
2848
  }, [autoFetch, refreshProfile]);
2571
- useEffect8(() => {
2849
+ useEffect9(() => {
2572
2850
  mountedRef.current = true;
2573
2851
  return () => {
2574
2852
  mountedRef.current = false;
@@ -2589,8 +2867,8 @@ var useUserProfile = (options = {}) => {
2589
2867
  };
2590
2868
 
2591
2869
  // src/components/UserProfile/UserProfileDisplay.tsx
2592
- import { useState as useState8 } from "react";
2593
- import { Fragment as Fragment7, jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
2870
+ import { useState as useState9 } from "react";
2871
+ import { Fragment as Fragment7, jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
2594
2872
  var UserProfileDisplay = ({
2595
2873
  showExtendedData = true,
2596
2874
  showProfileCard = true,
@@ -2601,19 +2879,19 @@ var UserProfileDisplay = ({
2601
2879
  retryOnError: true,
2602
2880
  maxRetries: 3
2603
2881
  });
2604
- const [showAllFields, setShowAllFields] = useState8(false);
2882
+ const [showAllFields, setShowAllFields] = useState9(false);
2605
2883
  if (loading) {
2606
- return /* @__PURE__ */ jsxs8(Box7, { display: "flex", justifyContent: "center", alignItems: "center", p: 3, children: [
2607
- /* @__PURE__ */ jsx11(CircularProgress6, {}),
2608
- /* @__PURE__ */ jsx11(Typography7, { variant: "body2", sx: { ml: 2 }, children: "Cargando perfil de usuario..." })
2884
+ return /* @__PURE__ */ jsxs9(Box8, { display: "flex", justifyContent: "center", alignItems: "center", p: 3, children: [
2885
+ /* @__PURE__ */ jsx12(CircularProgress6, {}),
2886
+ /* @__PURE__ */ jsx12(Typography7, { variant: "body2", sx: { ml: 2 }, children: "Cargando perfil de usuario..." })
2609
2887
  ] });
2610
2888
  }
2611
2889
  if (error) {
2612
- return /* @__PURE__ */ jsxs8(
2613
- Alert6,
2890
+ return /* @__PURE__ */ jsxs9(
2891
+ Alert7,
2614
2892
  {
2615
2893
  severity: "error",
2616
- action: /* @__PURE__ */ jsx11(IconButton, { color: "inherit", size: "small", onClick: refreshProfile, children: /* @__PURE__ */ jsx11(Typography7, { variant: "caption", children: "Reintentar" }) }),
2894
+ action: /* @__PURE__ */ jsx12(IconButton, { color: "inherit", size: "small", onClick: refreshProfile, children: /* @__PURE__ */ jsx12(Typography7, { variant: "caption", children: "Reintentar" }) }),
2617
2895
  children: [
2618
2896
  "Error al cargar el perfil: ",
2619
2897
  error
@@ -2622,7 +2900,7 @@ var UserProfileDisplay = ({
2622
2900
  );
2623
2901
  }
2624
2902
  if (!userProfile) {
2625
- return /* @__PURE__ */ jsx11(Alert6, { severity: "warning", children: "No se encontr\xF3 informaci\xF3n del usuario" });
2903
+ return /* @__PURE__ */ jsx12(Alert7, { severity: "warning", children: "No se encontr\xF3 informaci\xF3n del usuario" });
2626
2904
  }
2627
2905
  const displayData = extendedData?.displayData || {};
2628
2906
  const totalFields = extendedData?.totalFields || 0;
@@ -2648,11 +2926,11 @@ var UserProfileDisplay = ({
2648
2926
  return String(value);
2649
2927
  };
2650
2928
  const basicFields = [
2651
- { key: "id", label: "ID", icon: /* @__PURE__ */ jsx11(Badge, {}) },
2652
- { key: "email", label: "Email", icon: /* @__PURE__ */ jsx11(Email, {}) },
2653
- { key: "username", label: "Usuario", icon: /* @__PURE__ */ jsx11(Person, {}) },
2654
- { key: "fullName", label: "Nombre completo", icon: /* @__PURE__ */ jsx11(AccountCircle, {}) },
2655
- { key: "role", label: "Rol", icon: /* @__PURE__ */ jsx11(Security, {}) }
2929
+ { key: "id", label: "ID", icon: /* @__PURE__ */ jsx12(Badge, {}) },
2930
+ { key: "email", label: "Email", icon: /* @__PURE__ */ jsx12(Email, {}) },
2931
+ { key: "username", label: "Usuario", icon: /* @__PURE__ */ jsx12(Person, {}) },
2932
+ { key: "fullName", label: "Nombre completo", icon: /* @__PURE__ */ jsx12(AccountCircle, {}) },
2933
+ { key: "role", label: "Rol", icon: /* @__PURE__ */ jsx12(Security, {}) }
2656
2934
  ];
2657
2935
  const extendedFields = [
2658
2936
  { key: "firstName", label: "Nombre" },
@@ -2664,10 +2942,10 @@ var UserProfileDisplay = ({
2664
2942
  ];
2665
2943
  const knownFields = [...basicFields.map((f) => f.key), ...extendedFields.map((f) => f.key), "permissions"];
2666
2944
  const customFields = Object.keys(displayData).filter((key) => !knownFields.includes(key)).map((key) => ({ key, label: key }));
2667
- return /* @__PURE__ */ jsxs8(Box7, { children: [
2668
- showProfileCard && /* @__PURE__ */ jsx11(Card, { sx: { mb: 2 }, children: /* @__PURE__ */ jsxs8(CardContent, { children: [
2669
- /* @__PURE__ */ jsxs8(Box7, { display: "flex", alignItems: "center", mb: 2, children: [
2670
- /* @__PURE__ */ jsx11(
2945
+ return /* @__PURE__ */ jsxs9(Box8, { children: [
2946
+ showProfileCard && /* @__PURE__ */ jsx12(Card, { sx: { mb: 2 }, children: /* @__PURE__ */ jsxs9(CardContent, { children: [
2947
+ /* @__PURE__ */ jsxs9(Box8, { display: "flex", alignItems: "center", mb: 2, children: [
2948
+ /* @__PURE__ */ jsx12(
2671
2949
  Avatar,
2672
2950
  {
2673
2951
  src: displayData.avatar,
@@ -2675,10 +2953,10 @@ var UserProfileDisplay = ({
2675
2953
  children: displayData.fullName?.[0] || displayData.username?.[0] || displayData.email?.[0]
2676
2954
  }
2677
2955
  ),
2678
- /* @__PURE__ */ jsxs8(Box7, { children: [
2679
- /* @__PURE__ */ jsx11(Typography7, { variant: "h6", children: displayData.fullName || displayData.username || displayData.email }),
2680
- /* @__PURE__ */ jsx11(Typography7, { variant: "body2", color: "text.secondary", children: displayData.role || "Usuario" }),
2681
- displayData.isActive !== void 0 && /* @__PURE__ */ jsx11(
2956
+ /* @__PURE__ */ jsxs9(Box8, { children: [
2957
+ /* @__PURE__ */ jsx12(Typography7, { variant: "h6", children: displayData.fullName || displayData.username || displayData.email }),
2958
+ /* @__PURE__ */ jsx12(Typography7, { variant: "body2", color: "text.secondary", children: displayData.role || "Usuario" }),
2959
+ displayData.isActive !== void 0 && /* @__PURE__ */ jsx12(
2682
2960
  Chip,
2683
2961
  {
2684
2962
  label: displayData.isActive ? "Activo" : "Inactivo",
@@ -2689,35 +2967,35 @@ var UserProfileDisplay = ({
2689
2967
  )
2690
2968
  ] })
2691
2969
  ] }),
2692
- /* @__PURE__ */ jsx11(Box7, { display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(250px, 1fr))", gap: 2, children: basicFields.map(
2693
- ({ key, label, icon }) => displayData[key] ? /* @__PURE__ */ jsxs8(Box7, { display: "flex", alignItems: "center", children: [
2694
- /* @__PURE__ */ jsx11(Box7, { sx: { mr: 1, color: "text.secondary" }, children: icon }),
2695
- /* @__PURE__ */ jsxs8(Box7, { children: [
2696
- /* @__PURE__ */ jsx11(Typography7, { variant: "caption", color: "text.secondary", children: label }),
2697
- /* @__PURE__ */ jsx11(Typography7, { variant: "body2", children: renderFieldValue(key, displayData[key]) })
2970
+ /* @__PURE__ */ jsx12(Box8, { display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(250px, 1fr))", gap: 2, children: basicFields.map(
2971
+ ({ key, label, icon }) => displayData[key] ? /* @__PURE__ */ jsxs9(Box8, { display: "flex", alignItems: "center", children: [
2972
+ /* @__PURE__ */ jsx12(Box8, { sx: { mr: 1, color: "text.secondary" }, children: icon }),
2973
+ /* @__PURE__ */ jsxs9(Box8, { children: [
2974
+ /* @__PURE__ */ jsx12(Typography7, { variant: "caption", color: "text.secondary", children: label }),
2975
+ /* @__PURE__ */ jsx12(Typography7, { variant: "body2", children: renderFieldValue(key, displayData[key]) })
2698
2976
  ] })
2699
2977
  ] }, key) : null
2700
2978
  ) }),
2701
- displayData.permissions && Array.isArray(displayData.permissions) && displayData.permissions.length > 0 && /* @__PURE__ */ jsxs8(Box7, { mt: 2, children: [
2702
- /* @__PURE__ */ jsx11(Typography7, { variant: "caption", color: "text.secondary", display: "block", children: "Permisos" }),
2703
- /* @__PURE__ */ jsxs8(Box7, { display: "flex", flexWrap: "wrap", gap: 0.5, mt: 0.5, children: [
2704
- displayData.permissions.slice(0, 5).map((permission, index) => /* @__PURE__ */ jsx11(Chip, { label: permission, size: "small", variant: "outlined" }, index)),
2705
- displayData.permissions.length > 5 && /* @__PURE__ */ jsx11(Chip, { label: `+${displayData.permissions.length - 5} m\xE1s`, size: "small" })
2979
+ displayData.permissions && Array.isArray(displayData.permissions) && displayData.permissions.length > 0 && /* @__PURE__ */ jsxs9(Box8, { mt: 2, children: [
2980
+ /* @__PURE__ */ jsx12(Typography7, { variant: "caption", color: "text.secondary", display: "block", children: "Permisos" }),
2981
+ /* @__PURE__ */ jsxs9(Box8, { display: "flex", flexWrap: "wrap", gap: 0.5, mt: 0.5, children: [
2982
+ displayData.permissions.slice(0, 5).map((permission, index) => /* @__PURE__ */ jsx12(Chip, { label: permission, size: "small", variant: "outlined" }, index)),
2983
+ displayData.permissions.length > 5 && /* @__PURE__ */ jsx12(Chip, { label: `+${displayData.permissions.length - 5} m\xE1s`, size: "small" })
2706
2984
  ] })
2707
2985
  ] })
2708
2986
  ] }) }),
2709
- showExtendedData && /* @__PURE__ */ jsx11(Card, { children: /* @__PURE__ */ jsxs8(CardContent, { children: [
2710
- /* @__PURE__ */ jsxs8(Box7, { display: "flex", justifyContent: "space-between", alignItems: "center", mb: 2, children: [
2711
- /* @__PURE__ */ jsxs8(Typography7, { variant: "h6", display: "flex", alignItems: "center", children: [
2712
- /* @__PURE__ */ jsx11(Info, { sx: { mr: 1 } }),
2987
+ showExtendedData && /* @__PURE__ */ jsx12(Card, { children: /* @__PURE__ */ jsxs9(CardContent, { children: [
2988
+ /* @__PURE__ */ jsxs9(Box8, { display: "flex", justifyContent: "space-between", alignItems: "center", mb: 2, children: [
2989
+ /* @__PURE__ */ jsxs9(Typography7, { variant: "h6", display: "flex", alignItems: "center", children: [
2990
+ /* @__PURE__ */ jsx12(Info, { sx: { mr: 1 } }),
2713
2991
  "Informaci\xF3n Detallada"
2714
2992
  ] }),
2715
- /* @__PURE__ */ jsx11(Chip, { label: `${totalFields} campos totales`, size: "small" })
2993
+ /* @__PURE__ */ jsx12(Chip, { label: `${totalFields} campos totales`, size: "small" })
2716
2994
  ] }),
2717
- /* @__PURE__ */ jsxs8(List, { dense: true, children: [
2718
- extendedFields.map(({ key, label }) => displayData[key] !== void 0 && /* @__PURE__ */ jsxs8(ListItem, { divider: true, children: [
2719
- /* @__PURE__ */ jsx11(ListItemIcon, { children: /* @__PURE__ */ jsx11(Schedule, { fontSize: "small" }) }),
2720
- /* @__PURE__ */ jsx11(
2995
+ /* @__PURE__ */ jsxs9(List, { dense: true, children: [
2996
+ extendedFields.map(({ key, label }) => displayData[key] !== void 0 && /* @__PURE__ */ jsxs9(ListItem, { divider: true, children: [
2997
+ /* @__PURE__ */ jsx12(ListItemIcon, { children: /* @__PURE__ */ jsx12(Schedule, { fontSize: "small" }) }),
2998
+ /* @__PURE__ */ jsx12(
2721
2999
  ListItemText,
2722
3000
  {
2723
3001
  primary: label,
@@ -2725,22 +3003,22 @@ var UserProfileDisplay = ({
2725
3003
  }
2726
3004
  )
2727
3005
  ] }, key)),
2728
- customFields.length > 0 && /* @__PURE__ */ jsxs8(Fragment7, { children: [
2729
- /* @__PURE__ */ jsx11(Divider, { sx: { my: 1 } }),
2730
- /* @__PURE__ */ jsx11(ListItem, { children: /* @__PURE__ */ jsx11(
3006
+ customFields.length > 0 && /* @__PURE__ */ jsxs9(Fragment7, { children: [
3007
+ /* @__PURE__ */ jsx12(Divider, { sx: { my: 1 } }),
3008
+ /* @__PURE__ */ jsx12(ListItem, { children: /* @__PURE__ */ jsx12(
2731
3009
  ListItemText,
2732
3010
  {
2733
- primary: /* @__PURE__ */ jsxs8(Box7, { display: "flex", justifyContent: "space-between", alignItems: "center", children: [
2734
- /* @__PURE__ */ jsxs8(Typography7, { variant: "subtitle2", children: [
3011
+ primary: /* @__PURE__ */ jsxs9(Box8, { display: "flex", justifyContent: "space-between", alignItems: "center", children: [
3012
+ /* @__PURE__ */ jsxs9(Typography7, { variant: "subtitle2", children: [
2735
3013
  "Campos Personalizados (",
2736
3014
  customFields.length,
2737
3015
  ")"
2738
3016
  ] }),
2739
- /* @__PURE__ */ jsx11(IconButton, { size: "small", onClick: () => setShowAllFields(!showAllFields), children: showAllFields ? /* @__PURE__ */ jsx11(ExpandLess, {}) : /* @__PURE__ */ jsx11(ExpandMore, {}) })
3017
+ /* @__PURE__ */ jsx12(IconButton, { size: "small", onClick: () => setShowAllFields(!showAllFields), children: showAllFields ? /* @__PURE__ */ jsx12(ExpandLess, {}) : /* @__PURE__ */ jsx12(ExpandMore, {}) })
2740
3018
  ] })
2741
3019
  }
2742
3020
  ) }),
2743
- /* @__PURE__ */ jsx11(Collapse, { in: showAllFields, children: customFields.map(({ key, label }) => /* @__PURE__ */ jsx11(ListItem, { sx: { pl: 4 }, children: /* @__PURE__ */ jsx11(
3021
+ /* @__PURE__ */ jsx12(Collapse, { in: showAllFields, children: customFields.map(({ key, label }) => /* @__PURE__ */ jsx12(ListItem, { sx: { pl: 4 }, children: /* @__PURE__ */ jsx12(
2744
3022
  ListItemText,
2745
3023
  {
2746
3024
  primary: label,
@@ -2749,12 +3027,12 @@ var UserProfileDisplay = ({
2749
3027
  ) }, key)) })
2750
3028
  ] })
2751
3029
  ] }),
2752
- /* @__PURE__ */ jsxs8(Box7, { mt: 2, display: "flex", justifyContent: "space-between", alignItems: "center", children: [
2753
- /* @__PURE__ */ jsxs8(Typography7, { variant: "caption", color: "text.secondary", children: [
3030
+ /* @__PURE__ */ jsxs9(Box8, { mt: 2, display: "flex", justifyContent: "space-between", alignItems: "center", children: [
3031
+ /* @__PURE__ */ jsxs9(Typography7, { variant: "caption", color: "text.secondary", children: [
2754
3032
  "\xDAltima actualizaci\xF3n: ",
2755
3033
  formatDate(displayData.updatedAt)
2756
3034
  ] }),
2757
- /* @__PURE__ */ jsx11(IconButton, { size: "small", onClick: refreshProfile, disabled: loading, children: /* @__PURE__ */ jsx11(Typography7, { variant: "caption", children: "Actualizar" }) })
3035
+ /* @__PURE__ */ jsx12(IconButton, { size: "small", onClick: refreshProfile, disabled: loading, children: /* @__PURE__ */ jsx12(Typography7, { variant: "caption", children: "Actualizar" }) })
2758
3036
  ] })
2759
3037
  ] }) })
2760
3038
  ] });
@@ -2765,11 +3043,11 @@ var UserProfileDisplay_default = UserProfileDisplay;
2765
3043
  import { useRef as useRef4 } from "react";
2766
3044
  import { useTranslation as useTranslation4 } from "react-i18next";
2767
3045
  import {
2768
- Box as Box10,
3046
+ Box as Box11,
2769
3047
  Typography as Typography10,
2770
3048
  Button as Button7,
2771
3049
  Stack as Stack3,
2772
- Alert as Alert7,
3050
+ Alert as Alert8,
2773
3051
  Divider as Divider3
2774
3052
  } from "@mui/material";
2775
3053
  import { Add } from "@mui/icons-material";
@@ -2778,7 +3056,7 @@ import { Add } from "@mui/icons-material";
2778
3056
  import { forwardRef } from "react";
2779
3057
  import { useTranslation as useTranslation3 } from "react-i18next";
2780
3058
  import {
2781
- Box as Box9,
3059
+ Box as Box10,
2782
3060
  FormControl,
2783
3061
  InputLabel,
2784
3062
  Select,
@@ -2794,10 +3072,10 @@ import {
2794
3072
  import { Delete, SelectAll as SelectAll2, ClearAll as ClearAll2 } from "@mui/icons-material";
2795
3073
 
2796
3074
  // src/components/PublicPolicies/FieldSelector/FieldSelector.tsx
2797
- import { useState as useState9, useEffect as useEffect9, useRef as useRef3 } from "react";
3075
+ import { useState as useState10, useEffect as useEffect10, useRef as useRef3 } from "react";
2798
3076
  import { useTranslation as useTranslation2 } from "react-i18next";
2799
3077
  import {
2800
- Box as Box8,
3078
+ Box as Box9,
2801
3079
  Typography as Typography8,
2802
3080
  Button as Button5,
2803
3081
  Stack,
@@ -2811,7 +3089,7 @@ import {
2811
3089
  SelectAll,
2812
3090
  ClearAll
2813
3091
  } from "@mui/icons-material";
2814
- import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
3092
+ import { jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
2815
3093
  var FieldSelector = ({
2816
3094
  value,
2817
3095
  onChange,
@@ -2820,9 +3098,9 @@ var FieldSelector = ({
2820
3098
  disabled = false
2821
3099
  }) => {
2822
3100
  const { t } = useTranslation2();
2823
- const [mode, setMode] = useState9("custom");
3101
+ const [mode, setMode] = useState10("custom");
2824
3102
  const isUpdatingRef = useRef3(false);
2825
- useEffect9(() => {
3103
+ useEffect10(() => {
2826
3104
  const current = value || { allow: [], owner_allow: [], deny: [] };
2827
3105
  const all = new Set(availableFields);
2828
3106
  const allow = (current.allow || []).filter((f) => all.has(f));
@@ -2878,20 +3156,20 @@ var FieldSelector = ({
2878
3156
  }, 0);
2879
3157
  };
2880
3158
  if (availableFields.length === 0) {
2881
- return /* @__PURE__ */ jsxs9(Box8, { children: [
2882
- /* @__PURE__ */ jsx12(Typography8, { variant: "body2", color: "text.secondary", sx: { mb: 1 }, children: t("modules.form.publicPolicies.fields.conditions.label") }),
2883
- /* @__PURE__ */ jsx12(Typography8, { variant: "body2", color: "text.secondary", sx: { fontStyle: "italic" }, children: t("modules.form.publicPolicies.fields.conditions.noFieldsAvailable") }),
2884
- error && /* @__PURE__ */ jsx12(FormHelperText, { error: true, sx: { mt: 1 }, children: error })
3159
+ return /* @__PURE__ */ jsxs10(Box9, { children: [
3160
+ /* @__PURE__ */ jsx13(Typography8, { variant: "body2", color: "text.secondary", sx: { mb: 1 }, children: t("modules.form.publicPolicies.fields.conditions.label") }),
3161
+ /* @__PURE__ */ jsx13(Typography8, { variant: "body2", color: "text.secondary", sx: { fontStyle: "italic" }, children: t("modules.form.publicPolicies.fields.conditions.noFieldsAvailable") }),
3162
+ error && /* @__PURE__ */ jsx13(FormHelperText, { error: true, sx: { mt: 1 }, children: error })
2885
3163
  ] });
2886
3164
  }
2887
- return /* @__PURE__ */ jsxs9(Box8, { children: [
2888
- /* @__PURE__ */ jsx12(Typography8, { variant: "body2", color: "text.secondary", sx: { mb: 2 }, children: t("modules.form.publicPolicies.fields.conditions.label") }),
2889
- /* @__PURE__ */ jsxs9(Stack, { direction: "row", spacing: 1, sx: { mb: 3 }, children: [
2890
- /* @__PURE__ */ jsx12(
3165
+ return /* @__PURE__ */ jsxs10(Box9, { children: [
3166
+ /* @__PURE__ */ jsx13(Typography8, { variant: "body2", color: "text.secondary", sx: { mb: 2 }, children: t("modules.form.publicPolicies.fields.conditions.label") }),
3167
+ /* @__PURE__ */ jsxs10(Stack, { direction: "row", spacing: 1, sx: { mb: 3 }, children: [
3168
+ /* @__PURE__ */ jsx13(
2891
3169
  Button5,
2892
3170
  {
2893
3171
  variant: mode === "all" ? "contained" : "outlined",
2894
- startIcon: /* @__PURE__ */ jsx12(SelectAll, {}),
3172
+ startIcon: /* @__PURE__ */ jsx13(SelectAll, {}),
2895
3173
  onClick: setAllAllow,
2896
3174
  disabled,
2897
3175
  size: "small",
@@ -2905,11 +3183,11 @@ var FieldSelector = ({
2905
3183
  children: t("modules.form.publicPolicies.fields.conditions.allFields")
2906
3184
  }
2907
3185
  ),
2908
- /* @__PURE__ */ jsx12(
3186
+ /* @__PURE__ */ jsx13(
2909
3187
  Button5,
2910
3188
  {
2911
3189
  variant: mode === "none" ? "contained" : "outlined",
2912
- startIcon: /* @__PURE__ */ jsx12(ClearAll, {}),
3190
+ startIcon: /* @__PURE__ */ jsx13(ClearAll, {}),
2913
3191
  onClick: setAllDeny,
2914
3192
  disabled,
2915
3193
  size: "small",
@@ -2924,14 +3202,14 @@ var FieldSelector = ({
2924
3202
  }
2925
3203
  )
2926
3204
  ] }),
2927
- /* @__PURE__ */ jsxs9(Box8, { sx: { p: 2, border: "1px solid #d1d9e0", borderRadius: 1, backgroundColor: "#f6f8fa" }, children: [
2928
- /* @__PURE__ */ jsx12(Typography8, { variant: "body2", color: "text.secondary", sx: { mb: 2 }, children: t("modules.form.publicPolicies.fields.conditions.help") }),
2929
- /* @__PURE__ */ jsx12(Stack, { spacing: 1, children: availableFields.map((fieldName) => {
3205
+ /* @__PURE__ */ jsxs10(Box9, { sx: { p: 2, border: "1px solid #d1d9e0", borderRadius: 1, backgroundColor: "#f6f8fa" }, children: [
3206
+ /* @__PURE__ */ jsx13(Typography8, { variant: "body2", color: "text.secondary", sx: { mb: 2 }, children: t("modules.form.publicPolicies.fields.conditions.help") }),
3207
+ /* @__PURE__ */ jsx13(Stack, { spacing: 1, children: availableFields.map((fieldName) => {
2930
3208
  const fieldState = getFieldState(fieldName);
2931
- return /* @__PURE__ */ jsxs9(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [
2932
- /* @__PURE__ */ jsx12(Typography8, { variant: "body2", sx: { minWidth: 100, fontFamily: "monospace" }, children: fieldName }),
2933
- /* @__PURE__ */ jsxs9(ToggleButtonGroup, { value: fieldState, exclusive: true, size: "small", children: [
2934
- /* @__PURE__ */ jsxs9(
3209
+ return /* @__PURE__ */ jsxs10(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [
3210
+ /* @__PURE__ */ jsx13(Typography8, { variant: "body2", sx: { minWidth: 100, fontFamily: "monospace" }, children: fieldName }),
3211
+ /* @__PURE__ */ jsxs10(ToggleButtonGroup, { value: fieldState, exclusive: true, size: "small", children: [
3212
+ /* @__PURE__ */ jsxs10(
2935
3213
  ToggleButton,
2936
3214
  {
2937
3215
  value: "allow",
@@ -2955,12 +3233,12 @@ var FieldSelector = ({
2955
3233
  }
2956
3234
  },
2957
3235
  children: [
2958
- /* @__PURE__ */ jsx12(CheckCircle, { sx: { fontSize: 16, mr: 0.5 } }),
3236
+ /* @__PURE__ */ jsx13(CheckCircle, { sx: { fontSize: 16, mr: 0.5 } }),
2959
3237
  t("modules.form.publicPolicies.fields.conditions.states.allow")
2960
3238
  ]
2961
3239
  }
2962
3240
  ),
2963
- /* @__PURE__ */ jsx12(
3241
+ /* @__PURE__ */ jsx13(
2964
3242
  ToggleButton,
2965
3243
  {
2966
3244
  value: "owner_allow",
@@ -2986,7 +3264,7 @@ var FieldSelector = ({
2986
3264
  children: t("modules.form.publicPolicies.fields.conditions.states.ownerAllow")
2987
3265
  }
2988
3266
  ),
2989
- /* @__PURE__ */ jsxs9(
3267
+ /* @__PURE__ */ jsxs10(
2990
3268
  ToggleButton,
2991
3269
  {
2992
3270
  value: "deny",
@@ -3010,7 +3288,7 @@ var FieldSelector = ({
3010
3288
  }
3011
3289
  },
3012
3290
  children: [
3013
- /* @__PURE__ */ jsx12(Cancel, { sx: { fontSize: 16, mr: 0.5 } }),
3291
+ /* @__PURE__ */ jsx13(Cancel, { sx: { fontSize: 16, mr: 0.5 } }),
3014
3292
  t("modules.form.publicPolicies.fields.conditions.states.deny")
3015
3293
  ]
3016
3294
  }
@@ -3019,7 +3297,7 @@ var FieldSelector = ({
3019
3297
  ] }, fieldName);
3020
3298
  }) })
3021
3299
  ] }),
3022
- error && /* @__PURE__ */ jsx12(FormHelperText, { error: true, sx: { mt: 1 }, children: error })
3300
+ error && /* @__PURE__ */ jsx13(FormHelperText, { error: true, sx: { mt: 1 }, children: error })
3023
3301
  ] });
3024
3302
  };
3025
3303
  var FieldSelector_default = FieldSelector;
@@ -3034,7 +3312,7 @@ var PREFERRED_POLICY_ORDER = [
3034
3312
  ];
3035
3313
 
3036
3314
  // src/components/PublicPolicies/PolicyItem/PolicyItem.tsx
3037
- import { jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
3315
+ import { jsx as jsx14, jsxs as jsxs11 } from "react/jsx-runtime";
3038
3316
  var PolicyItem = forwardRef(({
3039
3317
  policy,
3040
3318
  onChange,
@@ -3051,7 +3329,7 @@ var PolicyItem = forwardRef(({
3051
3329
  value: a,
3052
3330
  label: t(`modules.form.publicPolicies.fields.action.options.${a}`)
3053
3331
  }));
3054
- return /* @__PURE__ */ jsxs10(
3332
+ return /* @__PURE__ */ jsxs11(
3055
3333
  Paper,
3056
3334
  {
3057
3335
  ref,
@@ -3063,8 +3341,8 @@ var PolicyItem = forwardRef(({
3063
3341
  backgroundColor: "#ffffff"
3064
3342
  },
3065
3343
  children: [
3066
- /* @__PURE__ */ jsxs10(Box9, { sx: { display: "flex", justifyContent: "space-between", alignItems: "flex-start", mb: 3 }, children: [
3067
- /* @__PURE__ */ jsx13(
3344
+ /* @__PURE__ */ jsxs11(Box10, { sx: { display: "flex", justifyContent: "space-between", alignItems: "flex-start", mb: 3 }, children: [
3345
+ /* @__PURE__ */ jsx14(
3068
3346
  Typography9,
3069
3347
  {
3070
3348
  variant: "subtitle1",
@@ -3076,7 +3354,7 @@ var PolicyItem = forwardRef(({
3076
3354
  children: t("modules.form.publicPolicies.policyTitle")
3077
3355
  }
3078
3356
  ),
3079
- /* @__PURE__ */ jsx13(
3357
+ /* @__PURE__ */ jsx14(
3080
3358
  IconButton2,
3081
3359
  {
3082
3360
  onClick: onRemove,
@@ -3090,14 +3368,14 @@ var PolicyItem = forwardRef(({
3090
3368
  backgroundColor: "rgba(207, 34, 46, 0.1)"
3091
3369
  }
3092
3370
  },
3093
- children: /* @__PURE__ */ jsx13(Delete, {})
3371
+ children: /* @__PURE__ */ jsx14(Delete, {})
3094
3372
  }
3095
3373
  )
3096
3374
  ] }),
3097
- /* @__PURE__ */ jsxs10(Stack2, { spacing: 3, children: [
3098
- /* @__PURE__ */ jsx13(Stack2, { direction: { xs: "column", md: "row" }, spacing: 2, children: /* @__PURE__ */ jsx13(Box9, { sx: { flex: 1, minWidth: 200 }, children: /* @__PURE__ */ jsxs10(FormControl, { fullWidth: true, children: [
3099
- /* @__PURE__ */ jsx13(InputLabel, { children: t("modules.form.publicPolicies.fields.action.label") }),
3100
- /* @__PURE__ */ jsx13(
3375
+ /* @__PURE__ */ jsxs11(Stack2, { spacing: 3, children: [
3376
+ /* @__PURE__ */ jsx14(Stack2, { direction: { xs: "column", md: "row" }, spacing: 2, children: /* @__PURE__ */ jsx14(Box10, { sx: { flex: 1, minWidth: 200 }, children: /* @__PURE__ */ jsxs11(FormControl, { fullWidth: true, children: [
3377
+ /* @__PURE__ */ jsx14(InputLabel, { children: t("modules.form.publicPolicies.fields.action.label") }),
3378
+ /* @__PURE__ */ jsx14(
3101
3379
  Select,
3102
3380
  {
3103
3381
  value: policy.action,
@@ -3127,20 +3405,20 @@ var PolicyItem = forwardRef(({
3127
3405
  },
3128
3406
  children: actionOptions.map((option) => {
3129
3407
  const disabledOption = takenActions.has(option.value);
3130
- return /* @__PURE__ */ jsx13(MenuItem, { value: option.value, disabled: disabledOption, children: option.label }, option.value);
3408
+ return /* @__PURE__ */ jsx14(MenuItem, { value: option.value, disabled: disabledOption, children: option.label }, option.value);
3131
3409
  })
3132
3410
  }
3133
3411
  ),
3134
- error && /* @__PURE__ */ jsx13(FormHelperText2, { error: true, children: error })
3412
+ error && /* @__PURE__ */ jsx14(FormHelperText2, { error: true, children: error })
3135
3413
  ] }) }) }),
3136
- policy.action === "delete" ? /* @__PURE__ */ jsxs10(Box9, { children: [
3137
- /* @__PURE__ */ jsx13(Typography9, { variant: "body2", color: "text.secondary", sx: { mb: 2 }, children: t("modules.form.publicPolicies.fields.conditions.label") }),
3138
- /* @__PURE__ */ jsxs10(Stack2, { direction: "row", spacing: 1, sx: { mb: 3 }, children: [
3139
- /* @__PURE__ */ jsx13(
3414
+ policy.action === "delete" ? /* @__PURE__ */ jsxs11(Box10, { children: [
3415
+ /* @__PURE__ */ jsx14(Typography9, { variant: "body2", color: "text.secondary", sx: { mb: 2 }, children: t("modules.form.publicPolicies.fields.conditions.label") }),
3416
+ /* @__PURE__ */ jsxs11(Stack2, { direction: "row", spacing: 1, sx: { mb: 3 }, children: [
3417
+ /* @__PURE__ */ jsx14(
3140
3418
  Button6,
3141
3419
  {
3142
3420
  variant: policy.permission === "*" ? "contained" : "outlined",
3143
- startIcon: /* @__PURE__ */ jsx13(SelectAll2, {}),
3421
+ startIcon: /* @__PURE__ */ jsx14(SelectAll2, {}),
3144
3422
  onClick: () => onChange({ ...policy, permission: "*" }),
3145
3423
  disabled: isSubmitting,
3146
3424
  size: "small",
@@ -3155,7 +3433,7 @@ var PolicyItem = forwardRef(({
3155
3433
  children: t("modules.form.publicPolicies.fields.conditions.allFields")
3156
3434
  }
3157
3435
  ),
3158
- /* @__PURE__ */ jsx13(
3436
+ /* @__PURE__ */ jsx14(
3159
3437
  Button6,
3160
3438
  {
3161
3439
  variant: policy.permission === "owner" ? "contained" : "outlined",
@@ -3173,11 +3451,11 @@ var PolicyItem = forwardRef(({
3173
3451
  children: t("modules.form.publicPolicies.fields.conditions.states.ownerAllow")
3174
3452
  }
3175
3453
  ),
3176
- /* @__PURE__ */ jsx13(
3454
+ /* @__PURE__ */ jsx14(
3177
3455
  Button6,
3178
3456
  {
3179
3457
  variant: policy.permission === "deny" ? "contained" : "outlined",
3180
- startIcon: /* @__PURE__ */ jsx13(ClearAll2, {}),
3458
+ startIcon: /* @__PURE__ */ jsx14(ClearAll2, {}),
3181
3459
  onClick: () => onChange({ ...policy, permission: "deny" }),
3182
3460
  disabled: isSubmitting,
3183
3461
  size: "small",
@@ -3193,7 +3471,7 @@ var PolicyItem = forwardRef(({
3193
3471
  }
3194
3472
  )
3195
3473
  ] })
3196
- ] }) : /* @__PURE__ */ jsx13(
3474
+ ] }) : /* @__PURE__ */ jsx14(
3197
3475
  FieldSelector_default,
3198
3476
  {
3199
3477
  value: policy.fields || { allow: [], owner_allow: [], deny: [] },
@@ -3202,8 +3480,8 @@ var PolicyItem = forwardRef(({
3202
3480
  disabled: isSubmitting
3203
3481
  }
3204
3482
  ),
3205
- /* @__PURE__ */ jsx13(Paper, { variant: "outlined", sx: { p: 2, backgroundColor: "#f9fafb" }, children: policy.action === "delete" ? /* @__PURE__ */ jsxs10(Typography9, { variant: "body2", sx: { fontFamily: "monospace", color: "text.secondary" }, children: [
3206
- /* @__PURE__ */ jsxs10(Box9, { component: "span", sx: {
3483
+ /* @__PURE__ */ jsx14(Paper, { variant: "outlined", sx: { p: 2, backgroundColor: "#f9fafb" }, children: policy.action === "delete" ? /* @__PURE__ */ jsxs11(Typography9, { variant: "body2", sx: { fontFamily: "monospace", color: "text.secondary" }, children: [
3484
+ /* @__PURE__ */ jsxs11(Box10, { component: "span", sx: {
3207
3485
  color: policy.permission === "*" ? "#16a34a" : policy.permission === "owner" ? "#0ea5e9" : "#dc2626"
3208
3486
  }, children: [
3209
3487
  t("modules.form.publicPolicies.fields.conditions.states.allow"),
@@ -3211,25 +3489,25 @@ var PolicyItem = forwardRef(({
3211
3489
  ] }),
3212
3490
  " ",
3213
3491
  policy.permission || "-"
3214
- ] }) : /* @__PURE__ */ jsxs10(Stack2, { spacing: 0.5, divider: /* @__PURE__ */ jsx13(Divider2, { sx: { borderColor: "#e5e7eb" } }), children: [
3215
- /* @__PURE__ */ jsxs10(Typography9, { variant: "body2", sx: { fontFamily: "monospace", color: "text.secondary" }, children: [
3216
- /* @__PURE__ */ jsxs10(Box9, { component: "span", sx: { color: "#16a34a" }, children: [
3492
+ ] }) : /* @__PURE__ */ jsxs11(Stack2, { spacing: 0.5, divider: /* @__PURE__ */ jsx14(Divider2, { sx: { borderColor: "#e5e7eb" } }), children: [
3493
+ /* @__PURE__ */ jsxs11(Typography9, { variant: "body2", sx: { fontFamily: "monospace", color: "text.secondary" }, children: [
3494
+ /* @__PURE__ */ jsxs11(Box10, { component: "span", sx: { color: "#16a34a" }, children: [
3217
3495
  t("modules.form.publicPolicies.fields.conditions.states.allow"),
3218
3496
  ":"
3219
3497
  ] }),
3220
3498
  " ",
3221
3499
  (policy?.fields?.allow || []).join(", ") || "-"
3222
3500
  ] }),
3223
- /* @__PURE__ */ jsxs10(Typography9, { variant: "body2", sx: { fontFamily: "monospace", color: "text.secondary" }, children: [
3224
- /* @__PURE__ */ jsxs10(Box9, { component: "span", sx: { color: "#0ea5e9" }, children: [
3501
+ /* @__PURE__ */ jsxs11(Typography9, { variant: "body2", sx: { fontFamily: "monospace", color: "text.secondary" }, children: [
3502
+ /* @__PURE__ */ jsxs11(Box10, { component: "span", sx: { color: "#0ea5e9" }, children: [
3225
3503
  t("modules.form.publicPolicies.fields.conditions.states.ownerAllow"),
3226
3504
  ":"
3227
3505
  ] }),
3228
3506
  " ",
3229
3507
  (policy?.fields?.owner_allow || []).join(", ") || "-"
3230
3508
  ] }),
3231
- /* @__PURE__ */ jsxs10(Typography9, { variant: "body2", sx: { fontFamily: "monospace", color: "text.secondary" }, children: [
3232
- /* @__PURE__ */ jsxs10(Box9, { component: "span", sx: { color: "#dc2626" }, children: [
3509
+ /* @__PURE__ */ jsxs11(Typography9, { variant: "body2", sx: { fontFamily: "monospace", color: "text.secondary" }, children: [
3510
+ /* @__PURE__ */ jsxs11(Box10, { component: "span", sx: { color: "#dc2626" }, children: [
3233
3511
  t("modules.form.publicPolicies.fields.conditions.states.deny"),
3234
3512
  ":"
3235
3513
  ] }),
@@ -3245,7 +3523,7 @@ var PolicyItem = forwardRef(({
3245
3523
  var PolicyItem_default = PolicyItem;
3246
3524
 
3247
3525
  // src/components/PublicPolicies/Policies.tsx
3248
- import { Fragment as Fragment8, jsx as jsx14, jsxs as jsxs11 } from "react/jsx-runtime";
3526
+ import { Fragment as Fragment8, jsx as jsx15, jsxs as jsxs12 } from "react/jsx-runtime";
3249
3527
  var generateId = () => {
3250
3528
  const c = globalThis?.crypto;
3251
3529
  if (c && typeof c.randomUUID === "function") return c.randomUUID();
@@ -3300,11 +3578,11 @@ var Policies = ({
3300
3578
  return typeof msg === "string" ? msg : null;
3301
3579
  })();
3302
3580
  const usedActions = new Set((policies || []).map((p) => p.action));
3303
- return /* @__PURE__ */ jsxs11(Fragment8, { children: [
3304
- /* @__PURE__ */ jsx14(Divider3, { sx: { borderColor: "#e0e4e7" } }),
3305
- /* @__PURE__ */ jsxs11(Box10, { children: [
3306
- /* @__PURE__ */ jsx14(Box10, { display: "flex", justifyContent: "space-between", alignItems: "center", mb: 3, children: /* @__PURE__ */ jsxs11(Box10, { children: [
3307
- /* @__PURE__ */ jsx14(
3581
+ return /* @__PURE__ */ jsxs12(Fragment8, { children: [
3582
+ /* @__PURE__ */ jsx15(Divider3, { sx: { borderColor: "#e0e4e7" } }),
3583
+ /* @__PURE__ */ jsxs12(Box11, { children: [
3584
+ /* @__PURE__ */ jsx15(Box11, { display: "flex", justifyContent: "space-between", alignItems: "center", mb: 3, children: /* @__PURE__ */ jsxs12(Box11, { children: [
3585
+ /* @__PURE__ */ jsx15(
3308
3586
  Typography10,
3309
3587
  {
3310
3588
  variant: "h6",
@@ -3316,7 +3594,7 @@ var Policies = ({
3316
3594
  children: t("modules.form.publicPolicies.title")
3317
3595
  }
3318
3596
  ),
3319
- /* @__PURE__ */ jsx14(
3597
+ /* @__PURE__ */ jsx15(
3320
3598
  Typography10,
3321
3599
  {
3322
3600
  variant: "body2",
@@ -3326,9 +3604,9 @@ var Policies = ({
3326
3604
  }
3327
3605
  )
3328
3606
  ] }) }),
3329
- arrayError && /* @__PURE__ */ jsx14(Alert7, { severity: "error", sx: { mb: 3 }, children: arrayError }),
3330
- /* @__PURE__ */ jsxs11(Stack3, { spacing: 3, children: [
3331
- (policies || []).length === 0 ? /* @__PURE__ */ jsx14(Alert7, { severity: "info", children: t("modules.form.publicPolicies.noPolicies") }) : policies.map((policy, index) => /* @__PURE__ */ jsx14(
3607
+ arrayError && /* @__PURE__ */ jsx15(Alert8, { severity: "error", sx: { mb: 3 }, children: arrayError }),
3608
+ /* @__PURE__ */ jsxs12(Stack3, { spacing: 3, children: [
3609
+ (policies || []).length === 0 ? /* @__PURE__ */ jsx15(Alert8, { severity: "info", children: t("modules.form.publicPolicies.noPolicies") }) : policies.map((policy, index) => /* @__PURE__ */ jsx15(
3332
3610
  PolicyItem_default,
3333
3611
  {
3334
3612
  ref: (el) => {
@@ -3348,12 +3626,12 @@ var Policies = ({
3348
3626
  },
3349
3627
  policy.id
3350
3628
  )),
3351
- canAddPolicy && /* @__PURE__ */ jsx14(Box10, { children: /* @__PURE__ */ jsx14(
3629
+ canAddPolicy && /* @__PURE__ */ jsx15(Box11, { children: /* @__PURE__ */ jsx15(
3352
3630
  Button7,
3353
3631
  {
3354
3632
  type: "button",
3355
3633
  variant: "outlined",
3356
- startIcon: /* @__PURE__ */ jsx14(Add, {}),
3634
+ startIcon: /* @__PURE__ */ jsx15(Add, {}),
3357
3635
  onClick: addPolicy,
3358
3636
  disabled: isSubmitting,
3359
3637
  sx: {
@@ -3374,13 +3652,13 @@ var Policies = ({
3374
3652
  var Policies_default = Policies;
3375
3653
 
3376
3654
  // src/components/LoginComponent.tsx
3377
- import { useState as useState10 } from "react";
3378
- import { Button as Button8, TextField as TextField5, Box as Box11, Alert as Alert8, Typography as Typography11, CircularProgress as CircularProgress7 } from "@mui/material";
3379
- import { jsx as jsx15, jsxs as jsxs12 } from "react/jsx-runtime";
3655
+ import { useState as useState11 } from "react";
3656
+ import { Button as Button8, TextField as TextField5, Box as Box12, Alert as Alert9, Typography as Typography11, CircularProgress as CircularProgress7 } from "@mui/material";
3657
+ import { jsx as jsx16, jsxs as jsxs13 } from "react/jsx-runtime";
3380
3658
  function LoginComponent() {
3381
- const [email, setEmail] = useState10("");
3382
- const [password, setPassword] = useState10("");
3383
- const [showForm, setShowForm] = useState10(false);
3659
+ const [email, setEmail] = useState11("");
3660
+ const [password, setPassword] = useState11("");
3661
+ const [showForm, setShowForm] = useState11(false);
3384
3662
  const {
3385
3663
  isAuthenticated,
3386
3664
  isLoading,
@@ -3411,30 +3689,30 @@ function LoginComponent() {
3411
3689
  await refreshTokens();
3412
3690
  };
3413
3691
  if (isAuthenticated) {
3414
- return /* @__PURE__ */ jsxs12(Box11, { sx: { maxWidth: 600, mx: "auto", p: 3 }, children: [
3415
- /* @__PURE__ */ jsx15(Typography11, { variant: "h4", gutterBottom: true, children: "Welcome! \u{1F389}" }),
3416
- /* @__PURE__ */ jsx15(Alert8, { severity: "success", sx: { mb: 3 }, children: "You are successfully logged in with Refresh Token Pattern enabled" }),
3417
- /* @__PURE__ */ jsxs12(Box11, { sx: { mb: 3, p: 2, bgcolor: "background.paper", border: 1, borderColor: "divider", borderRadius: 1 }, children: [
3418
- /* @__PURE__ */ jsx15(Typography11, { variant: "h6", gutterBottom: true, children: "Token Status" }),
3419
- /* @__PURE__ */ jsxs12(Typography11, { variant: "body2", color: "text.secondary", children: [
3692
+ return /* @__PURE__ */ jsxs13(Box12, { sx: { maxWidth: 600, mx: "auto", p: 3 }, children: [
3693
+ /* @__PURE__ */ jsx16(Typography11, { variant: "h4", gutterBottom: true, children: "Welcome! \u{1F389}" }),
3694
+ /* @__PURE__ */ jsx16(Alert9, { severity: "success", sx: { mb: 3 }, children: "You are successfully logged in with Refresh Token Pattern enabled" }),
3695
+ /* @__PURE__ */ jsxs13(Box12, { sx: { mb: 3, p: 2, bgcolor: "background.paper", border: 1, borderColor: "divider", borderRadius: 1 }, children: [
3696
+ /* @__PURE__ */ jsx16(Typography11, { variant: "h6", gutterBottom: true, children: "Token Status" }),
3697
+ /* @__PURE__ */ jsxs13(Typography11, { variant: "body2", color: "text.secondary", children: [
3420
3698
  "Access Token expires in: ",
3421
3699
  Math.round(expiresIn / 1e3 / 60),
3422
3700
  " minutes"
3423
3701
  ] }),
3424
- isExpiringSoon && /* @__PURE__ */ jsx15(Alert8, { severity: "warning", sx: { mt: 1 }, children: "Token expires soon - automatic refresh will happen" })
3702
+ isExpiringSoon && /* @__PURE__ */ jsx16(Alert9, { severity: "warning", sx: { mt: 1 }, children: "Token expires soon - automatic refresh will happen" })
3425
3703
  ] }),
3426
- /* @__PURE__ */ jsxs12(Box11, { sx: { display: "flex", gap: 2, flexWrap: "wrap" }, children: [
3427
- /* @__PURE__ */ jsx15(
3704
+ /* @__PURE__ */ jsxs13(Box12, { sx: { display: "flex", gap: 2, flexWrap: "wrap" }, children: [
3705
+ /* @__PURE__ */ jsx16(
3428
3706
  Button8,
3429
3707
  {
3430
3708
  variant: "contained",
3431
3709
  onClick: handleRefreshTokens,
3432
3710
  disabled: isLoading,
3433
- startIcon: isLoading ? /* @__PURE__ */ jsx15(CircularProgress7, { size: 16 }) : null,
3711
+ startIcon: isLoading ? /* @__PURE__ */ jsx16(CircularProgress7, { size: 16 }) : null,
3434
3712
  children: "Refresh Tokens"
3435
3713
  }
3436
3714
  ),
3437
- /* @__PURE__ */ jsx15(
3715
+ /* @__PURE__ */ jsx16(
3438
3716
  Button8,
3439
3717
  {
3440
3718
  variant: "outlined",
@@ -3445,13 +3723,13 @@ function LoginComponent() {
3445
3723
  }
3446
3724
  )
3447
3725
  ] }),
3448
- error && /* @__PURE__ */ jsx15(Alert8, { severity: "error", sx: { mt: 2 }, onClose: clearError, children: error })
3726
+ error && /* @__PURE__ */ jsx16(Alert9, { severity: "error", sx: { mt: 2 }, onClose: clearError, children: error })
3449
3727
  ] });
3450
3728
  }
3451
- return /* @__PURE__ */ jsxs12(Box11, { sx: { maxWidth: 400, mx: "auto", p: 3 }, children: [
3452
- /* @__PURE__ */ jsx15(Typography11, { variant: "h4", gutterBottom: true, align: "center", children: "Login with Refresh Tokens" }),
3453
- /* @__PURE__ */ jsx15(Alert8, { severity: "info", sx: { mb: 3 }, children: "This demo shows the new Refresh Token Pattern with automatic session management" }),
3454
- !showForm ? /* @__PURE__ */ jsx15(
3729
+ return /* @__PURE__ */ jsxs13(Box12, { sx: { maxWidth: 400, mx: "auto", p: 3 }, children: [
3730
+ /* @__PURE__ */ jsx16(Typography11, { variant: "h4", gutterBottom: true, align: "center", children: "Login with Refresh Tokens" }),
3731
+ /* @__PURE__ */ jsx16(Alert9, { severity: "info", sx: { mb: 3 }, children: "This demo shows the new Refresh Token Pattern with automatic session management" }),
3732
+ !showForm ? /* @__PURE__ */ jsx16(
3455
3733
  Button8,
3456
3734
  {
3457
3735
  fullWidth: true,
@@ -3461,8 +3739,8 @@ function LoginComponent() {
3461
3739
  sx: { mt: 2 },
3462
3740
  children: "Show Login Form"
3463
3741
  }
3464
- ) : /* @__PURE__ */ jsxs12("form", { onSubmit: handleLogin, children: [
3465
- /* @__PURE__ */ jsx15(
3742
+ ) : /* @__PURE__ */ jsxs13("form", { onSubmit: handleLogin, children: [
3743
+ /* @__PURE__ */ jsx16(
3466
3744
  TextField5,
3467
3745
  {
3468
3746
  fullWidth: true,
@@ -3475,7 +3753,7 @@ function LoginComponent() {
3475
3753
  autoComplete: "email"
3476
3754
  }
3477
3755
  ),
3478
- /* @__PURE__ */ jsx15(
3756
+ /* @__PURE__ */ jsx16(
3479
3757
  TextField5,
3480
3758
  {
3481
3759
  fullWidth: true,
@@ -3488,7 +3766,7 @@ function LoginComponent() {
3488
3766
  autoComplete: "current-password"
3489
3767
  }
3490
3768
  ),
3491
- /* @__PURE__ */ jsx15(
3769
+ /* @__PURE__ */ jsx16(
3492
3770
  Button8,
3493
3771
  {
3494
3772
  type: "submit",
@@ -3496,29 +3774,29 @@ function LoginComponent() {
3496
3774
  variant: "contained",
3497
3775
  size: "large",
3498
3776
  disabled: isLoading,
3499
- startIcon: isLoading ? /* @__PURE__ */ jsx15(CircularProgress7, { size: 16 }) : null,
3777
+ startIcon: isLoading ? /* @__PURE__ */ jsx16(CircularProgress7, { size: 16 }) : null,
3500
3778
  sx: { mt: 3, mb: 2 },
3501
3779
  children: isLoading ? "Logging in..." : "Login"
3502
3780
  }
3503
3781
  )
3504
3782
  ] }),
3505
- error && /* @__PURE__ */ jsx15(Alert8, { severity: "error", sx: { mt: 2 }, onClose: clearError, children: error })
3783
+ error && /* @__PURE__ */ jsx16(Alert9, { severity: "error", sx: { mt: 2 }, onClose: clearError, children: error })
3506
3784
  ] });
3507
3785
  }
3508
3786
  function SessionStatus() {
3509
3787
  const { isAuthenticated, isLoading, isExpiringSoon, expiresIn } = useSessionContext();
3510
3788
  if (isLoading) {
3511
- return /* @__PURE__ */ jsxs12(Box11, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
3512
- /* @__PURE__ */ jsx15(CircularProgress7, { size: 16 }),
3513
- /* @__PURE__ */ jsx15(Typography11, { variant: "caption", children: "Loading session..." })
3789
+ return /* @__PURE__ */ jsxs13(Box12, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
3790
+ /* @__PURE__ */ jsx16(CircularProgress7, { size: 16 }),
3791
+ /* @__PURE__ */ jsx16(Typography11, { variant: "caption", children: "Loading session..." })
3514
3792
  ] });
3515
3793
  }
3516
3794
  if (!isAuthenticated) {
3517
- return /* @__PURE__ */ jsx15(Typography11, { variant: "caption", color: "text.secondary", children: "Not logged in" });
3795
+ return /* @__PURE__ */ jsx16(Typography11, { variant: "caption", color: "text.secondary", children: "Not logged in" });
3518
3796
  }
3519
- return /* @__PURE__ */ jsxs12(Box11, { children: [
3520
- /* @__PURE__ */ jsx15(Typography11, { variant: "caption", color: "success.main", children: "\u2713 Authenticated" }),
3521
- isExpiringSoon && /* @__PURE__ */ jsxs12(Typography11, { variant: "caption", color: "warning.main", display: "block", children: [
3797
+ return /* @__PURE__ */ jsxs13(Box12, { children: [
3798
+ /* @__PURE__ */ jsx16(Typography11, { variant: "caption", color: "success.main", children: "\u2713 Authenticated" }),
3799
+ isExpiringSoon && /* @__PURE__ */ jsxs13(Typography11, { variant: "caption", color: "warning.main", display: "block", children: [
3522
3800
  "\u26A0 Token expires in ",
3523
3801
  Math.round(expiresIn / 1e3 / 60),
3524
3802
  " min"
@@ -3527,29 +3805,29 @@ function SessionStatus() {
3527
3805
  }
3528
3806
 
3529
3807
  // src/hooks/useUserData.ts
3530
- import { useState as useState11, useEffect as useEffect10, useCallback as useCallback3, useRef as useRef5 } from "react";
3808
+ import { useState as useState12, useEffect as useEffect11, useCallback as useCallback4, useRef as useRef5 } from "react";
3531
3809
  import crudify4 from "@nocios/crudify-browser";
3532
3810
  var useUserData = (options = {}) => {
3533
3811
  const { autoFetch = true, retryOnError = false, maxRetries = 3 } = options;
3534
3812
  const { isAuthenticated, isInitialized, sessionData, tokens } = useSessionContext();
3535
- const [userData, setUserData] = useState11(null);
3536
- const [loading, setLoading] = useState11(false);
3537
- const [error, setError] = useState11(null);
3813
+ const [userData, setUserData] = useState12(null);
3814
+ const [loading, setLoading] = useState12(false);
3815
+ const [error, setError] = useState12(null);
3538
3816
  const abortControllerRef = useRef5(null);
3539
3817
  const mountedRef = useRef5(true);
3540
3818
  const requestIdRef = useRef5(0);
3541
3819
  const retryCountRef = useRef5(0);
3542
- const getUserEmail = useCallback3(() => {
3820
+ const getUserEmail = useCallback4(() => {
3543
3821
  if (!sessionData) return null;
3544
3822
  return sessionData.email || sessionData["cognito:username"] || null;
3545
3823
  }, [sessionData]);
3546
- const clearProfile = useCallback3(() => {
3824
+ const clearProfile = useCallback4(() => {
3547
3825
  setUserData(null);
3548
3826
  setError(null);
3549
3827
  setLoading(false);
3550
3828
  retryCountRef.current = 0;
3551
3829
  }, []);
3552
- const refreshProfile = useCallback3(async () => {
3830
+ const refreshProfile = useCallback4(async () => {
3553
3831
  const userEmail = getUserEmail();
3554
3832
  console.log("\u{1F464} useUserData - Refreshing profile for:", userEmail);
3555
3833
  if (!userEmail) {
@@ -3681,14 +3959,14 @@ var useUserData = (options = {}) => {
3681
3959
  }
3682
3960
  }
3683
3961
  }, [isInitialized, getUserEmail, retryOnError, maxRetries]);
3684
- useEffect10(() => {
3962
+ useEffect11(() => {
3685
3963
  if (autoFetch && isAuthenticated && isInitialized) {
3686
3964
  refreshProfile();
3687
3965
  } else if (!isAuthenticated) {
3688
3966
  clearProfile();
3689
3967
  }
3690
3968
  }, [autoFetch, isAuthenticated, isInitialized, refreshProfile, clearProfile]);
3691
- useEffect10(() => {
3969
+ useEffect11(() => {
3692
3970
  mountedRef.current = true;
3693
3971
  return () => {
3694
3972
  mountedRef.current = false;
@@ -3714,7 +3992,7 @@ var useUserData = (options = {}) => {
3714
3992
  };
3715
3993
 
3716
3994
  // src/hooks/useAuth.ts
3717
- import { useCallback as useCallback4 } from "react";
3995
+ import { useCallback as useCallback5 } from "react";
3718
3996
  var useAuth = () => {
3719
3997
  const {
3720
3998
  isAuthenticated,
@@ -3732,7 +4010,7 @@ var useAuth = () => {
3732
4010
  expiresIn,
3733
4011
  refreshExpiresIn
3734
4012
  } = useSessionContext();
3735
- const setToken = useCallback4((token) => {
4013
+ const setToken = useCallback5((token) => {
3736
4014
  if (token) {
3737
4015
  console.warn("useAuth.setToken() is deprecated. Use login() method instead for better security.");
3738
4016
  } else {
@@ -3767,7 +4045,7 @@ var useAuth = () => {
3767
4045
  };
3768
4046
 
3769
4047
  // src/hooks/useData.ts
3770
- import { useCallback as useCallback5 } from "react";
4048
+ import { useCallback as useCallback6 } from "react";
3771
4049
  import crudify5 from "@nocios/crudify-browser";
3772
4050
  var useData = () => {
3773
4051
  const {
@@ -3777,10 +4055,10 @@ var useData = () => {
3777
4055
  isAuthenticated,
3778
4056
  login: sessionLogin
3779
4057
  } = useSessionContext();
3780
- const isReady = useCallback5(() => {
4058
+ const isReady = useCallback6(() => {
3781
4059
  return isInitialized && !isLoading && !error;
3782
4060
  }, [isInitialized, isLoading, error]);
3783
- const waitForReady = useCallback5(async () => {
4061
+ const waitForReady = useCallback6(async () => {
3784
4062
  return new Promise((resolve, reject) => {
3785
4063
  const checkReady = () => {
3786
4064
  if (isReady()) {
@@ -3794,36 +4072,36 @@ var useData = () => {
3794
4072
  checkReady();
3795
4073
  });
3796
4074
  }, [isReady, error]);
3797
- const ensureReady = useCallback5(async () => {
4075
+ const ensureReady = useCallback6(async () => {
3798
4076
  if (!isReady()) {
3799
4077
  throw new Error("System not ready. Check isInitialized, isLoading, and error states.");
3800
4078
  }
3801
4079
  }, [isReady]);
3802
- const readItems = useCallback5(async (moduleKey, filter, options) => {
4080
+ const readItems = useCallback6(async (moduleKey, filter, options) => {
3803
4081
  await ensureReady();
3804
4082
  return await crudify5.readItems(moduleKey, filter || {}, options);
3805
4083
  }, [ensureReady]);
3806
- const readItem = useCallback5(async (moduleKey, filter, options) => {
4084
+ const readItem = useCallback6(async (moduleKey, filter, options) => {
3807
4085
  await ensureReady();
3808
4086
  return await crudify5.readItem(moduleKey, filter, options);
3809
4087
  }, [ensureReady]);
3810
- const createItem = useCallback5(async (moduleKey, data, options) => {
4088
+ const createItem = useCallback6(async (moduleKey, data, options) => {
3811
4089
  await ensureReady();
3812
4090
  return await crudify5.createItem(moduleKey, data, options);
3813
4091
  }, [ensureReady]);
3814
- const updateItem = useCallback5(async (moduleKey, data, options) => {
4092
+ const updateItem = useCallback6(async (moduleKey, data, options) => {
3815
4093
  await ensureReady();
3816
4094
  return await crudify5.updateItem(moduleKey, data, options);
3817
4095
  }, [ensureReady]);
3818
- const deleteItem = useCallback5(async (moduleKey, id, options) => {
4096
+ const deleteItem = useCallback6(async (moduleKey, id, options) => {
3819
4097
  await ensureReady();
3820
4098
  return await crudify5.deleteItem(moduleKey, id, options);
3821
4099
  }, [ensureReady]);
3822
- const transaction = useCallback5(async (operations, options) => {
4100
+ const transaction = useCallback6(async (operations, options) => {
3823
4101
  await ensureReady();
3824
4102
  return await crudify5.transaction(operations, options);
3825
4103
  }, [ensureReady]);
3826
- const login = useCallback5(async (email, password) => {
4104
+ const login = useCallback6(async (email, password) => {
3827
4105
  try {
3828
4106
  const result = await sessionLogin(email, password);
3829
4107
  if (result.success) {
@@ -3972,10 +4250,416 @@ var SecureStorage = class {
3972
4250
  };
3973
4251
  var secureSessionStorage = new SecureStorage("sessionStorage");
3974
4252
  var secureLocalStorage = new SecureStorage("localStorage");
4253
+
4254
+ // src/hooks/useCrudifyWithNotifications.ts
4255
+ import { useCallback as useCallback7 } from "react";
4256
+ import crudify6 from "@nocios/crudify-browser";
4257
+ var ERROR_SEVERITY_MAP2 = {
4258
+ // Errores de autenticación - warning porque el usuario puede corregirlos
4259
+ INVALID_CREDENTIALS: "warning",
4260
+ UNAUTHORIZED: "warning",
4261
+ INVALID_API_KEY: "error",
4262
+ // Errores de usuario/permisos - warning
4263
+ USER_NOT_FOUND: "warning",
4264
+ USER_NOT_ACTIVE: "warning",
4265
+ NO_PERMISSION: "warning",
4266
+ // Errores de datos - info porque pueden ser esperados
4267
+ ITEM_NOT_FOUND: "info",
4268
+ NOT_FOUND: "info",
4269
+ IN_USE: "warning",
4270
+ // Errores de validación - warning
4271
+ FIELD_ERROR: "warning",
4272
+ BAD_REQUEST: "warning",
4273
+ // Errores del sistema - error
4274
+ INTERNAL_SERVER_ERROR: "error",
4275
+ DATABASE_CONNECTION_ERROR: "error",
4276
+ INVALID_CONFIGURATION: "error",
4277
+ UNKNOWN_OPERATION: "error",
4278
+ // Rate limiting - warning con mayor duración
4279
+ TOO_MANY_REQUESTS: "warning"
4280
+ };
4281
+ var ERROR_TRANSLATION_MAP = {
4282
+ INVALID_CREDENTIALS: "errors.auth.INVALID_CREDENTIALS",
4283
+ UNAUTHORIZED: "errors.auth.UNAUTHORIZED",
4284
+ INVALID_API_KEY: "errors.auth.INVALID_API_KEY",
4285
+ USER_NOT_FOUND: "errors.auth.USER_NOT_FOUND",
4286
+ USER_NOT_ACTIVE: "errors.auth.USER_NOT_ACTIVE",
4287
+ NO_PERMISSION: "errors.auth.NO_PERMISSION",
4288
+ ITEM_NOT_FOUND: "errors.data.ITEM_NOT_FOUND",
4289
+ NOT_FOUND: "errors.data.NOT_FOUND",
4290
+ IN_USE: "errors.data.IN_USE",
4291
+ FIELD_ERROR: "errors.data.FIELD_ERROR",
4292
+ BAD_REQUEST: "errors.data.BAD_REQUEST",
4293
+ INTERNAL_SERVER_ERROR: "errors.system.INTERNAL_SERVER_ERROR",
4294
+ DATABASE_CONNECTION_ERROR: "errors.system.DATABASE_CONNECTION_ERROR",
4295
+ INVALID_CONFIGURATION: "errors.system.INVALID_CONFIGURATION",
4296
+ UNKNOWN_OPERATION: "errors.system.UNKNOWN_OPERATION",
4297
+ TOO_MANY_REQUESTS: "errors.system.TOO_MANY_REQUESTS"
4298
+ };
4299
+ var useCrudifyWithNotifications = (options = {}) => {
4300
+ const { showNotification } = useGlobalNotification();
4301
+ const {
4302
+ showSuccessNotifications = false,
4303
+ showErrorNotifications = true,
4304
+ customErrorMessages = {},
4305
+ defaultErrorMessage = "Ha ocurrido un error inesperado",
4306
+ autoHideDuration = 6e3,
4307
+ appStructure = [],
4308
+ translateFn = (key) => key
4309
+ // Fallback si no hay función de traducción
4310
+ } = options;
4311
+ const shouldShowNotification = useCallback7((response) => {
4312
+ if (!response.success && response.errors) {
4313
+ const hasFieldErrors = Object.keys(response.errors).some((key) => key !== "_error" && key !== "_graphql" && key !== "_transaction");
4314
+ if (hasFieldErrors) return false;
4315
+ if (response.errors._transaction?.includes("ONE_OR_MORE_OPERATIONS_FAILED")) return false;
4316
+ if (response.errors._error?.includes("TOO_MANY_REQUESTS")) return false;
4317
+ }
4318
+ if (!response.success && response.data?.response?.status === "TOO_MANY_REQUESTS") return false;
4319
+ return true;
4320
+ }, []);
4321
+ const getSafeTranslation = useCallback7(
4322
+ (key, fallback) => {
4323
+ const translated = translateFn(key);
4324
+ if (translated === key) return fallback || translateFn("error.unknown");
4325
+ return translated;
4326
+ },
4327
+ [translateFn]
4328
+ );
4329
+ const isCrudOperation = useCallback7((operation) => {
4330
+ return ["create", "update", "delete"].includes(operation);
4331
+ }, []);
4332
+ const shouldShowSuccessNotification = useCallback7(
4333
+ (operation, moduleKey) => {
4334
+ if (!showSuccessNotifications) return false;
4335
+ if (isCrudOperation(operation) && moduleKey) return true;
4336
+ return appStructure.some((action) => action.key === operation);
4337
+ },
4338
+ [showSuccessNotifications, appStructure, isCrudOperation]
4339
+ );
4340
+ const getSuccessMessage = useCallback7(
4341
+ (operation, moduleKey, actionConfig) => {
4342
+ const operationKey = actionConfig?.key && typeof actionConfig.key === "string" ? actionConfig.key : operation;
4343
+ const successKey = `action.onSuccess.${operationKey}`;
4344
+ const successMessage = getSafeTranslation(successKey);
4345
+ if (successMessage !== translateFn("error.unknown")) {
4346
+ if (isCrudOperation(operationKey) && moduleKey) {
4347
+ const itemNameKey = `action.${moduleKey}Singular`;
4348
+ const itemName = getSafeTranslation(itemNameKey);
4349
+ if (itemName !== translateFn("error.unknown")) {
4350
+ return translateFn(successKey, { item: itemName });
4351
+ } else {
4352
+ const withoutItemKey = `action.onSuccess.${operationKey}WithoutItem`;
4353
+ const withoutItemMessage = getSafeTranslation(withoutItemKey);
4354
+ return withoutItemMessage !== translateFn("error.unknown") ? withoutItemMessage : successMessage;
4355
+ }
4356
+ }
4357
+ return successMessage;
4358
+ }
4359
+ return translateFn("success.transaction");
4360
+ },
4361
+ [getSafeTranslation, translateFn, isCrudOperation]
4362
+ );
4363
+ const getErrorMessage2 = useCallback7(
4364
+ (response) => {
4365
+ if (response.errorCode && customErrorMessages[response.errorCode]) {
4366
+ return customErrorMessages[response.errorCode];
4367
+ }
4368
+ if (response.errorCode && ERROR_TRANSLATION_MAP[response.errorCode]) {
4369
+ return getSafeTranslation(ERROR_TRANSLATION_MAP[response.errorCode]);
4370
+ }
4371
+ if (response.errorCode) {
4372
+ const possibleKeys = [
4373
+ `errors.auth.${response.errorCode}`,
4374
+ `errors.data.${response.errorCode}`,
4375
+ `errors.system.${response.errorCode}`,
4376
+ `errors.${response.errorCode}`
4377
+ ];
4378
+ for (const key of possibleKeys) {
4379
+ const translated = getSafeTranslation(key);
4380
+ if (translated !== translateFn("error.unknown")) {
4381
+ return translated;
4382
+ }
4383
+ }
4384
+ }
4385
+ if (typeof response.data === "string" && response.data.startsWith("errors.")) {
4386
+ const translated = getSafeTranslation(response.data);
4387
+ if (translated !== translateFn("error.unknown")) {
4388
+ return translated;
4389
+ }
4390
+ }
4391
+ if (response.errors && Object.keys(response.errors).length > 0) {
4392
+ const errorFields = Object.keys(response.errors);
4393
+ if (errorFields.length === 1 && errorFields[0] === "_transaction") {
4394
+ const transactionErrors = response.errors["_transaction"];
4395
+ if (transactionErrors?.includes("ONE_OR_MORE_OPERATIONS_FAILED")) {
4396
+ return "";
4397
+ }
4398
+ if (Array.isArray(transactionErrors) && transactionErrors.length > 0) {
4399
+ const firstError = transactionErrors[0];
4400
+ if (typeof firstError === "string" && firstError !== "ONE_OR_MORE_OPERATIONS_FAILED") {
4401
+ try {
4402
+ const parsed = JSON.parse(firstError);
4403
+ if (Array.isArray(parsed) && parsed.length > 0) {
4404
+ const firstTransactionError = parsed[0];
4405
+ if (firstTransactionError?.response?.errorCode) {
4406
+ const errorCode = firstTransactionError.response.errorCode;
4407
+ if (ERROR_TRANSLATION_MAP[errorCode]) {
4408
+ return getSafeTranslation(ERROR_TRANSLATION_MAP[errorCode]);
4409
+ }
4410
+ const possibleKeys = [
4411
+ `errors.auth.${errorCode}`,
4412
+ `errors.data.${errorCode}`,
4413
+ `errors.system.${errorCode}`,
4414
+ `errors.${errorCode}`
4415
+ ];
4416
+ for (const key of possibleKeys) {
4417
+ const translated = getSafeTranslation(key);
4418
+ if (translated !== getSafeTranslation("error.unknown")) {
4419
+ return translated;
4420
+ }
4421
+ }
4422
+ }
4423
+ if (firstTransactionError?.response?.data) {
4424
+ return firstTransactionError.response.data;
4425
+ }
4426
+ }
4427
+ if (parsed?.response?.message) {
4428
+ const errorMsg = parsed.response.message.toLowerCase();
4429
+ if (errorMsg.includes("expired")) {
4430
+ return getSafeTranslation("resetPassword.linkExpired", "El enlace ha expirado");
4431
+ } else if (errorMsg.includes("invalid")) {
4432
+ return getSafeTranslation("resetPassword.invalidCode", "C\xF3digo inv\xE1lido");
4433
+ }
4434
+ return parsed.response.message;
4435
+ }
4436
+ } catch {
4437
+ if (firstError.toLowerCase().includes("expired")) {
4438
+ return getSafeTranslation("resetPassword.linkExpired", "El enlace ha expirado");
4439
+ } else if (firstError.toLowerCase().includes("invalid")) {
4440
+ return getSafeTranslation("resetPassword.invalidCode", "C\xF3digo inv\xE1lido");
4441
+ }
4442
+ return firstError;
4443
+ }
4444
+ }
4445
+ }
4446
+ return getSafeTranslation("error.transaction", "Error en la operaci\xF3n");
4447
+ }
4448
+ if (errorFields.length === 1 && errorFields[0] === "_error") {
4449
+ const errorMessages = response.errors["_error"];
4450
+ return Array.isArray(errorMessages) ? errorMessages[0] : String(errorMessages);
4451
+ }
4452
+ if (errorFields.length === 1 && errorFields[0] === "_graphql") {
4453
+ return getSafeTranslation("errors.system.DATABASE_CONNECTION_ERROR");
4454
+ }
4455
+ return `${getSafeTranslation("errors.data.FIELD_ERROR")}: ${errorFields.join(", ")}`;
4456
+ }
4457
+ return defaultErrorMessage || translateFn("error.unknown");
4458
+ },
4459
+ [customErrorMessages, defaultErrorMessage, translateFn, getSafeTranslation]
4460
+ );
4461
+ const getErrorSeverity = useCallback7((response) => {
4462
+ if (response.errorCode && ERROR_SEVERITY_MAP2[response.errorCode]) {
4463
+ return ERROR_SEVERITY_MAP2[response.errorCode];
4464
+ }
4465
+ return "error";
4466
+ }, []);
4467
+ const createItem = useCallback7(
4468
+ async (moduleKey, data, options2) => {
4469
+ const response = await crudify6.createItem(moduleKey, data, options2);
4470
+ if (!response.success && showErrorNotifications && shouldShowNotification(response)) {
4471
+ const message = getErrorMessage2(response);
4472
+ const severity = getErrorSeverity(response);
4473
+ showNotification(message, severity, { autoHideDuration });
4474
+ } else if (response.success) {
4475
+ const actionConfig = options2?.actionConfig;
4476
+ const operation = actionConfig?.key || "create";
4477
+ const effectiveModuleKey = actionConfig?.moduleKey || moduleKey;
4478
+ if (shouldShowSuccessNotification(operation, effectiveModuleKey)) {
4479
+ const message = getSuccessMessage(operation, effectiveModuleKey, actionConfig);
4480
+ showNotification(message, "success", { autoHideDuration });
4481
+ }
4482
+ }
4483
+ return response;
4484
+ },
4485
+ [
4486
+ showErrorNotifications,
4487
+ shouldShowSuccessNotification,
4488
+ showNotification,
4489
+ getErrorMessage2,
4490
+ getErrorSeverity,
4491
+ getSuccessMessage,
4492
+ autoHideDuration,
4493
+ shouldShowNotification
4494
+ ]
4495
+ );
4496
+ const updateItem = useCallback7(
4497
+ async (moduleKey, data, options2) => {
4498
+ const response = await crudify6.updateItem(moduleKey, data, options2);
4499
+ if (!response.success && showErrorNotifications && shouldShowNotification(response)) {
4500
+ const message = getErrorMessage2(response);
4501
+ const severity = getErrorSeverity(response);
4502
+ showNotification(message, severity, { autoHideDuration });
4503
+ } else if (response.success) {
4504
+ const actionConfig = options2?.actionConfig;
4505
+ const operation = actionConfig?.key || "update";
4506
+ const effectiveModuleKey = actionConfig?.moduleKey || moduleKey;
4507
+ if (shouldShowSuccessNotification(operation, effectiveModuleKey)) {
4508
+ const message = getSuccessMessage(operation, effectiveModuleKey, actionConfig);
4509
+ showNotification(message, "success", { autoHideDuration });
4510
+ }
4511
+ }
4512
+ return response;
4513
+ },
4514
+ [
4515
+ showErrorNotifications,
4516
+ shouldShowSuccessNotification,
4517
+ showNotification,
4518
+ getErrorMessage2,
4519
+ getErrorSeverity,
4520
+ getSuccessMessage,
4521
+ autoHideDuration,
4522
+ shouldShowNotification
4523
+ ]
4524
+ );
4525
+ const deleteItem = useCallback7(
4526
+ async (moduleKey, id, options2) => {
4527
+ const response = await crudify6.deleteItem(moduleKey, id, options2);
4528
+ if (!response.success && showErrorNotifications && shouldShowNotification(response)) {
4529
+ const message = getErrorMessage2(response);
4530
+ const severity = getErrorSeverity(response);
4531
+ showNotification(message, severity, { autoHideDuration });
4532
+ } else if (response.success) {
4533
+ const actionConfig = options2?.actionConfig;
4534
+ const operation = actionConfig?.key || "delete";
4535
+ const effectiveModuleKey = actionConfig?.moduleKey || moduleKey;
4536
+ if (shouldShowSuccessNotification(operation, effectiveModuleKey)) {
4537
+ const message = getSuccessMessage(operation, effectiveModuleKey, actionConfig);
4538
+ showNotification(message, "success", { autoHideDuration });
4539
+ }
4540
+ }
4541
+ return response;
4542
+ },
4543
+ [
4544
+ showErrorNotifications,
4545
+ shouldShowSuccessNotification,
4546
+ showNotification,
4547
+ getErrorMessage2,
4548
+ getErrorSeverity,
4549
+ getSuccessMessage,
4550
+ autoHideDuration,
4551
+ shouldShowNotification
4552
+ ]
4553
+ );
4554
+ const readItem = useCallback7(
4555
+ async (moduleKey, filter, options2) => {
4556
+ const response = await crudify6.readItem(moduleKey, filter, options2);
4557
+ if (!response.success && showErrorNotifications && shouldShowNotification(response)) {
4558
+ const message = getErrorMessage2(response);
4559
+ const severity = getErrorSeverity(response);
4560
+ showNotification(message, severity, { autoHideDuration });
4561
+ }
4562
+ return response;
4563
+ },
4564
+ [showErrorNotifications, showNotification, getErrorMessage2, getErrorSeverity, autoHideDuration, shouldShowNotification]
4565
+ );
4566
+ const readItems = useCallback7(
4567
+ async (moduleKey, filter, options2) => {
4568
+ const response = await crudify6.readItems(moduleKey, filter, options2);
4569
+ if (!response.success && showErrorNotifications && shouldShowNotification(response)) {
4570
+ const message = getErrorMessage2(response);
4571
+ const severity = getErrorSeverity(response);
4572
+ showNotification(message, severity, { autoHideDuration });
4573
+ }
4574
+ return response;
4575
+ },
4576
+ [showErrorNotifications, showNotification, getErrorMessage2, getErrorSeverity, autoHideDuration, shouldShowNotification]
4577
+ );
4578
+ const transaction = useCallback7(
4579
+ async (data, options2) => {
4580
+ const response = await crudify6.transaction(data, options2);
4581
+ const skipNotifications = options2?.skipNotifications === true;
4582
+ if (!skipNotifications && !response.success && showErrorNotifications && shouldShowNotification(response)) {
4583
+ const message = getErrorMessage2(response);
4584
+ const severity = getErrorSeverity(response);
4585
+ showNotification(message, severity, { autoHideDuration });
4586
+ } else if (!skipNotifications && response.success) {
4587
+ let operation = "transaction";
4588
+ let moduleKey;
4589
+ let actionConfig = null;
4590
+ if (options2?.actionConfig) {
4591
+ actionConfig = options2.actionConfig;
4592
+ operation = actionConfig.key;
4593
+ moduleKey = actionConfig.moduleKey;
4594
+ } else if (Array.isArray(data) && data.length > 0 && data[0].operation) {
4595
+ operation = data[0].operation;
4596
+ actionConfig = appStructure.find((action) => action.key === operation);
4597
+ if (actionConfig) {
4598
+ moduleKey = actionConfig.moduleKey;
4599
+ }
4600
+ }
4601
+ if (shouldShowSuccessNotification(operation, moduleKey)) {
4602
+ const message = getSuccessMessage(operation, moduleKey, actionConfig);
4603
+ showNotification(message, "success", { autoHideDuration });
4604
+ }
4605
+ }
4606
+ return response;
4607
+ },
4608
+ [
4609
+ showErrorNotifications,
4610
+ shouldShowSuccessNotification,
4611
+ showNotification,
4612
+ getErrorMessage2,
4613
+ getErrorSeverity,
4614
+ getSuccessMessage,
4615
+ autoHideDuration,
4616
+ shouldShowNotification,
4617
+ appStructure
4618
+ ]
4619
+ );
4620
+ const handleResponse = useCallback7(
4621
+ (response, successMessage) => {
4622
+ if (!response.success && showErrorNotifications && shouldShowNotification(response)) {
4623
+ const message = getErrorMessage2(response);
4624
+ const severity = getErrorSeverity(response);
4625
+ showNotification(message, severity, { autoHideDuration });
4626
+ } else if (response.success && showSuccessNotifications && successMessage) {
4627
+ showNotification(successMessage, "success", { autoHideDuration });
4628
+ }
4629
+ return response;
4630
+ },
4631
+ [
4632
+ showErrorNotifications,
4633
+ showSuccessNotifications,
4634
+ showNotification,
4635
+ getErrorMessage2,
4636
+ getErrorSeverity,
4637
+ autoHideDuration,
4638
+ shouldShowNotification,
4639
+ translateFn
4640
+ ]
4641
+ );
4642
+ return {
4643
+ // Métodos de crudify con notificaciones automáticas
4644
+ createItem,
4645
+ updateItem,
4646
+ deleteItem,
4647
+ readItem,
4648
+ readItems,
4649
+ transaction,
4650
+ // Método genérico para manejar respuestas
4651
+ handleResponse,
4652
+ // Funciones de utilidad
4653
+ getErrorMessage: getErrorMessage2,
4654
+ getErrorSeverity,
4655
+ shouldShowNotification
4656
+ };
4657
+ };
3975
4658
  export {
3976
4659
  CrudifyLogin_default as CrudifyLogin,
3977
4660
  ERROR_CODES,
3978
4661
  ERROR_SEVERITY_MAP,
4662
+ GlobalNotificationProvider,
3979
4663
  LoginComponent,
3980
4664
  POLICY_ACTIONS,
3981
4665
  PREFERRED_POLICY_ORDER,
@@ -3987,6 +4671,7 @@ export {
3987
4671
  SessionStatus,
3988
4672
  TokenStorage,
3989
4673
  UserProfileDisplay_default as UserProfileDisplay,
4674
+ createErrorTranslator,
3990
4675
  default2 as crudify,
3991
4676
  decodeJwtSafely,
3992
4677
  getCookie,
@@ -3999,8 +4684,13 @@ export {
3999
4684
  parseTransactionError,
4000
4685
  secureLocalStorage,
4001
4686
  secureSessionStorage,
4687
+ translateError,
4688
+ translateErrorCode,
4689
+ translateErrorCodes,
4002
4690
  useAuth,
4691
+ useCrudifyWithNotifications,
4003
4692
  useData,
4693
+ useGlobalNotification,
4004
4694
  useSession,
4005
4695
  useSessionContext,
4006
4696
  useUserData,