@chimera-pe/react-saas 0.1.2 → 0.1.4

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.
@@ -1,48 +1,49 @@
1
- import { jsx as o, jsxs as d, Fragment as $e } from "react/jsx-runtime";
2
- import { Box as $, CircularProgress as X, Alert as Q, AlertTitle as xe, Snackbar as Te, useMediaQuery as we, CssBaseline as Se, Container as je, Grid as g, Typography as A, Card as Oe, CardHeader as Re, CardContent as ke, AppBar as ze, Toolbar as De, Link as Ie, InputAdornment as G, Button as Ae } from "@mui/material";
3
- import { useTranslate as j, I18n as Le } from "react-polyglot";
4
- import i from "prop-types";
5
- import { useDispatch as m, useSelector as u, Provider as Pe } from "react-redux";
6
- import { createSlice as O, createAsyncThunk as q, configureStore as Ne } from "@reduxjs/toolkit";
7
- import N from "axios";
8
- import qe from "jwt-decode";
9
- import { useState as Fe, useEffect as v, useMemo as Me, useCallback as Ge } from "react";
10
- import { enGB as Ee, es as He } from "date-fns/locale";
11
- import { LocalizationProvider as Ue } from "@mui/x-date-pickers";
12
- import { AdapterDateFns as Be } from "@mui/x-date-pickers/AdapterDateFns";
13
- import Ve from "navigator-languages";
14
- import { createTheme as Ke, ThemeProvider as Je } from "@mui/material/styles";
15
- import { grey as E } from "@mui/material/colors";
16
- import { useLocation as Y, Navigate as ee, BrowserRouter as Ze, Routes as We, Route as H } from "react-router-dom";
17
- import { Email as Xe, Lock as Qe } from "@mui/icons-material";
18
- import { Form as Ye } from "react-final-form";
19
- import { TextField as U } from "mui-rff";
20
- const er = () => /* @__PURE__ */ o($, { sx: {
1
+ import { jsx as o, jsxs as d, Fragment as ee } from "react/jsx-runtime";
2
+ import { Box as x, CircularProgress as U, Alert as N, AlertTitle as re, Snackbar as ie, useMediaQuery as ne, CssBaseline as oe, Container as ae, Grid as h, Typography as j, Card as te, CardHeader as se, CardContent as ce, AppBar as le, Toolbar as de, Link as ue, InputAdornment as q, Button as pe } from "@mui/material";
3
+ import { useTranslate as w, I18n as me } from "react-polyglot";
4
+ import t from "prop-types";
5
+ import { useDispatch as g, useSelector as u, Provider as fe } from "react-redux";
6
+ import { createSlice as C, createAsyncThunk as z, configureStore as ge } from "@reduxjs/toolkit";
7
+ import L from "axios";
8
+ import he from "jwt-decode";
9
+ import { useState as ye, useEffect as y, useMemo as xe, useCallback as be } from "react";
10
+ import { enGB as ke, es as Te } from "date-fns/locale";
11
+ import { LocalizationProvider as we } from "@mui/x-date-pickers";
12
+ import { AdapterDateFns as Ce } from "@mui/x-date-pickers/AdapterDateFns";
13
+ import Re from "navigator-languages";
14
+ import { createTheme as Se, ThemeProvider as je } from "@mui/material/styles";
15
+ import { grey as v } from "@mui/material/colors";
16
+ import { useLocation as _, Navigate as F, BrowserRouter as Ae, Routes as Le, Route as I } from "react-router-dom";
17
+ import { Email as ze, Lock as qe } from "@mui/icons-material";
18
+ import { Form as ve } from "react-final-form";
19
+ import { TextField as D } from "mui-rff";
20
+ import E from "lodash/memoize";
21
+ const Ie = () => /* @__PURE__ */ o(x, { sx: {
21
22
  display: "flex",
22
23
  flexDirection: "column",
23
24
  flexGrow: 1,
24
25
  justifyContent: "center",
25
26
  alignItems: "center"
26
- }, children: /* @__PURE__ */ o(X, {}) }), rr = ({ titulo: e, texto: r, align: t = "center", severity: a = "error" }) => {
27
- const n = j();
28
- return /* @__PURE__ */ o($, { sx: {
27
+ }, children: /* @__PURE__ */ o(U, {}) }), De = ({ titulo: r, texto: e, align: i = "center", severity: n = "error" }) => {
28
+ const a = w();
29
+ return /* @__PURE__ */ o(x, { sx: {
29
30
  display: "flex",
30
31
  flexDirection: "column",
31
32
  flexGrow: 1,
32
33
  justifyContent: "center",
33
- alignItems: t
34
- }, children: /* @__PURE__ */ d(Q, { severity: a, children: [
35
- /* @__PURE__ */ o(xe, { children: n(e) }),
36
- r && n(r)
34
+ alignItems: i
35
+ }, children: /* @__PURE__ */ d(N, { severity: n, children: [
36
+ /* @__PURE__ */ o(re, { children: a(r) }),
37
+ e && a(e)
37
38
  ] }) });
38
39
  };
39
40
  Error.propTypes = {
40
- titulo: i.string.isRequired,
41
- texto: i.string,
42
- align: i.string,
43
- severity: i.string
41
+ titulo: t.string.isRequired,
42
+ texto: t.string,
43
+ align: t.string,
44
+ severity: t.string
44
45
  };
45
- const re = O({
46
+ const O = C({
46
47
  name: "ui",
47
48
  initialState: {
48
49
  tema: "light",
@@ -50,40 +51,40 @@ const re = O({
50
51
  idioma: "es"
51
52
  },
52
53
  reducers: {
53
- cambiarTema: (e, r) => {
54
- e.tema = r.payload, e.temaSeleccionado = !0, localStorage.setItem("tema", r.payload);
54
+ cambiarTema: (r, e) => {
55
+ r.tema = e.payload, r.temaSeleccionado = !0, localStorage.setItem("tema", e.payload);
55
56
  },
56
- cambiarIdioma: (e, r) => {
57
- e.idioma = r.payload;
57
+ cambiarIdioma: (r, e) => {
58
+ r.idioma = e.payload;
58
59
  }
59
60
  }
60
- }), { cambiarTema: tr, cambiarIdioma: ar } = re.actions, nr = re.reducer, or = "https://saas.chimera.com.pe/backend", ir = "https://saas.chimera.com.pe/oauth", te = (e = ir) => ({
61
- login: (r, t) => N({
62
- url: `${e}/oauth/token`,
61
+ }), { cambiarTema: Ue, cambiarIdioma: Ne } = O.actions, _e = O.reducer, Fe = "https://saas.chimera.com.pe/backend", Ee = "https://saas.chimera.com.pe/oauth", P = (r = Ee) => ({
62
+ login: (e, i) => L({
63
+ url: `${r}/oauth/token`,
63
64
  headers: {
64
65
  "content-type": "application/x-www-form-urlencoded",
65
- Authorization: `Basic ${r}`
66
+ Authorization: `Basic ${e}`
66
67
  },
67
68
  method: "post",
68
69
  data: {
69
- username: t.correo,
70
- password: t.password,
70
+ username: i.correo,
71
+ password: i.password,
71
72
  grant_type: "password"
72
73
  }
73
74
  }),
74
- refreshToken: (r, t) => N({
75
- url: `${e}/oauth/token`,
75
+ refreshToken: (e, i) => L({
76
+ url: `${r}/oauth/token`,
76
77
  headers: {
77
78
  "content-type": "application/x-www-form-urlencoded",
78
- Authorization: `Basic ${r}`
79
+ Authorization: `Basic ${e}`
79
80
  },
80
81
  method: "post",
81
82
  data: {
82
- refresh_token: t,
83
+ refresh_token: i,
83
84
  grant_type: "refresh_token"
84
85
  }
85
86
  })
86
- }), ae = O({
87
+ }), B = C({
87
88
  name: "login",
88
89
  initialState: {
89
90
  cargando: !1,
@@ -96,107 +97,107 @@ const re = O({
96
97
  error: null
97
98
  },
98
99
  reducers: {
99
- logout: (e) => {
100
- e.cargando = !1, e.autenticado = !1, e.token = null, e.refreshToken = null, e.expiracion = null, e.usuario = null, e.perfiles = [], e.error = null;
100
+ logout: (r) => {
101
+ r.cargando = !1, r.autenticado = !1, r.token = null, r.refreshToken = null, r.expiracion = null, r.usuario = null, r.perfiles = [], r.error = null;
101
102
  }
102
103
  },
103
- extraReducers(e) {
104
- e.addCase(T.pending, (r) => {
105
- r.cargando = !0, r.error = null;
106
- }).addCase(T.fulfilled, (r, t) => {
107
- const a = t.payload.access_token, n = qe(a), c = /* @__PURE__ */ new Date();
108
- c.setSeconds(c.getSeconds() + t.payload.expires_in), r.cargando = !1, r.autenticado = !0, r.token = a, r.refreshToken = t.payload.refresh_token, r.expiracion = c.getTime(), r.usuario = n.name, r.perfiles = n.authorities;
109
- }).addCase(T.rejected, (r, t) => {
110
- var a;
111
- console.log(t), r.cargando = !1, r.autenticado = !1, r.token = null, r.refreshToken = null, r.expiracion = null, r.usuario = null, r.perfiles = [], r.error = (a = t.error) == null ? void 0 : a.message;
112
- }).addCase(w.pending, (r) => {
113
- r.cargando = !0;
114
- }).addCase(w.fulfilled, (r, t) => {
115
- const a = /* @__PURE__ */ new Date();
116
- a.setSeconds(a.getSeconds() + t.payload.expires_in), r.token = t.payload.access_token, r.refreshToken = t.payload.refresh_token, r.expiracion = a.getTime();
117
- }).addCase(w.rejected, (r, t) => {
118
- var a;
119
- r.cargando = !1, r.autenticado = !1, r.token = null, r.refreshToken = null, r.expiracion = null, r.usuario = null, r.perfiles = [], r.error = (a = t.error) == null ? void 0 : a.message;
104
+ extraReducers(r) {
105
+ r.addCase(b.pending, (e) => {
106
+ e.cargando = !0, e.error = null;
107
+ }).addCase(b.fulfilled, (e, i) => {
108
+ const n = i.payload.access_token, a = he(n), c = /* @__PURE__ */ new Date();
109
+ c.setSeconds(c.getSeconds() + i.payload.expires_in), e.cargando = !1, e.autenticado = !0, e.token = n, e.refreshToken = i.payload.refresh_token, e.expiracion = c.getTime(), e.usuario = a.name, e.perfiles = a.authorities;
110
+ }).addCase(b.rejected, (e, i) => {
111
+ var n;
112
+ console.log(i), e.cargando = !1, e.autenticado = !1, e.token = null, e.refreshToken = null, e.expiracion = null, e.usuario = null, e.perfiles = [], e.error = (n = i.error) == null ? void 0 : n.message;
113
+ }).addCase(k.pending, (e) => {
114
+ e.cargando = !0;
115
+ }).addCase(k.fulfilled, (e, i) => {
116
+ const n = /* @__PURE__ */ new Date();
117
+ n.setSeconds(n.getSeconds() + i.payload.expires_in), e.token = i.payload.access_token, e.refreshToken = i.payload.refresh_token, e.expiracion = n.getTime();
118
+ }).addCase(k.rejected, (e, i) => {
119
+ var n;
120
+ e.cargando = !1, e.autenticado = !1, e.token = null, e.refreshToken = null, e.expiracion = null, e.usuario = null, e.perfiles = [], e.error = (n = i.error) == null ? void 0 : n.message;
120
121
  });
121
122
  }
122
- }), T = q("login/requestToken", async (e) => (await te(e.devURL).login(e.clientCredentials, e.data)).data), w = q("login/refreshToken", async (e, r, t) => (await te(e).refreshToken(r, t)).data), { logout: sr } = ae.actions, Sn = (e) => e.token, jn = (e) => e.usuario, On = (e) => e.perfiles, cr = ae.reducer, ne = O({
123
+ }), b = z("login/requestToken", async (r) => (await P(r.devURL).login(r.clientCredentials, r.data)).data), k = z("login/refreshToken", async (r, e, i) => (await P(r).refreshToken(e, i)).data), { logout: Oe } = B.actions, Cr = (r) => r.login.token, Rr = (r) => r.login.usuario, Sr = (r) => r.login.perfiles, Pe = B.reducer, M = C({
123
124
  name: "notificacion",
124
125
  initialState: [],
125
126
  reducers: {
126
- mostrarNotificacion: (e, r) => {
127
- e.push(r.payload);
127
+ mostrarNotificacion: (r, e) => {
128
+ r.push(e.payload);
128
129
  },
129
- ocultarNotificacion: (e) => {
130
- e.pop();
130
+ ocultarNotificacion: (r) => {
131
+ r.pop();
131
132
  }
132
133
  }
133
- }), { mostrarNotificacion: lr, ocultarNotificacion: dr } = ne.actions, ur = ne.reducer, pr = (e = or, r) => N({
134
- url: `${e}/identidad/`,
134
+ }), { mostrarNotificacion: Be, ocultarNotificacion: Me } = M.actions, Ge = M.reducer, $e = (r = Fe, e) => L({
135
+ url: `${r}/identidad/`,
135
136
  params: {
136
- codigoAplicacion: r
137
+ codigoAplicacion: e
137
138
  }
138
- }), L = {
139
+ }), A = {
139
140
  primary: "#1C6CCC",
140
141
  secondary: "#17A7FF",
141
142
  error: "#f44336",
142
143
  warning: "#ff9800",
143
144
  info: "#2196f3",
144
145
  success: "#4caf50"
145
- }, hr = O({
146
+ }, He = C({
146
147
  name: "inicializar",
147
148
  initialState: {
148
149
  inicializando: !0,
149
150
  inicializado: !1,
150
151
  instancia: {
151
- color: L
152
+ color: A
152
153
  },
153
154
  error: null
154
155
  },
155
- extraReducers(e) {
156
- e.addCase(S.pending, (r) => {
157
- r.inicializando = !0;
158
- }).addCase(S.fulfilled, (r, t) => {
159
- r.inicializando = !1, r.inicializado = !0, r.instancia = {
160
- ...t.payload,
161
- abreviatura: t.payload.nombre.match(/\b([A-Z])/g).join(""),
156
+ extraReducers(r) {
157
+ r.addCase(T.pending, (e) => {
158
+ e.inicializando = !0;
159
+ }).addCase(T.fulfilled, (e, i) => {
160
+ e.inicializando = !1, e.inicializado = !0, e.instancia = {
161
+ ...i.payload,
162
+ abreviatura: i.payload.nombre.match(/\b([A-Z])/g).join(""),
162
163
  color: {
163
- ...L,
164
- ...t.payload.color
164
+ ...A,
165
+ ...i.payload.color
165
166
  }
166
- }, r.error = null;
167
- }).addCase(S.rejected, (r, t) => {
168
- r.inicializando = !1, r.inicializado = !1, r.instancia = {
169
- color: L
170
- }, r.error = t.payload;
167
+ }, e.error = null;
168
+ }).addCase(T.rejected, (e, i) => {
169
+ e.inicializando = !1, e.inicializado = !1, e.instancia = {
170
+ color: A
171
+ }, e.error = i.payload;
171
172
  });
172
173
  }
173
- }), S = q("inicializar", async (e) => (await pr(e.devURL, e.aplicacion)).data), Rn = (e) => e.instancia, fr = hr.reducer, mr = (e) => Ne({
174
+ }), T = z("inicializar", async (r) => (await $e(r.devURL, r.aplicacion)).data), jr = (r) => r.aplicacion.instancia, Ve = He.reducer, Ze = (r) => ge({
174
175
  reducer: {
175
- ui: nr,
176
- aplicacion: fr,
177
- login: cr,
178
- notificaciones: ur,
179
- ...e
176
+ ui: _e,
177
+ aplicacion: Ve,
178
+ login: Pe,
179
+ notificaciones: Ge,
180
+ ...r
180
181
  }
181
- }), gr = () => {
182
- const [e, r] = Fe(!1), t = m(), a = j(), n = u((s) => s.notificaciones[0]);
183
- v(() => {
184
- r(!!n);
185
- }, [n]);
182
+ }), We = () => {
183
+ const [r, e] = ye(!1), i = g(), n = w(), a = u((s) => s.notificaciones[0]);
184
+ y(() => {
185
+ e(!!a);
186
+ }, [a]);
186
187
  const c = () => {
187
- r(!1), t(dr());
188
+ e(!1), i(Me());
188
189
  };
189
190
  return /* @__PURE__ */ o(
190
- Te,
191
+ ie,
191
192
  {
192
- open: e,
193
- message: (n == null ? void 0 : n.mensaje) && n.tipo === "default" && a(n.mensaje),
193
+ open: r,
194
+ message: (a == null ? void 0 : a.mensaje) && a.tipo === "default" && n(a.mensaje),
194
195
  autoHideDuration: 5e3,
195
196
  onClose: c,
196
- children: (n == null ? void 0 : n.mensaje) && n.tipo !== "default" && /* @__PURE__ */ o(Q, { severity: n.tipo, children: a(n.mensaje) })
197
+ children: (a == null ? void 0 : a.mensaje) && a.tipo !== "default" && /* @__PURE__ */ o(N, { severity: a.tipo, children: n(a.mensaje) })
197
198
  }
198
199
  );
199
- }, vr = {
200
+ }, Je = {
200
201
  inicializar: {
201
202
  error: {
202
203
  titulo: "Error iniciando aplicación",
@@ -215,158 +216,158 @@ const re = O({
215
216
  error: "Usuario o contraseña incorrectos"
216
217
  },
217
218
  copy: "Todos los derechos reservados "
218
- }, yr = {
219
- es: vr
220
- }, _r = { en: Ee, es: He }, oe = ({ messages: e, children: r }) => {
221
- const t = u((a) => a.ui.idioma);
222
- return /* @__PURE__ */ o(Le, { locale: t, messages: e[t], children: /* @__PURE__ */ o(Ue, { dateAdapter: Be, adapterLocale: _r[t], children: r }) });
219
+ }, Ke = {
220
+ es: Je
221
+ }, Qe = { en: ke, es: Te }, G = ({ messages: r, children: e }) => {
222
+ const i = u((n) => n.ui.idioma);
223
+ return /* @__PURE__ */ o(me, { locale: i, messages: r[i], children: /* @__PURE__ */ o(we, { dateAdapter: Ce, adapterLocale: Qe[i], children: e }) });
223
224
  };
224
- oe.propTypes = {
225
- messages: i.object,
226
- children: i.element.isRequired
225
+ G.propTypes = {
226
+ messages: t.object,
227
+ children: t.element.isRequired
227
228
  };
228
- const br = () => {
229
- const e = Ve();
230
- if (!(e != null && e.length))
229
+ const Xe = () => {
230
+ const r = Re();
231
+ if (!(r != null && r.length))
231
232
  return;
232
- const r = e[0];
233
- return r.indexOf("-") ? r.substring(0, r.indexOf("-")) : r;
234
- }, ie = ({ messages: e, idiomaDefecto: r, children: t }) => {
235
- const a = m(), n = br();
236
- v(() => {
237
- let s = Reflect.ownKeys(e)[0];
238
- n && Object.hasOwn(e, n) ? s = n : r && Object.hasOwn(e, r) && (s = r), a(ar(s));
239
- }, [a, e, r, n]);
233
+ const e = r[0];
234
+ return e.indexOf("-") ? e.substring(0, e.indexOf("-")) : e;
235
+ }, $ = ({ messages: r, idiomaDefecto: e, children: i }) => {
236
+ const n = g(), a = Xe();
237
+ y(() => {
238
+ let s = Reflect.ownKeys(r)[0];
239
+ a && Object.hasOwn(r, a) ? s = a : e && Object.hasOwn(r, e) && (s = e), n(Ne(s));
240
+ }, [n, r, e, a]);
240
241
  const c = {};
241
- return Object.keys(e).forEach((s) => {
242
+ return Object.keys(r).forEach((s) => {
242
243
  c[s] = {
243
- ...e[s],
244
- saas: yr[s]
244
+ ...r[s],
245
+ saas: Ke[s]
245
246
  };
246
- }), /* @__PURE__ */ o(oe, { messages: c, children: t });
247
+ }), /* @__PURE__ */ o(G, { messages: c, children: i });
247
248
  };
248
- ie.propTypes = {
249
- messages: i.object,
250
- idiomaDefecto: i.string,
251
- children: i.element.isRequired
249
+ $.propTypes = {
250
+ messages: t.object,
251
+ idiomaDefecto: t.string,
252
+ children: t.element.isRequired
252
253
  };
253
- const se = ({ children: e }) => {
254
- const r = m(), { instancia: t } = u((s) => s.aplicacion), a = u((s) => s.ui.tema), n = we("(prefers-color-scheme: dark)");
255
- v(() => {
256
- r(tr(n ? "dark" : "light"));
257
- }, [r, n]);
258
- const c = Me(() => Ke({
254
+ const H = ({ children: r }) => {
255
+ const e = g(), { instancia: i } = u((s) => s.aplicacion), n = u((s) => s.ui.tema), a = ne("(prefers-color-scheme: dark)");
256
+ y(() => {
257
+ e(Ue(a ? "dark" : "light"));
258
+ }, [e, a]);
259
+ const c = xe(() => Se({
259
260
  palette: {
260
- mode: a,
261
+ mode: n,
261
262
  primary: {
262
- main: t.color.primary
263
+ main: i.color.primary
263
264
  },
264
265
  secondary: {
265
- main: t.color.secondary
266
+ main: i.color.secondary
266
267
  },
267
268
  error: {
268
- main: t.color.error
269
+ main: i.color.error
269
270
  },
270
271
  warning: {
271
- main: t.color.warning
272
+ main: i.color.warning
272
273
  },
273
274
  info: {
274
- main: t.color.info
275
+ main: i.color.info
275
276
  },
276
277
  success: {
277
- main: t.color.success
278
+ main: i.color.success
278
279
  },
279
- ...a === "light" && {
280
+ ...n === "light" && {
280
281
  background: {
281
- default: E.A200,
282
- paper: E[100]
282
+ default: v.A200,
283
+ paper: v[100]
283
284
  }
284
285
  }
285
286
  },
286
287
  shape: {
287
288
  borderRadius: 6
288
289
  }
289
- }), [a, t]);
290
- return /* @__PURE__ */ d(Je, { theme: c, children: [
291
- /* @__PURE__ */ o(Se, {}),
292
- e
290
+ }), [n, i]);
291
+ return /* @__PURE__ */ d(je, { theme: c, children: [
292
+ /* @__PURE__ */ o(oe, {}),
293
+ r
293
294
  ] });
294
295
  };
295
- se.propTypes = {
296
- children: i.element.isRequired
296
+ H.propTypes = {
297
+ children: t.element.isRequired
297
298
  };
298
- const ce = (e) => {
299
- const r = m(), t = u((n) => n.login), a = u((n) => n.aplicacion.instancia);
300
- return v(() => {
301
- t.autenticado && t.expiracion && new Date(t.expiracion) < /* @__PURE__ */ new Date() && (t.refreshToken ? r(w(e, a.clientCredentials, t.refreshToken)) : r(sr()));
302
- }, [e, a.clientCredentials, t, r]), t.autenticado;
303
- }, Cr = () => {
304
- const e = m();
305
- return Ge((r, t = "default") => {
306
- e(lr({ mensaje: r, tipo: t }));
307
- }, [e]);
308
- }, le = ({ devURL: e }) => {
309
- const r = m(), t = j(), a = Cr(), { cargando: n, error: c } = u((l) => l.login), s = u((l) => l.aplicacion.instancia), D = (l) => {
310
- r(T({
311
- devURL: e,
299
+ const V = (r) => {
300
+ const e = g(), i = u((a) => a.login), n = u((a) => a.aplicacion.instancia);
301
+ return y(() => {
302
+ i.autenticado && i.expiracion && new Date(i.expiracion) < /* @__PURE__ */ new Date() && (i.refreshToken ? e(k(r, n.clientCredentials, i.refreshToken)) : e(Oe()));
303
+ }, [r, n.clientCredentials, i, e]), i.autenticado;
304
+ }, Ye = () => {
305
+ const r = g();
306
+ return be((e, i = "default") => {
307
+ r(Be({ mensaje: e, tipo: i }));
308
+ }, [r]);
309
+ }, Z = ({ devURL: r }) => {
310
+ const e = g(), i = w(), n = Ye(), { cargando: a, error: c } = u((l) => l.login), s = u((l) => l.aplicacion.instancia), R = (l) => {
311
+ e(b({
312
+ devURL: r,
312
313
  clientCredentials: s.clientCredentials,
313
314
  data: {
314
315
  correo: l.correo,
315
316
  password: l.password
316
317
  }
317
318
  }));
318
- }, Ce = (l) => {
319
- const I = { correo: void 0, password: void 0 };
320
- return l.correo || (I.correo = t("saas.login.validacion.correo")), l.password || (I.password = t("saas.login.validacion.password")), I;
319
+ }, Y = (l) => {
320
+ const S = { correo: void 0, password: void 0 };
321
+ return l.correo || (S.correo = i("saas.login.validacion.correo")), l.password || (S.password = i("saas.login.validacion.password")), S;
321
322
  };
322
- return v(() => {
323
- c && a("saas.login.error", "error");
324
- }, [a, c]), /* @__PURE__ */ o(
325
- Ye,
323
+ return y(() => {
324
+ c && n("saas.login.error", "error");
325
+ }, [n, c]), /* @__PURE__ */ o(
326
+ ve,
326
327
  {
327
- onSubmit: D,
328
- validate: Ce,
328
+ onSubmit: R,
329
+ validate: Y,
329
330
  render: ({ handleSubmit: l }) => /* @__PURE__ */ d("form", { onSubmit: l, children: [
330
331
  /* @__PURE__ */ o(
331
- U,
332
+ D,
332
333
  {
333
334
  id: "correo",
334
335
  name: "correo",
335
- label: t("saas.login.correo"),
336
+ label: i("saas.login.correo"),
336
337
  variant: "outlined",
337
338
  autoComplete: "off",
338
- disabled: n,
339
+ disabled: a,
339
340
  autoFocus: !0,
340
341
  InputProps: {
341
- startAdornment: /* @__PURE__ */ o(G, { position: "start", children: /* @__PURE__ */ o(Xe, { color: "primary" }) })
342
+ startAdornment: /* @__PURE__ */ o(q, { position: "start", children: /* @__PURE__ */ o(ze, { color: "primary" }) })
342
343
  }
343
344
  }
344
345
  ),
345
346
  /* @__PURE__ */ o(
346
- U,
347
+ D,
347
348
  {
348
349
  id: "password",
349
350
  name: "password",
350
351
  type: "password",
351
- label: t("saas.login.password"),
352
+ label: i("saas.login.password"),
352
353
  variant: "outlined",
353
354
  autoComplete: "current-password",
354
- disabled: n,
355
+ disabled: a,
355
356
  InputProps: {
356
- startAdornment: /* @__PURE__ */ o(G, { position: "start", children: /* @__PURE__ */ o(Qe, { color: "primary" }) })
357
+ startAdornment: /* @__PURE__ */ o(q, { position: "start", children: /* @__PURE__ */ o(qe, { color: "primary" }) })
357
358
  }
358
359
  }
359
360
  ),
360
- /* @__PURE__ */ d(g, { container: !0, children: [
361
- /* @__PURE__ */ o(g, { item: !0, xs: 6 }),
362
- /* @__PURE__ */ o(g, { item: !0, xs: 6, align: "right", children: /* @__PURE__ */ o(
363
- Ae,
361
+ /* @__PURE__ */ d(h, { container: !0, children: [
362
+ /* @__PURE__ */ o(h, { item: !0, xs: 6 }),
363
+ /* @__PURE__ */ o(h, { item: !0, xs: 6, align: "right", children: /* @__PURE__ */ o(
364
+ pe,
364
365
  {
365
366
  variant: "contained",
366
367
  color: "primary",
367
368
  type: "submit",
368
- disabled: n,
369
- children: n ? /* @__PURE__ */ o(X, { size: 24, thickness: 4 }) : t("saas.login.ingresar")
369
+ disabled: a,
370
+ children: a ? /* @__PURE__ */ o(U, { size: 24, thickness: 4 }) : i("saas.login.ingresar")
370
371
  }
371
372
  ) })
372
373
  ] })
@@ -374,12 +375,12 @@ const ce = (e) => {
374
375
  }
375
376
  );
376
377
  };
377
- le.propTypes = {
378
- devURL: i.string
378
+ Z.propTypes = {
379
+ devURL: t.string
379
380
  };
380
- const de = ({ devURL: e }) => {
381
- const r = u((s) => s.aplicacion.instancia), t = j(), a = Y(), n = ce(e), { from: c } = a.state || { from: { pathname: "/" } };
382
- return !r.requiereLogin || n ? /* @__PURE__ */ o(ee, { to: c }) : /* @__PURE__ */ d($, { sx: {
381
+ const W = ({ devURL: r }) => {
382
+ const e = u((s) => s.aplicacion.instancia), i = w(), n = _(), a = V(r), { from: c } = n.state || { from: { pathname: "/" } };
383
+ return !e.requiereLogin || a ? /* @__PURE__ */ o(F, { to: c }) : /* @__PURE__ */ d(x, { sx: {
383
384
  position: "relative",
384
385
  display: "flex",
385
386
  flexDirection: "column",
@@ -388,7 +389,7 @@ const de = ({ devURL: e }) => {
388
389
  backgroundColor: "primary.main",
389
390
  "&::before": {
390
391
  content: '""',
391
- backgroundImage: `url(${r.logo})`,
392
+ backgroundImage: `url(${e.logo})`,
392
393
  backgroundSize: "contain",
393
394
  backgroundRepeat: "no-repeat",
394
395
  backgroundPosition: "right",
@@ -401,401 +402,172 @@ const de = ({ devURL: e }) => {
401
402
  filter: "grayscale(100%)"
402
403
  }
403
404
  }, children: [
404
- /* @__PURE__ */ o($, { sx: {
405
+ /* @__PURE__ */ o(x, { sx: {
405
406
  display: "flex",
406
407
  justifyContent: "center",
407
408
  alignItems: "center",
408
409
  flexGrow: 1
409
- }, children: /* @__PURE__ */ o(je, { maxWidth: "md", children: /* @__PURE__ */ d(g, { container: !0, spacing: 3, children: [
410
- /* @__PURE__ */ d(g, { item: !0, xs: 12, lg: 5, align: "center", children: [
411
- /* @__PURE__ */ o("img", { src: r.logo, alt: r.nombre, style: { maxWidth: "100%" } }),
412
- /* @__PURE__ */ o(A, { variant: "h3", align: "center", children: t("aplicacion.nombre", { smart_count: 1 }) }),
413
- /* @__PURE__ */ o(A, { variant: "h5", align: "center", children: r.nombre })
410
+ }, children: /* @__PURE__ */ o(ae, { maxWidth: "md", children: /* @__PURE__ */ d(h, { container: !0, spacing: 3, children: [
411
+ /* @__PURE__ */ d(h, { item: !0, xs: 12, lg: 5, align: "center", children: [
412
+ /* @__PURE__ */ o("img", { src: e.logo, alt: e.nombre, style: { maxWidth: "100%" } }),
413
+ /* @__PURE__ */ o(j, { variant: "h3", align: "center", children: i("aplicacion.nombre", { smart_count: 1 }) }),
414
+ /* @__PURE__ */ o(j, { variant: "h5", align: "center", children: e.nombre })
414
415
  ] }),
415
- /* @__PURE__ */ o(g, { item: !0, xs: 12, lg: 7, sx: {
416
+ /* @__PURE__ */ o(h, { item: !0, xs: 12, lg: 7, sx: {
416
417
  display: "flex",
417
418
  alignItems: "center",
418
419
  justifyContent: "center",
419
420
  zIndex: 5
420
- }, children: /* @__PURE__ */ d(Oe, { elevation: 5, children: [
421
- /* @__PURE__ */ o(Re, { title: t("saas.login.titulo"), titleTypographyProps: { align: "center" } }),
422
- /* @__PURE__ */ o(ke, { sx: {
421
+ }, children: /* @__PURE__ */ d(te, { elevation: 5, children: [
422
+ /* @__PURE__ */ o(se, { title: i("saas.login.titulo"), titleTypographyProps: { align: "center" } }),
423
+ /* @__PURE__ */ o(ce, { sx: {
423
424
  "& .MuiTextField-root": {
424
425
  mb: 2
425
426
  }
426
- }, children: /* @__PURE__ */ o(le, { devURL: e }) })
427
+ }, children: /* @__PURE__ */ o(Z, { devURL: r }) })
427
428
  ] }) })
428
429
  ] }) }) }),
429
- /* @__PURE__ */ o(ze, { position: "static", color: "primary", children: /* @__PURE__ */ o(De, { sx: { justifyContent: "center" }, children: /* @__PURE__ */ d(A, { variant: "caption", children: [
430
- t("saas.copy"),
431
- /* @__PURE__ */ o(Ie, { href: "//chimera.com.pe", color: "inherit", target: "_blank", rel: "noreferrer", children: "Chimera Software" })
430
+ /* @__PURE__ */ o(le, { position: "static", color: "primary", children: /* @__PURE__ */ o(de, { sx: { justifyContent: "center" }, children: /* @__PURE__ */ d(j, { variant: "caption", children: [
431
+ i("saas.copy"),
432
+ /* @__PURE__ */ o(ue, { href: "//chimera.com.pe", color: "inherit", target: "_blank", rel: "noreferrer", children: "Chimera Software" })
432
433
  ] }) }) })
433
434
  ] });
434
435
  };
435
- de.propTypes = {
436
- devURL: i.string
436
+ W.propTypes = {
437
+ devURL: t.string
437
438
  };
438
- const ue = ({ devURL: e, redirectTo: r, children: t }) => {
439
- const a = Y();
440
- return ce(e) ? t : /* @__PURE__ */ o(ee, { to: r, state: { from: a }, replace: !0 });
439
+ const J = ({ devURL: r, redirectTo: e, children: i }) => {
440
+ const n = _();
441
+ return V(r) ? i : /* @__PURE__ */ o(F, { to: e, state: { from: n }, replace: !0 });
441
442
  };
442
- ue.propTypes = {
443
- devURL: i.string,
444
- redirectTo: i.string.isRequired,
445
- children: i.element.isRequired
443
+ J.propTypes = {
444
+ devURL: t.string,
445
+ redirectTo: t.string.isRequired,
446
+ children: t.element.isRequired
446
447
  };
447
- const pe = ({ devURL: e, requiereLogin: r, children: t }) => /* @__PURE__ */ o(Ze, { children: /* @__PURE__ */ d(We, { children: [
448
- /* @__PURE__ */ o(H, { path: "/login", element: /* @__PURE__ */ o(de, { devURL: e }) }),
448
+ const K = ({ devURL: r, requiereLogin: e, children: i }) => /* @__PURE__ */ o(Ae, { children: /* @__PURE__ */ d(Le, { children: [
449
+ /* @__PURE__ */ o(I, { path: "/login", element: /* @__PURE__ */ o(W, { devURL: r }) }),
449
450
  /* @__PURE__ */ o(
450
- H,
451
+ I,
451
452
  {
452
453
  path: "/*",
453
- element: r ? /* @__PURE__ */ o(ue, { devURL: e, redirectTo: "/login", children: t }) : t
454
+ element: e ? /* @__PURE__ */ o(J, { devURL: r, redirectTo: "/login", children: i }) : i
454
455
  }
455
456
  )
456
457
  ] }) });
457
- pe.propTypes = {
458
- devURL: i.string,
459
- requiereLogin: i.bool,
460
- children: i.element.isRequired
458
+ K.propTypes = {
459
+ devURL: t.string,
460
+ requiereLogin: t.bool,
461
+ children: t.element.isRequired
461
462
  };
462
- const he = ({ devURL: e, children: r }) => {
463
- const t = u((a) => a.aplicacion);
464
- return /* @__PURE__ */ o($, { sx: {
463
+ const Q = ({ devURL: r, children: e }) => {
464
+ const i = u((n) => n.aplicacion);
465
+ return /* @__PURE__ */ o(x, { sx: {
465
466
  display: "flex",
466
467
  flexDirection: "column",
467
468
  minHeight: "100vh",
468
469
  justifyContent: "flex-start",
469
470
  backgroundColor: "background.default"
470
- }, children: t.inicializando ? /* @__PURE__ */ o(er, {}) : t.error || !t.inicializado ? /* @__PURE__ */ o(rr, { titulo: "saas.inicializar.error.titulo", texto: "saas.inicializar.error.mensaje" }) : /* @__PURE__ */ d($e, { children: [
471
- /* @__PURE__ */ o(pe, { devURL: e, requiereLogin: t.instancia.requiereLogin, children: r }),
472
- /* @__PURE__ */ o(gr, {})
471
+ }, children: i.inicializando ? /* @__PURE__ */ o(Ie, {}) : i.error || !i.inicializado ? /* @__PURE__ */ o(De, { titulo: "saas.inicializar.error.titulo", texto: "saas.inicializar.error.mensaje" }) : /* @__PURE__ */ d(ee, { children: [
472
+ /* @__PURE__ */ o(K, { devURL: r, requiereLogin: i.instancia.requiereLogin, children: e }),
473
+ /* @__PURE__ */ o(We, {})
473
474
  ] }) });
474
475
  };
475
- he.propTypes = {
476
- devURL: i.string,
477
- children: i.element.isRequired
476
+ Q.propTypes = {
477
+ devURL: t.string,
478
+ children: t.element.isRequired
478
479
  };
479
- const fe = ({
480
- aplicacion: e,
481
- devSaasURL: r,
482
- devAuthURL: t,
483
- messages: a,
484
- idiomaDefecto: n,
480
+ const X = ({
481
+ aplicacion: r,
482
+ devSaasURL: e,
483
+ devAuthURL: i,
484
+ messages: n,
485
+ idiomaDefecto: a,
485
486
  children: c
486
487
  }) => {
487
- const s = m();
488
- return v(() => {
489
- s(S({ devURL: r, aplicacion: e }));
490
- }, [s, e, r]), /* @__PURE__ */ o(ie, { messages: a, idiomaDefecto: n, children: /* @__PURE__ */ o(se, { children: /* @__PURE__ */ o(he, { devURL: t, children: c }) }) });
488
+ const s = g();
489
+ return y(() => {
490
+ s(T({ devURL: e, aplicacion: r }));
491
+ }, [s, r, e]), /* @__PURE__ */ o($, { messages: n, idiomaDefecto: a, children: /* @__PURE__ */ o(H, { children: /* @__PURE__ */ o(Q, { devURL: i, children: c }) }) });
491
492
  };
492
- fe.propTypes = {
493
- aplicacion: i.string.isRequired,
494
- devSaasURL: i.string,
495
- devAuthURL: i.string,
496
- messages: i.object.isRequired,
497
- idiomaDefecto: i.string,
498
- children: i.element.isRequired
493
+ X.propTypes = {
494
+ aplicacion: t.string.isRequired,
495
+ devSaasURL: t.string,
496
+ devAuthURL: t.string,
497
+ messages: t.object.isRequired,
498
+ idiomaDefecto: t.string,
499
+ children: t.element.isRequired
499
500
  };
500
- const $r = ({
501
- customReducers: e,
502
- aplicacion: r,
503
- devSaasURL: t,
504
- devAuthURL: a,
505
- dev: n = !1,
501
+ const er = ({
502
+ customReducers: r,
503
+ aplicacion: e,
504
+ devSaasURL: i,
505
+ devAuthURL: n,
506
+ dev: a = !1,
506
507
  idiomaDefecto: c,
507
508
  messages: s,
508
- children: D
509
- }) => /* @__PURE__ */ o(Pe, { store: mr(e), children: /* @__PURE__ */ o(
510
- fe,
509
+ children: R
510
+ }) => /* @__PURE__ */ o(fe, { store: Ze(r), children: /* @__PURE__ */ o(
511
+ X,
511
512
  {
512
- aplicacion: r,
513
- devSaasURL: n ? t : void 0,
514
- devAuthURL: n ? a : void 0,
513
+ aplicacion: e,
514
+ devSaasURL: a ? i : void 0,
515
+ devAuthURL: a ? n : void 0,
515
516
  idiomaDefecto: c,
516
517
  messages: s,
517
- children: D
518
+ children: R
518
519
  }
519
520
  ) });
520
- $r.propTypes = {
521
- customReducers: i.object,
522
- aplicacion: i.string.isRequired,
523
- devSaasURL: i.string,
524
- devAuthURL: i.string,
525
- dev: i.bool,
526
- idiomaDefecto: i.string,
527
- messages: i.object,
528
- children: i.element.isRequired
521
+ er.propTypes = {
522
+ customReducers: t.object,
523
+ aplicacion: t.string.isRequired,
524
+ devSaasURL: t.string,
525
+ devAuthURL: t.string,
526
+ dev: t.bool,
527
+ idiomaDefecto: t.string,
528
+ messages: t.object,
529
+ children: t.element.isRequired
529
530
  };
530
- var x = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
531
- function xr(e) {
532
- return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
533
- }
534
- var Tr = typeof x == "object" && x && x.Object === Object && x, wr = Tr, Sr = wr, jr = typeof self == "object" && self && self.Object === Object && self, Or = Sr || jr || Function("return this")(), F = Or, Rr = F, kr = Rr.Symbol, me = kr, B = me, ge = Object.prototype, zr = ge.hasOwnProperty, Dr = ge.toString, C = B ? B.toStringTag : void 0;
535
- function Ir(e) {
536
- var r = zr.call(e, C), t = e[C];
537
- try {
538
- e[C] = void 0;
539
- var a = !0;
540
- } catch {
541
- }
542
- var n = Dr.call(e);
543
- return a && (r ? e[C] = t : delete e[C]), n;
544
- }
545
- var Ar = Ir, Lr = Object.prototype, Pr = Lr.toString;
546
- function Nr(e) {
547
- return Pr.call(e);
548
- }
549
- var qr = Nr, V = me, Fr = Ar, Mr = qr, Gr = "[object Null]", Er = "[object Undefined]", K = V ? V.toStringTag : void 0;
550
- function Hr(e) {
551
- return e == null ? e === void 0 ? Er : Gr : K && K in Object(e) ? Fr(e) : Mr(e);
552
- }
553
- var Ur = Hr;
554
- function Br(e) {
555
- var r = typeof e;
556
- return e != null && (r == "object" || r == "function");
557
- }
558
- var ve = Br, Vr = Ur, Kr = ve, Jr = "[object AsyncFunction]", Zr = "[object Function]", Wr = "[object GeneratorFunction]", Xr = "[object Proxy]";
559
- function Qr(e) {
560
- if (!Kr(e))
561
- return !1;
562
- var r = Vr(e);
563
- return r == Zr || r == Wr || r == Jr || r == Xr;
564
- }
565
- var Yr = Qr, et = F, rt = et["__core-js_shared__"], tt = rt, P = tt, J = function() {
566
- var e = /[^.]+$/.exec(P && P.keys && P.keys.IE_PROTO || "");
567
- return e ? "Symbol(src)_1." + e : "";
568
- }();
569
- function at(e) {
570
- return !!J && J in e;
571
- }
572
- var nt = at, ot = Function.prototype, it = ot.toString;
573
- function st(e) {
574
- if (e != null) {
575
- try {
576
- return it.call(e);
577
- } catch {
578
- }
579
- try {
580
- return e + "";
581
- } catch {
582
- }
583
- }
584
- return "";
585
- }
586
- var ct = st, lt = Yr, dt = nt, ut = ve, pt = ct, ht = /[\\^$.*+?()[\]{}|]/g, ft = /^\[object .+?Constructor\]$/, mt = Function.prototype, gt = Object.prototype, vt = mt.toString, yt = gt.hasOwnProperty, _t = RegExp(
587
- "^" + vt.call(yt).replace(ht, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
588
- );
589
- function bt(e) {
590
- if (!ut(e) || dt(e))
591
- return !1;
592
- var r = lt(e) ? _t : ft;
593
- return r.test(pt(e));
594
- }
595
- var Ct = bt;
596
- function $t(e, r) {
597
- return e == null ? void 0 : e[r];
598
- }
599
- var xt = $t, Tt = Ct, wt = xt;
600
- function St(e, r) {
601
- var t = wt(e, r);
602
- return Tt(t) ? t : void 0;
603
- }
604
- var ye = St, jt = ye, Ot = jt(Object, "create"), R = Ot, Z = R;
605
- function Rt() {
606
- this.__data__ = Z ? Z(null) : {}, this.size = 0;
607
- }
608
- var kt = Rt;
609
- function zt(e) {
610
- var r = this.has(e) && delete this.__data__[e];
611
- return this.size -= r ? 1 : 0, r;
612
- }
613
- var Dt = zt, It = R, At = "__lodash_hash_undefined__", Lt = Object.prototype, Pt = Lt.hasOwnProperty;
614
- function Nt(e) {
615
- var r = this.__data__;
616
- if (It) {
617
- var t = r[e];
618
- return t === At ? void 0 : t;
619
- }
620
- return Pt.call(r, e) ? r[e] : void 0;
621
- }
622
- var qt = Nt, Ft = R, Mt = Object.prototype, Gt = Mt.hasOwnProperty;
623
- function Et(e) {
624
- var r = this.__data__;
625
- return Ft ? r[e] !== void 0 : Gt.call(r, e);
626
- }
627
- var Ht = Et, Ut = R, Bt = "__lodash_hash_undefined__";
628
- function Vt(e, r) {
629
- var t = this.__data__;
630
- return this.size += this.has(e) ? 0 : 1, t[e] = Ut && r === void 0 ? Bt : r, this;
631
- }
632
- var Kt = Vt, Jt = kt, Zt = Dt, Wt = qt, Xt = Ht, Qt = Kt;
633
- function y(e) {
634
- var r = -1, t = e == null ? 0 : e.length;
635
- for (this.clear(); ++r < t; ) {
636
- var a = e[r];
637
- this.set(a[0], a[1]);
638
- }
639
- }
640
- y.prototype.clear = Jt;
641
- y.prototype.delete = Zt;
642
- y.prototype.get = Wt;
643
- y.prototype.has = Xt;
644
- y.prototype.set = Qt;
645
- var Yt = y;
646
- function ea() {
647
- this.__data__ = [], this.size = 0;
648
- }
649
- var ra = ea;
650
- function ta(e, r) {
651
- return e === r || e !== e && r !== r;
652
- }
653
- var aa = ta, na = aa;
654
- function oa(e, r) {
655
- for (var t = e.length; t--; )
656
- if (na(e[t][0], r))
657
- return t;
658
- return -1;
659
- }
660
- var k = oa, ia = k, sa = Array.prototype, ca = sa.splice;
661
- function la(e) {
662
- var r = this.__data__, t = ia(r, e);
663
- if (t < 0)
664
- return !1;
665
- var a = r.length - 1;
666
- return t == a ? r.pop() : ca.call(r, t, 1), --this.size, !0;
667
- }
668
- var da = la, ua = k;
669
- function pa(e) {
670
- var r = this.__data__, t = ua(r, e);
671
- return t < 0 ? void 0 : r[t][1];
672
- }
673
- var ha = pa, fa = k;
674
- function ma(e) {
675
- return fa(this.__data__, e) > -1;
676
- }
677
- var ga = ma, va = k;
678
- function ya(e, r) {
679
- var t = this.__data__, a = va(t, e);
680
- return a < 0 ? (++this.size, t.push([e, r])) : t[a][1] = r, this;
681
- }
682
- var _a = ya, ba = ra, Ca = da, $a = ha, xa = ga, Ta = _a;
683
- function _(e) {
684
- var r = -1, t = e == null ? 0 : e.length;
685
- for (this.clear(); ++r < t; ) {
686
- var a = e[r];
687
- this.set(a[0], a[1]);
688
- }
689
- }
690
- _.prototype.clear = ba;
691
- _.prototype.delete = Ca;
692
- _.prototype.get = $a;
693
- _.prototype.has = xa;
694
- _.prototype.set = Ta;
695
- var wa = _, Sa = ye, ja = F, Oa = Sa(ja, "Map"), Ra = Oa, W = Yt, ka = wa, za = Ra;
696
- function Da() {
697
- this.size = 0, this.__data__ = {
698
- hash: new W(),
699
- map: new (za || ka)(),
700
- string: new W()
701
- };
702
- }
703
- var Ia = Da;
704
- function Aa(e) {
705
- var r = typeof e;
706
- return r == "string" || r == "number" || r == "symbol" || r == "boolean" ? e !== "__proto__" : e === null;
707
- }
708
- var La = Aa, Pa = La;
709
- function Na(e, r) {
710
- var t = e.__data__;
711
- return Pa(r) ? t[typeof r == "string" ? "string" : "hash"] : t.map;
712
- }
713
- var z = Na, qa = z;
714
- function Fa(e) {
715
- var r = qa(this, e).delete(e);
716
- return this.size -= r ? 1 : 0, r;
717
- }
718
- var Ma = Fa, Ga = z;
719
- function Ea(e) {
720
- return Ga(this, e).get(e);
721
- }
722
- var Ha = Ea, Ua = z;
723
- function Ba(e) {
724
- return Ua(this, e).has(e);
725
- }
726
- var Va = Ba, Ka = z;
727
- function Ja(e, r) {
728
- var t = Ka(this, e), a = t.size;
729
- return t.set(e, r), this.size += t.size == a ? 0 : 1, this;
730
- }
731
- var Za = Ja, Wa = Ia, Xa = Ma, Qa = Ha, Ya = Va, en = Za;
732
- function b(e) {
733
- var r = -1, t = e == null ? 0 : e.length;
734
- for (this.clear(); ++r < t; ) {
735
- var a = e[r];
736
- this.set(a[0], a[1]);
737
- }
738
- }
739
- b.prototype.clear = Wa;
740
- b.prototype.delete = Xa;
741
- b.prototype.get = Qa;
742
- b.prototype.has = Ya;
743
- b.prototype.set = en;
744
- var rn = b, _e = rn, tn = "Expected a function";
745
- function M(e, r) {
746
- if (typeof e != "function" || r != null && typeof r != "function")
747
- throw new TypeError(tn);
748
- var t = function() {
749
- var a = arguments, n = r ? r.apply(this, a) : a[0], c = t.cache;
750
- if (c.has(n))
751
- return c.get(n);
752
- var s = e.apply(this, a);
753
- return t.cache = c.set(n, s) || c, s;
754
- };
755
- return t.cache = new (M.Cache || _e)(), t;
756
- }
757
- M.Cache = _e;
758
- var an = M;
759
- const be = /* @__PURE__ */ xr(an), nn = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/, h = (e) => typeof e > "u" || e === null || e === "" || Array.isArray(e) && e.length === 0, p = (e, r, t, a) => typeof e == "function" ? e({ args: r, value: t, values: a }) : r ? { message: e, args: r } : e, f = (e) => be(e, (...r) => JSON.stringify(r)), kn = (...e) => (r, t, a) => (Array.isArray(e[0]) ? e[0] : e).reduce(
760
- (c, s) => c || typeof s == "function" && s(r, t, a),
531
+ const rr = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/, m = (r) => typeof r > "u" || r === null || r === "" || Array.isArray(r) && r.length === 0, p = (r, e, i, n) => typeof r == "function" ? r({ args: e, value: i, values: n }) : e ? { message: r, args: e } : r, f = (r) => E(r, (...e) => JSON.stringify(e)), Ar = (...r) => (e, i, n) => (Array.isArray(r[0]) ? r[0] : r).reduce(
532
+ (c, s) => c || typeof s == "function" && s(e, i, n),
761
533
  void 0
762
- ), zn = f((e = "validacion.obligatorio") => Object.assign(
763
- (r, t) => h(r) ? p(e, void 0, r, t) : void 0,
534
+ ), Lr = f((r = "validacion.obligatorio") => Object.assign(
535
+ (e, i) => m(e) ? p(r, void 0, e, i) : void 0,
764
536
  { isRequired: !0 }
765
- )), Dn = f((e = "validacion.obligatorio") => Object.assign(
766
- (r, t) => h(r) || !r ? p(e, void 0, r, t) : void 0,
537
+ )), zr = f((r = "validacion.obligatorio") => Object.assign(
538
+ (e, i) => m(e) || !e ? p(r, void 0, e, i) : void 0,
767
539
  { isRequired: !0 }
768
- )), In = f((e = "validacion.numero") => (r, t) => !h(r) && isNaN(r) ? p(e, void 0, r, t) : void 0), An = f(
769
- (e, r = "validacion.longitud.minima") => (t, a) => !h(t) && t.length < e ? p(r, void 0, t, a) : void 0
770
- ), Ln = f(
771
- (e, r = "validacion.longitud.maxima") => (t, a) => !h(t) && t.length > e ? p(r, void 0, t, a) : void 0
772
- ), Pn = f(
773
- (e, r = "validacion.minimo") => (t, a) => !h(t) && parseFloat(t) < e ? p(r, void 0, t, a) : void 0
774
- ), Nn = f(
775
- (e, r = "validacion.maximo") => (t, a) => !h(t) && parseFloat(t) > e ? p(r, void 0, t, a) : void 0
776
- ), on = be(
777
- (e, r = "validacion.regex") => (t, a) => !h(t) && typeof t == "string" && !e.test(t) ? p(r, void 0, t, a) : void 0,
778
- (e, r) => e.toString() + r
779
- ), qn = f((e = "validacion.correo") => on(nn, e)), Fn = f((e, r, t = "validacion.remote") => (a, n, c) => c.active && !h(a) && e(a, r).then((s) => s ? p(t, void 0, a, n) : void 0).catch((s) => p(s.message, void 0, a, n)));
540
+ )), qr = f((r = "validacion.numero") => (e, i) => !m(e) && isNaN(e) ? p(r, void 0, e, i) : void 0), vr = f(
541
+ (r, e = "validacion.longitud.minima") => (i, n) => !m(i) && i.length < r ? p(e, void 0, i, n) : void 0
542
+ ), Ir = f(
543
+ (r, e = "validacion.longitud.maxima") => (i, n) => !m(i) && i.length > r ? p(e, void 0, i, n) : void 0
544
+ ), Dr = f(
545
+ (r, e = "validacion.minimo") => (i, n) => !m(i) && parseFloat(i) < r ? p(e, void 0, i, n) : void 0
546
+ ), Ur = f(
547
+ (r, e = "validacion.maximo") => (i, n) => !m(i) && parseFloat(i) > r ? p(e, void 0, i, n) : void 0
548
+ ), ir = E(
549
+ (r, e = "validacion.regex") => (i, n) => !m(i) && typeof i == "string" && !r.test(i) ? p(e, void 0, i, n) : void 0,
550
+ (r, e) => r.toString() + e
551
+ ), Nr = f((r = "validacion.correo") => ir(rr, r)), _r = f((r, e, i = "validacion.remote") => (n, a, c) => c.active && !m(n) && r(n, e).then((s) => s ? p(i, void 0, n, a) : void 0).catch((s) => p(s.message, void 0, n, a)));
780
552
  export {
781
- er as Cargando,
782
- rr as Error,
783
- $r as SaasApp,
784
- kn as composeValidators,
785
- qn as email,
786
- Rn as getInstancia,
787
- On as getPerfiles,
788
- Sn as getToken,
789
- jn as getUsuario,
790
- sr as logout,
791
- Nn as max,
792
- Ln as maxLength,
793
- Pn as min,
794
- An as minLength,
795
- In as number,
796
- on as regex,
797
- Fn as remote,
798
- zn as required,
799
- Dn as requiredNotFalse,
800
- Cr as useNotificar
553
+ Ie as Cargando,
554
+ De as Error,
555
+ er as SaasApp,
556
+ Ar as composeValidators,
557
+ Nr as email,
558
+ jr as getInstancia,
559
+ Sr as getPerfiles,
560
+ Cr as getToken,
561
+ Rr as getUsuario,
562
+ Oe as logout,
563
+ Ur as max,
564
+ Ir as maxLength,
565
+ Dr as min,
566
+ vr as minLength,
567
+ qr as number,
568
+ ir as regex,
569
+ _r as remote,
570
+ Lr as required,
571
+ zr as requiredNotFalse,
572
+ Ye as useNotificar
801
573
  };
@@ -1 +1 @@
1
- (function(o,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("react/jsx-runtime"),require("@mui/material"),require("react-polyglot"),require("prop-types"),require("react-redux"),require("@reduxjs/toolkit"),require("axios"),require("jwt-decode"),require("react"),require("date-fns/locale"),require("@mui/x-date-pickers"),require("@mui/x-date-pickers/AdapterDateFns"),require("navigator-languages"),require("@mui/material/styles"),require("@mui/material/colors"),require("react-router-dom"),require("@mui/icons-material"),require("react-final-form"),require("mui-rff")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@mui/material","react-polyglot","prop-types","react-redux","@reduxjs/toolkit","axios","jwt-decode","react","date-fns/locale","@mui/x-date-pickers","@mui/x-date-pickers/AdapterDateFns","navigator-languages","@mui/material/styles","@mui/material/colors","react-router-dom","@mui/icons-material","react-final-form","mui-rff"],t):(o=typeof globalThis<"u"?globalThis:o||self,t(o["react-saas"]={},o.ReactJSX,o.MuiMaterial,o.ReactPolyglot,o.PropTypes,o.ReactRedux,o.ReduxToolkit,o.Axios,o.JWTDecode,o.React,o.DateFNSLocale,o.MuiXDatePickers,o.MuiXDatePickersAdapter,o.NavigatorLanguages,o.MuiMaterialStyles,o.MuiMaterialColors,o.ReactRouterDom,o.MuiIconsMaterial,o.ReactFinalForm,o.MUIRFF))})(this,function(o,t,c,S,s,u,m,z,be,p,N,Se,$e,je,G,E,_,H,we,U){"use strict";const B=()=>t.jsx(c.Box,{sx:{display:"flex",flexDirection:"column",flexGrow:1,justifyContent:"center",alignItems:"center"},children:t.jsx(c.CircularProgress,{})}),V=({titulo:e,texto:r,align:a="center",severity:n="error"})=>{const i=S.useTranslate();return t.jsx(c.Box,{sx:{display:"flex",flexDirection:"column",flexGrow:1,justifyContent:"center",alignItems:a},children:t.jsxs(c.Alert,{severity:n,children:[t.jsx(c.AlertTitle,{children:i(e)}),r&&i(r)]})})};Error.propTypes={titulo:s.string.isRequired,texto:s.string,align:s.string,severity:s.string};const J=m.createSlice({name:"ui",initialState:{tema:"light",temaSeleccionado:!1,idioma:"es"},reducers:{cambiarTema:(e,r)=>{e.tema=r.payload,e.temaSeleccionado=!0,localStorage.setItem("tema",r.payload)},cambiarIdioma:(e,r)=>{e.idioma=r.payload}}}),{cambiarTema:xe,cambiarIdioma:Te}=J.actions,ke=J.reducer,Oe="https://saas.chimera.com.pe/backend",qe="https://saas.chimera.com.pe/oauth",K=(e=qe)=>({login:(r,a)=>z({url:`${e}/oauth/token`,headers:{"content-type":"application/x-www-form-urlencoded",Authorization:`Basic ${r}`},method:"post",data:{username:a.correo,password:a.password,grant_type:"password"}}),refreshToken:(r,a)=>z({url:`${e}/oauth/token`,headers:{"content-type":"application/x-www-form-urlencoded",Authorization:`Basic ${r}`},method:"post",data:{refresh_token:a,grant_type:"refresh_token"}})}),X=m.createSlice({name:"login",initialState:{cargando:!1,autenticado:!1,token:null,refreshToken:null,expiracion:null,usuario:null,perfiles:[],error:null},reducers:{logout:e=>{e.cargando=!1,e.autenticado=!1,e.token=null,e.refreshToken=null,e.expiracion=null,e.usuario=null,e.perfiles=[],e.error=null}},extraReducers(e){e.addCase(j.pending,r=>{r.cargando=!0,r.error=null}).addCase(j.fulfilled,(r,a)=>{const n=a.payload.access_token,i=be(n),d=new Date;d.setSeconds(d.getSeconds()+a.payload.expires_in),r.cargando=!1,r.autenticado=!0,r.token=n,r.refreshToken=a.payload.refresh_token,r.expiracion=d.getTime(),r.usuario=i.name,r.perfiles=i.authorities}).addCase(j.rejected,(r,a)=>{var n;console.log(a),r.cargando=!1,r.autenticado=!1,r.token=null,r.refreshToken=null,r.expiracion=null,r.usuario=null,r.perfiles=[],r.error=(n=a.error)==null?void 0:n.message}).addCase(w.pending,r=>{r.cargando=!0}).addCase(w.fulfilled,(r,a)=>{const n=new Date;n.setSeconds(n.getSeconds()+a.payload.expires_in),r.token=a.payload.access_token,r.refreshToken=a.payload.refresh_token,r.expiracion=n.getTime()}).addCase(w.rejected,(r,a)=>{var n;r.cargando=!1,r.autenticado=!1,r.token=null,r.refreshToken=null,r.expiracion=null,r.usuario=null,r.perfiles=[],r.error=(n=a.error)==null?void 0:n.message})}}),j=m.createAsyncThunk("login/requestToken",async e=>(await K(e.devURL).login(e.clientCredentials,e.data)).data),w=m.createAsyncThunk("login/refreshToken",async(e,r,a)=>(await K(e).refreshToken(r,a)).data),{logout:W}=X.actions,ze=e=>e.token,De=e=>e.usuario,Ae=e=>e.perfiles,Ie=X.reducer,Z=m.createSlice({name:"notificacion",initialState:[],reducers:{mostrarNotificacion:(e,r)=>{e.push(r.payload)},ocultarNotificacion:e=>{e.pop()}}}),{mostrarNotificacion:Le,ocultarNotificacion:Me}=Z.actions,Fe=Z.reducer,Ne=(e=Oe,r)=>z({url:`${e}/identidad/`,params:{codigoAplicacion:r}}),D={primary:"#1C6CCC",secondary:"#17A7FF",error:"#f44336",warning:"#ff9800",info:"#2196f3",success:"#4caf50"},Ge=m.createSlice({name:"inicializar",initialState:{inicializando:!0,inicializado:!1,instancia:{color:D},error:null},extraReducers(e){e.addCase(x.pending,r=>{r.inicializando=!0}).addCase(x.fulfilled,(r,a)=>{r.inicializando=!1,r.inicializado=!0,r.instancia={...a.payload,abreviatura:a.payload.nombre.match(/\b([A-Z])/g).join(""),color:{...D,...a.payload.color}},r.error=null}).addCase(x.rejected,(r,a)=>{r.inicializando=!1,r.inicializado=!1,r.instancia={color:D},r.error=a.payload})}}),x=m.createAsyncThunk("inicializar",async e=>(await Ne(e.devURL,e.aplicacion)).data),Ee=e=>e.instancia,He=Ge.reducer,Ue=e=>m.configureStore({reducer:{ui:ke,aplicacion:He,login:Ie,notificaciones:Fe,...e}}),Be=()=>{const[e,r]=p.useState(!1),a=u.useDispatch(),n=S.useTranslate(),i=u.useSelector(l=>l.notificaciones[0]);p.useEffect(()=>{r(!!i)},[i]);const d=()=>{r(!1),a(Me())};return t.jsx(c.Snackbar,{open:e,message:(i==null?void 0:i.mensaje)&&i.tipo==="default"&&n(i.mensaje),autoHideDuration:5e3,onClose:d,children:(i==null?void 0:i.mensaje)&&i.tipo!=="default"&&t.jsx(c.Alert,{severity:i.tipo,children:n(i.mensaje)})})},Ve={es:{inicializar:{error:{titulo:"Error iniciando aplicación",mensaje:"No fue posible conectarnos con el servicio"}},login:{titulo:"Acceder al sistema",correo:"Correo electrónico",password:"Contraseña",ingresar:"Acceder",validacion:{correo:"Debe ingresar una dirección de correo",password:"Debe ingresar una contraseña"},error:"Usuario o contraseña incorrectos"},copy:"Todos los derechos reservados "}},Je={en:N.enGB,es:N.es},Q=({messages:e,children:r})=>{const a=u.useSelector(n=>n.ui.idioma);return t.jsx(S.I18n,{locale:a,messages:e[a],children:t.jsx(Se.LocalizationProvider,{dateAdapter:$e.AdapterDateFns,adapterLocale:Je[a],children:r})})};Q.propTypes={messages:s.object,children:s.element.isRequired};const Ke=()=>{const e=je();if(!(e!=null&&e.length))return;const r=e[0];return r.indexOf("-")?r.substring(0,r.indexOf("-")):r},Y=({messages:e,idiomaDefecto:r,children:a})=>{const n=u.useDispatch(),i=Ke();p.useEffect(()=>{let l=Reflect.ownKeys(e)[0];i&&Object.hasOwn(e,i)?l=i:r&&Object.hasOwn(e,r)&&(l=r),n(Te(l))},[n,e,r,i]);const d={};return Object.keys(e).forEach(l=>{d[l]={...e[l],saas:Ve[l]}}),t.jsx(Q,{messages:d,children:a})};Y.propTypes={messages:s.object,idiomaDefecto:s.string,children:s.element.isRequired};const P=({children:e})=>{const r=u.useDispatch(),{instancia:a}=u.useSelector(l=>l.aplicacion),n=u.useSelector(l=>l.ui.tema),i=c.useMediaQuery("(prefers-color-scheme: dark)");p.useEffect(()=>{r(xe(i?"dark":"light"))},[r,i]);const d=p.useMemo(()=>G.createTheme({palette:{mode:n,primary:{main:a.color.primary},secondary:{main:a.color.secondary},error:{main:a.color.error},warning:{main:a.color.warning},info:{main:a.color.info},success:{main:a.color.success},...n==="light"&&{background:{default:E.grey.A200,paper:E.grey[100]}}},shape:{borderRadius:6}}),[n,a]);return t.jsxs(G.ThemeProvider,{theme:d,children:[t.jsx(c.CssBaseline,{}),e]})};P.propTypes={children:s.element.isRequired};const R=e=>{const r=u.useDispatch(),a=u.useSelector(i=>i.login),n=u.useSelector(i=>i.aplicacion.instancia);return p.useEffect(()=>{a.autenticado&&a.expiracion&&new Date(a.expiracion)<new Date&&(a.refreshToken?r(w(e,n.clientCredentials,a.refreshToken)):r(W()))},[e,n.clientCredentials,a,r]),a.autenticado},ee=()=>{const e=u.useDispatch();return p.useCallback((r,a="default")=>{e(Le({mensaje:r,tipo:a}))},[e])},re=({devURL:e})=>{const r=u.useDispatch(),a=S.useTranslate(),n=ee(),{cargando:i,error:d}=u.useSelector(h=>h.login),l=u.useSelector(h=>h.aplicacion.instancia),M=h=>{r(j({devURL:e,clientCredentials:l.clientCredentials,data:{correo:h.correo,password:h.password}}))},En=h=>{const F={correo:void 0,password:void 0};return h.correo||(F.correo=a("saas.login.validacion.correo")),h.password||(F.password=a("saas.login.validacion.password")),F};return p.useEffect(()=>{d&&n("saas.login.error","error")},[n,d]),t.jsx(we.Form,{onSubmit:M,validate:En,render:({handleSubmit:h})=>t.jsxs("form",{onSubmit:h,children:[t.jsx(U.TextField,{id:"correo",name:"correo",label:a("saas.login.correo"),variant:"outlined",autoComplete:"off",disabled:i,autoFocus:!0,InputProps:{startAdornment:t.jsx(c.InputAdornment,{position:"start",children:t.jsx(H.Email,{color:"primary"})})}}),t.jsx(U.TextField,{id:"password",name:"password",type:"password",label:a("saas.login.password"),variant:"outlined",autoComplete:"current-password",disabled:i,InputProps:{startAdornment:t.jsx(c.InputAdornment,{position:"start",children:t.jsx(H.Lock,{color:"primary"})})}}),t.jsxs(c.Grid,{container:!0,children:[t.jsx(c.Grid,{item:!0,xs:6}),t.jsx(c.Grid,{item:!0,xs:6,align:"right",children:t.jsx(c.Button,{variant:"contained",color:"primary",type:"submit",disabled:i,children:i?t.jsx(c.CircularProgress,{size:24,thickness:4}):a("saas.login.ingresar")})})]})]})})};re.propTypes={devURL:s.string};const ae=({devURL:e})=>{const r=u.useSelector(l=>l.aplicacion.instancia),a=S.useTranslate(),n=_.useLocation(),i=R(e),{from:d}=n.state||{from:{pathname:"/"}};return!r.requiereLogin||i?t.jsx(_.Navigate,{to:d}):t.jsxs(c.Box,{sx:{position:"relative",display:"flex",flexDirection:"column",flexGrow:1,minHeight:"100vh",backgroundColor:"primary.main","&::before":{content:'""',backgroundImage:`url(${r.logo})`,backgroundSize:"contain",backgroundRepeat:"no-repeat",backgroundPosition:"right",position:"absolute",top:"20%",bottom:0,right:0,width:"50%",opacity:.02,filter:"grayscale(100%)"}},children:[t.jsx(c.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",flexGrow:1},children:t.jsx(c.Container,{maxWidth:"md",children:t.jsxs(c.Grid,{container:!0,spacing:3,children:[t.jsxs(c.Grid,{item:!0,xs:12,lg:5,align:"center",children:[t.jsx("img",{src:r.logo,alt:r.nombre,style:{maxWidth:"100%"}}),t.jsx(c.Typography,{variant:"h3",align:"center",children:a("aplicacion.nombre",{smart_count:1})}),t.jsx(c.Typography,{variant:"h5",align:"center",children:r.nombre})]}),t.jsx(c.Grid,{item:!0,xs:12,lg:7,sx:{display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:t.jsxs(c.Card,{elevation:5,children:[t.jsx(c.CardHeader,{title:a("saas.login.titulo"),titleTypographyProps:{align:"center"}}),t.jsx(c.CardContent,{sx:{"& .MuiTextField-root":{mb:2}},children:t.jsx(re,{devURL:e})})]})})]})})}),t.jsx(c.AppBar,{position:"static",color:"primary",children:t.jsx(c.Toolbar,{sx:{justifyContent:"center"},children:t.jsxs(c.Typography,{variant:"caption",children:[a("saas.copy"),t.jsx(c.Link,{href:"//chimera.com.pe",color:"inherit",target:"_blank",rel:"noreferrer",children:"Chimera Software"})]})})})]})};ae.propTypes={devURL:s.string};const ne=({devURL:e,redirectTo:r,children:a})=>{const n=_.useLocation();return R(e)?a:t.jsx(_.Navigate,{to:r,state:{from:n},replace:!0})};ne.propTypes={devURL:s.string,redirectTo:s.string.isRequired,children:s.element.isRequired};const te=({devURL:e,requiereLogin:r,children:a})=>t.jsx(_.BrowserRouter,{children:t.jsxs(_.Routes,{children:[t.jsx(_.Route,{path:"/login",element:t.jsx(ae,{devURL:e})}),t.jsx(_.Route,{path:"/*",element:r?t.jsx(ne,{devURL:e,redirectTo:"/login",children:a}):a})]})});te.propTypes={devURL:s.string,requiereLogin:s.bool,children:s.element.isRequired};const ie=({devURL:e,children:r})=>{const a=u.useSelector(n=>n.aplicacion);return t.jsx(c.Box,{sx:{display:"flex",flexDirection:"column",minHeight:"100vh",justifyContent:"flex-start",backgroundColor:"background.default"},children:a.inicializando?t.jsx(B,{}):a.error||!a.inicializado?t.jsx(V,{titulo:"saas.inicializar.error.titulo",texto:"saas.inicializar.error.mensaje"}):t.jsxs(t.Fragment,{children:[t.jsx(te,{devURL:e,requiereLogin:a.instancia.requiereLogin,children:r}),t.jsx(Be,{})]})})};ie.propTypes={devURL:s.string,children:s.element.isRequired};const oe=({aplicacion:e,devSaasURL:r,devAuthURL:a,messages:n,idiomaDefecto:i,children:d})=>{const l=u.useDispatch();return p.useEffect(()=>{l(x({devURL:r,aplicacion:e}))},[l,e,r]),t.jsx(Y,{messages:n,idiomaDefecto:i,children:t.jsx(P,{children:t.jsx(ie,{devURL:a,children:d})})})};oe.propTypes={aplicacion:s.string.isRequired,devSaasURL:s.string,devAuthURL:s.string,messages:s.object.isRequired,idiomaDefecto:s.string,children:s.element.isRequired};const se=({customReducers:e,aplicacion:r,devSaasURL:a,devAuthURL:n,dev:i=!1,idiomaDefecto:d,messages:l,children:M})=>t.jsx(u.Provider,{store:Ue(e),children:t.jsx(oe,{aplicacion:r,devSaasURL:i?a:void 0,devAuthURL:i?n:void 0,idiomaDefecto:d,messages:l,children:M})});se.propTypes={customReducers:s.object,aplicacion:s.string.isRequired,devSaasURL:s.string,devAuthURL:s.string,dev:s.bool,idiomaDefecto:s.string,messages:s.object,children:s.element.isRequired};var T=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Xe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var We=typeof T=="object"&&T&&T.Object===Object&&T,Ze=We,Qe=Ze,Ye=typeof self=="object"&&self&&self.Object===Object&&self,Pe=Qe||Ye||Function("return this")(),A=Pe,Re=A,er=Re.Symbol,ce=er,le=ce,de=Object.prototype,rr=de.hasOwnProperty,ar=de.toString,$=le?le.toStringTag:void 0;function nr(e){var r=rr.call(e,$),a=e[$];try{e[$]=void 0;var n=!0}catch{}var i=ar.call(e);return n&&(r?e[$]=a:delete e[$]),i}var tr=nr,ir=Object.prototype,or=ir.toString;function sr(e){return or.call(e)}var cr=sr,ue=ce,lr=tr,dr=cr,ur="[object Null]",hr="[object Undefined]",he=ue?ue.toStringTag:void 0;function fr(e){return e==null?e===void 0?hr:ur:he&&he in Object(e)?lr(e):dr(e)}var pr=fr;function gr(e){var r=typeof e;return e!=null&&(r=="object"||r=="function")}var fe=gr,vr=pr,mr=fe,_r="[object AsyncFunction]",yr="[object Function]",Cr="[object GeneratorFunction]",br="[object Proxy]";function Sr(e){if(!mr(e))return!1;var r=vr(e);return r==yr||r==Cr||r==_r||r==br}var $r=Sr,jr=A,wr=jr["__core-js_shared__"],xr=wr,I=xr,pe=function(){var e=/[^.]+$/.exec(I&&I.keys&&I.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Tr(e){return!!pe&&pe in e}var kr=Tr,Or=Function.prototype,qr=Or.toString;function zr(e){if(e!=null){try{return qr.call(e)}catch{}try{return e+""}catch{}}return""}var Dr=zr,Ar=$r,Ir=kr,Lr=fe,Mr=Dr,Fr=/[\\^$.*+?()[\]{}|]/g,Nr=/^\[object .+?Constructor\]$/,Gr=Function.prototype,Er=Object.prototype,Hr=Gr.toString,Ur=Er.hasOwnProperty,Br=RegExp("^"+Hr.call(Ur).replace(Fr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Vr(e){if(!Lr(e)||Ir(e))return!1;var r=Ar(e)?Br:Nr;return r.test(Mr(e))}var Jr=Vr;function Kr(e,r){return e==null?void 0:e[r]}var Xr=Kr,Wr=Jr,Zr=Xr;function Qr(e,r){var a=Zr(e,r);return Wr(a)?a:void 0}var ge=Qr,Yr=ge,Pr=Yr(Object,"create"),k=Pr,ve=k;function Rr(){this.__data__=ve?ve(null):{},this.size=0}var ea=Rr;function ra(e){var r=this.has(e)&&delete this.__data__[e];return this.size-=r?1:0,r}var aa=ra,na=k,ta="__lodash_hash_undefined__",ia=Object.prototype,oa=ia.hasOwnProperty;function sa(e){var r=this.__data__;if(na){var a=r[e];return a===ta?void 0:a}return oa.call(r,e)?r[e]:void 0}var ca=sa,la=k,da=Object.prototype,ua=da.hasOwnProperty;function ha(e){var r=this.__data__;return la?r[e]!==void 0:ua.call(r,e)}var fa=ha,pa=k,ga="__lodash_hash_undefined__";function va(e,r){var a=this.__data__;return this.size+=this.has(e)?0:1,a[e]=pa&&r===void 0?ga:r,this}var ma=va,_a=ea,ya=aa,Ca=ca,ba=fa,Sa=ma;function y(e){var r=-1,a=e==null?0:e.length;for(this.clear();++r<a;){var n=e[r];this.set(n[0],n[1])}}y.prototype.clear=_a,y.prototype.delete=ya,y.prototype.get=Ca,y.prototype.has=ba,y.prototype.set=Sa;var $a=y;function ja(){this.__data__=[],this.size=0}var wa=ja;function xa(e,r){return e===r||e!==e&&r!==r}var Ta=xa,ka=Ta;function Oa(e,r){for(var a=e.length;a--;)if(ka(e[a][0],r))return a;return-1}var O=Oa,qa=O,za=Array.prototype,Da=za.splice;function Aa(e){var r=this.__data__,a=qa(r,e);if(a<0)return!1;var n=r.length-1;return a==n?r.pop():Da.call(r,a,1),--this.size,!0}var Ia=Aa,La=O;function Ma(e){var r=this.__data__,a=La(r,e);return a<0?void 0:r[a][1]}var Fa=Ma,Na=O;function Ga(e){return Na(this.__data__,e)>-1}var Ea=Ga,Ha=O;function Ua(e,r){var a=this.__data__,n=Ha(a,e);return n<0?(++this.size,a.push([e,r])):a[n][1]=r,this}var Ba=Ua,Va=wa,Ja=Ia,Ka=Fa,Xa=Ea,Wa=Ba;function C(e){var r=-1,a=e==null?0:e.length;for(this.clear();++r<a;){var n=e[r];this.set(n[0],n[1])}}C.prototype.clear=Va,C.prototype.delete=Ja,C.prototype.get=Ka,C.prototype.has=Xa,C.prototype.set=Wa;var Za=C,Qa=ge,Ya=A,Pa=Qa(Ya,"Map"),Ra=Pa,me=$a,en=Za,rn=Ra;function an(){this.size=0,this.__data__={hash:new me,map:new(rn||en),string:new me}}var nn=an;function tn(e){var r=typeof e;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?e!=="__proto__":e===null}var on=tn,sn=on;function cn(e,r){var a=e.__data__;return sn(r)?a[typeof r=="string"?"string":"hash"]:a.map}var q=cn,ln=q;function dn(e){var r=ln(this,e).delete(e);return this.size-=r?1:0,r}var un=dn,hn=q;function fn(e){return hn(this,e).get(e)}var pn=fn,gn=q;function vn(e){return gn(this,e).has(e)}var mn=vn,_n=q;function yn(e,r){var a=_n(this,e),n=a.size;return a.set(e,r),this.size+=a.size==n?0:1,this}var Cn=yn,bn=nn,Sn=un,$n=pn,jn=mn,wn=Cn;function b(e){var r=-1,a=e==null?0:e.length;for(this.clear();++r<a;){var n=e[r];this.set(n[0],n[1])}}b.prototype.clear=bn,b.prototype.delete=Sn,b.prototype.get=$n,b.prototype.has=jn,b.prototype.set=wn;var xn=b,_e=xn,Tn="Expected a function";function L(e,r){if(typeof e!="function"||r!=null&&typeof r!="function")throw new TypeError(Tn);var a=function(){var n=arguments,i=r?r.apply(this,n):n[0],d=a.cache;if(d.has(i))return d.get(i);var l=e.apply(this,n);return a.cache=d.set(i,l)||d,l};return a.cache=new(L.Cache||_e),a}L.Cache=_e;var kn=L;const ye=Xe(kn),On=/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,g=e=>typeof e>"u"||e===null||e===""||Array.isArray(e)&&e.length===0,f=(e,r,a,n)=>typeof e=="function"?e({args:r,value:a,values:n}):r?{message:e,args:r}:e,v=e=>ye(e,(...r)=>JSON.stringify(r)),qn=(...e)=>(r,a,n)=>(Array.isArray(e[0])?e[0]:e).reduce((d,l)=>d||typeof l=="function"&&l(r,a,n),void 0),zn=v((e="validacion.obligatorio")=>Object.assign((r,a)=>g(r)?f(e,void 0,r,a):void 0,{isRequired:!0})),Dn=v((e="validacion.obligatorio")=>Object.assign((r,a)=>g(r)||!r?f(e,void 0,r,a):void 0,{isRequired:!0})),An=v((e="validacion.numero")=>(r,a)=>!g(r)&&isNaN(r)?f(e,void 0,r,a):void 0),In=v((e,r="validacion.longitud.minima")=>(a,n)=>!g(a)&&a.length<e?f(r,void 0,a,n):void 0),Ln=v((e,r="validacion.longitud.maxima")=>(a,n)=>!g(a)&&a.length>e?f(r,void 0,a,n):void 0),Mn=v((e,r="validacion.minimo")=>(a,n)=>!g(a)&&parseFloat(a)<e?f(r,void 0,a,n):void 0),Fn=v((e,r="validacion.maximo")=>(a,n)=>!g(a)&&parseFloat(a)>e?f(r,void 0,a,n):void 0),Ce=ye((e,r="validacion.regex")=>(a,n)=>!g(a)&&typeof a=="string"&&!e.test(a)?f(r,void 0,a,n):void 0,(e,r)=>e.toString()+r),Nn=v((e="validacion.correo")=>Ce(On,e)),Gn=v((e,r,a="validacion.remote")=>(n,i,d)=>d.active&&!g(n)&&e(n,r).then(l=>l?f(a,void 0,n,i):void 0).catch(l=>f(l.message,void 0,n,i)));o.Cargando=B,o.Error=V,o.SaasApp=se,o.composeValidators=qn,o.email=Nn,o.getInstancia=Ee,o.getPerfiles=Ae,o.getToken=ze,o.getUsuario=De,o.logout=W,o.max=Fn,o.maxLength=Ln,o.min=Mn,o.minLength=In,o.number=An,o.regex=Ce,o.remote=Gn,o.required=zn,o.requiredNotFalse=Dn,o.useNotificar=ee,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
1
+ (function(s,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("react/jsx-runtime"),require("@mui/material"),require("react-polyglot"),require("prop-types"),require("react-redux"),require("@reduxjs/toolkit"),require("axios"),require("jwt-decode"),require("react"),require("date-fns/locale"),require("@mui/x-date-pickers"),require("@mui/x-date-pickers/AdapterDateFns"),require("navigator-languages"),require("@mui/material/styles"),require("@mui/material/colors"),require("react-router-dom"),require("@mui/icons-material"),require("react-final-form"),require("mui-rff"),require("lodash/memoize")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@mui/material","react-polyglot","prop-types","react-redux","@reduxjs/toolkit","axios","jwt-decode","react","date-fns/locale","@mui/x-date-pickers","@mui/x-date-pickers/AdapterDateFns","navigator-languages","@mui/material/styles","@mui/material/colors","react-router-dom","@mui/icons-material","react-final-form","mui-rff","lodash/memoize"],r):(s=typeof globalThis<"u"?globalThis:s||self,r(s["react-saas"]={},s.ReactJSX,s.MuiMaterial,s.ReactPolyglot,s.PropTypes,s.ReactRedux,s.ReduxToolkit,s.Axios,s.JWTDecode,s.React,s.DateFNSLocale,s.MuiXDatePickers,s.MuiXDatePickersAdapter,s.NavigatorLanguages,s.MuiMaterialStyles,s.MuiMaterialColors,s.ReactRouterDom,s.MuiIconsMaterial,s.ReactFinalForm,s.MUIRFF,s.LodashMemoize))})(this,function(s,r,t,S,c,u,y,x,R,p,L,ee,ie,ne,z,v,k,T,re,I,D){"use strict";const F=()=>r.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",flexGrow:1,justifyContent:"center",alignItems:"center"},children:r.jsx(t.CircularProgress,{})}),N=({titulo:i,texto:e,align:n="center",severity:o="error"})=>{const a=S.useTranslate();return r.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",flexGrow:1,justifyContent:"center",alignItems:n},children:r.jsxs(t.Alert,{severity:o,children:[r.jsx(t.AlertTitle,{children:a(i)}),e&&a(e)]})})};Error.propTypes={titulo:c.string.isRequired,texto:c.string,align:c.string,severity:c.string};const M=y.createSlice({name:"ui",initialState:{tema:"light",temaSeleccionado:!1,idioma:"es"},reducers:{cambiarTema:(i,e)=>{i.tema=e.payload,i.temaSeleccionado=!0,localStorage.setItem("tema",e.payload)},cambiarIdioma:(i,e)=>{i.idioma=e.payload}}}),{cambiarTema:oe,cambiarIdioma:ae}=M.actions,se=M.reducer,ce="https://saas.chimera.com.pe/backend",te="https://saas.chimera.com.pe/oauth",U=(i=te)=>({login:(e,n)=>x({url:`${i}/oauth/token`,headers:{"content-type":"application/x-www-form-urlencoded",Authorization:`Basic ${e}`},method:"post",data:{username:n.correo,password:n.password,grant_type:"password"}}),refreshToken:(e,n)=>x({url:`${i}/oauth/token`,headers:{"content-type":"application/x-www-form-urlencoded",Authorization:`Basic ${e}`},method:"post",data:{refresh_token:n,grant_type:"refresh_token"}})}),E=y.createSlice({name:"login",initialState:{cargando:!1,autenticado:!1,token:null,refreshToken:null,expiracion:null,usuario:null,perfiles:[],error:null},reducers:{logout:i=>{i.cargando=!1,i.autenticado=!1,i.token=null,i.refreshToken=null,i.expiracion=null,i.usuario=null,i.perfiles=[],i.error=null}},extraReducers(i){i.addCase(q.pending,e=>{e.cargando=!0,e.error=null}).addCase(q.fulfilled,(e,n)=>{const o=n.payload.access_token,a=R(o),l=new Date;l.setSeconds(l.getSeconds()+n.payload.expires_in),e.cargando=!1,e.autenticado=!0,e.token=o,e.refreshToken=n.payload.refresh_token,e.expiracion=l.getTime(),e.usuario=a.name,e.perfiles=a.authorities}).addCase(q.rejected,(e,n)=>{var o;console.log(n),e.cargando=!1,e.autenticado=!1,e.token=null,e.refreshToken=null,e.expiracion=null,e.usuario=null,e.perfiles=[],e.error=(o=n.error)==null?void 0:o.message}).addCase(C.pending,e=>{e.cargando=!0}).addCase(C.fulfilled,(e,n)=>{const o=new Date;o.setSeconds(o.getSeconds()+n.payload.expires_in),e.token=n.payload.access_token,e.refreshToken=n.payload.refresh_token,e.expiracion=o.getTime()}).addCase(C.rejected,(e,n)=>{var o;e.cargando=!1,e.autenticado=!1,e.token=null,e.refreshToken=null,e.expiracion=null,e.usuario=null,e.perfiles=[],e.error=(o=n.error)==null?void 0:o.message})}}),q=y.createAsyncThunk("login/requestToken",async i=>(await U(i.devURL).login(i.clientCredentials,i.data)).data),C=y.createAsyncThunk("login/refreshToken",async(i,e,n)=>(await U(i).refreshToken(e,n)).data),{logout:_}=E.actions,de=i=>i.login.token,le=i=>i.login.usuario,ue=i=>i.login.perfiles,fe=E.reducer,B=y.createSlice({name:"notificacion",initialState:[],reducers:{mostrarNotificacion:(i,e)=>{i.push(e.payload)},ocultarNotificacion:i=>{i.pop()}}}),{mostrarNotificacion:ge,ocultarNotificacion:pe}=B.actions,he=B.reducer,me=(i=ce,e)=>x({url:`${i}/identidad/`,params:{codigoAplicacion:e}}),b={primary:"#1C6CCC",secondary:"#17A7FF",error:"#f44336",warning:"#ff9800",info:"#2196f3",success:"#4caf50"},ye=y.createSlice({name:"inicializar",initialState:{inicializando:!0,inicializado:!1,instancia:{color:b},error:null},extraReducers(i){i.addCase(w.pending,e=>{e.inicializando=!0}).addCase(w.fulfilled,(e,n)=>{e.inicializando=!1,e.inicializado=!0,e.instancia={...n.payload,abreviatura:n.payload.nombre.match(/\b([A-Z])/g).join(""),color:{...b,...n.payload.color}},e.error=null}).addCase(w.rejected,(e,n)=>{e.inicializando=!1,e.inicializado=!1,e.instancia={color:b},e.error=n.payload})}}),w=y.createAsyncThunk("inicializar",async i=>(await me(i.devURL,i.aplicacion)).data),ke=i=>i.aplicacion.instancia,Se=ye.reducer,qe=i=>y.configureStore({reducer:{ui:se,aplicacion:Se,login:fe,notificaciones:he,...i}}),Ce=()=>{const[i,e]=p.useState(!1),n=u.useDispatch(),o=S.useTranslate(),a=u.useSelector(d=>d.notificaciones[0]);p.useEffect(()=>{e(!!a)},[a]);const l=()=>{e(!1),n(pe())};return r.jsx(t.Snackbar,{open:i,message:(a==null?void 0:a.mensaje)&&a.tipo==="default"&&o(a.mensaje),autoHideDuration:5e3,onClose:l,children:(a==null?void 0:a.mensaje)&&a.tipo!=="default"&&r.jsx(t.Alert,{severity:a.tipo,children:o(a.mensaje)})})},we={es:{inicializar:{error:{titulo:"Error iniciando aplicación",mensaje:"No fue posible conectarnos con el servicio"}},login:{titulo:"Acceder al sistema",correo:"Correo electrónico",password:"Contraseña",ingresar:"Acceder",validacion:{correo:"Debe ingresar una dirección de correo",password:"Debe ingresar una contraseña"},error:"Usuario o contraseña incorrectos"},copy:"Todos los derechos reservados "}},xe={en:L.enGB,es:L.es},G=({messages:i,children:e})=>{const n=u.useSelector(o=>o.ui.idioma);return r.jsx(S.I18n,{locale:n,messages:i[n],children:r.jsx(ee.LocalizationProvider,{dateAdapter:ie.AdapterDateFns,adapterLocale:xe[n],children:e})})};G.propTypes={messages:c.object,children:c.element.isRequired};const be=()=>{const i=ne();if(!(i!=null&&i.length))return;const e=i[0];return e.indexOf("-")?e.substring(0,e.indexOf("-")):e},O=({messages:i,idiomaDefecto:e,children:n})=>{const o=u.useDispatch(),a=be();p.useEffect(()=>{let d=Reflect.ownKeys(i)[0];a&&Object.hasOwn(i,a)?d=a:e&&Object.hasOwn(i,e)&&(d=e),o(ae(d))},[o,i,e,a]);const l={};return Object.keys(i).forEach(d=>{l[d]={...i[d],saas:we[d]}}),r.jsx(G,{messages:l,children:n})};O.propTypes={messages:c.object,idiomaDefecto:c.string,children:c.element.isRequired};const $=({children:i})=>{const e=u.useDispatch(),{instancia:n}=u.useSelector(d=>d.aplicacion),o=u.useSelector(d=>d.ui.tema),a=t.useMediaQuery("(prefers-color-scheme: dark)");p.useEffect(()=>{e(oe(a?"dark":"light"))},[e,a]);const l=p.useMemo(()=>z.createTheme({palette:{mode:o,primary:{main:n.color.primary},secondary:{main:n.color.secondary},error:{main:n.color.error},warning:{main:n.color.warning},info:{main:n.color.info},success:{main:n.color.success},...o==="light"&&{background:{default:v.grey.A200,paper:v.grey[100]}}},shape:{borderRadius:6}}),[o,n]);return r.jsxs(z.ThemeProvider,{theme:l,children:[r.jsx(t.CssBaseline,{}),i]})};$.propTypes={children:c.element.isRequired};const H=i=>{const e=u.useDispatch(),n=u.useSelector(a=>a.login),o=u.useSelector(a=>a.aplicacion.instancia);return p.useEffect(()=>{n.autenticado&&n.expiracion&&new Date(n.expiracion)<new Date&&(n.refreshToken?e(C(i,o.clientCredentials,n.refreshToken)):e(_()))},[i,o.clientCredentials,n,e]),n.autenticado},V=()=>{const i=u.useDispatch();return p.useCallback((e,n="default")=>{i(ge({mensaje:e,tipo:n}))},[i])},X=({devURL:i})=>{const e=u.useDispatch(),n=S.useTranslate(),o=V(),{cargando:a,error:l}=u.useSelector(f=>f.login),d=u.useSelector(f=>f.aplicacion.instancia),A=f=>{e(q({devURL:i,clientCredentials:d.clientCredentials,data:{correo:f.correo,password:f.password}}))},Ue=f=>{const j={correo:void 0,password:void 0};return f.correo||(j.correo=n("saas.login.validacion.correo")),f.password||(j.password=n("saas.login.validacion.password")),j};return p.useEffect(()=>{l&&o("saas.login.error","error")},[o,l]),r.jsx(re.Form,{onSubmit:A,validate:Ue,render:({handleSubmit:f})=>r.jsxs("form",{onSubmit:f,children:[r.jsx(I.TextField,{id:"correo",name:"correo",label:n("saas.login.correo"),variant:"outlined",autoComplete:"off",disabled:a,autoFocus:!0,InputProps:{startAdornment:r.jsx(t.InputAdornment,{position:"start",children:r.jsx(T.Email,{color:"primary"})})}}),r.jsx(I.TextField,{id:"password",name:"password",type:"password",label:n("saas.login.password"),variant:"outlined",autoComplete:"current-password",disabled:a,InputProps:{startAdornment:r.jsx(t.InputAdornment,{position:"start",children:r.jsx(T.Lock,{color:"primary"})})}}),r.jsxs(t.Grid,{container:!0,children:[r.jsx(t.Grid,{item:!0,xs:6}),r.jsx(t.Grid,{item:!0,xs:6,align:"right",children:r.jsx(t.Button,{variant:"contained",color:"primary",type:"submit",disabled:a,children:a?r.jsx(t.CircularProgress,{size:24,thickness:4}):n("saas.login.ingresar")})})]})]})})};X.propTypes={devURL:c.string};const J=({devURL:i})=>{const e=u.useSelector(d=>d.aplicacion.instancia),n=S.useTranslate(),o=k.useLocation(),a=H(i),{from:l}=o.state||{from:{pathname:"/"}};return!e.requiereLogin||a?r.jsx(k.Navigate,{to:l}):r.jsxs(t.Box,{sx:{position:"relative",display:"flex",flexDirection:"column",flexGrow:1,minHeight:"100vh",backgroundColor:"primary.main","&::before":{content:'""',backgroundImage:`url(${e.logo})`,backgroundSize:"contain",backgroundRepeat:"no-repeat",backgroundPosition:"right",position:"absolute",top:"20%",bottom:0,right:0,width:"50%",opacity:.02,filter:"grayscale(100%)"}},children:[r.jsx(t.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",flexGrow:1},children:r.jsx(t.Container,{maxWidth:"md",children:r.jsxs(t.Grid,{container:!0,spacing:3,children:[r.jsxs(t.Grid,{item:!0,xs:12,lg:5,align:"center",children:[r.jsx("img",{src:e.logo,alt:e.nombre,style:{maxWidth:"100%"}}),r.jsx(t.Typography,{variant:"h3",align:"center",children:n("aplicacion.nombre",{smart_count:1})}),r.jsx(t.Typography,{variant:"h5",align:"center",children:e.nombre})]}),r.jsx(t.Grid,{item:!0,xs:12,lg:7,sx:{display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:r.jsxs(t.Card,{elevation:5,children:[r.jsx(t.CardHeader,{title:n("saas.login.titulo"),titleTypographyProps:{align:"center"}}),r.jsx(t.CardContent,{sx:{"& .MuiTextField-root":{mb:2}},children:r.jsx(X,{devURL:i})})]})})]})})}),r.jsx(t.AppBar,{position:"static",color:"primary",children:r.jsx(t.Toolbar,{sx:{justifyContent:"center"},children:r.jsxs(t.Typography,{variant:"caption",children:[n("saas.copy"),r.jsx(t.Link,{href:"//chimera.com.pe",color:"inherit",target:"_blank",rel:"noreferrer",children:"Chimera Software"})]})})})]})};J.propTypes={devURL:c.string};const W=({devURL:i,redirectTo:e,children:n})=>{const o=k.useLocation();return H(i)?n:r.jsx(k.Navigate,{to:e,state:{from:o},replace:!0})};W.propTypes={devURL:c.string,redirectTo:c.string.isRequired,children:c.element.isRequired};const Z=({devURL:i,requiereLogin:e,children:n})=>r.jsx(k.BrowserRouter,{children:r.jsxs(k.Routes,{children:[r.jsx(k.Route,{path:"/login",element:r.jsx(J,{devURL:i})}),r.jsx(k.Route,{path:"/*",element:e?r.jsx(W,{devURL:i,redirectTo:"/login",children:n}):n})]})});Z.propTypes={devURL:c.string,requiereLogin:c.bool,children:c.element.isRequired};const K=({devURL:i,children:e})=>{const n=u.useSelector(o=>o.aplicacion);return r.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",minHeight:"100vh",justifyContent:"flex-start",backgroundColor:"background.default"},children:n.inicializando?r.jsx(F,{}):n.error||!n.inicializado?r.jsx(N,{titulo:"saas.inicializar.error.titulo",texto:"saas.inicializar.error.mensaje"}):r.jsxs(r.Fragment,{children:[r.jsx(Z,{devURL:i,requiereLogin:n.instancia.requiereLogin,children:e}),r.jsx(Ce,{})]})})};K.propTypes={devURL:c.string,children:c.element.isRequired};const Q=({aplicacion:i,devSaasURL:e,devAuthURL:n,messages:o,idiomaDefecto:a,children:l})=>{const d=u.useDispatch();return p.useEffect(()=>{d(w({devURL:e,aplicacion:i}))},[d,i,e]),r.jsx(O,{messages:o,idiomaDefecto:a,children:r.jsx($,{children:r.jsx(K,{devURL:n,children:l})})})};Q.propTypes={aplicacion:c.string.isRequired,devSaasURL:c.string,devAuthURL:c.string,messages:c.object.isRequired,idiomaDefecto:c.string,children:c.element.isRequired};const Y=({customReducers:i,aplicacion:e,devSaasURL:n,devAuthURL:o,dev:a=!1,idiomaDefecto:l,messages:d,children:A})=>r.jsx(u.Provider,{store:qe(i),children:r.jsx(Q,{aplicacion:e,devSaasURL:a?n:void 0,devAuthURL:a?o:void 0,idiomaDefecto:l,messages:d,children:A})});Y.propTypes={customReducers:c.object,aplicacion:c.string.isRequired,devSaasURL:c.string,devAuthURL:c.string,dev:c.bool,idiomaDefecto:c.string,messages:c.object,children:c.element.isRequired};const Ae=/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,h=i=>typeof i>"u"||i===null||i===""||Array.isArray(i)&&i.length===0,g=(i,e,n,o)=>typeof i=="function"?i({args:e,value:n,values:o}):e?{message:i,args:e}:i,m=i=>D(i,(...e)=>JSON.stringify(e)),je=(...i)=>(e,n,o)=>(Array.isArray(i[0])?i[0]:i).reduce((l,d)=>l||typeof d=="function"&&d(e,n,o),void 0),Le=m((i="validacion.obligatorio")=>Object.assign((e,n)=>h(e)?g(i,void 0,e,n):void 0,{isRequired:!0})),ze=m((i="validacion.obligatorio")=>Object.assign((e,n)=>h(e)||!e?g(i,void 0,e,n):void 0,{isRequired:!0})),ve=m((i="validacion.numero")=>(e,n)=>!h(e)&&isNaN(e)?g(i,void 0,e,n):void 0),Te=m((i,e="validacion.longitud.minima")=>(n,o)=>!h(n)&&n.length<i?g(e,void 0,n,o):void 0),Ie=m((i,e="validacion.longitud.maxima")=>(n,o)=>!h(n)&&n.length>i?g(e,void 0,n,o):void 0),De=m((i,e="validacion.minimo")=>(n,o)=>!h(n)&&parseFloat(n)<i?g(e,void 0,n,o):void 0),Fe=m((i,e="validacion.maximo")=>(n,o)=>!h(n)&&parseFloat(n)>i?g(e,void 0,n,o):void 0),P=D((i,e="validacion.regex")=>(n,o)=>!h(n)&&typeof n=="string"&&!i.test(n)?g(e,void 0,n,o):void 0,(i,e)=>i.toString()+e),Ne=m((i="validacion.correo")=>P(Ae,i)),Me=m((i,e,n="validacion.remote")=>(o,a,l)=>l.active&&!h(o)&&i(o,e).then(d=>d?g(n,void 0,o,a):void 0).catch(d=>g(d.message,void 0,o,a)));s.Cargando=F,s.Error=N,s.SaasApp=Y,s.composeValidators=je,s.email=Ne,s.getInstancia=ke,s.getPerfiles=ue,s.getToken=de,s.getUsuario=le,s.logout=_,s.max=Fe,s.maxLength=Ie,s.min=De,s.minLength=Te,s.number=ve,s.regex=P,s.remote=Me,s.required=Le,s.requiredNotFalse=ze,s.useNotificar=V,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chimera-pe/react-saas",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -11,38 +11,39 @@
11
11
  "dependencies": {
12
12
  "@emotion/react": "^11.11.1",
13
13
  "@emotion/styled": "^11.11.0",
14
- "@mui/icons-material": "^5.14.8",
14
+ "@mui/icons-material": "^5.14.11",
15
15
  "@mui/lab": "^5.0.0-alpha.143",
16
- "@mui/material": "^5.14.8",
17
- "@mui/x-date-pickers": "^6.12.1",
18
- "@reduxjs/toolkit": "^1.9.5",
19
- "axios": "^1.5.0",
16
+ "@mui/material": "^5.14.11",
17
+ "@mui/x-date-pickers": "^6.15.0",
18
+ "@reduxjs/toolkit": "^1.9.6",
19
+ "axios": "^1.5.1",
20
20
  "date-fns": "^2.30.0",
21
21
  "final-form": "^4.20.10",
22
22
  "jwt-decode": "^3.1.2",
23
+ "lodash": "^4.17.21",
23
24
  "mui-rff": "^6.2.3",
24
25
  "navigator-languages": "^2.0.2",
25
26
  "node-polyglot": "^2.5.0",
26
- "react": ">=18",
27
- "react-dom": ">=18",
27
+ "react": "^18.2.0",
28
+ "react-dom": "^18.2.0",
28
29
  "react-final-form": "^6.5.9",
29
30
  "react-polyglot": "^0.7.2",
30
31
  "react-redux": "^8.1.2",
31
- "react-router-dom": "^6.15.0"
32
+ "react-router-dom": "^6.16.0"
32
33
  },
33
34
  "peerDependencies": {
34
- "react": ">=18",
35
- "react-dom": ">=18"
35
+ "react": "^18.2.0",
36
+ "react-dom": "^18.2.0"
36
37
  },
37
38
  "devDependencies": {
38
- "@types/react": "^18.2.15",
39
- "@types/react-dom": "^18.2.7",
40
- "@vitejs/plugin-react": "^4.0.3",
41
- "eslint": "^8.45.0",
42
- "eslint-plugin-react": "^7.32.2",
39
+ "@types/react": "^18.2.23",
40
+ "@types/react-dom": "^18.2.8",
41
+ "@vitejs/plugin-react": "^4.1.0",
42
+ "eslint": "^8.50.0",
43
+ "eslint-plugin-react": "^7.33.2",
43
44
  "eslint-plugin-react-hooks": "^4.6.0",
44
45
  "eslint-plugin-react-refresh": "^0.4.3",
45
- "vite": "^4.4.5"
46
+ "vite": "^4.4.9"
46
47
  },
47
48
  "description": "Componente integrador con SaaS",
48
49
  "main": "./dist/react-saas.umd.cjs",